Search is not available for this dataset
text
string | meta
dict |
---|---|
module ModuleInstInLet where
data Nat : Set where
zero : Nat
suc : Nat -> Nat
module List (Elem : Set) where
data List : Set where
[] : List
_::_ : Elem -> List -> List
xs : let open List Nat
in List
xs = List._::_ zero List.[]
|
{
"alphanum_fraction": 0.5875486381,
"avg_line_length": 14.2777777778,
"ext": "agda",
"hexsha": "762c6f7e998fc3544d4e68552df4109dc04ae88a",
"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/ModuleInstInLet.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/ModuleInstInLet.agda",
"max_line_length": 31,
"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/ModuleInstInLet.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": 81,
"size": 257
}
|
{-# OPTIONS --no-termination-check #-}
-- TODO: switch the termination checker back on.
open import Coinduction using ( ∞ ; ♭ ; ♯_ )
open import Data.Bool using ( Bool ; true ; false )
open import Data.Maybe using ( Maybe ; just ; nothing )
open import Data.Sum using ( _⊎_ ; inj₁ ; inj₂ )
open import Data.Product using ( ∃ ; _,_ )
open import Data.ByteString using ( ByteString ; strict ; null )
open import System.IO using ( IO ; Command ; return ; _>>_ ; _>>=_ ; skip ; getBytes ; putBytes ; commit )
open import System.IO.Transducers.Lazy using ( _⇒_ ; _⤇_ ; inp ; out ; done ; ι⁻¹ )
open import System.IO.Transducers.Session using ( I ; Σ ; Bytes )
open import System.IO.Transducers.Strict using ( _⇛_ )
module System.IO.Transducers.IO where
infixl 5 _$_
postulate
IOError : Set
_catch_ : ∀ {A} → (IO A) → (IOError → (IO A)) → (IO A)
{-# COMPILED_TYPE IOError IOError #-}
{-# COMPILED _catch_ (\ _ -> catch) #-}
_$_ : ∀ {A V F T} → (Σ {A} V F ⤇ T) → (a : A) → (♭ F a ⤇ T)
inp P $ a = ♭ P a
out b P $ a = out b (P $ a)
getBytes? : IO (Maybe (ByteString strict))
getBytes? = (getBytes >>= λ x → return (just x)) catch (λ e → return nothing)
runI : (I ⤇ Bytes) → Command
runI (out true (out x P)) = putBytes x >> commit >> runI P
runI (out false P) = skip
mutual
run? : (Bytes ⤇ Bytes) → (Maybe (ByteString strict)) → Command
run? P (just b) = run' (P $ true $ b)
run? P nothing = runI (P $ false)
run' : (Bytes ⤇ Bytes) → Command
run' (out true (out b P)) = putBytes b >> commit >> run' P
run' (out false P) = skip
run' P = getBytes? >>= run? P
run : (Bytes ⇒ Bytes) → Command
run P = run' (ι⁻¹ P)
|
{
"alphanum_fraction": 0.6028794241,
"avg_line_length": 34.0204081633,
"ext": "agda",
"hexsha": "c7821d378f1a71faf459edc174b7a8a921838d12",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:23.000Z",
"max_forks_repo_forks_event_min_datetime": "2017-08-10T06:12:54.000Z",
"max_forks_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "ilya-fiveisky/agda-system-io",
"max_forks_repo_path": "src/System/IO/Transducers/IO.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "ilya-fiveisky/agda-system-io",
"max_issues_repo_path": "src/System/IO/Transducers/IO.agda",
"max_line_length": 106,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "ilya-fiveisky/agda-system-io",
"max_stars_repo_path": "src/System/IO/Transducers/IO.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-15T04:35:41.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-04T13:45:16.000Z",
"num_tokens": 551,
"size": 1667
}
|
{-# OPTIONS --without-K --safe #-}
module EqBool where
open import Data.Bool
record HasEqBool {a} (A : Set a) : Set a where
field _==_ : A → A → Bool
open HasEqBool ⦃ ... ⦄ public
open import Data.List as List using (List; _∷_; [])
==[] : ∀ {a} {A : Set a} → ⦃ _ : HasEqBool A ⦄ → List A → List A → Bool
==[] [] [] = true
==[] [] (x ∷ ys) = false
==[] (x ∷ xs) [] = false
==[] (x ∷ xs) (y ∷ ys) = x == y ∧ ==[] xs ys
instance
eqList : ∀ {a} {A : Set a} → ⦃ _ : HasEqBool A ⦄ → HasEqBool (List A)
_==_ ⦃ eqList ⦄ = ==[]
open import Data.Nat using (ℕ)
instance
eqNat : HasEqBool ℕ
_==_ ⦃ eqNat ⦄ = Agda.Builtin.Nat._==_
where import Agda.Builtin.Nat
instance
eqBool : HasEqBool Bool
_==_ ⦃ eqBool ⦄ false false = true
_==_ ⦃ eqBool ⦄ false true = false
_==_ ⦃ eqBool ⦄ true y = y
open import Data.String using (String)
instance
eqString : HasEqBool String
_==_ ⦃ eqString ⦄ = Data.String._==_
where import Data.String
|
{
"alphanum_fraction": 0.5763598326,
"avg_line_length": 23.3170731707,
"ext": "agda",
"hexsha": "dc9f62b9b6332c460a849770f5ace82345194cf6",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2022-01-20T07:07:11.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-04-16T02:23:16.000Z",
"max_forks_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mckeankylej/agda-ring-solver",
"max_forks_repo_path": "src/EqBool.agda",
"max_issues_count": 5,
"max_issues_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500",
"max_issues_repo_issues_event_max_datetime": "2022-03-12T01:55:42.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-17T20:48:48.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "mckeankylej/agda-ring-solver",
"max_issues_repo_path": "src/EqBool.agda",
"max_line_length": 71,
"max_stars_count": 36,
"max_stars_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mckeankylej/agda-ring-solver",
"max_stars_repo_path": "src/EqBool.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-15T00:57:55.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-01-25T16:40:52.000Z",
"num_tokens": 377,
"size": 956
}
|
module L0 where
open import Common
-- Syntax
data Name : Set where
d n j m : Name
data Pred1 : Set where
M B : Pred1
data Pred2 : Set where
K L : Pred2
data Expr : Set where
_⦅_⦆ : Pred1 -> Name -> Expr
_⦅_,_⦆ : Pred2 -> Name -> Name -> Expr
¬ : Expr -> Expr
[_∧_] : Expr -> Expr -> Expr
[_∨_] : Expr -> Expr -> Expr
[_⇒_] : Expr -> Expr -> Expr
[_⇔_] : Expr -> Expr -> Expr
example1 : Expr
example1 = [ K ⦅ d , j ⦆ ∧ M ⦅ d ⦆ ]
example2 : Expr
example2 = ¬ [ M ⦅ d ⦆ ∨ B ⦅ m ⦆ ]
example3 : Expr
example3 = [ L ⦅ n , j ⦆ ⇒ [ B ⦅ d ⦆ ∨ ¬ (K ⦅ m , m ⦆) ] ]
example4 : Expr
example4 = [ ¬ (¬ (¬ (B ⦅ n ⦆))) ⇔ ¬ (M ⦅ n ⦆) ]
-- Semantics
data Person : Set where
Richard_Nixon : Person
Noam_Chomsky : Person
John_Mitchell : Person
Muhammad_Ali : Person
instance
eqPerson : Eq Person
-- _==_ ⦃ eqPerson ⦄ x y = isEq x y (refl {!x y!})
_==_ ⦃ eqPerson ⦄ Richard_Nixon Richard_Nixon = true
_==_ ⦃ eqPerson ⦄ Noam_Chomsky Noam_Chomsky = true
_==_ ⦃ eqPerson ⦄ John_Mitchell John_Mitchell = true
_==_ ⦃ eqPerson ⦄ Muhammad_Ali Muhammad_Ali = true
_==_ ⦃ eqPerson ⦄ _ _ = false
_∈_ : {A : Set} {{_ : Eq A}} -> A -> PSet A -> Bool
x ∈ ⦃⦄ = false
x ∈ (x₁ :: xs) = (x == x₁) || (x ∈ xs)
⟦_⟧ₙ : Name -> Person
⟦ d ⟧ₙ = Richard_Nixon
⟦ n ⟧ₙ = Noam_Chomsky
⟦ j ⟧ₙ = John_Mitchell
⟦ m ⟧ₙ = Muhammad_Ali
⟦_⟧ₚ₁ : Pred1 -> PSet Person
⟦ x ⟧ₚ₁ = {!!}
⟦_⟧ₚ₂ : Pred2 -> PSet (Pair Person)
⟦ x ⟧ₚ₂ = {!!}
⟦_⟧ₑ : Expr -> Bool
{-# TERMINATING #-}
⟦ x ⦅ x₁ ⦆ ⟧ₑ = ⟦ x₁ ⟧ₙ ∈ ⟦ x ⟧ₚ₁
⟦ x ⦅ x₁ , x₂ ⦆ ⟧ₑ = < ⟦ x₁ ⟧ₙ , ⟦ x₂ ⟧ₙ > ∈ ⟦ x ⟧ₚ₂
⟦ ¬ x ⟧ₑ = neg ⟦ x ⟧ₑ
⟦ [ x ∧ x₁ ] ⟧ₑ = ⟦ x ⟧ₑ && ⟦ x₁ ⟧ₑ
⟦ [ x ∨ x₁ ] ⟧ₑ = ⟦ x ⟧ₑ || ⟦ x₁ ⟧ₑ
⟦ [ x ⇒ x₁ ] ⟧ₑ = (neg ⟦ x₁ ⟧ₑ) || ⟦ x ⟧ₑ
⟦ [ x ⇔ x₁ ] ⟧ₑ = ⟦ [ x ⇒ x₁ ] ⟧ₑ && ⟦ [ x₁ ⇒ x ] ⟧ₑ
|
{
"alphanum_fraction": 0.5094124358,
"avg_line_length": 23.0657894737,
"ext": "agda",
"hexsha": "4ba72218cc306d19d228f9e58c768fbafee358c8",
"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": "9f8bbff7248dbeb54919e03957daf9b35ec1ac23",
"max_forks_repo_licenses": [
"Artistic-2.0"
],
"max_forks_repo_name": "daherb/Agda-Montague",
"max_forks_repo_path": "L0.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9f8bbff7248dbeb54919e03957daf9b35ec1ac23",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Artistic-2.0"
],
"max_issues_repo_name": "daherb/Agda-Montague",
"max_issues_repo_path": "L0.agda",
"max_line_length": 58,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "9f8bbff7248dbeb54919e03957daf9b35ec1ac23",
"max_stars_repo_licenses": [
"Artistic-2.0"
],
"max_stars_repo_name": "daherb/Agda-Montague",
"max_stars_repo_path": "L0.agda",
"max_stars_repo_stars_event_max_datetime": "2020-12-18T11:56:24.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-12-18T11:56:24.000Z",
"num_tokens": 906,
"size": 1753
}
|
{-# OPTIONS --cubical --safe --postfix-projections #-}
open import Prelude
open import Relation.Binary
module Relation.Binary.Construct.Bounded {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
data [∙] : Type e where
[⊥] [⊤] : [∙]
[_] : E → [∙]
_[≤]_ : [∙] → [∙] → Type _
[⊥] [≤] _ = Poly.⊤
_ [≤] [⊤] = Poly.⊤
[⊤] [≤] _ = Poly.⊥
_ [≤] [⊥] = Poly.⊥
[ x ] [≤] [ y ] = x ≤ y
_[<]_ : [∙] → [∙] → Type _
[⊤] [<] _ = Poly.⊥
_ [<] [⊥] = Poly.⊥
[⊥] [<] _ = Poly.⊤
_ [<] [⊤] = Poly.⊤
[ x ] [<] [ y ] = x < y
b-pord : PartialOrder [∙] _
b-pord .PartialOrder.preorder .Preorder._≤_ = _[≤]_
b-pord .PartialOrder.preorder .Preorder.refl {[⊥]} = Poly.tt
b-pord .PartialOrder.preorder .Preorder.refl {[⊤]} = Poly.tt
b-pord .PartialOrder.preorder .Preorder.refl {[ x ]} = ≤-refl
b-pord .PartialOrder.preorder .Preorder.trans {[⊥]} {y} {z} x≤y y≤z = Poly.tt
b-pord .PartialOrder.preorder .Preorder.trans {[⊤]} {[⊤]} {[⊤]} x≤y y≤z = Poly.tt
b-pord .PartialOrder.preorder .Preorder.trans {[ x ]} {[⊤]} {[⊤]} x≤y y≤z = Poly.tt
b-pord .PartialOrder.preorder .Preorder.trans {[ x ]} {[ y ]} {[⊤]} x≤y y≤z = Poly.tt
b-pord .PartialOrder.preorder .Preorder.trans {[ x ]} {[ y ]} {[ z ]} x≤y y≤z = ≤-trans x≤y y≤z
b-pord .PartialOrder.antisym {[⊥]} {[⊥]} x≤y y≤x i = [⊥]
b-pord .PartialOrder.antisym {[⊤]} {[⊤]} x≤y y≤x i = [⊤]
b-pord .PartialOrder.antisym {[ x ]} {[ y ]} x≤y y≤x i = [ antisym x≤y y≤x i ]
b-sord : StrictPartialOrder [∙] _
b-sord .StrictPartialOrder.strictPreorder .StrictPreorder._<_ = _[<]_
b-sord .StrictPartialOrder.strictPreorder .StrictPreorder.trans {[⊥]} {[ x ]} {[⊤]} x<y y<z = Poly.tt
b-sord .StrictPartialOrder.strictPreorder .StrictPreorder.trans {[⊥]} {[ x ]} {[ x₁ ]} x<y y<z = Poly.tt
b-sord .StrictPartialOrder.strictPreorder .StrictPreorder.trans {[ x ]} {[ x₁ ]} {[⊤]} x<y y<z = Poly.tt
b-sord .StrictPartialOrder.strictPreorder .StrictPreorder.trans {[ x ]} {[ x₁ ]} {[ x₂ ]} x<y y<z = <-trans x<y y<z
b-sord .StrictPartialOrder.strictPreorder .StrictPreorder.irrefl {[ x ]} x<x = irrefl x<x
b-sord .StrictPartialOrder.conn {[⊥]} {[⊥]} x≮y y≮x = refl
b-sord .StrictPartialOrder.conn {[⊥]} {[⊤]} x≮y y≮x = ⊥-elim (x≮y Poly.tt)
b-sord .StrictPartialOrder.conn {[⊥]} {[ x ]} x≮y y≮x = ⊥-elim (x≮y Poly.tt)
b-sord .StrictPartialOrder.conn {[⊤]} {[⊥]} x≮y y≮x = ⊥-elim (y≮x Poly.tt)
b-sord .StrictPartialOrder.conn {[⊤]} {[⊤]} x≮y y≮x = refl
b-sord .StrictPartialOrder.conn {[⊤]} {[ x ]} x≮y y≮x = ⊥-elim (y≮x Poly.tt)
b-sord .StrictPartialOrder.conn {[ x ]} {[⊥]} x≮y y≮x = ⊥-elim (y≮x Poly.tt)
b-sord .StrictPartialOrder.conn {[ x ]} {[⊤]} x≮y y≮x = ⊥-elim (x≮y Poly.tt)
b-sord .StrictPartialOrder.conn {[ x ]} {[ x₁ ]} x≮y y≮x = cong [_] (conn x≮y y≮x)
b-ord : TotalOrder [∙] _ _
b-ord .TotalOrder.strictPartialOrder = b-sord
b-ord .TotalOrder.partialOrder = b-pord
b-ord .TotalOrder._<?_ [⊥] [⊥] = no λ ()
b-ord .TotalOrder._<?_ [⊥] [⊤] = yes _
b-ord .TotalOrder._<?_ [⊥] [ y ] = yes _
b-ord .TotalOrder._<?_ [⊤] [⊥] = no λ ()
b-ord .TotalOrder._<?_ [⊤] [⊤] = no λ ()
b-ord .TotalOrder._<?_ [⊤] [ y ] = no λ ()
b-ord .TotalOrder._<?_ [ x ] [⊥] = no λ ()
b-ord .TotalOrder._<?_ [ x ] [⊤] = yes _
b-ord .TotalOrder._<?_ [ x ] [ y ] = x <? y
b-ord .TotalOrder.≰⇒> {[⊥]} {y} x≰y = ⊥-elim (x≰y Poly.tt)
b-ord .TotalOrder.≰⇒> {[⊤]} {[⊥]} x≰y = Poly.tt
b-ord .TotalOrder.≰⇒> {[⊤]} {[⊤]} x≰y = ⊥-elim (x≰y Poly.tt)
b-ord .TotalOrder.≰⇒> {[⊤]} {[ x ]} x≰y = Poly.tt
b-ord .TotalOrder.≰⇒> {[ x ]} {[⊥]} x≰y = Poly.tt
b-ord .TotalOrder.≰⇒> {[ x ]} {[⊤]} x≰y = ⊥-elim (x≰y Poly.tt)
b-ord .TotalOrder.≰⇒> {[ x ]} {[ x₁ ]} x≰y = ≰⇒> x≰y
b-ord .TotalOrder.≮⇒≥ {x} {[⊥]} x≮y = Poly.tt
b-ord .TotalOrder.≮⇒≥ {[⊥]} {[⊤]} x≮y = ⊥-elim (x≮y Poly.tt)
b-ord .TotalOrder.≮⇒≥ {[⊤]} {[⊤]} x≮y = Poly.tt
b-ord .TotalOrder.≮⇒≥ {[ x ]} {[⊤]} x≮y = ⊥-elim (x≮y Poly.tt)
b-ord .TotalOrder.≮⇒≥ {[⊥]} {[ x₁ ]} x≮y = ⊥-elim (x≮y Poly.tt)
b-ord .TotalOrder.≮⇒≥ {[⊤]} {[ x₁ ]} x≮y = Poly.tt
b-ord .TotalOrder.≮⇒≥ {[ x ]} {[ y ]} x≮y = ≮⇒≥ x≮y
|
{
"alphanum_fraction": 0.5572463768,
"avg_line_length": 47.5862068966,
"ext": "agda",
"hexsha": "8f7a5ee460d17f6b99c433b2d364ffe6cd0908cc",
"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/Bounded.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/Bounded.agda",
"max_line_length": 115,
"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/Bounded.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": 2023,
"size": 4140
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Lexicographic ordering of lists
------------------------------------------------------------------------
-- The definitions of lexicographic ordering used here are suitable if
-- the argument order is a strict partial order.
{-# OPTIONS --without-K --safe #-}
module Data.List.Relation.Binary.Lex.Strict where
open import Data.Empty using (⊥)
open import Data.Unit.Base using (⊤; tt)
open import Function using (_∘_; id)
open import Data.Product using (_,_)
open import Data.Sum using (inj₁; inj₂)
open import Data.List.Base using (List; []; _∷_)
open import Level using (_⊔_)
open import Relation.Nullary using (yes; no; ¬_)
open import Relation.Binary
open import Relation.Binary.Consequences
open import Data.List.Relation.Binary.Pointwise as Pointwise
using (Pointwise; []; _∷_; head; tail)
open import Data.List.Relation.Binary.Lex.Core as Core public
using (base; halt; this; next; ²-this; ²-next)
----------------------------------------------------------------------
-- Strict lexicographic ordering.
module _ {a ℓ₁ ℓ₂} {A : Set a} where
Lex-< : (_≈_ : Rel A ℓ₁) (_≺_ : Rel A ℓ₂) →
Rel (List A) (a ⊔ ℓ₁ ⊔ ℓ₂)
Lex-< = Core.Lex ⊥
-- Properties
module _ {_≈_ : Rel A ℓ₁} {_≺_ : Rel A ℓ₂} where
private
_≋_ = Pointwise _≈_
_<_ = Lex-< _≈_ _≺_
¬[]<[] : ¬ [] < []
¬[]<[] (base ())
<-irreflexive : Irreflexive _≈_ _≺_ → Irreflexive _≋_ _<_
<-irreflexive irr [] (base ())
<-irreflexive irr (x≈y ∷ xs≋ys) (this x<y) = irr x≈y x<y
<-irreflexive irr (x≈y ∷ xs≋ys) (next _ xs⊴ys) =
<-irreflexive irr xs≋ys xs⊴ys
<-asymmetric : Symmetric _≈_ → _≺_ Respects₂ _≈_ → Asymmetric _≺_ →
Asymmetric _<_
<-asymmetric sym resp as = asym
where
irrefl : Irreflexive _≈_ _≺_
irrefl = asym⟶irr resp sym as
asym : Asymmetric _<_
asym (halt) ()
asym (base bot) _ = bot
asym (this x<y) (this y<x) = as x<y y<x
asym (this x<y) (next y≈x ys⊴xs) = irrefl (sym y≈x) x<y
asym (next x≈y xs⊴ys) (this y<x) = irrefl (sym x≈y) y<x
asym (next x≈y xs⊴ys) (next y≈x ys⊴xs) = asym xs⊴ys ys⊴xs
<-antisymmetric : Symmetric _≈_ → Irreflexive _≈_ _≺_ →
Asymmetric _≺_ → Antisymmetric _≋_ _<_
<-antisymmetric = Core.antisymmetric
<-transitive : IsEquivalence _≈_ → _≺_ Respects₂ _≈_ →
Transitive _≺_ → Transitive _<_
<-transitive = Core.transitive
<-compare : Symmetric _≈_ → Trichotomous _≈_ _≺_ →
Trichotomous _≋_ _<_
<-compare sym tri [] [] = tri≈ ¬[]<[] [] ¬[]<[]
<-compare sym tri [] (y ∷ ys) = tri< halt (λ()) (λ())
<-compare sym tri (x ∷ xs) [] = tri> (λ()) (λ()) halt
<-compare sym tri (x ∷ xs) (y ∷ ys) with tri x y
... | tri< x<y x≉y y≮x =
tri< (this x<y) (x≉y ∘ head) (¬≤-this (x≉y ∘ sym) y≮x)
... | tri> x≮y x≉y y<x =
tri> (¬≤-this x≉y x≮y) (x≉y ∘ head) (this y<x)
... | tri≈ x≮y x≈y y≮x with <-compare sym tri xs ys
... | tri< xs<ys xs≉ys ys≮xs =
tri< (next x≈y xs<ys) (xs≉ys ∘ tail) (¬≤-next y≮x ys≮xs)
... | tri≈ xs≮ys xs≈ys ys≮xs =
tri≈ (¬≤-next x≮y xs≮ys) (x≈y ∷ xs≈ys) (¬≤-next y≮x ys≮xs)
... | tri> xs≮ys xs≉ys ys<xs =
tri> (¬≤-next x≮y xs≮ys) (xs≉ys ∘ tail) (next (sym x≈y) ys<xs)
<-decidable : Decidable _≈_ → Decidable _≺_ → Decidable _<_
<-decidable = Core.decidable (no id)
<-respects₂ : IsEquivalence _≈_ → _≺_ Respects₂ _≈_ →
_<_ Respects₂ _≋_
<-respects₂ = Core.respects₂
<-isStrictPartialOrder : IsStrictPartialOrder _≈_ _≺_ →
IsStrictPartialOrder _≋_ _<_
<-isStrictPartialOrder spo = record
{ isEquivalence = Pointwise.isEquivalence isEquivalence
; irrefl = <-irreflexive irrefl
; trans = Core.transitive isEquivalence <-resp-≈ trans
; <-resp-≈ = Core.respects₂ isEquivalence <-resp-≈
} where open IsStrictPartialOrder spo
<-isStrictTotalOrder : IsStrictTotalOrder _≈_ _≺_ →
IsStrictTotalOrder _≋_ _<_
<-isStrictTotalOrder sto = record
{ isEquivalence = Pointwise.isEquivalence isEquivalence
; trans = <-transitive isEquivalence <-resp-≈ trans
; compare = <-compare Eq.sym compare
} where open IsStrictTotalOrder sto
<-strictPartialOrder : ∀ {a ℓ₁ ℓ₂} → StrictPartialOrder a ℓ₁ ℓ₂ →
StrictPartialOrder _ _ _
<-strictPartialOrder spo = record
{ isStrictPartialOrder = <-isStrictPartialOrder isStrictPartialOrder
} where open StrictPartialOrder spo
<-strictTotalOrder : ∀ {a ℓ₁ ℓ₂} → StrictTotalOrder a ℓ₁ ℓ₂ →
StrictTotalOrder _ _ _
<-strictTotalOrder sto = record
{ isStrictTotalOrder = <-isStrictTotalOrder isStrictTotalOrder
} where open StrictTotalOrder sto
----------------------------------------------------------------------
-- Non-strict lexicographic ordering.
module _ {a ℓ₁ ℓ₂} {A : Set a} where
Lex-≤ : (_≈_ : Rel A ℓ₁) (_≺_ : Rel A ℓ₂) →
Rel (List A) (a ⊔ ℓ₁ ⊔ ℓ₂)
Lex-≤ = Core.Lex ⊤
-- Properties
≤-reflexive : (_≈_ : Rel A ℓ₁) (_≺_ : Rel A ℓ₂) →
Pointwise _≈_ ⇒ Lex-≤ _≈_ _≺_
≤-reflexive _≈_ _≺_ [] = base tt
≤-reflexive _≈_ _≺_ (x≈y ∷ xs≈ys) =
next x≈y (≤-reflexive _≈_ _≺_ xs≈ys)
module _ {_≈_ : Rel A ℓ₁} {_≺_ : Rel A ℓ₂} where
private
_≋_ = Pointwise _≈_
_≤_ = Lex-≤ _≈_ _≺_
≤-antisymmetric : Symmetric _≈_ → Irreflexive _≈_ _≺_ →
Asymmetric _≺_ → Antisymmetric _≋_ _≤_
≤-antisymmetric = Core.antisymmetric
≤-transitive : IsEquivalence _≈_ → _≺_ Respects₂ _≈_ →
Transitive _≺_ → Transitive _≤_
≤-transitive = Core.transitive
-- Note that trichotomy is an unnecessarily strong precondition for
-- the following lemma.
≤-total : Symmetric _≈_ → Trichotomous _≈_ _≺_ → Total _≤_
≤-total _ _ [] [] = inj₁ (base tt)
≤-total _ _ [] (x ∷ xs) = inj₁ halt
≤-total _ _ (x ∷ xs) [] = inj₂ halt
≤-total sym tri (x ∷ xs) (y ∷ ys) with tri x y
... | tri< x<y _ _ = inj₁ (this x<y)
... | tri> _ _ y<x = inj₂ (this y<x)
... | tri≈ _ x≈y _ with ≤-total sym tri xs ys
... | inj₁ xs≲ys = inj₁ (next x≈y xs≲ys)
... | inj₂ ys≲xs = inj₂ (next (sym x≈y) ys≲xs)
≤-decidable : Decidable _≈_ → Decidable _≺_ → Decidable _≤_
≤-decidable = Core.decidable (yes tt)
≤-respects₂ : IsEquivalence _≈_ → _≺_ Respects₂ _≈_ →
_≤_ Respects₂ _≋_
≤-respects₂ = Core.respects₂
≤-isPreorder : IsEquivalence _≈_ → Transitive _≺_ →
_≺_ Respects₂ _≈_ → IsPreorder _≋_ _≤_
≤-isPreorder eq tr resp = record
{ isEquivalence = Pointwise.isEquivalence eq
; reflexive = ≤-reflexive _≈_ _≺_
; trans = Core.transitive eq resp tr
}
≤-isPartialOrder : IsStrictPartialOrder _≈_ _≺_ →
IsPartialOrder _≋_ _≤_
≤-isPartialOrder spo = record
{ isPreorder = ≤-isPreorder isEquivalence trans <-resp-≈
; antisym = Core.antisymmetric Eq.sym irrefl asym
}
where open IsStrictPartialOrder spo
≤-isTotalOrder : IsStrictTotalOrder _≈_ _≺_ → IsTotalOrder _≋_ _≤_
≤-isTotalOrder sto = record
{ isPartialOrder = ≤-isPartialOrder isStrictPartialOrder
; total = ≤-total Eq.sym compare
}
where open IsStrictTotalOrder sto
≤-isDecTotalOrder : IsStrictTotalOrder _≈_ _≺_ →
IsDecTotalOrder _≋_ _≤_
≤-isDecTotalOrder sto = record
{ isTotalOrder = ≤-isTotalOrder sto
; _≟_ = Pointwise.decidable _≟_
; _≤?_ = ≤-decidable _≟_ _<?_
}
where open IsStrictTotalOrder sto
≤-preorder : ∀ {a ℓ₁ ℓ₂} → Preorder a ℓ₁ ℓ₂ → Preorder _ _ _
≤-preorder pre = record
{ isPreorder = ≤-isPreorder isEquivalence trans ∼-resp-≈
} where open Preorder pre
≤-partialOrder : ∀ {a ℓ₁ ℓ₂} → StrictPartialOrder a ℓ₁ ℓ₂ → Poset _ _ _
≤-partialOrder spo = record
{ isPartialOrder = ≤-isPartialOrder isStrictPartialOrder
} where open StrictPartialOrder spo
≤-decTotalOrder : ∀ {a ℓ₁ ℓ₂} → StrictTotalOrder a ℓ₁ ℓ₂ →
DecTotalOrder _ _ _
≤-decTotalOrder sto = record
{ isDecTotalOrder = ≤-isDecTotalOrder isStrictTotalOrder
} where open StrictTotalOrder sto
|
{
"alphanum_fraction": 0.5596287703,
"avg_line_length": 37.1551724138,
"ext": "agda",
"hexsha": "0d1ea08467d38b3bd7ccf7c878af590f4688ca00",
"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/Data/List/Relation/Binary/Lex/Strict.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "omega12345/agda-mode",
"max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Lex/Strict.agda",
"max_line_length": 74,
"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/Data/List/Relation/Binary/Lex/Strict.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3060,
"size": 8620
}
|
{-# OPTIONS --safe #-}
module Cubical.Algebra.CommAlgebra.FreeCommAlgebra.Base where
{-
The free commutative algebra over a commutative ring,
or in other words the ring of polynomials with coefficients in a given ring.
Note that this is a constructive definition, which entails that polynomials
cannot be represented by lists of coefficients, where the last one is non-zero.
For rings with decidable equality, that is still possible.
I learned about this (and other) definition(s) from David Jaz Myers.
You can watch him talk about these things here:
https://www.youtube.com/watch?v=VNp-f_9MnVk
This file contains
* the definition of the free commutative algebra on a type I over a commutative ring R as a HIT
(let us call that R[I])
* a prove that the construction is an commutative R-algebra
* definitions of the induced maps appearing in the universal property of R[I],
that is: * for any map I → A, where A is a commutative R-algebra,
the induced algebra homomorphism R[I] → A
('inducedHom')
* for any hom R[I] → A, the 'restricttion to variables' I → A
('evaluateAt')
* a proof that the two constructions are inverse to each other
('homRetrievable' and 'mapRetrievable')
* a proof, that the corresponding pointwise equivalence of functors is natural
('naturalR', 'naturalL')
-}
open import Cubical.Foundations.Prelude
open import Cubical.Algebra.CommRing
open import Cubical.Algebra.CommAlgebra.Base
private
variable
ℓ ℓ' : Level
module Construction (R : CommRing ℓ) where
open CommRingStr (snd R) using (1r; 0r) renaming (_+_ to _+r_; _·_ to _·r_)
data R[_] (I : Type ℓ') : Type (ℓ-max ℓ ℓ') where
var : I → R[ I ]
const : fst R → R[ I ]
_+_ : R[ I ] → R[ I ] → R[ I ]
-_ : R[ I ] → R[ I ]
_·_ : R[ I ] → R[ I ] → R[ I ] -- \cdot
+-assoc : (x y z : R[ I ]) → x + (y + z) ≡ (x + y) + z
+-rid : (x : R[ I ]) → x + (const 0r) ≡ x
+-rinv : (x : R[ I ]) → x + (- x) ≡ (const 0r)
+-comm : (x y : R[ I ]) → x + y ≡ y + x
·-assoc : (x y z : R[ I ]) → x · (y · z) ≡ (x · y) · z
·-lid : (x : R[ I ]) → (const 1r) · x ≡ x
·-comm : (x y : R[ I ]) → x · y ≡ y · x
ldist : (x y z : R[ I ]) → (x + y) · z ≡ (x · z) + (y · z)
+HomConst : (s t : fst R) → const (s +r t) ≡ const s + const t
·HomConst : (s t : fst R) → const (s ·r t) ≡ (const s) · (const t)
0-trunc : (x y : R[ I ]) (p q : x ≡ y) → p ≡ q
_⋆_ : {I : Type ℓ'} → fst R → R[ I ] → R[ I ]
r ⋆ x = const r · x
⋆-assoc : {I : Type ℓ'} → (s t : fst R) (x : R[ I ]) → (s ·r t) ⋆ x ≡ s ⋆ (t ⋆ x)
⋆-assoc s t x = const (s ·r t) · x ≡⟨ cong (λ u → u · x) (·HomConst _ _) ⟩
(const s · const t) · x ≡⟨ sym (·-assoc _ _ _) ⟩
const s · (const t · x) ≡⟨ refl ⟩
s ⋆ (t ⋆ x) ∎
⋆-ldist-+ : {I : Type ℓ'} → (s t : fst R) (x : R[ I ]) → (s +r t) ⋆ x ≡ (s ⋆ x) + (t ⋆ x)
⋆-ldist-+ s t x = (s +r t) ⋆ x ≡⟨ cong (λ u → u · x) (+HomConst _ _) ⟩
(const s + const t) · x ≡⟨ ldist _ _ _ ⟩
(s ⋆ x) + (t ⋆ x) ∎
⋆-rdist-+ : {I : Type ℓ'} → (s : fst R) (x y : R[ I ]) → s ⋆ (x + y) ≡ (s ⋆ x) + (s ⋆ y)
⋆-rdist-+ s x y = const s · (x + y) ≡⟨ ·-comm _ _ ⟩
(x + y) · const s ≡⟨ ldist _ _ _ ⟩
(x · const s) + (y · const s) ≡⟨ cong (λ u → u + (y · const s)) (·-comm _ _) ⟩
(s ⋆ x) + (y · const s) ≡⟨ cong (λ u → (s ⋆ x) + u) (·-comm _ _) ⟩
(s ⋆ x) + (s ⋆ y) ∎
⋆-assoc-· : {I : Type ℓ'} → (s : fst R) (x y : R[ I ]) → (s ⋆ x) · y ≡ s ⋆ (x · y)
⋆-assoc-· s x y = (s ⋆ x) · y ≡⟨ sym (·-assoc _ _ _) ⟩
s ⋆ (x · y) ∎
0a : {I : Type ℓ'} → R[ I ]
0a = (const 0r)
1a : {I : Type ℓ'} → R[ I ]
1a = (const 1r)
isCommAlgebra : {I : Type ℓ'} → IsCommAlgebra R {A = R[ I ]} 0a 1a _+_ _·_ -_ _⋆_
isCommAlgebra = makeIsCommAlgebra 0-trunc
+-assoc +-rid +-rinv +-comm
·-assoc ·-lid ldist ·-comm
⋆-assoc ⋆-rdist-+ ⋆-ldist-+ ·-lid ⋆-assoc-·
_[_] : (R : CommRing ℓ) (I : Type ℓ') → CommAlgebra R (ℓ-max ℓ ℓ')
(R [ I ]) = R[ I ] , commalgebrastr 0a 1a _+_ _·_ -_ _⋆_ isCommAlgebra
where
open Construction R
|
{
"alphanum_fraction": 0.4858180168,
"avg_line_length": 41.5754716981,
"ext": "agda",
"hexsha": "9c88e4d95d585b6fd45ab8c61801c278adea1c96",
"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/CommAlgebra/FreeCommAlgebra/Base.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "thomas-lamiaux/cubical",
"max_issues_repo_path": "Cubical/Algebra/CommAlgebra/FreeCommAlgebra/Base.agda",
"max_line_length": 98,
"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/CommAlgebra/FreeCommAlgebra/Base.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1752,
"size": 4407
}
|
module Issue256 where
open import Common.Level
const : ∀ {a b} {A : Set a} {B : Set b} → A → B → A
const x = λ _ → x
level : ∀ {ℓ} → Set ℓ → Level
level {ℓ} _ = ℓ
-- termination check should fail for the following definition
ℓ : Level
ℓ = const lzero (Set ℓ)
-- A : Set (lsuc {!ℓ!})
-- A = Set (level A)
|
{
"alphanum_fraction": 0.5903225806,
"avg_line_length": 17.2222222222,
"ext": "agda",
"hexsha": "c98827e0f2961d52a17a82458704c670ae4105cd",
"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/fail/Issue256.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "test/fail/Issue256.agda",
"max_line_length": 61,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "redfish64/autonomic-agda",
"max_stars_repo_path": "test/Fail/Issue256.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": 115,
"size": 310
}
|
module FunctionName where
open import OscarPrelude
record FunctionName : Set
where
constructor ⟨_⟩
field
name : Nat
open FunctionName public
instance EqFunctionName : Eq FunctionName
Eq._==_ EqFunctionName _ = decEq₁ (cong name) ∘ (_≟_ on name $ _)
|
{
"alphanum_fraction": 0.7414448669,
"avg_line_length": 16.4375,
"ext": "agda",
"hexsha": "f8650ee865b21b61f1bd1b82fe796dd58b8747c9",
"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/FunctionName.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/FunctionName.agda",
"max_line_length": 65,
"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/FunctionName.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 76,
"size": 263
}
|
{-# OPTIONS --without-K #-}
open import lib.Basics
open import lib.NConnected
open import lib.NType2
open import lib.cubical.Square
open import lib.types.Lift
open import lib.types.Nat
open import lib.types.Pointed
open import lib.types.Sigma
open import lib.types.TLevel
open import lib.types.Truncation
open import lib.types.Unit
{- Sequential colimits -}
module lib.types.NatColim where
module _ {i} {D : ℕ → Type i} where
private
data #ℕColim-aux (d : (n : ℕ) → D n → D (S n)) : Type i where
#ncin : (n : ℕ) → D n → #ℕColim-aux d
data #ℕColim (d : (n : ℕ) → D n → D (S n)) : Type i where
#ncolim : #ℕColim-aux d → (Unit → Unit) → #ℕColim d
ℕColim : (d : (n : ℕ) → D n → D (S n)) → Type i
ℕColim d = #ℕColim d
ncin : {d : (n : ℕ) → D n → D (S n)} → (n : ℕ) → D n → ℕColim d
ncin n x = #ncolim (#ncin n x) _
postulate -- HIT
ncglue : {d : (n : ℕ) → D n → D (S n)}
(n : ℕ) → (x : D n) → ncin {d = d} n x == ncin (S n) (d n x)
module ℕColimElim (d : (n : ℕ) → D n → D (S n))
{j} {P : ℕColim d → Type j}
(ncin* : (n : ℕ) (x : D n) → P (ncin n x))
(ncglue* : (n : ℕ) (x : D n)
→ ncin* n x == ncin* (S n) (d n x) [ P ↓ ncglue n x ])
where
f : Π (ℕColim d) P
f = f-aux phantom where
f-aux : Phantom ncglue* → Π (ℕColim d) P
f-aux phantom (#ncolim (#ncin n x) _) = ncin* n x
postulate -- HIT
ncglue-β : (n : ℕ) (x : D n) → apd f (ncglue n x) == ncglue* n x
open ℕColimElim public using () renaming (f to ℕColim-elim)
module ℕColimRec (d : (n : ℕ) → D n → D (S n))
{j} {A : Type j}
(ncin* : (n : ℕ) → D n → A)
(ncglue* : (n : ℕ) → (x : D n) → ncin* n x == ncin* (S n) (d n x))
where
private
module M = ℕColimElim d ncin* (λ n x → ↓-cst-in (ncglue* n x))
f : ℕColim d → A
f = M.f
ncglue-β : (n : ℕ) (x : D n) → ap f (ncglue n x) == ncglue* n x
ncglue-β n x = apd=cst-in {f = f} (M.ncglue-β n x)
⊙ℕColim : ∀ {i} {D : ℕ → Ptd i} (d : (n : ℕ) → fst (D n ⊙→ D (S n))) → Ptd i
⊙ℕColim {D = D} d = ⊙[ ℕColim (fst ∘ d) , ncin 0 (snd (D 0)) ]
{- Can define a function [nc-raise d : ℕColim d → ℕColim d]
so that [inn (S n) ∘ d = nc-raise d ∘ inn n] -}
module ℕCRaise {i} {D : ℕ → Type i} (d : (n : ℕ) → D n → D (S n)) =
ℕColimRec d {A = ℕColim d}
(λ n x → ncin (S n) (d n x))
(λ n x → ncglue (S n) (d n x))
nc-raise : ∀ {i} {D : ℕ → Type i} (d : (n : ℕ) → D n → D (S n))
→ ℕColim d → ℕColim d
nc-raise d = ℕCRaise.f d
nc-raise-= : ∀ {i} {D : ℕ → Type i} (d : (n : ℕ) → D n → D (S n)) (c : ℕColim d)
→ c == nc-raise d c
nc-raise-= d = ℕColimElim.f d
(λ n x → ncglue n x)
(λ n x → ↓-='-from-square $
ap-idf (ncglue n x) ∙v⊡ connection2 ⊡v∙ (! (ℕCRaise.ncglue-β d n x)))
{- Lift an element of D₀ to any level -}
nc-lift : ∀ {i} {D : ℕ → Type i} (d : (n : ℕ) → D n → D (S n))
(n : ℕ) → D O → D n
nc-lift d O x = x
nc-lift d (S n) x = d n (nc-lift d n x)
nc-lift-= : ∀ {i} {D : ℕ → Type i} (d : (n : ℕ) → D n → D (S n))
(n : ℕ) (x : D O)
→ ncin {d = d} O x == ncin n (nc-lift d n x)
nc-lift-= d O x = idp
nc-lift-= d (S n) x = nc-lift-= d n x ∙ ncglue n (nc-lift d n x)
{- Lift an element of D₀ to the 'same level' as some element of ℕColim d -}
module ℕCMatch {i} {D : ℕ → Type i} (d : (n : ℕ) → D n → D (S n)) (x : D O) =
ℕColimRec d {A = ℕColim d}
(λ n _ → ncin n (nc-lift d n x))
(λ n _ → ncglue n (nc-lift d n x))
nc-match = ℕCMatch.f
nc-match-=-base : ∀ {i} {D : ℕ → Type i} (d : (n : ℕ) → D n → D (S n))
(x : D O) (c : ℕColim d)
→ ncin O x == nc-match d x c
nc-match-=-base d x = ℕColimElim.f d
(λ n _ → nc-lift-= d n x)
(λ n y → ↓-cst=app-from-square $
disc-to-square idp ⊡v∙ ! (ℕCMatch.ncglue-β d x n y))
{- If all Dₙ are m-connected, then the colim is m-connected -}
ncolim-conn : ∀ {i} {D : ℕ → Type i} (d : (n : ℕ) → D n → D (S n)) (m : ℕ₋₂)
→ ((n : ℕ) → is-connected m (D n))
→ is-connected m (ℕColim d)
ncolim-conn {D = D} d ⟨-2⟩ cD = -2-conn (ℕColim d)
ncolim-conn {D = D} d (S m) cD =
Trunc-rec (prop-has-level-S is-contr-is-prop)
(λ x → ([ ncin O x ] ,
(Trunc-elim (λ _ → =-preserves-level _ Trunc-level) $
λ c → ap [_] (nc-match-=-base d x c) ∙ nc-match-=-point x c)))
(fst (cD O))
where
nc-match-=-point : (x : D O) (c : ℕColim d)
→ [_] {n = S m} (nc-match d x c) == [ c ]
nc-match-=-point x = ℕColimElim.f d
(λ n y → ap (Trunc-fmap (ncin n))
(contr-has-all-paths (cD n) [ nc-lift d n x ] [ y ]))
(λ n y → ↓-='-from-square $
(ap-∘ [_] (nc-match d x) (ncglue n y)
∙ ap (ap [_]) (ℕCMatch.ncglue-β d x n y))
∙v⊡
! (ap-idf _)
∙h⊡
(square-symmetry $
natural-square
(Trunc-elim (λ _ → =-preserves-level _ Trunc-level)
(λ c → ap [_] (nc-raise-= d c)))
(ap (Trunc-fmap (ncin n))
(contr-has-all-paths (cD n) [ nc-lift d n x ] [ y ])))
⊡h∙
(∘-ap (Trunc-fmap (nc-raise d)) (Trunc-fmap (ncin n))
(contr-has-all-paths (cD n) [ nc-lift d n x ] [ y ])
∙ vert-degen-path
(natural-square
(λ t → Trunc-fmap-∘ (nc-raise d) (ncin n) t
∙ ! (Trunc-fmap-∘ (ncin (S n)) (d n) t))
(contr-has-all-paths (cD n) [ nc-lift d n x ] [ y ]))
∙ ap-∘ (Trunc-fmap (ncin (S n))) (Trunc-fmap (d n))
(contr-has-all-paths (cD n) [ nc-lift d n x ] [ y ])
∙ ap (ap (Trunc-fmap (ncin (S n))))
(contr-has-all-paths (=-preserves-level _ (cD (S n))) _ _)))
{- Type of finite tuples -}
FinTuplesType : ∀ {i} → (ℕ → Ptd i) → ℕ → Ptd i
FinTuplesType F O = ⊙Lift ⊙Unit
FinTuplesType F (S n) = F O ⊙× FinTuplesType (F ∘ S) n
fin-tuples-map : ∀ {i} (F : ℕ → Ptd i) (n : ℕ)
→ fst (FinTuplesType F n ⊙→ FinTuplesType F (S n))
fin-tuples-map F O = (_ , idp)
fin-tuples-map F (S n) =
((λ {(x , r) → (x , fst (fin-tuples-map (F ∘ S) n) r)}) ,
pair×= idp (snd (fin-tuples-map (F ∘ S) n)))
⊙FinTuples : ∀ {i} → (ℕ → Ptd i) → Ptd i
⊙FinTuples {i} F = ⊙ℕColim (fin-tuples-map F)
FinTuples : ∀ {i} → (ℕ → Ptd i) → Type i
FinTuples = fst ∘ ⊙FinTuples
module FinTuplesCons {i} (F : ℕ → Ptd i) where
module Into (x : fst (F O)) =
ℕColimRec (fst ∘ fin-tuples-map (F ∘ S)) {A = fst (⊙FinTuples F)}
(λ n r → ncin (S n) (x , r))
(λ n r → ncglue (S n) (x , r))
into = uncurry Into.f
out-ncin : (n : ℕ)
→ fst (FinTuplesType F n) → fst (F O ⊙× ⊙FinTuples (F ∘ S))
out-ncin O x = (snd (F O) , ncin O _)
out-ncin (S n) (x , r) = (x , ncin n r)
out-ncglue : (n : ℕ) (r : fst (FinTuplesType F n))
→ out-ncin n r == out-ncin (S n) (fst (fin-tuples-map F n) r)
out-ncglue O x = idp
out-ncglue (S n) (x , r) = pair= idp (ncglue n r)
module Out = ℕColimRec _ out-ncin out-ncglue
out = Out.f
into-out-ncin : (n : ℕ) (r : fst (FinTuplesType F n))
→ into (out-ncin n r) == ncin n r
into-out-ncin O x = ! (ncglue O x)
into-out-ncin (S n) (x , r) = idp
into-out-ncglue : (n : ℕ) (r : fst (FinTuplesType F n))
→ into-out-ncin n r == into-out-ncin (S n) (fst (fin-tuples-map F n) r)
[ (λ s → into (out s) == s) ↓ ncglue n r ]
into-out-ncglue O x =
↓-∘=idf-from-square into out $
ap (ap into) (Out.ncglue-β O x)
∙v⊡ bl-square (ncglue O x)
into-out-ncglue (S n) (x , r) =
↓-∘=idf-from-square into out $
(ap (ap into) (Out.ncglue-β (S n) (x , r))
∙ ∘-ap into (_,_ x) (ncglue n r)
∙ Into.ncglue-β x n r)
∙v⊡ vid-square
into-out : (r : fst (⊙FinTuples F)) → into (out r) == r
into-out = ℕColimElim.f _
into-out-ncin
into-out-ncglue
out-into : (t : fst (F O ⊙× ⊙FinTuples (F ∘ S))) → out (into t) == t
out-into = uncurry $ λ x → ℕColimElim.f _
(λ n r → idp)
(λ n r → ↓-='-from-square $
(ap-∘ out (Into.f x) (ncglue n r)
∙ ap (ap out) (Into.ncglue-β x n r)
∙ Out.ncglue-β (S n) (x , r))
∙v⊡ vid-square)
fin-tuples-cons : ∀ {i} (F : ℕ → Ptd i)
→ fst (F O) × FinTuples (F ∘ S) ≃ FinTuples F
fin-tuples-cons {i} F = equiv into out into-out out-into
where open FinTuplesCons F
⊙fin-tuples-cons : ∀ {i} (F : ℕ → Ptd i)
→ (F O ⊙× ⊙FinTuples (F ∘ S)) ⊙≃ ⊙FinTuples F
⊙fin-tuples-cons F = ⊙≃-in (fin-tuples-cons F) (! (ncglue O _))
|
{
"alphanum_fraction": 0.5033751205,
"avg_line_length": 33.4516129032,
"ext": "agda",
"hexsha": "85314ac4c5b68aa15cf117beb0d3c6d4d2b06955",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cmknapp/HoTT-Agda",
"max_forks_repo_path": "core/lib/types/NatColim.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cmknapp/HoTT-Agda",
"max_issues_repo_path": "core/lib/types/NatColim.agda",
"max_line_length": 80,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cmknapp/HoTT-Agda",
"max_stars_repo_path": "core/lib/types/NatColim.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3626,
"size": 8296
}
|
module Bug where
data A : Set where
a : A
h : A -> A
h a = a
data B : A -> Set where
b : (x : A) -> B (h x)
data _==_ : {x₁ x₂ : A} -> B x₁ -> B x₂ -> Set where
eqb : {x : A} -> b x == b x
-- The problem here is that we get the constraint h x = h x, which when x is a
-- meta variable we don't solve. This constraint blocks the solution y := b x
-- and so we don't see that y should be dotted. Either explicitly dotting y or
-- binding x removes the problem.
bad : {x : A}{y : B x} -> y == y -> A
bad eqb = ?
-- bad .{h x} .{b x} (eqb {x}) = ? -- works
-- bad .{y = _} eqb = ? -- works
-- bad (eqb {_}) = ? -- works
-- The above example is solved by checking syntactic equality on blocked terms.
-- This doesn't work below:
infixl 70 _/_
infixl 50 _▻_
infix 40 _∋_ _⊢ _⇒_ _≛_ _≈∋_
mutual
data Ctxt : Set where
_▻_ : (Γ : Ctxt) -> Γ ⊢ -> Ctxt
data _⊢ : (Γ : Ctxt) -> Set where
✶ : {Γ : Ctxt} -> Γ ⊢
data _⇒_ : Ctxt -> Ctxt -> Set where
wk : {Γ : Ctxt} (σ : Γ ⊢) -> Γ ⇒ Γ ▻ σ
data _∋_ : (Γ : Ctxt) -> Γ ⊢ -> Set where
vz : {Γ : Ctxt} (τ : Γ ⊢) -> Γ ▻ τ ∋ τ / wk τ
_/_ : {Γ Δ : Ctxt} -> Γ ⊢ -> Γ ⇒ Δ -> Δ ⊢
✶ / ρ = ✶
data _≛_ : {Γ¹ Γ² : Ctxt} -> Γ¹ ⊢ -> Γ² ⊢ -> Set where
data _≈∋_ : {Γ¹ Γ² : Ctxt} {τ¹ : Γ¹ ⊢} {τ² : Γ² ⊢}
-> Γ¹ ∋ τ¹ -> Γ² ∋ τ² -> Set where
vzCong : {Γ¹ : Ctxt} {τ¹ : Γ¹ ⊢}
{Γ² : Ctxt} {τ² : Γ² ⊢}
-> τ¹ ≛ τ² -> vz τ¹ ≈∋ vz τ²
f : {Γ¹ : Ctxt} {σ¹ : Γ¹ ⊢} {v¹ : Γ¹ ∋ σ¹}
{Γ² : Ctxt} {σ² : Γ² ⊢} {v² : Γ² ∋ σ²}
{Γ³ : Ctxt} {σ³ : Γ³ ⊢} {v³ : Γ³ ∋ σ³}
-> v¹ ≈∋ v² -> v² ≈∋ v³ -> v¹ ≈∋ v³
f (vzCong eqσ¹²) (vzCong eqσ²³) = ?
|
{
"alphanum_fraction": 0.4746987952,
"avg_line_length": 25.9375,
"ext": "agda",
"hexsha": "d28738b33d63d088d07243136075de70c83afa90",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "alhassy/agda",
"max_forks_repo_path": "test/bugs/fixed/DotPattern.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "alhassy/agda",
"max_issues_repo_path": "test/bugs/fixed/DotPattern.agda",
"max_line_length": 79,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "alhassy/agda",
"max_stars_repo_path": "test/bugs/fixed/DotPattern.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": 780,
"size": 1660
}
|
module sv20.assign2.Second_old2 where
-- ------------------------------------------------------------------------
open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; trans; cong)
open import Data.Nat using (ℕ; zero; suc; _+_)
open import Data.Nat.Properties using (≡-decSetoid)
open import Data.List using (List; []; _∷_; _++_)
open import Relation.Binary using (Setoid; DecSetoid)
open import Data.Product using (_×_) renaming (_,_ to ⟨_,_⟩)
open import Relation.Nullary using (¬_; Dec; yes; no)
-- ℕsetoid : Setoid lzero lzero
-- ℕsetoid = record {
-- Carrier = ℕ
-- ; _≈_ = _≡_
-- ; isEquivalence = record {
-- refl = refl
-- ; sym = sym
-- ; trans = trans
-- }
-- }
-- open import Data.Product.Relation.Binary.Pointwise.NonDependent as Pointwise
-- using (Pointwise)
--
-- ℕ×ℕdecsetoid : DecSetoid lzero lzero
-- ℕ×ℕdecsetoid = record {
-- Carrier = ℕ × ℕ
-- ; _≈_ = _≡_
-- ; isDecEquivalence = record
-- { isEquivalence = record { refl = refl ; sym = sym ; trans = trans }
-- ; _≟_ = ? -- _≟_
-- }
-- }
import Data.List.Relation.Binary.Subset.Setoid as SubSetoid
open SubSetoid (DecSetoid.setoid ≡-decSetoid) using (_⊆_)
--import Data.List.Membership.Setoid
--module ListSetoid = Data.List.Membership.Setoid (ℕsetoid)
--open ListSetoid using (_∈_)
open import Data.List.Membership.DecSetoid (≡-decSetoid) using () renaming (_∈?_ to _∈ℕ?_)
--open import Data.List.Membership.DecSetoid (ℕ×ℕdecsetoid) using () renaming (_∈?_ to _∈ℕ×ℕ?_)
open import Data.List.Relation.Unary.Any using (Any; index; map; here; there)
--simple : [] ⊆ (2 ∷ [])
--simple ()
--
--simple₂ : (1 ∷ []) ⊆ (2 ∷ 1 ∷ [])
--simple₂ (here px) = there (here px)
--Look at:
-- https://agda.github.io/agda-stdlib/Data.List.Relation.Binary.Subset.Propositional.Properties.html
-- https://agda.github.io/agda-stdlib/Data.List.Relation.Binary.Subset.Setoid.html#692
-- https://agda.github.io/agda-stdlib/Relation.Binary.Structures.html#1522
--simple₃ : 1 ∈ (2 ∷ 1 ∷ [])
--simple₃ = ?
-- ⟨Set⟩ are basically lists in Athena. Which is not what a set should be but
-- the professor doesn't care about this, so I can implement this using lists
-- data relation {a b : Set} (A : ⟨Set⟩ a) (B : ⟨Set⟩ b) : ⟨Set⟩ (a × b) where
--
--relation = _×_
--
--range-theorem-2 : ∀ {a b} {A : ⟨Set⟩ a} {B : ⟨Set⟩ b}
-- (F G : ⟨Set⟩ (a × b))
-- → Range (F intersect G) ⊆ (Range F) intersect (Range G)
--
--range-theorem-2 : ∀ {a b} {A : ⟨Set⟩ a} {B : ⟨Set⟩ b}
-- (F G : ⟨Set⟩ (a × b))
-- → Range (F ∩ G) ⊆ (Range F) ∩ (Range G)
--
--dom-theorem-3 : ∀ {A B : ⟨Set⟩}
-- (F G : A × B)
-- → (Dom F) diff (Dom G) ⊆ Dom (F diff G)
--
--range-theorem-3 : ∀ {a b} {A : ⟨Set⟩ a} {B : ⟨Set⟩ b}
-- (F G : A × B)
-- → (Range F) diff (Range G) ⊆ Range (F diff G)
dom : ∀ {A B : Set} → List (A × B) → List A
dom [] = []
dom (⟨ x , _ ⟩ ∷ ls) = x ∷ dom ls
range : ∀ {A B : Set} → List (A × B) → List B
range [] = []
range (⟨ _ , y ⟩ ∷ ls) = y ∷ range ls
_∩ℕ_ : List ℕ → List ℕ → List ℕ
--_∩ : List A → List A → List A
[] ∩ℕ _ = []
--xs ∩ ys = ?
(x ∷ xs) ∩ℕ ys with x ∈ℕ? ys
... | yes _ = x ∷ (xs ∩ℕ ys)
... | no _ = xs ∩ℕ ys
--_intersectℕ×ℕ_ : List (ℕ × ℕ) → List (ℕ × ℕ) → List (ℕ × ℕ)
----_intersect_ : List A → List A → List A
--[] intersectℕ×ℕ _ = []
----xs intersect ys = ?
--(x ∷ xs) intersectℕ×ℕ ys with x ∈ℕ×ℕ? ys
--... | yes _ = x ∷ (xs intersectℕ×ℕ ys)
--... | no _ = xs intersectℕ×ℕ ys
simple-theorem : (F G : List ℕ)
→ (F ∩ℕ G) ⊆ F
simple-theorem [] _ p = p
simple-theorem (x ∷ xs) ys = ? -- NO IDEA HOW TO PROCEDE EVEN WITH THE "SIMPLEST" OF CASES
--simple-theorem (x ∷ xs) ys = ?
-- λ x xs ys x₁ → x₁ ListSetoid.∈ ((x ∷ xs) intersectℕ ys) → x₁ ListSetoid.∈ x ∷ xs}
--simple-theorem [] _ p = p
--simple-theorem (x ∷ xs) [] = ?
--simple-theorem (x ∷ xs) (y ∷ ys) = ?
-- (2 ∷ 3 ∷ 60 ∷ []) intersectℕ (1 ∷ 3 ∷ 2 ∷ [])
-- (⟨ 2 , 0 ⟩ ∷ ⟨ 3 , 2 ⟩ ∷ ⟨ 60 , 1 ⟩ ∷ []) intersectℕ (1 ∷ 3 ∷ 2 ∷ [])
--module Intersect {a ℓ} (DS : DecSetoid a ℓ) where
-- open import Data.List.Membership.DecSetoid (DS) using (_∈?_)
-- --open DecSetoid DS using (_≟_)
--
-- A = DecSetoid.Carrier DS
--
-- --_intersect_ : List ℕ → List ℕ → List ℕ
-- _intersect_ : List A → List A → List A
-- [] intersect ys = ys
-- --xs intersect ys = ?
-- (x ∷ xs) intersect ys with x ∈? ys
-- ... | yes _ = x ∷ (xs intersect ys)
-- ... | no _ = xs intersect ys
--
--
--import Data.List.Relation.Binary.Subset.Setoid as SubSetoid
--
--module Range-Theorem-2 {a ℓ} (DS₁ : DecSetoid a ℓ) (DS₂ : DecSetoid a ℓ) where
-- A = DecSetoid.Carrier DS₁
-- B = DecSetoid.Carrier DS₂
--
-- DSboth : DecSetoid a ℓ
-- DSboth = record {
-- Carrier = A × B
-- ; _≈_ = ?
-- ; isDecEquivalence = ?
-- }
--
-- open Intersect (DSboth) using (_intersect_)
-- open Intersect (DS₂) using () renaming (_intersect_ to _intersect₂_)
--
-- S₂setoid : Setoid a ℓ
-- S₂setoid = record {
-- Carrier = B
-- ; _≈_ = DecSetoid._≈_ DS₂
-- ; isEquivalence = Setoid.isEquivalence (DecSetoid.setoid DS₂)
-- }
-- open SubSetoid (S₂setoid) using (_⊆_)
--
-- range-theorem-2 : --∀ {A B : Set}
-- (F G : List (A × B))
-- --(F G : List (ℕ × ℕ))
-- → range (F intersect G) ⊆ (range F) intersect₂ (range G)
-- range-theorem-2 [] _ p = p
-- range-theorem-2 (x ∷ xs) [] = ?
-- range-theorem-2 (x ∷ xs) (y ∷ ys) = ?
--open import Data.AVL.Sets using (⟨Set⟩; empty; insert; delete)
|
{
"alphanum_fraction": 0.5405832748,
"avg_line_length": 33.6804733728,
"ext": "agda",
"hexsha": "80d7d754e61481f85cf22c7d79e2a05fed7b804c",
"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": "a432faf1b340cb379190a2f2b11b997b02d1cd8d",
"max_forks_repo_licenses": [
"CC0-1.0"
],
"max_forks_repo_name": "helq/old_code",
"max_forks_repo_path": "proglangs-learning/Agda/sv20/assign2/Second_old2.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d",
"max_issues_repo_issues_event_max_datetime": "2021-06-07T15:39:48.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-03-10T19:20:21.000Z",
"max_issues_repo_licenses": [
"CC0-1.0"
],
"max_issues_repo_name": "helq/old_code",
"max_issues_repo_path": "proglangs-learning/Agda/sv20/assign2/Second_old2.agda",
"max_line_length": 100,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d",
"max_stars_repo_licenses": [
"CC0-1.0"
],
"max_stars_repo_name": "helq/old_code",
"max_stars_repo_path": "proglangs-learning/Agda/sv20/assign2/Second_old2.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2054,
"size": 5692
}
|
module Issue307 where
postulate A : Set
_! : A → A
x ! = x
! : A → A
! x = x
data D : Set where
d : D → D
syntax d x = x d
f : D → D
f (x d) = x
g : D → D
g (d x) = x
|
{
"alphanum_fraction": 0.45,
"avg_line_length": 7.2,
"ext": "agda",
"hexsha": "2cd96cf7ffce33b68f993dec75d8be9c5800a8ad",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "test/succeed/Issue307.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "test/succeed/Issue307.agda",
"max_line_length": 21,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "test/succeed/Issue307.agda",
"max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z",
"num_tokens": 82,
"size": 180
}
|
-- Andreas, 2015-09-09 Issue 1643
-- {-# OPTIONS -v tc.mod.apply:20 #-}
-- {-# OPTIONS -v tc.signature:30 #-}
-- {-# OPTIONS -v tc.display:100 #-}
-- {-# OPTIONS -v scope:50 -v scope.inverse:100 -v interactive.meta:20 #-}
module _ where
module M where
postulate A : Set
module N = M -- This alias used to introduce a display form M.A --> N.A
open N
postulate
a : A
test : Set
test = a
-- ERROR SHOULD BE: A !=< Set of type Set
|
{
"alphanum_fraction": 0.6176470588,
"avg_line_length": 19.2173913043,
"ext": "agda",
"hexsha": "bead4e2ca66a959c5be170734001edadcd6715fa",
"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/Issue1643a.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/Issue1643a.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/Fail/Issue1643a.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": 140,
"size": 442
}
|
module PatternSynonymNoParse where
pattern f x = a b
|
{
"alphanum_fraction": 0.7962962963,
"avg_line_length": 13.5,
"ext": "agda",
"hexsha": "e84edb57467896e8433834c4f5561d744711bd36",
"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/PatternSynonymNoParse.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/PatternSynonymNoParse.agda",
"max_line_length": 34,
"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/PatternSynonymNoParse.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 15,
"size": 54
}
|
------------------------------------------
-- Mathematical induction derived from Z
------------------------------------------
module sv20.assign2.SetTheory.PMI where
open import sv20.assign2.SetTheory.Logic
open import sv20.assign2.SetTheory.ZAxioms
open import sv20.assign2.SetTheory.Algebra
open import sv20.assign2.SetTheory.Subset
open import sv20.assign2.SetTheory.Pairs
-- Axiom of infinity
postulate
infinity : ∃ (λ I → ∅ ∈ I ∧ ∀ x → x ∈ I → x ∪ singleton x ∈ I)
succ : 𝓢 → 𝓢
succ x = x ∪ singleton x
-- Inductive property
Inductive : 𝓢 → Set
Inductive A = ∅ ∈ A ∧ ((x : 𝓢) → x ∈ A → succ x ∈ A)
-- An inductive set.
I : 𝓢
I = proj₁ infinity
formulaN : 𝓢 → Set
formulaN x = (A : 𝓢) → Inductive A → x ∈ A
fullN : ∃ (λ B → {z : 𝓢} → z ∈ B ⇔ z ∈ I ∧ formulaN z)
fullN = sub formulaN I
ℕ : 𝓢
ℕ = proj₁ fullN
x∈ℕ→x∈InductiveSet : (x : 𝓢) → x ∈ ℕ → (A : 𝓢) → Inductive A → x ∈ A
x∈ℕ→x∈InductiveSet x h = ∧-proj₂ (∧-proj₁ (proj₂ _ fullN) h)
-- PMI version from Ivorra Castillo (n.d.), Teorema 8.13.
PMI : (A : 𝓢) → A ⊆ ℕ → ∅ ∈ A → ((n : 𝓢) → n ∈ A → succ n ∈ A) → A ≡ ℕ
PMI A h₁ h₂ h₃ = equalitySubset A ℕ (prf₁ , prf₂)
where
prf₁ : (z : 𝓢) → z ∈ A → z ∈ ℕ
prf₁ z h = h₁ z h
inductiveA : Inductive A
inductiveA = h₂ , h₃
prf₂ : (z : 𝓢) → z ∈ ℕ → z ∈ A
prf₂ z h = x∈ℕ→x∈InductiveSet z h A inductiveA
-- References
--
-- Suppes, Patrick (1960). Axiomatic Set Theory.
-- The University Series in Undergraduate Mathematics.
-- D. Van Nostrand Company, inc.
--
-- Enderton, Herbert B. (1977). Elements of Set Theory.
-- Academic Press Inc.
--
-- Ivorra Castillo, Carlos (n.d.). Lógica y Teoría de
-- Conjuntos. https://www.uv.es/ivorra/
|
{
"alphanum_fraction": 0.5935057126,
"avg_line_length": 25.984375,
"ext": "agda",
"hexsha": "7cd3791792738b9f3f4786cff897587705fc8efc",
"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": "a432faf1b340cb379190a2f2b11b997b02d1cd8d",
"max_forks_repo_licenses": [
"CC0-1.0"
],
"max_forks_repo_name": "helq/old_code",
"max_forks_repo_path": "proglangs-learning/Agda/sv20/assign2/SetTheory/PMI.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d",
"max_issues_repo_issues_event_max_datetime": "2021-06-07T15:39:48.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-03-10T19:20:21.000Z",
"max_issues_repo_licenses": [
"CC0-1.0"
],
"max_issues_repo_name": "helq/old_code",
"max_issues_repo_path": "proglangs-learning/Agda/sv20/assign2/SetTheory/PMI.agda",
"max_line_length": 70,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d",
"max_stars_repo_licenses": [
"CC0-1.0"
],
"max_stars_repo_name": "helq/old_code",
"max_stars_repo_path": "proglangs-learning/Agda/sv20/assign2/SetTheory/PMI.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 636,
"size": 1663
}
|
module tmp where
open import univ
open import cwf
open import Base
open import Nat
open import help
open import proofs
{- TODO: Prove
w = ƛ ((w // wk) ∙ vz) (η)
ƛ v // σ = ƛ (v // (σ ∘ wk ,, vz))
w ∙ u // σ = (w // σ) ∙ (u // σ)
-}
{-
lem-tmp : {Γ : Con}{A : Type Γ}(B : Type (Γ , A)) ->
Π A B =Ty Π A (B / (wk ∘ wk ,, castElem ? vz) / [ vz ])
lem-tmp B = ?
lem-η : {Γ : Con}{A : Type Γ}{B : Type (Γ , A)}(w : Elem Γ (Π A B)) ->
w =El castElem (lem-tmp B)
(ƛ {A = A}
(castElem (symTy (lem-Π/ B wk)) (w // wk {A = A}) ∙ vz)
)
lem-η (elem (el < w , pw >)) = ?
-}
|
{
"alphanum_fraction": 0.4624373957,
"avg_line_length": 18.71875,
"ext": "agda",
"hexsha": "293d6a26a10231b985030ce434a7032b4c224c6f",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "examples/outdated-and-incorrect/univ/tmp.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "examples/outdated-and-incorrect/univ/tmp.agda",
"max_line_length": 70,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "examples/outdated-and-incorrect/univ/tmp.agda",
"max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z",
"num_tokens": 265,
"size": 599
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- The free monad construction on containers
------------------------------------------------------------------------
module Data.Container.FreeMonad where
open import Level
open import Function using (_∘_)
open import Data.Empty using (⊥-elim)
open import Data.Sum using (inj₁; inj₂)
open import Data.Product
open import Data.Container
open import Data.Container.Combinator using (const; _⊎_)
open import Data.W
open import Category.Monad
infixl 1 _⋆C_
infix 1 _⋆_
------------------------------------------------------------------------
-- The free monad construction over a container and a set is, in
-- universal algebra terminology, also known as the term algebra over a
-- signature (a container) and a set (of variable symbols). The return
-- of the free monad corresponds to variables and the bind operator
-- corresponds to (parallel) substitution.
-- A useful intuition is to think of containers describing single
-- operations and the free monad construction over a container and a set
-- describing a tree of operations as nodes and elements of the set as
-- leafs. If one starts at the root, then any path will pass finitely
-- many nodes (operations described by the container) and eventually end
-- up in a leaf (element of the set) -- hence the Kleene star notation
-- (the type can be read as a regular expression).
_⋆C_ : ∀ {c} → Container c → Set c → Container c
C ⋆C X = const X ⊎ C
_⋆_ : ∀ {c} → Container c → Set c → Set c
C ⋆ X = μ (C ⋆C X)
do : ∀ {c} {C : Container c} {X} → ⟦ C ⟧ (C ⋆ X) → C ⋆ X
do (s , k) = sup (inj₂ s) k
rawMonad : ∀ {c} {C : Container c} → RawMonad (_⋆_ C)
rawMonad = record { return = return; _>>=_ = _>>=_ }
where
return : ∀ {c} {C : Container c} {X} → X → C ⋆ X
return x = sup (inj₁ x) (⊥-elim ∘ lower)
_>>=_ : ∀ {c} {C : Container c} {X Y} → C ⋆ X → (X → C ⋆ Y) → C ⋆ Y
sup (inj₁ x) _ >>= k = k x
sup (inj₂ s) f >>= k = do (s , λ p → f p >>= k)
|
{
"alphanum_fraction": 0.5948616601,
"avg_line_length": 36.1428571429,
"ext": "agda",
"hexsha": "f3e8a25e446c07d1bee459033d54cce8dae8a7da",
"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/Container/FreeMonad.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/Container/FreeMonad.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/Container/FreeMonad.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": 590,
"size": 2024
}
|
module Misc.NumeralSystem where -- One Numeral System to rule them all!?
open import Data.Maybe using (Maybe; nothing; just)
open import Data.Nat
open import Data.Product
open import Data.Unit using (⊤; tt)
open import Data.Empty using (⊥; ⊥-elim)
open import Relation.Nullary using (¬_ ; yes; no)
open import Relation.Binary
open import Level
renaming (zero to lzero; suc to lsuc)
open import Relation.Binary.PropositionalEquality as PropEq
using (_≡_; refl; setoid; cong)
open import Data.Nat.Properties using (≤-step)
open DecTotalOrder Data.Nat.decTotalOrder using () renaming (refl to ≤-refl; trans to ≤-trans)
infixr 5 _∷[_,_]_
--------------------------------------------------------------------------------
-- PN - Positional Notation
-- http://en.wikipedia.org/wiki/Positional_notation
--
-- base: b
-- digits: consecutive ℕ from m to n
-- ●────○
data PN (b m n : ℕ) : Set where
[_] : m < n → PN b m n
_∷[_,_]_ : (x : ℕ) → (m ≤ x) → (x < n) → PN b m n → PN b m n
--------------------------------------------------------------------------------
toℕ : ∀ {b m n} → PN b m n → ℕ
toℕ [ _ ] = 0
toℕ {b} (x ∷[ x≥m , x<n ] xs) = x + b * toℕ xs
private
≤→< : ∀ {m n} → m ≤ n → ¬ (m ≡ n) → m < n
≤→< {n = zero} z≤n 0≠0 = ⊥-elim (0≠0 refl)
≤→< {n = suc n} z≤n neq = s≤s z≤n
≤→< (s≤s m≤n) 1+m≠1+n = s≤s (≤→< m≤n (λ m≡n → 1+m≠1+n (cong suc m≡n)))
--------------------------------------------------------------------------------
-- increment
-- the image of 'incr' is "continuous" if when
-- b = 1 ⇒ m ≥ 1, n ≥ 2m
-- b > 1 ⇒ m ≥ 0, n ≥ m + b, n ≥ 1 + mb
incr : ∀ {b m n} → m ≤ 1 → 2 ≤ n → PN b m n → PN b m n
incr m≤1 2≤n [ m<n ] = 1 ∷[ m≤1 , 2≤n ] [ m<n ]
incr {b} {m} {n} m≤1 2≤n (x ∷[ m≤x , x<n ] xs) with suc x ≟ n
incr {b} {m} m≤1 2≤n (x ∷[ m≤x , x<n ] xs) | no 1+x≠n = suc x ∷[ ≤-step m≤x , ≤→< x<n 1+x≠n ] xs
incr {b} {m} m≤1 2≤n (x ∷[ m≤x , x<n ] xs) | yes refl = m ∷[ ≤-refl , s≤s m≤x ] incr m≤1 2≤n xs
base=1-incr : ∀ {m n} → 1 ≤ m → m * 2 ≤ n → PN 1 m n → PN 1 m n
base=1-incr {m} {n} 1≤m 2m≤n [ m<n ] = m ∷[ ≤-refl , m<n ] [ m<n ]
base=1-incr {m} {n} 1≤m 2m≤n (x ∷[ m≤x , x<n ] xs) with suc x ≟ n
base=1-incr {m} {n} 1≤m 2m≤n (x ∷[ m≤x , x<n ] xs) | no 1+x≠n = suc x ∷[ ≤-step m≤x , ≤→< x<n 1+x≠n ] xs
base=1-incr {m} 1≤m 2m≤n (x ∷[ m≤x , x<n ] xs) | yes refl = m ∷[ ≤-refl , s≤s m≤x ] base=1-incr 1≤m 2m≤n xs
base>1-incr : ∀ {b m n} → 1 < b → 0 ≤ m → m + b ≤ n → m * b + 1 ≤ n → PN b m n → PN b m n
base>1-incr {b} {m} {n} 1<b 0≤m m+b≤n mb+1≤n [ m<n ] = m ∷[ ≤-refl , m<n ] [ m<n ]
base>1-incr {b} {m} {n} 1<b 0≤m m+b≤n mb+1≤n (x ∷[ m≤x , x<n ] xs) with suc x ≟ n
base>1-incr {b} {m} {n} 1<b 0≤m m+b≤n mb+1≤n (x ∷[ m≤x , x<n ] xs) | no 1+x≠n = suc x ∷[ ≤-step m≤x , ≤→< x<n 1+x≠n ] xs
base>1-incr {b} {m} 1<b 0≤m m+b≤n mb+1≤n (x ∷[ m≤x , x<n ] xs) | yes refl = m ∷[ ≤-refl , s≤s m≤x ] base>1-incr 1<b 0≤m m+b≤n mb+1≤n xs
--
-- A ── incr ⟶ A'
-- | |
-- toℕ toℕ
-- ↓ ↓
-- n ── suc ⟶ suc n
--
-- first attempt :p
-- unary-toℕ-hom : (a : PN 1 1 2) → suc (toℕ a) ≡ toℕ (base=1-incr (s≤s z≤n) (s≤s (s≤s z≤n)) a)
-- unary-toℕ-hom [ m<n ] = refl
-- unary-toℕ-hom (zero ∷[ () , x<n ] xs)
-- unary-toℕ-hom (suc zero ∷[ m≤x , x<n ] xs) = cong suc {! !}
-- unary-toℕ-hom (suc (suc x) ∷[ m≤x , s≤s (s≤s ()) ] xs)
--------------------------------------------------------------------------------
-- Instances
private
-- Unary
Unary : Set
Unary = PN 1 1 2
u₀ : Unary
u₀ = 1 ∷[ s≤s z≤n , s≤s (s≤s z≤n) ] 1 ∷[ s≤s z≤n , s≤s (s≤s z≤n) ] [ s≤s (s≤s z≤n) ]
-- Binary
Bin : Set
Bin = PN 2 0 2
b₀ : Bin
b₀ = 1 ∷[ z≤n , s≤s (s≤s z≤n) ] 0 ∷[ z≤n , s≤s z≤n ] [ s≤s z≤n ]
-- Zeroless Binary
Bin+ : Set
Bin+ = PN 2 1 3
|
{
"alphanum_fraction": 0.4450359329,
"avg_line_length": 34.1545454545,
"ext": "agda",
"hexsha": "34421584bdf2acf969b36cd223f1f92b522b6d7b",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z",
"max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "banacorn/numeral",
"max_forks_repo_path": "legacy/Misc/NumeralSystem.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "banacorn/numeral",
"max_issues_repo_path": "legacy/Misc/NumeralSystem.agda",
"max_line_length": 135,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "banacorn/numeral",
"max_stars_repo_path": "legacy/Misc/NumeralSystem.agda",
"max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z",
"num_tokens": 1840,
"size": 3757
}
|
module Issue390 where
data main : Set where
|
{
"alphanum_fraction": 0.7777777778,
"avg_line_length": 11.25,
"ext": "agda",
"hexsha": "5328e6962c7c88fedcc838e8b81101c992f88eae",
"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/fail/Issue390.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "test/fail/Issue390.agda",
"max_line_length": 21,
"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/Fail/Issue390.agda",
"max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z",
"num_tokens": 11,
"size": 45
}
|
module Prelude.List.Relations.Permutation where
open import Prelude.List.Base
open import Prelude.List.Relations.Any
data Permutation {a} {A : Set a} : List A → List A → Set a where
[] : Permutation [] []
_∷_ : ∀ {x xs ys} (i : x ∈ ys) → Permutation xs (deleteIx ys i) →
Permutation (x ∷ xs) ys
|
{
"alphanum_fraction": 0.6474358974,
"avg_line_length": 31.2,
"ext": "agda",
"hexsha": "082a6d9e6c4d046453e9ec84778b90456733b1ea",
"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/Relations/Permutation.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/Relations/Permutation.agda",
"max_line_length": 67,
"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/Relations/Permutation.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 97,
"size": 312
}
|
module ASN1.BER where
open import Data.Word8 using (Word8; _==_) renaming (primWord8fromNat to to𝕎; primWord8toNat to from𝕎)
open import Data.ByteString using (ByteString; Strict; Lazy; null; pack; unpack; fromChunks; toStrict; unsafeHead; unsafeTail; unsafeSplitAt) renaming (length to BSlength)
open import Data.Bool using (Bool; true; false)
open import Data.Nat using (ℕ; _+_; _∸_; _≤?_)
open import Data.List using (List; []; _∷_; length; reverse; concatMap; foldl; map)
open import Data.Sum using (_⊎_; inj₁; inj₂)
open import Data.Product using (_×_; _,_)
open import Data.String using (String)
open import Relation.Nullary using (Dec; yes; no)
open import Function using (case_of_; const)
open import ASN1.Util
open import ASN1.Untyped
-- encode
module _ where
encodeLen : Len → List Word8
encodeLen n with n ≤? 127
encodeLen n | yes p = to𝕎 n ∷ []
encodeLen n | no ¬p = to𝕎 (128 + length ns) ∷ reverse ns where
ns : List Word8
ns = base256 n
-- TODO: use WF induction
{-# TERMINATING #-}
encode : AST → List (ByteString Strict)
encode (tlv t (constr vs)) = pack (constructed t ∷ encodeLen l) ∷ evs where
evs : List (ByteString Strict)
evs = concatMap encode vs
l : ℕ
l = foldl _+_ 0 (map BSlength evs)
encode (tlv t (prim octets)) = pack (t ∷ encodeLen (BSlength octets)) ∷ octets ∷ []
encode′ : AST → ByteString Lazy
encode′ ast = fromChunks (encode ast)
encode″ : AST → ByteString Strict
encode″ ast = toStrict (encode′ ast)
-- decode
module _ where
Stream = ByteString Strict
StateT : (Set → Set) → Set → Set → Set
StateT M S A = S → M (A × S)
E : Set → Set
E A = String ⊎ A
M = StateT E Stream
-- TODO: use std monad
_>>=_ : ∀ {A B} → M A → (A → M B) → M B
ma >>= f = λ st → case ma st of λ
{ (inj₁ err) → inj₁ err
; (inj₂ (a , st′)) → f a st′
}
_>>_ : ∀ {A B} → M A → M B → M B
ma >> mb = ma >>= (const mb)
return : ∀ {A : Set} → A → M A
return a = λ st → inj₂ (a , st)
get : M Stream
get st = inj₂ (st , st)
error : ∀ {A : Set} → String → M A
error e = λ _ → inj₁ e
head : M Word8
head st with null st
head st | false = inj₂ (unsafeHead st , unsafeTail st)
head st | true = inj₁ "stream is empty"
take : ℕ → M (ByteString Strict)
take n st with n ≤? BSlength st
take n st | yes _ = inj₂ (unsafeSplitAt n st)
take n st | no _ = inj₁ "stream is small"
getTag : M Tag
getTag = head
getLen : M Len
getLen = do
n ← head
let n′ = from𝕎 n
no _ ← return (n′ ≤? 127) where
yes _ → return n′
let k = n′ ∸ 128
ns ← take k
let n″ = (fromBase256 (unpack ns))
no _ ← return (n″ ≤? 127) where
yes _ → error "invalid len"
return n″
decode : M AST
{-# TERMINATING #-}
decodeTLVs : M (List AST)
decodeTLVs = do
st ← get
false ← return (null st) where
true → return []
h ← decode
t ← decodeTLVs
return (h ∷ t)
getValue : Tag → Len → M Value
getValue tag len = do
bs ← take len
true ← return (is-constructed tag) where
false → return (prim bs)
inj₂ (vs , _) ← return (decodeTLVs bs) where
inj₁ e → error e
return (constr vs)
decode = do
t ← getTag
l ← getLen
v ← getValue t l
return (tlv t v)
-- TODO: check for non-empty stream tail after decode
|
{
"alphanum_fraction": 0.6092854989,
"avg_line_length": 26.1181102362,
"ext": "agda",
"hexsha": "004a2de9b69bf24a3c6f3f677396da637ad8a7fe",
"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": "bbbeb679fa2c55a12f0cb345ad920c999c3f8fa8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "semenov-vladyslav/asn1-agda",
"max_forks_repo_path": "src/ASN1/BER.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "bbbeb679fa2c55a12f0cb345ad920c999c3f8fa8",
"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": "semenov-vladyslav/asn1-agda",
"max_issues_repo_path": "src/ASN1/BER.agda",
"max_line_length": 171,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "bbbeb679fa2c55a12f0cb345ad920c999c3f8fa8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "semenov-vladyslav/asn1-agda",
"max_stars_repo_path": "src/ASN1/BER.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1129,
"size": 3317
}
|
------------------------------------------------------------------------------
-- Conversion rules for the division
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOTC.Program.Division.ConversionRulesATP where
open import FOTC.Base
open import FOTC.Data.Nat
open import FOTC.Data.Nat.Inequalities
open import FOTC.Program.Division.Division
----------------------------------------------------------------------
-- NB. These equations are not used by the ATPs. They use the official
-- equation.
private
-- The division result when the dividend is minor than the
-- the divisor.
postulate div-x<y : ∀ {i j} → i < j → div i j ≡ zero
{-# ATP prove div-x<y #-}
-- The division result when the dividend is greater or equal than the
-- the divisor.
postulate div-x≮y : ∀ {i j} → i ≮ j → div i j ≡ succ₁ (div (i ∸ j) j)
{-# ATP prove div-x≮y #-}
|
{
"alphanum_fraction": 0.5055970149,
"avg_line_length": 34.5806451613,
"ext": "agda",
"hexsha": "697ea4b2a28842c35c3b7da99ce20bd92593ba7d",
"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/ConversionRulesATP.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/ConversionRulesATP.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/ConversionRulesATP.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": 240,
"size": 1072
}
|
{-# OPTIONS --safe #-}
module Sol01 where
open import Data.Nat
open import Data.Nat.Properties
open import Relation.Binary.PropositionalEquality
fibAux : ℕ -> ℕ -> ℕ -> ℕ
fibAux a b 0 = a
fibAux a b (suc n) = fibAux b (a + b) n
fib2 : ℕ -> ℕ
fib2 = fibAux 0 1
fib : ℕ -> ℕ
fib 0 = 0
fib 1 = 1
fib (suc (suc n)) = fib (suc n) + fib n
lemma : ∀ (a b c d n : ℕ) → fibAux (a + c) (b + d) n ≡ fibAux a b n + fibAux c d n
lemma a b c d zero = refl
lemma a b c d (suc n) rewrite sym (+-assoc (a + c) b d) | +-assoc a c b | +-comm c b | sym (+-assoc a b c) | +-assoc (a + b) c d = lemma b (a + b) d (c + d) n
fibEq : (n : ℕ) -> fib2 n ≡ fib n
fibEq zero = refl
fibEq (suc zero) = refl
fibEq (suc (suc n)) rewrite lemma 0 1 1 1 n | fibEq n | fibEq (suc n) | +-comm (fib n) (fib (suc n)) = refl
|
{
"alphanum_fraction": 0.5752212389,
"avg_line_length": 28.25,
"ext": "agda",
"hexsha": "c03aea99aa489615b3cebf1085ac970eb5ee11eb",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-12-13T04:50:46.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-12-13T04:50:46.000Z",
"max_forks_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Brethland/LEARNING-STUFF",
"max_forks_repo_path": "Agda/Sol01.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344",
"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": "Brethland/LEARNING-STUFF",
"max_issues_repo_path": "Agda/Sol01.agda",
"max_line_length": 158,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Brethland/LEARNING-STUFF",
"max_stars_repo_path": "Agda/Sol01.agda",
"max_stars_repo_stars_event_max_datetime": "2020-03-11T10:35:42.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-02-03T05:05:52.000Z",
"num_tokens": 330,
"size": 791
}
|
{-# OPTIONS --without-K --safe --no-sized-types --no-guardedness --no-subtyping #-}
module Agda.Builtin.Reflection.External where
open import Agda.Builtin.List
open import Agda.Builtin.Nat
open import Agda.Builtin.Sigma
open import Agda.Builtin.String
postulate
execTC : String → List String → String
→ TC (Σ Nat (λ _ → Σ String (λ _ → String)))
{-# BUILTIN AGDATCMEXEC execTC #-}
|
{
"alphanum_fraction": 0.7095959596,
"avg_line_length": 26.4,
"ext": "agda",
"hexsha": "86cdeb08ed50bbc5e93b1d5ad42739721fdb17be",
"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": "f7772e5515cd896fc9bf458fa19d18847ac56742",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Saizan/agda",
"max_forks_repo_path": "src/data/lib/prim/Agda/Builtin/Reflection/External.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f7772e5515cd896fc9bf458fa19d18847ac56742",
"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": "Saizan/agda",
"max_issues_repo_path": "src/data/lib/prim/Agda/Builtin/Reflection/External.agda",
"max_line_length": 83,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "f7772e5515cd896fc9bf458fa19d18847ac56742",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "Saizan/agda",
"max_stars_repo_path": "src/data/lib/prim/Agda/Builtin/Reflection/External.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 109,
"size": 396
}
|
open import Mockingbird.Forest using (Forest)
-- Russel’s Forest
module Mockingbird.Problems.Chapter15 {b ℓ} (forest : Forest {b} {ℓ}) where
open import Data.Empty using (⊥; ⊥-elim)
open import Data.Product using (_×_; _,_; ∃-syntax; proj₁; proj₂)
open import Data.Sum using (_⊎_; inj₁; inj₂)
open import Function using (_$_; flip; case_of_; _⇔_; Equivalence; mk⇔)
open import Function.Equivalence.Reasoning renaming (begin_ to ⇔-begin_; _∎ to _⇔-∎)
open import Level using (_⊔_)
open import Relation.Binary using (_Respects_)
open import Relation.Nullary using (¬_)
open import Relation.Unary using (Pred)
open Forest forest
open import Mockingbird.Forest.Birds forest
⇔-¬ : ∀ {a b} {A : Set a} {B : Set b} → A ⇔ B → (¬ A) ⇔ (¬ B)
⇔-¬ A⇔B = record
{ f = λ ¬A b → ¬A (A⇔B.g b)
; g = λ ¬B a → ¬B (A⇔B.f a)
; cong₁ = λ p → ≡.cong _ p
; cong₂ = λ p → ≡.cong _ p
} where
module A⇔B = Equivalence A⇔B
open import Relation.Binary.PropositionalEquality as ≡ using (cong)
⇔-↯ : ∀ {a} {A : Set a} → ¬ (A ⇔ (¬ A))
⇔-↯ {A = A} A⇔¬A = yes but no
where
_but_ = flip _$_
no : ¬ A
no A = Equivalence.f A⇔¬A A A
yes : A
yes = Equivalence.g A⇔¬A no
module _ {s} (Sings : Pred Bird s)
(respects : Sings Respects _≈_) where
private
-- TODO: move to Mockingbird.Forest.Axiom(.ExcludedMiddle)?
ExcludedMiddle : Set (b ⊔ s)
ExcludedMiddle = ∀ x → Sings x ⊎ ¬ Sings x
doubleNegation : ExcludedMiddle → ∀ x → ¬ ¬ Sings x → Sings x
doubleNegation LEM x ¬¬x-sings with LEM x
... | inj₁ x-sings = x-sings
... | inj₂ ¬x-sings = ⊥-elim $ ¬¬x-sings ¬x-sings
doubleNegation-⇔ : ExcludedMiddle → ∀ x → (¬ ¬ Sings x) ⇔ Sings x
doubleNegation-⇔ LEM x = mk⇔ (doubleNegation LEM x) λ x-sings ¬x-sings → ¬x-sings x-sings
respects-⇔ : ∀ {x y} → x ≈ y → Sings x ⇔ Sings y
respects-⇔ x≈y = mk⇔ (respects x≈y) (respects (sym x≈y))
problem₁ :
ExcludedMiddle
→ ∃[ a ] (∀ x → Sings (a ∙ x) ⇔ Sings (x ∙ x))
→ (∀ x → ∃[ x′ ] (∀ y → Sings (x′ ∙ y) ⇔ (¬ Sings (x ∙ y))))
→ ⊥
problem₁ LEM (a , is-a) neg =
let (a′ , is-a′) = neg a
a′a′-sings⇔¬a′a′-sings : Sings (a′ ∙ a′) ⇔ (¬ Sings (a′ ∙ a′))
a′a′-sings⇔¬a′a′-sings = ⇔-begin
Sings (a′ ∙ a′) ⇔⟨ is-a′ a′ ⟩
¬ Sings (a ∙ a′) ⇔⟨ ⇔-¬ $ is-a a′ ⟩
(¬ Sings (a′ ∙ a′)) ⇔-∎
a′a′-sings⇒¬a′a′-sings = Equivalence.f a′a′-sings⇔¬a′a′-sings
¬a′a′-sings⇒a′a′-sings = Equivalence.g a′a′-sings⇔¬a′a′-sings
↯ : ⊥
↯ = case LEM (a′ ∙ a′) of λ
{ (inj₁ a′a′-sings) → a′a′-sings⇒¬a′a′-sings a′a′-sings a′a′-sings
; (inj₂ ¬a′a′-sings) → ¬a′a′-sings (¬a′a′-sings⇒a′a′-sings ¬a′a′-sings)
}
in ↯
-- A constructive proof of Russel’s paradox, not using the LEM.
problem₁′ :
∃[ a ] (∀ x → Sings (a ∙ x) ⇔ Sings (x ∙ x))
→ (∀ x → ∃[ x′ ] (∀ y → Sings (x′ ∙ y) ⇔ (¬ Sings (x ∙ y))))
→ ⊥
problem₁′ (a , is-a) neg =
let (a′ , is-a′) = neg a
a′a′-sings⇔¬a′a′-sings : Sings (a′ ∙ a′) ⇔ (¬ Sings (a′ ∙ a′))
a′a′-sings⇔¬a′a′-sings = ⇔-begin
Sings (a′ ∙ a′) ⇔⟨ is-a′ a′ ⟩
(¬ Sings (a ∙ a′)) ⇔⟨ ⇔-¬ $ is-a a′ ⟩
(¬ Sings (a′ ∙ a′)) ⇔-∎
in ⇔-↯ a′a′-sings⇔¬a′a′-sings
problem₂ : ⦃ _ : HasSageBird ⦄
→ ExcludedMiddle
→ ∃[ N ] (∀ x → Sings x ⇔ (¬ Sings (N ∙ x)))
→ ⊥
problem₂ LEM (N , is-N) = isNotFond isFond
where
isFond : N IsFondOf (Θ ∙ N)
isFond = isSageBird N
isNotFond : ¬ N IsFondOf (Θ ∙ N)
isNotFond isFond with LEM (Θ ∙ N)
... | inj₁ ΘN-sings = Equivalence.f (is-N (Θ ∙ N)) ΘN-sings (respects (sym isFond) ΘN-sings)
... | inj₂ ¬ΘN-sings =
let N[ΘN]-sings : Sings (N ∙ (Θ ∙ N))
N[ΘN]-sings = doubleNegation LEM (N ∙ (Θ ∙ N)) $
Equivalence.f (⇔-¬ (is-N (Θ ∙ N))) ¬ΘN-sings
in Equivalence.f (is-N (Θ ∙ N)) (respects isFond N[ΘN]-sings) N[ΘN]-sings
-- A constructive proof of problem 2, not using the LEM.
problem₂′ : ⦃ _ : HasSageBird ⦄
→ ∃[ N ] (∀ x → Sings x ⇔ (¬ Sings (N ∙ x)))
→ ⊥
problem₂′ (N , is-N) = ⇔-↯ ΘN-sings⇔¬ΘN-sings
where
isFond : N IsFondOf (Θ ∙ N)
isFond = isSageBird N
ΘN-sings⇔¬ΘN-sings : Sings (Θ ∙ N) ⇔ (¬ Sings (Θ ∙ N))
ΘN-sings⇔¬ΘN-sings = ⇔-begin
Sings (Θ ∙ N) ⇔⟨ is-N (Θ ∙ N) ⟩
¬ Sings (N ∙ (Θ ∙ N)) ⇔⟨ ⇔-¬ $ respects-⇔ isFond ⟩
(¬ Sings (Θ ∙ N)) ⇔-∎
problem₃ : ⦃ _ : HasSageBird ⦄
→ ∃[ A ] (∀ x y → Sings (A ∙ x ∙ y) ⇔ (¬ Sings x × ¬ Sings y))
→ ⊥
problem₃ (A , is-A) = ↯
where
isFond : ∀ {x} → A ∙ x IsFondOf (Θ ∙ (A ∙ x))
isFond {x} = isSageBird (A ∙ x)
¬Θ[Ax]-sings : ∀ x → ¬ Sings (Θ ∙ (A ∙ x))
¬Θ[Ax]-sings x Θ[Ax]-sings =
let Ax[Θ[Ax]]-sings : Sings (A ∙ x ∙ (Θ ∙ (A ∙ x)))
Ax[Θ[Ax]]-sings = respects (sym isFond) Θ[Ax]-sings
¬Θ[Ax]-sings : ¬ Sings (Θ ∙ (A ∙ x))
¬Θ[Ax]-sings = proj₂ $ Equivalence.f (is-A x (Θ ∙ (A ∙ x))) Ax[Θ[Ax]]-sings
in ¬Θ[Ax]-sings Θ[Ax]-sings
¬¬x-sings : ∀ x → ¬ ¬ Sings x
¬¬x-sings x ¬x-sings =
let Ax[Θ[Ax]]-sings = Equivalence.g (is-A x (Θ ∙ (A ∙ x))) (¬x-sings , ¬Θ[Ax]-sings x)
Θ[Ax]-sings = respects isFond Ax[Θ[Ax]]-sings
in ¬Θ[Ax]-sings x Θ[Ax]-sings
↯ : ⊥
↯ = ¬¬x-sings (Θ ∙ (A ∙ A)) $ ¬Θ[Ax]-sings A
|
{
"alphanum_fraction": 0.4985196151,
"avg_line_length": 34.641025641,
"ext": "agda",
"hexsha": "d79cb0a04760ca3a772d5a83218f8044af1355ff",
"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/Problems/Chapter15.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/Problems/Chapter15.agda",
"max_line_length": 98,
"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/Problems/Chapter15.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": 2555,
"size": 5404
}
|
-- Disjoint sum type; also used as logical disjunction.
{-# OPTIONS --safe #-}
module Tools.Sum where
data _⊎_ (A B : Set) : Set where
inj₁ : A → A ⊎ B
inj₂ : B → A ⊎ B
-- Idempotency.
id : ∀ {A} → A ⊎ A → A
id (inj₁ x) = x
id (inj₂ x) = x
-- Symmetry.
sym : ∀ {A B} → A ⊎ B → B ⊎ A
sym (inj₁ x) = inj₂ x
sym (inj₂ x) = inj₁ x
|
{
"alphanum_fraction": 0.5384615385,
"avg_line_length": 15.3636363636,
"ext": "agda",
"hexsha": "751972d79d9800c873493fbc9ab836bffc2bf60f",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-02-15T19:42:19.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-01-26T14:55:51.000Z",
"max_forks_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "CoqHott/logrel-mltt",
"max_forks_repo_path": "Tools/Sum.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "CoqHott/logrel-mltt",
"max_issues_repo_path": "Tools/Sum.agda",
"max_line_length": 55,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "CoqHott/logrel-mltt",
"max_stars_repo_path": "Tools/Sum.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-17T16:13:53.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-06-21T08:39:01.000Z",
"num_tokens": 147,
"size": 338
}
|
mutual
record R (A : Set) : Set where
inductive
field
f₁ : A
f₂ : R′ A
record R′ (A : Set) : Set where
inductive
field
f : R A
|
{
"alphanum_fraction": 0.4880952381,
"avg_line_length": 12,
"ext": "agda",
"hexsha": "e90495cf68a77bb8b4ef3b6ff6d41c2d54ceaf34",
"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/Issue2916.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/Issue2916.agda",
"max_line_length": 33,
"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/Issue2916.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 63,
"size": 168
}
|
{-# OPTIONS --safe --experimental-lossy-unification #-}
module Cubical.Algebra.Polynomials.Multivariate.Equiv.Induced-Poly where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Data.Nat renaming (_+_ to _+n_; _·_ to _·n_)
open import Cubical.Data.Vec
open import Cubical.Data.Sigma
open import Cubical.Algebra.Ring
open import Cubical.Algebra.CommRing
open import Cubical.Algebra.Polynomials.Univariate.Base
open import Cubical.Algebra.Polynomials.Multivariate.Base
open import Cubical.Algebra.Polynomials.Multivariate.Properties
open import Cubical.Algebra.CommRing.Instances.MultivariatePoly
open Nth-Poly-structure
private variable
ℓ : Level
-----------------------------------------------------------------------------
-- Lift
open IsRingHom
makeCommRingHomPoly : (A' B' : CommRing ℓ) → (f : CommRingHom A' B') → (n : ℕ) → CommRingHom (PolyCommRing A' n) (PolyCommRing B' n)
fst (makeCommRingHomPoly A' B' (f , fcrhom) n) = Poly-Rec-Set.f A' n (Poly B' n) trunc
0P
(λ v a → base v (f a))
_Poly+_
Poly+-assoc
Poly+-Rid
Poly+-comm
(λ v → (cong (base v) (pres0 fcrhom)) ∙ (base-0P v))
λ v a b → (base-Poly+ v (f a) (f b)) ∙ (cong (base v) (sym (pres+ fcrhom a b)))
snd (makeCommRingHomPoly A' B' (f , fcrhom) n) = makeIsRingHom
(cong (base (replicate zero)) (pres1 fcrhom))
(λ P Q → refl)
(Poly-Ind-Prop.f A' n _ (λ P p q i Q j → trunc _ _ (p Q) (q Q) i j)
(λ Q → refl)
(λ v a → Poly-Ind-Prop.f A' n _ (λ _ → trunc _ _)
refl
(λ v' a' → cong (base (v +n-vec v')) (pres· fcrhom a a'))
λ {U V} ind-U ind-V → cong₂ _Poly+_ ind-U ind-V)
λ {U V} ind-U ind-V Q → cong₂ _Poly+_ (ind-U Q) (ind-V Q))
-----------------------------------------------------------------------------
-- Lift preserve equivalence
open RingEquivs
lift-equiv-poly : (A' B' : CommRing ℓ) → (e : CommRingEquiv A' B') → (n : ℕ) → CommRingEquiv (PolyCommRing A' n) (PolyCommRing B' n)
fst (lift-equiv-poly A' B' e n) = isoToEquiv is
where
et = fst e
fcrh = snd e
f = fst et
g = invEq et
gcrh : IsRingHom (snd (CommRing→Ring B')) g (snd (CommRing→Ring A'))
gcrh = isRingHomInv (et , fcrh)
is : Iso _ _
Iso.fun is = fst (makeCommRingHomPoly A' B' (f , fcrh) n)
Iso.inv is = fst (makeCommRingHomPoly B' A' (g , gcrh) n)
Iso.rightInv is = (Poly-Ind-Prop.f B' n _ (λ _ → trunc _ _)
refl
(λ v a → cong (base v) (secEq et a))
λ {U V} ind-U ind-V → cong₂ _Poly+_ ind-U ind-V)
Iso.leftInv is = (Poly-Ind-Prop.f A' n _ (λ _ → trunc _ _)
refl
(λ v a → cong (base v) (retEq et a))
λ {U V} ind-U ind-V → cong₂ _Poly+_ ind-U ind-V)
snd (lift-equiv-poly A' B' e n) = snd (makeCommRingHomPoly A' B' (fst (fst e) , snd e) n)
|
{
"alphanum_fraction": 0.5005847953,
"avg_line_length": 42.2222222222,
"ext": "agda",
"hexsha": "95fa9a44c6b75e6f9b4c265b0357d4735c49a580",
"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/Equiv/Induced-Poly.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/Equiv/Induced-Poly.agda",
"max_line_length": 132,
"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/Equiv/Induced-Poly.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 981,
"size": 3420
}
|
module FFI where
open import Common.Prelude
_+'_ : Nat → Nat → Nat
zero +' y = y
suc x +' y = suc (x +' y)
{-# COMPILE GHC _+'_ = (+) :: Integer -> Integer -> Integer #-}
-- on-purpose buggy haskell implementation!
_+''_ : Nat → Nat → Nat
zero +'' y = y
suc x +'' y = suc (x +'' y)
{-# COMPILE GHC _+''_ = (-) :: Integer -> Integer -> Integer #-}
listMap : {A B : Set} → (A → B) → List A → List B
listMap f [] = []
listMap f (x ∷ xs) = f x ∷ listMap f xs
{-# COMPILE GHC listMap as listMap #-}
{-# FOREIGN GHC
agdaMap :: (a -> b) -> [a] -> [b]
agdaMap = listMap () ()
#-}
open import Common.IO
open import Common.Unit
_>>_ : {A B : Set} → IO A → IO B → IO B
m >> m' = m >>= λ _ → m'
main : IO Unit
main = do
printNat (10 +' 5)
printNat (30 +'' 7)
|
{
"alphanum_fraction": 0.5314136126,
"avg_line_length": 20.6486486486,
"ext": "agda",
"hexsha": "a5ad01121fdd253056e6d637cc58ca42e0d06c77",
"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/Compiler/simple/FFI.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/Compiler/simple/FFI.agda",
"max_line_length": 64,
"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/Compiler/simple/FFI.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": 274,
"size": 764
}
|
------------------------------------------------------------------------------
-- Testing an implicit argument for natural numbers induction
------------------------------------------------------------------------------
{-# OPTIONS --allow-unsolved-metas #-}
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOT.PA.Inductive.ImplicitArgumentInductionSL where
open import Data.Nat renaming ( suc to succ )
open import Relation.Binary.PropositionalEquality
------------------------------------------------------------------------------
succCong : ∀ {m n} → m ≡ n → succ m ≡ succ n
succCong refl = refl
-- N.B. It is not possible to use an implicit argument in the
-- inductive hypothesis.
ℕ-ind : (A : ℕ → Set) → A zero → (∀ {n} → A n → A (succ n)) → ∀ n → A n
ℕ-ind A A0 h zero = A0
ℕ-ind A A0 h (succ n) = h (ℕ-ind A A0 h n)
+-assoc : ∀ m n o → m + n + o ≡ m + (n + o)
+-assoc m n o = ℕ-ind A A0 is m
where
A : ℕ → Set
A i = i + n + o ≡ i + (n + o)
A0 : A zero
A0 = refl
is : ∀ {i} → A i → A (succ i)
is ih = succCong ih
|
{
"alphanum_fraction": 0.4568527919,
"avg_line_length": 31.1052631579,
"ext": "agda",
"hexsha": "35c59d14b4932ff3203bf69f203a736d2a110128",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z",
"max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/fotc",
"max_forks_repo_path": "notes/FOT/PA/Inductive/ImplicitArgumentInductionSL.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/fotc",
"max_issues_repo_path": "notes/FOT/PA/Inductive/ImplicitArgumentInductionSL.agda",
"max_line_length": 78,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "notes/FOT/PA/Inductive/ImplicitArgumentInductionSL.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": 316,
"size": 1182
}
|
{-# OPTIONS --no-main #-}
postulate
easy : (A : Set₁) → A
record R₁ : Set₂ where
field
A : Set₁
record R₂ : Set₂ where
field
r₁ : R₁
a : R₁.A r₁
r₁ : R₁
r₁ .R₁.A = Set
r₂ : R₂
r₂ = λ where
.R₂.r₁ → r₁
.R₂.a → easy _
|
{
"alphanum_fraction": 0.5265306122,
"avg_line_length": 11.1363636364,
"ext": "agda",
"hexsha": "83bcf4bdefd325c552d13a2538a69d82d54b34fc",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Compiler/simple/Issue2918-Inlining.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Compiler/simple/Issue2918-Inlining.agda",
"max_line_length": 25,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Compiler/simple/Issue2918-Inlining.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": 112,
"size": 245
}
|
{-# OPTIONS --rewriting #-}
open import Agda.Builtin.Unit
open import Agda.Builtin.Equality
open import Agda.Builtin.Equality.Rewrite
data Box : Set → Set₁ where
box : (A : Set) → Box A
data D (A : Set) : Set₁ where
c : A → Box A → D A
postulate
any : {A : Set} → A
one : {A : Set} → D A
rew : ∀ A → c any (box A) ≡ one
-- Jesper, 2020-06-17: Ideally Agda should reject the above rewrite
-- rule, since it causes reduction to be unstable under eta-conversion
works : c any (box ⊤) ≡ c tt (box ⊤)
works = refl
-- However, currently it is accepted, breaking subject reduction:
{-# REWRITE rew #-}
fails : c any (box ⊤) ≡ c tt (box ⊤)
fails = refl
|
{
"alphanum_fraction": 0.6450151057,
"avg_line_length": 23.6428571429,
"ext": "agda",
"hexsha": "fc7d51ec3adcd2ee9ce82be65f5a220905ca96e5",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "shlevy/agda",
"max_forks_repo_path": "test/Bugs/Issue4755b.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/Bugs/Issue4755b.agda",
"max_line_length": 70,
"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/Bugs/Issue4755b.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": 218,
"size": 662
}
|
{-# OPTIONS --cubical --safe #-}
module Cubical.Data.Strict2Group.Explicit.ToXModule where
open import Cubical.Foundations.Prelude hiding (comp)
open import Cubical.Data.Group.Base
open import Cubical.Data.XModule.Base
open import Cubical.Data.Group.Action.Base
open import Cubical.Data.Sigma
open import Cubical.Data.Strict2Group.Explicit.Base
open import Cubical.Data.Strict2Group.Explicit.Interface
Strict2GroupExp→XModuleExp : {ℓ : Level} (S : Strict2GroupExp ℓ) → (XModuleExp ℓ)
Strict2GroupExp→XModuleExp (strict2groupexp C₀ C₁ s t i ∘ si ti s∘ t∘ isMorph∘ assoc∘ lUnit∘ rUnit∘) =
record
{ G = C₀ ;
H = ks ;
τ = tₖₛ ;
α = laction
(λ g h → lAction.act lad (id g) h)
(λ h →
ΣPathP (p1 h ,
isProp→PathP
(λ i → snd (P (p1 h i)))
(kerIsNormal {G = C₁} {H = C₀} s (id 1₀) h)
(kerIsNormal {G = C₁} {H = C₀} s 1₁ h))
∙ lAction.identity lad h)
(λ g g' h →
ΣPathP (p2 g g' h ,
isProp→PathP
(λ i → snd (P (p2 g g' h i)))
(kerIsNormal {G = C₁} {H = C₀} s (id (g ∙₀ g')) h)
(kerIsNormal {G = C₁} {H = C₀} s (id g ∙₁ id g') h))
∙ (lAction.coh lad (id g) (id g') h))
λ g h h' → lAction.hom lad (id g) h h' ;
equivar = equivar ;
peiffer = pf }
where
S = strict2groupexp C₀ C₁ s t i ∘ si ti s∘ t∘ isMorph∘ assoc∘ lUnit∘ rUnit∘
open S2GInterface S
-- the kernel of the source map
kers = ker {G = C₁} {H = C₀} s
-- the family of propositions ker(x) ≡ 1
P = Subgroup.typeProp kers
-- kernel coerced to group
ks = Subgroup→Group {G = C₁} kers
-- the left adjoint action of hom on its normal subgroup ker(src)
lad : lAction C₁ ks
lad = lActionAdjSubgroup C₁ kers (kerIsNormal {G = C₁} {H = C₀} s)
-- the target map restricted to ker(src)
tₖₛ = restrictGroupMorph {G = C₁} {H = C₀} t kers
tarₖₛ = fst tₖₛ
tar∙ₖₛ = snd tₖₛ
-- multiplication, inverse in ker src
_∙₁ₖₛ_ = isGroup.comp (Group.groupStruc ks)
ks⁻¹ = isGroup.inv (Group.groupStruc ks)
-- group laws in ker(src)
lUnitₖₛ = isGroup.lUnit (Group.groupStruc ks)
rUnitₖₛ = isGroup.rUnit (Group.groupStruc ks)
rCancelₖₛ = isGroup.rCancel (Group.groupStruc ks)
assocₖₛ = isGroup.assoc (Group.groupStruc ks)
1ₖₛ = isGroup.id (Group.groupStruc ks)
-- Composition restricted to ks×₀ks
∘ₖₛ : (g f : Group.type ks) → (src (fst g) ≡ tarₖₛ f) → Group.type ks
∘ₖₛ g f coh = (⊙' (fst g) (fst f) coh) , ((src⊙' (fst g) (fst f) coh) ∙ snd f)
-- right and left unit law for restricted ∘
abstract
rUnit∘ₖₛ : (h : Group.type ks) →
∘ₖₛ h (id (src (fst h)) , si (src (fst h)) ∙ snd h)
(sym (ti (src (fst h)))) ≡ h
rUnit∘ₖₛ h = ΣPathP (rUnit∘ (fst h) ,
isProp→PathP
(λ i → snd (P (rUnit∘ (fst h) i)))
(src⊙' (fst h) (id (src (fst h))) (sym (ti (src (fst h)))) ∙ si (src (fst h)) ∙ snd h)
(snd h))
abstract
lUnit∘ₖₛ : (h : Group.type ks) →
(⊙ (co (id (tar (fst h))) (fst h) (si (tar (fst h)))) , (src⊙' (id (tar (fst h))) (fst h) (si (tar (fst h)))) ∙ snd h) ≡ h
lUnit∘ₖₛ h = ΣPathP (
lUnit∘ (fst h) ,
isProp→PathP
(λ i → snd (P (lUnit∘ (fst h) i))) (src⊙' (id (tar (fst h))) (fst h) (si (tar (fst h))) ∙ snd h) (snd h))
-- two proofs used in equivariant
abstract
p1 = λ (h : Group.type ks) → cong (λ z → (z ∙₁ fst h) ∙₁ (C₁⁻¹ z)) (morphId {G = C₀} {H = C₁} i)
p2 = λ (g g' : Group.type C₀) (h : Group.type ks) → cong (λ z → (z ∙₁ fst h) ∙₁ (C₁⁻¹ z)) (id∙₀ g g')
equivar = λ g h → tar∙₁ (id g ∙₁ fst h) (C₁⁻¹ (id g)) ∙∙
cong (_∙₀ (tar (C₁⁻¹ (id g)))) (tar∙₁ (id g) (fst h)) ∙∙
cong (((tar (id g)) ∙₀ (tar (fst h))) ∙₀_) (morphInv {G = C₁} {H = C₀} t (id g)) ∙
cong (λ z → (z ∙₀ (tar (fst h))) ∙₀ (C₀⁻¹ z)) (ti g)
-- the peiffer identity, proved according to
-- ixh'ix- ≡ eixh'ix- ≡ hh-ixh'ix- ≡ hh-ixh'ixe
pf : (h h' : Group.type ks) → lAction.act lad (id (tarₖₛ h)) h' ≡ (h ∙₁ₖₛ h') ∙₁ₖₛ (ks⁻¹ h)
pf h h' =
ixh'ix-
≡⟨ sym (lUnitₖₛ ixh'ix-) ⟩
1ₖₛ ∙₁ₖₛ ixh'ix-
≡⟨ cong (_∙₁ₖₛ ixh'ix-) (sym (rCancelₖₛ h)) ⟩
(h ∙₁ₖₛ h-) ∙₁ₖₛ ixh'ix-
≡⟨ assocₖₛ h h- ixh'ix- ⟩
h ∙₁ₖₛ (h- ∙₁ₖₛ ixh'ix-)
≡⟨ cong (h ∙₁ₖₛ_) (
h- ∙₁ₖₛ ixh'ix-
≡⟨ cong (h- ∙₁ₖₛ_) (sym (rUnit∘ₖₛ ixh'ix-)) ⟩
h- ∙₁ₖₛ (∘ₖₛ ixh'ix- (is ixh'ix-) (src≡tarIdSrc (fst ixh'ix-)))
≡⟨ cong (_∙₁ₖₛ (∘ₖₛ ixh'ix- (is ixh'ix-) (src≡tarIdSrc (fst ixh'ix-)))) (sym (lUnit∘ₖₛ h-)) ⟩
(⊙ ix-⊙h-₁ , (src⊙ ix-⊙h-₁) ∙ snd h-) ∙₁ₖₛ ∘ₖₛ ixh'ix- (is ixh'ix-) (src≡tarIdSrc (fst ixh'ix-))
≡⟨ ΣPathP (q3 , isProp→PathP (λ i → snd (P (q3 i))) (snd ((ix-∘h-₁ , (src⊙ ix-⊙h-₁) ∙ snd h-) ∙₁ₖₛ ∘ₖₛ ixh'ix- (is ixh'ix-) (src≡tarIdSrc (fst ixh'ix-)))) (src⊙' (ix- ∙₁ fst ixh'ix-) (h- .fst ∙₁ fst (is ixh'ix-)) q1 ∙ q2)) ⟩
(⊙ (co (ix- ∙₁ fst ixh'ix-) (h- .fst ∙₁ fst (is ixh'ix-)) q1)) , (src⊙' (ix- ∙₁ fst ixh'ix-) (h- .fst ∙₁ fst (is ixh'ix-)) q1) ∙ q2
≡⟨ ΣPathP (q18 , (isProp→PathP (λ j → snd (P (q18 j))) ((src⊙' (ix- ∙₁ fst ixh'ix-) (h- .fst ∙₁ fst (is ixh'ix-)) q1) ∙ q2) ((src⊙' (ix- ∙₁ fst ixh'ix-) (h- .fst ∙₁ 1₁) (q5 ∙ q8)) ∙ q9))) ⟩
(⊙ (co (ix- ∙₁ fst ixh'ix-) (h- .fst ∙₁ 1₁) (q5 ∙ q8))) ,
(src⊙' (ix- ∙₁ fst ixh'ix-) (h- .fst ∙₁ 1₁) (q5 ∙ q8)) ∙ q9
≡⟨ ΣPathP (q17 , (isProp→PathP (λ j → snd (P (q17 j))) ((src⊙' (ix- ∙₁ fst ixh'ix-) (h- .fst ∙₁ 1₁) (q5 ∙ q8)) ∙ q9) ((src⊙' (ix- ∙₁ fst ixh'ix-) (fst h-) q5) ∙ snd h-))) ⟩
(⊙ (co (ix- ∙₁ fst ixh'ix-) (h- .fst) q5)) ,
(src⊙' (ix- ∙₁ fst ixh'ix-) (h- .fst) q5) ∙ snd h-
≡⟨ ΣPathP (q16 , isProp→PathP (λ j → snd (P (q16 j))) ((src⊙' (ix- ∙₁ fst ixh'ix-) (fst h-) q5) ∙ snd h-) ((src⊙' (ix- ∙₁ fst ixh'ix-) (1₁ ∙₁ h- .fst) (q5 ∙ q6)) ∙ q7)) ⟩
(⊙ (co (ix- ∙₁ fst ixh'ix-) (1₁ ∙₁ h- .fst) (q5 ∙ q6))) ,
(src⊙' (ix- ∙₁ fst ixh'ix-) (1₁ ∙₁ h- .fst) (q5 ∙ q6)) ∙ q7
≡⟨ ΣPathP (q15 , (isProp→PathP (λ j → snd (P (q15 j))) ((src⊙' (ix- ∙₁ fst ixh'ix-) (1₁ ∙₁ h- .fst) (q5 ∙ q6)) ∙ q7) ((src⊙' ((fst h') ∙₁ ix-) (1₁ ∙₁ h- .fst) q4) ∙ q7))) ⟩
(⊙ (co ((fst h') ∙₁ ix-) (1₁ ∙₁ h- .fst) q4)) ,
(src⊙' ((fst h') ∙₁ ix-) (1₁ ∙₁ h- .fst) q4) ∙ q7
≡⟨ ΣPathP (q14 , isProp→PathP (λ j → snd (P (q14 j))) ((src⊙' ((fst h') ∙₁ ix-) (1₁ ∙₁ h- .fst) q4) ∙ q7) q12) ⟩
(⊙ (co (fst h') 1₁ ((snd h') ∙ (sym tar1₁≡1₀)))) ∙₁ ix-∘h-₁ , q12
≡⟨ ΣPathP (q11 , isProp→PathP (λ j → snd (P (q11 j))) q12 q13) ⟩
h' .fst ∙₁ ix-∘h-₁ , q13
≡⟨ ΣPathP (q10 , isProp→PathP (λ j → snd (P (q10 j)))
(src∙₁ (fst h') ix-∘h-₁ ∙∙
(λ i₁ → snd h' i₁ ∙₀ src ix-∘h-₁) ∙∙
lUnit₀ (src ix-∘h-₁) ∙∙
src⊙ ix-⊙h-₁ ∙∙
snd h-)
(Subgroup.compClosed kers h' h-)) ⟩
h' .fst ∙₁ h- .fst , Subgroup.compClosed kers h' h- ≡⟨ refl ⟩
(h' ∙₁ₖₛ h-) ≡⟨ refl ⟩ refl ) ⟩
h ∙₁ₖₛ (h' ∙₁ₖₛ h-)
≡⟨ sym (assocₖₛ h h' h-) ⟩
(h ∙₁ₖₛ h') ∙₁ₖₛ h- ≡⟨ refl ⟩ refl
where
-- some abbreviations
h- = ks⁻¹ h -- h⁻¹
x = tarₖₛ h -- target of h
x- = tarₖₛ h- -- target of h⁻¹
x-≡x⁻¹ : x- ≡ C₀⁻¹ x
x-≡x⁻¹ = morphInv {G = ks} {H = C₀} tₖₛ h
ix = id x -- i (t h)
ix- = id x- -- i (t h⁻¹)
ixh'ix- : Group.type ks -- abv. for (ix ∙₁ h') ∙₁ ix-
ixh'ix- = lAction.act lad (id (tarₖₛ h)) h'
is : Group.type ks → Group.type ks -- abv. for i(s _) in ks
is h = id (src (fst h)) , (si (src (fst h))) ∙ snd h
ix-⊙h-₁ = co ix- (fst h-) (si x-)
ix-∘h-₁ = ⊙ ix-⊙h-₁
-- some identities
ix-≡ix⁻¹ : ix- ≡ (C₁⁻¹ ix)
ix-≡ix⁻¹ = (cong id x-≡x⁻¹) ∙ (morphInv {G = C₀} {H = C₁} i x)
ish≡1ₖₛ : (h : Group.type ks) → (is h) ≡ 1ₖₛ
ish≡1ₖₛ h =
ΣPathP
(cong (fst i) (snd h) ∙ id1₀≡1₁ ,
isProp→PathP
(λ j → snd (P (((λ k → id(snd h k)) ∙ id1₀≡1₁) j)))
(si (src (fst h)) ∙ snd h)
(Subgroup.subId kers))
-- t h⁻¹ ≡ (t h)⁻¹
th-≡x- = morphInv {G = ks} {H = C₀} tₖₛ h
-----------------------------------------
-- here comes particles of the main proof
-----------------------------------------
-- coherence condition for the composition
-- ∘ (ix- ∙₁ fst ixh'ix-) (h- .fst ∙₁ fst (is ixh'ix-))
q1 =
src∙₁ ix- (fst ixh'ix-) ∙∙
cong (_∙₀ src (fst ixh'ix-)) (si x-) ∙∙
cong (x- ∙₀_) (snd ixh'ix-) ∙∙
rUnit₀ x- ∙∙
th-≡x- ∙∙
sym (rUnit₀ (C₀⁻¹ x)) ∙∙
cong ((C₀⁻¹ x) ∙₀_) (sym ((ti ((src (fst ixh'ix-)))) ∙ (snd ixh'ix-))) ∙∙
cong (_∙₀ (tar (fst (is ixh'ix-)))) (sym th-≡x-) ∙∙
sym (tar∙₁ (fst h-) (fst (is ixh'ix-)))
-- to show that ∘ q1 is in ks, p2 is proof that f is in ks
q2 = src∙₁ (fst h-) (fst (is ixh'ix-)) ∙∙
cong (_∙₀ (src (fst (is ixh'ix-)))) (snd h-) ∙∙
lUnit₀ (src (fst (is ixh'ix-))) ∙∙
cong (λ z → src (fst z)) (ish≡1ₖₛ ixh'ix-) ∙∙
snd 1ₖₛ
-- (∘ (si x-)) ∙₁ (fst (∘ₖₛ (src≡tarIdSrc (fst ixh'ix-)))) ≡ ∘ q1
q3 =
(ix-∘h-₁ ∙₁ fst (∘ₖₛ ixh'ix- (is ixh'ix-) (src≡tarIdSrc (fst ixh'ix-)))) ≡⟨ refl ⟩
⊙ ix-⊙h-₁ ∙₁ ⊙ co3
≡⟨ sym (isMorph⊙ ix-⊙h-₁ co3) ⟩
⊙ (ix-⊙h-₁ ∙Co co3)
≡⟨ ⊙≡c (ix-⊙h-₁ ∙Co co3) q1 ⟩
⊙ co1 ≡⟨ refl ⟩ refl
where
co1 = co (ix- ∙₁ fst ixh'ix-) (fst h- ∙₁ fst (is ixh'ix-)) q1
co3 = co (fst ixh'ix-) (fst (is ixh'ix-)) (src≡tarIdSrc (fst ixh'ix-))
-- coherence condition for ∘ {g = ?} {f = 1₁ ∙₁ h- .fst} (_∙ q6)
q6 = sym (lUnit₀ (tar (fst h-))) ∙∙
sym (cong (_∙₀ (tar (fst h-))) (morphId {G = C₁} {H = C₀} t)) ∙∙
sym (tar∙₁ 1₁ (fst h-))
-- coherence condition for ∘ {g = (fst h') ∙₁ ix- } {f = 1₁ ∙₁ h- .fst } q4
q4 =
src∙₁ (fst h') ix- ∙∙
(cong (_∙₀ src ix-) (snd h')) ∙∙
lUnit₀ (src ix-) ∙∙
si x- ∙∙
q6
-- coherence condition for ∘ {g = ix- ∙₁ fst ixh'ix- } {f = ?} (q5 ∙ ?)
q5 =
src∙₁ ix- (fst ixh'ix-) ∙∙
cong ((src ix-) ∙₀_) (snd ixh'ix-) ∙∙
rUnit₀ (src ix-) ∙
si x-
-- proof that 1₁ ∙₁ h- .fst : ker s
q7 = src∙₁ 1₁ (fst h-) ∙∙
cong (src 1₁ ∙₀_) (snd h-) ∙∙
rUnit₀ (src 1₁) ∙ src1₁≡1₀
-- proof that s x- ≡ t (h- .fst ∙₁ 1₁)
q8 = sym (rUnit₀ (tar (fst h-))) ∙∙
(sym (cong ((tar (fst h-)) ∙₀_) tar1₁≡1₀)) ∙∙
(sym (tar∙₁ (fst h-) 1₁))
-- proof that h- .fst ∙₁ 1₁ : ker s
q9 = src∙₁ (fst h-) 1₁ ∙∙
cong (_∙₀ (src 1₁)) (snd h-) ∙∙
lUnit₀ (src 1₁) ∙
src1₁≡1₀
-- proof that (h' .fst ∙₁ ix-∘h-₁) ≡ (h' .fst ∙₁ h- .fst)
q10 = cong (h' .fst ∙₁_) (lUnit∘ (fst h-))
-- proof that (h'∘1₁)∙₁ ix-∘h-₁ ≡ h' ∙₁ ix-∘h-₁
q11 = cong (_∙₁ ix-∘h-₁)
(⊙≡ (co (fst h') 1₁ (snd h' ∙ sym tar1₁≡1₀)) (id (src (fst h')) , sym id1₀≡1₁ ∙ sym (cong id (snd h'))) ∙
rUnit⊙c
(fst h')
((snd h' ∙ (λ i₁ → tar1₁≡1₀ (~ i₁))) ∙ cong tar ((λ i₁ → id1₀≡1₁ (~ i₁)) ∙ (λ i₁ → id (snd h' (~ i₁))))))
q12 =
src∙₁ ((⊙ (co (fst h') 1₁ ((snd h') ∙ sym tar1₁≡1₀)))) ix-∘h-₁ ∙∙
cong (_∙₀ (src ix-∘h-₁)) ((src⊙' (fst h') 1₁ ((snd h') ∙ (sym tar1₁≡1₀))) ∙ src1₁≡1₀) ∙∙
lUnit₀ (src ix-∘h-₁) ∙
src⊙' ix- (fst h-) (si x-) ∙ snd h-
q13 = src∙₁ (fst h') ix-∘h-₁ ∙∙
cong (_∙₀ (src ix-∘h-₁)) (snd h') ∙∙
lUnit₀ (src ix-∘h-₁) ∙∙
src⊙' ix- (fst h-) (si x-) ∙∙
snd h-
q14 =
⊙' ((fst h') ∙₁ ix-) (1₁ ∙₁ h- .fst) q4
≡⟨ ⊙≡c~ q4 (𝒸 (co (fst h') 1₁ (snd h' ∙ (λ i₁ → tar1₁≡1₀ (~ i₁))) ∙Co ix-⊙h-₁)) ⟩
⊙' ((fst h') ∙₁ ix-) (1₁ ∙₁ (fst h-)) (𝒸 (co (fst h') 1₁ (snd h' ∙ (λ i₁ → tar1₁≡1₀ (~ i₁))) ∙Co ix-⊙h-₁))
≡⟨ isMorph⊙ (co (fst h') 1₁ (snd h' ∙ (λ i₁ → tar1₁≡1₀ (~ i₁)))) ix-⊙h-₁ ⟩
-- (⊙' (fst h') 1₁ (snd h' ∙ (λ i₁ → tar1₁≡1₀ (~ i₁)))) ∙₁ ix-∘h-₁ ≡⟨ refl ⟩
refl
q15 = ≡⊙c* (q5 ∙ q6)
(cong (ix- ∙₁_) (assoc₁ ix (fst h') (C₁⁻¹ ix)) ∙∙
sym (assoc₁ ix- ix (fst h' ∙₁ C₁⁻¹ ix)) ∙∙
cong (λ z → (z ∙₁ ix) ∙₁ (fst h' ∙₁ C₁⁻¹ ix)) ix-≡ix⁻¹ ∙∙
cong (_∙₁ (fst h' ∙₁ C₁⁻¹ ix)) (lCancel₁ ix) ∙∙
lUnit₁ (fst h' ∙₁ C₁⁻¹ ix) ∙
cong (fst h' ∙₁_) (sym ix-≡ix⁻¹))
q4
{- use this to see what's going on
⊙ co1
≡⟨ ≡⊙c* (q5 ∙ q6)
((cong (ix- ∙₁_) (assoc₁ ix (fst h') (C₁⁻¹ ix))) ∙
sym (assoc₁ ix- ix (fst h' ∙₁ C₁⁻¹ ix)) ∙
cong (λ z → (z ∙₁ ix) ∙₁ (fst h' ∙₁ C₁⁻¹ ix)) ix-≡ix⁻¹ ∙
cong (_∙₁ (fst h' ∙₁ C₁⁻¹ ix)) (lCancel₁ ix) ∙
(lUnit₁ (fst h' ∙₁ C₁⁻¹ ix)) ∙
(cong (fst h' ∙₁_) (sym ix-≡ix⁻¹)))
q4 ⟩
⊙ co2 ≡⟨ refl ⟩ refl
where
co1 = co (ix- ∙₁ (fst ixh'ix-)) (1₁ ∙₁ (fst h-)) (q5 ∙ q6)
co2 = co ((fst h') ∙₁ ix-) (1₁ ∙₁ (fst h-)) q4 -}
q16 = ⊙≡c* q5 (sym (lUnit₁ (fst h-))) (q5 ∙ q6)
{- use this to see what's going on
⊙ co1
≡⟨ ⊙≡c* q5 (sym (lUnit₁ (fst h-))) (q5 ∙ q6) ⟩
⊙ co2 ≡⟨ refl ⟩ refl
where
co1 = co (ix- ∙₁ fst ixh'ix-) (fst h-) q5
co2 = co (ix- ∙₁ fst ixh'ix-) (1₁ ∙₁ fst h-) (q5 ∙ q6) -}
q17 = ⊙≡c* (q5 ∙ q8) (rUnit₁ (fst h-)) q5
{- use this to see what's going on
⊙ co1
≡⟨ ⊙≡c* (q5 ∙ q8) (rUnit₁ (fst h-)) q5 ⟩
⊙ co2 ≡⟨ refl ⟩ refl
where
co1 = co (ix- ∙₁ fst ixh'ix-) (fst h- ∙₁ 1₁) (q5 ∙ q8)
co2 = co (ix- ∙₁ fst ixh'ix-) (fst h-) q5 -}
q18 = ⊙≡c* q1 (cong (fst h- ∙₁_) ((cong id (snd ixh'ix-)) ∙ id1₀≡1₁)) (q5 ∙ q8)
{- use this to see what's going on
⊙ co1 ≡⟨ ⊙≡c* q1 (cong (fst h- ∙₁_)
((cong id (snd ixh'ix-)) ∙ id1₀≡1₁))
(q5 ∙ q8) ⟩
⊙ co2 ≡⟨ refl ⟩ refl
where
co1 = co (ix- ∙₁ fst ixh'ix-) (fst h- ∙₁ (fst (is ixh'ix-))) q1
co2 = co (ix- ∙₁ fst ixh'ix-) (fst h- ∙₁ 1₁) (q5 ∙ q8) -}
|
{
"alphanum_fraction": 0.4049800923,
"avg_line_length": 47.6596385542,
"ext": "agda",
"hexsha": "68aa37c254e9924d7195f4ec03cf4127b501cdb4",
"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": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Schippmunk/cubical",
"max_forks_repo_path": "Cubical/Data/Strict2Group/Explicit/ToXModule.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a",
"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": "Schippmunk/cubical",
"max_issues_repo_path": "Cubical/Data/Strict2Group/Explicit/ToXModule.agda",
"max_line_length": 242,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Schippmunk/cubical",
"max_stars_repo_path": "Cubical/Data/Strict2Group/Explicit/ToXModule.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 7048,
"size": 15823
}
|
module Test.Numeral where
import Lvl
open import Relator.Equals{Lvl.𝟎}
module One where
test0 : (0 mod 1) ≡ 0
test0 = [≡]-intro
test1 : (1 mod 1) ≡ 0
test1 = [≡]-intro
test2 : (2 mod 1) ≡ 0
test2 = [≡]-intro
test3 : (3 mod 1) ≡ 0
test3 = [≡]-intro
test4 : (4 mod 1) ≡ 0
test4 = [≡]-intro
test5 : (5 mod 1) ≡ 0
test5 = [≡]-intro
test6 : (6 mod 1) ≡ 0
test6 = [≡]-intro
test7 : (7 mod 1) ≡ 0
test7 = [≡]-intro
test8 : (8 mod 1) ≡ 0
test8 = [≡]-intro
test9 : (9 mod 1) ≡ 0
test9 = [≡]-intro
test10 : (10 mod 1) ≡ 0
test10 = [≡]-intro
test11 : (11 mod 1) ≡ 0
test11 = [≡]-intro
module Two where
test0 : (0 mod 2) ≡ 0
test0 = [≡]-intro
test1 : (1 mod 2) ≡ 1
test1 = [≡]-intro
test2 : (2 mod 2) ≡ 0
test2 = [≡]-intro
test3 : (3 mod 2) ≡ 1
test3 = [≡]-intro
test4 : (4 mod 2) ≡ 0
test4 = [≡]-intro
test5 : (5 mod 2) ≡ 1
test5 = [≡]-intro
test6 : (6 mod 2) ≡ 0
test6 = [≡]-intro
test7 : (7 mod 2) ≡ 1
test7 = [≡]-intro
test8 : (8 mod 2) ≡ 0
test8 = [≡]-intro
test9 : (9 mod 2) ≡ 1
test9 = [≡]-intro
test10 : (10 mod 2) ≡ 0
test10 = [≡]-intro
test11 : (11 mod 2) ≡ 1
test11 = [≡]-intro
module Three where
test0 : (0 mod 3) ≡ 0
test0 = [≡]-intro
test1 : (1 mod 3) ≡ 1
test1 = [≡]-intro
test2 : (2 mod 3) ≡ 2
test2 = [≡]-intro
test3 : (3 mod 3) ≡ 0
test3 = [≡]-intro
test4 : (4 mod 3) ≡ 1
test4 = [≡]-intro
test5 : (5 mod 3) ≡ 2
test5 = [≡]-intro
test6 : (6 mod 3) ≡ 0
test6 = [≡]-intro
test7 : (7 mod 3) ≡ 1
test7 = [≡]-intro
test8 : (8 mod 3) ≡ 2
test8 = [≡]-intro
test9 : (9 mod 3) ≡ 0
test9 = [≡]-intro
test10 : (10 mod 3) ≡ 1
test10 = [≡]-intro
test11 : (11 mod 3) ≡ 2
test11 = [≡]-intro
|
{
"alphanum_fraction": 0.4581589958,
"avg_line_length": 16.6260869565,
"ext": "agda",
"hexsha": "9adc90b1de6c4cbc7aa350504c770d5912987b96",
"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/Tests/Numeral.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/Tests/Numeral.agda",
"max_line_length": 33,
"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/Tests/Numeral.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": 938,
"size": 1912
}
|
{-# OPTIONS --without-K --safe #-}
module Relation.Binary.PropositionalEquality.FasterReasoning {a} {A : Set a} where
open import Relation.Binary.PropositionalEquality
infix 3 _∎
infixr 2 _≡⟨⟩_ step-≡ step-≡˘
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
step-≡ : (x {y z} : A) → y ≡ z → x ≡ y → x ≡ z
step-≡ _ y≡z x≡y = trans x≡y y≡z
syntax step-≡ x y≡z x≡y = x ≡⟨ x≡y ⟩ y≡z
_∎ : (x : A) → x ≡ x
_∎ _ = refl
step-≡˘ : (x {y z} : A) → y ≡ z → y ≡ x → x ≡ z
step-≡˘ _ y≡z y≡x = trans (sym y≡x) y≡z
syntax step-≡˘ x y≡z y≡x = x ≡˘⟨ y≡x ⟩ y≡z
|
{
"alphanum_fraction": 0.5143769968,
"avg_line_length": 21.5862068966,
"ext": "agda",
"hexsha": "ccb01f8602539dbc97c1b862faa83eb6f8c10313",
"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": "92af4d620febd47a9791d466d747278dc4a417aa",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/agda-binary",
"max_forks_repo_path": "Relation/Binary/PropositionalEquality/FasterReasoning.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "92af4d620febd47a9791d466d747278dc4a417aa",
"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-binary",
"max_issues_repo_path": "Relation/Binary/PropositionalEquality/FasterReasoning.agda",
"max_line_length": 82,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "92af4d620febd47a9791d466d747278dc4a417aa",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/agda-binary",
"max_stars_repo_path": "Relation/Binary/PropositionalEquality/FasterReasoning.agda",
"max_stars_repo_stars_event_max_datetime": "2019-03-21T21:30:10.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-03-21T21:30:10.000Z",
"num_tokens": 357,
"size": 626
}
|
module AbstractData where
abstract
data D : Set where
c : D
d : D
d = c
|
{
"alphanum_fraction": 0.5813953488,
"avg_line_length": 7.8181818182,
"ext": "agda",
"hexsha": "a47f2ae45e778d8fc5ad58791072b72ccecdfc4c",
"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/AbstractData.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/AbstractData.agda",
"max_line_length": 25,
"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/AbstractData.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": 30,
"size": 86
}
|
-- ---------------------------------------------------------------------
-- Geometric Group Theory (topics from)
-- ------------------------------------------
-- actions are usually denoted as `·` (\cdot)
-- mimics structure in stdlib
-- ---------------------------------------------------------------------
module GGT where
open import GGT.Definitions public
open import GGT.Structures public
open import GGT.Bundles public
|
{
"alphanum_fraction": 0.4252336449,
"avg_line_length": 35.6666666667,
"ext": "agda",
"hexsha": "eaaa611ca72fce5e1d84cac95aeb6ae7b058fdd4",
"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.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.agda",
"max_line_length": 72,
"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.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": 71,
"size": 428
}
|
{-# OPTIONS --show-implicit #-}
{-# OPTIONS --sized-types #-}
{-# OPTIONS --termination-depth=2 #-}
-- {-# OPTIONS -v term:10 #-}
module SizedBTree where
open import Common.Size
data BTree (A : Set) : {size : Size} → Set where
leaf : {i : Size} → A → BTree A {↑ i}
node : {i : Size} → BTree A {i} → BTree A {i} → BTree A {↑ i}
map : ∀ {A B i} → (A → B) → BTree A {i} → BTree B {i}
map f (leaf a) = leaf (f a)
map f (node l r) = node (map f l) (map f r)
-- deep matching
deep : ∀ {i A} → BTree A {i} → A
deep (leaf a) = a
deep (node (leaf _) r) = deep r
deep (node (node l r) _) = deep (node l r)
-- nesting
deep2 : ∀ {i A} → BTree A {i} → BTree A {i}
deep2 (leaf a) = leaf a
deep2 (node (leaf _) r) = r
deep2 (node (node l r) t) with deep2 (deep2 (node l r))
... | leaf a = leaf a
... | node l2 r2 = deep2 (node l2 r2)
-- increasing the termination count does the job!
|
{
"alphanum_fraction": 0.5634920635,
"avg_line_length": 25.2,
"ext": "agda",
"hexsha": "9e7953bcac34cc1e3b58531b5f93b70e2ec3989a",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "np/agda-git-experiment",
"max_forks_repo_path": "test/succeed/SizedBTree.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "np/agda-git-experiment",
"max_issues_repo_path": "test/succeed/SizedBTree.agda",
"max_line_length": 63,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "test/succeed/SizedBTree.agda",
"max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z",
"num_tokens": 328,
"size": 882
}
|
{- Lemmas and operations involving rewriting and heterogeneous equality. -}
module TemporalOps.Common.Rewriting where
open import Relation.Binary.HeterogeneousEquality as ≅
open import Relation.Binary.PropositionalEquality as ≡
-- | Rewriting and heterogeneous equality
-- Substitution with identity predicate – explicit rewriting
rew : ∀{ℓ}{x y : Set ℓ} -> x ≡ y -> x -> y
rew refl x = x
-- Rewriting preserves heterogeneous equality
rew-to-≅ : ∀{ℓ}{A B : Set ℓ}{v : A} -> (p : A ≡ B) -> v ≅ rew p v
rew-to-≅ {A = A} {.A} {v} refl = ≅.refl
-- Heterogenous equality with differently typed arguments
-- can be converted to homogeneous equality via rewriting of the types
≅-to-rew-≡ : ∀ {P Q : Set} {x : P} {y : Q}
-> (p : x ≅ y) -> (e : P ≡ Q)
-> rew e x ≡ y
≅-to-rew-≡ ≅.refl refl = refl
-- Rewriting by p is cancelled out by rewriting by (sym p)
rew-cancel : ∀ {P Q : Set}
-> (v : P) -> (p : P ≡ Q)
-> rew (≡.sym p) (rew p v) ≡ v
rew-cancel v refl = refl
-- | Equality of equality proofs and functions
-- Two propositional equality proofs are propositionally (heterogeneously) equal
-- if given two heterogeneously equal values, rewriting each with
-- the respective proofs gives propositionally (heterogeneously) equal terms.
-- Propositional equality of equality proofs
Proof-≅ : ∀{p1 p2 q1 q2 : Set} -> p1 ≡ q1 -> p2 ≡ q2 -> Set
Proof-≅ {p1}{p2} pf1 pf2 =
(v : p1) (v′ : p2) -> v ≅ v′ -> rew pf1 v ≅ rew pf2 v′
-- Propositional equality of equality proofs
Proof-≡ : ∀{p1 p2 q : Set} -> p1 ≡ q -> p2 ≡ q -> Set
Proof-≡ {p1}{p2} pf1 pf2 =
(v : p1) (v′ : p2) -> v ≅ v′ -> rew pf1 v ≡ rew pf2 v′
-- Propositional equality of functions
Fun-≅ : ∀{a1 a2 b1 b2 : Set} -> (a1 -> b1) -> (a2 -> b2) -> Set
Fun-≅ {a1}{a2} f1 f2 =
(v : a1) (v′ : a2) -> v ≅ v′ -> f1 v ≅ f2 v′
-- | Other lemmas
-- Heterogeneous congruence of three arguments
≅-cong₃ : ∀ {a b c d} {A : Set a} {B : A → Set b} {C : ∀ (x : A) → B x → Set c}
{D : ∀ (x : A) -> (y : B x) -> C x y -> Set d} {x y z w u v}
-> (f : (x : A) (y : B x) (z : C x y) → D x y z)
-> x ≅ y -> z ≅ w -> u ≅ v -> f x z u ≅ f y w v
≅-cong₃ f ≅.refl ≅.refl ≅.refl = ≅.refl
|
{
"alphanum_fraction": 0.5699505173,
"avg_line_length": 36.4426229508,
"ext": "agda",
"hexsha": "bdcfca9b006b6d7a4c7d0ed042edf5be34412263",
"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/TemporalOps/Common/Rewriting.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/TemporalOps/Common/Rewriting.agda",
"max_line_length": 80,
"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/TemporalOps/Common/Rewriting.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": 837,
"size": 2223
}
|
module Issue546 where
data I : Set where
i : I
data ⊤ : Set where
tt : ⊤
abstract
P : I → Set
P i = ⊤
Q : P i → Set
Q _ = ⊤
q : Q tt
q = tt
-- Q tt should be rejected.
-- This bug was introduced in Agda 2.3.0.
|
{
"alphanum_fraction": 0.5625,
"avg_line_length": 10.6666666667,
"ext": "agda",
"hexsha": "2a37dfc02b3a65ae2d83bb1cf2e55bf4b3bf7fda",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "test/fail/Issue546.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "test/fail/Issue546.agda",
"max_line_length": 41,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "test/fail/Issue546.agda",
"max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z",
"num_tokens": 89,
"size": 224
}
|
open import Prelude hiding (id; Bool)
module Implicits.Resolution.Deterministic.Incomplete where
open import Implicits.Syntax
open import Implicits.WellTyped
open import Implicits.Substitutions
open import Data.Product
open import Data.List hiding ([_])
open import Data.List.Any
open Membership-≡
open import Extensions.ListFirst
Bool : Type 0
Bool = simpl $ tc 0
Int : Type 0
Int = simpl $ tc 1
-- We'll proof incompleteness with a simple example that we'll be able to resolve
-- using the ambigous resolution rules, but not with the deterministic rules.
-- This proofs that the ambiguous rules are stronger, such that together with Oliveira's
-- proof that determinstic resolution is sound w.r.t. ambiguous resolution, we have the
-- result that deterministic resolution is incomplete (or ambiguous resolution is strictly stronger)
Δ : ICtx 0
Δ = (Int ⇒ Bool) ∷ Bool List.∷ List.[]
open import Implicits.Resolution.Deterministic.Resolution as D
open import Implicits.Resolution.Ambiguous.Resolution as A
open import Extensions.ListFirst
private
-- proof that Bool is not derivable under the deterministic resolution rules
deterministic-cant : ¬ (Δ D.⊢ᵣ Bool)
deterministic-cant (r-simp fst fst↓bool) with
FirstLemmas.first-unique (here (m-iabs m-simp) (Bool List.∷ List.[])) fst
deterministic-cant (r-simp fst (i-iabs (r-simp r _) b)) | refl = ¬r◁Int (, r)
where
¬r◁Int : ¬ (∃ λ r → Δ ⟨ tc 1 ⟩= r)
¬r◁Int (._ , here (m-iabs ()) ._)
¬r◁Int (._ , there _ _ (here () .List.[]))
¬r◁Int ( _ , there _ _ (there _ _ ()))
-- proof that Bool is derivable under the "Ambiguous" resolution rules
ambiguous-can : Δ A.⊢ᵣ Bool
ambiguous-can = r-ivar (there (here refl))
incomplete : ∃ λ ν → ∃₂ λ (Δ : ICtx ν) r → (Δ A.⊢ᵣ r) × (¬ Δ D.⊢ᵣ r)
incomplete = , (Δ , (Bool , (ambiguous-can , deterministic-cant)))
|
{
"alphanum_fraction": 0.7041036717,
"avg_line_length": 35.6153846154,
"ext": "agda",
"hexsha": "3adb7bfdfd1a2b7c019f1d4c40a109269291389e",
"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": "7fe638b87de26df47b6437f5ab0a8b955384958d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "metaborg/ts.agda",
"max_forks_repo_path": "src/Implicits/Resolution/Deterministic/Incomplete.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d",
"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": "metaborg/ts.agda",
"max_issues_repo_path": "src/Implicits/Resolution/Deterministic/Incomplete.agda",
"max_line_length": 100,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "metaborg/ts.agda",
"max_stars_repo_path": "src/Implicits/Resolution/Deterministic/Incomplete.agda",
"max_stars_repo_stars_event_max_datetime": "2021-05-07T04:08:41.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-04-05T17:57:11.000Z",
"num_tokens": 563,
"size": 1852
}
|
module Issue676 where
data Bool : Set where
true false : Bool
data ⊥ : Set where
data Silly A : Set where
[_] : A → Silly A
fail : ⊥ → Silly A
-- This shouldn't be projection-like since the second clause won't reduce.
unsillify : ∀ {A} → Silly A → A
unsillify [ x ] = x
unsillify (fail ())
data _≡_ {A : Set}(x : A) : A → Set where
refl : x ≡ x
-- Triggers an __IMPOSSIBLE__ if unsillify is projection like.
bad : (x : ⊥) → unsillify (fail x) ≡ true
bad x = refl
|
{
"alphanum_fraction": 0.6325678497,
"avg_line_length": 19.9583333333,
"ext": "agda",
"hexsha": "0391b6a15c96ffba4646463b46b2509fb1d4e05a",
"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/Issue676.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/Issue676.agda",
"max_line_length": 74,
"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/Issue676.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": 171,
"size": 479
}
|
module Coirc.Format where
open import Data.Empty
open import Data.Unit
open import Data.Bool
open import Data.Nat
open import Data.Char
open import Data.String
open import Data.List
open import Data.Sum
open import Data.Product
open import Coirc
infixr 3 _∣_
infixr 1 _>>_ _>>-_ _>>=_
within? : Char → ℕ → ℕ → Bool
within? c start end = toBool lower ∧ toBool higher
where
target = toNat c
lower = suc target ∸ start
higher = suc end ∸ target
toBool : ℕ → Bool
toBool zero = false
toBool (suc _) = true
data DarRange (start end : ℕ) : Bool → Set where
dar : (c : Char) → DarRange start end (within? c start end)
data Dar : ℕ → Set where
dar : (c : Char) → Dar (toNat c)
data U : Set where
CHAR : U
DAR : ℕ → U
DAR-RANGE : ℕ → ℕ → U
`*! `*sp `*crlf : U
El : U → Set
El CHAR = Char
El (DAR n) = Dar n
El (DAR-RANGE n m) = DarRange n m true
El `*! = String
El `*sp = String
El `*crlf = String
mutual
data Format : Set where
Fail End : Format
As : Event → Format
Base : U → Format
Skip Or And : Format → Format → Format
Use : (f : Format) → (⟦ f ⟧ → Format) → Format
⟦_⟧ : Format → Set
⟦ Fail ⟧ = ⊥
⟦ End ⟧ = ⊤
⟦ As _ ⟧ = Event
⟦ Base u ⟧ = El u
⟦ Skip _ f ⟧ = ⟦ f ⟧
⟦ Or f₁ f₂ ⟧ = ⟦ f₁ ⟧ ⊎ ⟦ f₂ ⟧
⟦ And f₁ f₂ ⟧ = ⟦ f₁ ⟧ × ⟦ f₂ ⟧
⟦ Use f₁ f₂ ⟧ = Σ ⟦ f₁ ⟧ λ x → ⟦ f₂ x ⟧
_>>_ : Format → Format → Format
f₁ >> f₂ = Skip f₁ f₂
_>>-_ : Format → Format → Format
x >>- y = And x y
_>>=_ : (f : Format) → (⟦ f ⟧ → Format) → Format
x >>= y = Use x y
_∣_ : Format → Format → Format
x ∣ y = Or x y
char : Char → Format
char c = Base (DAR (toNat c))
str : String → Format
str s = chars (toList s)
where
chars : List Char → Format
chars [] = End
chars (x ∷ xs) = char x >>- chars xs
DIGIT = Base (DAR-RANGE (toNat '0') (toNat '9'))
cl = char ':'
sp = char ' '
cr = char '\r'
lf = char '\n'
crlf = cr >>- lf
prefix = cl >> Base `*sp
Notice : Format
Notice =
prefix >>
sp >>
str "NOTICE" >>
sp >> char '*' >> sp >>
Base `*crlf >> -- text
crlf >>
As notice
NumericReply : Format
NumericReply =
prefix >>
sp >>
(DIGIT >>- DIGIT >>- DIGIT) >>
sp >>
Base `*sp >> -- target
sp >>
Base `*crlf >> -- text
crlf >>
As numeric
Mode : Format
Mode =
prefix >>
sp >>
str "MODE" >>
sp >>
Base `*sp >> -- nickname
sp >>
Base `*crlf >> -- modes
crlf >>
As mode
Ping : Format
Ping =
str "PING" >>
sp >>
Base `*crlf >> -- server
crlf >>
As ping
Privmsg : Format
Privmsg =
cl >>
Base `*! >>= λ source →
Base `*sp >>
sp >>
str "PRIVMSG" >>
sp >>
Base `*sp >> -- target
sp >>
cl >>
Base `*crlf >>= λ text →
crlf >>
As (privmsg source text)
|
{
"alphanum_fraction": 0.5476455321,
"avg_line_length": 17.8609271523,
"ext": "agda",
"hexsha": "dd67342d355bdefb225043ec91d8371147875ee3",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:53:29.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:53:29.000Z",
"max_forks_repo_head_hexsha": "fd5b9aeb84851da56ce018ed15a7da1dcc949461",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "larrytheliquid/coirc",
"max_forks_repo_path": "src/Coirc/Format.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fd5b9aeb84851da56ce018ed15a7da1dcc949461",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "larrytheliquid/coirc",
"max_issues_repo_path": "src/Coirc/Format.agda",
"max_line_length": 61,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "fd5b9aeb84851da56ce018ed15a7da1dcc949461",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "larrytheliquid/coirc",
"max_stars_repo_path": "src/Coirc/Format.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1058,
"size": 2697
}
|
------------------------------------------------------------------------
-- Termination predicates
------------------------------------------------------------------------
{-# OPTIONS --erased-cubical --sized-types #-}
open import Prelude hiding (↑; module W)
module Delay-monad.Alternative.Termination {a} {A : Type a} where
open import Equality.Propositional.Cubical
open import Logical-equivalence using (_⇔_)
open import Equality.Decision-procedures equality-with-J
open import Function-universe equality-with-J hiding (id; _∘_)
open import H-level equality-with-J
open import H-level.Closure equality-with-J
open import H-level.Truncation.Propositional equality-with-paths
as Trunc
import Nat equality-with-J as N
open import Delay-monad hiding (Delay)
open import Delay-monad.Alternative
open import Delay-monad.Alternative.Equivalence
open import Delay-monad.Alternative.Properties
import Delay-monad.Bisimilarity as B
import Delay-monad.Termination as T
infix 4 _⇓_ _∥⇓∥_ _⇓′_
-- The three logically equivalent types x ⇓ y, x ∥⇓∥ y and x ⇓′ y
-- all mean that the computation x terminates with the value y:
--
-- ∙ _⇓_ is the "obvious" definition. The definition does not
-- involve truncation, and can be used directly.
--
-- ∙ _∥⇓∥_ is a truncated variant of _⇓_. It may be more convenient
-- to construct values of type x ∥⇓∥ y than of type x ⇓ y, because
-- the former type is a proposition.
--
-- ∙ _⇓′_ is an auxiliary definition, used to prove that the other
-- two are logically equivalent. This definition does not use
-- truncation, but is still propositional (if A is a set).
_⇓_ : Delay A → A → Type a
(f , _) ⇓ y = ∃ λ n → f n ↓ y
_∥⇓∥_ : Delay A → A → Type a
x ∥⇓∥ y = ∥ x ⇓ y ∥
_⇓′_ : Delay A → A → Type _
(f , _) ⇓′ y = ∃ λ m → f m ↓ y × (∀ n → ¬ f n ↑ → m N.≤ n)
-- _⇓′_ is a family of propositions (if A is a set).
⇓′-propositional :
Is-set A → ∀ x {y : A} → Is-proposition (x ⇓′ y)
⇓′-propositional A-set x@(f , _) {y} p q =
$⟨ number-unique p q ⟩
proj₁ p ≡ proj₁ q ↝⟨ ignore-propositional-component
(×-closure 1 (Maybe-closure 0 A-set)
(Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
≤-propositional)) ⟩□
p ≡ q □
where
number-unique : (p q : x ⇓′ y) → proj₁ p ≡ proj₁ q
number-unique (pm , f-pm↓y , pm≤) (qm , f-qm↓y , qm≤) =
N.≤-antisymmetric
(pm≤ qm λ f-qm↑ → ⊎.inj₁≢inj₂ (nothing ≡⟨ sym f-qm↑ ⟩
f qm ≡⟨ f-qm↓y ⟩∎
just y ∎))
(qm≤ pm λ f-pm↑ → ⊎.inj₁≢inj₂ (nothing ≡⟨ sym f-pm↑ ⟩
f pm ≡⟨ f-pm↓y ⟩∎
just y ∎))
-- All values that a computation can terminate with are equal.
termination-value-unique :
∀ (x : Delay A) {y z} → x ⇓ y → x ⇓ z → y ≡ z
termination-value-unique (f , inc) {y} {z} (m , fm↓y) (n , fn↓z)
with N.total m n
... | inj₁ m≤n = ⊎.cancel-inj₂
(just y ≡⟨ sym (↓-upwards-closed inc m≤n fm↓y) ⟩
f n ≡⟨ fn↓z ⟩∎
just z ∎)
... | inj₂ n≤m = ⊎.cancel-inj₂
(just y ≡⟨ sym fm↓y ⟩
f m ≡⟨ ↓-upwards-closed inc n≤m fn↓z ⟩∎
just z ∎)
-- _⇓_ is contained in _⇓′_.
⇓→⇓′ : ∀ x {y : A} → x ⇓ y → x ⇓′ y
⇓→⇓′ x@(f , inc) = uncurry find-min
where
find-min : ∀ {y} m → f m ↓ y → x ⇓′ y
find-min zero f0↓y = zero , f0↓y , λ _ _ → N.zero≤ _
find-min {y} (suc m) f-1+m↓y with inspect (f m)
... | nothing , fm↑ = suc m , f-1+m↓y , 1+m-is-min
where
1+m-is-min : ∀ n → ¬ f n ↑ → m N.< n
1+m-is-min n ¬fn↑ with inspect (f n)
... | nothing , fn↑ = ⊥-elim (¬fn↑ fn↑)
... | just _ , fn↓ = ↑<↓ inc fm↑ fn↓
... | just y′ , fm↓y′ =
$⟨ find-min m fm↓y′ ⟩
x ⇓′ y′ ↝⟨ Σ-map id (Σ-map with-other-value id) ⟩□
x ⇓′ y □
where
with-other-value : ∀ {n} → f n ↓ y′ → f n ↓ y
with-other-value =
subst (_ ↓_)
(termination-value-unique x (_ , fm↓y′) (_ , f-1+m↓y))
-- _⇓_ and _∥⇓∥_ are pointwise logically equivalent (if A is a set).
⇓⇔∥⇓∥ : Is-set A → ∀ x {y : A} → x ⇓ y ⇔ x ∥⇓∥ y
⇓⇔∥⇓∥ A-set x {y} = record
{ to = ∣_∣
; from = x ∥⇓∥ y ↝⟨ Trunc.rec (⇓′-propositional A-set x) (⇓→⇓′ x) ⟩
x ⇓′ y ↝⟨ Σ-map id proj₁ ⟩□
x ⇓ y □
}
-- The notion of termination defined here is logically equivalent
-- (via Delay⇔Delay) to the one defined for the coinductive delay
-- monad.
⇓⇔⇓ : ∀ x {y} → x ⇓ y ⇔ _⇔_.to Delay⇔Delay x T.⇓ y
⇓⇔⇓ x = record
{ to = λ { (n , fn↓y) → to n _ (proj₂ x) refl fn↓y }
; from = from _ refl
}
where
to : ∀ {f : ℕ → Maybe A} n x {y} →
Increasing f →
x ≡ f 0 → f n ↓ y → Delay⇔Delay.To.to′ f x T.⇓ y
to (suc n) nothing f-inc f0↑ fn↓y =
B.laterʳ (to n _ (f-inc ∘ suc) refl fn↓y)
to {f} zero nothing {y} _ f0↑ fn↓y =
⊥-elim $ ⊎.inj₁≢inj₂ (
nothing ≡⟨ f0↑ ⟩
f 0 ≡⟨ fn↓y ⟩∎
just y ∎)
to {f} n (just x) {y} f-inc f0↓x fn↓y =
subst (_ T.⇓_)
(⊎.cancel-inj₂ {A = ⊤}
(just x ≡⟨ sym $ ↓-upwards-closed₀ f-inc (sym f0↓x) n ⟩
f n ≡⟨ fn↓y ⟩∎
just y ∎))
B.now
from : ∀ {f : ℕ → Maybe A} {y} x →
x ≡ f 0 → Delay⇔Delay.To.to′ f x T.⇓ y → ∃ λ n → f n ↓ y
from (just x) f0↓x B.now = 0 , sym f0↓x
from nothing _ (B.laterʳ to⇓y) =
Σ-map suc id (from _ refl to⇓y)
⇓⇔⇓′ : ∀ {x} {y : A} → x T.⇓ y ⇔ _⇔_.from Delay⇔Delay x ⇓ y
⇓⇔⇓′ = record
{ to = to
; from = uncurry (from _)
}
where
to : ∀ {x y} → x T.⇓ y → Delay⇔Delay.from x ⇓ y
to B.now = 0 , refl
to (B.laterʳ p) = Σ-map suc id (to p)
from : ∀ x {y} n → proj₁ (Delay⇔Delay.from x) n ↓ y → x T.⇓ y
from (now x) n refl = B.now
from (later x) zero ()
from (later x) (suc n) xn↓y = B.laterʳ (from (force x) n xn↓y)
-- If there is a function f : ℕ → Maybe A satisfying a property
-- similar to termination-value-unique, then this function can be
-- turned into a value in Delay A which is, in some sense, weakly
-- bisimilar to the function.
complete-function :
(f : ℕ → Maybe A) →
(∀ {y z} → (∃ λ m → f m ↓ y) → (∃ λ n → f n ↓ z) → y ≡ z) →
∃ λ x → ∀ {y} → x ⇓ y ⇔ ∃ λ n → f n ↓ y
complete-function f unique =
(first-value , inc)
, λ {y} → record
{ to = (∃ λ n → first-value n ↓ y) ↝⟨ uncurry first-value↓→f↓ ⟩□
(∃ λ n → f n ↓ y) □
; from = (∃ λ n → f n ↓ y) ↝⟨ Σ-map id (f↓→first-value↓ _) ⟩□
(∃ λ n → first-value n ↓ y) □
}
where
-- If f m terminates for some m smaller than or equal to n, then
-- first-value n returns the value of f for the largest such m, and
-- otherwise nothing.
first-value : ℕ → Maybe A
first-value zero = f zero
first-value (suc n) =
Prelude.[ (λ _ → first-value n) , just ] (f (suc n))
-- Some simple lemmas.
step : ∀ {n} → f (suc n) ↑ → first-value (suc n) ≡ first-value n
step {n} = cong Prelude.[ (λ _ → first-value n) , just ]
done : ∀ {n y} → f (suc n) ↓ y → first-value (suc n) ↓ y
done {n} = cong Prelude.[ (λ _ → first-value n) , just ]
-- If f n terminates with a certain value, then first-value n
-- terminates with the same value.
f↓→first-value↓ : ∀ {y} n → f n ↓ y → first-value n ↓ y
f↓→first-value↓ zero f↓ = f↓
f↓→first-value↓ (suc n) f↑ = done f↑
-- If first-value m terminates with a certain value, then there is
-- some n for which f n terminates with the same value.
first-value↓→f↓ : ∀ {y} m → first-value m ↓ y → ∃ λ n → f n ↓ y
first-value↓→f↓ zero first-value↓ = zero , first-value↓
first-value↓→f↓ {y} (suc n) first-value↓ with inspect (f (suc n))
... | just y′ , f↓ = suc n , (f (suc n) ≡⟨ f↓ ⟩
just y′ ≡⟨ sym (done f↓) ⟩
first-value (suc n) ≡⟨ first-value↓ ⟩∎
just y ∎)
... | nothing , f↑ =
first-value↓→f↓ n (first-value n ≡⟨ sym (step f↑) ⟩
first-value (suc n) ≡⟨ first-value↓ ⟩∎
just y ∎)
-- The function first-value is an increasing sequence.
inc : Increasing first-value
inc n with inspect (first-value n) | inspect (f (suc n))
inc n | _ | nothing , f↑ =
inj₁ (first-value n ≡⟨ sym (step f↑) ⟩∎
first-value (suc n) ∎)
inc n | nothing , first-value↑ | just y , f↓ =
inj₂ (first-value↑ , λ first-value↑ → ⊎.inj₁≢inj₂ (
nothing ≡⟨ sym first-value↑ ⟩
first-value (suc n) ≡⟨ done f↓ ⟩∎
just y ∎))
inc n | just y , first-value↓ | just y′ , f↓ =
inj₁ (first-value n ≡⟨ first-value↓ ⟩
just y ≡⟨ cong just $ unique (_ , proj₂ (first-value↓→f↓ n first-value↓)) (_ , f↓) ⟩
just y′ ≡⟨ sym (done f↓) ⟩∎
first-value (suc n) ∎)
|
{
"alphanum_fraction": 0.4911326297,
"avg_line_length": 36.6175298805,
"ext": "agda",
"hexsha": "b9ec9d299ae6a29843af5fd2805c1628f417b2a3",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/partiality-monad",
"max_forks_repo_path": "src/Delay-monad/Alternative/Termination.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/partiality-monad",
"max_issues_repo_path": "src/Delay-monad/Alternative/Termination.agda",
"max_line_length": 108,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/partiality-monad",
"max_stars_repo_path": "src/Delay-monad/Alternative/Termination.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:08.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-05-21T22:59:18.000Z",
"num_tokens": 3486,
"size": 9191
}
|
module AnonymousDecl where
_ : Set₁
_ = Set
_ : Set → Set
_ = λ x → x
_∋_ : ∀ {ℓ} (A : Set ℓ) → A → A
A ∋ a = a
_ = Set₁
_ = (Set → Set) ∋ λ x → x
data Bool : Set where t f : Bool
not : Bool → Bool
not t = f
not f = t
data _≡_ {A : Set} (a : A) : A → Set where
refl : a ≡ a
_ : ∀ x → not (not x) ≡ x
_ = λ { t → refl; f → refl }
|
{
"alphanum_fraction": 0.4837758112,
"avg_line_length": 13.0384615385,
"ext": "agda",
"hexsha": "d5001dca11123c0cd56d6f678639fe0cd1645c4a",
"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/AnonymousDecl.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/AnonymousDecl.agda",
"max_line_length": 42,
"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/AnonymousDecl.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": 156,
"size": 339
}
|
open import FRP.JS.Time.Core using ( Time )
module FRP.JS.RSet where
infixr 1 _⇒_
RSet : Set₁
RSet = Time → Set
_⇒_ : RSet → RSet → RSet
(A ⇒ B) t = A t → B t
⟨_⟩ : Set → RSet
⟨ A ⟩ t = A
⟦_⟧ : RSet → Set
⟦ A ⟧ = ∀ {t} → A t
|
{
"alphanum_fraction": 0.5367965368,
"avg_line_length": 12.8333333333,
"ext": "agda",
"hexsha": "7f9ee091397d26ae4c0aaa6381b9f48a5c42039f",
"lang": "Agda",
"max_forks_count": 7,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-11-07T21:50:58.000Z",
"max_forks_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72",
"max_forks_repo_licenses": [
"MIT",
"BSD-3-Clause"
],
"max_forks_repo_name": "agda/agda-frp-js",
"max_forks_repo_path": "src/agda/FRP/JS/RSet.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT",
"BSD-3-Clause"
],
"max_issues_repo_name": "agda/agda-frp-js",
"max_issues_repo_path": "src/agda/FRP/JS/RSet.agda",
"max_line_length": 43,
"max_stars_count": 63,
"max_stars_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72",
"max_stars_repo_licenses": [
"MIT",
"BSD-3-Clause"
],
"max_stars_repo_name": "agda/agda-frp-js",
"max_stars_repo_path": "src/agda/FRP/JS/RSet.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-28T09:46:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-20T21:47:00.000Z",
"num_tokens": 115,
"size": 231
}
|
-- Andreas, 2016-12-30 test case for #2369
-- {-# OPTIONS --allow-unsolved-metas #-}
-- {-# OPTIONS -v scope.import:20 #-}
module Issue2369 where
import Issue2369.OpenIP
-- Error is:
-- Module cannot be imported since it has open interaction points
-- (consider adding {-# OPTIONS --allow-unsolved-metas #-} to this
-- module)
-- when scope checking the declaration
-- import Issue2369.OpenIP
-- Error could be better, or this could just work.
|
{
"alphanum_fraction": 0.7013274336,
"avg_line_length": 23.7894736842,
"ext": "agda",
"hexsha": "2fbf335265cef3f7c847844831182196abf73436",
"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/Issue2369.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/Issue2369.agda",
"max_line_length": 66,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Fail/Issue2369.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": 119,
"size": 452
}
|
module <-trans-revisited where
open import Data.Nat using (ℕ; suc)
open import Relations using (_≤_; z≤n; s≤s; ≤-trans; _<_; z<s; s<s)
open import ≤-iff-< using (≤-iff-<′)
<-iff-≤ : ∀ {m n : ℕ}
→ m < n
---------
→ suc m ≤ n
<-iff-≤ z<s = s≤s z≤n
<-iff-≤ (s<s m<n) = s≤s (<-iff-≤ m<n)
-- <-trans の別証明 (≤-trans版)
<-trans-revisited : ∀ {m n p : ℕ}
→ m < n
→ n < p
-----
→ m < p
<-trans-revisited z<s (s<s n<p) = ≤-iff-<′ (≤-trans (<-iff-≤ z<s) (<-iff-≤ (s<s n<p)))
<-trans-revisited (s<s m<n) (s<s n<p) = ≤-iff-<′ (≤-trans (s≤s (<-iff-≤ (lemma m<n))) (<-iff-≤ (s<s n<p)))
where
lemma : ∀ {m n : ℕ}
→ m < n
---------
→ m < suc n
lemma z<s = z<s
lemma (s<s m<n) = s<s (lemma m<n)
|
{
"alphanum_fraction": 0.432576769,
"avg_line_length": 24.9666666667,
"ext": "agda",
"hexsha": "d8d402fbd3e8fbfa9a9c76f5c2bd220948743bfa",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "akiomik/plfa-solutions",
"max_forks_repo_path": "part1/relations/<-trans-revisited.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "akiomik/plfa-solutions",
"max_issues_repo_path": "part1/relations/<-trans-revisited.agda",
"max_line_length": 106,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "akiomik/plfa-solutions",
"max_stars_repo_path": "part1/relations/<-trans-revisited.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z",
"num_tokens": 344,
"size": 749
}
|
postulate
A : Set
data B (a : A) : Set where
conB : B a → B a → B a
data C (a : A) : B a → Set where
conC : {bl br : B a} → C a bl → C a br → C a (conB bl br)
-- First bug.
{-
a !=<
"An internal error has occurred. Please report this as a bug.\nLocation of the error: src/full/Agda/TypeChecking/Telescope.hs:68\n"
of type A
when checking that the type
(a : A) (b : B a) (tl : C a (_16 a b)) →
C a (_16 a b) → (tr : C a (_17 a b)) → Set
of the generated with function is well-formed
-- Is there a contained error printing bug?
-}
goo : (a : A) (b : B a) (c : C a _) → Set
-- giving b for _ resolves the error
goo a b (conC tl tr) with tl
... | _ = _
|
{
"alphanum_fraction": 0.5687409551,
"avg_line_length": 27.64,
"ext": "agda",
"hexsha": "ba54efd3101a7ff8b61dd08ea1904a23f89ec51a",
"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/Issue2679a.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/Issue2679a.agda",
"max_line_length": 131,
"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/Issue2679a.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": 241,
"size": 691
}
|
------------------------------------------------------------------------
-- Correct-by-construction pretty-printing
--
-- Nils Anders Danielsson
------------------------------------------------------------------------
-- A pretty-printing library that guarantees that pretty-printers are
-- correct (on the assumption that grammars are unambiguous).
{-# OPTIONS --guardedness #-}
module README where
-- Various utility functions.
import Utilities
-- Infinite grammars.
import Grammar.Infinite.Basic
import Grammar.Infinite
-- Pretty-printing (documents and document combinators).
import Pretty
-- Document renderers.
import Renderer
-- Examples.
import Examples.Bool
import Examples.Expression
import Examples.Identifier
import Examples.Identifier-list
import Examples.Precedence
import Examples.Tree
import Examples.XML
-- Abstract grammars. (Not used by the pretty-printer.)
import Grammar.Abstract
-- Grammars defined as functions from non-terminals to productions.
-- (Not used by the pretty-printer.)
import Grammar.Non-terminal
-- A README directed towards readers of the paper
-- "Correct-by-Construction Pretty-Printing".
import README.Correct-by-Construction-Pretty-Printing
|
{
"alphanum_fraction": 0.6916043225,
"avg_line_length": 22.2777777778,
"ext": "agda",
"hexsha": "3f8c7218ef6aafd8c52afa72c83b070d19d6e4c6",
"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": "b956803ba90b6c5f57bbbaab01bb18485d948492",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/pretty",
"max_forks_repo_path": "README.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b956803ba90b6c5f57bbbaab01bb18485d948492",
"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/pretty",
"max_issues_repo_path": "README.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "b956803ba90b6c5f57bbbaab01bb18485d948492",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/pretty",
"max_stars_repo_path": "README.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 216,
"size": 1203
}
|
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
{- Maybe it is actually easier to prove [sum-subindicator]
and then derive the other lemma. -}
module groups.SumOfSubIndicator where
module _ {i} (G : Group i) where
open Group G
abstract
sum-ident : ∀ {I} (f : Fin I → El)
→ (∀ <I → f <I == ident)
→ sum f == ident
sum-ident {I = O} f z = idp
sum-ident {I = S I} f z =
ap2 comp
(sum-ident (f ∘ Fin-S) (z ∘ Fin-S))
(z (I , ltS))
∙ unit-l _
sum-subindicator : ∀ {I} (f : Fin I → El) <I*
→ (sub-indicator : ∀ {<I} → <I ≠ <I* → f <I == ident)
→ sum f == f <I*
sum-subindicator f (I , ltS) subind =
ap (λ g → comp g (f (I , ltS)))
(sum-ident (f ∘ Fin-S) (λ <I → subind (ltSR≠ltS <I)))
∙ unit-l _
sum-subindicator {I = S I} f (m , ltSR m<I) subind =
ap2 comp
(sum-subindicator (f ∘ Fin-S) (m , m<I) (subind ∘ Fin-S-≠))
(subind (ltS≠ltSR (m , m<I)))
∙ unit-r _
module _ {i j k} (G : Group i) {A : Type j} {B : Type k}
{I} (p : Fin I ≃ Coprod A B) (f : B → Group.El G) b*
(sub-indicator : ∀ {b} → b ≠ b* → f b == Group.ident G)
where
open Group G
abstract
private
sub-indicator' : ∀ {<I} → <I ≠ <– p (inr b*)
→ Coprod-rec (λ _ → ident) f (–> p <I) == ident
sub-indicator' {<I} <I≠p⁻¹b* =
Coprod-elim
{C = λ c → c ≠ inr b* → Coprod-rec (λ _ → ident) f c == ident}
(λ _ _ → idp)
(λ b inrb≠inrb* → sub-indicator (inrb≠inrb* ∘ ap inr))
(–> p <I) (<I≠p⁻¹b* ∘ equiv-adj p)
subsum-r-subindicator : subsum-r (–> p) f == f b*
subsum-r-subindicator =
sum-subindicator G
(Coprod-rec (λ _ → ident) f ∘ –> p)
(<– p (inr b*))
sub-indicator'
∙ ap (Coprod-rec (λ _ → ident) f) (<–-inv-r p (inr b*))
|
{
"alphanum_fraction": 0.4840626688,
"avg_line_length": 29.380952381,
"ext": "agda",
"hexsha": "f3ef87ccb536ebe7b97dd225cc33730f37de4429",
"lang": "Agda",
"max_forks_count": 50,
"max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z",
"max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "timjb/HoTT-Agda",
"max_forks_repo_path": "theorems/groups/SumOfSubIndicator.agda",
"max_issues_count": 31,
"max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "timjb/HoTT-Agda",
"max_issues_repo_path": "theorems/groups/SumOfSubIndicator.agda",
"max_line_length": 72,
"max_stars_count": 294,
"max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "timjb/HoTT-Agda",
"max_stars_repo_path": "theorems/groups/SumOfSubIndicator.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z",
"num_tokens": 714,
"size": 1851
}
|
module Issue502 where
record R : Set where
record S (A : Set) : Set where
field
f : A → A
|
{
"alphanum_fraction": 0.5865384615,
"avg_line_length": 13,
"ext": "agda",
"hexsha": "ac72500ceb5fe5057f5684ef15559de08c863946",
"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/Issue502.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/Issue502.agda",
"max_line_length": 32,
"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/Issue502.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 34,
"size": 104
}
|
--------------------------------------------------------------------------------
-- This file is the entry point for checking or executing code. It provides the
-- type MetaContext, which tracks the entire state of the interpreter as well as
-- the function tryExecute to parse and execute some code if possible
--------------------------------------------------------------------------------
{-# OPTIONS --type-in-type #-}
module Execution where
open import Class.Monad.Except
open import Class.Monad.IO
open import Class.Monad.State
open import Data.HSTrie
open import Conversion
open import CoreTheory
open import Parse.TreeConvert
open import Parse.Generate
open import Prelude
open import Prelude.Strings
record MetaEnv : Set where
field
grammar : Grammar
namespace : String -- we need to remember the current namespace
-- because the rule string in the grammar doesn't
evaluator : AnnTerm
-- The full state of the interpreter: the context of defined values plus parsing
-- and semantics for generating code
MetaContext : Set
MetaContext = GlobalContext × MetaEnv
-- Many statements just return a single string, in which case this function can
-- be used
strResult : String → MetaResult
strResult s = [ s ] , []
getParserNamespace : Context → String → List String
getParserNamespace (Γ , _) n = strDrop (strLength n + 1) <$> (trieKeys $ lookupHSTrie n Γ)
module _ {M : Set → Set} {{_ : Monad M}}
{{_ : MonadExcept M String}} {{_ : MonadState M MetaContext}} where
getContext : M Context
getContext = gets (globalToContext ∘ proj₁)
getMeta : M MetaEnv
getMeta = gets proj₂
modify' : (MetaContext → MetaContext) → M ⊤
modify' f = modify f >> return tt
setMeta : MetaEnv → M ⊤
setMeta menv =
modify' λ { (Γ , _) → (Γ , menv) }
setContext : GlobalContext → M ⊤
setContext Γ = modify' λ { (_ , m) → (Γ , m) }
modifyContext : (GlobalContext → GlobalContext) → M ⊤
modifyContext f = do
Γ ← getContext
setContext $ f $ contextToGlobal Γ
addDef : GlobalName → Def → M String
addDef n d = do
Γ ← getContext
case insertInGlobalContext n d (contextToGlobal Γ) of λ where
(inj₁ x) → throwError x
(inj₂ y) → setContext y >> return ("Defined " + n + show d)
unquoteFromTerm : ∀ {A} ⦃ _ : Unquote A ⦄ → PureTerm → M A
unquoteFromTerm t = do
Γ ← getContext
catchError (unquoteConstrs Γ $ normalizePure Γ t)
(λ e → throwError $ "Error while unquoting" <+> show t + ":\n" + e)
-- Typecheck a term and return its type
inferType : AnnTerm → M AnnTerm
inferType t = do
Γ ← getContext
synthType Γ t
checkType : AnnTerm → AnnTerm → M ⊤
checkType t T = do
t' ← inferType t
inferType T
Γ ← getContext
catchError (checkβη Γ T t')
(λ e → throwError $
"Type mismatch with the provided type!\n" + e + "\nProvided: " + show t' +
"\nSynthesized: " + show T)
checkTypePure : AnnTerm → PureTerm → M ⊤
checkTypePure t T = do
t' ← inferType t
Γ ← getContext
catchError (checkβηPure Γ T $ Erase t')
(λ e → throwError $
"Type mismatch with the provided type!\n" + e + "\nProvided: " + show t' +
"\nSynthesized: " + show T)
parseMeta : MetaEnv → String → M (AnnTerm × String)
parseMeta menv s = let open MetaEnv menv in parse grammar (initNT grammar) namespace s
module ExecutionDefs {M : Set → Set} {{_ : Monad M}}
{{_ : MonadExcept M String}} {{_ : MonadState M MetaContext}} {{_ : MonadIO M}}
where
{-# NON_TERMINATING #-}
-- Execute a term of type M t for some t
executeTerm : PureTerm → M (MetaResult × PureTerm)
executeStmt : Stmt → M MetaResult
executePrimitive : (m : PrimMeta) → primMetaArgs PureTerm m → M (MetaResult × AnnTerm)
-- Parse and execute a string
parseAndExecute' parseAndExecuteBootstrap : String → M (MetaResult × String)
parseAndExecute : String → M MetaResult
executeStmt (Let n t nothing) = do
T ← inferType t
strResult <$> addDef n (Let t T)
executeStmt (Let n t (just t')) = do
checkType t t'
strResult <$> addDef n (Let t t')
executeStmt (Ass n t) = do
_ ← inferType t
strResult <$> addDef n (Axiom t)
executeStmt (SetEval t n start) = do
Γ ← getContext
y ← generateCFG start $ getParserNamespace Γ n
(Pi-A _ u u₁) ← hnfNorm Γ <$> synthType Γ t
where _ → throwError "The evaluator needs to have a pi type"
appendIfError (checkβη Γ u $ FreeVar (n + "$" + start))
"The evaluator needs to accept the parse result as input"
case (hnfNorm Γ u₁) of λ where
(M-A _) → do
setMeta record { grammar = y ; namespace = n ; evaluator = t }
return $ strResult "Successfully set the evaluator"
_ → throwError "The evaluator needs to return a M type"
executeStmt (Import x) = do
res ← liftIO $ readFiniteFileError (x + ".mced")
case res of λ where
(inj₁ x) → throwError x
(inj₂ y) → parseAndExecute y
executeStmt Empty = return (strResult "")
executeTerm (Mu-P t t₁) = do
Γ ← getContext
(res , t') ← executeTerm (hnfNormPure Γ t)
(res' , resTerm) ← executeTerm (hnfNormPure Γ (t₁ ⟪$⟫ t'))
return (res + res' , resTerm)
executeTerm (Epsilon-P t) = return (([] , []) , t)
executeTerm (Gamma-P t t') =
catchError (executeTerm t) (λ s → executeTerm (t' ⟪$⟫ quoteToPureTerm s))
executeTerm (Ev-P m t) = do
(res , t') ← executePrimitive m t
checkTypePure t' $ primMetaT m t
return (res , Erase t')
{-# CATCHALL #-}
executeTerm t =
throwError ("Error: " + show t + " is not a term that can be evaluated!")
executePrimitive EvalStmt t = do
Γ ← getContext
stmt ← unquoteFromTerm t
res ← executeStmt stmt
return (res , quoteToAnnTerm res)
executePrimitive ShellCmd (t , t') = do
Γ ← getContext
cmd ← unquoteFromTerm t
args ← unquoteFromTerm t'
res ← liftIO $ runShellCmd cmd args
return (strResult res , quoteToAnnTerm res)
executePrimitive CheckTerm (t , t') = do
Γ ← getContext
u ← unquoteFromTerm t'
T' ← inferType u
catchError (checkβηPure Γ t $ Erase T')
(λ e → throwError $
"Type mismatch with the provided type!\nProvided: " + show t +
"\nSynthesized: " + show T')
return (strResult "" , u)
executePrimitive Parse (t , type , t') = do
Γ ← getContext
nonTerminal ← M String ∋ (unquoteFromTerm t)
text ← M String ∋ (unquoteFromTerm t')
record { grammar = G ; namespace = namespace } ← getMeta
NT ← maybeToError (findNT G nonTerminal)
("Non-terminal" <+> nonTerminal <+> "does not exist in the current grammar!")
(res , rest) ← parse G NT namespace text
T ← appendIfError (synthType Γ res)
("\n\nError while interpreting input: "
+ (shortenString 10000 (show res))
+ "\nWhile parsing: " + (shortenString 10000 text))
appendIfError (checkβηPure Γ type $ Erase T)
("Type mismatch with the provided type!\nProvided: " + show type +
"\nSynthesized: " + show T)
-- need to spell out instance manually, since we don't want to quote 'res'
return (strResult "" , quoteToAnnTerm ⦃ Quotable-ProductData ⦃ Quotable-NoQuoteAnnTerm ⦄ ⦄
record { lType = T ; rType = FreeVar "init$string" ; l = res ; r = rest })
executePrimitive Normalize t = do
Γ ← getContext
u ← unquoteFromTerm t
T ← synthType Γ u
return (strResult
(show u + " : " + show T + " normalizes to: " +
(show $ normalizePure Γ $ Erase u)) , (quoteToAnnTerm $ normalizePure Γ $ Erase u))
executePrimitive HeadNormalize t = do
Γ ← getContext
u ← unquoteFromTerm t
T ← synthType Γ u
return (strResult
(show t + " : " + show T + " head-normalizes to: " +
(show $ hnfNorm Γ u)) , (quoteToAnnTerm $ hnfNorm Γ u))
executePrimitive InferType t = do
Γ ← getContext
u ← unquoteFromTerm t
T ← synthType Γ u
return (strResult "" , (quoteToAnnTerm T))
parseAndExecuteBootstrap s = do
(fst , snd) ← parseStmt s
res ← appendIfError (executeStmt fst) ("\n\nError while executing statement: " + show fst)
return (res , snd)
parseAndExecute' s = do
Γ ← getContext
m ← getMeta
(fst , snd) ← parseMeta m s
let exec = MetaEnv.evaluator m ⟪$⟫ fst
(M-A _) ← hnfNorm Γ <$>
appendIfError (synthType Γ exec)
("\n\nError while interpreting input: "
+ (shortenString 10000 (show fst))
+ "\nWhile parsing: " + (shortenString 10000 s))
where _ → throwError "Trying to execute something that isn't of type M t. This should never happen!"
let execHnf = hnfNormPure Γ $ Erase exec
(res , _) ← appendIfError (executeTerm execHnf) ("\n\nError while executing input: " + s)
return (res , snd)
parseAndExecute s = do
record { evaluator = evaluator } ← getMeta
(res , rest) ← case evaluator of λ where
(Sort-A □) → parseAndExecuteBootstrap s
_ → parseAndExecute' s
res' ← if strNull rest then return mzero else parseAndExecute rest
return (res + res')
module ExecutionMonad where
open import Monads.ExceptT
open import Monads.StateT
ExecutionState : Set
ExecutionState = MetaContext
contextFromState : ExecutionState → MetaContext
contextFromState s = s
Execution : Set → Set
Execution = ExceptT (StateT IO ExecutionState) String
execute : ∀ {A} → Execution A → MetaContext → IO (ExecutionState × (String ⊎ A))
execute x Γ = do
(x' , s') ← x Γ
return (s' , x')
instance
Execution-Monad : Monad Execution
Execution-Monad = ExceptT-Monad {{StateT-Monad}}
Execution-MonadExcept : MonadExcept Execution {{Execution-Monad}} String
Execution-MonadExcept = ExceptT-MonadExcept {{StateT-Monad}}
Execution-MonadState : MonadState Execution {{Execution-Monad}} ExecutionState
Execution-MonadState = ExceptT-MonadState {{StateT-Monad}} {{StateT-MonadState}}
Execution-IO : MonadIO Execution {{Execution-Monad}}
Execution-IO = ExceptT-MonadIO {{StateT-Monad}} {{StateT-MonadIO {{_}} {{IO-MonadIO}}}}
open ExecutionMonad public
open ExecutionDefs {Execution} public
|
{
"alphanum_fraction": 0.6335088746,
"avg_line_length": 34.0664451827,
"ext": "agda",
"hexsha": "ead50781d649572752a2759198d4155d4ad6bd49",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2021-10-20T10:46:20.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-06-27T23:12:48.000Z",
"max_forks_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "WhatisRT/meta-cedille",
"max_forks_repo_path": "src/Execution.agda",
"max_issues_count": 10,
"max_issues_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c",
"max_issues_repo_issues_event_max_datetime": "2020-04-25T15:29:17.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-13T17:44:43.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "WhatisRT/meta-cedille",
"max_issues_repo_path": "src/Execution.agda",
"max_line_length": 106,
"max_stars_count": 35,
"max_stars_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "WhatisRT/meta-cedille",
"max_stars_repo_path": "src/Execution.agda",
"max_stars_repo_stars_event_max_datetime": "2021-10-12T22:59:10.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-06-13T07:44:50.000Z",
"num_tokens": 2914,
"size": 10254
}
|
{-# OPTIONS --erased-cubical --safe #-}
module Instruments where
open import Data.Fin using (#_)
open import MidiEvent using (InstrumentNumber-1; maxChannels)
open import Data.Vec using (Vec; []; _∷_)
-- Start of an instrument list
-- all instruments have this type
piano : InstrumentNumber-1
piano = # 0
brightPiano = # 1
electricGrandPiano = # 2
honkyTonkPiano = # 3
electricPiano1 = # 4
electricPiano2 = # 5
harpsichord = # 6
clavinet = # 7
celesta = # 8
vibraphone = # 11
drawbarOrgan = # 16
percussiveOrgan = # 17
rockOrgan = # 18
churchOrgan = # 19
acousticGuitar[nylon] = # 24
acousticGuitar[steel] = # 25
electricGuitar[jazz] = # 26
electricGuitar[clean] = # 27
electricGuitar[muted] = # 28
overdrivenGuitar = # 29
distortionGuitar = # 30
guitarHarmonics = # 31
harp = # 46
----------------
drums : InstrumentNumber-1
drums = # 0
----------------
-- Assign piano to all tracks
-- Note that channel 10 (9 as Channel-1) is percussion
pianos : Vec InstrumentNumber-1 maxChannels
pianos =
piano ∷ -- 1
piano ∷ -- 2
piano ∷ -- 3
piano ∷ -- 4
piano ∷ -- 5
piano ∷ -- 6
piano ∷ -- 7
piano ∷ -- 8
piano ∷ -- 9
drums ∷ -- 10 (percussion)
piano ∷ -- 11
piano ∷ -- 12
piano ∷ -- 13
piano ∷ -- 14
piano ∷ -- 15
piano ∷ -- 16
[]
|
{
"alphanum_fraction": 0.5543328748,
"avg_line_length": 20.4788732394,
"ext": "agda",
"hexsha": "66b2687affa26b616f03718269ac5130768d99d2",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2020-11-10T04:04:40.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-01-12T17:02:36.000Z",
"max_forks_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "halfaya/MusicTools",
"max_forks_repo_path": "agda/Instruments.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021",
"max_issues_repo_issues_event_max_datetime": "2020-11-17T00:58:55.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-11-13T01:26:20.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "halfaya/MusicTools",
"max_issues_repo_path": "agda/Instruments.agda",
"max_line_length": 61,
"max_stars_count": 28,
"max_stars_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "halfaya/MusicTools",
"max_stars_repo_path": "agda/Instruments.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-04T18:04:07.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-04-21T09:08:52.000Z",
"num_tokens": 498,
"size": 1454
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Documentation for the List type
------------------------------------------------------------------------
{-# OPTIONS --warning noMissingDefinitions #-}
module README.Data.List where
open import Algebra.Structures using (IsCommutativeMonoid)
open import Data.Char.Base using (Char; fromℕ)
open import Data.Char.Properties as CharProp hiding (setoid)
open import Data.Nat using (ℕ; _+_; _<_; s≤s; z≤n; _*_; _∸_; _≤_)
open import Data.Nat.Properties as NatProp
open import Relation.Binary.PropositionalEquality
using (_≡_; refl; sym; cong; setoid)
------------------------------------------------------------------------
-- 1. Basics
------------------------------------------------------------------------
-- The `List` datatype is exported by the following file:
open import Data.List
using
(List
; []; _∷_
; sum; map; take; reverse; _++_; drop
)
module Basics where
-- Lists are built using the "[]" and "_∷_" constructors.
list₁ : List ℕ
list₁ = 3 ∷ 1 ∷ 2 ∷ []
-- Basic operations over lists are also exported by the same file.
lem₁ : sum list₁ ≡ 6
lem₁ = refl
lem₂ : map (_+ 2) list₁ ≡ 5 ∷ 3 ∷ 4 ∷ []
lem₂ = refl
lem₃ : take 2 list₁ ≡ 3 ∷ 1 ∷ []
lem₃ = refl
lem₄ : reverse list₁ ≡ 2 ∷ 1 ∷ 3 ∷ []
lem₄ = refl
lem₅ : list₁ ++ list₁ ≡ 3 ∷ 1 ∷ 2 ∷ 3 ∷ 1 ∷ 2 ∷ []
lem₅ = refl
-- Various properties of these operations can be found in:
open import Data.List.Properties
lem₆ : ∀ n (xs : List ℕ) → take n xs ++ drop n xs ≡ xs
lem₆ = take++drop
lem₇ : ∀ (xs : List ℕ) → reverse (reverse xs) ≡ xs
lem₇ = reverse-involutive
lem₈ : ∀ (xs ys zs : List ℕ) → (xs ++ ys) ++ zs ≡ xs ++ (ys ++ zs)
lem₈ = ++-assoc
------------------------------------------------------------------------
-- 2. Binary relations over lists
------------------------------------------------------------------------
-- All binary relations over lists are found in the folder
-- `Data.List.Relation.Binary`.
------------------------------------------------------------------------
-- Pointwise
module PointwiseExplanation where
-- One of the most basic ways to form a binary relation between two
-- lists of type `List A`, given a binary relation over `A`, is to say
-- that two lists are related if:
-- i) the first elements in the lists are related
-- ii) the second elements in the lists are related
-- iii) the third elements in the lists are related etc.
--
-- A formalisation of this "pointwise" lifting of a relation to lists
-- is found in:
open import Data.List.Relation.Binary.Pointwise
-- The same syntax to construct a list (`[]` & `_∷_`) is used to
-- construct proofs for the `Pointwise` relation. For example if you
-- want to prove that one list is strictly less than another list:
lem₁ : Pointwise _<_ (0 ∷ 2 ∷ 1 ∷ []) (1 ∷ 4 ∷ 2 ∷ [])
lem₁ = 0<1 ∷ 2<4 ∷ 1<2 ∷ []
where
0<1 = s≤s z≤n
2<4 = s≤s (s≤s (s≤s z≤n))
1<2 = s≤s 0<1
-- Lists that are related by `Pointwise` must be of the same length.
-- For example:
open import Relation.Nullary using (¬_)
lem₂ : ¬ Pointwise _<_ (0 ∷ 2 ∷ []) (1 ∷ [])
lem₂ (0<1 ∷ ())
------------------------------------------------------------------------
-- Equality
module EqualityExplanation where
-- There are many different options for what it means for two
-- different lists of type `List A` to be "equal". We will initially
-- consider notions of equality that require the list elements to be
-- in the same order and later discuss other types of equality.
-- The most basic option in the former case is simply to use
-- propositional equality `_≡_` over lists:
open import Relation.Binary.PropositionalEquality
using (_≡_; sym; refl)
lem₁ : 1 ∷ 2 ∷ 3 ∷ [] ≡ 1 ∷ 2 ∷ 3 ∷ []
lem₁ = refl
-- However propositional equality is only suitable when we want to
-- use propositional equality to compare the individual elements.
-- Although a contrived example, consider trying to prove the
-- equality of two lists of the type `List (ℕ → ℕ)`:
lem₂ : (λ x → 2 * x + 2) ∷ [] ≡ (λ x → 2 * (x + 1)) ∷ []
-- In such a case it is impossible to prove the two lists equal with
-- refl as the two functions are not propositionally equal. In the
-- absence of postulating function extensionality (see README.Axioms),
-- the most common definition of function equality is to say that two
-- functions are equal if their outputs are always propositionally
-- equal for any input. This notion of function equality `_≗_` is
-- found in:
open import Relation.Binary.PropositionalEquality using (_≗_)
-- We now want to use the `Pointwise` relation to say that the two
-- lists are equal if their elements are pointwise equal with resepct
-- to `_≗_`. However instead of using the pointwise module directly
-- to write:
open import Data.List.Relation.Binary.Pointwise using (Pointwise)
lem₃ : Pointwise _≗_ ((λ x → x + 1) ∷ []) ((λ x → x + 2 ∸ 1) ∷ [])
-- the library provides some nicer wrappers and infix notation in the
-- folder "Data.List.Relation.Binary.Equality".
-- Within this folder there are four different modules.
import Data.List.Relation.Binary.Equality.Setoid as SetoidEq
import Data.List.Relation.Binary.Equality.DecSetoid as DecSetoidEq
import Data.List.Relation.Binary.Equality.Propositional as PropEq
import Data.List.Relation.Binary.Equality.DecPropositional as DecPropEq
-- Which one should be used depends on whether the underlying equality
-- over "A" is:
-- i) propositional or setoid-based
-- ii) decidable.
-- Each of the modules except `PropEq` are designed to be opened with a
-- module parameter. This is to avoid having to specify the underlying
-- equality relation or the decidability proofs every time you use the
-- list equality.
-- In our example function equality is not decidable and not propositional
-- and so we want to use the `SetoidEq` module. This requires a proof that
-- the `_≗_` relation forms a setoid over functions of the type `ℕ → ℕ`.
-- This is found in:
open import Relation.Binary.PropositionalEquality using (_→-setoid_)
-- The `SetoidEq` module should therefore be opened as follows:
open SetoidEq (ℕ →-setoid ℕ)
-- All four equality modules provide an infix operator `_≋_` for the
-- new equality relation over lists. The type of `lem₃` can therefore
-- be rewritten as:
lem₄ : (λ x → x + 1) ∷ [] ≋ (λ x → x + 2 ∸ 1) ∷ []
lem₄ = 2x+2≗2[x+1] ∷ []
where
2x+2≗2[x+1] : (λ x → x + 1) ≗ (λ x → x + 2 ∸ 1)
2x+2≗2[x+1] x = sym (+-∸-assoc x (s≤s z≤n))
-- The modules also provide proofs that the `_≋_` relation is a
-- setoid in its own right and therefore is reflexive, symmetric,
-- transitive:
lem₅ : (λ x → 2 * x + 2) ∷ [] ≋ (λ x → 2 * x + 2) ∷ []
lem₅ = ≋-refl
-- If we could prove that `_≗_` forms a `DecSetoid` then we could use
-- the module `DecSetoidEq` instead. This exports everything from
-- `SetoidEq` as well as the additional proof `_≋?_` that the list
-- equality is decidable.
-- This pattern of four modules for each of the four different types
-- of equality is repeated throughout the library (e.g. see the
-- `Membership` subheading below). Note that in this case the modules
-- `PropEq` and `DecPropEq` are not very useful as if two lists are
-- pointwise propositionally equal they are necessarily
-- propositionally equal (and vice-versa). There are proofs of this
-- fact exported by `PropEq` and `DecPropEq`. Although, these two
-- types of list equality are not very useful in practice, they are
-- included for completeness's sake.
------------------------------------------------------------------------
-- Permutations
module PermutationExplanation where
-- Alternatively you might consider two lists to be equal if they
-- contain the same elements regardless of the order of the elements.
-- This is known as either "set equality" or a "permutation".
-- The easiest-to-use formalisation of this relation is found in the
-- module:
open import Data.List.Relation.Binary.Permutation.Propositional
-- The permutation relation is written as `_↭_` and has four
-- constructors. The first `refl` says that a list is always
-- a permutation of itself, the second `prep` says that if the
-- heads of the lists are the same they can be skipped, the third
-- `swap` says that the first two elements of the lists can be
-- swapped and the fourth `trans` says that permutation proofs
-- can be chained transitively.
-- For example a proof that two lists are a permutation of one
-- another can be written as follows:
lem₁ : 1 ∷ 2 ∷ 3 ∷ [] ↭ 3 ∷ 1 ∷ 2 ∷ []
lem₁ = trans (prep 1 (swap 2 3 refl)) (swap 1 3 refl)
-- In practice it is difficult to parse the constructors in the
-- proof above and hence understand why it holds. The
-- `PermutationReasoning` module can be used to write this proof
-- in a much more readable form:
open PermutationReasoning
lem₂ : 1 ∷ 2 ∷ 3 ∷ [] ↭ 3 ∷ 1 ∷ 2 ∷ []
lem₂ = begin
1 ∷ 2 ∷ 3 ∷ [] ↭⟨ prep 1 (swap 2 3 refl) ⟩
1 ∷ 3 ∷ 2 ∷ [] ↭⟨ swap 1 3 refl ⟩
3 ∷ 1 ∷ 2 ∷ [] ∎
-- As might be expected, properties of the permutation relation may be
-- found in `Data.List.Relation.Binary.Permutation.Inductive.Properties`.
open import Data.List.Relation.Binary.Permutation.Propositional.Properties
lem₃ : ∀ {xs ys : List ℕ} → xs ↭ ys → map fromℕ xs ↭ map fromℕ ys
lem₃ = map⁺ fromℕ
lem₄ : IsCommutativeMonoid {A = List ℕ} _↭_ _++_ []
lem₄ = ++-isCommutativeMonoid
-- Note: at the moment permutations have only been formalised for
-- propositional equality. Permutations for the other three types of
-- equality (decidable propositional, setoid and decidable setoid)
-- will hopefully be added in later versions of the library.
------------------------------------------------------------------------
-- Other relations
-- There exist many other binary relations in the
-- `Data.List.Relation.Binary` folder, including:
-- 1. lexicographic orderings
-- 2. bag/multiset equality
-- 3. the subset relations.
-- 4. the sublist relations
------------------------------------------------------------------------
-- 3. Properties of lists
------------------------------------------------------------------------
-- Whereas binary relations deal with how two lists relate to one
-- another, the unary relations in `Data.List.Relation.Unary` are used
-- to reason about the properties of an individual list.
------------------------------------------------------------------------
-- Any
module AnyExplanation where
-- The predicate `Any` encodes the idea of at least one element of a
-- given list satisfying a given property (or more formally a
-- predicate, see the `Pred` type in `Relation.Unary`).
open import Data.List.Relation.Unary.Any as Any
-- A proof of type Any consists of a sequence of the "there"
-- constructors, which says that the element lies in the remainder of
-- the list, followed by a single "here" constructor which indicates
-- that the head of the list satisfies the predicate and takes a proof
-- that it does so.
-- For example a proof that a given list of natural numbers contains
-- at least one number greater than or equal to 4 can be written as
-- follows:
lem₁ : Any (4 ≤_) (3 ∷ 5 ∷ 1 ∷ 6 ∷ [])
lem₁ = there (here 4≤5)
where
4≤5 = s≤s (s≤s (s≤s (s≤s z≤n)))
-- Note that nothing requires that the proof of `Any` points at the
-- first such element in the list. There is therefore an alternative
-- proof for the above lemma which points to 6 instead of 5.
lem₂ : Any (4 ≤_) (3 ∷ 5 ∷ 1 ∷ 6 ∷ [])
lem₂ = there (there (there (here 4≤6)))
where
4≤6 = s≤s (s≤s (s≤s (s≤s z≤n)))
-- There also exist various operations over proofs of `Any` whose names
-- shadow the corresponding list operation. The standard way of using
-- these is to use `as` to name the module:
import Data.List.Relation.Unary.Any as Any
-- and then use the qualified name `Any.map`. For example, map can
-- be used to change the predicate of `Any`:
open import Data.Nat.Properties using (≤-trans; n≤1+n)
lem₃ : Any (3 ≤_) (3 ∷ 5 ∷ 1 ∷ 6 ∷ [])
lem₃ = Any.map 4≤x⇒3≤x lem₂
where
4≤x⇒3≤x : ∀ {x} → 4 ≤ x → 3 ≤ x
4≤x⇒3≤x = ≤-trans (n≤1+n 3)
------------------------------------------------------------------------
-- All
module AllExplanation where
-- The dual to `Any` is the predicate `All` which encodes the idea that
-- every element in a given list satisfies a given property.
open import Data.List.Relation.Unary.All
-- Proofs for `All` are constructed using exactly the same syntax as
-- is used to construct lists ("[]" & "_∷_"). For example to prove
-- that every element in a list is less than or equal to one:
lem₁ : All (_≤ 1) (1 ∷ 0 ∷ 1 ∷ [])
lem₁ = 1≤1 ∷ 0≤1 ∷ 1≤1 ∷ []
where
0≤1 = z≤n
1≤1 = s≤s z≤n
-- As with `Any`, the module also provides the standard operators
-- `map`, `zip` etc. to manipulate proofs for `All`.
import Data.List.Relation.Unary.All as All
open import Data.Nat.Properties using (≤-trans; n≤1+n)
lem₂ : All (_≤ 2) (1 ∷ 0 ∷ 1 ∷ [])
lem₂ = All.map ≤1⇒≤2 lem₁
where
≤1⇒≤2 : ∀ {x} → x ≤ 1 → x ≤ 2
≤1⇒≤2 x≤1 = ≤-trans x≤1 (n≤1+n 1)
------------------------------------------------------------------------
-- Membership
module MembershipExplanation where
-- Membership of a list is simply a special case of `Any` where
-- `x ∈ xs` is defined as `Any (x ≈_) xs`.
-- Just like pointwise equality of lists, the exact membership module
-- that should be used depends on whether the equality on the
-- underlying elements of the list is i) propositional or setoid-based
-- and ii) decidable.
import Data.List.Membership.Setoid as SetoidMembership
import Data.List.Membership.DecSetoid as DecSetoidMembership
import Data.List.Membership.Propositional as PropMembership
import Data.List.Membership.DecPropositional as DecPropMembership
-- For example if we want to reason about membership for `List ℕ`
-- then you would use the `DecSetoidMembership` as we use
-- propositional equality over `ℕ` and it is also decidable. Therefore
-- the module `DecPropMembership` should be opened as follows:
open DecPropMembership NatProp._≟_
-- As membership is just an instance of `Any` we also need to import
-- the constructors `here` and `there`. (See issue #553 on Github for
-- why we're struggling to have `here` and `there` automatically
-- re-exported by the membership modules).
open import Data.List.Relation.Unary.Any using (here; there)
-- These modules provide the infix notation `_∈_` which can be used
-- as follows:
lem₁ : 1 ∈ 2 ∷ 1 ∷ 3 ∷ []
lem₁ = there (here refl)
-- Properties of the membership relation can be found in the following
-- two files:
import Data.List.Membership.Setoid.Properties as SetoidProperties
import Data.List.Membership.Propositional.Properties as PropProperties
-- As of yet there are no corresponding files for properties of
-- membership for decidable versions of setoid and propositional
-- equality as we have no properties that only hold when equality is
-- decidable.
-- These `Properties` modules are NOT parameterised in the same way as
-- the main membership modules as some of the properties relate
-- membership proofs for lists of different types. For example in the
-- following the first `∈` refers to lists of type `List ℕ` whereas
-- the second `∈` refers to lists of type `List Char`.
open DecPropMembership CharProp._≟_ renaming (_∈_ to _∈ᶜ_)
open SetoidProperties using (∈-map⁺)
lem₂ : {v : ℕ} {xs : List ℕ} → v ∈ xs → fromℕ v ∈ᶜ map fromℕ xs
lem₂ = ∈-map⁺ (setoid ℕ) (setoid Char) (cong fromℕ)
|
{
"alphanum_fraction": 0.6315163652,
"avg_line_length": 36.4817351598,
"ext": "agda",
"hexsha": "e05d75bcdf8f7338c0500f76f772a4a76df29976",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DreamLinuxer/popl21-artifact",
"max_forks_repo_path": "agda-stdlib/README/Data/List.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DreamLinuxer/popl21-artifact",
"max_issues_repo_path": "agda-stdlib/README/Data/List.agda",
"max_line_length": 76,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DreamLinuxer/popl21-artifact",
"max_stars_repo_path": "agda-stdlib/README/Data/List.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": 4578,
"size": 15979
}
|
-- {-# OPTIONS -v scope.let:10 #-}
module Issue381 (A : Set) where
data _≡_ (x : A) : A → Set where
refl : x ≡ x
id : A → A
id x = let abstract y = x in y
-- abstract in let should be disallowed
lemma : ∀ x → id x ≡ x
lemma x = refl
|
{
"alphanum_fraction": 0.5774058577,
"avg_line_length": 18.3846153846,
"ext": "agda",
"hexsha": "51a0774d8b687f76fc64608291c546d2b76b21e1",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "test/fail/Issue381.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "test/fail/Issue381.agda",
"max_line_length": 39,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "test/fail/Issue381.agda",
"max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z",
"num_tokens": 87,
"size": 239
}
|
module Metalogic.Classical.Propositional.Syntax {ℓₚ} (Proposition : Set(ℓₚ)) where
import Lvl
infixl 1011 •_
infixl 1010 ¬_
infixl 1005 _∧_
infixl 1004 _∨_
infixl 1000 _⇐_ _⇔_ _⇒_
data Formula : Set(ℓₚ) where
•_ : Proposition → Formula
⊤ : Formula
⊥ : Formula
¬_ : Formula → Formula
_∧_ : Formula → Formula → Formula
_∨_ : Formula → Formula → Formula
_⇒_ : Formula → Formula → Formula
_⇐_ : Formula → Formula → Formula
_⇐_ a b = _⇒_ b a
_⇔_ : Formula → Formula → Formula
_⇔_ a b = (_⇐_ a b) ∧ (_⇒_ a b)
|
{
"alphanum_fraction": 0.6495238095,
"avg_line_length": 18.75,
"ext": "agda",
"hexsha": "a83fd8e924dda4af6756b6e8d8c6d5751a914925",
"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/Metalogic/Metalogic/Classical/Propositional/Syntax.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/Metalogic/Metalogic/Classical/Propositional/Syntax.agda",
"max_line_length": 82,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "old/Metalogic/Metalogic/Classical/Propositional/Syntax.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": 232,
"size": 525
}
|
{-# OPTIONS --cubical --safe #-}
module Lens where
open import Lens.Definition public
open import Lens.Operators public
open import Lens.Composition public
open import Lens.Pair public
|
{
"alphanum_fraction": 0.7860962567,
"avg_line_length": 20.7777777778,
"ext": "agda",
"hexsha": "49bf57b6113ee19e55422d9e5bdbace8b7897f53",
"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": "Lens.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": "Lens.agda",
"max_line_length": 35,
"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": "Lens.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": 41,
"size": 187
}
|
module Data.Unit.Instance where
open import Class.Monoid
open import Data.Unit.Polymorphic
instance
Unit-Monoid : ∀ {a} → Monoid {a} ⊤
Unit-Monoid = record { mzero = tt ; _+_ = λ _ _ -> tt }
|
{
"alphanum_fraction": 0.6751269036,
"avg_line_length": 21.8888888889,
"ext": "agda",
"hexsha": "cee7df8e45bba18eecb48abd24f7a826c8f72bc8",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2021-10-20T10:46:20.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-06-27T23:12:48.000Z",
"max_forks_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "WhatisRT/meta-cedille",
"max_forks_repo_path": "stdlib-exts/Data/Unit/Instance.agda",
"max_issues_count": 10,
"max_issues_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c",
"max_issues_repo_issues_event_max_datetime": "2020-04-25T15:29:17.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-13T17:44:43.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "WhatisRT/meta-cedille",
"max_issues_repo_path": "stdlib-exts/Data/Unit/Instance.agda",
"max_line_length": 57,
"max_stars_count": 35,
"max_stars_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "WhatisRT/meta-cedille",
"max_stars_repo_path": "stdlib-exts/Data/Unit/Instance.agda",
"max_stars_repo_stars_event_max_datetime": "2021-10-12T22:59:10.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-06-13T07:44:50.000Z",
"num_tokens": 64,
"size": 197
}
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Algebra.Group.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.SIP
open import Cubical.Data.Sigma
open import Cubical.Data.Int renaming (_+_ to _+Int_ ; _-_ to _-Int_)
open import Cubical.Data.Unit
open import Cubical.Algebra.Monoid
open import Cubical.Algebra.Semigroup
open import Cubical.Foundations.HLevels
private
variable
ℓ : Level
record IsGroup {G : Type ℓ}
(0g : G) (_+_ : G → G → G) (-_ : G → G) : Type ℓ where
constructor isgroup
field
isMonoid : IsMonoid 0g _+_
inverse : (x : G) → (x + (- x) ≡ 0g) × ((- x) + x ≡ 0g)
open IsMonoid isMonoid public
infixl 6 _-_
_-_ : G → G → G
x - y = x + (- y)
invl : (x : G) → (- x) + x ≡ 0g
invl x = inverse x .snd
invr : (x : G) → x + (- x) ≡ 0g
invr x = inverse x .fst
record GroupStr (G : Type ℓ) : Type (ℓ-suc ℓ) where
constructor groupstr
field
0g : G
_+_ : G → G → G
-_ : G → G
isGroup : IsGroup 0g _+_ -_
infix 8 -_
infixr 7 _+_
open IsGroup isGroup public
Group : Type (ℓ-suc ℓ)
Group = TypeWithStr _ GroupStr
Group₀ : Type₁
Group₀ = Group {ℓ-zero}
group : (G : Type ℓ) (0g : G) (_+_ : G → G → G) (-_ : G → G) (h : IsGroup 0g _+_ -_) → Group
group G 0g _+_ -_ h = G , groupstr 0g _+_ -_ h
isSetGroup : (G : Group {ℓ}) → isSet ⟨ G ⟩
isSetGroup G = GroupStr.isGroup (snd G) .IsGroup.isMonoid .IsMonoid.isSemigroup .IsSemigroup.is-set
makeIsGroup : {G : Type ℓ} {0g : G} {_+_ : G → G → G} { -_ : G → G}
(is-setG : isSet G)
(assoc : (x y z : G) → x + (y + z) ≡ (x + y) + z)
(rid : (x : G) → x + 0g ≡ x)
(lid : (x : G) → 0g + x ≡ x)
(rinv : (x : G) → x + (- x) ≡ 0g)
(linv : (x : G) → (- x) + x ≡ 0g)
→ IsGroup 0g _+_ -_
IsGroup.isMonoid (makeIsGroup is-setG assoc rid lid rinv linv) = makeIsMonoid is-setG assoc rid lid
IsGroup.inverse (makeIsGroup is-setG assoc rid lid rinv linv) = λ x → rinv x , linv x
makeGroup : {G : Type ℓ} (0g : G) (_+_ : G → G → G) (-_ : G → G)
(is-setG : isSet G)
(assoc : (x y z : G) → x + (y + z) ≡ (x + y) + z)
(rid : (x : G) → x + 0g ≡ x)
(lid : (x : G) → 0g + x ≡ x)
(rinv : (x : G) → x + (- x) ≡ 0g)
(linv : (x : G) → (- x) + x ≡ 0g)
→ Group
makeGroup 0g _+_ -_ is-setG assoc rid lid rinv linv = _ , helper
where
helper : GroupStr _
GroupStr.0g helper = 0g
GroupStr._+_ helper = _+_
GroupStr.- helper = -_
GroupStr.isGroup helper = makeIsGroup is-setG assoc rid lid rinv linv
makeGroup-right : ∀ {ℓ} {A : Type ℓ}
→ (id : A)
→ (comp : A → A → A)
→ (inv : A → A)
→ (set : isSet A)
→ (assoc : ∀ a b c → comp a (comp b c) ≡ comp (comp a b) c)
→ (rUnit : ∀ a → comp a id ≡ a)
→ (rCancel : ∀ a → comp a (inv a) ≡ id)
→ Group
makeGroup-right id comp inv set assoc rUnit rCancel =
makeGroup id comp inv set assoc rUnit lUnit rCancel lCancel
where
_⨀_ = comp
abstract
lCancel : ∀ a → comp (inv a) a ≡ id
lCancel a =
inv a ⨀ a
≡⟨ sym (rUnit (comp (inv a) a)) ⟩
(inv a ⨀ a) ⨀ id
≡⟨ cong (comp (comp (inv a) a)) (sym (rCancel (inv a))) ⟩
(inv a ⨀ a) ⨀ (inv a ⨀ (inv (inv a)))
≡⟨ assoc _ _ _ ⟩
((inv a ⨀ a) ⨀ (inv a)) ⨀ (inv (inv a))
≡⟨ cong (λ □ → □ ⨀ _) (sym (assoc _ _ _)) ⟩
(inv a ⨀ (a ⨀ inv a)) ⨀ (inv (inv a))
≡⟨ cong (λ □ → (inv a ⨀ □) ⨀ (inv (inv a))) (rCancel a) ⟩
(inv a ⨀ id) ⨀ (inv (inv a))
≡⟨ cong (λ □ → □ ⨀ (inv (inv a))) (rUnit (inv a)) ⟩
inv a ⨀ (inv (inv a))
≡⟨ rCancel (inv a) ⟩
id
∎
lUnit : ∀ a → comp id a ≡ a
lUnit a =
id ⨀ a
≡⟨ cong (λ b → comp b a) (sym (rCancel a)) ⟩
(a ⨀ inv a) ⨀ a
≡⟨ sym (assoc _ _ _) ⟩
a ⨀ (inv a ⨀ a)
≡⟨ cong (comp a) (lCancel a) ⟩
a ⨀ id
≡⟨ rUnit a ⟩
a
∎
makeGroup-left : ∀ {ℓ} {A : Type ℓ}
→ (id : A)
→ (comp : A → A → A)
→ (inv : A → A)
→ (set : isSet A)
→ (assoc : ∀ a b c → comp a (comp b c) ≡ comp (comp a b) c)
→ (lUnit : ∀ a → comp id a ≡ a)
→ (lCancel : ∀ a → comp (inv a) a ≡ id)
→ Group
makeGroup-left id comp inv set assoc lUnit lCancel =
makeGroup id comp inv set assoc rUnit lUnit rCancel lCancel
where
abstract
rCancel : ∀ a → comp a (inv a) ≡ id
rCancel a =
comp a (inv a)
≡⟨ sym (lUnit (comp a (inv a))) ⟩
comp id (comp a (inv a))
≡⟨ cong (λ b → comp b (comp a (inv a))) (sym (lCancel (inv a))) ⟩
comp (comp (inv (inv a)) (inv a)) (comp a (inv a))
≡⟨ sym (assoc (inv (inv a)) (inv a) (comp a (inv a))) ⟩
comp (inv (inv a)) (comp (inv a) (comp a (inv a)))
≡⟨ cong (comp (inv (inv a))) (assoc (inv a) a (inv a)) ⟩
comp (inv (inv a)) (comp (comp (inv a) a) (inv a))
≡⟨ cong (λ b → comp (inv (inv a)) (comp b (inv a))) (lCancel a) ⟩
comp (inv (inv a)) (comp id (inv a))
≡⟨ cong (comp (inv (inv a))) (lUnit (inv a)) ⟩
comp (inv (inv a)) (inv a)
≡⟨ lCancel (inv a) ⟩
id
∎
rUnit : ∀ a → comp a id ≡ a
rUnit a =
comp a id
≡⟨ cong (comp a) (sym (lCancel a)) ⟩
comp a (comp (inv a) a)
≡⟨ assoc a (inv a) a ⟩
comp (comp a (inv a)) a
≡⟨ cong (λ b → comp b a) (rCancel a) ⟩
comp id a
≡⟨ lUnit a ⟩
a
∎
open GroupStr hiding (0g ; _+_ ; -_)
isSetCarrier : ∀ {ℓ} → (G : Group {ℓ}) → isSet ⟨ G ⟩
isSetCarrier G = IsSemigroup.is-set (IsMonoid.isSemigroup (GroupStr.isMonoid (snd G)))
open GroupStr
dirProd : ∀ {ℓ ℓ'} → Group {ℓ} → Group {ℓ'} → Group
dirProd (GC , G) (HC , H) =
makeGroup (0g G , 0g H)
(λ { (x1 , x2) (y1 , y2) → _+_ G x1 y1 , _+_ H x2 y2 })
(λ { (x1 , x2) → -_ G x1 , -_ H x2 })
(isSet× (isSetCarrier (GC , G)) (isSetCarrier (HC , H)))
(λ { (x1 , x2) (y1 , y2) (z1 , z2) i →
assoc G x1 y1 z1 i , assoc H x2 y2 z2 i })
(λ { (x1 , x2) i → GroupStr.rid G x1 i , GroupStr.rid H x2 i })
(λ { (x1 , x2) i → GroupStr.lid G x1 i , GroupStr.lid H x2 i })
(λ { (x1 , x2) i → GroupStr.invr G x1 i , GroupStr.invr H x2 i })
(λ { (x1 , x2) i → GroupStr.invl G x1 i , GroupStr.invl H x2 i })
trivialGroup : Group₀
trivialGroup = Unit , groupstr tt (λ _ _ → tt) (λ _ → tt)
(makeIsGroup isSetUnit (λ _ _ _ → refl) (λ _ → refl) (λ _ → refl)
(λ _ → refl) (λ _ → refl))
intGroup : Group₀
intGroup = Int , groupstr 0 _+Int_ (0 -Int_)
(makeIsGroup isSetInt +-assoc (λ x → refl) (λ x → +-comm 0 x)
(λ x → +-comm x (pos 0 -Int x) ∙ minusPlus x 0) (λ x → minusPlus x 0))
|
{
"alphanum_fraction": 0.4791636832,
"avg_line_length": 32.6308411215,
"ext": "agda",
"hexsha": "407277ce24e9f24734b3fab004f79925051a3e71",
"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": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "ayberkt/cubical",
"max_forks_repo_path": "Cubical/Algebra/Group/Base.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f",
"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": "ayberkt/cubical",
"max_issues_repo_path": "Cubical/Algebra/Group/Base.agda",
"max_line_length": 100,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "ayberkt/cubical",
"max_stars_repo_path": "Cubical/Algebra/Group/Base.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2786,
"size": 6983
}
|
{-# OPTIONS --cubical #-}
module n2o.Network.WebSocket where
open import proto.Base
open import proto.IO
open import n2o.Network.Internal
{-# FOREIGN GHC import Network.N2O.Web.WebSockets #-}
data N2OProto (A : Set) : Set where
Io : ByteString Strict → ByteString Strict → N2OProto A
Nop : N2OProto A
Cx : Set → Set
Cx = Context N2OProto
CxHandler : Set → Set
CxHandler a = Cx a → Cx a
-- mkHandler : ∀ {A : Set} (h : Set → IO A) → Set → IO A
-- mkHandler h m = h m >> return Empty -- TODO : monad instance for Result
postulate
runServer : ∀ {A : Set} → String → ℤ → Context N2OProto A → IO ⊤
{-# COMPILE GHC Cx = Network.N2O.Web.WebSockets.Cx #-}
{-# COMPILE GHC CxHandler = Network.N2O.Web.WebSockets.CxHandler #-}
{-# COMPILE GHC runServer = Network.N2O.Web.WebSockets.runServer #-}
{-# COMPILE GHC N2OProto = data Network.N2O.Web.Websockets.N2OProto ( Io | Nop ) #-}
|
{
"alphanum_fraction": 0.5936883629,
"avg_line_length": 30.7272727273,
"ext": "agda",
"hexsha": "9a0115180f2518e07b116f91b8cb8fa090d294e3",
"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": "d7903dfffcd66ae174eed9347afe008f892b2491",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "o4/n2o",
"max_forks_repo_path": "n2o/Network/WebSocket.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "d7903dfffcd66ae174eed9347afe008f892b2491",
"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": "o4/n2o",
"max_issues_repo_path": "n2o/Network/WebSocket.agda",
"max_line_length": 85,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "d7903dfffcd66ae174eed9347afe008f892b2491",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "o4/n2o",
"max_stars_repo_path": "n2o/Network/WebSocket.agda",
"max_stars_repo_stars_event_max_datetime": "2019-01-02T06:37:47.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-11-30T11:37:10.000Z",
"num_tokens": 289,
"size": 1014
}
|
-- Andreas, 2012-11-22 abstract aliases
module Issue729 where
abstract
B = Set
B₁ = B
B₂ = Set
abstract
foo : Set₁
foo = x
where x = B
{- does not work yet
mutual
abstract
D = C
C = B
-}
-- other stuff
private
A = Set
Y = let X = Set in Set
|
{
"alphanum_fraction": 0.6007462687,
"avg_line_length": 9.9259259259,
"ext": "agda",
"hexsha": "6795b923bcb47172a6bb3c418b927c1180e28ed7",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "test/succeed/Issue729.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "test/succeed/Issue729.agda",
"max_line_length": 39,
"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/Succeed/Issue729.agda",
"max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z",
"num_tokens": 99,
"size": 268
}
|
{-# OPTIONS --without-K --safe #-}
module root2 where
-- imports. We use the latest agda stdlib.
open import Data.Nat
open import Data.Nat.DivMod
open import Data.Nat.Properties
open import Data.Nat.Solver
open import Relation.Binary.PropositionalEquality
open import Data.Product
open import Data.Sum renaming (inj₁ to even ; inj₂ to odd)
open import Relation.Nullary
open import Data.Empty
-- Even predicate.
Even : ℕ -> Set
Even n = ∃ λ k → n ≡ 2 * k
-- Odd predicate.
Odd : ℕ -> Set
Odd n = ∃ λ k → n ≡ 1 + 2 * k
open +-*-Solver
-- Lemma: an even number cannot equal to an odd number.
lemma-even-odd-exclusive : ∀ k l -> ¬ 2 * k ≡ 1 + 2 * l
lemma-even-odd-exclusive k l hyp = z hyp'
where
z : ¬ 0 ≡ 1
z ()
n*m%n≡0 : ∀ m n .{{_ : NonZero n}} → (n * m) % n ≡ 0
n*m%n≡0 m n = begin
(n * m) % n ≡⟨ cong (_% n) (solve 2 (λ n m → n :* m := m :* n) refl n m) ⟩
(m * n) % n ≡⟨ m*n%n≡0 m n ⟩
0 ∎
where
open ≡-Reasoning
lem1%2 : 1 % 2 ≡ 1
lem1%2 = refl
hyp' : 0 ≡ 1
hyp' = begin
0 ≡⟨ sym (n*m%n≡0 k 2) ⟩
(2 * k) % 2 ≡⟨ cong (_% 2) hyp ⟩
(1 + 2 * l) % 2 ≡⟨ %-distribˡ-+ 1 (2 * l) 2 ⟩
((1 % 2) + ((2 * l) % 2)) % 2 ≡⟨ cong (_% 2) (cong₂ (_+_) lem1%2 (n*m%n≡0 l 2)) ⟩
(1 + 0) % 2 ≡⟨ refl ⟩
1 % 2 ≡⟨ refl ⟩
1 ∎
where
open ≡-Reasoning
-- Lemma: a natural number cannot be both even and odd.
lemma-even-odd-exclusive' : ∀ n -> ¬ (Even n × Odd n)
lemma-even-odd-exclusive' n ((k , eqn) , (l , eqn')) = lemma-even-odd-exclusive k l claim
where
claim : 2 * k ≡ 1 + 2 * l
claim = begin
2 * k ≡⟨ sym eqn ⟩
n ≡⟨ eqn' ⟩
1 + 2 * l ∎
where
open ≡-Reasoning
-- Lemma: a natrual number is either even or odd (but not both as shown by lemma-even-odd-exclusive').
Parity : (n : ℕ) -> Even n ⊎ Odd n
Parity zero = even (zero , refl)
Parity (suc n) with Parity n
... | even (k , eq) = odd (k , cong suc eq)
... | odd (k , eq) = even (suc k , claim)
where
claim : suc n ≡ suc (k + suc (k + 0))
claim = begin
suc n ≡⟨ refl ⟩
1 + n ≡⟨ cong (1 +_) eq ⟩
1 + suc (k + (k + 0)) ≡⟨ solve 1 (λ k → con 1 :+ (con 1 :+ (k :+ (k :+ con 0))) := con 1 :+ (k :+ (con 1 :+ (k :+ con 0)))) refl k ⟩
1 + (k + (1 + (k + 0))) ≡⟨ refl ⟩
suc (k + suc (k + 0)) ∎
where
open ≡-Reasoning
-- Auxillary lemmas:
lemma-div2 : ∀ n .{{_ : NonZero n}} -> n / 2 < n
lemma-div2 n = m/n<m n 2 (s≤s (s≤s z≤n))
lemma-<-< : ∀ {a b c} -> a < b -> b < suc c -> a < c
lemma-<-< (s≤s ab) (s≤s bc) = <-transˡ (s≤s ab) bc
lemma-div2' : ∀ n b .{{_ : NonZero n}} -> n < 1 + b -> n / 2 < b
lemma-div2' n b n1b = lemma-<-< (lemma-div2 n) n1b
-- We do a case split in the parity of m and n. For each of the four
-- cases, we can derive a contradiction using induction on the bound
-- of m and n.
lemma-root2-irra : ∀ b m n -> ¬ m ≡ 0 -> ¬ n ≡ 0 → m < b → n < b → ¬ m * m ≡ 2 * (n * n)
lemma-root2-irra (suc b) 0 0 mnz nnz mlb nlb hyp = mnz refl
lemma-root2-irra (suc b) 0 (suc n) mnz nnz mlb nlb hyp = mnz refl
lemma-root2-irra (suc b) (suc m) 0 mnz nnz mlb nlb hyp = nnz refl
lemma-root2-irra (suc b) m@(suc m') n@(suc n') mnz nnz mlb nlb hyp with Parity m | Parity n
... | even (k , eqm) | even (l , eqn) = ih
where
factor-four : 4 * (k * k) ≡ 4 * (2 * (l * l))
factor-four = begin
4 * (k * k) ≡⟨ solve 1 (λ k → con 4 :* (k :* k) := (con 2 :* k) :* (con 2 :* k)) refl k ⟩
(2 * k) * (2 * k) ≡⟨ cong₂ _*_ (sym eqm) (sym eqm) ⟩
m * m ≡⟨ hyp ⟩
2 * (n * n) ≡⟨ cong (2 *_) (cong₂ _*_ eqn eqn) ⟩
2 * ((2 * l) * (2 * l)) ≡⟨ solve 1 (λ l → con 2 :* ((con 2 :* l) :* (con 2 :* l)) := con 4 :* (con 2 :* (l :* l))) refl l ⟩
4 * (2 * (l * l)) ∎
where
open ≡-Reasoning
hyp' : k * k ≡ 2 * (l * l)
hyp' = *-cancelˡ-≡ 4 factor-four
klb : k < b
klb = begin-strict
k ≡⟨ sym (m*n/n≡m k 2) ⟩
(k * 2) / 2 ≡⟨ cong (_/ 2) (solve 1 (λ k → k :* con 2 := con 2 :* k) refl k) ⟩
(2 * k) / 2 ≡⟨ cong (_/ 2) (sym eqm) ⟩
m / 2 <⟨ lemma-div2' m b mlb ⟩
b ∎
where
open ≤-Reasoning
llb : l < b
llb = begin-strict
l ≡⟨ sym (m*n/n≡m l 2) ⟩
(l * 2) / 2 ≡⟨ cong (_/ 2) (solve 1 (λ l → l :* con 2 := con 2 :* l) refl l) ⟩
(2 * l) / 2 ≡⟨ cong (_/ 2) (sym eqn) ⟩
n / 2 <⟨ lemma-div2' n b nlb ⟩
b ∎
where
open ≤-Reasoning
knz : ¬ k ≡ 0
knz k0 = mnz m0
where
m0 : m ≡ 0
m0 = begin
m ≡⟨ eqm ⟩
2 * k ≡⟨ cong (2 *_) k0 ⟩
2 * 0 ≡⟨ refl ⟩
0 ∎
where
open ≡-Reasoning
lnz : ¬ l ≡ 0
lnz l0 = nnz n0
where
n0 : n ≡ 0
n0 = begin
n ≡⟨ eqn ⟩
2 * l ≡⟨ cong (2 *_) l0 ⟩
2 * 0 ≡⟨ refl ⟩
0 ∎
where
open ≡-Reasoning
ih : ⊥
ih = lemma-root2-irra b k l knz lnz klb llb hyp'
... | even (k , eqm) | odd (l , eqn) = lemma-even-odd-exclusive' (n * n) (even-right , odd-right)
where
even-left : Even (m * m)
even-left = 2 * (k * k) , claim
where
claim : m * m ≡ 2 * (2 * (k * k))
claim = begin
m * m ≡⟨ cong₂ _*_ eqm eqm ⟩
(2 * k) * (2 * k) ≡⟨ solve 1 (λ k → (con 2 :* k) :* (con 2 :* k) := con 2 :* (con 2 :* (k :* k))) refl k ⟩
2 * (2 * (k * k)) ∎
where
open ≡-Reasoning
odd-right : Odd (n * n)
odd-right = (2 * (l * l) + 2 * l) , claim
where
claim : n * n ≡ 1 + 2 * (2 * (l * l) + 2 * l)
claim = begin
n * n ≡⟨ cong₂ _*_ eqn eqn ⟩
(1 + 2 * l) * (1 + 2 * l) ≡⟨ solve 1 (λ l → (con 1 :+ con 2 :* l) :* (con 1 :+ con 2 :* l) := con 1 :+ (con 2 :* ((con 2 :* (l :* l)) :+ con 2 :* l))) refl l ⟩
1 + 2 * (2 * (l * l) + 2 * l) ∎
where
open ≡-Reasoning
2*n*n≡2*2*k*k : 2 * (n * n) ≡ 2 * (2 * (k * k))
2*n*n≡2*2*k*k = begin
2 * (n * n) ≡⟨ sym hyp ⟩
m * m ≡⟨ (let (_ , p) = even-left in p) ⟩
2 * (2 * (k * k)) ∎
where
open ≡-Reasoning
n*n≡2*k*k : (n * n) ≡ (2 * (k * k))
n*n≡2*k*k = *-cancelˡ-≡ 2 2*n*n≡2*2*k*k
even-right : Even (n * n)
even-right = k * k , (n*n≡2*k*k)
... | odd (k , eqn) | _ = lemma-even-odd-exclusive' (m * m) (even-left , odd-left)
where
odd-left : Odd (m * m)
odd-left = (2 * (k * k) + 2 * k) , claim
where
claim : m * m ≡ 1 + 2 * (2 * (k * k) + 2 * k)
claim = begin
m * m ≡⟨ cong₂ _*_ eqn eqn ⟩
(1 + 2 * k) * (1 + 2 * k) ≡⟨ solve 1 (λ k → (con 1 :+ con 2 :* k) :* (con 1 :+ con 2 :* k) := con 1 :+ (con 2 :* ((con 2 :* (k :* k)) :+ con 2 :* k))) refl k ⟩
1 + 2 * (2 * (k * k) + 2 * k) ∎
where
open ≡-Reasoning
even-left : Even (m * m)
even-left = (n * n) , hyp
-- Main theorem: for any natural number m and n, it impossible that m
-- * m ≡ 2 * (n * n) except when m ≡ 0 and n ≡ 0 (in this situation,
-- m/n is not defined), in other words, no rational number equals √2.
theorem-root2-irra : ∀ m n -> m * m ≡ 2 * (n * n) -> m ≡ 0 × n ≡ 0
theorem-root2-irra zero zero hyp = (refl , refl )
theorem-root2-irra zero n@(suc n') hyp = (refl , sym 0≡n )
where
2*0≡2*n*n : 2 * 0 ≡ 2 * (n * n)
2*0≡2*n*n = hyp
0≡n*n : 0 ≡ n * n
0≡n*n = *-cancelˡ-≡ 2 hyp
n*0≡n*n : n * 0 ≡ n * n
n*0≡n*n = begin
n * 0 ≡⟨ *-comm n 0 ⟩
0 * n ≡⟨ refl ⟩
0 ≡⟨ 0≡n*n ⟩
n * n ∎
where
open ≡-Reasoning
0≡n : 0 ≡ n
0≡n = *-cancelˡ-≡ n n*0≡n*n
theorem-root2-irra m@(suc m') n@(suc n') hyp = ⊥-elim claim
where
-- m ⊔ n = max m n
b = 1 + (m ⊔ n)
mlb : m < b
mlb = s≤s (m≤m⊔n m n)
nlb : n < b
nlb = s≤s (m≤n⊔m m n)
claim = lemma-root2-irra b m n (λ ()) (λ ()) mlb nlb hyp
|
{
"alphanum_fraction": 0.4343998016,
"avg_line_length": 30.3157894737,
"ext": "agda",
"hexsha": "7693556ce7499f63e24c0ff8ce50cdc89f6fa7dc",
"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": "1e50ef1caffc2a4d2e2f8bc7aaa969acc1ba1cc4",
"max_forks_repo_licenses": [
"CC0-1.0"
],
"max_forks_repo_name": "onestruggler/root2",
"max_forks_repo_path": "root2.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "1e50ef1caffc2a4d2e2f8bc7aaa969acc1ba1cc4",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"CC0-1.0"
],
"max_issues_repo_name": "onestruggler/root2",
"max_issues_repo_path": "root2.agda",
"max_line_length": 169,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "1e50ef1caffc2a4d2e2f8bc7aaa969acc1ba1cc4",
"max_stars_repo_licenses": [
"CC0-1.0"
],
"max_stars_repo_name": "onestruggler/root2",
"max_stars_repo_path": "root2.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3622,
"size": 8064
}
|
module pretty where
open import general-util
-- Adapted from A Prettier Printer (Philip Wadler)
-- https://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf
-- The pretty printer
infixr 5 _:<|>_
infixr 6 _:<>_
infixr 6 _<>_
data DOC : Set where
NIL : DOC
_:<>_ : DOC → DOC → DOC
NEST : ℕ → DOC → DOC
TEXT : rope → DOC
LINE : DOC
_:<|>_ : DOC → DOC → DOC
data Doc : Set where
Nil : Doc
_Text_ : rope → Doc → Doc
_Line_ : ℕ → Doc → Doc
nil = NIL
_<>_ = _:<>_
nest = NEST
text = TEXT
line = LINE
flatten : DOC → DOC
flatten NIL = NIL
flatten (x :<> y) = flatten x :<> flatten y
flatten (NEST i x) = NEST i (flatten x)
flatten (TEXT s) = TEXT s
flatten LINE = TEXT [[ " " ]]
flatten (x :<|> y) = flatten x
flatten-out : DOC → rope
flatten-out NIL = [[]]
flatten-out (x :<> y) = flatten-out x ⊹⊹ flatten-out y
flatten-out (NEST i x) = flatten-out x
flatten-out (TEXT s) = s
flatten-out LINE = [[ " " ]]
flatten-out (x :<|> y) = flatten-out x
group = λ x → flatten x :<|> x
fold : ∀ {ℓ} {X : Set ℓ} → ℕ → X → (X → X) → X
fold 0 z s = z
fold (suc n) z s = s (fold n z s)
copy : ∀ {ℓ} {X : Set ℓ} → ℕ → X → 𝕃 X
copy i x = fold i [] (x ::_)
layout : Doc → rope
layout Nil = [[]]
layout (s Text x) = s ⊹⊹ layout x
layout (i Line x) = [[ 𝕃char-to-string ('\n' :: copy i ' ') ]] ⊹⊹ layout x
_∸'_ : ℕ → ℕ → maybe ℕ
m ∸' n with suc m ∸ n
...| zero = nothing
...| suc o = just o
fits : maybe ℕ → Doc → 𝔹
fits nothing x = ff
fits (just w) Nil = tt
fits (just w) (s Text x) = fits (w ∸' rope-length s) x
fits (just w) (i Line x) = tt
{-# TERMINATING #-}
be : ℕ → ℕ → 𝕃 (ℕ × DOC) → Doc
better : ℕ → ℕ → Doc → Doc → Doc
best : ℕ → ℕ → DOC → Doc
better w k x y = if fits (w ∸' k) x then x else y
best w k x = be w k [ 0 , x ]
be w k [] = Nil
be w k ((i , NIL) :: z) = be w k z
be w k ((i , x :<> y) :: z) = be w k ((i , x) :: (i , y) :: z)
be w k ((i , NEST j x) :: z) = be w k ((i + j , x) :: z)
be w k ((i , TEXT s) :: z) = s Text be w (k + rope-length s) z
be w k ((i , LINE) :: z) = i Line be w i z
be w k ((i , x :<|> y) :: z) = better w k (be w k ((i , x) :: z)) (be w k ((i , y) :: z))
pretty : ℕ → DOC → rope
pretty w x = layout (best w 0 x)
-- Utility functions
infixr 6 _<+>_ _</>_ _<+/>_
_<+>_ : DOC → DOC → DOC
x <+> y = x <> text [[ " " ]] <> y
_</>_ : DOC → DOC → DOC
x </> y = x <> line <> y
folddoc : (DOC → DOC → DOC) → 𝕃 DOC → DOC
folddoc f [] = nil
folddoc f (x :: []) = x
folddoc f (x :: xs) = f x (folddoc f xs)
spread = folddoc _<+>_
stack = folddoc _</>_
bracket : string → DOC → string → DOC
bracket l x r = group (text [[ l ]] <> nest 2 (line <> x) <> line <> text [[ r ]])
_<+/>_ : DOC → DOC → DOC
x <+/> y = x <> (text [[ " " ]] :<|> line) <> y
{-# TERMINATING #-}
fill : 𝕃 DOC → DOC
fill [] = nil
fill (x :: []) = x
fill (x :: y :: zs) = (flatten x <+> fill (flatten y :: zs)) :<|> (x </> fill (y :: zs))
{-# TERMINATING #-}
filln : 𝕃 (ℕ × DOC) → DOC
filln [] = nil
filln ((i , x) :: []) = nest i x
filln ((i , x) :: (j , y) :: zs) =
(flatten x <+> filln ((j , flatten y) :: zs))
:<|> (nest i x <> nest j line <> filln ((j , y) :: zs))
{-# TERMINATING #-}
fill-last : ℕ → 𝕃 DOC → DOC
fill-last i [] = nil
fill-last i (x :: []) = nest i x
fill-last i (x :: y :: []) = (flatten x <+> flatten y) :<|> (nest i (x </> y))
fill-last i (x :: y :: zs) = (flatten x <+> fill-last i (flatten y :: zs)) :<|> (x </> fill-last i (y :: zs))
|
{
"alphanum_fraction": 0.5094007051,
"avg_line_length": 23.9718309859,
"ext": "agda",
"hexsha": "f87204b532daf0bbc6bdd5c259256fdf76fc1554",
"lang": "Agda",
"max_forks_count": 34,
"max_forks_repo_forks_event_max_datetime": "2022-02-20T18:33:16.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-09-17T11:51:36.000Z",
"max_forks_repo_head_hexsha": "75f72bf2e41ac4042efc3128fa9958d4cd69b947",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mudathirmahgoub/cedille",
"max_forks_repo_path": "src/pretty.agda",
"max_issues_count": 123,
"max_issues_repo_head_hexsha": "75f72bf2e41ac4042efc3128fa9958d4cd69b947",
"max_issues_repo_issues_event_max_datetime": "2022-01-12T03:51:28.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-09-17T10:53:20.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "mudathirmahgoub/cedille",
"max_issues_repo_path": "src/pretty.agda",
"max_line_length": 109,
"max_stars_count": 328,
"max_stars_repo_head_hexsha": "75f72bf2e41ac4042efc3128fa9958d4cd69b947",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mudathirmahgoub/cedille",
"max_stars_repo_path": "src/pretty.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-26T10:33:07.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-09-14T20:06:09.000Z",
"num_tokens": 1352,
"size": 3404
}
|
{-# OPTIONS --without-K --safe #-}
open import Categories.Category.Core using (Category)
module Categories.Diagram.Pushout {o ℓ e} (C : Category o ℓ e) where
open Category C
open HomReasoning
open import Level
private
variable
A B E X Y Z : Obj
record Pushout (f : X ⇒ Y) (g : X ⇒ Z) : Set (o ⊔ ℓ ⊔ e) where
field
{Q} : Obj
i₁ : Y ⇒ Q
i₂ : Z ⇒ Q
field
commute : i₁ ∘ f ≈ i₂ ∘ g
universal : {h₁ : Y ⇒ B} {h₂ : Z ⇒ B} → h₁ ∘ f ≈ h₂ ∘ g → Q ⇒ B
unique : {h₁ : Y ⇒ E} {h₂ : Z ⇒ E} {j : Q ⇒ E} {eq : h₁ ∘ f ≈ h₂ ∘ g} →
j ∘ i₁ ≈ h₁ → j ∘ i₂ ≈ h₂ →
j ≈ universal eq
universal∘i₁≈h₁ : {h₁ : Y ⇒ E} {h₂ : Z ⇒ E} {eq : h₁ ∘ f ≈ h₂ ∘ g} →
universal eq ∘ i₁ ≈ h₁
universal∘i₂≈h₂ : {h₁ : Y ⇒ E} {h₂ : Z ⇒ E} {eq : h₁ ∘ f ≈ h₂ ∘ g} →
universal eq ∘ i₂ ≈ h₂
|
{
"alphanum_fraction": 0.4583333333,
"avg_line_length": 26.9090909091,
"ext": "agda",
"hexsha": "f0e4c47b0285a0789e23b21d66a212de56484bf5",
"lang": "Agda",
"max_forks_count": 64,
"max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z",
"max_forks_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bblfish/agda-categories",
"max_forks_repo_path": "src/Categories/Diagram/Pushout.agda",
"max_issues_count": 236,
"max_issues_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a",
"max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "bblfish/agda-categories",
"max_issues_repo_path": "src/Categories/Diagram/Pushout.agda",
"max_line_length": 78,
"max_stars_count": 279,
"max_stars_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bblfish/agda-categories",
"max_stars_repo_path": "src/Categories/Diagram/Pushout.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z",
"num_tokens": 374,
"size": 888
}
|
module Prelude.Product where
open import Agda.Primitive
open import Agda.Builtin.Sigma public
open import Prelude.Function
open import Prelude.Equality
open import Prelude.Decidable
open import Prelude.Ord
instance
ipair : ∀ {a b} {A : Set a} {B : A → Set b} {{x : A}} {{y : B x}} → Σ A B
ipair {{x}} {{y}} = x , y
infixr 3 _×_
_×_ : ∀ {a b} → Set a → Set b → Set (a ⊔ b)
A × B = Σ A (λ _ → B)
_,′_ : ∀ {a b} {A : Set a} {B : Set b} → A → B → A × B
_,′_ = _,_
uncurry : ∀ {a b c} {A : Set a} {B : A → Set b} {C : ∀ x → B x → Set c} →
(∀ x (y : B x) → C x y) → (p : Σ A B) → C (fst p) (snd p)
uncurry f (x , y) = f x y
uncurry′ : ∀ {a b c} {A : Set a} {B : A → Set b} {C : Set c} →
(∀ x → B x → C) → Σ A B → C
uncurry′ f (x , y) = f x y
curry : ∀ {a b c} {A : Set a} {B : A → Set b} {C : Σ A B → Set c} →
(∀ p → C p) → ∀ x (y : B x) → C (x , y)
curry f x y = f (x , y)
infixr 3 _***_ _***′_ _&&&_
_***_ : ∀ {a₁ a₂ b₁ b₂} {A₁ : Set a₁} {A₂ : Set a₂} {B₁ : A₁ → Set b₁} {B₂ : A₂ → Set b₂}
(f : A₁ → A₂) → (∀ {x} → B₁ x → B₂ (f x)) → Σ A₁ B₁ → Σ A₂ B₂
(f *** g) (x , y) = f x , g y
_***′_ : ∀ {a₁ a₂ b₁ b₂} {A₁ : Set a₁} {A₂ : Set a₂} {B₁ : Set b₁} {B₂ : Set b₂} →
(A₁ → A₂) → (B₁ → B₂) → A₁ × B₁ → A₂ × B₂
(f ***′ g) (x , y) = f x , g y
_&&&_ : ∀ {c a b} {C : Set c} {A : Set a} {B : A → Set b}
(f : C → A) → (∀ x → B (f x)) → C → Σ A B
(f &&& g) x = f x , g x
first : ∀ {a₁ a₂ b} {A₁ : Set a₁} {A₂ : Set a₂} {B : Set b} →
(A₁ → A₂) → A₁ × B → A₂ × B
first f = f *** id
second : ∀ {a b₁ b₂} {A : Set a} {B₁ : A → Set b₁} {B₂ : A → Set b₂} →
(∀ {x} → B₁ x → B₂ x) → Σ A B₁ → Σ A B₂
second f = id *** f
-- Eq instance --
sigma-inj-fst : ∀ {a b} {A : Set a} {B : A → Set b} {x : A} {y : B x}
{x₁ : A} {y₁ : B x₁} →
(x , y) ≡ (x₁ , y₁) → x ≡ x₁
sigma-inj-fst refl = refl
sigma-inj-snd : ∀ {a b} {A : Set a} {B : A → Set b} {x : A} {y y₁ : B x} →
_≡_ {A = Σ A B} (x , y) (x , y₁) → y ≡ y₁
sigma-inj-snd refl = refl
instance
EqSigma : ∀ {a b} {A : Set a} {B : A → Set b} {{EqA : Eq A}} {{EqB : ∀ {x} → Eq (B x)}} → Eq (Σ A B)
_==_ {{EqSigma}} (x , y) (x₁ , y₁) with x == x₁
_==_ {{EqSigma}} (x , y) (x₁ , y₁) | no neq = no λ eq → neq (sigma-inj-fst eq)
_==_ {{EqSigma}} (x , y) (.x , y₁) | yes refl with y == y₁
_==_ {{EqSigma}} (x , y) (.x , y₁) | yes refl | no neq = no λ eq → neq (sigma-inj-snd eq)
_==_ {{EqSigma}} (x , y) (.x , .y) | yes refl | yes refl = yes refl
-- Ord instance --
data LexiographicOrder {a b} {A : Set a} {B : A → Set b}
(_<A_ : A → A → Set a) (_<B_ : ∀ {x} → B x → B x → Set b) :
Σ A B → Σ A B → Set (a ⊔ b) where
fst< : ∀ {x₁ x₂} {y₁ : B x₁} {y₂ : B x₂} → x₁ <A x₂ → LexiographicOrder _<A_ _<B_ (x₁ , y₁) (x₂ , y₂)
snd< : ∀ {x} {y₁ y₂ : B x} → y₁ <B y₂ → LexiographicOrder _<A_ _<B_ (x , y₁) (x , y₂)
module _ {a b} {A : Set a} {B : A → Set b} {{OrdA : Ord A}} {{OrdB : ∀ {x} → Ord (B x)}} where
private
cmpSigma : (x y : Σ A B) → Comparison (LexiographicOrder _<_ _<_) x y
cmpSigma (x , y) (x₁ , y₁) with compare x x₁
cmpSigma (x , y) (x₁ , y₁) | less x<x₁ = less (fst< x<x₁)
cmpSigma (x , y) (x₁ , y₁) | greater x₁<x = greater (fst< x₁<x)
cmpSigma (x , y) (.x , y₁) | equal refl with compare y y₁
cmpSigma (x₁ , y) (.x₁ , y₁) | equal refl | less y<y₁ = less (snd< y<y₁)
cmpSigma (x₁ , y) (.x₁ , y₁) | equal refl | greater y₁<y = greater (snd< y₁<y)
cmpSigma (x₁ , y) (.x₁ , .y) | equal refl | equal refl = equal refl
from-eq : (x y : Σ A B) → x ≡ y → LexiographicOrder _<_ _≤_ x y
from-eq (x , y) (.x , .y) refl = snd< (eq-to-leq (refl {x = y}))
from-lt : (x y : Σ A B) → LexiographicOrder _<_ _<_ x y → LexiographicOrder _<_ _≤_ x y
from-lt (x₁ , y₁) (x₂ , y₂) (fst< lt) = fst< lt
from-lt (x , y₁) (.x , y₂) (snd< lt) = snd< (lt-to-leq {x = y₁} lt)
from-leq : (x y : Σ A B) → LexiographicOrder _<_ _≤_ x y → LessEq (LexiographicOrder _<_ _<_) x y
from-leq (a , b) (a₁ , b₁) (fst< a<a₁) = less (fst< a<a₁)
from-leq (a , b) (.a , b₁) (snd< b≤b₁) with leq-to-lteq {{OrdB}} b≤b₁
... | less b<b₁ = less (snd< b<b₁)
... | equal b=b₁ = equal ((a ,_) $≡ b=b₁)
instance
OrdSigma : Ord (Σ A B)
Ord._<_ OrdSigma = _
Ord._≤_ OrdSigma = LexiographicOrder _<_ _≤_
Ord.compare OrdSigma = cmpSigma
Ord.eq-to-leq OrdSigma = from-eq _ _
Ord.lt-to-leq OrdSigma = from-lt _ _
Ord.leq-to-lteq OrdSigma = from-leq _ _
module _ {a b} {A : Set a} {B : A → Set b} {{OrdA : Ord/Laws A}} {{OrdB : ∀ {x} → Ord/Laws (B x)}} where
OrdLawsSigma : Ord/Laws (Σ A B)
Ord/Laws.super OrdLawsSigma = OrdSigma {{OrdB = OrdB .Ord/Laws.super}}
less-antirefl {{OrdLawsSigma}} (fst< lt) = less-antirefl {A = A} lt
less-antirefl {{OrdLawsSigma}} (snd< {x = x} lt) = less-antirefl {A = B x} lt
less-trans {{OrdLawsSigma}} (fst< lt) (fst< lt₁) = fst< (less-trans {A = A} lt lt₁)
less-trans {{OrdLawsSigma}} (fst< lt) (snd< lt₁) = fst< lt
less-trans {{OrdLawsSigma}} (snd< lt) (fst< lt₁) = fst< lt₁
less-trans {{OrdLawsSigma}} (snd< {x = x} lt) (snd< lt₁) = snd< (less-trans {A = B x} lt lt₁)
|
{
"alphanum_fraction": 0.474738024,
"avg_line_length": 42.752,
"ext": "agda",
"hexsha": "b6edec1fb1e082e81db32c20c775db3df10a68b6",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "lclem/agda-prelude",
"max_forks_repo_path": "src/Prelude/Product.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "lclem/agda-prelude",
"max_issues_repo_path": "src/Prelude/Product.agda",
"max_line_length": 104,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "lclem/agda-prelude",
"max_stars_repo_path": "src/Prelude/Product.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2395,
"size": 5344
}
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Data.DescendingList where
open import Cubical.Data.DescendingList.Base public
open import Cubical.Data.DescendingList.Properties public
open import Cubical.Data.DescendingList.Examples public
open import Cubical.Data.DescendingList.Strict public
open import Cubical.Data.DescendingList.Strict.Properties public
|
{
"alphanum_fraction": 0.8337730871,
"avg_line_length": 37.9,
"ext": "agda",
"hexsha": "3faf3cad8e634876b4fab72a529667d1be35150c",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dan-iel-lee/cubical",
"max_forks_repo_path": "Cubical/Data/DescendingList.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "dan-iel-lee/cubical",
"max_issues_repo_path": "Cubical/Data/DescendingList.agda",
"max_line_length": 64,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "dan-iel-lee/cubical",
"max_stars_repo_path": "Cubical/Data/DescendingList.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 80,
"size": 379
}
|
import Lvl
-- TODO: Is it possible formalize this like this? Is it even correct?
-- Based on http://www.maths.ed.ac.uk/~tl/edinburgh_yrm/ (2017-11-22)
module Sets.ETCS where
open import Logic.Propositional
module Theory (S : Set(Lvl.𝟎)) (F : S → S → Set(Lvl.𝟎)) (_∘_ : ∀{a b c} → F(b)(c) → F(a)(b) → F(a)(c)) (_≡_ : ∀{a b} → F(a)(b) → F(a)(b) → Stmt{Lvl.𝟎}) where
open import Functional hiding (_∘_)
open import Logic.Predicate{Lvl.𝟎}{Lvl.𝟎}
open import Logic.Propositional.Theorems{Lvl.𝟎}
open import Relator.Equals{Lvl.𝟎} using () renaming (_≡_ to _≡ᵣ_)
open import Type{Lvl.𝟎}
Terminal : S → Stmt
Terminal(x) = (∀{a : S} → (f g : F(a)(x)) → (f ≡ g))
record Axioms : Set(Lvl.𝐒(Lvl.𝟎)) where
field
associativity : ∀{a b c d : S}{f : F(a)(b)}{g : F(b)(c)}{h : F(c)(d)} → ((h ∘ (g ∘ f)) ≡ ((h ∘ g) ∘ f))
identity : ∀{a : S} → ∃{F(a)(a)}(id ↦ (∀{b : S}{f : F(a)(b)} → ((f ∘ id) ≡ f)) ∧ (∀{b : S}{f : F(b)(a)} → ((id ∘ f) ≡ f)))
terminal : ∃(term ↦ Terminal(term))
𝟏 : S
𝟏 = [∃]-witness(terminal)
_∈_ : ∀{a b : S} → F(a)(b) → S → Stmt
_∈_ {a}{b} x X = (a ≡ᵣ 𝟏)∧(b ≡ᵣ X)
_∉_ : ∀{a b : S} → F(a)(b) → S → Stmt
_∉_ x X = ¬(x ∈ X)
field
empty : ∃{S}(∅ ↦ ∀{a b : S}{f : F(a)(b)} → (f ∉ ∅))
-- TODO
module Construction where
open import Data
open import Functional using (_∘_ ; id)
open import Logic.Predicate{Lvl.𝐒(Lvl.𝟎)}{Lvl.𝟎}
open import Logic.Propositional.Theorems{Lvl.𝐒(Lvl.𝟎)}
open import Relator.Equals{Lvl.𝟎}
Terminal : Set → Stmt
Terminal(x) = (∀{a : Set}{f g : a → x} → (f ≡ g))
_∈_ : ∀{a b : Set} → (a → b) → Set → Stmt
_∈_ {a}{b} _ X = (a ≡ Unit)∧(b ≡ X)
∅ : Set
∅ = Empty
-- TODO: Maybe use FunctionEquals instead?
-- TODO: Is this construction working? Try to prove some of the theorems of standard set theory
|
{
"alphanum_fraction": 0.5138381201,
"avg_line_length": 33.0172413793,
"ext": "agda",
"hexsha": "3d5a5c58b3a112b2ea2697f07e8d3237460d5d5a",
"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/Sets/ETCS.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/Sets/ETCS.agda",
"max_line_length": 159,
"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/Sets/ETCS.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": 827,
"size": 1915
}
|
module Lectures.Two where
-- Introduce imports
open import Lectures.One
-- Introduce type parameters
module List-types where
data List (A : Set₁) : Set₁ where
[] : List A
_∷_ : A → List A → List A
_ : List Set
_ = ⊥ ∷ (ℕ ∷ (⊤ ∷ []))
module List {ℓ} where
data List (A : Set ℓ) : Set ℓ where
[] : List A
_∷_ : A → List A → List A
_++_ : {A : Set ℓ} → List A → List A → List A
[] ++ ys = ys
(x ∷ xs) ++ ys = x ∷ (xs ++ ys)
map : {A B : Set ℓ} → (A → B) → List A → List B
map f [] = []
map f (x ∷ xs) = f x ∷ map f xs
open List using (List; []; _∷_)
_ : List ℕ
_ = 0 ∷ (1 ∷ (2 ∷ []))
-- Introduce type families
module Vec where
data Vec (A : Set) : ℕ → Set where
[] : Vec A zero
_∷_ : ∀ {n} → A → Vec A n → Vec A (suc n)
head : ∀ {A n} → Vec A (suc n) → A
head (x ∷ xs) = x
_++_ : ∀ {A n m} → Vec A n → Vec A m → Vec A (n + m)
[] ++ ys = ys
(x ∷ xs) ++ ys = x ∷ (xs ++ ys)
map : ∀ {A B n} → (A → B) → Vec A n → Vec B n
map f [] = []
map f (x ∷ xs) = f x ∷ map f xs
zipWith : ∀ {A B C : Set} {n} (f : A → B → C)
→ Vec A n → Vec B n → Vec C n
zipWith f [] [] = []
zipWith f (x ∷ xs) (y ∷ ys) = f x y ∷ zipWith f xs ys
-- \u+
data _⊎_ (A : Set) (B : Set) : Set where
inj₁ : A → A ⊎ B
inj₂ : B → A ⊎ B
Dec : Set → Set
Dec B = B ⊎ (¬ B)
private
data _×'_ (A : Set) (B : Set) : Set where
_,'_ : A → B → A ×' B
record _×''_ (A : Set) (B : Set) : Set where
constructor _,''_
field
proj₁ : A
proj₂ : B
-- \Sigma
record Σ {ℓ} (A : Set ℓ) (B : A → Set ℓ) : Set ℓ where
constructor _,_
field
proj₁ : A
proj₂ : B proj₁
open Σ public
_ : Σ ℕ _isEven
_ = 0 , tt
_×_ : Set → Set → Set
A × B = Σ A λ _ → B
|
{
"alphanum_fraction": 0.4663212435,
"avg_line_length": 18.8804347826,
"ext": "agda",
"hexsha": "4fc0491a3c56a0cfd6997747821ad7403e95c260",
"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": "d9359c5bfd0eaf69efe1113945d7f3145f6b2dff",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "UoG-Agda/Agda101",
"max_forks_repo_path": "Lectures/Two.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "d9359c5bfd0eaf69efe1113945d7f3145f6b2dff",
"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": "UoG-Agda/Agda101",
"max_issues_repo_path": "Lectures/Two.agda",
"max_line_length": 55,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "d9359c5bfd0eaf69efe1113945d7f3145f6b2dff",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "UoG-Agda/Agda101",
"max_stars_repo_path": "Lectures/Two.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 757,
"size": 1737
}
|
{- 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 Level
open import Function
open import Category.Functor
open import Relation.Binary.PropositionalEquality
module Optics.Functorial where
Lens' : (F : Set → Set) → RawFunctor F → Set → Set → Set
Lens' F _ S A = (A → F A) → S → F S
data Lens (S A : Set) : Set₁ where
lens : ((F : Set → Set)(rf : RawFunctor F) → Lens' F rf S A)
→ Lens S A
private
cf : {A : Set} → RawFunctor {Level.zero} (const A)
cf = record { _<$>_ = λ x x₁ → x₁ }
if : RawFunctor {Level.zero} id
if = record { _<$>_ = λ x x₁ → x x₁ }
-- We can make lenses relatively painlessly without requiring reflection
-- by providing getter and setter functions
mkLens' : ∀ {A B : Set}
→ (B → A)
→ (B → A → B)
→ Lens B A
mkLens' {A} {B} get set =
lens (λ F rf f b → Category.Functor.RawFunctor._<$>_
{F = F} rf
{A = A}
{B = B}
(set b)
(f (get b)))
-- Getter:
-- this is typed as ^\.
_^∙_ : ∀{S A} → S → Lens S A → A
_^∙_ {_} {A} s (lens p) = p (const A) cf id s
-- Setter:
set : ∀{S A} → Lens S A → A → S → S
set (lens p) a s = p id if (const a) s
syntax set p a s = s [ p := a ]
-- Modifier:
over : ∀{S A} → Lens S A → (A → A) → S → S
over (lens p) f s = p id if f s
syntax over p f s = s [ p %~ f ]
-- Composition
infixr 30 _∙_
_∙_ : ∀{S A B} → Lens S A → Lens A B → Lens S B
(lens p) ∙ (lens q) = lens (λ F rf x x₁ → p F rf (q F rf x) x₁)
|
{
"alphanum_fraction": 0.5238359202,
"avg_line_length": 27.7538461538,
"ext": "agda",
"hexsha": "57299b57c41e0f4f6e7a008fab4585f0aaa48804",
"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": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084",
"max_forks_repo_licenses": [
"UPL-1.0"
],
"max_forks_repo_name": "cwjnkins/bft-consensus-agda",
"max_forks_repo_path": "Optics/Functorial.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084",
"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": "cwjnkins/bft-consensus-agda",
"max_issues_repo_path": "Optics/Functorial.agda",
"max_line_length": 111,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084",
"max_stars_repo_licenses": [
"UPL-1.0"
],
"max_stars_repo_name": "cwjnkins/bft-consensus-agda",
"max_stars_repo_path": "Optics/Functorial.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 619,
"size": 1804
}
|
open import Agda.Primitive
open import Agda.Builtin.Nat
-- Named implicit function types
postulate
T : Set → Set → Set
foo : {A = X : Set} {B : Set} → T X B
bar : ∀ {A = X} {B} → T X B
foo₁ : (X : Set) → T X X
foo₁ X = foo {A = X} {B = X}
bar₁ : ∀ X → T X X
bar₁ X = bar {A = X} {B = X}
Id : {A = _ : Set} → Set
Id {A = X} = X
Id₁ : Set → Set
Id₁ X = Id {A = X}
-- With blanks
postulate
namedUnused : {A = _ : Set} → Set
unnamedUsed : {_ = X : Set} → X → X
unnamedUnused : {_ = _ : Set} → Set
_ : Set
_ = namedUnused {A = Nat}
_ : Nat → Nat
_ = unnamedUsed {Nat} -- can't give by name
_ : Set
_ = unnamedUnused {Nat}
-- In left-hand sides
id : {A = X : Set} → X → X
id {A = Y} x = x
-- In with-functions
with-fun : ∀ {A} {B = X} → T A X → T A X
with-fun {A = A} {B = Z} x with T A Z
with-fun {B = Z} x | Goal = x
-- In datatypes
data List {ℓ = a} (A : Set a) : Set a where
[] : List A
_∷_ : A → List A → List A
List₁ = List {ℓ = lsuc lzero}
-- In module telescopes
module Named {A : Set} {B = X : Set} where
postulate H : X → A
h : (A : Set) → A → A
h A = Named.H {A = A} {B = A}
postulate
X : Set
open Named {A = X} {B = X}
hh : X → X
hh = H
-- Constructors
data Q (n : Nat) : Set where
mkQ : Q n
data E {n = x} (q : Q x) : Set where
mkE : E q
e₁ : (q : Q 1) → E q
e₁ q = mkE {n = 1} {q = q}
-- Generalized variables
variable
m n : Nat
q₁ = mkQ {n = 1}
data D (x : Q n) : Q m → Set where
refl : {y = z : Q m} → D x z
D₁ = D {n = 1}
D₁₂ = λ x → D {n = 1} x {m = 2}
refl′ = λ x → refl {n = 1} {x = x} {m = 2} {y = mkQ}
|
{
"alphanum_fraction": 0.5028355388,
"avg_line_length": 15.87,
"ext": "agda",
"hexsha": "e9b1323adc270006b001ccd4d7b2d759faedf740",
"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/Issue952.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/Issue952.agda",
"max_line_length": 52,
"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/Issue952.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": 687,
"size": 1587
}
|
module Prelude.Bot where
data Bot : Set where
magic : ∀{A : Set} -> Bot -> A
magic ()
|
{
"alphanum_fraction": 0.6136363636,
"avg_line_length": 12.5714285714,
"ext": "agda",
"hexsha": "4b7d81f09dd91334a9cc3ff1a94d710dff4c07cb",
"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/epic/Prelude/Bot.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/epic/Prelude/Bot.agda",
"max_line_length": 30,
"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/epic/Prelude/Bot.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 26,
"size": 88
}
|
open import Data.List
{- --- 6. Vectors --- -}
{- 6.1 Warmup -}
{- Problem: what do we return for the empty list ? -}
head2 : {A : Set} → List A → A
head2 [] = {!!}
head2 (x ∷ l) = x
{- 6.2 Definition -}
open import Data.Nat
data Vec (A : Set) : ℕ → Set where
[] : Vec A zero
_::_ : {n : ℕ} → A → Vec A n → Vec A (suc n)
{- 6.3 Head and tail -}
head-vec : {A : Set} → {n : ℕ} → Vec A (suc n) → A
head-vec (x :: v) = x
tail-vec : {A : Set} → {n : ℕ} → Vec A (suc n) → Vec A n
tail-vec (x :: v) = v
{- 6.4 Concatenation -}
concat-vec : {A : Set} → {m n : ℕ} → Vec A m → Vec A n → Vec A (m + n)
concat-vec [] v2 = v2
concat-vec (x :: v1) v2 = x :: (concat-vec v1 v2)
{- 6.5 Reversal -}
snoc-vec : {A : Set} → {n : ℕ} → A → Vec A n → Vec A (suc n)
snoc-vec a [] = a :: []
snoc-vec a (x :: v) = x :: (snoc-vec a v)
rev-vec : {A : Set} → {n : ℕ} → Vec A n → Vec A n
rev-vec [] = []
rev-vec (x :: v) = snoc-vec x (rev-vec v)
{- 6.6 Accessing an element -}
data Fin : ℕ → Set where
zero : {n : ℕ} → Fin (suc n)
suc : {n : ℕ} (i : Fin n) → Fin (suc n)
{- 6.7 Zipping -}
open import Data.Product hiding (zip)
zip-vec : {A : Set} → {n : ℕ} → Vec A n → Vec A n → Vec (A × A) n
zip-vec [] [] = []
zip-vec (x₁ :: y₁) (x₂ :: y₂) = (x₁ , x₂) :: (zip-vec y₁ y₂)
|
{
"alphanum_fraction": 0.4944707741,
"avg_line_length": 24.8235294118,
"ext": "agda",
"hexsha": "7dbfa743e4eb6b8515652373ad997f9146618130",
"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": "9a0d4a3f97103550a67e5e9ecbc8322bf0a8be23",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "erwinkn/program-eq-proof",
"max_forks_repo_path": "TD6/Vector.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9a0d4a3f97103550a67e5e9ecbc8322bf0a8be23",
"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": "erwinkn/program-eq-proof",
"max_issues_repo_path": "TD6/Vector.agda",
"max_line_length": 70,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "9a0d4a3f97103550a67e5e9ecbc8322bf0a8be23",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "erwinkn/program-eq-proof",
"max_stars_repo_path": "TD6/Vector.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 554,
"size": 1266
}
|
{-# OPTIONS --without-K --safe #-}
open import Level
module Categories.Category.Instance.One where
open import Data.Unit using (⊤; tt)
open import Categories.Category
open import Categories.Functor
open import Categories.Category.Instance.Cats
import Categories.Object.Terminal as Term
module _ {o ℓ e : Level} where
open Term (Cats o ℓ e)
One : Category o ℓ e
One = record
{ Obj = Lift o ⊤
; _⇒_ = λ _ _ → Lift ℓ ⊤
; _≈_ = λ _ _ → Lift e ⊤
}
One-⊤ : Terminal
One-⊤ = record { ⊤ = One ; ! = record { F₀ = λ _ → lift tt } }
-- not only is One terminal, it can be shifted anywhere else. Stronger veersion of !
shift : {o ℓ e : Level} (o′ ℓ′ e′ : Level) → Functor (One {o} {ℓ} {e}) (One {o′} {ℓ′} {e′})
shift o′ ℓ′ e′ = _ -- so obvious, Agda can fill it all in automatically!
One0 : Category 0ℓ 0ℓ 0ℓ
One0 = One {0ℓ} {0ℓ} {0ℓ}
|
{
"alphanum_fraction": 0.6145952109,
"avg_line_length": 26.5757575758,
"ext": "agda",
"hexsha": "662282c5df19057b7accfde99066bd46ceb7c755",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "MirceaS/agda-categories",
"max_forks_repo_path": "src/Categories/Category/Instance/One.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "MirceaS/agda-categories",
"max_issues_repo_path": "src/Categories/Category/Instance/One.agda",
"max_line_length": 91,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "MirceaS/agda-categories",
"max_stars_repo_path": "src/Categories/Category/Instance/One.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 310,
"size": 877
}
|
{-# OPTIONS --universe-polymorphism #-}
module Categories.Presheaves where
open import Level
open import Categories.Category
open import Categories.Agda
open import Categories.FunctorCategory
Presheaves : ∀ {o ℓ e : Level} → Category o ℓ e → Category _ _ _
Presheaves {o} {ℓ} {e} C = Functors (Category.op C) (ISetoids ℓ e)
|
{
"alphanum_fraction": 0.745398773,
"avg_line_length": 29.6363636364,
"ext": "agda",
"hexsha": "733ca6df003cb28219b7807c1853a4229c33704c",
"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/Presheaves.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/Presheaves.agda",
"max_line_length": 66,
"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/Presheaves.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": 94,
"size": 326
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Properties of homogeneous binary relations
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Relation.Binary where
open import Agda.Builtin.Equality using (_≡_)
open import Data.Product
open import Data.Sum
open import Function
open import Level
import Relation.Binary.PropositionalEquality.Core as PropEq
open import Relation.Binary.Consequences
------------------------------------------------------------------------
-- Simple properties and equivalence relations
open import Relation.Binary.Core public
------------------------------------------------------------------------
-- Preorders
record IsPreorder {a ℓ₁ ℓ₂} {A : Set a}
(_≈_ : Rel A ℓ₁) -- The underlying equality.
(_∼_ : Rel A ℓ₂) -- The relation.
: Set (a ⊔ ℓ₁ ⊔ ℓ₂) where
field
isEquivalence : IsEquivalence _≈_
-- Reflexivity is expressed in terms of an underlying equality:
reflexive : _≈_ ⇒ _∼_
trans : Transitive _∼_
module Eq = IsEquivalence isEquivalence
refl : Reflexive _∼_
refl = reflexive Eq.refl
∼-respˡ-≈ : _∼_ Respectsˡ _≈_
∼-respˡ-≈ x≈y x∼z = trans (reflexive (Eq.sym x≈y)) x∼z
∼-respʳ-≈ : _∼_ Respectsʳ _≈_
∼-respʳ-≈ x≈y z∼x = trans z∼x (reflexive x≈y)
∼-resp-≈ : _∼_ Respects₂ _≈_
∼-resp-≈ = ∼-respʳ-≈ , ∼-respˡ-≈
record Preorder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
infix 4 _≈_ _∼_
field
Carrier : Set c
_≈_ : Rel Carrier ℓ₁ -- The underlying equality.
_∼_ : Rel Carrier ℓ₂ -- The relation.
isPreorder : IsPreorder _≈_ _∼_
open IsPreorder isPreorder public
------------------------------------------------------------------------
-- Setoids
-- Equivalence relations are defined in Relation.Binary.Core.
record Setoid c ℓ : Set (suc (c ⊔ ℓ)) where
infix 4 _≈_
field
Carrier : Set c
_≈_ : Rel Carrier ℓ
isEquivalence : IsEquivalence _≈_
open IsEquivalence isEquivalence public
isPreorder : IsPreorder _≡_ _≈_
isPreorder = record
{ isEquivalence = PropEq.isEquivalence
; reflexive = reflexive
; trans = trans
}
preorder : Preorder c c ℓ
preorder = record { isPreorder = isPreorder }
------------------------------------------------------------------------
-- Decidable equivalence relations
record IsDecEquivalence {a ℓ} {A : Set a}
(_≈_ : Rel A ℓ) : Set (a ⊔ ℓ) where
infix 4 _≟_
field
isEquivalence : IsEquivalence _≈_
_≟_ : Decidable _≈_
open IsEquivalence isEquivalence public
record DecSetoid c ℓ : Set (suc (c ⊔ ℓ)) where
infix 4 _≈_
field
Carrier : Set c
_≈_ : Rel Carrier ℓ
isDecEquivalence : IsDecEquivalence _≈_
open IsDecEquivalence isDecEquivalence public
setoid : Setoid c ℓ
setoid = record { isEquivalence = isEquivalence }
open Setoid setoid public using (preorder)
------------------------------------------------------------------------
-- Partial orders
record IsPartialOrder {a ℓ₁ ℓ₂} {A : Set a}
(_≈_ : Rel A ℓ₁) (_≤_ : Rel A ℓ₂) :
Set (a ⊔ ℓ₁ ⊔ ℓ₂) where
field
isPreorder : IsPreorder _≈_ _≤_
antisym : Antisymmetric _≈_ _≤_
open IsPreorder isPreorder public
renaming
( ∼-respˡ-≈ to ≤-respˡ-≈
; ∼-respʳ-≈ to ≤-respʳ-≈
; ∼-resp-≈ to ≤-resp-≈
)
record Poset c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
infix 4 _≈_ _≤_
field
Carrier : Set c
_≈_ : Rel Carrier ℓ₁
_≤_ : Rel Carrier ℓ₂
isPartialOrder : IsPartialOrder _≈_ _≤_
open IsPartialOrder isPartialOrder public
preorder : Preorder c ℓ₁ ℓ₂
preorder = record { isPreorder = isPreorder }
------------------------------------------------------------------------
-- Decidable partial orders
record IsDecPartialOrder {a ℓ₁ ℓ₂} {A : Set a}
(_≈_ : Rel A ℓ₁) (_≤_ : Rel A ℓ₂) :
Set (a ⊔ ℓ₁ ⊔ ℓ₂) where
infix 4 _≟_ _≤?_
field
isPartialOrder : IsPartialOrder _≈_ _≤_
_≟_ : Decidable _≈_
_≤?_ : Decidable _≤_
private
module PO = IsPartialOrder isPartialOrder
open PO public hiding (module Eq)
module Eq where
isDecEquivalence : IsDecEquivalence _≈_
isDecEquivalence = record
{ isEquivalence = PO.isEquivalence
; _≟_ = _≟_
}
open IsDecEquivalence isDecEquivalence public
record DecPoset c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
infix 4 _≈_ _≤_
field
Carrier : Set c
_≈_ : Rel Carrier ℓ₁
_≤_ : Rel Carrier ℓ₂
isDecPartialOrder : IsDecPartialOrder _≈_ _≤_
private
module DPO = IsDecPartialOrder isDecPartialOrder
open DPO public hiding (module Eq)
poset : Poset c ℓ₁ ℓ₂
poset = record { isPartialOrder = isPartialOrder }
open Poset poset public using (preorder)
module Eq where
decSetoid : DecSetoid c ℓ₁
decSetoid = record { isDecEquivalence = DPO.Eq.isDecEquivalence }
open DecSetoid decSetoid public
------------------------------------------------------------------------
-- Strict partial orders
record IsStrictPartialOrder {a ℓ₁ ℓ₂} {A : Set a}
(_≈_ : Rel A ℓ₁) (_<_ : Rel A ℓ₂) :
Set (a ⊔ ℓ₁ ⊔ ℓ₂) where
field
isEquivalence : IsEquivalence _≈_
irrefl : Irreflexive _≈_ _<_
trans : Transitive _<_
<-resp-≈ : _<_ Respects₂ _≈_
module Eq = IsEquivalence isEquivalence
asym : Asymmetric _<_
asym {x} {y} = trans∧irr⟶asym Eq.refl trans irrefl {x = x} {y}
<-respʳ-≈ : _<_ Respectsʳ _≈_
<-respʳ-≈ = proj₁ <-resp-≈
<-respˡ-≈ : _<_ Respectsˡ _≈_
<-respˡ-≈ = proj₂ <-resp-≈
asymmetric = asym
{-# WARNING_ON_USAGE asymmetric
"Warning: asymmetric was deprecated in v0.16.
Please use asym instead."
#-}
record StrictPartialOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
infix 4 _≈_ _<_
field
Carrier : Set c
_≈_ : Rel Carrier ℓ₁
_<_ : Rel Carrier ℓ₂
isStrictPartialOrder : IsStrictPartialOrder _≈_ _<_
open IsStrictPartialOrder isStrictPartialOrder public
------------------------------------------------------------------------
-- Decidable strict partial orders
record IsDecStrictPartialOrder {a ℓ₁ ℓ₂} {A : Set a}
(_≈_ : Rel A ℓ₁) (_<_ : Rel A ℓ₂) :
Set (a ⊔ ℓ₁ ⊔ ℓ₂) where
infix 4 _≟_ _<?_
field
isStrictPartialOrder : IsStrictPartialOrder _≈_ _<_
_≟_ : Decidable _≈_
_<?_ : Decidable _<_
private
module SPO = IsStrictPartialOrder isStrictPartialOrder
open SPO public hiding (module Eq)
module Eq where
isDecEquivalence : IsDecEquivalence _≈_
isDecEquivalence = record
{ isEquivalence = SPO.isEquivalence
; _≟_ = _≟_
}
open IsDecEquivalence isDecEquivalence public
record DecStrictPartialOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
infix 4 _≈_ _<_
field
Carrier : Set c
_≈_ : Rel Carrier ℓ₁
_<_ : Rel Carrier ℓ₂
isDecStrictPartialOrder : IsDecStrictPartialOrder _≈_ _<_
private
module DSPO = IsDecStrictPartialOrder isDecStrictPartialOrder
open DSPO public hiding (module Eq)
strictPartialOrder : StrictPartialOrder c ℓ₁ ℓ₂
strictPartialOrder = record { isStrictPartialOrder = isStrictPartialOrder }
module Eq where
decSetoid : DecSetoid c ℓ₁
decSetoid = record { isDecEquivalence = DSPO.Eq.isDecEquivalence }
open DecSetoid decSetoid public
------------------------------------------------------------------------
-- Total orders
record IsTotalOrder {a ℓ₁ ℓ₂} {A : Set a}
(_≈_ : Rel A ℓ₁) (_≤_ : Rel A ℓ₂) :
Set (a ⊔ ℓ₁ ⊔ ℓ₂) where
field
isPartialOrder : IsPartialOrder _≈_ _≤_
total : Total _≤_
open IsPartialOrder isPartialOrder public
record TotalOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
infix 4 _≈_ _≤_
field
Carrier : Set c
_≈_ : Rel Carrier ℓ₁
_≤_ : Rel Carrier ℓ₂
isTotalOrder : IsTotalOrder _≈_ _≤_
open IsTotalOrder isTotalOrder public
poset : Poset c ℓ₁ ℓ₂
poset = record { isPartialOrder = isPartialOrder }
open Poset poset public using (preorder)
------------------------------------------------------------------------
-- Decidable total orders
record IsDecTotalOrder {a ℓ₁ ℓ₂} {A : Set a}
(_≈_ : Rel A ℓ₁) (_≤_ : Rel A ℓ₂) :
Set (a ⊔ ℓ₁ ⊔ ℓ₂) where
infix 4 _≟_ _≤?_
field
isTotalOrder : IsTotalOrder _≈_ _≤_
_≟_ : Decidable _≈_
_≤?_ : Decidable _≤_
open IsTotalOrder isTotalOrder public hiding (module Eq)
module Eq where
isDecEquivalence : IsDecEquivalence _≈_
isDecEquivalence = record
{ isEquivalence = isEquivalence
; _≟_ = _≟_
}
open IsDecEquivalence isDecEquivalence public
record DecTotalOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
infix 4 _≈_ _≤_
field
Carrier : Set c
_≈_ : Rel Carrier ℓ₁
_≤_ : Rel Carrier ℓ₂
isDecTotalOrder : IsDecTotalOrder _≈_ _≤_
private
module DTO = IsDecTotalOrder isDecTotalOrder
open DTO public hiding (module Eq)
totalOrder : TotalOrder c ℓ₁ ℓ₂
totalOrder = record { isTotalOrder = isTotalOrder }
open TotalOrder totalOrder public using (poset; preorder)
module Eq where
decSetoid : DecSetoid c ℓ₁
decSetoid = record { isDecEquivalence = DTO.Eq.isDecEquivalence }
open DecSetoid decSetoid public
------------------------------------------------------------------------
-- Strict total orders
-- Note that these orders are decidable. The current implementation
-- of `Trichotomous` subsumes irreflexivity and asymmetry. Any reasonable
-- definition capturing these three properties implies decidability
-- as `Trichotomous` necessarily separates out the equality case.
record IsStrictTotalOrder {a ℓ₁ ℓ₂} {A : Set a}
(_≈_ : Rel A ℓ₁) (_<_ : Rel A ℓ₂) :
Set (a ⊔ ℓ₁ ⊔ ℓ₂) where
field
isEquivalence : IsEquivalence _≈_
trans : Transitive _<_
compare : Trichotomous _≈_ _<_
infix 4 _≟_ _<?_
_≟_ : Decidable _≈_
_≟_ = tri⟶dec≈ compare
_<?_ : Decidable _<_
_<?_ = tri⟶dec< compare
isDecEquivalence : IsDecEquivalence _≈_
isDecEquivalence = record
{ isEquivalence = isEquivalence
; _≟_ = _≟_
}
module Eq = IsDecEquivalence isDecEquivalence
<-respˡ-≈ : _<_ Respectsˡ _≈_
<-respˡ-≈ = trans∧tri⟶respˡ≈ Eq.trans trans compare
<-respʳ-≈ : _<_ Respectsʳ _≈_
<-respʳ-≈ = trans∧tri⟶respʳ≈ Eq.sym Eq.trans trans compare
<-resp-≈ : _<_ Respects₂ _≈_
<-resp-≈ = <-respʳ-≈ , <-respˡ-≈
isStrictPartialOrder : IsStrictPartialOrder _≈_ _<_
isStrictPartialOrder = record
{ isEquivalence = isEquivalence
; irrefl = tri⟶irr compare
; trans = trans
; <-resp-≈ = <-resp-≈
}
open IsStrictPartialOrder isStrictPartialOrder public
using (irrefl; asym)
record StrictTotalOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
infix 4 _≈_ _<_
field
Carrier : Set c
_≈_ : Rel Carrier ℓ₁
_<_ : Rel Carrier ℓ₂
isStrictTotalOrder : IsStrictTotalOrder _≈_ _<_
open IsStrictTotalOrder isStrictTotalOrder public
hiding (module Eq)
strictPartialOrder : StrictPartialOrder c ℓ₁ ℓ₂
strictPartialOrder =
record { isStrictPartialOrder = isStrictPartialOrder }
decSetoid : DecSetoid c ℓ₁
decSetoid = record { isDecEquivalence = isDecEquivalence }
module Eq = DecSetoid decSetoid
|
{
"alphanum_fraction": 0.5689741451,
"avg_line_length": 28.2783018868,
"ext": "agda",
"hexsha": "07bb58e66babfcfd76980d0d7012c80e3d46f641",
"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.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.agda",
"max_line_length": 77,
"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.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3807,
"size": 11990
}
|
open import Oscar.Prelude
open import Oscar.Class
open import Oscar.Class.SimilaritySingleton
open import Oscar.Class.SimilarityM
module Oscar.Class.Similarity where
module Similarity
{𝔞} {𝔄 : Ø 𝔞}
{𝔟} {𝔅 : Ø 𝔟}
{𝔣} {𝔉 : Ø 𝔣}
{𝔞̇ 𝔟̇}
(_∼₁_ : 𝔄 → 𝔄 → Ø 𝔞̇)
(_∼₂_ : 𝔅 → 𝔅 → Ø 𝔟̇) (let _∼₂_ = _∼₂_; infix 4 _∼₂_)
(_◃_ : 𝔉 → 𝔄 → 𝔅) (let _◃_ = _◃_; infix 16 _◃_)
= ℭLASS (_◃_ , _∼₂_) (∀ {x y} f → x ∼₁ y → f ◃ x ∼₂ f ◃ y)
module _
{𝔞} {𝔄 : Ø 𝔞}
{𝔟} {𝔅 : Ø 𝔟}
{𝔣} {𝔉 : Ø 𝔣}
{𝔞̇ 𝔟̇}
{_∼₁_ : 𝔄 → 𝔄 → Ø 𝔞̇}
{_∼₂_ : 𝔅 → 𝔅 → Ø 𝔟̇}
{_◃_ : 𝔉 → 𝔄 → 𝔅}
where
similarity = Similarity.method _∼₁_ _∼₂_ _◃_
module _ ⦃ _ : Similarity.class _∼₁_ _∼₂_ _◃_ ⦄ where
instance
toSimilaritySingleton : ∀ {x y f} → SimilaritySingleton.class (x ∼₁ y) _∼₂_ _◃_ x y f
toSimilaritySingleton .⋆ = similarity _
toSimilarityM : ∀ {x y} → SimilarityM.class _∼₁_ _∼₂_ _◃_ x y
toSimilarityM .⋆ = similarity
open import Oscar.Class.Smap
open import Oscar.Class.Surjection
module Similarity,cosmaparrow
{𝔵₁} {𝔛₁ : Ø 𝔵₁}
{𝔵₂} {𝔛₂ : Ø 𝔵₂}
(surjection : Surjection.type 𝔛₁ 𝔛₂)
{𝔯} (ℜ : 𝔛₁ → 𝔛₁ → Ø 𝔯)
{𝔭₁} (𝔓₁ : 𝔛₂ → Ø 𝔭₁)
{𝔭₂} (𝔓₂ : 𝔛₂ → Ø 𝔭₂)
(smaparrow : Smaparrow.type ℜ 𝔓₁ 𝔓₂ surjection surjection)
{𝔯̇} (ℜ̇ : ∀ {x y} → ℜ x y → ℜ x y → Ø 𝔯̇)
{𝔭̇₂} (𝔓̇₂ : ∀ {x} → 𝔓₂ x → 𝔓₂ x → Ø 𝔭̇₂)
where
class = ∀ {m n} → Similarity.class (ℜ̇ {m} {n}) (𝔓̇₂ {surjection n}) (flip smaparrow)
type = ∀ {m n} → Similarity.type (ℜ̇ {m} {n}) (𝔓̇₂ {surjection n}) (flip smaparrow)
module Similarity,cosmaparrow!
{𝔵₁} {𝔛₁ : Ø 𝔵₁}
{𝔵₂} {𝔛₂ : Ø 𝔵₂}
⦃ _ : Surjection.class 𝔛₁ 𝔛₂ ⦄
{𝔯} (ℜ : 𝔛₁ → 𝔛₁ → Ø 𝔯)
{𝔭₁} (𝔓₁ : 𝔛₂ → Ø 𝔭₁)
{𝔭₂} (𝔓₂ : 𝔛₂ → Ø 𝔭₂)
⦃ _ : Smaparrow!.class ℜ 𝔓₁ 𝔓₂ ⦄
{𝔯̇} (ℜ̇ : ∀ {x y} → ℜ x y → ℜ x y → Ø 𝔯̇)
{𝔭̇₂} (𝔓̇₂ : ∀ {x} → 𝔓₂ x → 𝔓₂ x → Ø 𝔭̇₂)
= Similarity,cosmaparrow surjection ℜ 𝔓₁ 𝔓₂ smaparrow ℜ̇ 𝔓̇₂
module Similarity,cosmaphomarrow
{𝔵₁} {𝔛₁ : Ø 𝔵₁}
{𝔵₂} {𝔛₂ : Ø 𝔵₂}
(surjection : Surjection.type 𝔛₁ 𝔛₂)
{𝔯} (ℜ : 𝔛₁ → 𝔛₁ → Ø 𝔯)
{𝔭} (𝔓 : 𝔛₂ → Ø 𝔭)
(smaparrow : Smaphomarrow.type ℜ 𝔓 surjection)
{𝔯̇} (ℜ̇ : ∀ {x y} → ℜ x y → ℜ x y → Ø 𝔯̇)
{𝔭̇} (𝔓̇ : ∀ {x} → 𝔓 x → 𝔓 x → Ø 𝔭̇)
= Similarity,cosmaparrow surjection ℜ 𝔓 𝔓 smaparrow ℜ̇ 𝔓̇
module Similarity,cosmaphomarrow!
{𝔵₁} {𝔛₁ : Ø 𝔵₁}
{𝔵₂} {𝔛₂ : Ø 𝔵₂}
⦃ _ : Surjection.class 𝔛₁ 𝔛₂ ⦄
{𝔯} (ℜ : 𝔛₁ → 𝔛₁ → Ø 𝔯)
{𝔭} (𝔓 : 𝔛₂ → Ø 𝔭)
⦃ _ : Smaphomarrow!.class ℜ 𝔓 ⦄
{𝔯̇} (ℜ̇ : ∀ {x y} → ℜ x y → ℜ x y → Ø 𝔯̇)
{𝔭̇} (𝔓̇ : ∀ {x} → 𝔓 x → 𝔓 x → Ø 𝔭̇)
= Similarity,cosmaphomarrow surjection ℜ 𝔓 smaparrow ℜ̇ 𝔓̇
module Similarity,smaparrow
{𝔵₁} {𝔛₁ : Ø 𝔵₁}
{𝔵₂} {𝔛₂ : Ø 𝔵₂}
(surjection : Surjection.type 𝔛₁ 𝔛₂)
{𝔯} (ℜ : π̂² 𝔯 𝔛₁)
{𝔭₁} (𝔓₁ : π̂ 𝔭₁ 𝔛₂)
{𝔭₂} (𝔓₂ : π̂ 𝔭₂ 𝔛₂)
(smaparrow : Smaparrow.type ℜ 𝔓₁ 𝔓₂ surjection surjection)
{𝔭̇₁} (𝔓̇₁ : ∀̇ π̂² 𝔭̇₁ (𝔓₁ ∘ surjection))
{𝔭̇₂} (𝔓̇₂ : ∀̇ π̂² 𝔭̇₂ (𝔓₂ ∘ surjection))
where
class = ∀ {m n} → Similarity.class (𝔓̇₁ {m}) (𝔓̇₂ {n}) smaparrow
type = ∀ {m n} → Similarity.type (𝔓̇₁ {m}) (𝔓̇₂ {n}) smaparrow
module Similarity,smaparrow!
{𝔵₁} {𝔛₁ : Ø 𝔵₁}
{𝔵₂} {𝔛₂ : Ø 𝔵₂}
⦃ _ : Surjection.class 𝔛₁ 𝔛₂ ⦄
{𝔯} (ℜ : π̂² 𝔯 𝔛₁)
{𝔭₁} (𝔓₁ : π̂ 𝔭₁ 𝔛₂)
{𝔭₂} (𝔓₂ : π̂ 𝔭₂ 𝔛₂)
⦃ _ : Smaparrow!.class ℜ 𝔓₁ 𝔓₂ ⦄
{𝔭̇₁} (𝔓̇₁ : ∀̇ π̂² 𝔭̇₁ (𝔓₁ ∘ surjection))
{𝔭̇₂} (𝔓̇₂ : ∀̇ π̂² 𝔭̇₂ (𝔓₂ ∘ surjection))
= Similarity,smaparrow surjection ℜ 𝔓₁ 𝔓₂ smaparrow 𝔓̇₁ 𝔓̇₂
module Similarity,smaphomarrow
{𝔵₁} {𝔛₁ : Ø 𝔵₁}
{𝔵₂} {𝔛₂ : Ø 𝔵₂}
(surjection : Surjection.type 𝔛₁ 𝔛₂)
{𝔯} (ℜ : π̂² 𝔯 𝔛₁)
{𝔭} (𝔓 : π̂ 𝔭 𝔛₂)
(smaparrow : Smaphomarrow.type ℜ 𝔓 surjection)
{𝔭̇} (𝔓̇ : ∀̇ π̂² 𝔭̇ (𝔓 ∘ surjection))
= Similarity,smaparrow surjection ℜ 𝔓 𝔓 smaparrow 𝔓̇ 𝔓̇
module Similarity,smaphomarrow!
{𝔵₁} {𝔛₁ : Ø 𝔵₁}
{𝔵₂} {𝔛₂ : Ø 𝔵₂}
⦃ _ : Surjection.class 𝔛₁ 𝔛₂ ⦄
{𝔯} (ℜ : π̂² 𝔯 𝔛₁)
{𝔭} (𝔓 : π̂ 𝔭 𝔛₂)
⦃ _ : Smaphomarrow!.class ℜ 𝔓 ⦄
{𝔭̇} (𝔓̇ : ∀̇ π̂² 𝔭̇ (𝔓 ∘ surjection))
= Similarity,smaphomarrow surjection ℜ 𝔓 smaparrow 𝔓̇
|
{
"alphanum_fraction": 0.5481425322,
"avg_line_length": 29.9772727273,
"ext": "agda",
"hexsha": "1782adff58587570e4b55cc64b7c21ad50dafd0a",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_forks_repo_licenses": [
"RSA-MD"
],
"max_forks_repo_name": "m0davis/oscar",
"max_forks_repo_path": "archive/agda-3/src/Oscar/Class/Similarity.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z",
"max_issues_repo_licenses": [
"RSA-MD"
],
"max_issues_repo_name": "m0davis/oscar",
"max_issues_repo_path": "archive/agda-3/src/Oscar/Class/Similarity.agda",
"max_line_length": 91,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_stars_repo_licenses": [
"RSA-MD"
],
"max_stars_repo_name": "m0davis/oscar",
"max_stars_repo_path": "archive/agda-3/src/Oscar/Class/Similarity.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2586,
"size": 3957
}
|
module Silica where
open import Agda.Builtin.Bool public
open import Data.Bool using (true; false) public
open import Prelude public
open import Data.Nat public
open import Data.List public
open import Data.Nat.Properties public
open import Relation.Nullary using (¬_; Dec; yes; no) public
open import Relation.Binary using (module StrictTotalOrder; DecSetoid; IsDecEquivalence) public
open import Data.Maybe using (just) public
import Relation.Binary.PropositionalEquality as Eq
import Relation.Binary.Core
import Relation.Binary.HeterogeneousEquality
open Eq using (_≡_; _≢_; refl; cong; sym) public
open Eq.≡-Reasoning public
open import Data.Product using (_×_; proj₁; proj₂; ∃-syntax; ∃) renaming (_,_ to ⟨_,_⟩) public
import Context
open import Data.List.Membership.DecSetoid ≡-decSetoid
import Data.List.Membership.DecSetoid
import Data.List.Relation.Binary.Subset.Setoid using (_⊆_)
import Data.List.Relation.Binary.Equality.DecPropositional using (_≡?_)
open import Data.List.Relation.Unary.Any
open import Data.List.All
open import Data.Empty
open import Data.Sum
open import Level
import Data.Fin
-------------- Syntax ------------
Id : Set
Id = ℕ
-- State sets
σ : Set
σ = List ℕ
-- List of ℕ subset
_⊆_ : σ → σ → Set
_⊆_ = Data.List.Relation.Binary.Subset.Setoid._⊆_ (DecSetoid.setoid ≡-decSetoid)
-- List of ℕ decidable equality
_≟l_ : Relation.Binary.Core.Decidable {A = σ} _≡_
_≟l_ = Data.List.Relation.Binary.Equality.DecPropositional._≡?_ _≟_
data Perm : Set where
Owned : Perm
Unowned : Perm
Shared : Perm
S : σ → Perm
record Tc : Set where
constructor tc
field
contractName : Id
perm : Perm
data Tbase : Set where
Void : Tbase
Boolean : Tbase
data Type : Set where
base : Tbase -> Type
contractType : Tc -> Type
SInjective : (l₁ l₂ : σ)
→ l₁ ≢ l₂
→ S l₁ ≢ S l₂
SInjective l₁ .l₁ lsEq refl = lsEq refl
TCInjectiveContractName : ∀ {p₁ p₂}
→ (cn₁ cn₂ : Id)
→ cn₁ ≢ cn₂
→ tc cn₁ p₁ ≢ tc cn₂ p₂
TCInjectiveContractName cn₁ cn₂ nEq refl = nEq refl
TCInjectivePermission : ∀ {cn₁ cn₂}
→ (p₁ p₂ : Perm)
→ p₁ ≢ p₂
→ tc cn₁ p₁ ≢ tc cn₂ p₂
TCInjectivePermission cn₁ cn₂ nEq refl = nEq refl
contractTypeInjective : ∀ {tc₁ tc₂}
→ tc₁ ≢ tc₂
→ contractType tc₁ ≢ contractType tc₂
contractTypeInjective nEq refl = nEq refl
-- Decidable equality for permissions
infix 4 _≟p_
_≟p_ : Relation.Binary.Core.Decidable {A = Perm} _≡_
Owned ≟p Owned = yes refl
Owned ≟p Unowned = no (λ ())
Owned ≟p Shared = no (λ ())
Owned ≟p S x = no (λ ())
Unowned ≟p Owned = no (λ ())
Unowned ≟p Unowned = yes refl
Unowned ≟p Shared = no (λ ())
Unowned ≟p S x = no (λ ())
Shared ≟p Owned = no (λ ())
Shared ≟p Unowned = no (λ ())
Shared ≟p Shared = yes refl
Shared ≟p S x = no (λ ())
S x ≟p Owned = no (λ ())
S x ≟p Unowned = no (λ ())
S x ≟p Shared = no (λ ())
S s1 ≟p S s2 with s1 ≟l s2
... | yes eq = yes (Eq.cong S eq)
... | no nEq = no λ sEq → SInjective s1 s2 nEq sEq
-- Decidable equality for types
infix 4 _≟t_
_≟t_ : Relation.Binary.Core.Decidable {A = Type} _≡_
base Void ≟t base Void = yes refl
base Void ≟t base Boolean = no (λ ())
base Boolean ≟t base Void = no (λ ())
base Boolean ≟t base Boolean = yes refl
base x ≟t contractType x₁ = no (λ ())
contractType x ≟t base x₁ = no (λ ())
contractType (tc contractName p₁) ≟t contractType (tc contractName₁ p₂) with contractName ≟ contractName₁ | p₁ ≟p p₂
... | yes eqNames | yes eqPerms = yes (Eq.cong₂ (λ a → λ b → contractType (tc a b)) eqNames eqPerms)
... | no nEqNames | _ = no (contractTypeInjective (TCInjectiveContractName contractName contractName₁ nEqNames))
... | _ | no nEqPerms = no (contractTypeInjective (TCInjectivePermission p₁ p₂ nEqPerms))
≟tIsEquivalence : Relation.Binary.IsEquivalence {A = Type} _≡_ -- _≟t_
≟tIsEquivalence = Eq.isEquivalence
≡t-isDecEquivalence : IsDecEquivalence (_≡_ {A = Type})
≡t-isDecEquivalence = record
{ isEquivalence = ≟tIsEquivalence
; _≟_ = _≟t_
}
≡t-decSetoid : DecSetoid 0ℓ 0ℓ
≡t-decSetoid = record
{ Carrier = Type
; _≈_ = _≡_
; isDecEquivalence = ≡t-isDecEquivalence
}
module tDecSetoid = Data.List.Membership.DecSetoid ≡t-decSetoid
_∈ₜ_ : Type → List Type → Set
_∈ₜ_ = tDecSetoid._∈_
isShared : Type → Bool
isShared (contractType (record {contractName = _ ; perm = Shared})) = true
isShared _ = false
eqContractTypes : ∀ {t₁ : Tc}
→ ∀ {t₂ : Tc}
→ Tc.perm t₁ ≡ Tc.perm t₂
→ Tc.contractName t₁ ≡ Tc.contractName t₂
→ t₁ ≡ t₂
eqContractTypes {t₁} {t₂} refl refl = refl
record State : Set where
field
field₁ : Tc
field₂ : Tc
isAsset : Bool
data Targ : Set where
arg-trans : Tc -> Perm -> Targ
base : Tbase -> Targ
IndirectRef : Set
IndirectRef = Id
ObjectRef : Set
ObjectRef = Id
data SimpleExpr : Set where
var : Id -> SimpleExpr
loc : IndirectRef -> SimpleExpr
record Object : Set where
field
contractName : Id
stateName : Id
x₁ : SimpleExpr
x₂ : SimpleExpr
data Value : Set where
boolVal : (b : Bool)
------------
→ Value
voidVal : Value
objVal : ∀ (o : ObjectRef)
--------------
→ Value
data Expr : Set where
valExpr : Value → Expr
simpleExpr : SimpleExpr → Expr
fieldAccess : Id → Expr -- All field accesses are to 'this', so the field name suffices.
assertₓ : Id → σ → Expr
assertₗ : IndirectRef → σ → Expr
new : Id → Id → SimpleExpr → SimpleExpr → Expr -- Contract, state, field values (always two of them).
-- TODO: add the rest of the expressions
objValInjective : ∀ {o o'}
→ o ≢ o'
→ objVal o ≢ objVal o'
objValInjective {o} {.o} oNeqo' refl = oNeqo' refl
objValInjectiveContrapositive : ∀ {o o'}
→ objVal o ≡ objVal o'
→ o ≡ o'
objValInjectiveContrapositive {o} {o'} refl = refl
record PublicTransaction : Set where
constructor publicTransaction
field
retType : Type
name : Id
argType : Targ
argName : Id
initialState : Perm
finalState : Perm
expr : Expr
-- TODO: add private transactions
record Contract : Set where
constructor contract
field
isAsset : Bool
name : Id
states : List State
transactions : List PublicTransaction
data Program : Set where
program : List Contract -> Expr -> Program
--============= Utilities ================
data FreeLocations : Expr → List IndirectRef → Set where
boolFL : ∀ {b : Bool} → FreeLocations (valExpr (boolVal b)) []
varFL : ∀ {x : Id} → FreeLocations (simpleExpr (var x)) []
voidFL : FreeLocations (valExpr voidVal) []
objValFL : ∀ {o : ObjectRef} → FreeLocations (valExpr (objVal o)) []
locFL : ∀ (l : IndirectRef) → FreeLocations (simpleExpr (loc l)) [ l ]
freeLocationsOfSimpleExpr : SimpleExpr → List IndirectRef
freeLocationsOfSimpleExpr (var x) = []
freeLocationsOfSimpleExpr (loc l) = [ l ]
freeLocations : Expr → List IndirectRef
freeLocations (valExpr (boolVal b)) = []
freeLocations (simpleExpr (se)) = freeLocationsOfSimpleExpr se
freeLocations (valExpr voidVal) = []
freeLocations (valExpr (objVal o)) = []
freeLocations (fieldAccess x) = []
freeLocations (assertₓ x x₁) = []
freeLocations (assertₗ l x₁) = [ l ]
freeLocations (new _ _ f₁ f₂) = (freeLocationsOfSimpleExpr f₁) ++ (freeLocationsOfSimpleExpr f₂)
data FreeVariables : Expr → List Id → Set where
boolFL : ∀ {b : Bool} → FreeVariables (valExpr (boolVal b)) []
varFL : ∀ {x : Id} → FreeVariables (simpleExpr (var x)) [ x ]
voidFL : FreeVariables (valExpr voidVal) []
objValFL : ∀ {o : ObjectRef} → FreeVariables (valExpr (objVal o)) []
locFL : ∀ (l : IndirectRef) → FreeVariables (simpleExpr (loc l)) []
data Closed : Expr → Set where
closed : ∀ (e : Expr)
→ FreeVariables e []
--------------------
→ Closed e
freeVariablesOfSimpleExpr : SimpleExpr → List IndirectRef
freeVariablesOfSimpleExpr (var x) = [ x ]
freeVariablesOfSimpleExpr (loc l) = []
freeVariables : Expr → List IndirectRef
freeVariables (valExpr (boolVal b)) = []
freeVariables (simpleExpr se) = freeVariablesOfSimpleExpr se
freeVariables (valExpr voidVal) = []
freeVariables (valExpr (objVal o)) = []
freeVariables (fieldAccess x) = []
freeVariables (assertₓ x x₁) = [ x ]
freeVariables (assertₗ l x₁) = []
freeVariables (new _ _ f₁ f₂) = (freeVariablesOfSimpleExpr f₁) ++ (freeVariablesOfSimpleExpr f₂)
--=============== Static Semantics ================
-- A ContractEnv (written Γ) maps from Ids to contract definitions.
module ContractEnv = Context Contract
module TypeEnvContext = Context Type
TypeEnv = TypeEnvContext.ctx
open TypeEnvContext
record StaticEnv : Set where
constructor se
field
varEnv : TypeEnv
locEnv : TypeEnv
objEnv : TypeEnv
_,ₓ_⦂_ : StaticEnv → Id → Type → StaticEnv
Δ ,ₓ x ⦂ T = record Δ {varEnv = (StaticEnv.varEnv Δ) , x ⦂ T}
_,ₗ_⦂_ : StaticEnv → Id → Type → StaticEnv
Δ ,ₗ l ⦂ T = record Δ {locEnv = (StaticEnv.locEnv Δ) , l ⦂ T}
_,ₒ_⦂_ : StaticEnv → Id → Type → StaticEnv
Δ ,ₒ o ⦂ T = record Δ {objEnv = (StaticEnv.objEnv Δ) , o ⦂ T}
-- Subtyping --
data _<:_ : Type → Type → Set where
<:-refl : ∀ {T : Type}
----------------
→ T <: T
-- TODO: add more subtyping judgments
-- Helper judgments --
--data _⊢_NotAsset : ContractEnv.ctx → Id → Set where
data NotAsset : ContractEnv.ctx → Id → Set where
inContext :
{Γ : ContractEnv.ctx}
→ {id : Id}
→ (contr : Contract)
→ (p : Contract.isAsset contr ≡ false)
→ (q : (Γ ContractEnv.∋ id ⦂ contr))
-------------
→ NotAsset Γ id
-- Context strength --
data _<ₗ_ : TypeEnv → TypeEnv → Set where
empty< : ∀ { Δ Δ' : TypeEnv}
→ (Δ' ≡ ∅)
--------------
→ Δ <ₗ Δ'
nonempty< : ∀ {Δ Δ' Δ'' Δ''' : TypeEnv}
→ ∀ {l : ℕ}
→ ∀ {T T' : Type}
→ Δ' ≡ (Δ'' , l ⦂ T')
→ Δ ≡ (Δ''' , l ⦂ T)
→ T <: T'
→ Δ''' <ₗ Δ''
-------------
→ Δ <ₗ Δ'
data _<*_ : StaticEnv → StaticEnv → Set where
* : ∀ {Δ Δ'}
→ (StaticEnv.locEnv Δ) <ₗ (StaticEnv.locEnv Δ')
-----------------------------------------------
→ Δ <* Δ'
<ₗ-refl : ∀ {Δ : TypeEnv}
→ Δ <ₗ Δ
<ₗ-refl {Context.∅} = empty< refl
<ₗ-refl {Δ , x ⦂ x₁} = nonempty< refl refl (<:-refl) (<ₗ-refl {Δ})
<*-refl : ∀ {Δ : StaticEnv}
→ Δ <* Δ
<*-refl = * <ₗ-refl
<*-o-extension : ∀ {Δ o T}
→ (Δ ,ₒ o ⦂ T) <* Δ
<*-o-extension {Δ} {o} {T} = * <ₗ-refl
-- Splitting --
record SplitType : Set where
constructor _⇛_/_
field
t₁ : Type
t₂ : Type
t₃ : Type
infix 4 _⊢_
data _⊢_ : ContractEnv.ctx -> SplitType -> Set where
voidSplit : ∀ {Γ : ContractEnv.ctx}
---------------
→ Γ ⊢ (base Void) ⇛ (base Void) / (base Void)
booleanSplit : ∀ {Γ : ContractEnv.ctx}
--------------
→ Γ ⊢ base Boolean ⇛ base Boolean / base Boolean
-- split Unowned off of anything.
unownedSplit : ∀ {Γ : ContractEnv.ctx}
→ ∀ {t1 t2 t3 : Tc}
→ (Tc.contractName t1) ≡ (Tc.contractName t2)
→ Tc.contractName t1 ≡ Tc.contractName t3
→ (Tc.perm t1) ≡ (Tc.perm t2)
→ Tc.perm t3 ≡ Unowned
--------------
→ Γ ⊢ contractType t1 ⇛ contractType t2 / contractType t3
shared-shared-shared : ∀ {Γ : ContractEnv.ctx}
→ ∀ {t : Tc}
→ Tc.perm t ≡ Shared
--------------------------------------------------------
→ Γ ⊢ contractType t ⇛ contractType t / contractType t
owned-shared :
∀ {c : Id}
→ ∀ {Γ : ContractEnv.ctx}
→ NotAsset Γ c
--------------
→ Γ ⊢ contractType (tc c Owned) ⇛ contractType (tc c Shared) / contractType (tc c Shared)
states-shared :
∀ {s : σ}
→ ∀ {c : Id}
→ ∀ {Γ : ContractEnv.ctx}
→ NotAsset Γ c
--------------
→ Γ ⊢ contractType ( record {perm = S s ; contractName = c} ) ⇛ contractType ( record {perm = Shared ; contractName = c} ) / contractType ( record {perm = Shared ; contractName = c} )
splitType : ∀ {Γ : ContractEnv.ctx}
→ ∀ {t1 t2 t3 : Type}
→ Γ ⊢ t1 ⇛ t2 / t3
→ SplitType
splitType voidSplit = (base Void) ⇛ (base Void) / (base Void)
splitType booleanSplit = base Boolean ⇛ base Boolean / base Boolean
splitType (unownedSplit {Γ} {t1} {t2} {t3} eqNames1 eqNames2 eqPerms eqUnownedPerm) = contractType t1 ⇛ contractType t2 / contractType t3
splitType (shared-shared-shared {Γ} {t} _) = contractType t ⇛ contractType t / contractType t
splitType (owned-shared {c} x) = contractType ( record {perm = Owned ; contractName = c} ) ⇛ contractType ( record {perm = Shared ; contractName = c} ) / contractType ( record {perm = Shared ; contractName = c} )
splitType (states-shared {s} {c} x) = contractType ( record {perm = S s ; contractName = c} ) ⇛ contractType ( record {perm = Shared ; contractName = c} ) / contractType ( record {perm = Shared ; contractName = c} )
splitTypeCorrect : ∀ {Γ}
→ ∀ {t1 t2 t3 : Type}
→ ∀ (p : Γ ⊢ t1 ⇛ t2 / t3)
→ splitType p ≡ t1 ⇛ t2 / t3
splitTypeCorrect voidSplit = refl
splitTypeCorrect booleanSplit = refl
splitTypeCorrect (unownedSplit x _ _ _) = refl
splitTypeCorrect (shared-shared-shared _) = refl
splitTypeCorrect (owned-shared x) = refl
splitTypeCorrect (states-shared x) = refl
------------ Type judgments ----------------
data _⊢_⦂_⊣_ : StaticEnv → Expr → Type → StaticEnv → Set where
varTy : ∀ {Γ : ContractEnv.ctx}
→ ∀ {Δ : StaticEnv}
→ ∀ {T₁ T₂ T₃ : Type}
→ ∀ (x : Id)
→ Γ ⊢ T₁ ⇛ T₂ / T₃
-----------------------------------
→ (Δ ,ₓ x ⦂ T₁) ⊢ (simpleExpr (var x)) ⦂ T₂ ⊣ (Δ ,ₓ x ⦂ T₃)
locTy : ∀ {Γ : ContractEnv.ctx}
→ ∀ {Δ : StaticEnv}
→ ∀ {T₁ T₂ T₃ : Type}
→ ∀ (l : IndirectRef)
→ Γ ⊢ T₁ ⇛ T₂ / T₃
------------------------------------
→ (Δ ,ₗ l ⦂ T₁) ⊢ (simpleExpr (loc l)) ⦂ T₂ ⊣ (Δ ,ₗ l ⦂ T₃)
objTy : ∀ {Γ : ContractEnv.ctx}
→ ∀ {Δ : StaticEnv}
→ ∀ {T₁ T₂ T₃ : Type}
→ ∀ (o : ObjectRef)
→ Γ ⊢ T₁ ⇛ T₂ / T₃
------------------------------------
→ (Δ ,ₒ o ⦂ T₁) ⊢ (valExpr (objVal o)) ⦂ T₂ ⊣ (Δ ,ₒ o ⦂ T₃)
boolTy : ∀ {Γ : ContractEnv.ctx}
→ ∀ {Δ : StaticEnv}
→ ∀ (b : Bool)
------------------------------------
→ Δ ⊢ (valExpr (boolVal b)) ⦂ (base Boolean) ⊣ Δ
voidTy : ∀ {Γ : ContractEnv.ctx}
→ ∀ {Δ : StaticEnv}
--------------------
→ Δ ⊢ (valExpr voidVal) ⦂ base Void ⊣ Δ
assertTyₓ : ∀ {Γ : ContractEnv.ctx}
→ ∀ {Δ : StaticEnv}
→ ∀ {s₁ s₂ : σ}
→ ∀ {tc : Tc}
→ ∀ {x : Id}
→ Tc.perm tc ≡ S s₁
→ s₁ ⊆ s₂
--------------------------
→ (Δ ,ₓ x ⦂ (contractType tc)) ⊢ assertₓ x s₁ ⦂ base Void ⊣ (Δ ,ₓ x ⦂ (contractType tc))
assertTyₗ : ∀ {Γ : ContractEnv.ctx}
→ ∀ {Δ : StaticEnv}
→ ∀ {s₁ s₂ : σ}
→ ∀ {tc : Tc}
→ ∀ {l : IndirectRef}
→ Tc.perm tc ≡ S s₁
→ s₁ ⊆ s₂
--------------------------
→ (Δ ,ₗ l ⦂ (contractType tc)) ⊢ assertₗ l s₁ ⦂ base Void ⊣ (Δ ,ₗ l ⦂ (contractType tc))
newTy : ∀ {Γ Δ Δ' Δ''}
→ {states : List State}
→ {C st : Id}
→ {x₁ x₂ : SimpleExpr}
→ {T₁ T₂ Tf₁ Tf₂ : Tc}
→ ∀ {isCAsset isSAsset transactions}
→ (stOK : st < (length states))
→ Δ ⊢ simpleExpr x₁ ⦂ (contractType T₁) ⊣ Δ'
→ Δ' ⊢ simpleExpr x₂ ⦂ (contractType T₂) ⊣ Δ''
→ Γ ContractEnv.∋ C ⦂ (contract isCAsset C states transactions)
→ (Data.List.lookup states (Data.Fin.fromℕ≤ stOK)) ≡ record {field₁ = Tf₁ ; field₂ = Tf₂ ; isAsset = isSAsset}
--------------------------
→ Δ ⊢ new C st x₁ x₂ ⦂ (contractType (tc C (S [ st ]))) ⊣ Δ''
------------ DYNAMIC SEMANTICS --------------
-- μ
module ObjectRefContext = Context Object
ObjectRefEnv = ObjectRefContext.ctx
-- ρ
module IndirectRefContext = Context Value -- TODO: require that these are all values
IndirectRefEnv = IndirectRefContext.ctx
-- φ
module StateLockingContext = Context Bool
StateLockingEnv = StateLockingContext.ctx
-- ψ
module ReentrancyContext = Context Bool
ReentrancyEnv = ReentrancyContext.ctx
record RuntimeEnv : Set where
constructor re
field
μ : ObjectRefEnv
ρ : IndirectRefEnv
φ : StateLockingEnv
ψ : ReentrancyEnv
----------- Reduction Rules ------------
data _,_⟶_,_ : RuntimeEnv → Expr → RuntimeEnv → Expr → Set where
SElookup : -- of locations (i.e. let-bound variables)
∀ {Σ : RuntimeEnv}
→ ∀ {Δ Δ' : StaticEnv}
→ ∀ {T : Type}
→ ∀ {l : IndirectRef}
→ ∀ {v : Value}
→ Δ ⊢ (simpleExpr (loc l)) ⦂ T ⊣ Δ'
→ RuntimeEnv.ρ Σ IndirectRefContext.∋ l ⦂ v
-----------------------------------------------------------
→ (Σ , (simpleExpr (loc l)) ⟶ Σ , valExpr v)
SEassertₓ :
∀ {Σ : RuntimeEnv}
→ ∀ (x : Id)
→ ∀ (s : σ)
--------------
→ (Σ , assertₓ x s ⟶ Σ , valExpr voidVal)
SEassertₗ :
∀ {Σ : RuntimeEnv}
→ ∀ (l : IndirectRef)
→ ∀ (s : σ)
--------------
→ (Σ , assertₗ l s ⟶ Σ , valExpr voidVal)
SEnew :
∀ {Σ μ' Σ' C st x₁ x₂ o}
→ o ObjectRefContext.∉dom (RuntimeEnv.μ Σ)
→ μ' ≡ (RuntimeEnv.μ Σ) ObjectRefContext., o ⦂ record { contractName = C ; stateName = st ; x₁ = x₁ ; x₂ = x₂ }
→ Σ' ≡ record Σ {μ = μ'}
-------------
→ (Σ , new C st x₁ x₂ ⟶ Σ' , valExpr (objVal o))
|
{
"alphanum_fraction": 0.5345861868,
"avg_line_length": 32.2,
"ext": "agda",
"hexsha": "4ed3de585ac35d4362ebbba301bc024ba4e1bfa7",
"lang": "Agda",
"max_forks_count": 11,
"max_forks_repo_forks_event_max_datetime": "2021-06-09T18:40:19.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-05-24T08:20:52.000Z",
"max_forks_repo_head_hexsha": "bda0fac3aadfbce2eacdb89095d100125fa4fdd6",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "ivoysey/Obsidian",
"max_forks_repo_path": "formalization/silica.agda",
"max_issues_count": 259,
"max_issues_repo_head_hexsha": "bda0fac3aadfbce2eacdb89095d100125fa4fdd6",
"max_issues_repo_issues_event_max_datetime": "2022-03-29T18:20:05.000Z",
"max_issues_repo_issues_event_min_datetime": "2017-08-18T19:50:41.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "ivoysey/Obsidian",
"max_issues_repo_path": "formalization/silica.agda",
"max_line_length": 218,
"max_stars_count": 79,
"max_stars_repo_head_hexsha": "bda0fac3aadfbce2eacdb89095d100125fa4fdd6",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "ivoysey/Obsidian",
"max_stars_repo_path": "formalization/silica.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-27T10:34:28.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-08-19T16:24:10.000Z",
"num_tokens": 5967,
"size": 18837
}
|
-- labeled λ-calculus
module IntrinsicallyTypedLLC where
open import Data.List
open import Data.List.Relation.Unary.All
open import Data.List.Base
open import Data.Vec hiding (_++_)
open import Data.Unit hiding (_≤_)
open import Data.Nat hiding (_≤_)
open import Data.Fin.Subset
open import Data.Fin.Subset.Properties
open import Data.Fin hiding (_≤_)
open import Data.Product
open import Data.Empty
open import Relation.Binary
-- definitions
data Ty (nl : ℕ) : Set where -- nl ~ (max.) number of labels
Tunit : Ty nl
Tlabel : Subset nl → Ty nl
Tfun : Ty nl → Ty nl → Ty nl
TEnv : ℕ → Set
TEnv nl = List (Ty nl)
data _≤_ {nl} : Ty nl → Ty nl → Set where
Sunit : Tunit ≤ Tunit
Slabel : ∀ {snl snl'} → snl ⊆ snl' → (Tlabel snl) ≤ (Tlabel snl')
Sfun : ∀ {A A' B B'} → A' ≤ A → B ≤ B' → (Tfun A B) ≤ (Tfun A' B')
data _∈`_ {nl : ℕ} : Ty nl → TEnv nl → Set where
here : ∀ {lt φ} → lt ∈` (lt ∷ φ)
there : ∀ {lt lt' φ} → lt ∈` φ → lt ∈` (lt' ∷ φ)
data Exp {nl : ℕ} : TEnv nl → Ty nl → Set where
Unit : ∀ {φ} → Exp φ Tunit
Var : ∀ {φ t} → (x : t ∈` φ) → Exp φ t -- t ∈` φ gives us the position of "x" in env
SubType : ∀ {A A' φ} → Exp φ A → A ≤ A'
→ Exp φ A'
Lab-I : ∀ {l snl φ} → l ∈ snl → Exp φ (Tlabel snl)
Lab-E : ∀ {snl φ B} → Exp φ (Tlabel snl)
→ (∀ l → l ∈ snl → Exp φ B)
→ Exp φ B
Abs : ∀ {B A φ} → Exp (A ∷ φ) B
→ Exp φ (Tfun A B)
App : ∀ {A B φ} → Exp φ (Tfun A B)
→ (ex : Exp φ A)
→ Exp φ B
-- subtyping properties
≤-trans : ∀ {nl} {t t' t'' : Ty nl} → t ≤ t' → t' ≤ t'' → t ≤ t''
≤-trans Sunit Sunit = Sunit
≤-trans (Slabel snl⊆snl') (Slabel snl'⊆snl'') = Slabel (⊆-trans snl⊆snl' snl'⊆snl'')
≤-trans (Sfun a'≤a b≤b') (Sfun a''≤a' b'≤b'') = Sfun (≤-trans a''≤a' a'≤a) (≤-trans b≤b' b'≤b'')
≤-refl : ∀ {nl} → (t : Ty nl) → t ≤ t
≤-refl Tunit = Sunit
≤-refl (Tlabel x) = Slabel (⊆-refl)
≤-refl (Tfun t t') = Sfun (≤-refl t) (≤-refl t')
-- big-step semantics
Val : ∀ {nl} → Ty nl → Set
Val Tunit = Data.Unit.⊤
Val {nl} (Tlabel snl) = Σ (Fin nl) (λ l → l ∈ snl)
Val (Tfun ty ty₁) = (Val ty) → (Val ty₁)
coerce : ∀ {nl} {t t' : Ty nl} → t ≤ t' → Val t → Val t' -- supertype of a Value is also a Value
coerce Sunit t = tt
coerce (Slabel snl⊆snl') (Finnl , Finnl∈snl) = (Finnl , (snl⊆snl' Finnl∈snl))
coerce (Sfun A'≤A B≤B') f = λ x → coerce B≤B' (f (coerce A'≤A x))
access : ∀ {nl} {t : Ty nl} {φ} → t ∈` φ → All Val φ → Val t
access here (px ∷ ρ) = px
access (there x) (px ∷ ρ) = access x ρ
eval : ∀ {nl φ t} → Exp {nl} φ t → All Val φ → Val t
eval Unit ϱ = tt
eval (Var x) ϱ = access x ϱ
eval (SubType e a≤a') ϱ = coerce a≤a' (eval e ϱ)
eval (Lab-I {l} l∈snl) ϱ = l , (l∈snl)
eval (Lab-E e case) ϱ with eval e ϱ
... | lab , lab∈nl = eval (case lab lab∈nl) ϱ
eval (Abs e) ϱ = λ x → eval e (x ∷ ϱ)
eval (App e e₁) ϱ = (eval e ϱ) (eval e₁ ϱ)
-- small-step semantics
-- substitution taken from PLFA
ext : ∀ {nl φ ψ} → (∀ {A : Ty nl} → A ∈` φ → A ∈` ψ)
→ (∀ {A B} → A ∈` (B ∷ φ) → A ∈` (B ∷ ψ))
ext ϱ here = here
ext ϱ (there x) = there (ϱ x)
rename : ∀ {nl φ ψ} → (∀ {A : Ty nl} → A ∈` φ → A ∈` ψ)
→ (∀ {A} → Exp φ A → Exp ψ A)
rename ϱ Unit = Unit
rename ϱ (Var x) = Var (ϱ x)
rename ϱ (SubType expr:A' A'≤A) = SubType (rename ϱ expr:A') A'≤A
rename {ψ} ϱ (Lab-I l∈snl) = Lab-I {ψ} l∈snl
rename ϱ (Lab-E expr:snl case) = Lab-E (rename ϱ expr:snl)
λ l l∈snl → (rename ϱ (case l l∈snl))
rename ϱ (Abs expr:B) = Abs (rename (ext ϱ) expr:B)
rename ϱ (App expr:A->B expr:A) = App (rename ϱ expr:A->B) (rename ϱ expr:A)
exts : ∀ {nl φ ψ} → (∀ {A : Ty nl} → A ∈` φ → Exp ψ A)
→ (∀ {A B} → A ∈` (B ∷ φ) → Exp (B ∷ ψ) A)
exts ϱ here = Var (here)
exts ϱ (there x) = rename there (ϱ x)
subst : ∀ {nl φ ψ} → (∀ {A : Ty nl} → A ∈` φ → Exp ψ A) -- simult. substitution
→ (∀ {A : Ty nl} → Exp φ A → Exp ψ A)
subst ϱ Unit = Unit
subst ϱ (Var x) = ϱ x
subst ϱ (SubType expr:A' A'≤A) = SubType (subst ϱ expr:A') A'≤A
subst {ψ} ϱ (Lab-I l∈snl) = Lab-I {ψ} l∈snl
subst ϱ (Lab-E expr:snl case) = Lab-E (subst ϱ expr:snl)
λ l l∈snl → (subst ϱ (case l l∈snl))
subst ϱ (Abs expr:B) = Abs (subst (exts ϱ) expr:B)
subst ϱ (App expr:A→B expr:A) = App (subst ϱ expr:A→B) (subst ϱ expr:A)
_[[_]] : ∀ {nl φ} {A B : Ty nl} → Exp (B ∷ φ) A → Exp φ B → Exp φ A -- single substitution
_[[_]] {nl} {φ} {A} {B} N M = subst {nl} {B ∷ φ} {φ} ϱ {A} N
where
ϱ : ∀ {A} → A ∈` (B ∷ φ) → Exp φ A
ϱ here = M
ϱ (there x) = Var x
expansionlemma : ∀ {nl} {lt : Ty nl} {φ φ'} → lt ∈` φ' → lt ∈` (φ' ++ φ)
expansionlemma here = here
expansionlemma (there x) = there (expansionlemma x)
extensionlemma : ∀ {nl} {lt : Ty nl} {φ φ'} → lt ∈` φ → lt ∈` (φ' ++ φ)
extensionlemma {φ' = []} here = here
extensionlemma {φ' = x ∷ xs} here = there (extensionlemma{φ' = xs} here)
extensionlemma {φ' = []} (there y) = there y
extensionlemma {φ' = x ∷ xs} (there y) = there (extensionlemma {φ' = xs} (there y))
inextdebr : ∀ {nl} {B A : Ty nl} {φ' φ} → B ∈` (φ' ++ φ) → B ∈` (φ' ++ (A ∷ φ))
inextdebr {φ' = []} here = there here
inextdebr {φ' = []} (there x) = there (there x)
inextdebr {φ' = x ∷ xs} here = here
inextdebr {φ' = x ∷ xs} (there y) = there (inextdebr{φ' = xs} y)
inext : ∀ {nl} {φ φ'} {A B : Ty nl} → Exp (φ' ++ φ) B → Exp (φ' ++ (A ∷ φ)) B
inext Unit = Unit
inext {φ' = φ'} (Var x) = Var (inextdebr{φ' = φ'} x)
inext {φ = φ}{φ' = φ'} (SubType expr b≤b') = SubType (inext{φ = φ}{φ' = φ'} expr) b≤b'
inext (Lab-I x) = Lab-I x
inext {φ = φ} {φ' = φ'} (Lab-E x x₁) = Lab-E (inext{φ = φ}{φ' = φ'} x) λ l x₂ → inext{φ = φ}{φ' = φ'} (x₁ l x₂)
inext {nl} {φ} {φ'} (Abs{A = A°} x) = Abs (inext{φ = φ}{φ' = A° ∷ φ'} x)
inext {φ = φ} {φ' = φ'} (App x x₁) = App (inext{φ = φ}{φ' = φ'} x) (inext{φ = φ}{φ' = φ'} x₁)
debrsub : ∀ {nl} {B B' A A' : Ty nl} {φ' φ} → B ∈` (φ' ++ (A ∷ φ)) → A' ≤ A → B ≤ B' → Exp (φ' ++ (A' ∷ φ)) B'
debrsub {φ' = []} here a'≤a b≤b' = SubType (Var here) (≤-trans a'≤a b≤b')
debrsub {φ' = []} (there x) a'≤a b≤b' = SubType (Var (there x)) b≤b'
debrsub {φ' = x ∷ xs} here a'≤a b≤b' = SubType (Var (here)) b≤b'
debrsub {φ' = x ∷ xs} (there z) a'≤a b≤b' = inext{φ' = []}{A = x} (debrsub{φ' = xs} z a'≤a b≤b')
typesub : ∀ {nl φ φ' A B A' B'} → Exp{nl} (φ' ++ (A ∷ φ)) B → A' ≤ A → B ≤ B' → Exp (φ' ++ (A' ∷ φ)) B' -- subtyping "substitution"
typesub Unit a'≤a Sunit = Unit
typesub {φ = φ} {φ'} {A} {B} {A'} {B'} (Var x) a'≤a b≤b' = debrsub{φ' = φ'}{φ = φ} x a'≤a b≤b'
typesub {nl} {φ} {φ'} (SubType expr x) a'≤a b≤b' = typesub{nl}{φ}{φ'} expr a'≤a (≤-trans x b≤b')
typesub (Lab-I l∈snl) a'≤a b≤b' = SubType (Lab-I l∈snl) b≤b'
typesub {nl} {φ} {φ'} (Lab-E{snl = snl} expr cases) a'≤a b≤b' = Lab-E (typesub{nl}{φ}{φ'} expr a'≤a (≤-refl (Tlabel snl))) λ l x → typesub{nl}{φ}{φ'} (cases l x) a'≤a b≤b'
typesub {φ' = φ'}{A = A}{B = A°→B°}{A' = A'}{B' = A°°→B°°} (Abs{A = A°} expr) a'≤a (Sfun{A = .A°}{A' = A°°}{B = B°}{B' = B°°} A°°≤A° B°≤B°°)
= SubType (Abs (typesub{φ' = A° ∷ φ'} expr a'≤a B°≤B°°)) (Sfun A°°≤A° (≤-refl B°°))
typesub {nl}{φ}{φ'}{A}{B}{A'}{B'} (App{A = A°}{B = .B} expr expr') a'≤a b≤b' = SubType (App (typesub{nl}{φ}{φ'} expr a'≤a (≤-refl (Tfun A° B))) (typesub{nl}{φ}{φ'} expr' a'≤a (≤-refl A°))) b≤b'
-- we force values to have type SubType, since Lab-I results in expressions with type {l}
-- and we want to keep the information about which subset l is in
data Val' {n φ} : (t : Ty n) → Exp {n} φ t → Set where
Vunit : Val' (Tunit) Unit
Vlab : ∀ {l snl l∈snl} → Val' (Tlabel snl) (Lab-I{l = l}{snl} l∈snl)
Vfun : ∀ {A B exp} → Val' (Tfun A B) (Abs exp)
data _~>_ {n φ} : {A : Ty n} → Exp {n} φ A → Exp {n} φ A → Set where -- small-steps semantics relation (call-by-value)
ξ-App1 : ∀ {A B} {L L' : (Exp φ (Tfun B A))} {M}
→ L ~> L'
→ App L M ~> App L' M
ξ-App2 : ∀ {A B} {M M' : Exp φ A} {L : Exp φ (Tfun A B)}
→ Val' (Tfun A B) L
→ M ~> M'
→ App L M ~> App L M'
β-App : ∀ {A B M exp}
→ Val' B M
→ App{B = A} (Abs exp) M
~>
(exp [[ M ]])
ξ-SubType : ∀ {A A' A≤A' } {L L' : Exp φ A}
→ L ~> L'
→ SubType{A = A}{A'} L A≤A' ~> SubType{A = A} L' A≤A'
ξ-Lab-E : ∀ {A snl} {L L' : Exp φ (Tlabel snl)} {cases}
→ L ~> L'
→ Lab-E{B = A} L cases ~> Lab-E L' cases
β-Lab-E : ∀ {A l snl l∈snl cases}
→ Lab-E{B = A} (Lab-I{l = l}{snl} l∈snl) cases
~>
cases l (l∈snl)
γ-Lab-I : ∀ {l snl snl'} {l∈snl : l ∈ snl} {snl⊆snl' : snl ⊆ snl'}
→ SubType (Lab-I{l = l}{snl = snl} l∈snl) (Slabel snl⊆snl')
~>
Lab-I (snl⊆snl' l∈snl)
γ-Abs : ∀ {A B A' B' e} {A'≤A : A' ≤ A} {B≤B' : B ≤ B'}
→ SubType (Abs{B = B}{A = A} e) (Sfun A'≤A B≤B')
~>
Abs{B = B'}{A = A'} (typesub{φ' = []} e A'≤A B≤B')
γ-SubType : ∀ {A A' A'' A≤A' A'≤A'' expr}
→ SubType{A = A'}{A' = A''} (SubType{A = A} expr A≤A') A'≤A''
~>
SubType expr (≤-trans A≤A' A'≤A'')
-- either we define Unit values to be SubTypes of Unit≤Unit; or we introducte the following rule
β-SubType-Unit : SubType Unit Sunit
~>
Unit
-- properties of small-step evaluation
infix 2 _~>>_ -- refl. transitive closure
infix 1 begin_
infixr 2 _~>⟨_⟩_
infix 3 _∎
data _~>>_ : ∀ {n} {φ} {A : Ty n} → Exp φ A → Exp φ A → Set where
_∎ : ∀ {n φ} {A : Ty n} (L : Exp φ A)
→ L ~>> L
_~>⟨_⟩_ : ∀ {n φ} {A : Ty n} (L : Exp φ A) {M N : Exp φ A}
→ L ~> M
→ M ~>> N
→ L ~>> N
begin_ : ∀ {n φ} {A : Ty n} {M N : Exp φ A} → M ~>> N → M ~>> N
begin M~>>N = M~>>N
-- progress theorem
data Progress {n A} (M : Exp{n} [] A) : Set where
step : ∀ {N : Exp [] A} → M ~> N → Progress M
done : Val' A M → Progress M
-- proof
progress : ∀ {n A} → (M : Exp{n} [] A) → Progress M
progress Unit = done Vunit
progress (Var ()) -- Var requires a proof for A ∈ [] which cannot exist
progress (SubType Unit Sunit) = step β-SubType-Unit
progress (SubType (Var ()) A'≤A)
progress (SubType (SubType expr:A' x) A'≤A) = step γ-SubType
progress (SubType (Lab-I{l}{snl} l∈snl) (Slabel{snl' = snl'} snl⊆snl')) = step γ-Lab-I
progress (SubType (Lab-E expr:A' x) A'≤A) with progress (Lab-E expr:A' x)
... | step a = step (ξ-SubType a)
... | done () -- Lab-E without SubType can't be a value
progress (SubType (Abs expr:A') (Sfun A'≤A B≤B')) with progress (Abs expr:A')
... | step a = step (ξ-SubType a)
... | done Vfun = step γ-Abs
progress (SubType (App expr:A' expr:A'') A'≤A) with progress (expr:A')
... | step a = step (ξ-SubType (ξ-App1 a))
... | done Vfun with progress (expr:A'')
... | step b = step (ξ-SubType (ξ-App2 Vfun b))
... | done val = step (ξ-SubType (β-App val))
progress (Lab-I l∈snl) = done Vlab
progress (Lab-E expr cases) with progress expr
... | step expr~>expr' = step (ξ-Lab-E expr~>expr')
... | done Vlab = step (β-Lab-E)
progress (Abs expr) = done Vfun
progress (App L M) with progress L
... | step L~>L' = step (ξ-App1 L~>L')
... | done Vfun with progress M
... | step M~>M' = step (ξ-App2 Vfun M~>M')
... | done x = step (β-App x)
-- generation of evaluation sequences
-- taken from plfa
data Gas : Set where
gas : ℕ → Gas
data Finished {n φ A} (N : Exp{n} φ A) : Set where
done : Val' A N → Finished N
out-of-gas : Finished N
data Steps : ∀ {n A} → Exp{n} [] A → Set where
steps : ∀ {n A} {L N : Exp{n} [] A}
→ L ~>> N
→ Finished N
→ Steps L
eval' : ∀ {n A} → Gas → (L : Exp{n} [] A) → Steps L
eval' (gas zero) L = steps (L ∎) out-of-gas
eval' (gas (suc m)) L with progress L
... | done VL = steps (L ∎) (done VL)
... | step {M} L~>M with eval' (gas m) M
... | steps M~>>N fin = steps (L ~>⟨ L~>M ⟩ M~>>N) fin
-- examples
-- (λ (x : Unit) → x) (Unit)
ex0 : Exp{suc zero} [] Tunit
ex0 = App (Abs (Unit{φ = (Tunit ∷ [])})) (Unit)
_ : ex0 ~>> Unit
_ =
begin
App (Abs (Unit)) (Unit)
~>⟨ β-App (Vunit) ⟩
Unit
∎
ex1 : Exp{suc zero} [] Tunit
ex1 = Lab-E (Lab-I (x∈⁅x⁆ zero)) λ l x → Unit
_ : ex1 ~>> Unit
_ =
begin
Lab-E (Lab-I (x∈⁅x⁆ zero)) (λ l x → Unit)
~>⟨ β-Lab-E ⟩
Unit
∎
ex2 : Exp{suc zero} [] Tunit
ex2 = App (SubType (Abs Unit) (Sfun Sunit Sunit)) Unit
-- proof that {inside, outside} ⊆ {inside, inside}
-- i.e. {0} ⊆ {0, 1}
x⊆y : (inside ∷ outside ∷ []) ⊆ (inside ∷ inside ∷ [])
x⊆y {.zero} here = here
x⊆y {.(suc (suc _))} (there (there ()))
-- proof that zero is in (inside ∷ outside ∷ [])
-- i.e. 0 ∈ {0}
l∈snl : (zero) ∈ (inside ∷ outside ∷ [])
l∈snl = here
-- [({0, 1}→{0, 1} <: {0}→{0, 1}) (λ x : {0, 1} . x)] 0
ex3 : Exp{suc (suc zero)} [] (Tlabel (inside ∷ inside ∷ []))
ex3 = App (SubType (Abs{A = Tlabel (inside ∷ inside ∷ [])} (Var here)) (Sfun (Slabel{snl = (inside ∷ outside ∷ [])} x⊆y) (≤-refl (Tlabel (inside ∷ inside ∷ [])))))
(Lab-I l∈snl)
|
{
"alphanum_fraction": 0.4336877076,
"avg_line_length": 42.5141242938,
"ext": "agda",
"hexsha": "f392b403d10abf124168fc910aeeae3f6cf99473",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-14T17:52:29.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-14T17:52:29.000Z",
"max_forks_repo_head_hexsha": "a87fb6402639c3d2bb393cc5466426c28e7a0398",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "kcaliban/ldlc",
"max_forks_repo_path": "src/llc/IntrinsicallyTypedLLC.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a87fb6402639c3d2bb393cc5466426c28e7a0398",
"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": "kcaliban/ldlc",
"max_issues_repo_path": "src/llc/IntrinsicallyTypedLLC.agda",
"max_line_length": 196,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a87fb6402639c3d2bb393cc5466426c28e7a0398",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "kcaliban/ldlc",
"max_stars_repo_path": "src/llc/IntrinsicallyTypedLLC.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 5861,
"size": 15050
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Wrapper for the erased modality
--
-- This allows us to store erased proofs in a record and use projections
-- to manipulate them without having to turn on the unsafe option
-- --irrelevant-projections.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Erased where
open import Level using (Level)
private
variable
a b c : Level
A : Set a
B : Set b
C : Set c
------------------------------------------------------------------------
-- Type
record Erased (A : Set a) : Set a where
constructor [_]
field .erased : A
open Erased public
------------------------------------------------------------------------
-- Algebraic structure: Functor, Appplicative and Monad-like
map : (A → B) → Erased A → Erased B
map f [ a ] = [ f a ]
pure : A → Erased A
pure x = [ x ]
infixl 4 _<*>_
_<*>_ : Erased (A → B) → Erased A → Erased B
[ f ] <*> [ a ] = [ f a ]
infixl 1 _>>=_
_>>=_ : Erased A → (.A → Erased B) → Erased B
[ a ] >>= f = f a
------------------------------------------------------------------------
-- Other functions
zipWith : (A → B → C) → Erased A → Erased B → Erased C
zipWith f a b = ⦇ f a b ⦈
|
{
"alphanum_fraction": 0.4401220442,
"avg_line_length": 24.2777777778,
"ext": "agda",
"hexsha": "4e74ce3df4186e3db9ac2938b8341451fc63cb6e",
"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/Erased.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/Erased.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/Erased.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": 324,
"size": 1311
}
|
open import Signature
-- | In this module, we construct the free monad and the free completely
-- iterative monad over a signature Σ (see Aczel, Adamek, Milius and Velebil).
-- The first assigns to a set V of variables the set TV of finite terms over Σ
-- (that is, finite trees labelled with symbols in f ∈ ∥Σ∥ and ar(f) branching).
-- The second extends this to also allow for infinite trees, the set of those
-- is then denoted by T∞(V).
-- Categorically, T(V) is the initial (Σ + V)-algebra, whereas T∞(V) is the
-- final (Σ + V)-coalgebra.
module Terms (Σ : Sig) where
open import Function
open import Data.Empty
open import Data.Unit hiding (_≤_)
open import Data.Product as Prod renaming (Σ to ⨿)
open import Data.Nat as Nat
open import Data.Sum as Sum
open import Relation.Binary.PropositionalEquality hiding ([_])
open import Relation.Binary hiding (_⇒_)
open import Relation.Unary hiding (_⇒_)
import Streams as Str
open import Streams hiding (corec)
-- | Natural transformations
Nat : (Set → Set) → (Set → Set) → Set₁
Nat F G = ∀{X} → F X → G X
Id : Set → Set
Id = id
least : {X : Set} (_⊑_ : Rel X _) (P : X → Set) → X → Set
least _⊑_ P x = (P x) × (∀ {y} → P y → x ⊑ y)
least-unique : {X : Set} {_⊑_ : Rel X _} → (IsTotalOrder _≡_ _⊑_) →
{P : X → Set} → (x y : X) → least _⊑_ P x → least _⊑_ P y → x ≡ y
least-unique isTO x y (p , l₁) (q , l₂) with IsTotalOrder.total isTO x y
least-unique isTO x y (p , l₁) (q , l₂) | inj₁ x⊑y =
IsTotalOrder.antisym isTO x⊑y (l₂ p)
least-unique isTO x y (p , l₁) (q , l₂) | inj₂ y⊑x =
IsTotalOrder.antisym isTO (l₁ q) y⊑x
infixr 1 _⇒_
_⇒_ = Nat
data T (V : Set) : Set where
sup : ⟪ Σ ⟫ (T V) ⊎ V → T V
rec : ∀{V X} → (f : ⟪ Σ ⟫ X ⊎ V → X) → T V → X
rec f (sup (inj₁ (s , α))) = f (inj₁ (s , λ i → rec f (α i)))
rec f (sup (inj₂ y)) = f (inj₂ y)
-- | Functor T, on morphisms
T₁ : ∀ {V W} → (V → W) → T V → T W
T₁ f = rec (sup ∘ Sum.map id f)
η : Id ⇒ T
η = sup ∘ inj₂
μ : T ∘ T ⇒ T
μ {V} = rec f
where
f : ⟪ Σ ⟫ (T V) ⊎ T V → T V
f = [ sup ∘ inj₁ , id ]
-- | T is free over Σ with inclusion
ι : ⟪ Σ ⟫ ⇒ T
ι = sup ∘ inj₁ ∘ ⟪ Σ ⟫₁ η
-- | Kleisli morphsims for T∞ V
Subst : Set → Set → Set
Subst V W = V → T W
infixr 9 _•_
-- | Kleisli composition
_•_ : ∀ {U V W} → Subst V W → Subst U V → Subst U W
τ • σ = μ ∘ T₁ τ ∘ σ
-- | Application of substitutions to infinite terms
app : ∀ {V W} → Subst V W → T V → T W
app σ = μ ∘ T₁ σ
infixl 1 _≡ₛ_
_≡ₛ_ : ∀{V W} → Rel (Subst V W) _
σ ≡ₛ τ = ∀ {v} → σ v ≡ τ v
-- | Order on subsitutions
_⊑_ : ∀{V W} → Rel (Subst V W) _
σ₁ ⊑ σ₂ = ∃ λ σ → σ • σ₁ ≡ₛ σ₂
matches : ∀{V W} → T V → T W → Subst V W → Set
matches t s σ = app σ t ≡ s
-- | Most general matcher
mgm : ∀{V W} → T V → T W → Subst V W → Set
mgm t s = least _⊑_ (matches t s)
unifies : ∀{V W} → T V → T V → Subst V W → Set
unifies t s σ = app σ t ≡ app σ s
-- | Most general unifier
mgu : ∀{V W} → T V → T V → Subst V W → Set
mgu t s = least _⊑_ (unifies t s)
-- | Free variables
fv : ∀{V} → T V → Pred V _
fv (sup (inj₁ (s , α))) v = ⨿ (Sig.ar Σ s) λ i → (fv (α i) v)
fv (sup (inj₂ v₁)) v = v₁ ≡ v
isVar : ∀{V} → Pred (T V) _
isVar (sup (inj₁ x)) = ⊥
isVar (sup (inj₂ y)) = ⊤
record T∞ (V : Set) : Set where
coinductive
field out : ⟪ Σ ⟫ (T∞ V) ⊎ V
open T∞ public
sum-lift : {A B : Set} (R₁ : A → A → Set) (R₂ : B → B → Set) (x y : A ⊎ B) → Set
sum-lift R₁ R₂ (inj₁ x) (inj₁ y) = R₁ x y
sum-lift R₁ R₂ (inj₁ x) (inj₂ y) = ⊥
sum-lift R₁ R₂ (inj₂ x) (inj₁ y) = ⊥
sum-lift R₁ R₂ (inj₂ x) (inj₂ y) = R₂ x y
~-data : ∀{V} (R : T∞ V → T∞ V → Set) (u w : ⟪ Σ ⟫ (T∞ V) ⊎ V) → Set
~-data R = sum-lift (sig-lift R) _≡_
record _~_ {V : Set} (t s : T∞ V) : Set where
coinductive
field out~ : ~-data _~_ (out t) (out s)
open _~_ public
corec : ∀{V X} → (f : X → ⟪ Σ ⟫ X ⊎ V) → X → T∞ V
out (corec f x) with f x
... | inj₁ (s , α) = inj₁ (s , (λ i → corec f (α i)))
... | inj₂ v = inj₂ v
prim-corec : ∀{V X} → (f : X → ⟪ Σ ⟫ X ⊎ V ⊎ T∞ V) → X → T∞ V
out (prim-corec {V} {X} f x) with f x
... | inj₁ (s , α) = inj₁ (s , (λ i → prim-corec f (α i)))
... | inj₂ (inj₁ v) = inj₂ v
... | inj₂ (inj₂ t) = out t
sup∞ : ∀{V} → ⟪ Σ ⟫ (T∞ V) ⊎ V → T∞ V
out (sup∞ (inj₁ u)) = inj₁ u
out (sup∞ (inj₂ v)) = inj₂ v
-- | Functor T∞, on morphisms
T∞₁ : ∀ {V W} → (V → W) → T∞ V → T∞ W
T∞₁ f = corec (Sum.map id f ∘ out)
η∞ : Id ⇒ T∞
η∞ = sup∞ ∘ inj₂
μ∞ : T∞ ∘ T∞ ⇒ T∞
μ∞ {V} = corec f
where
g : T∞ V → ⟪ Σ ⟫ (T∞ (T∞ V)) ⊎ V
g = Sum.map (⟪ Σ ⟫₁ η∞) id ∘ out
f : T∞ (T∞ V) → ⟪ Σ ⟫ (T∞ (T∞ V)) ⊎ V
f = [ inj₁ , g ] ∘ out
ι∞ : ⟪ Σ ⟫ ⇒ T∞
ι∞ {V} = g ∘ inj₁
where
g : ⟪ Σ ⟫ V ⊎ T∞ V → T∞ V
g = prim-corec [ inj₁ ∘ ⟪ Σ ⟫₁ (inj₂ ∘ η∞) , inj₂ ∘ inj₂ ]
-- | T is a submonad of T∞
χ : T ⇒ T∞
χ = rec sup∞
-- | Kleisli morphsims for T∞ V
Subst∞ : Set → Set → Set
Subst∞ V W = V → T∞ W
infixl 1 _≡ₛ∞_
_≡ₛ∞_ : ∀{V W} → Rel (Subst∞ V W) _
σ ≡ₛ∞ τ = ∀ {v} → σ v ~ τ v
infixr 9 _•∞_
-- | Kleisli composition
_•∞_ : ∀ {U V W} → Subst∞ V W → Subst∞ U V → Subst∞ U W
τ •∞ σ = μ∞ ∘ T∞₁ τ ∘ σ
-- | Application of substitutions to infinite terms
app∞ : ∀ {V W} → Subst∞ V W → T∞ V → T∞ W
app∞ σ = μ∞ ∘ T∞₁ σ
isVar∞ : ∀{V} → Pred (T∞ V) _
isVar∞ t with out t
isVar∞ t | inj₁ x = ⊥
isVar∞ t | inj₂ v = ⊤
varNowOrLater : ∀{V} → (T∞ V → Pred V _) → T∞ V → Pred V _
varNowOrLater R t v with out t
... | inj₁ (f , α) = ∃ (λ i → R (α i) v)
... | inj₂ v₁ = v ≡ v₁
record fv∞ {V : Set} (t : T∞ V) (v : V) : Set where
coinductive
field isFv∞ : varNowOrLater fv∞ t v
root-matches : ∀{V} → T V → ∥ Σ ∥ → Set
root-matches (sup (inj₁ (g , _))) f = g ≡ f
root-matches (sup (inj₂ y)) f = ⊥
record RootsMatch {V : Set} (s : Stream (T V)) (f : ∥ Σ ∥) : Set where
coinductive
field
hd-match : root-matches (hd s) f
tl-match : RootsMatch (tl s) f
open RootsMatch
-- | Nasty hack: assume that RootsMatch is propositional
postulate
RootsMatch-unique : ∀{V} {s : Stream (T V)} {f : ∥ Σ ∥}
(p q : RootsMatch s f) → p ≡ q
split : {V : Set} (s : Stream (T V)) (f : ∥ Σ ∥) → RootsMatch s f →
ar Σ f → Stream (T V)
hd (split s f p i) with hd s | hd-match p
hd (split s f p i) | sup (inj₁ (.f , α)) | refl = α i
hd (split s f p i) | sup (inj₂ y) | ()
tl (split s f p i) = split (tl s) f (tl-match p) i
root-matches∞ : ∀{V} → T∞ V → ∥ Σ ∥ → Set
root-matches∞ t f with out t
root-matches∞ t f | inj₁ (g , _) = f ≡ g
root-matches∞ t f | inj₂ v = ⊥
split∞ : {V : Set} → (t : T∞ V) (f : ∥ Σ ∥) → root-matches∞ t f →
ar Σ f → T∞ V
split∞ t f p i with out t
split∞ t f refl i | inj₁ (.f , α) = α i
split∞ t f () i | inj₂ y
data AnyRootMatch {V : Set} (s : Stream (T V)) (f : ∥ Σ ∥) : Stream (T V) → Set where
match-hd : root-matches (hd s) f → AnyRootMatch s f s
match-tl : AnyRootMatch (tl s) f (tl s) → AnyRootMatch s f (tl s)
first-root-match : ∀{V} → Stream (T V) → ∥ Σ ∥ → ℕ → Set
first-root-match s f = least _≤_ (λ k → root-matches (s at k) f)
conv-branch : {V : Set} (R : Stream (T V) → T∞ V → Set) →
Stream (T V) → T∞ V → T V → ⟪ Σ ⟫ (T∞ V) ⊎ V → Set
conv-branch R s t (sup (inj₁ (f , α))) (inj₁ (g , β)) =
⨿ (f ≡ g) λ p →
⨿ (RootsMatch (tl s) f) λ q →
∀ i → R (split (tl s) f q i) (β (subst (ar Σ) p i))
conv-branch R s t (sup (inj₁ (f , α))) (inj₂ v) = ⊥
conv-branch R s t (sup (inj₂ v)) (inj₁ (f , α)) =
∃ λ s' → AnyRootMatch s f s' × R s' t
conv-branch R s t (sup (inj₂ v)) (inj₂ w) = v ≡ w × R (tl s) t
{-
conv-branch : {V : Set} (R : Stream (T V) → T∞ V → Set) →
Stream (T V) → T∞ V → Set
conv-branch R s t with hd s | out t
conv-branch R s t | sup (inj₁ (f , α)) | inj₁ (g , β) =
⨿ (f ≡ g) λ p →
⨿ (RootsMatch (tl s) f) λ q →
∀ i → R (split (tl s) f q i) (β (subst (ar Σ) p i))
conv-branch R s t | sup (inj₁ x) | inj₂ v = ⊥
conv-branch R s t | sup (inj₂ v) | inj₁ (f , α) =
∃ λ n → first-root-match s f n × R (δ n s) t
conv-branch R s t | sup (inj₂ v) | inj₂ w = v ≡ w × R (tl s) t
-}
-- | A sequence s of finite terms converges to a possibly infinite term,
-- if for all i, sᵢ₊₁ = sᵢ[σ] for some substitution σ : V → T V and t = sᵢ[τ]
-- for some τ : V → T∞ V.
-- Note that this coincides with convergence in the prefix metric.
record _→∞_ {V : Set} (s : Stream (T V)) (t : T∞ V) : Set where
coinductive
field
conv-out : conv-branch _→∞_ s t (hd s) (out t)
{-
hd-matches : ∃ λ σ → hd (tl s) ≡ app σ (hd s)
hd-prefix : ∃ λ τ → t ~ app∞ τ (χ (hd s))
tl-converges : tl s →∞ t
-}
open _→∞_ public
{-
lem₂ : ∀{V n f} {s : Stream (T V)} →
first-root-match s f (suc n) → first-root-match (tl s) f n
lem₂ {n = n} {f} {s} (p , q) = (p , λ m → ≤-pred (q m))
-}
{-
lem₃ : ∀{V f} (s : Stream (T V)) → ∀{t} →
first-root-match s f zero → s →∞ t → first-root-match (tl s) f zero
lem₃ s {t} m c with hd s | out t | conv-out c
lem₃ s (refl , q) c | sup (inj₁ _) | inj₁ _ | refl , p , _
= (hd-match p , (λ m → z≤n))
lem₃ s (refl , q) c | sup (inj₁ _) | inj₂ v | ()
lem₃ s (() , q) c | sup (inj₂ v) | u | r
-}
lem₆ : ∀{V} (s : Stream (T V)) → ∀{t f} →
root-matches (hd s) f → s →∞ t → RootsMatch (tl s) f
hd-match (lem₆ s {t} m c) with hd s | out t | conv-out c
hd-match (lem₆ s refl c) | sup (inj₁ (f , α)) | inj₁ (.f , β) | refl , m₁ , br = hd-match m₁
hd-match (lem₆ s refl c) | sup (inj₁ (f , α)) | inj₂ y | ()
hd-match (lem₆ s () c) | sup (inj₂ v) | x | y
tl-match (lem₆ s {t} m c) with hd s | out t | conv-out c
tl-match (lem₆ s refl c) | sup (inj₁ (f , α)) | inj₁ (.f , β) | refl , m₁ , br = tl-match m₁
tl-match (lem₆ s refl c) | sup (inj₁ (f , α)) | inj₂ y | ()
tl-match (lem₆ s () c) | sup (inj₂ v) | x | y
lem₅ : ∀{V} (s : Stream (T V)) → ∀{t f} →
root-matches (hd s) f → s →∞ t → tl s →∞ t
conv-out (lem₅ s {t} m c) with hd s | out t | conv-out c
conv-out (lem₅ s refl c) | sup (inj₁ (f , α)) | inj₁ (.f , β) | refl , m , br = {!!}
conv-out (lem₅ s refl c) | sup (inj₁ (f , α)) | inj₂ y | ()
conv-out (lem₅ s () c) | sup (inj₂ v) | x | y
lem₇ : ∀{V} (s : Stream (T V)) → ∀{t f α} →
RootsMatch (tl s) f → s →∞ t → hd s ≡ sup (inj₁ (f , α)) →
∃ λ β → hd (tl s) ≡ sup (inj₁ (f , β))
lem₇ = {!!}
lem₄ : ∀{V} (s : Stream (T V)) → ∀{t} →
s →∞ t → tl s →∞ t
lem₄ {V} s {t} p = q {s} {t} (hd s) (out t) refl refl (conv-out p)
where
q : ∀{s t} → (u : T V) → (x : ⟪ Σ ⟫ (T∞ V) ⊎ V) →
hd s ≡ u → out t ≡ x → conv-branch _→∞_ s t u x → tl s →∞ t
conv-out (q {s} {t} (sup (inj₁ (f , α))) (inj₁ (.f , β)) hs≡u ot≡x (refl , m , br))
= subst₂ (λ u₁ u₂ → conv-branch _→∞_ (tl s) t u₁ u₂)
(sym (proj₂ (lem₇ s m
(record { conv-out =
subst₂ (λ u₁ u₂ → conv-branch _→∞_ s t u₁ u₂)
(sym hs≡u) (sym ot≡x) (refl , (m , br)) })
hs≡u)
)
)
(sym ot≡x) (refl , tl-match m , (λ i → lem₅ (split (tl s) f m i) {!!} (br i)))
-- conv-branch _→∞_ (tl s₁) t₁ (hd (tl s₁)) (out t₁)
-- conv-branch _→∞_ (tl .s) .t (hd (tl .s)) (out .t)
q (sup (inj₁ x)) (inj₂ y) hs≡u ot≡x ()
q (sup (inj₂ y)) (inj₁ (g , β)) hs≡u ot≡x (s₁ , match-hd x , c) = lem₅ s₁ x c
q (sup (inj₂ y)) (inj₁ (g , β)) hs≡u ot≡x (._ , match-tl m , c) = c
-- conv-out (q (sup (inj₂ y)) (inj₁ (g , β)) hs≡u ot≡x (zero , m , br)) = {!!}
-- conv-out (q {s} {t} (sup (inj₂ y)) (inj₁ x) hs≡u ot≡x (suc n , m , br)) = {!!}
-- q {s} {t} (hd (δ n s)) (inj₁ x) {!!} ot≡x {!!}
-- q (hd (tl s)) (inj₁ x) ? ot≡x br
--q (hd (δ n s)) (out t) refl refl (conv-out br)
q (sup (inj₂ y)) (inj₂ y₁) hs≡u ot≡x br = proj₂ br
{-
lem₄ : ∀{V} (s : Stream (T V)) → ∀{t} →
s →∞ t → tl s →∞ t
lem₄ {V} s {t} p = q {s} {t} (hd s) (out t) refl refl (conv-out p)
where
q : ∀{s t} → (u : T V) → (x : ⟪ Σ ⟫ (T∞ V) ⊎ V) →
hd s ≡ u → out t ≡ x → conv-branch _→∞_ s t u x → tl s →∞ t
q (sup (inj₁ (f , α))) (inj₁ (.f , β)) hs≡u ot≡x (refl , m , br) = {!!}
q (sup (inj₁ x)) (inj₂ y) hs≡u ot≡x ()
conv-out (q (sup (inj₂ y)) (inj₁ (g , β)) hs≡u ot≡x (zero , m , br)) = {!!}
conv-out (q {s} {t} (sup (inj₂ y)) (inj₁ x) hs≡u ot≡x (suc n , m , br)) = {!!}
-- q {s} {t} (hd (δ n s)) (inj₁ x) {!!} ot≡x {!!}
-- q (hd (tl s)) (inj₁ x) ? ot≡x br
--q (hd (δ n s)) (out t) refl refl (conv-out br)
q (sup (inj₂ y)) (inj₂ y₁) hs≡u ot≡x br = proj₂ br
-}
{-
lem₄ {V} s {t} p | sup (inj₁ (f , α)) | inj₁ (.f , β) | refl , m , r =
q {!!} m r
where
q : {s' : Stream (T V)} {t : T∞ V} {f : ∥ Σ ∥} {β : ar Σ f → T∞ V} →
out t ≡ inj₁ (f , β) →
(m : RootsMatch s' f) →
((i : ar Σ f) → split s' f m i →∞ β i) →
s' →∞ t
conv-out (q {s'} {t} ts m n) with hd s' | hd-match m | out t
conv-out (q {s'} refl m n) | sup (inj₁ (f₁ , α₁)) | refl | inj₁ (.f₁ , β₁)
= (refl , tl-match m , (λ i → lem₄ (split s' f₁ m i) (n i)))
conv-out (q () m₁ n) | sup (inj₁ (f₁ , α₁)) | refl | inj₂ v
conv-out (q ts m n) | sup (inj₂ y) | () | u
lem₄ s p | sup (inj₁ x) | inj₂ y | ()
lem₄ s p | sup (inj₂ y) | inj₁ x | r = {!!}
lem₄ s p | sup (inj₂ y) | inj₂ y₁ | r = proj₂ r
-}
{-
lem₁ : ∀{V} (n k : ℕ) (s : Stream (T V)) → ∀{f g t} →
first-root-match s f n → first-root-match s g k →
δ n s →∞ t → δ k s →∞ t → f ≡ g
lem₁ n k s {f} {g} {t} m₁ m₂ c₁ c₂
with s at n | s at k | m₁ | m₂
| out t | conv-out c₁ | conv-out c₂
lem₁ zero zero s _ _ c₁ c₂
| sup (inj₁ (f , α)) | sup (inj₁ (g , β)) | (refl , p) | (refl , q)
| inj₁ x | w | r =
trans (proj₁ w) (sym (proj₁ r))
lem₁ zero zero s _ _ c₁ c₂
| sup (inj₁ (f , α)) | sup (inj₁ (g , β)) | (refl , p) | (refl , q)
| inj₂ y | () | r
lem₁ zero zero s _ _ c₁ c₂
| sup (inj₁ (f , α)) | sup (inj₂ y) | (refl , p) | (() , q)
| v | w | r
lem₁ zero zero s _ _ c₁ c₂
| sup (inj₂ y) | u | (() , p) | m₂
| v | w | r
lem₁ zero (suc k) s m₁ m₂ c₁ c₂ | u | u₁ | m₁' | m₂'
| v | w | r = lem₁ zero k (tl s) (lem₃ s m₁ c₁) {!m₂!} (lem₄ s c₁) c₂
lem₁ (suc n) zero s _ _ c₁ c₂ | u | u₁ | m₁ | m₂ | v | w | r = {!!}
lem₁ (suc n) (suc k) s m₁ m₂ c₁ c₂
| u | u₁ | _ | _
| v | w | r = lem₁ n k (tl s) (lem₂ m₁) (lem₂ m₂) c₁ c₂
lem : ∀{V} (n k : ℕ) {s : Stream (T V)} → ∀{f g t} →
first-root-match s f n → first-root-match s g k →
δ n s →∞ t → δ k s →∞ t → n ≡ k
lem n k p q c₁ c₂ =
least-unique NatTO n k p (subst _ (sym (lem₁ n k _ p q c₁ c₂)) q)
where
NatTO = TotalOrder.isTotalOrder (DecTotalOrder.totalOrder Nat.decTotalOrder)
{-
lem n k {s} {f} {g} {t} (m₁ , p) (m₂ , q) c₁ c₂ with conv-out c₁ | conv-out c₂
lem zero zero (m₁ , p) (m₂ , q) c₁ c₂ | u | v = refl
lem zero (suc k) (m₁ , p) (m₂ , q) c₁ c₂ | u | v = {!!}
lem (suc n) zero (m₁ , p) (m₂ , q) c₁ c₂ | u | v = {!!}
lem (suc n) (suc k) {s} (m₁ , p) (m₂ , q) c₁ c₂ | u | v =
cong suc (lem n k {tl s} (m₁ , {!!}) {!!} {!!} {!!})
-}
unique-conv : ∀{V} (s : Stream (T V)) (t₁ t₂ : T∞ V) →
s →∞ t₁ → s →∞ t₂ → t₁ ~ t₂
out~ (unique-conv s t₁ t₂ p q)
with hd s | out t₁ | out t₂ | conv-out p | conv-out q
out~ (unique-conv s t₁ t₂ p q)
| sup (inj₁ (._ , α)) | inj₁ (._ , β) | inj₁ (f , γ)
| refl , q₁ , ω₁ | refl , q₂ , ω₂
= refl
, (λ {i} → unique-conv (split (tl s) f q₁ i)
(β i)
(γ i)
(ω₁ i)
(subst (λ u → split (tl s) f u i →∞ γ i)
(RootsMatch-unique q₂ q₁)
(ω₂ i)))
out~ (unique-conv s t₁ t₂ p q)
| sup (inj₁ x) | inj₁ x₁ | inj₂ y | y₁ | ()
out~ (unique-conv s t₁ t₂ p q)
| sup (inj₁ x) | inj₂ y | x₁ | () | z
out~ (unique-conv s t₁ t₂ p q)
| sup (inj₂ v) | inj₁ (f , α) | inj₁ (g , β) | (n , mg , p₁) | (k , mf , q₁)
with s at n | s at k
out~ (unique-conv s t₁ t₂ p q)
| sup (inj₂ v) | inj₁ (f , α) | inj₁ (.g , β) | n , m₁ , p₁ | k , (refl , r₂) , q₁
| sup (inj₁ (f' , γ)) | sup (inj₁ (g , ρ)) =
(lem₁ n k s ({!m₁!} , {!!}) {!!} {!!} {!!}) , {!!}
out~ (unique-conv s t₁ t₂ p q)
| sup (inj₂ v) | inj₁ (f , α) | inj₁ (g , β) | n , mg , p₁ | k , (() , _) , q₁
| sup (inj₁ x) | sup (inj₂ y)
out~ (unique-conv s t₁ t₂ p q)
| sup (inj₂ v) | inj₁ (f , α) | inj₁ (g , β) | n , (() , _) , p₁ | k , mf , q₁
| sup (inj₂ y) | b
out~ (unique-conv s t₁ t₂ p q) | sup (inj₂ y) | inj₁ x | inj₂ y₁ | y₂ | z = {!!}
out~ (unique-conv s t₁ t₂ p q) | sup (inj₂ y) | inj₂ y₁ | x₁ | y₂ | z = {!!}
-}
-- | A non-trivial substitution is a substitution σ, such that, for all v ∈ V
-- we have that either σ(v) is a non-trivial term or if it is a variable w, then
-- w = v.
-- This allows us to stop substituting the first time we hit a variable.
NonTrivSubst : Set → Set
NonTrivSubst V = ⨿ (Subst V V) λ σ → (∀ v → isVar (σ v) → σ v ≡ η v)
term-seq-from-subst-seq : ∀{V} → Stream (NonTrivSubst V) → T V → Stream (T V)
hd (term-seq-from-subst-seq Δ t) = t
tl (term-seq-from-subst-seq Δ t) = term-seq-from-subst-seq (tl Δ) (app (proj₁ (hd Δ)) t)
∞term-from-subst-seq : ∀{V} → Stream (NonTrivSubst V) → T V → T∞ V
out (∞term-from-subst-seq Δ (sup (inj₁ (s , α)))) =
inj₁ (s , (λ i → ∞term-from-subst-seq Δ (α i)))
out (∞term-from-subst-seq Δ (sup (inj₂ v))) with proj₁ (hd Δ) v | proj₂ (hd Δ) v
... | sup (inj₁ (s , α)) | f =
inj₁ (s , (λ i → ∞term-from-subst-seq (tl Δ) (α i)))
... | sup (inj₂ v₁) | f with f tt
out (∞term-from-subst-seq Δ (sup (inj₂ v))) | sup (inj₂ .v) | f | refl =
inj₂ v
{-
∞term-from-subst-seq-converges :
∀{V} → (Δ : Stream (NonTrivSubst V)) → (t : T V) →
term-seq-from-subst-seq Δ t →∞ ∞term-from-subst-seq Δ t
hd-matches (∞term-from-subst-seq-converges Δ t) = (proj₁ (hd Δ) , refl)
hd-prefix (∞term-from-subst-seq-converges Δ t) = {!!}
tl-converges (∞term-from-subst-seq-converges Δ t) = {!∞term-from-subst-seq-converges!}
-}
|
{
"alphanum_fraction": 0.4903233024,
"avg_line_length": 35.6135458167,
"ext": "agda",
"hexsha": "0a05a292dc176f26a974a9de0dbcc44beac7f939",
"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": "LP2/Terms.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": "LP2/Terms.agda",
"max_line_length": 96,
"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": "LP2/Terms.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 8291,
"size": 17878
}
|
module Function.Axioms where
open import Lang.Instance
open import Logic.Predicate
open import Logic
import Lvl
import Structure.Function.Names as Names
open import Structure.Setoid
open import Type
private variable ℓₒ ℓₒ₁ ℓₒ₂ ℓₒ₃ ℓₗ ℓₗ₁ ℓₗ₂ ℓₗ₃ : Lvl.Level
module _
{A : Type{ℓₒ₁}}
{B : Type{ℓₒ₂}} ⦃ _ : Equiv{ℓₗ₂}(B) ⦄
⦃ _ : Equiv{ℓₗ₃}(A → B) ⦄
(f g : A → B)
where
record FunctionExtensionalityOn : Stmt{ℓₒ₁ Lvl.⊔ ℓₗ₂ Lvl.⊔ ℓₗ₃} where
constructor intro
field proof : Names.FunctionExtensionalityOn(f)(g)
functionExtensionalityOn = inst-fn FunctionExtensionalityOn.proof
record FunctionApplicationOn : Stmt{ℓₒ₁ Lvl.⊔ ℓₗ₂ Lvl.⊔ ℓₗ₃} where
constructor intro
field proof : Names.FunctionApplicationOn(f)(g)
functionApplicationOn = inst-fn FunctionApplicationOn.proof
module _ (A : Type{ℓₒ₁}) (B : Type{ℓₒ₂}) ⦃ _ : Equiv{ℓₗ₂}(B) ⦄ ⦃ _ : Equiv{ℓₗ₃}(A → B) ⦄ where
FunctionExtensionality : Stmt
FunctionExtensionality = ∀²(FunctionExtensionalityOn{ℓₒ₁}{ℓₒ₂}{ℓₗ₂}{ℓₗ₃}{A}{B})
functionExtensionality : ⦃ funcExt : FunctionExtensionality ⦄ → Names.FunctionExtensionality(A)(B)
functionExtensionality {f}{g} = functionExtensionalityOn f g
FunctionApplication : Stmt
FunctionApplication = ∀²(FunctionApplicationOn{ℓₒ₁}{ℓₒ₂}{ℓₗ₂}{ℓₗ₃}{A}{B})
functionApplication : ⦃ funcApp : FunctionApplication ⦄ → Names.FunctionApplication(A)(B)
functionApplication {f}{g} = functionApplicationOn f g
module _
{A : Type{ℓₒ₁}}
{B : A → Type{ℓₒ₂}} ⦃ _ : ∀{a} → Equiv{ℓₗ₂}(B(a)) ⦄
⦃ _ : Equiv{ℓₗ₃}((a : A) → B(a)) ⦄
(f g : ((a : A) → B(a)))
where
record DependentFunctionExtensionalityOn : Stmt{ℓₒ₁ Lvl.⊔ ℓₗ₂ Lvl.⊔ ℓₗ₃} where
constructor intro
field proof : Names.DependentFunctionExtensionalityOn(f)(g)
dependentFunctionExtensionalityOn = inst-fn DependentFunctionExtensionalityOn.proof
module _ (A : Type{ℓₒ₁}) (B : A → Type{ℓₒ₂}) ⦃ _ : ∀{a} → Equiv{ℓₗ₂}(B(a)) ⦄ ⦃ _ : Equiv{ℓₗ₃}((a : A) → B(a)) ⦄ where
DependentFunctionExtensionality : Stmt
DependentFunctionExtensionality = ∀²(DependentFunctionExtensionalityOn{ℓₒ₁}{ℓₒ₂}{ℓₗ₂}{ℓₗ₃}{A}{B})
dependentFunctionExtensionality : ⦃ depFuncExt : DependentFunctionExtensionality ⦄ → Names.DependentFunctionExtensionality(A)(B)
dependentFunctionExtensionality {f}{g} = dependentFunctionExtensionalityOn f g
module _
{A : Type{ℓₒ₁}}
{B : A → Type{ℓₒ₂}} ⦃ _ : ∀{a} → Equiv{ℓₗ₂}(B(a)) ⦄
⦃ _ : Equiv{ℓₗ₃}({a : A} → B(a)) ⦄
(f g : ({a : A} → B(a)))
where
record DependentImplicitFunctionExtensionalityOn : Stmt{ℓₒ₁ Lvl.⊔ ℓₗ₂ Lvl.⊔ ℓₗ₃} where
constructor intro
field proof : Names.DependentImplicitFunctionExtensionalityOn(f)(g)
dependentImplicitFunctionExtensionalityOn = inst-fn DependentImplicitFunctionExtensionalityOn.proof
module _ (A : Type{ℓₒ₁}) (B : A → Type{ℓₒ₂}) ⦃ _ : ∀{a} → Equiv{ℓₗ₂}(B(a)) ⦄ ⦃ _ : Equiv{ℓₗ₃}({a : A} → B(a)) ⦄ where
DependentImplicitFunctionExtensionality : Stmt
DependentImplicitFunctionExtensionality = ∀²(DependentImplicitFunctionExtensionalityOn{ℓₒ₁}{ℓₒ₂}{ℓₗ₂}{ℓₗ₃}{A}{B})
dependentImplicitFunctionExtensionality : ⦃ depFuncExt : DependentImplicitFunctionExtensionality ⦄ → Names.DependentImplicitFunctionExtensionality(A)(B)
dependentImplicitFunctionExtensionality {f}{g} = dependentImplicitFunctionExtensionalityOn f g
module _
{A : Type{ℓₒ₁}}
{B : A → Type{ℓₒ₂}} ⦃ _ : ∀{a} → Equiv{ℓₗ₂}(B(a)) ⦄
⦃ _ : Equiv{ℓₗ₃}(⦃ a : A ⦄ → B(a)) ⦄
(f g : (⦃ a : A ⦄ → B(a)))
where
record DependentInstanceFunctionExtensionalityOn : Stmt{ℓₒ₁ Lvl.⊔ ℓₗ₂ Lvl.⊔ ℓₗ₃} where
constructor intro
field proof : Names.DependentInstanceFunctionExtensionalityOn(f)(g)
dependentInstanceFunctionExtensionalityOn = inst-fn DependentInstanceFunctionExtensionalityOn.proof
module _ (A : Type{ℓₒ₁}) (B : A → Type{ℓₒ₂}) ⦃ _ : ∀{a} → Equiv{ℓₗ₂}(B(a)) ⦄ ⦃ _ : Equiv{ℓₗ₃}(⦃ a : A ⦄ → B(a)) ⦄ where
DependentInstanceFunctionExtensionality : Stmt
DependentInstanceFunctionExtensionality = ∀²(DependentInstanceFunctionExtensionalityOn{ℓₒ₁}{ℓₒ₂}{ℓₗ₂}{ℓₗ₃}{A}{B})
dependentInstanceFunctionExtensionality : ⦃ depFuncExt : DependentInstanceFunctionExtensionality ⦄ → Names.DependentInstanceFunctionExtensionality(A)(B)
dependentInstanceFunctionExtensionality {f}{g} = dependentInstanceFunctionExtensionalityOn f g
|
{
"alphanum_fraction": 0.7197571228,
"avg_line_length": 45.0736842105,
"ext": "agda",
"hexsha": "f8dcf08830059442ed61dfa2c5f3752b61d5a0b4",
"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": "Function/Axioms.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": "Function/Axioms.agda",
"max_line_length": 154,
"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": "Function/Axioms.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": 1697,
"size": 4282
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Various forms of induction for natural numbers
------------------------------------------------------------------------
module Induction.Nat where
open import Function
open import Data.Nat
open import Data.Fin using (_≺_)
open import Data.Fin.Properties
open import Data.Product
open import Data.Unit
open import Induction
open import Induction.WellFounded as WF
open import Level using (Lift)
open import Relation.Binary.PropositionalEquality
open import Relation.Unary
------------------------------------------------------------------------
-- Ordinary induction
Rec : ∀ ℓ → RecStruct ℕ ℓ ℓ
Rec _ P zero = Lift ⊤
Rec _ P (suc n) = P n
rec-builder : ∀ {ℓ} → RecursorBuilder (Rec ℓ)
rec-builder P f zero = _
rec-builder P f (suc n) = f n (rec-builder P f n)
rec : ∀ {ℓ} → Recursor (Rec ℓ)
rec = build rec-builder
------------------------------------------------------------------------
-- Complete induction
CRec : ∀ ℓ → RecStruct ℕ ℓ ℓ
CRec _ P zero = Lift ⊤
CRec _ P (suc n) = P n × CRec _ P n
cRec-builder : ∀ {ℓ} → RecursorBuilder (CRec ℓ)
cRec-builder P f zero = _
cRec-builder P f (suc n) = f n ih , ih
where ih = cRec-builder P f n
cRec : ∀ {ℓ} → Recursor (CRec ℓ)
cRec = build cRec-builder
------------------------------------------------------------------------
-- Complete induction based on _<′_
<-Rec : ∀ {ℓ} → RecStruct ℕ ℓ ℓ
<-Rec = WfRec _<′_
mutual
<-well-founded : Well-founded _<′_
<-well-founded n = acc (<-well-founded′ n)
<-well-founded′ : ∀ n → <-Rec (Acc _<′_) n
<-well-founded′ zero _ ()
<-well-founded′ (suc n) .n ≤′-refl = <-well-founded n
<-well-founded′ (suc n) m (≤′-step m<n) = <-well-founded′ n m m<n
module _ {ℓ} where
open WF.All <-well-founded ℓ public
renaming ( wfRec-builder to <-rec-builder
; wfRec to <-rec
)
------------------------------------------------------------------------
-- Complete induction based on _≺_
≺-Rec : ∀ {ℓ} → RecStruct ℕ ℓ ℓ
≺-Rec = WfRec _≺_
≺-well-founded : Well-founded _≺_
≺-well-founded = Subrelation.well-founded ≺⇒<′ <-well-founded
module _ {ℓ} where
open WF.All ≺-well-founded ℓ public
renaming ( wfRec-builder to ≺-rec-builder
; wfRec to ≺-rec
)
------------------------------------------------------------------------
-- Examples
private
module Examples where
-- Doubles its input.
twice : ℕ → ℕ
twice = rec _ λ
{ zero _ → zero
; (suc n) twice-n → suc (suc twice-n)
}
-- Halves its input (rounding downwards).
--
-- The step function is mentioned in a proof below, so it has been
-- given a name. (The mutual keyword is used to avoid having to give
-- a type signature for the step function.)
mutual
half₁-step = λ
{ zero _ → zero
; (suc zero) _ → zero
; (suc (suc n)) (_ , half₁n , _) → suc half₁n
}
half₁ : ℕ → ℕ
half₁ = cRec _ half₁-step
-- An alternative implementation of half₁.
mutual
half₂-step = λ
{ zero _ → zero
; (suc zero) _ → zero
; (suc (suc n)) rec → suc (rec n (≤′-step ≤′-refl))
}
half₂ : ℕ → ℕ
half₂ = <-rec _ half₂-step
-- The application half₁ (2 + n) is definitionally equal to
-- 1 + half₁ n. Perhaps it is instructive to see why.
half₁-2+ : ∀ n → half₁ (2 + n) ≡ 1 + half₁ n
half₁-2+ n = begin
half₁ (2 + n) ≡⟨⟩
cRec (λ _ → ℕ) half₁-step (2 + n) ≡⟨⟩
half₁-step (2 + n) (cRec-builder (λ _ → ℕ) half₁-step (2 + n)) ≡⟨⟩
half₁-step (2 + n)
(let ih = cRec-builder (λ _ → ℕ) half₁-step (1 + n) in
half₁-step (1 + n) ih , ih) ≡⟨⟩
half₁-step (2 + n)
(let ih = cRec-builder (λ _ → ℕ) half₁-step n in
half₁-step (1 + n) (half₁-step n ih , ih) , half₁-step n ih , ih) ≡⟨⟩
1 + half₁-step n (cRec-builder (λ _ → ℕ) half₁-step n) ≡⟨⟩
1 + cRec (λ _ → ℕ) half₁-step n ≡⟨⟩
1 + half₁ n ∎
where open ≡-Reasoning
-- The application half₂ (2 + n) is definitionally equal to
-- 1 + half₂ n. Perhaps it is instructive to see why.
half₂-2+ : ∀ n → half₂ (2 + n) ≡ 1 + half₂ n
half₂-2+ n = begin
half₂ (2 + n) ≡⟨⟩
<-rec (λ _ → ℕ) half₂-step (2 + n) ≡⟨⟩
half₂-step (2 + n) (<-rec-builder (λ _ → ℕ) half₂-step (2 + n)) ≡⟨⟩
1 + <-rec-builder (λ _ → ℕ) half₂-step (2 + n) n (≤′-step ≤′-refl) ≡⟨⟩
1 + Some.wfRec-builder (λ _ → ℕ) half₂-step (2 + n)
(<-well-founded (2 + n)) n (≤′-step ≤′-refl) ≡⟨⟩
1 + Some.wfRec-builder (λ _ → ℕ) half₂-step (2 + n)
(acc (<-well-founded′ (2 + n))) n (≤′-step ≤′-refl) ≡⟨⟩
1 + half₂-step n
(Some.wfRec-builder (λ _ → ℕ) half₂-step n
(<-well-founded′ (2 + n) n (≤′-step ≤′-refl))) ≡⟨⟩
1 + half₂-step n
(Some.wfRec-builder (λ _ → ℕ) half₂-step n
(<-well-founded′ (1 + n) n ≤′-refl)) ≡⟨⟩
1 + half₂-step n
(Some.wfRec-builder (λ _ → ℕ) half₂-step n (<-well-founded n)) ≡⟨⟩
1 + half₂-step n (<-rec-builder (λ _ → ℕ) half₂-step n) ≡⟨⟩
1 + <-rec (λ _ → ℕ) half₂-step n ≡⟨⟩
1 + half₂ n ∎
where open ≡-Reasoning
-- Some properties that the functions above satisfy, proved using
-- cRec.
half₁-+₁ : ∀ n → half₁ (twice n) ≡ n
half₁-+₁ = cRec _ λ
{ zero _ → refl
; (suc zero) _ → refl
; (suc (suc n)) (_ , half₁twice-n≡n , _) →
cong (suc ∘ suc) half₁twice-n≡n
}
half₂-+₁ : ∀ n → half₂ (twice n) ≡ n
half₂-+₁ = cRec _ λ
{ zero _ → refl
; (suc zero) _ → refl
; (suc (suc n)) (_ , half₁twice-n≡n , _) →
cong (suc ∘ suc) half₁twice-n≡n
}
-- Some properties that the functions above satisfy, proved using
-- <-rec.
half₁-+₂ : ∀ n → half₁ (twice n) ≡ n
half₁-+₂ = <-rec _ λ
{ zero _ → refl
; (suc zero) _ → refl
; (suc (suc n)) rec →
cong (suc ∘ suc) (rec n (≤′-step ≤′-refl))
}
half₂-+₂ : ∀ n → half₂ (twice n) ≡ n
half₂-+₂ = <-rec _ λ
{ zero _ → refl
; (suc zero) _ → refl
; (suc (suc n)) rec →
cong (suc ∘ suc) (rec n (≤′-step ≤′-refl))
}
|
{
"alphanum_fraction": 0.4532363636,
"avg_line_length": 29.1313559322,
"ext": "agda",
"hexsha": "23a61b4d73d21797d0810d01a954e4c9ebebc138",
"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/Induction/Nat.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/Induction/Nat.agda",
"max_line_length": 77,
"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/Induction/Nat.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": 2220,
"size": 6875
}
|
module AuxDefs where
data ℕ : Set where
zero : ℕ
suc : ℕ → ℕ
_+_ : ℕ → ℕ → ℕ
zero + n = n
(suc m) + n = suc (m + n)
data Bool : Set where
true : Bool
false : Bool
data Comparison : Set where
less : Comparison
equal : Comparison
greater : Comparison
_<_ : ℕ → ℕ → Bool
zero < y = true
suc x < zero = false
suc x < suc y = x < y
|
{
"alphanum_fraction": 0.553133515,
"avg_line_length": 14.68,
"ext": "agda",
"hexsha": "6ad9299a4bf0576e7439cbcb515b61cf0e2ca4e0",
"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": "75bef9bb35643160e2d2ab4221a3057f22eb3324",
"max_forks_repo_licenses": [
"CC-BY-4.0"
],
"max_forks_repo_name": "abolotina/plfa.github.io",
"max_forks_repo_path": "src/plfa/part1/AuxDefs.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "75bef9bb35643160e2d2ab4221a3057f22eb3324",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"CC-BY-4.0"
],
"max_issues_repo_name": "abolotina/plfa.github.io",
"max_issues_repo_path": "src/plfa/part1/AuxDefs.agda",
"max_line_length": 27,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "75bef9bb35643160e2d2ab4221a3057f22eb3324",
"max_stars_repo_licenses": [
"CC-BY-4.0"
],
"max_stars_repo_name": "abolotina/plfa.github.io",
"max_stars_repo_path": "src/plfa/part1/AuxDefs.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 133,
"size": 367
}
|
module Splitting where
open import Basics
open import All
data _<[_]>_ {X : Set} : List X -> List X -> List X -> Set where
sz : [] <[ [] ]> []
sl : forall {l ls ms rs} -> ls <[ ms ]> rs -> (l ,- ls) <[ l ,- ms ]> rs
sr : forall {r ls ms rs} -> ls <[ ms ]> rs -> ls <[ r ,- ms ]> (r ,- rs)
riffle : {X : Set}{ls ms rs : List X} -> ls <[ ms ]> rs ->
{P : X -> Set} -> All P ls -> All P rs -> All P ms
riffle sz <> <> = <>
riffle (sl x) (p , lp) rp = p , riffle x lp rp
riffle (sr x) lp (p , rp) = p , riffle x lp rp
srs : forall {X : Set}(xs : List X) -> [] <[ xs ]> xs
srs [] = sz
srs (x ,- xs) = sr (srs xs)
data SRS {X : Set}(ms : List X) : (xs : List X) -> [] <[ ms ]> xs -> Set where
mkSRS : SRS ms ms (srs ms)
isSRS : {X : Set}{ms xs : List X}(i : [] <[ ms ]> xs) -> SRS ms xs i
isSRS sz = mkSRS
isSRS (sr i) with isSRS i
isSRS (sr .(srs _)) | mkSRS = mkSRS
slrs : forall {X : Set}(xs ys : List X) -> xs <[ xs +L ys ]> ys
slrs [] ys = srs ys
slrs (x ,- xs) ys = sl (slrs xs ys)
cat : forall {X}{P : X -> Set}(xs ys : List X) -> All P xs -> All P ys -> All P (xs +L ys)
cat xs ys ps qs = riffle (slrs xs ys) ps qs
data IsRiffle {X : Set}{ls ms rs : List X}(i : ls <[ ms ]> rs){P : X -> Set}
: All P ms -> Set where
mkRiffle : (lp : All P ls)(rp : All P rs) -> IsRiffle i (riffle i lp rp)
isRiffle : {X : Set}{ls ms rs : List X}(i : ls <[ ms ]> rs){P : X -> Set}(mp : All P ms) -> IsRiffle i mp
isRiffle sz <> = mkRiffle <> <>
isRiffle (sl i) (p , mp) with isRiffle i mp
isRiffle (sl i) (p , .(riffle i lp rp)) | mkRiffle lp rp = mkRiffle (p , lp) rp
isRiffle (sr i) (p , mp) with isRiffle i mp
isRiffle (sr i) (p , .(riffle i lp rp)) | mkRiffle lp rp = mkRiffle lp (p , rp)
mirror : {X : Set}{ls ms rs : List X} -> ls <[ ms ]> rs -> rs <[ ms ]> ls
mirror sz = sz
mirror (sl x) = sr (mirror x)
mirror (sr x) = sl (mirror x)
rotatel : {X : Set}{ls ms rs lrs rrs : List X} -> ls <[ ms ]> rs -> lrs <[ rs ]> rrs ->
Sg (List X) \ ns -> (ls <[ ns ]> lrs) * (ns <[ ms ]> rrs)
rotatel sz sz = [] , sz , sz
rotatel (sl x) y with rotatel x y
... | _ , a , b = _ , sl a , sl b
rotatel (sr x) (sl y) with rotatel x y
... | _ , a , b = _ , sr a , sl b
rotatel (sr x) (sr y) with rotatel x y
... | _ , a , b = _ , a , sr b
rotater : {X : Set}{lls rls ls ms rs : List X} -> lls <[ ls ]> rls -> ls <[ ms ]> rs ->
Sg (List X) \ ns -> (lls <[ ms ]> ns) * (rls <[ ns ]> rs)
rotater x y with rotatel (mirror y) (mirror x)
... | _ , a , b = _ , mirror b , mirror a
llswap : {X : Set}{ls ms lrs rrs : List X} ->
(Sg (List X) \ rs -> (ls <[ ms ]> rs) * (lrs <[ rs ]> rrs)) ->
Sg (List X) \ ns -> (lrs <[ ms ]> ns) * (ls <[ ns ]> rrs)
llswap (_ , x , y) with rotatel x y
... | _ , a , b = rotater (mirror a) b
insS : {X : Set}(xs : List X)(y : X)(zs : List X) -> (y ,- []) <[ (xs +L y ,- zs) ]> (xs +L zs)
insS [] y zs = sl (srs zs)
insS (x ,- xs) y zs = sr (insS xs y zs)
catS : forall {X}{as abs bs cs cds ds : List X} ->
as <[ abs ]> bs -> cs <[ cds ]> ds ->
(as +L cs) <[ (abs +L cds) ]> (bs +L ds)
catS sz y = y
catS (sl x) y = sl (catS x y)
catS (sr x) y = sr (catS x y)
splimap : forall {X Y}(f : X -> Y){xs xys ys} -> xs <[ xys ]> ys ->
list f xs <[ list f xys ]> list f ys
splimap f sz = sz
splimap f (sl s) = sl (splimap f s)
splimap f (sr s) = sr (splimap f s)
|
{
"alphanum_fraction": 0.5001503759,
"avg_line_length": 37.3595505618,
"ext": "agda",
"hexsha": "be7243178e2eca7562634d8782bce01914486d4c",
"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": "454cdd18f56db0b0d1643a1fcf36951b5ece395c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "pigworker/InteriorDesign",
"max_forks_repo_path": "Splitting.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "454cdd18f56db0b0d1643a1fcf36951b5ece395c",
"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": "pigworker/InteriorDesign",
"max_issues_repo_path": "Splitting.agda",
"max_line_length": 105,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "454cdd18f56db0b0d1643a1fcf36951b5ece395c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "pigworker/InteriorDesign",
"max_stars_repo_path": "Splitting.agda",
"max_stars_repo_stars_event_max_datetime": "2018-07-31T02:00:13.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-06-18T15:25:39.000Z",
"num_tokens": 1426,
"size": 3325
}
|
{-# OPTIONS --cubical --safe #-}
module Function.Injective where
open import Function.Injective.Base public
|
{
"alphanum_fraction": 0.7545454545,
"avg_line_length": 18.3333333333,
"ext": "agda",
"hexsha": "4088eaf731d015624bb9938f751cb68d5529313c",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z",
"max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/combinatorics-paper",
"max_forks_repo_path": "agda/Function/Injective.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"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/combinatorics-paper",
"max_issues_repo_path": "agda/Function/Injective.agda",
"max_line_length": 42,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/combinatorics-paper",
"max_stars_repo_path": "agda/Function/Injective.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": 23,
"size": 110
}
|
module Open where
open import bool
open import nat
open import product
open import sum
open import functor
data Row : Set₁ where
Empty : Row
Ty : Set → Row
Prod : Row → Row → Row
infixr 19 _♯_
_′ = Ty
_♯_ = Prod
all : Row → Set
all Empty = ⊤
all (Ty x) = x
all (Prod r₁ r₂) = (all r₁) × (all r₂)
one : Row → Set
one Empty = ⊥
one (Ty x) = x
one (Prod r₁ r₂) = (one r₁) ⊎ (one r₂)
_⊗_ : {A B : Row} → all A → all B → all (A ♯ B)
_⊗_ p₁ p₂ = p₁ , p₂
_&_ : {A : Set}{B : Row} → A → all B → all (A ′ ♯ B)
_&_ {A}{B} = _⊗_ {A ′}{B}
_⊕_ : {A B : Row} → (one A) ⊎ (one B) → one (A ♯ B)
_⊕_ p = p
⊕inj₁ : {A B : Row} → one A → one (A ♯ B)
⊕inj₁ = inj₁
⊕inj₂ : {A B : Row} → one B → one (A ♯ B)
⊕inj₂ = inj₂
inj : {A : Set}{B : Row} → A → one (A ′ ♯ B)
inj {A}{B} = ⊕inj₁ {A ′}{B}
test₁ : all (ℕ ′ ♯ 𝔹 ′ ♯ Empty)
test₁ = _&_ {ℕ}{𝔹 ′ ♯ Empty} 1 (_&_ {𝔹}{Empty} tt triv)
|
{
"alphanum_fraction": 0.5090702948,
"avg_line_length": 18.375,
"ext": "agda",
"hexsha": "3ea25ffb1e35ebb182ec750121f61e3f500d1dba",
"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": "open.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": "open.agda",
"max_line_length": 55,
"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": "open.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 449,
"size": 882
}
|
-- Andreas, 2017-08-24, issue #2717, reported by m0davis
--
-- Internal error in DisplayForm.hs triggered by -v 100.
-- Regression introduced by #2590
{-# OPTIONS -v tc.display.top:100 -v tc.polarity.dep:20 #-} -- KEEP
module _ (A : Set) where
module M (_ : Set) where
data D (n : Set) : Set where
d : D n
open M A
|
{
"alphanum_fraction": 0.6492307692,
"avg_line_length": 21.6666666667,
"ext": "agda",
"hexsha": "b81145a7bc019ff469d39e2571a2a1a8823f3896",
"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/Issue2717.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/Issue2717.agda",
"max_line_length": 67,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/Issue2717.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": 107,
"size": 325
}
|
{-# OPTIONS --cubical --safe #-}
module Path.Reasoning where
open import Prelude
infixr 2 ≡˘⟨⟩-syntax _≡⟨⟩_ ≡⟨∙⟩-syntax
≡˘⟨⟩-syntax : ∀ (x : A) {y z} → y ≡ z → y ≡ x → x ≡ z
≡˘⟨⟩-syntax _ y≡z y≡x = sym y≡x ; y≡z
syntax ≡˘⟨⟩-syntax x y≡z y≡x = x ≡˘⟨ y≡x ⟩ y≡z
≡⟨∙⟩-syntax : ∀ (x : A) {y z} → y ≡ z → x ≡ y → x ≡ z
≡⟨∙⟩-syntax _ y≡z x≡y = x≡y ; y≡z
syntax ≡⟨∙⟩-syntax x y≡z x≡y = x ≡⟨ x≡y ⟩ y≡z
_≡⟨⟩_ : ∀ (x : A) {y} → x ≡ y → x ≡ y
_ ≡⟨⟩ x≡y = x≡y
infix 2.5 _∎
_∎ : ∀ {A : Type a} (x : A) → x ≡ x
_∎ x = refl
|
{
"alphanum_fraction": 0.4410058027,
"avg_line_length": 20.68,
"ext": "agda",
"hexsha": "7c122044cd7e023fc76b55c74e382d1d40d100ec",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z",
"max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/combinatorics-paper",
"max_forks_repo_path": "agda/Path/Reasoning.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"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/combinatorics-paper",
"max_issues_repo_path": "agda/Path/Reasoning.agda",
"max_line_length": 53,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/combinatorics-paper",
"max_stars_repo_path": "agda/Path/Reasoning.agda",
"max_stars_repo_stars_event_max_datetime": "2021-01-05T15:32:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-01-05T14:07:44.000Z",
"num_tokens": 343,
"size": 517
}
|
module Generic.Lib.Reflection.Fold where
open import Generic.Lib.Intro
open import Generic.Lib.Decidable
open import Generic.Lib.Category
open import Generic.Lib.Data.Nat
open import Generic.Lib.Data.String
open import Generic.Lib.Data.Maybe
open import Generic.Lib.Data.List
open import Generic.Lib.Reflection.Core
foldTypeOf : Data Type -> Type
foldTypeOf (packData d a b cs ns) = appendType iab ∘ pi "π" π ∘ pi "P" P $ cs ʰ→ from ‵→ to where
infixr 5 _ʰ→_
i = countPis a
j = countPis b
ab = appendType a b
iab = implicitize ab
π = implRelArg (quoteTerm Level)
P = explRelArg ∘ appendType (shiftBy (suc j) b) ∘ agda-sort ∘ set $ pureVar j
hyp = mapName (λ p -> appVar p ∘ drop i) d ∘ shiftBy (2 + j)
_ʰ→_ = flip $ foldr (λ c r -> hyp c ‵→ shift r)
from = appDef d (pisToArgVars (2 + i + j) ab)
to = appVar 1 (pisToArgVars (3 + j) b)
foldClausesOf : Name -> Data Type -> List Clause
foldClausesOf f (packData d a b cs ns) = allToList $ mapAllInd (λ {a} n -> clauseOf n a) ns where
k = length cs
clauseOf : ℕ -> Type -> Name -> Clause
clauseOf i c n = clause lhs rhs where
args = explPisToNames c
j = length args
lhs = patVars ("P" ∷ unmap (λ n -> "f" ++ˢ showName n) ns)
∷ʳ explRelArg (patCon n (patVars args))
tryHyp : ℕ -> ℕ -> Type -> Maybe Term
tryHyp m l (explPi r s a b) = explLam s <$> tryHyp (suc m) l b
tryHyp m l (pi s a b) = tryHyp m l b
tryHyp m l (appDef e _) = d == e ?> vis appDef f (pars ∷ʳ rarg) where
pars = map (λ i -> pureVar (m + i)) $ downFromTo (suc k + j) j
rarg = vis appVar (m + l) $ map pureVar (downFrom m)
tryHyp m l b = nothing
hyps : ℕ -> Type -> List Term
hyps (suc l) (explPi r s a b) = fromMaybe (pureVar l) (tryHyp 0 l a) ∷ hyps l b
hyps l (pi s a b) = hyps l b
hyps l b = []
rhs = vis appVar (k + j ∸ suc i) (hyps j c)
-- i = 1: f
-- j = 3: x t r
-- k = 2: g f
-- 5 4 3 2 1 0 3 2 4 3 1 1 0 6 5 2 1 0
-- fold P g f (cons x t r) = f x (fold g f t) (λ y u -> fold g f (r y u))
defineFold : Name -> Data Type -> TC _
defineFold f D =
declareDef (explRelArg f) (foldTypeOf D) >>
defineFun f (foldClausesOf f D)
deriveFold : Name -> Data Type -> TC Name
deriveFold d D =
freshName ("fold" ++ˢ showName d) >>= λ f ->
f <$ defineFold f D
deriveFoldTo : Name -> Name -> TC _
deriveFoldTo f = getData >=> defineFold f
|
{
"alphanum_fraction": 0.5836669335,
"avg_line_length": 35.6857142857,
"ext": "agda",
"hexsha": "60b89eae85a52f3b381c11d3c9a5e6f1dea6fc8f",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2021-01-27T12:57:09.000Z",
"max_forks_repo_forks_event_min_datetime": "2017-07-17T07:23:39.000Z",
"max_forks_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "turion/Generic",
"max_forks_repo_path": "src/Generic/Lib/Reflection/Fold.agda",
"max_issues_count": 9,
"max_issues_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe",
"max_issues_repo_issues_event_max_datetime": "2022-01-04T15:43:14.000Z",
"max_issues_repo_issues_event_min_datetime": "2017-04-06T18:58:09.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "turion/Generic",
"max_issues_repo_path": "src/Generic/Lib/Reflection/Fold.agda",
"max_line_length": 97,
"max_stars_count": 30,
"max_stars_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "turion/Generic",
"max_stars_repo_path": "src/Generic/Lib/Reflection/Fold.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T10:19:38.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-07-19T21:10:54.000Z",
"num_tokens": 920,
"size": 2498
}
|
module MacroNotToTerm where
open import Common.Reflection
open import Common.Prelude
data X : Set where
macro
f : Term -> Set
f x _ = X
|
{
"alphanum_fraction": 0.7222222222,
"avg_line_length": 12,
"ext": "agda",
"hexsha": "c38d5c1a1489ed9b790f08b2ca74640d186c8e6b",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "redfish64/autonomic-agda",
"max_forks_repo_path": "test/Fail/MacroNotToTerm.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "redfish64/autonomic-agda",
"max_issues_repo_path": "test/Fail/MacroNotToTerm.agda",
"max_line_length": 29,
"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/Fail/MacroNotToTerm.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 40,
"size": 144
}
|
{-# OPTIONS --sized-types #-}
module SOList.Total {A : Set}(_≤_ : A → A → Set) where
open import Bound.Total A
open import Bound.Total.Order _≤_
open import Data.List
open import Size
data SOList : {ι : Size} → Bound → Bound → Set where
onil : {ι : Size}{b t : Bound}
→ LeB b t
→ SOList {↑ ι} b t
ocons : {ι : Size}{b t : Bound}(x : A)
→ SOList {ι} b (val x)
→ SOList {ι} (val x) t
→ SOList {↑ ι} b t
forget : {b t : Bound} → SOList b t → List A
forget (onil _) = []
forget (ocons x xs ys) = forget xs ++ (x ∷ forget ys)
|
{
"alphanum_fraction": 0.4968454259,
"avg_line_length": 25.36,
"ext": "agda",
"hexsha": "09691153bb472cf169d0795740592e8c2e2017f1",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bgbianchi/sorting",
"max_forks_repo_path": "agda/SOList/Total.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "bgbianchi/sorting",
"max_issues_repo_path": "agda/SOList/Total.agda",
"max_line_length": 55,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bgbianchi/sorting",
"max_stars_repo_path": "agda/SOList/Total.agda",
"max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z",
"num_tokens": 206,
"size": 634
}
|
{-# OPTIONS --without-K --safe #-}
open import Definition.Typed.EqualityRelation
module Definition.LogicalRelation.Substitution.Introductions.Nat {{eqrel : EqRelSet}} where
open EqRelSet {{...}}
open import Definition.Untyped
open import Definition.Typed
open import Definition.Typed.Properties
open import Definition.LogicalRelation
open import Definition.LogicalRelation.Properties
open import Definition.LogicalRelation.Substitution
open import Definition.LogicalRelation.Substitution.Introductions.Universe
open import Tools.Embedding
open import Tools.Product
-- Validity of the natural number type.
ℕᵛ : ∀ {Γ l} ([Γ] : ⊩ᵛ Γ) → Γ ⊩ᵛ⟨ l ⟩ ℕ / [Γ]
ℕᵛ [Γ] ⊢Δ [σ] = ℕᵣ (idRed:*: (ℕⱼ ⊢Δ)) , λ _ x₂ → ιx (ℕ₌ (id (ℕⱼ ⊢Δ)))
-- Validity of the natural number type as a term.
ℕᵗᵛ : ∀ {Γ} ([Γ] : ⊩ᵛ Γ)
→ Γ ⊩ᵛ⟨ ¹ ⟩ ℕ ∷ U / [Γ] / Uᵛ [Γ]
ℕᵗᵛ [Γ] ⊢Δ [σ] = let ⊢ℕ = ℕⱼ ⊢Δ
[ℕ] = ℕᵣ (idRed:*: (ℕⱼ ⊢Δ))
in Uₜ ℕ (idRedTerm:*: ⊢ℕ) ℕₙ (≅ₜ-ℕrefl ⊢Δ) [ℕ]
, (λ x x₁ → Uₜ₌ ℕ ℕ (idRedTerm:*: ⊢ℕ) (idRedTerm:*: ⊢ℕ) ℕₙ ℕₙ
(≅ₜ-ℕrefl ⊢Δ) [ℕ] [ℕ] (ιx (ℕ₌ (id (ℕⱼ ⊢Δ)))))
-- Validity of zero.
zeroᵛ : ∀ {Γ l} ([Γ] : ⊩ᵛ Γ)
→ Γ ⊩ᵛ⟨ l ⟩ zero ∷ ℕ / [Γ] / ℕᵛ [Γ]
zeroᵛ [Γ] ⊢Δ [σ] =
ιx (ℕₜ zero (idRedTerm:*: (zeroⱼ ⊢Δ)) (≅ₜ-zerorefl ⊢Δ) zeroᵣ)
, (λ _ x₁ → ιx (ℕₜ₌ zero zero (idRedTerm:*: (zeroⱼ ⊢Δ)) (idRedTerm:*: (zeroⱼ ⊢Δ))
(≅ₜ-zerorefl ⊢Δ) zeroᵣ))
-- Validity of successor of valid natural numbers.
sucᵛ : ∀ {Γ n l} ([Γ] : ⊩ᵛ Γ)
([ℕ] : Γ ⊩ᵛ⟨ l ⟩ ℕ / [Γ])
→ Γ ⊩ᵛ⟨ l ⟩ n ∷ ℕ / [Γ] / [ℕ]
→ Γ ⊩ᵛ⟨ l ⟩ suc n ∷ ℕ / [Γ] / [ℕ]
sucᵛ ⊢Γ [ℕ] [n] ⊢Δ [σ] =
sucTerm (proj₁ ([ℕ] ⊢Δ [σ])) (proj₁ ([n] ⊢Δ [σ]))
, (λ x x₁ → sucEqTerm (proj₁ ([ℕ] ⊢Δ [σ])) (proj₂ ([n] ⊢Δ [σ]) x x₁))
|
{
"alphanum_fraction": 0.543986637,
"avg_line_length": 36.6530612245,
"ext": "agda",
"hexsha": "9e1395b280783ac9b2496696285b2c579e12a562",
"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": "2251b8da423be0c6fb916f2675d7bd8537e4cd96",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "loic-p/logrel-mltt",
"max_forks_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Nat.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96",
"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": "loic-p/logrel-mltt",
"max_issues_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Nat.agda",
"max_line_length": 91,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "loic-p/logrel-mltt",
"max_stars_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Nat.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 892,
"size": 1796
}
|
{-# OPTIONS --without-K --safe #-}
module Cats.Category.Sets.Facts.Initial where
open import Data.Empty using (⊥ ; ⊥-elim)
open import Level using (Lift ; lift ; lower)
open import Cats.Category
open import Cats.Category.Sets using (Sets)
instance
hasInitial : ∀ {l} → HasInitial (Sets l)
hasInitial = record
{ ⊥ = Lift _ ⊥
; isInitial = λ X → record
{ arr = λ()
; unique = λ { _ () }
}
}
|
{
"alphanum_fraction": 0.6088992974,
"avg_line_length": 21.35,
"ext": "agda",
"hexsha": "55a83ebebf1635284de17774a3f625feedc06d92",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-18T15:35:07.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-18T15:35:07.000Z",
"max_forks_repo_head_hexsha": "1ad7b243acb622d46731e9ae7029408db6e561f1",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "JLimperg/cats",
"max_forks_repo_path": "Cats/Category/Sets/Facts/Initial.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "1ad7b243acb622d46731e9ae7029408db6e561f1",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "JLimperg/cats",
"max_issues_repo_path": "Cats/Category/Sets/Facts/Initial.agda",
"max_line_length": 45,
"max_stars_count": 24,
"max_stars_repo_head_hexsha": "1ad7b243acb622d46731e9ae7029408db6e561f1",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "JLimperg/cats",
"max_stars_repo_path": "Cats/Category/Sets/Facts/Initial.agda",
"max_stars_repo_stars_event_max_datetime": "2021-08-06T05:00:46.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-11-03T15:18:57.000Z",
"num_tokens": 122,
"size": 427
}
|
{-# OPTIONS --without-K --exact-split #-}
module 02-natural-numbers where
import 00-preamble
open 00-preamble public
-- Definition 2.2.3
id : {i : Level} {A : UU i} → A → A
id a = a
-- Definition 2.2.4
_∘_ :
{i j k : Level} {A : UU i} {B : UU j} {C : UU k} →
(B → C) → ((A → B) → (A → C))
(g ∘ f) a = g (f a)
data ℕ : UU lzero where
zero-ℕ : ℕ
succ-ℕ : ℕ → ℕ
one-ℕ : ℕ
one-ℕ = succ-ℕ zero-ℕ
-- induction: for any dependent type P over ℕ, define a section of P
-- built out of a term in P 0 and a section of P n → P(Nsucc n)
ind-ℕ : {i : Level} {P : ℕ → UU i} → P zero-ℕ → ((n : ℕ) → P n → P(succ-ℕ n)) → ((n : ℕ) → P n)
ind-ℕ p0 pS zero-ℕ = p0
ind-ℕ p0 pS (succ-ℕ n) = pS n (ind-ℕ p0 pS n)
-- use the general induction principle to define addition
-- in this case P is ℕ, the special non-dependent type over ℕ, and
-- so sections of P (dependent functions Π_{x:ℕ} P(x)) are functions ℕ → ℕ
add-ℕ : ℕ → ℕ → ℕ
add-ℕ zero-ℕ y = y
add-ℕ (succ-ℕ x) y = succ-ℕ (add-ℕ x y)
-- Exercise 2.2
const : {i j : Level} (A : UU i) (B : UU j) (b : B) → A → B
const A B b x = b
-- Exercise 2.3
-- In this exercise we are asked to construct some standard functions on the
-- natural numbers.
-- Exercise 2.3(a)
max-ℕ : ℕ → (ℕ → ℕ)
max-ℕ zero-ℕ n = n
max-ℕ (succ-ℕ m) zero-ℕ = succ-ℕ m
max-ℕ (succ-ℕ m) (succ-ℕ n) = succ-ℕ (max-ℕ m n)
min-ℕ : ℕ → (ℕ → ℕ)
min-ℕ zero-ℕ n = zero-ℕ
min-ℕ (succ-ℕ m) zero-ℕ = zero-ℕ
min-ℕ (succ-ℕ m) (succ-ℕ n) = succ-ℕ (min-ℕ m n)
-- Exercise 2.3(b)
mul-ℕ : ℕ → (ℕ → ℕ)
mul-ℕ zero-ℕ n = zero-ℕ
mul-ℕ (succ-ℕ m) n = add-ℕ (mul-ℕ m n) n
-- Exercise 2.3(c)
_^_ : ℕ → (ℕ → ℕ)
m ^ zero-ℕ = one-ℕ
m ^ (succ-ℕ n) = mul-ℕ m (m ^ n)
-- Exercise 2.3(d)
factorial : ℕ → ℕ
factorial zero-ℕ = one-ℕ
factorial (succ-ℕ m) = mul-ℕ (succ-ℕ m) (factorial m)
-- Exercise 2.3(e)
_choose_ : ℕ → ℕ → ℕ
zero-ℕ choose zero-ℕ = one-ℕ
zero-ℕ choose succ-ℕ k = zero-ℕ
(succ-ℕ n) choose zero-ℕ = one-ℕ
(succ-ℕ n) choose (succ-ℕ k) = add-ℕ (n choose k) (n choose (succ-ℕ k))
-- Exercise 2.3(f)
Fibonacci : ℕ → ℕ
Fibonacci zero-ℕ = zero-ℕ
Fibonacci (succ-ℕ zero-ℕ) = one-ℕ
Fibonacci (succ-ℕ (succ-ℕ n)) = add-ℕ (Fibonacci n) (Fibonacci (succ-ℕ n))
-- Exercise 2.4
_∘'_ :
{i j k : Level} {A : UU i} {B : A → UU j} {C : (x : A) → B x → UU k} →
(g : (x : A) → (y : B x) → C x y) (f : (x : A) → B x) → (x : A) → C x (f x)
(g ∘' f) x = g x (f x)
-- Exercise 2.5
Π-swap : {i j k : Level} {A : UU i} {B : UU j} {C : A → (B → UU k)} →
((x : A) (y : B) → C x y) → ((y : B) (x : A) → C x y)
Π-swap f y x = f x y
-- Note: apparently Agda still allows us to define a sequence of universe levels indexed by ℕ
Level-ℕ : ℕ → Level
Level-ℕ zero-ℕ = lzero
Level-ℕ (succ-ℕ n) = lsuc (Level-ℕ n)
sequence-UU : (n : ℕ) → UU (Level-ℕ (succ-ℕ n))
sequence-UU n = UU (Level-ℕ n)
-- However, the following definition is unacceptable for Agda, since it runs
-- into Setω.
{-
Π-sequence-UU : Setω
Π-sequence-UU = (n : ℕ) → sequence-UU n
-}
|
{
"alphanum_fraction": 0.5657356948,
"avg_line_length": 25.7543859649,
"ext": "agda",
"hexsha": "be1a16dfe251df6329fc1fd26b72f30773cd07ab",
"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": "f4228d6ecfc6cdb119c6e8b0e711fea05b98b2d5",
"max_forks_repo_licenses": [
"CC-BY-4.0"
],
"max_forks_repo_name": "tadejpetric/HoTT-Intro",
"max_forks_repo_path": "Agda/02-natural-numbers.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f4228d6ecfc6cdb119c6e8b0e711fea05b98b2d5",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"CC-BY-4.0"
],
"max_issues_repo_name": "tadejpetric/HoTT-Intro",
"max_issues_repo_path": "Agda/02-natural-numbers.agda",
"max_line_length": 95,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "f4228d6ecfc6cdb119c6e8b0e711fea05b98b2d5",
"max_stars_repo_licenses": [
"CC-BY-4.0"
],
"max_stars_repo_name": "tadejpetric/HoTT-Intro",
"max_stars_repo_path": "Agda/02-natural-numbers.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1376,
"size": 2936
}
|
{-# OPTIONS --type-in-type #-}
module TooManyArgs where
open import AgdaPrelude
myFun : (a : Set) -> a -> a -> a
myFun a x y = x
myApp = myFun _ Zero Zero Zero Zero
|
{
"alphanum_fraction": 0.6390532544,
"avg_line_length": 16.9,
"ext": "agda",
"hexsha": "861e4f46f6116568ed178361608171125a8cdb3b",
"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": "64a1b4c6632153d75cba540f7c91f40b49375e2f",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "JoeyEremondi/lambda-pi-constraint",
"max_forks_repo_path": "thesisExamples/TooManyArgs.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "64a1b4c6632153d75cba540f7c91f40b49375e2f",
"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": "JoeyEremondi/lambda-pi-constraint",
"max_issues_repo_path": "thesisExamples/TooManyArgs.agda",
"max_line_length": 35,
"max_stars_count": 16,
"max_stars_repo_head_hexsha": "64a1b4c6632153d75cba540f7c91f40b49375e2f",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "JoeyEremondi/lambda-pi-constraint",
"max_stars_repo_path": "thesisExamples/TooManyArgs.agda",
"max_stars_repo_stars_event_max_datetime": "2021-02-05T20:21:46.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-03-16T11:14:56.000Z",
"num_tokens": 55,
"size": 169
}
|
------------------------------------------------------------------------
-- A coinductive definition of (strong) bisimilarity
------------------------------------------------------------------------
{-# OPTIONS --sized-types #-}
open import Labelled-transition-system
module Bisimilarity {ℓ} (lts : LTS ℓ) where
open import Equality.Propositional
open import Prelude
open import Prelude.Size
import Function-universe equality-with-J as F
import Bisimilarity.General
open import Indexed-container using (Container; ν; ν′)
open import Relation
open import Up-to
open LTS lts
private
module General = Bisimilarity.General lts _[_]⟶_ _[_]⟶_ id id
open General public
using (module StepC; ⟨_,_⟩; left-to-right; right-to-left; force;
reflexive-∼; reflexive-∼′; ≡⇒∼; ∼:_; ∼′:_;
[_]_≡_; [_]_≡′_; []≡↔; module Bisimilarity-of-∼;
Extensionality; extensionality)
-- StepC is given in the following way, rather than via open public,
-- to make hyperlinks to it more informative.
StepC : Container (Proc × Proc) (Proc × Proc)
StepC = General.StepC
-- The following definitions are given explicitly, to make the code
-- easier to follow for readers of the paper.
Bisimilarity : Size → Rel₂ ℓ Proc
Bisimilarity = ν StepC
Bisimilarity′ : Size → Rel₂ ℓ Proc
Bisimilarity′ = ν′ StepC
infix 4 [_]_∼_ [_]_∼′_ _∼_ _∼′_
[_]_∼_ : Size → Proc → Proc → Type ℓ
[ i ] p ∼ q = ν StepC i (p , q)
[_]_∼′_ : Size → Proc → Proc → Type ℓ
[ i ] p ∼′ q = ν′ StepC i (p , q)
_∼_ : Proc → Proc → Type ℓ
_∼_ = [ ∞ ]_∼_
_∼′_ : Proc → Proc → Type ℓ
_∼′_ = [ ∞ ]_∼′_
private
-- However, these definitions are definitionally equivalent to
-- corresponding definitions in General.
indirect-Bisimilarity : Bisimilarity ≡ General.Bisimilarity
indirect-Bisimilarity = refl
indirect-Bisimilarity′ : Bisimilarity′ ≡ General.Bisimilarity′
indirect-Bisimilarity′ = refl
indirect-[]∼ : [_]_∼_ ≡ General.[_]_∼_
indirect-[]∼ = refl
indirect-[]∼′ : [_]_∼′_ ≡ General.[_]_∼′_
indirect-[]∼′ = refl
indirect-∼ : _∼_ ≡ General._∼_
indirect-∼ = refl
indirect-∼′ : _∼′_ ≡ General._∼′_
indirect-∼′ = refl
-- Combinators that can perhaps make the code a bit nicer to read.
infix -3 _⟶⟨_⟩ʳˡ_ _[_]⟶⟨_⟩ʳˡ_
lr-result-with-action lr-result-without-action
_⟶⟨_⟩ʳˡ_ : ∀ {i p′ q′ μ} p → p [ μ ]⟶ p′ → [ i ] p′ ∼′ q′ →
∃ λ p′ → p [ μ ]⟶ p′ × [ i ] p′ ∼′ q′
_ ⟶⟨ p⟶p′ ⟩ʳˡ p′∼′q′ = _ , p⟶p′ , p′∼′q′
_[_]⟶⟨_⟩ʳˡ_ : ∀ {i p′ q′} p μ → p [ μ ]⟶ p′ → [ i ] p′ ∼′ q′ →
∃ λ p′ → p [ μ ]⟶ p′ × [ i ] p′ ∼′ q′
_ [ _ ]⟶⟨ p⟶p′ ⟩ʳˡ p′∼′q′ = _ ⟶⟨ p⟶p′ ⟩ʳˡ p′∼′q′
lr-result-without-action :
∀ {i p′ q′ μ} → [ i ] p′ ∼′ q′ → ∀ q → q [ μ ]⟶ q′ →
∃ λ q′ → q [ μ ]⟶ q′ × [ i ] p′ ∼′ q′
lr-result-without-action p′∼′q′ _ q⟶q′ = _ , q⟶q′ , p′∼′q′
lr-result-with-action :
∀ {i p′ q′} → [ i ] p′ ∼′ q′ → ∀ μ q → q [ μ ]⟶ q′ →
∃ λ q′ → q [ μ ]⟶ q′ × [ i ] p′ ∼′ q′
lr-result-with-action p′∼′q′ _ _ q⟶q′ =
lr-result-without-action p′∼′q′ _ q⟶q′
syntax lr-result-without-action p′∼q′ q q⟶q′ = p′∼q′ ⟵⟨ q⟶q′ ⟩ q
syntax lr-result-with-action p′∼q′ μ q q⟶q′ = p′∼q′ [ μ ]⟵⟨ q⟶q′ ⟩ q
-- Strong bisimilarity is a weak simulation (of a certain kind).
strong-is-weak⇒̂ :
∀ {p p′ q μ} →
p ∼ q → p [ μ ]⇒̂ p′ →
∃ λ q′ → q [ μ ]⇒̂ q′ × p′ ∼ q′
strong-is-weak⇒̂ =
is-weak⇒̂ StepC.left-to-right (λ p∼′q → force p∼′q)
(λ s tr → step s tr done) ⟶→⇒̂
mutual
-- Bisimilarity is symmetric.
symmetric-∼ : ∀ {i p q} → [ i ] p ∼ q → [ i ] q ∼ p
symmetric-∼ p∼q =
StepC.⟨ Σ-map id (Σ-map id symmetric-∼′) ∘ StepC.right-to-left p∼q
, Σ-map id (Σ-map id symmetric-∼′) ∘ StepC.left-to-right p∼q
⟩
symmetric-∼′ : ∀ {i p q} → [ i ] p ∼′ q → [ i ] q ∼′ p
force (symmetric-∼′ p∼q) = symmetric-∼ (force p∼q)
private
-- An alternative proof of symmetry.
alternative-proof-of-symmetry : ∀ {i p q} → [ i ] p ∼ q → [ i ] q ∼ p
alternative-proof-of-symmetry {i} =
uncurry [ i ]_∼_ ⁻¹ ⊆⟨ ν-symmetric _ _ swap refl F.id ⟩∎
uncurry [ i ]_∼_ ∎
-- Strong bisimilarity is transitive.
transitive-∼ : ∀ {i p q r} → [ i ] p ∼ q → [ i ] q ∼ r → [ i ] p ∼ r
transitive-∼ {i} = λ p q →
StepC.⟨ lr p q
, Σ-map id (Σ-map id symmetric-∼′) ∘
lr (symmetric-∼ q) (symmetric-∼ p)
⟩
where
lr : ∀ {p p′ q r μ} →
[ i ] p ∼ q → [ i ] q ∼ r → p [ μ ]⟶ p′ →
∃ λ r′ → r [ μ ]⟶ r′ × [ i ] p′ ∼′ r′
lr p q tr =
let (_ , tr′ , p′) = StepC.left-to-right p tr
(_ , tr″ , q′) = StepC.left-to-right q tr′
in (_ , tr″ , λ { .force → transitive-∼ (force p′) (force q′) })
transitive-∼′ :
∀ {i p q r} → [ i ] p ∼′ q → [ i ] q ∼′ r → [ i ] p ∼′ r
force (transitive-∼′ p∼q q∼r) = transitive-∼ (force p∼q) (force q∼r)
|
{
"alphanum_fraction": 0.5284450063,
"avg_line_length": 28.9390243902,
"ext": "agda",
"hexsha": "b785933aed9d974fac2de25e600dfef88c86a1b0",
"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.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.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/up-to",
"max_stars_repo_path": "src/Bisimilarity.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2033,
"size": 4746
}
|
------------------------------------------------------------------------------
-- A proof that was rejected using the --without-K option
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module ListsSL where
open import Data.List
open import Data.Nat
open import Data.Nat.Properties
open import Data.Product
open import Relation.Binary.PropositionalEquality
open import Relation.Binary
module NDTO = DecTotalOrder ≤-decTotalOrder
------------------------------------------------------------------------------
LTC : {A : Set} → List A → List A → Set
LTC xs ys = ∃ (λ x → ys ≡ x ∷ xs)
LTL : {A : Set} → List A → List A → Set
LTL xs ys = (length xs) < (length ys)
helper : {A : Set}(y : A)(xs : List A) → (length xs) < (length (y ∷ xs))
helper y [] = s≤s z≤n
helper y (x ∷ xs) = s≤s NDTO.refl
-- 25 April 2014. The proof is accepted using Cockx's --without-K
-- implementation.
foo : {A : Set}(xs ys : List A) → LTC xs ys → LTL xs ys
foo xs .(x ∷ xs) (x , refl) = helper x xs
foo' : {A : Set}(xs ys : List A) → LTC xs ys → LTL xs ys
foo' xs ys (x , h) =
subst (λ ys' → length xs < length ys') (sym h) (helper x xs)
|
{
"alphanum_fraction": 0.498121713,
"avg_line_length": 32.4634146341,
"ext": "agda",
"hexsha": "780070022417806ca1abf277cef96a16bf3fa1f4",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z",
"max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/fotc",
"max_forks_repo_path": "notes/k-axiom/ListsSL.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/fotc",
"max_issues_repo_path": "notes/k-axiom/ListsSL.agda",
"max_line_length": 78,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "notes/k-axiom/ListsSL.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": 356,
"size": 1331
}
|
{-# OPTIONS --universe-polymorphism --no-irrelevant-projections --cubical-compatible #-}
module SafeFlagSafePragmas where
|
{
"alphanum_fraction": 0.7886178862,
"avg_line_length": 30.75,
"ext": "agda",
"hexsha": "c760824c8197c9b39d46235b6a7d0b86c4d39a69",
"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/Succeed/SafeFlagSafePragmas.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/Succeed/SafeFlagSafePragmas.agda",
"max_line_length": 88,
"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/Succeed/SafeFlagSafePragmas.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 30,
"size": 123
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.