Search is not available for this dataset
text
string | meta
dict |
---|---|
------------------------------------------------------------------------
-- Products
------------------------------------------------------------------------
module Data.Product where
open import Data.Function
open import Relation.Nullary.Core
infixr 4 _,_
infix 4 ,_
infixr 2 _×_ _-×-_ _-,-_
------------------------------------------------------------------------
-- Definition
data Σ (A : Set) (B : A → Set) : Set where
_,_ : (x : A) (y : B x) → Σ A B
∃ : {A : Set} → (A → Set) → Set
∃ = Σ _
∄ : {A : Set} → (A → Set) → Set
∄ P = ¬ ∃ P
∃₂ : {A : Set} {B : A → Set} (C : (x : A) → B x → Set) → Set
∃₂ C = ∃ λ a → ∃ λ b → C a b
_×_ : (A B : Set) → Set
A × B = Σ A (λ _ → B)
------------------------------------------------------------------------
-- Functions
-- Sometimes the first component can be inferred.
,_ : ∀ {A} {B : A → Set} {x} → B x → ∃ B
, y = _ , y
proj₁ : ∀ {A B} → Σ A B → A
proj₁ (x , y) = x
proj₂ : ∀ {A B} → (p : Σ A B) → B (proj₁ p)
proj₂ (x , y) = y
<_,_> : ∀ {A} {B : A → Set} {C : ∀ {x} → B x → Set}
(f : (x : A) → B x) → ((x : A) → C (f x)) →
((x : A) → Σ (B x) C)
< f , g > x = (f x , g x)
map : ∀ {A B P Q} →
(f : A → B) → (∀ {x} → P x → Q (f x)) →
Σ A P → Σ B Q
map f g = < f ∘ proj₁ , g ∘ proj₂ >
zip : ∀ {A B C P Q R} →
(_∙_ : A → B → C) →
(∀ {x y} → P x → Q y → R (x ∙ y)) →
Σ A P → Σ B Q → Σ C R
zip _∙_ _∘_ p₁ p₂ = (proj₁ p₁ ∙ proj₁ p₂ , proj₂ p₁ ∘ proj₂ p₂)
swap : ∀ {A B} → A × B → B × A
swap = < proj₂ , proj₁ >
_-×-_ : ∀ {A B} → (A → B → Set) → (A → B → Set) → (A → B → Set)
f -×- g = f -[ _×_ ]₁- g
_-,-_ : ∀ {A B C D} → (A → B → C) → (A → B → D) → (A → B → C × D)
f -,- g = f -[ _,_ ]- g
curry : {A : Set} {B : A → Set} {C : Σ A B → Set} →
((p : Σ A B) → C p) →
((x : A) → (y : B x) → C (x , y))
curry f x y = f (x , y)
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 (p₁ , p₂) = f p₁ p₂
| {
"alphanum_fraction": 0.3250249252,
"avg_line_length": 25.075,
"ext": "agda",
"hexsha": "3e5484bbefd5c0465f9e8081b7690117ecf479bd",
"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/Data/Product.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/Data/Product.agda",
"max_line_length": 72,
"max_stars_count": 56,
"max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "isabella232/Lemmachine",
"max_stars_repo_path": "vendor/stdlib/src/Data/Product.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": 861,
"size": 2006
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Foundations.Equiv.Base where
open import Cubical.Foundations.Function
open import Cubical.Foundations.Prelude
open import Cubical.Core.Glue public
using ( isEquiv ; equiv-proof ; _≃_ ; equivFun ; equivProof )
fiber : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} (f : A → B) (y : B) → Type (ℓ-max ℓ ℓ')
fiber {A = A} f y = Σ[ x ∈ A ] f x ≡ y
-- The identity equivalence
idIsEquiv : ∀ {ℓ} (A : Type ℓ) → isEquiv (idfun A)
equiv-proof (idIsEquiv A) y =
((y , refl) , λ z i → z .snd (~ i) , λ j → z .snd (~ i ∨ j))
idEquiv : ∀ {ℓ} (A : Type ℓ) → A ≃ A
idEquiv A .fst = idfun A
idEquiv A .snd = idIsEquiv A
| {
"alphanum_fraction": 0.6122754491,
"avg_line_length": 31.8095238095,
"ext": "agda",
"hexsha": "ba94946869715cbe3a882174e68edf9ae9544758",
"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/Foundations/Equiv/Base.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/Foundations/Equiv/Base.agda",
"max_line_length": 83,
"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/Foundations/Equiv/Base.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 261,
"size": 668
} |
module Prelude.List.Base where
open import Prelude.Nat
open import Prelude.Bool
open import Prelude.Maybe
open import Prelude.Product
open import Prelude.Empty
open import Prelude.Function
open import Prelude.Functor
open import Prelude.Applicative
open import Prelude.Monad
open import Prelude.Decidable
open import Prelude.Equality
open import Prelude.Ord
open import Prelude.Semiring
open import Prelude.Strict
open import Prelude.Variables
open import Agda.Builtin.List public
infixr 5 _++_
pattern [_] x = x ∷ []
singleton : A → List A
singleton x = x ∷ []
map : (A → B) → List A → List B
map f [] = []
map f (x ∷ xs) = f x ∷ map f xs
_++_ : List A → List A → List A
[] ++ ys = ys
(x ∷ xs) ++ ys = x ∷ xs ++ ys
length : List A → Nat
length [] = 0
length (x ∷ xs) = 1 + length xs
foldr : (A → B → B) → B → List A → B
foldr f z [] = z
foldr f z (x ∷ xs) = f x (foldr f z xs)
foldl : (B → A → B) → B → List A → B
foldl f z [] = z
foldl f z (x ∷ xs) = foldl f (f z x) xs
foldl! : (B → A → B) → B → List A → B
foldl! f z [] = z
foldl! f z (x ∷ xs) = force (f z x) λ z′ → foldl! f z′ xs
reverse : List A → List A
reverse xs = foldl (flip _∷_) [] xs
concat : List (List A) → List A
concat = foldr _++_ []
concatMap : (A → List B) → List A → List B
concatMap f = concat ∘ map f
filter : (A → Bool) → List A → List A
filter p [] = []
filter p (x ∷ xs) = if p x then x ∷ filter p xs
else filter p xs
catMaybes : List (Maybe A) → List A
catMaybes [] = []
catMaybes (x ∷ xs) = maybe (catMaybes xs) (_∷ catMaybes xs) x
all? : (A → Bool) → List A → Bool
all? p [] = true
all? p (x ∷ xs) = p x && all? p xs
any? : (A → Bool) → List A → Bool
any? p [] = false
any? p (x ∷ xs) = p x || any? p xs
take : Nat → List A → List A
take zero _ = []
take (suc n) [] = []
take (suc n) (x ∷ xs) = x ∷ take n xs
drop : Nat → List A → List A
drop zero xs = xs
drop (suc n) [] = []
drop (suc n) (x ∷ xs) = drop n xs
takeWhile : (A → Bool) → List A → List A
takeWhile p [] = []
takeWhile p (x ∷ xs) = if p x then x ∷ takeWhile p xs
else []
dropWhile : (A → Bool) → List A → List A
dropWhile p [] = []
dropWhile p (x ∷ xs) = if p x then dropWhile p xs
else x ∷ xs
splitAt : Nat → List A → List A × List A
splitAt zero xs = [] , xs
splitAt (suc n) [] = [] , []
splitAt (suc n) (x ∷ xs) = first (x ∷_) (splitAt n xs)
null : List A → Bool
null [] = true
null (_ ∷ _) = false
elem : ⦃ Eq A ⦄ → A → List A → Bool
elem x xs = not (null (filter (isYes ∘ _==_ x) xs))
lookup : ⦃ Eq A ⦄ → List (A × B) → A → Maybe B
lookup [] _ = nothing
lookup ((x₁ , v) ∷ xs) x = ifYes (x == x₁) then just v else lookup xs x
nub : ⦃ Eq A ⦄ → List A → List A
nub [] = []
nub (x ∷ xs) = x ∷ filter (isNo ∘ (x ==_)) (nub xs)
index : List A → Nat → Maybe A
index [] _ = nothing
index (x ∷ xs) 0 = just x
index (x ∷ xs) (suc i) = index xs i
replicate : Nat → A → List A
replicate zero x = []
replicate (suc n) x = x ∷ replicate n x
zipWith : (A → B → C) → List A → List B → List C
zipWith f [] _ = []
zipWith f _ [] = []
zipWith f (x ∷ xs) (y ∷ ys) = f x y ∷ zipWith f xs ys
zip : List A → List B → List (A × B)
zip = zipWith _,_
punctuate : A → List A → List A
punctuate z [] = []
punctuate z [ x ] = [ x ]
punctuate z (x ∷ xs) = x ∷ z ∷ punctuate z xs
replicateA : ⦃ Applicative F ⦄ → Nat → F A → F (List A)
replicateA zero _ = pure []
replicateA (suc n) x = pure _∷_ <*> x <*> replicateA n x
module _ ⦃ _ : Semiring A ⦄ where
sum : List A → A
sum = foldl! _+_ zro
product : List A → A
product = foldl! _*_ one
sumR : List A → A
sumR = foldr _+_ zro
productR : List A → A
productR = foldr _*_ one
module _ ⦃ _ : Ord A ⦄ where
insert : A → List A → List A
insert x [] = x ∷ []
insert x (y ∷ xs) = if x <? y then x ∷ y ∷ xs else y ∷ insert x xs
sort : List A → List A
sort [] = []
sort (x ∷ xs) = insert x (sort xs)
infix 10 from_for_ from_to_ from_for_step_ from-to-step
from_for_ : Nat → Nat → List Nat
from 0 for 0 = [] -- make strict
from a for 0 = []
from a for suc d = a ∷ from suc a for d
from_for_step_ : Nat → Nat → Nat → List Nat
from 0 for 0 step _ = [] -- make strict
from a for 0 step _ = []
from a for suc c step d = a ∷ from a + d for c step d
from_to_ : Nat → Nat → List Nat
from a to b = from a for (suc b - a)
syntax from-to-step d a b = from a to b step d
from-to-step : (d : Nat) {{_ : NonZero d}} → Nat → Nat → List Nat
from-to-step d a b = from a for 1 + (b - a) div d step d
--- Equality ---
cons-inj-tail : x ∷ xs ≡ y ∷ ys → xs ≡ ys
cons-inj-tail refl = refl
cons-inj-head : x ∷ xs ≡ y ∷ ys → x ≡ y
cons-inj-head refl = refl
private
dec-∷ : Dec (x ≡ y) → Dec (xs ≡ ys) → Dec (x ∷ xs ≡ y ∷ ys)
dec-∷ (yes refl) (yes refl) = yes refl
dec-∷ _ (no neq) = no λ eq → neq (cons-inj-tail eq)
dec-∷ (no neq) _ = no λ eq → neq (cons-inj-head eq)
eqList : ⦃ Eq A ⦄ → (xs ys : List A) → Dec (xs ≡ ys)
eqList [] [] = yes refl
eqList [] (_ ∷ _) = no (λ ())
eqList (_ ∷ _) [] = no (λ ())
eqList (x ∷ xs) (y ∷ ys) = dec-∷ (x == y) (eqList xs ys)
instance
EqList : ⦃ Eq A ⦄ → Eq (List A)
_==_ {{EqList}} = eqList
--- Ord ---
data LessList (_<_ : A → A → Set ℓ) : List A → List A → Set ℓ where
nil<cons : LessList _<_ [] (x ∷ xs)
head< : x < y → LessList _<_ (x ∷ xs) (y ∷ ys)
tail< : LessList _<_ xs ys → LessList _<_ (x ∷ xs) (x ∷ ys)
compareCons : ∀ {_<_ : A → A → Set ℓ} →
Comparison _<_ x y →
Comparison (LessList _<_) xs ys →
Comparison (LessList _<_) (x ∷ xs) (y ∷ ys)
compareCons (less lt) _ = less (head< lt)
compareCons (greater gt) _ = greater (head< gt)
compareCons (equal refl) (less lt) = less (tail< lt)
compareCons (equal refl) (greater gt) = greater (tail< gt)
compareCons (equal refl) (equal refl) = equal refl
compareList : ∀ {_<_ : A → A → Set ℓ} (cmp : ∀ x y → Comparison _<_ x y) (xs ys : List A) →
Comparison (LessList _<_) xs ys
compareList cmp [] [] = equal refl
compareList cmp [] (x ∷ ys) = less nil<cons
compareList cmp (x ∷ xs) [] = greater nil<cons
compareList cmp (x ∷ xs) (y ∷ ys) = compareCons (cmp x y) (compareList cmp xs ys)
instance
OrdList : ⦃ Ord A ⦄ → Ord (List A)
OrdList = defaultOrd (compareList compare)
OrdListLaws : ⦃ Ord/Laws A ⦄ → Ord/Laws (List A)
Ord/Laws.super OrdListLaws = it
less-antirefl {{OrdListLaws {A = A}}} (head< hd) = less-antirefl {A = A} hd
less-antirefl {{OrdListLaws {A = A}}} (tail< tl) = less-antirefl {A = List A} tl
less-trans {{OrdListLaws}} nil<cons (head< hd) = nil<cons
less-trans {{OrdListLaws}} nil<cons (tail< tl) = nil<cons
less-trans {{OrdListLaws {A = A}}} (head< hd) (head< hd₁) = head< (less-trans {A = A} hd hd₁)
less-trans {{OrdListLaws {A = A}}} (head< hd) (tail< tl) = head< hd
less-trans {{OrdListLaws {A = A}}} (tail< tl) (head< hd) = head< hd
less-trans {{OrdListLaws {A = A}}} (tail< tl) (tail< tl₁) = tail< (less-trans {A = List A} tl tl₁)
--- Functor ---
instance
FunctorList : Functor (List {ℓ})
fmap {{FunctorList}} = map
FunctorList′ : Functor′ {ℓ₁} {ℓ₂} List
fmap′ {{FunctorList′}} = map
ApplicativeList : Applicative (List {ℓ})
pure {{ApplicativeList}} x = x ∷ []
_<*>_ {{ApplicativeList}} = monadAp (flip concatMap)
ApplicativeList′ : Applicative′ {ℓ₁} {ℓ₂} List
_<*>′_ {{ApplicativeList′}} = monadAp′ (flip concatMap)
MonadList : Monad (List {ℓ})
_>>=_ {{MonadList}} xs f = concatMap f xs
MonadList′ : Monad′ {ℓ₁} {ℓ₂} List
_>>=′_ {{MonadList′}} xs f = concatMap f xs
--- More functions ---
IsPrefixOf : {A : Set ℓ} → List A → List A → Set ℓ
IsPrefixOf xs ys = ∃ zs , ys ≡ xs ++ zs
isPrefixOf : ⦃ Eq A ⦄ → (xs ys : List A) → Dec (IsPrefixOf xs ys)
isPrefixOf [] ys = yes (ys , refl)
isPrefixOf (x ∷ xs) [] = no λ where (zs , ())
isPrefixOf (x ∷ xs) (y ∷ ys) with y == x | isPrefixOf xs ys
... | yes y=x | yes (zs , xs⊑ys) = yes (zs , (_∷_ $≡ y=x *≡ xs⊑ys))
... | _ | no noprefix = no λ where (zs , eq) → noprefix ((zs , cons-inj-tail eq))
... | no y≠x | _ = no λ where (zs , eq) → y≠x (cons-inj-head eq)
isPrefixOf? : ⦃ Eq A ⦄ → List A → List A → Bool
isPrefixOf? xs ys = isYes (isPrefixOf xs ys)
dropPrefix : ⦃ Eq A ⦄ → List A → List A → Maybe (List A)
dropPrefix xs ys =
case isPrefixOf xs ys of λ where
(yes (tl , _)) → just tl
(no _) → nothing
commonPrefix : ⦃ Eq A ⦄ → (xs ys : List A) → ∃ zs , IsPrefixOf zs xs × IsPrefixOf zs ys
commonPrefix [] ys = [] , (_ , refl) , (_ , refl)
commonPrefix xs [] = [] , (_ , refl) , (_ , refl)
commonPrefix (x ∷ xs) (y ∷ ys) with y == x | commonPrefix xs ys
... | yes y=x | zs , (xs₁ , eqx) , (ys₁ , eqy) = (x ∷ zs) , (xs₁ , (x ∷_ $≡ eqx)) , (ys₁ , (_∷_ $≡ y=x *≡ eqy))
... | no _ | _ = [] , (_ , refl) , (_ , refl)
commonPrefix! : ⦃ Eq A ⦄ → (xs ys : List A) → List A
commonPrefix! xs ys = fst (commonPrefix xs ys)
wordsBy : (A → Bool) → List A → List (List A)
wordsBy {A = A} p = go in-word ∘ dropWhile p
where
data Mode : Set where
in-word in-space : Mode
cons : A → List (List A) → List (List A)
cons x [] = [ x ] ∷ []
cons x (xs ∷ xss) = (x ∷ xs) ∷ xss
go : Mode → List A → List (List A)
go _ [] = []
go mode (x ∷ xs) with p x
go mode (x ∷ xs) | false = cons x (go in-word xs)
go in-word (x ∷ xs) | true = [] ∷ go in-space xs
go in-space (x ∷ xs) | true = go in-space xs
| {
"alphanum_fraction": 0.547545059,
"avg_line_length": 30.263322884,
"ext": "agda",
"hexsha": "85a53252b4745ebedea91d3a27f726e62cd3dcbf",
"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": "da4fca7744d317b8843f2bc80a923972f65548d3",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "t-more/agda-prelude",
"max_forks_repo_path": "src/Prelude/List/Base.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3",
"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": "t-more/agda-prelude",
"max_issues_repo_path": "src/Prelude/List/Base.agda",
"max_line_length": 111,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "t-more/agda-prelude",
"max_stars_repo_path": "src/Prelude/List/Base.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3643,
"size": 9654
} |
import Relation.Binary.PropositionalEquality as Eq
open Eq using (_≡_; refl; sym; trans; cong; cong-app)
open Eq.≡-Reasoning
open import Data.Nat using (ℕ; zero; suc; _+_; _*_)
open import Data.Product using (∃; _,_)
+-assoc : ∀ (m n p : ℕ) → m + (n + p) ≡ (m + n) + p
+-assoc zero n p =
begin
zero + (n + p)
≡⟨⟩
n + p
≡⟨⟩
(zero + n) + p
∎
+-assoc (suc m) n p =
begin
suc m + (n + p)
≡⟨⟩
suc (m + (n + p))
≡⟨ cong suc (+-assoc m n p) ⟩
suc ((m + n) + p)
≡⟨⟩
(suc m + n) + p
∎
+-identity : ∀ (m : ℕ) → m + zero ≡ m
+-identity zero =
begin
zero + zero
≡⟨⟩
zero
∎
+-identity (suc m) =
begin
suc m + zero
≡⟨⟩
suc (m + zero)
≡⟨ cong suc (+-identity m) ⟩
suc m
∎
+-suc : ∀ (m n : ℕ) → m + suc n ≡ suc (m + n)
+-suc zero n =
begin
zero + suc n
≡⟨⟩
suc n
≡⟨⟩
suc (zero + n)
∎
+-suc (suc m) n =
begin
suc m + suc n
≡⟨⟩
suc (m + suc n)
≡⟨ cong suc (+-suc m n) ⟩
suc (suc (m + n))
≡⟨⟩
suc (suc m + n)
∎
+-comm : ∀ (m n : ℕ) → m + n ≡ n + m
+-comm m zero =
begin
m + zero
≡⟨ +-identity m ⟩
m
≡⟨⟩
zero + m
∎
+-comm m (suc n) =
begin
m + suc n
≡⟨ +-suc m n ⟩
suc (m + n)
≡⟨ cong suc (+-comm m n) ⟩
suc (n + m)
≡⟨⟩
suc n + m
∎
*-distrib-+ : ∀ (m n p : ℕ) → (m + n) * p ≡ m * p + n * p
*-distrib-+ zero n p =
begin
(zero + n) * p
≡⟨⟩
n * p
≡⟨⟩
zero * p + n * p
∎
*-distrib-+ (suc m) n p =
begin
(suc m + n) * p
≡⟨⟩
p + (m + n) * p
≡⟨ cong (_+_ p) (*-distrib-+ m n p) ⟩
p + (m * p + n * p)
≡⟨ +-assoc p (m * p) (n * p) ⟩
(p + m * p) + n * p
≡⟨⟩
suc m * p + n * p
∎
data even : ℕ → Set where
ev0 : even zero
ev+2 : ∀ {n : ℕ} → even n → even (suc (suc n))
lemma : ∀ (m : ℕ) → 2 * suc m ≡ suc (suc (2 * m))
lemma m =
begin
2 * suc m
≡⟨⟩
suc m + (suc m + zero)
≡⟨⟩
suc (m + (suc (m + zero)))
≡⟨ cong suc (+-suc m (m + zero)) ⟩
suc (suc (m + (m + zero)))
≡⟨⟩
suc (suc (2 * m))
∎
ev-ex : ∀ {n : ℕ} → even n → ∃(λ (m : ℕ) → 2 * m ≡ n)
ev-ex ev0 = (0 , refl)
ev-ex (ev+2 ev) with ev-ex ev
... | (m , refl) = (suc m , lemma m)
ex-ev : ∀ {n : ℕ} → ∃(λ (m : ℕ) → 2 * m ≡ n) → even n
ex-ev (zero , refl) = ev0
ex-ev (suc m , refl) rewrite lemma m = ev+2 (ex-ev (m , refl))
-- I can't see how to avoid using rewrite in the second proof,
-- or how to use rewrite in the first proof!
| {
"alphanum_fraction": 0.4262227702,
"avg_line_length": 17.3785714286,
"ext": "agda",
"hexsha": "f742d4b0d9706103fd2c005e57a46a0835f389e0",
"lang": "Agda",
"max_forks_count": 304,
"max_forks_repo_forks_event_max_datetime": "2022-03-28T11:35:02.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-07-16T18:24:59.000Z",
"max_forks_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4",
"max_forks_repo_licenses": [
"CC-BY-4.0"
],
"max_forks_repo_name": "manikdv/plfa.github.io",
"max_forks_repo_path": "extra/extra/Even.agda",
"max_issues_count": 323,
"max_issues_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4",
"max_issues_repo_issues_event_max_datetime": "2022-03-30T07:42:57.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-07-05T22:34:34.000Z",
"max_issues_repo_licenses": [
"CC-BY-4.0"
],
"max_issues_repo_name": "manikdv/plfa.github.io",
"max_issues_repo_path": "extra/extra/Even.agda",
"max_line_length": 62,
"max_stars_count": 1003,
"max_stars_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4",
"max_stars_repo_licenses": [
"CC-BY-4.0"
],
"max_stars_repo_name": "manikdv/plfa.github.io",
"max_stars_repo_path": "extra/extra/Even.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-27T07:03:28.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-07-05T18:15:14.000Z",
"num_tokens": 1178,
"size": 2433
} |
module ExportTestAgda where
open import Common.Prelude
itWorksText : String
itWorksText = "It works!"
{-# COMPILED_EXPORT itWorksText itWorksText #-}
| {
"alphanum_fraction": 0.7843137255,
"avg_line_length": 17,
"ext": "agda",
"hexsha": "f81f8c69d89a55bbd5933f7d3a499382bc86f290",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "test/compiler/ExportTestAgda.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/compiler/ExportTestAgda.agda",
"max_line_length": 47,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "redfish64/autonomic-agda",
"max_stars_repo_path": "test/Compiler/special/ExportTestAgda.agda",
"max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z",
"num_tokens": 39,
"size": 153
} |
-- There was a bug when unifying things of function type during pattern matching
-- (the T argument to P is unified with D below)
module Issue199 where
data D (A : Set) : Set where
data P {A : Set} : {T : Set → Set} → T A → Set where
p : ∀ d → P {_} {D} d
foo : ∀ {A} {l : D A} → P l → Set₁
foo (p _) = Set
| {
"alphanum_fraction": 0.6045016077,
"avg_line_length": 25.9166666667,
"ext": "agda",
"hexsha": "320d0a26336e40c7fa0c5a4ebfbcd1bad7c377f6",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Fail/Issue199.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Fail/Issue199.agda",
"max_line_length": 80,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Fail/Issue199.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 106,
"size": 311
} |
open import Type
module Relator.Converse {ℓ₁ ℓ₂} {T : Type{ℓ₁}} (_▫_ : T → T → Type{ℓ₂}) where
import Lvl
open import Functional
Converse : T → T → Type{ℓ₂}
Converse = swap(_▫_)
| {
"alphanum_fraction": 0.6451612903,
"avg_line_length": 18.6,
"ext": "agda",
"hexsha": "7194780ef54d1d432045abad71361b20811df930",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Relator/Converse.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Relator/Converse.agda",
"max_line_length": 77,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Relator/Converse.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": 73,
"size": 186
} |
module Issue4954 where
open import Issue4954.M Set
| {
"alphanum_fraction": 0.8269230769,
"avg_line_length": 13,
"ext": "agda",
"hexsha": "a89b994cf4da7114a74bea6fb8a49b96a32a7923",
"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/Issue4954.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/Issue4954.agda",
"max_line_length": 27,
"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/Issue4954.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": 14,
"size": 52
} |
module Relator.Ordering.Proofs where
open import Data
import Lvl
open import Functional
open import Lang.Instance
open import Logic
open import Logic.Classical
open import Logic.Propositional
open import Logic.Propositional.Theorems
open import Type
import Relator.Ordering
open import Structure.Relator.Ordering
import Structure.Relator.Names as Names
open import Structure.Relator.Proofs
open import Structure.Relator.Properties
open import Structure.Relator.Properties.Proofs
open import Structure.Relator
open import Structure.Setoid
open import Syntax.Implication
open import Syntax.Transitivity
private variable ℓ ℓ₁ ℓ₂ ℓ₃ ℓₗ ℓₑ ℓₗₑ ℓₗₜ : Lvl.Level
private variable T : Type{ℓ}
module From-[≤] (_≤_ : T → T → Stmt{ℓₗ}) where
open Relator.Ordering.From-[≤] (_≤_)
[≤][>]-not : ∀{a b} → (a ≤ b) → (a > b) → ⊥
[≤][>]-not = apply
[≥][<]-not : ∀{a b} → (a ≥ b) → (a < b) → ⊥
[≥][<]-not = apply
module _ ⦃ _ : Equiv{ℓₑ}(T) ⦄ ⦃ _ : Weak.TotalOrder(_≤_)(_≡_) ⦄ where
[<]-to-[≤] : Names.Subrelation(_<_)(_≤_)
[<]-to-[≤] {a} {b} nba with converseTotal(_≤_){a}{b}
[<]-to-[≤] {a} {b} nba | [∨]-introₗ ab = ab
[<]-to-[≤] {a} {b} nba | [∨]-introᵣ ba = [⊥]-elim(nba ba)
instance
[<][≤]-sub : (_<_) ⊆₂ (_≤_)
_⊆₂_.proof [<][≤]-sub = [<]-to-[≤]
[>]-to-[≥] : Names.Subrelation(_>_)(_≥_)
[>]-to-[≥] = [<]-to-[≤]
[>][≥]-sub : (_>_) ⊆₂ (_≥_)
_⊆₂_.proof [>][≥]-sub = [>]-to-[≥]
instance
[<]-irreflexivity : Irreflexivity(_<_)
Irreflexivity.proof [<]-irreflexivity = [¬¬]-intro(reflexivity(_≤_))
instance
[<]-transitivity : Transitivity(_<_)
Transitivity.proof [<]-transitivity {a} {b} {c} nba ncb ca = [≤][>]-not (transitivity(_≤_) ca ([<]-to-[≤] nba)) ncb
instance
[<]-asymmetry : Asymmetry(_<_) -- TODO: Proof of this property is independent of the model. Actually, many of them here are
[<]-asymmetry = [irreflexivity,transitivity]-to-asymmetry
[<]-strictOrder : Strict.PartialOrder(_<_)
[<]-strictOrder = Strict.intro
{- TODO: Maybe one must assume decidability of (_≡_)?
instance
[<]-total : ConverseTotal(_<_)
ConverseTotal.proof [<]-total {x} {y} with converseTotal(_≤_)
... | [∨]-introₗ x₁ = {!!}
... | [∨]-introᵣ x₁ = {!!}
-}
instance
[<][≤]-subtransitivityₗ : Subtransitivityₗ(_<_)(_≤_)
Subtransitivityₗ.proof [<][≤]-subtransitivityₗ xy yz zx = yz(transitivity(_≤_) zx xy)
instance
[<][≤]-subtransitivityᵣ : Subtransitivityᵣ(_<_)(_≤_)
Subtransitivityᵣ.proof [<][≤]-subtransitivityᵣ xy yz zx = xy(transitivity(_≤_) yz zx)
[≤][≢]-to-[<] : ∀{a b} → (a ≤ b) → (a ≢ b) → (a < b)
[≤][≢]-to-[<] le ne ba = ne(antisymmetry(_≤_)(_≡_) le ba)
[≥][≢]-to-[>] : ∀{a b} → (a ≥ b) → (a ≢ b) → (a > b)
[≥][≢]-to-[>] ge ne = [≤][≢]-to-[<] ge (ne ∘ symmetry(_≡_))
module _ ⦃ _ : (_≡_) ⊆₂ (_≤_) ⦄ where -- TODO: Consider including this in weak orders. Or just assume that (_≤_) is a relation and this will follow
instance
[≤][≡]-subtransitivityₗ : Subtransitivityₗ(_≤_)(_≡_)
[≤][≡]-subtransitivityₗ = subrelation-transitivity-to-subtransitivityₗ
instance
[≤][≡]-subtransitivityᵣ : Subtransitivityᵣ(_≤_)(_≡_)
[≤][≡]-subtransitivityᵣ = subrelation-transitivity-to-subtransitivityᵣ
[≡]-to-[≥] : Names.Subrelation(_≡_)(_≥_)
[≡]-to-[≥] = sub₂(_≡_)(_≤_) ∘ symmetry(_≡_)
instance
[≡][≥]-sub : (_≡_) ⊆₂ (_≥_)
_⊆₂_.proof [≡][≥]-sub = [≡]-to-[≥]
[≡][>]-not : ∀{a b} → (a ≡ b) → (a > b) → ⊥
[≡][>]-not eq gt = [≤][>]-not (sub₂(_≡_)(_≤_) eq) gt
instance
[≡][≯]-sub : (_≡_) ⊆₂ (_≯_)
_⊆₂_.proof [≡][≯]-sub = [≡][>]-not
instance
[>][≢]-sub : (_>_) ⊆₂ (_≢_)
_⊆₂_.proof [>][≢]-sub = swap [≡][>]-not
[≡][<]-not : ∀{a b} → (a ≡ b) → (a < b) → ⊥
[≡][<]-not eq lt = [≤][>]-not ([≡]-to-[≥] eq) lt
instance
[≡][≮]-sub : (_≡_) ⊆₂ (_≮_)
_⊆₂_.proof [≡][≮]-sub = [≡][<]-not
instance
[<][≢]-sub : (_<_) ⊆₂ (_≢_)
_⊆₂_.proof [<][≢]-sub = swap [≡][<]-not
instance
[<][≡]-subtransitivityₗ : Subtransitivityₗ(_<_)(_≡_)
Subtransitivityₗ.proof [<][≡]-subtransitivityₗ xy yz zx = [≡][>]-not xy (subtransitivityᵣ(_<_)(_≤_) yz zx)
instance
[<][≡]-subtransitivityᵣ : Subtransitivityᵣ(_<_)(_≡_)
Subtransitivityᵣ.proof [<][≡]-subtransitivityᵣ xy yz zx = [≡][>]-not yz (subtransitivityₗ(_<_)(_≤_) zx xy)
module _ ⦃ [≡]-classical : Classical₂(_≡_) ⦄ where
[≤]-or-[>] : ∀{a b} → (a ≤ b) ∨ (a > b)
[≤]-or-[>] {a} {b} with converseTotal(_≤_){a}{b}
[≤]-or-[>] {a} {b} | [∨]-introₗ ab = [∨]-introₗ ab
[≤]-or-[>] {a} {b} | [∨]-introᵣ ba with excluded-middle _ ⦃ [≡]-classical {a}{b} ⦄
[≤]-or-[>] {a} {b} | [∨]-introᵣ ba | [∨]-introₗ eqab = [∨]-introₗ (sub₂(_≡_)(_≤_) eqab)
[≤]-or-[>] {a} {b} | [∨]-introᵣ ba | [∨]-introᵣ neqab = [∨]-introᵣ (ab ↦ neqab(antisymmetry(_≤_)(_≡_) ab ba))
instance
[≤]-classical : Classical₂(_≤_)
Classical.excluded-middle [≤]-classical = [≤]-or-[>]
[≥]-or-[<] : ∀{a b} → (a ≥ b) ∨ (a < b)
[≥]-or-[<] = [≤]-or-[>]
[≥]-classical : Classical₂(_≥_)
Classical.excluded-middle [≥]-classical = [≥]-or-[<]
instance
[<]-classical : Classical₂(_<_)
Classical.excluded-middle ([<]-classical {a}{b}) with [≤]-or-[>] {b}{a}
Classical.excluded-middle ([<]-classical {a}{b}) | [∨]-introₗ x = [∨]-introᵣ ([¬¬]-intro x)
Classical.excluded-middle ([<]-classical {a}{b}) | [∨]-introᵣ x = [∨]-introₗ x
[>]-classical : Classical₂(_>_)
[>]-classical = [<]-classical
[≤]-to-[<][≡] : ∀{a b} → (a ≤ b) → ((a < b) ∨ (a ≡ b))
[≤]-to-[<][≡] {a} {b} ab with excluded-middle _ ⦃ [≡]-classical {a}{b} ⦄
[≤]-to-[<][≡] {a} {b} ab | [∨]-introₗ eq = [∨]-introᵣ eq
[≤]-to-[<][≡] {a} {b} ab | [∨]-introᵣ ne = [∨]-introₗ (ba ↦ ne(antisymmetry(_≤_)(_≡_) ab ba))
[≥]-to-[>][≡] : ∀{a b} → (a ≥ b) → ((a > b) ∨ (a ≡ b))
[≥]-to-[>][≡] ab = [∨]-elim2 id (symmetry(_≡_)) ([≤]-to-[<][≡] ab)
module From-[≤][≢] {ℓ₁ ℓ₂ ℓ₃} {T : Type{ℓ₁}} (_≤_ : T → T → Stmt{ℓ₂}) (_≢_ : T → T → Stmt{ℓ₃}) where
open Relator.Ordering.From-[≤][≢] (_≤_)(_≢_)
-- postulate instance [<]-totalOrder : Strict.TotalOrder(_<_)
instance
[<][≤]-sub : (_<_) ⊆₂ (_≤_)
_⊆₂_.proof [<][≤]-sub = [∧]-elimₗ
instance
[>][≥]-sub : (_>_) ⊆₂ (_≥_)
_⊆₂_.proof [>][≥]-sub = sub₂(_<_)(_≤_)
instance
[<][≢]-sub : (_<_) ⊆₂ (_≢_)
_⊆₂_.proof [<][≢]-sub = [∧]-elimᵣ
[>][≢]-sub : ⦃ sym : Symmetry(_≢_) ⦄ → ((_>_) ⊆₂ (_≢_))
_⊆₂_.proof [>][≢]-sub = symmetry(_≢_) ∘ sub₂(_<_)(_≢_)
-- [<]-transitivity : ⦃ [≤]-trans : Transitivity(_≤_) ⦄ → Transitivity(_<_)
-- Transitivity.proof [<]-transitivity ([∧]-intro xy neq-xy) ([∧]-intro yz neq-yz) = [∧]-intro (transitivity(_≤_) xy yz) {!!} xy
{-
instance
[<][≤]-subtransitivityₗ : Subtransitivityₗ(_<_)(_≤_)
left (Subtransitivityₗ.proof [<][≤]-subtransitivityₗ xy ([∧]-intro yz nyz)) = transitivity(_≤_) xy yz
Tuple.right (Subtransitivityₗ.proof [<][≤]-subtransitivityₗ xy yz) xz = {!!}
postulate instance [<][≤]-subtransitivityᵣ : Subtransitivityᵣ(_<_)(_≤_)
postulate instance [≤][≡]-subtransitivityₗ : Subtransitivityₗ(_≤_)(_≡_)
postulate instance [≤][≡]-subtransitivityᵣ : Subtransitivityᵣ(_≤_)(_≡_)
-}
module From-[≤][<]
⦃ equiv : Equiv{ℓₑ}(T) ⦄
(_≤_ : T → T → Stmt{ℓₗₑ}) ⦃ [≤]-relator : BinaryRelator(_≤_) ⦄
(_<_ : T → T → Stmt{ℓₗₜ}) ⦃ [<]-relator : BinaryRelator(_<_) ⦄
where
open Relator.Ordering.From-[≤][<] (_≤_)(_<_)
private variable a b : T
[≤]-def-[<][≡]ₗ-[<]-def-[≤][≢]ᵣ : ((∀{a b} → (a ≤ b) ← ((a < b) ∨ (a ≡ b))) ∧ Irreflexivity(_<_)) ↔ ((∀{a b} → (a < b) → ((a ≤ b) ∧ (a ≢ b))) ∧ Reflexivity(_≤_))
[≤]-def-[<][≡]ₗ-[<]-def-[≤][≢]ᵣ = [↔]-intro (\([∧]-intro p q) → l p ⦃ q ⦄) (\([∧]-intro p q) → r p ⦃ q ⦄) where
l : (∀{a b} → (a < b) → ((a ≤ b) ∧ (a ≢ b))) → ⦃ refl : Reflexivity(_≤_) ⦄ → ((∀{a b} → (a ≤ b) ← ((a < b) ∨ (a ≡ b))) ∧ Irreflexivity(_<_))
l [<]-def-[≤][≢]ᵣ = [∧]-intro
([∨]-elim (lt ↦ [∧]-elimₗ ([<]-def-[≤][≢]ᵣ lt)) (sub₂(_≡_)(_≤_) ⦃ reflexive-binaryRelator-sub ⦄))
(intro(xx ↦ [∧]-elimᵣ ([<]-def-[≤][≢]ᵣ xx) (reflexivity(_≡_))))
r : (∀{a b} → (a ≤ b) ← ((a < b) ∨ (a ≡ b))) → ⦃ irrefl : Irreflexivity(_<_) ⦄ → ((∀{a b} → (a < b) → ((a ≤ b) ∧ (a ≢ b))) ∧ Reflexivity(_≤_))
r [≤]-def-[<][≡]ᵣ = [∧]-intro
(lt ↦ [∧]-intro ([≤]-def-[<][≡]ᵣ ([∨]-introₗ lt)) (eq ↦ empty(irreflexivity(_<_) (substitute₂ₗ(_<_) eq lt))))
(intro ([≤]-def-[<][≡]ᵣ ([∨]-introᵣ (reflexivity(_≡_)))))
module By-[≤] ([<]-def-[≤][≢] : ∀{a b} → (a < b) ↔ ((a ≤ b) ∧ (a ≢ b))) where
instance
[<][≤]-sub : (_<_) ⊆₂ (_≤_)
_⊆₂_.proof [<][≤]-sub = [∧]-elimₗ ∘ [↔]-to-[→] [<]-def-[≤][≢]
instance
[<][≢]-sub : (_<_) ⊆₂ (_≢_)
_⊆₂_.proof [<][≢]-sub = [∧]-elimᵣ ∘ [↔]-to-[→] [<]-def-[≤][≢]
module _ ⦃ [≡]-classical : ∀{a b : T} → Classical(a ≡ b) ⦄ where
[≤]-def-[<][≡]ᵣ-by-classical : (a ≤ b) → ((a < b) ∨ (a ≡ b))
[≤]-def-[<][≡]ᵣ-by-classical {a}{b} le with excluded-middle(a ≡ b)
... | [∨]-introₗ eq = [∨]-introᵣ eq
... | [∨]-introᵣ ne = [∨]-introₗ ([↔]-to-[←] [<]-def-[≤][≢] ([∧]-intro le ne))
module _ ⦃ [<]-tri : ConverseTrichotomy(_<_)(_≡_) ⦄ ⦃ [≤]-antisym : Antisymmetry(_≤_)(_≡_) ⦄ where
[≤]-def-[<][≡]ᵣ-by-tri-antisym : (a ≤ b) → ((a < b) ∨ (a ≡ b))
[≤]-def-[<][≡]ᵣ-by-tri-antisym {a}{b} le with trichotomy(_<_)(_≡_) {a}{b}
... | [∨]-introₗ ([∨]-introₗ lt) = [∨]-introₗ lt
... | [∨]-introₗ ([∨]-introᵣ eq) = [∨]-introᵣ eq
... | [∨]-introᵣ gt = [∨]-introᵣ (antisymmetry(_≤_)(_≡_) le ([∧]-elimₗ ([↔]-to-[→] [<]-def-[≤][≢] gt)))
[<]-asymmetry-by-antisym : ⦃ antisym : Antisymmetry(_≤_)(_≡_) ⦄ → Asymmetry(_<_)
Asymmetry.proof [<]-asymmetry-by-antisym xy yx =
let [∧]-intro xy-le nxy = [↔]-to-[→] [<]-def-[≤][≢] xy
[∧]-intro yx-le nyx = [↔]-to-[→] [<]-def-[≤][≢] yx
in nxy(antisymmetry(_≤_)(_≡_) xy-le yx-le)
instance
[<]-irreflexivity : Irreflexivity(_<_)
Irreflexivity.proof [<]-irreflexivity xx = [∧]-elimᵣ ([↔]-to-[→] [<]-def-[≤][≢] xx) (reflexivity(_≡_))
[<]-transitivity-by-asym-trans : ⦃ antisym : Asymmetry(_<_) ⦄ → ⦃ trans : Transitivity(_≤_) ⦄ → Transitivity(_<_)
Transitivity.proof [<]-transitivity-by-asym-trans xy yz =
let [∧]-intro xy-le nxy = [↔]-to-[→] [<]-def-[≤][≢] xy
[∧]-intro yz-le nyz = [↔]-to-[→] [<]-def-[≤][≢] yz
in [↔]-to-[←] [<]-def-[≤][≢] ([∧]-intro (transitivity(_≤_) xy-le yz-le) (xz ↦ asymmetry(_<_) (substitute₂ₗ(_<_) xz xy) yz))
module By-[<] ([≤]-def-[<][≡] : ∀{a b} → (a ≤ b) ↔ ((a < b) ∨ (a ≡ b))) where
instance
[<][≤]-sub : (_<_) ⊆₂ (_≤_)
_⊆₂_.proof [<][≤]-sub = [↔]-to-[←] [≤]-def-[<][≡] ∘ [∨]-introₗ
instance
[≡][≤]-sub : (_≡_) ⊆₂ (_≤_)
_⊆₂_.proof [≡][≤]-sub = [↔]-to-[←] [≤]-def-[<][≡] ∘ [∨]-introᵣ
instance
[≰][≮]-sub : (_≰_) ⊆₂ (_≮_)
_⊆₂_.proof [≰][≮]-sub = contrapositiveᵣ(sub₂(_<_)(_≤_))
instance
[≰][≢]-sub : (_≰_) ⊆₂ (_≢_)
_⊆₂_.proof [≰][≢]-sub = contrapositiveᵣ(sub₂(_≡_)(_≤_))
instance
[>][≥]-sub : (_>_) ⊆₂ (_≥_)
_⊆₂_.proof [>][≥]-sub = sub₂(_<_)(_≤_)
instance
[≡][≥]-sub : (_≡_) ⊆₂ (_≥_)
_⊆₂_.proof [≡][≥]-sub = sub₂(_≡_)(_≤_) ∘ symmetry(_≡_)
instance
[≱][≯]-sub : (_≱_) ⊆₂ (_≯_)
_⊆₂_.proof [≱][≯]-sub = sub₂(_≰_)(_≮_)
instance
[≱][≢]-sub : (_≱_) ⊆₂ (_≢_)
_⊆₂_.proof [≱][≢]-sub = (_∘ symmetry(_≡_)) ∘ sub₂(_≰_)(_≢_)
[<]-def-[≤][≢]ₗ : (a < b) ← ((a ≤ b) ∧ (a ≢ b))
[<]-def-[≤][≢]ₗ([∧]-intro le ne) = [∨]-elim id ([⊥]-elim ∘ ne) ([↔]-to-[→] [≤]-def-[<][≡] le)
instance
[≤]-reflexivity : Reflexivity(_≤_)
Reflexivity.proof [≤]-reflexivity = [↔]-to-[←] [≤]-def-[<][≡] ([∨]-introᵣ (reflexivity(_≡_)))
[≤]-transitivity-by-trans : ⦃ [<]-trans : Transitivity(_<_) ⦄ → Transitivity(_≤_)
Transitivity.proof [≤]-transitivity-by-trans xy yz with [↔]-to-[→] [≤]-def-[<][≡] xy | [↔]-to-[→] [≤]-def-[<][≡] yz
... | [∨]-introₗ xy-lt | [∨]-introₗ yz-lt = [↔]-to-[←] [≤]-def-[<][≡] ([∨]-introₗ (transitivity(_<_) xy-lt yz-lt))
... | [∨]-introₗ xy-lt | [∨]-introᵣ yz-eq = [↔]-to-[←] [≤]-def-[<][≡] ([∨]-introₗ (substitute₂ᵣ(_<_) yz-eq xy-lt))
... | [∨]-introᵣ xy-eq | [∨]-introₗ yz-lt = [↔]-to-[←] [≤]-def-[<][≡] ([∨]-introₗ (substitute₂ₗ(_<_) (symmetry(_≡_) xy-eq) yz-lt))
... | [∨]-introᵣ xy-eq | [∨]-introᵣ yz-eq = [↔]-to-[←] [≤]-def-[<][≡] ([∨]-introᵣ (transitivity(_≡_) xy-eq yz-eq))
module _ ⦃ asym : Asymmetry(_<_) ⦄ where
[≤]-antisymmetry-by-asym : Antisymmetry(_≤_)(_≡_)
Antisymmetry.proof [≤]-antisymmetry-by-asym le ge with [↔]-to-[→] [≤]-def-[<][≡] le | [↔]-to-[→] [≤]-def-[<][≡] ge
... | [∨]-introₗ lt | [∨]-introₗ gt with () ← asymmetry(_<_) lt gt
... | [∨]-introₗ lt | [∨]-introᵣ eq = symmetry(_≡_) eq
... | [∨]-introᵣ eq | [∨]-introₗ gt = eq
... | [∨]-introᵣ eq₁ | [∨]-introᵣ eq₂ = eq₁
[<]-transitivity-by-asym-trans : ⦃ trans : Transitivity(_≤_) ⦄ → Transitivity(_<_)
Transitivity.proof [<]-transitivity-by-asym-trans {x}{y}{z} xy yz =
• (
• (xy ⇒
(x < y) ⇒-[ [↔]-to-[←] [≤]-def-[<][≡] ∘ [∨]-introₗ ]
(x ≤ y) ⇒-end
)
• (yz ⇒
(y < z) ⇒-[ [↔]-to-[←] [≤]-def-[<][≡] ∘ [∨]-introₗ ]
(y ≤ z) ⇒-end
)
⇒₂-[ transitivity(_≤_) ]
(x ≤ z) ⇒-[ [↔]-to-[→] [≤]-def-[<][≡] ]
(x < z) ∨ (x ≡ z) ⇒-end
)
• (
(\xz →
• (xz ⇒
(x ≡ z) ⇒-[ apply xy ∘ substitute₂ₗ(_<_) ]
(z < y) ⇒-end
)
• (yz ⇒
(y < z) ⇒-end
)
⇒₂-[ asymmetry(_<_) ]
⊥ ⇒-end
) ⇒
(x ≢ z) ⇒-end
)
⇒₂-[ [∨]-not-right ]
(x < z) ⇒-end
[<][≱]-sub-by-asym : ((_<_) ⊆₂ (_≱_))
_⊆₂_.proof [<][≱]-sub-by-asym lt-xy ge-xy = [∨]-elim
(lt-yx ↦ asymmetry(_<_) lt-xy lt-yx)
(eq-yx ↦ irreflexivity(_<_) ⦃ [asymmetry]-to-irreflexivity ⦄ (substitute₂ᵣ(_<_) eq-yx lt-xy))
([↔]-to-[→] [≤]-def-[<][≡] ge-xy)
[>][≰]-sub-by-asym : ((_>_) ⊆₂ (_≰_))
_⊆₂_.proof [>][≰]-sub-by-asym gt le = [∨]-elim
(asymmetry(_<_) gt)
(eq ↦ irreflexivity(_<_) ⦃ [asymmetry]-to-irreflexivity ⦄ (substitute₂ᵣ(_<_) eq gt))
([↔]-to-[→] [≤]-def-[<][≡] le)
module _
⦃ [<]-classical : Classical₂(_<_) ⦄
⦃ [≡]-classical : Classical₂(_≡_) ⦄
where
[≤]-classical-by-classical : Classical₂(_≤_)
Classical.excluded-middle ([≤]-classical-by-classical {x}{y}) with excluded-middle(x < y) | excluded-middle(x ≡ y)
... | [∨]-introₗ lt | _ = [∨]-introₗ (sub₂(_<_)(_≤_) lt)
... | [∨]-introᵣ nlt | [∨]-introₗ eq = [∨]-introₗ (sub₂(_≡_)(_≤_) eq)
... | [∨]-introᵣ nlt | [∨]-introᵣ ne = [∨]-introᵣ (le ↦ nlt ([<]-def-[≤][≢]ₗ ([∧]-intro le ne)))
module _
⦃ [<]-asym : Asymmetry(_<_) ⦄
⦃ [<]-total : ConverseTrichotomy(_<_)(_≡_) ⦄
where
[≤]-classical-by-asym-tri : Classical₂(_≤_)
Classical.excluded-middle ([≤]-classical-by-asym-tri {x} {y}) with trichotomy(_<_)(_≡_) {x}{y}
... | [∨]-introₗ([∨]-introₗ lt) = [∨]-introₗ (sub₂(_<_)(_≤_) lt)
... | [∨]-introₗ([∨]-introᵣ eq) = [∨]-introₗ (sub₂(_≡_)(_≤_) eq)
... | [∨]-introᵣ gt =
let [<]-def-[≤][≢]ᵣ = [∧]-elimₗ ([↔]-to-[→] [≤]-def-[<][≡]ₗ-[<]-def-[≤][≢]ᵣ ([∧]-intro ([↔]-to-[←] [≤]-def-[<][≡]) [asymmetry]-to-irreflexivity))
[∧]-intro ge ne = [<]-def-[≤][≢]ᵣ gt
in [∨]-introᵣ (ne ∘ antisymmetry(_≤_)(_≡_) ⦃ [≤]-antisymmetry-by-asym ⦄ ge)
-- TODO: Move to Structure.Relator.Properties.Proofs
module _
⦃ [<]-asym : Asymmetry(_<_) ⦄
⦃ [<]-total : ConverseTrichotomy(_<_)(_≡_) ⦄
where
[<]-classical-by-asym-tri : Classical₂(_<_)
Classical.excluded-middle ([<]-classical-by-asym-tri {x} {y}) with trichotomy(_<_)(_≡_) {x}{y}
... | [∨]-introₗ([∨]-introₗ lt) = [∨]-introₗ lt
... | [∨]-introₗ([∨]-introᵣ eq) = [∨]-introᵣ (lt ↦ irreflexivity(_<_) ⦃ [asymmetry]-to-irreflexivity ⦄ (substitute₂ₗ(_<_) eq lt))
... | [∨]-introᵣ gt = [∨]-introᵣ (lt ↦ asymmetry(_<_) lt gt)
module ByReflTriSub
⦃ [≤]-refl : Reflexivity(_≤_) ⦄
⦃ [<]-total : ConverseTrichotomy(_<_)(_≡_) ⦄
⦃ [<][≤]-sub : (_<_) ⊆₂ (_≤_) ⦄
where
[≰][≯]-not : (a ≰ b) → (a ≯ b) → ⊥
[≰][≯]-not {a}{b} nle ngt with trichotomy(_<_)(_≡_) {a}{b}
... | [∨]-introₗ([∨]-introₗ lt) = nle (sub₂(_<_)(_≤_) lt)
... | [∨]-introₗ([∨]-introᵣ eq) = substitute₂ₗ(_≰_) ⦃ [¬]-binaryRelator ⦄ eq nle (reflexivity(_≤_))
... | [∨]-introᵣ gt = ngt gt
[≮][≱]-not : (a ≮ b) → (a ≱ b) → ⊥
[≮][≱]-not = swap [≰][≯]-not
module _ ⦃ [<]-classical : Classical₂(_<_) ⦄ where
[≰][>]-sub : (_≰_) ⊆₂ (_>_)
_⊆₂_.proof [≰][>]-sub = [¬¬]-elim ∘ [≰][≯]-not
[≱][<]-sub : (_≱_) ⊆₂ (_<_)
_⊆₂_.proof [≱][<]-sub = _⊆₂_.proof [≰][>]-sub
module _ ⦃ [≤]-classical : Classical₂(_≤_) ⦄ where
[≯][≤]-sub : (_≯_) ⊆₂ (_≤_)
_⊆₂_.proof [≯][≤]-sub = [¬¬]-elim ∘ swap [≰][≯]-not
[≮][≥]-sub : (_≮_) ⊆₂ (_≥_)
_⊆₂_.proof [≮][≥]-sub = _⊆₂_.proof [≯][≤]-sub
module _
⦃ [≤]-classical : Classical₂(_≤_) ⦄
⦃ [<]-classical : Classical₂(_<_) ⦄
where
[≤]-or-[>] : (a ≤ b) ∨ (a > b)
[≤]-or-[>] {a}{b} with excluded-middle(a ≤ b)
... | [∨]-introₗ a≤b = [∨]-introₗ a≤b
... | [∨]-introᵣ a≰b = [∨]-introᵣ (sub₂(_≰_)(_>_) ⦃ [≰][>]-sub ⦄ a≰b)
[≥]-or-[<] : (a ≥ b) ∨ (a < b)
[≥]-or-[<] {a}{b} with excluded-middle(a ≥ b)
... | [∨]-introₗ a≥b = [∨]-introₗ a≥b
... | [∨]-introᵣ a≱b = [∨]-introᵣ (sub₂(_≱_)(_<_) ⦃ [≱][<]-sub ⦄ a≱b)
module ByStrictPartialOrder ([≤]-def-[<][≡] : ∀{a b} → (a ≤ b) ↔ ((a < b) ∨ (a ≡ b))) ⦃ ord : Strict.PartialOrder(_<_) ⦄ where
open By-[<] [≤]-def-[<][≡]
open By-[<] [≤]-def-[<][≡] public
using
( [<][≤]-sub
; [≡][≤]-sub
; [≰][≮]-sub
; [≰][≢]-sub
; [>][≥]-sub
; [≡][≥]-sub
; [≱][≯]-sub
; [≱][≢]-sub
; [<]-def-[≤][≢]ₗ
; [≤]-reflexivity
)
instance
[≤]-transitivity : Transitivity(_≤_)
[≤]-transitivity = [≤]-transitivity-by-trans
instance
[≤]-antisymmetry : Antisymmetry(_≤_)(_≡_)
[≤]-antisymmetry = [≤]-antisymmetry-by-asym
instance
[≤]-weakPartialorder : Weak.PartialOrder(_≤_)(_≡_)
[≤]-weakPartialorder = record{}
instance
[<][≱]-sub : ((_<_) ⊆₂ (_≱_))
[<][≱]-sub = [<][≱]-sub-by-asym
instance
[>][≰]-sub : ((_>_) ⊆₂ (_≰_))
[>][≰]-sub = [>][≰]-sub-by-asym
module ByStrictTotalOrder ([≤]-def-[<][≡] : ∀{a b} → (a ≤ b) ↔ ((a < b) ∨ (a ≡ b))) ⦃ ord : Strict.TotalOrder(_<_)(_≡_) ⦄ where
open By-[<] [≤]-def-[<][≡]
open ByStrictPartialOrder [≤]-def-[<][≡] public
instance
[<]-classical : Classical₂(_<_)
[<]-classical = [<]-classical-by-asym-tri
instance
[≤]-classical : Classical₂(_≤_)
[≤]-classical = [≤]-classical-by-asym-tri
[≰][≯]-not : (a ≰ b) → (a ≯ b) → ⊥
[≰][≯]-not = ByReflTriSub.[≰][≯]-not
[≮][≱]-not : (a ≮ b) → (a ≱ b) → ⊥
[≮][≱]-not = ByReflTriSub.[≮][≱]-not
instance
[≰][>]-sub : (_≰_) ⊆₂ (_>_)
[≰][>]-sub = ByReflTriSub.[≰][>]-sub
instance
[≱][<]-sub : (_≱_) ⊆₂ (_<_)
[≱][<]-sub = ByReflTriSub.[≱][<]-sub
instance
[≯][≤]-sub : (_≯_) ⊆₂ (_≤_)
[≯][≤]-sub = ByReflTriSub.[≯][≤]-sub
instance
[≮][≥]-sub : (_≮_) ⊆₂ (_≥_)
[≮][≥]-sub = ByReflTriSub.[≮][≥]-sub
[≤]-or-[>] : (a ≤ b) ∨ (a > b)
[≤]-or-[>] = ByReflTriSub.[≤]-or-[>]
[≥]-or-[<] : (a ≥ b) ∨ (a < b)
[≥]-or-[<] = ByReflTriSub.[≥]-or-[<]
| {
"alphanum_fraction": 0.4596734044,
"avg_line_length": 38.8510638298,
"ext": "agda",
"hexsha": "6be7421060b16c316f00bf186a47e3f3ba381ef5",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Relator/Ordering/Proofs.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Relator/Ordering/Proofs.agda",
"max_line_length": 163,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Relator/Ordering/Proofs.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z",
"num_tokens": 9443,
"size": 20086
} |
module HasSatisfaction where
open import OscarPrelude
open import Interpretation
record HasSatisfaction (A : Set) : Set₁
where
field
_⊨_ : Interpretation → A → Set
_⊭_ : Interpretation → A → Set
_⊭_ I = ¬_ ∘ I ⊨_
open HasSatisfaction ⦃ … ⦄ public
{-# DISPLAY HasSatisfaction._⊨_ _ = _⊨_ #-}
{-# DISPLAY HasSatisfaction._⊭_ _ = _⊭_ #-}
instance HasSatisfactionList : {A : Set} ⦃ _ : HasSatisfaction A ⦄ → HasSatisfaction $ List A
HasSatisfaction._⊨_ HasSatisfactionList I [] = ⊤
HasSatisfaction._⊨_ HasSatisfactionList I (x ∷ xs) = I ⊨ x × I ⊨ xs
module _ {A} ⦃ _ : HasSatisfaction A ⦄
where
⊨_ : A → Set
⊨ x = (I : Interpretation) → I ⊨ x
⊭_ : A → Set
⊭_ = ¬_ ∘ ⊨_
record HasDecidableValidation (A : Set) ⦃ _ : HasSatisfaction A ⦄ : Set₁
where
field
⊨?_ : (x : A) → Dec $ ⊨ x
open HasDecidableValidation ⦃ … ⦄ public
{-# DISPLAY HasDecidableValidation.⊨?_ _ = ⊨?_ #-}
record HasDecidableSatisfaction (A : Set) ⦃ _ : HasSatisfaction A ⦄ : Set₁
where
field
_⊨?_ : (I : Interpretation) → (x : A) → Dec (I ⊨ x)
open HasDecidableSatisfaction ⦃ … ⦄ public
{-# DISPLAY HasDecidableSatisfaction._⊨?_ _ = _⊨?_ #-}
| {
"alphanum_fraction": 0.6384814495,
"avg_line_length": 23.18,
"ext": "agda",
"hexsha": "db56e39109dcca412739a3ca91b415974621b48c",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_forks_repo_licenses": [
"RSA-MD"
],
"max_forks_repo_name": "m0davis/oscar",
"max_forks_repo_path": "archive/agda-1/HasSatisfaction.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z",
"max_issues_repo_licenses": [
"RSA-MD"
],
"max_issues_repo_name": "m0davis/oscar",
"max_issues_repo_path": "archive/agda-1/HasSatisfaction.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-1/HasSatisfaction.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 454,
"size": 1159
} |
{-# OPTIONS --without-K --safe #-}
open import Algebra
open import Relation.Unary
open import Relation.Binary hiding (Decidable)
module Data.FingerTree.Split.Intermediate
{r m}
(ℳ : Monoid r m)
{s}
{ℙ : Pred (Monoid.Carrier ℳ) s}
(ℙ-resp : ℙ Respects (Monoid._≈_ ℳ))
(ℙ? : Decidable ℙ)
where
open import Relation.Nullary using (¬_; yes; no; Dec)
open import Level using (_⊔_)
open import Data.Product
open import Function
open import Data.List as List using (List; _∷_; [])
open import Data.FingerTree.Measures ℳ
open import Data.FingerTree.Structures ℳ
open import Data.FingerTree.Reasoning ℳ
open import Data.FingerTree.View ℳ using (deepₗ; deepᵣ)
open import Data.FingerTree.Cons ℳ using (listToTree)
open import Relation.Nullary using (Dec; yes; no)
open import Relation.Nullary.Decidable using (True; toWitness; False; toWitnessFalse)
open σ ⦃ ... ⦄
open Monoid ℳ renaming (Carrier to 𝓡)
open import Data.FingerTree.Relation.Binary.Reasoning.FasterInference.Setoid setoid
open import Data.FingerTree.Split.Point ℳ ℙ-resp ℙ?
open import Data.FingerTree.Split.StoredPredicate ℳ ℙ-resp ℙ?
open import Data.Empty.Irrelevant using (⊥-elim)
record Split′ (i : 𝓡) {a b} (Σ : Set a) (A : Set b) ⦃ _ : σ Σ ⦄ ⦃ _ : σ A ⦄ : Set (a ⊔ b ⊔ s) where
constructor _∷⟨_⟩∷_[_]
field
left′ : Σ
focus′ : A
right′ : Σ
.proof′ : i ∙ μ left′ ∣ μ focus′
open Split′ public
instance
σ-Split′ : ∀ {a b} {Σ : Set a} {A : Set b} ⦃ _ : σ Σ ⦄ ⦃ _ : σ A ⦄ {i : 𝓡} → σ (Split′ i Σ A)
μ ⦃ σ-Split′ {i = i} ⦄ (l ∷⟨ x ⟩∷ r [ _ ]) = i ∙ (μ l ∙ (μ x ∙ μ r))
infixl 2 _i≈[_]
_i≈[_] : ∀ {a b} {Σ : Set a} {A : Set b} ⦃ _ : σ Σ ⦄ ⦃ _ : σ A ⦄
→ ∀ {i xs}
→ μ⟨ Split′ i Σ A ⟩≈ (i ∙ xs)
→ ∀ {j}
→ i ≈ j → μ⟨ Split′ j Σ A ⟩≈ (j ∙ xs)
xs ∷⟨ x ⟩∷ ys [ p₁ ] ⇑[ p₂ ] i≈[ i≈ ] = xs ∷⟨ x ⟩∷ ys [ p₁ ≈◄⟅ ≪∙ i≈ ⟆ ] ⇑[ ≪∙ sym i≈ ⍮ p₂ ⍮ ≪∙ i≈ ]
{-# INLINE _i≈[_] #-}
| {
"alphanum_fraction": 0.6016771488,
"avg_line_length": 30.7741935484,
"ext": "agda",
"hexsha": "d60be980ebec736b2f83ef7dbd4b2190868dd20e",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "39c3d96937384b052b782ffddf4fdec68c5d139f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/agda-indexed-fingertree",
"max_forks_repo_path": "src/Data/FingerTree/Split/Intermediate.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "39c3d96937384b052b782ffddf4fdec68c5d139f",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "oisdk/agda-indexed-fingertree",
"max_issues_repo_path": "src/Data/FingerTree/Split/Intermediate.agda",
"max_line_length": 100,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "39c3d96937384b052b782ffddf4fdec68c5d139f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/agda-indexed-fingertree",
"max_stars_repo_path": "src/Data/FingerTree/Split/Intermediate.agda",
"max_stars_repo_stars_event_max_datetime": "2019-02-26T07:04:54.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-02-26T07:04:54.000Z",
"num_tokens": 799,
"size": 1908
} |
{-# OPTIONS --safe #-}
module Cubical.Algebra.AbGroup.Instances.Unit where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Data.Unit renaming (Unit* to UnitType)
open import Cubical.Algebra.AbGroup
open import Cubical.Algebra.Group.Instances.Unit using (UnitGroup)
open import Cubical.Algebra.Group.Base using (GroupStr)
private
variable
ℓ : Level
open AbGroupStr
open IsAbGroup
UnitAbGroup : AbGroup ℓ
fst UnitAbGroup = UnitType
0g (snd UnitAbGroup) = tt*
_+_ (snd UnitAbGroup) = λ _ _ → tt*
- snd UnitAbGroup = λ _ → tt*
isGroup (isAbGroup (snd UnitAbGroup)) = GroupStr.isGroup (snd UnitGroup)
+Comm (isAbGroup (snd UnitAbGroup)) = λ _ _ → refl
| {
"alphanum_fraction": 0.7637130802,
"avg_line_length": 26.3333333333,
"ext": "agda",
"hexsha": "addd4fb3dbbcd06ab42b4154900c3a6b064e7dad",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "thomas-lamiaux/cubical",
"max_forks_repo_path": "Cubical/Algebra/AbGroup/Instances/Unit.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "thomas-lamiaux/cubical",
"max_issues_repo_path": "Cubical/Algebra/AbGroup/Instances/Unit.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "thomas-lamiaux/cubical",
"max_stars_repo_path": "Cubical/Algebra/AbGroup/Instances/Unit.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 204,
"size": 711
} |
-- Andreas, 2019-05-30, issue #3824:
-- Named where module should be in scope even if defined under a rewrite.
open import Agda.Builtin.Equality
postulate
A : Set
a b : A
a≡b : a ≡ b
P : A → Set
cast : P a → P b
cast p rewrite a≡b = q
module M where
q = p
test : P b → P b
test = M.q
-- ERROR WAS: M.q not in scope.
module Test = M
-- ERROR WAS: M not in scope.
-- Should succeed.
| {
"alphanum_fraction": 0.6117936118,
"avg_line_length": 15.0740740741,
"ext": "agda",
"hexsha": "d220a8775e5531e0da799a53f48b22fcb8b5dc55",
"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/Issue3824.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/Issue3824.agda",
"max_line_length": 73,
"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/Issue3824.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": 143,
"size": 407
} |
module TelescopingLet4 where
module Star where
★ : Set₁
★ = Set
★₁ : Set₂
★₁ = Set₁
data D5 (open Star using (★₁)) : ★₁ where
| {
"alphanum_fraction": 0.6131386861,
"avg_line_length": 12.4545454545,
"ext": "agda",
"hexsha": "d2deec5c635d89d97020c1db375880cd652fe84c",
"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/TelescopingLet4.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/TelescopingLet4.agda",
"max_line_length": 41,
"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/TelescopingLet4.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": 53,
"size": 137
} |
open import Data.Bool.Base using (Bool)
------------------------------------------------------------------------
-- The Agda standard library
--
-- IO
------------------------------------------------------------------------
open import Coinduction
open import Data.Unit
open import Data.String
open import Data.Colist
open import Function
import IO.Primitive as Prim
open import Level
------------------------------------------------------------------------
-- The IO monad
-- One cannot write "infinitely large" computations with the
-- postulated IO monad in IO.Primitive without turning off the
-- termination checker (or going via the FFI, or perhaps abusing
-- something else). The following coinductive deep embedding is
-- introduced to avoid this problem. Possible non-termination is
-- isolated to the run function below.
infixl 1 _>>=_ _>>_
data IO {a} (A : Set a) : Set (suc a) where
lift : (m : Prim.IO A) → IO A
return : (x : A) → IO A
_>>=_ : {B : Set a} (m : ∞ (IO B)) (f : (x : B) → ∞ (IO A)) → IO A
_>>_ : {B : Set a} (m₁ : ∞ (IO B)) (m₂ : ∞ (IO A)) → IO A
{-# NON_TERMINATING #-}
run : ∀ {a} {A : Set a} → IO A → Prim.IO A
run (lift m) = m
run (return x) = Prim.return x
run (m >>= f) = Prim._>>=_ (run (♭ m )) λ x → run (♭ (f x))
run (m₁ >> m₂) = Prim._>>=_ (run (♭ m₁)) λ _ → run (♭ m₂)
putStr∞ : Costring → IO ⊤
putStr∞ s =
♯ lift (Prim.putStr s) >>
♯ return _
putStr : String → IO ⊤
putStr s = putStr∞ (toCostring s)
putStrLn∞ : Costring → IO ⊤
putStrLn∞ s =
♯ lift (Prim.putStrLn s) >>
♯ return _
putStrLn : String → IO ⊤
putStrLn s = putStrLn∞ (toCostring s)
_∨_ : Bool → Bool → Bool
Bool.true ∨ _ = Bool.true
Bool.false ∨ b = b
_∧_ : Bool → Bool → Bool
Bool.false ∧ _ = Bool.false
Bool.true ∧ b = b
if_then_else_ : {A : Set} → Bool → A → A → A
if Bool.true then a else _ = a
if Bool.false then _ else b = b
----------------------------------------
_>>>_ : String → String → String
_>>>_ = primStringAppend
infixl 1 _>>>_
----------------------------------------
data Principle : Set where
# : String → Principle
_=p=_ : Principle → Principle → Bool
(# a) =p= (# b) = a == b
----------------------------------------
data List (A : Set) : Set where
[] : List A
_∷_ : A → List A → List A
infixr 5 _∷_
[[_]] : {A : Set} → A → List A
[[ x ]] = x ∷ []
any : {A : Set} → (A → Bool) → List A → Bool
any _ [] = Bool.false
any f (x ∷ xs) = (f x) ∨ (any f xs)
_∈∈_ : Principle → List Principle → Bool
x ∈∈ [] = Bool.false
x ∈∈ (y ∷ ys) with x =p= y
... | Bool.true = Bool.true
... | Bool.false = x ∈∈ ys
_∋∋_ : List Principle → Principle → Bool
xs ∋∋ y = y ∈∈ xs
----------------------------------------
data Arrow : Set where
⇒_ : Principle → Arrow
_⇒_ : Principle → Arrow → Arrow
_≡≡_ : Arrow → Arrow → Bool
(⇒ q) ≡≡ (⇒ s) = q =p= s
(p ⇒ q) ≡≡ (r ⇒ s) = (p =p= r) ∧ (q ≡≡ s)
_ ≡≡ _ = Bool.false
_∈∈∈∈_ : Arrow → List Arrow → Bool
x ∈∈∈∈ [] = Bool.false
x ∈∈∈∈ (y ∷ ys) with x ≡≡ y
... | Bool.true = Bool.true
... | Bool.false = x ∈∈∈∈ ys
closure : List Arrow → List Principle → List Principle
closure [] found = found
closure ((⇒ n) ∷ rest) found = n ∷ (closure rest (n ∷ found))
closure ((n ⇒ q) ∷ rest) found with (n ∈∈ found) ∨ (n ∈∈ (closure rest found))
... | Bool.true = closure (q ∷ rest) found
... | Bool.false = closure rest found
_,_⊢_ : List Arrow → List Principle → Principle → Bool
cs , ps ⊢ q = q ∈∈ (closure cs ps)
_⊢_ : List Arrow → Arrow → Bool
cs ⊢ (⇒ q) = q ∈∈ (closure cs [])
cs ⊢ (p ⇒ q) = ((⇒ p) ∷ cs) ⊢ q
----------------------------------------
data Separation : Set where
model : List Principle → List Principle → Separation
modelsupports : Separation → List Arrow → Principle → Bool
modelsupports (model holds _) cs n = cs , holds ⊢ n
modeldenies : Separation → List Arrow → Principle → Bool
modeldenies (model _ fails) cs n = any (_∋∋_ (closure cs ([[ n ]]))) fails
_⟪!_⟫_ : List Arrow → Separation → Arrow → Bool
cs ⟪! m ⟫ (⇒ q) = modeldenies m cs q
cs ⟪! m ⟫ (p ⇒ q) = (modelsupports m cs p) ∧ (cs ⟪! m ⟫ q)
_⟪_⟫_ : List Arrow → List Separation → Arrow → Bool
cs ⟪ [] ⟫ arr = Bool.false
cs ⟪ m ∷ ms ⟫ arr = (cs ⟪! m ⟫ arr) ∨ (cs ⟪ ms ⟫ arr)
----------------------------------------
data Relation : Set where
Proved : Relation
Derivable : Relation
Separated : Relation
Unknown : Relation
consider : List Arrow → List Separation → Arrow → Relation
consider cs ms arr with (arr ∈∈∈∈ cs)
... | Bool.true = Proved
... | Bool.false with (cs ⊢ arr)
... | Bool.true = Derivable
... | Bool.false with (cs ⟪ ms ⟫ arr)
... | Bool.true = Separated
... | Bool.false = Unknown
proofs : List Arrow
proofs =
((# "3") ⇒ (⇒ (# "4"))) ∷
-- ((# "5") ⇒ (⇒ (# "4"))) ∷
((# "6") ⇒ (⇒ (# "4"))) ∷
((# "3") ⇒ (⇒ (# "3"))) ∷
((# "3") ⇒ (⇒ (# "3"))) ∷
((# "9") ⇒ (⇒ (# "3"))) ∷
((# "9") ⇒ (⇒ (# "3"))) ∷
((# "5") ⇒ (⇒ (# "7"))) ∷
((# "9") ⇒ (⇒ (# "7"))) ∷
((# "6") ⇒ (⇒ (# "8"))) ∷
((# "10") ⇒ (⇒ (# "8"))) ∷
((# "10") ⇒ (⇒ (# "7"))) ∷
((# "5") ⇒ (⇒ (# "10"))) ∷
((# "10") ⇒ (⇒ (# "4"))) ∷
((# "5") ⇒ (⇒ (# "11"))) ∷
((# "6") ⇒ (⇒ (# "11"))) ∷
((# "11") ⇒ (⇒ (# "4"))) ∷
((# "10") ⇒ (⇒ (# "7"))) ∷
((# "8") ⇒ (⇒ (# "4"))) ∷
((# "9") ⇒ (⇒ (# "7"))) ∷
((# "9") ⇒ (⇒ (# "8"))) ∷
((# "3") ⇒ (⇒ (# "8"))) ∷
((# "5") ⇒ ((# "3") ⇒ (⇒ (# "9")))) ∷
((# "6") ⇒ ((# "7") ⇒ (⇒ (# "10")))) ∷
((# "6") ⇒ ((# "3") ⇒ (⇒ (# "3")))) ∷
((# "7") ⇒ (⇒ (# "7"))) ∷
((# "7") ⇒ (⇒ (# "7"))) ∷
((# "7") ⇒ ((# "8") ⇒ (⇒ (# "10")))) ∷
((# "3") ⇒ ((# "10") ⇒ (⇒ (# "9")))) ∷
((# "5") ⇒ (⇒ (# "1"))) ∷
((# "3") ⇒ ((# "1") ⇒ (⇒ (# "9")))) ∷
((# "1") ⇒ (⇒ (# "2"))) ∷
((# "10") ⇒ (⇒ (# "2"))) ∷ []
cms : List Separation
cms =
(model ((# "12") ∷ (# "6") ∷ (# "11") ∷ (# "4") ∷ (# "1") ∷ []) ((# "5") ∷ (# "3") ∷ (# "7") ∷ (# "7") ∷ [])) ∷
(model ((# "6") ∷ (# "3") ∷ (# "11") ∷ (# "4") ∷ (# "7") ∷ (# "8") ∷ (# "3") ∷ (# "9") ∷ (# "10") ∷ (# "1") ∷ []) ((# "5") ∷ [])) ∷
(model ((# "12") ∷ (# "5") ∷ (# "11") ∷ (# "4") ∷ (# "1") ∷ []) ((# "6") ∷ (# "3") ∷ [])) ∷
(model ((# "5") ∷ (# "3") ∷ (# "11") ∷ (# "4") ∷ (# "7") ∷ (# "8") ∷ (# "3") ∷ (# "9") ∷ (# "10") ∷ (# "1") ∷ []) ((# "6") ∷ [])) ∷
(model ((# "12") ∷ (# "4") ∷ (# "11") ∷ []) ((# "5") ∷ (# "6") ∷ (# "3") ∷ (# "8") ∷ (# "9") ∷ (# "1") ∷ [])) ∷
(model ((# "12") ∷ (# "5") ∷ (# "6") ∷ (# "4") ∷ (# "11") ∷ (# "1") ∷ []) ((# "3") ∷ [])) ∷
(model ((# "12") ∷ (# "4") ∷ (# "11") ∷ (# "7") ∷ []) ((# "9") ∷ (# "5") ∷ (# "6") ∷ (# "10") ∷ (# "8") ∷ (# "1") ∷ [])) ∷
(model ((# "10") ∷ (# "9") ∷ []) ((# "1") ∷ [])) ∷
(model ((# "3") ∷ (# "4") ∷ (# "11") ∷ []) ((# "9") ∷ (# "5") ∷ (# "6") ∷ (# "10") ∷ (# "7") ∷ (# "1") ∷ [])) ∷
(model ((# "12") ∷ (# "7") ∷ (# "1") ∷ []) ((# "4") ∷ (# "11") ∷ (# "8") ∷ [])) ∷
(model ((# "9") ∷ (# "3") ∷ (# "10") ∷ (# "8") ∷ (# "1") ∷ []) ((# "11") ∷ [])) ∷
(model ((# "12") ∷ (# "4") ∷ (# "10") ∷ (# "1") ∷ []) ((# "11") ∷ (# "3") ∷ [])) ∷
(model ((# "3") ∷ (# "6") ∷ (# "5") ∷ []) ([])) ∷
(model ((# "1") ∷ (# "2") ∷ (# "3") ∷ (# "4") ∷ (# "5") ∷ (# "6") ∷ (# "7") ∷ (# "8") ∷ (# "9") ∷ (# "10") ∷ (# "11") ∷ []) ((# "12") ∷ [])) ∷ []
testp : Relation
testp = consider proofs cms ((# "5") ⇒ (⇒ (# "10")))
testd : Relation
testd = consider proofs cms ((# "5") ⇒ (⇒ (# "4")))
tests : Relation
tests = consider proofs cms ((# "5") ⇒ (⇒ (# "3")))
testu : Relation
testu = consider proofs cms ((# "6") ⇒ (⇒ (# "1")))
testcl : List Principle
testcl = closure proofs ((# "5") ∷ [])
stringifylp : List Principle → String
stringifylp [] = "[]"
stringifylp ((# s) ∷ xs) = s >>> " ∷ " >>> (stringifylp xs)
main = run (putStrLn (stringifylp testcl))
| {
"alphanum_fraction": 0.3802466061,
"avg_line_length": 28.371024735,
"ext": "agda",
"hexsha": "976f481cae719d8758ef4f304ab7a3614a87e739",
"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": "e73df65d9a118e35a42d2d00d838aa901f9c3a6f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "louisswarren/hieretikz",
"max_forks_repo_path": "arrow.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e73df65d9a118e35a42d2d00d838aa901f9c3a6f",
"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": "louisswarren/hieretikz",
"max_issues_repo_path": "arrow.agda",
"max_line_length": 147,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "e73df65d9a118e35a42d2d00d838aa901f9c3a6f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "louisswarren/hieretikz",
"max_stars_repo_path": "arrow.agda",
"max_stars_repo_stars_event_max_datetime": "2018-03-26T03:34:11.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-03-18T12:17:36.000Z",
"num_tokens": 3241,
"size": 8029
} |
open import Relation.Binary.PropositionalEquality as P
open import Function
open import Streams
tl' : ∀{A} → Stream A → Stream A
tl' s = tl s
coind : ∀{A X : Set} → (f g : X → Stream A) →
hd ∘ f ≡ hd ∘ g →
(u : ?) →
((v : ∀ x → f x ~ g x) → v ∘ u
∀ x → f x ~ g x
hd~ (coind f g p x) = cong-app p x
tl~ (coind f g p x) = coind (tl' ∘ f) (tl' ∘ g) {!!} {!!}
| {
"alphanum_fraction": 0.4808184143,
"avg_line_length": 26.0666666667,
"ext": "agda",
"hexsha": "3ced84f699f1a7dbe4253a29862741cb8e7168cd",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "hbasold/Sandbox",
"max_forks_repo_path": "Streams/Coind-Test.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "hbasold/Sandbox",
"max_issues_repo_path": "Streams/Coind-Test.agda",
"max_line_length": 57,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "hbasold/Sandbox",
"max_stars_repo_path": "Streams/Coind-Test.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 159,
"size": 391
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Coinductive vectors
------------------------------------------------------------------------
module Data.Covec where
open import Coinduction
open import Data.Nat using (ℕ; zero; suc)
open import Data.Conat as Coℕ using (Coℕ; zero; suc; _+_)
open import Data.Cofin using (Cofin; zero; suc)
open import Data.Vec using (Vec; []; _∷_)
open import Data.Colist as Colist using (Colist; []; _∷_)
open import Data.Product using (_,_)
open import Relation.Binary
------------------------------------------------------------------------
-- The type
infixr 5 _∷_
data Covec (A : Set) : Coℕ → Set where
[] : Covec A zero
_∷_ : ∀ {n} (x : A) (xs : ∞ (Covec A (♭ n))) → Covec A (suc n)
------------------------------------------------------------------------
-- Some operations
map : ∀ {A B n} → (A → B) → Covec A n → Covec B n
map f [] = []
map f (x ∷ xs) = f x ∷ ♯ map f (♭ xs)
fromVec : ∀ {A n} → Vec A n → Covec A (Coℕ.fromℕ n)
fromVec [] = []
fromVec (x ∷ xs) = x ∷ ♯ fromVec xs
fromColist : ∀ {A} (xs : Colist A) → Covec A (Colist.length xs)
fromColist [] = []
fromColist (x ∷ xs) = x ∷ ♯ fromColist (♭ xs)
take : ∀ {A} m {n} → Covec A (m + n) → Covec A m
take zero xs = []
take (suc n) (x ∷ xs) = x ∷ ♯ take (♭ n) (♭ xs)
drop : ∀ {A} m {n} → Covec A (Coℕ.fromℕ m + n) → Covec A n
drop zero xs = xs
drop (suc n) (x ∷ xs) = drop n (♭ xs)
replicate : ∀ {A} n → A → Covec A n
replicate zero x = []
replicate (suc n) x = x ∷ ♯ replicate (♭ n) x
lookup : ∀ {A n} → Cofin n → Covec A n → A
lookup zero (x ∷ xs) = x
lookup (suc n) (x ∷ xs) = lookup n (♭ xs)
infixr 5 _++_
_++_ : ∀ {A m n} → Covec A m → Covec A n → Covec A (m + n)
[] ++ ys = ys
(x ∷ xs) ++ ys = x ∷ ♯ (♭ xs ++ ys)
[_] : ∀ {A} → A → Covec A (suc (♯ zero))
[ x ] = x ∷ ♯ []
------------------------------------------------------------------------
-- Equality and other relations
-- xs ≈ ys means that xs and ys are equal.
infix 4 _≈_
data _≈_ {A} : ∀ {n} (xs ys : Covec A n) → Set where
[] : [] ≈ []
_∷_ : ∀ {n} x {xs ys}
(xs≈ : ∞ (♭ xs ≈ ♭ ys)) → _≈_ {n = suc n} (x ∷ xs) (x ∷ ys)
-- x ∈ xs means that x is a member of xs.
infix 4 _∈_
data _∈_ {A} : ∀ {n} → A → Covec A n → Set where
here : ∀ {n x } {xs} → _∈_ {n = suc n} x (x ∷ xs)
there : ∀ {n x y} {xs} (x∈xs : x ∈ ♭ xs) → _∈_ {n = suc n} x (y ∷ xs)
-- xs ⊑ ys means that xs is a prefix of ys.
infix 4 _⊑_
data _⊑_ {A} : ∀ {m n} → Covec A m → Covec A n → Set where
[] : ∀ {n} {ys : Covec A n} → [] ⊑ ys
_∷_ : ∀ {m n} x {xs ys} (p : ∞ (♭ xs ⊑ ♭ ys)) →
_⊑_ {m = suc m} {suc n} (x ∷ xs) (x ∷ ys)
------------------------------------------------------------------------
-- Some proofs
setoid : Set → Coℕ → Setoid _ _
setoid A n = record
{ Carrier = Covec A n
; _≈_ = _≈_
; isEquivalence = record
{ refl = refl
; sym = sym
; trans = trans
}
}
where
refl : ∀ {A n} → Reflexive (_≈_ {A} {n})
refl {x = []} = []
refl {x = x ∷ xs} = x ∷ ♯ refl
sym : ∀ {A n} → Symmetric (_≈_ {A} {n})
sym [] = []
sym (x ∷ xs≈) = x ∷ ♯ sym (♭ xs≈)
trans : ∀ {A n} → Transitive (_≈_ {A} {n})
trans [] [] = []
trans (x ∷ xs≈) (.x ∷ ys≈) = x ∷ ♯ trans (♭ xs≈) (♭ ys≈)
poset : Set → Coℕ → Poset _ _ _
poset A n = record
{ Carrier = Covec A n
; _≈_ = _≈_
; _≤_ = _⊑_
; isPartialOrder = record
{ isPreorder = record
{ isEquivalence = Setoid.isEquivalence (setoid A n)
; reflexive = reflexive
; trans = trans
}
; antisym = antisym
}
}
where
reflexive : ∀ {A n} → _≈_ {A} {n} ⇒ _⊑_
reflexive [] = []
reflexive (x ∷ xs≈) = x ∷ ♯ reflexive (♭ xs≈)
trans : ∀ {A n} → Transitive (_⊑_ {A} {n})
trans [] _ = []
trans (x ∷ xs≈) (.x ∷ ys≈) = x ∷ ♯ trans (♭ xs≈) (♭ ys≈)
antisym : ∀ {A n} → Antisymmetric (_≈_ {A} {n}) _⊑_
antisym [] [] = []
antisym (x ∷ p₁) (.x ∷ p₂) = x ∷ ♯ antisym (♭ p₁) (♭ p₂)
map-cong : ∀ {A B n} (f : A → B) → _≈_ {n = n} =[ map f ]⇒ _≈_
map-cong f [] = []
map-cong f (x ∷ xs≈) = f x ∷ ♯ map-cong f (♭ xs≈)
take-⊑ : ∀ {A} m {n} (xs : Covec A (m + n)) → take m xs ⊑ xs
take-⊑ zero xs = []
take-⊑ (suc n) (x ∷ xs) = x ∷ ♯ take-⊑ (♭ n) (♭ xs)
| {
"alphanum_fraction": 0.4219457014,
"avg_line_length": 28.3333333333,
"ext": "agda",
"hexsha": "aa7e176adf33a1f18ccf2dae354b0c55c032a94f",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "qwe2/try-agda",
"max_forks_repo_path": "agda-stdlib-0.9/src/Data/Covec.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "qwe2/try-agda",
"max_issues_repo_path": "agda-stdlib-0.9/src/Data/Covec.agda",
"max_line_length": 72,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "qwe2/try-agda",
"max_stars_repo_path": "agda-stdlib-0.9/src/Data/Covec.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": 1789,
"size": 4420
} |
-- Andreas, 2022-03-28, issue #5856, reported by Szumi Xie.
-- Patterns in path-lambdas were simply ignored, but should be illegal.
{-# OPTIONS --cubical #-}
-- {-# OPTIONS -v tc.term.lambda:30 #-}
open import Agda.Builtin.Cubical.Path
postulate
A E : Set
a : A
data C : Set where
c : E → C
p : a ≡ a
p = λ (c e) → a
-- WAS: accepted.
-- Expected error:
-- Patterns are not allowed in Path-lambdas
-- when checking that the expression λ .patternInTele0 @ (c e) → a has type a ≡ a
| {
"alphanum_fraction": 0.6477732794,
"avg_line_length": 19.76,
"ext": "agda",
"hexsha": "1c0519b90a4bd375549d7f6e87634b1ceb4252ae",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "KDr2/agda",
"max_forks_repo_path": "test/Fail/Issue5856.agda",
"max_issues_count": 6,
"max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "KDr2/agda",
"max_issues_repo_path": "test/Fail/Issue5856.agda",
"max_line_length": 81,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "KDr2/agda",
"max_stars_repo_path": "test/Fail/Issue5856.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 159,
"size": 494
} |
{- Reported by Nils Anders Danielsson, 2011-07-06
From the release notes for Agda 2.2.10:
"Projections now preserve sizes, both in patterns and expressions."
However, the following code is rejected:
-}
module Issue425 where
record _×_ (A B : Set) : Set where
constructor _,_
field
proj₁ : A
proj₂ : B
open _×_
id : {A : Set} → A → A
id x = x
data I : Set where
c : I → I → I
data D : I → Set where
d : (j : I × I) → D (proj₁ j) → D (proj₂ j) → D (c (proj₁ j) (proj₂ j))
f : ∀ i → D i → Set
f .(c (proj₁ j) (proj₂ j)) (d j l r) = f (proj₁ j) (id l)
{- Is this intentional? I guess the issue here is the subterm relation
rather than the sizes. Should we modify the subterm relation?
-}
-- Andreas, 2011-07-07 this should termination check.
| {
"alphanum_fraction": 0.6354166667,
"avg_line_length": 21.3333333333,
"ext": "agda",
"hexsha": "a3d463d4519dafb9bffcf03d7a5508c13a74cf70",
"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/Issue425.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/Issue425.agda",
"max_line_length": 74,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/Issue425.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": 263,
"size": 768
} |
module Structure.Category.Functor.Functors where
import Functional as Fn
open import Function.Proofs
open import Logic.Predicate
import Lvl
open import Structure.Category
open import Structure.Category.Functor
open import Structure.Categorical.Properties
open import Structure.Function
open import Structure.Relator.Equivalence
open import Structure.Relator.Properties
open import Structure.Setoid
open import Syntax.Transitivity
open import Type
private variable ℓ ℓₒ ℓₘ ℓₑ ℓₗₑ ℓᵣₑ ℓₑ₁ ℓₑ₂ ℓₑ₃ : Lvl.Level
private variable Obj Obj₁ Obj₂ Obj₃ : Type{ℓ}
private variable Morphism Morphism₁ Morphism₂ Morphism₃ : Obj → Obj → Type{ℓ}
module Raw where
constᶠᵘⁿᶜᵗᵒʳ : Obj₂ → (Obj₁ → Obj₂)
constᶠᵘⁿᶜᵗᵒʳ = Fn.const
idᶠᵘⁿᶜᵗᵒʳ : Obj → Obj
idᶠᵘⁿᶜᵗᵒʳ = Fn.id
_∘ᶠᵘⁿᶜᵗᵒʳ_ : (Obj₂ → Obj₃) → (Obj₁ → Obj₂) → (Obj₁ → Obj₃)
_∘ᶠᵘⁿᶜᵗᵒʳ_ = Fn._∘_
infixl 10000 _∘ᶠᵘⁿᶜᵗᵒʳ_
module _
⦃ morphism-equivₗ : ∀{x y : Obj₁} → Equiv{ℓₗₑ}(Morphism₁ x y) ⦄
⦃ morphism-equivᵣ : ∀{x y : Obj₂} → Equiv{ℓᵣₑ}(Morphism₂ x y) ⦄
{Category₁ : Category(Morphism₁)}
{Category₂ : Category(Morphism₂)}
where
module _ where
private open module Equivₗ {x}{y} = Equivalence (Equiv-equivalence ⦃ morphism-equivₗ{x}{y} ⦄) using ()
private open module Equivᵣ {x}{y} = Equivalence (Equiv-equivalence ⦃ morphism-equivᵣ{x}{y} ⦄) using ()
open Category ⦃ … ⦄
open Functor
open Raw
private instance _ = Category₁
private instance _ = Category₂
-- A constant functor maps every object and morphism in a category to a single specified object and the identity morphism.
constant : (objᵣ : Obj₂) → Functor(Category₁)(Category₂)(constᶠᵘⁿᶜᵗᵒʳ(objᵣ))
map (constant(objᵣ)) = Fn.const(id)
op-preserving (constant(objᵣ)) = symmetry(_≡_) (Morphism.identityₗ(_∘_)(id))
id-preserving (constant(objᵣ)) = reflexivity(_≡_)
module _
⦃ morphism-equiv : ∀{x y : Obj} → Equiv{ℓₑ}(Morphism x y) ⦄
{Category : Category(Morphism)}
where
private open module [≡]-Equivalence {x}{y} = Equivalence (Equiv-equivalence ⦃ morphism-equiv{x}{y} ⦄) using ()
open Functor
open Raw
private instance _ = Category
identity : Endofunctor(Category)(idᶠᵘⁿᶜᵗᵒʳ)
map (identity) = Fn.id
op-preserving (identity) = reflexivity(_≡_)
id-preserving (identity) = reflexivity(_≡_)
module _
⦃ morphism-equiv₁ : ∀{x y : Obj₁} → Equiv{ℓₑ₁}(Morphism₁ x y) ⦄
⦃ morphism-equiv₂ : ∀{x y : Obj₂} → Equiv{ℓₑ₂}(Morphism₂ x y) ⦄
⦃ morphism-equiv₃ : ∀{x y : Obj₃} → Equiv{ℓₑ₃}(Morphism₃ x y) ⦄
{Category₁ : Category(Morphism₁)}
{Category₂ : Category(Morphism₂)}
{Category₃ : Category(Morphism₃)}
where
private open module Equiv₃ {x}{y} = Equivalence (Equiv-equivalence ⦃ morphism-equiv₃{x}{y} ⦄) using ()
open Category ⦃ … ⦄
open Functor
open Raw
private instance _ = Category₁
private instance _ = Category₂
private instance _ = Category₃
composition :
∀{F₂₃}{F₁₂}
→ (functor₂₃ : Functor(Category₂)(Category₃)(F₂₃))
→ (functor₁₂ : Functor(Category₁)(Category₂)(F₁₂))
→ Functor(Category₁)(Category₃)(F₂₃ ∘ᶠᵘⁿᶜᵗᵒʳ F₁₂)
map (composition{F₂₃}{F₁₂}(functor₂₃)(functor₁₂)){x}{y} = (map(functor₂₃){F₁₂(x)}{F₁₂(y)}) Fn.∘ (map(functor₁₂){x}{y})
map-function (composition{F₂₃}{F₁₂}(functor₂₃)(functor₁₂)) = [∘]-function ⦃ func-f = map-function(functor₂₃) ⦄ ⦃ func-g = map-function(functor₁₂) ⦄
op-preserving (composition{F₂₃}{F₁₂}(functor₂₃)(functor₁₂)){x}{y}{z} {f}{g} =
map(functor₂₃) (map(functor₁₂) (f ∘ g)) 🝖-[ congruence₁(map(functor₂₃)) (op-preserving(functor₁₂)) ]
map(functor₂₃) (map(functor₁₂) f ∘ map functor₁₂ g) 🝖-[ op-preserving(functor₂₃)]
map(functor₂₃) (map(functor₁₂) f) ∘ map(functor₂₃) (map(functor₁₂) g) 🝖-end
id-preserving (composition{F₂₃}{F₁₂}(functor₂₃)(functor₁₂)) {x} =
map(functor₂₃) (map(functor₁₂) id) 🝖-[ congruence₁(_) (id-preserving(functor₁₂)) ]
map(functor₂₃) id 🝖-[ id-preserving(functor₂₃) ]
id 🝖-end
module Wrapped where
open CategoryObject
private variable A B C : CategoryObject{ℓₒ}{ℓₘ}{ℓₑ}
constᶠᵘⁿᶜᵗᵒʳ : let _ = A in Object(B) → (A →ᶠᵘⁿᶜᵗᵒʳ B)
∃.witness (constᶠᵘⁿᶜᵗᵒʳ c) = Raw.constᶠᵘⁿᶜᵗᵒʳ c
∃.proof (constᶠᵘⁿᶜᵗᵒʳ c) = constant c
idᶠᵘⁿᶜᵗᵒʳ : A →ᶠᵘⁿᶜᵗᵒʳ A
∃.witness idᶠᵘⁿᶜᵗᵒʳ = Raw.idᶠᵘⁿᶜᵗᵒʳ
∃.proof idᶠᵘⁿᶜᵗᵒʳ = identity
_∘ᶠᵘⁿᶜᵗᵒʳ_ : let _ = A ; _ = B ; _ = C in (B →ᶠᵘⁿᶜᵗᵒʳ C) → (A →ᶠᵘⁿᶜᵗᵒʳ B) → (A →ᶠᵘⁿᶜᵗᵒʳ C)
∃.witness (_∘ᶠᵘⁿᶜᵗᵒʳ_ ([∃]-intro F) ([∃]-intro G)) = Raw._∘ᶠᵘⁿᶜᵗᵒʳ_ F G
∃.proof (_∘ᶠᵘⁿᶜᵗᵒʳ_ ([∃]-intro _ ⦃ F-functor ⦄) ([∃]-intro _ ⦃ G-functor ⦄)) = composition F-functor G-functor
| {
"alphanum_fraction": 0.6603012943,
"avg_line_length": 38.3170731707,
"ext": "agda",
"hexsha": "ac068ad97e88921997c617a8dd2689c65ec76dac",
"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/Functor/Functors.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/Functor/Functors.agda",
"max_line_length": 153,
"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/Functor/Functors.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": 2212,
"size": 4713
} |
open import Everything
module Test.UnifiesSubstitunction {𝔭} (𝔓 : Ø 𝔭) where
open Substitunction 𝔓
open Term 𝔓
open Substitist 𝔓
≡-Unifies₀-Term : ∀ {m} → Term m → Term m → Ṗroperty ∅̂ (Arrow Fin Term m)
≡-Unifies₀-Term = ≡-surjcollation
≡-Unifies₀-Term' : ∀ {m} → Term m → Term m → Ṗroperty ∅̂ (Arrow Fin Term m)
≡-Unifies₀-Term' = ≡-surjcollation[ Term ]⟦ Substitunction ⟧
≡-Unifies₀-Terms : ∀ {N m} → Terms N m → Terms N m → Ṗroperty ∅̂ (Arrow Fin Term m)
≡-Unifies₀-Terms = λ x → ≡-surjcollation x
≡-ExtensionalUnifies-Term : ∀ {m} → Term m → Term m → ArrowExtensionṖroperty ∅̂ Fin Term _≡_ m
≡-ExtensionalUnifies-Term = Surjextenscollation.method Substitunction _≡̇_
≡-ExtensionalUnifies-Terms : ∀ {N m} → Terms N m → Terms N m → LeftExtensionṖroperty ∅̂ (Arrow Fin Term) (Pointwise Proposequality) m
≡-ExtensionalUnifies-Terms = surjextenscollation⟦ Pointwise _≡_ ⟧
| {
"alphanum_fraction": 0.6750823271,
"avg_line_length": 37.9583333333,
"ext": "agda",
"hexsha": "d0b56f25578c1af6c0970e5f5660198eb27d2a93",
"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/UnifiesSubstitunction.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/UnifiesSubstitunction.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/Test/UnifiesSubstitunction.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 380,
"size": 911
} |
-- Modified: Andreas, 2011-04-11 freezing Metas
module HereditarilySingletonRecord where
data _≡_ {A : Set} (x : A) : A → Set where
refl : x ≡ x
-- * trivial unit type
record Singleton : Set where
foo : Singleton
foo = _
-- * product of unit types
record HereditarilySingleton : Set where
field
singleton : Singleton
also-singleton : Singleton
bar : HereditarilySingleton
bar = _
-- * hiding the unit types behind a type case
data ℕ : Set where
zero : ℕ
suc : (n : ℕ) → ℕ
Unit : ℕ → Set
Unit zero = Singleton
Unit (suc n) = Unit n
mutual -- needed to avoid freezing
one : ℕ
one = _
record HereditarilySingleton₂ : Set where
field
singleton : Unit one
baz : HereditarilySingleton₂
baz = _
force : one ≡ suc zero
force = refl
| {
"alphanum_fraction": 0.6611675127,
"avg_line_length": 16.4166666667,
"ext": "agda",
"hexsha": "8b23988cee18fbd687f47e36742a0921ee219ee6",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "redfish64/autonomic-agda",
"max_forks_repo_path": "test/Succeed/HereditarilySingletonRecord.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/HereditarilySingletonRecord.agda",
"max_line_length": 47,
"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/HereditarilySingletonRecord.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 234,
"size": 788
} |
-- Andreas, 2018-11-15, issue #3394 and testcase by Guillaume Brunerie
--
-- Internal error in termination checking the type of Ploop
-- due to uninitialized terSizeDepth.
postulate
A : Set
B : Set
P : B → Set
mutual
loop : A → B → B
loop a b = loop a b
Ploop : (b : B) → P (loop _ b) -- Unsolved meta caused internal error
Ploop b = whatever
where postulate whatever : _
-- Should fail termination checking in a controlled fashion.
| {
"alphanum_fraction": 0.6783369803,
"avg_line_length": 22.85,
"ext": "agda",
"hexsha": "ae89a1604cf4b5c63991b76049d615a8ac95af62",
"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/Issue3394.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/Issue3394.agda",
"max_line_length": 72,
"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/Issue3394.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": 457
} |
{- defining Nat as a kind of List -}
-- the need for ‼ is unfortunate
module Oscar.Data2 where
record ⊤ : Set where
constructor tt
-- List
data ⟦_⟧ {a} (A : Set a) : Set a where
∅ : ⟦ A ⟧
_∷_ : A → ⟦ A ⟧ → ⟦ A ⟧
-- Nat
⟦⟧ = ⟦ ⊤ ⟧
pattern ‼ ⟦A⟧ = tt ∷ ⟦A⟧
-- Fin
data ⟦⟧[_] : ⟦⟧ → Set where
∅ : ∀ {n} → ⟦⟧[ ‼ n ]
! : ∀ {n} → ⟦⟧[ n ] → ⟦⟧[ ‼ n ]
test : ⟦⟧[ ‼ (‼ ∅) ]
test = ! ∅
| {
"alphanum_fraction": 0.4296675192,
"avg_line_length": 16.2916666667,
"ext": "agda",
"hexsha": "27df37f092627d05e6002c84a6d77095b1ddcba1",
"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/Data2.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/Data2.agda",
"max_line_length": 38,
"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/Data2.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 206,
"size": 391
} |
------------------------------------------------------------------------
-- Lemmas related to strong similarity for CCS
------------------------------------------------------------------------
{-# OPTIONS --sized-types #-}
open import Prelude
module Similarity.CCS {ℓ} {Name : Type ℓ} where
open import Equality.Propositional
open import Prelude.Size
open import Function-universe equality-with-J hiding (id; _∘_)
import Bisimilarity.CCS as BL
import Bisimilarity.Equational-reasoning-instances
open import Equational-reasoning
open import Labelled-transition-system.CCS Name
import Similarity.Equational-reasoning-instances
open import Bisimilarity CCS as B using (_∼_; _∼′_)
open import Similarity CCS
------------------------------------------------------------------------
-- Congruence lemmas
private
module CL {i} = BL.Cong-lemmas [ i ]_≤′_ challenge
mutual
-- _∣_ preserves similarity.
infix 6 _∣-cong_ _∣-cong′_
_∣-cong_ : ∀ {i P P′ Q Q′} →
[ i ] P ≤ P′ → [ i ] Q ≤ Q′ → [ i ] P ∣ Q ≤ P′ ∣ Q′
P≤P′ ∣-cong Q≤Q′ = ⟨ CL.∣-cong _∣-cong′_ P≤P′ Q≤Q′ ⟩
_∣-cong′_ : ∀ {i P P′ Q Q′} →
[ i ] P ≤′ P′ → [ i ] Q ≤′ Q′ → [ i ] P ∣ Q ≤′ P′ ∣ Q′
force (P≤P′ ∣-cong′ Q≤Q′) = force P≤P′ ∣-cong force Q≤Q′
-- _⊕_ preserves similarity.
infix 8 _⊕-cong_ _⊕-cong′_
_⊕-cong_ : ∀ {i P P′ Q Q′} →
[ i ] P ≤ P′ → [ i ] Q ≤ Q′ → [ i ] P ⊕ Q ≤ P′ ⊕ Q′
P≤P′ ⊕-cong Q≤Q′ = ⟨ CL.⊕-cong P≤P′ Q≤Q′ ⟩
_⊕-cong′_ : ∀ {i P P′ Q Q′} →
[ i ] P ≤′ P′ → [ i ] Q ≤′ Q′ → [ i ] P ⊕ Q ≤′ P′ ⊕ Q′
force (P≤P′ ⊕-cong′ Q≤Q′) = force P≤P′ ⊕-cong force Q≤Q′
-- _·_ preserves similarity.
infix 12 _·-cong_ _·-cong′_
_·-cong_ :
∀ {i μ μ′ P P′} →
μ ≡ μ′ → [ i ] force P ≤′ force P′ → [ i ] μ · P ≤ μ′ · P′
_·-cong_ {i} refl P≤P′ = ⟨ CL.·-cong {i = i} P≤P′ ⟩
_·-cong′_ :
∀ {i μ μ′ P P′} →
μ ≡ μ′ → [ i ] force P ≤′ force P′ → [ i ] μ · P ≤′ μ′ · P′
force (μ≡μ′ ·-cong′ P≤P′) = μ≡μ′ ·-cong P≤P′
-- _∙_ preserves similarity.
infix 12 _∙-cong_ _∙-cong′_
_∙-cong_ : ∀ {i μ μ′ P P′} →
μ ≡ μ′ → [ i ] P ≤ P′ → [ i ] μ ∙ P ≤ μ′ ∙ P′
refl ∙-cong P≤P′ = refl ·-cong convert {a = ℓ} P≤P′
_∙-cong′_ : ∀ {i μ μ′ P P′} →
μ ≡ μ′ → [ i ] P ≤′ P′ → [ i ] μ ∙ P ≤′ μ′ ∙ P′
force (μ≡μ′ ∙-cong′ P≤P′) = μ≡μ′ ∙-cong force P≤P′
-- _∙ turns equal actions into similar processes.
infix 12 _∙-cong _∙-cong′
_∙-cong : ∀ {μ μ′} → μ ≡ μ′ → μ ∙ ≤ μ′ ∙
refl ∙-cong = reflexive
_∙-cong′ : ∀ {μ μ′} → μ ≡ μ′ → μ ∙ ≤′ μ′ ∙
refl ∙-cong′ = reflexive
mutual
-- ⟨ν_⟩ preserves similarity.
⟨ν_⟩-cong : ∀ {i a a′ P P′} →
a ≡ a′ → [ i ] P ≤ P′ → [ i ] ⟨ν a ⟩ P ≤ ⟨ν a′ ⟩ P′
⟨ν refl ⟩-cong P≤P′ = ⟨ CL.⟨ν⟩-cong ⟨ν refl ⟩-cong′ P≤P′ ⟩
⟨ν_⟩-cong′ : ∀ {i a a′ P P′} →
a ≡ a′ → [ i ] P ≤′ P′ → [ i ] ⟨ν a ⟩ P ≤′ ⟨ν a′ ⟩ P′
force (⟨ν a≡a′ ⟩-cong′ P≤P′) = ⟨ν a≡a′ ⟩-cong (force P≤P′)
mutual
-- !_ preserves similarity.
infix 10 !-cong_ !-cong′_
!-cong_ : ∀ {i P P′} →
[ i ] P ≤ P′ → [ i ] ! P ≤ ! P′
!-cong P≤P′ = ⟨ CL.!-cong BL.6-1-3-2 _∣-cong′_ !-cong′_ P≤P′ ⟩
!-cong′_ : ∀ {i P P′} → [ i ] P ≤′ P′ → [ i ] ! P ≤′ ! P′
force (!-cong′ P≤P′) = !-cong force P≤P′
-- _[_] preserves similarity.
mutual
infix 5 _[_]-cong _[_]-cong′
_[_]-cong :
∀ {i n Ps Qs}
(C : Context ∞ n) → (∀ x → [ i ] Ps x ≤ Qs x) →
[ i ] C [ Ps ] ≤ C [ Qs ]
hole x [ Ps≤Qs ]-cong = Ps≤Qs x
∅ [ Ps≤Qs ]-cong = reflexive
C₁ ∣ C₂ [ Ps≤Qs ]-cong = (C₁ [ Ps≤Qs ]-cong) ∣-cong (C₂ [ Ps≤Qs ]-cong)
C₁ ⊕ C₂ [ Ps≤Qs ]-cong = (C₁ [ Ps≤Qs ]-cong) ⊕-cong (C₂ [ Ps≤Qs ]-cong)
μ · C [ Ps≤Qs ]-cong = refl ·-cong λ { .force → force C [ Ps≤Qs ]-cong }
⟨ν a ⟩ C [ Ps≤Qs ]-cong = ⟨ν refl ⟩-cong (C [ Ps≤Qs ]-cong)
! C [ Ps≤Qs ]-cong = !-cong (C [ Ps≤Qs ]-cong)
_[_]-cong′ :
∀ {i n Ps Qs}
(C : Context ∞ n) → (∀ x → [ i ] Ps x ≤′ Qs x) →
[ i ] C [ Ps ] ≤′ C [ Qs ]
force (C [ Ps≤Qs ]-cong′) = C [ (λ x → force (Ps≤Qs x)) ]-cong
------------------------------------------------------------------------
-- Other results
-- P is similar to P ⊕ Q.
≤-⊕-left : ∀ {i P Q} → [ i ] P ≤ P ⊕ Q
≤-⊕-left = ⟨ (λ P⟶P′ → _ , sum-left P⟶P′ , reflexive) ⟩
-- Q is similar to P ⊕ Q.
≤-⊕-right : ∀ {i P Q} → [ i ] Q ≤ P ⊕ Q
≤-⊕-right = ⟨ (λ Q⟶Q′ → _ , sum-right Q⟶Q′ , reflexive) ⟩
-- If Name is inhabited, then there are two processes that are similar
-- in both directions, but not bisimilar.
--
-- I took this example from Wikipedia; I suspect that it is due to
-- Milner.
≤≥≁ : Name → ∃ λ P → ∃ λ Q → P ≤ Q × Q ≤ P × ¬ P ∼ Q
≤≥≁ x = machine₁ , machine₂
, machine₁≤machine₂ , machine₂≤machine₁ , machine₁≁machine₂
where
-- Some names (with kinds), constructed using x.
pay coffee tea : Name-with-kind
pay = x , true
coffee = pay
tea = x , false
-- Two vending machines.
machine₁ machine₂ machine₁′ machine₂′ : Proc ∞
machine₁′ = name pay ∙ (coffee ∙ ⊕ tea ∙)
machine₁ = ! machine₁′
machine₂′ = (name pay ∙ (coffee ∙) ⊕ name pay ∙ (tea ∙))
⊕
machine₁′
machine₂ = ! machine₂′
-- A lemma.
machine₁⟶ :
∀ {P μ} → machine₁ [ μ ]⟶ P →
μ ≡ name pay × P ∼ machine₁ ∣ (coffee ∙ ⊕ tea ∙)
machine₁⟶ tr = case BL.6-1-3-2 tr of λ where
(inj₁ (_ , action , P∼)) → refl , P∼
(inj₂ (_ , _ , _ , _ , action , tr , _)) →
⊥-elim (names-are-not-inverted tr)
-- The first machine is similar to the second one.
machine₁≤machine₂ : ∀ {i} → [ i ] machine₁ ≤ machine₂
machine₁≤machine₂ {i} =
StepC.⟨ (λ {P} tr →
case machine₁⟶ tr of λ where
(refl , P∼) →
_
, (machine₂ [ name pay ]⟶⟨ replication (par-right (sum-right action)) ⟩
machine₂ ∣ coffee ∙ ⊕ tea ∙)
, (P ∼⟨ ≤: convert {a = ℓ} P∼ ⟩
machine₁ ∣ coffee ∙ ⊕ tea ∙ ∼⟨ machine₁≤′machine₂ ∣-cong′ (_ ■) ⟩■
machine₂ ∣ coffee ∙ ⊕ tea ∙))
⟩
where
machine₁≤′machine₂ : [ i ] machine₁ ≤′ machine₂
force machine₁≤′machine₂ = machine₁≤machine₂
-- The second machine is similar to the first one.
machine₂≤machine₁ : ∀ {i} → [ i ] machine₂ ≤ machine₁
machine₂≤machine₁ {i} = StepC.⟨ helper ∘ BL.6-1-3-2 ⟩
where
machine₂≤′machine₁ : [ i ] machine₂ ≤′ machine₁
force machine₂≤′machine₁ = machine₂≤machine₁
lemma =
machine₁ [ name pay ]⟶⟨ replication (par-right action) ⟩
machine₁ ∣ coffee ∙ ⊕ tea ∙
helper :
∀ {P μ} →
(∃ λ P′ → machine₂′ [ μ ]⟶ P′ × P ∼ machine₂ ∣ P′)
⊎
(μ ≡ τ × ∃ λ P′ → ∃ λ P″ → ∃ λ a →
machine₂′ [ name a ]⟶ P′ × machine₂′ [ name (co a) ]⟶ P″ ×
P ∼ (machine₂ ∣ P′) ∣ P″) →
∃ λ Q → machine₁ [ μ ]⟶ Q × [ i ] P ≤′ Q
helper {P} (inj₁ (_ , sum-left (sum-left action) , P∼)) =
_
, lemma
, (P ∼⟨ ≤: convert {a = ℓ} P∼ ⟩
machine₂ ∣ coffee ∙ ∼⟨ machine₂≤′machine₁ ∣-cong′ convert {a = ℓ} ≤-⊕-left ⟩■
machine₁ ∣ coffee ∙ ⊕ tea ∙)
helper {P} (inj₁ (_ , sum-left (sum-right action) , P∼)) =
_
, lemma
, (P ∼⟨ ≤: convert {a = ℓ} P∼ ⟩
machine₂ ∣ tea ∙ ∼⟨ machine₂≤′machine₁ ∣-cong′ convert {a = ℓ} ≤-⊕-right ⟩■
machine₁ ∣ coffee ∙ ⊕ tea ∙)
helper {P} (inj₁ (_ , sum-right action , P∼)) =
_
, lemma
, (P ∼⟨ ≤: convert {a = ℓ} P∼ ⟩
machine₂ ∣ coffee ∙ ⊕ tea ∙ ∼⟨ machine₂≤′machine₁ ∣-cong′ (_ ■) ⟩■
machine₁ ∣ coffee ∙ ⊕ tea ∙)
helper (inj₂ (_ , _ , _ , _ , sum-left (sum-left action) , sum-left (sum-left tr) , _)) = ⊥-elim (names-are-not-inverted tr)
helper (inj₂ (_ , _ , _ , _ , sum-left (sum-left action) , sum-left (sum-right tr) , _)) = ⊥-elim (names-are-not-inverted tr)
helper (inj₂ (_ , _ , _ , _ , sum-left (sum-left action) , sum-right tr , _)) = ⊥-elim (names-are-not-inverted tr)
helper (inj₂ (_ , _ , _ , _ , sum-left (sum-right action) , sum-left (sum-left tr) , _)) = ⊥-elim (names-are-not-inverted tr)
helper (inj₂ (_ , _ , _ , _ , sum-left (sum-right action) , sum-left (sum-right tr) , _)) = ⊥-elim (names-are-not-inverted tr)
helper (inj₂ (_ , _ , _ , _ , sum-left (sum-right action) , sum-right tr , _)) = ⊥-elim (names-are-not-inverted tr)
helper (inj₂ (_ , _ , _ , _ , sum-right action , sum-left (sum-left tr) , _)) = ⊥-elim (names-are-not-inverted tr)
helper (inj₂ (_ , _ , _ , _ , sum-right action , sum-left (sum-right tr) , _)) = ⊥-elim (names-are-not-inverted tr)
helper (inj₂ (_ , _ , _ , _ , sum-right action , sum-right tr , _)) = ⊥-elim (names-are-not-inverted tr)
-- The two machines are not bisimilar.
machine₁≁machine₂ : ¬ machine₁ ∼ machine₂
machine₁≁machine₂ =
machine₁ ∼ machine₂ ↝⟨ (λ hyp → B.right-to-left hyp
(replication (par-right (sum-left (sum-left action))))) ⟩
(∃ λ P → machine₁ [ name pay ]⟶ P × P ∼′ machine₂ ∣ coffee ∙) ↝⟨ Σ-map id (Σ-map (proj₂ ∘ machine₁⟶) id) ⟩
(∃ λ P → P ∼ machine₁ ∣ (coffee ∙ ⊕ tea ∙) ×
P ∼′ machine₂ ∣ coffee ∙) ↝⟨ (λ { (_ , P∼ , P∼′) → transitive {a = ℓ} (symmetric P∼) (convert {a = ℓ} P∼′) }) ⟩
machine₁ ∣ (coffee ∙ ⊕ tea ∙) ∼ machine₂ ∣ coffee ∙ ↝⟨ (λ hyp → Σ-map id proj₁ $
B.left-to-right hyp (par-right (sum-right action))) ⟩
(∃ λ P → machine₂ ∣ coffee ∙ [ name tea ]⟶ P) ↝⟨ helper ∘ proj₂ ⟩
pay ≡ tea ⊎ coffee ≡ tea ↝⟨ [ (λ ()) , (λ ()) ] ⟩□
⊥ □
where
helper : ∀ {P} →
machine₂ ∣ coffee ∙ [ name tea ]⟶ P →
pay ≡ tea ⊎ coffee ≡ tea
helper (par-right tr) = inj₂ $ cancel-name $ ·-only tr
helper (par-left tr) =
inj₁ $ cancel-name $
!-only (⊕-only (⊕-only ·-only ·-only) ·-only) tr
| {
"alphanum_fraction": 0.4567288993,
"avg_line_length": 35.0989761092,
"ext": "agda",
"hexsha": "af175ea58f1622e204c594deca21f08b7feeedf9",
"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/CCS.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/CCS.agda",
"max_line_length": 152,
"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/CCS.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 4187,
"size": 10284
} |
{-# OPTIONS --type-in-type #-}
module RevisedHutton where
--********************************************
-- Prelude
--********************************************
-- Some preliminary stuffs, to avoid relying on the stdlib
--****************
-- Sigma and friends
--****************
data Sigma (A : Set) (B : A -> Set) : Set where
_,_ : (x : A) (y : B x) -> Sigma A B
_*_ : (A : Set)(B : Set) -> Set
A * B = Sigma A \_ -> B
fst : {A : Set}{B : A -> Set} -> Sigma A B -> A
fst (a , _) = a
snd : {A : Set}{B : A -> Set} (p : Sigma A B) -> B (fst p)
snd (a , b) = b
data Zero : Set where
data Unit : Set where
Void : Unit
--****************
-- Sum and friends
--****************
data _+_ (A : Set)(B : Set) : Set where
l : A -> A + B
r : B -> A + B
--****************
-- Equality
--****************
data _==_ {A : Set}(x : A) : A -> Set where
refl : x == x
subst : forall {x y} -> x == y -> x -> y
subst refl x = x
cong : {A B : Set}(f : A -> B){x y : A} -> x == y -> f x == f y
cong f refl = refl
cong2 : {A B C : Set}(f : A -> B -> C){x y : A}{z t : B} ->
x == y -> z == t -> f x z == f y t
cong2 f refl refl = refl
postulate
reflFun : {A B : Set}(f : A -> B)(g : A -> B)-> ((a : A) -> f a == g a) -> f == g
--****************
-- Meta-language
--****************
-- Note that we could define Nat, Bool, and the related operations in
-- IDesc. But it is awful to code with them, in Agda.
data Nat : Set where
ze : Nat
su : Nat -> Nat
data Bool : Set where
true : Bool
false : Bool
plus : Nat -> Nat -> Nat
plus ze n' = n'
plus (su n) n' = su (plus n n')
le : Nat -> Nat -> Bool
le ze _ = true
le (su _) ze = false
le (su n) (su n') = le n n'
data Vec (A : Set) : Nat -> Set where
vnil : Vec A ze
vcons : {n : Nat} -> A -> Vec A n -> Vec A (su n)
data Fin : Nat -> Set where
fze : {n : Nat} -> Fin (su n)
fsu : {n : Nat} -> Fin n -> Fin (su n)
--********************************************
-- Desc code
--********************************************
data IDesc (I : Set) : Set where
var : I -> IDesc I
const : Set -> IDesc I
prod : IDesc I -> IDesc I -> IDesc I
sigma : (S : Set) -> (S -> IDesc I) -> IDesc I
pi : (S : Set) -> (S -> IDesc I) -> IDesc I
--********************************************
-- Desc interpretation
--********************************************
[|_|] : {I : Set} -> IDesc I -> (I -> Set) -> Set
[| var i |] P = P i
[| const X |] P = X
[| prod D D' |] P = [| D |] P * [| D' |] P
[| sigma S T |] P = Sigma S (\s -> [| T s |] P)
[| pi S T |] P = (s : S) -> [| T s |] P
--********************************************
-- Fixpoint construction
--********************************************
data IMu {I : Set}(R : I -> IDesc I)(i : I) : Set where
con : [| R i |] (\j -> IMu R j) -> IMu R i
--********************************************
-- Predicate: All
--********************************************
All : {I : Set}(D : IDesc I)(P : I -> Set) -> [| D |] P -> IDesc (Sigma I P)
All (var i) P x = var (i , x)
All (const X) P x = const Unit
All (prod D D') P (d , d') = prod (All D P d) (All D' P d')
All (sigma S T) P (a , b) = All (T a) P b
All (pi S T) P f = pi S (\s -> All (T s) P (f s))
--********************************************
-- Elimination principle: induction
--********************************************
module Elim {I : Set}
(R : I -> IDesc I)
(P : Sigma I (IMu R) -> Set)
(m : (i : I)
(xs : [| R i |] (IMu R))
(hs : [| All (R i) (IMu R) xs |] P) ->
P ( i , con xs ))
where
mutual
indI : (i : I)(x : IMu R i) -> P (i , x)
indI i (con xs) = m i xs (hyps (R i) xs)
hyps : (D : IDesc I) ->
(xs : [| D |] (IMu R)) ->
[| All D (IMu R) xs |] P
hyps (var i) x = indI i x
hyps (const X) x = Void
hyps (prod D D') (d , d') = hyps D d , hyps D' d'
hyps (pi S R) f = \ s -> hyps (R s) (f s)
hyps (sigma S R) ( a , b ) = hyps (R a) b
indI : {I : Set}
(R : I -> IDesc I)
(P : Sigma I (IMu R) -> Set)
(m : (i : I)
(xs : [| R i |] (IMu R))
(hs : [| All (R i) (IMu R) xs |] P) ->
P ( i , con xs)) ->
(i : I)(x : IMu R i) -> P ( i , x )
indI = Elim.indI
--********************************************
-- Enumerations (hard-coded)
--********************************************
-- Unlike in Desc.agda, we don't carry the levitation of finite sets
-- here. We hard-code them and manipulate with standard Agda
-- machinery. Both presentation are isomorph but, in Agda, the coded
-- one quickly gets unusable.
data EnumU : Set where
nilE : EnumU
consE : EnumU -> EnumU
data EnumT : (e : EnumU) -> Set where
EZe : {e : EnumU} -> EnumT (consE e)
ESu : {e : EnumU} -> EnumT e -> EnumT (consE e)
spi : (e : EnumU)(P : EnumT e -> Set) -> Set
spi nilE P = Unit
spi (consE e) P = P EZe * spi e (\e -> P (ESu e))
switch : (e : EnumU)(P : EnumT e -> Set)(b : spi e P)(x : EnumT e) -> P x
switch nilE P b ()
switch (consE e) P b EZe = fst b
switch (consE e) P b (ESu n) = switch e (\e -> P (ESu e)) (snd b) n
_++_ : EnumU -> EnumU -> EnumU
nilE ++ e' = e'
(consE e) ++ e' = consE (e ++ e')
-- A special switch, for tagged descriptions. Switching on a
-- concatenation of finite sets:
sswitch : (e : EnumU)(e' : EnumU)(P : Set)
(b : spi e (\_ -> P))(b' : spi e' (\_ -> P))(x : EnumT (e ++ e')) -> P
sswitch nilE nilE P b b' ()
sswitch nilE (consE e') P b b' EZe = fst b'
sswitch nilE (consE e') P b b' (ESu n) = sswitch nilE e' P b (snd b') n
sswitch (consE e) e' P b b' EZe = fst b
sswitch (consE e) e' P b b' (ESu n) = sswitch e e' P (snd b) b' n
--********************************************
-- Tagged indexed description
--********************************************
FixMenu : Set -> Set
FixMenu I = Sigma EnumU (\e -> (i : I) -> spi e (\_ -> IDesc I))
SensitiveMenu : Set -> Set
SensitiveMenu I = Sigma (I -> EnumU) (\F -> (i : I) -> spi (F i) (\_ -> IDesc I))
TagIDesc : Set -> Set
TagIDesc I = FixMenu I * SensitiveMenu I
toIDesc : (I : Set) -> TagIDesc I -> (I -> IDesc I)
toIDesc I ((E , ED) , (F , FD)) i = sigma (EnumT (E ++ F i))
(\x -> sswitch E (F i) (IDesc I) (ED i) (FD i) x)
--********************************************
-- Catamorphism
--********************************************
cata : (I : Set)
(R : I -> IDesc I)
(T : I -> Set) ->
((i : I) -> [| R i |] T -> T i) ->
(i : I) -> IMu R i -> T i
cata I R T phi i x = indI R (\it -> T (fst it)) (\i xs ms -> phi i (replace (R i) T xs ms)) i x
where replace : (D : IDesc I)(T : I -> Set)
(xs : [| D |] (IMu R))
(ms : [| All D (IMu R) xs |] (\it -> T (fst it))) ->
[| D |] T
replace (var i) T x y = y
replace (const Z) T z z' = z
replace (prod D D') T (x , x') (y , y') = replace D T x y , replace D' T x' y'
replace (sigma A B) T (a , b) t = a , replace (B a) T b t
replace (pi A B) T f t = \s -> replace (B s) T (f s) (t s)
--********************************************
-- Hutton's razor
--********************************************
--********************************
-- Types code
--********************************
data Type : Set where
nat : Type
bool : Type
pair : Type -> Type -> Type
--********************************************
-- Free monad construction
--********************************************
_**_ : {I : Set} (R : TagIDesc I)(X : I -> Set) -> TagIDesc I
((E , ED) , FFD) ** X = ((( consE E , \ i -> ( const (X i) , ED i ))) , FFD)
--********************************************
-- Substitution
--********************************************
apply : {I : Set}
(R : TagIDesc I)(X Y : I -> Set) ->
((i : I) -> X i -> IMu (toIDesc I (R ** Y)) i) ->
(i : I) ->
[| toIDesc I (R ** X) i |] (IMu (toIDesc I (R ** Y))) ->
IMu (toIDesc I (R ** Y)) i
apply (( E , ED) , (F , FD)) X Y sig i (EZe , x) = sig i x
apply (( E , ED) , (F , FD)) X Y sig i (ESu n , t) = con (ESu n , t)
substI : {I : Set} (X Y : I -> Set)(R : TagIDesc I)
(sigma : (i : I) -> X i -> IMu (toIDesc I (R ** Y)) i)
(i : I)(D : IMu (toIDesc I (R ** X)) i) ->
IMu (toIDesc I (R ** Y)) i
substI {I} X Y R sig i term = cata I (toIDesc I (R ** X)) (IMu (toIDesc I (R ** Y))) (apply R X Y sig) i term
--********************************************
-- Hutton's razor is free monad
--********************************************
-- Fix menu:
exprFreeFixMenu : FixMenu Type
exprFreeFixMenu = ( consE nilE ,
\ty -> (prod (var bool) (prod (var ty) (var ty)), -- if b then t1 else t2
Void))
-- Index-dependent menu:
choiceFreeMenu : Type -> EnumU
choiceFreeMenu nat = consE nilE
choiceFreeMenu bool = consE nilE
choiceFreeMenu (pair x y) = nilE
choiceFreeDessert : (ty : Type) -> spi (choiceFreeMenu ty) (\ _ -> IDesc Type)
choiceFreeDessert nat = (prod (var nat) (var nat) , Void) -- plus x y
choiceFreeDessert bool = (prod (var nat) (var nat) , Void ) -- le x y
choiceFreeDessert (pair x y) = Void
exprFreeSensitiveMenu : SensitiveMenu Type
exprFreeSensitiveMenu = ( choiceFreeMenu , choiceFreeDessert )
-- Tagged description of expressions
exprFree : TagIDesc Type
exprFree = exprFreeFixMenu , exprFreeSensitiveMenu
-- Free monadic expressions
exprFreeC : (Type -> Set) -> TagIDesc Type
exprFreeC X = exprFree ** X
--********************************
-- Closed terms
--********************************
Val : Type -> Set
Val nat = Nat
Val bool = Bool
Val (pair x y) = (Val x) * (Val y)
closeTerm : Type -> IDesc Type
closeTerm = toIDesc Type (exprFree ** Val)
--********************************
-- Closed term evaluation
--********************************
eval : {ty : Type} -> IMu closeTerm ty -> Val ty
eval {ty} term = cata Type closeTerm Val evalOneStep ty term
where evalOneStep : (ty : Type) -> [| closeTerm ty |] Val -> Val ty
evalOneStep _ (EZe , t) = t
evalOneStep _ ((ESu EZe) , (true , ( x , _))) = x
evalOneStep _ ((ESu EZe) , (false , ( _ , y ))) = y
evalOneStep nat ((ESu (ESu EZe)) , (x , y)) = plus x y
evalOneStep nat ((ESu (ESu (ESu ()))) , t)
evalOneStep bool ((ESu (ESu EZe)) , (x , y) ) = le x y
evalOneStep bool ((ESu (ESu (ESu ()))) , _)
evalOneStep (pair x y) (ESu (ESu ()) , _)
--********************************
-- [Open terms]
--********************************
-- A context is a snoc-list of types
-- put otherwise, a context is a type telescope
data Context : Set where
[] : Context
_,_ : Context -> Type -> Context
-- The environment realizes the context, having a value for each type
Env : Context -> Set
Env [] = Unit
Env (G , S) = Env G * Val S
-- A typed-variable indexes into the context, obtaining a proof that
-- what we get is what you want (WWGIWYW)
Var : Context -> Type -> Set
Var [] T = Zero
Var (G , S) T = Var G T + (S == T)
-- The lookup gets into the context to extract the value
lookup : (G : Context) -> Env G -> (T : Type) -> Var G T -> Val T
lookup [] _ T ()
lookup (G , .T) (g , t) T (r refl) = t
lookup (G , S) (g , t) T (l x) = lookup G g T x
-- Open term: holes are either values or variables in a context
openTerm : Context -> Type -> IDesc Type
openTerm c = toIDesc Type (exprFree ** (\ty -> Val ty + Var c ty))
--********************************
-- Evaluation of open terms
--********************************
-- |discharge| is the local substitution expected by |substI|. It is
-- just sugar around context lookup
discharge : (context : Context) ->
Env context ->
(ty : Type) ->
(Val ty + Var context ty) ->
IMu closeTerm ty
discharge ctxt env ty (l value) = con (EZe , value)
discharge ctxt env ty (r variable) = con (EZe , lookup ctxt env ty variable )
-- |substExpr| is the specialized |substI| to expressions. We get it
-- generically from the free monad construction.
substExpr : {ty : Type}
(context : Context)
(sigma : (ty : Type) ->
(Val ty + Var context ty) ->
IMu closeTerm ty) ->
IMu (openTerm context) ty ->
IMu closeTerm ty
substExpr {ty} c sig term =
substI (\ty -> Val ty + Var c ty) Val exprFree sig ty term
-- By first doing substitution to close the term, we can use
-- evaluation of closed terms, obtaining evaluation of open terms
-- under a valid context.
evalOpen : {ty : Type}(context : Context) ->
Env context ->
IMu (openTerm context) ty ->
Val ty
evalOpen ctxt env tm = eval (substExpr ctxt (discharge ctxt env) tm)
--********************************
-- Tests
--********************************
-- Test context:
-- V 0 :-> true, V 1 :-> 2, V 2 :-> ( false , 1 )
testContext : Context
testContext = (([] , bool) , nat) , pair bool nat
testEnv : Env testContext
testEnv = ((Void , true ) , su (su ze)) , (false , su ze)
-- V 1
test1 : IMu (openTerm testContext) nat
test1 = con (EZe , r ( l (r refl) ) )
testSubst1 : IMu closeTerm nat
testSubst1 = substExpr testContext
(discharge testContext testEnv)
test1
-- = 2
testEval1 : Val nat
testEval1 = evalOpen testContext testEnv test1
-- add 1 (V 1)
test2 : IMu (openTerm testContext) nat
test2 = con (ESu (ESu EZe) , (con (EZe , l (su ze)) , con ( EZe , r (l (r refl)) )) )
testSubst2 : IMu closeTerm nat
testSubst2 = substExpr testContext
(discharge testContext testEnv)
test2
-- = 3
testEval2 : Val nat
testEval2 = evalOpen testContext testEnv test2
-- if (V 0) then (V 1) else 0
test3 : IMu (openTerm testContext) nat
test3 = con (ESu EZe , (con (EZe , r (l (l (r refl)))) ,
(con (EZe , r (l (r refl))) ,
con (EZe , l ze))))
testSubst3 : IMu closeTerm nat
testSubst3 = substExpr testContext
(discharge testContext testEnv)
test3
-- = 2
testEval3 : Val nat
testEval3 = evalOpen testContext testEnv test3
-- V 2
test4 : IMu (openTerm testContext) (pair bool nat)
test4 = con (EZe , r ( r refl ) )
testSubst4 : IMu closeTerm (pair bool nat)
testSubst4 = substExpr testContext
(discharge testContext testEnv)
test4
-- = (false , 1)
testEval4 : Val (pair bool nat)
testEval4 = evalOpen testContext testEnv test4 | {
"alphanum_fraction": 0.4627018189,
"avg_line_length": 30.58125,
"ext": "agda",
"hexsha": "5e61d5837325517d6c0071636379581e50a97fe1",
"lang": "Agda",
"max_forks_count": 12,
"max_forks_repo_forks_event_max_datetime": "2022-02-11T01:57:40.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-08-14T21:36:35.000Z",
"max_forks_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mietek/epigram",
"max_forks_repo_path": "models/RevisedHutton.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2",
"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": "mietek/epigram",
"max_issues_repo_path": "models/RevisedHutton.agda",
"max_line_length": 110,
"max_stars_count": 48,
"max_stars_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mietek/epigram",
"max_stars_repo_path": "models/RevisedHutton.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-11T01:55:28.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-01-09T17:36:19.000Z",
"num_tokens": 4638,
"size": 14679
} |
------------------------------------------------------------------------
-- Untyped kind/type/term equality in Fω with interval kinds
------------------------------------------------------------------------
{-# OPTIONS --safe --without-K #-}
module FOmegaInt.Syntax.WeakEquality where
open import Data.Fin using (Fin; zero; suc; raise)
open import Data.Fin.Substitution
open import Data.Fin.Substitution.ExtraLemmas
open import Data.Fin.Substitution.Relation
open import Data.Nat using (ℕ; zero; suc; _+_)
open import Data.List using ([]; _∷_; _++_)
open import Data.Vec as Vec using ([])
open import Relation.Binary using (IsEquivalence; Setoid)
import Relation.Binary.Reasoning.Setoid as SetoidReasoning
open import Relation.Binary.PropositionalEquality as P
open import FOmegaInt.Syntax
open import FOmegaInt.Syntax.SingleVariableSubstitution
open import FOmegaInt.Syntax.HereditarySubstitution
open import FOmegaInt.Syntax.Normalization
------------------------------------------------------------------------
-- Weak untyped kind/type/term equality.
--
-- A "weak" equality that identifies syntactically equal terms and
-- types in elimination form up to type/kind ascriptions in
-- abstractions (lambdas).
--
-- Certain commutation lemmas about hereditary substitution,
-- η-expansion and normalization of raw types do not hold on the nose
-- (i.e. up to α-equivalence) because type-directed η-expansion can
-- change domain annotations in type operator abstractions. Since
-- untyped normalization involves some degree of η-expansion, the
-- order in which these operations are performed can affect the domain
-- annotations in the resulting raw type expressions. This is not a
-- problem semantically because the two type expressions are
-- considered equal as types (by the type equality judgment). But
-- proving the relevant commutation lemmas directly w.r.t. to type
-- equality is difficult because of the complexity of that judgment.
-- Instead, we introduce a separate equivalence relation, called "weak
-- equality", that is essentially α-equivalence modulo shape-equal
-- domain annotations. The problematic commutation lemmas then all
-- hold weakly (i.e. up to weak equality, see the nf-/⟨⟩ lemma in the
-- FOmegaInt.Kinding.Simple.Normalization for example). Weak equality
-- is much easier to work with and can be embedded into (canonical)
-- type equivalence (see the FOmegaInt.Kinding.Canonical.WeakEquality
-- module).
open Syntax
infix 4 _≋_ _≈_ _≈Hd_ _≈Sp_ _≈Asc_ _≈Ctx_ _⟨≈⟩_ _≈?_
mutual
data _≋_ {n} : Kind Elim n → Kind Elim n → Set where
≋-Π : ∀ {j₁ j₂ k₁ k₂} → j₁ ≋ j₂ → k₁ ≋ k₂ → Π j₁ k₁ ≋ Π j₂ k₂
≋-⋯ : ∀ {a₁ a₂ b₁ b₂} → a₁ ≈ a₂ → b₁ ≈ b₂ → a₁ ⋯ b₁ ≋ a₂ ⋯ b₂
data _≈_ {n} : Elim n → Elim n → Set where
≈-∙ : ∀ {a₁ a₂ bs₁ bs₂} → a₁ ≈Hd a₂ → bs₁ ≈Sp bs₂ → a₁ ∙ bs₁ ≈ a₂ ∙ bs₂
data _≈Hd_ {n} : Head n → Head n → Set where
≈-var : ∀ x → var x ≈Hd var x
≈-⊥ : ⊥ ≈Hd ⊥
≈-⊤ : ⊤ ≈Hd ⊤
≈-∀ : ∀ {k₁ k₂ a₁ a₂} → k₁ ≋ k₂ → a₁ ≈ a₂ → Π k₁ a₁ ≈Hd Π k₂ a₂
≈-→ : ∀ {a₁ a₂ b₁ b₂} → a₁ ≈ a₂ → b₁ ≈ b₂ → a₁ ⇒ b₁ ≈Hd a₂ ⇒ b₂
≈-Λ : ∀ {k₁ k₂ a₁ a₂} → ⌊ k₁ ⌋ ≡ ⌊ k₂ ⌋ → a₁ ≈ a₂ → Λ k₁ a₁ ≈Hd Λ k₂ a₂
≈-λ : ∀ {a₁ a₂ b₁ b₂} → b₁ ≈ b₂ → ƛ a₁ b₁ ≈Hd ƛ a₂ b₂
≈-⊡ : ∀ {a₁ a₂ b₁ b₂} → a₁ ≈ a₂ → b₁ ≈ b₂ → a₁ ⊡ b₁ ≈Hd a₂ ⊡ b₂
data _≈Sp_ {n} : Spine n → Spine n → Set where
≈-[] : [] ≈Sp []
≈-∷ : ∀ {a₁ a₂ bs₁ bs₂} → a₁ ≈ a₂ → bs₁ ≈Sp bs₂ → a₁ ∷ bs₁ ≈Sp a₂ ∷ bs₂
data _≈Asc_ {n} : ElimAsc n → ElimAsc n → Set where
≈-kd : ∀ {k₁ k₂} → k₁ ≋ k₂ → kd k₁ ≈Asc kd k₂
≈-tp : ∀ {a₁ a₂} → a₁ ≈ a₂ → tp a₁ ≈Asc tp a₂
open ElimCtx hiding (_++_)
data _≈Ctx_ : ∀ {n} → Ctx n → Ctx n → Set where
≈-[] : [] ≈Ctx []
≈-∷ : ∀ {n a₁ a₂} {Γ₁ Γ₂ : Ctx n} →
a₁ ≈Asc a₂ → Γ₁ ≈Ctx Γ₂ → a₁ ∷ Γ₁ ≈Ctx a₂ ∷ Γ₂
-- Weak equality of single-variable substations and results.
data _⟨≈⟩_ : ∀ {m n} → SVSub m n → SVSub m n → Set where
≈-sub : ∀ {n} {a b : Elim n} → a ≈ b → sub a ⟨≈⟩ sub b
≈-↑ : ∀ {m n} {σ τ : SVSub m n} → σ ⟨≈⟩ τ → σ ↑ ⟨≈⟩ τ ↑
data _≈?_ {n} : SVRes n → SVRes n → Set where
≈-hit : ∀ {a b : Elim n} → a ≈ b → hit a ≈? hit b
≈-miss : ∀ (x : Fin n) → miss x ≈? miss x
-- Shorthands.
≈-var∙ : ∀ {n} (x : Fin n) → var∙ x ≈ var∙ x
≈-var∙ x = ≈-∙ (≈-var x) ≈-[]
≈-⊥∙ : ∀ {n} → _≈_ {n = n} ⊥∙ ⊥∙
≈-⊥∙ = ≈-∙ (≈-⊥) ≈-[]
≈-⊤∙ : ∀ {n} → _≈_ {n = n} ⊤∙ ⊤∙
≈-⊤∙ = ≈-∙ (≈-⊤) ≈-[]
≈-∀∙ : ∀ {n} {k₁ k₂ : Kind Elim n} {a₁ a₂} →
k₁ ≋ k₂ → a₁ ≈ a₂ → ∀∙ k₁ a₁ ≈ ∀∙ k₂ a₂
≈-∀∙ k₁≋k₂ a₁≈a₂ = ≈-∙ (≈-∀ k₁≋k₂ a₁≈a₂) ≈-[]
≈-⇒∙ : ∀ {n} {a₁ a₂ : Elim n} {b₁ b₂} →
a₁ ≈ a₂ → b₁ ≈ b₂ → a₁ ⇒∙ b₁ ≈ a₂ ⇒∙ b₂
≈-⇒∙ a₁≈a₂ b₁≈b₂ = ≈-∙ (≈-→ a₁≈a₂ b₁≈b₂) ≈-[]
≈-Λ∙ : ∀ {n} {k₁ k₂ : Kind Elim n} {a₁ a₂} → ⌊ k₁ ⌋ ≡ ⌊ k₂ ⌋ → a₁ ≈ a₂ →
Λ∙ k₁ a₁ ≈ Λ∙ k₂ a₂
≈-Λ∙ ⌊k₁⌋≡⌊k₂⌋ a₁≈a₂ = ≈-∙ (≈-Λ ⌊k₁⌋≡⌊k₂⌋ a₁≈a₂) ≈-[]
≈-λ∙ : ∀ {n} {a₁ a₂ : Elim n} {b₁ b₂} → b₁ ≈ b₂ → ƛ∙ a₁ b₁ ≈ ƛ∙ a₂ b₂
≈-λ∙ a₁≈a₂ = ≈-∙ (≈-λ a₁≈a₂) ≈-[]
≈-⊡∙ : ∀ {n} {a₁ a₂ : Elim n} {b₁ b₂} →
a₁ ≈ a₂ → b₁ ≈ b₂ → a₁ ⊡∙ b₁ ≈ a₂ ⊡∙ b₂
≈-⊡∙ a₁≈a₂ b₁≈b₂ = ≈-∙ (≈-⊡ a₁≈a₂ b₁≈b₂) ≈-[]
------------------------------------------------------------------------
-- Simple properties of weake equality.
-- Some simple congruence rules w.r.t. operations on spines and
-- eliminations.
≈-++ : ∀ {n} {as₁ as₂ : Spine n} {bs₁ bs₂} →
as₁ ≈Sp as₂ → bs₁ ≈Sp bs₂ → as₁ ++ bs₁ ≈Sp as₂ ++ bs₂
≈-++ ≈-[] bs₁≈bs₂ = bs₁≈bs₂
≈-++ (≈-∷ a₁≈a₂ as₁≈as₂) bs₁≈bs₂ = ≈-∷ a₁≈a₂ (≈-++ as₁≈as₂ bs₁≈bs₂)
≈-∙∙ : ∀ {n} {a₁ a₂ : Elim n} {bs₁ bs₂} →
a₁ ≈ a₂ → bs₁ ≈Sp bs₂ → a₁ ∙∙ bs₁ ≈ a₂ ∙∙ bs₂
≈-∙∙ (≈-∙ a₁≈a₂ as₁≈as₂) bs₁≈bs₂ = ≈-∙ a₁≈a₂ (≈-++ as₁≈as₂ bs₁≈bs₂)
≈-⌜·⌝ : ∀ {n} {a₁ a₂ : Elim n} {b₁ b₂} →
a₁ ≈ a₂ → b₁ ≈ b₂ → a₁ ⌜·⌝ b₁ ≈ a₂ ⌜·⌝ b₂
≈-⌜·⌝ a₁≈a₂ b₁≈b₂ = ≈-∙∙ a₁≈a₂ (≈-∷ b₁≈b₂ ≈-[])
-- Weakly equal kinds have equal shapes.
≋-⌊⌋ : ∀ {n} {k₁ k₂ : Kind Elim n} → k₁ ≋ k₂ → ⌊ k₁ ⌋ ≡ ⌊ k₂ ⌋
≋-⌊⌋ (≋-Π j₁≋j₂ k₁≋k₂) = cong₂ _⇒_ (≋-⌊⌋ j₁≋j₂) (≋-⌊⌋ k₁≋k₂)
≋-⌊⌋ (≋-⋯ a₁≈a₂ b₁≈b₂) = refl
module _ where
open SimpleCtx using (kd; ⌊_⌋Asc)
open ContextConversions using (⌊_⌋Ctx)
-- Weakly equal ascriptions and contexts have equal shapes.
≈Asc-⌊⌋ : ∀ {n} {a₁ a₂ : ElimAsc n} → a₁ ≈Asc a₂ → ⌊ a₁ ⌋Asc ≡ ⌊ a₂ ⌋Asc
≈Asc-⌊⌋ (≈-kd k₁≋k₂) = cong kd (≋-⌊⌋ k₁≋k₂)
≈Asc-⌊⌋ (≈-tp a₁≈a₂) = refl
≈Ctx-⌊⌋ : ∀ {n} {Γ₁ Γ₂ : Ctx n} → Γ₁ ≈Ctx Γ₂ → ⌊ Γ₁ ⌋Ctx ≡ ⌊ Γ₂ ⌋Ctx
≈Ctx-⌊⌋ ≈-[] = refl
≈Ctx-⌊⌋ (≈-∷ a₁≈a₂ Γ₁≈Γ₂) = cong₂ _∷_ (≈Asc-⌊⌋ a₁≈a₂) (≈Ctx-⌊⌋ Γ₁≈Γ₂)
-- Reflexivity of weak equality.
mutual
≋-refl : ∀ {n} (k : Kind Elim n) → k ≋ k
≋-refl (a ⋯ b) = ≋-⋯ (≈-refl a) (≈-refl b)
≋-refl (Π j k) = ≋-Π (≋-refl j) (≋-refl k)
≈-refl : ∀ {n} (a : Elim n) → a ≈ a
≈-refl (a ∙ as) = ≈-∙ (≈Hd-refl a) (≈Sp-refl as)
≈Hd-refl : ∀ {n} (a : Head n) → a ≈Hd a
≈Hd-refl (var x) = ≈-var x
≈Hd-refl ⊥ = ≈-⊥
≈Hd-refl ⊤ = ≈-⊤
≈Hd-refl (Π k a) = ≈-∀ (≋-refl k) (≈-refl a)
≈Hd-refl (a ⇒ b) = ≈-→ (≈-refl a) (≈-refl b)
≈Hd-refl (Λ k a) = ≈-Λ refl (≈-refl a)
≈Hd-refl (ƛ a b) = ≈-λ (≈-refl b)
≈Hd-refl (a ⊡ b) = ≈-⊡ (≈-refl a) (≈-refl b)
≈Sp-refl : ∀ {n} (as : Spine n) → as ≈Sp as
≈Sp-refl [] = ≈-[]
≈Sp-refl (a ∷ as) = ≈-∷ (≈-refl a) (≈Sp-refl as)
≈Asc-refl : ∀ {n} (a : ElimAsc n) → a ≈Asc a
≈Asc-refl (kd k) = ≈-kd (≋-refl k)
≈Asc-refl (tp a) = ≈-tp (≈-refl a)
≈Ctx-refl : ∀ {n} (Γ : Ctx n) → Γ ≈Ctx Γ
≈Ctx-refl [] = ≈-[]
≈Ctx-refl (a ∷ Γ) = ≈-∷ (≈Asc-refl a) (≈Ctx-refl Γ)
-- Transitivity of weak equality.
mutual
≋-trans : ∀ {n} {j k l : Kind Elim n} → j ≋ k → k ≋ l → j ≋ l
≋-trans (≋-Π j₁≋j₂ k₁≋k₂) (≋-Π j₂≋j₃ k₂≋k₃) =
≋-Π (≋-trans j₁≋j₂ j₂≋j₃) (≋-trans k₁≋k₂ k₂≋k₃)
≋-trans (≋-⋯ a₁≈a₂ b₁≈b₂) (≋-⋯ a₂≈a₃ b₂≈b₃) =
≋-⋯ (≈-trans a₁≈a₂ a₂≈a₃) (≈-trans b₁≈b₂ b₂≈b₃)
≈-trans : ∀ {n} {a b c : Elim n} → a ≈ b → b ≈ c → a ≈ c
≈-trans (≈-∙ a₁≈a₂ bs₁≈bs₂) (≈-∙ a₂≈a₃ bs₂≈bs₃) =
≈-∙ (≈Hd-trans a₁≈a₂ a₂≈a₃) (≈Sp-trans bs₁≈bs₂ bs₂≈bs₃)
≈Hd-trans : ∀ {n} {a b c : Head n} → a ≈Hd b → b ≈Hd c → a ≈Hd c
≈Hd-trans (≈-var x) (≈-var .x) = ≈-var x
≈Hd-trans ≈-⊥ ≈-⊥ = ≈-⊥
≈Hd-trans ≈-⊤ ≈-⊤ = ≈-⊤
≈Hd-trans (≈-∀ k₁≋k₂ a₁≈a₂) (≈-∀ k₂≋k₃ a₂≈a₃) =
≈-∀ (≋-trans k₁≋k₂ k₂≋k₃) (≈-trans a₁≈a₂ a₂≈a₃)
≈Hd-trans (≈-→ a₁≈a₂ b₁≈b₂) (≈-→ a₂≈a₃ b₂≈b₃) =
≈-→ (≈-trans a₁≈a₂ a₂≈a₃) (≈-trans b₁≈b₂ b₂≈b₃)
≈Hd-trans (≈-Λ ⌊k₁⌋≡⌊k₂⌋ a₁≈a₂) (≈-Λ ⌊k₂⌋≡⌊k₃⌋ a₂≈a₃) =
≈-Λ (trans ⌊k₁⌋≡⌊k₂⌋ ⌊k₂⌋≡⌊k₃⌋) (≈-trans a₁≈a₂ a₂≈a₃)
≈Hd-trans (≈-λ a₁≈a₂) (≈-λ a₂≈a₃) = ≈-λ (≈-trans a₁≈a₂ a₂≈a₃)
≈Hd-trans (≈-⊡ a₁≈a₂ b₁≈b₂) (≈-⊡ a₂≈a₃ b₂≈b₃) =
≈-⊡ (≈-trans a₁≈a₂ a₂≈a₃) (≈-trans b₁≈b₂ b₂≈b₃)
≈Sp-trans : ∀ {n} {as bs cs : Spine n} → as ≈Sp bs → bs ≈Sp cs → as ≈Sp cs
≈Sp-trans ≈-[] ≈-[] = ≈-[]
≈Sp-trans (≈-∷ a₁≈a₂ bs₁≈bs₂) (≈-∷ a₂≈a₃ bs₂≈bs₃) =
≈-∷ (≈-trans a₁≈a₂ a₂≈a₃) (≈Sp-trans bs₁≈bs₂ bs₂≈bs₃)
≈Asc-trans : ∀ {n} {a b c : ElimAsc n} → a ≈Asc b → b ≈Asc c → a ≈Asc c
≈Asc-trans (≈-kd k₁≋k₂) (≈-kd k₂≋k₃) = ≈-kd (≋-trans k₁≋k₂ k₂≋k₃)
≈Asc-trans (≈-tp a₁≈a₂) (≈-tp a₂≈a₃) = ≈-tp (≈-trans a₁≈a₂ a₂≈a₃)
≈Ctx-trans : ∀ {n} {Γ Δ E : Ctx n} → Γ ≈Ctx Δ → Δ ≈Ctx E → Γ ≈Ctx E
≈Ctx-trans ≈-[] ≈-[] = ≈-[]
≈Ctx-trans (≈-∷ a₁≈a₂ Γ₁≈Γ₂) (≈-∷ a₂≈a₃ Γ₂≈Γ₃) =
≈-∷ (≈Asc-trans a₁≈a₂ a₂≈a₃) (≈Ctx-trans Γ₁≈Γ₂ Γ₂≈Γ₃)
-- Symmetry of weak equality.
mutual
≋-sym : ∀ {n} {j k : Kind Elim n} → j ≋ k → k ≋ j
≋-sym (≋-⋯ a₁≈a₂ b₁≈b₂) = ≋-⋯ (≈-sym a₁≈a₂) (≈-sym b₁≈b₂)
≋-sym (≋-Π j₁≋j₂ k₁≋k₂) = ≋-Π (≋-sym j₁≋j₂) (≋-sym k₁≋k₂)
≈-sym : ∀ {n} {a b : Elim n} → a ≈ b → b ≈ a
≈-sym (≈-∙ a≈b as≈bs) = ≈-∙ (≈Hd-sym a≈b) (≈Sp-sym as≈bs)
≈Hd-sym : ∀ {n} {a b : Head n} → a ≈Hd b → b ≈Hd a
≈Hd-sym (≈-var x) = ≈-var x
≈Hd-sym ≈-⊥ = ≈-⊥
≈Hd-sym ≈-⊤ = ≈-⊤
≈Hd-sym (≈-∀ k₁≋k₂ a₁≈a₂) = ≈-∀ (≋-sym k₁≋k₂) (≈-sym a₁≈a₂)
≈Hd-sym (≈-→ a₁≈a₂ b₁≈b₂) = ≈-→ (≈-sym a₁≈a₂) (≈-sym b₁≈b₂)
≈Hd-sym (≈-Λ ⌊k₁⌋≡⌊k₂⌋ a₁≈a₂) = ≈-Λ (sym ⌊k₁⌋≡⌊k₂⌋) (≈-sym a₁≈a₂)
≈Hd-sym (≈-λ a₁≈a₂) = ≈-λ (≈-sym a₁≈a₂)
≈Hd-sym (≈-⊡ a₁≈a₂ b₁≈b₂) = ≈-⊡ (≈-sym a₁≈a₂) (≈-sym b₁≈b₂)
≈Sp-sym : ∀ {n} {as bs : Spine n} → as ≈Sp bs → bs ≈Sp as
≈Sp-sym ≈-[] = ≈-[]
≈Sp-sym (≈-∷ a₁≈a₂ as₁≈as₂) = ≈-∷ (≈-sym a₁≈a₂) (≈Sp-sym as₁≈as₂)
≈Asc-sym : ∀ {n} {a b : ElimAsc n} → a ≈Asc b → b ≈Asc a
≈Asc-sym (≈-kd j≋k) = ≈-kd (≋-sym j≋k)
≈Asc-sym (≈-tp a≈b) = ≈-tp (≈-sym a≈b)
≈Ctx-sym : ∀ {n} {Γ Δ : Ctx n} → Γ ≈Ctx Δ → Δ ≈Ctx Γ
≈Ctx-sym ≈-[] = ≈-[]
≈Ctx-sym (≈-∷ a₁≈a₂ Γ₁≈Γ₂) = ≈-∷ (≈Asc-sym a₁≈a₂) (≈Ctx-sym Γ₁≈Γ₂)
-- Weak equality is an equivalence relation.
≋-isEquivalence : (n : ℕ) → IsEquivalence (_≋_ {n})
≋-isEquivalence n = record
{ refl = λ {k} → ≋-refl k
; sym = ≋-sym
; trans = ≋-trans
}
≈-isEquivalence : (n : ℕ) → IsEquivalence (_≈_ {n})
≈-isEquivalence n = record
{ refl = λ {k} → ≈-refl k
; sym = ≈-sym
; trans = ≈-trans
}
≈Hd-isEquivalence : (n : ℕ) → IsEquivalence (_≈Hd_ {n})
≈Hd-isEquivalence n = record
{ refl = λ {k} → ≈Hd-refl k
; sym = ≈Hd-sym
; trans = ≈Hd-trans
}
≈Sp-isEquivalence : (n : ℕ) → IsEquivalence (_≈Sp_ {n})
≈Sp-isEquivalence n = record
{ refl = λ {k} → ≈Sp-refl k
; sym = ≈Sp-sym
; trans = ≈Sp-trans
}
≈Asc-isEquivalence : (n : ℕ) → IsEquivalence (_≈Asc_ {n})
≈Asc-isEquivalence n = record
{ refl = λ {k} → ≈Asc-refl k
; sym = ≈Asc-sym
; trans = ≈Asc-trans
}
≈Ctx-isEquivalence : (n : ℕ) → IsEquivalence (_≈Ctx_ {n})
≈Ctx-isEquivalence n = record
{ refl = λ {k} → ≈Ctx-refl k
; sym = ≈Ctx-sym
; trans = ≈Ctx-trans
}
-- Kinds together with weak equality form a setoid.
≋-setoid : ℕ → Setoid _ _
≋-setoid n = record
{ Carrier = Kind Elim n
; _≈_ = _≋_
; isEquivalence = ≋-isEquivalence n
}
-- Types and terms together with weak equality form a setoid.
≈-setoid : ℕ → Setoid _ _
≈-setoid n = record
{ Carrier = Elim n
; _≈_ = _≈_
; isEquivalence = ≈-isEquivalence n
}
≈Hd-setoid : ℕ → Setoid _ _
≈Hd-setoid n = record
{ Carrier = Head n
; _≈_ = _≈Hd_
; isEquivalence = ≈Hd-isEquivalence n
}
≈Sp-setoid : ℕ → Setoid _ _
≈Sp-setoid n = record
{ Carrier = Spine n
; _≈_ = _≈Sp_
; isEquivalence = ≈Sp-isEquivalence n
}
≈Asc-setoid : ℕ → Setoid _ _
≈Asc-setoid n = record
{ Carrier = ElimAsc n
; _≈_ = _≈Asc_
; isEquivalence = ≈Asc-isEquivalence n
}
≈Ctx-setoid : ℕ → Setoid _ _
≈Ctx-setoid n = record
{ Carrier = Ctx n
; _≈_ = _≈Ctx_
; isEquivalence = ≈Ctx-isEquivalence n
}
-- Equational reasoning for weak equality.
module ≈-Reasoning {n : ℕ} where
open SetoidReasoning (≈-setoid n) public
module Kd = SetoidReasoning (≋-setoid n)
module Hd = SetoidReasoning (≈Hd-setoid n)
module Sp = SetoidReasoning (≈Sp-setoid n)
module Asc = SetoidReasoning (≈Asc-setoid n)
module Ctx = SetoidReasoning (≈Ctx-setoid n)
------------------------------------------------------------------------
-- Substitution lemmas for weak equality.
-- Renamings in weakly equal terms.
--
-- The substitution lemmas below establishe that renamings of
-- variables in kinds, heads, eliminations and spines preserve weak
-- equality:
--
-- ≈
-- a ------→ b
-- | |
-- -/ρ | | -/ρ
-- ↓ ≈ ↓
-- a/ρ ····→ b/ρ
--
-- where ρ is a renaming.
module Renaming where
open Substitution
module V = VarSubst
mutual
-- Renamings preserve weak equality.
≋-/Var : ∀ {m n k₁ k₂} →
k₁ ≋ k₂ → (ρ : Sub Fin m n) → k₁ Kind′/Var ρ ≋ k₂ Kind′/Var ρ
≋-/Var (≋-Π j₁≋j₂ k₁≋k₂) ρ =
≋-Π (≋-/Var j₁≋j₂ ρ) (≋-/Var k₁≋k₂ (ρ V.↑))
≋-/Var (≋-⋯ a₁≈a₂ b₁≈b₂) ρ =
≋-⋯ (≈-/Var a₁≈a₂ ρ) (≈-/Var b₁≈b₂ ρ)
≈-/Var : ∀ {m n a₁ a₂} →
a₁ ≈ a₂ → (ρ : Sub Fin m n) → a₁ Elim/Var ρ ≈ a₂ Elim/Var ρ
≈-/Var (≈-∙ a₁≈a₂ bs₁≈bs₂) ρ =
≈-∙∙ (≈Hd-/Var a₁≈a₂ ρ) (≈Sp-/Var bs₁≈bs₂ ρ)
≈Hd-/Var : ∀ {m n a₁ a₂} →
a₁ ≈Hd a₂ → (ρ : Sub Fin m n) → a₁ Head/Var′ ρ ≈ a₂ Head/Var′ ρ
≈Hd-/Var (≈-var x) ρ = ≈-var∙ (Vec.lookup ρ x)
≈Hd-/Var ≈-⊥ ρ = ≈-⊥∙
≈Hd-/Var ≈-⊤ ρ = ≈-⊤∙
≈Hd-/Var (≈-∀ k₁≋k₂ a₁≈a₂) ρ =
≈-∀∙ (≋-/Var k₁≋k₂ ρ) (≈-/Var a₁≈a₂ (ρ V.↑))
≈Hd-/Var (≈-→ a₁≈a₂ b₁≈b₂) ρ =
≈-⇒∙ (≈-/Var a₁≈a₂ ρ) (≈-/Var b₁≈b₂ ρ)
≈Hd-/Var (≈-Λ {k₁} {k₂} ⌊k₁⌋≡⌊k₂⌋ a₁≈a₂) ρ =
≈-Λ∙ (begin
⌊ k₁ Kind′/Var _ ⌋ ≡⟨ ⌊⌋-Kind′/Var k₁ ⟩
⌊ k₁ ⌋ ≡⟨ ⌊k₁⌋≡⌊k₂⌋ ⟩
⌊ k₂ ⌋ ≡⟨ sym (⌊⌋-Kind′/Var k₂) ⟩
⌊ k₂ Kind′/Var _ ⌋ ∎)
(≈-/Var a₁≈a₂ (ρ V.↑))
where open ≡-Reasoning
≈Hd-/Var (≈-λ a₁≈a₂) ρ = ≈-λ∙ (≈-/Var a₁≈a₂ (ρ V.↑))
≈Hd-/Var (≈-⊡ a₁≈a₂ b₁≈b₂) ρ =
≈-⊡∙ (≈-/Var a₁≈a₂ ρ) (≈-/Var b₁≈b₂ ρ)
≈Sp-/Var : ∀ {m n as₁ as₂} →
as₁ ≈Sp as₂ → (ρ : Sub Fin m n) → as₁ //Var ρ ≈Sp as₂ //Var ρ
≈Sp-/Var ≈-[] ρ = ≈-[]
≈Sp-/Var (≈-∷ a₁≈a₂ as₁≈as₂) ρ =
≈-∷ (≈-/Var a₁≈a₂ ρ) (≈Sp-/Var as₁≈as₂ ρ)
≈?-/Var : ∀ {m n r₁ r₂} →
r₁ ≈? r₂ → (ρ : Sub Fin m n) → r₁ ?/Var ρ ≈? r₂ ?/Var ρ
≈?-/Var (≈-hit a₁≈a₂) ρ = ≈-hit (≈-/Var a₁≈a₂ ρ)
≈?-/Var (≈-miss x) ρ = ≈-miss (Vec.lookup ρ x)
≈-weakenElim : ∀ {n} {a₁ a₂ : Elim n} →
a₁ ≈ a₂ → weakenElim a₁ ≈ weakenElim a₂
≈-weakenElim a₁≈a₂ = ≈-/Var a₁≈a₂ V.wk
≈-weakenSVRes : ∀ {n} {r₁ r₂ : SVRes n} →
r₁ ≈? r₂ → weakenSVRes r₁ ≈? weakenSVRes r₂
≈-weakenSVRes r₁≈r₂ = ≈?-/Var r₁≈r₂ V.wk
open Renaming
-- Look up a weak equation in a pair of pointwise weakly equal
-- single-variable substitutions.
⟨≈⟩-lookup : ∀ {m n σ₁} {σ₂ : SVSub m n} →
σ₁ ⟨≈⟩ σ₂ → (x : Fin m) → lookupSV σ₁ x ≈? lookupSV σ₂ x
⟨≈⟩-lookup (≈-sub a₁≈a₂) zero = ≈-hit a₁≈a₂
⟨≈⟩-lookup (≈-sub a₁≈a₂) (suc x) = ≈-miss x
⟨≈⟩-lookup (≈-↑ σ₁≈σ₂) zero = ≈-miss zero
⟨≈⟩-lookup (≈-↑ σ₁≈σ₂) (suc x) = ≈-weakenSVRes (⟨≈⟩-lookup σ₁≈σ₂ x)
-- Weak equality lifted to hereditary substitutions.
--
-- The substitution lemmas below establishe that simoultaneous
-- hereditary substitutions of weakly equal types or terms in kinds,
-- heads, eliminations and spines preserve weak equality:
--
-- ≈
-- a ------- b
-- | |
-- -/σ₁ | | -/σ₂
-- ↓ ≈ ↓
-- a/σ₁ ···· b/σ₂
--
-- where σ₁ and σ₁ are weakly equal hereditary substitutions.
module WeakHereditarySubstitutionEquality where
open Substitution hiding (_↑; sub)
mutual
-- Point-wise weakly equal hereditary substitutions preserve weak
-- equality.
≋-/⟨⟩ : ∀ {k m n j₁ j₂} {σ₁ σ₂ : SVSub m n} →
j₁ ≋ j₂ → σ₁ ⟨≈⟩ σ₂ → j₁ Kind/⟨ k ⟩ σ₁ ≋ j₂ Kind/⟨ k ⟩ σ₂
≋-/⟨⟩ (≋-Π j₁≋j₂ k₁≋k₂) σ₁≈σ₂ =
≋-Π (≋-/⟨⟩ j₁≋j₂ σ₁≈σ₂) (≋-/⟨⟩ k₁≋k₂ (≈-↑ σ₁≈σ₂))
≋-/⟨⟩ (≋-⋯ a₁≈a₂ b₁≈b₂) σ₁≈σ₂ =
≋-⋯ (≈-/⟨⟩ a₁≈a₂ σ₁≈σ₂) (≈-/⟨⟩ b₁≈b₂ σ₁≈σ₂)
≈-/⟨⟩ : ∀ {k m n a₁ a₂} {σ₁ σ₂ : SVSub m n} →
a₁ ≈ a₂ → σ₁ ⟨≈⟩ σ₂ → a₁ /⟨ k ⟩ σ₁ ≈ a₂ /⟨ k ⟩ σ₂
≈-/⟨⟩ (≈-∙ (≈-var x) bs₁≈bs₂) σ₁≈σ₂ =
≈-?∙∙⟨⟩ _ (⟨≈⟩-lookup σ₁≈σ₂ x) (≈Sp-/⟨⟩ bs₁≈bs₂ σ₁≈σ₂)
≈-/⟨⟩ (≈-∙ ≈-⊥ bs₁≈bs₂) σ₁≈σ₂ = ≈-∙ ≈-⊥ (≈Sp-/⟨⟩ bs₁≈bs₂ σ₁≈σ₂)
≈-/⟨⟩ (≈-∙ ≈-⊤ bs₁≈bs₂) σ₁≈σ₂ = ≈-∙ ≈-⊤ (≈Sp-/⟨⟩ bs₁≈bs₂ σ₁≈σ₂)
≈-/⟨⟩ (≈-∙ (≈-∀ k₁≋k₂ a₁≈a₂) bs₁≈bs₂) σ₁≈σ₂ =
≈-∙ (≈-∀ (≋-/⟨⟩ k₁≋k₂ σ₁≈σ₂) (≈-/⟨⟩ a₁≈a₂ (≈-↑ σ₁≈σ₂)))
(≈Sp-/⟨⟩ bs₁≈bs₂ σ₁≈σ₂)
≈-/⟨⟩ (≈-∙ (≈-→ a₁≈a₂ b₁≈b₂) cs₁≈cs₂) σ₁≈σ₂ =
≈-∙ (≈-→ (≈-/⟨⟩ a₁≈a₂ σ₁≈σ₂) (≈-/⟨⟩ b₁≈b₂ σ₁≈σ₂))
(≈Sp-/⟨⟩ cs₁≈cs₂ σ₁≈σ₂)
≈-/⟨⟩ (≈-∙ (≈-Λ {k₁} {k₂} ⌊k₁⌋≡⌊k₂⌋ a₁≈a₂) bs₁≈bs₂) σ₁≈σ₂ =
≈-∙ (≈-Λ (begin
⌊ k₁ Kind/⟨ _ ⟩ _ ⌋ ≡⟨ ⌊⌋-Kind/⟨⟩ k₁ ⟩
⌊ k₁ ⌋ ≡⟨ ⌊k₁⌋≡⌊k₂⌋ ⟩
⌊ k₂ ⌋ ≡⟨ sym (⌊⌋-Kind/⟨⟩ k₂) ⟩
⌊ k₂ Kind/⟨ _ ⟩ _ ⌋ ∎)
(≈-/⟨⟩ a₁≈a₂ (≈-↑ σ₁≈σ₂)))
(≈Sp-/⟨⟩ bs₁≈bs₂ σ₁≈σ₂)
where open ≡-Reasoning
≈-/⟨⟩ (≈-∙ (≈-λ a₁≈a₂) bs₁≈bs₂) σ₁≈σ₂ =
≈-∙ (≈-λ (≈-/⟨⟩ a₁≈a₂ (≈-↑ σ₁≈σ₂))) (≈Sp-/⟨⟩ bs₁≈bs₂ σ₁≈σ₂)
≈-/⟨⟩ (≈-∙ (≈-⊡ a₁≈a₂ b₁≈b₂) cs₁≈cs₂) σ₁≈σ₂ =
≈-∙ (≈-⊡ (≈-/⟨⟩ a₁≈a₂ σ₁≈σ₂) (≈-/⟨⟩ b₁≈b₂ σ₁≈σ₂))
(≈Sp-/⟨⟩ cs₁≈cs₂ σ₁≈σ₂)
≈Sp-/⟨⟩ : ∀ {k m n as₁ as₂} {σ₁ σ₂ : SVSub m n} →
as₁ ≈Sp as₂ → σ₁ ⟨≈⟩ σ₂ → as₁ //⟨ k ⟩ σ₁ ≈Sp as₂ //⟨ k ⟩ σ₂
≈Sp-/⟨⟩ ≈-[] σ₁≈σ₂ = ≈-[]
≈Sp-/⟨⟩ (≈-∷ a₁≈a₂ as₁≈as₂) σ₁≈σ₂ =
≈-∷ (≈-/⟨⟩ a₁≈a₂ σ₁≈σ₂) (≈Sp-/⟨⟩ as₁≈as₂ σ₁≈σ₂)
-- Weak equality is a congruence w.r.t reducing applications.
≈-?∙∙⟨⟩ : ∀ k {n} {r₁ r₂ : SVRes n} {as₁ as₂} →
r₁ ≈? r₂ → as₁ ≈Sp as₂ → r₁ ?∙∙⟨ k ⟩ as₁ ≈ r₂ ?∙∙⟨ k ⟩ as₂
≈-?∙∙⟨⟩ k (≈-hit a₁≈a₂) as₁≈as₂ = ≈-∙∙⟨⟩ k a₁≈a₂ as₁≈as₂
≈-?∙∙⟨⟩ k (≈-miss x) as₁≈as₂ = ≈-∙ (≈-var x) as₁≈as₂
≈-∙∙⟨⟩ : ∀ k {n} {a₁ a₂ : Elim n} {bs₁ bs₂} →
a₁ ≈ a₂ → bs₁ ≈Sp bs₂ → a₁ ∙∙⟨ k ⟩ bs₁ ≈ a₂ ∙∙⟨ k ⟩ bs₂
≈-∙∙⟨⟩ k a₁≈a₂ ≈-[] = a₁≈a₂
≈-∙∙⟨⟩ ★ a₁≈a₂ (≈-∷ b₁≈b₂ bs₁≈bs₂) = ≈-∙∙ a₁≈a₂ (≈-∷ b₁≈b₂ bs₁≈bs₂)
≈-∙∙⟨⟩ (k₁ ⇒ k₂) a₁≈a₂ (≈-∷ b₁≈b₂ bs₁≈bs₂) =
≈-∙∙⟨⟩ k₂ (≈-⌜·⌝⟨⟩ (k₁ ⇒ k₂) a₁≈a₂ b₁≈b₂) bs₁≈bs₂
≈-⌜·⌝⟨⟩ : ∀ k {n} {a₁ a₂ : Elim n} {b₁ b₂} →
a₁ ≈ a₂ → b₁ ≈ b₂ → a₁ ⌜·⌝⟨ k ⟩ b₁ ≈ a₂ ⌜·⌝⟨ k ⟩ b₂
≈-⌜·⌝⟨⟩ ★ a₁≈a₂ b₁≈b₂ = ≈-⌜·⌝ a₁≈a₂ b₁≈b₂
≈-⌜·⌝⟨⟩ (k₁ ⇒ k₂) (≈-∙ a₁≈a₂ (≈-∷ b₁≈b₂ bs₁≈bs₂)) c₁≈c₂ =
≈-⌜·⌝ (≈-∙ a₁≈a₂ (≈-∷ b₁≈b₂ bs₁≈bs₂)) c₁≈c₂
≈-⌜·⌝⟨⟩ (k₁ ⇒ k₂) (≈-∙ (≈-Λ ⌊k₁⌋≡⌊k₂⌋ a₁≈a₂) ≈-[]) c₁≈c₂ =
≈-/⟨⟩ a₁≈a₂ (≈-sub c₁≈c₂)
-- Degenerate cases.
≈-⌜·⌝⟨⟩ (k₁ ⇒ k₂) (≈-∙ ≈-⊥ ≈-[]) c₁≈c₂ = ≈-∙ ≈-⊥ (≈-∷ c₁≈c₂ ≈-[])
≈-⌜·⌝⟨⟩ (k₁ ⇒ k₂) (≈-∙ ≈-⊤ ≈-[]) c₁≈c₂ = ≈-∙ ≈-⊤ (≈-∷ c₁≈c₂ ≈-[])
≈-⌜·⌝⟨⟩ (k₁ ⇒ k₂) (≈-∙ (≈-var x) ≈-[]) c₁≈c₂ =
≈-∙ (≈-var x) (≈-∷ c₁≈c₂ ≈-[])
≈-⌜·⌝⟨⟩ (k₁ ⇒ k₂) (≈-∙ (≈-∀ j₁≋j₂ a₁≈a₂) ≈-[]) c₁≈c₂ =
≈-∙ (≈-∀ j₁≋j₂ a₁≈a₂) (≈-∷ c₁≈c₂ ≈-[])
≈-⌜·⌝⟨⟩ (k₁ ⇒ k₂) (≈-∙ (≈-→ a₁≈a₂ b₁≈b₂) ≈-[]) c₁≈c₂ =
≈-∙ (≈-→ a₁≈a₂ b₁≈b₂) (≈-∷ c₁≈c₂ ≈-[])
≈-⌜·⌝⟨⟩ (k₁ ⇒ k₂) (≈-∙ (≈-λ a₁≈a₂) ≈-[]) c₁≈c₂ =
≈-∙ (≈-λ a₁≈a₂) (≈-∷ c₁≈c₂ ≈-[])
≈-⌜·⌝⟨⟩ (k₁ ⇒ k₂) (≈-∙ (≈-⊡ a₁≈a₂ b₁≈b₂) ≈-[]) c₁≈c₂ =
≈-∙ (≈-⊡ a₁≈a₂ b₁≈b₂) (≈-∷ c₁≈c₂ ≈-[])
-- A corollary.
≈-[∈] : ∀ {k n a₁ a₂} {b₁ b₂ : Elim n} →
a₁ ≈ a₂ → b₁ ≈ b₂ → a₁ [ b₁ ∈ k ] ≈ a₂ [ b₂ ∈ k ]
≈-[∈] a₁≈a₂ b₁≈b₂ = ≈-/⟨⟩ a₁≈a₂ (≈-sub b₁≈b₂)
-- Weak equality is a congruence w.r.t potentially reducing
-- applications.
≈-↓⌜·⌝ : ∀ {n} {a₁ a₂ : Elim n} {b₁ b₂} → a₁ ≈ a₂ → b₁ ≈ b₂ →
a₁ ↓⌜·⌝ b₁ ≈ a₂ ↓⌜·⌝ b₂
≈-↓⌜·⌝ (≈-∙ a₁≈a₂ (≈-∷ b₁≈b₂ bs₁≈bs₂)) c₁≈c₂ =
≈-⌜·⌝ (≈-∙ a₁≈a₂ (≈-∷ b₁≈b₂ bs₁≈bs₂)) c₁≈c₂
≈-↓⌜·⌝ {_} {_} {_} {b₁} {b₂}
(≈-∙ (≈-Λ {k₁} {k₂} {a₁} {a₂} ⌊k₁⌋≡⌊k₂⌋ a₁≈a₂) ≈-[]) c₁≈c₂ =
begin
a₁ [ b₁ ∈ ⌊ k₁ ⌋ ] ≈⟨ ≈-/⟨⟩ a₁≈a₂ (≈-sub c₁≈c₂) ⟩
a₂ [ b₂ ∈ ⌊ k₁ ⌋ ] ≡⟨ cong (a₂ [ b₂ ∈_]) ⌊k₁⌋≡⌊k₂⌋ ⟩
a₂ [ b₂ ∈ ⌊ k₂ ⌋ ] ∎
where open ≈-Reasoning
-- Degenerate cases.
≈-↓⌜·⌝ (≈-∙ ≈-⊥ ≈-[]) c₁≈c₂ = ≈-∙ ≈-⊥ (≈-∷ c₁≈c₂ ≈-[])
≈-↓⌜·⌝ (≈-∙ ≈-⊤ ≈-[]) c₁≈c₂ = ≈-∙ ≈-⊤ (≈-∷ c₁≈c₂ ≈-[])
≈-↓⌜·⌝ (≈-∙ (≈-var x) ≈-[]) c₁≈c₂ =
≈-∙ (≈-var x) (≈-∷ c₁≈c₂ ≈-[])
≈-↓⌜·⌝ (≈-∙ (≈-∀ j₁≋j₂ a₁≈a₂) ≈-[]) c₁≈c₂ =
≈-∙ (≈-∀ j₁≋j₂ a₁≈a₂) (≈-∷ c₁≈c₂ ≈-[])
≈-↓⌜·⌝ (≈-∙ (≈-→ a₁≈a₂ b₁≈b₂) ≈-[]) c₁≈c₂ =
≈-∙ (≈-→ a₁≈a₂ b₁≈b₂) (≈-∷ c₁≈c₂ ≈-[])
≈-↓⌜·⌝ (≈-∙ (≈-λ a₁≈a₂) ≈-[]) c₁≈c₂ =
≈-∙ (≈-λ a₁≈a₂) (≈-∷ c₁≈c₂ ≈-[])
≈-↓⌜·⌝ (≈-∙ (≈-⊡ a₁≈a₂ b₁≈b₂) ≈-[]) c₁≈c₂ =
≈-∙ (≈-⊡ a₁≈a₂ b₁≈b₂) (≈-∷ c₁≈c₂ ≈-[])
open WeakHereditarySubstitutionEquality
module WeakEqEtaExpansion where
private module TK = TrackSimpleKindsEtaExp
open Substitution
open SimpHSubstLemmas
open ≈-Reasoning
-- NOTE. The definition of the function ≈-η-exp′ in this module is
-- structurally recursive in the *shape* parameter k, but *not* in
-- the kinds (j₁ j₂ : Kind Elim n) because we need to weaken the
-- domains j₁₁ and j₂₁ of the dependent kinds (j₁ = Π j₁₁ j₁₂) and
-- (j₂ = Π j₂₁ j₂₂) in the arrow case. The additional premises ⌊ j₁
-- ⌋≡ k and ⌊ j₂ ⌋≡ k ensure that k is indeed the shape of the kinds
-- j₁ and j₂.
-- Weak equality is a congruence w.r.t. untyped η-expansion.
--
-- NOTE. We do *not* require the kinds j₁ and j₂ to be (weakly)
-- equal, we only require them to have the same shape.
≈-η-exp′ : ∀ {n k j₁ j₂} {a₁ a₂ : Elim n}
(hyp₁ : ⌊ j₁ ⌋≡ k) (hyp₂ : ⌊ j₂ ⌋≡ k) → a₁ ≈ a₂ →
TK.η-exp j₁ hyp₁ a₁ ≈ TK.η-exp j₂ hyp₂ a₂
≈-η-exp′ (is-★) (is-★) a₁≈a₂ = a₁≈a₂
≈-η-exp′ (is-⇒ ⌊j₁⌋≡l₁ ⌊k₁⌋≡l₂) (is-⇒ ⌊j₂⌋≡l₁ ⌊k₂⌋≡l₂) a₁≈a₂ =
≈-Λ∙ ⌊j₁⌋≡⌊j₂⌋ (≈-η-exp′ ⌊k₁⌋≡l₂ ⌊k₂⌋≡l₂ a₁·ηz≈a₂·ηz)
where
⌊j₁⌋≡⌊j₂⌋ = trans (⌊⌋≡⇒⌊⌋-≡ ⌊j₁⌋≡l₁) (sym (⌊⌋≡⇒⌊⌋-≡ ⌊j₂⌋≡l₁))
a₁·ηz≈a₂·ηz =
≈-⌜·⌝ (≈-weakenElim a₁≈a₂)
(≈-η-exp′ (⌊⌋≡-weaken ⌊j₁⌋≡l₁) (⌊⌋≡-weaken ⌊j₂⌋≡l₁) (≈-var∙ zero))
≈-η-exp : ∀ {n} {j₁ j₂ : Kind Elim n} {a₁ a₂} →
⌊ j₁ ⌋ ≡ ⌊ j₂ ⌋ → a₁ ≈ a₂ → η-exp j₁ a₁ ≈ η-exp j₂ a₂
≈-η-exp {_} {j₁} {j₂} {a₁} {a₂} ⌊j₁⌋≡⌊j₂⌋ a₁≈a₂ = begin
η-exp j₁ a₁
≡⟨ TK.η-exp-⌊⌋≡ (⌊⌋-⌊⌋≡ j₁) (⌊⌋≡-trans ⌊j₁⌋≡⌊j₂⌋ (⌊⌋-⌊⌋≡ j₂))
refl ⌊j₁⌋≡⌊j₂⌋ ⟩
TK.η-exp j₁ _ a₁
≈⟨ ≈-η-exp′ (⌊⌋≡-trans ⌊j₁⌋≡⌊j₂⌋ (⌊⌋-⌊⌋≡ j₂)) (⌊⌋-⌊⌋≡ j₂) a₁≈a₂ ⟩
η-exp j₂ a₂
∎
open SimpleCtx using (kd; ⌊_⌋Asc; kd-inj′)
open ContextConversions using (⌊_⌋Ctx)
-- A variant of `nf-var-kd' that is a corollary of the above.
nf-var-kd-⌊⌋ : ∀ {n} (Γ : Ctx n) {k} x →
⌊ lookup Γ x ⌋Asc ≡ kd ⌊ k ⌋ → nf Γ (var x) ≈ η-exp k (var∙ x)
nf-var-kd-⌊⌋ Γ x hyp with lookup Γ x
nf-var-kd-⌊⌋ Γ x hyp | kd j = ≈-η-exp (kd-inj′ hyp) (≈-var∙ x)
nf-var-kd-⌊⌋ Γ x () | tp _
open WeakEqEtaExpansion
module WeakEqNormalization where
open SimpleCtx using (kd; ⌊_⌋Asc; ⌊⌋-ElimAsc/Var; kd-inj′)
open ContextConversions
-- A helper lemma.
⌊⌋≡⌊⌋-lookup : ∀ {n} (Γ₁ Γ₂ : Ctx n) x → ⌊ Γ₁ ⌋Ctx ≡ ⌊ Γ₂ ⌋Ctx →
⌊ lookup Γ₁ x ⌋Asc ≡ ⌊ lookup Γ₂ x ⌋Asc
⌊⌋≡⌊⌋-lookup Γ₁ Γ₂ x ⌊Γ₁⌋≡⌊Γ₂⌋ = begin
⌊ lookup Γ₁ x ⌋Asc
≡˘⟨ ⌊⌋Asc-lookup Γ₁ x ⟩
SimpleCtx.lookup ⌊ Γ₁ ⌋Ctx x
≡⟨ cong (λ Δ → SimpleCtx.lookup Δ x) ⌊Γ₁⌋≡⌊Γ₂⌋ ⟩
SimpleCtx.lookup ⌊ Γ₂ ⌋Ctx x
≡⟨ ⌊⌋Asc-lookup Γ₂ x ⟩
⌊ lookup Γ₂ x ⌋Asc
∎
where open ≡-Reasoning
-- If two contexts have the same shape, then kinds, types and terms
-- normalize weakly equally in these contexts.
mutual
≈-nf : ∀ {n} {Γ₁ Γ₂ : Ctx n} →
⌊ Γ₁ ⌋Ctx ≡ ⌊ Γ₂ ⌋Ctx → ∀ a → nf Γ₁ a ≈ nf Γ₂ a
≈-nf {_} {Γ₁} {Γ₂} ⌊Γ₁⌋≡⌊Γ₂⌋ (var x)
with lookup Γ₁ x | lookup Γ₂ x | ⌊⌋≡⌊⌋-lookup Γ₁ Γ₂ x ⌊Γ₁⌋≡⌊Γ₂⌋
≈-nf ⌊Γ₁⌋≡⌊Γ₂⌋ (var x) | kd k₁ | kd k₂ | ⌊kd-k₁⌋≡⌊kd-k₂⌋ =
≈-η-exp (kd-inj′ ⌊kd-k₁⌋≡⌊kd-k₂⌋) (≈-var∙ x)
≈-nf ⌊Γ₁⌋≡⌊Γ₂⌋ (var x) | kd _ | tp _ | ()
≈-nf ⌊Γ₁⌋≡⌊Γ₂⌋ (var x) | tp _ | kd _ | ()
≈-nf ⌊Γ₁⌋≡⌊Γ₂⌋ (var x) | tp a₁ | tp a₂ | refl = ≈-var∙ x
≈-nf ⌊Γ₁⌋≡⌊Γ₂⌋ ⊥ = ≈-⊥∙
≈-nf ⌊Γ₁⌋≡⌊Γ₂⌋ ⊤ = ≈-⊤∙
≈-nf ⌊Γ₁⌋≡⌊Γ₂⌋ (Π k a) =
let k≋k′ = ≋-nfKind ⌊Γ₁⌋≡⌊Γ₂⌋ k
in ≈-∀∙ k≋k′ (≈-nf (cong₂ _∷_ (cong kd (≋-⌊⌋ k≋k′)) ⌊Γ₁⌋≡⌊Γ₂⌋) a)
≈-nf ⌊Γ₁⌋≡⌊Γ₂⌋ (a ⇒ b) = ≈-⇒∙ (≈-nf ⌊Γ₁⌋≡⌊Γ₂⌋ a) (≈-nf ⌊Γ₁⌋≡⌊Γ₂⌋ b)
≈-nf {_} {Γ₁} ⌊Γ₁⌋≡⌊Γ₂⌋ (Λ k a) =
let k≋k′ = ≋-nfKind ⌊Γ₁⌋≡⌊Γ₂⌋ k
in ≈-Λ∙ (≋-⌊⌋ k≋k′) (≈-nf (cong₂ _∷_ (cong kd (≋-⌊⌋ k≋k′)) ⌊Γ₁⌋≡⌊Γ₂⌋) a)
≈-nf ⌊Γ₁⌋≡⌊Γ₂⌋ (ƛ a b) = ≈-λ∙ (≈-refl ⌜ b ⌝)
≈-nf {_} {Γ₁} {Γ₂} ⌊Γ₁⌋≡⌊Γ₂⌋ (a · b) =
≈-↓⌜·⌝ (≈-nf ⌊Γ₁⌋≡⌊Γ₂⌋ a) (≈-nf ⌊Γ₁⌋≡⌊Γ₂⌋ b)
≈-nf ⌊Γ₁⌋≡⌊Γ₂⌋ (a ⊡ b) = ≈-⊡∙ (≈-refl ⌜ a ⌝) (≈-refl ⌜ b ⌝)
≋-nfKind : ∀ {n} {Γ₁ Γ₂ : Ctx n} →
⌊ Γ₁ ⌋Ctx ≡ ⌊ Γ₂ ⌋Ctx → ∀ k → nfKind Γ₁ k ≋ nfKind Γ₂ k
≋-nfKind ⌊Γ₁⌋≡⌊Γ₂⌋ (a ⋯ b) = ≋-⋯ (≈-nf ⌊Γ₁⌋≡⌊Γ₂⌋ a) (≈-nf ⌊Γ₁⌋≡⌊Γ₂⌋ b)
≋-nfKind ⌊Γ₁⌋≡⌊Γ₂⌋ (Π j k) =
let j≋j′ = ≋-nfKind ⌊Γ₁⌋≡⌊Γ₂⌋ j
in ≋-Π j≋j′ (≋-nfKind (cong₂ _∷_ (cong kd (≋-⌊⌋ j≋j′)) ⌊Γ₁⌋≡⌊Γ₂⌋) k)
| {
"alphanum_fraction": 0.4495502985,
"avg_line_length": 37.3229901269,
"ext": "agda",
"hexsha": "1699feb038944cd93c586dc792d19f677c54938a",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2021-05-14T10:25:05.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-05-13T22:29:48.000Z",
"max_forks_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Blaisorblade/f-omega-int-agda",
"max_forks_repo_path": "src/FOmegaInt/Syntax/WeakEquality.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f",
"max_issues_repo_issues_event_max_datetime": "2021-05-14T08:54:39.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-05-14T08:09:40.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Blaisorblade/f-omega-int-agda",
"max_issues_repo_path": "src/FOmegaInt/Syntax/WeakEquality.agda",
"max_line_length": 80,
"max_stars_count": 12,
"max_stars_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Blaisorblade/f-omega-int-agda",
"max_stars_repo_path": "src/FOmegaInt/Syntax/WeakEquality.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-27T05:53:06.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-06-13T16:05:35.000Z",
"num_tokens": 15873,
"size": 26462
} |
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2020 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.Prelude
open import Level using (0ℓ)
-- This module incldes various Agda lemmas that are independent of the project's domain
module LibraBFT.Lemmas where
cong₃ : ∀{a b c d}{A : Set a}{B : Set b}{C : Set c}{D : Set d}
→ (f : A → B → C → D) → ∀{x y u v m n} → x ≡ y → u ≡ v → m ≡ n
→ f x u m ≡ f y v n
cong₃ f refl refl refl = refl
≡-pi : ∀{a}{A : Set a}{x y : A}(p q : x ≡ y) → p ≡ q
≡-pi refl refl = refl
Unit-pi : {u1 u2 : Unit}
→ u1 ≡ u2
Unit-pi {unit} {unit} = refl
++-inj : ∀{a}{A : Set a}{m n o p : List A}
→ length m ≡ length n → m ++ o ≡ n ++ p
→ m ≡ n × o ≡ p
++-inj {m = []} {x ∷ n} () hip
++-inj {m = x ∷ m} {[]} () hip
++-inj {m = []} {[]} lhip hip
= refl , hip
++-inj {m = m ∷ ms} {n ∷ ns} lhip hip
with ++-inj {m = ms} {ns} (suc-injective lhip) (proj₂ (∷-injective hip))
...| (mn , op) rewrite proj₁ (∷-injective hip)
= cong (n ∷_) mn , op
++-abs : ∀{a}{A : Set a}{n : List A}(m : List A)
→ 1 ≤ length m → [] ≡ m ++ n → ⊥
++-abs [] ()
++-abs (x ∷ m) imp ()
data All-vec {ℓ} {A : Set ℓ} (P : A → Set ℓ) : ∀ {n} → Vec {ℓ} A n → Set (Level.suc ℓ) where
[] : All-vec P []
_∷_ : ∀ {x n} {xs : Vec A n} (px : P x) (pxs : All-vec P xs) → All-vec P (x ∷ xs)
≤-unstep : ∀{m n} → suc m ≤ n → m ≤ n
≤-unstep (s≤s ss) = ≤-step ss
≡⇒≤ : ∀{m n} → m ≡ n → m ≤ n
≡⇒≤ refl = ≤-refl
∈-cong : ∀{a b}{A : Set a}{B : Set b}{x : A}{l : List A}
→ (f : A → B) → x ∈ l → f x ∈ List-map f l
∈-cong f (here px) = here (cong f px)
∈-cong f (there hyp) = there (∈-cong f hyp)
All-self : ∀{a}{A : Set a}{xs : List A} → All (_∈ xs) xs
All-self = All-tabulate (λ x → x)
All-reduce⁺
: ∀{a b}{A : Set a}{B : Set b}{Q : A → Set}{P : B → Set}
→ { xs : List A }
→ (f : ∀{x} → Q x → B)
→ (∀{x} → (prf : Q x) → P (f prf))
→ (all : All Q xs)
→ All P (All-reduce f all)
All-reduce⁺ f hyp [] = []
All-reduce⁺ f hyp (ax ∷ axs) = (hyp ax) ∷ All-reduce⁺ f hyp axs
All-reduce⁻
: ∀{a b}{A : Set a}{B : Set b}
{Q : A → Set}
→ { xs : List A }
→ ∀ {vdq}
→ (f : ∀{x} → Q x → B)
→ (all : All Q xs)
→ vdq ∈ All-reduce f all
→ ∃[ v ] ∃[ v∈xs ] (vdq ≡ f {v} v∈xs)
All-reduce⁻ {Q = Q} {(h ∷ _)} {vdq} f (px ∷ pxs) (here refl) = h , px , refl
All-reduce⁻ {Q = Q} {(_ ∷ t)} {vdq} f (px ∷ pxs) (there vdq∈) = All-reduce⁻ {xs = t} f pxs vdq∈
List-index : ∀ {A : Set} → (_≟A_ : (a₁ a₂ : A) → Dec (a₁ ≡ a₂)) → A → (l : List A) → Maybe (Fin (length l))
List-index _≟A_ x l with break (_≟A x) l
...| not≡ , _ with length not≡ <? length l
...| no _ = nothing
...| yes found = just ( fromℕ< {length not≡} {length l} found)
nats : ℕ → List ℕ
nats 0 = []
nats (suc n) = (nats n) ++ (n ∷ [])
_ : nats 4 ≡ 0 ∷ 1 ∷ 2 ∷ 3 ∷ []
_ = refl
_ : Maybe-map toℕ (List-index _≟_ 2 (nats 4)) ≡ just 2
_ = refl
_ : Maybe-map toℕ (List-index _≟_ 4 (nats 4)) ≡ nothing
_ = refl
allDistinct : ∀ {A : Set} → List A → Set
allDistinct l = ∀ (i j : Σ ℕ (_< length l)) →
proj₁ i ≡ proj₁ j
⊎ List-lookup l (fromℕ< (proj₂ i)) ≢ List-lookup l (fromℕ< (proj₂ j))
postulate -- TODO-1: currently unused; prove it, if needed
allDistinct? : ∀ {A : Set} → {≟A : (a₁ a₂ : A) → Dec (a₁ ≡ a₂)} → (l : List A) → Dec (allDistinct l)
-- Extends an arbitrary relation to work on the head of
-- the supplied list, if any.
data OnHead {A : Set}(P : A → A → Set) (x : A) : List A → Set where
[] : OnHead P x []
on-∷ : ∀{y ys} → P x y → OnHead P x (y ∷ ys)
-- Establishes that a list is sorted according to the supplied
-- relation.
data IsSorted {A : Set}(_<_ : A → A → Set) : List A → Set where
[] : IsSorted _<_ []
_∷_ : ∀{x xs} → OnHead _<_ x xs → IsSorted _<_ xs → IsSorted _<_ (x ∷ xs)
OnHead-prop : ∀{A}(P : A → A → Set)(x : A)(l : List A)
→ Irrelevant P
→ isPropositional (OnHead P x l)
OnHead-prop P x [] hyp [] [] = refl
OnHead-prop P x (x₁ ∷ l) hyp (on-∷ x₂) (on-∷ x₃) = cong on-∷ (hyp x₂ x₃)
IsSorted-prop : ∀{A}(_<_ : A → A → Set)(l : List A)
→ Irrelevant _<_
→ isPropositional (IsSorted _<_ l)
IsSorted-prop _<_ [] hyp [] [] = refl
IsSorted-prop _<_ (x ∷ l) hyp (x₁ ∷ a) (x₂ ∷ b)
= cong₂ _∷_ (OnHead-prop _<_ x l hyp x₁ x₂)
(IsSorted-prop _<_ l hyp a b)
IsSorted-map⁻ : {A : Set}{_≤_ : A → A → Set}
→ {B : Set}(f : B → A)(l : List B)
→ IsSorted (λ x y → f x ≤ f y) l
→ IsSorted _≤_ (List-map f l)
IsSorted-map⁻ f .[] [] = []
IsSorted-map⁻ f .(_ ∷ []) (x ∷ []) = [] ∷ []
IsSorted-map⁻ f .(_ ∷ _ ∷ _) (on-∷ x ∷ (x₁ ∷ is)) = (on-∷ x) ∷ IsSorted-map⁻ f _ (x₁ ∷ is)
-- TODO-1 : Better name and/or replace with library property
Any-sym : ∀ {a b}{A : Set a}{B : Set b}{tgt : B}{l : List A}{f : A → B}
→ Any (λ x → tgt ≡ f x) l
→ Any (λ x → f x ≡ tgt) l
Any-sym (here x) = here (sym x)
Any-sym (there x) = there (Any-sym x)
Any-lookup-correct : ∀ {a b}{A : Set a}{B : Set b}{tgt : B}{l : List A}{f : A → B}
→ (p : Any (λ x → f x ≡ tgt) l)
→ Any-lookup p ∈ l
Any-lookup-correct (here px) = here refl
Any-lookup-correct (there p) = there (Any-lookup-correct p)
Any-lookup-correctP : ∀ {a}{A : Set a}{l : List A}{P : A → Set}
→ (p : Any P l)
→ Any-lookup p ∈ l
Any-lookup-correctP (here px) = here refl
Any-lookup-correctP (there p) = there (Any-lookup-correctP p)
Any-witness : ∀ {a b} {A : Set a} {l : List A} {P : A → Set b}
→ (p : Any P l) → P (Any-lookup p)
Any-witness (here px) = px
Any-witness (there x) = Any-witness x
-- TODO-1: there is probably a library property for this.
∈⇒Any : ∀ {A : Set}{x : A}
→ {xs : List A}
→ x ∈ xs
→ Any (_≡ x) xs
∈⇒Any {x = x} (here refl) = here refl
∈⇒Any {x = x} {h ∷ t} (there xxxx) = there (∈⇒Any {xs = t} xxxx)
false≢true : false ≢ true
false≢true ()
witness : {A : Set}{P : A → Set}{x : A}{xs : List A}
→ x ∈ xs → All P xs → P x
witness x y = All-lookup y x
maybe-⊥ : ∀{a}{A : Set a}{x : A}{y : Maybe A}
→ y ≡ just x
→ y ≡ nothing
→ ⊥
maybe-⊥ () refl
Maybe-map-cool : ∀ {S S₁ : Set} {f : S → S₁} {x : Maybe S} {z}
→ Maybe-map f x ≡ just z
→ x ≢ nothing
Maybe-map-cool {x = nothing} ()
Maybe-map-cool {x = just y} prf = λ x → ⊥-elim (maybe-⊥ (sym x) refl)
Maybe-map-cool-1 : ∀ {S S₁ : Set} {f : S → S₁} {x : Maybe S} {z}
→ Maybe-map f x ≡ just z
→ Σ S (λ x' → f x' ≡ z)
Maybe-map-cool-1 {x = nothing} ()
Maybe-map-cool-1 {x = just y} {z = z} refl = y , refl
Maybe-map-cool-2 : ∀ {S S₁ : Set} {f : S → S₁} {x : S} {z}
→ f x ≡ z
→ Maybe-map f (just x) ≡ just z
Maybe-map-cool-2 {S}{S₁}{f}{x}{z} prf rewrite prf = refl
T⇒true : ∀ {a : Bool} → T a → a ≡ true
T⇒true {true} _ = refl
isJust : ∀ {A : Set}{aMB : Maybe A}{a : A}
→ aMB ≡ just a
→ Is-just aMB
isJust refl = just tt
to-witness-isJust-≡ : ∀ {A : Set}{aMB : Maybe A}{a prf}
→ to-witness (isJust {aMB = aMB} {a} prf) ≡ a
to-witness-isJust-≡ {aMB = just a'} {a} {prf}
with to-witness-lemma (isJust {aMB = just a'} {a} prf) refl
...| xxx = just-injective (trans (sym xxx) prf)
| {
"alphanum_fraction": 0.4833311544,
"avg_line_length": 34.7681818182,
"ext": "agda",
"hexsha": "2b1ddddab0e68f53653caa124f77cf00cba671e2",
"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": "b7dd98dd90d98fbb934ef8cb4f3314940986790d",
"max_forks_repo_licenses": [
"UPL-1.0"
],
"max_forks_repo_name": "lisandrasilva/bft-consensus-agda-1",
"max_forks_repo_path": "LibraBFT/Lemmas.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b7dd98dd90d98fbb934ef8cb4f3314940986790d",
"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": "lisandrasilva/bft-consensus-agda-1",
"max_issues_repo_path": "LibraBFT/Lemmas.agda",
"max_line_length": 111,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "b7dd98dd90d98fbb934ef8cb4f3314940986790d",
"max_stars_repo_licenses": [
"UPL-1.0"
],
"max_stars_repo_name": "lisandrasilva/bft-consensus-agda-1",
"max_stars_repo_path": "LibraBFT/Lemmas.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3128,
"size": 7649
} |
-- {-# OPTIONS --verbose tc.records.ifs:15 #-}
-- {-# OPTIONS --verbose tc.rec.proj:15 #-}
-- {-# OPTIONS --verbose tc.rec:15 #-}
-- {-# OPTIONS --verbose tc.constr.findInScope:15 #-}
-- {-# OPTIONS --verbose tc.term.args.ifs:15 #-}
-- {-# OPTIONS --verbose tc.section.apply:15 #-}
-- {-# OPTIONS --verbose tc.mod.apply:15 #-}
module 02-classes-indep where
data T : Set where
tt : T
data Bool : Set where
true : Bool
false : Bool
module testMod (a : Bool) where
testModEntry : Bool
testModEntry = a
record Monoid (t : Set) : Set where
field
zeroT : t
plusT : t → t → t
test : Bool
test = false
or : Bool → Bool → Bool
or true _ = true
or _ true = true
or false false = false
aT : Monoid T
aT = record { zeroT = tt; plusT = λ _ _ → tt }
testMonoid : {t : Set} → {{tM : Monoid t}} → t → t
testMonoid {{tM}} t = let open Monoid tM in plusT t zeroT
aBool : Monoid Bool
aBool = record { zeroT = false; plusT = or }
test : Bool
test = testMonoid false
open Monoid {{...}}
test2 : {t : Set} → {{tM : Monoid t}} → t
test2 = zeroT
test3 : T
test3 = zeroT
test4 : Bool
test4 = zeroT
⋯ : {A : Set} → {{v : A}} → A
⋯ {{v}} = v
test5 : Bool
test5 = Monoid.zeroT ⋯
| {
"alphanum_fraction": 0.5954773869,
"avg_line_length": 19.2580645161,
"ext": "agda",
"hexsha": "7ea1527b4b6c9a604f17259fa934c361295178e0",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/agda-kanso",
"max_forks_repo_path": "examples/instance-arguments/02-classes-indep.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/agda-kanso",
"max_issues_repo_path": "examples/instance-arguments/02-classes-indep.agda",
"max_line_length": 57,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "examples/instance-arguments/02-classes-indep.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 417,
"size": 1194
} |
{-# OPTIONS --cubical --safe #-}
module Data.Bits.Strict where
open import Data.Bits
open import Prelude
infixr 8 0∷!_ 1∷!_
0∷!_ : Bits → Bits
0∷!_ = λ! xs →! 0∷ xs
{-# INLINE 0∷!_ #-}
1∷!_ : Bits → Bits
1∷!_ = λ! xs →! 1∷ xs
{-# INLINE 1∷!_ #-}
0∷!≡0∷ : ∀ xs → 0∷! xs ≡ 0∷ xs
0∷!≡0∷ = $!-≡ 0∷_
1∷!≡1∷ : ∀ xs → 1∷! xs ≡ 1∷ xs
1∷!≡1∷ = $!-≡ 1∷_
| {
"alphanum_fraction": 0.4828571429,
"avg_line_length": 15.9090909091,
"ext": "agda",
"hexsha": "7882e0fddeac3986cc75b24e7010b7f5dff40147",
"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/Strict.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/Strict.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/Bits/Strict.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": 209,
"size": 350
} |
{-# OPTIONS --without-K #-}
module CauchyProofsT where
-- Proofs about permutations defined in module Cauchy (multiplicative)
open import Level using (Level; _⊔_) renaming (zero to lzero; suc to lsuc)
open import Relation.Binary.PropositionalEquality
using (_≡_; refl; sym; trans; subst; subst₂; cong; cong₂; setoid;
proof-irrelevance; module ≡-Reasoning)
open import Relation.Binary.PropositionalEquality.TrustMe
using (trustMe)
open import Relation.Nullary using (Dec; yes; no; ¬_)
open import Data.Nat.Properties
using (m≤m+n; n≤m+n; n≤1+n; cancel-*-right-≤; ≰⇒>; ¬i+1+j≤i)
open import Data.Nat.Properties.Simple
using (+-right-identity; +-suc; +-assoc; +-comm;
*-assoc; *-comm; *-right-zero; distribʳ-*-+; +-*-suc)
open import Data.Nat.DivMod using (DivMod; result; _divMod_; _div_; _mod_)
open import Relation.Binary using (Rel; Decidable; Setoid)
open import Relation.Binary.Core using (Transitive)
open import Data.String using (String)
renaming (_++_ to _++S_)
open import Data.Nat.Show using (show)
open import Data.Bool using (Bool; false; true)
open import Data.Nat using (ℕ; suc; _+_; _∸_; _*_; _<_; _≮_; _≤_; _≰_;
_≥_; z≤n; s≤s; _≟_; _≤?_; ≤-pred; module ≤-Reasoning)
open import Data.Fin
using (Fin; zero; suc; toℕ; fromℕ; fromℕ≤; _ℕ-_; _≺_; reduce≥;
raise; inject+; inject₁; inject≤; _≻toℕ_)
renaming (_+_ to _F+_)
open import Data.Fin.Properties
using (bounded; inject+-lemma; to-from; toℕ-injective; inject≤-lemma; toℕ-fromℕ≤)
open import Data.Vec.Properties
using (lookup∘tabulate; tabulate∘lookup; lookup-allFin; tabulate-∘;
tabulate-allFin; allFin-map; lookup-++-inject+; lookup-++-≥)
open import Data.Product using (Σ)
open import Data.List
using (List; []; _∷_; _∷ʳ_; foldl; replicate; reverse; downFrom;
concatMap; gfilter; initLast; InitLast; _∷ʳ'_)
renaming (_++_ to _++L_; map to mapL; concat to concatL; zip to zipL)
open import Data.List.NonEmpty
using (List⁺; [_]; _∷⁺_; head; last; _⁺++_)
renaming (toList to nonEmptyListtoList; _∷ʳ_ to _n∷ʳ_; tail to ntail)
open import Data.List.Any using (Any; here; there; any; module Membership)
open import Data.Maybe using (Maybe; nothing; just; maybe′)
open import Data.Vec
using (Vec; tabulate; []; _∷_; tail; lookup; zip; zipWith; splitAt;
_[_]≔_; allFin; toList)
renaming (_++_ to _++V_; map to mapV; concat to concatV)
open import Function using (id; _∘_; _$_; _∋_)
open import Data.Empty using (⊥; ⊥-elim)
open import Data.Unit using (⊤; tt)
open import Data.Sum using (_⊎_; inj₁; inj₂)
open import Data.Product using (_×_; _,_; proj₁; proj₂)
open import Proofs
open import Cauchy
open import Perm
open import CauchyProofs
------------------------------------------------------------------------------
-- Proofs about multiplicative permutations
concat-nil : ∀ {m} →
concatV (tabulate {m} (λ b → [])) ≡ subst Cauchy (sym (*-right-zero m)) []
concat-nil {0} = refl
concat-nil {suc m} = concat-nil {m}
empty-vec : ∀ {m} → (eq : m ≡ 0) → allFin m ≡ subst Cauchy (sym eq) []
empty-vec {0} refl = refl
empty-vec {suc m} ()
inj-lemma' : (m n : ℕ) (d : Fin n) (leq : suc (toℕ d) ≤ n + m) →
inject+ m d ≡ inject≤ (fromℕ (toℕ d)) leq
inj-lemma' m 0 () _
inj-lemma' m (suc n) zero (s≤s _) = refl
inj-lemma' m (suc n) (suc d) (s≤s leq) = cong suc (inj-lemma' m n d leq)
inj-lemma : (m n : ℕ) (d : Fin n) (leq : suc (toℕ d) ≤ suc m * n) →
inject+ (m * n) d ≡ inject≤ (fromℕ (toℕ d)) leq
inj-lemma m 0 () _
inj-lemma m (suc n) zero (s≤s _) = refl
inj-lemma m (suc n) (suc d) (s≤s leq) = cong suc (inj-lemma' (m * suc n) n d leq)
map-f≡g : {B : Set} (n : ℕ) (f g : Fin n → B) → (∀ i → f i ≡ g i) →
mapV f (allFin n) ≡ mapV g (allFin n)
map-f≡g n f g eq =
begin (mapV f (tabulate id)
≡⟨ sym (tabulate-∘ f id) ⟩
tabulate f
≡⟨ finext eq ⟩
tabulate g
≡⟨ tabulate-∘ g id ⟩
mapV g (tabulate id) ∎)
where open ≡-Reasoning
map-inj-lemma : (m n : ℕ) →
(mapV (inject+ (m * n)) (allFin n)) ≡
(mapV
(λ d → inject≤
(fromℕ (toℕ d))
(i*n+k≤m*n {suc m} {n} zero d))
(allFin n))
map-inj-lemma m n =
map-f≡g n (inject+ (m * n))
(λ d → inject≤ (fromℕ (toℕ d)) (i*n+k≤m*n {suc m} zero d))
(λ d → inj-lemma m n d (i*n+k≤m*n {suc m} zero d))
map-raise-suc : (m n : ℕ) (j : Fin (suc m)) →
mapV (λ d → raise (suc n)
(inject≤
(fromℕ (toℕ j * suc n + toℕ d))
(i*n+k≤m*n j d)))
(idcauchy (suc n)) ≡
mapV (λ d → inject≤
(fromℕ (toℕ (suc j) * suc n + toℕ d))
(i*n+k≤m*n (suc j) d))
(idcauchy (suc n))
map-raise-suc m n j = map-f≡g (suc n)
(λ d → raise (suc n)
(inject≤
(fromℕ (toℕ j * suc n + toℕ d))
(i*n+k≤m*n j d)))
(λ d → inject≤
(fromℕ (toℕ (suc j) * suc n + toℕ d))
(i*n+k≤m*n (suc j) d))
( (λ d → raise-suc m n j d (i*n+k≤m*n j d) (i*n+k≤m*n (suc j) d)))
-- what should this be named?
lemma3 : (n m : ℕ) → (j : Fin m) →
mapV (raise (suc n))
(mapV (λ d → inject≤
(fromℕ (toℕ j * suc n + toℕ d))
(i*n+k≤m*n j d))
(idcauchy (suc n)))
≡
mapV (λ d → inject≤
(fromℕ (toℕ (suc j) * suc n + toℕ d))
(i*n+k≤m*n (suc j) d))
(idcauchy (suc n))
lemma3 n 0 ()
lemma3 n (suc m) j =
begin (
_
≡⟨ sym (map-∘ (raise (suc n)) (λ d → inject≤
(fromℕ (toℕ j * suc n + toℕ d))
(i*n+k≤m*n j d)) (idcauchy (suc n))) ⟩
mapV (λ d → raise (suc n) (inject≤
(fromℕ (toℕ j * suc n + toℕ d))
(i*n+k≤m*n j d))) (idcauchy (suc n))
≡⟨ map-raise-suc m n j ⟩
_ ∎)
where open ≡-Reasoning
map-raise-lemma : (m n : ℕ) →
mapV
(λ b → mapV
(raise (suc n))
(mapV
(λ d → inject≤
(fromℕ (toℕ b * suc n + toℕ d))
(i*n+k≤m*n b d))
(idcauchy (suc n))))
(idcauchy m) ≡
mapV
(λ b → mapV
(λ d → inject≤
(fromℕ (toℕ b * suc n + toℕ d))
(i*n+k≤m*n b d))
(idcauchy (suc n)))
(tabulate {m} suc)
map-raise-lemma 0 n = refl
map-raise-lemma (suc m) n =
begin (
mapV (λ b → mapV (raise (suc n))
(mapV
(λ d → inject≤
(fromℕ (toℕ b * suc n + toℕ d))
(i*n+k≤m*n b d))
(idcauchy (suc n))))
(idcauchy (suc m))
≡⟨ sym (tabulate-∘ _ id) ⟩
tabulate {suc m} (λ b → mapV (raise (suc n))
(mapV
(λ d → inject≤
(fromℕ (toℕ b * suc n + toℕ d))
(i*n+k≤m*n b d))
(idcauchy (suc n))))
≡⟨ finext (lemma3 n (suc m)) ⟩
tabulate {suc m} ((λ b → mapV
(λ d → inject≤
(fromℕ (toℕ b * suc n + toℕ d))
(i*n+k≤m*n b d))
(idcauchy (suc n))) ∘ suc)
≡⟨ tabulate-∘ _ suc ⟩
mapV (λ b → mapV
(λ d → inject≤
(fromℕ (toℕ b * suc n + toℕ d))
(i*n+k≤m*n b d))
(idcauchy (suc n)))
(tabulate {suc m} suc) ∎)
where open ≡-Reasoning
allFin* : (m n : ℕ) → allFin (m * n) ≡
concatV
(mapV
(λ b →
mapV
(λ d → inject≤ (fromℕ (toℕ b * n + toℕ d)) (i*n+k≤m*n b d))
(idcauchy n))
(idcauchy m))
allFin* 0 _ = refl
allFin* (suc m) 0 =
begin (allFin (suc m * 0)
≡⟨ empty-vec {suc m * 0} (*-right-zero (suc m)) ⟩
subst Cauchy (sym (*-right-zero (suc m))) []
≡⟨ sym (concat-nil {suc m}) ⟩
concatV (tabulate {suc m} (λ b → []))
≡⟨ cong concatV (tabulate-allFin {suc m} (λ b → [])) ⟩
concatV (mapV (λ b → []) (idcauchy (suc m))) ∎)
where open ≡-Reasoning
allFin* (suc m) (suc n) =
begin (allFin (suc n + m * suc n)
≡⟨ allFin+ (suc n) (m * suc n) ⟩
mapV (inject+ (m * suc n)) (allFin (suc n)) ++V
mapV (raise (suc n)) (allFin (m * suc n))
≡⟨ cong
(λ x →
mapV (inject+ (m * suc n)) (allFin (suc n)) ++V
mapV (raise (suc n)) x)
(allFin* m (suc n)) ⟩
mapV (inject+ (m * suc n)) (allFin (suc n)) ++V
mapV
(raise (suc n))
(concatV
(mapV
(λ b →
mapV
(λ d → inject≤
(fromℕ (toℕ b * suc n + toℕ d))
(i*n+k≤m*n b d))
(idcauchy (suc n)))
(idcauchy m)))
≡⟨ cong
(_++V_ (mapV (inject+ (m * suc n)) (allFin (suc n))))
(sym (concat-map
(mapV
(λ b →
mapV
(λ d → inject≤
(fromℕ (toℕ b * suc n + toℕ d))
(i*n+k≤m*n b d))
(idcauchy (suc n)))
(idcauchy m))
(raise (suc n)))) ⟩
mapV (inject+ (m * suc n)) (allFin (suc n)) ++V
concatV
(mapV
(mapV (raise (suc n)))
(mapV
(λ b →
mapV
(λ d → inject≤
(fromℕ (toℕ b * suc n + toℕ d))
(i*n+k≤m*n b d))
(idcauchy (suc n)))
(idcauchy m)))
≡⟨ refl ⟩
concatV
(mapV (inject+ (m * suc n)) (allFin (suc n)) ∷
mapV
(mapV (raise (suc n)))
(mapV
(λ b →
mapV
(λ d → inject≤
(fromℕ (toℕ b * suc n + toℕ d))
(i*n+k≤m*n b d))
(idcauchy (suc n)))
(idcauchy m)))
≡⟨ cong
(λ x →
concatV
((mapV (inject+ (m * suc n)) (allFin (suc n))) ∷ x))
(sym (map-∘
(mapV (raise (suc n)))
(λ b →
mapV
(λ d → inject≤
(fromℕ (toℕ b * suc n + toℕ d))
(i*n+k≤m*n b d))
(idcauchy (suc n)))
(idcauchy m))) ⟩
concatV
(mapV (inject+ (m * suc n)) (allFin (suc n)) ∷
mapV
(λ b → mapV
(raise (suc n))
(mapV
(λ d → inject≤
(fromℕ (toℕ b * suc n + toℕ d))
(i*n+k≤m*n b d))
(idcauchy (suc n))))
(idcauchy m))
≡⟨ cong
(λ x →
concatV
(x ∷
mapV
(λ b →
mapV
(raise (suc n))
(mapV
(λ d → inject≤
(fromℕ (toℕ b * suc n + toℕ d))
(i*n+k≤m*n b d))
(idcauchy (suc n))))
(idcauchy m)))
(map-inj-lemma m (suc n)) ⟩
concatV
(mapV
(λ d → inject≤
(fromℕ (toℕ d))
(i*n+k≤m*n {suc m} {suc n} zero d))
(idcauchy (suc n)) ∷
(mapV
(λ b → mapV
(raise (suc n))
(mapV
(λ d → inject≤
(fromℕ (toℕ b * suc n + toℕ d))
(i*n+k≤m*n b d))
(idcauchy (suc n))))
(idcauchy m)))
≡⟨ cong
(λ x →
concatV
(mapV
(λ d → inject≤
(fromℕ (toℕ d))
(i*n+k≤m*n {suc m} {suc n} zero d))
(idcauchy (suc n)) ∷
x))
(map-raise-lemma m n) ⟩
concatV
(mapV
(λ d → inject≤
(fromℕ (toℕ d))
(i*n+k≤m*n {suc m} {suc n} zero d))
(idcauchy (suc n)) ∷
(mapV
(λ b → mapV
(λ d → inject≤
(fromℕ (toℕ b * suc n + toℕ d))
(i*n+k≤m*n b d))
(idcauchy (suc n)))
(tabulate {m} suc)))
≡⟨ refl ⟩
concatV
(mapV
(λ b →
mapV
(λ d → inject≤
(fromℕ (toℕ b * suc n + toℕ d))
(i*n+k≤m*n b d))
(idcauchy (suc n)))
(idcauchy (suc m))) ∎)
where open ≡-Reasoning
tcomp-id : ∀ {m n} → tcompcauchy (idcauchy m) (idcauchy n) ≡ idcauchy (m * n)
tcomp-id {m} {n} = sym (allFin* m n)
-- Behaviour of parallel multiplicative composition wrt sequential
absurd : (m n q : ℕ) (r : Fin (suc n)) (k : Fin (suc (n + m * suc n)))
(k≡r+q*sn : toℕ k ≡ toℕ r + q * suc n) (p : suc m ≤ q) → ⊥
absurd m n q r k k≡r+q*sn p = ¬i+1+j≤i (toℕ k) {toℕ r} k≥k+sr
where k≥k+sr : toℕ k ≥ toℕ k + suc (toℕ r)
k≥k+sr =
begin (toℕ k + suc (toℕ r)
≡⟨ +-suc (toℕ k) (toℕ r) ⟩
suc (toℕ k) + toℕ r
≤⟨ cong+r≤ (bounded k) (toℕ r) ⟩
(suc n + m * suc n) + toℕ r
≡⟨ +-comm (suc n + m * suc n) (toℕ r) ⟩
toℕ r + (suc n + m * suc n)
≡⟨ refl ⟩
toℕ r + suc m * suc n
≤⟨ cong+l≤ (cong*r≤ p (suc n)) (toℕ r) ⟩
toℕ r + q * suc n
≡⟨ sym k≡r+q*sn ⟩
toℕ k ∎)
where open ≤-Reasoning
concat-tabulate-[] : ∀ {m n} {f : Fin m → Fin n} →
concatV (tabulate {m} ((λ x → []) ∘ f)) ≡
subst (λ n → Vec (Fin (m * 0)) n) (sym (*-right-zero m)) []
concat-tabulate-[] {0} = refl
concat-tabulate-[] {suc m} {_} {f} = concat-tabulate-[] {m} {_} {f ∘ suc}
tabulate-⊥ : ∀ {m n} {g : Fin (m * 0) → Fin n} →
tabulate g ≡ subst (Vec (Fin n)) (sym (*-right-zero m)) []
tabulate-⊥ {0} = refl
tabulate-⊥ {suc m}{_} {g} = tabulate-⊥ {m}
toℕ-inject+ : ∀ {n k} → (i : Fin n) → toℕ (inject+ k i) ≡ toℕ i
toℕ-inject+ {0} ()
toℕ-inject+ {suc n} zero = refl
toℕ-inject+ {suc n} (suc i) = cong suc (toℕ-inject+ i)
q≡ : (m : ℕ) (q : ℕ) (¬p : ¬ suc m ≤ q) →
q ≡ toℕ (fromℕ≤ (s≤s (≤-pred (≰⇒> ¬p))))
q≡ m q ¬p = sym (toℕ-fromℕ≤ (s≤s (≤-pred (≰⇒> ¬p))))
absurd2 : (n q : ℕ) (i : Fin (suc n)) (r : Fin (suc (suc n)))
(eq : suc (toℕ i) ≡ toℕ r + suc (suc (n + q * suc (suc n)))) → ⊥
absurd2 n q i r eq = ¬i+1+j≤i (suc (toℕ i)) {toℕ r} leq
where leq' = begin (suc (toℕ i)
≤⟨ bounded i ⟩
suc n
≤⟨ m≤m+n (suc n) (q * suc (suc n)) ⟩
suc (n + q * suc (suc n)) ∎)
where open ≤-Reasoning
leq = begin (suc (toℕ i) + suc (toℕ r)
≡⟨ +-suc (suc (toℕ i)) (toℕ r) ⟩
suc (suc (toℕ i)) + toℕ r
≡⟨ +-comm (suc (suc (toℕ i))) (toℕ r) ⟩
toℕ r + suc (suc (toℕ i))
≤⟨ cong+l≤ (s≤s leq') (toℕ r) ⟩
toℕ r + suc (suc (n + q * suc (suc n)))
≡⟨ sym eq ⟩
suc (toℕ i) ∎)
where open ≤-Reasoning
small-quotient : (n q : ℕ) → (i : Fin n) → (r : Fin (suc n)) →
(eq₁ : suc (toℕ i) ≡ toℕ r + q * suc n) → (q ≡ 0) × (toℕ r ≡ suc (toℕ i))
small-quotient 0 _ () _ _
small-quotient (suc n) 0 i r eq = (refl , sym (trans eq (+-right-identity (toℕ r))))
small-quotient (suc n) (suc q) i r eq = ⊥-elim (absurd2 n q i r eq)
first-row :
(m n : ℕ) → (f : Fin (suc m) × Fin (suc n) → Fin ((suc m) * (suc n))) →
tabulate {suc n} (λ x → f (zero , x)) ≡
tabulate {suc n} ((λ k → f (fin-project (suc m) (suc n) k)) ∘ inject+ (m * suc n))
first-row m n f =
finext pf
where
pf : (i : Fin (suc n)) → f (zero , i) ≡
f (fin-project (suc m) (suc n) (inject+ (m * suc n) i))
pf zero = refl
pf (suc i) with suc (toℕ (inject+ (m * suc n) i)) divMod suc n
pf (suc i) | result q r property with suc m ≤? q
pf (suc i) | result q r property | yes p =
⊥-elim (absurd m n q r (suc (inject+ (m * suc n) i)) property p)
pf (suc i) | result q r property | no ¬p =
cong f (cong₂ _,_ (toℕ-injective (sym a₁)) a₂)
where
q≡f₁ : q ≡ toℕ (fromℕ≤ (s≤s (≤-pred (≰⇒> ¬p))))
q≡f₁ = q≡ m q ¬p
si≡f₂ : _≡_ {A = ℕ} (suc (toℕ (inject+ (m * suc n) i))) (suc (toℕ i))
si≡f₂ = cong suc (toℕ-inject+ {k = m * suc n} i)
sq : (q ≡ 0) × (toℕ r ≡ suc (toℕ i))
sq = small-quotient n q i r (trans (sym si≡f₂) property)
a₁ : toℕ (fromℕ≤ (s≤s (≤-pred (≰⇒> ¬p)))) ≡ toℕ {suc q} zero
a₁ = trans (sym q≡f₁) (proj₁ sq)
a₂ : (suc i) ≡ r
a₂ = toℕ-injective (sym (proj₂ sq))
lookup-2d' : (m n : ℕ) (k : Fin (m * n))
(f : Fin m × Fin n → Fin (m * n)) →
lookup k (concatV (tabulate (λ i → tabulate (λ j → f (i , j)))))
≡ f (fin-project m n k)
lookup-2d' m n k f =
let fin-result b d dec dec' = fin-divMod m n k in
begin (lookup k (concatV (tabulate (λ i → tabulate (λ j → f (i , j)))))
≡⟨ cong (λ x → lookup k (concatV x))
(finext (λ i → tabulate-allFin (λ j → f (i , j)))) ⟩
lookup k (concatV (tabulate (λ i → mapV (λ j → f (i , j)) (allFin n))))
≡⟨ cong
(λ x → lookup k (concatV x))
(tabulate-allFin (λ i → mapV (λ j → f (i , j)) (allFin n))) ⟩
lookup k (concatV (mapV (λ i → mapV (λ j → f (i , j)) (allFin n)) (allFin m)))
≡⟨ lookup-2d m n k (allFin m) (allFin n) f ⟩
f (lookup b (allFin m) , lookup d (allFin n))
≡⟨ cong₂ (λ x y → f (x , y)) (lookup-allFin b) (lookup-allFin d) ⟩
f (b , d)
≡⟨ cong f (sym (inv' (fin-product-iso m n) (b , d))) ⟩
f (split (fin-product-iso m n) (combine (fin-product-iso m n) (b , d)))
≡⟨ refl ⟩
f (fin-project m n (combine (fin-product-iso m n) (b , d)))
≡⟨ cong
(λ x → f (fin-project m n x))
(sym dec') ⟩
f (fin-project m n k) ∎)
where open ≡-Reasoning
open Fin-Product-Iso
tabulate-concat : ∀ {m n} → (f : Fin m × Fin n → Fin (m * n)) →
concatV (tabulate {m} (λ i → tabulate {n} (λ j → f (i , j)))) ≡
tabulate {m * n} (λ (k : Fin (m * n)) → f (fin-project m n k))
tabulate-concat {m} {n} f =
begin (concatV (tabulate {m} (λ i → tabulate {n} (λ j → f (i , j))))
≡⟨ sym (tabulate∘lookup
(concatV (tabulate {m} (λ i → tabulate {n} (λ j → f (i , j)))))) ⟩
tabulate (λ i →
lookup i
(concatV (tabulate {m} (λ i → tabulate {n} (λ j → f (i , j))))))
≡⟨ finext (λ i → lookup-2d' m n i f) ⟩
tabulate {m * n} (λ (k : Fin (m * n)) → f (fin-project m n k)) ∎)
where open ≡-Reasoning
lookup-concat :
∀ {m n} → (k : Fin (m * n)) → (pm qm : Cauchy m) → (pn qn : Cauchy n) →
let vs = concatV
(mapV
(λ b →
mapV
(λ d → inject≤ (fromℕ (toℕ b * n + toℕ d)) (i*n+k≤m*n b d))
pn)
pm)
ws = concatV
(mapV
(λ b →
mapV
(λ d → inject≤ (fromℕ (toℕ b * n + toℕ d)) (i*n+k≤m*n b d))
qn)
qm)
in lookup (lookup k vs) ws
≡
let (b , d) = fin-project m n k
x = lookup (lookup b pm) qm
y = lookup (lookup d pn) qn
in inject≤ (fromℕ (toℕ x * n + toℕ y)) (i*n+k≤m*n x y)
lookup-concat {0} () pm qm pn qn
lookup-concat {suc m} {0} k pm qm [] [] =
⊥-elim (Fin0-⊥ (subst Fin (*-right-zero m) k))
lookup-concat {suc m} {suc n} zero (x ∷ pm) (x₁ ∷ qm) (x₂ ∷ pn) (x₃ ∷ qn) =
begin (lookup
(inject≤ (fromℕ (toℕ x * suc n + toℕ x₂)) (i*n+k≤m*n x x₂))
(concatV
(mapV
(λ b →
mapV
(λ d → inject≤ (fromℕ (toℕ b * suc n + toℕ d)) (i*n+k≤m*n b d))
(x₃ ∷ qn))
(x₁ ∷ qm)))
≡⟨ lookup-concat'
(suc m) (suc n) x x₂ (i*n+k≤m*n x x₂)
(λ {(b , d) → inject≤ (fromℕ (toℕ b * suc n + toℕ d)) (i*n+k≤m*n b d)})
(x₁ ∷ qm) (x₃ ∷ qn) ⟩
inject≤
(fromℕ (toℕ (lookup x (x₁ ∷ qm)) * suc n + toℕ (lookup x₂ (x₃ ∷ qn))))
(i*n+k≤m*n (lookup x (x₁ ∷ qm)) (lookup x₂ (x₃ ∷ qn)))
≡⟨ refl ⟩
let (b , d) = fin-project (suc m) (suc n) zero
x = lookup (lookup b (x ∷ pm)) (x₁ ∷ qm)
y = lookup (lookup d (x₂ ∷ pn)) (x₃ ∷ qn)
in inject≤ (fromℕ (toℕ x * suc n + toℕ y)) (i*n+k≤m*n x y) ∎)
where open ≡-Reasoning
lookup-concat {suc m} {suc n} (suc k) (x ∷ pm) (x₁ ∷ qm) (x₂ ∷ pn) (x₃ ∷ qn) =
begin (let vs = concatV
(mapV
(λ b →
mapV
(λ d →
inject≤ (fromℕ (toℕ b * suc n + toℕ d)) (i*n+k≤m*n b d))
(x₂ ∷ pn))
(x ∷ pm))
ws = concatV
(mapV
(λ b →
mapV
(λ d →
inject≤ (fromℕ (toℕ b * suc n + toℕ d)) (i*n+k≤m*n b d))
(x₃ ∷ qn))
(x₁ ∷ qm))
in lookup (lookup (suc k) vs) ws
≡⟨ cong (λ z →
lookup
(lookup z
(concatV
(mapV
(λ b →
mapV
(λ d →
inject≤ (fromℕ (toℕ b * suc n + toℕ d)) (i*n+k≤m*n b d))
(x₂ ∷ pn))
(x ∷ pm))))
(concatV
(mapV
(λ b →
mapV
(λ d →
inject≤ (fromℕ (toℕ b * suc n + toℕ d)) (i*n+k≤m*n b d))
(x₃ ∷ qn))
(x₁ ∷ qm))))
(fin-proj-lem (suc m) (suc n) (suc k)) ⟩
let (b' , d') = fin-project (suc m) (suc n) (suc k)
vs = concatV
(mapV
(λ b →
mapV
(λ d →
inject≤ (fromℕ (toℕ b * suc n + toℕ d)) (i*n+k≤m*n b d))
(x₂ ∷ pn))
(x ∷ pm))
ws = concatV
(mapV
(λ b →
mapV
(λ d →
inject≤ (fromℕ (toℕ b * suc n + toℕ d)) (i*n+k≤m*n b d))
(x₃ ∷ qn))
(x₁ ∷ qm))
in lookup
(lookup
(inject≤ (fromℕ (toℕ b' * (suc n) + toℕ d')) (i*n+k≤m*n b' d'))
vs)
ws
≡⟨ cong
(λ x → lookup x ws)
(lookup-concat' (suc m) (suc n) b' d' (i*n+k≤m*n b' d')
(λ {(b , d) → inject≤ (fromℕ (toℕ b * suc n + toℕ d)) (i*n+k≤m*n b d)})
(x ∷ pm) (x₂ ∷ pn)) ⟩
let (b' , d') = fin-project (suc m) (suc n) (suc k)
ws = concatV
(mapV
(λ b →
mapV
(λ d →
inject≤ (fromℕ (toℕ b * suc n + toℕ d)) (i*n+k≤m*n b d))
(x₃ ∷ qn))
(x₁ ∷ qm))
in lookup
(inject≤
(fromℕ (toℕ (lookup b' (x ∷ pm)) * suc n + toℕ (lookup d' (x₂ ∷ pn))))
(i*n+k≤m*n (lookup b' (x ∷ pm)) (lookup d' (x₂ ∷ pn))))
ws
≡⟨ lookup-concat' (suc m) (suc n) (lookup b' (x ∷ pm)) (lookup d' (x₂ ∷ pn))
(i*n+k≤m*n (lookup b' (x ∷ pm)) (lookup d' (x₂ ∷ pn)))
(λ {(b , d) → inject≤ (fromℕ (toℕ b * suc n + toℕ d)) (i*n+k≤m*n b d)})
(x₁ ∷ qm) (x₃ ∷ qn) ⟩
let (b , d) = fin-project (suc m) (suc n) (suc k)
r = lookup (lookup b (x ∷ pm)) (x₁ ∷ qm)
s = lookup (lookup d (x₂ ∷ pn)) (x₃ ∷ qn)
in inject≤
(fromℕ (toℕ r * suc n + toℕ s))
(i*n+k≤m*n r s) ∎)
where open ≡-Reasoning
tcomp-dist : ∀ {m n} → (pm qm : Cauchy m) → (pn qn : Cauchy n) →
scompcauchy (tcompcauchy pm pn) (tcompcauchy qm qn) ≡
tcompcauchy (scompcauchy pm qm) (scompcauchy pn qn)
tcomp-dist {m} {n} pm qm pn qn =
begin (scompcauchy (tcompcauchy pm pn) (tcompcauchy qm qn)
≡⟨ refl ⟩
tabulate {m * n} (λ k →
lookup
(lookup k (concatV
(mapV
(λ b →
mapV (λ d →
inject≤
(fromℕ (toℕ b * n + toℕ d))
(i*n+k≤m*n b d)) pn)
pm)))
(concatV
(mapV
(λ b →
mapV (λ d →
inject≤
(fromℕ (toℕ b * n + toℕ d))
(i*n+k≤m*n b d)) qn)
qm)))
≡⟨ finext (λ k → lookup-concat {m} {n} k pm qm pn qn) ⟩
tabulate {m * n}
(λ k →
let (i , j) = fin-project m n k
b = lookup (lookup i pm) qm
d = lookup (lookup j pn) qn in
inject≤ (fromℕ (toℕ b * n + toℕ d)) (i*n+k≤m*n b d))
≡⟨ sym (tabulate-concat
(λ {(i , j) →
let b = lookup (lookup i pm) qm
d = lookup (lookup j pn) qn in
inject≤ (fromℕ (toℕ b * n + toℕ d)) (i*n+k≤m*n b d)})) ⟩
concatV
(tabulate {m}
(λ i →
tabulate {n}
(λ j →
let b = lookup (lookup i pm) qm
d = lookup (lookup j pn) qn in
inject≤ (fromℕ (toℕ b * n + toℕ d)) (i*n+k≤m*n b d))))
≡⟨ cong concatV
(finext
(λ i →
tabulate-∘
(let b = lookup (lookup i pm) qm in
λ d →
inject≤ (fromℕ (toℕ b * n + toℕ d)) (i*n+k≤m*n b d))
(λ i → lookup (lookup i pn) qn))) ⟩
concatV
(tabulate {m}
(λ i →
let b = lookup (lookup i pm) qm in
mapV
(λ d → inject≤ (fromℕ (toℕ b * n + toℕ d)) (i*n+k≤m*n b d))
(tabulate (λ i → lookup (lookup i pn) qn))))
≡⟨ cong concatV (tabulate-∘
(λ b →
mapV
(λ d → inject≤ (fromℕ (toℕ b * n + toℕ d)) (i*n+k≤m*n b d))
(tabulate (λ i → lookup (lookup i pn) qn)))
(λ i → lookup (lookup i pm) qm)) ⟩
concatV
(mapV
(λ b →
mapV
(λ d → inject≤ (fromℕ (toℕ b * n + toℕ d)) (i*n+k≤m*n b d))
(tabulate (λ i → lookup (lookup i pn) qn)))
(tabulate (λ i → lookup (lookup i pm) qm)))
≡⟨ refl ⟩
tcompcauchy (scompcauchy pm qm) (scompcauchy pn qn) ∎)
where open ≡-Reasoning
------------------------------------------------------------------------------
| {
"alphanum_fraction": 0.3908353895,
"avg_line_length": 38.651226158,
"ext": "agda",
"hexsha": "69165fedb3d80d938a2ee0ab29cdd8892b4f3ce3",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z",
"max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "JacquesCarette/pi-dual",
"max_forks_repo_path": "Univalence/Obsolete/CauchyProofsT.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "JacquesCarette/pi-dual",
"max_issues_repo_path": "Univalence/Obsolete/CauchyProofsT.agda",
"max_line_length": 87,
"max_stars_count": 14,
"max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "JacquesCarette/pi-dual",
"max_stars_repo_path": "Univalence/Obsolete/CauchyProofsT.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": 10273,
"size": 28370
} |
-- Andreas, 2016-07-29 issue #707
-- {-# OPTIONS -v tc.ip:20 #-}
postulate A B : {!!}
-- Should not create two interaction points!
-- Also not two sort metas!
| {
"alphanum_fraction": 0.6296296296,
"avg_line_length": 18,
"ext": "agda",
"hexsha": "3a73540e832f6e31b2ed4ce8d99ca43889c255e4",
"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/Issue707.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/Issue707.agda",
"max_line_length": 44,
"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/Issue707.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": 48,
"size": 162
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Examples showing how the case expressions can be used with anonymous
-- pattern-matching lambda abstractions
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module README.Case where
open import Data.Fin hiding (pred)
open import Data.Maybe hiding (from-just)
open import Data.Nat hiding (pred)
open import Data.List
open import Data.Sum
open import Data.Product
open import Function
open import Relation.Nullary
open import Relation.Binary
open import Relation.Binary.PropositionalEquality
------------------------------------------------------------------------
-- Different types of pattern-matching lambdas
-- absurd pattern
empty : ∀ {a} {A : Set a} → Fin 0 → A
empty i = case i of λ ()
-- {}-delimited and ;-separated list of clauses
-- Note that they do not need to be on different lines
pred : ℕ → ℕ
pred n = case n of λ
{ zero → zero
; (suc n) → n
}
-- where-introduced and indentation-identified block of list of clauses
from-just : ∀ {a} {A : Set a} (x : Maybe A) → From-just x
from-just x = case x return From-just of λ where
(just x) → x
nothing → _
------------------------------------------------------------------------
-- We can define some recursive functions with case
plus : ℕ → ℕ → ℕ
plus m n = case m of λ
{ zero → n
; (suc m) → suc (plus m n)
}
div2 : ℕ → ℕ
div2 zero = zero
div2 (suc m) = case m of λ where
zero → zero
(suc m') → suc (div2 m')
-- Note that some natural uses of case are rejected by the termination
-- checker:
-- module _ {a} {A : Set a} (eq? : Decidable {A = A} _≡_) where
-- pairBy : List A → List (A ⊎ (A × A))
-- pairBy [] = []
-- pairBy (x ∷ []) = inj₁ x ∷ []
-- pairBy (x ∷ y ∷ xs) = case eq? x y of λ where
-- (yes _) → inj₂ (x , y) ∷ pairBy xs
-- (no _) → inj₁ x ∷ pairBy (y ∷ xs)
| {
"alphanum_fraction": 0.5388888889,
"avg_line_length": 26.7567567568,
"ext": "agda",
"hexsha": "2dd7595f55881e04415563471f6252ba9cadb4c6",
"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/Case.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/Case.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/README/Case.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": 536,
"size": 1980
} |
open import Oscar.Prelude
open import Oscar.Data.¶
module Oscar.Data.Vec where
data ⟨_⟩¶⟨≤_⟩ {𝔭} (𝔓 : ¶ → Ø 𝔭) : ¶ → Ø 𝔭 where
∅ : ⟨ 𝔓 ⟩¶⟨≤ ∅ ⟩
_,_ : ∀ {n} → 𝔓 n → ⟨ 𝔓 ⟩¶⟨≤ n ⟩ → ⟨ 𝔓 ⟩¶⟨≤ ↑ n ⟩
Vec⟨_⟩ = ⟨_⟩¶⟨≤_⟩
| {
"alphanum_fraction": 0.4409090909,
"avg_line_length": 18.3333333333,
"ext": "agda",
"hexsha": "8ca213bb823c8f92fe1ebd4640973e702dad0adb",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_forks_repo_licenses": [
"RSA-MD"
],
"max_forks_repo_name": "m0davis/oscar",
"max_forks_repo_path": "archive/agda-3/src/Oscar/Data/Vec.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z",
"max_issues_repo_licenses": [
"RSA-MD"
],
"max_issues_repo_name": "m0davis/oscar",
"max_issues_repo_path": "archive/agda-3/src/Oscar/Data/Vec.agda",
"max_line_length": 51,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_stars_repo_licenses": [
"RSA-MD"
],
"max_stars_repo_name": "m0davis/oscar",
"max_stars_repo_path": "archive/agda-3/src/Oscar/Data/Vec.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 140,
"size": 220
} |
module Logic.Structure.Applicative where
data Applicative (f : Set -> Set) : Set1 where
applicative :
(pure : {a : Set} -> a -> f a)
(_<*>_ : {a b : Set} -> f (a -> b) -> f a -> f b) ->
Applicative f
module Applicative {f : Set -> Set}(App : Applicative f) where
private
pure' : Applicative f -> {a : Set} -> a -> f a
pure' (applicative p _) = p
app' : Applicative f -> {a b : Set} -> f (a -> b) -> f a -> f b
app' (applicative _ a) = a
pure : {a : Set} -> a -> f a
pure = pure' App
_<*>_ : {a b : Set} -> f (a -> b) -> f a -> f b
_<*>_ = app' App
| {
"alphanum_fraction": 0.4892205638,
"avg_line_length": 24.12,
"ext": "agda",
"hexsha": "b3bd68bf95ba1552ce7c95e425b3479c47eecde5",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Logic/Structure/Applicative.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Logic/Structure/Applicative.agda",
"max_line_length": 67,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Logic/Structure/Applicative.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": 224,
"size": 603
} |
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
module groups.ProductRepr {i j}
{G : Group (lmax i j)} {H₁ : Group i} {H₂ : Group j}
(i₁ : H₁ →ᴳ G) (i₂ : H₂ →ᴳ G) (j₁ : G →ᴳ H₁) (j₂ : G →ᴳ H₂)
(p₁ : ∀ h₁ → GroupHom.f j₁ (GroupHom.f i₁ h₁) == h₁)
(p₂ : ∀ h₂ → GroupHom.f j₂ (GroupHom.f i₂ h₂) == h₂)
(ex₁ : is-exact i₁ j₂) (ex₂ : is-exact i₂ j₁) where
{- Given the following commutative diagram of homomorphisms,
H₁ i₁ i₂ H₂
↘ ↙
id ↓ G ↓ id
↙ ↘
H₁ j₁ j₂ H₂
- assuming i₁,j₂ and i₂,j₁ are exact sequences,
- there exists an isomorphism G == H₁ × H₂ such that i₁,i₂ correspond
- to the natural injections and j₁,j₂ correspond to the natural
- projections. -}
private
module G = Group G
module H₁ = Group H₁
module H₂ = Group H₂
module i₁ = GroupHom i₁
module i₂ = GroupHom i₂
module j₁ = GroupHom j₁
module j₂ = GroupHom j₂
fanout-has-trivial-ker : has-trivial-kerᴳ (×ᴳ-fanout j₁ j₂)
fanout-has-trivial-ker g q = Trunc-rec (G.El-level _ _)
(lemma g (fst×= q))
(ker-sub-im ex₁ g (snd×= q))
where
lemma : ∀ g → j₁.f g == H₁.ident
→ hfiber i₁.f g → g == G.ident
lemma ._ r (h , idp) =
ap i₁.f (! (p₁ h) ∙ r) ∙ i₁.pres-ident
β₁ : (h₁ : H₁.El) (h₂ : H₂.El)
→ j₁.f (G.comp (i₁.f h₁) (i₂.f h₂)) == h₁
β₁ h₁ h₂ =
j₁.pres-comp (i₁.f h₁) (i₂.f h₂)
∙ ap2 H₁.comp (p₁ h₁) (im-sub-ker ex₂ _ [ h₂ , idp ])
∙ H₁.unit-r h₁
β₂ : (h₁ : H₁.El) (h₂ : H₂.El)
→ j₂.f (G.comp (i₁.f h₁) (i₂.f h₂)) == h₂
β₂ h₁ h₂ =
j₂.pres-comp (i₁.f h₁) (i₂.f h₂)
∙ ap2 H₂.comp (im-sub-ker ex₁ _ [ h₁ , idp ]) (p₂ h₂)
∙ H₂.unit-l h₂
iso : G ≃ᴳ (H₁ ×ᴳ H₂)
iso = surjᴳ-and-injᴳ-iso (×ᴳ-fanout j₁ j₂)
(λ {(h₁ , h₂) → [ G.comp (i₁.f h₁) (i₂.f h₂) ,
pair×= (β₁ h₁ h₂) (β₂ h₁ h₂) ]})
(has-trivial-ker-is-injᴳ (×ᴳ-fanout j₁ j₂) fanout-has-trivial-ker)
j₁-fst-comm-sqr : CommSquareᴳ j₁ ×ᴳ-fst (–>ᴳ iso) (idhom _)
j₁-fst-comm-sqr = comm-sqrᴳ λ _ → idp
j₂-snd-comm-sqr : CommSquareᴳ j₂ (×ᴳ-snd {G = H₁}) (–>ᴳ iso) (idhom _)
j₂-snd-comm-sqr = comm-sqrᴳ λ _ → idp
abstract
i₁-inl-comm-sqr : CommSquareᴳ i₁ ×ᴳ-inl (idhom _) (–>ᴳ iso)
i₁-inl-comm-sqr = comm-sqrᴳ λ h₁ →
pair×= (p₁ h₁) (im-sub-ker ex₁ _ [ h₁ , idp ])
i₂-inr-comm-sqr : CommSquareᴳ i₂ ×ᴳ-inr (idhom _) (–>ᴳ iso)
i₂-inr-comm-sqr = comm-sqrᴳ λ h₂ →
pair×= (im-sub-ker ex₂ _ [ h₂ , idp ]) (p₂ h₂)
{- Given additionally maps
i₀ j₀
K –––→ G ––→ L
- such that j₀∘i₀ = 0, we have j₀(i₁(j₁(i₀ k)))⁻¹ = j₀(i₂(j₂(i₀ k))).
- (This is called the hexagon lemma in Eilenberg & Steenrod's book.
- The hexagon is not visible in this presentation.)
-}
module HexagonLemma {k l}
{K : Group k} {L : Group l}
(i₀ : K →ᴳ G) (j₀ : G →ᴳ L)
(ex₀ : ∀ g → GroupHom.f j₀ (GroupHom.f i₀ g) == Group.ident L)
where
abstract
decomp : ∀ g → G.comp (i₁.f (j₁.f g)) (i₂.f (j₂.f g)) == g
decomp g = <– (ap-equiv (GroupIso.f-equiv iso) _ g) $
GroupIso.f iso (G.comp (i₁.f (j₁.f g)) (i₂.f (j₂.f g)))
=⟨ GroupIso.pres-comp iso (i₁.f (j₁.f g)) (i₂.f (j₂.f g)) ⟩
Group.comp (H₁ ×ᴳ H₂) (GroupIso.f iso (i₁.f (j₁.f g))) (GroupIso.f iso (i₂.f (j₂.f g)))
=⟨ ap2 (Group.comp (H₁ ×ᴳ H₂))
((i₁-inl-comm-sqr □$ᴳ j₁.f g) ∙ ap (_, H₂.ident) (j₁-fst-comm-sqr □$ᴳ g))
((i₂-inr-comm-sqr □$ᴳ j₂.f g) ∙ ap (H₁.ident ,_) (j₂-snd-comm-sqr □$ᴳ g)) ⟩
(H₁.comp (fst (GroupIso.f iso g)) H₁.ident , H₂.comp H₂.ident (snd (GroupIso.f iso g)))
=⟨ pair×= (H₁.unit-r (fst (GroupIso.f iso g))) (H₂.unit-l (snd (GroupIso.f iso g))) ⟩
(fst (GroupIso.f iso g) , snd (GroupIso.f iso g))
=⟨ idp ⟩
GroupIso.f iso g
=∎
cancel : ∀ k →
Group.comp L (GroupHom.f (j₀ ∘ᴳ i₁ ∘ᴳ j₁ ∘ᴳ i₀) k)
(GroupHom.f (j₀ ∘ᴳ i₂ ∘ᴳ j₂ ∘ᴳ i₀) k)
== Group.ident L
cancel k = ! (GroupHom.pres-comp j₀ _ _)
∙ ap (GroupHom.f j₀) (decomp (GroupHom.f i₀ k))
∙ ex₀ k
inv₁ : ∀ k → Group.inv L (GroupHom.f (j₀ ∘ᴳ i₁ ∘ᴳ j₁ ∘ᴳ i₀) k)
== GroupHom.f (j₀ ∘ᴳ i₂ ∘ᴳ j₂ ∘ᴳ i₀) k
inv₁ k = Group.inv-unique-r L _ _ (cancel k)
inv₂ : ∀ k → Group.inv L (GroupHom.f (j₀ ∘ᴳ i₂ ∘ᴳ j₂ ∘ᴳ i₀) k)
== GroupHom.f (j₀ ∘ᴳ i₁ ∘ᴳ j₁ ∘ᴳ i₀) k
inv₂ k = Group.inv-unique-l L _ _ (cancel k)
| {
"alphanum_fraction": 0.5227929731,
"avg_line_length": 35.6904761905,
"ext": "agda",
"hexsha": "c783d28c18ad643a710e5b0fc42fdc81970f51d5",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z",
"max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mikeshulman/HoTT-Agda",
"max_forks_repo_path": "theorems/groups/ProductRepr.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "mikeshulman/HoTT-Agda",
"max_issues_repo_path": "theorems/groups/ProductRepr.agda",
"max_line_length": 95,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mikeshulman/HoTT-Agda",
"max_stars_repo_path": "theorems/groups/ProductRepr.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2008,
"size": 4497
} |
-- Intuitionistic propositional logic, de Bruijn approach, final encoding
module Bf.Ip where
open import Lib using (List; _,_; LMem; lzero; lsuc)
-- Types
infixl 2 _&&_
infixl 1 _||_
infixr 0 _=>_
data Ty : Set where
UNIT : Ty
_=>_ : Ty -> Ty -> Ty
_&&_ : Ty -> Ty -> Ty
_||_ : Ty -> Ty -> Ty
FALSE : Ty
infixr 0 _<=>_
_<=>_ : Ty -> Ty -> Ty
a <=> b = (a => b) && (b => a)
NOT : Ty -> Ty
NOT a = a => FALSE
TRUE : Ty
TRUE = FALSE => FALSE
-- Context and truth judgement
Cx : Set
Cx = List Ty
isTrue : Ty -> Cx -> Set
isTrue a tc = LMem a tc
-- Terms
TmRepr : Set1
TmRepr = Cx -> Ty -> Set
module ArrMp where
record Tm (tr : TmRepr) : Set1 where
infixl 1 _$_
infixr 0 lam=>_
field
var : forall {tc a} -> isTrue a tc -> tr tc a
lam=>_ : forall {tc a b} -> tr (tc , a) b -> tr tc (a => b)
_$_ : forall {tc a b} -> tr tc (a => b) -> tr tc a -> tr tc b
v0 : forall {tc a} -> tr (tc , a) a
v0 = var lzero
v1 : forall {tc a b} -> tr (tc , a , b) a
v1 = var (lsuc lzero)
v2 : forall {tc a b c} -> tr (tc , a , b , c) a
v2 = var (lsuc (lsuc lzero))
open Tm {{...}} public
module Mp where
record Tm (tr : TmRepr) : Set1 where
field
pair' : forall {tc a b} -> tr tc a -> tr tc b -> tr tc (a && b)
fst : forall {tc a b} -> tr tc (a && b) -> tr tc a
snd : forall {tc a b} -> tr tc (a && b) -> tr tc b
left : forall {tc a b} -> tr tc a -> tr tc (a || b)
right : forall {tc a b} -> tr tc b -> tr tc (a || b)
case' : forall {tc a b c} -> tr tc (a || b) -> tr (tc , a) c -> tr (tc , b) c -> tr tc c
isArrMp : ArrMp.Tm tr
open ArrMp.Tm isArrMp public
syntax pair' x y = [ x , y ]
syntax case' xy x y = case xy => x => y
open Tm {{...}} public
module Ip where
record Tm (tr : TmRepr) : Set1 where
field
abort : forall {tc a} -> tr tc FALSE -> tr tc a
isMp : Mp.Tm tr
open Mp.Tm isMp public
open Tm {{...}} public
Thm : Ty -> Set1
Thm a = forall {tr tc} {{_ : Tm tr}} -> tr tc a
open Ip public
-- Example theorems
t1 : forall {a b} -> Thm (a => NOT a => b)
t1 =
lam=>
lam=> abort (v0 $ v1)
t2 : forall {a b} -> Thm (NOT a => a => b)
t2 =
lam=>
lam=> abort (v1 $ v0)
t3 : forall {a} -> Thm (a => NOT (NOT a))
t3 =
lam=>
lam=> v0 $ v1
t4 : forall {a} -> Thm (NOT a <=> NOT (NOT (NOT a)))
t4 =
[ lam=>
lam=> v0 $ v1
, lam=>
lam=> v1 $ (lam=> v0 $ v1)
]
| {
"alphanum_fraction": 0.4742307692,
"avg_line_length": 21.8487394958,
"ext": "agda",
"hexsha": "39ab03b9e8d049b3e7158a5936781b2fb9ee678c",
"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": "2dd761bfa96ccda089888e8defa6814776fa2922",
"max_forks_repo_licenses": [
"X11"
],
"max_forks_repo_name": "mietek/formal-logic",
"max_forks_repo_path": "src/Bf/Ip.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "2dd761bfa96ccda089888e8defa6814776fa2922",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"X11"
],
"max_issues_repo_name": "mietek/formal-logic",
"max_issues_repo_path": "src/Bf/Ip.agda",
"max_line_length": 94,
"max_stars_count": 26,
"max_stars_repo_head_hexsha": "2dd761bfa96ccda089888e8defa6814776fa2922",
"max_stars_repo_licenses": [
"X11"
],
"max_stars_repo_name": "mietek/formal-logic",
"max_stars_repo_path": "src/Bf/Ip.agda",
"max_stars_repo_stars_event_max_datetime": "2021-11-13T12:37:44.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-08-31T09:49:52.000Z",
"num_tokens": 987,
"size": 2600
} |
------------------------------------------------------------------------
-- Experiments related to equality
--
-- Nils Anders Danielsson
--
-- Some files have been developed in collaboration with others, see
-- the individual files.
------------------------------------------------------------------------
{-# OPTIONS --cubical --with-K --guardedness --sized-types --prop #-}
module README where
-- "Safe" code that uses --without-K.
import README.Safe.Without-K
-- "Safe" code that uses --erased-cubical.
import README.Safe.Cubical.Erased
-- "Safe" code that uses --erased-cubical and --guardedness.
import README.Safe.Cubical.Erased.Guardedness
-- "Safe" code that uses --erased-cubical and --prop.
import README.Safe.Cubical.Erased.Prop
-- "Safe" code that uses --cubical.
import README.Safe.Cubical
-- "Safe" code that uses --with-K.
import README.Safe.With-K
-- Code which might depend on potentially unsafe features (other than
-- --sized-types).
import README.Unsafe
-- Code which is "safe", except for the use of --sized-types.
import README.Unsafe.Sized-types
-- Code related to the paper "Logical properties of a modality for
-- erasure". This code uses both --cubical and --with-K, but not at
-- the same time, except in the module README.Erased, which for that
-- reason cannot use --safe.
import README.Erased
| {
"alphanum_fraction": 0.6463142219,
"avg_line_length": 25.3396226415,
"ext": "agda",
"hexsha": "be3362d49db147df745d2993dcb46900c19f006b",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/equality",
"max_forks_repo_path": "README.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/equality",
"max_issues_repo_path": "README.agda",
"max_line_length": 72,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/equality",
"max_stars_repo_path": "README.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z",
"num_tokens": 315,
"size": 1343
} |
{-# OPTIONS --universe-polymorphism #-}
open import Categories.Category
-- small indexed products of specific shapes
module Categories.Object.IndexedProducts {o ℓ e} (C : Category o ℓ e) where
open Category C
-- open Equiv
open import Level
open import Categories.Support.Equivalence using (Setoid; module Setoid)
import Categories.Object.Indexed as IObj
import Categories.Object.IndexedProduct as IProduct
import Categories.Morphism.Indexed as IArrow
import Categories.Morphisms as Morphisms
record IndexedProducts {c q} {Shape : Setoid c q} : Set (o ⊔ ℓ ⊔ e ⊔ c ⊔ q) where
open IObj C Shape
open IArrow C Shape
open IProduct C
module Fan-Setoid {V} (xs : Dust) = Setoid (fan-setoid V xs)
open Fan-Setoid using () renaming (_≈_ to _[_≜_])
field
product : ∀ {As} → IndexedProduct Shape As
∏ : ∀ As → Obj
∏ As = IndexedProduct.∏ (product {As})
-- ×-comm : ∀ {A B} → _≅_ C (A × B) (B × A)
-- ×-comm = Commutative product product
-- ×-assoc : ∀ {X Y Z} → _≅_ C (X × (Y × Z)) ((X × Y) × Z)
-- ×-assoc = Associative product product product product
-- Convenience! well, sort of.
module Product {As} = IndexedProduct {As = As} (product {As = As})
open Product using (π; π[_]; π-cong; π▹_; uncurry; commute; commute∗; universal; universal∗; g-η; η; uncurry-cong; uncurry-cong∗; uncurry∘)
-- assocˡ : ∀ {A B C} → (((A × B) × C) ⇒ (A × (B × C)))
-- assocˡ = _≅_.g C ×-assoc
-- assocʳ : ∀ {A B C} → ((A × (B × C)) ⇒ ((A × B) × C))
-- assocʳ = _≅_.f C ×-assoc
_⋉π : ∀ {As Bs} → (As ∗⇒∗ Bs) → (∏ As ⇒∗ Bs)
_⋉π {As} {Bs} fs = _⋉_ {Ys = As} {Bs} fs (π {As})
bundle : ∀ {As Bs} → (As ∗⇒∗ Bs) → (∏ As ⇒ ∏ Bs)
bundle {As} {Bs} fs = uncurry {Bs} (_⋉π {As} {Bs} fs)
-- TODO: this is probably harder to use than necessary because of this definition. Maybe make a version
-- that doesn't have an explicit id in it, too?
-- first : ∀ {A B C} → (A ⇒ B) → ((A × C) ⇒ (B × C))
-- first f = f ⁂ id
-- second : ∀ {A C D} → (C ⇒ D) → ((A × C) ⇒ (A × D))
-- second g = id ⁂ g
-- Just to make this more obvious
.π▹bundle : ∀ {As Bs} {fs : As ∗⇒∗ Bs} → Bs [ π▹ bundle {As} {Bs} fs ≜ _⋉π {As} {Bs} fs ]
π▹bundle {As} {Bs} {fs = fs} = commute∗ {Bs} (_⋉π {As} {Bs} fs)
.π∘bundle : ∀ {As Bs} {fs : As ∗⇒∗ Bs} {x} → π[_] {Bs} x ∘ bundle {As} {Bs} fs ≡ (fs ‼ x) ∘ π[_] {As} x
π∘bundle {As} {Bs} {fs = fs} = commute {Bs} (_⋉π {As} {Bs} fs)
.bundle∘uncurry : ∀ {A Bs Cs} {fs : Bs ∗⇒∗ Cs} {gs : A ⇒∗ Bs} → bundle {Bs} {Cs} fs ∘ uncurry {Bs} gs ≡ uncurry {Cs} (_⋉_ {Ys = Bs} {Cs} fs gs)
bundle∘uncurry {Bs = Bs} {Cs} {fs = fs} {gs} = Equiv.sym (universal {Cs} (_⋉_ {Ys = Bs} {Cs} fs gs) helper)
where
helper : ∀ {x} → π[_] {Cs} x ∘ (bundle {Bs} {Cs} fs ∘ uncurry {Bs} gs) ≡ (fs ‼ x) ∘ (gs ‼ x)
helper {x} =
begin
π[_] {Cs} x ∘ (bundle {Bs} {Cs} fs ∘ uncurry {Bs} gs)
↑⟨ assoc ⟩
(π[_] {Cs} x ∘ bundle {Bs} {Cs} fs) ∘ uncurry {Bs} gs
↓⟨ ∘-resp-≡ˡ (π∘bundle {Bs} {Cs} {fs = fs}) ⟩
((fs ‼ x) ∘ π[_] {Bs} x) ∘ uncurry {Bs} gs
↓⟨ assoc ⟩
(fs ‼ x) ∘ (π[_] {Bs} x ∘ uncurry {Bs} gs)
↓⟨ ∘-resp-≡ʳ (commute {Bs} gs) ⟩
(fs ‼ x) ∘ (gs ‼ x)
∎
where
open HomReasoning
{-
.first∘⟨⟩ : ∀ {A B C D} → {f : B ⇒ C} {f′ : A ⇒ B} {g′ : A ⇒ D} → first f ∘ ⟨ f′ , g′ ⟩ ≡ ⟨ f ∘ f′ , g′ ⟩
first∘⟨⟩ {f = f} {f′} {g′} =
begin
first f ∘ ⟨ f′ , g′ ⟩
↓⟨ ⁂∘⟨⟩ ⟩
⟨ f ∘ f′ , id ∘ g′ ⟩
↓⟨ ⟨⟩-cong₂ refl identityˡ ⟩
⟨ f ∘ f′ , g′ ⟩
∎
where
open HomReasoning
.second∘⟨⟩ : ∀ {A B D E} → {f′ : A ⇒ B} {g : D ⇒ E} {g′ : A ⇒ D} → second g ∘ ⟨ f′ , g′ ⟩ ≡ ⟨ f′ , g ∘ g′ ⟩
second∘⟨⟩ {f′ = f′} {g} {g′} =
begin
second g ∘ ⟨ f′ , g′ ⟩
↓⟨ ⁂∘⟨⟩ ⟩
⟨ id ∘ f′ , g ∘ g′ ⟩
↓⟨ ⟨⟩-cong₂ identityˡ refl ⟩
⟨ f′ , g ∘ g′ ⟩
∎
where
open HomReasoning
-}
.bundle∘bundle : ∀ {As Bs Cs} → {fs : Bs ∗⇒∗ Cs} {gs : As ∗⇒∗ Bs} → (bundle {Bs} {Cs} fs) ∘ (bundle {As} {Bs} gs) ≡ bundle {As} {Cs} (_◽_ {As} {Bs} {Cs} fs gs)
bundle∘bundle {As} {Bs} {Cs} {fs = fs} {gs} =
begin
(bundle {Bs} {Cs} fs) ∘ (bundle {As} {Bs} gs)
↓⟨ bundle∘uncurry {Bs = Bs} {Cs} {fs = fs} ⟩
uncurry {Cs} (_⋉_ {Ys = Bs} {Cs} fs (_⋉_ {Ys = As} {Bs} gs (π {As})))
↑⟨ uncurry-cong∗ {Cs} {_} {_⋉_ {Ys = As} {Cs} (_◽_ {As} {Bs} {Cs} fs gs) (π {As})} {_⋉_ {Ys = Bs} {Cs} fs (_⋉_ {Ys = As} {Bs} gs (π {As}))} (assoc-◽⋉ {Ys = As} {Bs} {Cs} {fs} {gs} {π {As}}) ⟩
(bundle {As} {Cs} (_◽_ {As} {Bs} {Cs} fs gs))
∎
where
open HomReasoning
| {
"alphanum_fraction": 0.4936123348,
"avg_line_length": 36.0317460317,
"ext": "agda",
"hexsha": "94e61428be602f00faabf45bf47897ac18adec43",
"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/Object/IndexedProducts.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/Object/IndexedProducts.agda",
"max_line_length": 195,
"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/Object/IndexedProducts.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": 2094,
"size": 4540
} |
module Issue807b where
open import Common.Coinduction
data Unit : Set where
unit : Unit
From-unit : Unit → Set
From-unit unit = Unit
from-unit : (x : Unit) → From-unit x
from-unit unit = unit
data D : Set where
d₁ : D
d₂ : ∞ D → D
foo : D → Unit
foo d₁ = unit
foo (d₂ x) with ♭ x
foo (d₂ x) | d₁ = unit
foo (d₂ x) | d₂ _ = unit
-- x : ∞ D
x = ♯ d₁
-- There was an internal error if type-signature was not supplied.
| {
"alphanum_fraction": 0.6206896552,
"avg_line_length": 15.5357142857,
"ext": "agda",
"hexsha": "2792a83c83d18dc6ccddc14b0c0acdd436c0c0cf",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Succeed/Issue807b.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Succeed/Issue807b.agda",
"max_line_length": 66,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/Issue807b.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": 156,
"size": 435
} |
{-# OPTIONS --cubical --safe --postfix-projections #-}
open import Prelude
open import Relation.Binary
module Relation.Binary.Construct.UpperBound {e} {E : Type e} {r₁ r₂} (totalOrder : TotalOrder E r₁ r₂) where
open TotalOrder totalOrder renaming (refl to <-refl)
import Data.Unit.UniversePolymorphic as Poly
import Data.Empty.UniversePolymorphic as Poly
open import Data.Maybe.Base using () renaming (nothing to ⌈⊤⌉; just to ⌈_⌉) public
⌈∙⌉ : Type e
⌈∙⌉ = Maybe E
_≤⌈_⌉ : ⌈∙⌉ → E → Type _
⌈⊤⌉ ≤⌈ y ⌉ = Poly.⊥
⌈ x ⌉ ≤⌈ y ⌉ = x ≤ y
_⌈≤⌉_ : ⌈∙⌉ → ⌈∙⌉ → Type _
x ⌈≤⌉ ⌈⊤⌉ = Poly.⊤
x ⌈≤⌉ ⌈ y ⌉ = x ≤⌈ y ⌉
⌈_⌉<_ : E → ⌈∙⌉ → Type _
⌈ x ⌉< ⌈⊤⌉ = Poly.⊤
⌈ x ⌉< ⌈ y ⌉ = x < y
_⌈<⌉_ : ⌈∙⌉ → ⌈∙⌉ → Type _
⌈⊤⌉ ⌈<⌉ _ = Poly.⊥
⌈ x ⌉ ⌈<⌉ y = ⌈ x ⌉< y
ub-pord : PartialOrder ⌈∙⌉ _
ub-pord .PartialOrder.preorder .Preorder._≤_ = _⌈≤⌉_
ub-pord .PartialOrder.preorder .Preorder.refl {⌈⊤⌉} = Poly.tt
ub-pord .PartialOrder.preorder .Preorder.refl {⌈ x ⌉} = <-refl
ub-pord .PartialOrder.preorder .Preorder.trans {x} {y} {⌈⊤⌉} x≤y y≤z = Poly.tt
ub-pord .PartialOrder.preorder .Preorder.trans {⌈ x ⌉} {⌈ y ⌉} {⌈ z ⌉} x≤y y≤z = ≤-trans x≤y y≤z
ub-pord .PartialOrder.antisym {⌈⊤⌉} {⌈⊤⌉} p q = refl
ub-pord .PartialOrder.antisym {⌈ x ⌉} {⌈ y ⌉} p q = cong ⌈_⌉ (antisym p q)
ub-sord : StrictPartialOrder ⌈∙⌉ _
StrictPreorder._<_ (StrictPartialOrder.strictPreorder ub-sord) = _⌈<⌉_
StrictPreorder.trans (StrictPartialOrder.strictPreorder ub-sord) {⌈ x ⌉} {⌈ y ⌉} {⌈⊤⌉} p q = Poly.tt
StrictPreorder.trans (StrictPartialOrder.strictPreorder ub-sord) {⌈ x ⌉} {⌈ y ⌉} {⌈ z ⌉} p q = <-trans p q
StrictPreorder.irrefl (StrictPartialOrder.strictPreorder ub-sord) {⌈ x ⌉} = irrefl {x = x}
StrictPartialOrder.conn ub-sord {⌈⊤⌉} {⌈⊤⌉} p q = refl
StrictPartialOrder.conn ub-sord {⌈⊤⌉} {⌈ x ⌉} p q = ⊥-elim (q Poly.tt)
StrictPartialOrder.conn ub-sord {⌈ x ⌉} {⌈⊤⌉} p q = ⊥-elim (p Poly.tt)
StrictPartialOrder.conn ub-sord {⌈ x ⌉} {⌈ y ⌉} p q = cong ⌈_⌉ (conn p q)
ub-lt : ∀ x y → Dec (x ⌈<⌉ y)
ub-lt ⌈⊤⌉ y = no λ ()
ub-lt ⌈ x ⌉ ⌈⊤⌉ = yes Poly.tt
ub-lt ⌈ x ⌉ ⌈ y ⌉ = x <? y
ub-ord : TotalOrder ⌈∙⌉ _ _
TotalOrder.strictPartialOrder ub-ord = ub-sord
TotalOrder.partialOrder ub-ord = ub-pord
TotalOrder._<?_ ub-ord = ub-lt
TotalOrder.≰⇒> ub-ord {x} {⌈⊤⌉} p = ⊥-elim (p Poly.tt)
TotalOrder.≰⇒> ub-ord {⌈⊤⌉} {⌈ y ⌉} p = Poly.tt
TotalOrder.≰⇒> ub-ord {⌈ x ⌉} {⌈ y ⌉} p = ≰⇒> p
TotalOrder.≮⇒≥ ub-ord {⌈⊤⌉} {y} p = Poly.tt
TotalOrder.≮⇒≥ ub-ord {⌈ x ⌉} {⌈⊤⌉} p = ⊥-elim (p Poly.tt)
TotalOrder.≮⇒≥ ub-ord {⌈ x ⌉} {⌈ y ⌉} p = ≮⇒≥ p
import Data.Maybe.Sugar
module UBSugar = Data.Maybe.Sugar
| {
"alphanum_fraction": 0.5928237129,
"avg_line_length": 36.6285714286,
"ext": "agda",
"hexsha": "d04209cc76473c6a9b33ba0cd1d2aebab9e4989f",
"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/Construct/UpperBound.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/Construct/UpperBound.agda",
"max_line_length": 108,
"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/Construct/UpperBound.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": 1448,
"size": 2564
} |
variable A : Set
f : A
f = {!!}
-- The goal type should be printed as A, not A₁.
-- Introducing the hidden variable with C-c C-c should choose name A.
| {
"alphanum_fraction": 0.6666666667,
"avg_line_length": 19.125,
"ext": "agda",
"hexsha": "bac10dabf51cd0dd58b59993c1fe0d236c708c39",
"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/interaction/GeneralizeShadowing.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/interaction/GeneralizeShadowing.agda",
"max_line_length": 69,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/interaction/GeneralizeShadowing.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": 43,
"size": 153
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Propositional equality
--
-- This file contains some core definitions which are re-exported by
-- Relation.Binary.PropositionalEquality.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Relation.Binary.PropositionalEquality.Core where
open import Data.Product using (_,_)
open import Level
open import Relation.Binary.Core
open import Relation.Nullary using (¬_)
------------------------------------------------------------------------
-- Propositional equality
open import Agda.Builtin.Equality public
infix 4 _≢_
_≢_ : ∀ {a} {A : Set a} → Rel A a
x ≢ y = ¬ x ≡ y
------------------------------------------------------------------------
-- Some properties
module _ {a} {A : Set a} where
sym : Symmetric {A = A} _≡_
sym refl = refl
trans : Transitive {A = A} _≡_
trans refl eq = eq
subst : ∀ {p} → Substitutive {A = A} _≡_ p
subst P refl p = p
cong : ∀ {b} {B : Set b} (f : A → B) {x y} → x ≡ y → f x ≡ f y
cong f refl = refl
respˡ : ∀ {ℓ} (∼ : Rel A ℓ) → ∼ Respectsˡ _≡_
respˡ _∼_ refl x∼y = x∼y
respʳ : ∀ {ℓ} (∼ : Rel A ℓ) → ∼ Respectsʳ _≡_
respʳ _∼_ refl x∼y = x∼y
resp₂ : ∀ {ℓ} (∼ : Rel A ℓ) → ∼ Respects₂ _≡_
resp₂ _∼_ = respʳ _∼_ , respˡ _∼_
isEquivalence : IsEquivalence {A = A} _≡_
isEquivalence = record
{ refl = refl
; sym = sym
; trans = trans
}
------------------------------------------------------------------------
-- Various equality rearrangement lemmas
module _ {a} {A : Set a} {x y : A} where
trans-reflʳ : (p : x ≡ y) → trans p refl ≡ p
trans-reflʳ refl = refl
trans-assoc : ∀ {z u} (p : x ≡ y) {q : y ≡ z} {r : z ≡ u} →
trans (trans p q) r ≡ trans p (trans q r)
trans-assoc refl = refl
trans-symˡ : (p : x ≡ y) → trans (sym p) p ≡ refl
trans-symˡ refl = refl
trans-symʳ : (p : x ≡ y) → trans p (sym p) ≡ refl
trans-symʳ refl = refl
------------------------------------------------------------------------
-- Convenient syntax for equational reasoning
-- This is a special instance of `Relation.Binary.Reasoning.Setoid`.
-- Rather than instantiating the latter with (setoid A), we reimplement
-- equation chains from scratch since then goals are printed much more
-- readably.
module ≡-Reasoning {a} {A : Set a} where
infix 3 _∎
infixr 2 _≡⟨⟩_ _≡⟨_⟩_ _≡˘⟨_⟩_
infix 1 begin_
begin_ : ∀{x y : A} → x ≡ y → x ≡ y
begin_ x≡y = x≡y
_≡⟨⟩_ : ∀ (x {y} : A) → x ≡ y → x ≡ y
_ ≡⟨⟩ x≡y = x≡y
_≡⟨_⟩_ : ∀ (x {y z} : A) → x ≡ y → y ≡ z → x ≡ z
_ ≡⟨ x≡y ⟩ y≡z = trans x≡y y≡z
_≡˘⟨_⟩_ : ∀ (x {y z} : A) → y ≡ x → y ≡ z → x ≡ z
_ ≡˘⟨ y≡x ⟩ y≡z = trans (sym y≡x) y≡z
_∎ : ∀ (x : A) → x ≡ x
_∎ _ = refl
| {
"alphanum_fraction": 0.4843304843,
"avg_line_length": 26.2429906542,
"ext": "agda",
"hexsha": "7bfe5c32b033d52d958bc36504c3837a3738d115",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "omega12345/agda-mode",
"max_forks_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/PropositionalEquality/Core.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "omega12345/agda-mode",
"max_issues_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/PropositionalEquality/Core.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/PropositionalEquality/Core.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1025,
"size": 2808
} |
module objectOrientedGui where
open import Data.Product hiding (map)
open import Data.List
open import Data.Bool.Base
open import SizedIO.Base
open import NativeIO
open import Relation.Binary.PropositionalEquality hiding ([_])
open import Size
open import Function
open import StateSizedIO.GUI.BaseStateDependent
open import StateSizedIO.GUI.WxBindingsFFI
data VarList : Set₁ where
[]v : VarList
addVar : (A : Set) → Var A → VarList → VarList
prod : VarList → Set
prod []v = Unit
prod (addVar A v []v) = A
prod (addVar A v l) = A × prod l
takeVar : (l : VarList) → NativeIO (prod l)
takeVar []v = nativeReturn _
takeVar (addVar A v []v) = nativeTakeVar {A} v
takeVar (addVar A v (addVar B v' l)) =
nativeTakeVar {A} v native>>= λ a →
takeVar (addVar B v' l) native>>= λ rest →
nativeReturn ( a , rest )
putVar : (l : VarList) → prod l → NativeIO Unit
putVar []v _ = nativeReturn _
putVar (addVar A v []v) a = nativePutVar {A} v a
putVar (addVar A v (addVar B v' l)) (a , rest) =
nativePutVar {A} v a native>>= λ _ →
putVar (addVar B v' l) rest
data GuiLev1Command : Set where
makeFrame : GuiLev1Command
makeButton : Frame → GuiLev1Command
addButton : Frame → Button → GuiLev1Command
drawBitmap : DC → Bitmap → Point → Bool → GuiLev1Command
repaint : Frame → GuiLev1Command
GuiLev1Response : GuiLev1Command → Set
GuiLev1Response makeFrame = Frame
GuiLev1Response (makeButton _) = Button
GuiLev1Response _ = Unit
GuiLev1Interface : IOInterface
Command GuiLev1Interface = GuiLev1Command
Response GuiLev1Interface = GuiLev1Response
GuiLev2State : Set₁
GuiLev2State = VarList
data GuiLev2Command (s : GuiLev2State) : Set₁ where
level1C : GuiLev1Command → GuiLev2Command s
createVar : {A : Set} → A → GuiLev2Command s
setButtonHandler : Button
→ List (prod s → IO GuiLev1Interface ∞ (prod s))
→ GuiLev2Command s
setOnPaint : Frame
→ List (prod s → DC → Rect → IO GuiLev1Interface ∞ (prod s))
→ GuiLev2Command s
GuiLev2Response : (s : GuiLev2State) → GuiLev2Command s → Set
GuiLev2Response _ (level1C c) = GuiLev1Response c
GuiLev2Response _ (createVar {A} a) = Var A
GuiLev2Response _ _ = Unit
GuiLev2Next : (s : GuiLev2State) → (c : GuiLev2Command s)
→ GuiLev2Response s c
→ GuiLev2State
GuiLev2Next s (createVar {A} a) var = addVar A var s
GuiLev2Next s _ _ = s
GuiLev2Interface : IOInterfaceˢ
Stateˢ GuiLev2Interface = GuiLev2State
Commandˢ GuiLev2Interface = GuiLev2Command
Responseˢ GuiLev2Interface = GuiLev2Response
nextˢ GuiLev2Interface = GuiLev2Next
translateLev1Local : (c : GuiLev1Command) → NativeIO (GuiLev1Response c)
translateLev1Local makeFrame = nativeMakeFrame
translateLev1Local (makeButton fra) = nativeMakeButton fra
translateLev1Local (addButton fra bt) = nativeAddButton fra bt
translateLev1Local (drawBitmap dc bm p b) = nativeDrawBitmap dc bm p b
translateLev1Local (repaint fra) = nativeRepaint fra
translateLev1 : {A : Set} → IO GuiLev1Interface ∞ A → NativeIO A
translateLev1 = translateIO translateLev1Local
translateLev1List : {A : Set} → List (IO GuiLev1Interface ∞ A) → List (NativeIO A)
translateLev1List l = map translateLev1 l
dispatch : (l : VarList) → (prod l → NativeIO (prod l)) → NativeIO Unit
dispatch l f = takeVar l native>>= λ a →
f a native>>= λ a₁ →
putVar l a₁
dispatchList : (l : VarList) → List (prod l → NativeIO (prod l)) → NativeIO Unit
dispatchList l [] = nativeReturn _
dispatchList l (p ∷ rest) = dispatch l p native>>= λ _ →
dispatchList l rest
translateLev2Local : (s : GuiLev2State)
→ (c : GuiLev2Command s)
→ NativeIO (GuiLev2Response s c)
translateLev2Local s (level1C c) = translateLev1Local c
translateLev2Local s (createVar {A} a) = nativeNewVar {A} a
translateLev2Local s (setButtonHandler bt proglist) =
nativeSetButtonHandler bt
(dispatchList s (map (λ prog → translateLev1 ∘ prog) proglist))
translateLev2Local s (setOnPaint fra proglist) =
nativeSetOnPaint fra (λ dc rect → dispatchList s
(map (λ prog aa → translateLev1 (prog aa dc rect)) proglist))
translateLev2 : ∀ {A s} → IOˢ GuiLev2Interface ∞ (λ _ → A) s → NativeIO A
translateLev2 = translateIOˢ translateLev2Local
| {
"alphanum_fraction": 0.6373372533,
"avg_line_length": 38.4032258065,
"ext": "agda",
"hexsha": "14bf2a6d4bc808367dbc00f8a4c12feb06169750",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z",
"max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "agda/ooAgda",
"max_forks_repo_path": "presentationsAndExampleCode/agdaImplementorsMeetingGlasgow22April2016AntonSetzer/objectOrientedGui.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "agda/ooAgda",
"max_issues_repo_path": "presentationsAndExampleCode/agdaImplementorsMeetingGlasgow22April2016AntonSetzer/objectOrientedGui.agda",
"max_line_length": 83,
"max_stars_count": 23,
"max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "agda/ooAgda",
"max_stars_repo_path": "presentationsAndExampleCode/agdaImplementorsMeetingGlasgow22April2016AntonSetzer/objectOrientedGui.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z",
"num_tokens": 1538,
"size": 4762
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Consequences of a monomorphism between magma-like structures
------------------------------------------------------------------------
-- See Data.Nat.Binary.Properties for examples of how this and similar
-- modules can be used to easily translate properties between types.
{-# OPTIONS --without-K --safe #-}
open import Algebra.Core
open import Algebra.Bundles
open import Algebra.Morphism.Structures
open import Relation.Binary.Core
module Algebra.Morphism.MagmaMonomorphism
{a b ℓ₁ ℓ₂} {M₁ : RawMagma a ℓ₁} {M₂ : RawMagma b ℓ₂} {⟦_⟧}
(isMagmaMonomorphism : IsMagmaMonomorphism M₁ M₂ ⟦_⟧)
where
open IsMagmaMonomorphism isMagmaMonomorphism
open RawMagma M₁ renaming (Carrier to A; _≈_ to _≈₁_; _∙_ to _∙_)
open RawMagma M₂ renaming (Carrier to B; _≈_ to _≈₂_; _∙_ to _◦_)
open import Algebra.Structures
open import Algebra.Definitions
open import Data.Product
open import Data.Sum.Base using (inj₁; inj₂)
import Relation.Binary.Reasoning.Setoid as SetoidReasoning
import Relation.Binary.Morphism.RelMonomorphism isRelMonomorphism as RelMorphism
------------------------------------------------------------------------
-- Properties
module _ (◦-isMagma : IsMagma _≈₂_ _◦_) where
open IsMagma ◦-isMagma renaming (∙-cong to ◦-cong)
open SetoidReasoning setoid
cong : Congruent₂ _≈₁_ _∙_
cong {x} {y} {u} {v} x≈y u≈v = injective (begin
⟦ x ∙ u ⟧ ≈⟨ homo x u ⟩
⟦ x ⟧ ◦ ⟦ u ⟧ ≈⟨ ◦-cong (⟦⟧-cong x≈y) (⟦⟧-cong u≈v) ⟩
⟦ y ⟧ ◦ ⟦ v ⟧ ≈˘⟨ homo y v ⟩
⟦ y ∙ v ⟧ ∎)
assoc : Associative _≈₂_ _◦_ → Associative _≈₁_ _∙_
assoc assoc x y z = injective (begin
⟦ (x ∙ y) ∙ z ⟧ ≈⟨ homo (x ∙ y) z ⟩
⟦ x ∙ y ⟧ ◦ ⟦ z ⟧ ≈⟨ ◦-cong (homo x y) refl ⟩
(⟦ x ⟧ ◦ ⟦ y ⟧) ◦ ⟦ z ⟧ ≈⟨ assoc ⟦ x ⟧ ⟦ y ⟧ ⟦ z ⟧ ⟩
⟦ x ⟧ ◦ (⟦ y ⟧ ◦ ⟦ z ⟧) ≈˘⟨ ◦-cong refl (homo y z) ⟩
⟦ x ⟧ ◦ ⟦ y ∙ z ⟧ ≈˘⟨ homo x (y ∙ z) ⟩
⟦ x ∙ (y ∙ z) ⟧ ∎)
comm : Commutative _≈₂_ _◦_ → Commutative _≈₁_ _∙_
comm comm x y = injective (begin
⟦ x ∙ y ⟧ ≈⟨ homo x y ⟩
⟦ x ⟧ ◦ ⟦ y ⟧ ≈⟨ comm ⟦ x ⟧ ⟦ y ⟧ ⟩
⟦ y ⟧ ◦ ⟦ x ⟧ ≈˘⟨ homo y x ⟩
⟦ y ∙ x ⟧ ∎)
idem : Idempotent _≈₂_ _◦_ → Idempotent _≈₁_ _∙_
idem idem x = injective (begin
⟦ x ∙ x ⟧ ≈⟨ homo x x ⟩
⟦ x ⟧ ◦ ⟦ x ⟧ ≈⟨ idem ⟦ x ⟧ ⟩
⟦ x ⟧ ∎)
sel : Selective _≈₂_ _◦_ → Selective _≈₁_ _∙_
sel sel x y with sel ⟦ x ⟧ ⟦ y ⟧
... | inj₁ x◦y≈x = inj₁ (injective (begin
⟦ x ∙ y ⟧ ≈⟨ homo x y ⟩
⟦ x ⟧ ◦ ⟦ y ⟧ ≈⟨ x◦y≈x ⟩
⟦ x ⟧ ∎))
... | inj₂ x◦y≈y = inj₂ (injective (begin
⟦ x ∙ y ⟧ ≈⟨ homo x y ⟩
⟦ x ⟧ ◦ ⟦ y ⟧ ≈⟨ x◦y≈y ⟩
⟦ y ⟧ ∎))
cancelˡ : LeftCancellative _≈₂_ _◦_ → LeftCancellative _≈₁_ _∙_
cancelˡ cancelˡ x {y} {z} x∙y≈x∙z = injective (cancelˡ ⟦ x ⟧ (begin
⟦ x ⟧ ◦ ⟦ y ⟧ ≈˘⟨ homo x y ⟩
⟦ x ∙ y ⟧ ≈⟨ ⟦⟧-cong x∙y≈x∙z ⟩
⟦ x ∙ z ⟧ ≈⟨ homo x z ⟩
⟦ x ⟧ ◦ ⟦ z ⟧ ∎))
cancelʳ : RightCancellative _≈₂_ _◦_ → RightCancellative _≈₁_ _∙_
cancelʳ cancelʳ {x} y z y∙x≈z∙x = injective (cancelʳ ⟦ y ⟧ ⟦ z ⟧ (begin
⟦ y ⟧ ◦ ⟦ x ⟧ ≈˘⟨ homo y x ⟩
⟦ y ∙ x ⟧ ≈⟨ ⟦⟧-cong y∙x≈z∙x ⟩
⟦ z ∙ x ⟧ ≈⟨ homo z x ⟩
⟦ z ⟧ ◦ ⟦ x ⟧ ∎))
cancel : Cancellative _≈₂_ _◦_ → Cancellative _≈₁_ _∙_
cancel = map cancelˡ cancelʳ
------------------------------------------------------------------------
-- Structures
isMagma : IsMagma _≈₂_ _◦_ → IsMagma _≈₁_ _∙_
isMagma isMagma = record
{ isEquivalence = RelMorphism.isEquivalence M.isEquivalence
; ∙-cong = cong isMagma
} where module M = IsMagma isMagma
isSemigroup : IsSemigroup _≈₂_ _◦_ → IsSemigroup _≈₁_ _∙_
isSemigroup isSemigroup = record
{ isMagma = isMagma S.isMagma
; assoc = assoc S.isMagma S.assoc
} where module S = IsSemigroup isSemigroup
isBand : IsBand _≈₂_ _◦_ → IsBand _≈₁_ _∙_
isBand isBand = record
{ isSemigroup = isSemigroup B.isSemigroup
; idem = idem B.isMagma B.idem
} where module B = IsBand isBand
isSemilattice : IsSemilattice _≈₂_ _◦_ → IsSemilattice _≈₁_ _∙_
isSemilattice isSemilattice = record
{ isBand = isBand S.isBand
; comm = comm S.isMagma S.comm
} where module S = IsSemilattice isSemilattice
isSelectiveMagma : IsSelectiveMagma _≈₂_ _◦_ → IsSelectiveMagma _≈₁_ _∙_
isSelectiveMagma isSelMagma = record
{ isMagma = isMagma S.isMagma
; sel = sel S.isMagma S.sel
} where module S = IsSelectiveMagma isSelMagma
| {
"alphanum_fraction": 0.5435070671,
"avg_line_length": 34.8307692308,
"ext": "agda",
"hexsha": "e085efd6a1ab8c2090a51c900a5f0c44d97f0f59",
"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/Morphism/MagmaMonomorphism.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/Morphism/MagmaMonomorphism.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/Algebra/Morphism/MagmaMonomorphism.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": 2000,
"size": 4528
} |
{-# OPTIONS --safe #-}
module Cubical.Algebra.Algebra where
open import Cubical.Algebra.Algebra.Base public
open import Cubical.Algebra.Algebra.Properties public
| {
"alphanum_fraction": 0.8036809816,
"avg_line_length": 27.1666666667,
"ext": "agda",
"hexsha": "acdb869da55f7818020d7e5cca4f8dbf0602c0d2",
"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/Algebra.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/Algebra.agda",
"max_line_length": 53,
"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/Algebra.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": 36,
"size": 163
} |
{- Type classes and instances for categories. -}
module CategoryTheory.Categories where
open import Relation.Binary.PropositionalEquality
using (_≡_ ; refl ; sym ; trans ; subst ; cong) public
open import Relation.Binary using (IsEquivalence)
open import Agda.Primitive using (Level ; _⊔_ ; lzero ; lsuc) public
open import Relation.Binary.PropositionalEquality
-- Function extensionality
postulate
ext : ∀{a b} -> Extensionality a b
-- Type class for categories.
-- Based on https://github.com/UlfNorell/category-theory-experiments
record Category (n : Level) : Set (lsuc (lsuc n)) where
infixr 10 _~>_
infixl 40 _≈_
infixr 60 _∘_
field
-- || Data
-- Objects
obj : Set (lsuc n)
-- Arrows
_~>_ : obj -> obj -> Set n
-- || Operations
-- Identity arrow
id : {A : obj} -> A ~> A
-- Composition of arrows
_∘_ : {A B C : obj} -> (B ~> C) -> (A ~> B) -> (A ~> C)
-- Equality of arrows (as we don't have function extensionality)
_≈_ : {A B : obj} -> (A ~> B) -> (A ~> B) -> Set n
-- || Laws
-- Left identity
id-left : {A B : obj} {f : A ~> B} -> id ∘ f ≈ f
-- Right identity
id-right : {A B : obj} {f : A ~> B} -> f ∘ id ≈ f
-- Associativity of composition
∘-assoc : {A B C D : obj} {f : C ~> D} {g : B ~> C} {h : A ~> B}
-> (f ∘ g) ∘ h ≈ f ∘ (g ∘ h)
-- Arrow equality is an equivalence relation
≈-equiv : ∀{A B : obj} -> IsEquivalence (_≈_ {A} {B})
-- Congruence of equality and composition
≈-cong : ∀{A B C : obj} {f f′ : A ~> B} {g g′ : B ~> C}
-> f ≈ f′ -> g ≈ g′ -> g ∘ f ≈ g′ ∘ f′
-- Equational reasoning for ≈ (based on the standard library definitions)
infix 3 _∎
infixr 2 _≈⟨⟩_ _≈⟨_⟩_
infix 1 begin_
infixl 20 _[sym]
infixr 15 _≈>_
begin_ : ∀{A B : obj} {x y : A ~> B} → x ≈ y → x ≈ y
begin_ x≈y = x≈y
_≈⟨⟩_ : ∀{A B : obj} (x {y} : A ~> B) → x ≈ y → x ≈ y
_ ≈⟨⟩ x≈y = x≈y
_≈⟨_⟩_ : ∀{A B : obj} (x {y z} : A ~> B) → x ≈ y → y ≈ z → x ≈ z
_ ≈⟨ x≈y ⟩ y≈z = IsEquivalence.trans ≈-equiv x≈y y≈z
_∎ : ∀{A B : obj} (x : A ~> B) → x ≈ x
_∎ _ = IsEquivalence.refl ≈-equiv
r≈ : ∀{A B : obj} {x : A ~> B} → x ≈ x
r≈ = IsEquivalence.refl ≈-equiv
_[sym] : ∀{A B : obj} {x y : A ~> B} → x ≈ y → y ≈ x
p [sym] = IsEquivalence.sym ≈-equiv p
_≈>_ : ∀{A B : obj} {x y z : A ~> B} → x ≈ y → y ≈ z → x ≈ z
p1 ≈> p2 = IsEquivalence.trans ≈-equiv p1 p2
id-comm : {A B : obj} {f : A ~> B} -> f ∘ id ≈ id ∘ f
id-comm = id-right ≈> id-left [sym]
-- Derived congruence properties
≈-cong-left : ∀{A B C : obj} {f : A ~> B} {g g′ : B ~> C}
-> g ≈ g′ -> g ∘ f ≈ g′ ∘ f
≈-cong-left e = ≈-cong r≈ e
≈-cong-right : ∀{A B C : obj} {g : B ~> C} {f f′ : A ~> B}
-> f ≈ f′ -> g ∘ f ≈ g ∘ f′
≈-cong-right e = ≈-cong e r≈
-- Isomorphism of two objects
record _<~>_ (A B : obj) : Set (lsuc n) where
field
-- | Data
-- Arrow in one direction
iso~> : A ~> B
-- Arrow in other direction
iso<~ : B ~> A
-- | Laws
iso-id₁ : iso<~ ∘ iso~> ≈ id {A}
iso-id₂ : iso~> ∘ iso<~ ≈ id {B}
| {
"alphanum_fraction": 0.4663890541,
"avg_line_length": 32.9607843137,
"ext": "agda",
"hexsha": "efcfea1f50c7a17770f3427054afa1f282193ac6",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DimaSamoz/temporal-type-systems",
"max_forks_repo_path": "src/CategoryTheory/Categories.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DimaSamoz/temporal-type-systems",
"max_issues_repo_path": "src/CategoryTheory/Categories.agda",
"max_line_length": 77,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DimaSamoz/temporal-type-systems",
"max_stars_repo_path": "src/CategoryTheory/Categories.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-04T09:33:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-05-31T20:37:04.000Z",
"num_tokens": 1308,
"size": 3362
} |
module GGT.Group.Structures
{a b ℓ}
where
open import Relation.Unary using (Pred)
open import Relation.Binary
open import Algebra.Bundles using (Group)
open import Level
open import GGT.Group.Definitions
record IsSubGroup (G : Group a ℓ) (P : Pred (Group.Carrier G) b) : Set (a ⊔ b ⊔ ℓ) where
open Group G
field
ε∈ : (P ε)
∙-⁻¹-closed : IsOpInvClosed G P
r : P Respects _≈_
-- coset relation
_∼_ : Rel Carrier b
x ∼ y = P (x - y)
syntax IsSubGroup G P = P ≤ G
| {
"alphanum_fraction": 0.6591836735,
"avg_line_length": 21.3043478261,
"ext": "agda",
"hexsha": "da9dd97a7026e400d19ce1f9f4e7e4064f16a202",
"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": "e2d6b5f9bea15dd67817bf67e273f6b9a14335af",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "zampino/ggt",
"max_forks_repo_path": "src/ggt/group/Structures.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e2d6b5f9bea15dd67817bf67e273f6b9a14335af",
"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": "zampino/ggt",
"max_issues_repo_path": "src/ggt/group/Structures.agda",
"max_line_length": 88,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "e2d6b5f9bea15dd67817bf67e273f6b9a14335af",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "zampino/ggt",
"max_stars_repo_path": "src/ggt/group/Structures.agda",
"max_stars_repo_stars_event_max_datetime": "2020-11-28T05:48:39.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-17T11:10:00.000Z",
"num_tokens": 174,
"size": 490
} |
{-# OPTIONS --type-in-type #-}
module Structure where
open import Data.Nat
open import Prelude
record Struct (A : Set) : Set where
field
ℜ : {n : ℕ} → A ^ n → Set
𝔉 : {n : ℕ} → A ^ n → A
| {
"alphanum_fraction": 0.57,
"avg_line_length": 16.6666666667,
"ext": "agda",
"hexsha": "eb3f62b80a468c51e64ac0655062001cb661e09d",
"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": "6cd093011923758a21663bc32b5a63ce7893e049",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "vikraman/agda-structures",
"max_forks_repo_path": "Structure.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "6cd093011923758a21663bc32b5a63ce7893e049",
"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": "vikraman/agda-structures",
"max_issues_repo_path": "Structure.agda",
"max_line_length": 35,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "6cd093011923758a21663bc32b5a63ce7893e049",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "vikraman/agda-structures",
"max_stars_repo_path": "Structure.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 68,
"size": 200
} |
module ctxt-types where
open import lib
open import cedille-types
open import general-util
open import syntax-util
location : Set
location = string × posinfo -- file path and starting position in the file
-- file path and starting / ending position in file
span-location = string × posinfo × posinfo
-- missing locations
missing-location : location
missing-location = ("missing" , "missing")
missing-span-location : span-location
missing-span-location = ("missing" , "missing" , "missing")
{- we will generally keep classifiers of variables in hnf in the ctxt, although
we will not necessarily unfold recursive type definitions. -}
defScope : Set
defScope = 𝔹
localScope : defScope
localScope = tt
globalScope : defScope
globalScope = ff
defParams : Set
defParams = maybe params
data ctxt-info : Set where
-- for defining a datatype
datatype-def : params → kind → ctxt-info
-- for defining a datatype constructor
const-def : type → ctxt-info
-- for declaring a variable to have a given type (with no definition)
term-decl : type → ctxt-info
-- for defining a variable to equal a term with a given type
term-def : defParams → opacity → term → type → ctxt-info
-- for untyped term definitions
term-udef : defParams → opacity → term → ctxt-info
-- for declaring a variable to have a given kind (with no definition)
type-decl : kind → ctxt-info
-- for defining a variable to equal a type with a given kind
type-def : defParams → opacity → type → kind → ctxt-info
-- for defining a variable to equal a kind
kind-def : params → kind → ctxt-info
-- to rename a variable at any level to another
rename-def : var → ctxt-info
-- representing a declaration of a variable with no other information about it
var-decl : ctxt-info
sym-info : Set
sym-info = ctxt-info × location
-- module filename, name, parameters, and qualifying substitution
mod-info : Set
mod-info = string × string × params × qualif
-- datatypes info
datatype-info : Set
datatype-info = defDatatype
is-term-level : ctxt-info → 𝔹
is-term-level (term-decl _) = tt
is-term-level (term-def _ _ _ _) = tt
is-term-level (term-udef _ _ _) = tt
is-term-level (const-def _ ) = tt
is-term-level _ = ff
data ctxt : Set where
mk-ctxt : (mod : mod-info) → -- current module
(syms : trie (string × 𝕃 string) × trie string × trie params × trie ℕ × Σ ℕ (𝕍 string)) → -- map each filename to its module name and the symbols declared in that file, map each module name to its filename and params, and file ID's for use in to-string.agda
(i : trie sym-info) → -- map symbols (from Cedille files) to their ctxt-info and location
(sym-occurrences : trie (𝕃 (var × posinfo × string))) → -- map symbols to a list of definitions they occur in (and relevant file info)
(datatypes-info : trie datatype-info) →
ctxt
ctxt-binds-var : ctxt → var → 𝔹
ctxt-binds-var (mk-ctxt (_ , _ , _ , q) _ i _ _) x = trie-contains q x || trie-contains i x
ctxt-var-decl : var → ctxt → ctxt
ctxt-var-decl v (mk-ctxt (fn , mn , ps , q) syms i symb-occs d) =
mk-ctxt (fn , mn , ps , (trie-insert q v (v , ArgsNil))) syms (trie-insert i v (var-decl , "missing" , "missing")) symb-occs d
ctxt-var-decl-loc : posinfo → var → ctxt → ctxt
ctxt-var-decl-loc pi v (mk-ctxt (fn , mn , ps , q) syms i symb-occs d) =
mk-ctxt (fn , mn , ps , (trie-insert q v (v , ArgsNil))) syms (trie-insert i v (var-decl , fn , pi)) symb-occs d
qualif-var : ctxt → var → var
qualif-var (mk-ctxt (_ , _ , _ , q) _ _ _ _) v with trie-lookup q v
...| just (v' , _) = v'
...| nothing = v
start-modname : start → string
start-modname (File _ _ _ _ mn _ _ _) = mn
ctxt-get-current-filename : ctxt → string
ctxt-get-current-filename (mk-ctxt (fn , _) _ _ _ _) = fn
ctxt-get-current-mod : ctxt → mod-info
ctxt-get-current-mod (mk-ctxt m _ _ _ _) = m
ctxt-get-current-modname : ctxt → string
ctxt-get-current-modname (mk-ctxt (_ , mn , _ , _) _ _ _ _) = mn
ctxt-get-current-params : ctxt → params
ctxt-get-current-params (mk-ctxt (_ , _ , ps , _) _ _ _ _) = ps
ctxt-get-symbol-occurrences : ctxt → trie (𝕃 (var × posinfo × string))
ctxt-get-symbol-occurrences (mk-ctxt _ _ _ symb-occs _) = symb-occs
ctxt-set-symbol-occurrences : ctxt → trie (𝕃 (var × posinfo × string)) → ctxt
ctxt-set-symbol-occurrences (mk-ctxt fn syms i symb-occs d) new-symb-occs = mk-ctxt fn syms i new-symb-occs d
| {
"alphanum_fraction": 0.6720538721,
"avg_line_length": 34.0076335878,
"ext": "agda",
"hexsha": "0f303e5e3e51ee2dc068d5fefee2331b014f370e",
"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": "acf691e37210607d028f4b19f98ec26c4353bfb5",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "xoltar/cedille",
"max_forks_repo_path": "src/ctxt-types.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "acf691e37210607d028f4b19f98ec26c4353bfb5",
"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": "xoltar/cedille",
"max_issues_repo_path": "src/ctxt-types.agda",
"max_line_length": 272,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "acf691e37210607d028f4b19f98ec26c4353bfb5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "xoltar/cedille",
"max_stars_repo_path": "src/ctxt-types.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1266,
"size": 4455
} |
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
-- This module contains definitions allowing RWS programs to be written using
-- Agda's do-notation, as well as convenient short names for operations
-- (including lens operations).
module Dijkstra.RWS.Syntax where
open import Dijkstra.RWS
open import Dijkstra.Syntax
open import Haskell.Modules.RWS public
open import Haskell.Modules.RWS.Lens public
open import Haskell.Modules.RWS.RustAnyHow public
open import Haskell.Prelude
open import Level
renaming (suc to ℓ+1; zero to ℓ0; _⊔_ to _ℓ⊔_)
public
private
variable
Ev Wr St : Set
A B C : Set
-- These instance declarations give us variant conditional operations that we
-- can define to play nice with `RWS-weakestPre`
instance
RWS-MonadIfD : MonadIfD{ℓ₃ = ℓ0} (RWS Ev Wr St)
MonadIfD.monad RWS-MonadIfD = RWS-Monad
MonadIfD.ifD‖ RWS-MonadIfD = RWS-if
RWS-MonadMaybeD : MonadMaybeD (RWS Ev Wr St)
MonadMaybeD.monad RWS-MonadMaybeD = RWS-Monad
MonadMaybeD.maybeD RWS-MonadMaybeD = RWS-maybe
RWS-MonadEitherD : MonadEitherD (RWS Ev Wr St)
MonadEitherD.monad RWS-MonadEitherD = RWS-Monad
MonadEitherD.eitherD RWS-MonadEitherD = RWS-either
maybeM : RWS Ev Wr St B → (A → RWS Ev Wr St B) → RWS Ev Wr St (Maybe A) → RWS Ev Wr St B
maybeM mb f mma = do
x ← mma
caseMD x of λ where
nothing → mb
(just j) → f j
maybeMP-RWS : B → (A → RWS Ev Wr St B)
→ RWS Ev Wr St (Maybe A)
→ RWS Ev Wr St B
maybeMP-RWS b f ma = do
x ← ma
caseMD x of λ where
nothing → pure b
(just j) → f j
RWS-weakestPre-∙^∙Post : (ev : Ev) (e : C → C) → RWS-Post Wr St (Either C A) → RWS-Post Wr St (Either C A)
RWS-weakestPre-∙^∙Post ev e Post =
RWS-weakestPre-bindPost ev (either (bail ∘ e) ok) Post
| {
"alphanum_fraction": 0.7002544529,
"avg_line_length": 30.703125,
"ext": "agda",
"hexsha": "f97ddee71054662391c418ccf0616e1f8f7db864",
"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/Dijkstra/RWS/Syntax.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/Dijkstra/RWS/Syntax.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/Dijkstra/RWS/Syntax.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 670,
"size": 1965
} |
{-# OPTIONS --rewriting --prop #-}
open import common
open import common using (_===_)
open import syntx
open import derivability
open import structuralrules
open import typingrules
{- Type theories -}
Σ₀ : Signature
Symbols Σ₀ ar = Empty
E₀ : DerivabilityStructure Σ₀
E₀ = StructuralRules Σ₀
data TypeTheory : Set
TTSig : TypeTheory → Signature
TTDer : (t : TypeTheory) → DerivabilityStructure (TTSig t)
data TypeTheory where
◇ : TypeTheory
_,_ : (t : TypeTheory) {ar : SyntaxArity} (r : TypingRule (TTDer t) (args ar) (sort ar)) → TypeTheory
_,=_ : (t : TypeTheory) {ar : SyntaxArityArgs} {k : SyntaxSort} (r : EqualityRule (TTDer t) ar k) → TypeTheory
TTSig ◇ = Σ₀
TTSig (_,_ t {ar} r) = ExtSig (TTSig t) ar
TTSig (t ,= _) = TTSig t
TTDer ◇ = E₀
TTDer (t , r) = extend (TTDer t) (TRules r)
TTDer (t ,= r) = extendE (TTDer t) (ERule r)
{- Instances to make it possible to use numeric literals to refer to symbols and typing rules -}
instance
NumΣ₀ : Number Empty
Number.Constraint NumΣ₀ n = Empty
NumExtSig : {A : SyntaxArity → Set} {ar ar' : SyntaxArity} {{_ : Number (A ar')}} → Number (ExtSigSymbols A ar ar')
Number.Constraint (NumExtSig {ar = ar} {ar'}) zero = ar === ar'
Number.Constraint (NumExtSig {{r}}) (suc n) = Number.Constraint r n
Number.fromNat NumExtSig zero {{refl}} = new
Number.fromNat (NumExtSig {{r}}) (suc n) = prev (Number.fromNat r n)
instance
NumExtT : {A : JudgmentArity → Set} {ar : SyntaxArity} {ar' : JudgmentArity} {{_ : Number (A ar')}} → Number (ExtT A ar ar')
Number.Constraint (NumExtT {ar = ar} {ar'}) zero = TArity ar === ar'
Number.Constraint (NumExtT {{r}}) (suc n) = Number.Constraint r n
Number.fromNat NumExtT zero {{refl}} = typingrule
Number.fromNat (NumExtT {{r}}) (suc n) = prev (Number.fromNat r n)
NumExtC : {A : JudgmentArity → Set} {ar : SyntaxArity} {ar' : JudgmentArity} {{_ : Number (A ar')}} → Number (ExtC A ar ar')
Number.Constraint (NumExtC {ar = ar} {ar'}) zero = CArity ar === ar'
Number.Constraint (NumExtC {{r}}) (suc n) = Number.Constraint r n
Number.fromNat NumExtC zero {{refl}} = congruencerule
Number.fromNat (NumExtC {{r}}) (suc n) = prev (Number.fromNat r n)
NumExtE : {A : JudgmentArity → Set} {nar ar' : JudgmentArity} {{_ : Number (A ar')}} → Number (ExtE A nar ar')
Number.Constraint (NumExtE {nar = nar} {ar'}) zero = nar === ar'
Number.Constraint (NumExtE {{r}}) (suc n) = Number.Constraint r n
Number.fromNat NumExtE zero {{refl}} = equalityrule
Number.fromNat (NumExtE {{r}}) (suc n) = prev (Number.fromNat r n)
| {
"alphanum_fraction": 0.6618395303,
"avg_line_length": 38.1343283582,
"ext": "agda",
"hexsha": "72deec14a20f02f50570ef94787b406b56fe7ac7",
"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": "f9bfefd0a70ae5bdc3906829ee1165c731882bca",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "guillaumebrunerie/general-type-theories",
"max_forks_repo_path": "typetheories.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f9bfefd0a70ae5bdc3906829ee1165c731882bca",
"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": "guillaumebrunerie/general-type-theories",
"max_issues_repo_path": "typetheories.agda",
"max_line_length": 126,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "f9bfefd0a70ae5bdc3906829ee1165c731882bca",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "guillaumebrunerie/general-type-theories",
"max_stars_repo_path": "typetheories.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 863,
"size": 2555
} |
open import Agda.Builtin.Nat
data Bal : Nat → Nat → Nat → Set where
leanR : ∀ {n} → Bal n (suc n) (suc n)
leanL : ∀ {n} → Bal (suc n) n (suc n)
data Tree : Nat → Set where
leaf : Tree 0
node : ∀ {hˡ hʳ h} (t : Tree hʳ) (b : Bal hˡ hʳ h) → Tree (suc h)
join : ∀ {hˡ hʳ} h → Bal hˡ hʳ h → Tree (suc hˡ) → Nat
join _ leanL (node (node t b) leanR) = 0
join (suc _) leanL (node t leanL) = 1
join _ leanR t₁ = 2
| {
"alphanum_fraction": 0.5152173913,
"avg_line_length": 28.75,
"ext": "agda",
"hexsha": "0ad9adbbce306f2919b53003eac33bcb3e47e5a8",
"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/Issue4179.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/Issue4179.agda",
"max_line_length": 67,
"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/Issue4179.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": 201,
"size": 460
} |
------------------------------------------------------------------------
-- Lemmas related to weak bisimilarity and CCS
------------------------------------------------------------------------
{-# OPTIONS --sized-types #-}
open import Prelude hiding (step-→)
module Bisimilarity.Weak.CCS {ℓ} {Name : Type ℓ} where
open import Equality.Propositional
open import Prelude.Size
open import Function-universe equality-with-J hiding (id; _∘_)
import Bisimilarity.CCS as SE
import Bisimilarity.Equational-reasoning-instances
import Bisimilarity.Weak.Equational-reasoning-instances
open import Equational-reasoning
import Expansion.CCS as E
import Expansion.Equational-reasoning-instances
open import Labelled-transition-system.CCS Name
import Bisimilarity CCS as S
open import Bisimilarity.Weak CCS
open import Expansion CCS using (_≳_; ≳:_)
import Labelled-transition-system.Equational-reasoning-instances CCS
as Dummy
-- An instantiation of a module with helper lemmas.
private
module CL {i} =
E.Cong-lemmas
[ i ]_≈′_ right-to-left (⇒̂→[]⇒ (λ ())) ⇒→⇒̂
map-⇒̂ map-⇒̂′ zip-⇒̂
(λ hyp {P Q} → λ where
(silent s done) →
_
, (! P →⟨ silent s done ⟩■)
, (! P ∼⟨ symmetric SE.6-1-2 ⟩
! P ∣ P ∼≡⟨ refl ⟩■
! P ∣ Q)
(silent s (step {q = R} s′ P⟶R R⇒Q)) →
_
, (! P →⟨ ⟶→⇒ s′ (replication (par-right P⟶R)) ⟩
! P ∣ R →⟨ silent s (map-⇒ par-right R⇒Q) ⟩■)
, (! P ∣ Q ■)
(non-silent ¬s P⇒Q) →
_
, (! P →⟨ non-silent ¬s (hyp P⇒Q) ⟩■)
, (! P ∣ Q ■))
mutual
-- _∣_ preserves weak bisimilarity.
infix 6 _∣-cong_ _∣-cong′_
_∣-cong_ : ∀ {i P P′ Q Q′} →
[ i ] P ≈ P′ → [ i ] Q ≈ Q′ → [ i ] P ∣ Q ≈ P′ ∣ Q′
P≈P′ ∣-cong Q≈Q′ =
⟨ Σ-map id (Σ-map id symmetric) ∘
rl (symmetric P≈P′) (symmetric Q≈Q′)
, rl P≈P′ Q≈Q′
⟩
where
rl = CL.∣-cong _∣-cong′_
_∣-cong′_ : ∀ {i P P′ Q Q′} →
[ i ] P ≈′ P′ → [ i ] Q ≈′ Q′ → [ i ] P ∣ Q ≈′ P′ ∣ Q′
force (P≈P′ ∣-cong′ Q≈Q′) = force P≈P′ ∣-cong force Q≈Q′
-- _·_ preserves weak bisimilarity.
infix 12 _·-cong_ _·-cong′_
_·-cong_ :
∀ {i μ μ′ P P′} →
μ ≡ μ′ → [ i ] force P ≈′ force P′ → [ i ] μ · P ≈ μ′ · P′
_·-cong_ {i} refl P≈P′ =
⟨ Σ-map id (Σ-map id symmetric) ∘ rl (symmetric P≈P′)
, rl P≈P′
⟩
where
rl = CL.·-cong {i = i}
_·-cong′_ :
∀ {i μ μ′ P P′} →
μ ≡ μ′ → [ i ] force P ≈′ force P′ → [ i ] μ · P ≈′ μ′ · P′
force (μ≡μ′ ·-cong′ P≈P′) = μ≡μ′ ·-cong P≈P′
-- _∙_ preserves weak bisimilarity.
infix 12 _∙-cong_ _∙-cong′_
_∙-cong_ : ∀ {i μ μ′ P P′} →
μ ≡ μ′ → [ i ] P ≈ P′ → [ i ] μ ∙ P ≈ μ′ ∙ P′
refl ∙-cong P≈P′ = refl ·-cong convert {a = ℓ} P≈P′
_∙-cong′_ : ∀ {i μ μ′ P P′} →
μ ≡ μ′ → [ i ] P ≈′ P′ → [ i ] μ ∙ P ≈′ μ′ ∙ P′
force (μ≡μ′ ∙-cong′ P≈P′) = μ≡μ′ ∙-cong force P≈P′
-- _∙ turns equal actions into weakly bisimilar processes.
infix 12 _∙-cong _∙-cong′
_∙-cong : ∀ {μ μ′} → μ ≡ μ′ → μ ∙ ≈ μ′ ∙
refl ∙-cong = reflexive
_∙-cong′ : ∀ {μ μ′} → μ ≡ μ′ → μ ∙ ≈′ μ′ ∙
refl ∙-cong′ = reflexive
mutual
-- ⟨ν_⟩ preserves weak bisimilarity.
⟨ν_⟩-cong : ∀ {i a a′ P P′} →
a ≡ a′ → [ i ] P ≈ P′ → [ i ] ⟨ν a ⟩ P ≈ ⟨ν a′ ⟩ P′
⟨ν_⟩-cong {i} {a} {P = P} {P′} refl P≈P′ =
⟨ Σ-map id (Σ-map id symmetric) ∘
CL.⟨ν⟩-cong ⟨ν refl ⟩-cong′ (symmetric P≈P′)
, CL.⟨ν⟩-cong ⟨ν refl ⟩-cong′ P≈P′
⟩
⟨ν_⟩-cong′ : ∀ {i a a′ P P′} →
a ≡ a′ → [ i ] P ≈′ P′ → [ i ] ⟨ν a ⟩ P ≈′ ⟨ν a′ ⟩ P′
force (⟨ν a≡a′ ⟩-cong′ P≈P′) = ⟨ν a≡a′ ⟩-cong (force P≈P′)
mutual
-- !_ preserves weak bisimilarity.
infix 10 !-cong_ !-cong′_
!-cong_ : ∀ {i P P′} →
[ i ] P ≈ P′ → [ i ] ! P ≈ ! P′
!-cong_ {i} {P} {P′} P≈P′ =
⟨ Σ-map id (Σ-map id symmetric) ∘
CL.!-cong _∣-cong′_ !-cong′_ (symmetric P≈P′)
, CL.!-cong _∣-cong′_ !-cong′_ P≈P′
⟩
!-cong′_ : ∀ {i P P′} → [ i ] P ≈′ P′ → [ i ] ! P ≈′ ! P′
force (!-cong′ P≈P′) = !-cong (force P≈P′)
-- _⊕_ does not, in general, preserve weak bisimilarity in its first
-- argument (assuming that Name is inhabited).
¬⊕-congˡ : Name → ¬ (∀ {P P′ Q} → P ≈ P′ → P ⊕ Q ≈ P′ ⊕ Q)
¬⊕-congˡ x =
(∀ {P P′ Q} → P ≈ P′ → P ⊕ Q ≈ P′ ⊕ Q) ↝⟨ _∘ ≳⇒≈ ⟩
(∀ {P P′ Q} → P ≳ P′ → P ⊕ Q ≈ P′ ⊕ Q) ↝⟨ E.¬⊕-congˡ-≳≈ x ⟩□
⊥ □
-- _⊕_ does not, in general, preserve weak bisimilarity in its second
-- argument (assuming that Name is inhabited).
¬⊕-congʳ : Name → ¬ (∀ {P Q Q′} → Q ≈ Q′ → P ⊕ Q ≈ P ⊕ Q′)
¬⊕-congʳ x =
(∀ {P Q Q′} → Q ≈ Q′ → P ⊕ Q ≈ P ⊕ Q′) ↝⟨ _∘ ≳⇒≈ ⟩
(∀ {P Q Q′} → Q ≳ Q′ → P ⊕ Q ≈ P ⊕ Q′) ↝⟨ E.¬⊕-congʳ-≳≈ x ⟩□
⊥ □
-- Some congruence lemmas for combinations of _⊕_ and _·_.
⊕·-cong :
∀ {i P μ Q Q′} →
[ i ] force Q ≈′ force Q′ → [ i ] P ⊕ μ · Q ≈ P ⊕ μ · Q′
⊕·-cong {i} Q≈Q′ =
⟨ Σ-map id (Σ-map id symmetric) ∘ CL.⊕·-cong (symmetric Q≈Q′)
, CL.⊕·-cong {i = i} Q≈Q′
⟩
⊕·-cong′ :
∀ {i P μ Q Q′} →
[ i ] force Q ≈′ force Q′ → [ i ] P ⊕ μ · Q ≈′ P ⊕ μ · Q′
force (⊕·-cong′ Q≈Q′) = ⊕·-cong Q≈Q′
·⊕-cong : ∀ {i P P′ μ Q} →
[ i ] force P ≈′ force P′ → [ i ] μ · P ⊕ Q ≈ μ · P′ ⊕ Q
·⊕-cong {P = P} {P′} {μ} {Q} P≈P′ =
μ · P ⊕ Q ∼⟨ SE.⊕-comm ⟩
Q ⊕ μ · P ∼′⟨ ⊕·-cong P≈P′ ⟩ S.∼:
Q ⊕ μ · P′ ∼⟨ SE.⊕-comm ⟩■
μ · P′ ⊕ Q
·⊕-cong′ :
∀ {i P P′ μ Q} →
[ i ] force P ≈′ force P′ → [ i ] μ · P ⊕ Q ≈′ μ · P′ ⊕ Q
force (·⊕-cong′ P≈P′) = ·⊕-cong P≈P′
infix 8 _·⊕·-cong_ _·⊕·-cong′_
_·⊕·-cong_ :
∀ {i μ₁ μ₂ P₁ P₁′ P₂ P₂′} →
[ i ] force P₁ ≈′ force P₁′ → [ i ] force P₂ ≈′ force P₂′ →
[ i ] μ₁ · P₁ ⊕ μ₂ · P₂ ≈ μ₁ · P₁′ ⊕ μ₂ · P₂′
_·⊕·-cong_ {i} P₁≈P₁′ P₂≈P₂′ =
⟨ Σ-map id (Σ-map id symmetric) ∘
CL.·⊕·-cong (symmetric P₁≈P₁′) (symmetric P₂≈P₂′)
, CL.·⊕·-cong {i = i} P₁≈P₁′ P₂≈P₂′
⟩
_·⊕·-cong′_ :
∀ {i μ₁ μ₂ P₁ P₁′ P₂ P₂′} →
[ i ] force P₁ ≈′ force P₁′ → [ i ] force P₂ ≈′ force P₂′ →
[ i ] μ₁ · P₁ ⊕ μ₂ · P₂ ≈′ μ₁ · P₁′ ⊕ μ₂ · P₂′
force (P₁≈′P₁′ ·⊕·-cong′ P₂≈′P₂′) = P₁≈′P₁′ ·⊕·-cong P₂≈′P₂′
-- _[_] preserves weak bisimilarity for non-degenerate contexts. (This
-- result is similar to Theorem 6.5.25 in "Enhancements of the
-- bisimulation proof method" by Pous and Sangiorgi.)
--
-- TODO: This definition is very similar to E._[_]-cong. Find some way
-- to reduce the code duplication. (There was much less code
-- duplication before contexts were made coinductive.)
infix 5 _[_]-cong _[_]-cong′
_[_]-cong :
∀ {i n Ps Qs} {C : Context ∞ n} →
Non-degenerate ∞ C → (∀ x → [ i ] Ps x ≈ Qs x) →
[ i ] C [ Ps ] ≈ C [ Qs ]
hole [ Ps≈Qs ]-cong = Ps≈Qs _
∅ [ Ps≈Qs ]-cong = reflexive
D₁ ∣ D₂ [ Ps≈Qs ]-cong = (D₁ [ Ps≈Qs ]-cong) ∣-cong (D₂ [ Ps≈Qs ]-cong)
action D [ Ps≈Qs ]-cong = refl ·-cong λ { .force → force D [ Ps≈Qs ]-cong }
⟨ν⟩ D [ Ps≈Qs ]-cong = ⟨ν refl ⟩-cong (D [ Ps≈Qs ]-cong)
! D [ Ps≈Qs ]-cong = !-cong (D [ Ps≈Qs ]-cong)
D₁ ⊕ D₂ [ Ps≈Qs ]-cong = ⊕-cong Ps≈Qs D₁ D₂
where
_[_]-cong′ :
∀ {i n Ps Qs} {C : Context ∞ n} →
Non-degenerate′ ∞ C → (∀ x → [ i ] Ps x ≈ Qs x) →
[ i ] C [ Ps ] ≈′ C [ Qs ]
force (D [ Ps≈Qs ]-cong′) = force D [ Ps≈Qs ]-cong
⊕-cong :
∀ {i n Ps Qs} {C₁ C₂ : Context ∞ n} →
(∀ x → [ i ] Ps x ≈ Qs x) →
Non-degenerate-summand ∞ C₁ →
Non-degenerate-summand ∞ C₂ →
[ i ] (C₁ [ Ps ]) ⊕ (C₂ [ Ps ]) ≈ (C₁ [ Qs ]) ⊕ (C₂ [ Qs ])
⊕-cong {Ps = Ps} {Qs} Ps≈Qs = λ where
(process P₁) (process P₂) →
(context P₁ [ Ps ]) ⊕ (context P₂ [ Ps ]) ∼⟨ symmetric (SE.≡→∼ (context-[] P₁) SE.⊕-cong SE.≡→∼ (context-[] P₂)) ⟩
P₁ ⊕ P₂ ∼⟨ SE.≡→∼ (context-[] P₁) SE.⊕-cong SE.≡→∼ (context-[] P₂) ⟩■
(context P₁ [ Qs ]) ⊕ (context P₂ [ Qs ])
(process P₁) (action {μ = μ₂} {C = C₂} D₂) →
(context P₁ [ Ps ]) ⊕ μ₂ · (C₂ [ Ps ]′) ∼⟨ symmetric (SE.≡→∼ (context-[] P₁)) SE.⊕-cong (_ ■) ⟩
P₁ ⊕ μ₂ · (C₂ [ Ps ]′) ∼′⟨ ⊕·-cong (D₂ [ Ps≈Qs ]-cong′) ⟩ S.∼:
P₁ ⊕ μ₂ · (C₂ [ Qs ]′) ∼⟨ SE.≡→∼ (context-[] P₁) SE.⊕-cong (_ ■) ⟩■
(context P₁ [ Qs ]) ⊕ μ₂ · (C₂ [ Qs ]′)
(action {μ = μ₁} {C = C₁} D₁) (process P₂) →
μ₁ · (C₁ [ Ps ]′) ⊕ (context P₂ [ Ps ]) ∼⟨ (_ ■) SE.⊕-cong symmetric (SE.≡→∼ (context-[] P₂)) ⟩
μ₁ · (C₁ [ Ps ]′) ⊕ P₂ ∼′⟨ ·⊕-cong (D₁ [ Ps≈Qs ]-cong′) ⟩ S.∼:
μ₁ · (C₁ [ Qs ]′) ⊕ P₂ ∼⟨ (_ ■) SE.⊕-cong SE.≡→∼ (context-[] P₂) ⟩■
μ₁ · (C₁ [ Qs ]′) ⊕ (context P₂ [ Qs ])
(action {μ = μ₁} {C = C₁} D₁) (action {μ = μ₂} {C = C₂} D₂) →
μ₁ · (C₁ [ Ps ]′) ⊕ μ₂ · (C₂ [ Ps ]′) ∼⟨ (D₁ [ Ps≈Qs ]-cong′) ·⊕·-cong (D₂ [ Ps≈Qs ]-cong′) ⟩■
μ₁ · (C₁ [ Qs ]′) ⊕ μ₂ · (C₂ [ Qs ]′)
_[_]-cong′ :
∀ {i n Ps Qs} {C : Context ∞ n} →
Non-degenerate ∞ C → (∀ x → [ i ] Ps x ≈′ Qs x) →
[ i ] C [ Ps ] ≈′ C [ Qs ]
force (C [ Ps≈Qs ]-cong′) = C [ (λ x → force (Ps≈Qs x)) ]-cong
-- A variant of _[_]-cong for weakly guarded contexts.
--
-- Note that the input uses the primed variant of weak bisimilarity.
--
-- I got the idea for this lemma from Lemma 23 in Schäfer and Smolka's
-- "Tower Induction and Up-to Techniques for CCS with Fixed Points".
[]-cong-w :
∀ {i n Ps Qs} {C : Context ∞ n} →
Weakly-guarded C → Non-degenerate ∞ C → (∀ x → [ i ] Ps x ≈′ Qs x) →
[ i ] C [ Ps ] ≈ C [ Qs ]
[]-cong-w () hole
[]-cong-w _ ∅ Ps≈Qs = reflexive
[]-cong-w (W₁ ∣ W₂) (D₁ ∣ D₂) Ps≈Qs = []-cong-w W₁ D₁ Ps≈Qs ∣-cong
[]-cong-w W₂ D₂ Ps≈Qs
[]-cong-w action (action D) Ps≈Qs = refl ·-cong
(force D [ Ps≈Qs ]-cong′)
[]-cong-w (⟨ν⟩ W) (⟨ν⟩ D) Ps≈Qs = ⟨ν refl ⟩-cong
([]-cong-w W D Ps≈Qs)
[]-cong-w (! W) (! D) Ps≈Qs = !-cong []-cong-w W D Ps≈Qs
[]-cong-w {Ps = Ps} {Qs}
(W₁ ⊕ W₂) (D₁ ⊕ D₂) Ps≈Qs = case D₁ ,′ D₂ of λ where
(process P₁ , process P₂) →
(context P₁ [ Ps ]) ⊕ (context P₂ [ Ps ]) ∼⟨ symmetric (SE.≡→∼ (context-[] P₁) SE.⊕-cong SE.≡→∼ (context-[] P₂)) ⟩
P₁ ⊕ P₂ ∼⟨ SE.≡→∼ (context-[] P₁) SE.⊕-cong SE.≡→∼ (context-[] P₂) ⟩■
(context P₁ [ Qs ]) ⊕ (context P₂ [ Qs ])
(process P₁ , action {μ = μ₂} {C = C₂} D₂) →
(context P₁ [ Ps ]) ⊕ μ₂ · (C₂ [ Ps ]′) ∼⟨ symmetric (SE.≡→∼ (context-[] P₁)) SE.⊕-cong (_ ■) ⟩
P₁ ⊕ μ₂ · (C₂ [ Ps ]′) ∼′⟨ ⊕·-cong (force D₂ [ Ps≈Qs ]-cong′) ⟩ S.∼:
P₁ ⊕ μ₂ · (C₂ [ Qs ]′) ∼⟨ SE.≡→∼ (context-[] P₁) SE.⊕-cong (_ ■) ⟩■
(context P₁ [ Qs ]) ⊕ μ₂ · (C₂ [ Qs ]′)
(action {μ = μ₁} {C = C₁} D₁ , process P₂) →
μ₁ · (C₁ [ Ps ]′) ⊕ (context P₂ [ Ps ]) ∼⟨ (_ ■) SE.⊕-cong symmetric (SE.≡→∼ (context-[] P₂)) ⟩
μ₁ · (C₁ [ Ps ]′) ⊕ P₂ ∼′⟨ ·⊕-cong (force D₁ [ Ps≈Qs ]-cong′) ⟩ S.∼:
μ₁ · (C₁ [ Qs ]′) ⊕ P₂ ∼⟨ (_ ■) SE.⊕-cong SE.≡→∼ (context-[] P₂) ⟩■
μ₁ · (C₁ [ Qs ]′) ⊕ (context P₂ [ Qs ])
(action {μ = μ₁} {C = C₁} D₁ , action {μ = μ₂} {C = C₂} D₂) →
μ₁ · (C₁ [ Ps ]′) ⊕ μ₂ · (C₂ [ Ps ]′) ∼⟨ (force D₁ [ Ps≈Qs ]-cong′) ·⊕·-cong (force D₂ [ Ps≈Qs ]-cong′) ⟩■
μ₁ · (C₁ [ Qs ]′) ⊕ μ₂ · (C₂ [ Qs ]′)
-- A generalisation to systems of inequations of the following
-- property: If two processes satisfy the same equation X ≳ C [ X ],
-- for a weakly guarded, non-degenerate context C, then the two
-- processes are weakly bisimilar (assuming extensionality).
--
-- This result is a variant of Bisimilarity.CCS.unique-solutions.
-- Proposition 4.4.4 in Milner's "Operational and Algebraic Semantics
-- of Concurrent Processes" is perhaps more useful in practice, as
-- well as some of the results in Sangiorgi's "Equations,
-- Contractions, and Unique Solutions".
module _ (ext : Proc-extensionality) where
mutual
unique-solutions :
∀ {i n} {Ps Qs : Fin n → Proc ∞} {C : Fin n → Context ∞ n} →
(∀ x → Weakly-guarded (C x)) →
(∀ x → Non-degenerate ∞ (C x)) →
(∀ x → Ps x ≳ C x [ Ps ]) →
(∀ x → Qs x ≳ C x [ Qs ]) →
∀ x → [ i ] Ps x ≈ Qs x
unique-solutions {i} {Ps = Ps} {Qs} {C} w nd ≳C[Ps] ≳C[Qs] x =
Ps x ∼⟨ ≳C[Ps] x ⟩
C x [ Ps ] ∼′⟨ ≈: ⟨ lr ≳C[Ps] ≳C[Qs] , Σ-map id (Σ-map id symmetric) ∘ lr ≳C[Qs] ≳C[Ps] ⟩ ⟩ ≳:
C x [ Qs ] ∽⟨ ≳C[Qs] x ⟩■
Qs x
where
lr :
∀ {Ps Qs μ P} →
(∀ x → Ps x ≳ C x [ Ps ]) →
(∀ x → Qs x ≳ C x [ Qs ]) →
C x [ Ps ] [ μ ]⟶ P →
∃ λ Q → C x [ Qs ] [ μ ]⇒̂ Q × [ i ] P ≈′ Q
lr {Ps} {Qs} {μ} ≳C[Ps] ≳C[Qs] ⟶P =
case 6-2-15-nd ext (C x) (w x) (nd x) ⟶P of λ where
(C′ , nd′ , refl , trs) →
_
, (C x [ Qs ] →⟨ trs Qs ⟩■
C′ [ Qs ])
, (C′ [ Ps ] ∼⟨ nd′ [ unique-solutions′ w nd ≳C[Ps] ≳C[Qs] ]-cong′ ⟩■
C′ [ Qs ])
unique-solutions′ :
∀ {i n} {Ps Qs : Fin n → Proc ∞} {C : Fin n → Context ∞ n} →
(∀ x → Weakly-guarded (C x)) →
(∀ x → Non-degenerate ∞ (C x)) →
(∀ x → Ps x ≳ C x [ Ps ]) →
(∀ x → Qs x ≳ C x [ Qs ]) →
∀ x → [ i ] Ps x ≈′ Qs x
force (unique-solutions′ w nd ≳C[Ps] ≳C[Qs] x) =
unique-solutions w nd ≳C[Ps] ≳C[Qs] x
| {
"alphanum_fraction": 0.4494823547,
"avg_line_length": 35.5725806452,
"ext": "agda",
"hexsha": "885572bf0680841ca2ab353f95785e670b48f563",
"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/Bisimilarity/Weak/CCS.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/Bisimilarity/Weak/CCS.agda",
"max_line_length": 121,
"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/Bisimilarity/Weak/CCS.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 6484,
"size": 13233
} |
{-# OPTIONS --without-K #-}
module sets.empty where
open import level
data ⊥ {i} : Set i where
⊥-elim : ∀ {i j}{A : Set j} → ⊥ {i} → A
⊥-elim ()
¬_ : ∀ {i} → Set i → Set i
¬ X = X → ⊥ {lzero}
infix 3 ¬_
| {
"alphanum_fraction": 0.5023923445,
"avg_line_length": 13.9333333333,
"ext": "agda",
"hexsha": "97e6985cf2fe56d1dec2d6641c05993119414a9b",
"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/sets/empty.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/sets/empty.agda",
"max_line_length": 39,
"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/sets/empty.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": 89,
"size": 209
} |
{-# OPTIONS --type-in-type #-}
module chu.lens where
open import prelude
open import functors
open import chu
open import poly.core
→∫ : Chu → ∫
→∫ (A⁺ , A⁻ ! Ω) = A⁺ , λ a⁺ → ∃ (Ω a⁺)
→Lens : {A B : Chu} → Chu[ A , B ] → ∫[ →∫ A , →∫ B ]
→Lens (f ↔ fᵗ ! †) a⁺ = f a⁺ , λ (b⁻ , fa⁺Ωb⁻) → fᵗ b⁻ , subst id († a⁺ b⁻) fa⁺Ωb⁻
module _ {A B C : Chu}
(F@(f ↔ fᵗ ! _†₁_) : Chu[ A , B ])
(G@(g ↔ gᵗ ! _†₂_) : Chu[ B , C ]) where
comp₂ : ∀ a⁺ → π₂ (→Lens (F ▸ G) a⁺)
≡ π₂ ((→Lens F ▸ →Lens G) a⁺)
comp₂ a⁺ = extensionality λ ( c⁻ , gfaΩc ) → (λ x → (fᵗ ∘ gᵗ) c⁻ , x) ⟨$⟩
subst⋯ id (f a⁺ †₂ c⁻) (a⁺ †₁ gᵗ c⁻) gfaΩc
comp∀ : ∀ a⁺ → →Lens (F ▸ G) a⁺ ≡ (→Lens F ▸ →Lens G) a⁺
comp∀ a⁺ rewrite comp₂ a⁺ = refl
instance
open Chu[_,_]
chu-lens-functor : Functor →∫
chu-lens-functor = φ: →Lens
𝒾: refl
▸: λ F G → extensionality (comp∀ F G)
| {
"alphanum_fraction": 0.430196484,
"avg_line_length": 30.21875,
"ext": "agda",
"hexsha": "fc92d74ef479febe9a9b7b0c3b5d4a2a435eafe8",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2022-01-30T11:45:57.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-07-10T17:19:37.000Z",
"max_forks_repo_head_hexsha": "425de958985aacbd3284d3057fe21fd682e315ea",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dspivak/poly",
"max_forks_repo_path": "code-examples/agda/chu/lens.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "425de958985aacbd3284d3057fe21fd682e315ea",
"max_issues_repo_issues_event_max_datetime": "2022-01-12T10:06:32.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-09-02T02:29:39.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "dspivak/poly",
"max_issues_repo_path": "code-examples/agda/chu/lens.agda",
"max_line_length": 83,
"max_stars_count": 53,
"max_stars_repo_head_hexsha": "425de958985aacbd3284d3057fe21fd682e315ea",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mstone/poly",
"max_stars_repo_path": "code-examples/agda/chu/lens.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-22T23:08:27.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-02-18T16:31:04.000Z",
"num_tokens": 473,
"size": 967
} |
open import Agda.Builtin.Equality
open import Agda.Builtin.Nat
data AB : Set where
A B : AB
foo : Nat → AB → AB
foo 0 t = A
foo (suc n) t = foo n A -- NB tail-recursive
test : foo 100000 A ≡ A
test = refl -- memory blows up here
data N : Set where
z : N
s : N → N
produce : Nat → AB → N
produce 0 t = z
produce (suc n) t = s (produce n A)
consume : N → AB → AB
consume z t = t
consume (s n) t = consume n A
test₁ : consume (produce 100000 B) A ≡ A
test₁ = refl
| {
"alphanum_fraction": 0.6028513238,
"avg_line_length": 16.9310344828,
"ext": "agda",
"hexsha": "a9a8751bdeb47e36e3f527abe7e26923a79f93ab",
"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/Issue2159.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/Issue2159.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/Issue2159.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": 179,
"size": 491
} |
open import Type
module Structure.Container.IndexedIterable {ℓᵢ} {Index : Type{ℓᵢ}} where
import Lvl
open import Data
open import Data.Boolean
open import Data.Boolean.Stmt
open import Data.Option
import Data.Option.Functions as Option
open import Data.Tuple as Tuple using (_⨯_ ; _,_)
open import Functional
open import Logic.Propositional
open import Logic.Predicate
open import Numeral.Natural
open import Numeral.Natural.Relation.Order
open import Relator.Equals
private variable ℓ ℓₑ ℓₑ₁ ℓₑ₂ : Lvl.Level
private variable T : Type{ℓ}
private variable Elem : Type{ℓₑ}
private variable i : Index
module _ (Iter : Index → Type{ℓ}) where
IsEmptyTypeFn = ∀{i} → Iter(i) → Bool
IndexStepFn : IsEmptyTypeFn → Type
IndexStepFn isEmpty = ∀{i} → (iter : Iter(i)) → (if isEmpty(iter) then Unit else Index)
CurrentFn : Type{ℓₑ} → IsEmptyTypeFn → Type
CurrentFn Element isEmpty = ∀{i} → (iter : Iter(i)) → (if isEmpty(iter) then Unit else Element)
StepFn : Type{ℓₑ} → (isEmpty : IsEmptyTypeFn) → IndexStepFn isEmpty → Type
StepFn Element isEmpty indexStep = ∀{i} → (iter : Iter(i)) → Out iter where
Out : Iter(i) → Type
Out iter with isEmpty iter | indexStep iter
... | 𝑇 | <> = Unit
... | 𝐹 | is = Iter(is)
-- An iterator type `Iter` is iterable when there may be elements that the iterator can yield in sequence.
-- It should be possible to decide whether the iterator is empty, and when it is not, get the element it points to and advancing to its next state containing the next element in order.
record Iterable (Iter : Index → Type{ℓ}) {ℓₑ} : Type{ℓ Lvl.⊔ ℓᵢ Lvl.⊔ Lvl.𝐒(ℓₑ)} where
field
-- The type of the elements in the iterator.
{Element} : Type{ℓₑ}
-- Whether there are no elements left in the iterator.
isEmpty : IsEmptyTypeFn(Iter)
-- The current/frontmost element in the iterator if it is non-empty.
current : CurrentFn(Iter) Element isEmpty
-- The next iterator index. Advances the index if the iterator is non-empty.
{indexStep} : IndexStepFn(Iter) isEmpty
-- The next iterator state. Advancing the iterator if it is non-empty.
step : StepFn(Iter) Element isEmpty indexStep
-- Whether there are at most the given number of elements in the iterator.
atMost : ℕ → Iter(i) → Bool
atMost(𝟎) iter = isEmpty(iter)
atMost(𝐒(n)) iter with isEmpty(iter) | indexStep iter | step iter
... | 𝑇 | <> | <> = 𝑇
... | 𝐹 | _ | is = atMost(n) is
-- Skipping the given number of iterator indices. Advances as many steps as possible.
indexWalk : (n : ℕ) → (iter : Iter(i)) → (if(atMost n iter) then Unit else Index)
indexWalk {i} 𝟎 iter with isEmpty(iter)
... | 𝑇 = <>
... | 𝐹 = i
indexWalk {i} (𝐒(n)) iter with isEmpty(iter) | indexStep iter | step iter
... | 𝑇 | <> | <> = <>
... | 𝐹 | _ | iters = indexWalk n iters
WalkFn : Type
WalkFn = ∀{i} → (n : ℕ) → (iter : Iter(i)) → Out n iter where
Out : ℕ → Iter(i) → Type
Out n iter with atMost n iter | indexWalk n iter
... | 𝑇 | <> = Unit
... | 𝐹 | is = Iter(is)
{-
walk : WalkFn
walk(𝟎) iter with isEmpty(iter)
... | 𝑇 = <>
... | 𝐹 = iter
walk(𝐒(n)) iter with isEmpty(iter) | indexStep iter | step iter | walk n iter
... | 𝑇 | <> | <> | _ = <>
... | 𝐹 | _ | iters | iters2 = ? -- walk n iters
-}
Foldᵣ : ∀{ℓ} → Type{ℓ} → Type
Foldᵣ(T) = ∀{i} → (Element → T → T) → T → Iter(i) → T
FoldᵣCriteria : Foldᵣ(T) → (∀{i} → (Element → T → T) → T → Iter(i) → Type)
FoldᵣCriteria foldᵣ(_▫_) id iter with isEmpty iter | indexStep iter | current iter | step iter
... | 𝑇 | <> | <> | <> = (foldᵣ(_▫_) id iter ≡ id)
... | 𝐹 | _ | x | iters = (foldᵣ(_▫_) id iter ≡ x ▫ foldᵣ(_▫_) id iters)
-- An iterator is finite when it is possible to fold it (when a fold function exists).
-- This works because a fold for an infinite iterator cannot terminate, and only terminating functions exist.
-- TODO: But it seems to be impossible to define a "foldUntil" function (though it is up to function extensionality).
Finite = ∀{ℓ}{T : Type{ℓ}} → ∃{Obj = Foldᵣ(T)}(foldᵣ ↦ ∀{i}{_▫_}{id : T}{iter : Iter(i)} → FoldᵣCriteria (\{i}(_▫_) id → foldᵣ{i}(_▫_) id) (_▫_) id iter)
module _ ⦃ fin : Finite ⦄ where
foldᵣ : ∀{i} → (Element → T → T) → T → Iter(i) → T
foldᵣ = [∃]-witness fin
length : ∀{i} → Iter(i) → ℕ
length = foldᵣ(const 𝐒) 𝟎
count : ∀{i} → (Element → Bool) → Iter(i) → ℕ
count(P) = foldᵣ(x ↦ if P(x) then 𝐒 else id) 𝟎
foldₗ : (T → Element → T) → T → Iter(i) → T
foldₗ(_▫_) = swap(foldᵣ(y ↦ f ↦ x ↦ f(x ▫ y)) id)
last : ∀{i} → Iter(i) → Option(Element)
last = foldₗ(const Some) None
-- Note: Below are possibly inefficient implementations of functions because if they were guaranteed to exit early, the number of computations would be reduced.
first : ∀{i} → Iter(i) → Option(Element)
first = foldᵣ(const ∘ Some) None
-- TODO: Complete = Surjective(step)
record Initialed (i : Index) : Type{ℓᵢ Lvl.⊔ ℓ} where
constructor initialed
eta-equality
field
iter : Iter(i)
left : ℕ
Initialed-iterable : Iterable(Initialed)
Element Initialed-iterable = Element
isEmpty Initialed-iterable (initialed iter 𝟎) = 𝑇
current Initialed-iterable (initialed iter 𝟎) = <>
indexStep Initialed-iterable (initialed iter 𝟎) = <>
step Initialed-iterable (initialed iter 𝟎) = <>
isEmpty Initialed-iterable (initialed iter (𝐒(_))) = isEmpty iter
current Initialed-iterable (initialed iter (𝐒(_))) = current iter
indexStep Initialed-iterable (initialed iter (𝐒(_))) = indexStep iter
step Initialed-iterable (initialed iter (𝐒(n))) with isEmpty iter | indexStep iter | step iter
... | 𝑇 | _ | _ = <>
... | 𝐹 | _ | sIter = initialed sIter n
{-
record Skipped (i : Index) : Type{ℓᵢ Lvl.⊔ ℓ} where
constructor skipped
eta-equality
field
iter : Iter(i)
still : ℕ
Skipped-iterable : Iterable(Skipped)
Element Skipped-iterable = Element
isEmpty Skipped-iterable (skipped iter 𝟎) = 𝑇
current Skipped-iterable (skipped iter 𝟎) = <>
indexStep Skipped-iterable (skipped iter 𝟎) = <>
step Skipped-iterable (skipped iter 𝟎) = <>
isEmpty Skipped-iterable (skipped iter (𝐒(_))) = isEmpty (walk (𝐒(n)) iter)
current Skipped-iterable (skipped iter (𝐒(_))) = current (walk (𝐒(n)) iter)
indexStep Skipped-iterable (skipped iter (𝐒(_))) = indexStep (walk (𝐒(n)) iter)
step Skipped-iterable (skipped iter (𝐒(n))) with isEmpty iter | indexStep iter | step iter
-}
mapped : (Element → Elem) → Iterable(Iter)
Element (mapped {Elem = Elem} f) = Elem
isEmpty (mapped f) = isEmpty
current (mapped f) iter with isEmpty iter | current iter
... | 𝑇 | <> = <>
... | 𝐹 | x = f(x)
indexStep (mapped f) iter = indexStep iter
step (mapped f) iter = step iter
{-record Stored (n : ℕ) {Iter : Index → Type{ℓ₁}} (iterable : Iterable(Iter)) : Type where
field
Queue(Iterator.Element(iterable))
-}
{- TODO: Also needs to store data, so it cannot be the same Iter
skipped : ℕ → Iterator{ℓₑ} → Iterator
Iterator.Element (skipped _ iterator) = Iterator.Element iterator
Iterator.isEmpty (skipped n iterator) = Iterator.atMost n iterator
Iterator.current (skipped _ iterator) =
Iterator.indexStep (skipped iterator) =
Iterator.step (skipped iterator) =
-}
{-
skipped : ℕ → ∀{iter} → Iterable{ℓₑ}(iter) → Iterable(iter)
skipped 𝟎 iterable = iterable
skipped (𝐒 n) iterable = {!!}
-}
-- An empty iterator of the iterable.
EmptyConstruction : ∀{i} → Iter(i) → Type
EmptyConstruction(empty) = IsTrue(isEmpty empty)
-- A function prepending an element to an iterator of the iterable.
PrependConstruction : ∀{indexPrepend : ∀{i} → Element → Iter(i) → Index} → (∀{i} → (x : Element) → (iter : Iter(i)) → Iter(indexPrepend x iter)) → Type
PrependConstruction{indexPrepend} (prepend) = ∀{i}{x}{iter : Iter(i)} → ∃{Obj = IndexStep x iter}(Out x iter) where
IndexStep : Element → Iter(i) → Type
IndexStep{i} x iter with isEmpty(prepend x iter) | indexStep(prepend x iter)
... | 𝑇 | _ = Empty
... | 𝐹 | p = (p ≡ i)
Out : (x : Element) → (iter : Iter(i)) → IndexStep x iter → Type
Out x iter stepProof with isEmpty(prepend x iter) | indexStep(prepend x iter) | current(prepend x iter) | step(prepend x iter)
... | 𝐹 | _ | cur | st with [≡]-intro ← stepProof = (x ≡ cur) ∧ (st ≡ iter)
module _
{indexEmpty}{empty}
⦃ empty-construciton : EmptyConstruction{indexEmpty}(empty) ⦄
{indexPrepend : ∀{i} → Element → Iter(i) → Index}
{prepend : ∀{i} → (x : Element) → (iter : Iter(i)) → Iter(indexPrepend x iter)}
⦃ prepend-construction : PrependConstruction{indexPrepend}(prepend) ⦄
where
singleton : (x : Element) → Iter(indexPrepend x empty)
singleton x = prepend x empty
| {
"alphanum_fraction": 0.6348119034,
"avg_line_length": 40.2941176471,
"ext": "agda",
"hexsha": "2272611732b70098d781dee57ee57c18dacef652",
"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/Container/IndexedIterable.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/Container/IndexedIterable.agda",
"max_line_length": 184,
"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/Container/IndexedIterable.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": 2982,
"size": 8905
} |
------------------------------------------------------------------------------
-- The division result is correct
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOTC.Program.Division.ResultATP where
open import FOTC.Base
open import FOTC.Data.Nat
open import FOTC.Data.Nat.Inequalities
open import FOTC.Data.Nat.PropertiesATP
open import FOTC.Program.Division.Division
open import FOTC.Program.Division.Specification
------------------------------------------------------------------------------
-- The division result is correct when the dividend is less than
-- the divisor.
postulate div-x<y-helper : ∀ {i j} → N i → N j → i < j → i ≡ j * div i j + i
{-# ATP prove div-x<y-helper *-rightZero #-}
div-x<y-resultCorrect : ∀ {i j} → N i → N j → i < j →
∃[ r ] N r ∧ r < j ∧ i ≡ j * div i j + r
div-x<y-resultCorrect Ni Nj i<j = _ , Ni , i<j , div-x<y-helper Ni Nj i<j
-- The division result is correct when the dividend is greater or equal
-- than the divisor.
-- Using the inductive hypothesis ih we know that
--
-- i ∸ j = j * (div (i ∸ j) j) + r.
-- From that we get
--
-- i = j * (succ (div (i ∸ j) j)) + r and we know
--
-- div i j = succ (div (i ∸ j) j) therefore we get
--
-- i = j * div i j + r.
postulate helper : ∀ {i j r} → N i → N j → N r →
i ∸ j ≡ j * div (i ∸ j) j + r →
i ≡ j * succ₁ (div (i ∸ j) j) + r
postulate div-x≮y-helper : ∀ {i j r} → N i → N j → N r →
i ≮ j →
i ∸ j ≡ j * div (i ∸ j) j + r →
i ≡ j * div i j + r
{-# ATP prove div-x≮y-helper helper #-}
postulate div-x≮y-resultCorrect : ∀ {i j} → N i → N j →
(ih : divSpec (i ∸ j) j (div (i ∸ j) j)) →
i ≮ j →
∃[ r ] N r ∧ r < j ∧ i ≡ j * div i j + r
{-# ATP prove div-x≮y-resultCorrect div-x≮y-helper #-}
| {
"alphanum_fraction": 0.4463619403,
"avg_line_length": 36.9655172414,
"ext": "agda",
"hexsha": "b44a80927c9beb99e4c3c082f62921d34f2b3916",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z",
"max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/fotc",
"max_forks_repo_path": "src/fot/FOTC/Program/Division/ResultATP.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/fotc",
"max_issues_repo_path": "src/fot/FOTC/Program/Division/ResultATP.agda",
"max_line_length": 78,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "src/fot/FOTC/Program/Division/ResultATP.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": 608,
"size": 2144
} |
{-# OPTIONS --without-K #-}
module Cham.Agent where
open import Cham.Context
open import Cham.Label
open import Cham.Name
open import Data.Nat
open import Data.Product
data Agent : Context → Set where
Nil : Agent ∅
_∙_ : ∀ {Γ}
→ (Valence : Label)
→ Agent Γ
→ Agent (Γ ⊢ Valence)
_∣_ : ∀ {Γ₁ Γ₂}
→ Agent Γ₁
→ Agent Γ₂
→ Agent (Γ₁ , Γ₂)
_/_ : ∀ {Γ}
→ (Ion : Name)
→ Agent Γ
→ Agent (Γ ⊢ Ion ⁻)
_[]_ : ∀ {Γ₁ Γ₂}
→ Agent Γ₁
→ Agent Γ₂
→ Agent (Γ₁ , Γ₂)
Reaction : ∀ {Γ₁ Γ₂ Ion}
→ Agent (Γ₁ ⊢ Ion ⁺)
→ Agent (Γ₂ ⊢ Ion ⁻)
→ Agent Γ₁ × Agent Γ₂
Reaction (.(_ ⁺) ∙ a₁) (.(_ ⁻) ∙ a₂) = a₁ , a₂
Reaction (.(Ion ⁺) ∙ a₁) (Ion / a₂) = a₁ , a₂
| {
"alphanum_fraction": 0.4798439532,
"avg_line_length": 19.225,
"ext": "agda",
"hexsha": "79bd6d6d06b5177e734ec24cc61c0dc575301a6a",
"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": "292023fc36fa67ca4a81cff9a875a325a79b9d6f",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "riz0id/chemical-abstract-machine",
"max_forks_repo_path": "agda/Cham/Agent.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "292023fc36fa67ca4a81cff9a875a325a79b9d6f",
"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": "riz0id/chemical-abstract-machine",
"max_issues_repo_path": "agda/Cham/Agent.agda",
"max_line_length": 48,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "292023fc36fa67ca4a81cff9a875a325a79b9d6f",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "riz0id/chemical-abstract-machine",
"max_stars_repo_path": "agda/Cham/Agent.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 299,
"size": 769
} |
module GUIgeneric.GUIExampleBankAccount where
open import GUIgeneric.Prelude renaming (inj₁ to firstBtn; inj₂ to secondBtn; WxColor to Color;_∸_ to _-_) hiding (addButton; _>>_ ; show)
open import GUIgeneric.GUIDefinitions renaming (add to add'; add' to add)
open import GUIgeneric.GUI
open import GUIgeneric.GUIExampleLib renaming (addButton to addButton')
open import GUIgeneric.GUIExample hiding (main; changeGUI)
open import Data.Nat.Show
open import heap.libraryNat renaming (_≧ℕb_ to _≧_)
guifullToReturnType : ∀ {i} {g} → GUI {i} → returnType g
guifullToReturnType f = changedGUI (f .defFrame) (f .property)
guifullToReturnType' : ∀ {i} {g} → GUI {i} →
Σ[ r ∈ returnType g ]
(IOObjectˢ GuiLev1Interface handlerInterface i
(nextStateFrame g r))
guifullToReturnType' {i} {g} f = guifullToReturnType f , f .obj
changeGUI : ∀ {i} {g} → GUI {i} →
IO GuiLev1Interface ∞ (Σ[ r ∈ returnType g ]
(IOObjectˢ GuiLev1Interface handlerInterface i
(nextStateFrame g r)))
changeGUI f = return (guifullToReturnType' f)
threeBtnFrame : (s s' s'' : String) → Frame
threeBtnFrame s s' s'' = addButton s (addButton s'
(addButton s'' create-frame))
propThreeBtn : ∀{s s' s''} → properties (threeBtnFrame s s' s'')
propThreeBtn = black , black , black , oneColumnLayout
mutual
atm : ∀{i} → ℕ → GUI {i}
atm n .defFrame =
addButton "Withdraw 10"
(addButton "Withdraw 1"
(addTxtBox (show n) create-frame))
atm n .property =
black , black , black , oneColumnLayout
atm n .obj .method (firstBtn x) =
if n ≧ 10 then changeGUI (atm (n - 10))
else changeGUI (invalid n)
atm n .obj .method (secondBtn b) =
if n ≧ 1 then changeGUI (atm (n - 1))
else changeGUI (invalid n)
invalid : ∀{i} → ℕ → GUI {i}
invalid n .defFrame =
addButton "Not enough money" create-frame
invalid n .property = black , oneColumnLayout
invalid n .obj .method m = changeGUI (atm n)
main : NativeIO Unit
main = compileGUI (atm 55)
| {
"alphanum_fraction": 0.6217450891,
"avg_line_length": 29.9863013699,
"ext": "agda",
"hexsha": "e4aedd51b6fc6a7630db701c0044ef2683e9b9f0",
"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/GUIExampleBankAccount.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/GUIExampleBankAccount.agda",
"max_line_length": 138,
"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/GUIExampleBankAccount.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": 649,
"size": 2189
} |
-- {-# OPTIONS -v 100 -v tc.meta.name:100 -v interactive.meta:10 #-}
module Issue526 where
-- Don't just write _49,
-- include the corresponding implicit variable name as well (if any)
postulate
f : {A : Set} → {a : A} → Set1 → {B : Set} → Set
test : Set
test = f Set
test₁ : Set
test₁ = f {A = _} Set
postulate
g : (B : Set) → Set
test₂ : Set
test₂ = g _
test₃ : _ → Set
test₃ ()
| {
"alphanum_fraction": 0.6081424936,
"avg_line_length": 15.72,
"ext": "agda",
"hexsha": "df6277ea7e10158eaac8f5682675f007f660f09d",
"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/Issue526.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/Issue526.agda",
"max_line_length": 68,
"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/Issue526.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": 138,
"size": 393
} |
module MLib.Prelude.RelProps where
open import MLib.Prelude.FromStdlib
import Relation.Binary.Indexed as I
open FE using (cong)
import Data.Product.Relation.SigmaPropositional as OverΣ
Σ-bij : ∀ {a b c} {A : Set a} {B : A → Set b} {C : A → Set c} → (∀ x → B x ↔ C x) → Σ A B ↔ Σ A C
Σ-bij pw = record
{ to = ≡.→-to-⟶ (uncurry λ x y → x , Inverse.to (pw x) ⟨$⟩ y)
; from = ≡.→-to-⟶ (uncurry λ x y → x , Inverse.from (pw x) ⟨$⟩ y)
; inverse-of = record
{ left-inverse-of = uncurry λ x y → OverΣ.to-≡ (≡.refl , Inverse.left-inverse-of (pw x) y)
; right-inverse-of = uncurry λ x y → OverΣ.to-≡ (≡.refl , Inverse.right-inverse-of (pw x) y)
}
}
Σ-↞ : ∀ {a b c} {A : Set a} {B : A → Set b} {C : A → Set c} → (∀ x → B x ↞ C x) → Σ A B ↞ Σ A C
Σ-↞ f = record
{ to = ≡.→-to-⟶ (uncurry λ x y → x , LeftInverse.to (f x) ⟨$⟩ y)
; from = ≡.→-to-⟶ (uncurry λ x y → x , LeftInverse.from (f x) ⟨$⟩ y)
; left-inverse-of = uncurry λ x y → OverΣ.to-≡ (≡.refl , LeftInverse.left-inverse-of (f x) y)
}
Σ-↞′ :
∀ {a a′ b β} {A : Set a} {A′ : Set a′} {B-setoid : A → Setoid b β} (f : A ↞ A′)
→ LeftInverse (OverΣ.setoid B-setoid) (OverΣ.setoid (B-setoid ∘ (LeftInverse.from f ⟨$⟩_)))
Σ-↞′ {A = A} {A′} {B-setoid} f = record
{ to = record
{ _⟨$⟩_ = uncurry λ x y → LeftInverse.to f ⟨$⟩ x , ≡.subst B (≡.sym (LeftInverse.left-inverse-of f _)) y
; cong = uncurry λ {≡.refl y → ≡.refl , subst≈ _ _ (≡.sym (LeftInverse.left-inverse-of f _)) y}
}
; from = record
{ _⟨$⟩_ = uncurry λ x y → LeftInverse.from f ⟨$⟩ x , y
; cong = λ { (≡.refl , q) → ≡.refl , q }
}
; left-inverse-of = uncurry λ x y → OverΣ.symmetric sym (OverΣ.subst (≡.sym (LeftInverse.left-inverse-of f _)) refl)
}
where
module B x = Setoid (B-setoid x)
module B′ {x} = Setoid (B-setoid x)
open B using () renaming (Carrier to B)
open B′
subst≈ : ∀ {i j} (x y : B i) (p : i ≡ j) → x ≈ y → ≡.subst B p x ≈ ≡.subst B p y
subst≈ x y ≡.refl q = q
| {
"alphanum_fraction": 0.5432911392,
"avg_line_length": 39.5,
"ext": "agda",
"hexsha": "6209fecb1c83bcdc3ebcf0eeac237ade0ae7417b",
"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": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bch29/agda-matrices",
"max_forks_repo_path": "src/MLib/Prelude/RelProps.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574",
"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": "bch29/agda-matrices",
"max_issues_repo_path": "src/MLib/Prelude/RelProps.agda",
"max_line_length": 118,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bch29/agda-matrices",
"max_stars_repo_path": "src/MLib/Prelude/RelProps.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 862,
"size": 1975
} |
module Imports.A where
postulate A : Set
| {
"alphanum_fraction": 0.7272727273,
"avg_line_length": 7.3333333333,
"ext": "agda",
"hexsha": "20ac5003c7b2da29153235a8dd73c7d08b6f39ca",
"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/Imports/A.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/Imports/A.agda",
"max_line_length": 22,
"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/Imports/A.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": 12,
"size": 44
} |
module _ where
import Issue1168 ; module I = Issue1168
import PrettyInterface ; module P = PrettyInterface
id : {A : Set} → A → A
id {A = A} a = a
| {
"alphanum_fraction": 0.6369426752,
"avg_line_length": 19.625,
"ext": "agda",
"hexsha": "80bc72c10ecf5e8a97ca3735e032bd6101ab21f9",
"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/api/ScopeFromInterface.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/api/ScopeFromInterface.agda",
"max_line_length": 52,
"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/api/ScopeFromInterface.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": 51,
"size": 157
} |
module Dot where
postulate h : Set
f : Set -> Set -> Set
f .n n = h
| {
"alphanum_fraction": 0.5857142857,
"avg_line_length": 10,
"ext": "agda",
"hexsha": "0b761bec74b265ace8e7d65ea2bb3e5790f9163a",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "andrejtokarcik/agda-semantics",
"max_forks_repo_path": "tests/covered/Dot.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "andrejtokarcik/agda-semantics",
"max_issues_repo_path": "tests/covered/Dot.agda",
"max_line_length": 21,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "andrejtokarcik/agda-semantics",
"max_stars_repo_path": "tests/covered/Dot.agda",
"max_stars_repo_stars_event_max_datetime": "2018-12-06T17:24:25.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-08-10T15:33:56.000Z",
"num_tokens": 25,
"size": 70
} |
{-# OPTIONS --cubical --no-exact-split --safe #-}
module Cubical.Data.Nat.Properties where
open import Cubical.Core.Everything
open import Cubical.Foundations.Prelude
open import Cubical.Data.Nat.Base
open import Cubical.Data.Empty
open import Cubical.Data.Prod.Base
open import Cubical.Relation.Nullary
open import Cubical.Relation.Nullary.DecidableEq
open import Cubical.Data.Nat.Algebra public
+-zero : ∀ m → m + 0 ≡ m
+-zero zero = refl
+-zero (suc m) = cong suc (+-zero m)
+-suc : ∀ m n → m + suc n ≡ suc (m + n)
+-suc zero n = refl
+-suc (suc m) n = cong suc (+-suc m n)
+-comm : ∀ m n → m + n ≡ n + m
+-comm m zero = +-zero m
+-comm m (suc n) = (+-suc m n) ∙ (cong suc (+-comm m n))
-- Addition is associative
+-assoc : ∀ m n o → m + (n + o) ≡ (m + n) + o
+-assoc zero _ _ = refl
+-assoc (suc m) n o = cong suc (+-assoc m n o)
private
variable
l m n : ℕ
znots : ¬ (0 ≡ suc n)
znots eq = subst (caseNat ℕ ⊥) eq 0
snotz : ¬ (suc n ≡ 0)
snotz eq = subst (caseNat ⊥ ℕ) eq 0
injSuc : suc m ≡ suc n → m ≡ n
injSuc p = cong predℕ p
inj-m+ : m + l ≡ m + n → l ≡ n
inj-m+ {zero} p = p
inj-m+ {suc m} p = inj-m+ (injSuc p)
inj-+m : l + m ≡ n + m → l ≡ n
inj-+m {l} {m} {n} p = inj-m+ ((+-comm m l) ∙ (p ∙ (+-comm n m)))
m+n≡n→m≡0 : m + n ≡ n → m ≡ 0
m+n≡n→m≡0 {n = zero} = λ p → (sym (+-zero _)) ∙ p
m+n≡n→m≡0 {n = suc n} p = m+n≡n→m≡0 (injSuc ((sym (+-suc _ n)) ∙ p))
m+n≡0→m≡0×n≡0 : m + n ≡ 0 → (m ≡ 0) × (n ≡ 0)
m+n≡0→m≡0×n≡0 {zero} = refl ,_
m+n≡0→m≡0×n≡0 {suc m} p = ⊥-elim (snotz p)
discreteℕ : Discrete ℕ
discreteℕ zero zero = yes refl
discreteℕ zero (suc n) = no znots
discreteℕ (suc m) zero = no snotz
discreteℕ (suc m) (suc n) with discreteℕ m n
... | yes p = yes (cong suc p)
... | no p = no (λ x → p (injSuc x))
isSetℕ : isSet ℕ
isSetℕ = Discrete→isSet discreteℕ
0≡m*0 : ∀ m → 0 ≡ m * 0
0≡m*0 zero = refl
0≡m*0 (suc m) = 0≡m*0 m
*-suc : ∀ m n → m * suc n ≡ m + m * n
*-suc zero n = refl
*-suc (suc m) n
= cong suc
( n + m * suc n ≡⟨ cong (n +_) (*-suc m n) ⟩
n + (m + m * n) ≡⟨ +-assoc n m (m * n) ⟩
(n + m) + m * n ≡⟨ cong (_+ m * n) (+-comm n m) ⟩
(m + n) + m * n ≡⟨ sym (+-assoc m n (m * n)) ⟩
m + (n + m * n) ∎
)
*-comm : ∀ m n → m * n ≡ n * m
*-comm zero n = 0≡m*0 n
*-comm (suc m) n = cong (n +_) (*-comm m n) ∙ sym (*-suc n m)
0≡n*sm→0≡n : 0 ≡ n * suc m → 0 ≡ n
0≡n*sm→0≡n {n = zero} p = refl
0≡n*sm→0≡n {n = suc n} p = ⊥-elim (znots p)
inj-*sm : l * suc m ≡ n * suc m → l ≡ n
inj-*sm {zero} {m} {n} p = 0≡n*sm→0≡n p
inj-*sm {l} {m} {zero} p = sym (0≡n*sm→0≡n (sym p))
inj-*sm {suc l} {m} {suc n} p = cong suc (inj-*sm (inj-m+ {m = suc m} p))
inj-sm* : suc m * l ≡ suc m * n → l ≡ n
inj-sm* {m} {l} {n} p = inj-*sm (*-comm l (suc m) ∙ p ∙ *-comm (suc m) n)
| {
"alphanum_fraction": 0.5223279649,
"avg_line_length": 26.5242718447,
"ext": "agda",
"hexsha": "1f9c43baf02a3b674f6f0180942c7b923774d7ed",
"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": "a01973ef7264f9454a40697313a2073c51a6b77a",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/cubical",
"max_forks_repo_path": "Cubical/Data/Nat/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a01973ef7264f9454a40697313a2073c51a6b77a",
"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/cubical",
"max_issues_repo_path": "Cubical/Data/Nat/Properties.agda",
"max_line_length": 73,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a01973ef7264f9454a40697313a2073c51a6b77a",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/cubical",
"max_stars_repo_path": "Cubical/Data/Nat/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1354,
"size": 2732
} |
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
open import Haskell.Modules.RWS.RustAnyHow
import LibraBFT.Impl.Consensus.ConsensusTypes.BlockRetrieval as BlockRetrieval
import LibraBFT.Impl.IO.OBM.ObmNeedFetch as ObmNeedFetch
open import LibraBFT.Impl.OBM.Logging.Logging
open import LibraBFT.Impl.OBM.Rust.RustTypes
open import LibraBFT.ImplShared.Consensus.Types
open import LibraBFT.ImplShared.Consensus.Types.EpochIndep
open import LibraBFT.ImplShared.Util.Dijkstra.All
open import Optics.All
import Util.KVMap as Map
open import Util.Prelude
------------------------------------------------------------------------------
import Data.String as String
module LibraBFT.Impl.Consensus.BlockStorage.BlockRetriever where
pickPeer : ℕ → List Author → Either ErrLog (Author × List Author)
-- LBFT-OBM-DIFF : this lives in sync_manager.rs (in this file to isolate IO)
-- TODO-1 PROVE IT TERMINATES
{-# TERMINATING #-}
retrieveBlockForQCM : BlockRetriever → QuorumCert → U64 → LBFT (Either ErrLog (List Block))
retrieveBlockForQCM _retriever qc numBlocks =
loop (qc ^∙ qcCertifiedBlock ∙ biId) 0 (Map.kvm-keys (qc ^∙ qcLedgerInfo ∙ liwsSignatures))
where
doLoop : HashValue → ℕ → List Author → LBFT (Either ErrLog (List Block))
logIt : InfoLog → LBFT Unit
here' : List String.String → List String.String
loop : HashValue → ℕ → List Author → LBFT (Either ErrLog (List Block))
loop blockId attempt = λ where
[] → bail fakeErr -- [ "failed to fetch block, no more peers available"
-- , lsHV blockId, show attempt ]
peers0@(_ ∷ _) → do
mme ← use (lRoundManager ∙ rmObmMe)
maybeSD mme (bail fakeErr) $ λ me → do
nf ← use lObmNeedFetch
eitherS (pickPeer attempt peers0) bail $ λ (peer , peers) → do
let request = BlockRetrievalRequest∙new me blockId numBlocks
logIt fakeInfo -- ["to", lsA peer, lsBRQ request]
let response = ObmNeedFetch.writeRequestReadResponseUNSAFE nf me peer request
-- TODO : sign response and check sig on response
case response ^∙ brpStatus of λ where
BRSSucceeded → do
logIt fakeInfo -- (here [lsBRP response])
vv ← use (lRoundManager ∙ rmEpochState ∙ esVerifier)
-- LBFT-OBM-DIFF/TODO : this should live in a "network" module
case BlockRetrieval.verify response (request ^∙ brqBlockId) (request ^∙ brqNumBlocks) vv of λ where
(Left e) → bail (withErrCtx (here' []) e)
(Right _) → ok (response ^∙ brpBlocks)
BRSIdNotFound → doLoop blockId attempt peers
BRSNotEnoughBlocks → doLoop blockId attempt peers
doLoop blockId attempt peers = do
logIt fakeInfo -- (here' ["trying another peer", lsBRP response])
loop blockId (attempt + 1) peers
here' t = "BlockRetriever" ∷ "retrieveBlockForQCM" ∷ "NeedFetch" ∷ t
logIt l = -- do
logInfo l
-- let x = Unsafe.unsafePerformIO (putStrLn @Text (show l))
-- x `seq` pure x
pickPeer _ = λ where
[] → Left fakeErr -- ["no more peers"]
(p ∷ ps) → pure (p , ps)
| {
"alphanum_fraction": 0.6374133949,
"avg_line_length": 46.8108108108,
"ext": "agda",
"hexsha": "ad7dcd21bac55434c9d49c30d108aa35b3f04790",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_forks_repo_licenses": [
"UPL-1.0"
],
"max_forks_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_forks_repo_path": "src/LibraBFT/Impl/Consensus/BlockStorage/BlockRetriever.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"UPL-1.0"
],
"max_issues_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_issues_repo_path": "src/LibraBFT/Impl/Consensus/BlockStorage/BlockRetriever.agda",
"max_line_length": 113,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_stars_repo_licenses": [
"UPL-1.0"
],
"max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_stars_repo_path": "src/LibraBFT/Impl/Consensus/BlockStorage/BlockRetriever.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 946,
"size": 3464
} |
module Data.BitVector.ContainmentOrder where
open import Data.Empty
open import Data.Sum
open import Data.Vec
open import Relation.Nullary
open import Relation.Binary
open import Relation.Binary.PropositionalEquality
open import Data.Nat hiding (_≟_; _≤_; _≤?_) renaming (zero to Nzero; suc to Nsuc)
open import Data.BitVector
infix 4 _⊂_
data _⊂_ : ∀ {n} → BitVector n → BitVector n → Set where
[]⊂[] : [] ⊂ []
0#⊂0# : ∀ {n} {x y : BitVector n} → (x⊂y : x ⊂ y) → (0# ∷ x) ⊂ (0# ∷ y)
b⊂1# : ∀ {n} {x y : BitVector n} {b} → (x⊂y : x ⊂ y) → (b ∷ x) ⊂ (1# ∷ y)
⊂-refl : ∀ {n} → _≡_ ⇒ (_⊂_ {n})
⊂-refl {0} {[]} refl = []⊂[]
⊂-refl {Nsuc n} {0# ∷ xs} refl = 0#⊂0# (⊂-refl refl)
⊂-refl {Nsuc n} {1# ∷ xs} refl = b⊂1# (⊂-refl refl)
⊂-antisym : ∀ {n} → Antisymmetric _≡_ (_⊂_ {n})
⊂-antisym []⊂[] []⊂[] = refl
⊂-antisym (0#⊂0# x⊂y) (0#⊂0# y⊂x) rewrite ⊂-antisym x⊂y y⊂x = refl
⊂-antisym (b⊂1# x⊂y) (b⊂1# y⊂x) rewrite ⊂-antisym x⊂y y⊂x = refl
⊂-trans : ∀ {n} → Transitive (_⊂_ {n})
⊂-trans []⊂[] []⊂[] = []⊂[]
⊂-trans (0#⊂0# x⊂y) (0#⊂0# y⊂z) = 0#⊂0# (⊂-trans x⊂y y⊂z)
⊂-trans (0#⊂0# x⊂y) (b⊂1# y⊂z) = b⊂1# (⊂-trans x⊂y y⊂z)
⊂-trans (b⊂1# x⊂y) (b⊂1# y⊂z) = b⊂1# (⊂-trans x⊂y y⊂z)
_⊂?_ : ∀ {n} → Decidable (_⊂_ {n})
[] ⊂? [] = yes []⊂[]
(x ∷ xs) ⊂? (y ∷ ys) with xs ⊂? ys
(0# ∷ xs) ⊂? (0# ∷ ys) | no xs≢ys = no helper
where helper : ¬ 0# ∷ xs ⊂ 0# ∷ ys
helper (0#⊂0# pf) = xs≢ys pf
(x ∷ xs) ⊂? (1# ∷ ys) | no xs≢ys = no helper
where helper : ¬ x ∷ xs ⊂ 1# ∷ ys
helper (b⊂1# pf) = xs≢ys pf
(1# ∷ xs) ⊂? (0# ∷ ys) | no xs≢ys = no (λ ())
(0# ∷ xs) ⊂? (0# ∷ ys) | yes xs≡ys = yes (0#⊂0# xs≡ys)
(0# ∷ xs) ⊂? (1# ∷ ys) | yes xs≡ys = yes (b⊂1# xs≡ys)
(1# ∷ xs) ⊂? (0# ∷ ys) | yes xs≡ys = no (λ ())
(1# ∷ xs) ⊂? (1# ∷ ys) | yes xs≡ys = yes (b⊂1# xs≡ys)
decPoset : ∀ {n} → DecPoset _ _ _
decPoset {n} = record
{ Carrier = BitVector n
; _≈_ = _≡_
; _≤_ = _⊂_
; isDecPartialOrder = record
{ isPartialOrder = record
{ isPreorder = record
{ isEquivalence = isEquivalence
; reflexive = ⊂-refl
; trans = ⊂-trans
}
; antisym = ⊂-antisym
}
; _≟_ = _≟_
; _≤?_ = _⊂?_
}
} | {
"alphanum_fraction": 0.4757630162,
"avg_line_length": 31.8285714286,
"ext": "agda",
"hexsha": "627d2d9896413a2f0b30dc99c217027af2ea847a",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2021-11-12T01:40:57.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-05-25T00:15:43.000Z",
"max_forks_repo_head_hexsha": "6902f4bce0330f1b58f48395dac4406056713687",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "copumpkin/bitvector",
"max_forks_repo_path": "Data/BitVector/ContainmentOrder.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "6902f4bce0330f1b58f48395dac4406056713687",
"max_issues_repo_issues_event_max_datetime": "2016-05-25T02:00:59.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-05-25T02:00:59.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "copumpkin/bitvector",
"max_issues_repo_path": "Data/BitVector/ContainmentOrder.agda",
"max_line_length": 82,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "6902f4bce0330f1b58f48395dac4406056713687",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "copumpkin/bitvector",
"max_stars_repo_path": "Data/BitVector/ContainmentOrder.agda",
"max_stars_repo_stars_event_max_datetime": "2021-11-12T01:41:07.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-04T07:19:55.000Z",
"num_tokens": 1235,
"size": 2228
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Properties of sums (disjoint unions)
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Sum.Properties where
open import Level
open import Data.Sum.Base
open import Function
open import Relation.Binary using (Decidable)
open import Relation.Binary.PropositionalEquality
open import Relation.Nullary using (yes; no)
open import Relation.Nullary.Decidable using (map′)
private
variable
a b c d e f : Level
A : Set a
B : Set b
C : Set c
D : Set d
E : Set e
F : Set f
inj₁-injective : ∀ {x y} → (A ⊎ B ∋ inj₁ x) ≡ inj₁ y → x ≡ y
inj₁-injective refl = refl
inj₂-injective : ∀ {x y} → (A ⊎ B ∋ inj₂ x) ≡ inj₂ y → x ≡ y
inj₂-injective refl = refl
module _ (dec₁ : Decidable {A = A} {B = A} _≡_)
(dec₂ : Decidable {A = B} {B = B} _≡_) where
≡-dec : Decidable {A = A ⊎ B} _≡_
≡-dec (inj₁ x) (inj₁ y) = map′ (cong inj₁) inj₁-injective (dec₁ x y)
≡-dec (inj₁ x) (inj₂ y) = no λ()
≡-dec (inj₂ x) (inj₁ y) = no λ()
≡-dec (inj₂ x) (inj₂ y) = map′ (cong inj₂) inj₂-injective (dec₂ x y)
swap-involutive : swap {A = A} {B = B} ∘ swap ≗ id
swap-involutive = [ (λ _ → refl) , (λ _ → refl) ]
[,]-∘-distr : {f : A → B}
{g : C → A} {h : D → A} →
f ∘ [ g , h ] ≗ [ f ∘ g , f ∘ h ]
[,]-∘-distr (inj₁ _) = refl
[,]-∘-distr (inj₂ _) = refl
[,]-map-commute : {f : A → B} {g : C → D}
{f′ : B → E} {g′ : D → E} →
[ f′ , g′ ] ∘ (map f g) ≗ [ f′ ∘ f , g′ ∘ g ]
[,]-map-commute (inj₁ _) = refl
[,]-map-commute (inj₂ _) = refl
map-commute : {f : A → B} {g : C → D}
{f′ : B → E} {g′ : D → F} →
((map f′ g′) ∘ (map f g)) ≗ map (f′ ∘ f) (g′ ∘ g)
map-commute (inj₁ _) = refl
map-commute (inj₂ _) = refl
| {
"alphanum_fraction": 0.4768177028,
"avg_line_length": 29.65625,
"ext": "agda",
"hexsha": "b0c66a8a310dd364661a8b557f0016b1565f1e0c",
"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/Sum/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/Sum/Properties.agda",
"max_line_length": 72,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DreamLinuxer/popl21-artifact",
"max_stars_repo_path": "agda-stdlib/src/Data/Sum/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": 721,
"size": 1898
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Displayed.Properties where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Univalence using (pathToEquiv)
open import Cubical.Functions.FunExtEquiv
open import Cubical.Data.Unit
open import Cubical.Data.Nat
open import Cubical.Data.Sigma
open import Cubical.Relation.Binary
open BinaryRelation
open import Cubical.Displayed.Base
private
variable
ℓ ℓA ℓA' ℓP ℓ≅A ℓ≅A' ℓB ℓB' ℓ≅B ℓ≅B' ℓC ℓ≅C : Level
-- UARel on Σ-type
module _ {A : Type ℓA} {ℓ≅A : Level} {𝒮-A : UARel A ℓ≅A}
{B : A → Type ℓB} {ℓ≅B : Level}
(𝒮ᴰ-B : DUARel 𝒮-A B ℓ≅B)
where
open UARel 𝒮-A
open DUARel 𝒮ᴰ-B
∫ : UARel (Σ A B) (ℓ-max ℓ≅A ℓ≅B)
UARel._≅_ ∫ (a , b) (a' , b') = Σ[ p ∈ a ≅ a' ] (b ≅ᴰ⟨ p ⟩ b')
UARel.ua ∫ (a , b) (a' , b') =
compEquiv
(Σ-cong-equiv (ua a a') (λ p → uaᴰ b p b'))
ΣPath≃PathΣ
-- UARel on Π-type
module _ {A : Type ℓA} (𝒮-A : UARel A ℓ≅A) {B : A → Type ℓB} (𝒮ᴰ-B : DUARel 𝒮-A B ℓ≅B) where
open UARel 𝒮-A
open DUARel 𝒮ᴰ-B
𝒮ᴰ→𝒮-Π : UARel ((a : A) → B a) (ℓ-max ℓA ℓ≅B)
UARel._≅_ 𝒮ᴰ→𝒮-Π f f' = ∀ a → f a ≅ᴰ⟨ ρ a ⟩ f' a
UARel.ua 𝒮ᴰ→𝒮-Π f f' =
compEquiv
(equivΠCod λ a → uaᴰρ (f a) (f' a))
funExtEquiv
-- induction principles
module _ {A : Type ℓA} {ℓ≅A : Level} (𝒮-A : UARel A ℓ≅A) where
open UARel 𝒮-A
𝒮-J : {a : A}
(P : (a' : A) → (p : a ≡ a') → Type ℓ)
(d : P a refl)
{a' : A}
(p : a ≅ a')
→ P a' (≅→≡ p)
𝒮-J {a} P d {a'} p
= J (λ y q → P y q)
d
(≅→≡ p)
𝒮-J-2 : {a : A}
(P : (a' : A) → (p : a ≅ a') → Type ℓ)
(d : P a (ρ a))
{a' : A}
(p : a ≅ a')
→ P a' p
𝒮-J-2 {a = a} P d {a'} p
= subst (λ r → P a' r) (Iso.leftInv (uaIso a a') p) g
where
g : P a' (≡→≅ (≅→≡ p))
g = J (λ y q → P y (≡→≅ q)) d (≅→≡ p)
-- constructors
module _ {A : Type ℓA} {𝒮-A : UARel A ℓ≅A}
{B : A → Type ℓB}
(_≅ᴰ⟨_⟩_ : {a a' : A} → B a → UARel._≅_ 𝒮-A a a' → B a' → Type ℓ≅B)
where
open UARel 𝒮-A
-- constructor that reduces ua to the case where p = ρ a by induction on p
private
𝒮ᴰ-make-aux : (uni : {a : A} (b b' : B a) → b ≅ᴰ⟨ ρ a ⟩ b' ≃ (b ≡ b'))
→ ({a a' : A} (b : B a) (p : a ≅ a') (b' : B a') → (b ≅ᴰ⟨ p ⟩ b') ≃ PathP (λ i → B (≅→≡ p i)) b b')
𝒮ᴰ-make-aux uni {a} {a'} b p
= 𝒮-J-2 𝒮-A
(λ y q → (b' : B y) → (b ≅ᴰ⟨ q ⟩ b') ≃ PathP (λ i → B (≅→≡ q i)) b b')
(λ b' → uni' b')
p
where
g : (b' : B a) → (b ≡ b') ≡ PathP (λ i → B (≅→≡ (ρ a) i)) b b'
g b' = subst (λ r → (b ≡ b') ≡ PathP (λ i → B (r i)) b b')
(sym (Iso.rightInv (uaIso a a) refl))
refl
uni' : (b' : B a) → b ≅ᴰ⟨ ρ a ⟩ b' ≃ PathP (λ i → B (≅→≡ (ρ a) i)) b b'
uni' b' = compEquiv (uni b b') (pathToEquiv (g b'))
𝒮ᴰ-make-1 : (uni : {a : A} (b b' : B a) → b ≅ᴰ⟨ ρ a ⟩ b' ≃ (b ≡ b'))
→ DUARel 𝒮-A B ℓ≅B
DUARel._≅ᴰ⟨_⟩_ (𝒮ᴰ-make-1 uni) = _≅ᴰ⟨_⟩_
DUARel.uaᴰ (𝒮ᴰ-make-1 uni) = 𝒮ᴰ-make-aux uni
-- constructor that reduces univalence further to contractibility of relational singletons
𝒮ᴰ-make-2 : (ρᴰ : {a : A} → isRefl _≅ᴰ⟨ ρ a ⟩_)
(contrTotal : (a : A) → contrRelSingl _≅ᴰ⟨ UARel.ρ 𝒮-A a ⟩_)
→ DUARel 𝒮-A B ℓ≅B
DUARel._≅ᴰ⟨_⟩_ (𝒮ᴰ-make-2 ρᴰ contrTotal) = _≅ᴰ⟨_⟩_
DUARel.uaᴰ (𝒮ᴰ-make-2 ρᴰ contrTotal)
= 𝒮ᴰ-make-aux (contrRelSingl→isUnivalent _ ρᴰ (contrTotal _))
-- lifts
module _ {A : Type ℓA} (𝒮-A : UARel A ℓ≅A)
{B : A → Type ℓB}
{ℓ≅B : Level}
(𝒮ᴰ-B : DUARel 𝒮-A B ℓ≅B)
{C : A → Type ℓC}
(𝒮ᴰ-C : DUARel 𝒮-A C ℓ≅C)
where
open DUARel 𝒮ᴰ-B
Lift-𝒮ᴰ : DUARel (∫ 𝒮ᴰ-C) (λ (a , _) → B a) ℓ≅B
DUARel._≅ᴰ⟨_⟩_ Lift-𝒮ᴰ b p b' = b ≅ᴰ⟨ p .fst ⟩ b'
DUARel.uaᴰ Lift-𝒮ᴰ b p b' = uaᴰ b (p .fst) b'
-- associativity
module _ {A : Type ℓA} (𝒮-A : UARel A ℓ≅A)
{B : A → Type ℓB} {ℓ≅B : Level} (𝒮ᴰ-B : DUARel 𝒮-A B ℓ≅B)
{C : Σ A B → Type ℓC} {ℓ≅C : Level} (𝒮ᴰ-C : DUARel (∫ 𝒮ᴰ-B) C ℓ≅C)
where
open UARel 𝒮-A
open DUARel 𝒮ᴰ-B renaming (_≅ᴰ⟨_⟩_ to _≅B⟨_⟩_ ; uaᴰ to uaB)
open DUARel 𝒮ᴰ-C renaming (_≅ᴰ⟨_⟩_ to _≅C⟨_⟩_ ; uaᴰ to uaC)
splitTotal-𝒮ᴰ : DUARel 𝒮-A (λ a → Σ[ b ∈ B a ] C (a , b)) (ℓ-max ℓ≅B ℓ≅C)
DUARel._≅ᴰ⟨_⟩_ splitTotal-𝒮ᴰ (b , c) p (b' , c') =
Σ[ q ∈ b ≅B⟨ p ⟩ b' ] (c ≅C⟨ p , q ⟩ c')
DUARel.uaᴰ splitTotal-𝒮ᴰ (b , c) p (b' , c') =
compEquiv
(Σ-cong-equiv (uaB b p b') (λ q → uaC c (p , q) c'))
ΣPath≃PathΣ
-- combination
module _ {A : Type ℓA} {𝒮-A : UARel A ℓ≅A}
{B : A → Type ℓB} {ℓ≅B : Level} (𝒮ᴰ-B : DUARel 𝒮-A B ℓ≅B)
{C : A → Type ℓC} {ℓ≅C : Level} (𝒮ᴰ-C : DUARel 𝒮-A C ℓ≅C)
where
_×𝒮ᴰ_ : DUARel 𝒮-A (λ a → B a × C a) (ℓ-max ℓ≅B ℓ≅C)
_×𝒮ᴰ_ = splitTotal-𝒮ᴰ 𝒮-A 𝒮ᴰ-B (Lift-𝒮ᴰ 𝒮-A 𝒮ᴰ-C 𝒮ᴰ-B)
-- constant displayed structure
module _ {A : Type ℓA} (𝒮-A : UARel A ℓ≅A)
{B : Type ℓB} (𝒮-B : UARel B ℓ≅B) where
open UARel 𝒮-B
open DUARel
𝒮ᴰ-const : DUARel 𝒮-A (λ _ → B) ℓ≅B
𝒮ᴰ-const ._≅ᴰ⟨_⟩_ b _ b' = b ≅ b'
𝒮ᴰ-const .uaᴰ b p b' = ua b b'
-- UARel product
_×𝒮_ : UARel (A × B) (ℓ-max ℓ≅A ℓ≅B)
_×𝒮_ = ∫ 𝒮ᴰ-const
-- relational isomorphisms
𝒮-iso→iso : {A : Type ℓA} (𝒮-A : UARel A ℓ≅A)
{B : Type ℓB} (𝒮-B : UARel B ℓ≅B)
(F : RelIso (UARel._≅_ 𝒮-A) (UARel._≅_ 𝒮-B))
→ Iso A B
𝒮-iso→iso 𝒮-A 𝒮-B F
= RelIso→Iso (UARel._≅_ 𝒮-A)
(UARel._≅_ 𝒮-B)
(UARel.≅→≡ 𝒮-A)
(UARel.≅→≡ 𝒮-B)
F
-- fiberwise relational isomorphisms
module _ {A : Type ℓA} {𝒮-A : UARel A ℓ≅A}
{A' : Type ℓA'} {𝒮-A' : UARel A' ℓ≅A'}
(F : Iso A A')
{B : A → Type ℓB} (𝒮ᴰ-B : DUARel 𝒮-A B ℓ≅B)
{B' : A' → Type ℓB'} (𝒮ᴰ-B' : DUARel 𝒮-A' B' ℓ≅B') where
open UARel 𝒮-A
open DUARel 𝒮ᴰ-B renaming (_≅ᴰ⟨_⟩_ to _≅B⟨_⟩_
; uaᴰ to uaB
; fiberRel to fiberRelB
; uaᴰρ to uaᴰρB)
open DUARel 𝒮ᴰ-B' renaming (_≅ᴰ⟨_⟩_ to _≅B'⟨_⟩_
; uaᴰ to uaB'
; fiberRel to fiberRelB'
; uaᴰρ to uaᴰρB')
private
f = Iso.fun F
-- the following can of course be done slightly more generally
-- for fiberwise binary relations
F*fiberRelB' : (a : A) → Rel (B' (f a)) (B' (f a)) ℓ≅B'
F*fiberRelB' a = fiberRelB' (f a)
module _ (G : (a : A) → RelIso (fiberRelB a) (F*fiberRelB' a)) where
private
fiberIsoOver : (a : A) → Iso (B a) (B' (f a))
fiberIsoOver a
= RelIso→Iso (fiberRelB a)
(F*fiberRelB' a)
(equivFun (uaᴰρB _ _))
(equivFun (uaᴰρB' _ _))
(G a)
-- DUARelFiberIsoOver→TotalIso produces an isomorphism of total spaces
-- from a relational isomorphism between B a and (F * B) a
𝒮ᴰ-fiberIsoOver→totalIso : Iso (Σ A B) (Σ A' B')
𝒮ᴰ-fiberIsoOver→totalIso = Σ-cong-iso F fiberIsoOver
-- Special cases:
-- Subtypes
𝒮-type : (A : Type ℓ) → UARel A ℓ
UARel._≅_ (𝒮-type A) = _≡_
UARel.ua (𝒮-type A) a a' = idEquiv (a ≡ a')
module _ {A : Type ℓA} (𝒮-A : UARel A ℓ≅A) where
𝒮ᴰ-subtype : (P : A → hProp ℓP) → DUARel 𝒮-A (λ a → P a .fst) ℓ-zero
𝒮ᴰ-subtype P
= 𝒮ᴰ-make-2 (λ _ _ _ → Unit)
(λ _ → tt)
λ a p → isOfHLevelRespectEquiv 0
(invEquiv (Σ-contractSnd (λ _ → isContrUnit)))
(inhProp→isContr p (P a .snd))
| {
"alphanum_fraction": 0.4870573084,
"avg_line_length": 29.9806949807,
"ext": "agda",
"hexsha": "ca8e03d1e2eaba1a3435cf76c86d362723f7cbb3",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dan-iel-lee/cubical",
"max_forks_repo_path": "Cubical/Displayed/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "dan-iel-lee/cubical",
"max_issues_repo_path": "Cubical/Displayed/Properties.agda",
"max_line_length": 119,
"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/Displayed/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3956,
"size": 7765
} |
{-
This file contains:
- the abelianization of groups as a coequalizer of sets as performed
in https://1lab.dev/Algebra.Group.Ab.Free.html
- the proof that this way of defining the abelianization of groups is equivalent to defining
it as a HIT, more precisely that there is a unique isomorphism between the resulting
abelian groups
-}
{-# OPTIONS --safe #-}
module Cubical.Algebra.Group.Abelianization.AbelianizationAsCoeq where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Data.Sigma
open import Cubical.Algebra.Group.Base
open import Cubical.Algebra.Group.Properties
open import Cubical.Algebra.Group.Morphisms
open import Cubical.Algebra.Group.MorphismProperties
using (isPropIsGroupHom; compGroupHom; idGroupHom; compGroupHomAssoc; invGroupIso;
compGroupHomId; GroupIso≡; GroupIso→GroupHom)
open import Cubical.Algebra.AbGroup.Base
open import Cubical.HITs.SetCoequalizer
open import Cubical.Algebra.Group.Abelianization.Base
renaming (Abelianization to HITAbelianization;
η to HITη;
comm to HITcomm;
isset to HITisset)
open import Cubical.Algebra.Group.Abelianization.Properties
hiding (elimProp; elimProp2; elimProp3; elimContr; elimContr2; rec; rec2)
renaming (AbelianizationAbGroup to HITasAbelianGroup;
AbelianizationHom to HITηAsGroupHom)
open Cubical.Algebra.Group.Abelianization.Properties.UniversalProperty
renaming (inducedHom to HITinducedHom;
commutativity to HITcommutativity;
uniqueness to HITuniqueness)
private
variable
ℓ : Level
G : Group ℓ
module AbelianizationAsCoeq (G : Group ℓ) where
open GroupStr {{...}}
open GroupTheory G
private
instance
_ = snd G
G' = fst G
{-
The definition of the abelianization of a group as a coequalizer of sets. The generality
of the coequalized functions will be needed to define the group structure on the
abelianization.
-}
Abelianization : Type ℓ
Abelianization =
SetCoequalizer {A = G' × G' × G'} {B = G'}
(λ (x , y , z) → x · y · z)
(λ (x , y , z) → x · z · y)
-- some convenient relabellings, so it looks more similar to the abelianization as a HIT.
incAb : G' → Abelianization
incAb = inc
comm : (x y z : G') → incAb (x · (y · z)) ≡ incAb (x · (z · y))
comm = λ x y z → coeq (x , y , z)
{-
Definition of the group structure on the abelianization. Here the generality of the
coequalized functions is used.
-}
_·Ab_ : Abelianization → Abelianization → Abelianization
_·Ab_ =
rec2
squash
(λ x y → incAb (x · y))
(λ (a , b , c) d →
incAb ((a · (b · c)) · d) ≡⟨ cong (λ x → incAb (x · d)) (assoc _ _ _) ⟩
incAb (((a · b) · c) · d) ≡⟨ cong incAb (sym (assoc (a · b) c d)) ⟩
incAb ((a · b) · (c · d)) ≡⟨ comm (a · b) c d ⟩
incAb ((a · b) · (d · c)) ≡⟨ cong incAb (sym (assoc _ _ _)) ⟩
incAb (a · (b · (d · c))) ≡⟨ cong (λ x → incAb (a · x)) (assoc _ _ _) ⟩
incAb (a · ((b · d) · c)) ≡⟨ comm a (b · d) c ⟩
incAb (a · (c · (b · d))) ≡⟨ cong (λ x → incAb (a · x)) (assoc _ _ _) ⟩
incAb (a · ((c · b) · d)) ≡⟨ cong incAb (assoc a (c · b) d) ⟩
incAb ((a · (c · b)) · d) ∎)
(λ (b , c , d) a →
incAb (a · (b · (c · d))) ≡⟨ cong incAb (assoc _ _ _) ⟩
incAb ((a · b) · (c · d)) ≡⟨ comm (a · b) c d ⟩
incAb ((a · b) · (d · c)) ≡⟨ cong incAb (sym (assoc _ _ _)) ⟩
incAb (a · (b · (d · c))) ∎)
1Ab : Abelianization
1Ab = incAb 1g
invAb : Abelianization → Abelianization
invAb =
rec
squash
(λ x → incAb (inv x))
(λ (a , b , c) →
incAb (inv (a · (b · c))) ≡⟨ cong incAb (invDistr a (b · c)) ⟩
incAb (inv (b · c) · inv a) ≡⟨ cong (λ x → incAb (x · inv a)) (invDistr b c) ⟩
incAb ((inv c · inv b) · inv a) ≡⟨ cong
incAb
(sym (lid ((inv c · inv b) · inv a))) ⟩
incAb (1g · ((inv c · inv b) · inv a)) ≡⟨ comm 1g (inv c · inv b) (inv a) ⟩
incAb (1g · (inv a · (inv c · inv b))) ≡⟨ cong incAb (lid (inv a · (inv c · inv b))) ⟩
incAb (inv a · (inv c · inv b)) ≡⟨ comm (inv a) (inv c) (inv b) ⟩
incAb (inv a · (inv b · inv c)) ≡⟨ cong
incAb
(sym (lid (inv a · (inv b · inv c)))) ⟩
incAb (1g · (inv a · (inv b · inv c))) ≡⟨ comm 1g (inv a) (inv b · inv c) ⟩
incAb (1g · ((inv b · inv c) · inv a)) ≡⟨ cong incAb (lid ((inv b · inv c) · inv a)) ⟩
incAb ((inv b · inv c) · inv a) ≡⟨ cong
(λ x → incAb (x · inv a))
(sym (invDistr c b)) ⟩
incAb (inv (c · b) · inv a) ≡⟨ cong incAb (sym (invDistr a (c · b))) ⟩
incAb (inv (a · (c · b))) ∎)
assocAb : (x y z : Abelianization) → x ·Ab (y ·Ab z) ≡ (x ·Ab y) ·Ab z
assocAb =
elimProp3
(λ x y z → squash (x ·Ab (y ·Ab z))
((x ·Ab y) ·Ab z))
(λ x y z → cong incAb (assoc x y z))
ridAb : (x : Abelianization) → x ·Ab 1Ab ≡ x
ridAb =
elimProp
(λ x → squash (x ·Ab 1Ab) x)
(λ x → cong incAb (rid x))
rinvAb : (x : Abelianization) → x ·Ab (invAb x) ≡ 1Ab
rinvAb =
elimProp
(λ x → squash (x ·Ab (invAb x)) 1Ab)
(λ x → (incAb x) ·Ab (invAb (incAb x)) ≡⟨ refl ⟩
(incAb x) ·Ab (incAb (inv x)) ≡⟨ refl ⟩
incAb (x · (inv x)) ≡⟨ cong incAb (fst (inverse x)) ⟩
incAb 1g ≡⟨ refl ⟩
1Ab ∎)
commAb : (x y : Abelianization) → x ·Ab y ≡ y ·Ab x
commAb =
elimProp2
(λ x y → squash (x ·Ab y) (y ·Ab x))
(λ x y → (incAb x) ·Ab (incAb y) ≡⟨ refl ⟩
incAb (x · y) ≡⟨ cong incAb (sym (lid (x · y))) ⟩
incAb (1g · (x · y)) ≡⟨ comm 1g x y ⟩
incAb (1g · (y · x)) ≡⟨ cong incAb (lid (y · x)) ⟩
incAb (y · x) ≡⟨ refl ⟩
(incAb y) ·Ab (incAb x) ∎)
-- The proof that the abelianization is in fact an abelian group.
asAbelianGroup : AbGroup ℓ
asAbelianGroup = makeAbGroup 1Ab _·Ab_ invAb squash assocAb ridAb rinvAb commAb
-- The proof that incAb can be seen as a group homomorphism
incAbAsGroupHom : GroupHom G (AbGroup→Group asAbelianGroup)
incAbAsGroupHom = f , fIsHom
where
f = λ x → incAb x
fIsHom : IsGroupHom (snd G) f (snd (AbGroup→Group asAbelianGroup))
IsGroupHom.pres· fIsHom = λ x y → refl
IsGroupHom.pres1 fIsHom = refl
IsGroupHom.presinv fIsHom = λ x → refl
AbelianizationAbGroup : (G : Group ℓ) → AbGroup ℓ
AbelianizationAbGroup G = AbelianizationAsCoeq.asAbelianGroup G
AbelianizationHom : (G : Group ℓ) → GroupHom G (AbGroup→Group (AbelianizationAbGroup G))
AbelianizationHom G = AbelianizationAsCoeq.incAbAsGroupHom G
module UniversalPropertyCoeq (G : Group ℓ) where
open GroupStr {{...}}
open GroupTheory G
open AbelianizationAsCoeq G
private
instance
_ = snd G
G' = fst G
abstract
{- The proof of the universal property of the abelianization.
G -incAb-> Abelianization
\ .
\ .
f ∃! inducedHom
\ .
\ .
H
commuting diagram
-}
inducedHom : (H : AbGroup ℓ)
→ (f : GroupHom G (AbGroup→Group H))
→ AbGroupHom asAbelianGroup H
inducedHom H f = g , gIsHom
where open IsGroupHom
instance
_ : GroupStr (fst H)
_ = snd (AbGroup→Group H)
f' : fst G → fst H
f' = fst f
g : Abelianization → fst H
g = rec
(isSetAbGroup H)
(λ x → (f') x)
(λ (a , b , c) →
f' (a · b · c) ≡⟨ (snd f).pres· a (b · c) ⟩
(f' a) · (f' (b · c)) ≡⟨ cong (λ x → (f' a) · x) ((snd f).pres· b c) ⟩
(f' a) · (f' b) · (f' c) ≡⟨ cong (λ x → (f' a) · x)
((snd H).AbGroupStr.comm (f' b) (f' c)) ⟩
(f' a) · (f' c) · (f' b) ≡⟨ cong (λ x → (f' a) · x)
(sym ((snd f).pres· c b)) ⟩
(f' a) · (f' (c · b)) ≡⟨ sym ((snd f).pres· a (c · b)) ⟩
f' (a · c · b) ∎)
gIsHom : IsGroupHom (snd (AbGroup→Group asAbelianGroup)) g (snd (AbGroup→Group H))
pres· gIsHom =
elimProp2
(λ x y → isSetAbGroup H _ _)
((snd f).pres·)
pres1 gIsHom = (snd f).pres1
presinv gIsHom =
elimProp
(λ x → isSetAbGroup H _ _)
((snd f).presinv)
commutativity : (H : AbGroup ℓ)
→ (f : GroupHom G (AbGroup→Group H))
→ (compGroupHom incAbAsGroupHom (inducedHom H f) ≡ f)
commutativity H f =
Σ≡Prop
(λ _ → isPropIsGroupHom _ _)
(λ i x → q x i)
where q : (x : fst G)
→ fst (compGroupHom incAbAsGroupHom (inducedHom H f)) x ≡ fst f x
q = (λ x → refl)
uniqueness : (H : AbGroup ℓ)
→ (f : GroupHom G (AbGroup→Group H))
→ (g : AbGroupHom asAbelianGroup H)
→ (p : compGroupHom incAbAsGroupHom g ≡ f)
→ (g ≡ inducedHom H f)
uniqueness H f g p =
Σ≡Prop
(λ _ → isPropIsGroupHom _ _)
(λ i x → q x i)
where q : (x : Abelianization)
→ fst g x ≡ fst (inducedHom H f) x
q = elimProp
(λ _ → isSetAbGroup H _ _)
(λ x → fst g (incAb x) ≡⟨ cong (λ f → f x) (cong fst p) ⟩
(fst f) x ≡⟨ refl ⟩
fst (inducedHom H f) (incAb x)∎)
module IsoCoeqHIT (G : Group ℓ) where
open GroupStr {{...}}
open GroupTheory G
open AbelianizationAsCoeq G
open UniversalPropertyCoeq G
private
instance
_ = snd G
G' = fst G
{- The proof that defining the abelianization of groups as a coequalizer of sets is equivalent
to defining it as a HIT, more precisely that there is an isomorphism between the resulting
abelian groups unique with respect to commuting with the constructors η and inc.
G -incAb-> abelianization as coequalizer
\ .
\ .
η ∃! isomorphism
\ .
\ .
abelianization as HIT
commuting diagram
-}
isomorphism : AbGroupIso asAbelianGroup (HITasAbelianGroup G)
isomorphism = h , hIsHomo
where
f = inducedHom (HITasAbelianGroup G) (HITηAsGroupHom G)
g = HITinducedHom G asAbelianGroup incAbAsGroupHom
HITgfcomm : compGroupHom (HITηAsGroupHom G) (compGroupHom g f) ≡ (HITηAsGroupHom G)
HITgfcomm =
compGroupHom (HITηAsGroupHom G) (compGroupHom g f)
≡⟨ sym (compGroupHomAssoc (HITηAsGroupHom G) g f) ⟩
compGroupHom (compGroupHom (HITηAsGroupHom G) g) f
≡⟨ cong (λ x → compGroupHom x f) (HITcommutativity G asAbelianGroup incAbAsGroupHom) ⟩
compGroupHom incAbAsGroupHom f
≡⟨ commutativity (HITasAbelianGroup G) (HITηAsGroupHom G) ⟩
(HITηAsGroupHom G) ∎
HITidcomm : compGroupHom (HITηAsGroupHom G) idGroupHom ≡ HITηAsGroupHom G
HITidcomm = compGroupHomId (HITηAsGroupHom G)
HITidIsInduced : HITinducedHom G (HITasAbelianGroup G) (HITηAsGroupHom G) ≡ idGroupHom
HITidIsInduced = sym (HITuniqueness G
(HITasAbelianGroup G)
(HITηAsGroupHom G)
idGroupHom
HITidcomm)
HITgfIsInduced : HITinducedHom G (HITasAbelianGroup G) (HITηAsGroupHom G) ≡ compGroupHom g f
HITgfIsInduced = sym (HITuniqueness G
(HITasAbelianGroup G)
(HITηAsGroupHom G)
(compGroupHom g f)
HITgfcomm)
i : idGroupHom ≡ compGroupHom g f
i = idGroupHom ≡⟨ sym HITidIsInduced ⟩
HITinducedHom G (HITasAbelianGroup G) (HITηAsGroupHom G) ≡⟨ HITgfIsInduced ⟩
compGroupHom g f ∎
fgcomm : compGroupHom incAbAsGroupHom (compGroupHom f g) ≡ incAbAsGroupHom
fgcomm =
compGroupHom incAbAsGroupHom (compGroupHom f g)
≡⟨ sym (compGroupHomAssoc incAbAsGroupHom f g) ⟩
compGroupHom (compGroupHom incAbAsGroupHom f) g
≡⟨ cong (λ x → compGroupHom x g) (commutativity (HITasAbelianGroup G) (HITηAsGroupHom G)) ⟩
compGroupHom (HITηAsGroupHom G) g
≡⟨ (HITcommutativity G) asAbelianGroup incAbAsGroupHom ⟩
incAbAsGroupHom ∎
idcomm : compGroupHom incAbAsGroupHom idGroupHom ≡ incAbAsGroupHom
idcomm = compGroupHomId incAbAsGroupHom
idIsInduced : inducedHom asAbelianGroup incAbAsGroupHom ≡ idGroupHom
idIsInduced = sym (uniqueness asAbelianGroup incAbAsGroupHom idGroupHom idcomm)
fgIsInduced : inducedHom asAbelianGroup incAbAsGroupHom ≡ compGroupHom f g
fgIsInduced = sym (uniqueness asAbelianGroup incAbAsGroupHom (compGroupHom f g) fgcomm)
j : idGroupHom ≡ compGroupHom f g
j = idGroupHom ≡⟨ sym idIsInduced ⟩
inducedHom asAbelianGroup incAbAsGroupHom ≡⟨ fgIsInduced ⟩
compGroupHom f g ∎
h = iso
(fst f)
(fst g)
(λ b → cong (λ e → e b) (cong fst (sym i)))
(λ a → cong (λ e → e a) (cong fst (sym j)))
hIsHomo = snd f
isomorphismCommutativity : compGroupHom incAbAsGroupHom (GroupIso→GroupHom isomorphism)
≡ (HITηAsGroupHom G)
isomorphismCommutativity = commutativity (HITasAbelianGroup G) (HITηAsGroupHom G)
isomorphismUniqueness : (h : AbGroupIso asAbelianGroup (HITasAbelianGroup G))
→ (hcomm : compGroupHom incAbAsGroupHom (GroupIso→GroupHom h) ≡ (HITηAsGroupHom G))
→ h ≡ isomorphism
isomorphismUniqueness h hcomm = GroupIso≡ p
where
r : (x : fst asAbelianGroup)
→ fst (compGroupHom (GroupIso→GroupHom h) (GroupIso→GroupHom (invGroupIso h))) x ≡ x
r = λ x → (h .fst .Iso.leftInv) x
leftInvGroupHom : (compGroupHom
(GroupIso→GroupHom h)
(GroupIso→GroupHom (invGroupIso h))) ≡ idGroupHom
leftInvGroupHom =
Σ≡Prop
(λ _ → isPropIsGroupHom _ _)
(λ i x → r x i)
q : (g : fst G)
→ fst (compGroupHom
(HITηAsGroupHom G)
(GroupIso→GroupHom (invGroupIso h))) g ≡ fst incAbAsGroupHom g
q = λ g
→ fst (compGroupHom (HITηAsGroupHom G) (GroupIso→GroupHom (invGroupIso h))) g
≡⟨ cong
(λ f → f g)
(cong fst (cong
(λ f → compGroupHom f (GroupIso→GroupHom (invGroupIso h)))
(sym hcomm))) ⟩
fst (compGroupHom
(compGroupHom incAbAsGroupHom (GroupIso→GroupHom h))
(GroupIso→GroupHom (invGroupIso h))) g
≡⟨ cong
(λ f → f g)
(cong fst (compGroupHomAssoc
incAbAsGroupHom
(GroupIso→GroupHom h)
(GroupIso→GroupHom (invGroupIso h)))) ⟩
fst (compGroupHom
incAbAsGroupHom
(compGroupHom (GroupIso→GroupHom h) (GroupIso→GroupHom (invGroupIso h)))) g
≡⟨ cong
(λ f → f g)
(cong fst (cong (λ f → (compGroupHom incAbAsGroupHom f)) leftInvGroupHom)) ⟩
fst incAbAsGroupHom g ∎
isocomm : compGroupHom
(HITηAsGroupHom G)
(GroupIso→GroupHom (invGroupIso h)) ≡ incAbAsGroupHom
isocomm =
Σ≡Prop
(λ _ → isPropIsGroupHom _ _)
(λ i x → q x i)
p : h .fst ≡ isomorphism .fst
p =
Iso≡Set
(isSetAbGroup asAbelianGroup)
(isSetAbGroup (HITasAbelianGroup G))
(h .fst)
(isomorphism .fst)
(λ x → cong
(λ f → f x)
(cong fst (uniqueness
(HITasAbelianGroup G)
(HITηAsGroupHom G)
(GroupIso→GroupHom h)
hcomm)))
(λ x → cong
(λ f → f x)
(cong fst (HITuniqueness G
asAbelianGroup
incAbAsGroupHom
(GroupIso→GroupHom (invGroupIso h))
isocomm)))
AbelianizationComparisonIsomorphism : (G : Group ℓ)
→ AbGroupIso (AbelianizationAbGroup G) (HITasAbelianGroup G)
AbelianizationComparisonIsomorphism G = IsoCoeqHIT.isomorphism G
| {
"alphanum_fraction": 0.532746253,
"avg_line_length": 38.9704545455,
"ext": "agda",
"hexsha": "cafd9679a9e1348c9ad7008a9b87d0d7812d103e",
"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": "1d9b9691d375659fa8ebd9cbf8b63678955b196b",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "gmagaf/cubical",
"max_forks_repo_path": "Cubical/Algebra/Group/Abelianization/AbelianizationAsCoeq.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "1d9b9691d375659fa8ebd9cbf8b63678955b196b",
"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": "gmagaf/cubical",
"max_issues_repo_path": "Cubical/Algebra/Group/Abelianization/AbelianizationAsCoeq.agda",
"max_line_length": 99,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "1d9b9691d375659fa8ebd9cbf8b63678955b196b",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "gmagaf/cubical",
"max_stars_repo_path": "Cubical/Algebra/Group/Abelianization/AbelianizationAsCoeq.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 5584,
"size": 17147
} |
module list-to-string where
open import list
open import string
𝕃-to-string : ∀ {ℓ} {A : Set ℓ} → (f : A → string) → (separator : string) → 𝕃 A → string
𝕃-to-string f sep [] = ""
𝕃-to-string f sep (x1 :: (x2 :: xs)) = (f x1) ^ sep ^ (𝕃-to-string f sep (x2 :: xs))
𝕃-to-string f sep (x1 :: []) = (f x1)
| {
"alphanum_fraction": 0.5639344262,
"avg_line_length": 30.5,
"ext": "agda",
"hexsha": "42726adc690c5bcd374c28bcc9d432eb8e17e8ad",
"lang": "Agda",
"max_forks_count": 17,
"max_forks_repo_forks_event_max_datetime": "2021-11-28T20:13:21.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-12-03T22:38:15.000Z",
"max_forks_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "rfindler/ial",
"max_forks_repo_path": "list-to-string.agda",
"max_issues_count": 8,
"max_issues_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6",
"max_issues_repo_issues_event_max_datetime": "2022-03-22T03:43:34.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-07-09T22:53:38.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "rfindler/ial",
"max_issues_repo_path": "list-to-string.agda",
"max_line_length": 88,
"max_stars_count": 29,
"max_stars_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "rfindler/ial",
"max_stars_repo_path": "list-to-string.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-04T15:05:12.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-02-06T13:09:31.000Z",
"num_tokens": 123,
"size": 305
} |
module AbstractRationals where
open import Algebra
open import Data.Integer.Base using (+0)
open import Data.Maybe.Base using (just; nothing; decToMaybe)
open import Data.Rational.Base as ℚ public hiding (_+_; _*_; _-_)
open import Data.Rational.Properties as ℚ public
using (module ≤-Reasoning; <⇒≤)
open import Relation.Binary
open import Relation.Binary.PropositionalEquality
open import Function.Base
open import Data.Product using (_×_; _,_)
open import Tactic.RingSolver.Core.AlmostCommutativeRing
open import Tactic.RingSolver.NonReflective (fromCommutativeRing ℚ.+-*-commutativeRing (λ x → decToMaybe (0ℚ ℚ.≟ x)))
open import RationalUtils as ℚ public using (2ℚ; 3ℚ)
infixl 7 _*_
infixl 6 _+_ _-_
abstract
_+_ : ℚ → ℚ → ℚ
_+_ = ℚ._+_
_*_ : ℚ → ℚ → ℚ
_*_ = ℚ._*_
_-_ : ℚ → ℚ → ℚ
_-_ = ℚ._-_
+-eq : _+_ ≡ ℚ._+_
+-eq = refl
*-eq : _*_ ≡ ℚ._*_
*-eq = refl
neg-eq : _-_ ≡ ℚ._-_
neg-eq = refl
p+q-p≡q : ∀ p q → p + q - p ≡ q
p+q-p≡q = ℚ.p+q-p≡q
p+q-q≡p : ∀ p q → p + q - q ≡ p
p+q-q≡p = ℚ.p+q-q≡p
p-q+q≡p : ∀ p q → p - q + q ≡ p
p-q+q≡p = ℚ.p-q+q≡p
p-[p+q]≡q : ∀ p q → p - (p + q) ≡ q
p-[p+q]≡q = ℚ.p-[p+q]≡q
∣p-q∣≤∣p∣+∣q∣ : ∀ p q → ∣ p - q ∣ ≤ ∣ p ∣ + ∣ q ∣
∣p-q∣≤∣p∣+∣q∣ = ℚ.∣p-q∣≤∣p∣+∣q∣
∣p∣≤q⇒-q≤p≤q : ∀ p {q} → ∣ p ∣ ≤ q → - q ≤ p × p ≤ q
∣p∣≤q⇒-q≤p≤q p = ℚ.∣p∣≤q⇒-q≤p≤q p
-p<q<p⇒∣q∣<p : ∀ {p q} → - p < q → q < p → ∣ q ∣ < p
-p<q<p⇒∣q∣<p = ℚ.-p<q<p⇒∣q∣<p
2*p≡p+p : ∀ p → 2ℚ * p ≡ p + p
2*p≡p+p = ℚ.2*p≡p+p
+-assoc : Associative _≡_ _+_
+-assoc = ℚ.+-assoc
+-monoˡ-≤ : ∀ r → (_+ r) Preserves _≤_ ⟶ _≤_
+-monoˡ-≤ = ℚ.+-monoˡ-≤
+-monoʳ-≤ : ∀ r → (_+_ r) Preserves _≤_ ⟶ _≤_
+-monoʳ-≤ = ℚ.+-monoʳ-≤
+-mono-≤ : _+_ Preserves₂ _≤_ ⟶ _≤_ ⟶ _≤_
+-mono-≤ = ℚ.+-mono-≤
*-monoʳ-≤ : ∀ r → Positive r → (r *_) Preserves _≤_ ⟶ _≤_
*-monoʳ-≤ = ℚ.*-monoʳ-≤
∣p+q∣≤∣p∣+∣q∣ : ∀ p q → ∣ p + q ∣ ≤ ∣ p ∣ + ∣ q ∣
∣p+q∣≤∣p∣+∣q∣ = ℚ.∣p+q∣≤∣p∣+∣q∣
∣p*q∣≡∣p∣*∣q∣ : ∀ p q → ∣ p * q ∣ ≡ ∣ p ∣ * ∣ q ∣
∣p*q∣≡∣p∣*∣q∣ = ℚ.∣p*q∣≡∣p∣*∣q∣
p<r-q⇒p+q<r : ∀ p q r → p < r - q → p + q < r
p<r-q⇒p+q<r = ℚ.p<r-q⇒p+q<r
2p+p≡3p : ∀ p → 2ℚ * p + p ≡ 3ℚ * p
2p+p≡3p p = begin-equality
2ℚ * p + p ≡⟨ cong (2ℚ * p +_) (sym (ℚ.*-identityˡ p)) ⟩
2ℚ * p + 1ℚ * p ≡⟨ sym (ℚ.*-distribʳ-+ p 2ℚ 1ℚ) ⟩
(2ℚ + 1ℚ) * p ∎
where open ≤-Reasoning
lem1 : ∀ a b c d e f g → a + (b + c) + d + (e + f + f - g) - (e + f + f - g) ≡
c + (a + f + (e + b + d + f)) - g - (f + f + (e - g))
lem1 = solve 7 (λ a b c d e f g → (a ⊕ (b ⊕ c) ⊕ d ⊕ (e ⊕ f ⊕ f ⊕ (⊝ g)) ⊕ (⊝ (e ⊕ f ⊕ f ⊕ (⊝ g))) ,
c ⊕ (a ⊕ f ⊕ (e ⊕ b ⊕ d ⊕ f)) ⊕ (⊝ g) ⊕ (⊝ (f ⊕ f ⊕ (e ⊕ (⊝ g)))))) refl
| {
"alphanum_fraction": 0.4472913616,
"avg_line_length": 26.5242718447,
"ext": "agda",
"hexsha": "d965c776aab206135f9e0506c6ef7523dc7d85dd",
"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": "25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "vehicle-lang/vehicle",
"max_forks_repo_path": "examples/windController/agdaProof/AbstractRationals.agda",
"max_issues_count": 19,
"max_issues_repo_head_hexsha": "25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T20:49:39.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-03-07T14:09:13.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "vehicle-lang/vehicle",
"max_issues_repo_path": "examples/windController/agdaProof/AbstractRationals.agda",
"max_line_length": 117,
"max_stars_count": 9,
"max_stars_repo_head_hexsha": "25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "vehicle-lang/vehicle",
"max_stars_repo_path": "examples/windController/agdaProof/AbstractRationals.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-17T18:51:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2022-02-10T12:56:42.000Z",
"num_tokens": 1614,
"size": 2732
} |
module Issue461 where
data D : Set where
data D : Set where
| {
"alphanum_fraction": 0.7258064516,
"avg_line_length": 10.3333333333,
"ext": "agda",
"hexsha": "edc80b7a7e7da673c8dc71d61935e62221d9ec8d",
"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/Issue461.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/Issue461.agda",
"max_line_length": 21,
"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/Issue461.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": 18,
"size": 62
} |
{-# OPTIONS --no-auto-inline #-}
module Where where
open import Haskell.Prelude hiding (_+_; _*_; _-_)
open import Agda.Builtin.Nat
postulate
bool2nat : Bool → Nat
-- no outer arguments
ex1 : Nat
ex1 = mult num + bool2nat true
where
num : Nat
num = 42
mult : Nat → Nat
mult = _* 100
-- nested where
ex2 : Nat
ex2 = mult num + bool2nat true
where
num : Nat
num = 42
mult : Nat → Nat
mult = _⊗ 100
where
_⊗_ = _*_
-- with outer arguments
ex3 : Nat → Bool → Nat
ex3 n b = mult num + bool2nat b
where
num = 42 + bool2nat b
mult : Nat → Nat
mult = _* n
-- nested where with outer arguments
ex4 : Bool → Nat
ex4 b = mult 42
where
mult : Nat → Nat
mult n = bump n (bool2nat b)
where
bump : Nat → Nat → Nat
bump x y = x * y + (n - bool2nat b)
ex4' : Bool → Nat
ex4' b = mult (bool2nat b)
where
mult : Nat → Nat
mult n = bump n (bool2nat b)
where
bump : Nat → Nat → Nat
bump x y = go (x * y) (n - bool2nat b)
where
go : Nat → Nat → Nat
go z w = z + x + w + y + n + bool2nat b
-- with pattern matching and multiple clauses
ex5 : List Nat → Nat
ex5 [] = zro
where
zro : Nat
zro = 0
ex5 (n ∷ ns) = mult num + 1
where
num = 42 + ex5 ns
mult : Nat → Nat
mult = _* n
-- mix of patterns + inner multiple clauses + nested where
ex6 : List Nat → Bool → Nat
ex6 [] b = zro
where
zro : Nat
zro = 0
ex6 (n ∷ ns) b = mult (num ∷ 1 ∷ [])
where
mult : List Nat → Nat
mult [] = bump 5 (bool2nat b)
where
bump : Nat → Nat → Nat
bump x y = x * y + n
mult (m ∷ ms) = bump n m
where
bump : Nat → Nat → Nat
bump x y = x * y + (m - n)
num = 42 + ex6 ns true
ex7 : Nat → Nat
ex7 n₀ = go₁ n₀
where
go₁ : Nat → Nat
go₁ n₁ = go₂ (n₀ + n₁)
where
go₂ : Nat → Nat
go₂ n₂ = n₀ + n₁ + n₂
ex7' : Nat → Nat
ex7' n₀ = go₁ n₀
where
go₁ : Nat → Nat
go₁ n₁ = go₂ (n₀ + n₁)
where
go₂ : Nat → Nat
go₂ n₂ = go₃ (n₀ + n₁ + n₂)
where
go₃ : Nat → Nat
go₃ n₃ = n₀ + n₁ + n₂ + n₃
ex8 : Nat
ex8 = n₂
where
n₁ : Nat
n₁ = 1
n₂ = n₁ + 1
{-# COMPILE AGDA2HS bool2nat #-}
{-# COMPILE AGDA2HS ex1 #-}
{-# COMPILE AGDA2HS ex2 #-}
{-# COMPILE AGDA2HS ex3 #-}
{-# COMPILE AGDA2HS ex4 #-}
{-# COMPILE AGDA2HS ex4' #-}
{-# COMPILE AGDA2HS ex5 #-}
{-# COMPILE AGDA2HS ex6 #-}
{-# COMPILE AGDA2HS ex7 #-}
{-# COMPILE AGDA2HS ex7' #-}
{-# COMPILE AGDA2HS ex8 #-}
| {
"alphanum_fraction": 0.5193498452,
"avg_line_length": 19.1407407407,
"ext": "agda",
"hexsha": "9003207b99756d6c531173a78db65ca53286e794",
"lang": "Agda",
"max_forks_count": 18,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:42:52.000Z",
"max_forks_repo_forks_event_min_datetime": "2020-10-21T22:19:09.000Z",
"max_forks_repo_head_hexsha": "160478a51bc78b0fdab07b968464420439f9fed6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "seanpm2001/agda2hs",
"max_forks_repo_path": "test/Where.agda",
"max_issues_count": 63,
"max_issues_repo_head_hexsha": "160478a51bc78b0fdab07b968464420439f9fed6",
"max_issues_repo_issues_event_max_datetime": "2022-02-25T15:47:30.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-10-22T05:19:27.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "seanpm2001/agda2hs",
"max_issues_repo_path": "test/Where.agda",
"max_line_length": 58,
"max_stars_count": 55,
"max_stars_repo_head_hexsha": "8c8f24a079ed9677dbe6893cf786e7ed52dfe8b6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "dxts/agda2hs",
"max_stars_repo_path": "test/Where.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-26T21:57:56.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-20T13:36:25.000Z",
"num_tokens": 965,
"size": 2584
} |
-- Andreas, 2015-10-05, issue reported by mechvel, test case by Jesper Cockx
-- {-# OPTIONS -v tc.term.exlam:20 #-}
abstract
foo : Set₁
foo = Set
where
AbstractSet₁ : Set₂
AbstractSet₁ = Set₁
f : Set → AbstractSet₁
f = λ { _ → Set }
{-# NON_TERMINATING #-}
loop : Set → Set
loop = λ { A → loop A }
| {
"alphanum_fraction": 0.5855855856,
"avg_line_length": 19.5882352941,
"ext": "agda",
"hexsha": "f2ad0a64be9a5ce5b72b77311a0dfc818d8878aa",
"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/Issue1677.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/Issue1677.agda",
"max_line_length": 76,
"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/Issue1677.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": 108,
"size": 333
} |
module Issue65 where
open import Haskell.Prelude
yeet : (c : Bool) → ({{c ≡ true}} → a) → ({{c ≡ false}} → a) → a
yeet false x y = y {{refl}}
yeet true x y = x {{refl}}
{-# COMPILE AGDA2HS yeet #-}
-- The branches start with instance lambdas that should be dropped.
xx : Int
xx = yeet true 1 2
{-# COMPILE AGDA2HS xx #-}
| {
"alphanum_fraction": 0.6165644172,
"avg_line_length": 21.7333333333,
"ext": "agda",
"hexsha": "0824a4a8d0de5585bafb2ed026efe38b91495983",
"lang": "Agda",
"max_forks_count": 18,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:42:52.000Z",
"max_forks_repo_forks_event_min_datetime": "2020-10-21T22:19:09.000Z",
"max_forks_repo_head_hexsha": "160478a51bc78b0fdab07b968464420439f9fed6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "seanpm2001/agda2hs",
"max_forks_repo_path": "test/Issue65.agda",
"max_issues_count": 63,
"max_issues_repo_head_hexsha": "160478a51bc78b0fdab07b968464420439f9fed6",
"max_issues_repo_issues_event_max_datetime": "2022-02-25T15:47:30.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-10-22T05:19:27.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "seanpm2001/agda2hs",
"max_issues_repo_path": "test/Issue65.agda",
"max_line_length": 67,
"max_stars_count": 55,
"max_stars_repo_head_hexsha": "8c8f24a079ed9677dbe6893cf786e7ed52dfe8b6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "dxts/agda2hs",
"max_stars_repo_path": "test/Issue65.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-26T21:57:56.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-20T13:36:25.000Z",
"num_tokens": 114,
"size": 326
} |
{-# OPTIONS --safe #-}
module Cubical.Algebra.Polynomials.Multivariate.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Data.Nat renaming (_+_ to _+n_)
open import Cubical.Data.Vec
open import Cubical.Algebra.Ring
open import Cubical.Algebra.CommRing
private variable
ℓ ℓ' : Level
module _ (A' : CommRing ℓ) where
private
A = fst A'
open CommRingStr (snd A')
-----------------------------------------------------------------------------
-- Definition
data Poly (n : ℕ) : Type ℓ where
-- elements
0P : Poly n
base : (v : Vec ℕ n) → (a : A) → Poly n
_Poly+_ : (P : Poly n) → (Q : Poly n) → Poly n
-- AbGroup eq
Poly+-assoc : (P Q R : Poly n) → P Poly+ (Q Poly+ R) ≡ (P Poly+ Q) Poly+ R
Poly+-Rid : (P : Poly n) → P Poly+ 0P ≡ P
Poly+-comm : (P Q : Poly n) → P Poly+ Q ≡ Q Poly+ P
-- Base eq
base-0P : (v : Vec ℕ n) → base v 0r ≡ 0P
base-Poly+ : (v : Vec ℕ n) → (a b : A) → (base v a) Poly+ (base v b) ≡ base v (a + b)
-- Set Trunc
trunc : isSet(Poly n)
-----------------------------------------------------------------------------
-- Induction and Recursion
module _ (A' : CommRing ℓ) where
private
A = fst A'
open CommRingStr (snd A')
module Poly-Ind-Set
-- types
(n : ℕ)
(F : (P : Poly A' n) → Type ℓ')
(issd : (P : Poly A' n) → isSet (F P))
-- elements
(0P* : F 0P)
(base* : (v : Vec ℕ n) → (a : A) → F (base v a))
(_Poly+*_ : {P Q : Poly A' n} → (PS : F P) → (QS : F Q) → F (P Poly+ Q))
-- AbGroup eq
(Poly+-assoc* : {P Q R : Poly A' n} → (PS : F P) → (QS : F Q) → (RS : F R)
→ PathP (λ i → F (Poly+-assoc P Q R i)) (PS Poly+* (QS Poly+* RS)) ((PS Poly+* QS) Poly+* RS))
(Poly+-Rid* : {P : Poly A' n} → (PS : F P) →
PathP (λ i → F (Poly+-Rid P i)) (PS Poly+* 0P*) PS)
(Poly+-comm* : {P Q : Poly A' n} → (PS : F P) → (QS : F Q)
→ PathP (λ i → F (Poly+-comm P Q i)) (PS Poly+* QS) (QS Poly+* PS))
-- Base eq
(base-0P* : (v : Vec ℕ n) → PathP (λ i → F (base-0P v i)) (base* v 0r) 0P*)
(base-Poly+* : (v : Vec ℕ n) → (a b : A)
→ PathP (λ i → F (base-Poly+ v a b i)) ((base* v a) Poly+* (base* v b)) (base* v (a + b)))
where
f : (P : Poly A' n) → F P
f 0P = 0P*
f (base v a) = base* v a
f (P Poly+ Q) = (f P) Poly+* (f Q)
f (Poly+-assoc P Q R i) = Poly+-assoc* (f P) (f Q) (f R) i
f (Poly+-Rid P i) = Poly+-Rid* (f P) i
f (Poly+-comm P Q i) = Poly+-comm* (f P) (f Q) i
f (base-0P v i) = base-0P* v i
f (base-Poly+ v a b i) = base-Poly+* v a b i
f (trunc P Q p q i j) = isOfHLevel→isOfHLevelDep 2 issd (f P) (f Q) (cong f p) (cong f q) (trunc P Q p q) i j
module Poly-Rec-Set
-- types
(n : ℕ)
(B : Type ℓ')
(iss : isSet B)
-- elements
(0P* : B)
(base* : (v : Vec ℕ n) → (a : A) → B)
(_Poly+*_ : B → B → B)
-- AbGroup eq
(Poly+-assoc* : (PS QS RS : B) → (PS Poly+* (QS Poly+* RS)) ≡ ((PS Poly+* QS) Poly+* RS))
(Poly+-Rid* : (PS : B) → (PS Poly+* 0P*) ≡ PS)
(Poly+-comm* : (PS QS : B) → (PS Poly+* QS) ≡ (QS Poly+* PS))
-- Base eq
(base-0P* : (v : Vec ℕ n) → (base* v 0r) ≡ 0P*)
(base-Poly+* : (v : Vec ℕ n) → (a b : A) → ((base* v a) Poly+* (base* v b)) ≡ (base* v (a + b)))
where
f : Poly A' n → B
f = Poly-Ind-Set.f n (λ _ → B) (λ _ → iss) 0P* base* _Poly+*_ Poly+-assoc* Poly+-Rid* Poly+-comm* base-0P* base-Poly+*
module Poly-Ind-Prop
-- types
(n : ℕ)
(F : (P : Poly A' n) → Type ℓ')
(ispd : (P : Poly A' n) → isProp (F P))
-- elements
(0P* : F 0P)
(base* : (v : Vec ℕ n) → (a : A) → F (base v a))
(_Poly+*_ : {P Q : Poly A' n} → (PS : F P) → (QS : F Q) → F (P Poly+ Q))
where
f : (P : Poly A' n) → F P
f = Poly-Ind-Set.f n F (λ P → isProp→isSet (ispd P)) 0P* base* _Poly+*_
(λ {P Q R} PS QS RQ → toPathP (ispd _ (transport (λ i → F (Poly+-assoc P Q R i)) _) _))
(λ {P} PS → toPathP (ispd _ (transport (λ i → F (Poly+-Rid P i)) _) _))
(λ {P Q} PS QS → toPathP (ispd _ (transport (λ i → F (Poly+-comm P Q i)) _) _))
(λ v → toPathP (ispd _ (transport (λ i → F (base-0P v i)) _) _))
(λ v a b → toPathP (ispd _ (transport (λ i → F (base-Poly+ v a b i)) _) _))
module Poly-Rec-Prop
-- types
(n : ℕ)
(B : Type ℓ')
(isp : isProp B)
-- elements
(0P* : B)
(base* : (v : Vec ℕ n) → (a : A) → B)
(_Poly+*_ : B → B → B)
where
f : Poly A' n → B
f = Poly-Ind-Prop.f n (λ _ → B) (λ _ → isp) 0P* base* _Poly+*_
| {
"alphanum_fraction": 0.4509762755,
"avg_line_length": 35.0220588235,
"ext": "agda",
"hexsha": "d94f9f5239392152cddb3524d4afc9ad64ee4f84",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "howsiyu/cubical",
"max_forks_repo_path": "Cubical/Algebra/Polynomials/Multivariate/Base.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "howsiyu/cubical",
"max_issues_repo_path": "Cubical/Algebra/Polynomials/Multivariate/Base.agda",
"max_line_length": 122,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "howsiyu/cubical",
"max_stars_repo_path": "Cubical/Algebra/Polynomials/Multivariate/Base.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1939,
"size": 4763
} |
open import Agda.Builtin.Sigma renaming (fst to proj₁; snd to proj₂)
open import Agda.Builtin.Nat renaming (Nat to ℕ)
NEX : Set₁
NEX = Σ Set λ A → (ℕ → A)
variable
A : NEX
B : A .proj₁ → NEX
[Σ] : (A : NEX) → (B : A .proj₁ → NEX) → NEX
[Σ] A B .proj₁ = Σ (A .proj₁) λ x → B x .proj₁
[Σ] A B .proj₂ n = A .proj₂ n , B _ .proj₂ n
_[→]_ : (A B : NEX) → NEX
(A [→] B) .proj₁ = A .proj₁ → B .proj₁
(A [→] B) .proj₂ n x = B .proj₂ n
-- B.A is underdetermined and solved with (A .proj₁ , _snd) for a fresh meta
-- _snd : ℕ → A .proj₁, which is then generalized over. The bug was that _snd
-- turned into an explicit rather than implicit argument.
[π₁] : ([Σ] A B [→] A) .proj₁
[π₁] {A = A} {B = B} {snd = snd} x = x .proj₁
| {
"alphanum_fraction": 0.5895316804,
"avg_line_length": 29.04,
"ext": "agda",
"hexsha": "9457f6888f5478f31d39f2326abb5e7e7bf7ceac",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "shlevy/agda",
"max_forks_repo_path": "test/Succeed/Issue4970.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Succeed/Issue4970.agda",
"max_line_length": 77,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/Issue4970.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 311,
"size": 726
} |
module Haskell.Prim.Tuple where
open import Agda.Builtin.List
open import Haskell.Prim
private
variable
as : List Set
--------------------------------------------------
-- Tuples
infixr 5 _∷_
data Tuple : List Set → Set where
[] : Tuple []
_∷_ : a → Tuple as → Tuple (a ∷ as)
infix 3 _×_ _×_×_
_×_ : (a b : Set) → Set
a × b = Tuple (a ∷ b ∷ [])
_×_×_ : (a b c : Set) → Set
a × b × c = Tuple (a ∷ b ∷ c ∷ [])
infix -1 _,_ _,_,_
pattern _,_ x y = x Tuple.∷ y Tuple.∷ []
pattern _,_,_ x y z = x Tuple.∷ y Tuple.∷ z Tuple.∷ []
uncurry : (a → b → c) → a × b → c
uncurry f (x , y) = f x y
curry : (a × b → c) → a → b → c
curry f x y = f (x , y)
fst : a × b → a
fst (x , _) = x
snd : a × b → b
snd (_ , y) = y
first : (a → b) → a × c → b × c
first f (x , y) = f x , y
second : (a → b) → c × a → c × b
second f (x , y) = x , f y
_***_ : (a → b) → (c → d) → a × c → b × d
(f *** g) (x , y) = f x , g y
| {
"alphanum_fraction": 0.4421841542,
"avg_line_length": 17.6226415094,
"ext": "agda",
"hexsha": "e20333953639cd19be7f8312059d51b1b17a1b7d",
"lang": "Agda",
"max_forks_count": 18,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:42:52.000Z",
"max_forks_repo_forks_event_min_datetime": "2020-10-21T22:19:09.000Z",
"max_forks_repo_head_hexsha": "160478a51bc78b0fdab07b968464420439f9fed6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "seanpm2001/agda2hs",
"max_forks_repo_path": "lib/Haskell/Prim/Tuple.agda",
"max_issues_count": 63,
"max_issues_repo_head_hexsha": "160478a51bc78b0fdab07b968464420439f9fed6",
"max_issues_repo_issues_event_max_datetime": "2022-02-25T15:47:30.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-10-22T05:19:27.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "seanpm2001/agda2hs",
"max_issues_repo_path": "lib/Haskell/Prim/Tuple.agda",
"max_line_length": 58,
"max_stars_count": 55,
"max_stars_repo_head_hexsha": "8c8f24a079ed9677dbe6893cf786e7ed52dfe8b6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "dxts/agda2hs",
"max_stars_repo_path": "lib/Haskell/Prim/Tuple.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-26T21:57:56.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-20T13:36:25.000Z",
"num_tokens": 397,
"size": 934
} |
module Prelude.Vec where
open import Prelude.Nat
open import Prelude.Fin
open import Prelude.Function
open import Prelude.Functor
open import Prelude.Applicative
open import Prelude.List
open import Prelude.Equality
open import Prelude.Decidable
open import Prelude.Ord
open import Prelude.Semiring
infixr 5 _∷_
data Vec {a} (A : Set a) : Nat → Set a where
[] : Vec A zero
_∷_ : ∀ {n} (x : A) (xs : Vec A n) → Vec A (suc n)
private
-- These are private. Use pure and _<*>_ instead.
vec : ∀ {a} {A : Set a} {n} → A → Vec A n
vec {n = zero } x = []
vec {n = suc n} x = x ∷ vec x
vapp : ∀ {a b} {A : Set a} {B : Set b} {n} → Vec (A → B) n → Vec A n → Vec B n
vapp [] _ = []
vapp (f ∷ fs) (x ∷ xs) = f x ∷ vapp fs xs
vmap : ∀ {a b} {A : Set a} {B : Set b} {n} → (A → B) → Vec A n → Vec B n
vmap f [] = []
vmap f (x ∷ xs) = f x ∷ vmap f xs
vecToList : ∀ {a} {A : Set a} {@erased n} → Vec A n → List A
vecToList [] = []
vecToList (x ∷ xs) = x ∷ vecToList xs
listToVec : ∀ {a} {A : Set a} (xs : List A) → Vec A (length xs)
listToVec [] = []
listToVec (x ∷ xs) = x ∷ listToVec xs
--- Lookup ---
indexVec : ∀ {a} {A : Set a} {n} → Vec A n → Fin n → A
indexVec (x ∷ xs) zero = x
indexVec (x ∷ xs) (suc i) = indexVec xs i
tabulate : ∀ {a} {A : Set a} {n} → (Fin n → A) → Vec A n
tabulate {n = zero } f = []
tabulate {n = suc n} f = f zero ∷ tabulate (f ∘ suc)
--- Folding ---
vfoldr : ∀ {a b} {A : Set a} {B : Nat → Set b} → (∀ {@erased n} → A → B n → B (suc n)) → B 0 → ∀ {@erased n} → Vec A n → B n
vfoldr f z [] = z
vfoldr f z (x ∷ xs) = f x (vfoldr (λ {n} → f {n}) z xs)
vfoldl : ∀ {a b} {A : Set a} {B : Nat → Set b} → (∀ {n} → B n → A → B (suc n)) → B 0 → ∀ {@erased n} → Vec A n → B n
vfoldl f z [] = z
vfoldl {B = B} f z (x ∷ xs) = vfoldl {B = B ∘ suc} f (f z x) xs
--- Other list functions ---
module _ {a} {A : Set a} where
infixr 5 _v++_
_v++_ : ∀ {m n} → Vec A m → Vec A n → Vec A (m + n)
[] v++ ys = ys
(x ∷ xs) v++ ys = x ∷ xs v++ ys
vreverse : ∀ {@erased n} → Vec A n → Vec A n
vreverse xs = vfoldl {B = Vec A} (flip _∷_) [] xs
--- Equality ---
vcons-inj-head : ∀ {a} {A : Set a} {x y : A} {n}
{xs ys : Vec A n} → x Vec.∷ xs ≡ y ∷ ys → x ≡ y
vcons-inj-head refl = refl
vcons-inj-tail : ∀ {a} {A : Set a} {x y : A} {n}
{xs ys : Vec A n} → x Vec.∷ xs ≡ y ∷ ys → xs ≡ ys
vcons-inj-tail refl = refl
instance
EqVec : ∀ {a} {A : Set a} {{EqA : Eq A}} {n} → Eq (Vec A n)
_==_ {{EqVec}} [] [] = yes refl
_==_ {{EqVec}} (x ∷ xs) (y ∷ ys) with x == y
... | no neq = no λ eq → neq (vcons-inj-head eq)
... | yes eq with xs == ys
... | no neq = no λ eq₁ → neq (vcons-inj-tail eq₁)
... | yes eq₁ = yes (_∷_ $≡ eq *≡ eq₁)
--- Ord ---
data LessVec {a} {A : Set a} {{OrdA : Ord A}} : ∀ {n} → Vec A n → Vec A n → Set a where
head< : ∀ {@erased x y n} {@erased xs ys : Vec A n} → x < y → LessVec (x ∷ xs) (y ∷ ys)
tail< : ∀ {@erased x n} {@erased xs ys : Vec A n} → LessVec xs ys → LessVec (x ∷ xs) (x ∷ ys)
private
compareVec : ∀ {a} {A : Set a} {{OrdA : Ord A}} {@erased n} (xs ys : Vec A n) → Comparison LessVec xs ys
compareVec [] [] = equal refl
compareVec (x ∷ xs) (y ∷ ys) with compare x y
compareVec (x ∷ xs) (y ∷ ys) | less x<y = less (head< x<y)
compareVec (x ∷ xs) (y ∷ ys) | greater y<x = greater (head< y<x)
compareVec (x ∷ xs) (.x ∷ ys) | equal refl with compareVec xs ys
compareVec (x ∷ xs) (.x ∷ ys) | equal refl | less xs<ys = less (tail< xs<ys)
compareVec (x ∷ xs) (.x ∷ ys) | equal refl | greater ys<xs = greater (tail< ys<xs)
compareVec (x ∷ xs) (.x ∷ .xs) | equal refl | equal refl = equal refl
private
len : ∀ {a} {A : Set a} {n} → Vec A n → Nat
len {n = n} _ = n
instance
OrdVec : ∀ {a} {A : Set a} {{OrdA : Ord A}} {n} → Ord (Vec A n)
OrdVec = defaultOrd compareVec
OrdLawsVec : ∀ {a} {A : Set a} {{OrdA : Ord/Laws A}} {n} → Ord/Laws (Vec A n)
Ord/Laws.super OrdLawsVec = it
less-antirefl {{OrdLawsVec}} {[]} ()
less-antirefl {{OrdLawsVec {A = A}}} {x ∷ xs} (head< lt) = less-antirefl {A = A} lt
less-antirefl {{OrdLawsVec {A = A}}} {x ∷ xs} (tail< lt) = less-antirefl {A = Vec A (len xs)} {xs} lt
less-trans {{OrdLawsVec {A = A}}} {[]} {[]} () _
less-trans {{OrdLawsVec {A = A}}} {x ∷ xs} {y ∷ ys} {z ∷ zs} (head< lt) (head< lt₁) = head< (less-trans {A = A} lt lt₁)
less-trans {{OrdLawsVec {A = A}}} {x ∷ xs} {y ∷ ys} {y ∷ zs} (head< lt) (tail< lt₁) = head< lt
less-trans {{OrdLawsVec {A = A}}} {x ∷ xs} {x ∷ ys} {z ∷ zs} (tail< lt) (head< lt₁) = head< lt₁
less-trans {{OrdLawsVec {A = A}}} {x ∷ xs} {x ∷ ys} {x ∷ zs} (tail< lt) (tail< lt₁) = tail< (less-trans {A = Vec A (len xs)} lt lt₁)
--- Functor instances ---
instance
FunctorVec : ∀ {a n} → Functor {a} (flip Vec n)
fmap {{FunctorVec}} = vmap
FunctorVec′ : ∀ {a b n} → Functor′ {a} {b} (flip Vec n)
fmap′ {{FunctorVec′}} = vmap
ApplicativeVec : ∀ {a n} → Applicative {a} (flip Vec n)
pure {{ApplicativeVec}} = vec
_<*>_ {{ApplicativeVec}} = vapp
ApplicativeVec′ : ∀ {a b n} → Applicative′ {a} {b} (flip Vec n)
_<*>′_ {{ApplicativeVec′}} = vapp
| {
"alphanum_fraction": 0.5173010381,
"avg_line_length": 36.125,
"ext": "agda",
"hexsha": "4f991f7511df22e7f859676098633f350e06e8b4",
"lang": "Agda",
"max_forks_count": 24,
"max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z",
"max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "L-TChen/agda-prelude",
"max_forks_repo_path": "src/Prelude/Vec.agda",
"max_issues_count": 59,
"max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267",
"max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "L-TChen/agda-prelude",
"max_issues_repo_path": "src/Prelude/Vec.agda",
"max_line_length": 134,
"max_stars_count": 111,
"max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "L-TChen/agda-prelude",
"max_stars_repo_path": "src/Prelude/Vec.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z",
"num_tokens": 2193,
"size": 5202
} |
-- 2010-10-04
-- termination checker no longer counts stripping off a record constructor
-- as decrease
-- 2019-10-18
-- It does if it's an inductive non-eta record.
module Issue334b where
data Unit : Set where
unit : Unit
record E : Set where
inductive
constructor mkE
field
fromE : E
spam : Unit
f : E -> Set
f (mkE e unit) = f e
f' : E -> Set
f' (mkE e u) = f e
| {
"alphanum_fraction": 0.6528497409,
"avg_line_length": 16.7826086957,
"ext": "agda",
"hexsha": "cd9745170cd1e2b9857227c979e22c8cf1f5fa99",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2015-09-15T14:36:15.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-09-15T14:36:15.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/Issue334b.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "c8a3cfa002e77acc5ae1993bae413fde42d4f93b",
"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": "strake/agda",
"max_issues_repo_path": "test/Succeed/Issue334b.agda",
"max_line_length": 74,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "c8a3cfa002e77acc5ae1993bae413fde42d4f93b",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "strake/agda",
"max_stars_repo_path": "test/Succeed/Issue334b.agda",
"max_stars_repo_stars_event_max_datetime": "2020-09-20T00:28:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-10-29T09:40:30.000Z",
"num_tokens": 131,
"size": 386
} |
module Structure.Setoid.Size where
import Lvl
open import Logic
open import Logic.Propositional
open import Logic.Predicate
open import Structure.Setoid
open import Structure.Function.Domain
open import Structure.Function
open import Syntax.Function
open import Type
private variable ℓ ℓ₁ ℓ₂ ℓₑ₁ ℓₑ₂ : Lvl.Level
_≍_ : (A : Setoid{ℓₑ₁}{ℓ₁}) → (B : Setoid{ℓₑ₂}{ℓ₂}) → Stmt
_≍_ A B = ∃{Obj = Setoid.Type(A) → Setoid.Type(B)} (f ↦ Function(f) ∧ Bijective(f))
_≼_ : (A : Setoid{ℓₑ₁}{ℓ₁}) → (B : Setoid{ℓₑ₂}{ℓ₂}) → Stmt
_≼_ A B = ∃{Obj = Setoid.Type(A) → Setoid.Type(B)} (f ↦ Function(f) ∧ Injective(f))
_≽_ : (A : Setoid{ℓₑ₁}{ℓ₁}) → (B : Setoid{ℓₑ₂}{ℓ₂}) → Stmt
_≽_ A B = ∃{Obj = Setoid.Type(A) → Setoid.Type(B)} (f ↦ Function(f) ∧ Surjective(f))
_≭_ : (A : Setoid{ℓₑ₁}{ℓ₁}) → (B : Setoid{ℓₑ₂}{ℓ₂}) → Stmt
_≭_ A B = ¬(A ≍ B)
_≺_ : (A : Setoid{ℓₑ₁}{ℓ₁}) → (B : Setoid{ℓₑ₂}{ℓ₂}) → Stmt
_≺_ A B = (A ≼ B) ∧ (A ≭ B)
_≻_ : (A : Setoid{ℓₑ₁}{ℓ₁}) → (B : Setoid{ℓₑ₂}{ℓ₂}) → Stmt
_≻_ A B = (A ≽ B) ∧ (A ≭ B)
| {
"alphanum_fraction": 0.6087388282,
"avg_line_length": 31.46875,
"ext": "agda",
"hexsha": "8e1f549f415a62f5bf006343d17eaa480838a090",
"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/Setoid/Size.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/Setoid/Size.agda",
"max_line_length": 84,
"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/Setoid/Size.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": 484,
"size": 1007
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Containers, based on the work of Abbott and others
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe --sized-types #-}
module Data.Container where
open import Level using (_⊔_)
open import Codata.M hiding (map)
open import Data.W
open import Size
------------------------------------------------------------------------
-- Re-exporting content to maintain backwards compatibility
open import Data.Container.Core public
open import Data.Container.Relation.Unary.Any
using (◇) renaming (map to ◇-map) public
open import Data.Container.Relation.Unary.All
using (□) renaming (map to □-map) public
open import Data.Container.Membership
using (_∈_) public
open import Data.Container.Relation.Binary.Pointwise
using () renaming (Pointwise to Eq) public
open import Data.Container.Relation.Binary.Pointwise.Properties
using (refl; sym; trans) public
open import Data.Container.Relation.Binary.Equality.Setoid
using (isEquivalence; setoid) public
open import Data.Container.Properties
using () renaming (map-identity to identity; map-compose to composition) public
open import Data.Container.Related public
module Morphism where
open import Data.Container.Morphism.Properties
using (Natural; NT; natural; complete; id-correct; ∘-correct) public
open import Data.Container.Morphism
using (id; _∘_) public
-- The least and greatest fixpoints of a container.
μ : ∀ {s p} → Container s p → Set (s ⊔ p)
μ = W
ν : ∀ {s p} → Container s p → Set (s ⊔ p)
ν C = M C ∞
| {
"alphanum_fraction": 0.6462378641,
"avg_line_length": 32.3137254902,
"ext": "agda",
"hexsha": "4173bdc37c29eda3fe4c67d4f57dc868b8120592",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "omega12345/agda-mode",
"max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Container.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "omega12345/agda-mode",
"max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Container.agda",
"max_line_length": 81,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Container.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": 373,
"size": 1648
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Foundations.Logic where
import Cubical.Data.Empty as ⊥
open import Cubical.Data.Sum as ⊎ using (_⊎_)
open import Cubical.Data.Unit
open import Cubical.Data.Sigma
open import Cubical.Foundations.Prelude as FP
open import Cubical.Functions.Embedding
open import Cubical.Functions.Fibration as Fib
open import Cubical.Foundations.Equiv
open import Cubical.HITs.PropositionalTruncation as PropTrunc
open import Cubical.Foundations.HLevels using (hProp; isPropΠ; isPropΠ2; isSetΠ; isSetHProp; isOfHLevelΣ; isPropΣ) public
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Function
open import Cubical.Foundations.Univalence using (ua)
open import Cubical.Relation.Nullary hiding (¬_)
infix 10 ¬_
infixr 8 _⊔_
infixr 8 _⊔′_
infixr 8 _⊓_
infixr 8 _⊓′_
infixr 6 _⇒_
infixr 4 _⇔_
infix 30 _≡ₚ_
infix 30 _≢ₚ_
infix 2 ∃[]-syntax
infix 2 ∃[∶]-syntax
infix 2 ∀[∶]-syntax
infix 2 ∀[]-syntax
infix 2 ⇒∶_⇐∶_
infix 2 ⇐∶_⇒∶_
--------------------------------------------------------------------------------
-- The type hProp of mere propositions
-- the definition hProp is given in Foundations.HLevels
-- hProp ℓ = Σ (Type ℓ) isProp
private
variable
ℓ ℓ' ℓ'' : Level
P Q R : hProp ℓ
A B C : Type ℓ
[_] : hProp ℓ → Type ℓ
[_] = fst
isProp[] : (A : hProp ℓ) → isProp [ A ]
isProp[] = snd
∥_∥ₚ : Type ℓ → hProp ℓ
∥ A ∥ₚ = ∥ A ∥ , propTruncIsProp
_≡ₚ_ : (x y : A) → hProp _
x ≡ₚ y = ∥ x ≡ y ∥ₚ
hProp≡ : [ P ] ≡ [ Q ] → P ≡ Q
hProp≡ p = Σ≡Prop (\ _ → isPropIsProp) p
--------------------------------------------------------------------------------
-- Logical implication of mere propositions
_⇒_ : (A : hProp ℓ) → (B : hProp ℓ') → hProp _
A ⇒ B = ([ A ] → [ B ]) , isPropΠ λ _ → isProp[] B
⇔toPath : [ P ⇒ Q ] → [ Q ⇒ P ] → P ≡ Q
⇔toPath {P = P} {Q = Q} P⇒Q Q⇒P = hProp≡ (isoToPath
(iso P⇒Q Q⇒P (λ b → isProp[] Q (P⇒Q (Q⇒P b)) b) λ a → isProp[] P (Q⇒P (P⇒Q a)) a))
pathTo⇒ : P ≡ Q → [ P ⇒ Q ]
pathTo⇒ p x = subst fst p x
pathTo⇐ : P ≡ Q → [ Q ⇒ P ]
pathTo⇐ p x = subst fst (sym p) x
substₚ : {x y : A} (B : A → hProp ℓ) → [ x ≡ₚ y ⇒ B x ⇒ B y ]
substₚ {x = x} {y = y} B = PropTrunc.elim (λ _ → isPropΠ λ _ → isProp[] (B y)) (subst (fst ∘ B))
--------------------------------------------------------------------------------
-- Mixfix notations for ⇔-toPath
-- see ⊔-identityˡ and ⊔-identityʳ for the difference
⇒∶_⇐∶_ : [ P ⇒ Q ] → [ Q ⇒ P ] → P ≡ Q
⇒∶_⇐∶_ = ⇔toPath
⇐∶_⇒∶_ : [ Q ⇒ P ] → [ P ⇒ Q ] → P ≡ Q
⇐∶ g ⇒∶ f = ⇔toPath f g
--------------------------------------------------------------------------------
-- False and True
⊥ : hProp _
⊥ = ⊥.⊥ , λ ()
⊤ : hProp _
⊤ = Unit , (λ _ _ _ → tt)
--------------------------------------------------------------------------------
-- Pseudo-complement of mere propositions
¬_ : hProp ℓ → hProp _
¬ A = ([ A ] → ⊥.⊥) , isPropΠ λ _ → ⊥.isProp⊥
_≢ₚ_ : (x y : A) → hProp _
x ≢ₚ y = ¬ x ≡ₚ y
--------------------------------------------------------------------------------
-- Disjunction of mere propositions
_⊔′_ : Type ℓ → Type ℓ' → Type _
A ⊔′ B = ∥ A ⊎ B ∥
_⊔_ : hProp ℓ → hProp ℓ' → hProp _
P ⊔ Q = ∥ [ P ] ⊎ [ Q ] ∥ₚ
inl : A → A ⊔′ B
inl x = ∣ ⊎.inl x ∣
inr : B → A ⊔′ B
inr x = ∣ ⊎.inr x ∣
⊔-elim : (P : hProp ℓ) (Q : hProp ℓ') (R : [ P ⊔ Q ] → hProp ℓ'')
→ (∀ x → [ R (inl x) ]) → (∀ y → [ R (inr y) ]) → (∀ z → [ R z ])
⊔-elim _ _ R P⇒R Q⇒R = PropTrunc.elim (snd ∘ R) (⊎.elim P⇒R Q⇒R)
--------------------------------------------------------------------------------
-- Conjunction of mere propositions
_⊓′_ : Type ℓ → Type ℓ' → Type _
A ⊓′ B = A × B
_⊓_ : hProp ℓ → hProp ℓ' → hProp _
A ⊓ B = [ A ] ⊓′ [ B ] , isOfHLevelΣ 1 (isProp[] A) (\ _ → isProp[] B)
⊓-intro : (P : hProp ℓ) (Q : [ P ] → hProp ℓ') (R : [ P ] → hProp ℓ'')
→ (∀ a → [ Q a ]) → (∀ a → [ R a ]) → (∀ (a : [ P ]) → [ Q a ⊓ R a ] )
⊓-intro _ _ _ = \ f g a → f a , g a
--------------------------------------------------------------------------------
-- Logical bi-implication of mere propositions
_⇔_ : hProp ℓ → hProp ℓ' → hProp _
A ⇔ B = (A ⇒ B) ⊓ (B ⇒ A)
--------------------------------------------------------------------------------
-- Universal Quantifier
∀[∶]-syntax : (A → hProp ℓ) → hProp _
∀[∶]-syntax {A = A} P = (∀ x → [ P x ]) , isPropΠ (isProp[] ∘ P)
∀[]-syntax : (A → hProp ℓ) → hProp _
∀[]-syntax {A = A} P = (∀ x → [ P x ]) , isPropΠ (isProp[] ∘ P)
syntax ∀[∶]-syntax {A = A} (λ a → P) = ∀[ a ∶ A ] P
syntax ∀[]-syntax (λ a → P) = ∀[ a ] P
--------------------------------------------------------------------------------
-- Existential Quantifier
∃[]-syntax : (A → hProp ℓ) → hProp _
∃[]-syntax {A = A} P = ∥ Σ A ([_] ∘ P) ∥ₚ
∃[∶]-syntax : (A → hProp ℓ) → hProp _
∃[∶]-syntax {A = A} P = ∥ Σ A ([_] ∘ P) ∥ₚ
syntax ∃[∶]-syntax {A = A} (λ x → P) = ∃[ x ∶ A ] P
syntax ∃[]-syntax (λ x → P) = ∃[ x ] P
--------------------------------------------------------------------------------
-- Decidable mere proposition
Decₚ : (P : hProp ℓ) → hProp ℓ
Decₚ P = Dec [ P ] , isPropDec (isProp[] P)
--------------------------------------------------------------------------------
-- Negation commutes with truncation
∥¬A∥≡¬∥A∥ : (A : Type ℓ) → ∥ (A → ⊥.⊥) ∥ₚ ≡ (¬ ∥ A ∥ₚ)
∥¬A∥≡¬∥A∥ _ =
⇒∶ (λ ¬A A → PropTrunc.elim (λ _ → ⊥.isProp⊥)
(PropTrunc.elim (λ _ → isPropΠ λ _ → ⊥.isProp⊥) (λ ¬p p → ¬p p) ¬A) A)
⇐∶ λ ¬p → ∣ (λ p → ¬p ∣ p ∣) ∣
--------------------------------------------------------------------------------
-- (hProp, ⊔, ⊥) is a bounded ⊔-semilattice
⊔-assoc : (P : hProp ℓ) (Q : hProp ℓ') (R : hProp ℓ'')
→ P ⊔ (Q ⊔ R) ≡ (P ⊔ Q) ⊔ R
⊔-assoc P Q R =
⇒∶ ⊔-elim P (Q ⊔ R) (λ _ → (P ⊔ Q) ⊔ R)
(inl ∘ inl)
(⊔-elim Q R (λ _ → (P ⊔ Q) ⊔ R) (inl ∘ inr) inr)
⇐∶ assoc2
where
assoc2 : (A ⊔′ B) ⊔′ C → A ⊔′ (B ⊔′ C)
assoc2 ∣ ⊎.inr a ∣ = ∣ ⊎.inr ∣ ⊎.inr a ∣ ∣
assoc2 ∣ ⊎.inl ∣ ⊎.inr b ∣ ∣ = ∣ ⊎.inr ∣ ⊎.inl b ∣ ∣
assoc2 ∣ ⊎.inl ∣ ⊎.inl c ∣ ∣ = ∣ ⊎.inl c ∣
assoc2 ∣ ⊎.inl (squash x y i) ∣ = propTruncIsProp (assoc2 ∣ ⊎.inl x ∣) (assoc2 ∣ ⊎.inl y ∣) i
assoc2 (squash x y i) = propTruncIsProp (assoc2 x) (assoc2 y) i
⊔-idem : (P : hProp ℓ) → P ⊔ P ≡ P
⊔-idem P =
⇒∶ (⊔-elim P P (\ _ → P) (\ x → x) (\ x → x))
⇐∶ inl
⊔-comm : (P : hProp ℓ) (Q : hProp ℓ') → P ⊔ Q ≡ Q ⊔ P
⊔-comm P Q =
⇒∶ (⊔-elim P Q (\ _ → (Q ⊔ P)) inr inl)
⇐∶ (⊔-elim Q P (\ _ → (P ⊔ Q)) inr inl)
⊔-identityˡ : (P : hProp ℓ) → ⊥ ⊔ P ≡ P
⊔-identityˡ P =
⇒∶ (⊔-elim ⊥ P (λ _ → P) (λ ()) (λ x → x))
⇐∶ inr
⊔-identityʳ : (P : hProp ℓ) → P ⊔ ⊥ ≡ P
⊔-identityʳ P = ⇔toPath (⊔-elim P ⊥ (λ _ → P) (λ x → x) λ ()) inl
--------------------------------------------------------------------------------
-- (hProp, ⊓, ⊤) is a bounded ⊓-lattice
⊓-assoc : (P : hProp ℓ) (Q : hProp ℓ') (R : hProp ℓ'')
→ P ⊓ Q ⊓ R ≡ (P ⊓ Q) ⊓ R
⊓-assoc _ _ _ =
⇒∶ (λ {(x , (y , z)) → (x , y) , z})
⇐∶ (λ {((x , y) , z) → x , (y , z) })
⊓-comm : (P : hProp ℓ) (Q : hProp ℓ') → P ⊓ Q ≡ Q ⊓ P
⊓-comm _ _ = ⇔toPath (\ p → p .snd , p .fst) (\ p → p .snd , p .fst)
⊓-idem : (P : hProp ℓ) → P ⊓ P ≡ P
⊓-idem _ = ⇔toPath fst (λ x → x , x)
⊓-identityˡ : (P : hProp ℓ) → ⊤ ⊓ P ≡ P
⊓-identityˡ _ = ⇔toPath snd λ x → tt , x
⊓-identityʳ : (P : hProp ℓ) → P ⊓ ⊤ ≡ P
⊓-identityʳ _ = ⇔toPath fst λ x → x , tt
--------------------------------------------------------------------------------
-- Distributive laws
⇒-⊓-distrib : (P : hProp ℓ) (Q : hProp ℓ')(R : hProp ℓ'')
→ P ⇒ (Q ⊓ R) ≡ (P ⇒ Q) ⊓ (P ⇒ R)
⇒-⊓-distrib _ _ _ =
⇒∶ (λ f → (fst ∘ f) , (snd ∘ f))
⇐∶ (λ { (f , g) x → f x , g x})
⊓-⊔-distribˡ : (P : hProp ℓ) (Q : hProp ℓ')(R : hProp ℓ'')
→ P ⊓ (Q ⊔ R) ≡ (P ⊓ Q) ⊔ (P ⊓ R)
⊓-⊔-distribˡ P Q R =
⇒∶ (λ { (x , a) → ⊔-elim Q R (λ _ → (P ⊓ Q) ⊔ (P ⊓ R))
(λ y → ∣ ⊎.inl (x , y) ∣ )
(λ z → ∣ ⊎.inr (x , z) ∣ ) a })
⇐∶ ⊔-elim (P ⊓ Q) (P ⊓ R) (λ _ → P ⊓ Q ⊔ R)
(λ y → fst y , inl (snd y))
(λ z → fst z , inr (snd z))
⊔-⊓-distribˡ : (P : hProp ℓ) (Q : hProp ℓ')(R : hProp ℓ'')
→ P ⊔ (Q ⊓ R) ≡ (P ⊔ Q) ⊓ (P ⊔ R)
⊔-⊓-distribˡ P Q R =
⇒∶ ⊔-elim P (Q ⊓ R) (λ _ → (P ⊔ Q) ⊓ (P ⊔ R) )
(\ x → inl x , inl x) (\ p → inr (p .fst) , inr (p .snd))
⇐∶ (λ { (x , y) → ⊔-elim P R (λ _ → P ⊔ Q ⊓ R) inl
(λ z → ⊔-elim P Q (λ _ → P ⊔ Q ⊓ R) inl (λ y → inr (y , z)) x) y })
⊓-∀-distrib : (P : A → hProp ℓ) (Q : A → hProp ℓ')
→ (∀[ a ∶ A ] P a) ⊓ (∀[ a ∶ A ] Q a) ≡ (∀[ a ∶ A ] (P a ⊓ Q a))
⊓-∀-distrib P Q =
⇒∶ (λ {(p , q) a → p a , q a})
⇐∶ λ pq → (fst ∘ pq ) , (snd ∘ pq)
--------------------------------------------------------------------------------
-- Introduce the "powerset" of a type in the style of Escardó's lecture notes:
-- https://www.cs.bham.ac.uk/~mhe/HoTT-UF-in-Agda-Lecture-Notes/HoTT-UF-Agda.html#propositionalextensionality
ℙ : ∀ {ℓ} → Type ℓ → Type (ℓ-suc ℓ)
ℙ {ℓ} X = X → hProp ℓ
infix 5 _∈_
_∈_ : {X : Type ℓ} → X → ℙ X → Type ℓ
x ∈ A = [ A x ]
_⊆_ : {X : Type ℓ} → ℙ X → ℙ X → Type ℓ
A ⊆ B = ∀ x → x ∈ A → x ∈ B
∈-isProp : {X : Type ℓ} (A : ℙ X) (x : X) → isProp (x ∈ A)
∈-isProp A = isProp[] ∘ A
⊆-isProp : {X : Type ℓ} (A B : ℙ X) → isProp (A ⊆ B)
⊆-isProp A B = isPropΠ2 (λ x _ → ∈-isProp B x)
⊆-refl : {X : Type ℓ} (A : ℙ X) → A ⊆ A
⊆-refl A x = idfun (x ∈ A)
⊆-refl-consequence : {X : Type ℓ} (A B : ℙ X)
→ A ≡ B → (A ⊆ B) × (B ⊆ A)
⊆-refl-consequence {X} A B p = subst (λ B → (A ⊆ B)) p (⊆-refl A) , subst (λ A → (B ⊆ A)) (sym p) (⊆-refl B)
⊆-extensionality : {X : Type ℓ} (A B : ℙ X)
→ (A ⊆ B) × (B ⊆ A) → A ≡ B
⊆-extensionality A B (φ , ψ) i x = ⇔toPath {P = (A x)} {Q = (B x)} (φ x) (ψ x) i
powersets-are-sets : {X : Type ℓ} → isSet (ℙ X)
powersets-are-sets {X = X} = isSetΠ (λ _ → isSetHProp)
⊆-extensionalityEquiv : {X : Type ℓ} (A B : ℙ X)
→ (A ⊆ B) × (B ⊆ A) ≃ (A ≡ B)
⊆-extensionalityEquiv A B = isoToEquiv (iso (⊆-extensionality A B)
(⊆-refl-consequence A B)
(λ _ → powersets-are-sets A B _ _)
(λ _ → isPropΣ (⊆-isProp A B) (λ _ → ⊆-isProp B A) _ _))
-- We show that the powerset is the subtype classifier
-- i.e. ℙ X ≃ Σ[A ∈ Type ℓ] (A ↪ X)
Embedding→Subset : {X : Type ℓ} → Σ[ A ∈ Type ℓ ] (A ↪ X) → ℙ X
Embedding→Subset (_ , f , isPropFiber) x = fiber f x , isPropFiber x
Subset→Embedding : {X : Type ℓ} → ℙ X → Σ[ A ∈ Type ℓ ] (A ↪ X)
Subset→Embedding {X = X} A = D , f , ψ
where
D = Σ[ x ∈ X ] x ∈ A
f : D → X
f d = d .fst
ψ : hasPropFibers f
ψ x ((y , y∈A) , y≡x) ((z , z∈A) , z≡x) = ΣPathP (r , q)
where
p : y ≡ z
p = y≡x ∙ sym z≡x
r : (y , y∈A) ≡ (z , z∈A)
r = Σ≡Prop (∈-isProp A) p
q : PathP (λ i → p i ≡ x) y≡x z≡x
q i j = hcomp (λ k → λ { (j = i1) → x
; (i = i0) → y≡x j
; (i = i1) → z≡x (~ k ∨ j) })
(y≡x (i ∨ j))
Subset→Embedding→Subset : {X : Type ℓ} → section (Embedding→Subset {ℓ} {X}) (Subset→Embedding {ℓ} {X})
Subset→Embedding→Subset _ = funExt λ x → Σ≡Prop (λ _ → FP.isPropIsProp) (ua (Fib.FiberIso.fiberEquiv _ x))
Embedding→Subset→Embedding : {X : Type ℓ} → retract (Embedding→Subset {ℓ} {X}) (Subset→Embedding {ℓ} {X})
Embedding→Subset→Embedding {ℓ = ℓ} {X = X} (A , f , ψ) = cong (Σ-assoc-≃ .fst) p
where
χ = Subset→Embedding (Embedding→Subset (A , f , ψ)) .snd .snd
p : (((Σ[ x ∈ X ] fiber f x) , fst) , χ) ≡ ((A , f) , ψ)
p = Σ≡Prop (λ _ → hasPropFibersIsProp) ((equivToIso (Fib.fibrationEquiv X ℓ)) .Iso.leftInv (A , f))
Subset≃Embedding : {X : Type ℓ} → ℙ X ≃ (Σ[ A ∈ Type ℓ ] (A ↪ X))
Subset≃Embedding = isoToEquiv (iso Subset→Embedding Embedding→Subset Embedding→Subset→Embedding Subset→Embedding→Subset)
Subset≡Embedding : {X : Type ℓ} → ℙ X ≡ (Σ[ A ∈ Type ℓ ] (A ↪ X))
Subset≡Embedding = ua Subset≃Embedding
| {
"alphanum_fraction": 0.4317165753,
"avg_line_length": 31.4456233422,
"ext": "agda",
"hexsha": "316e4ebe8e0851c869709208307c12bed232a1ea",
"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": "f6771617374bfe65a7043d00731fed5a673aa729",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "knrafto/cubical",
"max_forks_repo_path": "Cubical/Foundations/Logic.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729",
"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": "knrafto/cubical",
"max_issues_repo_path": "Cubical/Foundations/Logic.agda",
"max_line_length": 121,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "knrafto/cubical",
"max_stars_repo_path": "Cubical/Foundations/Logic.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 5414,
"size": 11855
} |
module Nat where
import Prelude
import Equiv
import Datoid
open Prelude
open Equiv
open Datoid
data Nat : Set where
zero : Nat
suc : Nat -> Nat
one : Nat
one = suc zero
_+_ : Nat -> Nat -> Nat
zero + n = n
suc m + n = suc (m + n)
private
eqNat : Nat -> Nat -> Bool
eqNat zero zero = True
eqNat (suc m) (suc n) = eqNat m n
eqNat _ _ = False
refl' : (x : Nat) -> T (eqNat x x)
refl' zero = unit
refl' (suc n) = refl' n
sym' : (x y : Nat) -> T (eqNat x y) -> T (eqNat y x)
sym' zero zero _ = unit
sym' (suc n1) (suc n2) eq = sym' n1 n2 eq
sym' (suc _) zero wrong = wrong
sym' zero (suc _) wrong = wrong
trans' : (x y z : Nat) -> T (eqNat x y) -> T (eqNat y z) -> T (eqNat x z)
trans' zero _ zero _ _ = unit
trans' (suc n1) (suc n2) (suc n3) eq12 eq23 = trans' n1 n2 n3 eq12 eq23
trans' zero (suc _) _ wrong _ = absurdElim wrong
trans' _ zero (suc _) _ wrong = absurdElim wrong
trans' (suc _) zero _ wrong _ = absurdElim wrong
trans' _ (suc _) zero _ wrong = absurdElim wrong
decidableEquiv : DecidableEquiv Nat
decidableEquiv = decEquiv (equiv (T' eqNat) refl' sym' trans')
(boolFunctionsDecidable eqNat)
natDatoid : Datoid
natDatoid = datoid Nat decidableEquiv
| {
"alphanum_fraction": 0.5250859107,
"avg_line_length": 26.9444444444,
"ext": "agda",
"hexsha": "0b71bbc555dbdbaced03ec091a50334d8a585edf",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "examples/AIM4/bag/Nat.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "examples/AIM4/bag/Nat.agda",
"max_line_length": 77,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "examples/AIM4/bag/Nat.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": 513,
"size": 1455
} |
------------------------------------------------------------------------
-- Incorrect coinductive axiomatisation of subtyping
------------------------------------------------------------------------
-- This module shows that if we remove transitivity from
-- RecursiveTypes.Subtyping.Axiomatic.Coinductive._≤_, and take the
-- transitive closure of the resulting relation, then we get a weaker
-- (less defined) relation than the one we started with.
module RecursiveTypes.Subtyping.Axiomatic.Incorrect where
open import Codata.Musical.Notation
open import Data.Fin using (Fin; zero; suc)
open import Function using (id; _$_)
open import Data.Nat
using (ℕ; zero; suc; z≤n; s≤s; ≤′-refl) renaming (_≤_ to _≤ℕ_)
open import Data.Nat.Induction
open import Data.Nat.Properties using (≤-step; ≤⇒≤′)
open import Data.Product as Prod
open import Relation.Binary.PropositionalEquality
open import Relation.Nullary
open import RecursiveTypes.Syntax hiding (_≲_)
open import RecursiveTypes.Substitution using (_[0≔_]; unfold[μ_⟶_])
open import RecursiveTypes.Subtyping.Semantic.Coinductive as Sem
using (_≤Coind_; ⊥; ⊤; _⟶_)
------------------------------------------------------------------------
-- The alternative "subtyping" relation
infixr 10 _⟶_
infix 4 _≤_ _≤′_
infixr 2 _≤⟨_⟩_
infix 2 _∎
-- A definition which does not include a transitivity constructor.
data _≤′_ {n} : Ty n → Ty n → Set where
⊥ : ∀ {τ} → ⊥ ≤′ τ
⊤ : ∀ {σ} → σ ≤′ ⊤
_⟶_ : ∀ {σ₁ σ₂ τ₁ τ₂}
(τ₁≤′σ₁ : ∞ (τ₁ ≤′ σ₁)) (σ₂≤′τ₂ : ∞ (σ₂ ≤′ τ₂)) →
σ₁ ⟶ σ₂ ≤′ τ₁ ⟶ τ₂
unfold : ∀ {τ₁ τ₂} → μ τ₁ ⟶ τ₂ ≤′ unfold[μ τ₁ ⟶ τ₂ ]
fold : ∀ {τ₁ τ₂} → unfold[μ τ₁ ⟶ τ₂ ] ≤′ μ τ₁ ⟶ τ₂
_∎ : ∀ τ → τ ≤′ τ
-- The transitive closure of this relation.
data _≤_ {n} : Ty n → Ty n → Set where
include : ∀ {σ τ} (σ≤τ : σ ≤′ τ) → σ ≤ τ
_≤⟨_⟩_ : ∀ τ₁ {τ₂ τ₃} (τ₁≤τ₂ : τ₁ ≤ τ₂) (τ₂≤τ₃ : τ₂ ≤ τ₃) → τ₁ ≤ τ₃
------------------------------------------------------------------------
-- Some types used in counterexamples below
σ : Ty zero
σ = μ ⊤ ⟶ var zero
τ : Ty zero
τ = μ ⊥ ⟶ var zero
σ≤τ : σ ≤Coind τ
σ≤τ = ♯ ⊥ ⟶ ♯ σ≤τ
------------------------------------------------------------------------
-- Soundness and incompleteness of _≤′_
sound′ : ∀ {n} {σ τ : Ty n} → σ ≤′ τ → σ ≤Coind τ
sound′ ⊥ = ⊥
sound′ ⊤ = ⊤
sound′ (τ₁≤σ₁ ⟶ σ₂≤τ₂) = ♯ sound′ (♭ τ₁≤σ₁) ⟶ ♯ sound′ (♭ σ₂≤τ₂)
sound′ unfold = Sem.unfold
sound′ fold = Sem.fold
sound′ (τ ∎) = Sem.refl∞ _
incomplete′ : ¬ (∀ {n} {σ τ : Ty n} → σ ≤Coind τ → σ ≤′ τ)
incomplete′ hyp with hyp {σ = σ} {τ = τ} σ≤τ
... | ()
------------------------------------------------------------------------
-- Soundness of _≤_
sound : ∀ {n} {σ τ : Ty n} → σ ≤ τ → σ ≤Coind τ
sound (τ₁ ≤⟨ τ₁≤τ₂ ⟩ τ₂≤τ₃) = Sem.trans (sound τ₁≤τ₂) (sound τ₂≤τ₃)
sound (include σ≤τ) = sound′ σ≤τ
------------------------------------------------------------------------
-- An alternative definition of the transitive closure of _≤′_
infixr 5 _∷_
infix 4 _≲_
data _≲_ {n} : Ty n → Ty n → Set where
[_] : ∀ {σ τ} (σ≤τ : σ ≤′ τ) → σ ≲ τ
_∷_ : ∀ {τ₁ τ₂ τ₃} (τ₁≤τ₂ : τ₁ ≤′ τ₂) (τ₂≲τ₃ : τ₂ ≲ τ₃) → τ₁ ≲ τ₃
-- This definition is transitive.
_++_ : ∀ {n} {τ₁ τ₂ τ₃ : Ty n} → τ₁ ≲ τ₂ → τ₂ ≲ τ₃ → τ₁ ≲ τ₃
[ τ₁≤τ₂ ] ++ τ₂≤τ₃ = τ₁≤τ₂ ∷ τ₂≤τ₃
(τ₁≤τ₂ ∷ τ₂≤τ₃) ++ τ₃≤τ₄ = τ₁≤τ₂ ∷ (τ₂≤τ₃ ++ τ₃≤τ₄)
-- Hence it is complete with respect to the one above.
≲-complete : ∀ {n} {σ τ : Ty n} → σ ≤ τ → σ ≲ τ
≲-complete (include σ≤τ) = [ σ≤τ ]
≲-complete (τ₁ ≤⟨ τ₁≤τ₂ ⟩ τ₂≤τ₃) = ≲-complete τ₁≤τ₂ ++ ≲-complete τ₂≤τ₃
-- It is also sound.
≲-sound : ∀ {n} {σ τ : Ty n} → σ ≲ τ → σ ≤ τ
≲-sound [ σ≤τ ] = include σ≤τ
≲-sound (τ₁≤τ₂ ∷ τ₂≲τ₃) = _ ≤⟨ include τ₁≤τ₂ ⟩ ≲-sound τ₂≲τ₃
-- The number of uses of transitivity in the proof.
length : ∀ {n} {σ τ : Ty n} → σ ≲ τ → ℕ
length [ σ≤τ ] = 0
length (τ₁≤τ₂ ∷ τ₂≲τ₃) = suc (length τ₂≲τ₃)
------------------------------------------------------------------------
-- Given proofs of certain statements one can extract shorter or
-- equally long proofs for related statements
mutual
codomain-⟶μ : ∀ {n} {σ₁ σ₂ : Ty n} {τ₁ τ₂} →
(σ₁⟶σ₂≲μτ₁⟶τ₂ : σ₁ ⟶ σ₂ ≲ μ τ₁ ⟶ τ₂) →
∃ λ (σ₂≲τ₂′ : σ₂ ≲ τ₂ [0≔ μ τ₁ ⟶ τ₂ ]) →
length σ₂≲τ₂′ ≤ℕ length σ₁⟶σ₂≲μτ₁⟶τ₂
codomain-⟶μ [ fold ] = ([ _ ∎ ] , z≤n)
codomain-⟶μ (τ₁≤′σ₁ ⟶ σ₂≤′τ₂ ∷ τ₂≲τ₃) = Prod.map (_∷_ (♭ σ₂≤′τ₂)) s≤s (codomain-⟶μ τ₂≲τ₃)
codomain-⟶μ (fold ∷ τ₂≲τ₃) = Prod.map id ≤-step (codomain-μμ τ₂≲τ₃)
codomain-⟶μ ((._ ∎) ∷ τ₂≲τ₃) = Prod.map id ≤-step (codomain-⟶μ τ₂≲τ₃)
codomain-⟶μ (⊤ ∷ τ₂≲τ₃) with sound (≲-sound τ₂≲τ₃)
... | ()
codomain-μμ : ∀ {n} {σ₁ σ₂ τ₁ τ₂ : Ty (suc n)} →
(μσ₁⟶σ₂≲μτ₁⟶τ₂ : μ σ₁ ⟶ σ₂ ≲ μ τ₁ ⟶ τ₂) →
∃ λ (σ₂′≲τ₂′ : σ₂ [0≔ μ σ₁ ⟶ σ₂ ] ≲ τ₂ [0≔ μ τ₁ ⟶ τ₂ ]) →
length σ₂′≲τ₂′ ≤ℕ length μσ₁⟶σ₂≲μτ₁⟶τ₂
codomain-μμ [ ._ ∎ ] = ([ _ ∎ ] , z≤n)
codomain-μμ (unfold ∷ τ₂≲τ₃) = Prod.map id ≤-step (codomain-⟶μ τ₂≲τ₃)
codomain-μμ ((._ ∎) ∷ τ₂≲τ₃) = Prod.map id ≤-step (codomain-μμ τ₂≲τ₃)
codomain-μμ (⊤ ∷ τ₂≲τ₃) with sound (≲-sound τ₂≲τ₃)
... | ()
------------------------------------------------------------------------
-- Incompleteness of _≤_
incomplete : ¬ (∀ {n} {σ τ : Ty n} → σ ≤Coind τ → σ ≤ τ)
incomplete hyp = σ≴τ $ ≲-complete $ hyp σ≤τ
where
σ≴τ : ¬ σ ≲ τ
σ≴τ σ≲τ = <′-rec Pred ≴ _ σ≲τ refl
where
Pred : ℕ → Set
Pred n = (σ≲τ : σ ≲ τ) → length σ≲τ ≢ n
≴ : ∀ n → <′-Rec Pred n → Pred n
≴ n rec [ () ] _
≴ ._ rec ((._ ∎) ∷ τ₂≲τ₃) refl = rec _ ≤′-refl τ₂≲τ₃ refl
≴ ._ rec (unfold ∷ τ₂≲τ₃) refl with codomain-⟶μ τ₂≲τ₃
... | (τ₂≲τ₃′ , not-longer) = rec _ (≤⇒≤′ $ s≤s not-longer) τ₂≲τ₃′ refl
≴ n rec (⊤ ∷ τ₂≲τ₃) _ with sound (≲-sound τ₂≲τ₃)
... | ()
| {
"alphanum_fraction": 0.4772226926,
"avg_line_length": 34.7352941176,
"ext": "agda",
"hexsha": "f85e36591ab63550149d9a4ab0f0478ede894e18",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/codata",
"max_forks_repo_path": "RecursiveTypes/Subtyping/Axiomatic/Incorrect.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/codata",
"max_issues_repo_path": "RecursiveTypes/Subtyping/Axiomatic/Incorrect.agda",
"max_line_length": 91,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/codata",
"max_stars_repo_path": "RecursiveTypes/Subtyping/Axiomatic/Incorrect.agda",
"max_stars_repo_stars_event_max_datetime": "2021-02-13T14:48:45.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-02-13T14:48:45.000Z",
"num_tokens": 2559,
"size": 5905
} |
open import Mockingbird.Forest using (Forest)
module Mockingbird.Forest.Combination.Vec.Properties {b ℓ} (forest : Forest {b} {ℓ}) where
open import Data.Vec as Vec using (Vec; []; _∷_; _++_)
import Data.Vec.Relation.Unary.Any as Any
open import Data.Vec.Relation.Unary.Any.Properties as Anyₚ using (++⁺ˡ; ++⁺ʳ)
open import Function using (_$_; flip)
open import Relation.Unary using (Pred; _∈_; _⊆_; ∅)
open Forest forest
open import Mockingbird.Forest.Combination.Vec.Base forest
import Mockingbird.Forest.Combination.Properties forest as Combinationₚ
subst : ∀ {n x y} {bs : Vec Bird n} → x ≈ y → x ∈ ⟨ bs ⟩ → y ∈ ⟨ bs ⟩
subst = Combinationₚ.subst λ x≈y → Any.map (trans (sym x≈y))
subst′ : ∀ {n x y} {bs : Vec Bird n} → y ≈ x → x ∈ ⟨ bs ⟩ → y ∈ ⟨ bs ⟩
subst′ y≈x = subst (sym y≈x)
⟨[]⟩ : ⟨ [] ⟩ ⊆ ∅
⟨[]⟩ (X ⟨∙⟩ Y ∣ xy≈z) = ⟨[]⟩ X
weaken-∷ : ∀ {n x y} {bs : Vec Bird n} → x ∈ ⟨ bs ⟩ → x ∈ ⟨ y ∷ bs ⟩
weaken-∷ = Combinationₚ.weaken there
-- TODO: maybe call this ++⁺ˡ.
weaken-++ˡ : ∀ {m n x} {bs : Vec Bird m} {bs′ : Vec Bird n} → x ∈ ⟨ bs ⟩ → x ∈ ⟨ bs ++ bs′ ⟩
weaken-++ˡ {bs = bs} {bs′} [ x∈bs ] = [ ++⁺ˡ x∈bs ]
weaken-++ˡ {bs = bs} {bs′} (x∈⟨bs⟩ ⟨∙⟩ y∈⟨bs⟩ ∣ xy≈z) = weaken-++ˡ x∈⟨bs⟩ ⟨∙⟩ weaken-++ˡ y∈⟨bs⟩ ∣ xy≈z
-- TODO: maybe call this ++⁺ʳ.
weaken-++ʳ : ∀ {m n x} (bs : Vec Bird m) {bs′ : Vec Bird n} → x ∈ ⟨ bs′ ⟩ → x ∈ ⟨ bs ++ bs′ ⟩
weaken-++ʳ bs {bs′} [ x∈bs′ ] = [ ++⁺ʳ bs x∈bs′ ]
weaken-++ʳ bs {bs′} (x∈⟨bs′⟩ ⟨∙⟩ y∈⟨bs′⟩ ∣ xy≈z) = weaken-++ʳ bs x∈⟨bs′⟩ ⟨∙⟩ weaken-++ʳ bs y∈⟨bs′⟩ ∣ xy≈z
++-comm : ∀ {m n x} (bs : Vec Bird m) (bs′ : Vec Bird n) → x ∈ ⟨ bs ++ bs′ ⟩ → x ∈ ⟨ bs′ ++ bs ⟩
++-comm bs bs′ [ x∈bs++bs′ ] = [ Anyₚ.++-comm bs bs′ x∈bs++bs′ ]
++-comm bs bs′ (x∈⟨bs++bs′⟩ ⟨∙⟩ y∈⟨bs++bs′⟩ ∣ xy≈z) = ++-comm bs bs′ x∈⟨bs++bs′⟩ ⟨∙⟩ ++-comm bs bs′ y∈⟨bs++bs′⟩ ∣ xy≈z
open import Mockingbird.Forest.Birds forest
open import Mockingbird.Forest.Extensionality forest
module _ ⦃ _ : Extensional ⦄ ⦃ _ : HasCardinal ⦄ ⦃ _ : HasIdentity ⦄
⦃ _ : HasThrush ⦄ ⦃ _ : HasKestrel ⦄ ⦃ _ : HasStarling ⦄ where
private
CI≈T : C ∙ I ≈ T
CI≈T = ext $ λ x → ext $ λ y → begin
C ∙ I ∙ x ∙ y ≈⟨ isCardinal I x y ⟩
I ∙ y ∙ x ≈⟨ congʳ $ isIdentity y ⟩
y ∙ x ≈˘⟨ isThrush x y ⟩
T ∙ x ∙ y ∎
_ : T ∈ ⟨ C ∷ I ∷ [] ⟩
_ = subst CI≈T $ [# 0 ] ⟨∙⟩ [# 1 ]
_ : I ∈ ⟨ S ∷ K ∷ [] ⟩
_ = flip subst ([# 0 ] ⟨∙⟩ [# 1 ] ⟨∙⟩ [# 1 ]) $ ext $ λ x → begin
S ∙ K ∙ K ∙ x ≈⟨ isStarling K K x ⟩
K ∙ x ∙ (K ∙ x) ≈⟨ isKestrel x (K ∙ x) ⟩
x ≈˘⟨ isIdentity x ⟩
I ∙ x ∎
| {
"alphanum_fraction": 0.5042834891,
"avg_line_length": 40.7619047619,
"ext": "agda",
"hexsha": "ae7701710a455aedcca623bcb54728e5ec14a7fa",
"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/Properties.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/Properties.agda",
"max_line_length": 118,
"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/Properties.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": 1243,
"size": 2568
} |
{-# OPTIONS --postfix-projections #-}
open import Agda.Builtin.Nat
record R : Set where
field
x : Nat → Nat
open R {{...}}
f : R
f .x = {!!}
-- WAS: Case splitting on result produces the following nonsense:
-- f ⦃ .x ⦄ x₁ = ?
-- SHOULD: produce
-- f .x x₁ = ?
| {
"alphanum_fraction": 0.5808823529,
"avg_line_length": 14.3157894737,
"ext": "agda",
"hexsha": "52ec9edab979c3196f0cba35fada6ea4cf4a950e",
"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/Issue3289.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/Issue3289.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/Issue3289.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": 87,
"size": 272
} |
module Thesis.DeriveCorrect where
open import Thesis.Lang
open import Thesis.Changes
open import Thesis.LangChanges
open import Thesis.Derive
open import Relation.Binary.PropositionalEquality
open import Theorem.Groups-Nehemiah
fromtoDeriveConst : ∀ {τ : Type} (c : Const τ) →
ch ⟦ c ⟧ΔConst from ⟦ c ⟧Const to ⟦ c ⟧Const
fromtoDeriveConst unit = tt
fromtoDeriveConst (lit n) = right-id-int n
fromtoDeriveConst plus da a1 a2 daa db b1 b2 dbb rewrite sym daa | sym dbb = sym (mn·pq=mp·nq {a1} {da} {b1} {db})
fromtoDeriveConst minus da a1 a2 daa db b1 b2 dbb rewrite sym daa | sym dbb | sym (-m·-n=-mn {b1} {db}) = sym (mn·pq=mp·nq {a1} {da} { - b1} { - db})
fromtoDeriveConst cons da a1 a2 daa db b1 b2 dbb = daa , dbb
fromtoDeriveConst fst (da , db) (a1 , b1) (a2 , b2) (daa , dbb) = daa
fromtoDeriveConst snd (da , db) (a1 , b1) (a2 , b2) (daa , dbb) = dbb
fromtoDeriveConst linj da a1 a2 daa = sft₁ daa
fromtoDeriveConst rinj db b1 b2 dbb = sft₂ dbb
fromtoDeriveConst match .(inj₁ (inj₁ _)) .(inj₁ _) .(inj₁ _) (sft₁ daa) df f1 f2 dff dg g1 g2 dgg = dff _ _ _ daa
fromtoDeriveConst match .(inj₁ (inj₂ _)) .(inj₂ _) .(inj₂ _) (sft₂ dbb) df f1 f2 dff dg g1 g2 dgg = dgg _ _ _ dbb
fromtoDeriveConst match .(inj₂ (inj₂ b2)) .(inj₁ a1) .(inj₂ b2) (sftrp (inj₁ a1) (inj₂ b2)) df f1 f2 dff dg g1 g2 dgg
rewrite changeMatchSem-lem1 f1 df g1 dg a1 b2
| sym (fromto→⊕ dg g1 g2 dgg)
= ⊝-fromto (f1 a1) ((g1 ⊕ dg) b2)
fromtoDeriveConst match .(inj₂ (inj₁ a2)) .(inj₂ b1) .(inj₁ a2) (sftrp (inj₂ b1) (inj₁ a2)) df f1 f2 dff dg g1 g2 dgg
rewrite changeMatchSem-lem2 f1 df g1 dg b1 a2
| sym (fromto→⊕ df f1 f2 dff)
= ⊝-fromto (g1 b1) ((f1 ⊕ df) a2)
fromtoDeriveConst match .(inj₂ (inj₁ a2)) .(inj₁ a1) .(inj₁ a2) (sftrp (inj₁ a1) (inj₁ a2)) df f1 f2 dff dg g1 g2 dgg
rewrite changeMatchSem-lem3 f1 df g1 dg a1 a2
| sym (fromto→⊕ df f1 f2 dff)
= ⊝-fromto (f1 a1) ((f1 ⊕ df) a2)
fromtoDeriveConst match .(inj₂ (inj₂ b2)) .(inj₂ b1) .(inj₂ b2) (sftrp (inj₂ b1) (inj₂ b2)) df f1 f2 dff dg g1 g2 dgg
rewrite changeMatchSem-lem4 f1 df g1 dg b1 b2
| sym (fromto→⊕ dg g1 g2 dgg)
= ⊝-fromto (g1 b1) ((g1 ⊕ dg) b2)
fromtoDeriveVar : ∀ {Γ τ} → (x : Var Γ τ) →
∀ {dρ ρ1 ρ2} → [ Γ ]Γ dρ from ρ1 to ρ2 →
[ τ ]τ (⟦ x ⟧ΔVar ρ1 dρ) from (⟦ x ⟧Var ρ1) to (⟦ x ⟧Var ρ2)
fromtoDeriveVar this (dvv v• dρρ) = dvv
fromtoDeriveVar (that x) (dvv v• dρρ) = fromtoDeriveVar x dρρ
fromtoDeriveBase : ∀ {Γ} τ → (t : Term Γ τ) →
ch ⟦ t ⟧ΔTerm from ⟦ t ⟧Term to ⟦ t ⟧Term
fromtoDeriveBase τ (const c) dρ ρ1 ρ2 dρρ rewrite ⟦ c ⟧ΔConst-rewrite ρ1 dρ = fromtoDeriveConst c
fromtoDeriveBase τ (var x) dρ ρ1 ρ2 dρρ = fromtoDeriveVar x dρρ
fromtoDeriveBase τ (app {σ} s t) dρ ρ1 ρ2 dρρ rewrite sym (fit-sound t dρρ) =
let fromToF = fromtoDeriveBase (σ ⇒ τ) s _ _ _ dρρ
in let fromToB = fromtoDeriveBase σ t _ _ _ dρρ in fromToF _ _ _ fromToB
fromtoDeriveBase (σ ⇒ τ) (abs t) dρ ρ1 ρ2 dρρ = λ dv v1 v2 dvv →
fromtoDeriveBase τ t _ _ _ (dvv v• dρρ)
fromtoDerive : ∀ {Γ} τ → (t : Term Γ τ) →
{dρ : ChΓ Γ} {ρ1 ρ2 : ⟦ Γ ⟧Context} → [ Γ ]Γ dρ from ρ1 to ρ2 →
[ τ ]τ (⟦ t ⟧ΔTerm ρ1 dρ) from (⟦ t ⟧Term ρ1) to (⟦ t ⟧Term ρ2)
fromtoDerive τ t dρρ = fromtoDeriveBase τ t _ _ _ dρρ
-- Getting to the original equation 1 from PLDI'14.
correctDeriveOplus : ∀ {Γ} τ → (t : Term Γ τ) →
{dρ : ChΓ Γ} {ρ1 ρ2 : ⟦ Γ ⟧Context} → [ Γ ]Γ dρ from ρ1 to ρ2 →
(⟦ t ⟧Term ρ1) ⊕ (⟦ t ⟧ΔTerm ρ1 dρ) ≡ (⟦ t ⟧Term ρ2)
correctDeriveOplus τ t dρρ = fromto→⊕ _ _ _ (fromtoDerive τ t dρρ)
open import Thesis.LangOps
correctDeriveOplusτ : ∀ {Γ} τ → (t : Term Γ τ)
{dρ : ChΓ Γ} {ρ1 ρ2 : ⟦ Γ ⟧Context} → [ Γ ]Γ dρ from ρ1 to ρ2 →
(⟦ app₂ (oplusτo τ) (fit t) (derive t) ⟧Term dρ) ≡ (⟦ t ⟧Term ρ2)
correctDeriveOplusτ τ t {dρ = dρ} {ρ1 = ρ1} dρρ
rewrite oplusτ-equiv _ dρ _ (⟦ fit t ⟧Term dρ) (⟦ derive t ⟧Term dρ)
| sym (fit-sound t dρρ)
= correctDeriveOplus τ t dρρ
deriveGivesDerivative : ∀ {Γ} σ τ → (f : Term Γ (σ ⇒ τ)) (a : Term Γ σ)→
{dρ : ChΓ Γ} {ρ1 ρ2 : ⟦ Γ ⟧Context} → [ Γ ]Γ dρ from ρ1 to ρ2 →
(⟦ app f a ⟧Term ρ1) ⊕ (⟦ app f a ⟧ΔTerm ρ1 dρ) ≡ (⟦ app f a ⟧Term ρ2)
deriveGivesDerivative σ τ f a dρρ = correctDeriveOplus τ (app f a) dρρ
deriveGivesDerivative₂ : ∀ {Γ} σ τ → (f : Term Γ (σ ⇒ τ)) (a : Term Γ σ) →
{dρ : ChΓ Γ} {ρ1 ρ2 : ⟦ Γ ⟧Context} → [ Γ ]Γ dρ from ρ1 to ρ2 →
(⟦ app₂ (oplusτo τ) (fit (app f a)) (app₂ (derive f) (fit a) (derive a)) ⟧Term dρ) ≡ (⟦ app f a ⟧Term ρ2)
deriveGivesDerivative₂ σ τ f a dρρ = correctDeriveOplusτ τ (app f a) dρρ
-- Proof of the original equation 1 from PLDI'14. The original was restricted to
-- closed terms. This is a generalization, because it holds also for open terms,
-- *as long as* the environment change is a nil change.
eq1 : ∀ {Γ} σ τ →
{nilρ : ChΓ Γ} {ρ : ⟦ Γ ⟧Context} → [ Γ ]Γ nilρ from ρ to ρ →
∀ (f : Term Γ (σ ⇒ τ)) (a : Term Γ σ) (da : Term (ΔΓ Γ) (Δt σ)) →
(daa : [ σ ]τ (⟦ da ⟧Term nilρ) from (⟦ a ⟧Term ρ) to (⟦ a ⟧Term ρ ⊕ ⟦ da ⟧Term nilρ)) →
⟦ app₂ (oplusτo τ) (fit (app f a)) (app₂ (derive f) (fit a) da) ⟧Term nilρ ≡ ⟦ app (fit f) (app₂ (oplusτo σ) (fit a) da) ⟧Term nilρ
eq1 σ τ {nilρ} {ρ} dρρ f a da daa
rewrite
oplusτ-equiv _ nilρ _ (⟦ fit (app f a) ⟧Term nilρ) (⟦ (app₂ (derive f) (fit a) da) ⟧Term nilρ)
| sym (fit-sound f dρρ)
| oplusτ-equiv _ nilρ _ (⟦ fit a ⟧Term nilρ) (⟦ da ⟧Term nilρ)
| sym (fit-sound a dρρ)
= fromto→⊕ (⟦ f ⟧ΔTerm ρ nilρ (⟦ a ⟧Term ρ) (⟦ da ⟧Term nilρ)) _ _
(fromtoDerive _ f dρρ (⟦ da ⟧Term nilρ) (⟦ a ⟧Term ρ)
(⟦ a ⟧Term ρ ⊕ ⟦ da ⟧Term nilρ) daa)
| {
"alphanum_fraction": 0.6247268755,
"avg_line_length": 51.8113207547,
"ext": "agda",
"hexsha": "661109a8d5ac9ca221b15e3a838a4c431238ea4f",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z",
"max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "inc-lc/ilc-agda",
"max_forks_repo_path": "Thesis/DeriveCorrect.agda",
"max_issues_count": 6,
"max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "inc-lc/ilc-agda",
"max_issues_repo_path": "Thesis/DeriveCorrect.agda",
"max_line_length": 149,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "inc-lc/ilc-agda",
"max_stars_repo_path": "Thesis/DeriveCorrect.agda",
"max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z",
"num_tokens": 2689,
"size": 5492
} |
module Logic.Convenience {ℓ} where
import Lvl
open import Data.Tuple as Tuple using (_⨯_ ; _,_)
open import Functional
open import Logic.Propositional{ℓ}
open import Type
record [⇒]-proof (Proof : Stmt → Stmt → Type{ℓ}) : Type{Lvl.𝐒(ℓ)} where
infixl 10 _⇒_
infixr 10 _⇐_
field
_⇒_ : ∀{X Y : Stmt} → X → Proof(X)(Y) → Y
_⇐_ : ∀{X Y : Stmt} → Proof(X)(Y) → X → Y
_⇐_ = swap(_⇒_)
open [⇒]-proof ⦃...⦄ public
instance
[⇒]-proof-[→] : [⇒]-proof (X ↦ Y ↦ (X → Y))
_⇒_ ⦃ [⇒]-proof-[→] ⦄ = apply
instance
[⇒]-proof-[↔] : [⇒]-proof (X ↦ Y ↦ (X ↔ Y))
_⇒_ ⦃ [⇒]-proof-[↔] ⦄ = swap(Tuple.right)
instance
[⇒]-proof-unrelated : [⇒]-proof (X ↦ Y ↦ Y)
_⇒_ ⦃ [⇒]-proof-unrelated ⦄ = swap(const)
-- TODO: ⇔ probably means using transitivity
| {
"alphanum_fraction": 0.5590551181,
"avg_line_length": 23.0909090909,
"ext": "agda",
"hexsha": "0c84c291ca7d436c5d5aafe8245dac722459ba03",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "old/Logic/Convenience.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "old/Logic/Convenience.agda",
"max_line_length": 71,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "old/Logic/Convenience.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": 362,
"size": 762
} |
-- Andreas, 2016-05-04, discussion with Ulf
-- Projections should be treated in the same way asonstructors,
-- what parameters concerns
-- {-# OPTIONS -v tc.mod.apply:15 #-}
-- {-# OPTIONS -v tc.term.con:50 -v tc.term.def:10 #-}
module _ where
module M (A : Set) where
data D : Set where
c : A → D
record R : Set where
field f : A
g = f
open R public
open module N A = M A
-- After module copy, constructor parameter is still hidden
check : ∀ A → A → D A
check A x = c {A = A} x
pat : ∀ A → D A → Set
pat A (c x) = A
-- Field parameter should be hidden
infer : ∀ A → R A → A
infer A r = f r
-- and skipped on the lhs.
copat : ∀ A (a : A) → R A
f (copat A a) = a
| {
"alphanum_fraction": 0.5994236311,
"avg_line_length": 17.7948717949,
"ext": "agda",
"hexsha": "e9359125e84af48fda640ea0d1bd2534e35c76f8",
"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/Issue1954.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/Issue1954.agda",
"max_line_length": 63,
"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/Issue1954.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": 232,
"size": 694
} |
module Control.Monad.Except where
open import Prelude
open import Control.Monad.Zero
open import Control.Monad.Identity
open import Control.Monad.Transformer
record ExceptT {a} (E : Set a) (M : Set a → Set a) (A : Set a) : Set a where
no-eta-equality
constructor maybeT
field runExceptT : M (Either E A)
open ExceptT public
module _ {a} {E : Set a} {M : Set a → Set a} where
instance
FunctorExceptT : {{_ : Functor M}} → Functor {a = a} (ExceptT E M)
runExceptT (fmap {{FunctorExceptT}} f m) = fmap f <$> runExceptT m
FunctorZeroExceptT : {{_ : Monad M}} {{_ : Monoid E}} → FunctorZero {a = a} (ExceptT E M)
runExceptT (empty {{FunctorZeroExceptT}}) = return (left mempty)
AlternativeExceptT : {{_ : Monad M}} {{_ : Monoid E}} → Alternative {a = a} (ExceptT E M)
runExceptT (_<|>_ {{AlternativeExceptT {{monadM}}}} mx my) = do
right x ← runExceptT mx
where
left e₁ → do
right y ← runExceptT my
where left e₂ → return (left (e₁ <> e₂))
return (right y)
return (right x)
module _ {{_ : Monad M}} where
private
bindExceptT : ∀ {A B} → ExceptT E M A → (A → ExceptT E M B) → ExceptT E M B
runExceptT (bindExceptT m f) = do
right x ← runExceptT m
where left e → return (left e)
runExceptT (f x)
instance
ApplicativeExceptT : Applicative {a = a} (ExceptT E M)
runExceptT (pure {{ApplicativeExceptT}} x) = pure (right x)
_<*>_ {{ApplicativeExceptT}} = monadAp bindExceptT
MonadExceptT : Monad {a = a} (ExceptT E M)
_>>=_ {{MonadExceptT}} = bindExceptT
liftExceptT : {A : Set a} → M A → ExceptT E M A
runExceptT (liftExceptT m) = right <$> m
instance
TransformerExceptT : ∀ {a} {E : Set a} → Transformer {a} (ExceptT E)
lift {{TransformerExceptT}} = liftExceptT
Except : ∀ {a} (E : Set a) (A : Set a) → Set a
Except R = ExceptT R Identity
runExcept : ∀ {a} {E : Set a} {A : Set a} → Except E A → Either E A
runExcept m = runIdentity (runExceptT m)
| {
"alphanum_fraction": 0.610459433,
"avg_line_length": 31.96875,
"ext": "agda",
"hexsha": "84ffea0aa9ea7e88bbdffa7cc7df1247aceb6ff5",
"lang": "Agda",
"max_forks_count": 24,
"max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z",
"max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "L-TChen/agda-prelude",
"max_forks_repo_path": "src/Control/Monad/Except.agda",
"max_issues_count": 59,
"max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267",
"max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "L-TChen/agda-prelude",
"max_issues_repo_path": "src/Control/Monad/Except.agda",
"max_line_length": 93,
"max_stars_count": 111,
"max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "L-TChen/agda-prelude",
"max_stars_repo_path": "src/Control/Monad/Except.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z",
"num_tokens": 657,
"size": 2046
} |
module type-level where
open import bool
open import level
open import nat
{- multiApply{n} applies a sequence f1, f2, ..., f_n of functions
to a starting point a:
multiApply{n} a f1 f2 ... f_n = f_n (... (f2 (f1 a)))
-}
multiApplyTh : ℕ → Set → Set lone
multiApplyTh 0 A = Lift A
multiApplyTh (suc n) A = ∀{B : Set} → (A → B) → multiApplyTh n B
multiApplyT : ℕ → Set lone
multiApplyT n = ∀{A : Set} → A → multiApplyTh n A
multiApply-testT = multiApplyT 2
multiApplyh : {A : Set}{n : ℕ} → A → multiApplyTh n A
multiApplyh {n = zero} a = lift a
multiApplyh {n = suc n} a f = multiApplyh{n = n} (f a)
multiApply : {n : ℕ} → multiApplyT n
multiApply{n} = λ{A : Set}(a : A) → multiApplyh{A}{n} a
multiApply-test1 : Lift 𝔹
multiApply-test1 = multiApply{3} 3 (_+_ 3) is-even ~_ | {
"alphanum_fraction": 0.6434010152,
"avg_line_length": 26.2666666667,
"ext": "agda",
"hexsha": "b80fe50f1a2ab8c4aaf2c4487190157b9a45426a",
"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": "type-level.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": "type-level.agda",
"max_line_length": 66,
"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": "type-level.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 291,
"size": 788
} |
module Oscar.Category.Monoid where
open import Oscar.Level
record Monoid 𝔬 𝔪 𝔮 : Set (lsuc (𝔬 ⊔ 𝔪 ⊔ 𝔮)) where
| {
"alphanum_fraction": 0.7079646018,
"avg_line_length": 16.1428571429,
"ext": "agda",
"hexsha": "9b7e5b3221fee82d182cff9a64956aa26465dd32",
"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/Category/Monoid.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/Category/Monoid.agda",
"max_line_length": 50,
"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/Category/Monoid.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 47,
"size": 113
} |
module Numeral.Integer.Oper where
open import Numeral.Natural as ℕ using (ℕ)
import Numeral.Natural.Oper as ℕ
open import Numeral.Integer
open import Numeral.Integer.Sign
import Numeral.Sign as Sign
import Numeral.Sign.Oper0 as Sign
-- Unclosed total subtraction from natural numbers to integers
_−ₙ_ : ℕ → ℕ → ℤ
x −ₙ ℕ.𝟎 = ℤ.+ₙ x
ℕ.𝟎 −ₙ ℕ.𝐒(x) = ℤ.−𝐒ₙ(x)
ℕ.𝐒(x) −ₙ ℕ.𝐒(y) = x −ₙ y
-- Construction of an integer with the sign and numeral components
signed : (Sign.+|−) → ℕ → ℤ
signed (Sign.➕) (n) = +ₙ n
signed (Sign.➖) (n) = −ₙ n
signed0 : (Sign.+|0|−) → ℕ → ℤ
signed0(Sign.➕) (ℕ.𝐒(n)) = +𝐒ₙ(n)
signed0(Sign.➖) (ℕ.𝐒(n)) = −𝐒ₙ(n)
{-# CATCHALL #-}
signed0(_) (_) = 𝟎
------------------------------------------
-- Unary operations
-- Predecessor
𝐏 : ℤ → ℤ
𝐏(+𝐒ₙ(n)) = +ₙ n
𝐏(𝟎) = −𝐒ₙ(ℕ.𝟎)
𝐏(−𝐒ₙ(n)) = −𝐒ₙ(ℕ.𝐒(n))
-- Successor
𝐒 : ℤ → ℤ
𝐒(+ₙ n) = +ₙ ℕ.𝐒(n)
𝐒(−𝐒ₙ(ℕ.𝟎)) = +ₙ ℕ.𝟎
𝐒(−𝐒ₙ(ℕ.𝐒(n))) = −𝐒ₙ(n)
-- Identity
+_ : ℤ → ℤ
+ n = n
-- Negation
−_ : ℤ → ℤ
− 𝟎 = 𝟎
− (+𝐒ₙ(n)) = −𝐒ₙ(n)
− (−𝐒ₙ(n)) = +𝐒ₙ(n)
-- Absolute value
abs : ℤ → ℤ
abs(+ₙ x) = +ₙ x
abs(−𝐒ₙ x) = +𝐒ₙ x
------------------------------------------
-- Binary operations
infixl 10010 _+_
infixl 10020 _⋅_
-- Addition
_+_ : ℤ → ℤ → ℤ
(+ₙ x) + (+ₙ y) = +ₙ (x ℕ.+ y)
(−𝐒ₙ x) + (−𝐒ₙ y) = −𝐒ₙ(ℕ.𝐒(x ℕ.+ y))
(+ₙ x) + (−𝐒ₙ y) = x −ₙ ℕ.𝐒(y)
(−𝐒ₙ x) + (+ₙ y) = (+ₙ y) + (−𝐒ₙ x)
-- Subtraction
_−_ : ℤ → ℤ → ℤ
x − y = x + (− y)
-- Multiplication
_⋅_ : ℤ → ℤ → ℤ
x ⋅ y = signed0 ((sign0 x) Sign.⨯ (sign0 y)) ((absₙ x) ℕ.⋅ (absₙ y))
-- Distance
_𝄩_ : ℤ → ℤ → ℕ
(+ₙ x) 𝄩 (+ₙ y) = x ℕ.𝄩 y
(−𝐒ₙ x) 𝄩 (−𝐒ₙ y) = x ℕ.𝄩 y
(+ₙ(ℕ.𝟎)) 𝄩 (−𝐒ₙ y) = ℕ.𝐒(y)
(+ₙ(ℕ.𝐒 x)) 𝄩 (−𝐒ₙ y) = ℕ.𝐒((+ₙ x) 𝄩 (−𝐒ₙ y))
(−𝐒ₙ x) 𝄩 (+ₙ(ℕ.𝟎)) = ℕ.𝐒(x)
(−𝐒ₙ x) 𝄩 (+ₙ(ℕ.𝐒 y)) = ℕ.𝐒((−𝐒ₙ x) 𝄩 (+ₙ y))
| {
"alphanum_fraction": 0.4574700109,
"avg_line_length": 21.3255813953,
"ext": "agda",
"hexsha": "4373c719edc7bb6c4879305ad5bc06260045f169",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Numeral/Integer/Oper.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Numeral/Integer/Oper.agda",
"max_line_length": 68,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Numeral/Integer/Oper.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": 1095,
"size": 1834
} |
------------------------------------------------------------------------
-- A formalisation of some definitions and laws from Section 2.4 of
-- Ralf Hinze's paper "Streams and Unique Fixed Points"
------------------------------------------------------------------------
-- Note: Using the approach of Stream.Programs and Stream.Equality the
-- proofs look just like Hinze's, but they are based on guarded
-- coinduction rather than relying (directly) on universality.
-- Also note that the formalisation can be simplified by defining the
-- streams differently. See Hinze.Simplified.
module Hinze.Section2-4 where
open import Stream.Programs
open import Stream.Equality
open import Stream.Pointwise hiding (⟦_⟧)
open import Hinze.Lemmas
open import Codata.Musical.Notation hiding (∞)
open import Data.Nat
open import Relation.Binary.PropositionalEquality
renaming (module ≡-Reasoning to ER)
open import Algebra.Structures
import Data.Nat.Properties as Nat
private
module CS = IsCommutativeSemiring Nat.+-*-isCommutativeSemiring
open import Data.Product
------------------------------------------------------------------------
-- Definitions
nat : Prog ℕ
nat = 0 ≺ ♯ (nat ⟨ _+_ ⟩ 1 ∞)
2*nat : Prog ℕ
2*nat = 2 ∞ ⟨ _*_ ⟩ nat
2*nat+1 : Prog ℕ
2*nat+1 = 2*nat ⟨ _+_ ⟩ 1 ∞
fac : Prog ℕ
fac = 1 ≺ ♯ ((nat ⟨ _+_ ⟩ 1 ∞) ⟨ _*_ ⟩ fac)
fib : Prog ℕ
fib = 0 ≺ ♯ (fib ⟨ _+_ ⟩ (1 ≺ ♯ fib))
bin : Prog ℕ
bin = 0 ≺ ♯ ((2 ∞ ⟨ _*_ ⟩ bin) ⟨ _+_ ⟩ 1 ∞ ⋎
(2 ∞ ⟨ _*_ ⟩ bin) ⟨ _+_ ⟩ 2 ∞)
------------------------------------------------------------------------
-- Laws and properties
const-is-∞ : ∀ {A} {x : A} {xs} →
xs ≊ x ≺♯ xs → xs ≊ x ∞
const-is-∞ {x = x} {xs} eq =
xs
≊⟨ eq ⟩
x ≺♯ xs
≊⟨ refl ≺ ♯ const-is-∞ eq ⟩
x ≺♯ x ∞
≡⟨ refl ⟩
x ∞
∎
nat-lemma₁ : 0 ≺♯ 2*nat+1 ⋎ 2*nat ⟨ _+_ ⟩ 2 ∞ ≊ 2*nat ⋎ 2*nat+1
nat-lemma₁ =
0 ≺♯ 2*nat+1 ⋎ 2*nat ⟨ _+_ ⟩ 2 ∞
≊⟨ refl ≺ ♯ ⋎-cong 2*nat+1 2*nat+1 (2*nat+1 ∎)
(2*nat ⟨ _+_ ⟩ 2 ∞)
(2 ∞ ⟨ _*_ ⟩ (nat ⟨ _+_ ⟩ 1 ∞))
(lemma (2 ∞) nat) ⟩
0 ≺♯ 2*nat+1 ⋎ 2 ∞ ⟨ _*_ ⟩ (nat ⟨ _+_ ⟩ 1 ∞)
≡⟨ refl ⟩
2*nat ⋎ 2*nat+1
∎
where
lemma : ∀ s t →
(s ⟨ _*_ ⟩ t) ⟨ _+_ ⟩ s ≊ s ⟨ _*_ ⟩ (t ⟨ _+_ ⟩ 1 ∞)
lemma = pointwise 2 (λ s t → (s ⟨ _*_ ⟩ t) ⟨ _+_ ⟩ s)
(λ s t → s ⟨ _*_ ⟩ (t ⟨ _+_ ⟩ 1 ∞))
(λ m n → sym (ER.begin
m * (n + 1)
ER.≡⟨ proj₁ CS.distrib m n 1 ⟩
m * n + m * 1
ER.≡⟨ cong (_+_ (m * n)) (proj₂ CS.*-identity m) ⟩
m * n + m
ER.∎))
nat-lemma₂ : nat ≊ 2*nat ⋎ 2*nat+1
nat-lemma₂ =
nat
≡⟨ refl ⟩
0 ≺♯ nat ⟨ _+_ ⟩ 1 ∞
≊⟨ refl ≺ ♯ ⟨ _+_ ⟩-cong nat (2*nat ⋎ 2*nat+1) nat-lemma₂
(1 ∞) (1 ∞) (1 ∞ ∎) ⟩
0 ≺♯ (2*nat ⋎ 2*nat+1) ⟨ _+_ ⟩ 1 ∞
≊⟨ refl ≺ ♯ zip-⋎-const _+_ 2*nat 2*nat+1 1 ⟩
0 ≺♯ 2*nat+1 ⋎ 2*nat+1 ⟨ _+_ ⟩ 1 ∞
≊⟨ refl ≺ ♯ ⋎-cong 2*nat+1 2*nat+1 (2*nat+1 ∎)
(2*nat+1 ⟨ _+_ ⟩ 1 ∞)
(2*nat ⟨ _+_ ⟩ 2 ∞) (lemma 2*nat) ⟩
0 ≺♯ 2*nat+1 ⋎ 2*nat ⟨ _+_ ⟩ 2 ∞
≊⟨ nat-lemma₁ ⟩
2*nat ⋎ 2*nat+1
∎
where
lemma : ∀ s → (s ⟨ _+_ ⟩ 1 ∞) ⟨ _+_ ⟩ 1 ∞ ≊ s ⟨ _+_ ⟩ 2 ∞
lemma = pointwise 1 (λ s → (s ⟨ _+_ ⟩ 1 ∞) ⟨ _+_ ⟩ 1 ∞)
(λ s → s ⟨ _+_ ⟩ 2 ∞)
(λ n → CS.+-assoc n 1 1)
nat≊bin : nat ≊ bin
nat≊bin =
nat
≊⟨ nat-lemma₂ ⟩
2*nat ⋎ 2*nat+1
≊⟨ ≅-sym nat-lemma₁ ⟩
0 ≺♯ 2*nat+1 ⋎ 2*nat ⟨ _+_ ⟩ 2 ∞
≊⟨ refl ≺ coih ⟩
0 ≺♯ (2 ∞ ⟨ _*_ ⟩ bin) ⟨ _+_ ⟩ 1 ∞ ⋎
(2 ∞ ⟨ _*_ ⟩ bin) ⟨ _+_ ⟩ 2 ∞
≡⟨ refl ⟩
bin
∎
where
coih = ♯ ⋎-cong 2*nat+1 ((2 ∞ ⟨ _*_ ⟩ bin) ⟨ _+_ ⟩ 1 ∞)
(⟨ _+_ ⟩-cong 2*nat (2 ∞ ⟨ _*_ ⟩ bin)
(⟨ _*_ ⟩-cong (2 ∞) (2 ∞) (2 ∞ ∎)
nat bin nat≊bin)
(1 ∞) (1 ∞) (1 ∞ ∎))
(2*nat ⟨ _+_ ⟩ 2 ∞)
((2 ∞ ⟨ _*_ ⟩ bin) ⟨ _+_ ⟩ 2 ∞)
(⟨ _+_ ⟩-cong 2*nat (2 ∞ ⟨ _*_ ⟩ bin)
(⟨ _*_ ⟩-cong (2 ∞) (2 ∞) (2 ∞ ∎)
nat bin nat≊bin)
(2 ∞) (2 ∞) (2 ∞ ∎))
iterate-fusion
: ∀ {A B} (h : A → B) (f₁ : A → A) (f₂ : B → B) →
(∀ x → h (f₁ x) ≡ f₂ (h x)) →
∀ x → h · iterate f₁ x ≊ iterate f₂ (h x)
iterate-fusion h f₁ f₂ hyp x =
h · iterate f₁ x
≡⟨ refl ⟩
h x ≺♯ h · iterate f₁ (f₁ x)
≊⟨ refl ≺ ♯ iterate-fusion h f₁ f₂ hyp (f₁ x) ⟩
h x ≺♯ iterate f₂ (h (f₁ x))
≡⟨ cong (λ y → ⟦ h x ≺♯ iterate f₂ y ⟧) (hyp x) ⟩
h x ≺♯ iterate f₂ (f₂ (h x))
≡⟨ refl ⟩
iterate f₂ (h x)
∎
nat-iterate : nat ≊ iterate suc 0
nat-iterate =
nat
≡⟨ refl ⟩
0 ≺♯ nat ⟨ _+_ ⟩ 1 ∞
≊⟨ refl ≺ ♯ pointwise 1 (λ s → s ⟨ _+_ ⟩ 1 ∞) (_·_ suc)
(λ x → CS.+-comm x 1) nat ⟩
0 ≺♯ suc · nat
≊⟨ refl ≺ ♯ ·-cong suc nat (iterate suc 0) nat-iterate ⟩
0 ≺♯ suc · iterate suc 0
≊⟨ refl ≺ ♯ iterate-fusion suc suc suc (λ _ → refl) 0 ⟩
0 ≺♯ iterate suc 1
≡⟨ refl ⟩
iterate suc 0
∎
| {
"alphanum_fraction": 0.3305137845,
"avg_line_length": 37.3333333333,
"ext": "agda",
"hexsha": "d1c635a81cdfd35b780fd3008d0fe49a39e6061a",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/codata",
"max_forks_repo_path": "Hinze/Section2-4.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/codata",
"max_issues_repo_path": "Hinze/Section2-4.agda",
"max_line_length": 98,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/codata",
"max_stars_repo_path": "Hinze/Section2-4.agda",
"max_stars_repo_stars_event_max_datetime": "2021-02-13T14:48:45.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-02-13T14:48:45.000Z",
"num_tokens": 2302,
"size": 6384
} |
{-
This second-order equational theory was created from the following second-order syntax description:
syntax Monad | M
type
T : 1-ary
term
ret : α -> T α
bind : T α α.(T β) -> T β | _>>=_ r10
theory
(LU) a : α b : α.(T β) |> bind (ret(a), x. b[x]) = b[a]
(RU) t : T α |> bind (t, x. ret(x)) = t
(AS) t : T α b : α.(T β) c : β.(T γ) |> bind (bind (t, x.b[x]), y.c[y]) = bind (t, x. bind (b[x], y.c[y]))
-}
module Monad.Equality where
open import SOAS.Common
open import SOAS.Context
open import SOAS.Variable
open import SOAS.Families.Core
open import SOAS.Families.Build
open import SOAS.ContextMaps.Inductive
open import Monad.Signature
open import Monad.Syntax
open import SOAS.Metatheory.SecondOrder.Metasubstitution M:Syn
open import SOAS.Metatheory.SecondOrder.Equality M:Syn
private
variable
α β γ τ : MT
Γ Δ Π : Ctx
infix 1 _▹_⊢_≋ₐ_
-- Axioms of equality
data _▹_⊢_≋ₐ_ : ∀ 𝔐 Γ {α} → (𝔐 ▷ M) α Γ → (𝔐 ▷ M) α Γ → Set where
LU : ⁅ α ⁆ ⁅ α ⊩ T β ⁆̣ ▹ ∅ ⊢ (ret 𝔞) >>= 𝔟⟨ x₀ ⟩ ≋ₐ 𝔟⟨ 𝔞 ⟩
RU : ⁅ T α ⁆̣ ▹ ∅ ⊢ 𝔞 >>= (ret x₀) ≋ₐ 𝔞
AS : ⁅ T α ⁆ ⁅ α ⊩ T β ⁆ ⁅ β ⊩ T γ ⁆̣ ▹ ∅ ⊢ (𝔞 >>= 𝔟⟨ x₀ ⟩) >>= 𝔠⟨ x₀ ⟩ ≋ₐ 𝔞 >>= (𝔟⟨ x₀ ⟩ >>= 𝔠⟨ x₀ ⟩)
open EqLogic _▹_⊢_≋ₐ_
open ≋-Reasoning
| {
"alphanum_fraction": 0.5487900078,
"avg_line_length": 26.1428571429,
"ext": "agda",
"hexsha": "6f235c61e2b8b83ab31b34eb6c06a82c0328aebf",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z",
"max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "JoeyEremondi/agda-soas",
"max_forks_repo_path": "out/Monad/Equality.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8",
"max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "JoeyEremondi/agda-soas",
"max_issues_repo_path": "out/Monad/Equality.agda",
"max_line_length": 110,
"max_stars_count": 39,
"max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "JoeyEremondi/agda-soas",
"max_stars_repo_path": "out/Monad/Equality.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z",
"num_tokens": 576,
"size": 1281
} |
module PiQ.Opsem where
open import Data.Empty
open import Data.Unit hiding (_≟_)
open import Data.Sum
open import Data.Product
open import Data.Maybe
open import Relation.Binary.Core
open import Relation.Binary
open import Relation.Nullary
open import Relation.Binary.PropositionalEquality
open import Function using (_∘_)
open import Base
open import PiQ.Syntax
infix 1 _↦_
-- Base combinators
base : ∀ {A B} (c : A ↔ B) → Set
base unite₊l = ⊤
base uniti₊l = ⊤
base swap₊ = ⊤
base assocl₊ = ⊤
base assocr₊ = ⊤
base unite⋆l = ⊤
base uniti⋆l = ⊤
base swap⋆ = ⊤
base assocl⋆ = ⊤
base assocr⋆ = ⊤
base absorbr = ⊤
base factorzl = ⊤
base dist = ⊤
base factor = ⊤
base _ = ⊥
-- Dual combinators
dual : ∀ {A B} (c : A ↔ B) → Set
dual (ηₓ _) = ⊤
dual (εₓ _) = ⊤
dual η₊ = ⊤
dual ε₊ = ⊤
dual _ = ⊥
base-is-prop : ∀ {A B} (c : A ↔ B) → is-prop (base c)
base-is-prop unite₊l tt tt = refl
base-is-prop uniti₊l tt tt = refl
base-is-prop swap₊ tt tt = refl
base-is-prop assocl₊ tt tt = refl
base-is-prop assocr₊ tt tt = refl
base-is-prop unite⋆l tt tt = refl
base-is-prop uniti⋆l tt tt = refl
base-is-prop swap⋆ tt tt = refl
base-is-prop assocl⋆ tt tt = refl
base-is-prop assocr⋆ tt tt = refl
base-is-prop absorbr tt tt = refl
base-is-prop factorzl tt tt = refl
base-is-prop dist tt tt = refl
base-is-prop factor tt tt = refl
-- Evaluator for base combinators
δ : ∀ {A B} (c : A ↔ B) {_ : base c} → ⟦ A ⟧ → ⟦ B ⟧
δ unite₊l (inj₂ v) = v
δ uniti₊l v = inj₂ v
δ swap₊ (inj₁ x) = inj₂ x
δ swap₊ (inj₂ y) = inj₁ y
δ assocl₊ (inj₁ v) = inj₁ (inj₁ v)
δ assocl₊ (inj₂ (inj₁ v)) = inj₁ (inj₂ v)
δ assocl₊ (inj₂ (inj₂ v)) = inj₂ v
δ assocr₊ (inj₁ (inj₁ v)) = inj₁ v
δ assocr₊ (inj₁ (inj₂ v)) = inj₂ (inj₁ v)
δ assocr₊ (inj₂ v) = inj₂ (inj₂ v)
δ unite⋆l (tt , v) = v
δ uniti⋆l v = (tt , v)
δ swap⋆ (x , y) = (y , x)
δ assocl⋆ (v₁ , (v₂ , v₃)) = ((v₁ , v₂) , v₃)
δ assocr⋆ ((v₁ , v₂) , v₃) = (v₁ , (v₂ , v₃))
δ absorbr ()
δ factorzl ()
δ dist (inj₁ v₁ , v₃) = inj₁ (v₁ , v₃)
δ dist (inj₂ v₂ , v₃) = inj₂ (v₂ , v₃)
δ factor (inj₁ (v₁ , v₃)) = (inj₁ v₁ , v₃)
δ factor (inj₂ (v₂ , v₃)) = (inj₂ v₂ , v₃)
-- Decidable equality of PiQ values
_≟_ : {t : 𝕌} → Decidable (_≡_ {A = ⟦ t ⟧})
_≟_ {𝟙} tt tt = yes refl
_≟_ {t₁ +ᵤ t₂} (inj₁ x) (inj₁ y) with x ≟ y
... | yes refl = yes refl
... | no x≠y = no (x≠y ∘ λ {refl → refl})
_≟_ {t₁ +ᵤ t₂} (inj₁ x) (inj₂ y) = no (λ ())
_≟_ {t₁ +ᵤ t₂} (inj₂ x) (inj₁ y) = no (λ ())
_≟_ {t₁ +ᵤ t₂} (inj₂ x) (inj₂ y) with x ≟ y
... | yes refl = yes refl
... | no x≠y = no (x≠y ∘ λ {refl → refl})
_≟_ {t₁ ×ᵤ t₂} (x₁ , x₂) (y₁ , y₂) with x₁ ≟ y₁ | x₂ ≟ y₂
... | yes refl | yes refl = yes refl
... | yes refl | no x₂≠y₂ = no (x₂≠y₂ ∘ cong proj₂)
... | no x₁≠y₁ | yes refl = no (x₁≠y₁ ∘ cong proj₁)
... | no x₁≠y₁ | no x₂≠y₂ = no (x₁≠y₁ ∘ cong proj₁)
_≟_ {𝟙/ t} ↻ ↻ = yes refl
_≟_ { - t} (- v₁) (- v₂) with v₁ ≟ v₂
... | yes refl = yes refl
... | no neq = no (λ {refl → neq refl})
-- Context
data Context : {A B : 𝕌} → Set where
☐ : ∀ {A B} → Context {A} {B}
☐⨾_•_ : ∀ {A B C} → (c₂ : B ↔ C) → Context {A} {C} → Context {A} {B}
_⨾☐•_ : ∀ {A B C} → (c₁ : A ↔ B) → Context {A} {C} → Context {B} {C}
☐⊕_•_ : ∀ {A B C D} → (c₂ : C ↔ D) → Context {A +ᵤ C} {B +ᵤ D} → Context {A} {B}
_⊕☐•_ : ∀ {A B C D} → (c₁ : A ↔ B) → Context {A +ᵤ C} {B +ᵤ D} → Context {C} {D}
☐⊗[_,_]•_ : ∀ {A B C D} → (c₂ : C ↔ D) → ⟦ C ⟧ → Context {A ×ᵤ C} {B ×ᵤ D} → Context {A} {B}
[_,_]⊗☐•_ : ∀ {A B C D} → (c₁ : A ↔ B) → ⟦ B ⟧ → Context {A ×ᵤ C} {B ×ᵤ D} → Context {C} {D}
-- Machine state
data State : Set where
⟨_∣_∣_⟩▷ : ∀ {A B} → (c : A ↔ B) → ⟦ A ⟧ → Context {A} {B} → State
[_∣_∣_]▷ : ∀ {A B} → (c : A ↔ B) → ⟦ B ⟧ → Context {A} {B} → State
⟨_∣_∣_⟩◁ : ∀ {A B} → (c : A ↔ B) → ⟦ A ⟧ → Context {A} {B} → State
[_∣_∣_]◁ : ∀ {A B} → (c : A ↔ B) → ⟦ B ⟧ → Context {A} {B} → State
⊠ : State
-- Reduction relation
data _↦_ : State → State → Set where
↦⃗₁ : ∀ {A B} {c : A ↔ B} {b : base c} {v : ⟦ A ⟧} {κ : Context}
→ ⟨ c ∣ v ∣ κ ⟩▷ ↦ [ c ∣ δ c {b} v ∣ κ ]▷
↦⃗₂ : ∀ {A} {v : ⟦ A ⟧} {κ : Context} → ⟨ id↔ ∣ v ∣ κ ⟩▷ ↦ [ id↔ ∣ v ∣ κ ]▷
↦⃗₃ : ∀ {A B C} {c₁ : A ↔ B} {c₂ : B ↔ C} {v : ⟦ A ⟧} {κ : Context}
→ ⟨ c₁ ⨾ c₂ ∣ v ∣ κ ⟩▷ ↦ ⟨ c₁ ∣ v ∣ ☐⨾ c₂ • κ ⟩▷
↦⃗₄ : ∀ {A B C D} {c₁ : A ↔ B} {c₂ : C ↔ D} {x : ⟦ A ⟧} {κ : Context}
→ ⟨ c₁ ⊕ c₂ ∣ inj₁ x ∣ κ ⟩▷ ↦ ⟨ c₁ ∣ x ∣ ☐⊕ c₂ • κ ⟩▷
↦⃗₅ : ∀ {A B C D} {c₁ : A ↔ B} {c₂ : C ↔ D} {y : ⟦ C ⟧} {κ : Context}
→ ⟨ c₁ ⊕ c₂ ∣ inj₂ y ∣ κ ⟩▷ ↦ ⟨ c₂ ∣ y ∣ c₁ ⊕☐• κ ⟩▷
↦⃗₆ : ∀ {A B C D} {c₁ : A ↔ B} {c₂ : C ↔ D} {x : ⟦ A ⟧} {y : ⟦ C ⟧} {κ : Context}
→ ⟨ c₁ ⊗ c₂ ∣ (x , y) ∣ κ ⟩▷ ↦ ⟨ c₁ ∣ x ∣ ☐⊗[ c₂ , y ]• κ ⟩▷
↦⃗₇ : ∀ {A B C} {c₁ : A ↔ B} {c₂ : B ↔ C} {v : ⟦ B ⟧} {κ : Context}
→ [ c₁ ∣ v ∣ ☐⨾ c₂ • κ ]▷ ↦ ⟨ c₂ ∣ v ∣ (c₁ ⨾☐• κ) ⟩▷
↦⃗₈ : ∀ {A B C D} {c₁ : A ↔ B} {c₂ : C ↔ D} {x : ⟦ B ⟧} {y : ⟦ C ⟧} {κ : Context}
→ [ c₁ ∣ x ∣ ☐⊗[ c₂ , y ]• κ ]▷ ↦ ⟨ c₂ ∣ y ∣ [ c₁ , x ]⊗☐• κ ⟩▷
↦⃗₉ : ∀ {A B C D} {c₁ : A ↔ B} {c₂ : C ↔ D} {x : ⟦ B ⟧} {y : ⟦ D ⟧} {κ : Context}
→ [ c₂ ∣ y ∣ [ c₁ , x ]⊗☐• κ ]▷ ↦ [ c₁ ⊗ c₂ ∣ (x , y) ∣ κ ]▷
↦⃗₁₀ : ∀ {A B C} {c₁ : A ↔ B} {c₂ : B ↔ C} {v : ⟦ C ⟧} {κ : Context}
→ [ c₂ ∣ v ∣ (c₁ ⨾☐• κ) ]▷ ↦ [ c₁ ⨾ c₂ ∣ v ∣ κ ]▷
↦⃗₁₁ : ∀ {A B C D} {c₁ : A ↔ B} {c₂ : C ↔ D} {x : ⟦ B ⟧} {κ : Context}
→ [ c₁ ∣ x ∣ ☐⊕ c₂ • κ ]▷ ↦ [ c₁ ⊕ c₂ ∣ inj₁ x ∣ κ ]▷
↦⃗₁₂ : ∀ {A B C D} {c₁ : A ↔ B} {c₂ : C ↔ D} {y : ⟦ D ⟧} {κ : Context}
→ [ c₂ ∣ y ∣ c₁ ⊕☐• κ ]▷ ↦ [ c₁ ⊕ c₂ ∣ inj₂ y ∣ κ ]▷
↦⃖₁ : ∀ {A B} {c : A ↔ B} {b : base c} {v : ⟦ A ⟧} {κ : Context}
→ [ c ∣ δ c {b} v ∣ κ ]◁ ↦ ⟨ c ∣ v ∣ κ ⟩◁
↦⃖₂ : ∀ {A} {v : ⟦ A ⟧} {κ : Context} → [ id↔ ∣ v ∣ κ ]◁ ↦ ⟨ id↔ ∣ v ∣ κ ⟩◁
↦⃖₃ : ∀ {A B C} {c₁ : A ↔ B} {c₂ : B ↔ C} {v : ⟦ A ⟧} {κ : Context}
→ ⟨ c₁ ∣ v ∣ ☐⨾ c₂ • κ ⟩◁ ↦ ⟨ c₁ ⨾ c₂ ∣ v ∣ κ ⟩◁
↦⃖₄ : ∀ {A B C D} {c₁ : A ↔ B} {c₂ : C ↔ D} {x : ⟦ A ⟧} {κ : Context}
→ ⟨ c₁ ∣ x ∣ ☐⊕ c₂ • κ ⟩◁ ↦ ⟨ c₁ ⊕ c₂ ∣ inj₁ x ∣ κ ⟩◁
↦⃖₅ : ∀ {A B C D} {c₁ : A ↔ B} {c₂ : C ↔ D} {y : ⟦ C ⟧} {κ : Context}
→ ⟨ c₂ ∣ y ∣ c₁ ⊕☐• κ ⟩◁ ↦ ⟨ c₁ ⊕ c₂ ∣ inj₂ y ∣ κ ⟩◁
↦⃖₆ : ∀ {A B C D} {c₁ : A ↔ B} {c₂ : C ↔ D} {x : ⟦ A ⟧} {y : ⟦ C ⟧} {κ : Context}
→ ⟨ c₁ ∣ x ∣ ☐⊗[ c₂ , y ]• κ ⟩◁ ↦ ⟨ c₁ ⊗ c₂ ∣ (x , y) ∣ κ ⟩◁
↦⃖₇ : ∀ {A B C} {c₁ : A ↔ B} {c₂ : B ↔ C} {v : ⟦ B ⟧} {κ : Context}
→ ⟨ c₂ ∣ v ∣ (c₁ ⨾☐• κ) ⟩◁ ↦ [ c₁ ∣ v ∣ ☐⨾ c₂ • κ ]◁
↦⃖₈ : ∀ {A B C D} {c₁ : A ↔ B} {c₂ : C ↔ D} {x : ⟦ B ⟧} {y : ⟦ C ⟧} {κ : Context}
→ ⟨ c₂ ∣ y ∣ [ c₁ , x ]⊗☐• κ ⟩◁ ↦ [ c₁ ∣ x ∣ ☐⊗[ c₂ , y ]• κ ]◁
↦⃖₉ : ∀ {A B C D} {c₁ : A ↔ B} {c₂ : C ↔ D} {x : ⟦ B ⟧} {y : ⟦ D ⟧} {κ : Context}
→ [ c₁ ⊗ c₂ ∣ (x , y) ∣ κ ]◁ ↦ [ c₂ ∣ y ∣ [ c₁ , x ]⊗☐• κ ]◁
↦⃖₁₀ : ∀ {A B C} {c₁ : A ↔ B} {c₂ : B ↔ C} {v : ⟦ C ⟧} {κ : Context}
→ [ c₁ ⨾ c₂ ∣ v ∣ κ ]◁ ↦ [ c₂ ∣ v ∣ (c₁ ⨾☐• κ) ]◁
↦⃖₁₁ : ∀ {A B C D} {c₁ : A ↔ B} {c₂ : C ↔ D} {x : ⟦ B ⟧} {κ : Context}
→ [ c₁ ⊕ c₂ ∣ inj₁ x ∣ κ ]◁ ↦ [ c₁ ∣ x ∣ ☐⊕ c₂ • κ ]◁
↦⃖₁₂ : ∀ {A B C D} {c₁ : A ↔ B} {c₂ : C ↔ D} {y : ⟦ D ⟧} {κ : Context}
→ [ c₁ ⊕ c₂ ∣ inj₂ y ∣ κ ]◁ ↦ [ c₂ ∣ y ∣ c₁ ⊕☐• κ ]◁
↦η₊₁ : ∀ {A} {v : ⟦ A ⟧} {κ : Context} → [ η₊ ∣ inj₁ v ∣ κ ]◁ ↦ [ η₊ ∣ inj₂ (- v) ∣ κ ]▷
↦η₊₂ : ∀ {A} {v : ⟦ A ⟧} {κ : Context} → [ η₊ ∣ inj₂ (- v) ∣ κ ]◁ ↦ [ η₊ ∣ inj₁ v ∣ κ ]▷
↦ε₊₁ : ∀ {A} {v : ⟦ A ⟧} {κ : Context} → ⟨ ε₊ ∣ inj₁ v ∣ κ ⟩▷ ↦ ⟨ ε₊ ∣ inj₂ (- v) ∣ κ ⟩◁
↦ε₊₂ : ∀ {A} {v : ⟦ A ⟧} {κ : Context} → ⟨ ε₊ ∣ inj₂ (- v) ∣ κ ⟩▷ ↦ ⟨ ε₊ ∣ inj₁ v ∣ κ ⟩◁
↦⃗ηₓ : ∀ {A} {v : ⟦ A ⟧} {κ : Context} → ⟨ ηₓ v ∣ tt ∣ κ ⟩▷ ↦ [ ηₓ v ∣ (v , ↻) ∣ κ ]▷
↦⃖ηₓ₁ : ∀ {A} {v v' : ⟦ A ⟧} {κ : Context} {eq : v ≡ v'} → [ ηₓ v ∣ (v' , ↻) ∣ κ ]◁ ↦ ⟨ ηₓ v ∣ tt ∣ κ ⟩◁
↦⃖ηₓ₂ : ∀ {A} {v v' : ⟦ A ⟧} {κ : Context} {neq : v ≢ v'} → [ ηₓ v ∣ (v' , ↻) ∣ κ ]◁ ↦ ⊠
↦⃗εₓ₁ : ∀ {A} {v v' : ⟦ A ⟧} {κ : Context} {eq : v ≡ v'} → ⟨ εₓ v ∣ (v' , ↻) ∣ κ ⟩▷ ↦ [ εₓ v ∣ tt ∣ κ ]▷
↦⃗εₓ₂ : ∀ {A} {v v' : ⟦ A ⟧} {κ : Context} {neq : v ≢ v'} → ⟨ εₓ v ∣ (v' , ↻) ∣ κ ⟩▷ ↦ ⊠
↦⃖εₓ : ∀ {A} {v : ⟦ A ⟧} {κ : Context} → [ εₓ v ∣ tt ∣ κ ]◁ ↦ ⟨ εₓ v ∣ (v , ↻) ∣ κ ⟩◁
| {
"alphanum_fraction": 0.4041776771,
"avg_line_length": 44.15,
"ext": "agda",
"hexsha": "5d6a5bcfa2c408449c6abe305e2d9eb4dd51aaf1",
"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": "PiQ/Opsem.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": "PiQ/Opsem.agda",
"max_line_length": 107,
"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": "PiQ/Opsem.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": 4867,
"size": 7947
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.