Dataset Viewer
Auto-converted to Parquet Duplicate
fact
stringlengths
5
24.4k
type
stringclasses
3 values
library
stringclasses
2 values
imports
listlengths
0
70
filename
stringlengths
18
57
symbolic_name
stringlengths
1
32
docstring
stringclasses
1 value
Extensional (A : Type ℓ) ℓ-rel : Type (ℓ ⊔ lsuc ℓ-rel) where no-eta-equality field Pathᵉ : A → A → Type ℓ-rel reflᵉ : ∀ x → Pathᵉ x x idsᵉ : is-identity-system Pathᵉ reflᵉ {-# INLINE Extensional.constructor #-}
record
src
[ "open import 1Lab.Reflection.Signature", "open import 1Lab.Path.IdentitySystem", "open import 1Lab.Function.Embedding", "open import 1Lab.Reflection.HLevel", "open import 1Lab.Reflection.Subst", "open import 1Lab.HLevel.Closure", "open import 1Lab.Reflection", "open import 1Lab.Truncation", "open import 1Lab.Type.Sigma", "open import 1Lab.Type.Pi", "open import 1Lab.HLevel", "open import 1Lab.Equiv", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.Nat.Base" ]
src/1Lab/Extensionality.agda
Extensional
proposition : any pair of identity systems is connected by an equivalence
function
src
[ "open import 1Lab.Reflection.Signature", "open import 1Lab.Path.IdentitySystem", "open import 1Lab.Function.Embedding", "open import 1Lab.Reflection.HLevel", "open import 1Lab.Reflection.Subst", "open import 1Lab.HLevel.Closure", "open import 1Lab.Reflection", "open import 1Lab.Truncation", "open import 1Lab.Type.Sigma", "open import 1Lab.Type.Pi", "open import 1Lab.HLevel", "open import 1Lab.Equiv", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.Nat.Base" ]
src/1Lab/Extensionality.agda
proposition
points : - ext: turn extensional equality into equality
function
src
[ "open import 1Lab.Reflection.Signature", "open import 1Lab.Path.IdentitySystem", "open import 1Lab.Function.Embedding", "open import 1Lab.Reflection.HLevel", "open import 1Lab.Reflection.Subst", "open import 1Lab.HLevel.Closure", "open import 1Lab.Reflection", "open import 1Lab.Truncation", "open import 1Lab.Type.Sigma", "open import 1Lab.Type.Pi", "open import 1Lab.HLevel", "open import 1Lab.Equiv", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.Nat.Base" ]
src/1Lab/Extensionality.agda
points
Inductive {ℓ} (A : Type ℓ) ℓm : Type (ℓ ⊔ lsuc ℓm) where field methods : Type ℓm from : methods → A
record
src
[ "open import 1Lab.Reflection", "open import 1Lab.Univalence", "open import 1Lab.Equiv", "open import 1Lab.Type hiding (case_of_ ; case_return_of_)", "open import 1Lab.Path" ]
src/1Lab/Inductive.agda
Inductive
case_of_ : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} ⦃ r : Inductive (A → B) ℓm ⦄ → A → r .methods → B
function
src
[ "open import 1Lab.Reflection", "open import 1Lab.Univalence", "open import 1Lab.Equiv", "open import 1Lab.Type hiding (case_of_ ; case_return_of_)", "open import 1Lab.Path" ]
src/1Lab/Inductive.agda
case_of_
case_return_of_ : ∀ {ℓ ℓ'} {A : Type ℓ} (x : A) (B : A → Type ℓ') ⦃ r : Inductive (∀ x → B x) ℓm ⦄ (f : r .methods) → B x
function
src
[ "open import 1Lab.Reflection", "open import 1Lab.Univalence", "open import 1Lab.Equiv", "open import 1Lab.Type hiding (case_of_ ; case_return_of_)", "open import 1Lab.Path" ]
src/1Lab/Inductive.agda
case_return_of_
Membership {ℓ ℓe} (A : Type ℓe) (ℙA : Type ℓ) ℓm : Type (ℓ ⊔ ℓe ⊔ lsuc ℓm) where field _∈_ : A → ℙA → Type ℓm infix 30 _∈_
record
src
[ "open import 1Lab.Underlying", "open import 1Lab.Type hiding (Σ-syntax)" ]
src/1Lab/Membership.agda
Membership
Inclusion {ℓ} (ℙA : Type ℓ) ℓi : Type (ℓ ⊔ lsuc (ℓi)) where field _⊆_ : ℙA → ℙA → Type ℓi infix 30 _⊆_
record
src
[ "open import 1Lab.Underlying", "open import 1Lab.Type hiding (Σ-syntax)" ]
src/1Lab/Membership.agda
Inclusion
Underlying {ℓ} (T : Type ℓ) : Typeω where field ℓ-underlying : Level ⌞_⌟ : T → Type ℓ-underlying
record
src
[ "open import 1Lab.HLevel.Universe", "open import 1Lab.HLevel.Closure", "open import 1Lab.Truncation hiding (∃-syntax)", "open import 1Lab.Resizing", "open import 1Lab.HLevel", "open import 1Lab.Path", "open import 1Lab.Type hiding (Σ-syntax)", "open import Data.Bool.Base" ]
src/1Lab/Underlying.agda
Underlying
Funlike {ℓ ℓ' ℓ''} (A : Type ℓ) (arg : Type ℓ') (out : arg → Type ℓ'') : Type (ℓ ⊔ ℓ' ⊔ ℓ'') where field _·_ : A → (x : arg) → out x infixl 999 _·_
record
src
[ "open import 1Lab.HLevel.Universe", "open import 1Lab.HLevel.Closure", "open import 1Lab.Truncation hiding (∃-syntax)", "open import 1Lab.Resizing", "open import 1Lab.HLevel", "open import 1Lab.Path", "open import 1Lab.Type hiding (Σ-syntax)", "open import Data.Bool.Base" ]
src/1Lab/Underlying.agda
Funlike
make-copattern : Bool → Name → Term → Term → TC ⊤
function
src
[ "open import 1Lab.Reflection.Signature", "open import 1Lab.Reflection.Subst", "open import 1Lab.Reflection", "open import 1Lab.Path", "open import 1Lab.Type" ]
src/1Lab/Reflection/Copattern.agda
make-copattern
repack-record : Term → Term → TC Term
function
src
[ "open import 1Lab.Reflection.Signature", "open import 1Lab.Reflection.Subst", "open import 1Lab.Reflection", "open import 1Lab.Path", "open import 1Lab.Type" ]
src/1Lab/Reflection/Copattern.agda
repack-record
type-for : String → Bool → Name → Term → TC ⊤
function
src
[ "open import 1Lab.Reflection.Signature", "open import 1Lab.Reflection.Subst", "open import 1Lab.Reflection", "open import 1Lab.Path", "open import 1Lab.Type" ]
src/1Lab/Reflection/Copattern.agda
type-for
declare-copattern : ∀ {ℓ} {A : Type ℓ} → Name → A → TC ⊤
function
src
[ "open import 1Lab.Reflection.Signature", "open import 1Lab.Reflection.Subst", "open import 1Lab.Reflection", "open import 1Lab.Path", "open import 1Lab.Type" ]
src/1Lab/Reflection/Copattern.agda
declare-copattern
declare-copatternω : ∀ {U : Typeω} → Name → U → TC ⊤
function
src
[ "open import 1Lab.Reflection.Signature", "open import 1Lab.Reflection.Subst", "open import 1Lab.Reflection", "open import 1Lab.Path", "open import 1Lab.Type" ]
src/1Lab/Reflection/Copattern.agda
declare-copatternω
define-eta-expansion : Name → TC ⊤
function
src
[ "open import 1Lab.Reflection.Signature", "open import 1Lab.Reflection.Subst", "open import 1Lab.Reflection", "open import 1Lab.Path", "open import 1Lab.Type" ]
src/1Lab/Reflection/Copattern.agda
define-eta-expansion
hlevel-projection (proj : Name) : Type where field has-level : Name -- ^ The name of the h-level lemma. It must be sufficient to apply -- this to the "relevant" argument, see 'get-argument' below. In -- practice, this means that has-level lemmas take a single, visible -- argument. get-argument : List (Arg Term) → TC Term -- ^ Given /the arguments/ to a neutral application of 'proj', -- return the "relevant" argument. -- -- If the argument list is of invalid shape, which should be -- impossible, you can simply @typeError []@ to abort. -- -- If 'proj' is a record field, this will generally be the record -- *value*, but in general it may be any single datum computed from -- the argument list which is sufficient for lemma pointed to by -- 'has-level' to do its work. get-level : Term → TC Term -- ^ Given /the inferred type/ of the "relevant" argument, return a -- term representing the hlevel of that particular instance. -- -- In most cases, this will be a constant function returning a pure -- literal natural number; the extra generality is needed in e.g. -- 'hlevel-proj-n-type' below. {- Using projections ----------------- Projection decomposition happens as follows; suppose we have some neutral n = def (quote X) as In order, every 'hlevel-projection X' instance definition will be tried; Let us call a generic instance I. To use this instance, the get-level and get-argument functions are involved; get-argument must take 'as' and return some representative sub-expression e. get-level will receive e's inferred type and must return the h-level of the type n. Finally, we return I.has-level (get-argument as), possibly wrapped in (k - get-level (get-argument as)) applications of is-hlevel-suc. -}
record
src
[ "open import 1Lab.Reflection.Signature", "open import 1Lab.Function.Embedding", "open import 1Lab.Reflection.Subst", "open import 1Lab.Equiv.Fibrewise", "open import 1Lab.HLevel.Universe", "open import 1Lab.HLevel.Closure", "open import 1Lab.Reflection", "open import 1Lab.Type.Sigma", "open import 1Lab.HLevel", "open import 1Lab.Equiv", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.Bool.Base", "open import Data.List.Base", "open import Data.Nat.Base", "open import Data.Id.Base", "open import Meta.Foldable", "open import Prim.Data.Nat" ]
src/1Lab/Reflection/HLevel.agda
hlevel-projection
is-hlevel-le : ∀ {ℓ} {A : Type ℓ} n k → n ≤ k → is-hlevel A n → is-hlevel A k
function
src
[ "open import 1Lab.Reflection.Signature", "open import 1Lab.Function.Embedding", "open import 1Lab.Reflection.Subst", "open import 1Lab.Equiv.Fibrewise", "open import 1Lab.HLevel.Universe", "open import 1Lab.HLevel.Closure", "open import 1Lab.Reflection", "open import 1Lab.Type.Sigma", "open import 1Lab.HLevel", "open import 1Lab.Equiv", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.Bool.Base", "open import Data.List.Base", "open import Data.Nat.Base", "open import Data.Id.Base", "open import Meta.Foldable", "open import Prim.Data.Nat" ]
src/1Lab/Reflection/HLevel.agda
is-hlevel-le
hlevel-proj : ∀ {ℓ} → Type ℓ → Nat → Term → TC ⊤
function
src
[ "open import 1Lab.Reflection.Signature", "open import 1Lab.Function.Embedding", "open import 1Lab.Reflection.Subst", "open import 1Lab.Equiv.Fibrewise", "open import 1Lab.HLevel.Universe", "open import 1Lab.HLevel.Closure", "open import 1Lab.Reflection", "open import 1Lab.Type.Sigma", "open import 1Lab.HLevel", "open import 1Lab.Equiv", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.Bool.Base", "open import Data.List.Base", "open import Data.Nat.Base", "open import Data.Id.Base", "open import Meta.Foldable", "open import Prim.Data.Nat" ]
src/1Lab/Reflection/HLevel.agda
hlevel-proj
Elim-options : Type where field -- Whether to generate an induction principle or a recursion principle. -- (P : D → Type ℓ) vs (P : Type ℓ) induction : Bool -- If `just n`, assume the motive has hlevel n and omit methods accordingly. into-hlevel : Maybe Nat -- Hide the motive argument in the eliminator's type? -- (P : D → Type ℓ) vs. {P : D → Type ℓ} hide-motive : Bool -- Hide the indices in the motive's type? -- (P : (is : Ξ) → D is → Type ℓ) vs. (P : {is : Ξ} → D is → Type ℓ) hide-indices : Bool -- Hide non-inductive hypotheses in method types? -- (Psup : (x : A) (f : B x → W A B) (Pf : ∀ b → P (f b)) → P (sup x f)) -- vs. -- (Psup : {x : A} {f : B x → W A B} (Pf : ∀ b → P (f b)) → P (sup x f)) -- Arguments hidden in the constructor's type are always hidden. hide-cons-args : Bool private module Induction (opts : Elim-options) (D : Name) (pars : Nat) (ixTel : Telescope) (cs : List Name) where open Elim-options opts -- Given a term c : T, produce a replacement c↑ : T↑ (see below). -- The Replacements argument maps constructors and variables to their -- lifted version. {-# TERMINATING #-} replace : Replacements → Term → Maybe Term replace* : Replacements → Args → Args lookupR : Term → Replacements → Maybe Term lookupR t [] = nothing lookupR t@(con c _) ((con c' _ , r) ∷ rs) with c ≡? c' ... | yes _ = just r ... | no _ = lookupR t rs lookupR t@(var i _) ((var i' _ , r) ∷ rs) with i ≡? i' ... | yes _ = just r ... | no _ = lookupR t rs lookupR t (_ ∷ rs) = lookupR t rs replace rs (lam v (abs n t)) = lam v ∘ abs n <$> replace (raise 1 rs) t replace rs t@(con c args) = lookupR t rs <&> λ r → apply-tm* r (replace* rs (drop pars args)) replace rs t@(var i args) = lookupR t rs <&> λ r → apply-tm* r (replace* rs args) replace rs _ = nothing replace* rs [] = [] replace* rs (arg ai t ∷ as) with replace rs t ... | just t' = hide-if hide-cons-args (arg ai t) ∷ arg ai t' ∷ replace* rs as ... | nothing = arg ai t ∷ replace* rs as {- The main part of the algorithm: computes the method associated to a constructor. In detail, given a motive `P : (is : Ξ) → D ps is → Type ℓ` a term `c : T = Δ → D ps is` produces the "lifted" type `T↑ = Δ↑ → P is (c ρ)` where `Δ↑ ⊢ ρ : Δ` is an embedding where types of the form `S = Φ → D ps is` in Δ are replaced recursively with `{S}, S↑` in Δ↑ (this only occurs with a recursion depth of 1 due to strict positivity) and a spine α such that rec : Π P, Δ ⊢ α : Δ↑ where Π P = (is : Ξ) → (d : D ps is) → P is d or nothing if T doesn't end in `D ps`. Example: W A B sup : (a : A) (f : B a → W A B) → W A B f : B a → W A B display f = ((b : B a) → P (f b)) , (_ : Π P, b : B a ⊢ b : B a) display sup = ((a : A) {f : B a → W A B} (pf : ∀ b → P (f b)) → P (sup a f)) , (rec : Π P, a : A, f : B a → W A B ⊢ a, {f}, (λ b → rec (f b))) -} {-# TERMINATING #-} display : (depth : Nat) → (ps : Args) -- D's parameters → (P : Term) → (rs : Replacements) -- a list of replacements from terms to their lifted version, -- used for correcting path boundaries → (rec : Term) -- a variable for explicit recursion → (α : Args) -- accumulator for the spine → (c : Term) (T : Term) → Maybe (Term × Args) -- (T↑ , α) display depth ps P rs rec α c (pi (arg ai x) (abs n y)) = do let ps = raise 1 ps P = raise 1 P rs = raise 1 rs rec = raise 1 rec α = raise 1 α c = raise 1 c base = let c = c <#> arg ai (var 0 []) α = α ∷r hide-if hide-cons-args (arg ai (var 0 [])) in display depth ps P rs rec α c y <&> ×-map₁ λ y → pi (hide-if hide-cons-args (arg ai x)) (abs n y) suc depth-1 ← pure depth where _ → base just (h , α') ← pure (display depth-1 ps P rs unknown [] (var 0 []) (raise 1 x)) where _ → base let ps = raise 1 ps P = raise 1 P rs = (var 1 [] , var 0 []) ∷ raise 1 rs c = raise 1 c <#> arg ai (var 1 []) hTel = pi-view-path h l = tel→lam hTel (apply-tm* (raise (length hTel) rec) (infer-tel ixTel ∷r argN (var (length hTel) α'))) α = α ++ [ hide-if hide-cons-args (arg ai (var 0 [])) , argN l ] y = raise 1 y display depth ps P rs rec α c y <&> ×-map₁ λ y → pi (hide-if hide-cons-args (arg ai x)) (abs n (pi (argN h) (abs ("P" <> n) y))) display depth ps P rs rec α c (def (quote PathP) (_ h∷ lam v (abs n y) v∷ l v∷ r v∷ [])) = do l ← replace rs l r ← replace rs r let ps = raise 1 ps P = raise 1 P rs = raise 1 rs rec = raise 1 rec α = raise 1 α ∷r argN (var 0 []) c = raise 1 c <#> argN (var 0 []) display depth ps P rs rec α c y <&> ×-map₁ λ y → def (quote PathP) (unknown h∷ lam v (abs n y) v∷ l v∷ r v∷ []) display depth ps P rs rec α c (def D' args) = do yes _ ← pure (D ≡? D') where _ → nothing let ps' , is = split-at pars args yes _ ← pure (ps ≡? ps') where _ → nothing let Pc = apply-tm* P (if induction then hide-if hide-indices is ++ c v∷ [] else []) pure (Pc , α) display depth ps P rs rec α c _ = nothing try-hlevel : Term → TC (Maybe Term) try-hlevel T = (do maybe→alt into-hlevel m ← new-meta T unify m $ def (quote hlevel!) [] pure (just m)) <|> pure nothing ×-map₁₂ : ∀ {A B C : Type} → (A → A) → (B → B) → A × B × C → A × B × C ×-map₁₂ f g (a , b , c) = (f a , g b , c) -- Loop over D's constructors and build the method telescope, constructor -- replacements and spines to apply them to. methods : Args → Term → TC (Telescope × List Args × Replacements) methods ps P = go ps P [] cs where go : Args → Term → Replacements → List Name → TC _ go ps P rs [] = pure ([] , [] , rs) go ps P rs (c ∷ cs) = do let c' = con c (hide ps) cT ← flip pi-applyTC ps =<< normalise =<< get-type c just (methodT , α) ← pure (display 1 ps P rs (var 0 []) [] c' cT) where _ → typeError [ "The type of constructor " , nameErr c , " is not supported" ] try-hlevel methodT >>= λ where (just m) → do -- The type of the method is solvable by hlevel (i.e. contractible): -- we can omit that type from the telescope and replace the method with -- a call to `hlevel!`. let rs = (c' , m) ∷ rs go ps P rs cs <&> ×-map₁₂ id (α ∷_) nothing → do -- Otherwise, add m : T to the telescope and replace the corresponding -- constructor with m henceforth. method ← ("P" <>_) <$> render-name c q ← get-con-quantity c let argC = arg (arginfo visible (modality relevant q)) let ps = raise 1 ps P = raise 1 P rs = (c' , var 0 []) ∷ raise 1 rs extend-context method (argC methodT) (go ps P rs cs) <&> ×-map₁₂ ((method , argC methodT) ∷_) (α ∷_) make-elim-with : Elim-options → Name → Name → TC ⊤ make-elim-with opts elim D = work-on-types $ withNormalisation true do DT ← get-type D >>= normalise -- D : (ps : Γ) (is : Ξ) → Type _ data-type pars cs ← get-definition D where _ → typeError [ "not a data type: " , nameErr D ] let open Elim-options opts DTTel , _ = pi-view DT parTel , ixTel = split-at pars DTTel parTelH = hide parTel ixTel = hide-if hide-indices ixTel DTel = ixTel ∷r ("" , argN (def D (tel→args 0 DTTel))) -- (is : Ξ) (_ : D ps is) DTel = raise 1 DTel PTel = if induction then id else λ _ → [] argP = if hide-motive then argH else argN motiveTel = ("ℓ" , argH (quoteTerm Level)) -- P : DTel → Type ℓ ∷ ("P" , argP (unpi-view (PTel DTel) (agda-sort (set (var (length (PTel DTel)) []))))) ∷ [] DTel = raise 1 DTel -- We want to take is-hlevel as an argument, but we need to work in a context -- with an H-Level instance in scope. -- (d : DTel) → is-hlevel (P d) n hlevelTel = maybe→alt into-hlevel <&> λ n → "h" , argN (unpi-view (PTel DTel) (def (quote is-hlevel) (var (length (PTel DTel)) (tel→args 0 (PTel DTel)) v∷ lit (nat n) v∷ []))) -- {d : DTel} {k : Nat} → H-Level (P d) (n + k) H-LevelTel = maybe→alt into-hlevel <&> λ n → "h" , argI (unpi-view (hide (PTel DTel)) (pi (argH (quoteTerm Nat)) (abs "k" (def (quote H-Level) (var (length (PTel DTel) + 1) (tel→args 1 (PTel DTel)) v∷ def (quote _+_) (lit (nat n) v∷ var 0 [] v∷ []) v∷ []))))) ps = tel→args (length motiveTel + length hlevelTel) parTel P = var (length hlevelTel) [] module I = Induction opts D pars ixTel cs methodTel , αs , rs ← in-context (reverse (parTelH ++ motiveTel ++ H-LevelTel)) (I.methods ps P) let baseTel = parTelH ++ motiveTel ++ hlevelTel ++ methodTel DTel = raise (length hlevelTel + length methodTel) DTel P = raise (length methodTel + length DTel) P Pd = apply-tm* P (tel→args 0 (PTel DTel)) -- ∀ (ps : Γ) {ℓ} {P} (h : ∀ d → is-hlevel (P d) n)? (ms : methodTel) (d : DTel) → P d elimT = unpi-view (baseTel ++ DTel) Pd elimT' ← just <$> get-type elim <|> nothing <$ declare (argN elim) elimT for elimT' (unify elimT) -- Give a nicer error if the types don't match let ixTel = raise (length motiveTel + length hlevelTel + length methodTel) ixTel ps = raise (length methodTel + length ixTel) ps rs = raise (length ixTel) rs -- The replacements are in the H-Level context, so we substitute them back into -- our context using basic-instance. let h = length methodTel + length ixTel rs = Maybe-rec (λ n → applyS (inplaceS h (tel→lam (hide (PTel DTel)) (def (quote basic-instance) (lit (nat n) v∷ var (h + length (PTel DTel)) (tel→args 0 (PTel DTel)) v∷ []))))) id into-hlevel rs clauses ← in-context (reverse (baseTel ++ ixTel)) do let getClause = λ (c , α) → do cT ← flip pi-applyTC ps =<< normalise =<< get-type c let cTel = pi-view-path cT pats = tel→pats (length cTel) (baseTel ++ ixTel) ∷r argN (con c (tel→pats 0 cTel)) rec = def elim (tel→args (length ixTel + length cTel) baseTel) α = applyS (singletonS (length cTel) rec) α just m ← pure (I.replace rs (con c (hide ps))) where _ → typeError [] let m = apply-tm* (raise (length cTel) m) α pure (clause (baseTel ++ ixTel ++ cTel) pats m) traverse getClause (zip cs αs) define-function elim clauses default-elim = record { induction = true ; into-hlevel = nothing ; hide-motive = true ; hide-indices = true ; hide-cons-args = false } default-elim-visible = record { induction = true ; into-hlevel = nothing ; hide-motive = false ; hide-indices = false ; hide-cons-args = false } default-rec = record default-elim { induction = false } default-rec-visible = record default-elim-visible { induction = false } _into_ : Elim-options → Nat → Elim-options opts into n = record opts { into-hlevel = just n } make-elim make-rec : Name → Name → TC ⊤ make-elim = make-elim-with default-elim make-rec = make-elim-with default-rec make-elim-n make-rec-n : Nat → Name → Name → TC ⊤ make-elim-n n = make-elim-with (default-elim into n) make-rec-n n = make-elim-with (default-rec into n)
record
src
[ "open import 1Lab.Reflection.Signature", "open import 1Lab.Reflection.Subst", "open import 1Lab.Reflection", "open import 1Lab.Type.Sigma", "open import 1Lab.Type.Pi", "open import 1Lab.HLevel", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.Nat.Base", "open import Meta.Append", "open import 1Lab.HLevel.Closure public", "open import Data.Maybe.Base using (nothing; just) public" ]
src/1Lab/Reflection/Induction.agda
Elim-options
pi-view-path : Term → Telescope
function
src
[ "open import 1Lab.Reflection.Signature", "open import 1Lab.Reflection.Subst", "open import 1Lab.Reflection", "open import 1Lab.Type.Sigma", "open import 1Lab.Type.Pi", "open import 1Lab.HLevel", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.Nat.Base", "open import Meta.Append", "open import 1Lab.HLevel.Closure public", "open import Data.Maybe.Base using (nothing; just) public" ]
src/1Lab/Reflection/Induction.agda
pi-view-path
subst-replacements : Subst → Replacements → Replacements
function
src
[ "open import 1Lab.Reflection.Signature", "open import 1Lab.Reflection.Subst", "open import 1Lab.Reflection", "open import 1Lab.Type.Sigma", "open import 1Lab.Type.Pi", "open import 1Lab.HLevel", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.Nat.Base", "open import Meta.Append", "open import 1Lab.HLevel.Closure public", "open import Data.Maybe.Base using (nothing; just) public" ]
src/1Lab/Reflection/Induction.agda
subst-replacements
make-elim-with : Elim-options → Name → Name → TC ⊤
function
src
[ "open import 1Lab.Reflection.Signature", "open import 1Lab.Reflection.Subst", "open import 1Lab.Reflection", "open import 1Lab.Type.Sigma", "open import 1Lab.Type.Pi", "open import 1Lab.HLevel", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.Nat.Base", "open import Meta.Append", "open import 1Lab.HLevel.Closure public", "open import Data.Maybe.Base using (nothing; just) public" ]
src/1Lab/Reflection/Induction.agda
make-elim-with
_into_ : Elim-options → Nat → Elim-options
function
src
[ "open import 1Lab.Reflection.Signature", "open import 1Lab.Reflection.Subst", "open import 1Lab.Reflection", "open import 1Lab.Type.Sigma", "open import 1Lab.Type.Pi", "open import 1Lab.HLevel", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.Nat.Base", "open import Meta.Append", "open import 1Lab.HLevel.Closure public", "open import Data.Maybe.Base using (nothing; just) public" ]
src/1Lab/Reflection/Induction.agda
_into_
abstract-marker : Term → Maybe Term
function
src
[ "open import 1Lab.Reflection", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.Maybe.Base", "open import Prim.Data.Nat" ]
src/1Lab/Reflection/Marker.agda
abstract-marker
type whose components can all immediately be seen to have h-level n. That is, this works for things like Cat.Morphism._↪_, since the H-Level automation already works for showing that its representation as a Σ-type has hlevel 2, but it does not work for Algebra.Group.is-group, since that requires specific knowledge about is-group to work. Can be used either for unquoteDecl or unquoteDef. In the latter case, it is possible to give the generated instance a more specific context which might help to automatically derive instances for more types. -} private record-hlevel-instance : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} (n : Nat) ⦃ _ : H-Level A n ⦄ → Iso B A → ∀ {k} ⦃ p : n ≤ k ⦄ → H-Level B k record-hlevel-instance n im ⦃ p ⦄ = hlevel-instance $ Iso→is-hlevel _ im (is-hlevel-le _ _ p (hlevel _)) declare-record-hlevel : (n : Nat) → Name → Name → TC ⊤ declare-record-hlevel lvl inst rec = do (rec-tele , _) ← pi-view <$> get-type rec eqv ← helper-function-name rec "isom" declare-record-iso eqv rec let args = reverse $ map-up (λ n (_ , arg i _) → arg i (var₀ n)) 2 (reverse rec-tele) head-ty = it H-Level ##ₙ def rec args ##ₙ var₀ 1 inst-ty = unpi-view (map (λ (nm , arg _ ty) → nm , argH ty) rec-tele) $ pi (argH (it Nat)) $ abs "n" $ pi (argI (it _≤_ ##ₙ lit (nat lvl) ##ₙ var₀ 0)) $ abs "le" $ head-ty declare (argI inst) inst-ty define-function inst [ clause [] [] (it record-hlevel-instance ##ₙ lit (nat lvl) ##ₙ def₀ eqv) ] private module _ {ℓ} (A : Type ℓ) where record T : Type ℓ where no-eta-equality field ⦃ fp ⦄ : A {f} : A → A fixed : f fp ≡ fp unquoteDecl eqv = declare-record-iso eqv (quote T) _ : Iso T (S.Σ A (λ fp → S.Σ (A → A) (λ f → f fp ≡ fp))) _ = eqv unquoteDecl eqv-outside = declare-record-iso eqv-outside (quote T) _ : {ℓ : Level} {A : Type ℓ} → Iso (T A) (S.Σ A (λ fp → S.Σ (A → A) (λ f → f fp ≡ fp))) _ = eqv-outside unquoteDecl T-path = declare-record-path T-path (quote T) _ : {ℓ : Level} {A : Type ℓ} {t1 t2 : T A} → ∀ a b c → t1 ≡ t2 _ = T-path module _ (x : Nat) where unquoteDecl eqv-extra = declare-record-iso eqv-extra (quote T) _ : Nat → {ℓ : Level} {A : Type ℓ} → Iso (T A) (S.Σ A (λ fp → S.Σ (A → A) (λ f → f fp ≡ fp))) _ = eqv-extra record T2 : Type where -- works without eta equality too field some-field : Nat s-eqv : Iso T2 Nat unquoteDef s-eqv = define-record-iso s-eqv (quote T2)
record
src
[ "open import 1Lab.Reflection.Signature", "open import 1Lab.Reflection.HLevel", "open import 1Lab.Reflection.Subst", "open import 1Lab.HLevel.Closure", "open import 1Lab.Reflection", "open import 1Lab.Equiv", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.Nat.Base", "open import Meta.Foldable", "open import Meta.Append", "import Prim.Data.Sigma as S", "import Prim.Data.Nat as N" ]
src/1Lab/Reflection/Record.agda
type
Fields : Type
function
src
[ "open import 1Lab.Reflection.Signature", "open import 1Lab.Reflection.HLevel", "open import 1Lab.Reflection.Subst", "open import 1Lab.HLevel.Closure", "open import 1Lab.Reflection", "open import 1Lab.Equiv", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.Nat.Base", "open import Meta.Foldable", "open import Meta.Append", "import Prim.Data.Sigma as S", "import Prim.Data.Nat as N" ]
src/1Lab/Reflection/Record.agda
Fields
undo-clause : Name × List Name → Clause
function
src
[ "open import 1Lab.Reflection.Signature", "open import 1Lab.Reflection.HLevel", "open import 1Lab.Reflection.Subst", "open import 1Lab.HLevel.Closure", "open import 1Lab.Reflection", "open import 1Lab.Equiv", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.Nat.Base", "open import Meta.Foldable", "open import Meta.Append", "import Prim.Data.Sigma as S", "import Prim.Data.Nat as N" ]
src/1Lab/Reflection/Record.agda
undo-clause
redo-clause : Name × List Name → Clause
function
src
[ "open import 1Lab.Reflection.Signature", "open import 1Lab.Reflection.HLevel", "open import 1Lab.Reflection.Subst", "open import 1Lab.HLevel.Closure", "open import 1Lab.Reflection", "open import 1Lab.Equiv", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.Nat.Base", "open import Meta.Foldable", "open import Meta.Append", "import Prim.Data.Sigma as S", "import Prim.Data.Nat as N" ]
src/1Lab/Reflection/Record.agda
redo-clause
undo-redo-clause : Name × List Name → Clause
function
src
[ "open import 1Lab.Reflection.Signature", "open import 1Lab.Reflection.HLevel", "open import 1Lab.Reflection.Subst", "open import 1Lab.HLevel.Closure", "open import 1Lab.Reflection", "open import 1Lab.Equiv", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.Nat.Base", "open import Meta.Foldable", "open import Meta.Append", "import Prim.Data.Sigma as S", "import Prim.Data.Nat as N" ]
src/1Lab/Reflection/Record.agda
undo-redo-clause
redo-undo-clause : Name × List Name → Clause
function
src
[ "open import 1Lab.Reflection.Signature", "open import 1Lab.Reflection.HLevel", "open import 1Lab.Reflection.Subst", "open import 1Lab.HLevel.Closure", "open import 1Lab.Reflection", "open import 1Lab.Equiv", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.Nat.Base", "open import Meta.Foldable", "open import Meta.Append", "import Prim.Data.Sigma as S", "import Prim.Data.Nat as N" ]
src/1Lab/Reflection/Record.agda
redo-undo-clause
instantiate' : Term → Term → Term
function
src
[ "open import 1Lab.Reflection.Signature", "open import 1Lab.Reflection.HLevel", "open import 1Lab.Reflection.Subst", "open import 1Lab.HLevel.Closure", "open import 1Lab.Reflection", "open import 1Lab.Equiv", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.Nat.Base", "open import Meta.Foldable", "open import Meta.Append", "import Prim.Data.Sigma as S", "import Prim.Data.Nat as N" ]
src/1Lab/Reflection/Record.agda
instantiate'
Σ-pathpⁿ : List Term → Term
function
src
[ "open import 1Lab.Reflection.Signature", "open import 1Lab.Reflection.HLevel", "open import 1Lab.Reflection.Subst", "open import 1Lab.HLevel.Closure", "open import 1Lab.Reflection", "open import 1Lab.Equiv", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.Nat.Base", "open import Meta.Foldable", "open import Meta.Append", "import Prim.Data.Sigma as S", "import Prim.Data.Nat as N" ]
src/1Lab/Reflection/Record.agda
Σ-pathpⁿ
make-record-iso-sigma : Bool → Name → Name → TC ⊤
function
src
[ "open import 1Lab.Reflection.Signature", "open import 1Lab.Reflection.HLevel", "open import 1Lab.Reflection.Subst", "open import 1Lab.HLevel.Closure", "open import 1Lab.Reflection", "open import 1Lab.Equiv", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.Nat.Base", "open import Meta.Foldable", "open import Meta.Append", "import Prim.Data.Sigma as S", "import Prim.Data.Nat as N" ]
src/1Lab/Reflection/Record.agda
make-record-iso-sigma
Usage : slap
function
src
[ "open import 1Lab.Reflection.Signature", "open import 1Lab.Reflection.HLevel", "open import 1Lab.Reflection.Subst", "open import 1Lab.HLevel.Closure", "open import 1Lab.Reflection", "open import 1Lab.Equiv", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.Nat.Base", "open import Meta.Foldable", "open import Meta.Append", "import Prim.Data.Sigma as S", "import Prim.Data.Nat as N" ]
src/1Lab/Reflection/Record.agda
Usage
declare-record-iso : Name → Name → TC ⊤
function
src
[ "open import 1Lab.Reflection.Signature", "open import 1Lab.Reflection.HLevel", "open import 1Lab.Reflection.Subst", "open import 1Lab.HLevel.Closure", "open import 1Lab.Reflection", "open import 1Lab.Equiv", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.Nat.Base", "open import Meta.Foldable", "open import Meta.Append", "import Prim.Data.Sigma as S", "import Prim.Data.Nat as N" ]
src/1Lab/Reflection/Record.agda
declare-record-iso
define-record-iso : Name → Name → TC ⊤
function
src
[ "open import 1Lab.Reflection.Signature", "open import 1Lab.Reflection.HLevel", "open import 1Lab.Reflection.Subst", "open import 1Lab.HLevel.Closure", "open import 1Lab.Reflection", "open import 1Lab.Equiv", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.Nat.Base", "open import Meta.Foldable", "open import Meta.Append", "import Prim.Data.Sigma as S", "import Prim.Data.Nat as N" ]
src/1Lab/Reflection/Record.agda
define-record-iso
make-record-path : Bool → Name → Name → TC ⊤
function
src
[ "open import 1Lab.Reflection.Signature", "open import 1Lab.Reflection.HLevel", "open import 1Lab.Reflection.Subst", "open import 1Lab.HLevel.Closure", "open import 1Lab.Reflection", "open import 1Lab.Equiv", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.Nat.Base", "open import Meta.Foldable", "open import Meta.Append", "import Prim.Data.Sigma as S", "import Prim.Data.Nat as N" ]
src/1Lab/Reflection/Record.agda
make-record-path
declare-record-path : Name → Name → TC ⊤
function
src
[ "open import 1Lab.Reflection.Signature", "open import 1Lab.Reflection.HLevel", "open import 1Lab.Reflection.Subst", "open import 1Lab.HLevel.Closure", "open import 1Lab.Reflection", "open import 1Lab.Equiv", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.Nat.Base", "open import Meta.Foldable", "open import Meta.Append", "import Prim.Data.Sigma as S", "import Prim.Data.Nat as N" ]
src/1Lab/Reflection/Record.agda
declare-record-path
define-record-path : Name → Name → TC ⊤
function
src
[ "open import 1Lab.Reflection.Signature", "open import 1Lab.Reflection.HLevel", "open import 1Lab.Reflection.Subst", "open import 1Lab.HLevel.Closure", "open import 1Lab.Reflection", "open import 1Lab.Equiv", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.Nat.Base", "open import Meta.Foldable", "open import Meta.Append", "import Prim.Data.Sigma as S", "import Prim.Data.Nat as N" ]
src/1Lab/Reflection/Record.agda
define-record-path
declare-record-hlevel : (n : Nat) → Name → Name → TC ⊤
function
src
[ "open import 1Lab.Reflection.Signature", "open import 1Lab.Reflection.HLevel", "open import 1Lab.Reflection.Subst", "open import 1Lab.HLevel.Closure", "open import 1Lab.Reflection", "open import 1Lab.Equiv", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.Nat.Base", "open import Meta.Foldable", "open import Meta.Append", "import Prim.Data.Sigma as S", "import Prim.Data.Nat as N" ]
src/1Lab/Reflection/Record.agda
declare-record-hlevel
Constructor : Type where constructor conhead field -- Name of the constructor itself: con-name : Name -- Name of the data type: con-data : Name -- Quantity of the constructor. con-quantity : Quantity -- Argument telescope for the constructor, with the datatype's -- parameters removed. con-arguments : Telescope -- Return type of the constructor. con-returns : Term -- For the scoping of con-arguments and con-returns, we have -- -- data D Δ : Type ... where -- c : Γ → D δ -- -- becoming -- -- c : ∀ {Δ} → Γ → D δ -- -- in the signature. con-arguments is Δ ⊢ Γ, and con-returns is Δ, Γ ⊢ D δ. get-type-constructors : Name → TC (List Constructor) get-type-constructors n = datatype <|> recordtype where datatype = do (npars , cons) ← get-data-type n for cons λ qn → do q ← get-con-quantity qn (args , ty) ← pi-view <$> get-type qn pure (conhead qn n q (drop npars args) ty) recordtype = do (c , _) ← get-record-type n (np , _) ← pi-view <$> get-type n (args , ty) ← pi-view <$> get-type c pure ((conhead c n quantity-ω (drop (length np) args) ty) ∷ []) -- Look up a constructor in the signature. get-constructor : Name → TC Constructor get-constructor n = get-definition n >>= λ where (data-cons t q) → do (npars , cons) ← get-data-type t (args , ty) ← pi-view <$> get-type n pure (conhead n t q (drop npars args) ty) _ → typeError [ "get-constructor: " , nameErr n , " is not a data constructor." ] -- If a term reduces to an application of a record type, return -- information about that record. get-record : Term → TC (Name × List (Arg Name)) get-record tm = reduce tm >>= λ where (def qn _) → get-record-type qn _ → typeError [ "get-record: " , termErr tm , " is not a record type." ] -- Get the argument telescope of something in the signature. NOTE: If -- the Name refers to a Constructor, the returned telescope *will* -- include the data/record parameters! get-argument-tele : Name → TC Telescope get-argument-tele qn = get-type qn <&> fst ∘ pi-view
record
src
[ "open import 1Lab.Reflection.Subst", "open import 1Lab.Reflection", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.String.Show", "open import Meta.Foldable", "open import Meta.Append" ]
src/1Lab/Reflection/Signature.agda
Constructor
Has-constr {ℓ} (A : Type ℓ) : Type ℓ where field from-constr : Name → A
record
src
[ "open import 1Lab.Reflection.Subst", "open import 1Lab.Reflection", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.String.Show", "open import Meta.Foldable", "open import Meta.Append" ]
src/1Lab/Reflection/Signature.agda
Has-constr
Has-def {ℓ} (A : Type ℓ) : Type ℓ where field from-def : Name → A instance Has-constr-Pattern : Has-constr Pattern Has-constr-Pattern = record { from-constr = con₀ } Has-constr-Term : Has-constr Term Has-constr-Term = record { from-constr = con₀ } Has-def-Term : Has-def Term Has-def-Term = record { from-def = def₀ } Has-constr-Name : Has-constr Name Has-constr-Name = record { from-constr = id } Has-def-Name : Has-def Name Has-def-Name = record { from-def = id } private it-worker : Name → TC Term it-worker n = get-definition n <&> λ where (data-cons _ _) → def₀ (quote Has-constr.from-constr) ##ₙ def₀ (quote auto) ##ₙ lit (name n) _ → def₀ (quote Has-def.from-def) ##ₙ def₀ (quote auto) ##ₙ lit (name n) macro -- Macro which turns a Name into its quoted Term/Pattern -- representation. -- -- If the Name refers to a constructor, it's wrapped in con₀, -- otherwise, it's wrapped in def₀. -- -- Since `it` is a macro, you can use this as `it Foo` rather than -- `def₀ (quote Foo)`. it : Name → Term → TC ⊤ it n g = unify g =<< it-worker n _ : Path Term (it Σ) (def (quote Σ) []) _ = refl macro -- Macro which turns a *record name* into the quoted representation of -- its *constructor*, e.g. `constructor Σ` is `con₀ (quote _,_)`. `constructor : Name → Term → TC ⊤ `constructor n g = do (c , _) ← get-record-type n unify g (it Has-constr.from-constr ##ₙ def₀ (quote auto) ##ₙ lit (name c)) _ : Path Term (`constructor Σ) (con₀ (quote _,_)) _ = refl macro -- Like 'it', but the quoted representation is additionally wrapped in -- enough lambdas to apply the given definition to all of its visible -- arguments. itₙ : Name → Term → TC ⊤ itₙ n g = do tm ← it-worker n args ← get-argument-tele n let args = filter (λ { (_ , arg (arginfo visible _) _) → true ; _ → false }) args tm = def (quote applyⁿᵉ) (argN tm ∷ argN (list-term (reverse (map-up (λ i _ → it argN ##ₙ var₀ i) 0 args))) ∷ []) tm = foldr (λ _ y → lam visible (abs "_" y)) tm args ty = foldr (λ _ y → def (quote Fun) (argN (it Term) ∷ argN y ∷ [])) (it Term) args check-type g ty unify g tm _ : Path (Term → Term → Term) (itₙ Σ) (λ x y → def (quote Σ) (argN x ∷ argN y ∷ [])) _ = refl -- Check whether a name is defined. is-defined : Name → TC Bool is-defined nm = (true <$ get-type nm) <|> pure false -- Render a defined name as it would appear in the current scope. -- -- This will be the "least qualified" possible concrete representation -- for the given name, if one is available. -- -- If the name is not defined, return the shown representation, which is -- fully qualified. render-name : Name → TC String render-name def-nm = do d ← is-defined def-nm let fancy = get-definition def-nm >>= λ where (data-cons _ _) → formatErrorParts [ termErr (con₀ def-nm) ] _ → formatErrorParts [ termErr (def₀ def-nm) ] plain = show def-nm if d then fancy else pure plain -- Generate a fresh name for a "helper function" to the given -- definition. -- Example: `helper-function-name (quote f) "foo"` will be `quote -- f·foo`. helper-function-name : Name → String → TC Name helper-function-name def-nm suf = do t ← render-name def-nm freshName $ t <> "·" <> suf -- Declare and optionally define a helper function for the given -- definition; returns the generated name. -- -- The helper is always defined with default visibility. -- -- If the list of clauses is empty, the function will not be declared, -- so it can be filled in later. This supports generating -- mutually-recursive helpers. helper-function : Name → String → Term → List Clause → TC Name helper-function def-nm suf ty cls = do nm ← helper-function-name def-nm suf declare (argN nm) ty case cls of λ where [] → pure tt _ → define-function nm cls pure nm -- Given a well-typed `val : ty`, return a definitionally-equal atomic -- term equal to `val`, potentially by lifting it into the signature. -- See 'helper-function' for the naming scheme. define-abbrev : Name → String → Term → Term → TC Term define-abbrev def-nm suf ty val with is-atomic-tree? val ... | true = pure val ... | false = do let (tel , _) = pi-impl-view ty nm ← helper-function def-nm suf ty [ clause tel (tel→pats 0 tel) (apply-tm* val (tel→args 0 tel)) ] pure (def₀ nm) private make-args : Nat → List (Arg Nat) → List (Arg Term) make-args n xs = reverse $ map (λ (arg ai i) → arg ai (var (n - i - 1) [])) xs class-for-param : (Arg Term → Term) → Nat → List (Arg Nat) → Term → Maybe Term class-for-param class n xs (agda-sort _) = just (class (argN (var n (make-args n xs)))) class-for-param class n xs (pi a (abs s b)) = pi (argH (Arg.unarg a)) ∘ abs s <$> class-for-param class (suc n) (arg (Arg.arg-info a) n ∷ xs) b class-for-param _ _ _ _ = nothing compute-telescope : (Arg Term → Term) → Nat → List (Arg Nat) → Telescope → Telescope → Telescope × List (Arg Term) compute-telescope d n xs is [] = reverse is , make-args (n + length is) xs compute-telescope d n xs is ((x , a) ∷ tel) = let narg = arg (Arg.arg-info a) n is' = map (λ (s , arg ai t) → s , arg ai (raise 1 t)) is (tele , args) = case class-for-param d 0 [] (raise 1 (Arg.unarg a)) of λ where (just i) → compute-telescope d (1 + n) (narg ∷ xs) ((x , argI (raise (length is) i)) ∷ is') tel nothing → compute-telescope d (1 + n) (narg ∷ xs) is' tel in ((x , argH (Arg.unarg a)) ∷ tele) , args -- Given the name of a "class", and the name of a "data type", compute -- the telescope, and arguments *of the data type*, for a "derived -- instance" of that class. This is best demonstrated by example: -- -- instance-telescope (quote Show) (quote Vec) = -- ( {ℓ : Level} {A : Type ℓ} ⦃ _ : Show A ⦄ {n : Nat} -- , [ ℓ , A , n ] -- ) -- -- That is, all the parameters of the data type are bound invisibly, and -- parameters that (end in) a type additionally have corresponding -- instances of the class available. instance-telescope : (Arg Term → Term) → Name → TC (Telescope × List (Arg Term)) instance-telescope class dat = do (tele , _) ← pi-view <$> get-type dat pure (compute-telescope class 0 [] [] tele) -- Like `instance-telescope`, but instead return the complete pi-type of -- the derived instance. instance-type : (Arg Term → Term) → Name → TC Term instance-type class dat = do (tel , vs) ← instance-telescope class dat pure $ unpi-view tel $ class (argN (def dat vs))
record
src
[ "open import 1Lab.Reflection.Subst", "open import 1Lab.Reflection", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.String.Show", "open import Meta.Foldable", "open import Meta.Append" ]
src/1Lab/Reflection/Signature.agda
Has-def
get-data-type : Name → TC (Nat × List Name)
function
src
[ "open import 1Lab.Reflection.Subst", "open import 1Lab.Reflection", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.String.Show", "open import Meta.Foldable", "open import Meta.Append" ]
src/1Lab/Reflection/Signature.agda
get-data-type
get-record-type : Name → TC (Name × List (Arg Name))
function
src
[ "open import 1Lab.Reflection.Subst", "open import 1Lab.Reflection", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.String.Show", "open import Meta.Foldable", "open import Meta.Append" ]
src/1Lab/Reflection/Signature.agda
get-record-type
get-con-quantity : Name → TC Quantity
function
src
[ "open import 1Lab.Reflection.Subst", "open import 1Lab.Reflection", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.String.Show", "open import Meta.Foldable", "open import Meta.Append" ]
src/1Lab/Reflection/Signature.agda
get-con-quantity
get-type-constructors : Name → TC (List Constructor)
function
src
[ "open import 1Lab.Reflection.Subst", "open import 1Lab.Reflection", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.String.Show", "open import Meta.Foldable", "open import Meta.Append" ]
src/1Lab/Reflection/Signature.agda
get-type-constructors
get-constructor : Name → TC Constructor
function
src
[ "open import 1Lab.Reflection.Subst", "open import 1Lab.Reflection", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.String.Show", "open import Meta.Foldable", "open import Meta.Append" ]
src/1Lab/Reflection/Signature.agda
get-constructor
get-record : Term → TC (Name × List (Arg Name))
function
src
[ "open import 1Lab.Reflection.Subst", "open import 1Lab.Reflection", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.String.Show", "open import Meta.Foldable", "open import Meta.Append" ]
src/1Lab/Reflection/Signature.agda
get-record
get-argument-tele : Name → TC Telescope
function
src
[ "open import 1Lab.Reflection.Subst", "open import 1Lab.Reflection", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.String.Show", "open import Meta.Foldable", "open import Meta.Append" ]
src/1Lab/Reflection/Signature.agda
get-argument-tele
_ : Path Term (it Σ) (def (quote Σ) [])
function
src
[ "open import 1Lab.Reflection.Subst", "open import 1Lab.Reflection", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.String.Show", "open import Meta.Foldable", "open import Meta.Append" ]
src/1Lab/Reflection/Signature.agda
_
_ : Path Term (`constructor Σ) (con₀ (quote _,_))
function
src
[ "open import 1Lab.Reflection.Subst", "open import 1Lab.Reflection", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.String.Show", "open import Meta.Foldable", "open import Meta.Append" ]
src/1Lab/Reflection/Signature.agda
_
_ : Path (Term → Term → Term) (itₙ Σ) (λ x y → def (quote Σ) (argN x ∷ argN y ∷ []))
function
src
[ "open import 1Lab.Reflection.Subst", "open import 1Lab.Reflection", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.String.Show", "open import Meta.Foldable", "open import Meta.Append" ]
src/1Lab/Reflection/Signature.agda
_
is-defined : Name → TC Bool
function
src
[ "open import 1Lab.Reflection.Subst", "open import 1Lab.Reflection", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.String.Show", "open import Meta.Foldable", "open import Meta.Append" ]
src/1Lab/Reflection/Signature.agda
is-defined
render-name : Name → TC String
function
src
[ "open import 1Lab.Reflection.Subst", "open import 1Lab.Reflection", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.String.Show", "open import Meta.Foldable", "open import Meta.Append" ]
src/1Lab/Reflection/Signature.agda
render-name
helper-function-name : Name → String → TC Name
function
src
[ "open import 1Lab.Reflection.Subst", "open import 1Lab.Reflection", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.String.Show", "open import Meta.Foldable", "open import Meta.Append" ]
src/1Lab/Reflection/Signature.agda
helper-function-name
helper-function : Name → String → Term → List Clause → TC Name
function
src
[ "open import 1Lab.Reflection.Subst", "open import 1Lab.Reflection", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.String.Show", "open import Meta.Foldable", "open import Meta.Append" ]
src/1Lab/Reflection/Signature.agda
helper-function
define-abbrev : Name → String → Term → Term → TC Term
function
src
[ "open import 1Lab.Reflection.Subst", "open import 1Lab.Reflection", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.String.Show", "open import Meta.Foldable", "open import Meta.Append" ]
src/1Lab/Reflection/Signature.agda
define-abbrev
instance-telescope : (Arg Term → Term) → Name → TC (Telescope × List (Arg Term))
function
src
[ "open import 1Lab.Reflection.Subst", "open import 1Lab.Reflection", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.String.Show", "open import Meta.Foldable", "open import Meta.Append" ]
src/1Lab/Reflection/Signature.agda
instance-telescope
instance-type : (Arg Term → Term) → Name → TC Term
function
src
[ "open import 1Lab.Reflection.Subst", "open import 1Lab.Reflection", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.String.Show", "open import Meta.Foldable", "open import Meta.Append" ]
src/1Lab/Reflection/Signature.agda
instance-type
SimpleSolver : Type where constructor simple-solver field dont-reduce : List Name build-expr : Term → TC Term invoke-solver : Term → Term → Term invoke-normaliser : Term → Term
record
src
[ "open import 1Lab.Prelude", "open import 1Lab.Reflection", "open import 1Lab.Reflection.Variables", "open import Data.List.Base" ]
src/1Lab/Reflection/Solver.agda
SimpleSolver
VariableSolver {ℓ} (A : Type ℓ) : Type ℓ where constructor var-solver field dont-reduce : List Name build-expr : Variables A → Term → TC (Term × Variables A) invoke-solver : Term → Term → Term → Term invoke-normaliser : Term → Term → Term
record
src
[ "open import 1Lab.Prelude", "open import 1Lab.Reflection", "open import 1Lab.Reflection.Variables", "open import Data.List.Base" ]
src/1Lab/Reflection/Solver.agda
VariableSolver
solver-failed : Term → Term → TC A
function
src
[ "open import 1Lab.Prelude", "open import 1Lab.Reflection", "open import 1Lab.Reflection.Variables", "open import Data.List.Base" ]
src/1Lab/Reflection/Solver.agda
solver-failed
print-repr : Term → Term → TC A
function
src
[ "open import 1Lab.Prelude", "open import 1Lab.Reflection", "open import 1Lab.Reflection.Variables", "open import Data.List.Base" ]
src/1Lab/Reflection/Solver.agda
print-repr
print-var-repr : Term → Term → Term → TC A
function
src
[ "open import 1Lab.Prelude", "open import 1Lab.Reflection", "open import 1Lab.Reflection.Variables", "open import Data.List.Base" ]
src/1Lab/Reflection/Solver.agda
print-var-repr
Subst : Type where ids : Subst _∷_ : Term → Subst → Subst wk : Nat → Subst → Subst lift : Nat → Subst → Subst strengthen : Nat → Subst → Subst infixr 20 _∷_ wkS : Nat → Subst → Subst wkS zero ρ = ρ wkS n (wk x ρ) = wk (n + x) ρ wkS n ρ = wk n ρ liftS : Nat → Subst → Subst liftS zero ρ = ρ liftS n ids = ids liftS n (lift k ρ) = lift (n + k) ρ liftS n ρ = lift n ρ _++#_ : List Term → Subst → Subst x ++# ρ = foldr (_∷_) ρ x infix 15 _++#_ raiseS : Nat → Subst raiseS n = wk n ids raise-fromS : Nat → Nat → Subst raise-fromS n k = liftS n $ raiseS k -- Γ, Δ ⊢ u : A -- --------------------------------- -- Γ, Δ ⊢ singletonS |Δ| u : Γ, A, Δ singletonS : Nat → Term → Subst singletonS n u = map (λ i → var i []) (count n) ++# u ∷ raiseS n -- Γ, A, Δ ⊢ u : A -- ---------------------------------- -- Γ, A, Δ ⊢ inplaceS |Δ| u : Γ, A, Δ inplaceS : Nat → Term → Subst inplaceS n u = map (λ i → var i []) (count n) ++# u ∷ raiseS (suc n)
data
src
[ "open import 1Lab.Reflection", "open import 1Lab.Type", "open import Data.Maybe.Base", "open import Meta.Foldable", "open import Prim.Data.Nat" ]
src/1Lab/Reflection/Subst.agda
Subst
Has-subst {ℓ} (A : Type ℓ) : Type (lsuc ℓ) where field applyS : Subst → A → A
record
src
[ "open import 1Lab.Reflection", "open import 1Lab.Type", "open import Data.Maybe.Base", "open import Meta.Foldable", "open import Prim.Data.Nat" ]
src/1Lab/Reflection/Subst.agda
Has-subst
wkS : Nat → Subst → Subst
function
src
[ "open import 1Lab.Reflection", "open import 1Lab.Type", "open import Data.Maybe.Base", "open import Meta.Foldable", "open import Prim.Data.Nat" ]
src/1Lab/Reflection/Subst.agda
wkS
liftS : Nat → Subst → Subst
function
src
[ "open import 1Lab.Reflection", "open import 1Lab.Type", "open import Data.Maybe.Base", "open import Meta.Foldable", "open import Prim.Data.Nat" ]
src/1Lab/Reflection/Subst.agda
liftS
raiseS : Nat → Subst
function
src
[ "open import 1Lab.Reflection", "open import 1Lab.Type", "open import Data.Maybe.Base", "open import Meta.Foldable", "open import Prim.Data.Nat" ]
src/1Lab/Reflection/Subst.agda
raiseS
raise-fromS : Nat → Nat → Subst
function
src
[ "open import 1Lab.Reflection", "open import 1Lab.Type", "open import Data.Maybe.Base", "open import Meta.Foldable", "open import Prim.Data.Nat" ]
src/1Lab/Reflection/Subst.agda
raise-fromS
singletonS : Nat → Term → Subst
function
src
[ "open import 1Lab.Reflection", "open import 1Lab.Type", "open import Data.Maybe.Base", "open import Meta.Foldable", "open import Prim.Data.Nat" ]
src/1Lab/Reflection/Subst.agda
singletonS
inplaceS : Nat → Term → Subst
function
src
[ "open import 1Lab.Reflection", "open import 1Lab.Type", "open import Data.Maybe.Base", "open import Meta.Foldable", "open import Prim.Data.Nat" ]
src/1Lab/Reflection/Subst.agda
inplaceS
raise : ∀ {ℓ} {A : Type ℓ} ⦃ _ : Has-subst A ⦄ → Nat → A → A
function
src
[ "open import 1Lab.Reflection", "open import 1Lab.Type", "open import Data.Maybe.Base", "open import Meta.Foldable", "open import Prim.Data.Nat" ]
src/1Lab/Reflection/Subst.agda
raise
subst-clause : Subst → Clause → Clause
function
src
[ "open import 1Lab.Reflection", "open import 1Lab.Type", "open import Data.Maybe.Base", "open import Meta.Foldable", "open import Prim.Data.Nat" ]
src/1Lab/Reflection/Subst.agda
subst-clause
subst-tm : Subst → Term → Term
function
src
[ "open import 1Lab.Reflection", "open import 1Lab.Type", "open import Data.Maybe.Base", "open import Meta.Foldable", "open import Prim.Data.Nat" ]
src/1Lab/Reflection/Subst.agda
subst-tm
apply-tm : Term → Arg Term → Term
function
src
[ "open import 1Lab.Reflection", "open import 1Lab.Type", "open import Data.Maybe.Base", "open import Meta.Foldable", "open import Prim.Data.Nat" ]
src/1Lab/Reflection/Subst.agda
apply-tm
subst-tel : Subst → Telescope → Telescope
function
src
[ "open import 1Lab.Reflection", "open import 1Lab.Type", "open import Data.Maybe.Base", "open import Meta.Foldable", "open import Prim.Data.Nat" ]
src/1Lab/Reflection/Subst.agda
subst-tel
lookup-tm : (σ : Subst) (i : Nat) → Term
function
src
[ "open import 1Lab.Reflection", "open import 1Lab.Type", "open import Data.Maybe.Base", "open import Meta.Foldable", "open import Prim.Data.Nat" ]
src/1Lab/Reflection/Subst.agda
lookup-tm
apply-abs : ∀ {ℓ} {A : Type ℓ} ⦃ _ : Has-subst A ⦄ → Abs A → Term → A
function
src
[ "open import 1Lab.Reflection", "open import 1Lab.Type", "open import Data.Maybe.Base", "open import Meta.Foldable", "open import Prim.Data.Nat" ]
src/1Lab/Reflection/Subst.agda
apply-abs
pi-apply : Term → List (Arg Term) → Maybe Term
function
src
[ "open import 1Lab.Reflection", "open import 1Lab.Type", "open import Data.Maybe.Base", "open import Meta.Foldable", "open import Prim.Data.Nat" ]
src/1Lab/Reflection/Subst.agda
pi-apply
pi-applyTC : Term → List (Arg Term) → TC Term
function
src
[ "open import 1Lab.Reflection", "open import 1Lab.Type", "open import Data.Maybe.Base", "open import Meta.Foldable", "open import Prim.Data.Nat" ]
src/1Lab/Reflection/Subst.agda
pi-applyTC
name-of-glue : Name
function
src
[ "open import 1Lab.Reflection", "open import 1Lab.Univalence", "open import 1Lab.Type", "open import Prim.Extension", "open import Prim.HCompU", "open import Prim.Kan", "import 1Lab.Univalence as U" ]
src/1Lab/Reflection/Univalence.agda
name-of-glue
Env {ℓ} (A : Type ℓ) : Nat → Type ℓ where [] : Env A zero _▷_ : ∀ {n} → Env A n → A → Env A (suc n)
data
src
[ "open import 1Lab.Reflection hiding (reverse)", "open import 1Lab.Type", "open import Data.Dec.Base", "open import Data.Fin.Base" ]
src/1Lab/Reflection/Variables.agda
Env
Variables {a} (A : Type a) : Type a where constructor mk-variables field {nvars} : Nat -- We store the bindings in reverse order so that it's -- cheap to add a new one. bound : Env A nvars variables : Term → Maybe Term
record
src
[ "open import 1Lab.Reflection hiding (reverse)", "open import 1Lab.Type", "open import Data.Dec.Base", "open import Data.Fin.Base" ]
src/1Lab/Reflection/Variables.agda
Variables
empty-vars : Variables A
function
src
[ "open import 1Lab.Reflection hiding (reverse)", "open import 1Lab.Type", "open import Data.Dec.Base", "open import Data.Fin.Base" ]
src/1Lab/Reflection/Variables.agda
empty-vars
bind-var : Variables A → Term → TC (Term × Variables A)
function
src
[ "open import 1Lab.Reflection hiding (reverse)", "open import 1Lab.Type", "open import Data.Dec.Base", "open import Data.Fin.Base" ]
src/1Lab/Reflection/Variables.agda
bind-var
environment : Variables A → TC (Term × Term)
function
src
[ "open import 1Lab.Reflection hiding (reverse)", "open import 1Lab.Type", "open import Data.Dec.Base", "open import Data.Fin.Base" ]
src/1Lab/Reflection/Variables.agda
environment
derive-show : Name → Name → TC ⊤
function
src
[ "open import 1Lab.Reflection.Signature", "open import 1Lab.Reflection", "open import 1Lab.Type", "open import Data.Reflection.Term", "open import Data.String.Show", "open import Data.String.Base", "open import Data.Char.Base", "open import Data.Fin.Base", "open import Data.Vec.Base hiding (map)", "open import Data.Nat.Base", "open import Data.Int.Base using (Int ; pos ; negsuc)", "open import Meta.Foldable", "open import Meta.Append" ]
src/1Lab/Reflection/Deriving/Show.agda
derive-show
makeAutoStr-term : Nat → Term → TC ⊤
function
src
[ "open import 1Lab.Univalence.SIP", "open import 1Lab.Reflection", "open import 1Lab.Type.Sigma", "open import 1Lab.Univalence", "open import 1Lab.Equiv", "open import 1Lab.Path", "open import 1Lab.Type", "open import Data.List.Base" ]
src/1Lab/Univalence/SIP/Auto.agda
makeAutoStr-term
Module-notation {ℓ ℓm} (R : Ring ℓ) (T : Type ℓm) : Type (ℓ ⊔ ℓm) where private module R = Ring-on (R .snd) field instance additive-group : Abelian-group-on T private _+_ : T → T → T _+_ = Abelian-group-on._*_ additive-group field +-comm : (a b : T) → a + b ≡ b + a _⋆_ : ⌞ R ⌟ → T → T ⋆-distribl : ∀ r x y → r ⋆ (x + y) ≡ (r ⋆ x) + (r ⋆ y) ⋆-distribr : ∀ r s x → (r R.+ s) ⋆ x ≡ (r ⋆ x) + (s ⋆ x) ⋆-assoc : ∀ r s x → r ⋆ (s ⋆ x) ≡ (r R.* s) ⋆ x ⋆-id : ∀ x → R.1r ⋆ x ≡ x infixr 25 _⋆_ module-notation : ∀ {ℓ ℓm} {R : Ring ℓ} (M : Module R ℓm) → Module-notation R ⌞ M ⌟ module-notation M .Module-notation.additive-group = Module-on→Abelian-group-on (M .snd) module-notation M .Module-notation.+-comm a b = Module-on.+-comm (M .snd) module-notation M .Module-notation._⋆_ = Module-on._⋆_ (M .snd) module-notation M .Module-notation.⋆-distribl = Module-on.⋆-distribl (M .snd) module-notation M .Module-notation.⋆-distribr = Module-on.⋆-distribr (M .snd) module-notation M .Module-notation.⋆-assoc = Module-on.⋆-assoc (M .snd) module-notation M .Module-notation.⋆-id = Module-on.⋆-id (M .snd)
record
src
[ "open import Algebra.Group.Notation", "open import Algebra.Ring.Module", "open import Algebra.Group.Ab", "open import Algebra.Group", "open import Algebra.Ring", "open import Cat.Prelude hiding (_+_ ; _*_)" ]
src/Algebra/Ring/Module/Notation.agda
Module-notation
module-notation : ∀ {ℓ ℓm} {R : Ring ℓ} (M : Module R ℓm) → Module-notation R ⌞ M ⌟
function
src
[ "open import Algebra.Group.Notation", "open import Algebra.Ring.Module", "open import Algebra.Group.Ab", "open import Algebra.Group", "open import Algebra.Ring", "open import Cat.Prelude hiding (_+_ ; _*_)" ]
src/Algebra/Ring/Module/Notation.agda
module-notation
Dualises {ℓ} (T : Type ℓ) : Type where field dualiser : Name
record
src
[ "open import 1Lab.Reflection.Copattern", "open import 1Lab.Reflection.Signature", "open import 1Lab.Reflection", "open import Cat.Prelude", "open import Data.List.Base", "import Cat.Functor.Compose" ]
src/Cat/Functor/Coherence.agda
Dualises
make-cohere : ∀ {ℓ} {S : Type ℓ} → S → Term → TC ⊤
function
src
[ "open import 1Lab.Reflection.Copattern", "open import 1Lab.Reflection.Signature", "open import 1Lab.Reflection", "open import Cat.Prelude", "open import Data.List.Base", "import Cat.Functor.Compose" ]
src/Cat/Functor/Coherence.agda
make-cohere
make-dualise : ∀ {ℓ} {S : Type ℓ} → S → Term → TC ⊤
function
src
[ "open import 1Lab.Reflection.Copattern", "open import 1Lab.Reflection.Signature", "open import 1Lab.Reflection", "open import Cat.Prelude", "open import Data.List.Base", "import Cat.Functor.Compose" ]
src/Cat/Functor/Coherence.agda
make-dualise
cohere-into : ∀ {ℓ ℓ'} {S : Type ℓ'} → Name → (T : Type ℓ) → S → TC ⊤
function
src
[ "open import 1Lab.Reflection.Copattern", "open import 1Lab.Reflection.Signature", "open import 1Lab.Reflection", "open import Cat.Prelude", "open import Data.List.Base", "import Cat.Functor.Compose" ]
src/Cat/Functor/Coherence.agda
cohere-into
define-coherence : Name → TC ⊤
function
src
[ "open import 1Lab.Reflection.Copattern", "open import 1Lab.Reflection.Signature", "open import 1Lab.Reflection", "open import Cat.Prelude", "open import Data.List.Base", "import Cat.Functor.Compose" ]
src/Cat/Functor/Coherence.agda
define-coherence
nat-assoc-to : f ⇒ g ⊗ h ⊗ i → f ⇒ (g ⊗ h) ⊗ i
function
src
[ "open import 1Lab.Reflection.Copattern", "open import 1Lab.Reflection.Signature", "open import 1Lab.Reflection", "open import Cat.Prelude", "open import Data.List.Base", "import Cat.Functor.Compose" ]
src/Cat/Functor/Coherence.agda
nat-assoc-to
nat-assoc-from : f ⊗ g ⊗ h ⇒ i → (f ⊗ g) ⊗ h ⇒ i
function
src
[ "open import 1Lab.Reflection.Copattern", "open import 1Lab.Reflection.Signature", "open import 1Lab.Reflection", "open import Cat.Prelude", "open import Data.List.Base", "import Cat.Functor.Compose" ]
src/Cat/Functor/Coherence.agda
nat-assoc-from
End of preview. Expand in Data Studio

Agda-1Lab

Structured dataset from 1Lab — Cross-linked reference resource for HoTT.

2,114 declarations extracted from Agda source files.

Applications

  • Training language models on formal proofs
  • Fine-tuning theorem provers
  • Retrieval-augmented generation for proof assistants
  • Learning proof embeddings and representations

Source

Schema

Column Type Description
fact string Declaration body
type string data, record, function
library string Source module
imports list Required imports
filename string Source file path
symbolic_name string Identifier
Downloads last month
16

Collection including phanerozoic/Agda-1Lab