Search is not available for this dataset
text
string | meta
dict |
---|---|
module Oscar.Data.Proposequality where
open import Agda.Builtin.Equality public using (_≡_) renaming (refl to ∅) public
open import Relation.Binary.PropositionalEquality public using (_≢_) public
open import Oscar.Category.Setoid
open import Relation.Binary.PropositionalEquality using (sym; trans)
open import Oscar.Level
open import Oscar.Relation
instance
IsSetoidProposequality : ∀ {a} {A : Set a} → IsSetoid (_≡_ {A = A})
IsSetoid.reflexivity IsSetoidProposequality _ = ∅
IsSetoid.symmetry IsSetoidProposequality = sym
IsSetoid.transitivity IsSetoidProposequality = λ ‵ → trans ‵
module _ {a} (A : Set a) where
setoid : Setoid a a
setoid = ↑ _≡_ {A = A}
{-
private
infixl 7 _∙_
_∙_ : Transitive (_≡_ {A = A})
_∙_ = (λ y≡z x≡y → transitivity x≡y y≡z)
-}
open import Oscar.Category.Morphism
open import Oscar.Function
module _ {b} (B : A → A → Set b) where
{-
private
infix 4 _≞_
_≞_ = λ {x} {y} → _≡_ {A = B x y}
-}
morphism : Morphism a b b
morphism = -- ↑ λ {x} {y} → _≞_ {x} {y} -- _≡_ {A = B x y}
↑ λ {x} {y} → _≡_ {A = B x y}
open Morphism morphism
open import Oscar.Category.Semigroupoid
module _ (_∙_ : Transitive _↦_) (associativity : Associative _∙_ _≞_) where
instance
IsSemigroupoidProposequality : IsSemigroupoid morphism _∙_
IsSemigroupoid.extensionality IsSemigroupoidProposequality ∅ ∅ = ∅
IsSemigroupoid.associativity IsSemigroupoidProposequality = associativity
-- instance
-- IsSemigroupoidProposequality : ∀ {a} {A : Set a} {b} {B : A → A → Set b}
-- → IsSemigroupoid (morphism B) {!!} -- (transitivity ⦃ setoid A ⦄)
-- IsSemigroupoidProposequality = {!!}
-- IsSemigroupoidProposequality' : ∀ {a} {A : Set a}
-- → IsSemigroupoid (morphism (_≡_ {A = A})) (λ y≡z x≡y → transitivity x≡y y≡z) -- (transitivity ⦃ setoid A ⦄)
-- IsSemigroupoid.extensionality IsSemigroupoidProposequality' = {!!} -- ∅ ∅ = ∅
-- IsSemigroupoid.associativity IsSemigroupoidProposequality' ∅ _ _ = ∅
-- -- semigroupoid : Semigroupoid
-- -- setoid : ∀ {a} (A : Set a) → Setoid a a
-- -- setoid A = ↑ _≡_ {A = A}
-- -- open import Oscar.Category.Morphism
-- -- open import Oscar.Function
-- -- morphism : ∀ {a} {A : Set a} {b} (B : A → A → Set b) → Morphism a b b
-- -- morphism B = ↑ λ {x} {y} → _≡_ {A = B x y}
-- -- open import Oscar.Category.Semigroupoid
-- -- infixl 7 _∙_
-- -- _∙_ : ∀ {y z} → y ↦ z → ∀ {x} → x ↦ y → x ↦ z
-- -- instance
-- -- IsSemigroupoidProposequality : ∀ {a} {A : Set a} {b} {B : A → A → Set b}
-- -- → IsSemigroupoid (morphism B) {!!} -- (transitivity ⦃ setoid A ⦄)
-- -- IsSemigroupoidProposequality = {!!}
-- -- IsSemigroupoidProposequality' : ∀ {a} {A : Set a}
-- -- → IsSemigroupoid (morphism (_≡_ {A = A})) (λ y≡z x≡y → transitivity x≡y y≡z) -- (transitivity ⦃ setoid A ⦄)
-- -- IsSemigroupoid.extensionality IsSemigroupoidProposequality' = {!!} -- ∅ ∅ = ∅
-- -- IsSemigroupoid.associativity IsSemigroupoidProposequality' ∅ _ _ = ∅
-- -- -- semigroupoid : Semigroupoid
| {
"alphanum_fraction": 0.6207008436,
"avg_line_length": 30.2156862745,
"ext": "agda",
"hexsha": "4c2a904250643b13d61de5e8f4881608767bede1",
"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/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-2/Oscar/Data/Proposequality.agda",
"max_line_length": 117,
"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/Data/Proposequality.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1121,
"size": 3082
} |
-- Andreas, 2017-01-27, issue #2437
-- Polarity checker turns Nonvariant to Unused arg in types,
-- thus, reducing them.
-- However, this should not happen without need.
-- We wish to preserve the types as much as possible.
-- {-# OPTIONS -v 20 #-}
-- {-# OPTIONS -v tc.polarity:30 #-}
-- {-# OPTIONS -v tc.decl:30 #-}
-- {-# OPTIONS -v tc.term:30 #-}
-- {-# OPTIONS -v tc.conv.coerce:20 #-}
-- {-# OPTIONS -v tc.signature:30 #-}
-- {-# OPTIONS -v import.iface:100 #-}
open import Agda.Primitive
open import Agda.Builtin.Nat
open import Agda.Builtin.Equality
plus0 : ∀ x → x + 0 ≡ x
plus0 zero = refl
plus0 (suc x) rewrite plus0 x = refl
Identity : ∀{a} {A : Set a} (f : A → A) → Set a
Identity f = ∀ x → f x ≡ x
plus-0 : Identity (_+ 0)
plus-0 = plus0
-- Test (interactive): C-c C-d plus-0 RET
-- Expected: Identity (λ section → section + 0)
-- Type should be inferred non-reduced, i.e, not as
-- ∀ x → x + 0 ≡ x
| {
"alphanum_fraction": 0.6176154672,
"avg_line_length": 27.3823529412,
"ext": "agda",
"hexsha": "1a0fe91f86617a9a57f3931a8300774fcdef07df",
"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/Issue2437.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/Issue2437.agda",
"max_line_length": 60,
"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/Issue2437.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": 303,
"size": 931
} |
{-# OPTIONS --safe #-}
module Cubical.Algebra.CommMonoid.Properties 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.Structures.Axioms
open import Cubical.Structures.Auto
open import Cubical.Structures.Macro
open import Cubical.Algebra.Semigroup
open import Cubical.Algebra.Monoid
open import Cubical.Algebra.CommMonoid.Base
private
variable
ℓ : Level
module CommMonoidTheory (M' : CommMonoid ℓ) where
open CommMonoidStr (snd M')
private M = ⟨ M' ⟩
commAssocl : (x y z : M) → x · (y · z) ≡ y · (x · z)
commAssocl x y z = assoc x y z ∙∙ cong (_· z) (comm x y) ∙∙ sym (assoc y x z)
commAssocr : (x y z : M) → x · y · z ≡ x · z · y
commAssocr x y z = sym (assoc x y z) ∙∙ cong (x ·_) (comm y z) ∙∙ assoc x z y
commAssocr2 : (x y z : M) → x · y · z ≡ z · y · x
commAssocr2 x y z = commAssocr _ _ _ ∙∙ cong (_· y) (comm _ _) ∙∙ commAssocr _ _ _
commAssocSwap : (x y z w : M) → (x · y) · (z · w) ≡ (x · z) · (y · w)
commAssocSwap x y z w = assoc (x · y) z w ∙∙ cong (_· w) (commAssocr x y z)
∙∙ sym (assoc (x · z) y w)
| {
"alphanum_fraction": 0.6622284513,
"avg_line_length": 33.1860465116,
"ext": "agda",
"hexsha": "d85d44125090916ceb104299a4f8ab381707ab09",
"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/Algebra/CommMonoid/Properties.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/Algebra/CommMonoid/Properties.agda",
"max_line_length": 83,
"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/Algebra/CommMonoid/Properties.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": 486,
"size": 1427
} |
------------------------------------------------------------------------
-- The derivative operator does not remove any ambiguity
------------------------------------------------------------------------
module TotalParserCombinators.Derivative.RightInverse where
open import Data.List
open import Data.Maybe
open import Relation.Binary.HeterogeneousEquality as H using (_≅_; refl)
open import Relation.Binary.PropositionalEquality
open import TotalParserCombinators.Derivative.SoundComplete
import TotalParserCombinators.InitialBag as I
open import TotalParserCombinators.Lib
open import TotalParserCombinators.Parser
open import TotalParserCombinators.Semantics hiding (_≅_)
mutual
sound∘complete : ∀ {Tok R xs x s t} {p : Parser Tok R xs} →
(x∈p : x ∈ p · t ∷ s) →
sound p (complete x∈p) ≡ x∈p
sound∘complete x∈p = H.≅-to-≡ (sound∘complete′ x∈p refl)
sound∘complete′ :
∀ {Tok R xs x s′ s t} {p : Parser Tok R xs}
(x∈p : x ∈ p · s′) (eq : s′ ≡ t ∷ s) →
sound p (complete′ p x∈p eq) ≅ x∈p
sound∘complete′ token refl = refl
sound∘complete′ (∣-left x∈p₁) refl rewrite sound∘complete x∈p₁ = refl
sound∘complete′ (∣-right _ x∈p₂) refl rewrite sound∘complete x∈p₂ = refl
sound∘complete′ (<$> x∈p) refl rewrite sound∘complete x∈p = refl
sound∘complete′ (_⊛_ {s₁ = _ ∷ _} {fs = nothing} {xs = just _} f∈p₁ x∈p₂) refl
rewrite sound∘complete f∈p₁ = refl
sound∘complete′ (_⊛_ {s₁ = _ ∷ _} {fs = just _} {xs = just _} f∈p₁ x∈p₂) refl
rewrite sound∘complete f∈p₁ = refl
sound∘complete′ {Tok} (_⊛_ {s₁ = []} {fs = just _} {xs = just _} f∈p₁ x∈p₂) refl
rewrite Return⋆.sound∘complete {Tok = Tok} (I.complete f∈p₁)
| I.sound∘complete f∈p₁
| sound∘complete x∈p₂ = refl
sound∘complete′ {p = _⊛_ {xs = nothing} _ _}
(_⊛_ {s₁ = _ ∷ _} {fs = nothing} {xs = nothing} f∈p₁ x∈p₂) refl
rewrite sound∘complete f∈p₁ = refl
sound∘complete′ (_⊛_ {s₁ = _ ∷ _} {fs = just _} {xs = nothing} f∈p₁ x∈p₂) refl
rewrite sound∘complete f∈p₁ = refl
sound∘complete′ {Tok} (_⊛_ {s₁ = []} {fs = just _} {xs = nothing} f∈p₁ x∈p₂) refl
rewrite Return⋆.sound∘complete {Tok = Tok} (I.complete f∈p₁)
| I.sound∘complete f∈p₁
| sound∘complete x∈p₂ = refl
sound∘complete′ (_>>=_ {s₁ = _ ∷ _} {xs = nothing} {f = just _} x∈p₁ y∈p₂x) refl
rewrite sound∘complete x∈p₁ = refl
sound∘complete′ (_>>=_ {s₁ = _ ∷ _} {xs = just _} {f = just _} x∈p₁ y∈p₂x) refl
rewrite sound∘complete x∈p₁ = refl
sound∘complete′ {Tok} (_>>=_ {s₁ = []} {xs = just _} {f = just _} x∈p₁ y∈p₂x) refl
rewrite Return⋆.sound∘complete {Tok = Tok} (I.complete x∈p₁)
| I.sound∘complete x∈p₁
| sound∘complete y∈p₂x = refl
sound∘complete′ {p = _>>=_ {xs = nothing} _ _}
(_>>=_ {s₁ = _ ∷ _} {xs = nothing} {f = nothing} x∈p₁ y∈p₂x) refl
rewrite sound∘complete x∈p₁ = refl
sound∘complete′ (_>>=_ {s₁ = _ ∷ _} {xs = just _} {f = nothing} x∈p₁ y∈p₂x) refl
rewrite sound∘complete x∈p₁ = refl
sound∘complete′ {Tok} (_>>=_ {s₁ = []} {xs = just _} {f = nothing} x∈p₁ y∈p₂x) refl
rewrite Return⋆.sound∘complete {Tok = Tok} (I.complete x∈p₁)
| I.sound∘complete x∈p₁
| sound∘complete y∈p₂x = refl
sound∘complete′ (nonempty x∈p) refl rewrite sound∘complete x∈p = refl
sound∘complete′ (cast x∈p) refl rewrite sound∘complete x∈p = refl
sound∘complete′ (_⊛_ {s₁ = []} {fs = nothing} f∈p₁ _) _ with I.complete f∈p₁
... | ()
sound∘complete′ (_>>=_ {s₁ = []} {xs = nothing} x∈p₁ _) _ with I.complete x∈p₁
... | ()
sound∘complete′ return ()
| {
"alphanum_fraction": 0.572158022,
"avg_line_length": 44.2976190476,
"ext": "agda",
"hexsha": "f76b2dd4f94eb8299bd82d12fb2b73f90a6dd6fc",
"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": "TotalParserCombinators/Derivative/RightInverse.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/parser-combinators",
"max_issues_repo_path": "TotalParserCombinators/Derivative/RightInverse.agda",
"max_line_length": 89,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/parser-combinators",
"max_stars_repo_path": "TotalParserCombinators/Derivative/RightInverse.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:13.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-07-03T08:56:13.000Z",
"num_tokens": 1442,
"size": 3721
} |
-- Copyright: (c) 2016 Ertugrul Söylemez
-- License: BSD3
-- Maintainer: Ertugrul Söylemez <[email protected]>
module Data.Nat.Core where
open import Agda.Builtin.Nat public
renaming (Nat to ℕ)
using (suc; zero)
renaming (_+_ to _+ℕ_; _*_ to _*ℕ_)
open import Classes
open import Core
instance
ℕ-Number : Number ℕ
ℕ-Number =
record {
Constraint = λ _ → ⊤;
fromNat = λ n → n
}
ℕ-Plus : Plus ℕ
ℕ-Plus = record { _+_ = _+ℕ_ }
ℕ-Times : Times ℕ
ℕ-Times = record { _*_ = _*ℕ_ }
ℕ,≡ : Equiv ℕ
ℕ,≡ = PropEq ℕ
module ℕ,≡ = Equiv ℕ,≡
data _≤_ : ℕ → ℕ → Set where
instance 0≤s : ∀ {y} → 0 ≤ y
instance s≤s : ∀ {x y} → x ≤ y → suc x ≤ suc y
infix 4 _≤_
ℕ,≤ : TotalOrder ℕ
ℕ,≤ =
record {
partialOrder = record {
Eq = PropEq ℕ;
_≤_ = _≤_;
antisym = antisym;
refl' = refl';
trans = trans
};
total = total
}
where
antisym : {x y : ℕ} → x ≤ y → y ≤ x → x ≡ y
antisym 0≤s 0≤s = ≡-refl
antisym (s≤s p) (s≤s q) = cong suc (antisym p q)
refl' : {x y : ℕ} → x ≡ y → x ≤ y
refl' {zero} ≡-refl = 0≤s
refl' {suc x} ≡-refl = s≤s (refl' ≡-refl)
trans : {x y z : ℕ} → x ≤ y → y ≤ z → x ≤ z
trans 0≤s q = 0≤s
trans (s≤s p) (s≤s q) = s≤s (trans p q)
total : (x y : ℕ) → Either (x ≤ y) (y ≤ x)
total zero y = Left 0≤s
total (suc x) zero = Right 0≤s
total (suc x) (suc y) with total x y
total (suc x) (suc y) | Left p = Left (s≤s p)
total (suc x) (suc y) | Right p = Right (s≤s p)
module ℕ,≤ = TotalOrder ℕ,≤
_≤?_ : ∀ x y → Decision (x ≤ y)
zero ≤? y = yes 0≤s
suc x ≤? zero = no (λ ())
suc x ≤? suc y with x ≤? y
suc x ≤? suc y | yes p = yes (s≤s p)
suc x ≤? suc y | no np = no (λ { (s≤s p) → np p })
_multiple-of_ : ℕ → ℕ → Set
x multiple-of y = ∃ (λ k → k * y ≡ x)
module Props where
open Equiv (PropEq ℕ)
private
_!+!_ : ∀ {x1 x2 y1 y2 : ℕ} → x1 ≡ x2 → y1 ≡ y2 → x1 + y1 ≡ x2 + y2
_!+!_ = cong2 _+_
R = λ x → refl {x = x}
infixl 6 _!+!_
+-assoc : ∀ x y z → (x + y) + z ≈ x + (y + z)
+-assoc zero y z = refl
+-assoc (suc x) y z = cong suc (+-assoc x y z)
+-left-id : ∀ x → 0 + x ≈ x
+-left-id _ = refl
+-right-id : ∀ x → x + 0 ≈ x
+-right-id zero = refl
+-right-id (suc x) = cong suc (+-right-id x)
+-comm : ∀ x y → x + y ≈ y + x
+-comm zero y = sym (+-right-id y)
+-comm (suc x) y =
begin
suc x + y ≈[ cong suc (+-comm x y) ]
suc y + x ≈[ sym (one-comm y x) ]
y + suc x
qed
where
one-comm : ∀ x y → x + suc y ≈ suc x + y
one-comm zero _ = refl
one-comm (suc x) y = cong suc (one-comm x y)
+-suc-assoc : ∀ x y → x + suc y ≈ suc (x + y)
+-suc-assoc x y =
begin
x + suc y ≈[ sym (+-assoc x 1 y) ]
(x + 1) + y ≈[ +-comm x 1 !+! R y ]
suc (x + y)
qed
*-+-left-dist : ∀ x a b → x * (a + b) ≈ x * a + x * b
*-+-left-dist zero a b = refl
*-+-left-dist (suc x) a b =
begin
a + b + x * (a + b) ≈[ R (a + b) !+! *-+-left-dist x a b ]
a + b + (x * a + x * b) ≈[ +-assoc a b _ ]
a + (b + (x * a + x * b)) ≈[
cong (a +_) $
b + (x * a + x * b) ≈[ sym (+-assoc b (x * a) (x * b)) ]
b + x * a + x * b ≈[ +-comm b _ !+! R (x * b) ]
x * a + b + x * b ≈[ +-assoc (x * a) _ _ ]
x * a + (b + x * b)
qed ]
a + (x * a + (b + x * b)) ≈[ sym (+-assoc a _ _) ]
a + x * a + (b + x * b)
qed
*-+-right-dist : ∀ a b x → (a + b) * x ≈ a * x + b * x
*-+-right-dist zero b x = refl
*-+-right-dist (suc a) b x =
begin
x + (a + b) * x ≈[ R x !+! *-+-right-dist a b x ]
x + (a * x + b * x) ≈[ sym (+-assoc x (a * x) (b * x)) ]
(x + a * x) + b * x
qed
*-assoc : ∀ x y z → (x * y) * z ≈ x * (y * z)
*-assoc zero y z = refl
*-assoc (suc x) y z =
begin
(y + x * y) * z ≈[ *-+-right-dist y (x * y) z ]
y * z + (x * y) * z ≈[ R (y * z) !+! *-assoc x y z ]
y * z + x * (y * z)
qed
*-left-id : ∀ x → 1 * x ≈ x
*-left-id = +-right-id
*-right-id : ∀ x → x * 1 ≈ x
*-right-id zero = refl
*-right-id (suc x) = cong suc (*-right-id x)
*-right-zero : ∀ x → x * 0 ≈ 0
*-right-zero zero = refl
*-right-zero (suc x) = *-right-zero x
*-comm : ∀ x y → x * y ≈ y * x
*-comm zero y = sym (*-right-zero y)
*-comm (suc x) zero = *-comm x zero
*-comm (suc x) (suc y) =
cong suc $
begin
y + x * suc y ≈[ R y !+! (*-+-left-dist x 1 y) ]
y + (x * 1 + x * y) ≈[ R y !+! (*-right-id x !+! R (x * y)) ]
y + (x + x * y) ≈[ sym (+-assoc y x (x * y)) ]
y + x + x * y ≈[ +-comm y x !+! *-comm x y ]
x + y + y * x ≈[ +-assoc x y (y * x) ]
x + (y + y * x) ≈[ R x !+! (sym (*-right-id y) !+! R (y * x)) ]
x + (y * 1 + y * x) ≈[ R x !+! sym (*-+-left-dist y 1 x) ]
x + y * suc x
qed
suc-inj : ∀ {x y} → suc x ≈ suc y → x ≈ y
suc-inj ≡-refl = refl
sum-mult : ∀ {x1 x2 y} → x1 multiple-of y → x2 multiple-of y → (x1 + x2) multiple-of y
sum-mult {x1} {x2} {y} (k1 , p1) (k2 , p2) =
k1 + k2
because:
(k1 + k2) * y ≈[ *-+-right-dist k1 k2 y ]
k1 * y + k2 * y ≈[ p1 !+! p2 ]
x1 + x2
qed
| {
"alphanum_fraction": 0.4303357777,
"avg_line_length": 25.4019607843,
"ext": "agda",
"hexsha": "873fe2469322d3a5e6ff8b0259e8644835c358c3",
"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": "d9245e5a8b2e902781736de09bd17e81022f6f13",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "esoeylemez/agda-simple",
"max_forks_repo_path": "Data/Nat/Core.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "d9245e5a8b2e902781736de09bd17e81022f6f13",
"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": "esoeylemez/agda-simple",
"max_issues_repo_path": "Data/Nat/Core.agda",
"max_line_length": 88,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "d9245e5a8b2e902781736de09bd17e81022f6f13",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "esoeylemez/agda-simple",
"max_stars_repo_path": "Data/Nat/Core.agda",
"max_stars_repo_stars_event_max_datetime": "2019-10-07T17:36:42.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-10-07T17:36:42.000Z",
"num_tokens": 2358,
"size": 5182
} |
------------------------------------------------------------------------
-- Some boring lemmas used by the ring solver
------------------------------------------------------------------------
-- Note that these proofs use all "almost commutative ring" properties
-- except for zero and -‿pres-≈.
open import Algebra
open import Algebra.RingSolver.AlmostCommutativeRing
module Algebra.RingSolver.Lemmas
(coeff : RawRing)
(r : AlmostCommutativeRing)
(morphism : coeff -Raw-AlmostCommutative⟶ r)
where
private
module C = RawRing coeff
open AlmostCommutativeRing r
open import Algebra.Morphism
open _-RawRing⟶_ morphism
import Relation.Binary.EqReasoning as EqR; open EqR setoid
open import Data.Function
open import Data.Product
lemma₀ : ∀ x → x + ⟦ C.0# ⟧ ≈ x
lemma₀ x = begin
x + ⟦ C.0# ⟧ ≈⟨ refl ⟨ +-pres-≈ ⟩ 0-homo ⟩
x + 0# ≈⟨ proj₂ +-identity _ ⟩
x ∎
lemma₁ : ∀ a b c d x →
(a + b) * x + (c + d) ≈ (a * x + c) + (b * x + d)
lemma₁ a b c d x = begin
(a + b) * x + (c + d) ≈⟨ proj₂ distrib _ _ _ ⟨ +-pres-≈ ⟩ refl ⟩
(a * x + b * x) + (c + d) ≈⟨ +-assoc _ _ _ ⟩
a * x + (b * x + (c + d)) ≈⟨ refl ⟨ +-pres-≈ ⟩ sym (+-assoc _ _ _) ⟩
a * x + ((b * x + c) + d) ≈⟨ refl ⟨ +-pres-≈ ⟩ (+-comm _ _ ⟨ +-pres-≈ ⟩ refl) ⟩
a * x + ((c + b * x) + d) ≈⟨ refl ⟨ +-pres-≈ ⟩ +-assoc _ _ _ ⟩
a * x + (c + (b * x + d)) ≈⟨ sym $ +-assoc _ _ _ ⟩
(a * x + c) + (b * x + d) ∎
lemma₂ : ∀ x y z → x + (y + z) ≈ y + (x + z)
lemma₂ x y z = begin
x + (y + z) ≈⟨ sym $ +-assoc _ _ _ ⟩
(x + y) + z ≈⟨ +-comm _ _ ⟨ +-pres-≈ ⟩ refl ⟩
(y + x) + z ≈⟨ +-assoc _ _ _ ⟩
y + (x + z) ∎
lemma₃ : ∀ a b c x → a * c * x + b * c ≈ (a * x + b) * c
lemma₃ a b c x = begin
a * c * x + b * c ≈⟨ lem ⟨ +-pres-≈ ⟩ refl ⟩
a * x * c + b * c ≈⟨ sym $ proj₂ distrib _ _ _ ⟩
(a * x + b) * c ∎
where
lem = begin
a * c * x ≈⟨ *-assoc _ _ _ ⟩
a * (c * x) ≈⟨ refl ⟨ *-pres-≈ ⟩ *-comm _ _ ⟩
a * (x * c) ≈⟨ sym $ *-assoc _ _ _ ⟩
a * x * c ∎
lemma₄ : ∀ a b c x → a * b * x + a * c ≈ a * (b * x + c)
lemma₄ a b c x = begin
a * b * x + a * c ≈⟨ *-assoc _ _ _ ⟨ +-pres-≈ ⟩ refl ⟩
a * (b * x) + a * c ≈⟨ sym $ proj₁ distrib _ _ _ ⟩
a * (b * x + c) ∎
lemma₅ : ∀ a b c d x →
a * c * x * x + ((a * d + b * c) * x + b * d) ≈
(a * x + b) * (c * x + d)
lemma₅ a b c d x = begin
a * c * x * x +
((a * d + b * c) * x + b * d) ≈⟨ lem₁ ⟨ +-pres-≈ ⟩
(lem₂ ⟨ +-pres-≈ ⟩ refl) ⟩
a * x * (c * x) +
(a * x * d + b * (c * x) + b * d) ≈⟨ refl ⟨ +-pres-≈ ⟩ +-assoc _ _ _ ⟩
a * x * (c * x) +
(a * x * d + (b * (c * x) + b * d)) ≈⟨ sym $ +-assoc _ _ _ ⟩
a * x * (c * x) + a * x * d +
(b * (c * x) + b * d) ≈⟨ sym $ proj₁ distrib _ _ _
⟨ +-pres-≈ ⟩
proj₁ distrib _ _ _ ⟩
a * x * (c * x + d) + b * (c * x + d) ≈⟨ sym $ proj₂ distrib _ _ _ ⟩
(a * x + b) * (c * x + d) ∎
where
lem₁' = begin
a * c * x ≈⟨ *-assoc _ _ _ ⟩
a * (c * x) ≈⟨ refl ⟨ *-pres-≈ ⟩ *-comm _ _ ⟩
a * (x * c) ≈⟨ sym $ *-assoc _ _ _ ⟩
a * x * c ∎
lem₁ = begin
a * c * x * x ≈⟨ lem₁' ⟨ *-pres-≈ ⟩ refl ⟩
a * x * c * x ≈⟨ *-assoc _ _ _ ⟩
a * x * (c * x) ∎
lem₂ = begin
(a * d + b * c) * x ≈⟨ proj₂ distrib _ _ _ ⟩
a * d * x + b * c * x ≈⟨ *-assoc _ _ _ ⟨ +-pres-≈ ⟩ *-assoc _ _ _ ⟩
a * (d * x) + b * (c * x) ≈⟨ (refl ⟨ *-pres-≈ ⟩ *-comm _ _)
⟨ +-pres-≈ ⟩ refl ⟩
a * (x * d) + b * (c * x) ≈⟨ sym $ *-assoc _ _ _ ⟨ +-pres-≈ ⟩ refl ⟩
a * x * d + b * (c * x) ∎
lemma₆ : ∀ a b x → - a * x + - b ≈ - (a * x + b)
lemma₆ a b x = begin
- a * x + - b ≈⟨ -‿*-distribˡ _ _ ⟨ +-pres-≈ ⟩ refl ⟩
- (a * x) + - b ≈⟨ -‿+-comm _ _ ⟩
- (a * x + b) ∎
lemma₇ : ∀ x → ⟦ C.1# ⟧ * x + ⟦ C.0# ⟧ ≈ x
lemma₇ x = begin
⟦ C.1# ⟧ * x + ⟦ C.0# ⟧ ≈⟨ (1-homo ⟨ *-pres-≈ ⟩ refl) ⟨ +-pres-≈ ⟩ 0-homo ⟩
1# * x + 0# ≈⟨ proj₂ +-identity _ ⟩
1# * x ≈⟨ proj₁ *-identity _ ⟩
x ∎
| {
"alphanum_fraction": 0.3728530534,
"avg_line_length": 35.8290598291,
"ext": "agda",
"hexsha": "9b8c74a2fec83299ce8f1885dcd9d7a2fbabcc90",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z",
"max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "isabella232/Lemmachine",
"max_forks_repo_path": "vendor/stdlib/src/Algebra/RingSolver/Lemmas.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "larrytheliquid/Lemmachine",
"max_issues_repo_path": "vendor/stdlib/src/Algebra/RingSolver/Lemmas.agda",
"max_line_length": 82,
"max_stars_count": 56,
"max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "isabella232/Lemmachine",
"max_stars_repo_path": "vendor/stdlib/src/Algebra/RingSolver/Lemmas.agda",
"max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z",
"num_tokens": 1923,
"size": 4192
} |
module Membership-equality where
import Membership-old
open import Relation.Binary.PropositionalEquality as PropEq
open import Data.List
open import Data.List.Any
open import Relation.Binary
import Relation.Binary.InducedPreorders as Ind
open import Function.Related as Related hiding (_∼[_]_)
private
open module M {a} {A : Set a} = Membership-old (PropEq.setoid A) public
hiding (lose; ⊆-preorder)
lose : ∀ {a p} {A : Set a} {P : A → Set p} {x xs} →
x M.∈ xs → P x → Any P xs
lose {P = P} = M.lose (PropEq.subst P)
-- _⊆_ is a preorder.
⊆-preorder : ∀ {a} → Set a → Preorder _ _ _
⊆-preorder A = Ind.InducedPreorder₂ (PropEq.setoid (List A)) _∈_
(PropEq.subst (_∈_ _))
-- Set and bag equality and related preorders.
open Related public
using (Kind; Symmetric-kind)
renaming ( implication to subset
; reverse-implication to superset
; equivalence to set
; injection to subbag
; reverse-injection to superbag
; bijection to bag
)
[_]-Order : Kind → ∀ {a} → Set a → Preorder _ _ _
[ k ]-Order A = Related.InducedPreorder₂ k (_∈_ {A = A})
[_]-Equality : Symmetric-kind → ∀ {a} → Set a → Setoid _ _
[ k ]-Equality A = Related.InducedEquivalence₂ k (_∈_ {A = A})
infix 4 _∼[_]_
_∼[_]_ : ∀ {a} {A : Set a} → List A → Kind → List A → Set _
_∼[_]_ {A = A} xs k ys = Preorder._∼_ ([ k ]-Order A) xs ys
-- Bag equality implies the other relations.
bag-=⇒ : ∀ {k a} {A : Set a} {xs ys : List A} →
xs ∼[ bag ] ys → xs ∼[ k ] ys
bag-=⇒ xs≈ys = ↔⇒ xs≈ys
| {
"alphanum_fraction": 0.5894283958,
"avg_line_length": 30.1296296296,
"ext": "agda",
"hexsha": "c94ad1de86ffc91e9d86bc2be0409d48f42fea13",
"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": "ae541df13d069df4eb1464f29fbaa9804aad439f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Zalastax/singly-typed-actors",
"max_forks_repo_path": "unused/Membership-equality.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ae541df13d069df4eb1464f29fbaa9804aad439f",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Zalastax/singly-typed-actors",
"max_issues_repo_path": "unused/Membership-equality.agda",
"max_line_length": 73,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "ae541df13d069df4eb1464f29fbaa9804aad439f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Zalastax/singly-typed-actors",
"max_stars_repo_path": "unused/Membership-equality.agda",
"max_stars_repo_stars_event_max_datetime": "2019-10-29T09:30:26.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-10-29T09:30:26.000Z",
"num_tokens": 534,
"size": 1627
} |
------------------------------------------------------------------------
-- A small definition of a dependently typed language, using the
-- technique from McBride's "Outrageous but Meaningful Coincidences"
------------------------------------------------------------------------
-- The code contains an example, a partial definition of categories,
-- which triggers the use of an enormous amount of memory (with the
-- development version of Agda which is current at the time of
-- writing). I'm not entirely sure if the code is correct: 2.5G heap
-- doesn't seem to suffice to typecheck this code. /NAD
module Language where
------------------------------------------------------------------------
-- Prelude
record ⊤ : Set₁ where
record Σ (A : Set₁) (B : A → Set₁) : Set₁ where
constructor _,_
field
proj₁ : A
proj₂ : B proj₁
open Σ
uncurry : ∀ {A : Set₁} {B : A → Set₁} {C : Σ A B → Set₁} →
((x : A) (y : B x) → C (x , y)) →
((p : Σ A B) → C p)
uncurry f (x , y) = f x y
record ↑ (A : Set) : Set₁ where
constructor lift
field
lower : A
------------------------------------------------------------------------
-- Contexts
-- The definition of contexts is parametrised by a universe.
module Context (U : Set₁) (El : U → Set₁) where
mutual
-- Contexts.
data Ctxt : Set₁ where
ε : Ctxt
_▻_ : (Γ : Ctxt) → Ty Γ → Ctxt
-- Types.
Ty : Ctxt → Set₁
Ty Γ = Env Γ → U
-- Environments.
Env : Ctxt → Set₁
Env ε = ⊤
Env (Γ ▻ σ) = Σ (Env Γ) λ γ → El (σ γ)
-- Variables (de Bruijn indices).
infix 4 _∋_
data _∋_ : (Γ : Ctxt) → Ty Γ → Set₁ where
zero : ∀ {Γ σ} → Γ ▻ σ ∋ λ γ → σ (proj₁ γ)
suc : ∀ {Γ σ τ} (x : Γ ∋ τ) → Γ ▻ σ ∋ λ γ → τ (proj₁ γ)
-- A lookup function.
lookup : ∀ {Γ σ} → Γ ∋ σ → (γ : Env Γ) → El (σ γ)
lookup zero (γ , v) = v
lookup (suc x) (γ , v) = lookup x γ
------------------------------------------------------------------------
-- A universe
mutual
data U : Set₁ where
set : U
el : Set → U
σ π : (a : U) → (El a → U) → U
El : U → Set₁
El set = Set
El (el A) = ↑ A
El (σ a b) = Σ (El a) λ x → El (b x)
El (π a b) = (x : El a) → El (b x)
open Context U El
-- Abbreviations.
infixr 20 _⊗_
infixr 10 _⇾_
_⇾_ : U → U → U
a ⇾ b = π a λ _ → b
_⊗_ : U → U → U
a ⊗ b = σ a λ _ → b
-- Example.
raw-categoryU : U
raw-categoryU =
σ set λ obj →
σ (el obj ⇾ el obj ⇾ set) λ hom →
(π (el obj) λ x → el (hom x x))
⊗
(π (el obj) λ x → π (el obj) λ y → π (el obj) λ z →
el (hom x y) ⇾ el (hom y z) ⇾ el (hom x z))
------------------------------------------------------------------------
-- A language
mutual
infixl 30 _·_
infix 4 _⊢_
-- Syntax for types.
data Type : (Γ : Ctxt) → Ty Γ → Set₁ where
set : ∀ {Γ} → Type Γ (λ _ → set)
el : ∀ {Γ} (x : Γ ⊢ λ _ → set) → Type Γ (λ γ → el (⟦ x ⟧ γ))
σ : ∀ {Γ a b} → Type Γ a → Type (Γ ▻ a) b →
Type Γ (λ γ → σ (a γ) (λ v → b (γ , v)))
π : ∀ {Γ a b} → Type Γ a → Type (Γ ▻ a) b →
Type Γ (λ γ → π (a γ) (λ v → b (γ , v)))
-- Terms.
data _⊢_ : (Γ : Ctxt) → Ty Γ → Set₁ where
var : ∀ {Γ a} → Γ ∋ a → Γ ⊢ a
ƛ : ∀ {Γ a b} → Γ ▻ a ⊢ uncurry b →
Γ ⊢ (λ γ → π (a γ) (λ v → b γ v))
_·_ : ∀ {Γ a} {b : (γ : Env Γ) → El (a γ) → U} →
Γ ⊢ (λ γ → π (a γ) (λ v → b γ v)) →
(t₂ : Γ ⊢ a) → Γ ⊢ (λ γ → b γ (⟦ t₂ ⟧ γ))
-- The semantics of a term.
⟦_⟧ : ∀ {Γ a} → Γ ⊢ a → (γ : Env Γ) → El (a γ)
⟦ var x ⟧ γ = lookup x γ
⟦ ƛ t ⟧ γ = λ v → ⟦ t ⟧ (γ , v)
⟦ t₁ · t₂ ⟧ γ = (⟦ t₁ ⟧ γ) (⟦ t₂ ⟧ γ)
-- Example.
raw-category : Type ε (λ _ → raw-categoryU)
raw-category =
-- Objects.
σ set
-- Morphisms.
(σ (π (el (var zero)) (π (el (var (suc zero))) set))
-- Identity.
(σ (π (el (var (suc zero)))
(el (var (suc zero) · var zero · var zero)))
-- Composition.
(π (el (var (suc (suc zero)))) -- X.
(π (el (var (suc (suc (suc zero))))) -- Y.
(π (el (var (suc (suc (suc (suc zero)))))) -- Z.
(π (el (var (suc (suc (suc (suc zero)))) ·
var (suc (suc zero)) ·
var (suc zero))) -- Hom X Y.
(π (el (var (suc (suc (suc (suc (suc zero))))) ·
var (suc (suc zero)) ·
var (suc zero))) -- Hom Y Z.
(el (var (suc (suc (suc (suc (suc (suc zero)))))) ·
var (suc (suc (suc (suc zero)))) ·
var (suc (suc zero))))) -- Hom X Z.
))))))
| {
"alphanum_fraction": 0.4132444636,
"avg_line_length": 26.2768361582,
"ext": "agda",
"hexsha": "46c0bd5f6bd76fe452c499d0666bc969054a819c",
"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": "benchmark/categories/Language.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": "benchmark/categories/Language.agda",
"max_line_length": 72,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "benchmark/categories/Language.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": 1712,
"size": 4651
} |
{-# OPTIONS --universe-polymorphism #-}
module Categories.Functor.Properties where
open import Relation.Binary using (_Preserves_⟶_)
open import Categories.Category
open import Categories.Functor
import Categories.Morphisms as Morphisms
module FunctorsAlways {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} (F : Functor C D) where
open Functor F
module C = Category C
module D = Category D
resp-Iso : ∀ {A B} {f : C [ A , B ]} {g : C [ B , A ]}
→ Morphisms.Iso C f g → Morphisms.Iso D (F₁ f) (F₁ g)
resp-Iso {f = f} {g} I = record
{ isoˡ = begin
D [ F₁ g ∘ F₁ f ]
↑⟨ homomorphism ⟩
F₁ (C [ g ∘ f ])
↓⟨ F-resp-≡ I.isoˡ ⟩
F₁ (C.id)
↓⟨ identity ⟩
D.id
∎
; isoʳ = begin
D [ F₁ f ∘ F₁ g ]
↑⟨ homomorphism ⟩
F₁ (C [ f ∘ g ])
↓⟨ F-resp-≡ I.isoʳ ⟩
F₁ (C.id)
↓⟨ identity ⟩
D.id
∎
}
where
module I = Morphisms.Iso I
open D.HomReasoning
resp-≅ : F₀ Preserves Morphisms._≅_ C ⟶ Morphisms._≅_ D
resp-≅ I = record
{ f = F₁ I.f
; g = F₁ I.g
; iso = resp-Iso I.iso
}
where
module I = Morphisms._≅_ I
| {
"alphanum_fraction": 0.4861538462,
"avg_line_length": 26.5306122449,
"ext": "agda",
"hexsha": "5a5f89083d6f6ec5088c6e09f2b1160069633cd0",
"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/Functor/Properties.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/Functor/Properties.agda",
"max_line_length": 107,
"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/Functor/Properties.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": 453,
"size": 1300
} |
module LibA where
import LibB
| {
"alphanum_fraction": 0.8333333333,
"avg_line_length": 10,
"ext": "agda",
"hexsha": "f88ae2fa94805707783965197b587e102cc247c5",
"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": "cc026a6a97a3e517bb94bafa9d49233b067c7559",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "cagix/agda",
"max_forks_repo_path": "test/interaction/Issue5245/LibA.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559",
"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-2-Clause"
],
"max_issues_repo_name": "cagix/agda",
"max_issues_repo_path": "test/interaction/Issue5245/LibA.agda",
"max_line_length": 17,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "cagix/agda",
"max_stars_repo_path": "test/interaction/Issue5245/LibA.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": 9,
"size": 30
} |
-- Andreas, 2014-03-02, issue reported by roly.perera
-- Test case by Nisse
{-# OPTIONS --allow-unsolved-metas #-}
-- To see what is going on:
-- {-# OPTIONS -v tc.meta.assign.proj:25 #-}
record Σ (A : Set) (B : A → Set) : Set where
constructor t
field
proj₁ : A
proj₂ : B proj₁
open Σ public
map : {A B : Set} {P : A → Set} {Q : B → Set} →
(f : A → B) → (∀ {x} → P x → Q (f x)) →
Σ A P → Σ B Q
map f g x = t (f (proj₁ x)) (g (proj₂ x))
postulate
U : Set
El : U → Set
mutual
data C : Set where
c : (x : C) → (F x → U) → C
F : C → Set
F (c x y) = Σ (F x) λ v → El (y v)
f : ∀ x y → F (c x y) → F x
f _ _ = proj₁
postulate
P : ∀ x y → (F x → F y) → Set
p : ∀ x y → P (c _ _) (c x y) (map (f _ _) (λ v → v))
-- WAS: internal error in Records.hs
-- NOW: unsolved meta
| {
"alphanum_fraction": 0.4969474969,
"avg_line_length": 19.0465116279,
"ext": "agda",
"hexsha": "755f49d2dc2adb884c0821e82ed2b3c169662de9",
"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/Issue1069.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/Issue1069.agda",
"max_line_length": 55,
"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/Issue1069.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": 343,
"size": 819
} |
module PrintNat where
import PreludeShow
open PreludeShow
mainS = showNat 42
| {
"alphanum_fraction": 0.8227848101,
"avg_line_length": 11.2857142857,
"ext": "agda",
"hexsha": "0d28dff3ae40258bb543b3046254c414b63f4c48",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "examples/outdated-and-incorrect/Alonzo/PrintNat.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "examples/outdated-and-incorrect/Alonzo/PrintNat.agda",
"max_line_length": 21,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "examples/outdated-and-incorrect/Alonzo/PrintNat.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": 21,
"size": 79
} |
{-# OPTIONS --safe #-}
module Definition.Typed.Consequences.NeTypeEq where
open import Definition.Untyped
open import Definition.Typed
open import Definition.Typed.Properties
open import Definition.Typed.Weakening
open import Definition.Typed.Consequences.Syntactic
open import Definition.Typed.Consequences.Injectivity
open import Definition.Typed.Consequences.Substitution
open import Tools.Product
import Tools.PropositionalEquality as PE
-- to be moved in Untyped
typelevel-injectivity : ∀ {r r' l l'} → [ r , l ] PE.≡ [ r' , l' ] → r PE.≡ r' × l PE.≡ l'
typelevel-injectivity PE.refl = PE.refl , PE.refl
-- Helper function for the same variable instance of a context have equal types.
varTypeEq′ : ∀ {n R rR T rT Γ} → n ∷ R ^ rR ∈ Γ → n ∷ T ^ rT ∈ Γ → R PE.≡ T × rR PE.≡ rT
varTypeEq′ here here = PE.refl , PE.refl
varTypeEq′ (there n∷R) (there n∷T) with varTypeEq′ n∷R n∷T
... | PE.refl , PE.refl = PE.refl , PE.refl
-- The same variable instance of a context have equal types.
varTypeEq : ∀ {x A B rA rB Γ} → Γ ⊢ A ^ rA → Γ ⊢ B ^ rB
→ x ∷ A ^ rA ∈ Γ
→ x ∷ B ^ rB ∈ Γ
→ Γ ⊢ A ≡ B ^ rA × rA PE.≡ rB
varTypeEq A B x∷A x∷B with varTypeEq′ x∷A x∷B
... | PE.refl , PE.refl = refl A , PE.refl
-- The same neutral term have equal types.
-- to use this with different relevances rA rB we need unicity of relevance for types
neTypeEq : ∀ {t A B rA lA lA' Γ} → Neutral t → Γ ⊢ t ∷ A ^ [ rA , lA ] → Γ ⊢ t ∷ B ^ [ rA , lA' ] →
lA PE.≡ lA' × Γ ⊢ A ≡ B ^ [ rA , lA ]
neTypeEq (var x) (var x₁ x₂) (var x₃ x₄) =
let V , e = varTypeEq (syntacticTerm (var x₃ x₂)) (syntacticTerm (var x₃ x₄)) x₂ x₄
_ , el = typelevel-injectivity e
in el , V
neTypeEq (∘ₙ neT) (t∷A ∘ⱼ t∷A₁) (t∷B ∘ⱼ t∷B₁) with neTypeEq neT t∷A t∷B
... | e , q = let _ , _ , _ , elG , w = injectivity q
in PE.cong _ elG , substTypeEq w (genRefl t∷A₁)
neTypeEq (natrecₙ neT) (natrecⱼ x t∷A t∷A₁ t∷A₂) (natrecⱼ x₁ t∷B t∷B₁ t∷B₂) =
PE.refl , refl (substType x₁ t∷B₂)
neTypeEq Emptyrecₙ (Emptyrecⱼ x t∷A) (Emptyrecⱼ x₁ t∷B) =
PE.refl , refl x₁
neTypeEq (Idₙ X) (Idⱼ Y Y₁ Y₂) (Idⱼ Z Z₁ Z₂) =
let e , q = neTypeEq X Y Z
el = next-inj e
in e , PE.subst (λ l → _ ⊢ _ ≡ SProp l ^ _) el (refl (Ugenⱼ (wfTerm Y) ) )
neTypeEq (Idℕₙ X) (Idⱼ Y Y₁ Y₂) (Idⱼ Z Z₁ Z₂) =
let e , q = neTypeEq X Y₁ Z₁
el = ιinj e
in PE.cong next el , PE.subst (λ l → _ ⊢ _ ≡ SProp l ^ _) el (refl (Ugenⱼ (wfTerm Y) ) )
neTypeEq (Idℕ0ₙ X) (Idⱼ Y Y₁ Y₂) (Idⱼ Z Z₁ Z₂) =
let e , q = neTypeEq X Y₂ Z₂
el = ιinj e
in PE.cong next el , PE.subst (λ l → _ ⊢ _ ≡ SProp l ^ _) el (refl (Ugenⱼ (wfTerm Y) ) )
neTypeEq (IdℕSₙ X) (Idⱼ Y Y₁ Y₂) (Idⱼ Z Z₁ Z₂) =
let e , q = neTypeEq X Y₂ Z₂
el = ιinj e
in PE.cong next el , PE.subst (λ l → _ ⊢ _ ≡ SProp l ^ _) el (refl (Ugenⱼ (wfTerm Y) ) )
neTypeEq (IdUₙ X) (Idⱼ Y Y₁ Y₂) (Idⱼ Z Z₁ Z₂) =
let e , q = neTypeEq X Y₁ Z₁
el = ιinj e
in PE.cong next el , PE.subst (λ l → _ ⊢ _ ≡ SProp l ^ _) el (refl (Ugenⱼ (wfTerm Y) ) )
neTypeEq (IdUℕₙ X) (Idⱼ Y Y₁ Y₂) (Idⱼ Z Z₁ Z₂) =
let e , q = neTypeEq X Y₂ Z₂
el = ιinj e
in PE.cong next el , PE.subst (λ l → _ ⊢ _ ≡ SProp l ^ _) el (refl (Ugenⱼ (wfTerm Y) ) )
neTypeEq (IdUΠₙ X) (Idⱼ Y Y₁ Y₂) (Idⱼ Z Z₁ Z₂) =
let e , q = neTypeEq X Y₂ Z₂
el = ιinj e
in PE.cong next el , PE.subst (λ l → _ ⊢ _ ≡ SProp l ^ _) el (refl (Ugenⱼ (wfTerm Y) ) )
neTypeEq X (castⱼ Y Y₁ Y₂ Y₃) (castⱼ Z Z₁ Z₂ Z₃) = PE.refl , refl (univ Y₁)
neTypeEq x (conv t∷A x₁) t∷B =
let e , q = neTypeEq x t∷A t∷B
in e , trans (sym x₁) q
neTypeEq x t∷A (conv t∷B x₃) =
let e , q = neTypeEq x t∷A t∷B
in e , trans q (PE.subst (λ l → _ ⊢ _ ≡ _ ^ [ _ , l ]) (PE.sym e) x₃)
natTypeEq : ∀ {A rA lA Γ} → Γ ⊢ ℕ ∷ A ^ [ rA , lA ] → rA PE.≡ ! × lA PE.≡ ι ¹ × Γ ⊢ A ≡ U ⁰ ^ [ ! , ι ¹ ]
natTypeEq (ℕⱼ x) = PE.refl , PE.refl , refl (univ (univ 0<1 x))
natTypeEq (conv X x) = let eqrA , eqlA , eqAU = natTypeEq X in eqrA , eqlA ,
trans (sym (PE.subst (λ l → _ ⊢ _ ≡ _ ^ [ _ , l ] ) eqlA (PE.subst (λ r → _ ⊢ _ ≡ _ ^ [ r , _ ]) eqrA x))) eqAU
emptyTypeEq : ∀ {A rA lA Γ l} → Γ ⊢ Empty l ∷ A ^ [ rA , lA ] →
rA PE.≡ ! × lA PE.≡ next l × Γ ⊢ A ≡ SProp l ^ [ ! , next l ]
emptyTypeEq (Emptyⱼ x) = PE.refl , PE.refl , refl (Ugenⱼ x)
emptyTypeEq (conv X x) = let eqrA , eqlA , eqAU = emptyTypeEq X in eqrA , eqlA ,
trans (sym (PE.subst (λ l → _ ⊢ _ ≡ _ ^ [ _ , l ] ) eqlA (PE.subst (λ r → _ ⊢ _ ≡ _ ^ [ r , _ ]) eqrA x))) eqAU
| {
"alphanum_fraction": 0.5813953488,
"avg_line_length": 44.29,
"ext": "agda",
"hexsha": "3ba649135ab3977eff47b402088c244446d6924d",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-02-15T19:42:19.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-01-26T14:55:51.000Z",
"max_forks_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "CoqHott/logrel-mltt",
"max_forks_repo_path": "Definition/Typed/Consequences/NeTypeEq.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "CoqHott/logrel-mltt",
"max_issues_repo_path": "Definition/Typed/Consequences/NeTypeEq.agda",
"max_line_length": 114,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "CoqHott/logrel-mltt",
"max_stars_repo_path": "Definition/Typed/Consequences/NeTypeEq.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-17T16:13:53.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-06-21T08:39:01.000Z",
"num_tokens": 2085,
"size": 4429
} |
module _ where
module M where
open M using () renaming () hiding ()
-- empty lists should not be errors here
| {
"alphanum_fraction": 0.7053571429,
"avg_line_length": 14,
"ext": "agda",
"hexsha": "85a59c6b66d77899057dfe3a9646bb5facdd6f4a",
"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/EmptyRenamingAndHiding.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/EmptyRenamingAndHiding.agda",
"max_line_length": 40,
"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/EmptyRenamingAndHiding.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": 25,
"size": 112
} |
{-# OPTIONS --universe-polymorphism #-}
open import Common.Prelude
open import Common.Level
open import Common.Reflection
module UnquoteSetOmega where
`Level : Term
`Level = def (quote Level) []
-- while building the syntax of ∀ ℓ → Set ℓ (of type Setω) is harmless
`∀ℓ→Setℓ : Term
`∀ℓ→Setℓ = pi (vArg `Level) (abs "_" (sort (set (var 0 []))))
-- unquoting it is harmfull
∀ℓ→Setℓ = unquote (give `∀ℓ→Setℓ)
| {
"alphanum_fraction": 0.6853658537,
"avg_line_length": 24.1176470588,
"ext": "agda",
"hexsha": "d98d7150d60c53c47b50ab996cd32acd6e1152ab",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/UnquoteSetOmega.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "hborum/agda",
"max_issues_repo_path": "test/Fail/UnquoteSetOmega.agda",
"max_line_length": 70,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "hborum/agda",
"max_stars_repo_path": "test/Fail/UnquoteSetOmega.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": 142,
"size": 410
} |
{-
TBA - Talk 'Bout Agda
Ulf Norell
Chalmers
DTP 2008, Nottingham
-}
module Talk where
-- Normal everyday lists
data List (A : Set) : Set where
[] : List A
_::_ : A -> List A -> List A
infixr 40 _::_
map : {A B : Set} -> (A -> B) -> List A -> List B
map f [] = []
map f (x :: xs) = f x :: map f xs
-- More boring types: Bool and Maybe
data Bool : Set where
false : Bool
true : Bool
data Maybe (A : Set) : Set where
nothing : Maybe A
just : A -> Maybe A
fmap : forall {A B} -> (A -> B) -> Maybe A -> Maybe B
fmap f nothing = nothing
fmap f (just x) = just (f x)
-- The intensional equality type
data _==_ {A : Set}(x : A) : A -> Set where
refl : x == x
-- Sigma types
data Σ {A : Set}(B : A -> Set) : Set where
_,_ : (x : A) -> B x -> Σ B
fst : {A : Set}{B : A -> Set} -> Σ B -> A
fst (x , y) = x
snd : {A : Set}{B : A -> Set}(p : Σ B) -> B (fst p)
snd (x , y) = y
_×_ : Set -> Set -> Set
A × B = Σ {A} (\_ -> B)
-- A more interesting type
infix 20 _∈_
data _∈_ {A : Set} : A -> List A -> Set where
first : forall {x xs} -> x ∈ x :: xs
later : forall {x y xs} -> x ∈ xs -> x ∈ y :: xs
module Map (K V : Set)
(_=?=_ : (x y : K) -> Maybe (x == y))
where
Map : Set
Map = List (K × V)
HasKey : K -> Map -> Set
HasKey k m = k ∈ map fst m
member : (x : K)(m : Map) -> Maybe (HasKey x m)
member x [] = nothing
member x ((y , v) :: m) with x =?= y
... | nothing = fmap later (member x m)
member x ((.x , v) :: m) | just refl = just first
lookup : (x : K)(m : Map) -> HasKey x m -> Σ \v -> (x , v) ∈ m
lookup x [] ()
lookup x ((.x , u) :: m) first = u , first
lookup x (e :: m) (later p) with lookup x m p
... | v , q = v , later q
| {
"alphanum_fraction": 0.4850028297,
"avg_line_length": 20.5465116279,
"ext": "agda",
"hexsha": "16f5fd33efd676e8abe8615279786b00460fa0d2",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "examples/DTP08/ulf/Talk.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "examples/DTP08/ulf/Talk.agda",
"max_line_length": 64,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "examples/DTP08/ulf/Talk.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": 675,
"size": 1767
} |
open import Agda.Builtin.Equality
record IsGroup (G : Set) : Set where
field _∙_ : G → G → G
open IsGroup ⦃ ... ⦄
record Group : Set₁ where
field G : Set
⦃ IsG ⦄ : IsGroup G
open Group using () renaming (G to [_])
variable
G : Group
postulate
works : ∀ {G} → (x : [ G ]) → (x ∙ x) ≡ x
fails : (x : [ G ]) → (x ∙ x) ≡ x
-- WAS: No instance of type IsGroup [ G ]
| {
"alphanum_fraction": 0.538071066,
"avg_line_length": 17.9090909091,
"ext": "agda",
"hexsha": "61eb9548f42135ea741162b4f5c03f0f4089308a",
"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/Issue3358.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/Issue3358.agda",
"max_line_length": 43,
"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/Issue3358.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": 152,
"size": 394
} |
module Colist where
open import Size using (Size ; Size<_)
data Colist (i : Size) {a} (A : Set a) : Set a
record ∞Colist (i : Size) {a} (A : Set a) : Set a where
coinductive
constructor delay_
field force : ∀ {j : Size< i} → Colist j A
data Colist (i : Size) {a} (A : Set a) where
[] : Colist i A
_∷_ : (x : A) (xs : ∞Colist i A) → Colist i A
| {
"alphanum_fraction": 0.5660377358,
"avg_line_length": 24.7333333333,
"ext": "agda",
"hexsha": "3e719f9dd91611ef7e3dab45f703e183657e7881",
"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": "ae541df13d069df4eb1464f29fbaa9804aad439f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Zalastax/singly-typed-actors",
"max_forks_repo_path": "src/Colist.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ae541df13d069df4eb1464f29fbaa9804aad439f",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Zalastax/singly-typed-actors",
"max_issues_repo_path": "src/Colist.agda",
"max_line_length": 56,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "ae541df13d069df4eb1464f29fbaa9804aad439f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Zalastax/thesis",
"max_stars_repo_path": "src/Colist.agda",
"max_stars_repo_stars_event_max_datetime": "2018-02-02T16:44:43.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-02-02T16:44:43.000Z",
"num_tokens": 141,
"size": 371
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Strictness combinators
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Strict where
open import Level
open import Agda.Builtin.Equality
open import Agda.Builtin.Strict
renaming ( primForce to force
; primForceLemma to force-≡) public
-- Derived combinators
module _ {ℓ ℓ′ : Level} {A : Set ℓ} {B : Set ℓ′} where
force′ : A → (A → B) → B
force′ = force
force′-≡ : (a : A) (f : A → B) → force′ a f ≡ f a
force′-≡ = force-≡
seq : A → B → B
seq a b = force a (λ _ → b)
seq-≡ : (a : A) (b : B) → seq a b ≡ b
seq-≡ a b = force-≡ a (λ _ → b)
| {
"alphanum_fraction": 0.4549071618,
"avg_line_length": 23.5625,
"ext": "agda",
"hexsha": "0fe710d6fd94497e749ee98d41b14cddf0615ab1",
"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/Strict.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/Strict.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/Strict.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": 231,
"size": 754
} |
module Common.Predicate where
open import Common public
open import Common.Context public
using (Cx ; VCx ; ∅ ; _,_)
-- Predicates.
Pred : ∀ {ℓ} → Set ℓ → Set (sucᴸ ℓ)
Pred {ℓ} U = U → Set ℓ
-- Set membership.
module _ {U : Set} where
infix 3 _∈ᴾ_
_∈ᴾ_ : U → Pred U → Set
A ∈ᴾ P = P A
infix 3 _∉ᴾ_
_∉ᴾ_ : U → Pred U → Set
A ∉ᴾ P = Not (A ∈ᴾ P)
-- Empty set.
module _ {U : Set} where
∅ᴾ : Pred U
∅ᴾ = K 𝟘
bot∈ᴾ : ∀ {A} → A ∉ᴾ ∅ᴾ
bot∈ᴾ = elim𝟘
-- Universal set.
module _ {U : Set} where
Uᴾ : Pred U
Uᴾ = K 𝟙
top∈ᴾ : ∀ {A} → A ∈ᴾ Uᴾ
top∈ᴾ = ∙
-- Set inclusion.
module _ {U : Set} where
infix 3 _⊆ᴾ_
_⊆ᴾ_ : Pred U → Pred U → Set
P ⊆ᴾ Q = ∀ {A : U} → A ∈ᴾ P → A ∈ᴾ Q
infix 3 _⊈ᴾ_
_⊈ᴾ_ : Pred U → Pred U → Set
P ⊈ᴾ Q = Not (P ⊆ᴾ Q)
refl⊆ᴾ : ∀ {P} → P ⊆ᴾ P
refl⊆ᴾ = I
trans⊆ᴾ : ∀ {P Q R} → P ⊆ᴾ Q → Q ⊆ᴾ R → P ⊆ᴾ R
trans⊆ᴾ η η′ = η′ ∘ η
bot⊆ᴾ : ∀ {P} → ∅ᴾ ⊆ᴾ P
bot⊆ᴾ = elim𝟘
top⊆ᴾ : ∀ {P} → P ⊆ᴾ Uᴾ
top⊆ᴾ = K ∙
-- Set equality.
module _ {U : Set} where
infix 3 _⫗ᴾ_
_⫗ᴾ_ : Pred U → Pred U → Set
P ⫗ᴾ Q = (P ⊆ᴾ Q) × (Q ⊆ᴾ P)
refl⫗ᴾ : ∀ {P} → P ⫗ᴾ P
refl⫗ᴾ {P} = refl⊆ᴾ {P = P} , refl⊆ᴾ {P = P}
trans⫗ᴾ : ∀ {P Q R} → P ⫗ᴾ Q → Q ⫗ᴾ R → P ⫗ᴾ R
trans⫗ᴾ {P} (η , μ) (η′ , μ′) = trans⊆ᴾ {P = P} η η′ , trans⊆ᴾ {R = P} μ′ μ
sym⫗ᴾ : ∀ {P Q} → P ⫗ᴾ Q → Q ⫗ᴾ P
sym⫗ᴾ (η , μ) = (μ , η)
antisym⊆ᴾ : ∀ {P Q} → ((P ⊆ᴾ Q) × (Q ⊆ᴾ P)) ≡ (P ⫗ᴾ Q)
antisym⊆ᴾ = refl
-- Predicate-based necessity.
module _ {U : Set} where
data All (P : Pred U) : Pred (Cx U) where
∅ : All P ∅
_,_ : ∀ {A Γ} → All P Γ → P A → All P (Γ , A)
fill : ∀ {Γ P} → (∀ A → P A) → All P Γ
fill {∅} f = ∅
fill {Γ , A} f = fill f , f A
mapAll : ∀ {P Q} → P ⊆ᴾ Q → All P ⊆ᴾ All Q
mapAll η ∅ = ∅
mapAll η (γ , a) = mapAll η γ , η a
lastAll : ∀ {A Γ P} → All P (Γ , A) → P A
lastAll (γ , a) = a
initAll : ∀ {A Γ P} → All P (Γ , A) → All P Γ
initAll (γ , a) = γ
all : ∀ {P} → (∀ A → Dec (P A)) → (∀ Γ → Dec (All P Γ))
all P? ∅ = yes ∅
all P? (Γ , A) with P? A
… | yes a = mapDec (_, a) initAll (all P? Γ)
… | no ¬a = no (¬a ∘ lastAll)
-- Predicate-based possibility.
module _ {U : Set} where
data Any (P : Pred U) : Pred (Cx U) where
top : ∀ {A Γ} → P A → Any P (Γ , A)
pop : ∀ {A Γ} → Any P Γ → Any P (Γ , A)
find : ∀ {Γ P} → Any P Γ → Σ U (λ A → P A)
find (top {A} a) = A , a
find (pop i) = find i
mapAny : ∀ {P Q} → P ⊆ᴾ Q → Any P ⊆ᴾ Any Q
mapAny η (top a) = top (η a)
mapAny η (pop γ) = pop (mapAny η γ)
initAny : ∀ {A Γ P} → Not (P A) → Any P (Γ , A) → Any P Γ
initAny ¬a (top a) = a ↯ ¬a
initAny ¬a (pop γ) = γ
any : ∀ {P} → (∀ A → Dec (P A)) → (∀ Γ → Dec (Any P Γ))
any P? ∅ = no λ ()
any P? (Γ , A) with P? A
… | yes a = yes (top a)
… | no ¬a = mapDec pop (initAny ¬a) (any P? Γ)
| {
"alphanum_fraction": 0.4454764362,
"avg_line_length": 20.3286713287,
"ext": "agda",
"hexsha": "f67fd48553297bab9236f5150c8a010b785eee2c",
"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/Predicate.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/Predicate.agda",
"max_line_length": 77,
"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/Predicate.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": 1614,
"size": 2907
} |
open import Agda.Primitive
variable
a : Level
A : Set a
x : A
postulate
P : ∀ {a b} {A : Set a} {B : Set b} → (A → B) → Set
p : P x
postulate
H : ∀ a (A : Set a) (x : A) → Set
Id : ∀ {a} (A : Set a) → A → A → Set a
h : (i : H _ _ x) (j : H a _ _) → Id (H _ A _) i j
| {
"alphanum_fraction": 0.4475524476,
"avg_line_length": 16.8235294118,
"ext": "agda",
"hexsha": "00c1b3167e3e781493712284afbafa07b7530f5a",
"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/Issue4253.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/Issue4253.agda",
"max_line_length": 53,
"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/Issue4253.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": 135,
"size": 286
} |
{-
The sheaf property of a presheaf on a distributive lattice or a basis thereof
can be expressed as preservation of limits over diagrams defined in this file.
-}
{-# OPTIONS --safe #-}
module Cubical.Categories.DistLatticeSheaf.Diagram where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.HLevels
open import Cubical.Data.Nat
open import Cubical.Data.Nat.Order
open import Cubical.Data.Empty
open import Cubical.Data.Sigma
open import Cubical.Data.FinData
open import Cubical.Data.FinData.Order
open import Cubical.Data.Sum
open import Cubical.Relation.Nullary
open import Cubical.Relation.Binary.Poset
open import Cubical.Categories.Category
open import Cubical.Categories.Functor
open import Cubical.Categories.Limits.Limits
open import Cubical.Categories.Limits.Pullback
open import Cubical.Categories.Instances.DistLattice
open import Cubical.Algebra.DistLattice
open import Cubical.Algebra.Lattice
open import Cubical.Algebra.Semilattice
open import Cubical.Algebra.DistLattice.BigOps
private
variable
ℓ ℓ' ℓ'' : Level
data DLShfDiagOb (n : ℕ) : Type where
sing : Fin n → DLShfDiagOb n
pair : (i j : Fin n) → i <'Fin j → DLShfDiagOb n
data DLShfDiagHom (n : ℕ) : DLShfDiagOb n → DLShfDiagOb n → Type where
idAr : {x : DLShfDiagOb n} → DLShfDiagHom n x x
singPairL : {i j : Fin n} {i<j : i <'Fin j} → DLShfDiagHom n (sing i) (pair i j i<j)
singPairR : {i j : Fin n} {i<j : i <'Fin j}→ DLShfDiagHom n (sing j) (pair i j i<j)
module DLShfDiagHomPath where
variable
n : ℕ
-- DLShfDiagHom n x y is a retract of Code x y
Code : (x y : DLShfDiagOb n) → Type
Code (sing i) (sing j) = i ≡ j
Code (sing i) (pair j k j<k) =
(Σ[ p ∈ (i ≡ j) ] Σ[ i<k ∈ i <'Fin k ] PathP (λ ι → p ι <'Fin k) i<k j<k)
⊎ (Σ[ p ∈ (i ≡ k) ] Σ[ j<i ∈ j <'Fin i ] PathP (λ ι → j <'Fin p ι) j<i j<k)
Code (pair i j i<j) (sing k) = ⊥
Code (pair i j i<j) (pair k l k<l) =
Σ[ p ∈ (i ≡ k) × (j ≡ l) ] PathP (λ ι → fst p ι <'Fin snd p ι) i<j k<l
isSetCode : ∀ (x y : DLShfDiagOb n) → isSet (Code x y)
isSetCode (sing _) (sing _) = isProp→isSet (isSetFin _ _)
isSetCode (sing i) (pair j k j<k) =
isSet⊎
(isSetΣ (isProp→isSet (isSetFin _ _))
λ _ → isSetΣ (isProp→isSet (≤'FinIsPropValued _ _))
λ _ → isOfHLevelPathP 2 (isProp→isSet (≤'FinIsPropValued _ _)) _ _)
(isSetΣ (isProp→isSet (isSetFin _ _))
λ _ → isSetΣ (isProp→isSet (≤'FinIsPropValued _ _))
λ _ → isOfHLevelPathP 2 (isProp→isSet (≤'FinIsPropValued _ _)) _ _)
isSetCode (pair _ _ _) (sing _) = isProp→isSet isProp⊥
isSetCode (pair _ _ _) (pair _ _ _) =
isSetΣ
(isSet× (isProp→isSet (isSetFin _ _)) (isProp→isSet (isSetFin _ _)))
λ _ → isOfHLevelPathP 2 (isProp→isSet (≤'FinIsPropValued _ _)) _ _
encode : (x y : DLShfDiagOb n) → DLShfDiagHom n x y → Code x y
encode (sing i) (sing .i) idAr = refl
encode (sing i) (pair .i j i<j) singPairL = inl (refl , i<j , refl)
encode (sing j) (pair i .j i<j) singPairR = inr (refl , i<j , refl)
encode (pair i j i<j) (pair .i .j .i<j) idAr = (refl , refl) , refl
decode : (x y : DLShfDiagOb n) → Code x y → DLShfDiagHom n x y
decode (sing i) (sing j) p = subst (λ k → DLShfDiagHom _ (sing i) (sing k)) p idAr
decode (sing i) (pair j k j<k) (inl (p , i<k , q)) =
transport (λ ι → DLShfDiagHom _ (sing i) (pair (p ι) k (q ι))) singPairL
decode (sing i) (pair k j k<j) (inr (p , k<i , q)) =
transport (λ ι → DLShfDiagHom _ (sing i) (pair k (p ι) (q ι))) singPairR
decode (pair i j i<j) (pair k l k<l) (_ , p) =
transport (λ ι → DLShfDiagHom _ (pair _ _ i<j) (pair _ _ (p ι))) idAr
codeRetract : ∀ (x y : DLShfDiagOb n) (f : DLShfDiagHom n x y)
→ decode x y (encode x y f) ≡ f
codeRetract (sing i) (sing .i) idAr = transportRefl idAr
codeRetract (sing i) (pair .i k i<k) singPairL = transportRefl singPairL
codeRetract (sing i) (pair j .i j<i) singPairR = transportRefl singPairR
codeRetract (pair i j i<j) (pair .i .j .i<j) idAr = transportRefl idAr
isSetDLShfDiagHom : ∀ (x y : DLShfDiagOb n) → isSet (DLShfDiagHom n x y)
isSetDLShfDiagHom x y = isSetRetract (encode x y) (decode x y)
(codeRetract x y) (isSetCode x y)
open Category
DLShfDiag : ℕ → Category ℓ-zero ℓ-zero
ob (DLShfDiag n) = DLShfDiagOb n
Hom[_,_] (DLShfDiag n) = DLShfDiagHom n
id (DLShfDiag n) = idAr
_⋆_ (DLShfDiag n) idAr f = f
_⋆_ (DLShfDiag n) singPairL idAr = singPairL
_⋆_ (DLShfDiag n) singPairR idAr = singPairR
⋆IdL (DLShfDiag n) _ = refl
⋆IdR (DLShfDiag n) idAr = refl
⋆IdR (DLShfDiag n) singPairL = refl
⋆IdR (DLShfDiag n) singPairR = refl
⋆Assoc (DLShfDiag n) idAr _ _ = refl
⋆Assoc (DLShfDiag n) singPairL idAr _ = refl
⋆Assoc (DLShfDiag n) singPairR idAr _ = refl
isSetHom (DLShfDiag n) = let open DLShfDiagHomPath in (isSetDLShfDiagHom _ _)
module _ (L' : DistLattice ℓ) where
private
L = fst L'
LCat = (DistLatticeCategory L') ^op
instance
_ = snd L'
open DistLatticeStr ⦃...⦄
open Join L'
open JoinSemilattice (Lattice→JoinSemilattice (DistLattice→Lattice L'))
open PosetStr (IndPoset .snd) hiding (_≤_)
open MeetSemilattice (Lattice→MeetSemilattice (DistLattice→Lattice L'))
using (∧≤RCancel ; ∧≤LCancel)
open Order (DistLattice→Lattice L')
open Category LCat
open Functor
open Cone
FinVec→Diag : {n : ℕ} → FinVec L n → Functor (DLShfDiag n) LCat
F-ob (FinVec→Diag α) (sing i) = α i
F-ob (FinVec→Diag α) (pair i j _) = α i ∧l α j
F-hom (FinVec→Diag α) idAr = is-refl _
F-hom (FinVec→Diag α) singPairL = ≤m→≤j _ _ (∧≤RCancel _ _)
F-hom (FinVec→Diag α) singPairR = ≤m→≤j _ _ (∧≤LCancel _ _)
F-id (FinVec→Diag α) = is-prop-valued _ _ _ _
F-seq (FinVec→Diag α) _ _ = is-prop-valued _ _ _ _
⋁Cone : {n : ℕ} (α : FinVec L n) → Cone (FinVec→Diag α) (⋁ α)
coneOut (⋁Cone α) (sing i) = ind≤⋁ α i
coneOut (⋁Cone α) (pair i _ _) = is-trans _ (α i) _ (≤m→≤j _ _ (∧≤RCancel _ _)) (ind≤⋁ α i)
coneOutCommutes (⋁Cone α) _ = is-prop-valued _ _ _ _
isLimCone⋁Cone : {n : ℕ} (α : FinVec L n) → isLimCone (FinVec→Diag α) (⋁ α) (⋁Cone α)
fst (fst (isLimCone⋁Cone α u uCone)) = ⋁IsMax α _ λ i → uCone .coneOut (sing i)
snd (fst (isLimCone⋁Cone α u uCone)) _ = is-prop-valued _ _ _ _
snd (isLimCone⋁Cone α _ uCone) _ = Σ≡Prop (λ _ → isPropIsConeMor uCone (⋁Cone α) _)
(is-prop-valued _ _ _ _)
module PullbacksAsDLShfDiags (C : Category ℓ ℓ')
(cspan : Cospan C)
(pback : Pullback C cspan) where
open Functor
open Cone
open Cospan ⦃...⦄
open Pullback ⦃...⦄
instance
_ = cspan
_ = pback
cospanAsDiag : Functor (DLShfDiag 2) C
F-ob cospanAsDiag (sing zero) = l
F-ob cospanAsDiag (sing (suc zero)) = r
F-ob cospanAsDiag (pair _ _ _) = m
F-hom cospanAsDiag idAr = id C
F-hom cospanAsDiag {x = sing zero} singPairL = s₁
F-hom cospanAsDiag {x = sing (suc zero)} singPairL = s₂
F-hom cospanAsDiag {x = sing zero} singPairR = s₁
F-hom cospanAsDiag {x = sing (suc zero)} singPairR = s₂
F-id cospanAsDiag = refl
F-seq cospanAsDiag idAr idAr = sym (⋆IdL C _)
F-seq cospanAsDiag idAr singPairL = sym (⋆IdL C _)
F-seq cospanAsDiag idAr singPairR = sym (⋆IdL C _)
F-seq cospanAsDiag singPairL idAr = sym (⋆IdR C _)
F-seq cospanAsDiag singPairR idAr = sym (⋆IdR C _)
pbPrAsCone : Cone cospanAsDiag pbOb
coneOut pbPrAsCone (sing zero) = pbPr₁
coneOut pbPrAsCone (sing (suc zero)) = pbPr₂
coneOut pbPrAsCone (pair _ _ _) = pbPr₁ ⋆⟨ C ⟩ s₁
coneOutCommutes pbPrAsCone idAr = ⋆IdR C _
coneOutCommutes pbPrAsCone (singPairL {zero}) = refl
coneOutCommutes pbPrAsCone (singPairL {suc zero}) = sym pbCommutes
coneOutCommutes pbPrAsCone (singPairR {zero} {zero}) = refl
coneOutCommutes pbPrAsCone (singPairR {zero} {suc zero}) = sym pbCommutes
coneOutCommutes pbPrAsCone (singPairR {suc zero} {zero}) = refl
coneOutCommutes pbPrAsCone (singPairR {suc zero} {suc zero}) = sym pbCommutes
pbAsLimit : isLimCone cospanAsDiag pbOb pbPrAsCone
pbAsLimit c cc = uniqueExists (fromPBUnivProp .fst .fst)
toConeMor
(λ _ → isPropIsConeMor cc pbPrAsCone _)
(λ f cf → cong fst (fromPBUnivProp .snd (f , fromConeMor cf)))
where
fromPBUnivProp : ∃![ hk ∈ C [ c , Pullback.pbOb pback ] ]
(coneOut cc (sing zero) ≡ hk ⋆⟨ C ⟩ pbPr₁) ×
(coneOut cc (sing (suc zero)) ≡ hk ⋆⟨ C ⟩ pbPr₂)
fromPBUnivProp = univProp
(cc .coneOut (sing zero)) (cc .coneOut (sing (suc zero)))
(cc .coneOutCommutes (singPairL {i<j = s≤s z≤}) ∙ sym (cc .coneOutCommutes singPairR))
toConeMor : isConeMor cc pbPrAsCone (fromPBUnivProp .fst .fst)
toConeMor (sing zero) = sym (fromPBUnivProp .fst .snd .fst)
toConeMor (sing (suc zero)) = sym (fromPBUnivProp .fst .snd .snd)
toConeMor (pair zero j _) = path
where
path : fromPBUnivProp .fst .fst ⋆⟨ C ⟩ (pbPr₁ ⋆⟨ C ⟩ s₁) ≡ cc .coneOut (pair zero j _)
path = fromPBUnivProp .fst .fst ⋆⟨ C ⟩ (pbPr₁ ⋆⟨ C ⟩ s₁)
≡⟨ sym (⋆Assoc C _ _ _) ⟩
(fromPBUnivProp .fst .fst ⋆⟨ C ⟩ pbPr₁) ⋆⟨ C ⟩ s₁
≡⟨ cong (λ f → f ⋆⟨ C ⟩ s₁) (sym (fromPBUnivProp .fst .snd .fst)) ⟩
cc .coneOut (sing zero) ⋆⟨ C ⟩ s₁
≡⟨ cc .coneOutCommutes singPairL ⟩
cc .coneOut (pair zero j _) ∎
toConeMor (pair (suc zero) j _) = path
where
path : fromPBUnivProp .fst .fst ⋆⟨ C ⟩ (pbPr₁ ⋆⟨ C ⟩ s₁)
≡ cc .coneOut (pair (suc zero) j _)
path = fromPBUnivProp .fst .fst ⋆⟨ C ⟩ (pbPr₁ ⋆⟨ C ⟩ s₁)
≡⟨ cong (λ f → fromPBUnivProp .fst .fst ⋆⟨ C ⟩ f) pbCommutes ⟩
fromPBUnivProp .fst .fst ⋆⟨ C ⟩ (pbPr₂ ⋆⟨ C ⟩ s₂)
≡⟨ sym (⋆Assoc C _ _ _) ⟩
(fromPBUnivProp .fst .fst ⋆⟨ C ⟩ pbPr₂) ⋆⟨ C ⟩ s₂
≡⟨ cong (λ f → f ⋆⟨ C ⟩ s₂) (sym (fromPBUnivProp .fst .snd .snd)) ⟩
cc .coneOut (sing (suc zero)) ⋆⟨ C ⟩ s₂
≡⟨ cc .coneOutCommutes singPairL ⟩
cc .coneOut (pair (suc zero) j _) ∎
fromConeMor : {f : C [ c , pbOb ]}
→ isConeMor cc pbPrAsCone f
→ (coneOut cc (sing zero) ≡ f ⋆⟨ C ⟩ pbPr₁) ×
(coneOut cc (sing (suc zero)) ≡ f ⋆⟨ C ⟩ pbPr₂)
fst (fromConeMor cf) = sym (cf (sing zero))
snd (fromConeMor cf) = sym (cf (sing (suc zero)))
module DLShfDiagsAsPullbacks (C : Category ℓ ℓ')
(F : Functor (DLShfDiag 2) C)
(limF : LimCone F) where
open Cospan
open Pullback
open Functor ⦃...⦄
open Cone ⦃...⦄
open LimCone ⦃...⦄
instance
_ = F
_ = limF
_ = limF .limCone
DiagAsCospan : Cospan C
l DiagAsCospan = F-ob (sing zero)
m DiagAsCospan = F-ob (pair zero (suc zero) (s≤s z≤))
r DiagAsCospan = F-ob (sing (suc zero))
s₁ DiagAsCospan = F-hom singPairL
s₂ DiagAsCospan = F-hom singPairR
LimAsPullback : Pullback C DiagAsCospan
pbOb LimAsPullback = lim
pbPr₁ LimAsPullback = coneOut (sing zero)
pbPr₂ LimAsPullback = coneOut (sing (suc zero))
pbCommutes LimAsPullback = coneOutCommutes singPairL ∙ sym (coneOutCommutes singPairR)
univProp LimAsPullback {d = d} f g cSq =
uniqueExists
(fromUnivProp .fst .fst)
(sym (fromUnivProp .fst .snd (sing zero)) , sym (fromUnivProp .fst .snd (sing (suc zero))))
(λ _ → isProp× (isSetHom C _ _) (isSetHom C _ _))
λ h' trs → cong fst (fromUnivProp .snd (h' , toConeMor h' trs))
where
theCone : Cone F d
Cone.coneOut theCone (sing zero) = f
Cone.coneOut theCone (sing (suc zero)) = g
Cone.coneOut theCone (pair zero zero ())
Cone.coneOut theCone (pair zero (suc zero) (s≤s z≤)) = f ⋆⟨ C ⟩ DiagAsCospan .s₁
Cone.coneOut theCone (pair (suc zero) zero ())
Cone.coneOut theCone (pair (suc zero) (suc zero) (s≤s ()))
Cone.coneOutCommutes theCone {u} idAr = cong (seq' C (Cone.coneOut theCone u)) F-id
∙ ⋆IdR C (Cone.coneOut theCone u)
Cone.coneOutCommutes theCone {sing zero} {pair ._ (suc zero) (s≤s z≤)} singPairL = refl
Cone.coneOutCommutes theCone {sing (suc zero)} {pair ._ (suc zero) (s≤s ())} singPairL
Cone.coneOutCommutes theCone {sing (suc zero)} {pair zero ._ (s≤s z≤)} singPairR = sym cSq
Cone.coneOutCommutes theCone {sing (suc zero)} {pair (suc zero) ._ (s≤s ())} singPairR
fromUnivProp : ∃![ h ∈ C [ d , lim ] ] isConeMor theCone limCone h
fromUnivProp = LimCone.univProp limF d theCone
toConeMor : ∀ (h' : C [ d , lim ])
→ (f ≡ h' ⋆⟨ C ⟩ coneOut (sing zero)) × (g ≡ h' ⋆⟨ C ⟩ coneOut (sing (suc zero)))
→ isConeMor theCone limCone h'
toConeMor h' (tr₁ , tr₂) (sing zero) = sym tr₁
toConeMor h' (tr₁ , tr₂) (sing (suc zero)) = sym tr₂
toConeMor h' (tr₁ , tr₂) (pair zero (suc zero) (s≤s z≤)) = path
where
path : h' ⋆⟨ C ⟩ coneOut (pair zero (suc zero) (s≤s z≤))
≡ f ⋆⟨ C ⟩ F-hom singPairL
path = h' ⋆⟨ C ⟩ coneOut (pair zero (suc zero) (s≤s z≤))
≡⟨ cong (seq' C h') (sym (coneOutCommutes singPairL)) ⟩
h' ⋆⟨ C ⟩ (coneOut (sing zero) ⋆⟨ C ⟩ F-hom singPairL)
≡⟨ sym (⋆Assoc C _ _ _) ⟩
(h' ⋆⟨ C ⟩ coneOut (sing zero)) ⋆⟨ C ⟩ F-hom singPairL
≡⟨ cong (λ x → seq' C x (F-hom singPairL)) (sym tr₁) ⟩
f ⋆⟨ C ⟩ F-hom singPairL ∎
toConeMor h' (tr₁ , tr₂) (pair (suc zero) (suc zero) (s≤s ()))
| {
"alphanum_fraction": 0.6218588253,
"avg_line_length": 40.7675840979,
"ext": "agda",
"hexsha": "36d0c4fe0620f95e938317285c441e114b0a95b8",
"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/Categories/DistLatticeSheaf/Diagram.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/Categories/DistLatticeSheaf/Diagram.agda",
"max_line_length": 97,
"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/Categories/DistLatticeSheaf/Diagram.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": 5504,
"size": 13331
} |
module list-thms where
-- see list-thms2 for more
open import bool
open import bool-thms
open import functions
open import list
open import nat
open import nat-thms
open import product-thms
open import logic
++[] : ∀{ℓ}{A : Set ℓ} → (l : 𝕃 A) → l ++ [] ≡ l
++[] [] = refl
++[] (x :: xs) rewrite ++[] xs = refl
++-assoc : ∀ {ℓ}{A : Set ℓ} (l1 l2 l3 : 𝕃 A) →
(l1 ++ l2) ++ l3 ≡ l1 ++ (l2 ++ l3)
++-assoc [] l2 l3 = refl
++-assoc (x :: xs) l2 l3 rewrite ++-assoc xs l2 l3 = refl
length-++ : ∀{ℓ}{A : Set ℓ}(l1 l2 : 𝕃 A) →
length (l1 ++ l2) ≡ (length l1) + (length l2)
length-++ [] l2 = refl
length-++ (h :: t) l2 rewrite length-++ t l2 = refl
map-append : ∀ {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} →
(f : A → B) (l1 l2 : 𝕃 A) →
map f (l1 ++ l2) ≡ (map f l1) ++ (map f l2)
map-append f [] l2 = refl
map-append f (x :: xs) l2 rewrite map-append f xs l2 = refl
map-compose : ∀ {ℓ ℓ' ℓ''} {A : Set ℓ} {B : Set ℓ'}{C : Set ℓ''} →
(f : B → C) (g : A → B) (l : 𝕃 A) →
map f (map g l) ≡ map (f ∘ g) l
map-compose f g [] = refl
map-compose f g (x :: xs) rewrite map-compose f g xs = refl
foldr-monoid : ∀{ℓ}{A B : Set ℓ}{l₁ l₂ : 𝕃 A}{_⊗_ : B → B → B}{f : A → B}{b : B}
{p-sym : ∀{a} → b ⊗ a ≡ a}
{p-assoc : ∀{a b c} → a ⊗ (b ⊗ c) ≡ (a ⊗ b) ⊗ c}
→ (foldr (λ x r → (f x) ⊗ r) b l₁) ⊗ (foldr (λ x r → (f x) ⊗ r) b l₂) ≡ foldr (λ x r → (f x) ⊗ r) b (l₁ ++ l₂)
foldr-monoid {ℓ}{A}{B}{[]}{l₂}{_⊗_}{f}{b}{p-sym} rewrite p-sym {foldr (λ x → _⊗_ (f x)) b l₂} = refl
foldr-monoid {ℓ}{A}{B}{y :: ys}{l₂}{_⊗_}{f}{b}{p-sym}{p-assoc}
rewrite
sym (p-assoc {f y}{foldr (λ x → _⊗_ (f x)) b ys}{foldr (λ x → _⊗_ (f x)) b l₂})
| foldr-monoid {l₁ = ys}{l₂}{_⊗_}{f}{b}{p-sym}{p-assoc}
= refl
foldr-append : ∀{ℓ₂}{B : Set ℓ₂}{l₁ l₂ : 𝕃 (𝕃 B)} → (foldr _++_ [] l₁) ++ (foldr _++_ [] l₂) ≡ foldr _++_ [] (l₁ ++ l₂)
foldr-append {l₁ = []}{l₂} = refl
foldr-append {_}{B}{l₁ = x :: xs}{l₂} rewrite sym (foldr-append {l₁ = xs}{l₂}) = ++-assoc x (foldr _++_ [] xs) (foldr _++_ [] l₂)
foldr-append-fun : ∀{ℓ₁ ℓ₂}{A : Set ℓ₁}{B : Set ℓ₂}{l₁ l₂ : 𝕃 (A → 𝕃 B)}{a : A}
→ (foldr (λ f → _++_ (f a)) [] l₁) ++ (foldr (λ f → _++_ (f a)) [] l₂) ≡ foldr (λ f → _++_ (f a)) [] (l₁ ++ l₂)
foldr-append-fun {l₁ = []}{_}{a} = refl
foldr-append-fun {l₁ = x :: l₁}{l₂}{a}
rewrite
++-assoc (x a) (foldr (λ f → _++_ (f a)) [] l₁) (foldr (λ f → _++_ (f a)) [] l₂)
| foldr-append-fun {l₁ = l₁}{l₂}{a}
= refl
foldr-map : ∀{ℓ}{A : Set ℓ}{l : 𝕃 A} → l ≡ foldr _++_ [] (map (λ x₁ → x₁ :: []) l)
foldr-map {_}{_}{[]} = refl
foldr-map {ℓ}{A}{x :: xs} rewrite sym (foldr-map {ℓ}{A}{xs}) = refl
invert𝕃 : ∀{ℓ}{A : Set ℓ}{t : A}{ts : 𝕃 A} → t :: ts ≢ []
invert𝕃 ()
length-repeat : ∀{ℓ}{A : Set ℓ} (n : ℕ) (a : A) → length (repeat n a) ≡ n
length-repeat 0 a = refl
length-repeat (suc n) a rewrite length-repeat n a = refl
map-repeat : ∀ {ℓ ℓ'}{A : Set ℓ}{B : Set ℓ'}(n : ℕ)(a : A)(f : A → B) → map f (repeat n a) ≡ repeat n (f a)
map-repeat 0 a f = refl
map-repeat (suc x) a f rewrite map-repeat x a f = refl
length-map : ∀{ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} (f : A → B)(l : 𝕃 A) → length (map f l) ≡ length l
length-map f [] = refl
length-map f (head :: tail) rewrite length-map f tail = refl
length-reverse-helper : ∀{ℓ}{A : Set ℓ}(h l : 𝕃 A) →
length (reverse-helper h l) ≡ length h + length l
length-reverse-helper h [] rewrite +0 (length h) = refl
length-reverse-helper h (x :: xs) rewrite length-reverse-helper (x :: h) xs = sym (+suc (length h) (length xs))
length-reverse : ∀{ℓ}{A : Set ℓ}(l : 𝕃 A) → length (reverse l) ≡ length l
length-reverse l = length-reverse-helper [] l
reverse-++h : ∀{ℓ}{A : Set ℓ}(l1 l2 : 𝕃 A) → reverse-helper l1 l2 ≡ reverse-helper [] l2 ++ l1
reverse-++h l1 [] = refl
reverse-++h l1 (x :: xs) rewrite reverse-++h (x :: l1) xs | reverse-++h (x :: []) xs | ++-assoc (reverse xs) (x :: []) l1 = refl
reverse-++ : ∀{ℓ}{A : Set ℓ}(l1 l2 : 𝕃 A) → reverse(l1 ++ l2) ≡ reverse(l2) ++ reverse(l1)
reverse-++ [] l2 rewrite ++[] (reverse l2) = refl
reverse-++ (x :: xs) l2 rewrite reverse-++h (x :: []) (xs ++ l2) | reverse-++ xs l2 | ++-assoc (reverse l2) (reverse xs) (x :: []) | sym (reverse-++h (x :: []) xs) = refl
reverse-involution-aux : ∀{ℓ}{A : Set ℓ}(h h' l : 𝕃 A) → reverse-helper h (reverse-helper h' l) ≡ (reverse-helper [] h') ++ l ++ h
reverse-involution-aux h h' [] = reverse-++h h h'
reverse-involution-aux h h' (x₁ :: l) rewrite reverse-involution-aux h (x₁ :: h') l | reverse-++h (x₁ :: []) h' | ++-assoc (reverse-helper [] h') (x₁ :: []) (l ++ h) = refl
reverse-involution : ∀{ℓ}{A : Set ℓ}(l : 𝕃 A) → reverse (reverse l) ≡ l
reverse-involution l rewrite reverse-involution-aux [] [] l = ++[] l
reverse-++-bad : ∀{ℓ}{A : Set ℓ}(l1 l2 : 𝕃 A) → reverse-bad (l1 ++ l2) ≡ reverse-bad l2 ++ reverse-bad l1
reverse-++-bad [] l2 = sym (++[] (reverse-bad l2))
reverse-++-bad (x :: l1) l2 rewrite reverse-++-bad l1 l2 = ++-assoc (reverse-bad l2) (reverse-bad l1) (x :: [])
reverse-involution-bad : ∀{ℓ}{A : Set ℓ}(l : 𝕃 A) → reverse-bad (reverse-bad l) ≡ l
reverse-involution-bad [] = refl
reverse-involution-bad (x :: xs) rewrite reverse-++-bad (reverse-bad xs) (x :: []) | reverse-involution-bad xs = refl
=𝕃-refl : ∀{ℓ}{A : Set ℓ}{l1 : 𝕃 A} → (eq : A → A → 𝔹) → ((x y : A) → x ≡ y → eq x y ≡ tt) → =𝕃 eq l1 l1 ≡ tt
=𝕃-refl{l1 = []} eq rise = refl
=𝕃-refl{l1 = x :: xs} eq rise = &&-combo (rise x x refl) (=𝕃-refl{l1 = xs} eq rise)
≡𝕃-from-= : ∀{ℓ}{A : Set ℓ}{l1 l2 : 𝕃 A} → (eq : A → A → 𝔹) → ((x y : A) → eq x y ≡ tt → x ≡ y) → =𝕃 eq l1 l2 ≡ tt → l1 ≡ l2
≡𝕃-from-={l1 = []}{[]} eq drop p = refl
≡𝕃-from-={l1 = x :: xs}{[]} eq drop ()
≡𝕃-from-={l1 = []}{y :: ys} eq drop ()
≡𝕃-from-={l1 = x :: xs}{y :: ys} eq drop p rewrite ≡𝕃-from-={l1 = xs} eq drop (&&-snd{eq x y}{=𝕃 eq xs ys} p) | drop x y (&&-fst p) = refl
=𝕃-from-≡ : ∀{ℓ}{A : Set ℓ}{l1 l2 : 𝕃 A} → (eq : A → A → 𝔹) → ((x y : A) → x ≡ y → eq x y ≡ tt) → l1 ≡ l2 → =𝕃 eq l1 l2 ≡ tt
=𝕃-from-≡{l2 = l2} eq rise p rewrite p = =𝕃-refl{l1 = l2} eq rise
multi++-assoc : ∀{ℓ}{A : Set ℓ} → (Ls : 𝕃 (𝕃 A)) → (l0 : 𝕃 A) → (foldr _++_ [] Ls) ++ l0 ≡ (foldr _++_ [] (Ls ++ [ l0 ]))
multi++-assoc [] l' rewrite ++[] l' = refl
multi++-assoc (l :: ls) l' rewrite ++-assoc l (foldr _++_ [] ls) l' | multi++-assoc ls l' = refl
concat-foldr : ∀{ℓ}{A : Set ℓ} → (ls : 𝕃 (𝕃 A)) → (l : 𝕃 A) → concat ls ++ l ≡ foldr _++_ l ls
concat-foldr [] l = refl
concat-foldr (l' :: ls) l rewrite ++-assoc l' (concat ls) l | concat-foldr ls l = refl
--concat-foldr (l' :: (l'' :: ls)) l rewrite ++-assoc l' (concat (l'' :: ls)) l | concat-foldr (l'' :: ls) l = refl
longer-trans : ∀{ℓ}{A : Set ℓ}(l1 l2 l3 : 𝕃 A) →
l1 longer l2 ≡ tt →
l2 longer l3 ≡ tt →
l1 longer l3 ≡ tt
longer-trans [] l2 l3 () q
longer-trans (x :: l1) [] l3 p ()
longer-trans (x :: l1) (x₁ :: l2) [] p q = refl
longer-trans (x :: l1) (x₁ :: l2) (x₂ :: l3) p q = longer-trans l1 l2 l3 p q
filter-idem : ∀{ℓ}{A : Set ℓ}(p : A → 𝔹)(l : 𝕃 A) →
(filter p (filter p l)) ≡ (filter p l)
filter-idem p [] = refl
filter-idem p (x :: l) with keep (p x)
filter-idem p (x :: l) | tt , p' rewrite p' | p' | filter-idem p l = refl
filter-idem p (x :: l) | ff , p' rewrite p' = filter-idem p l
length-filter : ∀{ℓ}{A : Set ℓ}(p : A → 𝔹)(l : 𝕃 A) →
length (filter p l) ≤ length l ≡ tt
length-filter p [] = refl
length-filter p (x :: l) with p x
length-filter p (x :: l) | tt = length-filter p l
length-filter p (x :: l) | ff =
≤-trans{length (filter p l)} (length-filter p l) (≤-suc (length l))
filter-++ : ∀{ℓ}{A : Set ℓ}(p : A → 𝔹)(l1 l2 : 𝕃 A) → filter p (l1 ++ l2) ≡ filter p l1 ++ filter p l2
filter-++ p [] l2 = refl
filter-++ p (x :: l1) l2 with p x
filter-++ p (x :: l1) l2 | tt rewrite (filter-++ p l1 l2) = refl
filter-++ p (x :: l1) l2 | ff rewrite (filter-++ p l1 l2) = refl
remove-++ : ∀{ℓ}{A : Set ℓ}(eq : A → A → 𝔹)(a : A)(l1 l2 : 𝕃 A) →
remove eq a (l1 ++ l2) ≡ remove eq a l1 ++ remove eq a l2
remove-++ eq a l1 l2 = filter-++ (λ x → ~ (eq a x)) l1 l2
::-injective : ∀{ℓ}{A : Set ℓ}{x y : A}{xs ys : 𝕃 A} →
x :: xs ≡ y :: ys → x ≡ y ∧ xs ≡ ys
::-injective refl = refl , refl
concat-++ : ∀{ℓ}{A : Set ℓ}(ls1 ls2 : 𝕃 (𝕃 A)) → concat (ls1 ++ ls2) ≡ (concat ls1) ++ (concat ls2)
concat-++ [] ls2 = refl
concat-++ (l :: ls) ls2 rewrite concat-++ ls ls2 = sym (++-assoc l (concat ls) (concat ls2))
-- This holds as long as we have the equations p₁ and p₂. We know
-- that these equations are consistant to adopt, because they are
-- equivalent up and an isomorphism, and hence, by univalence they are
-- consistent as equations. The respective isomorphisms can be found
-- in products-thms.agda.
all-pred-append : ∀{X : Set}{f : X → Set}{l₁ l₂}
→ (p₁ : ∀{ℓ}{A : Set ℓ} → A ≡ ((⊤ {ℓ}) ∧ A))
→ (p₂ : ∀{ℓ}{A B C : Set ℓ} → (A ∧ (B ∧ C)) ≡ ((A ∧ B) ∧ C))
→ all-pred f (l₁ ++ l₂) ≡ ((all-pred f l₁) ∧ (all-pred f l₂))
all-pred-append {l₁ = []} {l₂} p₁ p₂ = p₁
all-pred-append {X}{f}{x :: l₁} {l₂} p₁ p₂ rewrite all-pred-append {X}{f}{l₁ = l₁} {l₂} p₁ p₂ = p₂
all-pred-triv : {ℓ : Level}{l : 𝕃 (⊤ {ℓ})}(γ : ⊤ {ℓ} → Set ℓ)(p : γ triv) → all-pred γ l
all-pred-triv {_}{[]} γ p = triv
all-pred-triv {_}{triv :: l} γ p = p , all-pred-triv γ p
map-proj-⊎₁ : ∀{ℓ ℓ'}{A : Set ℓ}{B : Set ℓ'} → (l : 𝕃 A) →
proj-⊎₁ {A = A}{B} (map inj₁ l) ≡ l
map-proj-⊎₁ [] = refl
map-proj-⊎₁ {A = A}{B} (x :: l) rewrite map-proj-⊎₁ {A = A}{B} l = refl
map-proj-⊎₂ : ∀{ℓ ℓ'}{A : Set ℓ}{B : Set ℓ'} → (l : 𝕃 B) →
proj-⊎₂ {A = A}{B} (map inj₂ l) ≡ l
map-proj-⊎₂ [] = refl
map-proj-⊎₂ {A = A}{B} (x :: l) rewrite map-proj-⊎₂ {A = A}{B} l = refl
map-proj-⊎₂-[] : ∀{ℓ ℓ'}{A : Set ℓ}{B : Set ℓ'} → (l : 𝕃 A) →
proj-⊎₂ {A = A}{B} (map inj₁ l) ≡ []
map-proj-⊎₂-[] [] = refl
map-proj-⊎₂-[] {A = A}{B} (x :: l) rewrite map-proj-⊎₂-[] {A = A}{B} l = refl
map-proj-⊎₁-[] : ∀{ℓ ℓ'}{A : Set ℓ}{B : Set ℓ'} → (l : 𝕃 B) →
proj-⊎₁ {A = A}{B} (map inj₂ l) ≡ []
map-proj-⊎₁-[] [] = refl
map-proj-⊎₁-[] {A = A}{B} (x :: l) rewrite map-proj-⊎₁-[] {A = A}{B} l = refl
is-empty-++ : ∀{ℓ}{A : Set ℓ}(l1 l2 : 𝕃 A) → is-empty (l1 ++ l2) ≡ is-empty l1 && is-empty l2
is-empty-++ [] l2 = refl
is-empty-++ (x :: l1) l2 = refl
is-empty-ff-length : ∀{ℓ}{A : Set ℓ}(l : 𝕃 A) → is-empty l ≡ ff → length l =ℕ 0 ≡ ff
is-empty-ff-length [] ()
is-empty-ff-length (x :: l) p = refl
| {
"alphanum_fraction": 0.5093018796,
"avg_line_length": 46.972972973,
"ext": "agda",
"hexsha": "ee1b17cd5fbf3f95539efd673402e28cbfd42fc6",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "heades/AUGL",
"max_forks_repo_path": "list-thms.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "heades/AUGL",
"max_issues_repo_path": "list-thms.agda",
"max_line_length": 172,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "heades/AUGL",
"max_stars_repo_path": "list-thms.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 4738,
"size": 10428
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Pointwise lifting of relations to vectors
------------------------------------------------------------------------
module Relation.Binary.Vec.Pointwise where
open import Category.Applicative.Indexed
open import Data.Fin
open import Data.Nat
open import Data.Plus as Plus hiding (equivalent; map)
open import Data.Vec as Vec hiding ([_]; head; tail; map)
import Data.Vec.Properties as VecProp
open import Function
open import Function.Equality using (_⟨$⟩_)
open import Function.Equivalence as Equiv
using (_⇔_; ⇔-setoid; module Equivalence)
import Level
open import Relation.Binary
open import Relation.Binary.PropositionalEquality as P using (_≡_)
open import Relation.Nullary
import Relation.Nullary.Decidable as Dec
-- Functional definition.
record Pointwise {ℓ} {A B : Set ℓ} (_∼_ : REL A B ℓ)
{n} (xs : Vec A n) (ys : Vec B n) : Set ℓ where
constructor ext
field app : ∀ i → lookup i xs ∼ lookup i ys
-- Inductive definition.
infixr 5 _∷_
data Pointwise′ {ℓ} {A B : Set ℓ} (_∼_ : REL A B ℓ) :
∀ {n} (xs : Vec A n) (ys : Vec B n) → Set ℓ where
[] : Pointwise′ _∼_ [] []
_∷_ : ∀ {n x y} {xs : Vec A n} {ys : Vec B n}
(x∼y : x ∼ y) (xs∼ys : Pointwise′ _∼_ xs ys) →
Pointwise′ _∼_ (x ∷ xs) (y ∷ ys)
-- The two definitions are equivalent.
equivalent : ∀ {ℓ} {A B : Set ℓ} {_∼_ : REL A B ℓ} {n}
{xs : Vec A n} {ys : Vec B n} →
Pointwise _∼_ xs ys ⇔ Pointwise′ _∼_ xs ys
equivalent {A = A} {B} {_∼_} = Equiv.equivalence (to _ _) from
where
to : ∀ {n} (xs : Vec A n) (ys : Vec B n) →
Pointwise _∼_ xs ys → Pointwise′ _∼_ xs ys
to [] [] xs∼ys = []
to (x ∷ xs) (y ∷ ys) xs∼ys =
Pointwise.app xs∼ys zero ∷
to xs ys (ext (Pointwise.app xs∼ys ∘ suc))
nil : Pointwise _∼_ [] []
nil = ext λ()
cons : ∀ {n x y} {xs : Vec A n} {ys : Vec B n} →
x ∼ y → Pointwise _∼_ xs ys → Pointwise _∼_ (x ∷ xs) (y ∷ ys)
cons {x = x} {y} {xs} {ys} x∼y xs∼ys = ext helper
where
helper : ∀ i → lookup i (x ∷ xs) ∼ lookup i (y ∷ ys)
helper zero = x∼y
helper (suc i) = Pointwise.app xs∼ys i
from : ∀ {n} {xs : Vec A n} {ys : Vec B n} →
Pointwise′ _∼_ xs ys → Pointwise _∼_ xs ys
from [] = nil
from (x∼y ∷ xs∼ys) = cons x∼y (from xs∼ys)
-- Some destructors.
head : ∀ {ℓ} {A B : Set ℓ} {_∼_ : REL A B ℓ} {n x y xs} {ys : Vec B n} →
Pointwise′ _∼_ (x ∷ xs) (y ∷ ys) → x ∼ y
head (x∼y ∷ xs∼ys) = x∼y
tail : ∀ {ℓ} {A B : Set ℓ} {_∼_ : REL A B ℓ} {n x y xs} {ys : Vec B n} →
Pointwise′ _∼_ (x ∷ xs) (y ∷ ys) → Pointwise′ _∼_ xs ys
tail (x∼y ∷ xs∼ys) = xs∼ys
-- Pointwise preserves reflexivity.
refl : ∀ {ℓ} {A : Set ℓ} {_∼_ : Rel A ℓ} {n} →
Reflexive _∼_ → Reflexive (Pointwise _∼_ {n = n})
refl rfl = ext (λ _ → rfl)
-- Pointwise preserves symmetry.
sym : ∀ {ℓ} {A B : Set ℓ} {P : REL A B ℓ} {Q : REL B A ℓ} {n} →
Sym P Q → Sym (Pointwise P) (Pointwise Q {n = n})
sym sm xs∼ys = ext λ i → sm (Pointwise.app xs∼ys i)
-- Pointwise preserves transitivity.
trans : ∀ {ℓ} {A B C : Set ℓ}
{P : REL A B ℓ} {Q : REL B C ℓ} {R : REL A C ℓ} {n} →
Trans P Q R →
Trans (Pointwise P) (Pointwise Q) (Pointwise R {n = n})
trans trns xs∼ys ys∼zs = ext λ i →
trns (Pointwise.app xs∼ys i) (Pointwise.app ys∼zs i)
-- Pointwise preserves equivalences.
isEquivalence :
∀ {ℓ} {A : Set ℓ} {_∼_ : Rel A ℓ} {n} →
IsEquivalence _∼_ → IsEquivalence (Pointwise _∼_ {n = n})
isEquivalence equiv = record
{ refl = refl (IsEquivalence.refl equiv)
; sym = sym (IsEquivalence.sym equiv)
; trans = trans (IsEquivalence.trans equiv)
}
-- Pointwise preserves decidability.
decidable : ∀ {ℓ} {A B : Set ℓ} {_∼_ : REL A B ℓ} →
Decidable _∼_ → ∀ {n} → Decidable (Pointwise _∼_ {n = n})
decidable {_∼_ = _∼_} dec xs ys =
Dec.map (Setoid.sym (⇔-setoid _) equivalent) (decidable′ xs ys)
where
decidable′ : ∀ {n} → Decidable (Pointwise′ _∼_ {n = n})
decidable′ [] [] = yes []
decidable′ (x ∷ xs) (y ∷ ys) with dec x y
... | no ¬x∼y = no (¬x∼y ∘ head)
... | yes x∼y with decidable′ xs ys
... | no ¬xs∼ys = no (¬xs∼ys ∘ tail)
... | yes xs∼ys = yes (x∼y ∷ xs∼ys)
-- Pointwise _≡_ is equivalent to _≡_.
Pointwise-≡ : ∀ {ℓ} {A : Set ℓ} {n} {xs ys : Vec A n} →
Pointwise _≡_ xs ys ⇔ xs ≡ ys
Pointwise-≡ {ℓ} {A} =
Equiv.equivalence
(to ∘ _⟨$⟩_ {f₂ = ℓ} (Equivalence.to equivalent))
(λ xs≡ys → P.subst (Pointwise _≡_ _) xs≡ys (refl P.refl))
where
to : ∀ {n} {xs ys : Vec A n} → Pointwise′ _≡_ xs ys → xs ≡ ys
to [] = P.refl
to (P.refl ∷ xs∼ys) = P.cong (_∷_ _) $ to xs∼ys
-- Pointwise and Plus commute when the underlying relation is
-- reflexive.
⁺∙⇒∙⁺ : ∀ {ℓ} {A : Set ℓ} {_∼_ : Rel A ℓ} {n} {xs ys : Vec A n} →
Plus (Pointwise _∼_) xs ys → Pointwise (Plus _∼_) xs ys
⁺∙⇒∙⁺ [ ρ≈ρ′ ] = ext (λ x → [ Pointwise.app ρ≈ρ′ x ])
⁺∙⇒∙⁺ (ρ ∼⁺⟨ ρ≈ρ′ ⟩ ρ′≈ρ″) =
ext (λ x → _ ∼⁺⟨ Pointwise.app (⁺∙⇒∙⁺ ρ≈ρ′ ) x ⟩
Pointwise.app (⁺∙⇒∙⁺ ρ′≈ρ″) x)
∙⁺⇒⁺∙ : ∀ {ℓ} {A : Set ℓ} {_∼_ : Rel A ℓ} {n} {xs ys : Vec A n} →
Reflexive _∼_ →
Pointwise (Plus _∼_) xs ys → Plus (Pointwise _∼_) xs ys
∙⁺⇒⁺∙ {ℓ} {A} {_∼_} x∼x =
Plus.map (_⟨$⟩_ {f₂ = ℓ} (Equivalence.from equivalent)) ∘
helper ∘
_⟨$⟩_ {f₂ = ℓ} (Equivalence.to equivalent)
where
helper : ∀ {n} {xs ys : Vec A n} →
Pointwise′ (Plus _∼_) xs ys → Plus (Pointwise′ _∼_) xs ys
helper [] = [ [] ]
helper (_∷_ {x = x} {y = y} {xs = xs} {ys = ys} x∼y xs∼ys) =
x ∷ xs ∼⁺⟨ Plus.map (λ x∼y → x∼y ∷ xs∼xs) x∼y ⟩
y ∷ xs ∼⁺⟨ Plus.map (λ xs∼ys → x∼x ∷ xs∼ys) (helper xs∼ys) ⟩∎
y ∷ ys ∎
where
xs∼xs : Pointwise′ _∼_ xs xs
xs∼xs = _⟨$⟩_ {f₂ = ℓ} (Equivalence.to equivalent) (refl x∼x)
-- Note that ∙⁺⇒⁺∙ cannot be defined if the requirement of reflexivity
-- is dropped.
private
module Counterexample where
data D : Set where
i j x y z : D
data _R_ : Rel D Level.zero where
iRj : i R j
xRy : x R y
yRz : y R z
xR⁺z : x [ _R_ ]⁺ z
xR⁺z =
x ∼⁺⟨ [ xRy ] ⟩
y ∼⁺⟨ [ yRz ] ⟩∎
z ∎
ix : Vec D 2
ix = i ∷ x ∷ []
jz : Vec D 2
jz = j ∷ z ∷ []
ix∙⁺jz : Pointwise′ (Plus _R_) ix jz
ix∙⁺jz = [ iRj ] ∷ xR⁺z ∷ []
¬ix⁺∙jz : ¬ Plus′ (Pointwise′ _R_) ix jz
¬ix⁺∙jz [ iRj ∷ () ∷ [] ]
¬ix⁺∙jz ((iRj ∷ xRy ∷ []) ∷ [ () ∷ yRz ∷ [] ])
¬ix⁺∙jz ((iRj ∷ xRy ∷ []) ∷ (() ∷ yRz ∷ []) ∷ _)
counterexample :
¬ (∀ {n} {xs ys : Vec D n} →
Pointwise (Plus _R_) xs ys →
Plus (Pointwise _R_) xs ys)
counterexample ∙⁺⇒⁺∙ =
¬ix⁺∙jz (Equivalence.to Plus.equivalent ⟨$⟩
Plus.map (_⟨$⟩_ (Equivalence.to equivalent))
(∙⁺⇒⁺∙ (Equivalence.from equivalent ⟨$⟩ ix∙⁺jz)))
-- Map.
map : ∀ {ℓ} {A : Set ℓ} {_R_ _R′_ : Rel A ℓ} {n} →
_R_ ⇒ _R′_ → Pointwise _R_ ⇒ Pointwise _R′_ {n}
map R⇒R′ xsRys = ext λ i →
R⇒R′ (Pointwise.app xsRys i)
-- A variant.
gmap : ∀ {ℓ} {A A′ : Set ℓ}
{_R_ : Rel A ℓ} {_R′_ : Rel A′ ℓ} {f : A → A′} {n} →
_R_ =[ f ]⇒ _R′_ →
Pointwise _R_ =[ Vec.map {n = n} f ]⇒ Pointwise _R′_
gmap {_R′_ = _R′_} {f} R⇒R′ {i = xs} {j = ys} xsRys = ext λ i →
let module M = Morphism (VecProp.lookup-morphism i) in
P.subst₂ _R′_ (P.sym $ M.op-<$> f xs)
(P.sym $ M.op-<$> f ys)
(R⇒R′ (Pointwise.app xsRys i))
| {
"alphanum_fraction": 0.5137031643,
"avg_line_length": 32.2777777778,
"ext": "agda",
"hexsha": "722645f72e0babc8d42cef28b4b5f60fe44d13c0",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "qwe2/try-agda",
"max_forks_repo_path": "agda-stdlib-0.9/src/Relation/Binary/Vec/Pointwise.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "qwe2/try-agda",
"max_issues_repo_path": "agda-stdlib-0.9/src/Relation/Binary/Vec/Pointwise.agda",
"max_line_length": 72,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "qwe2/try-agda",
"max_stars_repo_path": "agda-stdlib-0.9/src/Relation/Binary/Vec/Pointwise.agda",
"max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z",
"num_tokens": 3257,
"size": 7553
} |
-- Andreas, 2017-01-26. Testing the --no-eta-equality option.
-- Records in files without the option (unless Agda runs with this
-- option globally), should have eta.
module HaveEtaForImportedRecords.EtaRecord where
open import Agda.Builtin.Equality public
record ⊤ : Set where
private
test : ∀{x y : ⊤} → x ≡ y
test = refl
| {
"alphanum_fraction": 0.7185628743,
"avg_line_length": 22.2666666667,
"ext": "agda",
"hexsha": "9c164efe9fa9d5d0a23745941632fff20b1f9463",
"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/HaveEtaForImportedRecords/EtaRecord.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/HaveEtaForImportedRecords/EtaRecord.agda",
"max_line_length": 66,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/HaveEtaForImportedRecords/EtaRecord.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": 98,
"size": 334
} |
module _ where
open import Agda.Builtin.Nat
module Postulates where
infixl 5 _<*>_
postulate
F : Set → Set
pure : ∀ {A} → A → F A
_<*>_ : ∀ {A B} → F (A → B) → F A → F B
test₀ : F Nat → F Nat → F Nat
test₀ a b = (| a + b |)
test₁ : F Nat
test₁ = (| 5 |)
test₂ : F Nat → F Nat
test₂ a = (| suc a |)
test₃ : F Nat → F Nat
test₃ a = (| (_+ 5) a |)
-- Spaces are required! (Issue #2186)
test₄ : Nat → Nat
test₄ |n| = suc (|n| + |n|)
module Params {F : Set → Set}
(pure : ∀ {A} → A → F A)
(_<*>_ : ∀ {A B} → F (A → B) → F A → F B) where
test₀ : F Nat → F Nat → F Nat
test₀ a b = (| a + b |)
test₁ : F Nat
test₁ = (| 5 |)
test₂ : F Nat → F Nat
test₂ a = (| suc a |)
test₃ : F Nat → F Nat
test₃ a = (| (_+ 5) a |)
| {
"alphanum_fraction": 0.4499381953,
"avg_line_length": 17.5869565217,
"ext": "agda",
"hexsha": "0983c6f1afec5fdf8fe4c81be796462fd692a8c4",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "alhassy/agda",
"max_forks_repo_path": "test/Succeed/IdiomBrackets.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/IdiomBrackets.agda",
"max_line_length": 61,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "alhassy/agda",
"max_stars_repo_path": "test/Succeed/IdiomBrackets.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": 350,
"size": 809
} |
open import Data.Boolean
open import Type
module Data.List.Sorting.HeapSort {ℓ} {T : Type{ℓ}} (_≤?_ : T → T → Bool) where
import Lvl
open import Data.List
import Data.List.Functions as List
open import Data.BinaryTree
import Data.BinaryTree.Heap as Heap
open import Functional using (_∘_)
heapSort : List(T) → List(T)
heapSort = Heap.foldOrdered(_≤?_)(_⊰_) ∅ ∘ List.foldᵣ(Heap.insert(_≤?_)) emptyTree
module Proofs where
| {
"alphanum_fraction": 0.7065462754,
"avg_line_length": 24.6111111111,
"ext": "agda",
"hexsha": "c5e1a6672fe134d6db887f9172c526a211eda593",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Data/List/Sorting/HeapSort.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Data/List/Sorting/HeapSort.agda",
"max_line_length": 82,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Data/List/Sorting/HeapSort.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": 139,
"size": 443
} |
module Lemmachine.Default.Lemmas where
open import Lemmachine
import Lemmachine.Default
import Lemmachine.Lemmas
open Lemmachine.Lemmas Lemmachine.Default.resource
open import Relation.Binary.PropositionalEquality
open import Data.Empty
open import Data.Maybe
open import Data.Product hiding (map)
open import Data.Function using (const)
open import Data.List.Any hiding (any)
methodAlwaysKnown : ∀ r → any (eqMethod (method r))
(knownMethods r) ≡ true
methodAlwaysKnown r with method r
... | HEAD = refl
... | GET = refl
... | PUT = refl
... | DELETE = refl
... | POST = refl
... | TRACE = refl
... | CONNECT = refl
... | OPTIONS = refl
| {
"alphanum_fraction": 0.7087087087,
"avg_line_length": 26.64,
"ext": "agda",
"hexsha": "ab900e211f9004a98bc02df76cecbb32d1089246",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z",
"max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "isabella232/Lemmachine",
"max_forks_repo_path": "src/Lemmachine/Default/Lemmas.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "larrytheliquid/Lemmachine",
"max_issues_repo_path": "src/Lemmachine/Default/Lemmas.agda",
"max_line_length": 51,
"max_stars_count": 56,
"max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "isabella232/Lemmachine",
"max_stars_repo_path": "src/Lemmachine/Default/Lemmas.agda",
"max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z",
"num_tokens": 162,
"size": 666
} |
-- Andreas, 2020-03-27, issue #3684
-- Warn about duplicate fields instead of hard error.
module DuplicateFields where
postulate X : Set
record D : Set where
field x : X
d : X → X → D
d x y = record{ x = x; x = y }
| {
"alphanum_fraction": 0.6515837104,
"avg_line_length": 17,
"ext": "agda",
"hexsha": "c9d24e6cef41de2d7db0f6e2bd544c97d79b725c",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "shlevy/agda",
"max_forks_repo_path": "test/Succeed/DuplicateFields.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/DuplicateFields.agda",
"max_line_length": 53,
"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/DuplicateFields.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": 71,
"size": 221
} |
{-# OPTIONS --without-K --exact-split --allow-unsolved-metas #-}
module 14-image where
import 13-propositional-truncation
open 13-propositional-truncation public
{- We introduce the image inclusion of a map. -}
precomp-emb :
{ l1 l2 l3 l4 : Level} {X : UU l1} {A : UU l2} (f : A → X)
{B : UU l3} ( i : B ↪ X) (q : hom-slice f (map-emb i)) →
{C : UU l4} ( j : C ↪ X) (r : hom-slice (map-emb i) (map-emb j)) →
hom-slice f (map-emb j)
precomp-emb f i q j r =
pair
( ( map-hom-slice (map-emb i) (map-emb j) r) ∘
( map-hom-slice f (map-emb i) q))
( ( triangle-hom-slice f (map-emb i) q) ∙h
( ( triangle-hom-slice (map-emb i) (map-emb j) r) ·r
( map-hom-slice f (map-emb i) q)))
is-prop-hom-slice :
{ l1 l2 l3 : Level} {X : UU l1} {A : UU l2} (f : A → X) →
{ B : UU l3} (i : B ↪ X) → is-prop (hom-slice f (map-emb i))
is-prop-hom-slice {X = X} f i =
is-prop-is-equiv
( (x : X) → fib f x → fib (map-emb i) x)
( fiberwise-hom-hom-slice f (map-emb i))
( is-equiv-fiberwise-hom-hom-slice f (map-emb i))
( is-prop-Π
( λ x → is-prop-Π
( λ p → is-prop-map-is-emb (map-emb i) (is-emb-map-emb i) x)))
universal-property-image :
( l : Level) {l1 l2 l3 : Level} {X : UU l1} {A : UU l2} (f : A → X) →
{ B : UU l3} (i : B ↪ X) (q : hom-slice f (map-emb i)) →
UU (lsuc l ⊔ l1 ⊔ l2 ⊔ l3)
universal-property-image l {X = X} f i q =
( C : UU l) (j : C ↪ X) → is-equiv (precomp-emb f i q j)
universal-property-image' :
( l : Level) {l1 l2 l3 : Level} {X : UU l1} {A : UU l2} (f : A → X) →
{ B : UU l3} (i : B ↪ X) (q : hom-slice f (map-emb i)) →
UU (lsuc l ⊔ l1 ⊔ l2 ⊔ l3)
universal-property-image' l {X = X} f i q =
( C : UU l) (j : C ↪ X) →
hom-slice f (map-emb j) → hom-slice (map-emb i) (map-emb j)
universal-property-image-universal-property-image' :
( l : Level) {l1 l2 l3 : Level} {X : UU l1} {A : UU l2} (f : A → X) →
{ B : UU l3} (i : B ↪ X) (q : hom-slice f (map-emb i)) →
universal-property-image' l f i q → universal-property-image l f i q
universal-property-image-universal-property-image' l f i q up' C j =
is-equiv-is-prop
( is-prop-hom-slice (map-emb i) j)
( is-prop-hom-slice f j)
( up' C j)
-- Section 13.4
is-small :
(l : Level) {l1 : Level} (A : UU l1) → UU (lsuc l ⊔ l1)
is-small l A = Σ (UU l) (λ X → A ≃ X)
is-small-map :
(l : Level) {l1 l2 : Level} {A : UU l1} {B : UU l2} →
(A → B) → UU (lsuc l ⊔ (l1 ⊔ l2))
is-small-map l {B = B} f = (b : B) → is-small l (fib f b)
is-locally-small :
(l : Level) {l1 : Level} (A : UU l1) → UU (lsuc l ⊔ l1)
is-locally-small l A = (x y : A) → is-small l (Id x y)
total-subtype :
{l1 l2 : Level} {A : UU l1} (P : A → UU-Prop l2) → UU (l1 ⊔ l2)
total-subtype {A = A} P = Σ A (λ x → pr1 (P x))
equiv-subtype-equiv :
{l1 l2 l3 l4 : Level}
{A : UU l1} {B : UU l2} (e : A ≃ B)
(C : A → UU-Prop l3) (D : B → UU-Prop l4) →
((x : A) → (C x) ↔ (D (map-equiv e x))) →
total-subtype C ≃ total-subtype D
equiv-subtype-equiv e C D H =
equiv-toto (λ y → type-Prop (D y)) e
( λ x → equiv-iff (C x) (D (map-equiv e x)) (H x))
equiv-comp-equiv' :
{l1 l2 l3 : Level} {A : UU l1} {B : UU l2} →
(A ≃ B) → (C : UU l3) → (B ≃ C) ≃ (A ≃ C)
equiv-comp-equiv' e C =
equiv-subtype-equiv
( equiv-precomp-equiv e C)
( is-equiv-Prop)
( is-equiv-Prop)
( λ g →
pair
( is-equiv-comp' g (map-equiv e) (is-equiv-map-equiv e))
( λ is-equiv-eg →
is-equiv-left-factor'
g (map-equiv e) is-equiv-eg (is-equiv-map-equiv e)))
is-prop-is-small :
(l : Level) {l1 : Level} (A : UU l1) → is-prop (is-small l A)
is-prop-is-small l A =
is-prop-is-contr-if-inh
( λ Xe →
is-contr-equiv'
( Σ (UU l) (λ Y → (pr1 Xe) ≃ Y))
( equiv-tot ((λ Y → equiv-comp-equiv' (pr2 Xe) Y)))
( is-contr-total-equiv (pr1 Xe)))
is-prop-is-locally-small :
(l : Level) {l1 : Level} (A : UU l1) → is-prop (is-locally-small l A)
is-prop-is-locally-small l A =
is-prop-Π (λ x → is-prop-Π (λ y → is-prop-is-small l (Id x y)))
| {
"alphanum_fraction": 0.5334650531,
"avg_line_length": 34.313559322,
"ext": "agda",
"hexsha": "8598df054fd8413f472a20c194491313debb99bc",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934",
"max_forks_repo_licenses": [
"CC-BY-4.0"
],
"max_forks_repo_name": "hemangandhi/HoTT-Intro",
"max_forks_repo_path": "Agda/14-image.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"CC-BY-4.0"
],
"max_issues_repo_name": "hemangandhi/HoTT-Intro",
"max_issues_repo_path": "Agda/14-image.agda",
"max_line_length": 71,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934",
"max_stars_repo_licenses": [
"CC-BY-4.0"
],
"max_stars_repo_name": "hemangandhi/HoTT-Intro",
"max_stars_repo_path": "Agda/14-image.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1734,
"size": 4049
} |
module Builtin where
data Bool : Set where
false : Bool
true : Bool
not : Bool -> Bool
not true = false
not false = true
_||_ : Bool -> Bool -> Bool
true || _ = true
false || x = x
_&&_ : Bool -> Bool -> Bool
true && x = x
false && _ = false
{-# BUILTIN BOOL Bool #-}
{-# BUILTIN TRUE true #-}
{-# BUILTIN FALSE false #-}
data Nat : Set where
zero : Nat
suc : Nat -> Nat
{-# BUILTIN NATURAL Nat #-}
zero' : Nat
zero' = 0
one : Nat
one = 1
data Int : Set where
pos : Nat → Int
negsuc : Nat → Int
postulate
String : Set
Float : Set
Char : Set
{-# BUILTIN INTEGER Int #-}
{-# BUILTIN INTEGERPOS pos #-}
{-# BUILTIN INTEGERNEGSUC negsuc #-}
{-# BUILTIN STRING String #-}
{-# BUILTIN FLOAT Float #-}
{-# BUILTIN CHAR Char #-}
infixr 10 _::_
data List (A : Set) : Set where
nil : List A
_::_ : A -> List A -> List A
{-# BUILTIN LIST List #-}
{-# BUILTIN NIL nil #-}
{-# BUILTIN CONS _::_ #-}
primitive
-- Integer functions
primShowInteger : Int -> String
-- Floating point functions
primNatToFloat : Nat -> Float
primFloatPlus : Float -> Float -> Float
primFloatMinus : Float -> Float -> Float
primFloatTimes : Float -> Float -> Float
primFloatDiv : Float -> Float -> Float
primFloatLess : Float -> Float -> Bool
primFloatSqrt : Float -> Float
primRound : Float -> Int
primFloor : Float -> Int
primCeiling : Float -> Int
primExp : Float -> Float
primLog : Float -> Float
primSin : Float -> Float
primShowFloat : Float -> String
-- Character functions
primCharEquality : Char -> Char -> Bool
primIsLower : Char -> Bool
primIsDigit : Char -> Bool
primIsAlpha : Char -> Bool
primIsSpace : Char -> Bool
primIsAscii : Char -> Bool
primIsLatin1 : Char -> Bool
primIsPrint : Char -> Bool
primIsHexDigit : Char -> Bool
primToUpper : Char -> Char
primToLower : Char -> Char
primCharToNat : Char -> Nat
primNatToChar : Nat -> Char -- partial
primShowChar : Char -> String
-- String functions
primStringToList : String -> List Char
primStringFromList : List Char -> String
primStringAppend : String -> String -> String
primStringEquality : String -> String -> Bool
primShowString : String -> String
isLower : Char -> Bool
isLower = primIsLower
isAlpha : Char -> Bool
isAlpha = primIsAlpha
isUpper : Char -> Bool
isUpper c = isAlpha c && not (isLower c)
infixl 14 _/_
nat0 = primCharToNat '\0'
int0 = pos nat0
_/_ = primFloatDiv
pi : Float
pi = 3.141592653589793
sin : Float -> Float
sin = primSin
cos : Float -> Float
cos x = sin (primFloatMinus (pi / 2.0) x)
tan : Float -> Float
tan x = sin x / cos x
reverse : {A : Set} -> List A -> List A
reverse xs = rev xs nil
where
rev : {A : Set} -> List A -> List A -> List A
rev nil ys = ys
rev (x :: xs) ys = rev xs (x :: ys)
infixr 20 _∘_
_∘_ : {A B C : Set} -> (B -> C) -> (A -> B) -> A -> C
f ∘ g = \x -> f (g x)
map : {A B : Set} -> (A -> B) -> List A -> List B
map f nil = nil
map f (x :: xs) = f x :: map f xs
stringAsList : (List Char -> List Char) -> String -> String
stringAsList f = primStringFromList ∘ f ∘ primStringToList
revStr : String -> String
revStr = stringAsList reverse
mapStr : (Char -> Char) -> String -> String
mapStr f = stringAsList (map f)
-- Testing unicode literals
uString = "åäö⊢ξ∀"
uChar = '∀'
data _≡_ {a} {A : Set a} (x : A) : A → Set a where
refl : x ≡ x
thm-show-pos : primShowInteger (pos 42) ≡ "42"
thm-show-pos = refl
thm-show-neg : primShowInteger (negsuc 41) ≡ "-42"
thm-show-neg = refl
thm-floor : primFloor 4.2 ≡ pos 4
thm-floor = refl
thm-ceiling : primCeiling -5.1 ≡ negsuc 4
thm-ceiling = refl
| {
"alphanum_fraction": 0.5845597728,
"avg_line_length": 22.2586206897,
"ext": "agda",
"hexsha": "9da5c1582ecdc6e43d62a1b0416445c5a10a07e7",
"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/Succeed/Builtin.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/Builtin.agda",
"max_line_length": 59,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "redfish64/autonomic-agda",
"max_stars_repo_path": "test/Succeed/Builtin.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1234,
"size": 3873
} |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category using (Category)
-- 'Heterogeneous' identity morphism and some laws about them.
module Categories.Morphism.HeterogeneousIdentity {o ℓ e} (C : Category o ℓ e) where
open import Level
open import Relation.Binary.PropositionalEquality
import Categories.Morphism as Morphism
open Category C
open Morphism C
-- If Agda was an extensional type theory, any pair of morphisms
--
-- f : A ⇒ B and g : A ⇒ C,
--
-- where `A ≡ B`, would belong to the same homset, even if `A` and `B`
-- are not definitionally equal. In particular, the identity on `B`
-- could be given the type |id {B} : B ⇒ C|.
--
-- But Agda is an intensional type theory, so the identity cannot have
-- this type, in general. Instead one needs to manually 'transport'
-- |id {B}| into the homset |B ⇒ C|. Given |p : B ≡ C| one obtains
--
-- subst (B ⇒_) p (id {B})
--
-- Morphisms like thes are no longer identities (in the strict
-- sense) but they still enjoy many of the properties identities do.
--
-- To make this precise, this module introduces a notion of
-- 'heterogeneous identity', which is an identity morphism whose
-- domain and codomain are propositionally equal (but not necessarily
-- syntically equal).
-- A heterogeneous identity is just the transport of an identity
-- along a 'strict' equation of objects.
hid : ∀ {A B} (p : A ≡ B) → A ⇒ B
hid {A} p = subst (A ⇒_) p id
-- Lemmas about heterogeneous identities
hid-refl : ∀ {A : Obj} → hid refl ≈ id {A}
hid-refl = Equiv.refl
hid-trans : ∀ {A B C} (p : B ≡ C) (q : A ≡ B) →
hid p ∘ hid q ≈ hid (trans q p)
hid-trans refl refl = identityˡ
hid-symˡ : ∀ {A B} (p : A ≡ B) → hid (sym p) ∘ hid p ≈ id {A}
hid-symˡ refl = identityˡ
hid-symʳ : ∀ {A B} (p : A ≡ B) → hid p ∘ hid (sym p) ≈ id {B}
hid-symʳ refl = identityˡ
hid-iso : ∀ {A B} (p : A ≡ B) → Iso (hid p) (hid (sym p))
hid-iso p = record { isoˡ = hid-symˡ p ; isoʳ = hid-symʳ p }
hid-cong : ∀ {A B} {p q : A ≡ B} → p ≡ q → hid p ≈ hid q
hid-cong refl = Equiv.refl
-- Transporting the domain/codomain is the same as
-- pre/post-composing with heterogeneous identity.
hid-subst-dom : ∀ {A B C} (p : A ≡ B) (f : B ⇒ C) →
subst (_⇒ C) (sym p) f ≈ f ∘ hid p
hid-subst-dom refl f = Equiv.sym identityʳ
hid-subst-cod : ∀ {A B C} (f : A ⇒ B) (p : B ≡ C) →
subst (A ⇒_) p f ≈ hid p ∘ f
hid-subst-cod f refl = Equiv.sym identityˡ
hid-subst₂ : ∀ {A B C D} (p : A ≡ B) (q : C ≡ D) (f : A ⇒ C) →
subst₂ (_⇒_) p q f ≈ hid q ∘ f ∘ hid (sym p)
hid-subst₂ refl refl f = Equiv.sym (Equiv.trans identityˡ identityʳ)
| {
"alphanum_fraction": 0.6248103187,
"avg_line_length": 32.5432098765,
"ext": "agda",
"hexsha": "6f915ec84fd60ee9cb2201cd10356f9f9363c0ee",
"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": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "MirceaS/agda-categories",
"max_forks_repo_path": "src/Categories/Morphism/HeterogeneousIdentity.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"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": "MirceaS/agda-categories",
"max_issues_repo_path": "src/Categories/Morphism/HeterogeneousIdentity.agda",
"max_line_length": 83,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "MirceaS/agda-categories",
"max_stars_repo_path": "src/Categories/Morphism/HeterogeneousIdentity.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 896,
"size": 2636
} |
{-# OPTIONS --allow-unsolved-metas #-}
open import Oscar.Class
open import Oscar.Class.Smap
open import Oscar.Class.Transitivity
open import Oscar.Class.Reflexivity
open import Oscar.Class.Transleftidentity
open import Oscar.Class.Symmetry
open import Oscar.Class.Hmap
open import Oscar.Data.Proposequality
open import Oscar.Data.Substitunction
open import Oscar.Data.Term
open import Oscar.Prelude
module Test.ProblemWithDerivation-3 where
postulate
A : Set
B : Set
_~A~_ : A → A → Set
_~B~_ : B → B → Set
s1 : A → B
f1 : ∀ {x y} → x ~A~ y → s1 x ~B~ s1 y
instance
𝓢urjectivity1 : Smap.class _~A~_ _~B~_ s1 s1
𝓢urjectivity1 .⋆ _ _ = f1
module _ {𝔭} {𝔓 : Ø 𝔭} where
open Substitunction 𝔓
open Term 𝔓
test-1-before : ∀ {x y} → x ~A~ y → s1 x ~B~ s1 y
test-1-before {x} {y} = smap
instance
HmapFromTransleftidentitySymmetry : ∀
{𝔵} {𝔛 : Ø 𝔵}
{𝔞} {𝔄 : 𝔛 → Ø 𝔞}
{𝔟} {𝔅 : 𝔛 → Ø 𝔟}
(let _∼_ = Arrow 𝔄 𝔅)
{ℓ̇} {_∼̇_ : ∀ {x y} → x ∼ y → x ∼ y → Ø ℓ̇}
{transitivity : Transitivity.type _∼_}
{reflexivity : Reflexivity.type _∼_}
{ℓ}
⦃ _ : Transleftidentity.class _∼_ _∼̇_ reflexivity transitivity ⦄
⦃ _ : ∀ {x y} → Symmetry.class (_∼̇_ {x} {y}) ⦄
→ ∀ {m n}
→ Hmap.class (λ (f : m ∼ n) (P : LeftExtensionṖroperty ℓ _∼_ _∼̇_ m) → π₀ (π₀ P) f)
(λ f P → π₀ (π₀ P) (transitivity f reflexivity))
HmapFromTransleftidentitySymmetry .⋆ P₁ (π₂ , π₃) = π₃ $ symmetry transleftidentity
instance
𝓣ransleftidentityExtension :
∀ {a} {A : Ø a} {b} {B : A → Ø b}
→ Transleftidentity.class (Extension B) _≡̇_ ¡ (flip _∘′_)
𝓣ransleftidentityExtension .⋆ _ = ∅
TransleftidentityFunction :
∀ {𝔬}
→ Transleftidentity.class Function⟦ 𝔬 ⟧ _≡̇_ ¡ (flip _∘′_)
TransleftidentityFunction .⋆ _ = ∅
-- Oscar.Property.Setoid.Proposextensequality
module _ {𝔬} {𝔒 : Ø 𝔬} {𝔭} {𝔓 : 𝔒 → Ø 𝔭} where
instance
𝓢ymmetryProposextensequality : Symmetry.class Proposextensequality⟦ 𝔓 ⟧
𝓢ymmetryProposextensequality .⋆ f₁≡̇f₂ x rewrite f₁≡̇f₂ x = ∅
test-1-after : ∀ {x y} → x ~A~ y → s1 x ~B~ s1 y
test-1-after {x} {y} = smap -- FIXME confusion somehow due to 𝓣ransleftidentityExtension, which is somewhat redundant (i.e. we don't need it as an instance given TransleftidentityFunction). needs explanation. -- FIXME ah ha! this is fixed by modification of Symmetry.class (or maybe is it b/c we don't have a Symmetry instance). -- FIXME we still need to see why this doesn't work when we use import Everything. -- FIXME answer is seen by adding `𝓢ymmetryProposextensequality`
| {
"alphanum_fraction": 0.6524437548,
"avg_line_length": 33.0512820513,
"ext": "agda",
"hexsha": "aebcbb36a6b777ff2222beb0001a41590431ab50",
"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/Test/ProblemWithDerivation-3.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/Test/ProblemWithDerivation-3.agda",
"max_line_length": 476,
"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/Test/ProblemWithDerivation-3.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1005,
"size": 2578
} |
open import Level
open import Ordinals
module VL {n : Level } (O : Ordinals {n}) where
open import zf
open import logic
import OD
open import Relation.Nullary
open import Relation.Binary
open import Data.Empty
open import Relation.Binary
open import Relation.Binary.Core
open import Relation.Binary.PropositionalEquality
open import Data.Nat renaming ( zero to Zero ; suc to Suc ; ℕ to Nat ; _⊔_ to _n⊔_ )
import BAlgbra
open BAlgbra O
open inOrdinal O
import OrdUtil
import ODUtil
open Ordinals.Ordinals O
open Ordinals.IsOrdinals isOrdinal
open Ordinals.IsNext isNext
open OrdUtil O
open ODUtil O
open OD O
open OD.OD
open ODAxiom odAxiom
-- import ODC
open _∧_
open _∨_
open Bool
open HOD
-- The cumulative hierarchy
-- V 0 := ∅
-- V α + 1 := P ( V α )
-- V α := ⋃ { V β | β < α }
V : ( β : Ordinal ) → HOD
V β = TransFinite V1 β where
V1 : (x : Ordinal ) → ( ( y : Ordinal) → y o< x → HOD ) → HOD
V1 x V0 with trio< x o∅
V1 x V0 | tri< a ¬b ¬c = ⊥-elim ( ¬x<0 a)
V1 x V0 | tri≈ ¬a refl ¬c = Ord o∅
V1 x V0 | tri> ¬a ¬b c with Oprev-p x
V1 x V0 | tri> ¬a ¬b c | yes p = Power ( V0 (Oprev.oprev p ) (subst (λ k → _ o< k) (Oprev.oprev=x p) <-osuc ))
V1 x V0 | tri> ¬a ¬b c | no ¬p =
record { od = record { def = λ y → (y o< x ) ∧ ((lt : y o< x ) → odef (V0 y lt) x ) } ; odmax = x; <odmax = λ {x} lt → proj1 lt }
--
-- L ⊆ HOD ⊆ V
--
-- HOD=V : (x : HOD) → V (odmax x) ∋ x
-- HOD=V x = {!!}
--
-- Definition for Power Set
--
record Definitions : Set (suc n) where
field
Definition : HOD → HOD
open Definitions
Df : Definitions → (x : HOD) → HOD
Df D x = Power x ∩ Definition D x
-- The constructible Sets
-- L 0 := ∅
-- L α + 1 := Df (L α) -- Definable Power Set
-- V α := ⋃ { L β | β < α }
L : ( β : Ordinal ) → Definitions → HOD
L β D = TransFinite L1 β where
L1 : (x : Ordinal ) → ( ( y : Ordinal) → y o< x → HOD ) → HOD
L1 x L0 with trio< x o∅
L1 x L0 | tri< a ¬b ¬c = ⊥-elim ( ¬x<0 a)
L1 x L0 | tri≈ ¬a refl ¬c = Ord o∅
L1 x L0 | tri> ¬a ¬b c with Oprev-p x
L1 x L0 | tri> ¬a ¬b c | yes p = Df D ( L0 (Oprev.oprev p ) (subst (λ k → _ o< k) (Oprev.oprev=x p) <-osuc ))
L1 x L0 | tri> ¬a ¬b c | no ¬p =
record { od = record { def = λ y → (y o< x ) ∧ ((lt : y o< x ) → odef (L0 y lt) x ) } ; odmax = x; <odmax = λ {x} lt → proj1 lt }
V=L0 : Set (suc n)
V=L0 = (x : Ordinal) → V x ≡ L x record { Definition = λ y → y }
| {
"alphanum_fraction": 0.5618619845,
"avg_line_length": 28.1494252874,
"ext": "agda",
"hexsha": "1865bbbe83213ebca933c206674009ecd0e4fa35",
"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": "031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "shinji-kono/zf-in-agda",
"max_forks_repo_path": "src/VL.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "shinji-kono/zf-in-agda",
"max_issues_repo_path": "src/VL.agda",
"max_line_length": 138,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "shinji-kono/zf-in-agda",
"max_stars_repo_path": "src/VL.agda",
"max_stars_repo_stars_event_max_datetime": "2021-01-10T13:27:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-10-02T13:46:23.000Z",
"num_tokens": 996,
"size": 2449
} |
{-# OPTIONS --without-K --safe #-}
module Categories.Category.Discrete where
-- Discrete Category.
-- https://ncatlab.org/nlab/show/discrete+category
-- says:
-- A category is discrete if it is both a groupoid and a preorder. That is,
-- every morphism should be invertible, any two parallel morphisms should be equal.
-- The idea is that in a discrete category, no two distinct (nonisomorphic) objects
-- are connectable by any path (morphism), and an object connects to itself only through
-- its identity morphism.
open import Level using (Level; suc; _⊔_)
open import Categories.Category using (Category)
open import Categories.Category.Groupoid using (IsGroupoid)
record IsDiscrete {o ℓ e} (C : Category o ℓ e) : Set (o ⊔ ℓ ⊔ e) where
open Category C using (Obj; _⇒_; _≈_)
field
isGroupoid : IsGroupoid C
preorder : {A B : Obj} → (f g : A ⇒ B) → f ≈ g
record DiscreteCategory (o ℓ e : Level) : Set (suc (o ⊔ ℓ ⊔ e)) where
field
category : Category o ℓ e
isDiscrete : IsDiscrete category
open IsDiscrete isDiscrete public
| {
"alphanum_fraction": 0.708490566,
"avg_line_length": 35.3333333333,
"ext": "agda",
"hexsha": "2773e2ad0667abd1d77506d0834c34c4fb2e3f70",
"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/Discrete.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/Discrete.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/Discrete.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": 305,
"size": 1060
} |
module Issue417 where
data _≡_ (A : Set₁) : Set₁ → Set₂ where
refl : A ≡ A
abstract
A : Set₁
A = Set
unfold-A : A ≡ Set
unfold-A = refl
-- The result of inferring the type of unfold-A is the following:
--
-- Set ≡ Set
| {
"alphanum_fraction": 0.6127659574,
"avg_line_length": 13.8235294118,
"ext": "agda",
"hexsha": "8cce996cc54af542fb45014d34b28b57c7fbf91c",
"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/Issue417.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/Issue417.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/interaction/Issue417.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": 235
} |
open import Mockingbird.Forest using (Forest)
module Mockingbird.Forest.Combination.Vec {b ℓ} (forest : Forest {b} {ℓ}) where
open import Mockingbird.Forest.Combination.Vec.Base forest public
| {
"alphanum_fraction": 0.7886597938,
"avg_line_length": 32.3333333333,
"ext": "agda",
"hexsha": "8e9bf71fe1a31238397d57260d983a0e406ea3b7",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "splintah/combinatory-logic",
"max_forks_repo_path": "Mockingbird/Forest/Combination/Vec.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "splintah/combinatory-logic",
"max_issues_repo_path": "Mockingbird/Forest/Combination/Vec.agda",
"max_line_length": 79,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "splintah/combinatory-logic",
"max_stars_repo_path": "Mockingbird/Forest/Combination/Vec.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-28T23:44:42.000Z",
"max_stars_repo_stars_event_min_datetime": "2022-02-28T23:44:42.000Z",
"num_tokens": 56,
"size": 194
} |
module Serializer.Fin where
open import Data.Fin hiding (_+_)
open import Data.Nat
open import Function using (_∘_ ; _$_ ; _∋_ ; id ; const)
open import Function.Bijection
open import Relation.Binary.PropositionalEquality using (_≡_ ; refl ; cong ; setoid )
open import Serializer
instance
serializerFin : ∀ {n} -> Serializer (Fin n)
serializerFin {n} = record {
size = n ;
from = Function.id ;
to = Function.id ;
bijection = Function.Bijection.id }
| {
"alphanum_fraction": 0.6962025316,
"avg_line_length": 24.9473684211,
"ext": "agda",
"hexsha": "bcea58730055cc9768a4d274871444cd87ed024b",
"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": "Serializer/Fin.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": "Serializer/Fin.agda",
"max_line_length": 85,
"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": "Serializer/Fin.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": 126,
"size": 474
} |
module List where
open import Prelude
open import Star
[_] : Set -> Rel True
[ A ] = \_ _ -> A
List : Set -> Set
List A = Star [ A ] _ _
-- Actually there isn't really that much interesting stuff to be
-- done for lists that isn't generic.
{- Note that the "proofs" are the elements of the list. -}
| {
"alphanum_fraction": 0.6590163934,
"avg_line_length": 17.9411764706,
"ext": "agda",
"hexsha": "810ac02dff834c9ec7964a98d664abb0a40d29e2",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "examples/AIM6/Path/List.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "examples/AIM6/Path/List.agda",
"max_line_length": 64,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "examples/AIM6/Path/List.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 85,
"size": 305
} |
{-# OPTIONS --safe #-}
{-
This file has been split in two due to slow type checking
combined with insufficient reductions when the
experimental-lossy-unification flag is included.
Part 2: Cubical.Homotopy.Group.Pi4S3.S3PushoutIso2
The goal of these two files is to show that
π₄(S³) ≅ π₃((S² × S²) ⊔ᴬ S²) where A = S² ∨ S².
This is proved in Brunerie (2016) using the James construction and
via (S² × S²) ⊔ᴬ S² ≃ J₂(S²).
In this file, we prove it directly using the encode-decode method. For
the statement of the isomorphism, see part 2.
-}
module Cubical.Homotopy.Group.Pi4S3.S3PushoutIso where
open import Cubical.Homotopy.Loopspace
open import Cubical.Homotopy.Group.Base
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Pointed
open import Cubical.Foundations.Pointed.Homogeneous
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.GroupoidLaws renaming (assoc to ∙assoc)
open import Cubical.Foundations.Path
open import Cubical.Foundations.Isomorphism
open Iso
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Univalence
open import Cubical.Functions.Morphism
open import Cubical.HITs.SetTruncation
renaming (rec to sRec ; rec2 to sRec2
; elim to sElim ; elim2 to sElim2 ; elim3 to sElim3
; map to sMap)
open import Cubical.HITs.Sn
open import Cubical.HITs.Susp renaming (toSusp to σ)
open import Cubical.HITs.S1 hiding (decode ; encode)
open import Cubical.Data.Sigma
open import Cubical.Data.Nat
open import Cubical.Data.Bool
open import Cubical.Algebra.Group
open import Cubical.Algebra.Semigroup
open import Cubical.Algebra.Monoid
open import Cubical.HITs.Join
open import Cubical.HITs.Pushout
open import Cubical.HITs.Wedge
open import Cubical.Homotopy.Freudenthal hiding (Code ; encode)
open import Cubical.Homotopy.Connected
open import Cubical.HITs.Truncation renaming
(rec to trRec ; elim to trElim ; elim2 to trElim2 ; map to trMap)
open import Cubical.Foundations.Function
open import Cubical.HITs.S2
Pushout⋁↪fold⋁ : ∀ {ℓ} (A : Pointed ℓ) → Type ℓ
Pushout⋁↪fold⋁ A = Pushout {A = A ⋁ A} ⋁↪ fold⋁
Pushout⋁↪fold⋁∙ : ∀ {ℓ} (A : Pointed ℓ) → Pointed ℓ
fst (Pushout⋁↪fold⋁∙ A) = Pushout⋁↪fold⋁ A
snd (Pushout⋁↪fold⋁∙ A) = inl (pt A , pt A)
-- The type of interest -- ''almost`` equivalent to ΩS³
Pushout⋁↪fold⋁S₊2 = Pushout {A = S₊∙ 2 ⋁ S₊∙ 2} ⋁↪ fold⋁
-- Same type, using base/surf definition of S² (easier to work with)
Pushout⋁↪fold⋁S² = Pushout⋁↪fold⋁ S²∙
-- Truncated version, to be proved equivalent to ∥ ΩS³ ∥₅
∥Pushout⋁↪fold⋁S²∥₅ = hLevelTrunc 5 Pushout⋁↪fold⋁S²
Ω∥S³∥₆ = Path (hLevelTrunc 6 (Susp S²)) ∣ north ∣ ∣ north ∣
-- Elimination into sets for Pushout⋁↪fold⋁S²
module _ {ℓ : Level} {P : Pushout⋁↪fold⋁S² → Type ℓ}
(hlev : ((x : Pushout⋁↪fold⋁S²) → isSet (P x)))
(b : P (inl (base , base))) where
private
×fun : (x y : S²) → P (inl (x , y))
×fun = S²ToSetElim (λ _ → isSetΠ (λ _ → hlev _))
(S²ToSetElim (λ _ → hlev _) b)
inrfun : (x : S²) → P (inr x)
inrfun = S²ToSetElim (λ _ → hlev _) (subst P (push (inl base)) b)
inl-pp : (x : S²) → PathP (λ i → P (push (inl x) i)) (×fun x base) (inrfun x)
inl-pp = S²ToSetElim (λ _ → isOfHLevelPathP 2 (hlev _) _ _)
λ j → transp (λ i → P (push (inl base) (i ∧ j))) (~ j) b
inr-pp : (x : S²) → PathP (λ i → P (push (inr x) i)) (×fun base x) (inrfun x)
inr-pp = S²ToSetElim (λ _ → isOfHLevelPathP 2 (hlev _) _ _)
(transport (λ j → PathP (λ i → P (push (push tt j) i)) (×fun base base)
(inrfun base))
(inl-pp base))
Pushout⋁↪fold⋁S²→Set : (x : Pushout⋁↪fold⋁S²) → P x
Pushout⋁↪fold⋁S²→Set (inl x) = ×fun (fst x) (snd x)
Pushout⋁↪fold⋁S²→Set (inr x) = inrfun x
Pushout⋁↪fold⋁S²→Set (push (inl x) i) = inl-pp x i
Pushout⋁↪fold⋁S²→Set (push (inr x) i) = inr-pp x i
Pushout⋁↪fold⋁S²→Set (push (push a j) i) = help j i
where
help : SquareP (λ j i → P (push (push tt j) i))
(λ i → inl-pp base i)
(λ i → inr-pp base i)
(λ _ → ×fun base base)
(λ _ → inrfun base)
help = toPathP (isProp→PathP (λ _ → isOfHLevelPathP' 1 (hlev _) _ _) _ _)
{- A wedge connectivity lemma for Pushout⋁↪fold⋁S². It can be
stated for general dependent types, but it's easier to work with
in the special case of path types -}
module Pushout⋁↪fold⋁S²WedgeCon {ℓ : Level } {A : Type ℓ}
(f g : Pushout⋁↪fold⋁S² → A)
(h : isOfHLevel 5 A)
(lp : (x : S²) → f (inl (x , base)) ≡ g (inl (x , base)))
(rp : (x : S²) → f (inl (base , x)) ≡ g (inl (base , x)))
(r≡l : (x : S²)
→ (sym (cong f (push (inl x))) ∙∙ lp x ∙∙ cong g (push (inl x)))
≡ (sym (cong f (push (inr x))) ∙∙ rp x ∙∙ cong g (push (inr x))))
where
btm-filler : I → I → I → A
btm-filler k i j =
hfill (λ k → λ {(i = i0)
→ doubleCompPath-filler (sym (cong f (push (inl base))))
(lp base)
(cong g (push (inl base))) (~ k) j
; (i = i1)
→ doubleCompPath-filler (sym (cong f (push (inr base))))
(rp base)
(cong g (push (inr base))) (~ k) j
; (j = i0) → f (push (push tt i) (~ k))
; (j = i1) → g (push (push tt i) (~ k))})
(inS (r≡l base i j))
k
lp-base≡rp-base : lp base ≡ rp base
lp-base≡rp-base = (λ i j → btm-filler i1 i j)
f∘inl≡g∘inl : (x y : S²) → f (inl (x , y)) ≡ g (inl (x , y))
f∘inl≡g∘inl = wedgeconFunS² (λ _ _ → h _ _) lp rp lp-base≡rp-base
f∘inl≡g∘inl-base : (x : S²) → f∘inl≡g∘inl x base ≡ lp x
f∘inl≡g∘inl-base = wedgeconFunS²Id (λ _ _ → h _ _) lp rp lp-base≡rp-base
f∘inr≡g∘inr : (x : S²) → f (inr x) ≡ g (inr x)
f∘inr≡g∘inr x = cong f (sym (push (inl x))) ∙∙ lp x ∙∙ cong g (push (inl x))
inlfill : (x : S²) → I → I → I → A
inlfill x k i j =
hfill (λ k → λ { (i = i0) → f∘inl≡g∘inl-base x (~ k) j
; (i = i1) → doubleCompPath-filler
(cong f (sym (push (inl x))))
(lp x)
(cong g (push (inl x))) k j
; (j = i0) → f (push (inl x) (i ∧ k))
; (j = i1) → g (push (inl x) (i ∧ k))})
(inS (lp x j))
k
inrfill : (x : S²) → I → I → I → A
inrfill x k i j =
hfill (λ k → λ { (i = i0) → doubleCompPath-filler
(cong f (sym (push (inr x))))
(rp x)
(cong g (push (inr x))) (~ k) j
; (i = i1) → f∘inr≡g∘inr x j
; (j = i0) → f (push (inr x) (i ∨ ~ k))
; (j = i1) → g (push (inr x) (i ∨ ~ k))})
(inS (r≡l x (~ i) j))
k
main : (x : Pushout⋁↪fold⋁S²) → f x ≡ g x
main (inl x) = f∘inl≡g∘inl (fst x) (snd x)
main (inr x) = f∘inr≡g∘inr x
main (push (inl x) i) j = inlfill x i1 i j
main (push (inr x) i) j = inrfill x i1 i j
main (push (push a i) j) k =
hcomp (λ r → λ {(i = i0) → inlfill base i1 j k
; (i = i1) → inrfill-side r j k
; (j = i0) → rp base k
; (j = i1) → r≡l base (~ r ∧ i) k
; (k = i0) → f (push (push a i) j)
; (k = i1) → g (push (push a i) j)})
(hcomp (λ r → λ {(i = i0) → inlfill base r j k
; (i = i1) → doubleCompPath-filler
(cong f (sym (push (inr base))))
(rp base)
(cong g (push (inr base))) (j ∧ r) k
; (j = i0) → lp-base≡rp-base (r ∨ i) k
; (j = i1) → inlfill-side r i k
; (k = i0) → f (push (push a i) (j ∧ r))
; (k = i1) → g (push (push a i) (j ∧ r))})
(lp-base≡rp-base i k))
where
inlfill-side : I → I → I → A
inlfill-side r i k =
hcomp (λ j → λ { (r = i0) → btm-filler j i k
; (r = i1) → r≡l base i k
; (i = i0) → doubleCompPath-filler
(cong f (sym (push (inl base))))
(lp base)
(cong g (push (inl base))) (r ∨ ~ j) k
; (i = i1) → doubleCompPath-filler
(cong f (sym (push (inr base))))
(rp base)
(cong g (push (inr base))) (r ∨ ~ j) k
; (k = i0) → f (push (push a i) (r ∨ ~ j))
; (k = i1) → g (push (push a i) (r ∨ ~ j))})
(r≡l base i k)
inrfill-side : I → I → I → A
inrfill-side r j k =
hcomp (λ i → λ { (r = i0)
→ (doubleCompPath-filler
(cong f (sym (push (inr base))))
(rp base)
(cong g (push (inr base)))) (j ∨ ~ i) k
; (r = i1) → inrfill base i j k
; (j = i0) → inrfill base i i0 k
; (j = i1) → r≡l base (~ r) k
; (k = i0) → f (push (inr base) (j ∨ ~ i))
; (k = i1) → g (push (inr base) (j ∨ ~ i))})
(r≡l base (~ r ∨ ~ j) k)
{-
Goal: Prove Ω ∥ SuspS² ∥₆ ≃ ∥ Pushout⋁↪fold⋁S² ∥₅
This will by done via the encode-decode method. For this, we nede a family
of equivalences ∥ Pushout⋁↪fold⋁S² ∥₅ ≃ ∥ Pushout⋁↪fold⋁S² ∥₅, indexed by S².
In order to define this, we need the following cubes/coherences in
∥ Pushout⋁↪fold⋁S² ∥₅:
-}
→Ω²∥Pushout⋁↪fold⋁S²∥₅ : (x y : S²)
→ Square {A = ∥Pushout⋁↪fold⋁S²∥₅} (λ _ → ∣ inl (x , y) ∣ₕ)
(λ _ → ∣ inl (x , y) ∣ₕ)
(λ _ → ∣ inl (x , y) ∣ₕ)
(λ _ → ∣ inl (x , y) ∣ₕ)
→Ω²∥Pushout⋁↪fold⋁S²∥₅ =
wedgeconFunS²
(λ _ _ → isOfHLevelPath 4 (isOfHLevelTrunc 5 _ _) _ _)
(λ x → λ i j → ∣ inl (x , surf i j) ∣ₕ)
(λ x → λ i j → ∣ inl (surf i j , x) ∣ₕ)
λ r i j → ∣ hcomp (λ k → λ { (i = i0) → push (push tt (~ r)) (~ k)
; (i = i1) → push (push tt (~ r)) (~ k)
; (j = i1) → push (push tt (~ r)) (~ k)
; (j = i0) → push (push tt (~ r)) (~ k)
; (r = i0) → push (inr (surf i j)) (~ k)
; (r = i1) → push (inl (surf i j)) (~ k)})
(inr (surf i j)) ∣ₕ
→Ω²∥Pushout⋁↪fold⋁S²∥₅Id : (x : S²)
→ →Ω²∥Pushout⋁↪fold⋁S²∥₅ x base ≡ λ i j → ∣ inl (x , surf i j) ∣ₕ
→Ω²∥Pushout⋁↪fold⋁S²∥₅Id =
wedgeconFunS²Id
(λ _ _ → isOfHLevelPath 4 (isOfHLevelTrunc 5 _ _) _ _)
(λ x → λ i j → ∣ inl (x , surf i j) ∣ₕ)
(λ x → λ i j → ∣ inl (surf i j , x) ∣ₕ)
λ r i j → ∣ hcomp (λ k → λ { (i = i0) → push (push tt (~ r)) (~ k)
; (i = i1) → push (push tt (~ r)) (~ k)
; (j = i1) → push (push tt (~ r)) (~ k)
; (j = i0) → push (push tt (~ r)) (~ k)
; (r = i0) → push (inr (surf i j)) (~ k)
; (r = i1) → push (inl (surf i j)) (~ k)})
(inr (surf i j)) ∣ₕ
push-inl∙push-inr⁻ : (y : S²) → Path Pushout⋁↪fold⋁S² (inl (y , base)) (inl (base , y))
push-inl∙push-inr⁻ y i = (push (inl y) ∙ sym (push (inr y))) i
push-inl∙push-inr⁻∙ : push-inl∙push-inr⁻ base ≡ refl
push-inl∙push-inr⁻∙ =
(λ k i → (push (inl base) ∙ sym (push (push tt (~ k)))) i)
∙ rCancel (push (inl base))
push-inl∙push-inr⁻-filler : I → I → I → I → Pushout⋁↪fold⋁S²
push-inl∙push-inr⁻-filler r i j k =
hfill (λ r → λ { (i = i0) → push-inl∙push-inr⁻∙ (~ r) k
; (i = i1) → push-inl∙push-inr⁻∙ (~ r) k
; (j = i0) → push-inl∙push-inr⁻∙ (~ r) k
; (j = i1) → push-inl∙push-inr⁻∙ (~ r) k
; (k = i0) → inl (surf i j , base)
; (k = i1) → inl (surf i j , base)})
(inS (inl (surf i j , base)))
r
push-inl∙push-inr⁻-hLevFiller : (y : S²)
→ Cube {A = ∥Pushout⋁↪fold⋁S²∥₅}
(λ j k → ∣ push-inl∙push-inr⁻ y k ∣)
(λ j k → ∣ push-inl∙push-inr⁻ y k ∣)
(λ j k → ∣ push-inl∙push-inr⁻ y k ∣)
(λ j k → ∣ push-inl∙push-inr⁻ y k ∣)
(→Ω²∥Pushout⋁↪fold⋁S²∥₅ y (pt (S² , base)))
λ i j → ∣ inl (surf i j , y) ∣
push-inl∙push-inr⁻-hLevFiller =
S²ToSetElim (λ _ → isOfHLevelPathP' 2
(isOfHLevelPathP' 3
(isOfHLevelPathP' 4 (isOfHLevelTrunc 5) _ _) _ _) _ _)
λ i j k → ∣ push-inl∙push-inr⁻-filler i1 i j k ∣ₕ
{-
We combine the above definitions. The equivalence
∥Pushout⋁↪fold⋁S²∥₅ ≃ ∥Pushout⋁↪fold⋁S²∥₅ (w.r.t. S²) is induced
by the following function
-}
S²→Pushout⋁↪fold⋁S²↺' : (x : S²) → Pushout⋁↪fold⋁S² → ∥Pushout⋁↪fold⋁S²∥₅
S²→Pushout⋁↪fold⋁S²↺' base (inl (x , y)) = ∣ inl (x , y) ∣
S²→Pushout⋁↪fold⋁S²↺' (surf i j) (inl (x , y)) = →Ω²∥Pushout⋁↪fold⋁S²∥₅ x y i j
S²→Pushout⋁↪fold⋁S²↺' base (inr z) = ∣ inl (base , z) ∣ₕ
S²→Pushout⋁↪fold⋁S²↺' (surf i i₁) (inr z) = ∣ inl (surf i i₁ , z) ∣ₕ
S²→Pushout⋁↪fold⋁S²↺' base (push (inl y) k) =
∣ (push (inl y) ∙ sym (push (inr y))) k ∣
S²→Pushout⋁↪fold⋁S²↺' (surf i j) (push (inl y) k) =
push-inl∙push-inr⁻-hLevFiller y i j k
S²→Pushout⋁↪fold⋁S²↺' base (push (inr y) i) = ∣ inl (base , y) ∣
S²→Pushout⋁↪fold⋁S²↺' (surf i j) (push (inr y) k) = ∣ inl (surf i j , y) ∣
S²→Pushout⋁↪fold⋁S²↺' base (push (push a i₁) i) = ∣ push-inl∙push-inr⁻∙ i₁ i ∣
S²→Pushout⋁↪fold⋁S²↺' (surf i j) (push (push a k) l) =
∣ hcomp (λ r → λ { (i = i0) → push-inl∙push-inr⁻∙ (k ∨ ~ r) l
; (i = i1) → push-inl∙push-inr⁻∙ (k ∨ ~ r) l
; (j = i0) → push-inl∙push-inr⁻∙ (k ∨ ~ r) l
; (j = i1) → push-inl∙push-inr⁻∙ (k ∨ ~ r) l
; (k = i0) → push-inl∙push-inr⁻-filler r i j l
; (k = i1) → inl (surf i j , base)
; (l = i0) → inl (surf i j , base)
; (l = i1) → inl (surf i j , base)})
(inl (surf i j , base)) ∣ₕ
{- For easier treatment later, we state its inverse explicitly -}
S²→Pushout⋁↪fold⋁S²↺'⁻ : (x : S²) → Pushout⋁↪fold⋁S² → ∥Pushout⋁↪fold⋁S²∥₅
S²→Pushout⋁↪fold⋁S²↺'⁻ base y = S²→Pushout⋁↪fold⋁S²↺' base y
S²→Pushout⋁↪fold⋁S²↺'⁻ (surf i j) y = S²→Pushout⋁↪fold⋁S²↺' (surf (~ i) j) y
S²→Pushout⋁↪fold⋁S²↺'≡idfun : (x : _) → S²→Pushout⋁↪fold⋁S²↺' base x ≡ ∣ x ∣
S²→Pushout⋁↪fold⋁S²↺'≡idfun (inl x) = refl
S²→Pushout⋁↪fold⋁S²↺'≡idfun (inr x) = cong ∣_∣ₕ (push (inr x))
S²→Pushout⋁↪fold⋁S²↺'≡idfun (push (inl x) i) j =
∣ compPath-filler (push (inl x)) (λ i₁ → push (inr x) (~ i₁)) (~ j) i ∣ₕ
S²→Pushout⋁↪fold⋁S²↺'≡idfun (push (inr x) i) j = ∣ push (inr x) (j ∧ i) ∣
S²→Pushout⋁↪fold⋁S²↺'≡idfun (push (push a i) j) k =
∣ coh-lem {A = Pushout⋁↪fold⋁S²}
(push (inl base)) (push (inr base)) (λ k → push (push tt k)) i j k ∣ₕ
where
coh-lem : ∀ {ℓ} {A : Type ℓ} {x y : A} (p q : x ≡ y) (r : p ≡ q)
→ Cube {A = A}
(λ j k → compPath-filler p (sym q) (~ k) j) (λ k j → q (k ∧ j))
(λ i k → x) (λ i k → q k)
(((λ k → p ∙ sym (r (~ k))) ∙ rCancel p))
r
coh-lem {A = A} {x = x} {y = y} =
J (λ y p → (q : x ≡ y) (r : p ≡ q)
→ Cube {A = A}
(λ j k → compPath-filler p (sym q) (~ k) j) (λ k j → q (k ∧ j))
(λ i k → x) (λ i k → q k)
(((λ k → p ∙ sym (r (~ k))) ∙ rCancel p))
r)
λ q → J (λ q r → Cube (λ j k → compPath-filler refl (λ i → q (~ i)) (~ k) j)
(λ k j → q (k ∧ j)) (λ i k → x) (λ i k → q k)
((λ k → refl ∙ (λ i → r (~ k) (~ i))) ∙ rCancel refl) r)
((λ z j k → lUnit (sym (rUnit (λ _ → x))) z k j)
◁ (λ i j k → (refl ∙ (λ i₁ → rUnit (λ _ → x) (~ i₁))) (k ∨ i) j))
S²→Pushout⋁↪fold⋁S²↺ : (x : S²) → ∥Pushout⋁↪fold⋁S²∥₅ → ∥Pushout⋁↪fold⋁S²∥₅
S²→Pushout⋁↪fold⋁S²↺ x = trRec (isOfHLevelTrunc 5) (S²→Pushout⋁↪fold⋁S²↺' x)
isEq-S²→Pushout⋁↪fold⋁S²↺' : (x : _) → isEquiv (S²→Pushout⋁↪fold⋁S²↺ x)
isEq-S²→Pushout⋁↪fold⋁S²↺' =
S²ToSetElim (λ _ → isProp→isSet (isPropIsEquiv _))
(subst isEquiv (funExt id≡) (idIsEquiv _))
where
id≡ : (x : _) → x ≡ S²→Pushout⋁↪fold⋁S²↺ base x
id≡ = trElim (λ _ → isOfHLevelPath 5 (isOfHLevelTrunc 5) _ _)
(sym ∘ S²→Pushout⋁↪fold⋁S²↺'≡idfun)
S²→Pushout⋁↪fold⋁S²↺⁻¹ : (x : S²) → ∥Pushout⋁↪fold⋁S²∥₅ → ∥Pushout⋁↪fold⋁S²∥₅
S²→Pushout⋁↪fold⋁S²↺⁻¹ x = trRec (isOfHLevelTrunc 5) (S²→Pushout⋁↪fold⋁S²↺'⁻ x)
{- S²→Pushout⋁↪fold⋁S²↺⁻¹ is a section of S²→Pushout⋁↪fold⋁S²↺ -}
secS²→Pushout⋁↪fold⋁S²↺ : (x : S²) (y : ∥Pushout⋁↪fold⋁S²∥₅)
→ S²→Pushout⋁↪fold⋁S²↺ x (S²→Pushout⋁↪fold⋁S²↺⁻¹ x y) ≡ y
secS²→Pushout⋁↪fold⋁S²↺ x =
trElim (λ _ → isOfHLevelPath 5 (isOfHLevelTrunc 5) _ _)
(h x)
where
h : (x : S²) (a : Pushout⋁↪fold⋁S²)
→ S²→Pushout⋁↪fold⋁S²↺ x
(S²→Pushout⋁↪fold⋁S²↺⁻¹ x ∣ a ∣) ≡ ∣ a ∣
h base a = cong (S²→Pushout⋁↪fold⋁S²↺ base)
(S²→Pushout⋁↪fold⋁S²↺'≡idfun a)
∙ S²→Pushout⋁↪fold⋁S²↺'≡idfun a
h (surf i j) a k = main a k i j
where
side : (a : Pushout⋁↪fold⋁S²) → _
side a = cong (S²→Pushout⋁↪fold⋁S²↺ base) (S²→Pushout⋁↪fold⋁S²↺'≡idfun a)
∙ S²→Pushout⋁↪fold⋁S²↺'≡idfun a
refl-b : Path ∥Pushout⋁↪fold⋁S²∥₅ _ _
refl-b = (refl {x = ∣ inl (base , base) ∣ₕ})
main : (a : Pushout⋁↪fold⋁S²)
→ Cube (λ i j → S²→Pushout⋁↪fold⋁S²↺ (surf i j)
(S²→Pushout⋁↪fold⋁S²↺⁻¹ (surf i j) ∣ a ∣))
(λ _ _ → ∣ a ∣)
(λ i _ → side a i) (λ i _ → side a i)
(λ i _ → side a i) (λ i _ → side a i)
main =
Pushout⋁↪fold⋁S²→Set (λ _ → isOfHLevelPathP' 2
(isOfHLevelPathP' 3 (isOfHLevelTrunc 5 _ _) _ _) _ _)
λ k i j →
hcomp (λ r → λ { (i = i0) → rUnit refl-b r k
; (i = i1) → rUnit refl-b r k
; (j = i0) → rUnit refl-b r k
; (j = i1) → rUnit refl-b r k
; (k = i0) → →Ω²∥Pushout⋁↪fold⋁S²∥₅Id
(surf (~ i) j) (~ r) i j
; (k = i1) → μ base base})
(μ-coh k i j)
where
μ : (x y : S²) → ∥Pushout⋁↪fold⋁S²∥₅
μ x y = ∣ inl (x , y) ∣ₕ
μUnit : (x : S²) → μ x base ≡ μ base x
μUnit base = refl
μUnit (surf i j) k = ∣
hcomp (λ r → λ {(i = i0) → push (push tt k) (~ r)
; (i = i1) → push (push tt k) (~ r)
; (j = i0) → push (push tt k) (~ r)
; (j = i1) → push (push tt k) (~ r)
; (k = i0) → push (inl (surf i j)) (~ r)
; (k = i1) → push (inr (surf i j)) (~ r)})
(inr (surf i j)) ∣ₕ
μ-coh : Path (Square {A = ∥Pushout⋁↪fold⋁S²∥₅}
(λ _ → ∣ inl (base , base) ∣) (λ _ → ∣ inl (base , base) ∣)
(λ _ → ∣ inl (base , base) ∣) (λ _ → ∣ inl (base , base) ∣))
(λ i j → ∣ inl (surf (~ i) j , surf i j) ∣ₕ)
refl
μ-coh =
(cong₂Funct (λ (x y : (Path S² base base)) → cong₂ μ x y) (sym surf) surf
∙ cong (_∙ cong (cong (μ base)) surf) (λ i → cong (cong (λ x → μUnit x i)) (sym surf))
∙ lCancel (cong (cong (μ base)) surf))
retrS²→Pushout⋁↪fold⋁S²↺ : (x : S²) (y : ∥Pushout⋁↪fold⋁S²∥₅)
→ S²→Pushout⋁↪fold⋁S²↺⁻¹ x (S²→Pushout⋁↪fold⋁S²↺ x y) ≡ y
retrS²→Pushout⋁↪fold⋁S²↺ x =
trElim (λ _ → isOfHLevelPath 5 (isOfHLevelTrunc 5) _ _)
(main x)
where
main : (x : S²) (a : Pushout⋁↪fold⋁S²)
→ S²→Pushout⋁↪fold⋁S²↺⁻¹ x (S²→Pushout⋁↪fold⋁S²↺ x ∣ a ∣) ≡ ∣ a ∣
main base a = secS²→Pushout⋁↪fold⋁S²↺ base ∣ a ∣
main (surf i j) a l = secS²→Pushout⋁↪fold⋁S²↺ (surf (~ i) j) ∣ a ∣ l
∥Pushout⋁↪fold⋁S²∥₅≃∥Pushout⋁↪fold⋁S²∥₅ : (x : S²)
→ Iso ∥Pushout⋁↪fold⋁S²∥₅ ∥Pushout⋁↪fold⋁S²∥₅
fun (∥Pushout⋁↪fold⋁S²∥₅≃∥Pushout⋁↪fold⋁S²∥₅ x) = S²→Pushout⋁↪fold⋁S²↺ x
inv (∥Pushout⋁↪fold⋁S²∥₅≃∥Pushout⋁↪fold⋁S²∥₅ x) = S²→Pushout⋁↪fold⋁S²↺⁻¹ x
rightInv (∥Pushout⋁↪fold⋁S²∥₅≃∥Pushout⋁↪fold⋁S²∥₅ x) = secS²→Pushout⋁↪fold⋁S²↺ x
leftInv (∥Pushout⋁↪fold⋁S²∥₅≃∥Pushout⋁↪fold⋁S²∥₅ x) = retrS²→Pushout⋁↪fold⋁S²↺ x
PreCode : (x : Susp S²) → Type
PreCode north = ∥Pushout⋁↪fold⋁S²∥₅
PreCode south = ∥Pushout⋁↪fold⋁S²∥₅
PreCode (merid a i) = isoToPath (∥Pushout⋁↪fold⋁S²∥₅≃∥Pushout⋁↪fold⋁S²∥₅ a) i
hLevPreCode : (x : Susp S²) → isOfHLevel 5 (PreCode x)
hLevPreCode =
suspToPropElim base (λ _ → isPropIsOfHLevel 5) (isOfHLevelTrunc 5)
Code : (hLevelTrunc 6 (Susp S²)) → Type ℓ-zero
Code =
fst ∘ trRec {B = TypeOfHLevel ℓ-zero 5} (isOfHLevelTypeOfHLevel 5)
λ x → (PreCode x) , (hLevPreCode x)
private
cong-coherence : ∀ {ℓ} {A : Type ℓ} {x : A} (p : x ≡ x) (r : refl ≡ p)
→ cong (p ∙_) (sym r) ∙ sym (rUnit p)
≡ cong (_∙ p) (sym r) ∙ sym (lUnit p)
cong-coherence p = J (λ p r → cong (p ∙_) (sym r) ∙ sym (rUnit p)
≡ cong (_∙ p) (sym r) ∙ sym (lUnit p)) refl
{- The function Pushout⋁↪fold⋁S² → Ω∥S³∥₆ will be the obvious one -}
Pushout⋁↪fold⋁S²→Ω∥S³∥₆ : Pushout⋁↪fold⋁S² → Ω∥S³∥₆
Pushout⋁↪fold⋁S²→Ω∥S³∥₆ (inl x) = cong ∣_∣ₕ (σ S²∙ (fst x) ∙ σ S²∙ (snd x))
Pushout⋁↪fold⋁S²→Ω∥S³∥₆ (inr x) = cong ∣_∣ₕ (σ S²∙ x)
Pushout⋁↪fold⋁S²→Ω∥S³∥₆ (push (inl x) i) j =
∣ (cong (σ S²∙ x ∙_) (rCancel (merid base)) ∙ sym (rUnit (σ S²∙ x))) i j ∣ₕ
Pushout⋁↪fold⋁S²→Ω∥S³∥₆ (push (inr x) i) j =
∣ (cong (_∙ σ S²∙ x) (rCancel (merid base)) ∙ sym (lUnit (σ S²∙ x))) i j ∣ₕ
Pushout⋁↪fold⋁S²→Ω∥S³∥₆ (push (push a k) i) j =
∣ cong-coherence (σ S²∙ base) (sym (rCancel (merid base))) k i j ∣ₕ
{- Truncated version (the equivalence) -}
∥Pushout⋁↪fold⋁S²∥₅→Ω∥S³∥₆ : ∥Pushout⋁↪fold⋁S²∥₅ → Ω∥S³∥₆
∥Pushout⋁↪fold⋁S²∥₅→Ω∥S³∥₆ =
trRec (isOfHLevelTrunc 6 _ _) Pushout⋁↪fold⋁S²→Ω∥S³∥₆
decode' : (x : Susp S²) → Code ∣ x ∣
→ Path (hLevelTrunc 6 (Susp S²)) ∣ north ∣ ∣ x ∣
decode' north p = ∥Pushout⋁↪fold⋁S²∥₅→Ω∥S³∥₆ p
decode' south p = ∥Pushout⋁↪fold⋁S²∥₅→Ω∥S³∥₆ p ∙ cong ∣_∣ₕ (merid base)
decode' (merid a i) = main a i
where
baseId : (x : Pushout⋁↪fold⋁S²)
→ ∥Pushout⋁↪fold⋁S²∥₅→Ω∥S³∥₆ (S²→Pushout⋁↪fold⋁S²↺' base x)
≡ ∥Pushout⋁↪fold⋁S²∥₅→Ω∥S³∥₆ ∣ x ∣
baseId x =
cong ∥Pushout⋁↪fold⋁S²∥₅→Ω∥S³∥₆ (S²→Pushout⋁↪fold⋁S²↺'≡idfun x)
mainLemma : (a : S²) (x : Pushout⋁↪fold⋁S²)
→ ∥Pushout⋁↪fold⋁S²∥₅→Ω∥S³∥₆ (S²→Pushout⋁↪fold⋁S²↺'⁻ a x)
∙ (λ i → ∣ merid a i ∣)
≡ ∥Pushout⋁↪fold⋁S²∥₅→Ω∥S³∥₆ ∣ x ∣ ∙ cong ∣_∣ₕ (merid base)
mainLemma base x = cong (_∙ cong ∣_∣ₕ (merid base)) (baseId x)
mainLemma (surf i j) x k = surf-filler x k i j
where
∙ΩbaseId :
(q : typ (Ω (Susp∙ (typ S²∙)))) → q ≡ q ∙ σ S²∙ base
∙ΩbaseId q = rUnit q ∙ cong (q ∙_) (sym (rCancel (merid base)))
cubeCoherence :
∀ {ℓ} {A : Type ℓ} {x : A} {p : x ≡ x}
→ (refl ≡ p)
→ (q : Square {A = x ≡ x} (λ _ → p) (λ _ → p) (λ _ → p) (λ _ → p))
→ Cube {A = Path A x x}
(λ i j → q i j ∙ q (~ i) j) (λ _ _ → p ∙ p)
(λ k j → p ∙ p) (λ _ _ → p ∙ p)
(λ _ _ → p ∙ p) λ _ _ → p ∙ p
cubeCoherence {A = A} {x = x} {p = p} =
J (λ p _ → (q : Square {A = x ≡ x}
(λ _ → p) (λ _ → p) (λ _ → p) (λ _ → p))
→ Cube {A = Path A x x}
(λ i j → q i j ∙ q (~ i) j) (λ _ _ → p ∙ p)
(λ k j → p ∙ p) (λ _ _ → p ∙ p)
(λ _ _ → p ∙ p) λ _ _ → p ∙ p)
(λ q →
(cong₂Funct (λ (x y : Path (x ≡ x) refl refl) → cong₂ _∙_ x y) q (sym q)
∙ transport
(λ i → cong (λ (p : (refl {x = x}) ≡ refl) k → rUnit (p k) i) q
∙ cong (λ (p : (refl {x = x}) ≡ refl) k → lUnit (p k) i) (sym q)
≡ refl {x = refl {x = lUnit (refl {x = x}) i}})
(rCancel q)))
surf-side : (i j r l : I) → hLevelTrunc 6 (Susp S²)
surf-side i j r l =
((cong ∣_∣ₕ (∙ΩbaseId (σ S²∙ (surf (~ i) j)) r))
∙ cong ∣_∣ₕ (compPath-filler (merid (surf i j))
(sym (merid base)) (~ r))) l
side : (r l : I) → hLevelTrunc 6 (Susp S²)
side r l =
((cong ∣_∣ₕ (∙ΩbaseId (σ S²∙ base) r))
∙ cong ∣_∣ₕ (compPath-filler (merid base)
(sym (merid base)) (~ r))) l
surf-filler : (x : Pushout⋁↪fold⋁S²)
→ Cube {A = Path (hLevelTrunc 6 (Susp S²)) ∣ north ∣ ∣ south ∣}
(λ i j → ∥Pushout⋁↪fold⋁S²∥₅→Ω∥S³∥₆
(S²→Pushout⋁↪fold⋁S²↺' (surf (~ i) j) x)
∙ (λ k → ∣ merid (surf i j) k ∣))
(λ _ _ → ∥Pushout⋁↪fold⋁S²∥₅→Ω∥S³∥₆ ∣ x ∣
∙ cong ∣_∣ₕ (merid base))
(λ k j → baseId x k ∙ (λ i₂ → ∣ merid base i₂ ∣))
(λ k j → baseId x k ∙ (λ i₂ → ∣ merid base i₂ ∣))
(λ k i → baseId x k ∙ (λ i₂ → ∣ merid base i₂ ∣))
(λ k i → baseId x k ∙ (λ i₂ → ∣ merid base i₂ ∣))
surf-filler =
Pushout⋁↪fold⋁S²→Set
(λ _ → isOfHLevelPathP' 2
(isOfHLevelPathP' 3 (isOfHLevelTrunc 6 _ _ _ _) _ _) _ _)
(λ k i j l → hcomp (λ r
→ λ {(i = i0) → surf-side i0 i0 r l
; (i = i1) → surf-side i0 i0 r l
; (j = i0) → surf-side i0 i0 r l
; (j = i1) → surf-side i0 i0 r l
; (k = i0) → surf-side i j r l
; (k = i1) → surf-side i0 i0 r l
; (l = i0) → ∣ north ∣ₕ
; (l = i1) → ∣ merid base r ∣ₕ})
(cubeCoherence {p = cong ∣_∣ₕ (σ (S²∙) base)}
(cong (cong ∣_∣ₕ) (sym (rCancel (merid base))))
(λ i j k → ∣ σ S²∙ (surf (~ i) j) k ∣ₕ) k i j l))
main : (a : S²)
→ PathP (λ i → Code ∣ merid a i ∣
→ Path (hLevelTrunc 6 (Susp S²)) ∣ north ∣ ∣ merid a i ∣)
∥Pushout⋁↪fold⋁S²∥₅→Ω∥S³∥₆
λ x → ∥Pushout⋁↪fold⋁S²∥₅→Ω∥S³∥₆ x
∙ cong ∣_∣ₕ (merid base)
main a =
toPathP (funExt
(trElim (λ _ → isOfHLevelSuc 4 (isOfHLevelTrunc 6 _ _ _ _))
(λ x
→ (λ j → transp (λ i → Path
(hLevelTrunc 6 (Susp S²)) ∣ north ∣ ∣ merid a (i ∨ j) ∣) j
(compPath-filler
(∥Pushout⋁↪fold⋁S²∥₅→Ω∥S³∥₆
(S²→Pushout⋁↪fold⋁S²↺'⁻ a (transportRefl x j)))
(cong ∣_∣ₕ (merid a)) j))
∙ mainLemma a x)))
decode : (x : hLevelTrunc 6 (Susp S²))
→ Code x → Path (hLevelTrunc 6 (Susp S²)) ∣ north ∣ x
decode =
trElim (λ _ → isOfHLevelΠ 6 λ _ → isOfHLevelPath 6 (isOfHLevelTrunc 6) _ _)
decode'
decode∙ : decode ∣ north ∣ ∣ inl (base , base) ∣ ≡ refl
decode∙ =
cong (cong ∣_∣ₕ) (cong (λ x → x ∙ x) (rCancel (merid base)) ∙ sym (rUnit refl))
encode : (x : hLevelTrunc 6 (Susp S²))
→ Path (hLevelTrunc 6 (Susp S²)) ∣ north ∣ x → Code x
encode x p = subst Code p ∣ inl (base , base) ∣
encode-decode : (x : hLevelTrunc 6 (Susp S²))
→ (p : ∣ north ∣ ≡ x) → decode x (encode x p) ≡ p
encode-decode x = J (λ x p → decode x (encode x p) ≡ p)
(cong (decode ∣ north ∣) (transportRefl ∣ inl (base , base) ∣ₕ)
∙ decode∙)
decode-encode : (p : Code ∣ north ∣) → encode ∣ north ∣ (decode ∣ north ∣ p) ≡ p
decode-encode =
trElim (λ _ → isOfHLevelPath 5 (isOfHLevelTrunc 5) _ _)
(Pushout⋁↪fold⋁S²WedgeCon.main ((λ a → encode ∣ north ∣ (decode ∣ north ∣ ∣ a ∣))) ∣_∣ₕ
(isOfHLevelTrunc 5)
(λ x → cong (encode ∣ north ∣) (cong (cong ∣_∣ₕ) (cong (σ S²∙ x ∙_)
(rCancel (merid base)) ∙ sym (rUnit (σ S²∙ x))))
∙ surf-filler x)
(λ x → (cong (encode ∣ north ∣) (cong (cong ∣_∣ₕ) (cong (_∙ σ S²∙ x)
(rCancel (merid base)) ∙ sym (lUnit (σ S²∙ x))))
∙ surf-filler x
∙ cong ∣_∣ₕ (push (inl x)) ∙ cong ∣_∣ₕ (sym (push (inr x)))))
λ x → lem (encode ∣ north ∣)
(cong (decode ∣ north ∣) (cong ∣_∣ₕ (push (inl x))))
((cong (decode ∣ north ∣) (cong ∣_∣ₕ (push (inr x)))))
(surf-filler x) (cong ∣_∣ₕ (push (inl x))) (cong ∣_∣ₕ (sym (push (inr x)))))
where
subber = transport (λ j → Code ∣ merid base (~ j) ∣ₕ)
lem : ∀ {ℓ} {A B : Type ℓ} {x x' y : A} {l w u : B}
(f : A → B) (p : x ≡ y) (p' : x' ≡ y) (q : f y ≡ l)
(r : l ≡ w) (r' : w ≡ u)
→ cong f (sym p) ∙∙ cong f p ∙ q ∙∙ r
≡ (cong f (sym p') ∙∙ (cong f p' ∙ q ∙ (r ∙ r')) ∙∙ sym r')
lem {x = x} {x' = x'} {y = y'} {l = l} {w = w} {u = u} f p p' q r r' =
(λ i → (λ j → f (p (~ j ∨ i))) ∙∙ (λ j → f (p (j ∨ i))) ∙ q ∙∙ r)
∙∙ (λ i → (λ j → f (p' (~ j ∨ ~ i))) ∙∙ (λ j → f (p' (j ∨ ~ i)))
∙ compPath-filler q r i ∙∙ λ j → r (i ∨ j))
∙∙ λ i → cong f (sym p') ∙∙ cong f p' ∙ q
∙ compPath-filler r r' i ∙∙ λ j → r' (~ j ∧ i)
mainId : (x : S²)
→ (S²→Pushout⋁↪fold⋁S²↺' x (inl (base , base))) ≡ ∣ inl (x , base) ∣ₕ
mainId base = refl
mainId (surf i i₁) = refl
surf-filler : (x : S²)
→ encode ∣ north ∣ (λ i → ∣ σ S²∙ x i ∣) ≡ ∣ inl (x , base) ∣
surf-filler x =
(λ i → transp (λ j → Code (∣ merid base (i ∧ ~ j) ∣ₕ)) (~ i)
(encode ∣ merid base i ∣
λ j → ∣ compPath-filler
(merid x) (sym (merid base)) (~ i) j ∣ₕ))
∙ cong subber
(transportRefl (S²→Pushout⋁↪fold⋁S²↺' x (inl (base , base)))
∙ mainId x)
IsoΩ∥SuspS²∥₅∥Pushout⋁↪fold⋁S²∥₅ :
Iso (hLevelTrunc 5 (typ (Ω (Susp∙ S²))))
(hLevelTrunc 5 Pushout⋁↪fold⋁S²)
IsoΩ∥SuspS²∥₅∥Pushout⋁↪fold⋁S²∥₅ =
compIso (invIso (PathIdTruncIso _)) is
where
is : Iso _ _
fun is = encode ∣ north ∣
inv is = decode ∣ north ∣
rightInv is = decode-encode
leftInv is = encode-decode ∣ north ∣
| {
"alphanum_fraction": 0.4739811496,
"avg_line_length": 44.1171303075,
"ext": "agda",
"hexsha": "fca96aa61123ad52e054b3954562319bfefd479d",
"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/Homotopy/Group/Pi4S3/S3PushoutIso.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/Homotopy/Group/Pi4S3/S3PushoutIso.agda",
"max_line_length": 97,
"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/Homotopy/Group/Pi4S3/S3PushoutIso.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": 14020,
"size": 30132
} |
{-# OPTIONS --without-K --safe #-}
module Categories.Category.Construction.Properties.EilenbergMoore where
open import Level
import Relation.Binary.PropositionalEquality as ≡
open import Categories.Adjoint
open import Categories.Adjoint.Properties
open import Categories.Category
open import Categories.Functor using (Functor; _∘F_)
open import Categories.Functor.Equivalence
open import Categories.Monad
open import Categories.NaturalTransformation renaming (id to idN)
open import Categories.Morphism.HeterogeneousIdentity
open import Categories.Adjoint.Construction.EilenbergMoore
open import Categories.Category.Construction.EilenbergMoore
private
variable
o ℓ e : Level
𝒞 𝒟 : Category o ℓ e
module _ {F : Functor 𝒞 𝒟} {G : Functor 𝒟 𝒞} (F⊣G : Adjoint F G) where
private
T : Monad 𝒞
T = adjoint⇒monad F⊣G
𝒞ᵀ : Category _ _ _
𝒞ᵀ = EilenbergMoore T
module 𝒞 = Category 𝒞
module 𝒟 = Category 𝒟
module 𝒞ᵀ = Category 𝒞ᵀ
open 𝒞.HomReasoning
module T = Monad T
module F = Functor F
module G = Functor G
open Adjoint F⊣G
open NaturalTransformation
-- Maclane's Comparison Functor
ComparisonF : Functor 𝒟 𝒞ᵀ
ComparisonF = record
{ F₀ = λ X → record
{ A = G.F₀ X
; action = G.F₁ (counit.η X)
; commute = commute (G ∘ˡ counit) (counit.η X)
; identity = zag
}
; F₁ = λ {A} {B} f → record
{ arr = G.F₁ f
; commute = begin
𝒞 [ G.F₁ f ∘ G.F₁ (counit.η A) ] ≈˘⟨ G.homomorphism ⟩
G.F₁ (𝒟 [ f ∘ (counit.η A) ]) ≈˘⟨ G.F-resp-≈ (counit.commute f) ⟩
G.F₁ (𝒟 [ counit.η B ∘ F.F₁ (G.F₁ f) ]) ≈⟨ G.homomorphism ⟩
𝒞 [ G.F₁ (counit.η B) ∘ G.F₁ (F.F₁ (G.F₁ f)) ] ∎
}
; identity = G.identity
; homomorphism = G.homomorphism
; F-resp-≈ = G.F-resp-≈
}
private
K = ComparisonF
module K = Functor K
module Gᵀ = Functor (Forgetful T)
module Fᵀ = Functor (Free T)
Comparison∘F≡Free : (ComparisonF ∘F F) ≡F Free T
Comparison∘F≡Free = record
{ eq₀ = λ X → ≡.refl
; eq₁ = λ {A} {B} f → begin
Module⇒.arr (𝒞ᵀ [ (hid 𝒞ᵀ ≡.refl) ∘ K.F₁ (F.F₁ f) ]) ≈⟨ hid-refl 𝒞ᵀ {A = K.F₀ (F.F₀ B)} ⟩∘⟨refl ⟩
Module⇒.arr (𝒞ᵀ [ 𝒞ᵀ.id ∘ K.F₁ (F.F₁ f) ]) ≈⟨ 𝒞.identityˡ {f = Module⇒.arr (K.F₁ (F.F₁ f))} ⟩
Module⇒.arr (K.F₁ (F.F₁ f)) ≈⟨ refl ⟩
Module⇒.arr (Fᵀ.F₁ f) ≈˘⟨ 𝒞ᵀ.identityʳ {f = Fᵀ.F₁ f} ⟩
Module⇒.arr (𝒞ᵀ [ Fᵀ.F₁ f ∘ 𝒞ᵀ.id ]) ≈˘⟨ refl⟩∘⟨ hid-refl 𝒞ᵀ {A = Fᵀ.F₀ A} ⟩
Module⇒.arr (𝒞ᵀ [ Fᵀ.F₁ f ∘ (hid 𝒞ᵀ ≡.refl) ]) ∎
}
Forgetful∘ComparisonF≡G : (Forgetful T ∘F ComparisonF) ≡F G
Forgetful∘ComparisonF≡G = record
{ eq₀ = λ X → ≡.refl
; eq₁ = λ f → begin
𝒞 [ (hid 𝒞 ≡.refl) ∘ (Gᵀ.F₁ (K.F₁ f)) ] ≈⟨ hid-refl 𝒞 ⟩∘⟨refl ⟩
𝒞 [ 𝒞.id ∘ (Gᵀ.F₁ (K.F₁ f)) ] ≈⟨ 𝒞.identityˡ ⟩
(Gᵀ.F₁ (K.F₁ f)) ≈⟨ refl ⟩
G.F₁ f ≈˘⟨ 𝒞.identityʳ ⟩
𝒞 [ G.F₁ f ∘ 𝒞.id ] ≈˘⟨ refl⟩∘⟨ hid-refl 𝒞 ⟩
𝒞 [ G.F₁ f ∘ (hid 𝒞 ≡.refl) ] ∎
}
| {
"alphanum_fraction": 0.5461104141,
"avg_line_length": 32.8659793814,
"ext": "agda",
"hexsha": "0e036e3b65998f1899638ae78af17c9f2af3a975",
"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": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "MirceaS/agda-categories",
"max_forks_repo_path": "src/Categories/Category/Construction/Properties/EilenbergMoore.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"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": "MirceaS/agda-categories",
"max_issues_repo_path": "src/Categories/Category/Construction/Properties/EilenbergMoore.agda",
"max_line_length": 109,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "MirceaS/agda-categories",
"max_stars_repo_path": "src/Categories/Category/Construction/Properties/EilenbergMoore.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1362,
"size": 3188
} |
{-# OPTIONS --without-K #-}
module overloading.bundle where
open import level
record Bundle {i j} {Base : Set i}
(Struct : Base → Set j) : Set (lsuc (i ⊔ j)) where
constructor bundle
field
parent : Base
struct : Struct parent
| {
"alphanum_fraction": 0.6076923077,
"avg_line_length": 21.6666666667,
"ext": "agda",
"hexsha": "026c241fdddc353e47c989d5178c5a509637734e",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2019-02-26T06:17:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-04-11T17:19:12.000Z",
"max_forks_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "HoTT/M-types",
"max_forks_repo_path": "overloading/bundle.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c",
"max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "pcapriotti/agda-base",
"max_issues_repo_path": "src/overloading/bundle.agda",
"max_line_length": 70,
"max_stars_count": 27,
"max_stars_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "HoTT/M-types",
"max_stars_repo_path": "overloading/bundle.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-09T07:26:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-14T15:47:03.000Z",
"num_tokens": 68,
"size": 260
} |
{-# OPTIONS --without-K #-}
--open import HoTT
open import homotopy.3x3.PushoutPushout
open import homotopy.3x3.Transpose
import homotopy.3x3.To as To
import homotopy.3x3.From as From
open import homotopy.3x3.Common
module homotopy.3x3.FromToInit {i} (d : Span^2 {i}) where
open Span^2 d
open M d hiding (Pushout^2)
open M (transpose d) using () renaming (module F₁∙ to F∙₁; f₁∙ to f∙₁;
module F₃∙ to F∙₃; f₃∙ to f∙₃;
v-h-span to h-v-span)
open M using (Pushout^2)
open To d
open From d
from-to-l-g : (c : A₀₂) → ap (from ∘ to ∘ left) (glue c) == ap left (glue c)
from-to-l-g c =
ap (from ∘ i₀∙) (glue c)
=⟨ ap-∘ from i₀∙ (glue c) ⟩
ap from (ap i₀∙ (glue c))
=⟨ I₀∙.glue-β c |in-ctx ap from ⟩
ap from (glue (left c))
=⟨ From.glue-β (left c) ⟩
ap left (glue c) ∎
module FromToL = PushoutElim {d = span _ _ _ f₀₁ f₀₃} {P = λ a → from (to (left a)) == left a}
(λ a → idp) (λ b → idp) (λ c → ↓-='-in (! (from-to-l-g c)))
from-to-l : (a : A₀∙) → from (to (left a)) == left a
from-to-l = FromToL.f
from-to-r-g : (c : A₄₂) → ap (from ∘ to ∘ right) (glue c) == ap right (glue c)
from-to-r-g c =
ap (from ∘ i₄∙) (glue c)
=⟨ ap-∘ from i₄∙ (glue c) ⟩
ap from (ap i₄∙ (glue c))
=⟨ I₄∙.glue-β c |in-ctx ap from ⟩
ap from (glue (right c))
=⟨ From.glue-β (right c) ⟩
ap right (glue c) ∎
module FromToR = PushoutElim {d = span _ _ _ f₄₁ f₄₃} {P = λ b → from (to (right b)) == right b}
(λ a → idp) (λ b → idp) (λ c → ↓-='-in (! (from-to-r-g c)))
from-to-r : (b : A₄∙) → from (to (right b)) == right b
from-to-r = FromToR.f
from-to-g-l : (a : A₂₀) → glue (left a) == ap from (ap to (glue (left a)))
from-to-g-l a =
glue (left a)
=⟨ ! (I∙₀.glue-β a) ⟩
ap i∙₀ (glue a)
=⟨ ap-∘ from left (glue a) ⟩
ap from (ap left (glue a))
=⟨ ! (To.glue-β (left a)) |in-ctx ap from ⟩
ap from (ap to (glue (left a))) ∎
from-to-g-r : (b : A₂₄) → glue (right b) == ap from (ap to (glue (right b)))
from-to-g-r b =
glue (right b)
=⟨ ! (I∙₄.glue-β b) ⟩
ap i∙₄ (glue b)
=⟨ ap-∘ from right (glue b) ⟩
ap from (ap right (glue b))
=⟨ ! (To.glue-β (right b)) |in-ctx ap from ⟩
ap from (ap to (glue (right b))) ∎
| {
"alphanum_fraction": 0.5216076059,
"avg_line_length": 31.698630137,
"ext": "agda",
"hexsha": "1140fc09de4fa5b55f13d3ece49c5f4e449d63ec",
"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": "homotopy/3x3/FromToInit.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": "homotopy/3x3/FromToInit.agda",
"max_line_length": 96,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "f8fa68bf753d64d7f45556ca09d0da7976709afa",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "UlrikBuchholtz/HoTT-Agda",
"max_stars_repo_path": "homotopy/3x3/FromToInit.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": 1006,
"size": 2314
} |
module Issue4260 where
open import Issue4260.M
-- syntax F X = G X
H : Set → Set
H X = G X
| {
"alphanum_fraction": 0.6421052632,
"avg_line_length": 10.5555555556,
"ext": "agda",
"hexsha": "688a773d315d33da316b2546ba23659ccce591b0",
"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/Issue4260.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/Issue4260.agda",
"max_line_length": 23,
"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/Issue4260.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": 34,
"size": 95
} |
module plfa-code.Negation where
open import Relation.Binary.PropositionalEquality using (_≡_; refl)
open import Data.Nat using (ℕ; zero; suc)
open import Data.Empty using (⊥; ⊥-elim)
open import Data.Sum using (_⊎_; inj₁; inj₂)
open import Data.Product using (_×_) renaming (_,_ to ⟨_,_⟩)
open import plfa-code.Isomorphism using (_≃_; extensionality)
¬_ : Set → Set
¬ A = A → ⊥
¬-elim : ∀ {A : Set}
→ ¬ A
→ A
---
→ ⊥
¬-elim ¬x x = ¬x x
infix 3 ¬_
¬¬-intro : ∀ {A : Set}
→ A
-----
→ ¬ ¬ A
¬¬-intro x = λ ¬x → ¬x x
¬¬-intro′ : ∀ {A : Set}
→ A
-----
→ ¬ ¬ A
¬¬-intro′ x ¬x = ¬x x
¬¬¬-elim : ∀ {A : Set}
→ ¬ ¬ ¬ A
-------
→ ¬ A
¬¬¬-elim ¬¬¬x = λ x → ¬¬¬x (¬¬-intro x)
contraposition : ∀ {A B : Set}
→ (A → B)
------------
→ (¬ B → ¬ A)
contraposition f ¬y x = ¬y (f x)
_≢_ : ∀ {A : Set} → A → A → Set
x ≢ y = ¬ (x ≡ y)
_ : 1 ≢ 2
_ = λ ()
peano : ∀ {m : ℕ} → zero ≢ suc m
peano = λ ()
id : ⊥ → ⊥
id x = x
id′ : ⊥ → ⊥
id′ ()
id≡id′ : id ≡ id′
id≡id′ = extensionality (λ ())
assimilation : ∀ {A : Set} (¬x ¬x′ : ¬ A) → ¬x ≡ ¬x′
assimilation ¬x ¬x′ = extensionality (λ x → ⊥-elim (¬x′ x))
open Data.Nat using (_<_; _≤_; z≤n; s≤s)
open Relation.Binary.PropositionalEquality using (cong)
open import Function
open Data.Product using (proj₁; proj₂)
---------- practice ----------
<-irreflexive : ∀ {n : ℕ} → ¬ (n < n)
<-irreflexive {suc n} (s≤s n<n) = <-irreflexive n<n
data Trichotomy (m n : ℕ) : Set where
less : m < n → ¬ (n < m) → ¬ (m ≡ n) → Trichotomy m n
greater : n < m → ¬ (m ≡ n) → ¬ (m < n) → Trichotomy m n
equal : m ≡ n → ¬ (m < n) → ¬ (n < m) → Trichotomy m n
inv-< : ∀ {m n} → suc m < suc n → m < n
inv-< (s≤s sm<sn) = sm<sn
inv-≡ : ∀ {m n} → suc m ≡ suc n → m ≡ n
inv-≡ refl = refl
<-trichotomy : ∀ (m n : ℕ) → Trichotomy m n
<-trichotomy zero zero = equal refl (λ ()) (λ ())
<-trichotomy zero (suc n) = less (s≤s z≤n) (λ ()) (λ ())
<-trichotomy (suc m) zero = greater (s≤s z≤n) (λ ()) (λ ())
<-trichotomy (suc m) (suc n) with <-trichotomy m n
... | less m<n ¬n<m ¬m≡n = less (s≤s m<n) (¬n<m ∘ inv-<) (¬m≡n ∘ inv-≡)
... | greater n<m ¬m≡n ¬m<n = greater (s≤s n<m) (¬m≡n ∘ inv-≡) (¬m<n ∘ inv-<)
... | equal m≡n ¬m<n ¬n<m = equal (cong suc m≡n) (¬m<n ∘ inv-<) (¬n<m ∘ inv-<)
⊎-dual-× : ∀ (A B : Set) → ¬ (A ⊎ B) ≃ (¬ A) × (¬ B)
⊎-dual-× A B =
record
{ to = λ ¬-A⊎B → ⟨ (¬-A⊎B ∘ inj₁) , (¬-A⊎B ∘ inj₂) ⟩
; from = λ{ ¬A׬B (inj₁ a) → proj₁ ¬A׬B a
; ¬A׬B (inj₂ b) → proj₂ ¬A׬B b
}
; from∘to = λ{x → assimilation _ x}
; to∘from = λ{ ⟨ ¬a , ¬b ⟩ → refl}
}
-- ¬ (A × B) ≃ (¬ A) ⊎ (¬ B) does not hold, but we could say:
⊎¬-implies-¬× : ∀ (A B : Set) → (¬ A) ⊎ (¬ B) → ¬ (A × B)
⊎¬-implies-¬× A B (inj₁ ¬a) = λ ab → ¬a (proj₁ ab)
⊎¬-implies-¬× A B (inj₂ ¬b) = λ ab → ¬b (proj₂ ab)
------------------------------
em-irrefutable : ∀ {A : Set} → ¬ ¬ (A ⊎ ¬ A)
em-irrefutable k = k (inj₂ (λ x → k (inj₁ x)))
---------- practice ----------
-- to prove the implying relations among a group of
-- proposition P₀ P₁ P₂ ... Pₙ, we just need prove P₀ → P₁,
-- P₁ → P₂, ..., Pₙ₋₁ → Pₙ, Pₙ → P₀.
P₀ = ∀ {A : Set} → A ⊎ ¬ A
P₁ = ∀ {A : Set} → (¬ ¬ A → A)
P₂ = ∀ {A B : Set} → ((A → B) → A) → A
P₃ = ∀ {A B : Set} → (A → B) → ¬ A ⊎ B
P₄ = ∀ {A B : Set} → ¬ (¬ A × ¬ B) → A ⊎ B
P₀⇒P₁ : P₀ → P₁
P₀⇒P₁ p₀ {A} ¬¬a with p₀ {A}
... | inj₁ a = a
... | inj₂ ¬a = ⊥-elim (¬¬a ¬a)
P₁⇒P₂ : P₁ → P₂
P₁⇒P₂ p₁ x = p₁ $ λ ¬a → (¬a $ x $ p₁ ∘ const ∘ ¬a)
P₂⇒P₃ : P₂ → P₃
P₂⇒P₃ p₂ {A} {B} f = p₂ {¬ A ⊎ B} {⊥} (λ z → inj₁ (z ∘ inj₂ ∘ f))
--- the prove 'P₃⇒P₄' below referenced https://github.com/googleson78/plfa
P₃⇒P₀ : P₃ → P₀
P₃⇒P₀ p₃ {A} with p₃ Function.id
... | inj₁ ¬x = inj₂ ¬x
... | inj₂ x = inj₁ x
P₁⇒P₄ : P₁ → P₄
P₁⇒P₄ p₁ {A} {B} ¬x = p₁ (λ ¬y → ¬x ⟨ ¬y ∘ inj₁ , ¬y ∘ inj₂ ⟩)
P₃⇒P₄ : P₃ → P₄
P₃⇒P₄ = P₁⇒P₄ ∘ P₀⇒P₁ ∘ P₃⇒P₀
P₄⇒P₀ : P₄ → P₀
P₄⇒P₀ p₄ {A} = p₄ {A} {¬ A} $ proj₂ ˢ proj₁
Stable : Set → Set
Stable A = ¬ ¬ A → A
¬⇒stable : ∀ {A : Set} → ¬ A → Stable (¬ A)
¬⇒stable ¬a = ¬¬¬-elim
×⇒stable : ∀ {A B : Set} → Stable A → Stable B → Stable (A × B)
×⇒stable a b = λ x → ⟨ (a $ λ z → x (z ∘ proj₁)) , (b $ λ z → x (z ∘ proj₂)) ⟩
| {
"alphanum_fraction": 0.4523584906,
"avg_line_length": 25.8536585366,
"ext": "agda",
"hexsha": "9649844cadf8fbfd4657c2aafcbb31bdf3bbf07f",
"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/Negation.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/Negation.agda",
"max_line_length": 80,
"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/Negation.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2106,
"size": 4240
} |
{-# OPTIONS -Werror -WnoEmptyRewritePragma #-}
{-# REWRITE #-}
| {
"alphanum_fraction": 0.640625,
"avg_line_length": 16,
"ext": "agda",
"hexsha": "d6177072eec100664108b5abab8cc669eebca7f3",
"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/Issue2912.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/Issue2912.agda",
"max_line_length": 46,
"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/Issue2912.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": 17,
"size": 64
} |
{-# OPTIONS --without-K --exact-split #-}
module hott-i where
import 04-inductive-types
open 04-inductive-types public
data 𝕀 : UU lzero where
left : 𝕀
postulate right : 𝕀
data Path {l : Level} (A : 𝕀 → UU l) : (a : A left) (a' : A right) → UU l where
pcon : (f : (x : 𝕀) → A x) → Path A (f left) (f right)
apply-path :
{l : Level} (A : 𝕀 → UU l) (a : A left) (a' : A right) →
Path A a a' → (x : 𝕀) → A x
apply-path A .(f left) .(f right) (pcon f) x = f x
refl-path :
{l : Level} (A : UU l) (a : A) → Path (λ x → A) a a
refl-path A a = pcon (λ x → a)
apply-path-pcon :
{l : Level} (A : 𝕀 → UU l) (f : (x : 𝕀) → A x) →
(x : 𝕀) → Path (λ y → A x) (apply-path A (f left) (f right) (pcon f) x) (f x)
apply-path-pcon A f x = refl-path (A x) (f x)
left-apply-path :
{l : Level} (A : 𝕀 → UU l) (a : A left) (a' : A right) (p : Path A a a') →
Path (λ y → A left) (apply-path A a a' p left) a
left-apply-path A .(f left) .(f right) (pcon f) = refl-path (A left) (f left)
right-apply-path :
{l : Level} (A : 𝕀 → UU l) (a : A left) (a' : A right) (p : Path A a a') →
Path (λ y → A right) (apply-path A a a' p right) a'
right-apply-path A .(f left) .(f right) (pcon f) = refl-path (A right) (f right)
free-transport-path :
{l : Level} (A : 𝕀 → UU l) → A left → (x : 𝕀) → A x
free-transport-path A a left = a
transport-path :
{l : Level} (A : 𝕀 → UU l) → A left → A right
transport-path A a = free-transport-path A a right
elim-path-lemma :
{l : Level} {A : UU l} (f : (x : 𝕀) → A) →
(i : 𝕀) → Path (λ j → A) (f left) (f i)
elim-path-lemma {A = A} f left = refl-path A (f left)
elim-path :
{l1 l2 : Level} (A : UU l1) (a : A)
(B : (x : A) (p : Path (λ i → A) a x) → UU l2) →
B a (refl-path A a) →
(x : A) (p : Path (λ i → A) a x) → B x p
elim-path A .(f left) B b .(f right) (pcon f) =
transport-path (λ i → B (f i) {!elim-path-lemma f i!}) b
concat-path :
{l : Level} {A : UU l} {x y z : A} →
Path (λ i → A) x y → Path (λ i → A) y z → Path (λ i → A) x z
concat-path {l} {A} {x} p (pcon f) =
transport-path (λ i → Path (λ j → A) x (f i)) p
function-extensionality' :
{l1 l2 : Level} {A : UU l1} {B : A → UU l2} {f g : (x : A) → B x} →
(H : (x : A) → Path (λ i → B x) (f x) (g x)) →
(i : 𝕀) (x : A) → B x
function-extensionality' {B = B} {f} {g} H i x =
apply-path (λ j → B x) (f x) (g x) (H x) i
function-extensionality :
{l1 l2 : Level} {A : UU l1} {B : A → UU l2} {f g : (x : A) → B x} →
(H : (x : A) → Path (λ i → B x) (f x) (g x)) →
Path (λ j → (x : A) → B x) f g
function-extensionality {l1} {l2} {A} {B} {f} {g} H =
concat-path
( concat-path
{!!}
( pcon (function-extensionality' H)))
( {!!})
{-
pcon-apply-path :
{l : Level} (A : 𝕀 → UU l) (a : A left) (a' : A right) (p : Path A a a') →
Path (λ y → Path A a a') (pcon (apply-path A a a' p)) ?
pcon-apply-path A a a' p = ?
-}
| {
"alphanum_fraction": 0.5060827251,
"avg_line_length": 31.2717391304,
"ext": "agda",
"hexsha": "9855b797050a29094ad82317eb6c55ad3597a9ad",
"lang": "Agda",
"max_forks_count": 30,
"max_forks_repo_forks_event_max_datetime": "2022-03-16T00:33:50.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-09-26T09:08:57.000Z",
"max_forks_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9",
"max_forks_repo_licenses": [
"CC-BY-4.0"
],
"max_forks_repo_name": "UlrikBuchholtz/HoTT-Intro",
"max_forks_repo_path": "Agda/hott-i.agda",
"max_issues_count": 8,
"max_issues_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9",
"max_issues_repo_issues_event_max_datetime": "2020-10-16T15:27:01.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-18T04:16:04.000Z",
"max_issues_repo_licenses": [
"CC-BY-4.0"
],
"max_issues_repo_name": "UlrikBuchholtz/HoTT-Intro",
"max_issues_repo_path": "Agda/hott-i.agda",
"max_line_length": 80,
"max_stars_count": 333,
"max_stars_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9",
"max_stars_repo_licenses": [
"CC-BY-4.0"
],
"max_stars_repo_name": "UlrikBuchholtz/HoTT-Intro",
"max_stars_repo_path": "Agda/hott-i.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-22T23:50:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-09-26T08:33:30.000Z",
"num_tokens": 1294,
"size": 2877
} |
open import Agda.Primitive
open import Agda.Builtin.Bool
open import Agda.Builtin.Equality
infix 2 _↔_
record _↔_ {a} {b} (p : Set a) (q : Set b) : Set (a ⊔ b) where
field
l2r : p → q
r2l : q → p
_&_ : Bool → Bool → Bool
true & true = true
_ & _ = false
[_] : Bool → Set
[ P ] = P ≡ true
record ∃ {A : Set} (P : A → Bool) : Set where
field
{witness} : A
proof : [ P witness ]
postulate
U : Set
set : Set
subset : set → set → Bool
int : set → set → set
mem : ∀ {A : Set} → A → set → Bool
mapsF : set → set → Bool
F : ∀ {A B : Set} → A → B → Bool
same : ∀ {A B : Set} → A → B → Bool
equal : set → set → Bool
invF : set → set → set
subsetMembershipLaw : ∀ {A} {B} → [ subset A B ] ↔ (∀ {M : Set} {x : M} → [ mem x A ] → [ mem x B ])
-- mapsFLaw : ∀ {A} {B} → [ mapsF A B ] ↔ ((∀ {M : Set} {x : M} → [ mem x A ] → ∃ λ (y : M) → mem y B & F x y)
{-
Problem #758
same as problem 757 but rewritten with only expressions of first-order logic
Given premises:
(all A)(all B)((subset A B) <-> (all x)((mem x A) -> (mem x B))) justification = 1.0
(all A)(all B)(some intAB)(IsInt A B intAB) justification = 1.0
(all A)(all B)(all intAB)((IsInt A B intAB) <-> (all x)((mem x intAB) <-> ((mem x A) & (mem x B)))) justification = 1.0
(all A)(all B)((mapsF A B) <-> ((all x)((mem x A) -> (some y)((mem y B) & (F x y))) & (all x)(all y)(all z)(((mem x A) & ((mem y A) & (mem z A))) -> (((F x y) & (F x z)) -> (same y z))))) justification = 1.0
(all A)(all x)(all y)((same x y) -> ((mem x A) -> (mem y A))) justification = 1.0
(all x)(same x x) justification = 1.0
(all x)(all y)((same x y) <-> (same y x)) justification = 1.0
(all x)(all y)(all z)(((same x y) & (same y z)) -> (same x z)) justification = 1.0
(all A)(all B)((equal A B) <-> ((subset A B) & (subset B A))) justification = 1.0
(all A)(all B)(some invFBA)(IsInvF B A invFBA) justification = 1.0
(all A)(all B)(all invFBA)((IsInvF B A invFBA) <-> (all x)((mem x invFBA) <-> ((mem x A) & (some y)((mem y B) & (F x y))))) justification = 1.0
Ultimate epistemic interests:
(all A)(all B)(all X)(all Y)(((mapsF A B) & ((subset X B) & (subset Y B))) -> (some intXY)((IsInt X Y intXY) & (some invFIntXYA)((IsInvF intXY A invFIntXYA) & (some invFXA)((IsInvF X A invFXA) & (some invFYA)((IsInvF Y A invFYA) & (some intInvFXAInvFYA)((IsInt invFXA invFYA intInvFXAInvFYA) & (equal invFIntXYA intInvFXAInvFYA))))))) interest = 1.0
-}
| {
"alphanum_fraction": 0.5395941106,
"avg_line_length": 45.6909090909,
"ext": "agda",
"hexsha": "37cf864c6c094bb0ba65d6d5de715418c3768300",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_forks_repo_licenses": [
"RSA-MD"
],
"max_forks_repo_name": "m0davis/oscar",
"max_forks_repo_path": "archive/lisp-revised/Problem758.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z",
"max_issues_repo_licenses": [
"RSA-MD"
],
"max_issues_repo_name": "m0davis/oscar",
"max_issues_repo_path": "archive/lisp-revised/Problem758.agda",
"max_line_length": 357,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_stars_repo_licenses": [
"RSA-MD"
],
"max_stars_repo_name": "m0davis/oscar",
"max_stars_repo_path": "archive/lisp-revised/Problem758.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 993,
"size": 2513
} |
------------------------------------------------------------------------
-- An up-to technique for weak similarity
------------------------------------------------------------------------
{-# OPTIONS --sized-types #-}
open import Labelled-transition-system
module Similarity.Weak.Up-to {ℓ} (lts : LTS ℓ) where
open import Logical-equivalence using (_⇔_)
open import Prelude
open import Prelude.Size
open import Equational-reasoning
open import Expansion lts using (Expansion)
open import Relation
open import Similarity.Weak lts
import Similarity.Weak.Equational-reasoning-instances
import Up-to
open LTS lts
------------------------------------------------------------------------
-- The general up-to machinery, instantiated with the StepC container
open Up-to StepC public
------------------------------------------------------------------------
-- An example
-- Up to expansion to the left and weak similarity to the right.
--
-- This is a generalisation of the non-symmetric up-to technique
-- presented by Pous and Sangiorgi in Section 6.5.2.4 of "Enhancements
-- of the bisimulation proof method".
Up-to-expansion-and-weak-similarity : Trans₂ ℓ Proc
Up-to-expansion-and-weak-similarity R =
Expansion ∞ ⊙ R ⊙ Weak-similarity ∞
-- The relation transformer is monotone.
up-to-expansion-and-weak-similarity-monotone :
Monotone Up-to-expansion-and-weak-similarity
up-to-expansion-and-weak-similarity-monotone R⊆S =
Σ-map id (Σ-map id (Σ-map id (Σ-map R⊆S id)))
-- The relation transformer is size-preserving.
up-to-expansion-and-weak-similarity-size-preserving :
Size-preserving Up-to-expansion-and-weak-similarity
up-to-expansion-and-weak-similarity-size-preserving =
_⇔_.from (monotone→⇔ up-to-expansion-and-weak-similarity-monotone)
(λ where
{x = p , q} (r , p≳r , s , r≼s , s≼q) →
p ∼⟨ p≳r ⟩
r ∼′⟨ r≼s ⟩ ≼:
s ∼⟨ s≼q ⟩■
q)
| {
"alphanum_fraction": 0.6074619023,
"avg_line_length": 31.1967213115,
"ext": "agda",
"hexsha": "ca1d9907b96d81e2b1ac0696598540066ac6a2b1",
"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": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/up-to",
"max_forks_repo_path": "src/Similarity/Weak/Up-to.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14",
"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/up-to",
"max_issues_repo_path": "src/Similarity/Weak/Up-to.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/up-to",
"max_stars_repo_path": "src/Similarity/Weak/Up-to.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 505,
"size": 1903
} |
{-# OPTIONS --without-K #-}
module pointed.equality where
open import sum
open import equality.core
open import function.extensionality
open import function.isomorphism.core
open import function.isomorphism.utils
open import pointed.core
pmap-eq : ∀ {i j}{X : Set i}{Y : Set j}{x₀ : X}{y₀ : Y}
→ {f : X → Y}{p : f x₀ ≡ y₀}
→ {g : X → Y}{q : g x₀ ≡ y₀}
→ (Σ ((x : X) → f x ≡ g x) λ γ → p ≡ γ x₀ · q)
≅ _≡_ {A = PMap (X , x₀) (Y , y₀)} (f , p) (g , q)
pmap-eq {X = X}{Y}{x₀}{y₀} = Σ-ap-iso' strong-funext-iso lem ·≅ Σ-split-iso
where
lem : {f : X → Y}{p : f x₀ ≡ y₀}
→ {g : X → Y}{q : g x₀ ≡ y₀}
→ (h : f ≡ g)
→ (p ≡ funext-inv h x₀ · q)
≅ (subst (λ u → u x₀ ≡ y₀) h p ≡ q)
lem refl = refl≅
| {
"alphanum_fraction": 0.5019607843,
"avg_line_length": 31.875,
"ext": "agda",
"hexsha": "46671d620a61ced4624c2c283de882cedd814e90",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z",
"max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "pcapriotti/agda-base",
"max_forks_repo_path": "src/pointed/equality.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c",
"max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "pcapriotti/agda-base",
"max_issues_repo_path": "src/pointed/equality.agda",
"max_line_length": 75,
"max_stars_count": 20,
"max_stars_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "pcapriotti/agda-base",
"max_stars_repo_path": "src/pointed/equality.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-01T11:25:54.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-06-12T12:20:17.000Z",
"num_tokens": 318,
"size": 765
} |
{-# OPTIONS --safe #-}
module Cubical.Data.Unit.Pointed where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Pointed.Base
open import Cubical.Data.Unit
private
variable
ℓ : Level
Unit∙ : Pointed ℓ
Unit∙ = Unit* , tt*
| {
"alphanum_fraction": 0.7380952381,
"avg_line_length": 16.8,
"ext": "agda",
"hexsha": "b80614d2920a5e2dd4f5ec60cfcadf5281f9e5b1",
"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/Unit/Pointed.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/Unit/Pointed.agda",
"max_line_length": 44,
"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/Unit/Pointed.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": 71,
"size": 252
} |
{-# OPTIONS --cubical --safe #-}
module Data.Bits.Fold where
open import Data.Bits
open import Strict
open import Prelude
module _ {a} {A : Type a} (zer : A → A) (one : A → A) (base : A) where
foldr-bits : Bits → A
foldr-bits [] = base
foldr-bits (0∷ xs) = zer (foldr-bits xs)
foldr-bits (1∷ xs) = one (foldr-bits xs)
foldr-universal : ∀ (h : Bits → A) z o e →
(h [] ≡ e) →
(∀ xs → h (0∷ xs) ≡ z (h xs)) →
(∀ xs → h (1∷ xs) ≡ o (h xs)) →
∀ xs → h xs ≡ foldr-bits z o e xs
foldr-universal h z o e base zer one [] = base
foldr-universal h z o e base zer one (0∷ xs) = zer xs ; cong z (foldr-universal h z o e base zer one xs)
foldr-universal h z o e base zer one (1∷ xs) = one xs ; cong o (foldr-universal h z o e base zer one xs)
module _ {a} {A : Type a} (zer : A → A) (one : A → A) where
foldl-go : Bits → A → A
foldl-go [] base = base
foldl-go (0∷ xs) base = foldl-go xs $! zer base
foldl-go (1∷ xs) base = foldl-go xs $! one base
foldl-bits : A → Bits → A
foldl-bits = λ base xs → foldl-go xs $! base
{-# INLINE foldl-bits #-}
foldl-universal : ∀ (h : Bits → A → A) z o e →
(∀ xs bs → h (0∷ xs) bs ≡ h xs (z bs)) →
(∀ xs bs → h (1∷ xs) bs ≡ h xs (o bs)) →
(∀ bs → h [] bs ≡ bs) →
∀ xs → h xs e ≡ foldl-bits z o e xs
foldl-universal h z o e zer one bs [] = bs e ; sym ($!-≡ (foldl-go z o []) e)
foldl-universal h z o e zer one bs (0∷ xs) = zer xs e ; foldl-universal h z o (z e) zer one bs xs ; sym ($!-≡ (foldl-go z o (0∷ xs)) e)
foldl-universal h z o e zer one bs (1∷ xs) = one xs e ; foldl-universal h z o (o e) zer one bs xs ; sym ($!-≡ (foldl-go z o (1∷ xs)) e)
| {
"alphanum_fraction": 0.5150997151,
"avg_line_length": 41.7857142857,
"ext": "agda",
"hexsha": "a628a9aec8df66e3074ee6400aec23a2f7513809",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z",
"max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/agda-playground",
"max_forks_repo_path": "Data/Bits/Fold.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "oisdk/agda-playground",
"max_issues_repo_path": "Data/Bits/Fold.agda",
"max_line_length": 135,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/agda-playground",
"max_stars_repo_path": "Data/Bits/Fold.agda",
"max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z",
"num_tokens": 688,
"size": 1755
} |
{-# OPTIONS --safe --warning=error --without-K #-}
open import Functions
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import LogicalFormulae
open import Setoids.Subset
open import Setoids.Setoids
open import Setoids.Orders
open import Fields.Fields
open import Rings.Orders.Total.Definition
open import Rings.Orders.Total.Lemmas
open import Rings.Orders.Partial.Definition
open import Rings.Definition
open import Fields.Orders.LeastUpperBounds.Definition
open import Numbers.ClassicalReals.RealField
open import Groups.Definition
open import Groups.Homomorphisms.Definition
open import Rings.Homomorphisms.Definition
open import Sets.EquivalenceRelations
open import Semirings.Definition
open import Numbers.Naturals.Semiring
open import Numbers.Integers.Definition
open import Numbers.Integers.RingStructure.Ring
module Numbers.ClassicalReals.RealField.AllIsomorphic (ℝ : RealField) where
open RealField ℝ
open Ring R
open Group additiveGroup
open Setoid S
open Equivalence eq
open import Rings.Lemmas R
open import Groups.Lemmas additiveGroup
fromN : ℕ → A
fromN zero = 0R
fromN (succ n) = 1R + fromN n
fromNPreserves+ : (a b : ℕ) → fromN (a +N b) ∼ (fromN a) + (fromN b)
fromNPreserves+ zero b = symmetric identLeft
fromNPreserves+ (succ a) b = transitive (+WellDefined reflexive (fromNPreserves+ a b)) +Associative
fromNPreserves* : (a b : ℕ) → fromN (a *N b) ∼ (fromN a) * (fromN b)
fromNPreserves* zero b = symmetric (transitive *Commutative timesZero)
fromNPreserves* (succ a) b = transitive (transitive (fromNPreserves+ b (a *N b)) (+WellDefined (symmetric identIsIdent) (fromNPreserves* a b))) (symmetric *DistributesOver+')
fromNWellDefined : {a b : ℕ} → a ≡ b → fromN a ∼ fromN b
fromNWellDefined refl = reflexive
fromZ : ℤ → A
fromZ (nonneg x) = fromN x
fromZ (negSucc x) = inverse (fromN (succ x))
private
lemma : (a : ℕ) → (b : ℕ) → (1R + fromN (succ a *N b +N a)) ∼ ((1R + fromN a) * (1R + fromN b))
lemma a b = transitive (transitive (transitive (+WellDefined reflexive (transitive (fromNPreserves+ ((succ a) *N b) a) (transitive groupIsAbelian (+WellDefined reflexive (transitive (fromNPreserves+ b (a *N b)) (+WellDefined (symmetric identIsIdent) (fromNPreserves* a b))))))) +Associative) (+WellDefined (transitive (symmetric identIsIdent) *Commutative) (symmetric *DistributesOver+'))) (symmetric *DistributesOver+)
fromZPreserves+ : (a b : ℤ) → fromZ (a +Z b) ∼ (fromZ a) + (fromZ b)
fromZPreserves+ (nonneg zero) (nonneg y) = symmetric identLeft
fromZPreserves+ (nonneg (succ x)) (nonneg y) = transitive (+WellDefined reflexive (fromNPreserves+ x y)) +Associative
fromZPreserves+ (nonneg zero) (negSucc y) = symmetric identLeft
fromZPreserves+ (nonneg (succ x)) (negSucc zero) = transitive (transitive (transitive (transitive (symmetric identLeft) (+WellDefined (symmetric invLeft) reflexive)) (symmetric +Associative)) (+WellDefined (inverseWellDefined (symmetric identRight)) reflexive)) (groupIsAbelian)
fromZPreserves+ (nonneg (succ x)) (negSucc (succ y)) = transitive (fromZPreserves+ (nonneg x) (negSucc y)) (transitive (transitive (transitive (transitive (transitive (transitive (transitive (symmetric identLeft) +Associative) groupIsAbelian) (+WellDefined reflexive (+WellDefined (symmetric invLeft) reflexive))) (+WellDefined reflexive (symmetric +Associative))) +Associative) groupIsAbelian) (+WellDefined reflexive (symmetric invContravariant)))
fromZPreserves+ (negSucc zero) (nonneg zero) = symmetric identRight
fromZPreserves+ (negSucc zero) (nonneg (succ y)) = transitive (transitive (symmetric identLeft) (+WellDefined (symmetric (transitive (+WellDefined reflexive (symmetric identRight)) invLeft)) reflexive)) (symmetric +Associative)
fromZPreserves+ (negSucc (succ x)) (nonneg zero) = symmetric identRight
fromZPreserves+ (negSucc (succ x)) (nonneg (succ y)) = transitive (fromZPreserves+ (negSucc x) (nonneg y)) (transitive (transitive (+WellDefined reflexive (transitive (symmetric identLeft) (transitive (+WellDefined (symmetric invLeft) reflexive) (symmetric +Associative)))) +Associative) (+WellDefined (symmetric invContravariant) reflexive))
fromZPreserves+ (negSucc x) (negSucc y) = transitive (transitive invContravariant (transitive (+WellDefined invContravariant reflexive) (transitive (+WellDefined (transitive (transitive (+WellDefined (transitive (inverseWellDefined (fromNPreserves+ x y)) invContravariant) reflexive) (symmetric +Associative)) groupIsAbelian) reflexive) (symmetric +Associative)))) (+WellDefined (symmetric invContravariant) (symmetric invContravariant))
fromZPreserves* : (a b : ℤ) → fromZ (a *Z b) ∼ (fromZ a) * (fromZ b)
fromZPreserves* (nonneg a) (nonneg b) = fromNPreserves* a b
fromZPreserves* (nonneg zero) (negSucc b) = symmetric (transitive *Commutative timesZero)
fromZPreserves* (nonneg (succ a)) (negSucc b) = transitive (inverseWellDefined (lemma a b)) (symmetric ringMinusExtracts)
fromZPreserves* (negSucc a) (nonneg zero) = symmetric timesZero
fromZPreserves* (negSucc a) (nonneg (succ b)) = transitive (inverseWellDefined (transitive (+WellDefined reflexive (fromNWellDefined {(a +N b *N a) +N b} {(b +N a *N b) +N a} (transitivity (Semiring.commutative ℕSemiring _ b) (transitivity (applyEquality (b +N_) (transitivity (Semiring.commutative ℕSemiring a _) (applyEquality (_+N a) (multiplicationNIsCommutative b a)))) (Semiring.+Associative ℕSemiring b _ a))))) (lemma a b))) (symmetric ringMinusExtracts')
fromZPreserves* (negSucc a) (negSucc b) = transitive (transitive (+WellDefined reflexive (fromNWellDefined {b +N a *N succ b} {(b +N a *N b) +N a} (transitivity (applyEquality (b +N_) (transitivity (multiplicationNIsCommutative a (succ b)) (transitivity (Semiring.commutative ℕSemiring a _) (applyEquality (_+N a) (multiplicationNIsCommutative b a))))) (Semiring.+Associative ℕSemiring b _ a)))) (lemma a b)) (symmetric twoNegativesTimes)
ringHom : RingHom ℤRing R fromZ
RingHom.preserves1 ringHom = identRight
RingHom.ringHom ringHom {r} {s} = fromZPreserves* r s
GroupHom.groupHom (RingHom.groupHom ringHom) {r} {s} = fromZPreserves+ r s
GroupHom.wellDefined (RingHom.groupHom ringHom) refl = reflexive
| {
"alphanum_fraction": 0.7632779407,
"avg_line_length": 73.0714285714,
"ext": "agda",
"hexsha": "64378a176c9bd27b5fed9f1cd9209ca9d2f8a2f1",
"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": "Numbers/ClassicalReals/RealField/AllIsomorphic.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": "Numbers/ClassicalReals/RealField/AllIsomorphic.agda",
"max_line_length": 463,
"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": "Numbers/ClassicalReals/RealField/AllIsomorphic.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": 1898,
"size": 6138
} |
-- {-# OPTIONS --allow-unsolved-metas #-}
module GUIgeneric.GUIFeaturesPart5 where
open import GUIgeneric.Prelude renaming (addButton to addButton')
open import GUIgeneric.GUIDefinitions renaming (add to add'; add' to add)
open import GUIgeneric.GUI
open import GUIgeneric.GUIExampleLib
open import StateSizedIO.GUI.WxGraphicsLibLevel3 renaming (addButton to addButton')
open import GUIgeneric.GUIFeatures
open import GUIgeneric.GUIFeaturesPart2 hiding ( main ; main1 )
open import GUIgeneric.GUIFeaturesPart3 hiding ( main ; Tea ; Cancel)
open import GUIgeneric.GUIFeaturesPart4 hiding ( main ; cancelNewStateSM ; cancelStateAdded ; cancelFeatureAdded )
open import GUIgeneric.GUIExample hiding (main )
data StatesBasicVM : Set where
pay change soda serveSoda open' close : StatesBasicVM
basicVM : FMachine StatesBasicVM
basicVM .Features = ⊤
basicVM .AddStateF = ⊥
basicVM .GUIF f (inj₁ pay) =
simpleSMState "Pay" (inj₁ change)
basicVM .GUIF f (inj₁ change) =
simpleSMState "Get Change" (inj₁ soda)
basicVM .GUIF f (inj₁ soda) =
simpleSMState "Soda" (inj₁ serveSoda)
basicVM .GUIF f (inj₁ serveSoda) =
simpleSMState "Serve Soda" (inj₁ open')
basicVM .GUIF f (inj₁ open') =
simpleSMState "Open" (inj₁ close)
basicVM .GUIF f (inj₁ close) =
simpleSMState "Close" (inj₁ pay)
basicVM .GUIF f (inj₂ ())
newState : {A B : Set} → A ⊎ B ⊎ ⊤
newState = (inj₂ (inj₂ tt))
{- handler for the new state to be added to the tea machine -}
teaNewStateSM : (fm : FMachine StatesBasicVM)
→ SMachineState
(StatesBasicVM ⊎ fm .AddStateF ⊎ ⊤)
newState
teaNewStateSM fm = simpleSMState "Serve Tea" (inj₁ open')
{- add the new state to the feature machine -}
TeaMAddNewState : FMachine StatesBasicVM
→ FMachine StatesBasicVM
TeaMAddNewState fm =
addOneStateFMachine fm (teaNewStateSM fm)
{- add a dummy feature "FeatureTea" to the feature machine -}
TeaMAddFeature : FMachine StatesBasicVM
→ FMachine StatesBasicVM
TeaMAddFeature fm = addDummyFeatures
(TeaMAddNewState fm)
FeatureTea
{- redefine in the feature machine one button -}
Tea : FMachine StatesBasicVM
→ FMachine StatesBasicVM
Tea fm .Features = TeaMAddFeature fm .Features
Tea fm .AddStateF = TeaMAddFeature fm .AddStateF
Tea fm .GUIF (f , yesTea) (inj₁ soda) =
addBtn2StateMachine
( TeaMAddFeature fm .GUIF
(f , yesTea) (inj₁ soda))
"Tea" newState
Tea fm .GUIF f s = TeaMAddFeature fm .GUIF f s
{- handler for the new state to be added to the cancel machine -}
cancelNewStateSM : (fm : FMachine StatesBasicVM) →
SMachineState (StatesBasicVM ⊎ fm .AddStateF ⊎ ⊤) newState
cancelNewStateSM fm = simpleSMState "Cancelling" (inj₁ pay)
{- add the state to the old feature machine -}
cancelStateAdded : FMachine StatesBasicVM → FMachine StatesBasicVM
cancelStateAdded fm = addOneStateFMachine fm (cancelNewStateSM fm)
{- add a dummy feature "FeatureCancel" to the feature machine -}
cancelFeatureAdded : FMachine StatesBasicVM → FMachine StatesBasicVM
cancelFeatureAdded fm = addDummyFeatures
(cancelStateAdded fm)
FeatureCancel
{- redefine in the feature machine one button -}
Cancel : FMachine StatesBasicVM
→ FMachine StatesBasicVM
Cancel fm .Features = cancelFeatureAdded fm .Features
Cancel fm .AddStateF = cancelFeatureAdded fm .AddStateF
Cancel fm .GUIF (f , yesCancel) (inj₁ soda) =
addBtn2StateMachine (cancelFeatureAdded fm .GUIF (f , yesCancel) (inj₁ soda))
"Cancel" newState
Cancel fm .GUIF f s = cancelFeatureAdded fm .GUIF f s
{- add the Dummy free feature -}
FreeMAddFeature : FMachine StatesBasicVM
→ FMachine StatesBasicVM
FreeMAddFeature fm = addDummyFeatures fm FeatureFree
{- redefine the pay button to free in case feature free is yesFree -}
Free : FMachine StatesBasicVM
→ FMachine StatesBasicVM
Free fm .Features = FreeMAddFeature fm .Features
Free fm .AddStateF = FreeMAddFeature fm .AddStateF
Free fm .GUIF (f , yesFree) (inj₁ pay) =
simpleSMState "Free" (inj₁ soda)
Free fm .GUIF (f , yesFree) (inj₁ open') =
simpleSMState "Skip" (inj₁ pay)
Free fm .GUIF f s = FreeMAddFeature fm .GUIF f s
main1 : NativeIO Unit
main1 = compileFeatureVM (Tea (Cancel basicVM)) ((_ , yesCancel) , yesTea) (inj₁ pay)
main2 : NativeIO Unit
main2 = compileFeatureVM (Free basicVM) (_ , yesFree) (inj₁ pay) --
multiFeatureMachine : FMachine StatesBasicVM
multiFeatureMachine = Free (Cancel (Tea basicVM))
main : NativeIO Unit
main = compileFeatureVM
multiFeatureMachine
(((_ , yesTea) , yesCancel) , noFree) (inj₁ pay)
| {
"alphanum_fraction": 0.6939744119,
"avg_line_length": 38.157480315,
"ext": "agda",
"hexsha": "fd9e4c7b74a0e4396f0e1cc5bcfdca246269121f",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "stephanadls/state-dependent-gui",
"max_forks_repo_path": "examples/GUIgeneric/GUIFeaturesPart5.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "stephanadls/state-dependent-gui",
"max_issues_repo_path": "examples/GUIgeneric/GUIFeaturesPart5.agda",
"max_line_length": 115,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "stephanadls/state-dependent-gui",
"max_stars_repo_path": "examples/GUIgeneric/GUIFeaturesPart5.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-31T17:20:59.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-07-31T15:37:39.000Z",
"num_tokens": 1383,
"size": 4846
} |
{-# OPTIONS --safe --cubical #-}
module Relation.Binary.Bool where
open import Prelude
-- record TotalOrder {e} (E : Type e) : Type e where
-- field
-- _≤?_ : E → E → Bool
-- _≤_ : E → E → Type
| {
"alphanum_fraction": 0.572815534,
"avg_line_length": 17.1666666667,
"ext": "agda",
"hexsha": "5464e1f13d1da8cfdd1df6056f28349fa0bd8176",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z",
"max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/agda-playground",
"max_forks_repo_path": "Relation/Binary/Bool.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "oisdk/agda-playground",
"max_issues_repo_path": "Relation/Binary/Bool.agda",
"max_line_length": 52,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/agda-playground",
"max_stars_repo_path": "Relation/Binary/Bool.agda",
"max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z",
"num_tokens": 68,
"size": 206
} |
{-# OPTIONS --safe #-}
open import Definition.Typed.EqualityRelation
module Definition.LogicalRelation.Properties.Escape {{eqrel : EqRelSet}} where
open EqRelSet {{...}}
open import Definition.Untyped
open import Definition.Typed
open import Definition.Typed.Weakening
open import Definition.Typed.Properties
open import Definition.LogicalRelation
open import Definition.LogicalRelation.Properties.Reflexivity
open import Tools.Product
import Tools.PropositionalEquality as PE
import Data.Fin as Fin
import Data.Nat as Nat
-- Reducible types are well-formed.
escape : ∀ {l Γ A r} → Γ ⊩⟨ l ⟩ A ^ r → Γ ⊢ A ^ r
escape (Uᵣ′ _ _ _ _ _ PE.refl [[ ⊢A , ⊢B , D ]]) = ⊢A
escape (ℕᵣ [[ ⊢A , ⊢B , D ]]) = ⊢A
escape (Emptyᵣ [[ ⊢A , ⊢B , D ]]) = ⊢A
escape (ne′ K [[ ⊢A , ⊢B , D ]] neK K≡K) = ⊢A
escape (Πᵣ′ rF lF lG _ _ F G [[ ⊢A , ⊢B , D ]] ⊢F ⊢G A≡A [F] [G] G-ext) = ⊢A
escape (∃ᵣ′ F G [[ ⊢A , ⊢B , D ]] ⊢F ⊢G A≡A [F] [G] G-ext) = ⊢A
escape {ι ¹} (emb X A) = escape A
escape {∞} (emb X A) = escape A
-- Reducible type equality respect the equality relation.
escapeEq : ∀ {l Γ A B r} → ([A] : Γ ⊩⟨ l ⟩ A ^ r)
→ Γ ⊩⟨ l ⟩ A ≡ B ^ r / [A]
→ Γ ⊢ A ≅ B ^ r
escapeEq (Uᵣ′ _ _ _ ⁰ _ PE.refl [[ ⊢A , ⊢B , D ]]) D′ = ≅-red D D′ Uₙ Uₙ (≅-univ (≅-U⁰refl (wf ⊢A)))
escapeEq (Uᵣ′ _ _ _ ¹ _ PE.refl [[ ⊢A , ⊢B , D ]]) D′ = ≅-red D D′ Uₙ Uₙ (≅-U¹refl (wf ⊢A))
escapeEq (ℕᵣ [[ ⊢A , ⊢B , D ]]) D′ = ≅-red D D′ ℕₙ ℕₙ (≅-univ (≅ₜ-ℕrefl (wf ⊢A)))
escapeEq (Emptyᵣ [[ ⊢A , ⊢B , D ]]) D′ = ≅-red D D′ Emptyₙ Emptyₙ (≅-univ ((≅ₜ-Emptyrefl (wf ⊢A))))
escapeEq (ne′ K D neK K≡K) (ne₌ M D′ neM K≡M) =
≅-red (red D) (red D′) (ne neK) (ne neM) (~-to-≅ K≡M)
escapeEq (Πᵣ′ rF lF lG _ _ F G D ⊢F ⊢G A≡A [F] [G] G-ext)
(Π₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) =
≅-red (red D) D′ Πₙ Πₙ A≡B
escapeEq (∃ᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext)
(∃₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) =
≅-red (red D) D′ ∃ₙ ∃ₙ A≡B
escapeEq {ι ¹} (emb X A) A≡B = escapeEq A A≡B
escapeEq {∞} (emb X A) A≡B = escapeEq A A≡B
-- Reducible terms are well-formed.
escapeTerm : ∀ {l Γ A t r} → ([A] : Γ ⊩⟨ l ⟩ A ^ r)
→ Γ ⊩⟨ l ⟩ t ∷ A ^ r / [A]
→ Γ ⊢ t ∷ A ^ r
escapeTerm (Uᵣ′ _ _ _ _ l< PE.refl D) (Uₜ A [[ ⊢t , ⊢u , d ]] typeA A≡A [A]) = conv ⊢t (sym (subset* (red D)))
escapeTerm (ℕᵣ D) (ℕₜ n [[ ⊢t , ⊢u , d ]] t≡t prop) =
conv ⊢t (sym (subset* (red D)))
escapeTerm (Emptyᵣ D) (Emptyₜ (ne ⊢t)) =
conv ⊢t (sym (subset* (red D)))
escapeTerm {r = [ ! , l ]} (ne′ K D neK K≡K) (neₜ k [[ ⊢t , ⊢u , d ]] nf) =
conv ⊢t (sym (subset* (red D)))
escapeTerm {r = [ % , l ]} (ne′ K D neK K≡K) (neₜ d) = d
escapeTerm {r = [ ! , l ] } (Πᵣ′ rF lF lG _ _ F G D ⊢F ⊢G A≡A [F] [G] G-ext)
(f , [[ ⊢t , ⊢u , d ]] , funcF , f≡f , [f] , [f]₁) =
conv ⊢t (sym (subset* (red D)))
escapeTerm {r = [ % , l ]} (Πᵣ′ rF lF lG _ _ F G D ⊢F ⊢G A≡A [F] [G] G-ext) ⊢t = conv ⊢t (sym (subset* (red D)))
escapeTerm (∃ᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) ⊢t = conv ⊢t (sym (subset* (red D)))
escapeTerm {ι ¹} (emb X A) t = escapeTerm A t
escapeTerm {∞} (emb X A) t = escapeTerm A t
-- Reducible term equality respect the equality relation.
escapeTermEq : ∀ {l Γ A t u r} → ([A] : Γ ⊩⟨ l ⟩ A ^ r)
→ Γ ⊩⟨ l ⟩ t ≡ u ∷ A ^ r / [A]
→ Γ ⊢ t ≅ u ∷ A ^ r
escapeTermEq (Uᵣ′ _ _ _ _ l< PE.refl D) (Uₜ₌ (Uₜ A d typeA A≡A [t]) (Uₜ B d′ typeB B≡B [u]) A≡B [A≡B]) = ≅ₜ-red (red D) (redₜ d) (redₜ d′) Uₙ (typeWhnf typeA) (typeWhnf typeB) A≡B
escapeTermEq (ℕᵣ D) (ℕₜ₌ k k′ d d′ k≡k′ prop) =
let natK , natK′ = split prop
in ≅ₜ-red (red D) (redₜ d) (redₜ d′) ℕₙ
(naturalWhnf natK) (naturalWhnf natK′) k≡k′
escapeTermEq (Emptyᵣ D) (Emptyₜ₌ (ne ⊢t ⊢u)) =
~-to-≅ₜ (~-irrelevance ((conv ⊢t (sym (subset* (red D))))) ((conv ⊢u (sym (subset* (red D))))))
escapeTermEq {r = [ ! , l ]} (ne′ K D neK K≡K)
(neₜ₌ k m d d′ (neNfₜ₌ neT neU t≡u)) =
≅ₜ-red (red D) (redₜ d) (redₜ d′) (ne neK) (ne neT) (ne neU)
(~-to-≅ₜ t≡u)
escapeTermEq {r = [ % , l ]} (ne′ K D neK K≡K)
(neₜ₌ d d′) = ~-to-≅ₜ (~-irrelevance d d′)
escapeTermEq {r = [ ! , l ]} (Πᵣ′ rF lF lG _ _ F G D ⊢F ⊢G A≡A [F] [G] G-ext)
(Πₜ₌ f g d d′ funcF funcG f≡g [f] [g] [f≡g]) =
≅ₜ-red (red D) (redₜ d) (redₜ d′) Πₙ (functionWhnf funcF) (functionWhnf funcG) f≡g
escapeTermEq {r = [ % , l ] } (Πᵣ′ rF lF lG _ _ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (⊢t , ⊢u) = ~-to-≅ₜ (~-irrelevance ((conv ⊢t (sym (subset* (red D))))) ((conv ⊢u (sym (subset* (red D))))))
escapeTermEq (∃ᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (⊢t , ⊢u) = ~-to-≅ₜ (~-irrelevance ((conv ⊢t (sym (subset* (red D))))) ((conv ⊢u (sym (subset* (red D))))))
escapeTermEq {ι ¹} (emb X A) t≡u = escapeTermEq A t≡u
escapeTermEq {∞} (emb X A) t≡u = escapeTermEq A t≡u
escapeEqRefl : ∀ {l Γ A r}
→ ([A] : Γ ⊩⟨ l ⟩ A ^ r)
→ Γ ⊢ A ≅ A ^ r
escapeEqRefl [A] = escapeEq [A] (reflEq [A])
escapeEqReflTerm : ∀ {l Γ A t r}
→ ([A] : Γ ⊩⟨ l ⟩ A ^ r)
→ ([t] : Γ ⊩⟨ l ⟩ t ∷ A ^ r / [A])
→ Γ ⊢ t ≅ t ∷ A ^ r
escapeEqReflTerm [A] [t] = escapeTermEq [A] (reflEqTerm [A] [t])
| {
"alphanum_fraction": 0.5047114252,
"avg_line_length": 48.0566037736,
"ext": "agda",
"hexsha": "46ffbd31999fdb9df7462c389f4d985615b16040",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-02-15T19:42:19.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-01-26T14:55:51.000Z",
"max_forks_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "CoqHott/logrel-mltt",
"max_forks_repo_path": "Definition/LogicalRelation/Properties/Escape.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "CoqHott/logrel-mltt",
"max_issues_repo_path": "Definition/LogicalRelation/Properties/Escape.agda",
"max_line_length": 186,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "CoqHott/logrel-mltt",
"max_stars_repo_path": "Definition/LogicalRelation/Properties/Escape.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-17T16:13:53.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-06-21T08:39:01.000Z",
"num_tokens": 2572,
"size": 5094
} |
{-# OPTIONS --without-K --safe #-}
-- We do not parameterize this module since we do not have access to _+_ or _*_
-- for the fields that we want (real numbers)
module FLA.Algebra.Structures where
open import Level using (Level) renaming (suc to lsuc)
open import Data.Sum using (_⊎_)
open import Relation.Binary.PropositionalEquality using (_≡_; _≢_)
private
variable
ℓ : Level
A : Set ℓ
record Field (A : Set ℓ) : Set ℓ where
infixl 6 _+_
infixl 7 _*_
infixl 9 -_
infixl 10 _⁻¹
field
_+_ : A → A → A
_*_ : A → A → A
0ᶠ : A
1ᶠ : A
-_ : A → A -- + inverse
_⁻¹ : A → A -- * inverse
+-assoc : (a b c : A) → a + (b + c) ≡ (a + b) + c
+-comm : (a b : A) → a + b ≡ b + a
+0ᶠ : (a : A) → a + 0ᶠ ≡ a
+-inv : (a : A) → - a + a ≡ 0ᶠ
*-assoc : (a b c : A) → a * (b * c) ≡ (a * b) * c
*-comm : (a b : A) → a * b ≡ b * a
*1ᶠ : (a : A) → a * 1ᶠ ≡ a
*-inv : (a : A) → (a ≢ 0ᶠ) → a ⁻¹ * a ≡ 1ᶠ
*-distr-+ : (a b c : A) → a * (b + c) ≡ a * b + a * c
record TotalOrder (A : Set ℓ) : Set (lsuc ℓ) where
infixl 5 _≤_
field
_≤_ : A → A → Set ℓ
total : (x y : A) → x ≤ y ⊎ y ≤ x
trans : (x y z : A) → x ≤ y → y ≤ z → x ≤ z
anti-sym : (x y : A) → x ≤ y → y ≤ x → x ≡ y
record TotalOrderField (A : Set ℓ) : Set (lsuc ℓ) where
field
⦃ F ⦄ : Field A
⦃ TO ⦄ : TotalOrder A
open Field F public
open TotalOrder TO public
field
x≤y→z+x≤z+y : (x y z : A) → x ≤ y → z + x ≤ z + y
0≤x→0≤y→0≤x*y : (x y : A) → 0ᶠ ≤ x → 0ᶠ ≤ y → 0ᶠ ≤ x * y
-- record CompleteOrderedField (A : Set ℓ) : Set (lsuc ℓ) where
-- field
-- ⦃ TOF ⦄ : TotalOrderField A
-- open LinearlyOrderedField LinOrdField
--
-- UpperBound : Data.Set.NonEmpty A → Data.Set
-- Supremum : (∀ (v : UpperBound(A)) → ∃ [u ∈ UpperBound(A)] [u ≤ v])
-- completeness : (S : Data.Set.NonEmpty A)
-- → (ub: ∃ [y ∈ A] (λ x ∈ S → x ≤ y))
-- → Supremum A
-- completeness : every non-empty subset of F, bounded above, has a
-- supremum in F. If A is a non-empty subset of R, and if A has an upper
-- bound, then A has a least upper bound u, such that for every upper
-- bound v of A, u ≤ v.
-- apparently completeness implies the archimedian principle.
{-
If we want the reals, we need a few things
Linearly ordered set on F, ∀ x, y, z ∈ F
Totality : x ≤ y or y ≤ x
Transitivity : if x ≤ y and y ≤ z then x ≤ z
Anti-symmetry : if x ≤ y and y ≤ x, then x ≡ y
Linearly ordered field (F, +, *, ≤) if
x ≤ y then z + x ≤ z + y
0 ≤ x and 0 ≤ y then 0 ≤ x*y
Complete ordered field (F, +, *, ≤) if
(F, +, *, ≤) is a linearly ordered field
Completeness : every non-empty subset of F, bounded above, has a supremum in F
Archimedian property:
(F, +, *, ≤) is a complete ordered field
r, s ∈ F. r > 0 ∃ n ∈ ℕ. s < r + ... + r (n times)
Roughly speaking, it is the property of having no infinitely large or
infinitely small elements
Axiom of Archimedies is a formulation of this property for ordered fields:
∀ ε ∈ F. ε > 0 → ∃ n ∈ ℕ . 1/n < ε
Cauchy sequences representation of the reals and the Dedekind representation
of the reals are both Archimedian completely ordered fields and hence
isomorphic to the reals. Note there is a proof that all Archimedian complete
ordered fields are isomorphic.
References:
[1]: https://www.cs.swan.ac.uk/~csetzer/articlesFromOthers/chiMing/chiMingChuangExtractionOfProgramsForExactRealNumberComputation.pdf
[2]: https://en.wikipedia.org/wiki/Axiomatic_theory_of_real_numbers
-}
| {
"alphanum_fraction": 0.5690179806,
"avg_line_length": 29.631147541,
"ext": "agda",
"hexsha": "62dd8324bda485f96c91435f009653effcd0813c",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2021-09-07T19:55:59.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-04-12T20:34:17.000Z",
"max_forks_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "turion/functional-linear-algebra",
"max_forks_repo_path": "src/FLA/Algebra/Structures.agda",
"max_issues_count": 6,
"max_issues_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898",
"max_issues_repo_issues_event_max_datetime": "2022-01-07T05:27:53.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-09-01T01:42:12.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "turion/functional-linear-algebra",
"max_issues_repo_path": "src/FLA/Algebra/Structures.agda",
"max_line_length": 133,
"max_stars_count": 21,
"max_stars_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "turion/functional-linear-algebra",
"max_stars_repo_path": "src/FLA/Algebra/Structures.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-07T05:28:00.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-09-22T20:49:34.000Z",
"num_tokens": 1370,
"size": 3615
} |
{-# OPTIONS --safe #-}
module Cubical.Categories.Constructions.FullSubcategory where
-- Full subcategory (not necessarily injective on objects)
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Categories.Category
open import Cubical.Categories.Functor renaming (𝟙⟨_⟩ to funcId)
private
variable
ℓC ℓC' ℓD ℓD' ℓE ℓE' ℓP ℓQ ℓR : Level
module _ (C : Category ℓC ℓC') (P : Category.ob C → Type ℓP) where
private
module C = Category C
open Category
open Functor
FullSubcategory : Category (ℓ-max ℓC ℓP) ℓC'
ob FullSubcategory = Σ[ x ∈ C.ob ] P x
Hom[_,_] FullSubcategory (x , p) (y , q) = C.Hom[ x , y ]
id FullSubcategory = C.id
_⋆_ FullSubcategory = C._⋆_
⋆IdL FullSubcategory = C.⋆IdL
⋆IdR FullSubcategory = C.⋆IdR
⋆Assoc FullSubcategory = C.⋆Assoc
isSetHom FullSubcategory = C.isSetHom
FullInclusion : Functor FullSubcategory C
F-ob FullInclusion = fst
F-hom FullInclusion = idfun _
F-id FullInclusion = refl
F-seq FullInclusion f g = refl
module _ (C : Category ℓC ℓC')
(D : Category ℓD ℓD') (Q : Category.ob D → Type ℓQ) where
private
module C = Category C
module D = Category D
open Category
open Functor
ToFullSubcategory : (F : Functor C D) → ((c : C.ob) → Q (F-ob F c)) → Functor C (FullSubcategory D Q)
F-ob (ToFullSubcategory F f) c = F-ob F c , f c
F-hom (ToFullSubcategory F f) = F-hom F
F-id (ToFullSubcategory F f) = F-id F
F-seq (ToFullSubcategory F f) = F-seq F
module _ (C : Category ℓC ℓC') (P : Category.ob C → Type ℓP)
(D : Category ℓD ℓD') (Q : Category.ob D → Type ℓQ) where
private
module C = Category C
module D = Category D
open Category
open Functor
MapFullSubcategory : (F : Functor C D) → ((c : C.ob) → P c → Q (F-ob F c))
→ Functor (FullSubcategory C P) (FullSubcategory D Q)
MapFullSubcategory F f = ToFullSubcategory (FullSubcategory C P) D Q
(funcComp F (FullInclusion C P) )
λ (c , p) → f c p
module _ (C : Category ℓC ℓC') (P : Category.ob C → Type ℓP) where
private
module C = Category C
open Category
open Functor
MapFullSubcategory-id :
MapFullSubcategory C P C P (funcId C) (λ c p → p) ≡ funcId (FullSubcategory C P)
MapFullSubcategory-id = Functor≡
(λ (c , p) → refl)
(λ γ → refl)
module _ (C : Category ℓC ℓC') (P : Category.ob C → Type ℓP)
(D : Category ℓD ℓD') (Q : Category.ob D → Type ℓQ)
(E : Category ℓE ℓE') (R : Category.ob E → Type ℓR) where
private
module C = Category C
module D = Category D
module E = Category E
open Category
open Functor
MapFullSubcategory-seq :
(F : Functor C D) → (f : (c : C.ob) → P c → Q (F-ob F c)) →
(G : Functor D E) → (g : (d : D.ob) → Q d → R (F-ob G d)) →
MapFullSubcategory C P E R (funcComp G F) (λ c p → g (F-ob F c) (f c p)) ≡
funcComp
(MapFullSubcategory D Q E R G g)
(MapFullSubcategory C P D Q F f)
MapFullSubcategory-seq F f G g = Functor≡
(λ (c , p) → refl)
(λ γ → refl)
| {
"alphanum_fraction": 0.6388432468,
"avg_line_length": 31.3711340206,
"ext": "agda",
"hexsha": "b9daf4ca5dc5a2e7ba3c119b58531175d6e3e73a",
"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/Categories/Constructions/FullSubcategory.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/Categories/Constructions/FullSubcategory.agda",
"max_line_length": 104,
"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/Categories/Constructions/FullSubcategory.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": 1102,
"size": 3043
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.HITs.ListedFiniteSet where
open import Cubical.HITs.ListedFiniteSet.Base public
open import Cubical.HITs.ListedFiniteSet.Properties public
| {
"alphanum_fraction": 0.8058252427,
"avg_line_length": 34.3333333333,
"ext": "agda",
"hexsha": "78c74ed26dd682884eaea46f03fd75d43db82bce",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dan-iel-lee/cubical",
"max_forks_repo_path": "Cubical/HITs/ListedFiniteSet.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "dan-iel-lee/cubical",
"max_issues_repo_path": "Cubical/HITs/ListedFiniteSet.agda",
"max_line_length": 58,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "dan-iel-lee/cubical",
"max_stars_repo_path": "Cubical/HITs/ListedFiniteSet.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 54,
"size": 206
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- This module is DEPRECATED.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Algebra.FunctionProperties.Consequences.Core
{a} {A : Set a} where
{-# WARNING_ON_IMPORT
"Algebra.FunctionProperties.Consequences.Core was deprecated in v1.3.
Use Algebra.Consequences.Base instead."
#-}
open import Algebra.Consequences.Base public
| {
"alphanum_fraction": 0.5337301587,
"avg_line_length": 28,
"ext": "agda",
"hexsha": "fe7df6f7707b0da24c9ea6ea1a99ea8604fdbcbc",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DreamLinuxer/popl21-artifact",
"max_forks_repo_path": "agda-stdlib/src/Algebra/FunctionProperties/Consequences/Core.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DreamLinuxer/popl21-artifact",
"max_issues_repo_path": "agda-stdlib/src/Algebra/FunctionProperties/Consequences/Core.agda",
"max_line_length": 72,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DreamLinuxer/popl21-artifact",
"max_stars_repo_path": "agda-stdlib/src/Algebra/FunctionProperties/Consequences/Core.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": 86,
"size": 504
} |
module OldO where
open import Data.Product
open import Function renaming (_∘_ to _○_)
open import Circle
------------------------------------------------------------------------------
-- Abstract interpretation:
-- natural numbers with paths equating all even numbers in one
-- connected component and all odd numbers in another connected
-- component
-- module with 0,1,2,3,4 ... this is the concrete domain
data N : Set where
Zero : N
One : N
Two : N
Three : N
Four : N
recN : (C : Set) → C → C → C → C → C → N → C
recN C c0 c1 c2 c3 c4 Zero = c0
recN C c0 c1 c2 c3 c4 One = c1
recN C c0 c1 c2 c3 c4 Two = c2
recN C c0 c1 c2 c3 c4 Three = c3
recN C c0 c1 c2 c3 c4 Four = c4
indN : (C : N → Set) → C Zero → C One → C Two → C Three → C Four → (n : N) → C n
indN C c0 c1 c2 c3 c4 Zero = c0
indN C c0 c1 c2 c3 c4 One = c1
indN C c0 c1 c2 c3 c4 Two = c2
indN C c0 c1 c2 c3 c4 Three = c3
indN C c0 c1 c2 c3 c4 Four = c4
-- module for the abstract domain {even, odd} except that we don't define it
-- this way: we simply add paths between the even elements and paths between
-- the odd elements
module Parity where
private
data N* : Set where
Zero* : N*
One* : N*
Two* : N*
Three* : N*
Four* : N*
NA : Set
NA = N*
zero : NA
zero = Zero*
one : NA
one = One*
two : NA
two = Two*
three : NA
three = Three*
four : NA
four = Four*
postulate
even02 : Zero* ≡ Two*
even04 : Zero* ≡ Four*
odd13 : One* ≡ Three*
recNA : (C : Set) → (c0 c1 c2 c3 c4 : C) →
(ceven02 : c0 ≡ c2) → (ceven04 : c0 ≡ c4) → (codd13 : c1 ≡ c3) →
NA → C
recNA C c0 c1 c2 c3 c4 _ _ _ Zero* = c0
recNA C c0 c1 c2 c3 c4 _ _ _ One* = c1
recNA C c0 c1 c2 c3 c4 _ _ _ Two* = c2
recNA C c0 c1 c2 c3 c4 _ _ _ Three* = c3
recNA C c0 c1 c2 c3 c4 _ _ _ Four* = c4
postulate
αrecNA02 : (C : Set) → (c0 c1 c2 c3 c4 : C) →
(ceven02 : c0 ≡ c2) → (ceven04 : c0 ≡ c4) → (codd13 : c1 ≡ c3) →
ap (recNA C c0 c1 c2 c3 c4 ceven02 ceven04 codd13) even02 ≡ ceven02
αrecNA04 : (C : Set) → (c0 c1 c2 c3 c4 : C) →
(ceven02 : c0 ≡ c2) → (ceven04 : c0 ≡ c4) → (codd13 : c1 ≡ c3) →
ap (recNA C c0 c1 c2 c3 c4 ceven02 ceven04 codd13) even04 ≡ ceven04
αrecNA13 : (C : Set) → (c0 c1 c2 c3 c4 : C) →
(ceven02 : c0 ≡ c2) → (ceven04 : c0 ≡ c4) → (codd13 : c1 ≡ c3) →
ap (recNA C c0 c1 c2 c3 c4 ceven02 ceven04 codd13) odd13 ≡ codd13
indNA : (C : NA → Set) →
(c0 : C Zero*) →
(c1 : C One*) →
(c2 : C Two*) →
(c3 : C Three*) →
(c4 : C Four*) →
(ceven02 : transport C even02 c0 ≡ c2) →
(ceven04 : transport C even04 c0 ≡ c4) →
(codd13 : transport C odd13 c1 ≡ c3) →
(n : NA) → C n
indNA C c0 c1 c2 c3 c4 ceven02 ceven04 codd13 Zero* = c0
indNA C c0 c1 c2 c3 c4 ceven02 ceven04 codd13 One* = c1
indNA C c0 c1 c2 c3 c4 ceven02 ceven04 codd13 Two* = c2
indNA C c0 c1 c2 c3 c4 ceven02 ceven04 codd13 Three* = c3
indNA C c0 c1 c2 c3 c4 ceven02 ceven04 codd13 Four* = c4
open Parity
-- Now we define functions back and forth
abs : N → NA
abs = recN NA zero one two three four
con : NA → N
con = recNA N Zero One Zero One Zero (refl Zero) (refl Zero) (refl One)
conEven02 : ap con even02 ≡ refl Zero
conEven02 = αrecNA02 N Zero One Zero One Zero (refl Zero) (refl Zero) (refl One)
conEven04 : ap con even04 ≡ refl Zero
conEven04 = αrecNA04 N Zero One Zero One Zero (refl Zero) (refl Zero) (refl One)
conOdd13 : ap con odd13 ≡ refl One
conOdd13 = αrecNA13 N Zero One Zero One Zero (refl Zero) (refl Zero) (refl One)
-- Compose both ways
absconeven02 : ap (abs ○ con) even02 ≡ refl zero
absconeven02 =
ap (abs ○ con) even02
≡⟨ {!!} ⟩
ap abs (ap con even02)
≡⟨ {!!} ⟩
ap abs (refl Zero)
≡⟨ {!!} ⟩
refl zero ∎
absconeven04 : ap (abs ○ con) even04 ≡ refl zero
absconeven04 =
ap (abs ○ con) even04
≡⟨ {!!} ⟩
ap abs (ap con even04)
≡⟨ {!!} ⟩
ap abs (refl Zero)
≡⟨ {!!} ⟩
refl zero ∎
absconodd13 : ap (abs ○ con) odd13 ≡ refl one
absconodd13 =
ap (abs ○ con) odd13
≡⟨ {!!} ⟩
ap abs (ap con odd13)
≡⟨ {!!} ⟩
ap abs (refl One)
≡⟨ {!!} ⟩
refl one ∎
αeven02 : transport (λ x → (abs ○ con) x ≡ x) even02 (refl zero) ≡ even02
αeven02 =
transport (λ x → (abs ○ con) x ≡ x) even02 (refl zero)
≡⟨ {!!} ⟩
! (ap (abs ○ con) even02) ∘ refl zero ∘ ap id even02
≡⟨ {!!} ⟩
! (ap (abs ○ con) even02) ∘ refl zero ∘ even02
≡⟨ {!!} ⟩
! (ap (abs ○ con) even02) ∘ even02
≡⟨ {!!} ⟩
refl zero ∘ even02
≡⟨ {!!} ⟩
even02 ∎
αeven04 : transport (λ x → (abs ○ con) x ≡ x) even04 (refl zero) ≡ even04
αeven04 =
transport (λ x → (abs ○ con) x ≡ x) even04 (refl zero)
≡⟨ {!!} ⟩
even04 ∎
αodd13 : transport (λ x → (abs ○ con) x ≡ x) odd13 (refl one) ≡ odd13
αodd13 =
transport (λ x → (abs ○ con) x ≡ x) odd13 (refl one)
≡⟨ {!!} ⟩
odd13 ∎
-- Galois connections...
αN : con ○ abs ○ con ○ abs ∼ con ○ abs
αN = indN (λ x → (con ○ abs ○ con ○ abs) x ≡ (con ○ abs) x)
(refl Zero) (refl One) (refl Zero) (refl One) (refl Zero)
αNA : abs ○ con ∼ id
αNA = indNA (λ x → (abs ○ con) x ≡ x)
(refl zero) (refl one) even02 odd13 even04
αeven02 αeven04 αodd13
-- Computations on N and NA can be related
-- Concrete computation
incN : N → N
incN Zero = One
incN One = Two
incN Two = Three
incN Three = Four
incN Four = Zero
addN : N → N → N
addN Zero b = b
addN a Zero = a
addN One One = Two
addN One Two = Three
addN One Three = Four
addN One Four = Zero
addN Two One = Three
addN Two Two = Four
addN Two Three = Zero
addN Two Four = One
addN Three One = Four
addN Three Two = Zero
addN Three Three = One
addN Three Four = Two
addN Four One = Zero
addN Four Two = One
addN Four Three = Two
addN Four Four = Three
-- we can apply an operation in the abstract domain and report the
-- approximate result
absF : (N → N) → (NA → NA)
absF f = abs ○ f ○ con
approx : (N → N) → (N → N)
approx f n = con ((absF f) (abs n))
test0 : approx incN Zero ≡ One
test0 = refl One
test1 : approx incN One ≡ Zero
test1 = refl Zero
test2 : approx incN Two ≡ One
test2 = refl One
test3 : approx incN Three ≡ Zero
test3 = refl Zero
test4 : approx incN Four ≡ One
test4 = refl One
------------------------------------------------------------------------------
| {
"alphanum_fraction": 0.5499241275,
"avg_line_length": 25.7421875,
"ext": "agda",
"hexsha": "5bf86f72270e0b4ce0e4452bf8fb7fb9b3cce589",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z",
"max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "JacquesCarette/pi-dual",
"max_forks_repo_path": "OBT/OldO.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "JacquesCarette/pi-dual",
"max_issues_repo_path": "OBT/OldO.agda",
"max_line_length": 81,
"max_stars_count": 14,
"max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "JacquesCarette/pi-dual",
"max_stars_repo_path": "OBT/OldO.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": 2621,
"size": 6590
} |
{-# OPTIONS --cubical --safe #-}
module Data.Finite where
open import Prelude
open import Data.Fin
𝒞 : Type a → Type a
𝒞 A = ∃ n × ∥ A ≃ Fin n ∥
ℂ : Type _
ℂ = Σ[ T ⦂ Type ] × 𝒞 T
| {
"alphanum_fraction": 0.5815217391,
"avg_line_length": 14.1538461538,
"ext": "agda",
"hexsha": "acd42cd5c7f0e5b290860f2d9e35ef98a69b25e3",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z",
"max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/agda-playground",
"max_forks_repo_path": "Data/Finite.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "oisdk/agda-playground",
"max_issues_repo_path": "Data/Finite.agda",
"max_line_length": 32,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/agda-playground",
"max_stars_repo_path": "Data/Finite.agda",
"max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z",
"num_tokens": 76,
"size": 184
} |
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2020, 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
open import LibraBFT.Concrete.System.Parameters
open import LibraBFT.Impl.Consensus.BlockStorage.BlockStore
open import LibraBFT.ImplShared.Base.Types
open import LibraBFT.ImplShared.Consensus.Types
open import LibraBFT.ImplShared.Util.Crypto
open import Optics.All
open import Util.ByteString
open import Util.PKCS
open import Util.Prelude
open import Yasm.Base
open import Yasm.System ℓ-RoundManager ℓ-VSFP ConcSysParms
-- This module contains the machinery we use for tracking hash collisions for the hash function
-- postulated in LibraBFT.ImplShared.Util.Crypto. (Note that, although we call it sha256 to remind
-- ourselves that this *represents* a real hash function, in fact it is just postulated and could
-- represent any hash function.) We prove our correctness conditions modulo hash collisions of this
-- function, which is used to derive IDs for Blocks. Therefore, how we model and reason about such
-- collisions is critical to the validity of our proofs.
--
-- A common approach is to simply assume (e.g., postulate or state as an axiom) that the function is
-- injective. While this is a reasonable pragmatic approach, it does raise an important issue.
-- Because practical hash functions have unbounded domains and finite codomains, they are not
-- injective. Therefore, assuming that the function represented by the postulated one is injective
-- amounts to making an unsatisfiable assumption, from which anything can be proved (false implies
-- anything). For this reason, it is not sufficient to show that the desired property holds unless
-- a hash collision *exists*. Instead, we must construct evidence of a *specific* hash collision
-- (i.e., two values and evidence that their hashes are the same but the values themselves are
-- different). Such evidence is captured by the type NonInjective-≡ sha256. Below we elaborate on
-- some subtleties and tradeoffs with what we prove in which contexts.
--
-- First, when we are dealing with *abstract* Records (as in the Abstract and Concrete modules), it
-- is trivial to construct an injectivity failure of Block IDs, simply by constructing two different
-- abstract Blocks that have the same ID. In that context, it is important that we prove our
-- correctness conditions modulo injectivity failures between Blocks that are actually represented
-- in the specific ReachableSystemState about which we're reasoning (because that allows the
-- injectivity failure of IDs of the *abstract* Blocks to be related back to concrete blocks whose
-- IDs are derived using the hash function).
--
-- In contrast, it is far from trivial to construct a specific collision for the *postulated*
-- sha256-cr function. It would be possible to prove that *some* collision *exists* by using a
-- pigeonhole principle counting argument. In principle, one could then construct a specific
-- collision by generating 2 ^ 256 + 1 distinct Records (in case the postulated hash function is
-- assumed to produce 256-bit hashes), and asking for each pair of them whether they hash to the
-- same value. We could eliminate the possibility that none of these pairs provides a collision
-- using the counting argument.
--
-- One could not do this "accidentally" (as could potentially occur with Abstract records), and
-- furthermore, by examining all proofs that use meta-no-collision, it is not difficult to see that
-- the specific collisions are all produced from Records introduced by the proof obligations (i.e.,
-- Records that are in the ReachableSystemState under consideration). Therefore, we do not consider
-- it necessary to explicitly associate any collisions for the postulated hash function with the
-- ReachableSystemState.
--
-- Having received feedback from some people who were uncomfortable with this argument, we have put
-- some effort into explicitly tying each collision to data "in the system" in the
-- ReachableSystemState in question. Our exploration convinces us that it's possible, but
-- reinforces our view that it is not worthwhile; we elaborate on this in comments below.
--
-- Our current position is to keep for illustrative purposes our work so far on explicitly tying
-- some hash collisions to particular Records in the system for some cases, but to continue to
-- simply construct the evidence of the collision in other cases. The two approaches can coexist
-- because proofs can "bail out" when finding a hash collision between Records the proof is
-- considering by invoking either of the postulated functions below (meta-no-collision-in-sys and
-- meta-no-collsion). Both state that there is no collision, so providing evidence of a specific
-- collision is sufficient to bail out of the proof of a condition that might not hold in case of a
-- collision. The first requires the specific elements contributing to the collision to be
-- precisely located within the current ReachableSystemState, while the second requires only
-- evidence of the collision's existence, without specific information about where its elements came
-- from. Below we explain our initial approach for meta-no-collision-in-sys, overview some examples
-- demonstrating the additional proof burden it creates, and also discuss what would be needed to
-- complete this effort, if it were deemed worthwhile.
module LibraBFT.ImplShared.Util.HashCollisions
(iiah : SystemInitAndHandlers ℓ-RoundManager ConcSysParms)
where
open WithInitAndHandlers iiah
-- By placing the constructs below within a module that takes a ReachableSystemState as a module
-- parameter, we ensure that a proof that wants to "bail out" due to a hash collision must specify
-- a ReachableSystemState and show that the specific collision is between elements represented in
-- that state.
module PerReachableState {st} (r : ReachableSystemState st) where
-- The following datatypes are used in the definition of HashCollisionFound below to enumerate
-- the ways in which hash collisions that would undermine correctness can arise in the given
-- state st. Note that we do not need to capture all ways in which a ByteString might be
-- represented, only those for which our proofs require injectivity properties. Our initial
-- work requires capturing hash collisions only for Block IDs.
data _∈Block_ : BSL → Block → Set where
inB : ∀ {b} → blockData-bsl (b ^∙ bBlockData) ∈Block b
open _∈Block_
data _∈ProposalMsg_ (bsl : BSL) (pm : ProposalMsg) : Set where
inPM : bsl ∈Block (pm ^∙ pmProposal) → bsl ∈ProposalMsg pm
open _∈ProposalMsg_
data _∈nm (bsl : BSL) : Set where
inP : ∀ {sndr pm} → (sndr , P pm) ∈ msgPool st → bsl ∈ProposalMsg pm → bsl ∈nm
open _∈nm
-- We could refine this further (∈BlockTree, ∈btIdToBlock), but I don't think we need to.
data _∈BS_ (bsl : BSL) (bs : BlockStore) : Set where
inBS : ∀ {eb} → (getBlock (hashBSL bsl) bs ≡ just eb) → bsl ∈Block (eb ^∙ ebBlock) → bsl ∈BS bs
data _∈RM_ (bsl : BSL) (rm : RoundManager) : Set where
inRM : bsl ∈BS (rm ^∙ lBlockStore) → bsl ∈RM rm
-- So far, HashCollisionFound includes two constructors, one (msgRmHC) for a collision between a
-- ByteString represented in a message that has been sent (∈nm) and one represented in the
-- RoundManager of some peer. The other (msgmsgHC) is unused so far, but would be needed if we
-- were to take this work further; it is for cases in which there is a collision between two
-- elements in messages that have been sent.
data HashCollisionFound : Set where
msgRmHC : ∀ {bs1 bs2 pid}
→ bs1 ∈nm
→ initialised st pid ≡ initd
→ bs2 ∈RM (peerStates st pid)
→ hashBSL bs1 ≡ hashBSL bs2
→ bs1 ≢ bs2
→ HashCollisionFound
msgmsgHC : ∀ {bs1 bs2}
→ bs1 ∈nm
→ bs2 ∈nm
→ hashBSL bs1 ≡ hashBSL bs2
→ bs1 ≢ bs2
→ HashCollisionFound
-- By postulating the lack of existence of HashCollisionFound, we enable any proof to "bail out"
-- only if it can construct a *specific* hash collision that is "in the system" represented by
-- the specific ReachableSystemState, according to the specific notions thereof captured by the
-- constructors for this type.
postulate -- Valid assumption: there are no hash collisions among values found in the system
meta-no-collision-in-sys : ¬ HashCollisionFound
-- Discussion
--
-- As noted above, we have applied this approach to some proofs but not others. In particular,
-- there are still a number of proofs that use meta-no-collision (below), which does not require
-- the constructed collision to be explicitly placed in context of the ReachableSystemState.
--
-- We have used meta-no-collision-in-sys for the case of a peer handling a proposal. The
-- proposal contains a Block which has an ID, which is supposed to be the hash of some parts of
-- the proposal. This condition is verified when the proposal message is first received (see
-- verifyWellFormed in LibraBFT.Impl.Consensus.ConsensusTypes.Block), and the knowledge that it
-- verified correctly is needed all the way down the stack when the receiving peer inserts the
-- block into its BlockTree. If an ExecutedBlock is found in the BlockTree associated with the
-- ID of the new Block, then the algorithm assumes it's the same Block (because both the new
-- Block and the one inserted previously in the BlockTree have been verified as hashing to the
-- same ID). If there were a collision (i.e., these two Blocks that hash to the same ID
-- actually have different bits that are hashed to derive the ID), then incorrect behaviour
-- would be possible.
--
-- To use meta-no-collision-in-sys, we need to construct a value of HashCollisionFound in
-- context of the ReachableSystemState under consideration (but see note below). This requires
-- carrying the fact that the hash of the newly proposed Block matches its ID from the
-- above-mentioned verification all the way down the stack, where it is needed to invoke an
-- assumption about the lack of collisions between the new Block and one previously stored when
-- proving the Contract for insertBlockESpec. (This is the NOHC1 argument given to the blocks≈
-- field insertBlockESpec.ContrackOk.) Then, each Contract up the stack must receive a similar
-- argument enabling it to invoke the Contract of the next function down the stack. See, for
-- example, the ebBlock≈ field of executeAndInsertBlockESpec.ContractOk, the voteAttemptCorrect
-- field of processProposalMsgMSpec.Contract (and others in the same file), and similarly for
-- handleProposalSpec.Contract. Then this argument must be provided by higher level properties
-- that wish to invoke the lower-level contracts. Because the higher-level properties are in
-- context of a specific ReachableSystemState, they can construct a proof of the absence of the
-- potential collision by using meta-no-collision-in-sys for that ReachableSystemState.
--
-- As can be seen, connecting a potential hash collision to a specific ReachableSystemState is a
-- fair amount of work, which complicates proofs. As explained above, we do not think it is
-- worthwhile to continue this effort, just to show that we can. One issue we would want to
-- address if taking this work further would be to *ensure* that the ReachableSystemState
-- for which a potential collision is considered is the same one about which we're proving the
-- given property. This already is the case in our proofs, but our conditions don't *ensure*
-- that it is because, in principle, when calling nohc to use meta-no-collision-in-sys to
-- eliminate an assumed collision, we could provide *any* ReachableSystemState. To require it
-- to be the same ReachableSystemState, we would need to explicitly express for each relevant
-- property that it holds unless there is collision in *that state*. So, for example, the
-- conclusion of the IncreasingRoundObligation property would have to become something like the
-- following (where pre is the state about which IncreasingRoundObligation is proved):
--
-- HashCollisionFound pre
-- ⊎ v' ^∙ vRound < v ^∙ vRound
-- ⊎ VoteForRound∈ pk (v ^∙ vRound) (v ^∙ vEpoch) (v ^∙ vProposedId) (msgPool pre)
--
-- The first disjunct is not currently necessary because there is no requirement to place the
-- HashCollisionFound in the same ReachableSystemState. We would then need to propagate those
-- disjuncts from one proof to another, making even more work and complicating proofs and
-- properties further. Importantly, doing so would provide no additional benefit over what we
-- have done already, exactly because it is not practical to construct a collision for the
-- postulated hash function anyway (and we could not do so "accidentally"): giving ourselves the
-- freedom to associate it with a diffferent ReachabeSystemState does not change that. This
-- underlines the point that requiring the collision to be associated with a
-- ReachableSystemState creates quite a bit of work, and provides little benefit.
postulate -- valid assumption. Note that this does *not* say that no collisions *exist*; it
-- says a proof cannot escape its obligations unless it can provide specfic evidence
-- of a collision; as explained above, doing so other than from Records presented to
-- the proof (because they are in the system state under consideration) is
-- impractical and impossible to do "accidentally"
meta-no-collision : ¬ (NonInjective-≡ sha256)
sameSig⇒sameVoteDataNoCol : ∀ {v1 v2 : Vote} {pk}
→ WithVerSig pk v1
→ WithVerSig pk v2
→ v1 ^∙ vSignature ≡ v2 ^∙ vSignature
→ v2 ^∙ vVoteData ≡ v1 ^∙ vVoteData
sameSig⇒sameVoteDataNoCol {v1} {v2} wvs1 wvs2 refl
with sameSig⇒sameVoteData {v1} {v2} wvs1 wvs2 refl
...| inj₁ hb = ⊥-elim (meta-no-collision hb)
...| inj₂ x = x
| {
"alphanum_fraction": 0.7310141752,
"avg_line_length": 65.4843049327,
"ext": "agda",
"hexsha": "025a42afbcee4724a3c2e36081bd9bcd4ef83819",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_forks_repo_licenses": [
"UPL-1.0"
],
"max_forks_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_forks_repo_path": "src/LibraBFT/ImplShared/Util/HashCollisions.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"UPL-1.0"
],
"max_issues_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_issues_repo_path": "src/LibraBFT/ImplShared/Util/HashCollisions.agda",
"max_line_length": 111,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_stars_repo_licenses": [
"UPL-1.0"
],
"max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_stars_repo_path": "src/LibraBFT/ImplShared/Util/HashCollisions.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3485,
"size": 14603
} |
-- Andreas, 2020-03-27, issue #4534
-- Better error message for quote.
open import Agda.Builtin.Reflection
_ : Name
_ = quote Set
-- Can only quote defined names, but encountered Set
-- when checking that the expression quote Set has type Name
| {
"alphanum_fraction": 0.7449392713,
"avg_line_length": 22.4545454545,
"ext": "agda",
"hexsha": "016e824aa2da70f73ecdac4fd722ccd6c6c30c07",
"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/Issue4534a.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/Issue4534a.agda",
"max_line_length": 60,
"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/Issue4534a.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": 63,
"size": 247
} |
open import Formalization.PredicateLogic.Signature
module Formalization.PredicateLogic.Classical.SequentCalculus (𝔏 : Signature) where
open Signature(𝔏)
open import Data.List
open import Data.List.Functions using () renaming (singleton to · ; _++_ to _∪_)
open import Data.List.Relation.Permutation
open import Formalization.PredicateLogic.Syntax(𝔏)
open import Formalization.PredicateLogic.Syntax.Substitution(𝔏)
open import Functional as Fn
import Lvl
open import Numeral.Finite
open import Numeral.Natural
open import Type
private variable ℓ : Lvl.Level
private variable n vars : ℕ
_∪·_ : ∀{T : Type{ℓ}} → List(T) → T → List(T)
_∪·_ = Fn.swap(_⊰_)
infixl 1000 _∪·_
module _ where
private variable Γ Γ₁ Γ₂ Γ₃ Δ Δ₁ Δ₂ Δ₃ : List(Formula(vars))
private variable φ φ₁ φ₂ ψ A B C : Formula(vars)
private variable p : Prop(n)
data _⇒_ : List(Formula(vars)) → List(Formula(vars)) → Type{Lvl.𝐒(ℓₚ Lvl.⊔ ℓₒ)} where
axiom : ((· φ) ⇒ (· φ))
weakenₗ : (Γ ⇒ Δ) → ((Γ ∪· A) ⇒ Δ)
permuteₗ : .(Γ₁ permutes Γ₂) → (Γ₁ ⇒ Δ) → (Γ₂ ⇒ Δ)
contractₗ : ((Γ ∪· A ∪· A) ⇒ Δ) → ((Γ ∪· A) ⇒ Δ)
⊥ₗ : (Γ ∪· ⊥) ⇒ ∅
∧ₗₗ : ((Γ ∪· A) ⇒ Δ) → ((Γ ∪· (A ∧ B)) ⇒ Δ)
∧ₗᵣ : ((Γ ∪· B) ⇒ Δ) → ((Γ ∪· (A ∧ B)) ⇒ Δ)
∨ₗ : ((Γ ∪· A) ⇒ Δ) → ((Γ ∪· B) ⇒ Δ) → ((Γ ∪· (A ∨ B)) ⇒ Δ)
⟶ₗ : (Γ ⇒ (Δ ∪· A)) → ((Γ ∪· B) ⇒ Δ) → ((Γ ∪· (A ⟶ B)) ⇒ Δ)
Ɐₗ : ∀{t} → ((Γ ∪· (substitute0 t A)) ⇒ Δ) → ((Γ ∪· (Ɐ A)) ⇒ Δ)
∃ₗ : ∀{v}{n} → ((Γ ∪· (substituteN n (var v) A)) ⇒ Δ) → ((Γ ∪· (∃ A)) ⇒ Δ)
weakenᵣ : (Γ ⇒ Δ) → (Γ ⇒ (Δ ∪· A))
permuteᵣ : .(Δ₁ permutes Δ₂) → (Γ ⇒ Δ₁) → (Γ ⇒ Δ₂)
contractᵣ : (Γ ⇒ (Δ ∪· A ∪· A)) → (Γ ⇒ (Δ ∪· A))
⊤ᵣ : ∅ ⇒ (Δ ∪· ⊤)
∧ᵣ : (Γ ⇒ (Δ ∪· A)) → (Γ ⇒ (Δ ∪· B)) → (Γ ⇒ (Δ ∪· (A ∧ B)))
∨ᵣₗ : (Γ ⇒ (Δ ∪· A)) → (Γ ⇒ (Δ ∪· (A ∨ B)))
∨ᵣᵣ : (Γ ⇒ (Δ ∪· B)) → (Γ ⇒ (Δ ∪· (A ∨ B)))
⟶ᵣ : ((Γ ∪· A) ⇒ (Δ ∪· B)) → (Γ ⇒ (Δ ∪· (A ⟶ B)))
Ɐᵣ : ∀{v}{n} → (Γ ⇒ (Δ ∪· (substituteN n (var v) A))) → (Γ ⇒ (Δ ∪· (Ɐ A)))
∃ᵣ : ∀{t} → (Γ ⇒ (Δ ∪· (substitute0 t A))) → (Γ ⇒ (Δ ∪· (∃ A)))
| {
"alphanum_fraction": 0.4849531327,
"avg_line_length": 38.2452830189,
"ext": "agda",
"hexsha": "c89e068e2e91a2c44f9d59a7c75f0a418c11abb9",
"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/PredicateLogic/Classical/SequentCalculus.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/PredicateLogic/Classical/SequentCalculus.agda",
"max_line_length": 87,
"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/PredicateLogic/Classical/SequentCalculus.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": 1034,
"size": 2027
} |
module FreezingTest where
data _≡_ {A : Set} (x : A) : A → Set where
refl : x ≡ x
data ℕ : Set where
zero : ℕ
suc : (n : ℕ) → ℕ
force : let one : ℕ
one = _ -- this meta is not frozen after the end of let
in one ≡ suc zero
force = refl
| {
"alphanum_fraction": 0.5328467153,
"avg_line_length": 19.5714285714,
"ext": "agda",
"hexsha": "ec2e1813dae539999d23becf8b828000e30c84be",
"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/FreezingTest.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/FreezingTest.agda",
"max_line_length": 75,
"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/FreezingTest.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": 95,
"size": 274
} |
postulate
C : Set
anything : C
record I : Set where
constructor c
field
f : C
data Wrap : (j : I) → Set where
wrap : ∀ {j} → Wrap j
works1 : ∀ {j} → Wrap j → C
works1 {c ._} (wrap {j = c _}) with anything
... | z = z
| {
"alphanum_fraction": 0.5384615385,
"avg_line_length": 14.625,
"ext": "agda",
"hexsha": "ccacd41aa968d0d8b3f1f49cf553a99f196644dc",
"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/Issue1605b.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/Issue1605b.agda",
"max_line_length": 44,
"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/Issue1605b.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": 90,
"size": 234
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Some examples showing where the natural numbers and some related
-- operations and properties are defined, and how they can be used
------------------------------------------------------------------------
{-# OPTIONS --without-K #-}
module README.Data.Nat where
-- The natural numbers and various arithmetic operations are defined
-- in Data.Nat.
open import Data.Nat using (ℕ; _+_; _*_)
-- _*_ has precedence 7 over precedence 6 of _+_
-- precedence of both defined in module Agda.Builtin.Nat
ex₁ : ℕ
ex₁ = 1 + 3 * 4
-- Propositional equality and some related properties can be found
-- in Relation.Binary.PropositionalEquality.
open import Relation.Binary.PropositionalEquality using (_≡_; refl)
ex₂ : 3 + 5 ≡ 2 * 4
ex₂ = refl
-- Data.Nat.Properties contains a number of properties about natural
-- numbers.
open import Data.Nat.Properties using (*-comm; +-identityʳ)
ex₃ : ∀ m n → m * n ≡ n * m
ex₃ m n = *-comm m n
-- The module ≡-Reasoning in Relation.Binary.PropositionalEquality
-- provides some combinators for equational reasoning.
open Relation.Binary.PropositionalEquality using (cong; module ≡-Reasoning)
ex₄ : ∀ m n → m * (n + 0) ≡ n * m
ex₄ m n = begin
m * (n + 0) ≡⟨ cong (_*_ m) (+-identityʳ n) ⟩
m * n ≡⟨ *-comm m n ⟩
n * m ∎
where open ≡-Reasoning
-- The module SemiringSolver in Data.Nat.Solver contains a solver
-- for natural number equalities involving variables, constants, _+_
-- and _*_.
open import Data.Nat.Solver using (module +-*-Solver)
open +-*-Solver using (solve; _:*_; _:+_; con; _:=_)
ex₅ : ∀ m n → m * (n + 0) ≡ n * m
ex₅ = solve 2 (λ m n → m :* (n :+ con 0) := n :* m) refl
| {
"alphanum_fraction": 0.617830778,
"avg_line_length": 29.8474576271,
"ext": "agda",
"hexsha": "60dbf266bfb4312a9d67dd67d76d1055ab9239cc",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DreamLinuxer/popl21-artifact",
"max_forks_repo_path": "agda-stdlib/README/Data/Nat.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DreamLinuxer/popl21-artifact",
"max_issues_repo_path": "agda-stdlib/README/Data/Nat.agda",
"max_line_length": 75,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DreamLinuxer/popl21-artifact",
"max_stars_repo_path": "agda-stdlib/README/Data/Nat.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": 510,
"size": 1761
} |
module test.IntegerOverflow where
open import Type
open import Declarative
open import Builtin
open import Builtin.Constant.Type
open import Builtin.Constant.Term Ctx⋆ Kind * # _⊢⋆_ con size⋆
open import Agda.Builtin.Sigma
open import Data.Integer
open import Data.Nat
open import Data.Empty
-- zerepoch/zerepoch-core/test/data/integerOverflow.plc
-- This term is impossible as terms are intrinsically sized
-- completeting this definition requires an element of the empty type
{-
intOverflow : ∀{Γ} → Γ ⊢ con integer (size⋆ 1)
intOverflow = con (integer 1 (ℤ.pos 128) (-≤+ Σ., +≤+ (gen _ _ {!!})))
-}
| {
"alphanum_fraction": 0.7462932455,
"avg_line_length": 26.3913043478,
"ext": "agda",
"hexsha": "5c52651bac5cce9eb18e181dc672a8579fcb0e85",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-02-21T16:38:59.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-13T21:25:19.000Z",
"max_forks_repo_head_hexsha": "c8cf4619e6e496930c9092cf6d64493eff300177",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "Quantum-One-DLT/zerepoch",
"max_forks_repo_path": "zerepoch-metatheory/test/IntegerOverflow.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c8cf4619e6e496930c9092cf6d64493eff300177",
"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": "Quantum-One-DLT/zerepoch",
"max_issues_repo_path": "zerepoch-metatheory/test/IntegerOverflow.agda",
"max_line_length": 70,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "c8cf4619e6e496930c9092cf6d64493eff300177",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "Quantum-One-DLT/zerepoch",
"max_stars_repo_path": "zerepoch-metatheory/test/IntegerOverflow.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 184,
"size": 607
} |
---------------------------------------------------------------------
-- This file contains the definition of heterogenous equality and --
-- related facts. A lot of this code is old, and could be written --
-- better. This equality is mainly used for object equivalence. --
-- --
-- Some of it came from the paper: --
-- "Monads Need Not Be Endofunctors" by Altenkirch et al. --
-- --
-- See: http://www.cs.nott.ac.uk/~txa/publ/Relative_Monads.pdf --
---------------------------------------------------------------------
module Equality.Eq where
open import Level
open import Relation.Relation
open import Relation.Binary.PropositionalEquality public renaming (sym to prop-sym ; trans to prop-trans; refl to prop-refl)
data _≅_ {l : Level} {A : Set l} (a : A) : {A' : Set l} → A' → Set l where
refl : a ≅ a
postulate ext : ∀{i j}{A : Set i}{B B' : A → Set j}{f : ∀ a → B a}{g : ∀ a → B' a} →
(∀ a → f a ≅ g a) → f ≅ g
postulate prop-ext : ∀{i j}{A : Set i}{B : A → Set j}{f : ∀ a → B a}{g : ∀ a → B a} →
(∀ a → f a ≡ g a) → f ≡ g
≅-to-≡ : ∀{l : Level}{A : Set l}{a b : A} → a ≅ b → a ≡ b
≅-to-≡ refl = prop-refl
-- this could just be derived from ext
postulate iext : ∀{i j}{A : Set i}{B B' : A → Set j}{f : ∀ {a} → B a}{g : ∀{a} → B' a} →
(∀ a → f {a} ≅ g {a}) →
_≅_ {_}{ {a : A} → B a} f { {a : A} → B' a} g
sym : ∀{l : Level}{A : Set l }{a b : A} → a ≅ b → b ≅ a
sym refl = refl
trans : ∀{l : Level}{A : Set l}{a b c : A} → a ≅ b → b ≅ c → a ≅ c
trans refl refl = refl
isEqRel : ∀{l : Level}{A : Set l} → EqRel {A = A} (λ x y → x ≅ y)
isEqRel {l} {A} = record { parEqPf = record { symPf = sym; transPf = trans }; refPf = refl }
ir : ∀{l : Level}{A A' : Set l}{a : A}{a' : A'}{p q : a ≅ a'} → p ≅ q
ir {p = refl}{q = refl} = refl
eqApp : ∀{l l' : Level}{A : Set l}{B : Set l'}{f : A → B}{b c : A} → b ≅ c → (f b) ≅ (f c)
eqApp refl = refl
subst≅ : {l l' : Level}{A : Set l}{a b : A}{P : A → Set l'} → a ≅ b → P a → P b
subst≅ refl x = x
-- Cite from relative monads paper.
deqApp : ∀{l : Level}{A : Set l}{B : A → Set l}(f : ∀ a → B a){a a' : A}
→ a ≅ a' → f a ≅ f a'
deqApp f refl = refl
feqApp : ∀{l l' : Level}{A : Set l}{B : Set l'}{f f' : A → B}{b c : A} → f ≅ f' → b ≅ c → (f b) ≅ (f' c)
feqApp refl refl = refl
ifeqApp : ∀{i j}{A : Set i}{B : A → Set j}{f f' : {x : A} → B x}(a : A) → _≅_ {_}{ {a : A} → B a} f { {a : A} → B a} f' → f {a} ≅ f' {a}
ifeqApp a refl = refl
ieqApp : ∀{x y}{A : Set x}{B : A → Set y}(f : ∀ {a} → B a){a a' : A} → a ≅ a' → f {a} ≅ f {a'}
ieqApp f refl = refl
-- Cite from relative monads paper.
eqApp2 : ∀{i j k}{A : Set i}{B : A → Set j}{C : Set k}{a a' : A} → a ≅ a' → {b : B a}{b' : B a'} → b ≅ b' →
(f : (a : A) → B a → C) → f a b ≅ f a' b'
eqApp2 refl refl f = refl
eqApp3 : ∀{x y z w}{A : Set x}{B : A → Set y}{C : (a : A) → B a → Set z}{E : Set w}
(f : (a : A)(b : B a)(c : C a b) → E) →
{a a' : A} → a ≅ a' →
{b : B a}{b' : B a'} → b ≅ b' →
{c : C a b}{c' : C a' b'} → c ≅ c' →
f a b c ≅ f a' b' c'
eqApp3 f refl refl refl = refl
depfeqApp3a : ∀{l}{A : Set l}{B : Set (suc l)}{C : A → Set (suc l)}{D : Set (suc l)}
(f : (x : A)(y : B)(z : C x) → D) →
(f' : (x : A)(y : B)(z : C x) → D) →
f ≅ f' →
{a : A}{b : B} {c : C a} →
f a b c ≅ f' a b c
depfeqApp3a {_}{A}{B}{C} f f' p {a}{b}{c} =
feqApp {f = f a b} {f' = f' a b} (feqApp {f = f a} {f' = f' a} (eqApp {f = λ h → h a} p) refl) refl
depfeqApp3b : ∀{l}{A : Set l}{B : A → Set (suc l)}{C : A → Set (suc l)}{D : Set (suc l)}
(f : (x : A)(y : B x)(z : C x) → D) →
(f' : (x : A)(y : B x)(z : C x) → D) →
f ≅ f' →
{a : A}{b : B a} {c : C a} →
f a b c ≅ f' a b c
depfeqApp3b {_}{A}{B}{C} f f' p {a}{b}{c} =
feqApp {f = f a b} {f' = f' a b} (feqApp {f = f a} {f' = f' a} (eqApp {f = λ h → h a} p) refl) refl
depfeqApp3c : ∀{l}{A : Set l}{B : A → A → Set (suc l)}{C : A → Set (suc l)}{D : Set (suc l)}
(f : (x : A)(y : B x x)(z : C x) → D) →
(f' : (x : A)(y : B x x)(z : C x) → D) →
f ≅ f' →
{a : A}{b : B a a} {c : C a} →
f a b c ≅ f' a b c
depfeqApp3c {_}{A}{B}{C} f f' p {a}{b}{c} =
feqApp {f = f a b} {f' = f' a b} (feqApp {f = f a} {f' = f' a} (eqApp {f = λ h → h a} p) refl) refl
depfeqApp3d : ∀{l}{A : Set l}{B : A → A → Set (suc l)}{C : A → A → Set (suc l)}{D : Set (suc l)}
(f : (x : A)(y : B x x)(z : C x x) → D) →
(f' : (x : A)(y : B x x)(z : C x x) → D) →
f ≅ f' →
{a : A}{b : B a a} {c : C a a} →
f a b c ≅ f' a b c
depfeqApp3d {_}{A}{B}{C} f f' p {a}{b}{c} =
feqApp {f = f a b} {f' = f' a b} (feqApp {f = f a} {f' = f' a} (eqApp {f = λ h → h a} p) refl) refl
depfeqApp3e : ∀{l}{A : Set l}{B : Set (suc l)}{C : A → A → Set (suc l)}{D : Set (suc l)}
(f : (x : A)(y : B)(z : C x x) → D) →
(f' : (x : A)(y : B)(z : C x x) → D) →
f ≅ f' →
{a : A}{b : B} {c : C a a} →
f a b c ≅ f' a b c
depfeqApp3e {_}{A}{B}{C} f f' p {a}{b}{c} =
feqApp {f = f a b} {f' = f' a b} (feqApp {f = f a} {f' = f' a} (eqApp {f = λ h → h a} p) refl) refl
depfeqAppa : ∀{l l' l'' l'''}{A : Set l}{B : Set l'}{C : A → B → Set l''}{D : A → B → Set l'''}{a : A}
(f : (x : A)(y : B)(z : C x y) → D x y) →
(f' : (x : A)(y : B)(z : C x y) → D x y) →
f ≅ f' →
f a ≅ f' a
depfeqAppa {l}{l'}{l''}{l'''}{A}{B}{C}{D}{a} f f' p = eqApp {f = λ h → h a} p
depfeqApp2a : ∀{l l' l'' l'''}{A : Set l}{B : Set l'}{C : A → B → Set l''}{D : A → B → Set l'''}{a : A}
(f : (y : B)(z : C a y) → D a y) →
(f' : (y : B)(z : C a y) → D a y) →
f ≅ f' →
{b : B} {c : C a b} →
f b c ≅ f' b c
depfeqApp2a f f' p {b} {c} = feqApp {f = f b} {f' = f' b} (eqApp {f = λ h → h b} p) refl
depfeqApp3f : ∀{l l' l'' l'''}{A : Set l}{B : Set l'}{C : A → B → Set l''}{D : A → B → Set l'''}
(f : (x : A)(y : B)(z : C x y) → D x y) →
(f' : (x : A)(y : B)(z : C x y) → D x y) →
f ≅ f' →
{a : A}{b : B} {c : C a b} →
f a b c ≅ f' a b c
depfeqApp3f {_}{_}{_}{_}{A}{B}{C}{D} f f' p {a}{b}{c} =
depfeqApp2a {A = A} {B = B}{C = λ o1 o2 → C o1 o2}
{D = λ o1₁ o2₁ → D o1₁ o2₁} (f a) (f' a) (eqApp {f = λ h → h a} p) {b} {c}
depfeqApp3g : ∀{l l' l'' l'''}{A : Set l}{B : Set l'}{C : A → B → Set l''}{D D' : A → B → Set l'''}
(f : (x : A)(y : B)(z : C x y) → D x y) →
(f' : (x : A)(y : B)(z : C x y) → D' x y) →
D ≅ D' →
f ≅ f' →
{a : A}{b : B} {c : C a b} →
f a b c ≅ f' a b c
depfeqApp3g {_}{_}{_}{_}{A}{B}{C}{D} f f' refl p {a}{b}{c} =
depfeqApp2a {A = A} {B = B} {C = λ o1₁ o2₁ → C o1₁ o2₁} {D = λ o1 o2 → D o1 o2} (f a) (f' a) (eqApp {f = λ h → h a} p) {b} {c}
idepfeqApp2a : ∀{l l' l'' l''' l''''}{A : Set l}{B : Set l'}{C : Set l''}{D : A → B → C → Set l'''}{E : A → B → C → Set l''''}{a : A}
(f : {x : B}{y : C}(z : D a x y) → E a x y) →
(f' : {x : B}{y : C}(z : D a x y) → E a x y) →
(∀{x y} → f {x}{y} ≅ f' {x}{y}) →
{b : B}{c : C}{m : D a b c} →
f {b}{c} m ≅ f' {b} {c} m
idepfeqApp2a {l}{l'}{l''}{l'''}{l''''}{A}{B}{C}{D}{E}{a} f f' p {b}{c}{m} =
feqApp {f = f {b} {c}} {f' = f' {b} {c}} {m} {m} (ext (λ h → feqApp {f = f {b} {c}} {f' = f' {b} {c}} {h} {h} (p {b}{c}) refl)) refl
depfeqApp2b : ∀{l l' l''}{A : Set l}{D : A → A → Set l'}{E E' : A → A → Set l''}
(f : (x : A)(y : A)(z : A) → (m1 : D y z) → (m2 : D x y) → E x z) →
{f' : (x : A)(y : A)(z : A) → (m1 : D y z) → (m2 : D x y) → E' x z} →
E ≅ E' →
f ≅ f' →
{a a' b b' c c' : A}{m1 : D b c}{m2 : D a b}{m1' : D b' c'}{m2' : D a' b'} →
a ≅ a' → b ≅ b' → c ≅ c' → m1 ≅ m1' → m2 ≅ m2' →
f a b c m1 m2 ≅ f' a' b' c' m1' m2'
depfeqApp2b {_}{_}{_}{A}{D}{E} f refl refl {a = a}{b = b}{c = c}{m1 = m1}{m2 = m2} refl refl refl refl refl =
eqApp {f = f a b c m1} {m2}{m2} refl
feqApp3 : ∀{l}{A : Set l}{B : A → Set (suc l)}{C : A → Set (suc l)}{D : Set (suc l)}
(f : (x : A)(y : B x)(z : C x) → D) →
(f' : (x : A)(y : B x)(z : C x) → D) →
f ≅ f' →
{a : A}{b : B a} {c : C a} →
f a b c ≅ f' a b c
feqApp3 {_}{A}{B}{C} f f' p {a}{b}{c} =
feqApp {f = f a b} {f' = f' a b} (feqApp {f = f a} {f' = f' a} (eqApp {f = λ h → h a} p) refl) refl
coerce : ∀{l}{A B : Set l} → A ≅ B → A → B
coerce refl a = a
p : ∀{m}{A B : Set m}{a : A}{b : B} → (q : B ≅ A) → _≅_ {m} {A} a {A} (coerce q b) → _≅_ {m} {A} a {B} b
p refl refl = refl
eqApp4 : ∀{x y z v w}{A : Set x}{B : A → Set y}{C : (a : A) → B a → Set z}{D : (a : A)(b : B a) → C a b → Set v}{E : Set w}
(f : (a : A)(b : B a)(c : C a b) → D a b c → E) →
{a a' : A} → a ≅ a' →
{b : B a}{b' : B a'} → b ≅ b' →
{c : C a b}{c' : C a' b'} → c ≅ c' →
{d : D a b c}{d' : D a' b' c'} → d ≅ d' →
f a b c d ≅ f a' b' c' d'
eqApp4 f refl refl refl refl = refl
funCong : ∀{l m : Level}{A : Set l}{B : Set m}{f g : A → B}{a : A}{b : B}
→ (p : f ≅ g) → (q : f a ≅ b)
→ (w : g a ≅ b) → q ≅ w
funCong refl q w = ir
funCong2 : ∀{l : Level}{A B B' X Y : Set l}{f : ∀{X Y} → A → B}{g : ∀{X Y} → A → B'}{a : A}{b : B}
→ (r : B ≅ B') → (p : (λ {X}{Y} → f {X}{Y}) ≅ (λ {X}{Y} → g {X}{Y})) → (q : f {X}{Y} a ≅ b)
→ (w : g {X}{Y} a ≅ b) → q ≅ w
funCong2 refl refl q w = ir
fixtypes : ∀{x}{A A' : Set x}{a a' : A}{a'' a''' : A'}{p : a ≅ a'}{q : a'' ≅ a'''} → a ≅ a'' → a' ≅ a''' → p ≅ q
fixtypes refl refl = ir
| {
"alphanum_fraction": 0.3654328418,
"avg_line_length": 45.5205479452,
"ext": "agda",
"hexsha": "1116f2f83b517e3f93e6ad0cdd3a427dec0b476d",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "heades/AUGL",
"max_forks_repo_path": "setoid-cats/Equality/Eq.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "heades/AUGL",
"max_issues_repo_path": "setoid-cats/Equality/Eq.agda",
"max_line_length": 151,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "heades/AUGL",
"max_stars_repo_path": "setoid-cats/Equality/Eq.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 4785,
"size": 9969
} |
open import Oscar.Prelude
open import Oscar.Class.Transitivity
module Oscar.Class.Congruity where
module _ where
module _
{ℓ} (_∼_ : ∀ {𝔬} {𝔒 : Ø 𝔬} → 𝔒 → 𝔒 → Ø ℓ)
𝔵 𝔶
where
𝓬ongruity = ∀ {𝔛 : Ø 𝔵} {𝔜 : Ø 𝔶} {x₁ x₂} (f : 𝔛 → 𝔜) → x₁ ∼ x₂ → f x₁ ∼ f x₂
record 𝓒ongruity : Ø ℓ ∙̂ ↑̂ (𝔵 ∙̂ 𝔶) where
field congruity : 𝓬ongruity
open 𝓒ongruity ⦃ … ⦄ public
module _
{ℓ} (_∼_ : ∀ {𝔬} {𝔒 : Ø 𝔬} → 𝔒 → 𝔒 → Ø ℓ)
{𝔵 𝔶} (𝔛 : Ø 𝔵) (𝔜 : Ø 𝔶)
where
𝓬ongruity' = ∀ {x₁ x₂} (f : 𝔛 → 𝔜) → x₁ ∼ x₂ → f x₁ ∼ f x₂
record 𝓒ongruity' : Ø ℓ ∙̂ ↑̂ (𝔵 ∙̂ 𝔶) where
field congruity' : 𝓬ongruity'
open 𝓒ongruity' ⦃ … ⦄ public
module _
{ℓ} {𝔬} (_∼_ : ∀ {𝔒 : Ø 𝔬} → 𝔒 → 𝔒 → Ø ℓ)
(𝔛 𝔜 : Ø 𝔬)
where
𝓬ongruity'' = ∀ {x₁ x₂} (f : 𝔛 → 𝔜) → x₁ ∼ x₂ → f x₁ ∼ f x₂
record 𝓒ongruity'' : Ø ℓ ∙̂ 𝔬 where
field congruity'' : 𝓬ongruity''
open 𝓒ongruity'' ⦃ … ⦄ public
-- a functional replacement of 𝓒ongruity₂ (but note the additional requirement of 𝓣ransitivity)
congruity2 : ∀ {ℓ} {_∼_ : ∀ {x} {X : Ø x} → X → X → Ø ℓ}
{𝔵 𝔶 𝔷}
⦃ _ : 𝓒ongruity _∼_ 𝔵 (𝔶 ∙̂ 𝔷) ⦄
⦃ _ : 𝓒ongruity _∼_ (𝔶 ∙̂ 𝔷) 𝔷 ⦄
⦃ _ : 𝓒ongruity _∼_ 𝔶 (𝔵 ∙̂ 𝔷) ⦄
⦃ _ : 𝓒ongruity _∼_ (𝔵 ∙̂ 𝔷) 𝔷 ⦄
⦃ _ : ∀ {x} {X : Ø x} → Transitivity.class (_∼_ {X = X}) ⦄
→ ∀ {𝔛 : Ø 𝔵} {𝔜 : Ø 𝔶} {ℨ : Ø 𝔷} {x₁ x₂} {y₁ y₂} (f : 𝔛 → 𝔜 → ℨ) → x₁ ∼ x₂ → y₁ ∼ y₂ → f x₁ y₁ ∼ f x₂ y₂
congruity2 {𝔛 = 𝔛}{𝔜}{ℨ}{x₁}{x₂}{y₁}{y₂} f x₁∼x₂ y₁∼y₂ =
let fx1=fx2 = congruity f x₁∼x₂ in
let g2 = λ (fx : 𝔜 → ℨ) → fx y₂ in
let fx1y2=fx2y2 = congruity g2 fx1=fx2 in
let e = flip f in
let ey1=ey2 = congruity e y₁∼y₂ in
let h1 = λ (ex : 𝔛 → ℨ) → ex x₁ in
let fx1y1=fx1y2 = congruity h1 ey1=ey2 in
transitivity fx1y1=fx1y2 fx1y2=fx2y2
module _ where
record 𝓒ongruity₂
{ℓ} (_∼_ : ∀ {x} {X : Ø x} → X → X → Ø ℓ)
𝔵 𝔶 𝔷
: Ø ℓ ∙̂ ↑̂ (𝔵 ∙̂ 𝔶 ∙̂ 𝔷) where
field congruity₂ : ∀ {𝔛 : Ø 𝔵} {𝔜 : Ø 𝔶} {ℨ : Ø 𝔷} {x₁ x₂} {y₁ y₂} (f : 𝔛 → 𝔜 → ℨ) → x₁ ∼ x₂ → y₁ ∼ y₂ → f x₁ y₁ ∼ f x₂ y₂
open 𝓒ongruity₂ ⦃ … ⦄ public
module _ where
module _
𝔬 𝔭
{ℓ} (_∼̇_ : ∀ {⋆ : Ø 𝔬} {⋆̇ : ⋆ → Ø 𝔭} → ((𝓞 : ⋆) → ⋆̇ 𝓞) → ((𝓞 : ⋆) → ⋆̇ 𝓞) → Ø ℓ)
(let infix 4 _∼̇_ ; _∼̇_ = _∼̇_)
where
record 𝓒̇ongruity : Ø ↑̂ (𝔬 ∙̂ 𝔭) ∙̂ ℓ where
field ċongruity : ∀ {⋆ : Ø 𝔬} {⋆̇ : ⋆ → Ø 𝔭} {f₁ f₂ : (𝓞 : ⋆) → ⋆̇ 𝓞} (G : ∀ {𝓞 : ⋆} → ⋆̇ 𝓞 → ⋆̇ 𝓞) → f₁ ∼̇ f₂ → G ∘ f₁ ∼̇ G ∘ f₂
open 𝓒̇ongruity ⦃ … ⦄ public
| {
"alphanum_fraction": 0.4790983607,
"avg_line_length": 30.8860759494,
"ext": "agda",
"hexsha": "1313ba8b88ec1a88595204772b2e99aa89db2203",
"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/Class/Congruity.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/Class/Congruity.agda",
"max_line_length": 136,
"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/Class/Congruity.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1574,
"size": 2440
} |
module Issue478b where
record Ko (Q : Set) : Set₁ where
field
T : Set
foo : T
foo = Set
-- This previously said Set₁ !=< T r | {
"alphanum_fraction": 0.6086956522,
"avg_line_length": 12.5454545455,
"ext": "agda",
"hexsha": "3b07b12eee7e0811793531b56dc3144974e49218",
"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/Issue478b.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/Issue478b.agda",
"max_line_length": 36,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "test/fail/Issue478b.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": 47,
"size": 138
} |
{-# OPTIONS --safe --experimental-lossy-unification #-}
module Cubical.Algebra.GradedRing.DirectSumFun where
{-
This file give a graded ring construction in the case of the fun direct sum.
Because of the current proofs this is done only in the case where
- Idx is ℕ and for a monoid on it
- For the usual ∸ of the Nat library
The proof consists in :
- Defining a _prod_ operation on the structure
- Proving the underlying equivalence respect it
- Transporting the proof of RingStr
- Deducing an equivalence proof
-}
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Transport
open import Cubical.Foundations.HLevels
open import Cubical.Relation.Nullary
open import Cubical.Data.Empty as ⊥
open import Cubical.Data.Nat renaming (_+_ to _+ℕ_ ; _∸_ to _-ℕ_ )
open import Cubical.Data.Nat.Order
open import Cubical.Data.Sigma
open import Cubical.Data.Sum
open import Cubical.Algebra.Monoid
open import Cubical.Algebra.Group.Morphisms
open import Cubical.Algebra.AbGroup
open import Cubical.Algebra.DirectSum.Equiv-DSHIT-DSFun
open import Cubical.Algebra.DirectSum.DirectSumHIT.Base
open import Cubical.Algebra.DirectSum.DirectSumHIT.Properties
open import Cubical.Algebra.DirectSum.DirectSumFun.Base
open import Cubical.Algebra.AbGroup.Instances.NProd
open import Cubical.Algebra.AbGroup.Instances.DirectSumFun
open import Cubical.Algebra.Ring
open import Cubical.Algebra.GradedRing.Base
open import Cubical.Algebra.GradedRing.DirectSumHIT
open import Cubical.Algebra.CommRing
open import Cubical.HITs.PropositionalTruncation as PT
private variable
ℓ ℓ' : Level
open AbGroupStr
open AbGroupTheory
-----------------------------------------------------------------------------
-- Def, notation, lemma
module _
-- monoid
(_+n_ : ℕ → ℕ → ℕ) -- need to instantiate on +'
(isM : IsMonoid 0 _+n_)
(_+≡_ : (n m : ℕ) → n +n m ≡ n +ℕ m) -- needed for the behaviour under -ℕ
--
(G : ℕ → Type ℓ)
(Gstr : (n : ℕ) → AbGroupStr (G n))
where
sameFiber+ : {i n : ℕ} → i ≤ n → i +ℕ (n -ℕ i) ≡ n
sameFiber+ {zero} {zero} p = refl
sameFiber+ {zero} {suc n} p = refl
sameFiber+ {suc i} {zero} p = ⊥.rec (¬-<-zero p)
sameFiber+ {suc i} {suc n} p = cong suc (sameFiber+ (pred-≤-pred p))
sameFiber : {i n : ℕ} → (i ≤ n) → i +n (n -ℕ i) ≡ n
sameFiber {i} {n} p = (i +≡ (n -ℕ i)) ∙ sameFiber+ p
open SubstLemma ℕ G Gstr
open IsMonoid isM using ()
renaming
( ·Assoc to +nAssoc
; ·IdR to +nIdR
; ·IdL to +nIdL )
open AbGroupStr (snd (NProd-AbGroup G Gstr)) using ()
renaming
( 0g to 0Fun
; _+_ to _+Fun_
; is-set to isSetFun )
module _
(1⋆ : G 0)
(_⋆_ : {k l : ℕ} → G k → G l → G (k +n l))
(0-⋆ : {k l : ℕ} → (b : G l) → (0g (Gstr k)) ⋆ b ≡ 0g (Gstr (k +n l)))
(⋆-0 : {k l : ℕ} → (a : G k) → a ⋆ (0g (Gstr l)) ≡ 0g (Gstr (k +n l)))
(⋆Assoc : {k l m : ℕ} → (a : G k) → (b : G l) → (c : G m) →
_≡_ {A = Σ[ k ∈ ℕ ] G k} ((k +n (l +n m)) , (a ⋆ (b ⋆ c))) (((k +n l) +n m) , ((a ⋆ b) ⋆ c)))
(⋆IdR : {k : ℕ} → (a : G k) → _≡_ {A = Σ[ k ∈ ℕ ] G k} ( k +n 0 , a ⋆ 1⋆ ) (k , a))
(⋆IdL : {l : ℕ} → (b : G l) → _≡_ {A = Σ[ k ∈ ℕ ] G k} ( 0 +n l , 1⋆ ⋆ b ) (l , b))
(⋆DistR+ : {k l : ℕ} → (a : G k) → (b c : G l) →
a ⋆ ((Gstr l) ._+_ b c) ≡ Gstr (k +n l) ._+_ (a ⋆ b) (a ⋆ c))
(⋆DistL+ : {k l : ℕ} → (a b : G k) → (c : G l) →
((Gstr k) ._+_ a b) ⋆ c ≡ Gstr (k +n l) ._+_ (a ⋆ c) (b ⋆ c))
where
-----------------------------------------------------------------------------
-- Definition of 1
-- import for pres
open Equiv-Properties G Gstr using
( substG
; fun-trad
; fun-trad-eq
; fun-trad-neq
; ⊕HIT→Fun
; ⊕HIT→⊕Fun
; ⊕HIT→⊕Fun-pres+)
1Fun : (n : ℕ) → G n
1Fun zero = 1⋆
1Fun (suc n) = 0g (Gstr (suc n))
1⊕Fun : ⊕Fun G Gstr
1⊕Fun = 1Fun , ∣ 0 , helper ∣₁
where
helper : AlmostNullProof G Gstr 1Fun 0
helper zero r = ⊥.rec (¬-<-zero r)
helper (suc n) r = refl
⊕HIT→Fun-pres1 : (n : ℕ) → ⊕HIT→Fun (base 0 1⋆) n ≡ 1Fun n
⊕HIT→Fun-pres1 zero with discreteℕ 0 0
... | yes p = cong (λ X → subst G X 1⋆) (isSetℕ _ _ _ _) ∙ transportRefl _
... | no ¬p = ⊥.rec (¬p refl)
⊕HIT→Fun-pres1 (suc n) with discreteℕ (suc n) 0
... | yes p = ⊥.rec (snotz p)
... | no ¬p = refl
⊕HIT→⊕Fun-pres1 : ⊕HIT→⊕Fun (base 0 1⋆) ≡ 1⊕Fun
⊕HIT→⊕Fun-pres1 = ΣPathTransport→PathΣ _ _
((funExt (λ n → ⊕HIT→Fun-pres1 n)) , (squash₁ _ _))
-----------------------------------------------------------------------------
-- Definition of the ring product
sumFun : (i n : ℕ) → (i ≤ n) → (f g : (n : ℕ) → G n) → G n
sumFun zero n r f g = subst G (sameFiber r) ((f 0) ⋆ (g (n -ℕ 0)))
sumFun (ℕ.suc i) n r f g = Gstr n ._+_ (subst G (sameFiber r) ((f (suc i)) ⋆ (g (n -ℕ suc i))))
(sumFun i n (≤-trans ≤-sucℕ r) f g)
_prodFun_ : (f g : (n : ℕ) → G n) → (n : ℕ) → G n
_prodFun_ f g n = sumFun n n ≤-refl f g
-- Proof that it is an almost null sequence
prodAn : (f g : (n : ℕ) → G n) → AlmostNull G Gstr f → AlmostNull G Gstr g → AlmostNull G Gstr (f prodFun g)
prodAn f g (k , nf) (l , ng) = (k +ℕ l) , λ n pp → sumF0 n n pp ≤-refl
where
sumF0 : (i n : ℕ) → (pp : k +ℕ l < n) → (r : i ≤ n) → sumFun i n r f g ≡ 0g (Gstr n)
sumF0 zero n pp r = cong (subst G (sameFiber r))
(cong (λ X → f 0 ⋆ X) (ng (n -ℕ zero) (<-k+-trans pp)) ∙ ⋆-0 _) ∙ subst0g _
sumF0 (suc i) n pp r with splitℕ-≤ (suc i) k
... | inl x = cong₂ (Gstr n ._+_)
(cong (subst G (sameFiber r))
(cong (λ X → f (suc i) ⋆ X) (ng (n -ℕ suc i)
-- Goal : l < n - suc i
-- Proof : l = k + l - k < n - k < n - suc i
(subst (λ X → X < n -ℕ suc i) (∸+ l k)
(≤<-trans (≤-∸-≥ (k +ℕ l) (suc i) k x)
(<-∸-< (k +ℕ l) n (suc i) pp (≤<-trans x (<-+k-trans pp))))))
∙ ⋆-0 (f (suc i))))
(sumF0 i n pp (≤-trans ≤-sucℕ r))
∙ +IdR (Gstr n) _
∙ subst0g _
... | inr x = cong₂ (Gstr n ._+_)
(cong (subst G (sameFiber r))
(cong (λ X → X ⋆ g (n -ℕ (suc i))) (nf (suc i) x)
∙ 0-⋆ _))
(sumF0 i n pp (≤-trans ≤-sucℕ r))
∙ +IdR (Gstr n) _
∙ subst0g _
_prodF_ : ⊕Fun G Gstr → ⊕Fun G Gstr → ⊕Fun G Gstr
_prodF_(f , Anf) (g , Ang) = (f prodFun g) , helper Anf Ang
where
helper : AlmostNullP G Gstr f → AlmostNullP G Gstr g → AlmostNullP G Gstr (f prodFun g)
helper = PT.rec2 squash₁ (λ x y → ∣ (prodAn f g x y) ∣₁)
-----------------------------------------------------------------------------
-- Some Ring properties that are needed
-- lemma for 0 case
prodFunAnnihilL : (f : (n : ℕ) → G n) → 0Fun prodFun f ≡ 0Fun
prodFunAnnihilL f = funExt (λ n → sumF0 n n ≤-refl)
where
sumF0 : (i n : ℕ) → (r : i ≤ n) → sumFun i n r 0Fun f ≡ 0g (Gstr n)
sumF0 zero n r = cong (subst G (sameFiber r)) (0-⋆ _) ∙ subst0g _
sumF0 (suc i) n r = cong₂ (Gstr n ._+_)
(cong (subst G (sameFiber r)) (0-⋆ _))
(sumF0 i n (≤-trans ≤-sucℕ r))
∙ +IdR (Gstr n) _
∙ subst0g _
prodFunAnnihilR : (f : (n : ℕ) → (G n)) → f prodFun 0Fun ≡ 0Fun
prodFunAnnihilR f = funExt (λ n → sumF0 n n ≤-refl)
where
sumF0 : (i n : ℕ) → (r : i ≤ n) → sumFun i n r f 0Fun ≡ 0g (Gstr n)
sumF0 zero n r = cong (subst G (sameFiber r)) (⋆-0 _) ∙ subst0g _
sumF0 (suc i) n r = cong₂ (Gstr n ._+_)
(cong (subst G (sameFiber r)) (⋆-0 _))
(sumF0 i n (≤-trans ≤-sucℕ r))
∙ +IdR (Gstr n) _
∙ subst0g _
prodFunDistR : (f g h : (n : ℕ) → G n) → f prodFun (g +Fun h) ≡ (f prodFun g) +Fun (f prodFun h)
prodFunDistR f g h = funExt (λ n → sumFAssoc n n ≤-refl)
where
sumFAssoc : (i n : ℕ) → (r : i ≤ n) → sumFun i n r f (g +Fun h) ≡ (Gstr n) ._+_ (sumFun i n r f g) (sumFun i n r f h)
sumFAssoc zero n r = cong (subst G (sameFiber r)) (⋆DistR+ _ _ _)
∙ sym (subst+ _ _ _)
sumFAssoc (suc i) n r = cong₂ (Gstr n ._+_)
(cong (subst G (sameFiber r)) (⋆DistR+ _ _ _) ∙ sym (subst+ _ _ _))
(sumFAssoc i n (≤-trans ≤-sucℕ r))
∙ comm-4 ((G n) , (Gstr n)) _ _ _ _
prodFunDistL : (f g h : (n : ℕ) → G n) → (f +Fun g) prodFun h ≡ (f prodFun h) +Fun (g prodFun h)
prodFunDistL f g h = funExt (λ n → sumFAssoc n n ≤-refl)
where
sumFAssoc : (i n : ℕ) → (r : i ≤ n) → sumFun i n r (f +Fun g) h ≡ (Gstr n) ._+_ (sumFun i n r f h) (sumFun i n r g h)
sumFAssoc zero n r = cong (subst G (sameFiber r)) (⋆DistL+ _ _ _)
∙ sym (subst+ _ _ _)
sumFAssoc (suc i) n r = cong₂ (Gstr n ._+_)
(cong (subst G (sameFiber r)) (⋆DistL+ _ _ _) ∙ sym (subst+ _ _ _))
(sumFAssoc i n (≤-trans ≤-sucℕ r))
∙ comm-4 ((G n) , (Gstr n)) _ _ _ _
-----------------------------------------------------------------------------
-- Preserving the product
-- A substitution lemma
subst⋆ : {m n k l : ℕ} → (p : m ≡ n) → (q : k ≡ l) → (r : m +n k ≡ n +n l) →
(a : G m) → (b : G k) → subst G p a ⋆ subst G q b ≡ subst G r (a ⋆ b)
subst⋆ p q r a b = J (λ n p → subst G p a ⋆ subst G q b ≡ subst G (cong₂ _+n_ p q) (a ⋆ b))
(J (λ l q → subst G refl a ⋆ subst G q b ≡ subst G (cong₂ _+n_ refl q) (a ⋆ b))
(cong₂ _⋆_ (transportRefl _) (transportRefl _) ∙ sym (transportRefl _))
q)
p
∙ cong (λ X → subst G X (a ⋆ b)) (isSetℕ _ _ _ _)
-- Proving the base case
open GradedRing-⊕HIT-index (ℕ , (monoidstr 0 _+n_ isM)) G Gstr
open GradedRing-⊕HIT-⋆ 1⋆ _⋆_ 0-⋆ ⋆-0 ⋆Assoc ⋆IdR ⋆IdL ⋆DistR+ ⋆DistL+
sumFun≠ : (k : ℕ) → (a : G k) → (l : ℕ) → (b : G l) →
(i n : ℕ) → (r : i ≤ n) → (¬pp : k +n l ≡ n → ⊥) →
sumFun i n r (fun-trad k a) (fun-trad l b) ≡ 0g (Gstr n)
sumFun≠ k a l b zero n r ¬pp with discreteℕ k 0 | discreteℕ l n
... | yes p | yes q = ⊥.rec (¬pp ((k +≡ l) ∙ cong₂ _+ℕ_ p q) )
... | yes p | no ¬q = cong (subst G (sameFiber r)) (⋆-0 _) ∙ subst0g _
... | no ¬p | yes q = cong (subst G (sameFiber r)) (0-⋆ _) ∙ subst0g _
... | no ¬p | no ¬q = cong (subst G (sameFiber r)) (0-⋆ _) ∙ subst0g _
sumFun≠ k a l b (suc i) n r ¬pp with discreteℕ k (suc i) | discreteℕ l (n -ℕ (suc i))
... | yes p | yes q = ⊥.rec (¬pp (cong₂ _+n_ p q ∙ sameFiber r))
... | yes p | no ¬q = cong₂ (Gstr n ._+_)
(cong (subst G (sameFiber r)) (⋆-0 _))
(sumFun≠ k a l b i n (≤-trans ≤-sucℕ r) ¬pp)
∙ +IdR (Gstr n) _
∙ subst0g _
... | no ¬p | yes q = cong₂ (Gstr n ._+_)
(cong (subst G (sameFiber r)) (0-⋆ _))
(sumFun≠ k a l b i n (≤-trans ≤-sucℕ r) ¬pp)
∙ +IdR (Gstr n) _
∙ subst0g _
... | no ¬p | no ¬q = cong₂ (Gstr n ._+_)
(cong (subst G (sameFiber r)) (0-⋆ _))
(sumFun≠ k a l b i n (≤-trans ≤-sucℕ r) ¬pp)
∙ +IdR (Gstr n) _
∙ subst0g _
-- If k +n l ≡ n then, we unwrap the sum until we reach k.
-- Before it is 0, in k the value, then it is 0
sumFun< : (k : ℕ) → (a : G k) → (l : ℕ) → (b : G l) →
(i n : ℕ) → (r : i ≤ n) → (i < k) →
sumFun i n r (fun-trad k a) (fun-trad l b) ≡ 0g (Gstr n)
sumFun< k a l b zero n r pp with discreteℕ k 0
... | yes p = ⊥.rec (<→≢ pp (sym p))
... | no ¬p = cong (subst G (sameFiber r)) (0-⋆ _) ∙ subst0g _
sumFun< k a l b (suc i) n r pp with discreteℕ k (suc i)
... | yes p = ⊥.rec (<→≢ pp (sym p))
... | no ¬p = cong₂ (Gstr n ._+_)
(cong (subst G (sameFiber r)) (0-⋆ _))
(sumFun< k a l b i n (≤-trans ≤-sucℕ r) (<-trans ≤-refl pp))
∙ +IdR (Gstr n) _
∙ subst0g _
sumFun≤ : (k : ℕ) → (a : G k) → (l : ℕ) → (b : G l ) →
(i n : ℕ) → (r : i ≤ n) → (pp : k +n l ≡ n) → (k ≤ i) →
sumFun i n r (fun-trad k a) (fun-trad l b) ≡ subst G pp (a ⋆ b)
sumFun≤ k a l b zero n r pp rr with discreteℕ k 0 | discreteℕ l n
... | yes p | yes q = cong (subst G (sameFiber r)) (subst⋆ p q (pp ∙ sym (+nIdL _)) a b)
∙ sym (substComposite G _ _ _)
∙ cong (λ X → subst G X (a ⋆ b)) (isSetℕ _ _ _ _)
... | yes p | no ¬q = ⊥.rec (¬q (sym (+nIdL l) ∙ cong (λ X → X +n l) (sym p) ∙ pp))
... | no ¬p | yes q = ⊥.rec (¬p (≤0→≡0 rr))
... | no ¬p | no ¬q = ⊥.rec (¬p (≤0→≡0 rr))
sumFun≤ k a l b (suc i) n r pp rr with discreteℕ k (suc i) | discreteℕ l (n -ℕ suc i)
... | yes p | yes q = cong₂ (Gstr n ._+_)
(cong (subst G (sameFiber r))
(subst⋆ p q (pp ∙ sym (sameFiber r)) a b)
∙ sym (substComposite G _ _ _))
(sumFun< k a l b i n (≤-trans ≤-sucℕ r) (0 , (sym p)))
∙ +IdR (Gstr n) _
∙ cong (λ X → subst G X (a ⋆ b)) (isSetℕ _ _ _ _)
... | yes p | no ¬q = ⊥.rec (¬q (inj-m+ (sym ((suc i) +≡ l)
∙ cong (λ X → X +n l) (sym p)
∙ pp
∙ sym (sameFiber r)
∙ ((suc i) +≡ (n -ℕ suc i)))))
... | no ¬p | yes q = ⊥.rec (¬p (inj-+m (sym (k +≡ (n -ℕ suc i))
∙ cong (λ X → k +n X) (sym q)
∙ pp
∙ sym (sameFiber r)
∙ ((suc i) +≡ (n -ℕ suc i)))))
... | no ¬p | no ¬q = cong₂ (Gstr n ._+_)
(cong (subst G (sameFiber r)) (0-⋆ _) ∙ subst0g _)
(sumFun≤ k a l b i n (≤-trans ≤-sucℕ r) pp (≤-suc-≢ rr ¬p))
∙ +IdL (Gstr n) _
-- If k +n l ≢ n, then it is both zero
-- Otherwise, it coincide in (k,l)
sumFBase : (k : ℕ) → (a : G k) → (l : ℕ) → (b : G l) → (n : ℕ) →
fun-trad (k +n l) (a ⋆ b) n ≡ sumFun n n ≤-refl (fun-trad k a) (fun-trad l b)
sumFBase k a l b n with discreteℕ (k +n l) n
... | yes p = sym (sumFun≤ k a l b n n ≤-refl p (l , (+-comm l k ∙ sym (k +≡ l) ∙ p)))
... | no ¬p = sym (sumFun≠ k a l b n n ≤-refl ¬p)
-- Proof that ⊕HIT→⊕Fun preserve the cup product
⊕HIT→Fun-pres-prodFun : (x y : ⊕HIT ℕ G Gstr) → ⊕HIT→Fun (x prod y) ≡ ((⊕HIT→Fun x) prodFun (⊕HIT→Fun y))
⊕HIT→Fun-pres-prodFun = DS-Ind-Prop.f _ _ _ _
(λ x → isPropΠ (λ _ → isSetFun _ _))
(λ y → sym (prodFunAnnihilL (⊕HIT→Fun y)))
(λ k a → DS-Ind-Prop.f _ _ _ _ (λ _ → isSetFun _ _)
(sym (prodFunAnnihilR (⊕HIT→Fun (base k a))))
(λ l b → funExt λ n → sumFBase k a l b n)
λ {U V} ind-U ind-V → cong₂ _+Fun_ ind-U ind-V
∙ sym (prodFunDistR _ _ _))
λ {U} {V} ind-U ind-V y → cong₂ _+Fun_ (ind-U y) (ind-V y)
∙ sym (prodFunDistL _ _ _)
⊕HIT→⊕Fun-pres-prodF : (x y : ⊕HIT ℕ G Gstr) → ⊕HIT→⊕Fun (x prod y) ≡ ((⊕HIT→⊕Fun x) prodF (⊕HIT→⊕Fun y))
⊕HIT→⊕Fun-pres-prodF x y = ΣPathTransport→PathΣ _ _
((⊕HIT→Fun-pres-prodFun x y) , (squash₁ _ _))
-----------------------------------------------------------------------------
-- Graded Ring Structure
open AbGroupStr (snd (⊕Fun-AbGr G Gstr)) using ()
renaming
( 0g to 0⊕Fun
; _+_ to _+⊕Fun_
; -_ to -⊕Fun_
; is-set to isSet⊕Fun)
open IsGroupHom
⊕FunGradedRing-Ring : Ring ℓ
⊕FunGradedRing-Ring = InducedRing ⊕HITgradedRing-Ring
0⊕Fun 1⊕Fun _+⊕Fun_ _prodF_ -⊕Fun_
(fst (Equiv-DirectSum G Gstr))
(pres1 (snd (Equiv-DirectSum G Gstr)))
⊕HIT→⊕Fun-pres1
(pres· (snd (Equiv-DirectSum G Gstr)))
⊕HIT→⊕Fun-pres-prodF
(presinv (snd (Equiv-DirectSum G Gstr)))
RingEquiv-DirectSumGradedRing : RingEquiv ⊕HITgradedRing-Ring ⊕FunGradedRing-Ring
RingEquiv-DirectSumGradedRing = InducedRingEquiv ⊕HITgradedRing-Ring
0⊕Fun 1⊕Fun _+⊕Fun_ _prodF_ -⊕Fun_
(fst (Equiv-DirectSum G Gstr))
(pres1 (snd (Equiv-DirectSum G Gstr)))
⊕HIT→⊕Fun-pres1
(pres· (snd (Equiv-DirectSum G Gstr)))
⊕HIT→⊕Fun-pres-prodF
(presinv (snd (Equiv-DirectSum G Gstr)))
⊕Fun-GradedRing : GradedRing ℓ-zero ℓ
⊕Fun-GradedRing = makeGradedRing
⊕FunGradedRing-Ring
(ℕ , (monoidstr 0 _+n_ isM))
G Gstr
1⋆ _⋆_
0-⋆ ⋆-0
⋆Assoc ⋆IdR ⋆IdL
⋆DistR+ ⋆DistL+
(RingEquivs.invRingEquiv RingEquiv-DirectSumGradedRing)
-----------------------------------------------------------------------------
-- CommRing extension
module _
(⋆Comm : {k l : ℕ} → (a : G k) → (b : G l) →
_≡_ {A = Σ[ k ∈ ℕ ] G k} ((k +n l) , (a ⋆ b)) ((l +n k) , (b ⋆ a)))
where
open ExtensionCommRing ⋆Comm
⊕FunGradedRing-CommRing : CommRing ℓ
⊕FunGradedRing-CommRing = InducedCommRing ⊕HITgradedRing-CommRing
0⊕Fun 1⊕Fun _+⊕Fun_ _prodF_ -⊕Fun_
(fst (Equiv-DirectSum G Gstr))
(pres1 (snd (Equiv-DirectSum G Gstr)))
⊕HIT→⊕Fun-pres1
(pres· (snd (Equiv-DirectSum G Gstr)))
⊕HIT→⊕Fun-pres-prodF
(presinv (snd (Equiv-DirectSum G Gstr)))
CommRingEquiv-DirectSumGradedRing : CommRingEquiv ⊕HITgradedRing-CommRing ⊕FunGradedRing-CommRing
CommRingEquiv-DirectSumGradedRing = InducedCommRingEquiv ⊕HITgradedRing-CommRing
0⊕Fun 1⊕Fun _+⊕Fun_ _prodF_ -⊕Fun_
(fst (Equiv-DirectSum G Gstr))
(pres1 (snd (Equiv-DirectSum G Gstr)))
⊕HIT→⊕Fun-pres1
(pres· (snd (Equiv-DirectSum G Gstr)))
⊕HIT→⊕Fun-pres-prodF
(presinv (snd (Equiv-DirectSum G Gstr)))
| {
"alphanum_fraction": 0.4257581725,
"avg_line_length": 47.2372093023,
"ext": "agda",
"hexsha": "59dc0c5ee55aee7b51f8b850449631f02a5d5390",
"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/GradedRing/DirectSumFun.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/GradedRing/DirectSumFun.agda",
"max_line_length": 122,
"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/GradedRing/DirectSumFun.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 7368,
"size": 20312
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Notation for adding an additional point to any set
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Relation.Nullary.Construct.Add.Point where
open import Data.Maybe.Base using ()
renaming (Maybe to Pointed; nothing to ∙; just to [_])
public
| {
"alphanum_fraction": 0.4680851064,
"avg_line_length": 30.2142857143,
"ext": "agda",
"hexsha": "8384868b1b8c716c8f28350cc1000167f7acb817",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "omega12345/agda-mode",
"max_forks_repo_path": "test/asset/agda-stdlib-1.0/Relation/Nullary/Construct/Add/Point.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "omega12345/agda-mode",
"max_issues_repo_path": "test/asset/agda-stdlib-1.0/Relation/Nullary/Construct/Add/Point.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Nullary/Construct/Add/Point.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 69,
"size": 423
} |
{-# OPTIONS --without-K #-}
open import M-types.Base.Core
module M-types.Base.Prod where
∏ : (X : Ty ℓ₀) → (Y : X → Ty ℓ₁) → Ty (ℓ-max ℓ₀ ℓ₁)
∏ X Y = (x : X) → Y x
∏-syntax : (X : Ty ℓ₀) → (Y : X → Ty ℓ₁) → Ty (ℓ-max ℓ₀ ℓ₁)
∏-syntax = ∏
infix 2 ∏-syntax
syntax ∏-syntax X (λ x → Y) = ∏[ x ∈ X ] Y
id : {X : Ty ℓ} →
(X → X)
id = λ x → x
infixr 9 _∘_
_∘_ : {X : Ty ℓ₀} {Y : X → Ty ℓ₁} {Z : {x : X} → Y x → Ty ℓ₂} →
∏[ g ∈ ({x : X} → ∏[ y ∈ Y x ] Z y) ]
∏[ f ∈ (∏[ x ∈ X ] Y x) ]
∏[ x ∈ X ] Z (f x)
f ∘ g = λ x → f (g x)
| {
"alphanum_fraction": 0.3714759536,
"avg_line_length": 21.5357142857,
"ext": "agda",
"hexsha": "82028592bbd1aab4d52bed74b07c441b0e16f42e",
"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": "5b70f4b3dc3e50365ad7a3a80b0cd14efbfa4369",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DDOtten/M-types",
"max_forks_repo_path": "Base/Prod.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "5b70f4b3dc3e50365ad7a3a80b0cd14efbfa4369",
"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": "DDOtten/M-types",
"max_issues_repo_path": "Base/Prod.agda",
"max_line_length": 67,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "5b70f4b3dc3e50365ad7a3a80b0cd14efbfa4369",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DDOtten/M-types",
"max_stars_repo_path": "Base/Prod.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 298,
"size": 603
} |
{-# OPTIONS --cumulativity #-}
open import Agda.Primitive
module _ (a ℓ : Level) where
mutual
X : Level
X = _
X<=a : Set X → Set a
X<=a A = A
test : Set₁
test with (lsuc ℓ)
... | _ = Set
where
a<=X : Set a → Set X
a<=X A = A
| {
"alphanum_fraction": 0.5095785441,
"avg_line_length": 12.4285714286,
"ext": "agda",
"hexsha": "73ecaa9df78f6b8cc8e3f9a7357a0313e0c09ba7",
"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/Issue4203.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/Issue4203.agda",
"max_line_length": 30,
"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/Issue4203.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": 101,
"size": 261
} |
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import lib.types.TwoSemiCategory
module homotopy.HSpace where
-- This is just an approximation because
-- not all higher cells are killed.
record HSpaceStructure {i} (X : Ptd i) : Type i where
constructor hSpaceStructure
field
⊙μ : (X ⊙× X) ⊙→ X
μ : de⊙ X → de⊙ X → de⊙ X
μ = curry (fst ⊙μ)
field
⊙unit-l : ⊙μ ⊙∘ ⊙×-inr X X ⊙∼ ⊙idf X
⊙unit-r : ⊙μ ⊙∘ ⊙×-inl X X ⊙∼ ⊙idf X
unit-l : ∀ x → μ (pt X) x == x
unit-l = fst ⊙unit-l
unit-r : ∀ x → μ x (pt X) == x
unit-r = fst ⊙unit-r
coh : unit-l (pt X) == unit-r (pt X)
coh = ! (↓-idf=cst-out (snd ⊙unit-l) ∙ ∙-unit-r _)
∙ (↓-idf=cst-out (snd ⊙unit-r) ∙ ∙-unit-r _)
record AlternativeHSpaceStructure {i} (X : Ptd i) : Type i where
constructor hSpaceStructure
field
μ : de⊙ X → de⊙ X → de⊙ X
unit-l : ∀ x → μ (pt X) x == x
unit-r : ∀ x → μ x (pt X) == x
coh : unit-l (pt X) == unit-r (pt X)
⊙μ : (X ⊙× X) ⊙→ X
⊙μ = uncurry μ , unit-l (pt X)
⊙unit-l : ⊙μ ⊙∘ ⊙×-inr X X ⊙∼ ⊙idf X
⊙unit-l = unit-l , ↓-idf=cst-in' idp
⊙unit-r : ⊙μ ⊙∘ ⊙×-inl X X ⊙∼ ⊙idf X
⊙unit-r = unit-r , ↓-idf=cst-in' coh
from-alt-h-space : ∀ {i} {X : Ptd i} → AlternativeHSpaceStructure X → HSpaceStructure X
from-alt-h-space hss = record {AlternativeHSpaceStructure hss}
to-alt-h-space : ∀ {i} {X : Ptd i} → HSpaceStructure X → AlternativeHSpaceStructure X
to-alt-h-space hss = record {HSpaceStructure hss}
module ConnectedHSpace {i} {X : Ptd i} {{_ : is-connected 0 (de⊙ X)}}
(hX : HSpaceStructure X) where
open HSpaceStructure hX public
{-
Given that [X] is 0-connected, to prove that each [μ x] is an equivalence we
only need to prove that one of them is. But for [x] = [pt X], [μ x] is the
identity so we’re done.
-}
l-is-equiv : ∀ x → is-equiv (λ y → μ y x)
l-is-equiv = prop-over-connected {a = pt X}
(λ x → (is-equiv (λ y → μ y x) , is-equiv-is-prop))
(transport! is-equiv (λ= unit-r) (idf-is-equiv _))
r-is-equiv : ∀ x → is-equiv (λ y → μ x y)
r-is-equiv = prop-over-connected {a = pt X}
(λ x → (is-equiv (λ y → μ x y) , is-equiv-is-prop))
(transport! is-equiv (λ= unit-l) (idf-is-equiv _))
l-equiv : de⊙ X → de⊙ X ≃ de⊙ X
l-equiv x = _ , l-is-equiv x
r-equiv : de⊙ X → de⊙ X ≃ de⊙ X
r-equiv x = _ , r-is-equiv x
module _ {i} {X : Ptd i} (hX : HSpaceStructure X) where
module hX = HSpaceStructure hX
associator : Type i
associator = ∀ a b c → hX.μ (hX.μ a b) c == hX.μ a (hX.μ b c)
coh-unit-l-eq : associator → de⊙ X → de⊙ X → Type i
coh-unit-l-eq assoc a b =
assoc (pt X) a b ◃∙
hX.unit-l (hX.μ a b) ◃∎
=ₛ
ap (λ x → hX.μ x b) (hX.unit-l a) ◃∎
coh-unit-l : associator → Type i
coh-unit-l assoc = ∀ a b → coh-unit-l-eq assoc a b
coh-unit-r-eq : associator → de⊙ X → de⊙ X → Type i
coh-unit-r-eq assoc a b =
hX.unit-r (hX.μ a b) ◃∎
=ₛ
assoc a b (pt X) ◃∙
ap (hX.μ a) (hX.unit-r b) ◃∎
coh-unit-r : associator → Type i
coh-unit-r assoc = ∀ a b → coh-unit-r-eq assoc a b
coh-unit-l-r-pentagon : associator → Type i
coh-unit-l-r-pentagon assoc = ∀ a' →
hX.unit-r (hX.μ (pt X) a') ◃∙
hX.unit-l a' ◃∎
=ₛ
assoc (pt X) a' (pt X) ◃∙
hX.unit-l (hX.μ a' (pt X)) ◃∙
hX.unit-r a' ◃∎
coh-unit-l-to-unit-l-r-pentagon : (assoc : associator)
→ coh-unit-l assoc → coh-unit-l-r-pentagon assoc
coh-unit-l-to-unit-l-r-pentagon assoc c a' =
hX.unit-r (hX.μ (pt X) a') ◃∙
hX.unit-l a' ◃∎
=ₛ⟨ !ₛ (homotopy-naturality-to-idf (λ x → hX.μ x (pt X)) hX.unit-r (hX.unit-l a')) ⟩
ap (λ x → hX.μ x (pt X)) (hX.unit-l a') ◃∙
hX.unit-r a' ◃∎
=ₛ⟨ 0 & 1 & !ₛ (c a' (pt X)) ⟩
assoc (pt X) a' (pt X) ◃∙
hX.unit-l (hX.μ a' (pt X)) ◃∙
hX.unit-r a' ◃∎ ∎ₛ
coh-unit-r-to-unit-l-r-pentagon : (assoc : associator)
→ coh-unit-r assoc → coh-unit-l-r-pentagon assoc
coh-unit-r-to-unit-l-r-pentagon assoc c a' =
hX.unit-r (hX.μ (pt X) a') ◃∙
hX.unit-l a' ◃∎
=ₛ⟨ 0 & 1 & c (pt X) a' ⟩
assoc (pt X) a' (pt X) ◃∙
ap (hX.μ (pt X)) (hX.unit-r a') ◃∙
hX.unit-l a' ◃∎
=ₛ⟨ 1 & 3 &
homotopy-naturality-to-idf (hX.μ (pt X))
hX.unit-l
(hX.unit-r a') ⟩
assoc (pt X) a' (pt X) ◃∙
hX.unit-l (hX.μ a' (pt X)) ◃∙
hX.unit-r a' ◃∎ ∎ₛ
coh-assoc-pentagon-eq : (assoc : associator) → (a b c d : de⊙ X) → Type i
coh-assoc-pentagon-eq assoc a b c d =
assoc (hX.μ a b) c d ◃∙ assoc a b (hX.μ c d) ◃∎
=ₛ
ap (λ s → hX.μ s d) (assoc a b c) ◃∙ assoc a (hX.μ b c) d ◃∙ ap (hX.μ a) (assoc b c d) ◃∎
coh-assoc-pentagon : (assoc : associator) → Type i
coh-assoc-pentagon assoc = ∀ a b c d → coh-assoc-pentagon-eq assoc a b c d
HSpace-2-semi-category : {{X-level : has-level 1 (de⊙ X)}}
→ (assoc : associator)
→ coh-assoc-pentagon assoc
→ TwoSemiCategory lzero i
HSpace-2-semi-category assoc assoc-coh =
record
{ El = ⊤
; Arr = λ _ _ → de⊙ X
; Arr-level = λ _ _ → ⟨⟩
; two-semi-cat-struct =
record
{ comp = hX.μ
; assoc = assoc
; pentagon-identity = assoc-coh
}
}
| {
"alphanum_fraction": 0.5378216289,
"avg_line_length": 29.8786127168,
"ext": "agda",
"hexsha": "9518b76098a920dd09be14cf5876fb7af858ef59",
"lang": "Agda",
"max_forks_count": 50,
"max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z",
"max_forks_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "AntoineAllioux/HoTT-Agda",
"max_forks_repo_path": "theorems/homotopy/HSpace.agda",
"max_issues_count": 31,
"max_issues_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6",
"max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "AntoineAllioux/HoTT-Agda",
"max_issues_repo_path": "theorems/homotopy/HSpace.agda",
"max_line_length": 93,
"max_stars_count": 294,
"max_stars_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "AntoineAllioux/HoTT-Agda",
"max_stars_repo_path": "theorems/homotopy/HSpace.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": 2235,
"size": 5169
} |
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2020, 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
open import LibraBFT.ImplShared.Base.Types
open import LibraBFT.Abstract.Types.EpochConfig UID NodeId
open import LibraBFT.Base.ByteString
open import LibraBFT.Base.Encode
open import LibraBFT.Base.KVMap as KVMap
open import LibraBFT.Base.PKCS
open import LibraBFT.Concrete.System
open import LibraBFT.Concrete.System.Parameters
open import LibraBFT.Hash
open import LibraBFT.Impl.Consensus.EpochManagerTypes
import LibraBFT.Impl.Consensus.Liveness.RoundState as RoundState
import LibraBFT.Impl.IO.OBM.GenKeyFile as GenKeyFile
open import LibraBFT.Impl.IO.OBM.InputOutputHandlers
import LibraBFT.Impl.IO.OBM.Start as Start
open import LibraBFT.Impl.OBM.Rust.RustTypes
open import LibraBFT.Impl.OBM.Time
import LibraBFT.Impl.Types.BlockInfo as BlockInfo
import LibraBFT.Impl.Types.ValidatorSigner as ValidatorSigner
open import LibraBFT.Impl.Consensus.RoundManager
open import LibraBFT.ImplShared.Consensus.Types
open import LibraBFT.ImplShared.Consensus.Types.EpochIndep
open import LibraBFT.ImplShared.Interface.Output
open import LibraBFT.ImplShared.Util.Crypto
open import LibraBFT.ImplShared.Util.Util
open import LibraBFT.Lemmas
open import LibraBFT.Prelude
open import LibraBFT.Yasm.Base
import LibraBFT.Yasm.Types as LYT
open import Optics.All
-- This module connects implementation handlers to the interface of the SystemModel.
module LibraBFT.Impl.Handle where
open EpochConfig
------------------------------------------------------------------------------
-- This function works with any implementation of a RoundManager.
-- NOTE: The system layer only cares about this step function.
-- 0 is given as a timestamp.
peerStep : NodeId → NetworkMsg → RoundManager → RoundManager × List (LYT.Action NetworkMsg)
peerStep nid msg st = runHandler st (handle nid msg 0)
where
-- This invokes an implementation handler.
runHandler : RoundManager → LBFT Unit → RoundManager × List (LYT.Action NetworkMsg)
runHandler st handler = ×-map₂ (outputsToActions {st}) (proj₂ (LBFT-run handler st))
------------------------------------------------------------------------------
-- This connects the implementation handler to the system model so it can be initialized.
module InitHandler where
{-
IMPL-DIFF: In Haskell, nodes are started with a filepath of a file containing
- number of faults allowed
- genesis LedgerInfoWithSignatures
- network addresses/name and secret and public keys of all nodes in the genesis epoch
Main reads/checks that file then calls a network specific 'run' functions (e.g., ZMQ.hs)
that setup the network handlers then eventually call 'Start.startViaConsensusProvider'.
That functions calls 'ConsensusProvider.startConsensus' which returns
'(EpochManager, [Output]'.
'Start.startViaConsensusProvider' then goes on to create and wire up internal communication
channels and starts threads. The most relevant thread starts up
`(EpochManager.obmStartLoop epochManager output ...)' to handle the initialization output
and then to handle new messages from the network.
In Agda below,
- we assume 'BootstrapInfo' known to all peers
- i.e., the same info that Haskell creates via 'GenKeyFile.create'
- the assumed info is given to 'mkSysInitAndHandlers' in 'InitAndHandlers'
- System initialization calls 'initHandler'
- 'initHandler' eventually calls 'initialize'
- 'initialize' calls 'State.startViaConsensusProvider'
when then calls 'ConsensusProvider.startConsensus' which returns
'(EpochManager, List Output)', just like Haskell.
- Since there is no network, internal channels and threads, this is the end of this process.
Note: although both the Haskell and Agda version support non-uniform voting, the
above initialization process assumes one-vote per peer.
-}
postulate -- TODO-2: Eliminate when/if timestamps are modeled
now : Instant
proposalGenerator : ProposalGenerator
proposalGenerator = ProposalGenerator∙new 0
initialize' : Instant → GenKeyFile.NfLiwsVsVvPe → Either ErrLog (EpochManager × List Output)
initialize' now nfLiwsVsVvPe =
Start.startViaConsensusProvider
now nfLiwsVsVvPe
(TxTypeDependentStuffForNetwork∙new
proposalGenerator
(StateComputer∙new BlockInfo.gENESIS_VERSION))
abstract
initialize : Instant → GenKeyFile.NfLiwsVsVvPe → Either ErrLog (EpochManager × List Output)
initialize = initialize'
initialize≡ : initialize ≡ initialize'
initialize≡ = refl
mkNfLiwsVsVvPe : BootstrapInfo → ValidatorSigner → GenKeyFile.NfLiwsVsVvPe
mkNfLiwsVsVvPe bsi vs = (bsi ^∙ bsiNumFaults , bsi ^∙ bsiLIWS , vs , bsi ^∙ bsiVV , bsi ^∙ bsiPE)
initEMWithOutput' : BootstrapInfo → ValidatorSigner → Either ErrLog (EpochManager × List Output)
initEMWithOutput' bsi vs =
initialize now (mkNfLiwsVsVvPe bsi vs)
initEMWithOutput : BootstrapInfo → ValidatorSigner → EitherD ErrLog (EpochManager × List Output)
initEMWithOutput bsi vs =
fromEither $
initialize now (mkNfLiwsVsVvPe bsi vs)
getEmRm : EpochManager → Either ErrLog RoundManager
getEmRm em =
case em ^∙ emProcessor of λ where
nothing → Left fakeErr
(just p) → case p of λ where
(RoundProcessorRecovery _) → Left fakeErr
(RoundProcessorNormal rm) → Right rm
initRMWithOutput' : BootstrapInfo → ValidatorSigner → Either ErrLog (RoundManager × List Output)
initRMWithOutput' bsi vs = do
(em , lo) ← initEMWithOutput' bsi vs
rm ← getEmRm em
Right (rm , lo)
initRMWithOutput : BootstrapInfo → ValidatorSigner → EitherD ErrLog (RoundManager × List Output)
initRMWithOutput bsi vs = do
(em , lo) ← initEMWithOutput bsi vs
rm ← fromEither
$ getEmRm em
fromEither $ Right (rm , lo)
-- This shows that the Either and EitherD versions are equivalent.
-- This is a first step towards eliminating the painful VariantOf stuff,
-- so we can have the version that looks (almost) exactly like the Haskell,
-- and the EitherD variant, broken into explicit steps, etc. for proving.
initEMWithOutput≡
: ∀ {bsi : BootstrapInfo} {vs : ValidatorSigner}
→ initEMWithOutput' bsi vs ≡ EitherD-run (initEMWithOutput bsi vs)
initEMWithOutput≡ {bsi} {vs}
with initialize now (mkNfLiwsVsVvPe bsi vs)
... | Left _ = refl
... | Right _ = refl
initRMWithOutput≡
: ∀ {bsi : BootstrapInfo} {vs : ValidatorSigner}
→ initRMWithOutput' bsi vs ≡ EitherD-run (initRMWithOutput bsi vs)
initRMWithOutput≡ {bsi} {vs}
with initialize now (mkNfLiwsVsVvPe bsi vs)
... | Left _ = refl
... | Right (em , _)
with getEmRm em
... | Left _ = refl
... | Right _ = refl
abstract
initHandler : Author → BootstrapInfo → Maybe (RoundManager × List (LYT.Action NetworkMsg))
initHandler pid bsi =
case ValidatorSigner.obmGetValidatorSigner pid (bsi ^∙ bsiVSS) of λ where
(Left _) → nothing
(Right vs) →
case initRMWithOutput' bsi vs of λ where
(Left _) → nothing
(Right (rm , lo)) → just (rm , outputsToActions {State = rm} lo)
InitAndHandlers : SystemInitAndHandlers ℓ-RoundManager ConcSysParms
InitAndHandlers =
mkSysInitAndHandlers
fakeBootstrapInfo
fakeInitRM
initHandler
peerStep
where
postulate -- TODO-1: eliminate by constructing inhabitants
bs : BlockStore
pe : ProposerElection
rs : RoundState
sr : SafetyRules
vv : BootstrapInfo → ValidatorVerifier
-- For uninitialised peers, so we know nothing about their state.
-- Construct a value of type `RoundManager` to ensure it is inhabitable.
fakeInitRM : RoundManager
fakeInitRM = RoundManager∙new
ObmNeedFetch∙new
(EpochState∙new 1 (vv fakeBootstrapInfo))
bs rs pe proposalGenerator sr false
| {
"alphanum_fraction": 0.7188498403,
"avg_line_length": 40.69,
"ext": "agda",
"hexsha": "6eebf18df5822806536ed6cdbf14270d82835254",
"lang": "Agda",
"max_forks_count": 6,
"max_forks_repo_forks_event_max_datetime": "2022-02-18T01:04:32.000Z",
"max_forks_repo_forks_event_min_datetime": "2020-12-16T19:43:52.000Z",
"max_forks_repo_head_hexsha": "49f8b1b70823be805d84ffc3157c3b880edb1e92",
"max_forks_repo_licenses": [
"UPL-1.0"
],
"max_forks_repo_name": "oracle/bft-consensus-agda",
"max_forks_repo_path": "LibraBFT/Impl/Handle.agda",
"max_issues_count": 72,
"max_issues_repo_head_hexsha": "49f8b1b70823be805d84ffc3157c3b880edb1e92",
"max_issues_repo_issues_event_max_datetime": "2022-03-25T05:36:11.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-02-04T05:04:33.000Z",
"max_issues_repo_licenses": [
"UPL-1.0"
],
"max_issues_repo_name": "oracle/bft-consensus-agda",
"max_issues_repo_path": "LibraBFT/Impl/Handle.agda",
"max_line_length": 111,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "49f8b1b70823be805d84ffc3157c3b880edb1e92",
"max_stars_repo_licenses": [
"UPL-1.0"
],
"max_stars_repo_name": "oracle/bft-consensus-agda",
"max_stars_repo_path": "LibraBFT/Impl/Handle.agda",
"max_stars_repo_stars_event_max_datetime": "2021-12-18T19:24:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-12-16T19:43:41.000Z",
"num_tokens": 2180,
"size": 8138
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Properties related to All
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.List.Relation.Unary.All.Properties where
open import Axiom.Extensionality.Propositional using (Extensionality)
open import Data.Bool.Base using (Bool; T; true; false)
open import Data.Bool.Properties using (T-∧)
open import Data.Empty
open import Data.Fin.Base using (Fin) renaming (zero to fzero; suc to fsuc)
open import Data.List.Base as List using
( List; []; _∷_; [_]; _∷ʳ_; fromMaybe; null; _++_; concat; map; mapMaybe
; inits; tails; drop; take; applyUpTo; applyDownFrom; replicate; tabulate
; filter; zipWith; all; derun; deduplicate
)
open import Data.List.Membership.Propositional
open import Data.List.Membership.Propositional.Properties
open import Data.List.Relation.Unary.All as All using
( All; []; _∷_; lookup; updateAt
; _[_]=_; here; there
; Null
)
open import Data.List.Relation.Unary.Any as Any using (Any; here; there)
import Data.List.Relation.Binary.Equality.Setoid as ListEq using (_≋_; []; _∷_)
open import Data.List.Relation.Binary.Pointwise using (Pointwise; []; _∷_)
open import Data.List.Relation.Binary.Subset.Propositional using (_⊆_)
open import Data.Maybe.Base as Maybe using (Maybe; just; nothing)
open import Data.Maybe.Relation.Unary.All as MAll using (just; nothing)
open import Data.Nat.Base using (zero; suc; z≤n; s≤s; _<_)
open import Data.Nat.Properties using (≤-refl; ≤-step)
open import Data.Product as Prod using (_×_; _,_; uncurry; uncurry′)
open import Function.Base
open import Function.Equality using (_⟨$⟩_)
open import Function.Equivalence using (_⇔_; equivalence; Equivalence)
open import Function.Inverse using (_↔_; inverse)
open import Function.Surjection using (_↠_; surjection)
open import Level using (Level)
open import Relation.Binary as B using (REL; Setoid; _Respects_)
open import Relation.Binary.PropositionalEquality
using (_≡_; refl; cong; cong₂; _≗_)
open import Relation.Nullary.Reflects using (invert)
open import Relation.Nullary
open import Relation.Nullary.Negation using (¬?; contradiction; decidable-stable)
open import Relation.Unary
using (Decidable; Pred; Universal) renaming (_⊆_ to _⋐_)
private
variable
a b c p q r ℓ : Level
A : Set a
B : Set b
C : Set c
------------------------------------------------------------------------
-- Properties regarding Null
Null⇒null : ∀ {xs : List A} → Null xs → T (null xs)
Null⇒null [] = _
null⇒Null : ∀ {xs : List A} → T (null xs) → Null xs
null⇒Null {xs = [] } _ = []
null⇒Null {xs = _ ∷ _} ()
------------------------------------------------------------------------
-- Properties of the "points-to" relation _[_]=_
module _ {p} {P : Pred A p} where
-- Relation _[_]=_ is deterministic: each index points to a single value.
[]=-injective : ∀ {x xs} {px qx : P x} {pxs : All P xs} {i : x ∈ xs} →
pxs [ i ]= px →
pxs [ i ]= qx →
px ≡ qx
[]=-injective here here = refl
[]=-injective (there x↦px) (there x↦qx) = []=-injective x↦px x↦qx
-- See also Data.List.Relation.Unary.All.Properties.WithK.[]=-irrelevant.
------------------------------------------------------------------------
-- Lemmas relating Any, All and negation.
module _ {P : A → Set p} where
¬Any⇒All¬ : ∀ xs → ¬ Any P xs → All (¬_ ∘ P) xs
¬Any⇒All¬ [] ¬p = []
¬Any⇒All¬ (x ∷ xs) ¬p = ¬p ∘ here ∷ ¬Any⇒All¬ xs (¬p ∘ there)
All¬⇒¬Any : ∀ {xs} → All (¬_ ∘ P) xs → ¬ Any P xs
All¬⇒¬Any (¬p ∷ _) (here p) = ¬p p
All¬⇒¬Any (_ ∷ ¬p) (there p) = All¬⇒¬Any ¬p p
¬All⇒Any¬ : Decidable P → ∀ xs → ¬ All P xs → Any (¬_ ∘ P) xs
¬All⇒Any¬ dec [] ¬∀ = ⊥-elim (¬∀ [])
¬All⇒Any¬ dec (x ∷ xs) ¬∀ with dec x
... | true because [p] = there (¬All⇒Any¬ dec xs (¬∀ ∘ _∷_ (invert [p])))
... | false because [¬p] = here (invert [¬p])
Any¬⇒¬All : ∀ {xs} → Any (¬_ ∘ P) xs → ¬ All P xs
Any¬⇒¬All (here ¬p) = ¬p ∘ All.head
Any¬⇒¬All (there ¬p) = Any¬⇒¬All ¬p ∘ All.tail
¬Any↠All¬ : ∀ {xs} → (¬ Any P xs) ↠ All (¬_ ∘ P) xs
¬Any↠All¬ = surjection (¬Any⇒All¬ _) All¬⇒¬Any to∘from
where
to∘from : ∀ {xs} (¬p : All (¬_ ∘ P) xs) → ¬Any⇒All¬ xs (All¬⇒¬Any ¬p) ≡ ¬p
to∘from [] = refl
to∘from (¬p ∷ ¬ps) = cong₂ _∷_ refl (to∘from ¬ps)
-- If equality of functions were extensional, then the surjection
-- could be strengthened to a bijection.
from∘to : Extensionality _ _ →
∀ xs → (¬p : ¬ Any P xs) → All¬⇒¬Any (¬Any⇒All¬ xs ¬p) ≡ ¬p
from∘to ext [] ¬p = ext λ ()
from∘to ext (x ∷ xs) ¬p = ext λ
{ (here p) → refl
; (there p) → cong (λ f → f p) $ from∘to ext xs (¬p ∘ there)
}
Any¬⇔¬All : ∀ {xs} → Decidable P → Any (¬_ ∘ P) xs ⇔ (¬ All P xs)
Any¬⇔¬All dec = equivalence Any¬⇒¬All (¬All⇒Any¬ dec _)
where
-- If equality of functions were extensional, then the logical
-- equivalence could be strengthened to a surjection.
to∘from : Extensionality _ _ →
∀ {xs} (¬∀ : ¬ All P xs) → Any¬⇒¬All (¬All⇒Any¬ dec xs ¬∀) ≡ ¬∀
to∘from ext ¬∀ = ext (⊥-elim ∘ ¬∀)
module _ {_~_ : REL A B ℓ} where
All-swap : ∀ {xs ys} →
All (λ x → All (x ~_) ys) xs →
All (λ y → All (_~ y) xs) ys
All-swap {ys = []} _ = []
All-swap {ys = y ∷ ys} [] = All.universal (λ _ → []) (y ∷ ys)
All-swap {ys = y ∷ ys} ((x~y ∷ x~ys) ∷ pxs) =
(x~y ∷ (All.map All.head pxs)) ∷
All-swap (x~ys ∷ (All.map All.tail pxs))
------------------------------------------------------------------------
-- Defining properties of lookup and _[_]=_
--
-- pxs [ i ]= px if and only if lookup pxs i = px.
module _ {P : A → Set p} where
-- `i` points to `lookup pxs i` in `pxs`.
[]=lookup : ∀ {x xs} (pxs : All P xs) (i : x ∈ xs) →
pxs [ i ]= lookup pxs i
[]=lookup (px ∷ pxs) (here refl) = here
[]=lookup (px ∷ pxs) (there i) = there ([]=lookup pxs i)
-- If `i` points to `px` in `pxs`, then `lookup pxs i ≡ px`.
[]=⇒lookup : ∀ {x xs} {px : P x} {pxs : All P xs} {i : x ∈ xs} →
pxs [ i ]= px →
lookup pxs i ≡ px
[]=⇒lookup x↦px = []=-injective ([]=lookup _ _) x↦px
-- If `lookup pxs i ≡ px`, then `i` points to `px` in `pxs`.
lookup⇒[]= : ∀{x xs} {px : P x} (pxs : All P xs) (i : x ∈ xs) →
lookup pxs i ≡ px →
pxs [ i ]= px
lookup⇒[]= pxs i refl = []=lookup pxs i
------------------------------------------------------------------------
-- Properties of operations over `All`
------------------------------------------------------------------------
-- map
module _ {P : Pred A p} {Q : Pred A q} {f : P ⋐ Q} where
map-cong : ∀ {xs} {g : P ⋐ Q} (pxs : All P xs) →
(∀ {x} → f {x} ≗ g) → All.map f pxs ≡ All.map g pxs
map-cong [] _ = refl
map-cong (px ∷ pxs) feq = cong₂ _∷_ (feq px) (map-cong pxs feq)
map-id : ∀ {xs} (pxs : All P xs) → All.map id pxs ≡ pxs
map-id [] = refl
map-id (px ∷ pxs) = cong (px ∷_) (map-id pxs)
map-compose : ∀ {r} {R : Pred A r} {xs} {g : Q ⋐ R} (pxs : All P xs) →
All.map g (All.map f pxs) ≡ All.map (g ∘ f) pxs
map-compose [] = refl
map-compose (px ∷ pxs) = cong (_ ∷_) (map-compose pxs)
lookup-map : ∀ {xs x} (pxs : All P xs) (i : x ∈ xs) →
lookup (All.map f pxs) i ≡ f (lookup pxs i)
lookup-map (px ∷ pxs) (here refl) = refl
lookup-map (px ∷ pxs) (there i) = lookup-map pxs i
------------------------------------------------------------------------
-- _[_]%=_ / updateAt
module _ {P : Pred A p} where
-- Defining properties of updateAt:
-- (+) updateAt actually updates the element at the given index.
updateAt-updates : ∀ {x xs} (i : x ∈ xs) {f : P x → P x} {px : P x} (pxs : All P xs) →
pxs [ i ]= px →
updateAt i f pxs [ i ]= f px
updateAt-updates (here refl) (px ∷ pxs) here = here
updateAt-updates (there i) (px ∷ pxs) (there x↦px) =
there (updateAt-updates i pxs x↦px)
-- (-) updateAt i does not touch the elements at other indices.
updateAt-minimal : ∀ {x y xs} (i : x ∈ xs) (j : y ∈ xs) →
∀ {f : P y → P y} {px : P x} (pxs : All P xs) →
i ≢∈ j →
pxs [ i ]= px →
updateAt j f pxs [ i ]= px
updateAt-minimal (here .refl) (here refl) (px ∷ pxs) i≢j here =
⊥-elim (i≢j refl refl)
updateAt-minimal (here .refl) (there j) (px ∷ pxs) i≢j here = here
updateAt-minimal (there i) (here refl) (px ∷ pxs) i≢j (there val) = there val
updateAt-minimal (there i) (there j) (px ∷ pxs) i≢j (there val) =
there (updateAt-minimal i j pxs (there-injective-≢∈ i≢j) val)
-- lookup after updateAt reduces.
-- For same index this is an easy consequence of updateAt-updates
-- using []=↔lookup.
lookup∘updateAt : ∀ {x xs} (pxs : All P xs) (i : x ∈ xs) {f : P x → P x} →
lookup (updateAt i f pxs) i ≡ f (lookup pxs i)
lookup∘updateAt pxs i =
[]=⇒lookup (updateAt-updates i pxs (lookup⇒[]= pxs i refl))
-- For different indices it easily follows from updateAt-minimal.
lookup∘updateAt′ : ∀ {x y xs} (i : x ∈ xs) (j : y ∈ xs) →
∀ {f : P y → P y} {px : P x} (pxs : All P xs) →
i ≢∈ j →
lookup (updateAt j f pxs) i ≡ lookup pxs i
lookup∘updateAt′ i j pxs i≢j =
[]=⇒lookup (updateAt-minimal i j pxs i≢j (lookup⇒[]= pxs i refl))
-- The other properties are consequences of (+) and (-).
-- We spell the most natural properties out.
-- Direct inductive proofs are in most cases easier than just using
-- the defining properties.
-- In the explanations, we make use of shorthand f = g ↾ x
-- meaning that f and g agree at point x, i.e. f x ≡ g x.
-- updateAt (i : x ∈ xs) is a morphism
-- from the monoid of endofunctions P x → P x
-- to the monoid of endofunctions All P xs → All P xs.
-- 1a. relative identity: f = id ↾ (lookup pxs i)
-- implies updateAt i f = id ↾ pxs
updateAt-id-relative : ∀ {x xs} (i : x ∈ xs) {f : P x → P x} (pxs : All P xs) →
f (lookup pxs i) ≡ lookup pxs i →
updateAt i f pxs ≡ pxs
updateAt-id-relative (here refl)(px ∷ pxs) eq = cong (_∷ pxs) eq
updateAt-id-relative (there i) (px ∷ pxs) eq = cong (px ∷_) (updateAt-id-relative i pxs eq)
-- 1b. identity: updateAt i id ≗ id
updateAt-id : ∀ {x xs} (i : x ∈ xs) (pxs : All P xs) →
updateAt i id pxs ≡ pxs
updateAt-id i pxs = updateAt-id-relative i pxs refl
-- 2a. relative composition: f ∘ g = h ↾ (lookup i pxs)
-- implies updateAt i f ∘ updateAt i g = updateAt i h ↾ pxs
updateAt-compose-relative : ∀ {x xs} (i : x ∈ xs) {f g h : P x → P x} (pxs : All P xs) →
f (g (lookup pxs i)) ≡ h (lookup pxs i) →
updateAt i f (updateAt i g pxs) ≡ updateAt i h pxs
updateAt-compose-relative (here refl) (px ∷ pxs) fg=h = cong (_∷ pxs) fg=h
updateAt-compose-relative (there i) (px ∷ pxs) fg=h =
cong (px ∷_) (updateAt-compose-relative i pxs fg=h)
-- 2b. composition: updateAt i f ∘ updateAt i g ≗ updateAt i (f ∘ g)
updateAt-compose : ∀ {x xs} (i : x ∈ xs) {f g : P x → P x} →
updateAt {P = P} i f ∘ updateAt i g ≗ updateAt i (f ∘ g)
updateAt-compose (here refl) (px ∷ pxs) = refl
updateAt-compose (there i) (px ∷ pxs) = cong (px ∷_) (updateAt-compose i pxs)
-- 3. congruence: updateAt i is a congruence wrt. extensional equality.
-- 3a. If f = g ↾ (lookup pxs i)
-- then updateAt i f = updateAt i g ↾ pxs
updateAt-cong-relative : ∀ {x xs} (i : x ∈ xs) {f g : P x → P x} (pxs : All P xs) →
f (lookup pxs i) ≡ g (lookup pxs i) →
updateAt i f pxs ≡ updateAt i g pxs
updateAt-cong-relative (here refl) (px ∷ pxs) f=g = cong (_∷ pxs) f=g
updateAt-cong-relative (there i) (px ∷ pxs) f=g = cong (px ∷_) (updateAt-cong-relative i pxs f=g)
-- 3b. congruence: f ≗ g → updateAt i f ≗ updateAt i g
updateAt-cong : ∀ {x xs} (i : x ∈ xs) {f g : P x → P x} →
f ≗ g →
updateAt i f ≗ updateAt i g
updateAt-cong i f≗g pxs = updateAt-cong-relative i pxs (f≗g (lookup pxs i))
-- The order of updates at different indices i ≢ j does not matter.
-- This a consequence of updateAt-updates and updateAt-minimal
-- but easier to prove inductively.
updateAt-commutes : ∀ {x y xs} (i : x ∈ xs) (j : y ∈ xs) →
∀ {f : P x → P x} {g : P y → P y} →
i ≢∈ j →
updateAt i f ∘ updateAt j g ≗ updateAt j g ∘ updateAt i f
updateAt-commutes (here refl) (here refl) i≢j (px ∷ pxs) =
⊥-elim (i≢j refl refl)
updateAt-commutes (here refl) (there j) i≢j (px ∷ pxs) = refl
updateAt-commutes (there i) (here refl) i≢j (px ∷ pxs) = refl
updateAt-commutes (there i) (there j) i≢j (px ∷ pxs) =
cong (px ∷_) (updateAt-commutes i j (there-injective-≢∈ i≢j) pxs)
module _ {P : Pred A p} {Q : Pred A q} where
map-updateAt : ∀ {x xs} {f : P ⋐ Q} {g : P x → P x} {h : Q x → Q x}
(pxs : All P xs) (i : x ∈ xs) →
f (g (lookup pxs i)) ≡ h (f (lookup pxs i)) →
All.map f (pxs All.[ i ]%= g) ≡ (All.map f pxs) All.[ i ]%= h
map-updateAt (px ∷ pxs) (here refl) = cong (_∷ _)
map-updateAt (px ∷ pxs) (there i) feq = cong (_ ∷_) (map-updateAt pxs i feq)
------------------------------------------------------------------------
-- Introduction (⁺) and elimination (⁻) rules for list operations
------------------------------------------------------------------------
-- map
module _ {P : B → Set p} {f : A → B} where
map⁺ : ∀ {xs} → All (P ∘ f) xs → All P (map f xs)
map⁺ [] = []
map⁺ (p ∷ ps) = p ∷ map⁺ ps
map⁻ : ∀ {xs} → All P (map f xs) → All (P ∘ f) xs
map⁻ {xs = []} [] = []
map⁻ {xs = _ ∷ _} (p ∷ ps) = p ∷ map⁻ ps
-- A variant of All.map.
module _ {P : A → Set p} {Q : B → Set q} {f : A → B} where
gmap : P ⋐ Q ∘ f → All P ⋐ All Q ∘ map f
gmap g = map⁺ ∘ All.map g
------------------------------------------------------------------------
-- mapMaybe
module _ (P : B → Set p) {f : A → Maybe B} where
mapMaybe⁺ : ∀ {xs} → All (MAll.All P) (map f xs) → All P (mapMaybe f xs)
mapMaybe⁺ {[]} [] = []
mapMaybe⁺ {x ∷ xs} (px ∷ pxs) with f x
... | nothing = mapMaybe⁺ pxs
... | just v with px
... | just pv = pv ∷ mapMaybe⁺ pxs
------------------------------------------------------------------------
-- _++_
module _ {P : A → Set p} where
++⁺ : ∀ {xs ys} → All P xs → All P ys → All P (xs ++ ys)
++⁺ [] pys = pys
++⁺ (px ∷ pxs) pys = px ∷ ++⁺ pxs pys
++⁻ˡ : ∀ xs {ys} → All P (xs ++ ys) → All P xs
++⁻ˡ [] p = []
++⁻ˡ (x ∷ xs) (px ∷ pxs) = px ∷ (++⁻ˡ _ pxs)
++⁻ʳ : ∀ xs {ys} → All P (xs ++ ys) → All P ys
++⁻ʳ [] p = p
++⁻ʳ (x ∷ xs) (px ∷ pxs) = ++⁻ʳ xs pxs
++⁻ : ∀ xs {ys} → All P (xs ++ ys) → All P xs × All P ys
++⁻ [] p = [] , p
++⁻ (x ∷ xs) (px ∷ pxs) = Prod.map (px ∷_) id (++⁻ _ pxs)
++↔ : ∀ {xs ys} → (All P xs × All P ys) ↔ All P (xs ++ ys)
++↔ {xs} = inverse (uncurry ++⁺) (++⁻ xs) ++⁻∘++⁺ (++⁺∘++⁻ xs)
where
++⁺∘++⁻ : ∀ xs {ys} (p : All P (xs ++ ys)) →
uncurry′ ++⁺ (++⁻ xs p) ≡ p
++⁺∘++⁻ [] p = refl
++⁺∘++⁻ (x ∷ xs) (px ∷ pxs) = cong (_∷_ px) $ ++⁺∘++⁻ xs pxs
++⁻∘++⁺ : ∀ {xs ys} (p : All P xs × All P ys) →
++⁻ xs (uncurry ++⁺ p) ≡ p
++⁻∘++⁺ ([] , pys) = refl
++⁻∘++⁺ (px ∷ pxs , pys) rewrite ++⁻∘++⁺ (pxs , pys) = refl
------------------------------------------------------------------------
-- concat
module _ {P : A → Set p} where
concat⁺ : ∀ {xss} → All (All P) xss → All P (concat xss)
concat⁺ [] = []
concat⁺ (pxs ∷ pxss) = ++⁺ pxs (concat⁺ pxss)
concat⁻ : ∀ {xss} → All P (concat xss) → All (All P) xss
concat⁻ {[]} [] = []
concat⁻ {xs ∷ xss} pxs = ++⁻ˡ xs pxs ∷ concat⁻ (++⁻ʳ xs pxs)
------------------------------------------------------------------------
-- take and drop
module _ {P : A → Set p} where
drop⁺ : ∀ {xs} n → All P xs → All P (drop n xs)
drop⁺ zero pxs = pxs
drop⁺ (suc n) [] = []
drop⁺ (suc n) (px ∷ pxs) = drop⁺ n pxs
take⁺ : ∀ {xs} n → All P xs → All P (take n xs)
take⁺ zero pxs = []
take⁺ (suc n) [] = []
take⁺ (suc n) (px ∷ pxs) = px ∷ take⁺ n pxs
------------------------------------------------------------------------
-- applyUpTo
module _ {P : A → Set p} where
applyUpTo⁺₁ : ∀ f n → (∀ {i} → i < n → P (f i)) → All P (applyUpTo f n)
applyUpTo⁺₁ f zero Pf = []
applyUpTo⁺₁ f (suc n) Pf = Pf (s≤s z≤n) ∷ applyUpTo⁺₁ (f ∘ suc) n (Pf ∘ s≤s)
applyUpTo⁺₂ : ∀ f n → (∀ i → P (f i)) → All P (applyUpTo f n)
applyUpTo⁺₂ f n Pf = applyUpTo⁺₁ f n (λ _ → Pf _)
applyUpTo⁻ : ∀ f n → All P (applyUpTo f n) → ∀ {i} → i < n → P (f i)
applyUpTo⁻ f (suc n) (px ∷ _) (s≤s z≤n) = px
applyUpTo⁻ f (suc n) (_ ∷ pxs) (s≤s (s≤s i<n)) =
applyUpTo⁻ (f ∘ suc) n pxs (s≤s i<n)
------------------------------------------------------------------------
-- applyDownFrom
module _ {P : A → Set p} where
applyDownFrom⁺₁ : ∀ f n → (∀ {i} → i < n → P (f i)) → All P (applyDownFrom f n)
applyDownFrom⁺₁ f zero Pf = []
applyDownFrom⁺₁ f (suc n) Pf = Pf ≤-refl ∷ applyDownFrom⁺₁ f n (Pf ∘ ≤-step)
applyDownFrom⁺₂ : ∀ f n → (∀ i → P (f i)) → All P (applyDownFrom f n)
applyDownFrom⁺₂ f n Pf = applyDownFrom⁺₁ f n (λ _ → Pf _)
------------------------------------------------------------------------
-- tabulate
module _ {P : A → Set p} where
tabulate⁺ : ∀ {n} {f : Fin n → A} →
(∀ i → P (f i)) → All P (tabulate f)
tabulate⁺ {zero} Pf = []
tabulate⁺ {suc n} Pf = Pf fzero ∷ tabulate⁺ (Pf ∘ fsuc)
tabulate⁻ : ∀ {n} {f : Fin n → A} →
All P (tabulate f) → (∀ i → P (f i))
tabulate⁻ {suc n} (px ∷ _) fzero = px
tabulate⁻ {suc n} (_ ∷ pf) (fsuc i) = tabulate⁻ pf i
------------------------------------------------------------------------
-- remove
module _ {P : A → Set p} {Q : A → Set q} where
─⁺ : ∀ {xs} (p : Any P xs) → All Q xs → All Q (xs Any.─ p)
─⁺ (here px) (_ ∷ qs) = qs
─⁺ (there p) (q ∷ qs) = q ∷ ─⁺ p qs
─⁻ : ∀ {xs} (p : Any P xs) → Q (Any.lookup p) → All Q (xs Any.─ p) → All Q xs
─⁻ (here px) q qs = q ∷ qs
─⁻ (there p) q (q′ ∷ qs) = q′ ∷ ─⁻ p q qs
------------------------------------------------------------------------
-- filter
module _ {P : A → Set p} (P? : Decidable P) where
all-filter : ∀ xs → All P (filter P? xs)
all-filter [] = []
all-filter (x ∷ xs) with P? x
... | true because [Px] = invert [Px] ∷ all-filter xs
... | false because _ = all-filter xs
module _ {P : A → Set p} {Q : A → Set q} (P? : Decidable P) where
filter⁺ : ∀ {xs} → All Q xs → All Q (filter P? xs)
filter⁺ {xs = _} [] = []
filter⁺ {xs = x ∷ _} (Qx ∷ Qxs) with does (P? x)
... | false = filter⁺ Qxs
... | true = Qx ∷ filter⁺ Qxs
filter⁻ : ∀ {xs} → All Q (filter P? xs) → All Q (filter (¬? ∘ P?) xs) → All Q xs
filter⁻ {[]} [] [] = []
filter⁻ {x ∷ xs} all⁺ all⁻ with P? x | ¬? (P? x)
filter⁻ {x ∷ xs} all⁺ all⁻ | yes Px | yes ¬Px = contradiction Px ¬Px
filter⁻ {x ∷ xs} (qx ∷ all⁺) all⁻ | yes Px | no ¬¬Px = qx ∷ filter⁻ all⁺ all⁻
filter⁻ {x ∷ xs} all⁺ (qx ∷ all⁻) | no _ | yes ¬Px = qx ∷ filter⁻ all⁺ all⁻
filter⁻ {x ∷ xs} all⁺ all⁻ | no ¬Px | no ¬¬Px = contradiction ¬Px ¬¬Px
------------------------------------------------------------------------
-- derun and deduplicate
module _ {P : A → Set p} {R : A → A → Set q} (R? : B.Decidable R) where
derun⁺ : ∀ {xs} → All P xs → All P (derun R? xs)
derun⁺ {[]} [] = []
derun⁺ {x ∷ []} (px ∷ []) = px ∷ []
derun⁺ {x ∷ y ∷ xs} (px ∷ all[P,y∷xs]) with does (R? x y)
... | false = px ∷ derun⁺ all[P,y∷xs]
... | true = derun⁺ all[P,y∷xs]
deduplicate⁺ : ∀ {xs} → All P xs → All P (deduplicate R? xs)
deduplicate⁺ [] = []
deduplicate⁺ {x ∷ _} (px ∷ all[P,xs]) = px ∷ filter⁺ (¬? ∘ R? x) (deduplicate⁺ all[P,xs])
derun⁻ : P B.Respects (flip R) → ∀ xs → All P (derun R? xs) → All P xs
derun⁻ P-resp-R [] [] = []
derun⁻ P-resp-R (x ∷ xs) all[P,x∷xs] = aux x xs all[P,x∷xs] where
aux : ∀ x xs → All P (derun R? (x ∷ xs)) → All P (x ∷ xs)
aux x [] (px ∷ []) = px ∷ []
aux x (y ∷ xs) all[P,x∷y∷xs] with R? x y
aux x (y ∷ xs) all[P,y∷xs] | yes Rxy with aux y xs all[P,y∷xs]
aux x (y ∷ xs) all[P,y∷xs] | yes Rxy | r@(py ∷ _) = P-resp-R Rxy py ∷ r
aux x (y ∷ xs) (px ∷ all[P,y∷xs]) | no _ = px ∷ aux y xs all[P,y∷xs]
module _ (P-resp-R : P B.Respects R) where
deduplicate⁻ : ∀ xs → All P (deduplicate R? xs) → All P xs
deduplicate⁻ [] [] = []
deduplicate⁻ (x ∷ xs) (px ∷ app[P,dedup[xs]]) = px ∷ deduplicate⁻ xs (filter⁻ (¬? ∘ R? x) app[P,dedup[xs]] (All.tabulate aux)) where
aux : ∀ {z} → z ∈ filter (¬? ∘ ¬? ∘ R? x) (deduplicate R? xs) → P z
aux {z} z∈filter = P-resp-R (decidable-stable (R? x z) (Prod.proj₂ (∈-filter⁻ (¬? ∘ ¬? ∘ R? x) {z} {deduplicate R? xs} z∈filter))) px
------------------------------------------------------------------------
-- zipWith
module _ (P : C → Set p) (f : A → B → C) where
zipWith⁺ : ∀ {xs ys} → Pointwise (λ x y → P (f x y)) xs ys →
All P (zipWith f xs ys)
zipWith⁺ [] = []
zipWith⁺ (Pfxy ∷ Pfxsys) = Pfxy ∷ zipWith⁺ Pfxsys
------------------------------------------------------------------------
-- Operations for constructing lists
------------------------------------------------------------------------
-- singleton
module _ {P : A → Set p} where
singleton⁻ : ∀ {x} → All P [ x ] → P x
singleton⁻ (px ∷ []) = px
------------------------------------------------------------------------
-- snoc
module _ {P : A → Set p} {x xs} where
∷ʳ⁺ : All P xs → P x → All P (xs ∷ʳ x)
∷ʳ⁺ pxs px = ++⁺ pxs (px ∷ [])
∷ʳ⁻ : All P (xs ∷ʳ x) → All P xs × P x
∷ʳ⁻ pxs = Prod.map₂ singleton⁻ $ ++⁻ xs pxs
------------------------------------------------------------------------
-- fromMaybe
module _ {P : A → Set p} where
fromMaybe⁺ : ∀ {mx} → MAll.All P mx → All P (fromMaybe mx)
fromMaybe⁺ (just px) = px ∷ []
fromMaybe⁺ nothing = []
fromMaybe⁻ : ∀ mx → All P (fromMaybe mx) → MAll.All P mx
fromMaybe⁻ (just x) (px ∷ []) = just px
fromMaybe⁻ nothing p = nothing
------------------------------------------------------------------------
-- replicate
module _ {P : A → Set p} where
replicate⁺ : ∀ n {x} → P x → All P (replicate n x)
replicate⁺ zero px = []
replicate⁺ (suc n) px = px ∷ replicate⁺ n px
replicate⁻ : ∀ {n x} → All P (replicate (suc n) x) → P x
replicate⁻ (px ∷ _) = px
------------------------------------------------------------------------
-- inits
module _ {P : A → Set p} where
inits⁺ : ∀ {xs} → All P xs → All (All P) (inits xs)
inits⁺ [] = [] ∷ []
inits⁺ (px ∷ pxs) = [] ∷ gmap (px ∷_) (inits⁺ pxs)
inits⁻ : ∀ xs → All (All P) (inits xs) → All P xs
inits⁻ [] pxs = []
inits⁻ (x ∷ []) ([] ∷ p[x] ∷ []) = p[x]
inits⁻ (x ∷ xs@(_ ∷ _)) ([] ∷ pxs@(p[x] ∷ _)) =
singleton⁻ p[x] ∷ inits⁻ xs (All.map (drop⁺ 1) (map⁻ pxs))
------------------------------------------------------------------------
-- tails
module _ {P : A → Set p} where
tails⁺ : ∀ {xs} → All P xs → All (All P) (tails xs)
tails⁺ [] = [] ∷ []
tails⁺ pxxs@(_ ∷ pxs) = pxxs ∷ tails⁺ pxs
tails⁻ : ∀ xs → All (All P) (tails xs) → All P xs
tails⁻ [] pxs = []
tails⁻ (x ∷ xs) (pxxs ∷ _) = pxxs
------------------------------------------------------------------------
-- all
module _ (p : A → Bool) where
all⁺ : ∀ xs → T (all p xs) → All (T ∘ p) xs
all⁺ [] _ = []
all⁺ (x ∷ xs) px∷xs with Equivalence.to (T-∧ {p x}) ⟨$⟩ px∷xs
... | (px , pxs) = px ∷ all⁺ xs pxs
all⁻ : ∀ {xs} → All (T ∘ p) xs → T (all p xs)
all⁻ [] = _
all⁻ (px ∷ pxs) = Equivalence.from T-∧ ⟨$⟩ (px , all⁻ pxs)
------------------------------------------------------------------------
-- All is anti-monotone.
anti-mono : ∀ {P : A → Set p} {xs ys} → xs ⊆ ys → All P ys → All P xs
anti-mono xs⊆ys pys = All.tabulate (lookup pys ∘ xs⊆ys)
all-anti-mono : ∀ (p : A → Bool) {xs ys} →
xs ⊆ ys → T (all p ys) → T (all p xs)
all-anti-mono p xs⊆ys = all⁻ p ∘ anti-mono xs⊆ys ∘ all⁺ p _
------------------------------------------------------------------------
-- Interactions with pointwise equality
------------------------------------------------------------------------
module _ {c ℓ} (S : Setoid c ℓ) where
open Setoid S
open ListEq S
respects : {P : Pred Carrier p} → P Respects _≈_ → (All P) Respects _≋_
respects p≈ [] [] = []
respects p≈ (x≈y ∷ xs≈ys) (px ∷ pxs) = p≈ x≈y px ∷ respects p≈ xs≈ys pxs
------------------------------------------------------------------------
-- DEPRECATED NAMES
------------------------------------------------------------------------
-- Please use the new names as continuing support for the old names is
-- not guaranteed.
-- Version 0.16
All-all = all⁻
{-# WARNING_ON_USAGE All-all
"Warning: All-all was deprecated in v0.16.
Please use all⁻ instead."
#-}
all-All = all⁺
{-# WARNING_ON_USAGE all-All
"Warning: all-All was deprecated in v0.16.
Please use all⁺ instead."
#-}
All-map = map⁺
{-# WARNING_ON_USAGE All-map
"Warning: All-map was deprecated in v0.16.
Please use map⁺ instead."
#-}
map-All = map⁻
{-# WARNING_ON_USAGE map-All
"Warning: map-All was deprecated in v0.16.
Please use map⁻ instead."
#-}
-- Version 1.0
filter⁺₁ = all-filter
{-# WARNING_ON_USAGE filter⁺₁
"Warning: filter⁺₁ was deprecated in v1.0.
Please use all-filter instead."
#-}
filter⁺₂ = filter⁺
{-# WARNING_ON_USAGE filter⁺₂
"Warning: filter⁺₂ was deprecated in v1.0.
Please use filter⁺ instead."
#-}
-- Version 1.3
Any¬→¬All = Any¬⇒¬All
{-# WARNING_ON_USAGE Any¬→¬All
"Warning: Any¬→¬All was deprecated in v1.3.
Please use Any¬⇒¬All instead."
#-}
| {
"alphanum_fraction": 0.4708537044,
"avg_line_length": 36.8282548476,
"ext": "agda",
"hexsha": "9f18f4dd81f1b63ce3a51903cb36c4c84577a5ab",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DreamLinuxer/popl21-artifact",
"max_forks_repo_path": "agda-stdlib/src/Data/List/Relation/Unary/All/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DreamLinuxer/popl21-artifact",
"max_issues_repo_path": "agda-stdlib/src/Data/List/Relation/Unary/All/Properties.agda",
"max_line_length": 139,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DreamLinuxer/popl21-artifact",
"max_stars_repo_path": "agda-stdlib/src/Data/List/Relation/Unary/All/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z",
"num_tokens": 9726,
"size": 26590
} |
{-# OPTIONS --without-K #-}
open import lib.Basics
open import lib.types.Paths
open import lib.types.Pi
open import lib.types.Unit
open import lib.types.Nat
open import lib.types.TLevel
open import lib.types.Pointed
open import lib.types.Sigma
open import lib.NType2
open import lib.types.PathSeq
open import nicolai.pseudotruncations.Liblemmas
open import nicolai.pseudotruncations.SeqColim
open import nicolai.pseudotruncations.wconst-preparation
module nicolai.pseudotruncations.heptagon
{i} {C : Sequence {i}} (wc : wconst-chain C) (a₀ : fst C O) where
{- î-def is defined in this module: -}
open wconst-init {i} {C} wc a₀
module _ (n : ℕ) (a : A n) where
{- Let us formulate different simplification steps of the
heptagon. -}
full-hepta : seq-loop (ins (S n) (f n a))
full-hepta = (î-def (S n) (f n a)) ⋯ (‼ (î-def n a) ⋯ toSeq (glue n a))
remove-g : seq-loop (ins (S n) (f n a))
remove-g = (î-def (S n) (f n a))
⋯ ‼ (ins (S n) (f n a)
=⟪ ap (ins (S n)) (wc n _ _) ⟫
ins (S n) (lift-point C a₀ (S n))
=⟪ ! (lift-point-= C a₀ (S n)) ⟫
ins O a₀
∎∎)
simplify-‼ : seq-loop (ins (S n) (f n a))
simplify-‼ = (î-def (S n) (f n a))
⋯ (ins O a₀
=⟪ lift-point-= C a₀ (S n) ⟫
ins (S n) (lift-point C a₀ (S n))
=⟪ ! (ap (ins (S n)) (wc n _ _)) ⟫
ins (S n) (f n a)
∎∎)
simplify-one-g : seq-loop (ins {C = C} (S n) (f n a))
simplify-one-g =
ins (S n) (f n a)
=⟪ glue (S n) (f n a) ⟫
ins (S (S n)) (f (S n) (f n a))
=⟪ ap (ins (S (S n))) (wc (S n) (f n a) (lift-point C a₀ (S n))) ⟫
ins (S (S n)) (lift-point C a₀ (S (S n)))
=⟪ ! (glue (S n) (lift-point C a₀ (S n))) ⟫
ins (S n) (lift-point C a₀ (S n))
=⟪ ! (lift-point-= C a₀ (S n)) ⟫
ins O a₀
=⟪ lift-point-= C a₀ (S n) ⟫
ins (S n) (lift-point C a₀ (S n))
=⟪ ! (ap (ins (S n)) (wc n a (lift-point C a₀ n))) ⟫
ins (S n) (f n a)
∎∎
simplify-many-g : seq-loop (ins {C = C} (S n) (f n a))
simplify-many-g =
ins (S n) (f n a)
=⟪ glue (S n) (f n a) ⟫
ins (S (S n)) (f (S n) (f n a))
=⟪ ap (ins (S (S n))) (wc (S n) (f n a) (lift-point C a₀ (S n))) ⟫
ins (S (S n)) (lift-point C a₀ (S (S n)))
=⟪ ! (glue (S n) (lift-point C a₀ (S n))) ⟫
ins (S n) (lift-point C a₀ (S n))
=⟪ ! (ap (ins (S n)) (wc n a (lift-point C a₀ n))) ⟫
ins (S n) (f n a)
∎∎
replace-ap-SSn : seq-loop (ins {C = C} (S n) (f n a))
replace-ap-SSn =
ins (S n) (f n a)
=⟪ glue (S n) (f n a) ⟫
ins (S (S n)) (f (S n) (f n a))
=⟪ ap (ins (S (S n))) (ap (f (S n)) (wc n a (lift-point C a₀ n))) ⟫
ins (S (S n)) (lift-point C a₀ (S (S n)))
=⟪ ! (glue (S n) (lift-point C a₀ (S n))) ⟫
ins (S n) (lift-point C a₀ (S n))
=⟪ ! (ap (ins (S n)) (wc n a (lift-point C a₀ n))) ⟫
ins (S n) (f n a)
∎∎
{-
Now, let us generalize:
x for f n a
y for lift-point C a₀ (S n)
q for wc n a (lift C a₀ n)
Then, we can show that the square commutes by induction on q.
-}
generalize-square : (x y : A (S n)) (q : x == y)
→ (↯
ins {C = C} (S n) x
=⟪ glue (S n) x ⟫
ins (S (S n)) (f (S n) x)
=⟪ ap (ins (S (S n))) (ap (f (S n)) q) ⟫
ins (S (S n)) (f (S n) y)
=⟪ ! (glue (S n) y) ⟫
ins (S n) y
=⟪ ! (ap (ins (S n)) q) ⟫
ins (S n) x
∎∎
) == idp
generalize-square x .x idp =
glue (S n) x ∙ ! (glue (S n) x) ∙ idp
=⟨ ap (λ q → (glue (S n) x) ∙ q) (∙-unit-r _) ⟩
glue (S n) x ∙ ! (glue (S n) x)
=⟨ !-inv-r (glue (S n) x) ⟩
idp
∎
{- Let us use some ad-hoc lemmas; these could all be done via
very tedious concatenations of library lemmas.
Of course, our ad-hoc way is somewhat ugly, but it saves a
lot of work compared to using concatenations and nestings of
library lemmas. The strategy is to formulate the equality
that we need and solve it by trivial path induction.
This ad-hoc approach is surely not the best way one can
think of.
The best way to do it would probably be a more principled
approach with more powerful high-level lemmas that allow the
manipulation of paths; however, such a technology is not
implemented so far. -}
adhoc-!-∙ : ∀ {i} {X : Type i} {x y z u v w o : X}
(p : x == y) (q : y == z) (r : u == z)
(s : v == u) (t : v == w) (l : w == o)
→ (↯ x =⟪ p ⟫ y =⟪ q ⟫ z =⟪ ! (s ∙ r) ⟫ v =⟪ t ⟫ w =⟪ l ⟫ o ∎∎ )
==
(↯ x =⟪ p ⟫ y =⟪ q ⟫ z =⟪ ! r ⟫ u =⟪ ! s ⟫ v =⟪ t ⟫ w =⟪ l ⟫ o ∎∎)
adhoc-!-∙ idp idp idp idp idp idp = idp
adhoc-cancel-inv : ∀ {i} {X : Type i} {x y z u v w : X}
(p : x == y) (q : y == z) (r : z == u)
(s : v == u) (t : u == w)
→ (↯ x =⟪ p ⟫ y =⟪ q ⟫ z =⟪ r ⟫ u =⟪ ! s ⟫ v =⟪ s ⟫ u =⟪ t ⟫ w ∎∎ )
==
(↯ x =⟪ p ⟫ y =⟪ q ⟫ z =⟪ r ⟫ u =⟪ t ⟫ w ∎∎)
adhoc-cancel-inv idp idp idp idp idp = idp
{- Now, we are ready to show that the heptagon is trivial! -}
ĝ-def : (↯ full-hepta) == idp
ĝ-def =
(↯ full-hepta)
=⟨ ap (λ q → (glue (S n) (f n a))
∙ ap (ins (S (S n))) (wc (S n) (f n a) (snd C n (lift-point C a₀ n)))
∙ ! ((lift-point-= C a₀ n ∙ glue n (lift-point C a₀ n))
∙ glue (S n) (snd C n (lift-point C a₀ n)))
∙ ! (! (lift-point-= C a₀ n ∙ glue n (lift-point C a₀ n)))
∙ ! (ap (ins (S n)) (wc n a (lift-point C a₀ n)))
∙ q )
(!-inv-l (glue n a)) ⟩
(↯ (remove-g ⋯ (toSeq idp)))
=⟨ ap (λ q → (glue (S n) (f n a))
∙ ap (ins (S (S n))) (wc (S n) (f n a) (snd C n (lift-point C a₀ n)))
∙ ! ((lift-point-= C a₀ n ∙ glue n (lift-point C a₀ n))
∙ glue (S n) (snd C n (lift-point C a₀ n)))
∙ ! (! (lift-point-= C a₀ n ∙ glue n (lift-point C a₀ n)))
∙ q )
(∙-unit-r (! (ap (ins (S n)) (wc n a (lift-point C a₀ n))))) ⟩
(↯ remove-g)
=⟨ ap (λ q → (glue (S n) (f n a))
∙ ap (ins (S (S n))) (wc (S n) (f n a) (snd C n (lift-point C a₀ n)))
∙ ! ((lift-point-= C a₀ n ∙ glue n (lift-point C a₀ n))
∙ glue (S n) (snd C n (lift-point C a₀ n)))
∙ q
∙ ! (ap (ins (S n)) (wc n a (lift-point C a₀ n)))
)
(!-! (lift-point-= C a₀ n ∙ glue n (lift-point C a₀ n))) ⟩
(↯ simplify-‼)
=⟨ adhoc-!-∙
(glue (S n) (f n a))
(ap (ins (S (S n))) (wc (S n) (f n a) (snd C n (lift-point C a₀ n))))
(glue (S n) (snd C n (lift-point C a₀ n)))
(lift-point-= C a₀ n ∙ glue n (lift-point C a₀ n))
(lift-point-= C a₀ n ∙ glue n (lift-point C a₀ n))
(! (ap (ins (S n)) (wc n a (lift-point C a₀ n)))) ⟩
(↯ simplify-one-g)
=⟨ adhoc-cancel-inv
(glue (S n) (f n a))
(ap (ins (S (S n))) (wc (S n) (f n a) (snd C n (lift-point C a₀ n))))
(! (glue (S n) (snd C n (lift-point C a₀ n))))
(lift-point-= C a₀ n ∙ glue n (lift-point C a₀ n))
(! (ap (ins (S n)) (wc n a (lift-point C a₀ n)))) ⟩
(↯ simplify-many-g)
=⟨ ap (λ q → (glue (S n) (f n a))
∙ q
∙ ! (glue (S n) (snd C n (lift-point C a₀ n)))
∙ ! (ap (ins (S n)) (wc n a (lift-point C a₀ n)))
)
(ap-wconst (ins (S (S n)))
(ins-wconst (S (S n)))
(wc (S n) (f n a) (snd C n (lift-point C a₀ n)))
(ap (f (S n)) (wc n a (lift-point C a₀ n)))
) ⟩
(↯ replace-ap-SSn)
=⟨ generalize-square (f n a) (lift-point C a₀ (S n)) (wc n a (lift-point C a₀ n)) ⟩
idp
∎
| {
"alphanum_fraction": 0.3843544858,
"avg_line_length": 40.2643171806,
"ext": "agda",
"hexsha": "e8a293846ffeb402fd4ac2d60bd2bd99a42c82cd",
"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/heptagon.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/heptagon.agda",
"max_line_length": 93,
"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/heptagon.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": 3203,
"size": 9140
} |
module FormalLanguage.ContextFreeGrammar where
| {
"alphanum_fraction": 0.914893617,
"avg_line_length": 23.5,
"ext": "agda",
"hexsha": "9d6e23b569c30118894a3e94827d7ed20d6f7234",
"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": "FormalLanguage/ContextFreeGrammar.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": "FormalLanguage/ContextFreeGrammar.agda",
"max_line_length": 46,
"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": "FormalLanguage/ContextFreeGrammar.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z",
"num_tokens": 8,
"size": 47
} |
-- Andreas, 2015-02-13
-- Termination errors in parametrized modules
module Issue1429 (A : Set) (f : A → A) where
test : A → A
test a = test (f a)
-- should report problematic call
--
-- test (f a)
--
-- not
--
-- test (f₁ a)
| {
"alphanum_fraction": 0.5785123967,
"avg_line_length": 14.2352941176,
"ext": "agda",
"hexsha": "eb3a21ef66b7db105ff6af2b22a9b470b5b4479f",
"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/Issue1429.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/Issue1429.agda",
"max_line_length": 45,
"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/Issue1429.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": 82,
"size": 242
} |
{-# OPTIONS --cubical --safe #-}
module Algebra.Construct.Sign where
open import Prelude
data Signed {a} (A : Type a) : Type a where
⁻_ : A → Signed A
±0 : Signed A
⁺_ : A → Signed A
unsign : (A → B) → B → (A → B) → Signed A → B
unsign f g h (⁻ x) = f x
unsign f g h ±0 = g
unsign f g h (⁺ x) = h x
| {
"alphanum_fraction": 0.5598705502,
"avg_line_length": 19.3125,
"ext": "agda",
"hexsha": "2e7ca09e2f274a69fba757f3e4d6128eeabf1a56",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z",
"max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/agda-playground",
"max_forks_repo_path": "Algebra/Construct/Sign.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "oisdk/agda-playground",
"max_issues_repo_path": "Algebra/Construct/Sign.agda",
"max_line_length": 45,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/agda-playground",
"max_stars_repo_path": "Algebra/Construct/Sign.agda",
"max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z",
"num_tokens": 123,
"size": 309
} |
{-# OPTIONS --without-K #-}
open import HoTT
{-
This file contains three proofs of Ω(S¹) = ℤ and the fact that the circle is
a 1-type:
- Something closely related to Mike’s original proof
- Dan’s encode-decode proof
- Guillaume’s proof using the flattening lemma.
This file is divided in a lot of different parts so that common parts can be
factored:
1. Definition of the universal cover and the encoding map (this part is common
to all three proofs)
2. Proof that [encode (loop^ n) == n] (this part is common to Mike’s proof and
the encode-decode proof)
3. Dan’s encode-decode proof that [Ω S¹ ≃ ℤ]
4. Mike’s proof that [Σ S¹ Cover] is contractible
5. Proof with the flattening lemma that [Σ S¹ S¹Cover] is contractible
6. Proof of [Ω S¹ ≃ ℤ] using the fact that [Σ S¹ S¹Cover] is contractible (common
to Mike’s proof and the flattening lemma proof)
7. Encode-decode proof of the whole equivalence
8. Proof that the circle is a 1-type (common to all three proofs)
Keep
- 1, 2, 3 for the encode-decode proof (+ 7, 8 for S¹ is a 1-type)
- 1, 2, 4, 6 for Mike’s proof (+ 8)
- 1, 5, 6 for the flattening lemma proof (+ 8)
-}
module homotopy.LoopSpaceCircle where
{- 1. Universal cover and encoding map (common to all three proofs) -}
module S¹Cover = S¹RecType ℤ succ-equiv
S¹Cover : S¹ → Type₀
S¹Cover = S¹Cover.f
encode : {x : S¹} (p : base == x) → S¹Cover x
encode p = transport S¹Cover p 0
{- 2. Encoding [loop^ n] (common to Mike’s proof and the encode-decode proof) -}
-- We define the element of [Ω S¹] which is supposed to correspond to an
-- integer [n], this is the loop winding around the circle [n] times.
-- This is easy by induction on [n]
loop^ : (n : ℤ) → base == base
loop^ (pos O) = idp
loop^ (pos (S n)) = loop^ (pos n) ∙ loop
loop^ (negsucc O) = ! loop
loop^ (negsucc (S n)) = loop^ (negsucc n) ∙ (! loop)
-- Compatibility of [loop^] with the successor function
-- This is again not difficult by induction on [n]
loop^succ : (n : ℤ) → loop^ n ∙ loop == loop^ (succ n)
loop^succ (pos n) = idp
loop^succ (negsucc O) = !-inv-l loop
loop^succ (negsucc (S n)) =
(loop^ (negsucc n) ∙ ! loop) ∙ loop
=⟨ ∙-assoc (loop^ (negsucc n)) (! loop) loop ⟩
loop^ (negsucc n) ∙ (! loop ∙ loop)
=⟨ !-inv-l loop |in-ctx (λ u → loop^ (negsucc n) ∙ u) ⟩
loop^ (negsucc n) ∙ idp
=⟨ ∙-unit-r _ ⟩
loop^ (negsucc n) ∎
-- Now we check that encoding [loop^ n] gives indeed [n], again by induction
-- on [n]
encode-loop^ : (n : ℤ) → encode (loop^ n) == n
encode-loop^ (pos O) = idp
encode-loop^ (pos (S n)) =
encode (loop^ (pos n) ∙ loop) =⟨ idp ⟩
coe (ap S¹Cover (loop^ (pos n) ∙ loop)) 0
=⟨ ap-∙ S¹Cover (loop^ (pos n)) loop |in-ctx (λ u → coe u 0) ⟩
coe (ap S¹Cover (loop^ (pos n)) ∙ ap S¹Cover loop) 0
=⟨ coe-∙ (ap S¹Cover (loop^ (pos n)))
(ap S¹Cover loop) 0 ⟩
coe (ap S¹Cover loop) (coe (ap S¹Cover (loop^ (pos n))) 0)
=⟨ encode-loop^ (pos n) |in-ctx coe (ap S¹Cover loop) ⟩
coe (ap S¹Cover loop) (pos n)
=⟨ S¹Cover.coe-loop-β (pos n) ⟩
pos (S n) ∎
encode-loop^ (negsucc O) =
coe (ap S¹Cover (! loop)) 0 =⟨ coe-ap-! S¹Cover loop 0 ⟩
coe! (ap S¹Cover loop) 0 =⟨ S¹Cover.coe!-loop-β 0 ⟩
negsucc O ∎
encode-loop^ (negsucc (S n)) =
encode (loop^ (negsucc n) ∙ ! loop) =⟨ idp ⟩
coe (ap S¹Cover (loop^ (negsucc n) ∙ ! loop)) 0
=⟨ ap-∙ S¹Cover (loop^ (negsucc n)) (! loop)
|in-ctx (λ u → coe u 0) ⟩
coe (ap S¹Cover (loop^ (negsucc n)) ∙ ap S¹Cover (! loop)) 0
=⟨ coe-∙ (ap S¹Cover (loop^ (negsucc n)))
(ap S¹Cover (! loop)) 0 ⟩
coe (ap S¹Cover (! loop)) (coe (ap S¹Cover (loop^ (negsucc n))) 0)
=⟨ encode-loop^ (negsucc n) |in-ctx coe (ap S¹Cover (! loop)) ⟩
coe (ap S¹Cover (! loop)) (negsucc n)
=⟨ coe-ap-! S¹Cover loop (negsucc n) ⟩
coe! (ap S¹Cover loop) (negsucc n)
=⟨ S¹Cover.coe!-loop-β (negsucc n) ⟩
negsucc (S n) ∎
{- 3. Dan’s encode-decode proof -}
-- The decoding function at [base] is [loop^], but we extend it to the whole
-- of [S¹] so that [decode-encode] becomes easier (and we need [loop^succ] to
-- be able to extend it)
decode : (x : S¹) → (S¹Cover x → base == x)
decode =
S¹-elim loop^ (↓-→-in (λ {n} q →
↓-cst=idf-in
(loop^succ n ∙ ap loop^ (S¹Cover.↓-loop-out q))))
decode-encode : (x : S¹) (p : base == x) → decode x (encode p) == p
decode-encode _ p = J (λ x p → decode x (encode p) == p) idp p -- Magic!
-- And we get the theorem
ΩS¹≃ℤ : (base == base) ≃ ℤ
ΩS¹≃ℤ = equiv encode (decode base) encode-loop^ (decode-encode base)
{- 4. Mike’s proof that [Σ S¹ Cover] is contractible -}
-- We want to prove that every point of [Σ S¹ S¹Cover] is equal to [(base , O)]
paths-mike : (xt : Σ S¹ S¹Cover) → (base , 0) == xt
paths-mike (x , t) = paths-mike-c x t where
-- We do it by circle-induction on the first component. When it’s [base],
-- we use the [↓-loop^] below (which is essentially [encode-loop^]) and
-- for [loop] we use [loop^succ] and the fact that [ℤ] is a set.
paths-mike-c : (x : S¹) (t : S¹Cover x) → (base , 0) == (x , t) :> Σ S¹ S¹Cover
paths-mike-c = S¹-elim
(λ n → pair= (loop^ n) (↓-loop^ n))
(↓-Π-in (λ {n} {n'} q →
↓-cst=idf-in
(pair= (loop^ n) (↓-loop^ n) ∙ pair= loop q
=⟨ Σ-∙ (↓-loop^ n) q ⟩
pair= (loop^ n ∙ loop) (↓-loop^ n ∙ᵈ q)
=⟨ pair== (loop^succ n ∙ ap loop^ (S¹Cover.↓-loop-out q))
(set-↓-has-all-paths-↓ ℤ-is-set) ⟩
pair= (loop^ n') (↓-loop^ n') ∎))) where
↓-loop^ : (n : ℤ) → 0 == n [ S¹Cover ↓ loop^ n ]
↓-loop^ n = from-transp _ _ (encode-loop^ n)
contr-mike : is-contr (Σ S¹ S¹Cover)
contr-mike = ((base , 0) , paths-mike)
{- 5. Flattening lemma proof that [Σ S¹ Cover] is contractible -}
--We import the flattening lemma for the universal cover of the circle
--open FlatteningS¹ ℤ succ-equiv
open S¹Cover using (module Wt; Wt; cct; ppt; flattening-S¹)
-- We prove that the flattened HIT corresponding to the universal cover of the
-- circle (the real line) is contractible
Wt-is-contr : is-contr Wt
Wt-is-contr = (cct tt 0 , Wt.elim (base* ∘ snd) (loop* ∘ snd)) where
-- This is basically [loop^]
base* : (n : ℤ) → cct tt 0 == cct tt n
base* (pos O) = idp
base* (pos (S n)) = base* (pos n) ∙ ppt tt (pos n)
base* (negsucc O) = ! (ppt tt (negsucc O))
base* (negsucc (S n)) = base* (negsucc n) ∙ ! (ppt tt (negsucc (S n)))
loop* : (n : ℤ)
→ base* n == base* (succ n) [ (λ x → cct tt 0 == x) ↓ ppt tt n ]
loop* n = ↓-cst=idf-in (aux n) where
-- This is basically [loop^succ]
aux : (n : ℤ) → base* n ∙ ppt tt n == base* (succ n)
aux (pos n) = idp
aux (negsucc O) = !-inv-l (ppt tt (negsucc O))
aux (negsucc (S n)) =
base* (negsucc (S n)) ∙ ppt tt (negsucc (S n))
=⟨ idp ⟩
(base* (negsucc n) ∙ ! (ppt tt (negsucc (S n)))) ∙ ppt tt (negsucc (S n))
=⟨ ∙-assoc (base* (negsucc n)) _ _ ⟩
base* (negsucc n) ∙ (! (ppt tt (negsucc (S n))) ∙ ppt tt (negsucc (S n)))
=⟨ !-inv-l (ppt tt (negsucc (S n)))
|in-ctx (λ u → base* (negsucc n) ∙ u) ⟩
base* (negsucc n) ∙ idp
=⟨ ∙-unit-r _ ⟩
base* (negsucc n) ∎
-- Then, using the flattening lemma we get that the total space of [Cover] is
-- contractible
contr-flattening : is-contr (Σ S¹ S¹Cover)
contr-flattening = transport! is-contr flattening-S¹ Wt-is-contr
{- 6. Proof that [Ω S¹ ≃ ℤ] using the fact that [Σ S¹ Cover] is contractible -}
tot-encode : Σ S¹ (λ x → base == x) → Σ S¹ S¹Cover
tot-encode (x , y) = (x , encode y)
-- The previous map induces an equivalence on the total spaces, because both
-- total spaces are contractible
total-is-equiv : is-equiv tot-encode
total-is-equiv = contr-to-contr-is-equiv _ (pathfrom-is-contr base) contr-flattening
-- Hence it’s an equivalence fiberwise
postulate -- TODO, will be only one line using the fact that an equivalence on
-- total spaces induces an equivalence fiberwise
encode-is-equiv : (x : S¹) → is-equiv (encode {x})
-- We can then conclude that the loop space of the circle is equivalent to [ℤ]
ΩS¹≃ℤ' : (base == base) ≃ ℤ
ΩS¹≃ℤ' = (encode {base} , encode-is-equiv base)
{- 7. Encode-decode proof of the whole fiberwise equivalence -}
-- This is quite similar to [paths-mike], we’re doing it by circle-induction,
-- the base case is [encode-loop^] and the loop case is using the fact that [ℤ]
-- is a set (and [loop^succ] is already used in [decode])
encode-decode : (x : S¹) (t : S¹Cover x) → encode (decode x t) == t
encode-decode =
S¹-elim {P = λ x → (t : S¹Cover x) → encode (decode x t) == t}
encode-loop^ (↓-Π-in (λ q → prop-has-all-paths-↓ (ℤ-is-set _ _)))
encode-is-equiv' : (x : S¹) → is-equiv (encode {x})
encode-is-equiv' x = is-eq encode (decode x) (encode-decode x) (decode-encode x)
{- 8. Proof that the circle is a 1-type -}
S¹Cover-is-set : (y : S¹) → is-set (S¹Cover y)
S¹Cover-is-set = S¹-elim ℤ-is-set (prop-has-all-paths-↓ is-set-is-prop)
ΩS¹-is-set : (y : S¹) → is-set (base == y)
ΩS¹-is-set y = equiv-preserves-level ((encode {y} , encode-is-equiv y) ⁻¹)
(S¹Cover-is-set y)
S¹-level : has-level 1 S¹
S¹-level =
S¹-elim ΩS¹-is-set (prop-has-all-paths-↓ (Π-level (λ x → is-set-is-prop)))
| {
"alphanum_fraction": 0.5961127723,
"avg_line_length": 39.5105485232,
"ext": "agda",
"hexsha": "ad7418a26dc17b815dbb93d097c19183c9ea2c2f",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cmknapp/HoTT-Agda",
"max_forks_repo_path": "theorems/homotopy/LoopSpaceCircle.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cmknapp/HoTT-Agda",
"max_issues_repo_path": "theorems/homotopy/LoopSpaceCircle.agda",
"max_line_length": 84,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cmknapp/HoTT-Agda",
"max_stars_repo_path": "theorems/homotopy/LoopSpaceCircle.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3467,
"size": 9364
} |
open import FRP.JS.Bool using ( Bool ; _∨_ ; not )
open import FRP.JS.True using ( True )
open import FRP.JS.Maybe using ( Maybe )
open import FRP.JS.Float using ( ℝ ) renaming ( _/?_ to _/?r_ )
open import FRP.JS.Primitive using ( ℕ ; String )
module FRP.JS.Int where
infixr 4 _≤_ _<_ _≟_
infixl 6 _+_ _-_
infixl 7 _*_ _/_ _/?_
open import FRP.JS.Primitive public using ( ℤ )
private
primitive
primIntegerPlus : ℤ -> ℤ -> ℤ
primIntegerMinus : ℤ -> ℤ -> ℤ
primIntegerTimes : ℤ -> ℤ -> ℤ
primIntegerDiv : ℤ -> ℤ -> ℤ
primIntegerMod : ℤ -> ℤ -> ℤ
primIntegerEquality : ℤ -> ℤ -> Bool
primIntegerLess : ℤ -> ℤ -> Bool
primIntegerToFloat : ℤ -> ℝ
primIntegerAbs : ℤ -> ℕ
primShowInteger : ℤ -> String
primNatToInteger : ℕ → ℤ
primFloatDiv : ℝ → ℝ → ℝ
_+_ = primIntegerPlus
_-_ = primIntegerMinus
_*_ = primIntegerTimes
_%_ = primIntegerMod
_≟_ = primIntegerEquality
_<_ = primIntegerLess
float = primIntegerToFloat
abs = primIntegerAbs
show = primShowInteger
{-# COMPILED_JS _+_ function(x) { return function(y) { return x + y; }; } #-}
{-# COMPILED_JS _-_ function(x) { return function(y) { return x - y; }; } #-}
{-# COMPILED_JS _*_ function(x) { return function(y) { return x * y; }; } #-}
{-# COMPILED_JS _%_ function(x) { return function(y) { if (x < 0) { return (x % y) + x; } else { return x % y; } }; } #-}
{-# COMPILED_JS _≟_ function(x) { return function(y) { return x === y; }; } #-}
{-# COMPILED_JS _<_ function(x) { return function(y) { return x < y; }; } #-}
{-# COMPILED_JS float function(x) { return x; } #-}
{-# COMPILED_JS abs function(x) { return Math.abs(x); } #-}
{-# COMPILED_JS show function(x) { return x.toString(); } #-}
+0 = primNatToInteger 0
+1 = primNatToInteger 1
-1 = +0 - +1
-_ : ℤ → ℤ
- x = +0 - x
_≤_ : ℤ → ℤ → Bool
x ≤ y = (x < y) ∨ (x ≟ y)
_≠_ : ℤ → ℤ → Bool
x ≠ y = not (x ≟ y)
_/_ : (x y : ℤ) → {y≠0 : True (y ≠ +0)} → ℝ
x / y = primFloatDiv (float x) (float y)
_/?_ : ℤ → ℤ → Maybe ℝ
x /? y = (float x) /?r (float y)
{-# COMPILED_JS _/_ function(x) { return function(y) { return x / y; }; } #-}
{-# COMPILED_JS _≤_ function(x) { return function(y) { return x <= y; }; } #-}
{-# COMPILED_JS _≠_ function(x) { return function(y) { return x !== y; }; } #-}
{-# COMPILED_JS _/_ function(x) { return function(y) { return function() { return x / y; }; }; } #-}
{-# COMPILED_JS _/?_ function(x) { return function(y) { if (y === 0) { return null; } else { return x / y; } }; } #-}
| {
"alphanum_fraction": 0.5791352638,
"avg_line_length": 34.0675675676,
"ext": "agda",
"hexsha": "c2ac65b2ed461ecae1be084a9d8dec034ae5816d",
"lang": "Agda",
"max_forks_count": 7,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-11-07T21:50:58.000Z",
"max_forks_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72",
"max_forks_repo_licenses": [
"MIT",
"BSD-3-Clause"
],
"max_forks_repo_name": "agda/agda-frp-js",
"max_forks_repo_path": "src/agda/FRP/JS/Int.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT",
"BSD-3-Clause"
],
"max_issues_repo_name": "agda/agda-frp-js",
"max_issues_repo_path": "src/agda/FRP/JS/Int.agda",
"max_line_length": 123,
"max_stars_count": 63,
"max_stars_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72",
"max_stars_repo_licenses": [
"MIT",
"BSD-3-Clause"
],
"max_stars_repo_name": "agda/agda-frp-js",
"max_stars_repo_path": "src/agda/FRP/JS/Int.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-28T09:46:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-20T21:47:00.000Z",
"num_tokens": 910,
"size": 2521
} |
{-
Define finitely generated ideals of commutative rings and
show that they are an ideal.
Parts of this should be reusable for explicit constructions
of free modules over a finite set.
-}
{-# OPTIONS --safe #-}
module Cubical.Algebra.CommRing.FGIdeal where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Transport
open import Cubical.Foundations.HLevels
open import Cubical.Data.Sigma
open import Cubical.Data.FinData hiding (elim ; rec)
open import Cubical.Data.Nat renaming ( zero to ℕzero ; suc to ℕsuc
; _+_ to _+ℕ_ ; _·_ to _·ℕ_
; +-assoc to +ℕ-assoc ; +-comm to +ℕ-comm
; ·-assoc to ·ℕ-assoc ; ·-comm to ·ℕ-comm)
hiding (elim)
open import Cubical.HITs.PropositionalTruncation
open import Cubical.Algebra.CommRing
open import Cubical.Algebra.CommRing.Ideal
open import Cubical.Algebra.Ring.QuotientRing
open import Cubical.Algebra.Ring.Properties
open import Cubical.Algebra.Ring.BigOps
open import Cubical.Algebra.RingSolver.ReflectionSolving
open import Cubical.Algebra.Matrix
private
variable
ℓ : Level
module _ (Ring@(R , str) : CommRing ℓ) where
infixr 5 _holds
_holds : hProp ℓ → Type ℓ
P holds = fst P
open CommRingStr str
open RingTheory (CommRing→Ring Ring)
open Sum (CommRing→Ring Ring)
linearCombination : {n : ℕ} → FinVec R n → FinVec R n → R
linearCombination α V = ∑ (λ i → α i · V i)
sumDist+ : ∀ {n : ℕ} (α β V : FinVec R n)
→ linearCombination (λ i → α i + β i) V ≡ linearCombination α V + linearCombination β V
sumDist+ α β V = ∑Ext (λ i → ·Ldist+ (α i) (β i) (V i)) ∙ ∑Split (λ i → α i · V i) (λ i → β i · V i)
dist- : ∀ {n : ℕ} (α V : FinVec R n)
→ linearCombination (λ i → - α i) V ≡ - linearCombination α V
dist- α V = ∑Ext (λ i → -DistL· (α i) (V i)) ∙ ∑Dist- (λ i → α i · V i)
dist0 : ∀ {n : ℕ} (V : FinVec R n)
→ linearCombination (replicateFinVec n 0r) V ≡ 0r
dist0 {n = n} V = ∑Ext (λ i → 0LeftAnnihilates (V i)) ∙ ∑0r n
isLinearCombination : {n : ℕ} → FinVec R n → R → Type ℓ
isLinearCombination V x = ∃[ α ∈ FinVec R _ ] x ≡ linearCombination α V
{- If x and y are linear combinations of l, then (x + y) is
a linear combination. -}
isLinearCombination+ : {n : ℕ} {x y : R} (V : FinVec R n)
→ isLinearCombination V x
→ isLinearCombination V y
→ isLinearCombination V (x + y)
isLinearCombination+ V = map2 λ α β → (λ i → α .fst i + β .fst i)
, cong₂ (_+_) (α .snd) (β .snd) ∙ sym (sumDist+ _ _ V)
{- If x is a linear combinations of l, then -x is
a linear combination. -}
isLinearCombination- : {n : ℕ} {x : R} (V : FinVec R n)
→ isLinearCombination V x → isLinearCombination V (- x)
isLinearCombination- V = map λ α → (λ i → - α .fst i) , cong (-_) (α .snd) ∙ sym (dist- _ V)
{- 0r is the trivial linear Combination -}
isLinearCombination0 : {n : ℕ} (V : FinVec R n)
→ isLinearCombination V 0r
isLinearCombination0 V = ∣ _ , sym (dist0 V) ∣
{- Linear combinations are stable under left multiplication -}
isLinearCombinationL· : {n : ℕ} (V : FinVec R n) (r : R) {x : R}
→ isLinearCombination V x → isLinearCombination V (r · x)
isLinearCombinationL· V r = map λ α → (λ i → r · α .fst i) , cong (r ·_) (α .snd)
∙∙ ∑Mulrdist r (λ i → α .fst i · V i)
∙∙ ∑Ext λ i → ·Assoc r (α .fst i) (V i)
generatedIdeal : {n : ℕ} → FinVec R n → IdealsIn Ring
generatedIdeal V = makeIdeal Ring
(λ x → isLinearCombination V x , isPropPropTrunc)
(isLinearCombination+ V)
(isLinearCombination0 V)
λ r → isLinearCombinationL· V r
open CommIdeal.isCommIdeal
genIdeal : {n : ℕ} (R : CommRing ℓ) → FinVec (fst R) n → CommIdeal.CommIdeal R
fst (genIdeal R V) x = isLinearCombination R V x , isPropPropTrunc
+Closed (snd (genIdeal R V)) = isLinearCombination+ R V
contains0 (snd (genIdeal R V)) = isLinearCombination0 R V
·Closed (snd (genIdeal R V)) r = isLinearCombinationL· R V r
syntax genIdeal R V = ⟨ V ⟩[ R ]
FGIdealIn : (R : CommRing ℓ) → Type (ℓ-suc ℓ)
FGIdealIn R = Σ[ I ∈ CommIdeal.CommIdeal R ]
∃[ nV ∈ Σ[ n ∈ ℕ ] FinVec (fst R) n ] I ≡ ⟨ nV .snd ⟩[ R ]
-- The lattice laws
module _ (R' : CommRing ℓ) where
open CommRingStr (snd R')
open RingTheory (CommRing→Ring R')
open CommIdeal R'
open Sum (CommRing→Ring R')
open KroneckerDelta (CommRing→Ring R')
private
R = fst R'
⟨_⟩ : {n : ℕ} → FinVec R n → CommIdeal
⟨ V ⟩ = ⟨ V ⟩[ R' ]
inclOfFGIdeal : {n : ℕ} (V : FinVec R n) (I : CommIdeal)
→ (∀ i → V i ∈ I) → ⟨ V ⟩ ⊆ I
inclOfFGIdeal V I ∀i→Vi∈I x = elim (λ _ → I .fst x .snd) inclOfFGIdealΣ
where
inclOfFGIdealΣ : Σ[ α ∈ FinVec R _ ] x ≡ linearCombination R' α V → x ∈ I
inclOfFGIdealΣ (α , x≡α·V) = subst-∈ I (sym x≡α·V) (∑Closed I (λ i → α i · V i)
λ i → ·Closed (I .snd) _ (∀i→Vi∈I i))
indInIdeal : ∀ {n : ℕ} (U : FinVec R n) (i : Fin n) → U i ∈ ⟨ U ⟩
indInIdeal U i = ∣ (δ i) , sym (∑Mul1r _ U i) ∣
sucIncl : ∀ {n : ℕ} (U : FinVec R (ℕsuc n)) → ⟨ U ∘ suc ⟩ ⊆ ⟨ U ⟩
sucIncl U x = map λ (α , x≡∑αUsuc) → (λ { zero → 0r ; (suc i) → α i }) , x≡∑αUsuc ∙ path _ _
where
path : ∀ s u₀ → s ≡ 0r · u₀ + s
path = solve R'
emptyFGIdeal : ∀ (V : FinVec R 0) → ⟨ V ⟩ ≡ 0Ideal
emptyFGIdeal V = CommIdeal≡Char (λ _ → rec (is-set _ _) snd)
(λ _ x≡0 → ∣ (λ ()) , x≡0 ∣)
0FGIdealLIncl : {n : ℕ} → ⟨ replicateFinVec n 0r ⟩ ⊆ 0Ideal
0FGIdealLIncl x = elim (λ _ → is-set _ _)
λ (α , x≡∑α0) → subst-∈ 0Ideal (sym x≡∑α0) (∑Closed 0Ideal (λ i → α i · 0r)
λ i → subst-∈ 0Ideal (sym (0RightAnnihilates _)) refl)
0FGIdealRIncl : {n : ℕ} → 0Ideal ⊆ ⟨ replicateFinVec n 0r ⟩
0FGIdealRIncl x x≡0 = subst-∈ ⟨ replicateFinVec _ 0r ⟩ (sym x≡0)
(⟨ replicateFinVec _ 0r ⟩ .snd .contains0)
0FGIdeal : {n : ℕ} → ⟨ replicateFinVec n 0r ⟩ ≡ 0Ideal
0FGIdeal = CommIdeal≡Char 0FGIdealLIncl 0FGIdealRIncl
FGIdealAddLemmaLIncl : {n m : ℕ} (U : FinVec R n) (V : FinVec R m)
→ ⟨ U ++Fin V ⟩ ⊆ (⟨ U ⟩ +i ⟨ V ⟩)
FGIdealAddLemmaLIncl {n = ℕzero} U V x x∈⟨V⟩ =
∣ (0r , x) , ⟨ U ⟩ .snd .contains0 , x∈⟨V⟩ , sym (+Lid x) ∣
FGIdealAddLemmaLIncl {n = ℕsuc n} U V x = rec isPropPropTrunc helperΣ
where
helperΣ : Σ[ α ∈ FinVec R _ ] (x ≡ ∑ λ i → α i · (U ++Fin V) i) → x ∈ (⟨ U ⟩ +i ⟨ V ⟩)
helperΣ (α , p) = subst-∈ (⟨ U ⟩ +i ⟨ V ⟩) (sym p)
((⟨ U ⟩ +i ⟨ V ⟩) .snd .+Closed zeroIncl sumIncl)
where
zeroIncl : (α zero · U zero) ∈ (⟨ U ⟩ +i ⟨ V ⟩)
zeroIncl = +iLincl ⟨ U ⟩ ⟨ V ⟩ (α zero · U zero)
(⟨ U ⟩ .snd .·Closed (α zero) (indInIdeal U zero))
sumIncl : (∑ λ i → (α ∘ suc) i · ((U ∘ suc) ++Fin V) i) ∈ (⟨ U ⟩ +i ⟨ V ⟩)
sumIncl = let sum = ∑ λ i → (α ∘ suc) i · ((U ∘ suc) ++Fin V) i in
+iRespLincl ⟨ U ∘ suc ⟩ ⟨ U ⟩ ⟨ V ⟩ (sucIncl U) sum
(FGIdealAddLemmaLIncl (U ∘ suc) V _ ∣ (α ∘ suc) , refl ∣)
FGIdealAddLemmaRIncl : {n m : ℕ} (U : FinVec R n) (V : FinVec R m)
→ (⟨ U ⟩ +i ⟨ V ⟩) ⊆ ⟨ U ++Fin V ⟩
FGIdealAddLemmaRIncl U V x = rec isPropPropTrunc (uncurry3 helper)
where
helperΣ : ((y , z) : R × R)
→ Σ[ α ∈ FinVec R _ ] (y ≡ ∑ λ i → α i · U i)
→ Σ[ β ∈ FinVec R _ ] (z ≡ ∑ λ i → β i · V i)
→ x ≡ y + z
→ x ∈ ⟨ U ++Fin V ⟩
helperΣ (y , z) (α , y≡∑αU) (β , z≡∑βV) x≡y+z = ∣ (α ++Fin β) , path ∣
where
path : x ≡ ∑ λ i → (α ++Fin β) i · (U ++Fin V) i
path = x ≡⟨ x≡y+z ⟩
y + z ≡⟨ cong₂ (_+_) y≡∑αU z≡∑βV ⟩
(∑ λ i → α i · U i) + (∑ λ i → β i · V i) ≡⟨ sym (∑Split++ (λ i → α i · U i) _) ⟩
(∑ ((λ i → α i · U i) ++Fin (λ i → β i · V i))) ≡⟨ ∑Ext (mul++dist α U β V) ⟩
(∑ λ i → (α ++Fin β) i · (U ++Fin V) i) ∎
helper : ((y , z) : R × R)
→ ∃[ α ∈ FinVec R _ ] (y ≡ ∑ λ i → α i · U i)
→ ∃[ β ∈ FinVec R _ ] (z ≡ ∑ λ i → β i · V i)
→ x ≡ y + z
→ x ∈ ⟨ U ++Fin V ⟩
helper _ = rec2 (isPropΠ (λ _ → isPropPropTrunc)) (helperΣ _)
FGIdealAddLemma : {n m : ℕ} (U : FinVec R n) (V : FinVec R m)
→ ⟨ U ++Fin V ⟩ ≡ ⟨ U ⟩ +i ⟨ V ⟩
FGIdealAddLemma U V = CommIdeal≡Char (FGIdealAddLemmaLIncl U V) (FGIdealAddLemmaRIncl U V)
IdealAddAssoc : {n m k : ℕ} (U : FinVec R n) (V : FinVec R m) (W : FinVec R k)
→ ⟨ U ++Fin (V ++Fin W) ⟩ ≡ ⟨ (U ++Fin V) ++Fin W ⟩
IdealAddAssoc {n = n} {m = m} {k = k} U V W =
let genIdealExpl : (n : ℕ) → FinVec R n → CommIdeal
genIdealExpl _ V = ⟨ V ⟩
in cong₂ genIdealExpl (+ℕ-assoc n m k) (++FinAssoc U V W)
++FinComm : ∀ {n m : ℕ} (V : FinVec R n) (W : FinVec R m)
→ ⟨ V ++Fin W ⟩ ≡ ⟨ W ++Fin V ⟩
++FinComm V W = FGIdealAddLemma V W ∙∙ +iComm ⟨ V ⟩ ⟨ W ⟩ ∙∙ sym (FGIdealAddLemma W V)
open ProdFin R'
prodIn··Ideal : {n m : ℕ} (U : FinVec R n) (V : FinVec R m) (x y : R)
→ (x ∈ ⟨ U ⟩) → (y ∈ ⟨ V ⟩) → (x · y) ∈ ⟨ U ··Fin V ⟩
prodIn··Ideal {n = n} {m = m} U V x y = map2 Σhelper
where
Σhelper : Σ[ α ∈ FinVec R n ] x ≡ linearCombination R' α U
→ Σ[ β ∈ FinVec R m ] y ≡ linearCombination R' β V
→ Σ[ γ ∈ FinVec R (n ·ℕ m) ] (x · y) ≡ linearCombination R' γ (U ··Fin V)
Σhelper (α , x≡∑αU) (β , y≡∑βV) = α ··Fin β , path
where
path : x · y ≡ ∑ λ i → (α ··Fin β) i · (U ··Fin V) i
path = x · y ≡⟨ cong₂ (_·_) x≡∑αU y≡∑βV ⟩
(∑ λ i → α i · U i) · (∑ λ i → β i · V i) ≡⟨ ∑Dist··Fin (λ i → α i · U i) _ ⟩
(∑ λ j → ((λ i → α i · U i) ··Fin (λ i → β i · V i)) j) ≡⟨ ∑Ext (·Dist··Fin α U β V) ⟩
(∑ λ i → (α ··Fin β) i · (U ··Fin V) i) ∎
FGIdealMultLemmaLIncl : {n m : ℕ} (U : FinVec R n) (V : FinVec R m)
→ ⟨ U ··Fin V ⟩ ⊆ (⟨ U ⟩ ·i ⟨ V ⟩)
FGIdealMultLemmaLIncl U V x = elim (λ _ → isPropPropTrunc)
λ (α , x≡∑αUV) → subst-∈ (⟨ U ⟩ ·i ⟨ V ⟩) (sym x≡∑αUV) --replace x by ∑αᵢⱼUᵢVⱼ
(∑Closed (⟨ U ⟩ ·i ⟨ V ⟩) (λ i → α i · (U ··Fin V) i) --show that each αᵢ(U··V)ᵢ is in product
λ i → (⟨ U ⟩ ·i ⟨ V ⟩) .snd .·Closed (α i) --drop the α's
(flattenElim {P = _∈ (⟨ U ⟩ ·i ⟨ V ⟩)} (toMatrix U V) --show theat UᵢVⱼ is in product
(λ j k → prodInProd ⟨ U ⟩ ⟨ V ⟩ (U j) (V k) (indInIdeal U j) (indInIdeal V k)) i))
FGIdealMultLemmaRIncl : {n m : ℕ} (U : FinVec R n) (V : FinVec R m)
→ (⟨ U ⟩ ·i ⟨ V ⟩) ⊆ ⟨ U ··Fin V ⟩
FGIdealMultLemmaRIncl U V x = elim (λ _ → isPropPropTrunc)
λ (_ , (α , β) , ∀α∈⟨U⟩ , ∀β∈⟨V⟩ , x≡∑αβ) → subst-∈ ⟨ U ··Fin V ⟩ (sym x≡∑αβ)
(∑Closed ⟨ U ··Fin V ⟩ _ (λ i → prodIn··Ideal U V (α i) (β i) (∀α∈⟨U⟩ i) (∀β∈⟨V⟩ i)))
FGIdealMultLemma : {n m : ℕ} (U : FinVec R n) (V : FinVec R m)
→ ⟨ U ··Fin V ⟩ ≡ ⟨ U ⟩ ·i ⟨ V ⟩
FGIdealMultLemma U V = CommIdeal≡Char (FGIdealMultLemmaLIncl U V) (FGIdealMultLemmaRIncl U V)
| {
"alphanum_fraction": 0.5063878194,
"avg_line_length": 45.712,
"ext": "agda",
"hexsha": "0bd4c5e6fc6f6713798322fb1948d0522172ae76",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "8d687c1a6237ad2db1396c6b0af6667bd203f548",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dolio/cubical",
"max_forks_repo_path": "Cubical/Algebra/CommRing/FGIdeal.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "8d687c1a6237ad2db1396c6b0af6667bd203f548",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "dolio/cubical",
"max_issues_repo_path": "Cubical/Algebra/CommRing/FGIdeal.agda",
"max_line_length": 102,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "8d687c1a6237ad2db1396c6b0af6667bd203f548",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "dolio/cubical",
"max_stars_repo_path": "Cubical/Algebra/CommRing/FGIdeal.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 4590,
"size": 11428
} |
open import MJ.Types as Types
import MJ.Classtable.Core as Core
module MJ.Semantics.Objects {c}(Ct : Core.Classtable c) where
open import Prelude
open import Level renaming (suc to lsuc; zero to lzero)
open import Data.List
open import Data.List.Relation.Unary.All
open import Data.List.Prefix
open Core c
open Classtable Ct
open import MJ.Classtable.Membership Ct
open import MJ.Semantics.Values Ct
open import MJ.LexicalScope c
{-
Abstract interface for object encodings.
-}
record ObjEncoding : Set (lsuc lzero) where
field
Obj : World c → Cid c → Set
weaken-obj : ∀ {W W'} cid → W' ⊒ W → Obj W cid → Obj W' cid
getter : ∀ {W m a} c → Obj W c → IsMember c FIELD m a → Val W a
setter : ∀ {W m a} c → Obj W c → IsMember c FIELD m a → Val W a → Obj W c
defaultObject : ∀ {W} c → Obj W c
data StoreVal (W : World c) : Ty⁺ c → Set where
val : ∀ {ty} → Val W ty → StoreVal W (vty ty)
obj : ∀ cid → Obj W cid → StoreVal W (obj cid)
Store : World c → Set
Store W = All (StoreVal W) W
| {
"alphanum_fraction": 0.6656891496,
"avg_line_length": 27.6486486486,
"ext": "agda",
"hexsha": "f6d211a174f1bae263e45a26cd3d7b59f10ea714",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z",
"max_forks_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "metaborg/mj.agda",
"max_forks_repo_path": "src/MJ/Semantics/Objects.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z",
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "metaborg/mj.agda",
"max_issues_repo_path": "src/MJ/Semantics/Objects.agda",
"max_line_length": 77,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "metaborg/mj.agda",
"max_stars_repo_path": "src/MJ/Semantics/Objects.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z",
"num_tokens": 328,
"size": 1023
} |
postulate
Nat : Set
Fin : Nat → Set
Foo : (n : Nat) → Fin n → Set
private
module M where
variable
n : Nat
m : Fin _
postulate
Bar : Foo n m → Set
open M public using (Bar)
variable
n : Nat
m : Fin _
l : Foo n m
before : Bar l
before {n} {m} {l} = {!C-c C-e!}
after : Bar l
after {n} {m} {l} = {!C-c C-e!}
| {
"alphanum_fraction": 0.5263157895,
"avg_line_length": 11.7931034483,
"ext": "agda",
"hexsha": "b7ab9eb5b225ffcb07b6cd20d70a7a6188a795a1",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-04-01T18:30:09.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-04-01T18:30:09.000Z",
"max_forks_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "hborum/agda",
"max_forks_repo_path": "test/interaction/Issue3110.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"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": "hborum/agda",
"max_issues_repo_path": "test/interaction/Issue3110.agda",
"max_line_length": 32,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "hborum/agda",
"max_stars_repo_path": "test/interaction/Issue3110.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 134,
"size": 342
} |
{-# OPTIONS --safe #-}
module Cubical.Algebra.CommRing.Instances.UnivariatePoly where
open import Cubical.Foundations.Prelude
open import Cubical.Data.Nat using (ℕ ; zero ; suc)
open import Cubical.Algebra.CommRing
open import Cubical.Algebra.Polynomials.Univariate.Base
open import Cubical.Algebra.Polynomials.Univariate.Properties
private
variable
ℓ : Level
UnivariatePoly : (CommRing ℓ) → CommRing ℓ
UnivariatePoly R = (PolyMod.Poly R) , str
where
open CommRingStr --(snd R)
str : CommRingStr (PolyMod.Poly R)
0r str = PolyModTheory.0P R
1r str = PolyModTheory.1P R
_+_ str = PolyModTheory._Poly+_ R
_·_ str = PolyModTheory._Poly*_ R
- str = PolyModTheory.Poly- R
isCommRing str = makeIsCommRing (PolyMod.isSetPoly R)
(PolyModTheory.Poly+Assoc R)
(PolyModTheory.Poly+Rid R)
(PolyModTheory.Poly+Inverses R)
(PolyModTheory.Poly+Comm R)
(PolyModTheory.Poly*Associative R)
(PolyModTheory.Poly*Rid R)
(PolyModTheory.Poly*LDistrPoly+ R)
(PolyModTheory.Poly*Commutative R)
nUnivariatePoly : (A' : CommRing ℓ) → (n : ℕ) → CommRing ℓ
nUnivariatePoly A' zero = A'
nUnivariatePoly A' (suc n) = UnivariatePoly (nUnivariatePoly A' n)
| {
"alphanum_fraction": 0.583277592,
"avg_line_length": 36.4634146341,
"ext": "agda",
"hexsha": "bdba5b10af2d3b3cf98014ad6b52275eb62dbde8",
"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": "ce3120d3f8d692847b2744162bcd7a01f0b687eb",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "guilhermehas/cubical",
"max_forks_repo_path": "Cubical/Algebra/CommRing/Instances/UnivariatePoly.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ce3120d3f8d692847b2744162bcd7a01f0b687eb",
"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": "guilhermehas/cubical",
"max_issues_repo_path": "Cubical/Algebra/CommRing/Instances/UnivariatePoly.agda",
"max_line_length": 72,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "ce3120d3f8d692847b2744162bcd7a01f0b687eb",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "guilhermehas/cubical",
"max_stars_repo_path": "Cubical/Algebra/CommRing/Instances/UnivariatePoly.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": 391,
"size": 1495
} |
module Utils.NatOrdLemmas where
open import Data.Nat.Properties.Simple
open import Data.Nat
open import Data.Empty
open import Relation.Binary.PropositionalEquality
open import Relation.Nullary
open import Function
{- Just a bunch of lemmas about the standard ordering on naturals -}
data Cmp (a b : ℕ) : Set where
LT : a Data.Nat.< b → Cmp a b
EQ : a ≡ b → Cmp a b
GT : a > b → Cmp a b
cmp : ∀ a b → Cmp a b
cmp zero zero = EQ refl
cmp zero (suc b) = LT (s≤s z≤n)
cmp (suc a) zero = GT (s≤s z≤n)
cmp (suc a) (suc b) with cmp a b
cmp (suc a) (suc b) | LT x = LT (s≤s x)
cmp (suc a) (suc .a) | EQ refl = EQ refl
cmp (suc a) (suc b) | GT x = GT (s≤s x)
a≮a : ∀ a → ¬ (a < a)
a≮a zero ()
a≮a (suc a) (s≤s p) = a≮a a p
<-weakenr1 : ∀ a b → a < b → a < suc b
<-weakenr1 zero b p = s≤s z≤n
<-weakenr1 (suc a) zero ()
<-weakenr1 (suc a) (suc b) (s≤s p) = s≤s (<-weakenr1 a b p)
<-weakenr : ∀ c a b → a < b → a < c + b
<-weakenr zero a b p = p
<-weakenr (suc c) a b p = <-weakenr1 a (c + b) (<-weakenr c a b p)
<-weakenl1 : ∀ a b → suc a < b → a < b
<-weakenl1 zero ._ (s≤s p) = s≤s z≤n
<-weakenl1 (suc a) zero ()
<-weakenl1 (suc a) (suc b) (s≤s p) = s≤s (<-weakenl1 a b p)
<-weakenl : ∀ c a b → c + a < b → a < b
<-weakenl zero a b p = p
<-weakenl (suc c) a b p = <-weakenl c a b (<-weakenl1 (c + a) b p)
a≢sa : (a : ℕ) → a ≢ suc a
a≢sa a ()
a<b⟶a≢sb : ∀ a b → a < b → a ≢ suc b
a<b⟶a≢sb zero b p1 ()
a<b⟶a≢sb (suc ._) ._ (s≤s p1) refl = a<b⟶a≢sb _ _ p1 refl
a<v⟶a≢c+b : ∀ c a b → a < b → a ≢ c + b
a<v⟶a≢c+b zero a .a p1 refl = a≮a a p1
a<v⟶a≢c+b (suc c) a b p1 p2 = a<b⟶a≢sb a (c + b) (<-weakenr c a b p1) p2
a<sb+a : ∀ a b → a < suc b + a
a<sb+a zero b = s≤s z≤n
a<sb+a (suc a) b rewrite +-suc b a = s≤s (a<sb+a a b)
a<b+sa : ∀ a b → a < b + suc a
a<b+sa a b rewrite +-suc b a = a<sb+a a b
≤-strict : ∀ a b → a ≤ b → a ≢ b → a < b
≤-strict zero zero z≤n p2 = ⊥-elim (p2 refl)
≤-strict zero (suc b) z≤n p2 = s≤s z≤n
≤-strict (suc a) zero () p2
≤-strict (suc a) (suc b) (s≤s p1) p2 = s≤s (≤-strict a b p1 (p2 ∘ cong suc))
a≢sa+b : ∀ a b → a ≢ suc a + b
a≢sa+b zero b ()
a≢sa+b (suc a) b p = a≢sa+b a b $ cong pred p
a≢sb+a : ∀ a b → a ≢ suc b + a
a≢sb+a a b p rewrite +-comm b a = a≢sa+b a b p
| {
"alphanum_fraction": 0.5395390872,
"avg_line_length": 28.0126582278,
"ext": "agda",
"hexsha": "ec7f60ef72453c20d66b11499809454e3f1d6b0a",
"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": "05200d60b4a4b2c6fa37806ced9247055d24db94",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "AndrasKovacs/SemanticsWithApplications",
"max_forks_repo_path": "Utils/NatOrdLemmas.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "05200d60b4a4b2c6fa37806ced9247055d24db94",
"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": "AndrasKovacs/SemanticsWithApplications",
"max_issues_repo_path": "Utils/NatOrdLemmas.agda",
"max_line_length": 76,
"max_stars_count": 8,
"max_stars_repo_head_hexsha": "05200d60b4a4b2c6fa37806ced9247055d24db94",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "AndrasKovacs/SemanticsWithApplications",
"max_stars_repo_path": "Utils/NatOrdLemmas.agda",
"max_stars_repo_stars_event_max_datetime": "2020-02-02T10:01:52.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-09-12T04:25:39.000Z",
"num_tokens": 1123,
"size": 2213
} |
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import homotopy.PtdMapSequence
open import groups.HomSequence
open import cohomology.Theory
module cohomology.PtdMapSequence {i} (CT : CohomologyTheory i) where
open CohomologyTheory CT
-- FIXME maybe this should be named [ap-C-seq],
-- but I do not know how to name [C-seq-isemap]. -favonia
C-seq : ∀ {X Y : Ptd i} (n : ℤ)
→ PtdMapSequence X Y
→ HomSequence (C n Y) (C n X)
C-seq n (X ⊙⊣|) = C n X ⊣|ᴳ
C-seq n (X ⊙→⟨ f ⟩ seq) = HomSeq-snoc (C-seq n seq) (C-fmap n f)
C-comm-square : ∀ (n : ℤ) {X₀ X₁ Y₀ Y₁ : Ptd i}
→ {f₀ : X₀ ⊙→ Y₀} {f₁ : X₁ ⊙→ Y₁} {hX : X₀ ⊙→ X₁} {hY : Y₀ ⊙→ Y₁}
→ CommSquare (fst f₀) (fst f₁) (fst hX) (fst hY)
→ CommSquareᴳ (C-fmap n f₁) (C-fmap n f₀) (C-fmap n hY) (C-fmap n hX)
C-comm-square n {f₀ = f₀} {f₁} {hX} {hY} (comm-sqr □) = comm-sqrᴳ λ y₁ →
∘-CEl-fmap n hX f₁ y₁ ∙ CEl-fmap-base-indep' n (λ x → ! (□ x)) y₁ ∙ CEl-fmap-∘ n hY f₀ y₁
C-seq-fmap : ∀ {X₀ X₁ Y₀ Y₁ : Ptd i} (n : ℤ)
{seq₀ : PtdMapSequence X₀ Y₀} {seq₁ : PtdMapSequence X₁ Y₁}
{hX : X₀ ⊙→ X₁} {hY : Y₀ ⊙→ Y₁}
→ PtdMapSeqMap seq₀ seq₁ hX hY
→ HomSeqMap (C-seq n seq₁) (C-seq n seq₀) (C-fmap n hY) (C-fmap n hX)
C-seq-fmap n (hX ⊙↓|) = C-fmap n hX ↓|ᴳ
C-seq-fmap n (hX ⊙↓⟨ □ ⟩ seq) = HomSeqMap-snoc (C-seq-fmap n seq) (C-comm-square n □)
C-seq-isemap : ∀ {X₀ X₁ Y₀ Y₁ : Ptd i} (n : ℤ)
{seq₀ : PtdMapSequence X₀ Y₀} {seq₁ : PtdMapSequence X₁ Y₁}
{hX : X₀ ⊙→ X₁} {hY : Y₀ ⊙→ Y₁}
{seq-map : PtdMapSeqMap seq₀ seq₁ hX hY}
→ is-⊙seq-equiv seq-map
→ is-seqᴳ-equiv (C-seq-fmap n seq-map)
C-seq-isemap n {seq-map = h ⊙↓|} h-is-equiv = CEl-isemap n h h-is-equiv
C-seq-isemap n {seq-map = h ⊙↓⟨ □ ⟩ seq} (h-is-equiv , seq-is-equiv) =
is-seqᴳ-equiv-snoc (C-seq-isemap n seq-is-equiv) (CEl-isemap n h h-is-equiv)
C-seq-emap : ∀ {X₀ X₁ Y₀ Y₁ : Ptd i} (n : ℤ)
{seq₀ : PtdMapSequence X₀ Y₀} {seq₁ : PtdMapSequence X₁ Y₁}
{hX : X₀ ⊙→ X₁} {hY : Y₀ ⊙→ Y₁}
→ PtdMapSeqEquiv seq₀ seq₁ hX hY
→ HomSeqEquiv (C-seq n seq₁) (C-seq n seq₀) (C-fmap n hY) (C-fmap n hX)
C-seq-emap n (seq , seq-ise) = C-seq-fmap n seq , C-seq-isemap n seq-ise
| {
"alphanum_fraction": 0.5833714025,
"avg_line_length": 42.0961538462,
"ext": "agda",
"hexsha": "1427954189f82963b4f6260afc2d351c4e6e6262",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z",
"max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mikeshulman/HoTT-Agda",
"max_forks_repo_path": "theorems/cohomology/PtdMapSequence.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "mikeshulman/HoTT-Agda",
"max_issues_repo_path": "theorems/cohomology/PtdMapSequence.agda",
"max_line_length": 93,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mikeshulman/HoTT-Agda",
"max_stars_repo_path": "theorems/cohomology/PtdMapSequence.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1044,
"size": 2189
} |
module Structure.Category.Equiv where
import Lvl
open import Structure.Setoid
open import Structure.Category
-- TODO: https://en.wikipedia.org/wiki/Equivalence_of_categories
module _ {ℓₒ ℓₘ : Lvl.Level} {Obj : Type{ℓₒ}} (Morphism : Obj → Obj → Type{ℓₘ}) ⦃ morphism-equiv : ∀{x y} → Equiv(Morphism x y) ⦄ where
Category-equiv : Equiv(Category(Morphism))
Category-equiv
| {
"alphanum_fraction": 0.7244094488,
"avg_line_length": 31.75,
"ext": "agda",
"hexsha": "0d95dbc7b99a736244985d834f250a3e82fa6184",
"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/Category/Equiv.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/Category/Equiv.agda",
"max_line_length": 135,
"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/Category/Equiv.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": 118,
"size": 381
} |
{-# OPTIONS --without-K --safe #-}
module Definition.Conversion.FullReduction where
open import Definition.Untyped as U hiding (wk)
open import Definition.Untyped.Properties
open import Definition.Typed
open import Definition.Typed.Properties
open import Definition.Typed.Weakening
open import Definition.Conversion
open import Definition.Conversion.Whnf
open import Definition.Typed.Consequences.InverseUniv
open import Definition.Typed.Consequences.Syntactic
open import Definition.Typed.Consequences.NeTypeEq
open import Definition.Typed.Consequences.Substitution
open import Tools.Product
import Tools.PropositionalEquality as PE
mutual
data NfNeutral : Term → Set where
var : ∀ n → NfNeutral (var n)
∘ₙ : ∀ {k u} → NfNeutral k → Nf u → NfNeutral (k ∘ u)
fstₙ : ∀ {p} → NfNeutral p → NfNeutral (fst p)
sndₙ : ∀ {p} → NfNeutral p → NfNeutral (snd p)
natrecₙ : ∀ {C c g k} → Nf C → Nf c → Nf g → NfNeutral k
→ NfNeutral (natrec C c g k)
Emptyrecₙ : ∀ {C k} → Nf C → NfNeutral k → NfNeutral (Emptyrec C k)
data Nf : Term → Set where
Uₙ : Nf U
Πₙ : ∀ {A B} → Nf A → Nf B → Nf (Π A ▹ B)
Σₙ : ∀ {A B} → Nf A → Nf B → Nf (Σ A ▹ B)
ℕₙ : Nf ℕ
Emptyₙ : Nf Empty
Unitₙ : Nf Unit
lamₙ : ∀ {t} → Nf t → Nf (lam t)
prodₙ : ∀ {t u} → Nf t → Nf u → Nf (prod t u)
zeroₙ : Nf zero
sucₙ : ∀ {t} → Nf t → Nf (suc t)
starₙ : Nf star
ne : ∀ {n} → NfNeutral n → Nf n
mutual
fullRedNe : ∀ {t A Γ} → Γ ⊢ t ~ t ↑ A → ∃ λ u → NfNeutral u × Γ ⊢ t ≡ u ∷ A
fullRedNe (var-refl x _) = var _ , var _ , refl x
fullRedNe (app-cong t u) =
let t′ , nfT′ , t≡t′ = fullRedNe~↓ t
u′ , nfU′ , u≡u′ = fullRedTerm u
in (t′ ∘ u′) , (∘ₙ nfT′ nfU′) , app-cong t≡t′ u≡u′
fullRedNe (fst-cong p~p) =
let p′ , neP′ , p≡p′ = fullRedNe~↓ p~p
⊢ΣFG , _ , _ = syntacticEqTerm p≡p′
⊢F , ⊢G = syntacticΣ ⊢ΣFG
in fst p′ , fstₙ neP′ , fst-cong ⊢F ⊢G p≡p′
fullRedNe (snd-cong p~p) =
let p′ , neP′ , p≡p′ = fullRedNe~↓ p~p
⊢ΣFG , _ , _ = syntacticEqTerm p≡p′
⊢F , ⊢G = syntacticΣ ⊢ΣFG
in snd p′ , sndₙ neP′ , snd-cong ⊢F ⊢G p≡p′
fullRedNe (natrec-cong C z s n) =
let C′ , nfC′ , C≡C′ = fullRed C
z′ , nfZ′ , z≡z′ = fullRedTerm z
s′ , nfS′ , s≡s′ = fullRedTerm s
n′ , nfN′ , n≡n′ = fullRedNe~↓ n
in natrec C′ z′ s′ n′ , natrecₙ nfC′ nfZ′ nfS′ nfN′
, natrec-cong C≡C′ z≡z′ s≡s′ n≡n′
fullRedNe (Emptyrec-cong C n) =
let C′ , nfC′ , C≡C′ = fullRed C
n′ , nfN′ , n≡n′ = fullRedNe~↓ n
in Emptyrec C′ n′ , Emptyrecₙ nfC′ nfN′
, Emptyrec-cong C≡C′ n≡n′
fullRedNe~↓ : ∀ {t A Γ} → Γ ⊢ t ~ t ↓ A → ∃ λ u → NfNeutral u × Γ ⊢ t ≡ u ∷ A
fullRedNe~↓ ([~] A D whnfB k~l) =
let u , nf , t≡u = fullRedNe k~l
in u , nf , conv t≡u (subset* D)
fullRed : ∀ {A Γ} → Γ ⊢ A [conv↑] A → ∃ λ B → Nf B × Γ ⊢ A ≡ B
fullRed ([↑] A′ B′ D D′ whnfA′ whnfB′ A′<>B′)
rewrite whrDet* (D , whnfA′) (D′ , whnfB′) =
let B″ , nf , B′≡B″ = fullRedConv↓ A′<>B′
in B″ , nf , trans (subset* D′) B′≡B″
fullRedConv↓ : ∀ {A Γ} → Γ ⊢ A [conv↓] A → ∃ λ B → Nf B × Γ ⊢ A ≡ B
fullRedConv↓ (U-refl ⊢Γ) = U , Uₙ , refl (Uⱼ ⊢Γ)
fullRedConv↓ (ℕ-refl ⊢Γ) = ℕ , ℕₙ , refl (ℕⱼ ⊢Γ)
fullRedConv↓ (Empty-refl ⊢Γ) = Empty , Emptyₙ , refl (Emptyⱼ ⊢Γ)
fullRedConv↓ (Unit-refl ⊢Γ) = Unit , Unitₙ , refl (Unitⱼ ⊢Γ)
fullRedConv↓ (ne A) =
let B , nf , A≡B = fullRedNe~↓ A
in B , ne nf , univ A≡B
fullRedConv↓ (Π-cong ⊢F F G) =
let F′ , nfF′ , F≡F′ = fullRed F
G′ , nfG′ , G≡G′ = fullRed G
in Π F′ ▹ G′ , Πₙ nfF′ nfG′ , Π-cong ⊢F F≡F′ G≡G′
fullRedConv↓ (Σ-cong ⊢F F G) =
let F′ , nfF′ , F≡F′ = fullRed F
G′ , nfG′ , G≡G′ = fullRed G
in Σ F′ ▹ G′ , Σₙ nfF′ nfG′ , Σ-cong ⊢F F≡F′ G≡G′
fullRedTerm : ∀ {t A Γ} → Γ ⊢ t [conv↑] t ∷ A → ∃ λ u → Nf u × Γ ⊢ t ≡ u ∷ A
fullRedTerm ([↑]ₜ B t′ u′ D d d′ whnfB whnft′ whnfu′ t<>u)
rewrite whrDet*Term (d , whnft′) (d′ , whnfu′) =
let u″ , nf , u′≡u″ = fullRedTermConv↓ t<>u
in u″ , nf , conv (trans (subset*Term d′) u′≡u″) (sym (subset* D))
fullRedTermConv↓ : ∀ {t A Γ} → Γ ⊢ t [conv↓] t ∷ A → ∃ λ u → Nf u × Γ ⊢ t ≡ u ∷ A
fullRedTermConv↓ (ℕ-ins t) =
let u , nf , t≡u = fullRedNe~↓ t
in u , ne nf , t≡u
fullRedTermConv↓ (Empty-ins t) =
let u , nf , t≡u = fullRedNe~↓ t
in u , ne nf , t≡u
fullRedTermConv↓ (Unit-ins t) =
let u , nf , t≡u = fullRedNe~↓ t
in u , ne nf , t≡u
fullRedTermConv↓ (ne-ins ⊢t _ _ t) =
let u , nfU , t≡u = fullRedNe~↓ t
_ , ⊢t∷M , _ = syntacticEqTerm t≡u
_ , neT , _ = ne~↓ t
in u , ne nfU , conv t≡u (neTypeEq neT ⊢t∷M ⊢t)
fullRedTermConv↓ (univ ⊢t _ t) =
let u , nf , t≡u = fullRedConv↓ t
in u , nf , inverseUnivEq ⊢t t≡u
fullRedTermConv↓ (zero-refl ⊢Γ) = zero , zeroₙ , refl (zeroⱼ ⊢Γ)
fullRedTermConv↓ (suc-cong t) =
let u , nf , t≡u = fullRedTerm t
in suc u , sucₙ nf , suc-cong t≡u
fullRedTermConv↓ (η-eq ⊢t _ _ _ t∘0) =
let u , nf , t∘0≡u = fullRedTerm t∘0
_ , _ , ⊢u = syntacticEqTerm t∘0≡u
⊢F , _ = syntacticΠ (syntacticTerm ⊢t)
ΓF⊢ = wf ⊢F ∙ ⊢F
wk⊢F = wk (step id) ΓF⊢ ⊢F
ΓFF'⊢ = ΓF⊢ ∙ wk⊢F
wk⊢u = wkTerm (lift (step id)) ΓFF'⊢ ⊢u
λu∘0 = lam (U.wk (lift (step id)) u) ∘ var 0
in lam u , lamₙ nf
, η-eq ⊢F ⊢t (lamⱼ ⊢F ⊢u)
(trans t∘0≡u (PE.subst₂ (λ x y → _ ⊢ x ≡ λu∘0 ∷ y)
(wkSingleSubstId u) (wkSingleSubstId _)
(sym (β-red wk⊢F wk⊢u (var ΓF⊢ here)))))
fullRedTermConv↓ (Σ-η ⊢t _ tProd _ fstConv sndConv) =
let fst′ , nfFst′ , fst≡fst′ = fullRedTerm fstConv
snd′ , nfSnd′ , snd≡snd′ = fullRedTerm sndConv
_ , _ , ⊢fst′ = syntacticEqTerm fst≡fst′
_ , _ , ⊢snd′₁ = syntacticEqTerm snd≡snd′
⊢ΣFG = syntacticTerm ⊢t
⊢F , ⊢G = syntacticΣ ⊢ΣFG
Gfst≡Gfst′ = substTypeEq (refl ⊢G) fst≡fst′
⊢snd′ = conv ⊢snd′₁ Gfst≡Gfst′
⊢prod = prodⱼ ⊢F ⊢G ⊢fst′ ⊢snd′
fstprod≡fst′ = Σ-β₁ ⊢F ⊢G ⊢fst′ ⊢snd′
fst≡fstprod = trans fst≡fst′ (sym fstprod≡fst′)
Gfst≡Gfstprod = substTypeEq (refl ⊢G) fst≡fstprod
sndprod≡snd′ = conv (Σ-β₂ ⊢F ⊢G ⊢fst′ ⊢snd′) (sym Gfst≡Gfstprod)
snd≡sndprod = trans snd≡snd′ (sym sndprod≡snd′)
in prod fst′ snd′ , prodₙ nfFst′ nfSnd′
, Σ-η ⊢F ⊢G ⊢t ⊢prod fst≡fstprod snd≡sndprod
fullRedTermConv↓ (η-unit ⊢t _ tUnit _) =
star , starₙ , η-unit ⊢t (starⱼ (wfTerm ⊢t))
| {
"alphanum_fraction": 0.520370094,
"avg_line_length": 39.650887574,
"ext": "agda",
"hexsha": "2c495b0d5062fc89647138dd7cf26067fe30bdcc",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Vtec234/logrel-mltt",
"max_forks_repo_path": "Definition/Conversion/FullReduction.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Vtec234/logrel-mltt",
"max_issues_repo_path": "Definition/Conversion/FullReduction.agda",
"max_line_length": 83,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Vtec234/logrel-mltt",
"max_stars_repo_path": "Definition/Conversion/FullReduction.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3094,
"size": 6701
} |
{-# 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.Primes.Definition {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} {R : Ring S _+_ _*_} (intDom : IntegralDomain R) where
open import Rings.Divisible.Definition R
open Ring R
open Setoid S
open import Rings.Units.Definition R
record Prime (x : A) : Set (a ⊔ b) where
field
isPrime : (r s : A) → (x ∣ (r * s)) → ((x ∣ r) → False) → (x ∣ s)
nonzero : (x ∼ 0R) → False
nonunit : Unit x → False
| {
"alphanum_fraction": 0.6534508076,
"avg_line_length": 30.9545454545,
"ext": "agda",
"hexsha": "adee8eda95577cdb53a2b384459c2c8c4c03a4b4",
"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/Primes/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/Primes/Definition.agda",
"max_line_length": 152,
"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/Primes/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": 231,
"size": 681
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Properties of operations on characters
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Char.Properties where
open import Data.Bool.Base using (Bool)
open import Data.Char.Base
import Data.Nat.Base as ℕ
import Data.Nat.Properties as ℕₚ
open import Function
open import Relation.Nullary using (yes; no)
open import Relation.Nullary.Decidable using (map′; isYes)
open import Relation.Binary
open import Relation.Binary.PropositionalEquality.Core
import Relation.Binary.Construct.On as On
import Relation.Binary.PropositionalEquality as PropEq
------------------------------------------------------------------------
-- Primitive properties
open import Agda.Builtin.Char.Properties
renaming ( primCharToNatInjective to toℕ-injective)
public
------------------------------------------------------------------------
-- Properties of _≈_
≈⇒≡ : _≈_ ⇒ _≡_
≈⇒≡ = toℕ-injective _ _
≈-reflexive : _≡_ ⇒ _≈_
≈-reflexive = cong toℕ
≈-refl : Reflexive _≈_
≈-refl = refl
≈-sym : Symmetric _≈_
≈-sym = sym
≈-trans : Transitive _≈_
≈-trans = trans
≈-subst : ∀ {ℓ} → Substitutive _≈_ ℓ
≈-subst P x≈y p = subst P (≈⇒≡ x≈y) p
infix 4 _≈?_
_≈?_ : Decidable _≈_
x ≈? y = toℕ x ℕₚ.≟ toℕ y
≈-isEquivalence : IsEquivalence _≈_
≈-isEquivalence = record
{ refl = λ {i} → ≈-refl {i}
; sym = λ {i j} → ≈-sym {i} {j}
; trans = λ {i j k} → ≈-trans {i} {j} {k}
}
≈-setoid : Setoid _ _
≈-setoid = record
{ isEquivalence = ≈-isEquivalence
}
≈-isDecEquivalence : IsDecEquivalence _≈_
≈-isDecEquivalence = record
{ isEquivalence = ≈-isEquivalence
; _≟_ = _≈?_
}
≈-decSetoid : DecSetoid _ _
≈-decSetoid = record
{ isDecEquivalence = ≈-isDecEquivalence
}
------------------------------------------------------------------------
-- Properties of _≡_
infix 4 _≟_
_≟_ : Decidable {A = Char} _≡_
x ≟ y = map′ ≈⇒≡ ≈-reflexive (x ≈? y)
≡-setoid : Setoid _ _
≡-setoid = PropEq.setoid Char
≡-decSetoid : DecSetoid _ _
≡-decSetoid = PropEq.decSetoid _≟_
------------------------------------------------------------------------
-- Boolean equality test.
--
-- Why is the definition _==_ = primCharEquality not used? One reason
-- is that the present definition can sometimes improve type
-- inference, at least with the version of Agda that is current at the
-- time of writing: see unit-test below.
infix 4 _==_
_==_ : Char → Char → Bool
c₁ == c₂ = isYes (c₁ ≟ c₂)
private
-- The following unit test does not type-check (at the time of
-- writing) if _==_ is replaced by primCharEquality.
data P : (Char → Bool) → Set where
p : (c : Char) → P (c ==_)
unit-test : P ('x' ==_)
unit-test = p _
------------------------------------------------------------------------
-- Properties of _<_
infix 4 _<?_
_<?_ : Decidable _<_
_<?_ = On.decidable toℕ ℕ._<_ ℕₚ._<?_
<-isStrictPartialOrder-≈ : IsStrictPartialOrder _≈_ _<_
<-isStrictPartialOrder-≈ = On.isStrictPartialOrder toℕ ℕₚ.<-isStrictPartialOrder
<-isStrictTotalOrder-≈ : IsStrictTotalOrder _≈_ _<_
<-isStrictTotalOrder-≈ = On.isStrictTotalOrder toℕ ℕₚ.<-isStrictTotalOrder
<-strictPartialOrder-≈ : StrictPartialOrder _ _ _
<-strictPartialOrder-≈ = On.strictPartialOrder ℕₚ.<-strictPartialOrder toℕ
<-strictTotalOrder-≈ : StrictTotalOrder _ _ _
<-strictTotalOrder-≈ = On.strictTotalOrder ℕₚ.<-strictTotalOrder toℕ
------------------------------------------------------------------------
-- DEPRECATED NAMES
------------------------------------------------------------------------
-- Please use the new names as continuing support for the old names is
-- not guaranteed.
-- Version 1.1
toNat-injective = toℕ-injective
{-# WARNING_ON_USAGE toℕ-injective
"Warning: toNat-injective was deprecated in v1.1.
Please use toℕ-injective instead."
#-}
setoid = ≡-setoid
{-# WARNING_ON_USAGE setoid
"Warning: setoid was deprecated in v1.1.
Please use ≡-setoid instead."
#-}
decSetoid = ≡-decSetoid
{-# WARNING_ON_USAGE decSetoid
"Warning: decSetoid was deprecated in v1.1.
Please use ≡-decSetoid instead."
#-}
strictTotalOrder = <-strictTotalOrder-≈
{-# WARNING_ON_USAGE strictTotalOrder
"Warning: strictTotalOrder was deprecated in v1.1.
Please use <-strictTotalOrder-≈ instead."
#-}
| {
"alphanum_fraction": 0.5931891394,
"avg_line_length": 26.1807228916,
"ext": "agda",
"hexsha": "86c6db9c14955918c874907fb649d3bbd4fe1161",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DreamLinuxer/popl21-artifact",
"max_forks_repo_path": "agda-stdlib/src/Data/Char/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DreamLinuxer/popl21-artifact",
"max_issues_repo_path": "agda-stdlib/src/Data/Char/Properties.agda",
"max_line_length": 80,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DreamLinuxer/popl21-artifact",
"max_stars_repo_path": "agda-stdlib/src/Data/Char/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z",
"num_tokens": 1308,
"size": 4346
} |
module Dave.Logic.Bool where
data Bool : Set where
false : Bool
true : Bool
¬_ : Bool → Bool
¬ true = false
¬ false = true
_∧_ : Bool → Bool → Bool
a ∧ true = a
a ∧ false = false
if_then_else_ : {A : Set} → Bool → A → A → A
if false then a else b = b
if true then a else b = a
identity : {A : Set} → A → A
identity a = a
| {
"alphanum_fraction": 0.4974874372,
"avg_line_length": 18.9523809524,
"ext": "agda",
"hexsha": "18749005038c4224dd0b5dabb5fc0301239f4ae8",
"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": "05213fb6ab1f51f770f9858b61526ba950e06232",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DavidStahl97/formal-proofs",
"max_forks_repo_path": "Dave/Logic/Bool.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "05213fb6ab1f51f770f9858b61526ba950e06232",
"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": "DavidStahl97/formal-proofs",
"max_issues_repo_path": "Dave/Logic/Bool.agda",
"max_line_length": 48,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "05213fb6ab1f51f770f9858b61526ba950e06232",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DavidStahl97/formal-proofs",
"max_stars_repo_path": "Dave/Logic/Bool.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 128,
"size": 398
} |
{-# OPTIONS --safe --warning=error --without-K #-}
open import LogicalFormulae
open import Setoids.Setoids
open import Rings.Definition
open import Rings.IntegralDomains.Definition
open import Vectors
open import Numbers.Naturals.Semiring
open import Numbers.Naturals.Order
open import Numbers.Naturals.Definition
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
module Rings.UniqueFactorisationDomains.Definition {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} {R : Ring S _+_ _*_} (intDom : IntegralDomain R) where
open import Rings.Units.Definition R
open import Rings.Irreducibles.Definition intDom
open import Rings.Associates.Definition intDom
open import Rings.Primes.Definition intDom
open Ring R
open Setoid S
private
power : A → ℕ → A
power x zero = 1R
power x (succ n) = x * power x n
allDistinct : {n : ℕ} → Vec A n → Set (a ⊔ b)
allDistinct [] = True'
allDistinct (x ,- xs) = (allDistinct xs) && vecAllTrue (λ n → (n ∼ x) → False) xs
record Factorisation {r : A} .(nonzero : (r ∼ 0R) → False) .(nonunit : (Unit r) → False) : Set (a ⊔ b) where
field
len : ℕ
factorise : Vec (A && ℕ) len
factoriseIsFactorisation : vecFold (λ x y → y * power (_&&_.fst x) (succ (_&&_.snd x))) 1R factorise ∼ r
factoriseIsIrreducibles : vecAllTrue Irreducible (vecMap _&&_.fst factorise)
distinct : allDistinct (vecMap _&&_.fst factorise)
private
equality : {n : ℕ} (v1 v2 : Vec (A && ℕ) n) → Set (a ⊔ b)
equality [] [] = True'
equality {succ n} ((a ,, an) ,- v1) v2 = Sg ℕ (λ index → Sg (index <N succ n) (λ i<n → (Associates (_&&_.fst (vecIndex v2 index i<n)) a) && ((_&&_.snd (vecIndex v2 index i<n) ≡ an) && equality v1 (vecDelete index i<n v2))))
factorisationEquality : {r : A} → .{nonzero : (r ∼ 0R) → False} → .{nonunit : (Unit r) → False} → Factorisation nonzero nonunit → Factorisation nonzero nonunit → Set (a ⊔ b)
factorisationEquality record { len = lenA ; factorise = factoriseA ; factoriseIsFactorisation = factoriseIsFactorisationA ; factoriseIsIrreducibles = factoriseIsIrreduciblesA ; distinct = distinctA } record { len = lenB ; factorise = factoriseB ; factoriseIsFactorisation = factoriseIsFactorisationB ; factoriseIsIrreducibles = factoriseIsIrreduciblesB ; distinct = distinctB } with ℕDecideEquality lenA lenB
factorisationEquality record { len = a ; factorise = factoriseA } record { len = .a ; factorise = factoriseB } | inl refl = equality factoriseA factoriseB
factorisationEquality record { len = a ; factorise = factoriseA } record { len = b ; factorise = factoriseB } | inr _ = False'
record UFD : Set (a ⊔ b) where
field
factorisation : {r : A} → (nonzero : (r ∼ 0R) → False) → (nonunit : (Unit r) → False) → Factorisation nonzero nonunit
uniqueFactorisation : {r : A} → (nonzero : (r ∼ 0R) → False) → (nonunit : (Unit r) → False) → (f1 f2 : Factorisation nonzero nonunit) → factorisationEquality f1 f2
record UFD' : Set (a ⊔ b) where
field
factorisation : {r : A} → (nonzero : (r ∼ 0R) → False) → (nonunit : (Unit r) → False) → Factorisation nonzero nonunit
irreduciblesArePrime : {r : A} → Irreducible r → Prime r
| {
"alphanum_fraction": 0.6839592616,
"avg_line_length": 53.2542372881,
"ext": "agda",
"hexsha": "2048777696af76034b2e22d499df9950f944f3c0",
"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/UniqueFactorisationDomains/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/UniqueFactorisationDomains/Definition.agda",
"max_line_length": 408,
"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/UniqueFactorisationDomains/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": 1029,
"size": 3142
} |
module Oscar.Function where
open import Function public using (id; _∘_; _∘′_; flip; _on_; _$_) renaming (const to const_)
infix -1 _∋_
_∋_ : ∀ {a} (A : Set a) → A → A
_ ∋ x = x
open import Prelude.Function public using (it)
| {
"alphanum_fraction": 0.6535087719,
"avg_line_length": 20.7272727273,
"ext": "agda",
"hexsha": "80179b4d0d315872ef8af97ebf349b5c1234cfc2",
"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/Function.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/Function.agda",
"max_line_length": 93,
"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/Function.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 82,
"size": 228
} |
{-# OPTIONS --no-termination-check #-}
module PiMeadow where
open import Level
open import Data.Empty
open import Data.Unit
open import Data.Sum
open import Data.Product
open import Relation.Binary.PropositionalEquality
-- infixr 20 _◎_
{-
postulate
A : Set
a b c : A
p : a ≡ b
q : b ≡ c
data <_> {a : Level} {A : Set a} (x : A) : Set a where
singleton : {y : A} → y ≡ x -> < x >
irr : singleton {_} {A} {b} p ≡ singleton {_} {A} {b} (sym q)
irr = {!!}
-}
data <_> {a : Level} {A : Set a} (x : A) : Set a where
singleton : {y : A} → y ≡ x -> < x >
-- Courtesy of Wolfram Kahl, a dependent cong₂
cong₂D : {a b c : Level} {A : Set a} {B : A → Set b} {C : Set c} (f : (x : A) → B x → C)
→ {x₁ x₂ : A} {y₁ : B x₁} {y₂ : B x₂}
→ (x₁≡x₂ : x₁ ≡ x₂) → y₁ ≡ subst B (sym x₁≡x₂) y₂ → f x₁ y₁ ≡ f x₂ y₂
cong₂D f refl refl = refl
mutual
data B : Set₁ where
ZERO : B
ONE : B
PLUS : B → B → B
TIMES : B → B → B
SING : (b : B) → ⟦ b ⟧ → B
RECIP : (b : B) → ⟦ b ⟧ → B
DPAIR : (b : B) → (⟦ b ⟧ → B) → B
⟦_⟧ : B → Set
⟦ ZERO ⟧ = ⊥
⟦ ONE ⟧ = ⊤
⟦ PLUS b₁ b₂ ⟧ = ⟦ b₁ ⟧ ⊎ ⟦ b₂ ⟧
⟦ TIMES b₁ b₂ ⟧ = ⟦ b₁ ⟧ × ⟦ b₂ ⟧
⟦ SING b v ⟧ = <_> {A = ⟦ b ⟧} v
⟦ RECIP b v ⟧ = <_> {A = ⟦ b ⟧} v → ⊤
⟦ DPAIR b c ⟧ = Σ ⟦ b ⟧ (λ v → ⟦ c v ⟧)
-- Useful abbrev
leftIdemp : (b : B) → ⟦ b ⟧ → B
leftIdemp b v = TIMES (SING b v) (RECIP b v)
mutual
data _⟷_ : B → B → Set₁ where
unite₊ : {b : B} → PLUS ZERO b ⟷ b
uniti₊ : {b : B} → b ⟷ PLUS ZERO b
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₃)
id⟷ : {b : B } → b ⟷ b
op : { b₁ b₂ : B } → (b₁ ⟷ b₂) → (b₂ ⟷ b₁)
_◎_ : { b₁ b₂ b₃ : B } → (b₁ ⟷ b₂) → (b₂ ⟷ b₃) → (b₁ ⟷ b₃)
_◑_ : { b₁ b₂ : B } {c d : ⟦ b₂ ⟧ → B} →
(b₁ ⟷ DPAIR b₂ c) →
(∀ {v} → c v ⟷ d v ) → (b₁ ⟷ DPAIR b₂ d )
{- _◐_ : { b₁ b₂ : B } {c d : ⟦ b₂ ⟧ → B} →
(∀ {v} → c v ⟷ d v ) → (b₁ ⟷ DPAIR b₂ c) →
(b₁ ⟷ DPAIR b₂ d ) -}
lift : { b₁ b₂ : B } {v : ⟦ b₁ ⟧ } {w : ⟦ b₂ ⟧ }
(c : b₁ ⟷ b₂) → (w ≡ eval c v) →
(SING b₁ v ⟷ SING b₂ w)
_⊕_ : { 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₄)
η : {b : B} → b ⟷ DPAIR b (λ v → leftIdemp b v)
ε : {b : B} → (DPAIR b (λ v → leftIdemp b v)) ⟷ b
eval : {b₁ b₂ : B} → (c : b₁ ⟷ b₂) → ⟦ b₁ ⟧ → ⟦ b₂ ⟧
eval unite₊ (inj₁ ())
eval unite₊ (inj₂ v) = v
eval uniti₊ v = inj₂ v
eval swap₊ (inj₁ x) = inj₂ x
eval swap₊ (inj₂ y) = inj₁ y
eval assocl₊ (inj₁ x) = inj₁ (inj₁ x)
eval assocl₊ (inj₂ (inj₁ x)) = inj₁ (inj₂ x)
eval assocl₊ (inj₂ (inj₂ x)) = inj₂ x
eval assocr₊ (inj₁ (inj₁ x)) = inj₁ x
eval assocr₊ (inj₁ (inj₂ y)) = inj₂ (inj₁ y)
eval assocr₊ (inj₂ y) = inj₂ (inj₂ y)
eval unite⋆ (tt , x) = x
eval uniti⋆ v = ( tt , v)
eval swap⋆ (v₁ , v₂) = (v₂ , v₁)
eval assocl⋆ (x , (y , z)) = ((x , y), z)
eval assocr⋆ ((x , y), z) = (x , (y , z))
eval id⟷ v = v
eval (op c) v = evalB c v
eval (c₁ ◎ c₂) v = eval c₂ (eval c₁ v)
eval (c₁ ⊕ c₂) (inj₁ x) = inj₁ (eval c₁ x)
eval (c₁ ⊕ c₂) (inj₂ y) = inj₂ (eval c₂ y)
eval (c₁ ⊗ c₂) (x , y) = (eval c₁ x , eval c₂ y)
eval (η {b}) v = v , ((singleton refl) , (λ x → tt))
eval (ε {b}) (w , c) = w
eval (c₁ ◑ c₂) v = proj₁ v₂ , eval (c₂ {proj₁ v₂}) (proj₂ v₂)
where v₂ = eval c₁ v
{- eval (c₁ ◐ c₂) v = proj₁ v₂ , eval (c₁ {proj₁ v₂}) (proj₂ v₂)
where v₂ = eval c₂ v -}
eval (lift c z) (singleton {y = v} prf) = singleton {y = eval c v} (trans (cong (eval c) prf) (sym z))
-- eval (lift c z) (singleton {y = v} refl) = singleton {y = eval c v} (sym z)
-- eval (lift {- w = .(eval c v) -} c refl) (singleton {y = v} refl) = singleton {y = eval c v} refl
evalB : {b₁ b₂ : B} → (c : b₁ ⟷ b₂) → ⟦ b₂ ⟧ → ⟦ b₁ ⟧
evalB uniti₊ (inj₁ ())
evalB uniti₊ (inj₂ v) = v
evalB unite₊ v = inj₂ v
evalB swap₊ (inj₁ x) = inj₂ x
evalB swap₊ (inj₂ y) = inj₁ y
evalB assocr₊ (inj₁ x) = inj₁ (inj₁ x)
evalB assocr₊ (inj₂ (inj₁ x)) = inj₁ (inj₂ x)
evalB assocr₊ (inj₂ (inj₂ x)) = inj₂ x
evalB assocl₊ (inj₁ (inj₁ x)) = inj₁ x
evalB assocl₊ (inj₁ (inj₂ y)) = inj₂ (inj₁ y)
evalB assocl₊ (inj₂ y) = inj₂ (inj₂ y)
evalB uniti⋆ (tt , x) = x
evalB unite⋆ v = ( tt , v)
evalB swap⋆ (v₁ , v₂) = (v₂ , v₁)
evalB assocr⋆ (x , (y , z)) = ((x , y), z)
evalB assocl⋆ ((x , y), z) = (x , (y , z))
evalB id⟷ v = v
evalB (op c) v = eval c v
evalB (c₁ ◎ c₂) v = evalB c₁ (evalB c₂ v)
evalB (c₁ ⊕ c₂) (inj₁ x) = inj₁ (evalB c₁ x)
evalB (c₁ ⊕ c₂) (inj₂ y) = inj₂ (evalB c₂ y)
evalB (c₁ ⊗ c₂) (x , y) = (evalB c₁ x , evalB c₂ y)
evalB (η {b}) (w , c) = w
evalB (ε {b}) v = v , ((singleton refl) , (λ x → tt))
evalB (c₁ ◑ c₂) (v , x) = evalB c₁ (v , evalB c₂ x)
{- evalB (c₁ ◐ c₂) (v , x) = evalB c₂ (v , evalB c₁ x) -}
evalB (lift {v = v} c z) _ = eval (lift (op c) (reverse v c)) (singleton {y = eval c v} refl)
reverse : {b₁ b₂ : B} (v : ⟦ b₁ ⟧) → (c : b₁ ⟷ b₂) → v ≡ evalB c (eval c v)
reverse (inj₁ ()) unite₊
reverse (inj₂ y) unite₊ = refl
reverse v uniti₊ = refl
reverse (inj₁ x) swap₊ = refl
reverse (inj₂ y) swap₊ = refl
reverse (inj₁ x) assocl₊ = refl
reverse (inj₂ (inj₁ x)) assocl₊ = refl
reverse (inj₂ (inj₂ y)) assocl₊ = refl
reverse (inj₁ (inj₁ x)) assocr₊ = refl
reverse (inj₁ (inj₂ y)) assocr₊ = refl
reverse (inj₂ y) assocr₊ = refl
reverse v unite⋆ = refl
reverse v uniti⋆ = refl
reverse v swap⋆ = refl
reverse v assocl⋆ = refl
reverse v assocr⋆ = refl
reverse v id⟷ = refl
reverse v (op c) = reverse' c v
reverse v (c ◎ c₁) = trans (reverse v c) (cong (evalB c) eq)
where eq : eval c v ≡ evalB c₁ (eval c₁ (eval c v))
eq = reverse (eval c v) c₁
reverse v (_◑_ {_} {b₂} {c} c₁ u) = trans eq₁ (cong (evalB c₁) eq₃)
where y : Σ ⟦ b₂ ⟧ (λ ww → ⟦ c ww ⟧)
y = eval c₁ v
eq₁ : v ≡ evalB c₁ y
eq₁ = reverse v c₁
eq₂ : proj₂ y ≡ evalB u (eval u (proj₂ y))
eq₂ = reverse (proj₂ y) u
eq₃ : y ≡ (proj₁ y , evalB u (eval u (proj₂ y)))
eq₃ = cong (λ z → (proj₁ y , z)) eq₂
{- reverse v (_◐_ {_} {b₂} {c} c₁ c₂) = {!!} -}
-- reverse (singleton {.v₂} refl) (lift {v = v₂} {.(eval c v₂)} c refl) = {!cong singleton {! proof-irrelevance {! (reverse v₂ c) !} ?!} !}
reverse (singleton prf₁) (lift {v = v₂} c prf₂) =
cong₂D (λ x e → singleton {y = x} e)
(trans prf₁ (reverse v₂ c)) (proof-irrelevance prf₁ _)
reverse (inj₁ x) (c ⊕ _) = cong inj₁ (reverse x c)
reverse (inj₂ y) (_ ⊕ c) = cong inj₂ (reverse y c)
reverse (x , y) (c₁ ⊗ c₂) = cong₂ _,_ (reverse x c₁) (reverse y c₂)
reverse v η = refl
reverse (_ , (singleton refl , _)) ε = refl
reverse' : {b₁ b₂ : B} (c : b₁ ⟷ b₂) → (w : ⟦ b₂ ⟧) → w ≡ eval c (evalB c w)
reverse' unite₊ w = refl
reverse' uniti₊ (inj₁ ())
reverse' uniti₊ (inj₂ y) = refl
reverse' swap₊ (inj₁ x) = refl
reverse' swap₊ (inj₂ y) = refl
reverse' assocl₊ (inj₁ (inj₁ x)) = refl
reverse' assocl₊ (inj₁ (inj₂ y)) = refl
reverse' assocl₊ (inj₂ y) = refl
reverse' assocr₊ (inj₁ x) = refl
reverse' assocr₊ (inj₂ (inj₁ x)) = refl
reverse' assocr₊ (inj₂ (inj₂ y)) = refl
reverse' unite⋆ w = refl
reverse' uniti⋆ w = refl
reverse' swap⋆ w = refl
reverse' assocl⋆ w = refl
reverse' assocr⋆ w = refl
reverse' id⟷ w = refl
reverse' (op c) w = reverse w c
reverse' (c ◎ c₁) w = trans (reverse' c₁ w) (cong (eval c₁) (reverse' c (evalB c₁ w)))
reverse' {b₁} {DPAIR b₂ d} (_◑_ {c = c} c₁ c₂) (w₁ , w₂)
rewrite (sym (reverse' c₁ (w₁ , evalB c₂ w₂))) | (sym (reverse' c₂ w₂)) = refl
{- reverse' (c₁ ◐ c₂) w = {!!} -}
reverse' (lift {v = v} {w = .(eval c v)} c refl) (singleton refl) = cong₂D (λ x e → singleton {y = x} e) (reverse' c (eval c v)) (proof-irrelevance refl _)
reverse' (c ⊕ _) (inj₁ x) = cong inj₁ (reverse' c x)
reverse' (_ ⊕ c) (inj₂ y) = cong inj₂ (reverse' c y)
reverse' (c₁ ⊗ c₂) (x , y) = cong₂ _,_ (reverse' c₁ x) (reverse' c₂ y)
reverse' η (_ , singleton refl , _ ) = refl
reverse' ε w = refl
-- they are properly inverse of each other
-- easy direction
η∘ε : {b : B} (v : ⟦ b ⟧) → eval {b} (η ◎ ε) v ≡ v
η∘ε _ = refl
-- hard direction.
ε∘η : {b : B} (v : ⟦ b ⟧) → { w : Σ < v > (λ _ → < v > → ⊤) }
→ (eval {DPAIR b (leftIdemp b) } {_} (ε ◎ η) (v , w)) ≡ (v , w)
ε∘η {b} v {(singleton refl , r )} = cong f {v , v , (singleton refl)} refl
where f : Σ ⟦ b ⟧ (λ x → Σ ⟦ b ⟧ (λ y → < v >)) →
Σ ⟦ b ⟧ (λ z → Σ < z > (λ x → < z > → ⊤ ))
f (_ , (_ , j)) = (v , j , r)
-- Now need to write some actual programs...
makeFunc : {b₁ b₂ : B} → (c : b₁ ⟷ b₂) → b₁ ⟷ DPAIR b₁ (λ x → TIMES (SING b₂ (eval c x)) (RECIP b₁ x))
makeFunc {b₁} {b₂} c = η {b₁} ◑ (λ {v₁} → (lift c refl) ⊗ id⟷)
| {
"alphanum_fraction": 0.4977635783,
"avg_line_length": 39.125,
"ext": "agda",
"hexsha": "d8da139690522cce8a7d469fb16ef0831c39afb2",
"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": "agda/PiMeadow.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": "agda/PiMeadow.agda",
"max_line_length": 157,
"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": "agda/PiMeadow.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": 4494,
"size": 9390
} |
------------------------------------------------------------------------------
-- Properties of the alter list
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOT.FOTC.UnguardedCorecursion.Alter.PropertiesI where
open import FOT.FOTC.UnguardedCorecursion.Alter.Alter
open import FOTC.Base
open import FOTC.Base.List
open import FOTC.Data.List
open import FOTC.Data.Stream.Type
open import FOTC.Relation.Binary.Bisimilarity.Type
------------------------------------------------------------------------------
-- TODO (23 December 2013).
-- alter-Stream : Stream alter
-- alter-Stream = Stream-coind A h refl
-- where
-- A : D → Set
-- A xs = xs ≡ alter
-- h : ∀ {xs} → A xs → ∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ A xs'
-- h Ax = true , (false ∷ alter) , trans Ax alter-eq , {!!}
-- TODO (23 December 2013).
-- alter≈alter' : alter ≈ alter'
-- alter≈alter' = ≈-coind B h₁ h₂
-- where
-- B : D → D → Set
-- B xs ys = xs ≡ xs
-- h₁ : B alter alter' → ∃[ x' ] ∃[ xs' ] ∃[ ys' ]
-- alter ≡ x' ∷ xs' ∧ alter' ≡ x' ∷ ys' ∧ B xs' ys'
-- h₁ _ = true
-- , false ∷ alter
-- , map not₀ alter'
-- , alter-eq
-- , alter'-eq
-- , refl
-- h₂ : B alter alter'
-- h₂ = refl
| {
"alphanum_fraction": 0.4547339323,
"avg_line_length": 29.5306122449,
"ext": "agda",
"hexsha": "34562899aa5dcc1099db0468ba7dd9a82004dc3e",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z",
"max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/fotc",
"max_forks_repo_path": "notes/FOT/FOTC/UnguardedCorecursion/Alter/PropertiesI.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/fotc",
"max_issues_repo_path": "notes/FOT/FOTC/UnguardedCorecursion/Alter/PropertiesI.agda",
"max_line_length": 78,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "notes/FOT/FOTC/UnguardedCorecursion/Alter/PropertiesI.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z",
"num_tokens": 415,
"size": 1447
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.