Search is not available for this dataset
text
string
meta
dict
-- Andreas, 2017-04-28, issue #2558 reported by Youyou Cong -- Size solver assumed invariants that do not hold. open import Common.Size data Con (i : Size) : Set where c : {j : Size< i} → Con i -- needed postulate Tms : {i j : Size} → Con i → Con j → Set Ty : (i : Size) {j : Size< i} → Con j → Set sub : ∀{i}{j k : Size< i} {l : Size< j} {Γ : Con k} {Δ : Con l} → Tms Γ Δ → Ty j Δ → Ty i Γ P : ∀{A : Set} (a : A) → Set [][]T : {i : Size} {j : Size< i} {k : Size< ↑ i} {l : Size< ↑ (↑ i)} {Γ : Con l} {Δ : Con k} {Σ : Con j} {A : Ty i Σ} → (δ : Tms Δ Σ) → (σ : Tms Γ Δ) → -- Γ needed P (sub σ (sub δ A)) -- sub σ needed -- Should pass
{ "alphanum_fraction": 0.4690140845, "avg_line_length": 28.4, "ext": "agda", "hexsha": "9b9b81e6ac49c74a0528b4304206aeba49703048", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue2558.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue2558.agda", "max_line_length": 70, "max_stars_count": 2, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue2558.agda", "max_stars_repo_stars_event_max_datetime": "2020-09-20T00:28:57.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-29T09:40:30.000Z", "num_tokens": 291, "size": 710 }
module Tactic.Reflection.Reright where open import Prelude hiding (abs) open import Container.Traversable open import Tactic.Reflection open import Tactic.Reflection.Match open import Tactic.Reflection.Replace open import Tactic.Reflection.Quote private {-# TERMINATING #-} reorderVars : List Nat → Term → Term reorderVars xs (var x args) = var (maybe x id (index xs x)) (fmap (reorderVars xs) <$> args) reorderVars xs (con c args) = con c ((fmap ∘ fmap) (reorderVars xs) args) reorderVars xs (def f args) = def f (fmap (reorderVars xs) <$> args) reorderVars xs (lam v t) = lam v (reorderVars (0 ∷ weaken 1 xs) <$> t) reorderVars xs (pat-lam cs args) = pat-lam (fmap (reorderVarsInClause xs) cs) ((fmap ∘ fmap) (reorderVars xs) args) where reorderVarsInClause : List Nat → Clause → Clause -- TODO reorder patterns? reorderVarsInClause xs (clause ps t) = (clause ps (reorderVars xs t)) reorderVarsInClause xs (absurd-clause ps) = (absurd-clause ps) reorderVars xs (pi a b) = pi (reorderVars xs <$> a) (reorderVars (0 ∷ weaken 1 xs) <$> b) reorderVars xs (agda-sort (set t)) = agda-sort (set (reorderVars xs t)) reorderVars xs (agda-sort (lit n)) = agda-sort (lit n) reorderVars xs (agda-sort unknown) = agda-sort unknown reorderVars xs (lit l) = lit l reorderVars xs (meta x args) = meta x $ (fmap ∘ fmap) (reorderVars xs) args reorderVars xs unknown = unknown {-# TERMINATING #-} freeDependencies : List (Arg Type) → Type → Maybe VarSet freeDependencies Γ x = foldr _∪_ (freeVars x) <$> mapM go (freeVars x) where _∪_ : VarSet → VarSet → VarSet -- REFACTOR this was stolen from Tactic.Reflection.Free [] ∪ ys = ys xs ∪ [] = xs (x ∷ xs) ∪ (y ∷ ys) with compare x y ... | (less _) = x ∷ (xs ∪ (y ∷ ys)) ... | (equal _) = x ∷ (xs ∪ ys) ... | (greater _) = y ∷ ((x ∷ xs) ∪ ys) go : Nat → Maybe VarSet go v = weaken (suc v) $ join $ freeDependencies (drop (suc v) Γ) <$> (unArg <$> index Γ v) .test-freeDependencies₁ : freeDependencies [] unknown ≡ just [] test-freeDependencies₁ = refl .test-freeDependencies₂ : freeDependencies (vArg (var₀ 0) ∷ vArg unknown ∷ []) (var₀ 0) ≡ just (0 ∷ 1 ∷ []) test-freeDependencies₂ = refl .test-freeDependencies₃ : freeDependencies (vArg (var₀ 0) ∷ vArg (var₀ 1) ∷ vArg unknown ∷ vArg unknown ∷ []) (var₀ 0) ≡ just (0 ∷ 1 ∷ 3 ∷ []) test-freeDependencies₃ = refl .test-freeDependencies₄ : freeDependencies (vArg (var₀ 0) ∷ vArg (var₀ 1) ∷ vArg unknown ∷ vArg unknown ∷ []) (var₀ 1) ≡ just (1 ∷ 3 ∷ []) test-freeDependencies₄ = refl .test-freeDependencies₅ : freeDependencies (vArg (var₀ 1) ∷ vArg unknown ∷ vArg unknown ∷ []) (var₀ 0) ≡ just (0 ∷ 2 ∷ []) test-freeDependencies₅ = refl .test-freeDependencies₆ : freeDependencies (vArg (var₀ 0) ∷ vArg (var₀ 1) ∷ vArg unknown ∷ vArg unknown ∷ []) (var₁ 0 (var₀ 1)) ≡ just (0 ∷ 1 ∷ 3 ∷ []) test-freeDependencies₆ = refl record Request : Set where field l≡r : Term A : Type L R : Type Γᶜ : List (Arg Type) 𝐺 : Type [iᶜ∣iᶜ∈FVᴬ] : VarSet [iᶜ∣iᶜ∈FVᴬ] = maybe [] id $ freeDependencies Γᶜ A -- TODO this is a hack; I don't expect freeDependencies will return 'nothing', but if it does, I hope(!) the rest of the computation will fail [iᶜ∣iᶜ∉FVᴬ] : VarSet [iᶜ∣iᶜ∉FVᴬ] = filter (not ∘ flip elem [iᶜ∣iᶜ∈FVᴬ]) (from 0 for (length Γᶜ)) record γᶜ' : Set where field iᶜ : Nat γᶜᵢ : Arg Type iᶜ∈FVᴬ : Bool iʷ : Nat γᶜᵢ∈Γʳ : Bool gᶜᵢ : Type gᶜᵢ = unArg γᶜᵢ Γᶜ' : List γᶜ' Γᶜ' = go 0 (length Γᶜ) Γᶜ where go : Nat → Nat → List (Arg Type) → List γᶜ' go iᶜ 0 _ = [] go iᶜ _ [] = [] go iᶜ (suc n) (γᶜᵢ ∷ Γᶜ) = γᶜᵢ' ∷ go (suc iᶜ) n (weaken 1 Γᶜ) where γᶜᵢ' = record { iᶜ = iᶜ ; γᶜᵢ = γᶜᵢ ; iᶜ∈FVᴬ = elem iᶜ [iᶜ∣iᶜ∈FVᴬ] ; iʷ = if elem iᶜ [iᶜ∣iᶜ∉FVᴬ] then (length (filter (_<? iᶜ) [iᶜ∣iᶜ∉FVᴬ])) else (length [iᶜ∣iᶜ∉FVᴬ] + (length (filter (_≤? iᶜ) [iᶜ∣iᶜ∈FVᴬ]))) ; γᶜᵢ∈Γʳ = let gᶜᵢ = unArg γᶜᵢ in (isNo $ weaken 1 gᶜᵢ == weaken 1 gᶜᵢ r[ unknown / L ]) && (isNo $ l≡r == var₀ iᶜ) } [iʷ∣γᶜᵢ∈Γʳ] : VarSet [iʷ∣γᶜᵢ∈Γʳ] = iʷ <$> filter γᶜᵢ∈Γʳ Γᶜ' where open γᶜ' [iʷ] : List Nat [iʷ] = iʷ <$> Γᶜ' where open γᶜ' subsetList : {A : Set} → List A → List Nat → Maybe (List A) subsetList xs is = traverse (index xs) is module _ where private Γʷ/ᶜ : Maybe (List (Arg Type)) Γʷ/ᶜ = go [iʷ] Γᶜ where go : List Nat → List (Arg Type) → Maybe (List (Arg Type)) go _ [] = just [] go [] _ = nothing go (iʷ ∷ [iʷ]) (γᶜᵢ ∷ Γᶜ) = _∷_ <$> (strengthen (suc iʷ) $ reorderVars [iʷ] <$> γᶜᵢ) <*> (go [iʷ] Γᶜ) Γʷ/ᴬ = join $ subsetList <$> Γʷ/ᶜ <*> pure [iᶜ∣iᶜ∈FVᴬ] Γʷ/⁻ᴬ = join $ subsetList <$> Γʷ/ᶜ <*> pure [iᶜ∣iᶜ∉FVᴬ] module _ where private Lʷ = reorderVars [iʷ] L Γʷ = caseF Γʷ' of _R[ var₀ (length [iᶜ∣iᶜ∉FVᴬ]) / Lʷ ] where Γʷ' : Maybe (List (Arg Type)) Γʷ' = _++_ <$> Γʷ/⁻ᴬ <*> (_∷_ <$> (strengthen (length [iᶜ∣iᶜ∉FVᴬ] + 1) $ hArg (reorderVars [iʷ] A)) <*> Γʷ/ᴬ) where 𝐺ʷ = reorderVars [iʷ] 𝐺 r[ var₀ (length [iᶜ∣iᶜ∉FVᴬ]) / Lʷ ] module _ where private Rʷ = reorderVars [iʷ] R gʳ : Maybe Type gʳ = join $ go <$> gʳ' <*> pure [iʷ∣γᶜᵢ∈Γʳ] <*> pure 𝐺ʷʳ where go : List (Arg Type) → List Nat → Type → Maybe Type go [] [] 𝐺 = just 𝐺 go (γʷ ∷ Γʷ) (iʷ ∷ iʷs) 𝐺 = go Γʷ iʷs $ pi (weaken (1 + iʷ) γʷ) $ abs "_" $ weaken 1 𝐺 r[ var₀ 0 / var₀ $ weaken 1 iʷ ] go _ _ _ = nothing gʳ' : Maybe (List (Arg Type)) gʳ' = join $ subsetList <$> (caseF Γʷ of _R[ Rʷ / var₀ (length [iᶜ∣iᶜ∉FVᴬ]) ]) <*> pure [iʷ∣γᶜᵢ∈Γʳ] 𝐺ʷʳ = 𝐺ʷ r[ Rʷ / var₀ (length [iᶜ∣iᶜ∉FVᴬ]) ] helper-type : Maybe Type helper-type = telPi <$> (_++_ <$> (reverse <$> Γʷ) <*> (_∷_ <$> (pure $ vArg (def₂ (quote _≡_) (var₀ (length [iᶜ∣iᶜ∉FVᴬ])) Rʷ)) <*> ([_] ∘ vArg <$> (weaken 1 <$> gʳ)))) <*> pure (weaken 2 𝐺ʷ) make-vars-from-args : List Nat → List (Arg Type) → Maybe (List (Arg Type)) make-vars-from-args [] [] = pure [] make-vars-from-args (i ∷ is) (x ∷ xs) = _∷_ <$> pure (var₀ i <$ x) <*> make-vars-from-args is xs make-vars-from-args _ _ = nothing defineHelper : Name → TC ⊤ defineHelper n = maybe (typeError ( strErr "error constructing helper function type, patterns, or term" ∷ strErr "\nhelper-type:" ∷ termErr (maybe unknown id helper-type) ∷ strErr "\n`helper-type:" ∷ termErr (` helper-type) ∷ strErr "\nhelper-patterns:" ∷ termErr (` helper-patterns) ∷ strErr "\nhelper-term:" ∷ termErr (maybe unknown id helper-term) ∷ strErr "\ngʳ:" ∷ termErr (` gʳ) ∷ strErr "\nΓʷ:" ∷ termErr (` Γʷ) ∷ strErr "\n𝐺ʷ:" ∷ termErr (` 𝐺ʷ) ∷ strErr "\nl≡r:" ∷ termErr (` l≡r) ∷ strErr "\nA:" ∷ termErr (` A) ∷ strErr "\nL:" ∷ termErr (` L) ∷ strErr "\nR:" ∷ termErr (` R) ∷ strErr "\nΓᶜ:" ∷ termErr (` Γᶜ) ∷ strErr "\n𝐺:" ∷ termErr (` 𝐺) ∷ strErr "\nΓʷ/ᴬ" ∷ termErr (` Γʷ/ᴬ) ∷ strErr "\nΓʷ/⁻ᴬ" ∷ termErr (` Γʷ/⁻ᴬ) ∷ strErr "\n[iᶜ∣iᶜ∈FVᴬ]" ∷ termErr (` [iᶜ∣iᶜ∈FVᴬ]) ∷ strErr "\n[iᶜ∣iᶜ∉FVᴬ]" ∷ termErr (` [iᶜ∣iᶜ∉FVᴬ]) ∷ strErr "\n[iʷ]" ∷ termErr (` [iʷ]) ∷ [] )) (λ {(helper-type , helper-patterns , helper-term) → catchTC (define (vArg n) helper-type [ clause helper-patterns helper-term ]) (typeError ( strErr "error defining helper function" ∷ strErr "\nhelper-type:" ∷ termErr helper-type ∷ strErr "\n`helper-type:" ∷ termErr (` helper-type) ∷ strErr "\nhelper-patterns:" ∷ termErr (` helper-patterns) ∷ strErr "\nhelper-term:" ∷ termErr helper-term ∷ strErr "\n`helper-term:" ∷ termErr (` helper-term) ∷ strErr "\ngʳ:" ∷ termErr (` gʳ) ∷ strErr "\nΓʷ:" ∷ termErr (` Γʷ) ∷ strErr "\n𝐺ʷ:" ∷ termErr (` 𝐺ʷ) ∷ strErr "\nl≡r:" ∷ termErr (` l≡r) ∷ strErr "\nA:" ∷ termErr (` A) ∷ strErr "\nL:" ∷ termErr (` L) ∷ strErr "\nR:" ∷ termErr (` R) ∷ strErr "\nΓᶜ:" ∷ termErr (` Γᶜ) ∷ strErr "\n𝐺:" ∷ termErr (` 𝐺) ∷ strErr "\nΓʷ/ᴬ" ∷ termErr (` Γʷ/ᴬ) ∷ strErr "\nΓʷ/⁻ᴬ" ∷ termErr (` Γʷ/⁻ᴬ) ∷ strErr "\n[iᶜ∣iᶜ∈FVᴬ]" ∷ termErr (` [iᶜ∣iᶜ∈FVᴬ]) ∷ strErr "\n[iᶜ∣iᶜ∉FVᴬ]" ∷ termErr (` [iᶜ∣iᶜ∉FVᴬ]) ∷ strErr "\n[iʷ]" ∷ termErr (` [iʷ]) ∷ [] )) }) (_,_ <$> helper-type <*> (_,_ <$> helper-patterns <*> helper-term)) where helper-patterns : Maybe (List (Arg Pattern)) helper-patterns = (λ pa w p-a pr → pa ++ w ∷ (p-a ++ pr)) <$> (telePat ∘ reverse <$> Γʷ/ᴬ) <*> just (hArg dot) <*> (telePat ∘ reverse <$> Γʷ/⁻ᴬ) <*> pure (vArg (con₀ (quote refl)) ∷ [ vArg (var "_") ]) helper-term : Maybe Term helper-term = do γʷs ← join $ subsetList <$> Γʷ <*> pure [iʷ∣γᶜᵢ∈Γʳ] iʷs ← make-vars-from-args [iʷ∣γᶜᵢ∈Γʳ] γʷs pure (var 0 (reverse (weaken 1 iʷs))) callHelper : Name → Tactic callHelper n hole = maybe (typeError [ strErr "error constructing helper call" ]) (unify hole) $ helper-call n where helper-call : Name → Maybe Term helper-call n = def n <$> (reverse <$> (_∷_ <$> pure (vArg l≡r) <*> Γʰ)) where Γʰ : Maybe $ List $ Arg Term Γʰ = (λ xs → take (length [iᶜ∣iᶜ∉FVᴬ]) xs ++ hArg unknown ∷ drop (length [iᶜ∣iᶜ∉FVᴬ]) xs) <$> (join $ make-vars-from-args <$> pure ([iᶜ∣iᶜ∉FVᴬ] ++ [iᶜ∣iᶜ∈FVᴬ]) <*> Γʰ') where Γʰ' : Maybe (List (Arg Type)) Γʰ' = _++_ <$> subsetList Γᶜ [iᶜ∣iᶜ∉FVᴬ] <*> subsetList Γᶜ [iᶜ∣iᶜ∈FVᴬ] inferGoal : Term → TC Type inferGoal hole = unPi =<< forceFun =<< inferType hole where unPi : Type → TC Type unPi (pi _ (abs _ (meta x _))) = blockOnMeta! x unPi (pi _ (abs _ b)) = maybe (typeError (strErr "error strengthening" ∷ termErr b ∷ [])) pure $ strengthen 1 b unPi x = typeError (strErr "goal is not a pi type" ∷ termErr x ∷ []) getRequest : Term → Term → TC Request getRequest l≡r hole = do L≡R ← inferType l≡r L≡R-matched ← maybe (typeError (strErr "not an equality" ∷ termErr l≡r ∷ termErr L≡R ∷ [])) pure $ match 3 (def (quote _≡_) (hArg unknown ∷ (hArg (var₀ 0)) ∷ (vArg (var₀ 1)) ∷ (vArg (var₀ 2)) ∷ [])) L≡R 𝐺 ← inferGoal hole Γᶜ ← getContext case L≡R-matched of λ { (A ∷ L ∷ R ∷ []) → pure $ record { l≡r = l≡r ; A = A ; L = L ; R = R ; Γᶜ = Γᶜ ; 𝐺 = 𝐺 } } macro reright : Term → Tactic reright l≡r hole = do q ← getRequest l≡r hole n ← freshName "reright" let open Request q defineHelper n callHelper n hole
{ "alphanum_fraction": 0.4980877951, "avg_line_length": 47.3543307087, "ext": "agda", "hexsha": "579bdfa14a96c5257e0ea4bf1b7aef48fa8664e8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "lclem/agda-prelude", "max_forks_repo_path": "src/Tactic/Reflection/Reright.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "lclem/agda-prelude", "max_issues_repo_path": "src/Tactic/Reflection/Reright.agda", "max_line_length": 209, "max_stars_count": null, "max_stars_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "lclem/agda-prelude", "max_stars_repo_path": "src/Tactic/Reflection/Reright.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4779, "size": 12028 }
primitive primLevelMax : _
{ "alphanum_fraction": 0.7586206897, "avg_line_length": 9.6666666667, "ext": "agda", "hexsha": "fa382541d9b03e3cf6a02ee9a5cb8c1452749a36", "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/Issue3318-3.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/Issue3318-3.agda", "max_line_length": 18, "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/Issue3318-3.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": 29 }
module 10-localInstances where import Data.Empty as E open import Data.String using (String; toList; _≟_) open import Data.Bool using (Bool; true; false; if_then_else_) open import Data.Nat using (ℕ) renaming (_≟_ to _ℕ≟_) import Data.List as List open import Relation.Nullary.Decidable using (⌊_⌋) open import Function using (_on_; _∘_) record Eq (A : Set) : Set where field eq : A → A → Bool length : String → ℕ length = List.length ∘ toList open Eq {{...}} eqℕ : Eq ℕ eqℕ = record { eq = λ x x' → ⌊ x ℕ≟ x' ⌋ } eqString₁ : String → String → Bool eqString₁ s₁ s₂ = ⌊ s₁ ≟ s₂ ⌋ eqString₂ : String → String → Bool eqString₂ = eq on length test : Bool → Bool test lengthEq = if eq "abcd" "dcba" then false else true where eqLocal = record { eq = if lengthEq then eqString₂ else eqString₁ } test2 = test true
{ "alphanum_fraction": 0.6890243902, "avg_line_length": 24.8484848485, "ext": "agda", "hexsha": "c98b30f375cca3b32f8a598398e1336384c85e3b", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "larrytheliquid/agda", "max_forks_repo_path": "examples/instance-arguments/10-localInstances.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/agda", "max_issues_repo_path": "examples/instance-arguments/10-localInstances.agda", "max_line_length": 75, "max_stars_count": null, "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_path": "examples/instance-arguments/10-localInstances.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 275, "size": 820 }
------------------------------------------------------------------------------ -- Draft modules render to HTML (via an external Makefile) ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module RenderToHTML where
{ "alphanum_fraction": 0.3549160671, "avg_line_length": 37.9090909091, "ext": "agda", "hexsha": "14af6e241223cf3c16ed0fd0d8d39471ea379657", "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/RenderToHTML.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/RenderToHTML.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/RenderToHTML.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": 55, "size": 417 }
{-# OPTIONS --profile=modules --profile=internal #-}
{ "alphanum_fraction": 0.679245283, "avg_line_length": 26.5, "ext": "agda", "hexsha": "2107c8d7278b114b27fd2424e0347693c2c70ddf", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b5b3b1657556f720a7310cb7744edb1fac71eaf4", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "Seanpm2001-Agda-lang/agda", "max_forks_repo_path": "test/Fail/Issue5781c.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "b5b3b1657556f720a7310cb7744edb1fac71eaf4", "max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z", "max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "Seanpm2001-Agda-lang/agda", "max_issues_repo_path": "test/Fail/Issue5781c.agda", "max_line_length": 52, "max_stars_count": 1, "max_stars_repo_head_hexsha": "6b13364d36eeb60d8ec15eaf8effe23c73401900", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "sseefried/agda", "max_stars_repo_path": "test/Fail/Issue5781c.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-05T00:25:14.000Z", "max_stars_repo_stars_event_min_datetime": "2022-03-05T00:25:14.000Z", "num_tokens": 11, "size": 53 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Rational numbers in non-reduced form. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Rational.Unnormalised where open import Data.Integer.Base as ℤ using (ℤ; ∣_∣; +_; +0; +[1+_]; -[1+_]) open import Data.Nat as ℕ using (ℕ; zero; suc) open import Level using (0ℓ) open import Relation.Nullary using (¬_) open import Relation.Nullary.Decidable using (False) open import Relation.Binary using (Rel) open import Relation.Binary.PropositionalEquality using (_≡_) ------------------------------------------------------------------------ -- Definition -- Here we define rationals that are not necessarily in reduced form. -- Consequently there are multiple ways of representing a given rational -- number, and the performance of the arithmetic operations may suffer -- due to blowup of the numerator and denominator. -- Nonetheless they are much easier to reason about. In general proofs -- are first proved for these unnormalised rationals and then translated -- into the normalised rationals. record ℚᵘ : Set where constructor mkℚᵘ field numerator : ℤ denominator-1 : ℕ denominatorℕ : ℕ denominatorℕ = suc denominator-1 denominator : ℤ denominator = + denominatorℕ open ℚᵘ public using () renaming ( numerator to ↥_ ; denominator to ↧_ ; denominatorℕ to ↧ₙ_ ) ------------------------------------------------------------------------ -- Equality of rational numbers (does not coincide with _≡_) infix 4 _≃_ data _≃_ : Rel ℚᵘ 0ℓ where *≡* : ∀ {p q} → (↥ p ℤ.* ↧ q) ≡ (↥ q ℤ.* ↧ p) → p ≃ q ------------------------------------------------------------------------ -- Ordering of rationals infix 4 _≤_ _<_ _≥_ _>_ _≰_ _≱_ _≮_ _≯_ data _≤_ : Rel ℚᵘ 0ℓ where *≤* : ∀ {p q} → (↥ p ℤ.* ↧ q) ℤ.≤ (↥ q ℤ.* ↧ p) → p ≤ q data _<_ : Rel ℚᵘ 0ℓ where *<* : ∀ {p q} → (↥ p ℤ.* ↧ q) ℤ.< (↥ q ℤ.* ↧ p) → p < q _≥_ : Rel ℚᵘ 0ℓ x ≥ y = y ≤ x _>_ : Rel ℚᵘ 0ℓ x > y = y < x _≰_ : Rel ℚᵘ 0ℓ x ≰ y = ¬ (x ≤ y) _≱_ : Rel ℚᵘ 0ℓ x ≱ y = ¬ (x ≥ y) _≮_ : Rel ℚᵘ 0ℓ x ≮ y = ¬ (x < y) _≯_ : Rel ℚᵘ 0ℓ x ≯ y = ¬ (x > y) ------------------------------------------------------------------------ -- Constructing rationals infix 4 _≢0 _≢0 : ℕ → Set n ≢0 = False (n ℕ.≟ 0) -- An alternative constructor for ℚᵘ. See the constants section below -- for examples of how to use this operator. infixl 7 _/_ _/_ : (n : ℤ) (d : ℕ) .{d≢0 : d ≢0} → ℚᵘ n / suc d = mkℚᵘ n d ------------------------------------------------------------------------------ -- Operations on rationals infix 8 -_ 1/_ infixl 7 _*_ _÷_ infixl 6 _-_ _+_ -- negation -_ : ℚᵘ → ℚᵘ - mkℚᵘ n d = mkℚᵘ (ℤ.- n) d -- addition _+_ : ℚᵘ → ℚᵘ → ℚᵘ p + q = (↥ p ℤ.* ↧ q ℤ.+ ↥ q ℤ.* ↧ p) / (↧ₙ p ℕ.* ↧ₙ q) -- multiplication _*_ : ℚᵘ → ℚᵘ → ℚᵘ p * q = (↥ p ℤ.* ↥ q) / (↧ₙ p ℕ.* ↧ₙ q) -- subtraction _-_ : ℚᵘ → ℚᵘ → ℚᵘ p - q = p + (- q) -- reciprocal: requires a proof that the numerator is not zero 1/_ : (p : ℚᵘ) → .{n≢0 : ∣ ↥ p ∣ ≢0} → ℚᵘ 1/ mkℚᵘ +[1+ n ] d = mkℚᵘ +[1+ d ] n 1/ mkℚᵘ -[1+ n ] d = mkℚᵘ -[1+ d ] n -- division: requires a proof that the denominator is not zero _÷_ : (p q : ℚᵘ) → .{n≢0 : ∣ ↥ q ∣ ≢0} → ℚᵘ (p ÷ q) {n≢0} = p * (1/_ q {n≢0}) ------------------------------------------------------------------------------ -- Some constants 0ℚᵘ : ℚᵘ 0ℚᵘ = + 0 / 1 1ℚᵘ : ℚᵘ 1ℚᵘ = + 1 / 1 ½ : ℚᵘ ½ = + 1 / 2 -½ : ℚᵘ -½ = - ½
{ "alphanum_fraction": 0.4890469417, "avg_line_length": 22.9738562092, "ext": "agda", "hexsha": "40ad40eb688b3637da6ae18defa11ff71fb56478", "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/Rational/Unnormalised.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/Rational/Unnormalised.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/Rational/Unnormalised.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": 1375, "size": 3515 }
-------------------------------------------------------------------------------- -- This is part of Agda Inference Systems {-# OPTIONS --sized-types #-} open import Codata.Colist open import Codata.Thunk open import Size open import Data.Empty open import Relation.Binary.PropositionalEquality module Examples.Colists.Auxiliary.Colist_member {A : Set} where data _∈_ : A → Colist A ∞ → Set where here : ∀ {x xs} → x ∈ (x ∷ xs) there : ∀{x y xs} → x ∈ xs .force → x ∈ (y ∷ xs) mem-abs : ∀{x xs} → x ∈ xs → xs ≡ [] → ⊥ mem-abs {_} {.[]} () refl
{ "alphanum_fraction": 0.5365418895, "avg_line_length": 29.5263157895, "ext": "agda", "hexsha": "5682b4551eebf681b1696fac5134784c6c81e356", "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": "b9043f99e4bf7211db4066a7a943401d127f0c8f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "LcicC/inference-systems-agda", "max_forks_repo_path": "Examples/Colists/Auxiliary/Colist_member.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b9043f99e4bf7211db4066a7a943401d127f0c8f", "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": "LcicC/inference-systems-agda", "max_issues_repo_path": "Examples/Colists/Auxiliary/Colist_member.agda", "max_line_length": 80, "max_stars_count": 3, "max_stars_repo_head_hexsha": "b9043f99e4bf7211db4066a7a943401d127f0c8f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "LcicC/inference-systems-agda", "max_stars_repo_path": "Examples/Colists/Auxiliary/Colist_member.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-25T15:48:52.000Z", "max_stars_repo_stars_event_min_datetime": "2022-03-10T15:53:47.000Z", "num_tokens": 159, "size": 561 }
-- Andreas, 2022-03-11, issue #5823 -- Make sure we do not weaken the singleton detection too much by checking for loops. open import Agda.Builtin.Nat record ⊤ : Set where record Wrap (A : Set) : Set where field unwrap : A record _×_ (A B : Set) : Set where field fst : A snd : B -- A singleton record type with nestings of Wrap. Singleton = (Wrap ⊤ × Wrap (Wrap ⊤)) × Wrap (Wrap (Wrap ⊤ × ⊤) × Wrap ⊤) -- Agda should solve this meta: unique : Singleton unique = _ -- This is fine, even though we pass through 'Wrap' several times. -- Passing already visited non-recursive records is fine! mutual record S (n : Nat) : Set where inductive; eta-equality field inn : T n T : Nat → Set T zero = ⊤ T (suc n) = T n × S n -- S n is a eta singleton type for each n because it is terminating. inh5 : S 5 inh5 = _
{ "alphanum_fraction": 0.650887574, "avg_line_length": 20.6097560976, "ext": "agda", "hexsha": "c862f023b36a42acecf9856bbbaf255f3ccf4f46", "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/Succeed/Issue5823.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/Succeed/Issue5823.agda", "max_line_length": 85, "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/Succeed/Issue5823.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 261, "size": 845 }
{-# OPTIONS --cubical --no-import-sorts --allow-unsolved-metas #-} module Number.Structures2 where open import Agda.Primitive renaming (_⊔_ to ℓ-max; lsuc to ℓ-suc; lzero to ℓ-zero) open import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc) open import Cubical.Relation.Nullary.Base renaming (¬_ to ¬ᵗ_)-- ¬ᵗ_ open import Cubical.Foundations.Logic open import Cubical.Data.Sum.Base renaming (_⊎_ to infixr 4 _⊎_) open import Cubical.Data.Sigma renaming (_×_ to infixr 4 _×_) open import Utils open import MoreLogic.Definitions open import MoreLogic.Properties open import MorePropAlgebra.Definitions open import MorePropAlgebra.Consequences open import MorePropAlgebra.Structures {- | name | struct | apart | abs | order | cauchy | sqrt₀⁺ | exp | final name | |------|---------------------|-------|-----|-------|--------|---------|-----|------------------------------------------------------------------------| | ℕ | CommSemiring | (✓) | (✓) | lin. | | (on x²) | | LinearlyOrderedCommSemiring | | ℤ | CommRing | (✓) | (✓) | lin. | | (on x²) | | LinearlyOrderedCommRing | | ℚ | Field | (✓) | (✓) | lin. | | (on x²) | (✓) | LinearlyOrderedField | | ℝ | Field | (✓) | (✓) | part. | ✓ | ✓ | (✓) | CompletePartiallyOrderedFieldWithSqrt | | ℂ | euclidean 2-Product | (✓) | (✓) | | (✓) | | ? | EuclideanTwoProductOfCompletePartiallyOrderedFieldWithSqrt | | R | Ring | ✓ | ✓ | | | | ? | ApartnessRingWithAbsIntoCompletePartiallyOrderedFieldWithSqrt | | G | Group | ✓ | ✓ | | | | ? | ApartnessGroupWithAbsIntoCompletePartiallyOrderedFieldWithSqrt | | K | Field | ✓ | ✓ | | ✓ | | ? | CompleteApartnessFieldWithAbsIntoCompletePartiallyOrderedFieldWithSqrt | -- NOTE: what about conjugation `conj`? -} -- we usually mean "CommRing" when writing just "Ring" ⇒ TODO: rename this where applicable -- this is ℕ record IsLinearlyOrderedCommSemiring {ℓ ℓ'} {F : Type ℓ} (0f 1f : F) (_+_ _·_ : F → F → F) (_<_ : hPropRel F F ℓ') (min max : F → F → F) : Type (ℓ-max ℓ ℓ') where constructor islinearlyorderedcommsemiring infixl 4 _#_ infixl 4 _≤_ -- ≤, as in Lemma 4.1.7 _≤_ : hPropRel F F ℓ' x ≤ y = ¬ (y < x) field is-CommSemiring : [ isCommSemiring 0f 1f _+_ _·_ ] <-StrictLinearOrder : [ isStrictLinearOrder _<_ ] ≤-Lattice : [ isLattice _≤_ min max ] +-<-ext : ∀ w x y z → [ (w + x) < (y + z) ] → [ (w < y) ⊔ (x < z) ] ·-preserves-< : ∀ x y z → [ 0f < z ] → [ x < y ] → [ (x · z) < (y · z) ] open IsCommSemiring is-CommSemiring public open IsStrictLinearOrder <-StrictLinearOrder public renaming ( is-irrefl to <-irrefl ; is-trans to <-trans ; is-tricho to <-trichoᵗ ) abstract <-asym : ∀ a b → [ a < b ] → [ ¬ b < a ] -- [ isAsym _<_ ] <-asym = irrefl+trans⇒asym _<_ <-irrefl <-trans <-irrefl'' : ∀ a b → ([ a < b ] ⊎ [ b < a ]) → [ ¬(a ≡ₚ b) ] <-irrefl'' = isIrrefl'⇔isIrrefl'' _<_ <-asym .fst (isIrrefl⇔isIrrefl' _<_ .fst <-irrefl) <-irreflˢ'' : ∀ a b → ([ a < b ] ⊎ [ b < a ]) → ¬ᵗ(a ≡ b) <-irreflˢ'' = isIrreflˢ''⇔isIrrefl'' _<_ is-set <-asym .snd <-irrefl'' <-tricho : ∀ a b → ([ a < b ] ⊎ [ b < a ]) ⊎ (a ≡ b) <-tricho = isTrichotomousˢ⇔isTrichotomous _<_ is-set <-irrefl'' <-irreflˢ'' <-asym .snd <-trichoᵗ <-StrictPartialOrder : [ isStrictPartialOrder _<_ ] <-StrictPartialOrder = strictlinearorder⇒strictpartialorder _<_ <-StrictLinearOrder -- ≤-PartialOrder : [ isPartialOrder _≤_ ] -- ≤-PartialOrder = {! linearorder⇒partialorder !} ≤-LinearOrder : [ isLinearOrder _≤_ ] ≤-LinearOrder = ≤'-isLinearOrder <-StrictLinearOrder ≤-Preorder : [ isPreorder _≤_ ] ≤-Preorder = ≤'-isPreorder <-StrictPartialOrder -- # is defined as in Lemma 4.1.7 _#_ : hPropRel F F ℓ' x # y = [ <-asym x y ] (x < y) ⊎ᵖ (y < x) #-ApartnessRel : [ isApartnessRel _#_ ] #-ApartnessRel = #''-isApartnessRel <-StrictPartialOrder <-asym open IsApartnessRel #-ApartnessRel public renaming ( is-irrefl to #-irrefl ; is-sym to #-sym ; is-cotrans to #-cotrans ) _ : [ isCommSemiring 0f 1f _+_ _·_ ]; _ = is-CommSemiring _ : [ isStrictLinearOrder _<_ ]; _ = <-StrictLinearOrder _ : [ isLattice _≤_ min max ]; _ = ≤-Lattice open IsLattice ≤-Lattice renaming (≤-antisym to ≤-antisymᵗ) public ≤-antisym : [ isAntisymˢ _≤_ is-set ] ≤-antisym = isAntisymˢ⇔isAntisym _≤_ is-set .snd ≤-antisymᵗ isLinearlyOrderedCommSemiring : ∀{ℓ ℓ'} {F : Type ℓ} (0f 1f : F) (_+_ _·_ : F → F → F) (_<_ : hPropRel F F ℓ') (min max : F → F → F) → hProp (ℓ-max ℓ ℓ') isLinearlyOrderedCommSemiring 0f 1f _+_ _·_ _<_ min max .fst = IsLinearlyOrderedCommSemiring 0f 1f _+_ _·_ _<_ min max isLinearlyOrderedCommSemiring 0f 1f _+_ _·_ _<_ min max .snd = φ where abstract φ = {! !} -- this is ℤ record IsLinearlyOrderedCommRing {ℓ ℓ'} {F : Type ℓ} (0f 1f : F) (_+_ _·_ : F → F → F) (-_ : F → F) (_<_ : hPropRel F F ℓ') (min max : F → F → F) : Type (ℓ-max ℓ ℓ') where constructor islinearlyorderedcommring field is-LinearlyOrderedCommSemiring : [ isLinearlyOrderedCommSemiring 0f 1f _+_ _·_ _<_ min max ] +-inverse : ∀ x → (x + (- x) ≡ 0f) × ((- x) + x ≡ 0f) infixl 6 _-_ _-_ : F → F → F x - y = x + (- y) +-linv : (x : F) → (- x) + x ≡ 0f +-linv x = +-inverse x .snd +-rinv : (x : F) → x + (- x) ≡ 0f +-rinv x = +-inverse x .fst open IsLinearlyOrderedCommSemiring is-LinearlyOrderedCommSemiring public isLinearlyOrderedCommRing : ∀{ℓ ℓ'} {F : Type ℓ} (0f 1f : F) (_+_ _·_ : F → F → F) (-_ : F → F) (_<_ : hPropRel F F ℓ') (min max : F → F → F) → hProp (ℓ-max ℓ ℓ') isLinearlyOrderedCommRing 0f 1f _+_ _·_ -_ _<_ min max .fst = IsLinearlyOrderedCommRing 0f 1f _+_ _·_ -_ _<_ min max isLinearlyOrderedCommRing 0f 1f _+_ _·_ -_ _<_ min max .snd = φ where abstract φ = {! !} -- this is ℚ record IsLinearlyOrderedField {ℓ ℓ'} {F : Type ℓ} (0f 1f : F) (_+_ _·_ : F → F → F) (-_ : F → F) (_<_ : hPropRel F F ℓ') (min max : F → F → F) : Type (ℓ-max ℓ ℓ') where constructor islinearlyorderedfield field is-LinearlyOrderedCommRing : [ isLinearlyOrderedCommRing 0f 1f _+_ _·_ (-_) _<_ min max ] open IsLinearlyOrderedCommRing is-LinearlyOrderedCommRing public field ·-inv'' : ∀ x → [ (∃[ y ] ([ is-set ] (x · y) ≡ˢ 1f)) ⇔ (x # 0f) ] isLinearlyOrderedField : ∀{ℓ ℓ'} {F : Type ℓ} (0f 1f : F) (_+_ _·_ : F → F → F) (-_ : F → F) (_<_ : hPropRel F F ℓ') (min max : F → F → F) → hProp (ℓ-max ℓ ℓ') isLinearlyOrderedField 0f 1f _+_ _·_ -_ _<_ min max .fst = IsLinearlyOrderedField 0f 1f _+_ _·_ -_ _<_ min max isLinearlyOrderedField 0f 1f _+_ _·_ -_ _<_ min max .snd = φ where abstract φ = {! !} -- this is ℝ record IsCompletePartiallyOrderedFieldWithSqrt {ℓ ℓ'} {F : Type ℓ} (0f 1f : F) (_+_ _·_ : F → F → F) (-_ : F → F) (_<_ : hPropRel F F ℓ') (min max : F → F → F) (sqrt : (x : F) → {{ ! [ ¬(x < 0f) ] }} → F) : Type (ℓ-max ℓ ℓ') where constructor iscompletepartiallyorderedfield field -- 1. 2. 3. 4. 5. 6. (†) and (∗) is-PartiallyOrderedField : [ isPartiallyOrderedField 0f 1f _+_ _·_ -_ _<_ min max ]
{ "alphanum_fraction": 0.548745426, "avg_line_length": 48.1257861635, "ext": "agda", "hexsha": "748ad8f63ed776ac2a90d6afd6a36f9ed24ae2f7", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mchristianl/synthetic-reals", "max_forks_repo_path": "agda/Number/Structures2.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mchristianl/synthetic-reals", "max_issues_repo_path": "agda/Number/Structures2.agda", "max_line_length": 230, "max_stars_count": 3, "max_stars_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mchristianl/synthetic-reals", "max_stars_repo_path": "agda/Number/Structures2.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-19T12:15:21.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-31T18:15:26.000Z", "num_tokens": 2878, "size": 7652 }
{- Definition of join for ◇ and associated lemmas. -} module TemporalOps.Diamond.Join where open import CategoryTheory.Categories open import CategoryTheory.Instances.Reactive open import CategoryTheory.Functor open import CategoryTheory.NatTrans open import CategoryTheory.Monad open import TemporalOps.Common open import TemporalOps.Next open import TemporalOps.Delay open import TemporalOps.Diamond.Functor import Relation.Binary.PropositionalEquality as ≡ open import Data.Product open import Relation.Binary.HeterogeneousEquality as ≅ using (_≅_ ; ≅-to-≡ ; ≡-to-≅ ; cong₂) open import Data.Nat.Properties using (+-identityʳ ; +-comm ; +-suc ; +-assoc) open import Holes.Term using (⌞_⌟) open import Holes.Cong.Propositional -- | Auxiliary definitions for μ -- Shifting an event by some interval μ-shift : {A : τ} -> (k n : ℕ) -> ◇ A at n -> ◇ A at (k + n) μ-shift {A} k n (l , v) = k + l , rew (sym (delay-+ k l n)) v -- Auxiliary function for μ, taking the comparison of the delay and -- time index as an argument μ-compare : (A : τ) -> (n k : ℕ) -> (v : delay ◇ A by k at n) -> LeqOrdering k n -> ◇ A at n μ-compare A .(k + l) k v snd==[ .k + l ] = μ-shift k l (rew (delay-+-left0 k l) v) μ-compare A n .(n + suc l) v fst==suc[ .n + l ] = n + suc l , rew (delay-⊤ n l) top.tt private module F-◇ = Functor F-◇ -- Join for ◇ μ-◇ : (F-◇ ²) ⟹ F-◇ μ-◇ = record { at = μ-◇-at ; nat-cond = λ {A} {B} {f} {n} {a} -> μ-◇-nat-cond {A} {B} {f} {n} {a} } where open Functor private module F-▹ = Functor F-▹ open ≡.≡-Reasoning -- The order of mapping and shifting of events can be interchanged μ-shift-fmap : {A B : τ} {f : A ⇴ B} {k l : ℕ} {a : ◇ A at l} -> F-◇.fmap f (k + l) (μ-shift {A} k l a) ≡ μ-shift {B} k l (F-◇.fmap f l a) μ-shift-fmap {A} {B} {f} {zero} {l} {j , y} = refl μ-shift-fmap {A} {B} {f} {suc k} {l} {j , y} rewrite μ-shift-fmap {A} {B} {f} {k} {l} {j , y} = cong (λ x → suc k + j , x) (fmap-delay-+-k k j l y) -- Join for ◇ μ-◇-at : (A : τ) -> ◇ ◇ A ⇴ ◇ A μ-◇-at A n (k , v) = μ-compare A n k v (compareLeq k n) -- Naturality proof μ-◇-nat-cond : ∀{A B : τ} {f : A ⇴ B} {n : ℕ} {a : ◇ ◇ A at n} -> F-◇.fmap f n (μ-◇-at A n a) ≡ μ-◇-at B n (Functor.fmap (F-◇ ²) f n a) μ-◇-nat-cond {A} {B} {f} {n} {k , v} with inspect (compareLeq k n) -- n = k + l μ-◇-nat-cond {A} {B} {f} {.(k + l)} {k , v} | snd==[ .k + l ] with≡ pf = begin F-◇.fmap f (k + l) (μ-◇-at A (k + l) (k , v)) ≡⟨⟩ -- Def. of μ-◇-at F-◇.fmap f (k + l) (μ-compare A (k + l) k v ⌞ compareLeq k (k + l) ⌟) ≡⟨ cong! pf ⟩ F-◇.fmap f (k + l) (μ-shift k l (rew (delay-+-left0 k l) v)) ≡⟨ μ-shift-fmap {_}{_}{_}{k}{l}{(rew (delay-+-left0 k l) v)} ⟩ μ-shift k l (F-◇.fmap f l ⌞ rew (delay-+-left0 k l) v ⌟) ≡⟨ cong! (delay-+-left0-eq k l v v′ v≅v′) ⟩ μ-shift k l (F-◇.fmap f l (rew (delay-+ k 0 l) v′)) ≡⟨⟩ -- Def. of (F-delay 0).fmap μ-shift k l ((Functor.fmap (F-delay 0) (F-◇.fmap f) at l) (rew (delay-+ k 0 l) v′)) ≡⟨ cong (λ x → μ-shift k l x) (sym (fmap-delay-+-n+k k 0 l v′)) ⟩ μ-shift k l ⌞ rew (delay-+ k 0 l) ((Functor.fmap (F-delay (k + 0)) (F-◇.fmap f) at (k + l)) v′) ⌟ ≡⟨ cong! (sym (delay-+-left0-eq k l ((Functor.fmap (F-delay k) (F-◇.fmap f) at (k + l)) v) ((Functor.fmap (F-delay (k + 0)) (F-◇.fmap f) at (k + l)) v′) pr)) ⟩ μ-shift k l (rew (delay-+-left0 k l) ((Functor.fmap (F-delay k) (F-◇.fmap f) at (k + l)) v)) ≡⟨⟩ -- Def. of μ-compare μ-compare B (k + l) k ((Functor.fmap (F-delay k) (F-◇.fmap f) at (k + l)) v) (snd==[ k + l ]) ≡⟨ cong (λ x → μ-compare B (k + l) k ((Functor.fmap (F-delay k) (F-◇.fmap f) at (k + l)) v) x) (sym pf) ⟩ μ-compare B (k + l) k ((Functor.fmap (F-delay k) (F-◇.fmap f) at (k + l)) v) (compareLeq k (k + l)) ≡⟨⟩ -- Folding definitions μ-◇-at B (k + l) (fmap (F-◇ ²) f (k + l) (k , v)) ∎ where v′ : delay (◇ A) by (k + 0) at (k + l) v′ = rew (delay-+0-left k (k + l)) v v≅v′ : v ≅ v′ v≅v′ = rew-to-≅ (delay-+0-left k (k + l)) pr : (Functor.fmap (F-delay k) (F-◇.fmap f) at (k + l)) v ≅ (Functor.fmap (F-delay (k + 0)) (F-◇.fmap f) at (k + l)) v′ pr = cong₂ (λ x y → (Functor.fmap (F-delay x) (F-◇.fmap f) at (k + l)) y) (≡-to-≅ (sym (+-identityʳ k))) v≅v′ -- k = suc n + l μ-◇-nat-cond {A} {B} {f} {.n} {.(n + suc l) , v} | fst==suc[ n + l ] with≡ pf = begin F-◇.fmap f n (μ-◇-at A n (n + suc l , v)) ≡⟨⟩ -- Def. of μ-◇-at F-◇.fmap f n (μ-compare A n (n + suc l) v ⌞ compareLeq (n + suc l) n ⌟) ≡⟨ cong! pf ⟩ F-◇.fmap f n (n + suc l , rew (delay-⊤ n l) top.tt) ≡⟨⟩ -- Def. of F-◇.fmap n + suc l , (Functor.fmap (F-delay (n + suc l)) f at n) (rew (delay-⊤ n l) top.tt) ≡⟨ cong (λ x → n + suc l , x) (eq n l) ⟩ n + suc l , rew (delay-⊤ n l) top.tt ≡⟨⟩ -- Def. of μ-compare μ-compare B n (n + suc l) ((Functor.fmap (F-delay ((n + suc l))) (F-◇.fmap f) at n) v) (fst==suc[ n + l ]) ≡⟨ cong (λ x → μ-compare B n (n + suc l) ((Functor.fmap (F-delay (n + suc l)) (F-◇.fmap f) at n) v) x) (sym pf) ⟩ μ-compare B n (n + suc l) ((Functor.fmap (F-delay (n + suc l)) (F-◇.fmap f) at n) v) (compareLeq (n + suc l) n) ≡⟨⟩ -- Def. of μ-◇-at μ-◇-at B n (Functor.fmap (F-◇ ²) f n (n + suc l , v)) ∎ where eq : ∀ (n l : ℕ) -> (Functor.fmap (F-delay (n + suc l)) f at n) (rew (delay-⊤ n l) top.tt) ≡ rew (delay-⊤ n l) top.tt eq zero l = refl eq (suc n) l = eq n l
{ "alphanum_fraction": 0.4691872085, "avg_line_length": 44.1470588235, "ext": "agda", "hexsha": "888fdd9ebb2e23a4feeb9d9139aed6a9a502b109", "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": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DimaSamoz/temporal-type-systems", "max_forks_repo_path": "src/TemporalOps/Diamond/Join.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "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": "DimaSamoz/temporal-type-systems", "max_issues_repo_path": "src/TemporalOps/Diamond/Join.agda", "max_line_length": 123, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DimaSamoz/temporal-type-systems", "max_stars_repo_path": "src/TemporalOps/Diamond/Join.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-04T09:33:48.000Z", "max_stars_repo_stars_event_min_datetime": "2018-05-31T20:37:04.000Z", "num_tokens": 2572, "size": 6004 }
module Issue760 where module M where A : Set₂ A = Set₁ abstract B : Set₁ B = Set open M public -- Not abstract. C : Set₁ C = F where F = Set -- where clauses declare an anonymous open public module -- but we should not see any error here InScope : A InScope = Set private D : Set₁ D = Set open M public -- Private & public?! E : Set₁ E = F where F = Set -- where clauses declare an anonymous open public module -- but we should not see any error here
{ "alphanum_fraction": 0.6177606178, "avg_line_length": 16.1875, "ext": "agda", "hexsha": "830cfd2ebbd78ec824797f6b744c2b3626ee44c5", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-06-14T11:07:38.000Z", "max_forks_repo_forks_event_min_datetime": "2021-06-14T11:07:38.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue760.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue760.agda", "max_line_length": 68, "max_stars_count": 2, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue760.agda", "max_stars_repo_stars_event_max_datetime": "2020-09-20T00:28:57.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-29T09:40:30.000Z", "num_tokens": 150, "size": 518 }
open import prelude -- Copied pretty much verbatim data Term : Set where true : Term false : Term if_then_else_end : Term → Term → Term → Term zero : Term succ : Term → Term iszero : Term → Term data NValue : Term → Set where zero : NValue zero succ : ∀ {t} → NValue(t) → NValue(succ t) data Value : Term → Set where true : Value true false : Value false nv : ∀ {t} → NValue(t) → Value(t) data _⟶_ : Term → Term → Set where E─IfTrue : ∀ {t₂ t₃} → ----------------------------------- if true then t₂ else t₃ end ⟶ t₂ E─IfFalse : ∀ {t₂ t₃} → ----------------------------------- if false then t₂ else t₃ end ⟶ t₃ E─IfCong : ∀ {t₁ t₁′ t₂ t₃} → (t₁ ⟶ t₁′) → ---------------------------------------------------------- (if t₁ then t₂ else t₃ end ⟶ if t₁′ then t₂ else t₃ end) E─SuccCong : ∀ {t₁ t₁′} → (t₁ ⟶ t₁′) → ---------------------- (succ t₁ ⟶ succ t₁′) E─IsZero : ---------------------- (iszero zero ⟶ true) E─IsSucc : ∀ {n} → -------------------------- (iszero (succ n) ⟶ false) E─IsCong : ∀ {t₁ t₁′} → (t₁ ⟶ t₁′) → -------------------------- (iszero t₁ ⟶ iszero t₁′) data Redex : Term → Set where redex : ∀ {t t′} → t ⟶ t′ → -------- Redex(t) -- Types data Type : Set where bool : Type nat : Type data _∈_ : Term → Type → Set where T-True : ----------- true ∈ bool T-False : ----------- false ∈ bool T-If : ∀ {t₁ t₂ t₃ T} → t₁ ∈ bool → t₂ ∈ T → t₃ ∈ T → ----------------------------- if t₁ then t₂ else t₃ end ∈ T T-Zero : ---------- zero ∈ nat T-Succ : ∀ {t₁} → t₁ ∈ nat → ------------- succ t₁ ∈ nat T-IsZero : ∀ {t₁} → t₁ ∈ nat → ------------- iszero t₁ ∈ bool -- Proving that well-typed terms stay well-typed preservation : ∀ {t t′ T} → (t ∈ T) → (t ⟶ t′) → (t′ ∈ T) preservation (T-If p₁ p₂ p₃) E─IfTrue = p₂ preservation (T-If p₁ p₂ p₃) E─IfFalse = p₃ preservation (T-If p₁ p₂ p₃) (E─IfCong q) = T-If (preservation p₁ q) p₂ p₃ preservation (T-Succ p) (E─SuccCong q) = T-Succ (preservation p q) preservation (T-IsZero p) E─IsZero = T-True preservation (T-IsZero p) E─IsSucc = T-False preservation (T-IsZero p) (E─IsCong q) = T-IsZero (preservation p q) -- Proving that every term is a value or a redex data ValueOrRedex : Term → Set where value : ∀ {t} → (Value(t)) → --------------- ValueOrRedex(t) redex : ∀ {t t′} → t ⟶ t′ → --------------- ValueOrRedex(t) progress : ∀ {t T} → (t ∈ T) → ValueOrRedex(t) progress T-True = value true progress T-False = value false progress (T-If p₁ p₂ p₃) = helper (progress p₁) p₁ where helper : ∀ {t₀ t₁ t₂} → ValueOrRedex(t₀) → t₀ ∈ bool → ValueOrRedex(if t₀ then t₁ else t₂ end) helper (value true) p = redex E─IfTrue helper (value false) p = redex E─IfFalse helper (redex r) p = redex (E─IfCong r) helper (value (nv ())) T-True helper (value (nv ())) T-False helper (value (nv ())) (T-If p p₁ p₂) progress T-Zero = value (nv zero) progress (T-Succ p) = helper (progress p) p where helper : ∀ {t₀} → ValueOrRedex(t₀) → t₀ ∈ nat → ValueOrRedex(succ t₀) helper (value (nv n)) p = value (nv (succ n)) helper (redex r) p = redex (E─SuccCong r) progress (T-IsZero p) = helper (progress p) p where helper : ∀ {t₀} → ValueOrRedex(t₀) → t₀ ∈ nat → ValueOrRedex(iszero t₀) helper (value (nv zero)) p = redex E─IsZero helper (value (nv (succ x))) p = redex E─IsSucc helper (redex r) p = redex (E─IsCong r) -- Interpreter data _⟶*_ : Term → Term → Set where done : ∀ {t} → -------- t ⟶* t redex : ∀ {t t′ t″} → t ⟶ t′ → t′ ⟶* t″ → ---------- t ⟶* t″ -- An interpreter result data Result : Term → Set where result : ∀ {t t′} → t ⟶* t′ → Value(t′) → --------- Result(t) -- The interpreter just calls `progress` until it is a value. -- This might bot terminate! {-# NON_TERMINATING #-} interp : ∀ {t T} → (t ∈ T) → Result(t) interp p = helper₂ p (progress p) where helper₁ : ∀ {t t′} → (t ⟶ t′) → Result(t′) → Result(t) helper₁ r (result s v) = result (redex r s) v helper₂ : ∀ {t T} → (t ∈ T) → ValueOrRedex(t) → Result(t) helper₂ p (value v) = result done v helper₂ p (redex r) = helper₁ r (interp (preservation p r)) ex = if (iszero zero) then (succ zero) else (zero) end exNat : (ex ∈ nat) exNat = T-If (T-IsZero T-Zero) (T-Succ T-Zero) T-Zero -- Normalize (C-N) interp exNat -- result -- (redex (E─IfCong E─IsZero) -- (redex E─IfTrue -- done)) -- (nv (succ zero))
{ "alphanum_fraction": 0.5120274914, "avg_line_length": 21.1636363636, "ext": "agda", "hexsha": "4a3e1bbe23385d1d1181721ce5116d801f9123df", "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": "de2ae6c24d001b85a5032c9e06cc731557dbc5e5", "max_forks_repo_licenses": [ "CC0-1.0" ], "max_forks_repo_name": "asajeffrey/tapl", "max_forks_repo_path": "ch8.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "de2ae6c24d001b85a5032c9e06cc731557dbc5e5", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC0-1.0" ], "max_issues_repo_name": "asajeffrey/tapl", "max_issues_repo_path": "ch8.agda", "max_line_length": 96, "max_stars_count": 3, "max_stars_repo_head_hexsha": "de2ae6c24d001b85a5032c9e06cc731557dbc5e5", "max_stars_repo_licenses": [ "CC0-1.0" ], "max_stars_repo_name": "asajeffrey/tapl", "max_stars_repo_path": "ch8.agda", "max_stars_repo_stars_event_max_datetime": "2021-03-15T12:09:59.000Z", "max_stars_repo_stars_event_min_datetime": "2021-03-12T22:44:19.000Z", "num_tokens": 1721, "size": 4656 }
------------------------------------------------------------------------ -- A definition of the propositional truncation operator that does not -- use recursive higher inductive types ------------------------------------------------------------------------ -- The definition does use natural numbers. The code is based on van -- Doorn's "Constructing the Propositional Truncation using -- Non-recursive HITs". {-# OPTIONS --erased-cubical --safe #-} import Equality.Path as P module H-level.Truncation.Propositional.Non-recursive {e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where private open module PD = P.Derived-definitions-and-properties eq hiding (elim) open import Prelude open import Colimit.Sequential eq as C using (Colimit) open import Equality.Decidable-UIP equality-with-J open import Equality.Path.Isomorphisms eq open import Equivalence equality-with-J as Eq using (_≃_) open import Function-universe equality-with-J as F open import H-level equality-with-J open import H-level.Closure equality-with-J import H-level.Truncation.Propositional eq as T open import H-level.Truncation.Propositional.Non-recursive.Erased eq as N using (∥_∥ᴱ) open import H-level.Truncation.Propositional.One-step eq as O using (∥_∥¹; ∥_∥¹-out-^; ∣_∣-out-^) private variable a p : Level A B : Type a P : A → Type p e x : A -- The propositional truncation operator. ∥_∥ : Type a → Type a ∥ A ∥ = Colimit ∥ A ∥¹-out-^ O.∣_∣ -- The point constructor. ∣_∣ : A → ∥ A ∥ ∣_∣ = C.∣_∣ -- The eliminator. record Elim {A : Type a} (P : ∥ A ∥ → Type p) : Type (a ⊔ p) where no-eta-equality field ∣∣ʳ : ∀ x → P ∣ x ∣ is-propositionʳ : ∀ x → Is-proposition (P x) open Elim public elim : Elim P → (x : ∥ A ∥) → P x elim {A = A} {P = P} e = C.elim λ where .C.Elim.∣∣ʳ {n = n} → helper n .C.Elim.∣∣≡∣∣ʳ _ → E.is-propositionʳ _ _ _ where module E = Elim e helper : ∀ n (x : ∥ A ∥¹-out-^ n) → P C.∣ x ∣ helper zero = E.∣∣ʳ helper (suc n) = O.elim λ where .O.Elim.∣∣ʳ x → subst P (sym (C.∣∣≡∣∣ x)) (helper n x) .O.Elim.∣∣-constantʳ _ _ → E.is-propositionʳ _ _ _ _ : elim e ∣ x ∣ ≡ e .∣∣ʳ x _ = refl _ -- The propositional truncation operator returns propositions. ∥∥-proposition : Is-proposition ∥ A ∥ ∥∥-proposition {A = A} = elim λ where .is-propositionʳ → Π≡-proposition ext .∣∣ʳ x → C.elim λ where .C.Elim.∣∣ʳ → lemma₁ _ x .C.Elim.∣∣≡∣∣ʳ {n = n} y → subst (∣ x ∣ ≡_) (C.∣∣≡∣∣ y) (lemma₁ (suc n) x O.∣ y ∣) ≡⟨ sym trans-subst ⟩ trans (lemma₁ (1 + n) x O.∣ y ∣) (C.∣∣≡∣∣ y) ≡⟨⟩ trans (trans (sym (trans (C.∣∣≡∣∣ (∣ x ∣-out-^ (1 + n))) (lemma₀ (1 + n) x))) (trans (cong C.∣_∣ (O.∣∣-constant (∣ x ∣-out-^ (1 + n)) O.∣ y ∣)) (C.∣∣≡∣∣ O.∣ y ∣))) (C.∣∣≡∣∣ y) ≡⟨ trans (cong (λ eq → trans (trans eq (trans (cong C.∣_∣ (O.∣∣-constant _ _)) (C.∣∣≡∣∣ _))) (C.∣∣≡∣∣ _)) $ sym-trans _ _) $ trans (trans-assoc _ _ _) $ trans (trans-assoc _ _ _) $ cong (trans (sym (lemma₀ (1 + n) _))) $ sym $ trans-assoc _ _ _ ⟩ trans (sym (lemma₀ (1 + n) x)) (trans (trans (sym (C.∣∣≡∣∣ (∣ x ∣-out-^ (1 + n)))) (trans (cong C.∣_∣ (O.∣∣-constant (∣ x ∣-out-^ (1 + n)) O.∣ y ∣)) (C.∣∣≡∣∣ O.∣ y ∣))) (C.∣∣≡∣∣ y)) ≡⟨ cong (λ eq → trans (sym (lemma₀ (1 + n) _)) (trans (trans (sym (C.∣∣≡∣∣ _)) eq) (C.∣∣≡∣∣ _))) $ sym $ lemma₂ _ _ _ _ _ ⟩ trans (sym (lemma₀ (1 + n) x)) (trans (trans (sym (C.∣∣≡∣∣ (∣ x ∣-out-^ (1 + n)))) (trans (C.∣∣≡∣∣ (∣ x ∣-out-^ (1 + n))) (cong C.∣_∣ (O.∣∣-constant _ _)))) (C.∣∣≡∣∣ y)) ≡⟨ cong (λ eq → trans (sym (lemma₀ (1 + n) _)) (trans eq (C.∣∣≡∣∣ _))) $ trans-sym-[trans] _ _ ⟩ trans (sym (lemma₀ (1 + n) x)) (trans (cong C.∣_∣ (O.∣∣-constant _ _)) (C.∣∣≡∣∣ y)) ≡⟨⟩ lemma₁ n x y ∎ where lemma₀ : ∀ n (x : A) → C.∣ ∣ x ∣-out-^ n ∣ ≡ ∣ x ∣ lemma₀ zero x = ∣ x ∣ ∎ lemma₀ (suc n) x = C.∣ O.∣ ∣ x ∣-out-^ n ∣ ∣ ≡⟨ C.∣∣≡∣∣ (∣ x ∣-out-^ n) ⟩ C.∣ ∣ x ∣-out-^ n ∣ ≡⟨ lemma₀ n x ⟩∎ ∣ x ∣ ∎ lemma₁ : ∀ n (x : A) (y : ∥ A ∥¹-out-^ n) → ∣ x ∣ ≡ C.∣ y ∣ lemma₁ n x y = ∣ x ∣ ≡⟨ sym (lemma₀ (suc n) x) ⟩ C.∣ ∣ x ∣-out-^ (suc n) ∣ ≡⟨⟩ C.∣ O.∣ ∣ x ∣-out-^ n ∣ ∣ ≡⟨ cong C.∣_∣ (O.∣∣-constant _ _) ⟩ C.∣ O.∣ y ∣ ∣ ≡⟨ C.∣∣≡∣∣ y ⟩∎ C.∣ y ∣ ∎ lemma₂ : ∀ n (x y : ∥ A ∥¹-out-^ n) (p : x ≡ y) (q : O.∣ x ∣ ≡ O.∣ y ∣) → trans (C.∣∣≡∣∣ {P = ∥ A ∥¹-out-^} x) (cong C.∣_∣ p) ≡ trans (cong C.∣_∣ q) (C.∣∣≡∣∣ y) lemma₂ n x y p q = trans (C.∣∣≡∣∣ x) (cong C.∣_∣ p) ≡⟨ PD.elim (λ {x y} p → trans (C.∣∣≡∣∣ x) (cong C.∣_∣ p) ≡ trans (cong C.∣_∣ (cong O.∣_∣ p)) (C.∣∣≡∣∣ y)) (λ x → trans (C.∣∣≡∣∣ x) (cong C.∣_∣ (refl _)) ≡⟨ cong (trans _) $ cong-refl _ ⟩ trans (C.∣∣≡∣∣ x) (refl _) ≡⟨ trans-reflʳ _ ⟩ C.∣∣≡∣∣ x ≡⟨ sym $ trans-reflˡ _ ⟩ trans (refl _) (C.∣∣≡∣∣ x) ≡⟨ cong (flip trans _) $ sym $ trans (cong (cong C.∣_∣) $ cong-refl _) $ cong-refl _ ⟩∎ trans (cong C.∣_∣ (cong O.∣_∣ (refl _))) (C.∣∣≡∣∣ x) ∎) p ⟩ trans (cong C.∣_∣ (cong O.∣_∣ p)) (C.∣∣≡∣∣ y) ≡⟨ cong (flip trans _) $ cong-preserves-Constant (λ u v → C.∣ u ∣ ≡⟨ sym (C.∣∣≡∣∣ u) ⟩ C.∣ O.∣ u ∣ ∣ ≡⟨ cong C.∣_∣ (O.∣∣-constant _ _) ⟩ C.∣ O.∣ v ∣ ∣ ≡⟨ C.∣∣≡∣∣ v ⟩∎ C.∣ v ∣ ∎) _ _ ⟩∎ trans (cong C.∣_∣ q) (C.∣∣≡∣∣ y) ∎ -- ∥_∥ is pointwise equivalent to T.∥_∥. ∥∥≃∥∥ : ∥ A ∥ ≃ T.∥ A ∥ ∥∥≃∥∥ = Eq.⇔→≃ ∥∥-proposition T.truncation-is-proposition (elim λ where .∣∣ʳ → T.∣_∣ .is-propositionʳ _ → T.truncation-is-proposition) (T.rec ∥∥-proposition ∣_∣) -- Functions from T.∥ A ∥ can be expressed as families of functions -- from ∥ A ∥¹-out-^ that satisfy a certain property. ∥∥→≃ : (T.∥ A ∥ → B) ≃ (∃ λ (f : ∀ n → ∥ A ∥¹-out-^ n → B) → ∀ n x → f (suc n) O.∣ x ∣ ≡ f n x) ∥∥→≃ {A = A} {B = B} = (T.∥ A ∥ → B) ↝⟨ →-cong ext (inverse ∥∥≃∥∥) F.id ⟩ (∥ A ∥ → B) ↝⟨ C.universal-property ⟩□ (∃ λ (f : ∀ n → ∥ A ∥¹-out-^ n → B) → ∀ n x → f (suc n) O.∣ x ∣ ≡ f n x) □ ------------------------------------------------------------------------ -- Some conversion functions -- ∥ A ∥ᴱ implies ∥ A ∥. ∥∥ᴱ→∥∥ : ∥ A ∥ᴱ → ∥ A ∥ ∥∥ᴱ→∥∥ = N.elim λ where .N.∣∣ʳ → ∣_∣ .N.is-propositionʳ _ → ∥∥-proposition -- In erased contexts ∥ A ∥ᴱ and ∥ A ∥ are equivalent. @0 ∥∥ᴱ≃∥∥ : ∥ A ∥ᴱ ≃ ∥ A ∥ ∥∥ᴱ≃∥∥ = Eq.↔→≃ ∥∥ᴱ→∥∥ (elim λ @0 where .∣∣ʳ → N.∣_∣ .is-propositionʳ _ → N.∥∥ᴱ-proposition) (elim λ @0 where .∣∣ʳ _ → refl _ .is-propositionʳ _ → mono₁ 1 ∥∥-proposition) (N.elim λ where .N.∣∣ʳ _ → refl _ .N.is-propositionʳ _ → mono₁ 1 N.∥∥ᴱ-proposition)
{ "alphanum_fraction": 0.3447862129, "avg_line_length": 41.6727272727, "ext": "agda", "hexsha": "a2903018fcbe35e7f0a08b0314d99dd8c5019a61", "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/H-level/Truncation/Propositional/Non-recursive.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/H-level/Truncation/Propositional/Non-recursive.agda", "max_line_length": 141, "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/H-level/Truncation/Propositional/Non-recursive.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": 3495, "size": 9168 }
{-# OPTIONS --without-K --safe #-} module Math.FormalLanguage where -- agda-stdlib import Algebra.FunctionProperties as FP import Algebra.Structures as Structures open import Level renaming (zero to lzero; suc to lsuc) open import Data.List as L using (List; []; _++_) import Data.List.Properties as Lₚ open import Data.Nat hiding (_⊔_; _^_) open import Data.Empty open import Data.Product using (proj₁; proj₂; _,_; _×_; ∃₂; ∃) open import Function using (_$_) import Function as F open import Relation.Binary.PropositionalEquality open import Relation.Binary open import Relation.Unary hiding (∅; {_}) import Relation.Unary as U import Relation.Unary.Properties as Uₚ -- Equivalence of predicate infix 4 _≡ᴾ_ _≡ᴾ_ : ∀ {a l} {A : Set a} → Rel (Pred A l) (a ⊔ l) _≡ᴾ_ P Q = (P ⊆ Q) × (Q ⊆ P) ≡ᴾ-refl : ∀ {a l} {A : Set a} → Reflexive {A = Pred A l} _≡ᴾ_ ≡ᴾ-refl = F.id , F.id ≡ᴾ-sym : ∀ {a l} {A : Set a} → Symmetric {A = Pred A l} _≡ᴾ_ ≡ᴾ-sym = Data.Product.swap ≡ᴾ-trans : ∀ {a l} {A : Set a} → Transitive {A = Pred A l} _≡ᴾ_ ≡ᴾ-trans P≡Q Q≡R = proj₁ Q≡R F.∘ proj₁ P≡Q , proj₂ P≡Q F.∘ proj₂ Q≡R ≡ᴾ-isEquivalence : ∀ {a l} {A : Set a} → IsEquivalence {A = Pred A l} _≡ᴾ_ ≡ᴾ-isEquivalence = record { refl = ≡ᴾ-refl ; sym = ≡ᴾ-sym ; trans = ≡ᴾ-trans } ≡ᴾ-setoid : ∀ {a l} {A : Set a} → Setoid _ _ ≡ᴾ-setoid {a} {l} {A} = record { Carrier = Pred A l ; _≈_ = _≡ᴾ_ ; isEquivalence = ≡ᴾ-isEquivalence } ∅ : ∀ {a l} {A : Set a} → Pred A l ∅ {l = l} = λ _ → Lift l ⊥ {_} : ∀ {a l} {A : Set a} → A → Pred A (a ⊔ l) {_}{l = l} x = λ y → Lift l (y ≡ x) Lang : ∀ {s} → Set s → (l : Level) → Set _ Lang Σ l = Pred (List Σ) l -- TODO Move Math.FormalLanguage.Construct.EmptyLang data EmptyLang {a l} {A : Set a} : Lang A (a ⊔ l) where mkEmptyLang : EmptyLang [] -- TODO Move Math.FormalLanguage.Construct.Concat -- TODO Hetero -- Lang A l → Lang B l → Lang (A ⊎ B) l -- map inj₁ xs ++ map inj₂ ys -- concatenation of formal language data _<>_ {a l} {A : Set a} (L₁ L₂ : Lang A l) : Lang A (a ⊔ l) where mk<> : ∀ {xs ys} → L₁ xs → L₂ ys → (L₁ <> L₂) (xs ++ ys) -- TODO Move Math.FormalLanguage.Construct.Concat.Properties module _ {s l} {Σ : Set s} where open FP {A = Lang Σ (s ⊔ l)} _≡ᴾ_ <>-identityˡ : LeftIdentity (EmptyLang {l = l}) _<>_ <>-identityˡ L = to , from where to : EmptyLang <> L ⊆ L to (mk<> mkEmptyLang x₁) = x₁ from : L ⊆ EmptyLang <> L from Lx = mk<> mkEmptyLang Lx <>-identityʳ : RightIdentity (EmptyLang {l = l}) _<>_ <>-identityʳ L = to , from where to : L <> EmptyLang ⊆ L to (mk<> Lx mkEmptyLang) = subst L (sym $ Lₚ.++-identityʳ _) Lx from : L ⊆ L <> EmptyLang from {xs} x = subst (L <> EmptyLang) (Lₚ.++-identityʳ xs) $ mk<> {xs = xs} {ys = []} x mkEmptyLang {- TODO move contents of agda-combinatorics to agda-misc <>-dec : ∀ {L₁ L₂ : Lang Σ l} → U.Decidable L₁ → U.Decidable L₂ → U.Decidable (L₁ <> L₂) <>-dec L₁? L₂? zs with L.filter (L₁? Uₚ.×? L₂?) (splits₂ zs) ... | x = ? -}
{ "alphanum_fraction": 0.5936981758, "avg_line_length": 30.7653061224, "ext": "agda", "hexsha": "20fff9337a60567cf4b67a8ee1e2e04698842c2f", "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/FormalLanguage.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/FormalLanguage.agda", "max_line_length": 74, "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/FormalLanguage.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": 1247, "size": 3015 }
module Everything where import Data.BitVector import Data.BitVector.ContainmentOrder import Data.BitVector.NumericOrder import Data.BitVector.Peano import Data.BitVector.Properties import Data.BitVector.Properties.LatticeProperties
{ "alphanum_fraction": 0.8798283262, "avg_line_length": 25.8888888889, "ext": "agda", "hexsha": "e7e2d989c12d09fbe182d3ab7e081108daa25a60", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2021-11-12T01:40:57.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-25T00:15:43.000Z", "max_forks_repo_head_hexsha": "6902f4bce0330f1b58f48395dac4406056713687", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "copumpkin/bitvector", "max_forks_repo_path": "Everything.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "6902f4bce0330f1b58f48395dac4406056713687", "max_issues_repo_issues_event_max_datetime": "2016-05-25T02:00:59.000Z", "max_issues_repo_issues_event_min_datetime": "2016-05-25T02:00:59.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "copumpkin/bitvector", "max_issues_repo_path": "Everything.agda", "max_line_length": 50, "max_stars_count": 3, "max_stars_repo_head_hexsha": "6902f4bce0330f1b58f48395dac4406056713687", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "copumpkin/bitvector", "max_stars_repo_path": "Everything.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-12T01:41:07.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-04T07:19:55.000Z", "num_tokens": 48, "size": 233 }
module objectsInAgda where open import Data.Product open import interactiveProgramsAgda hiding (main) open import NativeIO open import Data.String.Base record Interface : Set₁ where field Method : Set Result : (m : Method) → Set open Interface public record Object (I : Interface) : Set where coinductive field objectMethod : (m : Method I) → Result I m × Object I open Object public open import Size record IOObject (Iᵢₒ : IOInterface) (I : Interface) (i : Size) : Set where coinductive field method : ∀{j : Size< i} (m : Method I) → IO Iᵢₒ ∞ (Result I m × IOObject Iᵢₒ I j) open IOObject public {- Example Cell -} data CellMethod A : Set where get : CellMethod A put : A → CellMethod A CellResult : ∀{A} → CellMethod A → Set CellResult {A} get = A CellResult (put _) = Unit cellI : (A : Set) → Interface Method (cellI A) = CellMethod A Result (cellI A) m = CellResult m {- A cell as an Object -} Cell : Set → Set Cell A = Object (cellI A) cell : {A : Set} → A → Cell A objectMethod (cell a) get = a , cell a objectMethod (cell a) (put a') = unit , cell a' {- A cell as an IOObject -} CellC : (i : Size) → Set CellC = IOObject ConsoleInterface (cellI String) simpleCell : ∀{i} (s : String) → CellC i force (method (simpleCell s) get) = do' (putStrLn ("getting (" ++ s ++ ")")) λ _ → return (s , simpleCell s) force (method (simpleCell _) (put s)) = do' (putStrLn ("putting (" ++ s ++ ")")) λ _ → return (_ , simpleCell s) program : ∀{i} → CellC ∞ → IO ConsoleInterface i Unit force (program c) = do' getLine λ s → method c (put s) >>= λ{ (_ , c) → method c get >>= λ{ (s' , c) → do (putStrLn s') λ _ → program c }} main : NativeIO Unit main = translateIOConsole (program (simpleCell "Start"))
{ "alphanum_fraction": 0.5995762712, "avg_line_length": 22.4761904762, "ext": "agda", "hexsha": "32dbdcf176bac526746a0b4fbbc22b4ec4a831c1", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z", "max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/ooAgda", "max_forks_repo_path": "presentationsAndExampleCode/agdaImplementorsMeetingGlasgow22April2016AntonSetzer/objectsInAgda.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/ooAgda", "max_issues_repo_path": "presentationsAndExampleCode/agdaImplementorsMeetingGlasgow22April2016AntonSetzer/objectsInAgda.agda", "max_line_length": 74, "max_stars_count": 23, "max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/ooAgda", "max_stars_repo_path": "presentationsAndExampleCode/agdaImplementorsMeetingGlasgow22April2016AntonSetzer/objectsInAgda.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z", "num_tokens": 609, "size": 1888 }
module trichotomy where open import Relation.Binary.PropositionalEquality using (_≡_; refl) open import Data.Nat using (ℕ; zero; suc) open import Data.Sum using (_⊎_; inj₁; inj₂) open import Data.Product using (_×_) renaming (_,_ to ⟨_,_⟩) open import Negation using (¬_; _≢_) infix 4 _<_ data _<_ : ℕ → ℕ → Set where z<s : ∀ {n : ℕ} ------------ → zero < suc n s<s : ∀ {m n : ℕ} → m < n ------------- → suc m < suc n infix 4 _≮_ _≮_ : ∀ (m n : ℕ) → Set m ≮ n = ¬ (m < n) -- 1 + m ≡ 1 + n ならば m ≡ n sm≡sn→m≡n : ∀ {m n : ℕ} → suc m ≡ suc n → m ≡ n sm≡sn→m≡n refl = refl -- m ≢ n ならば 1 + m ≢ 1 + n m≢n→sm≢sn : ∀ {m n : ℕ} → m ≢ n → suc m ≢ suc n m≢n→sm≢sn m≢n = λ{ sm≡sn → m≢n (sm≡sn→m≡n sm≡sn) } -- m ≮ n ならば 1 + m ≮ 1 + n m≮n→sm≮sn : ∀ {m n : ℕ} → m ≮ n → suc m ≮ suc n m≮n→sm≮sn m≮n = λ{ (s<s m<n) → m≮n m<n } -- 三分律の証明 trichotomy : ∀ (m n : ℕ) → (m < n × m ≢ n × n ≮ m) ⊎ (m ≮ n × m ≡ n × n ≮ m) ⊎ (m ≮ n × m ≢ n × n < m) trichotomy zero zero = inj₂ (inj₁ ⟨ (λ()) , ⟨ refl , (λ()) ⟩ ⟩) trichotomy zero (suc n) = inj₁ ⟨ z<s , ⟨ (λ()) , (λ()) ⟩ ⟩ trichotomy (suc m) zero = inj₂ (inj₂ ⟨ (λ()) , ⟨ (λ()) , z<s ⟩ ⟩) trichotomy (suc m) (suc n) with trichotomy m n ... | inj₁ ⟨ m<n , ⟨ m≢n , n≮m ⟩ ⟩ = inj₁ ⟨ s<s m<n , ⟨ m≢n→sm≢sn m≢n , m≮n→sm≮sn n≮m ⟩ ⟩ ... | inj₂ (inj₁ ⟨ m≮n , ⟨ refl , n≮m ⟩ ⟩) = inj₂ (inj₁ ⟨ m≮n→sm≮sn m≮n , ⟨ refl , m≮n→sm≮sn n≮m ⟩ ⟩) ... | inj₂ (inj₂ ⟨ m≮n , ⟨ m≢n , n<m ⟩ ⟩) = inj₂ (inj₂ ⟨ m≮n→sm≮sn m≮n , ⟨ m≢n→sm≢sn m≢n , s<s n<m ⟩ ⟩)
{ "alphanum_fraction": 0.4042923434, "avg_line_length": 35.1836734694, "ext": "agda", "hexsha": "45cbab416bf929a3edc3491fc144937ae8a1cb82", "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": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "akiomik/plfa-solutions", "max_forks_repo_path": "part1/negation/trichotomy.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "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": "akiomik/plfa-solutions", "max_issues_repo_path": "part1/negation/trichotomy.agda", "max_line_length": 130, "max_stars_count": 1, "max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "akiomik/plfa-solutions", "max_stars_repo_path": "part1/negation/trichotomy.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z", "num_tokens": 817, "size": 1724 }
open import Lemmachine.Resource module Lemmachine.Resolve (c : Resource) where open import Lemmachine.Request open import Lemmachine.Response open import Lemmachine.Utils open import Data.Bool open import Data.Nat open import Data.String open import Data.Function open import Data.Maybe open import Data.List open import Data.Product open import Relation.Binary open import Relation.Binary.PropositionalEquality O18 : Request → Status O18 r with Resource.multipleChoices c r ... | false = OK ... | true = MultipleChoices O20 : Request → Status O20 r with Request.reqBody r ... | nothing = NoContent ... | just _ = O18 r P11 : Request → Status P11 r with fetchHeader "Location" (Request.headers r) ... | nothing = O20 r ... | just _ = Created O14 : Request → Status O14 r with Resource.isConflict c r ... | true = Conflict ... | false = P11 r O16 : Request → Status O16 r with Request.method r ... | PUT = O14 r ... | _ = O18 r N11 : Request → Status N11 r with isRedirect r ... | true = SeeOther ... | false = P11 r N16 : Request → Status N16 r with Request.method r ... | POST = N11 r ... | _ = O16 r M20 : Request → Status M20 r with Resource.deleteResource c r ... | false = Accepted ... | true = O20 r M16 : Request → Status M16 r with Request.method r ... | DELETE = M20 r ... | _ = N16 r L13+L14+L15+L17 : Request → Status L13+L14+L15+L17 r with fetchHeader "If-Modified-Since" (Request.headers r) ... | nothing = M16 r ... | just clientDate with isDate clientDate ... | false = M16 r ... | true with isModified now clientDate ... | true = M16 r ... | false with Resource.lastModified c r ... | nothing = M16 r ... | just serverDate with isModified clientDate serverDate ... | true = M16 r ... | false = NotModified J18 : Request → Status J18 r with Request.method r ... | HEAD = NotModified ... | GET = NotModified ... | _ = PreconditionFailed I12+I13+K13 : Request → Status I12+I13+K13 r with fetchHeader "If-None-Match" (Request.headers r) ... | nothing = L13+L14+L15+L17 r ... | just clientETag with "*" == clientETag ... | true = J18 r ... | false with Resource.generateETag c r ... | nothing = L13+L14+L15+L17 r ... | just serverETag with clientETag == serverETag ... | true = J18 r ... | false = L13+L14+L15+L17 r H10+H11+H12 : Request → Status H10+H11+H12 r with fetchHeader "If-Unmodified-Since" (Request.headers r) ... | nothing = I12+I13+K13 r ... | just clientDate with isDate clientDate ... | false = I12+I13+K13 r ... | true with Resource.lastModified c r ... | nothing = I12+I13+K13 r ... | just serverDate with isModified clientDate serverDate ... | true = PreconditionFailed ... | false = I12+I13+K13 r G8+G9+G11 : Request → Status G8+G9+G11 r with fetchHeader "If-Match" (Request.headers r) ... | nothing = H10+H11+H12 r ... | just clientETag with "*" == clientETag ... | true = H10+H11+H12 r ... | false with Resource.generateETag c r ... | nothing = PreconditionFailed ... | just serverETag with clientETag == serverETag ... | true = H10+H11+H12 r ... | false = PreconditionFailed I7+I4+P3+K7+K5+L5+M5+N5+L7+M7 : Request → Status I7+I4+P3+K7+K5+L5+M5+N5+L7+M7 r with Request.method r I7+I4+P3+K7+K5+L5+M5+N5+L7+M7 r | PUT with Resource.movedPermanently c r I7+I4+P3+K7+K5+L5+M5+N5+L7+M7 _ | PUT | just _ = MovedPermanently I7+I4+P3+K7+K5+L5+M5+N5+L7+M7 r | PUT | nothing with Resource.isConflict c r I7+I4+P3+K7+K5+L5+M5+N5+L7+M7 r | PUT | nothing | false = N11 r I7+I4+P3+K7+K5+L5+M5+N5+L7+M7 _ | PUT | nothing | true = Conflict I7+I4+P3+K7+K5+L5+M5+N5+L7+M7 r | _ with Resource.previouslyExisted c r I7+I4+P3+K7+K5+L5+M5+N5+L7+M7 r | _ | true with Resource.movedPermanently c r I7+I4+P3+K7+K5+L5+M5+N5+L7+M7 _ | _ | true | just _ = MovedPermanently I7+I4+P3+K7+K5+L5+M5+N5+L7+M7 r | _ | true | nothing with Resource.movedTemporarily c r I7+I4+P3+K7+K5+L5+M5+N5+L7+M7 _ | _ | true | nothing | just _ = MovedTemporarily I7+I4+P3+K7+K5+L5+M5+N5+L7+M7 r | POST | true | nothing | nothing with Resource.allowMissingPost c r I7+I4+P3+K7+K5+L5+M5+N5+L7+M7 _ | POST | true | nothing | nothing | false = Gone I7+I4+P3+K7+K5+L5+M5+N5+L7+M7 r | POST | true | nothing | nothing | true = N11 r I7+I4+P3+K7+K5+L5+M5+N5+L7+M7 _ | _ | true | nothing | nothing = Gone I7+I4+P3+K7+K5+L5+M5+N5+L7+M7 r | POST | false with Resource.allowMissingPost c r I7+I4+P3+K7+K5+L5+M5+N5+L7+M7 _ | POST | false | false = NotFound I7+I4+P3+K7+K5+L5+M5+N5+L7+M7 r | POST | false | true = N11 r I7+I4+P3+K7+K5+L5+M5+N5+L7+M7 _ | _ | false = NotFound H7 : Request → Status H7 r with fetchHeader "If-Match" (Request.headers r) ... | just "*" = PreconditionFailed ... | _ = I7+I4+P3+K7+K5+L5+M5+N5+L7+M7 r G7 : Request → Status G7 r with Resource.resourceExists c r ... | true = G8+G9+G11 r ... | false = H7 r F6+F7 : Request → Status F6+F7 r with fetchHeader "Accept-Encoding" (Request.headers r) ... | nothing = G7 r ... | just encoding with fetch encoding (Resource.encodingsProvided c r) ... | just _ = G7 r ... | nothing = NotAcceptable E5+E6 : Request → Status E5+E6 r with fetchHeader "Accept-Charset" (Request.headers r) ... | nothing = F6+F7 r ... | just charset with fetch charset (Resource.charsetsProvided c r) ... | just _ = F6+F7 r ... | nothing = NotAcceptable D4+D5 : Request → Status D4+D5 r with fetchHeader "Accept-Language" (Request.headers r) ... | nothing = E5+E6 r ... | just language with Resource.languageAvailable c r ... | true = E5+E6 r ... | false = NotAcceptable C3+C4 : Request → Status C3+C4 r with fetchHeader "Accept" (Request.headers r) ... | nothing = D4+D5 r ... | just contentType with fetchContentType contentType (Resource.contentTypesProvided c r) ... | just _ = D4+D5 r ... | nothing = NotAcceptable B3 : Request → Status B3 r with eqMethod (Request.method r) OPTIONS ... | true = OK ... | false = C3+C4 r B4 : Request → Status B4 r with Resource.validEntityLength c r ... | true = B3 r ... | false = RequestEntityTooLarge B5 : Request → Status B5 r with Resource.knownContentType c r ... | true = B4 r ... | false = UnsupportedMediaType B6 : Request → Status B6 r with Resource.validContentHeaders c r ... | true = B5 r ... | false = NotImplemented B7 : Request → Status B7 r with Resource.forbidden c r ... | true = Forbidden ... | false = B6 r B8 : Request → Status B8 r with Resource.isAuthorized c r ... | true = B7 r ... | false = Unauthorized B9 : Request → Status B9 r with Resource.malformedRequest c r ... | true = BadRequest ... | false = B8 r B10 : Request → Status B10 r with any (eqMethod (Request.method r)) (Resource.allowedMethods c r) ... | true = B9 r ... | false = MethodNotAllowed B11 : Request → Status B11 r with Resource.uriTooLong c r ... | true = RequestURItooLong ... | false = B10 r B12 : Request → Status B12 r with any (eqMethod (Request.method r)) (Resource.knownMethods c r) ... | true = B11 r ... | false = NotImplemented B13 : Request → Status B13 r with Resource.serviceAvailable c r ... | true = B12 r ... | false = ServiceUnavailable resolveStatus : Request → Status resolveStatus r = B13 r resolve : Application resolve r = record { status = s ; headers = hs $ fetchAccept (Request.headers r) (Resource.contentTypesProvided c r) ; body = Resource.body c s } where s = resolveStatus r hs : Maybe String → List ResponseHeader hs (just s) = [ "Content-Type" , s ] hs nothing = []
{ "alphanum_fraction": 0.6628777748, "avg_line_length": 30.7736625514, "ext": "agda", "hexsha": "cfcdb5e3ee71ba65fe186c858b6958811d239995", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_path": "src/Lemmachine/Resolve.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_path": "src/Lemmachine/Resolve.agda", "max_line_length": 105, "max_stars_count": 56, "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_path": "src/Lemmachine/Resolve.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "num_tokens": 2686, "size": 7478 }
{-# OPTIONS --without-K --safe #-} module Definition.Typed.Reduction where open import Definition.Untyped open import Definition.Typed open import Definition.Typed.Properties -- Weak head expansion of type equality reduction : ∀ {A A′ B B′ Γ} → Γ ⊢ A ⇒* A′ → Γ ⊢ B ⇒* B′ → Whnf A′ → Whnf B′ → Γ ⊢ A′ ≡ B′ → Γ ⊢ A ≡ B reduction D D′ whnfA′ whnfB′ A′≡B′ = trans (subset* D) (trans A′≡B′ (sym (subset* D′))) reduction′ : ∀ {A A′ B B′ Γ} → Γ ⊢ A ⇒* A′ → Γ ⊢ B ⇒* B′ → Whnf A′ → Whnf B′ → Γ ⊢ A ≡ B → Γ ⊢ A′ ≡ B′ reduction′ D D′ whnfA′ whnfB′ A≡B = trans (sym (subset* D)) (trans A≡B (subset* D′)) -- Weak head expansion of term equality reductionₜ : ∀ {a a′ b b′ A B Γ} → Γ ⊢ A ⇒* B → Γ ⊢ a ⇒* a′ ∷ B → Γ ⊢ b ⇒* b′ ∷ B → Whnf B → Whnf a′ → Whnf b′ → Γ ⊢ a′ ≡ b′ ∷ B → Γ ⊢ a ≡ b ∷ A reductionₜ D d d′ whnfB whnfA′ whnfB′ a′≡b′ = conv (trans (subset*Term d) (trans a′≡b′ (sym (subset*Term d′)))) (sym (subset* D)) reductionₜ′ : ∀ {a a′ b b′ A B Γ} → Γ ⊢ A ⇒* B → Γ ⊢ a ⇒* a′ ∷ B → Γ ⊢ b ⇒* b′ ∷ B → Whnf B → Whnf a′ → Whnf b′ → Γ ⊢ a ≡ b ∷ A → Γ ⊢ a′ ≡ b′ ∷ B reductionₜ′ D d d′ whnfB whnfA′ whnfB′ a≡b = trans (sym (subset*Term d)) (trans (conv a≡b (subset* D)) (subset*Term d′))
{ "alphanum_fraction": 0.4224422442, "avg_line_length": 26.1206896552, "ext": "agda", "hexsha": "70bb2a4c3b61f352fb515c52196ad23460bb7202", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Vtec234/logrel-mltt", "max_forks_repo_path": "Definition/Typed/Reduction.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Vtec234/logrel-mltt", "max_issues_repo_path": "Definition/Typed/Reduction.agda", "max_line_length": 55, "max_stars_count": null, "max_stars_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Vtec234/logrel-mltt", "max_stars_repo_path": "Definition/Typed/Reduction.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 600, "size": 1515 }
{-# OPTIONS --warning=error --safe --without-K #-} open import LogicalFormulae open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) open import Numbers.Naturals.Naturals open import Numbers.Naturals.Order open import Vectors open import Semirings.Definition open import Categories.Definition open import Groups.Definition open import Setoids.Setoids open import Groups.Homomorphisms.Definition open import Groups.Homomorphisms.Examples open import Groups.Homomorphisms.Lemmas open import Functions module Categories.Examples where SET : {a : _} → Category {lsuc a} {a} Category.objects (SET {a}) = Set a Category.arrows (SET {a}) = λ a b → (a → b) Category.id (SET {a}) = λ x → λ y → y Category._∘_ (SET {a}) = λ f g → λ x → f (g x) Category.rightId (SET {a}) = λ f → refl Category.leftId (SET {a}) = λ f → refl Category.compositionAssociative (SET {a}) = λ f g h → refl GROUP : {a b : _} → Category {lsuc a ⊔ lsuc b} {a ⊔ b} Category.objects (GROUP {a} {b}) = Sg (Set a) (λ A → Sg (A → A → A) (λ _+_ → Sg (Setoid {a} {b} A) (λ S → Group S _+_))) Category.arrows (GROUP {a}) (A , (_+A_ , (S , G))) (B , (_+B_ , (T , H))) = Sg (A → B) (GroupHom G H) Category.id (GROUP {a}) (A , (_+A_ , (S , G))) = (λ i → i) , identityHom G Category._∘_ (GROUP {a}) {A , (_+A_ , (S , G))} {B , (_+B_ , (T , H))} {C , (_+C_ , (U , I))} (f , fHom) (g , gHom) = (f ∘ g) , groupHomsCompose gHom fHom Category.rightId (GROUP {a}) {A , (_+A_ , (S , G))} {B , (_+B_ , (T , H))} (f , fHom) = {!!} Category.leftId (GROUP {a}) {A , (_+A_ , (S , G))} {B , (_+B_ , (T , H))} (f , fHom) = {!!} Category.compositionAssociative (GROUP {a}) = {!!} DISCRETE : {a : _} (X : Set a) → Category {a} {a} Category.objects (DISCRETE X) = X Category.arrows (DISCRETE X) = λ a b → a ≡ b Category.id (DISCRETE X) = λ x → refl Category._∘_ (DISCRETE X) = λ y=z x=y → transitivity x=y y=z Category.rightId (DISCRETE X) refl = refl Category.leftId (DISCRETE X) refl = refl Category.compositionAssociative (DISCRETE X) refl refl refl = refl
{ "alphanum_fraction": 0.627245509, "avg_line_length": 44.5333333333, "ext": "agda", "hexsha": "b461c9eeda893081d8a06923746635c952eb0287", "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": "Categories/Examples.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": "Categories/Examples.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": "Categories/Examples.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": 746, "size": 2004 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Algebra.RingSolver.RingExpression where open import Cubical.Foundations.Prelude open import Cubical.Data.FinData open import Cubical.Data.Nat using (ℕ) open import Cubical.Data.Nat.Order using (zero-≤) open import Cubical.Data.Vec.Base open import Cubical.Algebra.RingSolver.AlmostRing open import Cubical.Algebra.RingSolver.RawRing renaming (⟨_⟩ to ⟨_⟩ᵣ) private variable ℓ : Level infixl 6 _⊕_ infixl 7 _⊗_ -- Expression in a ring on A with n variables data Expr {ℓ} (A : Type ℓ) (n : ℕ) : Type ℓ where K : A → Expr A n ∣ : Fin n → Expr A n _⊕_ : Expr A n → Expr A n → Expr A n _⊗_ : Expr A n → Expr A n → Expr A n -- _⊛_ : Expr A n → ℕ → Expr A n -- exponentiation ⊝_ : Expr A n → Expr A n module Eval (R : RawRing {ℓ}) where open import Cubical.Data.Vec open RawRing R ⟦_⟧ : ∀ {n} → Expr ⟨ R ⟩ᵣ n → Vec ⟨ R ⟩ᵣ n → ⟨ R ⟩ᵣ ⟦ K r ⟧ v = r ⟦ ∣ k ⟧ v = lookup k v ⟦ x ⊕ y ⟧ v = ⟦ x ⟧ v + ⟦ y ⟧ v ⟦ x ⊗ y ⟧ v = ⟦ x ⟧ v · ⟦ y ⟧ v -- ⟦ x ⊛ l ⟧ v = ⟦ x ⟧ v ^ l ⟦ ⊝ x ⟧ v = - ⟦ x ⟧ v
{ "alphanum_fraction": 0.5987144169, "avg_line_length": 27.225, "ext": "agda", "hexsha": "234e395f839aa66d3cc4a908bea8479525a63e7c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Algebra/RingSolver/RingExpression.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Algebra/RingSolver/RingExpression.agda", "max_line_length": 69, "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/Algebra/RingSolver/RingExpression.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 463, "size": 1089 }
-- The <local hints> in an ATP pragma <prove> can be functions. module ATPLocalHints3 where postulate D : Set zero : D succ : D → D data N : D → Set where zN : N zero sN : ∀ {n} → N n → N (succ n) 1-N : N (succ zero) 1-N = sN zN postulate 2-N : N (succ (succ zero)) {-# ATP prove 2-N 1-N #-}
{ "alphanum_fraction": 0.5490797546, "avg_line_length": 16.3, "ext": "agda", "hexsha": "f67ada8d46064659f76b3e0e1b55addb45284ff4", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2016-08-03T03:54:55.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-10T23:06:19.000Z", "max_forks_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/apia", "max_forks_repo_path": "examples/ATPLocalHints3.agda", "max_issues_count": 121, "max_issues_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_issues_repo_issues_event_max_datetime": "2018-04-22T06:01:44.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-25T13:22:12.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/apia", "max_issues_repo_path": "examples/ATPLocalHints3.agda", "max_line_length": 63, "max_stars_count": 10, "max_stars_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/apia", "max_stars_repo_path": "examples/ATPLocalHints3.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-03T13:44:25.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:54:16.000Z", "num_tokens": 120, "size": 326 }
{-# OPTIONS --prop --rewriting --confluence-check #-} open import Agda.Primitive open import Agda.Builtin.Equality open import Agda.Builtin.Nat renaming (Nat to ℕ; _+_ to _+ℕ_) infix 4 _≐_ data _≐_ {ℓ} {A : Set ℓ} (x : A) : A → Prop ℓ where refl : x ≐ x {-# BUILTIN REWRITE _≐_ #-} variable ℓ : Level A B C : Set ℓ x y z : A cong : (f : A → B) → x ≐ y → f x ≐ f y cong f refl = refl data ℤ : Set where zero : ℤ pred suc : ℤ → ℤ postulate pred-suc : (x : ℤ) → pred (suc x) ≐ x suc-pred : (x : ℤ) → suc (pred x) ≐ x {-# REWRITE pred-suc suc-pred #-} count-suc : ℤ → ℕ count-suc zero = 0 count-suc (pred x) = count-suc x count-suc (suc x) = 1 +ℕ count-suc x
{ "alphanum_fraction": 0.5867647059, "avg_line_length": 19.4285714286, "ext": "agda", "hexsha": "78283f53cc25df9793033acecd9d7b67c2038a64", "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/ConstructorRewriteConfluenceFail.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/ConstructorRewriteConfluenceFail.agda", "max_line_length": 61, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/ConstructorRewriteConfluenceFail.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": 288, "size": 680 }
open import Agda.Builtin.Equality test : (A : Set) (x y : A) → x ≡ y → Set test A .y y refl with A test A .y y refl | X = ? -- Jesper, 2018-12-03, issue #2892: -- Error message is: -- Ill-typed pattern after with abstraction: y -- (perhaps you can replace it by `_`?) -- when checking that the clause ;Issue2892.with-14 A X y = ? has type -- (A w : Set) (x : w) → Set -- Implementing the suggestion makes the code typecheck, so this -- behaviour is at least not obviously wrong.
{ "alphanum_fraction": 0.6424242424, "avg_line_length": 30.9375, "ext": "agda", "hexsha": "41bb1d998689d06e5622e14406f52e3c859ae8fc", "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/Issue2892.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/Issue2892.agda", "max_line_length": 73, "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/Issue2892.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": 158, "size": 495 }
{-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.Algebra.CommAlgebra.Properties where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.Equiv open import Cubical.Foundations.Equiv.HalfAdjoint open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Foundations.Transport open import Cubical.Foundations.SIP open import Cubical.Foundations.GroupoidLaws open import Cubical.Foundations.Path open import Cubical.Data.Sigma open import Cubical.Reflection.StrictEquiv open import Cubical.Structures.Axioms open import Cubical.Algebra.Semigroup open import Cubical.Algebra.Monoid open import Cubical.Algebra.CommRing open import Cubical.Algebra.Ring open import Cubical.Algebra.Algebra open import Cubical.Algebra.CommAlgebra.Base open import Cubical.HITs.PropositionalTruncation private variable ℓ ℓ' ℓ'' ℓ''' : Level -- An R-algebra is the same as a CommRing A with a CommRingHom φ : R → A module CommAlgChar (R : CommRing ℓ) where open Iso open IsRingHom open CommRingTheory CommRingWithHom : Type (ℓ-suc ℓ) CommRingWithHom = Σ[ A ∈ CommRing ℓ ] CommRingHom R A toCommAlg : CommRingWithHom → CommAlgebra R ℓ toCommAlg (A , φ , φIsHom) = ⟨ A ⟩ , ACommAlgStr where open CommRingStr (snd A) ACommAlgStr : CommAlgebraStr R ⟨ A ⟩ CommAlgebraStr.0a ACommAlgStr = 0r CommAlgebraStr.1a ACommAlgStr = 1r CommAlgebraStr._+_ ACommAlgStr = _+_ CommAlgebraStr._·_ ACommAlgStr = _·_ CommAlgebraStr.- ACommAlgStr = -_ CommAlgebraStr._⋆_ ACommAlgStr r a = (φ r) · a CommAlgebraStr.isCommAlgebra ACommAlgStr = makeIsCommAlgebra is-set +Assoc +Rid +Rinv +Comm ·Assoc ·Lid ·Ldist+ ·Comm (λ _ _ x → cong (λ y → y · x) (pres· φIsHom _ _) ∙ sym (·Assoc _ _ _)) (λ _ _ x → cong (λ y → y · x) (pres+ φIsHom _ _) ∙ ·Ldist+ _ _ _) (λ _ _ _ → ·Rdist+ _ _ _) (λ x → cong (λ y → y · x) (pres1 φIsHom) ∙ ·Lid x) (λ _ _ _ → sym (·Assoc _ _ _)) fromCommAlg : CommAlgebra R ℓ → CommRingWithHom fromCommAlg A = (CommAlgebra→CommRing A) , φ , φIsHom where open CommRingStr (snd R) renaming (_·_ to _·r_) hiding (·Lid) open CommAlgebraStr (snd A) open AlgebraTheory (CommRing→Ring R) (CommAlgebra→Algebra A) φ : ⟨ R ⟩ → ⟨ A ⟩ φ r = r ⋆ 1a φIsHom : IsRingHom (CommRing→Ring R .snd) φ (CommRing→Ring (CommAlgebra→CommRing A) .snd) φIsHom = makeIsRingHom (⋆-lid _) (λ _ _ → ⋆-ldist _ _ _) λ x y → cong (λ a → (x ·r y) ⋆ a) (sym (·Lid _)) ∙ ⋆Dist· _ _ _ _ CommRingWithHomRoundTrip : (Aφ : CommRingWithHom) → fromCommAlg (toCommAlg Aφ) ≡ Aφ CommRingWithHomRoundTrip (A , φ) = ΣPathP (APath , φPathP) where open CommRingStr -- note that the proofs of the axioms might differ! APath : fst (fromCommAlg (toCommAlg (A , φ))) ≡ A fst (APath i) = ⟨ A ⟩ 0r (snd (APath i)) = 0r (snd A) 1r (snd (APath i)) = 1r (snd A) _+_ (snd (APath i)) = _+_ (snd A) _·_ (snd (APath i)) = _·_ (snd A) -_ (snd (APath i)) = -_ (snd A) isCommRing (snd (APath i)) = isProp→PathP (λ i → isPropIsCommRing _ _ _ _ _ ) (isCommRing (snd (fst (fromCommAlg (toCommAlg (A , φ)))))) (isCommRing (snd A)) i -- this only works because fst (APath i) = fst A definitionally! φPathP : PathP (λ i → CommRingHom R (APath i)) (snd (fromCommAlg (toCommAlg (A , φ)))) φ φPathP = RingHomPathP _ _ _ _ _ _ λ i x → ·Rid (snd A) (fst φ x) i CommAlgRoundTrip : (A : CommAlgebra R ℓ) → toCommAlg (fromCommAlg A) ≡ A CommAlgRoundTrip A = ΣPathP (refl , AlgStrPathP) where open CommAlgebraStr ⦃...⦄ instance _ = snd A AlgStrPathP : PathP (λ i → CommAlgebraStr R ⟨ A ⟩) (snd (toCommAlg (fromCommAlg A))) (snd A) CommAlgebraStr.0a (AlgStrPathP i) = 0a CommAlgebraStr.1a (AlgStrPathP i) = 1a CommAlgebraStr._+_ (AlgStrPathP i) = _+_ CommAlgebraStr._·_ (AlgStrPathP i) = _·_ CommAlgebraStr.-_ (AlgStrPathP i) = -_ CommAlgebraStr._⋆_ (AlgStrPathP i) r x = (⋆-lassoc r 1a x ∙ cong (r ⋆_) (·Lid x)) i CommAlgebraStr.isCommAlgebra (AlgStrPathP i) = isProp→PathP (λ i → isPropIsCommAlgebra _ _ _ _ _ _ (CommAlgebraStr._⋆_ (AlgStrPathP i))) (CommAlgebraStr.isCommAlgebra (snd (toCommAlg (fromCommAlg A)))) isCommAlgebra i CommAlgIso : Iso (CommAlgebra R ℓ) CommRingWithHom fun CommAlgIso = fromCommAlg inv CommAlgIso = toCommAlg rightInv CommAlgIso = CommRingWithHomRoundTrip leftInv CommAlgIso = CommAlgRoundTrip open RingHoms isCommRingWithHomHom : (A B : CommRingWithHom) → CommRingHom (fst A) (fst B) → Type ℓ isCommRingWithHomHom (_ , f) (_ , g) h = h ∘r f ≡ g CommRingWithHomHom : CommRingWithHom → CommRingWithHom → Type ℓ CommRingWithHomHom (A , f) (B , g) = Σ[ h ∈ CommRingHom A B ] h ∘r f ≡ g toCommAlgebraHom : (A B : CommRingWithHom) (h : CommRingHom (fst A) (fst B)) → isCommRingWithHomHom A B h → CommAlgebraHom (toCommAlg A) (toCommAlg B) toCommAlgebraHom (A , f) (B , g) h commDiag = makeCommAlgebraHom (fst h) (pres1 (snd h)) (pres+ (snd h)) (pres· (snd h)) pres⋆h where open CommRingStr ⦃...⦄ instance _ = snd A _ = snd B pres⋆h : ∀ r x → fst h (fst f r · x) ≡ fst g r · fst h x pres⋆h r x = fst h (fst f r · x) ≡⟨ pres· (snd h) _ _ ⟩ fst h (fst f r) · fst h x ≡⟨ cong (λ φ → fst φ r · fst h x) commDiag ⟩ fst g r · fst h x ∎ fromCommAlgebraHom : (A B : CommAlgebra R ℓ) → CommAlgebraHom A B → CommRingWithHomHom (fromCommAlg A) (fromCommAlg B) fst (fst (fromCommAlgebraHom A B f)) = fst f pres0 (snd (fst (fromCommAlgebraHom A B f))) = IsAlgebraHom.pres0 (snd f) pres1 (snd (fst (fromCommAlgebraHom A B f))) = IsAlgebraHom.pres1 (snd f) pres+ (snd (fst (fromCommAlgebraHom A B f))) = IsAlgebraHom.pres+ (snd f) pres· (snd (fst (fromCommAlgebraHom A B f))) = IsAlgebraHom.pres· (snd f) pres- (snd (fst (fromCommAlgebraHom A B f))) = IsAlgebraHom.pres- (snd f) snd (fromCommAlgebraHom A B f) = RingHom≡ (funExt (λ x → IsAlgebraHom.pres⋆ (snd f) x 1a ∙ cong (x ⋆_) (IsAlgebraHom.pres1 (snd f)))) where open CommAlgebraStr (snd A) using (1a) open CommAlgebraStr (snd B) using (_⋆_) isCommRingWithHomEquiv : (A B : CommRingWithHom) → CommRingEquiv (fst A) (fst B) → Type ℓ isCommRingWithHomEquiv A B e = isCommRingWithHomHom A B (RingEquiv→RingHom e) CommRingWithHomEquiv : CommRingWithHom → CommRingWithHom → Type ℓ CommRingWithHomEquiv A B = Σ[ e ∈ CommRingEquiv (fst A) (fst B) ] isCommRingWithHomEquiv A B e toCommAlgebraEquiv : (A B : CommRingWithHom) (e : CommRingEquiv (fst A) (fst B)) → isCommRingWithHomEquiv A B e → CommAlgebraEquiv (toCommAlg A) (toCommAlg B) fst (toCommAlgebraEquiv A B e eCommDiag) = e .fst snd (toCommAlgebraEquiv A B e eCommDiag) = toCommAlgebraHom A B _ eCommDiag .snd module CommAlgebraHoms {R : CommRing ℓ} where open AlgebraHoms idCommAlgebraHom : (A : CommAlgebra R ℓ') → CommAlgebraHom A A idCommAlgebraHom A = idAlgebraHom (CommAlgebra→Algebra A) compCommAlgebraHom : (A : CommAlgebra R ℓ') (B : CommAlgebra R ℓ'') (C : CommAlgebra R ℓ''') → CommAlgebraHom A B → CommAlgebraHom B C → CommAlgebraHom A C compCommAlgebraHom A B C = compAlgebraHom {A = CommAlgebra→Algebra A} {CommAlgebra→Algebra B} {CommAlgebra→Algebra C} _∘ca_ : {A : CommAlgebra R ℓ'} {B : CommAlgebra R ℓ''} {C : CommAlgebra R ℓ'''} → CommAlgebraHom B C → CommAlgebraHom A B → CommAlgebraHom A C g ∘ca f = compCommAlgebraHom _ _ _ f g compIdCommAlgebraHom : {A B : CommAlgebra R ℓ'} (f : CommAlgebraHom A B) → compCommAlgebraHom _ _ _ (idCommAlgebraHom A) f ≡ f compIdCommAlgebraHom = compIdAlgebraHom idCompCommAlgebraHom : {A B : CommAlgebra R ℓ'} (f : CommAlgebraHom A B) → compCommAlgebraHom _ _ _ f (idCommAlgebraHom B) ≡ f idCompCommAlgebraHom = idCompAlgebraHom compAssocCommAlgebraHom : {A B C D : CommAlgebra R ℓ'} (f : CommAlgebraHom A B) (g : CommAlgebraHom B C) (h : CommAlgebraHom C D) → compCommAlgebraHom _ _ _ (compCommAlgebraHom _ _ _ f g) h ≡ compCommAlgebraHom _ _ _ f (compCommAlgebraHom _ _ _ g h) compAssocCommAlgebraHom = compAssocAlgebraHom module CommAlgebraEquivs {R : CommRing ℓ} where open AlgebraEquivs compCommAlgebraEquiv : {A : CommAlgebra R ℓ'} {B : CommAlgebra R ℓ''} {C : CommAlgebra R ℓ'''} → CommAlgebraEquiv A B → CommAlgebraEquiv B C → CommAlgebraEquiv A C compCommAlgebraEquiv {A = A} {B = B} {C = C} = compAlgebraEquiv {A = CommAlgebra→Algebra A} {B = CommAlgebra→Algebra B} {C = CommAlgebra→Algebra C} -- the CommAlgebra version of uaCompEquiv module CommAlgebraUAFunctoriality {R : CommRing ℓ} where open CommAlgebraStr open CommAlgebraEquivs CommAlgebra≡ : (A B : CommAlgebra R ℓ') → ( Σ[ p ∈ ⟨ A ⟩ ≡ ⟨ B ⟩ ] Σ[ q0 ∈ PathP (λ i → p i) (0a (snd A)) (0a (snd B)) ] Σ[ q1 ∈ PathP (λ i → p i) (1a (snd A)) (1a (snd B)) ] Σ[ r+ ∈ PathP (λ i → p i → p i → p i) (_+_ (snd A)) (_+_ (snd B)) ] Σ[ r· ∈ PathP (λ i → p i → p i → p i) (_·_ (snd A)) (_·_ (snd B)) ] Σ[ s- ∈ PathP (λ i → p i → p i) (-_ (snd A)) (-_ (snd B)) ] Σ[ s⋆ ∈ PathP (λ i → ⟨ R ⟩ → p i → p i) (_⋆_ (snd A)) (_⋆_ (snd B)) ] PathP (λ i → IsCommAlgebra R (q0 i) (q1 i) (r+ i) (r· i) (s- i) (s⋆ i)) (isCommAlgebra (snd A)) (isCommAlgebra (snd B))) ≃ (A ≡ B) CommAlgebra≡ A B = isoToEquiv theIso where open Iso theIso : Iso _ _ fun theIso (p , q0 , q1 , r+ , r· , s- , s⋆ , t) i = p i , commalgebrastr (q0 i) (q1 i) (r+ i) (r· i) (s- i) (s⋆ i) (t i) inv theIso x = cong ⟨_⟩ x , cong (0a ∘ snd) x , cong (1a ∘ snd) x , cong (_+_ ∘ snd) x , cong (_·_ ∘ snd) x , cong (-_ ∘ snd) x , cong (_⋆_ ∘ snd) x , cong (isCommAlgebra ∘ snd) x rightInv theIso _ = refl leftInv theIso _ = refl caracCommAlgebra≡ : {A B : CommAlgebra R ℓ'} (p q : A ≡ B) → cong ⟨_⟩ p ≡ cong ⟨_⟩ q → p ≡ q caracCommAlgebra≡ {A = A} {B = B} p q P = sym (transportTransport⁻ (ua (CommAlgebra≡ A B)) p) ∙∙ cong (transport (ua (CommAlgebra≡ A B))) helper ∙∙ transportTransport⁻ (ua (CommAlgebra≡ A B)) q where helper : transport (sym (ua (CommAlgebra≡ A B))) p ≡ transport (sym (ua (CommAlgebra≡ A B))) q helper = Σ≡Prop (λ _ → isPropΣ (isOfHLevelPathP' 1 (is-set (snd B)) _ _) λ _ → isPropΣ (isOfHLevelPathP' 1 (is-set (snd B)) _ _) λ _ → isPropΣ (isOfHLevelPathP' 1 (isSetΠ2 λ _ _ → is-set (snd B)) _ _) λ _ → isPropΣ (isOfHLevelPathP' 1 (isSetΠ2 λ _ _ → is-set (snd B)) _ _) λ _ → isPropΣ (isOfHLevelPathP' 1 (isSetΠ λ _ → is-set (snd B)) _ _) λ _ → isPropΣ (isOfHLevelPathP' 1 (isSetΠ2 λ _ _ → is-set (snd B)) _ _) λ _ → isOfHLevelPathP 1 (isPropIsCommAlgebra _ _ _ _ _ _ _) _ _) (transportRefl (cong ⟨_⟩ p) ∙ P ∙ sym (transportRefl (cong ⟨_⟩ q))) uaCompCommAlgebraEquiv : {A B C : CommAlgebra R ℓ'} (f : CommAlgebraEquiv A B) (g : CommAlgebraEquiv B C) → uaCommAlgebra (compCommAlgebraEquiv f g) ≡ uaCommAlgebra f ∙ uaCommAlgebra g uaCompCommAlgebraEquiv f g = caracCommAlgebra≡ _ _ ( cong ⟨_⟩ (uaCommAlgebra (compCommAlgebraEquiv f g)) ≡⟨ uaCompEquiv _ _ ⟩ cong ⟨_⟩ (uaCommAlgebra f) ∙ cong ⟨_⟩ (uaCommAlgebra g) ≡⟨ sym (cong-∙ ⟨_⟩ (uaCommAlgebra f) (uaCommAlgebra g)) ⟩ cong ⟨_⟩ (uaCommAlgebra f ∙ uaCommAlgebra g) ∎) open CommAlgebraHoms open CommAlgebraEquivs open CommAlgebraUAFunctoriality recPT→CommAlgebra : {R : CommRing ℓ} {A : Type ℓ'} (𝓕 : A → CommAlgebra R ℓ'') → (σ : ∀ x y → CommAlgebraEquiv (𝓕 x) (𝓕 y)) → (∀ x y z → σ x z ≡ compCommAlgebraEquiv (σ x y) (σ y z)) ------------------------------------------------------ → ∥ A ∥ → CommAlgebra R ℓ'' recPT→CommAlgebra 𝓕 σ compCoh = GpdElim.rec→Gpd isGroupoidCommAlgebra 𝓕 (3-ConstantCompChar 𝓕 (λ x y → uaCommAlgebra (σ x y)) λ x y z → sym ( cong uaCommAlgebra (compCoh x y z) ∙ uaCompCommAlgebraEquiv (σ x y) (σ y z))) contrCommAlgebraHom→contrCommAlgebraEquiv : {R : CommRing ℓ} {A : Type ℓ'} (σ : A → CommAlgebra R ℓ'') → (∀ x y → isContr (CommAlgebraHom (σ x) (σ y))) ---------------------------------------------------------------------------- → ∀ x y → isContr (CommAlgebraEquiv (σ x) (σ y)) contrCommAlgebraHom→contrCommAlgebraEquiv σ contrHom x y = σEquiv , λ e → Σ≡Prop (λ _ → isPropIsAlgebraHom _ _ _ _) (Σ≡Prop isPropIsEquiv (cong fst (contrHom _ _ .snd (CommAlgebraEquiv→CommAlgebraHom e)))) where open Iso χ₁ = contrHom x y .fst χ₂ = contrHom y x .fst χ₁∘χ₂≡id : χ₁ ∘ca χ₂ ≡ idCommAlgebraHom _ χ₁∘χ₂≡id = isContr→isProp (contrHom _ _) _ _ χ₂∘χ₁≡id : χ₂ ∘ca χ₁ ≡ idCommAlgebraHom _ χ₂∘χ₁≡id = isContr→isProp (contrHom _ _) _ _ σIso : Iso ⟨ σ x ⟩ ⟨ σ y ⟩ fun σIso = fst χ₁ inv σIso = fst χ₂ rightInv σIso = funExt⁻ (cong fst χ₁∘χ₂≡id) leftInv σIso = funExt⁻ (cong fst χ₂∘χ₁≡id) σEquiv : CommAlgebraEquiv (σ x) (σ y) fst σEquiv = isoToEquiv σIso snd σEquiv = snd χ₁
{ "alphanum_fraction": 0.6133782695, "avg_line_length": 44.3149350649, "ext": "agda", "hexsha": "8ffe8d2946909ad8b162aa5de98e61a1527709d2", "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": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "howsiyu/cubical", "max_forks_repo_path": "Cubical/Algebra/CommAlgebra/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "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": "howsiyu/cubical", "max_issues_repo_path": "Cubical/Algebra/CommAlgebra/Properties.agda", "max_line_length": 106, "max_stars_count": null, "max_stars_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "howsiyu/cubical", "max_stars_repo_path": "Cubical/Algebra/CommAlgebra/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5114, "size": 13649 }
------------------------------------------------------------------------ -- Record types with manifest fields and "with", based on Randy -- Pollack's "Dependently Typed Records in Type Theory" ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} -- The module is parametrised by the type of labels, which should come -- with decidable equality. open import Equality open import Prelude hiding (id; proj₁; proj₂) module Records-with-with {c⁺} (eq : ∀ {a p} → Equality-with-J a p c⁺) (open Derived-definitions-and-properties eq) (Label : Type) (_≟_ : Decidable-equality Label) where open import Bijection eq using (_↔_; ↑↔) open import Function-universe eq hiding (_∘_) open import List eq using (foldr) ------------------------------------------------------------------------ -- A Σ-type with a manifest field -- A variant of Σ where the value of the second field is "manifest" -- (given by the first). infix 4 _, record Manifest-Σ {a b} (A : Type a) {B : A → Type b} (f : (x : A) → B x) : Type a where constructor _, field proj₁ : A proj₂ : B proj₁ proj₂ = f proj₁ ------------------------------------------------------------------------ -- Signatures and records mutual infixl 5 _,_∶_ _,_≔_ data Signature s : Type (lsuc s) where ∅ : Signature s _,_∶_ : (Sig : Signature s) (ℓ : Label) (A : Record Sig → Type s) → Signature s _,_≔_ : (Sig : Signature s) (ℓ : Label) {A : Record Sig → Type s} (a : (r : Record Sig) → A r) → Signature s -- Record is a record type to ensure that the signature can be -- inferred from a value of type Record Sig. record Record {s} (Sig : Signature s) : Type s where eta-equality inductive constructor rec field fun : Record-fun Sig Record-fun : ∀ {s} → Signature s → Type s Record-fun ∅ = ↑ _ ⊤ Record-fun (Sig , ℓ ∶ A) = Σ (Record Sig) A Record-fun (Sig , ℓ ≔ a) = Manifest-Σ (Record Sig) a ------------------------------------------------------------------------ -- Labels -- A signature's labels, starting with the last one. labels : ∀ {s} → Signature s → List Label labels ∅ = [] labels (Sig , ℓ ∶ A) = ℓ ∷ labels Sig labels (Sig , ℓ ≔ a) = ℓ ∷ labels Sig -- Inhabited if the label is part of the signature. infix 4 _∈_ _∈_ : ∀ {s} → Label → Signature s → Type ℓ ∈ Sig = foldr (λ ℓ′ → if ℓ ≟ ℓ′ then (λ _ → ⊤) else id) ⊥ (labels Sig) ------------------------------------------------------------------------ -- Projections -- Signature restriction and projection. (Restriction means removal of -- a given field and all subsequent fields.) Restrict : ∀ {s} (Sig : Signature s) (ℓ : Label) → ℓ ∈ Sig → Signature s Restrict ∅ ℓ () Restrict (Sig , ℓ′ ∶ A) ℓ ℓ∈ with ℓ ≟ ℓ′ ... | yes _ = Sig ... | no _ = Restrict Sig ℓ ℓ∈ Restrict (Sig , ℓ′ ≔ a) ℓ ℓ∈ with ℓ ≟ ℓ′ ... | yes _ = Sig ... | no _ = Restrict Sig ℓ ℓ∈ Restricted : ∀ {s} (Sig : Signature s) (ℓ : Label) → ℓ ∈ Sig → Type s Restricted Sig ℓ ℓ∈ = Record (Restrict Sig ℓ ℓ∈) Proj : ∀ {s} (Sig : Signature s) (ℓ : Label) (ℓ∈ : ℓ ∈ Sig) → Restricted Sig ℓ ℓ∈ → Type s Proj ∅ ℓ () Proj (Sig , ℓ′ ∶ A) ℓ ℓ∈ with ℓ ≟ ℓ′ ... | yes _ = A ... | no _ = Proj Sig ℓ ℓ∈ Proj (_,_≔_ Sig ℓ′ {A = A} a) ℓ ℓ∈ with ℓ ≟ ℓ′ ... | yes _ = A ... | no _ = Proj Sig ℓ ℓ∈ -- Record restriction and projection. infixl 5 _∣_ _∣_ : ∀ {s} {Sig : Signature s} → Record Sig → (ℓ : Label) {ℓ∈ : ℓ ∈ Sig} → Restricted Sig ℓ ℓ∈ _∣_ {Sig = ∅} r ℓ {} _∣_ {Sig = Sig , ℓ′ ∶ A} (rec r) ℓ {ℓ∈} with ℓ ≟ ℓ′ ... | yes _ = Σ.proj₁ r ... | no _ = _∣_ (Σ.proj₁ r) ℓ {ℓ∈} _∣_ {Sig = Sig , ℓ′ ≔ a} (rec r) ℓ {ℓ∈} with ℓ ≟ ℓ′ ... | yes _ = Manifest-Σ.proj₁ r ... | no _ = _∣_ (Manifest-Σ.proj₁ r) ℓ {ℓ∈} infixl 5 _·_ _·_ : ∀ {s} {Sig : Signature s} (r : Record Sig) (ℓ : Label) {ℓ∈ : ℓ ∈ Sig} → Proj Sig ℓ ℓ∈ (r ∣ ℓ) _·_ {Sig = ∅} r ℓ {} _·_ {Sig = Sig , ℓ′ ∶ A} (rec r) ℓ {ℓ∈} with ℓ ≟ ℓ′ ... | yes _ = Σ.proj₂ r ... | no _ = _·_ (Σ.proj₁ r) ℓ {ℓ∈} _·_ {Sig = Sig , ℓ′ ≔ a} (rec r) ℓ {ℓ∈} with ℓ ≟ ℓ′ ... | yes _ = Manifest-Σ.proj₂ r ... | no _ = _·_ (Manifest-Σ.proj₁ r) ℓ {ℓ∈} ------------------------------------------------------------------------ -- With -- Sig With ℓ ≔ a is the signature Sig, but with the ℓ field set to a. mutual infixl 5 _With_≔_ _With_≔_ : ∀ {s} (Sig : Signature s) (ℓ : Label) {ℓ∈ : ℓ ∈ Sig} → ((r : Restricted Sig ℓ ℓ∈) → Proj Sig ℓ ℓ∈ r) → Signature s _With_≔_ ∅ ℓ {} a _With_≔_ (Sig , ℓ′ ∶ A) ℓ {ℓ∈} a with ℓ ≟ ℓ′ ... | yes _ = Sig , ℓ′ ≔ a ... | no _ = _With_≔_ Sig ℓ {ℓ∈} a , ℓ′ ∶ A ∘ drop-With _With_≔_ (Sig , ℓ′ ≔ a′) ℓ {ℓ∈} a with ℓ ≟ ℓ′ ... | yes _ = Sig , ℓ′ ≔ a ... | no _ = _With_≔_ Sig ℓ {ℓ∈} a , ℓ′ ≔ a′ ∘ drop-With drop-With : ∀ {s} {Sig : Signature s} {ℓ : Label} {ℓ∈ : ℓ ∈ Sig} {a : (r : Restricted Sig ℓ ℓ∈) → Proj Sig ℓ ℓ∈ r} → Record (_With_≔_ Sig ℓ {ℓ∈} a) → Record Sig drop-With {Sig = ∅} {ℓ∈ = ()} r drop-With {Sig = Sig , ℓ′ ∶ A} {ℓ} (rec r) with ℓ ≟ ℓ′ ... | yes _ = rec (Manifest-Σ.proj₁ r , Manifest-Σ.proj₂ r) ... | no _ = rec (drop-With (Σ.proj₁ r) , Σ.proj₂ r) drop-With {Sig = Sig , ℓ′ ≔ a} {ℓ} (rec r) with ℓ ≟ ℓ′ ... | yes _ = rec (Manifest-Σ.proj₁ r ,) ... | no _ = rec (drop-With (Manifest-Σ.proj₁ r) ,) ------------------------------------------------------------------------ -- Alternative definitions of Record, along with some isomorphisms -- An alternative definition of Record: right-nested, without the -- record type, and without Manifest-Σ. Recordʳ : ∀ {s} (Sig : Signature s) → (Record Sig → Type s) → Type s Recordʳ ∅ κ = κ _ Recordʳ (Sig , ℓ ∶ A) κ = Recordʳ Sig (λ r → Σ (A r) (κ ∘ rec ∘ (r ,_))) Recordʳ (Sig , ℓ ≔ a) κ = Recordʳ Sig (λ r → κ (rec (r ,))) -- Manifest-Σ A f is isomorphic to A. Manifest-Σ↔ : ∀ {a b} {A : Type a} {B : A → Type b} {f : (x : A) → B x} → Manifest-Σ A f ↔ A Manifest-Σ↔ = record { surjection = record { logical-equivalence = record { to = Manifest-Σ.proj₁ ; from = _, } ; right-inverse-of = λ _ → refl _ } ; left-inverse-of = λ _ → refl _ } -- Record is pointwise isomorphic to Record-fun. Record↔Record-fun : ∀ {s} {Sig : Signature s} → Record Sig ↔ Record-fun Sig Record↔Record-fun = record { surjection = record { logical-equivalence = record { to = Record.fun ; from = rec } ; right-inverse-of = λ _ → refl _ } ; left-inverse-of = λ _ → refl _ } -- Record and Recordʳ are, in a certain sense, isomorphic. mutual Σ-Record↔Recordʳ : ∀ {s} (Sig : Signature s) (κ : Record Sig → Type s) → Σ (Record Sig) κ ↔ Recordʳ Sig κ Σ-Record↔Recordʳ Sig κ = Σ (Record Sig) κ ↝⟨ Σ-cong Record↔Record-fun (λ _ → id) ⟩ Σ (Record-fun Sig) (κ ∘ rec) ↝⟨ Σ-Record-fun↔Recordʳ Sig κ ⟩□ Recordʳ Sig κ □ Σ-Record-fun↔Recordʳ : ∀ {s} (Sig : Signature s) (κ : Record Sig → Type s) → Σ (Record-fun Sig) (κ ∘ rec) ↔ Recordʳ Sig κ Σ-Record-fun↔Recordʳ ∅ κ = Σ (↑ _ ⊤) (κ ∘ rec) ↝⟨ Σ-cong ↑↔ (λ _ → id) ⟩ Σ ⊤ (κ ∘ rec ∘ lift) ↝⟨ Σ-left-identity ⟩□ κ _ □ Σ-Record-fun↔Recordʳ (Sig , ℓ ∶ A) κ = Σ (Σ (Record Sig) A) (κ ∘ rec) ↝⟨ inverse Σ-assoc ⟩ Σ (Record Sig) (λ r → Σ (A r) (κ ∘ rec ∘ (r ,_))) ↝⟨ Σ-Record↔Recordʳ Sig _ ⟩□ Recordʳ Sig (λ r → Σ (A r) (κ ∘ rec ∘ (r ,_))) □ Σ-Record-fun↔Recordʳ (Sig , ℓ ≔ a) κ = Σ (Manifest-Σ (Record Sig) a) (κ ∘ rec) ↝⟨ Σ-cong Manifest-Σ↔ (λ _ → id) ⟩ Σ (Record Sig) (κ ∘ rec ∘ _,) ↝⟨ Σ-Record↔Recordʳ Sig _ ⟩□ Recordʳ Sig (κ ∘ rec ∘ _,) □ -- Note that the continuation is initialised with a (lifted) unit -- type. Record↔Recordʳ : ∀ {s} (Sig : Signature s) → Record Sig ↔ Recordʳ Sig (λ _ → ↑ s ⊤) Record↔Recordʳ Sig = Record Sig ↝⟨ inverse ×-right-identity ⟩ Record Sig × ⊤ ↝⟨ id ×-cong inverse ↑↔ ⟩ Record Sig × ↑ _ ⊤ ↝⟨ Σ-Record↔Recordʳ Sig _ ⟩□ Recordʳ Sig (λ _ → ↑ _ ⊤) □ -- Another alternative definition of Record: basically the same as -- Recordʳ, but the continuation is initialised with the first -- non-manifest field, if any, to avoid a pointless innermost unit -- type. Recʳ : ∀ {s} → Signature s → Type s Recʳ ∅ = ↑ _ ⊤ Recʳ (Sig , ℓ ∶ A) = Recordʳ Sig A Recʳ (Sig , ℓ ≔ a) = Recʳ Sig -- Record and Recʳ are pointwise isomorphic. mutual Record↔Recʳ : ∀ {s} {Sig : Signature s} → Record Sig ↔ Recʳ Sig Record↔Recʳ {Sig = Sig} = Record Sig ↝⟨ Record↔Record-fun ⟩ Record-fun Sig ↝⟨ Record-fun↔Recʳ Sig ⟩□ Recʳ Sig □ Record-fun↔Recʳ : ∀ {s} (Sig : Signature s) → Record-fun Sig ↔ Recʳ Sig Record-fun↔Recʳ ∅ = ↑ _ ⊤ □ Record-fun↔Recʳ (Sig , ℓ ∶ A) = Σ (Record Sig) A ↝⟨ Σ-Record↔Recordʳ Sig A ⟩□ Recordʳ Sig A □ Record-fun↔Recʳ (Sig , ℓ ≔ a) = Manifest-Σ (Record Sig) a ↝⟨ Manifest-Σ↔ ⟩ Record Sig ↝⟨ Record↔Recʳ ⟩□ Recʳ Sig □
{ "alphanum_fraction": 0.499731385, "avg_line_length": 31.127090301, "ext": "agda", "hexsha": "6c4ea689f23a79b4dd406e864e3d956116b14bdf", "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/Records-with-with.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/Records-with-with.agda", "max_line_length": 83, "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/Records-with-with.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": 3584, "size": 9307 }
------------------------------------------------------------------------ -- The Agda standard library -- -- A definition for the permutation relation using setoid equality ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.List.Relation.Binary.Permutation.Homogeneous where open import Data.List.Base using (List; _∷_) open import Data.List.Relation.Binary.Pointwise as Pointwise using (Pointwise) open import Level using (Level; _⊔_) open import Relation.Binary private variable a r s : Level A : Set a data Permutation {A : Set a} (R : Rel A r) : Rel (List A) (a ⊔ r) where refl : ∀ {xs ys} → Pointwise R xs ys → Permutation R xs ys prep : ∀ {xs ys x y} (eq : R x y) → Permutation R xs ys → Permutation R (x ∷ xs) (y ∷ ys) swap : ∀ {xs ys x y x' y'} (eq₁ : R x x') (eq₂ : R y y') → Permutation R xs ys → Permutation R (x ∷ y ∷ xs) (y' ∷ x' ∷ ys) trans : ∀ {xs ys zs} → Permutation R xs ys → Permutation R ys zs → Permutation R xs zs ------------------------------------------------------------------------ -- The Permutation relation is an equivalence module _ {R : Rel A r} where sym : Symmetric R → Symmetric (Permutation R) sym R-sym (refl xs∼ys) = refl (Pointwise.symmetric R-sym xs∼ys) sym R-sym (prep x∼x' xs↭ys) = prep (R-sym x∼x') (sym R-sym xs↭ys) sym R-sym (swap x∼x' y∼y' xs↭ys) = swap (R-sym y∼y') (R-sym x∼x') (sym R-sym xs↭ys) sym R-sym (trans xs↭ys ys↭zs) = trans (sym R-sym ys↭zs) (sym R-sym xs↭ys) isEquivalence : Reflexive R → Symmetric R → IsEquivalence (Permutation R) isEquivalence R-refl R-sym = record { refl = refl (Pointwise.refl R-refl) ; sym = sym R-sym ; trans = trans } setoid : Reflexive R → Symmetric R → Setoid _ _ setoid R-refl R-sym = record { isEquivalence = isEquivalence R-refl R-sym } map : ∀ {R : Rel A r} {S : Rel A s} → (R ⇒ S) → (Permutation R ⇒ Permutation S) map R⇒S (refl xs∼ys) = refl (Pointwise.map R⇒S xs∼ys) map R⇒S (prep e xs∼ys) = prep (R⇒S e) (map R⇒S xs∼ys) map R⇒S (swap e₁ e₂ xs∼ys) = swap (R⇒S e₁) (R⇒S e₂) (map R⇒S xs∼ys) map R⇒S (trans xs∼ys ys∼zs) = trans (map R⇒S xs∼ys) (map R⇒S ys∼zs)
{ "alphanum_fraction": 0.5573916927, "avg_line_length": 39.2807017544, "ext": "agda", "hexsha": "fb1f0d29f01e70f4b5bf592ed117835230dd51ee", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Data/List/Relation/Binary/Permutation/Homogeneous.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Data/List/Relation/Binary/Permutation/Homogeneous.agda", "max_line_length": 125, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Data/List/Relation/Binary/Permutation/Homogeneous.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": 798, "size": 2239 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Algebra.Semigroup.Construct.Empty where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Algebra.Semigroup open import Cubical.Data.Empty import Cubical.Algebra.Magma.Construct.Empty as ⊥Magma open ⊥Magma public hiding (⊥-isMagma; ⊥-Magma) ◯-assoc : Associative _◯_ ◯-assoc _ _ _ = isProp⊥ _ _ ⊥-isSemigroup : IsSemigroup ⊥ _◯_ ⊥-isSemigroup = record { isMagma = ⊥Magma.⊥-isMagma ; assoc = ◯-assoc } ⊥-Semigroup : Semigroup ℓ-zero ⊥-Semigroup = record { isSemigroup = ⊥-isSemigroup }
{ "alphanum_fraction": 0.7303921569, "avg_line_length": 24.48, "ext": "agda", "hexsha": "ad138a0e90c06ee79ce757624e1872e4626699ad", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_path": "Cubical/Algebra/Semigroup/Construct/Empty.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_path": "Cubical/Algebra/Semigroup/Construct/Empty.agda", "max_line_length": 54, "max_stars_count": null, "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_path": "Cubical/Algebra/Semigroup/Construct/Empty.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 219, "size": 612 }
{-# OPTIONS --cubical #-} module CubicalPrims where open import Agda.Primitive renaming (_⊔_ to ℓ-max) open import Agda.Primitive.Cubical renaming (primIMin to _∧_; primIMax to _∨_; primINeg to ~_; isOneEmpty to empty) open import Agda.Builtin.Bool open import Agda.Builtin.Cubical.Sub renaming (Sub to _[_↦_]; primSubOut to ouc) open import Agda.Builtin.Cubical.Path open import Agda.Builtin.Cubical.Id renaming (primIdJ to J) open import Agda.Builtin.Cubical.Glue renaming (primGlue to Glue; prim^glue to glue; prim^unglue to unglue) open import Agda.Builtin.Sigma open import Agda.Builtin.List open Helpers module _ {ℓ} {A : Set ℓ} where trans : {x y z : A} → x ≡ y → y ≡ z → x ≡ z trans {x = x} p q i = primComp (λ _ → A) _ (λ { j (i = i0) → x ; j (i = i1) → q j }) (p i) module _ {ℓ ℓ'} {A : Set ℓ} {x : A} (P : ∀ y → x ≡ y → Set ℓ') (d : P x ((λ i → x))) where pathJ : (y : A) → (p : x ≡ y) → P y p pathJ _ p = primTransp (λ i → P (p i) (\ j → p (i ∧ j))) i0 d module DerivedComp where forward : (la : I → Level) (A : ∀ i → Set (la i)) (r : I) → A r → A i1 forward la A r x = primTransp (\ i → A (i ∨ r)) r x module _ (la : I → Level) (A : ∀ i → Set (la i)) (φ : I) (u : ∀ i → Partial φ (A i)) (u0 : A i0 [ φ ↦ u i0 ]) where comp : A i1 comp = primHComp (\ i → \ { (φ = i1) → forward la A i (u i itIsOne) }) (forward la A i0 (ouc u0)) comp-test : comp ≡ primComp A φ u (ouc u0) comp-test = refl test-sym : ∀ {ℓ} {A : Set ℓ} → {x y : A} → (p : x ≡ y) → sym (sym p) ≡ p test-sym p = refl transpFill : ∀ {ℓ} {A' : Set ℓ} (φ : I) (A : (i : I) → Set ℓ [ φ ↦ (\ _ → A') ]) → (u0 : ouc (A i0)) → PathP (λ i → ouc (A i)) u0 (primTransp (λ i → ouc (A i)) φ u0) transpFill φ A u0 i = primTransp (\ j → ouc (A (i ∧ j))) (~ i ∨ φ) u0 test-bool : (p : true ≡ false) → Bool test-bool p = primComp (λ _ → Bool) i1 (λ j → λ _ → p j) true -- cannot reduce to true, because it's already reducing to false. test-bool-beta : ∀ p → test-bool p ≡ false test-bool-beta p = refl etaExpand : ∀ {ℓ} {A : Set ℓ} {x y : A} → (p : x ≡ y) → x ≡ y etaExpand p = λ z → p z etaEq : ∀ {ℓ} {A : Set ℓ} {x y : A} → (p : x ≡ y) → p ≡ etaExpand p etaEq p = refl module IntervalEquations where postulate P : I → Set test-0 : (P (~ i0) ≡ P i1) test-0 = refl test-1 : P (~ i1) ≡ P i0 test-1 = refl test-2 : ∀ {i j} → P (~ (i ∧ j)) ≡ P (~ i ∨ ~ j) test-2 = refl test-3 : ∀ {i j} → P (~ (i ∨ j)) ≡ P (~ i ∧ ~ j) test-3 = refl test-4 : ∀ {i} → P (~ (~ i)) ≡ P i test-4 = refl test-5 : ∀ {i} → P (_∧_ i0 i) ≡ P i0 test-5 = refl test-52 : ∀ {i} → P (_∧_ i i) ≡ P i test-52 = refl test-53 : ∀ {i j} → P (i ∧ j) ≡ P (j ∧ i) test-53 = refl test-n6 : ∀ {i} → P (i1 ∧ i) ≡ P i test-n6 = refl test-n7 : ∀ {i} → P (i ∧ i0) ≡ P i0 test-n7 = refl test-n8 : ∀ {i} → P (i ∧ i1) ≡ P i test-n8 = refl reflId : ∀ {l} {A : Set l} {x : A} → Id x x reflId = conid i1 refl J-comp : ∀ {ℓ ℓ'} {A : Set ℓ} {x : A} {P : ∀ y → Id x y → Set ℓ'} → (d : P x reflId) → J P d reflId ≡ d J-comp _ = refl outPartial : ∀ {ℓ} {A : Set ℓ} → Partial i1 A → A outPartial = λ f → f itIsOne inPartial : ∀ {ℓ} {A : Set ℓ} → A → Partial i1 A inPartial a = λ _ → a module _ {ℓ ℓ'} {A : I → Set ℓ} {B : ∀ i → A i → Set ℓ'} (let ℓ = _ ; C : I → Set ℓ ; C i = (x : A i) → B i x) where compPi : (φ : I) → (u : ∀ i → Partial φ (C i)) → (a : C i0 [ φ ↦ u i0 ]) → C i1 compPi φ u a' x1 = primComp (λ i → B i (v i)) φ (λ i o → u i o (v i)) (a (v i0)) where a = ouc a' v : (i : I) → A i v i = primTransp (λ j → A (i ∨ (~ j))) i x1 f : ∀ i → (a : A i) → Partial φ (B i a) f i a = λ { (φ = i1) → u i itIsOne a } compPi' : (φ : I) → (u : ∀ i → Partial φ (C i)) → (a : C i0 [ φ ↦ u i0 ]) → C i1 compPi' φ u a = primComp C φ u (ouc a) test-compPi : (φ : I) → (u : ∀ i → Partial φ (C i)) → (a : C i0 [ φ ↦ u i0 ]) → compPi φ u a ≡ compPi' φ u a test-compPi = λ φ u u0 → refl module HCompPathP {ℓ} {A : I → Set ℓ} (u : A i0) (v : A i1) (φ : I) (let C = PathP A u v) (p : ∀ i → Partial φ C) (p0 : C [ φ ↦ p i0 ]) where hcompPathP : C hcompPathP j = primHComp (\ { i (φ = i1) → p i itIsOne j ; i (j = i0) → u ; i (j = i1) → v }) (ouc p0 j) test-hcompPathP : hcompPathP ≡ primHComp p (ouc p0) test-hcompPathP = refl module TranspPathP {ℓ} {A : I → I → Set ℓ} (u : ∀ i → A i i0)(v : ∀ i → A i i1) (let C = λ (i : I) → PathP (A i) (u i) (v i)) (p0 : C i0) where φ = i0 transpPathP : C i1 transpPathP j = primComp (λ i → A i j) _ (\ { i (j = i0) → u i ; i (j = i1) → v i }) (p0 j) test-compPathP : transpPathP ≡ primTransp C i0 p0 test-compPathP = refl module RecordComp where record R {ℓ ℓ'} (A : Set ℓ) (B : A → Set ℓ') (C : (x : A) → B x → Set ℓ) : Set (ℓ-max ℓ ℓ') where coinductive constructor _,_ field fst : A snd : B fst trd : C fst snd open R hcompR : ∀ {ℓ ℓ'} {A : Set ℓ} {B : A → Set ℓ'} {C : (x : A) → B x → Set ℓ} → (let ℓ = _ ; Z : Set ℓ ; Z = R(A)(B)(C)) (φ : I) → (u : ∀ i → Partial φ Z) → Z [ φ ↦ u i0 ] → Z fst (hcompR {A = A} {B} φ w w0) = primComp (\ _ → A) φ (λ i → (λ{ (φ = i1) → fst (w i itIsOne) }) ) (fst (ouc w0)) snd (hcompR {A = A} {B} φ w w0) = primComp (λ i → B (a i)) φ (λ i → (λ { (φ = i1) → snd (w i itIsOne) })) (snd (ouc w0)) where a = fill (λ z → A) (λ i → (λ { (φ = i1) → fst (w i itIsOne) }) ) (inc (fst (ouc w0))) trd (hcompR {A = A} {B} {C} φ w w0) = primComp (λ i → C (a i) (b i)) φ ((λ i → (λ { (φ = i1) → trd (w i itIsOne)}))) (trd (ouc w0)) where a = fill (λ z → A) (λ i → (λ { (φ = i1) → fst (w i itIsOne) }) ) (inc (fst (ouc w0))) b = fill (λ i → B (a i)) (λ i → (λ { (φ = i1) → snd (w i itIsOne) }) ) (inc (snd (ouc w0))) module _ {ℓ ℓ'} {A : Set ℓ} {B : A → Set ℓ'} {C : (x : A) → B x → Set ℓ} (let ℓ = _ ; Z : Set ℓ ; Z = R(A)(B)(C)) (φ : I) (u : ∀ i → Partial φ (Z)) (a : Z [ φ ↦ u i0 ]) where test-compR-fst : hcompR {A = A} {B} {C} φ u a .fst ≡ primHComp u (ouc a) .fst test-compR-fst = refl test-compR-snd : hcompR {A = A} {B} {C} φ u a .snd ≡ primHComp u (ouc a) .snd test-compR-snd = refl test-compR-trd : hcompR {A = A} {B} {C} φ u a .trd ≡ primHComp u (ouc a) .trd test-compR-trd = refl module _ {ℓ ℓ'} {A : I → Set ℓ} {B : ∀ i → A i → Set ℓ'} {C : ∀ i → (x : A i) → B i x → Set ℓ} (let ℓ = _ ; Z : I → Set ℓ ; Z i = R(A i)(B i)(C i)) where φ = i0 transpR : Z i0 → Z i1 fst (transpR w0) = primTransp A φ (fst w0) snd (transpR w0) = primTransp (\ i → B i (a i)) φ (snd w0) where a = transpFill {A' = A i0} φ (λ i → inc (A i)) (fst w0) trd (transpR w0) = primTransp (\ i → C i (a i) (b i)) φ (trd w0) where a = transpFill {A' = A i0} φ (λ i → inc (A i)) (fst w0) b = transpFill {A' = B i0 (a i0)} φ (λ i → inc (B i (a i))) (snd w0) module _ {ℓ ℓ'} {A : I → Set ℓ} {B : ∀ i → A i → Set ℓ'} {C : ∀ i → (x : A i) → B i x → Set ℓ} (let ℓ = _ ; Z : I → Set ℓ ; Z i = R(A i)(B i)(C i)) (a : Z i0) where test-transpR-fst : fst (transpR {A = A} {B} {C} a) ≡ fst (primTransp Z i0 a) test-transpR-fst = refl test-transpR-snd : snd (transpR {A = A} {B} {C} a) ≡ snd (primTransp Z i0 a) test-transpR-snd = refl test-transpR-trd : trd (transpR {A = A} {B} {C} a) ≡ trd (primTransp Z i0 a) test-transpR-trd = refl module _ {ℓ} {A : Set ℓ} {φ : I} {T : Partial φ (Set ℓ)} {e : PartialP φ (λ o → T o ≃ A)} where test-Glue-β : (t : PartialP φ T) (a : A [ φ ↦ (\ o → e o .fst (t o)) ]) → unglue {A = A} {φ = φ} {T = T} {e} (glue t (ouc a)) ≡ ouc a test-Glue-β _ _ = refl test-Glue-η : (b : Glue A T e) → (glue {φ = φ} (λ{ (φ = i1) → b }) (unglue {φ = φ} b)) ≡ b test-Glue-η b = refl module _ {ℓ} {A : Set ℓ} (let φ = i1) {T : Partial φ (Set ℓ)} {e : PartialP φ (λ o → T o ≃ A)} where test-unglue-0 : (b : Glue A T e) → unglue {A = A} {φ = φ} {T = T} {e} b ≡ e itIsOne .fst b test-unglue-0 _ = refl test-unglue-2 : (t : PartialP φ T) (a : A [ φ ↦ (\ o → e o .fst (t o)) ]) → unglue {A = A} {φ = φ} {T = T} {e} (glue {A = A}{φ = φ}{T = T}{e} t (ouc a)) ≡ e itIsOne .fst (t itIsOne) -- = a test-unglue-2 _ _ = refl test-glue-0 : (t : PartialP φ T) (a : A [ φ ↦ (\ o → e o .fst (t o)) ]) → (glue {A = A} {T = T} {e} t (ouc a)) ≡ t itIsOne test-glue-0 _ _ = refl eqToPath : ∀ {ℓ} {A B : Set ℓ} → A ≃ B → A ≡ B eqToPath {ℓ} {A} {B} f = λ i → Glue B ([ ~ i ↦ (λ _ → A) , i ↦ (λ _ → B) ]) ([ ~ i ↦ (λ{ (i = i0) → f }) , i ↦ (λ{ (i = i1) → pathToEquiv (λ _ → B) }) ]) univ = eqToPath not : Bool → Bool not true = false not false = true notnot : ∀ y → y ≡ not (not y) notnot true = refl notnot false = refl nothelp : ∀ y (y₁ : Σ Bool \ x → (not x ≡ y)) → (not y , sym (notnot y)) ≡ y₁ nothelp y (true , eq) = pathJ (λ y₁ eq' → (not y₁ , sym (notnot y₁)) ≡ (true , eq')) refl _ eq nothelp y (false , eq) = pathJ (λ y₁ eq' → (not y₁ , sym (notnot y₁)) ≡ (false , eq')) refl _ (eq) notEquiv : Bool ≃ Bool notEquiv = not , (λ { .equiv-proof y → (not y , sym (notnot y)) , nothelp y }) test : Bool test = primComp (λ i → univ {A = Bool} {B = Bool} notEquiv i) i0 (λ _ → empty) true test-test : test ≡ primComp (λ i → Bool) i0 (λ _ _ → false) (primComp (λ i → Bool) i0 (λ _ _ → false) (primComp (λ i → Bool) i0 (λ _ _ → false) (primComp (λ i → Bool) i0 (λ _ _ → false) (primComp (λ i → Bool) i0 (λ _ _ → false) (primComp (λ i → Bool) i0 (λ _ _ → false) (primComp (λ i → Bool) i0 (λ _ _ → false) (primComp (λ i → Bool) i0 (λ _ _ → false) (primComp (λ i → Bool) i0 (λ _ _ → false) false)))))))) test-test = refl test-test2 : test ≡ false test-test2 = refl test2 : Bool test2 = primComp (λ i → eqToPath {A = Bool} {B = Bool} notEquiv i) i0 (λ _ → empty) true test2-test : test2 ≡ primComp (λ _ → Bool) i0 (λ _ _ → false) (primComp (λ _ → Bool) i0 ((λ _ _ → false)) (primComp (λ _ → Bool) i0 ((λ _ _ → false)) (primComp (λ _ → Bool) i0 ((λ _ _ → false)) false))) test2-test = refl test3 : Bool test3 = primComp (λ i → eqToPath {A = Bool} {B = Bool} notEquiv i) i0 (λ _ → empty) true test3-test : test3 ≡ primComp (λ i → Bool) i0 (λ _ _ → false) (primComp (λ _ → Bool) i0 (λ _ _ → false) (primComp (λ i → Bool) i0 (λ _ _ → false) false)) test3-test = refl data D2 (A : Set) : Set where c1 : D2 A c2 : D2 A test5-test : ∀ j → primComp (λ i → D2 Bool) (j ∨ ~ j) (λ i → [ j ↦ (λ{ (j = i1) → c1 }) , ~ j ↦ (λ{ (j = i0) → c1 }) ]) c1 ≡ c1 test5-test j = refl test6-test : (j : I → I) → primComp (λ i → D2 Bool) (j i0) (λ i o → c1) c1 ≡ c1 test6-test j = refl test4-test : ∀ j → primComp (λ i → Bool) (j ∨ ~ j) (λ i → [ j ↦ (λ{ (j = i1) → false }) , ~ j ↦ (λ{ (j = i0) → false }) ] ) false ≡ false test4-test j = refl ListNot : List Bool ≡ List Bool ListNot = λ i → List (univ {A = Bool} {B = Bool} notEquiv i) trues : List Bool trues = true ∷ true ∷ [] falses : List Bool falses = primComp (λ i → ListNot i) i0 (λ _ → empty) trues test-falses : falses ≡ (false ∷ false ∷ []) test-falses = refl trues2 : List Bool trues2 = primComp (λ i → trans ListNot ListNot i) i0 (λ _ → empty) trues test-trues2 : trues2 ≡ trues test-trues2 = refl trues3 : List Bool trues3 = primComp (λ i → let p = trans ListNot ListNot in trans p p i) i0 (λ _ → empty) trues test-trues3 : trues3 ≡ trues test-trues3 = refl
{ "alphanum_fraction": 0.463385063, "avg_line_length": 33.895890411, "ext": "agda", "hexsha": "74fb4927f28813144373919569ac42af61930770", "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": "2fa8ede09451d43647f918dbfb24ff7b27c52edc", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "phadej/agda", "max_forks_repo_path": "test/Succeed/CubicalPrims.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2fa8ede09451d43647f918dbfb24ff7b27c52edc", "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": "phadej/agda", "max_issues_repo_path": "test/Succeed/CubicalPrims.agda", "max_line_length": 117, "max_stars_count": null, "max_stars_repo_head_hexsha": "2fa8ede09451d43647f918dbfb24ff7b27c52edc", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "phadej/agda", "max_stars_repo_path": "test/Succeed/CubicalPrims.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5239, "size": 12372 }
{- Mayer-Vietoris cofiber sequence: Let X be a pointed type, and let a span B ←[f]- X -[g]→ C be given. Then the mapping cone of the canonical map (B ⋁ C) → B ⊔_X C is equivalent to Susp X. The sequence Susp X → (B ⋁ C) → B ⊔_X C therefore induces a long exact sequence in cohomology. Proof is adapted from Evan Cavallo's master's thesis. -} {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Homotopy.MayerVietorisCofiber where open import Cubical.Core.Everything open import Cubical.Foundations.Everything open import Cubical.Foundations.Pointed open import Cubical.Data.Unit open import Cubical.HITs.MappingCones open import Cubical.HITs.Pushout open import Cubical.HITs.Susp open import Cubical.HITs.Wedge module _ {ℓX ℓB ℓC} {X : Pointed ℓX} {B : Type ℓB} {C : Type ℓC} (f : X .fst → B) (g : X .fst → C) where private Y : Pointed _ Y = (B , f (X .snd)) Z : Pointed _ Z = (C , g (X .snd)) wedgeToPushout : Y ⋁ Z → Pushout f g wedgeToPushout (inl y) = inl y wedgeToPushout (inr z) = inr z wedgeToPushout (push _ i) = push (pt X) i pushoutToSusp : Pushout f g → Susp (X .fst) pushoutToSusp (inl y) = north pushoutToSusp (inr z) = south pushoutToSusp (push x i) = merid x i {- Coherence lemma: To construct a function f : (c : Cone wedgeToPushout) → D c, we can always adjust the definition of (f (spoke (inr z) i)) so that there is a canonical choice for (f (spoke (push tt j) i)) -} module Helper {ℓD} {D : Cone wedgeToPushout → Type ℓD} (inj* : ∀ w → D (inj w)) (hub* : D hub) (inl* : ∀ y → PathP (λ i → D (spoke (inl y) i)) hub* (inj* (inl y))) (inr* : ∀ z → PathP (λ i → D (spoke (inr z) i)) hub* (inj* (inr z))) where cap : (i j : I) → D (spoke (push tt j) i) cap i j = fill (λ i → D (spoke (push tt j) (~ i))) (λ i → λ { (j = i0) → inl* (Y .snd) (~ i) ; (j = i1) → inr* (Z .snd) (~ i) }) (inS (inj* (push (X .snd) j))) (~ i) cap0 : (j : I) → D hub cap0 = cap i0 face-i≡0 : (k j : I) → D hub face-i≡0 k j = hfill (λ j → λ { (k = i0) → cap0 j ; (k = i1) → hub* }) (inS hub*) j inrFiller : ∀ z → (k i : I) → D (spoke (inr z) i) inrFiller z k i = hfill (λ k → λ { (i = i0) → face-i≡0 k i1 ; (i = i1) → inj* (inr z) }) (inS (inr* z i)) k fun : ∀ c → D c fun (inj w) = inj* w fun hub = hub* fun (spoke (inl y) i) = inl* y i fun (spoke (inr z) i) = inrFiller z i1 i fun (spoke (push tt j) i) = hcomp (λ k → λ { (i = i0) → face-i≡0 k j ; (i = i1) → inj* (push (X .snd) j) ; (j = i0) → inl* (Y .snd) i }) (cap i j) equiv : Cone wedgeToPushout ≃ Susp (X .fst) equiv = isoToEquiv (iso fwd bwd fwdBwd bwdFwd) where fwd : Cone wedgeToPushout → Susp (X .fst) fwd (inj w) = pushoutToSusp w fwd hub = north fwd (spoke (inl y) i) = north fwd (spoke (inr z) i) = merid (X .snd) i fwd (spoke (push tt j) i) = merid (X .snd) (i ∧ j) bwd : Susp (X .fst) → Cone wedgeToPushout bwd north = hub bwd south = hub bwd (merid x i) = hcomp (λ k → λ { (i = i0) → spoke (inl (f x)) (~ k) ; (i = i1) → spoke (inr (g x)) (~ k) }) (inj (push x i)) bwdPushout : (w : Pushout f g) → bwd (pushoutToSusp w) ≡ inj w bwdPushout (inl y) = spoke (inl y) bwdPushout (inr z) = spoke (inr z) bwdPushout (push x i) k = hfill (λ k → λ { (i = i0) → spoke (inl (f x)) (~ k) ; (i = i1) → spoke (inr (g x)) (~ k) }) (inS (inj (push x i))) (~ k) bwdMeridPt : refl ≡ cong bwd (merid (X .snd)) bwdMeridPt j i = hcomp (λ k → λ { (i = i0) → spoke (inl (Y .snd)) (~ k) ; (i = i1) → spoke (inr (Z .snd)) (~ k) ; (j = i0) → spoke (push _ i) (~ k) }) (inj (push (X .snd) i)) bwdFwd : (c : Cone wedgeToPushout) → bwd (fwd c) ≡ c bwdFwd = Helper.fun bwdPushout refl (λ y i k → spoke (inl y) (i ∧ k)) (λ z i k → hcomp (λ l → λ { (i = i0) → hub ; (i = i1) → spoke (inr z) k ; (k = i0) → bwdMeridPt l i ; (k = i1) → spoke (inr z) i }) (spoke (inr z) (i ∧ k))) fwdBwd : (s : Susp (X .fst)) → fwd (bwd s) ≡ s fwdBwd north = refl fwdBwd south = merid (X .snd) fwdBwd (merid a i) j = fill (λ _ → Susp (X .fst)) (λ j → λ { (i = i0) → north ; (i = i1) → merid (X .snd) (~ j) }) (inS (merid a i)) (~ j)
{ "alphanum_fraction": 0.4796361381, "avg_line_length": 27.4829545455, "ext": "agda", "hexsha": "58f0198d7491192df17ede548b8169334569fd42", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Homotopy/MayerVietorisCofiber.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Homotopy/MayerVietorisCofiber.agda", "max_line_length": 98, "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/Homotopy/MayerVietorisCofiber.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1884, "size": 4837 }
------------------------------------------------------------------------------ -- Conversion rules for the greatest common divisor ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Program.GCD.Total.ConversionRulesI where open import Common.FOL.Relation.Binary.EqReasoning open import FOTC.Base open import FOTC.Data.Nat open import FOTC.Data.Nat.Inequalities open import FOTC.Program.GCD.Total.GCD ------------------------------------------------------------------------------ private -- Before to prove some properties for the gcd it is convenient to -- descompose the behavior of the function step by step. -- Initially, we define the possible states (gcd-s₁, gcd-s₂, -- ...). Then we write down the proof for the execution step from -- the state p to the state q, e.g. -- -- proof₂₋₃ : ∀ m n → gcd-s₂ m n → gcd-s₃ m n. -- The functions gcd-00, gcd-S0, gcd-0S, gcd-Sm>Sn and gcd-Sm≯Sn -- show the use of the states gcd-s₁, gcd-s₂, ..., and the proofs -- associated with the execution steps. ---------------------------------------------------------------------------- -- The steps -- Initially, the equation gcd-eq is used. gcd-s₁ : D → D → D gcd-s₁ m n = if (iszero₁ n) then m else (if (iszero₁ m) then n else (if (gt m n) then gcd (m ∸ n) n else gcd m (n ∸ m))) -- First if_then_else_ (iszero₁ n). gcd-s₂ : D → D → D → D gcd-s₂ m n b = if b then m else (if (iszero₁ m) then n else (if (gt m n) then gcd (m ∸ n) n else gcd m (n ∸ m))) -- First if_then_else_ when iszero₁ n = true. gcd-s₃ : D → D gcd-s₃ m = m -- First if_then_else_ when iszero₁ n = false. gcd-s₄ : D → D → D gcd-s₄ m n = if (iszero₁ m) then n else (if (gt m n) then gcd (m ∸ n) n else gcd m (n ∸ m)) -- Second if_then_else_ (iszero₁ m). gcd-s₈ : D → D → D → D gcd-s₈ m n b = if b then n else (if (gt m n) then gcd (m ∸ n) n else gcd m (n ∸ m)) -- Second if_then_else_, when iszero₁ m = true. gcd-s₉ : D → D gcd-s₉ n = n -- Second if_then_else_, when iszero₁ m = false. gcd-s₁₀ : D → D → D gcd-s₁₀ m n = if (gt m n) then gcd (m ∸ n) n else gcd m (n ∸ m) -- Third if_then_else_ (gt m n). gcd-s₁₁ : D → D → D → D gcd-s₁₁ m n b = if b then gcd (m ∸ n) n else gcd m (n ∸ m) -- Third if_then_else_ when gt m n = true. gcd-s₁₂ : D → D → D gcd-s₁₂ m n = gcd (m ∸ n) n -- Fourth if_then_else_ when gt m n = false. gcd-s₁₃ : D → D → D gcd-s₁₃ m n = gcd m (n ∸ m) ---------------------------------------------------------------------------- -- The execution steps {- To prove the execution steps, e.g. proof₃₋₄ : ∀ m n → gcd-s₃ m n → gcd_s₄ m n) we usually need to prove that C [m] ≡ C [n] (1) given that m ≡ n, (2) where (2) is a conversion rule usually. We prove (1) using subst : ∀ {x y} (D : A → Set) → x ≡ y → P x → P y where • P is given by λ m → C [m ] ≡ C [n], • x ≡ y is given n ≡ m (actually, we use sym (m ≡ n)) and • P x is given by C [n] ≡ C [n] (i.e. refl). -} proof₀₋₁ : ∀ m n → gcd m n ≡ gcd-s₁ m n proof₀₋₁ = gcd-eq -- 25 April 2014. Failed with Andreas' --without-K. proof₁₋₂ : ∀ m n b → iszero₁ n ≡ b → gcd-s₁ m n ≡ gcd-s₂ m n b proof₁₋₂ m n .(iszero₁ n) refl = refl proof₂₋₃ : ∀ m n → gcd-s₂ m n true ≡ gcd-s₃ m proof₂₋₃ m _ = if-true (gcd-s₃ m) proof₂₋₄ : ∀ m n → gcd-s₂ m n false ≡ gcd-s₄ m n proof₂₋₄ m n = if-false (gcd-s₄ m n) proof₄₋₈ : ∀ m n b → iszero₁ m ≡ b → gcd-s₄ m n ≡ gcd-s₈ m n b proof₄₋₈ m n .(iszero₁ m) refl = refl proof₈₋₉ : ∀ m n → gcd-s₈ m n true ≡ gcd-s₉ n proof₈₋₉ _ n = if-true n proof₈₋₁₀ : ∀ m n → gcd-s₈ m n false ≡ gcd-s₁₀ m n proof₈₋₁₀ m n = if-false (gcd-s₁₀ m n) proof₁₀₋₁₁ : ∀ m n b → gt m n ≡ b → gcd-s₁₀ m n ≡ gcd-s₁₁ m n b proof₁₀₋₁₁ m n .(lt n m) refl = refl proof₁₁₋₁₂ : ∀ m n → gcd-s₁₁ m n true ≡ gcd-s₁₂ m n proof₁₁₋₁₂ m n = if-true (gcd (m ∸ n) n) proof₁₁₋₁₃ : ∀ m n → gcd-s₁₁ m n false ≡ gcd-s₁₃ m n proof₁₁₋₁₃ m n = if-false (gcd m (n ∸ m)) ------------------------------------------------------------------------------ -- The five equations for gcd -- First equation. gcd-00 : gcd zero zero ≡ zero gcd-00 = gcd zero zero ≡⟨ proof₀₋₁ zero zero ⟩ gcd-s₁ zero zero ≡⟨ proof₁₋₂ zero zero true iszero-0 ⟩ gcd-s₂ zero zero true ≡⟨ proof₂₋₃ zero zero ⟩ zero ∎ -- Second equation. gcd-S0 : ∀ n → gcd (succ₁ n) zero ≡ succ₁ n gcd-S0 n = gcd (succ₁ n) zero ≡⟨ proof₀₋₁ (succ₁ n) zero ⟩ gcd-s₁ (succ₁ n) zero ≡⟨ proof₁₋₂ (succ₁ n) zero true iszero-0 ⟩ gcd-s₂ (succ₁ n) zero true ≡⟨ proof₂₋₃ (succ₁ n) zero ⟩ succ₁ n ∎ -- Third equation. gcd-0S : ∀ n → gcd zero (succ₁ n) ≡ succ₁ n gcd-0S n = gcd zero (succ₁ n) ≡⟨ proof₀₋₁ zero (succ₁ n) ⟩ gcd-s₁ zero (succ₁ n) ≡⟨ proof₁₋₂ zero (succ₁ n) false (iszero-S n) ⟩ gcd-s₂ zero (succ₁ n) false ≡⟨ proof₂₋₄ zero (succ₁ n) ⟩ gcd-s₄ zero (succ₁ n) ≡⟨ proof₄₋₈ zero (succ₁ n) true iszero-0 ⟩ gcd-s₈ zero (succ₁ n) true ≡⟨ proof₈₋₉ zero (succ₁ n) ⟩ succ₁ n ∎ -- Fourth equation. gcd-S>S : ∀ m n → succ₁ m > succ₁ n → gcd (succ₁ m) (succ₁ n) ≡ gcd (succ₁ m ∸ succ₁ n) (succ₁ n) gcd-S>S m n Sm>Sn = gcd (succ₁ m) (succ₁ n) ≡⟨ proof₀₋₁ (succ₁ m) (succ₁ n) ⟩ gcd-s₁ (succ₁ m) (succ₁ n) ≡⟨ proof₁₋₂ (succ₁ m) (succ₁ n) false (iszero-S n) ⟩ gcd-s₂ (succ₁ m) (succ₁ n) false ≡⟨ proof₂₋₄ (succ₁ m) (succ₁ n) ⟩ gcd-s₄ (succ₁ m) (succ₁ n) ≡⟨ proof₄₋₈ (succ₁ m) (succ₁ n) false (iszero-S m) ⟩ gcd-s₈ (succ₁ m) (succ₁ n) false ≡⟨ proof₈₋₁₀ (succ₁ m) (succ₁ n) ⟩ gcd-s₁₀ (succ₁ m) (succ₁ n) ≡⟨ proof₁₀₋₁₁ (succ₁ m) (succ₁ n) true Sm>Sn ⟩ gcd-s₁₁ (succ₁ m) (succ₁ n) true ≡⟨ proof₁₁₋₁₂ (succ₁ m) (succ₁ n) ⟩ gcd (succ₁ m ∸ succ₁ n) (succ₁ n) ∎ -- Fifth equation. gcd-S≯S : ∀ m n → succ₁ m ≯ succ₁ n → gcd (succ₁ m) (succ₁ n) ≡ gcd (succ₁ m) (succ₁ n ∸ succ₁ m) gcd-S≯S m n Sm≯Sn = gcd (succ₁ m) (succ₁ n) ≡⟨ proof₀₋₁ (succ₁ m) (succ₁ n) ⟩ gcd-s₁ (succ₁ m) (succ₁ n) ≡⟨ proof₁₋₂ (succ₁ m) (succ₁ n) false (iszero-S n) ⟩ gcd-s₂ (succ₁ m) (succ₁ n) false ≡⟨ proof₂₋₄ (succ₁ m) (succ₁ n) ⟩ gcd-s₄ (succ₁ m) (succ₁ n) ≡⟨ proof₄₋₈ (succ₁ m) (succ₁ n) false (iszero-S m) ⟩ gcd-s₈ (succ₁ m) (succ₁ n) false ≡⟨ proof₈₋₁₀ (succ₁ m) (succ₁ n) ⟩ gcd-s₁₀ (succ₁ m) (succ₁ n) ≡⟨ proof₁₀₋₁₁ (succ₁ m) (succ₁ n) false Sm≯Sn ⟩ gcd-s₁₁ (succ₁ m) (succ₁ n) false ≡⟨ proof₁₁₋₁₃ (succ₁ m) (succ₁ n) ⟩ gcd (succ₁ m) (succ₁ n ∸ succ₁ m) ∎
{ "alphanum_fraction": 0.5001396258, "avg_line_length": 34.7669902913, "ext": "agda", "hexsha": "a257f82bb05307fc6b3ad52f3aea0a1165c014d4", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/FOTC/Program/GCD/Total/ConversionRulesI.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/FOTC/Program/GCD/Total/ConversionRulesI.agda", "max_line_length": 88, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/FOTC/Program/GCD/Total/ConversionRulesI.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": 2768, "size": 7162 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Properties satisfied by Heyting Algebra ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Relation.Binary.Lattice module Relation.Binary.Properties.HeytingAlgebra {c ℓ₁ ℓ₂} (L : HeytingAlgebra c ℓ₁ ℓ₂) where open HeytingAlgebra L open import Algebra.FunctionProperties _≈_ open import Data.Product using (_,_) open import Function using (_$_; flip; _∘_) open import Level using (_⊔_) open import Relation.Binary import Relation.Binary.Reasoning.PartialOrder as POR open import Relation.Binary.Properties.MeetSemilattice meetSemilattice open import Relation.Binary.Properties.JoinSemilattice joinSemilattice import Relation.Binary.Properties.BoundedMeetSemilattice boundedMeetSemilattice as BM open import Relation.Binary.Properties.Lattice lattice open import Relation.Binary.Properties.BoundedLattice boundedLattice import Relation.Binary.Reasoning.Setoid as EqReasoning ------------------------------------------------------------------------ -- Useful lemmas ⇨-eval : ∀ {x y} → (x ⇨ y) ∧ x ≤ y ⇨-eval {x} {y} = transpose-∧ refl swap-transpose-⇨ : ∀ {x y w} → x ∧ w ≤ y → w ≤ x ⇨ y swap-transpose-⇨ x∧w≤y = transpose-⇨ $ trans (reflexive $ ∧-comm _ _) x∧w≤y ------------------------------------------------------------------------ -- Properties of exponential ⇨-unit : ∀ {x} → x ⇨ x ≈ ⊤ ⇨-unit = antisym (maximum _) (transpose-⇨ $ reflexive $ BM.identityˡ _) y≤x⇨y : ∀ {x y} → y ≤ x ⇨ y y≤x⇨y = transpose-⇨ (x∧y≤x _ _) ⇨-drop : ∀ {x y} → (x ⇨ y) ∧ y ≈ y ⇨-drop = antisym (x∧y≤y _ _) (∧-greatest y≤x⇨y refl) ⇨-app : ∀ {x y} → (x ⇨ y) ∧ x ≈ y ∧ x ⇨-app = antisym (∧-greatest ⇨-eval (x∧y≤y _ _)) (∧-monotonic y≤x⇨y refl) ⇨ʳ-covariant : ∀ {x} → (x ⇨_) Preserves _≤_ ⟶ _≤_ ⇨ʳ-covariant y≤z = transpose-⇨ (trans ⇨-eval y≤z) ⇨ˡ-contravariant : ∀ {x} → (_⇨ x) Preserves (flip _≤_) ⟶ _≤_ ⇨ˡ-contravariant z≤y = transpose-⇨ (trans (∧-monotonic refl z≤y) ⇨-eval) ⇨-relax : _⇨_ Preserves₂ (flip _≤_) ⟶ _≤_ ⟶ _≤_ ⇨-relax {x} {y} {u} {v} y≤x u≤v = begin x ⇨ u ≤⟨ ⇨ʳ-covariant u≤v ⟩ x ⇨ v ≤⟨ ⇨ˡ-contravariant y≤x ⟩ y ⇨ v ∎ where open POR poset ⇨-cong : _⇨_ Preserves₂ _≈_ ⟶ _≈_ ⟶ _≈_ ⇨-cong x≈y u≈v = antisym (⇨-relax (reflexive $ Eq.sym x≈y) (reflexive u≈v)) (⇨-relax (reflexive x≈y) (reflexive $ Eq.sym u≈v)) ⇨-applyˡ : ∀ {w x y} → w ≤ x → (x ⇨ y) ∧ w ≤ y ⇨-applyˡ = transpose-∧ ∘ ⇨ˡ-contravariant ⇨-applyʳ : ∀ {w x y} → w ≤ x → w ∧ (x ⇨ y) ≤ y ⇨-applyʳ w≤x = trans (reflexive (∧-comm _ _)) (⇨-applyˡ w≤x) ⇨-curry : ∀ {x y z} → x ∧ y ⇨ z ≈ x ⇨ y ⇨ z ⇨-curry = antisym (transpose-⇨ $ transpose-⇨ $ trans (reflexive $ ∧-assoc _ _ _) ⇨-eval) (transpose-⇨ $ trans (reflexive $ Eq.sym $ ∧-assoc _ _ _) (transpose-∧ $ ⇨-applyˡ refl)) ------------------------------------------------------------------------ -- Various proofs of distributivity ∧-distribˡ-∨-≤ : ∀ x y z → x ∧ (y ∨ z) ≤ x ∧ y ∨ x ∧ z ∧-distribˡ-∨-≤ x y z = trans (reflexive $ ∧-comm _ _) (transpose-∧ $ ∨-least (swap-transpose-⇨ (x≤x∨y _ _)) $ swap-transpose-⇨ (y≤x∨y _ _)) ∧-distribˡ-∨-≥ : ∀ x y z → x ∧ y ∨ x ∧ z ≤ x ∧ (y ∨ z) ∧-distribˡ-∨-≥ x y z = let x∧y≤x , x∧y≤y , _ = infimum x y x∧z≤x , x∧z≤z , _ = infimum x z y≤y∨z , z≤y∨z , _ = supremum y z in ∧-greatest (∨-least x∧y≤x x∧z≤x) (∨-least (trans x∧y≤y y≤y∨z) (trans x∧z≤z z≤y∨z)) ∧-distribˡ-∨ : _∧_ DistributesOverˡ _∨_ ∧-distribˡ-∨ x y z = antisym (∧-distribˡ-∨-≤ x y z) (∧-distribˡ-∨-≥ x y z) ⇨-distribˡ-∧-≤ : ∀ x y z → x ⇨ y ∧ z ≤ (x ⇨ y) ∧ (x ⇨ z) ⇨-distribˡ-∧-≤ x y z = let y∧z≤y , y∧z≤z , _ = infimum y z in ∧-greatest (transpose-⇨ $ trans ⇨-eval y∧z≤y) (transpose-⇨ $ trans ⇨-eval y∧z≤z) ⇨-distribˡ-∧-≥ : ∀ x y z → (x ⇨ y) ∧ (x ⇨ z) ≤ x ⇨ y ∧ z ⇨-distribˡ-∧-≥ x y z = transpose-⇨ (begin (((x ⇨ y) ∧ (x ⇨ z)) ∧ x) ≈⟨ ∧-cong Eq.refl $ Eq.sym $ ∧-idempotent _ ⟩ (((x ⇨ y) ∧ (x ⇨ z)) ∧ x ∧ x) ≈⟨ Eq.sym $ ∧-assoc _ _ _ ⟩ (((x ⇨ y) ∧ (x ⇨ z)) ∧ x) ∧ x ≈⟨ ∧-cong (∧-assoc _ _ _) Eq.refl ⟩ (((x ⇨ y) ∧ (x ⇨ z) ∧ x) ∧ x) ≈⟨ ∧-cong (∧-cong Eq.refl $ ∧-comm _ _) Eq.refl ⟩ (((x ⇨ y) ∧ x ∧ (x ⇨ z)) ∧ x) ≈⟨ ∧-cong (Eq.sym $ ∧-assoc _ _ _) Eq.refl ⟩ (((x ⇨ y) ∧ x) ∧ (x ⇨ z)) ∧ x ≈⟨ ∧-assoc _ _ _ ⟩ (((x ⇨ y) ∧ x) ∧ (x ⇨ z) ∧ x) ≤⟨ ∧-monotonic ⇨-eval ⇨-eval ⟩ y ∧ z ∎) where open POR poset ⇨-distribˡ-∧ : _⇨_ DistributesOverˡ _∧_ ⇨-distribˡ-∧ x y z = antisym (⇨-distribˡ-∧-≤ x y z) (⇨-distribˡ-∧-≥ x y z) ⇨-distribˡ-∨-∧-≤ : ∀ x y z → x ∨ y ⇨ z ≤ (x ⇨ z) ∧ (y ⇨ z) ⇨-distribˡ-∨-∧-≤ x y z = let x≤x∨y , y≤x∨y , _ = supremum x y in ∧-greatest (transpose-⇨ $ trans (∧-monotonic refl x≤x∨y) ⇨-eval) (transpose-⇨ $ trans (∧-monotonic refl y≤x∨y) ⇨-eval) ⇨-distribˡ-∨-∧-≥ : ∀ x y z → (x ⇨ z) ∧ (y ⇨ z) ≤ x ∨ y ⇨ z ⇨-distribˡ-∨-∧-≥ x y z = transpose-⇨ (trans (reflexive $ ∧-distribˡ-∨ _ _ _) (∨-least (trans (transpose-∧ (x∧y≤x _ _)) refl) (trans (transpose-∧ (x∧y≤y _ _)) refl))) ⇨-distribˡ-∨-∧ : ∀ x y z → x ∨ y ⇨ z ≈ (x ⇨ z) ∧ (y ⇨ z) ⇨-distribˡ-∨-∧ x y z = antisym (⇨-distribˡ-∨-∧-≤ x y z) (⇨-distribˡ-∨-∧-≥ x y z) ------------------------------------------------------------------------ -- Heyting algebras are distributive lattices isDistributiveLattice : IsDistributiveLattice _≈_ _≤_ _∨_ _∧_ isDistributiveLattice = record { isLattice = isLattice ; ∧-distribˡ-∨ = ∧-distribˡ-∨ } distributiveLattice : DistributiveLattice _ _ _ distributiveLattice = record { isDistributiveLattice = isDistributiveLattice } ------------------------------------------------------------------------ -- Heyting algebras can define pseudo-complement infix 8 ¬_ ¬_ : Op₁ Carrier ¬ x = x ⇨ ⊥ x≤¬¬x : ∀ x → x ≤ ¬ ¬ x x≤¬¬x x = transpose-⇨ (trans (reflexive (∧-comm _ _)) ⇨-eval) ------------------------------------------------------------------------ -- De-Morgan laws de-morgan₁ : ∀ x y → ¬ (x ∨ y) ≈ ¬ x ∧ ¬ y de-morgan₁ x y = ⇨-distribˡ-∨-∧ _ _ _ de-morgan₂-≤ : ∀ x y → ¬ (x ∧ y) ≤ ¬ ¬ (¬ x ∨ ¬ y) de-morgan₂-≤ x y = transpose-⇨ $ begin ¬ (x ∧ y) ∧ ¬ (¬ x ∨ ¬ y) ≈⟨ ∧-cong ⇨-curry (de-morgan₁ _ _) ⟩ (x ⇨ ¬ y) ∧ ¬ ¬ x ∧ ¬ ¬ y ≈⟨ ∧-cong Eq.refl (∧-comm _ _) ⟩ (x ⇨ ¬ y) ∧ ¬ ¬ y ∧ ¬ ¬ x ≈⟨ Eq.sym $ ∧-assoc _ _ _ ⟩ ((x ⇨ ¬ y) ∧ ¬ ¬ y) ∧ ¬ ¬ x ≤⟨ ⇨-applyʳ $ transpose-⇨ $ begin ((x ⇨ ¬ y) ∧ ¬ ¬ y) ∧ x ≈⟨ ∧-cong (∧-comm _ _) Eq.refl ⟩ ((¬ ¬ y) ∧ (x ⇨ ¬ y)) ∧ x ≈⟨ ∧-assoc _ _ _ ⟩ (¬ ¬ y) ∧ (x ⇨ ¬ y) ∧ x ≤⟨ ∧-monotonic refl ⇨-eval ⟩ ¬ ¬ y ∧ ¬ y ≤⟨ ⇨-eval ⟩ ⊥ ∎ ⟩ ⊥ ∎ where open POR poset de-morgan₂-≥ : ∀ x y → ¬ ¬ (¬ x ∨ ¬ y) ≤ ¬ (x ∧ y) de-morgan₂-≥ x y = transpose-⇨ $ ⇨-applyˡ $ transpose-⇨ $ begin (x ∧ y) ∧ (¬ x ∨ ¬ y) ≈⟨ ∧-distribˡ-∨ _ _ _ ⟩ (x ∧ y) ∧ ¬ x ∨ (x ∧ y) ∧ ¬ y ≤⟨ ∨-monotonic (⇨-applyʳ (x∧y≤x _ _)) (⇨-applyʳ (x∧y≤y _ _)) ⟩ ⊥ ∨ ⊥ ≈⟨ ∨-idempotent _ ⟩ ⊥ ∎ where open POR poset de-morgan₂ : ∀ x y → ¬ (x ∧ y) ≈ ¬ ¬ (¬ x ∨ ¬ y) de-morgan₂ x y = antisym (de-morgan₂-≤ x y) (de-morgan₂-≥ x y) weak-lem : ∀ {x} → ¬ ¬ (¬ x ∨ x) ≈ ⊤ weak-lem {x} = begin ¬ ¬ (¬ x ∨ x) ≈⟨ ⇨-cong (de-morgan₁ _ _) Eq.refl ⟩ ¬ (¬ ¬ x ∧ ¬ x) ≈⟨ ⇨-cong ⇨-app Eq.refl ⟩ ⊥ ∧ (x ⇨ ⊥) ⇨ ⊥ ≈⟨ ⇨-cong (∧-zeroˡ _) Eq.refl ⟩ ⊥ ⇨ ⊥ ≈⟨ ⇨-unit ⟩ ⊤ ∎ where open EqReasoning setoid
{ "alphanum_fraction": 0.4679757512, "avg_line_length": 38.1306532663, "ext": "agda", "hexsha": "e84d1705c3f72f00e50784d1c98cee7ed9c38f7a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Properties/HeytingAlgebra.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Properties/HeytingAlgebra.agda", "max_line_length": 88, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Properties/HeytingAlgebra.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3537, "size": 7588 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Many properties which hold for _∼_ also hold for flip _∼_ ------------------------------------------------------------------------ open import Relation.Binary module Relation.Binary.Flip where open import Function open import Data.Product implies : ∀ {a b ℓ₁ ℓ₂} {A : Set a} {B : Set b} (≈ : REL A B ℓ₁) (∼ : REL A B ℓ₂) → ≈ ⇒ ∼ → flip ≈ ⇒ flip ∼ implies _ _ impl = impl reflexive : ∀ {a ℓ} {A : Set a} (∼ : Rel A ℓ) → Reflexive ∼ → Reflexive (flip ∼) reflexive _ refl = refl irreflexive : ∀ {a b ℓ₁ ℓ₂} {A : Set a} {B : Set b} (≈ : REL A B ℓ₁) (∼ : REL A B ℓ₂) → Irreflexive ≈ ∼ → Irreflexive (flip ≈) (flip ∼) irreflexive _ _ irrefl = irrefl symmetric : ∀ {a ℓ} {A : Set a} (∼ : Rel A ℓ) → Symmetric ∼ → Symmetric (flip ∼) symmetric _ sym = sym transitive : ∀ {a ℓ} {A : Set a} (∼ : Rel A ℓ) → Transitive ∼ → Transitive (flip ∼) transitive _ trans = flip trans antisymmetric : ∀ {a ℓ₁ ℓ₂} {A : Set a} (≈ : Rel A ℓ₁) (≤ : Rel A ℓ₂) → Antisymmetric ≈ ≤ → Antisymmetric (flip ≈) (flip ≤) antisymmetric _ _ antisym = antisym asymmetric : ∀ {a ℓ} {A : Set a} (< : Rel A ℓ) → Asymmetric < → Asymmetric (flip <) asymmetric _ asym = asym respects : ∀ {a ℓ p} {A : Set a} (∼ : Rel A ℓ) (P : A → Set p) → Symmetric ∼ → P Respects ∼ → P Respects flip ∼ respects _ _ sym resp ∼ = resp (sym ∼) respects₂ : ∀ {a ℓ₁ ℓ₂} {A : Set a} (∼₁ : Rel A ℓ₁) (∼₂ : Rel A ℓ₂) → Symmetric ∼₂ → ∼₁ Respects₂ ∼₂ → flip ∼₁ Respects₂ flip ∼₂ respects₂ _ _ sym (resp₁ , resp₂) = ((λ {_} {_} {_} ∼ → resp₂ (sym ∼)) , λ {_} {_} {_} ∼ → resp₁ (sym ∼)) decidable : ∀ {a b ℓ} {A : Set a} {B : Set b} (∼ : REL A B ℓ) → Decidable ∼ → Decidable (flip ∼) decidable _ dec x y = dec y x total : ∀ {a ℓ} {A : Set a} (∼ : Rel A ℓ) → Total ∼ → Total (flip ∼) total _ tot x y = tot y x trichotomous : ∀ {a ℓ₁ ℓ₂} {A : Set a} (≈ : Rel A ℓ₁) (< : Rel A ℓ₂) → Trichotomous ≈ < → Trichotomous (flip ≈) (flip <) trichotomous _ _ compare x y = compare y x isEquivalence : ∀ {a ℓ} {A : Set a} {≈ : Rel A ℓ} → IsEquivalence ≈ → IsEquivalence (flip ≈) isEquivalence {≈ = ≈} eq = record { refl = reflexive ≈ Eq.refl ; sym = symmetric ≈ Eq.sym ; trans = transitive ≈ Eq.trans } where module Eq = IsEquivalence eq setoid : ∀ {s₁ s₂} → Setoid s₁ s₂ → Setoid s₁ s₂ setoid S = record { _≈_ = flip S._≈_ ; isEquivalence = isEquivalence S.isEquivalence } where module S = Setoid S isPreorder : ∀ {a ℓ₁ ℓ₂} {A : Set a} {≈ : Rel A ℓ₁} {∼ : Rel A ℓ₂} → IsPreorder ≈ ∼ → IsPreorder (flip ≈) (flip ∼) isPreorder {≈ = ≈} {∼} pre = record { isEquivalence = isEquivalence Pre.isEquivalence ; reflexive = implies ≈ ∼ Pre.reflexive ; trans = transitive ∼ Pre.trans } where module Pre = IsPreorder pre preorder : ∀ {p₁ p₂ p₃} → Preorder p₁ p₂ p₃ → Preorder p₁ p₂ p₃ preorder P = record { _∼_ = flip P._∼_ ; _≈_ = flip P._≈_ ; isPreorder = isPreorder P.isPreorder } where module P = Preorder P isDecEquivalence : ∀ {a ℓ} {A : Set a} {≈ : Rel A ℓ} → IsDecEquivalence ≈ → IsDecEquivalence (flip ≈) isDecEquivalence {≈ = ≈} dec = record { isEquivalence = isEquivalence Dec.isEquivalence ; _≟_ = decidable ≈ Dec._≟_ } where module Dec = IsDecEquivalence dec decSetoid : ∀ {s₁ s₂} → DecSetoid s₁ s₂ → DecSetoid s₁ s₂ decSetoid S = record { _≈_ = flip S._≈_ ; isDecEquivalence = isDecEquivalence S.isDecEquivalence } where module S = DecSetoid S isPartialOrder : ∀ {a ℓ₁ ℓ₂} {A : Set a} {≈ : Rel A ℓ₁} {≤ : Rel A ℓ₂} → IsPartialOrder ≈ ≤ → IsPartialOrder (flip ≈) (flip ≤) isPartialOrder {≈ = ≈} {≤} po = record { isPreorder = isPreorder Po.isPreorder ; antisym = antisymmetric ≈ ≤ Po.antisym } where module Po = IsPartialOrder po poset : ∀ {p₁ p₂ p₃} → Poset p₁ p₂ p₃ → Poset p₁ p₂ p₃ poset O = record { _≈_ = flip O._≈_ ; _≤_ = flip O._≤_ ; isPartialOrder = isPartialOrder O.isPartialOrder } where module O = Poset O isStrictPartialOrder : ∀ {a ℓ₁ ℓ₂} {A : Set a} {≈ : Rel A ℓ₁} {< : Rel A ℓ₂} → IsStrictPartialOrder ≈ < → IsStrictPartialOrder (flip ≈) (flip <) isStrictPartialOrder {≈ = ≈} {<} spo = record { isEquivalence = isEquivalence Spo.isEquivalence ; irrefl = irreflexive ≈ < Spo.irrefl ; trans = transitive < Spo.trans ; <-resp-≈ = respects₂ < ≈ Spo.Eq.sym Spo.<-resp-≈ } where module Spo = IsStrictPartialOrder spo strictPartialOrder : ∀ {s₁ s₂ s₃} → StrictPartialOrder s₁ s₂ s₃ → StrictPartialOrder s₁ s₂ s₃ strictPartialOrder O = record { _≈_ = flip O._≈_ ; _<_ = flip O._<_ ; isStrictPartialOrder = isStrictPartialOrder O.isStrictPartialOrder } where module O = StrictPartialOrder O isTotalOrder : ∀ {a ℓ₁ ℓ₂} {A : Set a} {≈ : Rel A ℓ₁} {≤ : Rel A ℓ₂} → IsTotalOrder ≈ ≤ → IsTotalOrder (flip ≈) (flip ≤) isTotalOrder {≈ = ≈} {≤} to = record { isPartialOrder = isPartialOrder To.isPartialOrder ; total = total ≤ To.total } where module To = IsTotalOrder to totalOrder : ∀ {t₁ t₂ t₃} → TotalOrder t₁ t₂ t₃ → TotalOrder t₁ t₂ t₃ totalOrder O = record { _≈_ = flip O._≈_ ; _≤_ = flip O._≤_ ; isTotalOrder = isTotalOrder O.isTotalOrder } where module O = TotalOrder O isDecTotalOrder : ∀ {a ℓ₁ ℓ₂} {A : Set a} {≈ : Rel A ℓ₁} {≤ : Rel A ℓ₂} → IsDecTotalOrder ≈ ≤ → IsDecTotalOrder (flip ≈) (flip ≤) isDecTotalOrder {≈ = ≈} {≤} dec = record { isTotalOrder = isTotalOrder Dec.isTotalOrder ; _≟_ = decidable ≈ Dec._≟_ ; _≤?_ = decidable ≤ Dec._≤?_ } where module Dec = IsDecTotalOrder dec decTotalOrder : ∀ {d₁ d₂ d₃} → DecTotalOrder d₁ d₂ d₃ → DecTotalOrder d₁ d₂ d₃ decTotalOrder O = record { _≈_ = flip O._≈_ ; _≤_ = flip O._≤_ ; isDecTotalOrder = isDecTotalOrder O.isDecTotalOrder } where module O = DecTotalOrder O isStrictTotalOrder : ∀ {a ℓ₁ ℓ₂} {A : Set a} {≈ : Rel A ℓ₁} {< : Rel A ℓ₂} → IsStrictTotalOrder ≈ < → IsStrictTotalOrder (flip ≈) (flip <) isStrictTotalOrder {≈ = ≈} {<} sto = record { isEquivalence = isEquivalence Sto.isEquivalence ; trans = transitive < Sto.trans ; compare = trichotomous ≈ < Sto.compare ; <-resp-≈ = respects₂ < ≈ Sto.Eq.sym Sto.<-resp-≈ } where module Sto = IsStrictTotalOrder sto strictTotalOrder : ∀ {s₁ s₂ s₃} → StrictTotalOrder s₁ s₂ s₃ → StrictTotalOrder s₁ s₂ s₃ strictTotalOrder O = record { _≈_ = flip O._≈_ ; _<_ = flip O._<_ ; isStrictTotalOrder = isStrictTotalOrder O.isStrictTotalOrder } where module O = StrictTotalOrder O
{ "alphanum_fraction": 0.5690751445, "avg_line_length": 34.9494949495, "ext": "agda", "hexsha": "9d52c36e6993cc38c16482ecfa4ceba2b713610c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_path": "agda-stdlib-0.9/src/Relation/Binary/Flip.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_path": "agda-stdlib-0.9/src/Relation/Binary/Flip.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Relation/Binary/Flip.agda", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "num_tokens": 2621, "size": 6920 }
module Unsolved-meta-in-module-application where module M (A : Set) where open M _ public
{ "alphanum_fraction": 0.7608695652, "avg_line_length": 15.3333333333, "ext": "agda", "hexsha": "e2cf4128c69ff58b31f613c22c965616fb37b6dd", "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/Unsolved-meta-in-module-application.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/Unsolved-meta-in-module-application.agda", "max_line_length": 48, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/Unsolved-meta-in-module-application.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": 23, "size": 92 }
-- Closed monoid in the skew-closed category of families module SOAS.Abstract.Monoid {T : Set} where open import SOAS.Common open import SOAS.Context open import SOAS.Variable open import SOAS.ContextMaps.Combinators open import SOAS.Construction.Structure as Structure open import SOAS.Abstract.Hom {T} open import SOAS.Abstract.Coalgebra using (module Sorted) ; open Sorted open import SOAS.Families.Core {T} open import Categories.Category.Equivalence using (StrongEquivalence) open import Categories.NaturalTransformation.NaturalIsomorphism using (niHelper) open import SOAS.Coalgebraic.Map {T} open import SOAS.Coalgebraic.Lift {T} private variable Γ Δ Θ : Ctx α β γ : T record Mon (𝒳 : Familyₛ) : Set where field η : ℐ ⇾̣ 𝒳 μ : 𝒳 ⇾̣ 〖 𝒳 , 𝒳 〗 lunit : {σ : Γ ~[ 𝒳 ]↝ Δ}{v : ℐ α Γ} → μ (η v) σ ≡ σ v runit : {t : 𝒳 α Γ} → μ t η ≡ t assoc : {σ : Γ ~[ 𝒳 ]↝ Δ}{ς : Δ ~[ 𝒳 ]↝ Θ} {t : 𝒳 α Γ} → μ (μ t σ) ς ≡ μ t (λ v → μ (σ v) ς) -- Congruence in both arguments of the multiplication μ≈₁ : {t₁ t₂ : 𝒳 α Γ}{σ : Γ ~[ 𝒳 ]↝ Δ} → t₁ ≡ t₂ → μ t₁ σ ≡ μ t₂ σ μ≈₁ refl = refl μ≈₂ : {t : 𝒳 α Γ}{σ ς : Γ ~[ 𝒳 ]↝ Δ} → ({τ : T}{v : ℐ τ Γ} → σ v ≡ ς v) → μ t σ ≡ μ t ς μ≈₂ {t = t} p = cong (μ t) (dext′ p) -- Monoids are pointed coalgebras ᵇ : Coalg 𝒳 ᵇ = record { r = λ t ρ → μ t (η ∘ ρ) ; counit = runit ; comult = λ { {t = t} → sym (trans assoc (μ≈₂ lunit)) } } ᴮ : Coalgₚ 𝒳 ᴮ = record { ᵇ = ᵇ ; η = η ; r∘η = lunit } -- Single-variable substitution [_/] : 𝒳 α Γ → 𝒳 β (α ∙ Γ) → 𝒳 β Γ [ s /] t = μ t (add 𝒳 s η) -- Substitution for second variable [_/]′ : 𝒳 α Γ → 𝒳 γ (β ∙ α ∙ Γ) → 𝒳 γ (β ∙ Γ) [ s /]′ t = μ t (lift₁ ᴮ (add 𝒳 s η)) -- Substitution for top two variables [_,_/]₂ : 𝒳 α Γ → 𝒳 β Γ → 𝒳 γ (α ∙ β ∙ Γ) → 𝒳 γ Γ [ s₁ , s₂ /]₂ t = μ t (add 𝒳 s₁ (add 𝒳 s₂ η)) open Coalgₚ ᴮ public using (r ; r∘η) -- Multiplication is coalgebraic map μᶜ : Coalgebraic ᴮ ᴮ ᴮ μ μᶜ = record { r∘f = assoc ; f∘r = trans assoc (μ≈₂ lunit) ; f∘η = lunit } -- Monoid homomorphisms record Mon⇒ {𝒳 𝒴 : Familyₛ}(𝒳ᵐ : Mon 𝒳)(𝒴ᵐ : Mon 𝒴) (f : 𝒳 ⇾̣ 𝒴) : Set where private module 𝒳 = Mon 𝒳ᵐ private module 𝒴 = Mon 𝒴ᵐ field ⟨η⟩ : {v : ℐ α Γ} → f (𝒳.η v) ≡ 𝒴.η v ⟨μ⟩ : {σ : Γ ~[ 𝒳 ]↝ Δ}{t : 𝒳 α Γ} → f (𝒳.μ t σ) ≡ 𝒴.μ (f t) (f ∘ σ) ᵇ⇒ : Coalg⇒ 𝒳.ᵇ 𝒴.ᵇ f ᵇ⇒ = record { ⟨r⟩ = trans ⟨μ⟩ (𝒴.μ≈₂ ⟨η⟩) } ᴮ⇒ : Coalgₚ⇒ 𝒳.ᴮ 𝒴.ᴮ f ᴮ⇒ = record { ᵇ⇒ = ᵇ⇒ ; ⟨η⟩ = ⟨η⟩ } -- Preservation of multiplication and unit implies the semantic substitution -- lemma for single- and double-variable substitution sub-lemma : (s : 𝒳 α Γ)(t : 𝒳 β (α ∙ Γ)) → f (𝒳.[ s /] t) ≡ 𝒴.[ f s /] (f t) sub-lemma s t = trans ⟨μ⟩ (cong (𝒴.μ (f t)) (dext λ{ new → refl ; (old y) → ⟨η⟩})) sub-lemma₂ : (s₁ : 𝒳 α Γ)(s₂ : 𝒳 β Γ)(t : 𝒳 γ (α ∙ β ∙ Γ)) → f (𝒳.[ s₁ , s₂ /]₂ t) ≡ 𝒴.[ f s₁ , f s₂ /]₂ (f t) sub-lemma₂ s₁ s₂ t = trans ⟨μ⟩ (cong (𝒴.μ (f t)) (dext λ{ new → refl ; (old new) → refl ; (old (old y)) → ⟨η⟩})) module MonoidStructure = Structure 𝔽amiliesₛ Mon -- Category of substitution monoids 𝕄onoids : Category 1ℓ 0ℓ 0ℓ 𝕄onoids = MonoidStructure.StructCat record { IsHomomorphism = Mon⇒ ; id-hom = record { ⟨η⟩ = refl ; ⟨μ⟩ = refl } ; comp-hom = λ g f gᵐ⇒ fᵐ⇒ → record { ⟨η⟩ = trans (cong g (⟨η⟩ fᵐ⇒)) (⟨η⟩ gᵐ⇒) ; ⟨μ⟩ = trans (cong g (⟨μ⟩ fᵐ⇒)) (⟨μ⟩ gᵐ⇒) } } where open Mon⇒ module 𝕄on = Category 𝕄onoids Monoid : Set₁ Monoid = 𝕄on.Obj Monoid⇒ : Monoid → Monoid → Set Monoid⇒ = 𝕄on._⇒_ module AsMonoid (ℳᵐ : Monoid) where open Object ℳᵐ renaming (𝐶 to ℳ; ˢ to ᵐ) public open Mon ᵐ public module AsMonoid⇒ {ℳᵐ 𝒩ᵐ : Monoid} (fᵐ⇒ : Monoid⇒ ℳᵐ 𝒩ᵐ) where open Morphism fᵐ⇒ renaming (𝑓 to f ; ˢ⇒ to ᵐ⇒) public open Mon⇒ ᵐ⇒ public
{ "alphanum_fraction": 0.5394434516, "avg_line_length": 28.1798561151, "ext": "agda", "hexsha": "feea3d8e79ab8d79f4e04967a7da86a2a59ba3c7", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_path": "SOAS/Abstract/Monoid.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_path": "SOAS/Abstract/Monoid.agda", "max_line_length": 80, "max_stars_count": 39, "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_path": "SOAS/Abstract/Monoid.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "num_tokens": 1906, "size": 3917 }
module GUIgeneric.GUIFeaturesPart4 where open import GUIgeneric.Prelude renaming (addButton to addButton') open import GUIgeneric.GUIDefinitions renaming (add to add'; add' to add) open import GUIgeneric.GUI open import GUIgeneric.GUIExampleLib open import StateSizedIO.GUI.WxGraphicsLibLevel3 renaming (addButton to addButton') open import GUIgeneric.GUIFeatures open import GUIgeneric.GUIFeaturesPart2 hiding ( main ) open import GUIgeneric.GUIFeaturesPart3 hiding ( main ) open import GUIgeneric.GUIExample hiding (main ) open import Data.Product open import Data.Fin addStateFMachine : {BaseState : Set} (vm : FMachine BaseState) (Snew : Set) (newSM : (s : Snew) → SMachineState (BaseState ⊎ vm .AddStateF ⊎ Snew) (inj₂ (inj₂ s))) → FMachine BaseState addStateFMachine {BaseState} vm Snew newSM .Features = vm .Features addStateFMachine {BaseState} vm Snew newSM .AddStateF = vm .AddStateF ⊎ Snew addStateFMachine {BaseState} vm Snew newSM .GUIF f (inj₁ s) = mapFMachineHandle (inj₁ s) (vm .GUIF f (inj₁ s)) addStateFMachine {BaseState} vm Snew newSM .GUIF f (inj₂ (inj₁ s)) = mapFMachineHandle (inj₂ s) (vm .GUIF f (inj₂ s)) addStateFMachine {BaseState} vm Snew newSM .GUIF f (inj₂ (inj₂ s)) .fSM = newSM s .fSM addStateFMachine {BaseState} vm Snew newSM .GUIF f (inj₂ (inj₂ s)) .propSM = newSM s .propSM addStateFMachine {BaseState} vm Snew newSM .GUIF f (inj₂ (inj₂ s)) .handlSM = newSM s .handlSM addOneStateFMachine : {BaseState : Set} (vm : FMachine BaseState) (newSM : SMachineState (BaseState ⊎ vm .AddStateF ⊎ ⊤) (inj₂ (inj₂ _))) → FMachine BaseState addOneStateFMachine vm newSM = addStateFMachine vm ⊤ λ _ → newSM addDummyFeatures : {BaseState : Set} (vm : FMachine BaseState) (FeatureNew : Set) → FMachine BaseState addDummyFeatures vm FeatureNew .Features = vm .Features × FeatureNew addDummyFeatures vm FeatureNew .AddStateF = vm .AddStateF addDummyFeatures vm FeatureNew .GUIF (f , _) s = vm .GUIF f s {- handler for the new state to be added to the cancel machine -} cancelNewStateSM : (vm : FMachine StateV) → SMachineState (StateV ⊎ vm .AddStateF ⊎ ⊤) (inj₂ (inj₂ tt)) cancelNewStateSM vm = simpleSMState "Intermediate" (inj₁ s0) {- add the state to the old feature machine -} cancelStateAdded : FMachine StateV → FMachine StateV cancelStateAdded vm = addOneStateFMachine vm (cancelNewStateSM vm) {- add a dummy feature "FeatureCancel" to the feature machine -} cancelFeatureAdded : FMachine StateV → FMachine StateV cancelFeatureAdded vm = addDummyFeatures (cancelStateAdded vm) FeatureCancel {- redefine in the feature machine one button -} Cancel' : FMachine StateV → FMachine StateV Cancel' vm .Features = cancelFeatureAdded vm .Features Cancel' vm .AddStateF = cancelFeatureAdded vm .AddStateF Cancel' vm .GUIF (f , yesCancel) (inj₁ s1) = addBtn2StateMachine (cancelFeatureAdded vm .GUIF (f , yesCancel) (inj₁ s1)) "Cancel" (inj₂ (inj₂ _)) Cancel' vm .GUIF f s = cancelFeatureAdded vm .GUIF f s main : NativeIO Unit main = compileFeatureVM (Cancel' baseF) (_ , yesCancel) (inj₁ s0) --
{ "alphanum_fraction": 0.6614942529, "avg_line_length": 43.5, "ext": "agda", "hexsha": "f10f4e53f0fa31ab2816f4096a5102caeb91070b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "stephanadls/state-dependent-gui", "max_forks_repo_path": "examples/GUIgeneric/GUIFeaturesPart4.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "stephanadls/state-dependent-gui", "max_issues_repo_path": "examples/GUIgeneric/GUIFeaturesPart4.agda", "max_line_length": 97, "max_stars_count": 2, "max_stars_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "stephanadls/state-dependent-gui", "max_stars_repo_path": "examples/GUIgeneric/GUIFeaturesPart4.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-31T17:20:59.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-31T15:37:39.000Z", "num_tokens": 974, "size": 3480 }
module Nat where open import Data.Product open import Data.Sum open import Relation.Binary.PropositionalEquality as Eq open import Data.Empty open import Level hiding (zero) data ℕ : Set where zero : ℕ succ : ℕ → ℕ open Eq.≡-Reasoning ¬_ : { ℓ : Level} → Set ℓ → Set ℓ ¬ P = P → ⊥ ≡-succ : (n m : ℕ) → succ n ≡ succ m → n ≡ m ≡-succ zero .zero refl = refl ≡-succ (succ n) .(succ n) refl = refl sn≢0 : (n : ℕ) → ¬ (succ n ≡ zero) sn≢0 _ () _+_ : ℕ → ℕ → ℕ zero + m = m succ n + m = succ (n + m) _*_ : ℕ → ℕ → ℕ zero * _ = zero succ n * m = m + (n * m) +-rUnit : (n : ℕ) → n + zero ≡ n +-rUnit zero = refl +-rUnit (succ n) = cong succ (+-rUnit n) +-lUnit : (n : ℕ) → zero + n ≡ n +-lUnit _ = refl +-assoc : (n m l : ℕ) → n + (m + l) ≡ (n + m) + l +-assoc zero m l = refl +-assoc (succ n) m l = cong succ (+-assoc n m l) +-right : (n m : ℕ) → n + succ m ≡ succ (n + m) +-right zero m = refl +-right (succ n) m = cong succ (+-right n m) +-comm : (m n : ℕ) → m + n ≡ n + m +-comm zero n = sym (+-rUnit n) +-comm (succ m) n = begin succ (m + n) ≡⟨ cong succ (+-comm m n) ⟩ succ (n + m) ≡⟨ sym (+-right n m) ⟩ n + succ m ∎ +-lCancel : (n m l : ℕ) → l + n ≡ l + m → n ≡ m +-lCancel n m zero p = p +-lCancel n m (succ l) p = +-lCancel n m l (≡-succ (l + n) (l + m) p) +-rCancel : (n m l : ℕ) → n + l ≡ m + l → n ≡ m +-rCancel n m zero p = begin n ≡⟨ sym (+-rUnit n) ⟩ n + zero ≡⟨ p ⟩ m + zero ≡⟨ +-rUnit m ⟩ m ∎ +-rCancel n m (succ l) n+sl≡m+sl = +-rCancel n m l (≡-succ (n + l) (m + l) (begin succ (n + l) ≡⟨ sym (+-right n l) ⟩ n + succ l ≡⟨ n+sl≡m+sl ⟩ m + succ l ≡⟨ +-right m l ⟩ succ (m + l) ∎)) *-rAbsorp : (n : ℕ) → n * zero ≡ zero *-rAbsorp zero = refl *-rAbsorp (succ n) = begin succ n * zero ≡⟨ refl ⟩ zero + (n * zero) ≡⟨ cong (λ x → zero + x) (*-rAbsorp n) ⟩ zero + zero ≡⟨ refl ⟩ zero ∎ *-right : (m n : ℕ) → m * succ n ≡ (m * n) + m *-right zero n = begin zero * succ n ≡⟨ refl ⟩ zero ≡⟨ refl ⟩ zero * n ≡⟨ +-rUnit (zero * n) ⟩ (zero * n) + zero ∎ *-right (succ m) n = begin succ m * succ n ≡⟨ refl ⟩ succ n + (m * succ n) ≡⟨ cong (λ x → succ n + x) (*-right m n) ⟩ succ n + ((m * n) + m) ≡⟨ refl ⟩ succ (n + ((m * n) + m)) ≡⟨ cong succ (+-assoc n (m * n) m) ⟩ succ ((n + (m * n)) + m) ≡⟨ sym (+-right (n + (m * n)) m) ⟩ (succ m * n) + succ m ∎ +*-rDist : (m n l : ℕ) → (m + n) * l ≡ (m * l) + (n * l) +*-rDist m n zero = begin (m + n) * zero ≡⟨ *-rAbsorp (m + n) ⟩ zero ≡⟨ sym (*-rAbsorp m) ⟩ m * zero ≡⟨ sym (+-rUnit (m * zero)) ⟩ (m * zero) + zero ≡⟨ cong (λ x → (m * zero) + x) (sym (*-rAbsorp n)) ⟩ (m * zero) + (n * zero) ∎ +*-rDist m n (succ l) = begin (m + n) * succ l ≡⟨ *-right (m + n) l ⟩ ((m + n) * l) + (m + n) ≡⟨ cong (λ x → x + (m + n)) (+*-rDist m n l) ⟩ ((m * l) + (n * l)) + (m + n) ≡⟨ +-assoc ((m * l) + (n * l)) m n ⟩ (((m * l) + (n * l)) + m) + n ≡⟨ cong (λ x → x + n) (sym (+-assoc (m * l) (n * l) m)) ⟩ ((m * l) + ((n * l) + m)) + n ≡⟨ cong (λ x → x + n) (cong (λ x → (m * l) + x) (+-comm (n * l) m)) ⟩ ((m * l) + (m + (n * l))) + n ≡⟨ cong (λ x → x + n) (+-assoc (m * l) m (n * l)) ⟩ (((m * l) + m) + (n * l)) + n ≡⟨ sym (+-assoc ((m * l) + m) (n * l) n) ⟩ ((m * l) + m) + ((n * l) + n) ≡⟨ cong (λ x → x + ((n * l) + n)) (sym (*-right m l)) ⟩ (m * succ l) + ((n * l) + n) ≡⟨ cong (λ x → (m * succ l) + x) (sym (*-right n l)) ⟩ (m * succ l) + (n * succ l) ∎ *-assoc : (m n l : ℕ) → m * (n * l) ≡ (m * n) * l *-assoc zero n l = refl *-assoc (succ m) n l = begin succ m * (n * l) ≡⟨ refl ⟩ (n * l) + (m * (n * l)) ≡⟨ cong (λ x → (n * l) + x) (*-assoc m n l) ⟩ (n * l) + ((m * n) * l) ≡⟨ sym (+*-rDist n (m * n) l) ⟩ (n + (m * n)) * l ≡⟨ refl ⟩ (succ m * n) * l ∎ *-comm : (m n : ℕ) → m * n ≡ n * m *-comm zero n = sym (*-rAbsorp n) *-comm (succ m) n = begin succ m * n ≡⟨ refl ⟩ n + (m * n) ≡⟨ +-comm n (m * n) ⟩ (m * n) + n ≡⟨ cong (λ x → x + n) (*-comm m n) ⟩ (n * m) + n ≡⟨ sym (*-right n m) ⟩ n * succ m ∎ _≤_ : ℕ → ℕ → Set n ≤ m = Σ ℕ (λ l → n + l ≡ m) ≤-refl : (n : ℕ) → n ≤ n ≤-refl zero = zero , refl ≤-refl (succ n) = zero , (begin (succ n + zero) ≡⟨ +-rUnit (succ n) ⟩ (succ n) ∎) 0≤n : (n : ℕ) → zero ≤ n 0≤n zero = ≤-refl zero 0≤n (succ n) = succ n , refl ≤-trans : (n m l : ℕ) → n ≤ m → m ≤ l → n ≤ l ≤-trans zero m l p q = l , refl ≤-trans (succ n) m l (a , succn+a≡m) (b , m+b≡l) = (a + b) , (begin succ n + (a + b) ≡⟨ +-assoc (succ n) a b ⟩ (succ n + a) + b ≡⟨ cong (λ x → x + b) succn+a≡m ⟩ m + b ≡⟨ m+b≡l ⟩ l ∎) +-lZero : (n m : ℕ) → n + m ≡ zero → n ≡ zero +-lZero zero m = λ _ → refl +-lZero (succ n) m () ≤-antisym : (n m : ℕ) → n ≤ m → m ≤ n → n ≡ m ≤-antisym n m (c , n+c≡m) (d , m+d≡n) = trans (sym n+c≡n) n+c≡m where c≡0 : c ≡ zero c≡0 = +-lZero c d (+-lCancel (c + d) zero n ( begin n + (c + d) ≡⟨ +-assoc n c d ⟩ (n + c) + d ≡⟨ cong (λ x → x + d) n+c≡m ⟩ m + d ≡⟨ m+d≡n ⟩ n ≡⟨ sym (+-rUnit n) ⟩ n + zero ∎)) n+c≡n : n + c ≡ n n+c≡n = begin n + c ≡⟨ cong (λ x → n + x) c≡0 ⟩ n + zero ≡⟨ +-rUnit n ⟩ n ∎ n+s0≡sn : (n : ℕ) → n + succ zero ≡ succ n n+s0≡sn n = begin n + succ zero ≡⟨ +-right n zero ⟩ succ (n + zero) ≡⟨ cong succ (+-rUnit n) ⟩ succ n ∎ n≤sn : (n : ℕ) → n ≤ succ n n≤sn n = succ zero , n+s0≡sn n ℕ-ω : (n : ℕ) → n ≡ zero ⊎ Σ ℕ (λ c → n ≡ succ c) ℕ-ω zero = inj₁ refl ℕ-ω (succ n) = inj₂ (n , refl) m+sn≡sm+n : (m n : ℕ) → m + succ n ≡ succ m + n m+sn≡sm+n m zero = begin m + succ zero ≡⟨ n+s0≡sn m ⟩ succ m ≡⟨ sym (+-rUnit (succ m)) ⟩ succ m + zero ∎ m+sn≡sm+n m (succ n) = begin m + succ (succ n) ≡⟨ +-right m (succ n) ⟩ succ (m + succ n) ≡⟨ cong succ (m+sn≡sm+n m n) ⟩ succ (succ m + n) ≡⟨ sym (+-right (succ m) n) ⟩ succ m + succ n ∎ sn≤m : (n m : ℕ) → n ≤ m → ¬ (n ≡ m) → succ n ≤ m sn≤m n m (c , n+c≡m) q = lem (ℕ-ω c) where n+c≡n : c ≡ zero → n + c ≡ n n+c≡n p = begin n + c ≡⟨ cong (λ x → n + x) p ⟩ n + zero ≡⟨ +-rUnit n ⟩ n ∎ lem : c ≡ zero ⊎ Σ ℕ (λ d → c ≡ succ d) → succ n ≤ m lem (inj₁ x) = ⊥-elim (q (trans (sym (n+c≡n x)) n+c≡m)) lem (inj₂ (d , c≡sd)) = d , (begin succ n + d ≡⟨ sym (m+sn≡sm+n n d) ⟩ n + succ d ≡⟨ sym (cong (λ x → n + x) c≡sd) ⟩ n + c ≡⟨ n+c≡m ⟩ m ∎) ≤-all : (m n : ℕ) → m ≤ n ⊎ n ≤ m ≤-all m zero = inj₂ (m , refl) ≤-all m (succ n) = lem (≤-all m n) where lem : m ≤ n ⊎ n ≤ m → m ≤ succ n ⊎ succ n ≤ m lem (inj₁ x) = inj₁ (≤-trans m n (succ n) x (n≤sn n)) lem (inj₂ (zero , n+zero≡m)) = inj₁ (succ zero , (begin m + succ zero ≡⟨ +-right m zero ⟩ succ (m + zero) ≡⟨ cong succ (+-rUnit m) ⟩ succ m ≡⟨ cong succ (sym n+zero≡m) ⟩ succ (n + zero) ≡⟨ cong succ (+-rUnit n) ⟩ succ n ∎)) lem (inj₂ (succ c , n+sc≡m)) = inj₂ (c , (begin succ n + c ≡⟨ refl ⟩ succ (n + c) ≡⟨ sym (+-right n c) ⟩ n + succ c ≡⟨ n+sc≡m ⟩ m ∎)) +-mono : (m n l : ℕ) → m ≤ n → (m + l) ≤ (n + l) +-mono m n zero (c , m+c≡n) = c , (begin (m + zero) + c ≡⟨ cong (λ x → x + c) (+-rUnit m) ⟩ m + c ≡⟨ m+c≡n ⟩ n ≡⟨ sym (+-rUnit n) ⟩ n + zero ∎) +-mono m n (succ l) (c , m+c≡n) = lem (+-mono m n l (c , m+c≡n)) where lem : (m + l) ≤ (n + l) → (m + succ l) ≤ (n + succ l) lem (d , m+l+d≡n+l) = d , (begin (m + succ l) + d ≡⟨ cong (λ x → x + d) (+-right m l) ⟩ succ (m + l) + d ≡⟨ refl ⟩ succ ((m + l) + d) ≡⟨ cong succ m+l+d≡n+l ⟩ succ (n + l) ≡⟨ sym (+-right n l) ⟩ n + succ l ∎) *-mono : (m n l : ℕ) → m ≤ n → (m * l) ≤ (n * l) *-mono m n zero (c , m+c≡n) = zero , (begin (m * zero) + zero ≡⟨ +-rUnit (m * zero) ⟩ m * zero ≡⟨ trans (*-rAbsorp m) (sym (*-rAbsorp n)) ⟩ n * zero ∎) *-mono m n (succ l) (c , m+c≡n) = lem (*-mono m n l (c , m+c≡n)) where lem : (m * l) ≤ (n * l) → (m * succ l) ≤ (n * succ l) lem (d , m*l+d≡n*l) = (c * succ l) , sym (begin n * succ l ≡⟨ cong (λ x → x * succ l) (sym m+c≡n) ⟩ (m + c) * succ l ≡⟨ +*-rDist m c (succ l) ⟩ (m * succ l) + (c * succ l) ∎) s≤s : (m n : ℕ) → m ≤ n → succ m ≤ succ n s≤s zero n (c , c≡n) = n , refl s≤s (succ m) n (c , sm+c≡n) = c , cong succ sm+c≡n data _≲_ : ℕ → ℕ → Set where 0≲n : {n : ℕ} → zero ≲ n s≲s : {n m : ℕ} → n ≲ m → succ n ≲ succ m ≤-≲ : (m n : ℕ) → m ≤ n → m ≲ n ≤-≲ zero _ _ = 0≲n ≤-≲ (succ m) zero (c , ()) ≤-≲ (succ m) (succ n) (c , m+c≡n) = s≲s (≤-≲ m n (c , ≡-succ (m + c) n m+c≡n)) ≲-≤ : (m n : ℕ) → m ≲ n → m ≤ n ≲-≤ .zero n 0≲n = n , refl ≲-≤ (succ m) (succ n) (s≲s p) = s≤s m n (≲-≤ m n p)
{ "alphanum_fraction": 0.3589999004, "avg_line_length": 26.1432291667, "ext": "agda", "hexsha": "2a141467784b751f4522afc5e260428459b2e21d", "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": "bf1f5ed013ea7072055c061b8458c4f1259b54f5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "karrym/NatToReal", "max_forks_repo_path": "Nat.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bf1f5ed013ea7072055c061b8458c4f1259b54f5", "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": "karrym/NatToReal", "max_issues_repo_path": "Nat.agda", "max_line_length": 78, "max_stars_count": null, "max_stars_repo_head_hexsha": "bf1f5ed013ea7072055c061b8458c4f1259b54f5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "karrym/NatToReal", "max_stars_repo_path": "Nat.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4567, "size": 10039 }
-- mostly adapted from Agda stdlib module level where import Agda.Primitive open Agda.Primitive public using (Level ; _⊔_ ; lsuc ; lzero) level = Level lone : level lone = lsuc lzero record Lift {a ℓ} (A : Set a) : Set (a ⊔ ℓ) where constructor lift field lower : A open Lift public
{ "alphanum_fraction": 0.6833333333, "avg_line_length": 15, "ext": "agda", "hexsha": "fd41b909c974d96738c6feca569fb0359bfc98ba", "lang": "Agda", "max_forks_count": 17, "max_forks_repo_forks_event_max_datetime": "2021-11-28T20:13:21.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-03T22:38:15.000Z", "max_forks_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rfindler/ial", "max_forks_repo_path": "level.agda", "max_issues_count": 8, "max_issues_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_issues_repo_issues_event_max_datetime": "2022-03-22T03:43:34.000Z", "max_issues_repo_issues_event_min_datetime": "2018-07-09T22:53:38.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "rfindler/ial", "max_issues_repo_path": "level.agda", "max_line_length": 49, "max_stars_count": 29, "max_stars_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rfindler/ial", "max_stars_repo_path": "level.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-04T15:05:12.000Z", "max_stars_repo_stars_event_min_datetime": "2019-02-06T13:09:31.000Z", "num_tokens": 99, "size": 300 }
module Issue327 where open import Common.Prelude open import Common.Reflect _==_ : QName → QName → Bool _==_ = primQNameEquality postulate Dec : Bool → Set _≟_ : (x y : QName) → Dec (x == y) Foo : Set₁ Foo with quote Foo ≟ quote Foo ... | _ = Set
{ "alphanum_fraction": 0.65234375, "avg_line_length": 15.0588235294, "ext": "agda", "hexsha": "5f896f8f114abcd9c4d60934f4740bb1bed802c7", "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/Issue327.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/Issue327.agda", "max_line_length": 36, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/succeed/Issue327.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": 86, "size": 256 }
{-# OPTIONS --omega-in-omega --no-termination-check --overlapping-instances #-} {-# OPTIONS --allow-unsolved-metas #-} module Light.Implementation.Relation.Binary.Equality.Propositional.Decidable where import Light.Implementation.Relation.Binary.Equality.Propositional as Propositional open import Light.Library.Relation.Decidable using (Decidable ; yes ; no ; if_then_else_ ; from‐witness) open import Light.Variable.Sets open import Light.Library.Relation.Binary.Equality using (_≈_ ; SelfEquality ; wrap) open import Light.Library.Relation.Binary using (SelfSymmetric ; SelfTransitive ; Reflexive ; Binary ; SelfBinary ; Symmetric ; Transitive ; CongruentFor ; Preserved ; reflexivity ; transitivity ; symmetry ; congruence) import Light.Implementation.Relation.Decidable open import Light.Variable.Sets open import Light.Variable.Levels open import Light.Library.Relation using (_∧_ ; _⇢_) open import Light.Library.Data.Product using (first ; second ; both) import Light.Implementation.Data.Product module Base {𝕒 : Set aℓ} where instance relation : SelfBinary 𝕒 relation = record { are = λ a b → Decidable (a ≈ b) } instance reflexive : Reflexive relation reflexive .Reflexive.reflexivity = {!!} instance symmetric : SelfSymmetric relation symmetric .Symmetric.symmetry a‐≈?‐b = if a‐≈?‐b then (λ ⦃ b‐≈‐a ⦄ → yes (symmetry b‐≈‐a)) else (λ ⦃ f ⦄ → no λ b‐≈‐a → f (symmetry b‐≈‐a)) instance transitive : SelfTransitive relation transitive .Transitive.transitivity a‐≈?‐b b‐≈?‐c = if a‐≈?‐b ∧ b‐≈?‐c then (λ ⦃ a‐≈‐c ⦄ → yes (transitivity (first a‐≈‐c) (second a‐≈‐c))) else (λ ⦃ f ⦄ → no λ a‐≈‐c → f (both {!!} {!!})) instance equals : SelfEquality 𝕒 equals = wrap relation instance base‐congruent : ∀ {f : 𝕒 → 𝕓} → CongruentFor f Base.relation Base.relation base‐congruent .Preserved.preservation a‐≈?‐c = if a‐≈?‐c then (λ ⦃ a‐≈‐c ⦄ → yes (congruence a‐≈‐c)) else λ ⦃ f ⦄ → no λ fa‐≈‐fc → f {!!} module Main (_≈?_ : ∀ (a b : 𝕒) → Decidable (_≈_ ⦃ r = Propositional.equals ⦄ a b)) where instance relation : SelfBinary 𝕒 relation = record { are = λ a b → a ≈? b } open import Agda.Builtin.Equality using (_≡_) instance reflexive : Reflexive relation reflexive .Reflexive.reflexivity {a = a} = from‐witness {a? = a ≈? a} ⦃ witness = reflexivity ⦄ instance symmetric : SelfSymmetric relation symmetric .Symmetric.symmetry {a = a} {b = b} = from‐witness {a? = (a ≈? b) ⇢ (b ≈? a)} ⦃ witness = symmetry ⦄ instance transitive : SelfTransitive relation transitive .Transitive.transitivity {a = a} {b = b} {c = c} = from‐witness {a? = (a ≈? b) ⇢ ((b ≈? c) ⇢ (a ≈? c))} ⦃ witness = transitivity ⦄ module _ (_≈a?_ : ∀ (a b : 𝕒) → Decidable (_≈_ ⦃ r = Propositional.equals ⦄ a b)) (_≈b?_ : ∀ (a b : 𝕓) → Decidable (_≈_ ⦃ r = Propositional.equals ⦄ a b)) where private module A = Main _≈a?_ private module B = Main _≈b?_ instance congruent : ∀ {f : 𝕒 → 𝕓} → CongruentFor f A.relation B.relation congruent {f = f} .Preserved.preservation {a = a} {c = c} = from‐witness {a? = (a ≈a? c) ⇢ (f a ≈b? f c)} ⦃ witness = congruence ⦄
{ "alphanum_fraction": 0.6294953158, "avg_line_length": 48.6617647059, "ext": "agda", "hexsha": "ae06382aec71f8170b0b026a5bbe22f72d60cb58", "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/Implementation/Relation/Binary/Equality/Propositional/Decidable.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "0BSD" ], "max_issues_repo_name": "Zambonifofex/lightlib", "max_issues_repo_path": "Light/Implementation/Relation/Binary/Equality/Propositional/Decidable.agda", "max_line_length": 183, "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/Implementation/Relation/Binary/Equality/Propositional/Decidable.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-20T21:33:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-12-20T21:33:05.000Z", "num_tokens": 1107, "size": 3309 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Regular where -- https://ncatlab.org/nlab/show/regular+category -- https://en.wikipedia.org/wiki/Regular_category open import Level open import Categories.Category.Core open import Categories.Category.Complete.Finitely using (FinitelyComplete) open import Categories.Diagram.Coequalizer open import Categories.Diagram.KernelPair open import Categories.Diagram.Pullback open import Categories.Morphism.Regular record Regular {o ℓ e : Level} (𝒞 : Category o ℓ e) : Set (suc (o ⊔ ℓ ⊔ e)) where open Category 𝒞 open Pullback field finitely-complete : FinitelyComplete 𝒞 coeq-of-kernelpairs : {A B : Obj} (f : A ⇒ B) (kp : KernelPair 𝒞 f) → Coequalizer 𝒞 (p₁ kp) (p₂ kp) pullback-of-regularepi-is-regularepi : {A B C : Obj} (f : B ⇒ A) {g : C ⇒ A} → RegularEpi 𝒞 f → (p : Pullback 𝒞 f g) → RegularEpi 𝒞 (p₂ p)
{ "alphanum_fraction": 0.7182940516, "avg_line_length": 35.64, "ext": "agda", "hexsha": "3e378bff2cec9d2999b8233739cfac207efa3c0e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Category/Regular.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Category/Regular.agda", "max_line_length": 142, "max_stars_count": 5, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Category/Regular.agda", "max_stars_repo_stars_event_max_datetime": "2019-05-22T03:54:24.000Z", "max_stars_repo_stars_event_min_datetime": "2019-05-21T17:07:19.000Z", "num_tokens": 279, "size": 891 }
open import Prelude module Implicits.Resolution.Stack.Resolution where open import Coinduction open import Data.Fin.Substitution open import Implicits.Syntax open import Implicits.Substitutions open import Induction open import Induction.Nat open import Implicits.Resolution.Termination.Stack infixl 5 _⊢ᵣ_ infixl 5 _&_⊢ᵣ_ _&_,_⊢_↓_ mutual -- Δ & s , r ⊢ a ↓ τ denotes: -- Under the context Δ, with stack of resolution goals s, the type a yields simple type τ. -- 'r' is used to keep track of the rule from the context that yielded 'a' -- ('a' is getting recursively refined) data _&_,_⊢_↓_ {ν} (Δ : ICtx ν) : ∀ {r} → Stack Δ → r List.∈ Δ → Type ν → SimpleType ν → Set where i-simp : ∀ {r s} {r∈Δ : r List.∈ Δ} a → Δ & s , r∈Δ ⊢ simpl a ↓ a i-iabs : ∀ {ρ₁ ρ₂ a r s} {r∈Δ : r List.∈ Δ} → ρ₁ for r∈Δ ⊬dom s → -- subproblems decrease when recursing Δ & (s push ρ₁ for r∈Δ) ⊢ᵣ ρ₁ → -- domain is resolvable Δ & s , r∈Δ ⊢ ρ₂ ↓ a → -- codomain matches Δ & s , r∈Δ ⊢ ρ₁ ⇒ ρ₂ ↓ a i-tabs : ∀ {ρ a r s} {r∈Δ : r List.∈ Δ} b → Δ & s , r∈Δ ⊢ ρ tp[/tp b ] ↓ a → Δ & s , r∈Δ ⊢ ∀' ρ ↓ a data _&_⊢ᵣ_ {ν} (Δ : ICtx ν) : Stack Δ → Type ν → Set where r-simp : ∀ {r τ s} → (r∈Δ : r List.∈ Δ) → Δ & s , r∈Δ ⊢ r ↓ τ → Δ & s ⊢ᵣ simpl τ r-iabs : ∀ {ρ₁ ρ₂} {s : Stack Δ} → ((ρ₁ List.∷ Δ) & (s prepend ρ₁) ⊢ᵣ ρ₂) → Δ & s ⊢ᵣ (ρ₁ ⇒ ρ₂) r-tabs : ∀ {ρ s} → ictx-weaken Δ & stack-weaken s ⊢ᵣ ρ → Δ & s ⊢ᵣ ∀' ρ -- TODO: This doesn't hold. -- e.g. we can unify (a → b) with the codomain of a rule (a → b → a) ⇒ (a → b) -- so the subgoal is larger than the initial goal. -- -- We instantiate the stack with types that act as 'infinity' on the goal. -- Every possible 'subgoal' we encounter and push to the stack will certainly -- be smaller than r _⊢ᵣ_ : ∀ {ν} → ICtx ν → Type ν → Set Δ ⊢ᵣ r = Δ & All.tabulate (const r) ⊢ᵣ r
{ "alphanum_fraction": 0.5753781951, "avg_line_length": 39.1224489796, "ext": "agda", "hexsha": "c3fe10deed360210a2a80aabee715a84b76cf3db", "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/Implicits/Resolution/Stack/Resolution.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/Implicits/Resolution/Stack/Resolution.agda", "max_line_length": 92, "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/Implicits/Resolution/Stack/Resolution.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": 799, "size": 1917 }
module Data.List where import Lvl open import Type private variable ℓ : Lvl.Level private variable T : Type{ℓ} infixr 1000 _⊰_ -- A list is a container/collection of elements. -- • The elements are in a linear order. -- • The container allows multiples (non-uniqueness of elements in the container). data List (T : Type{ℓ}) : Type{ℓ} where ∅ : List(T) -- An empty list _⊰_ : T → List(T) → List(T) -- Cons {-# BUILTIN LIST List #-} private variable l : List(T) private variable P : List(T) → Type{ℓ} elim : P(∅) → (∀(x : T)(l : List(T)) → P(l) → P(x ⊰ l)) → ((l : List(T)) → P(l)) elim base next ∅ = base elim base next (x ⊰ l) = next(x)(l)(elim base next l)
{ "alphanum_fraction": 0.6196769457, "avg_line_length": 27.24, "ext": "agda", "hexsha": "1f99b494e8bb4d5b512506a2551db91f387b5d88", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Data/List.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Data/List.agda", "max_line_length": 82, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Data/List.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": 228, "size": 681 }
{-# OPTIONS --without-K --safe #-} module Data.Fin.Indexed.Literals where -- import Data.Nat as ℕ -- import Data.Nat.Properties as ℕ open import Data.Fin.Indexed.Base open import Literals.Number -- open import Relation.Nullary open import Agda.Builtin.Nat renaming (_<_ to _<ᵇ_) open import Data.Bool open import Agda.Builtin.Nat using (_<_) instance numberFin : ∀ {n} → Number (Fin n) numberFin {n} = record { Constraint = λ m → T (m <ᵇ n) ; fromNat = λ m {{pr}} → FinFromℕ {n} m pr }
{ "alphanum_fraction": 0.6732283465, "avg_line_length": 25.4, "ext": "agda", "hexsha": "8bf8897455e67ecd2e636e9fa2a85e2274f830bb", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_path": "Data/Fin/Indexed/Literals.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_path": "Data/Fin/Indexed/Literals.agda", "max_line_length": 51, "max_stars_count": 6, "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_path": "Data/Fin/Indexed/Literals.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "num_tokens": 157, "size": 508 }
-- Andreas, 2016-09-20 test whether --no-eta-equality is respected {-# OPTIONS --no-eta-equality #-} open import Common.Equality data Wrap (A : Set) : Set where wrap : A → Wrap A record R : Set where inductive constructor c field p : Wrap R open R test : ∀ (w : R) → w ≡ c (p w) test w = refl -- should fail
{ "alphanum_fraction": 0.6366459627, "avg_line_length": 17.8888888889, "ext": "agda", "hexsha": "e36fb151e263876cb0ef451fb4cf44c3391eed33", "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/NoEtaEqualityInductiveRecord.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/NoEtaEqualityInductiveRecord.agda", "max_line_length": 66, "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/NoEtaEqualityInductiveRecord.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": 105, "size": 322 }
{-# OPTIONS -v treeless.opt:20 #-} -- Test that inlining a recursive function doesn't throw -- the compiler into a loop. module _ where open import Common.Prelude f : Nat → Nat f zero = zero f (suc n) = f n {-# INLINE f #-} main : IO Unit main = printNat (f 4)
{ "alphanum_fraction": 0.6628787879, "avg_line_length": 17.6, "ext": "agda", "hexsha": "58c0677a1cd94bf70b50a3479d620f9a0c0934e9", "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/Compiler/simple/InlineRecursive.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/Compiler/simple/InlineRecursive.agda", "max_line_length": 56, "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/Compiler/simple/InlineRecursive.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 78, "size": 264 }
------------------------------------------------------------------------------ -- Testing a proof done using Hip (Haskell Inductive Prover) ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module SK where -- We add 3 to the fixities of the Agda standard library 0.8.1 (see -- Algebra.agda and Relation/Binary/Core.agda). infixl 9 _·_ infix 7 _≡_ postulate D : Set K S : D _·_ : D → D → D -- The identity type. data _≡_ (x : D) : D → Set where refl : x ≡ x postulate K-eq : ∀ x y → K · x · y ≡ x S-eq : ∀ x y z → S · x · y · z ≡ x · z · (y · z) {-# ATP axioms K-eq S-eq #-} id : D → D id x = x {-# ATP definition id #-} -- We don't use extensional equality, because _≡_ is not -- polymorphic. See (Rosén 2012, p. 24). postulate thm : ∀ x → S · K · K · x ≡ id x {-# ATP prove thm #-} ------------------------------------------------------------------------------ -- References -- -- Rosén, D. (2012). Proving Equational Haskell Properties Using -- Automated Theorem Provers. MA thesis. University of Gothenburg.
{ "alphanum_fraction": 0.471636953, "avg_line_length": 27.4222222222, "ext": "agda", "hexsha": "bfc8588742372d491e706818bed4b85654508a7c", "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/hip/SK.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/hip/SK.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/hip/SK.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": 337, "size": 1234 }
module list-merge-sort-test where open import list open import nat open import list-merge-sort ℕ _<_ test-list = 3 :: 2 :: 5 :: 1 :: 1 :: 6 :: 8 :: 9 :: 4 :: [] sorted = merge-sort test-list
{ "alphanum_fraction": 0.6237113402, "avg_line_length": 19.4, "ext": "agda", "hexsha": "f7d457a6e420f9a6162cf8422d937b0add9bc325", "lang": "Agda", "max_forks_count": 17, "max_forks_repo_forks_event_max_datetime": "2021-11-28T20:13:21.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-03T22:38:15.000Z", "max_forks_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rfindler/ial", "max_forks_repo_path": "list-merge-sort-test.agda", "max_issues_count": 8, "max_issues_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_issues_repo_issues_event_max_datetime": "2022-03-22T03:43:34.000Z", "max_issues_repo_issues_event_min_datetime": "2018-07-09T22:53:38.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "rfindler/ial", "max_issues_repo_path": "list-merge-sort-test.agda", "max_line_length": 59, "max_stars_count": 29, "max_stars_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rfindler/ial", "max_stars_repo_path": "list-merge-sort-test.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-04T15:05:12.000Z", "max_stars_repo_stars_event_min_datetime": "2019-02-06T13:09:31.000Z", "num_tokens": 63, "size": 194 }
open import Relation.Nullary using (¬_; Dec; yes; no) open import Relation.Binary using (Decidable) open import Relation.Binary.PropositionalEquality using (_≡_; refl) open import Relation.Nullary.Decidable using (False; map) open import Function.Equivalence as FE using () module AKS.Nat.Base where open import Agda.Builtin.FromNat using (Number) open import Data.Nat using (ℕ; _+_; _∸_; _*_; _≟_; _<ᵇ_; pred) public open ℕ public open import Data.Nat.Literals using (number) instance ℕ-number : Number ℕ ℕ-number = number data ℕ⁺ : Set where ℕ+ : ℕ → ℕ⁺ _+⁺_ : ℕ⁺ → ℕ⁺ → ℕ⁺ ℕ+ n +⁺ ℕ+ m = ℕ+ (suc (n + m)) _*⁺_ : ℕ⁺ → ℕ⁺ → ℕ⁺ ℕ+ n *⁺ ℕ+ m = ℕ+ (n + m * (suc n)) _≟⁺_ : Decidable {A = ℕ⁺} _≡_ ℕ+ n ≟⁺ ℕ+ m = map (FE.equivalence (λ { refl → refl }) (λ { refl → refl })) (n ≟ m) ⟅_⇑⟆ : ∀ n {≢0 : False (n ≟ zero)} → ℕ⁺ ⟅ suc n ⇑⟆ = ℕ+ n ⟅_⇓⟆ : ℕ⁺ → ℕ ⟅ ℕ+ n ⇓⟆ = suc n instance ℕ⁺-number : Number ℕ⁺ ℕ⁺-number = record { Constraint = λ n → False (n ≟ zero) ; fromNat = λ n {{≢0}} → ⟅ n ⇑⟆ {≢0} } infix 4 _≤_ record _≤_ (n : ℕ) (m : ℕ) : Set where constructor lte field k : ℕ ≤-proof : n + k ≡ m infix 4 _≥_ _≥_ : ℕ → ℕ → Set n ≥ m = m ≤ n infix 4 _≰_ _≰_ : ℕ → ℕ → Set n ≰ m = ¬ (n ≤ m) infix 4 _≱_ _≱_ : ℕ → ℕ → Set n ≱ m = ¬ (m ≤ n) infix 4 _<_ _<_ : ℕ → ℕ → Set n < m = suc n ≤ m infix 4 _≮_ _≮_ : ℕ → ℕ → Set n ≮ m = ¬ (n < m) infix 4 _>_ _>_ : ℕ → ℕ → Set n > m = m < n infix 4 _≯_ _≯_ : ℕ → ℕ → Set n ≯ m = m ≮ n
{ "alphanum_fraction": 0.5418082937, "avg_line_length": 18.858974359, "ext": "agda", "hexsha": "18c6f37c38d1da2d59f65215f76e720c82c087a7", "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": "ddad4c0d5f384a0219b2177461a68dae06952dde", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mckeankylej/thesis", "max_forks_repo_path": "proofs/AKS/Nat/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde", "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": "mckeankylej/thesis", "max_issues_repo_path": "proofs/AKS/Nat/Base.agda", "max_line_length": 83, "max_stars_count": 1, "max_stars_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mckeankylej/thesis", "max_stars_repo_path": "proofs/AKS/Nat/Base.agda", "max_stars_repo_stars_event_max_datetime": "2020-12-01T22:38:27.000Z", "max_stars_repo_stars_event_min_datetime": "2020-12-01T22:38:27.000Z", "num_tokens": 680, "size": 1471 }
---------------------------------------------------------------------- -- Functional small-step semantics ---------------------------------------------------------------------- module SystemF.Reduction where open import Codata.Musical.Notation open import Category.Monad open import Category.Monad.Partiality.All open import Data.Maybe as Maybe using (Maybe; just; nothing; map) open import Data.Maybe.Relation.Unary.All as MaybeAll using (nothing; just) open import Data.Maybe.Relation.Unary.Any as MaybeAny using (just) open import Data.Nat using (ℕ; _+_) open import Data.Unit using (tt) open import Data.Vec using ([]) open import Relation.Binary.PropositionalEquality as P using (_≡_; _≢_) open import Relation.Nullary open import PartialityAndFailure as PF open PF.Equality hiding (fail) open PF.Equivalence private open module M {f} = RawMonad (PF.monad {f}) using (_>>=_; return) open import SystemF.Type open import SystemF.Term open import SystemF.WtTerm open import SystemF.Eval hiding (type-soundness) open TypeSubst using () renaming (_[/_] to _[/tp_]) open TermTypeSubst using () renaming (_[/_] to _[/tmTp_]) open TermTermSubst using () renaming (_[/_] to _[/tmTm_]) open WtTermTypeSubst using () renaming (_[/_]′ to _[/⊢tmTp_]) open WtTermTermSubst using () renaming (_[/_] to _[/⊢tmTm_]) ---------------------------------------------------------------------- -- Functional call-by-value small-step semantics in the partiality -- monad -- The functional presentation of the small-step semantics below is -- heavily inspired by Danielsson's ICFP'12 paper "Operational -- Semantics Using the Partiality Monad". Whereas the paper -- illustrates the technique to give a functional abstract machine -- semantics (i.e. the semantics of a "VM"), we skip the compilation -- step and directly reduce terms, which results in a (functional) -- structural operational semantics (SOS). We adopt many of the -- conventions used in the accompanying code, which can be found at -- -- http://www.cse.chalmers.se/~nad/publications/danielsson-semantics-partiality-monad.tgz -- -- As pointed out in Danielsson's paper, the functional presentation -- of the semantics feels rather natural in that it follows the form -- of an interpreter, and it has the added advantage of proving that -- the semantics are deterministic and computable "for free". -- -- For more information about Danielson's paper see -- -- http://www.cse.chalmers.se/~nad/publications/danielsson-semantics-partiality-monad.html ---------------------------------------------------------------------- -- Small-step call-by-value reduction -- Results of reduction steps data Result (m n : ℕ) : Set where continue : (t : Term m n) → Result m n -- further reducible term done : (v : Val m n) → Result m n -- irreducible value -- Take a single reduction step (if possible). step : ∀ {m n} → Term m n → Maybe (Result m n) step (var x) = nothing step (Λ t) = just (done (Λ t)) step (λ' a t) = just (done (λ' a t)) step (μ a t) = just (continue (t [/tmTm μ a t ])) step (t [ a ]) with step t ... | just (continue t′) = just (continue (t′ [ a ])) ... | just (done (Λ t′)) = just (continue (t′ [/tmTp a ])) ... | just (done _) = nothing ... | nothing = nothing step {m} {n} (s · t) with step s ... | just (continue s′) = just (continue (s′ · t)) ... | just (done v) = nested v where -- Call-by-value: only reduce (s · t) if s is a value. nested : Val m n → Maybe (Result m n) nested v with step t nested v | (just (continue t′)) = just (continue (⌜ v ⌝ · t′)) nested (λ' _ s′) | (just (done v)) = just (continue (s′ [/tmTm ⌜ v ⌝ ])) nested _ | (just (done _)) = nothing nested _ | nothing = nothing ... | nothing = nothing step (fold a t) with step t ... | just (continue t′) = just (continue (fold a t′)) ... | just (done v) = just (done (fold a v)) ... | nothing = nothing step (unfold a t) with step t ... | just (continue t′) = just (continue (unfold a t′)) ... | just (done (fold _ v)) = just (done v) ... | just (done _) = nothing ... | nothing = nothing ---------------------------------------------------------------------- -- Type soundness infix 4 _⊢res_∈_ _⊢res?_∈_ -- Well-typedness lifted to results of reduction steps. data _⊢res_∈_ {m n} (Γ : Ctx m n) : Result m n → Type n → Set where ⊢continue : ∀ {t a} → Γ ⊢ t ∈ a → Γ ⊢res continue t ∈ a ⊢done : ∀ {v a} → Γ ⊢val v ∈ a → Γ ⊢res done v ∈ a -- Well-typedness lifted to possibly undefined reduction steps. _⊢res?_∈_ : ∀ {m n} → Ctx m n → Maybe (Result m n) → Type n → Set Γ ⊢res? r? ∈ a = MaybeAll.All (λ r → Γ ⊢res r ∈ a) r? -- Preservation of well-typedness: a well-typed term reduces in one -- step to a result of the same type or fails to reduce. ⊢step : ∀ {m n} {Γ : Ctx m n} {t a} → Γ ⊢ t ∈ a → Γ ⊢res? step t ∈ a ⊢step (var x) = nothing ⊢step (Λ ⊢t) = just (⊢done (Λ ⊢t)) ⊢step (λ' a ⊢t) = just (⊢done (λ' a ⊢t)) ⊢step (μ a ⊢t) = just (⊢continue (⊢t [/⊢tmTm μ a ⊢t ])) ⊢step {t = t [ a ]} (⊢t [ .a ]) with step t | ⊢step ⊢t ... | just ._ | just (⊢continue ⊢t′) = just (⊢continue (⊢t′ [ a ])) ... | just ._ | just (⊢done (Λ ⊢t′)) = just (⊢continue (⊢t′ [/⊢tmTp a ])) ... | nothing | nothing = nothing ⊢step {m} {n} {Γ} {s · t} {b} (⊢s · ⊢t) with step s | ⊢step ⊢s ... | just ._ | just (⊢continue ⊢s′) = just (⊢continue (⊢s′ · ⊢t)) ... | just (done (λ' a s′)) | just (⊢done (λ' .a ⊢s′)) = nested where nested : Γ ⊢res? step ((λ' a s′) · t) ∈ b nested with step t | ⊢step ⊢t ... | just ._ | just (⊢continue ⊢t′) = just (⊢continue ((λ' a ⊢s′) · ⊢t′)) ... | just ._ | just (⊢done v) = just (⊢continue (⊢s′ [/⊢tmTm ⊢⌜ v ⌝ ])) ... | nothing | nothing = nothing ... | nothing | nothing = nothing ⊢step {t = fold a t} (fold .a ⊢t) with step t | ⊢step ⊢t ... | just ._ | just (⊢continue ⊢t′) = just (⊢continue (fold a ⊢t′)) ... | just ._ | just (⊢done ⊢v) = just (⊢done (fold a ⊢v)) ... | nothing | nothing = nothing ⊢step {t = unfold a t} (unfold .a ⊢t) with step t | ⊢step ⊢t ... | just ._ | just (⊢continue ⊢t′) = just (⊢continue (unfold a ⊢t′)) ... | just ._ | just (⊢done (fold .a ⊢v)) = just (⊢done ⊢v) ... | nothing | nothing = nothing -- Progress: reduction of well-typed closed terms does not fail. progress : ∀ {t} {a : Type 0} → [] ⊢ t ∈ a → Maybe.Is-just (step t) progress (var ()) progress (Λ t) = just tt progress (λ' a t) = just tt progress (μ a t) = just tt progress {t [ a ]} (⊢t [ .a ]) with step t | ⊢step ⊢t | progress ⊢t ... | just ._ | just (⊢continue _) | just tt = just tt ... | just ._ | just (⊢done (Λ _)) | just tt = just tt progress {s · t} (⊢s · ⊢t) with step s | ⊢step ⊢s | progress ⊢s ... | just ._ | just (⊢continue _) | just tt = just tt ... | just (done (λ' a s′)) | just (⊢done (λ' .a _)) | just tt = nested where nested : Maybe.Is-just (step ((λ' a s′) · t)) nested with step t | ⊢step ⊢t | progress ⊢t ... | just ._ | just (⊢continue _) | just tt = just tt ... | just ._ | just (⊢done _) | just tt = just tt progress {fold a t} (fold .a ⊢t) with step t | ⊢step ⊢t | progress ⊢t ... | just ._ | just (⊢continue _) | just tt = just tt ... | just ._ | just (⊢done _) | just tt = just tt progress {unfold a t} (unfold .a ⊢t) with step t | ⊢step ⊢t | progress ⊢t ... | just ._ | just (⊢continue _) | just tt = just tt ... | just ._ | just (⊢done (fold .a _)) | just tt = just tt infix 7 _↓ ⊢_↓ -- Evaluation of untyped (open) terms in the partiality monad via -- repeated reduction. _↓ : ∀ {m n} → Term m n → Comp m n t ↓ with step t ... | just (continue t′) = later (♯ (t′ ↓)) ... | just (done v) = return v ... | nothing = fail -- Evaluation of closed terms preserves well-typedness. ⊢_↓ : ∀ {t a} → [] ⊢ t ∈ a → [] ⊢comp t ↓ ∈ a ⊢_↓ {t} ⊢t with step t | ⊢step ⊢t | progress ⊢t ... | just (continue t′) | just (⊢continue ⊢t′) | just tt = later (♯ ⊢ ⊢t′ ↓) ... | just (done v) | just (⊢done ⊢v) | just tt = now (just ⊢v) ... | nothing | _ | () -- Type soundness: evaluation of well-typed terms does not fail. type-soundness : ∀ {t a} → [] ⊢ t ∈ a → ¬ t ↓ ≈ fail type-soundness ⊢t = does-not-fail ⊢ ⊢t ↓ ---------------------------------------------------------------------- -- Strong bisimilarity of big-step and small-step semantics open PF.AlternativeEquality renaming (return to returnP; fail to failP; _>>=_ to _>>=P_) -- Lemma: values don't reduce. step-val : ∀ {m n} (v : Val m n) → step ⌜ v ⌝ ≡ just (done v) step-val (Λ a) = P.refl step-val (λ' a t) = P.refl step-val (fold a v) with step ⌜ v ⌝ | step-val v ... | just (continue t) | () ... | just (done w) | w≡v = P.cong (map (lower a)) w≡v where lower : ∀ {m n} → Type (1 + n) → Result m n → Result m n lower a (done v) = done (fold a v) lower a (continue t) = continue t ... | nothing | () -- Lemma: _↓ "preserves" values. ↓-val : ∀ {m n} (v : Val m n) → ⌜ v ⌝ ↓ ≡ return v ↓-val v with step ⌜ v ⌝ | step-val v ↓-val v | just (continue t) | () ↓-val v | just (done w) | w≡v = P.cong toComp w≡v where toComp : ∀ {m n} → Maybe (Result m n) → Comp m n toComp (just (continue t′)) = later (♯ (t′ ↓)) toComp (just (done v)) = return v toComp nothing = fail ↓-val v | nothing | () mutual infix 7 _[_]⇓≅↓′ _·⇓≅↓′_ -- A helper lemma relating reduction and evaluation of type -- application. _[_]⇓≅↓′ : ∀ {m n} (t : Term m n) (a : Type n) → (t ↓) [ a ]⇓ ≅P (t [ a ]) ↓ t [ a ]⇓≅↓′ with step t ... | just (continue t′) = later (♯ (t′ [ a ]⇓≅↓′)) ... | just (done (Λ t′)) = later (♯ ⇓≅↓′ (t′ [/tmTp a ]) ) ... | just (done (λ' _ _)) = failP ... | just (done (fold _ _)) = failP ... | nothing = failP -- A helper lemma relating reduction and evaluation of term -- application. _·⇓≅↓′_ : ∀ {m n} (s : Term m n) (t : Term m n) → (s ↓) ·⇓ (t ↓) ≅P (s · t) ↓ s ·⇓≅↓′ t with step s s ·⇓≅↓′ t | just (continue s′) = later (♯ (s′ ·⇓≅↓′ t)) s ·⇓≅↓′ t | just (done v) with step t s ·⇓≅↓′ t | just (done v) | just (continue t′) = later (♯ subst v) where subst : ∀ v → (return v) ·⇓ (t′ ↓) ≅P (⌜ v ⌝ · t′) ↓ subst v with ⌜ v ⌝ ↓ | ↓-val v | ⌜ v ⌝ ·⇓≅↓′ t′ subst v | now (just .v) | P.refl | v≅t′ = v≅t′ subst _ | now nothing | () | _ subst _ | later x₁ | () | _ s ·⇓≅↓′ t | just (done (Λ s′)) | just (done w) = failP s ·⇓≅↓′ t | just (done (λ' a s′)) | just (done w) = later (♯ ⇓≅↓′ (s′ [/tmTm ⌜ w ⌝ ])) s ·⇓≅↓′ t | just (done (fold x v)) | just (done w) = failP s ·⇓≅↓′ t | just (done v) | nothing = failP s ·⇓≅↓′ t | nothing = failP -- A helper lemma relating reduction and evaluation of recursive -- type folding. fold⇓≅↓′ : ∀ {m n} (a : Type (1 + n)) (t : Term m n) → fold⇓ a (t ↓) ≅P (fold a t) ↓ fold⇓≅↓′ a t with step t ... | just (continue t′) = later (♯ fold⇓≅↓′ a t′) ... | just (done v) = returnP P.refl ... | nothing = failP -- A helper lemma relating reduction and evaluation of recursive -- type unfolding. unfold⇓≅↓′ : ∀ {m n} (a : Type (1 + n)) (t : Term m n) → unfold⇓ a (t ↓) ≅P (unfold a t) ↓ unfold⇓≅↓′ a t with step t ... | just (continue t′) = later (♯ unfold⇓≅↓′ a t′) ... | just (done (Λ _)) = failP ... | just (done (λ' _ _)) = failP ... | just (done (fold _ v)) = returnP P.refl ... | nothing = failP -- Big-step evaluation and small-step reduction are strongly bisimliar. ⇓≅↓′ : ∀ {m n} (t : Term m n) → t ⇓ ≅P t ↓ ⇓≅↓′ (var x) = failP ⇓≅↓′ (Λ t) = returnP P.refl ⇓≅↓′ (λ' a t) = returnP P.refl ⇓≅↓′ (μ a t) = later (♯ ⇓≅↓′ (t [/tmTm μ a t ])) ⇓≅↓′ (t [ a ]) = (t [ a ]) ⇓ ≅⟨ complete ([]-comp t a) ⟩ (t ⇓) [ a ]⇓ ≅⟨ (⇓≅↓′ t) >>=P (λ v → (_ ∎)) ⟩ (t ↓) [ a ]⇓ ≅⟨ t [ a ]⇓≅↓′ ⟩ (t [ a ]) ↓ ∎ ⇓≅↓′ (s · t) = (s · t) ⇓ ≅⟨ complete (·-comp s t) ⟩ (s ⇓) ·⇓ (t ⇓) ≅⟨ (⇓≅↓′ s >>=P λ v → ⇓≅↓′ t >>=P λ w → (_ ∎)) ⟩ (s ↓) ·⇓ (t ↓) ≅⟨ s ·⇓≅↓′ t ⟩ (s · t) ↓ ∎ ⇓≅↓′ (fold a t) = (fold a t) ⇓ ≅⟨ complete (fold-comp a t) ⟩ fold⇓ a (t ⇓) ≅⟨ (⇓≅↓′ t) >>=P (λ v → (_ ∎)) ⟩ fold⇓ a (t ↓) ≅⟨ fold⇓≅↓′ a t ⟩ (fold a t) ↓ ∎ ⇓≅↓′ (unfold a t) = (unfold a t) ⇓ ≅⟨ complete (unfold-comp a t) ⟩ unfold⇓ a (t ⇓) ≅⟨ (⇓≅↓′ t) >>=P (λ v → (_ ∎)) ⟩ unfold⇓ a (t ↓) ≅⟨ unfold⇓≅↓′ a t ⟩ (unfold a t) ↓ ∎ -- Big-step evaluation and small-step reduction are strongly bisimliar. ⇓≅↓ : ∀ {m n} (t : Term m n) → t ⇓ ≅ t ↓ ⇓≅↓ t = sound (⇓≅↓′ t)
{ "alphanum_fraction": 0.5082944729, "avg_line_length": 42.7483660131, "ext": "agda", "hexsha": "eea0a4932fa88df0f45e6ee26a74b02042405df1", "lang": "Agda", "max_forks_count": 8, "max_forks_repo_forks_event_max_datetime": "2021-07-06T23:12:48.000Z", "max_forks_repo_forks_event_min_datetime": "2015-05-29T12:24:46.000Z", "max_forks_repo_head_hexsha": "ea262cf7714cdb762643f10275c568596f57cd1d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "sstucki/system-f-agda", "max_forks_repo_path": "src/SystemF/Reduction.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "ea262cf7714cdb762643f10275c568596f57cd1d", "max_issues_repo_issues_event_max_datetime": "2019-05-11T19:23:26.000Z", "max_issues_repo_issues_event_min_datetime": "2017-05-30T06:43:04.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "sstucki/system-f-agda", "max_issues_repo_path": "src/SystemF/Reduction.agda", "max_line_length": 92, "max_stars_count": 68, "max_stars_repo_head_hexsha": "ea262cf7714cdb762643f10275c568596f57cd1d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "sstucki/system-f-agda", "max_stars_repo_path": "src/SystemF/Reduction.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-01T01:25:16.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-26T13:12:56.000Z", "num_tokens": 4898, "size": 13081 }
open import Data.Nat using (ℕ; suc; zero; _<_; _≤_; z≤n; s≤s; _+_; _⊔_) open import Data.Bool using (Bool; true; false; not; _∧_) open import Data.Sum using (inj₁; inj₂; _⊎_; [_,_]) open import Data.Product using (_×_; _,_; -,_; _-,-_; ∃; ∃-syntax; proj₂) open import Data.String using (String; _≟_; length) open import Relation.Nullary using (¬_; yes; no) open import Relation.Nullary.Decidable using (⌊_⌋) open import Relation.Nullary.Negation using (contradiction) open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; cong; trans; cong₂) open import Data.Nat.Properties hiding (_≤?_; _≟_) open import IMP level = ℕ sec : vname → level -- We can also temporarily use "sec x" to avoid the -- automatic expansion of the definition in error messages sec x = length x secₐ : aexp → level secₐ (N n) = 0 secₐ (V x) = sec x secₐ (Plus a b) = secₐ a ⊔ secₐ b sec₆ : bexp → level sec₆ (Bc x) = 0 sec₆ (Not b) = sec₆ b sec₆ (And b₁ b₂) = sec₆ b₁ ⊔ sec₆ b₂ sec₆ (Less a b) = secₐ a ⊔ secₐ b _≡_⦅≤_⦆ : state → state → level → Set s₁ ≡ s₂ ⦅≤ l ⦆ = ∀ x → sec x ≤ l → s₁ x ≡ s₂ x _≡_⦅<_⦆ : state → state → level → Set s₁ ≡ s₂ ⦅< l ⦆ = ∀ x → sec x < l → s₁ x ≡ s₂ x non-interference-aexp : ∀ a {s₁ s₂ l} → s₁ ≡ s₂ ⦅≤ l ⦆ → secₐ a ≤ l → aval a s₁ ≡ aval a s₂ non-interference-aexp (N x) r e = refl non-interference-aexp (V x) r e = r x e non-interference-aexp (Plus a b) r e = cong₂ (_+_) (non-interference-aexp a r (m⊔n≤o⇒m≤o _ _ e)) (non-interference-aexp b r (m⊔n≤o⇒n≤o _ _ e)) non-interference-bexp : ∀ a {s₁ s₂ l} → s₁ ≡ s₂ ⦅≤ l ⦆ → sec₆ a ≤ l → bval a s₁ ≡ bval a s₂ non-interference-bexp (Bc x) r e = refl non-interference-bexp (Not a) r e = cong not (non-interference-bexp a r e) non-interference-bexp (And a b) r e = cong₂ (_∧_) (non-interference-bexp a r (m⊔n≤o⇒m≤o _ _ e)) (non-interference-bexp b r (m⊔n≤o⇒n≤o _ _ e)) non-interference-bexp (Less a b) r e = cong₂ (_≤?_) (non-interference-aexp a r (m⊔n≤o⇒m≤o _ _ e)) (non-interference-aexp b r (m⊔n≤o⇒n≤o _ _ e)) data _⊢_ : level → com → Set where SecSkip : ∀{l} → l ⊢ SKIP SecLoc : ∀{l a x} → secₐ a ≤ sec x → l ≤ sec x → l ⊢ (x ::= a) SecSeq : ∀{l c₁ c₂} → l ⊢ c₁ → l ⊢ c₂ → l ⊢ (c₁ :: c₂) SecIf : ∀{b l c₁ c₂} → (l ⊔ sec₆ b) ⊢ c₁ → (l ⊔ sec₆ b) ⊢ c₂ → l ⊢ (IF b THEN c₁ ELSE c₂) SecWhile : ∀{b l c} → (l ⊔ sec₆ b) ⊢ c → l ⊢ (WHILE b DO c) anti-monotonicity : ∀{l l′ c} → l ⊢ c → l′ ≤ l → l′ ⊢ c anti-monotonicity SecSkip s = SecSkip anti-monotonicity (SecLoc x x₁) s = SecLoc x (≤-trans s x₁) anti-monotonicity (SecSeq d d₁) s = SecSeq (anti-monotonicity d s) (anti-monotonicity d₁ s) anti-monotonicity (SecIf d d₁) s = SecIf (anti-monotonicity d (⊔-monoˡ-≤ _ s)) (anti-monotonicity d₁ (⊔-monoˡ-≤ _ s)) anti-monotonicity (SecWhile d) s = SecWhile ((anti-monotonicity d (⊔-monoˡ-≤ _ s))) data ⦅_,_⦆⇒_ : com → state → state → Set where Skip : ∀{s} → ⦅ SKIP , s ⦆⇒ s Loc : ∀{s x a} → ⦅ x ::= a , s ⦆⇒ (s [ x ::= aval a s ]) Seq : ∀{c₁ c₂ s₁ s₂ s₃} → ⦅ c₁ , s₁ ⦆⇒ s₂ → ⦅ c₂ , s₂ ⦆⇒ s₃ → ⦅ c₁ :: c₂ , s₁ ⦆⇒ s₃ IfTrue : ∀{c₁ c₂ b s t} → bval b s ≡ true → ⦅ c₁ , s ⦆⇒ t → ⦅ IF b THEN c₁ ELSE c₂ , s ⦆⇒ t IfFalse : ∀{c₁ c₂ b s t} → bval b s ≡ false → ⦅ c₂ , s ⦆⇒ t → ⦅ IF b THEN c₁ ELSE c₂ , s ⦆⇒ t WhileFalse : ∀{c b s} → bval b s ≡ false → ⦅ WHILE b DO c , s ⦆⇒ s WhileTrue : ∀{c b s₁ s₂ s₃} → bval b s₁ ≡ true → ⦅ c , s₁ ⦆⇒ s₂ → ⦅ WHILE b DO c , s₂ ⦆⇒ s₃ → ⦅ WHILE b DO c , s₁ ⦆⇒ s₃ confinement : ∀{c s t l} → ⦅ c , s ⦆⇒ t → l ⊢ c → s ≡ t ⦅< l ⦆ confinement Skip SecSkip x₂ x₃ = refl confinement (Loc {x = x₂}) (SecLoc x x₁) e r with e ≟ x₂ ... | yes refl = contradiction x₁ (<⇒≱ r) ... | no _ = refl confinement (Seq x x₄) (SecSeq x₁ x₅) x₂ x₃ = trans (confinement x x₁ x₂ x₃) (confinement x₄ x₅ x₂ x₃) confinement (IfTrue x x₄) (SecIf x₁ x₅) x₂ x₃ = confinement x₄ x₁ x₂ (m<n⇒m<n⊔o _ x₃) confinement (IfFalse x x₄) (SecIf x₁ x₅) x₂ x₃ = confinement x₄ x₅ x₂ (m<n⇒m<n⊔o _ x₃) confinement (WhileFalse x) (SecWhile x₁) x₂ x₃ = refl confinement {l = l} (WhileTrue x x₄ x₅) (SecWhile x₁) x₂ x₃ = trans (confinement x₄ (anti-monotonicity x₁ (m≤m⊔n _ _)) x₂ x₃) (confinement x₅ (SecWhile x₁) x₂ x₃) true≢false : ¬ (true ≡ false) true≢false = λ () reversal₁ : ∀{b c s₁ s₃} → ⦅ WHILE b DO c , s₁ ⦆⇒ s₃ → bval b s₁ ≡ true → ∃[ s₂ ] ( ⦅ c , s₁ ⦆⇒ s₂ × ⦅ WHILE b DO c , s₂ ⦆⇒ s₃) reversal₁ (WhileFalse x) v = contradiction (trans (sym v) x) true≢false reversal₁ (WhileTrue x e e₁) v = -, e , e₁ reversal₂ : ∀{b c s₁ s₃} → ⦅ WHILE b DO c , s₁ ⦆⇒ s₃ → bval b s₁ ≡ false → s₁ ≡ s₃ reversal₂ (WhileFalse x) v = refl reversal₂ (WhileTrue x r r₁) v = contradiction (trans (sym x) v) true≢false level-cong : ∀{l l′ c} → l ≡ l′ → l ⊢ c → l′ ⊢ c level-cong refl x = x ≤⇒<suc : ∀{a b} → a ≤ b → a < suc b ≤⇒<suc z≤n = s≤s z≤n ≤⇒<suc (s≤s r) = s≤s (≤⇒<suc r) non-interference : ∀{c s s′ t t′ l} → ⦅ c , s ⦆⇒ s′ → ⦅ c , t ⦆⇒ t′ → 0 ⊢ c → s ≡ t ⦅≤ l ⦆ → s′ ≡ t′ ⦅≤ l ⦆ non-interference Skip Skip z e = e non-interference (Loc {x = x₂} {a}) Loc (SecLoc x₃ z≤n) e x x₁ with x ≟ x₂ ... | yes refl = non-interference-aexp a e (≤-trans x₃ x₁) ... | no _ = e x x₁ non-interference (Seq x cs) (Seq y ct) (SecSeq z z₁) e = non-interference cs ct z₁ (non-interference x y z e) non-interference {l = l} (IfTrue {b = b} x cs) (IfTrue x₁ red) (SecIf w w₁) e r r₁ = non-interference cs red (anti-monotonicity w z≤n) e r r₁ non-interference {l = l} (IfTrue {b = b} x cs) (IfFalse x₁ red) (SecIf w w₁) e r r₁ = [ (λ secb≤l → let wr = non-interference-bexp b e secb≤l in contradiction (trans (sym x) (trans wr x₁)) true≢false) , (λ l<secb → let oo₁ = confinement cs w oo₂ = confinement red w₁ in trans (sym (oo₁ r (<-transʳ r₁ l<secb))) (trans (e r r₁) (oo₂ r (<-transʳ r₁ l<secb)))) ] (≤-<-connex (sec₆ b) l) non-interference {l = l} (IfFalse x₁ red) (IfTrue {b = b} x cs) (SecIf w w₁) e r r₁ = [ (λ secb≤l → let wr = non-interference-bexp b e secb≤l in contradiction (trans (sym x) (trans (sym wr) x₁)) true≢false) , (λ l<secb → let oo₁ = confinement cs w oo₂ = confinement red w₁ in trans (sym (oo₂ r (<-transʳ r₁ l<secb))) (trans (e r r₁) (oo₁ r (<-transʳ r₁ l<secb)))) ] (≤-<-connex (sec₆ b) l) non-interference (IfFalse x₁ red) (IfFalse x cs) (SecIf x₇ x₈) = non-interference red cs (anti-monotonicity x₈ z≤n) non-interference (WhileFalse x) (WhileFalse x₁) (SecWhile z) e = e non-interference {l = l} (WhileFalse {b = b} r) (WhileTrue c ct ct₁) (SecWhile z) e x x₁ = [ (λ secb≤l → let wr = non-interference-bexp b e secb≤l in contradiction (trans (sym c) (trans (sym wr) r)) true≢false) , (λ l<secb → let simp = confinement ct z simp2 = confinement ct₁ (SecWhile (level-cong (sym (m≤n⇒m⊔n≡n l<secb)) z)) in trans (e x x₁) (trans (simp x (<-transʳ x₁ l<secb)) (simp2 x (≤⇒<suc x₁)))) ] (≤-<-connex (sec₆ b) l) non-interference {l = l} (WhileTrue c ct ct₁) (WhileFalse {b = b} r) (SecWhile z) e x x₁ = [ (λ secb≤l → let wr = non-interference-bexp b e secb≤l in contradiction (trans (sym c) (trans wr r)) true≢false) , (λ l<secb → let simp = confinement ct z simp2 = confinement ct₁ (SecWhile (level-cong (sym (m≤n⇒m⊔n≡n l<secb)) z)) in trans (trans (sym (simp2 x (≤⇒<suc x₁))) (sym (simp x ((<-transʳ x₁ l<secb))))) (e x x₁)) ] (≤-<-connex (sec₆ b) l) non-interference {l = l} (WhileTrue {b = b} r cs cs₁) (WhileTrue c ct ct₁) (SecWhile z) e = let h₁ = non-interference cs ct (anti-monotonicity z z≤n) e h₂ = non-interference cs₁ ct₁ (SecWhile z) h₁ in h₂
{ "alphanum_fraction": 0.5558049632, "avg_line_length": 36.6164383562, "ext": "agda", "hexsha": "101300cc6e3e857f0dc52c7f1e3dad02695f5cda", "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": "cb98e3b3b93362654b79152bfdf2c21eb4951fcc", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "iwilare/imp-semantics", "max_forks_repo_path": "Security.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cb98e3b3b93362654b79152bfdf2c21eb4951fcc", "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": "iwilare/imp-semantics", "max_issues_repo_path": "Security.agda", "max_line_length": 117, "max_stars_count": 6, "max_stars_repo_head_hexsha": "cb98e3b3b93362654b79152bfdf2c21eb4951fcc", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "iwilare/imp-semantics", "max_stars_repo_path": "Security.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-24T22:29:44.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-08T11:54:07.000Z", "num_tokens": 3669, "size": 8019 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Relations between properties of functions, such as associativity and -- commutativity (only those that don't require any sort of setoid) ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Algebra.FunctionProperties.Consequences.Core {a} {A : Set a} where open import Algebra.FunctionProperties open import Data.Sum open import Relation.Binary sel⇒idem : ∀ {ℓ} {_•_ : Op₂ A} (_≈_ : Rel A ℓ) → Selective _≈_ _•_ → Idempotent _≈_ _•_ sel⇒idem _ sel x with sel x x ... | inj₁ x•x≈x = x•x≈x ... | inj₂ x•x≈x = x•x≈x
{ "alphanum_fraction": 0.5357142857, "avg_line_length": 31.8181818182, "ext": "agda", "hexsha": "48bc2515d6171eff6004968703b0072a3eb7bbba", "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/Algebra/FunctionProperties/Consequences/Core.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/Algebra/FunctionProperties/Consequences/Core.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Algebra/FunctionProperties/Consequences/Core.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 189, "size": 700 }
------------------------------------------------------------------------------ -- We could not define the FOTC colists using the Agda machinery for -- co-inductive types. ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.FOTC.Data.Colist.TypeSL where open import Codata.Musical.Notation open import FOTC.Base open import FOTC.Base.List ------------------------------------------------------------------------------ data Colist : D → Set where nilCL : Colist [] consCL : ∀ x xs → ∞ (Colist xs) → Colist (x ∷ xs) -- Example (finite colist). l₁ : Colist (zero ∷ true ∷ []) l₁ = consCL zero (true ∷ []) (♯ (consCL true [] (♯ nilCL))) -- Example (infinite colist). -- zerosCL : Colist {!!} -- zerosCL = consCL zero {!!} (♯ zerosCL)
{ "alphanum_fraction": 0.4569327731, "avg_line_length": 30.7096774194, "ext": "agda", "hexsha": "81785cab88f74e404fc02b35ab92d20b3dc5a4b6", "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/Data/Colist/TypeSL.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/Data/Colist/TypeSL.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/Data/Colist/TypeSL.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": 217, "size": 952 }
{-# OPTIONS --without-K --safe --no-sized-types --no-guardedness --no-subtyping #-} module Agda.Builtin.Float.Properties where open import Agda.Builtin.Float open import Agda.Builtin.Equality primitive primFloatToWord64Injective : ∀ a b → primFloatToWord64 a ≡ primFloatToWord64 b → a ≡ b
{ "alphanum_fraction": 0.7231270358, "avg_line_length": 25.5833333333, "ext": "agda", "hexsha": "a090623f0948449392d80abeaa727efcdc9a2de0", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-04-18T13:34:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-18T13:34:07.000Z", "max_forks_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "shlevy/agda", "max_forks_repo_path": "src/data/lib/prim/Agda/Builtin/Float/Properties.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2015-09-15T15:49:15.000Z", "max_issues_repo_issues_event_min_datetime": "2015-09-15T15:49:15.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "src/data/lib/prim/Agda/Builtin/Float/Properties.agda", "max_line_length": 88, "max_stars_count": 1, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "src/data/lib/prim/Agda/Builtin/Float/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2016-05-20T13:58:52.000Z", "max_stars_repo_stars_event_min_datetime": "2016-05-20T13:58:52.000Z", "num_tokens": 84, "size": 307 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.HITs.Interval where open import Cubical.HITs.Interval.Base public -- open import Cubical.HITs.Interval.Properties public
{ "alphanum_fraction": 0.7671957672, "avg_line_length": 27, "ext": "agda", "hexsha": "db71aa3da4c5b1d0c0304d7c8f912e322696de8c", "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/HITs/Interval.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/HITs/Interval.agda", "max_line_length": 54, "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/HITs/Interval.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 46, "size": 189 }
-- Basic intuitionistic modal logic S4, without ∨, ⊥, or ◇. -- Tarski-style semantics with context pairs as concrete worlds, and glueing for α, ▻, and □. -- Hilbert-style syntax. module BasicIS4.Semantics.TarskiOvergluedDyadicHilbert where open import BasicIS4.Syntax.Common public open import Common.Semantics public -- Intuitionistic Tarski models. record Model : Set₁ where infix 3 _⊩ᵅ_ _[⊢]_ field -- Forcing for atomic propositions; monotonic. _⊩ᵅ_ : Cx² Ty Ty → Atom → Set mono²⊩ᵅ : ∀ {P Π Π′} → Π ⊆² Π′ → Π ⊩ᵅ P → Π′ ⊩ᵅ P -- Hilbert-style syntax representation; monotonic. _[⊢]_ : Cx² Ty Ty → Ty → Set mono²[⊢] : ∀ {A Π Π′} → Π ⊆² Π′ → Π [⊢] A → Π′ [⊢] A [var] : ∀ {A Γ Δ} → A ∈ Γ → Γ ⁏ Δ [⊢] A [app] : ∀ {A B Γ Δ} → Γ ⁏ Δ [⊢] A ▻ B → Γ ⁏ Δ [⊢] A → Γ ⁏ Δ [⊢] B [ci] : ∀ {A Γ Δ} → Γ ⁏ Δ [⊢] A ▻ A [ck] : ∀ {A B Γ Δ} → Γ ⁏ Δ [⊢] A ▻ B ▻ A [cs] : ∀ {A B C Γ Δ} → Γ ⁏ Δ [⊢] (A ▻ B ▻ C) ▻ (A ▻ B) ▻ A ▻ C [mvar] : ∀ {A Γ Δ} → A ∈ Δ → Γ ⁏ Δ [⊢] A [box] : ∀ {A Γ Δ} → ∅ ⁏ Δ [⊢] A → Γ ⁏ Δ [⊢] □ A [cdist] : ∀ {A B Γ Δ} → Γ ⁏ Δ [⊢] □ (A ▻ B) ▻ □ A ▻ □ B [cup] : ∀ {A Γ Δ} → Γ ⁏ Δ [⊢] □ A ▻ □ □ A [cdown] : ∀ {A Γ Δ} → Γ ⁏ Δ [⊢] □ A ▻ A [cpair] : ∀ {A B Γ Δ} → Γ ⁏ Δ [⊢] A ▻ B ▻ A ∧ B [cfst] : ∀ {A B Γ Δ} → Γ ⁏ Δ [⊢] A ∧ B ▻ A [csnd] : ∀ {A B Γ Δ} → Γ ⁏ Δ [⊢] A ∧ B ▻ B [unit] : ∀ {Γ Δ} → Γ ⁏ Δ [⊢] ⊤ -- NOTE: [mlam] is necessary for [mmulticut], which is necessary for eval. [mlam] : ∀ {A B Γ Δ} → Γ ⁏ Δ , A [⊢] B → Γ ⁏ Δ [⊢] □ A ▻ B infix 3 _[⊢]⋆_ _[⊢]⋆_ : Cx² Ty Ty → Cx Ty → Set Π [⊢]⋆ ∅ = 𝟙 Π [⊢]⋆ Ξ , A = Π [⊢]⋆ Ξ × Π [⊢] A open Model {{…}} public -- Forcing in a particular model. module _ {{_ : Model}} where infix 3 _⊩_ _⊩_ : Cx² Ty Ty → Ty → Set Π ⊩ α P = Glue (Π [⊢] α P) (Π ⊩ᵅ P) Π ⊩ A ▻ B = ∀ {Π′} → Π ⊆² Π′ → Glue (Π′ [⊢] A ▻ B) (Π′ ⊩ A → Π′ ⊩ B) Π ⊩ □ A = ∀ {Π′} → Π ⊆² Π′ → Glue (Π′ [⊢] □ A) (Π′ ⊩ A) Π ⊩ A ∧ B = Π ⊩ A × Π ⊩ B Π ⊩ ⊤ = 𝟙 infix 3 _⊩⋆_ _⊩⋆_ : Cx² Ty Ty → Cx Ty → Set Π ⊩⋆ ∅ = 𝟙 Π ⊩⋆ Ξ , A = Π ⊩⋆ Ξ × Π ⊩ A -- Monotonicity with respect to context inclusion. module _ {{_ : Model}} where mono²⊩ : ∀ {A Π Π′} → Π ⊆² Π′ → Π ⊩ A → Π′ ⊩ A mono²⊩ {α P} ψ s = mono²[⊢] ψ (syn s) ⅋ mono²⊩ᵅ ψ (sem s) mono²⊩ {A ▻ B} ψ s = λ ψ′ → s (trans⊆² ψ ψ′) mono²⊩ {□ A} ψ s = λ ψ′ → s (trans⊆² ψ ψ′) mono²⊩ {A ∧ B} ψ s = mono²⊩ {A} ψ (π₁ s) , mono²⊩ {B} ψ (π₂ s) mono²⊩ {⊤} ψ s = ∙ mono²⊩⋆ : ∀ {Ξ Π Π′} → Π ⊆² Π′ → Π ⊩⋆ Ξ → Π′ ⊩⋆ Ξ mono²⊩⋆ {∅} ψ ∙ = ∙ mono²⊩⋆ {Ξ , A} ψ (ts , t) = mono²⊩⋆ ψ ts , mono²⊩ {A} ψ t -- Extraction of syntax representation in a particular model. module _ {{_ : Model}} where reifyʳ : ∀ {A Π} → Π ⊩ A → Π [⊢] A reifyʳ {α P} s = syn s reifyʳ {A ▻ B} s = syn (s refl⊆²) reifyʳ {□ A} s = syn (s refl⊆²) reifyʳ {A ∧ B} s = [app] ([app] [cpair] (reifyʳ {A} (π₁ s))) (reifyʳ {B} (π₂ s)) reifyʳ {⊤} s = [unit] reifyʳ⋆ : ∀ {Ξ Π} → Π ⊩⋆ Ξ → Π [⊢]⋆ Ξ reifyʳ⋆ {∅} ∙ = ∙ reifyʳ⋆ {Ξ , A} (ts , t) = reifyʳ⋆ ts , reifyʳ t -- Useful theorems in functional form. module _ {{_ : Model}} where [mmulticut] : ∀ {Ξ A Γ Δ} → Γ ⁏ Δ [⊢]⋆ □⋆ Ξ → Γ ⁏ Ξ [⊢] A → Γ ⁏ Δ [⊢] A [mmulticut] {∅} ∙ u = mono²[⊢] (refl⊆ , bot⊆) u [mmulticut] {Ξ , B} (ts , t) u = [app] ([mmulticut] ts ([mlam] u)) t -- Additional useful equipment. module _ {{_ : Model}} where _⟪$⟫_ : ∀ {A B Π} → Π ⊩ A ▻ B → Π ⊩ A → Π ⊩ B s ⟪$⟫ a = sem (s refl⊆²) a ⟪K⟫ : ∀ {A B Π} → Π ⊩ A → Π ⊩ B ▻ A ⟪K⟫ {A} a ψ = let a′ = mono²⊩ {A} ψ a in [app] [ck] (reifyʳ a′) ⅋ K a′ ⟪S⟫ : ∀ {A B C Π} → Π ⊩ A ▻ B ▻ C → Π ⊩ A ▻ B → Π ⊩ A → Π ⊩ C ⟪S⟫ s₁ s₂ a = (s₁ ⟪$⟫ a) ⟪$⟫ (s₂ ⟪$⟫ a) ⟪S⟫′ : ∀ {A B C Π} → Π ⊩ A ▻ B ▻ C → Π ⊩ (A ▻ B) ▻ A ▻ C ⟪S⟫′ {A} {B} {C} s₁ ψ = let s₁′ = mono²⊩ {A ▻ B ▻ C} ψ s₁ t = syn (s₁′ refl⊆²) in [app] [cs] t ⅋ λ s₂ ψ′ → let s₁″ = mono²⊩ {A ▻ B ▻ C} (trans⊆² ψ ψ′) s₁ s₂′ = mono²⊩ {A ▻ B} ψ′ s₂ t′ = syn (s₁″ refl⊆²) u = syn (s₂′ refl⊆²) in [app] ([app] [cs] t′) u ⅋ ⟪S⟫ s₁″ s₂′ _⟪D⟫_ : ∀ {A B Π} → Π ⊩ □ (A ▻ B) → Π ⊩ □ A → Π ⊩ □ B (s₁ ⟪D⟫ s₂) ψ = let t ⅋ s₁′ = s₁ ψ u ⅋ a = s₂ ψ in [app] ([app] [cdist] t) u ⅋ s₁′ ⟪$⟫ a _⟪D⟫′_ : ∀ {A B Π} → Π ⊩ □ (A ▻ B) → Π ⊩ □ A ▻ □ B _⟪D⟫′_ {A} {B} s₁ ψ = let s₁′ = mono²⊩ {□ (A ▻ B)} ψ s₁ in [app] [cdist] (reifyʳ (λ {_} ψ′ → s₁′ ψ′)) ⅋ _⟪D⟫_ s₁′ ⟪↑⟫ : ∀ {A Π} → Π ⊩ □ A → Π ⊩ □ □ A ⟪↑⟫ {A} s ψ = [app] [cup] (syn (s ψ)) ⅋ λ ψ′ → s (trans⊆² ψ ψ′) ⟪↓⟫ : ∀ {A Π} → Π ⊩ □ A → Π ⊩ A ⟪↓⟫ s = sem (s refl⊆²) _⟪,⟫′_ : ∀ {A B Π} → Π ⊩ A → Π ⊩ B ▻ A ∧ B _⟪,⟫′_ {A} a ψ = let a′ = mono²⊩ {A} ψ a in [app] [cpair] (reifyʳ a′) ⅋ _,_ a′ -- Forcing in a particular world of a particular model, for sequents. module _ {{_ : Model}} where infix 3 _⊩_⇒_ _⊩_⇒_ : Cx² Ty Ty → Cx² Ty Ty → Ty → Set Π ⊩ Γ ⁏ Δ ⇒ A = Π ⊩⋆ Γ → Π ⊩⋆ □⋆ Δ → Π ⊩ A infix 3 _⊩_⇒⋆_ _⊩_⇒⋆_ : Cx² Ty Ty → Cx² Ty Ty → Cx Ty → Set Π ⊩ Γ ⁏ Δ ⇒⋆ Ξ = Π ⊩⋆ Γ → Π ⊩⋆ □⋆ Δ → Π ⊩⋆ Ξ -- Entailment, or forcing in all worlds of all models, for sequents. infix 3 _⊨_ _⊨_ : Cx² Ty Ty → Ty → Set₁ Π ⊨ A = ∀ {{_ : Model}} {w : Cx² Ty Ty} → w ⊩ Π ⇒ A infix 3 _⊨⋆_ _⊨⋆_ : Cx² Ty Ty → Cx Ty → Set₁ Π ⊨⋆ Ξ = ∀ {{_ : Model}} {w : Cx² Ty Ty} → w ⊩ Π ⇒⋆ Ξ -- Additional useful equipment, for sequents. module _ {{_ : Model}} where lookup : ∀ {A Γ w} → A ∈ Γ → w ⊩⋆ Γ → w ⊩ A lookup top (γ , a) = a lookup (pop i) (γ , b) = lookup i γ mlookup : ∀ {A Δ w} → A ∈ Δ → w ⊩⋆ □⋆ Δ → w ⊩ A mlookup top (γ , s) = sem (s refl⊆²) mlookup (pop i) (γ , s) = mlookup i γ -- TODO: More equipment.
{ "alphanum_fraction": 0.403327787, "avg_line_length": 33.021978022, "ext": "agda", "hexsha": "4a48984c7523257967d806e0ce874e7f5c18adbb", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "mietek/hilbert-gentzen", "max_forks_repo_path": "BasicIS4/Semantics/TarskiOvergluedDyadicHilbert.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_issues_repo_issues_event_max_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_licenses": [ "X11" ], "max_issues_repo_name": "mietek/hilbert-gentzen", "max_issues_repo_path": "BasicIS4/Semantics/TarskiOvergluedDyadicHilbert.agda", "max_line_length": 93, "max_stars_count": 29, "max_stars_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "mietek/hilbert-gentzen", "max_stars_repo_path": "BasicIS4/Semantics/TarskiOvergluedDyadicHilbert.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-01T10:29:18.000Z", "max_stars_repo_stars_event_min_datetime": "2016-07-03T18:51:56.000Z", "num_tokens": 3468, "size": 6010 }
{-# OPTIONS --without-K --safe #-} module Dodo.Binary.Acyclic where -- Stdlib imports open import Level using (Level; _⊔_) open import Function using (flip) open import Data.Product using (_×_; _,_; proj₁; proj₂) open import Relation.Binary using (Rel; REL) open import Relation.Binary using (Irreflexive; Transitive; Symmetric) open import Relation.Binary.Construct.Closure.Transitive using (TransClosure; [_]; _∷_; _++_) -- Local imports open import Dodo.Binary.Equality open import Dodo.Binary.Transitive -- # Definitions -- | Acyclicity of a binary relation R: x R⁺ y → x ≠ y -- -- Defined with an underlying equality (≈) Acyclic : {a ℓ₁ ℓ₂ : Level} → {A : Set a} → Rel A ℓ₁ → Rel A ℓ₂ → Set _ Acyclic _≈_ _<_ = Irreflexive _≈_ (TransClosure _<_) -- # Operations module _ {a ℓ₁ ℓ₂ : Level} {A : Set a} {_≈_ : Rel A ℓ₁} {R : Rel A ℓ₂} where -- | Any acyclic relation is also irreflexive Acyclic⇒Irreflexive : Acyclic _≈_ R → Irreflexive _≈_ R Acyclic⇒Irreflexive acyclicR x≈y Rxy = acyclicR x≈y [ Rxy ] module _ {a ℓ₁ ℓ₂ ℓ₃ : Level} {A : Set a} {_≈_ : Rel A ℓ₁} {P : Rel A ℓ₂} {Q : Rel A ℓ₃} where -- | If a relation is acyclic, then any subset of that relation is also acyclic acyclic-⊆₂ : Acyclic _≈_ Q → P ⊆₂ Q → Acyclic _≈_ P acyclic-⊆₂ acyclicQ P⊆Q x≈y P⁺ = acyclicQ x≈y (⊆₂-apply (⁺-preserves-⊆₂ P⊆Q) P⁺) module _ {a ℓ₁ ℓ₂ ℓ₃ : Level} {A : Set a} {_≈_ : Rel A ℓ₁} {R : Rel A ℓ₂} where -- | If a relation is acyclic, then its transitive closure is also acyclic ⁺-preserves-acyclic : Acyclic _≈_ R → Acyclic _≈_ (TransClosure R) ⁺-preserves-acyclic acR x≈y R⁺⁺xy = acR x≈y (⇔₂-apply-⊇₂ ⁺-idem R⁺⁺xy)
{ "alphanum_fraction": 0.6455026455, "avg_line_length": 34.02, "ext": "agda", "hexsha": "ce6f743f2725681c8a1a91e96edf616c8b920cfe", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "sourcedennis/agda-dodo", "max_forks_repo_path": "src/Dodo/Binary/Acyclic.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "sourcedennis/agda-dodo", "max_issues_repo_path": "src/Dodo/Binary/Acyclic.agda", "max_line_length": 94, "max_stars_count": null, "max_stars_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "sourcedennis/agda-dodo", "max_stars_repo_path": "src/Dodo/Binary/Acyclic.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 660, "size": 1701 }
postulate F : Set₁ → Set₁ data P : Set₁ → Set₁ where c : P (F (P Set)) → P Set
{ "alphanum_fraction": 0.5595238095, "avg_line_length": 14, "ext": "agda", "hexsha": "b1ba5e828df1f7d06e7c4db3e6abce57bc90df90", "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/Issue3592-2.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/Issue3592-2.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/Issue3592-2.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 36, "size": 84 }
-- There was a bug where reexported constructors weren't -- properly translated when termination checking. module OpenPublicTermination where module A where data U : Set where nat : U list : U -> U module A' where open A public open A' f : U -> U f nat = nat f (list nat) = nat f (list (list u)) = f (list u)
{ "alphanum_fraction": 0.6430678466, "avg_line_length": 16.1428571429, "ext": "agda", "hexsha": "c2437a2f042b54f44252049054977597dadb69ba", "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/OpenPublicTermination.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/OpenPublicTermination.agda", "max_line_length": 56, "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/OpenPublicTermination.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": 97, "size": 339 }
------------------------------------------------------------------------ -- Simple regular expression matcher (without soundness proof) ------------------------------------------------------------------------ open import Eq open import Setoids open import Prelude import RegExps module BoolMatcher (D : Datoid) where private open module D' = Datoid D open module S' = Setoid setoid open module R = RegExps setoid infix 4 _∈‿⟦_⟧¿ ------------------------------------------------------------------------ -- Helper function decToBool : forall {x y} -> Dec (x ≈ y) -> Bool decToBool (yes _) = true decToBool (no _) = false ------------------------------------------------------------------------ -- Regular expression matcher matches-⊙¿ : (xs₁ xs₂ : [ carrier ]) -> (re₁ re₂ : RegExp) -> Bool _∈‿⟦_⟧¿ : (xs : [ carrier ]) -> (re : RegExp) -> Bool [] ∈‿⟦ ε ⟧¿ = true x ∷ [] ∈‿⟦ • ⟧¿ = true x ∷ [] ∈‿⟦ sym y ⟧¿ = decToBool (x ≟ y) xs ∈‿⟦ re₁ ∣ re₂ ⟧¿ = xs ∈‿⟦ re₁ ⟧¿ ∨ xs ∈‿⟦ re₂ ⟧¿ xs ∈‿⟦ re₁ ⊙ re₂ ⟧¿ = matches-⊙¿ [] xs re₁ re₂ [] ∈‿⟦ re ⋆ ⟧¿ = true x ∷ xs ∈‿⟦ re ⋆ ⟧¿ = matches-⊙¿ (x ∷ []) xs re (re ⋆) _ ∈‿⟦ _ ⟧¿ = false matches-⊙¿ xs₁ xs₂ re₁ re₂ with xs₁ ∈‿⟦ re₁ ⟧¿ ∨ xs₂ ∈‿⟦ re₂ ⟧¿ matches-⊙¿ xs₁ xs₂ re₁ re₂ | true = true matches-⊙¿ xs₁ [] re₁ re₂ | false = false matches-⊙¿ xs₁ (x ∷ xs₂) re₁ re₂ | false = matches-⊙¿ (xs₁ ++ x ∷ []) xs₂ re₁ re₂
{ "alphanum_fraction": 0.4198895028, "avg_line_length": 30.8085106383, "ext": "agda", "hexsha": "6bfdf3e1c0164c5b75fe3415ae89dcfd66291b27", "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/AIM6/RegExp/talk/BoolMatcher.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/AIM6/RegExp/talk/BoolMatcher.agda", "max_line_length": 72, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "examples/AIM6/RegExp/talk/BoolMatcher.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": 528, "size": 1448 }
{-# OPTIONS --show-implicit #-} -- {-# OPTIONS -v tc.def.fun:10 -v tc.def.where:100 #-} module PartialityMonad where open import Common.Level open import Common.Coinduction record RawMonad {f} (M : Set f → Set f) : Set (lsuc f) where infixl 1 _>>=_ field return : ∀ {A} → A → M A _>>=_ : ∀ {A B} → M A → (A → M B) → M B ------------------------------------------------------------------------ -- The partiality monad data _⊥ {a} (A : Set a) : Set a where now : (x : A) → A ⊥ later : (x : ∞ (A ⊥)) → A ⊥ -- Fails if hidden pattern {f} is removed monad : ∀ {f} → RawMonad {f = f} _⊥ -- monad {f} = record monad = record { return = now ; _>>=_ = _>>=_ } where _>>=_ : ∀ {A B} → A ⊥ → (A → B ⊥) → B ⊥ now x >>= f = f x later x >>= f = later (♯ (♭ x >>= f))
{ "alphanum_fraction": 0.4592220828, "avg_line_length": 22.7714285714, "ext": "agda", "hexsha": "2492bd3ebc76db77e12da03bb29c616072e21b3a", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/Succeed/PartialityMonad.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "alhassy/agda", "max_issues_repo_path": "test/Succeed/PartialityMonad.agda", "max_line_length": 72, "max_stars_count": 3, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/Succeed/PartialityMonad.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": 300, "size": 797 }
---------------------------------------------------------------------------- -- The FOTC lists of natural numbers type ---------------------------------------------------------------------------- {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Data.Nat.List.Type where open import FOTC.Base open import FOTC.Base.List open import FOTC.Data.Nat.Type ------------------------------------------------------------------------------ -- The FOTC lists of natural numbers type (inductive predicate for -- total lists of natural numbers). data ListN : D → Set where lnnil : ListN [] lncons : ∀ {n ns} → N n → ListN ns → ListN (n ∷ ns) {-# ATP axioms lnnil lncons #-} -- Induction principle. ListN-ind : (A : D → Set) → A [] → (∀ {n ns} → N n → A ns → A (n ∷ ns)) → ∀ {ns} → ListN ns → A ns ListN-ind A A[] h lnnil = A[] ListN-ind A A[] h (lncons Nn Lns) = h Nn (ListN-ind A A[] h Lns)
{ "alphanum_fraction": 0.4415341441, "avg_line_length": 34.4838709677, "ext": "agda", "hexsha": "c2cbd70284781ceca8657c29ea1318a46cca7158", "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/Nat/List/Type.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/Nat/List/Type.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/FOTC/Data/Nat/List/Type.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": 264, "size": 1069 }
module x04equality where ------------------------------------------------------------------------------ -- EQUALITY -- for any type A -- for any x of type A -- refl constructor provides evidence that x ≡ x -- i.e., every value is equal to itself data _≡_ {A : Set} (x : A) : A → Set where refl : x ≡ x infix 4 _≡_ -- tell Agda which type corresponds to equality {-# BUILTIN EQUALITY _≡_ #-} {- Note: - 1st arg to _≡_ is PARAMETER (x : A) - BEST PRACTICE: use parameters when possible - can be a parameter because it does not vary - 2nd arg is an INDEX in A → Set - must be an index, so it can be required to be equal to the first ------------------------------------------------------------------------------ -- EQUALITY is an EQUIVALENCE RELATION (reflexive, symmetric, transitive) reflexivity in the def of equality, via refl constructor -} -- symmetry sym : ∀ {A : Set} {x y : A} → x ≡ y -- arg has type x ≡ y ----- → y ≡ x sym refl -- LHS :instantiates arg to refl CONSTRUCTOR (only one possible) -- refl requires x y to be the same = refl -- RHS : need a term of type x ≡ x, so refl -- transitive trans : ∀ {A : Set} {x y z : A} → x ≡ y → y ≡ z ----- → x ≡ z trans refl refl = refl ------------------------------------------------------------------------------ -- EQUALITY SATISFIES CONGRUENCE -- if two terms are equal, they remain so after same function is applied to both cong : ∀ {A B : Set} (f : A → B) {x y : A} → x ≡ y --------- → f x ≡ f y cong f refl = refl -- where f takes two args cong₂ : ∀ {A B C : Set} (f : A → B → C) {u x : A} {v y : B} → u ≡ x → v ≡ y ------------- → f u v ≡ f x y cong₂ f refl refl = refl -- if two functions are equal, then applying them to same term yields equal terms cong-app : ∀ {A B : Set} {f g : A → B} → f ≡ g --------------------- → ∀ (x : A) → f x ≡ g x cong-app refl x = refl ------------------------------------------------------------------------------ -- EQUALITY SATISFIES SUBSTITUTION -- if two values are equal and a predicate holds of first then it also holds of second subst : ∀ {A : Set} {x y : A} (P : A → Set) → x ≡ y --------- → P x → P y subst P refl px = px ------------------------------------------------------------------------------ -- CHAINS OF EQUATIONS (aka EQUATIONAL REASONING) module ≡-Reasoning {A : Set} where infix 1 begin_ infixr 2 _≡⟨⟩_ _≡⟨_⟩_ infix 3 _∎ -- identity : this is just used to make proof look nice begin_ : ∀ {x y : A} → x ≡ y ----- → x ≡ y begin x≡y = x≡y -- think of _≡⟨⟩_ as equivalent to _≡⟨ refl ⟩_ _≡⟨⟩_ : ∀ (x : A) {y : A} → x ≡ y ----- → x ≡ y x ≡⟨⟩ x≡y = x≡y _≡⟨_⟩_ : ∀ (x : A) {y z : A} → x ≡ y → y ≡ z ----- → x ≡ z x ≡⟨ x≡y ⟩ y≡z = trans x≡y y≡z _∎ : ∀ (x : A) ----- → x ≡ x x ∎ = refl open ≡-Reasoning trans′ : ∀ {A : Set} {x y z : A} → x ≡ y → y ≡ z ----- → x ≡ z trans′ {A} {x} {y} {z} x≡y y≡z = begin -- Goal: x ≡ z ; y≡z : y ≡ z; x≡y : x ≡ y x ≡⟨ x≡y ⟩ -- Goal: y ≡ z y ≡⟨ y≡z ⟩ -- Goal: z ≡ z z ∎ {- EXERCISE trans and ≡-Reasoning (practice) TODO Cannot use definition of trans’ using ≡-Reasoning as the definition for trans. Why? Hint: look at the definition of _≡⟨_⟩_ -- Your code goes here ------------------------------------------------------------------------------ Chains of equations, another example : addition is commutative -} data ℕ : Set where zero : ℕ suc : ℕ → ℕ {-# BUILTIN NATURAL ℕ #-} _+_ : ℕ → ℕ → ℕ zero + n = n (suc m) + n = suc (m + n) infixl 6 _+_ -- to save space, postulate (rather than prove) two lemmas: -- POSTULATE : specifies a signature but no def. Use with care. DON'T postulate something false! postulate +-identity : ∀ (m : ℕ) → m + zero ≡ m +-suc : ∀ (m n : ℕ) → m + suc n ≡ suc (m + n) +-comm : ∀ (m n : ℕ) → m + n ≡ n + m +-comm m zero = begin m + zero ≡⟨ +-identity m ⟩ m ≡⟨⟩ zero + m ∎ +-comm m (suc n) = begin m + suc n ≡⟨ +-suc m n ⟩ suc (m + n) ≡⟨ cong suc (+-comm m n) ⟩ suc (n + m) ≡⟨⟩ -- terms are equivalent to simplified term suc n + m ∎ {- ------------------------------------------------------------------------------ Exercise ≤-Reasoning (stretch) redo proof of +-monoʳ-≤ (from Chapter Relations) using an analogue of ≡-Reasoning define ≤-Reasoning use it to write out proof that addition is monotonic with regard to inequality by redoing all of +-monoˡ-≤, +-monoʳ-≤, and +-mono-≤ -} module ≤-Reasoning {A : Set} where data _≤_ : ℕ → ℕ → Set where z≤n : ∀ {n : ℕ} -------- → zero ≤ n s≤s : ∀ {m n : ℕ} → m ≤ n ------------- → suc m ≤ suc n infix 4 _≤_ ≤-trans : ∀ {m n p : ℕ} → m ≤ n → n ≤ p → m ≤ p ≤-trans z≤n _ = z≤n ≤-trans (s≤s m≤n) (s≤s n≤p) = s≤s (≤-trans m≤n n≤p) infix 1 begin≤_ infixr 2 _≤⟨⟩_ _≤⟨_⟩_ infix 3 _∎≤ -------------------------------------------------- begin≤_ : ∀ {x y : ℕ} → x ≤ y ----- → x ≤ y begin≤ x≤y = x≤y -- can think of _≤⟨⟩_ as equivalent to _≤⟨ refl ⟩_ _≤⟨⟩_ : ∀ (x : ℕ) {y : ℕ} → x ≤ y ----- → x ≤ y x ≤⟨⟩ x≤y = x≤y _≤⟨_⟩_ : ∀ (x : ℕ) {y z : ℕ} → x ≤ y → y ≤ z ----- → x ≤ z x ≤⟨ x≤y ⟩ y≤z = ≤-trans x≤y y≤z _∎≤ : ∀ (x : ℕ) ----- → x ≤ x zero ∎≤ = z≤n suc x ∎≤ = s≤s (x ∎≤) -------------------------------------------------- +-monoʳ-≤ : ∀ (n p q : ℕ) → p ≤ q ------------- → (n + p) ≤ (n + q) +-monoʳ-≤ zero p q p≤q = begin≤ zero + p ≤⟨⟩ p ≤⟨ p≤q ⟩ q ≤⟨⟩ zero + q ∎≤ +-monoʳ-≤ (suc n) p q p≤q = begin≤ suc n + p ≤⟨ s≤s (+-monoʳ-≤ n p q p≤q) ⟩ suc n + q ∎≤ ------------------------- postulate +-comm-≤ : ∀ (m n : ℕ) → m + n ≤ n + m +-monoˡ-≤ : ∀ (m n p : ℕ) → m ≤ n ------------- → m + p ≤ n + p +-monoˡ-≤ m n p m≤n = begin≤ m + p ≤⟨ +-comm-≤ m p ⟩ p + m ≤⟨ +-monoʳ-≤ p m n m≤n ⟩ p + n ≤⟨ +-comm-≤ p n ⟩ n + p ∎≤ ------------------------- +-mono-≤ : ∀ (m n p q : ℕ) → m ≤ n → p ≤ q ------------- → m + p ≤ n + q +-mono-≤ m n p q m≤n p≤q = begin≤ m + p ≤⟨ +-monoˡ-≤ m n p m≤n ⟩ n + p ≤⟨ +-monoʳ-≤ n p q p≤q ⟩ n + q ∎≤ {- ------------------------------------------------------------------------------ -- Rewriting -} data even : ℕ → Set data odd : ℕ → Set data even where even-zero : even zero even-suc : ∀ {n : ℕ} → odd n ------------ → even (suc n) data odd where odd-suc : ∀ {n : ℕ} → even n ----------- → odd (suc n) {- given even (m + n) holds prove even (n + m) holds REWRITE: notation to support this kind of reasoning -} -- then use rewrite even-comm : ∀ (m n : ℕ) → even (m + n) ------------ → even (n + m) even-comm m n ev -- even (n + m) rewrite +-comm n m -- Goal: even (m + n); ev : even (m + n) = ev {- keyword REWRITE : followed by evidence of an equality That equality is used to rewrite the type of the goal and of any variable in scope. -} even-comm' : ∀ (m n : ℕ) → even (m + n) ------------ → even (n + m) even-comm' m n ev -- Goal: even (n + m) ; ev : even (m + n) rewrite +-comm m n -- Goal: even (n + m) ; ev : even (n + m) <-- rewrites evidence = ev -- ^ -- note: arg order diff than 'even-comm' above ------------------------------------------------------------------------------ -- Multiple rewrites : each separated by a vertical bar +-comm′ : ∀ (m n : ℕ) → m + n ≡ n + m +-comm′ zero n -- zero + n ≡ n + zero -- n ≡ n + zero rewrite +-identity n -- n ≡ n = refl +-comm′ (suc m) n -- suc m + n ≡ n + suc m -- suc (m + n) ≡ n + suc m rewrite +-suc n m -- suc (m + n) ≡ suc (n + m) <-- rewrites LHS | +-comm′ m n -- suc (n + m) ≡ suc (n + m) <-- rewrites RHS = refl {- Previous +-comm proof required cong suc (+-comm m n) (invoking inductive hypothesis). Rewriting automatically takes congruence into account. Proofs with rewriting are shorter. Proofs as chains of equalities are easier to follow. -} +-comm′' : ∀ (m n : ℕ) → m + n ≡ n + m +-comm′' zero n = begin zero + n ≡⟨⟩ n ≡⟨ +-comm′ zero n ⟩ n + zero ∎ +-comm′' (suc m) n = begin suc m + n ≡⟨ +-comm′ (suc m) n ⟩ n + suc m ∎ {- ------------------------------------------------------------------------------ --rewrite is shorthand for 'WITH' -} even-comm′ : ∀ (m n : ℕ) → even (m + n) ------------ → even (n + m) even-comm′ m n ev with m + n | +-comm m n ... | .(n + m) | refl = ev {- WITH : can be followed by one or more expressions, separated by bars - where each equation has the same number of patterns 1st COLUMN asserts m + n and n + m are identical 2nd COLUMN justifies assertion with evidence of the appropriate equality DOT PATTERN : .(n + m) - dot followed by an expression - used when other info forces value matched to be equal to value of expression in dot pattern Here: m + n ≡ n + m justified by matching +-comm m n with refl ------------------------------------------------------------------------------ -- using SUBSTITUTION instead of REWRITE -} even-comm″ : ∀ (m n : ℕ) → even (m + n) ------------ → even (n + m) even-comm″ m n -- m + n ≡ n + m -- v --= subst even {!!} --= subst {!!} (+-comm m n) -- ^ -- Constraints -- ?0 (n + m) =< even (n + m) -- even (m + n) =< ?0 (m + n) = subst even (+-comm m n) {- ------------------------------------------------------------------------------ -- Leibniz equality : TWO OBJECTS EQUAL IFF THEY SATISFY THE SAME PROPERTIES. The form of asserting equality so far is due to Martin Löf (1975). Another form is due to Leibniz (1686). Define Leibniz equality and show that two terms satisfy Leibniz equality IFF they satisfy Martin Löf equality. x ≐ y holds if every property P that holds of x also holds of y also ensures converse every property P that holds of y also holds of x Let x and y be objects of type A. x ≐ y holds if for every predicate P over type A we have that P x implies P y: -} _≐_ : ∀ {A : Set} (x y : A) → Set₁ _≐_ {A} x y = ∀ (P : A → Set) → P x → P y {- write _≐_ {A} x y (instead of infix) to provide access to the implicit parameter A FIRST USE OF LEVELS Cannot assign Set the type Set - would lead to contradictions such as Russell’s Paradox and Girard’s Paradox hierarchy of types, where Set : Set₁, Set₁ : Set₂, ... 'Set' is an abbreviation for 'Set₀' Since the equation defining _≐_ mentions Set on the right-hand side, the corresponding signature must use Set₁. ------------------------------------------------------------------------------ Leibniz equality is reflexive, transitive, symmetric -} -- reflexiviity follows by a variant of the identity function refl-≐ : ∀ {A : Set} {x : A} → x ≐ x refl-≐ P Px = Px -- transitivity follows by a variant of function composition trans-≐ : ∀ {A : Set} {x y z : A} → x ≐ y → y ≐ z ----- → x ≐ z trans-≐ x≐y y≐z P Px = y≐z P (x≐y P Px) -- show that if P x implies P y for all predicates P -- then P y implies P x sym-≐ : ∀ {A : Set} {x y : A} → x ≐ y -- given x ≐ y ----- → y ≐ x sym-≐ {A} {x} {y} x≐y P = Qy -- TODO : where is 'P' in the signature? where Q : A → Set -- instantiate the equality with a predicate Q such that Q z holds Q z = P z → P x -- if P z implies P x Qx : Q x -- The property Q x is by reflexivity, and hence Q y follows from x ≐ y. Qx = refl-≐ P Qy : Q y -- Q y is the required proof : P y implies P x Qy = x≐y Q Qx {- ------------------------------------------------------------------------------ Martin Löf equality implies Leibniz equality given x ≡ y need for any P to take evidence of P x to evidence of P y the equality of x and y implies that any proof of P x is also a proof of P y follows from substitution -} ≡-implies-≐ : ∀ {A : Set} {x y : A} → x ≡ y ----- → x ≐ y ≡-implies-≐ x≡y P = subst P x≡y {- ------------------------------------------------------------------------------ Leibniz equality implies Martin Löf equality given for any P we can take a proof of P x to a proof of P y show x ≡ y proof is similar to that for symmetry of Leibniz equality -} ≐-implies-≡ : ∀ {A : Set} {x y : A} → x ≐ y ----- → x ≡ y ≐-implies-≡ {A} {x} {y} x≐y = Qy where Q : A → Set -- Q is predicate that holds of z if x ≡ z Q z = x ≡ z Qx : Q x -- Q x by reflexivity of Martin Löf equality Qx = refl Qy : Q y -- Q y follows from x ≐ y Qy = x≐y Q Qx -- Q y is required proof : x ≡ y {- This section adapted from ≐≃≡: Leibniz Equality is Isomorphic to Martin-Löf Identity, Parametrically draft/2017 by Andreas Abel, Jesper Cockx, Dominique Devries, Andreas Nuyts, and Philip Wadler ------------------------------------------------------------------------------ UNIVERSE POLYMORPHISM (aka LEVELs) every type belongs somewhere in the hierarchy Set₀, Set₁, Set₂, ... Set abbreviates Set₀ Set₀ : Set₁ Set₁ : Set₂ ... to compare values of a type that belongs to Set ℓ for some arbitrary level ℓ? via UNIVERSE POLYMORPHISM definition is made with respect to an arbitrary level ℓ to use levels: -} open import Level using (Level; _⊔_) renaming (zero to lzero; suc to lsuc) {- rename constructors zero and suc to avoid confusion between levels and naturals Levels are isomorphic to natural numbers, and have similar constructors: lzero : Level lsuc : Level → Level Set₀, Set₁, Set₂, ... abbreviations for Set lzero Set (lsuc lzero) Set (lsuc (lsuc lzero)) _⊔_ : Level → Level → Level that given two levels returns the larger of the two. -} -- equality, generalised to an arbitrary level: data _≡′_ {ℓ : Level} {A : Set ℓ} (x : A) : A → Set ℓ where refl′ : x ≡′ x -- generalised definition of symmetry: sym′ : ∀ {ℓ : Level} {A : Set ℓ} {x y : A} → x ≡′ y ------ → y ≡′ x sym′ refl′ = refl′ {- For simplicity, this book avoids universe polymorphism. Most definitions in the standard library are generalised to arbitrary levels as above. -} -- generalised definition of Leibniz equality: _≐′_ : ∀ {ℓ : Level} {A : Set ℓ} (x y : A) → Set (lsuc ℓ) _≐′_ {ℓ} {A} x y = ∀ (P : A → Set ℓ) → P x → P y {- Before the signature used Set₁ as the type of a term that includes Set, whereas here the signature uses Set (lsuc ℓ) as the type of a term that includes Set ℓ. Most other functions in the standard library are also generalised to arbitrary levels. -} -- definition of composition. _∘_ : ∀ {ℓ₁ ℓ₂ ℓ₃ : Level} {A : Set ℓ₁} {B : Set ℓ₂} {C : Set ℓ₃} → (B → C) → (A → B) → A → C (g ∘ f) x = g (f x) {- ------------------------------------------------------------------------------ Standard library standard library defines _≡⟨_⟩_ as step-≡, which reverses the order of the arguments standard library defines a macro,imported when import step-≡ which recovers the original argument order: import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl; trans; sym; cong; cong-app; subst) open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; step-≡; _∎) ------------------------------------------------------------------------------ Unicode ≡ U+2261 IDENTICAL TO (\==, \equiv) ⟨ U+27E8 MATHEMATICAL LEFT ANGLE BRACKET (\<) ⟩ U+27E9 MATHEMATICAL RIGHT ANGLE BRACKET (\>) ∎ U+220E END OF PROOF (\qed) ≐ U+2250 APPROACHES THE LIMIT (\.=) ℓ U+2113 SCRIPT SMALL L (\ell) ⊔ U+2294 SQUARE CUP (\lub) ₀ U+2080 SUBSCRIPT ZERO (\_0) ₁ U+2081 SUBSCRIPT ONE (\_1) ₂ U+2082 SUBSCRIPT TWO (\_2) -}
{ "alphanum_fraction": 0.4861833953, "avg_line_length": 24.7926267281, "ext": "agda", "hexsha": "9578edfd598bf78818bab8922dfcb6fe2488fa12", "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/x04equality.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/x04equality.agda", "max_line_length": 96, "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/x04equality.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": 5461, "size": 16140 }
module List where data List (a : Set) : Set where nil : List a _::_ : a -> List a -> List a nil2 : (\x -> x) ({a : Set} -> List a) nil2 = nil {_} tt : Set1 -> Set2 tt _ = Set1 map : {a b : Set} -> (a -> b) -> List a -> List b map f nil = nil map f (x :: xs) = f x :: map f xs
{ "alphanum_fraction": 0.4519230769, "avg_line_length": 18.3529411765, "ext": "agda", "hexsha": "516ebe51c7c83dc0eacf0cfafb8b1bdb62230b58", "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/List.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/List.agda", "max_line_length": 51, "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/List.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": 123, "size": 312 }
module Issue892a where record R : Set₁ where field f : Set g : Set g = f -- The type of R.g should print as (r : R) → Set -- rather than ( : R) → Set. bad : R.g bad = ?
{ "alphanum_fraction": 0.5698324022, "avg_line_length": 12.7857142857, "ext": "agda", "hexsha": "5cc7812e246ff434061a77266db7cc91d0fb4c3f", "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/Issue892a.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/Issue892a.agda", "max_line_length": 48, "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/Issue892a.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": 65, "size": 179 }
{-# OPTIONS --exact-split #-} module Thesis.SIRelBigStep.DOpSem where open import Data.Nat open import Relation.Nullary open import Relation.Binary.PropositionalEquality open import Thesis.SIRelBigStep.DLangDerive public open import Thesis.SIRelBigStep.OpSem public open import Thesis.SIRelBigStep.DSyntax public data DVal : Type → Set import Base.Denotation.Environment module D = Base.Denotation.Environment DType DVal ChΔ : ∀ (Δ : Context) → Set ChΔ Δ = D.⟦ Δ ⟧Context data DVal where bang : ∀ {τ} → Val τ → DVal τ dclosure : ∀ {Γ σ τ} → (dt : DTerm (σ • Γ) τ) → (ρ : ⟦ Γ ⟧Context) → (dρ : ChΔ Γ) → DVal (σ ⇒ τ) dnatV : ∀ (n : ℕ) → DVal nat dpairV : ∀ {σ τ} → DVal σ → DVal τ → DVal (pair σ τ) _⊕_ : ∀ {τ} → (v1 : Val τ) (dv : DVal τ) → Val τ _⊕ρ_ : ∀ {Γ} → ⟦ Γ ⟧Context → ChΔ Γ → ⟦ Γ ⟧Context ∅ ⊕ρ ∅ = ∅ (v • ρ1) ⊕ρ (dv • dρ) = v ⊕ dv • ρ1 ⊕ρ dρ v1 ⊕ bang v2 = v2 closure {Γ} t ρ ⊕ dclosure {Γ1} dt ρ₁ dρ with Γ ≟Ctx Γ1 closure {Γ} t ρ ⊕ dclosure {.Γ} dt ρ₁ dρ | yes refl = closure t (ρ ⊕ρ dρ) ... | no ¬p = closure t ρ natV n ⊕ dnatV dn = natV (n + dn) pairV v1 v2 ⊕ dpairV dv1 dv2 = pairV (v1 ⊕ dv1) (v2 ⊕ dv2) inv-Δτ-nat : ∀ τ → Δτ τ ≡ nat → τ ≡ nat inv-Δτ-nat nat refl = refl inv-Δτ-nat (τ ⇒ τ₁) () inv-Δτ-nat (pair τ τ₁) () deval-const : ∀ {τ} → Const (Δτ τ) → DVal τ deval-const {σ} c with Δτ σ | inv-Δτ-nat σ deval-const {σ} (lit n) | .nat | inv-σ with inv-σ refl deval-const {.nat} (lit n) | .nat | inv-σ | refl = dnatV n deval : ∀ {Γ τ} (sv : DSVal Γ τ) (ρ : ⟦ Γ ⟧Context) (dρ : ChΔ Γ) → DVal τ deval (dvar x) ρ dρ = D.⟦ x ⟧Var dρ deval (dabs dt) ρ dρ = dclosure dt ρ dρ deval (dcons dsv1 dsv2) ρ dρ = dpairV (deval dsv1 ρ dρ) (deval dsv2 ρ dρ) deval (dconst c) ρ dρ = deval-const c deval-primitive : ∀ {σ τ} → Primitive (σ ⇒ τ) → Val σ → DVal σ → DVal τ deval-primitive succ (natV _) (bang (natV n2)) = bang (natV (suc n2)) deval-primitive succ (natV n) (dnatV dn) = dnatV dn deval-primitive add (pairV _ _) (dpairV (dnatV da) (dnatV db)) = dnatV (da + db) deval-primitive add (pairV _ _) (bang p2) = bang (eval-primitive add p2) -- During the proof we need to know which clauses hold definitionally, and sadly we can't get a single equation here. deval-primitive add p1 @ (pairV a1 b1) dp @ (dpairV (dnatV da) (bang b2)) = bang (eval-primitive add (p1 ⊕ dp)) deval-primitive add p1 @ (pairV a1 b1) dp @ (dpairV (bang a2) db) = bang (eval-primitive add (p1 ⊕ dp)) deval-derive-const-inv : ∀ {τ Γ} (c : Const τ) (ρ : ⟦ Γ ⟧Context) dρ → deval (derive-const c) ρ dρ ≡ deval (derive-const c) ∅ ∅ deval-derive-const-inv (lit n) ρ dρ = refl data _D_⊢_↓_ {Γ} (ρ : ⟦ Γ ⟧Context) (dρ : ChΔ Γ) : ∀ {τ} → DTerm Γ τ → DVal τ → Set where dval : ∀ {τ} (sv : DSVal Γ τ) → ρ D dρ ⊢ dval sv ↓ deval sv ρ dρ dprimapp : ∀ {σ τ} (p : Primitive (σ ⇒ τ)) (sv : SVal Γ σ) dsv → ρ D dρ ⊢ dprimapp p sv dsv ↓ deval-primitive p (eval sv ρ) (deval dsv ρ dρ) dapp : ∀ {hasIdx} {n : Idx hasIdx} {Γ′ σ τ ρ′ dρ′} {dvs} {vt} {dvt} {vtv} {dvtv} {dt : DTerm (σ • Γ′) τ} {dv} → ρ D dρ ⊢ dval dvs ↓ dclosure dt ρ′ dρ′ → ρ ⊢ val vt ↓[ n ] vtv → ρ D dρ ⊢ dval dvt ↓ dvtv → (vtv • ρ′) D (dvtv • dρ′) ⊢ dt ↓ dv → ρ D dρ ⊢ dapp dvs vt dvt ↓ dv dlett : ∀ {hasIdx} {n : Idx hasIdx} {σ τ} {s : Term Γ σ} {ds} {dt : DTerm (σ • Γ) τ} {vsv dvsv dv} → ρ ⊢ s ↓[ n ] vsv → ρ D dρ ⊢ ds ↓ dvsv → (vsv • ρ) D (dvsv • dρ) ⊢ dt ↓ dv → ρ D dρ ⊢ dlett s ds dt ↓ dv bangapp : ∀ {hasIdx1 hasIdx2} {n1 : Idx hasIdx1} {n2 : Idx hasIdx2} {Γ′ σ τ ρ′} {dvs} {vt} {dvt} {vtv1 dvtv} {t : Term (σ • Γ′) τ} {v2} → ρ D dρ ⊢ dval dvs ↓ bang (closure t ρ′) → ρ ⊢ val vt ↓[ n1 ] vtv1 → ρ D dρ ⊢ dval dvt ↓ dvtv → (vtv1 ⊕ dvtv • ρ′) ⊢ t ↓[ n2 ] v2 → ρ D dρ ⊢ dapp dvs vt dvt ↓ bang v2
{ "alphanum_fraction": 0.5775656325, "avg_line_length": 37.71, "ext": "agda", "hexsha": "ff191437ed4ee05c3d03ffd8ab8930c935d916e4", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "inc-lc/ilc-agda", "max_forks_repo_path": "Thesis/SIRelBigStep/DOpSem.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z", "max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "inc-lc/ilc-agda", "max_issues_repo_path": "Thesis/SIRelBigStep/DOpSem.agda", "max_line_length": 127, "max_stars_count": 10, "max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "inc-lc/ilc-agda", "max_stars_repo_path": "Thesis/SIRelBigStep/DOpSem.agda", "max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z", "num_tokens": 1765, "size": 3771 }
{-# OPTIONS --cubical --safe #-} module Cubical.Foundations.FunExtEquiv where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Univalence -- Function extensionality is an equivalence. module _ {ℓ ℓ'} {A : Type ℓ} {B : A → Type ℓ'} {f g : (x : A) → B x} where private appl : f ≡ g → ∀ x → f x ≡ g x appl eq x i = eq i x fib : (p : f ≡ g) → fiber (funExt {B = B}) p fib p = (appl p , refl) funExt-fiber-isContr : (p : f ≡ g) → (fi : fiber (funExt {B = B}) p) → fib p ≡ fi funExt-fiber-isContr p (h , eq) i = (appl (eq (~ i)) , λ j → eq (~ i ∨ j)) funExt-isEquiv : isEquiv (funExt {B = B}) equiv-proof funExt-isEquiv p = (fib p , funExt-fiber-isContr p) funExtEquiv : (∀ x → f x ≡ g x) ≃ (f ≡ g) funExtEquiv = (funExt {B = B} , funExt-isEquiv) funExtPath : (∀ x → f x ≡ g x) ≡ (f ≡ g) funExtPath = ua funExtEquiv
{ "alphanum_fraction": 0.5884773663, "avg_line_length": 28.5882352941, "ext": "agda", "hexsha": "09312da1b72274dbbc6f32e266fbe540f2643a6b", "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": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cj-xu/cubical", "max_forks_repo_path": "Cubical/Foundations/FunExtEquiv.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "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": "cj-xu/cubical", "max_issues_repo_path": "Cubical/Foundations/FunExtEquiv.agda", "max_line_length": 78, "max_stars_count": null, "max_stars_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cj-xu/cubical", "max_stars_repo_path": "Cubical/Foundations/FunExtEquiv.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 368, "size": 972 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Sums (disjoint unions) ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Sum where open import Function open import Data.Unit.Base using (⊤; tt) open import Data.Maybe.Base using (Maybe; just; nothing) open import Level open import Agda.Builtin.Equality ------------------------------------------------------------------------ -- Re-export content from base module open import Data.Sum.Base public ------------------------------------------------------------------------ -- Additional functions module _ {a b} {A : Set a} {B : Set b} where isInj₁ : A ⊎ B → Maybe A isInj₁ (inj₁ x) = just x isInj₁ (inj₂ y) = nothing isInj₂ : A ⊎ B → Maybe B isInj₂ (inj₁ x) = nothing isInj₂ (inj₂ y) = just y From-inj₁ : A ⊎ B → Set a From-inj₁ (inj₁ _) = A From-inj₁ (inj₂ _) = Lift a ⊤ from-inj₁ : (x : A ⊎ B) → From-inj₁ x from-inj₁ (inj₁ x) = x from-inj₁ (inj₂ _) = _ From-inj₂ : A ⊎ B → Set b From-inj₂ (inj₁ _) = Lift b ⊤ From-inj₂ (inj₂ _) = B from-inj₂ : (x : A ⊎ B) → From-inj₂ x from-inj₂ (inj₁ _) = _ from-inj₂ (inj₂ x) = x
{ "alphanum_fraction": 0.4779116466, "avg_line_length": 24.9, "ext": "agda", "hexsha": "643939df93d17f7125530bcf74ee43ad13228b9b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Sum.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Sum.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Sum.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 379, "size": 1245 }
open import Agda.Primitive open import Data.List -- f1 : {l : Level} -> (a : Set l) -> (x : a) -> (y : x) -> x -- f1 : (a : Set2) -> (x : a) -> (y : x) -> x -- f1 a x y = ? f0 : (a : Set) -> (x : a) -> a f0 a x = x f1 : (a : Set1) -> (x : a) -> a f1 a x = x myprod : (As : List Set) -> Set myprod = {!!} mysum : (As : List Set) -> Set mysum = {!!} hej : (tyOp : List Set -> Set) -> Set hej = {!!} test1 = hej myprod test2 = hej mysum Type = Set data Dummy : Set where Dum : Dummy -- Start of example hej2 : List Type -> Type -- Is universe-monomorphic in Agda, but polymorphic in Idris hej2 (t ∷ ts) = t hej2 _ = ? test21 : Type test21 = hej2 [ Type ] -- test21 == Type in Idris, but Agda complains test22 : Type test22 = hej2 [ Dummy ] -- test22 == Dummy
{ "alphanum_fraction": 0.5380645161, "avg_line_length": 19.375, "ext": "agda", "hexsha": "4a50f51267200cd912fedd98b875686e7cc7c648", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-11-27T16:25:18.000Z", "max_forks_repo_forks_event_min_datetime": "2019-11-27T16:25:18.000Z", "max_forks_repo_head_hexsha": "a5f65e28cc9fdfefde49e7d8cf84486601b9e7b1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hjorthjort/IdrisToAgda", "max_forks_repo_path": "univ.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "a5f65e28cc9fdfefde49e7d8cf84486601b9e7b1", "max_issues_repo_issues_event_max_datetime": "2019-11-28T17:52:42.000Z", "max_issues_repo_issues_event_min_datetime": "2019-11-28T17:52:42.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hjorthjort/IdrisToAgda", "max_issues_repo_path": "univ.agda", "max_line_length": 89, "max_stars_count": 2, "max_stars_repo_head_hexsha": "a5f65e28cc9fdfefde49e7d8cf84486601b9e7b1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hjorthjort/IdrisToAgda", "max_stars_repo_path": "univ.agda", "max_stars_repo_stars_event_max_datetime": "2020-06-29T20:42:43.000Z", "max_stars_repo_stars_event_min_datetime": "2020-02-16T23:22:50.000Z", "num_tokens": 309, "size": 775 }
{-# OPTIONS --allow-unsolved-metas #-} open import Relation.Binary.PropositionalEquality hiding ( [_] ) open import Relation.Nullary using (¬_; Dec; yes; no) open import Data.List hiding ( [_] ) open import finiteSet module derive ( Σ : Set) ( fin : FiniteSet Σ ) ( eq? : (x y : Σ) → Dec (x ≡ y)) where -- open import nfa open import Data.Nat -- open import Data.Nat hiding ( _<_ ; _>_ ) -- open import Data.Fin hiding ( _<_ ) open import finiteSetUtil open import automaton open import logic open import regex open FiniteSet -- whether a regex accepts empty input -- empty? : Regex Σ → Bool empty? ε = true empty? φ = false empty? (x *) = true empty? (x & y) = empty? x /\ empty? y empty? (x || y) = empty? x \/ empty? y empty? < x > = false derivative : Regex Σ → Σ → Regex Σ derivative ε s = φ derivative φ s = φ derivative (x *) s with derivative x s ... | ε = x * ... | φ = φ ... | t = t & (x *) derivative (x & y) s with empty? x ... | true with derivative x s | derivative y s ... | ε | φ = φ ... | ε | t = y || t ... | φ | t = t ... | x1 | φ = x1 & y ... | x1 | y1 = (x1 & y) || y1 derivative (x & y) s | false with derivative x s ... | ε = y ... | φ = φ ... | t = t & y derivative (x || y) s with derivative x s | derivative y s ... | φ | y1 = y1 ... | x1 | φ = x1 ... | x1 | y1 = x1 || y1 derivative < x > s with eq? x s ... | yes _ = ε ... | no _ = φ data regex-states (x : Regex Σ ) : Regex Σ → Set where unit : regex-states x x derive : { y : Regex Σ } → regex-states x y → (s : Σ) → regex-states x ( derivative y s ) record Derivative (x : Regex Σ ) : Set where field state : Regex Σ is-derived : regex-states x state open Derivative open import Data.Fin hiding (_<_) -- derivative generates (x & y) || ... form. y and x part is a substerm of original regex -- since subterm is finite, only finite number of state is generated for each operator -- this does not work, becuase it depends on input sequences -- finite-derivative : (r : Regex Σ) → FiniteSet Σ → FiniteSet (Derivative r) -- order : Regex Σ → ℕ -- decline-derive : (x : Regex Σ ) (i : Σ ) → 0 < order x → order (derivative x i) < order x -- is not so easy -- in case of automaton, number of derivative is limited by iteration of input length, so it is finite. -- so we cannot say derived automaton is finite i.e. regex-match is regular language now regex→automaton : (r : Regex Σ) → Automaton (Derivative r) Σ regex→automaton r = record { δ = λ d s → record { state = derivative (state d) s ; is-derived = derive-step d s} ; aend = λ d → empty? (state d) } where derive-step : (d0 : Derivative r) → (s : Σ) → regex-states r (derivative (state d0) s) derive-step d0 s = derive (is-derived d0) s regex-match : (r : Regex Σ) → (List Σ) → Bool regex-match ex is = accept ( regex→automaton ex ) record { state = ex ; is-derived = unit } is open import Relation.Binary.Definitions cmp-regex : (x y : Regex Σ) → Dec ( x ≡ y ) cmp-regex ε ε = yes refl cmp-regex ε φ = no (λ ()) cmp-regex ε (y *) = no (λ ()) cmp-regex ε (y & y₁) = no (λ ()) cmp-regex ε (y || y₁) = no (λ ()) cmp-regex ε < x > = no (λ ()) cmp-regex φ ε = no (λ ()) cmp-regex φ φ = yes refl cmp-regex φ (y *) = no (λ ()) cmp-regex φ (y & y₁) = no (λ ()) cmp-regex φ (y || y₁) = no (λ ()) cmp-regex φ < x > = no (λ ()) cmp-regex (x *) ε = no (λ ()) cmp-regex (x *) φ = no (λ ()) cmp-regex (x *) (y *) with cmp-regex x y ... | yes refl = yes refl ... | no ne = no (λ x → ne (cmp1 x)) where cmp1 : (x *) ≡ (y *) → x ≡ y cmp1 refl = refl cmp-regex (x *) (y & y₁) = no (λ ()) cmp-regex (x *) (y || y₁) = no (λ ()) cmp-regex (x *) < x₁ > = no (λ ()) cmp-regex (x & x₁) ε = no (λ ()) cmp-regex (x & x₁) φ = no (λ ()) cmp-regex (x & x₁) (y *) = no (λ ()) cmp-regex (x & x₁) (y & y₁) with cmp-regex x y | cmp-regex x₁ y₁ ... | yes refl | yes refl = yes refl ... | no ne | _ = no (λ x → ne (cmp1 x)) where cmp1 : x & x₁ ≡ y & y₁ → x ≡ y cmp1 refl = refl ... | _ | no ne = no (λ x → ne (cmp1 x)) where cmp1 : x & x₁ ≡ y & y₁ → x₁ ≡ y₁ cmp1 refl = refl cmp-regex (x & x₁) (y || y₁) = no (λ ()) cmp-regex (x & x₁) < x₂ > = no (λ ()) cmp-regex (x || x₁) ε = no (λ ()) cmp-regex (x || x₁) φ = no (λ ()) cmp-regex (x || x₁) (y *) = no (λ ()) cmp-regex (x || x₁) (y & y₁) = no (λ ()) cmp-regex (x || x₁) (y || y₁) with cmp-regex x y | cmp-regex x₁ y₁ ... | yes refl | yes refl = yes refl ... | no ne | _ = no (λ x → ne (cmp1 x)) where cmp1 : x || x₁ ≡ y || y₁ → x ≡ y cmp1 refl = refl ... | _ | no ne = no (λ x → ne (cmp1 x)) where cmp1 : x || x₁ ≡ y || y₁ → x₁ ≡ y₁ cmp1 refl = refl cmp-regex (x || x₁) < x₂ > = no (λ ()) cmp-regex < x > ε = no (λ ()) cmp-regex < x > φ = no (λ ()) cmp-regex < x > (y *) = no (λ ()) cmp-regex < x > (y & y₁) = no (λ ()) cmp-regex < x > (y || y₁) = no (λ ()) cmp-regex < x > < x₁ > with equal? fin x x₁ | inspect ( equal? fin x ) x₁ ... | false | record { eq = eq } = no (λ x → ¬-bool eq (cmp1 x)) where cmp1 : < x > ≡ < x₁ > → equal? fin x x₁ ≡ true cmp1 refl = equal?-refl fin ... | true | record { eq = eq } with equal→refl fin eq ... | refl = yes refl insert : List (Regex Σ) → (Regex Σ) → List (Regex Σ) insert [] k = k ∷ [] insert (x ∷ t) k with cmp-regex k x ... | no n = x ∷ (insert t k) ... | yes y = x ∷ t regex-derive : List (Regex Σ) → List (Regex Σ) regex-derive t = regex-derive0 t t where regex-derive1 : Regex Σ → List Σ → List (Regex Σ) → List (Regex Σ) regex-derive1 x [] t = t regex-derive1 x (i ∷ t) r = regex-derive1 x t (insert r (derivative x i)) regex-derive0 : List (Regex Σ) → List (Regex Σ) → List (Regex Σ) regex-derive0 [] t = t regex-derive0 (x ∷ r) t = regex-derive0 r (regex-derive1 x (to-list fin (λ _ → true)) t) -- -- if (Derivative r is finite, regex→automaton is finite -- drive-is-finite : (r : Regex Σ) → FiniteSet (Derivative r) drive-is-finite ε = {!!} drive-is-finite φ = {!!} drive-is-finite (r *) = {!!} where d1 : FiniteSet (Derivative r ) d1 = drive-is-finite r drive-is-finite (r & r₁) = {!!} drive-is-finite (r || r₁) = {!!} drive-is-finite < x > = {!!}
{ "alphanum_fraction": 0.5567127746, "avg_line_length": 34.5224719101, "ext": "agda", "hexsha": "2bcd51eb76f2c333eaa3b7a17139d84e1571f7e1", "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": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "shinji-kono/automaton-in-agda", "max_forks_repo_path": "src/derive.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "shinji-kono/automaton-in-agda", "max_issues_repo_path": "src/derive.agda", "max_line_length": 153, "max_stars_count": null, "max_stars_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "shinji-kono/automaton-in-agda", "max_stars_repo_path": "src/derive.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2285, "size": 6145 }
-- Insertion sort {-# OPTIONS --without-K --safe #-} module Algorithms.List.Sort.Insertion where -- agda-stdlib open import Data.Bool hiding (_≤_; _≤?_; _<_) open import Data.List import Data.Nat as ℕ open import Relation.Binary as B open import Relation.Binary.PropositionalEquality using (_≡_; refl) open import Relation.Nullary module InsertionSortOperation {a r} {A : Set a} {_≤_ : Rel A r} (_≤?_ : B.Decidable _≤_) where -- swap : A x A → A × A -- swap ∘ swap ≡ id -- ifTrueSwap : Bool → A × A → A × A -- ifTrueSwap x ∘ ifTrueSwap y ≡ ifTrueSwap (xor x y) -- x : A → A ≡ Unit ⊎ (Σ A (λ y → x ≢ y)) insert : A → List A → List A insert x [] = [ x ] insert x (y ∷ ys) with x ≤? y ... | true because _ = x ∷ y ∷ ys ... | false because _ = y ∷ insert x ys -- | Insertion sort sort : List A → List A sort = foldr insert [] private open InsertionSortOperation ℕ._≤?_ _ : sort (5 ∷ 2 ∷ 4 ∷ 3 ∷ 1 ∷ []) ≡ 1 ∷ 2 ∷ 3 ∷ 4 ∷ 5 ∷ [] _ = refl
{ "alphanum_fraction": 0.587398374, "avg_line_length": 24.6, "ext": "agda", "hexsha": "55b6a9180bea484da03551adf5e26fd19a8103a8", "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": "Algorithms/List/Sort/Insertion.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": "Algorithms/List/Sort/Insertion.agda", "max_line_length": 67, "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": "Algorithms/List/Sort/Insertion.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": 363, "size": 984 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Instance.Sets where -- Category of (Agda) Sets, aka (types, functions, pointwise equality with implicit value) -- Note the (explicit) levels in each open import Level open import Relation.Binary open import Function using (_∘′_) renaming (id to idf) open import Relation.Binary.PropositionalEquality as ≡ using (_≡_) open import Categories.Category Sets : ∀ o → Category (suc o) o o Sets o = record { Obj = Set o ; _⇒_ = λ c d → c → d ; _≈_ = λ f g → ∀ {x} → f x ≡ g x ; id = idf ; _∘_ = _∘′_ ; assoc = ≡.refl ; sym-assoc = ≡.refl ; identityˡ = ≡.refl ; identityʳ = ≡.refl ; identity² = ≡.refl ; equiv = record { refl = ≡.refl ; sym = λ eq → ≡.sym eq ; trans = λ eq₁ eq₂ → ≡.trans eq₁ eq₂ } ; ∘-resp-≈ = resp } where resp : ∀ {A B C : Set o} {f h : B → C} {g i : A → B} → ({x : B} → f x ≡ h x) → ({x : A} → g x ≡ i x) → {x : A} → f (g x) ≡ h (i x) resp {h = h} eq₁ eq₂ = ≡.trans eq₁ (≡.cong h eq₂)
{ "alphanum_fraction": 0.5242451967, "avg_line_length": 29.5405405405, "ext": "agda", "hexsha": "af24c7aca5e619016fbbebb06eedf0344b517680", "lang": "Agda", "max_forks_count": 64, "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Category/Instance/Sets.agda", "max_issues_count": 236, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Category/Instance/Sets.agda", "max_line_length": 90, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Category/Instance/Sets.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "num_tokens": 418, "size": 1093 }
{-# OPTIONS --cubical --safe --postfix-projections #-} open import Prelude open import Relation.Binary module Data.RBTree {e} {E : Type e} {r₁ r₂} (totalOrder : TotalOrder E r₁ r₂) where open import Relation.Binary.Construct.Bounded totalOrder open TotalOrder totalOrder using (_≤?_) data Colour : Type where red black : Colour add-black : Colour → ℕ → ℕ add-black red = λ n → n add-black black = suc private variable n : ℕ data Tree (lb ub : [∙]) : ℕ → Type (e ℓ⊔ r₂) where leaf : lb [≤] ub → Tree lb ub n node : (x : E) → (c : Colour) → Tree lb [ x ] n → Tree [ x ] ub n → Tree lb ub (add-black c n) private variable lb ub : [∙] IsBlack : Tree lb ub n → Type IsBlack (leaf x) = ⊤ IsBlack (node x red tr tr₁) = ⊥ IsBlack (node x black tr tr₁) = ⊤ Valid-rec : Tree lb ub n → Type Valid-rec (leaf x) = ⊤ Valid-rec (node x red xs ys) = IsBlack xs × IsBlack ys × Valid-rec xs × Valid-rec ys Valid-rec (node x black xs ys) = Valid-rec xs × Valid-rec ys Valid : Tree lb ub n → Type Valid tr = IsBlack tr × Valid-rec tr -- insertWithin : (x : E) → -- (lb [≤] [ x ]) → -- ([ x ] [≤] ub) → -- (tr : Tree lb ub n) → -- Valid-rec tr → -- ∃ c Σ (Tree lb ub (add-black c n)) Valid-rec -- insertWithin x lb≤x x≤ub (leaf _) val = red , node x red (leaf lb≤x) (leaf x≤ub) , tt , tt , tt , tt -- insertWithin x lb≤x x≤ub (node y c ls rs) val with x ≤? y -- insertWithin x lb≤x x≤ub (node y red ls rs) val | inl x≤y with insertWithin x lb≤x x≤y ls (fst (snd (snd val))) -- insertWithin x lb≤x x≤ub (node y red ls rs) val | inl x≤y | red , ls′ , val′ = black , node y black ls′ rs , val′ , snd (snd (snd val)) -- insertWithin x lb≤x x≤ub (node y red ls rs) val | inl x≤y | black , ls′ , val′ = {!{!!} , node y {!!} ls′ rs , {!!}!} -- insertWithin x lb≤x x≤ub (node y black ls rs) val | inl x≤y with insertWithin x lb≤x x≤y ls (fst val) -- insertWithin x lb≤x x≤ub (node y black ls rs) val | inl x≤y | res = {!!} -- insertWithin x lb≤x x≤ub (node y c ls rs) val | inr y≤x = {!!} -- -- insertWithin x lb≤x x≤ub (node y ls rs) with x ≤? y -- -- insertWithin x lb≤x x≤ub (node y ls rs) | inl x≤y = node y (insertWithin x lb≤x x≤y ls) rs -- -- insertWithin x lb≤x x≤ub (node y ls rs) | inr y≤x = node y ls (insertWithin x y≤x x≤ub rs)
{ "alphanum_fraction": 0.582761578, "avg_line_length": 37.0158730159, "ext": "agda", "hexsha": "738c5289fdd242c32bb63899de746e726e5631e1", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_path": "Data/RBTree.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_path": "Data/RBTree.agda", "max_line_length": 143, "max_stars_count": 6, "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_path": "Data/RBTree.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "num_tokens": 878, "size": 2332 }
{-# OPTIONS --safe #-} module Cubical.Algebra.CommRing.Instances.Polynomials.UnivariatePolyList where open import Cubical.Foundations.Prelude open import Cubical.Data.Nat using (ℕ ; zero ; suc) open import Cubical.Algebra.CommRing open import Cubical.Algebra.Polynomials.UnivariateList.Base open import Cubical.Algebra.Polynomials.UnivariateList.Properties private variable ℓ : Level open CommRingStr module _ (R : CommRing ℓ) where open PolyMod R open PolyModTheory R UnivariatePolyList : CommRing ℓ fst UnivariatePolyList = Poly R 0r (snd UnivariatePolyList) = 0P 1r (snd UnivariatePolyList) = 1P _+_ (snd UnivariatePolyList) = _Poly+_ _·_ (snd UnivariatePolyList) = _Poly*_ - snd UnivariatePolyList = Poly- isCommRing (snd UnivariatePolyList) = makeIsCommRing isSetPoly Poly+Assoc Poly+Rid Poly+Inverses Poly+Comm Poly*Associative Poly*Rid Poly*LDistrPoly+ Poly*Commutative nUnivariatePolyList : (A' : CommRing ℓ) → (n : ℕ) → CommRing ℓ nUnivariatePolyList A' zero = A' nUnivariatePolyList A' (suc n) = UnivariatePolyList (nUnivariatePolyList A' n)
{ "alphanum_fraction": 0.725, "avg_line_length": 30.5263157895, "ext": "agda", "hexsha": "8c9baf9506c0e69c4f48129daaa17abd3063c038", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/Algebra/CommRing/Instances/Polynomials/UnivariatePolyList.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/Algebra/CommRing/Instances/Polynomials/UnivariatePolyList.agda", "max_line_length": 95, "max_stars_count": null, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/Algebra/CommRing/Instances/Polynomials/UnivariatePolyList.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 343, "size": 1160 }
module SizedPolyIO.IOObject where open import Data.Product open import Level using (_⊔_) renaming (suc to lsuc) open import Size open import SizedPolyIO.Base open import SizedPolyIO.Object -- An IO object is like a simple object, -- but the method returns IO applied to the result type of a simple object -- which means the method returns an IO program which when terminating -- returns the result of the simple object module _ {γ ρ} (ioi : IOInterface γ ρ) (let C = Command ioi) (let R = Response ioi) {μ σ} (oi : Interface μ σ) (let M = Method oi) (let Rt = Result oi) where record IOObject (i : Size) : Set (ρ ⊔ γ ⊔ μ ⊔ σ) where coinductive field method : ∀{j : Size< i} (m : M) → IO ioi ∞ (Rt m × IOObject j) open IOObject public
{ "alphanum_fraction": 0.6700507614, "avg_line_length": 29.1851851852, "ext": "agda", "hexsha": "bfe4681ab4c8895ce800e4600f1a184b7c651bf7", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z", "max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/ooAgda", "max_forks_repo_path": "src/SizedPolyIO/IOObject.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/ooAgda", "max_issues_repo_path": "src/SizedPolyIO/IOObject.agda", "max_line_length": 91, "max_stars_count": 23, "max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/ooAgda", "max_stars_repo_path": "src/SizedPolyIO/IOObject.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z", "num_tokens": 240, "size": 788 }
module Relator.Category where open import Data open import Data.Tuple import Lvl open import Structure.Categorical.Properties open import Structure.Category open import Structure.Operator open import Type private variable ℓ : Lvl.Level
{ "alphanum_fraction": 0.8230452675, "avg_line_length": 20.25, "ext": "agda", "hexsha": "f37d788119a901db64f7a0e2f62e7c183021e557", "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": "Relator/Category.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Relator/Category.agda", "max_line_length": 44, "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": "Relator/Category.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 51, "size": 243 }
module Prelude.IO where open import Prelude.Function open import Prelude.Functor open import Prelude.Applicative open import Prelude.Monad open import Prelude.List open import Prelude.String open import Prelude.Char open import Prelude.Unit open import Prelude.Show open import Prelude.Nat open import Agda.Builtin.IO public postulate ioReturn : ∀ {a} {A : Set a} → A → IO A ioBind : ∀ {a b} {A : Set a} {B : Set b} → IO A → (A → IO B) → IO B {-# COMPILE GHC ioReturn = (\ _ _ -> return) #-} {-# COMPILE GHC ioBind = (\ _ _ _ _ -> (>>=)) #-} {-# COMPILE UHC ioReturn = (\ _ _ x -> UHC.Agda.Builtins.primReturn x) #-} {-# COMPILE UHC ioBind = (\ _ _ _ _ x y -> UHC.Agda.Builtins.primBind x y) #-} ioMap : ∀ {a b} {A : Set a} {B : Set b} → (A → B) → IO A → IO B ioMap f m = ioBind m λ x → ioReturn (f x) instance FunctorIO : ∀ {a} → Functor {a} IO fmap {{FunctorIO}} = ioMap ApplicativeIO : ∀ {a} → Applicative {a} IO pure {{ApplicativeIO}} = ioReturn _<*>_ {{ApplicativeIO}} = monadAp ioBind MonadIO : ∀ {a} → Monad {a} IO _>>=_ {{MonadIO}} = ioBind FunctorIO′ : ∀ {a b} → Functor′ {a} {b} IO fmap′ {{FunctorIO′}} = ioMap ApplicativeIO′ : ∀ {a b} → Applicative′ {a} {b} IO _<*>′_ {{ApplicativeIO′}} = monadAp′ ioBind MonadIO′ : ∀ {a b} → Monad′ {a} {b} IO _>>=′_ {{MonadIO′}} = ioBind --- Terminal IO --- postulate getChar : IO Char putChar : Char → IO Unit putStr : String → IO Unit putStrLn : String → IO Unit {-# FOREIGN GHC import qualified Data.Text as Text #-} {-# FOREIGN GHC import qualified Data.Text.IO as Text #-} {-# COMPILE GHC getChar = getChar #-} {-# COMPILE GHC putChar = putChar #-} {-# COMPILE GHC putStr = Text.putStr #-} {-# COMPILE GHC putStrLn = Text.putStrLn #-} {-# COMPILE UHC putStr = (UHC.Agda.Builtins.primPutStr) #-} {-# COMPILE UHC putStrLn = (UHC.Agda.Builtins.primPutStrLn) #-} print : ∀ {a} {A : Set a} {{ShowA : Show A}} → A → IO Unit print = putStrLn ∘ show --- Command line arguments --- {-# FOREIGN GHC import System.Environment (getArgs, getProgName) #-} postulate getArgs : IO (List String) getProgName : IO String {-# COMPILE GHC getArgs = fmap (map Text.pack) getArgs #-} {-# COMPILE GHC getProgName = fmap Text.pack getProgName #-} --- Misc --- {-# FOREIGN GHC import System.Exit #-} data ExitCode : Set where Success : ExitCode -- TODO we probably should also enforce an upper limit? Failure : (n : Nat) → {p : NonZero n} → ExitCode private {-# FOREIGN GHC exitWith' x = exitWith (if x == 0 then ExitSuccess else ExitFailure $ fromInteger x) #-} postulate exitWith' : ∀ {a} {A : Set a} → Nat → IO A {-# COMPILE GHC exitWith' = \ _ _ -> exitWith' #-} exitWith : ∀ {a} {A : Set a} → ExitCode → IO A exitWith Success = exitWith' 0 exitWith (Failure i) = exitWith' i
{ "alphanum_fraction": 0.6225680934, "avg_line_length": 27.7156862745, "ext": "agda", "hexsha": "4b6950fa34f7f76686b03ab9433bb315b4900b5f", "lang": "Agda", "max_forks_count": 24, "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "L-TChen/agda-prelude", "max_forks_repo_path": "src/Prelude/IO.agda", "max_issues_count": 59, "max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "L-TChen/agda-prelude", "max_issues_repo_path": "src/Prelude/IO.agda", "max_line_length": 106, "max_stars_count": 111, "max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "L-TChen/agda-prelude", "max_stars_repo_path": "src/Prelude/IO.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "num_tokens": 918, "size": 2827 }
------------------------------------------------------------------------ -- The two methods used to specify the grammars are (language) -- equivalent (for acyclic graphs) ------------------------------------------------------------------------ open import Mixfix.Expr open import Mixfix.Acyclic.PrecedenceGraph using (acyclic; precedence) module Mixfix.Equivalence (g : PrecedenceGraphInterface.PrecedenceGraph acyclic) where open import Function using (_∘_) open import Data.List using (List; []; _∷_) open import Data.List.NonEmpty using (_∷_) open import Data.Nat using (ℕ; zero; suc; _+_) open import Data.Product open import Data.Vec using (Vec; []; _∷_) open import TotalParserCombinators.Parser open import TotalParserCombinators.Semantics open import TotalParserCombinators.Semantics.Continuation as ContSem import StructurallyRecursiveDescentParsing.Simplified as Simplified import StructurallyRecursiveDescentParsing.Simplified.Semantics as SSem open import Mixfix.Fixity open import Mixfix.Operator import Mixfix.Acyclic.Grammar import Mixfix.Cyclic.Grammar import Mixfix.Acyclic.Lemma private module Acyclic = Mixfix.Acyclic.Grammar g module ALemma = Mixfix.Acyclic.Lemma g module Cyclic = Mixfix.Cyclic.Grammar acyclic g open import Mixfix.Acyclic.Lib as ALib open ALib.Semantics-⊕ renaming (_⊕_∈⟦_⟧·_ to _⊕_∈⟦_⟧A·_) open import Mixfix.Cyclic.Lib as CLib renaming (⟦_⟧ to ⟦_⟧C) open CLib.Semantics-⊕ renaming (_⊕_∈⟦_⟧·_ to _⊕_∈⟦_⟧C·_) open PrecedenceCorrect acyclic g ⟦_⟧A : ∀ {R} → ALib.ParserProg R → Parser NamePart R [] ⟦ p ⟧A = Simplified.⟦_⟧ (ALib.⟦_⟧ p) module AcyclicToCyclic where mutual precs : ∀ ps {s s′ e} → e ⊕ s′ ∈⟦ Acyclic.precs ps ⟧A· s → e ⊕ s′ ∈⟦ Cyclic.precs ps ⟧C· s precs [] () precs (p ∷ ps) (∣ˡ (<$> e∈p)) = ∣ˡ (<$> prec p e∈p) precs (p ∷ ps) (∣ʳ (<$> e∈ps)) = ∣ʳ (<$> precs ps e∈ps) prec : ∀ p {s s′ e} → e ⊕ s′ ∈⟦ Acyclic.prec p ⟧A· s → e ⊕ s′ ∈⟦ Cyclic.prec p ⟧C· s prec (precedence ops sucs) e∈ = prec′ e∈ where p = precedence ops sucs module A = Acyclic.Prec ops sucs module C = Cyclic.Prec p preRight : ∀ {s s′ f} → f ⊕ s′ ∈⟦ A.preRight ⟧A· s → f ⊕ s′ ∈⟦ C.preRight ⟧C· s preRight (∣ˡ (<$> i∈)) = ∣ˡ (<$> inner _ i∈) preRight (∣ʳ (<$> ↑∈ ⊛ i∈)) = ∣ʳ (<$> precs _ ↑∈ ⊛ inner _ i∈) preRight⁺ : ∀ {s s′ s″ fs e} → fs ⊕ s′ ∈⟦ A.preRight + ⟧A· s → e ⊕ s″ ∈⟦ Acyclic.precs sucs ⟧A· s′ → A.appʳ fs e ⊕ s″ ∈⟦ C.preRight⁺ ⟧C· s preRight⁺ {fs = _ ∷ ._} (+-[] f∈) ↑∈ = preRight f∈ ⊛∞ ∣ʳ (<$> precs _ ↑∈) preRight⁺ {fs = _ ∷ ._} (+-∷ f∈ fs∈) ↑∈ = preRight f∈ ⊛∞ ∣ˡ (<$> preRight⁺ fs∈ ↑∈) postLeft : ∀ {s s′ f} → f ⊕ s′ ∈⟦ A.postLeft ⟧A· s → f ⊕ s′ ∈⟦ C.postLeft ⟧C· s postLeft (∣ˡ (<$> i∈ )) = ∣ˡ (<$> inner _ i∈) postLeft (∣ʳ (<$> i∈ ⊛ ↑∈)) = ∣ʳ (<$> inner _ i∈ ⊛ precs _ ↑∈) postLeft⁺ : ∀ {s s′ s″ o fs} → o ⊕ s′ ∈⟦ similar <$> C.postLeft⁺ ∣ tighter <$> C.p↑ ⟧C· s → fs ⊕ s″ ∈⟦ A.postLeft + ⟧A· s′ → ALemma.appˡ o fs ⊕ s″ ∈⟦ C.postLeft⁺ ⟧C· s postLeft⁺ {fs = _ ∷ ._} o∈ (+-[] f∈) = <$> o∈ ⊛∞ postLeft f∈ postLeft⁺ {fs = _ ∷ ._} o∈ (+-∷ f∈ fs∈) = postLeft⁺ (∣ˡ (<$> (<$> o∈ ⊛∞ postLeft f∈))) fs∈ prec′ : ∀ {s s′ assoc} {e : ExprIn p assoc} → (-, e) ⊕ s′ ∈⟦ Acyclic.prec p ⟧A· s → (-, e) ⊕ s′ ∈⟦ Cyclic.prec p ⟧C· s prec′ (∥ˡ (<$> i∈)) = ∥ˡ (<$> inner _ i∈) prec′ (∥ʳ (∥ˡ (<$> ↑₁∈ ⊛ i∈ ⊛ ↑₂∈))) = ∥ʳ (∥ˡ (<$> precs _ ↑₁∈ ⊛ inner _ i∈ ⊛∞ precs _ ↑₂∈ )) prec′ (∥ʳ (∥ʳ (∥ˡ (<$> fs∈ ⊛ ↑∈)))) = ∥ʳ (∥ʳ (∥ˡ (preRight⁺ fs∈ ↑∈))) prec′ (∥ʳ (∥ʳ (∥ʳ (∥ˡ (<$> ↑∈ ⊛ fs∈))))) = ∥ʳ (∥ʳ (∥ʳ (∥ˡ (postLeft⁺ (∣ʳ (<$> precs _ ↑∈)) fs∈)))) prec′ (∥ʳ (∥ʳ (∥ʳ (∥ʳ ())))) inner : ∀ {fix} (ops : List (∃ (Operator fix))) {s s′ i} → i ⊕ s′ ∈⟦ Acyclic.inner ops ⟧A· s → i ⊕ s′ ∈⟦ Cyclic.inner ops ⟧C· s inner [] () inner ((_ , op) ∷ ops) (∣ˡ (<$> i∈)) = ∣ˡ (<$> inner′ _ i∈) inner ((_ , op) ∷ ops) (∣ʳ (<$> i∈)) = ∣ʳ (<$> inner ops i∈) inner′ : ∀ {arity} (ns : Vec NamePart (1 + arity)) {s s′ i} → i ⊕ s′ ∈⟦ Acyclic.expr between ns ⟧A· s → i ⊕ s′ ∈⟦ Cyclic.expr between ns ⟧C· s inner′ (n ∷ .[]) between-[] = between-[] inner′ (n ∷ ns) (between-∷ e∈g es∈g) = between-∷ (precs g e∈g) (inner′ ns es∈g) module CyclicToAcyclic where mutual precs : ∀ ps {s s′ e} → e ⊕ s′ ∈⟦ Cyclic.precs ps ⟧C· s → e ⊕ s′ ∈⟦ Acyclic.precs ps ⟧A· s precs [] () precs (p ∷ ps) (∣ˡ (<$> e∈p)) = ∣ˡ (<$> prec p e∈p) precs (p ∷ ps) (∣ʳ (<$> e∈ps)) = ∣ʳ (<$> precs ps e∈ps) prec : ∀ p {s s′ e} → e ⊕ s′ ∈⟦ Cyclic.prec p ⟧C· s → e ⊕ s′ ∈⟦ Acyclic.prec p ⟧A· s prec (precedence ops sucs) e∈ = prec′ e∈ where p = precedence ops sucs module A = Acyclic.Prec ops sucs module C = Cyclic.Prec p preRight : ∀ {s s′ f} → f ⊕ s′ ∈⟦ C.preRight ⟧C· s → f ⊕ s′ ∈⟦ A.preRight ⟧A· s preRight (∣ˡ (<$> i∈)) = ∣ˡ (<$> inner _ i∈) preRight (∣ʳ (<$> ↑∈ ⊛ i∈)) = ∣ʳ (<$> precs _ ↑∈ ⊛ inner _ i∈) preRight⁺ : ∀ {s s′ e} → e ⊕ s′ ∈⟦ C.preRight⁺ ⟧C· s → e ⊕ s′ ∈⟦ A.appʳ <$> A.preRight + ⊛ A.p↑ ⟧A· s preRight⁺ (f∈ ⊛∞ ∣ˡ (<$> pre∈)) with preRight⁺ pre∈ preRight⁺ (f∈ ⊛∞ ∣ˡ (<$> pre∈)) | <$> fs∈ ⊛ ↑∈ = <$> +-∷ (preRight f∈) fs∈ ⊛ ↑∈ preRight⁺ (f∈ ⊛∞ ∣ʳ (<$> ↑∈) ) = <$> +-[] (preRight f∈) ⊛ precs _ ↑∈ postLeft : ∀ {s s′ f} → f ⊕ s′ ∈⟦ C.postLeft ⟧C· s → f ⊕ s′ ∈⟦ A.postLeft ⟧A· s postLeft (∣ˡ (<$> i∈ )) = ∣ˡ (<$> inner _ i∈) postLeft (∣ʳ (<$> i∈ ⊛ ↑∈)) = ∣ʳ (<$> inner _ i∈ ⊛ precs _ ↑∈) postLeft⁺ : ∀ {s s′ e} → e ⊕ s′ ∈⟦ C.postLeft⁺ ⟧C· s → e ⊕ s′ ∈⟦ A.appˡ <$> A.p↑ ⊛ A.postLeft + ⟧A· s postLeft⁺ (<$> ∣ˡ (<$> post∈) ⊛∞ f∈) with postLeft⁺ post∈ postLeft⁺ (<$> ∣ˡ (<$> post∈) ⊛∞ f∈) | _⊛_ {x = fs} (<$> ↑∈) fs∈ = AS.cast∈ (ALemma.appˡ-∷ʳ _ fs _) ( <$> ↑∈ ⊛ AS.+-∷ʳ fs∈ (postLeft f∈)) where module AS = ALib.Semantics-⊕ postLeft⁺ (<$> ∣ʳ (<$> ↑∈) ⊛∞ f∈) = <$> precs _ ↑∈ ⊛ +-[] (postLeft f∈) prec′ : ∀ {s s′ assoc} {e : ExprIn p assoc} → (-, e) ⊕ s′ ∈⟦ Cyclic.prec p ⟧C· s → (-, e) ⊕ s′ ∈⟦ Acyclic.prec p ⟧A· s prec′ (∥ˡ (<$> i∈)) = ∥ˡ (<$> inner _ i∈) prec′ (∥ʳ (∥ˡ (<$> ↑₁∈ ⊛ i∈ ⊛∞ ↑₂∈))) = ∥ʳ (∥ˡ (<$> precs _ ↑₁∈ ⊛ inner _ i∈ ⊛ precs _ ↑₂∈ )) prec′ (∥ʳ (∥ʳ (∥ˡ pre∈))) = ∥ʳ (∥ʳ (∥ˡ (preRight⁺ pre∈))) prec′ (∥ʳ (∥ʳ (∥ʳ (∥ˡ post∈)))) = ∥ʳ (∥ʳ (∥ʳ (∥ˡ (postLeft⁺ post∈)))) prec′ (∥ʳ (∥ʳ (∥ʳ (∥ʳ ())))) inner : ∀ {fix} (ops : List (∃ (Operator fix))) {s s′ i} → i ⊕ s′ ∈⟦ Cyclic.inner ops ⟧C· s → i ⊕ s′ ∈⟦ Acyclic.inner ops ⟧A· s inner [] () inner ((_ , op) ∷ ops) (∣ˡ (<$> i∈)) = ∣ˡ (<$> inner′ _ i∈) inner ((_ , op) ∷ ops) (∣ʳ (<$> i∈)) = ∣ʳ (<$> inner ops i∈) inner′ : ∀ {arity} (ns : Vec NamePart (1 + arity)) {s s′ i} → i ⊕ s′ ∈⟦ Cyclic.expr between ns ⟧C· s → i ⊕ s′ ∈⟦ Acyclic.expr between ns ⟧A· s inner′ (n ∷ .[]) between-[] = between-[] inner′ (n ∷ ns) (between-∷ e∈g es∈g) = between-∷ (precs g e∈g) (inner′ ns es∈g) acyclicToCyclic : ∀ {e s} → e ∈ Simplified.⟦_⟧ Acyclic.expression · s → e ∈ Cyclic.expression · s acyclicToCyclic = ContSem.sound ∘ CLib.Semantics-⊕.sound ∘ AcyclicToCyclic.precs _ ∘ ALib.Semantics-⊕.complete _ ∘ SSem.⊕-complete ∘ SSem.complete _ cyclicToAcyclic : ∀ {e s} → e ∈ Cyclic.expression · s → e ∈ Simplified.⟦_⟧ Acyclic.expression · s cyclicToAcyclic = SSem.sound ∘ SSem.⊕-sound ∘ ALib.Semantics-⊕.sound ∘ CyclicToAcyclic.precs _ ∘ CLib.Semantics-⊕.complete _ ∘ ContSem.complete
{ "alphanum_fraction": 0.4315655396, "avg_line_length": 40.9289099526, "ext": "agda", "hexsha": "99a8faa0e6ad5546407708e61cb193517a30bb20", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/parser-combinators", "max_forks_repo_path": "Mixfix/Equivalence.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/parser-combinators", "max_issues_repo_path": "Mixfix/Equivalence.agda", "max_line_length": 104, "max_stars_count": 1, "max_stars_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/parser-combinators", "max_stars_repo_path": "Mixfix/Equivalence.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:13.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-03T08:56:13.000Z", "num_tokens": 3721, "size": 8636 }
------------------------------------------------------------------------------ -- Testing the η-expansion ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module Eta3 where postulate D : Set P² : D → D → Set data ∃ (A : D → Set) : Set where _,_ : (t : D) → A t → ∃ A -- Because Agda η-reduces the equations, the internal representation -- of P corresponds to the predicate -- -- P xs = ∃ (P² xs) -- -- We η-expand the definition of P before the translation to FOL. P : D → Set P xs = ∃ λ ys → P² xs ys {-# ATP definition P #-} postulate bar : ∀ {xs} → P xs → (∃ λ ys → P² xs ys) {-# ATP prove bar #-}
{ "alphanum_fraction": 0.4504283966, "avg_line_length": 25.53125, "ext": "agda", "hexsha": "49c71963906e24ad2c81b9e25cd8130cb04317da", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2016-08-03T03:54:55.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-10T23:06:19.000Z", "max_forks_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/apia", "max_forks_repo_path": "test/Succeed/fol-theorems/Eta3.agda", "max_issues_count": 121, "max_issues_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_issues_repo_issues_event_max_datetime": "2018-04-22T06:01:44.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-25T13:22:12.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/apia", "max_issues_repo_path": "test/Succeed/fol-theorems/Eta3.agda", "max_line_length": 78, "max_stars_count": 10, "max_stars_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/apia", "max_stars_repo_path": "test/Succeed/fol-theorems/Eta3.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-03T13:44:25.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:54:16.000Z", "num_tokens": 204, "size": 817 }
module Cat where open import Agda.Builtin.Equality {- A category is very much like a graph. It has vertices named objects and vertices named arrows. Each arrow goes from an object to an object (possibly the same!). -} record Cat (obj : Set) (arr : obj -> obj -> Set) : Set where constructor MkCat field {- For each object, there is an arrow called `id` which goes from the object to itself. -} id : {o : obj} -> arr o o {- Given an arrow `f` from object `a` to `b` and an arrow `g` from `b` to `c`. We can compose these arrow. The result is an arrow from `a` to `c`. -} compose : {a b c : obj} -> arr a b -> arr b c -> arr a c -- Here comes some properties of `id` and `compose` {- For any arrow `f`, compose id f = f -} neutralLeft : {a b : obj} -> (f : arr a b) -> compose id f ≡ f {- For any arrow `f`, compose f id = f -} neutralRight : {a b : obj} -> (f : arr a b) -> compose f id ≡ f {- For any arrows `f`, `g` and `h`, composing f with g, and then the result with h gives exatctly the same result as composing f with the result of the composition of g and h Which means, like string concatenation than we can commpose the way we preserve the order of each element in the sequence. -} associativity : {a b c d : obj} -> (f : arr a b) -> (g : arr b c) -> (h : arr c d) -> compose f (compose g h) ≡ compose (compose f g) h open import Agda.Builtin.Nat {- `LE n m` encode the property that `n ≤ m` i.e. `n` is less or equal to `m` -} data LE : Nat -> Nat -> Set where LERefl : {n : Nat} -> LE n n LENext : {n m : Nat} -> LE n m -> LE n (suc m) {- Taking naturals as objects and `LE` as arrows, this actually forms a category! -} natPoset : Cat Nat LE natPoset = ???
{ "alphanum_fraction": 0.5845905172, "avg_line_length": 36.3921568627, "ext": "agda", "hexsha": "a1bae4e34fbe4c3ef5b48eb39e1a23ea0b4514a5", "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": "277e034f7152623a17527c4ae55acc7aa8ce1f89", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "chrilves/big4-tutorial", "max_forks_repo_path": "Agda/Cat.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "277e034f7152623a17527c4ae55acc7aa8ce1f89", "max_issues_repo_issues_event_max_datetime": "2021-08-24T14:31:45.000Z", "max_issues_repo_issues_event_min_datetime": "2021-08-24T14:31:45.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "chrilves/big4-tutorial", "max_issues_repo_path": "Agda/Cat.agda", "max_line_length": 70, "max_stars_count": 3, "max_stars_repo_head_hexsha": "277e034f7152623a17527c4ae55acc7aa8ce1f89", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "chrilves/big4-tutorial", "max_stars_repo_path": "Agda/Cat.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-22T18:44:11.000Z", "max_stars_repo_stars_event_min_datetime": "2019-02-02T14:13:39.000Z", "num_tokens": 561, "size": 1856 }
-- Checks that UHC FFI calls using non-magic datatypes work module UHC-FFI where data Nat : Set where Zero : Nat Suc : Nat -> Nat {-# COMPILED_DATA_UHC Nat UHC.Agda.Builtins.Nat Zero Suc #-} {-# IMPORT_UHC Data.Char #-} open import Common.IO open import Common.Unit open import Common.String open import Common.Char postulate toLower : Char -> Char {-# COMPILED_UHC toLower Data.Char.toLower #-} main : IO Unit main = putStr (charToStr (toLower 'A'))
{ "alphanum_fraction": 0.7207792208, "avg_line_length": 20.0869565217, "ext": "agda", "hexsha": "5a58e2455209faa0ebd17cfa882935d48f3275a9", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_path": "test/Compiler/simple/UHC-FFI.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/Compiler/simple/UHC-FFI.agda", "max_line_length": 60, "max_stars_count": null, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/Compiler/simple/UHC-FFI.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 129, "size": 462 }
-- modular arithmetic module nat-mod where open import eq open import nat infix 8 _≡_mod_ data _≡_mod_ : ℕ → ℕ → ℕ → Set where mod-refl : ∀ {n k} → n ≡ n mod k mod-add : ∀ {n m k} → n ≡ m mod k → n + k ≡ m mod k mod-symm : ∀ {n m k} → n ≡ m mod k → m ≡ n mod k {- mod-trans : ∀ {n m o k} → n ≡ m mod k → m ≡ o mod k → n ≡ o mod k mod-trans{n}{.n}{o}{k} mod-refl p2 = {!!} mod-trans}{m}{o}{k} (mod-add p1) p2 = {!!} mod-trans{n}{m}{o}{k} (mod-symm p1) p2 = {!!} -}
{ "alphanum_fraction": 0.5189873418, "avg_line_length": 23.7, "ext": "agda", "hexsha": "a2d0623273b64b975ce51278efd525c35a0d29dc", "lang": "Agda", "max_forks_count": 17, "max_forks_repo_forks_event_max_datetime": "2021-11-28T20:13:21.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-03T22:38:15.000Z", "max_forks_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rfindler/ial", "max_forks_repo_path": "nat-mod.agda", "max_issues_count": 8, "max_issues_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_issues_repo_issues_event_max_datetime": "2022-03-22T03:43:34.000Z", "max_issues_repo_issues_event_min_datetime": "2018-07-09T22:53:38.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "rfindler/ial", "max_issues_repo_path": "nat-mod.agda", "max_line_length": 65, "max_stars_count": 29, "max_stars_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rfindler/ial", "max_stars_repo_path": "nat-mod.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-04T15:05:12.000Z", "max_stars_repo_stars_event_min_datetime": "2019-02-06T13:09:31.000Z", "num_tokens": 212, "size": 474 }
module Generic.Function.FoldMono where open import Generic.Core CurryAll : ∀ {α β} {A : Set α} -> (A -> Set β) -> List A -> Set β -> Set β CurryAll B [] C = C CurryAll B (x ∷ xs) C = B x -> CurryAll B xs C curryAll : ∀ {α β} {A : Set α} {B : A -> Set β} {C xs} -> (All B xs -> C) -> CurryAll B xs C curryAll {xs = []} g = g tt curryAll {xs = x ∷ xs} g = curryAll ∘ curry g mutual Hyp : ∀ {ι β} {I : Set ι} -> (I -> Set β) -> (D : Desc I β) -> Set β Hyp C (var i) = C i Hyp C (π i q D) = Hypᵇ i C D q Hyp C (D ⊛ E) = Hyp C D × Hyp C E Hypᵇ : ∀ {α ι β γ q} {I : Set ι} i -> (I -> Set β) -> Binder α β γ i q I -> α ≤ℓ β -> Set β Hypᵇ i C (coerce (A , D)) q = Coerce′ q $ Pi i A λ x -> Hyp C (D x) mutual Fold : ∀ {ι β} {I : Set ι} -> (I -> Set β) -> (D : Desc I β) -> Set β Fold C (var i) = C i Fold C (π i q D) = Foldᵇ i C D q Fold C (D ⊛ E) = Hyp C D -> Fold C E Foldᵇ : ∀ {α ι β γ q} {I : Set ι} i -> (I -> Set β) -> Binder α β γ i q I -> α ≤ℓ β -> Set β Foldᵇ i C (coerce (A , D)) q = Coerce′ q $ Pi i A λ x -> Fold C (D x) module _ {ι β} {I : Set ι} {D₀ : Data (Desc I β)} (C : I -> Set β) where module _ (hs : All (Fold C) (consTypes D₀)) where {-# TERMINATING #-} mutual foldHyp : (D : Desc I β) -> ⟦ D ⟧ (μ D₀) -> Hyp C D foldHyp (var i) d = foldMono d foldHyp (π i q D) f = foldHypᵇ i D f foldHyp (D ⊛ E) (x , y) = foldHyp D x , foldHyp E y foldHypᵇ : ∀ {α γ q q′} i -> (D : Binder α β γ i q′ I) -> ⟦ i / D ⟧ᵇ q (μ D₀) -> Hypᵇ i C D q foldHypᵇ {q = q} i (coerce (A , D)) f = coerce′ q $ lamPi i λ x -> foldHyp (D x) (appPi i (uncoerce′ q f) x) foldExtend : ∀ {j} -> (D : Desc I β) -> Fold C D -> Extend D (μ D₀) j -> C j foldExtend (var i) z lrefl = z foldExtend (π i q D) h p = foldExtendᵇ i D h p foldExtend (D ⊛ E) h (d , e) = foldExtend E (h (foldHyp D d)) e foldExtendᵇ : ∀ {α γ q q′ j} i -> (D : Binder α β γ i q′ I) -> Foldᵇ i C D q -> Extendᵇ i D q (μ D₀) j -> C j foldExtendᵇ {q = q} i (coerce (A , D)) h p with p | inspectUncoerce′ q p ... | _ | (x , e) , refl = foldExtend (D x) (appPi i (uncoerce′ q h) x) e foldAny : ∀ {j} (Ds : List (Desc I β)) d a b ns -> All (Fold C) Ds -> Node D₀ (packData d a b Ds ns) j -> C j foldAny [] d a b tt tt () foldAny (D ∷ []) d a b (_ , ns) (h , tt) e = foldExtend D h e foldAny (D ∷ E ∷ Ds) d a b (_ , ns) (h , hs) (inj₁ e) = foldExtend D h e foldAny (D ∷ E ∷ Ds) d a b (_ , ns) (h , hs) (inj₂ r) = foldAny (E ∷ Ds) d a b ns hs r foldMono : ∀ {j} -> μ D₀ j -> C j foldMono (node e) = foldAny (consTypes D₀) (dataName D₀) (parsTele D₀) (indsTele D₀) (consNames D₀) hs e curryFoldMono : ∀ {j} -> μ D₀ j -> CurryAll (Fold C) (consTypes D₀) (C j) curryFoldMono d = curryAll λ hs -> foldMono hs d
{ "alphanum_fraction": 0.4447929737, "avg_line_length": 41.9473684211, "ext": "agda", "hexsha": "cf9af2265a63eb6aae99de9cce637037e145f5ec", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2021-01-27T12:57:09.000Z", "max_forks_repo_forks_event_min_datetime": "2017-07-17T07:23:39.000Z", "max_forks_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "turion/Generic", "max_forks_repo_path": "src/Generic/Function/FoldMono.agda", "max_issues_count": 9, "max_issues_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe", "max_issues_repo_issues_event_max_datetime": "2022-01-04T15:43:14.000Z", "max_issues_repo_issues_event_min_datetime": "2017-04-06T18:58:09.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "turion/Generic", "max_issues_repo_path": "src/Generic/Function/FoldMono.agda", "max_line_length": 96, "max_stars_count": 30, "max_stars_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "turion/Generic", "max_stars_repo_path": "src/Generic/Function/FoldMono.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T10:19:38.000Z", "max_stars_repo_stars_event_min_datetime": "2016-07-19T21:10:54.000Z", "num_tokens": 1299, "size": 3188 }
{-# OPTIONS --termination-depth=2 #-} module plfa-code.Quantifiers where import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl) open import Data.Nat using (ℕ; zero; suc; _+_; _*_) open import Relation.Nullary using (¬_) open import Data.Product using (_×_; proj₁; proj₂) renaming (_,_ to ⟨_,_⟩) open import Data.Sum using (_⊎_; inj₁; inj₂) open import plfa-code.Isomorphism using (_≃_; extensionality) ∀-elim : ∀ {A : Set} {B : A → Set} → (L : ∀ (x : A) → B x) → (M : A) -------------------------- → B M ∀-elim L M = L M ---------- practice ---------- ∀-distrib-× : ∀ {A : Set} {B C : A → Set} → (∀ (x : A) → B x × C x) ≃ (∀ (x : A) → B x) × (∀ (x : A) → C x) ∀-distrib-× = record { to = λ fₗ → ⟨ (λ a → proj₁ (fₗ a)) , (λ a → proj₂ (fₗ a)) ⟩ ; from = λ x a → ⟨ (proj₁ x a) , (proj₂ x a) ⟩ ; from∘to = λ fₗ → refl ; to∘from = λ x → refl } ⊎∀-implies-∀⊎ : ∀ {A : Set} {B C : A → Set} → (∀ (x : A) → B x) ⊎ (∀ (x : A) → C x) → ∀ (x : A) → B x ⊎ C x ⊎∀-implies-∀⊎ (inj₁ f₁) a = inj₁ (f₁ a) ⊎∀-implies-∀⊎ (inj₂ f₂) a = inj₂ (f₂ a) -- the converse doesn't hold. If we construct a function -- '∀ (x : A) → B x', we could build a '∀ (x : A) → B x ⊎ C x', -- but '∀ (x : A) → C x' maybe doesn't hold. data Tri : Set where aa : Tri bb : Tri cc : Tri postulate ∀-extensionality : ∀ {A : Set} {B : A → Set} (f g : ∀ (x : A) → B x) → (∀ (x : A) → (f x ≡ g x)) → f ≡ g ∀-× : {B : Tri → Set} → (∀ (x : Tri) → B x) ≃ (B aa × B bb × B cc) ∀-× {B} = record { to = to′ ; from = from′ ; from∘to = λ f → ∀-extensionality (from′ ⟨ f aa , ⟨ f bb , f cc ⟩ ⟩) f λ{aa → refl; bb → refl; cc → refl} ; to∘from = λ xx → refl } where to′ : (∀ (x : Tri) → B x) → (B aa × B bb × B cc) to′ f = ⟨ f aa , ⟨ f bb , f cc ⟩ ⟩ from′ : (B aa × B bb × B cc) → (∀ (x : Tri) → B x) from′ xx aa = proj₁ xx from′ xx bb = proj₁ (proj₂ xx) from′ xx cc = proj₂ (proj₂ xx) -- every λ expression has different types , wtf ------------------------------ data Σ (A : Set) (B : A → Set) : Set where ⟨_,_⟩ : (x : A) → B x → Σ A B Σ-syntax = Σ infix 2 Σ-syntax syntax Σ-syntax A (λ x → B) = Σ[ x ∈ A ] B record Σ′ (A : Set) (B : A → Set) : Set where field proj₁′ : A proj₂′ : B proj₁′ ∃ : ∀ {A : Set} (B : A → Set) → Set ∃ {A} B = Σ A B ∃-syntax = ∃ syntax ∃-syntax (λ x → B) = ∃[ x ] B ∃-elim : ∀ {A : Set} {B : A → Set} {C : Set} → (∀ x → B x → C) → ∃[ x ] B x --------------- → C ∃-elim f ⟨ x , y ⟩ = f x y ∀∃-currying : ∀ {A : Set} {B : A → Set} {C : Set} → (∀ x → B x → C) ≃ (∃[ x ] B x → C) ∀∃-currying = record { to = λ{ f → λ{ ⟨ x , y ⟩ → f x y }} ; from = λ{ g → λ{ x → λ{ y → g ⟨ x , y ⟩ }}} ; from∘to = λ f → refl ; to∘from = λ g → extensionality (λ{ ⟨ x , y ⟩ → refl}) } ---------- practice ---------- ∃-distrib-⊎ : ∀ {A : Set} {B C : A → Set} → ∃[ x ] (B x ⊎ C x) ≃ (∃[ x ] B x) ⊎ (∃[ x ] C x) ∃-distrib-⊎ = record { to = λ{ ⟨ a , inj₁ b ⟩ → inj₁ ⟨ a , b ⟩ ; ⟨ a , inj₂ c ⟩ → inj₂ ⟨ a , c ⟩ } ; from = λ{ (inj₁ ⟨ a , b ⟩) → ⟨ a , inj₁ b ⟩ ; (inj₂ ⟨ a , c ⟩) → ⟨ a , inj₂ c ⟩ } ; from∘to = λ{ ⟨ a , inj₁ b ⟩ → refl ; ⟨ a , inj₂ c ⟩ → refl } ; to∘from = λ{ (inj₁ ⟨ a , b ⟩) → refl ; (inj₂ ⟨ a , c ⟩) → refl } } ∃×-implies-×∃ : ∀ {A : Set} {B C : A → Set} → ∃[ x ] (B x × C x) → (∃[ x ] B x) × (∃[ x ] C x) ∃×-implies-×∃ ⟨ a , ⟨ b , c ⟩ ⟩ = ⟨ ⟨ a , b ⟩ , ⟨ a , c ⟩ ⟩ -- the converse doesn't hold, because the x in ∃[ x ] B x is maybe not -- the same 'x' in ∃[ x ] C x ∃-⊎ : ∀ {B : Tri → Set} → ∃[ x ] B x ≃ B aa ⊎ B bb ⊎ B cc ∃-⊎ = record { to = λ{ ⟨ aa , a ⟩ → inj₁ a ; ⟨ bb , b ⟩ → inj₂ (inj₁ b) ; ⟨ cc , c ⟩ → inj₂ (inj₂ c) } ; from = λ{ (inj₁ a) → ⟨ aa , a ⟩ ; (inj₂ (inj₁ b)) → ⟨ bb , b ⟩ ; (inj₂ (inj₂ c)) → ⟨ cc , c ⟩ } ; from∘to = λ{ ⟨ aa , a ⟩ → refl ; ⟨ bb , b ⟩ → refl ; ⟨ cc , c ⟩ → refl } ; to∘from = λ{ (inj₁ a) → refl ; (inj₂ (inj₁ b)) → refl ; (inj₂ (inj₂ c)) → refl } } data even : ℕ → Set data odd : ℕ → Set data even where even-zero : even zero even-suc : ∀ {n : ℕ} → odd n ------------ → even (suc n) data odd where odd-suc : ∀ {n : ℕ} → even n ----------- → odd (suc n) even-∃ : ∀ {n : ℕ} → even n → ∃[ m ] ( m * 2 ≡ n) odd-∃ : ∀ {n : ℕ} → odd n → ∃[ m ] (1 + m * 2 ≡ n) even-∃ even-zero = ⟨ zero , refl ⟩ even-∃ (even-suc o) with odd-∃ o ... | ⟨ m , refl ⟩ = ⟨ suc m , refl ⟩ odd-∃ (odd-suc e) with even-∃ e ... | ⟨ m , refl ⟩ = ⟨ m , refl ⟩ ∃-even : ∀ {n : ℕ} → ∃[ m ] ( m * 2 ≡ n) → even n ∃-odd : ∀ {n : ℕ} → ∃[ m ] (1 + m * 2 ≡ n) → odd n ∃-even ⟨ zero , refl ⟩ = even-zero ∃-even ⟨ suc m , refl ⟩ = even-suc (∃-odd ⟨ m , refl ⟩) ∃-odd ⟨ m , refl ⟩ = odd-suc (∃-even ⟨ m , refl ⟩) --------- practice ---------- open import Data.Nat.Properties using (+-identityʳ; +-suc; +-assoc) open Eq using (cong; sym; trans) open Eq.≡-Reasoning using (begin_; _≡⟨⟩_) open import plfa-code.Reasoning-legacy ∃-even′ : ∀ {n : ℕ} → ∃[ m ] ( 2 * m ≡ n) → even n ∃-odd′ : ∀ {n : ℕ} → ∃[ m ] (2 * m + 1 ≡ n) → odd n dbl≡2* : ∀ n → n + n ≡ 2 * n dbl≡2* n = cong (n +_) (sym (+-identityʳ n)) ∃-even′ ⟨ zero , refl ⟩ = even-zero ∃-even′ ⟨ suc m , refl ⟩ rewrite +-identityʳ m | +-suc m m | dbl≡2* m = even-suc (odd-suc (∃-even′ ⟨ m , refl ⟩)) ∃-odd′ ⟨ m , refl ⟩ rewrite +-suc (2 * m) 0 | +-identityʳ m | +-identityʳ (m + m) | dbl≡2* m = odd-suc (∃-even′ ⟨ m , refl ⟩) -- it's more difficult far away ... open Data.Nat using (_≤_; z≤n; s≤s) open Data.Nat.Properties using (≤-pred) ∃+⇒≤ : ∀ (y z : ℕ) → ∃[ x ] (x + y ≡ z) → y ≤ z ∃+⇒≤ zero .(x + 0) ⟨ x , refl ⟩ = z≤n ∃+⇒≤ (suc y) .(x + suc y) ⟨ x , refl ⟩ rewrite +-suc x y = s≤s (∃+⇒≤ y (x + y) ⟨ x , refl ⟩) ≤⇒∃+ : ∀ (y z : ℕ) → y ≤ z → ∃[ x ] (x + y ≡ z) ≤⇒∃+ zero z y≤z = ⟨ z , (+-identityʳ z) ⟩ ≤⇒∃+ (suc y) (suc z) y≤z with ≤⇒∃+ y z (≤-pred y≤z) ... | ⟨ x , x+y≡z ⟩ = ⟨ x , trans (+-suc x y) (cong suc x+y≡z) ⟩ ----------------------------- ¬∃≃∀¬ : ∀ {A : Set} {B : A → Set} → (¬ ∃[ x ] B x) ≃ ∀ x → ¬ B x ¬∃≃∀¬ = record { to = λ{ ¬∃xy x y → ¬∃xy ⟨ x , y ⟩ } ; from = λ{ ∀¬xy ⟨ x , y ⟩ → ∀¬xy x y } ; from∘to = λ{ ¬∃xy → extensionality λ{ ⟨ x , y ⟩ → refl } } ; to∘from = λ{ ∀¬xy → refl } } ---------- practice ---------- ∃¬-implies-¬∀ : ∀ {A : Set} {B : A → Set} → ∃[ x ] (¬ B x) -------------- → ¬ (∀ x → B x) ∃¬-implies-¬∀ ⟨ a , ¬b ⟩ = λ a→b → ¬b (a→b a) -- the converse doesn't hold. we couldn't get a instance -- of A to construct ∃[ x ] (¬ B x) open import plfa-code.Bin using (Bin; Can; One; zero; can-one; x0_; x1_; nil; one; from; to; can-to-n; can-tf-eq; from-to-const) open Eq using (subst₂; cong₂) open import Data.Empty using (⊥-elim) open import Function using (_∘_) one-assim : ∀ {b : Bin} → (x : One b) → (y : One b) → x ≡ y one-assim one one = refl one-assim (x0 x) (x0 y) = sym (cong x0_ (one-assim y x)) one-assim (x1 x) (x1 y) = sym (cong x1_ (one-assim y x)) can-assim : ∀ {b : Bin} → (x : Can b) → (y : Can b) → x ≡ y can-assim zero zero = refl can-assim zero (can-one (x0 ())) can-assim (can-one (x0 ())) zero can-assim (can-one one) (can-one one) = refl can-assim (can-one (x0 x)) (can-one (x0 y)) = cong (can-one ∘ x0_) (one-assim x y) can-assim (can-one (x1 x)) (can-one (x1 y)) = cong (can-one ∘ x1_) (one-assim x y) ∃-proj₁ : {A : Set} {B : A → Set} → ∃[ x ] B x → A ∃-proj₁ ⟨ x , _ ⟩ = x ∃≡ : ∀ {A : Set} {B : A → Set} (p₁ : ∃[ x ](B x)) (p₂ : ∃[ y ](B y)) → ∃-proj₁ p₁ ≡ ∃-proj₁ p₂ → (∀ (x) → (b₁ : B x) → (b₂ : B x) → b₁ ≡ b₂) → p₁ ≡ p₂ ∃≡ ⟨ x , bx ⟩ ⟨ .x , by ⟩ refl f = sym (cong (⟨_,_⟩ x) (f x by bx)) Bin-isomorphism : ℕ ≃ ∃[ x ](Can x) Bin-isomorphism = record { to = to′ ; from = from′ ; from∘to = from-to-const ; to∘from = to∘from′ } where to′ : ℕ → ∃[ x ](Can x) to′ n = ⟨ to n , can-to-n n ⟩ from′ : ∃[ x ](Can x) → ℕ from′ ⟨ b , can-b ⟩ = from b to∘from′ : ∀ y → to′ (from′ y) ≡ y to∘from′ ⟨ b , can-b ⟩ = ∃≡ ⟨ to (from b) , can-to-n (from b) ⟩ ⟨ b , can-b ⟩ (can-tf-eq can-b) (λ x → can-assim {x})
{ "alphanum_fraction": 0.4067387305, "avg_line_length": 29.883161512, "ext": "agda", "hexsha": "a7c83d556925b7834f4379253b623657a937296c", "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": "ec5b359a8c22bf5268cae3c36a97e6737c75d5f3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "chirsz-ever/plfa-code", "max_forks_repo_path": "src/plfa-code/Quantifiers.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ec5b359a8c22bf5268cae3c36a97e6737c75d5f3", "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": "chirsz-ever/plfa-code", "max_issues_repo_path": "src/plfa-code/Quantifiers.agda", "max_line_length": 120, "max_stars_count": null, "max_stars_repo_head_hexsha": "ec5b359a8c22bf5268cae3c36a97e6737c75d5f3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "chirsz-ever/plfa-code", "max_stars_repo_path": "src/plfa-code/Quantifiers.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3890, "size": 8696 }
{- This is mostly for convenience, when working with ideals (which are defined for general rings) in a commutative ring. -} {-# OPTIONS --safe #-} module Cubical.Algebra.CommRing.Ideal where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.HLevels open import Cubical.Foundations.Powerset renaming ( _∈_ to _∈p_ ; _⊆_ to _⊆p_ ; subst-∈ to subst-∈p ) open import Cubical.Functions.Logic open import Cubical.Data.Nat using (ℕ ; zero ; suc ; tt) renaming ( --zero to ℕzero ; suc to ℕsuc _+_ to _+ℕ_ ; _·_ to _·ℕ_ ; +-assoc to +ℕ-assoc ; +-comm to +ℕ-comm ; ·-assoc to ·ℕ-assoc ; ·-comm to ·ℕ-comm) open import Cubical.Data.FinData hiding (rec ; elim) open import Cubical.Data.Sigma open import Cubical.HITs.PropositionalTruncation open import Cubical.Algebra.CommRing open import Cubical.Algebra.Ring open import Cubical.Algebra.Ring.Ideal renaming (IdealsIn to IdealsInRing) open import Cubical.Algebra.Ring.BigOps open import Cubical.Algebra.RingSolver.ReflectionSolving private variable ℓ : Level IdealsIn : (R : CommRing ℓ) → Type _ IdealsIn R = IdealsInRing (CommRing→Ring R) module _ (Ring@(R , str) : CommRing ℓ) where open CommRingStr str makeIdeal : (I : R → hProp ℓ) → (+-closed : {x y : R} → x ∈p I → y ∈p I → (x + y) ∈p I) → (0r-closed : 0r ∈p I) → (·-closedLeft : {x : R} → (r : R) → x ∈p I → r · x ∈p I) → IdealsIn (R , str) makeIdeal I +-closed 0r-closed ·-closedLeft = I , (record { +-closed = +-closed ; -closed = λ x∈pI → subst-∈p I (useSolver _) (·-closedLeft (- 1r) x∈pI) ; 0r-closed = 0r-closed ; ·-closedLeft = ·-closedLeft ; ·-closedRight = λ r x∈pI → subst-∈p I (·-comm r _) (·-closedLeft r x∈pI) }) where useSolver : (x : R) → - 1r · x ≡ - x useSolver = solve Ring -- better? module CommIdeal (R' : CommRing ℓ) where private R = fst R' open CommRingStr (snd R') open Sum (CommRing→Ring R') open CommRingTheory R' open RingTheory (CommRing→Ring R') record isCommIdeal (I : ℙ R) : Type ℓ where constructor makeIsCommIdeal field +Closed : ∀ {x y : R} → x ∈p I → y ∈p I → (x + y) ∈p I contains0 : 0r ∈p I ·Closed : ∀ {x : R} (r : R) → x ∈p I → r · x ∈p I ·RClosed : ∀ {x : R} (r : R) → x ∈p I → x · r ∈p I ·RClosed r x∈pI = subst-∈p I (·-comm _ _) (·Closed r x∈pI) open isCommIdeal isPropIsCommIdeal : (I : ℙ R) → isProp (isCommIdeal I) +Closed (isPropIsCommIdeal I ici₁ ici₂ i) x∈pI y∈pI = I _ .snd (ici₁ .+Closed x∈pI y∈pI) (ici₂ .+Closed x∈pI y∈pI) i contains0 (isPropIsCommIdeal I ici₁ ici₂ i) = I 0r .snd (ici₁ .contains0) (ici₂ .contains0) i ·Closed (isPropIsCommIdeal I ici₁ ici₂ i) r x∈pI = I _ .snd (ici₁ .·Closed r x∈pI) (ici₂ .·Closed r x∈pI) i CommIdeal : Type (ℓ-suc ℓ) CommIdeal = Σ[ I ∈ ℙ R ] isCommIdeal I --inclusion and containment of ideals _⊆_ : CommIdeal → CommIdeal → Type ℓ I ⊆ J = I .fst ⊆p J .fst infix 5 _∈_ _∈_ : R → CommIdeal → Type ℓ x ∈ I = x ∈p I .fst subst-∈ : (I : CommIdeal) {x y : R} → x ≡ y → x ∈ I → y ∈ I subst-∈ I = subst-∈p (I .fst) CommIdeal≡Char : {I J : CommIdeal} → I ⊆ J → J ⊆ I → I ≡ J CommIdeal≡Char I⊆J J⊆I = Σ≡Prop isPropIsCommIdeal (⊆-extensionality _ _ (I⊆J , J⊆I)) ∑Closed : (I : CommIdeal) {n : ℕ} (V : FinVec R n) → (∀ i → V i ∈ I) → ∑ V ∈ I ∑Closed I {n = zero} _ _ = I .snd .contains0 ∑Closed I {n = suc n} V h = I .snd .+Closed (h zero) (∑Closed I (V ∘ suc) (h ∘ suc)) 0Ideal : CommIdeal fst 0Ideal x = (x ≡ 0r) , is-set _ _ +Closed (snd 0Ideal) x≡0 y≡0 = cong₂ (_+_) x≡0 y≡0 ∙ +Rid _ contains0 (snd 0Ideal) = refl ·Closed (snd 0Ideal) r x≡0 = cong (r ·_) x≡0 ∙ 0RightAnnihilates _ 1Ideal : CommIdeal fst 1Ideal x = ⊤ +Closed (snd 1Ideal) _ _ = lift tt contains0 (snd 1Ideal) = lift tt ·Closed (snd 1Ideal) _ _ = lift tt contains1Is1 : (I : CommIdeal) → 1r ∈ I → I ≡ 1Ideal contains1Is1 I 1∈I = CommIdeal≡Char (λ _ _ → lift tt) λ x _ → subst-∈ I (·Rid _) (I .snd .·Closed x 1∈I) -- x≡x·1 ∈ I _+i_ : CommIdeal → CommIdeal → CommIdeal fst (I +i J) x = (∃[ (y , z) ∈ (R × R) ] ((y ∈ I) × (z ∈ J) × (x ≡ y + z))) --have a record for this? , isPropPropTrunc +Closed (snd (I +i J)) {x = x₁} {y = x₂} = map2 +ClosedΣ where +ClosedΣ : Σ[ (y₁ , z₁) ∈ (R × R) ] ((y₁ ∈ I) × (z₁ ∈ J) × (x₁ ≡ y₁ + z₁)) → Σ[ (y₂ , z₂) ∈ (R × R) ] ((y₂ ∈ I) × (z₂ ∈ J) × (x₂ ≡ y₂ + z₂)) → Σ[ (y₃ , z₃) ∈ (R × R) ] ((y₃ ∈ I) × (z₃ ∈ J) × (x₁ + x₂ ≡ y₃ + z₃)) +ClosedΣ ((y₁ , z₁) , y₁∈I , z₁∈J , x₁≡y₁+z₁) ((y₂ , z₂) , y₂∈I , z₂∈J , x₂≡y₂+z₂) = (y₁ + y₂ , z₁ + z₂) , +Closed (snd I) y₁∈I y₂∈I , +Closed (snd J) z₁∈J z₂∈J , cong₂ (_+_) x₁≡y₁+z₁ x₂≡y₂+z₂ ∙ +ShufflePairs _ _ _ _ contains0 (snd (I +i J)) = ∣ (0r , 0r) , contains0 (snd I) , contains0 (snd J) , sym (+Rid _) ∣ ·Closed (snd (I +i J)) {x = x} r = map ·ClosedΣ where ·ClosedΣ : Σ[ (y₁ , z₁) ∈ (R × R) ] ((y₁ ∈ I) × (z₁ ∈ J) × (x ≡ y₁ + z₁)) → Σ[ (y₂ , z₂) ∈ (R × R) ] ((y₂ ∈ I) × (z₂ ∈ J) × (r · x ≡ y₂ + z₂)) ·ClosedΣ ((y₁ , z₁) , y₁∈I , z₁∈J , x≡y₁+z₁) = (r · y₁ , r · z₁) , ·Closed (snd I) r y₁∈I , ·Closed (snd J) r z₁∈J , cong (r ·_) x≡y₁+z₁ ∙ ·Rdist+ _ _ _ infixl 6 _+i_ +iComm⊆ : ∀ (I J : CommIdeal) → (I +i J) ⊆ (J +i I) +iComm⊆ I J x = map λ ((y , z) , y∈I , z∈J , x≡y+z) → (z , y) , z∈J , y∈I , x≡y+z ∙ +Comm _ _ +iComm : ∀ (I J : CommIdeal) → I +i J ≡ J +i I +iComm I J = CommIdeal≡Char (+iComm⊆ I J) (+iComm⊆ J I) +iLidLIncl : ∀ (I : CommIdeal) → (0Ideal +i I) ⊆ I +iLidLIncl I x = rec (I .fst x .snd) λ ((y , z) , y≡0 , z∈I , x≡y+z) → subst-∈ I (sym (x≡y+z ∙∙ cong (_+ z) y≡0 ∙∙ +Lid z)) z∈I +iLidRIncl : ∀ (I : CommIdeal) → I ⊆ (0Ideal +i I) +iLidRIncl I x x∈I = ∣ (0r , x) , refl , x∈I , sym (+Lid _) ∣ +iLid : ∀ (I : CommIdeal) → 0Ideal +i I ≡ I +iLid I = CommIdeal≡Char (+iLidLIncl I) (+iLidRIncl I) +iLincl : ∀ (I J : CommIdeal) → I ⊆ (I +i J) +iLincl I J x x∈I = ∣ (x , 0r) , x∈I , J .snd .contains0 , sym (+Rid x) ∣ +iRincl : ∀ (I J : CommIdeal) → J ⊆ (I +i J) +iRincl I J x x∈J = ∣ (0r , x) , I .snd .contains0 , x∈J , sym (+Lid x) ∣ +iRespLincl : ∀ (I J K : CommIdeal) → I ⊆ J → (I +i K) ⊆ (J +i K) +iRespLincl I J K I⊆J x = map λ ((y , z) , y∈I , z∈K , x≡y+z) → ((y , z) , I⊆J y y∈I , z∈K , x≡y+z) +iAssocLIncl : ∀ (I J K : CommIdeal) → (I +i (J +i K)) ⊆ ((I +i J) +i K) +iAssocLIncl I J K x = elim (λ _ → ((I +i J) +i K) .fst x .snd) (uncurry3 λ (y , z) y∈I → elim (λ _ → isPropΠ λ _ → ((I +i J) +i K) .fst x .snd) λ ((u , v) , u∈J , v∈K , z≡u+v) x≡y+z → ∣ (y + u , v) , ∣ _ , y∈I , u∈J , refl ∣ , v∈K , x≡y+z ∙∙ cong (y +_) z≡u+v ∙∙ +Assoc _ _ _ ∣) +iAssocRIncl : ∀ (I J K : CommIdeal) → ((I +i J) +i K) ⊆ (I +i (J +i K)) +iAssocRIncl I J K x = elim (λ _ → (I +i (J +i K)) .fst x .snd) (uncurry3 λ (y , z) → elim (λ _ → isPropΠ2 λ _ _ → (I +i (J +i K)) .fst x .snd) λ ((u , v) , u∈I , v∈J , y≡u+v) z∈K x≡y+z → ∣ (u , v + z) , u∈I , ∣ _ , v∈J , z∈K , refl ∣ , x≡y+z ∙∙ cong (_+ z) y≡u+v ∙∙ sym (+Assoc _ _ _) ∣) +iAssoc : ∀ (I J K : CommIdeal) → I +i (J +i K) ≡ (I +i J) +i K +iAssoc I J K = CommIdeal≡Char (+iAssocLIncl I J K) (+iAssocRIncl I J K) +iIdemLIncl : ∀ (I : CommIdeal) → (I +i I) ⊆ I +iIdemLIncl I x = rec (I .fst x .snd) λ ((y , z) , y∈I , z∈I , x≡y+z) → subst-∈ I (sym x≡y+z) (I .snd .+Closed y∈I z∈I) +iIdemRIncl : ∀ (I : CommIdeal) → I ⊆ (I +i I) +iIdemRIncl I x x∈I = ∣ (0r , x) , I .snd .contains0 , x∈I , sym (+Lid _) ∣ +iIdem : ∀ (I : CommIdeal) → I +i I ≡ I +iIdem I = CommIdeal≡Char (+iIdemLIncl I) (+iIdemRIncl I) -- where to put this? mul++dist : ∀ {n m : ℕ} (α U : FinVec R n) (β V : FinVec R m) (j : Fin (n +ℕ m)) → ((λ i → α i · U i) ++Fin (λ i → β i · V i)) j ≡ (α ++Fin β) j · (U ++Fin V) j mul++dist {n = zero} α U β V j = refl mul++dist {n = suc n} α U β V zero = refl mul++dist {n = suc n} α U β V (suc j) = mul++dist (α ∘ suc) (U ∘ suc) β V j -- define multiplication of ideals _·i_ : CommIdeal → CommIdeal → CommIdeal fst (I ·i J) x = (∃[ n ∈ ℕ ] Σ[ (α , β) ∈ (FinVec R n × FinVec R n) ] (∀ i → α i ∈ I) × (∀ i → β i ∈ J) × (x ≡ ∑ λ i → α i · β i)) , isPropPropTrunc +Closed (snd (I ·i J)) = map2 λ (n , (α , β) , ∀αi∈I , ∀βi∈J , x≡∑αβ) (m , (γ , δ) , ∀γi∈I , ∀δi∈J , y≡∑γδ) → n +ℕ m , (α ++Fin γ , β ++Fin δ) , ++FinPres∈ (I .fst) ∀αi∈I ∀γi∈I , ++FinPres∈ (J .fst) ∀βi∈J ∀δi∈J , cong₂ (_+_) x≡∑αβ y≡∑γδ ∙∙ sym (∑Split++ (λ i → α i · β i) (λ i → γ i · δ i)) ∙∙ ∑Ext (mul++dist α β γ δ) contains0 (snd (I ·i J)) = ∣ 0 , ((λ ()) , (λ ())) , (λ ()) , (λ ()) , refl ∣ ·Closed (snd (I ·i J)) r = map λ (n , (α , β) , ∀αi∈I , ∀βi∈J , x≡∑αβ) → n , ((λ i → r · α i) , β) , (λ i → I .snd .·Closed r (∀αi∈I i)) , ∀βi∈J , cong (r ·_) x≡∑αβ ∙ ∑Mulrdist r (λ i → α i · β i) ∙ ∑Ext λ i → ·Assoc r (α i) (β i) infixl 7 _·i_ prodInProd : ∀ (I J : CommIdeal) (x y : R) → x ∈ I → y ∈ J → (x · y) ∈ (I ·i J) prodInProd _ _ x y x∈I y∈J = ∣ 1 , ((λ _ → x) , λ _ → y) , (λ _ → x∈I) , (λ _ → y∈J) , sym (+Rid _) ∣ ·iLincl : ∀ (I J : CommIdeal) → (I ·i J) ⊆ I ·iLincl I J x = elim (λ _ → I .fst x .snd) λ (_ , (α , β) , α∈I , _ , x≡∑αβ) → subst-∈ I (sym x≡∑αβ) (∑Closed I (λ i → α i · β i) λ i → ·RClosed (I .snd) _ (α∈I i)) ·iComm⊆ : ∀ (I J : CommIdeal) → (I ·i J) ⊆ (J ·i I) ·iComm⊆ I J x = map λ (n , (α , β) , ∀αi∈I , ∀βi∈J , x≡∑αβ) → (n , (β , α) , ∀βi∈J , ∀αi∈I , x≡∑αβ ∙ ∑Ext (λ i → ·-comm (α i) (β i))) ·iComm : ∀ (I J : CommIdeal) → I ·i J ≡ J ·i I ·iComm I J = CommIdeal≡Char (·iComm⊆ I J) (·iComm⊆ J I) I⊆I1 : ∀ (I : CommIdeal) → I ⊆ (I ·i 1Ideal) I⊆I1 I x x∈I = ∣ 1 , ((λ _ → x) , λ _ → 1r) , (λ _ → x∈I) , (λ _ → lift tt) , useSolver x ∣ where useSolver : ∀ x → x ≡ x · 1r + 0r useSolver = solve R' ·iRid : ∀ (I : CommIdeal) → I ·i 1Ideal ≡ I ·iRid I = CommIdeal≡Char (·iLincl I 1Ideal) (I⊆I1 I) -- a useful corollary ·iRContains1id : ∀ (I J : CommIdeal) → 1r ∈ J → I ·i J ≡ I ·iRContains1id I J 1∈J = cong (I ·i_) (contains1Is1 J 1∈J) ∙ ·iRid I ·iAssocLIncl : ∀ (I J K : CommIdeal) → (I ·i (J ·i K)) ⊆ ((I ·i J) ·i K) ·iAssocLIncl I J K x = rec isPropPropTrunc λ (_ , (α , β) , α∈I , β∈JK , x≡∑αβ) → subst-∈ ((I ·i J) ·i K) (sym x≡∑αβ) (∑Closed ((I ·i J) ·i K) (λ i → α i · β i) λ i → rec isPropPropTrunc (λ (_ , (γ , δ) , γ∈J , δ∈K , βi≡∑γδ) → subst-∈ ((I ·i J) ·i K) -- each αᵢβᵢ ≡...≡ ∑αᵢγⱼδⱼ ∈IJK (sym (cong (α i ·_) βi≡∑γδ ∙∙ ∑Mulrdist (α i) (λ j → γ j · δ j) ∙∙ ∑Ext (λ j → ·Assoc (α i) (γ j) (δ j)))) (∑Closed ((I ·i J) ·i K) (λ j → α i · γ j · δ j) -- each αᵢγⱼδⱼ∈IJK λ j → prodInProd (I ·i J) K _ _ (prodInProd I J _ _ (α∈I i) (γ∈J j)) (δ∈K j))) (β∈JK i)) ·iAssocRIncl : ∀ (I J K : CommIdeal) → ((I ·i J) ·i K) ⊆ (I ·i (J ·i K)) ·iAssocRIncl I J K x = rec isPropPropTrunc λ (_ , (α , β) , α∈IJ , β∈K , x≡∑αβ) → subst-∈ (I ·i (J ·i K)) (sym x≡∑αβ) (∑Closed (I ·i (J ·i K)) (λ i → α i · β i) λ i → rec isPropPropTrunc (λ (_ , (γ , δ) , γ∈I , δ∈J , αi≡∑γδ) → subst-∈ (I ·i (J ·i K)) (sym (cong (_· β i) αi≡∑γδ ∙∙ ∑Mulldist (β i) (λ j → γ j · δ j) ∙∙ ∑Ext (λ j → sym (·Assoc (γ j) (δ j) (β i))))) (∑Closed (I ·i (J ·i K)) (λ j → γ j · (δ j · β i)) λ j → prodInProd I (J ·i K) _ _ (γ∈I j) (prodInProd J K _ _ (δ∈J j) (β∈K i)))) (α∈IJ i)) ·iAssoc : ∀ (I J K : CommIdeal) → I ·i (J ·i K) ≡ (I ·i J) ·i K ·iAssoc I J K = CommIdeal≡Char (·iAssocLIncl I J K) (·iAssocRIncl I J K) ·iRdist+iLIncl : ∀ (I J K : CommIdeal) → (I ·i (J +i K)) ⊆ (I ·i J +i I ·i K) ·iRdist+iLIncl I J K x = rec isPropPropTrunc λ (n , (α , β) , α∈I , β∈J+K , x≡∑αβ) → subst-∈ ((I ·i J) +i (I ·i K)) (sym x≡∑αβ) (∑Closed ((I ·i J) +i (I ·i K)) (λ i → α i · β i) -- each αi·βi ∈ IJ+IK λ i → rec isPropPropTrunc (λ ((γi , δi) , γi∈J , δi∈K , βi≡γi+δi) → ∣ (α i · γi , α i · δi) , prodInProd I J _ _ (α∈I i) γi∈J , prodInProd I K _ _ (α∈I i) δi∈K , cong (α i ·_) βi≡γi+δi ∙ ·Rdist+ _ _ _ ∣) (β∈J+K i)) ·iRdist+iRIncl : ∀ (I J K : CommIdeal) → ((I ·i J) +i (I ·i K)) ⊆ (I ·i (J +i K)) ·iRdist+iRIncl I J K x = rec isPropPropTrunc λ ((y , z) , y∈IJ , z∈IK , x≡y+z) → subst-∈ (I ·i (J +i K)) (sym x≡y+z) ((I ·i (J +i K)) .snd .+Closed (inclHelperLeft _ y∈IJ) (inclHelperRight _ z∈IK)) where inclHelperLeft : (I ·i J) ⊆ (I ·i (J +i K)) inclHelperLeft x' = map (λ (n , (α , β) , α∈I , β∈J , x'≡∑αβ) → n , (α , β) , α∈I , (λ i → +iLincl J K _ (β∈J i)) , x'≡∑αβ) inclHelperRight : (I ·i K) ⊆ (I ·i (J +i K)) inclHelperRight x' = map (λ (n , (α , β) , α∈I , β∈K , x'≡∑αβ) → n , (α , β) , α∈I , (λ i → +iRincl J K _ (β∈K i)) , x'≡∑αβ) ·iRdist+i : ∀ (I J K : CommIdeal) → I ·i (J +i K) ≡ I ·i J +i I ·i K ·iRdist+i I J K = CommIdeal≡Char (·iRdist+iLIncl I J K) (·iRdist+iRIncl I J K) -- only one absorption law, i.e. CommIdeal , +i , ·i does not form a dist. lattice ·iAbsorb+iLIncl : ∀ (I J : CommIdeal) → (I +i (I ·i J)) ⊆ I ·iAbsorb+iLIncl I J x = rec (I .fst x .snd) λ ((y , z) , y∈I , z∈IJ , x≡y+z) → subst-∈ I (sym x≡y+z) (I .snd .+Closed y∈I (·iLincl I J _ z∈IJ)) ·iAbsorb+iRIncl : ∀ (I J : CommIdeal) → I ⊆ (I +i (I ·i J)) ·iAbsorb+iRIncl I J = +iLincl I (I ·i J) ·iAbsorb+i : ∀ (I J : CommIdeal) → I +i (I ·i J) ≡ I ·iAbsorb+i I J = CommIdeal≡Char (·iAbsorb+iLIncl I J) (·iAbsorb+iRIncl I J)
{ "alphanum_fraction": 0.4590778884, "avg_line_length": 44.5653495441, "ext": "agda", "hexsha": "c8b368dcecdd427428b765a8ba4a81c6d565773b", "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": "8d687c1a6237ad2db1396c6b0af6667bd203f548", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dolio/cubical", "max_forks_repo_path": "Cubical/Algebra/CommRing/Ideal.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8d687c1a6237ad2db1396c6b0af6667bd203f548", "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": "dolio/cubical", "max_issues_repo_path": "Cubical/Algebra/CommRing/Ideal.agda", "max_line_length": 100, "max_stars_count": null, "max_stars_repo_head_hexsha": "8d687c1a6237ad2db1396c6b0af6667bd203f548", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dolio/cubical", "max_stars_repo_path": "Cubical/Algebra/CommRing/Ideal.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 6743, "size": 14662 }
------------------------------------------------------------------------ -- Convenient syntax for "equational reasoning" using a partial order ------------------------------------------------------------------------ open import Relation.Binary module Relation.Binary.PartialOrderReasoning (p : Poset) where open Poset p import Relation.Binary.PreorderReasoning as PreR open PreR preorder public renaming (_∼⟨_⟩_ to _≤⟨_⟩_)
{ "alphanum_fraction": 0.5234741784, "avg_line_length": 35.5, "ext": "agda", "hexsha": "086217fd762f3106ba1944639ec5c62090a11961", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_path": "vendor/stdlib/src/Relation/Binary/PartialOrderReasoning.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_path": "vendor/stdlib/src/Relation/Binary/PartialOrderReasoning.agda", "max_line_length": 72, "max_stars_count": 56, "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_path": "vendor/stdlib/src/Relation/Binary/PartialOrderReasoning.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "num_tokens": 78, "size": 426 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category.Monoidal -- Monoidal natural transformations between lax and strong monoidal functors. -- -- See -- * John Baez, Some definitions everyone should know, -- https://math.ucr.edu/home/baez/qg-fall2004/definitions.pdf -- * https://ncatlab.org/nlab/show/monoidal+natural+transformation module Categories.NaturalTransformation.Monoidal where open import Level open import Data.Product using (_,_) open import Categories.Category using (module Commutation) open import Categories.Category.Product import Categories.Category.Monoidal.Reasoning as MonoidalReasoning open import Categories.Functor.Monoidal open import Categories.Functor.Monoidal.Properties using () renaming (∘-Monoidal to _∘Fˡ_; ∘-StrongMonoidal to _∘Fˢ_) import Categories.Morphism as Morphism import Categories.Morphism.Reasoning as MorphismReasoning open import Categories.NaturalTransformation as NT using (NaturalTransformation) open NaturalTransformation renaming (η to _[_]) module Lax where module _ {o ℓ e o′ ℓ′ e′} {C : MonoidalCategory o ℓ e} {D : MonoidalCategory o′ ℓ′ e′} (F G : MonoidalFunctor C D) where private module C = MonoidalCategory C module D = MonoidalCategory D module F = MonoidalFunctor F renaming (F to U) module G = MonoidalFunctor G renaming (F to U) open D hiding (U; id) open Commutation D.U -- Monoidal natural transformations between lax monoidal functors. record IsMonoidalNaturalTransformation (β : NaturalTransformation F.U G.U) : Set (o ⊔ ℓ′ ⊔ e′) where field ε-compat : [ unit ⇒ G.₀ C.unit ]⟨ F.ε ⇒⟨ F.₀ C.unit ⟩ β [ C.unit ] ≈ G.ε ⟩ ⊗-homo-compat : ∀ {X Y} → [ F.₀ X ⊗₀ F.₀ Y ⇒ G.₀ (X C.⊗₀ Y) ]⟨ F.⊗-homo [ (X , Y) ] ⇒⟨ F.₀ (X C.⊗₀ Y) ⟩ β [ X C.⊗₀ Y ] ≈ β [ X ] ⊗₁ β [ Y ] ⇒⟨ G.₀ X ⊗₀ G.₀ Y ⟩ G.⊗-homo [ (X , Y) ] ⟩ record MonoidalNaturalTransformation : Set (o ⊔ ℓ ⊔ ℓ′ ⊔ e′) where field U : NaturalTransformation F.U G.U isMonoidal : IsMonoidalNaturalTransformation U open NaturalTransformation U public open IsMonoidalNaturalTransformation isMonoidal public -- To shorten some definitions private _⇛_ = MonoidalNaturalTransformation -- Identity and compositions module _ {o ℓ e o′ ℓ′ e′} {C : MonoidalCategory o ℓ e} {D : MonoidalCategory o′ ℓ′ e′} where private module C = MonoidalCategory C module D = MonoidalCategory D open D hiding (U; id) open MorphismReasoning D.U open MonoidalReasoning D.monoidal infixr 9 _∘ᵥ_ id : {F : MonoidalFunctor C D} → F ⇛ F id {F} = record { U = NT.id ; isMonoidal = record { ε-compat = D.identityˡ ; ⊗-homo-compat = λ {X Y} → begin D.id ∘ ⊗-homo.η (X , Y) ≈⟨ id-comm-sym ⟩ ⊗-homo.η (X , Y) ∘ D.id ≈˘⟨ refl⟩∘⟨ ⊗.identity ⟩ ⊗-homo.η (X , Y) ∘ D.id ⊗₁ D.id ∎ } } where open MonoidalFunctor F _∘ᵥ_ : {F G H : MonoidalFunctor C D} → G ⇛ H → F ⇛ G → F ⇛ H _∘ᵥ_ {F} {G} {H} αᵐ βᵐ = record { U = α NT.∘ᵥ β ; isMonoidal = record { ε-compat = begin (α [ _ ] ∘ β [ _ ]) ∘ F.ε ≈⟨ pullʳ (ε-compat βᵐ) ⟩ α [ _ ] ∘ G.ε ≈⟨ ε-compat αᵐ ⟩ H.ε ∎ ; ⊗-homo-compat = λ {X Y} → begin (α [ X C.⊗₀ Y ] ∘ β [ X C.⊗₀ Y ]) ∘ F.⊗-homo.η (X , Y) ≈⟨ pullʳ (⊗-homo-compat βᵐ) ⟩ α [ X C.⊗₀ Y ] ∘ G.⊗-homo.η (X , Y) ∘ β [ X ] ⊗₁ β [ Y ] ≈⟨ extendʳ (⊗-homo-compat αᵐ) ⟩ H.⊗-homo.η (X , Y) ∘ α [ X ] ⊗₁ α [ Y ] ∘ β [ X ] ⊗₁ β [ Y ] ≈˘⟨ refl⟩∘⟨ ⊗-distrib-over-∘ ⟩ H.⊗-homo.η (X , Y) ∘ (α [ X ] ∘ β [ X ]) ⊗₁ (α [ Y ] ∘ β [ Y ]) ∎ } } where open MonoidalNaturalTransformation α = U αᵐ β = U βᵐ module F = MonoidalFunctor F module G = MonoidalFunctor G module H = MonoidalFunctor H module _ {o ℓ e o′ ℓ′ e′ o″ ℓ″ e″} {C : MonoidalCategory o ℓ e} {D : MonoidalCategory o′ ℓ′ e′} {E : MonoidalCategory o″ ℓ″ e″} where private module C = MonoidalCategory C module D = MonoidalCategory D module E = MonoidalCategory E open E hiding (U; id) open MorphismReasoning E.U open MonoidalReasoning E.monoidal infixr 9 _∘ₕ_ _∘ˡ_ _∘ʳ_ _∘ₕ_ : {F G : MonoidalFunctor C D} {H I : MonoidalFunctor D E} → H ⇛ I → F ⇛ G → (H ∘Fˡ F) ⇛ (I ∘Fˡ G) _∘ₕ_ {F} {G} {H} {I} αᵐ βᵐ = record { U = α NT.∘ₕ β ; isMonoidal = record { ε-compat = begin (I.₁ (β [ C.unit ]) ∘ α [ F.₀ C.unit ]) ∘ H.₁ F.ε ∘ H.ε ≈⟨ extend² (commute αᵐ F.ε) ⟩ (I.₁ (β [ C.unit ]) ∘ I.₁ F.ε) ∘ α [ D.unit ] ∘ H.ε ≈˘⟨ I.homomorphism ⟩∘⟨refl ⟩ I.₁ (β [ C.unit ] D.∘ F.ε) ∘ α [ D.unit ] ∘ H.ε ≈⟨ I.F-resp-≈ (ε-compat βᵐ) ⟩∘⟨ ε-compat αᵐ ⟩ I.F₁ G.ε ∘ I.ε ∎ ; ⊗-homo-compat = λ {X Y} → begin (I.₁ (β [ X C.⊗₀ Y ]) ∘ α [ F.₀ (X C.⊗₀ Y) ]) ∘ H.₁ (F.⊗-homo.η (X , Y)) ∘ H.⊗-homo.η (F.₀ X , F.₀ Y) ≈⟨ extend² (commute αᵐ (F.⊗-homo.η (X , Y))) ⟩ (I.₁ (β [ X C.⊗₀ Y ]) ∘ I.₁ (F.⊗-homo.η (X , Y))) ∘ α [ F.₀ X D.⊗₀ F.₀ Y ] ∘ H.⊗-homo.η (F.₀ X , F.₀ Y) ≈˘⟨ I.homomorphism ⟩∘⟨refl ⟩ (I.₁ (β [ X C.⊗₀ Y ] D.∘ F.⊗-homo.η (X , Y))) ∘ α [ F.₀ X D.⊗₀ F.₀ Y ] ∘ H.⊗-homo.η (F.₀ X , F.₀ Y) ≈⟨ (I.F-resp-≈ (⊗-homo-compat βᵐ) ⟩∘⟨ ⊗-homo-compat αᵐ) ⟩ (I.₁ (G.⊗-homo.η (X , Y) D.∘ β [ X ] D.⊗₁ β [ Y ])) ∘ I.⊗-homo.η (F.₀ X , F.₀ Y) ∘ α [ F.₀ X ] ⊗₁ α [ F.₀ Y ] ≈⟨ I.homomorphism ⟩∘⟨refl ⟩ (I.₁ (G.⊗-homo.η (X , Y)) ∘ I.₁ (β [ X ] D.⊗₁ β [ Y ])) ∘ I.⊗-homo.η (F.₀ X , F.₀ Y) ∘ α [ F.₀ X ] ⊗₁ α [ F.₀ Y ] ≈˘⟨ extend² (I.⊗-homo.commute ((β [ X ]) , (β [ Y ]))) ⟩ (I.₁ (G.⊗-homo.η (X , Y)) ∘ I.⊗-homo.η (G.₀ X , G.₀ Y)) ∘ I.₁ (β [ X ]) ⊗₁ I.₁ (β [ Y ]) ∘ α [ F.₀ X ] ⊗₁ α [ F.₀ Y ] ≈˘⟨ refl⟩∘⟨ ⊗-distrib-over-∘ ⟩ (I.₁ (G.⊗-homo.η (X , Y)) ∘ I.⊗-homo.η (G.₀ X , G.₀ Y)) ∘ (I.₁ (β [ X ]) ∘ α [ F.₀ X ]) ⊗₁ (I.₁ (β [ Y ]) ∘ α [ F.₀ Y ]) ∎ } } where open MonoidalNaturalTransformation α = U αᵐ β = U βᵐ module F = MonoidalFunctor F module G = MonoidalFunctor G module H = MonoidalFunctor H module I = MonoidalFunctor I _∘ˡ_ : {F G : MonoidalFunctor C D} (H : MonoidalFunctor D E) → F ⇛ G → (H ∘Fˡ F) ⇛ (H ∘Fˡ G) H ∘ˡ α = id {F = H} ∘ₕ α _∘ʳ_ : {G H : MonoidalFunctor D E} → G ⇛ H → (F : MonoidalFunctor C D) → (G ∘Fˡ F) ⇛ (H ∘Fˡ F) α ∘ʳ F = α ∘ₕ id {F = F} module Strong where open StrongMonoidalFunctor using () renaming (F to UF; monoidalFunctor to laxF) module _ {o ℓ e o′ ℓ′ e′} {C : MonoidalCategory o ℓ e} {D : MonoidalCategory o′ ℓ′ e′} (F G : StrongMonoidalFunctor C D) where -- Monoidal natural transformations between strong monoidal functors. IsMonoidalNaturalTransformation : NaturalTransformation (UF F) (UF G) → Set (o ⊔ ℓ′ ⊔ e′) IsMonoidalNaturalTransformation α = Lax.IsMonoidalNaturalTransformation (laxF F) (laxF G) α -- NOTE. This record contains the same data as the lax version, -- but the type arguments are different. This helps type -- inference by providing the right constraints. record MonoidalNaturalTransformation : Set (o ⊔ ℓ ⊔ ℓ′ ⊔ e′) where field U : NaturalTransformation (UF F) (UF G) isMonoidal : IsMonoidalNaturalTransformation U laxNT : Lax.MonoidalNaturalTransformation (laxF F) (laxF G) laxNT = record { U = U ; isMonoidal = isMonoidal } open Lax.MonoidalNaturalTransformation laxNT public hiding (U; isMonoidal) private _⇛_ = MonoidalNaturalTransformation open MonoidalNaturalTransformation module _ {o ℓ e o′ ℓ′ e′} {C : MonoidalCategory o ℓ e} {D : MonoidalCategory o′ ℓ′ e′} where infixr 9 _∘ᵥ_ -- Since they contain the same data, we can strengthen a lax -- monoidal transformation to a strong one. strengthen : {F G : StrongMonoidalFunctor C D} → Lax.MonoidalNaturalTransformation (laxF F) (laxF G) → F ⇛ G strengthen α = record { U = L.U ; isMonoidal = L.isMonoidal } where module L = Lax.MonoidalNaturalTransformation α -- Identity and compositions id : {F : StrongMonoidalFunctor C D} → F ⇛ F id = strengthen Lax.id _∘ᵥ_ : {F G H : StrongMonoidalFunctor C D} → G ⇛ H → F ⇛ G → F ⇛ H α ∘ᵥ β = strengthen (laxNT α Lax.∘ᵥ laxNT β) module _ {o ℓ e o′ ℓ′ e′ o″ ℓ″ e″} {C : MonoidalCategory o ℓ e} {D : MonoidalCategory o′ ℓ′ e′} {E : MonoidalCategory o″ ℓ″ e″} where open Lax.MonoidalNaturalTransformation infixr 9 _∘ₕ_ _∘ˡ_ _∘ʳ_ _∘ₕ_ : {F G : StrongMonoidalFunctor C D} {H I : StrongMonoidalFunctor D E} → H ⇛ I → F ⇛ G → (H ∘Fˢ F) ⇛ (I ∘Fˢ G) -- FIXME: this definition is clearly equivalent to -- -- α ∘ₕ β = strengthen (laxNT α Lax.∘ₕ laxNT β) -- -- but the latter takes an unreasonably long time to typecheck, -- while the unfolded version typechecks almost immediately. α ∘ₕ β = record { U = L.U ; isMonoidal = record { ε-compat = L.ε-compat ; ⊗-homo-compat = L.⊗-homo-compat } } where module L = Lax.MonoidalNaturalTransformation (laxNT α Lax.∘ₕ laxNT β) _∘ˡ_ : {F G : StrongMonoidalFunctor C D} (H : StrongMonoidalFunctor D E) → F ⇛ G → (H ∘Fˢ F) ⇛ (H ∘Fˢ G) H ∘ˡ α = id {F = H} ∘ₕ α _∘ʳ_ : {G H : StrongMonoidalFunctor D E} → G ⇛ H → (F : StrongMonoidalFunctor C D) → (G ∘Fˢ F) ⇛ (H ∘Fˢ F) α ∘ʳ F = α ∘ₕ id {F = F}
{ "alphanum_fraction": 0.514524015, "avg_line_length": 37.2535714286, "ext": "agda", "hexsha": "11d0e5c2bae4168d0fe1dd8abb012a552690d2b6", "lang": "Agda", "max_forks_count": 64, "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/NaturalTransformation/Monoidal.agda", "max_issues_count": 236, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/NaturalTransformation/Monoidal.agda", "max_line_length": 80, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/NaturalTransformation/Monoidal.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "num_tokens": 4047, "size": 10431 }
import Lvl open import Type module Structure.Logic.Constructive.Functions {ℓₒ} (Domain : Type{ℓₒ}) where private module Meta where open import Numeral.Finite public open import Numeral.Natural public -- The type of a function. Functions on the domain in the meta-logic. Function : Type{_} Function = (Domain → Domain) BinaryOperator : Type{_} BinaryOperator = (Domain → Domain → Domain) Tuple : Meta.ℕ → Type{_} Tuple(n) = Meta.𝕟(n) → Domain Sequence : Type{_} Sequence = Meta.ℕ → Domain
{ "alphanum_fraction": 0.6835205993, "avg_line_length": 23.2173913043, "ext": "agda", "hexsha": "75214ba856d9a025b651a1bb2d8063ad0081062b", "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/Constructive/Functions.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "old/Structure/Logic/Constructive/Functions.agda", "max_line_length": 76, "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/Constructive/Functions.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 145, "size": 534 }
{-# OPTIONS --without-K --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.Untyped as U open import Definition.Untyped.Properties open import Definition.Typed.Properties open import Definition.Typed open import Definition.Typed.Weakening open import Tools.Product import Tools.PropositionalEquality as PE -- The different cases of the logical relation are spread out through out -- this file. This is due to them having different dependencies. -- We will refer to expressions that satisfies the logical relation as reducible. -- Reducibility of Neutrals: -- Neutral type record _⊩ne_ (Γ : Con Term) (A : Term) : Set where constructor ne field K : Term D : Γ ⊢ A :⇒*: K neK : Neutral K K≡K : Γ ⊢ K ~ K ∷ U -- Neutral type equality record _⊩ne_≡_/_ (Γ : Con Term) (A B : Term) ([A] : Γ ⊩ne A) : Set where constructor ne₌ open _⊩ne_ [A] field M : Term D′ : Γ ⊢ B :⇒*: M neM : Neutral M K≡M : Γ ⊢ K ~ M ∷ U -- Neutral term in WHNF record _⊩neNf_∷_ (Γ : Con Term) (k A : Term) : Set where inductive constructor neNfₜ field neK : Neutral k ⊢k : Γ ⊢ k ∷ A k≡k : Γ ⊢ k ~ k ∷ A -- Neutral term record _⊩ne_∷_/_ (Γ : Con Term) (t A : Term) ([A] : Γ ⊩ne A) : Set where inductive constructor neₜ open _⊩ne_ [A] field k : Term d : Γ ⊢ t :⇒*: k ∷ K nf : Γ ⊩neNf k ∷ K -- Neutral term equality in WHNF record _⊩neNf_≡_∷_ (Γ : Con Term) (k m A : Term) : Set where inductive constructor neNfₜ₌ field neK : Neutral k neM : Neutral m k≡m : Γ ⊢ k ~ m ∷ A -- Neutral term equality record _⊩ne_≡_∷_/_ (Γ : Con Term) (t u A : Term) ([A] : Γ ⊩ne A) : Set where constructor neₜ₌ open _⊩ne_ [A] field k m : Term d : Γ ⊢ t :⇒*: k ∷ K d′ : Γ ⊢ u :⇒*: m ∷ K nf : Γ ⊩neNf k ≡ m ∷ K -- Reducibility of natural numbers: -- Natural number type _⊩ℕ_ : (Γ : Con Term) (A : Term) → Set Γ ⊩ℕ A = Γ ⊢ A :⇒*: ℕ -- Natural number type equality _⊩ℕ_≡_ : (Γ : Con Term) (A B : Term) → Set Γ ⊩ℕ A ≡ B = Γ ⊢ B ⇒* ℕ mutual -- Natural number term record _⊩ℕ_∷ℕ (Γ : Con Term) (t : Term) : Set where inductive constructor ℕₜ field n : Term d : Γ ⊢ t :⇒*: n ∷ ℕ n≡n : Γ ⊢ n ≅ n ∷ ℕ prop : Natural-prop Γ n -- WHNF property of natural number terms data Natural-prop (Γ : Con Term) : (n : Term) → Set where sucᵣ : ∀ {n} → Γ ⊩ℕ n ∷ℕ → Natural-prop Γ (suc n) zeroᵣ : Natural-prop Γ zero ne : ∀ {n} → Γ ⊩neNf n ∷ ℕ → Natural-prop Γ n mutual -- Natural number term equality record _⊩ℕ_≡_∷ℕ (Γ : Con Term) (t u : Term) : Set where inductive constructor ℕₜ₌ field k k′ : Term d : Γ ⊢ t :⇒*: k ∷ ℕ d′ : Γ ⊢ u :⇒*: k′ ∷ ℕ k≡k′ : Γ ⊢ k ≅ k′ ∷ ℕ prop : [Natural]-prop Γ k k′ -- WHNF property of Natural number term equality data [Natural]-prop (Γ : Con Term) : (n n′ : Term) → Set where sucᵣ : ∀ {n n′} → Γ ⊩ℕ n ≡ n′ ∷ℕ → [Natural]-prop Γ (suc n) (suc n′) zeroᵣ : [Natural]-prop Γ zero zero ne : ∀ {n n′} → Γ ⊩neNf n ≡ n′ ∷ ℕ → [Natural]-prop Γ n n′ -- Natural extraction from term WHNF property natural : ∀ {Γ n} → Natural-prop Γ n → Natural n natural (sucᵣ x) = sucₙ natural zeroᵣ = zeroₙ natural (ne (neNfₜ neK ⊢k k≡k)) = ne neK -- Natural extraction from term equality WHNF property split : ∀ {Γ a b} → [Natural]-prop Γ a b → Natural a × Natural b split (sucᵣ x) = sucₙ , sucₙ split zeroᵣ = zeroₙ , zeroₙ split (ne (neNfₜ₌ neK neM k≡m)) = ne neK , ne neM -- Reducibility of Empty -- Empty type _⊩Empty_ : (Γ : Con Term) (A : Term) → Set Γ ⊩Empty A = Γ ⊢ A :⇒*: Empty -- Empty type equality _⊩Empty_≡_ : (Γ : Con Term) (A B : Term) → Set Γ ⊩Empty A ≡ B = Γ ⊢ B ⇒* Empty -- WHNF property of absurd terms data Empty-prop (Γ : Con Term) : (n : Term) → Set where ne : ∀ {n} → Γ ⊩neNf n ∷ Empty → Empty-prop Γ n -- Empty term record _⊩Empty_∷Empty (Γ : Con Term) (t : Term) : Set where inductive constructor Emptyₜ field n : Term d : Γ ⊢ t :⇒*: n ∷ Empty n≡n : Γ ⊢ n ≅ n ∷ Empty prop : Empty-prop Γ n data [Empty]-prop (Γ : Con Term) : (n n′ : Term) → Set where ne : ∀ {n n′} → Γ ⊩neNf n ≡ n′ ∷ Empty → [Empty]-prop Γ n n′ -- Empty term equality record _⊩Empty_≡_∷Empty (Γ : Con Term) (t u : Term) : Set where inductive constructor Emptyₜ₌ field k k′ : Term d : Γ ⊢ t :⇒*: k ∷ Empty d′ : Γ ⊢ u :⇒*: k′ ∷ Empty k≡k′ : Γ ⊢ k ≅ k′ ∷ Empty prop : [Empty]-prop Γ k k′ empty : ∀ {Γ n} → Empty-prop Γ n → Neutral n empty (ne (neNfₜ neK _ _)) = neK esplit : ∀ {Γ a b} → [Empty]-prop Γ a b → Neutral a × Neutral b esplit (ne (neNfₜ₌ neK neM k≡m)) = neK , neM -- Reducibility of Unit -- Unit type _⊩Unit_ : (Γ : Con Term) (A : Term) → Set Γ ⊩Unit A = Γ ⊢ A :⇒*: Unit -- Unit type equality _⊩Unit_≡_ : (Γ : Con Term) (A B : Term) → Set Γ ⊩Unit A ≡ B = Γ ⊢ B ⇒* Unit record _⊩Unit_∷Unit (Γ : Con Term) (t : Term) : Set where inductive constructor Unitₜ field n : Term d : Γ ⊢ t :⇒*: n ∷ Unit prop : Whnf n -- Unit term equality record _⊩Unit_≡_∷Unit (Γ : Con Term) (t u : Term) : Set where constructor Unitₜ₌ field ⊢t : Γ ⊢ t ∷ Unit ⊢u : Γ ⊢ u ∷ Unit -- Type levels data TypeLevel : Set where ⁰ : TypeLevel ¹ : TypeLevel data _<_ : (i j : TypeLevel) → Set where 0<1 : ⁰ < ¹ -- Logical relation -- Exported interface record LogRelKit : Set₁ where constructor Kit field _⊩U : (Γ : Con Term) → Set _⊩B⟨_⟩_ : (Γ : Con Term) (W : BindingType) → Term → Set _⊩_ : (Γ : Con Term) → Term → Set _⊩_≡_/_ : (Γ : Con Term) (A B : Term) → Γ ⊩ A → Set _⊩_∷_/_ : (Γ : Con Term) (t A : Term) → Γ ⊩ A → Set _⊩_≡_∷_/_ : (Γ : Con Term) (t u A : Term) → Γ ⊩ A → Set module LogRel (l : TypeLevel) (rec : ∀ {l′} → l′ < l → LogRelKit) where -- Reducibility of Universe: -- Universe type record _⊩¹U (Γ : Con Term) : Set where constructor Uᵣ field l′ : TypeLevel l< : l′ < l ⊢Γ : ⊢ Γ -- Universe type equality _⊩¹U≡_ : (Γ : Con Term) (B : Term) → Set Γ ⊩¹U≡ B = B PE.≡ U -- Note lack of reduction -- Universe term record _⊩¹U_∷U/_ {l′} (Γ : Con Term) (t : Term) (l< : l′ < l) : Set where constructor Uₜ open LogRelKit (rec l<) field A : Term d : Γ ⊢ t :⇒*: A ∷ U typeA : Type A A≡A : Γ ⊢ A ≅ A ∷ U [t] : Γ ⊩ t -- Universe term equality record _⊩¹U_≡_∷U/_ {l′} (Γ : Con Term) (t u : Term) (l< : l′ < l) : Set where constructor Uₜ₌ open LogRelKit (rec l<) field A B : Term d : Γ ⊢ t :⇒*: A ∷ U d′ : Γ ⊢ u :⇒*: B ∷ U typeA : Type A typeB : Type B A≡B : Γ ⊢ A ≅ B ∷ U [t] : Γ ⊩ t [u] : Γ ⊩ u [t≡u] : Γ ⊩ t ≡ u / [t] mutual -- Reducibility of Binding types (Π, Σ): -- B-type record _⊩¹B⟨_⟩_ (Γ : Con Term) (W : BindingType) (A : Term) : Set where inductive constructor Bᵣ field F : Term G : Term D : Γ ⊢ A :⇒*: ⟦ W ⟧ F ▹ G ⊢F : Γ ⊢ F ⊢G : Γ ∙ F ⊢ G A≡A : Γ ⊢ ⟦ W ⟧ F ▹ G ≅ ⟦ W ⟧ F ▹ G [F] : ∀ {ρ Δ} → ρ ∷ Δ ⊆ Γ → ⊢ Δ → Δ ⊩¹ U.wk ρ F [G] : ∀ {ρ Δ a} → ([ρ] : ρ ∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → Δ ⊩¹ a ∷ U.wk ρ F / [F] [ρ] ⊢Δ → Δ ⊩¹ U.wk (lift ρ) G [ a ] G-ext : ∀ {ρ Δ a b} → ([ρ] : ρ ∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → ([a] : Δ ⊩¹ a ∷ U.wk ρ F / [F] [ρ] ⊢Δ) → ([b] : Δ ⊩¹ b ∷ U.wk ρ F / [F] [ρ] ⊢Δ) → Δ ⊩¹ a ≡ b ∷ U.wk ρ F / [F] [ρ] ⊢Δ → Δ ⊩¹ U.wk (lift ρ) G [ a ] ≡ U.wk (lift ρ) G [ b ] / [G] [ρ] ⊢Δ [a] -- B-type equality record _⊩¹B⟨_⟩_≡_/_ (Γ : Con Term) (W : BindingType) (A B : Term) ([A] : Γ ⊩¹B⟨ W ⟩ A) : Set where inductive constructor B₌ open _⊩¹B⟨_⟩_ [A] field F′ : Term G′ : Term D′ : Γ ⊢ B ⇒* ⟦ W ⟧ F′ ▹ G′ A≡B : Γ ⊢ ⟦ W ⟧ F ▹ G ≅ ⟦ W ⟧ F′ ▹ G′ [F≡F′] : ∀ {ρ Δ} → ([ρ] : ρ ∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → Δ ⊩¹ U.wk ρ F ≡ U.wk ρ F′ / [F] [ρ] ⊢Δ [G≡G′] : ∀ {ρ Δ a} → ([ρ] : ρ ∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → ([a] : Δ ⊩¹ a ∷ U.wk ρ F / [F] [ρ] ⊢Δ) → Δ ⊩¹ U.wk (lift ρ) G [ a ] ≡ U.wk (lift ρ) G′ [ a ] / [G] [ρ] ⊢Δ [a] -- Term reducibility of Π-type _⊩¹Π_∷_/_ : (Γ : Con Term) (t A : Term) ([A] : Γ ⊩¹B⟨ BΠ ⟩ A) → Set Γ ⊩¹Π t ∷ A / Bᵣ F G D ⊢F ⊢G A≡A [F] [G] G-ext = ∃ λ f → Γ ⊢ t :⇒*: f ∷ Π F ▹ G × Function f × Γ ⊢ f ≅ f ∷ Π F ▹ G × (∀ {ρ Δ a b} ([ρ] : ρ ∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) ([a] : Δ ⊩¹ a ∷ U.wk ρ F / [F] [ρ] ⊢Δ) ([b] : Δ ⊩¹ b ∷ U.wk ρ F / [F] [ρ] ⊢Δ) ([a≡b] : Δ ⊩¹ a ≡ b ∷ U.wk ρ F / [F] [ρ] ⊢Δ) → Δ ⊩¹ U.wk ρ f ∘ a ≡ U.wk ρ f ∘ b ∷ U.wk (lift ρ) G [ a ] / [G] [ρ] ⊢Δ [a]) × (∀ {ρ Δ a} → ([ρ] : ρ ∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → ([a] : Δ ⊩¹ a ∷ U.wk ρ F / [F] [ρ] ⊢Δ) → Δ ⊩¹ U.wk ρ f ∘ a ∷ U.wk (lift ρ) G [ a ] / [G] [ρ] ⊢Δ [a]) {- NOTE(WN): Last 2 fields could be refactored to a single forall. But touching this definition is painful, so only do it if you have to change it anyway. -} -- Issue: Agda complains about record use not being strictly positive. -- Therefore we have to use × -- Term equality of Π-type _⊩¹Π_≡_∷_/_ : (Γ : Con Term) (t u A : Term) ([A] : Γ ⊩¹B⟨ BΠ ⟩ A) → Set Γ ⊩¹Π t ≡ u ∷ A / [A]@(Bᵣ F G D ⊢F ⊢G A≡A [F] [G] G-ext) = ∃₂ λ f g → Γ ⊢ t :⇒*: f ∷ Π F ▹ G × Γ ⊢ u :⇒*: g ∷ Π F ▹ G × Function f × Function g × Γ ⊢ f ≅ g ∷ Π F ▹ G × Γ ⊩¹Π t ∷ A / [A] × Γ ⊩¹Π u ∷ A / [A] × (∀ {ρ Δ a} ([ρ] : ρ ∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) ([a] : Δ ⊩¹ a ∷ U.wk ρ F / [F] [ρ] ⊢Δ) → Δ ⊩¹ U.wk ρ f ∘ a ≡ U.wk ρ g ∘ a ∷ U.wk (lift ρ) G [ a ] / [G] [ρ] ⊢Δ [a]) -- Issue: Same as above. -- Term reducibility of Σ-type _⊩¹Σ_∷_/_ : (Γ : Con Term) (t A : Term) ([A] : Γ ⊩¹B⟨ BΣ ⟩ A) → Set Γ ⊩¹Σ t ∷ A / [A]@(Bᵣ F G D ⊢F ⊢G A≡A [F] [G] G-ext) = ∃ λ p → Γ ⊢ t :⇒*: p ∷ Σ F ▹ G × Product p × Γ ⊢ p ≅ p ∷ Σ F ▹ G × (Σ (Γ ⊩¹ fst p ∷ U.wk id F / [F] id (wf ⊢F)) λ [fst] → Γ ⊩¹ snd p ∷ U.wk (lift id) G [ fst p ] / [G] id (wf ⊢F) [fst]) -- Term equality of Σ-type _⊩¹Σ_≡_∷_/_ : (Γ : Con Term) (t u A : Term) ([A] : Γ ⊩¹B⟨ BΣ ⟩ A) → Set Γ ⊩¹Σ t ≡ u ∷ A / [A]@(Bᵣ F G D ⊢F ⊢G A≡A [F] [G] G-ext) = ∃₂ λ p r → Γ ⊢ t :⇒*: p ∷ Σ F ▹ G × Γ ⊢ u :⇒*: r ∷ Σ F ▹ G × Product p × Product r × Γ ⊢ p ≅ r ∷ Σ F ▹ G × Γ ⊩¹Σ t ∷ A / [A] × Γ ⊩¹Σ u ∷ A / [A] × (Σ (Γ ⊩¹ fst p ∷ U.wk id F / [F] id (wf ⊢F)) λ [fstp] → Γ ⊩¹ fst r ∷ U.wk id F / [F] id (wf ⊢F) × Γ ⊩¹ fst p ≡ fst r ∷ U.wk id F / [F] id (wf ⊢F) × Γ ⊩¹ snd p ≡ snd r ∷ U.wk (lift id) G [ fst p ] / [G] id (wf ⊢F) [fstp]) -- Logical relation definition data _⊩¹_ (Γ : Con Term) : Term → Set where Uᵣ : Γ ⊩¹U → Γ ⊩¹ U ℕᵣ : ∀ {A} → Γ ⊩ℕ A → Γ ⊩¹ A Emptyᵣ : ∀ {A} → Γ ⊩Empty A → Γ ⊩¹ A Unitᵣ : ∀ {A} → Γ ⊩Unit A → Γ ⊩¹ A ne : ∀ {A} → Γ ⊩ne A → Γ ⊩¹ A Bᵣ : ∀ {A} W → Γ ⊩¹B⟨ W ⟩ A → Γ ⊩¹ A emb : ∀ {A l′} (l< : l′ < l) (let open LogRelKit (rec l<)) ([A] : Γ ⊩ A) → Γ ⊩¹ A _⊩¹_≡_/_ : (Γ : Con Term) (A B : Term) → Γ ⊩¹ A → Set Γ ⊩¹ A ≡ B / Uᵣ UA = Γ ⊩¹U≡ B Γ ⊩¹ A ≡ B / ℕᵣ D = Γ ⊩ℕ A ≡ B Γ ⊩¹ A ≡ B / Emptyᵣ D = Γ ⊩Empty A ≡ B Γ ⊩¹ A ≡ B / Unitᵣ D = Γ ⊩Unit A ≡ B Γ ⊩¹ A ≡ B / ne neA = Γ ⊩ne A ≡ B / neA Γ ⊩¹ A ≡ B / Bᵣ W BA = Γ ⊩¹B⟨ W ⟩ A ≡ B / BA Γ ⊩¹ A ≡ B / emb l< [A] = Γ ⊩ A ≡ B / [A] where open LogRelKit (rec l<) _⊩¹_∷_/_ : (Γ : Con Term) (t A : Term) → Γ ⊩¹ A → Set Γ ⊩¹ t ∷ .U / Uᵣ (Uᵣ l′ l< ⊢Γ) = Γ ⊩¹U t ∷U/ l< Γ ⊩¹ t ∷ A / ℕᵣ D = Γ ⊩ℕ t ∷ℕ Γ ⊩¹ t ∷ A / Emptyᵣ D = Γ ⊩Empty t ∷Empty Γ ⊩¹ t ∷ A / Unitᵣ D = Γ ⊩Unit t ∷Unit Γ ⊩¹ t ∷ A / ne neA = Γ ⊩ne t ∷ A / neA Γ ⊩¹ t ∷ A / Bᵣ BΠ ΠA = Γ ⊩¹Π t ∷ A / ΠA Γ ⊩¹ t ∷ A / Bᵣ BΣ ΣA = Γ ⊩¹Σ t ∷ A / ΣA Γ ⊩¹ t ∷ A / emb l< [A] = Γ ⊩ t ∷ A / [A] where open LogRelKit (rec l<) _⊩¹_≡_∷_/_ : (Γ : Con Term) (t u A : Term) → Γ ⊩¹ A → Set Γ ⊩¹ t ≡ u ∷ .U / Uᵣ (Uᵣ l′ l< ⊢Γ) = Γ ⊩¹U t ≡ u ∷U/ l< Γ ⊩¹ t ≡ u ∷ A / ℕᵣ D = Γ ⊩ℕ t ≡ u ∷ℕ Γ ⊩¹ t ≡ u ∷ A / Emptyᵣ D = Γ ⊩Empty t ≡ u ∷Empty Γ ⊩¹ t ≡ u ∷ A / Unitᵣ D = Γ ⊩Unit t ≡ u ∷Unit Γ ⊩¹ t ≡ u ∷ A / ne neA = Γ ⊩ne t ≡ u ∷ A / neA Γ ⊩¹ t ≡ u ∷ A / Bᵣ BΠ ΠA = Γ ⊩¹Π t ≡ u ∷ A / ΠA Γ ⊩¹ t ≡ u ∷ A / Bᵣ BΣ ΣA = Γ ⊩¹Σ t ≡ u ∷ A / ΣA Γ ⊩¹ t ≡ u ∷ A / emb l< [A] = Γ ⊩ t ≡ u ∷ A / [A] where open LogRelKit (rec l<) kit : LogRelKit kit = Kit _⊩¹U _⊩¹B⟨_⟩_ _⊩¹_ _⊩¹_≡_/_ _⊩¹_∷_/_ _⊩¹_≡_∷_/_ open LogRel public using (Uᵣ; ℕᵣ; Emptyᵣ; Unitᵣ; ne; Bᵣ; B₌; emb; Uₜ; Uₜ₌) -- Patterns for the non-records of Π pattern Πₜ f d funcF f≡f [f] [f]₁ = f , d , funcF , f≡f , [f] , [f]₁ pattern Πₜ₌ f g d d′ funcF funcG f≡g [f] [g] [f≡g] = f , g , d , d′ , funcF , funcG , f≡g , [f] , [g] , [f≡g] pattern Σₜ p d pProd p≅p [fst] [snd] = p , d , pProd , p≅p , ([fst] , [snd]) pattern Σₜ₌ p r d d′ pProd rProd p≅r [t] [u] [fstp] [fstr] [fst≡] [snd≡] = p , r , d , d′ , pProd , rProd , p≅r , [t] , [u] , ([fstp] , [fstr] , [fst≡] , [snd≡]) pattern Uᵣ′ a b c = Uᵣ (Uᵣ a b c) pattern ne′ a b c d = ne (ne a b c d) pattern Bᵣ′ W a b c d e f g h i = Bᵣ W (Bᵣ a b c d e f g h i) pattern Πᵣ′ a b c d e f g h i = Bᵣ′ BΠ a b c d e f g h i pattern Σᵣ′ a b c d e f g h i = Bᵣ′ BΣ a b c d e f g h i logRelRec : ∀ l {l′} → l′ < l → LogRelKit logRelRec ⁰ = λ () logRelRec ¹ 0<1 = LogRel.kit ⁰ (λ ()) kit : ∀ (i : TypeLevel) → LogRelKit kit l = LogRel.kit l (logRelRec l) -- a bit of repetition in "kit ¹" definition, would work better with Fin 2 for -- TypeLevel because you could recurse. _⊩′⟨_⟩U : (Γ : Con Term) (l : TypeLevel) → Set Γ ⊩′⟨ l ⟩U = Γ ⊩U where open LogRelKit (kit l) _⊩′⟨_⟩B⟨_⟩_ : (Γ : Con Term) (l : TypeLevel) (W : BindingType) → Term → Set Γ ⊩′⟨ l ⟩B⟨ W ⟩ A = Γ ⊩B⟨ W ⟩ A where open LogRelKit (kit l) _⊩⟨_⟩_ : (Γ : Con Term) (l : TypeLevel) → Term → Set Γ ⊩⟨ l ⟩ A = Γ ⊩ A where open LogRelKit (kit l) _⊩⟨_⟩_≡_/_ : (Γ : Con Term) (l : TypeLevel) (A B : Term) → Γ ⊩⟨ l ⟩ A → Set Γ ⊩⟨ l ⟩ A ≡ B / [A] = Γ ⊩ A ≡ B / [A] where open LogRelKit (kit l) _⊩⟨_⟩_∷_/_ : (Γ : Con Term) (l : TypeLevel) (t A : Term) → Γ ⊩⟨ l ⟩ A → Set Γ ⊩⟨ l ⟩ t ∷ A / [A] = Γ ⊩ t ∷ A / [A] where open LogRelKit (kit l) _⊩⟨_⟩_≡_∷_/_ : (Γ : Con Term) (l : TypeLevel) (t u A : Term) → Γ ⊩⟨ l ⟩ A → Set Γ ⊩⟨ l ⟩ t ≡ u ∷ A / [A] = Γ ⊩ t ≡ u ∷ A / [A] where open LogRelKit (kit l)
{ "alphanum_fraction": 0.462481674, "avg_line_length": 32.2709677419, "ext": "agda", "hexsha": "9fc4ad014cc89f2490396cb24cf8c30a8b403d37", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Vtec234/logrel-mltt", "max_forks_repo_path": "Definition/LogicalRelation.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Vtec234/logrel-mltt", "max_issues_repo_path": "Definition/LogicalRelation.agda", "max_line_length": 161, "max_stars_count": null, "max_stars_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Vtec234/logrel-mltt", "max_stars_repo_path": "Definition/LogicalRelation.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 7312, "size": 15006 }
module Readme where -- SystemF with small-step semantics -- and normal forms open import SystemF.Everything -- SystemF extended with functions that take implicit parameters -- including a reduction to SystemF open import Implicits.Everything -- Simply typed lambda calculus with references, -- accompanied by a store-passing small-step semantics open import Impure.STLCRef.Readme -- First order dependently typed lambda calculus with references, -- accompanied by a store-passing small-step semantics -- and a proof that the small-step semantics is deterministic open import Impure.LFRef.Readme
{ "alphanum_fraction": 0.8080133556, "avg_line_length": 31.5263157895, "ext": "agda", "hexsha": "1f11678bb0b9f500bf7463381052e07dc87b19bf", "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/Readme.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/Readme.agda", "max_line_length": 65, "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/Readme.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 127, "size": 599 }
module tests.Forcing2 where open import Prelude.Nat open import Prelude.IO open import Prelude.Unit data _**_ (A B : Set) : Set where _,_ : A -> B -> A ** B data P {A B : Set} : A ** B -> Set where _,_ : (x : A)(y : B) -> P (x , y) data Q {A : Set} : A ** A -> Set where [_] : (x : A) -> Q (x , x) test1 : (p : Nat ** Nat) -> P p -> Nat test1 .(x , y) (x , y) = x + y test2 : (q : Nat ** Nat) -> Q q -> Nat test2 .(x , x) [ x ] = ((S (S Z)) * x) + 1 test3 : (q : (Nat ** Nat) ** (Nat ** Nat)) -> Q q -> Nat test3 .((Z , Z) , (Z , Z)) [ Z , Z ] = Z test3 .((S n , m) , (S n , m)) [ S n , m ] = S n + m test3 .((Z , m) , (Z , m)) [ Z , m ] = m main : IO Unit main = printNat (test1 (5 , 8) (5 , 8)) ,, printNat (test2 (1 , 1) [ 1 ]) ,, printNat (test3 ( (3 , 4) , (3 , 4) ) [ 3 , 4 ]) ,, return unit
{ "alphanum_fraction": 0.4247058824, "avg_line_length": 25.7575757576, "ext": "agda", "hexsha": "7ddca0c40b419e33b5b5dfa7ef0498abaf46710a", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "larrytheliquid/agda", "max_forks_repo_path": "test/epic/tests/Forcing2.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/agda", "max_issues_repo_path": "test/epic/tests/Forcing2.agda", "max_line_length": 56, "max_stars_count": null, "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_path": "test/epic/tests/Forcing2.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 378, "size": 850 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Conat Literals ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe --sized-types #-} module Codata.Conat.Literals where open import Agda.Builtin.FromNat open import Data.Unit open import Codata.Conat number : ∀ {i} → Number (Conat i) number = record { Constraint = λ _ → ⊤ ; fromNat = λ n → fromℕ n }
{ "alphanum_fraction": 0.4620253165, "avg_line_length": 23.7, "ext": "agda", "hexsha": "a6ad101efbd81cc6a6ae1a92395bd849dcb46cc2", "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": "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/Literals.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/Literals.agda", "max_line_length": 72, "max_stars_count": 5, "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/Literals.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 103, "size": 474 }
open import Data.Product using ( _×_ ; _,_ ) open import Relation.Nullary using ( ¬_ ) open import Relation.Unary using ( _∈_ ; ∅ ; _∪_ ) open import Web.Semantic.DL.ABox using ( ABox ; Assertions ; ε ; _,_ ; _∼_ ; _∈₁_ ; _∈₂_ ) open import Web.Semantic.DL.ABox.Interp using ( Interp ; ⌊_⌋ ; ind ) open import Web.Semantic.DL.Signature using ( Signature ) open import Web.Semantic.DL.Concept using ( Concept ; ⟨_⟩ ; ⊤ ; ⊥ ; _⊓_ ; _⊔_ ; ∀[_]_ ; ∃⟨_⟩_ ; ≤1 ) open import Web.Semantic.DL.KB using ( KB ; tbox ; abox ) open import Web.Semantic.DL.Role using ( Role ; ⟨_⟩ ; ⟨_⟩⁻¹ ) open import Web.Semantic.DL.TBox using ( TBox ; Axioms ; ε ; _,_ ;_⊑₁_ ; _⊑₂_ ; Ref ; Tra ) open import Web.Semantic.DL.TBox.Interp using ( Δ ; _⊨_≈_ ; con ; rol ) open import Web.Semantic.Util using ( _⊕_⊕_ ; inode ; bnode ; enode ) module Web.Semantic.DL.Sequent {Σ : Signature} {W X Y : Set} where infix 2 _⊕_⊢_∼_ _⊕_⊢_∈₁_ _⊕_⊢_∈₂_ Γ : (Interp Σ X) → (KB Σ (X ⊕ W ⊕ Y)) → Set Γ I K = Δ ⌊ I ⌋ ⊕ W ⊕ Y γ : ∀ I K → (X ⊕ W ⊕ Y) → Γ I K γ I K (inode x) = inode (ind I x) γ I K (bnode w) = bnode w γ I K (enode y) = enode y mutual data _⊕_⊢_∼_ I K : Γ I K → Γ I K → Set where ∼-assert : ∀ {x y} → ((x ∼ y) ∈ Assertions (abox K)) → (I ⊕ K ⊢ γ I K x ∼ γ I K y) ∼-import : ∀ {x y} → (⌊ I ⌋ ⊨ x ≈ y) → (I ⊕ K ⊢ inode x ∼ inode y) ∼-refl : ∀ {x} → (I ⊕ K ⊢ x ∼ x) ∼-sym : ∀ {x y} → (I ⊕ K ⊢ x ∼ y) → (I ⊕ K ⊢ y ∼ x) ∼-trans : ∀ {x y z} → (I ⊕ K ⊢ x ∼ y) → (I ⊕ K ⊢ y ∼ z) → (I ⊕ K ⊢ x ∼ z) ∼-≤1 : ∀ {x y z R} → (I ⊕ K ⊢ x ∈₁ (≤1 R)) → (I ⊕ K ⊢ (x , y) ∈₂ R) → (I ⊕ K ⊢ (x , z) ∈₂ R) → (I ⊕ K ⊢ y ∼ z) data _⊕_⊢_∈₁_ I K : Γ I K → Concept Σ → Set where ∈₁-assert : ∀ {x c} → ((x ∈₁ c) ∈ Assertions (abox K)) → (I ⊕ K ⊢ γ I K x ∈₁ ⟨ c ⟩) ∈₁-import : ∀ {x c} → (x ∈ con ⌊ I ⌋ c) → (I ⊕ K ⊢ inode x ∈₁ ⟨ c ⟩) ∈₁-resp-∼ : ∀ {x y C} → (I ⊕ K ⊢ x ∈₁ C) → (I ⊕ K ⊢ x ∼ y) → (I ⊕ K ⊢ y ∈₁ C) ∈₁-subsum : ∀ {x C D} → (I ⊕ K ⊢ x ∈₁ C) → ((C ⊑₁ D) ∈ Axioms (tbox K)) → (I ⊕ K ⊢ x ∈₁ D) ∈₁-⊤-I : ∀ {x} → (I ⊕ K ⊢ x ∈₁ ⊤) ∈₁-⊓-I : ∀ {x C D} → (I ⊕ K ⊢ x ∈₁ C) → (I ⊕ K ⊢ x ∈₁ D) → (I ⊕ K ⊢ x ∈₁ (C ⊓ D)) ∈₁-⊓-E₁ : ∀ {x C D} → (I ⊕ K ⊢ x ∈₁ (C ⊓ D)) → (I ⊕ K ⊢ x ∈₁ C) ∈₁-⊓-E₂ : ∀ {x C D} → (I ⊕ K ⊢ x ∈₁ (C ⊓ D)) → (I ⊕ K ⊢ x ∈₁ D) ∈₁-⊔-I₁ : ∀ {x C D} → (I ⊕ K ⊢ x ∈₁ C) → (I ⊕ K ⊢ x ∈₁ (C ⊔ D)) ∈₁-⊔-I₂ : ∀ {x C D} → (I ⊕ K ⊢ x ∈₁ D) → (I ⊕ K ⊢ x ∈₁ (C ⊔ D)) ∈₁-∀-E : ∀ {x y R C} → (I ⊕ K ⊢ x ∈₁ (∀[ R ] C)) → (I ⊕ K ⊢ (x , y) ∈₂ R) → (I ⊕ K ⊢ y ∈₁ C) ∈₁-∃-I : ∀ {x y R C} → (I ⊕ K ⊢ (x , y) ∈₂ R) → (I ⊕ K ⊢ y ∈₁ C) → (I ⊕ K ⊢ x ∈₁ (∃⟨ R ⟩ C)) data _⊕_⊢_∈₂_ I K : (Γ I K × Γ I K) → Role Σ → Set where ∈₂-assert : ∀ {x y r} → (((x , y) ∈₂ r) ∈ Assertions (abox K)) → (I ⊕ K ⊢ (γ I K x , γ I K y) ∈₂ ⟨ r ⟩) ∈₂-import : ∀ {x y r} → ((x , y) ∈ rol ⌊ I ⌋ r) → (I ⊕ K ⊢ (inode x , inode y) ∈₂ ⟨ r ⟩) ∈₂-resp-∼ : ∀ {w x y z R} → (I ⊕ K ⊢ w ∼ x) → (I ⊕ K ⊢ (x , y) ∈₂ R) → (I ⊕ K ⊢ y ∼ z) → (I ⊕ K ⊢ (w , z) ∈₂ R) ∈₂-subsum : ∀ {xy R S} → (I ⊕ K ⊢ xy ∈₂ R) → ((R ⊑₂ S) ∈ Axioms (tbox K)) → (I ⊕ K ⊢ xy ∈₂ S) ∈₂-refl : ∀ x {R} → ((Ref R) ∈ Axioms (tbox K)) → (I ⊕ K ⊢ (x , x) ∈₂ R) ∈₂-trans : ∀ {x y z R} → (I ⊕ K ⊢ (x , y) ∈₂ R) → (I ⊕ K ⊢ (y , z) ∈₂ R) → ((Tra R) ∈ Axioms (tbox K)) → (I ⊕ K ⊢ (x , z) ∈₂ R) ∈₂-inv-I : ∀ {x y r} → (I ⊕ K ⊢ (x , y) ∈₂ ⟨ r ⟩) → (I ⊕ K ⊢ (y , x) ∈₂ ⟨ r ⟩⁻¹) ∈₂-inv-E : ∀ {x y r} → (I ⊕ K ⊢ (x , y) ∈₂ ⟨ r ⟩⁻¹) → (I ⊕ K ⊢ (y , x) ∈₂ ⟨ r ⟩)
{ "alphanum_fraction": 0.4089985486, "avg_line_length": 55.564516129, "ext": "agda", "hexsha": "68075f0963cdd3dd91955ec1e026f469fdf74da9", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:03.000Z", "max_forks_repo_forks_event_min_datetime": "2017-12-03T14:52:09.000Z", "max_forks_repo_head_hexsha": "38fbc3af7062ba5c3d7d289b2b4bcfb995d99057", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bblfish/agda-web-semantic", "max_forks_repo_path": "src/Web/Semantic/DL/Sequent.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "38fbc3af7062ba5c3d7d289b2b4bcfb995d99057", "max_issues_repo_issues_event_max_datetime": "2021-01-04T20:57:19.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T02:32:28.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bblfish/agda-web-semantic", "max_issues_repo_path": "src/Web/Semantic/DL/Sequent.agda", "max_line_length": 131, "max_stars_count": 9, "max_stars_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-web-semantic", "max_stars_repo_path": "src/Web/Semantic/DL/Sequent.agda", "max_stars_repo_stars_event_max_datetime": "2020-03-14T14:21:08.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-13T17:46:41.000Z", "num_tokens": 1933, "size": 3445 }
open import Agda.Builtin.Equality primitive primEraseEquality : ∀ {a} {A : Set a} {x y : A} → x ≡ y → x ≡ y
{ "alphanum_fraction": 0.6126126126, "avg_line_length": 22.2, "ext": "agda", "hexsha": "407ad63d02dfe516476a2eb8a532d737c9e08f4a", "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/UnsafePrimEraseEquality.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/UnsafePrimEraseEquality.agda", "max_line_length": 65, "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/UnsafePrimEraseEquality.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 44, "size": 111 }
{- https://lists.chalmers.se/pipermail/agda/2013/006033.html http://code.haskell.org/~Saizan/unification/ 18-Nov-2013 Andrea Vezzosi -} module Unify-monolithic where -- some equivalences needed to adapt Tactic.Nat to the standard library module EquivalenceOf≤ where open import Agda.Builtin.Equality open import Agda.Builtin.Nat open import Data.Nat using (less-than-or-equal) renaming (_≤_ to _≤s_) open import Data.Nat.Properties using (≤⇒≤″; ≤″⇒≤) open import Prelude using (diff; id) renaming (_≤_ to _≤p_) open import Tactic.Nat.Generic (quote _≤p_) (quote id) (quote id) using (by) ≤p→≤s : ∀ {a b} → a ≤p b → a ≤s b ≤p→≤s (diff k b₊₁≡k₊₁+a) = ≤″⇒≤ (less-than-or-equal {k = k} (by b₊₁≡k₊₁+a)) ≤s→≤p : ∀ {a b} → a ≤s b → a ≤p b ≤s→≤p a≤sb with ≤⇒≤″ a≤sb ≤s→≤p _ | less-than-or-equal {k = k} a+k≡b = diff k (by a+k≡b) module _ where open EquivalenceOf≤ open import Data.Nat open import Tactic.Nat.Generic (quote _≤_) (quote ≤s→≤p) (quote ≤p→≤s) public open import Data.Fin using (Fin; suc; zero) open import Data.Nat hiding (_≤_) --open import Relation.Binary.PropositionalEquality open import Relation.Binary.PropositionalEquality hiding ([_]) open import Function open import Relation.Nullary --open import Data.Product open import Data.Product renaming (map to _***_) open import Data.Empty data Term (n : ℕ) : Set where i : (x : Fin n) -> Term n leaf : Term n _fork_ : (s t : Term n) -> Term n {- data Term : ℕ -> Set where i : ∀ ..{n} -> (x : Fin n) -> Term n leaf : ∀ ..{n} -> Term n _fork_ : ∀ ..{n} -> (s t : Term n) -> Term n -} _~>_ : (m n : ℕ) -> Set m ~> n = Fin m -> Term n ▹ : ∀ {m n} -> (r : Fin m -> Fin n) -> Fin m -> Term n ▹ r = i ∘ r _◃ : ∀ {m n} -> (f : m ~> n) -> Term m -> Term n (f ◃ ) (i x) = f x (f ◃ ) leaf = leaf (f ◃ ) (s fork t) = (f ◃) s fork (f ◃) t _◃_ : ∀ {m n} -> (f : m ~> n) -> Term m -> Term n _◃_ = _◃ _≐_ : {m n : ℕ} -> (Fin m -> Term n) -> (Fin m -> Term n) -> Set f ≐ g = ∀ x -> f x ≡ g x ◃ext : ∀ {m n} {f g : Fin m -> Term n} -> f ≐ g -> ∀ t -> f ◃ t ≡ g ◃ t ◃ext p (i x) = p x ◃ext p leaf = refl ◃ext p (s fork t) = cong₂ _fork_ (◃ext p s) (◃ext p t) _◇_ : ∀ {l m n : ℕ } -> (f : Fin m -> Term n) (g : Fin l -> Term m) -> Fin l -> Term n f ◇ g = (f ◃) ∘ g ≐-cong : ∀ {m n o} {f : m ~> n} {g} (h : _ ~> o) -> f ≐ g -> (h ◇ f) ≐ (h ◇ g) ≐-cong h f≐g t = cong (h ◃) (f≐g t) ≐-sym : ∀ {m n} {f : m ~> n} {g} -> f ≐ g -> g ≐ f ≐-sym f≐g = sym ∘ f≐g module Sub where fact1 : ∀ {n} -> (t : Term n) -> i ◃ t ≡ t fact1 (i x) = refl fact1 leaf = refl fact1 (s fork t) = cong₂ _fork_ (fact1 s) (fact1 t) fact2 : ∀ {l m n} -> (f : Fin m -> Term n) (g : _) (t : Term l) -> (f ◇ g) ◃ t ≡ f ◃ (g ◃ t) fact2 f g (i x) = refl fact2 f g leaf = refl fact2 f g (s fork t) = cong₂ _fork_ (fact2 f g s) (fact2 f g t) fact3 : ∀ {l m n} (f : Fin m -> Term n) (r : Fin l -> Fin m) -> (f ◇ (▹ r)) ≡ (f ∘ r) fact3 f r = refl -- ext (λ _ -> refl) ◃ext' : ∀ {m n o} {f : Fin m -> Term n}{g : Fin m -> Term o}{h} -> f ≐ (h ◇ g) -> ∀ t -> f ◃ t ≡ h ◃ (g ◃ t) ◃ext' p t = trans (◃ext p t) (Sub.fact2 _ _ t) s : ℕ -> ℕ s = suc thin : ∀ {n} -> (x : Fin (s n)) (y : Fin n) -> Fin (s n) thin zero y = suc y thin (suc x) zero = zero thin (suc x) (suc y) = suc (thin x y) p : ∀ {n} -> Fin (suc (suc n)) -> Fin (suc n) p (suc x) = x p zero = zero module Thin where fact1 : ∀ {n} x y z -> thin {n} x y ≡ thin x z -> y ≡ z fact1 zero y .y refl = refl fact1 (suc x) zero zero r = refl fact1 (suc x) zero (suc z) () fact1 (suc x) (suc y) zero () fact1 (suc x) (suc y) (suc z) r = cong suc (fact1 x y z (cong p r)) fact2 : ∀ {n} x y -> ¬ thin {n} x y ≡ x fact2 zero y () fact2 (suc x) zero () fact2 (suc x) (suc y) r = fact2 x y (cong p r) fact3 : ∀{n} x y -> ¬ x ≡ y -> ∃ λ y' -> thin {n} x y' ≡ y fact3 zero zero ne = ⊥-elim (ne refl) fact3 zero (suc y) _ = y , refl fact3 {zero} (suc ()) _ _ fact3 {suc n} (suc x) zero ne = zero , refl fact3 {suc n} (suc x) (suc y) ne with y | fact3 x y (ne ∘ cong suc) ... | .(thin x y') | y' , refl = suc y' , refl open import Data.Maybe open import Category.Functor open import Category.Monad import Level open RawMonad (Data.Maybe.monad {Level.zero}) thick : ∀ {n} -> (x y : Fin (suc n)) -> Maybe (Fin n) thick zero zero = nothing thick zero (suc y) = just y thick {zero} (suc ()) _ thick {suc _} (suc x) zero = just zero thick {suc _} (suc x) (suc y) = suc <$> (thick x y) open import Data.Sum _≡Fin_ : ∀ {n} -> (x y : Fin n) -> Dec (x ≡ y) zero ≡Fin zero = yes refl zero ≡Fin suc y = no λ () suc x ≡Fin zero = no λ () suc {suc _} x ≡Fin suc y with x ≡Fin y ... | yes r = yes (cong suc r) ... | no r = no λ e -> r (cong p e) suc {zero} () ≡Fin _ module Thick where half1 : ∀ {n} (x : Fin (suc n)) -> thick x x ≡ nothing half1 zero = refl half1 {suc _} (suc x) = cong (_<$>_ suc) (half1 x) half1 {zero} (suc ()) half2 : ∀ {n} (x : Fin (suc n)) y -> ∀ y' -> thin x y' ≡ y -> thick x y ≡ just y' half2 zero zero y' () half2 zero (suc y) .y refl = refl half2 {suc n} (suc x) zero zero refl = refl half2 {suc _} (suc _) zero (suc _) () half2 {suc n} (suc x) (suc y) zero () half2 {suc n} (suc x) (suc .(thin x y')) (suc y') refl with thick x (thin x y') | half2 x (thin x y') y' refl ... | .(just y') | refl = refl half2 {zero} (suc ()) _ _ _ fact1 : ∀ {n} (x : Fin (suc n)) y r -> thick x y ≡ r -> x ≡ y × r ≡ nothing ⊎ ∃ λ y' -> thin x y' ≡ y × r ≡ just y' fact1 x y .(thick x y) refl with x ≡Fin y fact1 x .x ._ refl | yes refl = inj₁ (refl , half1 x) ... | no el with Thin.fact3 x y el ... | y' , thinxy'=y = inj₂ (y' , ( thinxy'=y , half2 x y y' thinxy'=y )) check : ∀{n} (x : Fin (suc n)) (t : Term (suc n)) -> Maybe (Term n) check x (i y) = i <$> thick x y check x leaf = just leaf check x (s fork t) = _fork_ <$> check x s ⊛ check x t _for_ : ∀ {n} (t' : Term n) (x : Fin (suc n)) -> Fin (suc n) -> Term n (t' for x) y = maybe′ i t' (thick x y) data AList : ℕ -> ℕ -> Set where anil : ∀ {n} -> AList n n _asnoc_/_ : ∀ {m n} (σ : AList m n) (t' : Term m) (x : Fin (suc m)) -> AList (suc m) n alist≥ : ∀ m n → AList m n → m Data.Nat.≥ n alist≥ m .m anil = {!!} alist≥ .(suc _) n (x asnoc t' / x₁) with alist≥ _ _ x … | r = {!!} sub : ∀ {m n} (σ : AList m n) -> Fin m -> Term n sub anil = i sub (σ asnoc t' / x) = sub σ ◇ (t' for x) _++_ : ∀ {l m n} (ρ : AList m n) (σ : AList l m) -> AList l n ρ ++ anil = ρ ρ ++ (σ asnoc t' / x) = (ρ ++ σ) asnoc t' / x ++-assoc : ∀ {l m n o} (ρ : AList l m) (σ : AList n _) (τ : AList o _) -> ρ ++ (σ ++ τ) ≡ (ρ ++ σ) ++ τ ++-assoc ρ σ anil = refl ++-assoc ρ σ (τ asnoc t / x) = cong (λ s -> s asnoc t / x) (++-assoc ρ σ τ) module SubList where anil-id-l : ∀ {m n} (σ : AList m n) -> anil ++ σ ≡ σ anil-id-l anil = refl anil-id-l (σ asnoc t' / x) = cong (λ σ -> σ asnoc t' / x) (anil-id-l σ) fact1 : ∀ {l m n} (ρ : AList m n) (σ : AList l m) -> sub (ρ ++ σ) ≐ (sub ρ ◇ sub σ) fact1 ρ anil v = refl fact1 {suc l} {m} {n} r (s asnoc t' / x) v = trans hyp-on-terms ◃-assoc where t = (t' for x) v hyp-on-terms = ◃ext (fact1 r s) t ◃-assoc = Sub.fact2 (sub r) (sub s) t _∃asnoc_/_ : ∀ {m} (a : ∃ (AList m)) (t' : Term m) (x : Fin (suc m)) -> ∃ (AList (suc m)) (n , σ) ∃asnoc t' / x = n , σ asnoc t' / x flexFlex : ∀ {m} (x y : Fin m) -> ∃ (AList m) flexFlex {suc m} x y with thick x y ... | just y' = m , anil asnoc i y' / x ... | nothing = suc m , anil flexFlex {zero} () _ flexRigid : ∀ {m} (x : Fin m) (t : Term m) -> Maybe (∃(AList m)) flexRigid {suc m} x t with check x t ... | just t' = just (m , anil asnoc t' / x) ... | nothing = nothing flexRigid {zero} () _ amgu : ∀ {m} (s t : Term m) (acc : ∃ (AList m)) -> Maybe (∃ (AList m)) amgu leaf leaf acc = just acc amgu leaf (s' fork t') acc = nothing amgu (s' fork t') leaf acc = nothing amgu (s1 fork s2) (t1 fork t2) acc = amgu s2 t2 =<< amgu s1 t1 acc amgu (i x) (i y) (m , anil) = just (flexFlex x y) amgu (i x) t (m , anil) = flexRigid x t amgu t (i x) (m , anil) = flexRigid x t amgu s t (n , σ asnoc r / z) = (λ σ -> σ ∃asnoc r / z) <$> amgu ((r for z) ◃ s) ((r for z) ◃ t) (n , σ) mgu : ∀ {m} -> (s t : Term m) -> Maybe (∃ (AList m)) mgu {m} s t = amgu s t (m , anil) {- open import Data.Fin using (Fin; suc; zero) open import Data.Nat hiding (_≤_) open import Relation.Binary.PropositionalEquality hiding ([_]) open import Function open import Relation.Nullary open import Data.Product renaming (map to _***_) open import Data.Empty -} open import Data.Maybe using (maybe; maybe′; nothing; just; monad; Maybe) open import Data.Sum --open import Unify open import Data.List renaming (_++_ to _++L_) open ≡-Reasoning open import Category.Functor open import Category.Monad import Level as L --open RawMonad (Data.Maybe.monad {L.zero}) record Σ₁ (A : Set1) (F : A -> Set) : Set1 where field π₁ : A π₂ : F π₁ _,,_ : ∀ {A F} (x : A) -> F x -> Σ₁ A F x ,, b = record{ π₁ = x; π₂ = b } open Σ₁ Property⋆ : (m : ℕ) -> Set1 Property⋆ m = ∀ {n} -> (Fin m -> Term n) -> Set Extensional : {m : ℕ} -> Property⋆ m -> Set Extensional P = ∀ {m f g} -> f ≐ g -> P {m} f -> P g Property : (m : ℕ) -> Set1 Property m = Σ₁ (Property⋆ m) Extensional prop-id : ∀ {m n} {f : _ ~> n} {P : Property m} -> π₁ P f -> π₁ P (i ◇ f) prop-id {_} {_} {f} {P'} Pf = π₂ P' (λ x → sym (Sub.fact1 (f x))) Pf Unifies⋆ : ∀ {m} (s t : Term m) -> Property⋆ m Unifies⋆ s t f = f ◃ s ≡ f ◃ t Unifies : ∀ {m} (s t : Term m) -> Property m Unifies s t = (λ {_} -> Unifies⋆ s t) ,, λ {_} {f} {g} f≐g f◃s=f◃t -> begin g ◃ s ≡⟨ sym (◃ext f≐g s) ⟩ f ◃ s ≡⟨ f◃s=f◃t ⟩ f ◃ t ≡⟨ ◃ext f≐g t ⟩ g ◃ t ∎ _∧⋆_ : ∀{m} -> (P Q : Property⋆ m) -> Property⋆ m P ∧⋆ Q = (λ f -> P f × Q f) _∧_ : ∀{m} -> (P Q : Property m) -> Property m P ∧ Q = (λ {_} f -> π₁ P f × π₁ Q f) ,, λ {_} {_} {_} f≐g Pf×Qf -> π₂ P f≐g (proj₁ Pf×Qf) , π₂ Q f≐g (proj₂ Pf×Qf) _⇔⋆_ : ∀{m} -> (P Q : Property⋆ m) -> Set P ⇔⋆ Q = ∀ {n} f -> (P {n} f -> Q f) × (Q f -> P f) _⇔_ : ∀{m} -> (P Q : Property m) -> Set P ⇔ Q = ∀ {n} f -> (π₁ P {n} f -> π₁ Q f) × (π₁ Q f -> π₁ P f) switch⋆ : ∀ {m} (P Q : Property⋆ m) -> P ⇔⋆ Q -> Q ⇔⋆ P switch⋆ _ _ P⇔Q f = proj₂ (P⇔Q f) , proj₁ (P⇔Q f) switch : ∀ {m} (P Q : Property m) -> P ⇔ Q -> Q ⇔ P switch _ _ P⇔Q f = proj₂ (P⇔Q f) , proj₁ (P⇔Q f) Nothing⋆ : ∀{m} -> (P : Property⋆ m) -> Set Nothing⋆ P = ∀{n} f -> P {n} f -> ⊥ Nothing : ∀{m} -> (P : Property m) -> Set Nothing P = ∀{n} f -> π₁ P {n} f -> ⊥ _[-◇⋆_] : ∀{m n} (P : Property⋆ m) (f : Fin m -> Term n) -> Property⋆ n (P [-◇⋆ f ]) g = P (g ◇ f) _[-◇_] : ∀{m n} (P : Property m) (f : Fin m -> Term n) -> Property n P [-◇ f ] = (λ {_} g -> π₁ P (g ◇ f)) ,, λ {_} {f'} {g'} f'≐g' Pf'◇f -> π₂ P (◃ext f'≐g' ∘ f) Pf'◇f module Properties where fact1 : ∀ {m} {s t : Term m} -> (Unifies s t) ⇔ (Unifies t s) fact1 _ = sym , sym fact1'⋆ : ∀ {m} {s1 s2 t1 t2 : Term m} -> Unifies⋆ (s1 fork s2) (t1 fork t2) ⇔⋆ (Unifies⋆ s1 t1 ∧⋆ Unifies⋆ s2 t2) fact1'⋆ f = deconstr _ _ _ _ , uncurry (cong₂ _fork_) where deconstr : ∀ {m} (s1 s2 t1 t2 : Term m) -> (s1 fork s2) ≡ (t1 fork t2) -> (s1 ≡ t1) × (s2 ≡ t2) deconstr s1 s2 .s1 .s2 refl = refl , refl fact1' : ∀ {m} {s1 s2 t1 t2 : Term m} -> Unifies (s1 fork s2) (t1 fork t2) ⇔ (Unifies s1 t1 ∧ Unifies s2 t2) fact1' f = deconstr _ _ _ _ , uncurry (cong₂ _fork_) where deconstr : ∀ {m} (s1 s2 t1 t2 : Term m) -> (s1 fork s2) ≡ (t1 fork t2) -> (s1 ≡ t1) × (s2 ≡ t2) deconstr s1 s2 .s1 .s2 refl = refl , refl fact2⋆ : ∀ {m} (P Q : Property⋆ m) -> P ⇔⋆ Q -> Nothing⋆ P -> Nothing⋆ Q fact2⋆ P Q iff notp f q with iff f ... | (p2q , q2p) = notp f (q2p q) fact2 : ∀ {m} (P Q : Property m) -> P ⇔ Q -> Nothing P -> Nothing Q fact2 P Q iff notp f q with iff f ... | (p2q , q2p) = notp f (q2p q) fact3 : ∀ {m} {P : Property m} -> P ⇔ (P [-◇ i ]) fact3 f = id , id fact4 : ∀{m n} {P : Property m} (f : _ -> Term n) -> Nothing P -> Nothing (P [-◇ f ]) fact4 f nop g = nop (g ◇ f) fact5⋆ : ∀{m n} (P Q : Property⋆ _) (f : m ~> n) -> P ⇔⋆ Q -> (P [-◇⋆ f ]) ⇔⋆ (Q [-◇⋆ f ]) fact5⋆ _ _ f P⇔Q f' = P⇔Q (f' ◇ f) fact5 : ∀{m n} (P Q : Property _) (f : m ~> n) -> P ⇔ Q -> (P [-◇ f ]) ⇔ (Q [-◇ f ]) fact5 _ _ f P⇔Q f' = P⇔Q (f' ◇ f) fact6 : ∀{m n} P {f g : m ~> n} -> f ≐ g -> (P [-◇ f ]) ⇔ (P [-◇ g ]) fact6 P f≐g h = π₂ P (≐-cong h f≐g) , π₂ P (≐-sym (≐-cong h f≐g)) {- fact5 : ∀ {l m n} {f : Fin n -> Term l} {g : Fin m -> Term n} {P : Property _ } -> (P [-◇ g ]) [-◇ f ] ⇔ P [-◇ (f ◇ g) ] fact5 h = {!!} , {!!} -} _≤_ : ∀ {m n n'} (f : Fin m -> Term n) (g : Fin m -> Term n') -> Set f ≤ g = ∃ λ f' -> f ≐ (f' ◇ g) module Order where reflex : ∀ {m n} {f : Fin m -> Term n} -> f ≤ f reflex = i , λ _ -> sym (Sub.fact1 _) transitivity : ∀ {l m n o} {f : Fin l -> Term m}{g : _ -> Term n} {h : _ -> Term o} -> f ≤ g -> g ≤ h -> f ≤ h transitivity {l} {_} {_} {_} {f} {g} {h} (fg , pfg) (gh , pgh) = fg ◇ gh , proof where proof : (x : Fin l) → f x ≡ (λ x' → fg ◃ (gh x')) ◃ (h x) proof x = trans z (sym (Sub.fact2 fg gh (h x))) where z = trans (pfg x) (cong (fg ◃) (pgh x)) i-max : ∀ {m n} (f : Fin m -> Term n) -> f ≤ i i-max f = f , λ _ -> refl dist : ∀{l m n o}{f : Fin l -> Term m}{g : _ -> Term n}(h : Fin o -> _) -> f ≤ g -> (f ◇ h) ≤ (g ◇ h) dist h (fg , pfg) = fg , λ x -> trans (◃ext pfg (h x)) (Sub.fact2 _ _ (h x)) Max⋆ : ∀ {m} (P : Property⋆ m) -> Property⋆ m Max⋆ P f = P f × (∀ {n} f' -> P {n} f' -> f' ≤ f) Max : ∀ {m} (P : Property m) -> Property m Max P' = (λ {_} → Max⋆ P) ,, λ {_} {_} {_} -> lemma1 where open Σ₁ P' renaming (π₁ to P; π₂ to Peq) lemma1 : {m : ℕ} {f : Fin _ → Term m} {g : Fin _ → Term m} → f ≐ g → P f × ({n : ℕ} (f' : Fin _ → Term n) → P f' → f' ≤ f) → P g × ({n : ℕ} (f' : Fin _ → Term n) → P f' → f' ≤ g) lemma1 {_} {f} {g} f≐g (Pf , MaxPf) = Peq f≐g Pf , λ {_} -> lemma2 where lemma2 : ∀ {n} f' → P {n} f' → ∃ λ f0 → f' ≐ (f0 ◇ g) lemma2 f' Pf' = f0 , λ x -> trans (f'≐f0◇f x) (cong (f0 ◃) (f≐g x)) where f0 = proj₁ (MaxPf f' Pf') f'≐f0◇f = proj₂ (MaxPf f' Pf') module Max where fact : ∀{m}(P Q : Property m) -> P ⇔ Q -> Max P ⇔ Max Q fact {m} P Q a f = (λ maxp → pq (proj₁ maxp) , λ f' → proj₂ maxp f' ∘ qp) , λ maxq → qp (proj₁ maxq) , λ f' → proj₂ maxq f' ∘ pq where pq : {n : ℕ} {f0 : Fin m → Term n} → (π₁ P f0 → π₁ Q f0) pq {_} {f} = proj₁ (a f) qp : {n : ℕ} {f0 : Fin m → Term n} → (π₁ Q f0 → π₁ P f0) qp {_} {f} = proj₂ (a f) DClosed : ∀{m} (P : Property m) -> Set DClosed P = ∀ {n} f {o} g -> f ≤ g -> π₁ P {o} g -> π₁ P {n} f module DClosed where fact1 : ∀ {m} s t -> DClosed {m} (Unifies s t) fact1 s t f g (f≤g , p) gs=gt = begin f ◃ s ≡⟨ ◃ext' p s ⟩ f≤g ◃ (g ◃ s) ≡⟨ cong (f≤g ◃) gs=gt ⟩ f≤g ◃ (g ◃ t) ≡⟨ sym (◃ext' p t) ⟩ f ◃ t ∎ optimist : ∀ {l m n o} (a : Fin _ -> Term n) (p : Fin _ -> Term o) (q : Fin _ -> Term l) (P Q : Property m) -> DClosed P -> π₁ (Max (P [-◇ a ])) p -> π₁ (Max (Q [-◇ (p ◇ a) ])) q -> π₁ (Max ((P ∧ Q) [-◇ a ])) (q ◇ p) optimist a p q P' Q' DCP (Ppa , pMax) (Qqpa , qMax) = (Peq (sym ∘ (Sub.fact2 _ _) ∘ a) (DCP (q ◇ (p ◇ a)) (p ◇ a) (q , λ _ -> refl) Ppa) , Qeq (sym ∘ (Sub.fact2 _ _) ∘ a) Qqpa ) , λ {_} -> aux where open Σ₁ P' renaming (π₁ to P; π₂ to Peq) open Σ₁ Q' renaming (π₁ to Q; π₂ to Qeq) aux : ∀ {n} (f : _ -> Term n) -> P (f ◇ a) × Q (f ◇ a) -> f ≤ (q ◇ p) aux f (Pfa , Qfa) = h , λ x -> trans (f≐g◇p x) (◃ext' g≐h◇q (p x)) where one = pMax f Pfa g = proj₁ one f≐g◇p = proj₂ one Qgpa : Q (g ◇ (p ◇ a)) Qgpa = Qeq (λ x -> ◃ext' f≐g◇p (a x)) Qfa g≤q = qMax g Qgpa h = proj₁ g≤q g≐h◇q = proj₂ g≤q module failure-propagation where first⋆ : ∀ {m n} (a : _ ~> n) (P Q : Property⋆ m) -> Nothing⋆ (P [-◇⋆ a ]) -> Nothing⋆ ((P ∧⋆ Q) [-◇⋆ a ]) first⋆ a P' Q' noP-a f (Pfa , Qfa) = noP-a f Pfa first : ∀ {m n} (a : _ ~> n) (P Q : Property m) -> Nothing (P [-◇ a ]) -> Nothing ((P ∧ Q) [-◇ a ]) first a P' Q' noP-a f (Pfa , Qfa) = noP-a f Pfa {- second⋆ : ∀ {m n o} (a : _ ~> n) (p : _ ~> o)(P Q : Property⋆ m) -> (Max⋆ (P [-◇⋆ a ])) p -> Nothing⋆ (Q [-◇⋆ (p ◇ a)]) -> Nothing⋆ ((P ∧⋆ Q) [-◇⋆ a ]) second⋆ a p P' Q' (Ppa , pMax) noQ-p◇a f (Pfa , Qfa) = noQ-p◇a g Qgpa where f≤p = pMax f Pfa g = proj₁ f≤p f≐g◇p = proj₂ f≤p Qgpa : Q' (g ◇ (p ◇ a)) Qgpa = {!!} {- noQ-p◇a g Qgpa where f≤p = pMax f Pfa g = proj₁ f≤p f≐g◇p = proj₂ f≤p Qgpa : π₁ Q' (g ◇ (p ◇ a)) Qgpa = π₂ Q' (◃ext' f≐g◇p ∘ a) Qfa -} -} second⋆ : ∀ {m n o} (a : _ ~> n) (p : _ ~> o)(P : Property⋆ m)(Q : Property m) -> (Max⋆ (P [-◇⋆ a ])) p -> Nothing⋆ (π₁ Q [-◇⋆ (p ◇ a)]) -> Nothing⋆ ((P ∧⋆ π₁ Q) [-◇⋆ a ]) second⋆ a p P' Q' (Ppa , pMax) noQ-p◇a f (Pfa , Qfa) = noQ-p◇a g Qgpa where f≤p = pMax f Pfa g = proj₁ f≤p f≐g◇p = proj₂ f≤p Qgpa : π₁ Q' (g ◇ (p ◇ a)) Qgpa = π₂ Q' (◃ext' f≐g◇p ∘ a) Qfa second : ∀ {m n o} (a : _ ~> n) (p : _ ~> o)(P Q : Property m) -> π₁ (Max (P [-◇ a ])) p -> Nothing (Q [-◇ (p ◇ a)]) -> Nothing ((P ∧ Q) [-◇ a ]) second a p P' Q' (Ppa , pMax) noQ-p◇a f (Pfa , Qfa) = noQ-p◇a g Qgpa where f≤p = pMax f Pfa g = proj₁ f≤p f≐g◇p = proj₂ f≤p Qgpa : π₁ Q' (g ◇ (p ◇ a)) Qgpa = π₂ Q' (◃ext' f≐g◇p ∘ a) Qfa trivial-problem : ∀ {m n t} {f : m ~> n} -> π₁ (Max ((Unifies t t) [-◇ f ])) i trivial-problem = refl , λ f' _ → f' , λ _ → refl var-elim : ∀ {m} (x : Fin (suc m)) (t' : Term _) -> π₁ (Max ((Unifies (i x) ((▹ (thin x) ◃) t')))) (t' for x) var-elim x t' = first , \{_} -> second where lemma : ∀{m}(x : Fin (suc m)) t → i ≐ ((t for x) ◇ (▹ (thin x))) lemma x t x' = sym (cong (maybe i t) (Thick.half2 x _ x' refl)) first = begin (t' for x) ◃ (i x) ≡⟨ cong (maybe i t') (Thick.half1 x) ⟩ t' ≡⟨ sym (Sub.fact1 t') ⟩ i ◃ t' ≡⟨ ◃ext' (lemma x t') t' ⟩ (t' for x) ◃ ((▹ (thin x) ◃) t') ∎ second : ∀ {n} (f : _ ~> n) → f x ≡ f ◃ ((▹ (thin x) ◃) t') → f ≤ (t' for x) second f Unifiesf = (f ∘ thin x) , third where third : ((x' : Fin _) → f x' ≡ (f ∘ thin x) ◃ (maybe′ i t' (thick x x'))) third x' with thick x x' | Thick.fact1 x x' (thick x x') refl third .x | .nothing | inj₁ (refl , refl) = sym (begin (f ∘ thin x) ◃ t' ≡⟨ cong (λ g -> (g ◃) t') (sym (Sub.fact3 f (thin x))) ⟩ (f ◇ (▹ (thin x))) ◃ t' ≡⟨ Sub.fact2 f (▹ (thin x)) t' ⟩ f ◃ ((▹ (thin x) ◃) t') ≡⟨ sym Unifiesf ⟩ f x ∎) third x' | .(just y) | inj₂ (y , ( thinxy≡x' , refl)) = sym (cong f thinxy≡x') var-elim-i : ∀ {m} (x : Fin (suc m)) (t' : Term _) -> π₁ (Max ((Unifies (i x) ((▹ (thin x) ◃) t')))) (i ◇ (t' for x)) var-elim-i {m} x t = prop-id {_} {_} {t for x} {Max (Unifies (i x) ((▹ (thin x) ◃) t))} (var-elim {m} x t) var-elim-i-≡ : ∀ {m} {t'} (x : Fin (suc m)) t1 -> t1 ≡ (i ∘ thin x) ◃ t' -> π₁ (Max (Unifies (i x) t1)) (i ◇ (t' for x)) var-elim-i-≡ {_} {t'} x .((i ∘ thin x) ◃ t') refl = var-elim-i x t' data Step (n : ℕ) : Set where left : Term n -> Step n right : Term n -> Step n fmapS : ∀ {n m} (f : Term n -> Term m) (s : Step n) -> Step m fmapS f (left x) = left (f x) fmapS f (right x) = right (f x) _⊹_ : ∀ {n} (ps : List (Step n)) (t : Term n) -> Term n [] ⊹ t = t (left r ∷ ps) ⊹ t = (ps ⊹ t) fork r (right l ∷ ps) ⊹ t = l fork (ps ⊹ t) _◃S : ∀ {n m} (f : n ~> m) -> List (Step n) -> List (Step m) _◃S f = Data.List.map (fmapS (f ◃)) map-[] : ∀ {n m} (f : n ~> m) ps -> (f ◃S) ps ≡ [] -> ps ≡ [] map-[] f [] _ = refl map-[] f (x ∷ xs) () module StepM where lemma1 : ∀ {n} (x : Step n) xs t -> [ x ] ⊹ ( xs ⊹ t ) ≡ (x ∷ xs) ⊹ t lemma1 (left y) xs t = refl lemma1 (right y) xs t = refl lemma2 : ∀ {n} {r} {t} {xs} (x : Step n) -> xs ⊹ t ≡ r -> ((x ∷ xs) ⊹ t ) ≡ [ x ] ⊹ r lemma2 (left y) eq = cong (λ t -> t fork y) eq lemma2 (right y) eq = cong (λ t -> y fork t) eq fact1 : ∀ {n} ps qs (t : Term n) -> (ps ++L qs) ⊹ t ≡ ps ⊹ (qs ⊹ t) fact1 [] qs t = refl fact1 (p ∷ ps) qs t = begin (p ∷ (ps ++L qs)) ⊹ t ≡⟨ lemma2 p (fact1 ps qs t) ⟩ [ p ] ⊹ (ps ⊹ (qs ⊹ t)) ≡⟨ lemma1 p ps (qs ⊹ t) ⟩ (p ∷ ps) ⊹ (qs ⊹ t) ∎ fact2 : ∀ {m n} (f : m ~> n) t ps -> f ◃ (ps ⊹ t) ≡ (f ◃S) ps ⊹ (f ◃ t) fact2 f t [] = refl fact2 f t (left y ∷ xs) = cong (λ t -> t fork (f ◃ y)) (fact2 f t xs) fact2 f t (right y ∷ xs) = cong (λ t -> (f ◃ y) fork t) (fact2 f t xs) check-prop : ∀ {m} (x : Fin (suc m)) t -> (∃ λ t' -> t ≡ (▹ (thin x) ◃) t' × check x t ≡ just t') ⊎ (∃ λ ps -> t ≡ (ps ⊹ i x) × check x t ≡ nothing) check-prop x (i x') with Thick.fact1 x x' (thick x x') refl check-prop x (i .x) | inj₁ (refl , e) = inj₂ ([] , refl , cong (_<$>_ i) e) ... | inj₂ (y , thinxy≡x' , thickxx'≡justy') = inj₁ (i y , cong i (sym (thinxy≡x')) , cong (_<$>_ i) thickxx'≡justy' ) check-prop x leaf = inj₁ (leaf , (refl , refl)) check-prop x (s fork t) with check-prop x s | check-prop x t ... | inj₁ (s' , s≡thinxs' , checkxs≡s') | inj₁ (t' , t≡thinxt' , checkxt≡t') = inj₁ (s' fork t' , cong₂ _fork_ s≡thinxs' t≡thinxt' , cong₂ (λ a b -> _fork_ <$> a ⊛ b) checkxs≡s' checkxt≡t' ) ... | inj₂ (ps , s≡ps+ix , checkxs≡no ) | _ = inj₂ (left t ∷ ps , cong (λ s -> s fork t) s≡ps+ix , cong (λ a -> _fork_ <$> a ⊛ check x t) checkxs≡no ) ... | _ | inj₂ (ps , s≡ps+ix , checkxs≡no ) = inj₂ (right s ∷ ps , cong (λ t -> s fork t) s≡ps+ix , trans (cong (λ a -> _fork_ <$> check x s ⊛ a) checkxs≡no) (lemma (_fork_ <$> check x s))) where lemma : ∀ {a b : Set} {y : b} (x : Maybe a) -> maybe (λ _ → y) y x ≡ y lemma (just x') = refl lemma nothing = refl fork++ : ∀ {m} {s t : Term m} ps -> (ps ⊹ (s fork t) ≡ (ps ++L [ left t ]) ⊹ s) × (ps ⊹ (s fork t) ≡ (ps ++L [ right s ]) ⊹ t) fork++ [] = refl , refl fork++ (left y' ∷ xs') = (cong (λ a -> a fork y') *** cong (λ a -> a fork y')) (fork++ xs') fork++ (right y' ∷ xs') = (cong (λ a -> y' fork a) *** cong (λ a -> y' fork a)) (fork++ xs') No-Cycle : ∀{m} (t : Term m) ps -> t ≡ ps ⊹ t -> ps ≡ [] No-Cycle _ [] refl = refl No-Cycle (i x) (left _ ∷ xs) () No-Cycle leaf (left y ∷ xs) () No-Cycle {m} (s fork t) (left y ∷ xs) r = proof where f : Term m -> Term m f (s fork t) = s f _ = s hyp : xs ++L [ left t ] ≡ [] hyp = No-Cycle s (xs ++L [ left t ]) (trans (cong f r) (proj₁ (fork++ xs))) proof : left y ∷ xs ≡ [] proof = case (_,_ {B = λ x → x ++L _ ≡ _} xs hyp) of λ { ([] , ()) ; (_ ∷ _ , ()) } No-Cycle (i x) (right _ ∷ xs) () No-Cycle leaf (right _ ∷ xs) () No-Cycle {m} (s fork t) (right y ∷ xs) r = proof where f : Term m -> Term m f (s fork t) = t f _ = s hyp = No-Cycle t (xs ++L [ right s ]) (trans (cong f r) (proj₂ (fork++ xs))) proof : right y ∷ xs ≡ [] proof = case (_,_ {B = λ x → x ++L _ ≡ _} xs hyp) of λ { ([] , ()) ; (_ ∷ _ , ()) } module Step2 where fact : ∀{m} (x : Fin m) p ps -> Nothing (Unifies (i x) ((p ∷ ps) ⊹ i x)) fact x p ps f r with No-Cycle (f x) ((f ◃S) (p ∷ ps)) (trans r (StepM.fact2 f (i x) (p ∷ ps))) ... | () ◇-assoc : ∀ {l m n o} (f : l ~> m) (g : n ~> _) (h : o ~> _) -> (f ◇ (g ◇ h)) ≐ ((f ◇ g) ◇ h) ◇-assoc f g h x = sym (Sub.fact2 f g (h x)) bind-assoc : ∀ {l m n o} (f : l ~> m) (g : n ~> _) (h : o ~> _) t -> (f ◇ g) ◃ (h ◃ t) ≡ (f ◇ (g ◇ h)) ◃ t bind-assoc f g h t = sym (begin (f ◇ (g ◇ h)) ◃ t ≡⟨ ◃ext (◇-assoc f g h) t ⟩ ((f ◇ g) ◇ h) ◃ t ≡⟨ Sub.fact2 (f ◇ g) h t ⟩ (f ◇ g) ◃ (h ◃ t) ∎) step-prop : ∀ {m n} (s t : Term (suc m)) (σ : AList m n) r z -> (Unifies s t [-◇ sub (σ asnoc r / z) ]) ⇔ (Unifies ((r for z) ◃ s) ((r for z) ◃ t) [-◇ sub σ ]) step-prop s t σ r z f = to , from where lemma1 : ∀ t -> (f ◇ sub σ) ◃ ((r for z) ◃ t) ≡ (f ◇ (sub σ ◇ (r for z))) ◃ t lemma1 t = bind-assoc f (sub σ) (r for z) t to = λ a → begin (f ◇ sub σ) ◃ ((r for z) ◃ s) ≡⟨ lemma1 s ⟩ (f ◇ (sub σ ◇ (r for z))) ◃ s ≡⟨ a ⟩ (f ◇ (sub σ ◇ (r for z))) ◃ t ≡⟨ sym (lemma1 t) ⟩ (f ◇ sub σ) ◃ ((r for z) ◃ t) ∎ from = λ a → begin (f ◇ (sub σ ◇ (r for z))) ◃ s ≡⟨ sym (lemma1 s) ⟩ (f ◇ sub σ) ◃ ((r for z) ◃ s) ≡⟨ a ⟩ (f ◇ sub σ) ◃ ((r for z) ◃ t) ≡⟨ lemma1 t ⟩ (f ◇ (sub σ ◇ (r for z))) ◃ t ∎ -- We use a view so that we need to handle fewer cases in the main proof data Amgu : {m : ℕ} -> (s t : Term m) -> ∃ (AList m) -> Maybe (∃ (AList m)) -> Set where Flip : ∀ {m s t acc} -> amgu t s acc ≡ amgu s t acc -> Amgu {m} t s acc (amgu t s acc) -> Amgu s t acc (amgu s t acc) leaf-leaf : ∀ {m acc} -> Amgu {m} leaf leaf acc (just acc) leaf-fork : ∀ {m s t acc} -> Amgu {m} leaf (s fork t) acc nothing fork-fork : ∀ {m s1 s2 t1 t2 acc} -> Amgu {m} (s1 fork s2) (t1 fork t2) acc (amgu s2 t2 =<< amgu s1 t1 acc) var-var : ∀ {m x y} -> Amgu (i x) (i y) (m , anil) (just (flexFlex x y)) var-t : ∀ {m x t} -> i x ≢ t -> Amgu (i x) t (m , anil) (flexRigid x t) s-t : ∀{m s t n σ r z} -> Amgu {suc m} s t (n , σ asnoc r / z) ((λ σ -> σ ∃asnoc r / z) <$> amgu ((r for z) ◃ s) ((r for z) ◃ t) (n , σ)) view : ∀ {m : ℕ} -> (s t : Term m) -> (acc : ∃ (AList m)) -> Amgu s t acc (amgu s t acc) view leaf leaf acc = leaf-leaf view leaf (s fork t) acc = leaf-fork view (s fork t) leaf acc = Flip refl leaf-fork view (s1 fork s2) (t1 fork t2) acc = fork-fork view (i x) (i y) (m , anil) = var-var view (i x) leaf (m , anil) = var-t (λ ()) view (i x) (s fork t) (m , anil) = var-t (λ ()) view leaf (i x) (m , anil) = Flip refl (var-t (λ ())) view (s fork t) (i x) (m , anil) = Flip refl (var-t (λ ())) view (i x) (i x') (n , σ asnoc r / z) = s-t view (i x) leaf (n , σ asnoc r / z) = s-t view (i x) (s fork t) (n , σ asnoc r / z) = s-t view leaf (i x) (n , σ asnoc r / z) = s-t view (s fork t) (i x) (n , σ asnoc r / z) = s-t amgu-Correctness : {m : ℕ} -> (s t : Term m) -> ∃ (AList m) -> Set amgu-Correctness s t (l , ρ) = (∃ λ n → ∃ λ σ → π₁ (Max (Unifies s t [-◇ sub ρ ])) (sub σ) × amgu s t (l , ρ) ≡ just (n , σ ++ ρ )) ⊎ (Nothing ((Unifies s t) [-◇ sub ρ ]) × amgu s t (l , ρ) ≡ nothing) amgu-Correctness⋆ : {m : ℕ} -> (s t : Term m) -> ∃ (AList m) -> Set amgu-Correctness⋆ s t (l , ρ) = (∃ λ n → ∃ λ σ → π₁ (Max (Unifies s t [-◇ sub ρ ])) (sub σ) × amgu s t (l , ρ) ≡ just (n , σ ++ ρ )) ⊎ (Nothing ((Unifies s t) [-◇ sub ρ ]) × amgu s t (l , ρ) ≡ nothing) amgu-Ccomm : ∀ {m} s t acc -> amgu {m} s t acc ≡ amgu t s acc -> amgu-Correctness s t acc -> amgu-Correctness t s acc amgu-Ccomm s t (l , ρ) st≡ts = lemma where Unst = (Unifies s t) [-◇ sub ρ ] Unts = (Unifies t s) [-◇ sub ρ ] Unst⇔Unts : ((Unifies s t) [-◇ sub ρ ]) ⇔ ((Unifies t s) [-◇ sub ρ ]) Unst⇔Unts = Properties.fact5 (Unifies s t) (Unifies t s) (sub ρ) (Properties.fact1 {_} {s} {t}) lemma : amgu-Correctness s t (l , ρ) -> amgu-Correctness t s (l , ρ) lemma (inj₁ (n , σ , MaxUnst , amgu≡just)) = inj₁ (n , σ , proj₁ (Max.fact Unst Unts Unst⇔Unts (sub σ)) MaxUnst , trans (sym st≡ts) amgu≡just) lemma (inj₂ (NoUnst , amgu≡nothing)) = inj₂ ((λ {_} → Properties.fact2 Unst Unts Unst⇔Unts NoUnst) , trans (sym st≡ts) amgu≡nothing) amgu-Ccomm⋆ : ∀ {m} s t acc -> amgu {m} s t acc ≡ amgu t s acc -> amgu-Correctness⋆ s t acc -> amgu-Correctness⋆ t s acc amgu-Ccomm⋆ s t (l , ρ) st≡ts = lemma where Unst = (Unifies s t) [-◇ sub ρ ] Unts = (Unifies t s) [-◇ sub ρ ] Unst⇔Unts : ((Unifies s t) [-◇ sub ρ ]) ⇔ ((Unifies t s) [-◇ sub ρ ]) Unst⇔Unts = Properties.fact5 (Unifies s t) (Unifies t s) (sub ρ) (Properties.fact1 {_} {s} {t}) lemma : amgu-Correctness s t (l , ρ) -> amgu-Correctness t s (l , ρ) lemma (inj₁ (n , σ , MaxUnst , amgu≡just)) = inj₁ (n , σ , proj₁ (Max.fact Unst Unts Unst⇔Unts (sub σ)) MaxUnst , trans (sym st≡ts) amgu≡just) lemma (inj₂ (NoUnst , amgu≡nothing)) = inj₂ ((λ {_} → Properties.fact2 Unst Unts Unst⇔Unts NoUnst) , trans (sym st≡ts) amgu≡nothing) amgu-c : ∀ {m s t l ρ} -> Amgu s t (l , ρ) (amgu s t (l , ρ)) -> (∃ λ n → ∃ λ σ → π₁ (Max ((Unifies s t) [-◇ sub ρ ])) (sub σ) × amgu {m} s t (l , ρ) ≡ just (n , σ ++ ρ )) ⊎ (Nothing ((Unifies s t) [-◇ sub ρ ]) × amgu {m} s t (l , ρ) ≡ nothing) amgu-c {m} {s} {t} {l} {ρ} amg with amgu s t (l , ρ) amgu-c {l = l} {ρ} leaf-leaf | ._ = inj₁ (l , anil , trivial-problem {_} {_} {leaf} {sub ρ} , cong (λ x -> just (l , x)) (sym (SubList.anil-id-l ρ)) ) amgu-c leaf-fork | .nothing = inj₂ ((λ _ () ) , refl) amgu-c {m} {s1 fork s2} {t1 fork t2} {l} {ρ} fork-fork | ._ with amgu s1 t1 (l , ρ) | amgu-c $ view s1 t1 (l , ρ) ... | .nothing | inj₂ (nounify , refl) = inj₂ ((λ {_} -> No[Q◇ρ]→No[P◇ρ] No[Q◇ρ]) , refl) where P = Unifies (s1 fork s2) (t1 fork t2) Q = (Unifies s1 t1 ∧ Unifies s2 t2) Q⇔P : Q ⇔ P Q⇔P = switch P Q (Properties.fact1' {_} {s1} {s2} {t1} {t2}) No[Q◇ρ]→No[P◇ρ] : Nothing (Q [-◇ sub ρ ]) -> Nothing (P [-◇ sub ρ ]) No[Q◇ρ]→No[P◇ρ] = Properties.fact2 (Q [-◇ sub ρ ]) (P [-◇ sub ρ ]) (Properties.fact5 Q P (sub ρ) Q⇔P) No[Q◇ρ] : Nothing (Q [-◇ sub ρ ]) No[Q◇ρ] = failure-propagation.first (sub ρ) (Unifies s1 t1) (Unifies s2 t2) nounify ... | .(just (n , σ ++ ρ)) | inj₁ (n , σ , a , refl) with amgu s2 t2 (n , σ ++ ρ) | amgu-c (view s2 t2 (n , (σ ++ ρ))) ... | .nothing | inj₂ (nounify , refl) = inj₂ ( (λ {_} -> No[Q◇ρ]→No[P◇ρ] No[Q◇ρ]) , refl) where P = Unifies (s1 fork s2) (t1 fork t2) Q = (Unifies s1 t1 ∧ Unifies s2 t2) Q⇔P : Q ⇔ P Q⇔P = switch P Q (Properties.fact1' {_} {s1} {s2} {t1} {t2}) No[Q◇ρ]→No[P◇ρ] : Nothing (Q [-◇ sub ρ ]) -> Nothing (P [-◇ sub ρ ]) No[Q◇ρ]→No[P◇ρ] = Properties.fact2 (Q [-◇ sub ρ ]) (P [-◇ sub ρ ]) (Properties.fact5 Q P (sub ρ) Q⇔P) No[Q◇ρ] : Nothing (Q [-◇ sub ρ ]) No[Q◇ρ] = failure-propagation.second (sub ρ) (sub σ) (Unifies s1 t1) (Unifies s2 t2) a (λ f Unifs2t2-f◇σ◇ρ → nounify f (π₂ (Unifies s2 t2) (λ t → cong (f ◃) (sym (SubList.fact1 σ ρ t))) Unifs2t2-f◇σ◇ρ)) ... | .(just (n1 , σ1 ++ (σ ++ ρ))) | inj₁ (n1 , σ1 , b , refl) = inj₁ (n1 , σ1 ++ σ , Max[P∧Q◇ρ][σ1++σ] , cong (λ σ -> just (n1 , σ)) (++-assoc σ1 σ ρ)) where P = Unifies s1 t1 Q = Unifies s2 t2 P∧Q = P ∧ Q C = Unifies (s1 fork s2) (t1 fork t2) Max[C◇ρ]⇔Max[P∧Q◇ρ] : Max (C [-◇ sub ρ ]) ⇔ Max (P∧Q [-◇ sub ρ ]) Max[C◇ρ]⇔Max[P∧Q◇ρ] = Max.fact (C [-◇ sub ρ ]) (P∧Q [-◇ sub ρ ]) (Properties.fact5 C P∧Q (sub ρ) (Properties.fact1' {_} {s1} {s2} {t1} {t2})) Max[Q◇σ++ρ]⇔Max[Q◇σ◇ρ] : Max (Q [-◇ sub (σ ++ ρ)]) ⇔ Max (Q [-◇ sub σ ◇ sub ρ ]) Max[Q◇σ++ρ]⇔Max[Q◇σ◇ρ] = Max.fact (Q [-◇ sub (σ ++ ρ)]) (Q [-◇ sub σ ◇ sub ρ ]) (Properties.fact6 Q (SubList.fact1 σ ρ)) Max[P∧Q◇ρ][σ1++σ] : π₁ (Max (C [-◇ sub ρ ])) (sub (σ1 ++ σ)) Max[P∧Q◇ρ][σ1++σ] = π₂ (Max (C [-◇ sub ρ ])) (≐-sym (SubList.fact1 σ1 σ)) (proj₂ (Max[C◇ρ]⇔Max[P∧Q◇ρ] (sub σ1 ◇ sub σ)) (optimist (sub ρ) (sub σ) (sub σ1) P Q (DClosed.fact1 s1 t1) a (proj₁ (Max[Q◇σ++ρ]⇔Max[Q◇σ◇ρ] (sub σ1)) b))) amgu-c {suc l} {i x} {i y} (var-var) | .(just (flexFlex x y)) with thick x y | Thick.fact1 x y (thick x y) refl ... | .(just y') | inj₂ (y' , thinxy'≡y , refl ) = inj₁ (l , anil asnoc i y' / x , var-elim-i-≡ x (i y) (sym (cong i thinxy'≡y)) , refl ) ... | .nothing | inj₁ ( x≡y , refl ) rewrite sym x≡y = inj₁ (suc l , anil , trivial-problem {_} {_} {i x} {sub anil} , refl) amgu-c {suc l} {i x} {t} (var-t ix≢t) | .(flexRigid x t) with check x t | check-prop x t ... | .nothing | inj₂ ( ps , r , refl) = inj₂ ( (λ {_} -> No-Unifier ) , refl) where No-Unifier : {n : ℕ} (f : Fin (suc l) → Term n) → f x ≡ f ◃ t → ⊥ No-Unifier f fx≡f◃t = ix≢t (sym (trans r (cong (λ ps -> ps ⊹ i x) ps≡[]))) where ps≡[] : ps ≡ [] ps≡[] = map-[] f ps (No-Cycle (f x) ((f ◃S) ps) (begin f x ≡⟨ fx≡f◃t ⟩ f ◃ t ≡⟨ cong (f ◃) r ⟩ f ◃ (ps ⊹ i x) ≡⟨ StepM.fact2 f (i x) ps ⟩ (f ◃S) ps ⊹ f x ∎)) ... | .(just t') | inj₁ (t' , r , refl) = inj₁ ( l , anil asnoc t' / x , var-elim-i-≡ x t r , refl ) amgu-c {suc m} {s} {t} {l} {ρ asnoc r / z} s-t | .((λ x' → x' ∃asnoc r / z) <$> (amgu ((r for z) ◃ s) ((r for z) ◃ t) (l , ρ))) with amgu-c (view ((r for z) ◃ s) ((r for z) ◃ t) (l , ρ)) ... | inj₂ (nounify , ra) = inj₂ ( (λ {_} -> NoQ→NoP nounify) , cong (_<$>_ (λ x' → x' ∃asnoc r / z)) ra ) where P = Unifies s t [-◇ sub (ρ asnoc r / z) ] Q = Unifies ((r for z) ◃ s) ((r for z) ◃ t) [-◇ sub ρ ] NoQ→NoP : Nothing Q → Nothing P NoQ→NoP = Properties.fact2 Q P (switch P Q (step-prop s t ρ r z)) ... | inj₁ (n , σ , a , ra) = inj₁ (n , σ , proj₂ (MaxP⇔MaxQ (sub σ)) a , cong (_<$>_ (λ x' → x' ∃asnoc r / z)) ra) where P = Unifies s t [-◇ sub (ρ asnoc r / z) ] Q = Unifies ((r for z) ◃ s) ((r for z) ◃ t) [-◇ sub ρ ] MaxP⇔MaxQ : Max P ⇔ Max Q MaxP⇔MaxQ = Max.fact P Q (step-prop s t ρ r z) amgu-c {m} {s} {t} {l} {ρ} (Flip amguts≡amgust amguts) | ._ = amgu-Ccomm t s (l , ρ) amguts≡amgust (amgu-c amguts) amgu-c {zero} {i ()} _ | _ amgu-c⋆ : ∀ {m s t l ρ} -> Amgu s t (l , ρ) (amgu s t (l , ρ)) -> (∃ λ n → ∃ λ σ → (Max⋆ ((Unifies⋆ s t) [-◇⋆ sub ρ ])) (sub σ) × amgu {m} s t (l , ρ) ≡ just (n , σ ++ ρ )) ⊎ (Nothing⋆ ((Unifies⋆ s t) [-◇⋆ sub ρ ]) × amgu {m} s t (l , ρ) ≡ nothing) amgu-c⋆ {m} {s} {t} {l} {ρ} amg with amgu s t (l , ρ) amgu-c⋆ {l = l} {ρ} leaf-leaf | ._ = inj₁ (l , anil , trivial-problem {_} {_} {leaf} {sub ρ} , cong (λ x -> just (l , x)) (sym (SubList.anil-id-l ρ)) ) amgu-c⋆ leaf-fork | .nothing = inj₂ ((λ _ () ) , refl) amgu-c⋆ {m} {s1 fork s2} {t1 fork t2} {l} {ρ} fork-fork | ._ with amgu s1 t1 (l , ρ) | amgu-c⋆ $ view s1 t1 (l , ρ) ... | .nothing | inj₂ (nounify , refl) = inj₂ ((λ {_} -> No[Q◇ρ]→No[P◇ρ] No[Q◇ρ]) , refl) where P = Unifies⋆ (s1 fork s2) (t1 fork t2) Q = (Unifies⋆ s1 t1 ∧⋆ Unifies⋆ s2 t2) Q⇔P : Q ⇔⋆ P Q⇔P = switch⋆ P Q (Properties.fact1' {_} {s1} {s2} {t1} {t2}) No[Q◇ρ]→No[P◇ρ] : Nothing⋆ (Q [-◇⋆ sub ρ ]) -> Nothing⋆ (P [-◇⋆ sub ρ ]) No[Q◇ρ]→No[P◇ρ] = Properties.fact2⋆ (Q [-◇⋆ sub ρ ]) (P [-◇⋆ sub ρ ]) (Properties.fact5⋆ Q P (sub ρ) Q⇔P) No[Q◇ρ] : Nothing⋆ (Q [-◇⋆ sub ρ ]) No[Q◇ρ] = failure-propagation.first⋆ (sub ρ) (Unifies⋆ s1 t1) (Unifies⋆ s2 t2) nounify ... | .(just (n , σ ++ ρ)) | inj₁ (n , σ , a , refl) with amgu s2 t2 (n , σ ++ ρ) | amgu-c⋆ (view s2 t2 (n , (σ ++ ρ))) ... | .nothing | inj₂ (nounify , refl) = inj₂ ( (λ {_} -> No[Q◇ρ]→No[P◇ρ]⋆ No[Q◇ρ]⋆) , refl) where P⋆ = Unifies⋆ (s1 fork s2) (t1 fork t2) Q⋆ = (Unifies⋆ s1 t1 ∧⋆ Unifies⋆ s2 t2) Q⇔P⋆ : Q⋆ ⇔⋆ P⋆ Q⇔P⋆ = switch⋆ P⋆ Q⋆ (Properties.fact1'⋆ {_} {s1} {s2} {t1} {t2}) No[Q◇ρ]→No[P◇ρ]⋆ : Nothing⋆ (Q⋆ [-◇⋆ sub ρ ]) -> Nothing⋆ (P⋆ [-◇⋆ sub ρ ]) No[Q◇ρ]→No[P◇ρ]⋆ = Properties.fact2⋆ (Q⋆ [-◇⋆ sub ρ ]) (P⋆ [-◇⋆ sub ρ ]) (Properties.fact5⋆ Q⋆ P⋆ (sub ρ) Q⇔P⋆) No[Q◇ρ]⋆ : Nothing⋆ (Q⋆ [-◇⋆ sub ρ ]) No[Q◇ρ]⋆ = failure-propagation.second⋆ (sub ρ) (sub σ) (Unifies⋆ s1 t1) (Unifies s2 t2) a (λ f → nounify f ∘ π₂ (Unifies s2 t2) (cong (f ◃) ∘ sym ∘ SubList.fact1 σ ρ)) {- No[Q◇ρ]⋆ = failure-propagation.second (sub ρ) (sub σ) (Unifies s1 t1) (Unifies s2 t2) a -- (λ f Unifs2t2-f◇σ◇ρ → nounify f ((π₂ (Unifies s2 t2) (λ t → cong (f ◃) (sym (SubList.fact1 σ ρ t))) Unifs2t2-f◇σ◇ρ))) -- (λ f → nounify f ∘ π₂ (Unifies s2 t2) (λ t → cong (f ◃) (sym (SubList.fact1 σ ρ t)))) (λ f → nounify f ∘ π₂ (Unifies s2 t2) (cong (f ◃) ∘ sym ∘ SubList.fact1 σ ρ)) -} P = Unifies (s1 fork s2) (t1 fork t2) Q = (Unifies s1 t1 ∧ Unifies s2 t2) Q⇔P : Q ⇔ P Q⇔P = switch P Q (Properties.fact1' {_} {s1} {s2} {t1} {t2}) No[Q◇ρ]→No[P◇ρ] : Nothing (Q [-◇ sub ρ ]) -> Nothing (P [-◇ sub ρ ]) No[Q◇ρ]→No[P◇ρ] = Properties.fact2 (Q [-◇ sub ρ ]) (P [-◇ sub ρ ]) (Properties.fact5 Q P (sub ρ) Q⇔P) No[Q◇ρ] : Nothing (Q [-◇ sub ρ ]) No[Q◇ρ] = failure-propagation.second (sub ρ) (sub σ) (Unifies s1 t1) (Unifies s2 t2) a (λ f Unifs2t2-f◇σ◇ρ → nounify f (π₂ (Unifies s2 t2) (λ t → cong (f ◃) (sym (SubList.fact1 σ ρ t))) Unifs2t2-f◇σ◇ρ)) ... | .(just (n1 , σ1 ++ (σ ++ ρ))) | inj₁ (n1 , σ1 , b , refl) = inj₁ (n1 , σ1 ++ σ , Max[P∧Q◇ρ][σ1++σ] , cong (λ σ -> just (n1 , σ)) (++-assoc σ1 σ ρ)) where P = Unifies s1 t1 Q = Unifies s2 t2 P∧Q = P ∧ Q C = Unifies (s1 fork s2) (t1 fork t2) Max[C◇ρ]⇔Max[P∧Q◇ρ] : Max (C [-◇ sub ρ ]) ⇔ Max (P∧Q [-◇ sub ρ ]) Max[C◇ρ]⇔Max[P∧Q◇ρ] = Max.fact (C [-◇ sub ρ ]) (P∧Q [-◇ sub ρ ]) (Properties.fact5 C P∧Q (sub ρ) (Properties.fact1' {_} {s1} {s2} {t1} {t2})) Max[Q◇σ++ρ]⇔Max[Q◇σ◇ρ] : Max (Q [-◇ sub (σ ++ ρ)]) ⇔ Max (Q [-◇ sub σ ◇ sub ρ ]) Max[Q◇σ++ρ]⇔Max[Q◇σ◇ρ] = Max.fact (Q [-◇ sub (σ ++ ρ)]) (Q [-◇ sub σ ◇ sub ρ ]) (Properties.fact6 Q (SubList.fact1 σ ρ)) Max[P∧Q◇ρ][σ1++σ] : π₁ (Max (C [-◇ sub ρ ])) (sub (σ1 ++ σ)) Max[P∧Q◇ρ][σ1++σ] = π₂ (Max (C [-◇ sub ρ ])) (≐-sym (SubList.fact1 σ1 σ)) (proj₂ (Max[C◇ρ]⇔Max[P∧Q◇ρ] (sub σ1 ◇ sub σ)) (optimist (sub ρ) (sub σ) (sub σ1) P Q (DClosed.fact1 s1 t1) a (proj₁ (Max[Q◇σ++ρ]⇔Max[Q◇σ◇ρ] (sub σ1)) b))) amgu-c⋆ {suc l} {i x} {i y} (var-var) | .(just (flexFlex x y)) with thick x y | Thick.fact1 x y (thick x y) refl ... | .(just y') | inj₂ (y' , thinxy'≡y , refl ) = inj₁ (l , anil asnoc i y' / x , var-elim-i-≡ x (i y) (sym (cong i thinxy'≡y)) , refl ) ... | .nothing | inj₁ ( x≡y , refl ) rewrite sym x≡y = inj₁ (suc l , anil , trivial-problem {_} {_} {i x} {sub anil} , refl) amgu-c⋆ {suc l} {i x} {t} (var-t ix≢t) | .(flexRigid x t) with check x t | check-prop x t ... | .nothing | inj₂ ( ps , r , refl) = inj₂ ( (λ {_} -> No-Unifier ) , refl) where No-Unifier : {n : ℕ} (f : Fin (suc l) → Term n) → f x ≡ f ◃ t → ⊥ No-Unifier f fx≡f◃t = ix≢t (sym (trans r (cong (λ ps -> ps ⊹ i x) ps≡[]))) where ps≡[] : ps ≡ [] ps≡[] = map-[] f ps (No-Cycle (f x) ((f ◃S) ps) (begin f x ≡⟨ fx≡f◃t ⟩ f ◃ t ≡⟨ cong (f ◃) r ⟩ f ◃ (ps ⊹ i x) ≡⟨ StepM.fact2 f (i x) ps ⟩ (f ◃S) ps ⊹ f x ∎)) ... | .(just t') | inj₁ (t' , r , refl) = inj₁ ( l , anil asnoc t' / x , var-elim-i-≡ x t r , refl ) amgu-c⋆ {suc m} {s} {t} {l} {ρ asnoc r / z} s-t | .((λ x' → x' ∃asnoc r / z) <$> (amgu ((r for z) ◃ s) ((r for z) ◃ t) (l , ρ))) with amgu-c⋆ (view ((r for z) ◃ s) ((r for z) ◃ t) (l , ρ)) ... | inj₂ (nounify , ra) = inj₂ ( (λ {_} -> NoQ→NoP nounify) , cong (_<$>_ (λ x' → x' ∃asnoc r / z)) ra ) where P = Unifies s t [-◇ sub (ρ asnoc r / z) ] Q = Unifies ((r for z) ◃ s) ((r for z) ◃ t) [-◇ sub ρ ] NoQ→NoP : Nothing Q → Nothing P NoQ→NoP = Properties.fact2 Q P (switch P Q (step-prop s t ρ r z)) ... | inj₁ (n , σ , a , ra) = inj₁ (n , σ , proj₂ (MaxP⇔MaxQ (sub σ)) a , cong (_<$>_ (λ x' → x' ∃asnoc r / z)) ra) where P = Unifies s t [-◇ sub (ρ asnoc r / z) ] Q = Unifies ((r for z) ◃ s) ((r for z) ◃ t) [-◇ sub ρ ] MaxP⇔MaxQ : Max P ⇔ Max Q MaxP⇔MaxQ = Max.fact P Q (step-prop s t ρ r z) amgu-c⋆ {m} {s} {t} {l} {ρ} (Flip amguts≡amgust amguts) | ._ = amgu-Ccomm⋆ t s (l , ρ) amguts≡amgust (amgu-c⋆ amguts) amgu-c⋆ {zero} {i ()} _ | _ mgu-c : ∀ {m} (s t : Term m) -> (∃ λ n → ∃ λ σ → π₁ (Max (Unifies s t)) (sub σ) × mgu s t ≡ just (n , σ)) ⊎ (Nothing (Unifies s t) × mgu s t ≡ nothing) mgu-c {m} s t = amgu-c (view s t (m , anil)) mgu-c⋆ : ∀ {m} (s t : Term m) -> (∃ λ n → ∃ λ σ → (Max⋆ (Unifies⋆ s t)) (sub σ) × mgu s t ≡ just (n , σ)) ⊎ (Nothing⋆ (Unifies⋆ s t) × mgu s t ≡ nothing) mgu-c⋆ {m} s t = amgu-c (view s t (m , anil)) data SidedTerm (n : ℕ) : Set where i-left : (x : Fin n) -> 2 * Data.Fin.toℕ x Data.Nat.≤ n → SidedTerm n i-right : (x : Fin n) -> n + Data.Fin.toℕ x Data.Nat.≤ 2 * n → SidedTerm n leaf : SidedTerm n _fork_ : (s t : SidedTerm n) -> SidedTerm n data dTerm (n : ℕ) : Term (2 * n) → Set where -- i : l1 : ∀ m → Data.Fin.toℕ (Data.Fin.fromℕ m) ≡ m l1 zero = refl l1 (suc m) = cong suc (l1 m) l2 : ∀ m → m ≡ m + 0 l2 zero = refl l2 (suc m) = cong suc (l2 m) fixup : ∀ m → Fin (Data.Fin.toℕ (Data.Fin.fromℕ m) + m) → Fin (m + (m + 0)) fixup m x rewrite l1 m | sym (l2 m) = x revise-down : ∀ {m} → Fin m → Fin (2 * m) revise-down {m} x = Data.Fin.inject+ (m + 0) x revise-up : ∀ {m} → Fin m → Fin (2 * m) revise-up {m} x = fixup m (Data.Fin.fromℕ m Data.Fin.+ x) {- reduce* : ∀ {m n} (i : Fin (m * 2)) → Fin m reduce* {zero} i i≥m = i reduce* {suc m} zero () reduce* {suc m} (suc i) (s≤s i≥m) = reduce≥ i i≥m -} downFin : ∀ {m} {x : Fin (2 * m)} → suc (Data.Fin.toℕ x) Data.Nat.≤ m → Fin m downFin {zero} {()} p₁ downFin {suc m} {zero} (s≤s p₁) = zero downFin {suc zero} {suc zero} (s≤s p₁) = zero downFin {suc zero} {suc (suc ())} (s≤s p₁) downFin {suc (suc m)} {suc zero} (s≤s x<m) = suc zero downFin {suc (suc m)} {suc (suc x)} (s≤s (s≤s x<m)) = suc ((downFin {suc m} {x = subst Fin (foo m) x} (s≤s {!x<m!}))) where foo : ∀ m → m + suc (suc (m + zero)) ≡ suc (m + suc (m + zero)) foo zero = refl foo (suc m) rewrite foo m = cong suc {!refl!} combineSubs : ∀ {m a} {A : Set a} → (Fin m → A) → (Fin m → A) → Fin (2 * m) → A combineSubs {m} fl fr x with suc (Data.Fin.toℕ x) ≤? m … | yes p = fl (downFin {x = x} p) … | no _ = fr {!!} write-variable-down : ∀ {m} → Term m → Term (2 * m) write-variable-down {m} (i l) = i $ revise-down l write-variable-down {m} leaf = leaf write-variable-down {m} (s fork t) = write-variable-down s fork write-variable-down t write-variable-up : ∀ {m} → Term m → Term (2 * m) write-variable-up {m} (i r) = i (revise-up r) write-variable-up {m} leaf = leaf write-variable-up {m} (s fork t) = write-variable-up s fork write-variable-up t write-variables-apart : ∀ {m} (s t : Term m) → Term (2 * m) × Term (2 * m) write-variables-apart s t = write-variable-down s , write-variable-up t separate-substitutions-down : ∀ {m n} → (Fin (2 * m) → Term n) → Fin m → Term n separate-substitutions-down {m} f x = f $ revise-down x separate-substitutions-up : ∀ {m n} → (Fin (2 * m) → Term n) → Fin m → Term n separate-substitutions-up {m} f x = f $ revise-up x separate-substitutions : ∀ {m n} → (Fin (2 * m) → Term n) → (Fin m → Term n) × (Fin m → Term n) separate-substitutions {m} x = separate-substitutions-down {m} x , separate-substitutions-up {m} x Property⋆2 : (m : ℕ) -> Set1 Property⋆2 m = ∀ {n} -> (Fin m -> Term n) × (Fin m -> Term n) -> Set Nothing⋆2 : ∀{m} -> (P : Property⋆2 m) -> Set Nothing⋆2 P = ∀{n} f -> P {n} f -> ⊥ Unifies⋆2 : ∀ {m} (s t : Term m) -> Property⋆2 m Unifies⋆2 s t (f₁ , f₂) = f₁ ◃ s ≡ f₂ ◃ t _≤2_ : ∀ {m n n'} (f : (Fin m -> Term n) × (Fin m -> Term n)) (g : (Fin m -> Term n') × (Fin m -> Term n')) -> Set (f₁ , f₂) ≤2 (g₁ , g₂) = ∃ λ f' -> f₁ ≐ (f' ◇ g₁) × f₂ ≐ (f' ◇ g₂) Max⋆2 : ∀ {m} (P : Property⋆2 m) -> Property⋆2 m Max⋆2 P f = P f × (∀ {n} f' -> P {n} f' -> f' ≤2 f) pair-mgu : ∀ {m} -> (s t : Term m) -> Maybe (∃ (AList m)) pair-mgu {m} s t = {!!} -- amgu s t (m , anil) write≡separate : ∀ {m n} (σ : AList (2 * m) n) (t : Term m) → (sub σ ◃) (write-variable-down t) ≡ ((separate-substitutions-down $ sub σ) ◃) t write≡separate {zero} {.0} anil (i x) = refl write≡separate {suc m} {.(suc (m + suc (m + 0)))} anil (i x) = refl write≡separate {suc m} {n} (σ asnoc t' / x) (i x₁) = refl write≡separate σ leaf = refl write≡separate σ (t₁ fork t₂) = cong₂ _fork_ (write≡separate σ t₁) (write≡separate σ t₂) write≡separate' : ∀ {m n} (σ : AList (2 * m) n) (t : Term m) → (sub σ ◃) (write-variable-down t) ≡ ((separate-substitutions-down $ sub σ) ◃) t write≡separate' {zero} {.0} anil (i x) = refl write≡separate' {suc m} {.(suc (m + suc (m + 0)))} anil (i x) = refl write≡separate' {suc m} {n} (σ asnoc t' / x) (i x₁) = refl write≡separate' σ leaf = refl write≡separate' σ (t₁ fork t₂) = cong₂ _fork_ (write≡separate σ t₁) (write≡separate σ t₂) {- (sub σ ◃) (write-variable-down s') ≡ (sub σ ◃) (write-variable-up t') → ((separate-substitutions-down $ sub σ) ◃) s' ≡ ((separate-substitutions-up $ sub σ) ◃) t' -} pair-mgu-c⋆! : ∀ {m} (s' t' : Term m) (let (s , t) = write-variables-apart s' t') -> (∃ λ n → ∃ λ σ → ∃ λ σ₁ → ∃ λ σ₂ → (σ₁ , σ₂) ≡ separate-substitutions (sub σ) × (Max⋆2 (Unifies⋆2 s' t')) (σ₁ , σ₂) × mgu s t ≡ just (n , σ)) ⊎ (Nothing⋆2 (Unifies⋆2 s t) × mgu s t ≡ nothing) pair-mgu-c⋆! {m} s' t' with write-variable-down s' | inspect write-variable-down s' | write-variable-up t' | inspect write-variable-up t' … | s | Reveal_·_is_.[_] refl | t | Reveal_·_is_.[_] refl with amgu-c⋆ (view s t (2 * m , anil)) … | (inj₁ (n , σ , (s-un-t , s-un-t-correct) , amgu=nσ)) = inj₁ (_ , σ , ((separate-substitutions-down $ sub σ) , ((separate-substitutions-up $ sub σ) , (refl , (({!trans (sym $ write≡separate σ s') s-un-t!} , (λ {(fl , fr) x → ((proj₁ ∘ s-un-t-correct (combineSubs fl fr)) {!(proj₂ ∘ s-un-t-correct (combineSubs fl fr)) !}) , ({!!} , {!!})})) , amgu=nσ))))) where … | (inj₂ (s-not-un-t , amgu=nothing)) = inj₂ {!!} -- pair-mgu-c⋆ : ∀ {m} (s' t' : Term m) (let (s , t) = write-variables-apart s' t') -> -- (∃ λ n → ∃ λ σ → ∃ λ σ₁ → ∃ λ σ₂ → (σ₁ , σ₂) ≡ separate-substitutions {m} {n} (sub {2 * m} {n} σ) × (Max⋆2 (Unifies⋆2 s t)) (σ₁ , σ₂) × mgu s t ≡ just (n , σ)) -- ⊎ (Nothing⋆2 (Unifies⋆2 s t) × mgu s t ≡ nothing) -- pair-mgu-c⋆ {m} s' t' -- with write-variables-apart s' t' -- … | (s , t) with amgu-c⋆ (view s t (2 * m , anil)) -- pair-mgu-c⋆ {m} s' t' | s , t | (inj₁ (n , σ , (s-un-t , s-un-t-correct) , amgu=nσ)) = inj₁ ({!!} , {!!}) -- pair-mgu-c⋆ {m} s' t' | s , t | (inj₂ (s-not-un-t , amgu=nothing)) = inj₂ {!!} -- -- pair-mgu-c⋆ {m} s t = {!!} -- amgu-c (view s t (m , anil)) -- {- -- Goal: Σ ℕ -- (λ n₁ → -- Σ (AList (m + (m + 0)) n₁) -- (λ σ₁ → -- Σ (Fin (m + (m + 0)) → Term n₁) -- (λ σ₂ → -- Σ (Fin (m + (m + 0)) → Term n₁) -- (λ σ₃ → -- Σ ((σ₂ , σ₃) ≡ (?8 (sub σ₁) , ?9 (sub σ₁))) -- (λ x → -- Σ -- (Σ ((σ₂ ◃) s ≡ (σ₃ ◃) t) -- (λ x₁ → -- {n = n₂ : ℕ} -- (f' -- : Σ (Fin (m + (m + 0)) → Term n₂) -- (λ x₂ → Fin (m + (m + 0)) → Term n₂)) → -- (proj₁ f' ◃) s ≡ (proj₂ f' ◃) t → -- Σ (Fin n₁ → Term n₂) -- (λ f'' → -- Σ ((x₂ : Fin (m + (m + 0))) → proj₁ f' x₂ ≡ (f'' ◃) (σ₂ x₂)) -- (λ x₂ → -- (x₃ : Fin (m + (m + 0))) → proj₂ f' x₃ ≡ (f'' ◃) (σ₃ x₃))))) -- (λ x₁ → amgu s t (m + (m + 0) , anil) ≡ just (n₁ , σ₁))))))) -- ⊎ -- Σ -- ({n = n₁ : ℕ} -- (f -- : Σ (Fin (m + (m + 0)) → Term n₁) -- (λ x → Fin (m + (m + 0)) → Term n₁)) → -- (proj₁ f ◃) s ≡ (proj₂ f ◃) t → ⊥) -- (λ x → amgu s t (m + (m + 0) , anil) ≡ nothing) -- ———————————————————————————————————————————————————————————— -- t' : Term m -- s' : Term m -- amgu=nσ : amgu s t (m + (m + 0) , anil) ≡ just (n , σ) -- s-un-t-correct -- : {n = n₁ : ℕ} (f' : Fin (m + (m + 0)) → Term n₁) → -- (f' ◃) s ≡ (f' ◃) t → -- Σ (Fin n → Term n₁) -- (λ f'' → (x : Fin (m + (m + 0))) → f' x ≡ (f'' ◃) (sub σ x)) -- s-un-t : (sub σ ◃) s ≡ (sub σ ◃) t -- σ : AList (m + (m + 0)) n -- n : ℕ -- t : Term (m + (m + 0)) -- s : Term (m + (m + 0)) -- m : ℕ -- -}
{ "alphanum_fraction": 0.4528399277, "avg_line_length": 42.4355518113, "ext": "agda", "hexsha": "4a702b49f482f5978ad8a379b08e1f90c2f48198", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-1/Unify-monolithic.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-1/Unify-monolithic.agda", "max_line_length": 364, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-1/Unify-monolithic.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 22782, "size": 50371 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics module lib.types.Lift where ⊙Lift : ∀ {i j} → Ptd i → Ptd (lmax i j) ⊙Lift {j = j} ⊙[ A , a ] = ⊙[ Lift {j = j} A , lift a ] ⊙lift : ∀ {i j} {X : Ptd i} → X ⊙→ ⊙Lift {j = j} X ⊙lift = (lift , idp) ⊙lower : ∀ {i j} {X : Ptd i} → ⊙Lift {j = j} X ⊙→ X ⊙lower = (lower , idp) lift-equiv : ∀ {i j} {A : Type i} → A ≃ Lift {j = j} A lift-equiv = equiv lift lower (λ _ → idp) (λ _ → idp) -- [lower-equiv] is in Equivalences.agda instance Lift-level : ∀ {i j} {A : Type i} {n : ℕ₋₂} → has-level n A → has-level n (Lift {j = j} A) Lift-level p = equiv-preserves-level lift-equiv {{p}} ⊙lift-equiv : ∀ {i j} {X : Ptd i} → X ⊙≃ ⊙Lift {j = j} X ⊙lift-equiv = (⊙lift , snd lift-equiv) ⊙lower-equiv : ∀ {i j} {X : Ptd i} → ⊙Lift {j = j} X ⊙≃ X ⊙lower-equiv = (⊙lower , snd lower-equiv) Lift-fmap : ∀ {i j k} {A : Type i} {B : Type j} → (A → B) → (Lift {j = k} A → Lift {j = k} B) Lift-fmap f = lift ∘ f ∘ lower Lift-fmap-equiv : ∀ {i j k} {A : Type i} {B : Type j} → (A → B) ≃ (Lift {j = k} A → Lift {j = k} B) Lift-fmap-equiv = equiv Lift-fmap (λ f → lower ∘ f ∘ lift) (λ _ → idp) (λ _ → idp) ⊙Lift-fmap : ∀ {i j k} {X : Ptd i} {Y : Ptd j} → (X ⊙→ Y) → (⊙Lift {j = k} X ⊙→ ⊙Lift {j = k} Y) ⊙Lift-fmap f = ⊙lift ⊙∘ f ⊙∘ ⊙lower ⊙Lift-fmap-equiv : ∀ {i j k} {X : Ptd i} {Y : Ptd j} → (X ⊙→ Y) ≃ (⊙Lift {j = k} X ⊙→ ⊙Lift {j = k} Y) ⊙Lift-fmap-equiv = equiv ⊙Lift-fmap (λ f → ⊙lower ⊙∘ f ⊙∘ ⊙lift) (λ {(_ , idp) → idp}) (λ {(_ , idp) → idp})
{ "alphanum_fraction": 0.4950690335, "avg_line_length": 31.6875, "ext": "agda", "hexsha": "16bf427b82e2f7c6f46d47be39af418c525ee27a", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "core/lib/types/Lift.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_path": "core/lib/types/Lift.agda", "max_line_length": 82, "max_stars_count": 294, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "core/lib/types/Lift.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": 753, "size": 1521 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} open import Cubical.Core.Everything open import Cubical.Relation.Binary open import Cubical.Algebra.Monoid module Cubical.Algebra.Monoid.Construct.Quotient {c ℓ} (M : Monoid c) {R : Rel (Monoid.Carrier M) ℓ} (isEq : IsEquivalence R) (closed : Congruent₂ R (Monoid._•_ M)) where open import Cubical.Foundations.Prelude open import Cubical.Algebra.Properties open import Cubical.HITs.SetQuotients open import Cubical.Data.Prod using (_,_) open Monoid M open IsEquivalence isEq import Cubical.Algebra.Semigroup.Construct.Quotient semigroup isEq closed as QSemigroup open QSemigroup public hiding (S/R-isSemigroup; S/R) εᴿ : Carrier/R εᴿ = [ ε ] •ᴿ-identityˡ : LeftIdentity εᴿ _•ᴿ_ •ᴿ-identityˡ = elimProp (λ _ → squash/ _ _) (λ x → cong [_] (identityˡ x)) •ᴿ-identityʳ : RightIdentity εᴿ _•ᴿ_ •ᴿ-identityʳ = elimProp (λ _ → squash/ _ _) (λ x → cong [_] (identityʳ x)) •ᴿ-identity : Identity εᴿ _•ᴿ_ •ᴿ-identity = •ᴿ-identityˡ , •ᴿ-identityʳ M/R-isMonoid : IsMonoid Carrier/R _•ᴿ_ εᴿ M/R-isMonoid = record { isSemigroup = QSemigroup.S/R-isSemigroup ; identity = •ᴿ-identity } M/R : Monoid (ℓ-max c ℓ) M/R = record { isMonoid = M/R-isMonoid }
{ "alphanum_fraction": 0.6878930818, "avg_line_length": 30.2857142857, "ext": "agda", "hexsha": "4c4b9ff58632fe8763c38297609d81c47189504d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_path": "Cubical/Algebra/Monoid/Construct/Quotient.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_path": "Cubical/Algebra/Monoid/Construct/Quotient.agda", "max_line_length": 125, "max_stars_count": null, "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_path": "Cubical/Algebra/Monoid/Construct/Quotient.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 450, "size": 1272 }
------------------------------------------------------------------------ -- The Agda standard library -- -- This module is DEPRECATED. Please use -- Data.Vec.Relation.Unary.All directly. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Vec.All where open import Data.Vec.Relation.Unary.All public {-# WARNING_ON_IMPORT "Data.Vec.All was deprecated in v1.0. Use Data.Vec.Relation.Unary.All instead." #-}
{ "alphanum_fraction": 0.5041841004, "avg_line_length": 26.5555555556, "ext": "agda", "hexsha": "b08fa1064454ce9165484b2c532273da44202651", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Data/Vec/All.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Data/Vec/All.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Data/Vec/All.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": 92, "size": 478 }
{-# OPTIONS --cubical --no-import-sorts #-} module MorePropAlgebra.Definitions where open import Agda.Primitive renaming (_⊔_ to ℓ-max; lsuc to ℓ-suc; lzero to ℓ-zero) open import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc) open import Cubical.Relation.Nullary.Base renaming (¬_ to ¬ᵗ_)-- ¬ᵗ_ open import Cubical.Data.Sum.Base renaming (_⊎_ to infixr 4 _⊎_) open import Cubical.HITs.PropositionalTruncation.Base using (∣_∣) open import Cubical.Foundations.Logic renaming ( inl to inlᵖ ; inr to inrᵖ ; _⇒_ to infixr 0 _⇒_ -- shifting by -6 ; _⇔_ to infixr -2 _⇔_ -- ; ∃[]-syntax to infix -4 ∃[]-syntax -- ; ∃[∶]-syntax to infix -4 ∃[∶]-syntax -- ; ∀[∶]-syntax to infix -4 ∀[∶]-syntax -- ; ∀[]-syntax to infix -4 ∀[]-syntax -- ) open import Utils open import MoreLogic.Definitions renaming ( _ᵗ⇒_ to infixr 0 _ᵗ⇒_ ; ∀ᵖ[∶]-syntax to infix -4 ∀ᵖ[∶]-syntax ; ∀ᵖ〚∶〛-syntax to infix -4 ∀ᵖ〚∶〛-syntax ; ∀ᵖ!〚∶〛-syntax to infix -4 ∀ᵖ!〚∶〛-syntax ; ∀〚∶〛-syntax to infix -4 ∀〚∶〛-syntax ; Σᵖ[]-syntax to infix -4 Σᵖ[]-syntax ; Σᵖ[∶]-syntax to infix -4 Σᵖ[∶]-syntax ) -- hProps of relations module _ {ℓ ℓ' : Level} {A : Type ℓ} (R : hPropRel A A ℓ') where isRefl = ∀[ a ] R a a isIrrefl = ∀[ a ] ¬ (R a a) isIrrefl' = ∀[ a ] ∀[ b ] ( R a b ⊔ R b a ) ⇒ ¬( a ≡ₚ b) isIrrefl'' = ∀[ a ] ∀[ b ] ([ R a b ] ⊎ [ R b a ]) ᵗ⇒ ¬( a ≡ₚ b) isIrreflˢ'' = λ(isset : isSet A) → ∀[ a ] ∀[ b ] ([ R a b ] ⊎ [ R b a ]) ᵗ⇒ ¬([ isset ] a ≡ˢ b) isTrans = ∀[ a ] ∀[ b ] ∀[ x ] R a b ⇒ R b x ⇒ R a x isCotrans = ∀[ a ] ∀[ b ] R a b ⇒ (∀[ x ] R a x ⊔ R x b) isConnex = ∀[ a ] ∀[ b ] R a b ⊔ R b a -- isTrichotomous = λ(<-irrefl ∶ [ isIrrefl' _<_ ]) → λ(<-asym : isAsym _<_) ∀[ a ] ∀[ b ] [ <-irrefl ] -- [ P ] → ¬ᵗ [ Q ] -- a ≡ b ⊎ (a < b ⊎ b < a) -- (a < b ⊎ b < a) ⇒ (¬ a ≡ b) -- also irrefl -- isTight -- two variants of asymmetry -- -- IsAsym R = ∀ a b → [ R a b ⇒ ¬ R b a ] -- IsAsym' R = ∀ a b → [ ¬ (R a b ⊓ R b a) ] -- -- which are equivalent -- -- isAsymᵖ≡' : isAsym R ≡ isAsym' R -- -- but it seems that this one is not equivalent: -- -- ∀ a b → [ (¬ R b a) ⇒ R a b ] isSym = ∀[ a ] ∀[ b ] R a b ⇒ R b a isAsym = ∀[ a ] ∀[ b ] R a b ⇒ ¬ R b a isAsym' = ∀[ a ] ∀[ b ] ¬ (R a b ⊓ R b a) isAsym'' = ∀[ a ] ∀[ b ] ¬ R a b ⇒ R b a -- not equivalent! (weaker) isTrichotomous : (<-irrefl : [ isIrrefl'' ]) → (<-asym : [ isAsym ]) → hProp _ isTrichotomousˢ : (isset : isSet A) → (<-irrefl : [ isIrreflˢ'' isset ]) → (<-asym : [ isAsym ]) → hProp _ isTrichotomous isirrefl isasym = ∀[ a ] ∀[ b ] ([ isirrefl a b ] ([ isasym a b ] R a b ⊎ᵖ R b a ) ⊎ᵖ ( a ≡ₚ b)) isTrichotomousˢ isset isirrefl isasym = ∀[ a ] ∀[ b ] ([ isirrefl a b ] ([ isasym a b ] R a b ⊎ᵖ R b a ) ⊎ᵖ ([ isset ] a ≡ˢ b)) isAntisym = ∀[ a ] ∀[ b ] R a b ⇒ R b a ⇒ a ≡ₚ b isAntisymˢ = λ(isset : isSet A) → ∀[ a ] ∀[ b ] R a b ⇒ R b a ⇒ ([ isset ] a ≡ˢ b) isAntisym' = ∀[ a ] ∀[ b ] R a b ⇒ ¬( a ≡ₚ b) ⇒ R b a isAntisymˢ' = λ(isset : isSet A) → ∀[ a ] ∀[ b ] R a b ⇒ ¬([ isset ] a ≡ˢ b) ⇒ R b a -- tightness is closely related to antisymmetry: -- -- R-antisym : [ R a b ] → [ R b a ] → a ≡ b -- R-tight : [ ¬ R a b ] → [ ¬ R b a ] → a ≡ b -- -- this becomes even more obvious if we regard the intended use: when _≤_ and _#_ are derived from _<_ -- -- a ≤ b = ¬ (b < a) -- a # b = ¬ ([ a < b ] ⊎ [ b < a ]) -- -- and indeed, we get -- -- isTight _<_ ≡ isAntisym (λ a b → ¬ (b < a)) -- isTight' _<_ ≡ isTight''' (λ a b → (a < b) ⊔ (b < a)) -- -- In that case, `≤-antisym` and `#-tight` are almost the same, definitionally: -- -- ≤-antisym : [ ¬ (b < a) ] → [ ¬ (a < b) ] → a ≡ b -- ≤-antisym : [ ¬ (b < a) ] × [ ¬ (a < b) ] → a ≡ b -- by curry/uncurry -- ≤-antisym : ¬ᵗ ( [ b < a ] ⊎ [ a < b ]) → a ≡ b -- by deMorgan -- #-tight : [ ¬ (a < b) ] → [ ¬ (b < a) ] → a ≡ b -- #-tight : [ ¬ (a < b) ] × [ ¬ (b < a) ] → a ≡ b -- by curry/uncurry -- #-tight : ¬ᵗ ( [ a < b ] ⊎ [ b < a ]) → a ≡ b -- by deMorgan -- -- We provide a few variants of tightness -- isTight = ∀[ a ] ∀[ b ] ¬ R a b ⇒ ¬ R b a ⇒ a ≡ₚ b -- on _<_, "canonical" isTightˢ = λ(isset : isSet A) → ∀[ a ] ∀[ b ] ¬ R a b ⇒ ¬ R b a ⇒ [ isset ] a ≡ˢ b -- on _<_ isTight' = ∀[ a ] ∀[ b ] ¬ ( R a b ⊔ R b a ) ⇒ a ≡ₚ b -- on _<_, definitional `isTight-ᵖ'≡'''` isTightˢ' = λ(isset : isSet A) → ∀[ a ] ∀[ b ] ¬ ( R a b ⊔ R b a ) ⇒ [ isset ] a ≡ˢ b -- on _<_ isTight'' = ∀[ a ] ∀[ b ] (¬ᵗ ([ R a b ] ⊎ [ R b a ])) ᵗ⇒ a ≡ₚ b -- on _<_, definitional `isTight-ᵖ''≡'''` isTightˢ'' = λ(isset : isSet A) → ∀[ a ] ∀[ b ] (¬ᵗ ([ R a b ] ⊎ [ R b a ])) ᵗ⇒ [ isset ] a ≡ˢ b -- on _<_, "convenient" isTight''' = ∀[ a ] ∀[ b ] ¬ R a b ⇒ a ≡ₚ b -- on _#_ isTightˢ''' = λ(isset : isSet A) → ∀[ a ] ∀[ b ] ¬ R a b ⇒ [ isset ] a ≡ˢ b -- on _#_, also "convenient" -- -- where the very first one, `IsTight` corresponds to a "canonical" definition, -- the later one, `IsTightˢ''` is the "most convenient" one to use for `a # b = ¬ ([ a < b ] ⊎ [ b < a ])` on sets. -- and the last ones `IsTight'''` and `IsTightˢ'''` are for "_#_" instead of "_<_". -- -- These tightness definitions are all equivalent in the following sense: -- -- isTight-ˢ≡ : (is-set : isSet A) → isTightˢ is-set _<_ ≡ isTight _<_ -- isTight-ˢ'≡' : (is-set : isSet A) → isTightˢ' is-set _<_ ≡ isTight' _<_ -- isTight-ˢ''≡'' : (is-set : isSet A) → isTightˢ'' is-set _<_ ≡ isTight'' _<_ -- isTight-ˢ'''≡''' : (is-set : isSet A) → isTightˢ''' is-set _#_ ≡ isTight''' _#_ -- isTight-≡' : isTight _<_ ≡ isTight' _<_ -- isTight-'≡'' : isTight' _<_ ≡ isTight'' _<_ -- isTight-'≡''' : isTight' _<_ ≡ isTight''' (λ a b → (a < b) ⊔ (b < a)) -- isTight-''≡''' : (<-asym : [ isAsym _<_ ]) → isTight'' _<_ ≡ isTight''' (λ a b → [ <-asym a b ] (a < b) ⊎ᵖ (b < a)) -- -- where `isTight-ᵖ'≡'''` and `isTight-ᵖ''≡'''` hold definitionally. -- common definitions of less equal _≤_ and apartness _#_ with respect to _<_ module _ {ℓ ℓ'} {X : Type ℓ} {_<_ : hPropRel X X ℓ'} where _#'_ : hPropRel X X ℓ' _#'_ x y = (x < y) ⊔ (y < x) -- a variant that omits propositional truncation by using asymmetry of _<_ _#''_ : {<-asym : [ isAsym _<_ ]} → hPropRel X X ℓ' _#''_ {<-asym = <-asym} x y = [ <-asym x y ] (x < y) ⊎ᵖ (y < x) _≤'_ : hPropRel X X ℓ' _≤'_ x y = ¬ (y < x) -- this is how Bridges 1999 defines _≤_ _≤''_ : hPropRel X X (ℓ-max ℓ ℓ') x ≤'' y = ∀[ ε ] (y < ε) ⇒ (x < ε) -- (∀ ε → [ y < ε ] → [ x < ε ]) , isPropΠ2 (λ ε y<ε → isProp[] (x < ε)) -- combined hProps of relations module _ {ℓ ℓ' : Level} {A : Type ℓ} (R : hPropRel A A ℓ') (let _<_ = R; _≤_ = R) -- "strict" is denoted by _<_, and "non-strict" by _≤_ where record IsApartnessRel : Type (ℓ-max ℓ ℓ') where constructor isapartnessrel field is-irrefl : ∀ a → [ ¬ R a a ] is-sym : ∀ a b → [ R a b ] → [ R b a ] is-cotrans : ∀ a b → [ R a b ] → ∀ x → [ R a x ⊔ R x b ] _ : [ isIrrefl R ]; _ = is-irrefl _ : [ isSym R ]; _ = is-sym _ : [ isCotrans R ]; _ = is-cotrans isApartnessRel : hProp (ℓ-max ℓ ℓ') isApartnessRel .fst = IsApartnessRel isApartnessRel .snd (isapartnessrel a₀ b₀ c₀) (isapartnessrel a₁ b₁ c₁) = φ where abstract φ = λ i → isapartnessrel (snd (isIrrefl R) a₀ a₁ i) (snd (isSym R) b₀ b₁ i) (snd (isCotrans R) c₀ c₁ i) record IsStrictPartialOrder : Type (ℓ-max ℓ ℓ') where constructor isstrictpartialorder field is-irrefl : ∀ a → [ ¬ a < a ] is-trans : ∀ a b x → [ a < b ] → [ b < x ] → [ a < x ] is-cotrans : ∀ a b → [ a < b ] → ∀ x → [ a < x ⊔ x < b ] _ : [ isIrrefl _<_ ]; _ = is-irrefl _ : [ isTrans _<_ ]; _ = is-trans _ : [ isCotrans _<_ ]; _ = is-cotrans isStrictPartialOrder : hProp (ℓ-max ℓ ℓ') isStrictPartialOrder .fst = IsStrictPartialOrder isStrictPartialOrder .snd (isstrictpartialorder a₀ b₀ c₀) (isstrictpartialorder a₁ b₁ c₁) = φ where abstract φ = λ i → isstrictpartialorder (snd (isIrrefl _<_) a₀ a₁ i) (snd (isTrans _<_) b₀ b₁ i) (snd (isCotrans _<_) c₀ c₁ i) record IsPreorder : Type (ℓ-max ℓ ℓ') where constructor ispreorder field is-refl : ∀ a → [ R a a ] is-trans : ∀ a b x → [ R a b ] → [ R b x ] → [ R a x ] _ : [ isRefl R ]; _ = is-refl _ : [ isTrans R ]; _ = is-trans isPreorder : hProp (ℓ-max ℓ ℓ') isPreorder .fst = IsPreorder isPreorder .snd (ispreorder a₀ b₀) (ispreorder a₁ b₁) = φ where abstract φ = λ i → ispreorder (snd (isRefl R) a₀ a₁ i) (snd (isTrans R) b₀ b₁ i) record IsPartialOrder : Type (ℓ-max ℓ ℓ') where constructor ispartialorder field is-refl : ∀ a → [ a ≤ a ] is-antisym : ∀ a b → [ a ≤ b ] → [ b ≤ a ] → [ a ≡ₚ b ] is-trans : ∀ a b x → [ a ≤ b ] → [ b ≤ x ] → [ a ≤ x ] _ : [ isRefl _≤_ ]; _ = is-refl _ : [ isAntisym _≤_ ]; _ = is-antisym _ : [ isTrans _≤_ ]; _ = is-trans isPartialOrder : hProp (ℓ-max ℓ ℓ') isPartialOrder .fst = IsPartialOrder isPartialOrder .snd (ispartialorder a₀ b₀ c₀) (ispartialorder a₁ b₁ c₁) = φ where abstract φ = λ i → ispartialorder (snd (isRefl _≤_) a₀ a₁ i) (snd (isAntisym _≤_) b₀ b₁ i) (snd (isTrans _≤_) c₀ c₁ i) record IsLinearOrder : Type (ℓ-max ℓ ℓ') where constructor islinearorder field is-connex : ∀ a b → [ a ≤ b ⊔ b ≤ a ] is-antisym : ∀ a b → [ a ≤ b ] → [ b ≤ a ] → [ a ≡ₚ b ] is-trans : ∀ a b x → [ a ≤ b ] → [ b ≤ x ] → [ a ≤ x ] _ : [ isConnex _≤_ ]; _ = is-connex _ : [ isAntisym _≤_ ]; _ = is-antisym _ : [ isTrans _≤_ ]; _ = is-trans isLinearOrder : hProp (ℓ-max ℓ ℓ') isLinearOrder .fst = IsLinearOrder isLinearOrder .snd (islinearorder a₀ b₀ c₀) (islinearorder a₁ b₁ c₁) = φ where abstract φ = λ i → islinearorder (snd (isConnex _≤_) a₀ a₁ i) (snd (isAntisym _≤_) b₀ b₁ i) (snd (isTrans _≤_) c₀ c₁ i) record IsStrictLinearOrder : Type (ℓ-max ℓ ℓ') where constructor isstrictlinearorder field is-irrefl : ∀ a → [ ¬ a < a ] is-trans : ∀ a b x → [ a < b ] → [ b < x ] → [ a < x ] is-tricho : ∀ a b → ([ a < b ] ⊎ [ b < a ]) ⊎ [ a ≡ₚ b ] private is-asym : ∀ a b → [ a < b ] → [ ¬ b < a ] is-asym a b a<b b<a = is-irrefl _ (is-trans _ _ _ a<b b<a) is-irrefl'' : ∀ a b → [ a < b ] ⊎ [ b < a ] → [ ¬(a ≡ₚ b) ] is-irrefl'' a b (inl a<b) a≡b = is-irrefl _ (substₚ (λ p → p < b) a≡b a<b) is-irrefl'' a b (inr b<a) a≡b = is-irrefl _ (substₚ (λ p → b < p) a≡b b<a) _ : [ isIrrefl _<_ ]; _ = is-irrefl _ : [ isTrans _<_ ]; _ = is-trans _ : [ isTrichotomous _<_ is-irrefl'' is-asym ]; _ = is-tricho isStrictLinearOrder : hProp (ℓ-max ℓ ℓ') isStrictLinearOrder .fst = IsStrictLinearOrder isStrictLinearOrder .snd (isstrictlinearorder a₀ b₀ c₀) (isstrictlinearorder a₁ b₁ c₁) = φ where abstract φ = λ i → let is-irrefl = snd (isIrrefl _<_ ) a₀ a₁ i is-trans = snd (isTrans _<_ ) b₀ b₁ i is-asym : ∀ a b → [ a < b ] → [ ¬ b < a ] is-asym a b a<b b<a = is-irrefl _ (is-trans _ _ _ a<b b<a) is-irrefl'' : ∀ a b → [ a < b ] ⊎ [ b < a ] → [ ¬(a ≡ₚ b) ] is-irrefl'' a b = λ { (inl a<b) a≡b → is-irrefl _ (substₚ (λ p → p < b) a≡b a<b) ; (inr b<a) a≡b → is-irrefl _ (substₚ (λ p → b < p) a≡b b<a) } is-tricho = snd (isTrichotomous _<_ is-irrefl'' is-asym) c₀ c₁ i in isstrictlinearorder is-irrefl is-trans is-tricho -- properties tied to some operation `op` on sets module _ {ℓ : Level} {A : Type ℓ} (op : A → A → A) (is-set : isSet A) (let _·_ = op -- different semantics _+_ = op -- _≡ˢ_ = λ(x y : A) → [ is-set ] x ≡ˢ y infixl 7 _·_ infixl 5 _+_ infixl 4 _≡ˢ_ ) where isAssociativeˢ = ∀[ x ] ∀[ y ] ∀[ z ] x · (y · z) ≡ˢ (x · y) · z isIdentityˢ = λ(ε : A) → ∀[ x ] ( x · ε ≡ˢ x) ⊓ ( ε · x ≡ˢ x) isCommutativeˢ = ∀[ x ] ∀[ y ] x + y ≡ˢ y + x -- other properties module _ {ℓ : Level} {A : Type ℓ} where is-+-#-Extensional : (_+_ : A → A → A) → ∀{ℓ'} → (_#_ : hPropRel A A ℓ') → hProp _ is-+-<-Extensional : (_+_ : A → A → A) → ∀{ℓ'} → (_<_ : hPropRel A A ℓ') → hProp _ is-+-#-Extensional _+_ _#_ = ∀[ w ] ∀[ x ] ∀[ y ] ∀[ z ] (w + x) # (y + z) ⇒ (w # y) ⊔ (x # z) is-+-<-Extensional _+_ _<_ = ∀[ w ] ∀[ x ] ∀[ y ] ∀[ z ] (w + x) < (y + z) ⇒ (w < y) ⊔ (x < z) isMin : ∀{ℓ'} → (_≤_ : hPropRel A A ℓ') (min : A → A → A) → hProp _ isMax : ∀{ℓ'} → (_≤_ : hPropRel A A ℓ') (max : A → A → A) → hProp _ isMin _≤_ min = ∀[ x ] ∀[ y ] ∀[ z ] z ≤ (min x y) ⇔ z ≤ x ⊓ z ≤ y isMax _≤_ max = ∀[ x ] ∀[ y ] ∀[ z ] (max x y) ≤ z ⇔ x ≤ z ⊓ y ≤ z operation_preserves_when_ : (op : A → A → A) → ∀{ℓ'} → (R : hPropRel A A ℓ') → ∀{ℓ''} → (A → hProp ℓ'') → hProp _ operation_reflects_when_ : (op : A → A → A) → ∀{ℓ'} → (R : hPropRel A A ℓ') → ∀{ℓ''} → (A → hProp ℓ'') → hProp _ operation_reflects_〚when〛 : (op : A → A → A) → ∀{ℓ'} → (R : hPropRel A A ℓ') → ∀{ℓ''} → (A → hProp ℓ'') → hProp _ operation_creates_when_ : (op : A → A → A) → ∀{ℓ'} → (R : hPropRel A A ℓ') → ∀{ℓ''} → (A → hProp ℓ'') → hProp _ operation _·_ preserves _<_ when P = ∀[ x ] ∀[ y ] ∀[ z ] P z ⇒ x < y ⇒ (x · z) < (y · z) operation _·_ reflects _<_ when P = ∀[ x ] ∀[ y ] ∀[ z ] P z ⇒ (x · z) < (y · z) ⇒ x < y operation _·_ reflects _<_ 〚when〛 P = ∀[ x ] ∀[ y ] ∀[ z ] ∀〚 _ ∶ [ P z ] 〛 (x · z) < (y · z) ⇒ x < y operation _·_ creates _<_ when P = ∀[ x ] ∀[ y ] ∀[ z ] P z ⇒ (x < y ⇔ (x · z) < (y · z)) isAbsNonnegative : ∀{ℓ} {F : Type ℓ} {Rℓ Rℓ'} {R : Type Rℓ} (0ᴿ : R) (_≤ᴿ_ : hPropRel R R Rℓ') (abs : F → R) → hProp _ isAbsCreatesZero : ∀{ℓ} {F : Type ℓ} (is-set : isSet F) (0f : F) {Rℓ Rℓ'} {R : Type Rℓ} (is-setᴿ : isSet R) (0ᴿ : R) (_≤ᴿ_ : hPropRel R R Rℓ') (abs : F → R) → hProp _ isAbsPreservesMultiplication : ∀{ℓ} {F : Type ℓ} ( _·_ : F → F → F) {Rℓ } {R : Type Rℓ} (is-setᴿ : isSet R) ( _·ᴿ_ : R → R → R) (abs : F → R) → hProp _ isAbsTriangleInequality : ∀{ℓ} {F : Type ℓ} (_+_ : F → F → F) {Rℓ Rℓ'} {R : Type Rℓ} (_+ᴿ_ : R → R → R) (_≤ᴿ_ : hPropRel R R Rℓ') (abs : F → R) → hProp _ isAbsNonnegative 0ᴿ _≤ᴿ_ abs = ∀[ x ] 0ᴿ ≤ᴿ (abs x) isAbsCreatesZero is-set 0f is-setᴿ 0ᴿ _≤ᴿ_ abs = ∀[ x ] ([ is-set ] x ≡ˢ 0f ⇔ [ is-setᴿ ] abs x ≡ˢ 0ᴿ) isAbsPreservesMultiplication _·_ is-setᴿ _·ᴿ_ abs = ∀[ x ] ∀[ y ] [ is-setᴿ ] (abs (x · y)) ≡ˢ (abs x ·ᴿ abs y) isAbsTriangleInequality _+_ _+ᴿ_ _≤ᴿ_ abs = ∀[ x ] ∀[ y ] abs (x + y) ≤ᴿ (abs x +ᴿ abs y) record IsAbsˢ { ℓ : Level} {F : Type ℓ } (is-set : isSet F) (0f : F) (_+_ _·_ : F → F → F) {Rℓ Rℓ' : Level} {R : Type Rℓ} (is-setᴿ : isSet R) (0ᴿ : R) (_+ᴿ_ _·ᴿ_ : R → R → R) (_≤ᴿ_ : hPropRel R R Rℓ') (abs : F → R) : Type (ℓ-suc (ℓ-max ℓ (ℓ-max Rℓ Rℓ'))) where constructor isabs field is-0≤abs : ∀ x → [ 0ᴿ ≤ᴿ (abs x) ] abs-creates-0 : ∀ x → [ [ is-set ] x ≡ˢ 0f ⇔ [ is-setᴿ ] abs x ≡ˢ 0ᴿ ] abs-preserves-· : ∀ x y → (abs (x · y)) ≡ (abs x ·ᴿ abs y) triangle-ineq : ∀ x y → [ abs (x + y) ≤ᴿ (abs x +ᴿ abs y) ] _ : [ isAbsNonnegative 0ᴿ _≤ᴿ_ abs ]; _ = is-0≤abs _ : [ isAbsCreatesZero is-set 0f is-setᴿ 0ᴿ _≤ᴿ_ abs ]; _ = abs-creates-0 _ : [ isAbsPreservesMultiplication _·_ is-setᴿ _·ᴿ_ abs ]; _ = abs-preserves-· _ : [ isAbsTriangleInequality _+_ _+ᴿ_ _≤ᴿ_ abs ]; _ = triangle-ineq abs-preserves-0 : ∀ x → x ≡ 0f → abs x ≡ 0ᴿ abs-preserves-0 x = abs-creates-0 x .fst abs-reflects-0 : ∀ x → abs x ≡ 0ᴿ → x ≡ 0f abs-reflects-0 x = abs-creates-0 x .snd isAbs : { ℓ : Level} {F : Type ℓ } (is-set : isSet F) (0f : F) (_+_ _·_ : F → F → F) {Rℓ Rℓ' : Level} {R : Type Rℓ} (is-setᴿ : isSet R) (0ᴿ : R) (_+ᴿ_ _·ᴿ_ : R → R → R) (_≤ᴿ_ : hPropRel R R Rℓ') (abs : F → R) → hProp (ℓ-suc (ℓ-max ℓ (ℓ-max Rℓ Rℓ'))) isAbs is-set 0f _+_ _·_ is-setᴿ 0ᴿ _+ᴿ_ _·ᴿ_ _≤ᴿ_ abs .fst = IsAbsˢ is-set 0f _+_ _·_ is-setᴿ 0ᴿ _+ᴿ_ _·ᴿ_ _≤ᴿ_ abs isAbs is-set 0f _+_ _·_ is-setᴿ 0ᴿ _+ᴿ_ _·ᴿ_ _≤ᴿ_ abs .snd (isabs a₀ b₀ c₀ d₀) (isabs a₁ b₁ c₁ d₁) = φ where abstract φ = λ i → isabs (snd (isAbsNonnegative 0ᴿ _≤ᴿ_ abs) a₀ a₁ i) (snd (isAbsCreatesZero is-set 0f is-setᴿ 0ᴿ _≤ᴿ_ abs) b₀ b₁ i) (snd (isAbsPreservesMultiplication _·_ is-setᴿ _·ᴿ_ abs) c₀ c₁ i) (snd (isAbsTriangleInequality _+_ _+ᴿ_ _≤ᴿ_ abs) d₀ d₁ i) -- other properties on sets module _ {ℓ : Level} {A : Type ℓ} (is-set : isSet A) (let _≡ˢ_ = λ(x y : A) → [ is-set ] x ≡ˢ y; infixl 4 _≡ˢ_) where -- NOTE: the left inverse is "on the right" of `_⊓_` (you get it with `snd`) -- and the right inverse is "on the left" of `_⊓_` (you get it with `fst`) -- .. this is how it's done in the cubical standard library isInverseˢ : (0g : A) (_+_ : A → A → A) (-_ : A → A) → hProp _ isDistributiveˢ : (_+_ _·_ : A → A → A) → hProp _ isNonzeroInverseˢ' : (0f 1f : A) ( _·_ : A → A → A) (_⁻¹ : (x : A) → {{ ! [ ¬'(x ≡ 0f) ] }} → A) → hProp _ isNonzeroInverseˢ : (0f 1f : A) ( _·_ : A → A → A) → ∀{ℓ'} → (_#_ : hPropRel A A ℓ') → (_⁻¹ : (x : A) → {{ [ x # 0f ] }} → A) → hProp _ isNonzeroInverseˢ'' : (0f 1f : A) ( _·_ : A → A → A) → ∀{ℓ'} → (_#_ : hPropRel A A ℓ') → hProp _ -- isNonzeroInverseˢ''' : (0f 1f : A) ( _·_ : A → A → A) → ∀{ℓ'} → (_#_ : hPropRel A A ℓ') → hProp _ isInverseNonzeroˢ : (0f 1f : A) ( _·_ : A → A → A) → ∀{ℓ'} → (_#_ : hPropRel A A ℓ') → hProp _ isInverseˢ 0g _+_ -_ = ∀[ x ] ( x + (- x) ≡ˢ 0g) ⊓ ((- x) + x ≡ˢ 0g) isDistributiveˢ _+_ _·_ = ∀[ x ] ∀[ y ] ∀[ z ] ( x · (y + z) ≡ˢ (x · y) + (x · z)) ⊓ ((x + y) · z ≡ˢ (x · z) + (y · z)) -- classical notion of inverse operating on `¬(x ≡ 0)`, used in `IsClassicalField` -- `∀ᵖ!〚_〛_` creates in instance argument of type `!_` -- because `¬'(x ≡ 0f)` is a function type with an explicit argument and won't be considered in instance search isNonzeroInverseˢ' 0f 1f _·_ _⁻¹ = ∀[ x ] ∀ᵖ!〚 p ∶ ¬'(x ≡ 0f) 〛 (x · (x ⁻¹) {{ p }} ≡ˢ 1f) ⊓ ((x ⁻¹) {{ p }} · x ≡ˢ 1f) -- constructive notion of inverse operating on `x # 0` -- `∀ᵖ〚_〛_` creates in instance argument isNonzeroInverseˢ 0f 1f _·_ _#_ _⁻¹ = ∀[ x ] ∀ᵖ〚 p ∶ x # 0f 〛 (x · (x ⁻¹) {{ p }} ≡ˢ 1f) ⊓ ((x ⁻¹) {{ p }} · x ≡ˢ 1f) -- constructive notion of inverse -- this is the formulation in Booij2020, used in `IsAlmostOrderedField` -- we need to proof uniqueness of inverses to obtain `_⁻¹` for `isNonzeroInverseˢ` isNonzeroInverseˢ'' 0f 1f _·_ _#_ = ∀[ x ] (∃[ y ] x · y ≡ˢ 1f) ⇔ x # 0f -- isNonzeroInverseˢ''' 0f 1f _·_ _#_ = ∀[ x ] (Σᵖ[ y ] x · y ≡ˢ 1f) ⇔ x # 0f isInverseNonzeroˢ 0f 1f _·_ _#_ = ∀[ x ] ∀[ y ] x · y ≡ˢ 1f ⇒ x # 0f ⊓ y # 0f
{ "alphanum_fraction": 0.433500483, "avg_line_length": 55.5933503836, "ext": "agda", "hexsha": "ac8e8df8c037150a9b478bc994b25ed20ef9e943", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mchristianl/synthetic-reals", "max_forks_repo_path": "agda/MorePropAlgebra/Definitions.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mchristianl/synthetic-reals", "max_issues_repo_path": "agda/MorePropAlgebra/Definitions.agda", "max_line_length": 227, "max_stars_count": 3, "max_stars_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mchristianl/synthetic-reals", "max_stars_repo_path": "agda/MorePropAlgebra/Definitions.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-19T12:15:21.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-31T18:15:26.000Z", "num_tokens": 9116, "size": 21737 }