Search is not available for this dataset
text
string | meta
dict |
---|---|
module MetaOccursInItself where
data List (A : Set) : Set where
nil : List A
_::_ : A -> List A -> List A
data One : Set where one : One
postulate
f : (A : Set) -> (A -> List A) -> One
err : One
err = f _ (\x -> x)
| {
"alphanum_fraction": 0.5570175439,
"avg_line_length": 14.25,
"ext": "agda",
"hexsha": "d592574cf661cd276eecf1af1b94bbe5c861b63b",
"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/fail/MetaOccursInItself.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/fail/MetaOccursInItself.agda",
"max_line_length": 39,
"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/fail/MetaOccursInItself.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 82,
"size": 228
} |
{-# OPTIONS --omega-in-omega --no-termination-check --overlapping-instances #-}
module Light.Implementation.Data.Boolean where
open import Light.Library.Data.Boolean using (Library ; Dependencies)
open import Light.Variable.Sets
open import Light.Library.Data.Unit as Unit using (Unit ; unit)
open import Light.Level using (lift)
open import Light.Library.Relation.Decidable using (Decidable ; yes ; no)
open import Light.Library.Relation.Binary.Equality using (_≈_ ; wrap)
open import Light.Library.Relation.Binary using (reflexivity)
import Light.Implementation.Relation.Binary.Equality.Propositional
import Light.Implementation.Relation.Decidable
import Light.Package
import Light.Implementation.Relation.Binary.Equality.Propositional.Decidable as DecidablePropositional
import Light.Implementation.Data.Empty
import Light.Implementation.Data.Unit
instance dependencies : Dependencies
dependencies = record {}
instance library : Library dependencies
library = record { Implementation }
where
module Implementation where
data Boolean : Set where true false : Boolean
{-# COMPILE JS
Boolean = (a, cons) => a ? cons.true() : cons.false()
#-}
{-# COMPILE JS true = !0 #-}
{-# COMPILE JS false = !1 #-}
-- TODO: Optimize operations using JS operators.
if_then_else_ : Boolean → 𝕒 → 𝕒 → 𝕒
if true then a else _ = a
if false then _ else a = a
postulate ¬_ : Boolean → Boolean
postulate _∧_ _∨_ _⇢_ : Boolean → Boolean → Boolean
true‐is‐true = lift unit
false‐is‐false = lift unit
private _≈?_ : ∀ (a b : Boolean) → Decidable (a ≈ b)
false ≈? false = yes reflexivity
false ≈? true = no λ ()
true ≈? false = no λ ()
true ≈? true = yes reflexivity
equals = record { equals = wrap (record { are = λ a b → a ≈? b }) }
module EqualityProperties = DecidablePropositional.Main _≈?_
| {
"alphanum_fraction": 0.6188925081,
"avg_line_length": 38.375,
"ext": "agda",
"hexsha": "3abeb1808ef7ee5bdebf8576ad35bf332c851d08",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756",
"max_forks_repo_licenses": [
"0BSD"
],
"max_forks_repo_name": "Zambonifofex/lightlib",
"max_forks_repo_path": "Light/Implementation/Data/Boolean.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"0BSD"
],
"max_issues_repo_name": "Zambonifofex/lightlib",
"max_issues_repo_path": "Light/Implementation/Data/Boolean.agda",
"max_line_length": 102,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756",
"max_stars_repo_licenses": [
"0BSD"
],
"max_stars_repo_name": "zamfofex/lightlib",
"max_stars_repo_path": "Light/Implementation/Data/Boolean.agda",
"max_stars_repo_stars_event_max_datetime": "2019-12-20T21:33:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-12-20T21:33:05.000Z",
"num_tokens": 476,
"size": 2149
} |
{-# OPTIONS --without-K --rewriting #-}
{-
favonia:
On 2017/05/08, I further partition the results into multiple
independent index[n].agda files because the garbage collection
is not really working.
-}
module index3 where
{- van kampen -}
import homotopy.VanKampen
{- blakers massey -}
import homotopy.BlakersMassey
{- cogroups and suspensions -}
import homotopy.Cogroup
{- modalities -}
import homotopy.ModalWedgeExtension
{- conjecture 3.5.3 in favonia's thesis -}
import groups.Int
| {
"alphanum_fraction": 0.74,
"avg_line_length": 19.2307692308,
"ext": "agda",
"hexsha": "fcd56470d8f47aee9126bf3814460d24fe0c5526",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "timjb/HoTT-Agda",
"max_forks_repo_path": "theorems/index3.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "timjb/HoTT-Agda",
"max_issues_repo_path": "theorems/index3.agda",
"max_line_length": 64,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "timjb/HoTT-Agda",
"max_stars_repo_path": "theorems/index3.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 143,
"size": 500
} |
module System.Directory where
open import System.FilePath
open import Prelude
open import Container.Traversable
{-# FOREIGN GHC import System.Directory #-}
private
module Internal where
postulate
listContents : String → IO (List String)
doesFileExist : String → IO Bool
{-# COMPILE GHC listContents = getDirectoryContents #-}
{-# COMPILE GHC doesFileExist = doesFileExist #-}
abstract
listContents : ∀ {k} → Path k → IO (List (Path k))
listContents p = fmap (p //_ ∘ relative) <$> Internal.listContents (toString p)
| {
"alphanum_fraction": 0.702166065,
"avg_line_length": 24.0869565217,
"ext": "agda",
"hexsha": "420b1348d161a3df7c53da03ca8749a39230e215",
"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/System/Directory.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/System/Directory.agda",
"max_line_length": 81,
"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/System/Directory.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": 132,
"size": 554
} |
open import Algebra.Bundles using (CommutativeRing)
module Algebra.Module.Diff
{r ℓr} {CR : CommutativeRing r ℓr}
where
open import Assume using (assume)
import Data.Nat as ℕ
open ℕ using (ℕ; zero; suc)
open import Relation.Binary using (Rel)
open import Algebra.Module using (Module)
open Module
open import Function using (_∘_)
open import Data.Product using (proj₁; proj₂; _,_)
open import Algebra.Module.Morphism.Module using (→-module'; →-module; ⊸-module; _⊸_)
open import Algebra.Module.Construct.DirectProduct using () renaming (⟨module⟩ to ×-module)
open import Level using (_⊔_; Level)
private
variable
ma mℓa mb mℓb mc mℓc : Level
D-module : (MA : Module CR ma mℓa) (MB : Module CR mb mℓb) → Module CR _ _
D-module MA MB = →-module' MA (×-module MB (⊸-module MA MB))
instance
D-module' : {MA : Module CR ma mℓa} {MB : Module CR mb mℓb} → Module CR _ _
D-module' {MA = MA} {MB = MB} = →-module' MA (×-module MB (⊸-module MA MB))
D : (MA : Module CR ma mℓa) (MB : Module CR mb mℓb) → Set (r ⊔ ma ⊔ mℓa ⊔ mb ⊔ mℓb)
D MA MB = Carrierᴹ (→-module' MA (×-module MB (⊸-module MA MB)))
compose
: {MA : Module CR ma mℓa} {MB : Module CR mb mℓb} {MC : Module CR mc mℓc}
→ D MB MC → D MA MB → D MA MC
compose {MA = MA} {MB = MB} {MC = MC} dbc dab a =
let (b , a⊸b) = dab a
(c , b⊸c) = dbc b
in c , ⊸-compose b⊸c a⊸b
where
⊸-compose : MB ⊸ MC → MA ⊸ MB → MA ⊸ MC
⊸-compose (b→c , b→c-ishom) (a→b , a→b-ishom) = b→c ∘ a→b , assume
run
: ∀ {ma mℓa mb mℓb} {MA : Module CR ma mℓa} {MB : Module CR mb mℓb}
→ D MA MB → Carrierᴹ MA → Carrierᴹ MB
run f = proj₁ ∘ f
∇_[_]∙_
: ∀ {ma mℓa mb mℓb} {MA : Module CR ma mℓa} {MB : Module CR mb mℓb}
→ D MA MB → Carrierᴹ MA → Carrierᴹ MA → Carrierᴹ MB
∇_[_]∙_ f = proj₁ ∘ proj₂ ∘ f
grad
: ∀ {ma mℓa mb mℓb} {MA : Module CR ma mℓa} {MB : Module CR mb mℓb}
→ D MA MB → Carrierᴹ MA → Carrierᴹ MA → Carrierᴹ MB
grad f = proj₁ ∘ proj₂ ∘ f
| {
"alphanum_fraction": 0.6225439504,
"avg_line_length": 29.7538461538,
"ext": "agda",
"hexsha": "6d26a0fbc272c744a994f07e1df625f28092dfde",
"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": "78c3dec24834ffeca5e74cb75578e9b210a5be62",
"max_forks_repo_licenses": [
"CC0-1.0"
],
"max_forks_repo_name": "cspollard/diff",
"max_forks_repo_path": "src/Algebra/Module/Diff.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "78c3dec24834ffeca5e74cb75578e9b210a5be62",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"CC0-1.0"
],
"max_issues_repo_name": "cspollard/diff",
"max_issues_repo_path": "src/Algebra/Module/Diff.agda",
"max_line_length": 91,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "78c3dec24834ffeca5e74cb75578e9b210a5be62",
"max_stars_repo_licenses": [
"CC0-1.0"
],
"max_stars_repo_name": "cspollard/diff",
"max_stars_repo_path": "src/Algebra/Module/Diff.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 797,
"size": 1934
} |
-- 2014-01-15 Andreas, reported by fredrik.forsberg
data Unit : Set where
tt : Unit
foo : Unit
foo = {!!}
-- Refine here should give tt
| {
"alphanum_fraction": 0.6714285714,
"avg_line_length": 15.5555555556,
"ext": "agda",
"hexsha": "74828d72f210bec48246eabc5f7487d067e68730",
"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/Issue1020a.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/Issue1020a.agda",
"max_line_length": 51,
"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/Issue1020a.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": 45,
"size": 140
} |
module Conversion where
open import Agda.Builtin.Nat
nonDependent : Nat -> Nat -> Nat
nonDependent a b = a
dependent : {A : Set} -> A -> A
dependent a = a
stuff : {A : Set} -> {B : Nat} -> Nat -> Nat
stuff zero = zero
stuff (suc c) = dependent c
| {
"alphanum_fraction": 0.6345381526,
"avg_line_length": 19.1538461538,
"ext": "agda",
"hexsha": "4cc387a4f004e7d3250d0cb9cd6449d7d12c4f80",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-01-31T08:40:41.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-01-31T08:40:41.000Z",
"max_forks_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "omega12345/RefactorAgda",
"max_forks_repo_path": "RefactorAgdaEngine/Test/Tests/input/Conversion.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b",
"max_issues_repo_issues_event_max_datetime": "2019-02-05T12:53:36.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-31T08:03:07.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "omega12345/RefactorAgda",
"max_issues_repo_path": "RefactorAgdaEngine/Test/Tests/input/Conversion.agda",
"max_line_length": 44,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "omega12345/RefactorAgda",
"max_stars_repo_path": "RefactorAgdaEngine/Test/Tests/input/Conversion.agda",
"max_stars_repo_stars_event_max_datetime": "2019-05-03T10:03:36.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-01-31T14:10:18.000Z",
"num_tokens": 81,
"size": 249
} |
module Cats.Category.Setoids.Facts.Products where
open import Data.Product as P using (_,_ ; <_,_>)
open import Relation.Binary using (Setoid)
open import Relation.Binary.Product.Pointwise using (×-setoid)
open import Cats.Category
open import Cats.Category.Setoids as Setoids using (Setoids ; ≈-intro ; ≈-elim)
open import Cats.Util.Conv
open Setoid using (Carrier ; refl ; sym ; trans) renaming (_≈_ to _≣_)
-- The existence of binary products, proven below, already follows from the
-- existence of general products, proven further below. We still construct them
-- explicitly because the definitions in this module are much easier to work
-- with.
module BuildBinary l l≈ where
infixr 2 _×_
open Category (Setoids l l≈)
open Setoids._⇒_ using (resp)
_×_ : Obj → Obj → Obj
_×_ = ×-setoid
projl : ∀ {A B} → A × B ⇒ A
projl {A} {B} = record
{ arr = P.proj₁
; resp = λ { (eq₁ , eq₂) → eq₁ }
}
projr : ∀ {A B} → A × B ⇒ B
projr {A} {B} = record
{ arr = P.proj₂
; resp = λ { (eq₁ , eq₂) → eq₂ }
}
⟨_,_⟩ : ∀ {X A B} → X ⇒ A → X ⇒ B → X ⇒ A × B
⟨_,_⟩ {A = A} {B} xl xr = record
{ arr = < xl ⃗ , xr ⃗ >
; resp = λ eq → resp xl eq , resp xr eq
}
isBinaryProduct : ∀ {A B} → IsBinaryProduct (A × B) projl projr
isBinaryProduct xl xr = record
{ arr = ⟨ xl , xr ⟩
; prop = (≈-intro λ eq → resp xl eq) , (≈-intro λ eq → resp xr eq)
; unique = λ { (eq₁ , eq₂) → ≈-intro λ x≈y → ≈-elim eq₁ x≈y , ≈-elim eq₂ x≈y }
}
_×′_ : ∀ A B → BinaryProduct A B
A ×′ B = mkBinaryProduct projl projr isBinaryProduct
instance
hasBinaryProducts : ∀ l l≈ → HasBinaryProducts (Setoids l l≈)
hasBinaryProducts l l≈ .HasBinaryProducts._×′_ = BuildBinary._×′_ l l≈
module Build l {I : Set l} where
open Category (Setoids l l)
open Setoids._⇒_ using (resp)
Π : (O : I → Obj) → Obj
Π O = record
{ Carrier = ∀ i → Carrier (O i)
; _≈_ = λ f g → ∀ i → _≣_ (O i) (f i) (g i)
; isEquivalence = record
{ refl = λ i → refl (O i)
; sym = λ eq i → sym (O i) (eq i)
; trans = λ eq₁ eq₂ i → trans (O i) (eq₁ i) (eq₂ i)
}
}
proj : ∀ {O : I → Obj} i → Π O ⇒ O i
proj i = record
{ arr = λ f → f i
; resp = λ eq → eq i
}
isProduct : ∀ {O : I → Obj} → IsProduct O (Π O) proj
isProduct x = record
{ arr = record
{ arr = λ a i → (x i ⃗) a
; resp = λ eq i → resp (x i) eq
}
; prop = λ i → ≈-intro λ eq → resp (x i) eq
; unique = λ x-candidate → ≈-intro λ eq i → ≈-elim (x-candidate i) eq
}
Π′ : (O : I → Obj) → Product O
Π′ O = record { prod = Π O ; proj = proj ; isProduct = isProduct }
instance
hasProducts : ∀ l → HasProducts l (Setoids l l)
hasProducts l = record { Π′ = Build.Π′ l }
| {
"alphanum_fraction": 0.5508474576,
"avg_line_length": 25.2857142857,
"ext": "agda",
"hexsha": "dc8cd2fb2f65dab5377307fbe9196079bc72d32d",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "alessio-b-zak/cats",
"max_forks_repo_path": "Cats/Category/Setoids/Facts/Products.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "alessio-b-zak/cats",
"max_issues_repo_path": "Cats/Category/Setoids/Facts/Products.agda",
"max_line_length": 82,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "alessio-b-zak/cats",
"max_stars_repo_path": "Cats/Category/Setoids/Facts/Products.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1017,
"size": 2832
} |
data Id (A : Set) : Set where
wrap : A → Id A
data Maybe (A : Set) : Set where
nothing : Maybe A
just : A → Maybe A
maybe : {A : Set} {B : Maybe A → Set} →
((x : A) → B (just x)) → B nothing → (x : Maybe A) → B x
maybe j n (just x) = j x
maybe j n nothing = n
record MaybeT (M : Set → Set) (A : Set) : Set where
constructor wrap
field
run : M (Maybe A)
open MaybeT public
postulate
R : Set
r : R
module M (_ : R) where
record Monad (M : Set → Set) : Set₁ where
field
return : ∀ {A} → A → M A
_>>=_ : ∀ {A B} → M A → (A → M B) → M B
open Monad ⦃ … ⦄ public
instance
transform : {M : Set → Set} ⦃ is-raw-monad : Monad M ⦄ →
Monad (MaybeT M)
run (Monad.return transform x) = return (just x)
run (Monad._>>=_ transform x f) =
run x >>= maybe (λ x → run (f x)) (return nothing)
open M r
instance
id-raw-monad : Monad Id
Monad.return id-raw-monad = wrap
Monad._>>=_ id-raw-monad (wrap x) f = f x
postulate
_∼_ : {A : Set} → Id A → Id A → Set
refl : {A : Set} (x : Id A) → x ∼ x
trans : {A : Set} {x y z : Id A} → x ∼ y → y ∼ z → x ∼ z
id : {A : Set} {x : Id A} (y : Id A) → x ∼ y → x ∼ y
>>=-cong : {A : Set} (x : Id A) {f g : A → Id A} →
(∀ z → f z ∼ g z) → (x >>= f) ∼ (x >>= g)
assoc : {A : Set} (x : Id A) (f : A → Id A) (g : A → Id A) →
(x >>= (λ x → f x >>= g)) ∼ ((x >>= f) >>= g)
fails :
{A : Set}
(x : MaybeT Id A) (f : A → MaybeT Id A) (g : A → MaybeT Id A) →
run (x >>= λ x → f x >>= g) ∼ run ((x >>= f) >>= g)
fails x f g =
trans (>>=-cong (run x) (maybe (λ _ → refl _) (refl _)))
(id (run ((x >>= f) >>= g))
(assoc (run x) _ _))
| {
"alphanum_fraction": 0.4493417287,
"avg_line_length": 25.6911764706,
"ext": "agda",
"hexsha": "4483e902d29b3b0214313186c81917c9b316e040",
"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/Issue2296c.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/Issue2296c.agda",
"max_line_length": 65,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/Issue2296c.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": 700,
"size": 1747
} |
module ZisRing where
open import Data.Product using (_×_; _,_)
open import Function using (_∘_)
open import Relation.Binary.PropositionalEquality
as PropEq using (_≡_; refl; cong; sym)
open import Integer10 -- 整数の定義
-- ---------- record ----------
record IsSemiGroup (A : Set) (_∙_ : A → A → A) : Set where
field
assoc : ∀ x y z → (x ∙ y) ∙ z ≡ x ∙ (y ∙ z)
record IsMonoid (A : Set) (_∙_ : A → A → A) (e : A) : Set where
field
isSemiGroup : IsSemiGroup A _∙_
identity : (∀ x → e ∙ x ≡ x) × (∀ x → x ∙ e ≡ x)
record IsGroup (A : Set) (_∙_ : A → A → A) (e : A) (iF : A → A) : Set where
field
isMonoid : IsMonoid A _∙_ e
inv : (∀ x → (iF x) ∙ x ≡ e) × (∀ x → x ∙ (iF x) ≡ e)
record IsAbelianGroup (A : Set) (_∙_ : A → A → A) (e : A) (iF : A → A) : Set where
field
isGroup : IsGroup A _∙_ e iF
comm : ∀ x y → x ∙ y ≡ y ∙ x
record IsRing (A : Set) (_⊕_ _⊗_ : A → A → A) (eP eT : A) (iF : A → A) : Set where
field
⊕isAbelianGroup : IsAbelianGroup A _⊕_ eP iF
⊗isMonoid : IsMonoid A _⊗_ eT
isDistR : (x y z : A) → (x ⊕ y) ⊗ z ≡ (x ⊗ z) ⊕ (y ⊗ z)
isDistL : (x y z : A) → x ⊗ (y ⊕ z) ≡ (x ⊗ y) ⊕ (x ⊗ z)
-- ----------------------------
-- Z,+が半群であること
lemma5 : (x : ℤ) → x + zero ≡ x
lemma5 zero = refl
lemma5 (succ _) = refl
lemma5 (pred _) = refl
postulate -- ここだけ
succPred : (x : ℤ) → succ (pred x) ≡ x
predSucc : (x : ℤ) → pred (succ x) ≡ x
mutual
succOut1 : (x y : ℤ) → succ x + y ≡ succ (x + y)
succOut1 x zero = cong succ (sym (lemma5 x))
succOut1 x (succ y) rewrite succOut1 x y
| succOut2 x y = refl
succOut1 x (pred y) rewrite predOut2 x y
| succPred (x + y) = refl
succOut2 : (x y : ℤ) → x + succ y ≡ succ (x + y)
succOut2 zero y = refl
succOut2 (succ x) y = refl
succOut2 (pred x) y rewrite predOut1 x y
| succPred (x + y) = refl
predOut1 : (x y : ℤ) → pred x + y ≡ pred (x + y)
predOut1 x zero = cong pred (sym (lemma5 x))
predOut1 x (succ y) rewrite succOut2 x y
| predSucc (x + y) = refl
predOut1 x (pred y) rewrite predOut1 x y
| predOut2 x y = refl
predOut2 : (x y : ℤ) → x + pred y ≡ pred (x + y)
predOut2 zero y = refl
predOut2 (succ x) y rewrite succOut1 x y
| predSucc (x + y) = refl
predOut2 (pred x) y = refl
ℤ+-assoc : ∀ x y z → (x + y) + z ≡ x + (y + z)
ℤ+-assoc zero y z = refl
ℤ+-assoc (succ x) y z rewrite succOut1 x y
| succOut1 (x + y) z
| succOut1 x (y + z) = cong succ (ℤ+-assoc x y z)
ℤ+-assoc (pred x) y z rewrite predOut1 x y
| predOut1 (x + y) z
| predOut1 x (y + z) = cong pred (ℤ+-assoc x y z)
ℤ+-isSemiGroup : IsSemiGroup ℤ _+_
ℤ+-isSemiGroup = record { assoc = ℤ+-assoc }
-- Z,+がモノイドであること
ℤ+Zero-isMonoid : IsMonoid ℤ _+_ zero
ℤ+Zero-isMonoid = record { isSemiGroup = ℤ+-isSemiGroup ;
identity = (zero+x≡x , x+zero≡x) }
where
zero+x≡x : ∀ x → zero + x ≡ x
zero+x≡x _ = refl
x+zero≡x : ∀ x → x + zero ≡ x
x+zero≡x = lemma5
-- Z,+が群であること
leftInv : ∀ x → (opposite x + x) ≡ zero
leftInv zero = refl
leftInv (succ x) = leftInv x
leftInv (pred x) = leftInv x
rightInv : ∀ x → (x + opposite x) ≡ zero
rightInv zero = refl
rightInv (succ x) = rightInv x
rightInv (pred x) = rightInv x
ℤ+ZeroOpposite-isGroup : IsGroup ℤ _+_ zero opposite
ℤ+ZeroOpposite-isGroup = record { isMonoid = ℤ+Zero-isMonoid ;
inv = (leftInv , rightInv) }
-- Z,+がアーベル群であること
ℤ+ZeroOpposite-Comm : ∀ x y → (x + y) ≡ (y + x)
ℤ+ZeroOpposite-Comm zero y = sym (lemma5 y)
ℤ+ZeroOpposite-Comm (succ x) y rewrite succOut1 x y
| succOut2 y x
= cong succ (ℤ+ZeroOpposite-Comm x y)
ℤ+ZeroOpposite-Comm (pred x) y rewrite predOut1 x y
| predOut2 y x
= cong pred (ℤ+ZeroOpposite-Comm x y)
ℤ+ZeroOpposite-isAbelianGroup : IsAbelianGroup ℤ _+_ zero opposite
ℤ+ZeroOpposite-isAbelianGroup
= record { isGroup = ℤ+ZeroOpposite-isGroup ;
comm = ℤ+ZeroOpposite-Comm }
-- Z,*が半群であること
lemma7 : (x y z : ℤ) → x * (y + z) ≡ (x * y) + (x * z)
lemma7 x y zero rewrite lemma5 y | lemma5 (x * y) = refl
lemma7 x y (succ z) rewrite succOut2 y z | lemma7 x y z
= ℤ+-assoc (x * y) (x * z) x
lemma7 x y (pred z) rewrite predOut2 y z | lemma7 x y z
= ℤ+-assoc (x * y) (x * z) (opposite x)
lemma8-3 : (x y : ℤ) → opposite x + opposite y ≡ opposite (x + y)
lemma8-3 x zero rewrite lemma5 (opposite x) | lemma5 x = refl
lemma8-3 x (succ y) rewrite predOut2 (opposite x) (opposite y)
| succOut2 x y = cong pred (lemma8-3 x y)
lemma8-3 x (pred y) rewrite succOut2 (opposite x) (opposite y)
| predOut2 x y = cong succ (lemma8-3 x y)
lemma8-5 : (x y : ℤ) → opposite x + y ≡ opposite (x + (opposite y))
lemma8-5 x zero rewrite lemma5 (opposite x) | lemma5 x = refl
lemma8-5 x (succ y) rewrite succOut2 (opposite x) y
| predOut2 x (opposite y) = cong succ (lemma8-5 x y)
lemma8-5 x (pred y) rewrite predOut2 (opposite x) y
| succOut2 x (opposite y) = cong pred (lemma8-5 x y)
lemma8-2 : (x y : ℤ) → x * opposite y ≡ opposite (x * y)
lemma8-2 x zero = refl
lemma8-2 x (succ y) rewrite lemma8-2 x y | lemma8-3 (x * y) x = refl
lemma8-2 x (pred y) rewrite lemma8-2 x y | lemma8-5 (x * y) x = refl
ℤ*-isSemiGroup : IsSemiGroup ℤ _*_
ℤ*-isSemiGroup = record { assoc = ℤ*-assoc }
where
ℤ*-assoc : ∀ x y z → ((x * y) * z) ≡ (x * (y * z))
ℤ*-assoc x y zero = refl
ℤ*-assoc x y (succ z) rewrite lemma7 x (y * z) y
= cong (_+ (x * y)) (ℤ*-assoc x y z)
ℤ*-assoc x y (pred z) rewrite lemma7 x (y * z) (opposite y)
| lemma8-2 x y
= cong (_+ opposite (x * y)) (ℤ*-assoc x y z)
-- Z,*がモノイドであること
one = succ zero
ℤ*One-isMonoid : IsMonoid ℤ _*_ one
ℤ*One-isMonoid = record { isSemiGroup = ℤ*-isSemiGroup ;
identity = (one*x≡x , x*one≡x) }
where
one*x≡x : ∀ x → (succ zero) * x ≡ x
one*x≡x zero = refl
one*x≡x (succ x) rewrite succOut2 (succ zero * x) zero
| lemma5 (succ zero * x) = cong succ (one*x≡x x)
one*x≡x (pred x) rewrite predOut2 (succ zero * x) zero
| lemma5 (succ zero * x) = cong pred (one*x≡x x)
x*one≡x : ∀ x → x * one ≡ x
x*one≡x _ = refl
-- Zが環であること
ℤ+ZeroOppo-*One-isRing : IsRing ℤ _+_ _*_ zero one opposite
ℤ+ZeroOppo-*One-isRing
= record { ⊕isAbelianGroup = ℤ+ZeroOpposite-isAbelianGroup ;
⊗isMonoid = ℤ*One-isMonoid ;
isDistR = isDistR-Z ;
isDistL = lemma7 }
where
lemma9 : ∀ a b c d → ((a + b) + (c + d)) ≡ ((a + c) + (b + d))
lemma9 zero b c d rewrite sym (ℤ+-assoc b c d)
| ℤ+ZeroOpposite-Comm b c
= ℤ+-assoc c b d
lemma9 (succ a) b c d rewrite succOut1 a b
| succOut1 (a + b) (c + d)
| succOut1 a c
| succOut1 (a + c) (b + d)
= cong succ (lemma9 a b c d)
lemma9 (pred a) b c d rewrite predOut1 a b
| predOut1 (a + b) (c + d)
| predOut1 a c
| predOut1 (a + c) (b + d)
= cong pred (lemma9 a b c d)
isDistR-Z : ∀ x y z → ((x + y) * z) ≡ ((x * z) + (y * z))
isDistR-Z x y zero = refl
isDistR-Z x y (succ z) rewrite isDistR-Z x y z = lemma9 (x * z) (y * z) x y
isDistR-Z x y (pred z) rewrite sym (lemma8-3 x y) | isDistR-Z x y z
= lemma9 (x * z) (y * z) (opposite x) (opposite y)
-- (-1) * (-1) = (+1) その2
-- 「反数の反数」を使ってはいけないらしい
-- (-1) * 0 ≡ (-1) * (-1) + (-1)
-- rewrite x * 0 ≡ 0
-- x ≡ y → x + 1 ≡ y + 1
-- rewrite 0 + 1 ≡ 1
-- 結合法則 rewrite (x + y) + z ≡ x + (y + z)
-- rewrite (-1) + 1 ≡ 0
-- rewrite x + 0 ≡ x
-- 左辺と右辺を入れ替える
-₁ = pred zero
seed2 : (x : ℤ) → x * zero ≡ x * -₁ + x
seed2 x rewrite leftInv x = refl
lemma1 : (-₁ * zero ≡ -₁ * -₁ + -₁) → (zero ≡ -₁ * -₁ + -₁)
lemma1 prf = prf
lemma2 : (zero ≡ -₁ * -₁ + -₁) → (zero + one ≡ -₁ * -₁ + -₁ + one)
lemma2 prf = cong (_+ one) prf
lemma3 : (zero + one ≡ -₁ * -₁ + -₁ + one) → (one ≡ -₁ * -₁)
lemma3 prf = prf
lemma4 : (one ≡ -₁ * -₁) → (-₁ * -₁ ≡ one)
lemma4 p = sym p
theorem2 : pred zero * pred zero ≡ succ zero
theorem2 = (lemma4 ∘ lemma3 ∘ lemma2 ∘ lemma1) (seed2 -₁)
| {
"alphanum_fraction": 0.4728127337,
"avg_line_length": 41.2378854626,
"ext": "agda",
"hexsha": "90aa3013ba1ffe7938dca4e49c3d7c2cc46beb20",
"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": "9117b6bec9880d8c0a5d6ee4399fd841c3544d84",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "righ1113/Agda",
"max_forks_repo_path": "ZisRing.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9117b6bec9880d8c0a5d6ee4399fd841c3544d84",
"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": "righ1113/Agda",
"max_issues_repo_path": "ZisRing.agda",
"max_line_length": 96,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "9117b6bec9880d8c0a5d6ee4399fd841c3544d84",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "righ1113/Agda",
"max_stars_repo_path": "ZisRing.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3388,
"size": 9361
} |
{-
This file contains:
- Definition of the Bouquet of circles of a type aka wedge of A circles
-}
{-# OPTIONS --safe #-}
module Cubical.HITs.Bouquet.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Pointed
private
variable
ℓ : Level
data Bouquet (A : Type ℓ) : Type ℓ where
base : Bouquet A
loop : A → base ≡ base
Bouquet∙ : Type ℓ → Pointed ℓ
Bouquet∙ A = Bouquet A , base
| {
"alphanum_fraction": 0.7018779343,
"avg_line_length": 17.04,
"ext": "agda",
"hexsha": "cb73f68544d248bf985f88687cf4cd5684272c6d",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "thomas-lamiaux/cubical",
"max_forks_repo_path": "Cubical/HITs/Bouquet/Base.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "thomas-lamiaux/cubical",
"max_issues_repo_path": "Cubical/HITs/Bouquet/Base.agda",
"max_line_length": 71,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "thomas-lamiaux/cubical",
"max_stars_repo_path": "Cubical/HITs/Bouquet/Base.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": 134,
"size": 426
} |
-- Only forced indices can be large.
data Img {a b} {A : Set a} {B : Set b} (f : A → B) : B → Set where
inv : ∀ x → Img f (f x)
| {
"alphanum_fraction": 0.5151515152,
"avg_line_length": 22,
"ext": "agda",
"hexsha": "7c9be052189a9d2a32c21df1cea866de2c64b34f",
"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/LargeIndices.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/LargeIndices.agda",
"max_line_length": 66,
"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/LargeIndices.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": 52,
"size": 132
} |
module Proof where
open import Agda.Primitive hiding (_⊔_)
open import Reflection
open import Data.Fin hiding (_+_)
open import Data.Fin.Properties using (eq? ; _≟_ )
open import Data.Nat hiding (eq? ; _⊔_)
open import Data.Nat.Properties
open import Data.List
open import Data.String hiding (setoid)
open import Data.Bool
open import Data.Vec
open import Relation.Binary
open import Relation.Binary.EqReasoning
open import Relation.Binary.PropositionalEquality using (_≡_ ; refl ; cong ; setoid )
import Relation.Binary.Indexed as I
open import Function using (_∘_ ; _$_ ; _∋_ ; id ; const)
open import Function.Equality using (_⟶_ ; _⟨$⟩_ ; Π )
open import Function.LeftInverse hiding (_∘_)
open import Function.Injection using (_↣_ ; Injective ; Injection )
open import Function.Surjection using (_↠_ ; Surjective ; Surjection)
open import Function.Bijection using (Bijection ; Bijective ; id )
open import Relation.Nullary
open import Relation.Nullary.Negation
open import Helper.Fin
open import Serializer
open import Serializer.Fin
open import Serializer.Bool
data Test : Set where
A : Bool -> Test
B : Fin 2 -> Bool -> Test
C : Fin 2 -> Test
open Serializer.Serializer {{...}}
fromTest : Test -> Fin 8
fromTest (A x) = +₁ 6 2 (+₁ 2 4 (from x))
fromTest (B x x₁) = +₁ 6 2 (+₂ 2 4 (× 2 2 (from x) (from x₁)))
fromTest (C x) = +₂ 6 2 (from x)
test : Fin 4 -> Test
test x with ⨂ 2 2 x
test .(× 2 2 i j) | is× i j = B (to i) (to j)
toTest : Fin 8 -> Test
toTest x = [ (\y -> [ (\z -> A $ to z) , test ] (⨁ 2 4 y) ) , (\y -> C $ to y) ] (⨁ 6 2 x)
--from-cong : Setoid._≈_ (setoid Test) I.=[ fromTest ]⇒ Setoid._≈_ (setoid (Fin 8))
--from-cong refl = refl
from-preserves-eq : setoid Test ⟶ setoid (Fin 8)
from-preserves-eq = record { _⟨$⟩_ = fromTest ; cong = (\{ {i} {.i} refl → refl }) }
from-injective : Injective from-preserves-eq
from-injective {A x} {A x₁} p with from-bool-injective ∘ +-eq₁ ∘ +-eq₁ $ p
from-injective {A x} {A .x} p | refl = refl
from-injective {A x} {B x₁ x₂} p = contradiction (+-eq₁ p) ¬+-eq₁
from-injective {A x} {C x₁} p = contradiction p ¬+-eq₁
from-injective {B x x₁} {A x₂} p = contradiction (+-eq₁ p) ¬+-eq₂
from-injective {B x x₁} {B y y₁} p with +-eq₂ {2} {4} ∘ +-eq₁ $ p
... | p2 with from-bool-injective (×-equal₁ {x₁ = x} {x₂ = y} p2) | ×-equal₂ {x₁ = x} {x₂ = y} p2
from-injective {B x x₁} {B .x .x₁} p | p2 | refl | refl = refl
from-injective {B x x₁} {C x₂} p = contradiction p ¬+-eq₁
from-injective {C x} {A x₁} p = contradiction p ¬+-eq₂
from-injective {C x} {B x₁ x₂} p = contradiction p ¬+-eq₂
from-injective {C x} {C .x} refl = refl
from-surjective : Surjective from-preserves-eq
from-surjective = record { from = preserves-eq-inv ; right-inverse-of = inv }
where
-- cong-inverse : Setoid._≈_ (setoid (Fin 8)) I.=[ toTest ]⇒ Setoid._≈_ (setoid Test)
-- cong-inverse refl = refl
preserves-eq-inv : setoid (Fin 8) ⟶ setoid Test
preserves-eq-inv = record { _⟨$⟩_ = toTest ; cong = (\{ {i} {.i} refl → refl }) }
inv : preserves-eq-inv RightInverseOf from-preserves-eq
inv x with ⨁ 6 2 x
inv .(+₁ 6 2 i) | is+₁ i with ⨁ 2 4 i
inv ._ | is+₁ ._ | is+₁ i
rewrite (Surjective.right-inverse-of (Bijective.surjective (Bijection.bijective (bijection {Bool})))) i = refl
inv ._ | is+₁ ._ | is+₂ j with ⨂ 2 2 j
inv ._ | is+₁ ._ | is+₂ ._ | is× i j
rewrite (Surjective.right-inverse-of (Bijective.surjective (Bijection.bijective (bijection {Fin 2})))) i
| (Surjective.right-inverse-of (Bijective.surjective (Bijection.bijective (bijection {Bool})))) j = refl
inv ._ | is+₂ j = refl
from-injection : Test ↣ Fin 8
from-injection = record { to = from-preserves-eq ; injective = from-injective }
from-surjection : Test ↠ Fin 8
from-surjection = record { to = from-preserves-eq ; surjective = from-surjective }
from-bijection : Bijection (setoid Test) (setoid (Fin 8))
from-bijection = record { to = from-preserves-eq ; bijective = record { injective = from-injective ; surjective = from-surjective } }
instance
serializerTest : Serializer Test
serializerTest = record {
size = 8 ;
from = fromTest ;
to = toTest ;
bijection = from-bijection
}
| {
"alphanum_fraction": 0.6543504172,
"avg_line_length": 39.2056074766,
"ext": "agda",
"hexsha": "2a0fd32758d873992854ecc0fb0f10eb8eaf1afa",
"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": "cb95986b772b7a01195619be5e8e590f2429c759",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mathijsb/generic-in-agda",
"max_forks_repo_path": "Proof.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "cb95986b772b7a01195619be5e8e590f2429c759",
"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": "mathijsb/generic-in-agda",
"max_issues_repo_path": "Proof.agda",
"max_line_length": 133,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "cb95986b772b7a01195619be5e8e590f2429c759",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mathijsb/generic-in-agda",
"max_stars_repo_path": "Proof.agda",
"max_stars_repo_stars_event_max_datetime": "2016-08-04T16:05:24.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-06-09T09:59:27.000Z",
"num_tokens": 1449,
"size": 4195
} |
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2020, 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
{-# OPTIONS --allow-unsolved-metas #-}
open import Optics.All
open import LibraBFT.Prelude
open import LibraBFT.Base.PKCS
open import LibraBFT.Base.Encode
open import LibraBFT.Base.KVMap as KVMap
open import LibraBFT.Base.Types
open import Data.String using (String)
-- This module defines types for an out-of-date implementation, based
-- on a previous version of LibraBFT. It will be updated to model a
-- more recent version in future.
--
-- One important trick here is that the EventProcessor type separayes
-- types that /define/ the EpochConfig and types that /use/ the
-- /EpochConfig/. The advantage of doing this separation can be seen
-- in Util.Util.liftEC, where we define a lifting of a function that
-- does not change the bits that define the EpochConfig into the whole
-- state. This enables a more elegant approach for reasoning about
-- functions that do not change parts of the state responsible for
-- defining the epoch config. However, the separation is not perfect,
-- so sometimes fields may be modified in EpochIndep even though there
-- is no epoch change.
module LibraBFT.Impl.Consensus.Types where
open import LibraBFT.Impl.Base.Types public
open import LibraBFT.Impl.NetworkMsg public
open import LibraBFT.Abstract.Types.EpochConfig UID NodeId public
open import LibraBFT.Impl.Consensus.Types.EpochIndep public
open import LibraBFT.Impl.Consensus.Types.EpochDep public
-- The parts of the state of a peer that are used to
-- define the EpochConfig are the SafetyRules and ValidatorVerifier:
record EventProcessorEC : Set where
constructor mkEventProcessorPreEC
field
₋epSafetyRules : SafetyRules
₋epValidators : ValidatorVerifier
open EventProcessorEC public
unquoteDecl epSafetyRules epValidators = mkLens (quote EventProcessorEC)
(epSafetyRules ∷ epValidators ∷ [])
epEpoch : Lens EventProcessorEC EpochId
epEpoch = epSafetyRules ∙ srPersistentStorage ∙ psEpoch
epLastVotedRound : Lens EventProcessorEC Round
epLastVotedRound = epSafetyRules ∙ srPersistentStorage ∙ psLastVotedRound
-- We need enough authors to withstand the desired number of
-- byzantine failures. We enforce this with a predicate over
-- 'EventProcessorEC'.
EventProcessorEC-correct : EventProcessorEC → Set
EventProcessorEC-correct epec =
let numAuthors = kvm-size (epec ^∙ epValidators ∙ vvAddressToValidatorInfo)
qsize = epec ^∙ epValidators ∙ vvQuorumVotingPower
bizF = numAuthors ∸ qsize
in suc (3 * bizF) ≤ numAuthors
EventProcessorEC-correct-≡ : (epec1 : EventProcessorEC)
→ (epec2 : EventProcessorEC)
→ (epec1 ^∙ epValidators) ≡ (epec2 ^∙ epValidators)
→ EventProcessorEC-correct epec1
→ EventProcessorEC-correct epec2
EventProcessorEC-correct-≡ epec1 epec2 refl = id
-- Given a well-formed set of definitions that defines an EpochConfig,
-- α-EC will compute this EpochConfig by abstracting away the unecessary
-- pieces from EventProcessorEC.
-- TODO-2: update and complete when definitions are updated to more recent version
α-EC : Σ EventProcessorEC EventProcessorEC-correct → EpochConfig
α-EC (epec , ok) =
let numAuthors = kvm-size (epec ^∙ epValidators ∙ vvAddressToValidatorInfo)
qsize = epec ^∙ epValidators ∙ vvQuorumVotingPower
bizF = numAuthors ∸ qsize
in (mkEpochConfig {! someHash?!}
(epec ^∙ epEpoch) numAuthors {!!} {!!} {!!} {!!} {!!} {!!} {!!} {!!})
postulate
α-EC-≡ : (epec1 : EventProcessorEC)
→ (epec2 : EventProcessorEC)
→ (vals≡ : (epec1 ^∙ epValidators) ≡ (epec2 ^∙ epValidators))
→ (epoch≡ : (epec1 ^∙ epEpoch) ≡ (epec2 ^∙ epEpoch))
→ (epec1-corr : EventProcessorEC-correct epec1)
→ α-EC (epec1 , epec1-corr) ≡ α-EC (epec2 , EventProcessorEC-correct-≡ epec1 epec2 vals≡ epec1-corr)
{-
α-EC-≡ epec1 epec2 refl refl epec1-corr = refl
-}
-- Finally, the EventProcessor is split in two pieces: those
-- that are used to make an EpochConfig versus those that
-- use an EpochConfig.
record EventProcessor : Set where
constructor mkEventProcessor
field
₋epEC : EventProcessorEC
₋epEC-correct : EventProcessorEC-correct ₋epEC
₋epWithEC : EventProcessorWithEC (α-EC (₋epEC , ₋epEC-correct))
-- If we want to add pieces that neither contribute to the
-- construction of the EC nor need one, they should be defined in
-- EventProcessor directly
open EventProcessor public
α-EC-EP : EventProcessor → EpochConfig
α-EC-EP ep = α-EC ((₋epEC ep) , (₋epEC-correct ep))
₋epHighestQC : (ep : EventProcessor) → QuorumCert
₋epHighestQC ep = ₋btHighestQuorumCert ((₋epWithEC ep) ^∙ (lBlockTree (α-EC-EP ep)))
epHighestQC : Lens EventProcessor QuorumCert
epHighestQC = mkLens' ₋epHighestQC
(λ (mkEventProcessor ec ecc (mkEventProcessorWithEC (mkBlockStore bsInner))) qc
→ mkEventProcessor ec ecc (mkEventProcessorWithEC (mkBlockStore (record bsInner {₋btHighestQuorumCert = qc}))))
₋epHighestCommitQC : (ep : EventProcessor) → QuorumCert
₋epHighestCommitQC ep = ₋btHighestCommitCert ((₋epWithEC ep) ^∙ (lBlockTree (α-EC-EP ep)))
epHighestCommitQC : Lens EventProcessor QuorumCert
epHighestCommitQC = mkLens' ₋epHighestCommitQC
(λ (mkEventProcessor ec ecc (mkEventProcessorWithEC (mkBlockStore bsInner))) qc
→ mkEventProcessor ec ecc (mkEventProcessorWithEC (mkBlockStore (record bsInner {₋btHighestCommitCert = qc}))))
| {
"alphanum_fraction": 0.6933710859,
"avg_line_length": 47.6507936508,
"ext": "agda",
"hexsha": "9c2e720c231601d4999dbea601d6e63df4bae96d",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "34e4627855fb198665d0c98f377403a906ba75d7",
"max_forks_repo_licenses": [
"UPL-1.0"
],
"max_forks_repo_name": "haroldcarr/bft-consensus-agda",
"max_forks_repo_path": "LibraBFT/Impl/Consensus/Types.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "34e4627855fb198665d0c98f377403a906ba75d7",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"UPL-1.0"
],
"max_issues_repo_name": "haroldcarr/bft-consensus-agda",
"max_issues_repo_path": "LibraBFT/Impl/Consensus/Types.agda",
"max_line_length": 137,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "34e4627855fb198665d0c98f377403a906ba75d7",
"max_stars_repo_licenses": [
"UPL-1.0"
],
"max_stars_repo_name": "haroldcarr/bft-consensus-agda",
"max_stars_repo_path": "LibraBFT/Impl/Consensus/Types.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1681,
"size": 6004
} |
module InstanceArguments where
postulate A₁ A₂ B : Set
f₁ : {{a : A₁}} → B
f₂ : {{a : A₂}} → B
a₁ : A₁
-- resolve from signature
test₁ : B
test₁ = f₁
-- resolve from context
test₂ : {{a : A₂}} → B
test₂ = f₂
postulate F : Set → Set
fA₁ : F A₁
fA₂ : F A₂
f₃ : {A : Set} → {{fA : F A}} → A → B
test₃ : B
test₃ = f₃ a₁
record Rec (t : Set) : Set₁ where
field
v : t
open module RecWI {t : Set} {{r : Rec t}} = Rec r
postulate testT₁ : Set
testV₁ : testT₁
testT₂ : Set
testV₂ : testT₂
testRec₁ : Rec testT₁
testRec₁ = record { v = testV₁ }
testRec₂ : Rec testT₂
testRec₂ = record { v = testV₂ }
-- needs constraint checking in instance argument resolution
test : testT₂
test = v
| {
"alphanum_fraction": 0.5481012658,
"avg_line_length": 18.3720930233,
"ext": "agda",
"hexsha": "6aad0aa53df4a68439d0f2f5a29d8e120a32a1b2",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "larrytheliquid/agda",
"max_forks_repo_path": "test/succeed/InstanceArguments.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "larrytheliquid/agda",
"max_issues_repo_path": "test/succeed/InstanceArguments.agda",
"max_line_length": 60,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "larrytheliquid/agda",
"max_stars_repo_path": "test/succeed/InstanceArguments.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 285,
"size": 790
} |
-- Andreas, 2015-06-11
-- testing with in copattern matching with dependent record
-- {-# OPTIONS -v tc.with:20 #-}
open import Common.Prelude
open import Common.Equality
data Dec P : Set where
yes : (p : P) → Dec P
no : (¬p : P → ⊥) → Dec P
postulate
_≟_ : (n m : Nat) → Dec (n ≡ m)
boring : {A : Set} → A
record R : Set₁ where
field
Car : Set
el : Car
same : (x : Car) → Dec (x ≡ el)
test : (n : Nat) → R
R.Car (test n) = Nat
R.el (test n) = n
R.same (test zero) zero = yes refl
R.same (test zero) (suc x) = no λ()
R.same (test (suc n)) zero = no λ()
R.same (test (suc n)) (suc x) with n ≟ x
R.same (test (suc n)) (suc .n) | yes refl = yes refl
R.same (test (suc n)) (suc x) | no ¬p = no boring
| {
"alphanum_fraction": 0.5655737705,
"avg_line_length": 22.875,
"ext": "agda",
"hexsha": "0d64c5b9a927cb64b712ba20d655f99b2a55407f",
"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/Issue1546.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/Issue1546.agda",
"max_line_length": 59,
"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/Issue1546.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": 287,
"size": 732
} |
module Prelude.Monad.Indexed {i} {I : Set i} where
open import Agda.Primitive
open import Prelude.Function
open import Prelude.Functor
open import Prelude.Applicative.Indexed {I = I}
record IMonad {a b} (M : I → I → Set a → Set b) : Set (i ⊔ lsuc a ⊔ b) where
infixr 1 _=<<_
infixl 1 _>>=_ _>>_
field
_>>=_ : ∀ {A B i j k} → M i j A → (A → M j k B) → M i k B
overlap {{super}} : IApplicative M
_>>_ : ∀ {A B i j k} → M i j A → M j k B → M i k B
m₁ >> m₂ = m₁ >>= λ _ → m₂
_=<<_ : ∀ {A B i j k} → (A → M j k B) → M i j A → M i k B
_=<<_ = flip _>>=_
return : ∀ {a b} {A : Set a} {M : I → I → Set a → Set b} {{_ : IMonad M}}
{i : I} → A → M i i A
return = pure
open IMonad {{...}} public
{-# DISPLAY IMonad._>>=_ _ = _>>=_ #-}
{-# DISPLAY IMonad._=<<_ _ = _=<<_ #-}
{-# DISPLAY IMonad._>>_ _ = _>>_ #-}
join : ∀ {a} {M : I → I → Set a → Set a} {{_ : IMonad M}} {A : Set a}
{i j k} → M i j (M j k A) → M i k A
join = _=<<_ id
-- Level polymorphic monads
record IMonad′ {a b} (M : ∀ {a} → I → I → Set a → Set a) : Set (i ⊔ lsuc (a ⊔ b)) where
field
_>>=′_ : {A : Set a} {B : Set b} {i j k : I} → M i j A → (A → M j k B) → M i k B
overlap {{super}} : IApplicative′ {a} {b} M
_>>′_ : {A : Set a} {B : Set b} {i j k : I} → M i j A → M j k B → M i k B
m >>′ m′ = m >>=′ λ _ → m′
open IMonad′ {{...}} public
| {
"alphanum_fraction": 0.4784828592,
"avg_line_length": 29.8043478261,
"ext": "agda",
"hexsha": "7c7cb96c2924fd820fd9922937398180d9722527",
"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/Monad/Indexed.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/Monad/Indexed.agda",
"max_line_length": 87,
"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/Monad/Indexed.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": 599,
"size": 1371
} |
{-# OPTIONS --safe --warning=error --without-K #-}
open import LogicalFormulae
open import Setoids.Setoids
open import Rings.Definition
open import Rings.IntegralDomains.Definition
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
module Rings.Irreducibles.Definition {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} {R : Ring S _+_ _*_} (intDom : IntegralDomain R) where
open Setoid S
open Ring R
open import Rings.Units.Definition R
record Irreducible (r : A) : Set (a ⊔ b) where
field
nonzero : (r ∼ 0R) → False
nonunit : (Unit r) → False
irreducible : (x y : A) → (x * y) ∼ r → (Unit x → False) → Unit y
| {
"alphanum_fraction": 0.6605504587,
"avg_line_length": 31.1428571429,
"ext": "agda",
"hexsha": "8d12160ad7d2b06323d47bd51bbd6fbf2f4caf57",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Smaug123/agdaproofs",
"max_forks_repo_path": "Rings/Irreducibles/Definition.agda",
"max_issues_count": 14,
"max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Smaug123/agdaproofs",
"max_issues_repo_path": "Rings/Irreducibles/Definition.agda",
"max_line_length": 158,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Smaug123/agdaproofs",
"max_stars_repo_path": "Rings/Irreducibles/Definition.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z",
"num_tokens": 222,
"size": 654
} |
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
module groups.ReducedWord {i} {A : Type i} (dec : has-dec-eq A) where
is-reduced : Word A → Type i
is-reduced nil = Lift ⊤
is-reduced (_ :: nil) = Lift ⊤
is-reduced (inl x :: inl y :: w) = is-reduced (inl y :: w)
is-reduced (inl x :: inr y :: w) = (x ≠ y) × is-reduced (inr y :: w)
is-reduced (inr x :: inl y :: w) = (x ≠ y) × is-reduced (inl y :: w)
is-reduced (inr x :: inr y :: w) = is-reduced (inr y :: w)
-- Everything is a set.
A-is-set : is-set A
A-is-set = dec-eq-is-set dec
PlusMinus-has-dec-eq : has-dec-eq (PlusMinus A)
PlusMinus-has-dec-eq (inl x) (inl y) with dec x y
PlusMinus-has-dec-eq (inl x) (inl y) | inl p = inl $ ap inl p
PlusMinus-has-dec-eq (inl x) (inl y) | inr ¬p = inr $ ¬p ∘ lower ∘ Coprod=-in
PlusMinus-has-dec-eq (inl x) (inr y) = inr $ lower ∘ Coprod=-in
PlusMinus-has-dec-eq (inr x) (inl y) = inr $ lower ∘ Coprod=-in
PlusMinus-has-dec-eq (inr x) (inr y) with dec x y
PlusMinus-has-dec-eq (inr x) (inr y) | inl p = inl $ ap inr p
PlusMinus-has-dec-eq (inr x) (inr y) | inr ¬p = inr $ ¬p ∘ lower ∘ Coprod=-in
Word-has-dec-eq : has-dec-eq (Word A)
Word-has-dec-eq nil nil = inl idp
Word-has-dec-eq nil (_ :: w) = inr $ lower ∘ List=-in
Word-has-dec-eq (_ :: v) nil = inr $ lower ∘ List=-in
Word-has-dec-eq (x :: v) (y :: w) with PlusMinus-has-dec-eq x y
Word-has-dec-eq (x :: v) (y :: w) | inl x=y with Word-has-dec-eq v w
Word-has-dec-eq (x :: v) (y :: w) | inl x=y | inl v=w = inl $ List=-out (x=y , v=w)
Word-has-dec-eq (x :: v) (y :: w) | inl x=y | inr v≠w = inr $ v≠w ∘ snd ∘ List=-in
Word-has-dec-eq (x :: v) (y :: w) | inr x≠y = inr $ x≠y ∘ fst ∘ List=-in
instance
Word-is-set : is-set (Word A)
Word-is-set = dec-eq-is-set Word-has-dec-eq
is-reduced-is-prop : {w : Word A} → is-prop (is-reduced w)
is-reduced-is-prop {nil} = ⟨⟩
is-reduced-is-prop {x :: nil} = ⟨⟩
is-reduced-is-prop {inl x :: inl y :: l} = is-reduced-is-prop {inl y :: l}
is-reduced-is-prop {inl x :: inr y :: l} = ⟨⟩ where instance _ = is-reduced-is-prop {inr y :: l}
is-reduced-is-prop {inr x :: inl y :: l} = ⟨⟩ where instance _ = is-reduced-is-prop {inl y :: l}
is-reduced-is-prop {inr x :: inr y :: l} = is-reduced-is-prop {inr y :: l}
is-reduced-prop : SubtypeProp (Word A) i
is-reduced-prop = is-reduced , λ w → is-reduced-is-prop {w}
-- The subtype
ReducedWord : Type i
ReducedWord = Subtype is-reduced-prop
instance
ReducedWord-is-set : is-set ReducedWord
ReducedWord-is-set = Subtype-level is-reduced-prop where instance _ = is-reduced-is-prop
-- Identifications in [ReducedWord].
ReducedWord= : ReducedWord → ReducedWord → Type i
ReducedWord= = Subtype= is-reduced-prop
ReducedWord=-out : {x y : ReducedWord} → ReducedWord= x y → x == y
ReducedWord=-out = Subtype=-out is-reduced-prop
-- The group structure of reduced words
private
rw-unit : ReducedWord
rw-unit = nil , lift tt
abstract
tail-is-reduced : ∀ x w → is-reduced (x :: w) → is-reduced w
tail-is-reduced x nil red = lift tt
tail-is-reduced (inl x) (inl y :: w) red = red
tail-is-reduced (inl x) (inr y :: w) red = snd red
tail-is-reduced (inr x) (inl y :: w) red = snd red
tail-is-reduced (inr x) (inr y :: w) red = red
rw-cons : PlusMinus A → ReducedWord → ReducedWord
rw-cons x (nil , _) = (x :: nil) , lift tt
rw-cons (inl x) ((inl y :: l) , red) = (inl x :: inl y :: l) , red
rw-cons (inl x) ((inr y :: l) , red) with dec x y
rw-cons (inl x) ((inr y :: l) , red) | inl p = l , tail-is-reduced (inr y) l red
rw-cons (inl x) ((inr y :: l) , red) | inr ¬p = (inl x :: inr y :: l) , (¬p , red)
rw-cons (inr x) ((inl y :: l) , red) with dec x y
rw-cons (inr x) ((inl y :: l) , red) | inl p = l , tail-is-reduced (inl y) l red
rw-cons (inr x) ((inl y :: l) , red) | inr ¬p = (inr x :: inl y :: l) , (¬p , red)
rw-cons (inr x) ((inr y :: l) , red) = (inr x :: inr y :: l) , red
rw-++' : Word A → ReducedWord → ReducedWord
rw-++' w₁ rw₂ = foldr rw-cons rw₂ w₁
reduce : Word A → ReducedWord
reduce w = rw-++' w rw-unit
rw-++ : ReducedWord → ReducedWord → ReducedWord
rw-++ rw₁ rw₂ = rw-++' (fst rw₁) rw₂
abstract
-- assoc
rw-cons-reduced : ∀ x w
→ (red : is-reduced w)
→ (red' : is-reduced (x :: w))
→ rw-cons x (w , red) == (x :: w) , red'
rw-cons-reduced x nil _ _ = ReducedWord=-out idp
rw-cons-reduced (inl x) (inl y :: w) _ red' = ReducedWord=-out idp
rw-cons-reduced (inl x) (inr y :: w) _ red' with dec x y
rw-cons-reduced (inl x) (inr y :: w) _ red' | inl p = ⊥-rec $ fst red' $ p
rw-cons-reduced (inl x) (inr y :: w) _ red' | inr ¬p = ReducedWord=-out idp
rw-cons-reduced (inr x) (inl y :: w) _ red' with dec x y
rw-cons-reduced (inr x) (inl y :: w) _ red' | inl p = ⊥-rec $ fst red' $ p
rw-cons-reduced (inr x) (inl y :: w) _ red' | inr ¬p = ReducedWord=-out idp
rw-cons-reduced (inr x) (inr y :: w) _ red' = ReducedWord=-out idp
rw-cons-flip : ∀ x w red red'
→ rw-cons x ((flip x :: w) , red) == w , red'
rw-cons-flip (inl x) w _ _ with dec x x
rw-cons-flip (inl x) w _ _ | inl x=x = ReducedWord=-out idp
rw-cons-flip (inl x) w _ _ | inr x≠x = ⊥-rec (x≠x idp)
rw-cons-flip (inr x) w _ _ with dec x x
rw-cons-flip (inr x) w _ _ | inl x=x = ReducedWord=-out idp
rw-cons-flip (inr x) w _ _ | inr x≠x = ⊥-rec (x≠x idp)
rw-cons-cons-flip : ∀ x rw
→ rw-cons x (rw-cons (flip x) rw) == rw
rw-cons-cons-flip x (nil , red) = rw-cons-flip x nil _ red
rw-cons-cons-flip (inl x) ((inl y :: w) , red) with dec x y
rw-cons-cons-flip (inl x) ((inl y :: w) , red) | inl x=y =
rw-cons-reduced (inl x) w _ (transport! (λ z → is-reduced (inl z :: w)) x=y red)
∙ ReducedWord=-out (ap (λ z → inl z :: w) x=y)
rw-cons-cons-flip (inl x) ((inl y :: w) , red) | inr x≠y =
rw-cons-flip (inl x) (inl y :: w) (x≠y , red) red
rw-cons-cons-flip (inl x) ((inr y :: w) , red) = rw-cons-flip (inl x) (inr y :: w) red red
rw-cons-cons-flip (inr x) ((inl y :: w) , red) = rw-cons-flip (inr x) (inl y :: w) red red
rw-cons-cons-flip (inr x) ((inr y :: w) , red) with dec x y
rw-cons-cons-flip (inr x) ((inr y :: w) , red) | inl x=y =
rw-cons-reduced (inr x) w _ (transport! (λ z → is-reduced (inr z :: w)) x=y red)
∙ ReducedWord=-out (ap (λ z → inr z :: w) x=y)
rw-cons-cons-flip (inr x) ((inr y :: w) , red) | inr x≠y =
rw-cons-flip (inr x) (inr y :: w) (x≠y , red) red
rw-++-cons : ∀ x rw₁ rw₂
→ rw-++ (rw-cons x rw₁) rw₂
== rw-cons x (rw-++ rw₁ rw₂)
rw-++-cons x (nil , _) rw₂ = idp
rw-++-cons (inl x) ((inl y :: w₁) , _) rw₂ = idp
rw-++-cons (inl x) ((inr y :: w₁) , _) rw₂ with dec x y
rw-++-cons (inl x) ((inr y :: w₁) , _) rw₂ | inl p rewrite p =
! (rw-cons-cons-flip (inl y) (rw-++' w₁ rw₂))
rw-++-cons (inl x) ((inr y :: w₁) , _) rw₂ | inr ¬p = idp
rw-++-cons (inr x) ((inl y :: w₁) , _) rw₂ with dec x y
rw-++-cons (inr x) ((inl y :: w₁) , _) rw₂ | inl p rewrite p =
! (rw-cons-cons-flip (inr y) (rw-++' w₁ rw₂))
rw-++-cons (inr x) ((inl y :: w₁) , _) rw₂ | inr ¬p = idp
rw-++-cons (inr x) ((inr y :: w₁) , _) rw₂ = idp
rw-++-assoc' : ∀ w₁ rw₂ rw₃
→ rw-++ (rw-++' w₁ rw₂) rw₃
== rw-++' w₁ (rw-++' (fst rw₂) rw₃)
rw-++-assoc' nil rw₂ rw = idp
rw-++-assoc' (x :: w₁) rw₂ rw₃ =
rw-++-cons x (rw-++' w₁ rw₂) rw₃
∙ ap (rw-cons x) (rw-++-assoc' w₁ rw₂ rw₃)
-- inv
abstract
head2-is-reduced : ∀ x y w → is-reduced (x :: y :: w) → is-reduced (x :: y :: nil)
head2-is-reduced (inl x) (inl y) w red = lift tt
head2-is-reduced (inl x) (inr y) w red = fst red , lift tt
head2-is-reduced (inr x) (inl y) w red = fst red , lift tt
head2-is-reduced (inr x) (inr y) w red = lift tt
cons-is-reduced : ∀ x y w → is-reduced (x :: y :: nil) → is-reduced (y :: w)
→ is-reduced (x :: y :: w)
cons-is-reduced (inl x) (inl y) _ _ red₂ = red₂
cons-is-reduced (inl x) (inr y) _ red₁ red₂ = fst red₁ , red₂
cons-is-reduced (inr x) (inl y) _ red₁ red₂ = fst red₁ , red₂
cons-is-reduced (inr x) (inr y) _ _ red₂ = red₂
++-is-reduced : ∀ w₁ x w₂ → is-reduced (w₁ ++ (x :: nil)) → is-reduced (x :: w₂)
→ is-reduced ((w₁ ++ (x :: nil)) ++ w₂)
++-is-reduced nil _ _ _ red₂ = red₂
++-is-reduced (x :: nil) y w₂ red₁ red₂ = cons-is-reduced x y w₂ red₁ red₂
++-is-reduced (x :: y :: w₁) z w₂ red₁ red₂ =
cons-is-reduced x y ((w₁ ++ (z :: nil)) ++ w₂)
(head2-is-reduced x y (w₁ ++ (z :: nil)) red₁)
(++-is-reduced (y :: w₁) z w₂ (tail-is-reduced x (y :: w₁ ++ (z :: nil)) red₁) red₂)
swap2-is-reduced : ∀ x y → is-reduced (x :: y :: nil) → is-reduced (y :: x :: nil)
swap2-is-reduced (inl x) (inl y) red = lift tt
swap2-is-reduced (inl x) (inr y) red = fst red ∘ ! , lift tt
swap2-is-reduced (inr x) (inl y) red = fst red ∘ ! , lift tt
swap2-is-reduced (inr x) (inr y) red = lift tt
reverse-is-reduced : ∀ w → is-reduced w → is-reduced (reverse w)
reverse-is-reduced nil red = red
reverse-is-reduced (x :: nil) red = red
reverse-is-reduced (x :: y :: w) red =
++-is-reduced
(reverse w) y (x :: nil)
(reverse-is-reduced (y :: w) (tail-is-reduced x (y :: w) red))
(swap2-is-reduced x y (head2-is-reduced x y w red))
flip2-is-reduced : ∀ x y → is-reduced (x :: y :: nil) → is-reduced (flip x :: flip y :: nil)
flip2-is-reduced (inl x) (inl y) red = red
flip2-is-reduced (inl x) (inr y) red = red
flip2-is-reduced (inr x) (inl y) red = red
flip2-is-reduced (inr x) (inr y) red = red
Word-flip-is-reduced : ∀ w → is-reduced w → is-reduced (Word-flip w)
Word-flip-is-reduced nil red = red
Word-flip-is-reduced (x :: nil) red = red
Word-flip-is-reduced (x :: y :: w) red =
cons-is-reduced (flip x) (flip y) (Word-flip w)
(flip2-is-reduced x y (head2-is-reduced x y w red))
(Word-flip-is-reduced (y :: w) (tail-is-reduced x (y :: w) red))
rw-inv : ReducedWord → ReducedWord
rw-inv (w , red) = reverse (Word-flip w) , reverse-is-reduced (Word-flip w) (Word-flip-is-reduced w red)
abstract
rw-inv-l-lemma : ∀ w₁ x w₂ (red₂ : is-reduced (x :: w₂)) (red₂' : is-reduced w₂)
→ rw-++' (w₁ ++ (flip x :: nil)) ((x :: w₂) , red₂)
== rw-++' w₁ (w₂ , red₂')
rw-inv-l-lemma nil (inl x) w₂ _ _ with dec x x
rw-inv-l-lemma nil (inl x) w₂ _ _ | inl p = ReducedWord=-out idp
rw-inv-l-lemma nil (inl x) w₂ _ _ | inr ¬p = ⊥-rec (¬p idp)
rw-inv-l-lemma nil (inr x) w₂ _ _ with dec x x
rw-inv-l-lemma nil (inr x) w₂ _ _ | inl p = ReducedWord=-out idp
rw-inv-l-lemma nil (inr x) w₂ _ _ | inr ¬p = ⊥-rec (¬p idp)
rw-inv-l-lemma (x :: w₁) y w₂ red₂ red₂' =
ap (rw-cons x) (rw-inv-l-lemma w₁ y w₂ red₂ red₂')
rw-inv-l' : ∀ w (red : is-reduced w)
→ rw-++' (reverse (Word-flip w)) (w , red) == nil , lift tt
rw-inv-l' nil _ = idp
rw-inv-l' (x :: w) red =
rw-inv-l-lemma (reverse (Word-flip w)) x w red (tail-is-reduced x w red)
∙ rw-inv-l' w (tail-is-reduced x w red)
suffix-is-reduced : ∀ w₁ w₂ → is-reduced (w₁ ++ w₂) → is-reduced w₂
suffix-is-reduced nil w₂ red = red
suffix-is-reduced (x :: w₁) w₂ red = suffix-is-reduced w₁ w₂ $ tail-is-reduced x (w₁ ++ w₂) red
ReducedWord-group-struct : GroupStructure ReducedWord
ReducedWord-group-struct = record
{ ident = nil , lift tt
; inv = rw-inv
; comp = rw-++
; unit-l = λ _ → idp
; assoc = λ rw → rw-++-assoc' (fst rw)
; inv-l = uncurry rw-inv-l'
}
ReducedWord-group : Group i
ReducedWord-group = group _ ReducedWord-group-struct
private
abstract
QuotWordRel-cons : ∀ x w₂ (red₂ : is-reduced w₂)
→ QuotWordRel (x :: w₂) (fst (rw-cons x (w₂ , red₂)))
QuotWordRel-cons x nil _ = qwr-refl idp
QuotWordRel-cons (inl x) (inl y :: w) _ = qwr-refl idp
QuotWordRel-cons (inl x) (inr y :: w) _ with dec x y
QuotWordRel-cons (inl x) (inr y :: w) _ | inl x=y rewrite x=y = qwr-flip (inl y) w
QuotWordRel-cons (inl x) (inr y :: w) _ | inr x≠y = qwr-refl idp
QuotWordRel-cons (inr x) (inl y :: w) _ with dec x y
QuotWordRel-cons (inr x) (inl y :: w) _ | inl x=y rewrite x=y = qwr-flip (inr y) w
QuotWordRel-cons (inr x) (inl y :: w) _ | inr x≠y = qwr-refl idp
QuotWordRel-cons (inr x) (inr y :: w) _ = qwr-refl idp
QuotWordRel-++ : ∀ w₁ rw₂
→ QuotWordRel (w₁ ++ fst rw₂) (fst (rw-++' w₁ rw₂))
QuotWordRel-++ nil _ = qwr-refl idp
QuotWordRel-++ (x :: w₁) rw₂ =
qwr-trans (qwr-cons x (QuotWordRel-++ w₁ rw₂)) $
uncurry (QuotWordRel-cons x) (rw-++' w₁ rw₂)
-- freeness
ReducedWord-to-FreeGroup : ReducedWord-group →ᴳ FreeGroup A
ReducedWord-to-FreeGroup = group-hom (λ rw → qw[ fst rw ])
(λ rw₁ rw₂ → ! $ quot-rel $ QuotWordRel-++ (fst rw₁) rw₂)
private
abstract
reduce-emap : ∀ {w₁ w₂} → QuotWordRel w₁ w₂ → reduce w₁ == reduce w₂
reduce-emap (qwr-refl p) = ap reduce p
reduce-emap (qwr-trans qwr₁ qwr₂) = reduce-emap qwr₁ ∙ reduce-emap qwr₂
reduce-emap (qwr-sym qwr) = ! (reduce-emap qwr)
reduce-emap (qwr-cons x qwr) = ap (rw-cons x) (reduce-emap qwr)
reduce-emap (qwr-flip x w) = rw-cons-cons-flip x (reduce w)
to = GroupHom.f ReducedWord-to-FreeGroup
from : QuotWord A → ReducedWord
from = QuotWord-rec reduce reduce-emap
abstract
QuotWordRel-reduce : ∀ w
→ QuotWordRel w (fst (reduce w))
QuotWordRel-reduce nil = qwr-refl idp
QuotWordRel-reduce (x :: w) =
qwr-trans (qwr-cons x (QuotWordRel-reduce w)) $
uncurry (QuotWordRel-cons x) (reduce w)
to-from : ∀ qw → to (from qw) == qw
to-from = QuotWord-elim
(λ w → ! $ quot-rel $ QuotWordRel-reduce w)
(λ _ → prop-has-all-paths-↓)
from-to : ∀ rw → from (to rw) == rw
from-to = Group.unit-r ReducedWord-group
ReducedWord-iso-FreeGroup : ReducedWord-group ≃ᴳ FreeGroup A
ReducedWord-iso-FreeGroup = ReducedWord-to-FreeGroup , is-eq to from to-from from-to
| {
"alphanum_fraction": 0.5450075126,
"avg_line_length": 45.3312693498,
"ext": "agda",
"hexsha": "34b56baaef5ce138bd972500b039348ed916f7a1",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "timjb/HoTT-Agda",
"max_forks_repo_path": "theorems/groups/ReducedWord.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "timjb/HoTT-Agda",
"max_issues_repo_path": "theorems/groups/ReducedWord.agda",
"max_line_length": 108,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "timjb/HoTT-Agda",
"max_stars_repo_path": "theorems/groups/ReducedWord.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 5656,
"size": 14642
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Base definitions for the left-biased universe-sensitive functor and
-- monad instances for the Product type.
--
-- To minimize the universe level of the RawFunctor, we require that
-- elements of B are "lifted" to a copy of B at a higher universe level
-- (a ⊔ b). See the Data.Product.Categorical.Examples for how this is
-- done.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Level
module Data.Product.Categorical.Left.Base
{a} (A : Set a) (b : Level) where
open import Data.Product using (_×_; map₂; proj₁; proj₂; <_,_>)
open import Category.Functor using (RawFunctor)
open import Category.Comonad using (RawComonad)
------------------------------------------------------------------------
-- Definitions
Productₗ : Set (a ⊔ b) → Set (a ⊔ b)
Productₗ B = A × B
functor : RawFunctor Productₗ
functor = record { _<$>_ = λ f → map₂ f }
comonad : RawComonad Productₗ
comonad = record
{ extract = proj₂
; extend = < proj₁ ,_>
}
| {
"alphanum_fraction": 0.5608888889,
"avg_line_length": 29.6052631579,
"ext": "agda",
"hexsha": "c7465d4d443ddad1a65d0f35edd711be31d52dae",
"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/Product/Categorical/Left/Base.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/Product/Categorical/Left/Base.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/Product/Categorical/Left/Base.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": 275,
"size": 1125
} |
module Data.Maybe.Instance where
open import Category.FAM
open import Data.Maybe
open import Function using (_∘_; id)
open import Relation.Binary.PropositionalEquality
instance
MaybeFunctor : ∀ {ℓ} → Functor {ℓ} Maybe
MaybeFunctor {ℓ} = record
{ _<$>_ = map
; isFunctor = record
{ identity = identity
; homo = homo
}
}
where
identity : ∀ {A : Set ℓ} (a : Maybe A) → map id a ≡ a
identity (just x) = refl
identity nothing = refl
homo : ∀ {A B C : Set ℓ} (f : B → C) (g : A → B)
(a : Maybe A) → map (f ∘ g) a ≡ map f (map g a)
homo _ _ (just x) = refl
homo _ _ nothing = refl
MaybeApplicative : ∀ {ℓ} → Applicative {ℓ} Maybe
MaybeApplicative {ℓ} = record
{ pure = just
; _⊛_ = ap
; isApplicative = record
{ identity = identity
; compose = compose
; homo = λ _ _ → refl
; interchange = interchange
}
}
where
open ≡-Reasoning
open import Function
ap : {A B : Set ℓ} → Maybe (A → B) → Maybe A → Maybe B
ap (just f) x = map f x
ap nothing x = nothing
identity : {A : Set ℓ} (x : Maybe A) → map id x ≡ x
identity (just x) = refl
identity nothing = refl
compose : {A B C : Set ℓ} (fs : Maybe (B → C)) (gs : Maybe (A → B))
→ (xs : Maybe A)
→ ap (ap (map _∘′_ fs) gs) xs ≡ ap fs (ap gs xs)
compose {A} {B} {C} (just fs) (just gs) (just xs) = refl
compose {A} {B} {C} (just fs) (just gs) nothing = refl
compose {A} {B} {C} (just fs) nothing (just xs) = refl
compose {A} {B} {C} (just fs) nothing nothing = refl
compose {A} {B} {C} nothing (just gs) (just xs) = refl
compose {A} {B} {C} nothing (just gs) nothing = refl
compose {A} {B} {C} nothing nothing (just xs) = refl
compose {A} {B} {C} nothing nothing nothing = refl
interchange : {A B : Set ℓ} (fs : Maybe (A → B)) (x : A) → ap fs (just x) ≡ ap (just (λ f → f x)) fs
interchange {A} {B} (just f) x = refl
interchange {A} {B} nothing x = refl
| {
"alphanum_fraction": 0.4704142012,
"avg_line_length": 35.8484848485,
"ext": "agda",
"hexsha": "ccac0d822a4460c969100d433711a4f3d659f49b",
"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": "e5e562e4cde2face1f3f5b6d0486c8c56a47b435",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "banacorn/FAM",
"max_forks_repo_path": "src/Data/Maybe/Instance.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e5e562e4cde2face1f3f5b6d0486c8c56a47b435",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "banacorn/FAM",
"max_issues_repo_path": "src/Data/Maybe/Instance.agda",
"max_line_length": 112,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "e5e562e4cde2face1f3f5b6d0486c8c56a47b435",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "banacorn/FAM",
"max_stars_repo_path": "src/Data/Maybe/Instance.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 722,
"size": 2366
} |
open import Coinduction using ( ♭ )
open import Data.Product using ( _,_ )
open import Relation.Binary using ( Poset )
open import Relation.Binary.PropositionalEquality using ( _≡_ ; refl ; sym ; trans ; cong ; subst₂ ) renaming ( setoid to ≡-setoid )
open import System.IO.Transducers using ( _⇒_ ; inp ; out ; done ; ⟦_⟧ ; _≃_ ; _≲_ ; _⟫_ )
open import System.IO.Transducers.Session using ( Session )
open import System.IO.Transducers.Trace using ( Trace ; [] ; _∷_ ; _⊑_ )
open import System.IO.Transducers.Properties.Category using ( ⟫-semantics )
import Relation.Binary.PartialOrderReasoning
module System.IO.Transducers.Properties.TwoCategory where
-- The category is poset-enriched, with order inherited from prefix order on traces.
-- Reflexivity
⊑-refl : ∀ {S} (as : Trace S) → (as ⊑ as)
⊑-refl [] = []
⊑-refl (a ∷ as) = (a ∷ ⊑-refl as)
≡-impl-⊑ : ∀ {S} {as bs : Trace S} → (as ≡ bs) → (as ⊑ bs)
≡-impl-⊑ refl = ⊑-refl _
≲-refl : ∀ {S T} (f : Trace S → Trace T) → (f ≲ f)
≲-refl f as = ⊑-refl (f as)
≃-impl-≲ : ∀ {S T} {f g : Trace S → Trace T} → (f ≃ g) → (f ≲ g)
≃-impl-≲ f≃g as = ≡-impl-⊑ (f≃g as)
-- Transitivity
⊑-trans : ∀ {S} {as bs cs : Trace S} → (as ⊑ bs) → (bs ⊑ cs) → (as ⊑ cs)
⊑-trans [] bs = []
⊑-trans (a ∷ as) (.a ∷ bs) = (a ∷ ⊑-trans as bs)
≲-trans : ∀ {S T} {f g h : Trace S → Trace T} → (f ≲ g) → (g ≲ h) → (f ≲ h)
≲-trans f≲g g≲h as = ⊑-trans (f≲g as) (g≲h as)
-- Antisymmetry
⊑-antisym : ∀ {S} {as bs : Trace S} → (as ⊑ bs) → (bs ⊑ as) → (as ≡ bs)
⊑-antisym [] [] = refl
⊑-antisym (a ∷ as) (.a ∷ bs) = cong (_∷_ a) (⊑-antisym as bs)
≲-antisym : ∀ {S T} {f g : Trace S → Trace T} → (f ≲ g) → (g ≲ f) → (f ≃ g)
≲-antisym f≲g g≲f as = ⊑-antisym (f≲g as) (g≲f as)
-- ⊑ and ≲ form posets
⊑-poset : Session → Poset _ _ _
⊑-poset S = record
{ Carrier = Trace S
; _≈_ = _≡_
; _≤_ = _⊑_
; isPartialOrder = record
{ antisym = ⊑-antisym
; isPreorder = record
{ reflexive = ≡-impl-⊑
; trans = ⊑-trans
; ∼-resp-≈ = ((λ bs≡cs → subst₂ _⊑_ refl bs≡cs) , (λ as≡bs → subst₂ _⊑_ as≡bs refl))
; isEquivalence = Relation.Binary.Setoid.isEquivalence (≡-setoid (Trace S))
}
}
}
≲-poset : Session → Session → Poset _ _ _
≲-poset S T = record
{ Carrier = (Trace S → Trace T)
; _≈_ = _≃_
; _≤_ = _≲_
; isPartialOrder = record
{ antisym = ≲-antisym
; isPreorder = record
{ reflexive = ≃-impl-≲
; trans = ≲-trans
; ∼-resp-≈ = (λ P≃Q P≲R as → subst₂ _⊑_ refl (P≃Q as) (P≲R as)) , λ Q≃R Q≲P as → subst₂ _⊑_ (Q≃R as) refl (Q≲P as)
; isEquivalence = record
{ refl = λ as → refl
; sym = λ P≃Q as → sym (P≃Q as)
; trans = λ P≃Q Q≃R as → trans (P≃Q as) (Q≃R as)
}
}
}
}
-- Inequational reasoning
module ⊑-Reasoning {S} where
open Relation.Binary.PartialOrderReasoning (⊑-poset S) public renaming ( _≤⟨_⟩_ to _⊑⟨_⟩_ ; _≈⟨_⟩_ to _≡⟨_⟩_ )
module ≲-Reasoning {S T} where
open Relation.Binary.PartialOrderReasoning (≲-poset S T) public renaming ( _≤⟨_⟩_ to _≲⟨_⟩_ ; _≈⟨_⟩_ to _≃⟨_⟩_ )
open ⊑-Reasoning
-- Processes are ⊑-monotone
P-monotone : ∀ {S T as bs} → (P : S ⇒ T) → (as ⊑ bs) → (⟦ P ⟧ as ⊑ ⟦ P ⟧ bs)
P-monotone (inp F) [] = []
P-monotone (inp F) (a ∷ as⊑bs) = P-monotone (♭ F a) as⊑bs
P-monotone (out b P) as⊑bs = b ∷ P-monotone P as⊑bs
P-monotone done as⊑bs = as⊑bs
-- Composition is ≲-monotone
⟫-monotone : ∀ {S T U} (P₁ P₂ : S ⇒ T) (Q₁ Q₂ : T ⇒ U) →
(⟦ P₁ ⟧ ≲ ⟦ P₂ ⟧) → (⟦ Q₁ ⟧ ≲ ⟦ Q₂ ⟧) →
(⟦ P₁ ⟫ Q₁ ⟧ ≲ ⟦ P₂ ⟫ Q₂ ⟧)
⟫-monotone P₁ P₂ Q₁ Q₂ P₁≲P₂ Q₁≲Q₂ as =
begin
⟦ P₁ ⟫ Q₁ ⟧ as
≡⟨ ⟫-semantics P₁ Q₁ as ⟩
⟦ Q₁ ⟧ (⟦ P₁ ⟧ as)
⊑⟨ P-monotone Q₁ (P₁≲P₂ as) ⟩
⟦ Q₁ ⟧ (⟦ P₂ ⟧ as)
⊑⟨ Q₁≲Q₂ (⟦ P₂ ⟧ as) ⟩
⟦ Q₂ ⟧ (⟦ P₂ ⟧ as)
≡⟨ sym (⟫-semantics P₂ Q₂ as) ⟩
⟦ P₂ ⟫ Q₂ ⟧ as
∎ | {
"alphanum_fraction": 0.5341891538,
"avg_line_length": 31.5454545455,
"ext": "agda",
"hexsha": "183e8c3791a8f12458e4a0a003ea28dccd84914e",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:23.000Z",
"max_forks_repo_forks_event_min_datetime": "2017-08-10T06:12:54.000Z",
"max_forks_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "ilya-fiveisky/agda-system-io",
"max_forks_repo_path": "src/System/IO/Transducers/Properties/TwoCategory.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "ilya-fiveisky/agda-system-io",
"max_issues_repo_path": "src/System/IO/Transducers/Properties/TwoCategory.agda",
"max_line_length": 132,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "ilya-fiveisky/agda-system-io",
"max_stars_repo_path": "src/System/IO/Transducers/Properties/TwoCategory.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-15T04:35:41.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-04T13:45:16.000Z",
"num_tokens": 1799,
"size": 3817
} |
{-# OPTIONS --without-K --safe #-}
module Source.Size where
open import Util.HoTT.HLevel.Core
open import Util.Prelude
infix 4 _<_
infixl 4 _∙_
mutual
data Ctx : Set where
[] : Ctx
_∙_ : (Δ : Ctx) (n : Size Δ) → Ctx
data Var : (Δ : Ctx) → Set where
zero : ∀ {Δ n} → Var (Δ ∙ n)
suc : ∀ {Δ n} (x : Var Δ) → Var (Δ ∙ n)
data Size : (Δ : Ctx) → Set where
var : ∀ {Δ} (x : Var Δ) → Size Δ
∞ zero : ∀ {Δ} → Size Δ
suc : ∀ {Δ} (n : Size Δ) → Size Δ
pattern ⋆ = suc ∞
variable
Δ Ω Δ′ Ω′ Δ″ Ω″ : Ctx
x y z : Var Δ
n m o p b n′ m′ o′ p′ b′ : Size Δ
wk : Size Δ → Size (Δ ∙ n)
wk (var x) = var (suc x)
wk ∞ = ∞
wk zero = zero
wk (suc m) = suc (wk m)
bound : Var Δ → Size Δ
bound (zero {Δ} {n}) = wk n
bound (suc x) = wk (bound x)
data _<_ {Δ} : (n m : Size Δ) → Set where
var : n ≡ bound x → var x < n
zero<suc : zero < suc n
zero<∞ : zero < ∞
suc<suc : (n<m : n < m) → suc n < suc m
suc<∞ : (n<∞ : n < ∞) → suc n < ∞
<-trans : n < m → m < o → n < o
<suc : n < suc n
data _≤_ {Δ} : (n m : Size Δ) → Set where
reflexive : n ≡ m → n ≤ m
<→≤ : n < m → n ≤ m
pattern ≤-refl = reflexive refl
pattern v0 = var zero
pattern v1 = var (suc zero)
pattern v2 = var (suc (suc zero))
abstract
n<m→n<Sm : n < m → n < suc m
n<m→n<Sm n<m = <-trans n<m <suc
n≤m→n<Sm : n ≤ m → n < suc m
n≤m→n<Sm ≤-refl = <suc
n≤m→n<Sm (<→≤ n<m) = n<m→n<Sm n<m
var<suc : var x ≤ n → var x < suc n
var<suc = n≤m→n<Sm
∞<suc : ∞ ≤ n → ∞ < suc n
∞<suc = n≤m→n<Sm
Sn<m→n<m : suc n < m → n < m
Sn<m→n<m (suc<suc n<m) = <-trans n<m <suc
Sn<m→n<m (suc<∞ n<∞) = n<∞
Sn<m→n<m (<-trans Sn<o o<m) = <-trans (Sn<m→n<m Sn<o) o<m
Sn<m→n<m <suc = <-trans <suc (suc<suc <suc)
suc-inj-Var : Var.suc {n = n} x ≡ suc y → x ≡ y
suc-inj-Var refl = refl
suc≡-prop-Var : (p : Var.suc {n = n} x ≡ suc y) → p ≡ cong suc (suc-inj-Var p)
suc≡-prop-Var refl = refl
Var-IsSet : (p q : x ≡ y) → p ≡ q
Var-IsSet {x = zero} {zero} refl refl = refl
Var-IsSet {x = suc x} {suc .x} p refl
= trans (suc≡-prop-Var p) (cong (cong suc) (Var-IsSet _ _))
suc-inj-Size : Size.suc n ≡ suc m → n ≡ m
suc-inj-Size refl = refl
suc≡-prop-Size : (p : Size.suc n ≡ suc m) → p ≡ cong suc (suc-inj-Size p)
suc≡-prop-Size refl = refl
var-inj-Size : Size.var x ≡ var y → x ≡ y
var-inj-Size refl = refl
var≡-prop-Size : (p : Size.var x ≡ var y) → p ≡ cong var (var-inj-Size p)
var≡-prop-Size refl = refl
Size-IsSet : (p q : n ≡ m) → p ≡ q
Size-IsSet {n = var x} {var .x} p refl
= trans (var≡-prop-Size p) (cong (cong var) (Var-IsSet _ _))
Size-IsSet {n = ∞} {∞} refl refl = refl
Size-IsSet {n = zero} {zero} refl refl = refl
Size-IsSet {n = suc n} {suc .n} p refl
= trans (suc≡-prop-Size p) (cong (cong suc) (Size-IsSet _ _))
wk-resp-< : n < m → wk {n = o} n < wk m
wk-resp-< (var p) = var (cong wk p)
wk-resp-< zero<suc = zero<suc
wk-resp-< zero<∞ = zero<∞
wk-resp-< (suc<suc n<m) = suc<suc (wk-resp-< n<m)
wk-resp-< (suc<∞ n<∞) = suc<∞ (wk-resp-< n<∞)
wk-resp-< (<-trans n<o o<m) = <-trans (wk-resp-< n<o) (wk-resp-< o<m)
wk-resp-< <suc = <suc
| {
"alphanum_fraction": 0.5095117311,
"avg_line_length": 21.9027777778,
"ext": "agda",
"hexsha": "97ae124dfa8cd9156e4ff165caec24cbc09e1641",
"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": "104cddc6b65386c7e121c13db417aebfd4b7a863",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "JLimperg/msc-thesis-code",
"max_forks_repo_path": "src/Source/Size.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "JLimperg/msc-thesis-code",
"max_issues_repo_path": "src/Source/Size.agda",
"max_line_length": 80,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "JLimperg/msc-thesis-code",
"max_stars_repo_path": "src/Source/Size.agda",
"max_stars_repo_stars_event_max_datetime": "2021-06-26T06:37:31.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-04-13T21:31:17.000Z",
"num_tokens": 1513,
"size": 3154
} |
module Prelude where
open import Agda.Primitive using (Level; lzero; lsuc) renaming (_⊔_ to lmax)
-- empty type
data ⊥ : Set where
-- from false, derive whatever
abort : ∀ {C : Set} → ⊥ → C
abort ()
-- unit
data ⊤ : Set where
<> : ⊤
-- sums
data _+_ (A B : Set) : Set where
Inl : A → A + B
Inr : B → A + B
-- pairs
infixr 1 _,_
record Σ {l1 l2 : Level} (A : Set l1) (B : A → Set l2) : Set (lmax l1 l2) where
constructor _,_
field
π1 : A
π2 : B π1
open Σ public
syntax Σ A (\ x -> B) = Σ[ x ∈ A ] B
_×_ : {l1 : Level} {l2 : Level} → (Set l1) → (Set l2) → Set (lmax l1 l2)
A × B = Σ A λ _ → B
infixr 1 _×_
-- equality
data _==_ {l : Level} {A : Set l} (M : A) : A → Set l where
refl : M == M
infixr 9 _==_
{-# BUILTIN EQUALITY _==_ #-}
{-# BUILTIN REFL refl #-}
_·_ : {l : Level} {α : Set l} {x y z : α} → x == y → y == z → x == z
refl · refl = refl
-- β: ! (refl m) == refl m
! : {l : Level} {α : Set l} {x y : α} → x == y → y == x
! refl = refl
-- β: (ap f (refl m)) == refl (f m)
ap1 : {l1 l2 : Level} {α : Set l1} {β : Set l2} {x y : α} (F : α → β)
→ x == y → F x == F y
ap1 F refl = refl
-- β? : tr β (refl x) y == y
tr : {l1 l2 : Level} {α : Set l1} {x y : α}
(B : α → Set l2)
→ x == y
→ B x
→ B y
tr B refl x₁ = x₁
ap2 : {l1 l2 l3 : Level}
{A : Set l1} {B : Set l2} {C : Set l3}
{M N : A} {M' N' : B}
(f : A -> B -> C) -> M == N -> M' == N' -> (f M M') == (f N N')
ap2 f refl refl = refl
infix 2 _■
infixr 2 _=<_>_
_=<_>_ : {l : Level} {A : Set l} (x : A) {y z : A} → x == y → y == z → x == z
_ =< p1 > p2 = p1 · p2
_■ : {l : Level} {A : Set l} (x : A) → x == x
_■ _ = refl
-- options
data Maybe (A : Set) : Set where
Some : A → Maybe A
None : Maybe A
-- the some constructor is injective. perhaps unsurprisingly.
someinj : {A : Set} {x y : A} → Some x == Some y → x == y
someinj refl = refl
-- order
data Order : Set where
Less : Order
Equal : Order
Greater : Order
-- function extensionality
postulate
funext : {A : Set} {B : A → Set} {f g : (x : A) → (B x)} →
((x : A) → f x == g x) → f == g
| {
"alphanum_fraction": 0.439119171,
"avg_line_length": 23.3939393939,
"ext": "agda",
"hexsha": "5abd644c2f7c6271978f3ee85febab6fef311341",
"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": "86a755ca6749e080f9a03287e34d1cda889f1edb",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "ivoysey/agda-tfp16",
"max_forks_repo_path": "Prelude.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "86a755ca6749e080f9a03287e34d1cda889f1edb",
"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": "ivoysey/agda-tfp16",
"max_issues_repo_path": "Prelude.agda",
"max_line_length": 81,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "86a755ca6749e080f9a03287e34d1cda889f1edb",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "ivoysey/agda-tfp16",
"max_stars_repo_path": "Prelude.agda",
"max_stars_repo_stars_event_max_datetime": "2016-04-14T02:19:58.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-04-09T13:35:22.000Z",
"num_tokens": 960,
"size": 2316
} |
{-# OPTIONS --universe-polymorphism #-}
module Categories.Monoidal.Cartesian.Pentagon where
open import Categories.Support.PropositionalEquality using (_≣_; ≣-refl)
open import Categories.Category using (Category; module Category)
open import Categories.Object.BinaryProducts
open import Categories.Square
module Law {o ℓ e} (C : Category o ℓ e) (P : BinaryProducts C) where
open Category C
open BinaryProducts P
shave3ˡ : ∀ {A B C} → ((A × B) × C) ⇒ (B × C)
shave3ˡ = ⟨ π₂ ∘ π₁ , π₂ ⟩ -- in real life, 'first π₂'
shave4ˡʳ : ∀ {A B C D} → (((A × B) × C) × D) ⇒ (B × C)
shave4ˡʳ = ⟨ (π₂ ∘ π₁) ∘ π₁ , π₂ ∘ π₁ ⟩
shave4ˡ : ∀ {A B C D} → (((A × B) × C) × D) ⇒ ((B × C) × D)
shave4ˡ = ⟨ shave4ˡʳ , π₂ ⟩
.π₁∘assocˡ : ∀ {X Y Z} → π₁ ∘ assocˡ {X} {Y} {Z} ≡ π₁ ∘ π₁
π₁∘assocˡ = commute₁
.π₂∘assocˡ : ∀ {X Y Z} → π₂ ∘ assocˡ {X} {Y} {Z} ≡ shave3ˡ
π₂∘assocˡ = commute₂
.π₂₁-assocˡ : ∀ {X Y Z W} → (π₂ ∘ π₁) ∘ assocˡ {X × Y} {Z} {W} ≡ (π₂ ∘ π₁) ∘ π₁
π₂₁-assocˡ =
begin
(π₂ ∘ π₁) ∘ assocˡ
↓⟨ assoc ⟩
π₂ ∘ (π₁ ∘ assocˡ)
↓⟨ ∘-resp-≡ʳ π₁∘assocˡ ⟩
π₂ ∘ (π₁ ∘ π₁)
↑⟨ assoc ⟩
(π₂ ∘ π₁) ∘ π₁
∎
where
open HomReasoning
.π₁₁-assocˡ : ∀ {X Y Z W} → (π₁ ∘ π₁) ∘ assocˡ {_} {Z} {W} ≡ (π₁ ∘ π₁) ∘ first (assocˡ {X} {Y} {Z})
π₁₁-assocˡ =
begin
(π₁ ∘ π₁) ∘ assocˡ
↓⟨ glue (sym π₁∘assocˡ) π₁∘assocˡ ⟩
π₁ ∘ (assocˡ ∘ π₁)
↑⟨ ∘-resp-≡ʳ π₁∘⁂ ⟩
π₁ ∘ (π₁ ∘ first assocˡ)
↑⟨ assoc ⟩
(π₁ ∘ π₁) ∘ first assocˡ
∎
where
open HomReasoning {_} {_}
open Equiv
open GlueSquares C
.π₁∘shave4ˡʳ : ∀ {A B C D} → π₁ ∘ shave4ˡʳ {A} {B} {C} {D} ≡ (π₂ ∘ π₁) ∘ π₁
π₁∘shave4ˡʳ = commute₁
.π₂∘shave4ˡʳ : ∀ {A B C D} → π₂ ∘ shave4ˡʳ {A} {B} {C} {D} ≡ π₂ ∘ π₁
π₂∘shave4ˡʳ = commute₂
.shave3ˡ∘π₁ : ∀ {A B C D} → shave3ˡ ∘ π₁ ≡ shave4ˡʳ {A} {B} {C} {D}
shave3ˡ∘π₁ = ⟨⟩∘
.π₁∘shave4ˡ : ∀ {A B C D} → π₁ ∘ shave4ˡ ≡ shave4ˡʳ {A} {B} {C} {D}
π₁∘shave4ˡ = commute₁
.π₂∘shave4ˡ : ∀ {A B C D} → π₂ ∘ shave4ˡ {A} {B} {C} {D} ≡ π₂
π₂∘shave4ˡ = commute₂
private
infix 3 ⟨_⟩,⟨_⟩
.⟨_⟩,⟨_⟩ : ∀ {A B C} → {f f′ : A ⇒ B} {g g′ : A ⇒ C} → f ≡ f′ → g ≡ g′ → ⟨ f , g ⟩ ≡ ⟨ f′ , g′ ⟩
⟨_⟩,⟨_⟩ x y = ⟨⟩-cong₂ x y
.shave3ˡ∘assocˡ : ∀ {X Y Z W} → shave3ˡ ∘ assocˡ ≡ assocˡ ∘ shave4ˡ {X} {Y} {Z} {W}
shave3ˡ∘assocˡ =
begin
shave3ˡ ∘ assocˡ
↓⟨ ⟨⟩∘ ⟩
⟨ (π₂ ∘ π₁) ∘ assocˡ , π₂ ∘ assocˡ ⟩
↓⟨ ⟨ π₂₁-assocˡ ⟩,⟨ π₂∘assocˡ ⟩ ⟩
⟨ (π₂ ∘ π₁) ∘ π₁ , shave3ˡ ⟩
↑⟨ ⟨ π₁∘shave4ˡʳ ⟩,⟨ ⟨⟩-congˡ π₂∘shave4ˡʳ ⟩ ⟩
⟨ π₁ ∘ shave4ˡʳ , ⟨ π₂ ∘ shave4ˡʳ , π₂ ⟩ ⟩
↑⟨ ⟨ ∘-resp-≡ʳ π₁∘shave4ˡ ⟩,⟨ ⟨ ∘-resp-≡ʳ π₁∘shave4ˡ ⟩,⟨ π₂∘shave4ˡ ⟩ ⟩ ⟩
⟨ π₁ ∘ (π₁ ∘ shave4ˡ) , ⟨ π₂ ∘ (π₁ ∘ shave4ˡ) , π₂ ∘ shave4ˡ ⟩ ⟩
↑⟨ ⟨ assoc ⟩,⟨ ⟨⟩-congˡ assoc ⟩ ⟩
⟨ (π₁ ∘ π₁) ∘ shave4ˡ , ⟨ (π₂ ∘ π₁) ∘ shave4ˡ , π₂ ∘ shave4ˡ ⟩ ⟩
↑⟨ ⟨⟩-congʳ ⟨⟩∘ ⟩
⟨ (π₁ ∘ π₁) ∘ shave4ˡ , ⟨ π₂ ∘ π₁ , π₂ ⟩ ∘ shave4ˡ ⟩
↑⟨ ⟨⟩∘ ⟩
assocˡ ∘ shave4ˡ
∎
where
open HomReasoning
open Equiv
.shave3ˡ∘first-assocˡ : ∀ {X Y Z W} → shave3ˡ ∘ first assocˡ ≡ shave4ˡ {X} {Y} {Z} {W}
shave3ˡ∘first-assocˡ =
begin
shave3ˡ ∘ first assocˡ
↓⟨ ⟨⟩∘ ⟩
⟨ (π₂ ∘ π₁) ∘ first assocˡ , π₂ ∘ first assocˡ ⟩
↓⟨ ⟨ glue◃◽ π₂∘assocˡ π₁∘⁂ ⟩,⟨ π₂∘⁂ ⟩ ⟩
⟨ shave3ˡ ∘ π₁ , id ∘ π₂ ⟩
↓⟨ ⟨ shave3ˡ∘π₁ ⟩,⟨ identityˡ ⟩ ⟩
shave4ˡ
∎
where
open HomReasoning
open Equiv
open GlueSquares C
.pentagon : ∀ {X Y Z W} → assocˡ {X} {Y} ∘ assocˡ ≡ second (assocˡ {Y} {Z} {W}) ∘ (assocˡ ∘ first (assocˡ {X}))
pentagon =
begin
assocˡ ∘ assocˡ
↓⟨ ⟨⟩∘ ⟩
⟨ (π₁ ∘ π₁) ∘ assocˡ , shave3ˡ ∘ assocˡ ⟩
↓⟨ ⟨⟩-congʳ shave3ˡ∘assocˡ ⟩
⟨ (π₁ ∘ π₁) ∘ assocˡ , assocˡ ∘ shave4ˡ ⟩
↑⟨ ⟨ sym π₁₁-assocˡ ⟩,⟨ ∘-resp-≡ʳ shave3ˡ∘first-assocˡ ⟩ ⟩
⟨ (π₁ ∘ π₁) ∘ first assocˡ , assocˡ ∘ (shave3ˡ ∘ first assocˡ) ⟩
↑⟨ ⟨ ∘-resp-≡ˡ identityˡ ⟩,⟨ assoc ⟩ ⟩
⟨ (id ∘ (π₁ ∘ π₁)) ∘ first assocˡ , (assocˡ ∘ shave3ˡ) ∘ first assocˡ ⟩
↑⟨ ⟨⟩∘ ⟩
⟨ id ∘ (π₁ ∘ π₁) , assocˡ ∘ shave3ˡ ⟩ ∘ first assocˡ
↑⟨ ∘-resp-≡ˡ ⁂∘⟨⟩ ⟩
(second assocˡ ∘ assocˡ) ∘ first assocˡ
↓⟨ assoc ⟩
second assocˡ ∘ (assocˡ ∘ first assocˡ)
∎
where
open HomReasoning
open Equiv
| {
"alphanum_fraction": 0.4962616822,
"avg_line_length": 30.7913669065,
"ext": "agda",
"hexsha": "5f42810b097fd46bde3c8bcbbbc47b48a089a10c",
"lang": "Agda",
"max_forks_count": 23,
"max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z",
"max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "p-pavel/categories",
"max_forks_repo_path": "Categories/Monoidal/Cartesian/Pentagon.agda",
"max_issues_count": 19,
"max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2",
"max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "p-pavel/categories",
"max_issues_repo_path": "Categories/Monoidal/Cartesian/Pentagon.agda",
"max_line_length": 113,
"max_stars_count": 98,
"max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "copumpkin/categories",
"max_stars_repo_path": "Categories/Monoidal/Cartesian/Pentagon.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z",
"num_tokens": 2411,
"size": 4280
} |
module Data.Vec.Membership.Propositional.Disjoint where
open import Data.Vec
open import Data.Vec.Membership.Propositional
open import Relation.Binary.PropositionalEquality as P using (_≡_; _≢_)
open import Data.Empty using (⊥; ⊥-elim)
open import Function using (flip)
Disjoint : ∀ {a} {A : Set a} {n m} → Vec A n → Vec A m → Set a
Disjoint xs ys = ∀ {x} → x ∈ xs → x ∈ ys → ⊥
disjoint-sim : ∀ {a} {A : Set a} {n m} {xs : Vec A n}{ys : Vec A m} → Disjoint xs ys → Disjoint ys xs
disjoint-sim dis = flip dis
disjoint-[]ˡ : ∀ {a} {A : Set a} {n} {xs : Vec A n} → Disjoint [] xs
disjoint-[]ˡ ()
disjoint-[]ʳ : ∀ {a} {A : Set a} {n} {xs : Vec A n} → Disjoint xs []
disjoint-[]ʳ = disjoint-sim disjoint-[]ˡ
disjointness : ∀ {a} {A : Set a} {n m} {xs : Vec A n}{ys : Vec A m} → Disjoint xs ys →
∀ {x y} → x ∈ xs → y ∈ ys → x ≢ y
disjointness dis x∈xs y∈ys x≡y rewrite x≡y = dis x∈xs y∈ys
| {
"alphanum_fraction": 0.6013215859,
"avg_line_length": 39.4782608696,
"ext": "agda",
"hexsha": "490cc02b8056f4ea15a45c350da21c292fecf23c",
"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/Vec/Membership/Propositional/Disjoint.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/Vec/Membership/Propositional/Disjoint.agda",
"max_line_length": 102,
"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/Vec/Membership/Propositional/Disjoint.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 355,
"size": 908
} |
module Formalization.SimplyTypedLambdaCalculus where
import Lvl
open import Numeral.Natural
open import Type as _ using (TYPE)
data Type (B : TYPE) : TYPE₁ where
Base : B → Type(B)
Function : Type(B) → Type(B) → Type(B)
data Term (B : TYPE) : TYPE₁ where
Apply : Term(B) → Term(B) → Term(B)
Abstract : Type(B) → Term(B) → Term(B)
Var : ℕ → Term(B)
Const : B → Term(B)
module _ {B} where
data _⊢_::_ (Γ : Term(B) → Type(B) → TYPE) : Term(B) → Type(B) → TYPE₁ where
intro : ∀{a}{T} → Γ(a)(T) → (Γ ⊢ a :: T)
-- const : ∀{a}{T} → Γ(a)(T) → (Γ ⊢ a :: T)
abstr : ∀{body}{A B} → (Γ ⊢ body :: B) → (Γ ⊢ Abstract A body :: Function A B)
apply : ∀{f x}{A B} → (Γ ⊢ f :: Function A B) → (Γ ⊢ x :: A) → (Γ ⊢ Apply f x :: B)
{-
A,B ::= Base | A ⟶ B
t ::= k | t t | λ t | Const b
b = true | false
Γ ⊢ Const b : Base
v ::= Const b | λ t
(⊢ t : Base) → ∃ v t ⟶* v
(⊢ t : A) → ∃ v t ⟶* v
Red(A)(t) definition "to be reducible"
Red(Base)(t) = ∃v(t ⟶* v)
Red(A→B)(t) = ∀u. Red(A)(u) → Red(B)(t u)
(t ⟶ t') → Red(A)(t') → Red(A)(t)
• A = Base:
∃v(t* ⟶* v) → ∃v(t ⟶* v)
t → t' ⟶* v
• A = B→C:
∀u. Red(B)(u) → Red(C)(t' u)
to show ∀u. Red(B)(u) → Red(C)(t u)
and just use induction on the first thing mentioned
Red(C)(t' u)
to get
Red(C)(t u)
data ⟶β : Set where
red1 : t ⟶β u
red2 : (λ t) u ⟶β substitute t u
red3 : (t ⟶β t') → ((t u) ⟶β (t' u))
red4 : (u ⟶β u') → (t u ⟶β t u')
⟶β-confluent : Confluent (_⟶β_)
module CallByName where
data ⟶β : Set where
red2 : (λ t) u ⟶β substitute t u
red3 : (t ⟶β t') → ((t u) ⟶β (t' u))
substitute-preservation : (Γ ⊢ ((λ u) u' : A)) → (Γ ⊢ (substitute u u' : A))
β⟶-preservation : (Γ ⊢ (t : A)) → (t ⟶β t') → (Γ ⊢ (t' : A))
Red(Γ)(σ)
Γ = () | Γ.A -- context
σ : ℕ → Term
∀k. Γ ⊢ k : A
Represent variable as a context
σ is a formal definition of "reducible" substitution
Example:
Γ.A ⊢ 0 : A
Γ.A.B ⊢ 1 : A
σ-substitution?:
Red(Γ)(σ) ∧ (Γ ⊢ t:A) → Red(A)(t σ)
Proof by induction on t
• t = Ref k
Red(A)(k σ) = Red(A)(σ(k))
• t = t₀ t₁
t_σ = (t₀ σ) (t₁ σ)
Γ ⊢ t₀ : B → A
Γ ⊢ t₁ : B
by induction hypothesis:
Red(B→A)(t₀ σ)
Red(B)(t₁ σ)
so Red(A)(t₀ σ)(t₁ σ)
• t = λ u
A = B → C
Γ.B ⊢ u : C
To show: Red(B→C)((λ u) σ)
it means: ∀ u',Red(B)(u'), show Red(C)((λv) σ u')
Define:
(_,_) : (σ : ℕ → Term) (u' : Term) : ℕ → Term
(σ,u')(0) = u'
(σ,u')(𝐒 n) = σ(n)
Claim: (λu) σ u' ⟶ u(σ,u')
Γ.B ⊢ (k : T) → Red(T)((σ,u') k)
k=0: Γ.B ⊢ 0
k=n+1 (Γ ⊢ u : T) → (Γ ,B ⊢ n+1 : T)
Summary:
This is all to prove ∃v(t ⟶* v) if ⊢ t : Base, which is Red(A)(t)?
Direct proof for application.
Generalize the statement to: (⊢ t : A) → Red(A)(t)
and then to: (Γ ⊢ t:A) → Red(Γ)(σ) → Red(A)(t σ)
Something else: Krivine abstract machine
How to evaluate λ-terms without substitution (defined before LISP eval with substitution)
Term: k | tt | λ t
Closure: t, ρ -- note: first mention of closure in this field? (denoted u v,‥)
Environment: list of closures
Stack: list of closures in stack order (denoted S)
3 components: Term t,ENv ρ, Stack S → Term Env STack
t₁ | ρ₁ | S₁ | t₂ | ρ₂ | S₂
λ t | ρ | u : S | t | (ρ,u) | S
t₀t1 | ρ | S | t₀ | ρ | (t₁,ρ) : S
0 | ρ,(t,ρ') | S | t | ρ' | S
k+1 | ρ,(t,p') | S | k | ρ | S
Those are the transformations/reductions of the machine.
Simplified description of how functional programs are evaluated.
-}
| {
"alphanum_fraction": 0.5095906098,
"avg_line_length": 27.5039370079,
"ext": "agda",
"hexsha": "d51a284b105d72f00f8ef0bf00f18cfe26986a7a",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Formalization/SimplyTypedLambdaCalculus.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Formalization/SimplyTypedLambdaCalculus.agda",
"max_line_length": 91,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Formalization/SimplyTypedLambdaCalculus.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": 1503,
"size": 3493
} |
module _ where
open import Common.Prelude
open import Common.Equality
primitive primForce : ∀ {a b} {A : Set a} {B : A → Set b} (x : A) → (∀ x → B x) → B x
force = primForce
not-stuck : (b : Bool) → force b not ≡ not b
not-stuck true = refl
not-stuck false = refl
stuck : (b : Bool) → force b not ≡ not b
stuck b = refl
| {
"alphanum_fraction": 0.6226993865,
"avg_line_length": 19.1764705882,
"ext": "agda",
"hexsha": "5d57efd570aec5e81f3887db8ce892d1cefbab93",
"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/PrimSeq.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/PrimSeq.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": "test/Fail/PrimSeq.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": 117,
"size": 326
} |
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
{- Useful lemmas for computing the effect of transporting a function
- across an equivalence in the domain or codomain.
- TODO move these lemmas into lib.types.Pi or lib.types.PointedPi -}
-- XXX Naming convensions?
module stash.homotopy.FunctionOver where
{- transporting a ptd function along a equivalence or path in the domain -}
module _ {i} {j} {Y : Ptd i} {Z : Ptd j} (g : Y ⊙→ Z) where
domain-over-⊙path : {X : Ptd i} (p : de⊙ X == de⊙ Y)
(q : coe p (pt X) == pt Y)
→ g ⊙∘ (coe p , q) == g [ (λ W → W ⊙→ Z) ↓ ptd= p (↓-idf-in p q) ]
domain-over-⊙path idp idp = idp
domain-over-⊙equiv : {X : Ptd i} (e : X ⊙≃ Y)
→ g ⊙∘ ⊙–> e == g [ (λ W → W ⊙→ Z) ↓ ⊙ua e ]
domain-over-⊙equiv {X = X} e =
ap (λ w → g ⊙∘ w) (! $ ⊙λ= (coe-β (⊙≃-to-≃ e)) (↓-idf=cst-in idp))
◃ domain-over-⊙path (ua (⊙≃-to-≃ e))
(coe-β (⊙≃-to-≃ e) (pt X) ∙ snd (⊙–> e))
module _ {i} {j} {X : Ptd i} {Z : Ptd j} (f : X ⊙→ Z) where
domain!-over-⊙path : {Y : Ptd i} (p : de⊙ X == de⊙ Y)
(q : coe p (pt X) == pt Y)
→ f == f ⊙∘ (coe! p , ap (coe! p) (! q) ∙ coe!-inv-l p (pt X))
[ (λ W → W ⊙→ Z) ↓ ptd= p (↓-idf-in p q) ]
domain!-over-⊙path idp idp = idp
domain!-over-⊙equiv : {Y : Ptd i} (e : X ⊙≃ Y)
→ f == f ⊙∘ (⊙<– e) [ (λ W → W ⊙→ Z) ↓ ⊙ua e ]
domain!-over-⊙equiv {Y = Y} e =
(! (ap (λ w → f ⊙∘ w) (⊙<–-inv-l e)) ∙ ! (⊙∘-assoc f _ (⊙–> e)))
◃ domain-over-⊙equiv (f ⊙∘ (⊙<– e)) e
{- transporting a ptd function along a equivalence or path in the codomain -}
module _ {i} {j} {X : Ptd i} {Y : Ptd j} (f : X ⊙→ Y) where
codomain-over-⊙path : {Z : Ptd j} (p : de⊙ Y == de⊙ Z)
(q : coe p (pt Y) == pt Z)
→ f == (coe p , q) ⊙∘ f [ (λ W → X ⊙→ W) ↓ ptd= p (↓-idf-in p q) ]
codomain-over-⊙path idp idp = pair= idp (! (∙-unit-r _ ∙ ap-idf (snd f)))
codomain-over-⊙equiv : {Z : Ptd j} (e : Y ⊙≃ Z)
→ f == (⊙–> e) ⊙∘ f [ (λ W → X ⊙→ W) ↓ ⊙ua e ]
codomain-over-⊙equiv {Z = Z} e =
codomain-over-⊙path (ua (⊙≃-to-≃ e))
(coe-β (⊙≃-to-≃ e) (pt Y) ∙ snd (⊙–> e))
▹ ap (λ w → w ⊙∘ f) (⊙λ= (coe-β (⊙≃-to-≃ e)) (↓-idf=cst-in idp))
module _ {i} {j} {X : Ptd i} {Z : Ptd j} (g : X ⊙→ Z) where
codomain!-over-⊙path : {Y : Ptd j} (p : de⊙ Y == de⊙ Z)
(q : coe p (pt Y) == pt Z)
→ (coe! p , ap (coe! p) (! q) ∙ coe!-inv-l p (pt Y)) ⊙∘ g == g
[ (λ W → X ⊙→ W) ↓ ptd= p (↓-idf-in p q) ]
codomain!-over-⊙path idp idp = pair= idp (∙-unit-r _ ∙ ap-idf (snd g))
codomain!-over-⊙equiv : {Y : Ptd j} (e : Y ⊙≃ Z)
→ (⊙<– e) ⊙∘ g == g [ (λ W → X ⊙→ W) ↓ ⊙ua e ]
codomain!-over-⊙equiv {Y = Y} e =
codomain-over-⊙equiv (⊙<– e ⊙∘ g) e
▹ ! (⊙∘-assoc (⊙–> e) _ g) ∙ ap (λ w → w ⊙∘ g) (⊙<–-inv-r e) ∙ ⊙∘-unit-l g
{- transporting a group homomorphism along an isomorphism -}
domain-over-iso : ∀ {i j} {G H : Group i} {K : Group j}
{φ : G →ᴳ H} {ie : is-equiv (GroupHom.f φ)} {ψ : G →ᴳ K} {χ : H →ᴳ K}
→ GroupHom.f ψ == GroupHom.f χ
[ (λ A → A → Group.El K) ↓ ua (GroupHom.f φ , ie) ]
→ ψ == χ [ (λ J → J →ᴳ K) ↓ uaᴳ (φ , ie) ]
domain-over-iso {K = K} {φ = φ} {ie} {ψ} {χ} p =
group-hom=-↓ $ ↓-ap-out _ Group.El _ $
transport
(λ q → GroupHom.f ψ == GroupHom.f χ [ (λ A → A → Group.El K) ↓ q ])
(! (El=-β (φ , ie)))
p
codomain-over-iso : ∀ {i j} {G : Group i} {H K : Group j}
{φ : H →ᴳ K} {ie : is-equiv (GroupHom.f φ)} {ψ : G →ᴳ H} {χ : G →ᴳ K}
→ GroupHom.f ψ == GroupHom.f χ
[ (λ A → Group.El G → A) ↓ ua (GroupHom.f φ , ie) ]
→ ψ == χ [ (λ J → G →ᴳ J) ↓ uaᴳ (φ , ie) ]
codomain-over-iso {G = G} {φ = φ} {ie} {ψ} {χ} p =
group-hom=-↓ $ ↓-ap-out _ Group.El _ $
transport
(λ q → GroupHom.f ψ == GroupHom.f χ [ (λ A → Group.El G → A) ↓ q ])
(! (El=-β (φ , ie)))
p
| {
"alphanum_fraction": 0.4662090813,
"avg_line_length": 39.4583333333,
"ext": "agda",
"hexsha": "3cb460e53fc8f712970094746760d6121d2f75b5",
"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/homotopy/FunctionOver.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/homotopy/FunctionOver.agda",
"max_line_length": 78,
"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/homotopy/FunctionOver.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": 1869,
"size": 3788
} |
-- Example by Simon Huber
{-# OPTIONS --cubical-compatible #-}
data _≡_ {A : Set} (a : A) : A → Set where
refl : a ≡ a
ap : {A B : Set} (f : A → B) {a b : A} (p : a ≡ b) → f a ≡ f b
ap f refl = refl
-- \bub
_•_ : {A : Set} {a b c : A} → a ≡ b → b ≡ c → a ≡ c
p • refl = p
infixr 30 _•_
! : {A : Set} {a b : A} → a ≡ b → b ≡ a
! refl = refl
-- \. (NB: not • aka \bub)
_∙_ : {A : Set} {B : A → Set}
{f g : (a : A) → B a} →
f ≡ g →
(x : A) → f x ≡ g x
refl ∙ x = refl
infix 30 _∙_
dotap : {A B : Set} {f g : A → B}
(p : f ≡ g) (x : A)
→ p ∙ x ≡ ap (λ F → F x) p
dotap refl x = refl
apcomp : {A B C : Set} (f : B → C) (g : A → B)
{x y : A} (p : x ≡ y)
→ ap (λ a → f (g a)) p ≡ ap f (ap g p)
apcomp f g refl = refl
-- combinators for equality reasoning
_≡⟨_⟩_ : {A : Set} (x : A) {y z : A} → x ≡ y → y ≡ z → x ≡ z
x ≡⟨ p ⟩ q = p • q
infixr 2 _≡⟨_⟩_
_□ : {A : Set} (x : A) → x ≡ x
x □ = refl
module Wrong (A B : Set) (a0 : A) where
const : B → (A → B)
const = λ x _ → x
to : {x y : B} → x ≡ y → const x ≡ const y
to = ap const
from : {x y : B} → const x ≡ const y → x ≡ y
from = ap (λ F → F a0)
-- This lemma should not typecheck:
lem : {x y : B} (p : const x ≡ const y) (a : A)
→ p ∙ a ≡ to (from p) ∙ a
lem p a = p ∙ a
≡⟨ dotap p a ⟩
ap (λ F → F a) p
≡⟨ refl ⟩
ap (λ F → const (F a) a) p
≡⟨ apcomp _ _ p ⟩
ap (λ G → G a) (ap (λ F → const (F a)) p)
≡⟨ ap (ap (λ G → G a)) (apcomp const (λ F → F a) p) ⟩
ap(λ G → G a) (ap const (ap (λ (F : A → B) → F a) p))
≡⟨ ! (dotap (ap const (ap (λ F → F a) p)) a) ⟩
(to (from p) ∙ a) □
| {
"alphanum_fraction": 0.3937644342,
"avg_line_length": 24.0555555556,
"ext": "agda",
"hexsha": "17431420bf8f568fa5243e34d5552f66f4f8c9a3",
"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/Issue2480.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/Issue2480.agda",
"max_line_length": 65,
"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/Issue2480.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 821,
"size": 1732
} |
-- Andreas, 2016-01-22
-- special size checking j : Size< i |- j : Size< ↑ j
-- was missing from checkInternal
-- {-# OPTIONS -v tc.polarity:10 #-}
-- {-# OPTIONS -v tc.with.type:50 #-}
-- {-# OPTIONS -v tc.check.internal:30 -v tc.infer.internal:30 #-}
open import Common.Unit
open import Common.Size
postulate
axiom : Unit
anything : ∀{A : Set} → A
-- An inductive-coinductive unit type.
mutual
record IC i : Set where
coinductive
field force : ∀(j : Size< i) → IC' j
data IC' i : Set where
cons : (xs : IC i) → IC' i -- necessary
-- The recursive identity on IC.
mutual
idIC : ∀ i (p : IC i) → IC i
IC.force (idIC i p) j = idIC' (↑ j) j (IC.force p j)
-- (↑ j) is triggering the error
-- if we write i here, things work
idIC' : ∀ i (j : Size< i) (p : IC' j) → IC' j
idIC' i j (cons p) = cons (idIC j p)
-- An inhabitant defined using with.
-- some : ∀ i → IC i
-- IC.force (some i) j with axiom -- with is necessary here!
-- ... | unit = cons (some j)
some : ∀ i → IC i
some' : ∀ i (j : Size< i) (u : Unit) → IC' j
IC.force (some i) j = some' i j axiom
some' i j unit = cons (some j)
-- A coindutive predicate with non-linear use of size i.
mutual
-- use of i in IC i is necessary, works with IC ∞
record All i (s : IC i) : Set where
coinductive
field force : ∀(j : Size< i) → All' j (IC.force s j)
data All' i : (s : IC' i) → Set where
-- With abstracted type is well-formed.
-- This means the type-checker can deal with it.
Test : Set₄
Test = (w : Set₃) (i : Size) (j : Size< i) →
All' j (idIC' (↑ j) j (some' i j axiom))
-- Agda claims: With abstracted type is ill-formed.
-- This means that checkInternal cannot deal with it.
test : ∀ i → All i (idIC i (some i))
All.force (test i) j with Set₂ -- any with expression does it here
... | w = anything
-- i !=< ↑ j of type Size
-- when checking that the type
-- (w : Set₃) (i : Size) (j : Size< i) →
-- All' j (idIC' (↑ j) j (some' i j axiom))
-- of the generated with function is well-formed
{-
candidate type:
(w : Set₃) (i : Size) (j : Size< i) →
All' j (idIC' (↑ j) j (some' i j axiom))
candidate type:
El {_getSort = Type (Max [ClosedLevel 4]), unEl =
Pi []r(El {_getSort = Type (Max [ClosedLevel 4]), unEl =
Sort (Type (Max [ClosedLevel 3]))}) (Abs "w"
El {_getSort = Type (Max []), unEl =
Pi []r(El {_getSort = SizeUniv, unEl =
Def Common.Size.Size []}) (Abs "i"
El {_getSort = Type (Max []), unEl =
Pi []r(El {_getSort = SizeUniv, unEl =
Def Common.Size.Size<_ [Apply []?(Var 0 [])]}) (Abs "j"
El {_getSort = Type (Max []), unEl =
Def Issue1795.All' [Apply []r(Var 0 []),Apply []r(
Def Issue1795.idIC' [Apply []r(Def Common.Size.↑_ [Apply []r(Var 0 [])]),Apply []r(Var 0 []),Apply []r(
Def Issue1795.some' [Apply []r(Var 1 []),Apply []r(Var 0 []),Apply []r(
Def Issue1795.axiom [])])])]})})})}
Last words:
type t = (j : Size< (↑ j)) → IC' j → IC' j
self = idIC' (↑ j)
eliminated by e = $ j
checking internal j : Size< (↑ j)
checking spine ( j : Size< i ) [] : Size< (↑ j)
-}
| {
"alphanum_fraction": 0.5757281553,
"avg_line_length": 28.3486238532,
"ext": "agda",
"hexsha": "b6c768e9116a116ca072ebba9ed3dc84b83891c6",
"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/Issue1795.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Succeed/Issue1795.agda",
"max_line_length": 107,
"max_stars_count": 3,
"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/Issue1795.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": 1100,
"size": 3090
} |
{-# OPTIONS --without-K --safe #-}
-- There are really all 'private' sub-pieces of
-- Categories.Category.Monoidal.Closed.IsClosed, but that is taking
-- forever to typecheck, so the idea is to split things into pieces and
-- hope that that will help.
open import Categories.Category using (Category)
open import Categories.Category.Monoidal
open import Categories.Category.Monoidal.Closed using (Closed)
module Categories.Category.Monoidal.Closed.IsClosed.Identity
{o ℓ e} {C : Category o ℓ e} {M : Monoidal C} (Cl : Closed M) where
open import Function using (_$_) renaming (_∘_ to _∙_)
open import Categories.Category.Monoidal.Utilities M
open import Categories.Morphism C using (Iso)
open import Categories.Morphism.Properties C using (Iso-resp-≈)
open import Categories.Morphism.Reasoning C using (pullʳ; pullˡ; pushˡ; cancelʳ)
open import Categories.Functor using (Functor) renaming (id to idF)
open import Categories.Functor.Bifunctor
open import Categories.Functor.Bifunctor.Properties
open import Categories.NaturalTransformation hiding (id)
open import Categories.NaturalTransformation.Dinatural
using (Extranaturalʳ; extranaturalʳ; DinaturalTransformation)
open import Categories.NaturalTransformation.NaturalIsomorphism
using (NaturalIsomorphism)
import Categories.Category.Closed as Cls
open Closed Cl
open Category C -- most of it is used
open HomReasoning
open adjoint renaming (unit to η; counit to ε; Ladjunct to 𝕃)
private
λ⇒ = unitorˡ.from
λ⇐ = unitorˡ.to
ρ⇒ = unitorʳ.from
ρ⇐ = unitorʳ.to
identity : NaturalIsomorphism idF [ unit ,-]
identity = record
{ F⇒G = F∘id⇒F ∘ᵥ ([ unit ,-] ∘ˡ (unitorʳ-natural.F⇒G)) ∘ᵥ η
; F⇐G = ε ∘ᵥ (unitorʳ-natural.F⇐G ∘ʳ [ unit ,-]) ∘ᵥ F⇒id∘F
; iso = λ X → Iso-resp-≈ (iso X) (⟺ identityˡ) (⟺ (∘-resp-≈ʳ identityʳ))
}
where
open Functor
iso : ∀ X → Iso (𝕃 unitorʳ.from) (ε.η X ∘ unitorʳ.to)
iso X = record
{ isoˡ = begin
(ε.η X ∘ ρ⇐) ∘ 𝕃 ρ⇒ ≈⟨ pullʳ unitorʳ-commute-to ⟩
ε.η X ∘ 𝕃 ρ⇒ ⊗₁ id ∘ ρ⇐ ≈˘⟨ assoc ⟩
Radjunct (𝕃 ρ⇒) ∘ ρ⇐ ≈⟨ RLadjunct≈id ⟩∘⟨refl ⟩
ρ⇒ ∘ ρ⇐ ≈⟨ unitorʳ.isoʳ ⟩
id ∎
; isoʳ = begin
𝕃 ρ⇒ ∘ ε.η X ∘ ρ⇐ ≈⟨ pullʳ (η.commute _) ⟩
[ id , ρ⇒ ]₁ ∘ 𝕃 ((ε.η X ∘ ρ⇐) ⊗₁ id) ≈˘⟨ pushˡ (homomorphism [ unit ,-]) ⟩
𝕃 (ρ⇒ ∘ (ε.η X ∘ ρ⇐) ⊗₁ id) ≈⟨ F-resp-≈ [ unit ,-] unitorʳ-commute-from ⟩∘⟨refl ⟩
𝕃 ((ε.η X ∘ ρ⇐) ∘ ρ⇒) ≈⟨ F-resp-≈ [ unit ,-] (cancelʳ unitorʳ.isoˡ) ⟩∘⟨refl ⟩
𝕃 (ε.η X) ≈⟨ zag ⟩
id ∎
}
module identity = NaturalIsomorphism identity
diagonal : Extranaturalʳ unit [-,-]
diagonal = extranaturalʳ (λ X → 𝕃 λ⇒)
$ λ {X Y f} → begin
[ id , f ]₁ ∘ 𝕃 λ⇒ ≈˘⟨ pushˡ (homomorphism [ X ,-]) ⟩
[ id , f ∘ λ⇒ ]₁ ∘ η.η unit ≈˘⟨ F-resp-≈ [ X ,-] unitorˡ-commute-from ⟩∘⟨refl ⟩
[ id , λ⇒ ∘ id ⊗₁ f ]₁ ∘ η.η unit ≈⟨ homomorphism [ X ,-] ⟩∘⟨refl ⟩
([ id , λ⇒ ]₁ ∘ [ id , id ⊗₁ f ]₁) ∘ η.η unit ≈⟨ pullʳ (mate.commute₁ f) ⟩
[ id , λ⇒ ]₁ ∘ [ f , id ]₁ ∘ η.η unit ≈⟨ pullˡ [ [-,-] ]-commute ⟩
([ f , id ]₁ ∘ [ id , λ⇒ ]₁) ∘ η.η unit ≈⟨ assoc ⟩
[ f , id ]₁ ∘ 𝕃 λ⇒ ∎
where open Functor
module diagonal = DinaturalTransformation diagonal
| {
"alphanum_fraction": 0.5831374853,
"avg_line_length": 41.0120481928,
"ext": "agda",
"hexsha": "f54cf258182f14fc664bba242ee2fbc6a213f34e",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Taneb/agda-categories",
"max_forks_repo_path": "Categories/Category/Monoidal/Closed/IsClosed/Identity.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Taneb/agda-categories",
"max_issues_repo_path": "Categories/Category/Monoidal/Closed/IsClosed/Identity.agda",
"max_line_length": 102,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Taneb/agda-categories",
"max_stars_repo_path": "Categories/Category/Monoidal/Closed/IsClosed/Identity.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1376,
"size": 3404
} |
{-# OPTIONS --without-K #-}
module H where
open import Data.Product using (_×_; _,_)
import Relation.Binary.Core as C
import Relation.Binary.PropositionalEquality as P
open P.≡-Reasoning
------------------------------------------------------------------------------
-- Some abbreviations and lemmas about paths
infix 4 _≡_
_≡_ : ∀ {ℓ} {A : Set ℓ} → (x y : A) → Set ℓ
_≡_ {ℓ} {A} x y = C._≡_ {ℓ} {A} x y
refl : ∀ {ℓ} {A} → (x : A) → x ≡ x
refl {ℓ} {A} x = C.refl {ℓ} {A} {x}
infixr 8 _•_
_•_ : ∀ {ℓ} {A : Set ℓ} {x y z : A} →
(x ≡ y) → (y ≡ z) → (x ≡ z)
_•_ = P.trans
unitTransR : ∀ {ℓ} {A : Set ℓ} {x y : A} → (p : x ≡ y) → (p ≡ p • refl y)
unitTransR {x = x} C.refl = refl (refl x)
unitTransL : {A : Set} {x y : A} → (p : x ≡ y) → (p ≡ refl x • p)
unitTransL {x = x} C.refl = refl (refl x)
-- ap, transport, apd at level 1
ap : ∀ {ℓ₁ ℓ₂} {A : Set ℓ₁} {B : Set ℓ₂} →
(f : A → B) → {x y : A} → (x ≡ y) → (f x ≡ f y)
ap = P.cong
transport : ∀ {ℓ₁ ℓ₂} {A : Set ℓ₁} (B : A → Set ℓ₂) →
{x y : A} → (x ≡ y) → B x → B y
transport = P.subst
-- binary version
transport₂ : ∀ {ℓ₁ ℓ₂ ℓ₃} {A : Set ℓ₁} {B : Set ℓ₂} (P : A → B → Set ℓ₃) →
{x₁ x₂ : A} {y₁ y₂ : B} → (x₁ ≡ x₂) → (y₁ ≡ y₂) →
P x₁ y₁ → P x₂ y₂
transport₂ = P.subst₂
apd : ∀ {ℓ₁ ℓ₂} → {A : Set ℓ₁} {B : A → Set ℓ₂} →
(f : (x : A) → B x) → {x y : A} → (p : x ≡ y) →
transport B p (f x) ≡ f y
apd f C.refl = C.refl
-- ap, transport, apd at level 2
ap² : ∀ {ℓ₁ ℓ₂} {A : Set ℓ₁} {B : Set ℓ₂} →
(f : A → B) → {x y : A} {p q : x ≡ y} → (r : p ≡ q) →
(ap f p ≡ ap f q)
ap² f C.refl = C.refl
transport² : ∀ {ℓ₁ ℓ₂} {A : Set ℓ₁} (P : A → Set ℓ₂) →
{x y : A} {p q : x ≡ y} → (r : p ≡ q) → (u : P x) →
(transport P p u ≡ transport P q u)
transport² P {p = C.refl} C.refl u = refl u
apd² : ∀ {ℓ₁ ℓ₂} → {A : Set ℓ₁} {B : A → Set ℓ₂} →
(f : (x : A) → B x) → {x y : A} {p q : x ≡ y} → (r : p ≡ q) →
apd f p ≡ (transport² B r (f x)) • (apd f q)
apd² f {p = C.refl} C.refl = C.refl
------------------------------------------------------------------------------
-- Some higher-inductive types from Ch. 6
module S¹ where
postulate
S¹ : Set
base : S¹
loop : base ≡ base
record rec (B : Set) (b : B) (p : b ≡ b) : Set₁ where
field
f : S¹ → B
α : f base ≡ b
β : transport (λ x → x ≡ x) α (ap f loop) ≡ p
record ind (P : S¹ → Set) (b : P base) (p : transport P loop b ≡ b) : Set₁ where
field
f : (x : S¹) → P x
α : f base ≡ b
β : transport (λ x → transport P loop x ≡ x) α (apd f loop) ≡ p
------------------------------------------------------------------------------
-- Interval
module I where
postulate
I : Set
𝟘 : I
𝟙 : I
seg : 𝟘 ≡ 𝟙
record rec (B : Set) (b₀ b₁ : B) (s : b₀ ≡ b₁) : Set₁ where
postulate
f : I → B
α₀ : f 𝟘 ≡ b₀
α₁ : f 𝟙 ≡ b₁
β : transport₂ (λ x y → x ≡ y) α₀ α₁ (ap f seg) ≡ s
record ind (P : I → Set) (b₀ : P 𝟘) (b₁ : P 𝟙)
(s : transport P seg b₀ ≡ b₁) : Set₁ where
postulate
f : (x : I) → P x
α₀ : f 𝟘 ≡ b₀
α₁ : f 𝟙 ≡ b₁
β : transport₂ (λ x y → transport P seg x ≡ y) α₀ α₁ (apd f seg) ≡ s
------------------------------------------------------------------------------
-- S²
module S² where
postulate
S² : Set
base : S²
surf : refl base ≡ refl base
record rec (B : Set) (b : B) (s : refl b ≡ refl b) : Set₁ where
postulate
f : S² → B
α : f base ≡ b
β : transport (λ p → refl p ≡ refl p) α (ap² f surf) ≡ s
record ind (P : S² → Set) (b : P base)
(s : refl b ≡ transport² P surf b • (refl b)) : Set₁ where
postulate
f : (x : S²) → P x
α : f base ≡ b
β : transport
(λ p → refl p ≡ transport² P surf p • refl p) α (apd² f surf)
≡ s
------------------------------------------------------------------------------
-- Suspensions
module Susp (A : Set) where
postulate
Σ : Set → Set₁
N : Σ A
S : Σ A
merid : A → (N ≡ S)
------------------------------------------------------------------------------
-- Torus
module T² where
postulate
T² : Set
b : T²
p : b ≡ b
q : b ≡ b
t : p • q ≡ q • p
------------------------------------------------------------------------------
-- Torus (alternative definition)
module T²' where
open S¹
T² : Set
T² = S¹ × S¹
------------------------------------------------------------------------------
-- Torus (second alternative definition)
module T²'' where
open S¹
postulate
T² : Set
b : T²
p : b ≡ b
q : b ≡ b
h : T²
f : S¹ → T²
fb : f base ≡ b
floop : transport (λ x → x ≡ x) fb (ap f loop) ≡ p • q • P.sym p • P.sym q
s : (x : S¹) → f x ≡ h
------------------------------------------------------------------------------
| {
"alphanum_fraction": 0.3968641824,
"avg_line_length": 25.056122449,
"ext": "agda",
"hexsha": "0bde5aa2155ff924acd6b3f1e5d59974c6af5189",
"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": "b05c58ffdaed99932ca2acc632deca8d14742b04",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "andmkent/misc-HoTT",
"max_forks_repo_path": "H-1.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b05c58ffdaed99932ca2acc632deca8d14742b04",
"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": "andmkent/misc-HoTT",
"max_issues_repo_path": "H-1.agda",
"max_line_length": 82,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "b05c58ffdaed99932ca2acc632deca8d14742b04",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "andmkent/misc-HoTT",
"max_stars_repo_path": "H-1.agda",
"max_stars_repo_stars_event_max_datetime": "2016-01-26T18:17:16.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-01-26T18:17:16.000Z",
"num_tokens": 1956,
"size": 4911
} |
module helloworld where
open import IO
main = run (putStrLn "Hello, World!")
| {
"alphanum_fraction": 0.7160493827,
"avg_line_length": 20.25,
"ext": "agda",
"hexsha": "fff21fdc0caa7402a852794895e111c69a1953f7",
"lang": "Agda",
"max_forks_count": 713,
"max_forks_repo_forks_event_max_datetime": "2022-03-02T22:57:21.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-08-12T21:37:49.000Z",
"max_forks_repo_head_hexsha": "827d8961d3a548daf8fe3b674642a1562daaa5c4",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Ayush7-BIT/sample-programs",
"max_forks_repo_path": "archive/a/agda/HelloWorld.agda",
"max_issues_count": 1498,
"max_issues_repo_head_hexsha": "827d8961d3a548daf8fe3b674642a1562daaa5c4",
"max_issues_repo_issues_event_max_datetime": "2021-12-14T03:02:00.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-08-10T19:18:52.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Ayush7-BIT/sample-programs",
"max_issues_repo_path": "archive/a/agda/HelloWorld.agda",
"max_line_length": 39,
"max_stars_count": 422,
"max_stars_repo_head_hexsha": "827d8961d3a548daf8fe3b674642a1562daaa5c4",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Ayush7-BIT/sample-programs",
"max_stars_repo_path": "archive/a/agda/HelloWorld.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-07T23:54:34.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-08-14T11:57:47.000Z",
"num_tokens": 22,
"size": 81
} |
module FairStream where
open import Level as Level using (zero)
open import Size
open import Function
open import Relation.Binary
open import Relation.Binary.PropositionalEquality as P
open ≡-Reasoning
-- open import Data.List using (List; module List; []; _∷_; _++_; length)
open import Data.Nat using (ℕ; zero; suc)
open import Data.Product renaming (map to pmap)
open import Stream
data List⁺ (A : Set) : Set where
one : A → List⁺ A
_∷_ : A → List⁺ A → List⁺ A
mutual
data LFin (A B : Set) : Set where
lin : A × LFin A B → LFin A B
rinl : RFin A B → LFin A B
data RFin (A B : Set) : Set where
rin : B × RFin A B → RFin A B
linr : LFin A B → RFin A B
Fair Fair' : Set → Set → Set
Fair A B = Stream (LFin A B)
Fair' A B = Stream (List⁺ A × List⁺ B)
α : ∀{A B} → Fair A B → Fair' A B
hd (α {A} {B} u) = (f₁ (hd u) , g (hd u))
where
f₁ : LFin A B → List⁺ A
f₂ : RFin A B → List⁺ A
f₁ (lin (a , x)) = a ∷ f₁ x
f₁ (rinl x) = f₂ x
f₂ (rin (b , y)) = f₂ y
f₂ (linr x) = f₁ x
g : LFin A B → List⁺ B
g (lin x) = {![]!}
g (rinl x) = {!!}
tl (α u) = {!!}
| {
"alphanum_fraction": 0.5704099822,
"avg_line_length": 21.5769230769,
"ext": "agda",
"hexsha": "4f7515128cc4bef20f459e5efb59f3d90fc497dd",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "hbasold/Sandbox",
"max_forks_repo_path": "Languages/FairStream.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "hbasold/Sandbox",
"max_issues_repo_path": "Languages/FairStream.agda",
"max_line_length": 73,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "hbasold/Sandbox",
"max_stars_repo_path": "Languages/FairStream.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 438,
"size": 1122
} |
{-# OPTIONS --without-K #-}
open import lib.Basics
open import lib.NType2
open import lib.PathGroupoid
open import lib.types.Bool
open import lib.types.IteratedSuspension
open import lib.types.Lift
open import lib.types.LoopSpace
open import lib.types.Nat
open import lib.types.Paths
open import lib.types.Pi
open import lib.types.Pointed
open import lib.types.Sigma
open import lib.types.Suspension
open import lib.types.TLevel
open import lib.types.Unit
open SuspensionRec public using () renaming (f to Susp-rec)
open import nicolai.pseudotruncations.Preliminary-definitions
open import nicolai.pseudotruncations.Liblemmas
open import nicolai.pseudotruncations.pointed-O-Sphere
module nicolai.pseudotruncations.LoopsAndSpheres where
{- We greatly benefit from Evan Cavallo's code - thank you! -}
open import homotopy.PtdAdjoint
open import homotopy.SuspAdjointLoop
isNull : ∀ {i j} {A : Type i} {B : Type j} (b : B) (f : A → B) → Type _
isNull {A = A} b f = (a : A) → f a == b
module null {i} {j} {Â : Ptd i} {B̂ : Ptd j} (ĝ : Â →̇ B̂) where
A = fst Â
a₀ = snd Â
B = fst B̂
b₀ = snd B̂
g = fst ĝ
p = snd ĝ
-- derived isNull
isNulld = (a : fst Â) → g a == b₀
-- pointed isNull; we state it in the equivalence form (slightly easier to handle)
isNull∙' = Σ ((a : A) → g a == b₀) λ pr → pr a₀ == p
-- the 'real' pointed isNull
isNull∙ = ĝ == ((λ _ → b₀) , idp)
{- The two versions are equivalent -}
isNull-equiv : isNull∙ ≃ isNull∙'
isNull-equiv =
ĝ == ((λ _ → b₀) , idp)
≃⟨ (=Σ-eqv _ _) ⁻¹ ⟩
=Σ ĝ ((λ _ → b₀) , idp)
≃⟨ equiv-Σ' {A₀ = g == λ _ → b₀}
app=-equiv
(λ h → (p == idp [ (λ f → f a₀ == b₀) ↓ h ])
≃⟨ to-transp-equiv _ _ ⟩
(transport (λ f → f a₀ == b₀) h p) == idp
≃⟨ coe-equiv
(ap (λ x → x == idp)
(trans-ap₁ (λ f → f a₀)
b₀ h p)) ⟩
(! (app= h a₀) ∙ p) == idp
≃⟨ adhoc-=-eqv (app= h a₀) p ⟩
(app= h a₀ == p)
≃∎) ⟩
(Σ ((a : A) → g a == b₀) λ pr → pr a₀ == p)
≃∎
-- Lemma 4.4: pointed and non-pointed 'nullness' are logically equivalent;
-- First, one direction:
null-lequiv : isNulld → isNull∙'
null-lequiv isnull = (λ a → isnull a ∙ ! (isnull a₀) ∙ p) , (
isnull a₀ ∙ ! (isnull a₀) ∙ p
=⟨ ! (∙-assoc (isnull a₀) _ _) ⟩
(isnull a₀ ∙ ! (isnull a₀)) ∙ p
=⟨ ap (λ t → t ∙ p) (!-inv-r (isnull a₀)) ⟩
p
∎)
-- The other direction is very easy; we do it using the non-prime variant:
null-lequiv-easy : isNull∙ → isNulld
null-lequiv-easy isn = app= (ap fst isn)
-- uncomment this if you want to wait forever for typechecking...
-- Σ⊣Ω-unitCounit : CounitUnitAdjoint Σ⊣Ω.SuspFunctor Σ⊣Ω.LoopFunctor
Σ⊣Ω-unitCounit = Σ⊣Ω.adj
Σ⊣Ω-homset : ∀ {i} → HomAdjoint {i} {i} Σ⊣Ω.SuspFunctor Σ⊣Ω.LoopFunctor
Σ⊣Ω-homset = counit-unit-to-hom Σ⊣Ω-unitCounit
module hom-adjoint {i} (Â : Ptd i) (B̂ : Ptd i) where
A = fst Â
B = fst B̂
a₀ = snd Â
b₀ = snd B̂
Φeq : (⊙Susp  →̇ B̂) ≃ ( →̇ ⊙Ω B̂)
Φeq = HomAdjoint.eq Σ⊣Ω-homset  B̂
{- This is Lemma 4.1 -}
Φ : (⊙Susp  →̇ B̂) → ( →̇ ⊙Ω B̂)
Φ = –> Φeq
Φ⁻¹ : ( →̇ ⊙Ω B̂) → (⊙Susp  →̇ B̂)
Φ⁻¹ = <– Φeq
open PtdFunctor
open Σ⊣Ω
open CounitUnitAdjoint
{- Some lemmas which are easy on paper and thus not explicitly
mentioned in the paper. It still takes some effort to
formalize them. -}
module simplify where
simpl-⊙ap : (⊙ap {X = obj SuspFunctor Â} ((λ _ → b₀) , idp))
==
((λ _ → idp) , idp)
simpl-⊙ap = →̇-maps-to
⊙ap ((λ _ → b₀) , idp)
((λ _ → idp) , idp)
(λ= (λ _ → ap-cst b₀ _))
((app= (λ= (λ _ → ap-cst b₀ _)) _) ∙ idp
=⟨ ∙-unit-r _ ⟩
app= (λ= (λ _ → ap-cst b₀ _)) _
=⟨ app=-β _ _ ⟩
ap-cst b₀ (idp {a = snd B̂})
=⟨ idp ⟩ -- !
idp
=⟨ idp ⟩ -- !
snd (⊙ap {X = obj SuspFunctor Â} ((λ _ → b₀) , idp))
∎ )
simpl-comp : ((λ (_ : Ω (⊙Susp Â)) → idp {a = b₀}) , idp)
⊙∘ (⊙η Â)
==
(λ _ → idp) , idp
simpl-comp = pair= idp ((ap-cst idp (snd (⊙η Â))) ∙ᵣ idp)
open simplify
{- Lemma 4.2 -}
Φ-is-pointed-map : Φ ((λ _ → b₀) , idp) == ((λ _ → idp) , idp)
Φ-is-pointed-map = Φ ((λ _ → b₀) , idp)
=⟨ idp ⟩
( arr LoopFunctor ((λ _ → b₀) , idp)
⊙∘ (CounitUnitAdjoint.η adj Â))
=⟨ idp ⟩
( (⊙ap {X = obj SuspFunctor Â} ((λ _ → b₀) , idp)
⊙∘ (⊙η Â)))
=⟨ ap (λ f → f ⊙∘ (⊙η Â)) simpl-⊙ap ⟩
((λ _ → idp) , idp) ⊙∘ (⊙η Â)
=⟨ simpl-comp ⟩
(λ _ → idp) , idp
∎
-- fix i
module _ {i} where
open hom-adjoint
open HomAdjoint
open null
-- Lemma 4.3
Φ-snd-nat : { B̂ Ĉ : Ptd i} (f : ⊙Susp  →̇ B̂) (g : B̂ →̇ Ĉ)
→ Φ Â Ĉ (g ⊙∘ f) == ⊙ap g ⊙∘ Φ Â B̂ f
Φ-snd-nat {Â} {B̂} {Ĉ} f g = ! (nat-cod Σ⊣Ω-homset  {B̂} {Ĉ} g f)
-- Lemma 4.4 is above (before 4.2).
-- Lemma 4.5
isnull-Φ : { B̂ : Ptd i} (g : ⊙Susp  →̇ B̂) → (isNull∙ g) ≃ isNull∙ (Φ Â B̂ g)
isnull-Φ {Â} {B̂} g =
isNull∙ g
≃⟨ equiv-ap (Φeq  B̂) _ _ ⟩
(Φ Â B̂ g) == Φ Â B̂ ((λ _ → snd B̂) , idp)
≃⟨ coe-equiv
{A = (Φ Â B̂ g) == Φ Â B̂ ((λ _ → snd B̂) , idp)}
{B = (Φ Â B̂ g) == (λ _ → idp) , idp}
(ap (λ q → (Φ Â B̂ g == q)) (Φ-is-pointed-map _ _ )) ⟩
(Φ Â B̂ g) == (λ _ → idp) , idp
≃∎
-- combination of 4.3 and 4.5
combine-isnull-nat : { B̂ Ĉ : Ptd i} (f : ⊙Susp  →̇ B̂) (g : B̂ →̇ Ĉ)
→ (isNull∙ (g ⊙∘ f)) ≃ (isNull∙ (⊙ap g ⊙∘ Φ Â B̂ f)) --
combine-isnull-nat {Â} {B̂} {Ĉ} f g =
isNull∙ (g ⊙∘ f)
≃⟨ isnull-Φ _ ⟩
isNull∙ (Φ Â Ĉ (g ⊙∘ f))
≃⟨ coe-equiv (ap (λ q → isNull∙ q) (Φ-snd-nat f g)) ⟩
isNull∙ (⊙ap g ⊙∘ Φ Â B̂ f)
≃∎
combine-isnull-nat' : {Â B̂ Ĉ : Ptd i} (f : Â →̇ ⊙Ω B̂) (g : B̂ →̇ Ĉ)
→ (isNull∙ (g ⊙∘ (Φ⁻¹ Â B̂ f))) ≃ (isNull∙ (⊙ap g ⊙∘ f))
combine-isnull-nat' {Â} {B̂} {Ĉ} f g =
isNull∙ (g ⊙∘ (Φ⁻¹ Â B̂ f))
≃⟨ combine-isnull-nat (Φ⁻¹ Â B̂ f) g ⟩
isNull∙ (⊙ap g ⊙∘ (Φ Â B̂ (Φ⁻¹ Â B̂ f)))
≃⟨ coe-equiv (ap (λ h → isNull∙ (⊙ap g ⊙∘ h)) (<–-inv-r (Φeq  B̂) f)) ⟩
isNull∙ (⊙ap g ⊙∘ f)
≃∎
module _ {i} where
open hom-adjoint
-- This was tricky (todo: could explain why)
Φ-iter : (Â B̂ : Ptd i) (n : Nat)
→ ((⊙Susp-iter' n Â) →̇ B̂)
→ (Â →̇ (⊙Ω^ n B̂))
Φ-iter  B̂ O f = f
Φ-iter  B̂ (S n) f = Φ Â (⊙Ω^ n B̂) (Φ-iter (⊙Susp Â) B̂ n f)
Φ-iter-equiv : ( B̂ : Ptd i) (n : Nat) → is-equiv (Φ-iter  B̂ n)
Φ-iter-equiv  B̂ O = snd (ide _)
Φ-iter-equiv  B̂ (S n) =
snd ((Φeq  (⊙Ω^ n B̂)) ∘e ((Φ-iter (⊙Susp Â) B̂ n) , Φ-iter-equiv (⊙Susp Â) B̂ n) )
module _ {i} where
open null
open hom-adjoint
-- Lemma 4.7 -- generalized, because we need to do it for Susp first before it works for Sphere!
isNull-Φ-many : (m : Nat)
→ (Â B̂ Ĉ : Ptd i)
→ (f : ⊙Susp-iter' m  →̇ B̂) (g : B̂ →̇ Ĉ)
→ isNull∙ (g ⊙∘ f)
≃
isNull∙ ((ap^ m g) ⊙∘ Φ-iter  B̂ m f)
isNull-Φ-many O Â B̂ Ĉ f g = ide _
isNull-Φ-many (S m) Â B̂ Ĉ f g =
isNull∙ (g ⊙∘ f)
≃⟨ isNull-Φ-many m (⊙Susp Â) B̂ Ĉ f g ⟩
isNull∙ ((ap^ m g) ⊙∘ Φ-iter (⊙Susp Â) B̂ m f)
≃⟨ combine-isnull-nat (Φ-iter (⊙Susp Â) B̂ m f) (ap^ m g) ⟩
(isNull∙
(⊙ap (ap^ m g) ⊙∘
Φ Â (⊙Ω^ m B̂)
(Φ-iter (⊙Susp Â) B̂ m f)))
≃∎
-- Lemma 4.7 (special with k = 0)
module _ {B̂ Ĉ : Ptd i} (m : Nat)
(f : ⊙Sphere' {i} m →̇ B̂) (g : B̂ →̇ Ĉ) where
isNull-Φ-Sphere : isNull∙ (g ⊙∘ f)
≃
isNull∙ ((ap^ m g) ⊙∘ Φ-iter (⊙Sphere' {i} O) B̂ m f)
isNull-Φ-Sphere = isNull-Φ-many m _ _ _ f g
open bool-neutral
module _ {B̂ Ĉ : Ptd i} (m : Nat)
(g : B̂ →̇ Ĉ) where
c₀ = snd (⊙Ω^ m Ĉ)
{- Lemma 4.8 -}
null-on-pspaces :
((f : (⊙Sphere' {i} m) →̇ B̂) → isNull∙ (g ⊙∘ f))
≃
isNulld (ap^ m g)
null-on-pspaces = -- {!equiv-Π-l!}
((f : (⊙Sphere' {i} m) →̇ B̂) → isNull∙ (g ⊙∘ f))
≃⟨ equiv-Π-r (λ f → isNull-Φ-Sphere m f g) ⟩
((f : (⊙Sphere' {i} m) →̇ B̂) → isNull∙ ((ap^ m g) ⊙∘ Φ-iter (⊙Sphere' {i} O) B̂ m f))
≃⟨ equiv-Π-l
{A = (⊙Sphere' {i} m) →̇ B̂}
{B = (⊙Sphere' {i} O) →̇ (⊙Ω^ m B̂)}
(λ f' → isNull∙ ((ap^ m g) ⊙∘ f'))
{h = Φ-iter (⊙Sphere' {i} O) B̂ m}
(Φ-iter-equiv _ _ m)
⟩
((f' : (⊙Sphere' {i} O) →̇ (⊙Ω^ m B̂)) → isNull∙ ((ap^ m g) ⊙∘ f'))
≃⟨ equiv-Π-r {A = ⊙Sphere' {i} O →̇ (⊙Ω^ m B̂)} (λ _ → isNull-equiv _) ⟩
((f' : (⊙Sphere' {i} O) →̇ (⊙Ω^ m B̂)) → isNull∙' ((ap^ m g) ⊙∘ f'))
≃⟨ ide _ ⟩
((f' : (⊙Sphere' {i} O) →̇ (⊙Ω^ m B̂)) → Σ ((x : bool) → fst ((ap^ m g) ⊙∘ f') x == _) λ h → h tt₀ == _)
≃⟨ equiv-Π-r {A = ⊙Sphere' {i} O →̇ (⊙Ω^ m B̂)}
(λ fp → reduction (λ b → fst (ap^ m g ⊙∘ fp) b == null.b₀ (ap^ m g ⊙∘ fp)) _) ⟩
((f' : (⊙Sphere' {i} O) →̇ (⊙Ω^ m B̂)) → fst ((ap^ m g) ⊙∘ f') ff₀ == _)
≃⟨ ide _ ⟩
((f' : (⊙Sphere' {i} O) →̇ (⊙Ω^ m B̂)) → fst (ap^ m g) (fst f' ff₀) == _)
≃⟨ equiv-Π-l {A = (⊙Sphere' {i} O) →̇ (⊙Ω^ m B̂)}
{B = fst (⊙Ω^ m B̂)}
_
(snd (reduction (λ _ → fst (⊙Ω^ m B̂)) _)) ⟩
((x : fst (⊙Ω^ m B̂)) → fst (ap^ m g) x == c₀)
≃⟨ ide _ ⟩
isNulld (ap^ m g)
≃∎
| {
"alphanum_fraction": 0.4069518218,
"avg_line_length": 31.2857142857,
"ext": "agda",
"hexsha": "2e9bb0b89120a95609ce5cacc69f08263c93b676",
"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": "nicolai/pseudotruncations/LoopsAndSpheres.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": "nicolai/pseudotruncations/LoopsAndSpheres.agda",
"max_line_length": 110,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nicolaikraus/HoTT-Agda",
"max_stars_repo_path": "nicolai/pseudotruncations/LoopsAndSpheres.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": 4826,
"size": 10731
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Algebra.CommRing.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Equiv.HalfAdjoint
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.Transport
open import Cubical.Foundations.SIP
open import Cubical.Data.Sigma
open import Cubical.Reflection.StrictEquiv
open import Cubical.Structures.Axioms
open import Cubical.Algebra.Semigroup
open import Cubical.Algebra.Monoid
open import Cubical.Algebra.AbGroup
open import Cubical.Algebra.Ring.Base
open Iso
private
variable
ℓ : Level
record IsCommRing {R : Type ℓ}
(0r 1r : R) (_+_ _·_ : R → R → R) (-_ : R → R) : Type ℓ where
constructor iscommring
field
isRing : IsRing 0r 1r _+_ _·_ -_
·-comm : (x y : R) → x · y ≡ y · x
open IsRing isRing public
record CommRingStr (A : Type ℓ) : Type (ℓ-suc ℓ) where
constructor commringstr
field
0r : A
1r : A
_+_ : A → A → A
_·_ : A → A → A
-_ : A → A
isCommRing : IsCommRing 0r 1r _+_ _·_ -_
infix 8 -_
infixl 7 _·_
infixl 6 _+_
open IsCommRing isCommRing public
CommRing : Type (ℓ-suc ℓ)
CommRing = TypeWithStr _ CommRingStr
makeIsCommRing : {R : Type ℓ} {0r 1r : R} {_+_ _·_ : R → R → R} { -_ : R → R}
(is-setR : isSet R)
(+-assoc : (x y z : R) → x + (y + z) ≡ (x + y) + z)
(+-rid : (x : R) → x + 0r ≡ x)
(+-rinv : (x : R) → x + (- x) ≡ 0r)
(+-comm : (x y : R) → x + y ≡ y + x)
(·-assoc : (x y z : R) → x · (y · z) ≡ (x · y) · z)
(·-rid : (x : R) → x · 1r ≡ x)
(·-rdist-+ : (x y z : R) → x · (y + z) ≡ (x · y) + (x · z))
(·-comm : (x y : R) → x · y ≡ y · x)
→ IsCommRing 0r 1r _+_ _·_ -_
makeIsCommRing {_+_ = _+_} is-setR +-assoc +-rid +-rinv +-comm ·-assoc ·-rid ·-rdist-+ ·-comm =
iscommring (makeIsRing is-setR +-assoc +-rid +-rinv +-comm ·-assoc ·-rid
(λ x → ·-comm _ _ ∙ ·-rid x) ·-rdist-+
(λ x y z → ·-comm _ _ ∙∙ ·-rdist-+ z x y ∙∙ λ i → (·-comm z x i) + (·-comm z y i))) ·-comm
makeCommRing : {R : Type ℓ} (0r 1r : R) (_+_ _·_ : R → R → R) (-_ : R → R)
(is-setR : isSet R)
(+-assoc : (x y z : R) → x + (y + z) ≡ (x + y) + z)
(+-rid : (x : R) → x + 0r ≡ x)
(+-rinv : (x : R) → x + (- x) ≡ 0r)
(+-comm : (x y : R) → x + y ≡ y + x)
(·-assoc : (x y z : R) → x · (y · z) ≡ (x · y) · z)
(·-rid : (x : R) → x · 1r ≡ x)
(·-rdist-+ : (x y z : R) → x · (y + z) ≡ (x · y) + (x · z))
(·-comm : (x y : R) → x · y ≡ y · x)
→ CommRing
makeCommRing 0r 1r _+_ _·_ -_ is-setR +-assoc +-rid +-rinv +-comm ·-assoc ·-rid ·-rdist-+ ·-comm =
_ , commringstr _ _ _ _ _ (makeIsCommRing is-setR +-assoc +-rid +-rinv +-comm ·-assoc ·-rid ·-rdist-+ ·-comm)
CommRing→Ring : CommRing {ℓ} → Ring
CommRing→Ring (_ , commringstr _ _ _ _ _ H) = _ , ringstr _ _ _ _ _ (IsCommRing.isRing H)
CommRingEquiv : (R S : CommRing) (e : ⟨ R ⟩ ≃ ⟨ S ⟩) → Type ℓ
CommRingEquiv R S e = RingEquiv (CommRing→Ring R) (CommRing→Ring S) e
CommRingHom : (R S : CommRing) → Type ℓ
CommRingHom R S = RingHom (CommRing→Ring R) (CommRing→Ring S)
module CommRingΣTheory {ℓ} where
open RingΣTheory
CommRingAxioms : (R : Type ℓ) (s : RawRingStructure R) → Type ℓ
CommRingAxioms R (_+_ , 1r , _·_) = RingAxioms R (_+_ , 1r , _·_)
× ((x y : R) → x · y ≡ y · x)
CommRingStructure : Type ℓ → Type ℓ
CommRingStructure = AxiomsStructure RawRingStructure CommRingAxioms
CommRingΣ : Type (ℓ-suc ℓ)
CommRingΣ = TypeWithStr ℓ CommRingStructure
CommRingEquivStr : StrEquiv CommRingStructure ℓ
CommRingEquivStr = AxiomsEquivStr RawRingEquivStr CommRingAxioms
isPropCommRingAxioms : (R : Type ℓ) (s : RawRingStructure R)
→ isProp (CommRingAxioms R s)
isPropCommRingAxioms R (_·_ , 0r , _+_) =
isPropΣ (isPropRingAxioms R (_·_ , 0r , _+_))
λ { (_ , x , _) → isPropΠ2 λ _ _ →
x .IsMonoid.isSemigroup .IsSemigroup.is-set _ _}
CommRing→CommRingΣ : CommRing → CommRingΣ
CommRing→CommRingΣ (_ , commringstr _ _ _ _ _ (iscommring G C)) =
_ , _ , Ring→RingΣ (_ , ringstr _ _ _ _ _ G) .snd .snd , C
CommRingΣ→CommRing : CommRingΣ → CommRing
CommRingΣ→CommRing (_ , _ , G , C) =
_ , commringstr _ _ _ _ _ (iscommring (RingΣ→Ring (_ , _ , G) .snd .RingStr.isRing) C)
CommRingIsoCommRingΣ : Iso CommRing CommRingΣ
CommRingIsoCommRingΣ =
iso CommRing→CommRingΣ CommRingΣ→CommRing (λ _ → refl) (λ _ → refl)
commRingUnivalentStr : UnivalentStr CommRingStructure CommRingEquivStr
commRingUnivalentStr = axiomsUnivalentStr _ isPropCommRingAxioms rawRingUnivalentStr
CommRingΣPath : (R S : CommRingΣ) → (R ≃[ CommRingEquivStr ] S) ≃ (R ≡ S)
CommRingΣPath = SIP commRingUnivalentStr
CommRingEquivΣ : (R S : CommRing) → Type ℓ
CommRingEquivΣ R S = CommRing→CommRingΣ R ≃[ CommRingEquivStr ] CommRing→CommRingΣ S
CommRingPath : (R S : CommRing) → (Σ[ e ∈ ⟨ R ⟩ ≃ ⟨ S ⟩ ] CommRingEquiv R S e) ≃ (R ≡ S)
CommRingPath R S =
Σ[ e ∈ ⟨ R ⟩ ≃ ⟨ S ⟩ ] CommRingEquiv R S e ≃⟨ strictIsoToEquiv RingIsoΣPath ⟩
CommRingEquivΣ R S ≃⟨ CommRingΣPath _ _ ⟩
CommRing→CommRingΣ R ≡ CommRing→CommRingΣ S
≃⟨ isoToEquiv (invIso (congIso CommRingIsoCommRingΣ)) ⟩
R ≡ S ■
CommRingPath : (R S : CommRing {ℓ}) → (Σ[ e ∈ ⟨ R ⟩ ≃ ⟨ S ⟩ ] CommRingEquiv R S e) ≃ (R ≡ S)
CommRingPath = CommRingΣTheory.CommRingPath
isSetCommRing : ((R , str) : CommRing {ℓ}) → isSet R
isSetCommRing (R , str) = str .CommRingStr.is-set
isPropIsCommRing : {R : Type ℓ} (0r 1r : R) (_+_ _·_ : R → R → R) (-_ : R → R)
→ isProp (IsCommRing 0r 1r _+_ _·_ -_)
isPropIsCommRing 0r 1r _+_ _·_ -_ (iscommring RR RC) (iscommring SR SC) =
λ i → iscommring (isPropIsRing _ _ _ _ _ RR SR i)
(isPropComm RC SC i)
where
isSetR : isSet _
isSetR = RR .IsRing.·IsMonoid .IsMonoid.isSemigroup .IsSemigroup.is-set
isPropComm : isProp ((x y : _) → x · y ≡ y · x)
isPropComm = isPropΠ2 λ _ _ → isSetR _ _
| {
"alphanum_fraction": 0.5693839452,
"avg_line_length": 37.8117647059,
"ext": "agda",
"hexsha": "d0020d59f1bc08d0be7bfc459c5e8a2a46d6586e",
"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": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Edlyr/cubical",
"max_forks_repo_path": "Cubical/Algebra/CommRing/Base.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e",
"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": "Edlyr/cubical",
"max_issues_repo_path": "Cubical/Algebra/CommRing/Base.agda",
"max_line_length": 115,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Edlyr/cubical",
"max_stars_repo_path": "Cubical/Algebra/CommRing/Base.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2497,
"size": 6428
} |
postulate
S : Set
id : S
comp : S → S → S
module C where
_∘_ = comp
postulate
R : (S → S) → Set
T : R (C._∘ id) → R (id C.∘_) → Set
t : Set
t = T {!!} {!!}
| {
"alphanum_fraction": 0.4418604651,
"avg_line_length": 10.75,
"ext": "agda",
"hexsha": "5e1a1ac3f29b9b5db674bddadcd8f4e41ef3f41d",
"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/Issue3072.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/Issue3072.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/interaction/Issue3072.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": 83,
"size": 172
} |
module Issue124 where
module A where
data A : Set where
c : A
module B where
data B : Set where
c : B
module C where
open A public
open B public
open C
f : B → B
f c = c | {
"alphanum_fraction": 0.6178010471,
"avg_line_length": 10.0526315789,
"ext": "agda",
"hexsha": "affaf8821285da98a4be7abdf94d55ae5c19b8e5",
"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/Issue124.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/Issue124.agda",
"max_line_length": 21,
"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/Issue124.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": 65,
"size": 191
} |
module Linear where
open import Data.Product
open import Data.Sum
open import Data.Empty
-- 1. PROPOSITIONAL FRAGMENT
infixr 0 _⊸_
infixr 1 _⊕_ _⅋_
infixr 2 _&_ _⊗_
-- Linear propositions consist of a positive part (affirmation, φ₊) and a negative
-- part (refutation, φ₋). We prove a linear proposition by proving its affirmation.
-- If we have a refutation then we cannot have an affirmation, on pain of contra-
-- diction.
data LProp : Set₁ where
lprop : (φ₊ : Set) → (φ₋ : Set) → (φ₋ → φ₊ → ⊥) → LProp
-- Linear negation exchanges affirmations and refutations.
~ : LProp → LProp
~ (lprop φ₊ φ₋ p) = lprop φ₋ φ₊ (λ a b → p b a)
-- Additive conjunction
_&_ : LProp → LProp → LProp
(lprop φ₊ φ₋ p) & (lprop ψ₊ ψ₋ q) = lprop (φ₊ × ψ₊) (φ₋ ⊎ ψ₋) pq where
pq : (φ₋ ⊎ ψ₋) → (φ₊ × ψ₊) → ⊥
pq (inj₁ ~a) (a , b) = p ~a a
pq (inj₂ ~b) (a , b) = q ~b b
-- Additive disjunction: notice the symmetry between the proofs `pq` between
-- additive conjunctions and additive disjunctions.
_⊕_ : LProp → LProp → LProp
(lprop φ₊ φ₋ p) ⊕ (lprop ψ₊ ψ₋ q) = lprop (φ₋ ⊎ ψ₋) (φ₊ × ψ₊) pq where
pq : (φ₊ × ψ₊) → (φ₋ ⊎ ψ₋) → ⊥
pq (a , b) (inj₁ ~a) = p ~a a
pq (a , b) (inj₂ ~b) = q ~b b
-- Multiplicative conjunction
_⊗_ : LProp → LProp → LProp
(lprop φ₊ φ₋ p) ⊗ (lprop ψ₊ ψ₋ q) = lprop (φ₊ × ψ₊) ((φ₊ → ψ₋) × (ψ₊ → φ₋)) pq where
pq : ((φ₊ → ψ₋) × (ψ₊ → φ₋)) → (φ₊ × ψ₊) → ⊥
pq (f , g) (a , b) = q (f a) b
-- Multiplicative disjunction
_⅋_ : LProp → LProp → LProp
(lprop φ₊ φ₋ p) ⅋ (lprop ψ₊ ψ₋ q) = lprop ((ψ₋ → φ₊) × (φ₋ → ψ₊)) (φ₋ × ψ₋) pq where
pq : (φ₋ × ψ₋) → ((ψ₋ → φ₊) × (φ₋ → ψ₊)) → ⊥
pq (~a , ~b) (f , g) = q ~b (g ~a)
-- Linear implication
_⊸_ : LProp → LProp → LProp
p ⊸ q = (~ p) ⅋ q
⟦_⟧ : LProp → Set
⟦ lprop φ₊ _ _ ⟧ = φ₊
_⊢_ : LProp → LProp → Set
Γ ⊢ P = ⟦ Γ ⊸ P ⟧
----------
-- Here we prove that these connectives satisfy Hesselink's axioms and rules
-- for the multiplicative fragment of linear logic. See also:
-- W. H. Hesselink: Axioms and models of linear logic, in Formal Aspects of Computing, 1990)
-- Identity axiom.
axiom-1 : (P : LProp) → ⟦ P ⊸ P ⟧
axiom-1 (lprop φ₊ φ₋ p) =
(λ x → x) ,
(λ x → x)
-- Commutativity of ⅋.
axiom-2 : (P Q : LProp) → ⟦ (P ⅋ Q) ⊸ (Q ⅋ P) ⟧
axiom-2 (lprop φ₊ φ₋ p) (lprop ψ₊ ψ₋ q) =
(λ x → proj₂ x , proj₁ x) ,
(λ x → proj₂ x , proj₁ x)
-- Associativity of ⅋: the proof looks ugly, but we really just re-associate ×.
axiom-3 : (P Q R : LProp) → ⟦ ((P ⅋ Q) ⅋ R) ⊸ (P ⅋ (Q ⅋ R)) ⟧
axiom-3
(lprop φ₊ φ₋ p)
(lprop ψ₊ ψ₋ q)
(lprop ρ₊ ρ₋ r) =
(λ x → (proj₁ x , proj₁ (proj₂ x)) , proj₂ (proj₂ x)) ,
(λ x → (λ y → proj₁ (proj₁ x (proj₂ y)) (proj₁ y)) ,
(λ y → (λ (z : ρ₋) → proj₂ (proj₁ x z) y) ,
(λ z → proj₂ x (y , z))))
-- Finally, the analogues of the rules of inferece work as expected.
mp-rule : (P Q : LProp) → ⟦ P ⟧ → ⟦ P ⊸ Q ⟧ → ⟦ Q ⟧
mp-rule
(lprop φ₊ φ₋ p)
(lprop ψ₊ ψ₋ q) a ab =
proj₂ ab a
mp-rule-ctx : (Γ P Q : LProp) → ⟦ Γ ⅋ P ⟧ → ⟦ P ⊸ Q ⟧ → ⟦ Γ ⅋ Q ⟧
mp-rule-ctx
(lprop γ₊ γ₋ g)
(lprop φ₊ φ₋ p)
(lprop ψ₊ ψ₋ q) a ab =
(λ x → proj₁ a (proj₁ ab x)) ,
(λ x → proj₂ ab (proj₂ a x))
-- A deduction-like variant of the same result.
deduction : (Γ P Q : LProp) → (Γ ⅋ P) ⊢ Q → Γ ⊢ (P ⊸ Q)
deduction
(lprop γ₊ γ₋ _)
(lprop φ₊ φ₋ _)
(lprop ψ₊ ψ₋ _) gpq =
(λ pq → helper1 (proj₂ pq)) ,
(λ g → helper2 ,
(λ p → helper3 (λ _ → g) (λ _ → p))) where
helper1 : ψ₋ → γ₋
helper1 x = proj₁ (proj₁ gpq x)
helper2 : ψ₋ → φ₋
helper2 x = proj₂ (proj₁ gpq x)
helper3 : (φ₋ → γ₊) → (γ₋ → φ₊) → ψ₊
helper3 x y = proj₂ gpq (x , y)
----------
-- Here we prove the involutive property of negation.
open import Relation.Binary.PropositionalEquality
theorem : (P : LProp) → ~ (~ P) ≡ P
theorem (lprop φ₊ φ₋ x) = refl
-- 2. PROPOSITIONAL-EXPONENTIAL FRAGMENT
-- The "of course!" modality
! : LProp → LProp
! (lprop φ₊ φ₋ _) = lprop φ₊ (φ₊ → ⊥) λ z → z
-- The "why not?" modality
⁇ : LProp → LProp
⁇ (lprop φ₊ φ₋ _) = lprop (φ₋ → ⊥) φ₋ λ x y → y x
----------
-- Here we verify that the H-CLL axioms hold for the modalities.
-- A weakening axiom
axiom-1! : (P Q : LProp) → ⟦ P ⊸ (! Q ⊸ P) ⟧
axiom-1!
(lprop φ₊ φ₋ p)
(lprop ψ₊ ψ₋ q) =
proj₂ ,
λ y → (λ x _ → p x y) , (λ _ → y)
axiom-2! : (P Q : LProp) → ⟦ ! (P ⊸ Q) ⊸ (! P ⊸ ! Q) ⟧
axiom-2!
(lprop φ₊ φ₋ p)
(lprop ψ₊ ψ₋ q) =
(λ x y → proj₂ x (proj₂ y (proj₁ x))) ,
(λ x → (λ y z → y (proj₂ x z)) , proj₂ x)
axiom-3! : (P : LProp) → ⟦ ! P ⊸ P ⟧
axiom-3! (lprop φ₊ φ₋ p) = p , (λ x → x)
axiom-4! : (P : LProp) → ⟦ ! P ⊸ ! (! P) ⟧
axiom-4! (lprop φ₊ φ₋ p) = (λ x → x) , (λ x → x)
-- A contraction axiom
axiom-5! : (P Q : LProp) → ⟦ (! P ⊸ (! P ⊸ Q)) ⊸ (! P ⊸ Q) ⟧
axiom-5!
(lprop φ₊ φ₋ p)
(lprop ψ₊ ψ₋ q) =
(λ pq → proj₁ pq , proj₁ pq , proj₂ pq) ,
(λ x → (λ y z → proj₁ x (z , y) z) ,
(λ y → proj₂ (proj₂ x y) y))
-- Fortunately, the modal inference rule is trivially verified.
modal-rule : (P : LProp) → ⟦ P ⟧ → ⟦ ! P ⟧
modal-rule (lprop φ₊ φ₋ p) x = x
| {
"alphanum_fraction": 0.5219988055,
"avg_line_length": 26.1614583333,
"ext": "agda",
"hexsha": "2d08d17d16f985408819b542f975fa6e8edc9f56",
"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": "2768afc74841e49cfdb328fc2ff4123b1a008c54",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "guoshimin/linear-constructive",
"max_forks_repo_path": "src/Linear.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "2768afc74841e49cfdb328fc2ff4123b1a008c54",
"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": "guoshimin/linear-constructive",
"max_issues_repo_path": "src/Linear.agda",
"max_line_length": 92,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "2768afc74841e49cfdb328fc2ff4123b1a008c54",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "guoshimin/linear-constructive",
"max_stars_repo_path": "src/Linear.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2417,
"size": 5023
} |
module Data.Show where
import Prelude
import Data.Nat
import Data.Integer
import Data.String
import Data.List
open Prelude
open Data.Nat
open Data.Integer using (Int; pos; neg)
open Data.String
open Data.List hiding (_++_)
showNat : Nat -> String
showNat zero = "0"
showNat n = fromList $ reverse $ toList $ show n
where
digit : Nat -> String
digit 0 = "0"
digit 1 = "1"
digit 2 = "2"
digit 3 = "3"
digit 4 = "4"
digit 5 = "5"
digit 6 = "6"
digit 7 = "7"
digit 8 = "8"
digit 9 = "9"
digit _ = "?"
show : Nat -> String
show zero = ""
show n = digit (mod n 10) ++ show (div n 10)
showInt : Int -> String
showInt (pos n) = showNat n
showInt (neg n) = "-" ++ showNat (suc n)
| {
"alphanum_fraction": 0.5871313673,
"avg_line_length": 18.1951219512,
"ext": "agda",
"hexsha": "cfc3ec30d57c1e585aaa3c7440ab563d4e9e4090",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Show.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Show.agda",
"max_line_length": 51,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Show.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": 249,
"size": 746
} |
{-# OPTIONS --cubical --no-import-sorts #-}
open import Agda.Primitive renaming (_⊔_ to ℓ-max; lsuc to ℓ-suc; lzero to ℓ-zero)
module Number.Postulates where
private
variable
ℓ ℓ' ℓ'' : Level
open import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc)
open import Cubical.Relation.Nullary.Base -- ¬_
open import Cubical.Relation.Binary.Base -- Rel
open import Function.Base using (_∋_)
ℕℓ = ℓ-zero
ℕℓ' = ℓ-zero
postulate
ℤℓ ℤℓ' : Level
ℚℓ ℚℓ' : Level
ℝℓ ℝℓ' : Level
ℂℓ ℂℓ' : Level
open import Number.Structures
open import Number.Bundles
import Number.Inclusions
import MoreAlgebra
module ℕ* where
import Cubical.Data.Nat as Nat
import Cubical.Data.Nat.Order as Order
open import Agda.Builtin.Nat using () renaming (Nat to ℕ) public
module Postulates where
postulate
min max : ℕ → ℕ → ℕ
isROrderedCommSemiring : IsROrderedCommSemiring
(Order._<_)
(Order._≤_)
((MoreAlgebra.Definitions._#'_ {_<_ = Order._<_}))
(min)
(max)
(Nat.zero)
(1)
(Nat._+_)
(Nat._*_)
module Bundle = ROrderedCommSemiring {ℕℓ} {ℕℓ'}
Bundle = ROrderedCommSemiring {ℕℓ} {ℕℓ'}
Carrier = ℕ
bundle : Bundle
bundle = (record
{ Carrier = ℕ
; _<_ = Order._<_
; _≤_ = Order._≤_
; _#_ = (MoreAlgebra.Definitions._#'_ { _<_ = Order._<_ })
; min = Postulates.min
; max = Postulates.max
; 0f = Nat.zero
; 1f = (Nat.suc Nat.zero)
; _+_ = Nat._+_
; _·_ = Nat._*_
; isROrderedCommSemiring = Postulates.isROrderedCommSemiring
})
open import Cubical.Data.Nat.Order using (_≤_; _<_) public
import MoreAlgebra
open MoreAlgebra.Definitions using (_#'_) public
open import Agda.Builtin.Nat using () renaming (zero to 0f) public
-- _<_ = Bundle._<_ bundle
-- _≤_ = Bundle._≤_ bundle
_#_ = Bundle._#_ bundle
min = Bundle.min bundle
max = Bundle.max bundle
-- 0f = Bundle.0f bundle
1f = Bundle.1f bundle
_+_ = Bundle._+_ bundle
_·_ = Bundle._·_ bundle
isROrderedCommSemiring = Bundle.isROrderedCommSemiring bundle
abs : ℕ → ℕ
abs x = x
open IsROrderedCommSemiring isROrderedCommSemiring public
module ℕ = ℕ* hiding (ℕ)
module ℕⁿ = ℕ*
renaming
( Carrier to Carrierⁿ
; _<_ to _<ⁿ_
; _≤_ to _≤ⁿ_
; _#_ to _#ⁿ_
; min to minⁿ
; max to maxⁿ
; 0f to 0ⁿ
; 1f to 1ⁿ
; _+_ to _+ⁿ_
; _·_ to _·ⁿ_
; isROrderedCommSemiring to isROrderedCommSemiringⁿ
; abs to absⁿ
)
module ℤ* where
module Postulates where
postulate
ℤ : Type ℤℓ
_<_ _≤_ _#_ : Rel ℤ ℤ ℤℓ'
min max : ℤ → ℤ → ℤ
0f 1f : ℤ
_+_ _·_ : ℤ → ℤ → ℤ
-_ : ℤ → ℤ
abs : ℤ → ℤ
abs x = max x (- x)
postulate
isROrderedCommRing : IsROrderedCommRing _<_ _≤_ _#_ min max 0f 1f _+_ _·_ -_
isAbsOrderedCommRing : IsAbsOrderedCommRing _<_ _≤_ _#_ min max 0f 1f _+_ _·_ -_ abs
module Bundle = ROrderedCommRing {ℤℓ} {ℤℓ'}
Bundle = ROrderedCommRing {ℤℓ} {ℤℓ'}
open Postulates public
Carrier = ℤ
bundle : Bundle
bundle = (record
{ Carrier = ℤ
; _<_ = _<_
; _≤_ = _≤_
; _#_ = _#_
; min = min
; max = max
; 0f = 0f
; 1f = 1f
; _+_ = _+_
; _·_ = _·_
; -_ = -_
; isROrderedCommRing = isROrderedCommRing
; isAbsOrderedCommRing = isAbsOrderedCommRing
})
open IsROrderedCommRing isROrderedCommRing public
-- abs : ℤ → ℤ
-- abs x = max x (- x)
module ℤ = ℤ* hiding (ℤ)
module ℤᶻ = ℤ*
renaming
( Carrier to Carrierᶻ
; _<_ to _<ᶻ_
; _≤_ to _≤ᶻ_
; _#_ to _#ᶻ_
; min to minᶻ
; max to maxᶻ
; 0f to 0ᶻ
; 1f to 1ᶻ
; _+_ to _+ᶻ_
; _·_ to _·ᶻ_
; -_ to -ᶻ_
; isROrderedCommRing to isROrderedCommRingᶻ
; abs to absᶻ
)
module ℚ* where
module Postulates where
postulate
ℚ : Type ℚℓ
_<_ _≤_ _#_ : Rel ℚ ℚ ℚℓ'
min max : ℚ → ℚ → ℚ
0f 1f : ℚ
_+_ _·_ : ℚ → ℚ → ℚ
-_ : ℚ → ℚ
_⁻¹ : (x : ℚ) → {{ x # 0f }} → ℚ
abs : ℚ → ℚ
abs x = max x (- x)
postulate
isROrderedField : IsROrderedField _<_ _≤_ _#_ min max 0f 1f _+_ _·_ -_ _⁻¹
isAbsOrderedCommRing : IsAbsOrderedCommRing _<_ _≤_ _#_ min max 0f 1f _+_ _·_ -_ abs
module Bundle = ROrderedField {ℚℓ} {ℚℓ'}
Bundle = ROrderedField {ℚℓ} {ℚℓ'}
open Postulates public
Carrier = ℚ
bundle : Bundle
bundle = (record
{ Carrier = ℚ
; _<_ = _<_
; _≤_ = _≤_
; _#_ = _#_
; min = min
; max = max
; 0f = 0f
; 1f = 1f
; _+_ = _+_
; _·_ = _·_
; -_ = -_
; _⁻¹ = _⁻¹
; isROrderedField = isROrderedField
; isAbsOrderedCommRing = isAbsOrderedCommRing
})
-- abs : ℚ → ℚ
-- abs x = max x (- x)
open IsROrderedField isROrderedField public
module ℚ = ℚ* hiding (ℚ)
module ℚᶠ = ℚ*
renaming
( Carrier to Carrierᶠ
; _<_ to _<ᶠ_
; _≤_ to _≤ᶠ_
; _#_ to _#ᶠ_
; min to minᶠ
; max to maxᶠ
; 0f to 0ᶠ
; 1f to 1ᶠ
; _+_ to _+ᶠ_
; _·_ to _·ᶠ_
; -_ to -ᶠ_
; _⁻¹ to _⁻¹ᶠ
; isROrderedField to isROrderedFieldᶠ
; abs to absᶠ
)
module ℝ* where
private
module Postulates where
postulate
ℝ : Type ℝℓ
_<_ _≤_ _#_ : Rel ℝ ℝ ℝℓ'
min max : ℝ → ℝ → ℝ
0f 1f : ℝ
_+_ _·_ : ℝ → ℝ → ℝ
-_ : ℝ → ℝ
_⁻¹ : (x : ℝ) → {{ x # 0f }} → ℝ
abs : ℝ → ℝ
abs x = max x (- x)
postulate
isROrderedField : IsROrderedField _<_ _≤_ _#_ min max 0f 1f _+_ _·_ -_ _⁻¹
isAbsOrderedCommRing : IsAbsOrderedCommRing _<_ _≤_ _#_ min max 0f 1f _+_ _·_ -_ abs
-- square root on ℝ₀⁺
sqrt : (x : ℝ) → {{0f ≤ x}} → ℝ
0≤sqrt : ∀ x → {{p : 0f ≤ x}} → 0f ≤ sqrt x {{p}}
sqrt-reflects-≡ : ∀ x y → {{px : 0f ≤ x}} → {{py : 0f ≤ y}} → sqrt x {{px}} ≡ sqrt y {{py}} → x ≡ y
sqrt-inv : ∀ x → {{p : 0f ≤ x}} → {{q : 0f ≤ (x · x)}}→ sqrt (x · x) {{q}} ≡ x
sqrt²-id : ∀ x → {{p : 0f ≤ x}} → sqrt x {{p}} · sqrt x {{p}} ≡ x
module Bundle = ROrderedField {ℝℓ} {ℝℓ'}
Bundle = ROrderedField {ℝℓ} {ℝℓ'}
open Postulates public
Carrier = ℝ
bundle : Bundle
bundle = (record
{ Carrier = ℝ
; _<_ = _<_
; _≤_ = _≤_
; _#_ = _#_
; min = min
; max = max
; 0f = 0f
; 1f = 1f
; _+_ = _+_
; _·_ = _·_
; -_ = -_
; _⁻¹ = _⁻¹
; isROrderedField = isROrderedField
; isAbsOrderedCommRing = isAbsOrderedCommRing
})
-- abs : ℝ → ℝ
-- abs x = max x (- x)
open IsROrderedField isROrderedField public
module ℝ = ℝ* hiding (ℝ)
module ℝʳ = ℝ*
renaming
( Carrier to Carrierʳ
; _<_ to _<ʳ_
; _≤_ to _≤ʳ_
; _#_ to _#ʳ_
; min to minʳ
; max to maxʳ
; 0f to 0ʳ
; 1f to 1ʳ
; _+_ to _+ʳ_
; _·_ to _·ʳ_
; -_ to -ʳ_
; _⁻¹ to _⁻¹ʳ
; isROrderedField to isROrderedFieldʳ
; isRField to isRFieldʳ
; Bundle to Bundleʳ
; bundle to bundleʳ
; abs to absʳ
)
module ℂ* where
open ℝʳ
module Postulates where
postulate
ℂ : Type ℂℓ
_#_ : Rel ℂ ℂ ℂℓ'
0f 1f : ℂ
_+_ _·_ : ℂ → ℂ → ℂ
-_ : ℂ → ℂ
_⁻¹ : (x : ℂ) → {{ x # 0f }} → ℂ
isRField : IsRField _#_ 0f 1f _+_ _·_ -_ _⁻¹
abs : ℂ → ℝ
0≤abs : ∀ x → 0ʳ ≤ʳ abs x
abs-preserves-0 : ∀ x → x ≡ 0f → abs x ≡ 0ʳ
abs-reflects-0 : ∀ x → abs x ≡ 0ʳ → x ≡ 0f
abs-preserves-· : ∀ x y → abs (x · y) ≡ (abs x) ·ʳ (abs y)
abs-preserves-#0 : ∀ x → x # 0f → abs x #ʳ 0ʳ
abs-reflects-#0 : ∀ x → abs x #ʳ 0ʳ → x # 0f
module Bundle = RField {ℂℓ} {ℂℓ'}
Bundle = RField {ℂℓ} {ℂℓ'}
open Postulates public
Carrier = ℂ
bundle : Bundle
bundle = (record
{ Carrier = ℂ
; _#_ = _#_
; 0f = 0f
; 1f = 1f
; _+_ = _+_
; _·_ = _·_
; -_ = -_
; _⁻¹ = _⁻¹
; isRField = isRField
})
open IsRField isRField public
module ℂ = ℂ* hiding (ℂ)
module ℂᶜ = ℂ*
renaming
( Carrier to Carrierᶜ
; _#_ to _#ᶜ_
; 0f to 0ᶜ
; 1f to 1ᶜ
; _+_ to _+ᶜ_
; _·_ to _·ᶜ_
; -_ to -ᶜ_
; _⁻¹ to _⁻¹ᶜ
; isRField to isRFieldᶜ
; abs to absᶜ
)
Isℕ↪ℤ = Number.Inclusions.IsROrderedCommSemiringInclusion
Isℕ↪ℚ = Number.Inclusions.IsROrderedCommSemiringInclusion
Isℕ↪ℂ = Number.Inclusions.IsRCommSemiringInclusion
Isℕ↪ℝ = Number.Inclusions.IsROrderedCommSemiringInclusion
Isℤ↪ℚ = Number.Inclusions.IsROrderedCommRingInclusion
Isℤ↪ℝ = Number.Inclusions.IsROrderedCommRingInclusion
Isℤ↪ℂ = Number.Inclusions.IsRCommRingInclusion
Isℚ↪ℝ = Number.Inclusions.IsROrderedFieldInclusion
Isℚ↪ℂ = Number.Inclusions.IsRFieldInclusion
Isℝ↪ℂ = Number.Inclusions.IsRFieldInclusion
module Isℕ↪ℤ = Number.Inclusions.IsROrderedCommSemiringInclusion
module Isℕ↪ℚ = Number.Inclusions.IsROrderedCommSemiringInclusion
module Isℕ↪ℂ = Number.Inclusions.IsRCommSemiringInclusion
module Isℕ↪ℝ = Number.Inclusions.IsROrderedCommSemiringInclusion
module Isℤ↪ℚ = Number.Inclusions.IsROrderedCommRingInclusion
module Isℤ↪ℝ = Number.Inclusions.IsROrderedCommRingInclusion
module Isℤ↪ℂ = Number.Inclusions.IsRCommRingInclusion
module Isℚ↪ℝ = Number.Inclusions.IsROrderedFieldInclusion
module Isℚ↪ℂ = Number.Inclusions.IsRFieldInclusion
module Isℝ↪ℂ = Number.Inclusions.IsRFieldInclusion
module _ where
open ℕ* using (ℕ)
open ℤ* using (ℤ)
open ℚ* using (ℚ)
open ℝ* using (ℝ)
open ℂ* using (ℂ)
postulate
ℕ↪ℤ : ℕ → ℤ
ℕ↪ℚ : ℕ → ℚ
ℕ↪ℂ : ℕ → ℂ
ℕ↪ℝ : ℕ → ℝ
ℤ↪ℚ : ℤ → ℚ
ℤ↪ℝ : ℤ → ℝ
ℤ↪ℂ : ℤ → ℂ
ℚ↪ℝ : ℚ → ℝ
ℚ↪ℂ : ℚ → ℂ
ℝ↪ℂ : ℝ → ℂ
ℕ↪ℤinc : Isℕ↪ℤ (record {ℕ*}) (record {ℤ*}) ℕ↪ℤ
ℕ↪ℚinc : Isℕ↪ℚ (record {ℕ*}) (record {ℚ*}) ℕ↪ℚ
ℕ↪ℂinc : Isℕ↪ℂ (record {ℕ*}) (record {ℂ*}) ℕ↪ℂ
ℕ↪ℝinc : Isℕ↪ℝ (record {ℕ*}) (record {ℝ*}) ℕ↪ℝ
ℤ↪ℚinc : Isℤ↪ℚ (record {ℤ*}) (record {ℚ*}) ℤ↪ℚ
ℤ↪ℝinc : Isℤ↪ℝ (record {ℤ*}) (record {ℝ*}) ℤ↪ℝ
ℤ↪ℂinc : Isℤ↪ℂ (record {ℤ*}) (record {ℂ*}) ℤ↪ℂ
ℚ↪ℝinc : Isℚ↪ℝ (record {ℚ*}) (record {ℝ*}) ℚ↪ℝ
ℚ↪ℂinc : Isℚ↪ℂ (record {ℚ*}) (record {ℂ*}) ℚ↪ℂ
ℝ↪ℂinc : Isℝ↪ℂ (record {ℝ*}) (record {ℂ*}) ℝ↪ℂ
{-
ℕ↪ℤinc : Isℕ↪ℤ ℕ.bundle (record { ℤ.Bundle ℤ.bundle }) ℕ↪ℤ
ℕ↪ℚinc : Isℕ↪ℚ ℕ.bundle (record { ℚ.Bundle ℚ.bundle }) ℕ↪ℚ
ℕ↪ℂinc : Isℕ↪ℂ ℕ.bundle ℂ.bundle ℕ↪ℂ
ℕ↪ℝinc : Isℕ↪ℝ ℕ.bundle (record { ℝ.Bundle ℝ.bundle }) ℕ↪ℝ
ℤ↪ℚinc : Isℤ↪ℚ ℤ.bundle (record { ℚ.Bundle ℚ.bundle }) ℤ↪ℚ
ℤ↪ℝinc : Isℤ↪ℝ ℤ.bundle (record { ℝ.Bundle ℝ.bundle }) ℤ↪ℝ
ℤ↪ℂinc : Isℤ↪ℂ ℤ.bundle ℂ.bundle ℤ↪ℂ
ℚ↪ℝinc : Isℚ↪ℝ ℚ.bundle (record { ℝ.Bundle ℝ.bundle }) ℚ↪ℝ
ℚ↪ℂinc : Isℚ↪ℂ (record { ℚ.Bundle ℚ.bundle }) (record { ℂ.Bundle ℂ.bundle }) ℚ↪ℂ
ℝ↪ℂinc : Isℝ↪ℂ (record { ℝ.Bundle ℝ.bundle }) (record { ℂ.Bundle ℂ.bundle }) ℝ↪ℂ
-}
| {
"alphanum_fraction": 0.5458781362,
"avg_line_length": 25.4794520548,
"ext": "agda",
"hexsha": "bcba043e72bc68cb9fb6467a96ffa03a894526ec",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mchristianl/synthetic-reals",
"max_forks_repo_path": "agda/Number/Postulates.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "mchristianl/synthetic-reals",
"max_issues_repo_path": "agda/Number/Postulates.agda",
"max_line_length": 107,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mchristianl/synthetic-reals",
"max_stars_repo_path": "agda/Number/Postulates.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-19T12:15:21.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-07-31T18:15:26.000Z",
"num_tokens": 4969,
"size": 11160
} |
{-# OPTIONS --rewriting --confluence-check #-}
open import Agda.Builtin.Equality
open import Agda.Builtin.Equality.Rewrite
postulate
A : Set
a b : A
f : A → A
rew₁ : f a ≡ b
rew₂ : f ≡ λ _ → a
{-# REWRITE rew₁ #-}
{-# REWRITE rew₂ #-}
| {
"alphanum_fraction": 0.6129032258,
"avg_line_length": 16.5333333333,
"ext": "agda",
"hexsha": "345e1cf559045dd78cfed971f643962d3afdde6a",
"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/Issue3810a.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/Issue3810a.agda",
"max_line_length": 46,
"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/Issue3810a.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": 86,
"size": 248
} |
{-# OPTIONS --no-termination-check #-}
module qsort where
_o_ : {a : Set} -> {b : Set} -> {c : Set} -> (b -> c) -> (a -> b) -> a -> c
f o g = \x -> f (g x)
data Bool : Set where
true : Bool
false : Bool
not : Bool -> Bool
not true = false
not false = true
if_then_else_ : {a : Set} -> Bool -> a -> a -> a
if true then x else _ = x
if false then _ else y = y
data List (a : Set) : Set where
nil : List a
_::_ : a -> List a -> List a
listrec : {a : Set} -> List a -> (a -> List a -> List a) -> List a -> List a
listrec e _ nil = e
listrec e b (x :: xs) = b x (listrec e b xs)
filter : {a : Set} -> (a -> Bool) -> List a -> List a
filter f = listrec nil (\x ih -> if (f x) then (x :: ih) else ih)
_++_ : {a : Set} -> List a -> List a -> List a
nil ++ ys = ys
(x :: xs) ++ ys = x :: (xs ++ ys)
data Nat : Set where
zero : Nat
succ : Nat -> Nat
_+_ : Nat -> Nat -> Nat
zero + m = m
succ n + m = succ (n + m)
_*_ : Nat -> Nat -> Nat
zero * m = zero
succ n * m = m + (n * m)
one : Nat
one = succ zero
fact : Nat -> Nat
fact zero = one
fact (succ n) = succ n * fact n
_<_ : Nat -> Nat -> Bool
zero < zero = false
zero < n = true
n < zero = false
(succ n) < (succ m) = n < m
--
qsort : {a : Set} -> (a -> a -> Bool) -> List a -> List a
qsort f nil = nil
qsort f (x :: xs) = (qsort f (filter (not o (f x)) xs)) ++
(x :: (qsort f (filter (f x) xs)))
| {
"alphanum_fraction": 0.4559111692,
"avg_line_length": 23.196969697,
"ext": "agda",
"hexsha": "ddefe0dc05e540b6552a3d70c5dcfe50a4e3019e",
"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/qsort.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/qsort.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": "test/succeed/qsort.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": 572,
"size": 1531
} |
{-# OPTIONS --safe --experimental-lossy-unification #-}
module Cubical.Algebra.Polynomials.Multivariate.EquivCarac.A[X]X-A where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Data.Nat
open import Cubical.Data.Vec
open import Cubical.Data.Sigma
open import Cubical.Data.FinData
open import Cubical.Algebra.Ring
open import Cubical.Algebra.CommRing
open import Cubical.Algebra.CommRing.FGIdeal
open import Cubical.Algebra.CommRing.QuotientRing
open import Cubical.Algebra.Polynomials.Multivariate.Base
open import Cubical.Algebra.CommRing.Instances.Int renaming (ℤCommRing to ℤCR)
open import Cubical.Algebra.CommRing.Instances.MultivariatePoly
open import Cubical.Algebra.CommRing.Instances.MultivariatePoly-Quotient
open import Cubical.Algebra.CommRing.Instances.MultivariatePoly-notationZ
open import Cubical.Relation.Nullary
open import Cubical.HITs.SetQuotients as SQ
open import Cubical.HITs.PropositionalTruncation as PT
private variable
ℓ : Level
-----------------------------------------------------------------------------
-- Functions
module Properties-Equiv-QuotientXn-A
(Ar@(A , Astr) : CommRing ℓ)
where
private
A[X] : CommRing ℓ
A[X] = A[X1,···,Xn] Ar 1
A[x] : Type ℓ
A[x] = A[x1,···,xn] Ar 1
A[X]/X : CommRing ℓ
A[X]/X = A[X1,···,Xn]/<Xkʲ> Ar 1 0 1
A[x]/x : Type ℓ
A[x]/x = A[x1,···,xn]/<xkʲ> Ar 1 0 1
open CommRingStr Astr using ()
renaming
( 0r to 0A
; 1r to 1A
; _+_ to _+A_
; -_ to -A_
; _·_ to _·A_
; +Assoc to +AAssoc
; +Identity to +AIdentity
; +Lid to +ALid
; +Rid to +ARid
; +Inv to +AInv
; +Linv to +ALinv
; +Rinv to +ARinv
; +Comm to +AComm
; ·Assoc to ·AAssoc
; ·Identity to ·AIdentity
; ·Lid to ·ALid
; ·Rid to ·ARid
; ·Rdist+ to ·ARdist+
; ·Ldist+ to ·ALdist+
; is-set to isSetA )
open CommRingStr (snd A[X] ) using ()
renaming
( 0r to 0PA
; 1r to 1PA
; _+_ to _+PA_
; -_ to -PA_
; _·_ to _·PA_
; +Assoc to +PAAssoc
; +Identity to +PAIdentity
; +Lid to +PALid
; +Rid to +PARid
; +Inv to +PAInv
; +Linv to +PALinv
; +Rinv to +PARinv
; +Comm to +PAComm
; ·Assoc to ·PAAssoc
; ·Identity to ·PAIdentity
; ·Lid to ·PALid
; ·Rid to ·PARid
; ·Comm to ·PAComm
; ·Rdist+ to ·PARdist+
; ·Ldist+ to ·PALdist+
; is-set to isSetPA )
open CommRingStr (snd A[X]/X) using ()
renaming
( 0r to 0PAI
; 1r to 1PAI
; _+_ to _+PAI_
; -_ to -PAI_
; _·_ to _·PAI_
; +Assoc to +PAIAssoc
; +Identity to +PAIIdentity
; +Lid to +PAILid
; +Rid to +PAIRid
; +Inv to +PAIInv
; +Linv to +PAILinv
; +Rinv to +PAIRinv
; +Comm to +PAIComm
; ·Assoc to ·PAIAssoc
; ·Identity to ·PAIIdentity
; ·Lid to ·PAILid
; ·Rid to ·PAIRid
; ·Rdist+ to ·PAIRdist+
; ·Ldist+ to ·PAILdist+
; is-set to isSetPAI )
open RingTheory
-----------------------------------------------------------------------------
-- Direct sens
A[x]→A : A[x] → A
A[x]→A = Poly-Rec-Set.f _ _ _ isSetA
0A
base-trad
_+A_
+AAssoc
+ARid
+AComm
base-neutral-eq
base-add-eq
where
base-trad : _
base-trad (zero ∷ []) a = a
base-trad (suc k ∷ []) a = 0A
base-neutral-eq : _
base-neutral-eq (zero ∷ []) = refl
base-neutral-eq (suc k ∷ []) = refl
base-add-eq : _
base-add-eq (zero ∷ []) a b = refl
base-add-eq (suc k ∷ []) a b = +ARid _
A[x]→A-pres1 : A[x]→A 1PA ≡ 1A
A[x]→A-pres1 = refl
A[x]→A-pres+ : (x y : A[x]) → (A[x]→A (x +PA y)) ≡ A[x]→A x +A A[x]→A y
A[x]→A-pres+ x y = refl
A[x]→A-pres· : (x y : A[x]) → (A[x]→A (x ·PA y)) ≡ A[x]→A x ·A A[x]→A y
A[x]→A-pres· = Poly-Ind-Prop.f _ _ _
(λ x u v i y → isSetA _ _ (u y) (v y) i)
(λ y → sym (0LeftAnnihilates (CommRing→Ring Ar) _))
(λ v a → Poly-Ind-Prop.f _ _ _ (λ _ → isSetA _ _)
(sym (0RightAnnihilates (CommRing→Ring Ar) _))
(λ v' a' → base-eq a a' v v')
(λ {U V} ind-U ind-V → cong₂ _+A_ ind-U ind-V ∙ sym (·ARdist+ _ _ _)))
λ {U V} ind-U ind-V y → cong₂ _+A_ (ind-U y) (ind-V y) ∙ sym (·ALdist+ _ _ _)
where
base-eq : (a a' : A) → (v v' : Vec ℕ 1) → (A[x]→A (base v a ·PA base v' a')) ≡ A[x]→A (base v a) ·A A[x]→A (base v' a')
base-eq a a' (zero ∷ []) (zero ∷ []) = refl
base-eq a a' (zero ∷ []) (suc k' ∷ []) = sym (0RightAnnihilates (CommRing→Ring Ar) _)
base-eq a a' (suc k ∷ []) (k' ∷ []) = sym (0LeftAnnihilates (CommRing→Ring Ar) _)
A[X]→A : CommRingHom A[X] Ar
fst A[X]→A = A[x]→A
snd A[X]→A = makeIsRingHom A[x]→A-pres1 A[x]→A-pres+ A[x]→A-pres·
A[x]→A-cancel : (k : Fin 1) → A[x]→A (<Xkʲ> Ar 1 0 1 k) ≡ 0A
A[x]→A-cancel zero = refl
A[X]/X→A : CommRingHom A[X]/X Ar
A[X]/X→A = Quotient-FGideal-CommRing-CommRing.f A[X] Ar A[X]→A (<Xkʲ> Ar 1 0 1) A[x]→A-cancel
A[x]/x→A : A[x]/x → A
A[x]/x→A = fst A[X]/X→A
-----------------------------------------------------------------------------
-- Converse sens
A→A[x] : A → A[x]
A→A[x] a = base (0 ∷ []) a
A→A[x]-pres+ : (a a' : A) → A→A[x] (a +A a') ≡ A→A[x] a +PA A→A[x] a'
A→A[x]-pres+ a a' = sym (base-poly+ (0 ∷ []) a a')
A→A[x]/x : A → A[x]/x
A→A[x]/x = [_] ∘ A→A[x]
A→A[x]/x-pres+ : (a a' : A) → A→A[x]/x (a +A a') ≡ A→A[x]/x a +PAI A→A[x]/x a'
A→A[x]/x-pres+ a a' = cong [_] (A→A[x]-pres+ a a')
-----------------------------------------------------------------------------
-- Section sens
e-sect : (a : A) → A[x]→A (A→A[x] a) ≡ a
e-sect a = refl
-----------------------------------------------------------------------------
-- Retraction sens
open IsRing
e-retr : (x : A[x]/x) → A→A[x]/x (A[x]/x→A x) ≡ x
e-retr = SQ.elimProp (λ x → isSetPAI _ _)
(Poly-Ind-Prop.f _ _ _ (λ x → isSetPAI _ _)
(cong [_] (base-0P _))
(λ v a → base-eq a v)
λ {U V} ind-U ind-V → cong [_] ((A→A[x]-pres+ _ _)) ∙ cong₂ _+PAI_ ind-U ind-V)
where
base-eq : (a : A) → (v : Vec ℕ 1) → A→A[x]/x (A[x]/x→A [ (base v a) ]) ≡ [ (base v a) ]
base-eq a (zero ∷ []) = cong [_] refl
base-eq a (suc k ∷ []) = eq/ (base (0 ∷ []) 0A) (base (suc k ∷ []) a) ∣ ((λ x → base (k ∷ []) (-A a)) , helper) ∣₁
where
helper : _
helper = cong (λ X → X poly+ base (suc k ∷ []) (-A a)) (base-0P _)
∙ +PALid _
∙ sym (+PARid _
∙ cong₂ base
(cong (λ X → X ∷ []) (+-suc _ _ ∙ +-zero _))
(·ARid _))
module _
(Ar@(A , Astr) : CommRing ℓ)
where
open Iso
open Properties-Equiv-QuotientXn-A Ar
Equiv-A[X]/X-A : CommRingEquiv (A[X1,···,Xn]/<Xkʲ> Ar 1 0 1) Ar
fst Equiv-A[X]/X-A = isoToEquiv is
where
is : Iso (A[x1,···,xn]/<xkʲ> Ar 1 0 1) A
fun is = A[x]/x→A
inv is = A→A[x]/x
rightInv is = e-sect
leftInv is = e-retr
snd Equiv-A[X]/X-A = snd A[X]/X→A
Equiv-ℤ[X]/X-ℤ : RingEquiv (CommRing→Ring ℤ[X]/X) (CommRing→Ring ℤCR)
Equiv-ℤ[X]/X-ℤ = Equiv-A[X]/X-A ℤCR
| {
"alphanum_fraction": 0.479185579,
"avg_line_length": 29.8875968992,
"ext": "agda",
"hexsha": "9b735697145b96f907745fad55b89cd137befa43",
"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": "b6fbca9e83e553c5c2e4a16a2df7f9e9039034dc",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "xekoukou/cubical",
"max_forks_repo_path": "Cubical/Algebra/Polynomials/Multivariate/EquivCarac/A[X]X-A.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b6fbca9e83e553c5c2e4a16a2df7f9e9039034dc",
"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": "xekoukou/cubical",
"max_issues_repo_path": "Cubical/Algebra/Polynomials/Multivariate/EquivCarac/A[X]X-A.agda",
"max_line_length": 131,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "b6fbca9e83e553c5c2e4a16a2df7f9e9039034dc",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "xekoukou/cubical",
"max_stars_repo_path": "Cubical/Algebra/Polynomials/Multivariate/EquivCarac/A[X]X-A.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2939,
"size": 7711
} |
module builtinInModule where
module Str where
{-# BUILTIN STRING S #-}
primitive primStringAppend : S → S → S
| {
"alphanum_fraction": 0.6949152542,
"avg_line_length": 13.1111111111,
"ext": "agda",
"hexsha": "9fc2efa35794812076d5f4580281a1cc0b071efc",
"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": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "alhassy/agda",
"max_forks_repo_path": "test/Succeed/builtinInModule.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "alhassy/agda",
"max_issues_repo_path": "test/Succeed/builtinInModule.agda",
"max_line_length": 40,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "alhassy/agda",
"max_stars_repo_path": "test/Succeed/builtinInModule.agda",
"max_stars_repo_stars_event_max_datetime": "2021-07-07T10:49:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-07-07T10:49:57.000Z",
"num_tokens": 31,
"size": 118
} |
{-# OPTIONS --without-K #-}
{- In this module, we derive the truncations of
* a truncated type,
* the unit type,
* dependent sums (and product types),
* path spaces
given truncations of their components.
More commonly later on, we will be given a truncation operator Tr
that returns a truncation for any given input type (at a fixed level).
Instead of trying to show, say,
Tr (Σ A (B ∘ cons (Tr A))) ≃ Σ (Tr A) (Tr ∘ B),
directly, it turns out to be much easier to just *derive* the truncation on
the left-hand side from Tr A and Tr ∘ B and then use unicity of truncation to
deduce the above equivalence. Significant parts of the unicity proof would be
duplicated in any direct proof of equivalence, while this approach allows us
to avoid a number of manual elimination and propositional reduction steps. -}
module Universe.Trunc.TypeConstructors where
open import lib.Basics
open import lib.NType2
open import lib.Equivalences2
open import lib.types.Unit
open import lib.types.Nat hiding (_+_)
open import lib.types.Pi
open import lib.types.Sigma
open import lib.types.Paths
open import Universe.Utility.General
open import Universe.Utility.TruncUniverse
open import Universe.Trunc.Universal
open import Universe.Trunc.Basics
open trunc-ty
open trunc-props
module trunc-self {i} {n : ℕ₋₂} (A : n -Type i) where
trunc : ∀ {j} → trunc-ty n ⟦ A ⟧ j
trunc = record
{ type = A
; cons = idf _
; univ = λ _ → snd (ide _) }
module trunc-⊤ {n : ℕ₋₂} = trunc-self {n = n} ⊤-≤
-- *** Lemma 6.9 ***
{- The truncation of a dependent sum type (where the family depends
only on the truncation of the first component) is the dependent sums
of the truncations. -}
module trunc-Σ {ia ib j} {n : ℕ₋₂} {A : Type ia}
(TrA : trunc-ty n A (ia ⊔ ib ⊔ j))
{B : ⟦ type TrA ⟧ → Type ib}
(TrB : (ta : ⟦ type TrA ⟧) → trunc-ty n (B ta) (ib ⊔ j)) where
trunc : trunc-ty n (Σ A (B ∘ cons TrA)) (ib ⊔ j)
trunc = record
{ type = Σ-≤ (type TrA) (type ∘ TrB)
; cons = λ {(a , b) → (cons TrA a , cons (TrB (cons TrA a)) b)}
; univ = snd ∘ e } where
e : (U : n -Type _) → _
e U =
(⟦ Σ-≤ (type TrA) (type ∘ TrB) ⟧ → ⟦ U ⟧) ≃⟨ curry-equiv ⟩
((ta : ⟦ type TrA ⟧) → ⟦ type (TrB ta) ⟧ → ⟦ U ⟧) ≃⟨ equiv-Π-r eb ⟩
((ta : ⟦ type TrA ⟧) → B ta → ⟦ U ⟧) ≃⟨ ea ⟩
((a : A) → B (cons TrA a) → ⟦ U ⟧) ≃⟨ curry-equiv ⁻¹ ⟩
(Σ A (B ∘ cons TrA) → ⟦ U ⟧) ≃∎ where
ea = dup {j = ib ⊔ j} TrA (λ ta → B ta →-≤ U)
eb = λ ta → up {j = ib ⊔ j} (TrB ta) U
-- Products are a special case of dependent sums.
module trunc-× {ia ib j} {n : ℕ₋₂} {A : Type ia} {B : Type ib}
(TrA : trunc-ty n A (ia ⊔ ib ⊔ j))
(TrB : trunc-ty n B (ib ⊔ j)) =
trunc-Σ {j = j} TrA (λ _ → TrB)
-- *** Lemma 6.10 ***
{- The n-truncation of a path space is the path space of the (n+1)-truncation.
The use of the encode-decode method is the reason why we have to assume
elimination into Type (lsucc i): large recursion is used to define
the type of codes. -}
module trunc-path {i j} {n : ℕ₋₂} {A : Type i} (TrA : trunc-ty (S n) A (lsucc (i ⊔ j))) where
private
l : ULevel
l = i ⊔ j
TrAA : trunc-ty (S n) (A × A) (lsucc l)
TrAA = trunc-×.trunc {j = lsucc l} TrA TrA
module MA = trunc-props {j = lsucc l} {k = l} TrA
module MAA = trunc-props {j = lsucc l} {k = l} TrAA
-- module MAL = trunc-elim {j = _} TrAA
{- There is some Yoneda hidden here that would enable us to express the final
equivalence e neatly as a sequence of trivial steps like in trunc-Σ;
unfortunately we lack the necessary category theoretic framework
in this code base. -}
module code (U : n -Type l) where
abstract
{- Large recursion used here.
Since we cannot talk about the truncation of a₀ == a₁ yet,
we instead talk about the continuation type (a₀ == a₁ → U) → U
for any n-type U instead. -}
code : ⟦ type TrAA ⟧ → n -Type l
code = rec {j = lsucc l} TrAA (n -Type-≤ l)
(λ {(a₀ , a₁) → (a₀ == a₁ → ⟦ U ⟧) →-≤ U})
code-β : {a₀ a₁ : A} → ⟦ code (cons TrAA (a₀ , a₁)) ⟧
≃ ((a₀ == a₁ → ⟦ U ⟧) → ⟦ U ⟧)
code-β = coe-equiv (ap ⟦_⟧ (rec-β TrAA _))
-- We can encode a path in the truncation, ...
encode : {ta₀ ta₁ : ⟦ type TrA ⟧} → ta₀ == ta₁ → ⟦ code (ta₀ , ta₁) ⟧
encode idp = MA.elim (λ ta → raise (code (ta , ta)))
(λ _ → <– code-β (λ f → f idp)) _
--- ...reducing when coming from a path in the original type.
encode-β : {a₀ a₁ : A} (p : a₀ == a₁) (f : a₀ == a₁ → ⟦ U ⟧)
→ –> code-β (encode (ap (cons TrA) p)) f == f p
encode-β idp = app= (ap (–> code-β) (MA.elim-β _) ∙ <–-inv-r code-β _)
-- We can decode into the U-continuation of a path in the truncation, ...
decode : {ta₀ ta₁ : ⟦ type TrA ⟧}
→ ⟦ code (ta₀ , ta₁) ⟧ → (ta₀ == ta₁ → ⟦ U ⟧) → ⟦ U ⟧
decode = MAA.elim
(λ {(ta₀ , ta₁) → _ →-≤ (ta₀ == ta₁ → ⟦ U ⟧) →-≤ raise U})
(λ _ c g → –> code-β c (g ∘ ap (cons TrA))) _ where
-- ...reducing
decode-β : {a₀ a₁ : A} (c : ⟦ code (cons TrAA (a₀ , a₁)) ⟧)
(g : cons TrA a₀ == cons TrA a₁ → ⟦ U ⟧)
→ decode c g == –> code-β c (g ∘ ap (cons TrA))
decode-β = app= ∘ app= (MAA.elim-β _)
-- encoding followed by decoding produces the expected continuation
decode-encode : {ta₀ ta₁ : ⟦ type TrA ⟧} (q : ta₀ == ta₁)
(g : ta₀ == ta₁ → ⟦ U ⟧) → decode (encode q) g == g q
decode-encode idp = MA.elim
(λ ta → Π-≤ (ta == ta → ⟦ U ⟧)
(λ g → Path-≤ (raise U) (decode (encode idp) g) (g idp)))
(λ _ g → decode-β (encode idp) g ∙ encode-β idp (g ∘ ap (cons TrA))) _
trunc : (a₀ a₁ : A) → trunc-ty n (a₀ == a₁) l
trunc a₀ a₁ = record
{ type = Path-< (type TrA) (cons TrA a₀) (cons TrA a₁)
; cons = ap (cons TrA)
; univ = snd ∘ e } where
e : (U : _) → (cons TrA a₀ == cons TrA a₁ → ⟦ U ⟧) ≃ (a₀ == a₁ → ⟦ U ⟧)
e U = equiv u v u-v v-u where
open code U
u : (cons TrA a₀ == cons TrA a₁ → ⟦ U ⟧) → a₀ == a₁ → ⟦ U ⟧
u g = g ∘ ap (cons TrA)
v : (a₀ == a₁ → ⟦ U ⟧) → cons TrA a₀ == cons TrA a₁ → ⟦ U ⟧
v f q = –> code-β (encode q) f
u-v : (f : a₀ == a₁ → ⟦ U ⟧) → u (v f) == f
u-v f = λ= (λ p → encode-β p f)
v-u : (g : cons TrA a₀ == cons TrA a₁ → ⟦ U ⟧) → v (u g) == g
v-u g = λ= (λ q → ! (decode-β (encode q) g) ∙ decode-encode q g)
| {
"alphanum_fraction": 0.537509434,
"avg_line_length": 38.9705882353,
"ext": "agda",
"hexsha": "dd2d0128fdace5d3dfa9c4d8b783b23147d4a71f",
"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": "c8fb8da3354fc9e0c430ac14160161759b4c5b37",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "sattlerc/HoTT-Agda",
"max_forks_repo_path": "Universe/Trunc/TypeConstructors.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c8fb8da3354fc9e0c430ac14160161759b4c5b37",
"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": "sattlerc/HoTT-Agda",
"max_issues_repo_path": "Universe/Trunc/TypeConstructors.agda",
"max_line_length": 93,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "c8fb8da3354fc9e0c430ac14160161759b4c5b37",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "sattlerc/HoTT-Agda",
"max_stars_repo_path": "Universe/Trunc/TypeConstructors.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2461,
"size": 6625
} |
-- Categories with objects parameterised by a sort
module SOAS.Sorting {T : Set} where
open import SOAS.Common
import Categories.Category.CartesianClosed.Canonical as Canonical
import Categories.Category.CartesianClosed as CCC
open import Categories.Category.Cocartesian
open import Categories.Category.BicartesianClosed
import Categories.Category.Monoidal as Monoidal
import Categories.Category.Monoidal.Closed as MonClosed
open import Categories.Object.Product
open import Categories.Functor.Bifunctor
-- Add sorting to a set
Sorted : Set₁ → Set₁
Sorted Obj = T → Obj
-- Lift a function on Obj to one on sorted Obj
sorted : {O₁ O₂ : Set₁} → (O₁ → O₂) → Sorted O₁ → Sorted O₂
sorted f 𝒳 τ = f (𝒳 τ)
-- Lift a binary operation on Obj to one on sorted Obj
sorted₂ : {O₁ O₂ O₃ : Set₁} → (O₁ → O₂ → O₃)
→ Sorted O₁ → Sorted O₂ → Sorted O₃
sorted₂ op 𝒳 𝒴 τ = op (𝒳 τ) (𝒴 τ)
sortedᵣ : {O₁ O₂ O₃ : Set₁} → (O₁ → O₂ → O₃)
→ O₁ → Sorted O₂ → Sorted O₃
sortedᵣ op X 𝒴 τ = op X (𝒴 τ)
sortedₗ : {O₁ O₂ O₃ : Set₁} → (O₁ → O₂ → O₃)
→ Sorted O₁ → O₂ → Sorted O₃
sortedₗ op 𝒳 Y τ = op (𝒳 τ) Y
-- Turn a category into a sorted category
𝕊orted : Category 1ℓ 0ℓ 0ℓ → Category 1ℓ 0ℓ 0ℓ
𝕊orted Cat = categoryHelper (record
{ Obj = Sorted Obj
; _⇒_ = λ A B → ∀{τ : T} → A τ ⇒ B τ
; _≈_ = λ f g → ∀{α : T} → f {α} ≈ g {α}
; id = id Cat
; _∘_ = λ g f → Category._∘_ Cat g f
; assoc = assoc
; identityˡ = identityˡ
; identityʳ = identityʳ
; equiv = record { refl = E.refl equiv ; sym = λ p → E.sym equiv p
; trans = λ p q → E.trans equiv p q }
; ∘-resp-≈ = λ p q → ∘-resp-≈ p q
})
where
open Category Cat
open import Relation.Binary.Structures renaming (IsEquivalence to E)
-- Lift functors to functors between sorted categories
𝕊orted-Functor : {ℂ 𝔻 : Category 1ℓ 0ℓ 0ℓ} → Functor ℂ 𝔻 → Functor (𝕊orted ℂ) (𝕊orted 𝔻)
𝕊orted-Functor F = record
{ F₀ = λ X τ → Functor.₀ F (X τ)
; F₁ = λ f → Functor.₁ F f
; identity = Functor.identity F
; homomorphism = Functor.homomorphism F
; F-resp-≈ = λ z → Functor.F-resp-≈ F z
}
-- Lift bifunctors to bifunctors between sorted categories
𝕊orted-Bifunctor : {ℂ 𝔻 𝔼 : Category 1ℓ 0ℓ 0ℓ} → Bifunctor ℂ 𝔻 𝔼 → Bifunctor (𝕊orted ℂ) (𝕊orted 𝔻) (𝕊orted 𝔼)
𝕊orted-Bifunctor F = record
{ F₀ = λ{ (X , Y) τ → Functor.₀ F (X τ , Y τ)}
; F₁ = λ{ (f , g) → Functor.₁ F (f , g)}
; identity = Functor.identity F
; homomorphism = Functor.homomorphism F
; F-resp-≈ = λ{ (p , q) → Functor.F-resp-≈ F (p , q)}
}
private
variable C : Category 1ℓ 0ℓ 0ℓ
-- A sorted CCC is itself a CCC
𝕊orted-CanCCC : Canonical.CartesianClosed C
→ Canonical.CartesianClosed (𝕊orted C)
𝕊orted-CanCCC CCC = record
{ ⊤ = λ τ → 𝓒.terminal.⊤
; _×_ = λ A B τ → (A τ) 𝓒.× (B τ)
; ! = 𝓒.terminal.!
; π₁ = 𝓒.π₁
; π₂ = 𝓒.π₂
; ⟨_,_⟩ = λ f g → 𝓒.⟨ f , g ⟩
; !-unique = λ f → 𝓒.terminal.!-unique f
; π₁-comp = 𝓒.π₁-comp
; π₂-comp = 𝓒.π₂-comp
; ⟨,⟩-unique = λ p₁ p₂ → 𝓒.⟨,⟩-unique p₁ p₂
; _^_ = λ B A τ → B τ 𝓒.^ A τ
; eval = 𝓒.eval
; curry = λ f → 𝓒.curry f
; eval-comp = 𝓒.eval-comp
; curry-resp-≈ = λ p → 𝓒.curry-resp-≈ p
; curry-unique = λ p → 𝓒.curry-unique p
} where private module 𝓒 = Canonical.CartesianClosed CCC
-- A sorted co-Cartesian category is co-Cartesian
𝕊orted-Cocartesian : Cocartesian C
→ Cocartesian (𝕊orted C)
𝕊orted-Cocartesian Cocart = record
{ initial = record
{ ⊥ = λ τ → 𝓒.⊥ ; ⊥-is-initial = record
{ ! = 𝓒.initial.! ; !-unique = λ f → 𝓒.initial.!-unique f } }
; coproducts = record { coproduct = λ {A}{B} → record
{ A+B = λ τ → 𝓒.coproduct.A+B {A τ}{B τ}
; i₁ = 𝓒.i₁
; i₂ = 𝓒.i₂
; [_,_] = λ f g → 𝓒.[ f , g ]
; inject₁ = 𝓒.inject₁
; inject₂ = 𝓒.inject₂
; unique = λ p₁ p₂ → 𝓒.coproduct.unique p₁ p₂
} }
} where private module 𝓒 = Cocartesian Cocart
-- A sorted bi-Cartesian closed category is itself bi-Cartesian closed
𝕊orted-BCCC : BicartesianClosed C
→ BicartesianClosed (𝕊orted C)
𝕊orted-BCCC BCCC = record
{ cartesianClosed = fromCanonical _ (𝕊orted-CanCCC (toCanonical _ cartesianClosed))
; cocartesian = 𝕊orted-Cocartesian cocartesian
}
where
open BicartesianClosed BCCC
open Canonical.Equivalence
-- A sorted monoidal category is itself monoidal
𝕊orted-Monoidal : Monoidal.Monoidal C
→ Monoidal.Monoidal (𝕊orted C)
𝕊orted-Monoidal {C} Mon = record
{ ⊗ = record
{ F₀ = λ{ (X , Y) τ → X τ 𝓒.⊗₀ Y τ }
; F₁ = λ{ (f , g) → f 𝓒.⊗₁ g}
; identity = Functor.identity 𝓒.⊗
; homomorphism = Functor.homomorphism 𝓒.⊗
; F-resp-≈ = λ{ (p₁ , p₂) {α} → Functor.F-resp-≈ 𝓒.⊗ (p₁ , p₂) }
}
; unit = λ τ → 𝓒.unit
; unitorˡ = record { from = λ {τ} → 𝓒.unitorˡ.from ; to = 𝓒.unitorˡ.to
; iso = record { isoˡ = Iso.isoˡ 𝓒.unitorˡ.iso ; isoʳ = Iso.isoʳ 𝓒.unitorˡ.iso } }
; unitorʳ = record { from = λ {τ} → 𝓒.unitorʳ.from ; to = 𝓒.unitorʳ.to
; iso = record { isoˡ = Iso.isoˡ 𝓒.unitorʳ.iso ; isoʳ = Iso.isoʳ 𝓒.unitorʳ.iso } }
; associator = record { from = λ {τ} → 𝓒.associator.from ; to = 𝓒.associator.to
; iso = record { isoˡ = Iso.isoˡ 𝓒.associator.iso ; isoʳ = Iso.isoʳ 𝓒.associator.iso } }
; unitorˡ-commute-from = 𝓒.unitorˡ-commute-from
; unitorˡ-commute-to = 𝓒.unitorˡ-commute-to
; unitorʳ-commute-from = 𝓒.unitorʳ-commute-from
; unitorʳ-commute-to = 𝓒.unitorʳ-commute-to
; assoc-commute-from = 𝓒.assoc-commute-from
; assoc-commute-to = 𝓒.assoc-commute-to
; triangle = 𝓒.triangle
; pentagon = 𝓒.pentagon
}
where
private module 𝓒 = Monoidal.Monoidal Mon
open import Categories.Morphism C
-- A sorted monoidal closed category is itself monoidal closed
𝕊orted-MonClosed : {Mon : Monoidal.Monoidal C}
→ MonClosed.Closed Mon
→ MonClosed.Closed (𝕊orted-Monoidal Mon)
𝕊orted-MonClosed {Mon} Cl = record
{ [-,-] = record
{ F₀ = λ (X , Y) τ → 𝓒.[ X τ , Y τ ]₀
; F₁ = λ (f , g) → 𝓒.[ f , g ]₁
; identity = λ {A} {α} → Functor.identity 𝓒.[-,-]
; homomorphism = Functor.homomorphism 𝓒.[-,-]
; F-resp-≈ = λ{ (p₁ , p₂) {α} → Functor.F-resp-≈ 𝓒.[-,-] (p₁ , p₂) }
}
; adjoint = record
{ unit = ntHelper record
{ η = λ X {τ} → NT.η 𝓒.adjoint.unit (X τ)
; commute = λ f → NT.commute 𝓒.adjoint.unit f
}
; counit = ntHelper record
{ η = λ X {τ} → NT.η 𝓒.adjoint.counit (X τ)
; commute = λ f → NT.commute 𝓒.adjoint.counit f
}
; zig = 𝓒.adjoint.zig
; zag = 𝓒.adjoint.zag
}
; mate = λ f → record { commute₁ = 𝓒.mate.commute₁ f ; commute₂ = 𝓒.mate.commute₂ f }
} where private module 𝓒 = MonClosed.Closed Cl
| {
"alphanum_fraction": 0.603264095,
"avg_line_length": 35.6613756614,
"ext": "agda",
"hexsha": "11e0c4dcd373f042712c98b51519fcd8816ce386",
"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/Sorting.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/Sorting.agda",
"max_line_length": 112,
"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/Sorting.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": 2702,
"size": 6740
} |
------------------------------------------------------------------------------
-- Conversion rules for the division
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOTC.Program.Division.ConversionRulesI where
open import Common.FOL.Relation.Binary.EqReasoning
open import FOTC.Base
open import FOTC.Data.Nat
open import FOTC.Data.Nat.Inequalities
open import FOTC.Program.Division.Division
------------------------------------------------------------------------------
-- Division properties
private
-- Before to prove some properties for div it is convenient
-- to have a proof for each possible execution step.
-- Initially, we define the possible states (div-s₁, div-s₂, ...)
-- and after that, we write down the proof for the execution step
-- from the state p to the state q, e.g.
--
-- proof₂₋₃ : ∀ i j → div-s₂ i j ≡ div-s₃ i j.
-- Initially, the conversion rule div-eq is applied.
div-s₁ : D → D → D
div-s₁ i j = if (lt i j) then zero else succ₁ (div (i ∸ j) j)
-- lt i j ≡ true.
div-s₂ : D → D → D
div-s₂ i j = if true
then zero
else succ₁ (div (i ∸ j) j)
-- lt i j ≡ false.
div-s₃ : D → D → D
div-s₃ i j = if false
then zero
else succ₁ (div (i ∸ j) j)
-- The conditional is true.
div-s₄ : D
div-s₄ = zero
-- The conditional is false.
div-s₅ : D → D → D
div-s₅ i j = succ₁ (div (i ∸ j) j)
{-
To prove the execution steps, e.g.
proof₃₋₄ : ∀ i j → div-s₃ i j → divh_s₄ i j,
we usually need to prove that
... m ... ≡ ... n ... (1)
given that
m ≡ n, (2)
where (2) is a conversion rule usually.
We prove (1) using
subst : ∀ {x y} (A : D → Set) → x ≡ y → A x → A y
where
• P is given by \m → ... m ... ≡ ... n ...,
• x ≡ y is given n ≡ m (actually, we use ≡-sym (m ≡ n)) and
• P x is given by ... n ... ≡ ... n ... (i.e. ≡-refl)
-}
-- From div i j to div-s₁ using the equation div-eq.
proof₀₋₁ : ∀ i j → div i j ≡ div-s₁ i j
proof₀₋₁ i j = div-eq i j
-- From div-s₁ to div-s₂ using the proof i<j.
proof₁₋₂ : ∀ i j → i < j → div-s₁ i j ≡ div-s₂ i j
proof₁₋₂ i j i<j =
subst (λ t → (if t
then zero
else succ₁ (div (i ∸ j) j))
≡
(if true
then zero
else succ₁ (div (i ∸ j) j))
)
(sym i<j)
refl
-- From div-s₁ to div-s₃ using the proof i≮j.
proof₁₋₃ : ∀ i j → i ≮ j → div-s₁ i j ≡ div-s₃ i j
proof₁₋₃ i j i≮j =
subst (λ t → (if t
then zero
else succ₁ (div (i ∸ j) j))
≡
(if false
then zero
else succ₁ (div (i ∸ j) j))
)
(sym i≮j)
refl
-- From div-s₂ to div-s₄ using the conversion rule if-true.
proof₂₋₄ : ∀ i j → div-s₂ i j ≡ div-s₄
proof₂₋₄ i j = if-true zero
-- From div-s₃ to div-s₅ using the conversion rule if-false.
proof₃₋₅ : ∀ i j → div-s₃ i j ≡ div-s₅ i j
proof₃₋₅ i j = if-false (succ₁ (div (i ∸ j) j))
----------------------------------------------------------------------
-- The division result when the dividend is minor than the
-- the divisor.
div-x<y : ∀ {i j} → i < j → div i j ≡ zero
div-x<y {i} {j} i<j =
div i j ≡⟨ proof₀₋₁ i j ⟩
div-s₁ i j ≡⟨ proof₁₋₂ i j i<j ⟩
div-s₂ i j ≡⟨ proof₂₋₄ i j ⟩
div-s₄ ∎
----------------------------------------------------------------------
-- The division result when the dividend is greater or equal than the
-- the divisor.
div-x≮y : ∀ {i j} → i ≮ j → div i j ≡ succ₁ (div (i ∸ j) j)
div-x≮y {i} {j} i≮j =
div i j ≡⟨ proof₀₋₁ i j ⟩
div-s₁ i j ≡⟨ proof₁₋₃ i j i≮j ⟩
div-s₃ i j ≡⟨ proof₃₋₅ i j ⟩
div-s₅ i j ∎
| {
"alphanum_fraction": 0.4439971584,
"avg_line_length": 29.9503546099,
"ext": "agda",
"hexsha": "1a4e1ff86a1cdf6c44d6905aeae83f2e19fbe157",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z",
"max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/fotc",
"max_forks_repo_path": "src/fot/FOTC/Program/Division/ConversionRulesI.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/fotc",
"max_issues_repo_path": "src/fot/FOTC/Program/Division/ConversionRulesI.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/Program/Division/ConversionRulesI.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z",
"num_tokens": 1338,
"size": 4223
} |
-- Imports from the standard library
module Library where
-- open import Level using () renaming (suc to lsuc) public
open import Data.Fin using (Fin; zero; suc) public
open import Data.List using (List; []; _∷_; map) public
open import Data.Nat
using (ℕ; zero; suc; z≤n; s≤s; pred; _≤′_; ≤′-refl; ≤′-step )
renaming (_≤_ to _≤ℕ_; _⊔_ to max)
public
open import Data.Nat.Properties
using (_+-mono_; ≤⇒≤′)
renaming (≤-decTotalOrder to decTotalOrderℕ)
public
open import Data.Product using (Σ; ∃; _×_; _,_; proj₁; proj₂) renaming (map to map×) public
open import Function using (id; _∘_) public
open import Induction.WellFounded using (Acc; acc) public
open import Relation.Binary using (module DecTotalOrder)
open import Relation.Binary.List.Pointwise as ListEq using ([]; _∷_) renaming (Rel to ≅L) hiding (module Rel) public
module ≅L = ListEq
open import Relation.Binary.PropositionalEquality as PropEq using (_≡_; module ≡-Reasoning) public
module ≡ = PropEq
open import Size public
module DecTotalOrderℕ = DecTotalOrder decTotalOrderℕ
module ≤ℕ = DecTotalOrderℕ
caseMax : ∀{m n} (P : ℕ → Set)
→ (pn : (m≤n : m ≤ℕ n) → P n)
→ (pm : (n≤m : n ≤ℕ m) → P m)
→ P (max m n)
caseMax {zero } {n } P pn pm = pn z≤n
caseMax {suc m} {zero } P pn pm = pm z≤n
caseMax {suc m} {suc n} P pn pm = caseMax (P ∘ suc) (pn ∘ s≤s) (pm ∘ s≤s)
n≤sn : ∀{n} → n ≤ℕ suc n
n≤sn = (z≤n {1}) +-mono DecTotalOrderℕ.refl
pred≤ℕ : ∀{n m} → suc n ≤ℕ suc m → n ≤ℕ m
pred≤ℕ (s≤s p) = p
record ⊤ {a} : Set a where
-- TODOs
postulate
TODO : ∀ {a}{A : Set a} → A
-- -}
| {
"alphanum_fraction": 0.6404002502,
"avg_line_length": 28.5535714286,
"ext": "agda",
"hexsha": "cf18b72e606cba1c01881b386572486210208282",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2018-02-23T18:22:17.000Z",
"max_forks_repo_forks_event_min_datetime": "2017-11-10T16:44:52.000Z",
"max_forks_repo_head_hexsha": "79d97481f3312c2d30a823c3b1bcb8ae871c2fe2",
"max_forks_repo_licenses": [
"Unlicense"
],
"max_forks_repo_name": "ryanakca/strong-normalization",
"max_forks_repo_path": "agda-aplas14/Library.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "79d97481f3312c2d30a823c3b1bcb8ae871c2fe2",
"max_issues_repo_issues_event_max_datetime": "2018-02-20T14:54:18.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-02-14T16:42:36.000Z",
"max_issues_repo_licenses": [
"Unlicense"
],
"max_issues_repo_name": "ryanakca/strong-normalization",
"max_issues_repo_path": "agda-aplas14/Library.agda",
"max_line_length": 116,
"max_stars_count": 32,
"max_stars_repo_head_hexsha": "79d97481f3312c2d30a823c3b1bcb8ae871c2fe2",
"max_stars_repo_licenses": [
"Unlicense"
],
"max_stars_repo_name": "ryanakca/strong-normalization",
"max_stars_repo_path": "agda-aplas14/Library.agda",
"max_stars_repo_stars_event_max_datetime": "2021-03-05T12:12:03.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-05-22T14:33:27.000Z",
"num_tokens": 607,
"size": 1599
} |
{-# OPTIONS --without-K #-}
module F0 where
import Level as L
open import Data.Unit
open import Data.Sum
open import Data.Product
open import Function using (id ; _$_ )
infixr 90 _⊗_
infixr 80 _⊕_
infixr 60 _∘_
infix 30 _⟷_
---------------------------------------------------------------------------
-- Our own version of refl that makes 'a' explicit
data _≡_ {u} {A : Set u} : (a b : A) → Set u where
refl : (a : A) → (a ≡ a)
-- if we have no occurrences of reciprocals then we can use plain sets; for
-- consistency with the rest of the story we will explicitly add refl paths
-- pi types with no reciprocals
data B : Set where
ONE : B
PLUS : B → B → B
TIMES : B → B → B
-- discrete groupoids
record 0-type : Set₁ where
constructor G₀
field
∣_∣ : Set
paths : {a : ∣_∣} → (a ≡ a)
paths {a} = refl a
open 0-type public
plus : 0-type → 0-type → 0-type
plus t₁ t₂ = G₀ (∣ t₁ ∣ ⊎ ∣ t₂ ∣)
times : 0-type → 0-type → 0-type
times t₁ t₂ = G₀ (∣ t₁ ∣ × ∣ t₂ ∣)
-- We interpret types as discrete groupoids
⟦_⟧ : B → 0-type
⟦ ONE ⟧ = G₀ ⊤
⟦ PLUS b₁ b₂ ⟧ = plus ⟦ b₁ ⟧ ⟦ b₂ ⟧
⟦ TIMES b₁ b₂ ⟧ = times ⟦ b₁ ⟧ ⟦ b₂ ⟧
-- isos
data _⟷_ : B → B → Set where
-- +
swap₊ : { b₁ b₂ : B } → PLUS b₁ b₂ ⟷ PLUS b₂ b₁
assocl₊ : { b₁ b₂ b₃ : B } → PLUS b₁ (PLUS b₂ b₃) ⟷ PLUS (PLUS b₁ b₂) b₃
assocr₊ : { b₁ b₂ b₃ : B } → PLUS (PLUS b₁ b₂) b₃ ⟷ PLUS b₁ (PLUS b₂ b₃)
-- *
unite⋆ : { b : B } → TIMES ONE b ⟷ b
uniti⋆ : { b : B } → b ⟷ TIMES ONE b
swap⋆ : { b₁ b₂ : B } → TIMES b₁ b₂ ⟷ TIMES b₂ b₁
assocl⋆ : { b₁ b₂ b₃ : B } → TIMES b₁ (TIMES b₂ b₃) ⟷ TIMES (TIMES b₁ b₂) b₃
assocr⋆ : { b₁ b₂ b₃ : B } → TIMES (TIMES b₁ b₂) b₃ ⟷ TIMES b₁ (TIMES b₂ b₃)
-- * distributes over +
dist : { b₁ b₂ b₃ : B } →
TIMES (PLUS b₁ b₂) b₃ ⟷ PLUS (TIMES b₁ b₃) (TIMES b₂ b₃)
factor : { b₁ b₂ b₃ : B } →
PLUS (TIMES b₁ b₃) (TIMES b₂ b₃) ⟷ TIMES (PLUS b₁ b₂) b₃
-- congruence
id⟷ : { b : B } → b ⟷ b
sym : { b₁ b₂ : B } → (b₁ ⟷ b₂) → (b₂ ⟷ b₁)
_∘_ : { b₁ b₂ b₃ : B } → (b₁ ⟷ b₂) → (b₂ ⟷ b₃) → (b₁ ⟷ b₃)
_⊕_ : { b₁ b₂ b₃ b₄ : B } →
(b₁ ⟷ b₃) → (b₂ ⟷ b₄) → (PLUS b₁ b₂ ⟷ PLUS b₃ b₄)
_⊗_ : { b₁ b₂ b₃ b₄ : B } →
(b₁ ⟷ b₃) → (b₂ ⟷ b₄) → (TIMES b₁ b₂ ⟷ TIMES b₃ b₄)
-- interpret isos as functors
record 0-functor (A B : 0-type) : Set where
constructor F₀
field
fobj : ∣ A ∣ → ∣ B ∣
fmor : {a b : ∣ A ∣} → (a ≡ b) → (fobj a ≡ fobj b)
fmor {a} {.a} (refl .a) = refl (fobj a)
open 0-functor public
swap⊎ : {A B : Set} → A ⊎ B → B ⊎ A
swap⊎ (inj₁ a) = inj₂ a
swap⊎ (inj₂ b) = inj₁ b
assocl⊎ : {A B C : Set} → A ⊎ (B ⊎ C) → (A ⊎ B) ⊎ C
assocl⊎ (inj₁ x) = inj₁ (inj₁ x)
assocl⊎ (inj₂ (inj₁ x)) = inj₁ (inj₂ x)
assocl⊎ (inj₂ (inj₂ y)) = inj₂ y
assocr⊎ : {A B C : Set} → (A ⊎ B) ⊎ C → A ⊎ (B ⊎ C)
assocr⊎ (inj₁ (inj₁ x)) = inj₁ x
assocr⊎ (inj₁ (inj₂ x)) = inj₂ (inj₁ x)
assocr⊎ (inj₂ y) = inj₂ (inj₂ y)
unite× : {A : Set} → ⊤ × A → A
unite× (tt , x) = x
uniti× : {A : Set} → A → ⊤ × A
uniti× x = (tt , x)
swap× : {A B : Set} → A × B → B × A
swap× (a , b) = (b , a)
assocl× : {A B C : Set} → A × (B × C) → (A × B) × C
assocl× (x , (y , z)) = (x , y) , z
assocr× : {A B C : Set} → (A × B) × C → A × (B × C)
assocr× ((x , y) , z) = x , (y , z)
dist×⊎ : {A B C : Set} → (A ⊎ B) × C → (A × C) ⊎ (B × C)
dist×⊎ (inj₁ a , c) = inj₁ (a , c)
dist×⊎ (inj₂ b , c) = inj₂ (b , c)
factor⊎× : {A B C : Set} → (A × C) ⊎ (B × C) → (A ⊎ B) × C
factor⊎× (inj₁ (a , c)) = (inj₁ a , c)
factor⊎× (inj₂ (b , c)) = (inj₂ b , c)
ev⊎ : {A B C D : Set} → (A → C) → (B → D) → A ⊎ B → C ⊎ D
ev⊎ f _ (inj₁ a) = inj₁ (f a)
ev⊎ _ g (inj₂ b) = inj₂ (g b)
ev× : {A B C D : Set} → (A → C) → (B → D) → A × B → C × D
ev× f g (a , b) = (f a , g b)
mutual
eval : {b₁ b₂ : B} → (b₁ ⟷ b₂) → 0-functor ⟦ b₁ ⟧ ⟦ b₂ ⟧
eval swap₊ = F₀ swap⊎
eval assocl₊ = F₀ assocl⊎
eval assocr₊ = F₀ assocr⊎
eval unite⋆ = F₀ unite×
eval uniti⋆ = F₀ uniti×
eval swap⋆ = F₀ swap×
eval assocl⋆ = F₀ assocl×
eval assocr⋆ = F₀ assocr×
eval dist = F₀ dist×⊎
eval factor = F₀ factor⊎×
eval id⟷ = F₀ id
eval (sym c) = evalB c
eval (c₁ ∘ c₂) = F₀ (λ x → fobj (eval c₂) (fobj (eval c₁) x))
eval (c₁ ⊕ c₂) = F₀ (ev⊎ (fobj $ eval c₁) (fobj $ eval c₂))
eval (c₁ ⊗ c₂) = F₀ (ev× (fobj $ eval c₁) (fobj $ eval c₂))
evalB : {b₁ b₂ : B} → (b₁ ⟷ b₂) → 0-functor ⟦ b₂ ⟧ ⟦ b₁ ⟧
evalB swap₊ = F₀ swap⊎
evalB assocl₊ = F₀ assocr⊎
evalB assocr₊ = F₀ assocl⊎
evalB unite⋆ = F₀ uniti×
evalB uniti⋆ = F₀ unite×
evalB swap⋆ = F₀ swap×
evalB assocl⋆ = F₀ assocr×
evalB assocr⋆ = F₀ assocl×
evalB dist = F₀ factor⊎×
evalB factor = F₀ dist×⊎
evalB id⟷ = F₀ id
evalB (sym c) = eval c
evalB (c₁ ∘ c₂) = F₀ (λ x → fobj (evalB c₁) (fobj (evalB c₂) x))
evalB (c₁ ⊕ c₂) = F₀ (ev⊎ (fobj $ evalB c₁) (fobj $ evalB c₂))
evalB (c₁ ⊗ c₂) = F₀ (ev× (fobj $ evalB c₁) (fobj $ evalB c₂))
---------------------------------------------------------------------------
| {
"alphanum_fraction": 0.4793582469,
"avg_line_length": 29.3735632184,
"ext": "agda",
"hexsha": "1fd3e9fede2dc438bdc575af5d9752c77db6dbe5",
"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": "F0.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": "F0.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": "F0.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": 2491,
"size": 5111
} |
open import Agda.Primitive
record Order {ℓ} ℓ' (A : Set ℓ) : Set (ℓ ⊔ lsuc ℓ') where
field
_≤_ : A → A → Set ℓ'
open Order {{...}} public
data ℕ : Set where
Zero : ℕ
Succ : ℕ → ℕ
data _≤ⁿ_ : ℕ → ℕ → Set where
Zero : ∀ {n} → Zero ≤ⁿ n
Succ : ∀ {n₁ n₂} → n₁ ≤ⁿ n₂ → Succ n₁ ≤ⁿ Succ n₂
instance
Order[ℕ] : Order lzero ℕ
Order[ℕ] = record { _≤_ = _≤ⁿ_ }
subtract : ∀ (n₁ n₂ : ℕ) → n₂ ≤ n₁ → ℕ
subtract n₁ .Zero Zero = n₁
subtract .(Succ _) .(Succ _) (Succ P) = subtract _ _ P
| {
"alphanum_fraction": 0.537109375,
"avg_line_length": 20.48,
"ext": "agda",
"hexsha": "c1fdccb9debb8272c75f8a1213b2494934c45062",
"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/Issue1865.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/Issue1865.agda",
"max_line_length": 57,
"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/Issue1865.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": 229,
"size": 512
} |
{-# OPTIONS --without-K --safe #-}
-- Monoidal natural isomorphisms between lax and strong symmetric
-- monoidal functors.
--
-- NOTE. Symmetric monoidal natural isomorphisms are really just
-- monoidal natural isomorphisms that happen to go between symmetric
-- monoidal functors. No additional conditions are necessary.
-- Nevertheless, the definitions in this module are useful when one is
-- working in a symmetric monoidal setting. They also help Agda's
-- type checker by bundling the (symmetric monoidal) categories and
-- functors involved.
module Categories.NaturalTransformation.NaturalIsomorphism.Monoidal.Symmetric
where
open import Level
open import Relation.Binary using (IsEquivalence)
open import Categories.Category.Monoidal using (SymmetricMonoidalCategory)
import Categories.Functor.Monoidal.Symmetric as BMF
open import Categories.Functor.Monoidal.Properties using () renaming
( idF-SymmetricMonoidal to idFˡ ; idF-StrongSymmetricMonoidal to idFˢ
; ∘-SymmetricMonoidal to _∘Fˡ_ ; ∘-StrongSymmetricMonoidal to _∘Fˢ_
)
open import Categories.NaturalTransformation.NaturalIsomorphism as NI
using (NaturalIsomorphism)
import Categories.NaturalTransformation.NaturalIsomorphism.Monoidal as MNI
module Lax where
open BMF.Lax using (SymmetricMonoidalFunctor)
open MNI.Lax using (IsMonoidalNaturalIsomorphism)
open SymmetricMonoidalFunctor using ()
renaming (F to UF; monoidalFunctor to MF)
private module U = MNI.Lax
module _ {o ℓ e o′ ℓ′ e′}
{C : SymmetricMonoidalCategory o ℓ e}
{D : SymmetricMonoidalCategory o′ ℓ′ e′} where
-- Monoidal natural isomorphisms between lax symmetric monoidal functors.
record SymmetricMonoidalNaturalIsomorphism
(F G : SymmetricMonoidalFunctor C D) : Set (o ⊔ ℓ ⊔ ℓ′ ⊔ e′) where
field
U : NaturalIsomorphism (UF F) (UF G)
F⇒G-isMonoidal : IsMonoidalNaturalIsomorphism (MF F) (MF G) U
⌊_⌋ : U.MonoidalNaturalIsomorphism (MF F) (MF G)
⌊_⌋ = record { U = U ; F⇒G-isMonoidal = F⇒G-isMonoidal }
open U.MonoidalNaturalIsomorphism ⌊_⌋ public hiding (U; F⇒G-isMonoidal)
infix 4 _≃_
_≃_ = SymmetricMonoidalNaturalIsomorphism
-- "Strengthening"
⌈_⌉ : {F G : SymmetricMonoidalFunctor C D} →
U.MonoidalNaturalIsomorphism (MF F) (MF G) → F ≃ G
⌈ α ⌉ = record { U = U ; F⇒G-isMonoidal = F⇒G-isMonoidal }
where open U.MonoidalNaturalIsomorphism α
open SymmetricMonoidalNaturalIsomorphism
-- Identity and compositions
infixr 9 _ⓘᵥ_
id : {F : SymmetricMonoidalFunctor C D} → F ≃ F
id = ⌈ U.id ⌉
_ⓘᵥ_ : {F G H : SymmetricMonoidalFunctor C D} → G ≃ H → F ≃ G → F ≃ H
α ⓘᵥ β = ⌈ ⌊ α ⌋ U.ⓘᵥ ⌊ β ⌋ ⌉
isEquivalence : IsEquivalence _≃_
isEquivalence = record
{ refl = id
; sym = λ α → record
{ U = NI.sym (U α)
; F⇒G-isMonoidal = F⇐G-isMonoidal α
}
; trans = λ α β → β ⓘᵥ α
}
where
open SymmetricMonoidalNaturalIsomorphism
module _ {o ℓ e o′ ℓ′ e′ o″ ℓ″ e″}
{C : SymmetricMonoidalCategory o ℓ e}
{D : SymmetricMonoidalCategory o′ ℓ′ e′}
{E : SymmetricMonoidalCategory o″ ℓ″ e″} where
infixr 9 _ⓘₕ_ _ⓘˡ_ _ⓘʳ_
_ⓘₕ_ : {F G : SymmetricMonoidalFunctor C D}
{H I : SymmetricMonoidalFunctor D E} →
H ≃ I → F ≃ G → (H ∘Fˡ F) ≃ (I ∘Fˡ G)
-- NOTE: this definition is clearly equivalent to
--
-- α ⓘₕ β = ⌈ ⌊ α ⌋ U.ⓘₕ ⌊ β ⌋ ⌉
--
-- but the latter takes an unreasonably long time to typecheck,
-- while the unfolded version typechecks almost immediately.
α ⓘₕ β = record
{ U = C.U
; F⇒G-isMonoidal = record
{ ε-compat = C.ε-compat
; ⊗-homo-compat = C.⊗-homo-compat }
}
where module C = U.MonoidalNaturalIsomorphism (⌊ α ⌋ U.ⓘₕ ⌊ β ⌋)
_ⓘˡ_ : {F G : SymmetricMonoidalFunctor C D}
(H : SymmetricMonoidalFunctor D E) → F ≃ G → (H ∘Fˡ F) ≃ (H ∘Fˡ G)
H ⓘˡ α = id {F = H} ⓘₕ α
_ⓘʳ_ : {G H : SymmetricMonoidalFunctor D E} →
G ≃ H → (F : SymmetricMonoidalFunctor C D) → (G ∘Fˡ F) ≃ (H ∘Fˡ F)
α ⓘʳ F = α ⓘₕ id {F = F}
-- Left and right unitors.
module _ {o ℓ e o′ ℓ′ e′}
{C : SymmetricMonoidalCategory o ℓ e}
{D : SymmetricMonoidalCategory o′ ℓ′ e′}
{F : SymmetricMonoidalFunctor C D} where
-- NOTE: Again, manual expansion seems necessary to type check in
-- reasonable time.
unitorˡ : idFˡ D ∘Fˡ F ≃ F
unitorˡ = record
{ U = LU.U
; F⇒G-isMonoidal = record
{ ε-compat = LU.ε-compat
; ⊗-homo-compat = LU.⊗-homo-compat
}
}
where module LU = U.MonoidalNaturalIsomorphism (U.unitorˡ {F = MF F})
unitorʳ : F ∘Fˡ idFˡ C ≃ F
unitorʳ = record
{ U = RU.U
; F⇒G-isMonoidal = record
{ ε-compat = RU.ε-compat
; ⊗-homo-compat = RU.⊗-homo-compat
}
}
where module RU = U.MonoidalNaturalIsomorphism (U.unitorʳ {F = MF F})
-- Associator.
module _ {o ℓ e o′ ℓ′ e′ o″ ℓ″ e″ o‴ ℓ‴ e‴}
{B : SymmetricMonoidalCategory o ℓ e}
{C : SymmetricMonoidalCategory o′ ℓ′ e′}
{D : SymmetricMonoidalCategory o″ ℓ″ e″}
{E : SymmetricMonoidalCategory o‴ ℓ‴ e‴}
{F : SymmetricMonoidalFunctor B C}
{G : SymmetricMonoidalFunctor C D}
{H : SymmetricMonoidalFunctor D E} where
-- NOTE: Again, manual expansion seems necessary to type check in
-- reasonable time.
associator : (H ∘Fˡ G) ∘Fˡ F ≃ H ∘Fˡ (G ∘Fˡ F)
associator = record
{ U = AU.U
; F⇒G-isMonoidal = record
{ ε-compat = AU.ε-compat
; ⊗-homo-compat = AU.⊗-homo-compat
}
}
where
module AU =
U.MonoidalNaturalIsomorphism (U.associator {F = MF F} {MF G} {MF H})
module Strong where
open BMF.Strong using (SymmetricMonoidalFunctor)
open MNI.Strong using (IsMonoidalNaturalIsomorphism)
open SymmetricMonoidalFunctor using () renaming
( F to UF
; monoidalFunctor to MF
; laxSymmetricMonoidalFunctor to laxBMF
)
private module U = MNI.Strong
module _ {o ℓ e o′ ℓ′ e′}
{C : SymmetricMonoidalCategory o ℓ e}
{D : SymmetricMonoidalCategory o′ ℓ′ e′} where
-- Monoidal natural isomorphisms between strong symmetric monoidal functors.
record SymmetricMonoidalNaturalIsomorphism
(F G : SymmetricMonoidalFunctor C D) : Set (o ⊔ ℓ ⊔ ℓ′ ⊔ e′) where
field
U : NaturalIsomorphism (UF F) (UF G)
F⇒G-isMonoidal : IsMonoidalNaturalIsomorphism (MF F) (MF G) U
⌊_⌋ : U.MonoidalNaturalIsomorphism (MF F) (MF G)
⌊_⌋ = record { U = U ; F⇒G-isMonoidal = F⇒G-isMonoidal }
laxBNI : Lax.SymmetricMonoidalNaturalIsomorphism (laxBMF F) (laxBMF G)
laxBNI = record { U = U ; F⇒G-isMonoidal = F⇒G-isMonoidal }
open Lax.SymmetricMonoidalNaturalIsomorphism laxBNI public
hiding (U; F⇒G-isMonoidal; ⌊_⌋)
infix 4 _≃_
_≃_ = SymmetricMonoidalNaturalIsomorphism
-- "Strengthening"
⌈_⌉ : {F G : SymmetricMonoidalFunctor C D} →
U.MonoidalNaturalIsomorphism (MF F) (MF G) → F ≃ G
⌈ α ⌉ = record { U = U ; F⇒G-isMonoidal = F⇒G-isMonoidal }
where open U.MonoidalNaturalIsomorphism α
open SymmetricMonoidalNaturalIsomorphism
-- Identity and compositions
infixr 9 _ⓘᵥ_
id : {F : SymmetricMonoidalFunctor C D} → F ≃ F
id = ⌈ U.id ⌉
_ⓘᵥ_ : {F G H : SymmetricMonoidalFunctor C D} → G ≃ H → F ≃ G → F ≃ H
α ⓘᵥ β = ⌈ ⌊ α ⌋ U.ⓘᵥ ⌊ β ⌋ ⌉
isEquivalence : IsEquivalence _≃_
isEquivalence = record
{ refl = id
; sym = λ α → record
{ U = NI.sym (U α)
; F⇒G-isMonoidal = F⇐G-isMonoidal α
}
; trans = λ α β → β ⓘᵥ α
}
where
open SymmetricMonoidalNaturalIsomorphism
module _ {o ℓ e o′ ℓ′ e′ o″ ℓ″ e″}
{C : SymmetricMonoidalCategory o ℓ e}
{D : SymmetricMonoidalCategory o′ ℓ′ e′}
{E : SymmetricMonoidalCategory o″ ℓ″ e″} where
infixr 9 _ⓘₕ_ _ⓘˡ_ _ⓘʳ_
_ⓘₕ_ : {F G : SymmetricMonoidalFunctor C D}
{H I : SymmetricMonoidalFunctor D E} →
H ≃ I → F ≃ G → (H ∘Fˢ F) ≃ (I ∘Fˢ G)
-- NOTE: this definition is clearly equivalent to
--
-- α ⓘₕ β = ⌈ ⌊ α ⌋ U.ⓘₕ ⌊ β ⌋ ⌉
--
-- but the latter takes an unreasonably long time to typecheck,
-- while the unfolded version typechecks almost immediately.
α ⓘₕ β = record
{ U = C.U
; F⇒G-isMonoidal = record
{ ε-compat = C.ε-compat
; ⊗-homo-compat = C.⊗-homo-compat }
}
where module C = U.MonoidalNaturalIsomorphism (⌊ α ⌋ U.ⓘₕ ⌊ β ⌋)
_ⓘˡ_ : {F G : SymmetricMonoidalFunctor C D}
(H : SymmetricMonoidalFunctor D E) → F ≃ G → (H ∘Fˢ F) ≃ (H ∘Fˢ G)
H ⓘˡ α = id {F = H} ⓘₕ α
_ⓘʳ_ : {G H : SymmetricMonoidalFunctor D E} →
G ≃ H → (F : SymmetricMonoidalFunctor C D) → (G ∘Fˢ F) ≃ (H ∘Fˢ F)
α ⓘʳ F = α ⓘₕ id {F = F}
-- Left and right unitors.
module _ {o ℓ e o′ ℓ′ e′}
{C : SymmetricMonoidalCategory o ℓ e}
{D : SymmetricMonoidalCategory o′ ℓ′ e′}
{F : SymmetricMonoidalFunctor C D} where
-- NOTE: Again, manual expansion seems necessary to type check in
-- reasonable time.
unitorˡ : idFˢ D ∘Fˢ F ≃ F
unitorˡ = record
{ U = LU.U
; F⇒G-isMonoidal = record
{ ε-compat = LU.ε-compat
; ⊗-homo-compat = LU.⊗-homo-compat
}
}
where module LU = U.MonoidalNaturalIsomorphism (U.unitorˡ {F = MF F})
unitorʳ : F ∘Fˢ idFˢ C ≃ F
unitorʳ = record
{ U = RU.U
; F⇒G-isMonoidal = record
{ ε-compat = RU.ε-compat
; ⊗-homo-compat = RU.⊗-homo-compat
}
}
where module RU = U.MonoidalNaturalIsomorphism (U.unitorʳ {F = MF F})
-- Associator.
module _ {o ℓ e o′ ℓ′ e′ o″ ℓ″ e″ o‴ ℓ‴ e‴}
{B : SymmetricMonoidalCategory o ℓ e}
{C : SymmetricMonoidalCategory o′ ℓ′ e′}
{D : SymmetricMonoidalCategory o″ ℓ″ e″}
{E : SymmetricMonoidalCategory o‴ ℓ‴ e‴}
{F : SymmetricMonoidalFunctor B C}
{G : SymmetricMonoidalFunctor C D}
{H : SymmetricMonoidalFunctor D E} where
-- NOTE: Again, manual expansion seems necessary to type check in
-- reasonable time.
associator : (H ∘Fˢ G) ∘Fˢ F ≃ H ∘Fˢ (G ∘Fˢ F)
associator = record
{ U = AU.U
; F⇒G-isMonoidal = record
{ ε-compat = AU.ε-compat
; ⊗-homo-compat = AU.⊗-homo-compat
}
}
where
module AU =
U.MonoidalNaturalIsomorphism (U.associator {F = MF F} {MF G} {MF H})
| {
"alphanum_fraction": 0.5847542628,
"avg_line_length": 32.8353293413,
"ext": "agda",
"hexsha": "09efaef3d7786e89ccd5a99214328413776cb166",
"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": "5fc007768264a270b8ff319570225986773da601",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "o1lo01ol1o/agda-categories",
"max_forks_repo_path": "src/Categories/NaturalTransformation/NaturalIsomorphism/Monoidal/Symmetric.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "5fc007768264a270b8ff319570225986773da601",
"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": "o1lo01ol1o/agda-categories",
"max_issues_repo_path": "src/Categories/NaturalTransformation/NaturalIsomorphism/Monoidal/Symmetric.agda",
"max_line_length": 80,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "5fc007768264a270b8ff319570225986773da601",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "o1lo01ol1o/agda-categories",
"max_stars_repo_path": "src/Categories/NaturalTransformation/NaturalIsomorphism/Monoidal/Symmetric.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3977,
"size": 10967
} |
{-# OPTIONS --without-K #-}
open import HoTT
module homotopy.S1SuspensionS0 where
{- To -}
module To = S¹Rec (north Bool) (merid _ true ∙ ! (merid _ false))
to : S¹ → Suspension Bool
to = To.f
{- From -}
from-merid : Bool → base == base
from-merid true = loop
from-merid false = idp
module From = SuspensionRec Bool base base from-merid
from : Suspension Bool → S¹
from = From.f
{- ToFrom and FromTo -}
module _ {i} {A : Type i} where
∙idp∙ : {x y z : A} (p : x == y) (q : y == z) → p ∙ idp ∙ q == p ∙ q
∙idp∙ idp idp = idp
p∙!q∙q : {x y z : A} (p : x == y) (q : z == y) → p ∙ ( ! q ∙ q) == p
p∙!q∙q idp idp = idp
!-∙∙ : {x y z w : A} (p : x == y) (q : y == z) (r : x == w) → ! (p ∙ q) ∙ r == (! q ∙ ! p ) ∙ r
!-∙∙ idp idp idp = idp
!-coh : {x y : A} {p p' : x == y} → p == p' → ! p == ! p'
!-coh idp = idp
add-idp-r : {x y : A} → (p : x == y) → p == p ∙ idp
add-idp-r idp = idp
ap-coh : ∀ {i j} {A : Type i} {B : Type j} {x y : A} → (f : A → B) → {p p' : x == y} → p == p' → ap f p == ap f p'
ap-coh f idp = idp
_∋_ : ∀ {i} (A : Type i) → A → A
A ∋ x = x
mt : north Bool == south Bool
mt = merid Bool true
mf : north Bool == south Bool
mf = merid Bool false
to-from-merid-t' : ( ! (ap to (ap from mt))) ∙ idp ∙ mt == mf
to-from-merid-t' = ! (ap to (ap from mt)) ∙ idp ∙ mt =⟨ ∙idp∙ ( ! (ap to (ap from mt))) mt ⟩
! (ap to (ap from mt)) ∙ mt =⟨ (!-coh (ap-coh to (From.glue-β true))) ∙ᵣ mt ⟩
! (ap to loop) ∙ mt =⟨ (!-coh (To.loop-β)) ∙ᵣ mt ⟩
(! (mt ∙ ! mf)) ∙ mt =⟨ !-∙∙ mt (! mf) mt ⟩
((! (! mf)) ∙ ! mt) ∙ mt =⟨ ((!-! mf) ∙ᵣ (! mt)) ∙ᵣ mt ⟩
(mf ∙ ! mt) ∙ mt =⟨ ∙-assoc mf (! mt) mt ⟩
mf ∙ (! mt ∙ mt) =⟨ p∙!q∙q mf mt ⟩
mf ∎
to-from-merid-f' : ( ! (ap to (ap from mf))) ∙ idp ∙ mf == mf
to-from-merid-f' = ! (ap to (ap from mf)) ∙ idp ∙ mf =⟨ ∙idp∙ ( ! (ap to (ap from mf))) mf ⟩
! (ap to (ap from mf)) ∙ mf =⟨ (!-coh (ap-coh to (From.glue-β false))) ∙ᵣ mf ⟩
mf ∎
-- to-from-merid' : (b : Bool) → ( ! (ap to (ap from (merid Bool b)))) ∙ idp ∙ mf == (merid Bool b)
-- to-from-merid' false = to-from-merid-f'
-- to-from-merid' true = to-from-merid-t'
to-from : (x : Suspension Bool) → to (from x) == x
to-from = ToFrom.f
where
Q : Suspension Bool → Set lzero
Q x = to (from x) == x
n : to (from (north Bool)) == north Bool
n = idp
s : to (from (south Bool)) == south Bool
s = mf
lemma : {x y : Suspension Bool} → (q : x == y) → (α : to (from x) == x) → transport Q q α == (! (ap to (ap from q))) ∙ α ∙ q
lemma idp α = add-idp-r α
p : (b : Bool) → n == s [ Q ↓ merid Bool b ]
p true = from-transp Q mt ((lemma mt n) ∙ to-from-merid-t')
p false = from-transp Q mf ((lemma mf n) ∙ to-from-merid-f')
module ToFrom = SuspensionElim Bool {P = Q} n s p
from-to-loop' : (! (ap from (ap to loop))) ∙ idp ∙ loop == idp
from-to-loop' = ! (ap from (ap to loop)) ∙ idp ∙ loop =⟨ ∙idp∙ (! (ap from (ap to loop))) loop ⟩
! (ap from (ap to loop)) ∙ loop =⟨ (!-coh (ap-coh from To.loop-β)) ∙ᵣ loop ⟩
! (ap from (mt ∙ ! mf)) ∙ loop =⟨ (!-coh (ap-∙ from mt (! mf))) ∙ᵣ loop ⟩
(! ((ap from mt) ∙ (ap from (! mf)))) ∙ loop =⟨ (!-coh ( (From.glue-β true) ∙ᵣ (ap from (! mf)))) ∙ᵣ loop ⟩
! (loop ∙ (ap from (! mf))) ∙ loop =⟨ !-coh (loop ∙ₗ ap-! from mf) ∙ᵣ loop ⟩
! (loop ∙ ! (ap from mf)) ∙ loop =⟨ !-coh (loop ∙ₗ (!-coh (From.glue-β false))) ∙ᵣ loop ⟩
! (loop ∙ ! idp) ∙ loop =⟨ !-∙∙ loop (! idp) loop ⟩
(! loop) ∙ loop =⟨ !-inv-l loop ⟩
idp ∎
from-to : (x : S¹) → from (to x) == x
from-to = FromTo.f
where
Q : S¹ → Type lzero
Q x = from (to x) == x
b : Q base
b = idp
lemma : {x y : S¹} → (q : x == y) → (α : from (to x) == x) → transport Q q α == (! (ap from (ap to q))) ∙ α ∙ q
lemma idp α = add-idp-r α
l : b == b [ Q ↓ loop ]
l = from-transp Q loop ((lemma loop b) ∙ from-to-loop')
module FromTo = S¹Elim {P = Q} b l
e : S¹ ≃ Suspension Bool
e = equiv to from to-from from-to
| {
"alphanum_fraction": 0.4239274657,
"avg_line_length": 36.7642276423,
"ext": "agda",
"hexsha": "f3e46ffe5a0e632619dc3e877188a8828e2bbbdf",
"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": "f8fa68bf753d64d7f45556ca09d0da7976709afa",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "UlrikBuchholtz/HoTT-Agda",
"max_forks_repo_path": "homotopy/S1SuspensionS0.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f8fa68bf753d64d7f45556ca09d0da7976709afa",
"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": "UlrikBuchholtz/HoTT-Agda",
"max_issues_repo_path": "homotopy/S1SuspensionS0.agda",
"max_line_length": 128,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "f8fa68bf753d64d7f45556ca09d0da7976709afa",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "UlrikBuchholtz/HoTT-Agda",
"max_stars_repo_path": "homotopy/S1SuspensionS0.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1824,
"size": 4522
} |
module Prelude.Bytes where
open import Prelude.Bool
open import Prelude.Decidable
open import Prelude.Equality
open import Prelude.Equality.Unsafe
{-# FOREIGN GHC import qualified Data.ByteString as B #-}
postulate
Bytes : Set
{-# COMPILE GHC Bytes = type B.ByteString #-}
private
module Internal where
postulate
empty : Bytes
append : Bytes → Bytes → Bytes
{-# COMPILE GHC empty = B.empty #-}
{-# COMPILE GHC append = B.append #-}
-- Eq --
private
postulate eqBytes : Bytes → Bytes → Bool
{-# COMPILE GHC eqBytes = (==) #-}
instance
EqBytes : Eq Bytes
_==_ {{EqBytes}} x y with eqBytes x y
... | true = yes unsafeEqual
... | false = no unsafeNotEqual
-- Monoid --
instance
open import Prelude.Monoid
MonoidBytes : Monoid Bytes
mempty {{MonoidBytes}} = Internal.empty
_<>_ {{MonoidBytes}} = Internal.append
| {
"alphanum_fraction": 0.6705069124,
"avg_line_length": 20.6666666667,
"ext": "agda",
"hexsha": "6926947fbcff49f7c48e863a5604276ec9541c51",
"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/Bytes.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/Bytes.agda",
"max_line_length": 57,
"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/Bytes.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 229,
"size": 868
} |
open import Prelude
open import Relation.Binary.PropositionalEquality
open import RW.Language.RTerm using (Name)
open import RW.Strategy.PropEq
open import RW.RW (≡-strat ∷ [])
open import Data.Nat.Properties.Simple
using (+-comm; +-right-identity; +-assoc)
module PropEqTest where
++-assoc : ∀{a}{A : Set a}(xs ys zs : List A) →
(xs ++ ys) ++ zs ≡ xs ++ (ys ++ zs)
++-assoc [] ys zs = refl
++-assoc (x ∷ xs) ys zs = tactic (by (quote ++-assoc))
open ≡-Reasoning
++-assocH : ∀{a}{A : Set a}(xs ys zs : List A) →
(xs ++ ys) ++ zs ≡ xs ++ (ys ++ zs)
++-assocH [] ys zs =
begin
([] ++ ys) ++ zs
≡⟨ refl ⟩
ys ++ zs
≡⟨ refl ⟩
[] ++ (ys ++ zs)
∎
++-assocH {A = A} (x ∷ xs) ys zs =
begin
((x ∷ xs) ++ ys) ++ zs
≡⟨ refl ⟩
x ∷ (xs ++ ys) ++ zs
≡⟨ refl ⟩
x ∷ ((xs ++ ys) ++ zs)
≡⟨ (tactic (by (quote ++-assocH))) ⟩
x ∷ (xs ++ (ys ++ zs))
≡⟨ refl ⟩
(x ∷ xs) ++ (ys ++ zs)
∎
[]-++-neutral : ∀{a}{A : Set a}(xs : List A)
→ xs ++ [] ≡ xs
[]-++-neutral [] = refl
[]-++-neutral (x ∷ xs) = tactic (by (quote []-++-neutral))
test1 : (x y : ℕ) → (x + y) + 0 ≡ y + (x + 0)
test1 x y
= begin
(x + y) + 0
≡⟨ (tactic (by+ acts)) ⟩
x + y
≡⟨ (tactic (by+ acts)) ⟩
y + x
≡⟨ (tactic (by+ acts)) ⟩
(y + x) + 0
≡⟨ (tactic (by+ acts)) ⟩
y + (x + 0)
∎
where
acts : List Name
acts = quote +-right-identity ∷ quote +-assoc ∷ quote +-comm ∷ []
| {
"alphanum_fraction": 0.3775055679,
"avg_line_length": 28.0625,
"ext": "agda",
"hexsha": "43f90834621158038b2cdc5be981972a1c81b03a",
"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": "2856afd12b7dbbcc908482975638d99220f38bf2",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "VictorCMiraldo/agda-rw",
"max_forks_repo_path": "Testing/PropEqTest.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "2856afd12b7dbbcc908482975638d99220f38bf2",
"max_issues_repo_issues_event_max_datetime": "2015-05-28T14:48:03.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-02-06T15:03:33.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "VictorCMiraldo/agda-rw",
"max_issues_repo_path": "Testing/PropEqTest.agda",
"max_line_length": 73,
"max_stars_count": 16,
"max_stars_repo_head_hexsha": "2856afd12b7dbbcc908482975638d99220f38bf2",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "VictorCMiraldo/agda-rw",
"max_stars_repo_path": "Testing/PropEqTest.agda",
"max_stars_repo_stars_event_max_datetime": "2019-10-24T17:38:20.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-02-09T15:43:38.000Z",
"num_tokens": 627,
"size": 1796
} |
module split where
import Relation.Binary.PropositionalEquality as Eq
open Eq using (_≡_; refl; sym; trans; cong)
open Eq.≡-Reasoning
open import Data.Nat using (ℕ; zero; suc; _+_; _*_; _∸_; _≤_; s≤s; z≤n; _≤?_)
open import Relation.Nullary using (¬_; Dec; yes; no)
open import Data.Product using (_×_; ∃; ∃-syntax) renaming (_,_ to ⟨_,_⟩)
open import Function using (_∘_)
open import lists using (List; []; _∷_; [_]; [_,_]; [_,_,_]; [_,_,_,_]; All; Decidable)
-- リストのマージ
-- xs と ys を使って zs を組み立てる
data merge {A : Set} : (xs ys zs : List A) → Set where
[] :
--------------
merge [] [] []
left-∷ : ∀ {x xs ys zs}
→ merge xs ys zs
--------------------------
→ merge (x ∷ xs) ys (x ∷ zs)
right-∷ : ∀ {y xs ys zs}
→ merge xs ys zs
--------------------------
→ merge xs (y ∷ ys) (y ∷ zs)
_ : merge [ 1 , 4 ] [ 2 , 3 ] [ 1 , 2 , 3 , 4 ]
_ = left-∷ (right-∷ (right-∷ (left-∷ [])))
-- リストの分割
-- 述語Pが成り立つ場合はxs、そうでない場合はysとして分割する (scalaでいうpartition)
split : ∀ {A : Set} {P : A → Set} (P? : Decidable P) (zs : List A)
→ ∃[ xs ] ∃[ ys ] (merge xs ys zs × All P xs × All (¬_ ∘ P) ys)
split P? [] = ⟨ [] , ⟨ [] , ⟨ [] , ⟨ [] , [] ⟩ ⟩ ⟩ ⟩
split P? (z ∷ zs) with P? z | split P? zs
... | yes Pz | ⟨ xs , ⟨ ys , ⟨ m , ⟨ Pxs , ¬Pys ⟩ ⟩ ⟩ ⟩ = ⟨ z ∷ xs , ⟨ ys , ⟨ left-∷ m , ⟨ Pz ∷ Pxs , ¬Pys ⟩ ⟩ ⟩ ⟩
... | no ¬Pz | ⟨ xs , ⟨ ys , ⟨ m , ⟨ Pxs , ¬Pys ⟩ ⟩ ⟩ ⟩ = ⟨ xs , ⟨ z ∷ ys , ⟨ right-∷ m , ⟨ Pxs , ¬Pz ∷ ¬Pys ⟩ ⟩ ⟩ ⟩
-- 0と等しい1以上の自然数は存在しない
¬z≡n : ∀ {n : ℕ} → ¬ (zero ≡ suc n)
¬z≡n ()
-- m = n が成り立たなければ (m + 1) = (n + 1) も成り立たない
¬s≡s : ∀ {m n : ℕ} → ¬ (m ≡ n) → ¬ (suc m ≡ suc n)
¬s≡s ¬m≡n refl = ¬m≡n refl
-- decidableを使った、2つの自然数が等しいかどうか判定する関数
_≡ℕ?_ : ∀ (m n : ℕ) → Dec (m ≡ n)
zero ≡ℕ? zero = yes refl
zero ≡ℕ? suc n = no ¬z≡n
suc m ≡ℕ? zero = no (λ ())
suc m ≡ℕ? suc n with m ≡ℕ? n
... | yes refl = yes refl
... | no ¬m≡n = no (¬s≡s ¬m≡n)
-- テスト
-- リストの要素を3とそれ以外とに分ける
_ : split (_≡ℕ? 3) [ 3 , 0 , 3 , 1 ]
≡ ⟨ [ 3 , 3 ] , ⟨ [ 0 , 1 ] , ⟨ (left-∷ (right-∷ (left-∷ (right-∷ [])))) , ⟨ refl ∷ refl ∷ [] , ¬z≡n ∷ (¬s≡s ¬z≡n) ∷ [] ⟩ ⟩ ⟩ ⟩
_ = refl
| {
"alphanum_fraction": 0.4197048611,
"avg_line_length": 36,
"ext": "agda",
"hexsha": "99fcbe483f561df8dc5ed133b3c00baeba1fb4a5",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "akiomik/plfa-solutions",
"max_forks_repo_path": "part1/lists/split.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "akiomik/plfa-solutions",
"max_issues_repo_path": "part1/lists/split.agda",
"max_line_length": 145,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "akiomik/plfa-solutions",
"max_stars_repo_path": "part1/lists/split.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z",
"num_tokens": 1079,
"size": 2304
} |
------------------------------------------------------------------------
-- A proof of univalence for an arbitrary "equality with J"
------------------------------------------------------------------------
{-# OPTIONS --cubical --safe #-}
import Equality.Path as P
module Equality.Path.Isomorphisms.Univalence
{e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where
open P.Derived-definitions-and-properties eq
import Equality.Path.Univalence as PU
open import Prelude
open import Equivalence equality-with-J
open import Univalence-axiom equality-with-J
open import Equality.Path.Isomorphisms eq
private
variable
ℓ : Level
-- Univalence.
univ : Univalence ℓ
univ = _≃_.from Univalence≃Univalence PU.univ
-- A variant of univ that does not compute at compile-time.
abstract
abstract-univ : Univalence ℓ
abstract-univ = univ
-- Propositional extensionality.
prop-ext : Propositional-extensionality ℓ
prop-ext =
_≃_.from
(Propositional-extensionality-is-univalence-for-propositions ext)
(λ _ _ → univ)
| {
"alphanum_fraction": 0.63996139,
"avg_line_length": 23.5454545455,
"ext": "agda",
"hexsha": "45af587412d49317e3ce2903c3ca609e524e6935",
"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/Equality/Path/Isomorphisms/Univalence.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/Equality/Path/Isomorphisms/Univalence.agda",
"max_line_length": 72,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/equality",
"max_stars_repo_path": "src/Equality/Path/Isomorphisms/Univalence.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": 249,
"size": 1036
} |
{-
Types Summer School 2007
Bertinoro
Aug 19 - 31, 2007
Agda
Ulf Norell
-}
-- Let's have a closer look at the module system
module Modules where
{-
Importing and opening modules
-}
-- You can import a module defined in a different file.
import Nat
-- This will bring the module into scope and allows you to
-- access its contents using qualified names.
plusTwo : Nat.Nat -> Nat.Nat
plusTwo n = Nat._+_ n 2
-- To bring everything from a module into scope you can open
-- the module.
open Nat
z : Nat
z = zero
-- There's also a short-hand to import and open at the same time
open import Bool
_&&_ : Bool -> Bool -> Bool
x && y = if x then y else false
-- Sometimes it's nice to be able to control what is brought
-- into scope when you open a module. There are three modifiers
-- that affect this: using, hiding and renaming.
module DifferentWaysOfOpeningNat where
-- nothing but Nat
open Nat using (Nat)
-- everything but zero
open Nat hiding (zero)
-- everything, but zero and suc under different names
open Nat renaming (zero to ZZ; suc to S_S)
two : Nat
two = S S zero S S
-- you can combine using or hiding with renaming, but not using
-- with hiding (for obvious reasons).
-- To re-export something opened use the public modifier.
module A where
open Nat public using (Nat)
N = A.Nat -- now Nat is a visible name in module A
{-
Parameterised modules
-}
-- A very useful feature is parameterised modules.
data Vec (A : Set) : Nat -> Set where
[] : Vec A 0
_::_ : {n : Nat} -> A -> Vec A n -> Vec A (suc n)
infixr 40 _::_
module Sort {A : Set}(_≤_ : A -> A -> Bool) where
insert : {n : Nat} -> A -> Vec A n -> Vec A (suc n)
insert x [] = x :: []
insert x (y :: ys) = if x ≤ y
then x :: y :: ys
else y :: insert x ys
sort : {n : Nat} -> Vec A n -> Vec A n
sort [] = []
sort (x :: xs) = insert x (sort xs)
_≤_ : Nat -> Nat -> Bool
zero ≤ m = true
suc n ≤ zero = false
suc n ≤ suc m = n ≤ m
-- When used directly, functions from parameterised modules
-- take the parameters as extra arguments.
test = Sort.sort _≤_ (6 :: 2 :: 0 :: 4 :: [])
-- But, you can also apply the entire module to its arguments.
-- Let's open the new module while we're at it.
open module SortNat = Sort _≤_
test' = sort (3 :: 2 :: 4 :: 0 :: [])
{-
Local definitions
-}
data _==_ {A : Set}(x : A) : A -> Set where
refl : x == x
subst : {A : Set}(C : A -> Set){x y : A} -> x == y -> C x -> C y
subst C refl cx = cx
cong : {A B : Set}(f : A -> B){x y : A} -> x == y -> f x == f y
cong f refl = refl
lem₁ : (n : Nat) -> n + 0 == n
lem₁ zero = refl
lem₁ (suc n) = cong suc (lem₁ n)
lem₂ : (n m : Nat) -> n + suc m == suc n + m
lem₂ n zero = refl
lem₂ n (suc m) = cong suc (lem₂ n m)
{-
What's next?
-}
-- The final thing on the agenda is records.
-- Move on to: Records.agda
| {
"alphanum_fraction": 0.5890823845,
"avg_line_length": 20.4520547945,
"ext": "agda",
"hexsha": "f31e13c81efe58838d4131b447c7e5c196459cb5",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "examples/SummerSchool07/Lecture/Modules.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "examples/SummerSchool07/Lecture/Modules.agda",
"max_line_length": 65,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "examples/SummerSchool07/Lecture/Modules.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": 913,
"size": 2986
} |
-- The point of this test is to check that we don't create needlessly
-- large anonymous modules when we open a module application.
{-# OPTIONS -vscope.mod.inst:10 -vtc.section.apply:20 #-}
module Optimised-open where
postulate A : Set
module M₁ (A : Set) where
postulate
P : A → Set
X : Set
-- There is no point in creating a module containing X here.
open M₁ A using (P)
postulate
a : A
p : P a
module M₂ where
-- Or here.
open M₁ A public using () renaming (P to P′)
postulate
p′ : P′ a
open M₂
-- Make sure that we get a type error.
postulate
x : P P
| {
"alphanum_fraction": 0.6621621622,
"avg_line_length": 16.9142857143,
"ext": "agda",
"hexsha": "d9fba35746dad7c6ecebef2fa06ed59c18a2b706",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "redfish64/autonomic-agda",
"max_forks_repo_path": "test/Fail/Optimised-open.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/Optimised-open.agda",
"max_line_length": 69,
"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/Optimised-open.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": 178,
"size": 592
} |
{-# OPTIONS --without-K --safe #-}
module Categories.Category.Instance.Quivers where
-- The Category of Quivers
open import Level using (Level; suc; _⊔_)
open import Relation.Binary.PropositionalEquality.Core using (refl)
open import Data.Quiver using (Quiver)
open import Data.Quiver.Morphism using (Morphism; id; _∘_; _≃_; ≃-Equivalence; ≃-resp-∘)
open import Categories.Category.Core using (Category)
private
variable
o ℓ e o′ ℓ′ e′ : Level
Quivers : ∀ o ℓ e → Category (suc (o ⊔ ℓ ⊔ e)) (o ⊔ ℓ ⊔ e) (o ⊔ ℓ ⊔ e)
Quivers o ℓ e = record
{ Obj = Quiver o ℓ e
; _⇒_ = Morphism
; _≈_ = _≃_
; id = id
; _∘_ = _∘_
; assoc = λ {_ _ _ G} → record { F₀≡ = refl ; F₁≡ = Equiv.refl G }
; sym-assoc = λ {_ _ _ G} → record { F₀≡ = refl ; F₁≡ = Equiv.refl G }
; identityˡ = λ {_ G} → record { F₀≡ = refl ; F₁≡ = Equiv.refl G }
; identityʳ = λ {_ G} → record { F₀≡ = refl ; F₁≡ = Equiv.refl G }
; identity² = λ {G} → record { F₀≡ = refl ; F₁≡ = Equiv.refl G }
; equiv = ≃-Equivalence
; ∘-resp-≈ = ≃-resp-∘
}
where open Quiver using (module Equiv)
| {
"alphanum_fraction": 0.5744680851,
"avg_line_length": 33.1764705882,
"ext": "agda",
"hexsha": "0b98f5c14bd54e1b649e009add08f15a00818196",
"lang": "Agda",
"max_forks_count": 64,
"max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z",
"max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Code-distancing/agda-categories",
"max_forks_repo_path": "src/Categories/Category/Instance/Quivers.agda",
"max_issues_count": 236,
"max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Code-distancing/agda-categories",
"max_issues_repo_path": "src/Categories/Category/Instance/Quivers.agda",
"max_line_length": 88,
"max_stars_count": 279,
"max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Trebor-Huang/agda-categories",
"max_stars_repo_path": "src/Categories/Category/Instance/Quivers.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z",
"num_tokens": 436,
"size": 1128
} |
-- Andreas, 2018-10-16, runtime erasure
id : (@0 A : Set) (@0 x : A) → A
id A x = x
-- Expected error:
--
-- Variable x is declared erased, so it cannot be used here
-- when checking that the expression x has type A
| {
"alphanum_fraction": 0.6467889908,
"avg_line_length": 21.8,
"ext": "agda",
"hexsha": "b74c29355d57b868608b8ce27b7280f5c6241dc4",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/Erasure-Illegal-Access.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/Erasure-Illegal-Access.agda",
"max_line_length": 59,
"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/Erasure-Illegal-Access.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": 68,
"size": 218
} |
module Numeral.Natural.Induction{ℓ} where
open import Logic
open import Logic.Propositional
open import Functional
open import Numeral.Natural
-- The induction proof method on natural numbers
-- TODO: There seems to be a problem making i implicit with unsolved metas.
-- TODO: Maybe rename to elim because this is the elimination rule for ℕ
ℕ-elim : ∀{T : ℕ → Stmt{ℓ}} → T(𝟎) → ((i : ℕ) → T(i) → T(𝐒(i))) → ((n : ℕ) → T(n))
ℕ-elim {T} base step 𝟎 = base
ℕ-elim {T} base step (𝐒(n)) = step n (ℕ-elim {T} base step n)
[ℕ]-induction : ∀{φ : ℕ → Stmt{ℓ}} → φ(𝟎) → (∀(i : ℕ) → φ(i) → φ(𝐒(i))) → (∀{n} → φ(n))
[ℕ]-induction {φ} base step {n} = ℕ-elim {φ} base step n
[ℕ]-inductionᵢ : ∀{φ : ℕ → Stmt{ℓ}} → φ(𝟎) → (∀{i : ℕ} → φ(i) → φ(𝐒(i))) → (∀{n} → φ(n))
[ℕ]-inductionᵢ {φ} base step = [ℕ]-induction {φ} base (i ↦ step{i})
| {
"alphanum_fraction": 0.592503023,
"avg_line_length": 41.35,
"ext": "agda",
"hexsha": "b5cabb5dcdd4326ab715819f924180132e6ad3e5",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Numeral/Natural/Induction.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Numeral/Natural/Induction.agda",
"max_line_length": 88,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Numeral/Natural/Induction.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": 347,
"size": 827
} |
module Common.PredicateBasedContext where
open import Common.Predicate public
-- Predicate-based context membership.
module _ {U : Set} where
infix 3 _∈_
_∈_ : U → Pred (Cx U)
A ∈ Γ = Any (_≡ A) Γ
infix 3 _∉_
_∉_ : U → Pred (Cx U)
A ∉ Γ = Not (A ∈ Γ)
lookup : ∀ {Γ P} → All P Γ → (∀ {A} → A ∈ Γ → P A)
-- Alternatively:
-- lookup : ∀ {Γ P} → All P Γ → (_∈ Γ) ⊆ᴾ P
lookup ∅ ()
lookup (γ , a) (top refl) = a
lookup (γ , a) (pop i) = lookup γ i
tabulate : ∀ {Γ P} → (∀ {A} → A ∈ Γ → P A) → All P Γ
-- Alternatively:
-- tabulate : ∀ {Γ P} → (_∈ Γ) ⊆ᴾ P → All P Γ
tabulate {∅} f = ∅
tabulate {Γ , A} f = tabulate (f ∘ pop) , f (top refl)
bot∈ : ∀ {A} → A ∉ ∅
bot∈ ()
[_]ᴵˣ : ∀ {A Γ} → A ∈ Γ → ℕ
[ top refl ]ᴵˣ = zero
[ pop i ]ᴵˣ = suc [ i ]ᴵˣ
i₀ : ∀ {A Γ} → A ∈ Γ , A
i₀ = top refl
i₁ : ∀ {A B Γ} → A ∈ Γ , A , B
i₁ = pop i₀
i₂ : ∀ {A B C Γ} → A ∈ Γ , A , B , C
i₂ = pop i₁
-- Predicate-based context inclusion.
module _ {U : Set} where
-- NOTE: This is similar to Ren from Conor’s fish-and-chips development.
infix 3 _⊆_
_⊆_ : Cx U → Pred (Cx U)
Γ ⊆ Γ′ = ∀ {A} → A ∈ Γ → A ∈ Γ′
-- Alternatively:
-- Γ ⊆ Γ′ = (_∈ Γ) ⊆ᴾ (_∈ Γ′)
infix 3 _⊈_
_⊈_ : Cx U → Pred (Cx U)
Γ ⊈ Γ′ = Not (Γ ⊆ Γ′)
skip⊆ : ∀ {A Γ Γ′} → Γ ⊆ Γ′ → Γ ⊆ Γ′ , A
skip⊆ η = pop ∘ η
-- NOTE: This is similar to wkr from Conor’s fish-and-chips development.
keep⊆ : ∀ {A Γ Γ′} → Γ ⊆ Γ′ → Γ , A ⊆ Γ′ , A
keep⊆ η (top refl) = top refl
keep⊆ η (pop i) = pop (η i)
refl⊆ : ∀ {Γ} → Γ ⊆ Γ
refl⊆ {Γ} = refl⊆ᴾ {P = _∈ Γ}
trans⊆ : ∀ {Γ Γ′ Γ″} → Γ ⊆ Γ′ → Γ′ ⊆ Γ″ → Γ ⊆ Γ″
trans⊆ {Γ} η η′ = trans⊆ᴾ {P = _∈ Γ} η η′
unskip⊆ : ∀ {A Γ Γ′} → Γ , A ⊆ Γ′ → Γ ⊆ Γ′
unskip⊆ η = η ∘ pop
-- NOTE: This doesn’t seem possible.
-- unkeep⊆ : ∀ {A Γ Γ′} → Γ , A ⊆ Γ′ , A → Γ ⊆ Γ′
weak⊆ : ∀ {A Γ} → Γ ⊆ Γ , A
weak⊆ = pop
bot⊆ : ∀ {Γ} → ∅ ⊆ Γ
bot⊆ ()
-- Predicate-based context equality.
module _ {U : Set} where
infix 3 _⫗_
_⫗_ : Cx U → Pred (Cx U)
Γ ⫗ Γ′ = (Γ ⊆ Γ′) × (Γ′ ⊆ Γ)
infix 3 _⫘_
_⫘_ : Cx U → Pred (Cx U)
Γ ⫘ Γ′ = Not (Γ ⫗ Γ′)
refl⫗ : ∀ {Γ} → Γ ⫗ Γ
refl⫗ {Γ} = refl⫗ᴾ {P = _∈ Γ}
trans⫗ : ∀ {Γ Γ′ Γ″} → Γ ⫗ Γ′ → Γ′ ⫗ Γ″ → Γ ⫗ Γ″
trans⫗ {Γ} σ σ′ = trans⫗ᴾ {P = _∈ Γ} σ σ′
sym⫗ : ∀ {Γ Γ′} → Γ ⫗ Γ′ → Γ′ ⫗ Γ
sym⫗ {Γ} σ = sym⫗ᴾ {P = _∈ Γ} σ
antisym⊆ : ∀ {Γ Γ′} → ((Γ ⊆ Γ′) × (Γ′ ⊆ Γ)) ≡ (Γ ⫗ Γ′)
antisym⊆ {Γ} = antisym⊆ᴾ {P = _∈ Γ}
-- Monotonicity with respect to predicate-based context inclusion.
module _ {U : Set} where
mono∈ : ∀ {A : U} {Γ Γ′} → Γ ⊆ Γ′ → A ∈ Γ → A ∈ Γ′
mono∈ η i = η i
reflmono∈ : ∀ {A Γ} → (i : A ∈ Γ) → i ≡ mono∈ refl⊆ i
reflmono∈ i = refl
transmono∈ : ∀ {A Γ Γ′ Γ″} → (η : Γ ⊆ Γ′) (η′ : Γ′ ⊆ Γ″) (i : A ∈ Γ)
→ mono∈ η′ (mono∈ η i) ≡ mono∈ (trans⊆ η η′) i
transmono∈ η η′ i = refl
-- Predicate-based context concatenation.
module _ {U : Set} where
_⧺_ : Cx U → Cx U → Cx U
Γ ⧺ ∅ = Γ
Γ ⧺ (Γ′ , A) = (Γ ⧺ Γ′) , A
id⧺₁ : ∀ {Γ} → Γ ⧺ ∅ ≡ Γ
id⧺₁ = refl
id⧺₂ : ∀ {Γ} → ∅ ⧺ Γ ≡ Γ
id⧺₂ {∅} = refl
id⧺₂ {Γ , A} = cong² _,_ id⧺₂ refl
weak⊆⧺₁ : ∀ {Γ} Γ′ → Γ ⊆ Γ ⧺ Γ′
weak⊆⧺₁ ∅ = refl⊆
weak⊆⧺₁ (Γ′ , A) = skip⊆ (weak⊆⧺₁ Γ′)
weak⊆⧺₂ : ∀ {Γ Γ′} → Γ′ ⊆ Γ ⧺ Γ′
weak⊆⧺₂ {Γ} {∅} = bot⊆
weak⊆⧺₂ {Γ} {Γ′ , A} = keep⊆ weak⊆⧺₂
-- Predicate-based context thinning.
module _ {U : Set} where
_-_ : ∀ {A} → (Γ : Cx U) → A ∈ Γ → Cx U
∅ - ()
(Γ , A) - top refl = Γ
(Γ , B) - pop i = (Γ - i) , B
thin⊆ : ∀ {A Γ} → (i : A ∈ Γ) → Γ - i ⊆ Γ
thin⊆ (top refl) = pop
thin⊆ (pop i) = keep⊆ (thin⊆ i)
-- Decidable predicate-based context membership equality.
module _ {U : Set} where
data _=∈_ {A : U} {Γ} (i : A ∈ Γ) : ∀ {C} → Pred (C ∈ Γ) where
same : i =∈ i
diff : ∀ {C} → (j : C ∈ Γ - i) → i =∈ mono∈ (thin⊆ i) j
_≟∈_ : ∀ {A C Γ} → (i : A ∈ Γ) (j : C ∈ Γ) → i =∈ j
top refl ≟∈ top refl = same
top refl ≟∈ pop j = diff j
pop i ≟∈ top refl = diff (top refl)
pop i ≟∈ pop j with i ≟∈ j
pop i ≟∈ pop .i | same = same
pop i ≟∈ pop ._ | diff j = diff (pop j)
| {
"alphanum_fraction": 0.4388593523,
"avg_line_length": 23.5113636364,
"ext": "agda",
"hexsha": "9f4c85d381a76f35b05e67f0a0b78da393dd1c9f",
"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": "Common/PredicateBasedContext.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": "Common/PredicateBasedContext.agda",
"max_line_length": 74,
"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": "Common/PredicateBasedContext.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": 2217,
"size": 4138
} |
open import ExtractSac as ES using ()
open import Extract (ES.kompile-fun)
open import Data.Nat as N using (ℕ; zero; suc; _≤_; _≥_; _<_; s≤s; z≤n)
import Data.Nat.DivMod as N
open import Data.Nat.Properties as N
open import Data.List as L using (List; []; _∷_)
open import Data.Vec as V using (Vec; []; _∷_)
import Data.Vec.Properties as V
open import Data.Fin using (Fin; zero; suc; #_)
open import Data.Product as Prod using (Σ; _,_; curry; uncurry) renaming (_×_ to _⊗_)
open import Relation.Binary.PropositionalEquality
open import Reflection
open import Structures
open import Function
open import Array.Base
open import Array.Properties
open import APL2
open import Agda.Builtin.Float
v→a : ∀ {a}{X : Set a}{n} → Vec X n → Ar X 1 (n ∷ [])
v→a s = imap (λ iv → V.lookup s $ ix-lookup iv zero )
a→v : ∀ {a}{X : Set a}{s} → Ar X 1 (s ∷ []) → Vec X s
a→v (imap x) = V.tabulate λ i → x (i ∷ [])
-- blog←{⍺×⍵×1-⍵}
blog : ∀ {n s} → Ar Float n s → Ar Float n s → Ar Float n s
blog α ω = α ×ᵣ ω ×ᵣ 1.0 -ᵣ ω
test-blog = a→v $ blog (v→a $ 3.0 ∷ 4.0 ∷ []) (v→a $ 5.0 ∷ 6.0 ∷ [])
kblog = kompile blog [] []
test₃₆ : kblog ≡ ok _
test₃₆ = refl
-- backbias←{+/,⍵}
backbias : ∀ {n s} → Ar Float n s → Scal Float
backbias ω = --(▾_ ∘₂ _+ᵣ_) / , ω
_+ᵣ′_ / , ω
where
--_+ᵣ′_ : Float → Float → Float
--a +ᵣ′ b = ▾ (a +ᵣ b)
_+ᵣ′_ = primFloatPlus
kbackbias = kompile backbias (quote prod ∷ []) (quote prod ∷ quote off→idx ∷ quote reduce-custom.reduce-1d ∷ [])
--test₃₇ : kbackbias ≡ ok _
--test₃₇ = refl
-- logistic←{÷1+*-⍵}
logistic : ∀ {n s} → Ar Float n s → Ar Float n s
logistic ω = ÷ᵣ 1.0 +ᵣ *ᵣ -ᵣ ω
klogistic = kompile logistic [] []
test₃₈ : klogistic ≡ ok _
test₃₈ = refl
-- meansqerr←{÷∘2+/,(⍺-⍵)*2}
meansqerr : ∀ {n s} → Ar Float n s → Ar Float n s → Scal Float
meansqerr α ω = _÷ᵣ 2.0 $ _+ᵣ′_ / , (α +ᵣ ω) ×ᵣ (α -ᵣ ω)
where
_+ᵣ′_ = primFloatPlus
kmeansqerr = kompile meansqerr (quote prod ∷ []) (quote prod ∷ quote off→idx ∷ quote reduce-custom.reduce-1d ∷ [])
test₃₉ : klogistic ≡ ok _
test₃₉ = refl
-- backavgpool←{2⌿2/⍵÷4}⍤2
backavgpool : ∀ {s} → Ar Float 2 s → Ar Float 2 $ ▾ (2 × s)
backavgpool {s = _ ∷ _ ∷ []} ω = 2 /ᵣ′ 2 ⌿ᵣ ω ×ᵣ 4.0
where
infixr 20 _/ᵣ′_
_/ᵣ′_ = _/ᵣ_ {s = _ ∷ []}
kbackavgpool = kompile backavgpool [] []
test₄₀ : kbackavgpool ≡ ok _
test₄₀ = refl
-- Something that could go in Stdlib.
≡⇒≤ : ∀ {a b} → a ≡ b → a N.≤ b
≡⇒≤ refl = ≤-refl
-- This should be perfectly generaliseable --- instead of 2
-- we can use any m>0
a<b⇒k<2⇒a*2+k<b*2 : ∀ {a b k} → a N.< b → k N.< 2 → a N.* 2 N.+ k N.< b N.* 2
a<b⇒k<2⇒a*2+k<b*2 {a} {b} {zero} a<b k<2
rewrite (+-identityʳ (a N.* 2))
| (*-comm a 2)
| (*-comm b 2) = *-monoʳ-< 1 a<b
a<b⇒k<2⇒a*2+k<b*2 {a} {b} {suc zero} a<b k<2 = ≤-trans (N.s≤s (≡⇒≤ (+-comm _ 1)))
(*-monoˡ-≤ 2 a<b)
a<b⇒k<2⇒a*2+k<b*2 {a} {b} {suc (suc k)} a<b (N.s≤s (N.s≤s ()))
A<B⇒K<2⇒A*2+K<B*2 : ∀ {n s}{a b k : Ar ℕ n s} → a <a b → k <a (cst 2) → ((a × 2) + k) <a (b × 2)
A<B⇒K<2⇒A*2+K<B*2 {a = imap a} {imap b} {imap k} a<b k<2 = λ iv → a<b⇒k<2⇒a*2+k<b*2 (a<b iv) (k<2 iv)
avgpool : ∀ {s}
→ Ar Float 2 $ ▾ (s × 2)
→ Ar Float 2 s
avgpool {s} (imap p) = imap body
where
body : _ → _
body iv = ▾ (_÷ᵣ 4.0 $ _+ᵣ′_ / , f ̈ ι [2,2])
where
[2,2] = cst {s = 2 ∷ []} 2
f : _ → _
f (i , pf) = let ix , ix<s = ix→a iv in
p $ a→ix ((ix × 2) + i) (s × 2) $ A<B⇒K<2⇒A*2+K<B*2 ix<s pf
_+ᵣ′_ = primFloatPlus
kavgpool = kompile avgpool [] []
open import ReflHelper
fin-id : ∀ {n} → Fin n → Fin n
fin-id x = x
| {
"alphanum_fraction": 0.5238990333,
"avg_line_length": 27.3823529412,
"ext": "agda",
"hexsha": "df48ebfb6513c4a6460af1fa21e9e1c7eacff68b",
"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": "c8954c8acd8089ced82af9e05084fbbc7fedb36c",
"max_forks_repo_licenses": [
"0BSD"
],
"max_forks_repo_name": "ashinkarov/agda-extractor",
"max_forks_repo_path": "Example-03.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c8954c8acd8089ced82af9e05084fbbc7fedb36c",
"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": "ashinkarov/agda-extractor",
"max_issues_repo_path": "Example-03.agda",
"max_line_length": 114,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "c8954c8acd8089ced82af9e05084fbbc7fedb36c",
"max_stars_repo_licenses": [
"0BSD"
],
"max_stars_repo_name": "ashinkarov/agda-extractor",
"max_stars_repo_path": "Example-03.agda",
"max_stars_repo_stars_event_max_datetime": "2021-01-11T14:52:59.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-01-11T14:52:59.000Z",
"num_tokens": 1738,
"size": 3724
} |
module Structure.Relator.Ordering.Proofs where
import Lvl
open import Functional
open import Lang.Instance
open import Logic
open import Structure.Relator.Ordering
open import Structure.Relator.Properties
open import Syntax.Transitivity
open import Type
private variable ℓ : Lvl.Level
private variable A B : Type{ℓ}
private variable _≤_ _≤₁_ _≤₂_ : A → A → Stmt{ℓ}
private variable f : A → B
private variable x : A
module _ ⦃ trans : Transitivity{T = B}(_≤_) ⦄ where
open Strict.Properties
-- TODO: Agda bug 20200523 does not allow instance arg
accessibleₗ-image-by-trans : Accessibleₗ{T = B}(_≤_)(f(x)) → Accessibleₗ((_≤_) on₂ f)(x)
accessibleₗ-image-by-trans {f = f} {y} (intro ⦃ acc ⦄) = intro ⦃ \{x} ⦃ xy ⦄ → intro ⦃ \{a} ⦃ ax ⦄ → accessibleₗ-image-by-trans (acc {f(a)} ⦃ transitivity(_≤_) ax xy ⦄ ) ⦄ ⦄
wellfounded-image-by-trans : ∀{f : A → B} → ⦃ _ : WellFounded{T = B}(_≤_) ⦄ → WellFounded((_≤_) on₂ f)
wellfounded-image-by-trans = accessibleₗ-image-by-trans infer
module _ ⦃ refl : Reflexivity{T = B}(_≤_) ⦄ where
open Strict.Properties
accessibleₗ-image-by-refl : ⦃ _ : Accessibleₗ{T = B}(_≤_)(f(x)) ⦄ → Accessibleₗ((_≤_) on₂ f)(x)
accessibleₗ-image-by-refl {f = f} {y} ⦃ intro ⦃ acc ⦄ ⦄ = accessibleₗ-image-by-refl ⦃ acc{f(y)} ⦃ reflexivity(_≤_) ⦄ ⦄
wellfounded-image-by-refl : ∀{f : A → B} → ⦃ _ : WellFounded{T = B}(_≤_) ⦄ → WellFounded((_≤_) on₂ f)
wellfounded-image-by-refl = accessibleₗ-image-by-refl
module _ ⦃ sub : (_≤₁_) ⊆₂ (_≤₂_) ⦄ where
open Strict.Properties
accessibleₗ-sub₂ : ⦃ _ : Accessibleₗ(_≤₂_)(x) ⦄ → Accessibleₗ(_≤₁_)(x)
accessibleₗ-sub₂ {x = y} ⦃ intro ⦃ acc ⦄ ⦄ = intro ⦃ \{x} ⦃ xy ⦄ → accessibleₗ-sub₂ ⦃ acc{x} ⦃ sub₂(_≤₁_)(_≤₂_) xy ⦄ ⦄ ⦄
wellfounded-sub₂ : ⦃ _ : WellFounded(_≤₂_) ⦄ → WellFounded(_≤₁_)
wellfounded-sub₂ = accessibleₗ-sub₂
| {
"alphanum_fraction": 0.6577070762,
"avg_line_length": 40.5111111111,
"ext": "agda",
"hexsha": "2df7e6ad1f25a7389e82a84c195d9d3b27e8775e",
"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/Relator/Ordering/Proofs.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/Relator/Ordering/Proofs.agda",
"max_line_length": 175,
"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/Relator/Ordering/Proofs.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": 741,
"size": 1823
} |
{-# OPTIONS --safe #-}
module Cubical.Algebra.AbGroup.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Equiv.HalfAdjoint
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.Transport
open import Cubical.Foundations.SIP
open import Cubical.Data.Sigma
open import Cubical.Data.Unit
open import Cubical.Algebra.Monoid
open import Cubical.Algebra.CommMonoid
open import Cubical.Algebra.Group
open import Cubical.Algebra.Group.Morphisms
open import Cubical.Algebra.Group.MorphismProperties
open import Cubical.Algebra.Group.DirProd
open import Cubical.Displayed.Base
open import Cubical.Displayed.Auto
open import Cubical.Displayed.Record
open import Cubical.Displayed.Universe
open import Cubical.Reflection.RecordEquiv
open Iso
private
variable
ℓ ℓ' : Level
record IsAbGroup {G : Type ℓ}
(0g : G) (_+_ : G → G → G) (-_ : G → G) : Type ℓ where
constructor isabgroup
field
isGroup : IsGroup 0g _+_ -_
+Comm : (x y : G) → x + y ≡ y + x
open IsGroup isGroup public
renaming
( ·Assoc to +Assoc
; ·IdL to +IdL
; ·IdR to +IdR
; ·InvL to +InvL
; ·InvR to +InvR)
infixl 6 _-_
-- Useful notation for additive groups
_-_ : G → G → G
x - y = x + (- y)
unquoteDecl IsAbGroupIsoΣ = declareRecordIsoΣ IsAbGroupIsoΣ (quote IsAbGroup)
record AbGroupStr (A : Type ℓ) : Type (ℓ-suc ℓ) where
constructor abgroupstr
field
0g : A
_+_ : A → A → A
-_ : A → A
isAbGroup : IsAbGroup 0g _+_ -_
infixr 7 _+_
infix 8 -_
open IsAbGroup isAbGroup public
AbGroup : ∀ ℓ → Type (ℓ-suc ℓ)
AbGroup ℓ = TypeWithStr ℓ AbGroupStr
module _ {G : Type ℓ} {0g : G} {_+_ : G → G → G} { -_ : G → G}
(is-setG : isSet G)
(+Assoc : (x y z : G) → x + (y + z) ≡ (x + y) + z)
(+IdR : (x : G) → x + 0g ≡ x)
(+InvR : (x : G) → x + (- x) ≡ 0g)
(+Comm : (x y : G) → x + y ≡ y + x)
where
makeIsAbGroup : IsAbGroup 0g _+_ -_
makeIsAbGroup .IsAbGroup.isGroup =
makeIsGroup is-setG +Assoc +IdR
(λ x → +Comm _ _ ∙ +IdR x)
+InvR
(λ x → +Comm _ _ ∙ +InvR x)
makeIsAbGroup .IsAbGroup.+Comm = +Comm
module _ {G : Type ℓ} (0g : G) (_+_ : G → G → G) (-_ : G → G)
(is-setG : isSet G)
(+Assoc : (x y z : G) → x + (y + z) ≡ (x + y) + z)
(+IdR : (x : G) → x + 0g ≡ x)
(+InvR : (x : G) → x + (- x) ≡ 0g)
(+Comm : (x y : G) → x + y ≡ y + x)
where
makeAbGroup : AbGroup ℓ
makeAbGroup .fst = G
makeAbGroup .snd .AbGroupStr.0g = 0g
makeAbGroup .snd .AbGroupStr._+_ = _+_
makeAbGroup .snd .AbGroupStr.-_ = -_
makeAbGroup .snd .AbGroupStr.isAbGroup = makeIsAbGroup is-setG +Assoc +IdR +InvR +Comm
open GroupStr
open AbGroupStr
open IsAbGroup
AbGroupStr→GroupStr : {G : Type ℓ} → AbGroupStr G → GroupStr G
AbGroupStr→GroupStr A .1g = A .0g
AbGroupStr→GroupStr A ._·_ = A ._+_
AbGroupStr→GroupStr A .inv = A .-_
AbGroupStr→GroupStr A .isGroup = A .isAbGroup .isGroup
AbGroup→Group : AbGroup ℓ → Group ℓ
fst (AbGroup→Group A) = fst A
snd (AbGroup→Group A) = AbGroupStr→GroupStr (snd A)
Group→AbGroup : (G : Group ℓ) → ((x y : fst G) → _·_ (snd G) x y ≡ _·_ (snd G) y x) → AbGroup ℓ
fst (Group→AbGroup G +Comm) = fst G
AbGroupStr.0g (snd (Group→AbGroup G +Comm)) = 1g (snd G)
AbGroupStr._+_ (snd (Group→AbGroup G +Comm)) = _·_ (snd G)
AbGroupStr.- snd (Group→AbGroup G +Comm) = inv (snd G)
IsAbGroup.isGroup (AbGroupStr.isAbGroup (snd (Group→AbGroup G +Comm))) = isGroup (snd G)
IsAbGroup.+Comm (AbGroupStr.isAbGroup (snd (Group→AbGroup G +Comm))) = +Comm
module _ ((G , abgroupstr _ _ _ GisGroup) : AbGroup ℓ) where
AbGroup→CommMonoid : CommMonoid ℓ
AbGroup→CommMonoid .fst = G
AbGroup→CommMonoid .snd .CommMonoidStr.ε = _
AbGroup→CommMonoid .snd .CommMonoidStr._·_ = _
AbGroup→CommMonoid .snd .CommMonoidStr.isCommMonoid .IsCommMonoid.isMonoid = IsAbGroup.isMonoid GisGroup
AbGroup→CommMonoid .snd .CommMonoidStr.isCommMonoid .IsCommMonoid.·Comm = IsAbGroup.+Comm GisGroup
isSetAbGroup : (A : AbGroup ℓ) → isSet ⟨ A ⟩
isSetAbGroup A = isSetGroup (AbGroup→Group A)
AbGroupHom : (G : AbGroup ℓ) (H : AbGroup ℓ') → Type (ℓ-max ℓ ℓ')
AbGroupHom G H = GroupHom (AbGroup→Group G) (AbGroup→Group H)
AbGroupIso : (G : AbGroup ℓ) (H : AbGroup ℓ') → Type (ℓ-max ℓ ℓ')
AbGroupIso G H = GroupIso (AbGroup→Group G) (AbGroup→Group H)
IsAbGroupEquiv : {A : Type ℓ} {B : Type ℓ'}
(G : AbGroupStr A) (e : A ≃ B) (H : AbGroupStr B) → Type (ℓ-max ℓ ℓ')
IsAbGroupEquiv G e H = IsGroupHom (AbGroupStr→GroupStr G) (e .fst) (AbGroupStr→GroupStr H)
AbGroupEquiv : (G : AbGroup ℓ) (H : AbGroup ℓ') → Type (ℓ-max ℓ ℓ')
AbGroupEquiv G H = Σ[ e ∈ (G .fst ≃ H .fst) ] IsAbGroupEquiv (G .snd) e (H .snd)
isPropIsAbGroup : {G : Type ℓ} (0g : G) (_+_ : G → G → G) (-_ : G → G)
→ isProp (IsAbGroup 0g _+_ (-_))
isPropIsAbGroup 0g _+_ -_ =
isOfHLevelRetractFromIso 1 IsAbGroupIsoΣ
(isPropΣ (isPropIsGroup 0g _+_ (-_))
(λ grp → isPropΠ2 (λ _ _ → grp .is-set _ _)))
where
open IsGroup
𝒮ᴰ-AbGroup : DUARel (𝒮-Univ ℓ) AbGroupStr ℓ
𝒮ᴰ-AbGroup =
𝒮ᴰ-Record (𝒮-Univ _) IsAbGroupEquiv
(fields:
data[ _+_ ∣ autoDUARel _ _ ∣ pres· ]
data[ 0g ∣ autoDUARel _ _ ∣ pres1 ]
data[ -_ ∣ autoDUARel _ _ ∣ presinv ]
prop[ isAbGroup ∣ (λ _ _ → isPropIsAbGroup _ _ _) ])
where
open AbGroupStr
open IsGroupHom
-- Extract the characterization of equality of groups
AbGroupPath : (G H : AbGroup ℓ) → (AbGroupEquiv G H) ≃ (G ≡ H)
AbGroupPath = ∫ 𝒮ᴰ-AbGroup .UARel.ua
-- The module below defines an abelian group induced from an
-- equivalence between an abelian group G and a type A which preserves
-- the full raw group structure from G to A. This version is useful
-- when proving that some type equivalent to an abelian group is an
-- abelian group while also specifying the binary operation, unit and
-- inverse. For an example of this see Algebra.Matrix
module _ (G : AbGroup ℓ) {A : Type ℓ}
(m : A → A → A)
(u : A)
(inverse : A → A)
(e : ⟨ G ⟩ ≃ A)
(p+ : ∀ x y → e .fst (G .snd ._+_ x y) ≡ m (e .fst x) (e .fst y))
(pu : e .fst (G .snd .0g) ≡ u)
(pinv : ∀ x → e .fst (G .snd .-_ x) ≡ inverse (e .fst x))
where
private
module G = AbGroupStr (G .snd)
BaseΣ : Type (ℓ-suc ℓ)
BaseΣ = Σ[ B ∈ Type ℓ ] (B → B → B) × B × (B → B)
FamilyΣ : BaseΣ → Type ℓ
FamilyΣ (B , m , u , i) = IsAbGroup u m i
inducedΣ : FamilyΣ (A , m , u , inverse)
inducedΣ =
subst FamilyΣ
(UARel.≅→≡ (autoUARel BaseΣ) (e , p+ , pu , pinv))
G.isAbGroup
InducedAbGroup : AbGroup ℓ
InducedAbGroup .fst = A
InducedAbGroup .snd ._+_ = m
InducedAbGroup .snd .0g = u
InducedAbGroup .snd .-_ = inverse
InducedAbGroup .snd .isAbGroup = inducedΣ
InducedAbGroupEquiv : AbGroupEquiv G InducedAbGroup
fst InducedAbGroupEquiv = e
snd InducedAbGroupEquiv = makeIsGroupHom p+
InducedAbGroupPath : G ≡ InducedAbGroup
InducedAbGroupPath = AbGroupPath _ _ .fst InducedAbGroupEquiv
-- The module below defines an abelian group induced from an
-- equivalence which preserves the binary operation (i.e. a group
-- isomorphism). This version is useful when proving that some type
-- equivalent to an abelian group G is an abelian group when one
-- doesn't care about what the unit and inverse are. When using this
-- version the unit and inverse will both be defined by transporting
-- over the unit and inverse from G to A.
module _ (G : AbGroup ℓ) {A : Type ℓ}
(m : A → A → A)
(e : ⟨ G ⟩ ≃ A)
(p· : ∀ x y → e .fst (G .snd ._+_ x y) ≡ m (e .fst x) (e .fst y))
where
private
module G = AbGroupStr (G .snd)
FamilyΣ : Σ[ B ∈ Type ℓ ] (B → B → B) → Type ℓ
FamilyΣ (B , n) = Σ[ e ∈ B ] Σ[ i ∈ (B → B) ] IsAbGroup e n i
inducedΣ : FamilyΣ (A , m)
inducedΣ =
subst FamilyΣ
(UARel.≅→≡ (autoUARel (Σ[ B ∈ Type ℓ ] (B → B → B))) (e , p·))
(G.0g , G.-_ , G.isAbGroup)
InducedAbGroupFromPres· : AbGroup ℓ
InducedAbGroupFromPres· .fst = A
InducedAbGroupFromPres· .snd ._+_ = m
InducedAbGroupFromPres· .snd .0g = inducedΣ .fst
InducedAbGroupFromPres· .snd .-_ = inducedΣ .snd .fst
InducedAbGroupFromPres· .snd .isAbGroup = inducedΣ .snd .snd
InducedAbGroupEquivFromPres· : AbGroupEquiv G InducedAbGroupFromPres·
fst InducedAbGroupEquivFromPres· = e
snd InducedAbGroupEquivFromPres· = makeIsGroupHom p·
InducedAbGroupPathFromPres· : G ≡ InducedAbGroupFromPres·
InducedAbGroupPathFromPres· = AbGroupPath _ _ .fst InducedAbGroupEquivFromPres·
dirProdAb : AbGroup ℓ → AbGroup ℓ' → AbGroup (ℓ-max ℓ ℓ')
dirProdAb A B =
Group→AbGroup (DirProd (AbGroup→Group A) (AbGroup→Group B))
λ p q → ΣPathP (+Comm (isAbGroup (snd A)) _ _
, +Comm (isAbGroup (snd B)) _ _)
trivialAbGroup : ∀ {ℓ} → AbGroup ℓ
fst trivialAbGroup = Unit*
0g (snd trivialAbGroup) = tt*
_+_ (snd trivialAbGroup) _ _ = tt*
(- snd trivialAbGroup) _ = tt*
isAbGroup (snd trivialAbGroup) = makeIsAbGroup
(isProp→isSet isPropUnit*)
(λ _ _ _ → refl)
(λ _ → refl)
(λ _ → refl)
(λ _ _ → refl)
-- useful lemma
-- duplicate propeerties => this file should be split !
move4 : ∀ {ℓ} {A : Type ℓ} (x y z w : A) (_+_ : A → A → A)
→ ((x y z : A) → x + (y + z) ≡ (x + y) + z)
→ ((x y : A) → x + y ≡ y + x)
→ (x + y) + (z + w) ≡ ((x + z) + (y + w))
move4 x y z w _+_ assoc +Comm =
sym (assoc x y (z + w))
∙∙ cong (x +_) (assoc y z w ∙∙ cong (_+ w) (+Comm y z) ∙∙ sym (assoc z y w))
∙∙ assoc x z (y + w)
---- The type of homomorphisms A → B is an AbGroup if B is -----
module _ {ℓ ℓ' : Level} (AGr : Group ℓ) (BGr : AbGroup ℓ') where
private
strA = snd AGr
strB = snd BGr
_* = AbGroup→Group
A = fst AGr
B = fst BGr
open IsGroupHom
open AbGroupStr strB
renaming (_+_ to _+B_ ; -_ to -B_ ; 0g to 0B
; +IdR to +IdRB ; +IdL to +IdLB
; +Assoc to +AssocB ; +Comm to +CommB
; +InvR to +InvRB ; +InvL to +InvLB)
open GroupStr strA
renaming (_·_ to _∙A_ ; inv to -A_
; 1g to 1A ; ·IdR to ·IdRA)
trivGroupHom : GroupHom AGr (BGr *)
fst trivGroupHom x = 0B
snd trivGroupHom = makeIsGroupHom λ _ _ → sym (+IdRB 0B)
compHom : GroupHom AGr (BGr *) → GroupHom AGr (BGr *) → GroupHom AGr (BGr *)
fst (compHom f g) x = fst f x +B fst g x
snd (compHom f g) =
makeIsGroupHom λ x y
→ cong₂ _+B_ (pres· (snd f) x y) (pres· (snd g) x y)
∙ move4 (fst f x) (fst f y) (fst g x) (fst g y)
_+B_ +AssocB +CommB
invHom : GroupHom AGr (BGr *) → GroupHom AGr (BGr *)
fst (invHom (f , p)) x = -B f x
snd (invHom (f , p)) =
makeIsGroupHom
λ x y → cong -B_ (pres· p x y)
∙∙ GroupTheory.invDistr (BGr *) (f x) (f y)
∙∙ +CommB _ _
open AbGroupStr
HomGroup : AbGroup (ℓ-max ℓ ℓ')
fst HomGroup = GroupHom AGr (BGr *)
0g (snd HomGroup) = trivGroupHom
_+_ (snd HomGroup) = compHom
- snd HomGroup = invHom
isAbGroup (snd HomGroup) =
makeIsAbGroup
isSetGroupHom
(λ { (f , p) (g , q) (h , r) → Σ≡Prop (λ _ → isPropIsGroupHom _ _)
(funExt λ x → +AssocB _ _ _) })
(λ { (f , p) → Σ≡Prop (λ _ → isPropIsGroupHom _ _) (funExt λ y → +IdRB _)})
((λ { (f , p) → Σ≡Prop (λ _ → isPropIsGroupHom _ _) (funExt λ y → +InvRB _)}))
(λ { (f , p) (g , q) → Σ≡Prop (λ _ → isPropIsGroupHom _ _) (funExt λ x → +CommB _ _)})
| {
"alphanum_fraction": 0.601754238,
"avg_line_length": 33.3061797753,
"ext": "agda",
"hexsha": "653714290f7e7236148025f593f96dbc656cb5e8",
"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/AbGroup/Base.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/AbGroup/Base.agda",
"max_line_length": 106,
"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/AbGroup/Base.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 4438,
"size": 11857
} |
------------------------------------------------------------------------
-- INCREMENTAL λ-CALCULUS
--
-- Dependently typed changes with the Nehemiah plugin.
------------------------------------------------------------------------
module Nehemiah.Change.Validity where
open import Nehemiah.Syntax.Type
open import Nehemiah.Denotation.Value
import Parametric.Change.Validity ⟦_⟧Base as Validity
open import Nehemiah.Change.Type
open import Nehemiah.Change.Value
open import Data.Integer
open import Structure.Bag.Nehemiah
open import Base.Change.Algebra
open import Level
change-algebra-base : ∀ ι → ChangeAlgebra ⟦ ι ⟧Base
change-algebra-base base-int = GroupChanges.changeAlgebraGroup _ {{abelian-int}}
change-algebra-base base-bag = GroupChanges.changeAlgebraGroup _ {{abelian-bag}}
instance
change-algebra-base-family : ChangeAlgebraFamily ⟦_⟧Base
change-algebra-base-family = family change-algebra-base
open Validity.Structure {{change-algebra-base-family}} public
| {
"alphanum_fraction": 0.6822810591,
"avg_line_length": 30.6875,
"ext": "agda",
"hexsha": "5fc1bf8b827963c9e41f6c42952ecde7ec074d50",
"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/Validity.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/Validity.agda",
"max_line_length": 80,
"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/Validity.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": 213,
"size": 982
} |
open import Oscar.Prelude
open import Oscar.Data.𝟘
module Oscar.Data.Proposequality where
module _ where
data Proposequality {𝔬} {𝔒 : Ø 𝔬} (𝓞 : 𝔒) : 𝔒 → Ø₀ where
instance ∅ : Proposequality 𝓞 𝓞
{-# BUILTIN EQUALITY Proposequality #-}
Proposequality⟦_⟧ : ∀ {𝔬} (𝔒 : Ø 𝔬) → 𝔒 → 𝔒 → Ø₀
Proposequality⟦ _ ⟧ = Proposequality
[Proposequality] : ∀ {𝔬} {𝔒 : Ø 𝔬} → {x y : 𝔒} → Ø₀
[Proposequality] {x = x} {y = y} = Proposequality x y
module _ where
infix 4 _≡_
_≡_ = Proposequality
-- transport : ∀ {a b} {A : Set a} (B : A → Set b) {x y} → x ≡ y → B x → B y
-- transport _ ∅ = ¡
-- transport₂ : ∀ {a b c} {A : Set a} {B : Set b} (C : A → B → Set c) {x₁ x₂ y₁ y₂} → x₁ ≡ x₂ → y₁ ≡ y₂ → C x₁ y₁ → C x₂ y₂
-- transport₂ _ ∅ ∅ = ¡
module _ where
Proposantiequality : ∀ {𝔬} {𝔒 : Ø 𝔬} → 𝔒 → 𝔒 → Ø₀
Proposantiequality x y = Proposequality x y → 𝟘
Proposantiequality⟦_⟧ : ∀ {𝔬} (𝔒 : Ø 𝔬) → 𝔒 → 𝔒 → Ø₀
Proposantiequality⟦ _ ⟧ = Proposantiequality
infix 4 _≢_
_≢_ = Proposantiequality
module _ where
Proposextensequality : ∀ {𝔬} {𝔒 : Ø 𝔬} {𝔭} {𝔓 : 𝔒 → Ø 𝔭} → ((𝓞 : 𝔒) → 𝔓 𝓞) → ((𝓞 : 𝔒) → 𝔓 𝓞) → Ø 𝔬
Proposextensequality 𝓟₁ 𝓟₂ = ∀ 𝓞 → Proposequality (𝓟₁ 𝓞) (𝓟₂ 𝓞)
Proposextensequality⟦_⟧ : ∀ {𝔬} {𝔒 : Ø 𝔬} {𝔭} (𝔓 : 𝔒 → Ø 𝔭) → ((𝓞 : 𝔒) → 𝔓 𝓞) → ((𝓞 : 𝔒) → 𝔓 𝓞) → Ø 𝔬
Proposextensequality⟦ _ ⟧ = Proposextensequality
Proposextensequality[_/_] : ∀ {𝔬} (𝔒 : Ø 𝔬) {𝔭} (𝔓 : 𝔒 → Ø 𝔭) → ((𝓞 : 𝔒) → 𝔓 𝓞) → ((𝓞 : 𝔒) → 𝔓 𝓞) → Ø 𝔬
Proposextensequality[ _ / _ ] = Proposextensequality
module _ where
infix 4 _≡̇_
_≡̇_ = Proposextensequality
infix 4 ≡̇⟦⟧-syntax
≡̇⟦⟧-syntax = Proposextensequality⟦_⟧
syntax ≡̇⟦⟧-syntax t x y = x ≡̇⟦ t ⟧ y
| {
"alphanum_fraction": 0.5650623886,
"avg_line_length": 27.5901639344,
"ext": "agda",
"hexsha": "252f2a556c699454c40d8fae8063b052cba0279d",
"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-3/src/Oscar/Data/Proposequality.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-3/src/Oscar/Data/Proposequality.agda",
"max_line_length": 123,
"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-3/src/Oscar/Data/Proposequality.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 923,
"size": 1683
} |
-- Andreas, 2016-02-09, should not record sections have all hidden parameters?
module _ (A : Set) where
record R : Set where
postulate
P : (a : A) → Set
-- Records have some magic to make record parameters hidden
-- in record section.
-- This leads to an error in @checkInternal@.
-- Should the parent parameters alse be hidden in the record section?
record Fails (a : A) : Set where
T = (w p : R.P _ a) → Set -- well-formed
f : R.P _ a → Set
f p with p
... | _ = A
-- ERROR:
-- Expected a hidden argument, but found a visible argument
-- when checking that the type (w p : R.P _ a) → Set of the generated
-- with function is well-formed
-- Should succeed.
| {
"alphanum_fraction": 0.6415362731,
"avg_line_length": 25.1071428571,
"ext": "agda",
"hexsha": "d4e571436d143557c113544b76011841189698a6",
"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/Issue1759-record.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/Issue1759-record.agda",
"max_line_length": 78,
"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/Issue1759-record.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": 198,
"size": 703
} |
-- Category of sets and functions
module Control.Category.SetsAndFunctions where
open import Level using (zero; suc; _⊔_)
open import Relation.Binary.PropositionalEquality
open import Relation.Binary
open import Data.Product
open import Axiom.FunctionExtensionality
open import Control.Category
open import Control.Category.Product
-- Category SET
Functions : Set → Set → Setoid _ _
Functions A B = setoid (A → B)
setIsCategory : IsCategory Functions
setIsCategory = record
{ ops = record
{ id = λ x → x
; _⟫_ = λ f g x → g (f x)
}
; laws = record
{ id-first = refl
; id-last = refl
; ∘-assoc = λ f → refl
; ∘-cong = λ{ refl refl → refl }
}
}
SET : Category _ _ _
SET = record { Hom = Functions; isCategory = setIsCategory }
{-
timesProductStructure : (A B : Set) → ProductStructure SET A B
timesProductStructure A B = record
{ A×B = A × B
; fst = proj₁
; snd = proj₂
}
⟨_,_⟩ : {A B C : Set} (f : C → A) (g : C → B) → C → A × B
⟨ f , g ⟩ = λ x → f x , g x
pairIsPair : {A B C : Set} (f : C → A) (g : C → B) →
IsPair (timesProductStructure A B) f g ⟨ f , g ⟩
pairIsPair f g = record
{ β-fst = refl
; β-snd = refl
}
open IsPair
pairPair : {A B C : Set} (f : C → A) (g : C → B) →
Pair (timesProductStructure A B) f g
pairPair f g = record
{ ⟨f,g⟩ = ⟨ f , g ⟩
; isPair = pairIsPair f g
; unique = λ p → fun-ext (λ x → cong₂ (λ f g → f x , g x) (β-fst p) (β-snd p))
}
timesIsProduct : (A B : Set) → Product SET A B
timesIsProduct A B = record
{ productStructure = timesProductStructure A B
; isProduct = record { pair = pairPair }
}
-- -}
| {
"alphanum_fraction": 0.6078672403,
"avg_line_length": 22.5972222222,
"ext": "agda",
"hexsha": "008d33b7fe83b8144d223849f1cd11825571ab49",
"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": "914f655c7c0417754c2ffe494d3f6ea7a357b1c3",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "andreasabel/cubical",
"max_forks_repo_path": "src/Control/Category/SetsAndFunctions.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "914f655c7c0417754c2ffe494d3f6ea7a357b1c3",
"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": "andreasabel/cubical",
"max_issues_repo_path": "src/Control/Category/SetsAndFunctions.agda",
"max_line_length": 81,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "914f655c7c0417754c2ffe494d3f6ea7a357b1c3",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "andreasabel/cubical",
"max_stars_repo_path": "src/Control/Category/SetsAndFunctions.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 562,
"size": 1627
} |
------------------------------------------------------------------------
-- A lemma
------------------------------------------------------------------------
open import Mixfix.Expr
open import Mixfix.Acyclic.PrecedenceGraph using (acyclic)
module Mixfix.Acyclic.Lemma
(g : PrecedenceGraphInterface.PrecedenceGraph acyclic)
where
open import Data.List using ([]; _∷_)
open import Data.List.NonEmpty as List⁺ using (List⁺; _∷_; foldl; _⁺∷ʳ_)
open import Data.Product using (uncurry)
open import Relation.Binary.PropositionalEquality
using (_≡_; refl)
open PrecedenceCorrect acyclic g
open import Mixfix.Fixity
-- A generalisation of Mixfix.Acyclic.Grammar.Prec.appˡ.
appˡ : ∀ {p} → Outer p left → List⁺ (Outer p left → ExprIn p left) →
ExprIn p left
appˡ e fs = foldl (λ e f → f (similar e)) (λ f → f e) fs
appˡ-∷ʳ : ∀ {p} (e : Outer p left) fs f →
appˡ e (fs ⁺∷ʳ f) ≡ f (similar (appˡ e fs))
appˡ-∷ʳ e (f′ ∷ fs) = helper e f′ fs
where
helper : ∀ {p} (e : Outer p left) f′ fs f →
appˡ e ((f′ ∷ fs) ⁺∷ʳ f) ≡ f (similar (appˡ e (f′ ∷ fs)))
helper e f′ [] f = refl
helper e f′ (f″ ∷ fs) f = helper (similar (f′ e)) f″ fs f
| {
"alphanum_fraction": 0.5505050505,
"avg_line_length": 33.9428571429,
"ext": "agda",
"hexsha": "cfbcb8f2f0618e66cd1d5aae94c34b02560c5f1f",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/parser-combinators",
"max_forks_repo_path": "Mixfix/Acyclic/Lemma.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644",
"max_issues_repo_issues_event_max_datetime": "2018-01-24T16:39:37.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-01-22T22:21:41.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/parser-combinators",
"max_issues_repo_path": "Mixfix/Acyclic/Lemma.agda",
"max_line_length": 72,
"max_stars_count": 7,
"max_stars_repo_head_hexsha": "b396d35cc2cb7e8aea50b982429ee385f001aa88",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "yurrriq/parser-combinators",
"max_stars_repo_path": "Mixfix/Acyclic/Lemma.agda",
"max_stars_repo_stars_event_max_datetime": "2021-06-22T05:35:31.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-12-13T05:23:14.000Z",
"num_tokens": 393,
"size": 1188
} |
{-# OPTIONS --copatterns --sized-types #-}
open import Function
open import Data.Unit as Unit renaming (tt to ∗)
open import Data.List as List
TyCtx = List ⊤
data TyVar : (Γ : TyCtx) → Set where
zero : ∀{Γ} → TyVar (∗ ∷ Γ)
succ : ∀{Γ} → (x : TyVar Γ) → TyVar (∗ ∷ Γ)
data Type (Γ : TyCtx) : Set where
unit : Type Γ
var : (x : TyVar Γ) → Type Γ
_⊕_ : (t₁ : Type Γ) (t₂ : Type Γ) → Type Γ
μ : (t : Type (_ ∷ Γ)) → Type Γ
_⊗_ : (t₁ : Type Γ) (t₂ : Type Γ) → Type Γ
_⇒_ : (t₁ : Type []) (t₂ : Type Γ) → Type Γ
ν : (t : Type (_ ∷ Γ)) → Type Γ
-- | Variable renaming in types
_▹_ : (Γ Δ : TyCtx) → Set
Γ ▹ Δ = TyVar Γ → TyVar Δ
{-
rename : {Γ Δ : TyCtx} → (ρ : Γ ▹ Δ) → Type Γ → Type Δ
rename ρ unit = unit
rename ρ (var x) = var (ρ ∗ x)
rename ρ (t₁ ⊕ t₂) = rename ρ t₁ ⊕ rename ρ t₂
rename {Γ} {Δ} ρ (μ t) = μ (rename ρ' t)
where
ρ' : (∗ ∷ Γ) ▹ (∗ ∷ Δ)
ρ' = ?
-- ρ' = id {[ ∗ ]} ⧻ ρ
rename ρ (t₁ ⊗ t₂) = rename ρ t₁ ⊗ rename ρ t₂
rename ρ (t₁ ⇒ t₂) = t₁ ⇒ rename ρ t₂
rename {Γ} {Δ} ρ (ν t) = ν (rename ρ' t)
where
ρ' : (∗ ∷ Γ) ▹ (∗ ∷ Δ)
ρ' = ?
-- ρ' = ctx-id {[ ∗ ]} ⧻ ρ
-------------------------
---- Generating structure on contexts (derived from renaming)
weaken : {Γ : TyCtx} (Δ : TyCtx) → Type Γ -> Type (Δ ++ Γ)
weaken {Γ} Δ = rename {Γ} {Δ ++ Γ} ?
exchange : (Γ Δ : TyCtx) → Type (Γ ++ Δ) -> Type (Δ ++ Γ)
exchange Γ Δ = rename [ i₂ {Δ} {Γ} , i₁ {Δ} {Γ} ]
contract : {Γ : TyCtx} → Type (Γ ∐ Γ) -> Type Γ
contract = rename [ ctx-id , ctx-id ]
-}
Subst : TyCtx → TyCtx → Set
Subst Γ Δ = TyVar Γ → Type Δ
update : ∀{Γ Δ : TyCtx} → Subst Γ Δ → Type Δ → (Subst (∗ ∷ Γ) Δ)
update σ a zero = a
update σ _ (succ x) = σ x
lift : ∀{Γ Δ} → Subst Γ Δ → Subst (∗ ∷ Γ) (∗ ∷ Δ)
lift σ zero = {!!}
lift σ (succ x) = {!!}
-- | Simultaneous substitution
subst : {Γ Δ : TyCtx} → (σ : Subst Γ Δ) → Type Γ → Type Δ
subst σ unit = unit
subst σ (var x) = σ x
subst σ (t₁ ⊕ t₂) = subst σ t₁ ⊕ subst σ t₂
subst {Γ} {Δ} σ (μ t) = μ (subst (lift σ) t)
subst σ (t₁ ⊗ t₂) = subst σ t₁ ⊗ subst σ t₂
subst σ (t₁ ⇒ t₂) = t₁ ⇒ subst σ t₂
subst {Γ} {Δ} σ (ν t) = ν (subst (lift σ) t)
data Term : Set where
| {
"alphanum_fraction": 0.4578111947,
"avg_line_length": 29.1951219512,
"ext": "agda",
"hexsha": "fbff2710b40d4457aaa2208ac4407eb0e5b6c8e9",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "hbasold/Sandbox",
"max_forks_repo_path": "ON/ON.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "hbasold/Sandbox",
"max_issues_repo_path": "ON/ON.agda",
"max_line_length": 64,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "hbasold/Sandbox",
"max_stars_repo_path": "ON/ON.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 997,
"size": 2394
} |
module Fold where
open import Prelude
myfold : {ac b : Set} -> (ac -> b -> ac) -> ac -> List b -> ac
#ifdef strict
myfold = foldl!
#else
myfold = foldl
#endif
| {
"alphanum_fraction": 0.6172839506,
"avg_line_length": 13.5,
"ext": "agda",
"hexsha": "3f6bea640cbef2f9937f803ae733c80457e4fde9",
"lang": "Agda",
"max_forks_count": 7,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:48.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-05-24T10:45:59.000Z",
"max_forks_repo_head_hexsha": "026a8f8473ab91f99c3f6545728e71fa847d2720",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "xekoukou/agda-ocaml",
"max_forks_repo_path": "benchmark/agda-ocaml/Fold0.agda",
"max_issues_count": 16,
"max_issues_repo_head_hexsha": "026a8f8473ab91f99c3f6545728e71fa847d2720",
"max_issues_repo_issues_event_max_datetime": "2019-09-08T13:47:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-10-08T00:32:04.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "xekoukou/agda-ocaml",
"max_issues_repo_path": "benchmark/agda-ocaml/Fold0.agda",
"max_line_length": 62,
"max_stars_count": 48,
"max_stars_repo_head_hexsha": "e38b699870ba638221828b07b12948d70a1bdaec",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "agda/agda-ocaml",
"max_stars_repo_path": "benchmark/agda-ocaml/Fold0.agda",
"max_stars_repo_stars_event_max_datetime": "2021-08-15T09:08:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-03-29T14:19:31.000Z",
"num_tokens": 52,
"size": 162
} |
------------------------------------------------------------------------
-- The double-negation monad
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Equality
module Double-negation
{reflexive} (eq : ∀ {a p} → Equality-with-J a p reflexive) where
open import Logical-equivalence using (_⇔_)
open import Prelude
open import Bijection eq using (_↔_)
open Derived-definitions-and-properties eq
open import Equivalence eq hiding (id; _∘_)
open import Excluded-middle eq
open import H-level eq
open import H-level.Closure eq
open import Monad eq
-- The double-negation monad, defined using a wrapper type to make
-- instance resolution easier.
infix 3 ¬¬_
record ¬¬_ {a} (A : Type a) : Type a where
constructor wrap
field
run : ¬ ¬ A
open ¬¬_ public
-- An extra universe-polymorphic variant of map.
map′ :
∀ {a b} {@0 A : Type a} {@0 B : Type b} →
(A → B) → ¬¬ A → ¬¬ B
run (map′ f ¬¬a) = λ ¬b → run ¬¬a (λ a → ¬b (f a))
-- Instances.
instance
double-negation-monad : ∀ {ℓ} → Raw-monad (λ (A : Type ℓ) → ¬¬ A)
run (Raw-monad.return double-negation-monad x) = _$ x
run (Raw-monad._>>=_ double-negation-monad x f) =
join (map′ (run ∘ f) x)
where
join : ∀ {a} {A : Type a} → ¬¬ ¬ A → ¬ A
join ¬¬¬a = λ a → run ¬¬¬a (λ ¬a → ¬a a)
private
proof-irrelevant : ∀ {a} {A : Type a} {x y : ¬¬ A} →
Extensionality a lzero → x ≡ y
proof-irrelevant ext =
cong wrap $ apply-ext ext λ _ → ⊥-propositional _ _
monad : ∀ {ℓ} →
Extensionality ℓ lzero →
Monad (λ (A : Type ℓ) → ¬¬ A)
Monad.raw-monad (monad _) = double-negation-monad
Monad.left-identity (monad ext) _ _ = proof-irrelevant ext
Monad.right-identity (monad ext) _ = proof-irrelevant ext
Monad.associativity (monad ext) _ _ _ = proof-irrelevant ext
-- The following variant of excluded middle is provable.
excluded-middle : ∀ {a} {@0 A : Type a} → ¬¬ Dec A
run excluded-middle ¬[a⊎¬a] = ¬[a⊎¬a] (no λ a → ¬[a⊎¬a] (yes a))
-- The following variant of Peirce's law is provable.
call/cc : ∀ {a w} {@0 A : Type a} {Whatever : Type w} →
((A → Whatever) → ¬¬ A) → ¬¬ A
run (call/cc hyp) ¬a = run (hyp (λ a → ⊥-elim (¬a a))) ¬a
-- If one can prove that the empty type is inhabited in the
-- double-negation monad, then the empty type is inhabited.
¬¬¬⊥ : ∀ {ℓ} → ¬ (¬¬ (⊥ {ℓ = ℓ}))
¬¬¬⊥ ¬¬⊥ = run ¬¬⊥ ⊥-elim
-- If the double-negation of a negation can be proved, then the
-- negation itself can be proved.
¬¬¬→¬ : ∀ {a} {A : Type a} → ¬¬ ¬ A → ¬ A
¬¬¬→¬ ¬¬¬a = λ a → ¬¬¬⊥ (¬¬¬a >>= λ ¬a → ⊥-elim (¬a a))
------------------------------------------------------------------------
-- Excluded middle and double-negation elimination
-- Double-negation elimination (roughly as stated in the HoTT book).
Double-negation-elimination : (ℓ : Level) → Type (lsuc ℓ)
Double-negation-elimination p =
{P : Type p} → Is-proposition P → ¬¬ P → P
-- Double-negation elimination is propositional (assuming
-- extensionality).
Double-negation-elimination-propositional :
∀ {ℓ} →
Extensionality (lsuc ℓ) ℓ →
Is-proposition (Double-negation-elimination ℓ)
Double-negation-elimination-propositional ext =
implicit-Π-closure ext 1 λ _ →
Π-closure (lower-extensionality _ lzero ext) 1 λ P-prop →
Π-closure (lower-extensionality _ lzero ext) 1 λ _ →
P-prop
-- Excluded middle implies double-negation elimination.
Excluded-middle→Double-negation-elimination :
∀ {ℓ} → Excluded-middle ℓ → Double-negation-elimination ℓ
Excluded-middle→Double-negation-elimination em P-prop ¬¬p =
[ id , ⊥-elim ∘ run ¬¬p ] (em P-prop)
-- Excluded middle is pointwise equivalent to double-negation
-- elimination (assuming extensionality).
Excluded-middle≃Double-negation-elimination :
∀ {ℓ} →
Extensionality (lsuc ℓ) (lsuc ℓ) →
Excluded-middle ℓ ≃ Double-negation-elimination ℓ
Excluded-middle≃Double-negation-elimination ext =
_↔_.to (⇔↔≃ ext
(Excluded-middle-propositional
(lower-extensionality lzero _ ext))
(Double-negation-elimination-propositional
(lower-extensionality lzero _ ext)))
(record
{ to = Excluded-middle→Double-negation-elimination
; from = λ dne P-prop →
dne (Dec-closure-propositional
(lower-extensionality _ _ ext) P-prop)
excluded-middle
})
| {
"alphanum_fraction": 0.5950134771,
"avg_line_length": 31.5744680851,
"ext": "agda",
"hexsha": "aa787c72f7d63cd1e100f40e05e24fa834f06f6c",
"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/Double-negation.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/Double-negation.agda",
"max_line_length": 72,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/equality",
"max_stars_repo_path": "src/Double-negation.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": 1418,
"size": 4452
} |
-- {-# OPTIONS -v tc.lhs.unify:100 #-}
module Issue811 where
module ParamIndex where
-- Report by stevan:
-- When case-splitting, I think dots end up at the wrong places,
-- consider:
data _≡_ {A : Set}(x : A) : A → Set where
refl : x ≡ x
-- If you case-split on p in:
dot : ∀ {A}(x : A)(y : A) → x ≡ y → Set
dot x y p = {!p!}
{- You get:
dot′ : ∀ {A}(x y : A) → x ≡ y → Set
dot′ .y y refl = {!!}
-- This seems the wrong way around to me, because we say that the first
-- argument has to be something, namely y, before that something has
-- been introduced.
-- If I'd do the case-splitting manually, I would write:
dot″ : ∀ {A}(x y : A) → x ≡ y → Set
dot″ x .x refl = {!!}
-}
-- Andreas, 2013-03-05 This is indeed what you get now, since
-- Agda now prefers the more left variables.
-- Unfortunately, this leads to bad behavior in this case:
dot1 : ∀ {A}{x : A}(y : A) → x ≡ y → Set
dot1 y p = {!p!}
-- This one works nicely
dot2 : ∀ {A}(x : A){y : A} → x ≡ y → Set
dot2 x p = {!p!}
module AllIndices where
data _≡_ {A : Set} : A → A → Set where
refl : ∀ x → x ≡ x
dot : ∀ {A}(x : A)(y : A) → x ≡ y → Set
dot x y p = {!p!}
-- Same problem here:
dot1 : ∀ {A}{x : A}(y : A) → x ≡ y → Set
dot1 y p = {!p!}
dot2 : ∀ {A}(x : A){y : A} → x ≡ y → Set
dot2 x p = {!p!}
| {
"alphanum_fraction": 0.5307635285,
"avg_line_length": 24.9814814815,
"ext": "agda",
"hexsha": "542f8f88a447621a4bd4197c2f0e7b0838afa833",
"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": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "np/agda-git-experiment",
"max_forks_repo_path": "test/interaction/Issue811.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"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": "np/agda-git-experiment",
"max_issues_repo_path": "test/interaction/Issue811.agda",
"max_line_length": 73,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "np/agda-git-experiment",
"max_stars_repo_path": "test/interaction/Issue811.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": 511,
"size": 1349
} |
module plfa-code.Lists where
import Relation.Binary.PropositionalEquality as Eq
open Eq using (_≡_; refl; sym; trans; cong)
open Eq.≡-Reasoning
open import Data.Bool using (Bool; true; false; T; _∧_; _∨_; not)
open import Data.Nat using (ℕ; zero; suc; _+_; _*_; _∸_; _≤_; s≤s; z≤n)
open import Data.Nat.Properties using
(+-assoc; +-identityˡ; +-identityʳ; *-assoc; *-identityˡ; *-identityʳ)
open import Relation.Nullary using (¬_; Dec; yes; no)
open import Data.Product using (_×_; ∃; ∃-syntax) renaming (_,_ to ⟨_,_⟩)
open import Function using (_∘_)
open import Level using (Level)
open import plfa-code.Isomorphism using (_≃_; _⇔_)
data List (A : Set) : Set where
[] : List A
_∷_ : A → List A → List A
infixr 5 _∷_
_ : List ℕ
_ = 0 ∷ 1 ∷ 2 ∷ []
data List′ : Set → Set where
[]′ : ∀ {A : Set} → List′ A
_∷′_ : ∀ {A : Set} → A → List′ A → List′ A
_ : List ℕ
_ = _∷_ {ℕ} 0 (_∷_ {ℕ} 1 (_∷_ {ℕ} 2 ([] {ℕ})))
{-# BUILTIN LIST List #-}
pattern [_] z = z ∷ []
pattern [_,_] y z = y ∷ z ∷ []
pattern [_,_,_] x y z = x ∷ y ∷ z ∷ []
pattern [_,_,_,_] w x y z = w ∷ x ∷ y ∷ z ∷ []
pattern [_,_,_,_,_] v w x y z = v ∷ w ∷ x ∷ y ∷ z ∷ []
pattern [_,_,_,_,_,_] u v w x y z = u ∷ v ∷ w ∷ x ∷ y ∷ z ∷ []
infixr 5 _++_
_++_ : ∀ {A : Set} → List A → List A → List A
[] ++ ys = ys
(x ∷ xs) ++ ys = x ∷ (xs ++ ys)
_ : [ 0 , 1 , 2 ] ++ [ 3 , 4 ] ≡ [ 0 , 1 , 2 , 3 , 4 ]
_ = -- refl
begin
0 ∷ 1 ∷ 2 ∷ [] ++ 3 ∷ 4 ∷ []
≡⟨⟩
0 ∷ (1 ∷ 2 ∷ [] ++ 3 ∷ 4 ∷ [])
≡⟨⟩
0 ∷ 1 ∷ (2 ∷ [] ++ 3 ∷ 4 ∷ [])
≡⟨⟩
0 ∷ 1 ∷ 2 ∷ ([] ++ 3 ∷ 4 ∷ [])
≡⟨⟩
0 ∷ 1 ∷ 2 ∷ 3 ∷ 4 ∷ []
∎
++-assoc : ∀ {A : Set} (xs ys zs : List A)
→ (xs ++ ys) ++ zs ≡ xs ++ (ys ++ zs)
++-assoc [] ys zs = -- refl
begin
([] ++ ys) ++ zs
≡⟨⟩
ys ++ zs
≡⟨⟩
[] ++ (ys ++ zs)
∎
++-assoc (x ∷ xs) ys zs = -- cong (_∷_ x) (++-assoc xs ys zs)
begin
(x ∷ xs ++ ys) ++ zs
≡⟨⟩
x ∷ (xs ++ ys) ++ zs
≡⟨⟩
x ∷ ((xs ++ ys) ++ zs)
≡⟨ cong (x ∷_) (++-assoc xs ys zs) ⟩
x ∷ (xs ++ (ys ++ zs))
≡⟨⟩
x ∷ xs ++ (ys ++ zs)
∎
++-identityˡ : ∀ {A : Set} (xs : List A) → [] ++ xs ≡ xs
++-identityˡ xs = -- refl
begin
[] ++ xs
≡⟨⟩
xs
∎
++-identityʳ : ∀ {A : Set} (xs : List A) → xs ++ [] ≡ xs
++-identityʳ [] = -- refl
begin
[] ++ []
≡⟨⟩
[]
∎
++-identityʳ (x ∷ xs) = -- cong (_∷_ x) (++-identityʳ xs)
begin
(x ∷ xs) ++ []
≡⟨⟩
x ∷ (xs ++ [])
≡⟨ cong (x ∷_) (++-identityʳ xs) ⟩
x ∷ xs
∎
length : ∀ {A : Set} → List A → ℕ
length [] = zero
length (x ∷ xs) = suc (length xs)
_ : length [ 0 , 1 , 2 ] ≡ 3
_ = -- refl
begin
length (0 ∷ 1 ∷ 2 ∷ [])
≡⟨⟩
suc (length (1 ∷ 2 ∷ []))
≡⟨⟩
suc (suc (length (2 ∷ [])))
≡⟨⟩
suc (suc (suc (length {ℕ} [])))
≡⟨⟩
suc (suc (suc zero))
∎
length-++ : ∀ {A : Set} (xs ys : List A)
→ length (xs ++ ys) ≡ length xs + length ys
length-++ {A} [] ys = -- refl
begin
length ([] ++ ys)
≡⟨⟩
length ys
≡⟨⟩
length {A} [] + length ys
∎
length-++ {A} (x ∷ xs) ys = -- cong suc (length-++ xs ys)
begin
length ((x ∷ xs) ++ ys)
≡⟨⟩
suc (length (xs ++ ys))
≡⟨ cong suc (length-++ xs ys) ⟩
suc (length xs + length ys)
≡⟨⟩
length (x ∷ xs) + length ys
∎
reverse : ∀ {A : Set} → List A → List A
reverse [] = []
reverse (x ∷ xs) = reverse xs ++ [ x ]
_ : reverse [ 0 , 1 , 2 ] ≡ [ 2 , 1 , 0 ]
_ =
begin
reverse (0 ∷ 1 ∷ 2 ∷ [])
≡⟨⟩
reverse (1 ∷ 2 ∷ []) ++ [ 0 ]
≡⟨⟩
(reverse (2 ∷ []) ++ [ 1 ]) ++ [ 0 ]
≡⟨⟩
((reverse [] ++ [ 2 ]) ++ [ 1 ]) ++ [ 0 ]
≡⟨⟩
(([] ++ [ 2 ]) ++ [ 1 ]) ++ [ 0 ]
≡⟨⟩
(([] ++ 2 ∷ []) ++ 1 ∷ []) ++ 0 ∷ []
≡⟨⟩
(2 ∷ [] ++ 1 ∷ []) ++ 0 ∷ []
≡⟨⟩
2 ∷ ([] ++ 1 ∷ []) ++ 0 ∷ []
≡⟨⟩
(2 ∷ 1 ∷ []) ++ 0 ∷ []
≡⟨⟩
2 ∷ (1 ∷ [] ++ 0 ∷ [])
≡⟨⟩
2 ∷ 1 ∷ ([] ++ 0 ∷ [])
≡⟨⟩
2 ∷ 1 ∷ 0 ∷ []
≡⟨⟩
[ 2 , 1 , 0 ]
∎
---------- practice ----------
reverse-++-commute : ∀ {A : Set} {xs ys : List A}
→ reverse (xs ++ ys) ≡ reverse ys ++ reverse xs
reverse-++-commute {_} {[]} {[]} = refl
reverse-++-commute {_} {[]} {y ∷ ys} = sym (++-identityʳ (reverse ys ++ [ y ]))
reverse-++-commute {_} {x ∷ xs} {ys} =
begin
reverse ((x ∷ xs) ++ ys)
≡⟨⟩
reverse (x ∷ (xs ++ ys))
≡⟨⟩
reverse (xs ++ ys) ++ [ x ]
≡⟨ cong (_++ [ x ]) (reverse-++-commute {_} {xs} {ys}) ⟩
(reverse ys ++ reverse xs) ++ [ x ]
≡⟨ ++-assoc (reverse ys) (reverse xs) [ x ] ⟩
reverse ys ++ reverse xs ++ [ x ]
≡⟨ cong (reverse ys ++_) (sym refl) ⟩
reverse ys ++ reverse ([ x ] ++ xs)
≡⟨⟩
reverse ys ++ reverse (x ∷ xs)
∎
reverse-involutive : ∀ {A : Set} {xs : List A}
→ reverse (reverse xs) ≡ xs
reverse-involutive {_} {[]} = refl
reverse-involutive {_} {x ∷ xs} =
begin
reverse (reverse (x ∷ xs))
≡⟨⟩
reverse (reverse xs ++ [ x ])
≡⟨ reverse-++-commute {_} {reverse xs} {[ x ]} ⟩
reverse [ x ] ++ reverse (reverse xs)
≡⟨ cong (reverse [ x ] ++_) reverse-involutive ⟩
[ x ] ++ xs
≡⟨⟩
x ∷ xs
∎
------------------------------
shunt : ∀ {A : Set} → List A → List A → List A
shunt [] ys = ys
shunt (x ∷ xs) ys = shunt xs (x ∷ ys)
shunt-reverse : ∀ {A : Set} (xs ys : List A)
→ shunt xs ys ≡ (reverse xs) ++ ys
shunt-reverse [] ys = -- refl
begin
shunt [] ys
≡⟨⟩
reverse [] ++ ys
∎
shunt-reverse (x ∷ xs) ys =
begin
shunt (x ∷ xs) ys
≡⟨⟩
shunt xs (x ∷ ys)
≡⟨ shunt-reverse xs (x ∷ ys) ⟩
reverse xs ++ (x ∷ ys)
≡⟨⟩
reverse xs ++ ([ x ] ++ ys)
≡⟨ sym (++-assoc (reverse xs) [ x ] ys) ⟩
(reverse xs ++ [ x ]) ++ ys
≡⟨⟩
reverse (x ∷ xs) ++ ys
∎
reverse′ : ∀ {A : Set} → List A → List A
reverse′ xs = shunt xs []
reverses : ∀ {A : Set} (xs : List A)
→ reverse′ xs ≡ reverse xs
reverses xs =
begin
reverse′ xs
≡⟨⟩
shunt xs []
≡⟨ shunt-reverse xs [] ⟩
reverse xs ++ []
≡⟨ ++-identityʳ (reverse xs) ⟩
reverse xs
∎
_ : reverse′ [ 0 , 1 , 2 ] ≡ [ 2 , 1 , 0 ]
_ =
begin
reverse′ (0 ∷ 1 ∷ 2 ∷ [])
≡⟨⟩
shunt (0 ∷ 1 ∷ 2 ∷ []) []
≡⟨⟩
shunt (1 ∷ 2 ∷ []) (0 ∷ [])
≡⟨⟩
shunt (2 ∷ []) (1 ∷ 0 ∷ [])
≡⟨⟩
shunt [] (2 ∷ 1 ∷ 0 ∷ [])
≡⟨⟩
2 ∷ 1 ∷ 0 ∷ []
∎
map : ∀ {A B : Set} → (A → B) → List A → List B
map f [] = []
map f (x ∷ xs) = f x ∷ map f xs
_ : map suc [ 0 , 1 , 2 ] ≡ [ 1 , 2 , 3 ]
_ =
begin
map suc (0 ∷ 1 ∷ 2 ∷ [])
≡⟨⟩
suc 0 ∷ map suc (1 ∷ 2 ∷ [])
≡⟨⟩
suc 0 ∷ suc 1 ∷ map suc (2 ∷ [])
≡⟨⟩
suc 0 ∷ suc 1 ∷ suc 2 ∷ map suc []
≡⟨⟩
suc 0 ∷ suc 1 ∷ suc 2 ∷ []
≡⟨⟩
1 ∷ 2 ∷ 3 ∷ []
∎
sucs : List ℕ → List ℕ
sucs = map suc
_ : sucs [ 0 , 1 , 2 ] ≡ [ 1 , 2 , 3 ]
_ =
begin
sucs [ 0 , 1 , 2 ]
≡⟨⟩
map suc [ 0 , 1 , 2 ]
≡⟨⟩
[ 1 , 2 , 3 ]
∎
---------- practice ----------
open plfa-code.Isomorphism using (extensionality)
map-compose : ∀ {A B C : Set} {f : A → B} {g : B → C}
→ map (g ∘ f) ≡ map g ∘ map f
map-compose {A} {B} {C} {f} {g} = extensionality hf
where
hf : (xs : List A) → map (g ∘ f) xs ≡ map g (map f xs)
hf [] = refl
hf (x ∷ xs) = cong ((g (f x)) ∷_) (hf xs)
map-++-commute : ∀ {A B : Set} {f : A → B} {xs ys : List A}
→ map f (xs ++ ys) ≡ map f xs ++ map f ys
map-++-commute {A} {B} {f} {[]} {ys} = refl
map-++-commute {A} {B} {f} {x ∷ xs} {ys} =
cong ((f x) ∷_) (map-++-commute {_} {_} {f} {xs} {ys})
data Tree (A B : Set) : Set where
leaf : A → Tree A B
node : Tree A B → B → Tree A B → Tree A B
map-Tree : ∀ {A B C D : Set}
→ (A → C) → (B → D) → Tree A B → Tree C D
map-Tree f g (leaf a) = leaf (f a)
map-Tree f g (node tree b tree₁) = node (map-Tree f g tree) (g b) (map-Tree f g tree₁)
------------------------------
foldr : ∀ {A B : Set} → (A → B → B) → B → List A → B
foldr _⊗_ e [] = e
foldr _⊗_ e (x ∷ xs) = x ⊗ (foldr _⊗_ e xs)
_ : foldr _+_ 0 [ 1 , 2 , 3 , 4 ] ≡ 10
_ =
begin
foldr _+_ 0 (1 ∷ 2 ∷ 3 ∷ 4 ∷ [])
≡⟨⟩
1 + foldr _+_ 0 (2 ∷ 3 ∷ 4 ∷ [])
≡⟨⟩
1 + (2 + foldr _+_ 0 (3 ∷ 4 ∷ []))
≡⟨⟩
1 + (2 + (3 + foldr _+_ 0 (4 ∷ [])))
≡⟨⟩
1 + (2 + (3 + (4 + foldr _+_ 0 [])))
≡⟨⟩
1 + (2 + (3 + (4 + 0)))
∎
sum : List ℕ → ℕ
sum = foldr _+_ 0
_ : sum [ 1 , 2 , 3 , 4 ] ≡ 10
_ =
begin
sum [ 1 , 2 , 3 , 4 ]
≡⟨⟩
foldr _+_ 0 [ 1 , 2 , 3 , 4 ]
≡⟨⟩
10
∎
---------- practice ----------
product : List ℕ → ℕ
product = foldr _*_ 1
_ : product [ 1 , 2 , 3 , 4 ] ≡ 24
_ = refl
foldr-++ : ∀ {A B : Set} (_⊗_ : A → B → B) (e : B) (xs ys : List A) →
foldr _⊗_ e (xs ++ ys) ≡ foldr _⊗_ (foldr _⊗_ e ys) xs
foldr-++ _⊗_ e [] ys = refl
foldr-++ _⊗_ e (x ∷ xs) ys = cong (x ⊗_) (foldr-++ _⊗_ e xs ys)
map-is-foldr : ∀ {A B : Set} {f : A → B} →
map f ≡ foldr (λ x xs → f x ∷ xs) []
map-is-foldr {A} {_} {f} = extensionality hf
where
hf : (l : List A) → map f l ≡ foldr (λ x xs → f x ∷ xs) [] l
hf [] = refl
hf (x ∷ xs) = cong (f x ∷_) (hf xs)
fold-Tree : ∀ {A B C : Set}
→ (A → C) → (C → B → C → C) → Tree A B → C
fold-Tree f g (leaf a) = f a
fold-Tree f g (node tree b tree₁) = g (fold-Tree f g tree) b (fold-Tree f g tree₁)
downFrom : ℕ → List ℕ
downFrom zero = []
downFrom (suc n) = n ∷ downFrom n
_ : downFrom 3 ≡ [ 2 , 1 , 0 ]
_ = refl
open Data.Nat.Properties using
(*-distribʳ-+; *-distribʳ-∸; m∸n+n≡m; m≤m+n;
+-comm; *-comm; +-identityʳ; *-identityˡ)
open Eq using (cong₂)
2n≡n+n : ∀ n → 2 * n ≡ n + n
2n≡n+n zero = refl
2n≡n+n (suc n) = cong (λ x → suc (n + suc x)) (+-identityʳ n)
n≤n*n : ∀ n → n ≤ n * n
n≤n*n zero = z≤n
n≤n*n (suc n) = s≤s (m≤m+n n (n * suc n))
sum-downFrom : ∀ (n : ℕ)
→ sum (downFrom n) * 2 ≡ n * (n ∸ 1)
sum-downFrom zero = refl
sum-downFrom (suc n) =
begin
sum (downFrom (suc n)) * 2
≡⟨⟩
(n + sum (downFrom n)) * 2
≡⟨ *-distribʳ-+ 2 n (sum (downFrom n)) ⟩
n * 2 + sum (downFrom n) * 2
≡⟨ cong (n * 2 +_) (sum-downFrom n) ⟩
n * 2 + n * (n ∸ 1)
≡⟨ cong₂ _+_ (*-comm n 2) (*-comm n (n ∸ 1)) ⟩
2 * n + (n ∸ 1) * n
≡⟨ cong (2 * n +_) (*-distribʳ-∸ n n 1) ⟩
2 * n + (n * n ∸ 1 * n)
≡⟨ cong₂ (λ a b → a + (n * n ∸ b)) (2n≡n+n n) (*-identityˡ n) ⟩
n + n + (n * n ∸ n)
≡⟨ +-comm (n + n) (n * n ∸ n) ⟩
n * n ∸ n + (n + n)
≡⟨ sym (+-assoc (n * n ∸ n) n n) ⟩
n * n ∸ n + n + n
≡⟨ cong (_+ n) (m∸n+n≡m (n≤n*n n)) ⟩
n * n + n
≡⟨ +-comm (n * n) n ⟩
n + n * n
≡⟨⟩
(suc n) * (suc n ∸ 1)
∎
------------------------------
record IsMonoid {A : Set} (_⊗_ : A → A → A) (e : A) : Set where
field
assoc : ∀ (x y z : A) → (x ⊗ y) ⊗ z ≡ x ⊗ (y ⊗ z)
identityˡ : ∀ (x : A) → e ⊗ x ≡ x
identityʳ : ∀ (x : A) → x ⊗ e ≡ x
open IsMonoid
+-monoid : IsMonoid _+_ 0
+-monoid =
record
{ assoc = +-assoc
; identityˡ = +-identityˡ
; identityʳ = +-identityʳ
}
*-monoid : IsMonoid _*_ 1
*-monoid =
record
{ assoc = *-assoc
; identityˡ = *-identityˡ
; identityʳ = *-identityʳ
}
++-monoid : ∀ {A : Set} → IsMonoid {List A} _++_ []
++-monoid =
record
{ assoc = ++-assoc
; identityˡ = ++-identityˡ
; identityʳ = ++-identityʳ
}
foldr-monoid : ∀ {A : Set} (_⊗_ : A → A → A) (e : A) → IsMonoid _⊗_ e →
∀ (xs : List A) (y : A) → foldr _⊗_ y xs ≡ foldr _⊗_ e xs ⊗ y
foldr-monoid _⊗_ e ⊗-monoid [] y = -- sym (identityˡ ⊗-monoid y)
begin
foldr _⊗_ y []
≡⟨⟩
y
≡⟨ sym (identityˡ ⊗-monoid y) ⟩
(e ⊗ y)
≡⟨⟩
foldr _⊗_ e [] ⊗ y
∎
foldr-monoid _⊗_ e ⊗-monoid (x ∷ xs) y =
begin
foldr _⊗_ y (x ∷ xs)
≡⟨⟩
x ⊗ (foldr _⊗_ y xs)
≡⟨ cong (x ⊗_) (foldr-monoid _⊗_ e ⊗-monoid xs y) ⟩
x ⊗ ((foldr _⊗_ e xs) ⊗ y)
≡⟨ sym (assoc ⊗-monoid x (foldr _⊗_ e xs) y) ⟩
(x ⊗ (foldr _⊗_ e xs)) ⊗ y
∎
foldr-monoid-++ : ∀ {A : Set} (_⊗_ : A → A → A) (e : A) → IsMonoid _⊗_ e →
∀ (xs ys : List A) → foldr _⊗_ e (xs ++ ys) ≡ foldr _⊗_ e xs ⊗ foldr _⊗_ e ys
foldr-monoid-++ _⊗_ e monoid-⊗ xs ys =
begin
foldr _⊗_ e (xs ++ ys)
≡⟨ foldr-++ _⊗_ e xs ys ⟩
foldr _⊗_ (foldr _⊗_ e ys) xs
≡⟨ foldr-monoid _⊗_ e monoid-⊗ xs (foldr _⊗_ e ys) ⟩
foldr _⊗_ e xs ⊗ foldr _⊗_ e ys
∎
---------- practice ----------
foldl : ∀ {A B : Set} → (B → A → B) → B → List A → B
foldl _⊗_ e [] = e
foldl _⊗_ e (x ∷ xs) = foldl _⊗_ (e ⊗ x) xs
foldl-monoid : ∀ {A : Set} (_⊗_ : A → A → A) (e : A) → IsMonoid _⊗_ e →
∀ (xs : List A) (y : A) → foldl _⊗_ y xs ≡ y ⊗ foldl _⊗_ e xs
foldl-monoid _⊗_ e ⊗-monoid [] y = sym (identityʳ ⊗-monoid y)
foldl-monoid _⊗_ e ⊗-monoid (x ∷ xs) y =
begin
foldl _⊗_ y (x ∷ xs)
≡⟨⟩
foldl _⊗_ (y ⊗ x) xs
≡⟨ foldl-monoid _⊗_ e ⊗-monoid xs (y ⊗ x) ⟩
(y ⊗ x) ⊗ (foldl _⊗_ e xs)
≡⟨ assoc ⊗-monoid y x (foldl _⊗_ e xs) ⟩
y ⊗ (x ⊗ foldl _⊗_ e xs)
≡⟨ sym (cong (y ⊗_) (foldl-monoid _⊗_ e ⊗-monoid xs x)) ⟩
y ⊗ (foldl _⊗_ x xs)
≡⟨ sym (cong (λ z → y ⊗ foldl _⊗_ z xs) (identityˡ ⊗-monoid x)) ⟩
y ⊗ (foldl _⊗_ (e ⊗ x) xs)
≡⟨⟩
y ⊗ foldl _⊗_ e (x ∷ xs)
∎
foldr-monoid-foldl : ∀ {A : Set} (_⊗_ : A → A → A) (e : A) → IsMonoid _⊗_ e →
∀ (xs : List A) → foldr _⊗_ e xs ≡ foldl _⊗_ e xs
foldr-monoid-foldl _⊗_ e ⊗-monoid [] = refl
foldr-monoid-foldl _⊗_ e ⊗-monoid (x ∷ xs) =
begin
foldr _⊗_ e (x ∷ xs)
≡⟨⟩
(x ⊗ foldr _⊗_ e xs)
≡⟨ cong (x ⊗_) (foldr-monoid-foldl _⊗_ e ⊗-monoid xs) ⟩
(x ⊗ foldl _⊗_ e xs)
≡⟨ sym (foldl-monoid _⊗_ e ⊗-monoid xs x) ⟩
foldl _⊗_ x xs
≡⟨ cong (λ a → foldl _⊗_ a xs) (sym (identityˡ ⊗-monoid x)) ⟩
foldl _⊗_ (e ⊗ x) xs
≡⟨⟩
foldl _⊗_ e (x ∷ xs)
∎
------------------------------
data All {A : Set} (P : A → Set) : List A → Set where
[] : All P []
_∷_ : ∀ {x : A} {xs : List A} → P x → All P xs → All P (x ∷ xs)
_ : All (_≤ 2) [ 0 , 1 , 2 ]
_ = z≤n ∷ s≤s z≤n ∷ s≤s (s≤s z≤n) ∷ []
data Any {A : Set} (P : A → Set) : List A → Set where
here : ∀ {x : A} {xs : List A} → P x → Any P (x ∷ xs)
there : ∀ {x : A} {xs : List A} → Any P xs → Any P (x ∷ xs)
_∈_ : ∀ {A : Set} (x : A) (xs : List A) → Set
x ∈ xs = Any (x ≡_) xs
_∉_ : ∀ {A : Set} (x : A) (xs : List A) → Set
x ∉ xs = ¬ (x ∈ xs)
_ : 0 ∈ [ 0 , 1 , 0 , 2 ]
_ = here refl
_ : 0 ∈ [ 0 , 1 , 0 , 2 ]
_ = there (there (here refl))
not-in : 3 ∉ [ 0 , 0 , 0 , 2 ]
not-in (here ())
not-in (there (here ()))
not-in (there (there (here ())))
not-in (there (there (there (here ()))))
not-in (there (there (there (there ()))))
All-++-⇔ : ∀ {A : Set} {P : A → Set} (xs ys : List A) →
All P (xs ++ ys) ⇔ (All P xs × All P ys)
All-++-⇔ xs ys =
record
{ to = to xs ys
; from = from xs ys
}
where
to : ∀ {A : Set} {P : A → Set} (xs ys : List A) →
All P (xs ++ ys) → (All P xs × All P ys)
to [] ys Pys = ⟨ [] , Pys ⟩
to (x ∷ xs) ys (Px ∷ Pxs++ys) with to xs ys Pxs++ys
... | ⟨ Pxs , Pys ⟩ = ⟨ Px ∷ Pxs , Pys ⟩
from : ∀ { A : Set} {P : A → Set} (xs ys : List A) →
All P xs × All P ys → All P (xs ++ ys)
from [] ys ⟨ [] , Pys ⟩ = Pys
from (x ∷ xs) ys ⟨ Px ∷ Pxs , Pys ⟩ = Px ∷ (from xs ys ⟨ Pxs , Pys ⟩)
---------- practice ----------
open import Data.Sum using (_⊎_; inj₁; inj₂)
open Data.Product using (proj₁; proj₂)
open import Data.Empty using (⊥-elim)
Any-++-⇔ : ∀ {A : Set} {P : A → Set} (xs ys : List A) →
Any P (xs ++ ys) ⇔ (Any P xs ⊎ Any P ys)
Any-++-⇔ {A} {P} xs ys =
record
{ to = to xs ys
; from = from xs ys
}
where
to : ∀ (xs ys : List A) →
Any P (xs ++ ys) → Any P xs ⊎ Any P ys
to [] ys Pys = inj₂ Pys
to (x ∷ xs) ys (here Px) = inj₁ (here Px)
to (x ∷ xs) ys (there ∃Pxs++ys) with to xs ys ∃Pxs++ys
... | inj₁ ∃Pxs = inj₁ (there ∃Pxs)
... | inj₂ ∃Pys = inj₂ ∃Pys
from : ∀ (xs ys : List A) →
Any P xs ⊎ Any P ys → Any P (xs ++ ys)
from [] ys (inj₂ ∃Pys) = ∃Pys
from (x ∷ xs) ys (inj₁ (here Px)) = here Px
from (x ∷ xs) ys (inj₁ (there ∃Pxs)) = there (from xs ys (inj₁ ∃Pxs))
from (x ∷ xs) ys (inj₂ ∃Pys) = there (from xs ys (inj₂ ∃Pys))
All-++-≃ : ∀ {A : Set} {P : A → Set} (xs ys : List A) →
All P (xs ++ ys) ≃ (All P xs × All P ys)
All-++-≃ {A} {P} xs ys =
record
{ to = to xs ys
; from = from xs ys
; from∘to = from∘to xs ys
; to∘from = to∘from xs ys
}
where
to : ∀ (xs ys : List A) → All P (xs ++ ys) → (All P xs × All P ys)
to xs ys = _⇔_.to (All-++-⇔ xs ys)
from : ∀ (xs ys : List A) → All P xs × All P ys → All P (xs ++ ys)
from xs ys = _⇔_.from (All-++-⇔ xs ys)
from∘to : ∀ (xs ys : List A) (Pxs++ys : All P (xs ++ ys))
→ from xs ys (to xs ys Pxs++ys) ≡ Pxs++ys
from∘to [] ys Pxs++ys = refl
from∘to (x ∷ xs) ys (Px ∷ Pxs++ys) = -- cong (Px ∷_) (from∘to xs ys Pxs++ys)
begin
from (x ∷ xs) ys (to (x ∷ xs) ys (Px ∷ Pxs++ys))
≡⟨⟩
from (x ∷ xs) ys ⟨ Px ∷ proj₁ t , proj₂ t ⟩
≡⟨⟩
Px ∷ from xs ys ⟨ proj₁ t , proj₂ t ⟩
≡⟨⟩
Px ∷ from xs ys (to xs ys Pxs++ys)
≡⟨ cong (Px ∷_) (from∘to xs ys Pxs++ys) ⟩
Px ∷ Pxs++ys
∎
where t = to xs ys Pxs++ys
to∘from : ∀ (xs ys : List A) (Pxs×Pys : All P xs × All P ys)
→ to xs ys (from xs ys Pxs×Pys) ≡ Pxs×Pys
to∘from [] ys ⟨ [] , Pys ⟩ = refl
to∘from (x ∷ xs) ys ⟨ Px ∷ Pxs , Pys ⟩ =
-- cong (λ k → ⟨ Px ∷ (proj₁ k) , proj₂ k ⟩) (to∘from xs ys ⟨ Pxs , Pys ⟩)
begin
to (x ∷ xs) ys (from (x ∷ xs) ys ⟨ Px ∷ Pxs , Pys ⟩)
≡⟨⟩
to (x ∷ xs) ys (Px ∷ (from xs ys ⟨ Pxs , Pys ⟩))
≡⟨⟩
⟨ Px ∷ (proj₁ tf) , (proj₂ tf) ⟩
≡⟨ cong (λ k → ⟨ Px ∷ (proj₁ k) , proj₂ k ⟩) (to∘from xs ys ⟨ Pxs , Pys ⟩) ⟩
⟨ Px ∷ (proj₁ ⟨ Pxs , Pys ⟩) , (proj₂ ⟨ Pxs , Pys ⟩) ⟩
≡⟨⟩
⟨ Px ∷ Pxs , Pys ⟩
∎
where tf = (to xs ys (from xs ys ⟨ Pxs , Pys ⟩))
_∘′_ : ∀ {ℓ₁ ℓ₂ ℓ₃ : Level} {A : Set ℓ₁} {B : Set ℓ₂} {C : Set ℓ₃}
→ (B → C) → (A → B) → A → C
(g ∘′ f) x = g (f x)
¬Any≃All¬ : ∀ {A : Set} (P : A → Set) (xs : List A)
→ (¬_ ∘′ Any P) xs ≃ All (¬_ ∘′ P) xs
¬Any≃All¬ {A} P xs =
record
{ to = to xs
; from = from xs
; from∘to = from∘to xs
; to∘from = to∘from xs
}
where
to : (xs : List A) → (¬_ ∘′ Any P) xs → All (¬_ ∘′ P) xs
to [] ¬Any = []
to (x ∷ xs) ¬Any = (λ Px → ¬Any (here Px)) ∷ to xs (λ Pxs → ¬Any (there Pxs))
from : (xs : List A) → All (¬_ ∘′ P) xs → (¬_ ∘′ Any P) xs
from (x ∷ xs) (¬Px ∷ All¬) (here Px) = ¬Px Px
from (x ∷ xs) (¬Px ∷ All¬) (there AnyP) = from xs All¬ AnyP
from∘to : (xs : List A) → ∀ (¬Any) → from xs (to xs ¬Any) ≡ ¬Any
from∘to xs ¬Any = extensionality λ AnyP → ⊥-elim (¬Any AnyP)
to∘from : (xs : List A) → ∀ (All¬) → to xs (from xs All¬) ≡ All¬
to∘from [] [] = refl
to∘from (x ∷ xs) (¬Px ∷ ¬Pxs) = cong (¬Px ∷_) (to∘from xs ¬Pxs)
-- ¬All≃Any¬ : ∀ {A : Set} (P : A → Set) (xs : List A)
-- → (¬_ ∘′ All P) xs ≃ Any (¬_ ∘′ P) xs
-- doesn't hold, because we couldn't use
-- ((¬_ ∘′ All P) xs) to construct a (Any (¬_ ∘′ P) xs)
------------------------------
all : ∀ {A : Set} → (A → Bool) → List A → Bool
all p = foldr _∧_ true ∘ map p
Decidable : ∀ {A : Set} → (A → Set) → Set
Decidable {A} P = ∀ (x : A) → Dec (P x)
All? : ∀ {A : Set} {P : A → Set} → Decidable P → Decidable (All P)
All? P? [] = yes []
All? P? (x ∷ xs) with P? x | All? P? xs
... | yes Px | yes p₁ = yes (Px ∷ p₁)
... | no ¬Px | _ = no λ{ (Px ∷ Pxs) → ¬Px Px}
... | _ | no ¬Pxs = no λ{ (Px ∷ Pxs) → ¬Pxs Pxs}
---------- practice ----------
any : ∀ {A : Set} → (A → Bool) → List A → Bool
any p = foldr _∨_ false ∘ map p
Any? : ∀ {A : Set} {P : A → Set} → Decidable P → Decidable (Any P)
Any? P? [] = no (λ ())
Any? P? (x ∷ xs) with P? x | Any? P? xs
Any? P? (x ∷ xs) | yes Px | _ = yes (here Px)
Any? P? (x ∷ xs) | _ | yes ∃Pxs = yes (there ∃Pxs)
Any? P? (x ∷ xs) | no ¬Px | no ¬∃Pxs = no λ{ (here Px) → ¬Px Px
; (there ∃Px) → ¬∃Pxs ∃Px
}
open import plfa-code.Quantifiers using (∀-extensionality)
-- the implicit argument x is too difficult to deal with ..
-- so I replace it with explicit
All-∀ : ∀ {A : Set} {P : A → Set} (xs : List A) →
All P xs ≃ (∀ (x) → x ∈ xs → P x)
All-∀ {A} {P} xs =
record
{ to = to xs
; from = from xs
; from∘to = from∘to xs
; to∘from = to∘from xs
}
where
to : ∀ (xs : List A) → All P xs → (∀ (x) → x ∈ xs → P x)
to (x₁ ∷ xs) (Px₁ ∷ _ ) .x₁ (here refl) = Px₁
to (x₁ ∷ xs) ( _ ∷ Pxs) x (there x∈xs) = to xs Pxs x x∈xs
from : ∀ (xs : List A) → (∀ (x) → x ∈ xs → P x) → All P xs
from [] f = []
from (x ∷ xs) f = f x (here refl) ∷ from xs (λ x₁ → (f x₁) ∘ there)
from∘to : ∀ (xs : List A) → (Pxs : All P xs) → from xs (to xs Pxs) ≡ Pxs
from∘to [] [] = refl
from∘to (x ∷ xs) (Px ∷ Pxs) = cong (Px ∷_) (from∘to xs Pxs)
to∘from : ∀ (xs : List A) → ∀ (f) → to xs (from xs f) ≡ f
to∘from [] f = ∀-extensionality (to [] []) f
(λ x → ∀-extensionality (to [] [] x) (f x) λ ())
to∘from (x ∷ xs) f = ∀-extensionality (to (x ∷ xs) (from (x ∷ xs) f)) f
(λ x₁ → ∀-extensionality (to (x ∷ xs) (from (x ∷ xs) f) x₁) (f x₁)
λ{ (here refl) → refl
; (there x₁∈xs) → cong (λ g → g x₁ x₁∈xs)
(to∘from xs (λ x₂ → (f x₂) ∘ there))
}
)
-- Emmmm..., "∃[ x ∈ xs ] P x" is not a valid type, I guess its real
-- meaning is like below
Any-∃ : {A : Set} {P : A → Set} (xs : List A) →
Any P xs ≃ ∃[ x ] (x ∈ xs × P x)
Any-∃ {A} {P} xs =
record
{ to = to xs
; from = from xs
; from∘to = from∘to xs
; to∘from = to∘from xs
}
where
to : ∀ (xs : List A) → Any P xs → ∃[ x ] (x ∈ xs × P x)
to (x ∷ xs) (here Px) = ⟨ x , ⟨ here refl , Px ⟩ ⟩
to (x ∷ xs) (there AnyP) with to xs AnyP
... | ⟨ x₁ , ⟨ x₁∈xs , Px ⟩ ⟩ = ⟨ x₁ , ⟨ there x₁∈xs , Px ⟩ ⟩
from : ∀ (xs : List A) → ∃[ x ] (x ∈ xs × P x) → Any P xs
from (x ∷ xs) ⟨ .x , ⟨ here refl , Px ⟩ ⟩ = here Px
from (x ∷ xs) ⟨ x₁ , ⟨ there x₁∈xs , Px₁ ⟩ ⟩ = there (from xs ⟨ x₁ , ⟨ x₁∈xs , Px₁ ⟩ ⟩)
from∘to : ∀ (xs : List A) → (AnyP : Any P xs)
→ from xs (to xs AnyP) ≡ AnyP
from∘to (x ∷ xs) (here x₁) = refl
from∘to (x ∷ xs) (there AnyP) = cong there (from∘to xs AnyP)
to∘from : ∀ (xs : List A) → ∀ ∃Pxs → to xs (from xs ∃Pxs) ≡ ∃Pxs
to∘from (x ∷ xs) ⟨ .x , ⟨ here refl , Px ⟩ ⟩ = refl
to∘from (x ∷ xs) ⟨ x₁ , ⟨ there x₁∈xs , Px₁ ⟩ ⟩
= cong (λ a → ⟨ proj₁ a , ⟨ there (proj₁ (proj₂ a)) , proj₂ (proj₂ a) ⟩ ⟩)
(to∘from xs ⟨ x₁ , ⟨ x₁∈xs , Px₁ ⟩ ⟩)
filter? : ∀ {A : Set} {P : A → Set}
→ (P? : Decidable P) → List A → ∃[ ys ]( All P ys )
filter? P? [] = ⟨ [] , [] ⟩
filter? P? (x ∷ xs) with P? x | filter? P? xs
... | yes Px | ⟨ ys , Pys ⟩ = ⟨ (x ∷ ys) , (Px ∷ Pys) ⟩
... | no ¬Px | ∃ys-Pys = ∃ys-Pys
| {
"alphanum_fraction": 0.4349940321,
"avg_line_length": 27.287092883,
"ext": "agda",
"hexsha": "b6120138b1e850ac89a729dd56aa2605d0bec3ec",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "ec5b359a8c22bf5268cae3c36a97e6737c75d5f3",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "chirsz-ever/plfa-code",
"max_forks_repo_path": "src/plfa-code/Lists.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ec5b359a8c22bf5268cae3c36a97e6737c75d5f3",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "chirsz-ever/plfa-code",
"max_issues_repo_path": "src/plfa-code/Lists.agda",
"max_line_length": 89,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "ec5b359a8c22bf5268cae3c36a97e6737c75d5f3",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "chirsz-ever/plfa-code",
"max_stars_repo_path": "src/plfa-code/Lists.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 10922,
"size": 22621
} |
------------------------------------------------------------------------
-- Code related to the paper "Higher Lenses"
--
-- Nils Anders Danielsson
--
-- The paper is coauthored with Paolo Capriotti and Andrea Vezzosi.
------------------------------------------------------------------------
-- Most of the code referenced below can be found in modules that are
-- parametrised by a notion of equality. One can use them both with
-- Cubical Agda paths and with the Cubical Agda identity type family.
-- Note that the code does not follow the paper exactly. For instance,
-- some definitions use bijections (functions with quasi-inverses)
-- instead of equivalences.
-- An attempt has also been made to track uses of univalence by
-- passing around explicit proofs of the univalence axiom (except in
-- certain README modules). However, univalence is provable in Cubical
-- Agda, and some library code that is used does not adhere to this
-- convention, so perhaps some use of univalence is not tracked in
-- this way. On the other hand some library code that is not defined
-- in Cubical Agda passes around explicit proofs of function
-- extensionality.
-- Some other differences are mentioned below.
-- Note that there is a known problem with guarded corecursion in
-- Agda. Due to "quantifier inversion" (see "Termination Checking in
-- the Presence of Nested Inductive and Coinductive Types" by Thorsten
-- Altenkirch and myself) certain types may not have the expected
-- semantics when the option --guardedness is used. I expect that the
-- results would still hold if this bug were fixed, but because I do
-- not know what the rules of a fixed version of Agda would be I do
-- not know if any changes to the code would be required.
{-# OPTIONS --cubical --guardedness #-}
module README.Higher-Lenses where
import Circle
import Coherently-constant
import Equality
import Equality.Decidable-UIP
import Equivalence
import Equivalence.Half-adjoint
import Function-universe
import H-level
import H-level.Truncation.Propositional
import H-level.Truncation.Propositional.Non-recursive
import H-level.Truncation.Propositional.One-step
import Preimage
import Surjection
import Lens.Non-dependent.Bijection as B
import Lens.Non-dependent.Equivalent-preimages as EP
import Lens.Non-dependent.Higher as E
import Lens.Non-dependent.Higher.Capriotti as F
import Lens.Non-dependent.Higher.Coinductive as C
import Lens.Non-dependent.Higher.Coherently.Coinductive as Coh
import Lens.Non-dependent.Higher.Coherently.Not-coinductive as NC
import Lens.Non-dependent.Higher.Coinductive.Small as S
import Lens.Non-dependent.Higher.Combinators as EC
import Lens.Non-dependent.Traditional as T
import Lens.Non-dependent.Traditional.Combinators as TC
import README.Not-a-set
------------------------------------------------------------------------
-- I: Introduction
-- Traditional lenses.
Lensᵀ = T.Lens
-- The function modify.
modify = T.Lens.modify
-- The two variants of Tm, and proofs showing that Tm A is not a set
-- if A is inhabited.
Tm₁ = README.Not-a-set.Tm
¬-Tm₁-set = README.Not-a-set.¬-Tm-set
Tm₂ = README.Not-a-set.Tmˢ
¬-Tm₂-set = README.Not-a-set.¬-Tmˢ-set
------------------------------------------------------------------------
-- II: Homotopy type theory
-- The cong function.
--
-- The axiomatisation of equality that is used makes it possible to
-- choose the implementation of cong. However, the implementation is
-- required to satisfy a property which implies that the definition is
-- unique.
cong = Equality.Equality-with-J.cong
cong-refl = Equality.Equality-with-J.cong-refl
cong-unique =
Equality.Derived-definitions-and-properties.monomorphic-cong-canonical
-- Is-equivalence and _≃_.
--
-- Note that the syntax used for Σ-types in the paper is not valid
-- Agda syntax. Furthermore the code defines _≃_ as a record type
-- instead of using a Σ-type.
Is-equivalence = Equivalence.Half-adjoint.Is-equivalence
_≃_ = Equivalence._≃_
-- Lemma 6.
lemma-6 = Equivalence._≃_.left-right-lemma
-- H-level, Contractible, Is-proposition and Is-set.
--
-- Some of the definitions are slightly different from the ones given
-- in the paper.
H-level = H-level.H-level
Contractible = Equality.Reflexive-relation′.Contractible
Is-proposition = Equality.Reflexive-relation′.Is-proposition
Is-set = Equality.Reflexive-relation′.Is-set
-- The circle.
𝕊¹ = Circle.𝕊¹
-- A function that is distinct from refl.
not-refl = Circle.not-refl
not-refl≢refl = Circle.not-refl≢refl
-- The type base ≡ base is equivalent to ℤ.
base≡base≃ℤ = Circle.base≡base≃ℤ
-- The circle is not a set.
circle-not-set = Circle.¬-𝕊¹-set
-- The propositional truncation operator.
∥_∥ = H-level.Truncation.Propositional.∥_∥
------------------------------------------------------------------------
-- III: Traditional lenses
-- Lenses with equal setters have equal getters.
getters-equal-if-setters-equal = T.getters-equal-if-setters-equal
-- The identity lens.
id-traditional = TC.id
-- The lens used for the counterexamples.
--
-- This lens is a little different from the one in the text: the
-- source and view types are liftings of the circle instead of the
-- circle. This change also affects the proof of Lemma 12.
l = T.bad
-- Lemmas 12 and 13.
lemmas-12-and-13 = T.getter-equivalence-but-not-coherent
-- There are lenses with equal setters that are not equal.
equal-setters-but-not-equal =
TC.equal-setters-and-equivalences-as-getters-but-not-equal
-- Lemma 14.
lemma-14 = T.lens-to-proposition↔
-- Lensᵀ A ⊤ is not necessarily a proposition (and thus not
-- necessarily equivalent to the unit type).
Traditional-lens-𝕊¹-⊤-not-propositional = T.¬-lens-to-⊤-propositional
-- Fibres.
_⁻¹_ = Preimage._⁻¹_
-- Lemmas 16 and 17, and a variant of Lemma 16 for lenses which
-- satisfy certain coherence laws.
lemma-16 = T.≃get⁻¹×
lemma-16-coherent = T.≃get⁻¹×-coherent
lemma-17 = T.≃Σ∥set⁻¹∥×
-- A variant of Lemma 17 without the requirement that the source type
-- is a set does not hold in general.
not-lemma-17-without-Is-set = TC.≄Σ∥set⁻¹∥×
------------------------------------------------------------------------
-- IV: Lenses based on bijections
-- Lenses based on bijections.
Lensᴮ = B.Lens
-- Lensᴮ ⊥ ⊥ is equivalent to Type.
--
-- Note that the definition of ⊥ that is used in the code can target
-- different universes, not just Type.
Lensᴮ-⊥-⊥≃Type = B.Lens-⊥-⊥≃Type
-- Lensᵀ ⊥ ⊥ is equivalent to ⊤.
Lensᵀ-⊥-⊥≃Type = T.lens-from-⊥≃⊤
------------------------------------------------------------------------
-- V: Higher lenses
-- Lensᴱ.
--
-- For performance reasons η-equality has been turned off for this
-- definition.
Lensᴱ = E.Lens
-- Lemma 20.
lemma-20 = E.isomorphism-to-lens
-- The functions get, remainder and set.
get = E.Lens.get
remainder = E.Lens.remainder
set = E.Lens.set
-- The inhabited field is equivalent to stating that the remainder
-- function is surjective.
inhabited≃remainder-surjective = E.inhabited≃remainder-surjective
-- Lemmas 24-27.
lemma-24 = E.Lens.get-set
lemma-25 = E.Lens.remainder-set
lemma-26 = E.Lens.set-get
lemma-27 = E.Lens.set-set
-- Traditional lenses that have stable view types and that satisfy two
-- coherence laws can be translated to higher lenses with the same
-- getters and setters.
coherent-to-higher = EP.coherent↠higher
coherent-to-higher-preserves-get-and-set =
EP.coherent↠higher-preserves-getters-and-setters
------------------------------------------------------------------------
-- VI: Coherence laws
-- Lemmas 28-29.
lemma-28 = E.Lens.get-set-get
lemma-29 = E.Lens.get-set-set
------------------------------------------------------------------------
-- VII: Some equivalences
-- Lemmas 30-37.
--
-- Lemmas 31 and 33 are formulated slightly differently.
lemma-30 = E.lens-to-proposition↔get
lemma-31 = E.lens-to-contractible↔⊤
lemma-32 = E.lens-to-⊥↔¬
lemma-33 = E.lens-from-contractible↔codomain-contractible
lemma-34 = E.lens-from-⊥↔⊤
lemma-35 = E.get-equivalence≃inhabited-equivalence
lemma-36 = E.≃-≃-Σ-Lens-Is-equivalence-get
lemma-37 = E.remainder≃get⁻¹
-- Lemmas 32-34 hold for traditional lenses.
lemma-32-for-traditional = T.lens-to-⊥↔
lemma-33-for-traditional = T.lens-from-⊤≃codomain-contractible
lemma-34-for-traditional = T.lens-from-⊥≃⊤
-- The right-to-left direction of Lemma 36 returns the lens's getter
-- (and some proof).
lemma-36-right-to-left = E.to-from-≃-≃-Σ-Lens-Is-equivalence-get≡get
-- Lemma 36 does not in general hold for traditional lenses.
¬-lemma-36-traditional = TC.¬Π≃-≃-Σ-Lens-Is-equivalence-get
------------------------------------------------------------------------
-- VIII: Equality of lenses with equal setters
-- Lemmas 38-44.
lemma-38 = E.equality-characterisation₁
lemma-39 = E.equality-characterisation₄
lemma-40 = E.lenses-with-inhabited-codomains-equal-if-setters-equal
lemma-41 = E.lenses-equal-if-setters-equal
lemma-42 = E.lenses-equal-if-setters-equal-and-remainder-set
lemma-43 = E.¬-lenses-equal-if-setters-equal
lemma-44 = E.lenses-equal-if-setters-equal→constant→coherently-constant
-- Constant and CC.
Constant = Equality.Decidable-UIP.Constant
CC = Coherently-constant.Coherently-constant
-- Lemma 47.
lemma-47 = Coherently-constant.¬-Constant→Coherently-constant
------------------------------------------------------------------------
-- IX: Homotopy levels
-- Lemmas 48-54.
lemma-48 = E.h-level-respects-lens-from-inhabited
lemma-49 = E.contractible-to-contractible
lemma-50 = E.no-first-projection-lens
lemma-51 = E.remainder-has-same-h-level-as-domain
lemma-52 = E.get-equivalence→remainder-propositional
lemma-53 = E.Contractible-closed-codomain
lemma-54 = E.Is-proposition-closed-codomain
-- Lemmas 48-50 for traditional lenses.
lemma-48-for-traditional = T.h-level-respects-lens-from-inhabited
lemma-49-for-traditional = T.contractible-to-contractible
lemma-50-for-traditional = T.no-first-projection-lens
------------------------------------------------------------------------
-- X: Higher and traditional lenses are equivalent for sets
-- Split surjections.
_↠_ = Surjection._↠_
-- Lemmas 55 and 56.
--
-- Lemma 55 takes an extra argument of type Unit, written as
-- Block "conversion". Some other definitions below also take such
-- arguments.
lemma-55 = E.¬Lens↠Traditional-lens
lemma-56 = E.Lens↔Traditional-lens
-- Lemma 56 preserves getters and setters in both directions.
lemma-56-preserves-get-and-set =
E.Lens↔Traditional-lens-preserves-getters-and-setters
------------------------------------------------------------------------
-- XI: Identity and composition
-- The identity lens.
id = EC.id
-- Lemma 58.
lemma-58 = EC.id-unique
-- A composition operator for types in the same universe.
∘-same-universe = EC._∘_
-- A more general composition operator.
∘-more-general = EC.⟨_,_⟩_∘_
-- A lens from a type in a smaller universe to a type in a (possibly)
-- larger universe.
smaller-to-larger = E.↑-lens
-- Composition laws.
associativity = EC.associativity
left-identity = EC.left-identity
right-identity = EC.right-identity
-- Composition laws for traditional lenses.
associativity-traditional = TC.associativity
left-identity-traditional = TC.left-identity
right-identity-traditional = TC.right-identity
-- Lemma 60.
--
-- The lemma is formulated slightly differently.
lemma-60 = EC.∘-unique
-- The composition operator produces lenses for which the setter
-- satisfies certain equations.
setter-correct = EC.∘-set
-- Is-bi-invertible.
Is-bi-invertible = EC.Is-bi-invertible
-- Lemmas 62 and 63.
lemma-62 = EC.≃≃≊
lemma-63 = EC.Is-bi-invertible≃Is-equivalence-get
-- Lemma 62 maps bi-invertible lenses to their getter functions.
lemma-62-right-to-left = EC.to-from-≃≃≊≡get
-- Lemma 62 does not in general hold for traditional lenses.
not-lemma-62-for-traditional = TC.¬Π≃≃≊
-- A variant of Lemma 62 for traditional lenses (a split surjection in
-- the other direction).
lemma-62-for-traditional = TC.≊↠≃
-- Lemma 63 for traditional lenses.
lemma-63-for-traditional = TC.Is-bi-invertible≃Is-equivalence-get
-- A category of higher lenses between sets with the same universe
-- level.
category-higher = EC.category
-- A category of traditional lenses between sets with the same
-- universe level.
category-traditional = TC.category
-- The category of higher lenses is equal to the one for traditional
-- lenses (lifted, so that the two categories have the same type).
category≡category = EC.category≡category
-- Naive categories.
Naive-category = TC.Naive-category
-- A notion of univalence for naive categories.
Univalent = TC.Univalent
-- A naive category of higher lenses between types with the same
-- universe level.
naive-category-higher = EC.naive-category
-- This category is univalent.
naive-category-higher-univalent = EC.univalent
-- A naive category of traditional lenses between types with the same
-- universe level.
naive-category-traditional = TC.naive-category
-- This category is not univalent.
naive-category-traditional-not-univalent = TC.¬-univalent
------------------------------------------------------------------------
-- XII: Coherently constant families of fibres
-- Lens^F.
Lens^F = F.Lens
-- Lemma 65.
lemma-65 = F.Lens.get⁻¹-constant
-- A setter.
set^F = F.Lens.set
-- Lemma 67.
--
-- Unlike in the paper this lemma is defined in two steps, using a
-- minor variant of Lens^F "in the middle".
lemma-67 = F.Lens≃Higher-lens
-- Lemma 67 preserves getters and setters in both directions.
lemma-67-preserves-get-and-set =
F.Lens≃Higher-lens-preserves-getters-and-setters
------------------------------------------------------------------------
-- XIII: Coinductive lenses
-- The one-step truncation operator, and its non-dependent eliminator.
∥_∥¹ = H-level.Truncation.Propositional.One-step.∥_∥¹
rec = H-level.Truncation.Propositional.One-step.rec′
-- Lemma 70.
lemma-70 = H-level.Truncation.Propositional.Non-recursive.∥∥→≃
-- ∥_∥¹-out, ∥_∥¹-in and ∣_,_∣-in.
∥_∥¹-out = H-level.Truncation.Propositional.One-step.∥_∥¹-out-^
∥_∥¹-in = H-level.Truncation.Propositional.One-step.∥_∥¹-in-^
∣_,_∣-in = H-level.Truncation.Propositional.One-step.∣_,_∣-in-^
-- Lemmas 74 and 75.
lemma-74 = H-level.Truncation.Propositional.One-step.∥∥¹-out-^≃∥∥¹-in-^
lemma-75 = H-level.Truncation.Propositional.One-step.∣∣≡∣,∣-in-^
-- Coherently and CC^C.
Coherently = Coh.Coherently
CC^C = C.Coherently-constant
-- Coherently can be defined without using coinduction.
Coherently-without-coinduction = NC.Coherently
Coherently≃Coherently-without-coinduction =
Coh.Coherently≃Not-coinductive-coherently
-- But then Lens^C would not be small (at least with the definition we
-- came up with).
Lens^C-without-coinduction = S.Not-coinductive-lens
Lens^C-without-coinduction≃Lens^C = S.Not-coinductive-lens≃Lens
-- Constant¹ and CC^C1.
Constant¹ = C.Constant′
CC^C1 = C.Coherently-constant′
-- Lemmas 80-86.
--
-- Lemma 84 is more general than in the paper.
lemma-80 = C.Constant≃Constant′
lemma-81 = C.Coherently-constant≃Coherently-constant′
lemma-82 = C.∥∥→≃
lemma-83 = Equivalence.Σ-preserves
lemma-84 = Function-universe.Π-cong-contra
lemma-85 = C.Coherently-constant′≃
lemma-86 = C.Coherently-constant≃Coherently-constant
-- Constant^S and CC^S.
Constant^S = S.Constant-≃
CC^S = S.Coherently-constant
-- Lemma 89.
lemma-89 = S.Coinductive-coherently-constant≃Coherently-constant
-- Lens^C.
Lens^C = S.Lens
-- Lemmas 91-92.
lemma-91 = S.Higher-lens≃Lens
lemma-92 = S.Lens.get⁻¹-constant
-- Lemma 91 preserves getters and setters.
lemma-91-preserves-get-and-set =
S.Higher-lens≃Lens-preserves-getters-and-setters
------------------------------------------------------------------------
-- XIV: Unrestricted composition
-- Lemmas 93 and 94.
lemma-93 = S.Coherently-constant-map
lemma-94 = S.Coherently-constant-Σ
-- Composition.
∘-most-general = S.⟨_,_⟩_∘_
-- Lemma 96.
lemma-96 = S.set-∘
-- Composition laws.
associativity-stable = S.associativity
left-identity-stable = S.left-identity
right-identity-stable = S.right-identity
-- An unrestricted composition operator for Lensᴱ.
∘-most-general′ = S.⟨_,_,_,_,_,_,_,_⟩_⊚_
-- This operator matches "∘-more-general" when all types have the same
-- universe level and the view type of the resulting lens is stable.
∘-more-general-matches-∘-most-general′ = S.⊚≡∘
------------------------------------------------------------------------
-- XV: Homotopy levels, continued
-- Coherently′.
Coherently′ = Coh.Coherently-with-restriction
-- Lemma 98.
lemma-98 = Coh.Coherently≃Coherently-with-restriction
-- Coherently′ can be expressed as an indexed M-type for a certain
-- indexed container.
Coherently′-as-M-type =
Coh.Coherently-with-restriction≃Coherently-with-restriction′
-- Lemmas 99-103.
lemma-99 = Coh.H-level-Coherently-with-restriction
lemma-100 = Coh.H-level-Coherently-→Type
lemma-101 = S.H-level-Coherently-constant
lemma-102 = S.lens-preserves-h-level
lemma-103 = S.h-level-respects-lens-from-inhabited
-- Lemma 103 and a variant of Lemma 102 hold for traditional lenses.
lemma-102-for-traditional = T.lens-preserves-h-level
lemma-103-for-traditional = T.lens-from-⊤≃codomain-contractible
------------------------------------------------------------------------
-- XVI: Related work
-- Lemmas 104-106.
lemma-104 = E.grenrus-example
lemma-105 = E.grenrus-example₁-true
lemma-106 = E.grenrus-example₂-false
-- The lenses used in Lemmas 105 and 106 are equal.
lenses-equal = E.grenrus-example₁≡grenrus-example₂
| {
"alphanum_fraction": 0.6828729907,
"avg_line_length": 27.056661562,
"ext": "agda",
"hexsha": "b8e8552b6f4da4d22539367602b4cd51dddb1f1b",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2020-07-01T14:33:26.000Z",
"max_forks_repo_forks_event_min_datetime": "2020-07-01T14:33:26.000Z",
"max_forks_repo_head_hexsha": "f2da6f7e95b87ca525e8ea43929c6d6163a74811",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/dependent-lenses",
"max_forks_repo_path": "README/Higher-Lenses.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f2da6f7e95b87ca525e8ea43929c6d6163a74811",
"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/dependent-lenses",
"max_issues_repo_path": "README/Higher-Lenses.agda",
"max_line_length": 72,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "f2da6f7e95b87ca525e8ea43929c6d6163a74811",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/dependent-lenses",
"max_stars_repo_path": "README/Higher-Lenses.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-03T08:55:52.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-16T12:10:46.000Z",
"num_tokens": 4953,
"size": 17668
} |
module Formalization.Polynomial where
import Lvl
open import Data.ListSized
open import Numeral.Natural as ℕ using (ℕ)
open import Type
private variable ℓ ℓₑ : Lvl.Level
private variable T : Type{ℓ}
private variable n n₁ n₂ : ℕ
-- TODO: Some of the operations should work with arbitrary Rg structures, not just ℕ, and some other stuff should work with more assumptions. Currently, one of the function that needs to be modified is 𝐷 and normalize for this to work because their implementations depend on ℕ.
-- TODO: Composition of polynomials, power operation
module _ where
-- A polynomial of a finite degree represented as a list of its coefficients.
-- Examples:
-- (a₀⋅x⁰ + a₁⋅x¹ + a₂⋅x² + a₃⋅x³ + a₄⋅x⁴) of degree 4 is [a₀,a₁,a₂,a₃,a₄]
-- (5 + 7⋅x + x³) of maximal degree 3 is [5,7,0,1]
Polynomial : ℕ → Type
Polynomial(n) = List(ℕ)(ℕ.𝐒(n))
open import Data.ListSized.Functions
import Functional as Fn
open import Logic.Propositional
open import Logic.Predicate
import Numeral.Natural.Function as ℕ
open import Numeral.Natural.Function.Proofs
import Numeral.Natural.Oper as ℕ
open import Numeral.Natural.Relation.Order
open import Numeral.Natural.Relation.Order.Proofs
open import Relator.Equals
open import Relator.Equals.Proofs.Equiv{T = ℕ}
-- Constant polynomial.
-- Semantically, this corresponds to a constant.
const : ℕ → Polynomial(n)
const {n} a = a ⊰ repeat ℕ.𝟎 n
-- Zero polynomial.
-- Semantically, this corresponds to zero.
𝟎 : Polynomial(n)
𝟎 {n} = const{n} ℕ.𝟎
-- Unit polynomial.
-- Semantically, this corresponds to one.
𝟏 : Polynomial(n)
𝟏 {n} = const{n}(ℕ.𝐒(ℕ.𝟎))
-- Increases the degree of the polynomial by adding a zero term at the beginning.
-- Semantically, this corresponds to multiplying the whole polynomial by the variable.
-- Example: (var⋅ [a₀,a₁,a₂] = [0,a₀,a₁,a₂])
-- x ⋅ (a₀⋅x⁰ + a₁⋅x¹ + a₂⋅x²)
-- = a₀⋅x¹ + a₁⋅x² + a₂⋅x³
var⋅_ : Polynomial(n) → Polynomial(ℕ.𝐒(n))
var⋅_ = ℕ.𝟎 ⊰_
-- Single variable polynomial.
var : Polynomial(ℕ.𝐒(n))
var = var⋅ 𝟏
-- Polynomial addition.
-- Adds the powers component-wise.
-- Examples: ([a₀,a₁,a₂] + [b₀,b₁,b₂] = [a₀b₀ , a₁+b₁ , a₂+b₂])
-- (a₀⋅x⁰ + a₁⋅x¹ + a₂⋅x²) + (b₀⋅x⁰ + b₁⋅x¹ + b₂⋅x²)
-- = (a₀+b₀)⋅x⁰ + (a₁+b₁)⋅x¹ + (a₂+b₂)⋅x²
-- of maximal degree 2 is [a₀+b₀ , a₁+b₁ , a₂+b₂]
_+_ : Polynomial(n₁) → Polynomial(n₂) → Polynomial(ℕ.max n₁ n₂)
_+_ = map₂(ℕ._+_) Fn.id Fn.id
-- Polymonial scalar multiplication.
-- Multiplies every component by a factor.
-- Example: (n ⋅ [a₀,a₁,a₂] = [n⋅a₀ , n⋅a₁ , n⋅a₂])
-- n ⋅ (a₀⋅x⁰ + a₁⋅x¹ + a₂⋅x²)
-- = (n⋅a₀)⋅x⁰ + (n⋅a₁)⋅x¹ + (n⋅a₂)⋅x²
_⋅_ : ℕ → Polynomial(n) → Polynomial(n)
n ⋅ as = map (n ℕ.⋅_) as
-- Increases the degree of the polynomial by adding zero terms at the end.
-- Semantically, this corresponds to adding terms multiplied by zero.
-- Example: (pad [a₀,a₁,a₂] = [a₀,a₁,a₂,0,0])
-- a₀⋅x⁰ + a₁⋅x¹ + a₂⋅x²
-- = a₀⋅x⁰ + a₁⋅x¹ + a₂⋅x² + 0⋅x³ + 0⋅x⁴
pad : ⦃ _ : (n₁ ≤ n₂)⦄ → Polynomial(n₁) → Polynomial(n₂)
pad {n₁ = ℕ.𝟎} {n₂ = ℕ.𝟎} ⦃ min ⦄ (a ⊰ ∅) = singleton a
pad {n₁ = ℕ.𝟎} {n₂ = ℕ.𝐒(n₂)} ⦃ min ⦄ (a ⊰ ∅) = a ⊰ 𝟎
pad {n₁ = ℕ.𝐒(n₁)} {n₂ = ℕ.𝐒(n₂)} ⦃ succ p ⦄ (a ⊰ as) = a ⊰ pad ⦃ p ⦄ as
-- Polynomial multiplication.
-- Proof of step:
-- ∑(0‥𝐒(n₁))(i ↦ aᵢ⋅xⁱ) ⋅ ∑(0‥𝐒(n₂))(i ↦ bᵢ⋅xⁱ)
-- = (a + ∑(1‥𝐒(n₁))(i ↦ aᵢ⋅xⁱ)) ⋅ (b + ∑(1‥𝐒(n₂))(i ↦ bᵢ⋅xⁱ))
-- = (a ⋅ b) + (a ⋅ ∑(1‥𝐒(n₂))(i ↦ bᵢ⋅xⁱ)) + (∑(1‥𝐒(n₁))(i ↦ aᵢ⋅xⁱ) ⋅ b) + (∑(1‥𝐒(n₁))(i ↦ aᵢ⋅xⁱ) ⋅ ∑(1‥𝐒(n₂))(i ↦ bᵢ⋅xⁱ))
-- = (a⋅b) + (a ⋅ ∑(1‥𝐒(n₂))(i ↦ bᵢ⋅xⁱ)) + (∑(1‥𝐒(n₁))(i ↦ aᵢ⋅xⁱ) ⋅ b⋅x) + (∑(1‥𝐒(n₁))(i ↦ aᵢ⋅xⁱ) ⋅ ∑(1‥𝐒(n₂))(i ↦ bᵢ⋅xⁱ))
-- = (a⋅b) + (a ⋅ ∑(0‥n₂)(i ↦ bᵢ⋅xⁱ)⋅x) + (∑(0‥n₁)(i ↦ aᵢ⋅xⁱ)⋅x ⋅ b) + (∑(1‥𝐒(n₁))(i ↦ aᵢ⋅xⁱ) ⋅ ∑(1‥𝐒(n₂))(i ↦ bᵢ⋅xⁱ))
-- = (a⋅b) + (a ⋅ ∑(0‥n₂)(i ↦ bᵢ⋅xⁱ))⋅x + (∑(0‥n₁)(i ↦ aᵢ⋅xⁱ) ⋅ b)⋅x + (∑(0‥n₁)(i ↦ aᵢ⋅xⁱ) ⋅ ∑(0‥n₂)(i ↦ bᵢ⋅xⁱ))⋅x²
-- = (a⋅b) + ((a ⋅ ∑(0‥n₂)(i ↦ bᵢ⋅xⁱ)) + (∑(0‥n₁)(i ↦ aᵢ⋅xⁱ) ⋅ b) + (∑(0‥n₁)(i ↦ aᵢ⋅xⁱ) ⋅ ∑(0‥n₂)(i ↦ bᵢ⋅xⁱ))⋅x)⋅x
-- Also see `eval-preserves-multiplication`.
_⨯_ : Polynomial(n₁) → Polynomial(n₂) → Polynomial(n₁ ℕ.+ n₂)
_⨯_ as@(_ ⊰ _) (b ⊰ ∅) = b ⋅ as
_⨯_ (a ⊰ ∅) bs@(_ ⊰ _ ⊰ _) = a ⋅ bs
_⨯_ {ℕ.𝐒 n₁}{ℕ.𝐒 n₂} (a ⊰ as@(_ ⊰ _)) (b ⊰ bs@(_ ⊰ _)) = (a ℕ.⋅ b) ⊰ lr where
l : Polynomial(n₁ ℕ.+ n₂)
l = pad ⦃ max-order-[+] ⦄ ((b ⋅ as) + (a ⋅ bs))
r : Polynomial(ℕ.𝐒(n₁ ℕ.+ n₂))
r = var⋅ (as ⨯ bs)
lr : Polynomial(ℕ.𝐒(n₁ ℕ.+ n₂))
lr = [≡]-substitutionᵣ ([↔]-to-[→] max-defᵣ [≤]-of-[𝐒]) {Polynomial} (l + r)
normalize : Polynomial(n) → ∃(Polynomial)
normalize {ℕ.𝟎} (x ⊰ ∅) = [∃]-intro ℕ.𝟎 ⦃ x ⊰ ∅ ⦄
normalize {ℕ.𝐒 n} (ℕ.𝟎 ⊰ p) with normalize{n} p
... | [∃]-intro ℕ.𝟎 ⦃ singleton ℕ.𝟎 ⦄ = [∃]-intro ℕ.𝟎 ⦃ singleton ℕ.𝟎 ⦄
{-# CATCHALL #-}
... | [∃]-intro m ⦃ a ⦄ = [∃]-intro (ℕ.𝐒(m)) ⦃ ℕ.𝟎 ⊰ a ⦄
normalize {ℕ.𝐒 n} (ℕ.𝐒(x) ⊰ p) = [∃]-map ℕ.𝐒 (ℕ.𝐒(x) ⊰_) (normalize{n} p)
degree : Polynomial(n) → ℕ
degree = [∃]-witness Fn.∘ normalize
𝐷 : Polynomial(n) → Polynomial(ℕ.𝐏(n))
𝐷 {ℕ.𝟎} = Fn.id
𝐷 {ℕ.𝐒 n} = map₂₌(ℕ._⋅_) (accumulateIterate n ℕ.𝐒(ℕ.𝐒(ℕ.𝟎))) Fn.∘ tail
import Numeral.Natural.Oper.FlooredDivision as ℕ
∫ : Polynomial(n) → Polynomial(ℕ.𝐒(n))
∫ {n} p = var⋅(map₂₌(ℕ._⌊/⌋₀_) p (accumulateIterate n ℕ.𝐒(ℕ.𝐒(ℕ.𝟎))))
module Semantics where
open import Data.ListSized.Functions
open import Logic.Propositional
open import Numeral.Finite as 𝕟 using (𝕟)
import Numeral.Natural.Oper as ℕ
open import Numeral.Natural.Oper.Proofs
open import Numeral.Natural.Relation.Order
open import Relator.Equals.Proofs.Equiv{T = ℕ}
open import Structure.Function.Multi
open import Structure.Operator
open import Structure.Operator.Proofs.Util
open import Structure.Operator.Properties
open import Structure.Relator.Properties
open import Structure.Setoid
open import Syntax.Function
open import Syntax.Transitivity
eval : Polynomial(n) → (ℕ → ℕ)
eval (singleton a) _ = a
eval (a ⊰ al@(_ ⊰ _)) x = a ℕ.+ (x ℕ.⋅ (eval al x))
module Proofs where
eval-of-[⊰] : ∀{x}{a}{al : Polynomial(n)} → (eval (a ⊰ al) x ≡ a ℕ.+ (x ℕ.⋅ (eval al x)))
eval-of-[⊰] {ℕ.𝟎} {x} {a} {b ⊰ ∅} = reflexivity(_≡_)
eval-of-[⊰] {ℕ.𝐒 n} {x} {a} {b ⊰ c ⊰ al} = reflexivity(_≡_)
eval-preserves-var⋅ : ∀{x}{a : Polynomial(n)} → (eval (var⋅ a) x ≡ x ℕ.⋅ (eval a x))
eval-preserves-var⋅ {n}{x}{a} = eval-of-[⊰] {n}{x}{ℕ.𝟎}{a}
eval-preserves-zero : ∀{x} → (eval{n} 𝟎 x ≡ ℕ.𝟎)
eval-preserves-zero {ℕ.𝟎} {x} = reflexivity(_≡_)
eval-preserves-zero {ℕ.𝐒 n} {x} =
eval(𝟎 {ℕ.𝐒 n}) x 🝖[ _≡_ ]-[]
eval(ℕ.𝟎 ⊰ 𝟎 {n}) x 🝖[ _≡_ ]-[]
ℕ.𝟎 ℕ.+ (x ℕ.⋅ eval (𝟎 {n}) x) 🝖[ _≡_ ]-[]
x ℕ.⋅ eval (𝟎 {n}) x 🝖[ _≡_ ]-[ congruence₂ᵣ(ℕ._⋅_)(x) (eval-preserves-zero{n}{x}) ]
x ℕ.⋅ ℕ.𝟎 🝖[ _≡_ ]-[ absorberᵣ(ℕ._⋅_)(ℕ.𝟎) {x} ]
ℕ.𝟎 🝖-end
eval-preserves-const : ∀{x}{a} → (eval{n} (const a) x ≡ a)
eval-preserves-const {ℕ.𝟎} {x}{a} = reflexivity(_≡_)
eval-preserves-const {ℕ.𝐒 n} {x}{a} =
eval{ℕ.𝐒 n} (const a) x 🝖[ _≡_ ]-[]
eval(a ⊰ repeat ℕ.𝟎 (ℕ.𝐒 n)) x 🝖[ _≡_ ]-[ eval-of-[⊰] {x = x}{a}{repeat ℕ.𝟎 (ℕ.𝐒 n)} ]
a ℕ.+ (x ℕ.⋅ eval(repeat ℕ.𝟎 (ℕ.𝐒 n)) x) 🝖[ _≡_ ]-[]
a ℕ.+ (x ℕ.⋅ eval{n} 𝟎 x) 🝖[ _≡_ ]-[ congruence₂ᵣ(ℕ._+_)(a) (eval-preserves-zero{ℕ.𝐒 n}{x = x}) ]
a ℕ.+ (x ℕ.⋅ ℕ.𝟎) 🝖[ _≡_ ]-[]
a ℕ.+ ℕ.𝟎 🝖[ _≡_ ]-[ identityᵣ(ℕ._+_)(ℕ.𝟎) ]
a 🝖-end
eval-preserves-one : ∀{x} → (eval{n} 𝟏 x ≡ ℕ.𝐒(ℕ.𝟎))
eval-preserves-one {n}{x} = eval-preserves-const {n}{x}{ℕ.𝐒(ℕ.𝟎)}
eval-preserves-var : ∀{x}{a : Polynomial(n)} → (eval (var{n}) x ≡ x)
eval-preserves-var {n}{x}{a} =
eval (var{n}) x 🝖[ _≡_ ]-[ eval-preserves-var⋅{n}{x}{𝟏} ]
x ℕ.⋅ eval (𝟏 {n}) x 🝖[ _≡_ ]-[ congruence₂ᵣ(ℕ._⋅_)(x) (eval-preserves-one {n}{x}) ]
x ℕ.⋅ ℕ.𝐒(ℕ.𝟎) 🝖[ _≡_ ]-[ identityᵣ(ℕ._⋅_)(ℕ.𝐒(ℕ.𝟎)) {x} ]
x 🝖-end
eval-preserves-addition : ∀{x}{a : Polynomial(n₁)}{b : Polynomial(n₂)} → (eval (a + b) x ≡ (eval a x) ℕ.+ (eval b x))
eval-preserves-addition {x = x} {singleton a} {singleton b} = reflexivity(_≡_)
eval-preserves-addition {x = x} {singleton a} {b ⊰ bs@(_ ⊰ _)} = associativity(ℕ._+_) {a}{b}
eval-preserves-addition {x = x} {a ⊰ as@(_ ⊰ _)} {singleton b} =
eval ((a ⊰ as) + (singleton b)) x 🝖[ _≡_ ]-[]
(a ℕ.+ b) ℕ.+ (x ℕ.⋅ (eval as x)) 🝖[ _≡_ ]-[ associativity(ℕ._+_) {a}{b} ]
a ℕ.+ (b ℕ.+ (x ℕ.⋅ (eval as x))) 🝖[ _≡_ ]-[ congruence₂ᵣ(ℕ._+_)(a) (commutativity(ℕ._+_) {x = b}) ]
a ℕ.+ ((x ℕ.⋅ (eval as x)) ℕ.+ b) 🝖[ _≡_ ]-[ associativity(ℕ._+_) {a}{x ℕ.⋅ eval as x} ]-sym
(a ℕ.+ (x ℕ.⋅ (eval as x))) ℕ.+ b 🝖[ _≡_ ]-[]
(eval (a ⊰ as) x) ℕ.+ (eval (singleton b) x) 🝖-end
eval-preserves-addition {x = x} {a ⊰ as@(_ ⊰ _)} {b ⊰ bs@(_ ⊰ _)} =
eval ((a ⊰ as) + (b ⊰ bs)) x 🝖[ _≡_ ]-[]
eval ((a ℕ.+ b) ⊰ (as + bs)) x 🝖[ _≡_ ]-[]
(a ℕ.+ b) ℕ.+ (x ℕ.⋅ (eval (as + bs) x)) 🝖[ _≡_ ]-[ congruence₂ᵣ(ℕ._+_)(a ℕ.+ b) (congruence₂ᵣ(ℕ._⋅_)(x) (eval-preserves-addition {x = x}{as}{bs})) ]
(a ℕ.+ b) ℕ.+ (x ℕ.⋅ ((eval as x) ℕ.+ (eval bs x))) 🝖[ _≡_ ]-[ congruence₂ᵣ(ℕ._+_)(a ℕ.+ b) (distributivityₗ(ℕ._⋅_)(ℕ._+_) {x}{eval as x}{eval bs x}) ]
(a ℕ.+ b) ℕ.+ ((x ℕ.⋅ (eval as x)) ℕ.+ (x ℕ.⋅ (eval bs x))) 🝖[ _≡_ ]-[ One.associate-commute4 {a = a}{b = b}{c = x ℕ.⋅ (eval as x)}{d = x ℕ.⋅ (eval bs x)} (commutativity(ℕ._+_) {b}) ]
(a ℕ.+ (x ℕ.⋅ (eval as x))) ℕ.+ (b ℕ.+ (x ℕ.⋅ (eval bs x))) 🝖[ _≡_ ]-[]
(eval (a ⊰ as) x) ℕ.+ (eval (b ⊰ bs) x) 🝖-end
eval-preserves-scalar-multiplication : ∀{x}{a}{b : Polynomial(n)} → (eval (a ⋅ b) x ≡ a ℕ.⋅ (eval b x))
eval-preserves-scalar-multiplication {ℕ.𝟎} {x} {a} {b ⊰ ∅} = reflexivity(_≡_)
eval-preserves-scalar-multiplication {ℕ.𝐒 n} {x} {a} {b ⊰ bs@(_ ⊰ _)} =
eval (a ⋅ (b ⊰ bs)) x 🝖[ _≡_ ]-[]
eval ((a ℕ.⋅ b) ⊰ (a ⋅ bs)) x 🝖[ _≡_ ]-[]
(a ℕ.⋅ b) ℕ.+ (x ℕ.⋅ (eval (a ⋅ bs) x)) 🝖[ _≡_ ]-[ congruence₂ᵣ(ℕ._+_)(a ℕ.⋅ b) (congruence₂ᵣ(ℕ._⋅_)(x) (eval-preserves-scalar-multiplication {n} {x}{a}{bs})) ]
(a ℕ.⋅ b) ℕ.+ (x ℕ.⋅ (a ℕ.⋅ (eval bs x))) 🝖[ _≡_ ]-[ congruence₂ᵣ(ℕ._+_)(a ℕ.⋅ b) (One.commuteₗ-assocᵣ {a = x}{b = a}{c = eval bs x}) ]
(a ℕ.⋅ b) ℕ.+ (a ℕ.⋅ (x ℕ.⋅ (eval bs x))) 🝖[ _≡_ ]-[ distributivityₗ(ℕ._⋅_)(ℕ._+_) {x = a}{y = b}{z = x ℕ.⋅ (eval bs x)} ]-sym
a ℕ.⋅ (b ℕ.+ (x ℕ.⋅ (eval bs x))) 🝖[ _≡_ ]-[]
a ℕ.⋅ eval (b ⊰ bs) x 🝖-end
eval-preserves-pad : ∀{x}{a : Polynomial(n₁)} ⦃ ord : (n₁ ≤ n₂) ⦄ → (eval (pad ⦃ ord ⦄ a) x ≡ eval a x)
eval-preserves-pad {ℕ.𝟎} {ℕ.𝟎} {x} {a ⊰ ∅} ⦃ ord@min ⦄ = reflexivity(_≡_)
eval-preserves-pad {ℕ.𝟎} {ℕ.𝐒 n₂} {x} {a ⊰ ∅} ⦃ ord@min ⦄ =
eval (pad ⦃ ord ⦄ (a ⊰ ∅)) x 🝖[ _≡_ ]-[]
a ℕ.+ (x ℕ.⋅ eval (𝟎 {n₂}) x) 🝖[ _≡_ ]-[ congruence₂ᵣ(ℕ._+_)(a) (congruence₂ᵣ(ℕ._⋅_)(x) (eval-preserves-zero{n₂}{x})) ]
a ℕ.+ (x ℕ.⋅ ℕ.𝟎) 🝖[ _≡_ ]-[ congruence₂ᵣ(ℕ._+_)(a) (absorberᵣ(ℕ._⋅_)(ℕ.𝟎) {x}) ]
a ℕ.+ ℕ.𝟎 🝖[ _≡_ ]-[ identityᵣ(ℕ._+_)(ℕ.𝟎) ]
a 🝖[ _≡_ ]-[]
eval (a ⊰ ∅) x 🝖-end
eval-preserves-pad {ℕ.𝐒 n₁} {ℕ.𝐒 n₂} {x} {a ⊰ as@(_ ⊰ _)} ⦃ ord@(succ p) ⦄ =
eval (pad ⦃ ord ⦄ (a ⊰ as)) x 🝖[ _≡_ ]-[]
eval (a ⊰ pad ⦃ _ ⦄ as) x 🝖[ _≡_ ]-[ eval-of-[⊰] {n₂}{x}{a}{pad ⦃ p ⦄ as} ]
a ℕ.+ (x ℕ.⋅ eval (pad ⦃ _ ⦄ as) x) 🝖[ _≡_ ]-[ congruence₂ᵣ(ℕ._+_)(a) (congruence₂ᵣ(ℕ._⋅_)(x) (eval-preserves-pad {n₁}{n₂}{x}{as} ⦃ p ⦄)) ]
a ℕ.+ (x ℕ.⋅ eval as x) 🝖[ _≡_ ]-[ eval-of-[⊰] {n₁}{x}{a}{as} ]-sym
eval (a ⊰ as) x 🝖-end
eval-preserves-multiplication : ∀{x}{a : Polynomial(n₁)}{b : Polynomial(n₂)} → (eval (a ⨯ b) x ≡ (eval a x) ℕ.⋅ (eval b x))
eval-preserves-multiplication {n₁} {ℕ.𝟎} {x} {a ⊰ as} {b ⊰ ∅} =
eval ((a ⊰ as) ⨯ (b ⊰ ∅)) x 🝖[ _≡_ ]-[]
eval (b ⋅ (a ⊰ as)) x 🝖[ _≡_ ]-[ eval-preserves-scalar-multiplication {x = x}{b}{a ⊰ as} ]
b ℕ.⋅ eval (a ⊰ as) x 🝖[ _≡_ ]-[ commutativity(ℕ._⋅_) {b}{eval(a ⊰ as) x} ]
eval (a ⊰ as) x ℕ.⋅ b 🝖[ _≡_ ]-[]
(eval (a ⊰ as) x ℕ.⋅ eval (b ⊰ ∅) x) 🝖-end
eval-preserves-multiplication {ℕ.𝟎} {ℕ.𝐒 n₂}{x} {a ⊰ ∅} {b ⊰ bs@(_ ⊰ _)} =
eval ((a ⊰ ∅) ⨯ (b ⊰ bs)) x 🝖[ _≡_ ]-[]
eval (a ⋅ (b ⊰ bs)) x 🝖[ _≡_ ]-[ eval-preserves-scalar-multiplication {x = x}{a}{b ⊰ bs} ]
a ℕ.⋅ (b ℕ.+ (x ℕ.⋅ eval bs x)) 🝖[ _≡_ ]-[]
eval (a ⊰ ∅) x ℕ.⋅ eval (b ⊰ bs) x 🝖-end
eval-preserves-multiplication {ℕ.𝐒 n₁}{ℕ.𝐒 n₂}{x} {a ⊰ as@(_ ⊰ _)} {b ⊰ bs@(_ ⊰ _)} =
eval((a ℕ.⋅ b) ⊰ lr) x 🝖[ _≡_ ]-[ eval-of-[⊰] {x = x}{a = a ℕ.⋅ b}{al = lr} ]
(a ℕ.⋅ b) ℕ.+ (x ℕ.⋅ eval lr x) 🝖[ _≡_ ]-[ congruence₂ᵣ(ℕ._+_)(a ℕ.⋅ b) (congruence₂ᵣ(ℕ._⋅_)(x) eval-lr) ]
(a ℕ.⋅ b) ℕ.+ (x ℕ.⋅ (((b ℕ.⋅ eval as x) ℕ.+ (a ℕ.⋅ eval bs x)) ℕ.+ (x ℕ.⋅ (eval as x ℕ.⋅ eval bs x)))) 🝖[ _≡_ ]-[ alg{a}{b}{x}{eval as x}{eval bs x} ]
(a ℕ.+ (x ℕ.⋅ eval as x)) ℕ.⋅ (b ℕ.+ (x ℕ.⋅ eval bs x)) 🝖[ _≡_ ]-[ congruence₂(ℕ._⋅_) (eval-of-[⊰] {x = x}{a = a}{al = as}) (eval-of-[⊰] {x = x}{a = b}{al = bs}) ]
(eval(a ⊰ as) x ℕ.⋅ eval(b ⊰ bs) x) 🝖-end
where
open import Numeral.Natural.Function
open import Numeral.Natural.Function.Proofs
open import Numeral.Natural.Relation.Order.Proofs
open import Relator.Equals using ([≡]-intro)
l : Polynomial(n₁ ℕ.+ n₂)
l = pad ⦃ max-order-[+] ⦄ ((b ⋅ as) + (a ⋅ bs))
r : Polynomial(ℕ.𝐒(n₁ ℕ.+ n₂))
r = var⋅ (as ⨯ bs)
lr : Polynomial(ℕ.𝐒(n₁ ℕ.+ n₂))
lr = [≡]-substitutionᵣ ([↔]-to-[→] max-defᵣ [≤]-of-[𝐒]) {Polynomial} (l + r)
eval-l : (eval l x ≡ (b ℕ.⋅ eval as x) ℕ.+ (a ℕ.⋅ eval bs x))
eval-l =
eval l x 🝖[ _≡_ ]-[]
eval (pad ⦃ max-order-[+] ⦄ ((b ⋅ as) + (a ⋅ bs))) x 🝖[ _≡_ ]-[ eval-preserves-pad {x = x}{(b ⋅ as) + (a ⋅ bs)} ⦃ max-order-[+] ⦄ ]
eval ((b ⋅ as) + (a ⋅ bs)) x 🝖[ _≡_ ]-[ eval-preserves-addition {x = x}{b ⋅ as}{a ⋅ bs} ]
eval (b ⋅ as) x ℕ.+ eval (a ⋅ bs) x 🝖[ _≡_ ]-[ congruence₂(ℕ._+_) (eval-preserves-scalar-multiplication {x = x}{b}{as}) (eval-preserves-scalar-multiplication {x = x}{a}{bs}) ]
(b ℕ.⋅ eval as x) ℕ.+ (a ℕ.⋅ eval bs x) 🝖-end
eval-r : (eval r x ≡ x ℕ.⋅ (eval as x ℕ.⋅ eval bs x))
eval-r =
eval r x 🝖[ _≡_ ]-[]
eval (var⋅ (as ⨯ bs)) x 🝖[ _≡_ ]-[ eval-preserves-var⋅ {x = x}{as ⨯ bs} ]
x ℕ.⋅ eval (as ⨯ bs) x 🝖[ _≡_ ]-[ congruence₂ᵣ(ℕ._⋅_)(x) (eval-preserves-multiplication {x = x}{as}{bs}) ]
x ℕ.⋅ (eval as x ℕ.⋅ eval bs x) 🝖-end
eval-substitution : ∀{m n}{a : Polynomial(m)}{eq : (m ≡ n)}{x} → (eval ([≡]-substitutionᵣ eq {Polynomial} a) x ≡ eval a x)
eval-substitution {eq = [≡]-intro} = [≡]-intro
eval-lr : (eval lr x ≡ ((b ℕ.⋅ eval as x) ℕ.+ (a ℕ.⋅ eval bs x)) ℕ.+ (x ℕ.⋅ (eval as x ℕ.⋅ eval bs x)))
eval-lr =
eval lr x 🝖[ _≡_ ]-[ eval-substitution{a = l + r}{[↔]-to-[→] max-defᵣ [≤]-of-[𝐒]}{x = x} ]
eval (l + r) x 🝖[ _≡_ ]-[ eval-preserves-addition{x = x}{l}{r} ]
eval l x ℕ.+ eval r x 🝖[ _≡_ ]-[ congruence₂(ℕ._+_) eval-l eval-r ]
((b ℕ.⋅ eval as x) ℕ.+ (a ℕ.⋅ eval bs x)) ℕ.+ (x ℕ.⋅ (eval as x ℕ.⋅ eval bs x)) 🝖-end
alg : ∀{a b x q r} → ((a ℕ.⋅ b) ℕ.+ (x ℕ.⋅ (((b ℕ.⋅ q) ℕ.+ (a ℕ.⋅ r)) ℕ.+ (x ℕ.⋅ (q ℕ.⋅ r)))) ≡ (a ℕ.+ (x ℕ.⋅ q)) ℕ.⋅ (b ℕ.+ (x ℕ.⋅ r)))
alg {a}{b}{x}{q}{r} =
(a ℕ.⋅ b) ℕ.+ (x ℕ.⋅ (((b ℕ.⋅ q) ℕ.+ (a ℕ.⋅ r)) ℕ.+ (x ℕ.⋅ (q ℕ.⋅ r)))) 🝖[ _≡_ ]-[ congruence₂ᵣ(ℕ._+_)(a ℕ.⋅ b) (distributivityₗ(ℕ._⋅_)(ℕ._+_) {x}{(b ℕ.⋅ q) ℕ.+ (a ℕ.⋅ r)}{x ℕ.⋅ (q ℕ.⋅ r)}) ]
(a ℕ.⋅ b) ℕ.+ ((x ℕ.⋅ ((b ℕ.⋅ q) ℕ.+ (a ℕ.⋅ r))) ℕ.+ (x ℕ.⋅ (x ℕ.⋅ (q ℕ.⋅ r)))) 🝖[ _≡_ ]-[ congruence₂ᵣ(ℕ._+_)(a ℕ.⋅ b) (congruence₂(ℕ._+_) (distributivityₗ(ℕ._⋅_)(ℕ._+_) {x}{b ℕ.⋅ q}{a ℕ.⋅ r}) (symmetry(_≡_) (associativity(ℕ._⋅_) {x}{x}{q ℕ.⋅ r}))) ]
(a ℕ.⋅ b) ℕ.+ (((x ℕ.⋅ (b ℕ.⋅ q)) ℕ.+ (x ℕ.⋅ (a ℕ.⋅ r))) ℕ.+ ((x ℕ.⋅ x) ℕ.⋅ (q ℕ.⋅ r))) 🝖[ _≡_ ]-[ congruence₂ᵣ(ℕ._+_)(a ℕ.⋅ b) (congruence₂(ℕ._+_) (congruence₂(ℕ._+_) (One.commuteᵣ-assocᵣ {_▫_ = ℕ._⋅_}{a = x}{b}{q}) (One.commuteₗ-assocᵣ {_▫_ = ℕ._⋅_}{a = x}{a}{r})) (One.associate-commute4-c {_▫_ = ℕ._⋅_}{a = x}{x}{q}{r})) ]
(a ℕ.⋅ b) ℕ.+ ((((x ℕ.⋅ q) ℕ.⋅ b) ℕ.+ (a ℕ.⋅ (x ℕ.⋅ r))) ℕ.+ ((x ℕ.⋅ q) ℕ.⋅ (x ℕ.⋅ r))) 🝖[ _≡_ ]-[ One.associate4-231-222 {_▫_ = ℕ._+_} {a = a ℕ.⋅ b}{(x ℕ.⋅ q) ℕ.⋅ b}{a ℕ.⋅ (x ℕ.⋅ r)}{(x ℕ.⋅ q) ℕ.⋅ (x ℕ.⋅ r)} ]
((a ℕ.⋅ b) ℕ.+ ((x ℕ.⋅ q) ℕ.⋅ b)) ℕ.+ ((a ℕ.⋅ (x ℕ.⋅ r)) ℕ.+ ((x ℕ.⋅ q) ℕ.⋅ (x ℕ.⋅ r))) 🝖[ _≡_ ]-[ OneTypeTwoOp.cross-distribute{a = a}{x ℕ.⋅ q}{b}{x ℕ.⋅ r} ]-sym
(a ℕ.+ (x ℕ.⋅ q)) ℕ.⋅ (b ℕ.+ (x ℕ.⋅ r)) 🝖-end
| {
"alphanum_fraction": 0.4531919569,
"avg_line_length": 60.0726072607,
"ext": "agda",
"hexsha": "0b368956c4f9a2ff926ef1af52856caeea7c34ca",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Formalization/Polynomial.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Formalization/Polynomial.agda",
"max_line_length": 338,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Formalization/Polynomial.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": 9124,
"size": 18202
} |
module Text.Greek.SBLGNT.Titus where
open import Data.List
open import Text.Greek.Bible
open import Text.Greek.Script
open import Text.Greek.Script.Unicode
ΠΡΟΣ-ΤΙΤΟΝ : List (Word)
ΠΡΟΣ-ΤΙΤΟΝ =
word (Π ∷ α ∷ ῦ ∷ ∙λ ∷ ο ∷ ς ∷ []) "Titus.1.1"
∷ word (δ ∷ ο ∷ ῦ ∷ ∙λ ∷ ο ∷ ς ∷ []) "Titus.1.1"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "Titus.1.1"
∷ word (ἀ ∷ π ∷ ό ∷ σ ∷ τ ∷ ο ∷ ∙λ ∷ ο ∷ ς ∷ []) "Titus.1.1"
∷ word (δ ∷ ὲ ∷ []) "Titus.1.1"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Titus.1.1"
∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "Titus.1.1"
∷ word (κ ∷ α ∷ τ ∷ ὰ ∷ []) "Titus.1.1"
∷ word (π ∷ ί ∷ σ ∷ τ ∷ ι ∷ ν ∷ []) "Titus.1.1"
∷ word (ἐ ∷ κ ∷ ∙λ ∷ ε ∷ κ ∷ τ ∷ ῶ ∷ ν ∷ []) "Titus.1.1"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "Titus.1.1"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.1.1"
∷ word (ἐ ∷ π ∷ ί ∷ γ ∷ ν ∷ ω ∷ σ ∷ ι ∷ ν ∷ []) "Titus.1.1"
∷ word (ἀ ∷ ∙λ ∷ η ∷ θ ∷ ε ∷ ί ∷ α ∷ ς ∷ []) "Titus.1.1"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "Titus.1.1"
∷ word (κ ∷ α ∷ τ ∷ []) "Titus.1.1"
∷ word (ε ∷ ὐ ∷ σ ∷ έ ∷ β ∷ ε ∷ ι ∷ α ∷ ν ∷ []) "Titus.1.1"
∷ word (ἐ ∷ π ∷ []) "Titus.1.2"
∷ word (ἐ ∷ ∙λ ∷ π ∷ ί ∷ δ ∷ ι ∷ []) "Titus.1.2"
∷ word (ζ ∷ ω ∷ ῆ ∷ ς ∷ []) "Titus.1.2"
∷ word (α ∷ ἰ ∷ ω ∷ ν ∷ ί ∷ ο ∷ υ ∷ []) "Titus.1.2"
∷ word (ἣ ∷ ν ∷ []) "Titus.1.2"
∷ word (ἐ ∷ π ∷ η ∷ γ ∷ γ ∷ ε ∷ ί ∷ ∙λ ∷ α ∷ τ ∷ ο ∷ []) "Titus.1.2"
∷ word (ὁ ∷ []) "Titus.1.2"
∷ word (ἀ ∷ ψ ∷ ε ∷ υ ∷ δ ∷ ὴ ∷ ς ∷ []) "Titus.1.2"
∷ word (θ ∷ ε ∷ ὸ ∷ ς ∷ []) "Titus.1.2"
∷ word (π ∷ ρ ∷ ὸ ∷ []) "Titus.1.2"
∷ word (χ ∷ ρ ∷ ό ∷ ν ∷ ω ∷ ν ∷ []) "Titus.1.2"
∷ word (α ∷ ἰ ∷ ω ∷ ν ∷ ί ∷ ω ∷ ν ∷ []) "Titus.1.2"
∷ word (ἐ ∷ φ ∷ α ∷ ν ∷ έ ∷ ρ ∷ ω ∷ σ ∷ ε ∷ ν ∷ []) "Titus.1.3"
∷ word (δ ∷ ὲ ∷ []) "Titus.1.3"
∷ word (κ ∷ α ∷ ι ∷ ρ ∷ ο ∷ ῖ ∷ ς ∷ []) "Titus.1.3"
∷ word (ἰ ∷ δ ∷ ί ∷ ο ∷ ι ∷ ς ∷ []) "Titus.1.3"
∷ word (τ ∷ ὸ ∷ ν ∷ []) "Titus.1.3"
∷ word (∙λ ∷ ό ∷ γ ∷ ο ∷ ν ∷ []) "Titus.1.3"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "Titus.1.3"
∷ word (ἐ ∷ ν ∷ []) "Titus.1.3"
∷ word (κ ∷ η ∷ ρ ∷ ύ ∷ γ ∷ μ ∷ α ∷ τ ∷ ι ∷ []) "Titus.1.3"
∷ word (ὃ ∷ []) "Titus.1.3"
∷ word (ἐ ∷ π ∷ ι ∷ σ ∷ τ ∷ ε ∷ ύ ∷ θ ∷ η ∷ ν ∷ []) "Titus.1.3"
∷ word (ἐ ∷ γ ∷ ὼ ∷ []) "Titus.1.3"
∷ word (κ ∷ α ∷ τ ∷ []) "Titus.1.3"
∷ word (ἐ ∷ π ∷ ι ∷ τ ∷ α ∷ γ ∷ ὴ ∷ ν ∷ []) "Titus.1.3"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "Titus.1.3"
∷ word (σ ∷ ω ∷ τ ∷ ῆ ∷ ρ ∷ ο ∷ ς ∷ []) "Titus.1.3"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "Titus.1.3"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "Titus.1.3"
∷ word (Τ ∷ ί ∷ τ ∷ ῳ ∷ []) "Titus.1.4"
∷ word (γ ∷ ν ∷ η ∷ σ ∷ ί ∷ ῳ ∷ []) "Titus.1.4"
∷ word (τ ∷ έ ∷ κ ∷ ν ∷ ῳ ∷ []) "Titus.1.4"
∷ word (κ ∷ α ∷ τ ∷ ὰ ∷ []) "Titus.1.4"
∷ word (κ ∷ ο ∷ ι ∷ ν ∷ ὴ ∷ ν ∷ []) "Titus.1.4"
∷ word (π ∷ ί ∷ σ ∷ τ ∷ ι ∷ ν ∷ []) "Titus.1.4"
∷ word (χ ∷ ά ∷ ρ ∷ ι ∷ ς ∷ []) "Titus.1.4"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.1.4"
∷ word (ε ∷ ἰ ∷ ρ ∷ ή ∷ ν ∷ η ∷ []) "Titus.1.4"
∷ word (ἀ ∷ π ∷ ὸ ∷ []) "Titus.1.4"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "Titus.1.4"
∷ word (π ∷ α ∷ τ ∷ ρ ∷ ὸ ∷ ς ∷ []) "Titus.1.4"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.1.4"
∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "Titus.1.4"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Titus.1.4"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "Titus.1.4"
∷ word (σ ∷ ω ∷ τ ∷ ῆ ∷ ρ ∷ ο ∷ ς ∷ []) "Titus.1.4"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "Titus.1.4"
∷ word (Τ ∷ ο ∷ ύ ∷ τ ∷ ο ∷ υ ∷ []) "Titus.1.5"
∷ word (χ ∷ ά ∷ ρ ∷ ι ∷ ν ∷ []) "Titus.1.5"
∷ word (ἀ ∷ π ∷ έ ∷ ∙λ ∷ ι ∷ π ∷ ό ∷ ν ∷ []) "Titus.1.5"
∷ word (σ ∷ ε ∷ []) "Titus.1.5"
∷ word (ἐ ∷ ν ∷ []) "Titus.1.5"
∷ word (Κ ∷ ρ ∷ ή ∷ τ ∷ ῃ ∷ []) "Titus.1.5"
∷ word (ἵ ∷ ν ∷ α ∷ []) "Titus.1.5"
∷ word (τ ∷ ὰ ∷ []) "Titus.1.5"
∷ word (∙λ ∷ ε ∷ ί ∷ π ∷ ο ∷ ν ∷ τ ∷ α ∷ []) "Titus.1.5"
∷ word (ἐ ∷ π ∷ ι ∷ δ ∷ ι ∷ ο ∷ ρ ∷ θ ∷ ώ ∷ σ ∷ ῃ ∷ []) "Titus.1.5"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.1.5"
∷ word (κ ∷ α ∷ τ ∷ α ∷ σ ∷ τ ∷ ή ∷ σ ∷ ῃ ∷ ς ∷ []) "Titus.1.5"
∷ word (κ ∷ α ∷ τ ∷ ὰ ∷ []) "Titus.1.5"
∷ word (π ∷ ό ∷ ∙λ ∷ ι ∷ ν ∷ []) "Titus.1.5"
∷ word (π ∷ ρ ∷ ε ∷ σ ∷ β ∷ υ ∷ τ ∷ έ ∷ ρ ∷ ο ∷ υ ∷ ς ∷ []) "Titus.1.5"
∷ word (ὡ ∷ ς ∷ []) "Titus.1.5"
∷ word (ἐ ∷ γ ∷ ώ ∷ []) "Titus.1.5"
∷ word (σ ∷ ο ∷ ι ∷ []) "Titus.1.5"
∷ word (δ ∷ ι ∷ ε ∷ τ ∷ α ∷ ξ ∷ ά ∷ μ ∷ η ∷ ν ∷ []) "Titus.1.5"
∷ word (ε ∷ ἴ ∷ []) "Titus.1.6"
∷ word (τ ∷ ί ∷ ς ∷ []) "Titus.1.6"
∷ word (ἐ ∷ σ ∷ τ ∷ ι ∷ ν ∷ []) "Titus.1.6"
∷ word (ἀ ∷ ν ∷ έ ∷ γ ∷ κ ∷ ∙λ ∷ η ∷ τ ∷ ο ∷ ς ∷ []) "Titus.1.6"
∷ word (μ ∷ ι ∷ ᾶ ∷ ς ∷ []) "Titus.1.6"
∷ word (γ ∷ υ ∷ ν ∷ α ∷ ι ∷ κ ∷ ὸ ∷ ς ∷ []) "Titus.1.6"
∷ word (ἀ ∷ ν ∷ ή ∷ ρ ∷ []) "Titus.1.6"
∷ word (τ ∷ έ ∷ κ ∷ ν ∷ α ∷ []) "Titus.1.6"
∷ word (ἔ ∷ χ ∷ ω ∷ ν ∷ []) "Titus.1.6"
∷ word (π ∷ ι ∷ σ ∷ τ ∷ ά ∷ []) "Titus.1.6"
∷ word (μ ∷ ὴ ∷ []) "Titus.1.6"
∷ word (ἐ ∷ ν ∷ []) "Titus.1.6"
∷ word (κ ∷ α ∷ τ ∷ η ∷ γ ∷ ο ∷ ρ ∷ ί ∷ ᾳ ∷ []) "Titus.1.6"
∷ word (ἀ ∷ σ ∷ ω ∷ τ ∷ ί ∷ α ∷ ς ∷ []) "Titus.1.6"
∷ word (ἢ ∷ []) "Titus.1.6"
∷ word (ἀ ∷ ν ∷ υ ∷ π ∷ ό ∷ τ ∷ α ∷ κ ∷ τ ∷ α ∷ []) "Titus.1.6"
∷ word (δ ∷ ε ∷ ῖ ∷ []) "Titus.1.7"
∷ word (γ ∷ ὰ ∷ ρ ∷ []) "Titus.1.7"
∷ word (τ ∷ ὸ ∷ ν ∷ []) "Titus.1.7"
∷ word (ἐ ∷ π ∷ ί ∷ σ ∷ κ ∷ ο ∷ π ∷ ο ∷ ν ∷ []) "Titus.1.7"
∷ word (ἀ ∷ ν ∷ έ ∷ γ ∷ κ ∷ ∙λ ∷ η ∷ τ ∷ ο ∷ ν ∷ []) "Titus.1.7"
∷ word (ε ∷ ἶ ∷ ν ∷ α ∷ ι ∷ []) "Titus.1.7"
∷ word (ὡ ∷ ς ∷ []) "Titus.1.7"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "Titus.1.7"
∷ word (ο ∷ ἰ ∷ κ ∷ ο ∷ ν ∷ ό ∷ μ ∷ ο ∷ ν ∷ []) "Titus.1.7"
∷ word (μ ∷ ὴ ∷ []) "Titus.1.7"
∷ word (α ∷ ὐ ∷ θ ∷ ά ∷ δ ∷ η ∷ []) "Titus.1.7"
∷ word (μ ∷ ὴ ∷ []) "Titus.1.7"
∷ word (ὀ ∷ ρ ∷ γ ∷ ί ∷ ∙λ ∷ ο ∷ ν ∷ []) "Titus.1.7"
∷ word (μ ∷ ὴ ∷ []) "Titus.1.7"
∷ word (π ∷ ά ∷ ρ ∷ ο ∷ ι ∷ ν ∷ ο ∷ ν ∷ []) "Titus.1.7"
∷ word (μ ∷ ὴ ∷ []) "Titus.1.7"
∷ word (π ∷ ∙λ ∷ ή ∷ κ ∷ τ ∷ η ∷ ν ∷ []) "Titus.1.7"
∷ word (μ ∷ ὴ ∷ []) "Titus.1.7"
∷ word (α ∷ ἰ ∷ σ ∷ χ ∷ ρ ∷ ο ∷ κ ∷ ε ∷ ρ ∷ δ ∷ ῆ ∷ []) "Titus.1.7"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "Titus.1.8"
∷ word (φ ∷ ι ∷ ∙λ ∷ ό ∷ ξ ∷ ε ∷ ν ∷ ο ∷ ν ∷ []) "Titus.1.8"
∷ word (φ ∷ ι ∷ ∙λ ∷ ά ∷ γ ∷ α ∷ θ ∷ ο ∷ ν ∷ []) "Titus.1.8"
∷ word (σ ∷ ώ ∷ φ ∷ ρ ∷ ο ∷ ν ∷ α ∷ []) "Titus.1.8"
∷ word (δ ∷ ί ∷ κ ∷ α ∷ ι ∷ ο ∷ ν ∷ []) "Titus.1.8"
∷ word (ὅ ∷ σ ∷ ι ∷ ο ∷ ν ∷ []) "Titus.1.8"
∷ word (ἐ ∷ γ ∷ κ ∷ ρ ∷ α ∷ τ ∷ ῆ ∷ []) "Titus.1.8"
∷ word (ἀ ∷ ν ∷ τ ∷ ε ∷ χ ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ν ∷ []) "Titus.1.9"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "Titus.1.9"
∷ word (κ ∷ α ∷ τ ∷ ὰ ∷ []) "Titus.1.9"
∷ word (τ ∷ ὴ ∷ ν ∷ []) "Titus.1.9"
∷ word (δ ∷ ι ∷ δ ∷ α ∷ χ ∷ ὴ ∷ ν ∷ []) "Titus.1.9"
∷ word (π ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "Titus.1.9"
∷ word (∙λ ∷ ό ∷ γ ∷ ο ∷ υ ∷ []) "Titus.1.9"
∷ word (ἵ ∷ ν ∷ α ∷ []) "Titus.1.9"
∷ word (δ ∷ υ ∷ ν ∷ α ∷ τ ∷ ὸ ∷ ς ∷ []) "Titus.1.9"
∷ word (ᾖ ∷ []) "Titus.1.9"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.1.9"
∷ word (π ∷ α ∷ ρ ∷ α ∷ κ ∷ α ∷ ∙λ ∷ ε ∷ ῖ ∷ ν ∷ []) "Titus.1.9"
∷ word (ἐ ∷ ν ∷ []) "Titus.1.9"
∷ word (τ ∷ ῇ ∷ []) "Titus.1.9"
∷ word (δ ∷ ι ∷ δ ∷ α ∷ σ ∷ κ ∷ α ∷ ∙λ ∷ ί ∷ ᾳ ∷ []) "Titus.1.9"
∷ word (τ ∷ ῇ ∷ []) "Titus.1.9"
∷ word (ὑ ∷ γ ∷ ι ∷ α ∷ ι ∷ ν ∷ ο ∷ ύ ∷ σ ∷ ῃ ∷ []) "Titus.1.9"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.1.9"
∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "Titus.1.9"
∷ word (ἀ ∷ ν ∷ τ ∷ ι ∷ ∙λ ∷ έ ∷ γ ∷ ο ∷ ν ∷ τ ∷ α ∷ ς ∷ []) "Titus.1.9"
∷ word (ἐ ∷ ∙λ ∷ έ ∷ γ ∷ χ ∷ ε ∷ ι ∷ ν ∷ []) "Titus.1.9"
∷ word (Ε ∷ ἰ ∷ σ ∷ ὶ ∷ ν ∷ []) "Titus.1.10"
∷ word (γ ∷ ὰ ∷ ρ ∷ []) "Titus.1.10"
∷ word (π ∷ ο ∷ ∙λ ∷ ∙λ ∷ ο ∷ ὶ ∷ []) "Titus.1.10"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.1.10"
∷ word (ἀ ∷ ν ∷ υ ∷ π ∷ ό ∷ τ ∷ α ∷ κ ∷ τ ∷ ο ∷ ι ∷ []) "Titus.1.10"
∷ word (μ ∷ α ∷ τ ∷ α ∷ ι ∷ ο ∷ ∙λ ∷ ό ∷ γ ∷ ο ∷ ι ∷ []) "Titus.1.10"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.1.10"
∷ word (φ ∷ ρ ∷ ε ∷ ν ∷ α ∷ π ∷ ά ∷ τ ∷ α ∷ ι ∷ []) "Titus.1.10"
∷ word (μ ∷ ά ∷ ∙λ ∷ ι ∷ σ ∷ τ ∷ α ∷ []) "Titus.1.10"
∷ word (ο ∷ ἱ ∷ []) "Titus.1.10"
∷ word (ἐ ∷ κ ∷ []) "Titus.1.10"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "Titus.1.10"
∷ word (π ∷ ε ∷ ρ ∷ ι ∷ τ ∷ ο ∷ μ ∷ ῆ ∷ ς ∷ []) "Titus.1.10"
∷ word (ο ∷ ὓ ∷ ς ∷ []) "Titus.1.11"
∷ word (δ ∷ ε ∷ ῖ ∷ []) "Titus.1.11"
∷ word (ἐ ∷ π ∷ ι ∷ σ ∷ τ ∷ ο ∷ μ ∷ ί ∷ ζ ∷ ε ∷ ι ∷ ν ∷ []) "Titus.1.11"
∷ word (ο ∷ ἵ ∷ τ ∷ ι ∷ ν ∷ ε ∷ ς ∷ []) "Titus.1.11"
∷ word (ὅ ∷ ∙λ ∷ ο ∷ υ ∷ ς ∷ []) "Titus.1.11"
∷ word (ο ∷ ἴ ∷ κ ∷ ο ∷ υ ∷ ς ∷ []) "Titus.1.11"
∷ word (ἀ ∷ ν ∷ α ∷ τ ∷ ρ ∷ έ ∷ π ∷ ο ∷ υ ∷ σ ∷ ι ∷ ν ∷ []) "Titus.1.11"
∷ word (δ ∷ ι ∷ δ ∷ ά ∷ σ ∷ κ ∷ ο ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "Titus.1.11"
∷ word (ἃ ∷ []) "Titus.1.11"
∷ word (μ ∷ ὴ ∷ []) "Titus.1.11"
∷ word (δ ∷ ε ∷ ῖ ∷ []) "Titus.1.11"
∷ word (α ∷ ἰ ∷ σ ∷ χ ∷ ρ ∷ ο ∷ ῦ ∷ []) "Titus.1.11"
∷ word (κ ∷ έ ∷ ρ ∷ δ ∷ ο ∷ υ ∷ ς ∷ []) "Titus.1.11"
∷ word (χ ∷ ά ∷ ρ ∷ ι ∷ ν ∷ []) "Titus.1.11"
∷ word (ε ∷ ἶ ∷ π ∷ έ ∷ ν ∷ []) "Titus.1.12"
∷ word (τ ∷ ι ∷ ς ∷ []) "Titus.1.12"
∷ word (ἐ ∷ ξ ∷ []) "Titus.1.12"
∷ word (α ∷ ὐ ∷ τ ∷ ῶ ∷ ν ∷ []) "Titus.1.12"
∷ word (ἴ ∷ δ ∷ ι ∷ ο ∷ ς ∷ []) "Titus.1.12"
∷ word (α ∷ ὐ ∷ τ ∷ ῶ ∷ ν ∷ []) "Titus.1.12"
∷ word (π ∷ ρ ∷ ο ∷ φ ∷ ή ∷ τ ∷ η ∷ ς ∷ []) "Titus.1.12"
∷ word (Κ ∷ ρ ∷ ῆ ∷ τ ∷ ε ∷ ς ∷ []) "Titus.1.12"
∷ word (ἀ ∷ ε ∷ ὶ ∷ []) "Titus.1.12"
∷ word (ψ ∷ ε ∷ ῦ ∷ σ ∷ τ ∷ α ∷ ι ∷ []) "Titus.1.12"
∷ word (κ ∷ α ∷ κ ∷ ὰ ∷ []) "Titus.1.12"
∷ word (θ ∷ η ∷ ρ ∷ ί ∷ α ∷ []) "Titus.1.12"
∷ word (γ ∷ α ∷ σ ∷ τ ∷ έ ∷ ρ ∷ ε ∷ ς ∷ []) "Titus.1.12"
∷ word (ἀ ∷ ρ ∷ γ ∷ α ∷ ί ∷ []) "Titus.1.12"
∷ word (ἡ ∷ []) "Titus.1.13"
∷ word (μ ∷ α ∷ ρ ∷ τ ∷ υ ∷ ρ ∷ ί ∷ α ∷ []) "Titus.1.13"
∷ word (α ∷ ὕ ∷ τ ∷ η ∷ []) "Titus.1.13"
∷ word (ἐ ∷ σ ∷ τ ∷ ὶ ∷ ν ∷ []) "Titus.1.13"
∷ word (ἀ ∷ ∙λ ∷ η ∷ θ ∷ ή ∷ ς ∷ []) "Titus.1.13"
∷ word (δ ∷ ι ∷ []) "Titus.1.13"
∷ word (ἣ ∷ ν ∷ []) "Titus.1.13"
∷ word (α ∷ ἰ ∷ τ ∷ ί ∷ α ∷ ν ∷ []) "Titus.1.13"
∷ word (ἔ ∷ ∙λ ∷ ε ∷ γ ∷ χ ∷ ε ∷ []) "Titus.1.13"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ὺ ∷ ς ∷ []) "Titus.1.13"
∷ word (ἀ ∷ π ∷ ο ∷ τ ∷ ό ∷ μ ∷ ω ∷ ς ∷ []) "Titus.1.13"
∷ word (ἵ ∷ ν ∷ α ∷ []) "Titus.1.13"
∷ word (ὑ ∷ γ ∷ ι ∷ α ∷ ί ∷ ν ∷ ω ∷ σ ∷ ι ∷ ν ∷ []) "Titus.1.13"
∷ word (ἐ ∷ ν ∷ []) "Titus.1.13"
∷ word (τ ∷ ῇ ∷ []) "Titus.1.13"
∷ word (π ∷ ί ∷ σ ∷ τ ∷ ε ∷ ι ∷ []) "Titus.1.13"
∷ word (μ ∷ ὴ ∷ []) "Titus.1.14"
∷ word (π ∷ ρ ∷ ο ∷ σ ∷ έ ∷ χ ∷ ο ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "Titus.1.14"
∷ word (Ἰ ∷ ο ∷ υ ∷ δ ∷ α ∷ ϊ ∷ κ ∷ ο ∷ ῖ ∷ ς ∷ []) "Titus.1.14"
∷ word (μ ∷ ύ ∷ θ ∷ ο ∷ ι ∷ ς ∷ []) "Titus.1.14"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.1.14"
∷ word (ἐ ∷ ν ∷ τ ∷ ο ∷ ∙λ ∷ α ∷ ῖ ∷ ς ∷ []) "Titus.1.14"
∷ word (ἀ ∷ ν ∷ θ ∷ ρ ∷ ώ ∷ π ∷ ω ∷ ν ∷ []) "Titus.1.14"
∷ word (ἀ ∷ π ∷ ο ∷ σ ∷ τ ∷ ρ ∷ ε ∷ φ ∷ ο ∷ μ ∷ έ ∷ ν ∷ ω ∷ ν ∷ []) "Titus.1.14"
∷ word (τ ∷ ὴ ∷ ν ∷ []) "Titus.1.14"
∷ word (ἀ ∷ ∙λ ∷ ή ∷ θ ∷ ε ∷ ι ∷ α ∷ ν ∷ []) "Titus.1.14"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ α ∷ []) "Titus.1.15"
∷ word (κ ∷ α ∷ θ ∷ α ∷ ρ ∷ ὰ ∷ []) "Titus.1.15"
∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "Titus.1.15"
∷ word (κ ∷ α ∷ θ ∷ α ∷ ρ ∷ ο ∷ ῖ ∷ ς ∷ []) "Titus.1.15"
∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "Titus.1.15"
∷ word (δ ∷ ὲ ∷ []) "Titus.1.15"
∷ word (μ ∷ ε ∷ μ ∷ ι ∷ α ∷ μ ∷ μ ∷ έ ∷ ν ∷ ο ∷ ι ∷ ς ∷ []) "Titus.1.15"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.1.15"
∷ word (ἀ ∷ π ∷ ί ∷ σ ∷ τ ∷ ο ∷ ι ∷ ς ∷ []) "Titus.1.15"
∷ word (ο ∷ ὐ ∷ δ ∷ ὲ ∷ ν ∷ []) "Titus.1.15"
∷ word (κ ∷ α ∷ θ ∷ α ∷ ρ ∷ ό ∷ ν ∷ []) "Titus.1.15"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "Titus.1.15"
∷ word (μ ∷ ε ∷ μ ∷ ί ∷ α ∷ ν ∷ τ ∷ α ∷ ι ∷ []) "Titus.1.15"
∷ word (α ∷ ὐ ∷ τ ∷ ῶ ∷ ν ∷ []) "Titus.1.15"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.1.15"
∷ word (ὁ ∷ []) "Titus.1.15"
∷ word (ν ∷ ο ∷ ῦ ∷ ς ∷ []) "Titus.1.15"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.1.15"
∷ word (ἡ ∷ []) "Titus.1.15"
∷ word (σ ∷ υ ∷ ν ∷ ε ∷ ί ∷ δ ∷ η ∷ σ ∷ ι ∷ ς ∷ []) "Titus.1.15"
∷ word (θ ∷ ε ∷ ὸ ∷ ν ∷ []) "Titus.1.16"
∷ word (ὁ ∷ μ ∷ ο ∷ ∙λ ∷ ο ∷ γ ∷ ο ∷ ῦ ∷ σ ∷ ι ∷ ν ∷ []) "Titus.1.16"
∷ word (ε ∷ ἰ ∷ δ ∷ έ ∷ ν ∷ α ∷ ι ∷ []) "Titus.1.16"
∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "Titus.1.16"
∷ word (δ ∷ ὲ ∷ []) "Titus.1.16"
∷ word (ἔ ∷ ρ ∷ γ ∷ ο ∷ ι ∷ ς ∷ []) "Titus.1.16"
∷ word (ἀ ∷ ρ ∷ ν ∷ ο ∷ ῦ ∷ ν ∷ τ ∷ α ∷ ι ∷ []) "Titus.1.16"
∷ word (β ∷ δ ∷ ε ∷ ∙λ ∷ υ ∷ κ ∷ τ ∷ ο ∷ ὶ ∷ []) "Titus.1.16"
∷ word (ὄ ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "Titus.1.16"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.1.16"
∷ word (ἀ ∷ π ∷ ε ∷ ι ∷ θ ∷ ε ∷ ῖ ∷ ς ∷ []) "Titus.1.16"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.1.16"
∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "Titus.1.16"
∷ word (π ∷ ᾶ ∷ ν ∷ []) "Titus.1.16"
∷ word (ἔ ∷ ρ ∷ γ ∷ ο ∷ ν ∷ []) "Titus.1.16"
∷ word (ἀ ∷ γ ∷ α ∷ θ ∷ ὸ ∷ ν ∷ []) "Titus.1.16"
∷ word (ἀ ∷ δ ∷ ό ∷ κ ∷ ι ∷ μ ∷ ο ∷ ι ∷ []) "Titus.1.16"
∷ word (Σ ∷ ὺ ∷ []) "Titus.2.1"
∷ word (δ ∷ ὲ ∷ []) "Titus.2.1"
∷ word (∙λ ∷ ά ∷ ∙λ ∷ ε ∷ ι ∷ []) "Titus.2.1"
∷ word (ἃ ∷ []) "Titus.2.1"
∷ word (π ∷ ρ ∷ έ ∷ π ∷ ε ∷ ι ∷ []) "Titus.2.1"
∷ word (τ ∷ ῇ ∷ []) "Titus.2.1"
∷ word (ὑ ∷ γ ∷ ι ∷ α ∷ ι ∷ ν ∷ ο ∷ ύ ∷ σ ∷ ῃ ∷ []) "Titus.2.1"
∷ word (δ ∷ ι ∷ δ ∷ α ∷ σ ∷ κ ∷ α ∷ ∙λ ∷ ί ∷ ᾳ ∷ []) "Titus.2.1"
∷ word (π ∷ ρ ∷ ε ∷ σ ∷ β ∷ ύ ∷ τ ∷ α ∷ ς ∷ []) "Titus.2.2"
∷ word (ν ∷ η ∷ φ ∷ α ∷ ∙λ ∷ ί ∷ ο ∷ υ ∷ ς ∷ []) "Titus.2.2"
∷ word (ε ∷ ἶ ∷ ν ∷ α ∷ ι ∷ []) "Titus.2.2"
∷ word (σ ∷ ε ∷ μ ∷ ν ∷ ο ∷ ύ ∷ ς ∷ []) "Titus.2.2"
∷ word (σ ∷ ώ ∷ φ ∷ ρ ∷ ο ∷ ν ∷ α ∷ ς ∷ []) "Titus.2.2"
∷ word (ὑ ∷ γ ∷ ι ∷ α ∷ ί ∷ ν ∷ ο ∷ ν ∷ τ ∷ α ∷ ς ∷ []) "Titus.2.2"
∷ word (τ ∷ ῇ ∷ []) "Titus.2.2"
∷ word (π ∷ ί ∷ σ ∷ τ ∷ ε ∷ ι ∷ []) "Titus.2.2"
∷ word (τ ∷ ῇ ∷ []) "Titus.2.2"
∷ word (ἀ ∷ γ ∷ ά ∷ π ∷ ῃ ∷ []) "Titus.2.2"
∷ word (τ ∷ ῇ ∷ []) "Titus.2.2"
∷ word (ὑ ∷ π ∷ ο ∷ μ ∷ ο ∷ ν ∷ ῇ ∷ []) "Titus.2.2"
∷ word (Π ∷ ρ ∷ ε ∷ σ ∷ β ∷ ύ ∷ τ ∷ ι ∷ δ ∷ α ∷ ς ∷ []) "Titus.2.3"
∷ word (ὡ ∷ σ ∷ α ∷ ύ ∷ τ ∷ ω ∷ ς ∷ []) "Titus.2.3"
∷ word (ἐ ∷ ν ∷ []) "Titus.2.3"
∷ word (κ ∷ α ∷ τ ∷ α ∷ σ ∷ τ ∷ ή ∷ μ ∷ α ∷ τ ∷ ι ∷ []) "Titus.2.3"
∷ word (ἱ ∷ ε ∷ ρ ∷ ο ∷ π ∷ ρ ∷ ε ∷ π ∷ ε ∷ ῖ ∷ ς ∷ []) "Titus.2.3"
∷ word (μ ∷ ὴ ∷ []) "Titus.2.3"
∷ word (δ ∷ ι ∷ α ∷ β ∷ ό ∷ ∙λ ∷ ο ∷ υ ∷ ς ∷ []) "Titus.2.3"
∷ word (μ ∷ η ∷ δ ∷ ὲ ∷ []) "Titus.2.3"
∷ word (ο ∷ ἴ ∷ ν ∷ ῳ ∷ []) "Titus.2.3"
∷ word (π ∷ ο ∷ ∙λ ∷ ∙λ ∷ ῷ ∷ []) "Titus.2.3"
∷ word (δ ∷ ε ∷ δ ∷ ο ∷ υ ∷ ∙λ ∷ ω ∷ μ ∷ έ ∷ ν ∷ α ∷ ς ∷ []) "Titus.2.3"
∷ word (κ ∷ α ∷ ∙λ ∷ ο ∷ δ ∷ ι ∷ δ ∷ α ∷ σ ∷ κ ∷ ά ∷ ∙λ ∷ ο ∷ υ ∷ ς ∷ []) "Titus.2.3"
∷ word (ἵ ∷ ν ∷ α ∷ []) "Titus.2.4"
∷ word (σ ∷ ω ∷ φ ∷ ρ ∷ ο ∷ ν ∷ ί ∷ ζ ∷ ω ∷ σ ∷ ι ∷ []) "Titus.2.4"
∷ word (τ ∷ ὰ ∷ ς ∷ []) "Titus.2.4"
∷ word (ν ∷ έ ∷ α ∷ ς ∷ []) "Titus.2.4"
∷ word (φ ∷ ι ∷ ∙λ ∷ ά ∷ ν ∷ δ ∷ ρ ∷ ο ∷ υ ∷ ς ∷ []) "Titus.2.4"
∷ word (ε ∷ ἶ ∷ ν ∷ α ∷ ι ∷ []) "Titus.2.4"
∷ word (φ ∷ ι ∷ ∙λ ∷ ο ∷ τ ∷ έ ∷ κ ∷ ν ∷ ο ∷ υ ∷ ς ∷ []) "Titus.2.4"
∷ word (σ ∷ ώ ∷ φ ∷ ρ ∷ ο ∷ ν ∷ α ∷ ς ∷ []) "Titus.2.5"
∷ word (ἁ ∷ γ ∷ ν ∷ ά ∷ ς ∷ []) "Titus.2.5"
∷ word (ο ∷ ἰ ∷ κ ∷ ο ∷ υ ∷ ρ ∷ γ ∷ ο ∷ ύ ∷ ς ∷ []) "Titus.2.5"
∷ word (ἀ ∷ γ ∷ α ∷ θ ∷ ά ∷ ς ∷ []) "Titus.2.5"
∷ word (ὑ ∷ π ∷ ο ∷ τ ∷ α ∷ σ ∷ σ ∷ ο ∷ μ ∷ έ ∷ ν ∷ α ∷ ς ∷ []) "Titus.2.5"
∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "Titus.2.5"
∷ word (ἰ ∷ δ ∷ ί ∷ ο ∷ ι ∷ ς ∷ []) "Titus.2.5"
∷ word (ἀ ∷ ν ∷ δ ∷ ρ ∷ ά ∷ σ ∷ ι ∷ ν ∷ []) "Titus.2.5"
∷ word (ἵ ∷ ν ∷ α ∷ []) "Titus.2.5"
∷ word (μ ∷ ὴ ∷ []) "Titus.2.5"
∷ word (ὁ ∷ []) "Titus.2.5"
∷ word (∙λ ∷ ό ∷ γ ∷ ο ∷ ς ∷ []) "Titus.2.5"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "Titus.2.5"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "Titus.2.5"
∷ word (β ∷ ∙λ ∷ α ∷ σ ∷ φ ∷ η ∷ μ ∷ ῆ ∷ τ ∷ α ∷ ι ∷ []) "Titus.2.5"
∷ word (Τ ∷ ο ∷ ὺ ∷ ς ∷ []) "Titus.2.6"
∷ word (ν ∷ ε ∷ ω ∷ τ ∷ έ ∷ ρ ∷ ο ∷ υ ∷ ς ∷ []) "Titus.2.6"
∷ word (ὡ ∷ σ ∷ α ∷ ύ ∷ τ ∷ ω ∷ ς ∷ []) "Titus.2.6"
∷ word (π ∷ α ∷ ρ ∷ α ∷ κ ∷ ά ∷ ∙λ ∷ ε ∷ ι ∷ []) "Titus.2.6"
∷ word (σ ∷ ω ∷ φ ∷ ρ ∷ ο ∷ ν ∷ ε ∷ ῖ ∷ ν ∷ []) "Titus.2.6"
∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "Titus.2.7"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ α ∷ []) "Titus.2.7"
∷ word (σ ∷ ε ∷ α ∷ υ ∷ τ ∷ ὸ ∷ ν ∷ []) "Titus.2.7"
∷ word (π ∷ α ∷ ρ ∷ ε ∷ χ ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ς ∷ []) "Titus.2.7"
∷ word (τ ∷ ύ ∷ π ∷ ο ∷ ν ∷ []) "Titus.2.7"
∷ word (κ ∷ α ∷ ∙λ ∷ ῶ ∷ ν ∷ []) "Titus.2.7"
∷ word (ἔ ∷ ρ ∷ γ ∷ ω ∷ ν ∷ []) "Titus.2.7"
∷ word (ἐ ∷ ν ∷ []) "Titus.2.7"
∷ word (τ ∷ ῇ ∷ []) "Titus.2.7"
∷ word (δ ∷ ι ∷ δ ∷ α ∷ σ ∷ κ ∷ α ∷ ∙λ ∷ ί ∷ ᾳ ∷ []) "Titus.2.7"
∷ word (ἀ ∷ φ ∷ θ ∷ ο ∷ ρ ∷ ί ∷ α ∷ ν ∷ []) "Titus.2.7"
∷ word (σ ∷ ε ∷ μ ∷ ν ∷ ό ∷ τ ∷ η ∷ τ ∷ α ∷ []) "Titus.2.7"
∷ word (∙λ ∷ ό ∷ γ ∷ ο ∷ ν ∷ []) "Titus.2.8"
∷ word (ὑ ∷ γ ∷ ι ∷ ῆ ∷ []) "Titus.2.8"
∷ word (ἀ ∷ κ ∷ α ∷ τ ∷ ά ∷ γ ∷ ν ∷ ω ∷ σ ∷ τ ∷ ο ∷ ν ∷ []) "Titus.2.8"
∷ word (ἵ ∷ ν ∷ α ∷ []) "Titus.2.8"
∷ word (ὁ ∷ []) "Titus.2.8"
∷ word (ἐ ∷ ξ ∷ []) "Titus.2.8"
∷ word (ἐ ∷ ν ∷ α ∷ ν ∷ τ ∷ ί ∷ α ∷ ς ∷ []) "Titus.2.8"
∷ word (ἐ ∷ ν ∷ τ ∷ ρ ∷ α ∷ π ∷ ῇ ∷ []) "Titus.2.8"
∷ word (μ ∷ η ∷ δ ∷ ὲ ∷ ν ∷ []) "Titus.2.8"
∷ word (ἔ ∷ χ ∷ ω ∷ ν ∷ []) "Titus.2.8"
∷ word (∙λ ∷ έ ∷ γ ∷ ε ∷ ι ∷ ν ∷ []) "Titus.2.8"
∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "Titus.2.8"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "Titus.2.8"
∷ word (φ ∷ α ∷ ῦ ∷ ∙λ ∷ ο ∷ ν ∷ []) "Titus.2.8"
∷ word (Δ ∷ ο ∷ ύ ∷ ∙λ ∷ ο ∷ υ ∷ ς ∷ []) "Titus.2.9"
∷ word (ἰ ∷ δ ∷ ί ∷ ο ∷ ι ∷ ς ∷ []) "Titus.2.9"
∷ word (δ ∷ ε ∷ σ ∷ π ∷ ό ∷ τ ∷ α ∷ ι ∷ ς ∷ []) "Titus.2.9"
∷ word (ὑ ∷ π ∷ ο ∷ τ ∷ ά ∷ σ ∷ σ ∷ ε ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "Titus.2.9"
∷ word (ἐ ∷ ν ∷ []) "Titus.2.9"
∷ word (π ∷ ᾶ ∷ σ ∷ ι ∷ ν ∷ []) "Titus.2.9"
∷ word (ε ∷ ὐ ∷ α ∷ ρ ∷ έ ∷ σ ∷ τ ∷ ο ∷ υ ∷ ς ∷ []) "Titus.2.9"
∷ word (ε ∷ ἶ ∷ ν ∷ α ∷ ι ∷ []) "Titus.2.9"
∷ word (μ ∷ ὴ ∷ []) "Titus.2.9"
∷ word (ἀ ∷ ν ∷ τ ∷ ι ∷ ∙λ ∷ έ ∷ γ ∷ ο ∷ ν ∷ τ ∷ α ∷ ς ∷ []) "Titus.2.9"
∷ word (μ ∷ ὴ ∷ []) "Titus.2.10"
∷ word (ν ∷ ο ∷ σ ∷ φ ∷ ι ∷ ζ ∷ ο ∷ μ ∷ έ ∷ ν ∷ ο ∷ υ ∷ ς ∷ []) "Titus.2.10"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "Titus.2.10"
∷ word (π ∷ ᾶ ∷ σ ∷ α ∷ ν ∷ []) "Titus.2.10"
∷ word (π ∷ ί ∷ σ ∷ τ ∷ ι ∷ ν ∷ []) "Titus.2.10"
∷ word (ἐ ∷ ν ∷ δ ∷ ε ∷ ι ∷ κ ∷ ν ∷ υ ∷ μ ∷ έ ∷ ν ∷ ο ∷ υ ∷ ς ∷ []) "Titus.2.10"
∷ word (ἀ ∷ γ ∷ α ∷ θ ∷ ή ∷ ν ∷ []) "Titus.2.10"
∷ word (ἵ ∷ ν ∷ α ∷ []) "Titus.2.10"
∷ word (τ ∷ ὴ ∷ ν ∷ []) "Titus.2.10"
∷ word (δ ∷ ι ∷ δ ∷ α ∷ σ ∷ κ ∷ α ∷ ∙λ ∷ ί ∷ α ∷ ν ∷ []) "Titus.2.10"
∷ word (τ ∷ ὴ ∷ ν ∷ []) "Titus.2.10"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "Titus.2.10"
∷ word (σ ∷ ω ∷ τ ∷ ῆ ∷ ρ ∷ ο ∷ ς ∷ []) "Titus.2.10"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "Titus.2.10"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "Titus.2.10"
∷ word (κ ∷ ο ∷ σ ∷ μ ∷ ῶ ∷ σ ∷ ι ∷ ν ∷ []) "Titus.2.10"
∷ word (ἐ ∷ ν ∷ []) "Titus.2.10"
∷ word (π ∷ ᾶ ∷ σ ∷ ι ∷ ν ∷ []) "Titus.2.10"
∷ word (Ἐ ∷ π ∷ ε ∷ φ ∷ ά ∷ ν ∷ η ∷ []) "Titus.2.11"
∷ word (γ ∷ ὰ ∷ ρ ∷ []) "Titus.2.11"
∷ word (ἡ ∷ []) "Titus.2.11"
∷ word (χ ∷ ά ∷ ρ ∷ ι ∷ ς ∷ []) "Titus.2.11"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "Titus.2.11"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "Titus.2.11"
∷ word (σ ∷ ω ∷ τ ∷ ή ∷ ρ ∷ ι ∷ ο ∷ ς ∷ []) "Titus.2.11"
∷ word (π ∷ ᾶ ∷ σ ∷ ι ∷ ν ∷ []) "Titus.2.11"
∷ word (ἀ ∷ ν ∷ θ ∷ ρ ∷ ώ ∷ π ∷ ο ∷ ι ∷ ς ∷ []) "Titus.2.11"
∷ word (π ∷ α ∷ ι ∷ δ ∷ ε ∷ ύ ∷ ο ∷ υ ∷ σ ∷ α ∷ []) "Titus.2.12"
∷ word (ἡ ∷ μ ∷ ᾶ ∷ ς ∷ []) "Titus.2.12"
∷ word (ἵ ∷ ν ∷ α ∷ []) "Titus.2.12"
∷ word (ἀ ∷ ρ ∷ ν ∷ η ∷ σ ∷ ά ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "Titus.2.12"
∷ word (τ ∷ ὴ ∷ ν ∷ []) "Titus.2.12"
∷ word (ἀ ∷ σ ∷ έ ∷ β ∷ ε ∷ ι ∷ α ∷ ν ∷ []) "Titus.2.12"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.2.12"
∷ word (τ ∷ ὰ ∷ ς ∷ []) "Titus.2.12"
∷ word (κ ∷ ο ∷ σ ∷ μ ∷ ι ∷ κ ∷ ὰ ∷ ς ∷ []) "Titus.2.12"
∷ word (ἐ ∷ π ∷ ι ∷ θ ∷ υ ∷ μ ∷ ί ∷ α ∷ ς ∷ []) "Titus.2.12"
∷ word (σ ∷ ω ∷ φ ∷ ρ ∷ ό ∷ ν ∷ ω ∷ ς ∷ []) "Titus.2.12"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.2.12"
∷ word (δ ∷ ι ∷ κ ∷ α ∷ ί ∷ ω ∷ ς ∷ []) "Titus.2.12"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.2.12"
∷ word (ε ∷ ὐ ∷ σ ∷ ε ∷ β ∷ ῶ ∷ ς ∷ []) "Titus.2.12"
∷ word (ζ ∷ ή ∷ σ ∷ ω ∷ μ ∷ ε ∷ ν ∷ []) "Titus.2.12"
∷ word (ἐ ∷ ν ∷ []) "Titus.2.12"
∷ word (τ ∷ ῷ ∷ []) "Titus.2.12"
∷ word (ν ∷ ῦ ∷ ν ∷ []) "Titus.2.12"
∷ word (α ∷ ἰ ∷ ῶ ∷ ν ∷ ι ∷ []) "Titus.2.12"
∷ word (π ∷ ρ ∷ ο ∷ σ ∷ δ ∷ ε ∷ χ ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "Titus.2.13"
∷ word (τ ∷ ὴ ∷ ν ∷ []) "Titus.2.13"
∷ word (μ ∷ α ∷ κ ∷ α ∷ ρ ∷ ί ∷ α ∷ ν ∷ []) "Titus.2.13"
∷ word (ἐ ∷ ∙λ ∷ π ∷ ί ∷ δ ∷ α ∷ []) "Titus.2.13"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.2.13"
∷ word (ἐ ∷ π ∷ ι ∷ φ ∷ ά ∷ ν ∷ ε ∷ ι ∷ α ∷ ν ∷ []) "Titus.2.13"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "Titus.2.13"
∷ word (δ ∷ ό ∷ ξ ∷ η ∷ ς ∷ []) "Titus.2.13"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "Titus.2.13"
∷ word (μ ∷ ε ∷ γ ∷ ά ∷ ∙λ ∷ ο ∷ υ ∷ []) "Titus.2.13"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "Titus.2.13"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.2.13"
∷ word (σ ∷ ω ∷ τ ∷ ῆ ∷ ρ ∷ ο ∷ ς ∷ []) "Titus.2.13"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "Titus.2.13"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Titus.2.13"
∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "Titus.2.13"
∷ word (ὃ ∷ ς ∷ []) "Titus.2.14"
∷ word (ἔ ∷ δ ∷ ω ∷ κ ∷ ε ∷ ν ∷ []) "Titus.2.14"
∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ὸ ∷ ν ∷ []) "Titus.2.14"
∷ word (ὑ ∷ π ∷ ὲ ∷ ρ ∷ []) "Titus.2.14"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "Titus.2.14"
∷ word (ἵ ∷ ν ∷ α ∷ []) "Titus.2.14"
∷ word (∙λ ∷ υ ∷ τ ∷ ρ ∷ ώ ∷ σ ∷ η ∷ τ ∷ α ∷ ι ∷ []) "Titus.2.14"
∷ word (ἡ ∷ μ ∷ ᾶ ∷ ς ∷ []) "Titus.2.14"
∷ word (ἀ ∷ π ∷ ὸ ∷ []) "Titus.2.14"
∷ word (π ∷ ά ∷ σ ∷ η ∷ ς ∷ []) "Titus.2.14"
∷ word (ἀ ∷ ν ∷ ο ∷ μ ∷ ί ∷ α ∷ ς ∷ []) "Titus.2.14"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.2.14"
∷ word (κ ∷ α ∷ θ ∷ α ∷ ρ ∷ ί ∷ σ ∷ ῃ ∷ []) "Titus.2.14"
∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ῷ ∷ []) "Titus.2.14"
∷ word (∙λ ∷ α ∷ ὸ ∷ ν ∷ []) "Titus.2.14"
∷ word (π ∷ ε ∷ ρ ∷ ι ∷ ο ∷ ύ ∷ σ ∷ ι ∷ ο ∷ ν ∷ []) "Titus.2.14"
∷ word (ζ ∷ η ∷ ∙λ ∷ ω ∷ τ ∷ ὴ ∷ ν ∷ []) "Titus.2.14"
∷ word (κ ∷ α ∷ ∙λ ∷ ῶ ∷ ν ∷ []) "Titus.2.14"
∷ word (ἔ ∷ ρ ∷ γ ∷ ω ∷ ν ∷ []) "Titus.2.14"
∷ word (Τ ∷ α ∷ ῦ ∷ τ ∷ α ∷ []) "Titus.2.15"
∷ word (∙λ ∷ ά ∷ ∙λ ∷ ε ∷ ι ∷ []) "Titus.2.15"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.2.15"
∷ word (π ∷ α ∷ ρ ∷ α ∷ κ ∷ ά ∷ ∙λ ∷ ε ∷ ι ∷ []) "Titus.2.15"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.2.15"
∷ word (ἔ ∷ ∙λ ∷ ε ∷ γ ∷ χ ∷ ε ∷ []) "Titus.2.15"
∷ word (μ ∷ ε ∷ τ ∷ ὰ ∷ []) "Titus.2.15"
∷ word (π ∷ ά ∷ σ ∷ η ∷ ς ∷ []) "Titus.2.15"
∷ word (ἐ ∷ π ∷ ι ∷ τ ∷ α ∷ γ ∷ ῆ ∷ ς ∷ []) "Titus.2.15"
∷ word (μ ∷ η ∷ δ ∷ ε ∷ ί ∷ ς ∷ []) "Titus.2.15"
∷ word (σ ∷ ο ∷ υ ∷ []) "Titus.2.15"
∷ word (π ∷ ε ∷ ρ ∷ ι ∷ φ ∷ ρ ∷ ο ∷ ν ∷ ε ∷ ί ∷ τ ∷ ω ∷ []) "Titus.2.15"
∷ word (Ὑ ∷ π ∷ ο ∷ μ ∷ ί ∷ μ ∷ ν ∷ ῃ ∷ σ ∷ κ ∷ ε ∷ []) "Titus.3.1"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ὺ ∷ ς ∷ []) "Titus.3.1"
∷ word (ἀ ∷ ρ ∷ χ ∷ α ∷ ῖ ∷ ς ∷ []) "Titus.3.1"
∷ word (ἐ ∷ ξ ∷ ο ∷ υ ∷ σ ∷ ί ∷ α ∷ ι ∷ ς ∷ []) "Titus.3.1"
∷ word (ὑ ∷ π ∷ ο ∷ τ ∷ ά ∷ σ ∷ σ ∷ ε ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "Titus.3.1"
∷ word (π ∷ ε ∷ ι ∷ θ ∷ α ∷ ρ ∷ χ ∷ ε ∷ ῖ ∷ ν ∷ []) "Titus.3.1"
∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "Titus.3.1"
∷ word (π ∷ ᾶ ∷ ν ∷ []) "Titus.3.1"
∷ word (ἔ ∷ ρ ∷ γ ∷ ο ∷ ν ∷ []) "Titus.3.1"
∷ word (ἀ ∷ γ ∷ α ∷ θ ∷ ὸ ∷ ν ∷ []) "Titus.3.1"
∷ word (ἑ ∷ τ ∷ ο ∷ ί ∷ μ ∷ ο ∷ υ ∷ ς ∷ []) "Titus.3.1"
∷ word (ε ∷ ἶ ∷ ν ∷ α ∷ ι ∷ []) "Titus.3.1"
∷ word (μ ∷ η ∷ δ ∷ έ ∷ ν ∷ α ∷ []) "Titus.3.2"
∷ word (β ∷ ∙λ ∷ α ∷ σ ∷ φ ∷ η ∷ μ ∷ ε ∷ ῖ ∷ ν ∷ []) "Titus.3.2"
∷ word (ἀ ∷ μ ∷ ά ∷ χ ∷ ο ∷ υ ∷ ς ∷ []) "Titus.3.2"
∷ word (ε ∷ ἶ ∷ ν ∷ α ∷ ι ∷ []) "Titus.3.2"
∷ word (ἐ ∷ π ∷ ι ∷ ε ∷ ι ∷ κ ∷ ε ∷ ῖ ∷ ς ∷ []) "Titus.3.2"
∷ word (π ∷ ᾶ ∷ σ ∷ α ∷ ν ∷ []) "Titus.3.2"
∷ word (ἐ ∷ ν ∷ δ ∷ ε ∷ ι ∷ κ ∷ ν ∷ υ ∷ μ ∷ έ ∷ ν ∷ ο ∷ υ ∷ ς ∷ []) "Titus.3.2"
∷ word (π ∷ ρ ∷ α ∷ ΰ ∷ τ ∷ η ∷ τ ∷ α ∷ []) "Titus.3.2"
∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "Titus.3.2"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ α ∷ ς ∷ []) "Titus.3.2"
∷ word (ἀ ∷ ν ∷ θ ∷ ρ ∷ ώ ∷ π ∷ ο ∷ υ ∷ ς ∷ []) "Titus.3.2"
∷ word (ἦ ∷ μ ∷ ε ∷ ν ∷ []) "Titus.3.3"
∷ word (γ ∷ ά ∷ ρ ∷ []) "Titus.3.3"
∷ word (π ∷ ο ∷ τ ∷ ε ∷ []) "Titus.3.3"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.3.3"
∷ word (ἡ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "Titus.3.3"
∷ word (ἀ ∷ ν ∷ ό ∷ η ∷ τ ∷ ο ∷ ι ∷ []) "Titus.3.3"
∷ word (ἀ ∷ π ∷ ε ∷ ι ∷ θ ∷ ε ∷ ῖ ∷ ς ∷ []) "Titus.3.3"
∷ word (π ∷ ∙λ ∷ α ∷ ν ∷ ώ ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "Titus.3.3"
∷ word (δ ∷ ο ∷ υ ∷ ∙λ ∷ ε ∷ ύ ∷ ο ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "Titus.3.3"
∷ word (ἐ ∷ π ∷ ι ∷ θ ∷ υ ∷ μ ∷ ί ∷ α ∷ ι ∷ ς ∷ []) "Titus.3.3"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.3.3"
∷ word (ἡ ∷ δ ∷ ο ∷ ν ∷ α ∷ ῖ ∷ ς ∷ []) "Titus.3.3"
∷ word (π ∷ ο ∷ ι ∷ κ ∷ ί ∷ ∙λ ∷ α ∷ ι ∷ ς ∷ []) "Titus.3.3"
∷ word (ἐ ∷ ν ∷ []) "Titus.3.3"
∷ word (κ ∷ α ∷ κ ∷ ί ∷ ᾳ ∷ []) "Titus.3.3"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.3.3"
∷ word (φ ∷ θ ∷ ό ∷ ν ∷ ῳ ∷ []) "Titus.3.3"
∷ word (δ ∷ ι ∷ ά ∷ γ ∷ ο ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "Titus.3.3"
∷ word (σ ∷ τ ∷ υ ∷ γ ∷ η ∷ τ ∷ ο ∷ ί ∷ []) "Titus.3.3"
∷ word (μ ∷ ι ∷ σ ∷ ο ∷ ῦ ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "Titus.3.3"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ή ∷ ∙λ ∷ ο ∷ υ ∷ ς ∷ []) "Titus.3.3"
∷ word (ὅ ∷ τ ∷ ε ∷ []) "Titus.3.4"
∷ word (δ ∷ ὲ ∷ []) "Titus.3.4"
∷ word (ἡ ∷ []) "Titus.3.4"
∷ word (χ ∷ ρ ∷ η ∷ σ ∷ τ ∷ ό ∷ τ ∷ η ∷ ς ∷ []) "Titus.3.4"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.3.4"
∷ word (ἡ ∷ []) "Titus.3.4"
∷ word (φ ∷ ι ∷ ∙λ ∷ α ∷ ν ∷ θ ∷ ρ ∷ ω ∷ π ∷ ί ∷ α ∷ []) "Titus.3.4"
∷ word (ἐ ∷ π ∷ ε ∷ φ ∷ ά ∷ ν ∷ η ∷ []) "Titus.3.4"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "Titus.3.4"
∷ word (σ ∷ ω ∷ τ ∷ ῆ ∷ ρ ∷ ο ∷ ς ∷ []) "Titus.3.4"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "Titus.3.4"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "Titus.3.4"
∷ word (ο ∷ ὐ ∷ κ ∷ []) "Titus.3.5"
∷ word (ἐ ∷ ξ ∷ []) "Titus.3.5"
∷ word (ἔ ∷ ρ ∷ γ ∷ ω ∷ ν ∷ []) "Titus.3.5"
∷ word (τ ∷ ῶ ∷ ν ∷ []) "Titus.3.5"
∷ word (ἐ ∷ ν ∷ []) "Titus.3.5"
∷ word (δ ∷ ι ∷ κ ∷ α ∷ ι ∷ ο ∷ σ ∷ ύ ∷ ν ∷ ῃ ∷ []) "Titus.3.5"
∷ word (ἃ ∷ []) "Titus.3.5"
∷ word (ἐ ∷ π ∷ ο ∷ ι ∷ ή ∷ σ ∷ α ∷ μ ∷ ε ∷ ν ∷ []) "Titus.3.5"
∷ word (ἡ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "Titus.3.5"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "Titus.3.5"
∷ word (κ ∷ α ∷ τ ∷ ὰ ∷ []) "Titus.3.5"
∷ word (τ ∷ ὸ ∷ []) "Titus.3.5"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "Titus.3.5"
∷ word (ἔ ∷ ∙λ ∷ ε ∷ ο ∷ ς ∷ []) "Titus.3.5"
∷ word (ἔ ∷ σ ∷ ω ∷ σ ∷ ε ∷ ν ∷ []) "Titus.3.5"
∷ word (ἡ ∷ μ ∷ ᾶ ∷ ς ∷ []) "Titus.3.5"
∷ word (δ ∷ ι ∷ ὰ ∷ []) "Titus.3.5"
∷ word (∙λ ∷ ο ∷ υ ∷ τ ∷ ρ ∷ ο ∷ ῦ ∷ []) "Titus.3.5"
∷ word (π ∷ α ∷ ∙λ ∷ ι ∷ γ ∷ γ ∷ ε ∷ ν ∷ ε ∷ σ ∷ ί ∷ α ∷ ς ∷ []) "Titus.3.5"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.3.5"
∷ word (ἀ ∷ ν ∷ α ∷ κ ∷ α ∷ ι ∷ ν ∷ ώ ∷ σ ∷ ε ∷ ω ∷ ς ∷ []) "Titus.3.5"
∷ word (π ∷ ν ∷ ε ∷ ύ ∷ μ ∷ α ∷ τ ∷ ο ∷ ς ∷ []) "Titus.3.5"
∷ word (ἁ ∷ γ ∷ ί ∷ ο ∷ υ ∷ []) "Titus.3.5"
∷ word (ο ∷ ὗ ∷ []) "Titus.3.6"
∷ word (ἐ ∷ ξ ∷ έ ∷ χ ∷ ε ∷ ε ∷ ν ∷ []) "Titus.3.6"
∷ word (ἐ ∷ φ ∷ []) "Titus.3.6"
∷ word (ἡ ∷ μ ∷ ᾶ ∷ ς ∷ []) "Titus.3.6"
∷ word (π ∷ ∙λ ∷ ο ∷ υ ∷ σ ∷ ί ∷ ω ∷ ς ∷ []) "Titus.3.6"
∷ word (δ ∷ ι ∷ ὰ ∷ []) "Titus.3.6"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Titus.3.6"
∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "Titus.3.6"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "Titus.3.6"
∷ word (σ ∷ ω ∷ τ ∷ ῆ ∷ ρ ∷ ο ∷ ς ∷ []) "Titus.3.6"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "Titus.3.6"
∷ word (ἵ ∷ ν ∷ α ∷ []) "Titus.3.7"
∷ word (δ ∷ ι ∷ κ ∷ α ∷ ι ∷ ω ∷ θ ∷ έ ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "Titus.3.7"
∷ word (τ ∷ ῇ ∷ []) "Titus.3.7"
∷ word (ἐ ∷ κ ∷ ε ∷ ί ∷ ν ∷ ο ∷ υ ∷ []) "Titus.3.7"
∷ word (χ ∷ ά ∷ ρ ∷ ι ∷ τ ∷ ι ∷ []) "Titus.3.7"
∷ word (κ ∷ ∙λ ∷ η ∷ ρ ∷ ο ∷ ν ∷ ό ∷ μ ∷ ο ∷ ι ∷ []) "Titus.3.7"
∷ word (γ ∷ ε ∷ ν ∷ η ∷ θ ∷ ῶ ∷ μ ∷ ε ∷ ν ∷ []) "Titus.3.7"
∷ word (κ ∷ α ∷ τ ∷ []) "Titus.3.7"
∷ word (ἐ ∷ ∙λ ∷ π ∷ ί ∷ δ ∷ α ∷ []) "Titus.3.7"
∷ word (ζ ∷ ω ∷ ῆ ∷ ς ∷ []) "Titus.3.7"
∷ word (α ∷ ἰ ∷ ω ∷ ν ∷ ί ∷ ο ∷ υ ∷ []) "Titus.3.7"
∷ word (Π ∷ ι ∷ σ ∷ τ ∷ ὸ ∷ ς ∷ []) "Titus.3.8"
∷ word (ὁ ∷ []) "Titus.3.8"
∷ word (∙λ ∷ ό ∷ γ ∷ ο ∷ ς ∷ []) "Titus.3.8"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.3.8"
∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "Titus.3.8"
∷ word (τ ∷ ο ∷ ύ ∷ τ ∷ ω ∷ ν ∷ []) "Titus.3.8"
∷ word (β ∷ ο ∷ ύ ∷ ∙λ ∷ ο ∷ μ ∷ α ∷ ί ∷ []) "Titus.3.8"
∷ word (σ ∷ ε ∷ []) "Titus.3.8"
∷ word (δ ∷ ι ∷ α ∷ β ∷ ε ∷ β ∷ α ∷ ι ∷ ο ∷ ῦ ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "Titus.3.8"
∷ word (ἵ ∷ ν ∷ α ∷ []) "Titus.3.8"
∷ word (φ ∷ ρ ∷ ο ∷ ν ∷ τ ∷ ί ∷ ζ ∷ ω ∷ σ ∷ ι ∷ ν ∷ []) "Titus.3.8"
∷ word (κ ∷ α ∷ ∙λ ∷ ῶ ∷ ν ∷ []) "Titus.3.8"
∷ word (ἔ ∷ ρ ∷ γ ∷ ω ∷ ν ∷ []) "Titus.3.8"
∷ word (π ∷ ρ ∷ ο ∷ ΐ ∷ σ ∷ τ ∷ α ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "Titus.3.8"
∷ word (ο ∷ ἱ ∷ []) "Titus.3.8"
∷ word (π ∷ ε ∷ π ∷ ι ∷ σ ∷ τ ∷ ε ∷ υ ∷ κ ∷ ό ∷ τ ∷ ε ∷ ς ∷ []) "Titus.3.8"
∷ word (θ ∷ ε ∷ ῷ ∷ []) "Titus.3.8"
∷ word (τ ∷ α ∷ ῦ ∷ τ ∷ ά ∷ []) "Titus.3.8"
∷ word (ἐ ∷ σ ∷ τ ∷ ι ∷ ν ∷ []) "Titus.3.8"
∷ word (κ ∷ α ∷ ∙λ ∷ ὰ ∷ []) "Titus.3.8"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.3.8"
∷ word (ὠ ∷ φ ∷ έ ∷ ∙λ ∷ ι ∷ μ ∷ α ∷ []) "Titus.3.8"
∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "Titus.3.8"
∷ word (ἀ ∷ ν ∷ θ ∷ ρ ∷ ώ ∷ π ∷ ο ∷ ι ∷ ς ∷ []) "Titus.3.8"
∷ word (μ ∷ ω ∷ ρ ∷ ὰ ∷ ς ∷ []) "Titus.3.9"
∷ word (δ ∷ ὲ ∷ []) "Titus.3.9"
∷ word (ζ ∷ η ∷ τ ∷ ή ∷ σ ∷ ε ∷ ι ∷ ς ∷ []) "Titus.3.9"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.3.9"
∷ word (γ ∷ ε ∷ ν ∷ ε ∷ α ∷ ∙λ ∷ ο ∷ γ ∷ ί ∷ α ∷ ς ∷ []) "Titus.3.9"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.3.9"
∷ word (ἔ ∷ ρ ∷ ε ∷ ι ∷ ς ∷ []) "Titus.3.9"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.3.9"
∷ word (μ ∷ ά ∷ χ ∷ α ∷ ς ∷ []) "Titus.3.9"
∷ word (ν ∷ ο ∷ μ ∷ ι ∷ κ ∷ ὰ ∷ ς ∷ []) "Titus.3.9"
∷ word (π ∷ ε ∷ ρ ∷ ι ∷ ΐ ∷ σ ∷ τ ∷ α ∷ σ ∷ ο ∷ []) "Titus.3.9"
∷ word (ε ∷ ἰ ∷ σ ∷ ὶ ∷ ν ∷ []) "Titus.3.9"
∷ word (γ ∷ ὰ ∷ ρ ∷ []) "Titus.3.9"
∷ word (ἀ ∷ ν ∷ ω ∷ φ ∷ ε ∷ ∙λ ∷ ε ∷ ῖ ∷ ς ∷ []) "Titus.3.9"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.3.9"
∷ word (μ ∷ ά ∷ τ ∷ α ∷ ι ∷ ο ∷ ι ∷ []) "Titus.3.9"
∷ word (α ∷ ἱ ∷ ρ ∷ ε ∷ τ ∷ ι ∷ κ ∷ ὸ ∷ ν ∷ []) "Titus.3.10"
∷ word (ἄ ∷ ν ∷ θ ∷ ρ ∷ ω ∷ π ∷ ο ∷ ν ∷ []) "Titus.3.10"
∷ word (μ ∷ ε ∷ τ ∷ ὰ ∷ []) "Titus.3.10"
∷ word (μ ∷ ί ∷ α ∷ ν ∷ []) "Titus.3.10"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.3.10"
∷ word (δ ∷ ε ∷ υ ∷ τ ∷ έ ∷ ρ ∷ α ∷ ν ∷ []) "Titus.3.10"
∷ word (ν ∷ ο ∷ υ ∷ θ ∷ ε ∷ σ ∷ ί ∷ α ∷ ν ∷ []) "Titus.3.10"
∷ word (π ∷ α ∷ ρ ∷ α ∷ ι ∷ τ ∷ ο ∷ ῦ ∷ []) "Titus.3.10"
∷ word (ε ∷ ἰ ∷ δ ∷ ὼ ∷ ς ∷ []) "Titus.3.11"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "Titus.3.11"
∷ word (ἐ ∷ ξ ∷ έ ∷ σ ∷ τ ∷ ρ ∷ α ∷ π ∷ τ ∷ α ∷ ι ∷ []) "Titus.3.11"
∷ word (ὁ ∷ []) "Titus.3.11"
∷ word (τ ∷ ο ∷ ι ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ ς ∷ []) "Titus.3.11"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.3.11"
∷ word (ἁ ∷ μ ∷ α ∷ ρ ∷ τ ∷ ά ∷ ν ∷ ε ∷ ι ∷ []) "Titus.3.11"
∷ word (ὢ ∷ ν ∷ []) "Titus.3.11"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ κ ∷ α ∷ τ ∷ ά ∷ κ ∷ ρ ∷ ι ∷ τ ∷ ο ∷ ς ∷ []) "Titus.3.11"
∷ word (Ὅ ∷ τ ∷ α ∷ ν ∷ []) "Titus.3.12"
∷ word (π ∷ έ ∷ μ ∷ ψ ∷ ω ∷ []) "Titus.3.12"
∷ word (Ἀ ∷ ρ ∷ τ ∷ ε ∷ μ ∷ ᾶ ∷ ν ∷ []) "Titus.3.12"
∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "Titus.3.12"
∷ word (σ ∷ ὲ ∷ []) "Titus.3.12"
∷ word (ἢ ∷ []) "Titus.3.12"
∷ word (Τ ∷ υ ∷ χ ∷ ι ∷ κ ∷ ό ∷ ν ∷ []) "Titus.3.12"
∷ word (σ ∷ π ∷ ο ∷ ύ ∷ δ ∷ α ∷ σ ∷ ο ∷ ν ∷ []) "Titus.3.12"
∷ word (ἐ ∷ ∙λ ∷ θ ∷ ε ∷ ῖ ∷ ν ∷ []) "Titus.3.12"
∷ word (π ∷ ρ ∷ ό ∷ ς ∷ []) "Titus.3.12"
∷ word (μ ∷ ε ∷ []) "Titus.3.12"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "Titus.3.12"
∷ word (Ν ∷ ι ∷ κ ∷ ό ∷ π ∷ ο ∷ ∙λ ∷ ι ∷ ν ∷ []) "Titus.3.12"
∷ word (ἐ ∷ κ ∷ ε ∷ ῖ ∷ []) "Titus.3.12"
∷ word (γ ∷ ὰ ∷ ρ ∷ []) "Titus.3.12"
∷ word (κ ∷ έ ∷ κ ∷ ρ ∷ ι ∷ κ ∷ α ∷ []) "Titus.3.12"
∷ word (π ∷ α ∷ ρ ∷ α ∷ χ ∷ ε ∷ ι ∷ μ ∷ ά ∷ σ ∷ α ∷ ι ∷ []) "Titus.3.12"
∷ word (ζ ∷ η ∷ ν ∷ ᾶ ∷ ν ∷ []) "Titus.3.13"
∷ word (τ ∷ ὸ ∷ ν ∷ []) "Titus.3.13"
∷ word (ν ∷ ο ∷ μ ∷ ι ∷ κ ∷ ὸ ∷ ν ∷ []) "Titus.3.13"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.3.13"
∷ word (Ἀ ∷ π ∷ ο ∷ ∙λ ∷ ∙λ ∷ ῶ ∷ ν ∷ []) "Titus.3.13"
∷ word (σ ∷ π ∷ ο ∷ υ ∷ δ ∷ α ∷ ί ∷ ω ∷ ς ∷ []) "Titus.3.13"
∷ word (π ∷ ρ ∷ ό ∷ π ∷ ε ∷ μ ∷ ψ ∷ ο ∷ ν ∷ []) "Titus.3.13"
∷ word (ἵ ∷ ν ∷ α ∷ []) "Titus.3.13"
∷ word (μ ∷ η ∷ δ ∷ ὲ ∷ ν ∷ []) "Titus.3.13"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῖ ∷ ς ∷ []) "Titus.3.13"
∷ word (∙λ ∷ ε ∷ ί ∷ π ∷ ῃ ∷ []) "Titus.3.13"
∷ word (μ ∷ α ∷ ν ∷ θ ∷ α ∷ ν ∷ έ ∷ τ ∷ ω ∷ σ ∷ α ∷ ν ∷ []) "Titus.3.14"
∷ word (δ ∷ ὲ ∷ []) "Titus.3.14"
∷ word (κ ∷ α ∷ ὶ ∷ []) "Titus.3.14"
∷ word (ο ∷ ἱ ∷ []) "Titus.3.14"
∷ word (ἡ ∷ μ ∷ έ ∷ τ ∷ ε ∷ ρ ∷ ο ∷ ι ∷ []) "Titus.3.14"
∷ word (κ ∷ α ∷ ∙λ ∷ ῶ ∷ ν ∷ []) "Titus.3.14"
∷ word (ἔ ∷ ρ ∷ γ ∷ ω ∷ ν ∷ []) "Titus.3.14"
∷ word (π ∷ ρ ∷ ο ∷ ΐ ∷ σ ∷ τ ∷ α ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "Titus.3.14"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "Titus.3.14"
∷ word (τ ∷ ὰ ∷ ς ∷ []) "Titus.3.14"
∷ word (ἀ ∷ ν ∷ α ∷ γ ∷ κ ∷ α ∷ ί ∷ α ∷ ς ∷ []) "Titus.3.14"
∷ word (χ ∷ ρ ∷ ε ∷ ί ∷ α ∷ ς ∷ []) "Titus.3.14"
∷ word (ἵ ∷ ν ∷ α ∷ []) "Titus.3.14"
∷ word (μ ∷ ὴ ∷ []) "Titus.3.14"
∷ word (ὦ ∷ σ ∷ ι ∷ ν ∷ []) "Titus.3.14"
∷ word (ἄ ∷ κ ∷ α ∷ ρ ∷ π ∷ ο ∷ ι ∷ []) "Titus.3.14"
∷ word (Ἀ ∷ σ ∷ π ∷ ά ∷ ζ ∷ ο ∷ ν ∷ τ ∷ α ∷ ί ∷ []) "Titus.3.15"
∷ word (σ ∷ ε ∷ []) "Titus.3.15"
∷ word (ο ∷ ἱ ∷ []) "Titus.3.15"
∷ word (μ ∷ ε ∷ τ ∷ []) "Titus.3.15"
∷ word (ἐ ∷ μ ∷ ο ∷ ῦ ∷ []) "Titus.3.15"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "Titus.3.15"
∷ word (ἄ ∷ σ ∷ π ∷ α ∷ σ ∷ α ∷ ι ∷ []) "Titus.3.15"
∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "Titus.3.15"
∷ word (φ ∷ ι ∷ ∙λ ∷ ο ∷ ῦ ∷ ν ∷ τ ∷ α ∷ ς ∷ []) "Titus.3.15"
∷ word (ἡ ∷ μ ∷ ᾶ ∷ ς ∷ []) "Titus.3.15"
∷ word (ἐ ∷ ν ∷ []) "Titus.3.15"
∷ word (π ∷ ί ∷ σ ∷ τ ∷ ε ∷ ι ∷ []) "Titus.3.15"
∷ word (ἡ ∷ []) "Titus.3.15"
∷ word (χ ∷ ά ∷ ρ ∷ ι ∷ ς ∷ []) "Titus.3.15"
∷ word (μ ∷ ε ∷ τ ∷ ὰ ∷ []) "Titus.3.15"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ ω ∷ ν ∷ []) "Titus.3.15"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "Titus.3.15"
∷ []
| {
"alphanum_fraction": 0.3497286192,
"avg_line_length": 48.6731343284,
"ext": "agda",
"hexsha": "774c2ccaf2125b83d30d47e43ce5ab14fa91f2d0",
"lang": "Agda",
"max_forks_count": 5,
"max_forks_repo_forks_event_max_datetime": "2017-06-11T11:25:09.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-02-27T22:34:13.000Z",
"max_forks_repo_head_hexsha": "915c46c27c7f8aad5907474d8484f2685a4cd6a7",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "scott-fleischman/GreekGrammar",
"max_forks_repo_path": "agda/Text/Greek/SBLGNT/Titus.agda",
"max_issues_count": 13,
"max_issues_repo_head_hexsha": "915c46c27c7f8aad5907474d8484f2685a4cd6a7",
"max_issues_repo_issues_event_max_datetime": "2020-09-07T11:58:38.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-05-28T20:04:08.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "scott-fleischman/GreekGrammar",
"max_issues_repo_path": "agda/Text/Greek/SBLGNT/Titus.agda",
"max_line_length": 87,
"max_stars_count": 44,
"max_stars_repo_head_hexsha": "915c46c27c7f8aad5907474d8484f2685a4cd6a7",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "scott-fleischman/GreekGrammar",
"max_stars_repo_path": "agda/Text/Greek/SBLGNT/Titus.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-06T15:41:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-05-29T14:48:51.000Z",
"num_tokens": 23123,
"size": 32611
} |
------------------------------------------------------------------------------
-- From ListN as the least fixed-point to ListN using data
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
-- We want to represent the total lists of total natural numbers data
-- type
--
-- data ListN : D → Set where
-- lnnil : ListN []
-- lncons : ∀ {n ns} → N n → ListN ns → ListN (n ∷ ns)
--
-- using the representation of ListN as the least fixed-point.
module LFPs.ListN where
open import FOTC.Base
open import FOTC.Base.List
open import FOTC.Data.Nat.Type
open import FOTC.Data.Nat.UnaryNumbers
------------------------------------------------------------------------------
-- ListN is a least fixed-point of a functor
-- The functor.
-- ListNF : (D → Set) → D → Set
-- ListNF P ns = ns ≡ [] ∨ (∃[ n' ] ∃[ ns' ] N n' ∧ ns ≡ n' ∷ ns' ∧ P ns')
-- List is the least fixed-point of ListF.
postulate
ListN : D → Set
-- ListN is a pre-fixed point of ListNF.
--
-- Peter: It corresponds to the introduction rules.
ListN-in : ∀ {ns} →
ns ≡ [] ∨ (∃[ n' ] ∃[ ns' ] N n' ∧ ns ≡ n' ∷ ns' ∧ ListN ns') →
ListN ns
-- ListN is the least pre-fixed point of ListFN.
--
-- Peter: It corresponds to the elimination rule of an inductively
-- defined predicate.
ListN-ind :
(A : D → Set) →
(∀ {ns} → ns ≡ [] ∨ (∃[ n' ] ∃[ ns' ] N n' ∧ ns ≡ n' ∷ ns' ∧ A ns') → A ns) →
∀ {ns} → ListN ns → A ns
------------------------------------------------------------------------------
-- The data constructors of List.
lnnil : ListN []
lnnil = ListN-in (inj₁ refl)
lncons : ∀ {n ns} → N n → ListN ns → ListN (n ∷ ns)
lncons {n} {ns} Nn LNns = ListN-in (inj₂ (n , ns , Nn , refl , LNns))
------------------------------------------------------------------------------
-- The induction principle for List.
ListN-ind' : (A : D → Set) →
A [] →
(∀ n {ns} → N n → A ns → A (n ∷ ns)) →
∀ {ns} → ListN ns → A ns
ListN-ind' A A[] is = ListN-ind A prf
where
prf : ∀ {ns} → ns ≡ [] ∨ (∃[ n' ] ∃[ ns' ] N n' ∧ ns ≡ n' ∷ ns' ∧ A ns') →
A ns
prf (inj₁ ns≡[]) = subst A (sym ns≡[]) A[]
prf (inj₂ (n' , ns' , Nn' , h₁ , Ans')) = subst A (sym h₁) (is n' Nn' Ans')
------------------------------------------------------------------------------
-- Example
ys : D
ys = 0' ∷ 1' ∷ 2' ∷ []
ys-ListN : ListN ys
ys-ListN =
lncons nzero (lncons (nsucc nzero) (lncons (nsucc (nsucc nzero)) lnnil))
| {
"alphanum_fraction": 0.4370342772,
"avg_line_length": 32.3373493976,
"ext": "agda",
"hexsha": "e598eb24a306ac530b11366dd813ee492c87e563",
"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/fixed-points/LFPs/ListN.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/fixed-points/LFPs/ListN.agda",
"max_line_length": 81,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "notes/fixed-points/LFPs/ListN.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": 815,
"size": 2684
} |
{-# OPTIONS --allow-unsolved-metas #-}
module TermNode where
open import OscarPrelude
open import TermCode
record TermNode : Set
where
inductive
field
children : List (TermCode × TermNode)
number : Nat
open TermNode public
open import Membership
_child∈_ : TermCode → TermNode → Set
_child∈_ 𝔠 𝔫 = 𝔠 ∈ (fst <$> children 𝔫)
_child∉_ : TermCode → TermNode → Set
𝔠 child∉ 𝔫 = ¬ (𝔠 child∈ 𝔫)
open import DecidableMembership
_child∈?_ : (𝔠 : TermCode) → (𝔫 : TermNode) → Dec $ 𝔠 child∈ 𝔫
c child∈? record { children = cs } = c ∈? (fst <$> cs)
getChild : {𝔠 : TermCode} → (𝔫 : TermNode) → 𝔠 child∈ 𝔫 → TermNode
getChild {𝔠} (record { children = [] ; number = number₁ }) ()
getChild {._} (record { children = (fst₁ , snd₁) ∷ children₁ ; number = number₁ }) zero = snd₁
getChild {𝔠} (𝔫@record { children = x ∷ children₁ ; number = number₁ }) (suc x₁) = getChild record 𝔫 { children = children₁ } x₁
addChild : {𝔠 : TermCode} (𝔫 : TermNode) → 𝔠 child∉ 𝔫 → TermNode → TermNode
addChild {𝔠} 𝔫 𝔠∉𝔫 𝔫' =
record 𝔫 { children = (𝔠 , 𝔫') ∷ children 𝔫 }
setChild : {𝔠 : TermCode} (𝔫 : TermNode) → 𝔠 child∈ 𝔫 → TermNode → TermNode
setChild {𝔠} record { children = [] ; number = number₁ } () 𝔫'
setChild 𝔫@record { children = ((fst₁ , snd₁) ∷ children₁) ; number = number₁ } (zero) 𝔫' =
record 𝔫 { children = ((fst₁ , 𝔫') ∷ children₁) }
setChild {𝔠} 𝔫@record { children = (x ∷ children₁) ; number = number₁ } (suc 𝔠∈𝔫) 𝔫' =
record 𝔫 { children = (x ∷ children (setChild (record 𝔫 { children = children₁ }) 𝔠∈𝔫 𝔫')) }
setGet-ok : ∀ {𝔠} 𝔫 → (𝔠∈𝔫 : 𝔠 child∈ 𝔫) → setChild 𝔫 𝔠∈𝔫 (getChild 𝔫 𝔠∈𝔫) ≡ 𝔫
setGet-ok record { children = [] ; number = number₁ } ()
setGet-ok record { children = ((fst₁ , snd₁) ∷ children₁) ; number = number₁ } (zero) = refl
setGet-ok record { children = ((fst₁ , snd₁) ∷ children₁) ; number = number₁ } (suc 𝔠∈𝔫) rewrite setGet-ok (record { children = children₁ ; number = number₁ }) 𝔠∈𝔫 = refl
storeTermCodes : List TermCode → Nat → StateT TermNode Identity Nat
storeTermCodes [] 𝔑 = return 𝔑
storeTermCodes (𝔠 ∷ 𝔠s) 𝔑 =
𝔫 ← get -|
case 𝔠 child∈? 𝔫 of λ
{ (no 𝔠∉tests) →
let 𝔑' , 𝔫' = runIdentity $
runStateT
(storeTermCodes 𝔠s $ suc 𝔑)
(record
{ children = []
; number = suc 𝔑 }) in
put ((addChild 𝔫 𝔠∉tests 𝔫')) ~|
return 𝔑'
; (yes 𝔠∈tests) →
let 𝔑' , 𝔫' = runIdentity $
runStateT
(storeTermCodes 𝔠s $ suc 𝔑)
((getChild 𝔫 𝔠∈tests)) in
put ((setChild 𝔫 𝔠∈tests 𝔫')) ~|
return 𝔑' }
storeTermCodes[] : (𝔫 : TermNode) (𝔑 : Nat) → (runIdentity $ runStateT (storeTermCodes [] 𝔑) 𝔫) ≡ (𝔑 , 𝔫)
storeTermCodes[] 𝔫 𝔑 = refl
--{-# REWRITE storeTermCodes[] #-}
storeTermCodes' : List TermCode → StateT Nat (StateT TermNode Identity) ⊤
storeTermCodes' 𝔠s =
𝔑 ← get -|
tn ← lift get -|
(let 𝔑' , tn' = runIdentity $ runStateT (storeTermCodes 𝔠s 𝔑) tn in
put 𝔑' ~| lift (put tn') ~| return tt)
open import Term
open import Vector
mutual
storeTerm : Term → StateT Nat (StateT TermNode Identity) ⊤
storeTerm τ@(variable _) = storeTermCodes' (encodeTerm τ)
storeTerm τ@(function _ τs) = storeTermCodes' (encodeTerm τ) ~| storeTerms τs
storeTerms : Terms → StateT Nat (StateT TermNode Identity) ⊤
storeTerms ⟨ ⟨ [] ⟩ ⟩ = return tt
storeTerms ⟨ ⟨ τ ∷ τs ⟩ ⟩ = storeTerm τ ~| storeTerms ⟨ ⟨ τs ⟩ ⟩ ~| return tt
module ExampleStoreTerm where
open import FunctionName
open import VariableName
example-Term₁ : Term
example-Term₁ =
(function ⟨ 2 ⟩
⟨ ⟨ variable ⟨ 0 ⟩
∷ function ⟨ 3 ⟩
⟨ ⟨ variable ⟨ 2 ⟩ ∷ [] ⟩ ⟩
∷ variable ⟨ 5 ⟩
∷ []
⟩ ⟩
)
example-Term₂ : Term
example-Term₂ =
(function ⟨ 2 ⟩
⟨ ⟨ variable ⟨ 0 ⟩
∷ variable ⟨ 2 ⟩
∷ function ⟨ 3 ⟩
⟨ ⟨ variable ⟨ 2 ⟩ ∷ [] ⟩ ⟩
∷ variable ⟨ 5 ⟩
∷ []
⟩ ⟩
)
topNode : TermNode
topNode = record { children = [] ; number = 0 }
example-storeTerm : (⊤ × Nat) × TermNode
example-storeTerm = runIdentity $ runStateT (runStateT (storeTerm example-Term₁ >> storeTerm example-Term₂) 0) topNode
NodeStateT = StateT TermNode
TopNodeState = StateT Nat (NodeStateT Identity)
open import LiteralFormula
open import IsLiteralFormula
storeLiteralFormulaTerms : LiteralFormula → StateT Nat (StateT TermNode Identity) ⊤
storeLiteralFormulaTerms ⟨ atomic 𝑃 τs ⟩ = storeTerms τs
storeLiteralFormulaTerms ⟨ logical 𝑃 τs ⟩ = storeTerms τs
open import 𝓢equent
storeSequentLiteralFormulaTerms : 𝓢equent LiteralFormula → StateT Nat (StateT TermNode Identity) ⊤′
storeSequentLiteralFormulaTerms (φˢs ⊢ φᵗ) = sequence $ storeLiteralFormulaTerms <$> ({!φᵗ!} ∷ φˢs)
| {
"alphanum_fraction": 0.6008221994,
"avg_line_length": 33.5517241379,
"ext": "agda",
"hexsha": "5d14ec67aa3002b7a3189fbe96cb59c503c48d45",
"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/TermNode.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/TermNode.agda",
"max_line_length": 170,
"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/TermNode.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1793,
"size": 4865
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Data.Unit where
open import Cubical.Data.Unit.Base public
open import Cubical.Data.Unit.Properties public
| {
"alphanum_fraction": 0.7430167598,
"avg_line_length": 29.8333333333,
"ext": "agda",
"hexsha": "6e085e1bd8c97a71ad14a54632db2f5c114aaa09",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dan-iel-lee/cubical",
"max_forks_repo_path": "Cubical/Data/Unit.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/Data/Unit.agda",
"max_line_length": 50,
"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/Data/Unit.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 40,
"size": 179
} |
-- Laws for weakenings and substitutions.
{-# OPTIONS --without-K --safe #-}
module Definition.Untyped.Properties where
open import Definition.Untyped
open import Tools.Fin
open import Tools.Nat
open import Tools.List
open import Tools.PropositionalEquality hiding (subst)
private
variable
ℓ m n : Nat
ρ ρ′ : Wk m n
η : Wk n ℓ
σ σ′ : Subst m n
-- Weakening properties
-- Two weakenings ρ and ρ′ are extensionally equal if they agree on
-- all arguments when interpreted as functions mapping variables to
-- variables. Formally, they are considered equal iff
--
-- (∀ x → wkVar ρ x ≡ wkVar ρ′ x)
--
-- Intensional (propositional) equality would be too fine. For
-- instance,
--
-- lift id : Γ∙A ≤ Γ∙A
--
-- is extensionally equal to
--
-- id : Γ∙A ≤ Γ∙A
--
-- but syntactically different.
-- "lift" preserves equality of weakenings. Or:
-- If two weakenings are equal under wkVar, then they are equal when lifted.
wkVar-lift : (∀ x → wkVar ρ x ≡ wkVar ρ′ x)
→ (∀ x → wkVar (lift ρ) x ≡ wkVar (lift ρ′) x)
wkVar-lift eq x0 = refl
wkVar-lift eq (x +1) = cong _+1 (eq x)
wkVar-lifts : (∀ x → wkVar ρ x ≡ wkVar ρ′ x)
→ (∀ n x → wkVar (liftn ρ n) x ≡ wkVar (liftn ρ′ n) x)
wkVar-lifts eq 0 x = eq x
wkVar-lifts eq (1+ n) x = wkVar-lift (wkVar-lifts eq n) x
-- Extensionally equal weakenings, if applied to a term,
-- yield the same weakened term. Or:
-- If two weakenings are equal under wkVar, then they are equal under wk.
mutual
wkVar-to-wk : (∀ x → wkVar ρ x ≡ wkVar ρ′ x)
→ ∀ t → wk ρ t ≡ wk ρ′ t
wkVar-to-wk eq (var x) = cong var (eq x)
wkVar-to-wk eq (gen k c) = cong (gen k) (wkVar-to-wkGen eq c)
wkVar-to-wkGen : (∀ x → wkVar ρ x ≡ wkVar ρ′ x)
→ ∀ {bs} c → wkGen {bs = bs} ρ c ≡ wkGen {bs = bs} ρ′ c
wkVar-to-wkGen eq [] = refl
wkVar-to-wkGen eq (_∷_ {b = b} t ts) =
cong₂ _∷_ (wkVar-to-wk (wkVar-lifts eq b) t) (wkVar-to-wkGen eq ts)
-- lift id is extensionally equal to id.
wkVar-lift-id : (x : Fin (1+ n)) → wkVar (lift id) x ≡ wkVar id x
wkVar-lift-id x0 = refl
wkVar-lift-id (x +1) = refl
wkVar-lifts-id : (n : Nat) (x : Fin (n + m)) → wkVar (liftn id n) x ≡ wkVar id x
wkVar-lifts-id 0 x = refl
wkVar-lifts-id (1+ n) x0 = refl
wkVar-lifts-id (1+ n) (x +1) = cong _+1 (wkVar-lifts-id n x)
-- id is the identity renaming.
wkVar-id : (x : Fin n) → wkVar id x ≡ x
wkVar-id x = refl
mutual
wk-id : (t : Term n) → wk id t ≡ t
wk-id (var x) = refl
wk-id (gen k ts) = cong (gen k) (wkGen-id ts)
wkGen-id : ∀ {bs} x → wkGen {n} {n} {bs} id x ≡ x
wkGen-id [] = refl
wkGen-id (_∷_ {b = b} t ts) =
cong₂ _∷_ (trans (wkVar-to-wk (wkVar-lifts-id b) t) ( wk-id t)) (wkGen-id ts)
-- lift id is also the identity renaming.
wk-lift-id : (t : Term (1+ n)) → wk (lift id) t ≡ t
wk-lift-id t = trans (wkVar-to-wk wkVar-lift-id t) (wk-id t)
-- The composition of weakenings is correct...
--
-- ...as action on variables.
wkVar-comp : (ρ : Wk m ℓ) (ρ′ : Wk ℓ n) (x : Fin n) → wkVar ρ (wkVar ρ′ x) ≡ wkVar (ρ • ρ′) x
wkVar-comp id ρ′ x = refl
wkVar-comp (step ρ) ρ′ x = cong _+1 (wkVar-comp ρ ρ′ x)
wkVar-comp (lift ρ) id x = refl
wkVar-comp (lift ρ) (step ρ′) x = cong _+1 (wkVar-comp ρ ρ′ x)
wkVar-comp (lift ρ) (lift ρ′) x0 = refl
wkVar-comp (lift ρ) (lift ρ′) (x +1) = cong _+1 (wkVar-comp ρ ρ′ x)
wkVar-comps : ∀ k → (ρ : Wk m ℓ) (ρ′ : Wk ℓ n) (x : Fin (k + n))
→ wkVar (liftn ρ k • liftn ρ′ k) x
≡ wkVar (liftn (ρ • ρ′) k) x
wkVar-comps 0 ρ ρ′ x = refl
wkVar-comps (1+ n) ρ ρ′ x0 = refl
wkVar-comps (1+ n) ρ ρ′ (x +1) = cong _+1 (wkVar-comps n ρ ρ′ x)
-- ... as action on terms.
mutual
wk-comp : (ρ : Wk m ℓ) (ρ′ : Wk ℓ n) (t : Term n) → wk ρ (wk ρ′ t) ≡ wk (ρ • ρ′) t
wk-comp ρ ρ′ (var x) = cong var (wkVar-comp ρ ρ′ x)
wk-comp ρ ρ′ (gen k ts) = cong (gen k) (wkGen-comp ρ ρ′ ts)
wkGen-comp : (ρ : Wk m ℓ) (ρ′ : Wk ℓ n) → ∀ {bs} g
→ wkGen ρ (wkGen ρ′ g) ≡ wkGen {bs = bs} (ρ • ρ′) g
wkGen-comp ρ ρ′ [] = refl
wkGen-comp ρ ρ′ (_∷_ {b = b} t ts) =
cong₂ _∷_ (trans (wk-comp (liftn ρ b) (liftn ρ′ b) t)
(wkVar-to-wk (wkVar-comps b ρ ρ′) t))
(wkGen-comp ρ ρ′ ts)
-- The following lemmata are variations on the equality
--
-- wk1 ∘ ρ = lift ρ ∘ wk1.
--
-- Typing: Γ∙A ≤ Γ ≤ Δ <==> Γ∙A ≤ Δ∙A ≤ Δ.
lift-step-comp : (ρ : Wk m n) → step id • ρ ≡ lift ρ • step id
lift-step-comp id = refl
lift-step-comp (step ρ) = cong step (lift-step-comp ρ)
lift-step-comp (lift ρ) = refl
wk1-wk : (ρ : Wk m n) (t : Term n) → wk1 (wk ρ t) ≡ wk (step ρ) t
wk1-wk ρ t = wk-comp (step id) ρ t
lift-wk1 : (ρ : Wk m n) (t : Term n) → wk (lift ρ) (wk1 t) ≡ wk (step ρ) t
lift-wk1 pr A = trans (wk-comp (lift pr) (step id) A)
(sym (cong (λ x → wk x A) (lift-step-comp pr)))
wk1-wk≡lift-wk1 : (ρ : Wk m n) (t : Term n) → wk1 (wk ρ t) ≡ wk (lift ρ) (wk1 t)
wk1-wk≡lift-wk1 ρ t = trans (wk1-wk ρ t) (sym (lift-wk1 ρ t))
-- Substitution properties.
-- Two substitutions σ and σ′ are equal if they are pointwise equal,
-- i.e., agree on all variables.
--
-- ∀ x → σ x ≡ σ′ x
-- If σ = σ′ then lift σ = lift σ′.
substVar-lift : (∀ x → σ x ≡ σ′ x) → ∀ x → liftSubst σ x ≡ liftSubst σ′ x
substVar-lift eq x0 = refl
substVar-lift eq (x +1) = cong wk1 (eq x)
substVar-lifts : (∀ x → σ x ≡ σ′ x) → ∀ n x → liftSubstn σ n x ≡ liftSubstn σ′ n x
substVar-lifts eq 0 x = eq x
substVar-lifts eq (1+ n) x0 = refl
substVar-lifts eq (1+ n) (x +1) = cong wk1 (substVar-lifts eq n x)
-- If σ = σ′ then subst σ t = subst σ′ t.
mutual
substVar-to-subst : ((x : Fin n) → σ x ≡ σ′ x)
→ (t : Term n) → subst σ t ≡ subst σ′ t
substVar-to-subst eq (var x) = eq x
substVar-to-subst eq (gen k ts) = cong (gen k) (substVar-to-substGen eq ts)
substVar-to-substGen : ∀ {bs} → ((x : Fin n) → σ x ≡ σ′ x)
→ ∀ g → substGen {bs = bs} σ g ≡ substGen {bs = bs} σ′ g
substVar-to-substGen eq [] = refl
substVar-to-substGen eq (_∷_ {b = b} t ts) =
cong₂ _∷_ (substVar-to-subst (substVar-lifts eq b) t)
(substVar-to-substGen eq ts)
-- lift id = id (as substitutions)
subst-lift-id : (x : Fin (1+ n)) → (liftSubst idSubst) x ≡ idSubst x
subst-lift-id x0 = refl
subst-lift-id (x +1) = refl
subst-lifts-id : (n : Nat) → (x : Fin (n + m)) → (liftSubstn idSubst n) x ≡ idSubst x
subst-lifts-id 0 x = refl
subst-lifts-id (1+ n) x0 = refl
subst-lifts-id (1+ n) (x +1) = cong wk1 (subst-lifts-id n x)
-- Identity substitution.
mutual
subst-id : (t : Term n) → subst idSubst t ≡ t
subst-id (var x) = refl
subst-id (gen k ts) = cong (gen k) (substGen-id ts)
substGen-id : ∀ {bs} g → substGen {n} {n} {bs} idSubst g ≡ g
substGen-id [] = refl
substGen-id (_∷_ {b = b} t ts) =
cong₂ _∷_ (trans (substVar-to-subst (subst-lifts-id b) t )
(subst-id t))
(substGen-id ts)
-- Correctness of composition of weakening and substitution.
-- Composition of liftings is lifting of the composition.
-- lift ρ •ₛ lift σ = lift (ρ •ₛ σ)
subst-lift-•ₛ : ∀ t
→ subst (lift ρ •ₛ liftSubst σ) t
≡ subst (liftSubst (ρ •ₛ σ)) t
subst-lift-•ₛ =
substVar-to-subst (λ { x0 → refl ; (x +1) → sym (wk1-wk≡lift-wk1 _ _)})
helper1 : (n : Nat) (x : Fin (1+ n + m)) →
(lift (liftn ρ n) •ₛ liftSubst (liftSubstn σ n)) x ≡
liftSubst (liftSubstn (ρ •ₛ σ) n) x
helper1 0 x0 = refl
helper1 0 (x +1) = sym (wk1-wk≡lift-wk1 _ _)
helper1 (1+ n) x0 = refl
helper1 (1+ n) (x +1) = trans (sym (wk1-wk≡lift-wk1 _ _)) (cong wk1 (helper1 n x))
subst-lifts-•ₛ : ∀ n t
→ subst (liftn ρ n •ₛ liftSubstn σ n) t
≡ subst (liftSubstn (ρ •ₛ σ) n) t
subst-lifts-•ₛ 0 t = refl
subst-lifts-•ₛ (1+ n) t = substVar-to-subst (helper1 n) t
-- lift σ ₛ• lift ρ = lift (σ ₛ• ρ)
subst-lift-ₛ• : ∀ t
→ subst (liftSubst σ ₛ• lift ρ) t
≡ subst (liftSubst (σ ₛ• ρ)) t
subst-lift-ₛ• = substVar-to-subst (λ { x0 → refl ; (x +1) → refl})
helper2 : (n : Nat) → (x : Fin (1+ n + m))
→ liftSubst (liftSubstn σ n) (wkVar (lift (liftn ρ n)) x) ≡
liftSubst (liftSubstn (λ x₁ → σ (wkVar ρ x₁)) n) x
helper2 0 x0 = refl
helper2 0 (x +1) = refl
helper2 (1+ n) x0 = refl
helper2 (1+ n) (x +1) = cong wk1 (helper2 n x)
subst-lifts-ₛ• : ∀ n t
→ subst (liftSubstn σ n ₛ• liftn ρ n) t
≡ subst (liftSubstn (σ ₛ• ρ) n) t
subst-lifts-ₛ• 0 t = refl
subst-lifts-ₛ• (1+ n) t = substVar-to-subst (helper2 n) t
-- wk ρ ∘ subst σ = subst (ρ •ₛ σ)
mutual
wk-subst : ∀ t → wk ρ (subst σ t) ≡ subst (ρ •ₛ σ) t
wk-subst (var x) = refl
wk-subst (gen k ts) = cong (gen k) (wkGen-substGen ts)
wkGen-substGen : ∀ {bs} t → wkGen ρ (substGen σ t) ≡ substGen {bs = bs} (ρ •ₛ σ) t
wkGen-substGen [] = refl
wkGen-substGen (_∷_ {b = b} t ts) =
cong₂ _∷_ (trans (wk-subst t) ( subst-lifts-•ₛ b t)) (wkGen-substGen ts)
-- subst σ ∘ wk ρ = subst (σ •ₛ ρ)
mutual
subst-wk : ∀ t → subst σ (wk ρ t) ≡ subst (σ ₛ• ρ) t
subst-wk (var x) = refl
subst-wk (gen k ts) = cong (gen k) (substGen-wkGen ts)
substGen-wkGen : ∀ {bs} t → substGen σ (wkGen ρ t) ≡ substGen {bs = bs} (σ ₛ• ρ) t
substGen-wkGen [] = refl
substGen-wkGen (_∷_ {b = b} t ts) =
cong₂ _∷_ (trans (subst-wk t) (subst-lifts-ₛ• b t)) (substGen-wkGen ts)
-- Composition of liftings is lifting of the composition.
wk-subst-lift : (G : Term (1+ n))
→ wk (lift ρ) (subst (liftSubst σ) G)
≡ subst (liftSubst (ρ •ₛ σ)) G
wk-subst-lift G = trans (wk-subst G) (subst-lift-•ₛ G)
-- Renaming with ρ is the same as substituting with ρ turned into a substitution.
wk≡subst : (ρ : Wk m n) (t : Term n) → wk ρ t ≡ subst (toSubst ρ) t
wk≡subst ρ t = trans (cong (wk ρ) (sym (subst-id t))) (wk-subst t)
-- Composition of substitutions.
-- Composition of liftings is lifting of the composition.
substCompLift : ∀ x
→ (liftSubst σ ₛ•ₛ liftSubst σ′) x
≡ (liftSubst (σ ₛ•ₛ σ′)) x
substCompLift x0 = refl
substCompLift {σ = σ} {σ′ = σ′} (x +1) = trans (subst-wk (σ′ x)) (sym (wk-subst (σ′ x)))
substCompLifts : ∀ n x
→ (liftSubstn σ n ₛ•ₛ liftSubstn σ′ n) x
≡ (liftSubstn (σ ₛ•ₛ σ′) n) x
substCompLifts 0 x = refl
substCompLifts (1+ n) x0 = refl
substCompLifts {σ = σ} {σ′ = σ′} (1+ n) (x +1) =
trans (substCompLift {σ = liftSubstn σ n} {σ′ = liftSubstn σ′ n} (x +1))
(cong wk1 (substCompLifts n x))
-- Soundness of the composition of substitutions.
mutual
substCompEq : ∀ (t : Term n)
→ subst σ (subst σ′ t) ≡ subst (σ ₛ•ₛ σ′) t
substCompEq (var x) = refl
substCompEq (gen k ts) = cong (gen k) (substGenCompEq ts)
substGenCompEq : ∀ {bs} t
→ substGen σ (substGen σ′ t) ≡ substGen {bs = bs} (σ ₛ•ₛ σ′) t
substGenCompEq [] = refl
substGenCompEq (_∷_ {b = b} t ts) =
cong₂ _∷_ (trans (substCompEq t) (substVar-to-subst (substCompLifts b) t))
(substGenCompEq ts)
-- Weakening single substitutions.
-- Pulling apart a weakening composition in specific context _[a].
wk-comp-subst : ∀ {a} (ρ : Wk m ℓ) (ρ′ : Wk ℓ n) G
→ wk (lift (ρ • ρ′)) G [ a ] ≡ wk (lift ρ) (wk (lift ρ′) G) [ a ]
wk-comp-subst {a = a} ρ ρ′ G =
cong (λ x → x [ a ]) (sym (wk-comp (lift ρ) (lift ρ′) G))
-- Pushing a weakening into a single substitution.
-- ρ (t[a]) = ((lift ρ) t)[ρ a]
wk-β : ∀ {a} t → wk ρ (t [ a ]) ≡ wk (lift ρ) t [ wk ρ a ]
wk-β t = trans (wk-subst t) (sym (trans (subst-wk t)
(substVar-to-subst (λ { x0 → refl ; (x +1) → refl}) t)))
-- Pushing a weakening into a single shifting substitution.
-- If ρ′ = lift ρ then ρ′(t[a]↑) = ρ′(t) [ρ′(a)]↑
wk-β↑ : ∀ {a} t → wk (lift ρ) (t [ a ]↑) ≡ wk (lift ρ) t [ wk (lift ρ) a ]↑
wk-β↑ t = trans (wk-subst t) (sym (trans (subst-wk t)
(substVar-to-subst (λ { x0 → refl ; (x +1) → refl}) t)))
-- A specific equation on weakenings used for the reduction of natrec.
wk-β-natrec : ∀ (ρ : Wk m n )G
→ Π ℕ ▹ (Π wk (lift ρ) G ▹ wk (lift (lift ρ)) (wk1 (G [ suc (var x0) ]↑)))
≡ Π ℕ ▹ (wk (lift ρ) G ▹▹ wk (lift ρ) G [ suc (var x0) ]↑)
wk-β-natrec ρ G =
cong₂ Π_▹_ refl (cong₂ Π_▹_ refl
(trans (wk-comp (lift (lift ρ)) (step id)
(subst (consSubst (wk1Subst var) (suc (var x0))) G))
(trans (wk-subst G) (sym (trans (wk-subst (wk (lift ρ) G))
(trans (subst-wk G)
(substVar-to-subst (λ { x0 → refl ; (x +1) → refl}) G)))))))
-- Composing a singleton substitution and a lifted substitution.
-- sg u ∘ lift σ = cons id u ∘ lift σ = cons σ u
substVarSingletonComp : ∀ {u} (x : Fin (1+ n))
→ (sgSubst u ₛ•ₛ liftSubst σ) x ≡ (consSubst σ u) x
substVarSingletonComp x0 = refl
substVarSingletonComp {σ = σ} (x +1) = trans (subst-wk (σ x)) (subst-id (σ x))
-- The same again, as action on a term t.
substSingletonComp : ∀ {a} t
→ subst (sgSubst a ₛ•ₛ liftSubst σ) t ≡ subst (consSubst σ a) t
substSingletonComp = substVar-to-subst substVarSingletonComp
-- A single substitution after a lifted substitution.
-- ((lift σ) G)[t] = (cons σ t)(G)
singleSubstComp : ∀ t (σ : Subst m n) G
→ (subst (liftSubst σ) G) [ t ]
≡ subst (consSubst σ t) G
singleSubstComp t σ G = trans (substCompEq G) (substSingletonComp G)
-- A single substitution after a lifted substitution (with weakening).
-- ((lift (ρ ∘ σ)) G)[t] = (cons (ρ ∘ σ) t)(G)
singleSubstWkComp : ∀ t (σ : Subst m n) G
→ wk (lift ρ) (subst (liftSubst σ) G) [ t ]
≡ subst (consSubst (ρ •ₛ σ) t) G
singleSubstWkComp t σ G =
trans (cong (subst (consSubst var t))
(trans (wk-subst G) (subst-lift-•ₛ G)))
(trans (substCompEq G) (substSingletonComp G))
-- Pushing a substitution into a single substitution.
singleSubstLift : ∀ G t
→ subst σ (G [ t ])
≡ subst (liftSubst σ) G [ subst σ t ]
singleSubstLift G t =
trans (substCompEq G)
(trans (trans (substVar-to-subst (λ { x0 → refl ; (x +1) → refl}) G)
(sym (substSingletonComp G)))
(sym (substCompEq G)))
-- More specific laws.
idWkLiftSubstLemma : ∀ (σ : Subst m n) G
→ wk (lift (step id)) (subst (liftSubst σ) G) [ var x0 ]
≡ subst (liftSubst σ) G
idWkLiftSubstLemma σ G =
trans (singleSubstWkComp (var x0) σ G)
(substVar-to-subst (λ { x0 → refl ; (x +1) → refl}) G)
substVarComp↑ : ∀ {t} (σ : Subst m n) x
→ (consSubst (wk1Subst idSubst) (subst (liftSubst σ) t) ₛ•ₛ liftSubst σ) x
≡ (liftSubst σ ₛ•ₛ consSubst (wk1Subst idSubst) t) x
substVarComp↑ σ x0 = refl
substVarComp↑ σ (x +1) = trans (subst-wk (σ x)) (sym (wk≡subst (step id) (σ x)))
singleSubstLift↑ : ∀ (σ : Subst m n) G t
→ subst (liftSubst σ) (G [ t ]↑)
≡ subst (liftSubst σ) G [ subst (liftSubst σ) t ]↑
singleSubstLift↑ σ G t =
trans (substCompEq G)
(sym (trans (substCompEq G) (substVar-to-subst (substVarComp↑ σ) G)))
substConsComp : ∀ {t G}
→ subst (consSubst (λ x → σ (x +1)) (subst (tail σ) t)) G
≡ subst σ (subst (consSubst (λ x → var (x +1)) (wk1 t)) G)
substConsComp {t = t} {G = G} =
trans (substVar-to-subst (λ { x0 → sym (subst-wk t) ; (x +1) → refl }) G)
(sym (substCompEq G))
wkSingleSubstId : (F : Term (1+ n)) → (wk (lift (step id)) F) [ var x0 ] ≡ F
wkSingleSubstId F =
trans (subst-wk F)
(trans (substVar-to-subst (λ { x0 → refl ; (x +1) → refl}) F)
(subst-id F))
cons-wk-subst : ∀ (ρ : Wk m n) (σ : Subst n ℓ) a t
→ subst (sgSubst a ₛ• lift ρ ₛ•ₛ liftSubst σ) t
≡ subst (consSubst (ρ •ₛ σ) a) t
cons-wk-subst ρ σ a = substVar-to-subst
(λ { x0 → refl
; (x +1) → trans (subst-wk (σ x)) (sym (wk≡subst ρ (σ x))) })
natrecSucCaseLemma : (x : Fin (1+ n))
→ (step id •ₛ consSubst (wk1Subst idSubst) (suc (var x0)) ₛ•ₛ liftSubst σ) x
≡ (liftSubst (liftSubst σ) ₛ• step id ₛ•ₛ consSubst (wk1Subst idSubst) (suc (var x0))) x
natrecSucCaseLemma x0 = refl
natrecSucCaseLemma {σ = σ} (x +1) =
trans (subst-wk (σ x))
(sym (trans (wk1-wk (step id) _)
(wk≡subst (step (step id)) (σ x))))
natrecSucCase : ∀ (σ : Subst m n) F
→ Π ℕ ▹ (Π subst (liftSubst σ) F
▹ subst (liftSubst (liftSubst σ)) (wk1 (F [ suc (var x0) ]↑)))
≡ Π ℕ ▹ (subst (liftSubst σ) F ▹▹ subst (liftSubst σ) F [ suc (var x0) ]↑)
natrecSucCase σ F =
cong₂ Π_▹_ refl
(cong₂ Π_▹_ refl
(trans (trans (subst-wk (F [ suc (var x0) ]↑))
(substCompEq F))
(sym (trans (wk-subst (subst (liftSubst σ) F))
(trans (substCompEq F)
(substVar-to-subst natrecSucCaseLemma F))))))
natrecIrrelevantSubstLemma : ∀ F z s m (σ : Subst ℓ n) (x : Fin (1+ n))
→ (sgSubst (natrec (subst (liftSubst σ) F) (subst σ z) (subst σ s) m)
ₛ•ₛ liftSubst (sgSubst m)
ₛ•ₛ liftSubst (liftSubst σ)
ₛ• step id
ₛ•ₛ consSubst (tail idSubst) (suc (var x0))) x
≡ (consSubst σ (suc m)) x
natrecIrrelevantSubstLemma F z s m σ x0 =
cong suc (trans (subst-wk m) (subst-id m))
natrecIrrelevantSubstLemma F z s m σ (x +1) =
trans (subst-wk (wk (step id) (σ x)))
(trans (subst-wk (σ x))
(subst-id (σ x)))
natrecIrrelevantSubst : ∀ F z s m (σ : Subst ℓ n)
→ subst (consSubst σ (suc m)) F
≡ subst (liftSubst (sgSubst m))
(subst (liftSubst (liftSubst σ))
(wk1 (F [ suc (var x0) ]↑)))
[ natrec (subst (liftSubst σ) F) (subst σ z) (subst σ s) m ]
natrecIrrelevantSubst F z s m σ =
sym (trans (substCompEq (subst (liftSubst (liftSubst σ))
(wk (step id)
(subst (consSubst (tail idSubst) (suc (var x0))) F))))
(trans (substCompEq (wk (step id)
(subst (consSubst (tail idSubst) (suc (var x0))) F)))
(trans
(subst-wk (subst (consSubst (tail idSubst) (suc (var x0))) F))
(trans (substCompEq F)
(substVar-to-subst (natrecIrrelevantSubstLemma F z s m σ) F)))))
natrecIrrelevantSubstLemma′ : ∀ F z s n (x : Fin (1+ m))
→ (sgSubst (natrec F z s n)
ₛ•ₛ liftSubst (sgSubst n)
ₛ• step id
ₛ•ₛ consSubst (tail idSubst) (suc (var x0))) x
≡ (consSubst var (suc n)) x
natrecIrrelevantSubstLemma′ F z s n x0 =
cong suc (trans (subst-wk n) (subst-id n))
natrecIrrelevantSubstLemma′ F z s n (x +1) = refl
natrecIrrelevantSubst′ : ∀ (F : Term (1+ m)) z s n
→ subst (liftSubst (sgSubst n))
(wk1 (F [ suc (var x0) ]↑))
[ natrec F z s n ]
≡ F [ suc n ]
natrecIrrelevantSubst′ F z s n =
trans (substCompEq (wk (step id)
(subst (consSubst (tail idSubst) (suc (var x0))) F)))
(trans (subst-wk (subst (consSubst (tail idSubst) (suc (var x0))) F))
(trans (substCompEq F)
(substVar-to-subst (natrecIrrelevantSubstLemma′ F z s n) F)))
cons0wkLift1-id : ∀ (σ : Subst m n) G
→ subst (sgSubst (var x0))
(wk (lift (step id)) (subst (liftSubst σ) G))
≡ subst (liftSubst σ) G
cons0wkLift1-id σ G =
trans (subst-wk (subst (liftSubst σ) G))
(trans (substVar-to-subst (λ { x0 → refl ; (x +1) → refl })
(subst (liftSubst σ) G))
(subst-id (subst (liftSubst σ) G)))
substConsId : ∀ {t} G
→ subst (consSubst σ (subst σ t)) G
≡ subst σ (subst (sgSubst t) G)
substConsId G =
sym (trans (substCompEq G)
(substVar-to-subst (λ { x0 → refl ; (x +1) → refl}) G))
substConsTailId : ∀ {G t}
→ subst (consSubst (tail σ) (subst σ t)) G
≡ subst σ (subst (consSubst (tail idSubst) t) G)
substConsTailId {G = G} =
trans (substVar-to-subst (λ { x0 → refl
; (x +1) → refl }) G)
(sym (substCompEq G))
substConcatSingleton′ : ∀ {a} t
→ subst (σ ₛ•ₛ sgSubst a) t
≡ subst (consSubst σ (subst σ a)) t
substConcatSingleton′ t = substVar-to-subst (λ { x0 → refl ; (x +1) → refl}) t
wk1-tailId : (t : Term n) → wk1 t ≡ subst (tail idSubst) t
wk1-tailId t = trans (sym (subst-id (wk1 t))) (subst-wk t)
wk1-sgSubst : ∀ (t : Term n) t' → (wk1 t) [ t' ] ≡ t
wk1-sgSubst t t' rewrite wk1-tailId t =
let substVar-sgSubst-tail : ∀ a n → (sgSubst a ₛ•ₛ tail idSubst) n ≡ idSubst n
substVar-sgSubst-tail a n = refl
in trans (trans
(substCompEq t)
(substVar-to-subst (substVar-sgSubst-tail t') t))
(subst-id t)
| {
"alphanum_fraction": 0.5557215129,
"avg_line_length": 35.9083044983,
"ext": "agda",
"hexsha": "82792a71eff4f3309f3300cd0547bd632ad20019",
"lang": "Agda",
"max_forks_count": 8,
"max_forks_repo_forks_event_max_datetime": "2021-11-27T15:58:33.000Z",
"max_forks_repo_forks_event_min_datetime": "2017-10-18T14:18:20.000Z",
"max_forks_repo_head_hexsha": "ea83fc4f618d1527d64ecac82d7d17e2f18ac391",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "fhlkfy/logrel-mltt",
"max_forks_repo_path": "Definition/Untyped/Properties.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "ea83fc4f618d1527d64ecac82d7d17e2f18ac391",
"max_issues_repo_issues_event_max_datetime": "2021-02-22T10:37:24.000Z",
"max_issues_repo_issues_event_min_datetime": "2017-06-22T12:49:23.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "fhlkfy/logrel-mltt",
"max_issues_repo_path": "Definition/Untyped/Properties.agda",
"max_line_length": 93,
"max_stars_count": 30,
"max_stars_repo_head_hexsha": "ea83fc4f618d1527d64ecac82d7d17e2f18ac391",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "fhlkfy/logrel-mltt",
"max_stars_repo_path": "Definition/Untyped/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:01:07.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-05-20T03:05:21.000Z",
"num_tokens": 8243,
"size": 20755
} |
{-# OPTIONS --without-K --safe #-}
open import Algebra
open import Relation.Unary
open import Relation.Binary hiding (Decidable)
module Data.FingerTree.Split.Point
{r m}
(ℳ : Monoid r m)
{s}
{ℙ : Pred (Monoid.Carrier ℳ) s}
(ℙ-resp : ℙ Respects (Monoid._≈_ ℳ))
(ℙ? : Decidable ℙ)
where
open import Relation.Nullary using (¬_; yes; no; Dec)
open import Level using (_⊔_)
open import Data.Product
open import Function
open import Data.List as List using (List; _∷_; [])
open import Data.FingerTree.Measures ℳ
open import Data.FingerTree.Reasoning ℳ
open import Relation.Nullary using (Dec; yes; no)
open import Relation.Nullary.Decidable using (True; toWitness; False; toWitnessFalse)
open σ ⦃ ... ⦄
open Monoid ℳ renaming (Carrier to 𝓡)
open import Data.FingerTree.Relation.Binary.Reasoning.FasterInference.Setoid setoid
infixr 5 _∣_
record _∣_ (left focus : 𝓡) : Set s where
constructor ¬[_]ℙ[_]
field
¬ℙ : ¬ ℙ left
!ℙ : ℙ (left ∙ focus)
open _∣_ public
_∣?_ : ∀ x y → Dec (x ∣ y)
x ∣? y with ℙ? x
... | yes p = no λ c → ¬ℙ c p
... | no ¬p with ℙ? (x ∙ y)
... | no ¬c = no (¬c ∘ !ℙ)
... | yes p = yes ¬[ ¬p ]ℙ[ p ]
infixl 2 _≈◄⟅_⟆ _≈▻⟅_⟆ _≈⟅_∣_⟆ _◄_ _▻_
_◄_ : ∀ {l f₁ f₂} → l ∣ f₁ ∙ f₂ → ¬ ℙ (l ∙ f₁) → (l ∙ f₁) ∣ f₂
!ℙ (p ◄ ¬ℙf) = ℙ-resp (sym (assoc _ _ _)) (!ℙ p)
¬ℙ (p ◄ ¬ℙf) = ¬ℙf
_▻_ : ∀ {l f₁ f₂} → l ∣ f₁ ∙ f₂ → ℙ (l ∙ f₁) → l ∣ f₁
!ℙ (p ▻ ℙf) = ℙf
¬ℙ (p ▻ ℙf) = ¬ℙ p
_≈◄⟅_⟆ : ∀ {x y z} → x ∣ y → x ≈ z → z ∣ y
¬ℙ (x⟅y⟆ ≈◄⟅ x≈z ⟆) = ¬ℙ x⟅y⟆ ∘ ℙ-resp (sym x≈z)
!ℙ (x⟅y⟆ ≈◄⟅ x≈z ⟆) = ℙ-resp (≪∙ x≈z) (!ℙ x⟅y⟆)
_≈▻⟅_⟆ : ∀ {x y z} → x ∣ y → y ≈ z → x ∣ z
¬ℙ (x⟅y⟆ ≈▻⟅ y≈z ⟆) = ¬ℙ x⟅y⟆
!ℙ (x⟅y⟆ ≈▻⟅ y≈z ⟆) = ℙ-resp (∙≫ y≈z) (!ℙ x⟅y⟆)
_≈⟅_∣_⟆ : ∀ {x₁ y₁ x₂ y₂} → x₁ ∣ y₁ → x₁ ≈ x₂ → y₁ ≈ y₂ → x₂ ∣ y₂
¬ℙ (x⟅y⟆ ≈⟅ x≈ ∣ y≈ ⟆) = ¬ℙ x⟅y⟆ ∘ ℙ-resp (sym x≈)
!ℙ (x⟅y⟆ ≈⟅ x≈ ∣ y≈ ⟆) = ℙ-resp (∙-cong x≈ y≈) (!ℙ x⟅y⟆)
¬∄ℙ : ∀ {i} → ¬ (i ∣ ε)
¬∄ℙ i⟅ε⟆ = ¬ℙ i⟅ε⟆ (ℙ-resp (identityʳ _) (!ℙ i⟅ε⟆))
| {
"alphanum_fraction": 0.5313959523,
"avg_line_length": 26.7638888889,
"ext": "agda",
"hexsha": "1c8639b49402fe61ef4ce3b723d180ac2a043c7d",
"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": "39c3d96937384b052b782ffddf4fdec68c5d139f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/agda-indexed-fingertree",
"max_forks_repo_path": "src/Data/FingerTree/Split/Point.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "39c3d96937384b052b782ffddf4fdec68c5d139f",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "oisdk/agda-indexed-fingertree",
"max_issues_repo_path": "src/Data/FingerTree/Split/Point.agda",
"max_line_length": 85,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "39c3d96937384b052b782ffddf4fdec68c5d139f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/agda-indexed-fingertree",
"max_stars_repo_path": "src/Data/FingerTree/Split/Point.agda",
"max_stars_repo_stars_event_max_datetime": "2019-02-26T07:04:54.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-02-26T07:04:54.000Z",
"num_tokens": 1075,
"size": 1927
} |
module Category.Profunctor where
open import Agda.Primitive using (Level; _⊔_; lsuc)
open import Data.Product using (_,_; _×_)
open import Function using (id)
open import Relation.Binary.PropositionalEquality using (_≡_)
Dimap : ∀ {a b} (p : Set a → Set a → Set b) → Set (lsuc a ⊔ b)
Lmap : ∀ {a b} (p : Set a → Set a → Set b) → Set (lsuc a ⊔ b)
Rmap : ∀ {a b} (p : Set a → Set a → Set b) → Set (lsuc a ⊔ b)
Dimap p = ∀ {x y z w} → (f : x -> y) -> (h : z -> w) -> (g : p y z) → p x w
Lmap p = ∀ {x y w} → (f : x -> y) -> (g : p y w) → p x w
Rmap p = ∀ {x z w} → (h : z -> w) -> (g : p x z) → p x w
record ProfunctorImp {a b : Level} (p : Set a → Set a → Set b) : Set (lsuc (a ⊔ b)) where
field
dimap : Dimap p
lmap : Lmap p
rmap : Rmap p
dimapFromLmapRmap : ∀ {a b} {p : Set a → Set a → Set b} (lmap : Lmap p) (rmap : Rmap p) → Dimap p
dimapFromLmapRmap lmap rmap f h g = rmap h (lmap f g)
lmapRmapFromDimap : ∀ {a b} {p : Set a → Set a → Set b} (dimap : Dimap p) → (Lmap p × Rmap p)
lmapRmapFromDimap dimap = (λ f → dimap f id) , dimap id
module Profunctor {a b : Level} {p : Set a → Set a → Set b} (isProfunctor : ProfunctorImp p) where
open ProfunctorImp isProfunctor public
record LawfulProfunctorImp {a b} {p : Set a → Set a → Set b} (isProfunctor : ProfunctorImp p) : Set (lsuc (a ⊔ b)) where
open Profunctor isProfunctor
field
lmapId : ∀ {a b} {g : p a b} → lmap id g ≡ g
rmapId : ∀ {a b} {g : p a b} → rmap id g ≡ g
dimapLmapRmap : ∀ {a b c d} {f : a → b} {g : p b c} {h : c → d} → dimap f h g ≡ lmap f (rmap h g)
module LawfulProfunctor {a b} {p : Set a → Set a → Set b} {isProfunctor : ProfunctorImp p} (isLawful : LawfulProfunctorImp isProfunctor) where
open Profunctor isProfunctor public
open LawfulProfunctorImp isLawful public
| {
"alphanum_fraction": 0.5839256424,
"avg_line_length": 44.6097560976,
"ext": "agda",
"hexsha": "290d1ebeadc3a03fd0778c9e50239eee7e8a5e96",
"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": "308afeeaa905870dbf1a995fa82e8825dfaf2d74",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "crisoagf/agda-optics",
"max_forks_repo_path": "src/Category/Profunctor.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "308afeeaa905870dbf1a995fa82e8825dfaf2d74",
"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": "crisoagf/agda-optics",
"max_issues_repo_path": "src/Category/Profunctor.agda",
"max_line_length": 142,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "308afeeaa905870dbf1a995fa82e8825dfaf2d74",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "crisoagf/agda-optics",
"max_stars_repo_path": "src/Category/Profunctor.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 749,
"size": 1829
} |
module Cats.Category.Op where
open import Relation.Binary using (Rel ; _Preserves₂_⟶_⟶_)
open import Relation.Binary.PropositionalEquality as ≡
open import Level
open import Cats.Category
open import Cats.Category.Cat using (Cat)
module _ {lo la l≈} (C : Category lo la l≈) where
infixr 9 _∘_
infixr 4 _≈_
private
module C = Category C
module ≈ = C.≈
Obj : Set lo
Obj = C.Obj
_⇒_ : Obj → Obj → Set la
A ⇒ B = B C.⇒ A
id : ∀ {A} → A ⇒ A
id = C.id
_∘_ : ∀ {A B C : Obj} → (B ⇒ C) → (A ⇒ B) → A ⇒ C
f ∘ g = g C.∘ f
_≈_ : ∀ {A B} → Rel (A ⇒ B) l≈
_≈_ = C._≈_
∘-resp : ∀ {A B C} → _∘_ {A} {B} {C} Preserves₂ _≈_ ⟶ _≈_ ⟶ _≈_
∘-resp {x = f} {g} {h} {i} f≈g h≈i = C.∘-resp h≈i f≈g
assoc : ∀ {A B C D} {f : C ⇒ D} {g : B ⇒ C} {h : A ⇒ B}
→ (f ∘ g) ∘ h ≈ f ∘ (g ∘ h)
assoc = C.unassoc
_ᵒᵖ : Category lo la l≈
_ᵒᵖ = record
{ Obj = Obj
; _⇒_ = _⇒_
; _≈_ = _≈_
; id = id
; _∘_ = λ f g → g C.∘ f
; equiv = C.equiv
; ∘-resp = ∘-resp
; id-r = C.id-l
; id-l = C.id-r
; assoc = assoc
}
module _ {lo la l≈ : Level} where
private module Cat = Category (Cat lo la l≈)
op-involution : {C : Category lo la l≈} → ((C ᵒᵖ) ᵒᵖ) Cat.≅ C
op-involution {C} = record
{ forth = record
{ fobj = λ x → x
; fmap = λ f → f
; fmap-resp = λ eq → eq
; fmap-id = C.≈.reflexive ≡.refl
; fmap-∘ = C.≈.reflexive ≡.refl
}
; back = record
{ fobj = λ x → x
; fmap = λ f → f
; fmap-resp = λ eq → eq
; fmap-id = C.≈.reflexive ≡.refl
; fmap-∘ = C.≈.reflexive ≡.refl
}
-- TODO This sort of natural iso comes up all the time. Can we abstract it
-- out?
; back-forth = record
{ iso = Coo.≅.refl
; forth-natural = C.≈.trans C.id-l (C.≈.sym C.id-r)
}
; forth-back = record
{ iso = C.≅.refl
; forth-natural = C.≈.trans C.id-l (C.≈.sym C.id-r)
}
}
where
module C = Category C
module Coo = Category ((C ᵒᵖ)ᵒᵖ)
module ≈ = C.≈
| {
"alphanum_fraction": 0.4649326521,
"avg_line_length": 23.402173913,
"ext": "agda",
"hexsha": "8d846c0220b7c21e6ab0830352e5ced3d7e2554f",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "alessio-b-zak/cats",
"max_forks_repo_path": "Cats/Category/Op.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "alessio-b-zak/cats",
"max_issues_repo_path": "Cats/Category/Op.agda",
"max_line_length": 80,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "alessio-b-zak/cats",
"max_stars_repo_path": "Cats/Category/Op.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 919,
"size": 2153
} |
module AgdalightTelescopeSyntax where
postulate
A : Set
B : A -> Set
g : (x y : A; z : B x) -> A
-- this is Agdalight syntax, should not parse | {
"alphanum_fraction": 0.644295302,
"avg_line_length": 21.2857142857,
"ext": "agda",
"hexsha": "20a905348f3d5a6cde748e27c16c25f7e8915734",
"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/fail/AgdalightTelescopeSyntax.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "test/fail/AgdalightTelescopeSyntax.agda",
"max_line_length": 45,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "test/fail/AgdalightTelescopeSyntax.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": 52,
"size": 149
} |
{-# OPTIONS --safe #-}
module Cubical.Data.Graph.Examples where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Isomorphism
open import Cubical.Data.Empty
open import Cubical.Data.Unit renaming (Unit to ⊤)
open import Cubical.Data.Nat
open import Cubical.Data.SumFin
open import Cubical.Relation.Nullary
open import Cubical.Data.Sum
open import Cubical.Data.Sigma
open import Cubical.Data.Graph.Base
-- Some small graphs of common shape
⇒⇐ : Graph ℓ-zero ℓ-zero
Node ⇒⇐ = Fin 3
Edge ⇒⇐ fzero (fsuc fzero) = ⊤
Edge ⇒⇐ (fsuc (fsuc fzero)) (fsuc fzero) = ⊤
Edge ⇒⇐ _ _ = ⊥
⇐⇒ : Graph ℓ-zero ℓ-zero
Node ⇐⇒ = Fin 3
Edge ⇐⇒ (fsuc fzero) fzero = ⊤
Edge ⇐⇒ (fsuc fzero) (fsuc (fsuc fzero)) = ⊤
Edge ⇐⇒ _ _ = ⊥
-- paralell pair graph
⇉ : Graph ℓ-zero ℓ-zero
Node ⇉ = Fin 2
Edge ⇉ fzero (fsuc fzero) = Fin 2
Edge ⇉ _ _ = ⊥
-- The graph ω = 0 → 1 → 2 → ···
data Adj : ℕ → ℕ → Type₀ where
adj : ∀ n → Adj n (suc n)
areAdj : ∀ m n → Dec (Adj m n)
areAdj zero zero = no λ ()
areAdj zero (suc zero) = yes (adj zero)
areAdj zero (suc (suc n)) = no λ ()
areAdj (suc m) zero = no λ ()
areAdj (suc m) (suc n) = mapDec (λ { (adj .m) → adj (suc m) })
(λ { ¬a (adj .(suc m)) → ¬a (adj m) })
(areAdj m n)
ωGr : Graph ℓ-zero ℓ-zero
Node ωGr = ℕ
Edge ωGr m n with areAdj m n
... | yes _ = ⊤ -- if n ≡ (suc m)
... | no _ = ⊥ -- otherwise
record ωDiag ℓ : Type (ℓ-suc ℓ) where
field
ωNode : ℕ → Type ℓ
ωEdge : ∀ n → ωNode n → ωNode (suc n)
asDiag : Diag ℓ ωGr
asDiag $ n = ωNode n
_<$>_ asDiag {m} {n} f with areAdj m n
asDiag <$> tt | yes (adj m) = ωEdge m
-- The finite connected subgraphs of ω: 𝟘,𝟙,𝟚,𝟛,...
data AdjFin : ∀ {k} → Fin k → Fin k → Type₀ where
adj : ∀ {k} (n : Fin k) → AdjFin (finj n) (fsuc n)
adj-fsuc : ∀ {k} {m n : Fin k} → AdjFin (fsuc m) (fsuc n) → AdjFin m n
adj-fsuc {suc k} {.(finj n)} {fsuc n} (adj .(fsuc n)) = adj n
areAdjFin : ∀ {k} (m n : Fin k) → Dec (AdjFin m n)
areAdjFin {suc k} fzero fzero = no λ ()
areAdjFin {suc (suc k)} fzero (fsuc fzero) = yes (adj fzero)
areAdjFin {suc (suc k)} fzero (fsuc (fsuc n)) = no λ ()
areAdjFin {suc k} (fsuc m) fzero = no λ ()
areAdjFin {suc k} (fsuc m) (fsuc n) = mapDec (λ { (adj m) → adj (fsuc m) })
(λ { ¬a a → ¬a (adj-fsuc a) })
(areAdjFin {k} m n)
[_]Gr : ℕ → Graph ℓ-zero ℓ-zero
Node [ k ]Gr = Fin k
Edge [ k ]Gr m n with areAdjFin m n
... | yes _ = ⊤ -- if n ≡ (suc m)
... | no _ = ⊥ -- otherwise
𝟘Gr 𝟙Gr 𝟚Gr 𝟛Gr : Graph ℓ-zero ℓ-zero
𝟘Gr = [ 0 ]Gr; 𝟙Gr = [ 1 ]Gr; 𝟚Gr = [ 2 ]Gr; 𝟛Gr = [ 3 ]Gr
record [_]Diag ℓ (k : ℕ) : Type (ℓ-suc ℓ) where
field
[]Node : Fin (suc k) → Type ℓ
[]Edge : ∀ (n : Fin k) → []Node (finj n) → []Node (fsuc n)
asDiag : Diag ℓ [ suc k ]Gr
asDiag $ n = []Node n
_<$>_ asDiag {m} {n} f with areAdjFin m n
_<$>_ asDiag {.(finj n)} {fsuc n} f | yes (adj .n) = []Edge n
-- Disjoint union of graphs
module _ {ℓv ℓe ℓv' ℓe'} where
_⊎Gr_ : ∀ (G : Graph ℓv ℓe) (G' : Graph ℓv' ℓe') → Graph (ℓ-max ℓv ℓv') (ℓ-max ℓe ℓe')
Node (G ⊎Gr G') = Node G ⊎ Node G'
Edge (G ⊎Gr G') (inl x) (inl y) = Lift {j = ℓe'} (Edge G x y)
Edge (G ⊎Gr G') (inr x) (inr y) = Lift {j = ℓe } (Edge G' x y)
Edge (G ⊎Gr G') _ _ = Lift ⊥
record ⊎Diag ℓ (G : Graph ℓv ℓe) (G' : Graph ℓv' ℓe')
: Type (ℓ-max (ℓ-suc ℓ) (ℓ-max (ℓ-max ℓv ℓv') (ℓ-max ℓe ℓe'))) where
field
⊎Node : Node G ⊎ Node G' → Type ℓ
⊎Edgel : ∀ {x y} → Edge G x y → ⊎Node (inl x) → ⊎Node (inl y)
⊎Edger : ∀ {x y} → Edge G' x y → ⊎Node (inr x) → ⊎Node (inr y)
asDiag : Diag ℓ (G ⊎Gr G')
asDiag $ x = ⊎Node x
_<$>_ asDiag {inl x} {inl y} f = ⊎Edgel (lower f)
_<$>_ asDiag {inr x} {inr y} f = ⊎Edger (lower f)
-- Cartesian product of graphs
module _ {ℓv ℓe ℓv' ℓe'} where
-- We need decidable equality in order to define the cartesian product
DecGraph : ∀ ℓv ℓe → Type (ℓ-suc (ℓ-max ℓv ℓe))
DecGraph ℓv ℓe = Σ[ G ∈ Graph ℓv ℓe ] Discrete (Node G)
_×Gr_ : (G : DecGraph ℓv ℓe) (G' : DecGraph ℓv' ℓe') → Graph (ℓ-max ℓv ℓv') (ℓ-max ℓe ℓe')
Node (G ×Gr G') = Node (fst G) × Node (fst G')
Edge (G ×Gr G') (x , x') (y , y') with snd G x y | snd G' x' y'
... | yes _ | yes _ = Edge (fst G) x y ⊎ Edge (fst G') x' y'
... | yes _ | no _ = Lift {j = ℓe } (Edge (fst G') x' y')
... | no _ | yes _ = Lift {j = ℓe'} (Edge (fst G) x y)
... | no _ | no _ = Lift ⊥
record ×Diag ℓ (G : DecGraph ℓv ℓe) (G' : DecGraph ℓv' ℓe')
: Type (ℓ-max (ℓ-suc ℓ) (ℓ-max (ℓ-max ℓv ℓv') (ℓ-max ℓe ℓe'))) where
field
×Node : Node (fst G) × Node (fst G') → Type ℓ
×Edge₁ : ∀ {x y} (f : Edge (fst G) x y) (x' : Node (fst G')) → ×Node (x , x') → ×Node (y , x')
×Edge₂ : ∀ (x : Node (fst G)) {x' y'} (f : Edge (fst G') x' y') → ×Node (x , x') → ×Node (x , y')
asDiag : Diag ℓ (G ×Gr G')
asDiag $ x = ×Node x
_<$>_ asDiag {x , x'} {y , y'} f with snd G x y | snd G' x' y'
_<$>_ asDiag {x , x'} {y , y'} (inl f) | yes _ | yes p' = subst _ p' (×Edge₁ f x')
_<$>_ asDiag {x , x'} {y , y'} (inr f) | yes p | yes _ = subst _ p (×Edge₂ x f )
_<$>_ asDiag {x , x'} {y , y'} f | yes p | no _ = subst _ p (×Edge₂ x (lower f) )
_<$>_ asDiag {x , x'} {y , y'} f | no _ | yes p' = subst _ p' (×Edge₁ (lower f) x')
| {
"alphanum_fraction": 0.5141466931,
"avg_line_length": 34.2530864198,
"ext": "agda",
"hexsha": "b94a303b9b4e9bfcb9c63dea341fa658274f98e9",
"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/Data/Graph/Examples.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/Data/Graph/Examples.agda",
"max_line_length": 103,
"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/Data/Graph/Examples.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": 2430,
"size": 5549
} |
{-# OPTIONS --safe --warning=error --without-K --guardedness #-}
open import Setoids.Setoids
open import Rings.Definition
open import Rings.Lemmas
open import Rings.Orders.Partial.Definition
open import Rings.Orders.Total.Definition
open import Groups.Definition
open import Groups.Lemmas
open import Fields.Fields
open import Sets.EquivalenceRelations
open import Sequences
open import Setoids.Orders.Partial.Definition
open import Setoids.Orders.Total.Definition
open import Functions.Definition
open import LogicalFormulae
open import Numbers.Naturals.Semiring
open import Numbers.Naturals.Order
open import Numbers.Naturals.Order.Lemmas
module Fields.CauchyCompletion.Multiplication {m n o : _} {A : Set m} {S : Setoid {m} {n} A} {_+_ : A → A → A} {_*_ : A → A → A} {_<_ : Rel {m} {o} A} {pOrder : SetoidPartialOrder S _<_} {R : Ring S _+_ _*_} {pRing : PartiallyOrderedRing R pOrder} (order : TotallyOrderedRing pRing) (F : Field R) where
open Setoid S
open SetoidTotalOrder (TotallyOrderedRing.total order)
open SetoidPartialOrder pOrder
open Equivalence eq
open PartiallyOrderedRing pRing
open Ring R
open Group additiveGroup
open Field F
open import Fields.Orders.Lemmas {F = F} record { oRing = order }
open import Fields.Orders.Total.Lemmas {F = F} record { oRing = order }
open import Fields.Lemmas F
open import Rings.Orders.Partial.Lemmas pRing
open import Rings.Orders.Total.Lemmas order
open import Rings.Orders.Total.Cauchy order
open import Rings.Orders.Total.AbsoluteValue order
open import Fields.CauchyCompletion.Definition order F
open import Fields.CauchyCompletion.Setoid order F
open import Fields.CauchyCompletion.Approximation order F
0!=1 : {e : A} → (0G < e) → 0R ∼ 1R → False
0!=1 {e} 0<e 0=1 = irreflexive (<WellDefined (Equivalence.reflexive eq) (oneZeroImpliesAllZero R 0=1) 0<e)
private
littleLemma : {a b c d : A} → ((a * b) + inverse (c * d)) ∼ ((a * (b + inverse d)) + (d * (a + inverse c)))
littleLemma {a} {b} {c} {d} = Equivalence.transitive eq (Equivalence.transitive eq (+WellDefined (Equivalence.reflexive eq) (Equivalence.transitive eq (Equivalence.transitive eq (Equivalence.symmetric eq identLeft) (+WellDefined (Equivalence.symmetric eq (Equivalence.transitive eq (+WellDefined (Equivalence.transitive eq (ringMinusExtracts R) (inverseWellDefined additiveGroup *Commutative)) (Equivalence.reflexive eq)) (invLeft {d * a}))) (Equivalence.transitive eq (Equivalence.symmetric eq (ringMinusExtracts' R)) *Commutative))) (Equivalence.symmetric eq +Associative))) (+Associative)) (Equivalence.symmetric eq (+WellDefined (*DistributesOver+) (*DistributesOver+)))
timesConverges : (a b : CauchyCompletion) → cauchy (apply _*_ (CauchyCompletion.elts a) (CauchyCompletion.elts b))
timesConverges record { elts = a ; converges = aConv } record { elts = b ; converges = bConv } e 0<e with boundModulus record { elts = a ; converges = aConv }
... | aBound , (Na , prABound) with boundModulus record { elts = b ; converges = bConv }
... | bBound , (Nb , prBBound) = N , ans
where
boundBoth : A
boundBoth = aBound + bBound
abstract
ab<bb : aBound < boundBoth
ab<bb = <WellDefined identLeft groupIsAbelian (orderRespectsAddition {0R} {bBound} (greaterThanAbsImpliesGreaterThan0 (prBBound (succ Nb) (le 0 refl))) aBound)
bb<bb : bBound < boundBoth
bb<bb = <WellDefined identLeft (Equivalence.reflexive eq) (orderRespectsAddition {0R} {aBound} (greaterThanAbsImpliesGreaterThan0 (prABound (succ Na) (le 0 refl))) bBound)
0<boundBoth : 0R < boundBoth
0<boundBoth = <WellDefined identLeft (Equivalence.reflexive eq) (ringAddInequalities (greaterThanAbsImpliesGreaterThan0 (prABound (succ Na) (le 0 refl))) (greaterThanAbsImpliesGreaterThan0 (prBBound (succ Nb) (le 0 refl))))
abstract
1/boundBoothAndPr : Sg A λ i → i * (aBound + bBound) ∼ 1R
1/boundBoothAndPr = allInvertible boundBoth λ pr → irreflexive (<WellDefined (Equivalence.reflexive eq) pr 0<boundBoth)
1/boundBooth : A
1/boundBooth with 1/boundBoothAndPr
... | a , _ = a
1/boundBoothPr : 1/boundBooth * (aBound + bBound) ∼ 1R
1/boundBoothPr with 1/boundBoothAndPr
... | _ , pr = pr
0<1/boundBooth : 0G < 1/boundBooth
0<1/boundBooth = inversePositiveIsPositive 1/boundBoothPr 0<boundBoth
abstract
miniEAndPr : Sg A (λ i → (i + i) ∼ (e * 1/boundBooth))
miniEAndPr = halve charNot2 (e * 1/boundBooth)
miniE : A
miniE with miniEAndPr
... | a , _ = a
miniEPr : (miniE + miniE) ∼ (e * 1/boundBooth)
miniEPr with miniEAndPr
... | _ , pr = pr
0<miniE : 0R < miniE
0<miniE = halvePositive miniE (<WellDefined (Equivalence.reflexive eq) (Equivalence.symmetric eq miniEPr) (orderRespectsMultiplication 0<e 0<1/boundBooth))
abstract
reallyNAAndPr : Sg ℕ (λ N → {m n : ℕ} → N <N m → N <N n → abs (index a m + inverse (index a n)) < miniE)
reallyNAAndPr = aConv miniE 0<miniE
reallyNa : ℕ
reallyNa with reallyNAAndPr
... | a , _ = a
reallyNaPr : {m n : ℕ} → reallyNa <N m → reallyNa <N n → abs (index a m + inverse (index a n)) < miniE
reallyNaPr with reallyNAAndPr
... | _ , pr = pr
reallyNBAndPr : Sg ℕ (λ N → {m n : ℕ} → N <N m → N <N n → abs (index b m + inverse (index b n)) < miniE)
reallyNBAndPr = bConv miniE 0<miniE
reallyNb : ℕ
reallyNb with reallyNBAndPr
... | a , _ = a
reallyNbPr : {m n : ℕ} → reallyNb <N m → reallyNb <N n → abs (index b m + inverse (index b n)) < miniE
reallyNbPr with reallyNBAndPr
... | _ , pr = pr
N : ℕ
N = (Na +N (Nb +N (reallyNa +N reallyNb)))
ans : {m : ℕ} {n : ℕ} → N <N m → N <N n → abs (index (apply _*_ a b) m + inverse (index (apply _*_ a b) n)) < e
ans {m} {n} N<m N<n rewrite indexAndApply a b _*_ {m} | indexAndApply a b _*_ {n} = ans'''
where
Na<m : Na <N m
Na<m = inequalityShrinkLeft N<m
Nb<n : Nb <N n
Nb<n = inequalityShrinkLeft (inequalityShrinkRight {Na} N<n)
abstract
sum : {m n : ℕ} → (reallyNa +N reallyNb) <N m → (reallyNa +N reallyNb) <N n → (boundBoth * ((abs (index b m + inverse (index b n))) + (abs (index a m + inverse (index a n))))) < e
sum {m} {n} <m <n = <WellDefined *Commutative (Equivalence.transitive eq (*WellDefined miniEPr (Equivalence.reflexive eq)) (Equivalence.transitive eq (Equivalence.symmetric eq *Associative) (Equivalence.transitive eq (Equivalence.transitive eq (*WellDefined (Equivalence.reflexive eq) 1/boundBoothPr) *Commutative) (identIsIdent)))) (ringCanMultiplyByPositive {c = boundBoth} 0<boundBoth (ringAddInequalities (reallyNbPr {m} {n} (inequalityShrinkRight <m) (inequalityShrinkRight <n)) (reallyNaPr {m} {n} (inequalityShrinkLeft <m) (inequalityShrinkLeft <n))))
q : ((boundBoth * (abs (index b m + inverse (index b n)))) + (boundBoth * (abs (index a m + inverse (index a n))))) < e
q = <WellDefined *DistributesOver+ (Equivalence.reflexive eq) (sum {m} {n} (inequalityShrinkRight {Nb} (inequalityShrinkRight {Na} N<m)) (inequalityShrinkRight {Nb} (inequalityShrinkRight {Na} N<n)))
p : ((abs (index a m) * abs (index b m + inverse (index b n))) + (abs (index b n) * abs (index a m + inverse (index a n)))) < e
p with totality 0R (index b m + inverse (index b n))
p | inl (inl 0<bm-bn) with totality 0R (index a m + inverse (index a n))
p | inl (inl 0<bm-bn) | inl (inl 0<am-an) = SetoidPartialOrder.<Transitive pOrder (ringAddInequalities (<WellDefined (Equivalence.reflexive eq) (*WellDefined (Equivalence.reflexive eq) (greaterZeroImpliesEqualAbs 0<bm-bn)) (ringCanMultiplyByPositive 0<bm-bn (SetoidPartialOrder.<Transitive pOrder (prABound m Na<m) ab<bb))) (<WellDefined (Equivalence.reflexive eq) (*WellDefined (Equivalence.reflexive eq) (greaterZeroImpliesEqualAbs 0<am-an)) (ringCanMultiplyByPositive 0<am-an (SetoidPartialOrder.<Transitive pOrder (prBBound n Nb<n) bb<bb)))) q
p | inl (inl 0<bm-bn) | inl (inr am-an<0) = SetoidPartialOrder.<Transitive pOrder (ringAddInequalities (<WellDefined (*WellDefined (Equivalence.reflexive eq) (Equivalence.symmetric eq (greaterZeroImpliesEqualAbs 0<bm-bn))) (Equivalence.reflexive eq) (ringCanMultiplyByPositive (<WellDefined (Equivalence.reflexive eq) (greaterZeroImpliesEqualAbs 0<bm-bn) 0<bm-bn) (SetoidPartialOrder.<Transitive pOrder (prABound m Na<m) ab<bb))) (<WellDefined (*WellDefined (Equivalence.reflexive eq) (lessZeroImpliesEqualNegAbs am-an<0)) (Equivalence.reflexive eq) (ringCanMultiplyByPositive (<WellDefined (Equivalence.reflexive eq) (Equivalence.symmetric eq (lessZeroImpliesEqualNegAbs am-an<0)) (lemm2 _ am-an<0)) (SetoidPartialOrder.<Transitive pOrder (prBBound n Nb<n) bb<bb)))) q
p | inl (inl 0<bm-bn) | inr 0=am-an = <WellDefined (+WellDefined (Equivalence.reflexive eq) (*WellDefined (Equivalence.reflexive eq) 0=am-an)) (Equivalence.reflexive eq) (<WellDefined (+WellDefined (Equivalence.reflexive eq) (Equivalence.symmetric eq timesZero)) (Equivalence.reflexive eq) (<WellDefined (Equivalence.symmetric eq identRight) (Equivalence.reflexive eq) (SetoidPartialOrder.<Transitive pOrder (<WellDefined (Equivalence.reflexive eq) (+WellDefined (Equivalence.reflexive eq) (*WellDefined (Equivalence.reflexive eq) (Equivalence.transitive eq (Equivalence.symmetric eq absZeroIsZero) (absWellDefined _ _ 0=am-an)))) (<WellDefined (Equivalence.reflexive eq) (+WellDefined (Equivalence.reflexive eq) (Equivalence.symmetric eq timesZero)) (<WellDefined (Equivalence.reflexive eq) (Equivalence.symmetric eq identRight) (<WellDefined (*WellDefined (Equivalence.reflexive eq) (Equivalence.symmetric eq (greaterZeroImpliesEqualAbs 0<bm-bn))) (Equivalence.reflexive eq) (ringCanMultiplyByPositive (<WellDefined (Equivalence.reflexive eq) (greaterZeroImpliesEqualAbs 0<bm-bn) 0<bm-bn) (SetoidPartialOrder.<Transitive pOrder (prABound m Na<m) ab<bb)))))) q)))
p | inl (inr bm-bn<0) = SetoidPartialOrder.<Transitive pOrder ans'' q
where
bar : ((abs (index a m)) * (inverse (index b m + inverse (index b n)))) < (boundBoth * abs (index b m + inverse (index b n)))
bar = <WellDefined (*WellDefined (Equivalence.reflexive eq) (lessZeroImpliesEqualNegAbs bm-bn<0)) (Equivalence.reflexive eq) (ringCanMultiplyByPositive (<WellDefined (Equivalence.reflexive eq) (Equivalence.symmetric eq (lessZeroImpliesEqualNegAbs bm-bn<0)) (lemm2 _ bm-bn<0)) (SetoidPartialOrder.<Transitive pOrder (prABound m Na<m) (ab<bb)))
foo : (((abs (index b n)) * (abs (index a m + inverse (index a n)))) < (boundBoth * abs (index a m + inverse (index a n)))) || (((abs (index b n)) * (abs (index a m + inverse (index a n)))) ∼ (boundBoth * abs (index a m + inverse (index a n))))
foo with totality 0R (index a m + inverse (index a n))
foo | inl (inl 0<am-an) = inl (ringCanMultiplyByPositive 0<am-an (SetoidPartialOrder.<Transitive pOrder (prBBound n Nb<n) bb<bb))
foo | inl (inr am-an<0) = inl (ringCanMultiplyByPositive (lemm2 _ am-an<0) (SetoidPartialOrder.<Transitive pOrder (prBBound n Nb<n) bb<bb))
foo | inr 0=am-an = inr (Equivalence.transitive eq (*WellDefined (Equivalence.reflexive eq) (Equivalence.symmetric eq 0=am-an)) (Equivalence.transitive eq (Equivalence.transitive eq timesZero (Equivalence.symmetric eq timesZero)) (*WellDefined (Equivalence.reflexive eq) 0=am-an)))
ans'' : _
ans'' with foo
... | inl pr = ringAddInequalities bar pr
... | inr pr = <WellDefined (Equivalence.reflexive eq) (+WellDefined (Equivalence.reflexive eq) pr) (orderRespectsAddition bar ((abs (index b n)) * (abs (index a m + inverse (index a n)))))
p | inr 0=bm-bn = ans''
where
bar : (boundBoth * abs (index b m + inverse (index b n))) ∼ 0R
bar = Equivalence.transitive eq (*WellDefined (Equivalence.reflexive eq) (Equivalence.transitive eq (absWellDefined _ _ (Equivalence.symmetric eq 0=bm-bn)) (absZeroIsZero))) timesZero
bar' : (abs (index a m) * (index b m + inverse (index b n))) ∼ 0R
bar' = Equivalence.transitive eq (*WellDefined (Equivalence.reflexive eq) (Equivalence.symmetric eq 0=bm-bn)) timesZero
foo : (((abs (index b n)) * (abs (index a m + inverse (index a n)))) < (boundBoth * abs (index a m + inverse (index a n)))) || (0R ∼ (index a m + inverse (index a n)))
foo with totality 0R (index a m + inverse (index a n))
foo | inl (inl 0<am-an) = inl (SetoidPartialOrder.<Transitive pOrder (ringCanMultiplyByPositive 0<am-an (prBBound n Nb<n)) (ringCanMultiplyByPositive 0<am-an bb<bb))
foo | inl (inr am-an<0) = inl (SetoidPartialOrder.<Transitive pOrder (ringCanMultiplyByPositive (lemm2 _ am-an<0) (prBBound n Nb<n)) (ringCanMultiplyByPositive (lemm2 _ am-an<0) bb<bb))
foo | inr 0=am-an = inr 0=am-an
ans'' : _
ans'' with foo
... | inl pr = SetoidPartialOrder.<Transitive pOrder (<WellDefined groupIsAbelian groupIsAbelian (<WellDefined (+WellDefined (Equivalence.reflexive eq) (Equivalence.symmetric eq bar')) (+WellDefined (Equivalence.reflexive eq) (Equivalence.symmetric eq bar)) (orderRespectsAddition pr 0R))) q
... | inr pr = <WellDefined (Equivalence.transitive eq (Equivalence.symmetric eq identRight) (+WellDefined (Equivalence.symmetric eq bar') (Equivalence.symmetric eq (Equivalence.transitive eq (*WellDefined (Equivalence.reflexive eq) (Equivalence.transitive eq (absWellDefined _ _ (Equivalence.symmetric eq pr)) absZeroIsZero)) timesZero)))) (Equivalence.reflexive eq) 0<e
ans''' : abs ((index a m * index b m) + inverse (index a n * index b n)) < e
ans''' with triangleInequality (index a m * (index b m + inverse (index b n))) (index b n * (index a m + inverse (index a n)))
... | inl less = <WellDefined (Equivalence.symmetric eq (absWellDefined ((index a m * index b m) + (inverse (index a n * index b n))) (((index a m) * (index b m + (inverse (index b n)))) + ((index b n) * (index a m + inverse (index a n)))) littleLemma)) (Equivalence.reflexive eq) (SetoidPartialOrder.<Transitive pOrder less (<WellDefined (+WellDefined (Equivalence.symmetric eq (absRespectsTimes (index a m) _)) (Equivalence.symmetric eq (absRespectsTimes (index b n) _))) (Equivalence.reflexive eq) p))
... | inr equal = <WellDefined {_ + _} {abs _} {e} {e} (symmetric (transitive (transitive (absWellDefined ((index a m * index b m) + (inverse (index a n * index b n))) (((index a m) * (index b m + (inverse (index b n)))) + ((index b n) * (index a m + inverse (index a n)))) littleLemma) equal) (+WellDefined (absRespectsTimes (index a m) _) (absRespectsTimes (index b n) _)))) reflexive p
_*C_ : CauchyCompletion → CauchyCompletion → CauchyCompletion
CauchyCompletion.elts (record { elts = a ; converges = aConv } *C record { elts = b ; converges = bConv }) = apply _*_ a b
CauchyCompletion.converges (a *C b) = timesConverges a b
*CCommutative : {a b : CauchyCompletion} → Setoid._∼_ cauchyCompletionSetoid (a *C b) (b *C a)
*CCommutative {a} {b} ε 0<e = 0 , ans
where
foo : {x y : A} → (x * y) + inverse (y * x) ∼ 0G
foo = Equivalence.transitive eq (+WellDefined (Equivalence.reflexive eq) (inverseWellDefined additiveGroup *Commutative)) invRight
ans : {m : ℕ} → 0 <N m → abs (index (apply _+_ (CauchyCompletion.elts (a *C b)) (map inverse (CauchyCompletion.elts (b *C a)))) m) < ε
ans {m} 0<m rewrite indexAndApply (apply _*_ (CauchyCompletion.elts a) (CauchyCompletion.elts b)) (map inverse (apply _*_ (CauchyCompletion.elts b) (CauchyCompletion.elts a))) _+_ {m} | indexAndApply (CauchyCompletion.elts a) (CauchyCompletion.elts b) _*_ {m} | equalityCommutative (mapAndIndex (apply _*_ (CauchyCompletion.elts b) (CauchyCompletion.elts a)) inverse m) | indexAndApply (CauchyCompletion.elts b) (CauchyCompletion.elts a) _*_ {m} = <WellDefined (Equivalence.symmetric eq (Equivalence.transitive eq (absWellDefined _ _ foo) (identityOfIndiscernablesRight _∼_ (Equivalence.reflexive eq) absZero))) (Equivalence.reflexive eq) 0<e
private
multiplicationWellDefinedLeft' : (0!=1 : 0R ∼ 1R → False) (a b c : CauchyCompletion) → Setoid._∼_ cauchyCompletionSetoid a b → Setoid._∼_ cauchyCompletionSetoid (a *C c) (b *C c)
multiplicationWellDefinedLeft' 0!=1 a b c a=b ε 0<e = N , ans
where
abstract
cBoundAndPr : Sg A (λ b → Sg ℕ (λ N → (m : ℕ) → (N <N m) → (abs (index (CauchyCompletion.elts c) m)) < b))
cBoundAndPr = boundModulus c
cBound : A
cBound with cBoundAndPr
... | a , _ = a
cBoundN : ℕ
cBoundN with cBoundAndPr
... | _ , (N , _) = N
cBoundPr : (m : ℕ) → (cBoundN <N m) → (abs (index (CauchyCompletion.elts c) m)) < cBound
cBoundPr with cBoundAndPr
... | _ , (_ , pr) = pr
0<cBound : 0G < cBound
0<cBound with totality 0G cBound
0<cBound | inl (inl 0<cBound) = 0<cBound
0<cBound | inl (inr cBound<0) = exFalso (absNonnegative (SetoidPartialOrder.<Transitive pOrder (cBoundPr (succ cBoundN) (le 0 refl)) cBound<0))
0<cBound | inr 0=cBound = exFalso (absNonnegative (<WellDefined (Equivalence.reflexive eq) (Equivalence.symmetric eq 0=cBound) (cBoundPr (succ cBoundN) (le 0 refl))))
e/c : A
e/c with allInvertible cBound (λ pr → irreflexive (<WellDefined (Equivalence.reflexive eq) pr 0<cBound))
... | (1/c , _) = ε * 1/c
e/cPr : e/c * cBound ∼ ε
e/cPr with allInvertible cBound (λ pr → irreflexive (<WellDefined (Equivalence.reflexive eq) pr 0<cBound))
... | (1/c , pr) = Equivalence.transitive eq (Equivalence.transitive eq (Equivalence.transitive eq (Equivalence.symmetric eq *Associative) (*WellDefined (Equivalence.reflexive eq) pr)) *Commutative) (identIsIdent)
0<e/c : 0G < e/c
0<e/c = ringCanCancelPositive {0G} {e/c} 0<cBound (<WellDefined (Equivalence.symmetric eq (Equivalence.transitive eq *Commutative timesZero)) (Equivalence.symmetric eq e/cPr) 0<e)
abBound : ℕ
abBound with a=b e/c 0<e/c
... | Na=b , _ = Na=b
abPr : {m : ℕ} → (abBound <N m) → abs (index (apply _+_ (CauchyCompletion.elts a) (map inverse (CauchyCompletion.elts b))) m) < e/c
abPr with a=b e/c 0<e/c
... | Na=b , pr = pr
N : ℕ
N = abBound +N cBoundN
cBounded : (m : ℕ) → (N <N m) → abs (index (CauchyCompletion.elts c) m) < cBound
cBounded m N<m = cBoundPr m (inequalityShrinkRight N<m)
a-bSmall : (m : ℕ) → N <N m → abs ((index (CauchyCompletion.elts a) m) + inverse (index (CauchyCompletion.elts b) m)) < e/c
a-bSmall m N<m = <WellDefined (absWellDefined _ _ (transitive (identityOfIndiscernablesLeft _∼_ reflexive (equalityCommutative (indexAndApply (CauchyCompletion.elts a) (map inverse (CauchyCompletion.elts b)) _+_ {m}))) (+WellDefined reflexive (identityOfIndiscernablesLeft _∼_ reflexive (mapAndIndex (CauchyCompletion.elts b) inverse m))))) reflexive (abPr {m} (inequalityShrinkLeft N<m))
ans : {m : ℕ} → N <N m → abs (index (apply _+_ (apply _*_ (CauchyCompletion.elts a) (CauchyCompletion.elts c)) (map inverse (apply _*_ (CauchyCompletion.elts b) (CauchyCompletion.elts c)))) m) < ε
ans {m} N<m = <WellDefined (absWellDefined _ _ (transitive (+WellDefined (identityOfIndiscernablesLeft _∼_ reflexive (indexAndApply _ _ _*_ {m})) (transitive (transitive (ringMinusExtracts' R) (inverseWellDefined additiveGroup (identityOfIndiscernablesRight _∼_ reflexive (equalityCommutative (indexAndApply _ _ _*_ {m}))))) (identityOfIndiscernablesLeft _∼_ reflexive (equalityCommutative (mapAndIndex _ inverse m))))) (identityOfIndiscernablesLeft _∼_ reflexive (indexAndApply _ _ _+_ {m})))) reflexive (<WellDefined (absWellDefined ((index (CauchyCompletion.elts a) m + inverse (index (CauchyCompletion.elts b) m)) * index (CauchyCompletion.elts c) m) _ (Equivalence.transitive eq (Equivalence.transitive eq *Commutative *DistributesOver+) (+WellDefined *Commutative *Commutative))) (Equivalence.reflexive eq) (<WellDefined (Equivalence.symmetric eq (absRespectsTimes _ _)) (Equivalence.reflexive eq) (<WellDefined (Equivalence.reflexive eq) e/cPr (ans' (index (CauchyCompletion.elts a) m) (index (CauchyCompletion.elts b) m) (index (CauchyCompletion.elts c) m) (a-bSmall m N<m) (cBounded m N<m)))))
where
ans' : (a b c : A) → abs (a + inverse b) < e/c → abs c < cBound → (abs (a + inverse b) * abs c) < (e/c * cBound)
ans' a b c a-b<e/c c<bound with totality 0R c
ans' a b c a-b<e/c c<bound | inl (inl 0<c) with totality 0G (a + inverse b)
ans' a b c a-b<e/c c<bound | inl (inl 0<c) | inl (inl 0<a-b) = ringMultiplyPositives 0<a-b 0<c a-b<e/c c<bound
ans' a b c a-b<e/c c<bound | inl (inl 0<c) | inl (inr a-b<0) = ringMultiplyPositives (lemm2 (a + inverse b) a-b<0) 0<c a-b<e/c c<bound
ans' a b c a-b<e/c c<bound | inl (inl 0<c) | inr 0=a-b = <WellDefined (Equivalence.symmetric eq (Equivalence.transitive eq (*WellDefined (Equivalence.symmetric eq 0=a-b) (Equivalence.reflexive eq)) (Equivalence.transitive eq *Commutative timesZero))) (Equivalence.reflexive eq) (orderRespectsMultiplication 0<e/c 0<cBound)
ans' a b c a-b<e/c c<bound | inl (inr c<0) with totality 0G (a + inverse b)
ans' a b c a-b<e/c c<bound | inl (inr c<0) | inl (inl 0<a-b) = ringMultiplyPositives 0<a-b (lemm2 c c<0) a-b<e/c c<bound
ans' a b c a-b<e/c c<bound | inl (inr c<0) | inl (inr a-b<0) = ringMultiplyPositives (lemm2 (a + inverse b) a-b<0) (lemm2 c c<0) a-b<e/c c<bound
ans' a b c a-b<e/c c<bound | inl (inr c<0) | inr 0=a-b = <WellDefined (Equivalence.symmetric eq (Equivalence.transitive eq (*WellDefined (Equivalence.symmetric eq 0=a-b) (Equivalence.reflexive eq)) (Equivalence.transitive eq *Commutative timesZero))) (Equivalence.reflexive eq) (orderRespectsMultiplication 0<e/c 0<cBound)
ans' a b c a-b<e/c c<bound | inr 0=c = <WellDefined (Equivalence.symmetric eq (Equivalence.transitive eq (*WellDefined (Equivalence.reflexive eq) (Equivalence.symmetric eq 0=c)) timesZero)) (Equivalence.reflexive eq) (orderRespectsMultiplication 0<e/c 0<cBound)
multiplicationWellDefinedLeft : (a b c : CauchyCompletion) → Setoid._∼_ cauchyCompletionSetoid a b → Setoid._∼_ cauchyCompletionSetoid (a *C c) (b *C c)
multiplicationWellDefinedLeft with totality 0R 1R
... | inl (inl 0<1') = multiplicationWellDefinedLeft' (λ pr → irreflexive {0G} (<WellDefined (Equivalence.reflexive eq) (Equivalence.symmetric eq pr) 0<1'))
... | inl (inr 1<0) = multiplicationWellDefinedLeft' (λ pr → irreflexive {0G} (<WellDefined (Equivalence.symmetric eq pr) (Equivalence.reflexive eq) 1<0))
... | inr (0=1) = λ a b c a=b → Equivalence.transitive (Setoid.eq cauchyCompletionSetoid) {a *C c} {injection 0G} {b *C c} (Equivalence.symmetric (Setoid.eq cauchyCompletionSetoid) {injection 0G} {a *C c} (trivialIfInputTrivial 0=1 (a *C c))) (trivialIfInputTrivial 0=1 (b *C c))
multiplicationPreservedLeft : {a b : A} {c : CauchyCompletion} → (a ∼ b) → Setoid._∼_ cauchyCompletionSetoid (injection a *C c) (injection b *C c)
multiplicationPreservedLeft {a} {b} {c} a=b = multiplicationWellDefinedLeft (injection a) (injection b) c (injectionPreservesSetoid a b a=b)
multiplicationPreservedRight : {a b : A} {c : CauchyCompletion} → (a ∼ b) → Setoid._∼_ cauchyCompletionSetoid (c *C injection a) (c *C injection b)
multiplicationPreservedRight {a} {b} {c} a=b = Equivalence.transitive (Setoid.eq cauchyCompletionSetoid) {c *C injection a} {injection a *C c} {c *C injection b} (*CCommutative {c} {injection a}) (Equivalence.transitive (Setoid.eq cauchyCompletionSetoid) {injection a *C c} {injection b *C c} {c *C injection b} (multiplicationPreservedLeft {a} {b} {c} a=b) (*CCommutative {injection b} {c}))
multiplicationPreserved : {a b c d : A} → (a ∼ b) → (c ∼ d) → Setoid._∼_ cauchyCompletionSetoid (injection a *C injection c) (injection b *C injection d)
multiplicationPreserved {a} {b} {c} {d} a=b c=d = Equivalence.transitive (Setoid.eq cauchyCompletionSetoid) {injection a *C injection c} {injection a *C injection d} {injection b *C injection d} (multiplicationPreservedRight {c} {d} {injection a} c=d) (multiplicationPreservedLeft {a} {b} {injection d} a=b)
private
multiplicationWellDefinedRight : (a b c : CauchyCompletion) → Setoid._∼_ cauchyCompletionSetoid b c → Setoid._∼_ cauchyCompletionSetoid (a *C b) (a *C c)
multiplicationWellDefinedRight a b c b=c = Equivalence.transitive (Setoid.eq cauchyCompletionSetoid) {a *C b} {b *C a} {a *C c} (*CCommutative {a} {b}) (Equivalence.transitive (Setoid.eq cauchyCompletionSetoid) {b *C a} {c *C a} {a *C c} (multiplicationWellDefinedLeft b c a b=c) (*CCommutative {c} {a}))
multiplicationWellDefined : {a b c d : CauchyCompletion} → Setoid._∼_ cauchyCompletionSetoid a b → Setoid._∼_ cauchyCompletionSetoid c d → Setoid._∼_ cauchyCompletionSetoid (a *C c) (b *C d)
multiplicationWellDefined {a} {b} {c} {d} a=b c=d = Equivalence.transitive (Setoid.eq cauchyCompletionSetoid) {a *C c} {a *C d} {b *C d} (multiplicationWellDefinedRight a c d c=d) (multiplicationWellDefinedLeft a b d a=b)
| {
"alphanum_fraction": 0.6828117629,
"avg_line_length": 102.979757085,
"ext": "agda",
"hexsha": "6c53cd331addf0c4722db280150b5c99fa494341",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Smaug123/agdaproofs",
"max_forks_repo_path": "Fields/CauchyCompletion/Multiplication.agda",
"max_issues_count": 14,
"max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Smaug123/agdaproofs",
"max_issues_repo_path": "Fields/CauchyCompletion/Multiplication.agda",
"max_line_length": 1174,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Smaug123/agdaproofs",
"max_stars_repo_path": "Fields/CauchyCompletion/Multiplication.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z",
"num_tokens": 8343,
"size": 25436
} |
open import Common.IO
open import Common.Unit
open import Common.String
-- Currently, it is not actually a test.
-- I need a wat to check that Erasure does not happen when it normally would.
{-# FOREIGN OCaml
type i =
| Bar of string;;
#-}
data I : Set where
bar : String → I
{-# COMPILE OCaml I No-Erasure #-}
showI : I → String
showI (bar x) = x
main : IO Unit
main = putStr (showI (bar "hello")) >>= λ _ → return unit
| {
"alphanum_fraction": 0.6590389016,
"avg_line_length": 16.1851851852,
"ext": "agda",
"hexsha": "0c32a71f9c7c0305622c718fdf3e7e8b9583241a",
"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": "026a8f8473ab91f99c3f6545728e71fa847d2720",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "xekoukou/agda-ocaml",
"max_forks_repo_path": "test/Compiler/simple/Issue3732.agda",
"max_issues_count": 16,
"max_issues_repo_head_hexsha": "026a8f8473ab91f99c3f6545728e71fa847d2720",
"max_issues_repo_issues_event_max_datetime": "2019-09-08T13:47:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-10-08T00:32:04.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "xekoukou/agda-ocaml",
"max_issues_repo_path": "test/Compiler/simple/Issue3732.agda",
"max_line_length": 77,
"max_stars_count": 7,
"max_stars_repo_head_hexsha": "026a8f8473ab91f99c3f6545728e71fa847d2720",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "xekoukou/agda-ocaml",
"max_stars_repo_path": "test/Compiler/simple/Issue3732.agda",
"max_stars_repo_stars_event_max_datetime": "2018-11-06T16:38:43.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-11-05T22:13:36.000Z",
"num_tokens": 126,
"size": 437
} |
------------------------------------------------------------------------------
-- The LTC-PCF Booleans type
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
-- N.B. This module is re-exported by LTC-Bool.Data.Bool.
module LTC-PCF.Data.Bool.Type where
open import LTC-PCF.Base
------------------------------------------------------------------------------
-- The LTC-PCF Booleans type (inductive predicate for total Booleans).
data Bool : D → Set where
btrue : Bool true
bfalse : Bool false
-- The rule of proof by case analysis.
Bool-ind : (A : D → Set) → A true → A false → ∀ {b} → Bool b → A b
Bool-ind A At Af btrue = At
Bool-ind A At Af bfalse = Af
| {
"alphanum_fraction": 0.4491916859,
"avg_line_length": 33.3076923077,
"ext": "agda",
"hexsha": "2b646c18dcf139340e82bd9abe852e11a569ba4c",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z",
"max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/fotc",
"max_forks_repo_path": "src/fot/LTC-PCF/Data/Bool/Type.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/fotc",
"max_issues_repo_path": "src/fot/LTC-PCF/Data/Bool/Type.agda",
"max_line_length": 78,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "src/fot/LTC-PCF/Data/Bool/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": 181,
"size": 866
} |
-- An ATP conjecture cannot have duplicate local hints.
-- This error is detected by Syntax.Translation.ConcreteToAbstract.
module ATPBadLocalHint2 where
postulate
D : Set
foo : D
bar : D
{-# ATP prove foo bar bar #-}
| {
"alphanum_fraction": 0.7173913043,
"avg_line_length": 17.6923076923,
"ext": "agda",
"hexsha": "8ef7e6a1eec95ba80c70f767b352f38e54075a41",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "asr/eagda",
"max_forks_repo_path": "test/fail/ATPBadLocalHint2.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "asr/eagda",
"max_issues_repo_path": "test/fail/ATPBadLocalHint2.agda",
"max_line_length": 67,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "asr/eagda",
"max_stars_repo_path": "test/fail/ATPBadLocalHint2.agda",
"max_stars_repo_stars_event_max_datetime": "2016-03-17T01:45:59.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-03-17T01:45:59.000Z",
"num_tokens": 59,
"size": 230
} |
module tuple where
data ℕ : Set where
Z : ℕ
S : ℕ -> ℕ
_+_ : ℕ -> ℕ -> ℕ
n + Z = n
n + S m = S (n + m)
infixr 30 _+_
data Nil : Set where
[] : Nil
infix 20 _::_
data Cons (A B : Set) : Set where
_::_ : A -> B -> Cons A B
Tuple : Set -> ℕ -> Set
Tuple A Z = Nil
Tuple A (S n) = Cons A (Tuple A n)
sumℕTuple : {n : ℕ} -> Tuple ℕ n -> Tuple ℕ n -> Tuple ℕ n
sumℕTuple {Z} [] [] = []
sumℕTuple {S n} (m :: l) (m' :: l')
= m + m' :: (sumℕTuple l l')
| {
"alphanum_fraction": 0.4488188976,
"avg_line_length": 13.0256410256,
"ext": "agda",
"hexsha": "a41bf092db1b308cc8f9384990fb0f69e8f5c288",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "andrejtokarcik/agda-semantics",
"max_forks_repo_path": "tests/covered/tuple.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "andrejtokarcik/agda-semantics",
"max_issues_repo_path": "tests/covered/tuple.agda",
"max_line_length": 58,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "andrejtokarcik/agda-semantics",
"max_stars_repo_path": "tests/covered/tuple.agda",
"max_stars_repo_stars_event_max_datetime": "2018-12-06T17:24:25.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-08-10T15:33:56.000Z",
"num_tokens": 201,
"size": 508
} |
-- Andreas, 2012-09-15
module InstanceArgumentsDontDiscardCandidateUponUnsolvedConstraints where
import Common.Level
data ⊥ : Set where
record ⊤ : Set where
data Nat : Set where
zero : Nat
suc : Nat → Nat
_≤_ : Nat → Nat → Set
zero ≤ m = ⊤
(suc n) ≤ zero = ⊥
(suc n) ≤ (suc m) = n ≤ m
data Vec (A : Set) : Nat → Set where
[] : Vec A zero
_∷_ : {n : Nat} → A → Vec A n → Vec A (suc n)
lookup : {A : Set}{n : Nat} (m : Nat) {{m≤n : suc m ≤ n}} → Vec A n → A
lookup m {{()}} []
lookup zero (a ∷ as) = a
lookup (suc m) (a ∷ as) = lookup m as
-- the instance in the recursive call is only found
-- if the candiate m≤n : suc m ≤ _n is kept
-- until the blocking _n has been solved
| {
"alphanum_fraction": 0.585915493,
"avg_line_length": 24.4827586207,
"ext": "agda",
"hexsha": "6002112560e94d1b628ac5d730c34004ac10aa62",
"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/InstanceArgumentsDontDiscardCandidateUponUnsolvedConstraints.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/InstanceArgumentsDontDiscardCandidateUponUnsolvedConstraints.agda",
"max_line_length": 73,
"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/InstanceArgumentsDontDiscardCandidateUponUnsolvedConstraints.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": 266,
"size": 710
} |
module SN.AntiRename where
open import Relation.Unary using (_∈_; _⊆_)
open import Library
open import Terms
open import Substitution
open import SN
mutual
-- To formulate this, we need heterogeneous SNholes, going from Γ to Δ
-- unRenameSNh : ∀{a b Γ Δ} (ρ : Δ ≤ Γ) {t : Tm Γ b} {E : ECxt Γ a b} {t' : Tm Γ a} →
-- SNhole (subst ρ t) (λ t' → subst ρ (E t')) t' → SNhole t E t'
-- unRenameSNh = TODO
unRenameSNe : ∀{a Γ Δ} {ρ : Δ ≤ Γ} {t : Tm Γ a}{t'} → IndRen ρ t t' →
SNe t' → SNe t
unRenameSNe (var x x₁) (var y) = var x
unRenameSNe (app is is₁) (elim 𝒏 (appl 𝒖)) = elim (unRenameSNe is 𝒏) (appl (unRenameSN is₁ 𝒖))
unRenameSN : ∀{a Γ Δ} {ρ : Δ ≤ Γ} {t : Tm Γ a} {t'} → IndRen ρ t t'
→ SN t' → SN t
-- neutral cases:
unRenameSN n (ne 𝒏) = ne (unRenameSNe n 𝒏)
-- redex cases:
unRenameSN is (exp t⇒ 𝒕) = exp (unRename⇒1 is t⇒) (unRenameSN (proj₂ (unRename⇒0 is t⇒)) 𝒕)
-- constructor cases:
unRenameSN (abs t) (abs 𝒕) = abs (unRenameSN t 𝒕)
unRename⇒0 : ∀{a Γ Δ} {ρ : Δ ≤ Γ} {t : Tm Γ a} {t' : Tm Δ a}{tρ} → IndRen ρ t tρ
→ tρ ⟨ _ ⟩⇒ t' → Σ _ \ s → IndRen ρ s t'
unRename⇒0 {ρ = ρ} (app {u = u} (abs {t = t} is) is₁) (β 𝒖) = _ , prop→Ind ρ (≡.trans (≡.sym (sgs-lifts-term {σ = ρ} {u = u} {t = t}))
(≡.cong₂ (λ t₁ u₁ → subst (sgs u₁) t₁) (Ind→prop _ is) (Ind→prop _ is₁)))
unRename⇒0 (app is is₁) (cong (appl u) (appl .u) tρ→t') = let s , iss = unRename⇒0 is tρ→t' in app s _ , app iss is₁
unRename⇒1 : ∀{a Γ Δ} {ρ : Δ ≤ Γ} {t : Tm Γ a} {t' : Tm Δ a}{tρ} → (is : IndRen ρ t tρ)
→ (t⇒ : tρ ⟨ _ ⟩⇒ t') → t ⟨ _ ⟩⇒ proj₁ (unRename⇒0 is t⇒)
unRename⇒1 (app (abs is) is₁) (β 𝒖) = β (unRenameSN is₁ 𝒖)
unRename⇒1 (app is is₁) (cong (appl u) (appl .u) tρ→t') = cong (appl _) (appl _) (unRename⇒1 is tρ→t')
-- Extensionality of SN for function types:
-- If t x ∈ SN then t ∈ SN.
absVarSNe : ∀{Γ a b}{t : Tm (a ∷ Γ) (a →̂ b)} → app t (var (zero)) ∈ SNe → t ∈ SNe
absVarSNe (elim 𝒏 (appl 𝒖)) = 𝒏
absVarSN : ∀{Γ a b}{t : Tm (a ∷ Γ) (a →̂ b)} → app t (var (zero)) ∈ SN → t ∈ SN
absVarSN (ne 𝒖) = ne (absVarSNe 𝒖)
absVarSN (exp (β {t = t} 𝒖) 𝒕′) = abs (unRenameSN (prop→Ind contract (subst-ext contract-sgs t)) 𝒕′)
absVarSN (exp (cong (appl ._) (appl ._) t⇒) 𝒕′) = exp t⇒ (absVarSN 𝒕′)
| {
"alphanum_fraction": 0.4996003197,
"avg_line_length": 45.4909090909,
"ext": "agda",
"hexsha": "7653611fe99b3b13d2e6737bff5755785530ee53",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2018-02-23T18:22:17.000Z",
"max_forks_repo_forks_event_min_datetime": "2017-11-10T16:44:52.000Z",
"max_forks_repo_head_hexsha": "79d97481f3312c2d30a823c3b1bcb8ae871c2fe2",
"max_forks_repo_licenses": [
"Unlicense"
],
"max_forks_repo_name": "ryanakca/strong-normalization",
"max_forks_repo_path": "agda-aplas14/SN/AntiRename.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "79d97481f3312c2d30a823c3b1bcb8ae871c2fe2",
"max_issues_repo_issues_event_max_datetime": "2018-02-20T14:54:18.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-02-14T16:42:36.000Z",
"max_issues_repo_licenses": [
"Unlicense"
],
"max_issues_repo_name": "ryanakca/strong-normalization",
"max_issues_repo_path": "agda-aplas14/SN/AntiRename.agda",
"max_line_length": 143,
"max_stars_count": 32,
"max_stars_repo_head_hexsha": "79d97481f3312c2d30a823c3b1bcb8ae871c2fe2",
"max_stars_repo_licenses": [
"Unlicense"
],
"max_stars_repo_name": "ryanakca/strong-normalization",
"max_stars_repo_path": "agda-aplas14/SN/AntiRename.agda",
"max_stars_repo_stars_event_max_datetime": "2021-03-05T12:12:03.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-05-22T14:33:27.000Z",
"num_tokens": 1116,
"size": 2502
} |
-- Andreas, 2016-12-29, issue #2363
data Nat : Set where
zero : Nat
suc : Nat → Nat
test : Nat → Nat
test (suc n) with zero
test zero | q = zero
test zero = zero
-- Error WAS:
-- With clause pattern zero is not an instance of its parent pattern (suc "n")
-- Expected error:
-- With clause pattern zero is not an instance of its parent pattern (suc n)
| {
"alphanum_fraction": 0.6768802228,
"avg_line_length": 21.1176470588,
"ext": "agda",
"hexsha": "72a69c2a6890865d66099d3dd4f595e7358f6a2b",
"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/Issue2363.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/Issue2363.agda",
"max_line_length": 78,
"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/Issue2363.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": 106,
"size": 359
} |
module Oscar.Class.AlphaConversion where
open import Oscar.Data.Nat
open import Oscar.Data.Fin
open import Oscar.Data.Equality
open import Oscar.Function
open import Oscar.Relation
open import Oscar.Level
record AlphaConversion {a} {A : Set a} {b} (B : A → Set b) {c} (C : A → Set c) : Set (a ⊔ b ⊔ c) where
infixr 19 _◂_
field
_◂_ : ∀ {m n} → m ⟨ B ⟩→ n → m ⟨ C ⟩→ n
◂-identity : ∀ {m} (x : C m) → id ◂ x ≡ x
◂-associativity : ∀ {l m n} (f : l ⟨ B ⟩→ m) (g : m ⟨ B ⟩→ n) (x : C l) → (g ∘ f) ◂ x ≡ g ◂ f ◂ x
◂-extensionality : ∀ {m n} {f g : m ⟨ B ⟩→ n} → f ≡̇ g → f ◂_ ≡̇ g ◂_
open AlphaConversion ⦃ … ⦄ public
instance AlphaConversion⋆ : ∀ {a} {A : Set a} {bc} {BC : A → Set bc} → AlphaConversion BC BC
AlphaConversion._◂_ AlphaConversion⋆ = id
AlphaConversion.◂-identity AlphaConversion⋆ _ = refl
AlphaConversion.◂-associativity AlphaConversion⋆ _ _ _ = refl
AlphaConversion.◂-extensionality AlphaConversion⋆ f≡̇g x = f≡̇g x
| {
"alphanum_fraction": 0.6149003148,
"avg_line_length": 36.6538461538,
"ext": "agda",
"hexsha": "d661ff09a47cce4c804915a2cd902fda9fa265a7",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_forks_repo_licenses": [
"RSA-MD"
],
"max_forks_repo_name": "m0davis/oscar",
"max_forks_repo_path": "archive/agda-2/Oscar/Class/AlphaConversion.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z",
"max_issues_repo_licenses": [
"RSA-MD"
],
"max_issues_repo_name": "m0davis/oscar",
"max_issues_repo_path": "archive/agda-2/Oscar/Class/AlphaConversion.agda",
"max_line_length": 102,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_stars_repo_licenses": [
"RSA-MD"
],
"max_stars_repo_name": "m0davis/oscar",
"max_stars_repo_path": "archive/agda-2/Oscar/Class/AlphaConversion.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 386,
"size": 953
} |
{-# OPTIONS --cubical --safe #-}
module Cubical.Data.Sigma.Base where
open import Cubical.Core.Primitives public
-- Σ-types are defined in Core/Primitives as they are needed for Glue types.
_×_ : ∀ {ℓ ℓ'} (A : Type ℓ) (B : Type ℓ') → Type (ℓ-max ℓ ℓ')
A × B = Σ A (λ _ → B)
infixr 5 _×_
| {
"alphanum_fraction": 0.6404109589,
"avg_line_length": 22.4615384615,
"ext": "agda",
"hexsha": "46c3087a93e70122ae6e84511ee04167281ed711",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cmester0/cubical",
"max_forks_repo_path": "Cubical/Data/Sigma/Base.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cmester0/cubical",
"max_issues_repo_path": "Cubical/Data/Sigma/Base.agda",
"max_line_length": 76,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cmester0/cubical",
"max_stars_repo_path": "Cubical/Data/Sigma/Base.agda",
"max_stars_repo_stars_event_max_datetime": "2020-03-23T23:52:11.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-03-23T23:52:11.000Z",
"num_tokens": 104,
"size": 292
} |
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module StrictApplication where
open import Data.Nat
{-# NON_TERMINATING #-}
loop : ℕ
loop = loop
foo : ℕ
foo = (λ _ → 0) loop
| {
"alphanum_fraction": 0.5529801325,
"avg_line_length": 18.875,
"ext": "agda",
"hexsha": "941796b213a6efe33893d7c635f3086491185aa9",
"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/strict-evaluation/StrictApplication.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/strict-evaluation/StrictApplication.agda",
"max_line_length": 42,
"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/strict-evaluation/StrictApplication.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": 71,
"size": 302
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.