Search is not available for this dataset
text
string
meta
dict
module _ where open import Common.Prelude renaming (_+_ to _+N_) open import Common.Integer diff : Nat β†’ Nat β†’ Integer diff a zero = pos a diff zero (suc b) = negsuc b diff (suc a) (suc b) = diff a b _+_ : Integer β†’ Integer β†’ Integer pos a + pos b = pos (a +N b) pos a + negsuc b = diff a (suc b) negsuc a + pos b = diff b (suc a) negsuc a + negsuc b = negsuc (suc a +N b) printInt : Integer β†’ IO Unit printInt n = putStrLn (intToString n) main : IO Unit main = printInt (pos 42 + pos 58) ,, printInt (pos 42 + negsuc 141) ,, printInt (pos 42 + negsuc 31) ,, printInt (negsuc 42 + pos 143) ,, printInt (negsuc 42 + pos 33) ,, printInt (negsuc 42 + negsuc 56)
{ "alphanum_fraction": 0.595890411, "avg_line_length": 26.0714285714, "ext": "agda", "hexsha": "0ba399540897dcbde387e3ca1b1d243171286248", "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/BuiltinInt.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/BuiltinInt.agda", "max_line_length": 49, "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/BuiltinInt.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": 270, "size": 730 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT renaming (pt to ptβŠ™) open import cw.CW module cw.FinCW where record AttachedFinSkeleton n (Skel : Typeβ‚€) (Real : Skel β†’ Skeleton n) : Typeβ‚€ where constructor attached-fin-skeleton field skel : Skel numCells : β„• attaching : Attaching ⟦ Real skel ⟧ (Fin numCells) (Sphere n) FinSkeleton : β„• β†’ Typeβ‚€ FinSkeleton-realize : {n : β„•} β†’ FinSkeleton n β†’ Skeleton n FinSkeleton O = β„• FinSkeleton (S n) = AttachedFinSkeleton n (FinSkeleton n) FinSkeleton-realize FinSkeleton-realize {n = O} n = Fin n , Fin-is-set FinSkeleton-realize {n = S n} (attached-fin-skeleton _ s Ξ±) = attached-skeleton _ (Fin s , Fin-is-set) Ξ± ⦉_⦊ = FinSkeleton-realize -- Pointedness -- this function is needed for pointedness fcw-head : βˆ€ {n : β„•} β†’ FinSkeleton n β†’ Typeβ‚€ fcw-head = cw-head ∘ FinSkeleton-realize fcw-head-has-dec-eq : βˆ€ {n : β„•} (fin-skel : FinSkeleton n) β†’ has-dec-eq (fcw-head fin-skel) fcw-head-has-dec-eq {n = 0} _ = Fin-has-dec-eq fcw-head-has-dec-eq {n = S n} (attached-fin-skeleton skel _ _) = fcw-head-has-dec-eq skel -- this function is needed for pointedness fcw-incl^ : βˆ€ {n : β„•} (skel : FinSkeleton n) β†’ fcw-head skel β†’ ⟦ ⦉ skel ⦊ ⟧ fcw-incl^ fin-skel = incl^ (FinSkeleton-realize fin-skel) -- disjointly pointed skeletons record βŠ™FinSkeleton (n : β„•) : Type₁ where constructor βŠ™fin-skeleton field skel : FinSkeleton n pt : fcw-head skel βŠ™FinSkeleton-realize : {n : β„•} β†’ βŠ™FinSkeleton n β†’ βŠ™Skeleton {i = lzero} n βŠ™FinSkeleton-realize (βŠ™fin-skeleton skel pt) = βŠ™skeleton (FinSkeleton-realize skel) pt (fcw-head-has-dec-eq skel pt) βŠ™β¦‰_⦊ : {n : β„•} β†’ βŠ™FinSkeleton n β†’ βŠ™Skeleton {i = lzero} n βŠ™β¦‰_⦊ = βŠ™FinSkeleton-realize -- Take a prefix of a skeleton fcw-init : βˆ€ {n} β†’ FinSkeleton (S n) β†’ FinSkeleton n fcw-init (attached-fin-skeleton skel _ _) = skel βŠ™fcw-init : βˆ€ {n} β†’ βŠ™FinSkeleton (S n) β†’ βŠ™FinSkeleton n βŠ™fcw-init (βŠ™fin-skeleton skel pt) = βŠ™fin-skeleton (fcw-init skel) pt -- Extra conditions on CW complexes -- 1. decidable equalities FinSkeleton-has-cells-with-dec-eq : βˆ€ {n} (fin-skel : FinSkeleton n) β†’ has-cells-with-dec-eq (FinSkeleton-realize fin-skel) FinSkeleton-has-cells-with-dec-eq {n = O} fin-skel = Fin-has-dec-eq FinSkeleton-has-cells-with-dec-eq {n = S n} fin-skel = FinSkeleton-has-cells-with-dec-eq (fcw-init fin-skel) , Fin-has-dec-eq βŠ™FinSkeleton-has-cells-with-dec-eq : βˆ€ {n} (βŠ™fin-skel : βŠ™FinSkeleton n) β†’ βŠ™has-cells-with-dec-eq (βŠ™FinSkeleton-realize βŠ™fin-skel) βŠ™FinSkeleton-has-cells-with-dec-eq βŠ™fin-skel = FinSkeleton-has-cells-with-dec-eq _ -- 2. choice FinSkeleton-has-cells-with-choice : βˆ€ t {n} (fin-skel : FinSkeleton n) j β†’ has-cells-with-choice t (FinSkeleton-realize fin-skel) j FinSkeleton-has-cells-with-choice t {n = O} fin-skel j = Fin-has-choice t j FinSkeleton-has-cells-with-choice t {n = S n} fin-skel j = FinSkeleton-has-cells-with-choice t (fcw-init fin-skel) j , Fin-has-choice t j βŠ™FinSkeleton-has-cells-with-choice : βˆ€ t {n} (fin-skel : βŠ™FinSkeleton n) j β†’ βŠ™has-cells-with-choice t (βŠ™FinSkeleton-realize fin-skel) j βŠ™FinSkeleton-has-cells-with-choice t fin-skel j = FinSkeleton-has-cells-with-choice t _ j
{ "alphanum_fraction": 0.6897637795, "avg_line_length": 34.8901098901, "ext": "agda", "hexsha": "7152828740176501526475aee5bdabeed489c298", "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": "theorems/cw/FinCW.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": "theorems/cw/FinCW.agda", "max_line_length": 89, "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": "theorems/cw/FinCW.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": 1135, "size": 3175 }
-- binary search trees (not balanced) open import bool open import bool-thms2 open import eq open import maybe open import product open import product-thms open import bool-relations using (transitive ; total) module bst (A : Set) (_≀A_ : A β†’ A β†’ 𝔹) (≀A-trans : transitive _≀A_) (≀A-total : total _≀A_) where open import bool-relations _≀A_ hiding (transitive ; total) open import minmax _≀A_ ≀A-trans ≀A-total data bst : A β†’ A β†’ Set where bst-leaf : βˆ€ {l u : A} β†’ l ≀A u ≑ tt β†’ bst l u bst-node : βˆ€ {l l' u' u : A}(d : A) β†’ bst l' d β†’ bst d u' β†’ l ≀A l' ≑ tt β†’ u' ≀A u ≑ tt β†’ bst l u -- find a node which is isomorphic (_=A_) to d and return it; or else return nothing bst-search : βˆ€{l u : A}(d : A) β†’ bst l u β†’ maybe (Ξ£ A (Ξ» d' β†’ d iso𝔹 d' ≑ tt)) bst-search d (bst-leaf _) = nothing bst-search d (bst-node d' L R _ _) with keep (d ≀A d') bst-search d (bst-node d' L R _ _) | tt , p1 with keep (d' ≀A d) bst-search d (bst-node d' L R _ _) | tt , p1 | tt , p2 = just (d' , iso𝔹-intro p1 p2) bst-search d (bst-node d' L R _ _) | tt , p1 | ff , p2 = bst-search d L bst-search d (bst-node d' L R _ _) | ff , p1 = bst-search d R bst-dec-lb : βˆ€ {l l' u' : A} β†’ bst l' u' β†’ l ≀A l' ≑ tt β†’ bst l u' bst-dec-lb (bst-leaf p) q = bst-leaf (≀A-trans q p) bst-dec-lb (bst-node d L R p1 p2) q = bst-node d L R (≀A-trans q p1) p2 bst-inc-ub : βˆ€ {l' u' u : A} β†’ bst l' u' β†’ u' ≀A u ≑ tt β†’ bst l' u bst-inc-ub (bst-leaf p) q = bst-leaf (≀A-trans p q) bst-inc-ub (bst-node d L R p1 p2) q = bst-node d L R p1 (≀A-trans p2 q) bst-insert : βˆ€{l u : A}(d : A) β†’ bst l u β†’ bst (min d l) (max d u) bst-insert d (bst-leaf p) = bst-node d (bst-leaf ≀A-refl) (bst-leaf ≀A-refl) min-≀1 max-≀1 bst-insert d (bst-node d' L R p1 p2) with keep (d ≀A d') bst-insert d (bst-node d' L R p1 p2) | tt , p with bst-insert d L bst-insert d (bst-node d' L R p1 p2) | tt , p | L' rewrite p = bst-node d' L' (bst-inc-ub R (≀A-trans p2 max-≀2)) (min2-mono p1) ≀A-refl bst-insert d (bst-node d' L R p1 p2) | ff , p with bst-insert d R bst-insert d (bst-node d' L R p1 p2) | ff , p | R' rewrite p = bst-node d' (bst-dec-lb L p1) R' min-≀2 (max2-mono p2)
{ "alphanum_fraction": 0.5747387551, "avg_line_length": 41.5283018868, "ext": "agda", "hexsha": "b3f8197f02d5ed9e2d4fd35b142177b0967b074e", "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": "2ad96390a9be5c238e73709a21533c7354cedd0c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "logicshan/IAL", "max_forks_repo_path": "bst.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2ad96390a9be5c238e73709a21533c7354cedd0c", "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": "logicshan/IAL", "max_issues_repo_path": "bst.agda", "max_line_length": 90, "max_stars_count": null, "max_stars_repo_head_hexsha": "2ad96390a9be5c238e73709a21533c7354cedd0c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "logicshan/IAL", "max_stars_repo_path": "bst.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 891, "size": 2201 }
{- https://github.com/mietek/hilbert-gentzen An Agda formalisation of IPC, IS4, ICML, and ILP. Work in progress. Made by MiΓ«tek Bak. Published under the MIT X11 license. -} module Everything where import Common import Common.Context import Common.ContextPair import Common.Predicate import Common.PredicateBasedContext import Common.Semantics import Common.UntypedContext -- Basic intuitionistic propositional calculus, without ∨ or βŠ₯. -- Common syntax. import BasicIPC.Syntax.Common -- Hilbert-style formalisation of closed syntax. import BasicIPC.Syntax.ClosedHilbertSequential -- Sequences of terms. import BasicIPC.Syntax.ClosedHilbert -- Nested terms. -- Hilbert-style formalisation of syntax. import BasicIPC.Syntax.HilbertSequential -- Sequences of terms. import BasicIPC.Syntax.Hilbert -- Nested terms. -- Gentzen-style formalisation of syntax. import BasicIPC.Syntax.Gentzen -- Simple terms. import BasicIPC.Syntax.GentzenNormalForm -- Normal forms and neutrals. import BasicIPC.Syntax.GentzenSpinalNormalForm -- Normal forms, neutrals, and spines. -- Translation between different formalisations of syntax. import BasicIPC.Syntax.Translation -- Basic Tarski-style semantics, for soundness only. import BasicIPC.Semantics.BasicTarski -- Tarski-style semantics with glueing for Ξ± and β–», after Coquand-Dybjer. import BasicIPC.Semantics.TarskiGluedClosedImplicit -- Implicit closed syntax. import BasicIPC.Semantics.TarskiGluedClosedHilbert -- Hilbert-style closed syntax. -- Tarski-style semantics with contexts as concrete worlds, and glueing for Ξ± and β–». import BasicIPC.Semantics.TarskiConcreteGluedImplicit -- Implicit syntax. import BasicIPC.Semantics.TarskiConcreteGluedHilbert -- Hilbert-style syntax. import BasicIPC.Semantics.TarskiConcreteGluedGentzen -- Gentzen-style syntax. -- Kripke-style semantics with contexts as concrete worlds, and glueing for Ξ± and β–». import BasicIPC.Semantics.KripkeConcreteGluedImplicit -- Implicit syntax. import BasicIPC.Semantics.KripkeConcreteGluedHilbert -- Hilbert-style syntax. import BasicIPC.Semantics.KripkeConcreteGluedGentzen -- Gentzen-style syntax. -- Kripke-style semantics with contexts as concrete worlds. import BasicIPC.Semantics.KripkeConcrete -- Kripke-style semantics with abstract worlds. import BasicIPC.Semantics.KripkeMcKinseyTarski -- McKinsey-Tarski embedding. import BasicIPC.Semantics.KripkeGodel -- GΓΆdel embedding. -- Available metatheory for basic IPC. -- -- β”Œβ”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β” -- β”‚ CH β”‚ H β”‚ G β”‚ Gⁿᢠ β”‚ G˒ⁿᢠ│ -- β”Œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€ -- β”‚ BT β”‚ eβ‚€ β”‚ e β”‚ e β”‚ β”‚ β”‚ -- β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€ -- β”‚ TGCIβ”‚ eβ‚€qβ‚€β”‚ eqβ‚€ β”‚ eqβ‚€ β”‚ β”‚ β”‚ -- β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€ -- β”‚ TGCHβ”‚ eβ‚€qβ‚€β”‚ eqβ‚€ β”‚ β”‚ β”‚ β”‚ -- β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€ -- β”‚ TCGIβ”‚ β”‚ eq β”‚ eq β”‚ β”‚ β”‚ -- β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€ -- β”‚ TCGHβ”‚ β”‚ eq β”‚ eq β”‚ β”‚ β”‚ -- β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€ -- β”‚ TCGGβ”‚ β”‚ eq β”‚ eq β”‚ β”‚ β”‚ -- β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€ -- β”‚ KCGIβ”‚ β”‚ eq β”‚ eq β”‚ β”‚ β”‚ -- β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€ -- β”‚ KCGHβ”‚ β”‚ eq β”‚ eq β”‚ β”‚ β”‚ -- β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€ -- β”‚ KCGGβ”‚ β”‚ eq β”‚ eq β”‚ β”‚ β”‚ -- β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€ -- β”‚ KC β”‚ β”‚ eq β”‚ eq β”‚ eq β”‚ β”‚ -- β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€ -- β”‚ KMT β”‚ β”‚ eq β”‚ eq β”‚ eq β”‚ β”‚ -- β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€ -- β”‚ KG β”‚ β”‚ eq β”‚ eq β”‚ eq β”‚ β”‚ -- β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€ -- β”‚ HS β”‚ β”‚ β”‚ β”‚ β”‚ n β”‚ -- β””β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”˜ -- -- eβ‚€ : Soundness only, for closed terms only. -- eβ‚€qβ‚€ : Soundness and completeness, for closed terms only. -- e : Soundness only. -- eqβ‚€ : Soundness, for all terms; completeness, for closed terms only. -- eq : Soundness and completeness, or normalisation by evaluation. -- n : Normalisation by other means. import BasicIPC.Metatheory.ClosedHilbert-BasicTarski import BasicIPC.Metatheory.ClosedHilbert-TarskiGluedClosedImplicit import BasicIPC.Metatheory.ClosedHilbert-TarskiGluedClosedHilbert import BasicIPC.Metatheory.Hilbert-BasicTarski import BasicIPC.Metatheory.Hilbert-TarskiGluedClosedImplicit import BasicIPC.Metatheory.Hilbert-TarskiGluedClosedHilbert import BasicIPC.Metatheory.Hilbert-TarskiConcreteGluedImplicit import BasicIPC.Metatheory.Hilbert-TarskiConcreteGluedHilbert import BasicIPC.Metatheory.Hilbert-TarskiConcreteGluedGentzen import BasicIPC.Metatheory.Hilbert-KripkeConcreteGluedImplicit import BasicIPC.Metatheory.Hilbert-KripkeConcreteGluedHilbert import BasicIPC.Metatheory.Hilbert-KripkeConcreteGluedGentzen import BasicIPC.Metatheory.Hilbert-KripkeConcrete import BasicIPC.Metatheory.Hilbert-KripkeMcKinseyTarski import BasicIPC.Metatheory.Hilbert-KripkeGodel import BasicIPC.Metatheory.Gentzen-BasicTarski import BasicIPC.Metatheory.Gentzen-TarskiGluedClosedImplicit import BasicIPC.Metatheory.Gentzen-TarskiConcreteGluedImplicit import BasicIPC.Metatheory.Gentzen-TarskiConcreteGluedHilbert import BasicIPC.Metatheory.Gentzen-TarskiConcreteGluedGentzen import BasicIPC.Metatheory.Gentzen-KripkeConcreteGluedImplicit import BasicIPC.Metatheory.Gentzen-KripkeConcreteGluedHilbert import BasicIPC.Metatheory.Gentzen-KripkeConcreteGluedGentzen import BasicIPC.Metatheory.Gentzen-KripkeConcrete import BasicIPC.Metatheory.Gentzen-KripkeMcKinseyTarski import BasicIPC.Metatheory.Gentzen-KripkeGodel import BasicIPC.Metatheory.GentzenNormalForm-KripkeConcrete import BasicIPC.Metatheory.GentzenNormalForm-KripkeMcKinseyTarski import BasicIPC.Metatheory.GentzenNormalForm-KripkeGodel import BasicIPC.Metatheory.GentzenSpinalNormalForm-HereditarySubstitution -- TODO -- Common syntax. import BasicT.Syntax.Common -- Gentzen-style formalisation of syntax. import BasicT.Syntax.Gentzen import BasicT.Syntax.GentzenNormalForm -- Basic Tarski-style semantics, for soundness only. import BasicT.Semantics.BasicTarski -- Available metatheory. import BasicT.Metatheory.Gentzen-BasicTarski import BasicT.Metatheory.GentzenNormalForm-Unknown -- Intuitionistic propositional calculus. -- Common syntax. import IPC.Syntax.Common -- Hilbert-style formalisation of closed syntax. import IPC.Syntax.ClosedHilbertSequential -- Sequences of terms. import IPC.Syntax.ClosedHilbert -- Nested terms. -- Hilbert-style formalisation of syntax. import IPC.Syntax.HilbertSequential -- Sequences of terms. import IPC.Syntax.Hilbert -- Nested terms. -- Gentzen-style formalisation of syntax. import IPC.Syntax.Gentzen -- Simple terms. import IPC.Syntax.GentzenNormalForm -- Normal forms and neutrals. import IPC.Syntax.GentzenSpinalNormalForm -- Normal forms, neutrals, and spines. -- Translation between different formalisations of syntax. import IPC.Syntax.Translation -- Basic Tarski-style semantics, for soundness only. import IPC.Semantics.BasicTarski -- Kripke-style semantics with exploding abstract worlds. import IPC.Semantics.KripkeExploding -- Available metatheory for IPC. -- -- β”Œβ”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β” -- β”‚ CH β”‚ H β”‚ G β”‚ Gⁿᢠ β”‚ G˒ⁿᢠ│ -- β”Œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€ -- β”‚ BT β”‚ eβ‚€ β”‚ e β”‚ e β”‚ β”‚ β”‚ -- β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€ -- β”‚ KE β”‚ β”‚ β”‚ eq β”‚ eq β”‚ β”‚ -- β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€ -- β”‚ HS β”‚ β”‚ β”‚ β”‚ β”‚ n β”‚ -- β””β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”˜ -- -- eβ‚€ : Soundness only, for closed terms only. -- eβ‚€qβ‚€ : Soundness and completeness, for closed terms only. -- e : Soundness only. -- eqβ‚€ : Soundness, for all terms; completeness, for closed terms only. -- eq : Soundness and completeness, or normalisation by evaluation. -- n : Normalisation by other means. import IPC.Metatheory.ClosedHilbert-BasicTarski import IPC.Metatheory.Hilbert-BasicTarski import IPC.Metatheory.Gentzen-BasicTarski import IPC.Metatheory.Gentzen-KripkeExploding import IPC.Metatheory.GentzenNormalForm-KripkeExploding import IPC.Metatheory.GentzenSpinalNormalForm-HereditarySubstitution -- Basic intuitionistic modal logic S4, without ∨, βŠ₯, or β—‡. -- Common syntax. import BasicIS4.Syntax.Common -- Hilbert-style formalisation of closed syntax. import BasicIS4.Syntax.ClosedHilbertSequential -- Sequences of terms. import BasicIS4.Syntax.ClosedHilbert -- Nested terms. -- Hilbert-style formalisation of syntax. import BasicIS4.Syntax.HilbertSequential -- Sequences of terms. import BasicIS4.Syntax.Hilbert -- Nested terms. -- Gentzen-style formalisation of syntax, after Bierman-de Paiva. import BasicIS4.Syntax.Gentzen -- Hilbert-style formalisation of syntax with context pairs. import BasicIS4.Syntax.DyadicHilbertSequential -- Sequences of terms. import BasicIS4.Syntax.DyadicHilbert -- Nested terms. -- Gentzen-style formalisation of syntax with context pairs, after Pfenning-Davies. import BasicIS4.Syntax.DyadicGentzen -- Simple terms. import BasicIS4.Syntax.DyadicGentzenNormalForm -- Normal forms and neutrals. import BasicIS4.Syntax.DyadicGentzenSpinalNormalForm -- Normal forms, neutrals, and spines. -- Gentzen-style formalisation of labelled syntax, after Basin-Matthews-ViganΓ². import BasicIS4.Syntax.LabelledGentzen -- Translation between different formalisations of syntax. import BasicIS4.Syntax.Translation -- Basic Kripke-style semantics with abstract worlds, for soundness only. import BasicIS4.Semantics.BasicKripkeOno -- Ono-style conditions. import BasicIS4.Semantics.BasicKripkeBozicDosen -- BoΕΎiΔ‡-DoΕ‘en-style conditions. import BasicIS4.Semantics.BasicKripkeEwald -- Ewald-style conditions. import BasicIS4.Semantics.BasicKripkeAlechina -- Alechina-style conditions. -- Tarski-style semantics with glueing for Ξ±, β–», and β–‘, after Gabbay-Nanevski. import BasicIS4.Semantics.TarskiClosedOvergluedImplicit -- Implicit closed syntax. import BasicIS4.Semantics.TarskiClosedOvergluedHilbert -- Hilbert-style closed syntax. -- Tarski-style semantics with contexts as concrete worlds, and glueing for Ξ±, β–», and β–‘. import BasicIS4.Semantics.TarskiOvergluedImplicit -- Implicit syntax. import BasicIS4.Semantics.TarskiOvergluedHilbert -- Hilbert-style syntax. import BasicIS4.Semantics.TarskiOvergluedGentzen -- Gentzen-style syntax. -- Tarski-style semantics with contexts as concrete worlds, and glueing for β–‘ only. import BasicIS4.Semantics.TarskiGluedImplicit -- Implicit syntax. import BasicIS4.Semantics.TarskiGluedHilbert -- Hilbert-style syntax. import BasicIS4.Semantics.TarskiGluedGentzen -- Gentzen-style syntax. -- Tarski-style semantics with context pairs as concrete worlds, and glueing for Ξ±, β–», and β–‘. import BasicIS4.Semantics.TarskiOvergluedDyadicImplicit -- Implicit syntax. import BasicIS4.Semantics.TarskiOvergluedDyadicHilbert -- Hilbert-style syntax. import BasicIS4.Semantics.TarskiOvergluedDyadicGentzen -- Gentzen-style syntax. -- Tarski-style semantics with context pairs as concrete worlds, and glueing for β–‘ only. import BasicIS4.Semantics.TarskiGluedDyadicImplicit -- Implicit syntax. -- TODO import BasicIS4.Semantics.TarskiGluedDyadicHilbert -- Hilbert-style syntax. import BasicIS4.Semantics.TarskiGluedDyadicGentzen -- Gentzen-style syntax. -- Canonical model equipment for Kripke-style semantics with contexts as concrete worlds. import BasicIS4.Equipment.KripkeCanonical import BasicIS4.Equipment.KripkeNonCanonical -- Canonical model equipment for Kripke-style semantics with context pairs as concrete worlds. import BasicIS4.Equipment.KripkeDyadicCanonical import BasicIS4.Equipment.KripkeDyadicNonCanonical -- Available metatheory for basic IS4. -- -- β”Œβ”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β” -- β”‚ CH β”‚ H β”‚ G β”‚ DH β”‚ DG β”‚ -- β”Œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€ -- β”‚ BKO β”‚ β”‚ e β”‚ e β”‚ e β”‚ e β”‚ -- β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€ -- β”‚ BKBDβ”‚ β”‚ e β”‚ e β”‚ e β”‚ e β”‚ -- β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€ -- β”‚ BKE β”‚ β”‚ e β”‚ e β”‚ e β”‚ e β”‚ -- β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€ -- β”‚ BKA&β”‚ β”‚ e β”‚ e β”‚ e β”‚ e β”‚ -- β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€ -- β”‚ TCOIβ”‚ eβ‚€qβ‚€β”‚ eqβ‚€ β”‚ eqβ‚€ β”‚ β”‚ β”‚ -- β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€ -- β”‚ TCOHβ”‚ eβ‚€qβ‚€β”‚ eqβ‚€ β”‚ β”‚ β”‚ β”‚ -- β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€ -- β”‚ TOI β”‚ β”‚ eq β”‚ eq β”‚ β”‚ β”‚ -- β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€ -- β”‚ TOH β”‚ β”‚ eq β”‚ β”‚ β”‚ β”‚ -- β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€ -- β”‚ TOG β”‚ β”‚ eq β”‚ eq β”‚ β”‚ β”‚ -- β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€ -- β”‚ TGI β”‚ β”‚ eq β”‚ WIP β”‚ β”‚ β”‚ -- β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€ -- β”‚ TGH β”‚ β”‚ eq β”‚ β”‚ β”‚ β”‚ -- β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€ -- β”‚ TGG β”‚ β”‚ β”‚ WIP β”‚ β”‚ β”‚ -- β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€ -- β”‚ TODIβ”‚ β”‚ β”‚ β”‚ eq β”‚ eq β”‚ -- β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€ -- β”‚ TODHβ”‚ β”‚ β”‚ β”‚ eq β”‚ β”‚ -- β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€ -- β”‚ TODGβ”‚ β”‚ β”‚ β”‚ eq β”‚ eq β”‚ -- β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€ -- β”‚ TGDIβ”‚ β”‚ β”‚ β”‚ WIP β”‚ WIP β”‚ -- β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€ -- β”‚ TGDHβ”‚ β”‚ β”‚ β”‚ WIP β”‚ β”‚ -- β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€ -- β”‚ TGDGβ”‚ β”‚ β”‚ β”‚ β”‚ WIP β”‚ -- β””β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”˜ -- -- eβ‚€ : Soundness only, for closed terms only. -- eβ‚€qβ‚€ : Soundness and completeness, for closed terms only. -- e : Soundness only. -- eqβ‚€ : Soundness, for all terms; completeness, for closed terms only. -- eq : Soundness and completeness, or normalisation by evaluation. -- WIP : Work in progress. import BasicIS4.Metatheory.ClosedHilbert-TarskiClosedOvergluedImplicit import BasicIS4.Metatheory.ClosedHilbert-TarskiClosedOvergluedHilbert import BasicIS4.Metatheory.Hilbert-BasicKripkeOno import BasicIS4.Metatheory.Hilbert-BasicKripkeBozicDosen import BasicIS4.Metatheory.Hilbert-BasicKripkeEwald import BasicIS4.Metatheory.Hilbert-BasicKripkeAlechina import BasicIS4.Metatheory.Hilbert-TarskiClosedOvergluedImplicit import BasicIS4.Metatheory.Hilbert-TarskiClosedOvergluedHilbert import BasicIS4.Metatheory.Hilbert-TarskiOvergluedImplicit import BasicIS4.Metatheory.Hilbert-TarskiOvergluedHilbert import BasicIS4.Metatheory.Hilbert-TarskiOvergluedGentzen import BasicIS4.Metatheory.Hilbert-TarskiGluedImplicit import BasicIS4.Metatheory.Hilbert-TarskiGluedHilbert import BasicIS4.Metatheory.Gentzen-BasicKripkeOno import BasicIS4.Metatheory.Gentzen-BasicKripkeBozicDosen import BasicIS4.Metatheory.Gentzen-BasicKripkeEwald import BasicIS4.Metatheory.Gentzen-BasicKripkeAlechina import BasicIS4.Metatheory.Gentzen-TarskiClosedOvergluedImplicit import BasicIS4.Metatheory.Gentzen-TarskiOvergluedImplicit import BasicIS4.Metatheory.Gentzen-TarskiOvergluedGentzen import BasicIS4.Metatheory.Gentzen-TarskiGluedImplicit -- FIXME import BasicIS4.Metatheory.Gentzen-TarskiGluedGentzen -- FIXME import BasicIS4.Metatheory.DyadicHilbert-BasicKripkeOno import BasicIS4.Metatheory.DyadicHilbert-BasicKripkeBozicDosen import BasicIS4.Metatheory.DyadicHilbert-BasicKripkeEwald import BasicIS4.Metatheory.DyadicHilbert-BasicKripkeAlechina import BasicIS4.Metatheory.DyadicHilbert-TarskiOvergluedDyadicImplicit import BasicIS4.Metatheory.DyadicHilbert-TarskiOvergluedDyadicHilbert import BasicIS4.Metatheory.DyadicHilbert-TarskiOvergluedDyadicGentzen import BasicIS4.Metatheory.DyadicHilbert-TarskiGluedDyadicImplicit -- FIXME import BasicIS4.Metatheory.DyadicHilbert-TarskiGluedDyadicHilbert import BasicIS4.Metatheory.DyadicGentzen-BasicKripkeOno import BasicIS4.Metatheory.DyadicGentzen-BasicKripkeBozicDosen import BasicIS4.Metatheory.DyadicGentzen-BasicKripkeEwald import BasicIS4.Metatheory.DyadicGentzen-BasicKripkeAlechina import BasicIS4.Metatheory.DyadicGentzen-TarskiOvergluedDyadicImplicit import BasicIS4.Metatheory.DyadicGentzen-TarskiOvergluedDyadicGentzen import BasicIS4.Metatheory.DyadicGentzen-TarskiGluedDyadicImplicit -- FIXME import BasicIS4.Metatheory.DyadicGentzen-TarskiGluedDyadicGentzen -- FIXME import BasicIS4.Metatheory.DyadicGentzenSpinalNormalForm-HereditarySubstitution -- Basic intuitionistic contextual modal logic, without ∨ or βŠ₯. -- Common syntax. import BasicICML.Syntax.Common -- Gentzen-style formalisation of syntax with context pairs, after Nanevski-Pfenning-Pientka. import BasicICML.Syntax.DyadicGentzen import BasicICML.Syntax.DyadicGentzenNormalForm import BasicICML.Syntax.DyadicGentzenSpinalNormalForm -- Available metatheory for basic ICML. import BasicICML.Metatheory.DyadicGentzenSpinalNormalForm-HereditarySubstitution -- Basic intuitionistic logic of proofs, without ∨, βŠ₯, or +. -- Common syntax. import BasicILP.Syntax.Common -- Gentzen-style formalisation of syntax with context pairs. import BasicILP.Syntax.DyadicGentzen import BasicILP.Syntax.DyadicGentzenNormalForm -- (To be rewritten.) -- Common syntax, with types parametrised by a closed, untyped representation of syntax. import OldBasicILP.UntypedSyntax.Common -- Hilbert-style formalisation of closed syntax. import OldBasicILP.UntypedSyntax.ClosedHilbertSequential -- Sequences of terms. import OldBasicILP.UntypedSyntax.ClosedHilbert -- Nested terms. -- Translation between different formalisations of syntax. import OldBasicILP.UntypedSyntax.Translation -- FIXME -- Common syntax, with types parametrised by closed syntax. import OldBasicILP.Syntax.Common -- Hilbert-style formalisation of closed syntax. import OldBasicILP.Syntax.ClosedHilbertSequential -- Sequences of terms. import OldBasicILP.Syntax.ClosedHilbert -- Nested terms. -- Translation between different formalisations of syntax. import OldBasicILP.Syntax.Translation -- FIXME -- import OldBasicILP.Syntax.Projection -- FIXME -- (To be rewritten.) import OlderBasicILP.Indirect import OlderBasicILP.Indirect.Hilbert.Sequential import OlderBasicILP.Indirect.Hilbert.Nested import OlderBasicILP.Indirect.Gentzen -- import OlderBasicILP.Indirect.Translation import OlderBasicILP.Direct.Hilbert.Nested import OlderBasicILP.Direct.Gentzen -- import OlderBasicILP.Direct.Translation
{ "alphanum_fraction": 0.6896925663, "avg_line_length": 39.0741525424, "ext": "agda", "hexsha": "53517d1bc506796910aa1f00a084e6caae34564f", "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": "Everything.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": "Everything.agda", "max_line_length": 94, "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": "Everything.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": 5965, "size": 18443 }
module IPL where data _∧_ (P : Set) (Q : Set) : Set where ∧-intro : P β†’ Q β†’ (P ∧ Q) proof₁ : {P Q : Set} β†’ (P ∧ Q) β†’ P proof₁ (∧-intro p q) = p proofβ‚‚ : {P Q : Set} β†’ (P ∧ Q) β†’ Q proofβ‚‚ (∧-intro p q) = q _⇔_ : (P : Set) β†’ (Q : Set) β†’ Set a ⇔ b = (a β†’ b) ∧ (b β†’ a) ∧-commβ€² : (P Q : Set) β†’ (P ∧ Q) β†’ (Q ∧ P) ∧-commβ€² _ _ (∧-intro p q) = ∧-intro q p ∧-comm : (P Q : Set) β†’ (P ∧ Q) ⇔ (Q ∧ P) ∧-comm P Q = ∧-intro (∧-commβ€² P Q) (∧-commβ€² Q P) ∧-comm1β€² : {P Q : Set} β†’ (P ∧ Q) β†’ (Q ∧ P) ∧-comm1β€² (∧-intro p q) = ∧-intro q p data _∨_ (P Q : Set) : Set where ∨-intro₁ : P β†’ P ∨ Q ∨-introβ‚‚ : Q β†’ P ∨ Q ∨-elim : {A B C : Set} β†’ (A β†’ C) β†’ (B β†’ C) β†’ (A ∨ B) β†’ C ∨-elim ac bc (∨-intro₁ a) = ac a ∨-elim ac bc (∨-introβ‚‚ b) = bc b ∨-commβ€² : {A B : Set} β†’ (A ∨ B) β†’ (B ∨ A) ∨-commβ€² (∨-intro₁ a) = ∨-introβ‚‚ a ∨-commβ€² (∨-introβ‚‚ b) = ∨-intro₁ b ∨-comm : {A B : Set} β†’ (A ∨ B) ⇔ (B ∨ A) ∨-comm = ∧-intro ∨-commβ€² ∨-commβ€² data βŠ₯ : Set where Β¬ : Set β†’ Set Β¬ A = A β†’ βŠ₯
{ "alphanum_fraction": 0.4219712526, "avg_line_length": 18.3773584906, "ext": "agda", "hexsha": "6fbdc19033d4ca5c3209752661d0580d0b004364", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2017-06-03T06:32:26.000Z", "max_forks_repo_forks_event_min_datetime": "2015-12-02T02:10:26.000Z", "max_forks_repo_head_hexsha": "a6fc111e02dc631f56302bb059d855446792bebc", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "shouya/thinking-dumps", "max_forks_repo_path": "learyouanagda/IPL.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "a6fc111e02dc631f56302bb059d855446792bebc", "max_issues_repo_issues_event_max_datetime": "2015-08-04T22:05:11.000Z", "max_issues_repo_issues_event_min_datetime": "2015-06-14T06:07:33.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "shouya/thinking-dumps", "max_issues_repo_path": "learyouanagda/IPL.agda", "max_line_length": 56, "max_stars_count": 24, "max_stars_repo_head_hexsha": "a6fc111e02dc631f56302bb059d855446792bebc", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "shouya/thinking-dumps", "max_stars_repo_path": "learyouanagda/IPL.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-09T01:02:15.000Z", "max_stars_repo_stars_event_min_datetime": "2015-02-14T17:18:34.000Z", "num_tokens": 516, "size": 974 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Conversion of ≀ to <, along with a number of properties ------------------------------------------------------------------------ -- Possible TODO: Prove that a conversion ≀ β†’ < β†’ ≀ returns a -- relation equivalent to the original one (and similarly for -- < → ≀ → <). open import Relation.Binary module Relation.Binary.NonStrictToStrict {a ℓ₁ β„“β‚‚} {A : Set a} (_β‰ˆ_ : Rel A ℓ₁) (_≀_ : Rel A β„“β‚‚) where open import Relation.Nullary open import Relation.Binary.Consequences open import Function open import Data.Product open import Data.Sum ------------------------------------------------------------------------ -- Conversion -- _≀_ can be turned into _<_ as follows: _<_ : Rel A _ x < y = (x ≀ y) Γ— Β¬ (x β‰ˆ y) ------------------------------------------------------------------------ -- The converted relations have certain properties -- (if the original relations have certain other properties) irrefl : Irreflexive _β‰ˆ_ _<_ irrefl xβ‰ˆy x<y = projβ‚‚ x<y xβ‰ˆy trans : IsPartialOrder _β‰ˆ_ _≀_ β†’ Transitive _<_ trans po = Ξ» x<y y<z β†’ ( PO.trans (proj₁ x<y) (proj₁ y<z) , Ξ» xβ‰ˆz β†’ projβ‚‚ x<y $ lemma (proj₁ x<y) (proj₁ y<z) xβ‰ˆz ) where module PO = IsPartialOrder po lemma : βˆ€ {x y z} β†’ x ≀ y β†’ y ≀ z β†’ x β‰ˆ z β†’ x β‰ˆ y lemma x≀y y≀z xβ‰ˆz = PO.antisym x≀y $ PO.trans y≀z (PO.reflexive $ PO.Eq.sym xβ‰ˆz) antisym⟢asym : Antisymmetric _β‰ˆ_ _≀_ β†’ Asymmetric _<_ antisym⟢asym antisym (x≀y , Β¬xβ‰ˆy) (y≀x , Β¬yβ‰ˆx) = Β¬xβ‰ˆy (antisym x≀y y≀x) <-resp-β‰ˆ : IsEquivalence _β‰ˆ_ β†’ _≀_ Respectsβ‚‚ _β‰ˆ_ β†’ _<_ Respectsβ‚‚ _β‰ˆ_ <-resp-β‰ˆ eq ≀-resp-β‰ˆ = (Ξ» {x y' y} y'β‰ˆy x<y' β†’ ( proj₁ ≀-resp-β‰ˆ y'β‰ˆy (proj₁ x<y') , Ξ» xβ‰ˆy β†’ projβ‚‚ x<y' (Eq.trans xβ‰ˆy (Eq.sym y'β‰ˆy)) ) ) , (Ξ» {y x' x} x'β‰ˆx x'<y β†’ ( projβ‚‚ ≀-resp-β‰ˆ x'β‰ˆx (proj₁ x'<y) , Ξ» xβ‰ˆy β†’ projβ‚‚ x'<y (Eq.trans x'β‰ˆx xβ‰ˆy) )) where module Eq = IsEquivalence eq trichotomous : Symmetric _β‰ˆ_ β†’ Decidable _β‰ˆ_ β†’ Antisymmetric _β‰ˆ_ _≀_ β†’ Total _≀_ β†’ Trichotomous _β‰ˆ_ _<_ trichotomous β‰ˆ-sym β‰ˆ-dec antisym total x y with β‰ˆ-dec x y ... | yes xβ‰ˆy = triβ‰ˆ (irrefl xβ‰ˆy) xβ‰ˆy (irrefl (β‰ˆ-sym xβ‰ˆy)) ... | no x≉y with total x y ... | inj₁ x≀y = tri< (x≀y , x≉y) x≉y (x≉y ∘ antisym x≀y ∘ proj₁) ... | injβ‚‚ xβ‰₯y = tri> (x≉y ∘ flip antisym xβ‰₯y ∘ proj₁) x≉y (xβ‰₯y , x≉y ∘ β‰ˆ-sym) decidable : Decidable _β‰ˆ_ β†’ Decidable _≀_ β†’ Decidable _<_ decidable β‰ˆ-dec ≀-dec x y with β‰ˆ-dec x y | ≀-dec x y ... | yes xβ‰ˆy | _ = no (flip projβ‚‚ xβ‰ˆy) ... | no x≉y | yes x≀y = yes (x≀y , x≉y) ... | no x≉y | no xβ‰°y = no (xβ‰°y ∘ proj₁) isPartialOrder⟢isStrictPartialOrder : IsPartialOrder _β‰ˆ_ _≀_ β†’ IsStrictPartialOrder _β‰ˆ_ _<_ isPartialOrder⟢isStrictPartialOrder po = record { isEquivalence = PO.isEquivalence ; irrefl = irrefl ; trans = trans po ; <-resp-β‰ˆ = <-resp-β‰ˆ PO.isEquivalence PO.≀-resp-β‰ˆ } where module PO = IsPartialOrder po isTotalOrder⟢isStrictTotalOrder : Decidable _β‰ˆ_ β†’ IsTotalOrder _β‰ˆ_ _≀_ β†’ IsStrictTotalOrder _β‰ˆ_ _<_ isTotalOrder⟢isStrictTotalOrder dec-β‰ˆ tot = record { isEquivalence = TO.isEquivalence ; trans = trans TO.isPartialOrder ; compare = trichotomous TO.Eq.sym dec-β‰ˆ TO.antisym TO.total ; <-resp-β‰ˆ = <-resp-β‰ˆ TO.isEquivalence TO.≀-resp-β‰ˆ } where module TO = IsTotalOrder tot isDecTotalOrder⟢isStrictTotalOrder : IsDecTotalOrder _β‰ˆ_ _≀_ β†’ IsStrictTotalOrder _β‰ˆ_ _<_ isDecTotalOrder⟢isStrictTotalOrder dtot = isTotalOrder⟢isStrictTotalOrder DTO._β‰Ÿ_ DTO.isTotalOrder where module DTO = IsDecTotalOrder dtot
{ "alphanum_fraction": 0.5625342841, "avg_line_length": 33.7592592593, "ext": "agda", "hexsha": "73e2eed20a132478a4d0490a1e70c2f0108c7e4b", "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/NonStrictToStrict.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/NonStrictToStrict.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/NonStrictToStrict.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": 1384, "size": 3646 }
-- This module is used to illustrate how to import a non-parameterised module. module examples.syntax.ModuleA where data Nat : Set where zero : Nat suc : Nat -> Nat plus : Nat -> Nat -> Nat eval : Nat -> Nat eval zero = zero eval (suc x) = suc (eval x) eval (plus zero y) = eval y eval (plus (suc x) y) = suc (eval (plus x y)) eval (plus (plus x y) z) = eval (plus x (plus y z))
{ "alphanum_fraction": 0.5787037037, "avg_line_length": 25.4117647059, "ext": "agda", "hexsha": "4a77449488fbd7dcde1b9f52534f28351388fc07", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "examples/outdated-and-incorrect/syntax/ModuleA.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "examples/outdated-and-incorrect/syntax/ModuleA.agda", "max_line_length": 78, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "examples/outdated-and-incorrect/syntax/ModuleA.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": 138, "size": 432 }
-- Andreas, 2012-09-24 Ensure that size successor is monotone {-# OPTIONS --sized-types #-} module SizeSucMonotone where open import Common.Size data Bool : Set where true false : Bool -- T should be monotone in its second arg T : Bool β†’ Size β†’ Set T true i = Size< i T false i = Size< (↑ i) test : {x : Bool}{i : Size}{j : Size< i} β†’ T x j β†’ T x i test h = h
{ "alphanum_fraction": 0.6467391304, "avg_line_length": 20.4444444444, "ext": "agda", "hexsha": "50929eca1d6b85e2437e0e55941884f581f6690c", "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/SizeSucMonotone.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/SizeSucMonotone.agda", "max_line_length": 61, "max_stars_count": 1, "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_path": "test/succeed/SizeSucMonotone.agda", "max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z", "num_tokens": 119, "size": 368 }
module Data.String.Exts where open import Data.Bool hiding (_<?_) open import Data.Char hiding (_<?_) open import Data.String hiding (_<?_) open import Data.Maybe open import Data.Nat open import Relation.Nullary.Decidable {-# FOREIGN GHC import Data.Text #-} postulate strHead : String -> Maybe Char strNull : String -> Bool strTake : β„• -> String -> String strDrop : β„• -> String -> String stripPrefix : String -> String -> Maybe String strLength : String -> β„• {-# COMPILE GHC strHead = (fmap fst) . uncons #-} {-# COMPILE GHC strNull = Data.Text.null #-} {-# COMPILE GHC strTake = Data.Text.take . fromIntegral #-} {-# COMPILE GHC strDrop = Data.Text.drop . fromIntegral #-} {-# COMPILE GHC stripPrefix = stripPrefix #-} {-# COMPILE GHC strLength = toInteger . Data.Text.length #-} shortenString : β„• -> String -> String shortenString l s = if ⌊ length s <? l βŒ‹ then s else strTake l s ++ "..."
{ "alphanum_fraction": 0.6772082879, "avg_line_length": 27.7878787879, "ext": "agda", "hexsha": "99ac2b5fa49d0fa4689c0093a90ecd79c39b0fe8", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-10-20T10:46:20.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-27T23:12:48.000Z", "max_forks_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "WhatisRT/meta-cedille", "max_forks_repo_path": "stdlib-exts/Data/String/Exts.agda", "max_issues_count": 10, "max_issues_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_issues_repo_issues_event_max_datetime": "2020-04-25T15:29:17.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-13T17:44:43.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "WhatisRT/meta-cedille", "max_issues_repo_path": "stdlib-exts/Data/String/Exts.agda", "max_line_length": 73, "max_stars_count": 35, "max_stars_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "WhatisRT/meta-cedille", "max_stars_repo_path": "stdlib-exts/Data/String/Exts.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-12T22:59:10.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-13T07:44:50.000Z", "num_tokens": 239, "size": 917 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT import homotopy.RelativelyConstantToSetExtendsViaSurjection as SurjExt module homotopy.vankampen.Code {i j k l} (span : Span {i} {j} {k}) {D : Type l} (h : D β†’ Span.C span) (h-is-surj : is-surj h) where open Span span open import homotopy.vankampen.CodeAP span h h-is-surj open import homotopy.vankampen.CodeBP span h h-is-surj pcAA-to-pcBA : βˆ€ dβ‚€ {a} β†’ precodeAA (f (h dβ‚€)) a β†’ precodeBA (g (h dβ‚€)) a pcAB-to-pcBB : βˆ€ dβ‚€ {b} β†’ precodeAB (f (h dβ‚€)) b β†’ precodeBB (g (h dβ‚€)) b pcAA-to-pcBA dβ‚€ (pc-a pA) = pc-bba dβ‚€ (pc-b idpβ‚€) pA pcAA-to-pcBA dβ‚€ (pc-aba d pc pA) = pc-bba d (pcAB-to-pcBB dβ‚€ pc) pA pcAB-to-pcBB dβ‚€ (pc-aab d pc pB) = pc-bab d (pcAA-to-pcBA dβ‚€ pc) pB abstract pcAA-to-pcBA-rel : βˆ€ dβ‚€ {a} {pcAA₁ pcAAβ‚‚ : precodeAA (f (h dβ‚€)) a} β†’ precodeAA-rel pcAA₁ pcAAβ‚‚ β†’ precodeBA-rel (pcAA-to-pcBA dβ‚€ pcAA₁) (pcAA-to-pcBA dβ‚€ pcAAβ‚‚) pcAB-to-pcBB-rel : βˆ€ dβ‚€ {a} {pcAB₁ pcABβ‚‚ : precodeAB (f (h dβ‚€)) a} β†’ precodeAB-rel pcAB₁ pcABβ‚‚ β†’ precodeBB-rel (pcAB-to-pcBB dβ‚€ pcAB₁) (pcAB-to-pcBB dβ‚€ pcABβ‚‚) pcAA-to-pcBA-rel dβ‚€ (pcAAr-idpβ‚€-idpβ‚€ pcAA) = pcBAr-idpβ‚€-idpβ‚€ (pcAA-to-pcBA dβ‚€ pcAA) pcAA-to-pcBA-rel dβ‚€ (pcAAr-cong r pA) = pcBAr-cong (pcAB-to-pcBB-rel dβ‚€ r) pA pcAB-to-pcBB-rel dβ‚€ (pcABr-idpβ‚€-idpβ‚€ pcAB) = pcBBr-idpβ‚€-idpβ‚€ (pcAB-to-pcBB dβ‚€ pcAB) pcAB-to-pcBB-rel dβ‚€ (pcABr-switch pcAB pC) = pcBBr-switch (pcAB-to-pcBB dβ‚€ pcAB) pC pcAB-to-pcBB-rel dβ‚€ (pcABr-cong r pB) = pcBBr-cong (pcAA-to-pcBA-rel dβ‚€ r) pB cAA-to-cBA : βˆ€ dβ‚€ {a} β†’ codeAA (f (h dβ‚€)) a β†’ codeBA (g (h dβ‚€)) a cAA-to-cBA dβ‚€ = SetQuot-rec SetQuot-level (q[_] ∘ pcAA-to-pcBA dβ‚€) (quot-rel ∘ pcAA-to-pcBA-rel dβ‚€) cAB-to-cBB : βˆ€ dβ‚€ {b} β†’ codeAB (f (h dβ‚€)) b β†’ codeBB (g (h dβ‚€)) b cAB-to-cBB dβ‚€ = SetQuot-rec SetQuot-level (q[_] ∘ pcAB-to-pcBB dβ‚€) (quot-rel ∘ pcAB-to-pcBB-rel dβ‚€) -- BX to AX pcBA-to-pcAA : βˆ€ dβ‚€ {a} β†’ precodeBA (g (h dβ‚€)) a β†’ precodeAA (f (h dβ‚€)) a pcBB-to-pcAB : βˆ€ dβ‚€ {b} β†’ precodeBB (g (h dβ‚€)) b β†’ precodeAB (f (h dβ‚€)) b pcBA-to-pcAA dβ‚€ (pc-bba d pc pA) = pc-aba d (pcBB-to-pcAB dβ‚€ pc) pA pcBB-to-pcAB dβ‚€ (pc-b pB) = pc-aab dβ‚€ (pc-a idpβ‚€) pB pcBB-to-pcAB dβ‚€ (pc-bab d pc pB) = pc-aab d (pcBA-to-pcAA dβ‚€ pc) pB abstract pcBA-to-pcAA-rel : βˆ€ dβ‚€ {a} {pcBA₁ pcBAβ‚‚ : precodeBA (g (h dβ‚€)) a} β†’ precodeBA-rel pcBA₁ pcBAβ‚‚ β†’ precodeAA-rel (pcBA-to-pcAA dβ‚€ pcBA₁) (pcBA-to-pcAA dβ‚€ pcBAβ‚‚) pcBB-to-pcAB-rel : βˆ€ dβ‚€ {a} {pcBB₁ pcBBβ‚‚ : precodeBB (g (h dβ‚€)) a} β†’ precodeBB-rel pcBB₁ pcBBβ‚‚ β†’ precodeAB-rel (pcBB-to-pcAB dβ‚€ pcBB₁) (pcBB-to-pcAB dβ‚€ pcBBβ‚‚) pcBA-to-pcAA-rel dβ‚€ (pcBAr-idpβ‚€-idpβ‚€ pcBA) = pcAAr-idpβ‚€-idpβ‚€ (pcBA-to-pcAA dβ‚€ pcBA) pcBA-to-pcAA-rel dβ‚€ (pcBAr-cong r pA) = pcAAr-cong (pcBB-to-pcAB-rel dβ‚€ r) pA pcBB-to-pcAB-rel dβ‚€ (pcBBr-idpβ‚€-idpβ‚€ pcBB) = pcABr-idpβ‚€-idpβ‚€ (pcBB-to-pcAB dβ‚€ pcBB) pcBB-to-pcAB-rel dβ‚€ (pcBBr-switch pcBB pC) = pcABr-switch (pcBB-to-pcAB dβ‚€ pcBB) pC pcBB-to-pcAB-rel dβ‚€ (pcBBr-cong r pB) = pcABr-cong (pcBA-to-pcAA-rel dβ‚€ r) pB cBA-to-cAA : βˆ€ dβ‚€ {a} β†’ codeBA (g (h dβ‚€)) a β†’ codeAA (f (h dβ‚€)) a cBA-to-cAA dβ‚€ = SetQuot-rec SetQuot-level (q[_] ∘ pcBA-to-pcAA dβ‚€) (quot-rel ∘ pcBA-to-pcAA-rel dβ‚€) cBB-to-cAB : βˆ€ dβ‚€ {b} β†’ codeBB (g (h dβ‚€)) b β†’ codeAB (f (h dβ‚€)) b cBB-to-cAB dβ‚€ = SetQuot-rec SetQuot-level (q[_] ∘ pcBB-to-pcAB dβ‚€) (quot-rel ∘ pcBB-to-pcAB-rel dβ‚€) -- roundtrips abstract pcBA-to-pcAA-to-pcBA : βˆ€ dβ‚€ {a} (pcBA : precodeBA _ a) β†’ q[ pcAA-to-pcBA dβ‚€ (pcBA-to-pcAA dβ‚€ pcBA) ] == q[ pcBA ] :> codeBA _ a pcBB-to-pcAB-to-pcBB : βˆ€ dβ‚€ {b} (pcBB : precodeBB _ b) β†’ q[ pcAB-to-pcBB dβ‚€ (pcBB-to-pcAB dβ‚€ pcBB) ] == q[ pcBB ] :> codeBB _ b pcBA-to-pcAA-to-pcBA dβ‚€ (pc-bba d pc pA) = pcBB-to-pcAB-to-pcBB dβ‚€ pc |in-ctx Ξ» c β†’ c-bba d c pA pcBB-to-pcAB-to-pcBB dβ‚€ (pc-b pB) = pcBB-idpβ‚€-idpβ‚€-head pB pcBB-to-pcAB-to-pcBB dβ‚€ (pc-bab d pc pB) = pcBA-to-pcAA-to-pcBA dβ‚€ pc |in-ctx Ξ» c β†’ c-bab d c pB pcAA-to-pcBA-to-pcAA : βˆ€ dβ‚€ {a} (pcAA : precodeAA _ a) β†’ q[ pcBA-to-pcAA dβ‚€ (pcAA-to-pcBA dβ‚€ pcAA) ] == q[ pcAA ] :> codeAA _ a pcAB-to-pcBB-to-pcAB : βˆ€ dβ‚€ {b} (pcAB : precodeAB _ b) β†’ q[ pcBB-to-pcAB dβ‚€ (pcAB-to-pcBB dβ‚€ pcAB) ] == q[ pcAB ] :> codeAB _ b pcAA-to-pcBA-to-pcAA dβ‚€ (pc-aba d pc pA) = pcAB-to-pcBB-to-pcAB dβ‚€ pc |in-ctx Ξ» c β†’ c-aba d c pA pcAA-to-pcBA-to-pcAA dβ‚€ (pc-a pA) = pcAA-idpβ‚€-idpβ‚€-head pA pcAB-to-pcBB-to-pcAB dβ‚€ (pc-aab d pc pB) = pcAA-to-pcBA-to-pcAA dβ‚€ pc |in-ctx Ξ» c β†’ c-aab d c pB private pcAA-lemma : βˆ€ d₁ dβ‚‚ {a₁} (p : h dβ‚‚ == h d₁) (pcAA : precodeAA _ a₁) β†’ q[ pcBA-prepend d₁ [ ap g p ] (pcAA-to-pcBA d₁ pcAA) ] == q[ pcAA-to-pcBA dβ‚‚ (pcAA-prepend d₁ [ ap f p ] pcAA) ] pcAB-lemma : βˆ€ d₁ dβ‚‚ {b₁} (p : h dβ‚‚ == h d₁) (pcAB : precodeAB _ b₁) β†’ q[ pcBB-prepend d₁ [ ap g p ] (pcAB-to-pcBB d₁ pcAB) ] == q[ pcAB-to-pcBB dβ‚‚ (pcAB-prepend d₁ [ ap f p ] pcAB) ] pcAA-lemma d₁ dβ‚‚ p (pc-a pA) = ap (Ξ» c β†’ c-bba d₁ c pA) $ ! $ q[ ⟧b idpβ‚€ bb⟦ _ ⟧a [ ap f p ] ba⟦ _ ⟧b idpβ‚€ ] =⟨ quot-rel (pcBBr-switch (⟧b idpβ‚€) [ p ]) ⟩ q[ ⟧b idpβ‚€ bb⟦ _ ⟧a idpβ‚€ ba⟦ _ ⟧b [ ap g p ] ] =⟨ pcBB-idpβ‚€-idpβ‚€-head [ ap g p ] ⟩ q[ ⟧b [ ap g p ] ] =⟨ ! (quot-rel (pcBBr-idpβ‚€-idpβ‚€ (pc-b [ ap g p ]))) ⟩ q[ ⟧b [ ap g p ] bb⟦ _ ⟧a idpβ‚€ ba⟦ _ ⟧b idpβ‚€ ] =∎ pcAA-lemma d₁ dβ‚‚ p (pc-aba d pc pA) = pcAB-lemma d₁ dβ‚‚ p pc |in-ctx (Ξ» c β†’ c-bba d c pA) pcAB-lemma d₁ dβ‚‚ p (pc-aab d pc pB) = pcAA-lemma d₁ dβ‚‚ p pc |in-ctx (Ξ» c β†’ c-bab d c pB) module CodeAAEquivCodeBA (a₁ : A) where eqv-on-image : (dβ‚€ : D) β†’ codeAA (f (h dβ‚€)) a₁ ≃ codeBA (g (h dβ‚€)) a₁ eqv-on-image dβ‚€ = equiv to from to-from from-to where to : codeAA (f (h dβ‚€)) a₁ β†’ codeBA (g (h dβ‚€)) a₁ to = cAA-to-cBA dβ‚€ from : codeBA (g (h dβ‚€)) a₁ β†’ codeAA (f (h dβ‚€)) a₁ from = cBA-to-cAA dβ‚€ abstract to-from : βˆ€ cBA β†’ to (from cBA) == cBA to-from = SetQuot-elim (Ξ» _ β†’ =-preserves-set SetQuot-is-set) (pcBA-to-pcAA-to-pcBA dβ‚€) (Ξ» _ β†’ prop-has-all-paths-↓ (SetQuot-is-set _ _)) from-to : βˆ€ cAA β†’ from (to cAA) == cAA from-to = SetQuot-elim (Ξ» _ β†’ =-preserves-set SetQuot-is-set) (pcAA-to-pcBA-to-pcAA dβ‚€) (Ξ» _ β†’ prop-has-all-paths-↓ (SetQuot-is-set _ _)) abstract eqv-is-const : βˆ€ d₁ dβ‚‚ (p : h d₁ == h dβ‚‚) β†’ eqv-on-image d₁ == eqv-on-image dβ‚‚ [ (Ξ» c β†’ codeAA (f c) a₁ ≃ codeBA (g c) a₁) ↓ p ] eqv-is-const d₁ dβ‚‚ p = ↓-Subtype-in (Ξ» d β†’ is-equiv-prop) $ ↓-β†’-from-transp $ Ξ»= $ SetQuot-elim (Ξ» _ β†’ =-preserves-set SetQuot-is-set) (Ξ» pcAA β†’ transport (Ξ» c β†’ codeBA (g c) a₁) p q[ pcAA-to-pcBA d₁ pcAA ] =⟨ ap-∘ (Ξ» b β†’ codeBA b a₁) g p |in-ctx (Ξ» p β†’ coe p q[ pcAA-to-pcBA d₁ pcAA ]) ⟩ transport (Ξ» b β†’ codeBA b a₁) (ap g p) q[ pcAA-to-pcBA d₁ pcAA ] =⟨ transp-cBA-l d₁ (ap g p) (pcAA-to-pcBA d₁ pcAA) ⟩ q[ pcBA-prepend d₁ [ ! $ ap g p ] (pcAA-to-pcBA d₁ pcAA) ] =⟨ !-ap g p |in-ctx (Ξ» p β†’ q[ pcBA-prepend d₁ [ p ] (pcAA-to-pcBA d₁ pcAA) ]) ⟩ q[ pcBA-prepend d₁ [ ap g (! p) ] (pcAA-to-pcBA d₁ pcAA) ] =⟨ pcAA-lemma d₁ dβ‚‚ (! p) pcAA ⟩ q[ pcAA-to-pcBA dβ‚‚ (pcAA-prepend d₁ [ ap f (! p) ] pcAA) ] =⟨ ap-! f p |in-ctx (Ξ» p β†’ q[ pcAA-to-pcBA dβ‚‚ (pcAA-prepend d₁ [ p ] pcAA) ]) ⟩ q[ pcAA-to-pcBA dβ‚‚ (pcAA-prepend d₁ [ ! $ ap f p ] pcAA) ] =⟨ ! $ transp-cAA-l d₁ (ap f p) pcAA |in-ctx cAA-to-cBA dβ‚‚ ⟩ cAA-to-cBA dβ‚‚ (transport (Ξ» a β†’ codeAA a a₁) (ap f p) q[ pcAA ]) =⟨ ∘-ap (Ξ» c β†’ codeAA c a₁) f p |in-ctx (Ξ» p β†’ coe p q[ pcAA ]) |in-ctx cAA-to-cBA dβ‚‚ ⟩ cAA-to-cBA dβ‚‚ (transport (Ξ» c β†’ codeAA (f c) a₁) p q[ pcAA ]) =∎) (Ξ» _ β†’ prop-has-all-paths-↓ (SetQuot-is-set _ _)) module SE = SurjExt (Ξ» c β†’ ≃-is-set SetQuot-is-set SetQuot-is-set) h h-is-surj eqv-on-image eqv-is-const abstract eqv : βˆ€ c β†’ codeAA (f c) a₁ ≃ codeBA (g c) a₁ eqv = SE.ext eqv-Ξ² : βˆ€ d β†’ eqv (h d) == eqv-on-image d eqv-Ξ² = SE.Ξ² module CodeABEquivCodeBB (b₁ : B) where eqv-on-image : (dβ‚€ : D) β†’ codeAB (f (h dβ‚€)) b₁ ≃ codeBB (g (h dβ‚€)) b₁ eqv-on-image dβ‚€ = equiv to from to-from from-to where to : codeAB (f (h dβ‚€)) b₁ β†’ codeBB (g (h dβ‚€)) b₁ to = cAB-to-cBB dβ‚€ from : codeBB (g (h dβ‚€)) b₁ β†’ codeAB (f (h dβ‚€)) b₁ from = cBB-to-cAB dβ‚€ abstract to-from : βˆ€ cBB β†’ to (from cBB) == cBB to-from = SetQuot-elim (Ξ» _ β†’ =-preserves-set SetQuot-is-set) (pcBB-to-pcAB-to-pcBB dβ‚€) (Ξ» _ β†’ prop-has-all-paths-↓ (SetQuot-is-set _ _)) from-to : βˆ€ cAB β†’ from (to cAB) == cAB from-to = SetQuot-elim (Ξ» _ β†’ =-preserves-set SetQuot-is-set) (pcAB-to-pcBB-to-pcAB dβ‚€) (Ξ» _ β†’ prop-has-all-paths-↓ (SetQuot-is-set _ _)) abstract eqv-is-const : βˆ€ d₁ dβ‚‚ (p : h d₁ == h dβ‚‚) β†’ eqv-on-image d₁ == eqv-on-image dβ‚‚ [ (Ξ» c β†’ codeAB (f c) b₁ ≃ codeBB (g c) b₁) ↓ p ] eqv-is-const d₁ dβ‚‚ p = ↓-Subtype-in (Ξ» d β†’ is-equiv-prop) $ ↓-β†’-from-transp $ Ξ»= $ SetQuot-elim (Ξ» _ β†’ =-preserves-set SetQuot-is-set) (Ξ» pcAB β†’ transport (Ξ» c β†’ codeBB (g c) b₁) p q[ pcAB-to-pcBB d₁ pcAB ] =⟨ ap-∘ (Ξ» b β†’ codeBB b b₁) g p |in-ctx (Ξ» p β†’ coe p q[ pcAB-to-pcBB d₁ pcAB ]) ⟩ transport (Ξ» b β†’ codeBB b b₁) (ap g p) q[ pcAB-to-pcBB d₁ pcAB ] =⟨ transp-cBB-l d₁ (ap g p) (pcAB-to-pcBB d₁ pcAB) ⟩ q[ pcBB-prepend d₁ [ ! $ ap g p ] (pcAB-to-pcBB d₁ pcAB) ] =⟨ !-ap g p |in-ctx (Ξ» p β†’ q[ pcBB-prepend d₁ [ p ] (pcAB-to-pcBB d₁ pcAB) ]) ⟩ q[ pcBB-prepend d₁ [ ap g (! p) ] (pcAB-to-pcBB d₁ pcAB) ] =⟨ pcAB-lemma d₁ dβ‚‚ (! p) pcAB ⟩ q[ pcAB-to-pcBB dβ‚‚ (pcAB-prepend d₁ [ ap f (! p) ] pcAB) ] =⟨ ap-! f p |in-ctx (Ξ» p β†’ q[ pcAB-to-pcBB dβ‚‚ (pcAB-prepend d₁ [ p ] pcAB) ]) ⟩ q[ pcAB-to-pcBB dβ‚‚ (pcAB-prepend d₁ [ ! $ ap f p ] pcAB) ] =⟨ ! $ transp-cAB-l d₁ (ap f p) pcAB |in-ctx cAB-to-cBB dβ‚‚ ⟩ cAB-to-cBB dβ‚‚ (transport (Ξ» a β†’ codeAB a b₁) (ap f p) q[ pcAB ]) =⟨ ∘-ap (Ξ» c β†’ codeAB c b₁) f p |in-ctx (Ξ» p β†’ coe p q[ pcAB ]) |in-ctx cAB-to-cBB dβ‚‚ ⟩ cAB-to-cBB dβ‚‚ (transport (Ξ» c β†’ codeAB (f c) b₁) p q[ pcAB ]) =∎) (Ξ» _ β†’ prop-has-all-paths-↓ (SetQuot-is-set _ _)) module SE = SurjExt (Ξ» c β†’ ≃-is-set SetQuot-is-set SetQuot-is-set) h h-is-surj eqv-on-image eqv-is-const abstract eqv : βˆ€ c β†’ codeAB (f c) b₁ ≃ codeBB (g c) b₁ eqv = SE.ext eqv-Ξ² : βˆ€ d β†’ eqv (h d) == eqv-on-image d eqv-Ξ² = SE.Ξ² module EqvPAIdEqvPB where abstract path-on-image : βˆ€ dβ‚€ d₁ β†’ CodeAAEquivCodeBA.eqv (f (h d₁)) (h dβ‚€) == CodeABEquivCodeBB.eqv (g (h d₁)) (h dβ‚€) [ (Ξ» p β†’ codeAP (f (h dβ‚€)) p ≃ codeBP (g (h dβ‚€)) p) ↓ glue (h d₁) ] path-on-image dβ‚€ d₁ = CodeAAEquivCodeBA.eqv-Ξ² (f (h d₁)) dβ‚€ βˆ™α΅ˆ lemma βˆ™'ᡈ ! (CodeABEquivCodeBB.eqv-Ξ² (g (h d₁)) dβ‚€) where lemma : CodeAAEquivCodeBA.eqv-on-image (f (h d₁)) dβ‚€ == CodeABEquivCodeBB.eqv-on-image (g (h d₁)) dβ‚€ [ (Ξ» p β†’ codeAP (f (h dβ‚€)) p ≃ codeBP (g (h dβ‚€)) p) ↓ glue (h d₁) ] lemma = ↓-Subtype-in (Ξ» d β†’ is-equiv-prop) $ ↓-β†’-from-transp $ Ξ»= $ SetQuot-elim (Ξ» _ β†’ =-preserves-set SetQuot-is-set) (Ξ» pcAA β†’ transport (Ξ» p β†’ codeBP (g (h dβ‚€)) p) (glue (h d₁)) q[ pcAA-to-pcBA dβ‚€ pcAA ] =⟨ transp-cBP-glue d₁ (pcAA-to-pcBA dβ‚€ pcAA) ⟩ q[ pcAA-to-pcBA dβ‚€ pcAA ba⟦ d₁ ⟧b idpβ‚€ ] =⟨ ! $ transp-cAP-glue d₁ pcAA |in-ctx cAB-to-cBB dβ‚€ ⟩ cAB-to-cBB dβ‚€ (transport (Ξ» p β†’ codeAP (f (h dβ‚€)) p) (glue (h d₁)) q[ pcAA ]) =∎) (Ξ» _ β†’ prop-has-all-paths-↓ $ SetQuot-is-set _ _) abstract path : βˆ€ cβ‚€ c₁ β†’ CodeAAEquivCodeBA.eqv (f c₁) cβ‚€ == CodeABEquivCodeBB.eqv (g c₁) cβ‚€ [ (Ξ» p β†’ codeAP (f cβ‚€) p ≃ codeBP (g cβ‚€) p) ↓ glue c₁ ] path = SurjExt.ext (Ξ» cβ‚€ β†’ Ξ -is-set Ξ» c₁ β†’ ↓-preserves-level $ ≃-is-set SetQuot-is-set SetQuot-is-set) h h-is-surj (Ξ» dβ‚€ β†’ SurjExt.ext (Ξ» c₁ β†’ ↓-preserves-level $ ≃-is-set SetQuot-is-set SetQuot-is-set) h h-is-surj (Ξ» d₁ β†’ path-on-image dβ‚€ d₁) (Ξ» _ _ _ β†’ prop-has-all-paths-↓ $ ↓-level $ ≃-is-set SetQuot-is-set SetQuot-is-set)) (Ξ» _ _ _ β†’ prop-has-all-paths-↓ $ Ξ -is-prop Ξ» _ β†’ ↓-level $ ≃-is-set SetQuot-is-set SetQuot-is-set) cAP-equiv-cBP : βˆ€ cβ‚€ p₁ β†’ codeAP (f cβ‚€) p₁ ≃ codeBP (g cβ‚€) p₁ cAP-equiv-cBP cβ‚€ = Pushout-elim {P = Ξ» p₁ β†’ codeAP (f cβ‚€) p₁ ≃ codeBP (g cβ‚€) p₁} (Ξ» a₁ β†’ CodeAAEquivCodeBA.eqv a₁ cβ‚€) (Ξ» b₁ β†’ CodeABEquivCodeBB.eqv b₁ cβ‚€) (Ξ» c₁ β†’ EqvPAIdEqvPB.path cβ‚€ c₁) module Code = PushoutRec {D = Pushout span β†’ Type (lmax (lmax (lmax i j) k) l)} codeAP codeBP (Ξ» cβ‚€ β†’ Ξ»= $ ua ∘ cAP-equiv-cBP cβ‚€) code : Pushout span β†’ Pushout span β†’ Type (lmax (lmax (lmax i j) k) l) code = Code.f abstract code-level : βˆ€ {pβ‚€ p₁} β†’ is-set (code pβ‚€ p₁) code-level {pβ‚€} {p₁} = Pushout-elim {P = Ξ» pβ‚€ β†’ βˆ€ p₁ β†’ is-set (code pβ‚€ p₁)} (Ξ» aβ‚€ p₁ β†’ codeAP-level {aβ‚€} {p₁}) (Ξ» bβ‚€ p₁ β†’ codeBP-level {bβ‚€} {p₁}) (Ξ» cβ‚€ β†’ prop-has-all-paths-↓ $ Ξ -is-prop Ξ» p₁ β†’ is-set-is-prop) pβ‚€ p₁ code-is-set = code-level abstract transp-cPA-glue : βˆ€ dβ‚€ {a₁} (pcAA : precodeAA (f (h dβ‚€)) a₁) β†’ transport (Ξ» pβ‚€ β†’ code pβ‚€ (left a₁)) (glue (h dβ‚€)) q[ pcAA ] == q[ pcAA-to-pcBA dβ‚€ pcAA ] transp-cPA-glue dβ‚€ {a₁} pcAA = transport (Ξ» pβ‚€ β†’ code pβ‚€ (left a₁)) (glue (h dβ‚€)) q[ pcAA ] =⟨ ap (Ξ» e β†’ coe e q[ pcAA ]) ( ap-∘ (_$ left a₁) code (glue (h dβ‚€)) βˆ™ ap (ap (_$ left a₁)) (Code.glue-Ξ² (h dβ‚€)) βˆ™ app=-Ξ² (ua ∘ cAP-equiv-cBP (h dβ‚€)) (left a₁) βˆ™ ap ua (CodeAAEquivCodeBA.eqv-Ξ² a₁ dβ‚€)) ⟩ coe (ua (CodeAAEquivCodeBA.eqv-on-image a₁ dβ‚€)) q[ pcAA ] =⟨ coe-Ξ² (CodeAAEquivCodeBA.eqv-on-image a₁ dβ‚€) q[ pcAA ] ⟩ q[ pcAA-to-pcBA dβ‚€ pcAA ] =∎ transp-cPB-glue : βˆ€ dβ‚€ {b₁} (pcAB : precodeAB (f (h dβ‚€)) b₁) β†’ transport (Ξ» pβ‚€ β†’ code pβ‚€ (right b₁)) (glue (h dβ‚€)) q[ pcAB ] == q[ pcAB-to-pcBB dβ‚€ pcAB ] transp-cPB-glue dβ‚€ {b₁} pcAB = transport (Ξ» pβ‚€ β†’ code pβ‚€ (right b₁)) (glue (h dβ‚€)) q[ pcAB ] =⟨ ap (Ξ» e β†’ coe e q[ pcAB ]) ( ap-∘ (_$ right b₁) code (glue (h dβ‚€)) βˆ™ ap (ap (_$ right b₁)) (Code.glue-Ξ² (h dβ‚€)) βˆ™ app=-Ξ² (ua ∘ cAP-equiv-cBP (h dβ‚€)) (right b₁) βˆ™ ap ua (CodeABEquivCodeBB.eqv-Ξ² b₁ dβ‚€)) ⟩ coe (ua (CodeABEquivCodeBB.eqv-on-image b₁ dβ‚€)) q[ pcAB ] =⟨ coe-Ξ² (CodeABEquivCodeBB.eqv-on-image b₁ dβ‚€) q[ pcAB ] ⟩ q[ pcAB-to-pcBB dβ‚€ pcAB ] =∎ -- code to path abstract pcAA-to-pcBA-to-path : βˆ€ dβ‚€ {a₁} (pcAA : precodeAA _ a₁) β†’ pcBA-to-path (pcAA-to-pcBA dβ‚€ pcAA) == !β‚€ [ glue (h dβ‚€) ] βˆ™β‚€' pcAA-to-path pcAA pcAB-to-pcBB-to-path : βˆ€ dβ‚€ {b₁} (pcAB : precodeAB _ b₁) β†’ pcBB-to-path (pcAB-to-pcBB dβ‚€ pcAB) == !β‚€ [ glue (h dβ‚€) ] βˆ™β‚€' pcAB-to-path pcAB pcAA-to-pcBA-to-path dβ‚€ (pc-a pA) = βˆ™β‚€'-unit-l (!β‚€ [ glue (h dβ‚€) ] βˆ™β‚€' apβ‚€ left pA) pcAA-to-pcBA-to-path dβ‚€ (pc-aba d pc pA) = ap (Ξ» p β†’ p βˆ™β‚€' !β‚€ [ glue (h d) ] βˆ™β‚€' apβ‚€ left pA) (pcAB-to-pcBB-to-path dβ‚€ pc) βˆ™ βˆ™β‚€'-assoc (!β‚€ [ glue (h dβ‚€) ]) (pcAB-to-path pc) (!β‚€ [ glue (h d) ] βˆ™β‚€' apβ‚€ left pA) pcAB-to-pcBB-to-path dβ‚€ (pc-aab d pc pB) = ap (Ξ» p β†’ p βˆ™β‚€' [ glue (h d) ] βˆ™β‚€' apβ‚€ right pB) (pcAA-to-pcBA-to-path dβ‚€ pc) βˆ™ βˆ™β‚€'-assoc (!β‚€ [ glue (h dβ‚€) ]) (pcAA-to-path pc) ([ glue (h d) ] βˆ™β‚€' apβ‚€ right pB) abstract decodeAA-is-decodeBA : βˆ€ {a₁} cβ‚€ β†’ decodeAA {f cβ‚€} {a₁} == decodeBA {g cβ‚€} {a₁} [ (Ξ» pβ‚€ β†’ code pβ‚€ (left a₁) β†’ pβ‚€ =β‚€ left a₁) ↓ glue cβ‚€ ] decodeAA-is-decodeBA {a₁ = a₁} = SurjExt.ext (Ξ» _ β†’ ↓-preserves-level $ Ξ -is-set Ξ» _ β†’ Trunc-level) h h-is-surj (Ξ» dβ‚€ β†’ ↓-β†’-from-transp $ Ξ»= $ SetQuot-elim {P = Ξ» cAA β†’ transport (_=β‚€ left a₁) (glue (h dβ‚€)) (decodeAA cAA) == decodeBA (transport (Ξ» pβ‚€ β†’ code pβ‚€ (left a₁)) (glue (h dβ‚€)) cAA)} (Ξ» _ β†’ =-preserves-set Trunc-level) (Ξ» pcAA β†’ transport (_=β‚€ left a₁) (glue (h dβ‚€)) (pcAA-to-path pcAA) =⟨ transpβ‚€-idf=β‚€cst [ glue (h dβ‚€) ] (pcAA-to-path pcAA) ⟩ !β‚€ [ glue (h dβ‚€) ] βˆ™β‚€ pcAA-to-path pcAA =⟨ βˆ™β‚€=βˆ™β‚€' [ ! (glue (h dβ‚€)) ] (pcAA-to-path pcAA) ⟩ !β‚€ [ glue (h dβ‚€) ] βˆ™β‚€' pcAA-to-path pcAA =⟨ ! $ pcAA-to-pcBA-to-path dβ‚€ pcAA ⟩ pcBA-to-path (pcAA-to-pcBA dβ‚€ pcAA) =⟨ ! $ ap (Ξ» e β†’ decodeBA (–> e q[ pcAA ])) (CodeAAEquivCodeBA.eqv-Ξ² a₁ dβ‚€) ⟩ decodeBA (–> (CodeAAEquivCodeBA.eqv a₁ (h dβ‚€)) q[ pcAA ]) =⟨ ! $ ap decodeBA (coe-Ξ² (CodeAAEquivCodeBA.eqv a₁ (h dβ‚€)) q[ pcAA ]) ⟩ decodeBA (coe (ua (CodeAAEquivCodeBA.eqv a₁ (h dβ‚€))) q[ pcAA ]) =⟨ ! $ ap (Ξ» p β†’ decodeBA (coe p q[ pcAA ])) (app=-Ξ² (ua ∘ cAP-equiv-cBP (h dβ‚€)) (left a₁)) ⟩ decodeBA (coe (app= (Ξ»= Ξ» p₁ β†’ ua (cAP-equiv-cBP (h dβ‚€) p₁)) (left a₁)) q[ pcAA ]) =⟨ ! $ ap (Ξ» p β†’ decodeBA (coe (app= p (left a₁)) q[ pcAA ])) (Code.glue-Ξ² (h dβ‚€)) ⟩ decodeBA (coe (app= (ap code (glue (h dβ‚€))) (left a₁)) q[ pcAA ]) =⟨ ap (Ξ» p β†’ decodeBA (coe p q[ pcAA ])) (∘-ap (Ξ» f₁ β†’ f₁ (left a₁)) code (glue (h dβ‚€))) ⟩ decodeBA (transport (Ξ» pβ‚€ β†’ code pβ‚€ (left a₁)) (glue (h dβ‚€)) q[ pcAA ]) =∎) (Ξ» _ β†’ prop-has-all-paths-↓ $ Trunc-level {n = 0} _ _)) (Ξ» _ _ _ β†’ prop-has-all-paths-↓ $ ↓-level $ Ξ -is-set Ξ» _ β†’ Trunc-level) abstract decodeAB-is-decodeBB : βˆ€ {b₁} cβ‚€ β†’ decodeAB {f cβ‚€} {b₁} == decodeBB {g cβ‚€} {b₁} [ (Ξ» pβ‚€ β†’ code pβ‚€ (right b₁) β†’ pβ‚€ =β‚€ right b₁) ↓ glue cβ‚€ ] decodeAB-is-decodeBB {b₁ = b₁} = SurjExt.ext (Ξ» _ β†’ ↓-preserves-level $ Ξ -is-set Ξ» _ β†’ Trunc-level) h h-is-surj (Ξ» dβ‚€ β†’ ↓-β†’-from-transp $ Ξ»= $ SetQuot-elim {P = Ξ» cAB β†’ transport (_=β‚€ right b₁) (glue (h dβ‚€)) (decodeAB cAB) == decodeBB (transport (Ξ» pβ‚€ β†’ code pβ‚€ (right b₁)) (glue (h dβ‚€)) cAB)} (Ξ» _ β†’ =-preserves-set Trunc-level) (Ξ» pcAB β†’ transport (_=β‚€ right b₁) (glue (h dβ‚€)) (pcAB-to-path pcAB) =⟨ transpβ‚€-idf=β‚€cst [ glue (h dβ‚€) ] (pcAB-to-path pcAB) ⟩ !β‚€ [ glue (h dβ‚€) ] βˆ™β‚€ pcAB-to-path pcAB =⟨ βˆ™β‚€=βˆ™β‚€' [ ! (glue (h dβ‚€)) ] (pcAB-to-path pcAB) ⟩ !β‚€ [ glue (h dβ‚€) ] βˆ™β‚€' pcAB-to-path pcAB =⟨ ! $ pcAB-to-pcBB-to-path dβ‚€ pcAB ⟩ pcBB-to-path (pcAB-to-pcBB dβ‚€ pcAB) =⟨ ! $ ap (Ξ» e β†’ decodeBB (–> e q[ pcAB ])) (CodeABEquivCodeBB.eqv-Ξ² b₁ dβ‚€) ⟩ decodeBB (–> (CodeABEquivCodeBB.eqv b₁ (h dβ‚€)) q[ pcAB ]) =⟨ ! $ ap decodeBB (coe-Ξ² (CodeABEquivCodeBB.eqv b₁ (h dβ‚€)) q[ pcAB ]) ⟩ decodeBB (coe (ua (CodeABEquivCodeBB.eqv b₁ (h dβ‚€))) q[ pcAB ]) =⟨ ! $ ap (Ξ» p β†’ decodeBB (coe p q[ pcAB ])) (app=-Ξ² (ua ∘ cAP-equiv-cBP (h dβ‚€)) (right b₁)) ⟩ decodeBB (coe (app= (Ξ»= Ξ» p₁ β†’ ua (cAP-equiv-cBP (h dβ‚€) p₁)) (right b₁)) q[ pcAB ]) =⟨ ! $ ap (Ξ» p β†’ decodeBB (coe (app= p (right b₁)) q[ pcAB ])) (Code.glue-Ξ² (h dβ‚€)) ⟩ decodeBB (coe (app= (ap code (glue (h dβ‚€))) (right b₁)) q[ pcAB ]) =⟨ ap (Ξ» p β†’ decodeBB (coe p q[ pcAB ])) (∘-ap (Ξ» f₁ β†’ f₁ (right b₁)) code (glue (h dβ‚€))) ⟩ decodeBB (transport (Ξ» pβ‚€ β†’ code pβ‚€ (right b₁)) (glue (h dβ‚€)) q[ pcAB ]) =∎) (Ξ» _ β†’ prop-has-all-paths-↓ $ Trunc-level {n = 0} _ _)) (Ξ» _ _ _ β†’ prop-has-all-paths-↓ $ ↓-level $ Ξ -is-set Ξ» _ β†’ Trunc-level) abstract decodeAP-is-decodeBP : βˆ€ cβ‚€ p₁ β†’ decodeAP {f cβ‚€} {p₁} == decodeBP {g cβ‚€} {p₁} [ (Ξ» pβ‚€ β†’ code pβ‚€ p₁ β†’ pβ‚€ =β‚€ p₁) ↓ glue cβ‚€ ] decodeAP-is-decodeBP cβ‚€ = Pushout-elim {P = Ξ» p₁ β†’ decodeAP {f cβ‚€} {p₁} == decodeBP {g cβ‚€} {p₁} [ (Ξ» pβ‚€ β†’ code pβ‚€ p₁ β†’ pβ‚€ =β‚€ p₁) ↓ glue cβ‚€ ]} (Ξ» a₁ β†’ decodeAA-is-decodeBA {a₁ = a₁} cβ‚€) (Ξ» b₁ β†’ decodeAB-is-decodeBB {b₁ = b₁} cβ‚€) (Ξ» _ β†’ prop-has-all-paths-↓ $ ↓-level $ Ξ -is-set Ξ» _ β†’ Trunc-level) decode : βˆ€ {pβ‚€ p₁} β†’ code pβ‚€ p₁ β†’ pβ‚€ =β‚€ p₁ decode {pβ‚€} {p₁} = Pushout-elim {P = Ξ» pβ‚€ β†’ code pβ‚€ p₁ β†’ pβ‚€ =β‚€ p₁} (Ξ» aβ‚€ β†’ decodeAP {aβ‚€} {p₁}) (Ξ» bβ‚€ β†’ decodeBP {bβ‚€} {p₁}) (Ξ» cβ‚€ β†’ decodeAP-is-decodeBP cβ‚€ p₁) pβ‚€
{ "alphanum_fraction": 0.5274369626, "avg_line_length": 49.7644230769, "ext": "agda", "hexsha": "bc6734a499ec29d85e08ff59ac292f7268528578", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mikeshulman/HoTT-Agda", "max_forks_repo_path": "theorems/homotopy/vankampen/Code.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mikeshulman/HoTT-Agda", "max_issues_repo_path": "theorems/homotopy/vankampen/Code.agda", "max_line_length": 107, "max_stars_count": null, "max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mikeshulman/HoTT-Agda", "max_stars_repo_path": "theorems/homotopy/vankampen/Code.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 8952, "size": 20702 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} open import Cubical.Core.Everything open import Cubical.Relation.Binary.Raw module Cubical.Relation.Binary.Reasoning.Preorder {c β„“} {A : Type c} (P : Preorder A β„“) where open Preorder P ------------------------------------------------------------------------ -- Publicly re-export the contents of the base module open import Cubical.Relation.Binary.Reasoning.Base.Single _∼_ isPreorder public
{ "alphanum_fraction": 0.6391982183, "avg_line_length": 32.0714285714, "ext": "agda", "hexsha": "e9a699340bc25b259149e9f191737c5c073e49ae", "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/Relation/Binary/Reasoning/Preorder.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/Relation/Binary/Reasoning/Preorder.agda", "max_line_length": 93, "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/Relation/Binary/Reasoning/Preorder.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 105, "size": 449 }
------------------------------------------------------------------------ -- The Agda standard library -- -- This module is DEPRECATED. Please use the -- Relation.Binary.Construct.Closure.Reflexive module directly. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.ReflexiveClosure where open import Relation.Binary.Construct.Closure.Reflexive public {-# WARNING_ON_IMPORT "Data.ReflexiveClosure was deprecated in v0.16. Use Relation.Binary.Construct.Closure.Reflexive instead." #-}
{ "alphanum_fraction": 0.5737410072, "avg_line_length": 30.8888888889, "ext": "agda", "hexsha": "43bf72b8c3f5908bfe99310c706247a93594289d", "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/ReflexiveClosure.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/ReflexiveClosure.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/ReflexiveClosure.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": 99, "size": 556 }
{-# OPTIONS --cubical --safe #-} module Cubical.Data.Prod.Properties where open import Cubical.Core.Everything open import Cubical.Data.Prod.Base open import Cubical.Data.Sigma open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence private variable β„“ β„“' : Level A : Type β„“ B : Type β„“' -- Swapping is an equivalence swap : A Γ— B β†’ B Γ— A swap (x , y) = (y , x) swap-invol : (xy : A Γ— B) β†’ swap (swap xy) ≑ xy swap-invol (_ , _) = refl isEquivSwap : (A : Type β„“) (B : Type β„“') β†’ isEquiv (Ξ» (xy : A Γ— B) β†’ swap xy) isEquivSwap A B = isoToIsEquiv (iso swap swap swap-invol swap-invol) swapEquiv : (A : Type β„“) (B : Type β„“') β†’ A Γ— B ≃ B Γ— A swapEquiv A B = (swap , isEquivSwap A B) swapEq : (A : Type β„“) (B : Type β„“') β†’ A Γ— B ≑ B Γ— A swapEq A B = ua (swapEquiv A B) private open import Cubical.Data.Nat -- As Γ— is defined as a datatype this computes as expected -- (i.e. "C-c C-n test1" reduces to (2 , 1)). If Γ— is implemented -- using Sigma this would be "transp (Ξ» i β†’ swapEq β„• β„• i) i0 (1 , 2)" test : β„• Γ— β„• test = transp (Ξ» i β†’ swapEq β„• β„• i) i0 (1 , 2) testrefl : test ≑ (2 , 1) testrefl = refl -- equivalence between the sigma-based definition and the inductive one AΓ—B≃AΓ—Ξ£B : A Γ— B ≃ A Γ—Ξ£ B AΓ—B≃AΓ—Ξ£B = isoToEquiv (iso (Ξ» { (a , b) β†’ (a , b)}) (Ξ» { (a , b) β†’ (a , b)}) (Ξ» _ β†’ refl) (Ξ» { (a , b) β†’ refl })) AΓ—B≑AΓ—Ξ£B : A Γ— B ≑ A Γ—Ξ£ B AΓ—B≑AΓ—Ξ£B = ua AΓ—B≃AΓ—Ξ£B swapΞ£Equiv : (A : Type β„“) (B : Type β„“') β†’ A Γ—Ξ£ B ≃ B Γ—Ξ£ A swapΞ£Equiv A B = compEquiv (compEquiv (invEquiv AΓ—B≃AΓ—Ξ£B) (swapEquiv A B)) AΓ—B≃AΓ—Ξ£B -- truncation for products isOfHLevelProd : (n : β„•) β†’ isOfHLevel n A β†’ isOfHLevel n B β†’ isOfHLevel n (A Γ— B) isOfHLevelProd {A = A} {B = B} n h1 h2 = let h : isOfHLevel n (A Γ—Ξ£ B) h = isOfHLevelΞ£ n h1 (Ξ» _ β†’ h2) in transport (Ξ» i β†’ isOfHLevel n (AΓ—B≑AΓ—Ξ£B {A = A} {B = B} (~ i))) h Γ—-≃ : βˆ€ {ℓ₁ β„“β‚‚ ℓ₃ β„“β‚„} {A : Type ℓ₁} {B : Type β„“β‚‚} {C : Type ℓ₃} {D : Type β„“β‚„} β†’ A ≃ C β†’ B ≃ D β†’ A Γ— B ≃ C Γ— D Γ—-≃ {A = A} {B = B} {C = C} {D = D} f g = isoToEquiv (iso Ο† ψ Ξ· Ξ΅) where Ο† : A Γ— B β†’ C Γ— D Ο† (a , b) = equivFun f a , equivFun g b ψ : C Γ— D β†’ A Γ— B ψ (c , d) = equivFun (invEquiv f) c , equivFun (invEquiv g) d Ξ· : section Ο† ψ Ξ· (c , d) i = retEq f c i , retEq g d i Ξ΅ : retract Ο† ψ Ξ΅ (a , b) i = secEq f a i , secEq g b i
{ "alphanum_fraction": 0.5636077196, "avg_line_length": 29.523255814, "ext": "agda", "hexsha": "2113997fefcd048c8de5076e6473db414d916367", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "borsiemir/cubical", "max_forks_repo_path": "Cubical/Data/Prod/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "borsiemir/cubical", "max_issues_repo_path": "Cubical/Data/Prod/Properties.agda", "max_line_length": 83, "max_stars_count": null, "max_stars_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "borsiemir/cubical", "max_stars_repo_path": "Cubical/Data/Prod/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1070, "size": 2539 }
{-# OPTIONS --cubical #-} open import Agda.Primitive.Cubical open import Agda.Builtin.Cubical.Path data S1 : Set where base : S1 loop : base ≑ base postulate weird : S1 β†’ I bad : (x : S1) β†’ I bad base = {!!} bad (loop x) = {!!}
{ "alphanum_fraction": 0.6074380165, "avg_line_length": 15.125, "ext": "agda", "hexsha": "043d9ec7d5f7c24bf6dc6294e8315bcc95a6da23", "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/Issue3314.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/Issue3314.agda", "max_line_length": 37, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue3314.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": 85, "size": 242 }
module Structure.Categorical.Multi where open import Data open import Data.Boolean open import Data.Tuple using (_β¨―_ ; _,_) open import Data.Tuple.Raiseα΅£ import Data.Tuple.Raiseα΅£.Functions as Raise open import Data.Tuple.RaiseTypeα΅£ import Data.Tuple.RaiseTypeα΅£.Functions as RaiseType open import Function.Multi open import Function.Multi.Functions open import Functional using (_β†’αΆ _) import Functional.Dependent as Fn open import Lang.Instance import Lvl open import Logic open import Logic.Predicate open import Logic.Propositional open import Numeral.Natural open import Numeral.Natural.Oper.Comparisons open import Structure.Setoid import Structure.Categorical.Names as Names import Structure.Operator.Names as Names import Structure.Relator.Names as Names open import Structure.Relator.Properties open import Syntax.Function open import Type open import Type.Properties.Singleton private variable β„“ β„“β‚’ β„“β‚˜ β„“β‚˜β‚ β„“β‚˜β‚‚ β„“β‚‘ ℓₑ₁ β„“β‚‘β‚‚ : Lvl.Level private variable Obj Obj₁ Objβ‚‚ : Type{β„“β‚’} module Morphism where module _ (_⟢_ : Obj β†’ Obj β†’ Stmt{β„“β‚˜}) ⦃ morphism-equiv : βˆ€{x y} β†’ Equiv{β„“β‚‘}(x ⟢ y) ⦄ where {- -- Examples: -- MorphismChain(3) T x y z -- = compose(1) ((x ⟢ y) ,_) (MorphismChain(2) T y) z -- = (x ⟢ y) , (MorphismChain(2) T y z) -- = (x ⟢ y) , (y ⟢ z) , T(z) -- -- MorphismChain(4) T x y z w -- = compose(2) ((x ⟢ y) ,_) (MorphismChain(3) T y) z w -- = (x ⟢ y) , (MorphismChain(3) T y z w) -- = (x ⟢ y) , (y ⟢ z) , (z ⟢ w) , T(w) MorphismChain : (n : β„•) β†’ (Obj β†’ Type{β„“β‚˜}) β†’ (RaiseType.repeat (𝐒(n)) Obj) ⇉ Types(Raise.repeat (𝐒(n)) β„“β‚˜) MorphismChain 0 T x = T(x) MorphismChain 1 T x y = (x ⟢ y) , T(y) MorphismChain (𝐒(𝐒(n))) T x y = compose(𝐒(n)) ((x ⟢ y) ,_) (MorphismChain(𝐒(n)) T y) -- Examples: -- MorphismMapping(2) x y -- = MorphismChain(2)(x ⟢_) x y -- = (x ⟢ y) β†’ (x ⟢ y) -- -- MorphismMapping(3) x y z -- = MorphismChain(3)(x ⟢_) x y z -- = (x ⟢ y) β†’ (y ⟢ z) β†’ (x ⟢ z) -- -- MorphismMapping(4) x y z w -- = MorphismChain(4)(x ⟢_) x y z w -- = (x ⟢ y) β†’ (y ⟢ z) β†’ (z ⟢ w) β†’ (x ⟢ w) MorphismMapping : (n : β„•) β†’ (RaiseType.repeat n Obj) ⇉ Type{β„“β‚˜} MorphismMapping(0) = Unit MorphismMapping(1) = {!!} MorphismMapping(𝐒(𝐒 n)) = {!!} --MorphismMapping(𝐒 n) = curry(n) {!Fs ↦ (uncurry(n) (MorphismChain(n)) Fs ⇉ (? β†’ ?))!} {- MorphismMapping(1) x = ? -- MorphismChain(1)(x ⟢_) x MorphismMapping(𝐒(𝐒(n))) x = compose(𝐒(n)) (RaiseType.reduceα΅£{𝐒(n)}{\ℓ₁ β„“β‚‚ β†’ ℓ₁ Lvl.βŠ” β„“β‚‚} _β†’αΆ _) (MorphismChain(𝐒(𝐒(n))) (x ⟢_) x) -- MorphismChain(𝐒(𝐒(n)))(x ⟢_) x-} -} MorphismFlippedChain : (n : β„•) β†’ (RaiseType.repeat (𝐒(n)) Obj) ⇉ Type{β„“β‚˜} MorphismFlippedChain 𝟎 x = x ⟢ x MorphismFlippedChain (𝐒(n)) x = Out(𝐒(n)) (x ⟢_) x where Out : (n : β„•) β†’ (Obj β†’ Type{β„“β‚˜}) β†’ (RaiseType.repeat (𝐒(n)) Obj) ⇉ Type{β„“β‚˜} Out 0 T x = T(x) Out 1 T x y = (x ⟢ y) β†’ T(y) Out (𝐒(𝐒(n))) T x y = Out(𝐒(n)) (z ↦ ((x ⟢ y) β†’ T(z))) y module _ (_βŸΆβ‚_ : Obj₁ β†’ Obj₁ β†’ Stmt{β„“β‚˜β‚}) ⦃ morphism-equiv₁ : βˆ€{x y} β†’ Equiv{ℓₑ₁}(x βŸΆβ‚ y) ⦄ (_βŸΆβ‚‚_ : Objβ‚‚ β†’ Objβ‚‚ β†’ Stmt{β„“β‚˜β‚‚}) ⦃ morphism-equivβ‚‚ : βˆ€{x y} β†’ Equiv{β„“β‚‘β‚‚}(x βŸΆβ‚‚ y) ⦄ where private open module Equivβ‚‚{x}{y} = Equiv(morphism-equivβ‚‚{x}{y}) using () renaming (_≑_ to _≑₂_) module _ {F : Obj₁ β†’ Objβ‚‚} where -- Definition of the relation between a function and an operation that says: -- The function preserves the operation. -- Often used when defining homomorphisms. -- Examples: -- Preserving(0) (map)(G₁)(Gβ‚‚) -- = βˆ€{x} β†’ (map βˆ˜β‚€ G₁ ≑ Gβ‚‚ onβ‚€ map) -- = βˆ€{x} β†’ (map(G₁) ≑ Gβ‚‚(f)) -- Preserving(1) (map)(G₁)(Gβ‚‚) -- = βˆ€{x y}{f : x ⟢ y} β†’ ((map βˆ˜β‚ G₁)(f) ≑ (Gβ‚‚ on₁ map)(f)) -- = βˆ€{x y}{f : x ⟢ y} β†’ (map(G₁(f)) ≑ Gβ‚‚(map(f))) -- Preserving(2) (map)(G₁)(Gβ‚‚) -- = βˆ€{x y z}{f₁ : y ⟢ z}{fβ‚‚ : x ⟢ y} β†’ ((map βˆ˜β‚‚ G₁)(f₁)(fβ‚‚) ≑ (Gβ‚‚ onβ‚‚ map)(f₁)(fβ‚‚)) -- = βˆ€{x y z}{f₁ : y ⟢ z}{fβ‚‚ : x ⟢ y} β†’ (map(G₁ f₁ fβ‚‚) ≑ Gβ‚‚ (map(f₁)) (map(fβ‚‚))) -- Preserving(3) (map)(G₁)(Gβ‚‚) -- = βˆ€{f₁ fβ‚‚ f₃} β†’ ((map βˆ˜β‚ƒ G₁)(f₁)(fβ‚‚)(f₃) ≑ (Gβ‚‚ on₃ map)(f₁)(fβ‚‚)(f₃)) -- = βˆ€{f₁ fβ‚‚ f₃} β†’ (map(G₁ f₁ fβ‚‚ f₃) ≑ Gβ‚‚ (map(f₁)) (map(fβ‚‚)) (map(f₃))) Preserving : (n : β„•) β†’ (map : βˆ€{x y} β†’ (x βŸΆβ‚ y) β†’ (F(x) βŸΆβ‚‚ F(y))) β†’ (quantifierβ‚Š(𝐒(n))(βˆ€β‚—) (MorphismFlippedChain(_βŸΆβ‚_)(n))) β†’ (quantifierβ‚Š(𝐒(n))(βˆ€β‚—) (MorphismFlippedChain(_βŸΆβ‚‚_)(n))) β†’ (RaiseType.repeat (𝐒(n)) Obj₁) ⇉ Stmt{if(n ≀? 0) then (β„“β‚‘β‚‚) else (β„“β‚˜β‚ Lvl.βŠ” β„“β‚‘β‚‚)} Preserving 0 map G₁ Gβ‚‚ x = (map{x}(G₁) ≑ Gβ‚‚) Preserving 1 map G₁ Gβ‚‚ x y = βˆ€{f : x βŸΆβ‚ y} β†’ map (G₁(f)) ≑ Gβ‚‚(map f) Preserving (𝐒(𝐒(n))) map G₁ Gβ‚‚ x y = {!Preserving(𝐒(n)) map ? ? y!} -- βˆ€{f} β†’ (G₁(f)) (Gβ‚‚(map f)) --Preserving 2 map G₁ Gβ‚‚ x y z = βˆ€{f₁ : y βŸΆβ‚ z}{fβ‚‚ : x βŸΆβ‚ y} β†’ (map(G₁(f₁)(fβ‚‚)) ≑ Gβ‚‚(map f₁)(map fβ‚‚)) -- Preserving (𝐒(𝐒(𝐒(n)))) map G₁ Gβ‚‚ x y z = {!βˆ€{f} β†’ Preserving(𝐒(𝐒(n))) map !} --test (P ↦ (βˆ€{f} β†’ P f)) (f ↦ Preserving (𝐒(𝐒(n))) map {!G₁!} {!Gβ‚‚!} y z) where -- test : ((P : {!!}) β†’ TYPE ({!!} Lvl.βŠ” {!!})) β†’ ((f : {!!} βŸΆβ‚ {!!}) β†’ RaiseType.repeat (𝐒 n) Obj₁ ⇉ Type) β†’ (RaiseType.repeat (𝐒 n) Obj₁ ⇉ Type) -- compose(𝐒(n)) (P ↦ (βˆ€{f} β†’ P f)) ({!f ↦ Preserving (𝐒(𝐒(n))) map {!G₁!} {!Gβ‚‚!} {!!} {!!}!}) -- compose(𝐒(n)) {!!} {!!} -- βˆ€{f : x βŸΆβ‚ y} β†’ -- Preserving(𝐒(𝐒(n))) map (\{a b} β†’ {!G₁{a}{x}{b}!}) \{a b} β†’ {!Gβ‚‚{a}{F x}{b}!} {- -- Preserving 3 map G₁ Gβ‚‚ a x y z -- = βˆ€{f : a βŸΆβ‚ x} β†’ Preserving 2 map (G₁(f)) (Gβ‚‚(map f)) x y z -- = βˆ€{f : a βŸΆβ‚ x}{f₁ : x βŸΆβ‚ y}{fβ‚‚ : y βŸΆβ‚ z} β†’ (map(G₁(f)(f₁)(fβ‚‚)) ≑ Gβ‚‚(map f)(map f₁)(map fβ‚‚)) -- βˆ€{x y}{f : x βŸΆβ‚ y} β†’ Preserving(𝐒(𝐒(n))) (map) (G₁(f)) (Gβ‚‚(map(f))) {- Preserving(𝟎) (f)(g₁)(gβ‚‚) = (f(g₁) ≑ gβ‚‚) Preserving(𝐒(𝟎)) (f)(g₁)(gβ‚‚) = (βˆ€{x} β†’ f(g₁(x)) ≑ gβ‚‚(f(x))) Preserving(𝐒(𝐒(n))) (f)(g₁)(gβ‚‚) = (βˆ€{x} β†’ Preserving(𝐒(n)) (f) (g₁(x)) (gβ‚‚(f(x)))) -- βˆ€{x y z : Objβ‚—}{f : y ⟢ z}{g : x ⟢ y} β†’ (map(f ∘ g) ≑ map(f) ∘ map(g)) -} -}
{ "alphanum_fraction": 0.5083816892, "avg_line_length": 43.3846153846, "ext": "agda", "hexsha": "a61593de71245bcfe6dc15a4bf2d398e8980224f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Structure/Categorical/Multi.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Structure/Categorical/Multi.agda", "max_line_length": 271, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Structure/Categorical/Multi.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": 2800, "size": 6204 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} import LibraBFT.Impl.Consensus.LedgerRecoveryData as LedgerRecoveryData open import LibraBFT.Impl.OBM.Logging.Logging open import LibraBFT.ImplShared.Consensus.Types open import Optics.All open import Util.Prelude ------------------------------------------------------------------------------ open import Data.String using (String) module LibraBFT.Impl.Consensus.RecoveryData where findBlocksToPrune : HashValue β†’ List Block β†’ List QuorumCert β†’ (List HashValue Γ— List Block Γ— List QuorumCert) new : Maybe Vote β†’ LedgerRecoveryData β†’ List Block β†’ RootMetadata β†’ List QuorumCert β†’ Maybe TimeoutCertificate β†’ Either ErrLog RecoveryData new lastVote storageLedger blocks0 rootMetadata quorumCerts0 highestTimeoutCertificate = do (root@(RootInfoβˆ™new rb _ _) , blocks1 , quorumCerts1) ← withErrCtx' (here' []) (LedgerRecoveryData.findRoot blocks0 quorumCerts0 storageLedger) let (blocksToPrune , blocks , quorumCerts) = findBlocksToPrune (rb ^βˆ™ bId) blocks1 quorumCerts1 epoch = rb ^βˆ™ bEpoch pure $ mkRecoveryData (case lastVote of Ξ» where (just v) β†’ if-dec v ^βˆ™ vEpoch β‰Ÿ epoch then just v else nothing nothing β†’ nothing) root rootMetadata blocks quorumCerts (just blocksToPrune) (case highestTimeoutCertificate of Ξ» where (just tc) β†’ if-dec tc ^βˆ™ tcEpoch β‰Ÿ epoch then just tc else nothing nothing β†’ nothing) where here' : List String β†’ List String here' t = "RecoveryData" ∷ "new" ∷ t -- TODO (the "TODO" is in the Haskell code) findBlocksToPrune _rootId blocks quorumCerts = ([] , blocks , quorumCerts)
{ "alphanum_fraction": 0.6781429317, "avg_line_length": 36.8653846154, "ext": "agda", "hexsha": "b5df892b9dfea36e82dbfd93e38cc0b96d669db3", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_forks_repo_path": "src/LibraBFT/Impl/Consensus/RecoveryData.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "UPL-1.0" ], "max_issues_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_issues_repo_path": "src/LibraBFT/Impl/Consensus/RecoveryData.agda", "max_line_length": 111, "max_stars_count": null, "max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_stars_repo_path": "src/LibraBFT/Impl/Consensus/RecoveryData.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 524, "size": 1917 }
{-# OPTIONS --without-K #-} module Circle where open import Agda.Prim open import Data.Product open import Function renaming (_∘_ to _β—‹_) infixr 8 _∘_ -- path composition infix 4 _≑_ -- propositional equality infix 4 _∼_ -- homotopy between two functions infix 4 _≃_ -- type of equivalences infix 2 _∎ -- equational reasoning infixr 2 _β‰‘βŸ¨_⟩_ -- equational reasoning ------------------------------------------------------------------------------ -- Identity types -- Our own version of refl that makes 'a' explicit data _≑_ {β„“} {A : Set β„“} : (a b : A) β†’ Set β„“ where refl : (a : A) β†’ (a ≑ a) pathInd : βˆ€ {u β„“} β†’ {A : Set u} β†’ (C : {x y : A} β†’ x ≑ y β†’ Set β„“) β†’ (c : (x : A) β†’ C (refl x)) β†’ ({x y : A} (p : x ≑ y) β†’ C p) pathInd C c (refl x) = c x ------------------------------------------------------------------------------ -- Ch. 2 -- Lemma 2.1.1 ! : βˆ€ {u} β†’ {A : Set u} {x y : A} β†’ (x ≑ y) β†’ (y ≑ x) ! = pathInd (Ξ» {x} {y} _ β†’ y ≑ x) refl -- Lemma 2.1.2 _∘_ : βˆ€ {u} β†’ {A : Set u} β†’ {x y z : A} β†’ (x ≑ y) β†’ (y ≑ z) β†’ (x ≑ z) _∘_ {u} {A} {x} {y} {z} p q = pathInd (Ξ» {x} {y} p β†’ ((z : A) β†’ (q : y ≑ z) β†’ (x ≑ z))) (Ξ» x z q β†’ pathInd (Ξ» {x} {z} _ β†’ x ≑ z) refl {x} {z} q) {x} {y} p z q -- Lemma 2.1.4 -- p = p . refl unitTransR : {A : Set} {x y : A} β†’ (p : x ≑ y) β†’ (p ≑ p ∘ refl y) unitTransR {A} {x} {y} p = pathInd (Ξ» {x} {y} p β†’ p ≑ p ∘ (refl y)) (Ξ» x β†’ refl (refl x)) {x} {y} p -- p = refl . p unitTransL : {A : Set} {x y : A} β†’ (p : x ≑ y) β†’ (p ≑ refl x ∘ p) unitTransL {A} {x} {y} p = pathInd (Ξ» {x} {y} p β†’ p ≑ (refl x) ∘ p) (Ξ» x β†’ refl (refl x)) {x} {y} p -- ! p . p = refl invTransL : {A : Set} {x y : A} β†’ (p : x ≑ y) β†’ (! p ∘ p ≑ refl y) invTransL {A} {x} {y} p = pathInd (Ξ» {x} {y} p β†’ ! p ∘ p ≑ refl y) (Ξ» x β†’ refl (refl x)) {x} {y} p -- p . ! p = refl invTransR : βˆ€ {β„“} {A : Set β„“} {x y : A} β†’ (p : x ≑ y) β†’ (p ∘ ! p ≑ refl x) invTransR {β„“} {A} {x} {y} p = pathInd (Ξ» {x} {y} p β†’ p ∘ ! p ≑ refl x) (Ξ» x β†’ refl (refl x)) {x} {y} p -- ! (! p) = p invId : {A : Set} {x y : A} β†’ (p : x ≑ y) β†’ (! (! p) ≑ p) invId {A} {x} {y} p = pathInd (Ξ» {x} {y} p β†’ ! (! p) ≑ p) (Ξ» x β†’ refl (refl x)) {x} {y} p -- p . (q . r) = (p . q) . r assocP : {A : Set} {x y z w : A} β†’ (p : x ≑ y) β†’ (q : y ≑ z) β†’ (r : z ≑ w) β†’ (p ∘ (q ∘ r) ≑ (p ∘ q) ∘ r) assocP {A} {x} {y} {z} {w} p q r = pathInd (Ξ» {x} {y} p β†’ (z : A) β†’ (w : A) β†’ (q : y ≑ z) β†’ (r : z ≑ w) β†’ p ∘ (q ∘ r) ≑ (p ∘ q) ∘ r) (Ξ» x z w q r β†’ pathInd (Ξ» {x} {z} q β†’ (w : A) β†’ (r : z ≑ w) β†’ (refl x) ∘ (q ∘ r) ≑ ((refl x) ∘ q) ∘ r) (Ξ» x w r β†’ pathInd (Ξ» {x} {w} r β†’ (refl x) ∘ ((refl x) ∘ r) ≑ ((refl x) ∘ (refl x)) ∘ r) (Ξ» x β†’ (refl (refl x))) {x} {w} r) {x} {z} q w r) {x} {y} p z w q r -- ! (p ∘ q) ≑ ! q ∘ ! p invComp : {A : Set} {x y z : A} β†’ (p : x ≑ y) β†’ (q : y ≑ z) β†’ ! (p ∘ q) ≑ ! q ∘ ! p invComp {A} {x} {y} {z} p q = pathInd (Ξ» {x} {y} p β†’ (z : A) β†’ (q : y ≑ z) β†’ ! (p ∘ q) ≑ ! q ∘ ! p) (Ξ» x z q β†’ pathInd (Ξ» {x} {z} q β†’ ! (refl x ∘ q) ≑ ! q ∘ ! (refl x)) (Ξ» x β†’ refl (refl x)) {x} {z} q) {x} {y} p z q -- Introduce equational reasoning syntax to simplify proofs _β‰‘βŸ¨_⟩_ : βˆ€ {u} β†’ {A : Set u} (x : A) {y z : A} β†’ (x ≑ y) β†’ (y ≑ z) β†’ (x ≑ z) _ β‰‘βŸ¨ p ⟩ q = p ∘ q bydef : βˆ€ {u} β†’ {A : Set u} {x : A} β†’ (x ≑ x) bydef {u} {A} {x} = refl x _∎ : βˆ€ {u} β†’ {A : Set u} (x : A) β†’ x ≑ x _∎ x = refl x ------------------------------------------------------------------------------ -- Functions are functors -- Lemma 2.2.1 -- computation rule: ap f (refl x) = refl (f x) ap : βˆ€ {β„“ β„“'} β†’ {A : Set β„“} {B : Set β„“'} {x y : A} β†’ (f : A β†’ B) β†’ (x ≑ y) β†’ (f x ≑ f y) ap {β„“} {β„“'} {A} {B} {x} {y} f p = pathInd (Ξ» {x} {y} p β†’ f x ≑ f y) (Ξ» x β†’ refl (f x)) {x} {y} p -- Lemma 2.2.2 -- f (p ∘ q) ≑ f p ∘ f q apfTrans : βˆ€ {u} β†’ {A B : Set u} {x y z : A} β†’ (f : A β†’ B) β†’ (p : x ≑ y) β†’ (q : y ≑ z) β†’ ap f (p ∘ q) ≑ (ap f p) ∘ (ap f q) apfTrans {u} {A} {B} {x} {y} {z} f p q = pathInd {u} (Ξ» {x} {y} p β†’ (z : A) β†’ (q : y ≑ z) β†’ ap f (p ∘ q) ≑ (ap f p) ∘ (ap f q)) (Ξ» x z q β†’ pathInd {u} (Ξ» {x} {z} q β†’ ap f (refl x ∘ q) ≑ (ap f (refl x)) ∘ (ap f q)) (Ξ» x β†’ refl (refl (f x))) {x} {z} q) {x} {y} p z q -- f (! p) ≑ ! (f p) apfInv : βˆ€ {u} β†’ {A B : Set u} {x y : A} β†’ (f : A β†’ B) β†’ (p : x ≑ y) β†’ ap f (! p) ≑ ! (ap f p) apfInv {u} {A} {B} {x} {y} f p = pathInd {u} (Ξ» {x} {y} p β†’ ap f (! p) ≑ ! (ap f p)) (Ξ» x β†’ refl (ap f (refl x))) {x} {y} p -- g (f p) ≑ (g β—‹ f) p apfComp : {A B C : Set} {x y : A} β†’ (f : A β†’ B) β†’ (g : B β†’ C) β†’ (p : x ≑ y) β†’ ap g (ap f p) ≑ ap (g β—‹ f) p apfComp {A} {B} {C} {x} {y} f g p = pathInd (Ξ» {x} {y} p β†’ ap g (ap f p) ≑ ap (g β—‹ f) p) (Ξ» x β†’ refl (ap g (ap f (refl x)))) {x} {y} p -- id p ≑ p apfId : {A : Set} {x y : A} β†’ (p : x ≑ y) β†’ ap id p ≑ p apfId {A} {x} {y} p = pathInd (Ξ» {x} {y} p β†’ ap id p ≑ p) (Ξ» x β†’ refl (refl x)) {x} {y} p -- Transport -- Lemma 2.3.1 transport : βˆ€ {β„“ β„“'} β†’ {A : Set β„“} {x y : A} β†’ (P : A β†’ Set β„“') β†’ (p : x ≑ y) β†’ P x β†’ P y transport {β„“} {β„“'} {A} {x} {y} P p = pathInd (Ξ» {x} {y} p β†’ (P x β†’ P y)) (Ξ» _ β†’ id) {x} {y} p ------------------------------------------------------------------------------- -- Homotopies and equivalences _∼_ : βˆ€ {β„“ β„“'} β†’ {A : Set β„“} {P : A β†’ Set β„“'} β†’ (f g : (x : A) β†’ P x) β†’ Set (_βŠ”_ β„“ β„“') _∼_ {β„“} {β„“'} {A} {P} f g = (x : A) β†’ f x ≑ g x -- Quasi-inverses record qinv {β„“ β„“'} {A : Set β„“} {B : Set β„“'} (f : A β†’ B) : Set (_βŠ”_ β„“ β„“') where constructor mkqinv field g : B β†’ A Ξ± : (f β—‹ g) ∼ id Ξ² : (g β—‹ f) ∼ id -- Example 2.4.7 idqinv : βˆ€ {β„“} β†’ {A : Set β„“} β†’ qinv {β„“} {β„“} {A} {A} id idqinv = record { g = id ; Ξ± = Ξ» b β†’ refl b ; Ξ² = Ξ» a β†’ refl a } -- Equivalences record isequiv {β„“ β„“'} {A : Set β„“} {B : Set β„“'} (f : A β†’ B) : Set (_βŠ”_ β„“ β„“') where constructor mkisequiv field g : B β†’ A Ξ± : (f β—‹ g) ∼ id h : B β†’ A Ξ² : (h β—‹ f) ∼ id equiv₁ : βˆ€ {β„“ β„“'} β†’ {A : Set β„“} {B : Set β„“'} {f : A β†’ B} β†’ qinv f β†’ isequiv f equiv₁ (mkqinv qg qΞ± qΞ²) = mkisequiv qg qΞ± qg qΞ² _≃_ : βˆ€ {β„“ β„“'} (A : Set β„“) (B : Set β„“') β†’ Set (_βŠ”_ β„“ β„“') A ≃ B = Ξ£ (A β†’ B) isequiv -- Lemma 2.4.12 idequiv : βˆ€ {β„“} {A : Set β„“} β†’ A ≃ A idequiv = (id , equiv₁ idqinv) ------------------------------------------------------------------------------ -- Sec. 2.10: Universes; univalence idtoeqv : {A B : Set} β†’ (A ≑ B) β†’ (A ≃ B) idtoeqv {A} {B} p = pathInd (Ξ» {A} {B} p β†’ A ≃ B) (Ξ» A β†’ idequiv) {A} {B} p postulate univalence : {A B : Set} β†’ (A ≑ B) ≃ (A ≃ B) ------------------------------------------------------------------------------ -- Sec. 2.11: Identity types -- Thm 2.11.3 transportId : {A B : Set} {y z : A} β†’ (f g : A β†’ B) β†’ (p : y ≑ z) β†’ (q : f y ≑ g y) β†’ transport (Ξ» x β†’ f x ≑ g x) p q ≑ ! (ap f p) ∘ q ∘ (ap g p) transportId {A} {B} {y} {z} f g p q = pathInd (Ξ» {y} {z} p β†’ (q : f y ≑ g y) β†’ transport (Ξ» x β†’ f x ≑ g x) p q ≑ ! (ap f p) ∘ q ∘ (ap g p)) (Ξ» y q β†’ q β‰‘βŸ¨ unitTransR q ⟩ q ∘ refl (g y) β‰‘βŸ¨ unitTransL (q ∘ refl (g y)) ⟩ refl (f y) ∘ q ∘ refl (g y) ∎) {y} {z} p q ------------------------------------------------------------------------------ -- Exercise: let's show that the following two definitions of the -- circle are "the same" {-- data SΒΉ where base : SΒΉ loop : base ≑ base data SΒΉ' where south : SΒΉ' north : SΒΉ' east : south ≑ north west : south ≑ north --} module Circle1 where private data SΒΉ* : Set where base* : SΒΉ* SΒΉ : Set SΒΉ = SΒΉ* base : SΒΉ base = base* postulate loop : base ≑ base recSΒΉ : {C : Set} β†’ (cbase : C) β†’ (cloop : cbase ≑ cbase) β†’ SΒΉ β†’ C recSΒΉ cbase cloop base* = cbase postulate Ξ²recSΒΉ : {C : Set} β†’ (cbase : C) β†’ (cloop : cbase ≑ cbase) β†’ ap (recSΒΉ cbase cloop) loop ≑ cloop indSΒΉ : {C : SΒΉ β†’ Set} β†’ (cbase : C base) β†’ (cloop : transport C loop cbase ≑ cbase) β†’ (circle : SΒΉ) β†’ C circle indSΒΉ cbase cloop base* = cbase open Circle1 public -- module Circle2 where private data SΒΉ'* : Set where south* : SΒΉ'* north* : SΒΉ'* SΒΉ' : Set SΒΉ' = SΒΉ'* south : SΒΉ' south = south* north : SΒΉ' north = north* postulate east : south ≑ north west : south ≑ north recSΒΉ' : {C : Set} β†’ (csouth cnorth : C) β†’ (ceast cwest : csouth ≑ cnorth) β†’ SΒΉ' β†’ C recSΒΉ' csouth cnorth ceast cwest south* = csouth recSΒΉ' csouth cnorth ceast cwest north* = cnorth postulate Ξ²receastSΒΉ' : {C : Set} β†’ (csouth cnorth : C) β†’ (ceast cwest : csouth ≑ cnorth) β†’ ap (recSΒΉ' csouth cnorth ceast cwest) east ≑ ceast Ξ²recwestSΒΉ' : {C : Set} β†’ (csouth cnorth : C) β†’ (ceast cwest : csouth ≑ cnorth) β†’ ap (recSΒΉ' csouth cnorth ceast cwest) west ≑ cwest indSΒΉ' : {C : SΒΉ' β†’ Set} β†’ (csouth : C south) β†’ (cnorth : C north) β†’ (ceast : transport C east csouth ≑ cnorth) β†’ (cwest : transport C west csouth ≑ cnorth) β†’ (circle : SΒΉ') β†’ C circle indSΒΉ' csouth cnorth ceast cwest south* = csouth indSΒΉ' csouth cnorth ceast cwest north* = cnorth open Circle2 public -- Maps between Circle1 and Circle2 and back -- fcircle (base) = south -- fcircle (loop) = east ∘ ! west fcircle : SΒΉ β†’ SΒΉ' fcircle = recSΒΉ south (east ∘ ! west) floop : ap fcircle loop ≑ (east ∘ ! west) floop = Ξ²recSΒΉ south (east ∘ ! west) -- gcircle (south) = base -- gcircle (north) = base -- gcircle (east) = loop -- gcircle (west) = refl base gcircle : SΒΉ' β†’ SΒΉ gcircle = recSΒΉ' base base loop (refl base) geast : ap gcircle east ≑ loop geast = Ξ²receastSΒΉ' base base loop (refl base) gwest : ap gcircle west ≑ (refl base) gwest = Ξ²recwestSΒΉ' base base loop (refl base) -- compose both ways -- gf (base) = base -- gf (loop) = loop gf : SΒΉ β†’ SΒΉ gf = gcircle β—‹ fcircle gfloop : ap gf loop ≑ loop gfloop = ap gf loop β‰‘βŸ¨ ! (apfComp fcircle gcircle loop) ⟩ ap gcircle (ap fcircle loop) β‰‘βŸ¨ ap (ap gcircle) floop ⟩ ap gcircle (east ∘ ! west) β‰‘βŸ¨ apfTrans gcircle east (! west) ⟩ ap gcircle east ∘ ap gcircle (! west) β‰‘βŸ¨ ap (Ξ» x β†’ ap gcircle east ∘ x) (apfInv gcircle west) ⟩ ap gcircle east ∘ ! (ap gcircle west) β‰‘βŸ¨ ap (Ξ» x β†’ ap gcircle east ∘ ! x) gwest ⟩ ap gcircle east ∘ (refl base) β‰‘βŸ¨ ! (unitTransR (ap gcircle east)) ⟩ ap gcircle east β‰‘βŸ¨ geast ⟩ loop ∎ Ξ±loop : transport (Ξ» x β†’ gf x ≑ x) loop (refl base) ≑ refl base Ξ±loop = transport (Ξ» x β†’ gf x ≑ x) loop (refl base) β‰‘βŸ¨ transportId gf id loop (refl base) ⟩ -- Thm 2.11.3 ! (ap gf loop) ∘ refl base ∘ ap id loop β‰‘βŸ¨ ap (Ξ» x β†’ ! (ap gf loop) ∘ refl base ∘ x) (apfId loop) ⟩ ! (ap gf loop) ∘ refl base ∘ loop β‰‘βŸ¨ ap (Ξ» x β†’ ! (ap gf loop) ∘ x) (! (unitTransL loop)) ⟩ ! (ap gf loop) ∘ loop β‰‘βŸ¨ ap (Ξ» x β†’ ! x ∘ loop) gfloop ⟩ ! loop ∘ loop β‰‘βŸ¨ invTransL loop ⟩ refl base ∎ Ξ²circle : gf ∼ id Ξ²circle = indSΒΉ {Ξ» x β†’ gf x ≑ x} (refl base) Ξ±loop -- fg (south) = south -- fg (north) = south -- fg (east) = east ∘ ! west -- fg (west) = refl south fg : SΒΉ' β†’ SΒΉ' fg = fcircle β—‹ gcircle fgeast : ap fg east ≑ east ∘ ! west fgeast = ap fg east β‰‘βŸ¨ ! (apfComp gcircle fcircle east) ⟩ ap fcircle (ap gcircle east) β‰‘βŸ¨ ap (ap fcircle) geast ⟩ ap fcircle loop β‰‘βŸ¨ floop ⟩ (east ∘ ! west) ∎ fgwest : ap fg west ≑ refl south fgwest = ap fg west β‰‘βŸ¨ ! (apfComp gcircle fcircle west) ⟩ ap fcircle (ap gcircle west) β‰‘βŸ¨ ap (ap fcircle) gwest ⟩ ap fcircle (refl base) β‰‘βŸ¨ bydef ⟩ refl south ∎ Ξ±east : transport (Ξ» x β†’ fg x ≑ x) east (refl south) ≑ west Ξ±east = transport (Ξ» x β†’ fg x ≑ x) east (refl south) β‰‘βŸ¨ transportId fg id east (refl south) ⟩ -- Thm 2.11.3 ! (ap fg east) ∘ refl south ∘ ap id east β‰‘βŸ¨ ap (Ξ» x β†’ ! (ap fg east) ∘ refl south ∘ x) (apfId east) ⟩ ! (ap fg east) ∘ refl south ∘ east β‰‘βŸ¨ ap (Ξ» x β†’ ! (ap fg east) ∘ x) (! (unitTransL east)) ⟩ ! (ap fg east) ∘ east β‰‘βŸ¨ ap (Ξ» x β†’ ! x ∘ east) fgeast ⟩ ! (east ∘ ! west) ∘ east β‰‘βŸ¨ ap (Ξ» x β†’ x ∘ east) (invComp east (! west)) ⟩ (! (! west) ∘ ! east) ∘ east β‰‘βŸ¨ ! (assocP (! (! west)) (! east) east) ⟩ ! (! west) ∘ ! east ∘ east β‰‘βŸ¨ ap (Ξ» x β†’ ! (! west) ∘ x) (invTransL east) ⟩ ! (! west) ∘ refl north β‰‘βŸ¨ ! (unitTransR (! (! west))) ⟩ ! (! west) β‰‘βŸ¨ invId west ⟩ west ∎ Ξ±west : transport (Ξ» x β†’ fg x ≑ x) west (refl south) ≑ west Ξ±west = transport (Ξ» x β†’ fg x ≑ x) west (refl south) β‰‘βŸ¨ transportId fg id west (refl south) ⟩ -- Thm 2.11.3 ! (ap fg west) ∘ refl south ∘ ap id west β‰‘βŸ¨ ap (Ξ» x β†’ ! (ap fg west) ∘ refl south ∘ x) (apfId west) ⟩ ! (ap fg west) ∘ refl south ∘ west β‰‘βŸ¨ ap (Ξ» x β†’ ! (ap fg west) ∘ x) (! (unitTransL west)) ⟩ ! (ap fg west) ∘ west β‰‘βŸ¨ ap (Ξ» x β†’ ! x ∘ west) fgwest ⟩ ! (refl south) ∘ west β‰‘βŸ¨ ! (unitTransL west) ⟩ west ∎ Ξ±circle : fg ∼ id Ξ±circle = indSΒΉ' {Ξ» x β†’ fg x ≑ x} (refl south) west Ξ±east Ξ±west -- sequiv : SΒΉ ≃ SΒΉ' sequiv = (fcircle , equiv₁ (mkqinv gcircle Ξ±circle Ξ²circle)) spath : SΒΉ ≑ SΒΉ' spath with univalence ... | (_ , eq) = isequiv.g eq sequiv ------------------------------------------------------------------------------
{ "alphanum_fraction": 0.4136978735, "avg_line_length": 27.3283018868, "ext": "agda", "hexsha": "f55b6f716648fff6d73eb9b7de0612b23a5c70ce", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "OBT/Circle.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "OBT/Circle.agda", "max_line_length": 80, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "OBT/Circle.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "num_tokens": 6050, "size": 14484 }
-- Andreas, 2015-03-17 -- Andreas, 2020-10-26 conform to Issue1428a open import Agda.Builtin.Size data βŠ₯ : Set where data SizeLt (i : Size) : Set where wrap : Size< i β†’ SizeLt i -- This definition of size predecessor should be forbidden... module _ (i : Size) where postulate pred : Size< i -- ...otherwise the injectivity test loops here. iter : βˆ€ i β†’ SizeLt i β†’ βŠ₯ iter i (wrap j) = iter j (wrap (pred j)) loop : Size β†’ βŠ₯ loop i = iter i (wrap (pred i)) absurd : βŠ₯ absurd = FIXME loop ∞ -- Testcase temporarily mutilated, original error: -- -- -Issue1428c.agda:... -- -We don't like postulated sizes in parametrized modules. -- -- +Issue1428c.agda:... -- +Not in scope: -- + FIXME at Issue1428c.agda:... -- +when scope checking FIXME
{ "alphanum_fraction": 0.6595744681, "avg_line_length": 21.4857142857, "ext": "agda", "hexsha": "8a5a573d330de89fa5ecbbc07d19daa66206ede1", "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": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "shlevy/agda", "max_forks_repo_path": "test/Fail/Issue1428c.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "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": "shlevy/agda", "max_issues_repo_path": "test/Fail/Issue1428c.agda", "max_line_length": 61, "max_stars_count": null, "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/Issue1428c.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 238, "size": 752 }
------------------------------------------------------------------------------ -- Note on the equality type class using Kettelhoit's approach ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- Adapted from Kettelhoit's thesis. module FOT.FOTC.TypeClasses.EqualityKettelhoit where open import FOTC.Base open import FOTC.Data.Bool open import FOTC.Data.Bool.Type open import FOTC.Data.Nat.Type ------------------------------------------------------------------------------ record Eq (P : D β†’ Set) : Set₁ where field equal : βˆ€ {t₁ tβ‚‚} β†’ P t₁ β†’ P tβ‚‚ β†’ Set open Eq {{...}} public boolEq : βˆ€ {b₁ bβ‚‚} β†’ Bool b₁ β†’ Bool bβ‚‚ β†’ Set boolEq btrue btrue = Bool true boolEq bfalse bfalse = Bool true {-# CATCHALL #-} boolEq _ _ = Bool false nEq : βˆ€ {m n} β†’ N m β†’ N n β†’ Set nEq nzero nzero = Bool true nEq (nsucc Nm) (nsucc Nn) = Bool true {-# CATCHALL #-} nEq _ _ = Bool false instance eqInstanceBool : Eq Bool eqInstanceBool = record { equal = boolEq } eqInstanceN : Eq N eqInstanceN = record { equal = nEq } test₁ : Set test₁ = equal nzero (nsucc nzero) testβ‚‚ : Set testβ‚‚ = equal bfalse bfalse eqN-sym : βˆ€ {m n} β†’ (Nm : N m) β†’ (Nn : N n) β†’ equal Nm Nn β†’ equal Nn Nm eqN-sym nzero nzero h = h eqN-sym nzero (nsucc Nn) h = h eqN-sym (nsucc Nm) nzero h = h eqN-sym (nsucc Nm) (nsucc Nn) h = h postulate eqN-sym' : βˆ€ {m n} β†’ (Nm : N m) β†’ (Nn : N n) β†’ equal Nm Nn β†’ equal Nn Nm -- {-# ATP prove eqN-sym' #-}
{ "alphanum_fraction": 0.5158020274, "avg_line_length": 28.4237288136, "ext": "agda", "hexsha": "6f272e8a048889a5946a103972ac223d56066c52", "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/TypeClasses/EqualityKettelhoit.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/TypeClasses/EqualityKettelhoit.agda", "max_line_length": 82, "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/TypeClasses/EqualityKettelhoit.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": 508, "size": 1677 }
-- 2014-03-05 Andreas, issue reported by James -- {-# OPTIONS -v tc.with.strip:60 -v:impossible:10 #-} data Nat : Set where zero : Nat pattern pzero = zero f : Nat β†’ Nat f pzero with pzero f pzero | pzero = pzero -- ERROR WAS: -- With clause pattern pzero is not an instance of its parent pattern -- when checking that the clause -- f pzero with pzero -- f pzero | pzero = pzero -- has type Nat β†’ Nat
{ "alphanum_fraction": 0.6789215686, "avg_line_length": 20.4, "ext": "agda", "hexsha": "e7660d87608c755c73ff48c644698eac0ef39ccd", "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/Issue1074.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/Issue1074.agda", "max_line_length": 69, "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/Issue1074.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": 126, "size": 408 }
{-# OPTIONS --without-K --safe #-} module Dodo.Binary.Functional where -- Stdlib imports open import Level using (Level; _βŠ”_) open import Relation.Binary using (Rel; REL) -- Local imports open import Dodo.Binary.Equality -- # Definitions # Functional : βˆ€ {a b ℓ₁ β„“β‚‚ : Level} {A : Set a} {B : Set b} β†’ Rel B ℓ₁ β†’ REL A B β„“β‚‚ --------------------- β†’ Set (a βŠ” b βŠ” ℓ₁ βŠ” β„“β‚‚) Functional _β‰ˆ_ r = βˆ€ x y₁ yβ‚‚ β†’ r x y₁ β†’ r x yβ‚‚ β†’ y₁ β‰ˆ yβ‚‚ -- The /explicit/ x, y₁, and yβ‚‚ are crucial. If they're implicit, Agda will attempt to -- instantiate them when absent, which often fails to resolve. Not sure why. -- # Operations # module _ {a ℓ₁ β„“β‚‚ ℓ₃ : Level} {A : Set a} {β‰ˆ : Rel A ℓ₁} {P : Rel A β„“β‚‚} {Q : Rel A ℓ₃} where functional-βŠ†β‚‚ : P βŠ†β‚‚ Q β†’ Functional β‰ˆ Q β†’ Functional β‰ˆ P functional-βŠ†β‚‚ PβŠ†Q funcQ x y₁ yβ‚‚ Pxy₁ Pxyβ‚‚ = funcQ x y₁ yβ‚‚ (βŠ†β‚‚-apply PβŠ†Q Pxy₁) (βŠ†β‚‚-apply PβŠ†Q Pxyβ‚‚)
{ "alphanum_fraction": 0.614334471, "avg_line_length": 29.3, "ext": "agda", "hexsha": "6b8d380808192152c29324c14125393b7e57cd4f", "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/Functional.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/Functional.agda", "max_line_length": 99, "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/Functional.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 346, "size": 879 }
module Data.Environment {a} {A : Set a} where open import Algebra open import Data.Nat open import Data.Empty using (βŠ₯-elim) open import Data.Pos using (ℕ⁺; suc; replicate⁺) open import Data.List as L using (List; []; _∷_; [_]; _++_; map; concatMap; replicate) open import Data.List.Any using (here; there) open import Data.List.Any.BagAndSetEquality as B using () open import Data.List.Any.Membership.Propositional public using (_∈_; _∼[_]_; bag) open import Data.Product using (Ξ£-syntax; βˆƒβ‚‚; _Γ—_; proj₁; projβ‚‚; _,_) open import Data.Sum using (_⊎_; inj₁; injβ‚‚) open import Function using (_$_; flip) open import Function.Equality using (_⟨$⟩_) open import Function.Inverse using (id; sym; _∘_) open Function.Inverse.Inverse using (to; from) open import Relation.Binary.PropositionalEquality as P using (_≑_) private module ++ = Monoid (L.monoid A) bubble : (xs {ys} : List A) {x y z : A} β†’ z ∈ xs ++ y ∷ x ∷ ys β†’ z ∈ xs ++ x ∷ y ∷ ys bubble [] (here px) = there (here px) bubble [] (there (here px)) = here px bubble [] (there (there i)) = there (there i) bubble (x ∷ xs) (here px) = here px bubble (x ∷ xs) (there i) = there (bubble xs i) -- There is a bijection between indices into the environment -- Ξ“BAΞ” and the environment Ξ“ABΞ”. This is called a 'bubble', -- because it swaps two adjacent elements, as in bubble -- sort. bbl : (xs {ys} : List A) {x y : A} β†’ xs ++ y ∷ x ∷ ys ∼[ bag ] xs ++ x ∷ y ∷ ys bbl xs {ys} {x} {y} = record { to = P.β†’-to-⟢ (bubble xs) ; from = P.β†’-to-⟢ (bubble xs) ; inverse-of = record { left-inverse-of = inv xs ; right-inverse-of = inv xs } } where inv : (xs {ys} : List A) {x y z : A} β†’ (i : z ∈ xs ++ y ∷ x ∷ ys) β†’ bubble xs (bubble xs i) ≑ i inv [] (here px) = P.refl inv [] (there (here px)) = P.refl inv [] (there (there i)) = P.refl inv (x ∷ xs) (here px) = P.refl inv (x ∷ xs) (there i) = P.cong there (inv xs i) -- There is a bijection between indices into the environment -- ΓΔAΘ and the environment Ξ“AΞ”Ξ˜. fwd : (xs ys {zs} : List A) {w : A} β†’ xs ++ ys ++ w ∷ zs ∼[ bag ] xs ++ w ∷ ys ++ zs fwd (x ∷ xs) ys = B.∷-cong P.refl (fwd xs ys) fwd [] ys = fwd' ys where fwd' : (xs {ys} : List A) {w : A} β†’ xs ++ w ∷ ys ∼[ bag ] w ∷ xs ++ ys fwd' [] = id fwd' (x ∷ xs) = bbl [] ∘ B.∷-cong P.refl (fwd' xs) bwd : (xs ys {zs} : List A) {w : A} β†’ xs ++ w ∷ ys ++ zs ∼[ bag ] xs ++ ys ++ w ∷ zs bwd xs ys = sym (fwd xs ys) -- List all possible ways to split a list xs into two lists xs₁ and xsβ‚‚. allSplit : (xs : List A) β†’ List (Ξ£[ xs₁ ∈ List A ] Ξ£[ xsβ‚‚ ∈ List A ] xs ≑ xs₁ ++ xsβ‚‚) allSplit [] = L.[ [] , [] , P.refl ] allSplit (x ∷ xs) = now ∷ later where now = ([] , x ∷ xs , P.refl) later = flip map (allSplit xs) $ Ξ»{(xs₁ , xsβ‚‚ , p) β†’ (x ∷ xs₁ , xsβ‚‚ , P.cong (x ∷_) p)} -- Test if allSplit does as advertised. {- private module _ where postulate x y z w : A test-allSplit : allSplit (x ∷ y ∷ z ∷ w ∷ []) ≑ ( ( [] , (x ∷ y ∷ z ∷ w ∷ []) , P.refl ) ∷ ( (x ∷ []) , (y ∷ z ∷ w ∷ []) , P.refl ) ∷ ( (x ∷ y ∷ []) , (z ∷ w ∷ []) , P.refl ) ∷ ( (x ∷ y ∷ z ∷ []) , (w ∷ []) , P.refl ) ∷ ( (x ∷ y ∷ z ∷ w ∷ [] ) , [] , P.refl ) ∷ [] ) test-allSplit = P.refl -} -- It is possible to list all environments Ξ” for which there -- exists a bijection between indices into the environment Ξ“ -- and the environment Ξ”. all : (xs : List A) β†’ List (Ξ£[ ys ∈ List A ] xs ∼[ bag ] ys) all [] = ([] , id) ∷ [] all (x ∷ xs) = concatMap insAll (all xs) where insAll : Ξ£[ ys ∈ List A ] xs ∼[ bag ] ys β†’ List (Ξ£[ ys ∈ List A ] x ∷ xs ∼[ bag ] ys) insAll (ys , b) = map insOne (allSplit ys) where insOne : Ξ£[ ys₁ ∈ List A ] Ξ£[ ysβ‚‚ ∈ List A ] ys ≑ ys₁ ++ ysβ‚‚ β†’ Ξ£[ zs ∈ List A ] x ∷ xs ∼[ bag ] zs insOne (ys₁ , ysβ‚‚ , p) = ys₁ ++ x ∷ ysβ‚‚ , bwd [] ys₁ {ysβ‚‚} {x} ∘ B.∷-cong P.refl (P.subst (ys ∼[ bag ]_) p id ∘ b) -- Any element which is contained in a list created using replicate -- is equal to the replicated element. ∈-replicate : {x y : A} (n : β„•) β†’ x ∈ y ∷ replicate n y β†’ x ≑ y ∈-replicate zero (here px) = px ∈-replicate zero (there ()) ∈-replicate (suc n) (here px) = px ∈-replicate (suc n) (there m) = ∈-replicate n m -- Any bag which is equivalent to the bag created using replicate, -- is equal to the bag created using replicate. all-replicate : {xs : List A} {y : A} (n : β„•) β†’ xs ∼[ bag ] replicate n y β†’ xs ≑ replicate n y all-replicate {[]} {y} zero b = P.refl all-replicate {[]} {y} (suc n) b with from b ⟨$⟩ here P.refl; ... | () all-replicate {x ∷ xs} {y} zero b with to b ⟨$⟩ here P.refl; ... | () all-replicate {x ∷ xs} {y} (suc n) b = P.congβ‚‚ _∷_ x=y (all-replicate n b') where x=y : x ≑ y x=y = ∈-replicate n (to b ⟨$⟩ here P.refl) b' : xs ∼[ bag ] replicate n y b' = B.drop-cons (P.subst (Ξ» x β†’ x ∷ xs ∼[ bag ] y ∷ replicate n y) x=y b) -- The same lemma holds for replicate⁺. all-replicate⁺ : {xs : List A} {y : A} (n : ℕ⁺) β†’ xs ∼[ bag ] replicate⁺ n y β†’ xs ≑ replicate⁺ n y all-replicate⁺ {[]} {y} (suc n) b with from b ⟨$⟩ here P.refl; ... | () all-replicate⁺ {x ∷ xs} {y} (suc n) b = P.congβ‚‚ _∷_ x=y (all-replicate n b') where x=y : x ≑ y x=y = ∈-replicate n (to b ⟨$⟩ here P.refl) b' : xs ∼[ bag ] replicate n y b' = B.drop-cons (P.subst (Ξ» x β†’ x ∷ xs ∼[ bag ] y ∷ replicate n y) x=y b) -- There is a bijection between indices into the environment -- ΓΣΔΠ and the environment ΓΔΣΠ. swpβ‚„ : (xs ys zs {ws} : List A) β†’ xs ++ zs ++ ys ++ ws ∼[ bag ] xs ++ ys ++ zs ++ ws swpβ‚„ xs [] zs = id swpβ‚„ xs (y ∷ ys) zs = ( P.substβ‚‚ _∼[ bag ]_ (++.assoc xs [ y ] _) (++.assoc xs [ y ] _) $ swpβ‚„ (xs ++ [ y ]) ys zs ) ∘ fwd xs zs -- Alias for swpβ‚„. swp = swpβ‚„ -- There is a bijection between indices into the environment -- ΓΣΔ and the environment ΓΔΣ. This is mostly a convenience -- function because of the annoyance of using ++.identity -- in the logic proofs. swp₃ : (xs ys {zs} : List A) β†’ xs ++ zs ++ ys ∼[ bag ] xs ++ ys ++ zs swp₃ xs ys {zs} = ( P.substβ‚‚ (Ξ» ys' zs' β†’ xs ++ zs ++ ys' ∼[ bag ] xs ++ ys ++ zs') (projβ‚‚ ++.identity ys) (projβ‚‚ ++.identity zs) $ swpβ‚„ xs ys zs ) -- There is a bijection between indices into the environment -- ΓΣΔ and the environment ΓΔΣ. This is mostly a convenience -- function because of the annoyance of using ++.identity -- in the logic proofs. swpβ‚‚ : (xs {ys} : List A) β†’ ys ++ xs ∼[ bag ] xs ++ ys swpβ‚‚ = swp₃ [] _-_ : (xs : List A) {x : A} (i : x ∈ xs) β†’ List A (x ∷ xs) - (here _) = xs (x ∷ xs) - (there i) = x ∷ xs - i del-[] : {x y : A} (i : y ∈ x ∷ []) β†’ (x ∷ []) - i ≑ [] del-[] (here px) = P.refl del-[] (there ()) -- Given a proof of membership x ∈ xs, we can be sure that -- there are two lists xs₁ and xsβ‚‚ s.t. -- -- (1) xs = xs₁ ++ x ∷ xsβ‚‚; and -- (2) xs - i = xs₁ ++ xsβ‚‚. -- -- That is to say, that we can break the list xs into a prefix, -- the element x, and a suffix, and that if we delete that occurrence -- of x, we are left with the prefix and the suffix. βˆˆβ†’++ : {xs : List A} {x : A} (i : x ∈ xs) β†’ βˆƒβ‚‚ Ξ» xs₁ xsβ‚‚ β†’ xs ≑ xs₁ ++ x ∷ xsβ‚‚ Γ— xs - i ≑ xs₁ ++ xsβ‚‚ βˆˆβ†’++ {x ∷ xs} (here P.refl) = ([] , xs , P.refl , P.refl) βˆˆβ†’++ {x ∷ xs} (there i) with βˆˆβ†’++ {xs} i ... | (xs₁ , xsβ‚‚ , p₁ , pβ‚‚) = (x ∷ xs₁ , xsβ‚‚ , P.cong (x ∷_) p₁ , P.cong (x ∷_) pβ‚‚) -- Given two lists which are bag-equal, we can prove that if we delete -- the same element from both lists, the resulting lists are also bag-equal. del-to : {xs ys : List A} {x : A} β†’ (eq : xs ∼[ bag ] ys) (i : x ∈ xs) β†’ xs - i ∼[ bag ] ys - (to eq ⟨$⟩ i) del-to {xs} {ys} {x} eq i with βˆˆβ†’++ {xs} i ... | (xs₁ , xsβ‚‚ , p₁ , pβ‚‚) rewrite p₁ | pβ‚‚ with βˆˆβ†’++ {ys} (to eq ⟨$⟩ i) ... | (ys₁ , ysβ‚‚ , q₁ , qβ‚‚) rewrite q₁ | qβ‚‚ = B.drop-cons (fwd [] ys₁ ∘ eq ∘ sym (fwd [] xs₁)) del-from : {xs ys : List A} {x : A} β†’ (eq : ys ∼[ bag ] xs) (i : x ∈ xs) β†’ ys - (from eq ⟨$⟩ i) ∼[ bag ] xs - i del-from {xs} {ys} {x} eq i with βˆˆβ†’++ {xs} i ... | (xs₁ , xsβ‚‚ , p₁ , pβ‚‚) rewrite p₁ | pβ‚‚ with βˆˆβ†’++ {ys} (from eq ⟨$⟩ i) ... | (ys₁ , ysβ‚‚ , q₁ , qβ‚‚) rewrite q₁ | qβ‚‚ = B.drop-cons (fwd [] xs₁ ∘ eq ∘ sym (fwd [] ys₁)) -- Split a environment based on a proof of membership (used as index). split : βˆ€ (xs {ys} : List A) {x : A} β†’ (i : x ∈ xs ++ ys) β†’ Ξ£[ j ∈ x ∈ xs ] ((xs ++ ys) - i ≑ xs - j ++ ys) ⊎ Ξ£[ j ∈ x ∈ ys ] ((xs ++ ys) - i ≑ xs ++ ys - j) split [] i = injβ‚‚ (i , P.refl) split (_ ∷ xs) (here px) = inj₁ (here px , P.refl) split (_ ∷ xs) (there i) with split xs i ... | inj₁ (j , p) = inj₁ (there j , P.cong (_ ∷_) p) ... | injβ‚‚ (j , p) = injβ‚‚ (j , P.cong (_ ∷_) p) -- -} -- -} -- -} -- -} -- -}
{ "alphanum_fraction": 0.4965318536, "avg_line_length": 37.0395256917, "ext": "agda", "hexsha": "bb9db5bcf772e19b2ad3beb98d548970faa0cef5", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-09-05T08:58:13.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-05T08:58:13.000Z", "max_forks_repo_head_hexsha": "fb5e78d6182276e4d93c4c0e0d563b6b027bc5c2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "pepijnkokke/nodcap", "max_forks_repo_path": "src/cpnd1/Data/Environment.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb5e78d6182276e4d93c4c0e0d563b6b027bc5c2", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "pepijnkokke/nodcap", "max_issues_repo_path": "src/cpnd1/Data/Environment.agda", "max_line_length": 117, "max_stars_count": 4, "max_stars_repo_head_hexsha": "fb5e78d6182276e4d93c4c0e0d563b6b027bc5c2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "wenkokke/nodcap", "max_stars_repo_path": "src/cpnd1/Data/Environment.agda", "max_stars_repo_stars_event_max_datetime": "2019-09-24T20:16:35.000Z", "max_stars_repo_stars_event_min_datetime": "2018-09-05T08:58:11.000Z", "num_tokens": 3505, "size": 9371 }
module x06-747Connectives-hc where import Relation.Binary.PropositionalEquality as Eq open Eq using (_≑_; refl) open Eq.≑-Reasoning open import Data.Nat using (β„•) open import Function using (_∘_) ------------------------------------------------------------------------------ -- BEGIN : Copied from 747Isomorphism. postulate extensionality : βˆ€ {A B : Set} {f g : A β†’ B} β†’ (βˆ€ (x : A) β†’ f x ≑ g x) ----------------------- β†’ f ≑ g infix 0 _≃_ record _≃_ (A B : Set) : Set where constructor mk-≃ -- This has been added, not in PLFA field to : A β†’ B from : B β†’ A from∘to : βˆ€ (x : A) β†’ from (to x) ≑ x to∘from : βˆ€ (y : B) β†’ to (from y) ≑ y open _≃_ infix 0 _≲_ record _≲_ (A B : Set) : Set where field to : A β†’ B from : B β†’ A from∘to : βˆ€ (x : A) β†’ from (to x) ≑ x open _≲_ record _⇔_ (A B : Set) : Set where field to : A β†’ B from : B β†’ A open _⇔_ -- You may copy over the various reasoning modules if you wish. -- END : Copied from 747Isomorphism. ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- logical AND is Cartesian product. data _Γ—_ (A : Set) (B : Set) : Set where ⟨_,_⟩ : A β†’ B ----- β†’ A Γ— B -- destructors (aka eliminators) for Γ—. proj₁ : βˆ€ {A B : Set} β†’ A Γ— B ----- β†’ A proj₁ ⟨ a , _ ⟩ = a projβ‚‚ : βˆ€ {A B : Set} β†’ A Γ— B ----- β†’ B projβ‚‚ ⟨ _ , b ⟩ = b -- equivalent construction using records record _Γ—β€²_ (A B : Set) : Set where field proj₁′ : A projβ‚‚β€² : B open _Γ—β€²_ -- eta-equivalence relates constructors and destructors Ξ·-Γ— : βˆ€ {A B : Set} (w : A Γ— B) β†’ ⟨ proj₁ w , projβ‚‚ w ⟩ ≑ w Ξ·-Γ— ⟨ a , b ⟩ = refl -- type with two members infixr 2 _Γ—_ data Bool : Set where true : Bool false : Bool -- type with three members (used in examples) data Tri : Set where aa : Tri bb : Tri cc : Tri -- Bool Γ— Tri has six members Γ—-count : Bool Γ— Tri β†’ β„• Γ—-count ⟨ true , aa ⟩ = 1 Γ—-count ⟨ true , bb ⟩ = 2 Γ—-count ⟨ true , cc ⟩ = 3 Γ—-count ⟨ false , aa ⟩ = 4 Γ—-count ⟨ false , bb ⟩ = 5 Γ—-count ⟨ false , cc ⟩ = 6 -- Cartesian product is commutative and associative up to isomorphism. swap : βˆ€ {A B : Set} β†’ A Γ— B β†’ B Γ— A swap ⟨ a , b ⟩ = ⟨ b , a ⟩ Γ—-comm : βˆ€ {A B : Set} β†’ A Γ— B ≃ B Γ— A to Γ—-comm = swap from Γ—-comm = swap from∘to Γ—-comm ⟨ _ , _ ⟩ = refl to∘from Γ—-comm ⟨ _ , _ ⟩ = refl Γ—-assoc : βˆ€ {A B C : Set} β†’ (A Γ— B) Γ— C ≃ A Γ— (B Γ— C) to Γ—-assoc ⟨ ⟨ a , b ⟩ , c ⟩ = ⟨ a , ⟨ b , c ⟩ ⟩ from Γ—-assoc ⟨ a , ⟨ b , c ⟩ ⟩ = ⟨ ⟨ a , b ⟩ , c ⟩ from∘to Γ—-assoc ⟨ ⟨ _ , _ ⟩ , _ ⟩ = refl to∘from Γ—-assoc ⟨ _ , ⟨ _ , _ ⟩ ⟩ = refl -- A ⇔ B is isomorphic to (A β†’ B) Γ— (B β†’ A) iff-iso-if-onlyif : βˆ€ {A B : Set} β†’ A ⇔ B ≃ (A β†’ B) Γ— (B β†’ A) _≃_.to iff-iso-if-onlyif record { to = to ; from = from } = ⟨ to , from ⟩ to (_≃_.from iff-iso-if-onlyif ⟨ Aβ†’B , Bβ†’A ⟩) = Aβ†’B from (_≃_.from iff-iso-if-onlyif ⟨ Aβ†’B , Bβ†’A ⟩) = Bβ†’A from∘to iff-iso-if-onlyif record { to = to ; from = from } = refl to∘from iff-iso-if-onlyif ⟨ Aβ†’B , Bβ†’A ⟩ = refl ------------------------------------------------------------------------------ -- logical True is a type with one member (unit) data ⊀ : Set where tt : -- ⊀ Ξ·-⊀ : βˆ€ (w : ⊀) β†’ tt ≑ w Ξ·-⊀ tt = refl ⊀-count : ⊀ β†’ β„• ⊀-count tt = 1 -- Unit is the left and right identity of product. ⊀-identityΛ‘ : βˆ€ {A : Set} β†’ ⊀ Γ— A ≃ A to ⊀-identityΛ‘ ⟨ ⊀ , a ⟩ = a from ⊀-identityΛ‘ a = ⟨ tt , a ⟩ from∘to ⊀-identityΛ‘ ⟨ tt , a ⟩ = refl to∘from ⊀-identityΛ‘ a = refl ⊀-identityΚ³ : βˆ€ {A : Set} β†’ (A Γ— ⊀) ≃ A to ⊀-identityΚ³ ⟨ a , ⊀ ⟩ = a from ⊀-identityΚ³ a = ⟨ a , tt ⟩ from∘to ⊀-identityΚ³ ⟨ a , tt ⟩ = refl to∘from ⊀-identityΚ³ a = refl ------------------------------------------------------------------------------ -- logical OR (disjunction) is sum (disjoint union) data _⊎_ : Set β†’ Set β†’ Set where inj₁ : βˆ€ {A B : Set} β†’ A ----- β†’ A ⊎ B injβ‚‚ : βˆ€ {A B : Set} β†’ B ----- β†’ A ⊎ B -- a way to eliminate a sum (but easier to use pattern-matching to eliminate sums) case-⊎ : βˆ€ {A B C : Set} β†’ (A β†’ C) β†’ (B β†’ C) β†’ A ⊎ B ----------- β†’ C case-⊎ f g (inj₁ x) = f x case-⊎ f g (injβ‚‚ x) = g x -- eta equivalence for sums Ξ·-⊎ : βˆ€ {A B : Set} (w : A ⊎ B) β†’ case-⊎ inj₁ injβ‚‚ w ≑ w Ξ·-⊎ (inj₁ _) = refl Ξ·-⊎ (injβ‚‚ _) = refl -- generalization uniq-⊎ : βˆ€ {A B C : Set} β†’ (h : A ⊎ B β†’ C) β†’ (w : A ⊎ B) β†’ case-⊎ (h ∘ inj₁) (h ∘ injβ‚‚) w ≑ h w uniq-⊎ h (inj₁ _) = refl uniq-⊎ h (injβ‚‚ _) = refl infix 1 _⊎_ -- Bool ⊎ Tri has five members ⊎-count : Bool ⊎ Tri β†’ β„• ⊎-count (inj₁ true) = 1 ⊎-count (inj₁ false) = 2 ⊎-count (injβ‚‚ aa) = 3 ⊎-count (injβ‚‚ bb) = 4 ⊎-count (injβ‚‚ cc) = 5 -- Sum is commutative up to isomorphism. ⊎-comm : βˆ€ {A B : Set} β†’ A ⊎ B ≃ B ⊎ A to ⊎-comm (inj₁ a) = injβ‚‚ a to ⊎-comm (injβ‚‚ b) = inj₁ b from ⊎-comm (inj₁ b) = injβ‚‚ b from ⊎-comm (injβ‚‚ a) = inj₁ a from∘to ⊎-comm (inj₁ _) = refl from∘to ⊎-comm (injβ‚‚ _) = refl to∘from ⊎-comm (inj₁ _) = refl to∘from ⊎-comm (injβ‚‚ _) = refl -- Sum is associative up to isomorphism. ⊎-assoc : βˆ€ {A B C : Set} β†’ (A ⊎ B) ⊎ C ≃ A ⊎ (B ⊎ C) to ⊎-assoc (inj₁ (inj₁ a)) = inj₁ a to ⊎-assoc (inj₁ (injβ‚‚ b)) = injβ‚‚ (inj₁ b) to ⊎-assoc (injβ‚‚ c) = injβ‚‚ (injβ‚‚ c) from ⊎-assoc (inj₁ a) = inj₁ (inj₁ a) from ⊎-assoc (injβ‚‚ (inj₁ b)) = inj₁ (injβ‚‚ b) from ⊎-assoc (injβ‚‚ (injβ‚‚ c)) = injβ‚‚ c from∘to ⊎-assoc (inj₁ (inj₁ _)) = refl from∘to ⊎-assoc (inj₁ (injβ‚‚ _)) = refl from∘to ⊎-assoc (injβ‚‚ _) = refl to∘from ⊎-assoc (inj₁ _) = refl to∘from ⊎-assoc (injβ‚‚ (inj₁ _)) = refl to∘from ⊎-assoc (injβ‚‚ (injβ‚‚ _)) = refl ------------------------------------------------------------------------------ -- logical False is the empty type ("bottom", "empty") data βŠ₯ : Set where -- no clauses -- Ex falso quodlibet "from falsehood, anything follows". βŠ₯-elim : βˆ€ {A : Set} β†’ βŠ₯ -- β†’ A βŠ₯-elim () uniq-βŠ₯ : βˆ€ {C : Set} β†’ (h : βŠ₯ β†’ C) β†’ (w : βŠ₯) β†’ βŠ₯-elim w ≑ h w uniq-βŠ₯ h () βŠ₯-count : βŠ₯ β†’ β„• βŠ₯-count () -- Empty is the left unit of sum up to isomorphism. ⊎-identityΛ‘ : βˆ€ {A : Set} β†’ βŠ₯ ⊎ A ≃ A to ⊎-identityΛ‘ (injβ‚‚ a) = a from ⊎-identityΛ‘ a = injβ‚‚ a from∘to ⊎-identityΛ‘ (injβ‚‚ _) = refl to∘from ⊎-identityΛ‘ _ = refl -- Empty is the right unit of sum up to isomorphism. ⊎-identityΚ³ : βˆ€ {A : Set} β†’ A ⊎ βŠ₯ ≃ A to ⊎-identityΚ³ (inj₁ a) = a from ⊎-identityΚ³ a = inj₁ a from∘to ⊎-identityΚ³ (inj₁ _) = refl to∘from ⊎-identityΚ³ _ = refl ------------------------------------------------------------------------------ -- logical implication (if-then) is the function TYPE constructor. -- Eliminating an if-then (modus ponens) is function application. β†’-elim : βˆ€ {A B : Set} β†’ (A β†’ B) β†’ A ------- β†’ B β†’-elim L M = L M -- β†’-elim works because eta-reduction for β†’ is built in Ξ·-β†’ : βˆ€ {A B : Set} β†’ (f : A β†’ B) β†’ (Ξ» (x : A) β†’ f x) ≑ f Ξ·-β†’ f = refl -- The function space A β†’ B is called the exponential Bᴬ. -- Bool β†’ Tri has 3Β² (9) members. β†’-count : (Bool β†’ Tri) β†’ β„• β†’-count f with f true | f false ... | aa | aa = 1 ... | aa | bb = 2 ... | aa | cc = 3 ... | bb | aa = 4 ... | bb | bb = 5 ... | bb | cc = 6 ... | cc | aa = 7 ... | cc | bb = 8 ... | cc | cc = 9 ------------------------------------------------------------------------------ -- "currying" : functions of multiple parameters -- math : (p ^ n) ^ m = p ^ (n * m) -- types : (A ^ B) ^ C ≃ A ^ (B Γ— C) currying : βˆ€ {A B C : Set} β†’ (A β†’ B β†’ C) ≃ (A Γ— B β†’ C) to currying f = Ξ» { ⟨ a , b ⟩ β†’ f a b } from currying f = Ξ» a b β†’ f ⟨ a , b ⟩ from∘to currying _ = refl to∘from currying f = extensionality Ξ» { ⟨ x , y ⟩ β†’ refl } -- math, : p ^ (n + m) = (p ^ n) * (p ^ m) -- types : (A ⊎ B β†’ C) ≃ ((A β†’ C) Γ— (B β†’ C)) β†’-distrib-⊎ : βˆ€ {A B C : Set} β†’ (A ⊎ B β†’ C) ≃ ((A β†’ C) Γ— (B β†’ C)) to β†’-distrib-⊎ f = ⟨ (Ξ» a β†’ f (inj₁ a)) , (Ξ» b β†’ f (injβ‚‚ b)) ⟩ from β†’-distrib-⊎ ⟨ Aβ†’C , Bβ†’C ⟩ = Ξ» { (inj₁ a) β†’ Aβ†’C a ; (injβ‚‚ b) β†’ Bβ†’C b } from∘to β†’-distrib-⊎ _ = extensionality Ξ» { (inj₁ x) β†’ refl ; (injβ‚‚ x) β†’ refl } to∘from β†’-distrib-⊎ = Ξ»{ ⟨ g , h ⟩ β†’ refl } -- math : (p * n) ^ m = (p ^ m) * (n ^ m) -- types : (A β†’ B Γ— C) ≃ (A β†’ B) Γ— (A β†’ C) β†’-distrib-Γ— : βˆ€ {A B C : Set} β†’ (A β†’ B Γ— C) ≃ (A β†’ B) Γ— (A β†’ C) to β†’-distrib-Γ— f = ⟨ (Ξ» a β†’ proj₁ (f a)) , (Ξ» a β†’ projβ‚‚ (f a)) ⟩ from β†’-distrib-Γ— f = Ξ» a β†’ ⟨ proj₁ f a , projβ‚‚ f a ⟩ from∘to β†’-distrib-Γ— = Ξ» aβ†’bΓ—c β†’ extensionality Ξ» a β†’ Ξ·-Γ— (aβ†’bΓ—c a) to∘from β†’-distrib-Γ— = Ξ» { ⟨ _ , _ ⟩ β†’ refl } Γ—-distrib-⊎ : βˆ€ {A B C : Set} β†’ (A ⊎ B) Γ— C ≃ (A Γ— C) ⊎ (B Γ— C) to Γ—-distrib-⊎ ⟨ inj₁ a , c ⟩ = inj₁ ⟨ a , c ⟩ to Γ—-distrib-⊎ ⟨ injβ‚‚ b , c ⟩ = injβ‚‚ ⟨ b , c ⟩ from Γ—-distrib-⊎ (inj₁ ⟨ a , c ⟩) = ⟨ inj₁ a , c ⟩ from Γ—-distrib-⊎ (injβ‚‚ ⟨ b , c ⟩) = ⟨ injβ‚‚ b , c ⟩ from∘to Γ—-distrib-⊎ = Ξ» { ⟨ inj₁ a , c ⟩ β†’ refl ; ⟨ injβ‚‚ b , c ⟩ β†’ refl } to∘from Γ—-distrib-⊎ = Ξ» { ( inj₁ ⟨ a , c ⟩) β†’ refl ; ( injβ‚‚ ⟨ b , c ⟩) β†’ refl } -- Think of a counterexample to show this is not an isomorphism. TODO ⊎-distrib-Γ— : βˆ€ {A B C : Set} β†’ (A Γ— B) ⊎ C ≲ (A ⊎ C) Γ— (B ⊎ C) to ⊎-distrib-Γ— (inj₁ ⟨ a , b ⟩) = ⟨ inj₁ a , inj₁ b ⟩ to ⊎-distrib-Γ— (injβ‚‚ c) = ⟨ injβ‚‚ c , injβ‚‚ c ⟩ from ⊎-distrib-Γ— ⟨ inj₁ a , inj₁ b ⟩ = inj₁ ⟨ a , b ⟩ from ⊎-distrib-Γ— ⟨ inj₁ a , injβ‚‚ c ⟩ = injβ‚‚ c from ⊎-distrib-Γ— ⟨ injβ‚‚ c , inj₁ b ⟩ = injβ‚‚ c from ⊎-distrib-Γ— ⟨ injβ‚‚ c , injβ‚‚ C ⟩ = injβ‚‚ c -- injβ‚‚ C also valid (loses info) from∘to ⊎-distrib-Γ— = Ξ» { (inj₁ ⟨ a , b ⟩) β†’ refl ; (injβ‚‚ c) β†’ refl } Γ—-distrib-β†’ : βˆ€ {A B C : Set} β†’ (C β†’ (A Γ— B)) ≃ (C β†’ A) Γ— (C β†’ B) to Γ—-distrib-β†’ f = ⟨ (Ξ» c β†’ proj₁ (f c)) , (Ξ» c β†’ projβ‚‚ (f c)) ⟩ from Γ—-distrib-β†’ f = Ξ» c β†’ ⟨ proj₁ f c , projβ‚‚ f c ⟩ from∘to Γ—-distrib-β†’ = Ξ» { cβ†’aΓ—b β†’ extensionality Ξ» c β†’ Ξ·-Γ— (cβ†’aΓ—b c) } to∘from Γ—-distrib-β†’ = Ξ» { ⟨ cβ†’a , cβ†’b ⟩ β†’ refl } ⊎-distrib-β†’ : βˆ€ {A B C : Set} β†’ ((A ⊎ B) β†’ C) ≃ (A β†’ C) Γ— (B β†’ C) to ⊎-distrib-β†’ f = ⟨ (Ξ» a β†’ f (inj₁ a)) , (Ξ» b β†’ f (injβ‚‚ b)) ⟩ from ⊎-distrib-β†’ f = Ξ» { (inj₁ a) β†’ (proj₁ f a) ; (injβ‚‚ b) β†’ (projβ‚‚ f b) } --from∘to ⊎-distrib-β†’ f = extensionality Ξ» a⊎b β†’ {!!} -- TODO from∘to ⊎-distrib-β†’ = Ξ» { a⊎bβ†’c β†’ extensionality Ξ» { (inj₁ a) β†’ refl ; (injβ‚‚ b) β†’ refl } } to∘from ⊎-distrib-β†’ = Ξ» { ⟨ aβ†’c , bβ†’c ⟩ β†’ refl } -- PLFA exercise: a weak distributive law. ⊎-weak-Γ— : βˆ€ {A B C : Set} β†’ (A ⊎ B) Γ— C β†’ A ⊎ (B Γ— C) ⊎-weak-Γ— ⟨ inj₁ a , c ⟩ = inj₁ a ⊎-weak-Γ— ⟨ injβ‚‚ b , c ⟩ = injβ‚‚ ⟨ b , c ⟩ -- State and prove the strong law, and explain the relationship. TODO -- SumOfProdImpProdOfSum : disjunct of conjuncts implies a conjunct of disjuncts. βŠŽΓ—-implies-Γ—βŠŽ : βˆ€ {A B C D : Set} β†’ (A Γ— B) ⊎ (C Γ— D) β†’ (A ⊎ C) Γ— (B ⊎ D) βŠŽΓ—-implies-Γ—βŠŽ (inj₁ ⟨ a , b ⟩) = ⟨ inj₁ a , inj₁ b ⟩ βŠŽΓ—-implies-Γ—βŠŽ (injβ‚‚ ⟨ c , d ⟩) = ⟨ injβ‚‚ c , injβ‚‚ d ⟩ -- the converse is NOT true Γ—βŠŽ-implies-βŠŽΓ—-not : βˆ€ {A B C D : Set} β†’ (A ⊎ C) Γ— (B ⊎ D) β†’ (A Γ— B) ⊎ (C Γ— D) Γ—βŠŽ-implies-βŠŽΓ—-not ⟨ inj₁ a , inj₁ b ⟩ = inj₁ ⟨ a , b ⟩ Γ—βŠŽ-implies-βŠŽΓ—-not ⟨ inj₁ a , injβ‚‚ d ⟩ = {!!} -- A Γ— B ⊎ C Γ— D -- not possible Γ—βŠŽ-implies-βŠŽΓ—-not ⟨ injβ‚‚ c , inj₁ b ⟩ = {!!} -- A Γ— B ⊎ C Γ— D -- not possible Γ—βŠŽ-implies-βŠŽΓ—-not ⟨ injβ‚‚ c , injβ‚‚ d ⟩ = injβ‚‚ ⟨ c , d ⟩
{ "alphanum_fraction": 0.4417214585, "avg_line_length": 30.6570680628, "ext": "agda", "hexsha": "5624a26ee44325d39cc1f4b33584b39fbc52a9ea", "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/x06-747Connectives-hc.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/x06-747Connectives-hc.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/x06-747Connectives-hc.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": 5018, "size": 11711 }
module PLDI14-List-of-Theorems where -- List of theorems in PLDI submission -- -- For hints about installation and execution, please refer -- to README.agda. -- -- Agda modules corresponding to definitions, lemmas and theorems -- are listed here with the most important names. For example, -- after this file type checks (C-C C-L), placing the cursor -- on the purple "Base.Change.Algebra" and pressing M-. will -- bring you to the file where change structures are defined. -- The name for change structures in that file is -- "ChangeAlgebra", given in the using-clause. -- Definition 2.1 (Change structures) open import Base.Change.Algebra using (ChangeAlgebra) ---- Carrier in record ChangeAlgebra --(a) open Base.Change.Algebra.ChangeAlgebra using (Change) --(b) open Base.Change.Algebra.ChangeAlgebra using (update) --(c) open Base.Change.Algebra.ChangeAlgebra using (diff) --(d) open Base.Change.Algebra.IsChangeAlgebra using (update-diff)--(e) -- Definition 2.2 (Nil change) -- IsChangeAlgebra.nil open Base.Change.Algebra using (IsChangeAlgebra) -- Lemma 2.3 (Behavior of nil) -- IsChangeAlgebra.update-nil open Base.Change.Algebra using (IsChangeAlgebra) -- Lemma 2.5 (Behavior of derivatives on nil) open import Base.Change.Equivalence using (deriv-zero) -- Definition 2.4 (Derivatives) open Base.Change.Algebra using (IsDerivative) -- Definition 2.6 (Carrier set of function changes) open Base.Change.Algebra.FunctionChanges -- Definition 2.7 (Operations on function changes) -- ChangeAlgebra.update FunctionChanges.changeAlgebra -- ChangeAlgebra.diff FunctionChanges.changeAlgebra open Base.Change.Algebra.FunctionChanges using (changeAlgebraFun) -- Theorem 2.8 (Function changes form a change structure) -- (In Agda, the proof of Theorem 2.8 has to be included in the -- definition of function changes, here -- FunctionChanges.changeAlgebra.) open Base.Change.Algebra.FunctionChanges using (changeAlgebraFun) -- Theorem 2.9 (Incrementalization) open Base.Change.Algebra.FunctionChanges using (incrementalization) -- Theorem 2.10 (Nil changes are derivatives) open Base.Change.Algebra.FunctionChanges using (nil-is-derivative) -- Definition 3.1 (Domains) import Parametric.Denotation.Value open Parametric.Denotation.Value.Structure using (⟦_⟧Type) -- Definition 3.2 (Environments) open import Base.Denotation.Environment using (⟦_⟧Context) -- Definition 3.3 (Evaluation) import Parametric.Denotation.Evaluation open Parametric.Denotation.Evaluation.Structure using (⟦_⟧Term) -- Definition 3.4 (Changes) -- Definition 3.5 (Change environments) import Parametric.Change.Validity open Parametric.Change.Validity.Structure using (change-algebra) open Parametric.Change.Validity.Structure using (environment-changes) -- Definition 3.6 (Change semantics) -- Lemma 3.7 (Change semantics is the derivative of semantics) import Parametric.Change.Specification open Parametric.Change.Specification.Structure using (⟦_βŸ§Ξ”) open Parametric.Change.Specification.Structure using (correctness) -- Definition 3.8 (Erasure) -- Lemma 3.9 (The erased version of a change is almost the same) import Parametric.Change.Implementation open Parametric.Change.Implementation.Structure using (_β‰ˆ_) open Parametric.Change.Implementation.Structure using (carry-over) -- Lemma 3.10 (⟦ t βŸ§Ξ” erases to Derive(t)) -- Theorem 3.11 (Correctness of differentiation) import Parametric.Change.Correctness open Parametric.Change.Correctness.Structure using (derive-correct-closed) open Parametric.Change.Correctness.Structure using (main-theorem)
{ "alphanum_fraction": 0.7772816076, "avg_line_length": 38.9456521739, "ext": "agda", "hexsha": "d9379e6c42fa7ae97d0409b0d3fcc919976cba17", "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": "PLDI14-List-of-Theorems.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": "PLDI14-List-of-Theorems.agda", "max_line_length": 74, "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": "PLDI14-List-of-Theorems.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": 890, "size": 3583 }
open import Data.Product using ( proj₁ ; projβ‚‚ ) open import Data.Sum using ( inj₁ ; injβ‚‚ ) open import Relation.Binary.PropositionalEquality using ( _≑_ ; refl ; sym ; cong ) open import Relation.Unary using ( _βŠ†_ ) open import Web.Semantic.DL.ABox using ( ABox ; ⟨ABox⟩ ; Assertions ) open import Web.Semantic.DL.ABox.Interp using ( ⌊_βŒ‹ ; ind ) open import Web.Semantic.DL.ABox.Model using ( _⊨a_ ; bnodes ; _,_ ) open import Web.Semantic.DL.Category.Object using ( Object ; IN ; fin ; iface ) open import Web.Semantic.DL.Category.Morphism using ( impl ; _≣_ ; _βŠ‘_ ; _,_ ) open import Web.Semantic.DL.Category.Tensor using ( _βŠ—_ ; _βŸ¨βŠ—βŸ©_ ) open import Web.Semantic.DL.Category.Properties.Tensor.Lemmas using ( tensor-up ; tensor-down ; tensor-resp-⊨a ) open import Web.Semantic.DL.Category.Wiring using ( wiring ; wires-β‰ˆ ; wires-β‰ˆβ»ΒΉ ; identity ; idβœ“ ) open import Web.Semantic.DL.Signature using ( Signature ) open import Web.Semantic.DL.TBox using ( TBox ) open import Web.Semantic.DL.TBox.Interp using ( Ξ” ; _⊨_β‰ˆ_ ; β‰ˆ-refl ; β‰ˆ-reflβ€² ; β‰ˆ-trans ) open import Web.Semantic.Util using ( id ; _∘_ ; False ; elim ; inj⁻¹ ; _βŠ•_βŠ•_ ; inode ; bnode ; enode ) module Web.Semantic.DL.Category.Properties.Tensor.RespectsWiring {Ξ£ : Signature} {S T : TBox Ξ£} where tensor-resp-wiring : βˆ€ (A₁ Aβ‚‚ B₁ Bβ‚‚ : Object S T) β†’ (f₁ : IN B₁ β†’ IN A₁) β†’ (fβ‚βœ“ : Assertions (⟨ABox⟩ f₁ (iface B₁)) βŠ† Assertions (iface A₁)) β†’ (fβ‚‚ : IN Bβ‚‚ β†’ IN Aβ‚‚) β†’ (fβ‚‚βœ“ : Assertions (⟨ABox⟩ fβ‚‚ (iface Bβ‚‚)) βŠ† Assertions (iface Aβ‚‚)) β†’ (g : IN (B₁ βŠ— Bβ‚‚) β†’ IN (A₁ βŠ— Aβ‚‚)) β†’ (gβœ“ : Assertions (⟨ABox⟩ g (iface (B₁ βŠ— Bβ‚‚))) βŠ† Assertions (iface (A₁ βŠ— Aβ‚‚))) β†’ (βˆ€ x β†’ inj₁ (f₁ x) ≑ g (inj₁ x)) β†’ (βˆ€ x β†’ injβ‚‚ (fβ‚‚ x) ≑ g (injβ‚‚ x)) β†’ ((wiring A₁ B₁ f₁ fβ‚βœ“ βŸ¨βŠ—βŸ© wiring Aβ‚‚ Bβ‚‚ fβ‚‚ fβ‚‚βœ“) ≣ (wiring (A₁ βŠ— Aβ‚‚) (B₁ βŠ— Bβ‚‚) g gβœ“)) tensor-resp-wiring A₁ Aβ‚‚ B₁ Bβ‚‚ f₁ fβ‚βœ“ fβ‚‚ fβ‚‚βœ“ g gβœ“ f₁≑g₁ f₂≑gβ‚‚ = (LHSβŠ‘RHS , RHSβŠ‘LHS) where LHSβŠ‘RHS : wiring A₁ B₁ f₁ fβ‚βœ“ βŸ¨βŠ—βŸ© wiring Aβ‚‚ Bβ‚‚ fβ‚‚ fβ‚‚βœ“ βŠ‘ wiring (A₁ βŠ— Aβ‚‚) (B₁ βŠ— Bβ‚‚) g gβœ“ LHSβŠ‘RHS I I⊨STA I⊨F = (elim , I⊨RHS) where lemma : βˆ€ x β†’ ⌊ I βŒ‹ ⊨ ind I (inode (g x)) β‰ˆ ind I (enode x) lemma (inj₁ x) = β‰ˆ-trans ⌊ I βŒ‹ (β‰ˆ-reflβ€² ⌊ I βŒ‹ (cong (ind I ∘ inode) (sym (f₁≑g₁ x)))) (wires-β‰ˆ f₁ (projβ‚‚ (fin B₁) x) (tensor-up (wiring A₁ B₁ f₁ fβ‚βœ“) (wiring Aβ‚‚ Bβ‚‚ fβ‚‚ fβ‚‚βœ“) I I⊨F)) lemma (injβ‚‚ x) = β‰ˆ-trans ⌊ I βŒ‹ (β‰ˆ-reflβ€² ⌊ I βŒ‹ (cong (ind I ∘ inode) (sym (f₂≑gβ‚‚ x)))) (wires-β‰ˆ fβ‚‚ (projβ‚‚ (fin Bβ‚‚) x) (tensor-down (wiring A₁ B₁ f₁ fβ‚βœ“) (wiring Aβ‚‚ Bβ‚‚ fβ‚‚ fβ‚‚βœ“) I I⊨F)) I⊨RHS : bnodes I elim ⊨a impl (wiring (A₁ βŠ— Aβ‚‚) (B₁ βŠ— Bβ‚‚) g gβœ“) I⊨RHS = wires-β‰ˆβ»ΒΉ g lemma (proj₁ (fin (B₁ βŠ— Bβ‚‚))) RHSβŠ‘LHS : wiring (A₁ βŠ— Aβ‚‚) (B₁ βŠ— Bβ‚‚) g gβœ“ βŠ‘ wiring A₁ B₁ f₁ fβ‚βœ“ βŸ¨βŠ—βŸ© wiring Aβ‚‚ Bβ‚‚ fβ‚‚ fβ‚‚βœ“ RHSβŠ‘LHS I I⊨STA I⊨F = (elim ∘ inj⁻¹ , I⊨LHS) where lemma₁ : βˆ€ x β†’ ⌊ I βŒ‹ ⊨ ind I (inode (inj₁ (f₁ x))) β‰ˆ ind I (enode (inj₁ x)) lemma₁ x = β‰ˆ-trans ⌊ I βŒ‹ (β‰ˆ-reflβ€² ⌊ I βŒ‹ (cong (ind I ∘ inode) (f₁≑g₁ x))) (wires-β‰ˆ g (projβ‚‚ (fin (B₁ βŠ— Bβ‚‚)) (inj₁ x)) I⊨F) lemmaβ‚‚ : βˆ€ x β†’ ⌊ I βŒ‹ ⊨ ind I (inode (injβ‚‚ (fβ‚‚ x))) β‰ˆ ind I (enode (injβ‚‚ x)) lemmaβ‚‚ x = β‰ˆ-trans ⌊ I βŒ‹ (β‰ˆ-reflβ€² ⌊ I βŒ‹ (cong (ind I ∘ inode) (f₂≑gβ‚‚ x))) (wires-β‰ˆ g (projβ‚‚ (fin (B₁ βŠ— Bβ‚‚)) (injβ‚‚ x)) I⊨F) I⊨LHS : bnodes I (elim ∘ inj⁻¹) ⊨a impl (wiring A₁ B₁ f₁ fβ‚βœ“ βŸ¨βŠ—βŸ© wiring Aβ‚‚ Bβ‚‚ fβ‚‚ fβ‚‚βœ“) I⊨LHS = tensor-resp-⊨a (wiring A₁ B₁ f₁ fβ‚βœ“) (wiring Aβ‚‚ Bβ‚‚ fβ‚‚ fβ‚‚βœ“) (bnodes I (elim ∘ inj⁻¹)) (wires-β‰ˆβ»ΒΉ f₁ lemma₁ (proj₁ (fin B₁))) (wires-β‰ˆβ»ΒΉ fβ‚‚ lemmaβ‚‚ (proj₁ (fin Bβ‚‚)))
{ "alphanum_fraction": 0.5715093273, "avg_line_length": 46.5526315789, "ext": "agda", "hexsha": "b04bc840873ec9bc65772a38243d9aff2dd3b8b4", "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/Category/Properties/Tensor/RespectsWiring.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/Category/Properties/Tensor/RespectsWiring.agda", "max_line_length": 97, "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/Category/Properties/Tensor/RespectsWiring.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": 1716, "size": 3538 }
module ParserC where {- import Prelude import Equiv import Eq import Datoid import List import Bag open Prelude open Equiv open Eq open Datoid open List open Bag parserDatoid : (a, s : Datoid) -> Datoid parserDatoid a s = Bag (pairDatoid a (listDatoid s)) -- We use the following datatype instead of -- type Parsing s a = [s] -> Bag (a, [s]) data Parsing (s, a : Datoid) : Set1 where P : (List (El s) -> El (parserDatoid a s)) -> Parsing s a private unP : {s, a : Datoid} -> Parsing s a -> List (El s) -> El (parserDatoid a s) unP (P x) = x _<+>_ : {a : Datoid} -> El (Bag a) -> El (Bag a) -> El (Bag a) _<+>_ {a} x y = bagElim (\bs -> El (Bag a)) ? y (\z zs ih -> insert z ih) x concatMap : {a, b : Datoid} -> (El a -> El (Bag b)) -> El (Bag a) -> El (Bag b) concatMap {a} {b} f = bagElim (\bs -> El (Bag b)) ? empty (\x b ih -> f x <+> ih) symbol : {s : Datoid} -> Parsing s s symbol {s} = P symbol' where symbol' : List (El s) -> El (parserDatoid s s) symbol' nil = empty symbol' (x :: xs) = insert (pair x xs) empty fail : {s, a : Datoid} -> Parsing s a fail = P (\ss -> empty) (+++) : {s, a : Datoid} -> Parsing s a -> Parsing s a -> Parsing s a P p +++ P q = P (\s -> p s <+> q s) return : {s, a : Datoid} -> (x : El a) -> Parsing s a return = \x -> P (\s -> insert (pair x s) empty) -- data Traverse (a : Datoid) : Set where -- Empty : Traverse a -- Insert : (x : El a) -> (b : El (Bag a)) -> Traverse a -- run : {a : Datoid} -> Traverse a -> El (Bag a) -- traverse : {a : Datoid} -> El (Bag a) -> Traverse a -- traverseTraverses -- : {a : Datoid} -> (b : El (Bag a)) -> run (traverse b) =^= b -- insert : {a : Datoid} -> El a -> El (Bag a) -> El (Bag a) -- pairDatoid : Datoid -> Datoid -> Datoid --(empty {Bag (pairDatoid s (listDatoid s))}) -- bagElim -- : {a : Datoid} -- -> (P : El (Bag a) -> Set) -- -> P empty -- -> ((x : El a) -> (b : El (Bag a)) -> P b -> P (insert x b)) -- -> (b : El (Bag a)) -- -> P b (>>=) : {s, a, b : Datoid} -> Parsing s a -> (El a -> Parsing s b) -> Parsing s b (>>=) {s} {a} {b} (P p) k = P (\s -> concatMap (\y -> unP (k (fst y)) (snd y)) (p s)) {- parserDatoid : (a, s : Datoid) -> Datoid parserDatoid a s = Bag (pairDatoid a (listDatoid s)) -- We use the following datatype instead of -- type Parsing s a = [s] -> Bag (a, [s]) data Parsing (s, a : Datoid) : Set1 where P : (List (El s) -> El (parserDatoid a s)) -> Parsing s a -} -}
{ "alphanum_fraction": 0.504611837, "avg_line_length": 27.1041666667, "ext": "agda", "hexsha": "60517c1ec0ba204ea17eea329e50bb9c7ec1ddc7", "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/AIM4/bag/ParserC.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/AIM4/bag/ParserC.agda", "max_line_length": 85, "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/AIM4/bag/ParserC.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": 973, "size": 2602 }
{-# OPTIONS --without-K #-} module Test where open import Level infixl 4 _≑_ data _≑_ {a} {A : Set a} (x : A) : A β†’ Set a where refl : x ≑ x J : {a b : Level} (A : Set a) (C : (x y : A) β†’ x ≑ y β†’ Set b) β†’ ((x : A) β†’ C x x refl) β†’ (x y : A) (P : x ≑ y) β†’ C x y P J A C b x .x refl = b x -- K : (A : Set) (x : A) (C : x ≑ x β†’ Set) -- β†’ C refl -- β†’ (loop : x ≑ x) -- β†’ C loop -- K A x C b p = {! p !} -- Lemma 2.1.1 (inversion of paths) infix 6 Β¬_ Β¬_ : {a : Level} {A : Set a} {x y : A} β†’ x ≑ y β†’ y ≑ x Β¬_ {a} {A} {x} {y} p = J A D d x y p where D : (x y : A) (p : x ≑ y) β†’ Set a D x y p = y ≑ x d : (x : A) β†’ D x x refl d x = refl -- Lemma 2.1.2 (concatenation of paths) infixl 5 _βˆ™_ _βˆ™_ : {a : Level} {A : Set a} {x y z : A} β†’ x ≑ y β†’ y ≑ z β†’ x ≑ z _βˆ™_ {a} {A} {x} {y} {z} p q = J {a} {a} A D d x y p z q where -- the predicate D : (x y : A) (p : x ≑ y) β†’ Set a D x y p = (z : A) (q : y ≑ z) β†’ x ≑ z -- base case d : (x : A) β†’ D x x refl d x z q = J A E e x z q where -- the predicate E : (x z : A) (q : x ≑ z) β†’ Set a E x z q = x ≑ z -- base case e : (x : A) β†’ E x x refl e x = refl -- Lemma 2.1.4.i (identity of path concatenation) βˆ™-identityΚ³ : {a : Level} {A : Set a} {x y : A} (p : x ≑ y) β†’ p ≑ p βˆ™ refl βˆ™-identityΚ³ {a} {A} {x} {y} p = J A D d x y p where -- the predicate D : (x y : A) (p : x ≑ y) β†’ Set a D x y p = p ≑ p βˆ™ refl -- base case d : (x : A) β†’ D x x refl d x = refl βˆ™-identityΛ‘ : {a : Level} {A : Set a} {x y : A} (p : x ≑ y) β†’ p ≑ refl βˆ™ p βˆ™-identityΛ‘ {a} {A} {x} {y} p = J A D d x y p where -- the predicate D : (x y : A) (p : x ≑ y) β†’ Set a D x y p = p ≑ refl βˆ™ p -- base case d : (x : A) β†’ D x x refl d x = refl -- Lemma 2.1.4.ii (identity of path inversion) Β¬-identityΚ³ : {a : Level} {A : Set a} {x y : A} (p : x ≑ y) β†’ Β¬ p βˆ™ p ≑ refl Β¬-identityΚ³ {a} {A} {x} {y} p = J A D d x y p where -- the predicate D : (x y : A) (p : x ≑ y) β†’ Set a D x y p = Β¬ p βˆ™ p ≑ refl -- base case d : (x : A) β†’ D x x refl d x = refl Β¬-identityΛ‘ : {a : Level} {A : Set a} {x y : A} (p : x ≑ y) β†’ p βˆ™ Β¬ p ≑ refl Β¬-identityΛ‘ {a} {A} {x} {y} p = J A D d x y p where -- the predicate D : (x y : A) (p : x ≑ y) β†’ Set a D x y p = p βˆ™ Β¬ p ≑ refl -- base case d : (x : A) β†’ D x x refl d x = refl -- Lemma 2.1.4.iii (involution of path inversion) involution : {A : Set} {x y : A} (p : x ≑ y) β†’ Β¬ Β¬ p ≑ p involution {A} {x} {y} p = J A D d x y p where -- the predicate D : (x y : A) (p : x ≑ y) β†’ Set D x y p = Β¬ Β¬ p ≑ p -- base case d : (x : A) β†’ D x x refl d x = refl -- Lemma 2.1.4.iv (associativity of path concatenation) βˆ™-assoc : {a : Level} {A : Set a} {w x y z : A} β†’ (p : w ≑ x) (q : x ≑ y) (r : y ≑ z) β†’ p βˆ™ (q βˆ™ r) ≑ (p βˆ™ q) βˆ™ r βˆ™-assoc {a} {A} {w} {x} {y} {z} p q r = J A D d w x p y q z r where -- the predicate D : (w x : A) (p : w ≑ x) β†’ Set a D w x p = (y : A) (q : x ≑ y) β†’ (z : A) (r : y ≑ z) β†’ p βˆ™ (q βˆ™ r) ≑ (p βˆ™ q) βˆ™ r -- base case d : (x : A) β†’ D x x refl d x y q z r = J A E e x y q z r where -- the predicate E : (x y : A) (q : x ≑ y) β†’ Set a E x y q = (z : A) (r : y ≑ z) β†’ refl βˆ™ (q βˆ™ r) ≑ refl βˆ™ q βˆ™ r -- base case e : (x : A) β†’ E x x refl e x z r = J A F f x z r where -- the predicate F : (y z : A) (r : y ≑ z) β†’ Set a F y z r = refl βˆ™ (refl βˆ™ r) ≑ refl βˆ™ refl βˆ™ r -- base case f : (x : A) β†’ F x x refl f x = {! !}
{ "alphanum_fraction": 0.397311828, "avg_line_length": 24.6357615894, "ext": "agda", "hexsha": "4bed8fc67385a11db50395a6b5339a5e395ff724", "lang": "Agda", "max_forks_count": 18, "max_forks_repo_forks_event_max_datetime": "2019-11-21T10:12:31.000Z", "max_forks_repo_forks_event_min_datetime": "2015-05-24T04:15:44.000Z", "max_forks_repo_head_hexsha": "67d4db3b1050e6acfbdfdc05f8a656fd4c1f0b07", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "erydo/agda-mode", "max_forks_repo_path": "test/asset/Test.agda", "max_issues_count": 126, "max_issues_repo_head_hexsha": "67d4db3b1050e6acfbdfdc05f8a656fd4c1f0b07", "max_issues_repo_issues_event_max_datetime": "2020-12-23T23:00:13.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-02T05:47:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "erydo/agda-mode", "max_issues_repo_path": "test/asset/Test.agda", "max_line_length": 76, "max_stars_count": 58, "max_stars_repo_head_hexsha": "67d4db3b1050e6acfbdfdc05f8a656fd4c1f0b07", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "erydo/agda-mode", "max_stars_repo_path": "test/asset/Test.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-11T01:42:34.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-10T10:24:09.000Z", "num_tokens": 1728, "size": 3720 }
{-# OPTIONS --without-K --safe #-} module Definition.Typed.Consequences.Equality where open import Definition.Untyped open import Definition.Typed open import Definition.Typed.Properties open import Definition.Typed.EqRelInstance open import Definition.LogicalRelation open import Definition.LogicalRelation.Irrelevance open import Definition.LogicalRelation.ShapeView open import Definition.LogicalRelation.Fundamental.Reducibility open import Tools.Product import Tools.PropositionalEquality as PE U≑Aβ€² : βˆ€ {A Ξ“ l} ([U] : Ξ“ ⊩⟨ l ⟩U) β†’ Ξ“ ⊩⟨ l ⟩ U ≑ A / (U-intr [U]) β†’ A PE.≑ U U≑Aβ€² (noemb [U]) [U≑A] = [U≑A] U≑Aβ€² (emb 0<1 [U]) [U≑A] = U≑Aβ€² [U] [U≑A] -- If A is judgmentally equal to U, then A is propositionally equal to U. U≑A : βˆ€ {A Ξ“} β†’ Ξ“ ⊒ U ≑ A β†’ A PE.≑ U U≑A {A} U≑A with reducibleEq U≑A U≑A {A} U≑A | [U] , [A] , [U≑A] = U≑Aβ€² (U-elim [U]) (irrelevanceEq [U] (U-intr (U-elim [U])) [U≑A]) ℕ≑Aβ€² : βˆ€ {A Ξ“ l} ([β„•] : Ξ“ ⊩⟨ l βŸ©β„• β„•) β†’ Ξ“ ⊩⟨ l ⟩ β„• ≑ A / (β„•-intr [β„•]) β†’ Whnf A β†’ A PE.≑ β„• ℕ≑Aβ€² (noemb x) [ℕ≑A] whnfA = whnfRed* [ℕ≑A] whnfA ℕ≑Aβ€² (emb 0<1 [β„•]) [ℕ≑A] whnfA = ℕ≑Aβ€² [β„•] [ℕ≑A] whnfA -- If A in WHNF is judgmentally equal to β„•, then A is propositionally equal to β„•. ℕ≑A : βˆ€ {A Ξ“} β†’ Ξ“ ⊒ β„• ≑ A β†’ Whnf A β†’ A PE.≑ β„• ℕ≑A {A} ℕ≑A whnfA with reducibleEq ℕ≑A ℕ≑A {A} ℕ≑A whnfA | [β„•] , [A] , [ℕ≑A] = ℕ≑Aβ€² (β„•-elim [β„•]) (irrelevanceEq [β„•] (β„•-intr (β„•-elim [β„•])) [ℕ≑A]) whnfA -- If A in WHNF is judgmentally equal to Empty, then A is propositionally equal to Empty. Empty≑Aβ€² : βˆ€ {A Ξ“ l} ([Empty] : Ξ“ ⊩⟨ l ⟩Empty Empty) β†’ Ξ“ ⊩⟨ l ⟩ Empty ≑ A / (Empty-intr [Empty]) β†’ Whnf A β†’ A PE.≑ Empty Empty≑Aβ€² (noemb x) [Empty≑A] whnfA = whnfRed* [Empty≑A] whnfA Empty≑Aβ€² (emb 0<1 [Empty]) [Empty≑A] whnfA = Empty≑Aβ€² [Empty] [Empty≑A] whnfA Empty≑A : βˆ€ {A Ξ“} β†’ Ξ“ ⊒ Empty ≑ A β†’ Whnf A β†’ A PE.≑ Empty Empty≑A {A} Empty≑A whnfA with reducibleEq Empty≑A Empty≑A {A} Empty≑A whnfA | [Empty] , [A] , [Empty≑A] = Empty≑Aβ€² (Empty-elim [Empty]) (irrelevanceEq [Empty] (Empty-intr (Empty-elim [Empty])) [Empty≑A]) whnfA Unit≑Aβ€² : βˆ€ {A Ξ“ l} ([Unit] : Ξ“ ⊩⟨ l ⟩Unit Unit) β†’ Ξ“ ⊩⟨ l ⟩ Unit ≑ A / (Unit-intr [Unit]) β†’ Whnf A β†’ A PE.≑ Unit Unit≑Aβ€² (noemb x) [Unit≑A] whnfA = whnfRed* [Unit≑A] whnfA Unit≑Aβ€² (emb 0<1 [Unit]) [Unit≑A] whnfA = Unit≑Aβ€² [Unit] [Unit≑A] whnfA Unit≑A : βˆ€ {A Ξ“} β†’ Ξ“ ⊒ Unit ≑ A β†’ Whnf A β†’ A PE.≑ Unit Unit≑A {A} Unit≑A whnfA with reducibleEq Unit≑A Unit≑A {A} Unit≑A whnfA | [Unit] , [A] , [Unit≑A] = Unit≑Aβ€² (Unit-elim [Unit]) (irrelevanceEq [Unit] (Unit-intr (Unit-elim [Unit])) [Unit≑A]) whnfA ne≑Aβ€² : βˆ€ {A K Ξ“ l} β†’ ([K] : Ξ“ ⊩⟨ l ⟩ne K) β†’ Ξ“ ⊩⟨ l ⟩ K ≑ A / (ne-intr [K]) β†’ Whnf A β†’ βˆƒ Ξ» M β†’ Neutral M Γ— A PE.≑ M ne≑Aβ€² (noemb [K]) (neβ‚Œ M Dβ€² neM K≑M) whnfA = M , neM , (whnfRed* (red Dβ€²) whnfA) ne≑Aβ€² (emb 0<1 [K]) [K≑A] whnfA = ne≑Aβ€² [K] [K≑A] whnfA -- If A in WHNF is judgmentally equal to K, then there exists a M such that -- A is propositionally equal to M. ne≑A : βˆ€ {A K Ξ“} β†’ Neutral K β†’ Ξ“ ⊒ K ≑ A β†’ Whnf A β†’ βˆƒ Ξ» M β†’ Neutral M Γ— A PE.≑ M ne≑A {A} neK ne≑A whnfA with reducibleEq ne≑A ne≑A {A} neK ne≑A whnfA | [ne] , [A] , [ne≑A] = ne≑Aβ€² (ne-elim neK [ne]) (irrelevanceEq [ne] (ne-intr (ne-elim neK [ne])) [ne≑A]) whnfA B≑Aβ€² : βˆ€ {A F G Ξ“ l} W ([W] : Ξ“ ⊩⟨ l ⟩B⟨ W ⟩ ⟦ W ⟧ F β–Ή G) β†’ Ξ“ ⊩⟨ l ⟩ ⟦ W ⟧ F β–Ή G ≑ A / (B-intr W [W]) β†’ Whnf A β†’ βˆƒβ‚‚ Ξ» H E β†’ A PE.≑ ⟦ W ⟧ H β–Ή E B≑Aβ€² W (noemb [W]) (Bβ‚Œ Fβ€² Gβ€² Dβ€² A≑B [F≑Fβ€²] [G≑Gβ€²]) whnfA = Fβ€² , Gβ€² , whnfRed* Dβ€² whnfA B≑Aβ€² W (emb 0<1 [W]) [W≑A] whnfA = B≑Aβ€² W [W] [W≑A] whnfA Π≑Aβ€² : βˆ€ {A F G Ξ“ l} β†’ _ Π≑Aβ€² {A} {F} {G} {Ξ“} {l} = B≑Aβ€² {A} {F} {G} {Ξ“} {l} BΞ  Σ≑Aβ€² : βˆ€ {A F G Ξ“ l} β†’ _ Σ≑Aβ€² {A} {F} {G} {Ξ“} {l} = B≑Aβ€² {A} {F} {G} {Ξ“} {l} BΞ£ -- If A is judgmentally equal to Ξ  F β–Ή G, then there exists H and E such that -- A is propositionally equal to Ξ  H β–Ή E. B≑A : βˆ€ {A F G Ξ“} W β†’ Ξ“ ⊒ ⟦ W ⟧ F β–Ή G ≑ A β†’ Whnf A β†’ βˆƒβ‚‚ Ξ» H E β†’ A PE.≑ ⟦ W ⟧ H β–Ή E B≑A {A} W W≑A whnfA with reducibleEq W≑A B≑A {A} W W≑A whnfA | [W] , [A] , [W≑A] = B≑Aβ€² W (B-elim W [W]) (irrelevanceEq [W] (B-intr W (B-elim W [W])) [W≑A]) whnfA Π≑A : βˆ€ {A F G Ξ“} β†’ _ Π≑A {A} {F} {G} {Ξ“} = B≑A {A} {F} {G} {Ξ“} BΞ  Σ≑A : βˆ€ {A F G Ξ“} β†’ _ Σ≑A {A} {F} {G} {Ξ“} = B≑A {A} {F} {G} {Ξ“} BΞ£
{ "alphanum_fraction": 0.5328312544, "avg_line_length": 33.4566929134, "ext": "agda", "hexsha": "29a9f15743b0b3b1ee980681c280407766f7f878", "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/Consequences/Equality.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/Consequences/Equality.agda", "max_line_length": 105, "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/Consequences/Equality.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2232, "size": 4249 }
{- Cubical Agda - A Dependently Typed PL with Univalence and HITs ============================================================== Anders MΓΆrtberg Every Proof Assistant - September 17, 2020 Link to slides: https://staff.math.su.se/anders.mortberg/slides/EPA2020.pdf Link to video: https://vimeo.com/459020971 -} -- To make Agda cubical add the following options {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Talks.EPA2020 where -- The "Foundations" package contain a lot of important results (in -- particular the univalence theorem) open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Data.Int open import Cubical.Data.Prod.Base -- The interval in Cubical Agda is written I and the endpoints i0 and i1. apply0 : (A : Type) (p : I β†’ A) β†’ A apply0 A p = p i0 -- We omit the universe level β„“ for simplicity in this talk. In the -- library everything is maximally universe polymorphic. -- We can write functions out of the interval using Ξ»-abstraction: refl' : {A : Type} (x : A) β†’ x ≑ x refl' x = Ξ» i β†’ x -- In fact, x ≑ y is short for PathP (Ξ» _ β†’ A) x y refl'' : {A : Type} (x : A) β†’ PathP (Ξ» _ β†’ A) x x refl'' x = Ξ» _ β†’ x -- In general PathP A x y has A : I β†’ Type, x : A i0 and y : A i1 -- PathP = Dependent paths (Path over a Path) -- We cannot pattern-match on interval variables as I is not inductively defined -- foo : {A : Type} β†’ I β†’ A -- foo r = {!r!} -- Try typing C-c C-c -- cong has a direct proof cong' : {A B : Type} (f : A β†’ B) {x y : A} β†’ x ≑ y β†’ f x ≑ f y cong' f p i = f (p i) -- function extensionality also has a direct proof. -- It also has computational content: swap the arguments. funExt' : {A B : Type} {f g : A β†’ B} (p : (x : A) β†’ f x ≑ g x) β†’ f ≑ g funExt' p i x = p x i -- Transport is more complex as ≑ isn't inductively defined (so we -- can't define it by pattern-matching on p) transport' : {A B : Type} β†’ A ≑ B β†’ A β†’ B transport' p a = transp (Ξ» i β†’ p i) i0 a -- This lets us define subst (which is called "transport" in the HoTT book) subst' : {A : Type} (P : A β†’ Type) {x y : A} (p : x ≑ y) β†’ P x β†’ P y subst' P p pa = transport (Ξ» i β†’ P (p i)) pa -- The transp operation reduces differently for different types -- formers. For paths it reduces to another primitive operation called -- hcomp. -- We can also define the J eliminator (aka path induction) J' : {A : Type} {B : A β†’ Type} {x : A} (P : (z : A) β†’ x ≑ z β†’ Type) (d : P x refl) {y : A} (p : x ≑ y) β†’ P y p J' P d p = transport (Ξ» i β†’ P (p i) (Ξ» j β†’ p (i ∧ j))) d -- So J is provable, but it doesn't satisfy computation rule -- definitionally. This is almost never a problem in practice as the -- cubical primitives satisfy many new definitional equalities. -- Another key concept in HoTT/UF is the Univalence Axiom. In Cubical -- Agda this is provable, we hence refer to it as the Univalence -- Theorem. -- The univalence theorem: equivalences of types give paths of types ua' : {A B : Type} β†’ A ≃ B β†’ A ≑ B ua' = ua -- Any isomorphism of types gives rise to an equivalence isoToEquiv' : {A B : Type} β†’ Iso A B β†’ A ≃ B isoToEquiv' = isoToEquiv -- And hence to a path isoToPath' : {A B : Type} β†’ Iso A B β†’ A ≑ B isoToPath' e = ua' (isoToEquiv' e) -- ua satisfies the following computation rule -- This suffices to be able to prove the standard formulation of univalence. uaΞ²' : {A B : Type} (e : A ≃ B) (x : A) β†’ transport (ua' e) x ≑ fst e x uaΞ²' e x = transportRefl (equivFun e x) -- Time for an example! -- Booleans data Bool : Type where false true : Bool not : Bool β†’ Bool not false = true not true = false notPath : Bool ≑ Bool notPath = isoToPath' (iso not not rem rem) where rem : (b : Bool) β†’ not (not b) ≑ b rem false = refl rem true = refl _ : transport notPath true ≑ false _ = refl -- Another example, integers: sucPath : Int ≑ Int sucPath = isoToPath' (iso sucInt predInt sucPred predSuc) _ : transport sucPath (pos 0) ≑ pos 1 _ = refl _ : transport (sucPath βˆ™ sucPath) (pos 0) ≑ pos 2 _ = refl _ : transport (sym sucPath) (pos 0) ≑ negsuc 0 _ = refl ----------------------------------------------------------------------------- -- Higher inductive types -- The following definition of finite multisets is due to Vikraman -- Choudhury and Marcelo Fiore. infixr 5 _∷_ data FMSet (A : Type) : Type where [] : FMSet A _∷_ : (x : A) β†’ (xs : FMSet A) β†’ FMSet A comm : (x y : A) (xs : FMSet A) β†’ x ∷ y ∷ xs ≑ y ∷ x ∷ xs -- trunc : (xs ys : FMSet A) (p q : xs ≑ ys) β†’ p ≑ q -- We need to add the trunc constructor for FMSets to be sets, omitted -- here for simplicity. _++_ : βˆ€ {A : Type} (xs ys : FMSet A) β†’ FMSet A [] ++ ys = ys (x ∷ xs) ++ ys = x ∷ xs ++ ys comm x y xs i ++ ys = comm x y (xs ++ ys) i -- trunc xs zs p q i j ++ ys = -- trunc (xs ++ ys) (zs ++ ys) (cong (_++ ys) p) (cong (_++ ys) q) i j unitr-++ : {A : Type} (xs : FMSet A) β†’ xs ++ [] ≑ xs unitr-++ [] = refl unitr-++ (x ∷ xs) = cong (x ∷_) (unitr-++ xs) unitr-++ (comm x y xs i) j = comm x y (unitr-++ xs j) i -- unitr-++ (trunc xs ys x y i j) = {!!} -- This is a special case of set quotients! Very useful for -- programming and set level mathematics data _/_ (A : Type) (R : A β†’ A β†’ Type) : Type where [_] : A β†’ A / R eq/ : (a b : A) β†’ R a b β†’ [ a ] ≑ [ b ] trunc : (a b : A / R) (p q : a ≑ b) β†’ p ≑ q -- Proving that they are effective ((a b : A) β†’ [ a ] ≑ [ b ] β†’ R a b) -- requires univalence for propositions. ------------------------------------------------------------------------- -- Topological examples of things that are not sets -- We can define the circle as the following simple data declaration: data SΒΉ : Type where base : SΒΉ loop : base ≑ base -- We can write functions on SΒΉ using pattern-matching equations: double : SΒΉ β†’ SΒΉ double base = base double (loop i) = (loop βˆ™ loop) i helix : SΒΉ β†’ Type helix base = Int helix (loop i) = sucPathInt i Ξ©SΒΉ : Type Ξ©SΒΉ = base ≑ base winding : Ξ©SΒΉ β†’ Int winding p = subst helix p (pos 0) _ : winding (Ξ» i β†’ double ((loop βˆ™ loop) i)) ≑ pos 4 _ = refl -- We can define the Torus as: data Torus : Type where point : Torus line1 : point ≑ point line2 : point ≑ point square : PathP (Ξ» i β†’ line1 i ≑ line1 i) line2 line2 -- And prove that it is equivalent to two circle: t2c : Torus β†’ SΒΉ Γ— SΒΉ t2c point = (base , base) t2c (line1 i) = (loop i , base) t2c (line2 j) = (base , loop j) t2c (square i j) = (loop i , loop j) c2t : SΒΉ Γ— SΒΉ β†’ Torus c2t (base , base) = point c2t (loop i , base) = line1 i c2t (base , loop j) = line2 j c2t (loop i , loop j) = square i j c2t-t2c : (t : Torus) β†’ c2t (t2c t) ≑ t c2t-t2c point = refl c2t-t2c (line1 _) = refl c2t-t2c (line2 _) = refl c2t-t2c (square _ _) = refl t2c-c2t : (p : SΒΉ Γ— SΒΉ) β†’ t2c (c2t p) ≑ p t2c-c2t (base , base) = refl t2c-c2t (base , loop _) = refl t2c-c2t (loop _ , base) = refl t2c-c2t (loop _ , loop _) = refl -- Using univalence we get the following equality: Torus≑SΒΉΓ—SΒΉ : Torus ≑ SΒΉ Γ— SΒΉ Torus≑SΒΉΓ—SΒΉ = isoToPath' (iso t2c c2t t2c-c2t c2t-t2c) windingTorus : point ≑ point β†’ Int Γ— Int windingTorus l = ( winding (Ξ» i β†’ proj₁ (t2c (l i))) , winding (Ξ» i β†’ projβ‚‚ (t2c (l i)))) _ : windingTorus (line1 βˆ™ sym line2) ≑ (pos 1 , negsuc 0) _ = refl -- We have many more topological examples, including Klein bottle, RP^n, -- higher spheres, suspensions, join, wedges, smash product: open import Cubical.HITs.KleinBottle open import Cubical.HITs.RPn open import Cubical.HITs.S2 open import Cubical.HITs.S3 open import Cubical.HITs.Susp open import Cubical.HITs.Join open import Cubical.HITs.Wedge open import Cubical.HITs.SmashProduct -- There's also a proof of the "3x3 lemma" for pushouts in less than -- 200LOC. In HoTT-Agda this took about 3000LOC. For details see: -- https://github.com/HoTT/HoTT-Agda/tree/master/theorems/homotopy/3x3 open import Cubical.HITs.Pushout -- We also defined the Hopf fibration and proved that its total space -- is SΒ³ in about 300LOC: open import Cubical.HITs.Hopf -- There is also some integer cohomology: open import Cubical.ZCohomology.Everything -- To compute cohomology groups of various spaces we need a bunch of -- interesting theorems: Freudenthal suspension theorem, -- Mayer-Vietoris sequence... open import Cubical.Homotopy.Freudenthal open import Cubical.ZCohomology.MayerVietorisUnreduced ------------------------------------------------------------------------- -- The structure identity principle -- A more efficient version of finite multisets based on association lists open import Cubical.HITs.AssocList.Base -- data AssocList (A : Type) : Type where -- ⟨⟩ : AssocList A -- ⟨_,_⟩∷_ : (a : A) (n : β„•) (xs : AssocList A) β†’ AssocList A -- per : (a b : A) (m n : β„•) (xs : AssocList A) -- β†’ ⟨ a , m ⟩∷ ⟨ b , n ⟩∷ xs ≑ ⟨ b , n ⟩∷ ⟨ a , m ⟩∷ xs -- agg : (a : A) (m n : β„•) (xs : AssocList A) -- β†’ ⟨ a , m ⟩∷ ⟨ a , n ⟩∷ xs ≑ ⟨ a , m + n ⟩∷ xs -- del : (a : A) (xs : AssocList A) β†’ ⟨ a , 0 ⟩∷ xs ≑ xs -- trunc : (xs ys : AssocList A) (p q : xs ≑ ys) β†’ p ≑ q -- Programming and proving is more complicated with AssocList compared -- to FMSet. This kind of example occurs everywhere in programming and -- mathematics: one representation is easier to work with, but not -- efficient, while another is efficient but difficult to work with. -- Solution: substitute using univalence substIso : {A B : Type} (P : Type β†’ Type) (e : Iso A B) β†’ P A β†’ P B substIso P e = subst P (isoToPath e) -- Can transport for example Monoid structure from FMSet to AssocList -- this way, but the achieved Monoid structure is not very efficient -- to work with. A better solution is to prove that FMSet and -- AssocList are equal *as monoids*, but how to do this? -- Solution: structure identity principle (SIP) -- This is a very useful consequence of univalence open import Cubical.Foundations.SIP sip' : {β„“ : Level} {S : Type β„“ β†’ Type β„“} {ΞΉ : StrEquiv S β„“} (ΞΈ : UnivalentStr S ΞΉ) (A B : TypeWithStr β„“ S) β†’ A ≃[ ΞΉ ] B β†’ A ≑ B sip' = sip -- The tricky thing is to prove that (S,ΞΉ) is a univalent structure. -- Luckily we provide automation for this in the library, see for example: open import Cubical.Algebra.Monoid.Base -- Another cool application of the SIP: matrices represented as -- functions out of pairs of Fin's and vectors are equal as abelian -- groups: open import Cubical.Algebra.Matrix -- The end, back to slides!
{ "alphanum_fraction": 0.628761272, "avg_line_length": 30.8040935673, "ext": "agda", "hexsha": "12b37d9c29d3ed147e74cbf6e28996aee663280e", "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/Talks/EPA2020.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/Talks/EPA2020.agda", "max_line_length": 80, "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/Talks/EPA2020.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3549, "size": 10535 }
module Structure.Sets.Relators where
{ "alphanum_fraction": 0.8648648649, "avg_line_length": 18.5, "ext": "agda", "hexsha": "134367bbfc51f3e9acaa5136a5fbcf628f06a338", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Structure/Sets/Relators.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Structure/Sets/Relators.agda", "max_line_length": 36, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Structure/Sets/Relators.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": 8, "size": 37 }
module Prelude.Monoid where open import Prelude.Function open import Prelude.Maybe open import Prelude.List open import Prelude.Semiring open import Prelude.Applicative open import Prelude.Functor record Monoid {a} (A : Set a) : Set a where infixr 6 _<>_ field mempty : A _<>_ : A β†’ A β†’ A open Monoid {{...}} public {-# DISPLAY Monoid.mempty _ = mempty #-} {-# DISPLAY Monoid._<>_ _ a b = a <> b #-} mconcat : βˆ€ {a} {A : Set a} {{MonA : Monoid A}} β†’ List A β†’ A mconcat = foldr _<>_ mempty --- Instances --- instance MonoidList : βˆ€ {a} {A : Set a} β†’ Monoid (List A) mempty {{MonoidList}} = [] _<>_ {{MonoidList}} = _++_ MonoidFun : βˆ€ {a b} {A : Set a} {B : A β†’ Set b} {{_ : βˆ€ {x} β†’ Monoid (B x)}} β†’ Monoid (βˆ€ x β†’ B x) mempty {{MonoidFun}} _ = mempty _<>_ {{MonoidFun}} f g x = f x <> g x MonoidMaybe : βˆ€ {a} {A : Set a} β†’ Monoid (Maybe A) mempty {{MonoidMaybe}} = nothing _<>_ {{MonoidMaybe}} nothing y = y _<>_ {{MonoidMaybe}} (just x) _ = just x record Sum {a} (A : Set a) : Set a where constructor mkSum field getSum : A open Sum public instance MonoidSum : βˆ€ {a} {A : Set a} {{_ : Semiring A}} β†’ Monoid (Sum A) getSum (mempty {{MonoidSum}}) = zro getSum (_<>_ {{MonoidSum}} x y) = getSum x + getSum y record Product {a} (A : Set a) : Set a where constructor mkProduct field getProduct : A open Product public instance MonoidProduct : βˆ€ {a} {A : Set a} {{_ : Semiring A}} β†’ Monoid (Product A) getProduct (mempty {{MonoidProduct}}) = one getProduct (_<>_ {{MonoidProduct}} x y) = getProduct x * getProduct y record Const {a b} (A : Set a) (B : Set b) : Set a where constructor mkConst field getConst : A open Const public module _ {a b} {A : Set a} {{MonA : Monoid A}} where instance FunctorConst : Functor {a = b} (Const A) getConst (fmap {{FunctorConst}} f x) = getConst x ApplicativeConst : Applicative (Const A) getConst (pure {{ApplicativeConst}} x) = mempty getConst (_<*>_ {{ApplicativeConst}} wf wx) = getConst wf <> getConst wx
{ "alphanum_fraction": 0.6107350097, "avg_line_length": 26.8571428571, "ext": "agda", "hexsha": "12a6238220386af3b23191863a9b1cfa45afea31", "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/Prelude/Monoid.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/Prelude/Monoid.agda", "max_line_length": 99, "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/Prelude/Monoid.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 714, "size": 2068 }
{-# OPTIONS --safe #-} module Cubical.Algebra.Group.Instances.NProd where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Data.Nat using (β„•) open import Cubical.Algebra.Group private variable β„“ : Level open GroupStr NProd-Group : (G : (n : β„•) β†’ Type β„“) β†’ (Gstr : (n : β„•) β†’ GroupStr (G n)) β†’ Group β„“ fst (NProd-Group G Gstr) = (n : β„•) β†’ G n 1g (snd (NProd-Group G Gstr)) = Ξ» n β†’ 1g (Gstr n) GroupStr._Β·_ (snd (NProd-Group G Gstr)) = Ξ» f g n β†’ Gstr n ._Β·_ (f n) (g n) inv (snd (NProd-Group G Gstr)) = Ξ» f n β†’ (Gstr n).inv (f n) isGroup (snd (NProd-Group G Gstr)) = makeIsGroup (isSetΞ  (Ξ» _ β†’ is-set (Gstr _))) (Ξ» f g h β†’ funExt Ξ» n β†’ Β·Assoc (Gstr n) _ _ _) (Ξ» f β†’ funExt Ξ» n β†’ Β·IdR (Gstr n) _) (Ξ» f β†’ funExt Ξ» n β†’ Β·IdL (Gstr n) _) (Ξ» f β†’ funExt Ξ» n β†’ Β·InvR (Gstr n) _) Ξ» f β†’ funExt Ξ» n β†’ Β·InvL (Gstr n) _
{ "alphanum_fraction": 0.4887285843, "avg_line_length": 41.0740740741, "ext": "agda", "hexsha": "8169e1da5fed15cc28ed752d38e4c186ee879601", "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/Group/Instances/NProd.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/Group/Instances/NProd.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/Group/Instances/NProd.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 352, "size": 1109 }
------------------------------------------------------------------------ -- An abstraction: term-like things ------------------------------------------------------------------------ open import Data.Universe.Indexed module deBruijn.Context.Term-like {i u e} (Uni : IndexedUniverse i u e) where import Axiom.Extensionality.Propositional as E open import Data.Product import deBruijn.Context.Basics as Basics import deBruijn.Context.Extension.Right as Right open import Function.Base hiding (_βˆ‹_) open import Level using (_βŠ”_) open import Relation.Binary using (Setoid) open import Relation.Binary.PropositionalEquality as P using (_≑_) open Basics Uni open Right Uni open P.≑-Reasoning ------------------------------------------------------------------------ -- Term-like things record Term-like β„“ : Set (i βŠ” u βŠ” e βŠ” Level.suc β„“) where infix 3 _⊒_ field _⊒_ : (Ξ“ : Ctxt) β†’ Type Ξ“ β†’ Set β„“ ⟦_⟧ : βˆ€ {Ξ“ Οƒ} β†’ Ξ“ ⊒ Οƒ β†’ Value Ξ“ Οƒ -- Equality of term-like things. record [⊒] : Set (i βŠ” u βŠ” e βŠ” β„“) where constructor [_] field {Ξ“} : Ctxt {Οƒ} : Type Ξ“ t : Ξ“ ⊒ Οƒ infix 4 _β‰…-⊒_ _β‰…-⊒_ : βˆ€ {Γ₁ σ₁} (t₁ : Γ₁ ⊒ σ₁) {Ξ“β‚‚ Οƒβ‚‚} (tβ‚‚ : Ξ“β‚‚ ⊒ Οƒβ‚‚) β†’ Set _ t₁ β‰…-⊒ tβ‚‚ = _≑_ {A = [⊒]} [ t₁ ] [ tβ‚‚ ] β‰…-⊒-β‡’-≑ : βˆ€ {Ξ“ Οƒ} {t₁ tβ‚‚ : Ξ“ ⊒ Οƒ} β†’ t₁ β‰…-⊒ tβ‚‚ β†’ t₁ ≑ tβ‚‚ β‰…-⊒-β‡’-≑ P.refl = P.refl -- Certain uses of substitutivity can be removed. drop-subst-⊒ : βˆ€ {a} {A : Set a} {x₁ xβ‚‚ : A} {Ξ“} (f : A β†’ Type Ξ“) {t} (eq : x₁ ≑ xβ‚‚) β†’ P.subst (Ξ» x β†’ Ξ“ ⊒ f x) eq t β‰…-⊒ t drop-subst-⊒ f P.refl = P.refl -- A congruence lemma. ⟦⟧-cong : βˆ€ {Γ₁ σ₁} {t₁ : Γ₁ ⊒ σ₁} {Ξ“β‚‚ Οƒβ‚‚} {tβ‚‚ : Ξ“β‚‚ ⊒ Οƒβ‚‚} β†’ t₁ β‰…-⊒ tβ‚‚ β†’ ⟦ t₁ ⟧ β‰…-Value ⟦ tβ‚‚ ⟧ ⟦⟧-cong P.refl = P.refl -- Values are term-like. Val : Term-like _ Val = record { _⊒_ = Value; ⟦_⟧ = id } -- Variables are term-like. Var : Term-like _ Var = record { _⊒_ = _βˆ‹_; ⟦_⟧ = lookup } ------------------------------------------------------------------------ -- Families of functions which, on the semantic side, correspond to -- the application of a given context morphism record [_⟢_] {t₁ tβ‚‚} (T₁ : Term-like t₁) (Tβ‚‚ : Term-like tβ‚‚) {Ξ“ Ξ” : Ctxt} (ρ̂ : Ξ“ ⇨̂ Ξ”) : Set (i βŠ” u βŠ” e βŠ” t₁ βŠ” tβ‚‚) where constructor _,_ open Term-like T₁ renaming (_⊒_ to _βŠ’β‚_; ⟦_⟧ to ⟦_βŸ§β‚) open Term-like Tβ‚‚ renaming (_⊒_ to _βŠ’β‚‚_; ⟦_⟧ to ⟦_βŸ§β‚‚) field function : βˆ€ Οƒ β†’ Ξ“ βŠ’β‚ Οƒ β†’ Ξ” βŠ’β‚‚ Οƒ /Μ‚ ρ̂ corresponds : βˆ€ Οƒ (t : Ξ“ βŠ’β‚ Οƒ) β†’ ⟦ t βŸ§β‚ /Μ‚Val ρ̂ β‰…-Value ⟦ function Οƒ t βŸ§β‚‚ -- Functions which do not change the context or type. [_⟢⁼_] : βˆ€ {t₁ tβ‚‚} β†’ Term-like t₁ β†’ Term-like tβ‚‚ β†’ Set _ [ T₁ ⟢⁼ Tβ‚‚ ] = βˆ€ {Ξ“} β†’ [ T₁ ⟢ Tβ‚‚ ] iΜ‚d[ Ξ“ ] -- Projections. (The fields above have explicit Οƒ's to avoid some -- problems; the projections below have implicit Οƒ's.) infixl 9 _Β·_ _Β·_ : βˆ€ {t₁ tβ‚‚} {T₁ : Term-like t₁} {Tβ‚‚ : Term-like tβ‚‚} β†’ let open Term-like T₁ renaming (_⊒_ to _βŠ’β‚_) open Term-like Tβ‚‚ renaming (_⊒_ to _βŠ’β‚‚_) in βˆ€ {Ξ“ Ξ” Οƒ} {ρ̂ : Ξ“ ⇨̂ Ξ”} β†’ [ T₁ ⟢ Tβ‚‚ ] ρ̂ β†’ Ξ“ βŠ’β‚ Οƒ β†’ Ξ” βŠ’β‚‚ Οƒ /Μ‚ ρ̂ _Β·_ f = [_⟢_].function f _ corresponds : βˆ€ {t₁ tβ‚‚} {T₁ : Term-like t₁} {Tβ‚‚ : Term-like tβ‚‚} β†’ let open Term-like T₁ renaming (_⊒_ to _βŠ’β‚_; ⟦_⟧ to ⟦_βŸ§β‚) open Term-like Tβ‚‚ renaming (⟦_⟧ to ⟦_βŸ§β‚‚) in βˆ€ {Ξ“ Ξ” : Ctxt} {ρ̂ : Ξ“ ⇨̂ Ξ”} {Οƒ} (f : [ T₁ ⟢ Tβ‚‚ ] ρ̂) (t : Ξ“ βŠ’β‚ Οƒ) β†’ ⟦ t βŸ§β‚ /Μ‚Val ρ̂ β‰…-Value ⟦ f Β· t βŸ§β‚‚ corresponds f = [_⟢_].corresponds f _ -- Weakening of variables (the successor function). weakenβˆ‹ : βˆ€ {Ξ“} {Οƒ : Type Ξ“} β†’ [ Var ⟢ Var ] wΜ‚k[ Οƒ ] weakenβˆ‹ = record { function = Ξ» _ β†’ suc ; corresponds = Ξ» _ _ β†’ P.refl } weakenβˆ‹[_] : βˆ€ {Ξ“} (Οƒ : Type Ξ“) β†’ [ Var ⟢ Var ] wΜ‚k[ Οƒ ] weakenβˆ‹[ _ ] = weakenβˆ‹ -- Lifts a function on variables, f, to a function which leaves a -- prefix of the context unchanged and otherwise behaves as f. lift : βˆ€ {Ξ“ Ξ”} {ρ̂ : Ξ“ ⇨̂ Ξ”} β†’ [ Var ⟢ Var ] ρ̂ β†’ βˆ€ Γ⁺ β†’ [ Var ⟢ Var ] (ρ̂ ↑̂⁺ Γ⁺) lift f Ξ΅ = f lift {Ξ“} {Ξ”} {ρ̂} f (Γ⁺ β–» Οƒ) = record { function = function ; corresponds = corr } where function : βˆ€ Ο„ β†’ Ξ“ ++⁺ Γ⁺ β–» Οƒ βˆ‹ Ο„ β†’ Ξ” ++⁺ (Γ⁺ β–» Οƒ) /̂⁺ ρ̂ βˆ‹ Ο„ /Μ‚ ρ̂ ↑̂⁺ (Γ⁺ β–» Οƒ) function ._ zero = zero function ._ (suc x) = suc (lift f Γ⁺ Β· x) abstract corr : βˆ€ Ο„ (x : Ξ“ ++⁺ Γ⁺ β–» Οƒ βˆ‹ Ο„) β†’ lookup x /Μ‚Val ρ̂ ↑̂⁺ (Γ⁺ β–» Οƒ) β‰…-Value lookup (function _ x) corr ._ zero = P.refl corr ._ (suc x) = begin [ lookup x /Μ‚Val ρ̂ ↑̂⁺ Γ⁺ /Μ‚Val wΜ‚k ] β‰‘βŸ¨ /Μ‚Val-cong (corresponds (lift f Γ⁺) x) P.refl ⟩ [ lookup (lift f Γ⁺ Β· x) /Μ‚Val wΜ‚k ] β‰‘βŸ¨ P.refl ⟩ [ lookup (suc (lift f Γ⁺ Β· x)) ] ∎ ------------------------------------------------------------------------ -- Equality for the functions introduced above -- Note that the definition of equality does not take the -- "corresponds" proof into account. record [⟢] {t₁ tβ‚‚} (T₁ : Term-like t₁) (Tβ‚‚ : Term-like tβ‚‚) : Set (i βŠ” u βŠ” e βŠ” t₁ βŠ” tβ‚‚) where constructor [_] open Term-like T₁ renaming (_⊒_ to _βŠ’β‚_) open Term-like Tβ‚‚ renaming (_⊒_ to _βŠ’β‚‚_) field {Ξ“ Ξ”} : Ctxt {ρ̂} : Ξ“ ⇨̂ Ξ” f : βˆ€ Οƒ β†’ Ξ“ βŠ’β‚ Οƒ β†’ Ξ” βŠ’β‚‚ Οƒ /Μ‚ ρ̂ [_]⟢ : βˆ€ {t₁ tβ‚‚} {T₁ : Term-like t₁} {Tβ‚‚ : Term-like tβ‚‚} {Ξ“ Ξ”} {ρ̂ : Ξ“ ⇨̂ Ξ”} β†’ [ T₁ ⟢ Tβ‚‚ ] ρ̂ β†’ [⟢] T₁ Tβ‚‚ [ f ]⟢ = [ [_⟢_].function f ] -- Equality is defined as a record type to make it possible to infer -- ρ₁ and ρ₂ from a value of type ρ₁ ≅-βŸΆΒ Οβ‚‚. infix 4 _β‰…-⟢_ record _β‰…-⟢_ {t₁ tβ‚‚} {T₁ : Term-like t₁} {Tβ‚‚ : Term-like tβ‚‚} {Γ₁ Δ₁ : Ctxt} {ρ̂₁ : Γ₁ ⇨̂ Δ₁} (f₁ : [ T₁ ⟢ Tβ‚‚ ] ρ̂₁) {Ξ“β‚‚ Ξ”β‚‚ : Ctxt} {ρ̂₂ : Ξ“β‚‚ ⇨̂ Ξ”β‚‚} (fβ‚‚ : [ T₁ ⟢ Tβ‚‚ ] ρ̂₂) : Set (i βŠ” u βŠ” e βŠ” t₁ βŠ” tβ‚‚) where constructor [_] field [f₁]βŸΆβ‰‘[fβ‚‚]⟢ : [ f₁ ]⟢ ≑ [ fβ‚‚ ]⟢ -- Some equational reasoning combinators. module β‰…-⟢-Reasoning {t₁ tβ‚‚} {T₁ : Term-like t₁} {Tβ‚‚ : Term-like tβ‚‚} where infix 3 _∎-⟢ infixr 2 _β‰…-⟢⟨_⟩_ _β‰…-⟢⟨_⟩_ : βˆ€ {Γ₁ Δ₁} {ρ̂₁ : Γ₁ ⇨̂ Δ₁} {Ξ“β‚‚ Ξ”β‚‚} {ρ̂₂ : Ξ“β‚‚ ⇨̂ Ξ”β‚‚} {Γ₃ Δ₃} {ρ̂₃ : Γ₃ ⇨̂ Δ₃} (f₁ : [ T₁ ⟢ Tβ‚‚ ] ρ̂₁) {fβ‚‚ : [ T₁ ⟢ Tβ‚‚ ] ρ̂₂} {f₃ : [ T₁ ⟢ Tβ‚‚ ] ρ̂₃} β†’ f₁ β‰…-⟢ fβ‚‚ β†’ fβ‚‚ β‰…-⟢ f₃ β†’ f₁ β‰…-⟢ f₃ _ β‰…-⟢⟨ [ f₁≅fβ‚‚ ] ⟩ [ fβ‚‚β‰…f₃ ] = [ P.trans f₁≅fβ‚‚ fβ‚‚β‰…f₃ ] _∎-⟢ : βˆ€ {Ξ“ Ξ”} {ρ̂ : Ξ“ ⇨̂ Ξ”} (f : [ T₁ ⟢ Tβ‚‚ ] ρ̂) β†’ f β‰…-⟢ f _ ∎-⟢ = [ P.refl ] sym-⟢ : βˆ€ {Γ₁ Δ₁} {ρ̂₁ : Γ₁ ⇨̂ Δ₁} {f₁ : [ T₁ ⟢ Tβ‚‚ ] ρ̂₁} {Ξ“β‚‚ Ξ”β‚‚} {ρ̂₂ : Ξ“β‚‚ ⇨̂ Ξ”β‚‚} {fβ‚‚ : [ T₁ ⟢ Tβ‚‚ ] ρ̂₂} β†’ f₁ β‰…-⟢ fβ‚‚ β†’ fβ‚‚ β‰…-⟢ f₁ sym-⟢ [ f₁≅fβ‚‚ ] = [ P.sym f₁≅fβ‚‚ ] open β‰…-⟢-Reasoning public -- A setoid for [_⟢_]. [_⟢_]-setoid : βˆ€ {t₁ tβ‚‚} (T₁ : Term-like t₁) (Tβ‚‚ : Term-like tβ‚‚) β†’ βˆ€ {Ξ“ Ξ”} β†’ Ξ“ ⇨̂ Ξ” β†’ Setoid _ _ [ T₁ ⟢ Tβ‚‚ ]-setoid ρ̂ = record { Carrier = [ T₁ ⟢ Tβ‚‚ ] ρ̂ ; _β‰ˆ_ = Ξ» f₁ fβ‚‚ β†’ f₁ β‰…-⟢ fβ‚‚ ; isEquivalence = record { refl = _ ∎-⟢ ; sym = sym-⟢ ; trans = Ξ» p q β†’ _ β‰…-⟢⟨ p ⟩ q } } -- A congruence lemma. Β·-cong : βˆ€ {t₁ tβ‚‚} {T₁ : Term-like t₁} {Tβ‚‚ : Term-like tβ‚‚} β†’ let open Term-like T₁ renaming (_⊒_ to _βŠ’β‚_; _β‰…-⊒_ to _β‰…-βŠ’β‚_) open Term-like Tβ‚‚ renaming (_⊒_ to _βŠ’β‚‚_; _β‰…-⊒_ to _β‰…-βŠ’β‚‚_) in βˆ€ {Γ₁ Δ₁ σ₁} {ρ̂₁ : Γ₁ ⇨̂ Δ₁} {f₁ : [ T₁ ⟢ Tβ‚‚ ] ρ̂₁} {t₁ : Γ₁ βŠ’β‚ σ₁} {Ξ“β‚‚ Ξ”β‚‚ Οƒβ‚‚} {ρ̂₂ : Ξ“β‚‚ ⇨̂ Ξ”β‚‚} {fβ‚‚ : [ T₁ ⟢ Tβ‚‚ ] ρ̂₂} {tβ‚‚ : Ξ“β‚‚ βŠ’β‚ Οƒβ‚‚} β†’ f₁ β‰…-⟢ fβ‚‚ β†’ t₁ β‰…-βŠ’β‚ tβ‚‚ β†’ f₁ Β· t₁ β‰…-βŠ’β‚‚ fβ‚‚ Β· tβ‚‚ Β·-cong {f₁ = _ , _} {fβ‚‚ = ._ , _} [ P.refl ] P.refl = P.refl abstract -- Two variants of extensional equality (assuming ordinary -- extensional equality). extensional-equality₁ : βˆ€ {t₁ tβ‚‚} {T₁ : Term-like t₁} {Tβ‚‚ : Term-like tβ‚‚} β†’ let open Term-like T₁ renaming (_⊒_ to _βŠ’β‚_) open Term-like Tβ‚‚ renaming (_β‰…-⊒_ to _β‰…-βŠ’β‚‚_) in E.Extensionality (i βŠ” u βŠ” e βŠ” t₁) (t₁ βŠ” tβ‚‚) β†’ βˆ€ {Ξ“ Δ₁} {ρ̂₁ : Ξ“ ⇨̂ Δ₁} {f₁ : [ T₁ ⟢ Tβ‚‚ ] ρ̂₁} {Ξ”β‚‚} {ρ̂₂ : Ξ“ ⇨̂ Ξ”β‚‚} {fβ‚‚ : [ T₁ ⟢ Tβ‚‚ ] ρ̂₂} β†’ ρ̂₁ β‰…-⇨̂ ρ̂₂ β†’ (βˆ€ {Οƒ} (t : Ξ“ βŠ’β‚ Οƒ) β†’ f₁ Β· t β‰…-βŠ’β‚‚ fβ‚‚ Β· t) β†’ f₁ β‰…-⟢ fβ‚‚ extensional-equality₁ {t₁} {tβ‚‚} {Tβ‚‚ = Tβ‚‚} ext P.refl f₁≅fβ‚‚ = [ P.cong [_] (ext₁ Ξ» Οƒ β†’ extβ‚‚ Ξ» t β†’ β‰…-βŠ’β‚‚-β‡’-≑ (f₁≅fβ‚‚ t)) ] where open Term-like Tβ‚‚ using () renaming (β‰…-⊒-β‡’-≑ to β‰…-βŠ’β‚‚-β‡’-≑) ext₁ : E.Extensionality (i βŠ” u βŠ” e) (t₁ βŠ” tβ‚‚) ext₁ = E.lower-extensionality t₁ Level.zero ext extβ‚‚ : E.Extensionality t₁ tβ‚‚ extβ‚‚ = E.lower-extensionality (i βŠ” u βŠ” e) t₁ ext extensional-equalityβ‚‚ : βˆ€ {t₁ tβ‚‚} {T₁ : Term-like t₁} {Tβ‚‚ : Term-like tβ‚‚} β†’ let open Term-like T₁ renaming (_β‰…-⊒_ to _β‰…-βŠ’β‚_; _⊒_ to _βŠ’β‚_) open Term-like Tβ‚‚ renaming (_β‰…-⊒_ to _β‰…-βŠ’β‚‚_) in E.Extensionality (i βŠ” u βŠ” e βŠ” t₁) (t₁ βŠ” tβ‚‚) β†’ βˆ€ {Γ₁ Δ₁} {ρ̂₁ : Γ₁ ⇨̂ Δ₁} {f₁ : [ T₁ ⟢ Tβ‚‚ ] ρ̂₁} {Ξ“β‚‚ Ξ”β‚‚} {ρ̂₂ : Ξ“β‚‚ ⇨̂ Ξ”β‚‚} {fβ‚‚ : [ T₁ ⟢ Tβ‚‚ ] ρ̂₂} β†’ ρ̂₁ β‰…-⇨̂ ρ̂₂ β†’ (βˆ€ {σ₁} {t₁ : Γ₁ βŠ’β‚ σ₁} {Οƒβ‚‚} {tβ‚‚ : Ξ“β‚‚ βŠ’β‚ Οƒβ‚‚} β†’ t₁ β‰…-βŠ’β‚ tβ‚‚ β†’ f₁ Β· t₁ β‰…-βŠ’β‚‚ fβ‚‚ Β· tβ‚‚) β†’ f₁ β‰…-⟢ fβ‚‚ extensional-equalityβ‚‚ {T₁ = T₁} ext P.refl f₁≅fβ‚‚ = extensional-equality₁ ext P.refl (Ξ» t β†’ f₁≅fβ‚‚ (P.refl {x = [ t ]})) where open Term-like T₁ using ([_]) -- lift ∘ weakenβˆ‹ sort of commutes with a lifted version of itself. lift-weakenβˆ‹-lift-lift-weakenβˆ‹ : βˆ€ {Ξ“} Οƒ Γ⁺ Ο„ Γ⁺⁺ {Ο…} (x : Ξ“ ++⁺ Γ⁺ ++⁺ Γ⁺⁺ βˆ‹ Ο…) β†’ lift weakenβˆ‹[ Ο„ /Μ‚ wΜ‚k ↑̂⁺ Γ⁺ ] (Γ⁺⁺ /̂⁺ wΜ‚k ↑̂⁺ Γ⁺) Β· (lift (lift weakenβˆ‹[ Οƒ ] Γ⁺) Γ⁺⁺ Β· x) β‰…-βˆ‹ lift (lift weakenβˆ‹[ Οƒ ] (Γ⁺ β–» Ο„)) (Γ⁺⁺ /̂⁺ wΜ‚k) Β· (lift weakenβˆ‹[ Ο„ ] Γ⁺⁺ Β· x) lift-weakenβˆ‹-lift-lift-weakenβˆ‹ Οƒ Γ⁺ Ο„ Ξ΅ x = P.refl lift-weakenβˆ‹-lift-lift-weakenβˆ‹ Οƒ Γ⁺ Ο„ (Γ⁺⁺ β–» Ο…) zero = zero-cong (/Μ‚-↑̂⁺-/Μ‚-wΜ‚k-↑̂⁺ Ο„ (wΜ‚k ↑̂⁺ Γ⁺) Γ⁺⁺ Ο…) lift-weakenβˆ‹-lift-lift-weakenβˆ‹ Οƒ Γ⁺ Ο„ (Γ⁺⁺ β–» Ο…) (suc x) = suc-cong (/Μ‚-↑̂⁺-/Μ‚-wΜ‚k-↑̂⁺ Ο„ (wΜ‚k ↑̂⁺ Γ⁺) Γ⁺⁺ Ο…) (lift-weakenβˆ‹-lift-lift-weakenβˆ‹ Οƒ Γ⁺ Ο„ Γ⁺⁺ x) ------------------------------------------------------------------------ -- Term-likeΒ t and [_⟢_] form a category -- At least if we ignore the context morphism index. -- Identity. [id] : βˆ€ {t} {T : Term-like t} {Ξ“} β†’ [ T ⟢ T ] iΜ‚d[ Ξ“ ] [id] = record { function = Ξ» _ β†’ id; corresponds = Ξ» _ _ β†’ P.refl } -- Composition. infixl 9 _[∘]_ _[∘]_ : βˆ€ {t₁ tβ‚‚ t₃} {T₁ : Term-like t₁} {Tβ‚‚ : Term-like tβ‚‚} {T₃ : Term-like t₃} {Ξ“ Ξ” Ξ•} {ρ̂₁ : Ξ“ ⇨̂ Ξ”} {ρ̂₂ : Ξ” ⇨̂ Ξ•} β†’ [ Tβ‚‚ ⟢ T₃ ] ρ̂₂ β†’ [ T₁ ⟢ Tβ‚‚ ] ρ̂₁ β†’ [ T₁ ⟢ T₃ ] (ρ̂₁ βˆ˜Μ‚ ρ̂₂) _[∘]_ {T₁ = T₁} {Tβ‚‚} {T₃} {ρ̂₁ = ρ̂₁} {ρ̂₂} f g = record { function = Ξ» _ β†’ _Β·_ f ∘ _Β·_ g ; corresponds = corr } where open P.≑-Reasoning open Term-like T₁ renaming (⟦_⟧ to ⟦_βŸ§β‚; _⊒_ to _βŠ’β‚_) open Term-like Tβ‚‚ renaming (⟦_⟧ to ⟦_βŸ§β‚‚) open Term-like T₃ renaming (⟦_⟧ to ⟦_βŸ§β‚ƒ) abstract corr : βˆ€ Οƒ (t : _ βŠ’β‚ Οƒ) β†’ ⟦ t βŸ§β‚ /Μ‚Val ρ̂₁ βˆ˜Μ‚ ρ̂₂ β‰…-Value ⟦ f Β· (g Β· t) βŸ§β‚ƒ corr = Ξ» Οƒ t β†’ begin [ ⟦ t βŸ§β‚ /Μ‚Val ρ̂₁ βˆ˜Μ‚ ρ̂₂ ] β‰‘βŸ¨ /Μ‚Val-cong (corresponds g t) P.refl ⟩ [ ⟦ g Β· t βŸ§β‚‚ /Μ‚Val ρ̂₂ ] β‰‘βŸ¨ corresponds f (g Β· t) ⟩ [ ⟦ f Β· (g Β· t) βŸ§β‚ƒ ] ∎ -- [id] and _[∘]_ preserve equality. [id]-cong : βˆ€ {t} {T : Term-like t} {Γ₁ Ξ“β‚‚} β†’ Γ₁ β‰…-Ctxt Ξ“β‚‚ β†’ [id] {T = T} {Ξ“ = Γ₁} β‰…-⟢ [id] {T = T} {Ξ“ = Ξ“β‚‚} [id]-cong P.refl = [ P.refl ] private module Dummy {t₁ tβ‚‚} {T₁ : Term-like t₁} {Tβ‚‚ : Term-like tβ‚‚} where [∘]-cong : βˆ€ {t₃} {T₃ : Term-like t₃} {Γ₁ Δ₁ Ε₁} {ρ̂₁₁ : Γ₁ ⇨̂ Δ₁} {ρ̂₂₁ : Δ₁ ⇨̂ Ε₁} {f₁₁ : [ T₁ ⟢ Tβ‚‚ ] ρ̂₁₁} {f₂₁ : [ Tβ‚‚ ⟢ T₃ ] ρ̂₂₁} {Ξ“β‚‚ Ξ”β‚‚ Ξ•β‚‚} {ρ̂₁₂ : Ξ“β‚‚ ⇨̂ Ξ”β‚‚} {ρ̂₂₂ : Ξ”β‚‚ ⇨̂ Ξ•β‚‚} {f₁₂ : [ T₁ ⟢ Tβ‚‚ ] ρ̂₁₂} {fβ‚‚β‚‚ : [ Tβ‚‚ ⟢ T₃ ] ρ̂₂₂} β†’ f₁₁ β‰…-⟢ f₁₂ β†’ f₂₁ β‰…-⟢ fβ‚‚β‚‚ β†’ f₂₁ [∘] f₁₁ β‰…-⟢ fβ‚‚β‚‚ [∘] f₁₂ [∘]-cong {f₁₁ = _ , _} {f₂₁ = _ , _} {f₁₂ = ._ , _} {fβ‚‚β‚‚ = ._ , _} [ P.refl ] [ P.refl ] = [ P.refl ] -- [id] is a left and right identity of _[∘]_, which is associative. [id]-[∘] : βˆ€ {Ξ“ Ξ”} {ρ̂ : Ξ“ ⇨̂ Ξ”} (f : [ T₁ ⟢ Tβ‚‚ ] ρ̂) β†’ [id] [∘] f β‰…-⟢ f [id]-[∘] f = [ P.refl ] [∘]-[id] : βˆ€ {Ξ“ Ξ”} {ρ̂ : Ξ“ ⇨̂ Ξ”} (f : [ T₁ ⟢ Tβ‚‚ ] ρ̂) β†’ f [∘] [id] β‰…-⟢ f [∘]-[id] f = [ P.refl ] [∘]-[∘] : βˆ€ {t₃ tβ‚„} {T₃ : Term-like t₃} {Tβ‚„ : Term-like tβ‚„} {Ξ“ Ξ” Ξ• Ξ–} {ρ̂₁ : Ξ“ ⇨̂ Ξ”} {ρ̂₂ : Ξ” ⇨̂ Ξ•} {ρ̂₃ : Ξ• ⇨̂ Ξ–} (f₃ : [ T₃ ⟢ Tβ‚„ ] ρ̂₃) (fβ‚‚ : [ Tβ‚‚ ⟢ T₃ ] ρ̂₂) (f₁ : [ T₁ ⟢ Tβ‚‚ ] ρ̂₁) β†’ f₃ [∘] (fβ‚‚ [∘] f₁) β‰…-⟢ (f₃ [∘] fβ‚‚) [∘] f₁ [∘]-[∘] f₃ fβ‚‚ f₁ = [ P.refl ] open Dummy public
{ "alphanum_fraction": 0.4594773953, "avg_line_length": 32.4059139785, "ext": "agda", "hexsha": "3cbf85d0a8cc0b227de995674128d4f31c156fef", "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": "498f8aefc570f7815fd1d6616508eeb92c52abce", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/dependently-typed-syntax", "max_forks_repo_path": "deBruijn/Context/Term-like.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "498f8aefc570f7815fd1d6616508eeb92c52abce", "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/dependently-typed-syntax", "max_issues_repo_path": "deBruijn/Context/Term-like.agda", "max_line_length": 97, "max_stars_count": 5, "max_stars_repo_head_hexsha": "498f8aefc570f7815fd1d6616508eeb92c52abce", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/dependently-typed-syntax", "max_stars_repo_path": "deBruijn/Context/Term-like.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-08T22:51:36.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-16T12:14:44.000Z", "num_tokens": 6147, "size": 12055 }
module Logic.Propositional.Proofs.Structures where import Data.Tuple as Tuple import Lvl open import Functional open import Logic open import Logic.Propositional import Logic.Propositional.Theorems as Theorems open import Structure.Operator.Properties open import Structure.Relator.Equivalence open import Structure.Relator.Properties open import Structure.Setoid open import Type open import Logic.Propositional.Equiv public private variable β„“ ℓ₁ β„“β‚‚ β„“β‚‘ ℓₑ₁ β„“β‚‘β‚‚ : Lvl.Level private variable T A B : Type{β„“} instance [β†’]-reflexivity : Reflexivity{β„“β‚‚ = β„“}(_β†’αΆ _) [β†’]-reflexivity = intro Theorems.[β†’]-reflexivity instance [β†’]-transitivity : Transitivity{β„“β‚‚ = β„“}(_β†’αΆ _) [β†’]-transitivity = intro Theorems.[β†’]-transitivity module _ where [←]-reflexivity : Reflexivity{β„“β‚‚ = β„“}(_←_) [←]-reflexivity = intro Theorems.[β†’]-reflexivity module _ where [←]-transitivity : Transitivity{β„“β‚‚ = β„“}(_←_) [←]-transitivity = intro (swap Theorems.[β†’]-transitivity) instance [↔]-antisymmetry : Antisymmetry{β„“β‚‚ = β„“}(_β†’αΆ _)(_↔_) [↔]-antisymmetry = intro(swap [↔]-intro) open import Structure.Relator open import Structure.Function open import Structure.Operator module _ ⦃ equiv : Equiv{β„“β‚‘}(T) ⦄ {P : T β†’ Type{β„“}} where relator-function₁ : UnaryRelator(P) ↔ Function ⦃ equiv-B = [↔]-equiv ⦄ (P) UnaryRelator.substitution (Tuple.left relator-function₁ (intro congruence)) xy = [↔]-to-[β†’] (congruence xy) Function.congruence (Tuple.right relator-function₁ (intro substitution)) xy = [↔]-intro (substitution(symmetry(_≑_) xy)) (substitution xy) module _ ⦃ equiv-A : Equiv{ℓₑ₁}(A) ⦄ ⦃ equiv-B : Equiv{β„“β‚‘β‚‚}(B) ⦄ {P : A β†’ B β†’ Type{β„“}} where relator-functionβ‚‚ : BinaryRelator(P) ↔ BinaryOperator ⦃ equiv-B = [↔]-equiv ⦄ (P) BinaryRelator.substitution (Tuple.left relator-functionβ‚‚ (intro congruence)) xy1 xy2 = [↔]-to-[β†’] (congruence xy1 xy2) BinaryOperator.congruence (Tuple.right relator-functionβ‚‚ (intro substitution)) xy1 xy2 = [↔]-intro (substitution(symmetry(_≑_) xy1) (symmetry(_≑_) xy2)) (substitution xy1 xy2) {- TODO: Maybe a general Equiv and Transitivity for (_↔_) is possible with indexed relation structures? What I mean by indexed: test : βˆ€{ℓ₁ β„“β‚‚}{T : TYPE ℓ₁}{β„“ : T β†’ Lvl.Level} β†’ ((x : T) β†’ TYPE(β„“ x)) β†’ TYPE β„“β‚‚ test2 : TYPE Lvl.𝟎 test2 = test{T = Lvl.Level}{β„“ = Lvl.𝐒} (\β„“ β†’ TYPE β„“) instead of: test : βˆ€{ℓ₁ β„“β‚‚}{T : TYPE ℓ₁}{β„“ : Lvl.Level} β†’ TYPE β„“ β†’ TYPE β„“β‚‚ Then all special cases for (_β†’_) and (_↔_) would finally be redundant. Also, substitution could be a special case of congruence, so *Relator would be special cases of *Operator -} instance [∧]-symmetry : Symmetry{β„“β‚‚ = β„“}(_∧_) [∧]-symmetry = intro Theorems.[∧]-symmetry instance [∨]-symmetry : Symmetry{β„“β‚‚ = β„“}(_∨_) [∨]-symmetry = intro Theorems.[∨]-symmetry instance [∧][↔]-sub : (_∧_) βŠ†β‚‚ (_↔_ {ℓ₁}{β„“β‚‚}) [∧][↔]-sub = intro Theorems.[∧]-to-[↔] instance [∧][β†’]-sub : (_∧_) βŠ†β‚‚ (_β†’αΆ _ {ℓ₁}{β„“β‚‚}) [∧][β†’]-sub = intro Theorems.[∧]-to-[β†’] instance [∧][←]-sub : (_∧_) βŠ†β‚‚ (_←_ {ℓ₁}{β„“β‚‚}) [∧][←]-sub = intro Theorems.[∧]-to-[←] instance [∧][∨]-sub : (_∧_) βŠ†β‚‚ (_∨_ {ℓ₁}{β„“β‚‚}) [∧][∨]-sub = intro Theorems.[∧]-to-[∨] instance [∧]-associativity : Associativity ⦃ [↔]-equiv ⦄ (_∧_ {β„“}) [∧]-associativity = intro Theorems.[∧]-associativity instance [∧]-operator : BinaryOperator ⦃ [↔]-equiv{ℓ₁} ⦄ ⦃ [↔]-equiv{β„“β‚‚} ⦄ ⦃ [↔]-equiv ⦄ (_∧_) BinaryOperator.congruence [∧]-operator = Theorems.[∧]-map-[↔] instance [∨]-operator : BinaryOperator ⦃ [↔]-equiv{ℓ₁} ⦄ ⦃ [↔]-equiv{β„“β‚‚} ⦄ ⦃ [↔]-equiv ⦄ (_∨_) BinaryOperator.congruence [∨]-operator = Theorems.[∨]-map-[↔] instance [β†’]-operator : BinaryOperator ⦃ [↔]-equiv{ℓ₁} ⦄ ⦃ [↔]-equiv{β„“β‚‚} ⦄ ⦃ [↔]-equiv ⦄ (_β†’αΆ _) BinaryOperator.congruence [β†’]-operator = Theorems.[β†’]-map-[↔] instance [↔]-operator : BinaryOperator ⦃ [↔]-equiv{ℓ₁} ⦄ ⦃ [↔]-equiv{β„“β‚‚} ⦄ ⦃ [↔]-equiv ⦄ (_↔_) BinaryOperator.congruence [↔]-operator = Theorems.[↔]-map-[↔]
{ "alphanum_fraction": 0.6533945891, "avg_line_length": 35.9449541284, "ext": "agda", "hexsha": "99e83434143373e9ac593b8fd86591bfb5ae0da3", "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": "Logic/Propositional/Proofs/Structures.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": "Logic/Propositional/Proofs/Structures.agda", "max_line_length": 178, "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": "Logic/Propositional/Proofs/Structures.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": 1586, "size": 3918 }
{-# OPTIONS --prop --rewriting #-} module Examples.Sorting.Parallel where open import Examples.Sorting.Parallel.Comparable open import Calf costMonoid open import Calf.Types.Nat open import Calf.Types.List open import Relation.Binary.PropositionalEquality as Eq using (_≑_) open import Data.Product using (_,_) open import Data.Nat using (z≀n; s≀s) test/forward = 1 ∷ 2 ∷ 3 ∷ 4 ∷ 5 ∷ 6 ∷ 7 ∷ 8 ∷ 9 ∷ 10 ∷ 11 ∷ 12 ∷ 13 ∷ 14 ∷ 15 ∷ 16 ∷ [] test/backward = 16 ∷ 15 ∷ 14 ∷ 13 ∷ 12 ∷ 11 ∷ 10 ∷ 9 ∷ 8 ∷ 7 ∷ 6 ∷ 5 ∷ 4 ∷ 3 ∷ 2 ∷ 1 ∷ [] test/shuffled = 4 ∷ 8 ∷ 12 ∷ 16 ∷ 13 ∷ 3 ∷ 5 ∷ 14 ∷ 9 ∷ 6 ∷ 7 ∷ 10 ∷ 11 ∷ 1 ∷ 2 ∷ 15 ∷ [] module Ex/InsertionSort where import Examples.Sorting.Parallel.InsertionSort NatComparable as Sort list' = list nat ex/insert : cmp (F list') ex/insert = Sort.insert 3 (1 ∷ 2 ∷ 4 ∷ []) ex/sort : cmp (F list') ex/sort = Sort.sort (1 ∷ 5 ∷ 3 ∷ 1 ∷ 2 ∷ []) ex/sort/forward : cmp (F list') ex/sort/forward = Sort.sort test/forward -- cost: 15 , 15 ex/sort/backward : cmp (F list') ex/sort/backward = Sort.sort test/backward -- cost: 120 , 120 ex/sort/shuffled : cmp (F list') ex/sort/shuffled = Sort.sort test/shuffled -- cost: 76 , 76 module Ex/MergeSort where import Examples.Sorting.Parallel.MergeSort NatComparable as Sort list' = list nat ex/split : cmp (F Sort.pair) ex/split = Sort.split (6 ∷ 2 ∷ 8 ∷ 3 ∷ 1 ∷ 8 ∷ 5 ∷ []) ex/merge : cmp (F list') ex/merge = Sort.merge (2 ∷ 3 ∷ 6 ∷ 8 ∷ [] , 1 ∷ 5 ∷ 8 ∷ []) ex/sort : cmp (F list') ex/sort = Sort.sort (1 ∷ 5 ∷ 3 ∷ 1 ∷ 2 ∷ []) ex/sort/forward : cmp (F list') ex/sort/forward = Sort.sort test/forward -- cost: 32, 15 ex/sort/backward : cmp (F list') ex/sort/backward = Sort.sort test/backward -- cost: 32, 15 ex/sort/shuffled : cmp (F list') ex/sort/shuffled = Sort.sort test/shuffled -- cost: 47, 26 module Ex/MergeSortPar where import Examples.Sorting.Parallel.MergeSortPar NatComparable as Sort list' = list nat ex/split : cmp (F Sort.pair) ex/split = Sort.split (6 ∷ 2 ∷ 8 ∷ 3 ∷ 1 ∷ 8 ∷ 5 ∷ []) ex/splitMid : cmp (F Sort.triple) ex/splitMid = Sort.splitMid test/forward (s≀s z≀n) ex/splitBy : cmp (F Sort.pair) ex/splitBy = Sort.splitBy test/forward 5 ex/merge : cmp (F list') ex/merge = Sort.merge (2 ∷ 3 ∷ 6 ∷ 8 ∷ [] , 1 ∷ 5 ∷ 8 ∷ []) ex/sort : cmp (F list') ex/sort = Sort.sort (1 ∷ 5 ∷ 3 ∷ 1 ∷ 2 ∷ []) ex/sort/forward : cmp (F list') ex/sort/forward = Sort.sort test/forward -- cost: 40, 21 ex/sort/backward : cmp (F list') ex/sort/backward = Sort.sort test/backward -- cost: 40, 21 ex/sort/shuffled : cmp (F list') ex/sort/shuffled = Sort.sort test/shuffled -- cost: 43, 17 module SortEquivalence (M : Comparable) where open Comparable M open import Examples.Sorting.Parallel.Core M import Examples.Sorting.Parallel.InsertionSort M as ISort import Examples.Sorting.Parallel.MergeSort M as MSort import Examples.Sorting.Parallel.MergeSortPar M as PSort isort≑msort : β—― (ISort.sort ≑ MSort.sort) isort≑msort = IsSort⇒≑ ISort.sort ISort.sort/correct MSort.sort MSort.sort/correct msort≑psort : β—― (MSort.sort ≑ PSort.sort) msort≑psort = IsSort⇒≑ MSort.sort MSort.sort/correct PSort.sort PSort.sort/correct
{ "alphanum_fraction": 0.6391465677, "avg_line_length": 31.0961538462, "ext": "agda", "hexsha": "1a796c9bfdc15dc94d53d24daa3d43c197ffcebb", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-01-29T08:12:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-10-06T10:28:24.000Z", "max_forks_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "jonsterling/agda-calf", "max_forks_repo_path": "src/Examples/Sorting/Parallel.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "jonsterling/agda-calf", "max_issues_repo_path": "src/Examples/Sorting/Parallel.agda", "max_line_length": 89, "max_stars_count": 29, "max_stars_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "jonsterling/agda-calf", "max_stars_repo_path": "src/Examples/Sorting/Parallel.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T20:35:11.000Z", "max_stars_repo_stars_event_min_datetime": "2021-07-14T03:18:28.000Z", "num_tokens": 1266, "size": 3234 }
module Day3 where open import Data.String as String open import Data.Maybe open import Foreign.Haskell using (Unit) open import Data.List as List hiding (fromMaybe) open import Data.Nat open import Data.Nat.DivMod open import Data.Nat.Properties import Data.Nat.Show as β„•s open import Data.Char open import Data.Vec as Vec renaming (_>>=_ to _VV=_ ; toList to VecToList) open import Data.Product open import Relation.Nullary open import Data.Nat.Properties open import Data.Bool.Base open import AocIO open import AocUtil open import AocVec open import Relation.Binary.PropositionalEquality open import EvenOdd printUsage : String β†’ IO Unit printUsage name = printString ("Usage: " String.++ name String.++ " NUMBER\n(NUMBER > 0)") sqr : (l : β„•) β†’ Ξ£[ k ∈ β„• ] (k ≑ l * l) sqr l = l * l , refl first-larger-odd-square : {m : β„•} β†’ (n : β„•) β†’ suc m ≑ n β†’ Ξ£[ k ∈ β„• ] (n ≀ (k * k) Γ— Odd k) first-larger-odd-square {m} n n-is-suc = helper 1 m n-is-suc oddOne where helper : (m diff : β„•) β†’ (m + diff) ≑ n β†’ Odd m β†’ Ξ£[ k ∈ β„• ] (n ≀ (k * k) Γ— Odd k) helper m (suc (suc diff)) p m-is-odd with sqr m ... | (mΒ² , m²≑m*m) with n ≀? mΒ² ... | yes n≀mΒ² rewrite m²≑m*m = m , n≀mΒ² , m-is-odd ... | no _ = helper (suc (suc m)) diff rewr-p (oddSuc m-is-odd) where rewr-p : suc (suc m + diff) ≑ n rewr-p with (+-suc m diff) | (+-suc m (suc diff)) ... | s | t rewrite (sym s) | t = p helper m zero p m-is-odd rewrite (+-identityΚ³ m) with (sqr m) ... | (mΒ² , q) = m , (my-proof n refl) , m-is-odd where my-proof : (k : β„•) β†’ k ≑ n β†’ n ≀ m * m my-proof k p₁ rewrite sym p₁ with k ... | zero = z≀n ... | suc kk rewrite p with (m≀m+n kk (kk * suc kk)) ... | kk≀kk+junk = s≀s kk≀kk+junk helper zero (suc zero) p () helper (suc zero) (suc zero) p m-is-odd rewrite sym p = 3 , (s≀s (s≀s z≀n) , oddSuc oddOne) helper (suc (suc m)) (suc zero) p m-is-odd = (suc (suc m)) , my-proof n refl , m-is-odd where my-proof : (k : β„•) β†’ k ≑ n β†’ n ≀ suc (suc (m + suc (suc (m + m * suc (suc m))))) my-proof k p₁ rewrite sym p₁ with k ... | zero = z≀n -- we replace with p and get an expression 1 + m ≀ suc (suc m + junk) -- +-comm m 1 turns 1 + m into suc m -- sym +-suc turns m + suc junk into suc (m + junk) to match the number on the other side -- finally we cancel suc on both sides and use m ≀ m + junk ... | suc kk rewrite sym p | +-comm m 1 | +-suc m (suc (m + m * suc (suc m))) = s≀s (s≀s (s≀s (m≀m+n m (suc (m + m * suc (suc m)))))) oddness : βˆ€ {n} β†’ Odd n β†’ β„• oddness oddOne = 1 oddness (oddSuc v) = suc (oddness v) ring-for-square# : {m : β„•} β†’ (n : β„•) β†’ suc m ≑ n β†’ Ξ£[ k ∈ β„• ] Odd k Γ— β„• ring-for-square# zero () ring-for-square# (suc n) p with (first-larger-odd-square (suc n) (cong suc refl)) ... | k , projβ‚„ , k-odd = k , k-odd , (oddness k-odd) ring-corners : {m : β„•} β†’ Odd m β†’ β„• Γ— β„• Γ— β„• Γ— β„• Γ— β„• ring-corners oddOne = 1 , (1 , (1 , 1 , 1)) ring-corners {(suc (suc n))} (oddSuc _) = (n * n) , ((proj₁ first-corner) , ((proj₁ second-corner) , ((proj₁ third-corner) , (proj₁ fourth-corner)))) where first-corner : Ξ£[ k ∈ β„• ] k ≑ suc ((n * n) + n) first-corner = suc (n * n + n) , refl second-corner : Ξ£[ k ∈ β„• ] k ≑ suc (suc ((n * n) + n + n)) second-corner = (suc (suc (n * n + n + n))) , refl third-corner : Ξ£[ k ∈ β„• ] k ≑ suc (suc (suc ((n * n) + n + n + n))) third-corner = suc (suc (suc (n * n + n + n + n))) , refl fourth-corner : Ξ£[ k ∈ β„• ] k ≑ suc (suc (n + suc (suc (n + n * suc (suc n))))) fourth-corner = sqr (suc (suc n)) ring-length : Ξ£[ k ∈ β„• ] k ≑ (2 * (suc (suc n))) + (2 * n) ring-length = (2 * (suc (suc n)) + 2 * n) , refl -- proof that fourth-corner = ring-length + prev-fourth-corner ring-length-proof : {m l : β„•} β†’ m ≑ suc (suc (n + suc (suc (n + n * suc (suc n))))) β†’ l ≑ (2 * (suc (suc n))) + (2 * n) β†’ l + (n * n) ≑ m ring-length-proof p q rewrite p | q = cong suc (cong suc my-proof) where halp : n + n + (n + n) ≑ n + n + n + n halp = begin n + n + (n + n) β‰‘βŸ¨ sym (+-assoc (n + n) n n) ⟩ n + n + n + n ∎ where open ≑-Reasoning halp-again : n * n + (n + n + n + n) ≑ n * n + n + n + n + n halp-again with +-assoc (n * n) (n + n + n) n ... | p₁ rewrite sym p₁ with +-assoc (n * n) (n + n) n ... | pβ‚‚ rewrite sym pβ‚‚ with +-assoc (n * n) n n ... | p₃ rewrite sym p₃ = refl my-proof : n + suc (suc (n + 0)) + (n + (n + 0)) + n * n ≑ n + suc (suc (n + n * suc (suc n))) my-proof rewrite +-identityΚ³ n | +-*-suc n (suc n) | +-*-suc n n with +-comm n (suc (suc n)) | +-comm n (suc (suc (n + (n + (n + n * n))))) ... | p₁ | pβ‚‚ rewrite p₁ | pβ‚‚ with +-comm n (n + n * n) | +-comm n (n + n * n + n) | +-comm n (n * n) | +-comm (n + n + (n + n)) (n * n) ... | p₃ | pβ‚„ | pβ‚… | p₆ rewrite p₃ | pβ‚„ | pβ‚… | p₆ | halp | halp-again = cong suc (cong suc refl) -- Here I'd like a proof that the distance between the corners add up to the length abs-diff : (n m : β„•) β†’ β„• abs-diff zero m = m abs-diff (suc n) zero = suc n abs-diff (suc n) (suc m) = abs-diff n m min-5 : (a b c d e : β„•) β†’ β„• min-5 a b c d e with a βŠ“ b | c βŠ“ d ... | min-ab | min-cd with min-ab βŠ“ min-cd ... | min-abcd = min-abcd βŠ“ e dist-to-closest-ring-corner : {k : β„•} β†’ (n : β„•) β†’ suc k ≑ n β†’ β„• dist-to-closest-ring-corner zero () dist-to-closest-ring-corner (suc k) p with (ring-for-square# (suc k) p) | (suc k) ... | corner-root , corner-root-odd , ring# | n with ring-corners corner-root-odd ... | cβ‚€ , c₁ , cβ‚‚ , c₃ , cβ‚„ with abs-diff n cβ‚€ | abs-diff n c₁ | abs-diff n cβ‚‚ | abs-diff n c₃ | abs-diff n cβ‚„ ... | n-cβ‚€ | n-c₁ | n-cβ‚‚ | n-c₃ | n-cβ‚„ = min-5 n-cβ‚€ n-c₁ n-cβ‚‚ n-c₃ n-cβ‚„ dist-to-center : {k : β„•} β†’ (n : β„•) β†’ suc k ≑ n β†’ β„• dist-to-center zero () dist-to-center (suc k) p with (ring-for-square# (suc k) p) | (suc k) ... | corner-root , corner-root-odd , ring# | n with dist-to-closest-ring-corner (suc k) refl ... | dist = abs-diff dist (2 * (pred ring#)) infixr 5 _+++_ _+++_ : String β†’ String β†’ String _+++_ s1 s2 = s1 String.++ " " String.++ s2 print-corners : {k : β„•} β†’ (n : β„•) β†’ suc k ≑ n β†’ IO Unit print-corners zero () print-corners (suc k) p with (ring-for-square# (suc k) p) | (suc k) ... | corner-root , corner-root-odd , ring# | n with ring-corners corner-root-odd ... | cβ‚€ , c₁ , cβ‚‚ , c₃ , cβ‚„ with abs-diff n cβ‚€ | abs-diff n c₁ | abs-diff n cβ‚‚ | abs-diff n c₃ | abs-diff n cβ‚„ ... | n-cβ‚€ | n-c₁ | n-cβ‚‚ | n-c₃ | n-cβ‚„ with β„•s.show n-cβ‚€ | β„•s.show n-c₁ | β„•s.show n-cβ‚‚ | β„•s.show n-c₃ | β„•s.show n-cβ‚„ | β„•s.show corner-root | β„•s.show ring# ... | s0 | s1 | s2 | s3 | s4 | s5 | s6 = printString (s0 +++ s1 +++ s2 +++ s3 +++ s4 +++ "==" +++ s5 +++ s6) main : IO Unit main = mainBuilder main' where main' : String β†’ (List String) β†’ IO Unit main' name (numS ∷ []) with (unsafeParseNat (String.toList numS)) ... | 0 = printUsage name ... | (suc n) = printString (β„•s.show (dist-to-center (suc n) (cong suc refl))) main' name _ = printUsage name
{ "alphanum_fraction": 0.5383426966, "avg_line_length": 46.2337662338, "ext": "agda", "hexsha": "82743da45bf400c2317d5ded5b0b2a0d1ab3db72", "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": "37956e581dc51bf78008d7dd902bb18d2ee481f6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Zalastax/adventofcode2017", "max_forks_repo_path": "day-3/Day3.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "37956e581dc51bf78008d7dd902bb18d2ee481f6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Zalastax/adventofcode2017", "max_issues_repo_path": "day-3/Day3.agda", "max_line_length": 154, "max_stars_count": null, "max_stars_repo_head_hexsha": "37956e581dc51bf78008d7dd902bb18d2ee481f6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Zalastax/adventofcode2017", "max_stars_repo_path": "day-3/Day3.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2778, "size": 7120 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT module experimental.NConnected where lemma₁ : βˆ€ {i j} {A : Type i} {B : Type j} (f : A β†’ B) {n : β„•β‚‹β‚‚} β†’ is-connected n A β†’ is-connected (S n) B β†’ has-conn-fibers n f lemma₁ f cA cB = Ξ» b β†’ Ξ£-conn cA (Ξ» a β†’ path-conn cB) lemmaβ‚‚ : βˆ€ {i} {A B C : Type i} β†’ (f : A β†’ B) (g : B β†’ C) {n : β„•β‚‹β‚‚} β†’ has-conn-fibers n (g ∘ f) β†’ has-conn-fibers (S n) g β†’ has-conn-fibers n f lemmaβ‚‚ f g {n} cA cB b = equiv-preserves-conn (eqv b idp ⁻¹) (lemma₁-fβ€² (g b) (b , idp)) where fβ€² : βˆ€ c β†’ hfiber (g ∘ f) c β†’ hfiber g c fβ€² c (a , p) = (f a , p) -- We first show [βˆ€ b β†’ is-connected n (hfiber (fβ€² (g b) (b , idp))) ] lemma₁-fβ€² : βˆ€ c β†’ has-conn-fibers n (fβ€² c) lemma₁-fβ€² c = lemma₁ (fβ€² c) (cA c) (cB c) -- The remaining shows [hfiber (fβ€² (g b) (b , idp))] -- is the same as [hfiber f b] to : βˆ€ b p β†’ hfiber f b β†’ hfiber (fβ€² (g b)) (b , p) to ._ p (a , idp) = ((a , p) , idp) fromβ€² : βˆ€ b a β†’ f a == b β†’ hfiber f b fromβ€² ._ a idp = (a , idp) from : βˆ€ b p β†’ hfiber (fβ€² (g b)) (b , p) β†’ hfiber f b from b p ((a , q) , r) = fromβ€² b a (fst= r) from-to : βˆ€ b p x β†’ from b p (to b p x) == x from-to ._ p (a , idp) = idp to-from : βˆ€ b p x β†’ to b p (from b p x) == x to-from b p ((a , q) , r) = to b p (from b p ((a , q) , r)) =⟨ pair=-Ξ· r |in-ctx (Ξ» r β†’ to b p (from b p ((a , q) , r))) ⟩ to b p (from b p ((a , q) , pair= (fst= r) (snd= r))) =⟨ lemma b p a q (fst= r) (snd= r) ⟩ ((a , q) , pair= (fst= r) (snd= r)) =⟨ ! (pair=-Ξ· r) |in-ctx (Ξ» r β†’ ((a , q) , r)) ⟩ ((a , q) , r) ∎ where lemma : βˆ€ b p a (q : g (f a) == g b) β†’ (r : f a == b) (s : q == p [ (Ξ» bβ€² β†’ g bβ€² == g b) ↓ r ]) β†’ to b p (from b p ((a , q) , pair= r s)) == ((a , q) , pair= r s) lemma ._ ._ a q idp idp = idp eqv : βˆ€ b p β†’ hfiber f b ≃ hfiber (fβ€² (g b)) (b , p) eqv b p = equiv (to b p) (from b p) (to-from b p) (from-to b p) lemma₃ : βˆ€ {i j} {A : Type i} {B : Type j} (f : A β†’ B) β†’ A ≃ Ξ£ B (hfiber f) lemma₃ {A = A} {B} f = equiv to from to-from from-to where to : A β†’ Ξ£ B (hfiber f) to a = (f a , (a , idp)) from : Ξ£ B (hfiber f) β†’ A from (_ , (a , p)) = a to-from : βˆ€ s β†’ to (from s) == s to-from (._ , (a , idp)) = idp from-to : βˆ€ a β†’ from (to a) == a from-to a = idp {- ∘-conn : βˆ€ {i j k} {A : Type i} {B : Type j} {C : Type k} β†’ (f : A β†’ B) β†’ (g : B β†’ C) β†’ {n : β„•β‚‹β‚‚} β†’ has-conn-fibers n f β†’ has-conn-fibers n g β†’ has-conn-fibers n (g ∘ f) ∘-conn f g {⟨-2⟩} cf cg c = -2-conn _ ∘-conn f g {S n } cf cg c = Trunc-rec {P = is-connected (hfiber (g ∘ f) c)} (prop-has-level-S n (is-connected-is-prop n A)) (Ξ» c ) (cg c) -} {- lemma₃-path : βˆ€ {i j} {A : Type i} {B : Type j} (f : A β†’ B) β†’ A == Ξ£ B (hfiber f) lemma₃-path = Ξ» f β†’ ua (lemma₃ f) -}
{ "alphanum_fraction": 0.4139922978, "avg_line_length": 31.7959183673, "ext": "agda", "hexsha": "df9db6d4aa8d7194f181591437946aacad07c90a", "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": "theorems/stash/NConnected.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": "theorems/stash/NConnected.agda", "max_line_length": 80, "max_stars_count": 294, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "theorems/stash/NConnected.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": 1314, "size": 3116 }
------------------------------------------------------------------------ -- The Agda standard library -- -- The basic code for equational reasoning with a single relation ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Relation.Binary module Relation.Binary.Reasoning.Base.Single {a β„“} {A : Set a} (_∼_ : Rel A β„“) (refl : Reflexive _∼_) (trans : Transitive _∼_) where ------------------------------------------------------------------------ -- Reasoning combinators -- Re-export combinators from partial reasoning open import Relation.Binary.Reasoning.Base.Partial _∼_ trans public hiding (_∎⟨_⟩) -- Redefine the terminating combinator now that we have reflexivity infix 3 _∎ _∎ : βˆ€ x β†’ x IsRelatedTo x x ∎ = relTo refl
{ "alphanum_fraction": 0.5185185185, "avg_line_length": 27, "ext": "agda", "hexsha": "d8957b78f6af00591f434601d511ccb510442274", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Relation/Binary/Reasoning/Base/Single.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Relation/Binary/Reasoning/Base/Single.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Relation/Binary/Reasoning/Base/Single.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": 180, "size": 810 }
{-# OPTIONS --universe-polymorphism #-} module Issue227 where open import Common.Level data D (a p b : Level) (A : Set a) (P : A β†’ Set p) : Set (p βŠ” a βŠ” b) where d : ((x : A) β†’ P x) β†’ D a p b A P -- Unsolved trivial constraint: Set (a βŠ” p) =< Set (p βŠ” a). OK : βˆ€ {a} {A : Set a} β†’ (A β†’ Set) β†’ A β†’ Set _ OK P = P NotOK : βˆ€ {a} {A : Set a} β†’ (P : A β†’ Set) β†’ A β†’ Set _ NotOK P = P -- Unsolved constraint: -- \/ (Set (a βŠ” suc zero)) (Set (a βŠ” suc zero)) = \/ (Set (a βŠ” suc zero)) (Set (a βŠ” suc zero))
{ "alphanum_fraction": 0.5138888889, "avg_line_length": 28, "ext": "agda", "hexsha": "b5334e00eb83db032381da85860d212407577c94", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/succeed/Issue227.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/Issue227.agda", "max_line_length": 94, "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/Issue227.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": 202, "size": 504 }
------------------------------------------------------------------------------ -- Induction principles for the total natural numbers inductive predicate ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.FOTC.Data.Nat.Type where open import FOTC.Base hiding ( succ₁ ) ------------------------------------------------------------------------------ -- We define succ₁ outside an abstract block. succ₁ : D β†’ D succ₁ n = succ Β· n module ConstantAndUnaryFunction where -- N using the constant succ. data N : D β†’ Set where nzero : N zero nsucc : βˆ€ {n} β†’ N n β†’ N (succ Β· n) N-ind : (A : D β†’ Set) β†’ A zero β†’ (βˆ€ {n} β†’ A n β†’ A (succ Β· n)) β†’ βˆ€ {n} β†’ N n β†’ A n N-ind A A0 h nzero = A0 N-ind A A0 h (nsucc Nn) = h (N-ind A A0 h Nn) -- N using the unary function succ₁. data N₁ : D β†’ Set where nzero₁ : N₁ zero nsucc₁ : βˆ€ {n} β†’ N₁ n β†’ N₁ (succ₁ n) N-ind₁ : (A : D β†’ Set) β†’ A zero β†’ (βˆ€ {n} β†’ A n β†’ A (succ₁ n)) β†’ βˆ€ {n} β†’ N₁ n β†’ A n N-ind₁ A A0 h nzero₁ = A0 N-ind₁ A A0 h (nsucc₁ Nn) = h (N-ind₁ A A0 h Nn) ---------------------------------------------------------------------------- -- From N/N₁ to N₁/N. Nβ†’N₁ : βˆ€ {n} β†’ N n β†’ N₁ n Nβ†’N₁ nzero = nzero₁ Nβ†’N₁ (nsucc {n} Nn) = nsucc₁ (Nβ†’N₁ Nn) N₁→N : βˆ€ {n} β†’ N₁ n β†’ N n N₁→N nzero₁ = nzero N₁→N (nsucc₁ {n} N₁n) = nsucc (N₁→N N₁n) ---------------------------------------------------------------------------- -- From N-ind β†’ N-ind₁. N-ind₁' : (A : D β†’ Set) β†’ A zero β†’ (βˆ€ {n} β†’ A n β†’ A (succ₁ n)) β†’ βˆ€ {n} β†’ N₁ n β†’ A n N-ind₁' A A0 h Nn₁ = N-ind A A0 h' (N₁→N Nn₁) where h' : βˆ€ {n} β†’ A n β†’ A (succ Β· n) h' {n} An = h An ---------------------------------------------------------------------------- -- From N-ind₁ β†’ N-ind. N-ind' : (A : D β†’ Set) β†’ A zero β†’ (βˆ€ {n} β†’ A n β†’ A (succ Β· n)) β†’ βˆ€ {n} β†’ N n β†’ A n N-ind' A A0 h Nn = N-ind₁ A A0 h' (Nβ†’N₁ Nn) where h' : βˆ€ {n} β†’ A n β†’ A (succ₁ n) h' {n} An = h An ------------------------------------------------------------------------------ module AdditionalHypotheis where data N : D β†’ Set where nzero : N zero nsucc : βˆ€ {n} β†’ N n β†’ N (succ₁ n) -- The induction principle generated by Coq 8.4pl4 when we define -- the data type N in Prop. N-ind₁ : (A : D β†’ Set) β†’ A zero β†’ (βˆ€ {n} β†’ N n β†’ A n β†’ A (succ₁ n)) β†’ βˆ€ {n} β†’ N n β†’ A n N-ind₁ A A0 h nzero = A0 N-ind₁ A A0 h (nsucc Nn) = h Nn (N-ind₁ A A0 h Nn) -- The induction principle removing the hypothesis N n from the -- inductive step (see Martin-LΓΆf 1971, p. 190). N-indβ‚‚ : (A : D β†’ Set) β†’ A zero β†’ (βˆ€ {n} β†’ A n β†’ A (succ₁ n)) β†’ βˆ€ {n} β†’ N n β†’ A n N-indβ‚‚ A A0 h nzero = A0 N-indβ‚‚ A A0 h (nsucc Nn) = h (N-indβ‚‚ A A0 h Nn) ---------------------------------------------------------------------------- -- N-indβ‚‚ from N-ind₁. N-indβ‚‚' : (A : D β†’ Set) β†’ A zero β†’ (βˆ€ {n} β†’ A n β†’ A (succ₁ n)) β†’ βˆ€ {n} β†’ N n β†’ A n N-indβ‚‚' A A0 h = N-ind₁ A A0 (Ξ» _ β†’ h) ---------------------------------------------------------------------------- -- N-ind₁ from N-indβ‚‚. N-ind₁' : (A : D β†’ Set) β†’ A zero β†’ (βˆ€ {n} β†’ N n β†’ A n β†’ A (succ₁ n)) β†’ βˆ€ {n} β†’ N n β†’ A n N-ind₁' A A0 h {n} Nn = ∧-projβ‚‚ (N-indβ‚‚ B B0 h' Nn) where B : D β†’ Set B n = N n ∧ A n B0 : B zero B0 = nzero , A0 h' : βˆ€ {m} β†’ B m β†’ B (succ₁ m) h' (Nm , Am) = nsucc Nm , h Nm Am ------------------------------------------------------------------------------ -- References -- -- Martin-LΓΆf, P. (1971). Hauptsatz for the Intuitionistic Theory of -- Iterated Inductive Definitions. In: Proceedings of the Second -- Scandinavian Logic Symposium. Ed. by Fenstad, -- J. E. Vol. 63. Studies in Logic and the Foundations of -- Mathematics. North-Holland Publishing Company, pp. 179–216.
{ "alphanum_fraction": 0.3912326184, "avg_line_length": 30.7463768116, "ext": "agda", "hexsha": "9028e7d935ee6ca0bd8b567c2b66bcf0a8bf64a2", "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/Nat/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": "notes/FOT/FOTC/Data/Nat/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": "notes/FOT/FOTC/Data/Nat/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": 1387, "size": 4243 }
{-# OPTIONS --without-K #-} open import HoTT.Base open import HoTT.Identity module HoTT.Homotopy where open variables private variable f g : A β†’ B -- Lemma 2.4.3 ~-natural : (Ξ± : f ~ g) {x y : A} (p : x == y) β†’ Ξ± x βˆ™ ap g p == ap f p βˆ™ Ξ± y ~-natural Ξ± {x} refl rewrite Ξ± x = refl ~-natural-id : (Ξ± : f ~ id) {x y : A} (p : x == y) β†’ Ξ± x βˆ™ p == ap f p βˆ™ Ξ± y ~-natural-id Ξ± {x} refl rewrite Ξ± x = refl -- Corollary 2.4.4 ~-natural-comm : {f : A β†’ A} (Ξ± : f ~ id) β†’ Ξ± ∘ f ~ ap f ∘ Ξ± ~-natural-comm {f = f} Ξ± x = cancelα΅£ (Ξ± (f x) βˆ™β‚— ap-id (Ξ± x) ⁻¹ βˆ™ ~-natural Ξ± (Ξ± x)) module ~-Reasoning where _~⟨_⟩_ : (f : Ξ  A P) {g h : Ξ  A P} β†’ f ~ g β†’ g ~ h β†’ f ~ h x ~⟨ Ξ± ⟩ Ξ² = Ξ± βˆ™β‚• Ξ² infixr 2 _~⟨_⟩_ _∎ : (f : Ξ  A P) β†’ f ~ f _ ∎ = reflβ‚• infix 3 _∎
{ "alphanum_fraction": 0.5066489362, "avg_line_length": 25.9310344828, "ext": "agda", "hexsha": "292c830abb899876b30072a04e35ddcba3c72600", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_forks_repo_licenses": [ "0BSD" ], "max_forks_repo_name": "michaelforney/hott", "max_forks_repo_path": "HoTT/Homotopy.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "0BSD" ], "max_issues_repo_name": "michaelforney/hott", "max_issues_repo_path": "HoTT/Homotopy.agda", "max_line_length": 84, "max_stars_count": null, "max_stars_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_stars_repo_licenses": [ "0BSD" ], "max_stars_repo_name": "michaelforney/hott", "max_stars_repo_path": "HoTT/Homotopy.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 349, "size": 752 }
module UniDB.Morph.Unit where open import UniDB.Spec -------------------------------------------------------------------------------- data Unit : MOR where unit : {Ξ³ : Dom} β†’ Unit Ξ³ Ξ³ instance iUpUnit : Up Unit _↑₁ {{iUpUnit}} unit = unit _↑_ {{iUpUnit}} unit Ξ΄ = unit ↑-zero {{iUpUnit}} unit = refl ↑-suc {{iUpUnit}} unit Ξ΄ = refl iIdmUnit : Idm Unit idm {{iIdmUnit}} _ = unit iCompUnit : Comp Unit _βŠ™_ {{iCompUnit}} unit unit = unit iUpIdmUnit : UpIdm Unit idm-↑₁ {{iUpIdmUnit}} = refl module _ {T : STX} {{vrT : Vr T}} where instance iLkUnit : Lk T Unit lk {{iLkUnit}} unit = vr {T = T} iLkUpUnit : {{wkT : Wk T}} {{wkVrT : WkVr T}} β†’ LkUp T Unit lk-↑₁-zero {{iLkUpUnit}} unit = refl lk-↑₁-suc {{iLkUpUnit}} unit i = sym (wk₁-vr {T = T} i) iLkIdmUnit : LkIdm T Unit lk-idm {{iLkIdmUnit}} i = refl --------------------------------------------------------------------------------
{ "alphanum_fraction": 0.4905263158, "avg_line_length": 23.1707317073, "ext": "agda", "hexsha": "f78293244babd44fc98db8ae5dde1f4e22bd165f", "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": "7ae52205db44ad4f463882ba7e5082120fb76349", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "skeuchel/unidb-agda", "max_forks_repo_path": "UniDB/Morph/Unit.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7ae52205db44ad4f463882ba7e5082120fb76349", "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": "skeuchel/unidb-agda", "max_issues_repo_path": "UniDB/Morph/Unit.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "7ae52205db44ad4f463882ba7e5082120fb76349", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "skeuchel/unidb-agda", "max_stars_repo_path": "UniDB/Morph/Unit.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 340, "size": 950 }
{-# OPTIONS --safe #-} module Cubical.Categories.Functor.Base where open import Cubical.Foundations.Prelude open import Cubical.Data.Sigma open import Cubical.Categories.Category private variable β„“C β„“C' β„“D β„“D' : Level record Functor (C : Category β„“C β„“C') (D : Category β„“D β„“D') : Type (β„“-max (β„“-max β„“C β„“C') (β„“-max β„“D β„“D')) where no-eta-equality open Category field F-ob : C .ob β†’ D .ob F-hom : {x y : C .ob} β†’ C [ x , y ] β†’ D [ F-ob x , F-ob y ] F-id : {x : C .ob} β†’ F-hom (C .id) ≑ D .id {x = F-ob x} F-seq : {x y z : C .ob} (f : C [ x , y ]) (g : C [ y , z ]) β†’ F-hom (f β‹†βŸ¨ C ⟩ g) ≑ (F-hom f) β‹†βŸ¨ D ⟩ (F-hom g) isFull = (x y : _) (F[f] : D [ F-ob x , F-ob y ]) β†’ βˆƒ[ f ∈ C [ x , y ] ] F-hom f ≑ F[f] isFaithful = (x y : _) (f g : C [ x , y ]) β†’ F-hom f ≑ F-hom g β†’ f ≑ g isEssentiallySurj = (d : D .ob) β†’ Ξ£[ c ∈ C .ob ] CatIso D (F-ob c) d private variable β„“ β„“' : Level C D E : Category β„“ β„“' open Category open Functor -- Helpful notation -- action on objects infix 30 _βŸ…_βŸ† _βŸ…_βŸ† : (F : Functor C D) β†’ C .ob β†’ D .ob _βŸ…_βŸ† = F-ob -- action on morphisms infix 30 _βŸͺ_⟫ -- same infix level as on objects since these will never be used in the same context _βŸͺ_⟫ : (F : Functor C D) β†’ βˆ€ {x y} β†’ C [ x , y ] β†’ D [(F βŸ… x βŸ†) , (F βŸ… y βŸ†)] _βŸͺ_⟫ = F-hom -- Functor constructions πŸ™βŸ¨_⟩ : βˆ€ (C : Category β„“ β„“') β†’ Functor C C πŸ™βŸ¨ C ⟩ .F-ob x = x πŸ™βŸ¨ C ⟩ .F-hom f = f πŸ™βŸ¨ C ⟩ .F-id = refl πŸ™βŸ¨ C ⟩ .F-seq _ _ = refl -- functor composition funcComp : βˆ€ (G : Functor D E) (F : Functor C D) β†’ Functor C E (funcComp G F) .F-ob c = G βŸ… F βŸ… c βŸ† βŸ† (funcComp G F) .F-hom f = G βŸͺ F βŸͺ f ⟫ ⟫ (funcComp G F) .F-id = cong (G βŸͺ_⟫) (F .F-id) βˆ™ G .F-id (funcComp G F) .F-seq f g = cong (G βŸͺ_⟫) (F .F-seq _ _) βˆ™ G .F-seq _ _ infixr 30 funcComp syntax funcComp G F = G ∘F F _^opF : Functor C D β†’ Functor (C ^op) (D ^op) (F ^opF) .F-ob = F .F-ob (F ^opF) .F-hom = F .F-hom (F ^opF) .F-id = F .F-id (F ^opF) .F-seq f g = F .F-seq g f
{ "alphanum_fraction": 0.513540128, "avg_line_length": 25.3875, "ext": "agda", "hexsha": "871dd6d72eba1d7958133aaa4c5dff4b3d7e0ff9", "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": "58f2d0dd07e51f8aa5b348a522691097b6695d1c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Seanpm2001-web/cubical", "max_forks_repo_path": "Cubical/Categories/Functor/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c", "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": "Seanpm2001-web/cubical", "max_issues_repo_path": "Cubical/Categories/Functor/Base.agda", "max_line_length": 98, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9acdecfa6437ec455568be4e5ff04849cc2bc13b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "FernandoLarrain/cubical", "max_stars_repo_path": "Cubical/Categories/Functor/Base.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-05T00:28:39.000Z", "max_stars_repo_stars_event_min_datetime": "2022-03-05T00:28:39.000Z", "num_tokens": 921, "size": 2031 }
module Prelude.Monoid where open import Prelude.Function open import Prelude.Maybe open import Prelude.List open import Prelude.Semiring open import Prelude.Semigroup public open import Prelude.Applicative open import Prelude.Functor open import Prelude.Equality open import Prelude.Variables record Monoid {a} (A : Set a) : Set a where field {{super}} : Semigroup A mempty : A open Monoid {{...}} public hiding (super) {-# DISPLAY Monoid.mempty _ = mempty #-} record Monoid/Laws {β„“} (A : Set β„“) : Set β„“ where field overlap {{super}} : Monoid A left-identity : (e : A) β†’ mempty <> e ≑ e right-identity : (e : A) β†’ e <> mempty ≑ e -- Using Semigroup/Laws instance creates inference problems -- Maby we can do this in a better way? monoid-assoc : (a b c : A) β†’ (a <> b) <> c ≑ a <> (b <> c) open Monoid/Laws {{...}} public hiding (super) mconcat : βˆ€ {a} {A : Set a} {{MonA : Monoid A}} β†’ List A β†’ A mconcat = foldr _<>_ mempty --- Instances --- instance MonoidList : βˆ€ {a} {A : Set a} β†’ Monoid (List A) Monoid.super MonoidList = it mempty {{MonoidList}} = [] MonoidFun : βˆ€ {a b} {A : Set a} {B : A β†’ Set b} {{_ : βˆ€ {x} β†’ Monoid (B x)}} β†’ Monoid (βˆ€ x β†’ B x) Monoid.super (MonoidFun {a} {b} {A} {B} {{SG}}) = SemigroupFun {a} {b} {A} {B} {{Monoid.super SG}} mempty {{MonoidFun}} _ = mempty MonoidMaybe : βˆ€ {a} {A : Set a} β†’ Monoid (Maybe A) Monoid.super MonoidMaybe = it mempty {{MonoidMaybe}} = nothing -- Temporarily here, better version comes in the list update Monoid/LawsList : Monoid/Laws (List A) Monoid/Laws.super Monoid/LawsList = it left-identity {{Monoid/LawsList}} _ = refl right-identity {{Monoid/LawsList}} [] = refl right-identity {{Monoid/LawsList}} (x ∷ xs) = cong (x ∷_) (right-identity xs) monoid-assoc {{Monoid/LawsList}} [] ys zs = refl monoid-assoc {{Monoid/LawsList}} (x ∷ xs) ys zs = cong (x ∷_) (monoid-assoc xs ys zs) record Sum {a} (A : Set a) : Set a where constructor mkSum field getSum : A open Sum public instance SemigroupSum : βˆ€ {a} {A : Set a} {{_ : Semiring A}} β†’ Semigroup (Sum A) getSum (_<>_ {{SemigroupSum}} x y) = getSum x + getSum y MonoidSum : βˆ€ {a} {A : Set a} {{_ : Semiring A}} β†’ Monoid (Sum A) Monoid.super MonoidSum = it getSum (mempty {{MonoidSum}}) = zro record Product {a} (A : Set a) : Set a where constructor mkProduct field getProduct : A open Product public instance SemigroupProduct : βˆ€ {a} {A : Set a} {{_ : Semiring A}} β†’ Semigroup (Product A) getProduct (_<>_ {{SemigroupProduct}} x y) = getProduct x * getProduct y MonoidProduct : βˆ€ {a} {A : Set a} {{_ : Semiring A}} β†’ Monoid (Product A) Monoid.super MonoidProduct = it getProduct (mempty {{MonoidProduct}}) = one record Const {a b} (A : Set a) (B : Set b) : Set a where constructor mkConst field getConst : A open Const public module _ {a b} {A : Set a} {{MonA : Monoid A}} where instance FunctorConst : Functor {a = b} (Const A) getConst (fmap {{FunctorConst}} f x) = getConst x ApplicativeConst : Applicative (Const A) getConst (pure {{ApplicativeConst}} x) = mempty getConst (_<*>_ {{ApplicativeConst}} wf wx) = getConst wf <> getConst wx
{ "alphanum_fraction": 0.6341917468, "avg_line_length": 29.3, "ext": "agda", "hexsha": "8cab9b38ab60c3a2800eef333c2fbf4d9403a3c8", "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/Monoid.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/Monoid.agda", "max_line_length": 99, "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/Monoid.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": 1084, "size": 3223 }
{-# OPTIONS --without-K #-} module T where open import Level open import Relation.Binary.PropositionalEquality using (_≑_; refl; sym; trans; cong; subst; module ≑-Reasoning) open import Data.Nat using (β„•; _+_) open import Data.Fin using (Fin) data Exp : Set where ONE : Exp PLUS : Exp β†’ Exp β†’ Exp val : Exp β†’ β„• val ONE = 1 val (PLUS e₁ eβ‚‚) = val e₁ + val eβ‚‚ data eqExp : Exp β†’ Exp β†’ Set where idExp : {e : Exp} β†’ eqExp e e transExp : {e₁ eβ‚‚ e₃ : Exp} β†’ (eqExp e₁ eβ‚‚) β†’ (eqExp eβ‚‚ e₃) β†’ (eqExp e₁ e₃) val≑ : {e₁ eβ‚‚ : Exp} β†’ (eqExp e₁ eβ‚‚) β†’ (val e₁ ≑ val eβ‚‚) val≑ idExp = refl val≑ (transExp α₁ Ξ±β‚‚) = trans (val≑ α₁) (val≑ Ξ±β‚‚) trans-assoc : {A : Set} {x y z w : A} β†’ (p : x ≑ y) (q : y ≑ z) (r : z ≑ w) β†’ trans (trans p q) r ≑ trans p (trans q r) trans-assoc refl refl refl = refl subst-trans : (P : β„• β†’ Set) (p : (n : β„•) β†’ P n) {e₁ eβ‚‚ e₃ : Exp} β†’ (Ξ± : eqExp e₁ eβ‚‚) (Ξ² : eqExp eβ‚‚ e₃) (v : P (val e₁)) β†’ subst P (trans (val≑ Ξ±) (val≑ Ξ²)) v ≑ subst P (val≑ Ξ²) (subst P (val≑ Ξ±) v) subst-trans P p idExp Ξ² v = refl subst-trans P p (transExp α₁ Ξ±β‚‚) Ξ² v = begin (subst P (trans (trans (val≑ α₁) (val≑ Ξ±β‚‚)) (val≑ Ξ²)) v β‰‘βŸ¨ cong (Ξ» x β†’ subst P x v) (trans-assoc (val≑ α₁) (val≑ Ξ±β‚‚) (val≑ Ξ²)) ⟩ subst P (trans (val≑ α₁) (trans (val≑ Ξ±β‚‚) (val≑ Ξ²))) v β‰‘βŸ¨ refl ⟩ subst P (trans (val≑ α₁) (val≑ (transExp Ξ±β‚‚ Ξ²))) v β‰‘βŸ¨ subst-trans P p α₁ (transExp Ξ±β‚‚ Ξ²) v ⟩ subst P (val≑ (transExp Ξ±β‚‚ Ξ²)) (subst P (val≑ α₁) v) β‰‘βŸ¨ refl ⟩ subst P (trans (val≑ Ξ±β‚‚) (val≑ Ξ²)) (subst P (val≑ α₁) v) β‰‘βŸ¨ subst-trans P p Ξ±β‚‚ Ξ² (subst P (val≑ α₁) v) ⟩ subst P (val≑ Ξ²) (subst P (val≑ Ξ±β‚‚) (subst P (val≑ α₁) v)) β‰‘βŸ¨ cong (Ξ» x β†’ subst P (val≑ Ξ²) x) (sym (subst-trans P p α₁ Ξ±β‚‚ v)) ⟩ subst P (val≑ Ξ²) (subst P (trans (val≑ α₁) (val≑ Ξ±β‚‚)) v) β‰‘βŸ¨ refl ⟩ subst P (val≑ Ξ²) (subst P (val≑ (transExp α₁ Ξ±β‚‚)) v) ∎) where open ≑-Reasoning pr : {P : β„• β†’ Set} {p : (n : β„•) β†’ P n} {e₁ eβ‚‚ : Exp} {Ξ± : eqExp e₁ eβ‚‚} β†’ subst P (val≑ Ξ±) (p (val e₁)) ≑ p (val eβ‚‚) pr {P} {p} {e} {.e} {idExp} = refl pr {P} {p} {e₁} {e₃} {transExp {eβ‚‚ = eβ‚‚} Ξ± Ξ²} = begin (subst P (val≑ (transExp Ξ± Ξ²)) (p (val e₁)) β‰‘βŸ¨ refl ⟩ subst P (trans (val≑ Ξ±) (val≑ Ξ²)) (p (val e₁)) β‰‘βŸ¨ subst-trans P p Ξ± Ξ² (p (val e₁)) ⟩ subst P (val≑ Ξ²) (subst P (val≑ Ξ±) (p (val e₁))) β‰‘βŸ¨ cong (Ξ» x β†’ subst P (val≑ Ξ²) x) (pr {P} {p} {e₁} {eβ‚‚} {Ξ±}) ⟩ subst P (val≑ Ξ²) (p (val eβ‚‚)) β‰‘βŸ¨ pr {P} {p} {eβ‚‚} {e₃} {Ξ²} ⟩ p (val e₃) ∎) where open ≑-Reasoning
{ "alphanum_fraction": 0.4915824916, "avg_line_length": 38.7391304348, "ext": "agda", "hexsha": "748581ee2fbf589898800b2383dba06650a18c59", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "Univalence/Obsolete/T.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "Univalence/Obsolete/T.agda", "max_line_length": 78, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "Univalence/Obsolete/T.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "num_tokens": 1186, "size": 2673 }
{- This file contains: - Some basic properties of Rijke finite types. -} {-# OPTIONS --safe #-} module Cubical.Data.FinType.Properties where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv open import Cubical.Foundations.Equiv.Properties open import Cubical.HITs.SetTruncation open import Cubical.Data.Nat open import Cubical.Data.FinSet open import Cubical.Data.FinSet.Constructors open import Cubical.Data.FinType.Base private variable β„“ β„“' : Level n : β„• X : Type β„“ Y : Type β„“' EquivPresIsFinType : (n : β„•) β†’ X ≃ Y β†’ isFinType n X β†’ isFinType n Y EquivPresIsFinType 0 e = EquivPresIsFinSet (isoToEquiv (setTruncIso (equivToIso e))) EquivPresIsFinType (suc n) e (p , q) .fst = EquivPresIsFinType 0 e p EquivPresIsFinType (suc n) e (p , q) .snd a b = EquivPresIsFinType n (invEquiv (congEquiv (invEquiv e))) (q _ _) isFinSetβ†’isFinType : (n : β„•) β†’ isFinSet X β†’ isFinType n X isFinSetβ†’isFinType 0 p = EquivPresIsFinSet (invEquiv (setTruncIdempotent≃ (isFinSetβ†’isSet p))) p isFinSetβ†’isFinType (suc n) p .fst = isFinSetβ†’isFinType 0 p isFinSetβ†’isFinType (suc n) p .snd a b = isFinSetβ†’isFinType n (isFinSet≑ (_ , p) _ _) isPathConnectedβ†’isFinType0 : isContr βˆ₯ X βˆ₯β‚‚ β†’ isFinType 0 X isPathConnectedβ†’isFinType0 p = isContrβ†’isFinSet p
{ "alphanum_fraction": 0.7441685478, "avg_line_length": 30.9069767442, "ext": "agda", "hexsha": "befeba15a6899449bba2ac710230efb970c2b9ae", "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/Data/FinType/Properties.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/Data/FinType/Properties.agda", "max_line_length": 96, "max_stars_count": 1, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/Data/FinType/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "num_tokens": 476, "size": 1329 }
{-# OPTIONS --universe-polymorphism #-} module Categories.Monoidal.Braided where open import Level open import Level using (_βŠ”_) open import Categories.Category open import Categories.Bifunctor using (Bifunctor) open import Categories.NaturalIsomorphism open import Categories.NaturalTransformation using (_βˆ˜β‚_) renaming (_≑_ to _≑ⁿ_) open import Categories.Monoidal.Helpers open import Categories.Monoidal.Braided.Helpers open import Categories.Monoidal record Braided {o β„“ e} {C : Category o β„“ e} (M : Monoidal C) : Set (o βŠ” β„“ βŠ” e) where private module C = Category C private module M = Monoidal M open C hiding (id; identityΛ‘; identityΚ³; assoc) open M open MonoidalHelperFunctors C βŠ— id open BraidedHelperFunctors C βŠ— id field braid : NaturalIsomorphism xβŠ—y yβŠ—x open Braiding identityΛ‘ identityΚ³ assoc braid field -- NB: Triangle is redundant, proof coming soon... .hexagon₁ : (Hexagon1SideB βˆ˜β‚ (Hexagon1TopB βˆ˜β‚ Hexagon1TopA)) ≑ⁿ (Hexagon1BottomB βˆ˜β‚ (Hexagon1BottomA βˆ˜β‚ Hexagon1SideA)) .hexagonβ‚‚ : (Hexagon2SideB βˆ˜β‚ (Hexagon2TopB βˆ˜β‚ Hexagon2TopA)) ≑ⁿ (Hexagon2BottomB βˆ˜β‚ (Hexagon2BottomA βˆ˜β‚ Hexagon2SideA))
{ "alphanum_fraction": 0.7519446845, "avg_line_length": 33.0571428571, "ext": "agda", "hexsha": "2e714243fd3fc13c6d03b09a1d4a0a25dc89bc3c", "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": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Categories/Monoidal/Braided.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "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": "p-pavel/categories", "max_issues_repo_path": "Categories/Monoidal/Braided.agda", "max_line_length": 124, "max_stars_count": 1, "max_stars_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "p-pavel/categories", "max_stars_repo_path": "Categories/Monoidal/Braided.agda", "max_stars_repo_stars_event_max_datetime": "2018-12-29T21:51:57.000Z", "max_stars_repo_stars_event_min_datetime": "2018-12-29T21:51:57.000Z", "num_tokens": 376, "size": 1157 }
module DaraisPhoas where open import Agda.Primitive using (_βŠ”_) module Prelude where infixr 3 βˆƒπ‘ π‘‘ infixl 5 _∨_ infixr 20 _∷_ data 𝔹 : Set where T : 𝔹 F : 𝔹 data _∨_ {ℓ₁ β„“β‚‚} (A : Set ℓ₁) (B : Set β„“β‚‚) : Set (ℓ₁ βŠ” β„“β‚‚) where Inl : A β†’ A ∨ B Inr : B β†’ A ∨ B syntax βˆƒπ‘ π‘‘ A (Ξ» x β†’ B) = βˆƒ x ⦂ A 𝑠𝑑 B data βˆƒπ‘ π‘‘ {ℓ₁ β„“β‚‚} (A : Set ℓ₁) (B : A β†’ Set β„“β‚‚) : Set (ℓ₁ βŠ” β„“β‚‚) where βŸ¨βˆƒ_,_⟩ : βˆ€ (x : A) β†’ B x β†’ βˆƒ x ⦂ A 𝑠𝑑 B x data ⟬_⟭ {β„“} (A : Set β„“) : Set β„“ where [] : ⟬ A ⟭ _∷_ : A β†’ ⟬ A ⟭ β†’ ⟬ A ⟭ open Prelude infixr 15 _βŸ¨β†’βŸ©_ data type : Set where βŸ¨β„•βŸ© : type _βŸ¨β†’βŸ©_ : type β†’ type β†’ type infixl 15 _βŸ¨βˆ™βŸ©_ data exp-phoas (var : type β†’ ⟬ type ⟭ β†’ Set) : βˆ€ (Ξ“ : ⟬ type ⟭) (Ο„ : type) β†’ Set where Var : βˆ€ {Ξ“ Ο„} (x : var Ο„ Ξ“) β†’ exp-phoas var Ξ“ Ο„ ⟨λ⟩ : βˆ€ {Ξ“ τ₁ Ο„β‚‚} (e : var τ₁ (τ₁ ∷ Ξ“) β†’ exp-phoas var (τ₁ ∷ Ξ“) Ο„β‚‚) β†’ exp-phoas var Ξ“ (τ₁ βŸ¨β†’βŸ© Ο„β‚‚) _βŸ¨βˆ™βŸ©_ : βˆ€ {Ξ“ τ₁ Ο„β‚‚} (e₁ : exp-phoas var Ξ“ (τ₁ βŸ¨β†’βŸ© Ο„β‚‚)) (eβ‚‚ : exp-phoas var Ξ“ τ₁) β†’ exp-phoas var Ξ“ Ο„β‚‚ infix 10 _∈_ data _∈_ {β„“} {A : Set β„“} (x : A) : βˆ€ (xs : ⟬ A ⟭) β†’ Set β„“ where Z : βˆ€ {xs} β†’ x ∈ x ∷ xs S : βˆ€ {xβ€² xs} β†’ x ∈ xs β†’ x ∈ xβ€² ∷ xs infix 10 _⊒_ data _⊒_ : βˆ€ (Ξ“ : ⟬ type ⟭) (Ο„ : type) β†’ Set where Var : βˆ€ {Ξ“ Ο„} (x : Ο„ ∈ Ξ“) β†’ Ξ“ ⊒ Ο„ ⟨λ⟩ : βˆ€ {Ξ“ τ₁ Ο„β‚‚} (e : τ₁ ∷ Ξ“ ⊒ Ο„β‚‚) β†’ Ξ“ ⊒ τ₁ βŸ¨β†’βŸ© Ο„β‚‚ _βŸ¨βˆ™βŸ©_ : βˆ€ {Ξ“ τ₁ Ο„β‚‚} (e₁ : Ξ“ ⊒ τ₁ βŸ¨β†’βŸ© Ο„β‚‚) (eβ‚‚ : Ξ“ ⊒ τ₁) β†’ Ξ“ ⊒ Ο„β‚‚ ⟦_βŸ§β‚ : βˆ€ {Ξ“ Ο„} (e : exp-phoas _∈_ Ξ“ Ο„) β†’ Ξ“ ⊒ Ο„ ⟦ Var x βŸ§β‚ = Var x ⟦ ⟨λ⟩ e βŸ§β‚ = ⟨λ⟩ ⟦ e Z βŸ§β‚ ⟦ e₁ βŸ¨βˆ™βŸ© eβ‚‚ βŸ§β‚ = ⟦ e₁ βŸ§β‚ βŸ¨βˆ™βŸ© ⟦ eβ‚‚ βŸ§β‚ ⟦_βŸ§β‚‚ : βˆ€ {Ξ“ Ο„} (e : Ξ“ ⊒ Ο„) β†’ exp-phoas _∈_ Ξ“ Ο„ ⟦ Var x βŸ§β‚‚ = Var x ⟦ ⟨λ⟩ e βŸ§β‚‚ = ⟨λ⟩ (Ξ» _ β†’ ⟦ e βŸ§β‚‚) ⟦ e₁ βŸ¨βˆ™βŸ© eβ‚‚ βŸ§β‚‚ = ⟦ e₁ βŸ§β‚‚ βŸ¨βˆ™βŸ© ⟦ eβ‚‚ βŸ§β‚‚ Ch : type Ch = (βŸ¨β„•βŸ© βŸ¨β†’βŸ© βŸ¨β„•βŸ©) βŸ¨β†’βŸ© βŸ¨β„•βŸ© βŸ¨β†’βŸ© βŸ¨β„•βŸ© twoDB : [] ⊒ Ch twoDB = ⟨λ⟩ (⟨λ⟩ (Var (S Z) βŸ¨βˆ™βŸ© (Var (S Z) βŸ¨βˆ™βŸ© Var Z))) twoPH : exp-phoas _∈_ [] Ch twoPH = ⟨λ⟩ (Ξ» f β†’ ⟨λ⟩ (Ξ» x β†’ Var f βŸ¨βˆ™βŸ© (Var f βŸ¨βˆ™βŸ© Var x))) {- /Users/wadler/sf/src/extra/DaraisPhoas.agda:82,9-60 βŸ¨β„•βŸ© βŸ¨β†’βŸ© βŸ¨β„•βŸ© != βŸ¨β„•βŸ© of type type when checking that the expression ⟨λ⟩ (Ξ» f β†’ ⟨λ⟩ (Ξ» x β†’ Var f βŸ¨βˆ™βŸ© (Var f βŸ¨βˆ™βŸ© Var x))) has type exp-phoas _∈_ [] Ch -}
{ "alphanum_fraction": 0.4388489209, "avg_line_length": 22.9120879121, "ext": "agda", "hexsha": "b513d70d9a25a82492c0e5a024c9769f510f0993", "lang": "Agda", "max_forks_count": 304, "max_forks_repo_forks_event_max_datetime": "2022-03-28T11:35:02.000Z", "max_forks_repo_forks_event_min_datetime": "2018-07-16T18:24:59.000Z", "max_forks_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "manikdv/plfa.github.io", "max_forks_repo_path": "extra/extra/DaraisPhoas.agda", "max_issues_count": 323, "max_issues_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_issues_repo_issues_event_max_datetime": "2022-03-30T07:42:57.000Z", "max_issues_repo_issues_event_min_datetime": "2018-07-05T22:34:34.000Z", "max_issues_repo_licenses": [ "CC-BY-4.0" ], "max_issues_repo_name": "manikdv/plfa.github.io", "max_issues_repo_path": "extra/extra/DaraisPhoas.agda", "max_line_length": 86, "max_stars_count": 1003, "max_stars_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "manikdv/plfa.github.io", "max_stars_repo_path": "extra/extra/DaraisPhoas.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-27T07:03:28.000Z", "max_stars_repo_stars_event_min_datetime": "2018-07-05T18:15:14.000Z", "num_tokens": 1221, "size": 2085 }
module All where open import Prelude open import T open import SubstTheory open import DynTheory open import Progress open import HT open import Examples open import Eq open import DenotCommutes
{ "alphanum_fraction": 0.8418367347, "avg_line_length": 16.3333333333, "ext": "agda", "hexsha": "06383780fc7bb2802794d27643875873e98a68f1", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2021-05-04T22:37:18.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-26T11:39:14.000Z", "max_forks_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "msullivan/godels-t", "max_forks_repo_path": "All.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "msullivan/godels-t", "max_issues_repo_path": "All.agda", "max_line_length": 25, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "msullivan/godels-t", "max_stars_repo_path": "All.agda", "max_stars_repo_stars_event_max_datetime": "2021-03-22T00:28:03.000Z", "max_stars_repo_stars_event_min_datetime": "2016-12-25T01:52:57.000Z", "num_tokens": 46, "size": 196 }
{- Problem #53 Given premises: (all x)[(F x) -> (some y)((F y) & (G x y))] justification = 1.0 Ultimate epistemic interests: (all x)[(F x) -> (some y)(some z)((G x y) & (G y z))] interest = 1.0 -} open import Prelude postulate U : Set F : U β†’ Set G : U β†’ U β†’ Set record Premise {x : U} (Fx : F x) : Set where field pY : U pF : F pY pG : G x pY open Premise record Conclusion {x : U} (Fx : F x) : Set where field cY : U cZ : U cGxy : G x cY cGyz : G cY cZ open Conclusion premise = βˆ€ x β†’ (Fx : F x) β†’ Premise Fx conclusion = βˆ€ x β†’ (Fx : F x) β†’ Conclusion Fx proof1 : premise β†’ conclusion proof1 p x Fx = record { cY = _ ; cZ = _ ; cGxy = pG p1 ; cGyz = pG p2 } where p1 = p x Fx p2 = p (pY p1) (pF p1) {- postulate U : Set F : U β†’ Set G : U β†’ U β†’ Set βˆƒ : βˆ€ {a b} {A : Set a} (B : A β†’ Set b) β†’ Set (a βŠ” b) βˆƒ = Ξ£ _ premise = βˆ€ x β†’ F x β†’ βˆƒ Ξ» y β†’ (F y Γ— G x y) conclusion = βˆ€ x β†’ F x β†’ βˆƒ Ξ» y β†’ βˆƒ Ξ» z β†’ (G x y Γ— G y z) pY : premise β†’ βˆ€ x β†’ F x β†’ _ pY p x Fx = fst (p x Fx) pF : premise β†’ βˆ€ x β†’ F x β†’ F y -- y is not in scope! pF p x Fx = {!fst (snd (p x Fx))!} pG : premise β†’ βˆ€ x β†’ F x β†’ _ pG p x Fx = {!snd (snd (p x Fx))!} proof1 : premise β†’ conclusion proof1 p x Fx = y , z , Gxy , Gyz where y : U y = {!!} z : U z = {!!} Gxy : G x y Gxy = {!!} Gyz : G y z Gyz = {!!} -}
{ "alphanum_fraction": 0.4759856631, "avg_line_length": 16.6071428571, "ext": "agda", "hexsha": "605f96e99b470405a868ea63cce39e46beecc8bf", "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/lisp-revised/Problem53.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/lisp-revised/Problem53.agda", "max_line_length": 75, "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/lisp-revised/Problem53.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 616, "size": 1395 }
module Issue384 where postulate D : (A : Set) β†’ A β†’ Set data I : Set where i : I Dβ€² : (A : Set) β†’ A β†’ I β†’ Set Dβ€² A x i = D A x postulate Q : (A : Set) β†’ A β†’ Set q : βˆ€ j A (x : A) β†’ Dβ€² A x j β†’ Q A x A : Set x : A d : D A x P : (A : Set) β†’ A β†’ Set p : P (Q _ _) (q _ _ _ d)
{ "alphanum_fraction": 0.430976431, "avg_line_length": 12.9130434783, "ext": "agda", "hexsha": "c5457a466043c43acc5f8e1389d8905f289cc53d", "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/Issue384.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/Issue384.agda", "max_line_length": 38, "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/Issue384.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": 141, "size": 297 }
module Issue168 where postulate X : Set open import Issue168b open Membership X postulate P : Nat β†’ Set lemma : βˆ€ n β†’ P (id n) foo : P zero foo = lemma _
{ "alphanum_fraction": 0.6687116564, "avg_line_length": 10.8666666667, "ext": "agda", "hexsha": "442c2d9fbfd5c29b88734d432c3ced70a796a4de", "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": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/agda-kanso", "max_forks_repo_path": "test/succeed/Issue168.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "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": "asr/agda-kanso", "max_issues_repo_path": "test/succeed/Issue168.agda", "max_line_length": 24, "max_stars_count": null, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/succeed/Issue168.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 52, "size": 163 }
------------------------------------------------------------------------ -- The Agda standard library -- -- List Literals ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.List.Literals where open import Agda.Builtin.FromString open import Data.Unit open import Agda.Builtin.Char open import Agda.Builtin.List open import Data.String.Base using (toList) isString : IsString (List Char) isString = record { Constraint = Ξ» _ β†’ ⊀ ; fromString = Ξ» s β†’ toList s }
{ "alphanum_fraction": 0.5250463822, "avg_line_length": 24.5, "ext": "agda", "hexsha": "7172cec21dcc1b24242a08fb00774a8f5b053bd8", "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/Data/List/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/Data/List/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/Data/List/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": 109, "size": 539 }
------------------------------------------------------------------------------ -- The relation of divisibility on partial natural numbers ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Data.Nat.Divisibility.By0 where open import FOTC.Base open import FOTC.Data.Nat infix 4 _∣_ ------------------------------------------------------------------------------ -- The relation of divisibility (the symbol is '\mid' not '|') -- -- It seems there is not agreement about if 0∣0: -- -- Hardy and Wright 1975, p. 1: 0∀0 -- -- Knuth 1977, p. 40: 0∀0 -- -- Agda standard libraryΒ 0.8.1: 0|0 -- -- Coq 8.4pl4: 0∣0 -- -- Isabelle2014: 0∣0 -- In our definition 0∣0, which is used to prove properties of the gcd -- as it is in GHC β‰₯ 7.2.1, where gcd 0 0 = 0 (see -- http://hackage.haskell.org/trac/ghc/ticket/3304). -- Note that @k@ should be a total natural number. _∣_ : D β†’ D β†’ Set m ∣ n = βˆƒ[ k ] N k ∧ n ≑ k * m {-# ATP definition _∣_ #-} ------------------------------------------------------------------------------ -- References: -- -- Hardy, G. H. and Wright, E. M. (1975). An Introduction to the -- Theory of Numbers. 4th ed. Oxford University Press. -- -- Knuth, Donald E. (1997). The Art of Computer Programming. 3rd -- ed. Vol. 1. Fundamental Algorithms. Addison-Wesley Professional.
{ "alphanum_fraction": 0.497671324, "avg_line_length": 30.6734693878, "ext": "agda", "hexsha": "d6f1f6abcf1d77a73b4c325d1211709bcc6474c5", "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/Divisibility/By0.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/Divisibility/By0.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/Divisibility/By0.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": 405, "size": 1503 }
------------------------------------------------------------------------ -- Compiler correctness ------------------------------------------------------------------------ {-# OPTIONS --cubical --sized-types #-} module Lambda.Partiality-monad.Inductive.Compiler-correctness where open import Equality.Propositional.Cubical open import Prelude hiding (βŠ₯) open import Bijection equality-with-J using (_↔_) open import Maybe equality-with-J as Maybe open import Monad equality-with-J open import Vec.Function equality-with-J open import Partiality-monad.Inductive open import Partiality-monad.Inductive.Monad open import Lambda.Compiler open import Lambda.Partiality-monad.Inductive.Interpreter open import Lambda.Partiality-monad.Inductive.Virtual-machine open import Lambda.Syntax open import Lambda.Virtual-machine private module C = Closure Code module T = Closure Tm -- Compiler correctness. mutual ⟦⟧-correct : βˆ€ {n} t {ρ : T.Env n} {c s} {k : β„• β†’ T.Value β†’ M C.Value} {n} β†’ (βˆ€ v β†’ steps ⟨ c , val (comp-val v) ∷ s , comp-env ρ ⟩ ≳[ n ] Ξ» n β†’ run (k n v)) β†’ steps ⟨ comp t c , s , comp-env ρ ⟩ ≳[ n ] Ξ» n β†’ run (⟦ t βŸ§β€² ρ n >>= k n) ⟦⟧-correct (con i) {ρ} {c} {s} {k} hyp = steps ⟨ con i ∷ c , s , comp-env ρ ⟩ β‰³βŸ¨ step⇓ ⟩ steps ⟨ c , val (comp-val (T.con i)) ∷ s , comp-env ρ ⟩ β‰³βŸ¨ hyp (T.con i) ⟩ (Ξ» n β†’ run (k n (T.con i))) β‰‘βŸ¨ sym now->>= βŸ©β‰³ (Ξ» n β†’ run (⟦ con i βŸ§β€² ρ n >>= k n)) βˆŽβ‰³ ⟦⟧-correct (var x) {ρ} {c} {s} {k} hyp = steps ⟨ var x ∷ c , s , comp-env ρ ⟩ β‰³βŸ¨ step⇓ ⟩ steps ⟨ c , val (comp-val (ρ x)) ∷ s , comp-env ρ ⟩ β‰³βŸ¨ hyp (ρ x) ⟩ (Ξ» n β†’ run (k n (ρ x))) β‰‘βŸ¨ sym now->>= βŸ©β‰³ (Ξ» n β†’ run (⟦ var x βŸ§β€² ρ n >>= k n)) βˆŽβ‰³ ⟦⟧-correct (Ζ› t) {ρ} {c} {s} {k} hyp = steps ⟨ clo (comp t (ret ∷ [])) ∷ c , s , comp-env ρ ⟩ β‰³βŸ¨ step⇓ ⟩ steps ⟨ c , val (comp-val (T.Ζ› t ρ)) ∷ s , comp-env ρ ⟩ β‰³βŸ¨ hyp (T.Ζ› t ρ) ⟩ (Ξ» n β†’ run (k n (T.Ζ› t ρ))) β‰‘βŸ¨ sym now->>= βŸ©β‰³ (Ξ» n β†’ run (⟦ Ζ› t βŸ§β€² ρ n >>= k n)) βˆŽβ‰³ ⟦⟧-correct (t₁ Β· tβ‚‚) {ρ} {c} {s} {k} {n} hyp = steps ⟨ comp t₁ (comp tβ‚‚ (app ∷ c)) , s , comp-env ρ ⟩ β‰³βŸ¨ (⟦⟧-correct t₁ {n = n} Ξ» v₁ β†’ ⟦⟧-correct tβ‚‚ Ξ» vβ‚‚ β†’ βˆ™-correct v₁ vβ‚‚ hyp) ⟩ (Ξ» n β†’ run (⟦ t₁ βŸ§β€² ρ n >>= Ξ» v₁ β†’ ⟦ tβ‚‚ βŸ§β€² ρ n >>= Ξ» vβ‚‚ β†’ (v₁ βˆ™ vβ‚‚) n >>= k n)) β‰‘βŸ¨ cong (Ξ» f β†’ run (⟦ t₁ βŸ§β€² ρ n >>= f)) (⟨ext⟩ Ξ» v₁ β†’ Monad.associativity tr (⟦ tβ‚‚ βŸ§β€² ρ n) _ _) βŸ©β‰³ (Ξ» n β†’ run (⟦ t₁ βŸ§β€² ρ n >>= Ξ» v₁ β†’ (⟦ tβ‚‚ βŸ§β€² ρ n >>= Ξ» vβ‚‚ β†’ (v₁ βˆ™ vβ‚‚) n) >>= k n)) β‰‘βŸ¨ cong MaybeT.run $ Monad.associativity tr (⟦ t₁ βŸ§β€² ρ n) _ _ βŸ©β‰³ (Ξ» n β†’ run (⟦ t₁ Β· tβ‚‚ βŸ§β€² ρ n >>= k n)) βˆŽβ‰³ where tr = Monad-transformer.transform (Maybe.monad-transformer ext) βˆ™-correct : βˆ€ {n} v₁ vβ‚‚ {ρ : T.Env n} {c s} {k : β„• β†’ T.Value β†’ M C.Value} {n} β†’ (βˆ€ v β†’ steps ⟨ c , val (comp-val v) ∷ s , comp-env ρ ⟩ ≳[ n ] Ξ» n β†’ run (k n v)) β†’ steps ⟨ app ∷ c , val (comp-val vβ‚‚) ∷ val (comp-val v₁) ∷ s , comp-env ρ ⟩ ≳[ n ] Ξ» n β†’ run ((v₁ βˆ™ vβ‚‚) n >>= k n) βˆ™-correct (T.con i) vβ‚‚ {ρ} {c} {s} {k} hyp = steps ⟨ app ∷ c , val (comp-val vβ‚‚) ∷ val (C.con i) ∷ s , comp-env ρ ⟩ β‰³βŸ¨βŸ© const (run fail) β‰‘βŸ¨ sym now->>= βŸ©β‰³ (Ξ» n β†’ run ((T.con i βˆ™ vβ‚‚) n >>= k n)) βˆŽβ‰³ βˆ™-correct (T.Ζ› t₁ ρ₁) vβ‚‚ {ρ} {c} {s} {k} {zero} hyp = steps ⟨ app ∷ c , val (comp-val vβ‚‚) ∷ val (comp-val (T.Ζ› t₁ ρ₁)) ∷ s , comp-env ρ ⟩ β‰‘βŸ¨ refl βŸ©β‰³ const never β‰‘βŸ¨ sym never->>= βŸ©β‰³ const (never >>= _) β‰‘βŸ¨ cong (_>>= maybe (MaybeT.run ∘ k 0) (return nothing) ⦂ (_ βŠ₯ β†’ _)) (sym never->>=) βŸ©β‰³ (Ξ» n β†’ run ((T.Ζ› t₁ ρ₁ βˆ™ vβ‚‚) n >>= k n)) βˆŽβ‰³ βˆ™-correct (T.Ζ› t₁ ρ₁) vβ‚‚ {ρ} {c} {s} {k} {suc n} hyp = later ( steps ⟨ app ∷ c , val (comp-val vβ‚‚) ∷ val (comp-val (T.Ζ› t₁ ρ₁)) ∷ s , comp-env ρ ⟩ ∘ suc β‰³βŸ¨βŸ© steps ⟨ comp t₁ (ret ∷ []) , ret c (comp-env ρ) ∷ s , cons (comp-val vβ‚‚) (comp-env ρ₁) ⟩ βˆ€β‰‘βŸ¨ (Ξ» n β†’ cong (Ξ» ρ′ β†’ steps ⟨ comp t₁ (ret ∷ []) , ret c (comp-env ρ) ∷ s , ρ′ ⟩ n) $ sym comp-cons) βŸ©β‰³ steps ⟨ comp t₁ (ret ∷ []) , ret c (comp-env ρ) ∷ s , comp-env (cons vβ‚‚ ρ₁) ⟩ β‰³βŸ¨ (⟦⟧-correct t₁ {n = n} Ξ» v β†’ steps ⟨ ret ∷ [] , val (comp-val v) ∷ ret c (comp-env ρ) ∷ s , comp-env (cons vβ‚‚ ρ₁) ⟩ β‰³βŸ¨ step⇓ ⟩ steps ⟨ c , val (comp-val v) ∷ s , comp-env ρ ⟩ β‰³βŸ¨ hyp v ⟩ (Ξ» n β†’ run (k n v)) β‰³βŸ¨ step⇓ ⟩ (Ξ» n β†’ run (k (suc n) v)) βˆŽβ‰³) ⟩ (Ξ» n β†’ run (⟦ t₁ βŸ§β€² (cons vβ‚‚ ρ₁) n >>= k (suc n))) β‰³βŸ¨βŸ© (Ξ» n β†’ run ((T.Ζ› t₁ ρ₁ βˆ™ vβ‚‚) (suc n) >>= k (suc n))) βˆŽβ‰³) -- Note that the equality that is used here is syntactic. correct : βˆ€ t β†’ wrap (exec ⟨ comp t [] , [] , nil ⟩) ≑ (⟦ t ⟧ nil >>= Ξ» v β†’ return (comp-val v)) correct t = wrap (exec ⟨ comp t [] , [] , nil ⟩) β‰‘βŸ¨ cong (Ξ» ρ β†’ wrap (exec ⟨ comp t [] , [] , ρ ⟩)) $ sym comp-nil ⟩ wrap (exec ⟨ comp t [] , [] , comp-env nil ⟩) β‰‘βŸ¨βŸ© wrap (⨆ (stepsΛ’ ⟨ comp t [] , [] , comp-env nil ⟩)) β‰‘βŸ¨ cong wrap (≳→⨆≑⨆ 0 $ ⟦⟧-correct t Ξ» v β†’ const (MaybeT.run (return (comp-val v))) βˆŽβ‰³) ⟩ wrap (⨆ (⟦ t ⟧˒ nil >>=Λ’ Ξ» v β†’ constΛ’ (MaybeT.run (return (comp-val v))))) β‰‘βŸ¨ cong (Ξ» s β†’ wrap (⨆ s)) (_↔_.to equality-characterisation-increasing (Ξ» _ β†’ refl)) ⟩ wrap (⨆ (maybe (Ξ» v β†’ MaybeT.run (return (comp-val v))) (return nothing) βˆ—-inc ⟦ t ⟧˒ nil)) β‰‘βŸ¨ cong wrap (sym ⨆->>=) ⟩∎ (⟦ t ⟧ nil >>= Ξ» v β†’ return (comp-val v)) ∎
{ "alphanum_fraction": 0.3845448992, "avg_line_length": 41.7070063694, "ext": "agda", "hexsha": "8dfe87fc08411a5b0c5a3692b3f5d2252a464a96", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/partiality-monad", "max_forks_repo_path": "src/Lambda/Partiality-monad/Inductive/Compiler-correctness.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/partiality-monad", "max_issues_repo_path": "src/Lambda/Partiality-monad/Inductive/Compiler-correctness.agda", "max_line_length": 145, "max_stars_count": 2, "max_stars_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/partiality-monad", "max_stars_repo_path": "src/Lambda/Partiality-monad/Inductive/Compiler-correctness.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:08.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:59:18.000Z", "num_tokens": 2416, "size": 6548 }
module BHeap.Properties {A : Set}(_≀_ : A β†’ A β†’ Set) where open import Bound.Lower A open import Bound.Lower.Order _≀_ open import BHeap _≀_ open import Data.List open import Data.Nat open import Data.Sum open import Nat.Sum open import List.Permutation.Base A open import List.Permutation.Base.Concatenation A open import List.Permutation.Base.Equivalence A open import List.Properties A open import Relation.Binary.Core open import Relation.Binary.PropositionalEquality lemma-merge-lf : {b : Bound}(tot≀ : Total _≀_)(h : BHeap b) β†’ merge tot≀ h lf ≑ h lemma-merge-lf _ lf = refl lemma-merge-lf _ (nd b≀x l r) = refl lemma-merge# : {b : Bound}(tot≀ : Total _≀_)(l r : BHeap b) β†’ # (merge tot≀ l r) ≑ # l + # r lemma-merge# _ lf r = refl lemma-merge# tot≀ l lf rewrite lemma-merge-lf tot≀ l | +id (# l) = refl lemma-merge# tot≀ (nd {x = y} x≀y l r) (nd {x = y'} x≀y' l' r') with tot≀ y y' ... | inj₁ y≀y' rewrite lemma-merge# tot≀ l r = refl ... | injβ‚‚ y'≀y rewrite lemma-merge# tot≀ l' r' | +assoc (# l + # r) (# l' + # r') = refl lemma-merge≀′ : {b : Bound}{x : A}(tot≀ : Total _≀_)(b≀x : LeB b (val x))(l r : BHeap (val x)) β†’ suc (# (merge tot≀ l r)) ≀′ # (nd b≀x l r) lemma-merge≀′ tot≀ b≀x l r rewrite lemma-merge# tot≀ l r = ≀′-refl lemma-merge∼ : {b : Bound}(tot≀ : Total _≀_)(l r : BHeap b) β†’ flatten (merge tot≀ l r) ∼ (flatten l ++ flatten r) lemma-merge∼ _ lf r = refl∼ lemma-merge∼ tot≀ l lf rewrite lemma-merge-lf tot≀ l | ++id (flatten l) = refl∼ lemma-merge∼ tot≀ (nd {x = y} b≀x l r) (nd {x = y'} b≀y' l' r') with tot≀ y y' ... | inj₁ y≀y' = lemma++∼r (∼x /head /head (lemma-merge∼ tot≀ l r)) ... | injβ‚‚ y'≀y = trans∼ (lemma++∼l {xs = y' ∷ (y ∷ flatten l ++ flatten r)} (lemma-merge∼ tot≀ l' r')) (∼x /head (lemma++/ {xs = y ∷ flatten l ++ flatten r}) refl∼)
{ "alphanum_fraction": 0.6128133705, "avg_line_length": 46.0256410256, "ext": "agda", "hexsha": "33f3a49df229bde81e36210219064c5eb40fa071", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_path": "agda/BHeap/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_path": "agda/BHeap/Properties.agda", "max_line_length": 165, "max_stars_count": 6, "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_path": "agda/BHeap/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "num_tokens": 731, "size": 1795 }
-- Andreas, 2012-10-30 Sections -- Reported by guillaume.brunerie, Oct 24 2012 module Issue735 where import Common.Level open import Common.Prelude using (Nat; zero; suc) {- I often want to use something like sections in Coq. I usually use parametrized modules but this has at least two issues that Coq does not have: 1) I need to give a name to the module, and there is often no meaningful name to be given 2) It exports the module, so I cannot define a module in another file with the same name I guess I can workaround 2) by declaring the module private, but this will mean that everything will be indented further (again) and I really want to avoid that. I think this can easily be fixed by adding a kind of anonymous modules. An anonymous module would be declared by naming it `_`, and the following code module _ params where declarations would be translated to: private module Fresh params where declarations open Fresh public where Fresh is a new name. -} -- Andreas: this translation is not necessary, because Agda -- has a concept of sections internally (in Abstract syntax). -- However, the translation and the actual implementation should -- have the same semantics, except that a name 'Fresh' is never generated. -- An empty section with no parameters module _ where -- A section with a non-hidden parameter module _ {a} (A : Set a) where data List : Set a where [] : List _∷_ : (x : A) (xs : List) β†’ List -- A section with all hidden parameters module _ {a} {A : Set a} where _++_ : List A β†’ List A β†’ List A [] ++ ys = ys (x ∷ xs) ++ ys = x ∷ (xs ++ ys) module _ (default : A) where head : List A β†’ A head [] = default head (x ∷ _) = x test : List Nat test = head 1 [] ∷ ((2 ∷ []) ++ (3 ∷ []))
{ "alphanum_fraction": 0.686285397, "avg_line_length": 24.6712328767, "ext": "agda", "hexsha": "91b4680ba4a294310f12cdad167339f664efa34a", "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/Issue735.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/Issue735.agda", "max_line_length": 74, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue735.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": 488, "size": 1801 }
module ImpossiblePattern where f : ? f (_ _) = ?
{ "alphanum_fraction": 0.6153846154, "avg_line_length": 7.4285714286, "ext": "agda", "hexsha": "c2065e84749a61672340e4bd0904f03a971f3f08", "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/bugs/ImpossiblePattern.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/bugs/ImpossiblePattern.agda", "max_line_length": 30, "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/bugs/ImpossiblePattern.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": 14, "size": 52 }
open import Issue2959.M Set r : R r = ?
{ "alphanum_fraction": 0.6341463415, "avg_line_length": 8.2, "ext": "agda", "hexsha": "3666f9520a710b3afbf1c2e71c5e51dd3f793232", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/interaction/Issue2959.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/interaction/Issue2959.agda", "max_line_length": 27, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/Issue2959.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": 15, "size": 41 }
------------------------------------------------------------------------------ -- Example of a nested recursive function using the Agda standard -- library ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- From: Ana Bove and Venanzio Capretta. Nested general recursion and -- partiality in type theory. vol 2152 LNCS. 2001. module FOT.FOTC.Program.Nest.NestSL where open import Data.Nat renaming (suc to succ) open import Relation.Binary.PropositionalEquality ------------------------------------------------------------------------------ {-# TERMINATING #-} nest : β„• β†’ β„• nest 0 = 0 nest (succ n) = nest (nest n) {-# TERMINATING #-} nest-x≑0 : βˆ€ n β†’ nest n ≑ zero nest-x≑0 zero = refl nest-x≑0 (succ n) = nest-x≑0 (nest n)
{ "alphanum_fraction": 0.4761904762, "avg_line_length": 31.5, "ext": "agda", "hexsha": "e2e9d5591910b897db1f4b5a07f80b4908e30a86", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/FOT/FOTC/Program/Nest/NestSL.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/FOT/FOTC/Program/Nest/NestSL.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/FOT/FOTC/Program/Nest/NestSL.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": 203, "size": 945 }
-- Andreas, 2022-03-09, issue #5819, reported by Zilin Chen -- -- This test uncovered an unsound optimization (8e0fca895b9c6740d9d6c1751ed1e0ecefe63473) -- in the termination checker which replaced a (stripAllProjections . normalize) -- by a (iteratively reduce . stripAllProjections). -- Those reductions on now ill-formed terms triggered the __IMPOSSIBLE__: -- Incomplete pattern matching when applying Issue5819.dl-iso open import Agda.Builtin.Unit using (⊀; tt) open import Agda.Builtin.Nat renaming (Nat to β„•) open import Agda.Builtin.Equality open import Agda.Builtin.Sigma renaming (fst to proj₁; snd to projβ‚‚) data βŠ₯ : Set where βˆƒ : {A : Set} (B : A β†’ Set) β†’ Set βˆƒ B = Ξ£ _ B _Γ—_ : (A B : Set) β†’ Set A Γ— B = Ξ£ A Ξ» _ β†’ B sym : {A : Set} {x y : A} β†’ x ≑ y β†’ y ≑ x sym refl = refl _β‰’_ : {A : Set} (x y : A) β†’ Set x β‰’ y = x ≑ y β†’ βŠ₯ record Inverse (A B : Set) : Set where field f : A β†’ B f⁻¹ : B β†’ A inverse : βˆ€ x β†’ f (f⁻¹ x) ≑ x open Inverse data DList : Set Fresh : (a : β„•) β†’ (l : DList) β†’ Set data DList where dnil : DList dcons : (a : β„•) β†’ (l : DList) β†’ Fresh a l β†’ DList Fresh a dnil = ⊀ Fresh a (dcons b l _) = (a β‰’ b) Γ— Fresh a l data Listβ€² : Set where nilβ€² : Listβ€² consβ€² : β„• β†’ Listβ€² β†’ Listβ€² Freshβ€² : β„• β†’ Listβ€² β†’ Set Freshβ€² a nilβ€² = ⊀ Freshβ€² a (consβ€² b l) = (a β‰’ b) Γ— Freshβ€² a l AllFresh : Listβ€² β†’ Set AllFresh nilβ€² = ⊀ AllFresh (consβ€² a l) = Freshβ€² a l Γ— AllFresh l data DListβ€² : Listβ€² β†’ Set β†’ Set₁ where dnilβ€² : DListβ€² nilβ€² ⊀ dconsβ€² : βˆ€{l}{prf} β†’ (a : β„•) β†’ DListβ€² l prf β†’ DListβ€² (consβ€² a l) (Freshβ€² a l Γ— prf) data DListβ€³ : Set where dlβ€³ : (l : Listβ€²) β†’ AllFresh l β†’ DListβ€³ undlβ€³-l : DListβ€³ β†’ Listβ€² undlβ€³-l (dlβ€³ l _) = l undlβ€³-p : DListβ€³ β†’ βˆƒ AllFresh undlβ€³-p (dlβ€³ l p) = l , p -- dl-iso : DList ↔ DListβ€³ dl-iso : Inverse DList DListβ€³ -- f-dl-iso : DList β†’ DListβ€³ -- g-dl-iso : DListβ€³ β†’ DList -- inverse-dl-iso : βˆ€ x β†’ f-dl-iso (g-dl-iso x) ≑ x Freshβ†’Freshβ€² : βˆ€{a}{l}{lβ€³} β†’ (f dl-iso l ≑ lβ€³) β†’ Fresh a l β†’ Freshβ€² a (undlβ€³-l lβ€³) Freshβ†’AllFresh : βˆ€{a}{l}{lβ€³} β†’ (f dl-iso l ≑ lβ€³) β†’ Fresh a l β†’ AllFresh (undlβ€³-l lβ€³) All/Freshβ€²β†’Fresh : βˆ€{a}{l}{lβ€³} β†’ (l ≑ f⁻¹ dl-iso lβ€³) β†’ Freshβ€² a (undlβ€³-l lβ€³) Γ— AllFresh (undlβ€³-l lβ€³) β†’ Fresh a l f dl-iso dnil = dlβ€³ nilβ€² tt f dl-iso (dcons a l p) = dlβ€³ (consβ€² a (undlβ€³-l (f dl-iso l))) ((Freshβ†’Freshβ€² {l = l}{lβ€³ = f dl-iso l} refl p) , (Freshβ†’AllFresh {a = a}{l = l}{lβ€³ = f dl-iso l} refl p)) f⁻¹ dl-iso (dlβ€³ nilβ€² p) = dnil f⁻¹ dl-iso (dlβ€³ (consβ€² a lβ€²) p) = dcons a (f⁻¹ dl-iso (dlβ€³ lβ€² (projβ‚‚ p))) (All/Freshβ€²β†’Fresh {lβ€³ = dlβ€³ lβ€² (projβ‚‚ p)} refl p) -- Can't do any further, otherwise an Agda bug occurs. inverse dl-iso x = invΛ‘ where invΛ‘ : βˆ€{x} β†’ f dl-iso (f⁻¹ dl-iso x) ≑ x invΛ‘ {dlβ€³ nilβ€² _} = refl invΛ‘ {dlβ€³ (consβ€² a l) p} rewrite invΛ‘ {dlβ€³ l {!!}} = {!!} -- add "rewrite invΛ‘ {dlβ€³ l ?}" (w/o quotes) to the left of the = sign and C-c C-l Freshβ†’Freshβ€² {a} {dnil} eq p rewrite sym eq = tt Freshβ†’Freshβ€² {a} {dcons a₁ l x} eq p rewrite sym eq = proj₁ p , Freshβ†’Freshβ€² {lβ€³ = f dl-iso l} refl (projβ‚‚ p) Freshβ†’AllFresh {l = dnil} eq p rewrite sym eq = tt Freshβ†’AllFresh {l = dcons a l x} eq p rewrite sym eq = (Freshβ†’Freshβ€² {lβ€³ = f dl-iso l} refl x) , Freshβ†’AllFresh {a = a}{l = l}{lβ€³ = f dl-iso l} refl x All/Freshβ€²β†’Fresh {a} {lβ€³ = dlβ€³ nilβ€² x} eq p rewrite eq = tt All/Freshβ€²β†’Fresh {a} {lβ€³ = dlβ€³ (consβ€² b l) x} eq p rewrite eq = (proj₁ (proj₁ p)) , {!All/Freshβ€²β†’Fresh!} -- put "All/Freshβ€²β†’Fresh" in the hole and C-c C-r -- WAS: internal error in reduction machinery -- SHOULD: fail with termination error
{ "alphanum_fraction": 0.563299755, "avg_line_length": 29.6209677419, "ext": "agda", "hexsha": "a895809ccf0bcc4e46036d3418d93cea774c6d64", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "KDr2/agda", "max_forks_repo_path": "test/Fail/Issue5819.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z", "max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "KDr2/agda", "max_issues_repo_path": "test/Fail/Issue5819.agda", "max_line_length": 143, "max_stars_count": null, "max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "KDr2/agda", "max_stars_repo_path": "test/Fail/Issue5819.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1509, "size": 3673 }
{-# OPTIONS --without-K #-} open import HoTT open import homotopy.HSpace module homotopy.EM1HSpace where module EM₁HSpace {i} (A : Group i) (A-abelian : is-abelian A) where module A = Group A open EM₁ A mult-loop : (g : A.El) (x : EM₁) β†’ x == x mult-loop g = EM₁-elim {P = Ξ» x β†’ x == x} (Ξ» _ β†’ =-preserves-level _ emlevel) (emloop g) loop' (set-↓-has-all-paths-↓ (emlevel embase embase)) (Ξ» _ _ β†’ set-↓-has-all-paths-↓ (emlevel embase embase)) where abstract loop' : (g' : A.El) β†’ emloop g == emloop g [ (Ξ» x β†’ x == x) ↓ emloop g' ] loop' g' = ↓-idf=idf-in $ emloop g βˆ™ emloop g' =⟨ ! (emloop-comp g g') ⟩ emloop (A.comp g g') =⟨ ap emloop (A-abelian g g') ⟩ emloop (A.comp g' g) =⟨ emloop-comp g' g ⟩ emloop g' βˆ™ emloop g =⟨ βˆ™=βˆ™' (emloop g') (emloop g) ⟩ emloop g' βˆ™' emloop g ∎ mult-hom : GroupHom A (Ξ©^S-group 0 ((EM₁ β†’ EM₁) , (Ξ» x β†’ x)) (Ξ -level (Ξ» _ β†’ emlevel))) mult-hom = record {f = f; pres-comp = pres-comp} where f = Ξ» g β†’ Ξ»= (mult-loop g) pres-comp = Ξ» g₁ gβ‚‚ β†’ ap Ξ»= (Ξ»= (EM₁-elim {P = Ξ» x β†’ mult-loop (A.comp g₁ gβ‚‚) x == mult-loop g₁ x βˆ™ mult-loop gβ‚‚ x} (Ξ» _ β†’ =-preserves-level _ (=-preserves-level _ emlevel)) (emloop-comp g₁ gβ‚‚) (Ξ» _ β†’ prop-has-all-paths-↓ (emlevel _ _ _ _)) (set-↓-has-all-paths-↓ (=-preserves-level _ (emlevel _ _))) (Ξ» _ _ β†’ set-↓-has-all-paths-↓ (=-preserves-level _ (emlevel _ _))))) βˆ™ ! (βˆ™-Ξ»= _ _) mult : EM₁ β†’ EM₁ β†’ EM₁ mult = EM₁-rec {C = EM₁ β†’ EM₁} (Ξ -level (Ξ» _ β†’ emlevel)) (Ξ» x β†’ x) mult-hom H-EM₁ : HSpaceStructure EM₁ H-EM₁ = record { e = embase; ΞΌ = mult; ΞΌ-e-l = ΞΌ-e-l; ΞΌ-e-r = ΞΌ-e-r; ΞΌ-coh = ΞΌ-coh } where ΞΌ-e-l : (x : EM₁) β†’ mult embase x == x ΞΌ-e-l = EM₁-elim {P = Ξ» x β†’ mult embase x == x} (Ξ» _ β†’ =-preserves-level 1 emlevel) idp (Ξ» g β†’ ↓-app=idf-in $ βˆ™'-unit-l (emloop g) βˆ™ (! (ap-idf (emloop g))) βˆ™ ! (βˆ™-unit-r (ap (mult embase) (emloop g)))) (set-↓-has-all-paths-↓ (emlevel _ _)) (Ξ» _ _ β†’ set-↓-has-all-paths-↓ (emlevel _ _)) ΞΌ-e-r : (x : EM₁) β†’ mult x embase == x ΞΌ-e-r = EM₁-elim {P = Ξ» x β†’ mult x embase == x} (Ξ» _ β†’ =-preserves-level 1 emlevel) idp (Ξ» g β†’ ↓-app=idf-in $ idp βˆ™' emloop g =⟨ βˆ™'-unit-l (emloop g) ⟩ emloop g =⟨ ! (app=-Ξ² (mult-loop g) embase) ⟩ app= (Ξ»= (mult-loop g)) embase =⟨ ! (EM₁Rec.emloop-Ξ² {C = EM₁ β†’ EM₁} (Ξ -level (Ξ» _ β†’ emlevel)) (Ξ» x β†’ x) mult-hom g) |in-ctx (Ξ» w β†’ app= w embase) ⟩ app= (ap mult (emloop g)) embase =⟨ ∘-ap (Ξ» f β†’ f embase) mult (emloop g) ⟩ ap (Ξ» z β†’ mult z embase) (emloop g) =⟨ ! (βˆ™-unit-r (ap (Ξ» z β†’ mult z embase) (emloop g))) ⟩ ap (Ξ» z β†’ mult z embase) (emloop g) βˆ™ idp ∎) (set-↓-has-all-paths-↓ (emlevel _ _)) (Ξ» _ _ β†’ set-↓-has-all-paths-↓ (emlevel _ _)) ΞΌ-coh : ΞΌ-e-l embase == ΞΌ-e-r embase ΞΌ-coh = idp open HSpaceStructure H-EM₁
{ "alphanum_fraction": 0.488061127, "avg_line_length": 34.9, "ext": "agda", "hexsha": "ec1ae3f3d26b8382e9d4290538eee81466a0d825", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cmknapp/HoTT-Agda", "max_forks_repo_path": "theorems/homotopy/EM1HSpace.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cmknapp/HoTT-Agda", "max_issues_repo_path": "theorems/homotopy/EM1HSpace.agda", "max_line_length": 86, "max_stars_count": null, "max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cmknapp/HoTT-Agda", "max_stars_repo_path": "theorems/homotopy/EM1HSpace.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1251, "size": 3141 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Format strings for Printf and Scanf ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Text.Format where open import Level using (0β„“) open import Category.Applicative open import Data.List.Base as List open import Data.Product open import Data.Product.Nary.NonDependent open import Data.Sum.Base import Data.Sum.Categorical.Left as Sumβ‚— open import Function open import Function.Nary.NonDependent using (0β„“s; Sets) open import Strict -- Formatted types open import Data.Char.Base open import Data.Integer.Base open import Data.Float open import Data.Nat.Base open import Data.String.Base ------------------------------------------------------------------------ -- Basic types data Chunk : Set where `β„• `β„€ `Float `Char `String : Chunk Raw : String β†’ Chunk Format : Set Format = List Chunk ------------------------------------------------------------------------ -- Semantics size : Format β†’ β„• size = List.sum βˆ˜β€² List.map Ξ» { (Raw _) β†’ 0; _ β†’ 1 } -- Meaning of a format as a list of value types ⟦_⟧ : (fmt : Format) β†’ Sets (size fmt) 0β„“s ⟦ [] ⟧ = _ ⟦ `β„• ∷ cs ⟧ = β„• , ⟦ cs ⟧ ⟦ `β„€ ∷ cs ⟧ = β„€ , ⟦ cs ⟧ ⟦ `Float ∷ cs ⟧ = Float , ⟦ cs ⟧ ⟦ `Char ∷ cs ⟧ = Char , ⟦ cs ⟧ ⟦ `String ∷ cs ⟧ = String , ⟦ cs ⟧ ⟦ Raw _ ∷ cs ⟧ = ⟦ cs ⟧ ------------------------------------------------------------------------ -- Lexer: from Strings to Formats -- Lexing may fail. To have a useful error message, we defined the following -- enumerated type data Error : Set where UnexpectedEndOfString : String β†’ Error -- ^ expected a type declaration; found an empty string InvalidType : String β†’ Char β†’ String β†’ Error -- ^ invalid type declaration -- return a focus: prefix processed, character causing failure, rest lexer : String β†’ Error ⊎ List Chunk lexer input = loop [] [] (toList input) where open RawApplicative (Sumβ‚—.applicative Error 0β„“) -- Type synonyms used locally to document the code RevWord = List Char -- Mere characters accumulated so far Prefix = RevWord -- Prefix of the input String already read toRevString : RevWord β†’ String toRevString = fromList βˆ˜β€² reverse -- Push a Raw token if we have accumulated some mere characters push : RevWord β†’ List Chunk β†’ List Chunk push [] ks = ks push cs ks = Raw (toRevString cs) ∷ ks -- Main loop loop : RevWord β†’ Prefix β†’ List Char β†’ Error ⊎ List Chunk type : Prefix β†’ List Char β†’ Error ⊎ List Chunk loop acc bef [] = pure (push acc []) -- escaped '%' character: treat like a mere character loop acc bef ('%' ∷ '%' ∷ cs) = loop ('%' ∷ acc) ('%' ∷ '%' ∷ bef) cs -- non escaped '%': type declaration following loop acc bef ('%' ∷ cs) = push acc <$> type ('%' ∷ bef) cs -- mere character: push onto the accumulator loop acc bef (c ∷ cs) = loop (c ∷ acc) (c ∷ bef) cs type bef [] = inj₁ (UnexpectedEndOfString input) type bef (c ∷ cs) = _∷_ <$> chunk c βŠ› loop [] (c ∷ bef) cs where chunk : Char β†’ Error ⊎ Chunk chunk 'd' = pure `β„€ chunk 'i' = pure `β„€ chunk 'u' = pure `β„• chunk 'f' = pure `Float chunk 'c' = pure `Char chunk 's' = pure `String chunk _ = forceβ€² (toRevString bef) $β€² Ξ» prefix β†’ forceβ€² (fromList cs) $β€² Ξ» suffix β†’ inj₁ (InvalidType prefix c suffix)
{ "alphanum_fraction": 0.5612332287, "avg_line_length": 31.5585585586, "ext": "agda", "hexsha": "3c2b9cd2f8a80efedd194ce0ec20da6ded6a5eab", "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/Text/Format.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/Text/Format.agda", "max_line_length": 76, "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/Text/Format.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": 961, "size": 3503 }
------------------------------------------------------------------------------ -- Testing Agsy *without* using the Agda standard library ------------------------------------------------------------------------------ {-# OPTIONS --allow-unsolved-metas #-} {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- Tested with the development version of Agda on 15 June 2012. module FOT.Agsy.NoStd.AgsyNoStd where -- The equational reasoning from the Agda standard libraryΒ 0.8.1. -- open import Relation.Binary.PropositionalEquality -- open ≑-Reasoning -- My equational reasoning. open import FOT.Agsy.NoStd.MyPropositionalEquality open ≑-Reasoning -- We add 3 to the fixities of the Agda standard libraryΒ 0.8.1 (see -- Data/Nat.agda). infixl 9 _+_ ------------------------------------------------------------------------------ data β„• : Set where zero : β„• suc : β„• β†’ β„• _+_ : β„• β†’ β„• β†’ β„• zero + n = n suc m + n = suc (m + n) +-assoc : βˆ€ m n o β†’ m + n + o ≑ m + (n + o) +-assoc zero n o = refl -- via Agsy +-assoc (suc m) n o = {!!} -- Agsy fails using my propositional equality
{ "alphanum_fraction": 0.5074135091, "avg_line_length": 30.35, "ext": "agda", "hexsha": "9e790ecaf60db73c770b6d5316628b495363872e", "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/Agsy/NoStd/AgsyNoStd.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/Agsy/NoStd/AgsyNoStd.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/Agsy/NoStd/AgsyNoStd.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": 304, "size": 1214 }
module Tactic.Nat.Subtract.Simplify where open import Prelude hiding (abs) open import Builtin.Reflection open import Tactic.Reflection.Quote open import Tactic.Reflection open import Control.Monad.State open import Tactic.Nat.Reflect open import Tactic.Nat.NF open import Tactic.Nat.Exp open import Tactic.Nat.Auto open import Tactic.Nat.Auto.Lemmas open import Tactic.Nat.Simpl.Lemmas open import Tactic.Nat.Simpl open import Tactic.Nat.Reflect open import Tactic.Nat.Subtract.Exp open import Tactic.Nat.Subtract.Reflect open import Tactic.Nat.Subtract.Lemmas open import Tactic.Nat.Less.Lemmas simplifySubEqn : βˆ€ eqn ρ β†’ c⟦ eqn ⟧eqn ρ β†’ ⟦ eqn ⟧eqn ρ simplifySubEqn (a :≑ b) = simplifySubEq a b simplifySubEqn (a :< b) = simplifySubLess a b complicateSubEqn : βˆ€ eqn ρ β†’ ⟦ eqn ⟧eqn ρ β†’ c⟦ eqn ⟧eqn ρ complicateSubEqn (a :≑ b) = complicateSubEq a b complicateSubEqn (a :< b) = complicateSubLess a b ⟦_⟧sh : List Eqn β†’ Env Var β†’ Set ⟦ [] ⟧sh ρ = βŠ₯ ⟦ h ∷ [] ⟧sh ρ = ⟦ h ⟧eqn ρ ⟦ h ∷ g ⟧sh ρ = ⟦ h ⟧eqn ρ β†’ ⟦ g ⟧sh ρ ⟦_⟧shs : List Eqn β†’ Env Var β†’ Set ⟦ [] ⟧shs ρ = βŠ₯ ⟦ h ∷ [] ⟧shs ρ = c⟦ h ⟧eqn ρ ⟦ h ∷ g ⟧shs ρ = c⟦ h ⟧eqn ρ β†’ ⟦ g ⟧shs ρ simplifySubH : βˆ€ goal ρ β†’ ⟦ goal ⟧shs ρ β†’ ⟦ goal ⟧sh ρ simplifySubH [] ρ () simplifySubH (h ∷ []) ρ H = simplifySubEqn h ρ H simplifySubH (h ∷ hβ‚‚ ∷ g) ρ H = Ξ» H₁ β†’ simplifySubH (hβ‚‚ ∷ g) ρ $ H (complicateSubEqn h ρ H₁) simplifysub-tactic : Term β†’ Type β†’ TC Term simplifysub-tactic prf g = inferType prf >>= Ξ» h β†’ let t = pi (vArg h) (abs "_" (weaken 1 g)) in caseM termToSubHyps t of Ξ» { nothing β†’ pure $ failedProof (quote invalidGoal) t ; (just (goal , Ξ“)) β†’ pure $ def (quote flip) $ vArg (def (quote simplifySubH) ( vArg (` goal) ∷ vArg (quotedEnv Ξ“) ∷ [] )) ∷ vArg prf ∷ [] } simplifygoal-tactic : Type β†’ TC Term simplifygoal-tactic t = caseM termToSubHyps t of Ξ» { nothing β†’ pure $ failedProof (quote invalidGoal) t ; (just (goal , Ξ“)) β†’ pure $ def (quote simplifySubH) $ vArg (` goal) ∷ vArg (quotedEnv Ξ“) ∷ [] }
{ "alphanum_fraction": 0.6319543509, "avg_line_length": 29.6197183099, "ext": "agda", "hexsha": "64029d5388ceee8b6c1742ff42bb260f8ebb43f7", "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/Tactic/Nat/Subtract/Simplify.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/Tactic/Nat/Subtract/Simplify.agda", "max_line_length": 92, "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/Tactic/Nat/Subtract/Simplify.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": 827, "size": 2103 }
{-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.ZCohomology.Groups.WedgeOfSpheres where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Data.Sigma.Base open import Cubical.ZCohomology.Base open import Cubical.ZCohomology.GroupStructure open import Cubical.ZCohomology.Groups.Unit open import Cubical.ZCohomology.Groups.Sn open import Cubical.ZCohomology.Groups.Wedge open import Cubical.ZCohomology.Groups.Connected open import Cubical.Data.Int renaming (_+_ to _β„€+_) open import Cubical.HITs.Sn open import Cubical.HITs.S1 open import Cubical.HITs.Susp open import Cubical.HITs.Wedge open import Cubical.HITs.Pushout open import Cubical.HITs.Truncation renaming (elim to trElim) hiding (map ; elim2) open import Cubical.Algebra.Group renaming (β„€ to β„€Group ; Bool to BoolGroup ; Unit to UnitGroup) open import Cubical.HITs.SetTruncation renaming (rec to sRec ; rec2 to sRec2 ; elim to sElim) S¹⋁SΒΉ : Typeβ‚€ S¹⋁SΒΉ = Sβ‚Šβˆ™ 1 ⋁ Sβ‚Šβˆ™ 1 S²⋁S¹⋁SΒΉ : Typeβ‚€ S²⋁S¹⋁SΒΉ = Sβ‚Šβˆ™ 2 ⋁ (S¹⋁SΒΉ , inl base) ------------- H⁰(S¹⋁SΒΉ) ------------ H⁰-S¹⋁SΒΉ : GroupIso (coHomGr 0 S¹⋁SΒΉ) β„€Group H⁰-S¹⋁SΒΉ = H⁰-connected (inl base) (wedgeConnected _ _ (Sn-connected 0) (Sn-connected 0)) ------------- HΒΉ(S¹⋁SΒΉ) ------------ HΒΉ-S¹⋁SΒΉ : GroupIso (coHomGr 1 S¹⋁SΒΉ) (DirProd β„€Group β„€Group) HΒΉ-S¹⋁SΒΉ = (Hⁿ-⋁ _ _ 0) β–‘ GroupIsoDirProd coHom1S1≃℀ coHom1S1≃℀ ------------- H⁰(S²⋁S¹⋁SΒΉ) --------- H⁰-S²⋁S¹⋁SΒΉ : GroupIso (coHomGr 0 S²⋁S¹⋁SΒΉ) β„€Group H⁰-S²⋁S¹⋁SΒΉ = H⁰-connected (inl north) (wedgeConnected _ _ (Sn-connected 1) (wedgeConnected _ _ (Sn-connected 0) (Sn-connected 0))) ------------- HΒΉ(S²⋁S¹⋁SΒΉ) --------- HΒΉ-S²⋁S¹⋁SΒΉ : GroupIso (coHomGr 1 S²⋁S¹⋁SΒΉ) (DirProd β„€Group β„€Group) HΒΉ-S²⋁S¹⋁SΒΉ = Hⁿ-⋁ (Sβ‚Šβˆ™ 2) (S¹⋁SΒΉ , inl base) 0 β–‘ GroupIsoDirProd (HΒΉ-Sⁿ≅0 0) HΒΉ-S¹⋁SΒΉ β–‘ lUnitGroupIso ------------- HΒ²(S²⋁S¹⋁SΒΉ) --------- HΒ²-S²⋁S¹⋁SΒΉ : GroupIso (coHomGr 2 S²⋁S¹⋁SΒΉ) β„€Group HΒ²-S²⋁S¹⋁SΒΉ = compGroupIso (Hⁿ-⋁ _ _ 1) (GroupIsoDirProd {B = UnitGroup} (Hⁿ-Sⁿ≅℀ 1) ((Hⁿ-⋁ _ _ 1) β–‘ GroupIsoDirProd (Hⁿ-SΒΉβ‰…0 0) (Hⁿ-SΒΉβ‰…0 0) β–‘ rUnitGroupIso) β–‘ rUnitGroupIso) private open IsGroupHom open Iso toβ‚‚ : coHom 2 S²⋁S¹⋁SΒΉ β†’ β„€ toβ‚‚ = fun (fst HΒ²-S²⋁S¹⋁SΒΉ) fromβ‚‚ : β„€ β†’ coHom 2 S²⋁S¹⋁SΒΉ fromβ‚‚ = inv (fst HΒ²-S²⋁S¹⋁SΒΉ) to₁ : coHom 1 S²⋁S¹⋁SΒΉ β†’ β„€ Γ— β„€ to₁ = fun (fst HΒΉ-S²⋁S¹⋁SΒΉ) from₁ : β„€ Γ— β„€ β†’ coHom 1 S²⋁S¹⋁SΒΉ from₁ = inv (fst HΒΉ-S²⋁S¹⋁SΒΉ) toβ‚€ : coHom 0 S²⋁S¹⋁SΒΉ β†’ β„€ toβ‚€ = fun (fst H⁰-S²⋁S¹⋁SΒΉ) fromβ‚€ : β„€ β†’ coHom 0 S²⋁S¹⋁SΒΉ fromβ‚€ = inv (fst H⁰-S²⋁S¹⋁SΒΉ) {- -- Compute pretty fast test1 : to₁ (from₁ (1 , 0) +β‚• from₁ (0 , 1)) ≑ (1 , 1) test1 = refl -- Computes, but only when computing some smaller numbers first test2 : to₁ (from₁ (50 , 3) +β‚• from₁ (2 , -2)) ≑ (52 , 1) test2 = refl test3 : toβ‚‚ (fromβ‚‚ 0) ≑ 0 test3 = refl test4 : toβ‚‚ (fromβ‚‚ 3) ≑ 3 test4 = refl test5 : toβ‚‚ (fromβ‚‚ 1 +β‚• fromβ‚‚ 1) ≑ 2 test5 = refl -} g : S²⋁S¹⋁SΒΉ β†’ βˆ₯ Susp SΒΉ βˆ₯ 4 g (inl x) = ∣ x ∣ g (inr x) = 0β‚– _ g (push a i) = 0β‚– _ G = ∣ g βˆ£β‚‚ {- Does not compute: testβ‚€ : toβ‚‚ (G +β‚• G) ≑ 2 testβ‚€ = refl but this does: testβ‚€ : toβ‚‚ (G +'β‚• G) ≑ 2 testβ‚€ = refl -}
{ "alphanum_fraction": 0.6269718528, "avg_line_length": 26.9416666667, "ext": "agda", "hexsha": "cdc616371c53fd4503a63a624e1bc1e46ec202c6", "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": "f2d74ae8e2e176963029a35bd886364480948214", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "kl-i/cubical-0.3", "max_forks_repo_path": "Cubical/ZCohomology/Groups/WedgeOfSpheres.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f2d74ae8e2e176963029a35bd886364480948214", "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": "kl-i/cubical-0.3", "max_issues_repo_path": "Cubical/ZCohomology/Groups/WedgeOfSpheres.agda", "max_line_length": 96, "max_stars_count": null, "max_stars_repo_head_hexsha": "f2d74ae8e2e176963029a35bd886364480948214", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "kl-i/cubical-0.3", "max_stars_repo_path": "Cubical/ZCohomology/Groups/WedgeOfSpheres.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1586, "size": 3233 }
------------------------------------------------------------------------ -- Vectors, defined as functions from finite sets ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Equality module Vec.Function {reflexive} (eq : βˆ€ {a p} β†’ Equality-with-J a p reflexive) where open import Prelude open import Bijection eq using (_↔_) open Derived-definitions-and-properties eq open import Function-universe eq hiding (id; _∘_) open import List eq using (length) open import Surjection eq using (_β† _; β† -≑) private variable a : Level A B : Type a n : β„• k : Kind ------------------------------------------------------------------------ -- The type -- Vectors. Vec : βˆ€ {a} β†’ Type a β†’ β„• β†’ Type a Vec A n = Fin n β†’ A -- Nil. nil : Vec A zero nil = Ξ» () -- Cons. cons : A β†’ Vec A n β†’ Vec A (suc n) cons x xs = [ const x , xs ] ------------------------------------------------------------------------ -- Some simple functions -- Finds the element at the given position. index : Vec A n β†’ Fin n β†’ A index = id -- Applies the function to every element in the vector. map : (A β†’ B) β†’ Vec A n β†’ Vec B n map f xs = f ∘ xs -- Constructs a vector containing a certain number of copies of the -- given element. replicate : A β†’ Vec A n replicate = const -- The head of the vector. head : Vec A (suc n) β†’ A head = _$ fzero -- The tail of the vector. tail : Vec A (suc n) β†’ Vec A n tail = _∘ fsuc -- Updates the element at the given position. infix 3 _[_≔_] _[_≔_] : Vec A n β†’ Fin n β†’ A β†’ Vec A n _[_≔_] {n = zero} _ () _ _[_≔_] {n = suc _} xs fzero x = cons x (tail xs) _[_≔_] {n = suc _} xs (fsuc i) x = cons (head xs) (tail xs [ i ≔ x ]) ------------------------------------------------------------------------ -- Some properties -- Empty lists are equal to nil (assuming extensionality). empty≑nil : {A : Type a} β†’ Extensionality lzero a β†’ {xs : Vec A zero} β†’ xs ≑ nil empty≑nil ext = apply-ext ext Ξ» () -- A non-empty list is equal to its head consed onto its tail -- (assuming extensionality). non-empty≑cons-head-tail : {A : Type a} β†’ Extensionality lzero a β†’ (xs : Vec A (suc n)) β†’ xs ≑ cons (head xs) (tail xs) non-empty≑cons-head-tail ext _ = apply-ext ext [ (Ξ» _ β†’ refl _) , (Ξ» _ β†’ refl _) ] ------------------------------------------------------------------------ -- Conversions to and from lists -- Vectors can be converted to lists. to-list : Vec A n β†’ List A to-list {n = zero} _ = [] to-list {n = suc _} xs = head xs ∷ to-list (tail xs) -- Lists can be converted to vectors. from-list : (xs : List A) β†’ Vec A (length xs) from-list [] = nil from-list (x ∷ xs) = cons x (from-list xs) -- There is a split surjection from βˆƒΒ (VecΒ A) to ListΒ A. βˆƒVecβ† List : βˆƒ (Vec A) β†  List A βˆƒVecβ† List {A = A} = record { logical-equivalence = record { to = to-list ∘ projβ‚‚ ; from = Ξ» xs β†’ length xs , from-list xs } ; right-inverse-of = to∘from } where to∘from : (xs : List A) β†’ to-list (from-list xs) ≑ xs to∘from [] = refl _ to∘from (x ∷ xs) = cong (x ∷_) (to∘from xs) -- βˆƒΒ (VecΒ A) is equivalent to ListΒ A (assuming extensionality). βˆƒVec≃List : {A : Type a} β†’ βˆƒ (Vec A) ↝[ lzero ∣ a ] List A βˆƒVec≃List {a = a} {A = A} = generalise-ext? (_β† _.logical-equivalence βˆƒVecβ† List) (Ξ» ext β†’ _β† _.right-inverse-of βˆƒVecβ† List , uncurry (from∘to ext)) where tailβ€² : A β†’ βˆƒ (Vec A) β†  βˆƒ (Vec A) tailβ€² y = record { logical-equivalence = record { to = Ξ» where (suc n , xs) β†’ n , tail xs xs@(zero , _) β†’ xs ; from = Ξ£-map suc (cons y) } ; right-inverse-of = refl } from∘to : Extensionality lzero a β†’ βˆ€ n (xs : Vec A n) β†’ (length (to-list xs) , from-list (to-list xs)) ≑ (n , xs) from∘to ext zero xs = (length {A = A} [] , nil) β‰‘βŸ¨ cong (zero ,_) $ sym $ empty≑nil ext ⟩∎ (zero , xs) ∎ from∘to ext (suc n) xs = $⟨ from∘to ext n (tail xs) ⟩ (length (to-list (tail xs)) , from-list (to-list (tail xs))) ≑ (n , tail xs) β†βŸ¨ _β† _.from $ β† -≑ (tailβ€² (head xs)) ⟩ (length (to-list xs) , from-list (to-list xs)) ≑ (suc n , cons (head xs) (tail xs)) β†βŸ¨ ≑⇒↝ _ $ cong (Ξ» ys β†’ (_ , from-list (to-list xs)) ≑ (_ , ys)) $ sym $ non-empty≑cons-head-tail ext xs βŸ©β–‘ (length (to-list xs) , from-list (to-list xs)) ≑ (suc n , xs) β–‘
{ "alphanum_fraction": 0.4867690994, "avg_line_length": 26.1787709497, "ext": "agda", "hexsha": "ba4c909f716c68e3a04298ca1944e81686770f33", "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/Vec/Function.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/Vec/Function.agda", "max_line_length": 138, "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/Vec/Function.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": 1453, "size": 4686 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT import homotopy.ConstantToSetExtendsToProp as ConstExt {- q[_]α΄³ G/Q β†ž------ G ↑ ↑ Ο†β‚‚ β•Ž β•Ž inject ↑ ↑ H β†ž------- P φ₁ Then, H ≃ᴳ P/Q. -} module groups.PropQuotUniqueFactorization {i j l₁ lβ‚‚} {G : Group i} {H : Group j} (P : SubgroupProp G l₁) (Q : NormalSubgroupProp G lβ‚‚) (φ₁ : Subgroup P β†’α΄³ H) (φ₁-is-surj : is-surjα΄³ φ₁) (Ο†β‚‚ : H β†’α΄³ QuotGroup Q) (Ο†β‚‚-is-inj : is-injα΄³ Ο†β‚‚) (Ο†-comm : βˆ€ p β†’ GroupHom.f (Ο†β‚‚ ∘ᴳ φ₁) p == q[ fst p ]) where private module G = Group G module H = Group H module P = Subgroup P module φ₁ = GroupHom φ₁ module Ο†β‚‚ = GroupHom Ο†β‚‚ P/Q-prop : NormalSubgroupProp (Subgroup P) lβ‚‚ P/Q-prop = quot-of-sub P Q P/Q : Group (lmax i (lmax l₁ lβ‚‚)) P/Q = QuotGroup P/Q-prop module P/Q = Group P/Q module _ (k : Group.El H) where H-to-P/Q-f' : hfiber φ₁.f k β†’ P/Q.El H-to-P/Q-f' (p , _) = q[ p ] abstract H-to-P/Q-f'-const : (hf₁ hfβ‚‚ : hfiber φ₁.f k) β†’ H-to-P/Q-f' hf₁ == H-to-P/Q-f' hfβ‚‚ H-to-P/Q-f'-const (h₁ , r₁) (hβ‚‚ , rβ‚‚) = quot-relα΄³ {P = P/Q-prop} $ <– (quot-relα΄³-equiv {P = Q}) $ ! (Ο†-comm h₁) βˆ™ ap Ο†β‚‚.f (r₁ βˆ™ ! rβ‚‚) βˆ™ Ο†-comm hβ‚‚ module HToP/Q = ConstExt P/Q.El-is-set H-to-P/Q-f' H-to-P/Q-f'-const H-to-P/Q-f : Trunc -1 (hfiber φ₁.f k) β†’ P/Q.El H-to-P/Q-f = HToP/Q.ext H-to-P/Q-f-is-const : βˆ€ hf₁ hfβ‚‚ β†’ H-to-P/Q-f hf₁ == H-to-P/Q-f hfβ‚‚ H-to-P/Q-f-is-const = HToP/Q.ext-is-const abstract H-to-P/Q-f-comp : (k₁ kβ‚‚ : H.El) β†’ (hf₁₂ : Trunc -1 (hfiber φ₁.f (H.comp k₁ kβ‚‚))) β†’ (hf₁ : Trunc -1 (hfiber φ₁.f k₁)) β†’ (hfβ‚‚ : Trunc -1 (hfiber φ₁.f kβ‚‚)) β†’ H-to-P/Q-f (H.comp k₁ kβ‚‚) hf₁₂ == P/Q.comp (H-to-P/Q-f k₁ hf₁) (H-to-P/Q-f kβ‚‚ hfβ‚‚) H-to-P/Q-f-comp k₁ kβ‚‚ hf₁₂ = Trunc-elim (Ξ» hf₁ β†’ Ξ -is-prop Ξ» hfβ‚‚ β†’ P/Q.El-is-set _ (P/Q.comp (H-to-P/Q-f k₁ hf₁) (H-to-P/Q-f kβ‚‚ hfβ‚‚))) (Ξ»{(p₁ , r₁) β†’ Trunc-elim (Ξ» hfβ‚‚ β†’ P/Q.El-is-set _ (P/Q.comp q[ p₁ ] (H-to-P/Q-f kβ‚‚ hfβ‚‚))) (Ξ»{(pβ‚‚ , rβ‚‚) β†’ H-to-P/Q-f-is-const (H.comp k₁ kβ‚‚) hf₁₂ [ P.comp p₁ pβ‚‚ , φ₁.pres-comp p₁ pβ‚‚ βˆ™ ap2 H.comp r₁ rβ‚‚ ]})}) H-to-P/Q : H β†’α΄³ P/Q H-to-P/Q = record { f = Ξ» k β†’ H-to-P/Q-f k (φ₁-is-surj k); pres-comp = Ξ» k₁ kβ‚‚ β†’ H-to-P/Q-f-comp k₁ kβ‚‚ (φ₁-is-surj (H.comp k₁ kβ‚‚)) (φ₁-is-surj k₁) (φ₁-is-surj kβ‚‚)} H-iso-P/Q : H ≃ᴳ P/Q H-iso-P/Q = H-to-P/Q , is-eq to from to-from from-to where to : H.El β†’ P/Q.El to = Ξ» k β†’ H-to-P/Q-f k (φ₁-is-surj k) from : P/Q.El β†’ H.El from = SetQuot-rec H.El-is-set (Ξ» p β†’ φ₁.f p) (Ξ» {p₁} {pβ‚‚} q'p₁p₂⁻¹ β†’ Ο†β‚‚-is-inj (φ₁.f p₁) (φ₁.f pβ‚‚) $ Ο†-comm p₁ βˆ™ quot-relα΄³ {P = Q} q'p₁p₂⁻¹ βˆ™ ! (Ο†-comm pβ‚‚)) abstract to-from : βˆ€ p/q β†’ to (from p/q) == p/q to-from = SetQuot-elim (Ξ» p/q β†’ raise-level -1 $ P/Q.El-is-set _ p/q) (Ξ» p β†’ H-to-P/Q-f-is-const (φ₁.f p) (φ₁-is-surj (φ₁.f p)) [ p , idp ]) (Ξ» _ β†’ prop-has-all-paths-↓ $ P/Q.El-is-set _ _) from-to' : βˆ€ k (hf : Trunc -1 (hfiber φ₁.f k)) β†’ from (H-to-P/Q-f k hf) == k from-to' k = Trunc-elim (Ξ» hf β†’ H.El-is-set (from (H-to-P/Q-f k hf)) k) (Ξ»{(p , r) β†’ r}) from-to : βˆ€ k β†’ from (to k) == k from-to k = from-to' k (φ₁-is-surj k)
{ "alphanum_fraction": 0.4952857985, "avg_line_length": 32.9514563107, "ext": "agda", "hexsha": "e61e98d5fb6d521b1836a9fdd4072bdda7c9c2fe", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mikeshulman/HoTT-Agda", "max_forks_repo_path": "theorems/groups/PropQuotUniqueFactorization.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mikeshulman/HoTT-Agda", "max_issues_repo_path": "theorems/groups/PropQuotUniqueFactorization.agda", "max_line_length": 94, "max_stars_count": null, "max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mikeshulman/HoTT-Agda", "max_stars_repo_path": "theorems/groups/PropQuotUniqueFactorization.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1432, "size": 3394 }
{-# OPTIONS --safe --without-K #-} open import Generics.Prelude open import Generics.Telescope open import Generics.Desc open import Agda.Builtin.Reflection module Generics.Helpers P I {levelArgRel : Level β†’ Level} (ArgRel : βˆ€ {a} β†’ Set a β†’ Set (levelArgRel a)) {levelArgIrr : Level β†’ Level} (ArgIrr : βˆ€ {a} β†’ Set a β†’ Set (levelArgIrr a)) (Ind : βˆ€ {V} (C : ConDesc P V I) β†’ SetΟ‰) where data ConHelper p {V} : ConDesc P V I β†’ SetΟ‰ where instance var : βˆ€ {f} β†’ ConHelper p (var f) pi-irr : βˆ€ {β„“ n v q} {S : ⟦ P , V ⟧xtel β†’ Set β„“} (let ai = n , arg-info v (modality irrelevant q)) {C : ConDesc P (V ⊒< ai > S) I} β†’ ⦃ βˆ€ {v} β†’ ArgIrr (S (p , v)) ⦄ β†’ ⦃ ConHelper p C ⦄ β†’ ConHelper p (Ο€ ai S C) pi-rel : βˆ€ {β„“ n v q} {S : ⟦ P , V ⟧xtel β†’ Set β„“} (let ai = n , arg-info v (modality relevant q)) {C : ConDesc P (V ⊒< ai > S) I} β†’ ⦃ βˆ€ {v} β†’ ArgRel (S (p , v)) ⦄ β†’ ⦃ ConHelper p C ⦄ β†’ ConHelper p (Ο€ ai S C) prod : {A B : ConDesc P V I} β†’ ⦃ Ind A ⦄ β†’ ⦃ ConHelper p B ⦄ β†’ ConHelper p (A βŠ— B) data Helpers p : {n : β„•} β†’ DataDesc P I n β†’ SetΟ‰ where instance nil : Helpers p [] cons : βˆ€ {n} {C : ConDesc P Ξ΅ I} {D : DataDesc P I n} β†’ ⦃ ConHelper p C ⦄ β†’ ⦃ Helpers p D ⦄ β†’ Helpers p (C ∷ D) lookupHelper : βˆ€ {n} {D : DataDesc P I n} {p} (HD : Helpers p D) (k : Fin n) β†’ ConHelper p (lookupCon D k) lookupHelper (cons ⦃ HC ⦄ ⦃ HD ⦄) zero = HC lookupHelper (cons ⦃ HC ⦄ ⦃ HD ⦄) (suc k) = lookupHelper HD k
{ "alphanum_fraction": 0.402281746, "avg_line_length": 36.6545454545, "ext": "agda", "hexsha": "bc3419170d682e1fbca649d177884c4a61d506b3", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-01-14T10:35:16.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-08T08:32:42.000Z", "max_forks_repo_head_hexsha": "db764f858d908aa39ea4901669a6bbce1525f757", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "flupe/generics", "max_forks_repo_path": "src/Generics/Helpers.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "db764f858d908aa39ea4901669a6bbce1525f757", "max_issues_repo_issues_event_max_datetime": "2022-01-14T10:48:30.000Z", "max_issues_repo_issues_event_min_datetime": "2021-09-13T07:33:50.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "flupe/generics", "max_issues_repo_path": "src/Generics/Helpers.agda", "max_line_length": 71, "max_stars_count": 11, "max_stars_repo_head_hexsha": "db764f858d908aa39ea4901669a6bbce1525f757", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "flupe/generics", "max_stars_repo_path": "src/Generics/Helpers.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T09:35:17.000Z", "max_stars_repo_stars_event_min_datetime": "2021-04-08T15:10:20.000Z", "num_tokens": 641, "size": 2016 }
open import Common.Prelude hiding (_>>=_) open import Common.Reflection open import Common.Equality setβ‚€ = sort (lit 0) set! = sort unknown -- Definitions added by tactics always use the original context, and thus are not -- affected by inContext and extendContext. The reason for this is that they are added -- to the module of the macro call, so they need to live in the context of that module -- or things break. freshFun : Type β†’ List Clause β†’ Tactic freshFun t cs hole = freshName "fresh" >>= Ξ» n β†’ inContext [] (define (vArg n) (funDef t cs)) >>= Ξ» _ β†’ unify hole (def n []) macro ack : Tactic ack = freshFun set! (clause [] setβ‚€ ∷ []) theA : Tactic theA = freshFun setβ‚€ (clause [] (var 0 []) ∷ []) module Foo (A : Set) where foo : Set foo = theA bar : Set₁ bar = ack check : {A : Set} β†’ Foo.foo A ≑ A check = refl
{ "alphanum_fraction": 0.6643192488, "avg_line_length": 23.6666666667, "ext": "agda", "hexsha": "faf01473ca1f767f408bffc146614ea05a8b1d1f", "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/Issue1827.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "hborum/agda", "max_issues_repo_path": "test/Succeed/Issue1827.agda", "max_line_length": 86, "max_stars_count": 3, "max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "hborum/agda", "max_stars_repo_path": "test/Succeed/Issue1827.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": 254, "size": 852 }
{-# OPTIONS --universe-polymorphism #-} module Categories.NaturalTransformation.Core where open import Level open import Relation.Binary using (Rel; IsEquivalence) open import Categories.Support.Equivalence open import Categories.Category open import Categories.Functor.Core renaming (id to idF; _∘_ to _∘F_) record NaturalTransformation {o β„“ e oβ€² β„“β€² eβ€²} {C : Category o β„“ e} {D : Category oβ€² β„“β€² eβ€²} (F G : Functor C D) : Set (o βŠ” β„“ βŠ” e βŠ” oβ€² βŠ” β„“β€² βŠ” eβ€²) where private module C = Category C private module D = Category D private module F = Functor F private module G = Functor G open F using (Fβ‚€; F₁) open G using () renaming (Fβ‚€ to Gβ‚€; F₁ to G₁) field Ξ· : βˆ€ X β†’ D [ Fβ‚€ X , Gβ‚€ X ] .commute : βˆ€ {X Y} (f : C [ X , Y ]) β†’ D.CommutativeSquare (F₁ f) (Ξ· X) (Ξ· Y) (G₁ f) op : NaturalTransformation G.op F.op op = record { Ξ· = Ξ· ; commute = Ξ» f β†’ D.Equiv.sym (commute f) } id : βˆ€ {o β„“ e oβ€² β„“β€² eβ€²} {C : Category o β„“ e} {D : Category oβ€² β„“β€² eβ€²} {F : Functor C D} β†’ NaturalTransformation F F id {C = C} {D} {F} = record { Ξ· = Ξ» _ β†’ D.id ; commute = commuteβ€² } where module C = Category C module D = Category D module F = Functor F open F .commuteβ€² : βˆ€ {X Y} (f : C [ X , Y ]) β†’ D [ D [ D.id ∘ F₁ f ] ≑ D [ F₁ f ∘ D.id ] ] commuteβ€² f = begin D [ D.id ∘ F₁ f ] β†“βŸ¨ D.identityΛ‘ ⟩ F₁ f β†‘βŸ¨ D.identityΚ³ ⟩ D [ F₁ f ∘ D.id ] ∎ where open D.HomReasoning infixr 9 _βˆ˜β‚_ _βˆ˜β‚€_ -- "Vertical composition" _βˆ˜β‚_ : βˆ€ {oβ‚€ β„“β‚€ eβ‚€ o₁ ℓ₁ e₁} {C : Category oβ‚€ β„“β‚€ eβ‚€} {D : Category o₁ ℓ₁ e₁} {F G H : Functor C D} β†’ NaturalTransformation G H β†’ NaturalTransformation F G β†’ NaturalTransformation F H _βˆ˜β‚_ {C = C} {D} {F} {G} {H} X Y = record { Ξ· = Ξ» q β†’ D [ X.Ξ· q ∘ Y.Ξ· q ] ; commute = commuteβ€² } where module C = Category C module D = Category D module F = Functor F module G = Functor G module H = Functor H module X = NaturalTransformation X module Y = NaturalTransformation Y open F open G renaming (Fβ‚€ to Gβ‚€; F₁ to G₁) open H renaming (Fβ‚€ to Hβ‚€; F₁ to H₁) .commuteβ€² : βˆ€ {A B} (f : C [ A , B ]) β†’ D [ D [ D [ X.Ξ· B ∘ Y.Ξ· B ] ∘ F₁ f ] ≑ D [ H₁ f ∘ D [ X.Ξ· A ∘ Y.Ξ· A ] ] ] commuteβ€² {A} {B} f = begin D [ D [ X.Ξ· B ∘ Y.Ξ· B ] ∘ F₁ f ] β†“βŸ¨ D.assoc ⟩ D [ X.Ξ· B ∘ D [ Y.Ξ· B ∘ F₁ f ] ] β†“βŸ¨ D.∘-resp-≑ʳ (Y.commute f) ⟩ D [ X.Ξ· B ∘ D [ G₁ f ∘ Y.Ξ· A ] ] β†‘βŸ¨ D.assoc ⟩ D [ D [ X.Ξ· B ∘ G₁ f ] ∘ Y.Ξ· A ] β†“βŸ¨ D.∘-resp-≑ˑ (X.commute f) ⟩ D [ D [ H₁ f ∘ X.Ξ· A ] ∘ Y.Ξ· A ] β†“βŸ¨ D.assoc ⟩ D [ H₁ f ∘ D [ X.Ξ· A ∘ Y.Ξ· A ] ] ∎ where open D.HomReasoning -- "Horizontal composition" _βˆ˜β‚€_ : βˆ€ {oβ‚€ β„“β‚€ eβ‚€ o₁ ℓ₁ e₁ oβ‚‚ β„“β‚‚ eβ‚‚} {C : Category oβ‚€ β„“β‚€ eβ‚€} {D : Category o₁ ℓ₁ e₁} {E : Category oβ‚‚ β„“β‚‚ eβ‚‚} {F G : Functor C D} {H I : Functor D E} β†’ NaturalTransformation H I β†’ NaturalTransformation F G β†’ NaturalTransformation (H ∘F F) (I ∘F G) _βˆ˜β‚€_ {C = C} {D} {E} {F} {G} {H} {I} Y X = record { Ξ· = Ξ» q β†’ E [ I₁ (X.Ξ· q) ∘ Y.Ξ· (Fβ‚€ q) ] ; commute = commuteβ€² } where module C = Category C module D = Category D module E = Category E module F = Functor F module G = Functor G module H = Functor H module I = Functor I module X = NaturalTransformation X module Y = NaturalTransformation Y open F open G renaming (Fβ‚€ to Gβ‚€; F₁ to G₁; F-resp-≑ to G-resp-≑) open H renaming (Fβ‚€ to Hβ‚€; F₁ to H₁; F-resp-≑ to H-resp-≑) open I renaming (Fβ‚€ to Iβ‚€; F₁ to I₁; F-resp-≑ to I-resp-≑) .commuteβ€² : βˆ€ {A B} (f : C [ A , B ]) β†’ E [ E [ E [ I₁ (X.Ξ· B) ∘ Y.Ξ· (Fβ‚€ B) ] ∘ H₁ (F₁ f) ] ≑ E [ I₁ (G₁ f) ∘ E [ I₁ (X.Ξ· A) ∘ Y.Ξ· (Fβ‚€ A) ] ] ] commuteβ€² {A} {B} f = begin E [ E [ I₁ (X.Ξ· B) ∘ Y.Ξ· (Fβ‚€ B) ] ∘ H₁ (F₁ f) ] β†“βŸ¨ E.assoc ⟩ E [ I₁ (X.Ξ· B) ∘ E [ Y.Ξ· (Fβ‚€ B) ∘ H₁ (F₁ f) ] ] β†“βŸ¨ E.∘-resp-≑ʳ (Y.commute (F₁ f)) ⟩ E [ I₁ (X.Ξ· B) ∘ E [ I₁ (F₁ f) ∘ Y.Ξ· (Fβ‚€ A) ] ] β†‘βŸ¨ E.assoc ⟩ E [ E [ I₁ (X.Ξ· B) ∘ I₁ (F₁ f) ] ∘ Y.Ξ· (Fβ‚€ A) ] β†‘βŸ¨ E.∘-resp-≑ˑ I.homomorphism ⟩ E [ I₁ (D [ X.Ξ· B ∘ F₁ f ]) ∘ Y.Ξ· (Fβ‚€ A) ] β†“βŸ¨ E.∘-resp-≑ˑ (I-resp-≑ (X.commute f)) ⟩ E [ I₁ (D [ G₁ f ∘ X.Ξ· A ]) ∘ Y.Ξ· (Fβ‚€ A) ] β†“βŸ¨ E.∘-resp-≑ˑ I.homomorphism ⟩ E [ E [ I₁ (G₁ f) ∘ I₁ (X.Ξ· A) ] ∘ Y.Ξ· (Fβ‚€ A) ] β†“βŸ¨ E.assoc ⟩ E [ I₁ (G₁ f) ∘ E [ I₁ (X.Ξ· A) ∘ Y.Ξ· (Fβ‚€ A) ] ] ∎ where open E.HomReasoning infix 4 _≑_ _≑_ : βˆ€ {o β„“ e oβ€² β„“β€² eβ€²} {C : Category o β„“ e} {D : Category oβ€² β„“β€² eβ€²} {F G : Functor C D} β†’ Rel (NaturalTransformation F G) (o βŠ” eβ€²) _≑_ {D = D} X Y = βˆ€ {x} β†’ D [ NaturalTransformation.Ξ· X x ≑ NaturalTransformation.Ξ· Y x ] .equiv : βˆ€ {o β„“ e oβ€² β„“β€² eβ€²} {C : Category o β„“ e} {D : Category oβ€² β„“β€² eβ€²} {F G : Functor C D} β†’ IsEquivalence (_≑_ {F = F} {G}) equiv {C = C} {D} {F} {G} = record { refl = refl ; sym = Ξ» f β†’ sym f ; trans = Ξ» f g β†’ trans f g } where open Category.Equiv D setoid : βˆ€ {o β„“ e oβ€² β„“β€² eβ€²} {C : Category o β„“ e} {D : Category oβ€² β„“β€² eβ€²} {F G : Functor C D} β†’ Setoid _ _ setoid {F = F} {G} = record { Carrier = NaturalTransformation F G ; _β‰ˆ_ = _≑_ ; isEquivalence = equiv {F = F} }
{ "alphanum_fraction": 0.4865611193, "avg_line_length": 33.3251533742, "ext": "agda", "hexsha": "21d3429bc17d0c0c77bc2b93c7b46847b1d513ba", "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": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Categories/NaturalTransformation/Core.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "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": "p-pavel/categories", "max_issues_repo_path": "Categories/NaturalTransformation/Core.agda", "max_line_length": 145, "max_stars_count": 1, "max_stars_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "p-pavel/categories", "max_stars_repo_path": "Categories/NaturalTransformation/Core.agda", "max_stars_repo_stars_event_max_datetime": "2018-12-29T21:51:57.000Z", "max_stars_repo_stars_event_min_datetime": "2018-12-29T21:51:57.000Z", "num_tokens": 2288, "size": 5432 }
------------------------------------------------------------------------ -- INCREMENTAL Ξ»-CALCULUS -- -- Incrementalization as term-to-term transformation with the Nehemiah plugin. ------------------------------------------------------------------------ module Nehemiah.Change.Derive where open import Nehemiah.Syntax.Type open import Nehemiah.Syntax.Term open import Nehemiah.Change.Type open import Nehemiah.Change.Term open import Data.Integer import Parametric.Change.Derive Const Ξ”Base as Derive derive-const : Derive.Structure derive-const (intlit-const n) = intlit (+ 0) derive-const add-const = absV 4 (Ξ» s ds t dt β†’ add ds dt) derive-const minus-const = absV 2 (Ξ» t dt β†’ minus dt) derive-const empty-const = empty derive-const insert-const = absV 4 (Ξ» s ds t dt β†’ insert (s βŠ•β‚ int β‚Ž ds) (t βŠ•β‚ bag β‚Ž dt) ⊝ insert s t) derive-const union-const = absV 4 (Ξ» s ds t dt β†’ union ds dt) derive-const negate-const = absV 2 (Ξ» t dt β†’ negate dt) derive-const flatmap-const = absV 4 (Ξ» s ds t dt β†’ flatmap (s βŠ•β‚ int β‡’ bag β‚Ž ds) (t βŠ•β‚ bag β‚Ž dt) ⊝ flatmap s t) derive-const sum-const = absV 2 (Ξ» t dt β†’ sum dt) open Derive.Structure derive-const public
{ "alphanum_fraction": 0.6076794658, "avg_line_length": 37.4375, "ext": "agda", "hexsha": "21149a18e05d1a806bc9f49ec251495f16f1c0ab", "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": "Nehemiah/Change/Derive.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": "Nehemiah/Change/Derive.agda", "max_line_length": 78, "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": "Nehemiah/Change/Derive.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": 348, "size": 1198 }
module InferrableFields where data β„• : Set where zero : β„• suc : β„• β†’ β„• data Vec A : β„• β†’ Set where [] : Vec A zero _∷_ : βˆ€ {n} β†’ A β†’ Vec A n β†’ Vec A (suc n) record SomeVec A : Set where field n : β„• unpack : Vec A n open SomeVec using (unpack) pack : βˆ€ {A n} β†’ Vec A n -> SomeVec A pack xs = record { unpack = xs } data _≑_ {A : Set}(x : A) : A β†’ Set where refl : x ≑ x lemPack : βˆ€ {A}(xs : SomeVec A) β†’ pack (unpack xs) ≑ xs lemPack xs = refl
{ "alphanum_fraction": 0.5567226891, "avg_line_length": 18.3076923077, "ext": "agda", "hexsha": "fd83fa80359e7e191d9107ae843c9e9e61e8c429", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_path": "test/Succeed/InferrableFields.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_path": "test/Succeed/InferrableFields.agda", "max_line_length": 55, "max_stars_count": 3, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/Succeed/InferrableFields.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": 179, "size": 476 }
-- {-# OPTIONS -v scope.operators:100 #-} module Issue675 where data D : Set where d : D β†’ D Foo : {x : D} β†’ Set₁ Foo {x = D.d x} = Set -- qualified constructors should also work in hidden arguments
{ "alphanum_fraction": 0.645320197, "avg_line_length": 20.3, "ext": "agda", "hexsha": "53beaeb30d2e0c56fff4ebd657bc8222d84dbfb5", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/Issue675.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/Issue675.agda", "max_line_length": 62, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue675.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": 62, "size": 203 }
module Functor where open import Level import Data.Nat as N open import Basic open import Category open Category.Category record Functor {cβ‚€ c₁ β„“ cβ‚€β€² c₁′ β„“β€²} (C : Category cβ‚€ c₁ β„“) (D : Category cβ‚€β€² c₁′ β„“β€²) : Set (suc (cβ‚€ βŠ” cβ‚€β€² βŠ” c₁ βŠ” c₁′ βŠ” β„“ βŠ” β„“β€²)) where field fobj : Obj C β†’ Obj D fmapsetoid : {A B : Obj C} β†’ Map.Map (Homsetoid C A B) (Homsetoid D (fobj A) (fobj B)) fmap : {A B : Obj C} β†’ Hom C A B β†’ Hom D (fobj A) (fobj B) fmap {A} {B} = Map.Map.mapping (fmapsetoid {A} {B}) field preserveId : {A : Obj C} β†’ D [ fmap (id C {A}) β‰ˆ id D {fobj A} ] preserveComp : {a b c : Obj C} {f : Hom C b c} {g : Hom C a b} β†’ D [ fmap (C [ f ∘ g ]) β‰ˆ (D [ fmap f ∘ fmap g ]) ] open Functor preserveEq : βˆ€ {cβ‚€ c₁ β„“ cβ‚€β€² c₁′ β„“β€²} {C : Category cβ‚€ c₁ β„“} {D : Category cβ‚€β€² c₁′ β„“β€²} {A B : Obj C} {x y : Hom C A B} (F : Functor C D) β†’ C [ x β‰ˆ y ] β†’ D [ fmap F x β‰ˆ fmap F y ] preserveEq F xy = Map.Map.preserveEq (fmapsetoid F) xy compose : βˆ€ {cβ‚€ c₁ β„“ cβ‚€β€² c₁′ β„“β€² cβ‚€β€³ c₁″ β„“β€³} {C : Category cβ‚€ c₁ β„“} {D : Category cβ‚€β€² c₁′ β„“β€²} {E : Category cβ‚€β€³ c₁″ β„“β€³} β†’ Functor {cβ‚€β€²} {c₁′} {β„“β€²} {cβ‚€β€³} {c₁″} {β„“β€³} D E β†’ Functor {cβ‚€} {c₁} {β„“} {cβ‚€β€²} {c₁′} {β„“β€²} C D β†’ Functor {cβ‚€} {c₁} {β„“} {cβ‚€β€³} {c₁″} {β„“β€³} C E compose {C = C} {D} {E} G F = record { fobj = Ξ» x β†’ fobj G (fobj F x); fmapsetoid = record { mapping = Ξ» f β†’ fmap G (fmap F f) ; preserveEq = Ξ» {x} {y} xβ‰ˆy β†’ begin⟨ E ⟩ fmap G (fmap F x) β‰ˆβŸ¨ preserveEq G (begin⟨ D ⟩ fmap F x β‰ˆβŸ¨ preserveEq F xβ‰ˆy ⟩ fmap F y ∎) ⟩ fmap G (fmap F y) ∎ }; preserveId = begin⟨ E ⟩ fmap G (fmap F (id C)) β‰ˆβŸ¨ preserveEq G (preserveId F) ⟩ fmap G (id D) β‰ˆβŸ¨ preserveId G ⟩ (id E) ∎; preserveComp = Ξ» {_} {_} {_} {f} {g} β†’ begin⟨ E ⟩ fmap G (fmap F (C [ f ∘ g ])) β‰ˆβŸ¨ preserveEq G (preserveComp F) ⟩ fmap G (D [ fmap F f ∘ fmap F g ]) β‰ˆβŸ¨ preserveComp G ⟩ (E [ fmap G (fmap F f) ∘ fmap G (fmap F g) ]) ∎ } identity : βˆ€ {cβ‚€ c₁ β„“} (C : Category cβ‚€ c₁ β„“) β†’ Functor {cβ‚€} {c₁} {β„“} {cβ‚€} {c₁} {β„“} C C identity C = record { fobj = Ξ» x β†’ x ; fmapsetoid = record { mapping = Ξ» x β†’ x ; preserveEq = Ξ» x₁ β†’ x₁ } ; preserveId = refl-hom C ; preserveComp = refl-hom C } exp : βˆ€ {cβ‚€ c₁ β„“} {C : Category cβ‚€ c₁ β„“} β†’ Functor C C β†’ N.β„• β†’ Functor C C exp {C = C} F N.zero = identity C exp F (N.suc N.zero) = F exp F (N.suc n) = compose F (exp F n) data _[_~_] {Cβ‚€ C₁ β„“ : Level} (C : Category Cβ‚€ C₁ β„“) {A B : Obj C} (f : Hom C A B) : βˆ€{X Y : Obj C} β†’ Hom C X Y β†’ Set (suc (Cβ‚€ βŠ” C₁ βŠ” β„“)) where eqArrow : {g : Hom C A B} β†’ C [ f β‰ˆ g ] β†’ C [ f ~ g ] eqArrowRefl : βˆ€ {cβ‚€ c₁ β„“} (C : Category cβ‚€ c₁ β„“) {A B : Obj C} {f : Hom C A B} β†’ C [ f ~ f ] eqArrowRefl C = eqArrow (refl-hom C) eqArrowSym : βˆ€ {cβ‚€ c₁ β„“} (C : Category cβ‚€ c₁ β„“) {X Y Z W : Obj C} {f : Hom C X Y} {g : Hom C Z W} β†’ C [ f ~ g ] β†’ C [ g ~ f ] eqArrowSym C (eqArrow f~g) = eqArrow (sym-hom C f~g) eqArrowTrans : βˆ€ {cβ‚€ c₁ β„“} (C : Category cβ‚€ c₁ β„“) {X Y Z W S T : Obj C} {f : Hom C X Y} {g : Hom C Z W} {h : Hom C S T} β†’ C [ f ~ g ] β†’ C [ g ~ h ] β†’ C [ f ~ h ] eqArrowTrans C (eqArrow f~g) (eqArrow g~h) = eqArrow (trans-hom C f~g g~h) eqArrowFmap : βˆ€ {cβ‚€ c₁ β„“ cβ‚€β€² c₁′ β„“β€²} {C : Category cβ‚€ c₁ β„“} {D : Category cβ‚€β€² c₁′ β„“β€²} {X Y Z W : Obj C} {x : Category.Hom C X Y} {y : Category.Hom C Z W} (F : Functor C D) β†’ C [ x ~ y ] β†’ D [ fmap F x ~ fmap F y ] eqArrowFmap F (eqArrow x~y) = eqArrow (preserveEq F x~y) equality : βˆ€ {cβ‚€ c₁ β„“} {C D : Category cβ‚€ c₁ β„“} β†’ (F G : Functor C D) β†’ _ equality {C = C} {D} F G = βˆ€ {A B : Obj C} (f : Hom C A B) β†’ D [ fmap F f ~ fmap G f ] Cat : βˆ€ {cβ‚€ c₁ β„“} β†’ Category (suc (cβ‚€ βŠ” c₁ βŠ” β„“)) _ _ Cat {cβ‚€} {c₁} {β„“} = record { Obj = Category cβ‚€ c₁ β„“; Homsetoid = Ξ» A B β†’ record { Carrier = Functor A B ; _β‰ˆ_ = equality ; isEquivalence = record { refl = Ξ» f β†’ eqArrowRefl B ; sym = Ξ» x f β†’ eqArrowSym B (x f); trans = Ξ» x x₁ f β†’ eqArrowTrans B (x f) (x₁ f) } }; comp = compose; id = Ξ» {A} β†’ identity A; leftId = Ξ» {A} {B} {f} f₁ β†’ eqArrow (refl-hom B); rightId = Ξ» {A} {B} {f} f₁ β†’ eqArrow (refl-hom B); assoc = Ξ» {A} {B} {C} {D} {f} {g} {h} f₁ β†’ eqArrow (begin⟨ D ⟩ fmap (compose (compose h g) f) f₁ β‰ˆβŸ¨ refl-hom D ⟩ fmap h (fmap g (fmap f f₁)) β‰ˆβŸ¨ refl-hom D ⟩ fmap (compose h (compose g f)) f₁ ∎); β‰ˆ-composite = Ξ» {A} {B} {C} {f} {g} {h} {i} f~g h~i f₁ β†’ eqArrowTrans C (f~g (fmap h f₁)) (eqArrowFmap g (h~i f₁)) }
{ "alphanum_fraction": 0.5287329795, "avg_line_length": 44.2142857143, "ext": "agda", "hexsha": "6f1f36cd84452d76867b7ee1f7cf5930bf28b137", "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": "59004994acdbc65fb4f8abf0baa1777a8dbe758e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "myuon/agda-cate", "max_forks_repo_path": "src/Functor.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "59004994acdbc65fb4f8abf0baa1777a8dbe758e", "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": "myuon/agda-cate", "max_issues_repo_path": "src/Functor.agda", "max_line_length": 256, "max_stars_count": 2, "max_stars_repo_head_hexsha": "59004994acdbc65fb4f8abf0baa1777a8dbe758e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "myuon/agda-cate", "max_stars_repo_path": "src/Functor.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-02T07:30:47.000Z", "max_stars_repo_stars_event_min_datetime": "2018-07-28T04:59:31.000Z", "num_tokens": 2008, "size": 4333 }
-- Bi-Cartesian closed structure of families module SOAS.Families.BCCC {T : Set} where open import SOAS.Common open import SOAS.Context {T} open import SOAS.Sorting {T} open import SOAS.Families.Core {T} open import SOAS.Families.Isomorphism {T} import Categories.Category.CartesianClosed.Canonical as Canonical import Categories.Category.CartesianClosed as CCC import Categories.Category.Cartesian as Cart open import Categories.Category.Cocartesian open import Categories.Category.BicartesianClosed import Categories.Object.Initial as Initial open import Categories.Category.Monoidal import Data.Unit as Unit import Data.Empty as Empty -- | Unsorted -- Category of families is Cartesian closed 𝔽am-CanCCC : Canonical.CartesianClosed 𝔽amilies 𝔽am-CanCCC = record { ⊀ = Ξ» Ξ“ β†’ Unit.⊀ ; _Γ—_ = Ξ» X Y Ξ“ β†’ X Ξ“ Γ— Y Ξ“ ; ! = Ξ» _ β†’ Unit.tt ; π₁ = proj₁ ; Ο€β‚‚ = projβ‚‚ ; ⟨_,_⟩ = Ξ» f g x β†’ f x , g x ; !-unique = Ξ» f β†’ refl ; π₁-comp = refl ; Ο€β‚‚-comp = refl ; ⟨,⟩-unique = Ξ» p₁ pβ‚‚ {Ξ“}{x} β†’ sym (congβ‚‚ _,_ p₁ pβ‚‚) ; _^_ = Ξ» X Y Ξ“ β†’ Y Ξ“ β†’ X Ξ“ ; eval = Ξ»{ (f , x) β†’ f x} ; curry = Ξ» f x y β†’ f (x , y) ; eval-comp = refl ; curry-resp-β‰ˆ = Ξ»{X}{Y}{Z}{f}{g} p β†’ ext (Ξ» x β†’ p) ; curry-unique = Ξ» p β†’ ext (Ξ» x β†’ p) } 𝔽am-CCC : CCC.CartesianClosed 𝔽amilies 𝔽am-CCC = Canonical.Equivalence.fromCanonical _ 𝔽am-CanCCC module 𝔽am-CCC = CCC.CartesianClosed 𝔽am-CCC -- Category of families is co-Cartesian 𝔽am-Cocartesian : Cocartesian 𝔽amilies 𝔽am-Cocartesian = record { initial = record { βŠ₯ = Ξ» Ξ“ β†’ Empty.βŠ₯ ; βŠ₯-is-initial = record { ! = Ξ» () ; !-unique = Ξ»{ f {Ξ“} {()}} } } ; coproducts = record { coproduct = Ξ»{X}{Y} β†’ record { A+B = Ξ» Ξ“ β†’ X Ξ“ ⊎ Y Ξ“ ; i₁ = inj₁ ; iβ‚‚ = injβ‚‚ ; [_,_] = Ξ»{ f g (inj₁ x) β†’ f x ; f g (injβ‚‚ y) β†’ g y} ; inject₁ = refl ; injectβ‚‚ = refl ; unique = Ξ»{ p₁ pβ‚‚ {Ξ“} {inj₁ x} β†’ sym p₁ ; p₁ pβ‚‚ {Ξ“} {injβ‚‚ y} β†’ sym pβ‚‚} } } } module 𝔽am-Cocart = Cocartesian 𝔽am-Cocartesian -- Category of families is bi-Cartesian closed 𝔽am-BCCC : BicartesianClosed 𝔽amilies 𝔽am-BCCC = record { cartesianClosed = 𝔽am-CCC ; cocartesian = 𝔽am-Cocartesian } module 𝔽am-BCCC = BicartesianClosed 𝔽am-BCCC -- Shorthand for family product and sum and exponential _Γ—β‚˜_ : Family β†’ Family β†’ Family _Γ—β‚˜_ = 𝔽am-CCC._Γ—_ _+β‚˜_ : Family β†’ Family β†’ Family _+β‚˜_ = 𝔽am-Cocart._+_ _⇨_ : Family β†’ Family β†’ Family _⇨_ = 𝔽am-CCC._⇨_ infixr 25 _⇨_ βŠ€β‚˜ : Family βŠ€β‚˜ Ξ“ = Unit.⊀ private variable X Y Z W : Family curryβ‚˜-iso : (X Γ—β‚˜ Y β‡Ύ Z) β‰…β‚› (X β‡Ύ Y ⇨ Z) curryβ‚˜-iso = record { from = Ξ» f x y β†’ f (x , y) ; to = Ξ»{ f (x , y) β†’ f x y } ; iso = record { isoΛ‘ = refl ; isoΚ³ = refl } } -- Congruence for indexed families of functions β‡Ύ-cong : X β‰…β‚˜ Y β†’ W β‰…β‚˜ Z β†’ (X β‡Ύ W) β‰…β‚› (Y β‡Ύ Z) β‡Ύ-cong Xβ‰…Y Wβ‰…Z = record { from = Ξ» f y β†’ _β‰…β‚˜_.from Wβ‰…Z (f (_β‰…β‚˜_.to Xβ‰…Y y)) ; to = Ξ» g x β†’ _β‰…β‚˜_.to Wβ‰…Z (g (_β‰…β‚˜_.from Xβ‰…Y x)) ; iso = record { isoΛ‘ = Ξ» {f} β†’ dextβ€² (trans (_β‰…β‚˜_.isoΛ‘ Wβ‰…Z) (cong f (_β‰…β‚˜_.isoΛ‘ Xβ‰…Y))) ; isoΚ³ = Ξ» {g} β†’ dextβ€² (trans (_β‰…β‚˜_.isoΚ³ Wβ‰…Z) (cong g (_β‰…β‚˜_.isoΚ³ Xβ‰…Y))) } } β‡Ύ-β‰…dom : X β‰…β‚˜ Y β†’ (X β‡Ύ W) β‰…β‚› (Y β‡Ύ W) β‡Ύ-β‰…dom Xβ‰…Y = β‡Ύ-cong Xβ‰…Y β‰…β‚˜.refl β‡Ύ-β‰…cod : W β‰…β‚˜ Z β†’ (X β‡Ύ W) β‰…β‚› (X β‡Ύ Z) β‡Ύ-β‰…cod Wβ‰…Z = β‡Ύ-cong β‰…β‚˜.refl Wβ‰…Z -- | Sorted -- Category of sorted families is Cartesian closed 𝔽amβ‚›-CanCCC : Canonical.CartesianClosed 𝔽amiliesβ‚› 𝔽amβ‚›-CanCCC = π•Šorted-CanCCC 𝔽am-CanCCC 𝔽amβ‚›-CCC : CCC.CartesianClosed 𝔽amiliesβ‚› 𝔽amβ‚›-CCC = Canonical.Equivalence.fromCanonical _ 𝔽amβ‚›-CanCCC -- Category of sorted families is co-Cartesian 𝔽amβ‚›-Cocartesian : Cocartesian 𝔽amiliesβ‚› 𝔽amβ‚›-Cocartesian = π•Šorted-Cocartesian 𝔽am-Cocartesian -- Category of sorted families is bi-Cartesian closed 𝔽amβ‚›-BCCC : BicartesianClosed 𝔽amiliesβ‚› 𝔽amβ‚›-BCCC = π•Šorted-BCCC 𝔽am-BCCC module 𝔽amβ‚›-CCC = CCC.CartesianClosed 𝔽amβ‚›-CCC module 𝔽amβ‚›-Cocart = Cocartesian 𝔽amβ‚›-Cocartesian 𝔽amβ‚›-Mon : Monoidal 𝔽amiliesβ‚› 𝔽amβ‚›-Mon = Cart.CartesianMonoidal.monoidal 𝔽amiliesβ‚› 𝔽amβ‚›-CCC.cartesian -- Shorthand for sorted family product and sum and exponential _Γ—Μ£β‚˜_ : Familyβ‚› β†’ Familyβ‚› β†’ Familyβ‚› _Γ—Μ£β‚˜_ = 𝔽amβ‚›-CCC._Γ—_ _+Μ£β‚˜_ : Familyβ‚› β†’ Familyβ‚› β†’ Familyβ‚› _+Μ£β‚˜_ = 𝔽amβ‚›-Cocart._+_ _⇨̣_ : Familyβ‚› β†’ Familyβ‚› β†’ Familyβ‚› _⇨̣_ = 𝔽amβ‚›-CCC._⇨_ infixr 25 _⇨̣_
{ "alphanum_fraction": 0.6489874638, "avg_line_length": 28.2176870748, "ext": "agda", "hexsha": "2b273fac2bf8d1ace452a764f53e13f4724d1fb8", "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/Families/BCCC.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/Families/BCCC.agda", "max_line_length": 108, "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/Families/BCCC.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": 1856, "size": 4148 }
module test where open import Relation.Binary.PropositionalEquality module NewCodata where open import Data.Nat open import Data.List open import Data.Maybe record Pair (A B : Set) : Set where field fst : A snd : B record Stream (A : Set) : Set where coinductive field hd : A tl : Stream A open Stream repeat : βˆ€ {A : Set} β†’ A β†’ Stream A hd (repeat x) = x tl (repeat x) = repeat x nth : βˆ€ {A : Set} β†’ β„• β†’ Stream A β†’ A nth zero s = hd s nth (suc n) s = nth n (tl s) mutual data ΞΌColist (A : Set) : Set where [] : ΞΌColist A _∷_ : (x : A) (xs : Ξ½Colist A) β†’ ΞΌColist A record Ξ½Colist (A : Set) : Set where coinductive field out : ΞΌColist A open Ξ½Colist record Ξ½Tree (A : Set) : Set where coinductive field label : A subs : List (Ξ½Tree A) open Ξ½Tree append : {A : Set} β†’ List A β†’ Ξ½Colist A β†’ Ξ½Colist A out (append [] ys) = out ys out (append (x ∷ xs) ys) = x ∷ append xs ys appendS : {A : Set} β†’ List A β†’ Stream A β†’ Stream A hd (appendS [] s) = hd s hd (appendS (x ∷ xs) s) = x tl (appendS [] s) = tl s tl (appendS (x ∷ xs) s) = tl (appendS xs s) record Pi (A : Set) (B : A β†’ Set) : Set where field _$_ : (x : A) β†’ B x infixl 20 _$_ open Pi _β†’'_ : Set β†’ Set β†’ Set A β†’' B = Pi A (Ξ» _ β†’ B) infixr 20 _β†’'_ plus2 : β„• β†’' β„• plus2 $ x = suc (suc x) plus : β„• β†’' β„• β†’' β„• plus $ 0 $ m = m plus $ (suc n) $ m = suc (plus $ n $ m) data Vec (A : Set) : β„• β†’ Set where nil : Vec A 0 _:::_ : {n : β„•} β†’ A β†’ Vec A n β†’ Vec A (suc n) test : Vec β„• 2 test = 2 ::: (2 ::: nil) repeat2V : Pi β„• (Ξ» n β†’ Vec β„• n) repeat2V $ 0 = nil repeat2V $ suc n = 2 ::: (repeat2V $ n) {- bf : {A : Set} β†’ List (Ξ½Tree A) β†’ Ξ½Colist A out (bf []) = [] out (bf (t ∷ ts)) = label t ∷ append (map label ts) (bf (concatMap subs (t ∷ ts))) -} record β„•βˆž : Set where coinductive field pred∞ : Maybe β„•βˆž open β„•βˆž infinity : β„•βˆž pred∞ infinity = just infinity zero∞ : β„•βˆž pred∞ zero∞ = nothing one∞ : β„•βˆž pred∞ one∞ = just zero∞ suc∞ : β„•βˆž β†’ β„•βˆž pred∞ (suc∞ x) = just x plus∞ : β„•βˆž β†’ β„•βˆž β†’ β„•βˆž pred∞ (plus∞ n m) with pred∞ n ... | nothing = pred∞ m ... | just n' = just (plus∞ n' m) {- record PStr (A : Set) (n : β„•βˆž) : Set where coinductive field phd : (k : β„•βˆž) β†’ PStr A (suc∞ k) β†’ A ptl : (k : β„•βˆž) β†’ PStr A (suc∞ k) β†’ PStr A k -} module OldCodata where open import Codata.Musical.Notation open import Data.Nat data Stream (A : Set) : Set where cons : A β†’ ∞ (Stream A) β†’ Stream A repeat : {A : Set} β†’ A β†’ Stream A repeat x = cons x (β™― (repeat x)) nth : {A : Set} β†’ β„• β†’ Stream A β†’ A nth 0 (cons x _) = x nth (suc n) (cons _ xs) = nth n (β™­ xs) data β„•βˆž : Set where zero∞ : β„•βˆž suc∞ : ∞ (β„•βˆž) β†’ β„•βˆž infinity : β„•βˆž infinity = suc∞ (β™― infinity) module NonTerminating where open import Data.Nat {- _/_ : β„• β†’ β„• β†’ β„• zero / y = zero suc x / y = suc ( (x ∸ y) / y) -} module PositiveSizedTypes where open import Agda.Builtin.Size data β„• : Size β†’ Set where zero : {i : Size} β†’ β„• i suc : {i : Size} β†’ β„• i β†’ β„• (↑ i) one : β„• ∞ one = suc zero two : β„• ∞ two = suc one three : β„• ∞ three = suc two four : β„• ∞ four = suc three five : β„• ∞ five = suc four _-_ : {i : Size} β†’ β„• i β†’ β„• ∞ β†’ β„• i zero - _ = zero n - zero = n (suc n) - (suc m) = n - m infixl 20 _-_ -test₁ : five - two ≑ three -test₁ = refl _/_ : {i : Size} β†’ β„• i β†’ β„• ∞ β†’ β„• i zero / _ = zero suc x / y = suc ( (x - y) / y) infixl 30 _/_ _+_ : β„• ∞ β†’ β„• ∞ β†’ β„• ∞ zero + y = y suc x + y = suc (x + y) infixl 20 _+_ _*_ : β„• ∞ β†’ β„• ∞ β†’ β„• ∞ zero * _ = zero suc x * y = x + x * y infixl 30 _*_ min : {i : Size} β†’ β„• i β†’ β„• i β†’ β„• i min zero _ = zero min _ zero = zero min (suc m) (suc n) = suc (min m n) test₁ : zero / zero ≑ zero test₁ = refl testβ‚‚ : zero / five ≑ zero testβ‚‚ = refl test₃ : one / one ≑ one test₃ = refl testβ‚„ : two / two ≑ one testβ‚„ = refl testβ‚… : five / five ≑ one testβ‚… = refl test₆ : one / zero ≑ one test₆ = refl test₇ : two / one ≑ one test₇ = refl testβ‚ˆ : four / two ≑ two testβ‚ˆ = refl module NegativSizedTypes where open import Agda.Builtin.Size open import Data.Nat open import Data.Bool using (if_then_else_) open import Relation.Nullary.Decidable using (⌊_βŒ‹) record Stream (i : Size) (A : Set) : Set where coinductive field hd : A tl : βˆ€ {j : Size< i} β†’ Stream j A open Stream cons : {i : Size} {A : Set} β†’ A -> Stream i A β†’ Stream i A hd (cons x _) = x tl (cons _ xs) = xs map : {A B : Set} {i : Size} β†’ (A β†’ B) β†’ Stream i A β†’ Stream i B hd (map f xs) = f (hd xs) tl (map f xs) = map f (tl xs) merge : {i : Size} β†’ Stream i β„• β†’ Stream i β„• β†’ Stream i β„• hd (merge xs ys) = hd xs βŠ“ hd ys tl (merge xs ys) = if ⌊ hd xs ≀? hd ys βŒ‹ then cons (hd ys) (merge (tl xs) (tl ys)) else cons (hd xs) (merge (tl xs) (tl ys)) ham : {i : Size} β†’ Stream i β„• hd ham = 1 tl ham = (merge (map (_*_ 2) ham) (map (_*_ 3) ham))
{ "alphanum_fraction": 0.503948853, "avg_line_length": 21.272, "ext": "agda", "hexsha": "1aff282ebdecfdb8002d87d17de46eb12a9401fd", "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": "68afff2b0a7183751737ef20e713df1fef3d4cf2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "StillerHarpo/masterarbeit", "max_forks_repo_path": "doc/test.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "68afff2b0a7183751737ef20e713df1fef3d4cf2", "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": "StillerHarpo/masterarbeit", "max_issues_repo_path": "doc/test.agda", "max_line_length": 66, "max_stars_count": null, "max_stars_repo_head_hexsha": "68afff2b0a7183751737ef20e713df1fef3d4cf2", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "StillerHarpo/masterarbeit", "max_stars_repo_path": "doc/test.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2141, "size": 5318 }
{-# OPTIONS --show-implicit #-} module BottomUp1 where record R (_ : Set) : Set where no-eta-equality record S (F : Set β†’ Set) ⦃ _ : {A : Set} β†’ R (F A) ⦄ : Set where module M0 where private postulate F : Set β†’ Set instance Ri : {A : Set} β†’ R (F A) instance Si : S F module M1 (_ : Set) where private postulate F : Set β†’ Set instance Ri : {A : Set} β†’ R (F A) instance Si-works : S F ⦃ Ri ⦄ instance Si-fails : S F {- No instance of type R (F A) was found in scope. -}
{ "alphanum_fraction": 0.5317604356, "avg_line_length": 20.4074074074, "ext": "agda", "hexsha": "ced1fb32ee21c7a4909f3d3b60ebac4e62fb1fca", "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/BottomUp1.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/BottomUp1.agda", "max_line_length": 59, "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/BottomUp1.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 187, "size": 551 }
open import Data.ByteString using ( lazy ; strict ) open import System.IO using ( _>>_ ; _>>=_ ; getBytes ; putStr ; commit ) module System.IO.Examples.DevNull where main = getBytes {lazy} >>= Ξ» bs β†’ putStr "Done.\n" >> commit
{ "alphanum_fraction": 0.6638297872, "avg_line_length": 23.5, "ext": "agda", "hexsha": "a5c768af937385ec538265dbae0c4edc52ed3553", "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": "d06c219c7b7afc85aae3b1d4d66951b889aa7371", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ilya-fiveisky/agda-system-io", "max_forks_repo_path": "src/System/IO/Examples/DevNull.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "ilya-fiveisky/agda-system-io", "max_issues_repo_path": "src/System/IO/Examples/DevNull.agda", "max_line_length": 73, "max_stars_count": null, "max_stars_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ilya-fiveisky/agda-system-io", "max_stars_repo_path": "src/System/IO/Examples/DevNull.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 67, "size": 235 }
module Data.Fin.Substitution.Lemmas.Extra where import Function as Fun open import Data.Nat open import Data.Fin hiding (_+_) open import Data.Fin.Substitution open import Data.Fin.Substitution.Lemmas open import Data.Vec.Properties open import Data.Vec open import Data.Star using (_β—…_ ; Ξ΅) open import Function hiding (id) open import Relation.Binary.PropositionalEquality open ≑-Reasoning module AdditionalLemmas {T} (lemmas : TermLemmas T) where open TermLemmas lemmas module Var = VarSubst -- Weakening commutes with single-variable substitution weaken-sub : βˆ€ {n} (a : T (1 + n)) (b : T n) β†’ weaken (a / sub b) ≑ a / wk ↑ / sub (weaken b) weaken-sub a b = begin weaken (a / sub b) β‰‘βŸ¨ sym (/-wkβ€² (a / sub b)) ⟩ a / sub b / wk β‰‘βŸ¨ sub-commutes a ⟩ a / wk ↑ / sub (b / wk) β‰‘βŸ¨ cong (Ξ» c β†’ a / wk ↑ / sub c) (/-wkβ€² b) ⟩ a / wk ↑ / sub (weaken b) ∎ where /-wkβ€² : βˆ€ {n} (a : T n) β†’ a / wk ≑ weaken a /-wkβ€² a = /-wk {t = a} -- Weakening commutes with reverse composition of substitutions. map-weaken-βŠ™ : βˆ€ {m n k} (σ₁ : Sub T m n) (Οƒβ‚‚ : Sub T n k) β†’ map weaken (σ₁ βŠ™ Οƒβ‚‚) ≑ (map weaken σ₁) βŠ™ (Οƒβ‚‚ ↑) map-weaken-βŠ™ σ₁ Οƒβ‚‚ = begin map weaken (σ₁ βŠ™ Οƒβ‚‚) β‰‘βŸ¨ map-weaken ⟩ (σ₁ βŠ™ Οƒβ‚‚) βŠ™ wk β‰‘βŸ¨ sym βŠ™-assoc ⟩ σ₁ βŠ™ (Οƒβ‚‚ βŠ™ wk) β‰‘βŸ¨ cong (Ξ» Οƒβ‚‚ β†’ σ₁ βŠ™ Οƒβ‚‚) βŠ™-wk ⟩ σ₁ βŠ™ (wk βŠ™ (Οƒβ‚‚ ↑)) β‰‘βŸ¨ βŠ™-assoc ⟩ (σ₁ βŠ™ wk) βŠ™ (Οƒβ‚‚ ↑) β‰‘βŸ¨ cong (Ξ» σ₁ β†’ σ₁ βŠ™ (Οƒβ‚‚ ↑)) (sym map-weaken) ⟩ (map weaken σ₁) βŠ™ (Οƒβ‚‚ ↑) ∎ weaken⋆↑ : βˆ€ {Ξ½ ΞΌ} (x : T Ξ½) (s : Sub T Ξ½ ΞΌ) β†’ (weaken x) / (s ↑) ≑ weaken (x / s) weaken⋆↑ x s = begin (weaken x) / (s ↑) β‰‘βŸ¨ cong (Ξ» u β†’ u / (s ↑)) (sym /-wk) ⟩ x / wk / (s ↑) β‰‘βŸ¨ sym (/-βŠ™ x) ⟩ x / (wk βŠ™ (s ↑)) β‰‘βŸ¨ cong (_/_ x) (sym βŠ™-wk) ⟩ x / (s βŠ™ wk) β‰‘βŸ¨ /-βŠ™ x ⟩ x / s / wk β‰‘βŸ¨ /-wk ⟩ weaken (x / s) ∎ weaken-sub-vanishes : βˆ€ {Ξ½} {a b : T Ξ½} β†’ (weaken a) / (sub b) ≑ a weaken-sub-vanishes {Ξ½} {a} {b} = begin (weaken a) / (sub b) β‰‘βŸ¨ cong (flip _/_ (sub b)) (sym $ /-wk {t = a}) ⟩ a / wk / (sub b) β‰‘βŸ¨ wk-sub-vanishes a ⟩ a ∎ -- make /Var usable from lemmas open TermSubst termSubst using (_/Var_) public private var⋆weaken : βˆ€ {n} β†’ _β‰—_ {A = Fin n} (var ∘ suc) (weaken ∘ var) var⋆weaken n = begin var (suc n) β‰‘βŸ¨ sym $ lookup-wk n ⟩ lookup n wk β‰‘βŸ¨ sym $ var-/ ⟩ (var n) / wk β‰‘βŸ¨ /-wk ⟩ weaken (var n) ∎ map-var⋆weaken : βˆ€ {n m} {v : Vec (Fin n) m} β†’ map var (map suc v) ≑ map weaken (map var v) map-var⋆weaken {v = v} = begin map var (map suc v) β‰‘βŸ¨ sym $ map-∘ var suc v ⟩ map (var ∘ suc) v β‰‘βŸ¨ map-cong var⋆weaken v ⟩ map (weaken ∘ var) v β‰‘βŸ¨ map-∘ weaken var v ⟩ map weaken (map var v) ∎ map-var-varid≑id : βˆ€ {n} β†’ map var (Var.id {n}) ≑ id {n} map-var-varid≑id {zero} = refl map-var-varid≑id {suc n} = begin var zero ∷ (map var $ map suc Var.id) β‰‘βŸ¨ cong (_∷_ (var zero)) map-var⋆weaken ⟩ var zero ∷ (map weaken $ map var Var.id) β‰‘βŸ¨ cong (Ξ» u β†’ var zero ∷ (map weaken u)) map-var-varid≑id ⟩ id ↑ ∎ map-var-varwk≑wk : βˆ€ {n} β†’ map var (Var.wk {n}) ≑ wk {n} map-var-varwk≑wk {zero} = refl map-var-varwk≑wk {suc n} = begin map var (map suc Var.id) β‰‘βŸ¨ map-var⋆weaken ⟩ map weaken (map var Var.id) β‰‘βŸ¨ cong (map weaken) map-var-varid≑id ⟩ wk ∎ map-var-↑ : βˆ€ {n m} {s : Vec (Fin n) m} {s'} β†’ map var s ≑ s' β†’ map var (s Var.↑) ≑ s' ↑ map-var-↑ {s = s} {s' = s'} eq = begin var zero ∷ (map var $ map suc s) β‰‘βŸ¨ cong (_∷_ $ var zero) map-var⋆weaken ⟩ var zero ∷ (map weaken $ map var s) β‰‘βŸ¨ cong (Ξ» u β†’ var zero ∷ (map weaken u)) eq ⟩ s' ↑ ∎ a/wk↑/sub0≑a : βˆ€ {Ξ½} (a : T (suc Ξ½)) β†’ a / wk ↑ / (sub $ var zero) ≑ a a/wk↑/sub0≑a a = begin a / wk ↑ / (sub $ var zero) β‰‘βŸ¨ sym $ /-βŠ™ a ⟩ a / (var zero / (sub $ var zero) ∷ map /-var-zero (map weaken wk)) β‰‘βŸ¨ cong (Ξ» u β†’ a / (u ∷ map /-var-zero (map weaken wk))) var-/ ⟩ a / (var zero ∷ map /-var-zero (map weaken wk)) β‰‘βŸ¨ cong' (sym $ map-∘ /-var-zero weaken wk) ⟩ a / (var zero ∷ map (Ξ» t β†’ (weaken t) / (sub $ var zero)) wk) β‰‘βŸ¨ cong' (map-cong (Ξ» t β†’ weaken-sub-vanishes) wk) ⟩ a / (var zero ∷ map Fun.id wk) β‰‘βŸ¨ cong' (map-id wk) ⟩ a / ((var zero ∷ wk)) β‰‘βŸ¨ id-vanishes a ⟩ a ∎ where /-var-zero = (Ξ» t β†’ t / (sub $ var zero)) cong' : βˆ€ {x y} β†’ x ≑ y β†’ a / (var zero ∷ x) ≑ a / (var zero ∷ y) cong' = Ξ» rest β†’ cong (Ξ» u β†’ a / (var zero ∷ u)) rest lookup-lift-∷ : βˆ€ {v w} k x {b}{ρ : Sub T v w} β†’ lookup (lift k suc x) ((b ∷ ρ) ↑⋆ k) ≑ lookup x (ρ ↑⋆ k) lookup-lift-∷ zero zero = refl lookup-lift-∷ zero (suc x) = refl lookup-lift-∷ (suc k) zero = refl lookup-lift-∷ (suc k) (suc x) {b} {ρ} = begin lookup (lift k suc x) (map (Ξ» t β†’ t /Var Var.wk) ((b ∷ ρ) ↑⋆ k)) β‰‘βŸ¨ lookup-map (lift k suc x) (Ξ» t β†’ t /Var Var.wk) ((b ∷ ρ) ↑⋆ k) ⟩ lookup (lift k suc x) ((b ∷ ρ) ↑⋆ k) /Var Var.wk β‰‘βŸ¨ cong (Ξ» t β†’ t /Var Var.wk) (lookup-lift-∷ k x) ⟩ lookup x (ρ ↑⋆ k) /Var Var.wk β‰‘βŸ¨ sym (lookup-map x (Ξ» t β†’ t /Var Var.wk) (ρ ↑⋆ k)) ⟩ lookup x (map (Ξ» t β†’ t /Var Var.wk) (ρ ↑⋆ k)) ∎ wk-∷ : βˆ€ {Ξ½ Ξ½'} (a : T Ξ½)(ρ : Sub T Ξ½ Ξ½'){b} β†’ a / wk / (b ∷ ρ) ≑ a / ρ wk-∷ a ρ {b} = begin a / wk / (b ∷ ρ) β‰‘βŸ¨ /✢-β†‘βœΆ ((b ∷ ρ) β—… wk β—… Ξ΅) (ρ β—… Ξ΅) (Ξ» k x β†’ begin (var x) /✢ ((b ∷ ρ) β—… wk β—… Ξ΅) β†‘βœΆ k β‰‘βŸ¨ refl ⟩ (var x) / wk ↑⋆ k / (b ∷ ρ) ↑⋆ k β‰‘βŸ¨ cong (flip _/_ ((b ∷ ρ) ↑⋆ k)) var-/ ⟩ (lookup x (wk ↑⋆ k)) / (b ∷ ρ) ↑⋆ k β‰‘βŸ¨ cong (flip _/_ ((b ∷ ρ) ↑⋆ k)) (lookup-wk-↑⋆ k x) ⟩ (var (lift k suc x)) / (b ∷ ρ) ↑⋆ k β‰‘βŸ¨ var-/ ⟩ lookup (lift k suc x) ((b ∷ ρ) ↑⋆ k) β‰‘βŸ¨ lookup-lift-∷ k x ⟩ lookup x (ρ ↑⋆ k) β‰‘βŸ¨ sym var-/ ⟩ (var x) /✢ (ρ β—… Ξ΅) β†‘βœΆ k ∎) 0 a ⟩ a / ρ ∎ wk⋆-++ : βˆ€ {Ξ½ Ξ½'} ΞΌ (a : T Ξ½)(ρ : Sub T Ξ½ Ξ½'){ρ'} β†’ a / wk⋆ ΞΌ / (ρ' ++ ρ) ≑ a / ρ wk⋆-++ zero a ρ {[]} = cong (Ξ» t β†’ t / ρ) (id-vanishes a) wk⋆-++ (suc ΞΌ) a ρ {_ ∷ ρ'} = begin a / wk⋆ (suc ΞΌ) / (_ ∷ ρ' ++ ρ) β‰‘βŸ¨ cong (Ξ» Ο† β†’ a / Ο† / (_ ∷ ρ' ++ ρ)) map-weaken ⟩ a / (wk⋆ ΞΌ βŠ™ wk) / (_ ∷ ρ' ++ ρ) β‰‘βŸ¨ cong (Ξ» t β†’ _/_ t (_ ∷ ρ' ++ ρ)) (/-βŠ™ a) ⟩ a / wk⋆ ΞΌ / wk / (_ ∷ ρ' ++ ρ) β‰‘βŸ¨ wk-∷ (a / wk⋆ ΞΌ) (ρ' ++ ρ) ⟩ a / wk⋆ ΞΌ / (ρ' ++ ρ) β‰‘βŸ¨ wk⋆-++ ΞΌ a ρ ⟩ a / ρ ∎
{ "alphanum_fraction": 0.4643590959, "avg_line_length": 38.1144578313, "ext": "agda", "hexsha": "2a1b2a8decc180c8a31a094ffb979a4879098a12", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "metaborg/mj.agda", "max_forks_repo_path": "src/Data/Fin/Substitution/Lemmas/Extra.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z", "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "metaborg/mj.agda", "max_issues_repo_path": "src/Data/Fin/Substitution/Lemmas/Extra.agda", "max_line_length": 107, "max_stars_count": 10, "max_stars_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "metaborg/mj.agda", "max_stars_repo_path": "src/Data/Fin/Substitution/Lemmas/Extra.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z", "max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z", "num_tokens": 3006, "size": 6327 }
module Ual.Either where infix 10 _∨_ data _∨_ (A B : Set) : Set where orL : A β†’ A ∨ B orR : B β†’ A ∨ B
{ "alphanum_fraction": 0.5607476636, "avg_line_length": 15.2857142857, "ext": "agda", "hexsha": "199476c1802e31da8805087f59e1079b7870c558", "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": "ea0260e1a0612ba581e4283dfb187f531a944dfd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "brunoczim/ual", "max_forks_repo_path": "Either.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ea0260e1a0612ba581e4283dfb187f531a944dfd", "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": "brunoczim/ual", "max_issues_repo_path": "Either.agda", "max_line_length": 32, "max_stars_count": null, "max_stars_repo_head_hexsha": "ea0260e1a0612ba581e4283dfb187f531a944dfd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "brunoczim/ual", "max_stars_repo_path": "Either.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 52, "size": 107 }
------------------------------------------------------------------------------ -- Group theory congruence proofs using pattern matching ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module LogicalFramework.GroupCongruence where open import GroupTheory.Base Β·-cong : βˆ€ {a b c d} β†’ a ≑ b β†’ c ≑ d β†’ a Β· c ≑ b Β· d Β·-cong refl refl = refl Β·-leftCong : βˆ€ {a b c} β†’ a ≑ b β†’ a Β· c ≑ b Β· c Β·-leftCong refl = refl Β·-rightCong : βˆ€ {a b c} β†’ b ≑ c β†’ a Β· b ≑ a Β· c Β·-rightCong refl = refl ⁻¹-cong : βˆ€ {a b} β†’ a ≑ b β†’ a ⁻¹ ≑ b ⁻¹ ⁻¹-cong refl = refl
{ "alphanum_fraction": 0.4278074866, "avg_line_length": 29.92, "ext": "agda", "hexsha": "95828cf7d3eb48616e557e204832d091ab7a8dcb", "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/thesis/report/LogicalFramework/GroupCongruence.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/thesis/report/LogicalFramework/GroupCongruence.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/thesis/report/LogicalFramework/GroupCongruence.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": 208, "size": 748 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Lists where at least one element satisfies a given property ------------------------------------------------------------------------ module Data.List.Any where open import Data.Empty open import Data.Fin open import Function open import Function.Equality using (_⟨$⟩_) open import Function.Equivalence as Equiv using (module Equivalence) open import Function.Related as Related hiding (_∼[_]_) open import Data.List as List using (List; []; _∷_) open import Data.Product as Prod using (βˆƒ; _Γ—_; _,_) open import Level using (Level; _βŠ”_) open import Relation.Nullary import Relation.Nullary.Decidable as Dec open import Relation.Unary using (Decidable) renaming (_βŠ†_ to _⋐_) open import Relation.Binary hiding (Decidable) import Relation.Binary.InducedPreorders as Ind open import Relation.Binary.List.Pointwise as ListEq using ([]; _∷_) open import Relation.Binary.PropositionalEquality as PropEq using (_≑_) -- Any P xs means that at least one element in xs satisfies P. data Any {a p} {A : Set a} (P : A β†’ Set p) : List A β†’ Set (a βŠ” p) where here : βˆ€ {x xs} (px : P x) β†’ Any P (x ∷ xs) there : βˆ€ {x xs} (pxs : Any P xs) β†’ Any P (x ∷ xs) -- Map. map : βˆ€ {a p q} {A : Set a} {P : A β†’ Set p} β†’ {Q : A β†’ Set q} β†’ P ⋐ Q β†’ Any P ⋐ Any Q map g (here px) = here (g px) map g (there pxs) = there (map g pxs) -- If the head does not satisfy the predicate, then the tail will. tail : βˆ€ {a p} {A : Set a} {x : A} {xs : List A} {P : A β†’ Set p} β†’ Β¬ P x β†’ Any P (x ∷ xs) β†’ Any P xs tail Β¬px (here px) = βŠ₯-elim (Β¬px px) tail Β¬px (there pxs) = pxs -- Decides Any. any : βˆ€ {a p} {A : Set a} {P : A β†’ Set p} β†’ Decidable P β†’ Decidable (Any P) any p [] = no Ξ»() any p (x ∷ xs) with p x any p (x ∷ xs) | yes px = yes (here px) any p (x ∷ xs) | no Β¬px = Dec.mapβ€² there (tail Β¬px) (any p xs) -- indexΒ x∈xs is the list position (zero-based) which x∈xs points to. index : βˆ€ {a p} {A : Set a} {P : A β†’ Set p} {xs} β†’ Any P xs β†’ Fin (List.length xs) index (here px) = zero index (there pxs) = suc (index pxs) ------------------------------------------------------------------------ -- List membership and some related definitions module Membership {c β„“ : Level} (S : Setoid c β„“) where private open module S = Setoid S using (_β‰ˆ_) renaming (Carrier to A) open module LS = Setoid (ListEq.setoid S) using () renaming (_β‰ˆ_ to _≋_) -- If a predicate P respects the underlying equality then AnyΒ P -- respects the list equality. lift-resp : βˆ€ {p} {P : A β†’ Set p} β†’ P Respects _β‰ˆ_ β†’ Any P Respects _≋_ lift-resp resp [] () lift-resp resp (xβ‰ˆy ∷ xsβ‰ˆys) (here px) = here (resp xβ‰ˆy px) lift-resp resp (xβ‰ˆy ∷ xsβ‰ˆys) (there pxs) = there (lift-resp resp xsβ‰ˆys pxs) -- List membership. infix 4 _∈_ _βˆ‰_ _∈_ : A β†’ List A β†’ Set _ x ∈ xs = Any (_β‰ˆ_ x) xs _βˆ‰_ : A β†’ List A β†’ Set _ x βˆ‰ xs = Β¬ x ∈ xs -- Subsets. infix 4 _βŠ†_ _⊈_ _βŠ†_ : List A β†’ List A β†’ Set _ xs βŠ† ys = βˆ€ {x} β†’ x ∈ xs β†’ x ∈ ys _⊈_ : List A β†’ List A β†’ Set _ xs ⊈ ys = Β¬ xs βŠ† ys -- Equality is respected by the predicate which is used to define -- _∈_. ∈-resp-β‰ˆ : βˆ€ {x} β†’ (_β‰ˆ_ x) Respects _β‰ˆ_ ∈-resp-β‰ˆ = flip S.trans -- List equality is respected by _∈_. ∈-resp-list-β‰ˆ : βˆ€ {x} β†’ _∈_ x Respects _≋_ ∈-resp-list-β‰ˆ = lift-resp ∈-resp-β‰ˆ -- _βŠ†_ is a preorder. βŠ†-preorder : Preorder _ _ _ βŠ†-preorder = Ind.InducedPreorderβ‚‚ (ListEq.setoid S) _∈_ ∈-resp-list-β‰ˆ module βŠ†-Reasoning where import Relation.Binary.PreorderReasoning as PreR open PreR βŠ†-preorder public renaming (_∼⟨_⟩_ to _βŠ†βŸ¨_⟩_) infix 1 _∈⟨_⟩_ _∈⟨_⟩_ : βˆ€ x {xs ys} β†’ x ∈ xs β†’ xs IsRelatedTo ys β†’ x ∈ ys x ∈⟨ x∈xs ⟩ xsβŠ†ys = (begin xsβŠ†ys) x∈xs -- A variant of List.map. map-with-∈ : βˆ€ {b} {B : Set b} (xs : List A) β†’ (βˆ€ {x} β†’ x ∈ xs β†’ B) β†’ List B map-with-∈ [] f = [] map-with-∈ (x ∷ xs) f = f (here S.refl) ∷ map-with-∈ xs (f ∘ there) -- Finds an element satisfying the predicate. find : βˆ€ {p} {P : A β†’ Set p} {xs} β†’ Any P xs β†’ βˆƒ Ξ» x β†’ x ∈ xs Γ— P x find (here px) = (_ , here S.refl , px) find (there pxs) = Prod.map id (Prod.map there id) (find pxs) lose : βˆ€ {p} {P : A β†’ Set p} {x xs} β†’ P Respects _β‰ˆ_ β†’ x ∈ xs β†’ P x β†’ Any P xs lose resp x∈xs px = map (flip resp px) x∈xs -- The code above instantiated (and slightly changed) for -- propositional equality, along with some additional definitions. module Membership-≑ where private open module M {a} {A : Set a} = Membership (PropEq.setoid A) public hiding (lift-resp; lose; βŠ†-preorder; module βŠ†-Reasoning) lose : βˆ€ {a p} {A : Set a} {P : A β†’ Set p} {x xs} β†’ x ∈ xs β†’ P x β†’ Any P xs lose {P = P} = M.lose (PropEq.subst P) -- _βŠ†_ is a preorder. βŠ†-preorder : βˆ€ {a} β†’ Set a β†’ Preorder _ _ _ βŠ†-preorder A = Ind.InducedPreorderβ‚‚ (PropEq.setoid (List A)) _∈_ (PropEq.subst (_∈_ _)) -- Set and bag equality and related preorders. open Related public using (Kind; Symmetric-kind) renaming ( implication to subset ; reverse-implication to superset ; equivalence to set ; injection to subbag ; reverse-injection to superbag ; bijection to bag ) [_]-Order : Kind β†’ βˆ€ {a} β†’ Set a β†’ Preorder _ _ _ [ k ]-Order A = Related.InducedPreorderβ‚‚ k (_∈_ {A = A}) [_]-Equality : Symmetric-kind β†’ βˆ€ {a} β†’ Set a β†’ Setoid _ _ [ k ]-Equality A = Related.InducedEquivalenceβ‚‚ k (_∈_ {A = A}) infix 4 _∼[_]_ _∼[_]_ : βˆ€ {a} {A : Set a} β†’ List A β†’ Kind β†’ List A β†’ Set _ _∼[_]_ {A = A} xs k ys = Preorder._∼_ ([ k ]-Order A) xs ys -- Bag equality implies the other relations. bag-=β‡’ : βˆ€ {k a} {A : Set a} {xs ys : List A} β†’ xs ∼[ bag ] ys β†’ xs ∼[ k ] ys bag-=β‡’ xsβ‰ˆys = ↔⇒ xsβ‰ˆys -- "Equational" reasoning for _βŠ†_. module βŠ†-Reasoning where import Relation.Binary.PreorderReasoning as PreR private open module PR {a} {A : Set a} = PreR (βŠ†-preorder A) public renaming (_∼⟨_⟩_ to _βŠ†βŸ¨_⟩_; _β‰ˆβŸ¨_⟩_ to _β‰‘βŸ¨_⟩_) infixr 2 _∼⟨_⟩_ infix 1 _∈⟨_⟩_ _∈⟨_⟩_ : βˆ€ {a} {A : Set a} x {xs ys : List A} β†’ x ∈ xs β†’ xs IsRelatedTo ys β†’ x ∈ ys x ∈⟨ x∈xs ⟩ xsβŠ†ys = (begin xsβŠ†ys) x∈xs _∼⟨_⟩_ : βˆ€ {k a} {A : Set a} xs {ys zs : List A} β†’ xs ∼[ ⌊ k βŒ‹β†’ ] ys β†’ ys IsRelatedTo zs β†’ xs IsRelatedTo zs xs ∼⟨ xsβ‰ˆys ⟩ ysβ‰ˆzs = xs βŠ†βŸ¨ β‡’β†’ xsβ‰ˆys ⟩ ysβ‰ˆzs ------------------------------------------------------------------------ -- Another function -- If any element satisfies P, then P is satisfied. satisfied : βˆ€ {a p} {A : Set a} {P : A β†’ Set p} {xs} β†’ Any P xs β†’ βˆƒ P satisfied = Prod.map id Prod.projβ‚‚ ∘ Membership-≑.find
{ "alphanum_fraction": 0.5429398986, "avg_line_length": 30.9641255605, "ext": "agda", "hexsha": "89a0255c3bf8075bcc8b74931042744c7f3d602e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_path": "agda-stdlib-0.9/src/Data/List/Any.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_path": "agda-stdlib-0.9/src/Data/List/Any.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/Data/List/Any.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": 2476, "size": 6905 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Well-founded induction ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Relation.Binary module Induction.WellFounded where open import Data.Product open import Function open import Induction open import Level open import Relation.Unary -- When using well-founded recursion you can recurse arbitrarily, as -- long as the arguments become smaller, and "smaller" is -- well-founded. WfRec : βˆ€ {a r} {A : Set a} β†’ Rel A r β†’ βˆ€ {β„“} β†’ RecStruct A β„“ _ WfRec _<_ P x = βˆ€ y β†’ y < x β†’ P y -- The accessibility predicate: x is accessible if everything which is -- smaller than x is also accessible (inductively). data Acc {a β„“} {A : Set a} (_<_ : Rel A β„“) (x : A) : Set (a βŠ” β„“) where acc : (rs : WfRec _<_ (Acc _<_) x) β†’ Acc _<_ x -- The accessibility predicate encodes what it means to be -- well-founded; if all elements are accessible, then _<_ is -- well-founded. WellFounded : βˆ€ {a β„“} {A : Set a} β†’ Rel A β„“ β†’ Set _ WellFounded _<_ = βˆ€ x β†’ Acc _<_ x Well-founded = WellFounded {-# WARNING_ON_USAGE Well-founded "Warning: Well-founded was deprecated in v0.15. Please use WellFounded instead." #-} ------------------------------------------------------------------------ -- Well-founded induction for the subset of accessible elements: module Some {a lt} {A : Set a} {_<_ : Rel A lt} {β„“} where wfRecBuilder : SubsetRecursorBuilder (Acc _<_) (WfRec _<_ {β„“ = β„“}) wfRecBuilder P f x (acc rs) = Ξ» y y<x β†’ f y (wfRecBuilder P f y (rs y y<x)) wfRec : SubsetRecursor (Acc _<_) (WfRec _<_) wfRec = subsetBuild wfRecBuilder wfRec-builder = wfRecBuilder {-# WARNING_ON_USAGE wfRec-builder "Warning: wfRec-builder was deprecated in v0.15. Please use wfRecBuilder instead." #-} ------------------------------------------------------------------------ -- Well-founded induction for all elements, assuming they are all -- accessible: module All {a lt} {A : Set a} {_<_ : Rel A lt} (wf : WellFounded _<_) β„“ where wfRecBuilder : RecursorBuilder (WfRec _<_ {β„“ = β„“}) wfRecBuilder P f x = Some.wfRecBuilder P f x (wf x) wfRec : Recursor (WfRec _<_) wfRec = build wfRecBuilder wfRec-builder = wfRecBuilder {-# WARNING_ON_USAGE wfRec-builder "Warning: wfRec-builder was deprecated in v0.15. Please use wfRecBuilder instead." #-} ------------------------------------------------------------------------ -- It might be useful to establish proofs of Acc or Well-founded using -- combinators such as the ones below (see, for instance, -- "Constructing Recursion Operators in Intuitionistic Type Theory" by -- Lawrence C Paulson). module Subrelation {a ℓ₁ β„“β‚‚} {A : Set a} {_<₁_ : Rel A ℓ₁} {_<β‚‚_ : Rel A β„“β‚‚} (<₁⇒<β‚‚ : βˆ€ {x y} β†’ x <₁ y β†’ x <β‚‚ y) where accessible : Acc _<β‚‚_ βŠ† Acc _<₁_ accessible (acc rs) = acc (Ξ» y y<x β†’ accessible (rs y (<₁⇒<β‚‚ y<x))) wellFounded : WellFounded _<β‚‚_ β†’ WellFounded _<₁_ wellFounded wf = Ξ» x β†’ accessible (wf x) well-founded = wellFounded {-# WARNING_ON_USAGE well-founded "Warning: well-founded was deprecated in v0.15. Please use wellFounded instead." #-} module InverseImage {a b β„“} {A : Set a} {B : Set b} {_<_ : Rel B β„“} (f : A β†’ B) where accessible : βˆ€ {x} β†’ Acc _<_ (f x) β†’ Acc (_<_ on f) x accessible (acc rs) = acc (Ξ» y fy<fx β†’ accessible (rs (f y) fy<fx)) wellFounded : WellFounded _<_ β†’ WellFounded (_<_ on f) wellFounded wf = Ξ» x β†’ accessible (wf (f x)) well-founded = wellFounded {-# WARNING_ON_USAGE well-founded "Warning: well-founded was deprecated in v0.15. Please use wellFounded instead." #-} module TransitiveClosure {a β„“} {A : Set a} (_<_ : Rel A β„“) where infix 4 _<⁺_ data _<⁺_ : Rel A (a βŠ” β„“) where [_] : βˆ€ {x y} (x<y : x < y) β†’ x <⁺ y trans : βˆ€ {x y z} (x<y : x <⁺ y) (y<z : y <⁺ z) β†’ x <⁺ z downwardsClosed : βˆ€ {x y} β†’ Acc _<⁺_ y β†’ x <⁺ y β†’ Acc _<⁺_ x downwardsClosed (acc rs) x<y = acc (Ξ» z z<x β†’ rs z (trans z<x x<y)) mutual accessible : βˆ€ {x} β†’ Acc _<_ x β†’ Acc _<⁺_ x accessible acc-x = acc (accessibleβ€² acc-x) accessibleβ€² : βˆ€ {x} β†’ Acc _<_ x β†’ WfRec _<⁺_ (Acc _<⁺_) x accessibleβ€² (acc rs) y [ y<x ] = accessible (rs y y<x) accessibleβ€² acc-x y (trans y<z z<x) = downwardsClosed (accessibleβ€² acc-x _ z<x) y<z wellFounded : WellFounded _<_ β†’ WellFounded _<⁺_ wellFounded wf = Ξ» x β†’ accessible (wf x) downwards-closed = downwardsClosed {-# WARNING_ON_USAGE downwards-closed "Warning: downwards-closed was deprecated in v0.15. Please use downwardsClosed instead." #-} well-founded = wellFounded {-# WARNING_ON_USAGE well-founded "Warning: well-founded was deprecated in v0.15. Please use wellFounded instead." #-} module Lexicographic {a b ℓ₁ β„“β‚‚} {A : Set a} {B : A β†’ Set b} (RelA : Rel A ℓ₁) (RelB : βˆ€ x β†’ Rel (B x) β„“β‚‚) where data _<_ : Rel (Ξ£ A B) (a βŠ” b βŠ” ℓ₁ βŠ” β„“β‚‚) where left : βˆ€ {x₁ y₁ xβ‚‚ yβ‚‚} (x₁<xβ‚‚ : RelA x₁ xβ‚‚) β†’ (x₁ , y₁) < (xβ‚‚ , yβ‚‚) right : βˆ€ {x y₁ yβ‚‚} (y₁<yβ‚‚ : RelB x y₁ yβ‚‚) β†’ (x , y₁) < (x , yβ‚‚) mutual accessible : βˆ€ {x y} β†’ Acc RelA x β†’ (βˆ€ {x} β†’ WellFounded (RelB x)) β†’ Acc _<_ (x , y) accessible accA wfB = acc (accessibleβ€² accA (wfB _) wfB) accessibleβ€² : βˆ€ {x y} β†’ Acc RelA x β†’ Acc (RelB x) y β†’ (βˆ€ {x} β†’ WellFounded (RelB x)) β†’ WfRec _<_ (Acc _<_) (x , y) accessibleβ€² (acc rsA) _ wfB ._ (left xβ€²<x) = accessible (rsA _ xβ€²<x) wfB accessibleβ€² accA (acc rsB) wfB ._ (right yβ€²<y) = acc (accessibleβ€² accA (rsB _ yβ€²<y) wfB) wellFounded : WellFounded RelA β†’ (βˆ€ {x} β†’ WellFounded (RelB x)) β†’ WellFounded _<_ wellFounded wfA wfB p = accessible (wfA (proj₁ p)) wfB well-founded = wellFounded {-# WARNING_ON_USAGE well-founded "Warning: well-founded was deprecated in v0.15. Please use wellFounded instead." #-} ------------------------------------------------------------------------ -- DEPRECATED NAMES ------------------------------------------------------------------------ -- Please use the new names as continuing support for the old names is -- not guaranteed. -- Version 1.0 module Inverse-image = InverseImage module Transitive-closure = TransitiveClosure
{ "alphanum_fraction": 0.5717841033, "avg_line_length": 32.3065326633, "ext": "agda", "hexsha": "7f0ea62de59db5a0ff3fdff9fccb9aa3803a538e", "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/Induction/WellFounded.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/Induction/WellFounded.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Induction/WellFounded.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1974, "size": 6429 }
open import FRP.LTL.RSet.Core using ( RSet ) module FRP.LTL.RSet.Stateless where infixr 1 _β‡’_ _β‡’_ : RSet β†’ RSet β†’ RSet (A β‡’ B) t = A t β†’ B t
{ "alphanum_fraction": 0.6413793103, "avg_line_length": 14.5, "ext": "agda", "hexsha": "33cb88eee7a2b890b9becfeb89093bf8ca36cfd0", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:04.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-01T07:33:00.000Z", "max_forks_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/agda-frp-ltl", "max_forks_repo_path": "src/FRP/LTL/RSet/Stateless.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_issues_repo_issues_event_max_datetime": "2015-03-02T15:23:53.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-01T07:01:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/agda-frp-ltl", "max_issues_repo_path": "src/FRP/LTL/RSet/Stateless.agda", "max_line_length": 44, "max_stars_count": 21, "max_stars_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-frp-ltl", "max_stars_repo_path": "src/FRP/LTL/RSet/Stateless.agda", "max_stars_repo_stars_event_max_datetime": "2020-06-15T02:51:13.000Z", "max_stars_repo_stars_event_min_datetime": "2015-07-02T20:25:05.000Z", "num_tokens": 62, "size": 145 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Properties of binary trees ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Tree.Binary.Properties where open import Level using (Level) open import Data.Nat.Base using (suc; _+_) open import Data.Tree.Binary open import Function.Base open import Relation.Binary.PropositionalEquality private variable a b : Level A : Set a B : Set b size-map : βˆ€ (f : A β†’ B) t β†’ size (map f t) ≑ size t size-map f leaf = refl size-map f (node l m r) = congβ‚‚ (Ξ» l r β†’ l + suc r) (size-map f l) (size-map f r) map-id : βˆ€ (t : Tree A) β†’ map id t ≑ t map-id leaf = refl map-id (node l v r) = congβ‚‚ (flip node v) (map-id l) (map-id r)
{ "alphanum_fraction": 0.5222623345, "avg_line_length": 26.8064516129, "ext": "agda", "hexsha": "d23b24aa198706814eaf1073e1fed3e2d509a703", "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/Tree/Binary/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Data/Tree/Binary/Properties.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Data/Tree/Binary/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 215, "size": 831 }
{-# OPTIONS --without-K --exact-split #-} module ideals where import abelian-subgroups import rings open abelian-subgroups public open rings public {- Subsets of rings -} subset-Ring : (l : Level) {l1 : Level} (R : Ring l1) β†’ UU ((lsuc l) βŠ” l1) subset-Ring l R = type-Ring R β†’ UU-Prop l is-set-subset-Ring : (l : Level) {l1 : Level} (R : Ring l1) β†’ is-set (subset-Ring l R) is-set-subset-Ring l R = is-set-function-type (is-set-UU-Prop l) {- Closure properties of subsets of rings -} is-additive-subgroup-subset-Ring : {l1 l2 : Level} (R : Ring l1) (P : subset-Ring l2 R) β†’ UU (l1 βŠ” l2) is-additive-subgroup-subset-Ring R = is-subgroup-Ab (ab-Ring R) is-closed-under-mul-left-subset-Ring : {l1 l2 : Level} (R : Ring l1) (P : subset-Ring l2 R) β†’ UU (l1 βŠ” l2) is-closed-under-mul-left-subset-Ring R P = (x : type-Ring R) (y : type-Ring R) β†’ type-Prop (P y) β†’ type-Prop (P (mul-Ring R x y)) is-closed-under-mul-right-subset-Ring : {l1 l2 : Level} (R : Ring l1) (P : subset-Ring l2 R) β†’ UU (l1 βŠ” l2) is-closed-under-mul-right-subset-Ring R P = (x : type-Ring R) (y : type-Ring R) β†’ type-Prop (P x) β†’ type-Prop (P (mul-Ring R x y)) {- The definition of left and right ideals -} is-left-ideal-subset-Ring : {l1 l2 : Level} (R : Ring l1) (P : subset-Ring l2 R) β†’ UU (l1 βŠ” l2) is-left-ideal-subset-Ring R P = is-additive-subgroup-subset-Ring R P Γ— is-closed-under-mul-left-subset-Ring R P Left-Ideal-Ring : (l : Level) {l1 : Level} (R : Ring l1) β†’ UU ((lsuc l) βŠ” l1) Left-Ideal-Ring l R = Ξ£ (subset-Ring l R) (is-left-ideal-subset-Ring R) is-right-ideal-subset-Ring : {l1 l2 : Level} (R : Ring l1) (P : subset-Ring l2 R) β†’ UU (l1 βŠ” l2) is-right-ideal-subset-Ring R P = is-additive-subgroup-subset-Ring R P Γ— is-closed-under-mul-right-subset-Ring R P Right-Ideal-Ring : (l : Level) {l1 : Level} (R : Ring l1) β†’ UU ((lsuc l) βŠ” l1) Right-Ideal-Ring l R = Ξ£ (subset-Ring l R) (is-right-ideal-subset-Ring R) is-two-sided-ideal-subset-Ring : {l1 l2 : Level} (R : Ring l1) (P : subset-Ring l2 R) β†’ UU (l1 βŠ” l2) is-two-sided-ideal-subset-Ring R P = is-additive-subgroup-subset-Ring R P Γ— ( is-closed-under-mul-left-subset-Ring R P Γ— is-closed-under-mul-right-subset-Ring R P) Two-Sided-Ideal-Ring : (l : Level) {l1 : Level} (R : Ring l1) β†’ UU ((lsuc l) βŠ” l1) Two-Sided-Ideal-Ring l R = Ξ£ (subset-Ring l R) (is-two-sided-ideal-subset-Ring R) {- Special ideals -}
{ "alphanum_fraction": 0.6391880696, "avg_line_length": 32.1866666667, "ext": "agda", "hexsha": "d377147d8c90aee2ff9e2997cb8d8268bd7b34d4", "lang": "Agda", "max_forks_count": 30, "max_forks_repo_forks_event_max_datetime": "2022-03-16T00:33:50.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-26T09:08:57.000Z", "max_forks_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_forks_repo_path": "Agda/ideals.agda", "max_issues_count": 8, "max_issues_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_issues_repo_issues_event_max_datetime": "2020-10-16T15:27:01.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-18T04:16:04.000Z", "max_issues_repo_licenses": [ "CC-BY-4.0" ], "max_issues_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_issues_repo_path": "Agda/ideals.agda", "max_line_length": 73, "max_stars_count": 333, "max_stars_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_stars_repo_path": "Agda/ideals.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T23:50:15.000Z", "max_stars_repo_stars_event_min_datetime": "2018-09-26T08:33:30.000Z", "num_tokens": 934, "size": 2414 }
open import Auto.Prelude -- using a type argument as a proof h0 : (x₁ xβ‚‚ : βŠ₯) β†’ x₁ ≑ xβ‚‚ h0 = {!!} --h0 = Ξ» x₁ β†’ Ξ» () -- using dependent pair to define non-dep pair module DND where _Γ—_ : Set β†’ Set β†’ Set A Γ— B = Ξ£ A (Ξ» _ β†’ B) h1-2 : βˆ€ {A B} β†’ A Γ— B β†’ B Γ— A -- h1-2 = {!!} -- no solution found h1-2 = Ξ» h β†’ Ξ£-i {!!} {!!} -- h1-2 = Ξ» h β†’ Ξ£-i (Ξ£.prf h) (Ξ£.wit h)
{ "alphanum_fraction": 0.4906666667, "avg_line_length": 15, "ext": "agda", "hexsha": "6da444fb9174e373a32c37e48f66b23d6bf8ad8f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/interaction/Auto-Misc.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/interaction/Auto-Misc.agda", "max_line_length": 46, "max_stars_count": 1, "max_stars_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "masondesu/agda", "max_stars_repo_path": "test/interaction/Auto-Misc.agda", "max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z", "num_tokens": 165, "size": 375 }
{-# OPTIONS --safe --without-K #-} open import Relation.Binary module Data.List.Membership.Setoid.Distinct where open import Data.List as List using (List; []; _∷_; _++_) open import Data.List.Any as Any hiding (map; head; tail) open import Data.List.Any.Properties open import Relation.Binary.PropositionalEquality as P using (_≑_) open import Function open import Function.Equivalence using (_⇔_; equivalence) open import Function.Equality using (_⟨$⟩_) open import Function.Inverse using () open import Function.Injection using (_↣_; Injection) open import Data.Product hiding (map) open import Data.Sum hiding (map) import Level as L open import Data.Fin as Fin using (Fin) open import Data.Nat as β„• module _ {a p} {S : Setoid a p} where open Setoid S renaming (Carrier to A) open import Data.List.Membership.Setoid (S) open import Data.List.Membership.Setoid.Properties open import Data.List.Membership.Setoid.Disjoint (S) renaming (Disjoint to _β‹ˆ_) open import Data.List.Membership.Setoid.Trans (S) open import Data.Empty data Distinct : List A β†’ Set (a L.βŠ” p) where distinct-[] : Distinct [] _distinct-∷_by_ : βˆ€ x {xs} β†’ Distinct xs β†’ x βˆ‰ xs β†’ Distinct (x ∷ xs) head : βˆ€ {x}{xs : List A} β†’ Distinct (x ∷ xs) β†’ A head (x distinct-∷ _ by _) = x tail : βˆ€ {x}{xs : List A} β†’ Distinct (x ∷ xs) β†’ Distinct xs tail (_ distinct-∷ dis by _) = dis headβˆ‰tail : βˆ€ {x}{xs : List A} β†’ Distinct (x ∷ xs) β†’ x βˆ‰ xs headβˆ‰tail (_ distinct-∷ _ by xβˆ‰xs) = xβˆ‰xs distinct-[_] : βˆ€ x β†’ Distinct (List.[ x ]) distinct-[ x ] = x distinct-∷ distinct-[] by (Ξ» ()) β‹ˆ-++ : βˆ€ (xs ys : List A) β†’ Distinct (xs ++ ys) ⇔ (Distinct xs Γ— Distinct ys Γ— xs β‹ˆ ys) β‹ˆ-++ xs ys = equivalence to from where to : βˆ€ {xs ys : List A} β†’ Distinct (xs ++ ys) β†’ (Distinct xs Γ— Distinct ys Γ— xs β‹ˆ ys) to {[]} dys = distinct-[] , dys , disjoint-[]Κ³ to {x ∷ xs} {ys} (.x distinct-∷ dis by xβˆ‰xsys) with to {xs = xs} dis ... | dxs , dys , xsβ‹ˆys = x distinct-∷ dxs by (Ξ» x∈xs β†’ xβˆ‰xsys (++⁺ˑ x∈xs)) , dys , Ξ» { (here px) ∈ys β†’ xβˆ‰xsys (++⁺ʳ xs (β‰ˆ-trans-∈ (sym px) ∈ys)) ; (there ∈xs) ∈ys β†’ xsβ‹ˆys ∈xs ∈ys} from : βˆ€ {xs ys : List A} β†’ (Distinct xs Γ— Distinct ys Γ— xs β‹ˆ ys) β†’ Distinct (xs ++ ys) from (distinct-[] , dys , xsβ‹ˆys) = dys from {xs = .x ∷ xs} ((x distinct-∷ dxs by xβˆ‰xs) , dys , xxsβ‹ˆys) with from (dxs , dys , xxsβ‹ˆys ∘ there) ... | dxsys = x distinct-∷ dxsys by Ξ» x∈xsys β†’ case ++⁻ xs x∈xsys of Ξ» { (inj₁ x∈xs) β†’ xβˆ‰xs x∈xs ; (injβ‚‚ x∈ys) β†’ xxsβ‹ˆys (here refl) x∈ys} lookup-injective : {xs : List A}(dxs : Distinct xs) β†’ βˆ€ {i j} β†’ List.lookup xs i ≑ List.lookup xs j β†’ i ≑ j lookup-injective distinct-[] {()} {()} _ lookup-injective (x distinct-∷ dxs by xβˆ‰xs) {Fin.zero} {Fin.zero} _ = P.refl lookup-injective (x distinct-∷ dxs by xβˆ‰xs) {Fin.suc i} {Fin.suc j} eq = P.cong Fin.suc (lookup-injective dxs eq) lookup-injective {xs} (x distinct-∷ dxs by xβˆ‰xs) {Fin.zero} {Fin.suc j} eq rewrite eq = βŠ₯-elim (xβˆ‰xs (∈-lookup S _ j)) lookup-injective (x distinct-∷ dxs by xβˆ‰xs) {Fin.suc i} {Fin.zero} eq rewrite P.sym eq = βŠ₯-elim (xβˆ‰xs (∈-lookup S _ i)) module _ {a₁ aβ‚‚ p₁ pβ‚‚}{S₁ : Setoid a₁ p₁} {Sβ‚‚ : Setoid aβ‚‚ pβ‚‚} where open Setoid S₁ renaming (Carrier to A) using () open Setoid Sβ‚‚ renaming (Carrier to B) using () open import Data.List.Membership.Setoid (Sβ‚‚) renaming (_βˆ‰_ to _βˆ‰β‚‚_) using () open import Data.List.Membership.Setoid.Properties open import Data.List.Membership.Setoid.Trans (S₁) map : (f : Injection S₁ Sβ‚‚) β†’ βˆ€ {xs : List A} β†’ Distinct {S = S₁} xs β†’ Distinct {S = Sβ‚‚} (List.map (Injection.to f ⟨$⟩_) xs) map f {[]} distinct-[] = distinct-[] map f {.x ∷ xs} (x distinct-∷ dis by xβˆ‰xs) = fx distinct-∷ map f dis by lemma where fx = Injection.to f ⟨$⟩ x lemma : fx βˆ‰β‚‚ List.map (Injection.to f ⟨$⟩_) xs lemma p with ∈-map⁻ S₁ Sβ‚‚ p ... | _ , y∈xs , fxβ‰ˆfy = xβˆ‰xs (β‰ˆ-trans-∈ (Injection.injective f fxβ‰ˆfy) y∈xs)
{ "alphanum_fraction": 0.5965686275, "avg_line_length": 48, "ext": "agda", "hexsha": "3f688f384bbed4e8ea1c1fa10a98678740095c96", "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": "d4cd2a3442a9b58e6139499d16a2b31268f27f80", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "tizmd/agda-distinct-disjoint", "max_forks_repo_path": "src/Data/List/Membership/Setoid/Distinct.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d4cd2a3442a9b58e6139499d16a2b31268f27f80", "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": "tizmd/agda-distinct-disjoint", "max_issues_repo_path": "src/Data/List/Membership/Setoid/Distinct.agda", "max_line_length": 136, "max_stars_count": null, "max_stars_repo_head_hexsha": "d4cd2a3442a9b58e6139499d16a2b31268f27f80", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "tizmd/agda-distinct-disjoint", "max_stars_repo_path": "src/Data/List/Membership/Setoid/Distinct.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1466, "size": 4080 }
module StateSized.GUI.BitMaps where open import StateSizedIO.GUI.WxBindingsFFI ship : Bitmap ship = bitmap "./StateSized/GUI/ship.ico" rock : Bitmap rock = bitmap "./StateSized/GUI/rock.ico"
{ "alphanum_fraction": 0.7680412371, "avg_line_length": 19.4, "ext": "agda", "hexsha": "951aae4e24daff87f21ac3dca69ce63ca503b8c0", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z", "max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/ooAgda", "max_forks_repo_path": "examples/StateSized/GUI/BitMaps.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/ooAgda", "max_issues_repo_path": "examples/StateSized/GUI/BitMaps.agda", "max_line_length": 42, "max_stars_count": 23, "max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/ooAgda", "max_stars_repo_path": "examples/StateSized/GUI/BitMaps.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": 56, "size": 194 }
-- Andreas, 2020-04-15, issue #4586 -- Better error message when `let` contains a `where` clause. foo : Set₁ foo = let x = Set where y = Set in Set -- WAS: -- Not a valid let-declaration -- when scope checking -- let x = Set -- where -- y = Set -- in Set -- EXPECTED: -- No `where' clauses allowed in let binding -- when scope checking -- let x = Set -- where -- y = Set -- in Set
{ "alphanum_fraction": 0.5612009238, "avg_line_length": 18.0416666667, "ext": "agda", "hexsha": "a3ec1d94475608beb2a37d2fab9be18e801fcb84", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "shlevy/agda", "max_forks_repo_path": "test/Fail/Issue4586WhereInLet.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/Issue4586WhereInLet.agda", "max_line_length": 61, "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/Issue4586WhereInLet.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": 130, "size": 433 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Least common multiple ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Nat.LCM where open import Algebra open import Data.Nat.Base open import Data.Nat.Coprimality using (Coprime) open import Data.Nat.Divisibility open import Data.Nat.DivMod open import Data.Nat.Properties open import Data.Nat.Solver open import Data.Nat.GCD open import Data.Product open import Data.Sum.Base using (_⊎_; inj₁; injβ‚‚) open import Function open import Relation.Binary.PropositionalEquality as P using (_≑_; refl; sym; trans; cong; congβ‚‚; module ≑-Reasoning) open import Relation.Binary open import Relation.Nullary.Decidable using (False; fromWitnessFalse) open +-*-Solver private gcdβ‰’0β€² : βˆ€ m n β†’ False (gcd (suc m) n β‰Ÿ 0) gcdβ‰’0β€² m n = fromWitnessFalse (gcd[m,n]β‰’0 (suc m) n (inj₁ (Ξ»()))) ------------------------------------------------------------------------ -- Definition lcm : β„• β†’ β„• β†’ β„• lcm zero n = zero lcm m@(suc m-1) n = m * (n / gcd m n) {gcdβ‰’0β€² m-1 n} ------------------------------------------------------------------------ -- Core properties private rearrange : βˆ€ m-1 n β†’ lcm (suc m-1) n ≑ ((suc m-1) * n / gcd (suc m-1) n) {gcdβ‰’0β€² m-1 n} rearrange m-1 n = sym (*-/-assoc m {n} {gcd m n} {gcdβ‰’0β€² m-1 n} (gcd[m,n]∣n m n)) where m = suc m-1 m∣lcm[m,n] : βˆ€ m n β†’ m ∣ lcm m n m∣lcm[m,n] zero n = 0 ∣0 m∣lcm[m,n] m@(suc _) n = m∣m*n (n / gcd m n) n∣lcm[m,n] : βˆ€ m n β†’ n ∣ lcm m n n∣lcm[m,n] zero n = n ∣0 n∣lcm[m,n] m@(suc m-1) n = begin n ∣⟨ m∣m*n (m / gcd m n) ⟩ n * (m / gcd m n) β‰‘βŸ¨ sym (*-/-assoc n {β‰’0 = gcdβ‰’0β€² m-1 n} (gcd[m,n]∣m m n)) ⟩ n * m / gcd m n β‰‘βŸ¨ cong (Ξ» v β†’ (v / gcd m n) {gcdβ‰’0β€² m-1 n}) (*-comm n m) ⟩ m * n / gcd m n β‰‘βŸ¨ sym (rearrange m-1 n) ⟩ m * (n / gcd m n) ∎ where open ∣-Reasoning lcm-least : βˆ€ {m n c} β†’ m ∣ c β†’ n ∣ c β†’ lcm m n ∣ c lcm-least {zero} {n} {c} 0∣c _ = 0∣c lcm-least {m@(suc m-1)} {n} {c} m∣c n∣c = P.subst (_∣ c) (sym (rearrange m-1 n)) (m∣n*oβ‡’m/n∣o {nβ‰’0 = gcdβ‰’0β€² m-1 n} gcd[m,n]∣m*n mn∣c*gcd) where open ∣-Reasoning gcd[m,n]∣m*n : gcd m n ∣ m * n gcd[m,n]∣m*n = ∣-trans (gcd[m,n]∣m m n) (m∣m*n n) mn∣c*gcd : m * n ∣ c * gcd m n mn∣c*gcd = begin m * n ∣⟨ gcd-greatest (P.subst (_∣ c * m) (*-comm n m) (*-monoΛ‘-∣ m n∣c)) (*-monoΛ‘-∣ n m∣c) ⟩ gcd (c * m) (c * n) β‰‘βŸ¨ sym (c*gcd[m,n]≑gcd[cm,cn] c m n) ⟩ c * gcd m n ∎ ------------------------------------------------------------------------ -- Other properties -- Note that all other properties of `gcd` should be inferable from the -- 3 core properties above. gcd*lcm : βˆ€ m n β†’ gcd m n * lcm m n ≑ m * n gcd*lcm zero n = *-zeroΚ³ (gcd 0 n) gcd*lcm m@(suc m-1) n = trans (cong (gcd m n *_) (rearrange m-1 n)) (m*[n/m]≑n {gcd m n} (begin gcd m n ∣⟨ gcd[m,n]∣m m n ⟩ m ∣⟨ m∣m*n n ⟩ m * n ∎)) where open ∣-Reasoning lcm[0,n]≑0 : βˆ€ n β†’ lcm 0 n ≑ 0 lcm[0,n]≑0 n = 0βˆ£β‡’β‰‘0 (m∣lcm[m,n] 0 n) lcm[n,0]≑0 : βˆ€ n β†’ lcm n 0 ≑ 0 lcm[n,0]≑0 n = 0βˆ£β‡’β‰‘0 (n∣lcm[m,n] n 0) lcm-comm : βˆ€ m n β†’ lcm m n ≑ lcm n m lcm-comm m n = ∣-antisym (lcm-least (n∣lcm[m,n] n m) (m∣lcm[m,n] n m)) (lcm-least (n∣lcm[m,n] m n) (m∣lcm[m,n] m n)) ------------------------------------------------------------------------ -- Least common multiple (lcm). module LCM where -- Specification of the least common multiple (lcm) of two natural -- numbers. record LCM (i j lcm : β„•) : Set where field -- The lcm is a common multiple. commonMultiple : i ∣ lcm Γ— j ∣ lcm -- The lcm divides all common multiples, i.e. the lcm is the least -- common multiple according to the partial order _∣_. least : βˆ€ {m} β†’ i ∣ m Γ— j ∣ m β†’ lcm ∣ m open LCM public -- The lcm is unique. unique : βˆ€ {d₁ dβ‚‚ m n} β†’ LCM m n d₁ β†’ LCM m n dβ‚‚ β†’ d₁ ≑ dβ‚‚ unique d₁ dβ‚‚ = ∣-antisym (LCM.least d₁ (LCM.commonMultiple dβ‚‚)) (LCM.least dβ‚‚ (LCM.commonMultiple d₁)) open LCM public using (LCM) hiding (module LCM) ------------------------------------------------------------------------ -- Calculating the LCM lcm-LCM : βˆ€ m n β†’ LCM m n (lcm m n) lcm-LCM m n = record { commonMultiple = m∣lcm[m,n] m n , n∣lcm[m,n] m n ; least = uncurryβ€² lcm-least } mkLCM : βˆ€ m n β†’ βˆƒ Ξ» d β†’ LCM m n d mkLCM m n = lcm m n , lcm-LCM m n GCD*LCM : βˆ€ {m n g l} β†’ GCD m n g β†’ LCM m n l β†’ m * n ≑ g * l GCD*LCM {m} {n} {g} {l} gc lc = sym (begin g * l β‰‘βŸ¨ congβ‚‚ _*_ (GCD.unique gc (gcd-GCD m n)) (LCM.unique lc (lcm-LCM m n)) ⟩ gcd m n * lcm m n β‰‘βŸ¨ gcd*lcm m n ⟩ m * n ∎) where open ≑-Reasoning
{ "alphanum_fraction": 0.4918759232, "avg_line_length": 32.2380952381, "ext": "agda", "hexsha": "4d2d3b1f2a0ea6f201f3f92a1a240558df37774b", "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/Nat/LCM.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/Nat/LCM.agda", "max_line_length": 111, "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/Nat/LCM.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": 1910, "size": 4739 }
_ : (@0 Set β†’ Set) β†’ (@Ο‰ Set β†’ Set) _ = Ξ» f β†’ f
{ "alphanum_fraction": 0.3958333333, "avg_line_length": 16, "ext": "agda", "hexsha": "6d383eb684aa5c9bf147c850131d225c48d30a37", "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/Issue5251-2.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/Issue5251-2.agda", "max_line_length": 35, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue5251-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": 22, "size": 48 }
-- Andreas, 2012-04-18, bug reported by pumpkingod on 2012-04-16 module Issue610 where import Common.Level open import Common.Equality data βŠ₯ : Set where record ⊀ : Set where record A : Set₁ where constructor set field .a : Set .get : A β†’ Set get x = helper x module R where helper : .A -> Set helper x = A.a x ack : A β†’ Set ack x = R.helper x x -- Expected error: -- Identifier R.helper is declared irrelevant, so it cannot be used here hah : set ⊀ ≑ set βŠ₯ hah = refl .moo : βŠ₯ moo with cong ack hah moo | q = subst (Ξ» x β†’ x) q _ baa : .βŠ₯ β†’ βŠ₯ baa () yoink : βŠ₯ yoink = baa moo
{ "alphanum_fraction": 0.6416666667, "avg_line_length": 15.3846153846, "ext": "agda", "hexsha": "cce06a4dfb29c4c752263e32910325ba00270fe3", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_path": "test/Fail/Issue610.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_path": "test/Fail/Issue610.agda", "max_line_length": 72, "max_stars_count": 3, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/Fail/Issue610.agda", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "num_tokens": 213, "size": 600 }
module Relation.Path where open import Relation.Path.Operation
{ "alphanum_fraction": 0.8307692308, "avg_line_length": 13, "ext": "agda", "hexsha": "f86b0e4c5174faf9961411e1c8e10e92b79e64bd", "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": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "CodaFi/HoTT-Exercises", "max_forks_repo_path": "Relation/Path.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "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": "CodaFi/HoTT-Exercises", "max_issues_repo_path": "Relation/Path.agda", "max_line_length": 35, "max_stars_count": null, "max_stars_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "CodaFi/HoTT-Exercises", "max_stars_repo_path": "Relation/Path.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 11, "size": 65 }
open import Mockingbird.Forest using (Forest) module Mockingbird.Forest.Combination {b β„“} (forest : Forest {b} {β„“}) where open import Mockingbird.Forest.Combination.Base public
{ "alphanum_fraction": 0.7877094972, "avg_line_length": 29.8333333333, "ext": "agda", "hexsha": "1226b73efbbaf4811b0a37fe5186fbf747a6018e", "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": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "splintah/combinatory-logic", "max_forks_repo_path": "Mockingbird/Forest/Combination.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "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": "splintah/combinatory-logic", "max_issues_repo_path": "Mockingbird/Forest/Combination.agda", "max_line_length": 75, "max_stars_count": 1, "max_stars_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "splintah/combinatory-logic", "max_stars_repo_path": "Mockingbird/Forest/Combination.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-28T23:44:42.000Z", "max_stars_repo_stars_event_min_datetime": "2022-02-28T23:44:42.000Z", "num_tokens": 51, "size": 179 }
{-# OPTIONS --without-K #-} module Path2Equiv where -- nothing for the standard library needed directly! open import FT open import Equivalences open import TypeEquivalences -- We now have enough to map each Pi combinator to the corresponding type equivalence path2equiv : {B₁ Bβ‚‚ : FT} β†’ (B₁ ⇛ Bβ‚‚) β†’ (⟦ B₁ ⟧ ≃ ⟦ Bβ‚‚ ⟧) path2equiv uniteβ‚Šβ‡› = uniteβ‚Šequiv path2equiv unitiβ‚Šβ‡› = unitiβ‚Šequiv path2equiv swapβ‚Šβ‡› = swapβ‚Šequiv path2equiv assoclβ‚Šβ‡› = assoclβ‚Šequiv path2equiv assocrβ‚Šβ‡› = assocrβ‚Šequiv path2equiv unite⋆⇛ = unite⋆equiv path2equiv uniti⋆⇛ = uniti⋆equiv path2equiv swap⋆⇛ = swap⋆equiv path2equiv assocl⋆⇛ = assocl⋆equiv path2equiv assocr⋆⇛ = assocr⋆equiv path2equiv distz⇛ = distzequiv path2equiv factorz⇛ = factorzequiv path2equiv dist⇛ = distequiv path2equiv factor⇛ = factorequiv path2equiv id⇛ = idequiv path2equiv (sym⇛ p) = sym≃ (path2equiv p) path2equiv (p β—Ž q) = trans≃ (path2equiv p) (path2equiv q) path2equiv (p βŠ• q) = path⊎ (path2equiv p) (path2equiv q) path2equiv (p βŠ— q) = pathΓ— (path2equiv p) (path2equiv q)
{ "alphanum_fraction": 0.7159199237, "avg_line_length": 30.8529411765, "ext": "agda", "hexsha": "53a4042c426c2f34a48c0e243accf81205d141f6", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "Univalence/OldUnivalence/Path2Equiv.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "Univalence/OldUnivalence/Path2Equiv.agda", "max_line_length": 85, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "Univalence/OldUnivalence/Path2Equiv.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "num_tokens": 436, "size": 1049 }
------------------------------------------------------------------------ -- Recursive types and potentially infinite trees ------------------------------------------------------------------------ module RecursiveTypes.Syntax where open import Data.Nat open import Data.Fin open import Function.Base open import Data.Product open import Codata.Musical.Notation open import Relation.Nullary import Relation.Nullary.Decidable as Dec open import Relation.Binary open import Relation.Binary.PropositionalEquality import Data.Fin.Properties as FP private open module DF {n} = DecSetoid (FP.≑-decSetoid n) using () renaming (_β‰Ÿ_ to _β‰ŸF_) ------------------------------------------------------------------------ -- Types infixr 10 _⟢_ infix 10 ΞΌ_⟢_ -- Recursive types, parameterised on the maximum number of free -- variables. -- -- ΞΌΒ ΟƒΒ βŸΆΒ Ο„ stands for ΞΌX.Β ΟƒΒ βŸΆΒ Ο„, where X can be free in Οƒ and Ο„. The -- arrow is included to avoid nonsensical types like ΞΌX.X. Note that -- no attempt is made to ensure that the variable bound in ΞΌ_⟢_ is -- actually used. data Ty (n : β„•) : Set where βŠ₯ : Ty n ⊀ : Ty n var : (x : Fin n) β†’ Ty n _⟢_ : (τ₁ Ο„β‚‚ : Ty n) β†’ Ty n ΞΌ_⟢_ : (τ₁ Ο„β‚‚ : Ty (suc n)) β†’ Ty n -- Potentially infinite trees. data Tree (n : β„•) : Set where βŠ₯ : Tree n ⊀ : Tree n var : (x : Fin n) β†’ Tree n _⟢_ : (τ₁ Ο„β‚‚ : ∞ (Tree n)) β†’ Tree n ------------------------------------------------------------------------ -- Syntactic equality of types is decidable private drop-var : βˆ€ {n x y} β†’ (Ty n βˆ‹ var x) ≑ var y β†’ x ≑ y drop-var refl = refl drop⟢ˑ : βˆ€ {n σ₁ Οƒβ‚‚ τ₁ Ο„β‚‚} β†’ (Ty n βˆ‹ σ₁ ⟢ Οƒβ‚‚) ≑ τ₁ ⟢ Ο„β‚‚ β†’ σ₁ ≑ τ₁ drop⟢ˑ refl = refl drop⟢ʳ : βˆ€ {n σ₁ Οƒβ‚‚ τ₁ Ο„β‚‚} β†’ (Ty n βˆ‹ σ₁ ⟢ Οƒβ‚‚) ≑ τ₁ ⟢ Ο„β‚‚ β†’ Οƒβ‚‚ ≑ Ο„β‚‚ drop⟢ʳ refl = refl dropμ⟢ˑ : βˆ€ {n σ₁ Οƒβ‚‚ τ₁ Ο„β‚‚} β†’ (Ty n βˆ‹ ΞΌ σ₁ ⟢ Οƒβ‚‚) ≑ ΞΌ τ₁ ⟢ Ο„β‚‚ β†’ σ₁ ≑ τ₁ dropμ⟢ˑ refl = refl dropμ⟢ʳ : βˆ€ {n σ₁ Οƒβ‚‚ τ₁ Ο„β‚‚} β†’ (Ty n βˆ‹ ΞΌ σ₁ ⟢ Οƒβ‚‚) ≑ ΞΌ τ₁ ⟢ Ο„β‚‚ β†’ Οƒβ‚‚ ≑ Ο„β‚‚ dropμ⟢ʳ refl = refl infix 4 _≑?_ _≑?_ : βˆ€ {n} (Οƒ Ο„ : Ty n) β†’ Dec (Οƒ ≑ Ο„) βŠ₯ ≑? βŠ₯ = yes refl βŠ₯ ≑? ⊀ = no (Ξ» ()) βŠ₯ ≑? var y = no (Ξ» ()) βŠ₯ ≑? τ₁ ⟢ Ο„β‚‚ = no (Ξ» ()) βŠ₯ ≑? ΞΌ τ₁ ⟢ Ο„β‚‚ = no (Ξ» ()) ⊀ ≑? βŠ₯ = no (Ξ» ()) ⊀ ≑? ⊀ = yes refl ⊀ ≑? var y = no (Ξ» ()) ⊀ ≑? τ₁ ⟢ Ο„β‚‚ = no (Ξ» ()) ⊀ ≑? ΞΌ τ₁ ⟢ Ο„β‚‚ = no (Ξ» ()) var x ≑? βŠ₯ = no (Ξ» ()) var x ≑? ⊀ = no (Ξ» ()) var x ≑? var y = Dec.mapβ€² (cong var) drop-var (x β‰ŸF y) var x ≑? τ₁ ⟢ Ο„β‚‚ = no (Ξ» ()) var x ≑? ΞΌ τ₁ ⟢ Ο„β‚‚ = no (Ξ» ()) σ₁ ⟢ Οƒβ‚‚ ≑? βŠ₯ = no (Ξ» ()) σ₁ ⟢ Οƒβ‚‚ ≑? ⊀ = no (Ξ» ()) σ₁ ⟢ Οƒβ‚‚ ≑? var y = no (Ξ» ()) σ₁ ⟢ Οƒβ‚‚ ≑? τ₁ ⟢ Ο„β‚‚ with σ₁ ≑? τ₁ | Οƒβ‚‚ ≑? Ο„β‚‚ σ₁ ⟢ Οƒβ‚‚ ≑? .σ₁ ⟢ .Οƒβ‚‚ | yes refl | yes refl = yes refl σ₁ ⟢ Οƒβ‚‚ ≑? τ₁ ⟢ Ο„β‚‚ | no σ₁≒τ₁ | _ = no (σ₁≒τ₁ ∘ drop⟢ˑ) σ₁ ⟢ Οƒβ‚‚ ≑? τ₁ ⟢ Ο„β‚‚ | _ | no Οƒβ‚‚β‰’Ο„β‚‚ = no (Οƒβ‚‚β‰’Ο„β‚‚ ∘ drop⟢ʳ) σ₁ ⟢ Οƒβ‚‚ ≑? ΞΌ τ₁ ⟢ Ο„β‚‚ = no (Ξ» ()) ΞΌ σ₁ ⟢ Οƒβ‚‚ ≑? βŠ₯ = no (Ξ» ()) ΞΌ σ₁ ⟢ Οƒβ‚‚ ≑? ⊀ = no (Ξ» ()) ΞΌ σ₁ ⟢ Οƒβ‚‚ ≑? var y = no (Ξ» ()) ΞΌ σ₁ ⟢ Οƒβ‚‚ ≑? τ₁ ⟢ Ο„β‚‚ = no (Ξ» ()) ΞΌ σ₁ ⟢ Οƒβ‚‚ ≑? ΞΌ τ₁ ⟢ Ο„β‚‚ with σ₁ ≑? τ₁ | Οƒβ‚‚ ≑? Ο„β‚‚ ΞΌ σ₁ ⟢ Οƒβ‚‚ ≑? ΞΌ .σ₁ ⟢ .Οƒβ‚‚ | yes refl | yes refl = yes refl ΞΌ σ₁ ⟢ Οƒβ‚‚ ≑? ΞΌ τ₁ ⟢ Ο„β‚‚ | no σ₁≒τ₁ | _ = no (σ₁≒τ₁ ∘ dropμ⟢ˑ) ΞΌ σ₁ ⟢ Οƒβ‚‚ ≑? ΞΌ τ₁ ⟢ Ο„β‚‚ | _ | no Οƒβ‚‚β‰’Ο„β‚‚ = no (Οƒβ‚‚β‰’Ο„β‚‚ ∘ dropμ⟢ʳ) ------------------------------------------------------------------------ -- Hypotheses -- A hypothesis is a pair of types where the first is assumed to be a -- subtype of the other. open Data.Product public using () renaming (_,_ to _≲_) Hyp : β„• β†’ Set Hyp n = Ty n Γ— Ty n
{ "alphanum_fraction": 0.4336378291, "avg_line_length": 31.2773109244, "ext": "agda", "hexsha": "8c3b482416449ebe181ac36a531fdf95aad76950", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/codata", "max_forks_repo_path": "RecursiveTypes/Syntax.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/codata", "max_issues_repo_path": "RecursiveTypes/Syntax.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/codata", "max_stars_repo_path": "RecursiveTypes/Syntax.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-13T14:48:45.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-13T14:48:45.000Z", "num_tokens": 1523, "size": 3722 }
module _ where module M₁ where record R : Setβ‚‚ where field _A : Set₁ open R -- The following code used to be syntactically incorrect, because -- the left-hand side could be parsed either as the function r -- applied to a pattern variable, or as the copattern _A applied -- toΒ r. Now the former interpretation is ruled out. r : R r A = Set module Mβ‚‚ where record R : Setβ‚‚ where field _A : Set₁ open R data D : Set where d_A : D -- Name parts coming from constructors can be used as part of -- copatterns. r : R r A = Set module M₃ where data Dβ‚‚ : Set where c : Dβ‚‚ record Rβ‚‚ : Set₁ where field f_c : Set open Rβ‚‚ -- Name parts coming from projections can be used as part of -- constructor patterns. F : Dβ‚‚ β†’ Set₁ F c = Set
{ "alphanum_fraction": 0.6385836386, "avg_line_length": 15.75, "ext": "agda", "hexsha": "964dc98cb17f92b7fa47341841a93d6dac6d9b3e", "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/Issue3400.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/Issue3400.agda", "max_line_length": 67, "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/Issue3400.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": 251, "size": 819 }
{-# OPTIONS --without-K #-} open import HoTT hiding (_::_) module algebra.Word {i} (A : Type i) where data Word : Type i where nil : Word _::_ : A β†’ Word β†’ Word _inv::_ : A β†’ Word β†’ Word infixr 60 _::_ _inv::_ -- The following six functions prove things like if [x ∷ v ≑ y ∷ w], -- then [x ≑ y]. -- This is not as easy as it sounds, you cannot directly induct on the equality -- (because [x ∷ v] is not a general element of type word), so you have to -- extract the head, but it’s not always possible… Word= : (v w : Word) β†’ Type i Word= nil nil = Lift ⊀ Word= nil (y :: w) = Lift βŠ₯ Word= nil (y inv:: w) = Lift βŠ₯ Word= (x :: v) nil = Lift βŠ₯ Word= (x :: v) (y :: w) = (x == y) Γ— (v == w) Word= (x :: v) (y inv:: w) = Lift βŠ₯ Word= (x inv:: v) nil = Lift βŠ₯ Word= (x inv:: v) (y :: w) = Lift βŠ₯ Word= (x inv:: v) (y inv:: w) = (x == y) Γ— (v == w) Word=-out : {v w : Word} (p : v == w) β†’ Word= v w Word=-out {v = nil} idp = lift unit Word=-out {v = x :: v} idp = (idp , idp) Word=-out {v = x inv:: v} idp = (idp , idp) Word=-in : {v w : Word} β†’ Word= v w β†’ v == w Word=-in {nil} {nil} _ = idp Word=-in {nil} {y :: w} (lift ()) Word=-in {nil} {y inv:: w} (lift ()) Word=-in {x :: v} {nil} (lift ()) Word=-in {x :: v} {y :: w} (p , q) = ap2 _::_ p q Word=-in {x :: v} {y inv:: w} (lift ()) Word=-in {x inv:: v} {nil} (lift ()) Word=-in {x inv:: v} {y :: w} (lift ()) Word=-in {x inv:: v} {y inv:: w} (p , q) = ap2 _inv::_ p q Word-fst= : {x y : A} {v w : Word} (p : x :: v == y :: w) β†’ x == y Word-fst= p = fst (Word=-out p) Word-snd= : {x y : A} {v w : Word} (p : x :: v == y :: w) β†’ v == w Word-snd= p = snd (Word=-out p) Word-fst=' : {x y : A} {v w : Word} (p : x inv:: v == y inv:: w) β†’ x == y Word-fst=' p = fst (Word=-out p) Word-snd=' : {x y : A} {v w : Word} (p : x inv:: v == y inv:: w) β†’ v == w Word-snd=' p = snd (Word=-out p)
{ "alphanum_fraction": 0.4459980714, "avg_line_length": 35.7586206897, "ext": "agda", "hexsha": "08a8586acdaa5a6988b1bc3ea81ecb0b3ec3cde9", "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": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_path": "algebra/Word.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "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": "nicolaikraus/HoTT-Agda", "max_issues_repo_path": "algebra/Word.agda", "max_line_length": 81, "max_stars_count": 1, "max_stars_repo_head_hexsha": "f8fa68bf753d64d7f45556ca09d0da7976709afa", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "UlrikBuchholtz/HoTT-Agda", "max_stars_repo_path": "algebra/Word.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-30T00:17:55.000Z", "max_stars_repo_stars_event_min_datetime": "2021-06-30T00:17:55.000Z", "num_tokens": 831, "size": 2074 }