Search is not available for this dataset
text
string | meta
dict |
---|---|
------------------------------------------------------------------------
-- A variant of Induction for Set₁
------------------------------------------------------------------------
-- I want universe polymorphism.
module Induction1 where
open import Relation.Unary1
-- A RecStruct describes the allowed structure of recursion. The
-- examples in Induction.Nat should explain what this is all about.
RecStruct : Set → Set₂
RecStruct a = Pred a → Pred a
-- A recursor builder constructs an instance of a recursion structure
-- for a given input.
RecursorBuilder : ∀ {a} → RecStruct a → Set₂
RecursorBuilder {a} Rec = (P : Pred a) → Rec P ⊆′ P → Universal (Rec P)
-- A recursor can be used to actually compute/prove something useful.
Recursor : ∀ {a} → RecStruct a → Set₂
Recursor {a} Rec = (P : Pred a) → Rec P ⊆′ P → Universal P
-- And recursors can be constructed from recursor builders.
build : ∀ {a} {Rec : RecStruct a} →
RecursorBuilder Rec →
Recursor Rec
build builder P f x = f x (builder P f x)
-- We can repeat the exercise above for subsets of the type we are
-- recursing over.
SubsetRecursorBuilder : ∀ {a} → Pred a → RecStruct a → Set₂
SubsetRecursorBuilder {a} Q Rec = (P : Pred a) → Rec P ⊆′ P → Q ⊆′ Rec P
SubsetRecursor : ∀ {a} → Pred a → RecStruct a → Set₂
SubsetRecursor {a} Q Rec = (P : Pred a) → Rec P ⊆′ P → Q ⊆′ P
subsetBuild : ∀ {a} {Q : Pred a} {Rec : RecStruct a} →
SubsetRecursorBuilder Q Rec →
SubsetRecursor Q Rec
subsetBuild builder P f x q = f x (builder P f x q)
| {
"alphanum_fraction": 0.6037371134,
"avg_line_length": 32.3333333333,
"ext": "agda",
"hexsha": "48d443bcf8efa939161ee3bec6a9d27785581b28",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z",
"max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "isabella232/Lemmachine",
"max_forks_repo_path": "vendor/stdlib/src/Induction1.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "larrytheliquid/Lemmachine",
"max_issues_repo_path": "vendor/stdlib/src/Induction1.agda",
"max_line_length": 72,
"max_stars_count": 56,
"max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "isabella232/Lemmachine",
"max_stars_repo_path": "vendor/stdlib/src/Induction1.agda",
"max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z",
"num_tokens": 423,
"size": 1552
} |
-- Andreas, 2012-03-09 do not solve relevant meta variable by irr. constraint
module Issue351a where
open import Common.Irrelevance
open import Common.Equality
data Bool : Set where
true false : Bool
-- the Boolean b is not(!) constrained by the equation
f : (b : Bool) -> squash b ≡ squash true -> Bool
f b _ = b
test = f _ refl
-- meta needs to remain unsolved
| {
"alphanum_fraction": 0.7208672087,
"avg_line_length": 23.0625,
"ext": "agda",
"hexsha": "d95576880e8ccb80347c6eee376c3a975dfa895f",
"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/Issue351a.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/Issue351a.agda",
"max_line_length": 77,
"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/Issue351a.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": 103,
"size": 369
} |
-- Andreas, 2018-06-10, issue #2797
-- Analysis and test case by Ulf
-- Relevance check was missing for overloaded projections.
{-# OPTIONS --irrelevant-projections #-}
-- {-# OPTIONS -v tc.proj.amb:30 #-}
open import Agda.Builtin.Nat
record Dummy : Set₁ where
field nat : Set
open Dummy
record S : Set where
field .nat : Nat
open S
mkS : Nat → S
mkS n .nat = n
-- The following should not pass, as projection
-- .nat is irrelevant for record type S
unS : S → Nat
unS s = s .nat
-- Error NOW, could be better:
-- Cannot resolve overloaded projection nat because no matching candidate found
-- when checking that the expression s .nat has type Nat
viaS : Nat → Nat
viaS n = unS (mkS n)
idN : Nat → Nat
idN zero = zero
idN (suc n) = suc n
canonicity-fail : Nat
canonicity-fail = idN (viaS 17)
-- C-c C-n canonicity-fail
-- idN .(17)
| {
"alphanum_fraction": 0.6827262045,
"avg_line_length": 19.3409090909,
"ext": "agda",
"hexsha": "5b87660017840ee25f290929eecb35e9330f47b2",
"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/Issue2797.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/Issue2797.agda",
"max_line_length": 79,
"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/Issue2797.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 263,
"size": 851
} |
module binding-preserve where
open import utility
renaming (_U̬_ to _∪_ ; _|̌_ to _-_)
open import sn-calculus
open import Function using (_∋_ ; _$_ ; _∘_)
open import Esterel.Lang
open import Esterel.Lang.Binding
open import Esterel.Lang.Properties
using (done; halted ; paused ; value-max)
open import Esterel.Context
open import Esterel.Context.Properties
open import Esterel.Environment
open import Esterel.Variable.Signal as Signal
using (Signal ; _ₛ)
open import Esterel.Variable.Shared as SharedVar
using (SharedVar ; _ₛₕ)
open import Esterel.Variable.Sequential as SeqVar
using (SeqVar ; _ᵥ)
open done
open halted
open paused
open Context1
open EvaluationContext1
open import Data.Empty
using (⊥ ; ⊥-elim)
open import Data.List
using (List ; [] ; _∷_ ; [_] ; _++_)
open import Data.List.Any
using (Any ; any ; here ; there)
open import Data.List.Any.Properties
using (++⁻)
renaming ( ++⁺ˡ to ++ˡ ; ++⁺ʳ to ++ʳ )
open import Data.Nat
using (ℕ ; zero ; suc ; _≟_ ; _+_)
open import Data.Product
using (Σ ; proj₁ ; proj₂ ; ∃ ; _,_ ; _,′_ ; _×_)
open import Data.Sum
using (_⊎_ ; inj₁ ; inj₂)
open import Function
using (_∘_ ; id)
open import Relation.Nullary
using (Dec ; yes ; no)
open import Relation.Binary.PropositionalEquality
using (_≡_ ; refl ; cong ; sym ; module ≡-Reasoning ; subst)
open ≡-Reasoning using (_≡⟨_⟩_ ; _≡⟨⟩_ ; _∎)
open ListSet Data.Nat._≟_
using (set-subtract ; set-subtract-merge ; set-subtract-notin; set-subtract-[]; set-subtract-split)
++-distribute-subtract : ∀ xs ys zs →
set-subtract (xs ++ ys) zs ≡
set-subtract xs zs ++ set-subtract ys zs
++-distribute-subtract [] ys zs = refl
++-distribute-subtract (x ∷ xs) ys zs with any (_≟_ x) zs
... | yes x∈zs = ++-distribute-subtract xs ys zs
... | no x∉zs = cong (x ∷_) (++-distribute-subtract xs ys zs)
subtract-⊆¹ : ∀ xs ys → set-subtract xs ys ⊆¹ xs
subtract-⊆¹ [] ys = ⊆¹-refl
subtract-⊆¹ (x ∷ xs) ys with any (_≟_ x) ys
... | yes x∈ys = λ w w∈xs-ys → ++ʳ [ x ] (subtract-⊆¹ xs ys w w∈xs-ys)
... | no x∉ys = λ { w (here refl) → here refl
; w (there w∈xs-ys) → there (subtract-⊆¹ xs ys w w∈xs-ys) }
R-maintain-raise-shared-0 : ∀{xs θ e} → ∀ s e' →
(ShrMap.keys (ShrMap.[ s ↦ SharedVar.old ,′ δ {θ} {e} e' ]) ++ xs)
⊆¹ (SharedVar.unwrap s ∷ xs)
R-maintain-raise-shared-0 s e' s' s'∈[s]++BV
rewrite ShrMap.keys-1map s (SharedVar.old ,′ δ e')
= s'∈[s]++BV
R-maintain-raise-shared-1 : ∀ ys {θ e} → ∀ s e' →
set-subtract ys (ShrMap.keys ShrMap.[ s ↦ SharedVar.old ,′ δ {θ} {e} e' ])
⊆¹ set-subtract ys (SharedVar.unwrap s ∷ [])
R-maintain-raise-shared-1 ys s e' s' s'∈ys-[s]
rewrite ShrMap.keys-1map s (SharedVar.old ,′ δ e')
= s'∈ys-[s]
R-maintain-raise-sig-0 : ∀{xs} → ∀ S →
(SigMap.keys (SigMap.[ S ↦ Signal.unknown ]) ++ xs)
⊆¹ (Signal.unwrap S ∷ xs)
R-maintain-raise-sig-0 S S' S'∈[S]++BV
rewrite SigMap.keys-1map S Signal.unknown
= S'∈[S]++BV
R-maintain-raise-sig-1 : ∀ ys → ∀ S →
set-subtract ys (SigMap.keys SigMap.[ S ↦ Signal.unknown ])
⊆¹ set-subtract ys (Signal.unwrap S ∷ [])
R-maintain-raise-sig-1 ys S S' S'∈ys-[S]
rewrite SigMap.keys-1map S Signal.unknown
= S'∈ys-[S]
R-maintain-lift-1 : ∀ S xs ys {zs} →
set-subtract xs ys ⊆¹ zs → set-subtract (S ∷ xs) ys ⊆¹ (S ∷ zs)
R-maintain-lift-1 S xs ys xs-ys⊆zs S' S'∈⟨S∷xs⟩-ys with any (_≟_ S) ys
R-maintain-lift-1 S xs ys xs-ys⊆zs S' (here refl) | no _ =
here refl
R-maintain-lift-1 S xs ys xs-ys⊆zs S' (there S'∈xs-ys) | no _ =
there (xs-ys⊆zs S' S'∈xs-ys)
... | yes _ =
there (xs-ys⊆zs S' S'∈⟨S∷xs⟩-ys)
R-maintain-lift-2' : ∀ {zs ws} xs ys →
set-subtract xs ys ⊆¹ zs →
set-subtract (xs ++ ws) ys ⊆¹ (zs ++ ws)
R-maintain-lift-2' {zs} {ws} xs ys xs-ys⊆zs
rewrite ++-distribute-subtract xs ws ys =
∪¹-join-⊆¹ (λ u → ++ˡ ∘ xs-ys⊆zs u)
(⊆¹-trans (subtract-⊆¹ ws ys) (λ u → ++ʳ zs ∘ ⊆¹-refl u))
R-maintain-lift-6' : ∀ {zs} ws xs ys →
set-subtract xs ys ⊆¹ zs →
set-subtract (ws ++ xs) ys ⊆¹ (ws ++ zs)
R-maintain-lift-6' {zs} ws xs ys xs-ys⊆zs
rewrite ++-distribute-subtract ws xs ys =
∪¹-join-⊆¹ (⊆¹-trans (subtract-⊆¹ ws ys) (λ u → ++ˡ ∘ ⊆¹-refl u))
(λ u → ++ʳ ws ∘ xs-ys⊆zs u)
R-maintain-lift-2 : ∀ {zs³ ws³} xs³ ys³ →
(xs³ - ys³) ⊆ zs³ →
((xs³ ∪ ws³) - ys³) ⊆ (zs³ ∪ ws³)
R-maintain-lift-2 xs³ ys³ xs³-ys³⊆zs³ =
R-maintain-lift-2' ,′ R-maintain-lift-2' ,′ R-maintain-lift-2' #
xs³ # ys³ # xs³-ys³⊆zs³
R-maintain-lift-6 : ∀ {zs³} ws³ xs³ ys³ →
(xs³ - ys³) ⊆ zs³ →
((ws³ ∪ xs³) - ys³) ⊆ (ws³ ∪ zs³)
R-maintain-lift-6 ws³ xs³ ys³ xs³-ys³⊆zs³ =
R-maintain-lift-6' ,′ R-maintain-lift-6' ,′ R-maintain-lift-6' #
ws³ # xs³ # ys³ # xs³-ys³⊆zs³
R-maintain-lift-3' : ∀ {ys zs ws} xs →
(xs ++ ys) ⊆¹ zs →
distinct' zs ws →
distinct' ys ws
R-maintain-lift-3' xs xs++ys⊆zs zs≠ws x x∈ys x∈ws =
zs≠ws x (xs++ys⊆zs x (++ʳ xs x∈ys)) x∈ws
R-maintain-lift-3 : ∀ {ys³ zs³ ws³} xs³ →
(xs³ ∪ ys³) ⊆ zs³ →
distinct zs³ ws³ →
distinct ys³ ws³
R-maintain-lift-3 xs³ xs³∪ys³⊆zs³ zs³≠ws³ =
R-maintain-lift-3' ,′ R-maintain-lift-3' ,′ R-maintain-lift-3' #
xs³ # xs³∪ys³⊆zs³ # zs³≠ws³
R-maintain-lift-4' : ∀ {xs ws us vs zs} ys →
set-subtract xs ys ⊆¹ us → distinct' us zs →
(ys ++ ws) ⊆¹ vs → distinct' vs zs →
distinct' xs zs
R-maintain-lift-4' {.a ∷ xs} ys xs-ys⊆us us≠zs ys++ws⊆vs vs≠zs
a (here refl) a∈zs with any (_≟_ a) ys
... | yes a∈ys = vs≠zs a (ys++ws⊆vs a (++ˡ a∈ys)) a∈zs
... | no a∉ys = us≠zs a (xs-ys⊆us a (here refl)) a∈zs
R-maintain-lift-4' {x ∷ xs} ys xs-ys⊆us us≠zs ys++ws⊆vs vs≠zs
a (there a∈xs) a∈zs with any (_≟_ x) ys
... | yes x∈ys = R-maintain-lift-4' ys xs-ys⊆us us≠zs ys++ws⊆vs vs≠zs a a∈xs a∈zs
... | no x∉ys = R-maintain-lift-4' ys (proj₂ (∪¹-unjoin-⊆¹ [ x ] xs-ys⊆us))
us≠zs ys++ws⊆vs vs≠zs a a∈xs a∈zs
R-maintain-lift-4 : ∀ {ws³ us³ vs³ xs³ zs³} ys³ →
(xs³ - ys³) ⊆ us³ → distinct us³ zs³ →
(ys³ ∪ ws³) ⊆ vs³ → distinct vs³ zs³ →
distinct xs³ zs³
R-maintain-lift-4 ys³ xs³-ys³⊆us³ us³≠zs³ ys³∪ws³⊆vs³ vs³≠zs³ =
R-maintain-lift-4' ,′ R-maintain-lift-4' ,′ R-maintain-lift-4' #
ys³ # xs³-ys³⊆us³ # us³≠zs³ # ys³∪ws³⊆vs³ # vs³≠zs³
R-maintain-lift-5 : ∀ xs³ ys³ {zs³ ws³} →
(ys³ ∪ zs³) ⊆ ws³ →
(ys³ ∪ (xs³ ∪ zs³)) ⊆ (xs³ ∪ ws³)
R-maintain-lift-5 xs³ ys³ ys³∪zs³⊆ws³ with ∪-unjoin-⊆ ys³ ys³∪zs³⊆ws³
... | ys³⊆ws³ , zs³⊆ws³ = ∪-join-⊆ (∪ʳ xs³ ys³⊆ws³) (∪-respect-⊆-right xs³ zs³⊆ws³)
R-maintain-lift-0 : ∀{p θ q BVp FVp E A} →
CorrectBinding p BVp FVp →
p ≐ E ⟦ ρ⟨ θ , A ⟩· q ⟧e →
Σ (VarList × VarList)
λ { (BV' , FV') →
(BV' ⊆ BVp × FV' ⊆ FVp) ×
CorrectBinding (ρ⟨ θ , A ⟩· E ⟦ q ⟧e) BV' FV' }
R-maintain-lift-0 cbp dehole = _ , (⊆-refl , ⊆-refl) , cbp
R-maintain-lift-0 (CBpar {BVq = BVq'} {FVq = FVq'} cbp' cbq'
BVp'≠BVq' FVp'≠BVq' BVp'≠FVq' Xp'≠Xq')
(depar₁ p'≐E⟦ρθ⟧)
with R-maintain-lift-0 cbp' p'≐E⟦ρθ⟧
... | (BV' , FV') , (BV'⊆BVp' , FV'⊆FVp') ,
CBρ {θ} {_} {_} {BVp''} {FVp''} cbp'' =
_ ,
(⊆-subst-left (∪-assoc (Dom θ) BVp'' BVq') (∪-respect-⊆-left BV'⊆BVp') ,′
R-maintain-lift-2 FVp'' (Dom θ) FV'⊆FVp') ,′
CBρ (CBpar cbp'' cbq'
(R-maintain-lift-3 (Dom θ) BV'⊆BVp' BVp'≠BVq')
(R-maintain-lift-4 (Dom θ) FV'⊆FVp' FVp'≠BVq' BV'⊆BVp' BVp'≠BVq')
(R-maintain-lift-3 (Dom θ) BV'⊆BVp' BVp'≠FVq')
(R-maintain-lift-4' (proj₂ (proj₂ (Dom θ))) (proj₂ (proj₂ FV'⊆FVp'))
Xp'≠Xq' (proj₂ (proj₂ BV'⊆BVp')) (proj₂ (proj₂ BVp'≠FVq'))))
R-maintain-lift-0 (CBpar {BVp = BVp'} {FVp = FVp'} cbp' cbq'
BVp'≠BVq' FVp'≠BVq' BVp'≠FVq' Xp'≠Xq')
(depar₂ q'≐E⟦ρθ⟧)
with R-maintain-lift-0 cbq' q'≐E⟦ρθ⟧
... | (BV' , FV') , (BV'⊆BVq' , FV'⊆FVq') ,
CBρ {θ} {_} {_} {BVq''} {FVq''} cbq'' =
_ ,
(R-maintain-lift-5 BVp' (Dom θ) BV'⊆BVq' ,′
R-maintain-lift-6 FVp' FVq'' (Dom θ) FV'⊆FVq') ,′
CBρ (CBpar cbp' cbq''
(distinct-sym (R-maintain-lift-3 (Dom θ) BV'⊆BVq' (distinct-sym BVp'≠BVq')))
(distinct-sym (R-maintain-lift-3 (Dom θ) BV'⊆BVq' (distinct-sym FVp'≠BVq')))
(distinct-sym (R-maintain-lift-4 (Dom θ)
FV'⊆FVq' (distinct-sym BVp'≠FVq')
BV'⊆BVq' (distinct-sym BVp'≠BVq')))
(distinct'-sym
(R-maintain-lift-4' (proj₂ (proj₂ (Dom θ))) (proj₂ (proj₂ FV'⊆FVq'))
(distinct'-sym Xp'≠Xq') (proj₂ (proj₂ BV'⊆BVq'))
(distinct'-sym (proj₂ (proj₂ FVp'≠BVq'))))))
R-maintain-lift-0 (CBseq cbp' cbq' BV≠FV) (deseq p'≐E⟦ρθ⟧)
with R-maintain-lift-0 cbp' p'≐E⟦ρθ⟧
... | (BV' , FV') , (BV'⊆BVp' , FV'⊆FVp') ,
CBρ {θ} {_} {_} {BVp''} {FVp''} cbp'' =
_ ,
(∪-join-⊆
(∪ˡ (∪-unjoin-⊆ˡ {Dom θ} BV'⊆BVp'))
(∪-respect-⊆-left (∪-unjoin-⊆ʳ (Dom θ) BV'⊆BVp')) ,′
R-maintain-lift-2 FVp'' (Dom θ) FV'⊆FVp') ,′
CBρ (CBseq cbp'' cbq'
(⊆-respect-distinct-left (∪-unjoin-⊆ʳ (Dom θ) BV'⊆BVp') BV≠FV))
R-maintain-lift-0 (CBloopˢ cbp' cbq' BVp'≠FVq' BVq'≠FVq') (deloopˢ p'≐E⟦ρθ⟧)
with R-maintain-lift-0 cbp' p'≐E⟦ρθ⟧
... | (BV' , FV') , (BV'⊆BVp' , FV'⊆FVp') ,
CBρ {θ} {_} {_} {BVp''} {FVp''} cbp'' =
_ ,
(∪-join-⊆
(∪ˡ (∪-unjoin-⊆ˡ {Dom θ} BV'⊆BVp'))
(∪-respect-⊆-left (∪-unjoin-⊆ʳ (Dom θ) BV'⊆BVp')) ,′
R-maintain-lift-2 FVp'' (Dom θ) FV'⊆FVp') ,′
CBρ (CBloopˢ cbp'' cbq'
(⊆-respect-distinct-left (∪-unjoin-⊆ʳ (Dom θ) BV'⊆BVp') BVp'≠FVq') BVq'≠FVq')
R-maintain-lift-0 (CBsusp {S = S} cbp' S∉BV) (desuspend p'≐E⟦ρθ⟧)
with R-maintain-lift-0 cbp' p'≐E⟦ρθ⟧
... | (BV' , FV') , (BV'⊆BVp' , FV'⊆FVp') ,
CBρ {θ} {_} {_} {BVp''} {FVp''} cbp'' =
_ ,
(BV'⊆BVp' ,′
(R-maintain-lift-1 (Signal.unwrap S) (proj₁ FVp'') (proj₁ (Dom θ)) (proj₁ FV'⊆FVp') ,′
proj₁ (proj₂ FV'⊆FVp') ,′
proj₂ (proj₂ FV'⊆FVp'))) ,′
CBρ (CBsusp cbp''
(λ S' S'∈[S] S'∈BV →
S∉BV S' S'∈[S] (proj₁ BV'⊆BVp' S' (++ʳ (proj₁ (Dom θ)) S'∈BV))))
R-maintain-lift-0 (CBtrap cbp') (detrap p'≐E⟦ρθ⟧)
with R-maintain-lift-0 cbp' p'≐E⟦ρθ⟧
... | (BV' , FV') , ⟨BV'⊆BVp'⟩×⟨FV'⊆FVp'⟩ , CBρ cbp'' =
_ , ⟨BV'⊆BVp'⟩×⟨FV'⊆FVp'⟩ ,′ CBρ (CBtrap cbp'')
R-maintain-raise-var-0 : ∀{xs θ e} → ∀ x e' →
(VarMap.keys (VarMap.[ x ↦ δ {θ} {e} e' ]) ++ xs)
⊆¹ (SeqVar.unwrap x ∷ xs)
R-maintain-raise-var-0 x e' x' x'∈[x]++BV
rewrite VarMap.keys-1map x (δ e')
= x'∈[x]++BV
R-maintain-raise-var-1 : ∀ ys {θ e} → ∀ x e' →
set-subtract ys (VarMap.keys VarMap.[ x ↦ δ {θ} {e} e' ])
⊆¹ set-subtract ys (SeqVar.unwrap x ∷ [])
R-maintain-raise-var-1 ys x e' x' x'∈ys-[x]
rewrite VarMap.keys-1map x (δ e')
= x'∈ys-[x]
R-maintains-binding : ∀{p q BV FV} → CorrectBinding p BV FV → p sn⟶₁ q → Σ (VarList × VarList) λ { (BV' , FV') → CorrectBinding q BV' FV' × BV' ⊆ BV × FV' ⊆ FV}
R-maintains-binding (CBpar{BVp = BVp}{FVp = FVp} cbp cbq BVp≠BVq FVp≠BVq BVp≠FVq Xp≠Xq) (rpar-done-right hnothin (dhalted q')) = _ , cbq , ∪ʳ BVp ((λ x x₁ → x₁) , (λ x x₁ → x₁) , (λ x x₁ → x₁)) , ∪ʳ FVp ((λ x x₁ → x₁) , (λ x x₁ → x₁) , (λ x x₁ → x₁))
R-maintains-binding (CBpar cbp cbq BVp≠BVq FVp≠BVq BVp≠FVq Xp≠Xq) (rpar-done-right (hexit _) (dhalted hnothin))
= _ , CBexit , ((λ x → λ ()) , ((λ x → λ ()) , (λ x → λ ()))) , ((λ x → λ ()) , ((λ x → λ ()) , (λ x → λ ())))
R-maintains-binding (CBpar cbp cbq BVp≠BVq FVp≠BVq BVp≠FVq Xp≠Xq) (rpar-done-right (hexit _) (dhalted (hexit _))) = _ , CBexit , (((λ x → λ ()) , ((λ x → λ ()) , (λ x → λ ())))) , ((λ x → λ ()) , ((λ x → λ ()) , (λ x → λ ())))
R-maintains-binding (CBpar{BVp = BVp}{FVp = FVp} cbp cbq BVp≠BVq FVp≠BVq BVp≠FVq Xp≠Xq) (rpar-done-right hnothin (dpaused q')) = _ , cbq , ∪ʳ BVp ((λ x x₁ → x₁) , (λ x x₁ → x₁) , (λ x x₁ → x₁)) , ∪ʳ FVp ((λ x x₁ → x₁) , (λ x x₁ → x₁) , (λ x x₁ → x₁))
R-maintains-binding (CBpar cbp cbq BVp≠BVq FVp≠BVq BVp≠FVq Xp≠Xq) (rpar-done-right (hexit _) (dpaused q')) = _ , CBexit , (((λ x → λ ()) , ((λ x → λ ()) , (λ x → λ ())))) , ((λ x → λ ()) , ((λ x → λ ()) , (λ x → λ ())))
R-maintains-binding (CBpar{BVp = BVp}{FVp = FVp} cbp cbq BVp≠BVq FVp≠BVq BVp≠FVq Xp≠Xq) (rpar-done-left (dhalted hnothin) q') = _ , cbq , ∪ʳ BVp ((λ x x₁ → x₁) , (λ x x₁ → x₁) , (λ x x₁ → x₁)) , ∪ʳ FVp ((λ x x₁ → x₁) , (λ x x₁ → x₁) , (λ x x₁ → x₁))
R-maintains-binding (CBpar cbp cbq BVp≠BVq FVp≠BVq BVp≠FVq Xp≠Xq) (rpar-done-left (dhalted (hexit _)) hnothin) = _ , CBexit , (((λ x → λ ()) , ((λ x → λ ()) , (λ x → λ ())))) , ((λ x → λ ()) , ((λ x → λ ()) , (λ x → λ ())))
R-maintains-binding (CBpar cbp cbq BVp≠BVq FVp≠BVq BVp≠FVq Xp≠Xq) (rpar-done-left (dhalted (hexit _)) (hexit _)) = _ , CBexit , (((λ x → λ ()) , ((λ x → λ ()) , (λ x → λ ())))) , ((λ x → λ ()) , ((λ x → λ ()) , (λ x → λ ())))
R-maintains-binding (CBpar cbp cbq BVp≠BVq FVp≠BVq BVp≠FVq Xp≠Xq) (rpar-done-left (dpaused p') hnothin) = _ , cbp , ∪ˡ ((λ x x₁ → x₁) , (λ x x₁ → x₁) , (λ x x₁ → x₁)), ∪ˡ ((λ x x₁ → x₁) , (λ x x₁ → x₁) , (λ x x₁ → x₁))
R-maintains-binding (CBpar cbp cbq BVp≠BVq FVp≠BVq BVp≠FVq Xp≠Xq) (rpar-done-left (dpaused p') (hexit _)) = _ , CBexit , (((λ x → λ ()) , ((λ x → λ ()) , (λ x → λ ())))) , ((λ x → λ ()) , ((λ x → λ ()) , (λ x → λ ())))
R-maintains-binding {(ρ⟨ θ , A ⟩· p)} (CBρ cb) red@(ris-present S∈ θS≡present p≐E⟦presentS⟧)
with binding-extract cb p≐E⟦presentS⟧
... | _ , _ , cbpresent@(CBpresent {S = S} cbp' cbq')
with binding-subst cb p≐E⟦presentS⟧
cbpresent (∪ˡ ⊆-refl) (∪ʳ (+S S base) (∪ˡ ⊆-refl))
cbp'
... | _ , (a , b) , cb' = _ , CBρ cb' , ∪-respect-⊆-right (Dom θ) a , ⊆-respect-|̌ (Dom θ) b
R-maintains-binding {(ρ⟨ θ , A ⟩· p)} (CBρ cb) red@(ris-absent S∈ θS≡absent p≐E⟦presentS⟧)
with binding-extract cb p≐E⟦presentS⟧
... | _ , _ , cbpresent@(CBpresent {S = S} {BVp = BVp'} {FVp = FVp'} cbp' cbq')
with binding-subst cb p≐E⟦presentS⟧
cbpresent (∪ʳ BVp' ⊆-refl) (∪ʳ (+S S base) (∪ʳ FVp' ⊆-refl))
cbq'
... | _ , (a , b) , cb' = _ , CBρ cb' , ∪-respect-⊆-right (Dom θ) a , ⊆-respect-|̌ (Dom θ) b
R-maintains-binding {(ρ⟨ θ , A ⟩· p)} (CBρ cb) (remit{S = S} S∈ θS≢absent p≐E⟦emitS⟧)
with binding-extract cb p≐E⟦emitS⟧
... | _ , _ , cbemit
with binding-subst cb p≐E⟦emitS⟧
cbemit ⊆-empty-left ⊆-empty-left
CBnothing
... | _ , (a , b) , cbp'
rewrite cong fst (sig-set-dom-eq S Signal.present θ S∈)
= _ , CBρ cbp' , ∪-respect-⊆-right (Dom θ') a , ⊆-respect-|̌ (Dom θ') b
where θ' = (set-sig{S} θ S∈ Signal.present)
R-maintains-binding {(loop p)} {FV = FV2} (CBloop {BV = BV}{FV = FV} cb BV≠FV) rloop-unroll =
_ , (CBloopˢ cb cb BV≠FV BV≠FV) , (sub BV , sub FV)
where
sub1 : ∀ x → (x ++ x) ⊆¹ x
sub1 x z y with ++⁻ x y
... | inj₁ a = a
... | inj₂ a = a
sub : ∀ x → (x ∪ x) ⊆ x
sub x = sub1 , sub1 , sub1 # x
R-maintains-binding (CBseq{BVp = BVp}{FVp = FVp} cbp cbq BV≠FV) rseq-done = _ , cbq , ∪ʳ BVp ⊆-refl , ∪ʳ FVp ⊆-refl
R-maintains-binding (CBseq cbp cbq BV≠FV) rseq-exit = _ , CBexit , ⊆-empty-left , ⊆-empty-left
R-maintains-binding (CBloopˢ cbp cbq BV≠FV _) rloopˢ-exit = _ , CBexit , ⊆-empty-left , ⊆-empty-left
R-maintains-binding (CBsusp cb _) (rsuspend-done _) = _ , cb , ⊆-refl , ((λ x x₁ → there x₁) , (λ x z → z) , (λ x z → z))
R-maintains-binding (CBtrap cb) (rtrap-done hnothin) = _ , CBnothing , ⊆-empty-left , ⊆-empty-left
R-maintains-binding (CBtrap cb) (rtrap-done (hexit zero)) = _ , CBnothing , ⊆-empty-left , ⊆-empty-left
R-maintains-binding (CBtrap cb) (rtrap-done (hexit (suc n))) = _ , CBexit , ⊆-empty-left , ⊆-empty-left
R-maintains-binding (CBsig{S = S}{FV = FV} cb) rraise-signal
= _ , CBρ cb
, ( (R-maintain-raise-sig-0 S) ,′ ⊆¹-refl ,′ ⊆¹-refl)
, ((R-maintain-raise-sig-1 (fst FV) S) ,′ ⊆¹-refl ,′ ⊆¹-refl)
R-maintains-binding (CBρ{θ = θ} cb) (rraise-shared {s = s} {e} e' p≐E⟦shared⟧)
with binding-extract cb p≐E⟦shared⟧
... | _ , _ , cbshr@(CBshared {FV = FV} cbp)
with binding-subst cb p≐E⟦shared⟧
cbshr (⊆¹-refl ,′ -- S'∈BVp
R-maintain-raise-shared-0 s e' ,′
⊆¹-refl) -- x'∈BVp
(∪ʳ (FVₑ e)
(⊆¹-refl ,′ -- S'∈FVe+⟨FVp-s⟩
R-maintain-raise-shared-1 (proj₁ (proj₂ FV)) s e' ,′
⊆¹-refl)) -- x'∈FVe+⟨FVp-s⟩
(CBρ cbp)
... | _ , (a , b) , cbp' = _ , CBρ cbp' , ∪-respect-⊆-right (Dom θ) a , ⊆-respect-|̌ (Dom θ) b
R-maintains-binding (CBρ{θ = θ} cb) (rset-shared-value-old{s = s} e' s∈ θs≡old p≐E⟦s⇐e⟧)
with binding-extract cb p≐E⟦s⇐e⟧
... | _ , _ , cbshrset
with binding-subst cb p≐E⟦s⇐e⟧
cbshrset ⊆-empty-left ⊆-empty-left
CBnothing
... | _ , (a , b) , cb'
rewrite cong snd (shr-set-dom-eq s SharedVar.new (δ e') θ s∈)
= _ , CBρ cb' , ∪-respect-⊆-right (Dom (set-shr{s = s} θ s∈ SharedVar.new (δ e'))) a , ⊆-respect-|̌ (Dom (set-shr{s = s} θ s∈ SharedVar.new (δ e'))) b
R-maintains-binding (CBρ{θ = θ} cb) (rset-shared-value-new{s = s} e' s∈ θs≡new p≐E⟦s⇐e⟧)
with binding-extract cb p≐E⟦s⇐e⟧
... | _ , _ , cbshrset
with binding-subst cb p≐E⟦s⇐e⟧
cbshrset ⊆-empty-left ⊆-empty-left
CBnothing
... | _ , (a , b) , cb'
rewrite cong snd (shr-set-dom-eq s SharedVar.new ((shr-vals{s} θ s∈) + (δ e')) θ s∈)
= _ , CBρ cb' , ( ∪-respect-⊆-right (Dom (set-shr{s = s} θ s∈ SharedVar.new _)) a) , ⊆-respect-|̌ (Dom (set-shr{s = s} θ s∈ SharedVar.new _)) b
R-maintains-binding (CBρ{θ = θ} cb) (rraise-var {x = x} {e = e} e' p≐E⟦var⟧)
with binding-extract cb p≐E⟦var⟧
... | _ , _ , cbvar@(CBvar {FV = FV} cbp)
with binding-subst cb p≐E⟦var⟧
cbvar (⊆¹-refl ,′
⊆¹-refl ,′
R-maintain-raise-var-0 x e')
(∪ʳ (FVₑ e)
(⊆¹-refl ,′
⊆¹-refl ,′
R-maintain-raise-var-1 (proj₂ (proj₂ FV)) x e'))
(CBρ cbp)
... | _ , (a , b) , cb' = _ , CBρ cb' , ( ∪-respect-⊆-right (Dom θ) a) , ⊆-respect-|̌ (Dom θ) b
R-maintains-binding (CBρ{θ = θ} cb) (rset-var{x = x} x∈ e' p≐E⟦x≔e⟧)
with binding-extract cb p≐E⟦x≔e⟧
... | _ , _ , cbvarset
with binding-subst cb p≐E⟦x≔e⟧
cbvarset ⊆-empty-left ⊆-empty-left
CBnothing
... | _ , (a , b) , cb'
rewrite cong thd (seq-set-dom-eq x (δ e') θ x∈)
= _ , CBρ cb' , ∪-respect-⊆-right (Dom (set-var{x} θ x∈ (δ e'))) a , ⊆-respect-|̌ (Dom (set-var{x} θ x∈ (δ e'))) b
R-maintains-binding (CBρ{θ = θ} cb) (rif-false x∈ θx≡zero p≐E⟦if⟧)
with binding-extract cb p≐E⟦if⟧
... | _ , _ , cbif@(CBif {x = x} {BVp = BVp} {FVp = FVp} cbp cbq)
with binding-subst cb p≐E⟦if⟧
cbif (∪ʳ BVp ⊆-refl) (∪ʳ (+x x base) (∪ʳ FVp ⊆-refl))
cbq
... | _ , (a , b) , cb' = _ , CBρ cb' , ( ∪-respect-⊆-right (Dom θ) a) , ( ⊆-respect-|̌ (Dom θ) b)
R-maintains-binding (CBρ{θ = θ} cb) (rif-true x∈ θx≡suc p≐E⟦if⟧)
with binding-extract cb p≐E⟦if⟧
... | _ , _ , cbif@(CBif {x = x} cbp cbq)
with binding-subst cb p≐E⟦if⟧
cbif (∪ˡ ⊆-refl) (∪ʳ (+x x base) (∪ˡ ⊆-refl))
cbp
... | _ , (a , b) , cb' = _ , CBρ cb' , ∪-respect-⊆-right (Dom θ) a , ( ⊆-respect-|̌ (Dom θ) b)
R-maintains-binding (CBρ{θ = θ} cb) (rabsence{S = S} S∈ θS≡unknown S∉canₛ) rewrite cong fst (sig-set-dom-eq S Signal.absent θ S∈) = _ , CBρ cb , ⊆-refl , ⊆-refl
R-maintains-binding (CBρ{θ = θ} cb) (rreadyness{s = s} s∈ θs≡old⊎θs≡new s∉canₛₕ) rewrite cong snd (shr-set-dom-eq s SharedVar.ready (shr-vals{s} θ s∈) θ s∈) = _ , CBρ cb , ⊆-refl , ⊆-refl
R-maintains-binding (CBρ{θ = θo}{BV = BVo}{FV = FVo} cb) (rmerge{θ₂ = θi} p≐E⟦ρθ⟧) with R-maintain-lift-0 cb p≐E⟦ρθ⟧
... | _ , (a , b) , cb'@(CBρ{BV = BVi}{FV = FVi} cbp'')
= _ , CBρ cbp'' ,
bvsub ,
fvsub
where
fvsubS : (set-subtract (fst FVi) (fst (Dom (θo ← θi)))) ⊆¹ (set-subtract (fst FVo) (fst (Dom θo)))
fvsubS x x∈FVi\Dom⟨θo←θi⟩ with set-subtract-merge{fst FVi}{(fst (Dom (θo ← θi)))}{x} x∈FVi\Dom⟨θo←θi⟩
... | (x∈FVi , x∉Dom⟨θo←θi⟩) = set-subtract-notin ((fst b) x (set-subtract-notin x∈FVi x∉Dom⟨θi⟩)) x∉Dom⟨θo⟩
where
x∉Dom⟨θo⟩ : x ∉ fst (Dom θo)
x∉Dom⟨θo⟩ x∈Dom⟨θo⟩ = x∉Dom⟨θo←θi⟩ (sig-←-monoˡ (x ₛ) θo θi x∈Dom⟨θo⟩)
x∉Dom⟨θi⟩ : x ∉ fst (Dom θi)
x∉Dom⟨θi⟩ x∈Dom⟨θi⟩ = x∉Dom⟨θo←θi⟩ (sig-←-monoʳ (x ₛ) θi θo x∈Dom⟨θi⟩)
fvsubs : (set-subtract (snd FVi) (snd (Dom (θo ← θi)))) ⊆¹ (set-subtract (snd FVo) (snd (Dom θo)))
fvsubs x x∈FVi\Dom⟨θo←θi⟩ with set-subtract-merge{snd FVi}{(snd (Dom (θo ← θi)))}{x} x∈FVi\Dom⟨θo←θi⟩
... | (x∈FVi , x∉Dom⟨θo←θi⟩) = set-subtract-notin ((snd b) x (set-subtract-notin x∈FVi x∉Dom⟨θi⟩)) x∉Dom⟨θo⟩
where
x∉Dom⟨θo⟩ : x ∉ snd (Dom θo)
x∉Dom⟨θo⟩ x∈Dom⟨θo⟩ = x∉Dom⟨θo←θi⟩ (shr-←-monoˡ (x ₛₕ) θo θi x∈Dom⟨θo⟩)
x∉Dom⟨θi⟩ : x ∉ snd (Dom θi)
x∉Dom⟨θi⟩ x∈Dom⟨θi⟩ = x∉Dom⟨θo←θi⟩ (shr-←-monoʳ (x ₛₕ) θi θo x∈Dom⟨θi⟩)
fvsubx : (set-subtract (thd FVi) (thd (Dom (θo ← θi)))) ⊆¹ (set-subtract (thd FVo) (thd (Dom θo)))
fvsubx x x∈FVi\Dom⟨θo←θi⟩ with set-subtract-merge{thd FVi}{(thd (Dom (θo ← θi)))}{x} x∈FVi\Dom⟨θo←θi⟩
... | (x∈FVi , x∉Dom⟨θo←θi⟩) = set-subtract-notin ((thd b) x (set-subtract-notin x∈FVi x∉Dom⟨θi⟩)) x∉Dom⟨θo⟩
where
x∉Dom⟨θo⟩ : x ∉ thd (Dom θo)
x∉Dom⟨θo⟩ x∈Dom⟨θo⟩ = x∉Dom⟨θo←θi⟩ (seq-←-monoˡ (x ᵥ) θo θi x∈Dom⟨θo⟩)
x∉Dom⟨θi⟩ : x ∉ thd (Dom θi)
x∉Dom⟨θi⟩ x∈Dom⟨θi⟩ = x∉Dom⟨θo←θi⟩ (seq-←-monoʳ (x ᵥ) θi θo x∈Dom⟨θi⟩)
fvsub : (FVi - (Dom (θo ← θi))) ⊆ (FVo - (Dom θo))
fvsub = fvsubS , fvsubs , fvsubx
bvsubS : ((fst (Dom (θo ← θi))) ++ (fst BVi)) ⊆¹ ((fst (Dom θo)) ++ (fst BVo))
bvsubS x y with ++⁻ (fst (Dom (θo ← θi))) y
... | inj₂ x∈BVi = ++ʳ (fst $ Dom θo) ((fst a) x (++ʳ (fst $ Dom θi) x∈BVi))
... | inj₁ x∈⟨θo←θi⟩ with sig-←⁻{θo}{θi} (x ₛ) x∈⟨θo←θi⟩
... | inj₁ x∈θo = ++ˡ x∈θo
... | inj₂ x∈θi = ++ʳ (fst $ Dom θo) ((fst a) x (++ˡ x∈θi))
bvsubs : ((snd (Dom (θo ← θi))) ++ (snd BVi)) ⊆¹ ((snd (Dom θo)) ++ (snd BVo))
bvsubs x y with ++⁻ (snd (Dom (θo ← θi))) y
... | inj₂ x∈BVi = ++ʳ (snd $ Dom θo) ((snd a) x (++ʳ (snd $ Dom θi) x∈BVi))
... | inj₁ x∈⟨θo←θi⟩ with shr-←⁻{θo}{θi} (x ₛₕ) x∈⟨θo←θi⟩
... | inj₁ x∈θo = ++ˡ x∈θo
... | inj₂ x∈θi = ++ʳ (snd $ Dom θo) ((snd a) x (++ˡ x∈θi))
bvsubx : ((thd (Dom (θo ← θi))) ++ (thd BVi)) ⊆¹ ((thd (Dom θo)) ++ (thd BVo))
bvsubx x y with ++⁻ (thd (Dom (θo ← θi))) y
... | inj₂ x∈BVi = ++ʳ (thd $ Dom θo) ((thd a) x (++ʳ (thd $ Dom θi) x∈BVi))
... | inj₁ x∈⟨θo←θi⟩ with seq-←⁻{θo}{θi} (x ᵥ) x∈⟨θo←θi⟩
... | inj₁ x∈θo = ++ˡ x∈θo
... | inj₂ x∈θi = ++ʳ (thd $ Dom θo) ((thd a) x (++ˡ x∈θi))
bvsub : ((Dom (θo ← θi)) ∪ BVi) ⊆ ((Dom θo) ∪ BVo)
bvsub = bvsubS , bvsubs , bvsubx
-- R-maintains-binding : ∀{p q BV FV} → CorrectBinding p BV FV → p sn⟶₁ q → Σ (VarList × VarList) λ { (BV' , FV') → CorrectBinding q BV' FV' }
sn⟶-maintains-binding : ∀ {p BV FV q} → CorrectBinding p BV FV → p sn⟶ q → Σ (VarList × VarList) λ {(BVq , FVq) → CorrectBinding q BVq FVq × BVq ⊆ BV × FVq ⊆ FV }
sn⟶-maintains-binding CBp (rcontext C dc p₁sn⟶₁q₁)
with binding-extractc' CBp dc
... | (BVp₁ , FVp₁) , CBp₁
with R-maintains-binding CBp₁ p₁sn⟶₁q₁
... | (BVq₁ , FVq₁) , (CBq₁ , BVq₁⊆BVp₁ , FVq₁⊆FVp₁)
with binding-substc' CBp dc CBp₁ BVq₁⊆BVp₁ FVq₁⊆FVp₁ CBq₁
... | (BVq , FVq) , ((BVq⊆BVp , FVq⊆FVp), CBq) =
(BVq , FVq) , (CBq , BVq⊆BVp , FVq⊆FVp)
sn⟶*-maintains-binding : ∀ {p BV FV q} → CorrectBinding p BV FV → p sn⟶* q → Σ (VarList × VarList) λ {(BVq , FVq) → CorrectBinding q BVq FVq}
sn⟶*-maintains-binding cb rrefl = _ , cb
sn⟶*-maintains-binding cb (rstep x psn⟶*q)
= sn⟶*-maintains-binding (proj₁ (proj₂ (sn⟶-maintains-binding cb x))) psn⟶*q
CB-preservation : ∀ p q C → CB (C ⟦ p ⟧c) → p sn⟶₁ q → CB (C ⟦ q ⟧c)
CB-preservation p q C CBp psn⟶₁q with
sn⟶-maintains-binding{p = C ⟦ p ⟧c}{q = C ⟦ q ⟧c} CBp (rcontext C Crefl psn⟶₁q)
... | (BV , FV) , CBq , _ with BVFVcorrect (C ⟦ q ⟧c) BV FV CBq
... | refl , refl = CBq
CB-preservation* : ∀ p q → CB p → p sn⟶* q → CB q
CB-preservation* p q CBp psn⟶*q with
sn⟶*-maintains-binding CBp psn⟶*q
... | (BV , FV) , CBq with BVFVcorrect q BV FV CBq
... | refl , refl = CBq
| {
"alphanum_fraction": 0.5267234388,
"avg_line_length": 49.7177419355,
"ext": "agda",
"hexsha": "0d6ac8b608c08b494f93a3cf718ac265c91719db",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2020-04-15T20:02:49.000Z",
"max_forks_repo_forks_event_min_datetime": "2020-04-15T20:02:49.000Z",
"max_forks_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "florence/esterel-calculus",
"max_forks_repo_path": "agda/binding-preserve.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd",
"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": "florence/esterel-calculus",
"max_issues_repo_path": "agda/binding-preserve.agda",
"max_line_length": 250,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "florence/esterel-calculus",
"max_stars_repo_path": "agda/binding-preserve.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-01T03:59:31.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-16T10:58:53.000Z",
"num_tokens": 12118,
"size": 24660
} |
module sn-calculus-confluence.rec where
open import Data.Nat using (_+_)
open import Function using (_∋_ ; _∘_)
open import Data.Nat.Properties.Simple using ( +-comm ; +-assoc )
open import utility
open import Esterel.Lang
open import Esterel.Lang.Properties
open import Esterel.Environment as Env
open import Esterel.Context
open import Data.Product
open import Data.Sum
open import Data.Bool
open import Data.List
open import Relation.Nullary
open import Relation.Binary.PropositionalEquality
open import Data.Empty
open import sn-calculus
open import context-properties
open import Esterel.Lang.Binding
open import Data.Maybe using ( just )
open import Data.List.Any
open import Data.List.Any.Properties
open import Data.FiniteMap
import Data.OrderedListMap as OMap
open import Data.Nat as Nat using (ℕ)
open import Esterel.Variable.Signal as Signal
using (Signal)
open import Esterel.Variable.Shared as SharedVar
using (SharedVar)
open import Esterel.Variable.Sequential as SeqVar
open import sn-calculus-confluence.helper
open import sn-calculus-confluence.recrec
ρ-conf-rec : ∀{θ El Er ql qr i oli ori qro qlo FV BV θl θr A Al Ar}
→ CorrectBinding (ρ⟨ θ , A ⟩· i) FV BV
→ (ieql : i ≐ El ⟦ ql ⟧e)
→ (ieqr : i ≐ Er ⟦ qr ⟧e)
→ El a~ Er
→ (rl : (ρ⟨ θ , A ⟩· i) sn⟶₁ (ρ⟨ θl , Al ⟩· oli))
→ (rr : (ρ⟨ θ , A ⟩· i) sn⟶₁ (ρ⟨ θr , Ar ⟩· ori))
→ (olieq : oli ≐ El ⟦ qlo ⟧e)
→ (orieq : ori ≐ Er ⟦ qro ⟧e)
→ (->E-view rl ieql olieq)
→ (->E-view rr ieqr orieq)
→ (
Σ[ θo ∈ Env ]
Σ[ Ao ∈ Ctrl ]
Σ[ si ∈ Term ]
Σ[ Elo ∈ EvaluationContext ]
Σ[ Ero ∈ EvaluationContext ]
Σ[ oorieq ∈ ori ≐ Elo ⟦ ql ⟧e ]
Σ[ oolieq ∈ oli ≐ Ero ⟦ qr ⟧e ]
Σ[ sireq ∈ (si ≐ Elo ⟦ qlo ⟧e ) ]
Σ[ sileq ∈ (si ≐ Ero ⟦ qro ⟧e ) ]
Σ[ redl ∈ ((ρ⟨ θl , Al ⟩· oli) sn⟶₁ (ρ⟨ θo , Ao ⟩· si )) ]
Σ[ redr ∈ ((ρ⟨ θr , Ar ⟩· ori) sn⟶₁ (ρ⟨ θo , Ao ⟩· si )) ]
((->E-view redl oolieq sileq) × (->E-view redr oorieq sireq)))
ρ-conf-rec {p₂} {El = El@.(epar₂ _ ∷ _)} {Er@.(epar₁ _ ∷ _)} {i = .(_ ∥ _)} cb (depar₂ ieqr) (depar₁ ieql) par redl redr olieq orieq viewl viewr with ρ-conf-rec2{El = El}{Er} cb (depar₂ ieqr) (depar₁ ieql) par redl redr olieq orieq viewl viewr refl refl
... | (θo , Ao , whatever , Erl , Ero , thig , oolieq , sireq , sileq , rlout , rrout , viewlo , viewro , _) = θo , Ao , whatever , Erl , Ero , thig , oolieq , sireq , sileq , rlout , rrout , viewlo , viewro
ρ-conf-rec {p₂} {El = (epar₁ q ∷ El)} {(epar₂ p ∷ Er)} {i = .(_ ∥ _)}{oli = (olp ∥ .q)}{ori = (.p ∥ orq)} cb@(CBρ (CBpar cbl cbr a b c d)) (depar₁ ieql) (depar₂ ieqr) par2 redl redr (depar₁ olieq) (depar₂ orieq) viewl viewr
with unwrap-rho redl (depar₁ ieql) (depar₁ olieq) ieql olieq viewl | unwrap-rho redr (depar₂ ieqr) (depar₂ orieq) ieqr orieq viewr
... | (redli , viewli) | (redri , viewri) with wrap-rho redli ieql olieq viewli (epar₂ q) (depar₂ ieql) (depar₂ olieq) | wrap-rho redri ieqr orieq viewri (epar₁ p) (depar₁ ieqr) (depar₁ orieq)
... | (redl2 , viewl2) | (redr2 , viewr2) with ρ-conf-rec2{El = epar₂ q ∷ El}{epar₁ p ∷ Er}{oli = oli2}{ori = ori2} (CBρ (CBpar cbr cbl (distinct-sym a) (distinct-sym c) (distinct-sym b) (distinct'-sym d))) (depar₂ ieql) (depar₁ ieqr) par redl2 redr2 (depar₂ olieq) (depar₁ orieq) viewl2 viewr2 refl refl
where
oli2 = Term ∋ (q ∥ olp)
ori2 = orq ∥ p
... | (θo , Ao , ([email protected] ∥ [email protected]) , (epar₂ _ ∷ Erl) , (epar₁ _ ∷ Ero) , (depar₂ oorieq) , (depar₁ oolieq) , (depar₂ sireq) , (depar₁ sileq) , rlout , rrout , viewlo , viewro , ((.Erl , .Ero , _ , _) , refl , refl))
with unwrap-rho rlout (depar₁ oolieq) (depar₁ sileq) oolieq sileq viewlo | unwrap-rho rrout (depar₂ oorieq) (depar₂ sireq) oorieq sireq viewro
... | (roli , roliview) | (rori , roriview)
with wrap-rho roli oolieq sileq roliview (epar₂ sir) (depar₂ oolieq) (depar₂ sileq) | wrap-rho rori oorieq sireq roriview (epar₁ sil) (depar₁ oorieq) (depar₁ sireq)
... | (rolo , roloview) | (roro , roroview) = θo , Ao , sir ∥ sil , epar₁ orq ∷ Erl ,
epar₂ olp ∷ Ero ,
depar₁ oorieq ,
depar₂ oolieq ,
depar₁ sireq , depar₂ sileq , rolo , roro , roloview , roroview -- _ , _ , _ , _ , _ , rolo , roro , roloview , roroview -- {! !}
ρ-conf-rec {El = epar₁ q ∷ El} {epar₁ .q ∷ Er} {ql} {qr} {.(_ ∥ q)} (CBρ (CBpar cb cb₁ x x₁ x₂ x₃)) (depar₁ ieql) (depar₁ ieqr) (parr a~~) redl redr (depar₁ olieq) (depar₁ orieq) viewl viewr
with unwrap-rho redl (depar₁ ieql) (depar₁ olieq) ieql olieq viewl | unwrap-rho redr (depar₁ ieqr) (depar₁ orieq) ieqr orieq viewr
... | (redli , viewli) | (redri , viewri) with ρ-conf-rec (CBρ cb) ieql ieqr a~~ redli redri olieq orieq viewli viewri
... | ( θo , Ao , si , Elo , Ero , oorieq , oolieq , sireq , sileq , rlout , rrout , viewlo , viewro )
with wrap-rho rlout oolieq sileq viewlo (epar₁ q) (depar₁ oolieq) (depar₁ sileq) | wrap-rho rrout oorieq sireq viewro (epar₁ q) (depar₁ oorieq) (depar₁ sireq)
... | (rol , rolview) | (ror , rorview) = θo , Ao , si ∥ q , (epar₁ q) ∷ Elo , (epar₁ q) ∷ Ero , depar₁ oorieq ,
depar₁ oolieq , depar₁ sireq , depar₁ sileq , rol , ror , rolview , rorview
ρ-conf-rec {El = (epar₂ p ∷ El)} {(epar₂ .p ∷ Er)} {i = .(_ ∥ _)} (CBρ (CBpar cb₁ cb x x₁ x₂ x₃)) (depar₂ ieql) (depar₂ ieqr) (parl a~~) redl redr (depar₂ olieq) (depar₂ orieq) viewl viewr
with unwrap-rho redl (depar₂ ieql) (depar₂ olieq) ieql olieq viewl | unwrap-rho redr (depar₂ ieqr) (depar₂ orieq) ieqr orieq viewr
... | (redli , viewli) | (redri , viewri) with ρ-conf-rec (CBρ cb) ieql ieqr a~~ redli redri olieq orieq viewli viewri
... | ( θo , Ao , si , Elo , Ero , oorieq , oolieq , sireq , sileq , rlout , rrout , viewlo , viewro )
with wrap-rho rlout oolieq sileq viewlo (epar₂ p) (depar₂ oolieq) (depar₂ sileq) | wrap-rho rrout oorieq sireq viewro (epar₂ p) (depar₂ oorieq) (depar₂ sireq)
... | (rol , rolview) | (ror , rorview) = θo , Ao , p ∥ si , (epar₂ p) ∷ Elo , (epar₂ p) ∷ Ero , depar₂ oorieq ,
depar₂ oolieq , depar₂ sireq , depar₂ sileq , rol , ror , rolview , rorview
ρ-conf-rec {El = (eseq q ∷ El)} {(eseq .q ∷ Er)} {i = .(_ >> q)} (CBρ (CBseq cb cb₁ x)) (deseq ieql) (deseq ieqr) (seq a~~) redl redr (deseq olieq) (deseq orieq) viewl viewr
with unwrap-rho redl (deseq ieql) (deseq olieq) ieql olieq viewl | unwrap-rho redr (deseq ieqr) (deseq orieq) ieqr orieq viewr
... | (redli , viewli) | (redri , viewri) with ρ-conf-rec (CBρ cb) ieql ieqr a~~ redli redri olieq orieq viewli viewri
... | ( θo , Ao , si , Elo , Ero , oorieq , oolieq , sireq , sileq , rlout , rrout , viewlo , viewro )
with wrap-rho rlout oolieq sileq viewlo (eseq q) (deseq oolieq) (deseq sileq) | wrap-rho rrout oorieq sireq viewro (eseq q) (deseq oorieq) (deseq sireq)
... | (rol , rolview) | (ror , rorview) = θo , Ao , (si >> q) , (eseq q) ∷ Elo , (eseq q) ∷ Ero , deseq oorieq ,
deseq oolieq , deseq sireq , deseq sileq , rol , ror , rolview , rorview
ρ-conf-rec {El = (eloopˢ q ∷ El)} {(eloopˢ .q ∷ Er)} {i = .(loopˢ _ q)} (CBρ (CBloopˢ cb cb₁ x _)) (deloopˢ ieql) (deloopˢ ieqr) (loopˢ a~~) redl redr (deloopˢ olieq) (deloopˢ orieq) viewl viewr
with unwrap-rho redl (deloopˢ ieql) (deloopˢ olieq) ieql olieq viewl | unwrap-rho redr (deloopˢ ieqr) (deloopˢ orieq) ieqr orieq viewr
... | (redli , viewli) | (redri , viewri) with ρ-conf-rec (CBρ cb) ieql ieqr a~~ redli redri olieq orieq viewli viewri
... | ( θo , Ao , si , Elo , Ero , oorieq , oolieq , sireq , sileq , rlout , rrout , viewlo , viewro )
with wrap-rho rlout oolieq sileq viewlo (eloopˢ q) (deloopˢ oolieq) (deloopˢ sileq) | wrap-rho rrout oorieq sireq viewro (eloopˢ q) (deloopˢ oorieq) (deloopˢ sireq)
... | (rol , rolview) | (ror , rorview) = θo , Ao , (loopˢ si q) , (eloopˢ q) ∷ Elo , (eloopˢ q) ∷ Ero , deloopˢ oorieq ,
deloopˢ oolieq , deloopˢ sireq , deloopˢ sileq , rol , ror , rolview , rorview
ρ-conf-rec {El = (esuspend S ∷ El)} {(esuspend .S ∷ Er)} {i = .(suspend _ _)} (CBρ (CBsusp cb x)) (desuspend ieql) (desuspend ieqr) (susp a~~) redl redr (desuspend olieq) (desuspend orieq) viewl viewr
with unwrap-rho redl (desuspend ieql) (desuspend olieq) ieql olieq viewl | unwrap-rho redr (desuspend ieqr) (desuspend orieq) ieqr orieq viewr
... | (redli , viewli) | (redri , viewri) with ρ-conf-rec (CBρ cb) ieql ieqr a~~ redli redri olieq orieq viewli viewri
... | ( θo , Ao , si , Elo , Ero , oorieq , oolieq , sireq , sileq , rlout , rrout , viewlo , viewro )
with wrap-rho rlout oolieq sileq viewlo (esuspend S) (desuspend oolieq) (desuspend sileq) | wrap-rho rrout oorieq sireq viewro (esuspend S) (desuspend oorieq) (desuspend sireq)
... | (rol , rolview) | (ror , rorview) = θo , Ao , (suspend si S) , (esuspend S) ∷ Elo , (esuspend S) ∷ Ero , desuspend oorieq ,
desuspend oolieq , desuspend sireq , desuspend sileq , rol , ror , rolview , rorview
ρ-conf-rec {El = (etrap ∷ El)} {(etrap ∷ Er)} {i = .(trap _)} (CBρ (CBtrap cb)) (detrap ieql) (detrap ieqr) (trp a~~) redl redr (detrap olieq) (detrap orieq) viewl viewr
with unwrap-rho redl (detrap ieql) (detrap olieq) ieql olieq viewl | unwrap-rho redr (detrap ieqr) (detrap orieq) ieqr orieq viewr
... | (redli , viewli) | (redri , viewri) with ρ-conf-rec (CBρ cb) ieql ieqr a~~ redli redri olieq orieq viewli viewri
... | ( θo , Ao , si , Elo , Ero , oorieq , oolieq , sireq , sileq , rlout , rrout , viewlo , viewro )
with wrap-rho rlout oolieq sileq viewlo (etrap) (detrap oolieq) (detrap sileq) | wrap-rho rrout oorieq sireq viewro (etrap) (detrap oorieq) (detrap sireq)
... | (rol , rolview) | (ror , rorview) = θo , Ao , (trap si) , (etrap) ∷ Elo , (etrap) ∷ Ero , detrap oorieq ,
detrap oolieq , detrap sireq , detrap sileq , rol , ror , rolview , rorview
| {
"alphanum_fraction": 0.5855077905,
"avg_line_length": 81.9538461538,
"ext": "agda",
"hexsha": "dcc396fd7702724c7d5dbb61bc3ecf950d6f3ead",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2020-04-15T20:02:49.000Z",
"max_forks_repo_forks_event_min_datetime": "2020-04-15T20:02:49.000Z",
"max_forks_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "florence/esterel-calculus",
"max_forks_repo_path": "agda/sn-calculus-confluence/rec.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd",
"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": "florence/esterel-calculus",
"max_issues_repo_path": "agda/sn-calculus-confluence/rec.agda",
"max_line_length": 305,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "florence/esterel-calculus",
"max_stars_repo_path": "agda/sn-calculus-confluence/rec.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-01T03:59:31.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-16T10:58:53.000Z",
"num_tokens": 4113,
"size": 10654
} |
{-# OPTIONS --without-K #-}
module hott.level where
open import hott.level.core public
open import hott.level.sets public
open import hott.level.closure public
| {
"alphanum_fraction": 0.7763975155,
"avg_line_length": 23,
"ext": "agda",
"hexsha": "c647d331815e8461829de5b72fe6e4efa45ae869",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2019-02-26T06:17:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-04-11T17:19:12.000Z",
"max_forks_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "HoTT/M-types",
"max_forks_repo_path": "hott/level.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c",
"max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "pcapriotti/agda-base",
"max_issues_repo_path": "src/hott/level.agda",
"max_line_length": 37,
"max_stars_count": 27,
"max_stars_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "HoTT/M-types",
"max_stars_repo_path": "hott/level.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-09T07:26:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-14T15:47:03.000Z",
"num_tokens": 34,
"size": 161
} |
{-# OPTIONS --safe #-}
module Cubical.Algebra.DirectSum.Equiv-DSHIT-DSFun where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Transport
open import Cubical.Relation.Nullary
open import Cubical.Data.Empty as ⊥
open import Cubical.Data.Nat renaming (_+_ to _+n_)
open import Cubical.Data.Nat.Order
open import Cubical.Data.Sigma
open import Cubical.Data.Sum
open import Cubical.Data.Vec
open import Cubical.Data.Vec.DepVec
open import Cubical.HITs.PropositionalTruncation as PT
open import Cubical.Algebra.Group
open import Cubical.Algebra.Group.Morphisms
open import Cubical.Algebra.Group.MorphismProperties
open import Cubical.Algebra.AbGroup
open import Cubical.Algebra.AbGroup.Instances.DirectSumFun
open import Cubical.Algebra.AbGroup.Instances.DirectSumHIT
open import Cubical.Algebra.AbGroup.Instances.NProd
open import Cubical.Algebra.DirectSum.DirectSumFun.Base
open import Cubical.Algebra.DirectSum.DirectSumHIT.Base
open import Cubical.Algebra.DirectSum.DirectSumHIT.Properties
open import Cubical.Algebra.DirectSum.DirectSumHIT.PseudoNormalForm
private variable
ℓ : Level
open GroupTheory
open AbGroupTheory
open AbGroupStr
-----------------------------------------------------------------------------
-- Notation
module Equiv-Properties
(G : ℕ → Type ℓ)
(Gstr : (n : ℕ) → AbGroupStr (G n))
where
-- the convention is a bit different and had a -
-- because otherwise it is unreadable
open AbGroupStr (snd (⊕HIT-AbGr ℕ G Gstr)) using ()
renaming
( 0g to 0⊕HIT
; _+_ to _+⊕HIT_
; -_ to -⊕HIT_
; +Assoc to +⊕HIT-Assoc
; +IdR to +⊕HIT-IdR
; +IdL to +⊕HIT-IdL
; +InvR to +⊕HIT-InvR
; +InvL to +⊕HIT-InvL
; +Comm to +⊕HIT-Comm
; is-set to isSet⊕HIT)
open AbGroupStr (snd (⊕Fun-AbGr G Gstr)) using ()
renaming
( 0g to 0⊕Fun
; _+_ to _+⊕Fun_
; -_ to -⊕Fun_
; +Assoc to +⊕Fun-Assoc
; +IdR to +⊕Fun-IdR
; +IdL to +⊕Fun-IdL
; +InvR to +⊕Fun-InvR
; +InvL to +⊕Fun-InvL
; +Comm to +⊕Fun-Comm
; is-set to isSet⊕Fun)
-----------------------------------------------------------------------------
-- AbGroup on Fun -> produit ? sequence ?
open AbGroupStr (snd (NProd-AbGroup G Gstr)) using ()
renaming
( 0g to 0Fun
; _+_ to _+Fun_
; -_ to -Fun_
; +Assoc to +FunAssoc
; +IdR to +FunIdR
; +IdL to +FunIdL
; +InvR to +FunInvR
; +InvL to +FunInvL
; +Comm to +FunComm
; is-set to isSetFun)
-----------------------------------------------------------------------------
-- Some simplification for transport
open SubstLemma ℕ G Gstr
substG : (g : (n : ℕ) → G n) → {k n : ℕ} → (p : k ≡ n) → subst G p (g k) ≡ g n
substG g {k} {n} p = J (λ n p → subst G p (g k) ≡ g n) (transportRefl _) p
-----------------------------------------------------------------------------
-- Direct Sense
-- To facilitate the proof the translation to the function
-- and its properties are done in two times
---------------------------------------------------------------------------
-- Translation to the function
fun-trad : (k : ℕ) → (a : G k) → (n : ℕ) → G n
fun-trad k a n with (discreteℕ k n)
... | yes p = subst G p a
... | no ¬p = 0g (Gstr n)
fun-trad-eq : (k : ℕ) → (a : G k) → fun-trad k a k ≡ a
fun-trad-eq k a with discreteℕ k k
... | yes p = cong (λ X → subst G X a) (isSetℕ _ _ _ _) ∙ transportRefl a
... | no ¬p = ⊥.rec (¬p refl)
fun-trad-neq : (k : ℕ) → (a : G k) → (n : ℕ) → (k ≡ n → ⊥) → fun-trad k a n ≡ 0g (Gstr n)
fun-trad-neq k a n ¬q with discreteℕ k n
... | yes p = ⊥.rec (¬q p)
... | no ¬p = refl
⊕HIT→Fun : ⊕HIT ℕ G Gstr → (n : ℕ) → G n
⊕HIT→Fun = DS-Rec-Set.f _ _ _ _ isSetFun
0Fun
fun-trad
_+Fun_
+FunAssoc
+FunIdR
+FunComm
(λ k → funExt (λ n → base0-eq k n))
λ k a b → funExt (λ n → base-add-eq k a b n)
where
base0-eq : (k : ℕ) → (n : ℕ) → fun-trad k (0g (Gstr k)) n ≡ 0g (Gstr n)
base0-eq k n with (discreteℕ k n)
... | yes p = subst0g _
... | no ¬p = refl
base-add-eq : (k : ℕ) → (a b : G k) → (n : ℕ) →
PathP (λ _ → G n) (Gstr n ._+_ (fun-trad k a n) (fun-trad k b n))
(fun-trad k ((Gstr k + a) b) n)
base-add-eq k a b n with (discreteℕ k n)
... | yes p = subst+ _ _ _
... | no ¬p = +IdR (Gstr n)_
⊕HIT→Fun-pres0 : ⊕HIT→Fun 0⊕HIT ≡ 0Fun
⊕HIT→Fun-pres0 = refl
⊕HIT→Fun-pres+ : (x y : ⊕HIT ℕ G Gstr) → ⊕HIT→Fun (x +⊕HIT y) ≡ ((⊕HIT→Fun x) +Fun (⊕HIT→Fun y))
⊕HIT→Fun-pres+ x y = refl
---------------------------------------------------------------------------
-- Translation to the properties
nfun-trad : (k : ℕ) → (a : G k) → AlmostNull G Gstr (fun-trad k a)
nfun-trad k a = k , fix-eq
where
fix-eq : (n : ℕ) → k < n → fun-trad k a n ≡ 0g (Gstr n)
fix-eq n q with (discreteℕ k n)
... | yes p = ⊥.rec (<→≢ q p)
... | no ¬p = refl
⊕HIT→⊕AlmostNull : (x : ⊕HIT ℕ G Gstr) → AlmostNullP G Gstr (⊕HIT→Fun x)
⊕HIT→⊕AlmostNull = DS-Ind-Prop.f _ _ _ _ (λ x → squash₁)
∣ (0 , (λ n q → refl)) ∣₁
(λ r a → ∣ (nfun-trad r a) ∣₁)
λ {U} {V} → PT.elim (λ _ → isPropΠ (λ _ → squash₁))
(λ { (k , nu) → PT.elim (λ _ → squash₁)
λ { (l , nv) →
∣ ((k +n l) , (λ n q → cong₂ ((Gstr n)._+_) (nu n (<-+k-trans q)) (nv n (<-k+-trans q))
∙ +IdR (Gstr n) _)) ∣₁} })
---------------------------------------------------------------------------
-- Translation + Morphism
⊕HIT→⊕Fun : ⊕HIT ℕ G Gstr → ⊕Fun G Gstr
⊕HIT→⊕Fun x = (⊕HIT→Fun x) , (⊕HIT→⊕AlmostNull x)
⊕HIT→⊕Fun-pres0 : ⊕HIT→⊕Fun 0⊕HIT ≡ 0⊕Fun
⊕HIT→⊕Fun-pres0 = refl
⊕HIT→⊕Fun-pres+ : (x y : ⊕HIT ℕ G Gstr) → ⊕HIT→⊕Fun (x +⊕HIT y) ≡ ((⊕HIT→⊕Fun x) +⊕Fun (⊕HIT→⊕Fun y))
⊕HIT→⊕Fun-pres+ x y = ΣPathTransport→PathΣ _ _ (refl , (squash₁ _ _))
-----------------------------------------------------------------------------
-- Converse sense
-----------------------------------------------------------------------------
-- Prood that ⊕HIT→⊕Fun is injective
open DefPNF G Gstr
sumFun : {m : ℕ} → depVec G m → (n : ℕ) → G n
sumFun {0} ⋆ = 0Fun
sumFun {suc m} (a □ dv) = (⊕HIT→Fun (base m a)) +Fun (sumFun dv)
SumHIT→SumFun : {m : ℕ} → (dv : depVec G m) → ⊕HIT→Fun (sumHIT dv) ≡ sumFun dv
SumHIT→SumFun {0} ⋆ = refl
SumHIT→SumFun {suc m} (a □ dv) = cong₂ _+Fun_ refl (SumHIT→SumFun dv)
sumFun< : {m : ℕ} → (dv : depVec G m) → (i : ℕ) → (m ≤ i) → sumFun dv i ≡ 0g (Gstr i)
sumFun< {0} ⋆ i r = refl
sumFun< {suc m} (a □ dv) i r with discreteℕ m i
... | yes p = ⊥.rec (<→≢ r p)
... | no ¬p = +IdL (Gstr i) _ ∙ sumFun< dv i (≤-trans ≤-sucℕ r)
sumFunHead : {m : ℕ} → (a b : (G m)) → (dva dvb : depVec G m) →
(x : sumFun (a □ dva) ≡ sumFun (b □ dvb)) → a ≡ b
sumFunHead {m} a b dva dvb x =
a
≡⟨ sym (+IdR (Gstr m) _) ⟩
(Gstr m)._+_ a (0g (Gstr m))
≡⟨ cong₂ (Gstr m ._+_) (sym (fun-trad-eq m a)) (sym (sumFun< dva m ≤-refl)) ⟩
(Gstr m)._+_ (fun-trad m a m) (sumFun dva m)
≡⟨ funExt⁻ x m ⟩
(Gstr m)._+_ (fun-trad m b m) (sumFun dvb m)
≡⟨ cong₂ (Gstr m ._+_) (fun-trad-eq m b) (sumFun< dvb m ≤-refl) ⟩
(Gstr m)._+_ b (0g (Gstr m))
≡⟨ +IdR (Gstr m) _ ⟩
b ∎
substSumFun : {m : ℕ} → (dv : depVec G m) → (n : ℕ) → (p : m ≡ n)
→ subst G p (sumFun dv m) ≡ sumFun dv n
substSumFun {m} dv n p = J (λ n p → subst G p (sumFun dv m) ≡ sumFun dv n)
(transportRefl _)
p
sumFunTail : {m : ℕ} → (a b : (G m)) → (dva dvb : depVec G m) →
(x : sumFun (a □ dva) ≡ sumFun (b □ dvb)) → (n : ℕ) →
sumFun dva n ≡ sumFun dvb n
sumFunTail {m} a b dva dvb x n with discreteℕ m n
... | yes p = sumFun dva n ≡⟨ sym (substSumFun dva n p) ⟩
subst G p (sumFun dva m) ≡⟨ cong (subst G p) (sumFun< dva m ≤-refl) ⟩
subst G p (0g (Gstr m)) ≡⟨ subst0g p ⟩
0g (Gstr n) ≡⟨ sym (subst0g p) ⟩
subst G p (0g (Gstr m)) ≡⟨ sym (cong (subst G p) (sumFun< dvb m ≤-refl)) ⟩
subst G p (sumFun dvb m) ≡⟨ substSumFun dvb n p ⟩
sumFun dvb n ∎
... | no ¬p = sumFun dva n ≡⟨ sym (+IdL (Gstr n) _) ⟩
(Gstr n)._+_ (0g (Gstr n)) (sumFun dva n) ≡⟨ cong (λ X → (Gstr n)._+_ X (sumFun dva n))
(sym (fun-trad-neq m a n ¬p)) ⟩
Gstr n ._+_ (fun-trad m a n) (sumFun dva n) ≡⟨ funExt⁻ x n ⟩
Gstr n ._+_ (fun-trad m b n) (sumFun dvb n) ≡⟨ cong (λ X → Gstr n ._+_ X (sumFun dvb n))
(fun-trad-neq m b n ¬p) ⟩
(Gstr n)._+_ (0g (Gstr n)) (sumFun dvb n) ≡⟨ +IdL (Gstr n) _ ⟩
sumFun dvb n ∎
injSumFun : {m : ℕ} → (dva dvb : depVec G m) → sumFun dva ≡ sumFun dvb → dva ≡ dvb
injSumFun {0} ⋆ ⋆ x = refl
injSumFun {suc m} (a □ dva) (b □ dvb) x = depVecPath.decode G (a □ dva) (b □ dvb)
((sumFunHead a b dva dvb x)
, (injSumFun dva dvb (funExt (sumFunTail a b dva dvb x))))
injSumHIT : {m : ℕ} → (dva dvb : depVec G m) → ⊕HIT→Fun (sumHIT dva) ≡ ⊕HIT→Fun (sumHIT dvb) → dva ≡ dvb
injSumHIT dva dvb r = injSumFun dva dvb (sym (SumHIT→SumFun dva) ∙ r ∙ SumHIT→SumFun dvb)
inj-⊕HIT→Fun : (x y : ⊕HIT ℕ G Gstr) → ⊕HIT→Fun x ≡ ⊕HIT→Fun y → x ≡ y
inj-⊕HIT→Fun x y r = helper (⊕HIT→PNF2 x y) r
where
helper : PNF2 x y → ⊕HIT→Fun x ≡ ⊕HIT→Fun y → x ≡ y
helper = PT.elim (λ _ → isPropΠ (λ _ → isSet⊕HIT _ _))
λ { (m , dva , dvb , p , q) r →
p
∙ cong sumHIT (injSumHIT dva dvb (sym (cong ⊕HIT→Fun p) ∙ r ∙ cong ⊕HIT→Fun q))
∙ sym q}
inj-⊕HIT→⊕Fun : (x y : ⊕HIT ℕ G Gstr) → ⊕HIT→⊕Fun x ≡ ⊕HIT→⊕Fun y → x ≡ y
inj-⊕HIT→⊕Fun x y p = inj-⊕HIT→Fun x y (fst (PathΣ→ΣPathTransport _ _ p))
lemProp : (g : ⊕Fun G Gstr) → isProp (Σ[ x ∈ ⊕HIT ℕ G Gstr ] ⊕HIT→⊕Fun x ≡ g )
lemProp g (x , p) (y , q) = ΣPathTransport→PathΣ _ _
((inj-⊕HIT→⊕Fun x y (p ∙ sym q)) , isSet⊕Fun _ _ _ _)
---------------------------------------------------------------------------
-- General translation for underliyng function
Strad : (g : (n : ℕ) → G n) → (i : ℕ) → ⊕HIT ℕ G Gstr
Strad g zero = base 0 (g 0)
Strad g (suc i) = (base (suc i) (g (suc i))) +⊕HIT (Strad g i)
Strad-pres+ : (f g : (n : ℕ) → G n) → (i : ℕ) → Strad (f +Fun g) i ≡ Strad f i +⊕HIT Strad g i
Strad-pres+ f g zero = sym (base-add 0 (f 0) (g 0))
Strad-pres+ f g (suc i) = cong₂ _+⊕HIT_ (sym (base-add _ _ _))
(Strad-pres+ f g i)
∙ comm-4 (⊕HIT-AbGr ℕ G Gstr) _ _ _ _
-- Properties in the converse sens
Strad-max : (f : (n : ℕ) → G n) → (k : ℕ) → (ng : AlmostNullProof G Gstr f k)
→ (i : ℕ) → (r : k ≤ i) → Strad f i ≡ Strad f k
Strad-max f k ng zero r = sym (cong (Strad f) (≤0→≡0 r))
Strad-max f k ng (suc i) r with ≤-split r
... | inl x = cong₂ _+⊕HIT_
(cong (base (suc i)) (ng (suc i) x) ∙ base-neutral (suc i))
(Strad-max f k ng i (pred-≤-pred x))
∙ +⊕HIT-IdL _
... | inr x = cong (Strad f) (sym x)
-- if m < n then the translation of sum up to i is 0
Strad-m<n : (g : (n : ℕ) → G n) → (m : ℕ) → (n : ℕ) → (r : m < n)
→ ⊕HIT→Fun (Strad g m) n ≡ 0g (Gstr n)
Strad-m<n g zero n r with discreteℕ 0 n
... | yes p = ⊥.rec (<→≢ r p)
... | no ¬p = refl
Strad-m<n g (suc m) n r with discreteℕ (suc m) n
... | yes p = ⊥.rec (<→≢ r p)
... | no ¬p = +IdL (Gstr n) _ ∙ Strad-m<n g m n (<-trans ≤-refl r)
{- if n ≤ m, prove ⊕HIT→Fun (∑_{i ∈〚0, m〛} base i (g i)) ≡ g n
then n is equal to only one〚0, m〛=> induction on m
case 0 : ok
case suc m : if n ≡ suc m, then the rest of the sum is 0 by trad-m<n
if n ≢ suc m, then it is in the rest of the sum => recursive call -}
Strad-n≤m : (g : (n : ℕ) → G n) → (m : ℕ) → (n : ℕ) → (r : n ≤ m) → ⊕HIT→Fun (Strad g m) n ≡ g n
Strad-n≤m g zero n r with discreteℕ 0 n
... | yes p = substG g p
... | no ¬p = ⊥.rec (¬p (sym (≤0→≡0 r)))
Strad-n≤m g (suc m) n r with discreteℕ (suc m) n
... | yes p = cong₂ ((Gstr n)._+_) (substG g p) (Strad-m<n g m n (0 , p)) ∙ +IdR (Gstr n) _
... | no ¬p = +IdL (Gstr n) _ ∙ Strad-n≤m g m n (≤-suc-≢ r λ x → ¬p (sym x))
---------------------------------------------------------------------------
-- Translation + Morphsim
-- translation
⊕Fun→⊕HIT+ : (g : ⊕Fun G Gstr) → Σ[ x ∈ ⊕HIT ℕ G Gstr ] ⊕HIT→⊕Fun x ≡ g
⊕Fun→⊕HIT+ (g , Ang) = PT.rec (lemProp (g , Ang))
(λ { (k , ng)
→ Strad g k , ΣPathTransport→PathΣ _ _
((funExt (trad-section g k ng)) , (squash₁ _ _)) })
Ang
where
trad-section : (g : (n : ℕ) → G n) → (k : ℕ) → (ng : (n : ℕ) → ( k < n) → g n ≡ 0g (Gstr n))
→ (n : ℕ) → ⊕HIT→Fun (Strad g k) n ≡ g n
trad-section g k ng n with splitℕ-≤ n k
... | inl x = Strad-n≤m g k n x
... | inr x = Strad-m<n g k n x ∙ sym (ng n x)
⊕Fun→⊕HIT : ⊕Fun G Gstr → ⊕HIT ℕ G Gstr
⊕Fun→⊕HIT g = fst (⊕Fun→⊕HIT+ g)
-- morphism
⊕Fun→⊕HIT-pres0 : ⊕Fun→⊕HIT 0⊕Fun ≡ 0⊕HIT
⊕Fun→⊕HIT-pres0 = base-neutral 0
⊕Fun→⊕HIT-pres+ : (f g : ⊕Fun G Gstr) → ⊕Fun→⊕HIT (f +⊕Fun g) ≡ (⊕Fun→⊕HIT f) +⊕HIT (⊕Fun→⊕HIT g)
⊕Fun→⊕HIT-pres+ (f , Anf) (g , Ang) = PT.elim2 (λ x y → isSet⊕HIT (⊕Fun→⊕HIT ((f , x) +⊕Fun (g , y)))
((⊕Fun→⊕HIT (f , x)) +⊕HIT (⊕Fun→⊕HIT (g , y))))
(λ x y → AN f x g y)
Anf Ang
where
AN : (f : (n : ℕ) → G n) → (x : AlmostNull G Gstr f) → (g : (n : ℕ) → G n) → (y : AlmostNull G Gstr g)
→ ⊕Fun→⊕HIT ((f , ∣ x ∣₁) +⊕Fun (g , ∣ y ∣₁)) ≡ (⊕Fun→⊕HIT (f , ∣ x ∣₁)) +⊕HIT (⊕Fun→⊕HIT (g , ∣ y ∣₁))
AN f (k , nf) g (l , ng) = Strad-pres+ f g (k +n l)
∙ cong₂ _+⊕HIT_ (Strad-max f k nf (k +n l) (l , (+-comm l k)))
(Strad-max g l ng (k +n l) (k , refl))
-----------------------------------------------------------------------------
-- Section
e-sect : (g : ⊕Fun G Gstr) → ⊕HIT→⊕Fun (⊕Fun→⊕HIT g) ≡ g
e-sect g = snd (⊕Fun→⊕HIT+ g)
-----------------------------------------------------------------------------
-- Retraction
lemmaSkk : (k : ℕ) → (a : G k) → (i : ℕ) → (r : i < k) → Strad (λ n → fun-trad k a n) i ≡ 0⊕HIT
lemmaSkk k a zero r with discreteℕ k 0
... | yes p = ⊥.rec (<→≢ r (sym p))
... | no ¬p = base-neutral 0
lemmaSkk k a (suc i) r with discreteℕ k (suc i)
... | yes p = ⊥.rec (<→≢ r (sym p))
... | no ¬p = cong₂ _+⊕HIT_ (base-neutral (suc i)) (lemmaSkk k a i (<-trans ≤-refl r)) ∙ +⊕HIT-IdR _
lemmakk : (k : ℕ) → (a : G k) → ⊕Fun→⊕HIT (⊕HIT→⊕Fun (base k a)) ≡ base k a
lemmakk zero a = cong (base 0) (transportRefl a)
lemmakk (suc k) a with (discreteℕ (suc k) (suc k)) | (discreteℕ k k)
... | yes p | yes q = cong₂ _add_
(sym (constSubstCommSlice G (⊕HIT ℕ G Gstr) base (cong suc q) a))
(lemmaSkk (suc k) a k ≤-refl)
∙ +⊕HIT-IdR _
... | yes p | no ¬q = ⊥.rec (¬q refl)
... | no ¬p | yes q = ⊥.rec (¬p refl)
... | no ¬p | no ¬q = ⊥.rec (¬q refl)
e-retr : (x : ⊕HIT ℕ G Gstr) → ⊕Fun→⊕HIT (⊕HIT→⊕Fun x) ≡ x
e-retr = DS-Ind-Prop.f _ _ _ _ (λ _ → isSet⊕HIT _ _)
(base-neutral 0)
lemmakk
λ {U} {V} ind-U ind-V → cong ⊕Fun→⊕HIT (⊕HIT→⊕Fun-pres+ U V)
∙ ⊕Fun→⊕HIT-pres+ (⊕HIT→⊕Fun U) (⊕HIT→⊕Fun V)
∙ cong₂ _+⊕HIT_ ind-U ind-V
module _
(G : ℕ → Type ℓ)
(Gstr : (n : ℕ) → AbGroupStr (G n))
where
open Iso
open Equiv-Properties G Gstr
Equiv-DirectSum : AbGroupEquiv (⊕HIT-AbGr ℕ G Gstr) (⊕Fun-AbGr G Gstr)
fst Equiv-DirectSum = isoToEquiv is
where
is : Iso (⊕HIT ℕ G Gstr) (⊕Fun G Gstr)
fun is = ⊕HIT→⊕Fun
Iso.inv is = ⊕Fun→⊕HIT
rightInv is = e-sect
leftInv is = e-retr
snd Equiv-DirectSum = makeIsGroupHom ⊕HIT→⊕Fun-pres+
| {
"alphanum_fraction": 0.4474621038,
"avg_line_length": 40.9788235294,
"ext": "agda",
"hexsha": "64df16dcae562f212806fd2a254507c1902d2c0b",
"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/DirectSum/Equiv-DSHIT-DSFun.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/DirectSum/Equiv-DSHIT-DSFun.agda",
"max_line_length": 124,
"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/DirectSum/Equiv-DSHIT-DSFun.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 6914,
"size": 17416
} |
-- The empty type; also used as absurd proposition (``Falsity'').
{-# OPTIONS --without-K --safe #-}
module Tools.Empty where
open import Data.Empty public
| {
"alphanum_fraction": 0.6981132075,
"avg_line_length": 19.875,
"ext": "agda",
"hexsha": "d93d25ffaf7f6ffbf6c06e2d64e16d80be0125b5",
"lang": "Agda",
"max_forks_count": 8,
"max_forks_repo_forks_event_max_datetime": "2021-11-27T15:58:33.000Z",
"max_forks_repo_forks_event_min_datetime": "2017-10-18T14:18:20.000Z",
"max_forks_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Vtec234/logrel-mltt",
"max_forks_repo_path": "Tools/Empty.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69",
"max_issues_repo_issues_event_max_datetime": "2021-02-22T10:37:24.000Z",
"max_issues_repo_issues_event_min_datetime": "2017-06-22T12:49:23.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Vtec234/logrel-mltt",
"max_issues_repo_path": "Tools/Empty.agda",
"max_line_length": 65,
"max_stars_count": 30,
"max_stars_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Vtec234/logrel-mltt",
"max_stars_repo_path": "Tools/Empty.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:01:07.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-05-20T03:05:21.000Z",
"num_tokens": 37,
"size": 159
} |
module STT where
-- simple type theory
{-
open import Data.Bool
open import Relation.Binary.PropositionalEquality
open import Data.Nat hiding (_>_)
-}
open import StdLibStuff
open import Syntax
-- inference system
data ⊢_ : ∀ {n} → {Γ : Ctx n} → Form Γ $o → Set where
ax-1 : ∀ {n} → {Γ : Ctx n} {x : Var Γ} →
(p : lookup-Var Γ x ≡ $o) →
⊢ ((var x p || var x p) => var x p)
ax-2 : ∀ {n} → {Γ : Ctx n} {x y : Var Γ} →
(px : lookup-Var Γ x ≡ $o) →
(py : lookup-Var Γ y ≡ $o) →
⊢ (var x px => (var x px || var y py))
ax-3 : ∀ {n} → {Γ : Ctx n} {x y : Var Γ} →
(px : lookup-Var Γ x ≡ $o) →
(py : lookup-Var Γ y ≡ $o) →
⊢ ((var x px || var y py) => (var y py || var x px))
ax-4 : ∀ {n} → {Γ : Ctx n} {x y z : Var Γ} →
(px : lookup-Var Γ x ≡ $o) →
(py : lookup-Var Γ y ≡ $o) →
(pz : lookup-Var Γ z ≡ $o) →
⊢ ((var x px => var y py) => ((var z pz || var x px) => (var z pz || var y py)))
ax-5 : ∀ {n} → {Γ : Ctx n} {α : Type n} {x y : Var Γ} →
(px : lookup-Var Γ x ≡ α > $o) →
(py : lookup-Var Γ y ≡ α) →
⊢ (app Π (var x px) => app (var x px) (var y py))
ax-6 : ∀ {n} → {Γ : Ctx n} {α : Type n} {x y : Var Γ} →
(px : lookup-Var Γ x ≡ α > $o) →
(py : lookup-Var Γ y ≡ $o) →
⊢ ((![ α ] (weak (var y py) || app (weak (var x px)) (var this refl))) => (var y py || app Π (var x px)))
ax-10-a : ∀ {n} → {Γ : Ctx n} {x y : Var Γ} →
(px : lookup-Var Γ x ≡ $o) →
(py : lookup-Var Γ y ≡ $o) →
⊢ ((var x px <=> var y py) => (var x px == var y py))
ax-10-b : ∀ {n} → {Γ : Ctx n} {α β : Type n} {f g : Var Γ} →
(pf : lookup-Var Γ f ≡ α > β) →
(pg : lookup-Var Γ g ≡ α > β) →
⊢ ((![ α ] (app (weak (var f pf)) (var this refl) == app (weak (var g pg)) (var this refl))) => (var f pf == var g pg))
ax-11 : ∀ {n} → {Γ : Ctx n} {α : Type n} {f : Var Γ} →
(pf : lookup-Var Γ f ≡ α > $o) →
⊢ ((?[ α ] (app (weak (var f pf)) (var this refl))) => (app (var f pf) (app i (var f pf))))
-- inf-I in Henkin is α-conversion
-- with de Bruijn-indeces we need context extension instead
extend-context : ∀ {n} {Γ : Ctx n} (α : Type n) {F : Form Γ $o} →
⊢_ {_} {α ∷ Γ} (weak F) →
⊢ F
inf-II : ∀ {n} → (Γ Γ' : Ctx n) {α β : Type n} (F : Form (Γ' ++ Γ) β → Form Γ $o) (G : Form (α ∷ (Γ' ++ Γ)) β) (H : Form (Γ' ++ Γ) α) →
⊢ (F ((^[ α ] G) · H) => F (sub H G)) -- formulated as an inference rule in Henkin, as an axiom (containing expressions) here
inf-III : ∀ {n} → (Γ Γ' : Ctx n) {α β : Type n} (F : Form (Γ' ++ Γ) β → Form Γ $o) (G : Form (α ∷ (Γ' ++ Γ)) β) (H : Form (Γ' ++ Γ) α) →
⊢ (F (sub H G) => F ((^[ α ] G) · H)) -- formulated as an inference rule in Henkin, as an axiom (containing expressions) here
inf-IV : ∀ {n} → {Γ : Ctx n} {α : Type n} (F : Form Γ (α > $o)) (x : Var Γ) (G : Form Γ α) →
occurs x F ≡ false →
(p : lookup-Var Γ x ≡ α) →
⊢ (app F (var x p)) →
⊢ (app F G)
inf-V : ∀ {n} → {Γ : Ctx n} {F G : Form Γ $o} →
⊢ (F => G) → ⊢ F →
⊢ G
inf-VI : ∀ {n} → {Γ : Ctx n} {α : Type n} {F : Form Γ (α > $o)} (x : Var Γ) →
occurs x F ≡ false →
(p : lookup-Var Γ x ≡ α) →
⊢ (app F (var x p) => app Π F) -- formulated as an inference rule in Henkin, as an axiom (containing expressions) here
-- -------------------------
-- Variants of the axioms that are simpler to work with
ax-1-s : ∀ {n} → {Γ : Ctx n} {F : Form Γ $o} →
⊢ ((F || F) => F)
ax-2-s : ∀ {n} → {Γ : Ctx n} {F G : Form Γ $o} →
⊢ (F => (F || G))
ax-3-s : ∀ {n} → {Γ : Ctx n} {F G : Form Γ $o} →
⊢ ((F || G) => (G || F))
ax-4-s : ∀ {n} → {Γ : Ctx n} {F G H : Form Γ $o} →
⊢ ((F => G) => ((H || F) => (H || G)))
ax-5-s : ∀ {n} → {Γ : Ctx n} {α : Type n} (F : Form (α ∷ Γ) $o) (G : Form Γ α) →
⊢ (![ α ] F => sub G F)
ax-5-s2 : ∀ {n} → {Γ : Ctx n} {α : Type n} (F : Form Γ (α > $o)) (G : Form Γ α) →
⊢ ((![ α ] (~ (weak F · $ this {refl}))) => (~ (F · G)))
ax-5-s3 : ∀ {n} → {Γ : Ctx n} {α : Type n} (F : Form Γ (α > $o)) (G : Form Γ α) →
⊢ ((!'[ α ] F) => (F · G))
ax-6-s : ∀ {n} → {Γ : Ctx n} {α : Type n} {F : Form Γ $o} {G : Form (α ∷ Γ) $o} →
⊢ ((![ α ] (weak F || G)) => (F || (![ α ] G)))
ax-10-a-s : ∀ {n} → {Γ : Ctx n} {F G : Form Γ $o} →
⊢ ((F <=> G) => (F == G))
ax-10-b-s : ∀ {n} → {Γ : Ctx n} {α β : Type n} {F G : Form (α ∷ Γ) β} → ⊢ ((![ α ] (F == G)) => (^[ α ] F == ^[ α ] G))
ax-10-b-s2 : ∀ {n} → {Γ : Ctx n} {α β : Type n} {F G : Form Γ (α > β)} →
⊢ ((![ α ] (app (weak F) (var this refl) == app (weak G) (var this refl))) => (F == G))
ax-11-s : ∀ {n} → {Γ : Ctx n} {α : Type n} {F : Form (α ∷ Γ) $o} →
⊢ ((?[ α ] F => sub (ι α F) F))
ax-11-s2 : ∀ {n} → {Γ : Ctx n} {α : Type n} (F : Form Γ (α > $o)) →
⊢ ((?'[ α ] F) => (F · ι' α F))
inf-II-samectx : ∀ {n} → {Γ : Ctx n} {α β : Type n} (F : Form Γ β → Form Γ $o) (G : Form (α ∷ Γ) β) (H : Form Γ α) →
⊢ (F ((^[ α ] G) · H) => F (sub H G))
inf-II-samectx {_} {Γ} = inf-II Γ ε
inf-III-samectx : ∀ {n} → {Γ : Ctx n} {α β : Type n} (F : Form Γ β → Form Γ $o) (G : Form (α ∷ Γ) β) (H : Form Γ α) →
⊢ (F (sub H G) => F ((^[ α ] G) · H))
inf-III-samectx {_} {Γ} = inf-III Γ ε
inf-VI-s : ∀ {n} → {Γ : Ctx n} {α : Type n} {F : Form (α ∷ Γ) $o} →
⊢ F →
⊢ ![ α ] F
-- -------------------------
ax-5-s F G = inf-V (inf-II-samectx (λ z → (![ _ ] F) => z) F G) (subst (λ z → ⊢ ((![ _ ] F) => ((^[ _ ] F) · z))) (sym (sub-weak-p-1' G (^[ _ ] F))) (inf-V (inf-II-samectx (λ z → z) (app Π (var this refl) => app (var this refl) (weak G)) (^[ _ ] F)) (extend-context (_ > $o) (inf-IV _ this _ (occurs-p-2 (lam _ (weak G))) refl (inf-V (inf-III-samectx (λ z → z) (app Π (var this refl) => app (var this refl) (weak-i (_ ∷ ε) _ (weak G))) (var this refl)) (extend-context _ (inf-V (inf-II-samectx (λ z → z) (app Π (var (next (next this)) refl) => app (var (next (next this)) refl) (var this refl)) _) (inf-IV _ this _ refl refl (inf-V (inf-III-samectx (λ z → z) _ _) (ax-5 {_} {_} {_} {next this} {this} refl refl))))))))))
inf-VI-s {_} {Γ} {α} {F} = λ h → extend-context α (inf-V (inf-VI this (occurs-p-2 (lam α F)) refl) (inf-V (inf-III-samectx (λ z → z) (weak-i (α ∷ ε) Γ F) (var this refl)) (subst (λ z → ⊢ z) (sym (sub-sub-weak-weak-p-3 F)) h)))
ax-6-s {_} {Γ} {α} {F} {G} =
subst (λ z → ⊢ ((![ α ] (weak F || z)) => (F || ![ α ] G))) (sub-sub-weak-weak-p F G)
(inf-V (inf-II Γ (α ∷ ε) (λ z → ((![ α ] (weak F || z)) => (F || app Π (lam α G)))) (sub-i (α ∷ (α ∷ ε)) Γ F (weak-i (α ∷ ε) ($o ∷ Γ) (weak-i (α ∷ ε) Γ G))) (var this refl))
(subst (λ z → ⊢ ((![ α ] (weak F || app (sub-i (α ∷ ε) Γ F (weak (weak (lam α G)))) (var this refl))) => (F || app Π z))) (sym (sub-weak-p-1' (lam α G) F))
(inf-V (ax-5-s _ F) (inf-VI-s (inf-V (ax-5-s _ (weak (lam α G))) (inf-VI-s (ax-6 {_} {_} {α} {this} {next this} refl refl)))))))
ax-10-b-s {_} {Γ} {α} {β} {F} {G} =
subst (λ z → ⊢ ((![ α ] (F == z) => (lam α F == lam α G)))) (sub-sub-weak-weak-p-3 G) (
inf-V (inf-II Γ (α ∷ ε) (λ z → ((![ α ] (F == z)) => (lam α F == lam α G))) (weak-i (α ∷ ε) Γ G) (var this refl)) (
subst (λ z → ⊢ ((![ α ] (z == app (weak (lam α G)) (var this refl))) => (lam α F == lam α G))) (sub-sub-weak-weak-p-2 F G) (
inf-V (inf-II Γ (α ∷ ε) (λ z → (((![ α ] (z == app (weak (lam α G)) (var this refl)) => (lam α F == lam α G))))) (sub-i (α ∷ (α ∷ ε)) Γ (lam α G) (weak-i (α ∷ ε) ((α > β) ∷ Γ) (weak-i (α ∷ ε) Γ F))) (var this refl)) (
subst (λ z → ⊢ (((![ α ] (app (sub-i (α ∷ ε) Γ (lam α G) (weak (weak (lam α F)))) (var this refl) == app (weak (lam α G)) (var this refl)) => (z == lam α G))))) (sym (sub-weak-p-1' (lam α F) (lam α G)))
(inf-V (ax-5-s _ (lam α G)) (inf-VI-s (inf-V (ax-5-s _ (weak (lam α F))) (inf-VI-s (ax-10-b {_} {_} {α} {β} {this} {next this} refl refl)))))))))
ax-10-b-s2 {_} {Γ} {α} {β} {F} {G} =
subst (λ z → (⊢ ((![ α ] (app (weak F) (var this refl) == app (weak G) (var this refl))) => (F == z)))) (sym (sub-weak-p-1' G F)) (
subst (λ z → (⊢ ((![ α ] (app (weak F) (var this refl) == app z (var this refl))) => (F == sub F (weak G))))) (sym (sub-weak-p-1 G F)) (
inf-V (ax-5-s ((![ α ] (app (weak (var this refl)) (var this refl) == app (weak (weak G)) (var this refl))) => (var this refl == weak G)) F) (
inf-VI-s (
inf-V (ax-5-s ((![ α ] (app (weak (var (next this) refl)) (var this refl) == app (weak (var this refl)) (var this refl))) => (var (next this) refl == var this refl)) (weak G)) (
inf-VI-s (
ax-10-b refl refl))))))
ax-11-s {_} {Γ} {α} {F} =
subst (λ z → ⊢ ((?[ α ] z) => sub (app i (lam α F)) F)) (sub-sub-weak-weak-p-3 F) (
inf-V (inf-II Γ (α ∷ ε) (λ z → ((?[ α ] z) => sub (app i (lam α F)) F)) (weak-i (α ∷ ε) Γ F) (var this refl)) (
inf-V (inf-II Γ ε (λ z → ((?[ α ] app (weak (lam α F)) (var this refl)) => z)) F (app i (lam α F))) (
inf-V (ax-5-s _ (lam α F)) (inf-VI-s (ax-11 {_} {_} {α} {this} refl)))))
ax-1-s {_} {_} {F} = inf-V (ax-5-s ((var this refl || var this refl) => var this refl) F) (inf-VI-s (ax-1 refl))
ax-2-s {_} {_} {F} {G} = subst (λ z → ⊢ (F => (F || z))) (sym (sub-weak-p-1' G F)) (inf-V (ax-5-s (var this refl => (var this refl || weak G)) F) (inf-VI-s (inf-V (ax-5-s (var (next this) refl => (var (next this) refl || var this refl)) (weak G)) (inf-VI-s (ax-2 refl refl)))))
ax-3-s {_} {_} {F} {G} = subst (λ z → ⊢ ((F || z) => (z || F))) (sym (sub-weak-p-1' G F)) (inf-V (ax-5-s _ F) (inf-VI-s (inf-V (ax-5-s _ (weak G)) (inf-VI-s (ax-3 {_} {_} {next this} {this} refl refl)))))
ax-4-s {_} {_} {F} {G} {H} = subst (λ z → ⊢ ((F => G) => ((z || F) => (z || G)))) (sym (sub-weak-p-1' H F)) (subst (λ z → ⊢ ((F => z) => ((sub F (weak H) || F) => (sub F (weak H) || z)))) (sym (sub-weak-p-1' G F)) (subst (λ z → ⊢ ((F => sub F (weak G)) => ((sub F z || F) => (sub F z || sub F (weak G))))) (sym (sub-weak-p-1' (weak H) (weak G))) (inf-V (ax-5-s _ F) (inf-VI-s (inf-V (ax-5-s _ (weak G)) (inf-VI-s (inf-V (ax-5-s _ (weak (weak H))) (inf-VI-s (ax-4 {_} {_} {next (next this)} {next this} {this} refl refl refl)))))))))
ax-10-a-s {_} {_} {F} {G} = subst (λ z → ⊢ ((F <=> z) => (F == z))) (sym (sub-weak-p-1' G F)) (inf-V (ax-5-s _ F) (inf-VI-s (inf-V (ax-5-s _ (weak G)) (inf-VI-s (ax-10-a {_} {_} {next this} {this} refl refl)))))
ax-5-s2 = λ F G → subst (λ z → ⊢ ((![ _ ] ~ (weak F · $ this {refl})) => ~ (z · G))) (sym (sub-weak-p-1' F G)) (ax-5-s (~ (weak F · $ this {refl})) G)
ax-5-s3 = λ F G →
subst (λ z → ⊢ ((!'[ _ ] F) => (F · z))) (sym (sub-weak-p-1' G F)) (
inf-V (ax-5-s ((!'[ _ ] ($ this {refl})) => (($ this {refl}) · weak G)) F) (
inf-VI-s (
inf-V (ax-5-s ((!'[ _ ] ($ (next this) {refl})) => (($ (next this) {refl}) · ($ this {refl}))) (weak G)) (
inf-VI-s (
ax-5 {_} {_} {_} {next this} {this} refl refl)))))
ax-11-s2 F =
inf-V (ax-5-s ((?'[ _ ] ($ this {refl})) => (($ this {refl}) · ι' _ ($ this {refl}))) F) (
inf-VI-s (
ax-11 refl))
-- ----------------------------------
mutual
hn-form : ∀ {n} → {Γ : Ctx n} {β : Type n} (F : Form Γ β → Form Γ $o) (G : Form Γ β) (m : ℕ) →
⊢ F (headNorm m G) → ⊢ F G
hn-form F (app G H) m p = hn-form' F G H m (hn-form (λ z → F (headNorm' m z H)) G m p)
hn-form F (var _ _) m p = p
hn-form F N m p = p
hn-form F A m p = p
hn-form F Π m p = p
hn-form F i m p = p
hn-form F (lam _ _) m p = p
hn-form' : ∀ {n} → {Γ : Ctx n} {α β : Type n} (F : Form Γ β → Form Γ $o) (G : Form Γ (α > β)) (H : Form Γ α) (m : ℕ) →
⊢ F (headNorm' m G H) → ⊢ F (app G H)
hn-form' F (lam α G) H (suc m) p = inf-V (inf-III-samectx F G H) (hn-form F (sub H G) m p)
hn-form' F (lam α G) H 0 p = p
hn-form' F (var _ _) H zero p = p
hn-form' F (var _ _) H (suc _) p = p
hn-form' F N H zero p = p
hn-form' F N H (suc _) p = p
hn-form' F A H zero p = p
hn-form' F A H (suc _) p = p
hn-form' F Π H zero p = p
hn-form' F Π H (suc _) p = p
hn-form' F i H zero p = p
hn-form' F i H (suc _) p = p
hn-form' F (app _ _) H zero p = p
hn-form' F (app _ _) H (suc _) p = p
| {
"alphanum_fraction": 0.4522677085,
"avg_line_length": 46.9083665339,
"ext": "agda",
"hexsha": "53a00099cbeb312041839f36b0ec6346fd296e55",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2022-01-15T11:51:19.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-05-17T20:28:10.000Z",
"max_forks_repo_head_hexsha": "032efd5f42e4b56d436ac8e0c3c0f5127b8dc1f7",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "frelindb/agsyHOL",
"max_forks_repo_path": "soundness/STT.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "032efd5f42e4b56d436ac8e0c3c0f5127b8dc1f7",
"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": "frelindb/agsyHOL",
"max_issues_repo_path": "soundness/STT.agda",
"max_line_length": 720,
"max_stars_count": 17,
"max_stars_repo_head_hexsha": "032efd5f42e4b56d436ac8e0c3c0f5127b8dc1f7",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "frelindb/agsyHOL",
"max_stars_repo_path": "soundness/STT.agda",
"max_stars_repo_stars_event_max_datetime": "2021-03-19T20:53:45.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-04T14:38:28.000Z",
"num_tokens": 5309,
"size": 11774
} |
{-# OPTIONS --without-K --safe #-}
open import Algebra
module Loop.Properties
{a ℓ} (L : Loop a ℓ) where
open Loop L
| {
"alphanum_fraction": 0.6475409836,
"avg_line_length": 13.5555555556,
"ext": "agda",
"hexsha": "bdc56f8fd55fb911268a2b957608569322723f72",
"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": "443e831e536b756acbd1afd0d6bae7bc0d288048",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Akshobhya1234/agda-NonAssociativeAlgebra",
"max_forks_repo_path": "src/Loop/Properties.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "443e831e536b756acbd1afd0d6bae7bc0d288048",
"max_issues_repo_issues_event_max_datetime": "2021-10-09T08:24:56.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-10-04T05:30:30.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Akshobhya1234/agda-NonAssociativeAlgebra",
"max_issues_repo_path": "src/Loop/Properties.agda",
"max_line_length": 34,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "443e831e536b756acbd1afd0d6bae7bc0d288048",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Akshobhya1234/agda-NonAssociativeAlgebra",
"max_stars_repo_path": "src/Loop/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2021-08-17T09:14:03.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-08-15T06:16:13.000Z",
"num_tokens": 36,
"size": 122
} |
-- Load me
module QuotationMark where
open import Agda.Builtin.Char
open import Agda.Builtin.List
open import Agda.Builtin.String
s : List Char
s = ")"
| {
"alphanum_fraction": 0.7647058824,
"avg_line_length": 17,
"ext": "agda",
"hexsha": "a7e631b40c529df644e09a476970b11f555feb95",
"lang": "Agda",
"max_forks_count": 22,
"max_forks_repo_forks_event_max_datetime": "2022-03-15T11:37:47.000Z",
"max_forks_repo_forks_event_min_datetime": "2020-05-29T12:07:13.000Z",
"max_forks_repo_head_hexsha": "7628c254e87374a924a781cf15ea3abd715fd2d3",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "SNU-2D/agda-mode-vscode",
"max_forks_repo_path": "test/tests/Parser/Response/QuotationMark.agda",
"max_issues_count": 126,
"max_issues_repo_head_hexsha": "7628c254e87374a924a781cf15ea3abd715fd2d3",
"max_issues_repo_issues_event_max_datetime": "2020-12-23T23:00:13.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-02-02T05:47:54.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "SNU-2D/agda-mode-vscode",
"max_issues_repo_path": "test/tests/Parser/Response/QuotationMark.agda",
"max_line_length": 31,
"max_stars_count": 98,
"max_stars_repo_head_hexsha": "7628c254e87374a924a781cf15ea3abd715fd2d3",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "EdNutting/agda-mode-vscode",
"max_stars_repo_path": "test/tests/Parser/Response/QuotationMark.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-18T09:35:55.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-05-29T07:46:51.000Z",
"num_tokens": 42,
"size": 153
} |
-- Andreas, 2017-05-26
-- Expand ellipsis with C-c C-c . RET
open import Agda.Builtin.Nat
test0 : Nat → Nat
test0 x with zero
... | q = {!.!} -- C-c C-c
-- Expected result:
-- test0 x | q = ?
data Fin : Nat → Set where
zero : ∀ n → Fin (suc n)
suc : ∀{n} → Fin n → Fin (suc n)
test1 : ∀{n} → Fin n → Nat
test1 (zero _) with Nat
... | q = {!.!} -- C-c C-c
-- Expected result:
-- test1 (zero _) | q = ?
test1 {.(suc n)} (suc {n} i) with Fin zero
... | q = {!.!} -- C-c C-c
-- Expected result:
-- test1 {.(suc n)} (suc {n} i) | q = ?
| {
"alphanum_fraction": 0.5081967213,
"avg_line_length": 16.6363636364,
"ext": "agda",
"hexsha": "c4d2a22271931b9f96a7d64fbfca21419e8d8862",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/interaction/ExpandEllipsis.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "hborum/agda",
"max_issues_repo_path": "test/interaction/ExpandEllipsis.agda",
"max_line_length": 42,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "hborum/agda",
"max_stars_repo_path": "test/interaction/ExpandEllipsis.agda",
"max_stars_repo_stars_event_max_datetime": "2020-09-20T00:28:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-10-29T09:40:30.000Z",
"num_tokens": 218,
"size": 549
} |
module Lib.Monad where
open import Lib.Nat
open import Lib.List
open import Lib.IO hiding (IO; mapM)
open import Lib.Maybe
open import Lib.Prelude
infixr 40 _>>=_ _>>_
infixl 90 _<*>_ _<$>_
-- Wrapper type, used to ensure that ElM is constructor-headed.
record IO (A : Set) : Set where
constructor io
field unIO : Lib.IO.IO A
open IO
-- State monad transformer
data StateT (S : Set)(M : Set -> Set)(A : Set) : Set where
stateT : (S -> M (A × S)) -> StateT S M A
runStateT : forall {S M A} -> StateT S M A -> S -> M (A × S)
runStateT (stateT f) = f
-- Reader monad transformer
data ReaderT (E : Set)(M : Set -> Set)(A : Set) : Set where
readerT : (E -> M A) -> ReaderT E M A
runReaderT : forall {E M A} -> ReaderT E M A -> E -> M A
runReaderT (readerT f) = f
-- The monad class
data Monad : Set1 where
maybe : Monad
list : Monad
io : Monad
state : Set -> Monad -> Monad
reader : Set -> Monad -> Monad
ElM : Monad -> Set -> Set
ElM maybe = Maybe
ElM list = List
ElM io = IO
ElM (state S m) = StateT S (ElM m)
ElM (reader E m) = ReaderT E (ElM m)
return : {m : Monad}{A : Set} -> A -> ElM m A
return {maybe} x = just x
return {list} x = x :: []
return {io} x = io (returnIO x)
return {state _ m} x = stateT \s -> return (x , s)
return {reader _ m} x = readerT \_ -> return x
_>>=_ : {m : Monad}{A B : Set} -> ElM m A -> (A -> ElM m B) -> ElM m B
_>>=_ {maybe} nothing k = nothing
_>>=_ {maybe} (just x) k = k x
_>>=_ {list} xs k = foldr (\x ys -> k x ++ ys) [] xs
_>>=_ {io} (io m) k = io (bindIO m (unIO ∘ k))
_>>=_ {state S m} (stateT f) k = stateT \s -> f s >>= rest
where
rest : _ × _ -> ElM m _
rest (x , s) = runStateT (k x) s
_>>=_ {reader E m} (readerT f) k = readerT \e -> f e >>= \x -> runReaderT (k x) e
-- State monad class
data StateMonad (S : Set) : Set1 where
state : Monad -> StateMonad S
reader : Set -> StateMonad S -> StateMonad S
ElStM : {S : Set} -> StateMonad S -> Monad
ElStM {S} (state m) = state S m
ElStM (reader E m) = reader E (ElStM m)
ElSt : {S : Set} -> StateMonad S -> Set -> Set
ElSt m = ElM (ElStM m)
get : {S : Set}{m : StateMonad S} -> ElSt m S
get {m = state m} = stateT \s -> return (s , s)
get {m = reader E m} = readerT \_ -> get
put : {S : Set}{m : StateMonad S} -> S -> ElSt m Unit
put {m = state m} s = stateT \_ -> return (unit , s)
put {m = reader E m} s = readerT \_ -> put s
-- Reader monad class
data ReaderMonad (E : Set) : Set1 where
reader : Monad -> ReaderMonad E
state : Set -> ReaderMonad E -> ReaderMonad E
ElRdM : {E : Set} -> ReaderMonad E -> Monad
ElRdM {E} (reader m) = reader E m
ElRdM (state S m) = state S (ElRdM m)
ElRd : {E : Set} -> ReaderMonad E -> Set -> Set
ElRd m = ElM (ElRdM m)
ask : {E : Set}{m : ReaderMonad E} -> ElRd m E
ask {m = reader m } = readerT \e -> return e
ask {m = state S m} = stateT \s -> ask >>= \e -> return (e , s)
local : {E A : Set}{m : ReaderMonad E} -> (E -> E) -> ElRd m A -> ElRd m A
local {m = reader _ } f (readerT m) = readerT \e -> m (f e)
local {m = state S _} f (stateT m) = stateT \s -> local f (m s)
-- Derived functions
-- Monad operations
_>>_ : {m : Monad}{A B : Set} -> ElM m A -> ElM m B -> ElM m B
m₁ >> m₂ = m₁ >>= \_ -> m₂
_<*>_ : {m : Monad}{A B : Set} -> ElM m (A -> B) -> ElM m A -> ElM m B
mf <*> mx = mf >>= \f -> mx >>= \x -> return (f x)
_<$>_ : {m : Monad}{A B : Set} -> (A -> B) -> ElM m A -> ElM m B
f <$> m = return f <*> m
mapM : {m : Monad}{A B : Set} -> (A -> ElM m B) -> List A -> ElM m (List B)
mapM f [] = return []
mapM f (x :: xs) = _::_ <$> f x <*> mapM f xs
-- State monad operations
modify : {S : Set}{m : StateMonad S} -> (S -> S) -> ElSt m Unit
modify f = get >>= \s -> put (f s)
-- Test
-- foo : Nat -> Maybe (Nat × Nat)
-- foo s = runReaderT (runStateT m s) s
-- where
-- m₁ : StateT Nat (ReaderT Nat Maybe) Nat
-- m₁ = local suc (ask >>= \s -> put (s + 3) >> get)
-- The problem: nested injective function don't seem to work
-- as well as one could hope. In this case:
-- ElM (ElRd ?0) == ReaderT Nat Maybe
-- inverts to
-- ElRd ?0 == reader Nat ?1
-- ElM ?1 == Maybe
-- it seems that the injectivity of ElRd isn't taken into account(?)
-- m : ReaderT Nat Maybe Nat
-- m = ask
| {
"alphanum_fraction": 0.55,
"avg_line_length": 27.8709677419,
"ext": "agda",
"hexsha": "398127718c1a2e61790cedf3d18efece03d96b46",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "examples/simple-lib/Lib/Monad.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "examples/simple-lib/Lib/Monad.agda",
"max_line_length": 81,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "examples/simple-lib/Lib/Monad.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": 1607,
"size": 4320
} |
{-# OPTIONS --sized-types #-}
module SizedTypesMergeSort where
postulate
Size : Set
_^ : Size -> Size
∞ : Size
{-# BUILTIN SIZE Size #-}
{-# BUILTIN SIZESUC _^ #-}
{-# BUILTIN SIZEINF ∞ #-}
-- sized lists
data List (A : Set) : {_ : Size} -> Set where
[] : {size : Size} -> List A {size ^}
_::_ : {size : Size} -> A -> List A {size} -> List A {size ^}
-- CPS split
split : {A : Set}{i : Size} -> List A {i} ->
{C : Set} -> (List A {i} -> List A {i} -> C) -> C
split [] k = k [] []
split (x :: xs) k = split xs (\ l r -> k (x :: r) l)
module Sort (A : Set) (compare : A -> A -> {B : Set} -> B -> B -> B) where
{- merge is currently rejected by the termination checker
it would be nice if it worked
see test/succeed/SizedTypesMergeSort.agda
-}
merge : List A -> List A -> List A
merge [] ys = ys
merge xs [] = xs
merge (x :: xs) (y :: ys) =
compare x y (x :: merge xs (y :: ys))
(y :: merge (x :: xs) ys)
sort : {i : Size} -> List A {i} -> List A
sort [] = []
sort (x :: []) = x :: []
sort (x :: (y :: xs)) = split xs (\ l r -> merge (sort (x :: l))
(sort (y :: r)))
| {
"alphanum_fraction": 0.4671654198,
"avg_line_length": 26.152173913,
"ext": "agda",
"hexsha": "34fc866f73b8900a2e1d80e718a797433fc14ed6",
"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/SizedTypesMergeSort.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/SizedTypesMergeSort.agda",
"max_line_length": 74,
"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/SizedTypesMergeSort.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": 393,
"size": 1203
} |
open import Formalization.PredicateLogic.Signature
module Formalization.PredicateLogic.Minimal.NaturalDeduction.Tree (𝔏 : Signature) where
open Signature(𝔏)
open import Data.DependentWidthTree as Tree hiding (height)
import Lvl
open import Formalization.PredicateLogic.Minimal.NaturalDeduction (𝔏)
open import Formalization.PredicateLogic.Syntax(𝔏)
open import Functional using (_∘_ ; _∘₂_ ; _∘₃_ ; _∘₄_ ; swap ; _←_)
open import Numeral.Finite
open import Numeral.Natural.Relation.Order
open import Numeral.Natural
open import Sets.PredicateSet using (PredSet ; _∈_ ; _∉_ ; _∪_ ; _∪•_ ; _∖_ ; _⊆_ ; _⊇_ ; ∅ ; [≡]-to-[⊆] ; [≡]-to-[⊇] ; map ; unmap) renaming (•_ to · ; _≡_ to _≡ₛ_)
open import Structure.Relator
open import Type.Properties.Inhabited
open import Type
module _ {vars} ⦃ pos-term : ◊(Term(vars)) ⦄ where
private variable ℓ : Lvl.Level
private variable Γ Γ₁ Γ₂ : PredSet{ℓ}(Formula(vars))
private variable φ ψ γ φ₁ ψ₁ γ₁ φ₂ ψ₂ γ₂ φ₃ ψ₃ φ₄ ψ₄ φ₅ ψ₅ δ₁ δ₂ : Formula(vars)
{-
height : Term(_) → (Γ ⊢ φ) → ℕ
height t (direct p) = 𝟎
height t [⊤]-intro = 𝟎
height t ([∧]-intro p q) = 𝐒((height t p) ⦗ max ⦘ᵣ (height t q))
height t ([∧]-elimₗ p) = 𝐒(height t p)
height t ([∧]-elimᵣ p) = 𝐒(height t p)
height t ([∨]-introₗ p) = 𝐒(height t p)
height t ([∨]-introᵣ p) = 𝐒(height t p)
height t ([∨]-elim p q r) = 𝐒((height t p) ⦗ max ⦘ᵣ (height t q) ⦗ max ⦘ᵣ (height t r))
height t ([⟶]-intro p) = 𝐒(height t p)
height t ([⟶]-elim p q) = 𝐒((height t p) ⦗ max ⦘ᵣ (height t q))
height t ([Ɐ]-intro p) = 𝐒(height t (p{t}))
height t ([Ɐ]-elim p) = 𝐒(height t p)
height t ([∃]-intro p) = 𝐒(height t p)
height t ([∃]-elim p q) = 𝐒((height t (p{t})) ⦗ max ⦘ᵣ (height t q))
test : ∀{t : Term(n)}{p q : Γ ⊢ φ} → (height t p ≤ height t ([∧]-intro p q))
test = [≤]-successor max-orderₗ
-}
tree : (Γ ⊢ φ) → FiniteTreeStructure
tree(direct x) = Node 0 \()
tree [⊤]-intro = Node 0 \()
tree([∧]-intro p q) = Node 2 \{𝟎 → tree p; (𝐒 𝟎) → tree q}
tree([∧]-elimₗ p) = Node 1 \{𝟎 → tree p}
tree([∧]-elimᵣ p) = Node 1 \{𝟎 → tree p}
tree([∨]-introₗ p) = Node 1 \{𝟎 → tree p}
tree([∨]-introᵣ p) = Node 1 \{𝟎 → tree p}
tree([∨]-elim p q r) = Node 3 \{𝟎 → tree p ; (𝐒 𝟎) → tree q ; (𝐒(𝐒 𝟎)) → tree r}
tree([⟶]-intro p) = Node 1 \{𝟎 → tree p}
tree([⟶]-elim p q) = Node 2 \{𝟎 → tree p ; (𝐒 𝟎) → tree q}
tree([Ɐ]-intro p) = Node 1 \{𝟎 → tree (p{[◊]-existence})}
tree([Ɐ]-elim p) = Node 1 \{𝟎 → tree p}
tree([∃]-intro p) = Node 1 \{𝟎 → tree p}
tree([∃]-elim p q) = Node 2 \{𝟎 → tree (p{[◊]-existence}) ; (𝐒 𝟎) → tree q}
height : (Γ ⊢ φ) → ℕ
height = Tree.height ∘ tree
open import Data.Tuple as Tuple using (_⨯_ ; _,_)
import Functional.Dependent
open Functional using (_on₂_)
open import Numeral.Natural.Induction
open import Numeral.Natural.Inductions
open import Numeral.Natural.Relation.Order.Proofs
open import Structure.Relator.Ordering
open import Structure.Relator.Ordering.Proofs
open import Type.Dependent
-- Ordering of natural deduction proofs on height.
_<⊢↑_ : Σ(PredSet{ℓ}(Formula(vars)) ⨯ Formula(vars))(Tuple.uncurry(_⊢_)) → Σ(PredSet(Formula(vars)) ⨯ Formula(vars))(Tuple.uncurry(_⊢_)) → Type
_<⊢↑_ = (_<_) on₂ (height Functional.Dependent.∘ Σ.right)
instance
[<⊢↑]-wellfounded : Strict.Properties.WellFounded(_<⊢↑_ {ℓ})
[<⊢↑]-wellfounded = wellfounded-image-by-trans {f = height Functional.Dependent.∘ Σ.right}
-- induction-on-height : ∀{P : ∀{Γ : PredSet{ℓₚ}(Formula(vars))}{φ} → (Γ ⊢ φ) → Type{ℓ}} → (∀{x : Prop(vars)} → P(direct x)) → P([⊤]-intro) → (∀{p₂ : Γ ⊢ φ} → (∀{Γ₁}{φ₁}{p₁ : Γ₁ ⊢ φ₁} → (height p₁ < height p₂) → P(p₁)) → P(p₂)) → (∀{p : (Γ ⊢ φ)} → P(p))
-- induction-on-height {Γ = Γ}{φ = φ} {P = P} dir top step {p} = Strict.Properties.wellfounded-induction(_<⊢↑_) {P = P Functional.Dependent.∘ Σ.right} {!!} {intro (Γ , φ) p}
-- substitute0-height : ∀{t} → height(substitute0 t φ) ≡
| {
"alphanum_fraction": 0.5866045142,
"avg_line_length": 47.3953488372,
"ext": "agda",
"hexsha": "8afb63950d63d91410ea3a2c6b496d638e989def",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Formalization/PredicateLogic/Minimal/NaturalDeduction/Tree.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Formalization/PredicateLogic/Minimal/NaturalDeduction/Tree.agda",
"max_line_length": 255,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Formalization/PredicateLogic/Minimal/NaturalDeduction/Tree.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": 1739,
"size": 4076
} |
{-# OPTIONS --without-K --safe #-}
module Categories.Diagram.Limit.Ran where
open import Level
open import Data.Product using (Σ)
open import Categories.Category
open import Categories.Category.Complete
open import Categories.Category.Construction.Cones
open import Categories.Category.Construction.Comma
open import Categories.Category.Construction.Properties.Comma
open import Categories.Diagram.Cone.Properties
open import Categories.Diagram.Limit.Properties
open import Categories.Functor
open import Categories.Functor.Properties
open import Categories.Functor.Construction.Constant
open import Categories.NaturalTransformation
open import Categories.NaturalTransformation.Equivalence using () renaming (_≃_ to _≊_)
open import Categories.NaturalTransformation.NaturalIsomorphism using (NaturalIsomorphism; _≃_; module ≃; _ⓘˡ_)
open import Categories.Kan
open import Categories.Diagram.Limit
import Categories.Morphism as Mor
import Categories.Morphism.Reasoning as MR
private
variable
o ℓ e : Level
C D E : Category o ℓ e
-- construct a Ran from a limit
module _ {o ℓ e o′ ℓ′ e′} {C : Category o′ ℓ′ e′} {D : Category o ℓ e}
(F : Functor C D) (X : Functor C E) (Com : Complete (o′ ⊔ ℓ) (ℓ′ ⊔ e) e′ E) where
private
module C = Category C
module D = Category D
module E = Category E
module F = Functor F
module X = Functor X
open Limit
open Cone renaming (commute to K-commute)
open Cone⇒ renaming (commute to ⇒-commute)
open Mor E
G : (d : D.Obj) → Functor (d ↙ F) E
G d = X ∘F Cod (const! d) F
⊤Gd : ∀ d → Limit (G d)
⊤Gd d = Com (G d)
module ⊤Gd d = Limit (⊤Gd d)
f↙F : ∀ {Y Z} (f : Y D.⇒ Z) → Functor (Z ↙ F) (Y ↙ F)
f↙F = along-natˡ′ F
Gf≃ : ∀ {Y Z} (f : Y D.⇒ Z) → G Z ≃ G Y ∘F f↙F f
Gf≃ f = record
{ F⇒G = ntHelper record
{ η = λ _ → X.F₁ C.id
; commute = λ _ → [ X ]-resp-square id-comm-sym
}
; F⇐G = ntHelper record
{ η = λ _ → X.F₁ C.id
; commute = λ _ → [ X ]-resp-square id-comm-sym
}
; iso = λ _ → record
{ isoˡ = [ X ]-resp-∘ C.identity² ○ X.identity
; isoʳ = [ X ]-resp-∘ C.identity² ○ X.identity
}
}
where open MR C
open E.HomReasoning
limY⇒limZ∘ : ∀ {Y Z} (f : Y D.⇒ Z) → Cones (G Y ∘F f↙F f) [ F-map-Coneʳ (f↙F f) (limit (Com (G Y))) , limit (Com (G Y ∘F f↙F f)) ]
limY⇒limZ∘ {Y} f = F⇒arr Com (f↙F f) (G Y)
limZ∘≅limZ : ∀ {Y Z} (f : Y D.⇒ Z) → apex (⊤Gd Z) ≅ apex (Com (G Y ∘F f↙F f))
limZ∘≅limZ {Y} {Z} f = ≃⇒lim≅ (Gf≃ f) (⊤Gd Z) (Com _)
limit-is-ran : Ran F X
limit-is-ran = record
{ R = R
; ε = ε
; δ = δ
; δ-unique = λ {M γ} δ′ eq → δ-unique {M} {γ} δ′ eq
; commutes = commutes
}
where open MR E
open E.HomReasoning
open D.HomReasoning using () renaming (_○_ to _●_ ; ⟺ to ⟷)
R₀ : D.Obj → E.Obj
R₀ d = apex (⊤Gd d)
R₁ : ∀ {A B} → D [ A , B ] → E [ R₀ A , R₀ B ]
R₁ {A} f = _≅_.to (limZ∘≅limZ f) E.∘ arr (limY⇒limZ∘ f)
proj-red : ∀ {Y Z} K (f : Y D.⇒ Z) → ⊤Gd.proj Z K E.∘ R₁ f E.≈ ⊤Gd.proj Y (record { f = D.id D.∘ CommaObj.f K D.∘ f })
proj-red {Y} {Z} K f = begin
⊤Gd.proj Z K E.∘ R₁ f ≈⟨ pullˡ (⇒-commute (≃⇒Cone⇒ (≃.sym (Gf≃ f)) (Com _) (⊤Gd Z))) ⟩
(X.F₁ C.id E.∘ proj (Com _) K) E.∘ arr (limY⇒limZ∘ f) ≈⟨ pullʳ (⇒-commute (limY⇒limZ∘ f)) ⟩
X.F₁ C.id E.∘ ⊤Gd.proj Y _ ≈⟨ elimˡ X.identity ⟩
⊤Gd.proj Y _ ∎
proj≈ : ∀ {d b} {f g : d D.⇒ F.F₀ b} → f D.≈ g → ⊤Gd.proj d record { f = f } E.≈ ⊤Gd.proj d record { f = g }
proj≈ {d} {b} {f} {g} eq = begin
⊤Gd.proj d _ ≈⟨ introˡ X.identity ⟩
X.F₁ C.id E.∘ ⊤Gd.proj d _ ≈⟨ K-commute _ (⊤Gd.limit d) (record { h = C.id ; commute = D.∘-resp-≈ F.identity eq ● MR.id-comm-sym D }) ⟩
⊤Gd.proj d _ ∎
R : Functor D E
R = record
{ F₀ = R₀
; F₁ = R₁
; identity = λ {d} → terminal.⊤-id (⊤Gd d) record
{ commute = λ {Z} → begin
⊤Gd.proj d Z ∘ R₁ D.id ≈⟨ proj-red Z D.id ⟩
⊤Gd.proj d record { f = D.id D.∘ CommaObj.f Z D.∘ D.id } ≈⟨ proj≈ (D.identityˡ ● D.identityʳ) ⟩
⊤Gd.proj d Z ∎
}
; homomorphism = λ {Y Z W} {f g} →
terminal.!-unique₂ (⊤Gd W)
{let module ⊤GY = Cone _ (⊤Gd.limit Y)
module H = Functor (f↙F (g D.∘ f))
in record
{ apex = record
{ ψ = λ K → ⊤GY.ψ (H.F₀ K)
; commute = λ h → ⊤GY.commute (H.F₁ h)
}
}}
{record
{ arr = R₁ (g D.∘ f)
; commute = λ {K} → proj-red K (g D.∘ f)
}}
{record
{ arr = R₁ g ∘ R₁ f
; commute = λ {K} → begin
⊤Gd.proj W K ∘ R₁ g ∘ R₁ f
≈⟨ sym-assoc ⟩
(⊤Gd.proj W K ∘ R₁ g) ∘ R₁ f
≈⟨ proj-red K g ⟩∘⟨refl ⟩
⊤Gd.proj Z record { f = D.id D.∘ CommaObj.f K D.∘ g } ∘ R₁ f
≈⟨ proj-red _ f ⟩
⊤Gd.proj Y record { f = D.id D.∘ (D.id D.∘ CommaObj.f K D.∘ g) D.∘ f }
≈⟨ proj≈ (D.identityˡ ● (MR.assoc²' D)) ⟩
⊤Gd.proj Y record { f = D.id D.∘ CommaObj.f K D.∘ g D.∘ f }
∎
}}
; F-resp-≈ = λ {Y Z} {f g} eq →
terminal.!-unique₂ (⊤Gd Z)
{let module ⊤GY = Cone _ (⊤Gd.limit Y)
module H = Functor (f↙F f)
in record
{ apex = record
{ ψ = λ K → ⊤GY.ψ (H.F₀ K)
; commute = λ h → ⊤GY.commute (H.F₁ h)
}
}}
{record
{ arr = R₁ f
; commute = F-resp-≈-commute D.Equiv.refl
}}
{record
{ arr = R₁ g
; commute = F-resp-≈-commute eq
}}
}
where open E
F-resp-≈-commute : ∀ {Y Z} {K : Category.Obj (Z ↙ F)} {f g : Y D.⇒ Z} → f D.≈ g →
⊤Gd.proj Z K ∘ R₁ g ≈ ⊤Gd.proj Y record { f = D.id D.∘ CommaObj.f K D.∘ f }
F-resp-≈-commute {Y} {Z} {K} {f} {g} eq = begin
⊤Gd.proj Z K ∘ R₁ g ≈⟨ proj-red K g ⟩
⊤Gd.proj Y _ ≈⟨ proj≈ (D.∘-resp-≈ʳ (D.∘-resp-≈ʳ (D.Equiv.sym eq))) ⟩
⊤Gd.proj Y _ ∎
ε : NaturalTransformation (R ∘F F) X
ε = ntHelper record
{ η = λ c → ⊤Gd.proj (F.F₀ c) record { f = D.id }
; commute = λ {Y Z} f → begin
⊤Gd.proj (F.F₀ Z) _ ∘ Functor.F₁ (R ∘F F) f ≈⟨ proj-red _ (F.F₁ f) ⟩
⊤Gd.proj (F.F₀ Y) _ ≈˘⟨ K-commute _ (⊤Gd.limit (F.F₀ Y)) record { h = f ; commute = ⟷ (D.∘-resp-≈ˡ D.identityˡ ● D.∘-resp-≈ˡ D.identityˡ) } ⟩
X.F₁ f ∘ ⊤Gd.proj (F.F₀ Y) _ ∎
}
where open E
δ-Cone : ∀ d (M : Functor D E) → NaturalTransformation (M ∘F F) X → Cone (G d)
δ-Cone d M γ = record
{ apex = record
{ ψ = λ K → γ.η (CommaObj.β K) E.∘ M.F₁ (CommaObj.f K)
; commute = λ {Y Z} f → begin
X.F₁ (Comma⇒.h f) E.∘ γ.η (CommaObj.β Y) E.∘ M.F₁ (CommaObj.f Y)
≈˘⟨ pushˡ (γ.commute (Comma⇒.h f)) ⟩
(γ.η (CommaObj.β Z) E.∘ M.F₁ (F.F₁ (Comma⇒.h f))) E.∘ M.F₁ (CommaObj.f Y)
≈⟨ pullʳ ([ M ]-resp-∘ (Comma⇒.commute f ● D.identityʳ)) ⟩
γ.η (CommaObj.β Z) E.∘ M.F₁ (CommaObj.f Z)
∎
}
}
where module M = Functor M
module γ = NaturalTransformation γ
δ : (M : Functor D E) → NaturalTransformation (M ∘F F) X → NaturalTransformation M R
δ M γ = ntHelper record
{ η = λ d → ⊤Gd.rep d (δ-Cone d M γ)
; commute = λ {Y Z} f →
terminal.!-unique₂ (⊤Gd Z)
{record
{ apex = record
{ ψ = λ W → δ-Cone.ψ Z W E.∘ M.F₁ f
; commute = λ {W V} g → begin
X.F₁ (Comma⇒.h g) E.∘ (γ.η (CommaObj.β W) E.∘ M.F₁ (CommaObj.f W)) E.∘ M.F₁ f
≈⟨ E.sym-assoc ⟩
(X.F₁ (Comma⇒.h g) E.∘ γ.η (CommaObj.β W) E.∘ M.F₁ (CommaObj.f W)) E.∘ M.F₁ f
≈⟨ δ-Cone.commute Z g ⟩∘⟨refl ⟩
(γ.η (CommaObj.β V) E.∘ M.F₁ (CommaObj.f V)) E.∘ M.F₁ f
∎
}
}}
{record
{ arr = ⊤Gd.rep Z (δ-Cone Z M γ) E.∘ M.F₁ f
; commute = pullˡ (⇒-commute (⊤Gd.rep-cone Z (δ-Cone Z M γ)))
}}
{record
{ arr = R₁ f E.∘ ⊤Gd.rep Y (δ-Cone Y M γ)
; commute = λ {W} → begin
⊤Gd.proj Z W E.∘ R₁ f E.∘ ⊤Gd.rep Y (δ-Cone Y M γ)
≈⟨ pullˡ (proj-red W f) ⟩
⊤Gd.proj Y (record { f = D.id D.∘ CommaObj.f W D.∘ f }) E.∘ ⊤Gd.rep Y (δ-Cone Y M γ)
≈⟨ ⇒-commute (⊤Gd.rep-cone Y (δ-Cone Y M γ)) ⟩
γ.η (CommaObj.β W) E.∘ M.F₁ (D.id D.∘ CommaObj.f W D.∘ f)
≈˘⟨ refl⟩∘⟨ [ M ]-resp-∘ (⟷ D.identityˡ) ⟩
γ.η (CommaObj.β W) E.∘ M.F₁ (CommaObj.f W) E.∘ M.F₁ f
≈⟨ E.sym-assoc ⟩
(γ.η (CommaObj.β W) E.∘ M.F₁ (CommaObj.f W)) E.∘ M.F₁ f
∎
}}
}
where module M = Functor M
module γ = NaturalTransformation γ
module δ-Cone d = Cone _ (δ-Cone d M γ)
δ-unique : ∀ {M : Functor D E} {α : NaturalTransformation (M ∘F F) X}
(δ′ : NaturalTransformation M R) → α ≊ ε ∘ᵥ δ′ ∘ʳ F → δ′ ≊ δ M α
δ-unique {M} {γ} δ′ eq {d} = ⟺ (⊤Gd.terminal.!-unique d record
{ arr = δ′.η d
; commute = λ {W} → begin
⊤Gd.proj d W E.∘ δ′.η d
≈˘⟨ proj≈ (D.identityˡ ● D.identityˡ) ⟩∘⟨refl ⟩
⊤Gd.proj d (record { f = D.id D.∘ D.id D.∘ CommaObj.f W }) E.∘ δ′.η d
≈˘⟨ pullˡ (proj-red _ (CommaObj.f W)) ⟩
⊤Gd.proj (F.F₀ (CommaObj.β W)) _ E.∘ R₁ (CommaObj.f W) E.∘ δ′.η d
≈˘⟨ pullʳ (δ′.commute (CommaObj.f W)) ⟩
(⊤Gd.proj (F.F₀ (CommaObj.β W)) (record { f = D.id}) E.∘ δ′.η (F.F₀ (CommaObj.β W))) E.∘ M.F₁ (CommaObj.f W)
≈˘⟨ eq ⟩∘⟨refl ⟩
γ.η (CommaObj.β W) E.∘ M.F₁ (CommaObj.f W)
∎
})
where module M = Functor M
module γ = NaturalTransformation γ
module δ′ = NaturalTransformation δ′
commutes : (M : Functor D E) (α : NaturalTransformation (M ∘F F) X) → α ≊ ε ∘ᵥ δ M α ∘ʳ F
commutes M γ {c} = ⟺ (⇒-commute (⊤Gd.rep-cone (F.F₀ c) (δ-Cone (F.F₀ c) M γ)) ○ elimʳ M.identity)
where module M = Functor M
module γ = NaturalTransformation γ
| {
"alphanum_fraction": 0.4194994081,
"avg_line_length": 45.1374045802,
"ext": "agda",
"hexsha": "30269f6017297ae889df25be80c559eae0f64fb7",
"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/Diagram/Limit/Ran.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/Diagram/Limit/Ran.agda",
"max_line_length": 179,
"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/Diagram/Limit/Ran.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 4377,
"size": 11826
} |
module regular-language where
open import Level renaming ( suc to Suc ; zero to Zero )
open import Data.List
open import Data.Nat hiding ( _≟_ )
open import Data.Fin hiding ( _+_ )
open import Data.Empty
open import Data.Unit
open import Data.Product
-- open import Data.Maybe
open import Relation.Nullary
open import Relation.Binary.PropositionalEquality hiding ( [_] )
open import logic
open import nat
open import automaton
language : { Σ : Set } → Set
language {Σ} = List Σ → Bool
language-L : { Σ : Set } → Set
language-L {Σ} = List (List Σ)
Union : {Σ : Set} → ( A B : language {Σ} ) → language {Σ}
Union {Σ} A B x = (A x ) \/ (B x)
split : {Σ : Set} → (List Σ → Bool)
→ ( List Σ → Bool) → List Σ → Bool
split x y [] = x [] /\ y []
split x y (h ∷ t) = (x [] /\ y (h ∷ t)) \/
split (λ t1 → x ( h ∷ t1 )) (λ t2 → y t2 ) t
Concat : {Σ : Set} → ( A B : language {Σ} ) → language {Σ}
Concat {Σ} A B = split A B
{-# TERMINATING #-}
Star : {Σ : Set} → ( A : language {Σ} ) → language {Σ}
Star {Σ} A [] = true
Star {Σ} A (h ∷ t) = split A ( Star {Σ} A ) (h ∷ t)
open import automaton-ex
test-AB→split : {Σ : Set} → {A B : List In2 → Bool} → split A B ( i0 ∷ i1 ∷ i0 ∷ [] ) ≡ (
( A [] /\ B ( i0 ∷ i1 ∷ i0 ∷ [] ) ) \/
( A ( i0 ∷ [] ) /\ B ( i1 ∷ i0 ∷ [] ) ) \/
( A ( i0 ∷ i1 ∷ [] ) /\ B ( i0 ∷ [] ) ) \/
( A ( i0 ∷ i1 ∷ i0 ∷ [] ) /\ B [] )
)
test-AB→split {_} {A} {B} = refl
star-nil : {Σ : Set} → ( A : language {Σ} ) → Star A [] ≡ true
star-nil A = refl
open Automaton
open import finiteSet
open import finiteSetUtil
record RegularLanguage ( Σ : Set ) : Set (Suc Zero) where
field
states : Set
astart : states
afin : FiniteSet states
automaton : Automaton states Σ
contain : List Σ → Bool
contain x = accept automaton astart x
open RegularLanguage
isRegular : {Σ : Set} → (A : language {Σ} ) → ( x : List Σ ) → (r : RegularLanguage Σ ) → Set
isRegular A x r = A x ≡ contain r x
RegularLanguage-is-language : { Σ : Set } → RegularLanguage Σ → language {Σ}
RegularLanguage-is-language {Σ} R = RegularLanguage.contain R
RegularLanguage-is-language' : { Σ : Set } → RegularLanguage Σ → List Σ → Bool
RegularLanguage-is-language' {Σ} R x = accept (automaton R) (astart R) x where
open RegularLanguage
-- a language is implemented by an automaton
-- postulate
-- fin-× : {A B : Set} → { a b : ℕ } → FiniteSet A {a} → FiniteSet B {b} → FiniteSet (A × B) {a * b}
M-Union : {Σ : Set} → (A B : RegularLanguage Σ ) → RegularLanguage Σ
M-Union {Σ} A B = record {
states = states A × states B
; astart = ( astart A , astart B )
; afin = fin-× (afin A) (afin B)
; automaton = record {
δ = λ q x → ( δ (automaton A) (proj₁ q) x , δ (automaton B) (proj₂ q) x )
; aend = λ q → ( aend (automaton A) (proj₁ q) \/ aend (automaton B) (proj₂ q) )
}
}
closed-in-union : {Σ : Set} → (A B : RegularLanguage Σ ) → ( x : List Σ ) → isRegular (Union (contain A) (contain B)) x ( M-Union A B )
closed-in-union A B [] = lemma where
lemma : aend (automaton A) (astart A) \/ aend (automaton B) (astart B) ≡
aend (automaton A) (astart A) \/ aend (automaton B) (astart B)
lemma = refl
closed-in-union {Σ} A B ( h ∷ t ) = lemma1 t ((δ (automaton A) (astart A) h)) ((δ (automaton B) (astart B) h)) where
lemma1 : (t : List Σ) → (qa : states A ) → (qb : states B ) →
accept (automaton A) qa t \/ accept (automaton B) qb t
≡ accept (automaton (M-Union A B)) (qa , qb) t
lemma1 [] qa qb = refl
lemma1 (h ∷ t ) qa qb = lemma1 t ((δ (automaton A) qa h)) ((δ (automaton B) qb h))
| {
"alphanum_fraction": 0.5643970468,
"avg_line_length": 34.5,
"ext": "agda",
"hexsha": "bbc4489606b508fc379f037a3b3771774205986e",
"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": "eba0538f088f3d0c0fedb19c47c081954fbc69cb",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "shinji-kono/automaton-in-agda",
"max_forks_repo_path": "src/regular-language.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "shinji-kono/automaton-in-agda",
"max_issues_repo_path": "src/regular-language.agda",
"max_line_length": 136,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "shinji-kono/automaton-in-agda",
"max_stars_repo_path": "src/regular-language.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1338,
"size": 3657
} |
{-# OPTIONS --safe #-}
module Cubical.HITs.Truncation.FromNegTwo where
open import Cubical.HITs.Truncation.FromNegTwo.Base public
open import Cubical.HITs.Truncation.FromNegTwo.Properties public
| {
"alphanum_fraction": 0.8214285714,
"avg_line_length": 32.6666666667,
"ext": "agda",
"hexsha": "257017b24bd0a015fbdc9b421769673542514a86",
"lang": "Agda",
"max_forks_count": 134,
"max_forks_repo_forks_event_max_datetime": "2022-03-23T16:22:13.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-11-16T06:11:03.000Z",
"max_forks_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "marcinjangrzybowski/cubical",
"max_forks_repo_path": "Cubical/HITs/Truncation/FromNegTwo.agda",
"max_issues_count": 584,
"max_issues_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237",
"max_issues_repo_issues_event_max_datetime": "2022-03-30T12:09:17.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-10-15T09:49:02.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "marcinjangrzybowski/cubical",
"max_issues_repo_path": "Cubical/HITs/Truncation/FromNegTwo.agda",
"max_line_length": 64,
"max_stars_count": 301,
"max_stars_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "marcinjangrzybowski/cubical",
"max_stars_repo_path": "Cubical/HITs/Truncation/FromNegTwo.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-24T02:10:47.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-10-17T18:00:24.000Z",
"num_tokens": 51,
"size": 196
} |
open import Empty
module Boolean where
data Bool : Set where
true : Bool
false : Bool
{-# BUILTIN BOOL Bool #-}
{-# BUILTIN TRUE true #-}
{-# BUILTIN FALSE false #-}
T : Bool → Set
T true = ⊤
T false = ⊥
not : Bool → Bool
not true = false
not false = true
and : Bool → Bool → Bool
and true true = true
and _ _ = false
or : Bool → Bool → Bool
or false false = false
or _ _ = true
xor : Bool → Bool → Bool
xor false true = true
xor true false = true
xor _ _ = false
infixr 6 _∧_
infixr 5 _∨_
¬_ : Set → Set
¬ A = A → ⊥
data _∨_ A B : Set where
Inl : A → A ∨ B
Inr : B → A ∨ B
data _∧_ A B : Set where
Conj : A → B → A ∧ B
_⇔_ : (P : Set) → (Q : Set) → Set
a ⇔ b = (a → b) ∧ (b → a)
∧-symmetry : ∀ { A B : Set } → A ∧ B → B ∧ A
∧-symmetry (Conj x y) = Conj y x
∨-symmetry : ∀ { A B : Set } → A ∨ B → B ∨ A
∨-symmetry (Inl x) = Inr x
∨-symmetry (Inr y) = Inl y
and_over : { A B C : Set } → A ∧ ( B ∨ C ) → ( A ∧ B ) ∨ ( A ∧ C )
and_over (Conj x (Inl y)) = Inl (Conj x y)
and_over (Conj x (Inr y)) = Inr (Conj x y)
and_over' : { A B C : Set } → ( A ∧ B ) ∨ ( A ∧ C ) → A ∧ ( B ∨ C )
and_over' (Inl (Conj x y)) = Conj x (Inl y)
and_over' (Inr (Conj x y)) = Conj x (Inr y)
or_over : { A B C : Set } → A ∨ ( B ∧ C ) → ( A ∨ B ) ∧ ( A ∨ C )
or_over (Inl x) = Conj (Inl x) (Inl x)
or_over (Inr (Conj x y)) = Conj (Inr x) (Inr y)
or_over' : { A B C : Set } → ( A ∨ B ) ∧ ( A ∨ C ) → A ∨ ( B ∧ C )
or_over' (Conj (Inl x) _) = Inl x
or_over' (Conj _ (Inl y)) = Inl y
or_over' (Conj (Inr x) (Inr y)) = Inr (Conj x y)
or_over_negated : { A B : Set } → ( A ∨ ( ¬ A ∧ B ) ) → ( A ∨ B )
or_over_negated (Inl x) = Inl x
or_over_negated (Inr (Conj _ y)) = Inr y
private
proof₁ : { P Q : Set } → (P ∧ Q) → P
proof₁ (Conj p q) = p
proof₂ : { P Q : Set } → (P ∧ Q) → Q
proof₂ (Conj p q) = q
deMorgan₁ : { A B : Set } → ¬ A ∧ ¬ B → ¬ (A ∨ B)
deMorgan₁ (Conj ¬x ¬y) (Inl x) = ¬x x
deMorgan₁ (Conj ¬x ¬y) (Inr y) = ¬y y
-- above is clearer if you re-write the type annotation as:
--deMorgan₁ : { A B : Set } → (A → ⊥) ∧ (B → ⊥) → (A ∨ B) → ⊥
deMorgan₂ : { A B : Set } → ¬ (A ∨ B) → ¬ A ∧ ¬ B
deMorgan₂ z = Conj (λ x → z (Inl x)) (λ y → z (Inr y))
deMorgan₃ : { A B : Set } → ¬ A ∨ ¬ B → ¬ (A ∧ B)
deMorgan₃ (Inl ¬x) (Conj x _) = ¬x x
deMorgan₃ (Inr ¬y) (Conj _ y) = ¬y y
-- NOT provable.
-- deMorgan₄ : { A B : Set } → ¬ (A ∧ B) → ¬ A ∨ ¬ B
| {
"alphanum_fraction": 0.4746101559,
"avg_line_length": 25.01,
"ext": "agda",
"hexsha": "707d01c977f7c2c10301cf683b895f577a6c891b",
"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": "382fcfae193079783621fc5cf54b6588e22ef759",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "cantsin/agda-experiments",
"max_forks_repo_path": "Boolean.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "382fcfae193079783621fc5cf54b6588e22ef759",
"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": "cantsin/agda-experiments",
"max_issues_repo_path": "Boolean.agda",
"max_line_length": 69,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "382fcfae193079783621fc5cf54b6588e22ef759",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "cantsin/agda-experiments",
"max_stars_repo_path": "Boolean.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1132,
"size": 2501
} |
-- Andreas, 2016-12-30, issues #555 and #1886, reported by nad
-- Hidden parameters can be omitted in the repetition
-- of the parameter list.
record R {a} (A : Set a) : Set a
record R A where
constructor c
field f : A
testR : ∀{a}{A : Set a}(x : A) → R A
testR x = c x
data D {a} (A : Set a) : Set a
data D A where
c : A → D A
testD : ∀{a}{A : Set a}(x : A) → D A
testD x = c x
-- Now, c is overloaded, should still work.
testR' : ∀{a}{A : Set a}(x : A) → R A
testR' x = c x
| {
"alphanum_fraction": 0.5795918367,
"avg_line_length": 18.8461538462,
"ext": "agda",
"hexsha": "372824fc0dfa715cd1833e5e29970ad92f580457",
"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/Issue1886-omit-hidden.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/Issue1886-omit-hidden.agda",
"max_line_length": 62,
"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/Issue1886-omit-hidden.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": 191,
"size": 490
} |
{-# OPTIONS --no-print-pattern-synonyms #-}
open import Agda.Builtin.Nat
open import Agda.Builtin.Equality
data Fin : Nat → Set where
fzero : ∀ {n} → Fin (suc n)
fsuc : ∀ {n} → Fin n → Fin (suc n)
pattern #1 = fsuc fzero
prf : (i : Fin 2) → i ≡ #1
prf i = refl -- should say i != fsuc fzero
| {
"alphanum_fraction": 0.6079734219,
"avg_line_length": 21.5,
"ext": "agda",
"hexsha": "53d3351b8427c3201bbf6e45cb52765aee67d27e",
"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/Issue2902.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/Issue2902.agda",
"max_line_length": 43,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Fail/Issue2902.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": 301
} |
module Numeral.Sign where
import Lvl
open import Type
-- The set of plus or minus sign
data +|− : Type{Lvl.𝟎} where
➕ : (+|−)
➖ : (+|−)
−|+ = +|−
elim₂ : ∀{ℓ}{P : (+|−) → Type{ℓ}} → P(➖) → P(➕) → ((s : (+|−)) → P(s))
elim₂ neg pos ➖ = neg
elim₂ neg pos ➕ = pos
-- The set of signs: plus, minus and neutral
data +|0|− : Type{Lvl.𝟎} where
➕ : (+|0|−)
𝟎 : (+|0|−)
➖ : (+|0|−)
−|0|+ = +|0|−
elim₃ : ∀{ℓ}{P : (+|0|−) → Type{ℓ}} → P(➖) → P(𝟎) → P(➕) → ((s : (+|0|−)) → P(s))
elim₃ neg zero pos ➖ = neg
elim₃ neg zero pos 𝟎 = zero
elim₃ neg zero pos ➕ = pos
zeroable : (+|−) → (+|0|−)
zeroable (➕) = (➕)
zeroable (➖) = (➖)
| {
"alphanum_fraction": 0.4507042254,
"avg_line_length": 19.3636363636,
"ext": "agda",
"hexsha": "692b0f532ce889d7bd6637e98e0c6f1044556c93",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Numeral/Sign.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Numeral/Sign.agda",
"max_line_length": 81,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Numeral/Sign.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": 327,
"size": 639
} |
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
open import LibraBFT.Base.Types
import LibraBFT.Impl.Consensus.SafetyRules.SafetyRules as SafetyRules
import LibraBFT.Impl.Consensus.TestUtils.MockStorage as MockStorage
open import LibraBFT.ImplShared.Consensus.Types
open import LibraBFT.ImplShared.Util.Dijkstra.All
open import Optics.All
open import Util.Prelude
module LibraBFT.Impl.Consensus.MetricsSafetyRules where
module performInitialize
(self : SafetyRules)
(obmPersistentLivenessStorage : PersistentLivenessStorage)
where
step₀ : EitherD ErrLog SafetyRules
step₁ : EpochChangeProof → EitherD ErrLog SafetyRules
step₀ = do
let consensusState = SafetyRules.consensusState self
srWaypoint = consensusState ^∙ csWaypoint
proofs ← MockStorage.retrieveEpochChangeProofED
(srWaypoint ^∙ wVersion) obmPersistentLivenessStorage
step₁ proofs
step₁ proofs = SafetyRules.initialize-ed-abs self proofs
abstract
performInitialize-ed-abs = performInitialize.step₀
performInitialize-abs : SafetyRules → PersistentLivenessStorage → Either ErrLog SafetyRules
performInitialize-abs sr storage = toEither $ performInitialize-ed-abs sr storage
performInitialize-abs-≡ : (sr : SafetyRules) (storage : PersistentLivenessStorage)
→ performInitialize-abs sr storage ≡ EitherD-run (performInitialize-ed-abs sr storage)
performInitialize-abs-≡ sr storage = refl
| {
"alphanum_fraction": 0.7669263032,
"avg_line_length": 41.725,
"ext": "agda",
"hexsha": "d6022c9a3b52b26e8c5d078aea2b24cb4d0604ea",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_forks_repo_licenses": [
"UPL-1.0"
],
"max_forks_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_forks_repo_path": "src/LibraBFT/Impl/Consensus/MetricsSafetyRules.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"UPL-1.0"
],
"max_issues_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_issues_repo_path": "src/LibraBFT/Impl/Consensus/MetricsSafetyRules.agda",
"max_line_length": 112,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_stars_repo_licenses": [
"UPL-1.0"
],
"max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_stars_repo_path": "src/LibraBFT/Impl/Consensus/MetricsSafetyRules.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 402,
"size": 1669
} |
-- Andreas, 2011-10-04, transcription of Dan Doel's post on the Agda list
{-# OPTIONS --experimental-irrelevance #-}
module IrrelevantMatchRefl where
import Common.Level
open import Common.Equality hiding (subst)
-- irrelevant subst should be rejected, because it suggests
-- that the equality proof is irrelevant also for reduction
subst : ∀ {i j}{A : Set i}(P : A → Set j){a b : A} → .(a ≡ b) → P a → P b
subst P refl x = x
postulate
D : Set
lie : (D → D) ≡ D
-- the following two substs may not reduce! ...
abs : (D → D) → D
abs f = subst (λ T → T) lie f
app : D → D → D
app d = subst (λ T → T) (sym lie) d
ω : D
ω = abs (λ d → app d d)
-- ... otherwise Ω loops
Ω : D
Ω = app ω ω
-- ... and this would be a real fixed-point combinator
Y : (D → D) → D
Y f = app δ δ
where δ = abs (λ x → f (app x x))
K : D → D
K x = abs (λ y → x)
K∞ : D
K∞ = Y K
mayloop : K∞ ≡ abs (λ y → K∞)
mayloop = refl
-- gives error D != D → D
| {
"alphanum_fraction": 0.5948827292,
"avg_line_length": 20.8444444444,
"ext": "agda",
"hexsha": "f37ed6e5ac5a8fd2a5b236d3b61d156d15bdb8f8",
"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/IrrelevantMatchRefl.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/IrrelevantMatchRefl.agda",
"max_line_length": 73,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/IrrelevantMatchRefl.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": 342,
"size": 938
} |
{-# OPTIONS --without-K #-}
open import HoTT
open import homotopy.JoinFunc
-- Associativity of the join (work in progress)
module homotopy.JoinAssoc3 where
import homotopy.JoinAssoc as Assoc
module JoinAssoc3 {i} (A : Type i) (B : Type i) (C : Type i) where
module A31 = Assoc A B C
postulate
-- from : ((A * B) * C) → (A * (B * C))
-- to : (A * (B * C)) → ((A * B) * C)
to-from : (z : (A * (B * C))) → (A31.to (A31.from z)) == z
from = A31.from
to = A31.to
idc : C → C
idc c = c
ida : A → A
ida a = a
-- import homotopy.JoinComm as JoinComm
-- open JoinComm
-- from' : ((A * B) * C) → (A * (B * C))
-- from' z = {! swap $ swap ** ida [ to $ swap $ swap ** idc [ z ] ] !}
module _ {i} {A : Type i} {B : Type i} {C : Type i} where
import homotopy.JoinComm as JoinComm
open JoinComm
module JA31 = JoinAssoc3 A B C
module JA32 = JoinAssoc3 C B A
module JA33 = JoinAssoc3 B A C
idc : C → C
idc c = c
ida : A → A
ida a = a
-- need A * (B * C)
from-to : (z : ((A * B) * C)) -> (JA31.from (JA31.to z)) == z
from-to z with JA31.to z -- idc ** swap [ {! swap $ swap ** idc [ z ]!} ] --JA32.to $ swap $ swap ** idc [ z ] ]
... | p = {!JA31.to-from p!} -- JA31.from-to p
| {
"alphanum_fraction": 0.5269509252,
"avg_line_length": 24.3725490196,
"ext": "agda",
"hexsha": "d20c9012d4ebe6a30fd08eecd43cab36cfa36d99",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "f8fa68bf753d64d7f45556ca09d0da7976709afa",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "UlrikBuchholtz/HoTT-Agda",
"max_forks_repo_path": "homotopy/JoinAssoc3.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f8fa68bf753d64d7f45556ca09d0da7976709afa",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "UlrikBuchholtz/HoTT-Agda",
"max_issues_repo_path": "homotopy/JoinAssoc3.agda",
"max_line_length": 115,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "f8fa68bf753d64d7f45556ca09d0da7976709afa",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "UlrikBuchholtz/HoTT-Agda",
"max_stars_repo_path": "homotopy/JoinAssoc3.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 485,
"size": 1243
} |
{- Formal verification of authenticated append-only skiplists in Agda, version 1.0.
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 Data.Unit.NonEta
open import Data.Empty
open import Data.Fin using (Fin; fromℕ≤) renaming (zero to fz; suc to fs)
import Data.Fin.Properties renaming (_≟_ to _≟Fin_)
open import Data.Sum
open import Data.Product
open import Data.Product.Properties
open import Data.Nat renaming (_≟_ to _≟ℕ_; _≤?_ to _≤?ℕ_)
open import Data.Nat.Properties
open import Data.List renaming (map to List-map)
open import Data.List.Properties using (∷-injective; length-++)
open import Data.List.Relation.Binary.Pointwise using (decidable-≡)
open import Data.List.Relation.Unary.All as List-All
open import Data.List.Relation.Unary.Any renaming (map to Any-map)
open import Data.List.Relation.Unary.Any.Properties renaming (gmap to Any-gmap)
open import Data.Bool hiding (_≤_ ; _<_)
open import Data.Maybe renaming (map to Maybe-map)
open import Function using (_∘_)
open import Relation.Binary.PropositionalEquality
open ≡-Reasoning
open import Relation.Binary.Core
open import Relation.Nullary
-- This module contains various useful lemmas
module AAOSL.Lemmas where
-----------------------------
-- Properties about functions
postulate -- valid assumption, functional extensionality
fun-ext : ∀{a b}{A : Set a}{B : Set b}
→ {f g : A → B}
→ (∀ x → f x ≡ g x)
→ f ≡ g
------------------------------
-- Properties about inequality
≢-pi : ∀{a}{A : Set a}{m n : A}(p q : m ≢ n) → p ≡ q
≢-pi p q = fun-ext {f = p} {q} (λ x → ⊥-elim (p x))
suc-≢ : ∀ {m n} → (suc m ≢ suc n) → m ≢ n
suc-≢ sm≢sn m≡n = sm≢sn (cong suc m≡n)
*-cong-≢ : ∀ p {m n} → 0 < p → m ≢ n → p * m ≢ p * n
*-cong-≢ (suc p) 0<p m≢n p*m≡p*n = m≢n (*-cancelˡ-≡ p p*m≡p*n)
⊥-1≡m*2 : ∀ m → 1 ≢ m * 2
⊥-1≡m*2 zero = λ x → <⇒≢ (s≤s z≤n) (sym x)
⊥-1≡m*2 (suc m) = λ x → <⇒≢ (s≤s z≤n) (suc-injective x)
∸-≢ : ∀{m} n → 1 ≤ n → n ≤ suc m → suc m ∸ n ≢ suc m
∸-≢ {m} (suc n) 1≤n (s≤s n≤sm)
rewrite sym (+-identityʳ (suc m))
| sym (n∸n≡0 n)
| sym (+-∸-assoc m {n} {n} ≤-refl)
| +-∸-comm {m} n {n} n≤sm = m≢1+m+n (m ∸ n)
1≢a+b : ∀{a b} → 1 ≤ a → 1 ≤ b → 1 ≢ a + b
1≢a+b (s≤s {n = a} 1≤a) (s≤s {n = b} 1≤b) abs
rewrite +-comm a (suc b) = 1+n≢0 (sym (suc-injective abs))
0≢a*b-magic : ∀{a b} → 0 < a → 0 < b → 0 ≢ a * b
0≢a*b-magic {a} {b} 0<a 0<b hip
with m*n≡0⇒m≡0∨n≡0 a (sym hip)
... | inj₁ x = <⇒≢ 0<a (sym x)
... | inj₂ y = <⇒≢ 0<b (sym y)
-----------------------------------
-- Injectivty of ℕ ranged functions
*2-injective : ∀ n m → n * 2 ≡ m * 2 → m ≡ n
*2-injective zero zero x = refl
*2-injective (suc n) (suc m) x
= cong suc (*2-injective n m (suc-injective (suc-injective x)))
2^-injective : ∀ {n m : ℕ}
→ 2 ^ n ≡ 2 ^ m
→ n ≡ m
2^-injective {n} {zero} 2^n≡2^0
with (m^n≡1⇒n≡0∨m≡1 2 n 2^n≡2^0)
...| inj₁ m≡0 = m≡0
2^-injective {zero} {suc m} 2^0≡2^sm
with (m^n≡1⇒n≡0∨m≡1 2 (suc m) (sym 2^0≡2^sm))
...| inj₁ sm≡0 = sym sm≡0
2^-injective {suc n} {suc m} 2^n≡2^m = cong suc (2^-injective (*-cancelˡ-≡ {2 ^ n} {2 ^ m} 1 2^n≡2^m))
+-inj : ∀ {m n p : ℕ} → m + n ≡ m + p → n ≡ p
+-inj {0} {n} {p} prf = prf
+-inj {suc m} {n} {p} prf = +-inj (suc-injective prf)
∸-inj : ∀{m} o n → o ≤ m → n ≤ m → m ∸ o ≡ m ∸ n → o ≡ n
∸-inj {m} o n o≤m n≤m m∸o≡m∸n =
begin
o
≡⟨ sym (m∸[m∸n]≡n o≤m) ⟩
m ∸ (m ∸ o)
≡⟨ cong (m ∸_) m∸o≡m∸n ⟩
m ∸ (m ∸ n)
≡⟨ m∸[m∸n]≡n n≤m ⟩
n
∎
-------------------------------
-- Properties about _≤_ and _<_
<-≤-trans : ∀{m n o} → m < n → n ≤ o → m < o
<-≤-trans p q = ≤-trans p q
≤-<-trans : ∀{m n o} → m ≤ n → n < o → m < o
≤-<-trans p q = ≤-trans (s≤s p) q
≤-unstep2 : ∀{m n} → suc m ≤ suc n → m ≤ n
≤-unstep2 (s≤s p) = p
≤-unstep : ∀{m n} → suc m ≤ n → m ≤ n
≤-unstep (s≤s p) = ≤-step p
0<-suc : ∀{m} → 0 < m → ∃[ n ] (m ≡ suc n)
0<-suc (s≤s p) = _ , refl
1≤0-⊥ : 1 ≤ 0 → ⊥
1≤0-⊥ ()
-------------------------------
-- Properties of Multiplication
a*2-lemma : ∀ a → (a + (a + zero)) ≡ a * 2
a*2-lemma a rewrite *-comm a 2 = refl
*2< : ∀ (m n : ℕ)
→ m * 2 < n * 2
→ m < n
*2< 0 0 ()
*2< 0 (suc n) _ = s≤s z≤n
*2< (suc m) (suc n) (s≤s (s≤s x)) = s≤s (*2< m n x)
a*b*2-lemma : ∀ a b → a * b * 2 ≡ (a + (a + zero)) * b
a*b*2-lemma a b rewrite *-comm (a * b) 2
| *-assoc 2 a b = refl
+-*-suc' : ∀ m n → m * suc n ≡ m + n * m
+-*-suc' m n with *-suc m n
...| xx rewrite *-comm n m = xx
----------------------------------
-- Properties of divisibility by 2
1+n=m*2⇒m<1+n : ∀ m n → 1 + n ≡ m * 2 → m < 1 + n
1+n=m*2⇒m<1+n (suc zero) (suc n) eq = s≤s (s≤s z≤n)
1+n=m*2⇒m<1+n (suc (suc m)) (suc (suc n)) eq = s≤s (<-trans ih (n<1+n (1 + n)))
where
eq' : 1 + n ≡ (1 + m) * 2
eq' = +-cancelˡ-≡ 2 eq
ih : (1 + m) < 1 + n
ih = 1+n=m*2⇒m<1+n (1 + m) n eq'
-------------------------------
-- Properties of exponentiation
1≤2^n : ∀ n → 1 ≤ (2 ^ n)
1≤2^n 0 = s≤s z≤n
1≤2^n (suc n) = ≤-trans (1≤2^n n) (m≤m+n (2 ^ n) ((2 ^ n) + zero))
1<2^sucn : ∀ n → 1 < (2 ^ suc n)
1<2^sucn n = ≤∧≢⇒< (1≤2^n (suc n))
(subst (λ P → 1 ≢ (2 ^ n) + P)
(+-comm 0 (2 ^ n))
(1≢a+b (1≤2^n n) (1≤2^n n)))
pow*d>1 : ∀ k d → 0 < k → 0 < d → 1 < 2 ^ k * d
pow*d>1 (suc k) d 0<k 0<d = *-mono-≤ (1<2^sucn k) 0<d
2^ld-2l : ∀ l₀ l₁ d → l₁ ≤ l₀
→ (2 ^ l₀) * d ∸ 2 ^ l₁ ≡ 2 ^ l₁ * (2 ^ (l₀ ∸ l₁) * d ∸ 1)
2^ld-2l l₀ l₁ d x rewrite *-distribˡ-∸ (2 ^ l₁) (2 ^ (l₀ ∸ l₁) * d) 1
| sym (*-assoc (2 ^ l₁) (2 ^ (l₀ ∸ l₁)) d)
| sym (^-distribˡ-+-* 2 l₁ (l₀ ∸ l₁))
| sym (+-∸-assoc l₁ {l₀} {l₁} x)
| m+n∸m≡n l₁ l₀
| *-identityʳ (2 ^ l₁) = refl
-------------------------------------
-- Monotonicity of ℕ ranged functions
2^-mono : ∀{m n} → m < n → 2 ^ m < 2 ^ n
2^-mono {zero} {suc zero} x = s≤s (s≤s z≤n)
2^-mono {zero} {suc (suc n)} x = +-mono-<-≤ (2^-mono {zero} {suc n} (s≤s z≤n))
(m≤n+m zero (2 * 2 ^ n))
2^-mono {suc m} {suc n} (s≤s x) = +-mono-< (2^-mono x)
(+-mono-<-≤ (2^-mono x) z≤n)
log-mono : ∀ (l n : ℕ)
→ 2 ^ l < 2 ^ n
→ l < n
log-mono l 0 x = ⊥-elim (<⇒≱ x (1≤2^n l))
log-mono 0 (suc n) x = s≤s z≤n
log-mono (suc l) (suc n) x
rewrite a*2-lemma (2 ^ l) | a*2-lemma (2 ^ n)
= s≤s ((log-mono l n (*2< (2 ^ l) (2 ^ n) x)))
^-mono : ∀ (l n : ℕ) → l ≤ n → 2 ^ l ≤ 2 ^ n
^-mono zero n _ = 1≤2^n n
^-mono (suc l) zero ()
^-mono (suc l) (suc n) (s≤s xx)
rewrite +-identityʳ (2 ^ l)
| +-identityʳ (2 ^ n)
= +-mono-≤ (^-mono l n xx) (^-mono l n xx)
2^kd-mono : ∀{m n d} → m ≤ n → 0 < d → 2 ^ m ≤ 2 ^ n * d
2^kd-mono {m} {n} {d} m≤n 0<d = ≤-trans (^-mono m n m≤n) (m≤m*n (2 ^ n) 0<d)
1≤m*n⇒0<n : ∀{m n} → 1 ≤ m * n → 0 < n
1≤m*n⇒0<n {m} {n} 1≤m*n rewrite *-comm m n = 1≤n*m⇒0<n n m 1≤m*n
where 1≤n*m⇒0<n : ∀ m n → 1 ≤ m * n → 0 < m
1≤n*m⇒0<n (suc m) n 1≤m*n = s≤s z≤n
n+p≡m+q∧n<m⇒q<p : ∀ {n p m q} → n < m → n + p ≡ m + q → q < p
n+p≡m+q∧n<m⇒q<p {n} {p} {m} {q} n<m n+p≡m+q = +-cancelˡ-< n (subst ((n + q) <_) (sym n+p≡m+q) (+-monoˡ-< q n<m))
-------------------
-- Misc. Properties
ss≰1 : ∀{n} → suc (suc n) ≰ 1
ss≰1 (s≤s ())
∸-split : ∀{a b c} → c < b → b < a → a ∸ c ≡ (a ∸ b) + (b ∸ c)
∸-split {a} {b} {c} c<b b<a
rewrite sym (+-∸-comm {a} (b ∸ c) {b} (<⇒≤ b<a))
| sym (+-∸-assoc a {b} {c} (<⇒≤ c<b))
| +-∸-comm {a} b {c} (<⇒≤ (<-trans c<b b<a))
| m+n∸n≡m (a ∸ c) b = refl
0<m-n : ∀{m n} → n < m → 0 < m ∸ n
0<m-n {n = zero} (s≤s x) = s≤s x
0<m-n {n = suc n} (s≤s x) = 0<m-n x
2^k-is-suc : ∀ n → ∃ (λ r → 2 ^ n ≡ suc r)
2^k-is-suc zero = 0 , refl
2^k-is-suc (suc n) with 2^k-is-suc n
...| fst , snd rewrite snd
| +-identityʳ fst
| +-comm fst (suc fst) = (suc (fst + fst)) , refl
-------------------------
-- Properties about lists
∷≡[]-⊥ : ∀{a}{A : Set a}{x : A}{xs : List A}
→ _≡_ {a} {List A} (x ∷ xs) [] → ⊥
∷≡[]-⊥ ()
All-pi : ∀{a}{A : Set a}{P : A → Set}
→ (∀ {x}(p₁ p₂ : P x) → p₁ ≡ p₂)
→ {xs : List A}
→ (a₁ a₂ : All P xs)
→ a₁ ≡ a₂
All-pi P-pi [] [] = refl
All-pi P-pi (a ∷ as) (b ∷ bs) = cong₂ _∷_ (P-pi a b) (All-pi P-pi as bs)
_∈_ : {A : Set} → A → List A → Set
x ∈ xs = Any (_≡_ x) xs
witness : {A : Set}{P : A → Set}{x : A}{xs : List A}
→ x ∈ xs → All P xs → P x
witness {x = x} {xs = []} ()
witness {P = P } {x = x} {xh ∷ xt} (here px) all = subst P (sym px) (List-All.head all)
witness {x = x} {xh ∷ xt} (there x∈xt) all = witness x∈xt (List-All.tail all)
List-map-≡ : {A B : Set}
→ (f g : A → B)
→ (xs : List A)
→ (∀ x → x ∈ xs → f x ≡ g x)
→ List-map f xs ≡ List-map g xs
List-map-≡ f g [] prf = refl
List-map-≡ f g (x ∷ xs) prf
= cong₂ _∷_ (prf x (here refl)) (List-map-≡ f g xs
(λ x₁ prf' → prf x₁ (there prf')))
List-map-≡-All : {A B : Set}
→ (f g : A → B)
→ (xs : List A)
→ All (λ x → f x ≡ g x) xs
→ List-map f xs ≡ List-map g xs
List-map-≡-All f g xs hyp
= List-map-≡ f g xs (λ x x∈xs → witness x∈xs hyp)
nats : (n : ℕ) → List (Fin n)
nats 0 = []
nats (suc n) = fz ∷ List-map fs (nats n)
nats-correct : ∀{m}(x : Fin m) → x ∈ nats m
nats-correct {suc m} fz = here refl
nats-correct {suc m} (fs x) = there (Any-gmap (cong fs) (nats-correct x))
nats-length : ∀{m} → 0 < m → 1 ≤ length (nats m)
nats-length (s≤s prf) = s≤s z≤n
++-inj : ∀{a}{A : Set a}{m n o p : List A}
→ length m ≡ length n → m ++ o ≡ n ++ p
→ m ≡ n × o ≡ p
++-inj {m = []} {x ∷ n} () hip
++-inj {m = x ∷ m} {[]} () hip
++-inj {m = []} {[]} lhip hip
= refl , hip
++-inj {m = m ∷ ms} {n ∷ ns} lhip hip
with ++-inj {m = ms} {ns} (suc-injective lhip) (proj₂ (∷-injective hip))
...| (mn , op) rewrite proj₁ (∷-injective hip)
= cong (n ∷_) mn , op
++-abs : ∀{a}{A : Set a}{n : List A}(m : List A)
→ 1 ≤ length m → [] ≡ m ++ n → ⊥
++-abs [] ()
++-abs (x ∷ m) imp ()
++-injₕ : ∀{a}{A : Set a}{m o p : List A}
→ m ++ o ≡ m ++ p
→ o ≡ p
++-injₕ {m = m} {o} {p} r = proj₂ (++-inj {m = m} {m} {o} {p} refl r)
| {
"alphanum_fraction": 0.4347218339,
"avg_line_length": 32.5181818182,
"ext": "agda",
"hexsha": "a78666ca60470ec1f08cf1bc6bf57ef602da8325",
"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": "356489da3a99c66807606eca8dd235dc6140649c",
"max_forks_repo_licenses": [
"UPL-1.0"
],
"max_forks_repo_name": "cwjnkins/aaosl-agda",
"max_forks_repo_path": "AAOSL/Lemmas.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "356489da3a99c66807606eca8dd235dc6140649c",
"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/aaosl-agda",
"max_issues_repo_path": "AAOSL/Lemmas.agda",
"max_line_length": 113,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "356489da3a99c66807606eca8dd235dc6140649c",
"max_stars_repo_licenses": [
"UPL-1.0"
],
"max_stars_repo_name": "cwjnkins/aaosl-agda",
"max_stars_repo_path": "AAOSL/Lemmas.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 5029,
"size": 10731
} |
module Algebra.Module.Morphism.Module where
open import Assume using (assume)
open import Algebra.Core using (Op₁; Op₂)
open import Algebra.Bundles using (CommutativeRing)
open import Algebra.Module.Bundles using (Module)
open import Algebra.Module.Structures using (IsModule)
open import Algebra.Module.Normed using (IsNormedModule; NormedModule)
open import Relation.Binary.Core using (Rel)
open import Data.Product using (Σ-syntax; ∃-syntax; _×_; _,_; proj₁)
open import Algebra.Module.Morphism.Structures
using (IsModuleHomomorphism; IsModuleMonomorphism; IsModuleIsomorphism)
open import Level using (_⊔_; suc)
private
module toModule
{a} (A : Set a)
{r ℓr} {CR : CommutativeRing r ℓr}
{mb ℓmb} (MB : Module CR mb ℓmb)
where
private
module CR = CommutativeRing CR
module MB = Module MB
Carrierᴹ : Set _
Carrierᴹ = A → MB.Carrierᴹ
_≈ᴹ_ : Rel Carrierᴹ _
f ≈ᴹ g = ∀ a → f a MB.≈ᴹ g a
_+ᴹ_ : Op₂ Carrierᴹ
f +ᴹ g = λ a → f a MB.+ᴹ g a
_*ₗ_ : CR.Carrier → Carrierᴹ → Carrierᴹ
s *ₗ f = λ a → s MB.*ₗ f a
_*ᵣ_ : Carrierᴹ → CR.Carrier → Carrierᴹ
f *ᵣ s = λ a → f a MB.*ᵣ s
0ᴹ : Carrierᴹ
0ᴹ _ = MB.0ᴹ
-ᴹ_ : Op₁ Carrierᴹ
-ᴹ_ f = λ a → MB.-ᴹ f a
isModule : IsModule CR _≈ᴹ_ _+ᴹ_ 0ᴹ -ᴹ_ _*ₗ_ _*ᵣ_
isModule = assume
→-module
: ∀ {a} (A : Set a)
{r ℓr} {CR : CommutativeRing r ℓr}
{mb ℓmb} (MB : Module CR mb ℓmb)
→ Module CR (a ⊔ mb) (a ⊔ ℓmb)
→-module A MB = record { toModule A MB }
→-module'
: ∀ {r ℓr} {CR : CommutativeRing r ℓr}
{ma ℓma} (MA : Module CR ma ℓma)
{mb ℓmb} (MB : Module CR mb ℓmb)
→ Module CR (ma ⊔ mb) (ma ⊔ ℓmb)
→-module' MA MB = →-module (Carrierᴹ MA) MB
where open Module
module _
{r ℓr} {CR : CommutativeRing r ℓr}
{ma ℓma} (MA : Module CR ma ℓma)
{mb ℓmb} (MB : Module CR mb ℓmb)
where
private
module MA = Module MA
module MB = Module MB
_⊸_ : Set _
_⊸_ = ∃[ f ] IsModuleHomomorphism MA MB f
⊸-module : Module CR (r ⊔ ma ⊔ ℓma ⊔ mb ⊔ ℓmb) (ma ⊔ ℓmb)
⊸-module =
record
{ Carrierᴹ = _⊸_
; _≈ᴹ_ = λ f g → ∀ x → proj₁ f x MB.≈ᴹ proj₁ g x
; _+ᴹ_ = λ f g → (λ x → proj₁ f x MB.+ᴹ proj₁ g x) , assume
; _*ₗ_ = λ s f → (λ x → s MB.*ₗ proj₁ f x) , assume
; _*ᵣ_ = λ f s → (λ x → proj₁ f x MB.*ᵣ s) , assume
; 0ᴹ = (λ x → MB.0ᴹ) , assume
; -ᴹ_ = λ f → (λ x → MB.-ᴹ proj₁ f x) , assume
; isModule = assume
}
module _
{r ℓr} {CR : CommutativeRing r ℓr}
(open CommutativeRing CR using () renaming (Carrier to S))
{rel} {_≤_ : Rel S rel}
{ma ℓma} (MA : NormedModule CR _≤_ ma ℓma)
{mb ℓmb} (MB : NormedModule CR _≤_ mb ℓmb)
where
private
module MB = NormedModule MB
module MA = NormedModule MA
⊸-normed : NormedModule CR _≤_ _ _
⊸-normed =
record
{ M = ⊸-module MA.M MB.M
; ∥_∥ = λ f → MB.∥ proj₁ f MA.0ᴹ ∥
; isNormedModule = assume
}
| {
"alphanum_fraction": 0.5924914676,
"avg_line_length": 25.4782608696,
"ext": "agda",
"hexsha": "3a20d06351d8a0d44584e7e48de0f8daff8f1dc3",
"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": "a193aeebf1326f960975b19d3e31b46fddbbfaa2",
"max_forks_repo_licenses": [
"CC0-1.0"
],
"max_forks_repo_name": "cspollard/reals",
"max_forks_repo_path": "src/Algebra/Module/Morphism/Module.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a193aeebf1326f960975b19d3e31b46fddbbfaa2",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"CC0-1.0"
],
"max_issues_repo_name": "cspollard/reals",
"max_issues_repo_path": "src/Algebra/Module/Morphism/Module.agda",
"max_line_length": 73,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a193aeebf1326f960975b19d3e31b46fddbbfaa2",
"max_stars_repo_licenses": [
"CC0-1.0"
],
"max_stars_repo_name": "cspollard/reals",
"max_stars_repo_path": "src/Algebra/Module/Morphism/Module.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1244,
"size": 2930
} |
{-# OPTIONS --without-K --safe #-}
module Categories.Category where
open import Level
-- The main definitions are in:
open import Categories.Category.Core public
private
variable
o ℓ e : Level
-- Convenience functions for working over mupliple categories at once:
-- C [ x , y ] (for x y objects of C) - Hom_C(x , y)
-- C [ f ≈ g ] (for f g arrows of C) - that f and g are equivalent arrows
-- C [ f ∘ g ] (for f g composables arrows of C) - composition in C
infix 10 _[_,_] _[_≈_] _[_∘_]
_[_,_] : (C : Category o ℓ e) → (X : Category.Obj C) → (Y : Category.Obj C) → Set ℓ
_[_,_] = Category._⇒_
_[_≈_] : (C : Category o ℓ e) → ∀ {X Y} (f g : C [ X , Y ]) → Set e
_[_≈_] = Category._≈_
_[_∘_] : (C : Category o ℓ e) → ∀ {X Y Z} (f : C [ Y , Z ]) → (g : C [ X , Y ]) → C [ X , Z ]
_[_∘_] = Category._∘_
module Definitions (𝓒 : Category o ℓ e) where
open Category 𝓒
CommutativeSquare : {A B C D : Obj} → (f : A ⇒ B) (g : A ⇒ C) (h : B ⇒ D) (i : C ⇒ D) → Set _
CommutativeSquare f g h i = h ∘ f ≈ i ∘ g
-- Combinators for commutative diagram
-- The idea is to use the combinators to write commutations in a more readable way.
-- It starts with [_⇒_]⟨_≈_⟩, and within the third and fourth places, use _⇒⟨_⟩_ to
-- connect morphisms with the intermediate object specified.
module Commutation (𝓒 : Category o ℓ e) where
open Category 𝓒
infix 1 [_⇒_]⟨_≈_⟩
[_⇒_]⟨_≈_⟩ : ∀ (A B : Obj) → A ⇒ B → A ⇒ B → Set _
[ A ⇒ B ]⟨ f ≈ g ⟩ = f ≈ g
infixl 2 connect
connect : ∀ {A C : Obj} (B : Obj) → A ⇒ B → B ⇒ C → A ⇒ C
connect B f g = g ∘ f
syntax connect B f g = f ⇒⟨ B ⟩ g
| {
"alphanum_fraction": 0.58375,
"avg_line_length": 32,
"ext": "agda",
"hexsha": "92e00cc437d773a30b5afbb3a08dbb6b0cd9cdeb",
"lang": "Agda",
"max_forks_count": 64,
"max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z",
"max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Code-distancing/agda-categories",
"max_forks_repo_path": "src/Categories/Category.agda",
"max_issues_count": 236,
"max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Code-distancing/agda-categories",
"max_issues_repo_path": "src/Categories/Category.agda",
"max_line_length": 95,
"max_stars_count": 279,
"max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Trebor-Huang/agda-categories",
"max_stars_repo_path": "src/Categories/Category.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": 617,
"size": 1600
} |
{-# OPTIONS -v treeless.opt:20 #-}
open import Agda.Builtin.Nat
open import Common.IO using (return)
open import Agda.Builtin.Unit
data List {a} (A : Set a) : Set a where
[] : List A
_∷_ : A → List A → List A
data Vec {a} (A : Set a) : ..(_ : Nat) → Set a where
[] : Vec A 0
_∷_ : ∀ ..{n} → A → Vec A n → Vec A (suc n)
-- We can't handle smashing this yet. Different backends might compile
-- datatypes differently so we can't guarantee representational
-- compatibility. Possible solution: handle datatype compilation in
-- treeless as well and be explicit about which datatypes compile to the
-- same representation.
vecToList : ∀ {a} {A : Set a} ..{n} → Vec A n → List A
vecToList [] = []
vecToList (x ∷ xs) = x ∷ vecToList xs
data Fin : ..(_ : Nat) → Set where
zero : ∀ ..{n} → Fin (suc n)
suc : ∀ ..{n} → Fin n → Fin (suc n)
-- These should all compile to identity functions:
wk : ∀ ..{n} → Fin n → Fin (suc n)
wk zero = zero
wk (suc i) = suc (wk i)
wkN : ∀ ..{n m} → Fin n → Fin (n + m)
wkN zero = zero
wkN (suc i) = suc (wkN i)
wkN′ : ∀ m ..{n} → Fin n → Fin (m + n)
wkN′ zero i = i
wkN′ (suc m) i = wk (wkN′ m i)
vecPlusZero : ∀ {a} {A : Set a} ..{n} → Vec A n → Vec A (n + 0)
vecPlusZero [] = []
vecPlusZero (x ∷ xs) = x ∷ vecPlusZero xs
main = return tt
| {
"alphanum_fraction": 0.5895465027,
"avg_line_length": 27.6808510638,
"ext": "agda",
"hexsha": "c9b37b0fbad391de0dda525acaa992a332cb6103",
"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/Compiler/simple/IdentitySmashing.agda",
"max_issues_count": 16,
"max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_issues_repo_issues_event_max_datetime": "2019-09-08T13:47:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-10-08T00:32:04.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "alhassy/agda",
"max_issues_repo_path": "test/Compiler/simple/IdentitySmashing.agda",
"max_line_length": 72,
"max_stars_count": 7,
"max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "alhassy/agda",
"max_stars_repo_path": "test/Compiler/simple/IdentitySmashing.agda",
"max_stars_repo_stars_event_max_datetime": "2018-11-06T16:38:43.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-11-05T22:13:36.000Z",
"num_tokens": 470,
"size": 1301
} |
module Pr where
data FF : Set where
magic : {X : Set} -> FF -> X
magic ()
record TT : Set where
data Id {S : Set}(s : S) : S -> Set where
refl : Id s s
data Pr : Set1 where
tt : Pr
ff : Pr
_/\_ : Pr -> Pr -> Pr
all : (S : Set) -> (S -> Pr) -> Pr
_eq_ : {S : Set} -> S -> S -> Pr
record Sig (S : Set)(T : S -> Set) : Set where
field
fst : S
snd : T fst
open module Sig' {S : Set}{T : S -> Set} = Sig {S}{T} public
_,_ : {S : Set}{T : S -> Set}(s : S) -> T s -> Sig S T
s , t = record {fst = s ; snd = t}
[|_|] : Pr -> Set
[| tt |] = TT
[| ff |] = FF
[| P /\ Q |] = Sig [| P |] \_ -> [| Q |]
[| all S P |] = (x : S) -> [| P x |]
[| a eq b |] = Id a b
_=>_ : Pr -> Pr -> Pr
P => Q = all [| P |] \_ -> Q
∼ : Pr -> Pr
∼ P = P => ff
data Decision (P : Pr) : Set where
yes : [| P |] -> Decision P
no : [| ∼ P |] -> Decision P
data Bool : Set where
true : Bool
false : Bool
So : Bool -> Pr
So true = tt
So false = ff
not : Bool -> Bool
not true = false
not false = true
so : (b : Bool) -> Decision (So b)
so true = yes _
so false = no magic
potahto : (b : Bool) -> [| So (not b) => ∼ (So b) |]
potahto true () _
potahto false _ ()
PEx : (P : Pr) -> ([| P |] -> Pr) -> Pr
PEx P Q = P /\ all [| P |] Q
Pow : Set -> Set1
Pow X = X -> Pr
_==>_ : {X : Set} -> Pow X -> Pow X -> Pr
_==>_ {X} P Q = all X \x -> P x => Q x
Decidable : {X : Set}(P : Pow X) -> Set
Decidable {X} P = (x : X) -> Decision (P x)
data _:-_ (S : Set)(P : Pow S) : Set where
[_/_] : (s : S) -> [| P s |] -> S :- P
wit : {S : Set}{P : S -> Pr} -> S :- P -> S
wit [ s / p ] = s
cert : {S : Set}{P : S -> Pr}(sp : S :- P) -> [| P (wit sp) |]
cert [ s / p ] = p
_??_ : {S : Set}{P : S -> Pr}
(sp : S :- P){M : Set} ->
((s : S)(p : [| P s |]) -> M) ->
M
sp ?? m = m (wit sp) (cert sp)
| {
"alphanum_fraction": 0.4288070368,
"avg_line_length": 19.5591397849,
"ext": "agda",
"hexsha": "77eeaee48e09ea7c85ec7e0ee35e95aa46c8aa35",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "benchmark/Syntacticosmos/Pr.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "benchmark/Syntacticosmos/Pr.agda",
"max_line_length": 62,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "benchmark/Syntacticosmos/Pr.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": 762,
"size": 1819
} |
{-# OPTIONS --cubical --no-import-sorts --no-exact-split --safe #-}
module Cubical.Data.InfNat where
open import Cubical.Data.InfNat.Base public
open import Cubical.Data.InfNat.Properties public
| {
"alphanum_fraction": 0.7704081633,
"avg_line_length": 32.6666666667,
"ext": "agda",
"hexsha": "c77c0dcbe4670b9346625325a91776d68e98b90a",
"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/InfNat.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/InfNat.agda",
"max_line_length": 67,
"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/InfNat.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 47,
"size": 196
} |
{-# OPTIONS --sized-types #-}
module Lang.Size where
-- Some stuff about sizes that seems to :
-- • Types:
-- • SizeU : TYPE
-- • Size : TYPE
-- • <ˢⁱᶻᵉ_ : Size → TYPE
-- • 𝐒ˢⁱᶻᵉ : Size → Size
-- • ∞ˢⁱᶻᵉ : Size
-- • _⊔ˢⁱᶻᵉ_ : Size → Size → Size
-- • Subtyping : ∀s₁∀s₂. (s₁: <ˢⁱᶻᵉ s₂) → (s₁: Size)
-- • Almost irreflexivity: ∀(s: Size). (s ≠ ∞ˢⁱᶻᵉ) → ¬(s: <ˢⁱᶻᵉ s)
-- • Transitivity : ∀s₁∀s₂∀s₃. (s₁: <ˢⁱᶻᵉ s₂) → (s₂: <ˢⁱᶻᵉ s₃) → (s₁: <ˢⁱᶻᵉ s₃)
-- • Successor : ∀(s: Size). s: <ˢⁱᶻᵉ 𝐒ˢⁱᶻᵉ(s)
-- • Maximum : ∀(s: Size). s: <ˢⁱᶻᵉ ∞ˢⁱᶻᵉ
-- • Successor of maximum: 𝐒ˢⁱᶻᵉ(∞ˢⁱᶻᵉ) = ∞ˢⁱᶻᵉ
-- • Max function left : ∀(s₁: Size)∀(s₂: Size)∀(s₃: Size). ((s₁: <ˢⁱᶻᵉ s₃) ∧ (s₂: <ˢⁱᶻᵉ s₃)) → (((s₁ ⊔ˢⁱᶻᵉ s₂)): <ˢⁱᶻᵉ s₃)
-- • Max function right : ∀(s₁: Size)∀(s₂: Size)∀(s₃: Size). ((s₁: <ˢⁱᶻᵉ s₂) ∨ (s₁: <ˢⁱᶻᵉ s₃)) → (s₁: <ˢⁱᶻᵉ (s₂ ⊔ˢⁱᶻᵉ s₃))
-- • Max of maximum left : ∀(s: Size). s ⊔ˢⁱᶻᵉ ∞ˢⁱᶻᵉ = ∞ˢⁱᶻᵉ
-- • Max of maximum right: ∀(s: Size). ∞ˢⁱᶻᵉ ⊔ˢⁱᶻᵉ s = ∞ˢⁱᶻᵉ
-- TODO: What is SizeU? See https://github.com/agda/agda/blob/cabe234d3c784e20646636ad082cc1e04ddf007b/src/full/Agda/TypeChecking/Rules/Builtin.hs#L294 , https://github.com/agda/agda/blob/1eec63b1c5566b252c0a4a815ce1df99a772c475/src/full/Agda/TypeChecking/Primitive/Base.hs#L134
{-# BUILTIN SIZEUNIV SizeU #-}
{-# BUILTIN SIZE Size #-}
{-# BUILTIN SIZELT <ˢⁱᶻᵉ_ #-}
{-# BUILTIN SIZESUC 𝐒ˢⁱᶻᵉ #-}
{-# BUILTIN SIZEINF ∞ˢⁱᶻᵉ #-}
{-# BUILTIN SIZEMAX _⊔ˢⁱᶻᵉ_ #-}
{-
private
module Test where
open import Relator.Equals
types-SizeU : TYPE
types-SizeU = SizeU
types-Size : TYPE
types-Size = Size
types-<ˢⁱᶻᵉ : Size → TYPE
types-<ˢⁱᶻᵉ = <ˢⁱᶻᵉ_
types-𝐒ˢⁱᶻᵉ : Size → Size
types-𝐒ˢⁱᶻᵉ = 𝐒ˢⁱᶻᵉ
types-∞ˢⁱᶻᵉ : Size
types-∞ˢⁱᶻᵉ = ∞ˢⁱᶻᵉ
types-_⊔ˢⁱᶻᵉ_ : Size → Size → Size
types-_⊔ˢⁱᶻᵉ_ = _⊔ˢⁱᶻᵉ_
subtyping : ∀{s₂ : Size}{s₁ : <ˢⁱᶻᵉ s₂} → Size
subtyping {s₁ = s₁} = s₁
reflexivity-of-maximum : <ˢⁱᶻᵉ ∞ˢⁱᶻᵉ
reflexivity-of-maximum = ∞ˢⁱᶻᵉ
transitivity : ∀{s₃ : Size}{s₂ : <ˢⁱᶻᵉ s₃}{s₁ : <ˢⁱᶻᵉ s₂} → (<ˢⁱᶻᵉ s₃)
transitivity {s₁ = s₁} = s₁
maximum : ∀{s : Size} → <ˢⁱᶻᵉ ∞ˢⁱᶻᵉ
maximum{s} = s
successor-of-maximum : 𝐒ˢⁱᶻᵉ ∞ˢⁱᶻᵉ ≡ ∞ˢⁱᶻᵉ
successor-of-maximum = [≡]-intro
max-of-maximumₗ : ∀{s : Size} → (∞ˢⁱᶻᵉ ⊔ˢⁱᶻᵉ s ≡ ∞ˢⁱᶻᵉ)
max-of-maximumₗ = [≡]-intro
max-of-maximumᵣ : ∀{s : Size} → (s ⊔ˢⁱᶻᵉ ∞ˢⁱᶻᵉ ≡ ∞ˢⁱᶻᵉ)
max-of-maximumᵣ = [≡]-intro
max-function-left : ∀{s₃ : Size}{s₁ : <ˢⁱᶻᵉ s₃}{s₂ : <ˢⁱᶻᵉ s₃} → (<ˢⁱᶻᵉ s₃)
max-function-left {s₁ = s₁}{s₂ = s₂} = s₁ ⊔ˢⁱᶻᵉ s₂
max-function-rightₗ : ∀{s₂ s₃ : Size}{s₁ : <ˢⁱᶻᵉ s₂} → (<ˢⁱᶻᵉ (s₂ ⊔ˢⁱᶻᵉ s₃))
max-function-rightₗ {s₁ = s₁} = s₁
max-function-rightᵣ : ∀{s₂ s₃ : Size}{s₁ : <ˢⁱᶻᵉ s₃} → (<ˢⁱᶻᵉ (s₂ ⊔ˢⁱᶻᵉ s₃))
max-function-rightᵣ {s₁ = s₁} = s₁
-- TODO: Is this supposed to not work? This is: ∀(sₗ₁ : Size)∀(sₗ₂ : Size)∀(sᵣ : Size) → (sₗ₁ <ˢⁱᶻᵉ sₗ₂) → ((sₗ₁ ⊔ˢⁱᶻᵉ sᵣ) <ˢⁱᶻᵉ (sₗ₂ ⊔ˢⁱᶻᵉ sᵣ))
max-should-work? : ∀{sₗ₂ sᵣ : Size}{sₗ₁ : <ˢⁱᶻᵉ sₗ₂} → (<ˢⁱᶻᵉ (sₗ₂ ⊔ˢⁱᶻᵉ sᵣ))
max-should-work? {sᵣ = sᵣ}{sₗ₁ = sₗ₁} = sₗ₁ ⊔ˢⁱᶻᵉ sᵣ
-}
| {
"alphanum_fraction": 0.5711104041,
"avg_line_length": 35.3146067416,
"ext": "agda",
"hexsha": "294007603f07b216ddbc52a483c5464d7e58d3f1",
"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": "Lang/Size.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Lang/Size.agda",
"max_line_length": 278,
"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": "Lang/Size.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z",
"num_tokens": 2115,
"size": 3143
} |
------------------------------------------------------------------------
-- INCREMENTAL λ-CALCULUS
--
-- Variables and contexts
--
-- This module defines the syntax of contexts and subcontexts,
-- together with variables and properties of these notions.
--
-- This module is parametric in the syntax of types, so it
-- can be reused for different calculi.
------------------------------------------------------------------------
module Base.Syntax.Context
(Type : Set)
where
open import Relation.Binary
open import Relation.Binary.PropositionalEquality
-- Typing Contexts
-- ===============
import Data.List as List
open import Base.Data.ContextList public
Context : Set
Context = List.List Type
-- Variables
-- =========
--
-- Here it is clear that we are using de Bruijn indices,
-- encoded as natural numbers, more or less.
data Var : Context → Type → Set where
this : ∀ {Γ τ} → Var (τ • Γ) τ
that : ∀ {Γ σ τ} → (x : Var Γ τ) → Var (σ • Γ) τ
-- Weakening
-- =========
--
-- We define weakening based on subcontext relationship.
-- Subcontexts
-- -----------
--
-- Useful as a reified weakening operation,
-- and for making theorems strong enough to prove by induction.
--
-- The contents of this module are currently exported at the end
-- of this file.
-- This handling of contexts is recommended by [this
-- email](https://lists.chalmers.se/pipermail/agda/2011/003423.html) and
-- attributed to Conor McBride.
--
-- The associated thread discusses a few alternatives solutions, including one
-- where beta-reduction can handle associativity of ++.
module Subcontexts where
infix 4 _≼_
data _≼_ : (Γ₁ Γ₂ : Context) → Set where
∅ : ∅ ≼ ∅
keep_•_ : ∀ {Γ₁ Γ₂} →
(τ : Type) →
Γ₁ ≼ Γ₂ →
τ • Γ₁ ≼ τ • Γ₂
drop_•_ : ∀ {Γ₁ Γ₂} →
(τ : Type) →
Γ₁ ≼ Γ₂ →
Γ₁ ≼ τ • Γ₂
-- Properties
∅≼Γ : ∀ {Γ} → ∅ ≼ Γ
∅≼Γ {∅} = ∅
∅≼Γ {τ • Γ} = drop τ • ∅≼Γ
≼-refl : Reflexive _≼_
≼-refl {∅} = ∅
≼-refl {τ • Γ} = keep τ • ≼-refl
≼-reflexive : ∀ {Γ₁ Γ₂} → Γ₁ ≡ Γ₂ → Γ₁ ≼ Γ₂
≼-reflexive refl = ≼-refl
≼-trans : Transitive _≼_
≼-trans ≼₁ ∅ = ≼₁
≼-trans (keep .τ • ≼₁) (keep τ • ≼₂) = keep τ • ≼-trans ≼₁ ≼₂
≼-trans (drop .τ • ≼₁) (keep τ • ≼₂) = drop τ • ≼-trans ≼₁ ≼₂
≼-trans ≼₁ (drop τ • ≼₂) = drop τ • ≼-trans ≼₁ ≼₂
≼-isPreorder : IsPreorder _≡_ _≼_
≼-isPreorder = record
{ isEquivalence = isEquivalence
; reflexive = ≼-reflexive
; trans = ≼-trans
}
≼-preorder : Preorder _ _ _
≼-preorder = record
{ Carrier = Context
; _≈_ = _≡_
; _∼_ = _≼_
; isPreorder = ≼-isPreorder
}
module ≼-Reasoning where
open import Relation.Binary.PreorderReasoning ≼-preorder public
renaming
( _≈⟨_⟩_ to _≡⟨_⟩_
; _∼⟨_⟩_ to _≼⟨_⟩_
; _≈⟨⟩_ to _≡⟨⟩_
)
-- Lift a variable to a super context
weaken-var : ∀ {Γ₁ Γ₂ τ} → Γ₁ ≼ Γ₂ → Var Γ₁ τ → Var Γ₂ τ
weaken-var (keep τ • ≼₁) this = this
weaken-var (keep τ • ≼₁) (that x) = that (weaken-var ≼₁ x)
weaken-var (drop τ • ≼₁) x = that (weaken-var ≼₁ x)
-- Currently, we export the subcontext relation.
open Subcontexts public
| {
"alphanum_fraction": 0.5684143223,
"avg_line_length": 25.024,
"ext": "agda",
"hexsha": "1d2ae4d857f10898eec54863e616755066cf35c7",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z",
"max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "inc-lc/ilc-agda",
"max_forks_repo_path": "Base/Syntax/Context.agda",
"max_issues_count": 6,
"max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "inc-lc/ilc-agda",
"max_issues_repo_path": "Base/Syntax/Context.agda",
"max_line_length": 78,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "inc-lc/ilc-agda",
"max_stars_repo_path": "Base/Syntax/Context.agda",
"max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z",
"num_tokens": 1106,
"size": 3128
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- This module is DEPRECATED. Please use
-- Data.List.Relation.Binary.Sublist.Propositional directly.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.List.Relation.Sublist.Propositional where
open import Data.List.Relation.Binary.Sublist.Propositional public
{-# WARNING_ON_IMPORT
"Data.List.Relation.Sublist.Propositional was deprecated in v1.0.
Use Data.List.Relation.Binary.Sublist.Propositional instead."
#-}
| {
"alphanum_fraction": 0.5892255892,
"avg_line_length": 33,
"ext": "agda",
"hexsha": "b40993aee7106990a1c773fe94eb4e412d5c26e0",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DreamLinuxer/popl21-artifact",
"max_forks_repo_path": "agda-stdlib/src/Data/List/Relation/Sublist/Propositional.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DreamLinuxer/popl21-artifact",
"max_issues_repo_path": "agda-stdlib/src/Data/List/Relation/Sublist/Propositional.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/List/Relation/Sublist/Propositional.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": 108,
"size": 594
} |
-- Andreas, 2012-01-10
-- {-# OPTIONS -v tc.constr.findInScope:50 #-}
module InstanceGuessesMeta where
data Bool : Set where
true false : Bool
postulate
D : Bool -> Set
E : Bool -> Set
d : {x : Bool} -> D x
f : {x : Bool}{{ dx : D x }} -> E x
b : E true
b = f -- should succeed
-- Agda is now allowed to solve hidden x in type of d by unification,
-- when searching for inhabitant of D x
| {
"alphanum_fraction": 0.6243781095,
"avg_line_length": 22.3333333333,
"ext": "agda",
"hexsha": "1364f4dc17f66f6b1b999973ab5a4ac8542a6567",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "larrytheliquid/agda",
"max_forks_repo_path": "test/succeed/InstanceGuessesMeta.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "larrytheliquid/agda",
"max_issues_repo_path": "test/succeed/InstanceGuessesMeta.agda",
"max_line_length": 69,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "larrytheliquid/agda",
"max_stars_repo_path": "test/succeed/InstanceGuessesMeta.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 133,
"size": 402
} |
-- Andreas, 2011-04-14
-- {-# OPTIONS -v tc.cover:20 -v tc.lhs.unify:20 #-}
module Issue291a where
open import Common.Coinduction
open import Common.Equality
data RUnit : Set where
runit : ∞ RUnit -> RUnit
j : (u : ∞ RUnit) -> ♭ u ≡ runit u -> Set
j u ()
-- needs to fail (reports a Bad split!)
| {
"alphanum_fraction": 0.6466666667,
"avg_line_length": 21.4285714286,
"ext": "agda",
"hexsha": "d95105a6e5ed96aa34440638a500b391bfd61bb5",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/Issue291a.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Fail/Issue291a.agda",
"max_line_length": 52,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/Issue291a.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": 104,
"size": 300
} |
module SystemF.Syntax where
open import SystemF.Syntax.Type public
open import SystemF.Syntax.Term public
open import SystemF.Syntax.Context public
| {
"alphanum_fraction": 0.8456375839,
"avg_line_length": 24.8333333333,
"ext": "agda",
"hexsha": "724ecb45f11de7dda713941f353a9895f4db1dd4",
"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/SystemF/Syntax.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/SystemF/Syntax.agda",
"max_line_length": 41,
"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/SystemF/Syntax.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": 30,
"size": 149
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Foundations.Filler where
open import Cubical.Foundations.Prelude
private
variable
ℓ ℓ' : Level
A : Type ℓ
cube-cong : {a b : A}
{p p' q q' : a ≡ b}
(P : p ≡ p') (Q : q ≡ q')
→ (p ≡ q) ≡ (p' ≡ q')
cube-cong {p = p} {p' = p'} {q = q} {q' = q'} P Q =
p ≡ q
≡⟨ cong (_≡ q) P ⟩
p' ≡ q
≡⟨ cong (p' ≡_) Q ⟩
p' ≡ q' ∎
| {
"alphanum_fraction": 0.4409090909,
"avg_line_length": 20,
"ext": "agda",
"hexsha": "21a83e919d73c7655e9bfd8785757e842a6c5cda",
"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/Foundations/Filler.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/Foundations/Filler.agda",
"max_line_length": 51,
"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/Foundations/Filler.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 196,
"size": 440
} |
{-# OPTIONS --syntactic-equality=2 --allow-unsolved-metas #-}
-- Limited testing suggests that --syntactic-equality=2 is a little
-- faster than --syntactic-equality=0 and --syntactic-equality=1 for
-- this file.
-- The option --allow-unsolved-metas and the open goal at the end of
-- the file ensure that time is not wasted on serialising things.
open import Agda.Builtin.Equality
data D : Set where
c : D
data Delay-D : Set where
now : D → Delay-D
later : Delay-D → Delay-D
-- The result of f x is 5000 applications of later to now x.
f : D → Delay-D
f x =
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
later (later (later (later (later (later (later (later (later (later (
now x
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))
mutual
α : D
α = _
_ : f α ≡ f c
_ = refl
_ : Set
_ = {!!}
| {
"alphanum_fraction": 0.6002029786,
"avg_line_length": 69.8006589786,
"ext": "agda",
"hexsha": "cff417cd2be9aaf1a9c28c193a3c26fe2851b24d",
"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/Issue5801.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/Issue5801.agda",
"max_line_length": 72,
"max_stars_count": 1,
"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/Issue5801.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-05T00:25:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2022-03-05T00:25:14.000Z",
"num_tokens": 12065,
"size": 42369
} |
open import Nat
open import Prelude
open import List
open import statics-core
-- erasure of cursor in the types and expressions is defined in the paper,
-- and in the core file, as a function on zexpressions. because of the
-- particular encoding of all the judgments as datatypes and the agda
-- semantics for pattern matching, it is sometimes also convenient to have
-- a judgemental form of erasure.
--
-- this file describes the obvious encoding of the view this function as a
-- jugement relating input and output as a datatype, and argues that this
-- encoding is correct by showing a isomorphism with the function. we also
-- show that as a correlary, the judgement is well moded at (∀, ∃!), which
-- is unsurprising if the jugement is written correctly.
--
-- taken together, these proofs allow us to move between the judgemental
-- form of erasure and the function form when it's convenient.
--
-- while we do not have it, the argument given here is sufficiently strong
-- to produce an equality between these things in a system with the
-- univalence axiom, as described in the homotopy type theory book and the
-- associated work done in agda.
module judgemental-erase where
--cursor erasure for types, as written in the paper
_◆t : ztyp → htyp
▹ t ◃ ◆t = t
(t1 ==>₁ t2) ◆t = (t1 ◆t) ==> t2
(t1 ==>₂ t2) ◆t = t1 ==> (t2 ◆t)
(t1 ⊕₁ t2) ◆t = (t1 ◆t) ⊕ t2
(t1 ⊕₂ t2) ◆t = t1 ⊕ (t2 ◆t)
(t1 ⊠₁ t2) ◆t = (t1 ◆t) ⊠ t2
(t1 ⊠₂ t2) ◆t = t1 ⊠ (t2 ◆t)
--cursor erasure for expressions, as written in the paper
_◆e : zexp → hexp
▹ x ◃ ◆e = x
(e ·:₁ t) ◆e = (e ◆e) ·: t
(e ·:₂ t) ◆e = e ·: (t ◆t)
·λ x e ◆e = ·λ x (e ◆e)
(·λ x ·[ t ]₁ e) ◆e = ·λ x ·[ t ◆t ] e
(·λ x ·[ t ]₂ e) ◆e = ·λ x ·[ t ] (e ◆e)
(e1 ∘₁ e2) ◆e = (e1 ◆e) ∘ e2
(e1 ∘₂ e2) ◆e = e1 ∘ (e2 ◆e)
(e1 ·+₁ e2) ◆e = (e1 ◆e) ·+ e2
(e1 ·+₂ e2) ◆e = e1 ·+ (e2 ◆e)
⦇⌜ e ⌟⦈[ u ] ◆e = ⦇⌜ e ◆e ⌟⦈[ u ]
(inl e) ◆e = inl (e ◆e)
(inr e) ◆e = inr (e ◆e)
(case₁ e x e1 y e2) ◆e = case (e ◆e) x e1 y e2
(case₂ e x e1 y e2) ◆e = case e x (e1 ◆e) y e2
(case₃ e x e1 y e2) ◆e = case e x e1 y (e2 ◆e)
⟨ e1 , e2 ⟩₁ ◆e = ⟨ e1 ◆e , e2 ⟩
⟨ e1 , e2 ⟩₂ ◆e = ⟨ e1 , e2 ◆e ⟩
fst e ◆e = fst (e ◆e)
snd e ◆e = snd (e ◆e)
-- this pair of theorems moves from the judgmental form to the function form
erase-t◆ : {t : ztyp} {tr : htyp} → (erase-t t tr) → (t ◆t == tr)
erase-t◆ ETTop = refl
erase-t◆ (ETArrL p) = ap1 (λ x → x ==> _) (erase-t◆ p)
erase-t◆ (ETArrR p) = ap1 (λ x → _ ==> x) (erase-t◆ p)
erase-t◆ (ETPlusL p) = ap1 (λ x → x ⊕ _) (erase-t◆ p)
erase-t◆ (ETPlusR p) = ap1 (λ x → _ ⊕ x) (erase-t◆ p)
erase-t◆ (ETProdL p) = ap1 (λ x → x ⊠ _) (erase-t◆ p)
erase-t◆ (ETProdR p) = ap1 (λ x → _ ⊠ x) (erase-t◆ p)
erase-e◆ : {e : zexp} {er : hexp} → (erase-e e er) → (e ◆e == er)
erase-e◆ EETop = refl
erase-e◆ (EEPlusL p) = ap1 (λ x → x ·+ _) (erase-e◆ p)
erase-e◆ (EEPlusR p) = ap1 (λ x → _ ·+ x) (erase-e◆ p)
erase-e◆ (EEAscL p) = ap1 (λ x → x ·: _) (erase-e◆ p)
erase-e◆ (EEAscR p) = ap1 (λ x → _ ·: x) (erase-t◆ p)
erase-e◆ (EELam p) = ap1 (λ x → ·λ _ x) (erase-e◆ p)
erase-e◆ (EEHalfLamL p) = ap1 (λ x → ·λ _ ·[ x ] _) (erase-t◆ p)
erase-e◆ (EEHalfLamR p) = ap1 (λ x → ·λ _ ·[ _ ] x) (erase-e◆ p)
erase-e◆ (EEApL p) = ap1 (λ x → x ∘ _) (erase-e◆ p)
erase-e◆ (EEApR p) = ap1 (λ x → _ ∘ x) (erase-e◆ p)
erase-e◆ (EEInl p) = ap1 inl (erase-e◆ p)
erase-e◆ (EEInr p) = ap1 inr (erase-e◆ p)
erase-e◆ (EECase1 p) = ap1 (λ x → case x _ _ _ _) (erase-e◆ p)
erase-e◆ (EECase2 p) = ap1 (λ x → case _ _ x _ _) (erase-e◆ p)
erase-e◆ (EECase3 p) = ap1 (λ x → case _ _ _ _ x) (erase-e◆ p)
erase-e◆ (EEPairL p) = ap1 (λ x → ⟨ x , _ ⟩ ) (erase-e◆ p)
erase-e◆ (EEPairR p) = ap1 (λ x → ⟨ _ , x ⟩ ) (erase-e◆ p)
erase-e◆ (EEFst p) = ap1 fst (erase-e◆ p)
erase-e◆ (EESnd p) = ap1 snd (erase-e◆ p)
erase-e◆ (EENEHole p) = ap1 (λ x → ⦇⌜ x ⌟⦈[ _ ]) (erase-e◆ p)
-- this pair of theorems moves back from judgmental form to the function form
◆erase-t : (t : ztyp) (tr : htyp) → (t ◆t == tr) → (erase-t t tr)
◆erase-t ▹ x ◃ .x refl = ETTop
◆erase-t (t ==>₁ x) (.(t ◆t) ==> .x) refl with ◆erase-t t (t ◆t) refl
... | ih = ETArrL ih
◆erase-t (x ==>₂ t) (.x ==> .(t ◆t)) refl with ◆erase-t t (t ◆t) refl
... | ih = ETArrR ih
◆erase-t (t1 ⊕₁ t2) (.(t1 ◆t) ⊕ .t2) refl = ETPlusL (◆erase-t t1 (t1 ◆t) refl)
◆erase-t (t1 ⊕₂ t2) (.t1 ⊕ .(t2 ◆t)) refl = ETPlusR (◆erase-t t2 (t2 ◆t) refl)
◆erase-t (t1 ⊠₁ t2) (.(t1 ◆t) ⊠ .t2) refl = ETProdL (◆erase-t t1 (t1 ◆t) refl)
◆erase-t (t1 ⊠₂ t2) (.t1 ⊠ .(t2 ◆t)) refl = ETProdR (◆erase-t t2 (t2 ◆t) refl)
◆erase-e : (e : zexp) (er : hexp) → (e ◆e == er) → (erase-e e er)
◆erase-e ▹ x ◃ .x refl = EETop
◆erase-e (e ·:₁ x) .((e ◆e) ·: x) refl with ◆erase-e e (e ◆e) refl
... | ih = EEAscL ih
◆erase-e (x ·:₂ x₁) .(x ·: (x₁ ◆t)) refl = EEAscR (◆erase-t x₁ (x₁ ◆t) refl)
◆erase-e (·λ x e) .(·λ x (e ◆e)) refl = EELam (◆erase-e e (e ◆e) refl)
◆erase-e (·λ x ·[ x₁ ]₁ x₂) _ refl = EEHalfLamL (◆erase-t x₁ (x₁ ◆t) refl)
◆erase-e (·λ x ·[ x₁ ]₂ e) _ refl = EEHalfLamR (◆erase-e e (e ◆e) refl)
◆erase-e (e ∘₁ x) .((e ◆e) ∘ x) refl = EEApL (◆erase-e e (e ◆e) refl)
◆erase-e (x ∘₂ e) .(x ∘ (e ◆e)) refl = EEApR (◆erase-e e (e ◆e) refl)
◆erase-e (e ·+₁ x) .((e ◆e) ·+ x) refl = EEPlusL (◆erase-e e (e ◆e) refl)
◆erase-e (x ·+₂ e) .(x ·+ (e ◆e)) refl = EEPlusR (◆erase-e e (e ◆e) refl)
◆erase-e ⦇⌜ e ⌟⦈[ u ] .(⦇⌜ e ◆e ⌟⦈[ u ]) refl = EENEHole (◆erase-e e (e ◆e) refl)
◆erase-e (inl e) _ refl = EEInl (◆erase-e e (e ◆e) refl)
◆erase-e (inr e) _ refl = EEInr (◆erase-e e (e ◆e) refl)
◆erase-e (case₁ e _ _ _ _) _ refl = EECase1 (◆erase-e e (e ◆e) refl)
◆erase-e (case₂ _ _ e _ _) _ refl = EECase2 (◆erase-e e (e ◆e) refl)
◆erase-e (case₃ _ _ _ _ e) _ refl = EECase3 (◆erase-e e (e ◆e) refl)
◆erase-e ⟨ e , x ⟩₁ .(⟨ (e ◆e) , x ⟩) refl = EEPairL (◆erase-e e (e ◆e) refl)
◆erase-e ⟨ x , e ⟩₂ .(⟨ x , (e ◆e) ⟩) refl = EEPairR (◆erase-e e (e ◆e) refl)
◆erase-e (fst e) _ refl = EEFst (◆erase-e e (e ◆e) refl)
◆erase-e (snd e) _ refl = EESnd (◆erase-e e (e ◆e) refl)
-- jugemental erasure for both types and terms only has one proof for
-- relating the a term to its non-judgemental erasure
t-contr : (t : ztyp) → (x y : erase-t t (t ◆t)) → x == y
t-contr ▹ x ◃ ETTop ETTop = refl
t-contr (t ==>₁ x) (ETArrL y) (ETArrL z) = ap1 ETArrL (t-contr t y z)
t-contr (x ==>₂ t) (ETArrR y) (ETArrR z) = ap1 ETArrR (t-contr t y z)
t-contr (x ⊕₁ x₁) (ETPlusL y) (ETPlusL z) = ap1 ETPlusL (t-contr x y z)
t-contr (x₁ ⊕₂ x) (ETPlusR y) (ETPlusR z) = ap1 ETPlusR (t-contr x y z)
t-contr (x ⊠₁ x₁) (ETProdL y) (ETProdL z) = ap1 ETProdL (t-contr x y z)
t-contr (x₁ ⊠₂ x) (ETProdR y) (ETProdR z) = ap1 ETProdR (t-contr x y z)
e-contr : (e : zexp) → (x y : erase-e e (e ◆e)) → x == y
e-contr ▹ x ◃ EETop EETop = refl
e-contr (e ·:₁ x) (EEAscL x₁) (EEAscL y) = ap1 EEAscL (e-contr e x₁ y)
e-contr (x₁ ·:₂ x) (EEAscR x₂) (EEAscR x₃) = ap1 EEAscR (t-contr x x₂ x₃)
e-contr (·λ x e) (EELam x₁) (EELam y) = ap1 EELam (e-contr e x₁ y)
e-contr (·λ x ·[ x₁ ]₁ x₂) (EEHalfLamL x₃) (EEHalfLamL x₄) = ap1 EEHalfLamL (t-contr x₁ x₃ x₄)
e-contr (·λ x ·[ x₁ ]₂ x₂) (EEHalfLamR y) (EEHalfLamR z) = ap1 EEHalfLamR (e-contr x₂ y z)
e-contr (e ∘₁ x) (EEApL x₁) (EEApL y) = ap1 EEApL (e-contr e x₁ y)
e-contr (x ∘₂ e) (EEApR x₁) (EEApR y) = ap1 EEApR (e-contr e x₁ y)
e-contr (e ·+₁ x) (EEPlusL x₁) (EEPlusL y) = ap1 EEPlusL (e-contr e x₁ y)
e-contr (x ·+₂ e) (EEPlusR x₁) (EEPlusR y) = ap1 EEPlusR (e-contr e x₁ y)
e-contr ⦇⌜ e ⌟⦈[ u ] (EENEHole x) (EENEHole y) = ap1 EENEHole (e-contr e x y)
e-contr (inl x) (EEInl y) (EEInl z) = ap1 EEInl (e-contr x y z)
e-contr (inr x) (EEInr y) (EEInr z) = ap1 EEInr (e-contr x y z)
e-contr (case₁ x x₁ x₂ x₃ x₄) (EECase1 y) (EECase1 z) = ap1 EECase1 (e-contr x y z)
e-contr (case₂ x₁ x₂ x x₃ x₄) (EECase2 y) (EECase2 z) = ap1 EECase2 (e-contr x y z)
e-contr (case₃ x₁ x₂ x₃ x₄ x) (EECase3 y) (EECase3 z) = ap1 EECase3 (e-contr x y z)
e-contr ⟨ e , x ⟩₁ (EEPairL x₁) (EEPairL y) = ap1 EEPairL (e-contr e x₁ y)
e-contr ⟨ x , e ⟩₂ (EEPairR x₁) (EEPairR y) = ap1 EEPairR (e-contr e x₁ y)
e-contr (fst x) (EEFst y) (EEFst z) = ap1 EEFst (e-contr x y z)
e-contr (snd x) (EESnd y) (EESnd z) = ap1 EESnd (e-contr x y z)
-- taken together, these four theorems demonstrate that both round-trips
-- of the above functions are stable up to ==
erase-trt1 : (t : ztyp) (tr : htyp) →
(x : t ◆t == tr) →
(erase-t◆ (◆erase-t t tr x)) == x
erase-trt1 ▹ x ◃ .x refl = refl
erase-trt1 (t ==>₁ x) (.(t ◆t) ==> .x) refl with erase-t◆ (◆erase-t t (t ◆t) refl)
erase-trt1 (t ==>₁ x) (.(t ◆t) ==> .x) refl | refl = refl
erase-trt1 (x ==>₂ t) (.x ==> .(t ◆t)) refl with erase-t◆ (◆erase-t t (t ◆t) refl)
erase-trt1 (x ==>₂ t) (.x ==> .(t ◆t)) refl | refl = refl
erase-trt1 (x ⊕₁ x₁) .((x ◆t) ⊕ x₁) refl with erase-t◆ (◆erase-t x (x ◆t) refl)
erase-trt1 (x ⊕₁ x₁) .((x ◆t) ⊕ x₁) refl | refl = refl
erase-trt1 (x ⊕₂ x₁) .(x ⊕ (x₁ ◆t)) refl with erase-t◆ (◆erase-t x₁ (x₁ ◆t) refl)
erase-trt1 (x ⊕₂ x₁) .(x ⊕ (x₁ ◆t)) refl | refl = refl
erase-trt1 (x ⊠₁ x₁) .((x ◆t) ⊠ x₁) refl with erase-t◆ (◆erase-t x (x ◆t) refl)
erase-trt1 (x ⊠₁ x₁) .((x ◆t) ⊠ x₁) refl | refl = refl
erase-trt1 (x ⊠₂ x₁) .(x ⊠ (x₁ ◆t)) refl with erase-t◆ (◆erase-t x₁ (x₁ ◆t) refl)
erase-trt1 (x ⊠₂ x₁) .(x ⊠ (x₁ ◆t)) refl | refl = refl
erase-trt2 : (t : ztyp) (tr : htyp) →
(x : erase-t t tr) →
◆erase-t t tr (erase-t◆ x) == x
erase-trt2 .(▹ tr ◃) tr ETTop = refl
erase-trt2 _ _ (ETArrL ETTop) = refl
erase-trt2 (t1 ==>₁ t2) _ (ETArrL x) with erase-t◆ x
erase-trt2 (t1 ==>₁ t2) _ (ETArrL x) | refl =
ap1 ETArrL (t-contr _ (◆erase-t t1 (t1 ◆t) refl) x)
erase-trt2 (t1 ==>₂ t2) _ (ETArrR x) with erase-t◆ x
erase-trt2 (t1 ==>₂ t2) _ (ETArrR x) | refl =
ap1 ETArrR (t-contr _ (◆erase-t t2 (t2 ◆t) refl) x)
erase-trt2 (t1 ⊕₁ t2) _ (ETPlusL x) with erase-t◆ x
erase-trt2 (t1 ⊕₁ t2) _ (ETPlusL x) | refl =
ap1 ETPlusL (t-contr _ (◆erase-t t1 (t1 ◆t) refl) x)
erase-trt2 (t1 ⊕₂ t2) _ (ETPlusR x) with erase-t◆ x
erase-trt2 (t1 ⊕₂ t2) _ (ETPlusR x) | refl =
ap1 ETPlusR (t-contr _ (◆erase-t t2 (t2 ◆t) refl) x)
erase-trt2 (t1 ⊠₁ t2) _ (ETProdL x) with erase-t◆ x
erase-trt2 (t1 ⊠₁ t2) _ (ETProdL x) | refl =
ap1 ETProdL (t-contr _ (◆erase-t t1 (t1 ◆t) refl) x)
erase-trt2 (t1 ⊠₂ t2) _ (ETProdR x) with erase-t◆ x
erase-trt2 (t1 ⊠₂ t2) _ (ETProdR x) | refl =
ap1 ETProdR (t-contr _ (◆erase-t t2 (t2 ◆t) refl) x)
erase-ert1 : (e : zexp) (er : hexp) →
(x : e ◆e == er) →
(erase-e◆ (◆erase-e e er x)) == x
erase-ert1 ▹ x ◃ .x refl = refl
erase-ert1 (e ·:₁ x) .((e ◆e) ·: x) refl with erase-e◆ (◆erase-e e (e ◆e) refl)
erase-ert1 (e ·:₁ x) .((e ◆e) ·: x) refl | refl = refl
erase-ert1 (x ·:₂ t) .(x ·: (t ◆t)) refl = ap1 (λ a → ap1 (_·:_ x) a) (erase-trt1 t _ refl)
erase-ert1 (·λ x e) .(·λ x (e ◆e)) refl = ap1 (λ a → ap1 (·λ x) a) (erase-ert1 e _ refl)
erase-ert1 (·λ x ·[ t ]₁ e) .((·λ x ·[ t ]₁ e) ◆e) refl =
ap1 (λ a → ap1 (λ b → ·λ x ·[ b ] e) a) (erase-trt1 t _ refl)
erase-ert1 (·λ x ·[ t ]₂ e) .((·λ x ·[ t ]₂ e) ◆e) refl =
ap1 (λ a → ap1 (λ b → ·λ x ·[ t ] b) a) (erase-ert1 e _ refl)
erase-ert1 (e ∘₁ x) .((e ◆e) ∘ x) refl =
ap1 (λ a → ap1 (λ x₁ → x₁ ∘ x) a) (erase-ert1 e _ refl)
erase-ert1 (x ∘₂ e) .(x ∘ (e ◆e)) refl =
ap1 (λ a → ap1 (_∘_ x) a) (erase-ert1 e _ refl)
erase-ert1 (e ·+₁ x) .((e ◆e) ·+ x) refl =
ap1 (λ a → ap1 (λ x₁ → x₁ ·+ x) a) (erase-ert1 e _ refl)
erase-ert1 (x ·+₂ e) .(x ·+ (e ◆e)) refl =
ap1 (λ a → ap1 (_·+_ x) a) (erase-ert1 e _ refl)
erase-ert1 ⦇⌜ e ⌟⦈[ u ] .(⦇⌜ e ◆e ⌟⦈[ u ]) refl =
ap1 (λ a → ap1 ⦇⌜_⌟⦈[ u ] a) (erase-ert1 e _ refl)
erase-ert1 (inl x) .(inl (x ◆e)) refl = ap1 (λ a → ap1 inl a) (erase-ert1 x _ refl)
erase-ert1 (inr x) .(inr (x ◆e)) refl = ap1 (λ a → ap1 inr a) (erase-ert1 x _ refl)
erase-ert1 (case₁ x x₁ x₂ x₃ x₄) .(case (x ◆e) x₁ x₂ x₃ x₄) refl =
ap1 (ap1 (λ a → case a x₁ x₂ x₃ x₄)) (erase-ert1 x _ refl)
erase-ert1 (case₂ x x₁ x₂ x₃ x₄) .(case x x₁ (x₂ ◆e) x₃ x₄) refl =
ap1 (ap1 (λ a → case x x₁ a x₃ x₄)) (erase-ert1 x₂ _ refl)
erase-ert1 (case₃ x x₁ x₂ x₃ x₄) .(case x x₁ x₂ x₃ (x₄ ◆e)) refl =
ap1 (ap1 (λ a → case x x₁ x₂ x₃ a)) (erase-ert1 x₄ _ refl)
erase-ert1 ⟨ e , x ⟩₁ .(⟨ (e ◆e) , x ⟩) refl =
ap1 (λ a → ap1 (λ x₁ → ⟨ x₁ , x ⟩) a) (erase-ert1 e _ refl)
erase-ert1 ⟨ x , e ⟩₂ .(⟨ x , (e ◆e) ⟩) refl =
ap1 (λ a → ap1 (⟨_,_⟩ x) a) (erase-ert1 e _ refl)
erase-ert1 (fst x) .(fst (x ◆e)) refl = ap1 (λ a → ap1 fst a) (erase-ert1 x _ refl)
erase-ert1 (snd x) .(snd (x ◆e)) refl = ap1 (λ a → ap1 snd a) (erase-ert1 x _ refl)
erase-ert2 : (e : zexp) (er : hexp) →
(b : erase-e e er) →
◆erase-e e er (erase-e◆ b) == b
erase-ert2 .(▹ er ◃) er EETop = refl
erase-ert2 (e ·:₁ x) _ (EEAscL b) with erase-e◆ b
erase-ert2 (e ·:₁ x) _ (EEAscL b) | refl =
ap1 EEAscL (e-contr _ (◆erase-e e (e ◆e) refl) b)
erase-ert2 (e ·:₂ x) _ (EEAscR b) with erase-t◆ b
erase-ert2 (e ·:₂ x) .(e ·: (x ◆t)) (EEAscR b) | refl =
ap1 EEAscR (t-contr _ (◆erase-t x (x ◆t) refl) b)
erase-ert2 (·λ x e) _ (EELam b) with erase-e◆ b
erase-ert2 (·λ x e) .(·λ x (e ◆e)) (EELam b) | refl =
ap1 EELam (e-contr _ (◆erase-e e (e ◆e) refl) b)
erase-ert2 (·λ x ·[ t ]₁ e) _ (EEHalfLamL b) with erase-t◆ b
erase-ert2 (·λ x ·[ t ]₁ e) .(·λ x ·[ t ◆t ] e) (EEHalfLamL b) | refl =
ap1 EEHalfLamL (t-contr _ (◆erase-t t (t ◆t) refl) b)
erase-ert2 (·λ x ·[ t ]₂ e) _ (EEHalfLamR b) with erase-e◆ b
erase-ert2 (·λ x ·[ t ]₂ e) .(·λ x ·[ t ] (e ◆e)) (EEHalfLamR b) | refl =
ap1 EEHalfLamR (e-contr _ (◆erase-e e (e ◆e) refl) b)
erase-ert2 (e ∘₁ x) _ (EEApL b) with erase-e◆ b
erase-ert2 (e ∘₁ x) .((e ◆e) ∘ x) (EEApL b) | refl =
ap1 EEApL (e-contr e (◆erase-e e (e ◆e) refl) b)
erase-ert2 (e1 ∘₂ e) _ (EEApR b) with erase-e◆ b
erase-ert2 (e1 ∘₂ e) .(e1 ∘ (e ◆e)) (EEApR b) | refl =
ap1 EEApR (e-contr e (◆erase-e e (e ◆e) refl) b)
erase-ert2 (e ·+₁ x) _ (EEPlusL b) with erase-e◆ b
erase-ert2 (e ·+₁ x) .((e ◆e) ·+ x) (EEPlusL b) | refl =
ap1 EEPlusL (e-contr e (◆erase-e e (e ◆e) refl) b)
erase-ert2 (e1 ·+₂ e) _ (EEPlusR b) with erase-e◆ b
erase-ert2 (e1 ·+₂ e) .(e1 ·+ (e ◆e)) (EEPlusR b) | refl =
ap1 EEPlusR (e-contr e (◆erase-e e (e ◆e) refl) b)
erase-ert2 ⦇⌜ e ⌟⦈[ u ] _ (EENEHole b) with erase-e◆ b
erase-ert2 ⦇⌜ e ⌟⦈[ u ] .(⦇⌜ e ◆e ⌟⦈[ u ]) (EENEHole b) | refl =
ap1 EENEHole (e-contr e (◆erase-e e (e ◆e) refl) b)
erase-ert2 (inl x) _ (EEInl z) with erase-e◆ z
erase-ert2 (inl x) .(inl (x ◆e)) (EEInl z) | refl = ap1 EEInl (e-contr x _ z)
erase-ert2 (inr x) _ (EEInr z) with erase-e◆ z
erase-ert2 (inr x) .(inr (x ◆e)) (EEInr z) | refl = ap1 EEInr (e-contr x _ z)
erase-ert2 (case₁ x x₁ x₂ x₃ x₄) _ (EECase1 z) with erase-e◆ z
erase-ert2 (case₁ x x₁ x₂ x₃ x₄) .(case (x ◆e) x₁ x₂ x₃ x₄) (EECase1 z) | refl =
ap1 EECase1 (e-contr x _ z)
erase-ert2 (case₂ e x₁ x₂ x₃ x₄) _ (EECase2 z) with erase-e◆ z
erase-ert2 (case₂ e x₁ x₂ x₃ x₄) .(case e x₁ (x₂ ◆e) x₃ x₄) (EECase2 z) | refl =
ap1 EECase2 (e-contr x₂ _ z)
erase-ert2 (case₃ e x₁ x₂ x₃ x₄) _ (EECase3 z) with erase-e◆ z
erase-ert2 (case₃ e x₁ x₂ x₃ x₄) .(case e x₁ x₂ x₃ (x₄ ◆e)) (EECase3 z) | refl =
ap1 EECase3 (e-contr x₄ _ z)
erase-ert2 ⟨ e , x ⟩₁ _ (EEPairL b) with erase-e◆ b
erase-ert2 ⟨ e , x ⟩₁ .(⟨ (e ◆e) , x ⟩) (EEPairL b) | refl =
ap1 EEPairL (e-contr e (◆erase-e e (e ◆e) refl) b)
erase-ert2 ⟨ e1 , e ⟩₂ _ (EEPairR b) with erase-e◆ b
erase-ert2 ⟨ e1 , e ⟩₂ .(⟨ e1 , (e ◆e) ⟩) (EEPairR b) | refl =
ap1 EEPairR (e-contr e (◆erase-e e (e ◆e) refl) b)
erase-ert2 (fst x) _ (EEFst z) with erase-e◆ z
erase-ert2 (fst x) .(fst (x ◆e)) (EEFst z) | refl = ap1 EEFst (e-contr x _ z)
erase-ert2 (snd x) _ (EESnd z) with erase-e◆ z
erase-ert2 (snd x) .(snd (x ◆e)) (EESnd z) | refl = ap1 EESnd (e-contr x _ z)
-- since both round trips are stable, these functions demonstrate
-- isomorphisms between the jugemental and non-judgemental definitions of
-- erasure
erase-e-iso : (e : zexp) (er : hexp) → (e ◆e == er) ≃ (erase-e e er)
erase-e-iso e er = (◆erase-e e er) , (erase-e◆ , erase-ert1 e er , erase-ert2 e er)
erase-t-iso : (t : ztyp) (tr : htyp) → (t ◆t == tr) ≃ (erase-t t tr)
erase-t-iso t tr = (◆erase-t t tr) , (erase-t◆ , erase-trt1 t tr , erase-trt2 t tr)
-- this isomorphism supplies the argument that the judgement has mode (∀,
-- !∃), where uniqueness comes from erase-e◆.
erase-e-mode : (e : zexp) → Σ[ er ∈ hexp ] (erase-e e er)
erase-e-mode e = (e ◆e) , (◆erase-e e (e ◆e) refl)
-- some translations and lemmas to move between the different
-- forms. these are not needed to show that this is an ok encoding pair,
-- but they are helpful when actually using it.
-- even more specifically, the relation relates an expression to its
-- functional erasure.
rel◆t : (t : ztyp) → (erase-t t (t ◆t))
rel◆t t = ◆erase-t t (t ◆t) refl
rel◆ : (e : zexp) → (erase-e e (e ◆e))
rel◆ e = ◆erase-e e (e ◆e) refl
lem-erase-synth : ∀{e e' Γ t} → erase-e e e' → Γ ⊢ e' => t → Γ ⊢ (e ◆e) => t
lem-erase-synth er wt = tr (λ x → _ ⊢ x => _) (! (erase-e◆ er)) wt
lem-erase-ana : ∀{e e' Γ t} → erase-e e e' → Γ ⊢ e' <= t → Γ ⊢ (e ◆e) <= t
lem-erase-ana er wt = tr (λ x → _ ⊢ x <= _) (! (erase-e◆ er)) wt
lem-synth-erase : ∀{Γ e t e' } → Γ ⊢ e ◆e => t → erase-e e e' → Γ ⊢ e' => t
lem-synth-erase d1 d2 with erase-e◆ d2
... | refl = d1
eraset-det : ∀{t t' t''} → erase-t t t' → erase-t t t'' → t' == t''
eraset-det e1 e2 with erase-t◆ e1
... | refl = erase-t◆ e2
erasee-det : ∀{e e' e''} → erase-e e e' → erase-e e e'' → e' == e''
erasee-det e1 e2 with erase-e◆ e1
... | refl = erase-e◆ e2
erase-in-hole : ∀ {e e' u} → erase-e e e' → erase-e ⦇⌜ e ⌟⦈[ u ] ⦇⌜ e' ⌟⦈[ u ]
erase-in-hole (EENEHole er) = EENEHole (erase-in-hole er)
erase-in-hole x = EENEHole x
eq-er-trans : ∀{e e◆ e'} →
(e ◆e) == (e' ◆e) →
erase-e e e◆ →
erase-e e' e◆
eq-er-trans {e} {e◆} {e'} eq er =
tr (λ f → erase-e e' f) (erasee-det (◆erase-e e (e' ◆e) eq) er) (rel◆ e')
eq-ert-trans : ∀{t t' t1 t2} →
(t ◆t) == (t' ◆t) →
erase-t t t1 →
erase-t t' t2 →
t1 == t2
eq-ert-trans eq er1 er2 = ! (erase-t◆ er1) · (eq · (erase-t◆ er2))
| {
"alphanum_fraction": 0.5419292293,
"avg_line_length": 51.7186629526,
"ext": "agda",
"hexsha": "cc6b9d99caa7b5b945657f9e3cec165aa5cb3a6b",
"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": "a3640d7b0f76cdac193afd382694197729ed6d57",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "hazelgrove/hazelnut-agda",
"max_forks_repo_path": "judgemental-erase.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57",
"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": "hazelgrove/hazelnut-agda",
"max_issues_repo_path": "judgemental-erase.agda",
"max_line_length": 96,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "hazelgrove/hazelnut-agda",
"max_stars_repo_path": "judgemental-erase.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 9151,
"size": 18567
} |
{-# OPTIONS --rewriting #-}
module Issue2792 where
open import Issue2792.Safe
| {
"alphanum_fraction": 0.7375,
"avg_line_length": 13.3333333333,
"ext": "agda",
"hexsha": "a72156b85cc484816fd87eb0af2f52052ecf03e1",
"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/Issue2792.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/Issue2792.agda",
"max_line_length": 27,
"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/Issue2792.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": 19,
"size": 80
} |
------------------------------------------------------------------------
-- Equivalences with erased "proofs"
------------------------------------------------------------------------
-- This module contains some basic definitions with few dependencies.
-- See Equivalence.Erased for more definitions. The definitions below
-- are reexported from Equivalence.Erased.
{-# OPTIONS --without-K --safe #-}
open import Equality
module Equivalence.Erased.Basics
{reflexive} (eq : ∀ {a p} → Equality-with-J a p reflexive) where
open Derived-definitions-and-properties eq
open import Logical-equivalence using (_⇔_)
open import Prelude as P hiding (id; [_,_]) renaming (_∘_ to _⊚_)
open import Equivalence eq as Eq using (_≃_; Is-equivalence)
import Equivalence.Half-adjoint eq as HA
open import Erased.Basics
open import Preimage eq as Preimage using (_⁻¹_)
private
variable
a b c d ℓ : Level
A B C : Type a
p x y : A
P Q : A → Type p
f g : (x : A) → P x
------------------------------------------------------------------------
-- Is-equivalenceᴱ
-- Is-equivalence with erased proofs.
Is-equivalenceᴱ : {A : Type a} {B : Type b} → @0 (A → B) → Type (a ⊔ b)
Is-equivalenceᴱ {A = A} {B = B} f =
∃ λ (f⁻¹ : B → A) → Erased (HA.Proofs f f⁻¹)
------------------------------------------------------------------------
-- Some conversion lemmas
-- Conversions between Is-equivalence and Is-equivalenceᴱ.
Is-equivalence→Is-equivalenceᴱ :
{@0 A : Type a} {@0 B : Type b} {@0 f : A → B} →
Is-equivalence f → Is-equivalenceᴱ f
Is-equivalence→Is-equivalenceᴱ = Σ-map P.id [_]→
@0 Is-equivalenceᴱ→Is-equivalence :
Is-equivalenceᴱ f → Is-equivalence f
Is-equivalenceᴱ→Is-equivalence = Σ-map P.id erased
-- See also Equivalence.Erased.Is-equivalence≃Is-equivalenceᴱ.
------------------------------------------------------------------------
-- _≃ᴱ_
private
module Dummy where
-- Equivalences with erased proofs.
infix 4 _≃ᴱ_
record _≃ᴱ_ (A : Type a) (B : Type b) : Type (a ⊔ b) where
constructor ⟨_,_⟩
field
to : A → B
is-equivalence : Is-equivalenceᴱ to
open Dummy public using (_≃ᴱ_; ⟨_,_⟩) hiding (module _≃ᴱ_)
-- A variant of the constructor of _≃ᴱ_ with erased type arguments.
⟨_,_⟩₀ :
{@0 A : Type a} {@0 B : Type b}
(to : A → B) → Is-equivalenceᴱ to → A ≃ᴱ B
⟨ to , eq ⟩₀ = ⟨ to , eq ⟩
-- Note that the type arguments A and B are erased. This is not the
-- case for the record module Dummy._≃ᴱ_.
module _≃ᴱ_ {@0 A : Type a} {@0 B : Type b} (A≃B : A ≃ᴱ B) where
-- The "left-to-right" direction of the equivalence.
to : A → B
to = let ⟨ to , _ ⟩ = A≃B in to
-- The function to is an equivalence.
is-equivalence : Is-equivalenceᴱ to
is-equivalence = let ⟨ _ , eq ⟩ = A≃B in eq
-- The "right-to-left" direction of the equivalence.
from : B → A
from = let from , _ = is-equivalence in from
-- The underlying logical equivalence.
logical-equivalence : A ⇔ B
logical-equivalence = record
{ to = to
; from = from
}
-- In an erased context one can construct a corresponding
-- equivalence.
@0 equivalence : A ≃ B
equivalence =
Eq.⟨ to , Is-equivalenceᴱ→Is-equivalence is-equivalence ⟩
-- In an erased context the function from is a right inverse of to.
@0 right-inverse-of : ∀ y → to (from y) ≡ y
right-inverse-of = _≃_.right-inverse-of equivalence
-- In an erased context the function from is a left inverse of to.
@0 left-inverse-of : ∀ x → from (to x) ≡ x
left-inverse-of = _≃_.left-inverse-of equivalence
-- Two coherence properties.
@0 left-right-lemma :
∀ x → cong to (left-inverse-of x) ≡ right-inverse-of (to x)
left-right-lemma = _≃_.left-right-lemma equivalence
@0 right-left-lemma :
∀ x → cong from (right-inverse-of x) ≡ left-inverse-of (from x)
right-left-lemma = _≃_.right-left-lemma equivalence
private
variable
A≃B : A ≃ᴱ B
------------------------------------------------------------------------
-- More conversion lemmas
-- Equivalences are equivalent to pairs.
≃ᴱ-as-Σ : (A ≃ᴱ B) ≃ (∃ λ (f : A → B) → Is-equivalenceᴱ f)
≃ᴱ-as-Σ = Eq.↔⇒≃ (record
{ surjection = record
{ logical-equivalence = record
{ to = λ { ⟨ f , is ⟩ → f , is }
; from = uncurry ⟨_,_⟩
}
; right-inverse-of = refl
}
; left-inverse-of = refl
})
-- Conversions between _≃_ and _≃ᴱ_.
≃→≃ᴱ :
{@0 A : Type a} {@0 B : Type b} →
A ≃ B → A ≃ᴱ B
≃→≃ᴱ Eq.⟨ f , is-equiv ⟩ =
⟨ f , Is-equivalence→Is-equivalenceᴱ is-equiv ⟩
@0 ≃ᴱ→≃ : A ≃ᴱ B → A ≃ B
≃ᴱ→≃ = _≃ᴱ_.equivalence
-- Data corresponding to the erased proofs of an equivalence with
-- erased proofs.
record Erased-proofs {A : Type a} {B : Type b}
(to : A → B) (from : B → A) : Type (a ⊔ b) where
field
proofs : HA.Proofs to from
-- Extracts "erased proofs" from a regular equivalence.
[proofs] :
{@0 A : Type a} {@0 B : Type b}
(A≃B : A ≃ B) → Erased-proofs (_≃_.to A≃B) (_≃_.from A≃B)
[proofs] A≃B .Erased-proofs.proofs =
let record { is-equivalence = is-equivalence } = A≃B in
proj₂₀ is-equivalence
-- Converts two functions and some erased proofs to an equivalence
-- with erased proofs.
--
-- Note that Agda can in many cases infer "to" and "from" from the
-- first explicit argument, see (for instance) ↔→≃ᴱ below.
[≃]→≃ᴱ :
{@0 A : Type a} {@0 B : Type b} {to : A → B} {from : B → A} →
@0 Erased-proofs to from →
A ≃ᴱ B
[≃]→≃ᴱ {to = to} {from = from} ep =
⟨ to , (from , [ ep .Erased-proofs.proofs ]) ⟩
-- A function with a quasi-inverse with erased proofs can be turned
-- into an equivalence with erased proofs.
↔→≃ᴱ :
{@0 A : Type a} {@0 B : Type b}
(f : A → B) (g : B → A) →
@0 (∀ x → f (g x) ≡ x) →
@0 (∀ x → g (f x) ≡ x) →
A ≃ᴱ B
↔→≃ᴱ {A = A} {B = B} f g f∘g g∘f = [≃]→≃ᴱ ([proofs] A≃B′)
where
@0 A≃B′ : A ≃ B
A≃B′ = Eq.↔⇒≃ (record
{ surjection = record
{ logical-equivalence = record
{ to = f
; from = g
}
; right-inverse-of = f∘g
}
; left-inverse-of = g∘f
})
-- A variant of ↔→≃ᴱ.
⇔→≃ᴱ :
{@0 A : Type a} {@0 B : Type b} →
@0 Is-proposition A → @0 Is-proposition B →
(A → B) → (B → A) →
A ≃ᴱ B
⇔→≃ᴱ A-prop B-prop to from =
[≃]→≃ᴱ ([proofs] (Eq.⇔→≃ A-prop B-prop to from))
------------------------------------------------------------------------
-- Equivalences with erased proofs form an equivalence relation
-- Identity.
id : {@0 A : Type a} → A ≃ᴱ A
id = [≃]→≃ᴱ ([proofs] Eq.id)
-- Inverse.
inverse :
{@0 A : Type a} {@0 B : Type b} →
A ≃ᴱ B → B ≃ᴱ A
inverse A≃B = [≃]→≃ᴱ ([proofs] (Eq.inverse (≃ᴱ→≃ A≃B)))
-- Composition.
infixr 9 _∘_
_∘_ :
{@0 A : Type a} {@0 B : Type b} {@0 C : Type c} →
B ≃ᴱ C → A ≃ᴱ B → A ≃ᴱ C
f ∘ g = [≃]→≃ᴱ ([proofs] (≃ᴱ→≃ f Eq.∘ ≃ᴱ→≃ g))
------------------------------------------------------------------------
-- A preservation lemma
-- Is-equivalenceᴱ f is logically equivalent to Is-equivalenceᴱ g if f
-- and g are pointwise equal.
--
-- See also Equivalence.Erased.[]-cong₂-⊔.Is-equivalenceᴱ-cong.
Is-equivalenceᴱ-cong-⇔ :
{@0 A : Type a} {@0 B : Type b} {@0 f g : A → B} →
@0 (∀ x → f x ≡ g x) →
Is-equivalenceᴱ f ⇔ Is-equivalenceᴱ g
Is-equivalenceᴱ-cong-⇔ {f = f} {g = g} f≡g =
record { to = to f≡g; from = to (sym ⊚ f≡g) }
where
to :
{@0 A : Type a} {@0 B : Type b} {@0 f g : A → B} →
@0 (∀ x → f x ≡ g x) →
Is-equivalenceᴱ f → Is-equivalenceᴱ g
to f≡g f-eq@(f⁻¹ , _) =
( f⁻¹
, [ erased $ proj₂ $
Is-equivalence→Is-equivalenceᴱ $
Eq.respects-extensional-equality f≡g $
Is-equivalenceᴱ→Is-equivalence f-eq
]
)
----------------------------------------------------------------------
-- The left-to-right and right-to-left components of an equivalence
-- with erased proofs can be replaced with extensionally equal
-- functions
-- The forward direction of an equivalence with erased proofs can be
-- replaced by an extensionally equal function.
with-other-function :
{@0 A : Type a} {@0 B : Type b}
(A≃B : A ≃ᴱ B) (f : A → B) →
@0 (∀ x → _≃ᴱ_.to A≃B x ≡ f x) →
A ≃ᴱ B
with-other-function ⟨ g , is-equivalence ⟩ f g≡f =
⟨ f
, (let record { to = to } = Is-equivalenceᴱ-cong-⇔ g≡f in
to is-equivalence)
⟩₀
_ : _≃ᴱ_.to (with-other-function A≃B f p) ≡ f
_ = refl _
_ : _≃ᴱ_.from (with-other-function A≃B f p) ≡ _≃ᴱ_.from A≃B
_ = refl _
-- The same applies to the other direction.
with-other-inverse :
{@0 A : Type a} {@0 B : Type b}
(A≃B : A ≃ᴱ B) (g : B → A) →
@0 (∀ x → _≃ᴱ_.from A≃B x ≡ g x) →
A ≃ᴱ B
with-other-inverse A≃B g ≡g =
inverse $ with-other-function (inverse A≃B) g ≡g
_ : _≃ᴱ_.from (with-other-inverse A≃B g p) ≡ g
_ = refl _
_ : _≃ᴱ_.to (with-other-inverse A≃B f p) ≡ _≃ᴱ_.to A≃B
_ = refl _
| {
"alphanum_fraction": 0.549510585,
"avg_line_length": 27.0338461538,
"ext": "agda",
"hexsha": "49069ac78b28b1a1da6ff4543eea737d122333d1",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/equality",
"max_forks_repo_path": "src/Equivalence/Erased/Basics.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/equality",
"max_issues_repo_path": "src/Equivalence/Erased/Basics.agda",
"max_line_length": 72,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/equality",
"max_stars_repo_path": "src/Equivalence/Erased/Basics.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z",
"num_tokens": 3222,
"size": 8786
} |
-- 2012-03-08 Andreas
module NoTerminationCheck4 where
data Bool : Set where
true false : Bool
{-# NON_TERMINATING #-}
private
f : Bool -> Bool
f true = f true
f false = f false
-- error: must place pragma before f
| {
"alphanum_fraction": 0.6814159292,
"avg_line_length": 16.1428571429,
"ext": "agda",
"hexsha": "d7a4080c8fe337ede6cdaa38507bf1983e415d0f",
"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/NoTerminationCheck4.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/NoTerminationCheck4.agda",
"max_line_length": 36,
"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/NoTerminationCheck4.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": 67,
"size": 226
} |
------------------------------------------------------------------------------
-- First-order logic (without equality)
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
-- This module is re-exported by the "base" modules whose theories are
-- defined on first-order logic (without equality).
-- The logical connectives are hard-coded in our translation, i.e. the
-- symbols ⊥, ⊤, ¬, ∧, ∨, → and ↔ must be used.
--
-- N.B. For the implication we use the Agda function type.
--
-- N.B For the universal quantifier we use the Agda (dependent)
-- function type.
module Common.FOL.FOL where
infixr 4 _,_
infix 3 ¬_
infixr 2 _∧_
infix 2 ∃
infixr 1 _∨_
infixr 0 _↔_
----------------------------------------------------------------------------
-- The universe of discourse/universal domain.
postulate D : Set
------------------------------------------------------------------------------
-- The conjunction data type.
-- It is not necessary to add the data constructor _,_ as an
-- axiom because the ATPs implement it.
data _∧_ (A B : Set) : Set where
_,_ : A → B → A ∧ B
-- It is not strictly necessary define the projections ∧-proj₁ and
-- ∧-proj₂ because the ATPs implement them. For the same reason, it is
-- not necessary to add them as (general/local) hints.
∧-proj₁ : ∀ {A B} → A ∧ B → A
∧-proj₁ (a , _) = a
∧-proj₂ : ∀ {A B} → A ∧ B → B
∧-proj₂ (_ , b) = b
-----------------------------------------------------------------------------
-- The disjunction data type.
-- It is not necessary to add the data constructors inj₁ and inj₂ as
-- axioms because the ATPs implement them.
data _∨_ (A B : Set) : Set where
inj₁ : A → A ∨ B
inj₂ : B → A ∨ B
-- It is not strictly necessary define the eliminator `case` because
-- the ATPs implement it. For the same reason, it is not necessary to
-- add it as a (general/local) hint.
case : ∀ {A B} → {C : Set} → (A → C) → (B → C) → A ∨ B → C
case f g (inj₁ a) = f a
case f g (inj₂ b) = g b
------------------------------------------------------------------------------
-- The empty type.
data ⊥ : Set where
⊥-elim : {A : Set} → ⊥ → A
⊥-elim ()
------------------------------------------------------------------------------
-- The unit type.
-- N.B. The name of this type is "\top", not T.
data ⊤ : Set where
tt : ⊤
------------------------------------------------------------------------------
-- Negation.
-- The underscore allows to write for example '¬ ¬ A' instead of '¬ (¬ A)'.
-- We do not add a definition because: i) the definition of negation
-- is not a FOL-definition and ii) the translation of the neagation is
-- hard-coded in Apia.
¬_ : Set → Set
¬ A = A → ⊥
------------------------------------------------------------------------------
-- Biconditional.
-- We do not add a definition because: i) the definition of the
-- biconditional is not a FOL-definition, ii) the translation of the
-- biconditional is hard-coded in Apia.
_↔_ : Set → Set → Set
A ↔ B = (A → B) ∧ (B → A)
------------------------------------------------------------------------------
-- The existential quantifier type on D.
data ∃ (A : D → Set) : Set where
_,_ : (t : D) → A t → ∃ A
-- Sugar syntax for the existential quantifier.
syntax ∃ (λ x → e) = ∃[ x ] e
-- 2012-03-05: We avoid to use the existential elimination or the
-- existential projections because we use pattern matching (and the
-- Agda's with constructor).
-- The existential elimination.
--
-- NB. We do not use the usual type theory elimination with two
-- projections because we are working in first-order logic where we do
-- not need extract a witness from an existence proof.
-- ∃-elim : {A : D → Set}{B : Set} → ∃ A → (∀ {x} → A x → B) → B
-- ∃-elim (_ , Ax) h = h Ax
-- The existential proyections.
-- ∃-proj₁ : ∀ {A} → ∃ A → D
-- ∃-proj₁ (x , _) = x
-- ∃-proj₂ : ∀ {A} → (h : ∃ A) → A (∃-proj₁ h)
-- ∃-proj₂ (_ , Ax) = Ax
------------------------------------------------------------------------------
-- Properties
→-trans : {A B C : Set} → (A → B) → (B → C) → A → C
→-trans f g a = g (f a)
| {
"alphanum_fraction": 0.492798111,
"avg_line_length": 31.6044776119,
"ext": "agda",
"hexsha": "2883f938b3b6cfd4a3d2e2d0ca131082616a2230",
"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/Common/FOL/FOL.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/Common/FOL/FOL.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/Common/FOL/FOL.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": 1129,
"size": 4235
} |
-- Andreas, 2014-06-12 This feature has been addressed by issue 907
{-# OPTIONS --copatterns #-}
module CopatternsToRHS where
import Common.Level
open import Common.Equality
open import Common.Prelude using (Bool; true; false)
record R (A : Set) : Set where
constructor mkR
field
fst : A → A
snd : Bool
open R
someR : {A : Set} → R A
fst someR x = x
snd someR = true
-- This already behaves like:
someR' : {A : Set} → R A
fst someR' = λ x → x
snd someR' = true
-- We translate it to:
someR″ : {A : Set} → R A
someR″ = mkR (λ x → x) true
data C {A : Set} : R A → Set where
c : ∀ f b → C (mkR f b)
works : {A : Set} → C {A} someR″ → Set₁
works (c .(λ x → x) .true) = Set
test : {A : Set} → C {A} someR → Set₁
test (c .(λ x → x) .true) = Set
| {
"alphanum_fraction": 0.5997392438,
"avg_line_length": 18.7073170732,
"ext": "agda",
"hexsha": "ace4c320e825b18ed9a10a8e621f30425ea7e37f",
"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/CopatternsToRHS.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/CopatternsToRHS.agda",
"max_line_length": 68,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/CopatternsToRHS.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": 285,
"size": 767
} |
------------------------------------------------------------------------
-- A tactic aimed at making equational reasoning proofs more readable
-- in modules that are parametrised by an implementation of equality
------------------------------------------------------------------------
-- The tactic uses the first instance of Equality-with-J that it finds
-- in the context.
{-# OPTIONS --without-K --safe #-}
open import Equality
open import Prelude
module Tactic.By.Parametrised
{c⁺} (eq : ∀ {a p} → Equality-with-J a p c⁺) where
open Derived-definitions-and-properties eq
open import List eq
open import Monad eq
open import Tactic.By eq as TB
open import TC-monad eq as TC
open TB public using (⟨_⟩)
------------------------------------------------------------------------
-- The ⟨by⟩ tactic
private
-- Finds the first instance of "∀ Δ → Equality-with-J something" in
-- the context (if any; Δ must not contain "visible" arguments),
-- starting from the "outside", and returns a term standing for this
-- instance.
find-Equality-with-J : TC Term
find-Equality-with-J = do
c ← getContext
n ← search (reverse c)
return (var (length c ∸ suc n) [])
where
search : List (Arg TC.Type) → TC ℕ
search [] = typeError (strErr err ∷ [])
where
err = "⟨by⟩: No instance of Equality-with-J found in the context."
search (a@(arg _ t) ∷ args) = do
if ok t then return 0
else suc ⟨$⟩ search args
where
ok : Term → Bool
ok (def f _) =
if eq-Name f (quote Equality-with-J)
then true
else false
ok (pi (arg (arg-info visible _) _) _) = false
ok (pi _ (abs _ b)) = ok b
ok _ = false
open ⟨By⟩
(λ where
(def (quote Reflexive-relation._≡_)
(arg _ a ∷ _ ∷ arg _ A ∷ arg _ x ∷ arg _ y ∷ [])) →
return $ just (a , A , x , y)
_ → return nothing)
find-Equality-with-J
(λ eq p → def (quote sym) (varg eq ∷ varg p ∷ []))
(λ eq lhs rhs f p → def (quote cong)
(varg eq ∷
replicate 4 (harg unknown) ++
harg lhs ∷ harg rhs ∷ varg f ∷ varg p ∷ []))
false
public
| {
"alphanum_fraction": 0.5186666667,
"avg_line_length": 30.4054054054,
"ext": "agda",
"hexsha": "6f53a40e2428202a41831fb77caa35889e5adb8f",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/equality",
"max_forks_repo_path": "src/Tactic/By/Parametrised.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/equality",
"max_issues_repo_path": "src/Tactic/By/Parametrised.agda",
"max_line_length": 72,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/equality",
"max_stars_repo_path": "src/Tactic/By/Parametrised.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z",
"num_tokens": 584,
"size": 2250
} |
-- Andreas, 2016-12-28, issue #2360 reported by m0davis
-- Ambigous projection in with-clause triggered internal error
postulate
A : Set
a : A
module M (X : Set) where
record R : Set where
field f : X
-- Opening two instantiations of M creates and ambiguous projection
open M A using (module R)
open M A
test : R
R.f test with a
R.f test | _ = a -- WAS: triggered __IMPOSSIBLE__
-- should succeed
| {
"alphanum_fraction": 0.6980676329,
"avg_line_length": 18.8181818182,
"ext": "agda",
"hexsha": "e9ffcd3c784a658cd797d9bed49e523531cbfdad",
"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/Issue2360.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/Issue2360.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/Issue2360.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": 126,
"size": 414
} |
{-# OPTIONS --safe #-}
module Ferros.Prelude where
open import Relation.Binary.PropositionalEquality
open import Data.Nat
open import Data.Nat.Properties
open import Data.Bool hiding (_≤_)
ℕ-sub : (x y : ℕ) → (y ≤ x) → ℕ
ℕ-sub x .zero z≤n = x
ℕ-sub ._ ._ (s≤s p) = ℕ-sub _ _ p
invert-ℕ-sub : ∀ x y → (p : y ≤ x) → (ℕ-sub x y p) + y ≡ x
invert-ℕ-sub x .zero z≤n = +-identityʳ x
invert-ℕ-sub (suc x) (suc y) (s≤s p) = begin
(ℕ-sub (suc x) (suc y) (s≤s p)) + suc y ≡⟨ +-suc (ℕ-sub (suc x) (suc y) (s≤s p)) y ⟩
suc ((ℕ-sub (suc x) (suc y) (s≤s p)) + y) ≡⟨ cong suc (invert-ℕ-sub x y p) ⟩
suc x
∎ where open ≡-Reasoning
| {
"alphanum_fraction": 0.5786963434,
"avg_line_length": 29.9523809524,
"ext": "agda",
"hexsha": "931c81371fb1b76092050b0803b6df919f9fbd74",
"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": "8759d36ac9ec24c53f226a60fa3811eb1d4e5d93",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "auxoncorp/ferros-spec",
"max_forks_repo_path": "Ferros/Prelude.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "8759d36ac9ec24c53f226a60fa3811eb1d4e5d93",
"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": "auxoncorp/ferros-spec",
"max_issues_repo_path": "Ferros/Prelude.agda",
"max_line_length": 88,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "8759d36ac9ec24c53f226a60fa3811eb1d4e5d93",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "auxoncorp/ferros-spec",
"max_stars_repo_path": "Ferros/Prelude.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-27T23:18:55.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-09-11T01:06:56.000Z",
"num_tokens": 289,
"size": 629
} |
{-# OPTIONS --without-K --safe #-}
module TypeTheory.Nat.Instance where
-- agda-stdlib
open import Level renaming (zero to lzero; suc to lsuc)
open import Data.Nat using (ℕ; zero; suc)
open import Relation.Binary.PropositionalEquality using (refl)
-- agda-misc
import TypeTheory.Nat.Operations as NatOperations
ℕ-ind : ∀ {l} (P : ℕ → Set l) → P zero → (∀ k → P k → P (suc k)) → ∀ n → P n
ℕ-ind P P-base P-step zero = P-base
ℕ-ind P P-base P-step (suc n) = P-step n (ℕ-ind P P-base P-step n)
open NatOperations ℕ zero suc ℕ-ind
(λ _ _ _ → refl) (λ _ _ _ _ → refl) public
| {
"alphanum_fraction": 0.6432160804,
"avg_line_length": 31.4210526316,
"ext": "agda",
"hexsha": "bb4175478e9da0edcb435782be87a29c772d69f3",
"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": "37200ea91d34a6603d395d8ac81294068303f577",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "rei1024/agda-misc",
"max_forks_repo_path": "TypeTheory/Nat/Instance.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577",
"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": "rei1024/agda-misc",
"max_issues_repo_path": "TypeTheory/Nat/Instance.agda",
"max_line_length": 76,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "rei1024/agda-misc",
"max_stars_repo_path": "TypeTheory/Nat/Instance.agda",
"max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z",
"num_tokens": 192,
"size": 597
} |
{-# OPTIONS --warning=error #-}
module UselessPrivateImport2 where
private
open import Common.Issue481ParametrizedModule Set
| {
"alphanum_fraction": 0.7984496124,
"avg_line_length": 18.4285714286,
"ext": "agda",
"hexsha": "95fa3dd30e44cad7df4ea969a702f0124faeff58",
"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/UselessPrivateImport2.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/UselessPrivateImport2.agda",
"max_line_length": 51,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/UselessPrivateImport2.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": 129
} |
module Numeral.Integer.Relation where
| {
"alphanum_fraction": 0.8684210526,
"avg_line_length": 19,
"ext": "agda",
"hexsha": "e0a5498630f3a703e323b896a9cf59e9f0753b55",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Numeral/Integer/Relation.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Numeral/Integer/Relation.agda",
"max_line_length": 37,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Numeral/Integer/Relation.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z",
"num_tokens": 8,
"size": 38
} |
module OpenPublicPlusTypeError where
module X where
postulate D : Set
open X public
postulate x : D
typeIncorrect : Set
typeIncorrect = Set1
| {
"alphanum_fraction": 0.7702702703,
"avg_line_length": 11.3846153846,
"ext": "agda",
"hexsha": "776aa30c5e52447a35ebd69e559609bfea899dbc",
"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/OpenPublicPlusTypeError.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/OpenPublicPlusTypeError.agda",
"max_line_length": 36,
"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/OpenPublicPlusTypeError.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": 39,
"size": 148
} |
{-# OPTIONS --cubical --safe #-}
module Cubical.Structures.TypeEqvTo where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.HITs.PropositionalTruncation
open import Cubical.Data.Prod hiding (_×_) renaming (_×Σ_ to _×_)
open import Cubical.Foundations.SIP renaming (SNS-PathP to SNS)
open import Cubical.Foundations.Pointed
open import Cubical.Structures.Pointed
private
variable
ℓ ℓ' ℓ'' : Level
TypeEqvTo : (ℓ : Level) (X : Type ℓ') → Type (ℓ-max (ℓ-suc ℓ) ℓ')
TypeEqvTo ℓ X = TypeWithStr ℓ (λ Y → ∥ Y ≃ X ∥)
PointedEqvTo : (ℓ : Level) (X : Type ℓ') → Type (ℓ-max (ℓ-suc ℓ) ℓ')
PointedEqvTo ℓ X = TypeWithStr ℓ (λ Y → Y × ∥ Y ≃ X ∥)
module _ (X : Type ℓ') where
PointedEqvTo-structure : Type ℓ → Type (ℓ-max ℓ ℓ')
PointedEqvTo-structure = add-to-structure pointed-structure (λ Y _ → ∥ Y ≃ X ∥)
PointedEqvTo-iso : StrIso PointedEqvTo-structure ℓ''
PointedEqvTo-iso = add-to-iso pointed-structure pointed-iso (λ Y _ → ∥ Y ≃ X ∥)
PointedEqvTo-is-SNS : SNS {ℓ} PointedEqvTo-structure PointedEqvTo-iso
PointedEqvTo-is-SNS = add-axioms-SNS pointed-structure pointed-iso (λ Y _ → ∥ Y ≃ X ∥)
(λ _ _ → squash)
pointed-is-SNS
PointedEqvTo-SIP : (A B : PointedEqvTo ℓ X) → A ≃[ PointedEqvTo-iso ] B ≃ (A ≡ B)
PointedEqvTo-SIP = SIP PointedEqvTo-structure PointedEqvTo-iso PointedEqvTo-is-SNS
PointedEqvTo-sip : (A B : PointedEqvTo ℓ X) → A ≃[ PointedEqvTo-iso ] B → (A ≡ B)
PointedEqvTo-sip A B = equivFun (PointedEqvTo-SIP A B)
| {
"alphanum_fraction": 0.6616161616,
"avg_line_length": 37.7142857143,
"ext": "agda",
"hexsha": "292100f630b8f2baf01bdc3b27639d67f81ee656",
"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": "cefeb3669ffdaea7b88ae0e9dd258378418819ca",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "borsiemir/cubical",
"max_forks_repo_path": "Cubical/Structures/TypeEqvTo.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca",
"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": "borsiemir/cubical",
"max_issues_repo_path": "Cubical/Structures/TypeEqvTo.agda",
"max_line_length": 88,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "borsiemir/cubical",
"max_stars_repo_path": "Cubical/Structures/TypeEqvTo.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 601,
"size": 1584
} |
module trie-core where
open import bool
open import char
open import list
open import maybe
open import product
open import string
open import unit
open import eq
open import nat
cal : Set → Set
cal A = 𝕃 (char × A)
empty-cal : ∀{A : Set} → cal A
empty-cal = []
cal-lookup : ∀ {A : Set} → cal A → char → maybe A
cal-lookup [] _ = nothing
cal-lookup ((c , a) :: l) c' with c =char c'
... | tt = just a
... | ff = cal-lookup l c'
cal-insert : ∀ {A : Set} → cal A → char → A → cal A
cal-insert [] c a = (c , a) :: []
cal-insert ((c' , a') :: l) c a with c =char c'
... | tt = (c , a) :: l
... | ff = (c' , a') :: (cal-insert l c a)
cal-remove : ∀ {A : Set} → cal A → char → cal A
cal-remove [] _ = []
cal-remove ((c , a) :: l) c' with c =char c'
... | tt = cal-remove l c'
... | ff = (c , a) :: cal-remove l c'
cal-add : ∀{A : Set} → cal A → char → A → cal A
cal-add l c a = (c , a) :: l
test-cal-insert = cal-insert (('a' , 1) :: ('b' , 2) :: []) 'b' 20
data trie (A : Set) : Set where
Node : maybe A → cal (trie A) → trie A
empty-trie : ∀{A : Set} → trie A
empty-trie = (Node nothing empty-cal)
trie-lookup-h : ∀{A : Set} → trie A → 𝕃 char → maybe A
trie-lookup-h (Node odata ts) (c :: cs) with cal-lookup ts c
trie-lookup-h (Node odata ts) (c :: cs) | nothing = nothing
trie-lookup-h (Node odata ts) (c :: cs) | just t = trie-lookup-h t cs
trie-lookup-h (Node odata ts) [] = odata
trie-insert-h : ∀{A : Set} → trie A → 𝕃 char → A → trie A
trie-insert-h (Node odata ts) [] x = (Node (just x) ts)
trie-insert-h (Node odata ts) (c :: cs) x with cal-lookup ts c
trie-insert-h (Node odata ts) (c :: cs) x | just t =
(Node odata (cal-insert ts c (trie-insert-h t cs x)))
trie-insert-h (Node odata ts) (c :: cs) x | nothing =
(Node odata (cal-add ts c (trie-insert-h empty-trie cs x)))
trie-remove-h : ∀{A : Set} → trie A → 𝕃 char → trie A
trie-remove-h (Node odata ts) (c :: cs) with cal-lookup ts c
trie-remove-h (Node odata ts) (c :: cs) | nothing = Node odata ts
trie-remove-h (Node odata ts) (c :: cs) | just t = Node odata (cal-insert ts c (trie-remove-h t cs))
trie-remove-h (Node odata ts) [] = Node nothing ts
| {
"alphanum_fraction": 0.5836849508,
"avg_line_length": 31.8358208955,
"ext": "agda",
"hexsha": "59c773e59d53e8387590990f56436a0b544f63b1",
"lang": "Agda",
"max_forks_count": 17,
"max_forks_repo_forks_event_max_datetime": "2021-11-28T20:13:21.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-12-03T22:38:15.000Z",
"max_forks_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "rfindler/ial",
"max_forks_repo_path": "trie-core.agda",
"max_issues_count": 8,
"max_issues_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6",
"max_issues_repo_issues_event_max_datetime": "2022-03-22T03:43:34.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-07-09T22:53:38.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "rfindler/ial",
"max_issues_repo_path": "trie-core.agda",
"max_line_length": 100,
"max_stars_count": 29,
"max_stars_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "rfindler/ial",
"max_stars_repo_path": "trie-core.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-04T15:05:12.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-02-06T13:09:31.000Z",
"num_tokens": 761,
"size": 2133
} |
postulate
F : Set → Set → Set
syntax F X Y = X ! Y
test : Set → Set → Set
test X = _! X
| {
"alphanum_fraction": 0.5434782609,
"avg_line_length": 11.5,
"ext": "agda",
"hexsha": "3a44998253f56bf10540a2f557a89d0c0f1da7fe",
"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/Sections-4.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/Sections-4.agda",
"max_line_length": 22,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Fail/Sections-4.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": 36,
"size": 92
} |
open import Everything
module Test.Test4
{𝔵} {𝔛 : Ø 𝔵}
{𝔞} {𝔒₁ : 𝔛 → Ø 𝔞}
{𝔟} {𝔒₂ : 𝔛 → Ø 𝔟}
{ℓ : Ł}
⦃ _ : Transitivity.class (Arrow 𝔒₁ 𝔒₂) ⦄
-- ⦃ _ : [𝓢urjectivity] (Arrow 𝔒₁ 𝔒₂) (Extension $ ArrowṖroperty ℓ 𝔒₁ 𝔒₂) ⦄
where
test[∙] : ∀ {x y} → ArrowṖroperty ℓ 𝔒₁ 𝔒₂ x → Arrow 𝔒₁ 𝔒₂ x y → ArrowṖroperty ℓ 𝔒₁ 𝔒₂ y
test[∙] P f .π₀ g = (f ◃ P) .π₀ g
| {
"alphanum_fraction": 0.5501355014,
"avg_line_length": 26.3571428571,
"ext": "agda",
"hexsha": "33227dc11a532be4369943df5cbb1a7e060b3b87",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_forks_repo_licenses": [
"RSA-MD"
],
"max_forks_repo_name": "m0davis/oscar",
"max_forks_repo_path": "archive/agda-3/src/Test/Test4.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z",
"max_issues_repo_licenses": [
"RSA-MD"
],
"max_issues_repo_name": "m0davis/oscar",
"max_issues_repo_path": "archive/agda-3/src/Test/Test4.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/Test/Test4.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 235,
"size": 369
} |
module parser where
open import lib
open import cedille-types
{-# FOREIGN GHC import qualified CedilleParser #-}
data Either (A : Set)(B : Set) : Set where
Left : A → Either A B
Right : B → Either A B
{-# COMPILE GHC Either = data Either (Left | Right) #-}
postulate
parseStart : string → Either (Either string string) start
parseTerm : string → Either string term
parseType : string → Either string type
parseKind : string → Either string kind
parseLiftingType : string → Either string liftingType
parseDefTermOrType : string → Either string defTermOrType
{-# COMPILE GHC parseStart = CedilleParser.parseTxt #-}
{-# COMPILE GHC parseTerm = CedilleParser.parseTerm #-}
{-# COMPILE GHC parseType = CedilleParser.parseType #-}
{-# COMPILE GHC parseKind = CedilleParser.parseKind #-}
{-# COMPILE GHC parseLiftingType = CedilleParser.parseLiftingType #-}
{-# COMPILE GHC parseDefTermOrType = CedilleParser.parseDefTermOrType #-}
| {
"alphanum_fraction": 0.7367864693,
"avg_line_length": 36.3846153846,
"ext": "agda",
"hexsha": "4818522c7211fe5d5f44a0054a7eaf30a136dc0c",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "acf691e37210607d028f4b19f98ec26c4353bfb5",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "xoltar/cedille",
"max_forks_repo_path": "src/parser.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "acf691e37210607d028f4b19f98ec26c4353bfb5",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "xoltar/cedille",
"max_issues_repo_path": "src/parser.agda",
"max_line_length": 73,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "acf691e37210607d028f4b19f98ec26c4353bfb5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "xoltar/cedille",
"max_stars_repo_path": "src/parser.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 236,
"size": 946
} |
{-# OPTIONS --without-K --rewriting #-}
open import lib.Basics
open import lib.types.Pi
open import lib.types.Pointed
open import lib.types.Sigma
open import lib.types.Span
open import lib.types.Paths
import lib.types.Generic1HIT as Generic1HIT
module lib.types.Pushout where
module _ {i j k} where
postulate -- HIT
Pushout : (d : Span {i} {j} {k}) → Type (lmax (lmax i j) k)
module _ {d : Span} where
postulate -- HIT
left : Span.A d → Pushout d
right : Span.B d → Pushout d
glue : (c : Span.C d) → left (Span.f d c) == right (Span.g d c)
module PushoutElim {d : Span} {l} {P : Pushout d → Type l}
(left* : (a : Span.A d) → P (left a))
(right* : (b : Span.B d) → P (right b))
(glue* : (c : Span.C d) → left* (Span.f d c) == right* (Span.g d c) [ P ↓ glue c ]) where
postulate -- HIT
f : Π (Pushout d) P
left-β : ∀ a → f (left a) ↦ left* a
right-β : ∀ b → f (right b) ↦ right* b
{-# REWRITE left-β #-}
{-# REWRITE right-β #-}
postulate -- HIT
glue-β : (c : Span.C d) → apd f (glue c) == glue* c
Pushout-elim = PushoutElim.f
module PushoutRec {i j k} {d : Span {i} {j} {k}} {l} {D : Type l}
(left* : Span.A d → D) (right* : Span.B d → D)
(glue* : (c : Span.C d) → left* (Span.f d c) == right* (Span.g d c)) where
private
module M = PushoutElim left* right* (λ c → ↓-cst-in (glue* c))
f : Pushout d → D
f = M.f
glue-β : (c : Span.C d) → ap f (glue c) == glue* c
glue-β c = apd=cst-in {f = f} (M.glue-β c)
Pushout-rec = PushoutRec.f
Pushout-rec-η : ∀ {i j k} {d : Span {i} {j} {k}} {l} {D : Type l} (f : Pushout d → D)
→ Pushout-rec (f ∘ left) (f ∘ right) (ap f ∘ glue) ∼ f
Pushout-rec-η f = Pushout-elim (λ _ → idp) (λ _ → idp)
(λ c → ↓-='-in' $ ! $ PushoutRec.glue-β (f ∘ left) (f ∘ right) (ap f ∘ glue) c)
module PushoutGeneric {i j k} {d : Span {i} {j} {k}} where
open Span d renaming (f to g; g to h)
open Generic1HIT (Coprod A B) C (inl ∘ g) (inr ∘ h) public
module _ where
module To = PushoutRec (cc ∘ inl) (cc ∘ inr) pp
to : Pushout d → T
to = To.f
from-cc : Coprod A B → Pushout d
from-cc (inl a) = left a
from-cc (inr b) = right b
module From = Rec from-cc glue
from : T → Pushout d
from = From.f
abstract
to-from : (x : T) → to (from x) == x
to-from = elim to-from-cc to-from-pp where
to-from-cc : (x : Coprod A B)
→ to (from (cc x)) == cc x
to-from-cc (inl a) = idp
to-from-cc (inr b) = idp
to-from-pp :
(c : C) → idp == idp [ (λ z → to (from z) == z) ↓ pp c ]
to-from-pp c = ↓-∘=idf-in' to from
(ap to (ap from (pp c)) =⟨ From.pp-β c |in-ctx ap to ⟩
ap to (glue c) =⟨ To.glue-β c ⟩
pp c =∎)
from-to : (x : Pushout d) → from (to x) == x
from-to = Pushout-elim (λ a → idp) (λ b → idp) (λ c → ↓-∘=idf-in' from to
(ap from (ap to (glue c)) =⟨ To.glue-β c |in-ctx ap from ⟩
ap from (pp c) =⟨ From.pp-β c ⟩
glue c =∎))
generic-pushout : Pushout d ≃ T
generic-pushout = equiv to from to-from from-to
_⊔^[_]_/_ : ∀ {i j k} (A : Type i) (C : Type k) (B : Type j)
(fg : (C → A) × (C → B)) → Type (lmax (lmax i j) k)
A ⊔^[ C ] B / (f , g) = Pushout (span A B C f g)
⊙Pushout : ∀ {i j k} (d : ⊙Span {i} {j} {k}) → Ptd _
⊙Pushout d = ⊙[ Pushout (⊙Span-to-Span d) , left (pt (⊙Span.X d)) ]
module _ {i j k} (d : ⊙Span {i} {j} {k}) where
open ⊙Span d
⊙left : X ⊙→ ⊙Pushout d
⊙left = (left , idp)
⊙right : Y ⊙→ ⊙Pushout d
⊙right =
(right , ap right (! (snd g)) ∙ ! (glue (pt Z)) ∙' ap left (snd f))
⊙glue : (⊙left ⊙∘ f) == (⊙right ⊙∘ g)
⊙glue = pair=
(λ= glue)
(↓-app=cst-in $
ap left (snd f) ∙ idp
=⟨ ∙-unit-r _ ⟩
ap left (snd f)
=⟨ lemma (glue (pt Z)) (ap right (snd g)) (ap left (snd f)) ⟩
glue (pt Z) ∙ ap right (snd g)
∙ ! (ap right (snd g)) ∙ ! (glue (pt Z)) ∙' ap left (snd f)
=⟨ !-ap right (snd g)
|in-ctx (λ w → glue (pt Z) ∙ ap right (snd g) ∙ w
∙ ! (glue (pt Z)) ∙' ap left (snd f)) ⟩
glue (pt Z) ∙ ap right (snd g)
∙ ap right (! (snd g)) ∙ ! (glue (pt Z)) ∙' ap left (snd f)
=⟨ ! (app=-β glue (pt Z))
|in-ctx (λ w → w ∙ ap right (snd g) ∙ ap right (! (snd g))
∙ ! (glue (pt Z)) ∙' ap left (snd f)) ⟩
app= (λ= glue) (pt Z) ∙ ap right (snd g)
∙ ap right (! (snd g)) ∙ ! (glue (pt Z)) ∙' ap left (snd f) =∎)
where
lemma : ∀ {i} {A : Type i} {x y z w : A}
(p : x == y) (q : y == z) (r : x == w)
→ r == p ∙ q ∙ ! q ∙ ! p ∙' r
lemma idp idp idp = idp
⊙pushout-J : ∀ {i j k l} (P : ⊙Span → Type l)
→ ({A : Type i} {B : Type j} (Z : Ptd k) (f : de⊙ Z → A) (g : de⊙ Z → B)
→ P (⊙span ⊙[ A , f (pt Z) ] ⊙[ B , g (pt Z) ] Z (f , idp) (g , idp)))
→ ((ps : ⊙Span) → P ps)
⊙pushout-J P t (⊙span ⊙[ _ , ._ ] ⊙[ _ , ._ ] Z (f , idp) (g , idp)) = t Z f g
| {
"alphanum_fraction": 0.4783214002,
"avg_line_length": 31.8227848101,
"ext": "agda",
"hexsha": "13d563b0813f0de7325af21af9c2fb894d6c28bc",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "timjb/HoTT-Agda",
"max_forks_repo_path": "core/lib/types/Pushout.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "timjb/HoTT-Agda",
"max_issues_repo_path": "core/lib/types/Pushout.agda",
"max_line_length": 93,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "timjb/HoTT-Agda",
"max_stars_repo_path": "core/lib/types/Pushout.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2120,
"size": 5028
} |
-- New NO_POSITIVITY_CHECK pragma for data definitions and mutual
-- blocks
-- Skipping an old-style mutual block: Somewhere within a `mutual`
-- block before a data definition.
mutual
data Cheat : Set where
cheat : Oops → Cheat
{-# NO_POSITIVITY_CHECK #-}
data Oops : Set where
oops : (Cheat → Cheat) → Oops
| {
"alphanum_fraction": 0.7015384615,
"avg_line_length": 25,
"ext": "agda",
"hexsha": "46e5e3ab88bb2787ae3c92f605eac611b6b5aeec",
"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/Issue1614b.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/Issue1614b.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/Succeed/Issue1614b.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 86,
"size": 325
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Algebra.RingSolver.CommRingEvalHom where
open import Cubical.Foundations.Prelude
open import Cubical.Data.Nat using (ℕ)
open import Cubical.Data.FinData
open import Cubical.Data.Vec
open import Cubical.Data.Bool.Base
open import Cubical.Algebra.RingSolver.RawAlgebra
open import Cubical.Algebra.RingSolver.CommRingHornerForms
open import Cubical.Algebra.CommRing
open import Cubical.Algebra.Ring
private
variable
ℓ : Level
module HomomorphismProperties (R : CommRing {ℓ}) where
private
νR = CommRing→RawℤAlgebra R
open CommRingStr (snd R)
open Theory (CommRing→Ring R)
open IteratedHornerOperations νR
EvalHom+0 : (n : ℕ) (P : IteratedHornerForms νR n) (xs : Vec ⟨ νR ⟩ n)
→ eval n (0ₕ +ₕ P) xs ≡ eval n P xs
EvalHom+0 ℕ.zero (const x) [] = cong (scalar R) (+Ridℤ x)
EvalHom+0 (ℕ.suc n) P xs = refl
Eval0H : (n : ℕ) (xs : Vec ⟨ νR ⟩ n)
→ eval {A = νR} n 0ₕ xs ≡ 0r
Eval0H .ℕ.zero [] = refl
Eval0H .(ℕ.suc _) (x ∷ xs) = refl
combineCasesEval :
{n : ℕ} (P : IteratedHornerForms νR (ℕ.suc n)) (Q : IteratedHornerForms νR n)
(x : (fst R)) (xs : Vec ⟨ νR ⟩ n)
→ eval (ℕ.suc n) (P ·X+ Q) (x ∷ xs) ≡ (eval (ℕ.suc n) P (x ∷ xs)) · x + eval n Q xs
combineCasesEval {n = n} 0H Q x xs =
eval n Q xs ≡⟨ sym (+Lid _) ⟩
0r + eval n Q xs ≡[ i ]⟨ 0LeftAnnihilates x (~ i) + eval n Q xs ⟩
0r · x + eval n Q xs ∎
combineCasesEval {n = n} (P ·X+ P₁) Q x xs = refl
Eval1ₕ : (n : ℕ) (xs : Vec ⟨ νR ⟩ n)
→ eval {A = νR} n 1ₕ xs ≡ 1r
Eval1ₕ .ℕ.zero [] = refl
Eval1ₕ (ℕ.suc n) (x ∷ xs) =
eval (ℕ.suc n) 1ₕ (x ∷ xs) ≡⟨ refl ⟩
eval (ℕ.suc n) (0H ·X+ 1ₕ) (x ∷ xs) ≡⟨ combineCasesEval 0H 1ₕ x xs ⟩
eval {A = νR} (ℕ.suc n) 0H (x ∷ xs) · x + eval n 1ₕ xs ≡⟨ cong (λ u → u · x + eval n 1ₕ xs)
(Eval0H _ (x ∷ xs)) ⟩
0r · x + eval n 1ₕ xs ≡⟨ cong (λ u → 0r · x + u)
(Eval1ₕ _ xs) ⟩
0r · x + 1r ≡⟨ cong (λ u → u + 1r)
(0LeftAnnihilates _) ⟩
0r + 1r ≡⟨ +Lid _ ⟩
1r ∎
-EvalDist :
(n : ℕ) (P : IteratedHornerForms νR n) (xs : Vec ⟨ νR ⟩ n)
→ eval n (-ₕ P) xs ≡ - eval n P xs
-EvalDist .ℕ.zero (const x) [] = -DistScalar R x
-EvalDist n 0H xs =
eval n (-ₕ 0H) xs ≡⟨ Eval0H n xs ⟩
0r ≡⟨ sym 0Selfinverse ⟩
- 0r ≡⟨ cong -_ (sym (Eval0H n xs)) ⟩
- eval n 0H xs ∎
-EvalDist .(ℕ.suc _) (P ·X+ Q) (x ∷ xs) =
eval (ℕ.suc _) (-ₕ (P ·X+ Q)) (x ∷ xs)
≡⟨ refl ⟩
eval (ℕ.suc _) ((-ₕ P) ·X+ (-ₕ Q)) (x ∷ xs)
≡⟨ combineCasesEval (-ₕ P) (-ₕ Q) x xs ⟩
(eval (ℕ.suc _) (-ₕ P) (x ∷ xs)) · x + eval _ (-ₕ Q) xs
≡⟨ cong (λ u → u · x + eval _ (-ₕ Q) xs) (-EvalDist _ P _) ⟩
(- eval (ℕ.suc _) P (x ∷ xs)) · x + eval _ (-ₕ Q) xs
≡⟨ cong (λ u → (- eval (ℕ.suc _) P (x ∷ xs)) · x + u) (-EvalDist _ Q _) ⟩
(- eval (ℕ.suc _) P (x ∷ xs)) · x + - eval _ Q xs
≡[ i ]⟨ -DistL· (eval (ℕ.suc _) P (x ∷ xs)) x i + - eval _ Q xs ⟩
- ((eval (ℕ.suc _) P (x ∷ xs)) · x) + (- eval _ Q xs)
≡⟨ -Dist _ _ ⟩
- ((eval (ℕ.suc _) P (x ∷ xs)) · x + eval _ Q xs)
≡[ i ]⟨ - combineCasesEval P Q x xs (~ i) ⟩
- eval (ℕ.suc _) (P ·X+ Q) (x ∷ xs) ∎
combineCases+ : (n : ℕ) (P Q : IteratedHornerForms νR (ℕ.suc n))
(r s : IteratedHornerForms νR n)
(xs : Vec ⟨ νR ⟩ (ℕ.suc n))
→ eval (ℕ.suc n) ((P ·X+ r) +ₕ (Q ·X+ s)) xs
≡ eval (ℕ.suc n) ((P +ₕ Q) ·X+ (r +ₕ s)) xs
combineCases+ ℕ.zero P Q r s xs with (P +ₕ Q) | (r +ₕ s)
... | (_ ·X+ _) | const (pos (ℕ.suc _)) = refl
... | (_ ·X+ _) | const (negsuc _) = refl
... | (_ ·X+ _) | const (pos ℕ.zero) = refl
... | 0H | const (pos (ℕ.suc _)) = refl
... | 0H | const (negsuc _) = refl
combineCases+ ℕ.zero P Q r s (x ∷ []) | 0H | const (pos ℕ.zero) = refl
combineCases+ (ℕ.suc n) P Q r s (x ∷ xs) with (P +ₕ Q) | (r +ₕ s)
... | (_ ·X+ _) | (_ ·X+ _) = refl
... | (_ ·X+ _) | 0H = refl
... | 0H | (_ ·X+ _) = refl
... | 0H | 0H = sym (Eval0H (ℕ.suc n) xs)
+Homeval :
(n : ℕ) (P Q : IteratedHornerForms νR n) (xs : Vec ⟨ νR ⟩ n)
→ eval n (P +ₕ Q) xs ≡ (eval n P xs) + (eval n Q xs)
+Homeval .ℕ.zero (const x) (const y) [] = +HomScalar R x y
+Homeval n 0H Q xs =
eval n (0H +ₕ Q) xs ≡⟨ refl ⟩
eval n Q xs ≡⟨ sym (+Lid _) ⟩
0r + eval n Q xs ≡⟨ cong (λ u → u + eval n Q xs) (sym (Eval0H n xs)) ⟩
eval n 0H xs + eval n Q xs ∎
+Homeval .(ℕ.suc _) (P ·X+ Q) 0H xs =
eval (ℕ.suc _) ((P ·X+ Q) +ₕ 0H) xs ≡⟨ refl ⟩
eval (ℕ.suc _) (P ·X+ Q) xs ≡⟨ sym (+Rid _) ⟩
eval (ℕ.suc _) (P ·X+ Q) xs + 0r
≡⟨ cong (λ u → eval (ℕ.suc _) (P ·X+ Q) xs + u) (sym (Eval0H _ xs)) ⟩
eval (ℕ.suc _) (P ·X+ Q) xs + eval (ℕ.suc _) 0H xs ∎
+Homeval .(ℕ.suc _) (P ·X+ Q) (S ·X+ T) (x ∷ xs) =
eval (ℕ.suc _) ((P ·X+ Q) +ₕ (S ·X+ T)) (x ∷ xs)
≡⟨ combineCases+ _ P S Q T (x ∷ xs) ⟩
eval (ℕ.suc _) ((P +ₕ S) ·X+ (Q +ₕ T)) (x ∷ xs)
≡⟨ combineCasesEval (P +ₕ S) (Q +ₕ T) x xs ⟩
(eval (ℕ.suc _) (P +ₕ S) (x ∷ xs)) · x + eval _ (Q +ₕ T) xs
≡⟨ cong (λ u → (eval (ℕ.suc _) (P +ₕ S) (x ∷ xs)) · x + u) (+Homeval _ Q T xs) ⟩
(eval (ℕ.suc _) (P +ₕ S) (x ∷ xs)) · x + (eval _ Q xs + eval _ T xs)
≡⟨ cong (λ u → u · x + (eval _ Q xs + eval _ T xs)) (+Homeval (ℕ.suc _) P S (x ∷ xs)) ⟩
(eval (ℕ.suc _) P (x ∷ xs) + eval (ℕ.suc _) S (x ∷ xs)) · x
+ (eval _ Q xs + eval _ T xs)
≡⟨ cong (λ u → u + (eval _ Q xs + eval _ T xs)) (·Ldist+ _ _ _) ⟩
(eval (ℕ.suc _) P (x ∷ xs)) · x + (eval (ℕ.suc _) S (x ∷ xs)) · x
+ (eval _ Q xs + eval _ T xs)
≡⟨ +ShufflePairs _ _ _ _ ⟩
((eval (ℕ.suc _) P (x ∷ xs)) · x + eval _ Q xs)
+ ((eval (ℕ.suc _) S (x ∷ xs)) · x + eval _ T xs)
≡[ i ]⟨ combineCasesEval P Q x xs (~ i) + combineCasesEval S T x xs (~ i) ⟩
eval (ℕ.suc _) (P ·X+ Q) (x ∷ xs)
+ eval (ℕ.suc _) (S ·X+ T) (x ∷ xs) ∎
⋆Homeval : (n : ℕ)
(r : IteratedHornerForms νR n)
(P : IteratedHornerForms νR (ℕ.suc n)) (x : ⟨ νR ⟩) (xs : Vec ⟨ νR ⟩ n)
→ eval (ℕ.suc n) (r ⋆ P) (x ∷ xs) ≡ eval n r xs · eval (ℕ.suc n) P (x ∷ xs)
⋆0LeftAnnihilates :
(n : ℕ) (P : IteratedHornerForms νR (ℕ.suc n)) (xs : Vec ⟨ νR ⟩ (ℕ.suc n))
→ eval (ℕ.suc n) (0ₕ ⋆ P) xs ≡ 0r
⋆0LeftAnnihilates n 0H xs = Eval0H (ℕ.suc n) xs
⋆0LeftAnnihilates ℕ.zero (P ·X+ Q) (x ∷ xs) = refl
⋆0LeftAnnihilates (ℕ.suc n) (P ·X+ Q) (x ∷ xs) = refl
·0LeftAnnihilates :
(n : ℕ) (P : IteratedHornerForms νR n) (xs : Vec ⟨ νR ⟩ n)
→ eval n (0ₕ ·ₕ P) xs ≡ 0r
·0LeftAnnihilates .ℕ.zero (const x) xs =
eval ℕ.zero (const _) xs ≡⟨ Eval0H _ xs ⟩ 0r ∎
·0LeftAnnihilates .(ℕ.suc _) 0H xs = Eval0H _ xs
·0LeftAnnihilates .(ℕ.suc _) (P ·X+ P₁) xs = Eval0H _ xs
·Homeval : (n : ℕ) (P Q : IteratedHornerForms νR n) (xs : Vec ⟨ νR ⟩ n)
→ eval n (P ·ₕ Q) xs ≡ (eval n P xs) · (eval n Q xs)
combineCases⋆ : (n : ℕ) (xs : Vec ⟨ νR ⟩ (ℕ.suc n))
→ (r : IteratedHornerForms νR n)
→ (P : IteratedHornerForms νR (ℕ.suc n))
→ (Q : IteratedHornerForms νR n)
→ eval (ℕ.suc n) (r ⋆ (P ·X+ Q)) xs ≡ eval (ℕ.suc n) ((r ⋆ P) ·X+ (r ·ₕ Q)) xs
combineCases⋆ .ℕ.zero (x ∷ []) (const (pos ℕ.zero)) P Q =
eval _ (const (pos ℕ.zero) ⋆ (P ·X+ Q)) (x ∷ []) ≡⟨ refl ⟩
eval _ 0ₕ (x ∷ []) ≡⟨ refl ⟩
0r ≡⟨ sym (+Rid _) ⟩
0r + 0r ≡[ i ]⟨ 0LeftAnnihilates x (~ i) + 0r ⟩
0r · x + 0r ≡[ i ]⟨ ⋆0LeftAnnihilates _ P (x ∷ []) (~ i) · x + ·0LeftAnnihilates _ Q [] (~ i) ⟩
eval _ (const (pos ℕ.zero) ⋆ P) (x ∷ []) · x + eval _ (const (pos ℕ.zero) ·ₕ Q) []
≡⟨ sym (combineCasesEval (const (pos ℕ.zero) ⋆ P) (const (pos ℕ.zero) ·ₕ Q) x []) ⟩
eval _ ((const (pos ℕ.zero) ⋆ P) ·X+ (const (pos ℕ.zero) ·ₕ Q)) (x ∷ []) ∎
combineCases⋆ .ℕ.zero (x ∷ []) (const (pos (ℕ.suc n))) P Q = refl
combineCases⋆ .ℕ.zero (x ∷ []) (const (negsuc n)) P Q = refl
combineCases⋆ .(ℕ.suc _) (x ∷ xs) 0H P Q =
eval _ (0H ⋆ (P ·X+ Q)) (x ∷ xs) ≡⟨ refl ⟩
eval _ 0ₕ (x ∷ []) ≡⟨ refl ⟩
0r ≡⟨ sym (+Rid _) ⟩
0r + 0r ≡[ i ]⟨ 0LeftAnnihilates x (~ i) + 0r ⟩
0r · x + 0r ≡[ i ]⟨ ⋆0LeftAnnihilates _ P (x ∷ xs) (~ i) · x + ·0LeftAnnihilates _ Q xs (~ i) ⟩
eval _ (0H ⋆ P) (x ∷ xs) · x + eval _ (0H ·ₕ Q) xs
≡⟨ sym (combineCasesEval (0H ⋆ P) (0H ·ₕ Q) x xs) ⟩
eval _ ((0H ⋆ P) ·X+ (0H ·ₕ Q)) (x ∷ xs) ∎
combineCases⋆ .(ℕ.suc _) (x ∷ xs) (r ·X+ r₁) P Q = refl
⋆Homeval n r 0H x xs =
eval (ℕ.suc n) (r ⋆ 0H) (x ∷ xs) ≡⟨ refl ⟩
0r ≡⟨ sym (0RightAnnihilates _) ⟩
eval n r xs · 0r ≡⟨ refl ⟩
eval n r xs · eval {A = νR} (ℕ.suc n) 0H (x ∷ xs) ∎
⋆Homeval n r (P ·X+ Q) x xs =
eval (ℕ.suc n) (r ⋆ (P ·X+ Q)) (x ∷ xs) ≡⟨ combineCases⋆ n (x ∷ xs) r P Q ⟩
eval (ℕ.suc n) ((r ⋆ P) ·X+ (r ·ₕ Q)) (x ∷ xs)
≡⟨ combineCasesEval (r ⋆ P) (r ·ₕ Q) x xs ⟩
(eval (ℕ.suc n) (r ⋆ P) (x ∷ xs)) · x + eval n (r ·ₕ Q) xs
≡⟨ cong (λ u → u · x + eval n (r ·ₕ Q) xs) (⋆Homeval n r P x xs) ⟩
(eval n r xs · eval (ℕ.suc n) P (x ∷ xs)) · x + eval n (r ·ₕ Q) xs
≡⟨ cong (λ u → (eval n r xs · eval (ℕ.suc n) P (x ∷ xs)) · x + u) (·Homeval n r Q xs) ⟩
(eval n r xs · eval (ℕ.suc n) P (x ∷ xs)) · x + eval n r xs · eval n Q xs
≡⟨ cong (λ u → u + eval n r xs · eval n Q xs) (sym (·Assoc _ _ _)) ⟩
eval n r xs · (eval (ℕ.suc n) P (x ∷ xs) · x) + eval n r xs · eval n Q xs
≡⟨ sym (·Rdist+ _ _ _) ⟩
eval n r xs · ((eval (ℕ.suc n) P (x ∷ xs) · x) + eval n Q xs)
≡[ i ]⟨ eval n r xs · combineCasesEval P Q x xs (~ i) ⟩
eval n r xs · eval (ℕ.suc n) (P ·X+ Q) (x ∷ xs) ∎
combineCases :
(n : ℕ) (Q : IteratedHornerForms νR n) (P S : IteratedHornerForms νR (ℕ.suc n))
(xs : Vec ⟨ νR ⟩ (ℕ.suc n))
→ eval (ℕ.suc n) ((P ·X+ Q) ·ₕ S) xs ≡ eval (ℕ.suc n) (((P ·ₕ S) ·X+ 0ₕ) +ₕ (Q ⋆ S)) xs
combineCases n Q P S (x ∷ xs) with (P ·ₕ S)
... | 0H =
eval (ℕ.suc n) (Q ⋆ S) (x ∷ xs) ≡⟨ sym (+Lid _) ⟩
0r + eval (ℕ.suc n) (Q ⋆ S) (x ∷ xs) ≡⟨ cong (λ u → u + eval _ (Q ⋆ S) (x ∷ xs)) lemma ⟩
eval (ℕ.suc n) (0H ·X+ 0ₕ) (x ∷ xs)
+ eval (ℕ.suc n) (Q ⋆ S) (x ∷ xs) ≡⟨ sym (+Homeval (ℕ.suc n)
(0H ·X+ 0ₕ) (Q ⋆ S) (x ∷ xs)) ⟩
eval (ℕ.suc n) ((0H ·X+ 0ₕ) +ₕ (Q ⋆ S)) (x ∷ xs) ∎
where lemma : 0r ≡ eval (ℕ.suc n) (0H ·X+ 0ₕ) (x ∷ xs)
lemma = 0r
≡⟨ sym (+Rid _) ⟩
0r + 0r
≡⟨ cong (λ u → u + 0r) (sym (0LeftAnnihilates _)) ⟩
0r · x + 0r
≡⟨ cong (λ u → 0r · x + u) (sym (Eval0H _ xs)) ⟩
0r · x + eval n 0ₕ xs
≡⟨ cong (λ u → u · x + eval n 0ₕ xs) (sym (Eval0H _ (x ∷ xs))) ⟩
eval {A = νR} (ℕ.suc n) 0H (x ∷ xs) · x + eval n 0ₕ xs
≡[ i ]⟨ combineCasesEval 0H 0ₕ x xs (~ i) ⟩
eval (ℕ.suc n) (0H ·X+ 0ₕ) (x ∷ xs) ∎
... | (_ ·X+ _) = refl
·Homeval .ℕ.zero (const x) (const y) [] = ·HomScalar R x y
·Homeval (ℕ.suc n) 0H Q xs =
eval (ℕ.suc n) (0H ·ₕ Q) xs ≡⟨ Eval0H _ xs ⟩
0r ≡⟨ sym (0LeftAnnihilates _) ⟩
0r · eval (ℕ.suc n) Q xs ≡⟨ cong (λ u → u · eval _ Q xs) (sym (Eval0H _ xs)) ⟩
eval (ℕ.suc n) 0H xs · eval (ℕ.suc n) Q xs ∎
·Homeval (ℕ.suc n) (P ·X+ Q) S (x ∷ xs) =
eval (ℕ.suc n) ((P ·X+ Q) ·ₕ S) (x ∷ xs)
≡⟨ combineCases n Q P S (x ∷ xs) ⟩
eval (ℕ.suc n) (((P ·ₕ S) ·X+ 0ₕ) +ₕ (Q ⋆ S)) (x ∷ xs)
≡⟨ +Homeval (ℕ.suc n) ((P ·ₕ S) ·X+ 0ₕ) (Q ⋆ S) (x ∷ xs) ⟩
eval (ℕ.suc n) ((P ·ₕ S) ·X+ 0ₕ) (x ∷ xs) + eval (ℕ.suc n) (Q ⋆ S) (x ∷ xs)
≡⟨ cong (λ u → u + eval (ℕ.suc n) (Q ⋆ S) (x ∷ xs)) (combineCasesEval (P ·ₕ S) 0ₕ x xs) ⟩
(eval (ℕ.suc n) (P ·ₕ S) (x ∷ xs) · x + eval n 0ₕ xs)
+ eval (ℕ.suc n) (Q ⋆ S) (x ∷ xs)
≡⟨ cong (λ u → u + eval (ℕ.suc n) (Q ⋆ S) (x ∷ xs))
((eval (ℕ.suc n) (P ·ₕ S) (x ∷ xs) · x + eval n 0ₕ xs)
≡⟨ cong (λ u → eval (ℕ.suc n) (P ·ₕ S) (x ∷ xs) · x + u) (Eval0H _ xs) ⟩
(eval (ℕ.suc n) (P ·ₕ S) (x ∷ xs) · x + 0r)
≡⟨ +Rid _ ⟩
(eval (ℕ.suc n) (P ·ₕ S) (x ∷ xs) · x)
≡⟨ cong (λ u → u · x) (·Homeval (ℕ.suc n) P S (x ∷ xs)) ⟩
((eval (ℕ.suc n) P (x ∷ xs) · eval (ℕ.suc n) S (x ∷ xs)) · x)
≡⟨ sym (·Assoc _ _ _) ⟩
(eval (ℕ.suc n) P (x ∷ xs) · (eval (ℕ.suc n) S (x ∷ xs) · x))
≡⟨ cong (λ u → eval (ℕ.suc n) P (x ∷ xs) · u) (·-comm _ _) ⟩
(eval (ℕ.suc n) P (x ∷ xs) · (x · eval (ℕ.suc n) S (x ∷ xs)))
≡⟨ ·Assoc _ _ _ ⟩
(eval (ℕ.suc n) P (x ∷ xs) · x) · eval (ℕ.suc n) S (x ∷ xs)
∎) ⟩
(eval (ℕ.suc n) P (x ∷ xs) · x) · eval (ℕ.suc n) S (x ∷ xs)
+ eval (ℕ.suc n) (Q ⋆ S) (x ∷ xs)
≡⟨ cong (λ u → (eval (ℕ.suc n) P (x ∷ xs) · x) · eval (ℕ.suc n) S (x ∷ xs) + u)
(⋆Homeval n Q S x xs) ⟩
(eval (ℕ.suc n) P (x ∷ xs) · x) · eval (ℕ.suc n) S (x ∷ xs)
+ eval n Q xs · eval (ℕ.suc n) S (x ∷ xs)
≡⟨ sym (·Ldist+ _ _ _) ⟩
((eval (ℕ.suc n) P (x ∷ xs) · x) + eval n Q xs) · eval (ℕ.suc n) S (x ∷ xs)
≡⟨ cong (λ u → u · eval (ℕ.suc n) S (x ∷ xs)) (sym (combineCasesEval P Q x xs)) ⟩
eval (ℕ.suc n) (P ·X+ Q) (x ∷ xs) · eval (ℕ.suc n) S (x ∷ xs) ∎
| {
"alphanum_fraction": 0.4326977803,
"avg_line_length": 50.0213523132,
"ext": "agda",
"hexsha": "821cf9c745ca9d5b9a7d952264ae3b0f3e7b7bb2",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dan-iel-lee/cubical",
"max_forks_repo_path": "Cubical/Algebra/RingSolver/CommRingEvalHom.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "dan-iel-lee/cubical",
"max_issues_repo_path": "Cubical/Algebra/RingSolver/CommRingEvalHom.agda",
"max_line_length": 104,
"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/Algebra/RingSolver/CommRingEvalHom.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 6615,
"size": 14056
} |
module Structure.Operator.Algebra where
open import Lang.Instance
open import Logic.Predicate
import Lvl
open import Structure.Function.Domain
open import Structure.Operator.Field
open import Structure.Operator.Monoid
open import Structure.Operator.Properties
open import Structure.Operator.Ring
open import Structure.Operator.Ring.Homomorphism
open import Structure.Operator.Vector
open import Structure.Operator.Vector.LinearMap
open import Structure.Setoid
open import Type
module _
{ℓᵥ ℓₛ ℓᵥₑ ℓₛₑ}
{V : Type{ℓᵥ}} ⦃ _ : Equiv{ℓᵥₑ}(V) ⦄
{S : Type{ℓₛ}} ⦃ _ : Equiv{ℓₛₑ}(S) ⦄
(_+ᵥ_ : V → V → V)
(_⋅ᵥ_ : V → V → V)
(_⋅ₛᵥ_ : S → V → V)
(_+ₛ_ : S → S → S)
(_⋅ₛ_ : S → S → S)
where
record Algebra : Type{ℓₛₑ Lvl.⊔ ℓₛ Lvl.⊔ ℓᵥₑ Lvl.⊔ ℓᵥ} where
constructor intro
field
⦃ vectorSpace ⦄ : VectorSpace(_+ᵥ_)(_⋅ₛᵥ_)(_+ₛ_)(_⋅ₛ_)
⦃ [⋅ᵥ]-bilinearity ⦄ : BilinearOperator vectorSpace (_⋅ᵥ_)
open VectorSpace(vectorSpace)
renaming (ring to ringₛ)
public
ringᵥ : ⦃ Associativity(_⋅ᵥ_) ⦄ → ⦃ ∃(Identity(_⋅ᵥ_)) ⦄ → Ring(_+ᵥ_)(_⋅ᵥ_)
Rng.[+]-commutative-group (Ring.rng ringᵥ) = vectorCommutativeGroup
Rng.[⋅]-binary-operator (Ring.rng ringᵥ) = BilinearMap.binaryOperator [⋅ᵥ]-bilinearity
Rng.[⋅]-associativity (Ring.rng ringᵥ) = infer
Rng.[⋅][+]-distributivityₗ (Ring.rng ringᵥ) = BilinearOperator.[+ᵥ]-distributivityₗ vectorSpace (_⋅ᵥ_) [⋅ᵥ]-bilinearity
Rng.[⋅][+]-distributivityᵣ (Ring.rng ringᵥ) = BilinearOperator.[+ᵥ]-distributivityᵣ vectorSpace (_⋅ᵥ_) [⋅ᵥ]-bilinearity
Unity.[⋅]-identity-existence (Ring.unity ringᵥ) = infer
-- TODO: I found some conflicting definitions for a star algebra from different sources. What is a reasonable definition?
record ⋆-algebra (_⋆ᵥ : V → V) (_⋆ₛ : S → S) : Type{ℓₛₑ Lvl.⊔ ℓₛ Lvl.⊔ ℓᵥₑ Lvl.⊔ ℓᵥ} where
constructor intro
field
⦃ algebra ⦄ : Algebra
open Algebra(algebra) public
field
⦃ [⋅ᵥ]-commutativity ⦄ : Commutativity(_⋅ᵥ_)
⦃ [⋅ᵥ]-associativity ⦄ : Associativity(_⋅ᵥ_)
⦃ [⋅ᵥ]-identity ⦄ : ∃(Identity(_⋅ᵥ_))
⦃ [⋆ₛ]-involution ⦄ : Involution(_⋆ᵥ)
⦃ [⋆ᵥ]-involution ⦄ : Involution(_⋆ᵥ)
[⋆ᵥ]-distribute-over-[⋅ₛᵥ]-to-[⋆ₛ] : ∀{s}{v} → ((s ⋅ₛᵥ v)⋆ᵥ ≡ (s ⋆ₛ) ⋅ₛᵥ (v ⋆ᵥ))
⦃ [⋆ₛ]-antihomomorphism ⦄ : Antihomomorphism ringₛ ringₛ (_⋆ₛ)
⦃ [⋆ᵥ]-antihomomorphism ⦄ : Antihomomorphism ringᵥ ringᵥ (_⋆ᵥ)
| {
"alphanum_fraction": 0.6221602232,
"avg_line_length": 41.131147541,
"ext": "agda",
"hexsha": "c4fa0a01c9fbbaf680104bbea367fc0b5db7b2dc",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Structure/Operator/Algebra.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Structure/Operator/Algebra.agda",
"max_line_length": 127,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Structure/Operator/Algebra.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": 1154,
"size": 2509
} |
module STLC.Kovacs.Normalisation where
open import STLC.Kovacs.NormalForm public
--------------------------------------------------------------------------------
-- (Tyᴺ)
infix 3 _⊩_
_⊩_ : 𝒞 → 𝒯 → Set
Γ ⊩ ⎵ = Γ ⊢ⁿᶠ ⎵
Γ ⊩ A ⇒ B = ∀ {Γ′} → (η : Γ′ ⊇ Γ) (a : Γ′ ⊩ A)
→ Γ′ ⊩ B
-- (Conᴺ ; ∙ ; _,_)
infix 3 _⊩⋆_
data _⊩⋆_ : 𝒞 → 𝒞 → Set
where
∅ : ∀ {Γ} → Γ ⊩⋆ ∅
_,_ : ∀ {Γ Ξ A} → (ρ : Γ ⊩⋆ Ξ) (a : Γ ⊩ A)
→ Γ ⊩⋆ Ξ , A
--------------------------------------------------------------------------------
-- (Tyᴺₑ)
acc : ∀ {A Γ Γ′} → Γ′ ⊇ Γ → Γ ⊩ A → Γ′ ⊩ A
acc {⎵} η M = renⁿᶠ η M
acc {A ⇒ B} η f = λ η′ a → f (η ○ η′) a
-- (Conᴺₑ)
-- NOTE: _⬖_ = acc⋆
_⬖_ : ∀ {Γ Γ′ Ξ} → Γ ⊩⋆ Ξ → Γ′ ⊇ Γ → Γ′ ⊩⋆ Ξ
∅ ⬖ η = ∅
(ρ , a) ⬖ η = ρ ⬖ η , acc η a
--------------------------------------------------------------------------------
-- (∈ᴺ)
getᵥ : ∀ {Γ Ξ A} → Γ ⊩⋆ Ξ → Ξ ∋ A → Γ ⊩ A
getᵥ (ρ , a) zero = a
getᵥ (ρ , a) (suc i) = getᵥ ρ i
-- (Tmᴺ)
eval : ∀ {Γ Ξ A} → Γ ⊩⋆ Ξ → Ξ ⊢ A → Γ ⊩ A
eval ρ (𝓋 i) = getᵥ ρ i
eval ρ (ƛ M) = λ η a → eval (ρ ⬖ η , a) M
eval ρ (M ∙ N) = eval ρ M idₑ (eval ρ N)
mutual
-- (qᴺ)
reify : ∀ {A Γ} → Γ ⊩ A → Γ ⊢ⁿᶠ A
reify {⎵} M = M
reify {A ⇒ B} f = ƛ (reify (f (wkₑ idₑ) (reflect 0)))
-- (uᴺ)
reflect : ∀ {A Γ} → Γ ⊢ⁿᵉ A → Γ ⊩ A
reflect {⎵} M = ne M
reflect {A ⇒ B} M = λ η a → reflect (renⁿᵉ η M ∙ reify a)
-- (uᶜᴺ)
idᵥ : ∀ {Γ} → Γ ⊩⋆ Γ
idᵥ {∅} = ∅
idᵥ {Γ , A} = idᵥ ⬖ wkₑ idₑ , reflect 0
-- (nf)
nf : ∀ {Γ A} → Γ ⊢ A → Γ ⊢ⁿᶠ A
nf M = reify (eval idᵥ M)
--------------------------------------------------------------------------------
| {
"alphanum_fraction": 0.3098086124,
"avg_line_length": 20.3902439024,
"ext": "agda",
"hexsha": "bb2e0446bd7f9996657b07db63d61d2078d82cfc",
"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": "bd626509948fbf8503ec2e31c1852e1ac6edcc79",
"max_forks_repo_licenses": [
"X11"
],
"max_forks_repo_name": "mietek/coquand-kovacs",
"max_forks_repo_path": "src/STLC/Kovacs/Normalisation.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "bd626509948fbf8503ec2e31c1852e1ac6edcc79",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"X11"
],
"max_issues_repo_name": "mietek/coquand-kovacs",
"max_issues_repo_path": "src/STLC/Kovacs/Normalisation.agda",
"max_line_length": 80,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "bd626509948fbf8503ec2e31c1852e1ac6edcc79",
"max_stars_repo_licenses": [
"X11"
],
"max_stars_repo_name": "mietek/coquand-kovacs",
"max_stars_repo_path": "src/STLC/Kovacs/Normalisation.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 875,
"size": 1672
} |
open import Oscar.Prelude
open import Oscar.Data.Decidable
open import Oscar.Data.Proposequality
module Oscar.Class.IsDecidable where
record IsDecidable {𝔬} (𝔒 : Ø 𝔬) : Ø 𝔬 where
infix 4 _≟_
field
_≟_ : (x y : 𝔒) → Decidable (x ≡ y)
open IsDecidable ⦃ … ⦄ public
| {
"alphanum_fraction": 0.7018181818,
"avg_line_length": 19.6428571429,
"ext": "agda",
"hexsha": "16694fb172c2f18c7bb4725d9501dfc3c1362df4",
"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/IsDecidable.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/IsDecidable.agda",
"max_line_length": 44,
"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/IsDecidable.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 103,
"size": 275
} |
module Syntax where
{-
open import Data.Nat hiding (_>_)
open import Data.Fin
open import Data.Product
open import Data.Bool
open import Relation.Binary.PropositionalEquality
-}
open import StdLibStuff
erase-subst :
(X : Set) → (Y : X → Set) →
(F : {x : X} → Y x) →
(x₁ x₂ : X) →
(eq : x₁ ≡ x₂) →
(P : Y x₂ → Set) →
P F →
P (subst Y eq F)
erase-subst X Y F .x₂ x₂ refl P h = h
-- type, ctx
data Type (n : ℕ) : Set where
$o : Type n
$i : Fin n → Type n
_>_ : Type n → Type n → Type n
data Ctx (n : ℕ) : Set where
ε : Ctx n
_∷_ : Type n → Ctx n → Ctx n
data Var : {n : ℕ} → Ctx n → Set where
this : ∀ {n t} → {Γ : Ctx n} → Var (t ∷ Γ)
next : ∀ {n t} → {Γ : Ctx n} → Var Γ → Var (t ∷ Γ)
lookup-Var : ∀ {n} → (Γ : Ctx n) → Var Γ → Type n
lookup-Var ε ()
lookup-Var (t ∷ _) this = t
lookup-Var (_ ∷ Γ) (next x) = lookup-Var Γ x
_++_ : ∀ {n} → Ctx n → Ctx n → Ctx n
ε ++ Γ = Γ
(t ∷ Γ₁) ++ Γ₂ = t ∷ (Γ₁ ++ Γ₂)
_r++_ : ∀ {n} → Ctx n → Ctx n → Ctx n
ε r++ Γ = Γ
(t ∷ Γ₁) r++ Γ₂ = Γ₁ r++ (t ∷ Γ₂)
-- stt formula
data Form : {n : ℕ} → Ctx n → Type n → Set where
var : ∀ {n} → {Γ : Ctx n} {t : Type n} → (x : Var Γ) → lookup-Var Γ x ≡ t → Form Γ t
N : ∀ {n} → {Γ : Ctx n} → Form Γ ($o > $o)
A : ∀ {n} → {Γ : Ctx n} → Form Γ ($o > ($o > $o))
Π : ∀ {n α} → {Γ : Ctx n} → Form Γ ((α > $o) > $o)
i : ∀ {n α} → {Γ : Ctx n} → Form Γ ((α > $o) > α)
app : ∀ {n α β} → {Γ : Ctx n} → Form Γ (α > β) → Form Γ α → Form Γ β
lam : ∀ {n β} → {Γ : Ctx n} → (α : _) → Form (α ∷ Γ) β → Form Γ (α > β)
-- abbreviations (TPTP-like notation)
~ : ∀ {n} → {Γ : Ctx n} → Form Γ $o → Form Γ $o
~ F = app N F
_||_ : ∀ {n} → {Γ : Ctx n} → Form Γ $o → Form Γ $o → Form Γ $o
F || G = app (app A F) G
_&_ : ∀ {n} → {Γ : Ctx n} → Form Γ $o → Form Γ $o → Form Γ $o
F & G = ~ ((~ F) || (~ G))
_=>_ : ∀ {n} → {Γ : Ctx n} → Form Γ $o → Form Γ $o → Form Γ $o
F => G = (~ F) || G
![_]_ : ∀ {n} → {Γ : Ctx n} → (α : Type n) → Form (α ∷ Γ) $o → Form Γ $o
![ α ] F = app Π (lam α F)
?[_]_ : ∀ {n} → {Γ : Ctx n} → (α : Type n) → Form (α ∷ Γ) $o → Form Γ $o
?[ α ] F = ~ (![ α ] ~ F)
ι : ∀ {n} → {Γ : Ctx n} → (α : Type n) → Form (α ∷ Γ) $o → Form Γ α
ι α F = app i (lam α F)
Q : ∀ {n} → {Γ : Ctx n} → (α : Type n) → Form Γ (α > (α > $o))
Q α = lam α (lam α (![ α > $o ] (app (var this refl) (var (next (next this)) refl) => app (var this refl) (var (next this) refl))))
_==_ : ∀ {n} → {Γ : Ctx n} → {α : Type n} → Form Γ α → Form Γ α → Form Γ $o
F == G = app (app (Q _) F) G
_<=>_ : ∀ {n} → {Γ : Ctx n} → Form Γ $o → Form Γ $o → Form Γ $o
F <=> G = (F => G) & (G => F)
$true : ∀ {n} → {Γ : Ctx n} → Form Γ $o
$true = ![ $o ] (var this refl => var this refl)
$false : ∀ {n} → {Γ : Ctx n} → Form Γ $o
$false = ![ $o ] var this refl
^[_]_ : ∀ {n Γ t₂} → (t₁ : Type n) → Form (t₁ ∷ Γ) t₂ → Form Γ (t₁ > t₂)
^[ tp ] t = lam tp t
_·_ : ∀ {n} → {Γ : Ctx n} → ∀ {t₁ t₂} → Form Γ (t₁ > t₂) → Form Γ t₁ → Form Γ t₂
t₁ · t₂ = app t₁ t₂
$ : ∀ {n Γ} → {t : Type n} (v : Var Γ) → {eq : lookup-Var Γ v ≡ t} → Form Γ t
$ v {p} = var v p
-- occurs in
eq-Var : ∀ {n} {Γ : Ctx n} → Var Γ → Var Γ → Bool
eq-Var this this = true
eq-Var this (next y) = false
eq-Var (next x) this = false
eq-Var (next x) (next y) = eq-Var x y
occurs : ∀ {n Γ} → {t : Type n} → Var Γ → Form Γ t → Bool
occurs x (var x' p) = eq-Var x x'
occurs x N = false
occurs x A = false
occurs x Π = false
occurs x i = false
occurs x (app f₁ f₂) = occurs x f₁ ∨ occurs x f₂
occurs x (lam α f) = occurs (next x) f
-- weakening and substitution
weak-var : ∀ {n} → {β : Type n} (Γ₁ Γ₂ : Ctx n) → (x : Var (Γ₁ ++ Γ₂)) → Var (Γ₁ ++ (β ∷ Γ₂))
weak-var ε Γ₂ x = next x
weak-var (t ∷ Γ₁) Γ₂ this = this
weak-var (t ∷ Γ₁) Γ₂ (next x) = next (weak-var Γ₁ Γ₂ x)
weak-var-p : ∀ {n} → {β : Type n} (Γ₁ Γ₂ : Ctx n) → (x : Var (Γ₁ ++ Γ₂)) →
lookup-Var (Γ₁ ++ (β ∷ Γ₂)) (weak-var Γ₁ Γ₂ x) ≡ lookup-Var (Γ₁ ++ Γ₂) x
weak-var-p ε Γ₂ x = refl
weak-var-p (t ∷ Γ₁) Γ₂ this = refl
weak-var-p (t ∷ Γ₁) Γ₂ (next x) = weak-var-p Γ₁ Γ₂ x
weak-i : ∀ {n} → {α β : Type n} (Γ₁ Γ₂ : Ctx n) → Form (Γ₁ ++ Γ₂) α → Form (Γ₁ ++ (β ∷ Γ₂)) α
weak-i Γ₁ Γ₂ (var x p) = var (weak-var Γ₁ Γ₂ x) (trans (weak-var-p Γ₁ Γ₂ x) p)
weak-i Γ₁ Γ₂ N = N
weak-i Γ₁ Γ₂ A = A
weak-i Γ₁ Γ₂ Π = Π
weak-i Γ₁ Γ₂ i = i
weak-i Γ₁ Γ₂ (app f₁ f₂) = app (weak-i Γ₁ Γ₂ f₁) (weak-i Γ₁ Γ₂ f₂)
weak-i Γ₁ Γ₂ (lam α f) = lam α (weak-i (α ∷ Γ₁) Γ₂ f)
weak : ∀ {n} → {Γ : Ctx n} {α β : Type n} → Form Γ α → Form (β ∷ Γ) α
weak {_} {Γ} = weak-i ε Γ
sub-var : ∀ {n} → {α β : Type n} (Γ₁ Γ₂ : Ctx n) → Form Γ₂ α → (x : Var (Γ₁ ++ (α ∷ Γ₂))) → lookup-Var (Γ₁ ++ (α ∷ Γ₂)) x ≡ β → Form (Γ₁ ++ Γ₂) β
sub-var ε Γ₂ g this p = subst (Form Γ₂) p g
sub-var ε Γ₂ g (next x) p = var x p
sub-var (t ∷ Γ₁) Γ₂ g this p = var this p
sub-var (t ∷ Γ₁) Γ₂ g (next x) p = weak (sub-var Γ₁ Γ₂ g x p)
sub-i : ∀ {n} → {α β : Type n} (Γ₁ Γ₂ : Ctx n) → Form Γ₂ α → Form (Γ₁ ++ (α ∷ Γ₂)) β → Form (Γ₁ ++ Γ₂) β
sub-i Γ₁ Γ₂ g (var x p) = sub-var Γ₁ Γ₂ g x p
sub-i Γ₁ Γ₂ g N = N
sub-i Γ₁ Γ₂ g A = A
sub-i Γ₁ Γ₂ g Π = Π
sub-i Γ₁ Γ₂ g i = i
sub-i Γ₁ Γ₂ g (app f₁ f₂) = app (sub-i Γ₁ Γ₂ g f₁) (sub-i Γ₁ Γ₂ g f₂)
sub-i Γ₁ Γ₂ g (lam α f) = lam α (sub-i (α ∷ Γ₁) Γ₂ g f)
sub : ∀ {n} → {Γ : Ctx n} {α β : Type n} → Form Γ α → Form (α ∷ Γ) β → Form Γ β
sub {_} {Γ} = sub-i ε Γ
-- properties about weak and sub
sub-weak-var-p-23-this-2 : ∀ {n} → {u v β : Type n} {Γ : Ctx n} (Γ' : Ctx n) (G : Form (v ∷ Γ) u) →
(Γ'' : Ctx n)
(h₁ : β ∷ Γ'' ≡ β ∷ (Γ' ++ (u ∷ (v ∷ Γ))))
(p'' : lookup-Var ((β ∷ Γ') ++ (u ∷ (v ∷ Γ))) (subst Var h₁ this) ≡ lookup-Var (β ∷ (Γ' ++ (v ∷ Γ))) this) →
var this refl ≡ sub-var (β ∷ Γ') (v ∷ Γ) G (subst Var h₁ this) p''
sub-weak-var-p-23-this-2 {n} {u} {v} {β} {Γ} Γ' G .(Γ' ++ (u ∷ (v ∷ Γ))) refl refl = refl
sub-weak-var-p-23-this-1 : ∀ {n} → {u v β : Type n} {Γ : Ctx n} (Γ' : Ctx n) (G : Form (v ∷ Γ) u) →
(h₁ : β ∷ ((Γ' ++ (u ∷ ε)) ++ (v ∷ Γ)) ≡ β ∷ (Γ' ++ (u ∷ (v ∷ Γ))))
(Γ'' : Ctx n)
(h₂ : β ∷ Γ'' ≡ β ∷ ((Γ' ++ (u ∷ ε)) ++ Γ))
(p'' : lookup-Var (β ∷ (Γ' ++ (u ∷ (v ∷ Γ)))) (subst Var h₁ (weak-var (β ∷ (Γ' ++ (u ∷ ε))) Γ (subst Var h₂ this))) ≡ β) →
var this refl ≡
sub-var (β ∷ Γ') (v ∷ Γ) G (subst Var h₁ (weak-var (β ∷ (Γ' ++ (u ∷ ε))) Γ (subst Var h₂ this))) p''
sub-weak-var-p-23-this-1 {n} {u} {v} {β} {Γ} Γ' G h₁ .((Γ' ++ (u ∷ ε)) ++ Γ) refl p'' = sub-weak-var-p-23-this-2 Γ' G ((Γ' ++ (u ∷ ε)) ++ (v ∷ Γ)) h₁ p''
mutual
sub-weak-var-p-23-next-2 : ∀ {n} → {u v β t : Type n} {Γ : Ctx n} (Γ' : Ctx n) (x : Var (Γ' ++ Γ)) (G : Form (v ∷ Γ) u) →
(p : lookup-Var (Γ' ++ (v ∷ Γ)) (weak-var Γ' Γ x) ≡ β)
(Γ'' : Ctx n)
(h₁₁ : t ∷ Γ'' ≡ t ∷ (Γ' ++ (u ∷ (v ∷ Γ))))
(h₁₂ : (Γ' ++ (u ∷ ε)) ++ (v ∷ Γ) ≡ Γ'')
(h₂ : Γ' ++ (u ∷ Γ) ≡ (Γ' ++ (u ∷ ε)) ++ Γ)
(p'' : lookup-Var ((t ∷ Γ') ++ (u ∷ (v ∷ Γ))) (subst Var h₁₁ (next (subst Var h₁₂ (weak-var (Γ' ++ (u ∷ ε)) Γ (subst Var h₂ (weak-var Γ' Γ x)))))) ≡ β) →
var (next (weak-var Γ' Γ x)) p ≡
sub-var (t ∷ Γ') (v ∷ Γ) G (subst Var h₁₁ (next (subst Var h₁₂ (weak-var (Γ' ++ (u ∷ ε)) Γ (subst Var h₂ (weak-var Γ' Γ x)))))) p''
sub-weak-var-p-23-next-2 {n} {u} {v} {β} {t} {Γ} Γ' x G p .(Γ' ++ (u ∷ (v ∷ Γ))) refl h₁₂ h₂ p'' = subst (λ z → var (next {_} {t} (weak-var Γ' Γ x)) p ≡ weak-i ε (Γ' ++ (v ∷ Γ)) z) {-{var (weak-var Γ' Γ x) p} {sub-var Γ' (v ∷ Γ) G (subst Var h₁₂ (weak-var (Γ' ++ (u ∷ ε)) Γ (subst Var h₂ (weak-var Γ' Γ x)))) p''}-} (sub-weak-var-p-23 {n} {u} {v} {β} {Γ} Γ' x G p h₁₂ h₂ p'') refl
sub-weak-var-p-23-next-1 : ∀ {n} → {u v β t : Type n} {Γ : Ctx n} (Γ' : Ctx n) (x : Var (Γ' ++ Γ)) (G : Form (v ∷ Γ) u) →
(p : lookup-Var (Γ' ++ (v ∷ Γ)) (weak-var Γ' Γ x) ≡ β)
(h₁ : t ∷ ((Γ' ++ (u ∷ ε)) ++ (v ∷ Γ)) ≡ t ∷ (Γ' ++ (u ∷ (v ∷ Γ))))
(Γ'' : Ctx n)
(h₂₁ : t ∷ Γ'' ≡ t ∷ ((Γ' ++ (u ∷ ε)) ++ Γ))
(h₂₂ : Γ' ++ (u ∷ Γ) ≡ Γ'')
(p'' : lookup-Var ((t ∷ Γ') ++ (u ∷ (v ∷ Γ))) (subst Var h₁ (weak-var (t ∷ (Γ' ++ (u ∷ ε))) Γ (subst Var h₂₁ (next (subst Var h₂₂ (weak-var Γ' Γ x)))))) ≡ β) →
var (next (weak-var Γ' Γ x)) p ≡
sub-var (t ∷ Γ') (v ∷ Γ) G (subst Var h₁ (weak-var (t ∷ (Γ' ++ (u ∷ ε))) Γ (subst Var h₂₁ (next (subst Var h₂₂ (weak-var Γ' Γ x)))))) p''
sub-weak-var-p-23-next-1 {n} {u} {v} {β} {t} {Γ} Γ' x G p h₁ .((Γ' ++ (u ∷ ε)) ++ Γ) refl h₂₂ p'' = sub-weak-var-p-23-next-2 Γ' x G p ((Γ' ++ (u ∷ ε)) ++ (v ∷ Γ)) h₁ refl h₂₂ p''
sub-weak-var-p-23 : ∀ {n} → {u v β : Type n} {Γ : Ctx n} (Γ' : Ctx n) (x : Var (Γ' ++ Γ)) (G : Form (v ∷ Γ) u) →
(p : lookup-Var (Γ' ++ (v ∷ Γ)) (weak-var Γ' Γ x) ≡ β) →
(h₁ : (Γ' ++ (u ∷ ε)) ++ (v ∷ Γ) ≡ Γ' ++ (u ∷ (v ∷ Γ))) →
(h₂ : Γ' ++ (u ∷ Γ) ≡ (Γ' ++ (u ∷ ε)) ++ Γ) →
(p'' : lookup-Var (Γ' ++ (u ∷ (v ∷ Γ))) (subst Var h₁ (weak-var (Γ' ++ (u ∷ ε)) Γ (subst Var h₂ (weak-var Γ' Γ x)))) ≡ β) →
var (weak-var Γ' Γ x) p ≡
sub-var Γ' (v ∷ Γ) G (subst Var h₁ (weak-var (Γ' ++ (u ∷ ε)) Γ (subst Var h₂ (weak-var Γ' Γ x)))) p''
sub-weak-var-p-23 ε x G refl refl refl refl = refl
sub-weak-var-p-23 {n} {u} {v} {β} {Γ} (.β ∷ Γ') this G refl h₁ h₂ p'' = sub-weak-var-p-23-this-1 Γ' G h₁ (Γ' ++ (u ∷ Γ)) h₂ p''
sub-weak-var-p-23 {n} {u} {v} {β} {Γ} (t ∷ Γ') (next x) G p h₁ h₂ p'' = sub-weak-var-p-23-next-1 Γ' x G p h₁ (Γ' ++ (u ∷ Γ)) h₂ refl p''
sub-weak-p-23-var-2 : ∀ {n} → {u v β : Type n} {Γ : Ctx n} (Γ' : Ctx n) (x : Var (Γ' ++ Γ)) (G : Form (v ∷ Γ) u) →
(p : lookup-Var (Γ' ++ Γ) x ≡ β) →
(Γ'' : Ctx n) →
(h₁₁ : Γ'' ≡ Γ' ++ (u ∷ (v ∷ Γ))) →
(h₁₂ : (Γ' ++ (u ∷ ε)) ++ (v ∷ Γ) ≡ Γ'') →
(h₂ : Γ' ++ (u ∷ Γ) ≡ (Γ' ++ (u ∷ ε)) ++ Γ) →
(p'' : lookup-Var Γ'' (subst Var h₁₂ (weak-var (Γ' ++ (u ∷ ε)) Γ (subst Var h₂ (weak-var Γ' Γ x)))) ≡ β) →
var (weak-var Γ' Γ x) (trans (weak-var-p Γ' Γ x) p) ≡
sub-i Γ' (v ∷ Γ) G (subst (λ z → Form z β) h₁₁ (var (subst Var h₁₂ (weak-var (Γ' ++ (u ∷ ε)) Γ (subst Var h₂ (weak-var Γ' Γ x)))) p''))
sub-weak-p-23-var-2 {n} {u} {v} {β} {Γ} Γ' x G p .(Γ' ++ (u ∷ (v ∷ Γ))) refl h₁₂ h₂ p'' = sub-weak-var-p-23 Γ' x G (trans (weak-var-p Γ' Γ x) p) h₁₂ h₂ p''
sub-weak-p-23-var-1 : ∀ {n} → {u v β : Type n} {Γ : Ctx n} (Γ' : Ctx n) (x : Var (Γ' ++ Γ)) (G : Form (v ∷ Γ) u) →
(p : lookup-Var (Γ' ++ Γ) x ≡ β) →
(h₁ : (Γ' ++ (u ∷ ε)) ++ (v ∷ Γ) ≡ Γ' ++ (u ∷ (v ∷ Γ))) →
(Γ'' : Ctx n) →
(h₂₁ : Γ'' ≡ (Γ' ++ (u ∷ ε)) ++ Γ) →
(h₂₂ : Γ' ++ (u ∷ Γ) ≡ Γ'') →
(p' : lookup-Var Γ'' (subst Var h₂₂ (weak-var Γ' Γ x)) ≡ β) →
var (weak-var Γ' Γ x) (trans (weak-var-p Γ' Γ x) p) ≡
sub-i Γ' (v ∷ Γ) G (subst (λ z → Form z β) h₁ (weak-i (Γ' ++ (u ∷ ε)) Γ (subst (λ z → Form z β) h₂₁ (var (subst Var h₂₂ (weak-var Γ' Γ x)) p'))))
sub-weak-p-23-var-1 {n} {u} {v} {β} {Γ} Γ' x G p h₁ .((Γ' ++ (u ∷ ε)) ++ Γ) refl h₂₂ p' = sub-weak-p-23-var-2 Γ' x G p ((Γ' ++ (u ∷ ε)) ++ (v ∷ Γ)) h₁ refl h₂₂ (trans (weak-var-p (Γ' ++ (u ∷ ε)) Γ (subst Var h₂₂ (weak-var Γ' Γ x))) p')
mutual
sub-weak-p-23-app-2 : ∀ {n} → {t u v w : Type n} {Γ : Ctx n} (Γ' : Ctx n) (f₁ : Form (Γ' ++ Γ) (w > t)) (f₂ : Form (Γ' ++ Γ) w) (G : Form (v ∷ Γ) u) →
(Γ'' : Ctx n) →
(h₁₁ : Γ'' ≡ Γ' ++ (u ∷ (v ∷ Γ))) →
(h₁₂ : (Γ' ++ (u ∷ ε)) ++ (v ∷ Γ) ≡ Γ'') →
(h₂ : Γ' ++ (u ∷ Γ) ≡ (Γ' ++ (u ∷ ε)) ++ Γ) →
app (weak-i Γ' Γ f₁) (weak-i Γ' Γ f₂) ≡
sub-i Γ' (v ∷ Γ) G (subst (λ z → Form z t) h₁₁ (app (subst (λ z → Form z (w > t)) h₁₂ (weak-i (Γ' ++ (u ∷ ε)) Γ (subst (λ z → Form z (w > t)) h₂ (weak-i Γ' Γ f₁)))) (subst (λ z → Form z w) h₁₂ (weak-i (Γ' ++ (u ∷ ε)) Γ (subst (λ z → Form z w) h₂ (weak-i Γ' Γ f₂))))))
sub-weak-p-23-app-2 {n} {t} {u} {v} {w} {Γ} Γ' f₁ f₂ G .(Γ' ++ (u ∷ (v ∷ Γ))) refl h₁₂ h₂ =
trans (cong (λ z → app z (weak-i Γ' Γ f₂)) (
sub-weak-p-23-i Γ' f₁ G h₁₂ h₂
))
(cong (λ z → app (sub-i Γ' (v ∷ Γ) G (subst (λ z → Form z (w > t)) h₁₂ (weak-i (Γ' ++ (u ∷ ε)) Γ (subst (λ z → Form z (w > t)) h₂ (weak-i Γ' Γ f₁))))) z) (
sub-weak-p-23-i Γ' f₂ G h₁₂ h₂
))
sub-weak-p-23-app-1 : ∀ {n} → {t u v w : Type n} {Γ : Ctx n} (Γ' : Ctx n) (f₁ : Form (Γ' ++ Γ) (w > t)) (f₂ : Form (Γ' ++ Γ) w) (G : Form (v ∷ Γ) u) →
(h₁ : (Γ' ++ (u ∷ ε)) ++ (v ∷ Γ) ≡ Γ' ++ (u ∷ (v ∷ Γ))) →
(Γ'' : Ctx n) →
(h₂₁ : Γ'' ≡ (Γ' ++ (u ∷ ε)) ++ Γ) →
(h₂₂ : Γ' ++ (u ∷ Γ) ≡ Γ'') →
app (weak-i Γ' Γ f₁) (weak-i Γ' Γ f₂) ≡
sub-i Γ' (v ∷ Γ) G (subst (λ z → Form z t) h₁ (weak-i (Γ' ++ (u ∷ ε)) Γ (subst (λ z → Form z t) h₂₁ (app (subst (λ z → Form z (w > t)) h₂₂ (weak-i Γ' Γ f₁)) (subst (λ z → Form z w) h₂₂ (weak-i Γ' Γ f₂))))))
sub-weak-p-23-app-1 {n} {t} {u} {v} {w} {Γ} Γ' f₁ f₂ G h₁ .((Γ' ++ (u ∷ ε)) ++ Γ) refl h₂₂ = sub-weak-p-23-app-2 Γ' f₁ f₂ G ((Γ' ++ (u ∷ ε)) ++ (v ∷ Γ)) h₁ refl h₂₂
sub-weak-p-23-lam-2 : ∀ {n} → {u v α β : Type n} {Γ : Ctx n} (Γ' : Ctx n) (f : Form ((α ∷ Γ') ++ Γ) β) (G : Form (v ∷ Γ) u) →
(Γ'' : Ctx n) →
(h₁₁ : Γ'' ≡ Γ' ++ (u ∷ (v ∷ Γ))) →
(h₁₂ : (Γ' ++ (u ∷ ε)) ++ (v ∷ Γ) ≡ Γ'') →
(h₂ : α ∷ (Γ' ++ (u ∷ Γ)) ≡ α ∷ ((Γ' ++ (u ∷ ε)) ++ Γ)) →
lam α (weak-i (α ∷ Γ') Γ f) ≡
sub-i Γ' (v ∷ Γ) G (subst (λ z → Form z (α > β)) h₁₁ (lam α (subst (λ z → Form z β) (cong (_∷_ α) h₁₂) (weak-i (α ∷ (Γ' ++ (u ∷ ε))) Γ (subst (λ z → Form z β) h₂ (weak-i (α ∷ Γ') Γ f))))))
sub-weak-p-23-lam-2 {n} {u} {v} {α} {β} {Γ} Γ' f G .(Γ' ++ (u ∷ (v ∷ Γ))) refl h₁₂ h₂ = cong (lam α) (
sub-weak-p-23-i (α ∷ Γ') f G (cong (_∷_ α) h₁₂) h₂)
sub-weak-p-23-lam-1 : ∀ {n} → {u v α β : Type n} {Γ : Ctx n} (Γ' : Ctx n) (f : Form ((α ∷ Γ') ++ Γ) β) (G : Form (v ∷ Γ) u) →
(h₁ : (Γ' ++ (u ∷ ε)) ++ (v ∷ Γ) ≡ Γ' ++ (u ∷ (v ∷ Γ))) →
(Γ'' : Ctx n) →
(h₂₁ : Γ'' ≡ (Γ' ++ (u ∷ ε)) ++ Γ) →
(h₂₂ : Γ' ++ (u ∷ Γ) ≡ Γ'') →
lam α (weak-i (α ∷ Γ') Γ f) ≡
sub-i Γ' (v ∷ Γ) G (subst (λ z → Form z (α > β)) h₁ (weak-i (Γ' ++ (u ∷ ε)) Γ (subst (λ z → Form z (α > β)) h₂₁ (lam α (subst (λ z → Form z β) (cong (λ z → α ∷ z) h₂₂) (weak-i (α ∷ Γ') Γ f))))))
sub-weak-p-23-lam-1 {n} {u} {v} {α} {β} {Γ} Γ' f G h₁ .((Γ' ++ (u ∷ ε)) ++ Γ) refl h₂₂ = sub-weak-p-23-lam-2 Γ' f G ((Γ' ++ (u ∷ ε)) ++ (v ∷ Γ)) h₁ refl (cong (_∷_ α) h₂₂)
sub-weak-p-23-i : ∀ {n} → {t u v : Type n} {Γ : Ctx n} (Γ' : Ctx n) (F : Form (Γ' ++ Γ) t) (G : Form (v ∷ Γ) u) →
(h₁ : (Γ' ++ (u ∷ ε)) ++ (v ∷ Γ) ≡ Γ' ++ (u ∷ (v ∷ Γ))) →
(h₂ : Γ' ++ (u ∷ Γ) ≡ (Γ' ++ (u ∷ ε)) ++ Γ) →
weak-i Γ' Γ F ≡ sub-i Γ' (v ∷ Γ) G (subst (λ z → Form z t) h₁ (weak-i (Γ' ++ (u ∷ ε)) Γ (subst (λ z → Form z t) h₂ (weak-i Γ' Γ F))))
-- sub-weak-p-23-i {_} {.(lookup-Var (Γ' ++ Γ) x)} {u} {v} {Γ} Γ' (var x) G h₁ h₂ = {!!}
sub-weak-p-23-i {_} {β} {u} {v} {Γ} Γ' (var x p) G h₁ h₂ = sub-weak-p-23-var-1 Γ' x G p h₁ (Γ' ++ (u ∷ Γ)) h₂ refl (trans (weak-var-p Γ' Γ x) p)
sub-weak-p-23-i {_} {.($o > $o)} {u} {v} {Γ} Γ' N G h₁ h₂ = erase-subst (Ctx _) (λ z → Form z ($o > $o)) N (Γ' ++ (u ∷ Γ)) ((Γ' ++ (u ∷ ε)) ++ Γ) h₂ (λ z → N ≡ sub-i Γ' (v ∷ Γ) G (subst (λ z → Form z ($o > $o)) h₁ (weak-i (Γ' ++ (u ∷ ε)) Γ z))) (erase-subst (Ctx _) (λ z → Form z ($o > $o)) N ((Γ' ++ (u ∷ ε)) ++ (v ∷ Γ)) (Γ' ++ (u ∷ (v ∷ Γ))) h₁ (λ z → N ≡ sub-i Γ' (v ∷ Γ) G z) refl) -- rewrite h₂ | h₁ = refl
sub-weak-p-23-i {_} {.($o > ($o > $o))} {u} {v} {Γ} Γ' A G h₁ h₂ = erase-subst (Ctx _) (λ z → Form z ($o > ($o > $o))) A (Γ' ++ (u ∷ Γ)) ((Γ' ++ (u ∷ ε)) ++ Γ) h₂ (λ z → A ≡ sub-i Γ' (v ∷ Γ) G (subst (λ z → Form z ($o > ($o > $o))) h₁ (weak-i (Γ' ++ (u ∷ ε)) Γ z))) (erase-subst (Ctx _) (λ z → Form z ($o > ($o > $o))) A ((Γ' ++ (u ∷ ε)) ++ (v ∷ Γ)) (Γ' ++ (u ∷ (v ∷ Γ))) h₁ (λ z → A ≡ sub-i Γ' (v ∷ Γ) G z) refl) -- rewrite h₂ | h₁ = refl
sub-weak-p-23-i {_} {((t > $o) > $o)} {u} {v} {Γ} Γ' Π G h₁ h₂ = erase-subst (Ctx _) (λ z → Form z ((t > $o) > $o)) Π (Γ' ++ (u ∷ Γ)) ((Γ' ++ (u ∷ ε)) ++ Γ) h₂ (λ z → Π ≡ sub-i Γ' (v ∷ Γ) G (subst (λ z → Form z ((t > $o) > $o)) h₁ (weak-i (Γ' ++ (u ∷ ε)) Γ z))) (erase-subst (Ctx _) (λ z → Form z ((t > $o) > $o)) Π ((Γ' ++ (u ∷ ε)) ++ (v ∷ Γ)) (Γ' ++ (u ∷ (v ∷ Γ))) h₁ (λ z → Π ≡ sub-i Γ' (v ∷ Γ) G z) refl) -- rewrite h₂ | h₁ = refl
sub-weak-p-23-i {_} {((t > $o) > .t)} {u} {v} {Γ} Γ' i G h₁ h₂ = erase-subst (Ctx _) (λ z → Form z ((t > $o) > t)) i (Γ' ++ (u ∷ Γ)) ((Γ' ++ (u ∷ ε)) ++ Γ) h₂ (λ z → i ≡ sub-i Γ' (v ∷ Γ) G (subst (λ z → Form z ((t > $o) > t)) h₁ (weak-i (Γ' ++ (u ∷ ε)) Γ z))) (erase-subst (Ctx _) (λ z → Form z ((t > $o) > t)) i ((Γ' ++ (u ∷ ε)) ++ (v ∷ Γ)) (Γ' ++ (u ∷ (v ∷ Γ))) h₁ (λ z → i ≡ sub-i Γ' (v ∷ Γ) G z) refl) -- rewrite h₂ | h₁ = refl
sub-weak-p-23-i {_} {t} {u} {v} {Γ} Γ' (app f₁ f₂) G h₁ h₂ = sub-weak-p-23-app-1 Γ' f₁ f₂ G h₁ (Γ' ++ (u ∷ Γ)) h₂ refl
sub-weak-p-23-i {_} {α > β} {u} {v} {Γ} Γ' (lam .α f) G h₁ h₂ = sub-weak-p-23-lam-1 Γ' f G h₁ (Γ' ++ (u ∷ Γ)) h₂ refl
sub-weak-var-p-1-this-2 : ∀ {n} → {u v β : Type n} {Γ : Ctx n} (Γ' : Ctx n) (G : Form Γ u) →
(Γ'' : Ctx n)
(h₁ : β ∷ Γ'' ≡ β ∷ (Γ' ++ (v ∷ Γ)))
(p' : β ≡ β) →
var this refl ≡
subst (λ z → Form z β) h₁ (var this p')
sub-weak-var-p-1-this-2 {n} {u} {v} {β} {Γ} Γ' G ._ refl refl = refl
sub-weak-var-p-1-this-1 : ∀ {n} → {u v β : Type n} {Γ : Ctx n} (Γ' : Ctx n) (G : Form Γ u) →
(h₁ : β ∷ ((Γ' ++ (v ∷ ε)) ++ Γ) ≡ β ∷ (Γ' ++ (v ∷ Γ)))
(Γ'' : Ctx n)
(h₂ : β ∷ Γ'' ≡ β ∷ ((Γ' ++ (v ∷ ε)) ++ (u ∷ Γ)))
(p' : lookup-Var ((β ∷ (Γ' ++ (v ∷ ε))) ++ (u ∷ Γ)) (subst Var h₂ this) ≡ β) →
var this refl ≡
subst (λ z → Form z β) h₁ (sub-var (β ∷ (Γ' ++ (v ∷ ε))) Γ G (subst Var h₂ this) p')
sub-weak-var-p-1-this-1 {n} {u} {v} {β} {Γ} Γ' G h₁ ._ refl p' = sub-weak-var-p-1-this-2 Γ' G _ h₁ p'
mutual
sub-weak-var-p-1-next-2 : ∀ {n} → {u v β t : Type n} {Γ : Ctx n} (Γ' : Ctx n) (x : Var (Γ' ++ Γ)) (G : Form Γ u) →
(p : lookup-Var (Γ' ++ (v ∷ Γ)) (weak-var Γ' Γ x) ≡ β)
(Γ'' : Ctx n)
(h₁₁ : t ∷ Γ'' ≡ t ∷ (Γ' ++ (v ∷ Γ)))
(h₁₂ : ((Γ' ++ (v ∷ ε)) ++ Γ) ≡ Γ'')
(h₂ : (Γ' ++ (v ∷ (u ∷ Γ))) ≡ ((Γ' ++ (v ∷ ε)) ++ (u ∷ Γ)))
(p' : lookup-Var ((Γ' ++ (v ∷ ε)) ++ (u ∷ Γ)) (subst Var h₂ (weak-var Γ' (u ∷ Γ) (weak-var Γ' Γ x))) ≡ β) →
var (next (weak-var Γ' Γ x)) p ≡
subst (λ z → Form z β) h₁₁ (weak-i ε Γ'' (subst (λ z → Form z β) h₁₂ (sub-var (Γ' ++ (v ∷ ε)) Γ G (subst Var h₂ (weak-var Γ' (u ∷ Γ) (weak-var Γ' Γ x))) p')))
sub-weak-var-p-1-next-2 {n} {u} {v} {β} {t} {Γ} Γ' x G p ._ refl h₁₂ h₂ p' =
subst (λ z → var (next {_} {t} (weak-var Γ' Γ x)) p ≡ weak-i ε (Γ' ++ (v ∷ Γ)) z)
(sub-weak-var-p-1 Γ' x G p h₁₂ h₂ p')
refl
sub-weak-var-p-1-next-1 : ∀ {n} → {u v β t : Type n} {Γ : Ctx n} (Γ' : Ctx n) (x : Var (Γ' ++ Γ)) (G : Form Γ u) →
(p : lookup-Var (Γ' ++ (v ∷ Γ)) (weak-var Γ' Γ x) ≡ β)
(h₁ : t ∷ ((Γ' ++ (v ∷ ε)) ++ Γ) ≡ t ∷ (Γ' ++ (v ∷ Γ)))
(Γ'' : Ctx n)
(h₂₁ : t ∷ Γ'' ≡ t ∷ ((Γ' ++ (v ∷ ε)) ++ (u ∷ Γ)))
(h₂₂ : (Γ' ++ (v ∷ (u ∷ Γ))) ≡ Γ'')
(p' : lookup-Var (t ∷ ((Γ' ++ (v ∷ ε)) ++ (u ∷ Γ))) (subst Var h₂₁ (next (subst Var h₂₂ (weak-var Γ' (u ∷ Γ) (weak-var Γ' Γ x))))) ≡ β) →
var (next (weak-var Γ' Γ x)) p ≡
subst (λ z → Form z β) h₁ (sub-var (t ∷ (Γ' ++ (v ∷ ε))) Γ G (subst Var h₂₁ (next (subst Var h₂₂ (weak-var Γ' (u ∷ Γ) (weak-var Γ' Γ x))))) p')
sub-weak-var-p-1-next-1 {n} {u} {v} {β} {t} {Γ} Γ' x G p h₁ ._ refl h₂₂ p' = sub-weak-var-p-1-next-2 Γ' x G p _ h₁ refl h₂₂ p'
sub-weak-var-p-1 : ∀ {n} → {u v β : Type n} {Γ : Ctx n} (Γ' : Ctx n) (x : Var (Γ' ++ Γ)) (G : Form Γ u) →
(p : lookup-Var (Γ' ++ (v ∷ Γ)) (weak-var Γ' Γ x) ≡ β) →
(h₁ : (Γ' ++ (v ∷ ε)) ++ Γ ≡ Γ' ++ (v ∷ Γ)) →
(h₂ : Γ' ++ (v ∷ (u ∷ Γ)) ≡ (Γ' ++ (v ∷ ε)) ++ (u ∷ Γ)) →
(p' : lookup-Var ((Γ' ++ (v ∷ ε)) ++ (u ∷ Γ)) (subst Var h₂ (weak-var Γ' (u ∷ Γ) (weak-var Γ' Γ x))) ≡ β) →
var (weak-var Γ' Γ x) p ≡
subst (λ z → Form z β) h₁ (sub-var (Γ' ++ (v ∷ ε)) Γ G (subst Var h₂ (weak-var Γ' (u ∷ Γ) (weak-var Γ' Γ x))) p')
sub-weak-var-p-1 ε x G refl refl refl refl = refl
sub-weak-var-p-1 {n} {u} {v} {β} {Γ} (.β ∷ Γ') this G refl h₁ h₂ p' = sub-weak-var-p-1-this-1 Γ' G h₁ _ h₂ p'
sub-weak-var-p-1 {n} {u} {v} {β} {Γ} (t ∷ Γ') (next x) G p h₁ h₂ p' = sub-weak-var-p-1-next-1 Γ' x G p h₁ _ h₂ refl p'
sub-weak-p-1-var : ∀ {n} → {u v β : Type n} {Γ : Ctx n} (Γ' : Ctx n) (x : Var (Γ' ++ Γ)) (G : Form Γ u) →
(p : lookup-Var (Γ' ++ Γ) x ≡ β)
(h₁ : (Γ' ++ (v ∷ ε)) ++ Γ ≡ Γ' ++ (v ∷ Γ))
(Γ'' : Ctx n)
(h₂₁ : Γ'' ≡ (Γ' ++ (v ∷ ε)) ++ (u ∷ Γ))
(h₂₂ : Γ' ++ (v ∷ (u ∷ Γ)) ≡ Γ'')
(p' : lookup-Var Γ'' (subst Var h₂₂ (weak-var Γ' (u ∷ Γ) (weak-var Γ' Γ x))) ≡ β) →
var (weak-var Γ' Γ x) (trans (weak-var-p Γ' Γ x) p) ≡
subst (λ z → Form z β) h₁ (sub-i (Γ' ++ (v ∷ ε)) Γ G (subst (λ z → Form z β) h₂₁ (var (subst Var h₂₂ (weak-var Γ' (u ∷ Γ) (weak-var Γ' Γ x))) p')))
sub-weak-p-1-var {n} {u} {v} {β} {Γ} Γ' x G p h₁ ._ refl h₂₂ p' = sub-weak-var-p-1 Γ' x G (trans (weak-var-p Γ' Γ x) p) h₁ h₂₂ p'
mutual
sub-weak-p-1-app-2 : ∀ {n} → {t u v w : Type n} {Γ : Ctx n} (Γ' : Ctx n) (f₁ : Form (Γ' ++ Γ) (w > t)) (f₂ : Form (Γ' ++ Γ) w) (G : Form Γ u) →
(Γ'' : Ctx n) →
(h₁₁ : Γ'' ≡ Γ' ++ (v ∷ Γ)) →
(h₁₂ : (Γ' ++ (v ∷ ε)) ++ Γ ≡ Γ'') →
(h₂ : Γ' ++ (v ∷ (u ∷ Γ)) ≡ (Γ' ++ (v ∷ ε)) ++ (u ∷ Γ)) →
app (weak-i Γ' Γ f₁) (weak-i Γ' Γ f₂) ≡
subst (λ z → Form z t) h₁₁ (app (subst (λ z → Form z (w > t)) h₁₂ (sub-i (Γ' ++ (v ∷ ε)) Γ G (subst (λ z → Form z (w > t)) h₂ (weak-i Γ' (u ∷ Γ) (weak-i Γ' Γ f₁))))) (subst (λ z → Form z w) h₁₂ (sub-i (Γ' ++ (v ∷ ε)) Γ G (subst (λ z → Form z w) h₂ (weak-i Γ' (u ∷ Γ) (weak-i Γ' Γ f₂))))))
sub-weak-p-1-app-2 {n} {t} {u} {v} {w} {Γ} Γ' f₁ f₂ G .(Γ' ++ (v ∷ Γ)) refl h₁₂ h₂ =
trans (cong (λ z → app z (weak-i Γ' Γ f₂)) (
sub-weak-p-1-i Γ' f₁ G h₁₂ h₂
))
(cong (λ z → app (subst (λ z → Form z (w > t)) h₁₂ (sub-i (Γ' ++ (v ∷ ε)) Γ G (subst (λ z → Form z (w > t)) h₂ (weak-i Γ' (u ∷ Γ) (weak-i Γ' Γ f₁))))) z) (
sub-weak-p-1-i Γ' f₂ G h₁₂ h₂
))
sub-weak-p-1-app-1 : ∀ {n} → {t u v w : Type n} {Γ : Ctx n} (Γ' : Ctx n) (f₁ : Form (Γ' ++ Γ) (w > t)) (f₂ : Form (Γ' ++ Γ) w) (G : Form Γ u) →
(h₁ : (Γ' ++ (v ∷ ε)) ++ Γ ≡ Γ' ++ (v ∷ Γ)) →
(Γ'' : Ctx n) →
(h₂₁ : Γ'' ≡ (Γ' ++ (v ∷ ε)) ++ (u ∷ Γ)) →
(h₂₂ : Γ' ++ (v ∷ (u ∷ Γ)) ≡ Γ'') →
app (weak-i Γ' Γ f₁) (weak-i Γ' Γ f₂) ≡
subst (λ z → Form z t) h₁ (sub-i (Γ' ++ (v ∷ ε)) Γ G (subst (λ z → Form z t) h₂₁ (app (subst (λ z → Form z (w > t)) h₂₂ (weak-i Γ' (u ∷ Γ) (weak-i Γ' Γ f₁))) (subst (λ z → Form z w) h₂₂ (weak-i Γ' (u ∷ Γ) (weak-i Γ' Γ f₂))))))
sub-weak-p-1-app-1 {n} {t} {u} {v} {w} {Γ} Γ' f₁ f₂ G h₁ .((Γ' ++ (v ∷ ε)) ++ (u ∷ Γ)) refl h₂₂ = sub-weak-p-1-app-2 Γ' f₁ f₂ G ((Γ' ++ (v ∷ ε)) ++ Γ) h₁ refl h₂₂
sub-weak-p-1-lam-2 : ∀ {n} → {u v α β : Type n} {Γ : Ctx n} (Γ' : Ctx n) (f : Form ((α ∷ Γ') ++ Γ) β) (G : Form Γ u) →
(Γ'' : Ctx n) →
(h₁₁ : Γ'' ≡ Γ' ++ (v ∷ Γ)) →
(h₁₂ : (Γ' ++ (v ∷ ε)) ++ Γ ≡ Γ'') →
(h₂ : Γ' ++ (v ∷ (u ∷ Γ)) ≡ (Γ' ++ (v ∷ ε)) ++ (u ∷ Γ)) →
lam α (weak-i (α ∷ Γ') Γ f) ≡
subst (λ z → Form z (α > β)) h₁₁ (lam α (subst (λ z → Form z β) (cong (_∷_ α) h₁₂) (sub-i (α ∷ (Γ' ++ (v ∷ ε))) Γ G (subst (λ z → Form z β) (cong (_∷_ α) h₂) (weak-i (α ∷ Γ') (u ∷ Γ) (weak-i (α ∷ Γ') Γ f))))))
sub-weak-p-1-lam-2 {n} {u} {v} {α} {β} {Γ} Γ' f G .(Γ' ++ (v ∷ Γ)) refl h₁₂ h₂ = cong (lam α) (
sub-weak-p-1-i (α ∷ Γ') f G (cong (_∷_ α) h₁₂) (cong (_∷_ α) h₂))
sub-weak-p-1-lam-1 : ∀ {n} → {u v α β : Type n} {Γ : Ctx n} (Γ' : Ctx n) (f : Form ((α ∷ Γ') ++ Γ) β) (G : Form Γ u) →
(h₁ : (Γ' ++ (v ∷ ε)) ++ Γ ≡ Γ' ++ (v ∷ Γ)) →
(Γ'' : Ctx n) →
(h₂₁ : Γ'' ≡ (Γ' ++ (v ∷ ε)) ++ (u ∷ Γ)) →
(h₂₂ : Γ' ++ (v ∷ (u ∷ Γ)) ≡ Γ'') →
lam α (weak-i (α ∷ Γ') Γ f) ≡
subst (λ z → Form z (α > β)) h₁ (sub-i (Γ' ++ (v ∷ ε)) Γ G (subst (λ z → Form z (α > β)) h₂₁ (lam α (subst (λ z → Form z β) (cong (λ z → α ∷ z) h₂₂) (weak-i (α ∷ Γ') (u ∷ Γ) (weak-i (α ∷ Γ') Γ f))))))
sub-weak-p-1-lam-1 {n} {u} {v} {α} {β} {Γ} Γ' f G h₁ .((Γ' ++ (v ∷ ε)) ++ (u ∷ Γ)) refl h₂₂ = sub-weak-p-1-lam-2 Γ' f G ((Γ' ++ (v ∷ ε)) ++ Γ) h₁ refl h₂₂
sub-weak-p-1-i : ∀ {n} → {t u v : Type n} {Γ : Ctx n} (Γ' : Ctx n) (F : Form (Γ' ++ Γ) t) (G : Form Γ u) →
(h₁ : (Γ' ++ (v ∷ ε)) ++ Γ ≡ Γ' ++ (v ∷ Γ)) →
(h₂ : Γ' ++ (v ∷ (u ∷ Γ)) ≡ (Γ' ++ (v ∷ ε)) ++ (u ∷ Γ)) →
weak-i Γ' Γ F ≡ subst (λ z → Form z t) h₁ (sub-i (Γ' ++ (v ∷ ε)) Γ G (subst (λ z → Form z t) h₂ (weak-i Γ' (u ∷ Γ) (weak-i Γ' Γ F))))
sub-weak-p-1-i {_} {β} {u} {v} {Γ} Γ' (var x p) G h₁ h₂ = sub-weak-p-1-var Γ' x G p h₁ _ h₂ refl (trans (weak-var-p Γ' (u ∷ Γ) (weak-var Γ' Γ x)) (trans (weak-var-p Γ' Γ x) p))
sub-weak-p-1-i {_} {$o > $o} {u} {v} {Γ} Γ' N G h₁ h₂ = erase-subst (Ctx _) (λ z → Form z ($o > $o)) N (Γ' ++ (v ∷ (u ∷ Γ))) ((Γ' ++ (v ∷ ε)) ++ (u ∷ Γ)) h₂ (λ z → N ≡ subst (λ z → Form z ($o > $o)) h₁ (sub-i (Γ' ++ (v ∷ ε)) Γ G z)) (erase-subst (Ctx _) (λ z → Form z ($o > $o)) N ((Γ' ++ (v ∷ ε)) ++ Γ) (Γ' ++ (v ∷ Γ)) h₁ (λ z → N ≡ z) refl) -- rewrite h₂ | h₁ = refl
sub-weak-p-1-i {_} {$o > ($o > $o)} {u} {v} {Γ} Γ' A G h₁ h₂ = erase-subst (Ctx _) (λ z → Form z ($o > ($o > $o))) A (Γ' ++ (v ∷ (u ∷ Γ))) ((Γ' ++ (v ∷ ε)) ++ (u ∷ Γ)) h₂ (λ z → A ≡ subst (λ z → Form z ($o > ($o > $o))) h₁ (sub-i (Γ' ++ (v ∷ ε)) Γ G z)) (erase-subst (Ctx _) (λ z → Form z ($o > ($o > $o))) A ((Γ' ++ (v ∷ ε)) ++ Γ) (Γ' ++ (v ∷ Γ)) h₁ (λ z → A ≡ z) refl) -- rewrite h₂ | h₁ = refl
sub-weak-p-1-i {_} {(t > $o) > $o} {u} {v} {Γ} Γ' Π G h₁ h₂ = erase-subst (Ctx _) (λ z → Form z ((t > $o) > $o)) Π (Γ' ++ (v ∷ (u ∷ Γ))) ((Γ' ++ (v ∷ ε)) ++ (u ∷ Γ)) h₂ (λ z → Π ≡ subst (λ z → Form z ((t > $o) > $o)) h₁ (sub-i (Γ' ++ (v ∷ ε)) Γ G z)) (erase-subst (Ctx _) (λ z → Form z ((t > $o) > $o)) Π ((Γ' ++ (v ∷ ε)) ++ Γ) (Γ' ++ (v ∷ Γ)) h₁ (λ z → Π ≡ z) refl) -- rewrite h₂ | h₁ = refl
sub-weak-p-1-i {_} {(t > $o) > .t} {u} {v} {Γ} Γ' i G h₁ h₂ = erase-subst (Ctx _) (λ z → Form z ((t > $o) > t)) i (Γ' ++ (v ∷ (u ∷ Γ))) ((Γ' ++ (v ∷ ε)) ++ (u ∷ Γ)) h₂ (λ z → i ≡ subst (λ z → Form z ((t > $o) > t)) h₁ (sub-i (Γ' ++ (v ∷ ε)) Γ G z)) (erase-subst (Ctx _) (λ z → Form z ((t > $o) > t)) i ((Γ' ++ (v ∷ ε)) ++ Γ) (Γ' ++ (v ∷ Γ)) h₁ (λ z → i ≡ z) refl) -- rewrite h₂ | h₁ = refl
sub-weak-p-1-i {_} {t} {u} {v} {Γ} Γ' (app f₁ f₂) G h₁ h₂ = sub-weak-p-1-app-1 Γ' f₁ f₂ G h₁ (Γ' ++ (v ∷ (u ∷ Γ))) h₂ refl
sub-weak-p-1-i {_} {α > β} {u} {v} {Γ} Γ' (lam .α f) G h₁ h₂ = sub-weak-p-1-lam-1 Γ' f G h₁ (Γ' ++ (v ∷ (u ∷ Γ))) h₂ refl
sub-weak-p-1'-var : ∀ {n} → {t u : Type n} {Γ : Ctx n} (Γ' : Ctx n) (x : Var (Γ' ++ Γ)) (G : Form Γ u)
(p : lookup-Var (Γ' ++ Γ) x ≡ t) →
var x p ≡ sub-var Γ' Γ G (weak-var Γ' Γ x) (trans (weak-var-p Γ' Γ x) p)
sub-weak-p-1'-var ε x G p = refl
sub-weak-p-1'-var (v ∷ Γ') this G p = refl
sub-weak-p-1'-var {_} {_} {_} {Γ} (v ∷ Γ') (next x) G p =
subst (λ z → var (next {_} {v} x) p ≡ weak-i ε (Γ' ++ Γ) z)
(sub-weak-p-1'-var Γ' x G p)
refl
sub-weak-p-1'-i : ∀ {n} → {t u : Type n} {Γ : Ctx n} (Γ' : Ctx n) (F : Form (Γ' ++ Γ) t) (G : Form Γ u) →
F ≡ sub-i Γ' Γ G (weak-i Γ' Γ F)
sub-weak-p-1'-i Γ' (var x p) G = sub-weak-p-1'-var Γ' x G p
sub-weak-p-1'-i Γ' N G = refl
sub-weak-p-1'-i Γ' A G = refl
sub-weak-p-1'-i Γ' Π G = refl
sub-weak-p-1'-i Γ' i G = refl
sub-weak-p-1'-i {_} {_} {_} {Γ} Γ' (app f₁ f₂) G = trans (cong (λ z → app z f₂) (sub-weak-p-1'-i Γ' f₁ G)) ((cong (λ z → app (sub-i Γ' Γ G (weak-i Γ' Γ f₁)) z) (sub-weak-p-1'-i Γ' f₂ G)))
sub-weak-p-1'-i Γ' (lam α f) G = cong (lam α) (sub-weak-p-1'-i (α ∷ Γ') f G)
sub-weak-p-1 : ∀ {n} → {t u v : Type n} {Γ : Ctx n} (F : Form Γ t) (G : Form Γ u) →
weak-i ε Γ F ≡ sub-i (v ∷ ε) Γ G (weak-i ε (u ∷ Γ) (weak-i ε Γ F))
sub-weak-p-1 F G = sub-weak-p-1-i ε F G refl refl
sub-weak-p-23 : ∀ {n} → {t u v : Type n} {Γ : Ctx n} (F : Form Γ t) (G : Form (v ∷ Γ) u) →
weak-i ε Γ F ≡ sub-i ε (v ∷ Γ) G (weak-i (u ∷ ε) Γ (weak-i ε Γ F))
sub-weak-p-23 F G = sub-weak-p-23-i ε F G refl refl
sub-weak-p-1' : ∀ {n} → {t u : Type n} {Γ : Ctx n} (F : Form Γ t) (G : Form Γ u) →
F ≡ sub G (weak F)
sub-weak-p-1' F G = sub-weak-p-1'-i ε F G
-- --------------------------
weak-var-irr-proof-2 : ∀ {n} {Γ : Ctx n} (t : Type n) (x : Var Γ)
(p₁ : lookup-Var Γ x ≡ t)
(p₂ : lookup-Var Γ x ≡ t) →
var x p₁ ≡ var x p₂
weak-var-irr-proof-2 {n} {Γ} .(lookup-Var Γ x) x refl refl = refl
weak-var-irr-proof : ∀ {n} {Γ : Ctx n} (t : Type n) (x₁ x₂ : Var Γ)
(p₁ : lookup-Var Γ x₁ ≡ t)
(p₂ : lookup-Var Γ x₂ ≡ t) →
x₁ ≡ x₂ →
var x₁ p₁ ≡ var x₂ p₂
weak-var-irr-proof {n} {Γ} t .x₂ x₂ p₁ p₂ refl = weak-var-irr-proof-2 t x₂ p₁ p₂ -- rewrite h = weak-var-irr-proof-2 t x₂ p₁ p₂
-- --------------------------
weak-weak-var-p-1-this : ∀ {n} Γ₁ Γ₂ → (t u v w : Type n)
(Γ'₁ Γ'₂ : Ctx n) →
(h₁ : w ∷ Γ'₁ ≡ w ∷ ((Γ₂ ++ (t ∷ ε)) ++ Γ₁))
(h₂ : w ∷ Γ'₂ ≡ w ∷ ((Γ₂ ++ (t ∷ ε)) ++ (u ∷ Γ₁))) →
weak-var (w ∷ (Γ₂ ++ (t ∷ ε))) Γ₁ (subst Var h₁ this) ≡
subst Var h₂ this
weak-weak-var-p-1-this Γ₁ Γ₂ t u v w ._ ._ refl refl = refl
mutual
weak-weak-var-p-1-next : ∀ {n} Γ₁ Γ₂ → (t u v w : Type n) (x : Var (Γ₂ ++ Γ₁))
(Γ'₁ Γ'₂ : Ctx n) →
(h₁₁ : w ∷ Γ'₁ ≡ w ∷ ((Γ₂ ++ (t ∷ ε)) ++ Γ₁))
(h₁₂ : Γ₂ ++ (t ∷ Γ₁) ≡ Γ'₁)
(h₂₁ : w ∷ Γ'₂ ≡ w ∷ ((Γ₂ ++ (t ∷ ε)) ++ (u ∷ Γ₁)))
(h₂₂ : Γ₂ ++ (t ∷ (u ∷ Γ₁)) ≡ Γ'₂) →
weak-var (w ∷ (Γ₂ ++ (t ∷ ε))) Γ₁ (subst Var h₁₁ (next (subst Var h₁₂ (weak-var Γ₂ Γ₁ x)))) ≡
subst Var h₂₁ (next (subst Var h₂₂ (weak-var Γ₂ (u ∷ Γ₁) (weak-var Γ₂ Γ₁ x))))
weak-weak-var-p-1-next Γ₁ Γ₂ t u v w x ._ ._ refl h₁₂ refl h₂₂ = cong next (weak-weak-var-p-1 Γ₁ Γ₂ t u v x h₁₂ h₂₂)
weak-weak-var-p-1 : ∀ {n} Γ₁ Γ₂ → (t u v : Type n) (x : Var (Γ₂ ++ Γ₁))
(h₁ : Γ₂ ++ (t ∷ Γ₁) ≡ (Γ₂ ++ (t ∷ ε)) ++ Γ₁)
(h₂ : Γ₂ ++ (t ∷ (u ∷ Γ₁)) ≡ (Γ₂ ++ (t ∷ ε)) ++ (u ∷ Γ₁)) →
weak-var (Γ₂ ++ (t ∷ ε)) Γ₁ (subst Var h₁ (weak-var Γ₂ Γ₁ x)) ≡
subst Var h₂ (weak-var Γ₂ (u ∷ Γ₁) (weak-var Γ₂ Γ₁ x))
weak-weak-var-p-1 Γ₂ ε t u v x refl refl = refl
weak-weak-var-p-1 Γ₁ (w ∷ Γ₂) t u v this h₁ h₂ = weak-weak-var-p-1-this Γ₁ Γ₂ t u v w _ _ h₁ h₂
weak-weak-var-p-1 Γ₁ (w ∷ Γ₂) t u v (next x) h₁ h₂ = weak-weak-var-p-1-next Γ₁ Γ₂ t u v w x _ _ h₁ refl h₂ refl
weak-weak-p-1-var : ∀ {n} Γ₁ Γ₂ → (t u v : Type n) (x : Var (Γ₂ ++ Γ₁))
(Γ'₁ Γ'₂ : Ctx n) →
(h₁₁ : Γ'₁ ≡ (Γ₂ ++ (t ∷ ε)) ++ Γ₁) →
(h₁₂ : Γ₂ ++ (t ∷ Γ₁) ≡ Γ'₁) →
(h₂₁ : Γ'₂ ≡ (Γ₂ ++ (t ∷ ε)) ++ (u ∷ Γ₁)) →
(h₂₂ : Γ₂ ++ (t ∷ (u ∷ Γ₁)) ≡ Γ'₂) →
(p₁ : lookup-Var Γ'₁ (subst Var h₁₂ (weak-var Γ₂ Γ₁ x)) ≡ v)
(p₂ : lookup-Var Γ'₂ (subst Var h₂₂ (weak-var Γ₂ (u ∷ Γ₁) (weak-var Γ₂ Γ₁ x))) ≡ v) →
weak-i (Γ₂ ++ (t ∷ ε)) Γ₁ (subst (λ z → Form z v) h₁₁ (var (subst Var h₁₂ (weak-var Γ₂ Γ₁ x)) p₁)) ≡
subst (λ z → Form z v) h₂₁ (var (subst Var h₂₂ (weak-var Γ₂ (u ∷ Γ₁) (weak-var Γ₂ Γ₁ x))) p₂)
weak-weak-p-1-var Γ₁ Γ₂ t u v x .((Γ₂ ++ (t ∷ ε)) ++ Γ₁) .((Γ₂ ++ (t ∷ ε)) ++ (u ∷ Γ₁)) refl h₁₂ refl h₂₂ p₁ p₂ = weak-var-irr-proof _ (weak-var (Γ₂ ++ (t ∷ ε)) Γ₁ (subst Var h₁₂ (weak-var Γ₂ Γ₁ x))) (subst Var h₂₂ (weak-var Γ₂ (u ∷ Γ₁) (weak-var Γ₂ Γ₁ x))) (trans (weak-var-p (Γ₂ ++ (t ∷ ε)) Γ₁ (subst Var h₁₂ (weak-var Γ₂ Γ₁ x))) p₁) p₂ (weak-weak-var-p-1 Γ₁ Γ₂ t u v x h₁₂ h₂₂)
mutual
weak-weak-p-1-app : ∀ {n} Γ₁ Γ₂ → (t u v α : Type n) (f₁ : Form (Γ₂ ++ Γ₁) (α > v)) (f₂ : Form (Γ₂ ++ Γ₁) α)
(Γ'₁ Γ'₂ : Ctx n) →
(h₁₁ : Γ'₁ ≡ (Γ₂ ++ (t ∷ ε)) ++ Γ₁) →
(h₁₂ : Γ₂ ++ (t ∷ Γ₁) ≡ Γ'₁) →
(h₂₁ : Γ'₂ ≡ (Γ₂ ++ (t ∷ ε)) ++ (u ∷ Γ₁)) →
(h₂₂ : Γ₂ ++ (t ∷ (u ∷ Γ₁)) ≡ Γ'₂) →
weak-i (Γ₂ ++ (t ∷ ε)) Γ₁ (subst (λ z → Form z v) h₁₁ (app (subst (λ z → Form z (α > v)) h₁₂ (weak-i Γ₂ Γ₁ f₁)) (subst (λ z → Form z α) h₁₂ (weak-i Γ₂ Γ₁ f₂)))) ≡
subst (λ z → Form z v) h₂₁ (app (subst (λ z → Form z (α > v)) h₂₂ (weak-i Γ₂ (u ∷ Γ₁) (weak-i Γ₂ Γ₁ f₁))) (subst (λ z → Form z α) h₂₂ (weak-i Γ₂ (u ∷ Γ₁) (weak-i Γ₂ Γ₁ f₂))))
weak-weak-p-1-app Γ₁ Γ₂ t u v α f₁ f₂ ._ ._ refl h₁₂ refl h₂₂ =
trans (cong (λ z → app z (weak-i (Γ₂ ++ (t ∷ ε)) Γ₁ (subst (λ z → Form z α) h₁₂ (weak-i Γ₂ Γ₁ f₂)))) (weak-weak-p-1-i Γ₁ Γ₂ t u (α > v) f₁ h₁₂ h₂₂)) (cong (app (subst (λ z → Form z (α > v)) h₂₂ (weak-i Γ₂ (u ∷ Γ₁) (weak-i Γ₂ Γ₁ f₁)))) (weak-weak-p-1-i Γ₁ Γ₂ t u α f₂ h₁₂ h₂₂))
weak-weak-p-1-lam : ∀ {n} Γ₁ Γ₂ → (t u α β : Type n) (X : Form (α ∷ (Γ₂ ++ Γ₁)) β)
(Γ'₁ Γ'₂ : Ctx n) →
(h₁₁ : Γ'₁ ≡ (Γ₂ ++ (t ∷ ε)) ++ Γ₁) →
(h₁₂ : Γ₂ ++ (t ∷ Γ₁) ≡ Γ'₁) →
(h₂₁ : Γ'₂ ≡ (Γ₂ ++ (t ∷ ε)) ++ (u ∷ Γ₁)) →
(h₂₂ : Γ₂ ++ (t ∷ (u ∷ Γ₁)) ≡ Γ'₂) →
weak-i (Γ₂ ++ (t ∷ ε)) Γ₁ (subst (λ z → Form z (α > β)) h₁₁ (lam α (subst (λ z → Form z β) (cong (_∷_ α) h₁₂) (weak-i (α ∷ Γ₂) Γ₁ X)))) ≡
subst (λ z → Form z (α > β)) h₂₁ (lam α (subst (λ z → Form z β) (cong (_∷_ α) h₂₂) (weak-i (α ∷ Γ₂) (u ∷ Γ₁) (weak-i (α ∷ Γ₂) Γ₁ X))))
weak-weak-p-1-lam Γ₁ Γ₂ t u α β X .((Γ₂ ++ (t ∷ ε)) ++ Γ₁) .((Γ₂ ++ (t ∷ ε)) ++ (u ∷ Γ₁)) refl h₁₂ refl h₂₂ = cong (lam α) (weak-weak-p-1-i Γ₁ (α ∷ Γ₂) t u β X (cong (_∷_ α) h₁₂) (cong (_∷_ α) h₂₂))
weak-weak-p-1-i : ∀ {n} Γ₁ Γ₂ → (t u v : Type n) (X : Form (Γ₂ ++ Γ₁) v) →
(h₁ : Γ₂ ++ (t ∷ Γ₁) ≡ (Γ₂ ++ (t ∷ ε)) ++ Γ₁) →
(h₂ : Γ₂ ++ (t ∷ (u ∷ Γ₁)) ≡ (Γ₂ ++ (t ∷ ε)) ++ (u ∷ Γ₁)) →
weak-i {n} {v} {u} (Γ₂ ++ (t ∷ ε)) Γ₁ (subst (λ z → Form z v) h₁ (weak-i {n} {v} {t} Γ₂ Γ₁ X)) ≡ subst (λ z → Form z v) h₂ (weak-i {n} {v} {t} Γ₂ (u ∷ Γ₁) (weak-i {n} {v} {u} Γ₂ Γ₁ X))
weak-weak-p-1-i Γ₁ Γ₂ t u v (var x p) h₁ h₂ = weak-weak-p-1-var Γ₁ Γ₂ t u v x _ _ h₁ refl h₂ refl (trans (weak-var-p Γ₂ Γ₁ x) p) (trans (weak-var-p Γ₂ (u ∷ Γ₁) (weak-var Γ₂ Γ₁ x)) (trans (weak-var-p Γ₂ Γ₁ x) p))
weak-weak-p-1-i Γ₁ Γ₂ t u .($o > $o) N h₁ h₂ = erase-subst (Ctx _) (λ z → Form z ($o > $o)) N (Γ₂ ++ (t ∷ (u ∷ Γ₁))) ((Γ₂ ++ (t ∷ ε)) ++ (u ∷ Γ₁)) h₂ (λ z → weak-i (Γ₂ ++ (t ∷ ε)) Γ₁ (subst (λ z → Form z ($o > $o)) h₁ N) ≡ z) (erase-subst (Ctx _) (λ z → Form z ($o > $o)) N (Γ₂ ++ (t ∷ Γ₁)) ((Γ₂ ++ (t ∷ ε)) ++ Γ₁) h₁ (λ z → weak-i {_} {_} {u} (Γ₂ ++ (t ∷ ε)) Γ₁ z ≡ N) refl) -- rewrite h₂ | h₁ = refl
weak-weak-p-1-i Γ₁ Γ₂ t u .($o > ($o > $o)) A h₁ h₂ = erase-subst (Ctx _) (λ z → Form z ($o > ($o > $o))) A (Γ₂ ++ (t ∷ (u ∷ Γ₁))) ((Γ₂ ++ (t ∷ ε)) ++ (u ∷ Γ₁)) h₂ (λ z → weak-i (Γ₂ ++ (t ∷ ε)) Γ₁ (subst (λ z → Form z ($o > ($o > $o))) h₁ A) ≡ z) (erase-subst (Ctx _) (λ z → Form z ($o > ($o > $o))) A (Γ₂ ++ (t ∷ Γ₁)) ((Γ₂ ++ (t ∷ ε)) ++ Γ₁) h₁ (λ z → weak-i {_} {_} {u} (Γ₂ ++ (t ∷ ε)) Γ₁ z ≡ A) refl) -- rewrite h₂ | h₁ = refl
weak-weak-p-1-i Γ₁ Γ₂ t u .((α > $o) > $o) (Π {._} {α}) h₁ h₂ = erase-subst (Ctx _) (λ z → Form z ((α > $o) > $o)) Π (Γ₂ ++ (t ∷ (u ∷ Γ₁))) ((Γ₂ ++ (t ∷ ε)) ++ (u ∷ Γ₁)) h₂ (λ z → weak-i (Γ₂ ++ (t ∷ ε)) Γ₁ (subst (λ z → Form z ((α > $o) > $o)) h₁ Π) ≡ z) (erase-subst (Ctx _) (λ z → Form z ((α > $o) > $o)) Π (Γ₂ ++ (t ∷ Γ₁)) ((Γ₂ ++ (t ∷ ε)) ++ Γ₁) h₁ (λ z → weak-i {_} {_} {u} (Γ₂ ++ (t ∷ ε)) Γ₁ z ≡ Π) refl) -- rewrite h₂ | h₁ = refl
weak-weak-p-1-i Γ₁ Γ₂ t u .((α > $o) > α) (i {._} {α}) h₁ h₂ = erase-subst (Ctx _) (λ z → Form z ((α > $o) > α)) i (Γ₂ ++ (t ∷ (u ∷ Γ₁))) ((Γ₂ ++ (t ∷ ε)) ++ (u ∷ Γ₁)) h₂ (λ z → weak-i (Γ₂ ++ (t ∷ ε)) Γ₁ (subst (λ z → Form z ((α > $o) > α)) h₁ i) ≡ z) (erase-subst (Ctx _) (λ z → Form z ((α > $o) > α)) i (Γ₂ ++ (t ∷ Γ₁)) ((Γ₂ ++ (t ∷ ε)) ++ Γ₁) h₁ (λ z → weak-i {_} {_} {u} (Γ₂ ++ (t ∷ ε)) Γ₁ z ≡ i) refl) -- rewrite h₂ | h₁ = refl
weak-weak-p-1-i Γ₁ Γ₂ t u v (app f₁ f₂) h₁ h₂ = weak-weak-p-1-app Γ₁ Γ₂ t u v _ f₁ f₂ _ _ h₁ refl h₂ refl
weak-weak-p-1-i Γ₁ Γ₂ t u .(α > β) (lam {._} {β} α f) h₁ h₂ = weak-weak-p-1-lam Γ₁ Γ₂ t u α β f _ _ h₁ refl h₂ refl
weak-weak-p-1 : ∀ {n} Γ → (t u v : Type n) (X : Form Γ v) →
weak-i {n} {v} {u} (t ∷ ε) Γ (weak-i {n} {v} {t} ε Γ X) ≡ weak-i {n} {v} {t} ε (u ∷ Γ) (weak-i {n} {v} {u} ε Γ X)
weak-weak-p-1 Γ t u v X = weak-weak-p-1-i Γ ε t u v X refl refl
-- -----------------------
thevar : ∀ {n Γ} → (Γ' : Ctx n) (α : Type n) → Var (Γ' ++ (α ∷ Γ))
thevar ε α = this
thevar (β ∷ Γ') α = next (thevar Γ' α)
occurs-p-2-i-var : ∀ {n} {Γ : Ctx n} {α β : Type n} (Γ' : Ctx n)
(v : Var (Γ' ++ Γ))
(p : lookup-Var (Γ' ++ Γ) v ≡ β) →
eq-Var (thevar Γ' α) (weak-var Γ' Γ v) ≡ false
occurs-p-2-i-var ε v p = refl
occurs-p-2-i-var (γ ∷ Γ') this p = refl
occurs-p-2-i-var (γ ∷ Γ') (next v) p = occurs-p-2-i-var Γ' v p
occurs-p-2-i : ∀ {n} {Γ : Ctx n} {α β : Type n} (Γ' : Ctx n) (F : Form (Γ' ++ Γ) β) →
occurs {n} {Γ' ++ (α ∷ Γ)} (thevar Γ' α) (weak-i Γ' Γ F) ≡ false
occurs-p-2-i Γ' (var v p) = occurs-p-2-i-var Γ' v p
occurs-p-2-i Γ' N = refl
occurs-p-2-i Γ' A = refl
occurs-p-2-i Γ' Π = refl
occurs-p-2-i Γ' i = refl
occurs-p-2-i {n} {Γ} {α} {β} Γ' (app f₁ f₂) = subst (λ z → z ∨ occurs (thevar Γ' α) (weak-i Γ' Γ f₂) ≡ false) (sym (occurs-p-2-i {n} {Γ} {α} {_ > β} Γ' f₁)) (occurs-p-2-i {n} {Γ} {α} Γ' f₂) -- rewrite occurs-p-2-i {n} {Γ} {α} {_ > β} Γ' f₁ | occurs-p-2-i {n} {Γ} {α} Γ' f₂ = refl
occurs-p-2-i Γ' (lam γ f) = occurs-p-2-i (γ ∷ Γ') f
occurs-p-2 : ∀ {n} {Γ : Ctx n} {α β : Type n} (F : Form Γ β) →
occurs {n} {α ∷ Γ} this (weak F) ≡ false
occurs-p-2 F = occurs-p-2-i ε F
-- -----------------------
sub-sub-weak-weak-p-3-i-var-2-this : ∀ {n} → {Γ Γ' : Ctx n} {α β γ : Type n} →
(Γ1 Γ2 : Ctx n) →
(eq1 : γ ∷ Γ1 ≡ γ ∷ (Γ' ++ (α ∷ (α ∷ Γ)))) →
(eq2 : γ ∷ Γ2 ≡ γ ∷ (Γ' ++ (α ∷ Γ))) →
(p1 : lookup-Var (γ ∷ (Γ' ++ (α ∷ (α ∷ Γ)))) (subst Var eq1 this) ≡ β) →
(p2 : lookup-Var (γ ∷ (Γ' ++ (α ∷ Γ))) (subst Var eq2 this) ≡ β) →
sub-var (γ ∷ Γ') (α ∷ Γ) (var this refl) (subst Var eq1 this) p1 ≡ var (subst Var eq2 this) p2
sub-sub-weak-weak-p-3-i-var-2-this {n} {Γ} {Γ'} {α} .(Γ' ++ (α ∷ (α ∷ Γ))) .(Γ' ++ (α ∷ Γ)) refl refl refl refl = refl
mutual
sub-sub-weak-weak-p-3-i-var-2-next : ∀ {n} → {Γ Γ' : Ctx n} {α β γ : Type n}
(x : Var ((Γ' ++ (α ∷ ε)) ++ Γ)) →
(Γ1 Γ2 : Ctx n) →
(eq1 : γ ∷ Γ1 ≡ γ ∷ (Γ' ++ (α ∷ (α ∷ Γ)))) →
(eq12 : (Γ' ++ (α ∷ ε)) ++ (α ∷ Γ) ≡ Γ1) →
(eq2 : γ ∷ Γ2 ≡ γ ∷ (Γ' ++ (α ∷ Γ))) →
(eq22 : (Γ' ++ (α ∷ ε)) ++ Γ ≡ Γ2) →
(p1 : lookup-Var ((γ ∷ Γ') ++ (lookup-Var (α ∷ Γ) this ∷ (α ∷ Γ))) (subst Var eq1 (next (subst Var eq12 (weak-var (Γ' ++ (α ∷ ε)) Γ x)))) ≡ β) →
(p2 : lookup-Var (γ ∷ (Γ' ++ (α ∷ Γ))) (subst Var eq2 (next (subst Var eq22 x))) ≡ β) →
sub-var (γ ∷ Γ') (α ∷ Γ) (var this refl) (subst Var eq1 (next (subst Var eq12 (weak-var (Γ' ++ (α ∷ ε)) Γ x)))) p1
≡ var (subst Var eq2 (next (subst Var eq22 x))) p2
sub-sub-weak-weak-p-3-i-var-2-next {n} {Γ} {Γ'} {α} x .(Γ' ++ (α ∷ (α ∷ Γ))) .(Γ' ++ (α ∷ Γ)) refl eq12 refl eq22 p1 p2 = cong (weak-i ε (Γ' ++ (α ∷ Γ))) (sub-sub-weak-weak-p-3-i-var-2 {n} {Γ} {Γ'} {α} x eq12 eq22 p1 p2)
sub-sub-weak-weak-p-3-i-var-2 : ∀ {n} → {Γ Γ' : Ctx n} {α β : Type n} (x : Var ((Γ' ++ (α ∷ ε)) ++ Γ)) →
(eq1 : (Γ' ++ (α ∷ ε)) ++ (α ∷ Γ) ≡ Γ' ++ (α ∷ (α ∷ Γ))) →
(eq2 : (Γ' ++ (α ∷ ε)) ++ Γ ≡ Γ' ++ (α ∷ Γ)) →
(p1 : lookup-Var (Γ' ++ (α ∷ (α ∷ Γ))) (subst Var eq1 (weak-var (Γ' ++ (α ∷ ε)) Γ x)) ≡ β) →
(p2 : lookup-Var (Γ' ++ (α ∷ Γ)) (subst Var eq2 x) ≡ β) →
sub-var Γ' (α ∷ Γ) (var this refl) (subst Var eq1 (weak-var (Γ' ++ (α ∷ ε)) Γ x)) p1
≡ var (subst Var eq2 x) p2
sub-sub-weak-weak-p-3-i-var-2 {n} {Γ} {ε} this refl refl refl refl = refl
sub-sub-weak-weak-p-3-i-var-2 {n} {Γ} {ε} (next x) refl refl refl refl = refl
sub-sub-weak-weak-p-3-i-var-2 {n} {Γ} {γ ∷ Γ'} this eq1 eq2 p1 p2 = sub-sub-weak-weak-p-3-i-var-2-this {n} {Γ} {Γ'} {_} {_} {γ} ((Γ' ++ (_ ∷ ε)) ++ (_ ∷ Γ)) ((Γ' ++ (_ ∷ ε)) ++ Γ) eq1 eq2 p1 p2
sub-sub-weak-weak-p-3-i-var-2 {n} {Γ} {γ ∷ Γ'} (next x) eq1 eq2 p1 p2 = sub-sub-weak-weak-p-3-i-var-2-next {n} {Γ} {Γ'} {_} {_} {γ} x ((Γ' ++ (_ ∷ ε)) ++ (_ ∷ Γ)) ((Γ' ++ (_ ∷ ε)) ++ Γ) eq1 refl eq2 refl p1 p2
sub-sub-weak-weak-p-3-i-var : ∀ {n} → {Γ Γ' : Ctx n} {α β : Type n} (x : Var ((Γ' ++ (α ∷ ε)) ++ Γ)) →
(Γ1 Γ2 : Ctx n) →
(eq11 : Γ1 ≡ Γ' ++ (α ∷ (α ∷ Γ))) →
(eq12 : (Γ' ++ (α ∷ ε)) ++ (α ∷ Γ) ≡ Γ1) →
(eq21 : Γ2 ≡ Γ' ++ (α ∷ Γ)) →
(eq22 : (Γ' ++ (α ∷ ε)) ++ Γ ≡ Γ2) →
(p1 : lookup-Var Γ1 (subst Var eq12 (weak-var (Γ' ++ (α ∷ ε)) Γ x)) ≡ β) →
(p2 : lookup-Var Γ2 (subst Var eq22 x) ≡ β) →
sub-i Γ' (α ∷ Γ) (var this refl) (subst (λ z → Form z β) eq11 (var (subst Var eq12 (weak-var (Γ' ++ (α ∷ ε)) Γ x)) p1))
≡ subst (λ z → Form z β) eq21 (var (subst Var eq22 x) p2)
sub-sub-weak-weak-p-3-i-var {n} {Γ} {Γ'} {α} x .(Γ' ++ (α ∷ (α ∷ Γ))) .(Γ' ++ (α ∷ Γ)) refl eq12 refl eq22 p1 p2 = sub-sub-weak-weak-p-3-i-var-2 {n} {Γ} {Γ'} {α} x eq12 eq22 p1 p2
mutual
sub-sub-weak-weak-p-3-i-app : ∀ {n} → {Γ Γ' : Ctx n} {α β γ : Type n}
(f₁ : Form ((Γ' ++ (α ∷ ε)) ++ Γ) (γ > β)) →
(f₂ : Form ((Γ' ++ (α ∷ ε)) ++ Γ) γ) →
(Γ1 Γ2 : Ctx n) →
(eq1 : Γ1 ≡ Γ' ++ (α ∷ (α ∷ Γ))) →
(eq12 : (Γ' ++ (α ∷ ε)) ++ (α ∷ Γ) ≡ Γ1) →
(eq2 : Γ2 ≡ Γ' ++ (α ∷ Γ)) →
(eq22 : (Γ' ++ (α ∷ ε)) ++ Γ ≡ Γ2) →
sub-i Γ' (α ∷ Γ) (var this refl) (subst (λ z → Form z β) eq1 (app (subst (λ z → Form z (γ > β)) eq12 (weak-i (Γ' ++ (α ∷ ε)) Γ f₁)) (subst (λ z → Form z γ) eq12 (weak-i (Γ' ++ (α ∷ ε)) Γ f₂))))
≡ subst (λ z → Form z β) eq2 (app (subst (λ z → Form z (γ > β)) eq22 f₁) (subst (λ z → Form z γ) eq22 f₂))
sub-sub-weak-weak-p-3-i-app {n} {Γ} {Γ'} {α} {β} {γ} f₁ f₂ .(Γ' ++ (α ∷ (α ∷ Γ))) .(Γ' ++ (α ∷ Γ)) refl eq12 refl eq22 = trans (cong (λ z → app z (sub-i Γ' (α ∷ Γ) (var this refl) (subst (λ z → Form z γ) eq12 (weak-i (Γ' ++ (α ∷ ε)) Γ f₂)))) (sub-sub-weak-weak-p-3-i {n} {Γ} {Γ'} {α} {γ > β} f₁ eq12 eq22)) (cong (app (subst (λ z → Form z (γ > β)) eq22 f₁)) (sub-sub-weak-weak-p-3-i {n} {Γ} {Γ'} {α} {γ} f₂ eq12 eq22))
sub-sub-weak-weak-p-3-i-lam : ∀ {n} → {Γ Γ' : Ctx n} {α β γ : Type n}
(f : Form (γ ∷ ((Γ' ++ (α ∷ ε)) ++ Γ)) β)
(Γ1 Γ2 : Ctx n)
(eq1 : Γ1 ≡ Γ' ++ (α ∷ (α ∷ Γ)))
(eq12 : γ ∷ ((Γ' ++ (α ∷ ε)) ++ (α ∷ Γ)) ≡ γ ∷ Γ1)
(eq2 : Γ2 ≡ Γ' ++ (α ∷ Γ))
(eq22 : γ ∷ ((Γ' ++ (α ∷ ε)) ++ Γ) ≡ γ ∷ Γ2) →
sub-i Γ' (α ∷ Γ) (var this refl) (subst (λ z → Form z (γ > β)) eq1 (lam γ (subst (λ z → Form z β) eq12 (weak-i (γ ∷ (Γ' ++ (α ∷ ε))) Γ f))))
≡ subst (λ z → Form z (γ > β)) eq2 (lam γ (subst (λ z → Form z β) eq22 f))
sub-sub-weak-weak-p-3-i-lam {n} {Γ} {Γ'} {α} {β} {γ} f .(Γ' ++ (α ∷ (α ∷ Γ))) .(Γ' ++ (α ∷ Γ)) refl eq12 refl eq22 = cong (lam γ) (sub-sub-weak-weak-p-3-i {n} {Γ} {γ ∷ Γ'} {α} {β} f eq12 eq22)
sub-sub-weak-weak-p-3-i : ∀ {n} → {Γ Γ' : Ctx n} {α β : Type n} (G : Form ((Γ' ++ (α ∷ ε)) ++ Γ) β) →
(eq1 : (Γ' ++ (α ∷ ε)) ++ (α ∷ Γ) ≡ Γ' ++ (α ∷ (α ∷ Γ))) →
(eq2 : (Γ' ++ (α ∷ ε)) ++ Γ ≡ Γ' ++ (α ∷ Γ)) →
sub-i Γ' (α ∷ Γ) (var this refl) (subst (λ z → Form z β) eq1 (weak-i (Γ' ++ (α ∷ ε)) Γ G)) ≡ subst (λ z → Form z β) eq2 G
sub-sub-weak-weak-p-3-i {n} {Γ} {Γ'} {α} {β} (var x p) eq1 eq2 = sub-sub-weak-weak-p-3-i-var {n} {Γ} {Γ'} {α} {β} x ((Γ' ++ (α ∷ ε)) ++ (α ∷ Γ)) ((Γ' ++ (α ∷ ε)) ++ Γ) eq1 refl eq2 refl (trans (weak-var-p (Γ' ++ (α ∷ ε)) Γ x) p) p
sub-sub-weak-weak-p-3-i {_} {Γ} {Γ'} {α} {$o > $o} N eq1 eq2 = erase-subst (Ctx _) (λ z → Form z ($o > $o)) N ((Γ' ++ (α ∷ ε)) ++ Γ) (Γ' ++ (α ∷ Γ)) eq2 (λ z → sub-i Γ' (α ∷ Γ) (var this refl) (subst (λ z → Form z ($o > $o)) eq1 N) ≡ z) (erase-subst (Ctx _) (λ z → Form z ($o > $o)) N ((Γ' ++ (α ∷ ε)) ++ (α ∷ Γ)) (Γ' ++ (α ∷ (α ∷ Γ))) eq1 (λ z → sub-i Γ' (α ∷ Γ) (var this refl) z ≡ N) refl) -- rewrite eq2 | eq1 = refl
sub-sub-weak-weak-p-3-i {_} {Γ} {Γ'} {α} {$o > ($o > $o)} A eq1 eq2 = erase-subst (Ctx _) (λ z → Form z ($o > ($o > $o))) A ((Γ' ++ (α ∷ ε)) ++ Γ) (Γ' ++ (α ∷ Γ)) eq2 (λ z → sub-i Γ' (α ∷ Γ) (var this refl) (subst (λ z → Form z ($o > ($o > $o))) eq1 A) ≡ z) (erase-subst (Ctx _) (λ z → Form z ($o > ($o > $o))) A ((Γ' ++ (α ∷ ε)) ++ (α ∷ Γ)) (Γ' ++ (α ∷ (α ∷ Γ))) eq1 (λ z → sub-i Γ' (α ∷ Γ) (var this refl) z ≡ A) refl) -- rewrite eq2 | eq1 = refl
sub-sub-weak-weak-p-3-i {_} {Γ} {Γ'} {α} {(β > $o) > $o} Π eq1 eq2 = erase-subst (Ctx _) (λ z → Form z ((β > $o) > $o)) Π ((Γ' ++ (α ∷ ε)) ++ Γ) (Γ' ++ (α ∷ Γ)) eq2 (λ z → sub-i Γ' (α ∷ Γ) (var this refl) (subst (λ z → Form z ((β > $o) > $o)) eq1 Π) ≡ z) (erase-subst (Ctx _) (λ z → Form z ((β > $o) > $o)) Π ((Γ' ++ (α ∷ ε)) ++ (α ∷ Γ)) (Γ' ++ (α ∷ (α ∷ Γ))) eq1 (λ z → sub-i Γ' (α ∷ Γ) (var this refl) z ≡ Π) refl) -- rewrite eq2 | eq1 = refl
sub-sub-weak-weak-p-3-i {_} {Γ} {Γ'} {α} {(β > $o) > .β} i eq1 eq2 = erase-subst (Ctx _) (λ z → Form z ((β > $o) > β)) i ((Γ' ++ (α ∷ ε)) ++ Γ) (Γ' ++ (α ∷ Γ)) eq2 (λ z → sub-i Γ' (α ∷ Γ) (var this refl) (subst (λ z → Form z ((β > $o) > β)) eq1 i) ≡ z) (erase-subst (Ctx _) (λ z → Form z ((β > $o) > β)) i ((Γ' ++ (α ∷ ε)) ++ (α ∷ Γ)) (Γ' ++ (α ∷ (α ∷ Γ))) eq1 (λ z → sub-i Γ' (α ∷ Γ) (var this refl) z ≡ i) refl) -- rewrite eq2 | eq1 = refl
sub-sub-weak-weak-p-3-i {_} {Γ} {Γ'} {α} (app f₁ f₂) eq1 eq2 = sub-sub-weak-weak-p-3-i-app {_} {Γ} {Γ'} {α} f₁ f₂ ((Γ' ++ (α ∷ ε)) ++ (α ∷ Γ)) ((Γ' ++ (α ∷ ε)) ++ Γ) eq1 refl eq2 refl
sub-sub-weak-weak-p-3-i {_} {Γ} {Γ'} {α} (lam γ f) eq1 eq2 = sub-sub-weak-weak-p-3-i-lam {_} {Γ} {Γ'} {α} f ((Γ' ++ (α ∷ ε)) ++ (α ∷ Γ)) ((Γ' ++ (α ∷ ε)) ++ Γ) eq1 refl eq2 refl
sub-sub-weak-weak-p-3 : ∀ {n} → {Γ : Ctx n} {α β : Type n} (G : Form (α ∷ Γ) β) →
sub (var this refl) (weak-i (α ∷ ε) Γ G) ≡ G
sub-sub-weak-weak-p-3 G = sub-sub-weak-weak-p-3-i {_} {_} {ε} G refl refl
sub-sub-weak-weak-p : ∀ {n} → {Γ : Ctx n} {α β : Type n} (F : Form Γ β) (G : Form (α ∷ Γ) β) →
sub (var this refl) (sub-i (α ∷ (α ∷ ε)) Γ F (weak-i (α ∷ ε) (β ∷ Γ) (weak-i (α ∷ ε) Γ G))) ≡ G
sub-sub-weak-weak-p {_} {Γ} {α} {β} F G = subst (λ z → sub (var this refl) z ≡ G) (sub-weak-p-1-i (α ∷ ε) G F refl refl) (sub-sub-weak-weak-p-3 G)
sub-sub-weak-weak-p-2 : ∀ {n} → {Γ : Ctx n} {α β : Type n} (F G : Form (α ∷ Γ) β) →
sub (var this refl) (sub-i (α ∷ (α ∷ ε)) Γ (lam α G) (weak-i (α ∷ ε) ((α > β) ∷ Γ) (weak-i (α ∷ ε) Γ F))) ≡ F
sub-sub-weak-weak-p-2 {_} {Γ} {α} {β} F G = subst (λ z → sub (var this refl) z ≡ F) (sub-weak-p-1-i (α ∷ ε) F (lam α G) refl refl) (sub-sub-weak-weak-p-3 F)
-- ----------------
mutual
headNorm : {n : ℕ} {Γ : Ctx n} {α : Type n} → ℕ → Form Γ α → Form Γ α
-- headNorm m (app (app (lam α (lam _ (app Π (lam (_ > $o) (app (app A (app N (app (var this _) (var (next (next this)) _)))) (app (var this _) (var (next this) _))))))) F) G) = ?
headNorm m (app F G) = headNorm' m (headNorm m F) G
headNorm _ F = F
headNorm' : {n : ℕ} {Γ : Ctx n} {α β : Type n} → ℕ → Form Γ (α > β) → Form Γ α → Form Γ β
headNorm' (suc m) (lam _ F) G = headNorm m (sub G F)
headNorm' 0 (lam _ F) G = app (lam _ F) G
headNorm' _ F G = app F G
-- ----------------
!'[_]_ : ∀ {n} → {Γ : Ctx n} → (α : Type n) → Form Γ (α > $o) → Form Γ $o
!'[ α ] F = app Π F
?'[_]_ : ∀ {n} → {Γ : Ctx n} → (α : Type n) → Form Γ (α > $o) → Form Γ $o
?'[ α ] F = ?[ α ] (weak F · $ this {refl})
ι' : ∀ {n} → {Γ : Ctx n} → (α : Type n) → Form Γ (α > $o) → Form Γ α
ι' α F = app i F
| {
"alphanum_fraction": 0.4393167647,
"avg_line_length": 63.9719101124,
"ext": "agda",
"hexsha": "881546ba40c54f53e6928e0b78e7f72bcbcf5955",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2022-01-15T11:51:19.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-05-17T20:28:10.000Z",
"max_forks_repo_head_hexsha": "032efd5f42e4b56d436ac8e0c3c0f5127b8dc1f7",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "frelindb/agsyHOL",
"max_forks_repo_path": "soundness/Syntax.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "032efd5f42e4b56d436ac8e0c3c0f5127b8dc1f7",
"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": "frelindb/agsyHOL",
"max_issues_repo_path": "soundness/Syntax.agda",
"max_line_length": 450,
"max_stars_count": 17,
"max_stars_repo_head_hexsha": "032efd5f42e4b56d436ac8e0c3c0f5127b8dc1f7",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "frelindb/agsyHOL",
"max_stars_repo_path": "soundness/Syntax.agda",
"max_stars_repo_stars_event_max_datetime": "2021-03-19T20:53:45.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-04T14:38:28.000Z",
"num_tokens": 24001,
"size": 45548
} |
-- Andreas, 2018-06-03, issue #3102
-- Regression: slow reduce with lots of module parameters and an import.
-- {-# OPTIONS -v tc.cc:30 -v tc.cover.top:30 --profile=internal #-}
open import Agda.Builtin.Bool
module _ (A B C D E F G H I J K L M O P Q R S T U V W X Y Z
A₁ B₁ C₁ D₁ E₁ F₁ G₁ H₁ I₁ J₁ K₁ L₁ M₁ O₁ P₁ Q₁ R₁ S₁ T₁ U₁ V₁ W₁ X₁ Y₁ Z₁
A₂ B₂ C₂ D₂ E₂ F₂ G₂ H₂ I₂ J₂ K₂ L₂ M₂ O₂ P₂ Q₂ R₂ S₂ T₂ U₂ V₂ W₂ X₂ Y₂ Z₂
A₃ B₃ C₃ D₃ E₃ F₃ G₃ H₃ I₃ J₃ K₃ L₃ M₃ O₃ P₃ Q₃ R₃ S₃ T₃ U₃ V₃ W₃ X₃ Y₃ Z₃
A₄ B₄ C₄ D₄ E₄ F₄ G₄ H₄ I₄ J₄ K₄ L₄ M₄ O₄ P₄ Q₄ R₄ S₄ T₄ U₄ V₄ W₄ X₄ Y₄ Z₄
: Set) where
test : Bool → Bool
test true = false
test false = false
-- Should succeed instantaneously.
| {
"alphanum_fraction": 0.625,
"avg_line_length": 36.4,
"ext": "agda",
"hexsha": "c9d0c63bb8914d8b62fa1f3db7ccd61a237e5758",
"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/Issue3102.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/Issue3102.agda",
"max_line_length": 84,
"max_stars_count": 1,
"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/Issue3102.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-05T00:24:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2022-03-05T00:24:48.000Z",
"num_tokens": 376,
"size": 728
} |
module AmbiguousTopLevelModuleName where
import Imports.Ambiguous
| {
"alphanum_fraction": 0.8955223881,
"avg_line_length": 16.75,
"ext": "agda",
"hexsha": "c1a8d10b67a15b50e223a3e7598f5d87b903dab5",
"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/AmbiguousTopLevelModuleName.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/AmbiguousTopLevelModuleName.agda",
"max_line_length": 40,
"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/AmbiguousTopLevelModuleName.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 14,
"size": 67
} |
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
open import LibraBFT.Base.Types
import LibraBFT.Impl.Consensus.ConsensusProvider as ConsensusProvider
open import LibraBFT.Impl.Properties.Util
import LibraBFT.Impl.IO.OBM.GenKeyFile as GenKeyFile
open import LibraBFT.Impl.OBM.Logging.Logging
import LibraBFT.Impl.Types.ValidatorVerifier as ValidatorVerifier
open import LibraBFT.ImplShared.Consensus.Types
open import LibraBFT.ImplShared.Consensus.Types.EpochDep
open import LibraBFT.ImplShared.Consensus.Types.EpochIndep
open import LibraBFT.ImplShared.Util.Dijkstra.All
open import Optics.All
open import Util.PKCS
open import Util.Prelude hiding (_++_)
module LibraBFT.Impl.Consensus.Properties.ConsensusProvider where
open InitProofDefs
module startConsensusSpec
(nodeConfig : NodeConfig)
(now : Instant)
(payload : OnChainConfigPayload)
(liws : LedgerInfoWithSignatures)
(sk : SK)
(needFetch : ObmNeedFetch)
(propGen : ProposalGenerator)
(stateComp : StateComputer)
where
-- TODO-2: Requires refinement
postulate
contract' : EitherD-weakestPre (ConsensusProvider.startConsensus-ed-abs
nodeConfig now payload liws sk needFetch propGen stateComp)
(InitContract nothing)
| {
"alphanum_fraction": 0.7190082645,
"avg_line_length": 38.3658536585,
"ext": "agda",
"hexsha": "b71777d0b5f884abe775911c4581937b71f7b637",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_forks_repo_licenses": [
"UPL-1.0"
],
"max_forks_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_forks_repo_path": "src/LibraBFT/Impl/Consensus/Properties/ConsensusProvider.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"UPL-1.0"
],
"max_issues_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_issues_repo_path": "src/LibraBFT/Impl/Consensus/Properties/ConsensusProvider.agda",
"max_line_length": 111,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_stars_repo_licenses": [
"UPL-1.0"
],
"max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_stars_repo_path": "src/LibraBFT/Impl/Consensus/Properties/ConsensusProvider.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 392,
"size": 1573
} |
-- Andreas, 2012-07-26, reported by Nisse
module Issue678 where
module Unit where
data Unit : Set where
unit : Unit
El : Unit → Set
El unit = Unit
data IsUnit : Unit → Set where
isUnit : IsUnit unit
test : (u : Unit)(x : El u)(p : IsUnit u) → Set
test .unit unit isUnit = Unit
-- this requires the coverage checker to skip the first split opportunity, x,
-- and move on to the second, p
module NisseOriginalTestCase where
record Box (A : Set) : Set where
constructor [_]
field unbox : A
data U : Set where
box : U → U
El : U → Set
El (box a) = Box (El a)
data Q : ∀ a → El a → El a → Set where
q₁ : ∀ {a x} → Q (box a) [ x ] [ x ]
q₂ : ∀ {a} {x y : El a} → Q a x y
data P : ∀ a → El a → El a → Set where
p : ∀ {a x y z} → P a x y → P a y z → P a x z
foo : ∀ {a xs ys} → P a xs ys → Q a xs ys
foo (p p₁ p₂) with foo p₁ | foo p₂
foo (p p₁ p₂) | q₁ | _ = q₂
foo (p p₁ p₂) | q₂ | _ = q₂
-- Error was:
-- Cannot split on argument of non-datatype El @1
-- when checking the definition of with-33
| {
"alphanum_fraction": 0.5704948646,
"avg_line_length": 22.7872340426,
"ext": "agda",
"hexsha": "e35accca457f4dc94e3de259342d999b0c63963d",
"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/Issue678.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/Issue678.agda",
"max_line_length": 79,
"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/Issue678.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": 391,
"size": 1071
} |
{-# OPTIONS --safe --warning=error --without-K #-}
module Naturals where
data ℕ : Set where
zero : ℕ
succ : ℕ → ℕ
{-# BUILTIN NATURAL ℕ #-}
_+N_ : ℕ → ℕ → ℕ
zero +N b = b
succ a +N b = succ (a +N b)
| {
"alphanum_fraction": 0.5603864734,
"avg_line_length": 14.7857142857,
"ext": "agda",
"hexsha": "1b4bde6a241f8f98f571c54e921ebf12a8ccd178",
"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": "3d56e649152d2cd906281943860ca19da1d1f344",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Smaug123/CubicalTutorial",
"max_forks_repo_path": "Naturals.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "3d56e649152d2cd906281943860ca19da1d1f344",
"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": "Smaug123/CubicalTutorial",
"max_issues_repo_path": "Naturals.agda",
"max_line_length": 50,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "3d56e649152d2cd906281943860ca19da1d1f344",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Smaug123/CubicalTutorial",
"max_stars_repo_path": "Naturals.agda",
"max_stars_repo_stars_event_max_datetime": "2021-01-16T23:14:13.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-26T17:02:42.000Z",
"num_tokens": 73,
"size": 207
} |
module Cats.Category.Base where
open import Level
open import Relation.Binary using
(Rel ; IsEquivalence ; _Preserves_⟶_ ; _Preserves₂_⟶_⟶_ ; Setoid)
open import Relation.Binary.EqReasoning as EqReasoning
import Cats.Util.SetoidReasoning as SetoidR
record Category lo la l≈ : Set (suc (lo ⊔ la ⊔ l≈)) where
infixr 9 _∘_
infix 4 _≈_
infixr -1 _⇒_
field
Obj : Set lo
_⇒_ : Obj → Obj → Set la
_≈_ : ∀ {A B} → Rel (A ⇒ B) l≈
id : {O : Obj} → O ⇒ O
_∘_ : ∀ {A B C} → B ⇒ C → A ⇒ B → A ⇒ C
equiv : ∀ {A B} → IsEquivalence (_≈_ {A} {B})
∘-resp : ∀ {A B C} → (_∘_ {A} {B} {C}) Preserves₂ _≈_ ⟶ _≈_ ⟶ _≈_
id-r : ∀ {A B} {f : A ⇒ B} → f ∘ id ≈ f
id-l : ∀ {A B} {f : A ⇒ B} → id ∘ f ≈ f
assoc : ∀ {A B C D} {f : C ⇒ D} {g : B ⇒ C} {h : A ⇒ B}
→ (f ∘ g) ∘ h ≈ f ∘ (g ∘ h)
Hom : (A B : Obj) → Setoid la l≈
Hom A B = record
{ Carrier = A ⇒ B
; _≈_ = _≈_
; isEquivalence = equiv
}
module ≈ {A B} = IsEquivalence (equiv {A} {B})
module ≈-Reasoning {A B} where
open EqReasoning (Hom A B) public
triangle = SetoidR.triangle (Hom A B)
unassoc : ∀ {A B C D} {f : C ⇒ D} {g : B ⇒ C} {h : A ⇒ B}
→ f ∘ (g ∘ h) ≈ (f ∘ g) ∘ h
unassoc = ≈.sym assoc
∘-resp-r : ∀ {A B C} {f : B ⇒ C} → (_∘_ {A} f) Preserves _≈_ ⟶ _≈_
∘-resp-r eq = ∘-resp ≈.refl eq
∘-resp-l : ∀ {A B C} {g : A ⇒ B} → (λ f → _∘_ {C = C} f g) Preserves _≈_ ⟶ _≈_
∘-resp-l eq = ∘-resp eq ≈.refl
| {
"alphanum_fraction": 0.4901158828,
"avg_line_length": 25.2931034483,
"ext": "agda",
"hexsha": "4eaace3e68c9258d5a49116998fdead0449eb4fb",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "alessio-b-zak/cats",
"max_forks_repo_path": "Cats/Category/Base.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "alessio-b-zak/cats",
"max_issues_repo_path": "Cats/Category/Base.agda",
"max_line_length": 81,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "alessio-b-zak/cats",
"max_stars_repo_path": "Cats/Category/Base.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 686,
"size": 1467
} |
{-# OPTIONS --rewriting --confluence-check #-}
open import Agda.Builtin.Equality
open import Agda.Builtin.Equality.Rewrite
postulate
A : Set
a b : A
f : (A → A) → A
g : A → A
rewf₁ : f (λ x → g x) ≡ a
rewf₂ : f (λ x → a) ≡ b
rewg : (x : A) → g x ≡ a
{-# REWRITE rewf₁ rewf₂ rewg #-}
| {
"alphanum_fraction": 0.5629139073,
"avg_line_length": 16.7777777778,
"ext": "agda",
"hexsha": "e08a58e643ac6e4278238051214dc1180e31dfce",
"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/Issue3816.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/Issue3816.agda",
"max_line_length": 46,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/Issue3816.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": 124,
"size": 302
} |
-- 2011-04-12 AIM XIII fixed this issue by freezing metas after declaration (Andreas & Ulf)
module Issue399 where
open import Common.Prelude
data Maybe (A : Set) : Set where
nothing : Maybe A
just : A → Maybe A
-- now in Common.Prelude
-- _++_ : {A : Set} → List A → List A → List A
-- [] ++ ys = ys
-- (x ∷ xs) ++ ys = x ∷ (xs ++ ys)
record MyMonadPlus m : Set₁ where
field mzero : {a : Set} → m a → List a
mplus : {a : Set} → m a → m a → List a
-- this produces an unsolved meta variable, because it is not clear which
-- level m has. m could be in Set -> Set or in Set -> Set1
-- if you uncomment the rest of the files, you get unsolved metas here
{- Old error, without freezing:
--Emacs error: and the 10th line is the above line
--/home/j/dev/apps/haskell/agda/learn/bug-in-record.agda:10,36-39
--Set != Set₁
--when checking that the expression m a has type Set₁
-}
mymaybemzero : {a : Set} → Maybe a → List a
mymaybemzero nothing = []
mymaybemzero (just x) = x ∷ []
mymaybemplus : {a : Set} → Maybe a → Maybe a → List a
mymaybemplus x y = (mymaybemzero x) ++ (mymaybemzero y)
-- the following def gives a type error because of unsolved metas in MyMonadPlus
-- if you uncomment it, you see m in MyMonadPlus yellow
mymaybeMonadPlus : MyMonadPlus Maybe
mymaybeMonadPlus = record { mzero = mymaybemzero
; mplus = mymaybemplus }
| {
"alphanum_fraction": 0.6568557071,
"avg_line_length": 32.3953488372,
"ext": "agda",
"hexsha": "67db62d4183a074b09c639cc89c2a9f778ae255a",
"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/Issue399.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/Issue399.agda",
"max_line_length": 91,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "larrytheliquid/agda",
"max_stars_repo_path": "test/fail/Issue399.agda",
"max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z",
"num_tokens": 451,
"size": 1393
} |
{-# OPTIONS --show-implicit #-}
open import Agda.Builtin.Nat
open import Agda.Builtin.Equality
open import Agda.Builtin.Unit
postulate
A B C D : Set
F : (A → A) → (A → A → A) → A
a : A
data Tree : Set where
leaf : Tree
node : (f : (x : A) → Tree) → Tree
tree1 : Nat → Tree
tree1 zero = leaf
tree1 (suc n) = node (λ x → tree1 n)
tree2 : Nat → Tree
tree2 zero = leaf
tree2 (suc n) = node (λ x → tree2 n)
-- In Agda 2.6.0.1, this takes >50 sec and >5GB to typecheck.
test : tree1 5000 ≡ tree2 5000
test = refl
| {
"alphanum_fraction": 0.6195028681,
"avg_line_length": 19.3703703704,
"ext": "agda",
"hexsha": "cdcf326fe906c0c081553b3e19067da4529b873c",
"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/Issue4044.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/Issue4044.agda",
"max_line_length": 61,
"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/Issue4044.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 201,
"size": 523
} |
module FlatDomInequality where
postulate
A : Set
g : A → A
g x = x
-- this is fine
h : (@♭ x : A) → A
h = g
-- this should fail, although the error message should be improved.
q : A → A
q = h
| {
"alphanum_fraction": 0.605,
"avg_line_length": 11.1111111111,
"ext": "agda",
"hexsha": "cff0f0d83dd35a9616b0d9205eb18d374338a67c",
"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": "d6a705ba40d8ba2a5bb550bc40eddc280aedbf2b",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Soares/agda",
"max_forks_repo_path": "test/Fail/FlatDomInequality.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "d6a705ba40d8ba2a5bb550bc40eddc280aedbf2b",
"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": "Soares/agda",
"max_issues_repo_path": "test/Fail/FlatDomInequality.agda",
"max_line_length": 67,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "d6a705ba40d8ba2a5bb550bc40eddc280aedbf2b",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "Soares/agda",
"max_stars_repo_path": "test/Fail/FlatDomInequality.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 70,
"size": 200
} |
{-# OPTIONS --prop --rewriting #-}
module Examples.Sorting where
import Examples.Sorting.Sequential
import Examples.Sorting.Parallel
| {
"alphanum_fraction": 0.7851851852,
"avg_line_length": 19.2857142857,
"ext": "agda",
"hexsha": "f63143a761563b3f38c21371eb4641ad120cbbcf",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-01-29T08:12:01.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-10-06T10:28:24.000Z",
"max_forks_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "jonsterling/agda-calf",
"max_forks_repo_path": "src/Examples/Sorting.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146",
"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": "jonsterling/agda-calf",
"max_issues_repo_path": "src/Examples/Sorting.agda",
"max_line_length": 34,
"max_stars_count": 29,
"max_stars_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "jonsterling/agda-calf",
"max_stars_repo_path": "src/Examples/Sorting.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-22T20:35:11.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-07-14T03:18:28.000Z",
"num_tokens": 27,
"size": 135
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Automatic solvers for equations over integers
------------------------------------------------------------------------
-- See README.Integer for examples of how to use this solver
{-# OPTIONS --without-K --safe #-}
module Data.Integer.Tactic.RingSolver where
open import Agda.Builtin.Reflection
open import Data.Maybe.Base using (just; nothing)
open import Data.Integer.Base
open import Data.Integer.Properties
open import Level using (0ℓ)
open import Data.Unit using (⊤)
open import Relation.Binary.PropositionalEquality
import Tactic.RingSolver as Solver
import Tactic.RingSolver.Core.AlmostCommutativeRing as ACR
------------------------------------------------------------------------
-- A module for automatically solving propositional equivalences
-- containing _+_ and _*_
ring : ACR.AlmostCommutativeRing 0ℓ 0ℓ
ring = ACR.fromCommutativeRing +-*-commutativeRing
λ { +0 → just refl; _ → nothing }
macro
solve-∀ : Term → TC ⊤
solve-∀ = Solver.solve-∀-macro (quote ring)
macro
solve : Term → Term → TC ⊤
solve n = Solver.solve-macro n (quote ring)
| {
"alphanum_fraction": 0.6144067797,
"avg_line_length": 30.2564102564,
"ext": "agda",
"hexsha": "ea4a00403f515fabedaf83dd8837cbffd09b032b",
"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/Integer/Tactic/RingSolver.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/Integer/Tactic/RingSolver.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/Integer/Tactic/RingSolver.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": 263,
"size": 1180
} |
open import Relation.Binary
open import Level
module GGT.Setoid
{a ℓ}
(S : Setoid a ℓ)
(l : Level)
where
open import Level
open Setoid S
open import Data.Product
open import Relation.Unary
open import Relation.Binary.Construct.On renaming (isEquivalence to isEq)
open import Function
subSetoid : (Pred Carrier l) → Setoid (a ⊔ l) ℓ
subSetoid P =
record { Carrier = Σ Carrier P ;
_≈_ = (_≈_ on proj₁) ;
isEquivalence = isEq proj₁ isEquivalence }
| {
"alphanum_fraction": 0.6958333333,
"avg_line_length": 21.8181818182,
"ext": "agda",
"hexsha": "b205c9651a378cab0c0cad41e04911e7406c9149",
"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/Setoid.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/Setoid.agda",
"max_line_length": 73,
"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/Setoid.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": 144,
"size": 480
} |
open import SOAS.Metatheory.Syntax
-- Metatheory of a second-order syntax
module SOAS.Metatheory {T : Set} (Syn : Syntax {T}) where
open import SOAS.Families.Core {T}
open import SOAS.Abstract.ExpStrength
open Syntax Syn
open CompatStrengths ⅀:CS public renaming (CoalgStr to ⅀:Str ; ExpStr to ⅀:ExpStr)
open import SOAS.Metatheory.Algebra ⅀F public
open import SOAS.Metatheory.Monoid ⅀F ⅀:Str public
module Theory (𝔛 : Familyₛ) where
open import SOAS.Metatheory.MetaAlgebra ⅀F 𝔛 public
open import SOAS.Metatheory.Semantics ⅀F ⅀:Str 𝔛 (𝕋:Init 𝔛) public
open import SOAS.Metatheory.Traversal ⅀F ⅀:Str 𝔛 (𝕋:Init 𝔛) public
open import SOAS.Metatheory.Renaming ⅀F ⅀:Str 𝔛 (𝕋:Init 𝔛) public
open import SOAS.Metatheory.Coalgebraic ⅀F ⅀:Str 𝔛 (𝕋:Init 𝔛) public
open import SOAS.Metatheory.Substitution ⅀F ⅀:Str 𝔛 (𝕋:Init 𝔛) public
| {
"alphanum_fraction": 0.7337962963,
"avg_line_length": 34.56,
"ext": "agda",
"hexsha": "bf4136d47bd825de8998f1c07db4462f279b7234",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z",
"max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "JoeyEremondi/agda-soas",
"max_forks_repo_path": "SOAS/Metatheory.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8",
"max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "JoeyEremondi/agda-soas",
"max_issues_repo_path": "SOAS/Metatheory.agda",
"max_line_length": 82,
"max_stars_count": 39,
"max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "JoeyEremondi/agda-soas",
"max_stars_repo_path": "SOAS/Metatheory.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z",
"num_tokens": 353,
"size": 864
} |
{-# OPTIONS --universe-polymorphism #-}
open import Level
module Categories.Terminal {o ℓ e : Level} where
open import Categories.Category
open import Categories.Functor
open import Categories.Categories
import Categories.Object.Terminal as Terminal
open Terminal (Categories o ℓ e)
record Unit {x : _} : Set x where
constructor unit
OneC : Category o ℓ e
OneC = record
{ Obj = Unit
; _⇒_ = λ _ _ → Unit
; _≡_ = λ _ _ → Unit
; _∘_ = λ _ _ → unit
; id = unit
; assoc = unit
; identityˡ = unit
; identityʳ = unit
; equiv = record
{ refl = unit
; sym = λ _ → unit
; trans = λ _ _ → unit
}
; ∘-resp-≡ = λ _ _ → unit
}
-- I can probably use Discrete here once we get universe cumulativity in Agda
One : Terminal
One = record
{ ⊤ = OneC
; ! = record
{ F₀ = λ _ → unit
; F₁ = λ _ → unit
; identity = unit
; homomorphism = unit
; F-resp-≡ = λ _ → unit
}
; !-unique = λ _ _ → Heterogeneous.≡⇒∼ unit
}
| {
"alphanum_fraction": 0.6047227926,
"avg_line_length": 20.2916666667,
"ext": "agda",
"hexsha": "bb4a0d776f37d4a6fc0d5829bfcbf6306f06f673",
"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/Terminal.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/Terminal.agda",
"max_line_length": 77,
"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/Terminal.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": 332,
"size": 974
} |
-- Andreas, 2013-11-23
-- Make sure sized types work with extended lambda
{-# OPTIONS --copatterns --sized-types #-}
-- {-# OPTIONS -v tc.def:100 -v tc.size:100 -v tc.meta.assign:20 #-}
module SizedTypesExtendedLambda where
open import Common.Size
data Maybe (A : Set) : Set where
nothing : Maybe A
just : A → Maybe A
mutual
data Delay (A : Set) (i : Size) : Set where
fail : Delay A i
now : A → Delay A i
later : ∞Delay A i → Delay A i
record ∞Delay (A : Set) (i : Size) : Set where
coinductive
constructor delay
field
force : {j : Size< i} → Delay A j
open ∞Delay
postulate
A : Set
something : ∀ {C : Set} → (Maybe A → C) → C
mutual
test : {i : Size} → Delay A i
test = something λ
{ nothing -> fail
; (just a) -> later (∞test a)
}
∞test : {i : Size} (a : A) → ∞Delay A i
force (∞test a) {j = _} = test
-- force (∞test a) = test -- still fails, unfortunately
| {
"alphanum_fraction": 0.5693581781,
"avg_line_length": 21.4666666667,
"ext": "agda",
"hexsha": "cf4b4fe00c514d6d47daa5bcfdf3a9a91797864c",
"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/SizedTypesExtendedLambda.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/SizedTypesExtendedLambda.agda",
"max_line_length": 68,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "larrytheliquid/agda",
"max_stars_repo_path": "test/succeed/SizedTypesExtendedLambda.agda",
"max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z",
"num_tokens": 321,
"size": 966
} |
module Numeral.Natural.Oper.FlooredDivision where
import Lvl
open import Data
open import Data.Boolean.Stmt
open import Logic.Propositional.Theorems
open import Numeral.Natural
open import Numeral.Natural.Oper.Comparisons
open import Numeral.Natural.Oper.Comparisons.Proofs
open import Numeral.Natural.Relation.Order
open import Relator.Equals
infixl 10100 _⌊/⌋_
-- Inductive definition of an algorithm for division.
-- `[ d , b ] a' div b'` should be interpreted as following:
-- `d` is the result of the algorithm that is being incremented as it runs.
-- `b` is the predecessor of the original denominator. This is constant throughout the whole process.
-- `a'` is the numerator. This is decremented as it runs.
-- `b'` is the predecessor of the temporary denominator. This is decremented as it runs.
-- By decrementing both `a'` and `b'`, and incrementing `d` when 'b`' reaches 0, it counts how many times `b` "fits into" `a`.
-- Note: See Numeral.Natural.Oper.Modulo for a similiar algorithm used to determine the modulo.
[_,_]_div_ : ℕ → ℕ → ℕ → ℕ → ℕ
[ d , _ ] 𝟎 div _ = d
[ d , b ] 𝐒(a') div 𝟎 = [ 𝐒(d) , b ] a' div b
[ d , b ] 𝐒(a') div 𝐒(b') = [ d , b ] a' div b'
{-# BUILTIN NATDIVSUCAUX [_,_]_div_ #-}
-- Floored division operation.
_⌊/⌋_ : ℕ → (m : ℕ) → .⦃ _ : IsTrue(positive?(m)) ⦄ → ℕ
a ⌊/⌋ 𝐒(m) = [ 𝟎 , m ] a div m
_⌊/⌋₀_ : ℕ → ℕ → ℕ
_ ⌊/⌋₀ 𝟎 = 𝟎
a ⌊/⌋₀ 𝐒(m) = a ⌊/⌋ 𝐒(m)
{-# INLINE _⌊/⌋₀_ #-}
| {
"alphanum_fraction": 0.6592643997,
"avg_line_length": 38.9459459459,
"ext": "agda",
"hexsha": "520841b7d5d06549b07ff7c2f5b25b4be908a75d",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Numeral/Natural/Oper/FlooredDivision.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Numeral/Natural/Oper/FlooredDivision.agda",
"max_line_length": 127,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Numeral/Natural/Oper/FlooredDivision.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": 532,
"size": 1441
} |
module Typed.LTLC where
open import Prelude
open import Function
open import Level
open import Category.Monad
open import Relation.Unary.PredicateTransformer using (PT; Pt)
open import Relation.Ternary.Separation.Construct.Unit
open import Relation.Ternary.Separation.Allstar
open import Relation.Ternary.Separation.Monad
open import Relation.Ternary.Separation.Morphisms
open import Relation.Ternary.Separation.Monad.Reader
open import Relation.Ternary.Separation.Monad.Delay
data Ty : Set where
unit : Ty
_⊸_ : (a b : Ty) → Ty
open import Relation.Ternary.Separation.Construct.List Ty
Ctx = List Ty
CtxT = List Ty → List Ty
infixr 20 _◂_
_◂_ : Ty → CtxT → CtxT
(x ◂ f) Γ = x ∷ f Γ
variable a b : Ty
variable ℓv : Level
variable τ : Set ℓv
variable Γ Γ₁ Γ₂ Γ₃ : List τ
data Exp : Ty → Ctx → Set where
-- a base type
tt : ε[ Exp unit ]
letunit : ∀[ Exp unit ✴ Exp a ⇒ Exp a ]
-- the λ-calculus
lam : ∀[ (a ◂ id ⊢ Exp b) ⇒ Exp (a ⊸ b) ]
ap : ∀[ Exp (a ⊸ b) ✴ Exp a ⇒ Exp b ]
var : ∀[ Just a ⇒ Exp a ]
module _ {{m : MonoidalSep 0ℓ}} where
open MonoidalSep m using (Carrier)
CPred : Set₁
CPred = Carrier → Set
mutual
Env : Ctx → CPred
Env = Allstar Val
data Val : Ty → CPred where
tt : ε[ Val unit ]
clos : Exp b (a ∷ Γ) → ∀[ Env Γ ⇒ Val (a ⊸ b) ]
module _ {i : Size} where
open ReaderTransformer id-morph Val (Delay i) public
open Monads.Monad reader-monad public
M : Size → (Γ₁ Γ₂ : Ctx) → CPred → CPred
M i = Reader {i}
open Monads using (str; _&_; typed-str)
mutual
eval : ∀ {i} → Exp a Γ → ε[ M i Γ ε (Val a) ]
eval tt = do
return tt
eval (letunit (e₁ ×⟨ Γ≺ ⟩ e₂)) = do
tt ← frame Γ≺ (►eval e₁)
►eval e₂
eval (lam e) = do
env ← ask
return (clos e env)
eval (ap (f ×⟨ Γ≺ ⟩ e)) = do
clos body env ← frame Γ≺ (►eval f)
v ×⟨ σ ⟩ env ← ►eval e & env
empty ← append (v :⟨ σ ⟩: env)
►eval body
eval (var refl) = do
lookup
►eval : ∀ {i} → Exp a Γ → ε[ M i Γ ε (Val a) ]
app (►eval e) E σ = later (λ where .force → app (eval e) E σ)
| {
"alphanum_fraction": 0.5975666823,
"avg_line_length": 23.2282608696,
"ext": "agda",
"hexsha": "856b088810e6804c4bf5b9cc2430a79521dbdfbf",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2020-05-23T00:34:36.000Z",
"max_forks_repo_forks_event_min_datetime": "2020-01-30T14:15:14.000Z",
"max_forks_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "laMudri/linear.agda",
"max_forks_repo_path": "src/Typed/LTLC.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0",
"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": "laMudri/linear.agda",
"max_issues_repo_path": "src/Typed/LTLC.agda",
"max_line_length": 65,
"max_stars_count": 34,
"max_stars_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "laMudri/linear.agda",
"max_stars_repo_path": "src/Typed/LTLC.agda",
"max_stars_repo_stars_event_max_datetime": "2021-02-03T15:22:33.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-12-20T13:57:50.000Z",
"num_tokens": 759,
"size": 2137
} |
-- Andreas, 2022-06-10, issue #5922, reported by j-towns.
-- Lack of normalization of data projections against data constructors
-- breaks termination checker applied to extended lambda gone through
-- forcing translation and reflection.
-- The workaround was to turn off the forcing translation:
-- {-# OPTIONS --no-forcing #-}
-- {-# OPTIONS -v term:20 #-}
open import Agda.Builtin.Nat
open import Agda.Builtin.Reflection
open import Agda.Builtin.Unit
data Fin : Nat → Set where
fz : (b : Nat) → Fin (suc b)
fs : (b : Nat) → Fin b → Fin (suc b)
apply : {A B C : Set} (input : A) (f : A → B) (cont : B → C) → C
apply input f cont = cont (f input)
macro
id-macro : (b : Nat) → (Fin b → Nat) → Term → TC ⊤
id-macro b f hole =
bindTC (quoteTC f) λ f-term →
unify hole f-term
test : (b : Nat) → Fin b → Nat
test b = id-macro b λ where
(fz _) → zero
(fs a x) → apply x (test a) suc
-- Should termination check.
-- WAS:
-- Termination checking failed for the following functions:
-- test
-- Problematic calls:
-- λ { (fz .(Agda.Builtin.Nat.suc-0 _)) → zero
-- ; (fs .(Agda.Builtin.Nat.suc-0 _) x)
-- → apply x
-- (test (Agda.Builtin.Nat.suc-0 (suc (Agda.Builtin.Nat.suc-0 b))))
-- suc
-- }
-- test (Agda.Builtin.Nat.suc-0 (suc b))
--
-- This shows data projection Agda.Builtin.Nat.suc-0 applied to data constructor
-- suc, which should be normalized away.
| {
"alphanum_fraction": 0.625,
"avg_line_length": 29.2244897959,
"ext": "agda",
"hexsha": "536fded26e16224942efaa7802c0eba2a8b2c9ac",
"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/Issue5922.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "KDr2/agda",
"max_issues_repo_path": "test/Succeed/Issue5922.agda",
"max_line_length": 80,
"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/Issue5922.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 452,
"size": 1432
} |
module _ where
module M where
private
module _ (A : Set) where
Id : Set
Id = A
foo : Set → Set
foo A = Id A
open M
bar : Set → Set
bar A = Id A -- Id should not be in scope
| {
"alphanum_fraction": 0.56,
"avg_line_length": 11.7647058824,
"ext": "agda",
"hexsha": "a0411b80076e2ce010c94392acf3e0a3c74143b9",
"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/Issue2199.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/Issue2199.agda",
"max_line_length": 41,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/Issue2199.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 68,
"size": 200
} |
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2020 Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
open import LibraBFT.Prelude
open import LibraBFT.Lemmas
open import LibraBFT.Base.Encode
open import LibraBFT.Base.ByteString
-- This module defines Hash functions, and related properties
module LibraBFT.Hash where
-------------------------------------------------
-- Hash function postulates
--
-- We are now assuming that our 'auth' function is collision
-- resistant. We might be able to carry the full proof in agda,
-- but that can take place on another module.
Hash : Set
Hash = Σ ByteString (λ bs → length bs ≡ 4)
hashLen-pi : ∀ {bs : ByteString} {n : ℕ } → (p1 p2 : length bs ≡ n) → p1 ≡ p2
hashLen-pi {[]} {.0} refl refl = refl
hashLen-pi {h ∷ t} {.(suc (length t))} refl refl = refl
sameBS⇒sameHash : ∀ {h1 h2 : Hash}
→ proj₁ h1 ≡ proj₁ h2
→ h1 ≡ h2
sameBS⇒sameHash { h1a , h1b } { h2a , h2b } refl rewrite hashLen-pi {h2a} h1b h2b = refl
_≟Hash_ : (h₁ h₂ : Hash) → Dec (h₁ ≡ h₂)
(l , pl) ≟Hash (m , pm) with List-≡-dec (Vec-≡-dec _≟Bool_) l m
...| yes refl = yes (cong (_,_ l) (≡-pi pl pm))
...| no abs = no (abs ∘ ,-injectiveˡ)
encodeH : Hash → ByteString
encodeH (bs , _) = bs
encodeH-inj : ∀ i j → encodeH i ≡ encodeH j → i ≡ j
encodeH-inj (i , pi) (j , pj) refl = cong (_,_ i) (≡-pi pi pj)
encodeH-len : ∀{h} → length (encodeH h) ≡ 4
encodeH-len { bs , p } = p
encodeH-len-lemma : ∀ i j → length (encodeH i) ≡ length (encodeH j)
encodeH-len-lemma i j = trans (encodeH-len {i}) (sym (encodeH-len {j}))
-- Which means that we can make a helper function that combines
-- the necessary injections into one big injection
++b-2-inj : (h₁ h₂ : Hash){l₁ l₂ : Hash}
→ encodeH h₁ ++ encodeH l₁ ≡ encodeH h₂ ++ encodeH l₂
→ h₁ ≡ h₂ × l₁ ≡ l₂
++b-2-inj h₁ h₂ {l₁} {l₂} hip
with ++-inj {m = encodeH h₁} {n = encodeH h₂} (encodeH-len-lemma h₁ h₂) hip
...| hh , ll = encodeH-inj h₁ h₂ hh , encodeH-inj l₁ l₂ ll
Collision : {A B : Set}(f : A → B)(a₁ a₂ : A) → Set
Collision f a₁ a₂ = a₁ ≢ a₂ × f a₁ ≡ f a₂
instance
enc-Hash : Encoder Hash
enc-Hash = record
{ encode = encodeH
; encode-inj = encodeH-inj _ _
}
module WithCryptoHash
-- A Hash function maps a bytestring into a hash.
(hash : BitString → Hash)
(hash-cr : ∀{x y} → hash x ≡ hash y → Collision hash x y ⊎ x ≡ y) where
-- We define the concatenation of hashes like one would expect
hash-concat : List Hash → Hash
hash-concat l = hash (bs-concat (List-map encodeH l))
-- And voila, it is either injective ot we broke the hash function!
hash-concat-inj : ∀{l₁ l₂} → hash-concat l₁ ≡ hash-concat l₂ → NonInjective-≡ hash ⊎ l₁ ≡ l₂
hash-concat-inj {l₁} {l₂} hyp with hash-cr hyp
...| inj₁ col = inj₁ ((_ , _) , col)
...| inj₂ same with bs-concat-inj (List-map encodeH l₁) (List-map encodeH l₂) same
...| res = inj₂ (map-inj encodeH (encodeH-inj _ _) res)
where
map-inj : ∀{a b}{A : Set a}{B : Set b}(f : A → B)
→ (f-injective : ∀{a₁ a₂} → f a₁ ≡ f a₂ → a₁ ≡ a₂)
→ ∀{xs ys} → List-map f xs ≡ List-map f ys → xs ≡ ys
map-inj f finj {[]} {[]} hyp = refl
map-inj f finj {x ∷ xs} {y ∷ ys} hyp
= cong₂ _∷_ (finj (proj₁ (∷-injective hyp)))
(map-inj f finj (proj₂ (∷-injective hyp)))
| {
"alphanum_fraction": 0.5989167617,
"avg_line_length": 37.3191489362,
"ext": "agda",
"hexsha": "9dfe29100c08f29ab4dd5076657003ffd6664220",
"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": "LibraBFT/Hash.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": "LibraBFT/Hash.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": "LibraBFT/Hash.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1254,
"size": 3508
} |
{-# OPTIONS --cubical --no-import-sorts --guardedness --safe #-}
module Cubical.Codata.M.AsLimit.stream where
open import Cubical.Data.Unit
open import Cubical.Foundations.Prelude
open import Cubical.Codata.M.AsLimit.M
open import Cubical.Codata.M.AsLimit.helper
open import Cubical.Codata.M.AsLimit.Container
--------------------------------------
-- Stream definitions using M.AsLimit --
--------------------------------------
stream-S : ∀ A -> Container ℓ-zero
stream-S A = (A , (λ _ → Unit))
stream : ∀ (A : Type₀) -> Type₀
stream A = M (stream-S A)
cons : ∀ {A} -> A -> stream A -> stream A
cons x xs = in-fun (x , λ { tt -> xs } )
hd : ∀ {A} -> stream A -> A
hd {A} S = out-fun S .fst
tl : ∀ {A} -> stream A -> stream A
tl {A} S = out-fun S .snd tt
| {
"alphanum_fraction": 0.5816993464,
"avg_line_length": 24.6774193548,
"ext": "agda",
"hexsha": "b7677f7cc31e5b2a2690104ca775b033b2dd0933",
"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/Codata/M/AsLimit/stream.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/Codata/M/AsLimit/stream.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/Codata/M/AsLimit/stream.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 220,
"size": 765
} |
module Sized.SimpleCell where
open import Data.Product
open import Data.String.Base
open import SizedIO.Object
open import SizedIO.IOObject
open import SizedIO.ConsoleObject
open import SizedIO.Base
open import SizedIO.Console hiding (main)
open import NativeIO
open import Size
data CellMethod A : Set where
get : CellMethod A
put : A → CellMethod A
CellResult : ∀{A} → CellMethod A → Set
CellResult {A} get = A
CellResult (put _) = Unit
-- cellJ is the interface of the object of a simple cell
cellJ : (A : Set) → Interface
Method (cellJ A) = CellMethod A
Result (cellJ A) m = CellResult m
cell : {A : Set} → A → Object (cellJ A)
objectMethod (cell a) get = a , (cell a)
objectMethod (cell a) (put a') = _ , (cell a')
-- cellC is the type of consoleObjects with interface (cellJ String)
CellC : (i : Size) → Set
CellC i = ConsoleObject i (cellJ String)
-- cellO is a program for a simple cell which
-- when get is called writes "getting s" for the string s of the object
-- and when putting s writes "putting s" for the string
-- cellP is constructor for the consoleObject for interface (cellJ String)
cellP : ∀{i} (s : String) → CellC i
force (method (cellP s) get) =
exec' (putStrLn ("getting (" ++ s ++ ")")) λ _ →
return (s , cellP s)
force (method (cellP s) (put x)) =
exec' (putStrLn ("putting (" ++ x ++ ")")) λ _ →
return (_ , (cellP x))
-- Program is another program
program : String → IOConsole ∞ Unit
program arg =
let c₀ = cellP "Start" in
method c₀ get >>= λ{ (s , c₁) →
exec1 (putStrLn s) >>
method c₁ (put arg) >>= λ{ (_ , c₂) →
method c₂ get >>= λ{ (s' , c₃) →
exec1 (putStrLn s')
}}}
main : NativeIO Unit
main = translateIOConsole (program "hello")
| {
"alphanum_fraction": 0.6582423894,
"avg_line_length": 26.7846153846,
"ext": "agda",
"hexsha": "5a457c0b1014ae8cc14aefd5927f3f0fddccddd3",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z",
"max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "agda/ooAgda",
"max_forks_repo_path": "examples/Sized/SimpleCell.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "agda/ooAgda",
"max_issues_repo_path": "examples/Sized/SimpleCell.agda",
"max_line_length": 74,
"max_stars_count": 23,
"max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "agda/ooAgda",
"max_stars_repo_path": "examples/Sized/SimpleCell.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z",
"num_tokens": 536,
"size": 1741
} |
module functions where
open import level
open import eq
{- Note that the Agda standard library has an interesting generalization
of the following basic composition operator, with more dependent typing. -}
_∘_ : ∀{ℓ ℓ' ℓ''}{A : Set ℓ}{B : Set ℓ'}{C : Set ℓ''} →
(B → C) → (A → B) → (A → C)
f ∘ g = λ x → f (g x)
∘-assoc : ∀{ℓ ℓ' ℓ'' ℓ'''}{A : Set ℓ}{B : Set ℓ'}{C : Set ℓ''}{D : Set ℓ'''}
(f : C → D)(g : B → C)(h : A → B) → (f ∘ g) ∘ h ≡ f ∘ (g ∘ h)
∘-assoc f g h = refl
id : ∀{ℓ}{A : Set ℓ} → A → A
id = λ x → x
∘-id : ∀{ℓ ℓ'}{A : Set ℓ}{B : Set ℓ'}(f : A → B) → f ∘ id ≡ f
∘-id f = refl
id-∘ : ∀{ℓ ℓ'}{A : Set ℓ}{B : Set ℓ'}(f : A → B) → id ∘ f ≡ f
id-∘ f = refl
extensionality : {ℓ₁ ℓ₂ : Level} → Set (lsuc ℓ₁ ⊔ lsuc ℓ₂)
extensionality {ℓ₁}{ℓ₂} = ∀{A : Set ℓ₁}{B : Set ℓ₂}{f g : A → B} → (∀{a : A} → f a ≡ g a) → f ≡ g
record Iso {ℓ₁ ℓ₂ : Level} (A : Set ℓ₁) (B : Set ℓ₂) : Set (ℓ₁ ⊔ ℓ₂) where
constructor isIso
field
l-inv : A → B
r-inv : B → A
l-cancel : r-inv ∘ l-inv ≡ id
r-cancel : l-inv ∘ r-inv ≡ id
| {
"alphanum_fraction": 0.4909781576,
"avg_line_length": 29.25,
"ext": "agda",
"hexsha": "a89b389e21976bbc9da520156279740b511ed1e2",
"lang": "Agda",
"max_forks_count": 17,
"max_forks_repo_forks_event_max_datetime": "2021-11-28T20:13:21.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-12-03T22:38:15.000Z",
"max_forks_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "rfindler/ial",
"max_forks_repo_path": "functions.agda",
"max_issues_count": 8,
"max_issues_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6",
"max_issues_repo_issues_event_max_datetime": "2022-03-22T03:43:34.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-07-09T22:53:38.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "rfindler/ial",
"max_issues_repo_path": "functions.agda",
"max_line_length": 97,
"max_stars_count": 29,
"max_stars_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "rfindler/ial",
"max_stars_repo_path": "functions.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-04T15:05:12.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-02-06T13:09:31.000Z",
"num_tokens": 509,
"size": 1053
} |
module Issue4835.ModB where
data B : Set where
b : B -> B
| {
"alphanum_fraction": 0.6557377049,
"avg_line_length": 12.2,
"ext": "agda",
"hexsha": "aef28e9ada311a2a928383b24ab71988d81af567",
"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/interaction/Issue4835/ModB.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/interaction/Issue4835/ModB.agda",
"max_line_length": 27,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/interaction/Issue4835/ModB.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 21,
"size": 61
} |
{-# OPTIONS --safe --warning=error --without-K #-}
open import LogicalFormulae
open import Setoids.Setoids
open import Functions.Definition
open import Groups.Definition
open import Sets.EquivalenceRelations
open import Groups.Isomorphisms.Definition
open import Groups.Homomorphisms.Definition
open import Groups.Homomorphisms.Lemmas
module Groups.Isomorphisms.Lemmas where
groupIsosCompose : {m n o r s t : _} {A : Set m} {S : Setoid {m} {r} A} {_+A_ : A → A → A} {B : Set n} {T : Setoid {n} {s} B} {_+B_ : B → B → B} {C : Set o} {U : Setoid {o} {t} C} {_+C_ : C → C → C} {G : Group S _+A_} {H : Group T _+B_} {I : Group U _+C_} {f : A → B} {g : B → C} (fHom : GroupIso G H f) (gHom : GroupIso H I g) → GroupIso G I (g ∘ f)
GroupIso.groupHom (groupIsosCompose fHom gHom) = groupHomsCompose (GroupIso.groupHom fHom) (GroupIso.groupHom gHom)
GroupIso.bij (groupIsosCompose {A = A} {S = S} {T = T} {C = C} {U = U} {f = f} {g = g} fHom gHom) = record { inj = record { injective = λ pr → (SetoidInjection.injective (SetoidBijection.inj (GroupIso.bij fHom))) (SetoidInjection.injective (SetoidBijection.inj (GroupIso.bij gHom)) pr) ; wellDefined = +WellDefined } ; surj = record { surjective = surj ; wellDefined = +WellDefined } }
where
open Setoid S renaming (_∼_ to _∼A_)
open Setoid U renaming (_∼_ to _∼C_)
+WellDefined : {x y : A} → (x ∼A y) → (g (f x) ∼C g (f y))
+WellDefined = GroupHom.wellDefined (groupHomsCompose (GroupIso.groupHom fHom) (GroupIso.groupHom gHom))
surj : {x : C} → Sg A (λ a → (g (f a) ∼C x))
surj {x} with SetoidSurjection.surjective (SetoidBijection.surj (GroupIso.bij gHom)) {x}
surj {x} | a , prA with SetoidSurjection.surjective (SetoidBijection.surj (GroupIso.bij fHom)) {a}
... | b , prB = b , transitive (GroupHom.wellDefined (GroupIso.groupHom gHom) prB) prA
where
open Equivalence (Setoid.eq U)
--groupIsoInvertible : {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d}} {_+A_ : A → A → A} {_+B_ : B → B → B} {G : Group S _+A_} {H : Group T _+B_} {f : A → B} → (iso : GroupIso G H f) → GroupIso H G (Invertible.inverse (bijectionImpliesInvertible (GroupIso.bijective iso)))
--GroupHom.groupHom (GroupIso.groupHom (groupIsoInvertible {G = G} {H} {f} iso)) {x} {y} = {!!}
-- where
-- open Group G renaming (_·_ to _+G_)
-- open Group H renaming (_·_ to _+H_)
--GroupHom.wellDefined (GroupIso.groupHom (groupIsoInvertible {G = G} {H} {f} iso)) {x} {y} x∼y = {!GroupHom.wellDefined x∼y!}
--GroupIso.bijective (groupIsoInvertible {G = G} {H} {f} iso) = invertibleImpliesBijection (inverseIsInvertible (bijectionImpliesInvertible (GroupIso.bijective iso)))
| {
"alphanum_fraction": 0.657687991,
"avg_line_length": 74.25,
"ext": "agda",
"hexsha": "e7e0197c1e81dd6215ca855a74e907611844cd85",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Smaug123/agdaproofs",
"max_forks_repo_path": "Groups/Isomorphisms/Lemmas.agda",
"max_issues_count": 14,
"max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Smaug123/agdaproofs",
"max_issues_repo_path": "Groups/Isomorphisms/Lemmas.agda",
"max_line_length": 385,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Smaug123/agdaproofs",
"max_stars_repo_path": "Groups/Isomorphisms/Lemmas.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z",
"num_tokens": 997,
"size": 2673
} |
{-# OPTIONS --sized-types #-}
module SNat.Log where
open import Size
open import SNat
open import SNat.Order
open import SNat.Order.Properties
open import SNat.Properties
open import SNat.Sum
lemma-≅-log : {ι ι' : Size}{m : SNat {ι}}{n : SNat {ι'}} → m ≅ n → log₂ m ≅ log₂ n
lemma-≅-log z≅z = z≅z
lemma-≅-log (s≅s z≅z) = z≅z
lemma-≅-log (s≅s (s≅s m≅n)) = s≅s (lemma-≅-log (s≅s (lemma-≅-/2 m≅n)))
mutual
lemma-logn≤′logsn : {ι : Size}(n : SNat {ι}) → log₂ n ≤′ log₂ (succ n)
lemma-logn≤′logsn zero = ≤′-eq z≅z
lemma-logn≤′logsn (succ zero) = ≤′-step (≤′-eq z≅z)
lemma-logn≤′logsn (succ (succ n)) = lemma-s≤′s (lemma-≤′-log (lemma-s≤′s (lemma-n/2≤′sn/2 n)))
lemma-≤′-log : {ι ι' : Size}{m : SNat {ι}}{n : SNat {ι'}} → m ≤′ n → log₂ m ≤′ log₂ n
lemma-≤′-log (≤′-eq m≅n) = ≤′-eq (lemma-≅-log m≅n)
lemma-≤′-log (≤′-step {n = n} m≤′n) = trans≤′ (lemma-≤′-log m≤′n) (lemma-logn≤′logsn n)
lemma-1+logn≤′log2n : (n : SNat) → succ (log₂ (succ n)) ≤′ log₂ (succ n + succ n)
lemma-1+logn≤′log2n zero = refl≤′
lemma-1+logn≤′log2n (succ n) rewrite +-assoc-succ (succ (succ n)) (succ n) | +-assoc-succ n (succ n) | +-assoc-succ n n = lemma-s≤′s (lemma-≤′-log (lemma-s≤′s (lemma-n+1≤′2n+2/2 n)))
lemma-log2n≤′1+logn : (n : SNat) → log₂ (n + n) ≤′ succ (log₂ n)
lemma-log2n≤′1+logn zero = ≤′-step refl≤′
lemma-log2n≤′1+logn (succ n) rewrite +-assoc-succ (succ n) n = lemma-s≤′s (lemma-≤′-log (lemma-s≤′s (lemma-2n/2≤′n n)))
| {
"alphanum_fraction": 0.5791316527,
"avg_line_length": 42,
"ext": "agda",
"hexsha": "c79852e0eba60947d23ab066a4a6e9dabc58cee9",
"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/SNat/Log.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/SNat/Log.agda",
"max_line_length": 182,
"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/SNat/Log.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": 714,
"size": 1428
} |
{-# OPTIONS --without-K #-}
open import lib.Basics
open import lib.types.Span
open import lib.types.Pushout
open import lib.types.PushoutFlattening
open import lib.types.Unit
open import lib.types.Pointed
-- Cofiber is defined as a particular case of pushout
module lib.types.Cofiber where
module _ {i j} {A : Type i} {B : Type j} (f : A → B) where
cofiber-span : Span
cofiber-span = span Unit B A (λ _ → tt) f
Cofiber : Type (lmax i j)
Cofiber = Pushout cofiber-span
cfbase' : Cofiber
cfbase' = left tt
cfcod' : B → Cofiber
cfcod' b = right b
cfglue' : (a : A) → cfbase' == cfcod' (f a)
cfglue' a = glue a
module _ {i j} {A : Type i} {B : Type j} {f : A → B} where
cfbase : Cofiber f
cfbase = cfbase' f
cfcod : B → Cofiber f
cfcod = cfcod' f
cfglue : (a : A) → cfbase == cfcod (f a)
cfglue = cfglue' f
module CofiberElim {k} {P : Cofiber f → Type k}
(b : P cfbase) (c : (y : B) → P (cfcod y))
(p : (x : A) → b == c (f x) [ P ↓ cfglue x ])
= PushoutElim (λ _ → b) c p
open CofiberElim public using () renaming (f to Cofiber-elim)
module CofiberRec {k} {C : Type k} (b : C) (c : B → C)
(p : (x : A) → b == c (f x))
= PushoutRec {d = cofiber-span f} (λ _ → b) c p
module CofiberRecType {k} (b : Type k) (c : B → Type k)
(p : (x : A) → b ≃ c (f x))
= PushoutRecType {d = cofiber-span f} (λ _ → b) c p
module _ {i j} {X : Ptd i} {Y : Ptd j} (F : fst (X ⊙→ Y)) where
⊙cof-span : ⊙Span
⊙cof-span = ⊙span ⊙Unit Y X ((λ _ → tt) , idp) F
⊙Cof : Ptd (lmax i j)
⊙Cof = ⊙Pushout ⊙cof-span
⊙cfcod' : fst (Y ⊙→ ⊙Cof)
⊙cfcod' = cfcod , ap cfcod (! (snd F)) ∙ ! (cfglue (snd X))
⊙cfglue' : ⊙cst == ⊙cfcod' ⊙∘ F
⊙cfglue' = ⊙λ= cfglue (lemma cfcod (cfglue (snd X)) (snd F))
where
lemma : ∀ {i j} {A : Type i} {B : Type j} (f : A → B)
{x y : A} {z : B} (p : z == f x) (q : x == y)
→ idp == p ∙ ap f q ∙ ap f (! q) ∙ ! p
lemma f idp idp = idp
module _ {i j} {X : Ptd i} {Y : Ptd j} {F : fst (X ⊙→ Y)} where
⊙cfcod : fst (Y ⊙→ ⊙Cof F)
⊙cfcod = ⊙cfcod' F
⊙cfglue : ⊙cst == ⊙cfcod ⊙∘ F
⊙cfglue = ⊙cfglue' F
| {
"alphanum_fraction": 0.5385700847,
"avg_line_length": 25.6144578313,
"ext": "agda",
"hexsha": "26f1ba0a04721426da48a594479a23e2d092499d",
"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/Cofiber.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/Cofiber.agda",
"max_line_length": 63,
"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/Cofiber.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 956,
"size": 2126
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Algebra.QuotientRing where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Logic using (_∈_)
open import Cubical.HITs.SetQuotients.Base
open import Cubical.HITs.SetQuotients.Properties
open import Cubical.Algebra.Ring
open import Cubical.Algebra.Ideal
private
variable
ℓ : Level
module _ (R' : Ring {ℓ}) (I : ⟨ R' ⟩ → hProp ℓ) (I-isIdeal : isIdeal R' I) where
open Ring R' renaming (Carrier to R)
open isIdeal I-isIdeal
open Theory R'
R/I : Type ℓ
R/I = R / (λ x y → x - y ∈ I)
private
homogeneity : ∀ (x a b : R)
→ (a - b ∈ I)
→ (x + a) - (x + b) ∈ I
homogeneity x a b p = subst (λ u → u ∈ I) (translatedDifference x a b) p
isSetR/I : isSet R/I
isSetR/I = squash/
[_]/I : (a : R) → R/I
[ a ]/I = [ a ]
lemma : (x y a : R)
→ x - y ∈ I
→ [ x + a ]/I ≡ [ y + a ]/I
lemma x y a x-y∈I = eq/ (x + a) (y + a) (subst (λ u → u ∈ I) calculate x-y∈I)
where calculate : x - y ≡ (x + a) - (y + a)
calculate =
x - y ≡⟨ translatedDifference a x y ⟩
((a + x) - (a + y)) ≡⟨ cong (λ u → u - (a + y)) (+-comm _ _) ⟩
((x + a) - (a + y)) ≡⟨ cong (λ u → (x + a) - u) (+-comm _ _) ⟩
((x + a) - (y + a)) ∎
pre-+/I : R → R/I → R/I
pre-+/I x = elim
(λ _ → squash/)
(λ y → [ x + y ])
λ y y' diffrenceInIdeal
→ eq/ (x + y) (x + y') (homogeneity x y y' diffrenceInIdeal)
pre-+/I-DescendsToQuotient : (x y : R) → (x - y ∈ I)
→ pre-+/I x ≡ pre-+/I y
pre-+/I-DescendsToQuotient x y x-y∈I i r = pointwise-equal r i
where
pointwise-equal : ∀ (u : R/I)
→ pre-+/I x u ≡ pre-+/I y u
pointwise-equal = elimProp (λ u → isSetR/I (pre-+/I x u) (pre-+/I y u))
(λ a → lemma x y a x-y∈I)
_+/I_ : R/I → R/I → R/I
x +/I y = (elim R/I→R/I-isSet pre-+/I pre-+/I-DescendsToQuotient x) y
where
R/I→R/I-isSet : R/I → isSet (R/I → R/I)
R/I→R/I-isSet _ = isSetΠ (λ _ → squash/)
+/I-comm : (x y : R/I) → x +/I y ≡ y +/I x
+/I-comm = elimProp2 (λ _ _ → squash/ _ _) eq
where eq : (x y : R) → [ x ] +/I [ y ] ≡ [ y ] +/I [ x ]
eq x y i = [ +-comm x y i ]
+/I-assoc : (x y z : R/I) → x +/I (y +/I z) ≡ (x +/I y) +/I z
+/I-assoc = elimProp3 (λ _ _ _ → squash/ _ _) eq
where eq : (x y z : R) → [ x ] +/I ([ y ] +/I [ z ]) ≡ ([ x ] +/I [ y ]) +/I [ z ]
eq x y z i = [ +-assoc x y z i ]
0/I : R/I
0/I = [ 0r ]
1/I : R/I
1/I = [ 1r ]
-/I : R/I → R/I
-/I = elim (λ _ → squash/) (λ x' → [ - x' ]) eq
where
eq : (x y : R) → (x - y ∈ I) → [ - x ] ≡ [ - y ]
eq x y x-y∈I = eq/ (- x) (- y) (subst (λ u → u ∈ I) eq' (isIdeal.-closed I-isIdeal x-y∈I))
where
eq' = - (x + (- y)) ≡⟨ sym (-isDistributive _ _) ⟩
(- x) - (- y) ∎
+/I-rinv : (x : R/I) → x +/I (-/I x) ≡ 0/I
+/I-rinv = elimProp (λ x → squash/ _ _) eq
where
eq : (x : R) → [ x ] +/I (-/I [ x ]) ≡ 0/I
eq x i = [ +-rinv x i ]
+/I-rid : (x : R/I) → x +/I 0/I ≡ x
+/I-rid = elimProp (λ x → squash/ _ _) eq
where
eq : (x : R) → [ x ] +/I 0/I ≡ [ x ]
eq x i = [ +-rid x i ]
_·/I_ : R/I → R/I → R/I
_·/I_ =
elim (λ _ → isSetΠ (λ _ → squash/))
(λ x → left· x)
eq'
where
eq : (x y y' : R) → (y - y' ∈ I) → [ x · y ] ≡ [ x · y' ]
eq x y y' y-y'∈I = eq/ _ _
(subst (λ u → u ∈ I)
(x · (y - y') ≡⟨ ·-rdist-+ _ _ _ ⟩
((x · y) + x · (- y')) ≡⟨ cong (λ u → (x · y) + u)
(-commutesWithRight-· x y') ⟩
(x · y) - (x · y') ∎)
(isIdeal.·-closedLeft I-isIdeal x y-y'∈I))
left· : (x : R) → R/I → R/I
left· x = elim (λ y → squash/)
(λ y → [ x · y ])
(eq x)
eq' : (x x' : R) → (x - x' ∈ I) → left· x ≡ left· x'
eq' x x' x-x'∈I i y = elimProp (λ y → squash/ (left· x y) (left· x' y))
(λ y → eq′ y)
y i
where
eq′ : (y : R) → left· x [ y ] ≡ left· x' [ y ]
eq′ y = eq/ (x · y) (x' · y)
(subst (λ u → u ∈ I)
((x - x') · y ≡⟨ ·-ldist-+ x (- x') y ⟩
x · y + (- x') · y ≡⟨ cong
(λ u → x · y + u)
(-commutesWithLeft-· x' y) ⟩
x · y - x' · y ∎)
(isIdeal.·-closedRight I-isIdeal y x-x'∈I))
-- more or less copy paste from '+/I' - this is preliminary anyway
·/I-assoc : (x y z : R/I) → x ·/I (y ·/I z) ≡ (x ·/I y) ·/I z
·/I-assoc = elimProp3 (λ _ _ _ → squash/ _ _) eq
where eq : (x y z : R) → [ x ] ·/I ([ y ] ·/I [ z ]) ≡ ([ x ] ·/I [ y ]) ·/I [ z ]
eq x y z i = [ ·-assoc x y z i ]
·/I-lid : (x : R/I) → 1/I ·/I x ≡ x
·/I-lid = elimProp (λ x → squash/ _ _) eq
where
eq : (x : R) → 1/I ·/I [ x ] ≡ [ x ]
eq x i = [ ·-lid x i ]
·/I-rid : (x : R/I) → x ·/I 1/I ≡ x
·/I-rid = elimProp (λ x → squash/ _ _) eq
where
eq : (x : R) → [ x ] ·/I 1/I ≡ [ x ]
eq x i = [ ·-rid x i ]
/I-ldist : (x y z : R/I) → (x +/I y) ·/I z ≡ (x ·/I z) +/I (y ·/I z)
/I-ldist = elimProp3 (λ _ _ _ → squash/ _ _) eq
where
eq : (x y z : R) → ([ x ] +/I [ y ]) ·/I [ z ] ≡ ([ x ] ·/I [ z ]) +/I ([ y ] ·/I [ z ])
eq x y z i = [ ·-ldist-+ x y z i ]
/I-rdist : (x y z : R/I) → x ·/I (y +/I z) ≡ (x ·/I y) +/I (x ·/I z)
/I-rdist = elimProp3 (λ _ _ _ → squash/ _ _) eq
where
eq : (x y z : R) → [ x ] ·/I ([ y ] +/I [ z ]) ≡ ([ x ] ·/I [ y ]) +/I ([ x ] ·/I [ z ])
eq x y z i = [ ·-rdist-+ x y z i ]
asRing : Ring {ℓ}
asRing = makeRing 0/I 1/I _+/I_ _·/I_ -/I isSetR/I
+/I-assoc +/I-rid +/I-rinv +/I-comm
·/I-assoc ·/I-rid ·/I-lid /I-rdist /I-ldist
| {
"alphanum_fraction": 0.3489417222,
"avg_line_length": 38.9717514124,
"ext": "agda",
"hexsha": "73c5354b72ec6a52a9364a1dc0e03ee8657397cf",
"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": "f6771617374bfe65a7043d00731fed5a673aa729",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "knrafto/cubical",
"max_forks_repo_path": "Cubical/Algebra/QuotientRing.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "knrafto/cubical",
"max_issues_repo_path": "Cubical/Algebra/QuotientRing.agda",
"max_line_length": 101,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "knrafto/cubical",
"max_stars_repo_path": "Cubical/Algebra/QuotientRing.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2597,
"size": 6898
} |
module Issue168b where
data Nat : Set where
zero : Nat
suc : Nat → Nat
module Membership (A : Set) where
id : Nat → Nat
id zero = zero
id (suc xs) = suc (id xs)
| {
"alphanum_fraction": 0.6,
"avg_line_length": 15,
"ext": "agda",
"hexsha": "8ea1f80b235354b0c13e05c0c3b8b3fdf9fb4d78",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/agda-kanso",
"max_forks_repo_path": "test/succeed/Issue168b.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/agda-kanso",
"max_issues_repo_path": "test/succeed/Issue168b.agda",
"max_line_length": 33,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "test/succeed/Issue168b.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 61,
"size": 180
} |
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2020, 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
{-# OPTIONS --allow-unsolved-metas #-}
open import Optics.All
open import LibraBFT.Prelude
open import LibraBFT.Lemmas
open import LibraBFT.Base.PKCS
import LibraBFT.Concrete.Properties.VotesOnce as VO
open import LibraBFT.Impl.Consensus.Types
open import LibraBFT.Impl.Util.Crypto
open import LibraBFT.Impl.Consensus.RoundManager.Properties
open import LibraBFT.Impl.Handle
open import LibraBFT.Impl.Handle.Properties
open import LibraBFT.Concrete.System
open import LibraBFT.Concrete.System.Parameters
open EpochConfig
open import LibraBFT.Yasm.Types
open import LibraBFT.Yasm.Yasm ℓ-RoundManager ℓ-VSFP ConcSysParms PeerCanSignForPK (λ {st} {part} {pk} → PeerCanSignForPK-stable {st} {part} {pk})
open WithSPS impl-sps-avp
open Structural impl-sps-avp
open import LibraBFT.Impl.Properties.VotesOnce
-- This module proves the two "VotesOnce" proof obligations for our fake handler. Unlike the
-- LibraBFT.Impl.Properties.VotesOnce, which is based on unwind, this proof is done
-- inductively on the ReachableSystemState.
module LibraBFT.Impl.Properties.VotesOnceDirect where
newVoteEpoch≡⇒Round≡ : ∀ {st : SystemState}{pid s' outs v m pk}
→ ReachableSystemState st
→ StepPeerState pid (msgPool st) (initialised st)
(peerStates st pid) (s' , outs)
→ v ⊂Msg m → send m ∈ outs → (sig : WithVerSig pk v)
→ Meta-Honest-PK pk → ¬ (∈GenInfo (ver-signature sig))
→ ¬ MsgWithSig∈ pk (ver-signature sig) (msgPool st)
→ v ^∙ vEpoch ≡ (₋rmEC s') ^∙ rmEpoch
→ v ^∙ vRound ≡ (₋rmEC s') ^∙ rmLastVotedRound
newVoteEpoch≡⇒Round≡ r step@(step-msg {_ , P pm} _ pinit) v⊂m (here refl)
sig pkH ¬gen vnew ep≡
with v⊂m
...| vote∈vm = refl
...| vote∈qc vs∈qc v≈rbld (inV qc∈m) rewrite cong ₋vSignature v≈rbld
= let qc∈rm = VoteMsgQCsFromRoundManager r step pkH v⊂m (here refl) qc∈m
in ⊥-elim (vnew (qcVotesSentB4 r pinit qc∈rm vs∈qc ¬gen))
open PeerCanSignForPK
peerCanSignSameS : ∀ {pid v pk s s'}
→ PeerCanSignForPK s v pid pk
→ s' ≡ s
→ PeerCanSignForPK s' v pid pk
peerCanSignSameS pcs refl = pcs
peerCanSignEp≡ : ∀ {pid v v' pk s'}
→ PeerCanSignForPK s' v pid pk
→ v ^∙ vEpoch ≡ v' ^∙ vEpoch
→ PeerCanSignForPK s' v' pid pk
peerCanSignEp≡ (mkPCS4PK 𝓔₁ 𝓔id≡₁ 𝓔inSys₁ mbr₁ nid≡₁ pk≡₁) refl
= (mkPCS4PK 𝓔₁ 𝓔id≡₁ 𝓔inSys₁ mbr₁ nid≡₁ pk≡₁)
MsgWithSig⇒ValidSenderInitialised : ∀ {st v pk}
→ ReachableSystemState st
→ Meta-Honest-PK pk → (sig : WithVerSig pk v)
→ ¬ (∈GenInfo (ver-signature sig))
→ MsgWithSig∈ pk (ver-signature sig) (msgPool st)
→ ∃[ pid ] ( initialised st pid ≡ initd
× PeerCanSignForPK st v pid pk )
MsgWithSig⇒ValidSenderInitialised {st} {v} (step-s r step@(step-peer (step-honest {pid} stP))) pkH sig ¬gen msv
with msgSameSig msv
...| refl
with newMsg⊎msgSentB4 r stP pkH (msgSigned msv) ¬gen (msg⊆ msv) (msg∈pool msv)
...| inj₁ (m∈outs , pcsN , newV)
with stP
...| step-msg _ initP
with PerState.sameSig⇒sameVoteDataNoCol st (step-s r step) (msgSigned msv) sig (msgSameSig msv)
...| refl = pid , peersRemainInitialized step initP , peerCanSignEp≡ pcsN refl
MsgWithSig⇒ValidSenderInitialised {st} {v} (step-s r step@(step-peer (step-honest stP))) pkH sig ¬gen msv
| refl
| inj₂ msb4
with MsgWithSig⇒ValidSenderInitialised {v = v} r pkH sig ¬gen msb4
...| pid , initP , pcsPre = pid ,
peersRemainInitialized step initP ,
PeerCanSignForPK-stable r step pcsPre
MsgWithSig⇒ValidSenderInitialised {st} {v} (step-s r step@(step-peer cheat@(step-cheat x))) pkH sig ¬gen msv
with msgSameSig msv
...| refl
with ¬cheatForgeNew cheat refl unit pkH msv ¬gen
...| msb4
with MsgWithSig⇒ValidSenderInitialised {v = v} r pkH sig ¬gen msb4
...| pid , initP , pcsPre = pid ,
peersRemainInitialized step initP ,
PeerCanSignForPK-stable r step pcsPre
peerCanSign-Msb4 : ∀ {pid v pk}{pre post : SystemState}
→ ReachableSystemState pre
→ Step pre post
→ PeerCanSignForPK post v pid pk
→ Meta-Honest-PK pk → (sig : WithVerSig pk v)
→ MsgWithSig∈ pk (ver-signature sig) (msgPool pre)
→ PeerCanSignForPK pre v pid pk
peerCanSign-Msb4 r step (mkPCS4PK 𝓔₁ 𝓔id≡₁ (inGenInfo refl) mbr₁ nid≡₁ pk≡₁) pkH sig msv
= mkPCS4PK 𝓔₁ 𝓔id≡₁ (inGenInfo refl) mbr₁ nid≡₁ pk≡₁
peerCanSignPK-Inj : ∀ {pid pid' pk v v'}{st : SystemState}
→ ReachableSystemState st
→ Meta-Honest-PK pk
→ PeerCanSignForPK st v' pid' pk
→ PeerCanSignForPK st v pid pk
→ v ^∙ vEpoch ≡ v' ^∙ vEpoch
→ pid ≡ pid'
peerCanSignPK-Inj {pid} {pid'} r pkH pcs' pcs eid≡
with availEpochsConsistent r pcs' pcs
...| refl
with NodeId-PK-OK-injective (𝓔 pcs) (PCS4PK⇒NodeId-PK-OK pcs) (PCS4PK⇒NodeId-PK-OK pcs')
...| refl = refl
msg∈pool⇒initd : ∀ {pid pk v}{st : SystemState}
→ ReachableSystemState st
→ PeerCanSignForPK st v pid pk
→ Meta-Honest-PK pk → (sig : WithVerSig pk v)
→ ¬ (∈GenInfo (ver-signature sig))
→ MsgWithSig∈ pk (ver-signature sig) (msgPool st)
→ initialised st pid ≡ initd
msg∈pool⇒initd {pid'} {st = st} step@(step-s r (step-peer {pid} (step-honest stPeer))) pcs pkH sig ¬gen msv
with msgSameSig msv
...| refl
with newMsg⊎msgSentB4 r stPeer pkH (msgSigned msv) ¬gen (msg⊆ msv) (msg∈pool msv)
...| inj₁ (m∈outs , pcsN , newV)
with sameSig⇒sameVoteData (msgSigned msv) sig (msgSameSig msv)
...| inj₁ hb = ⊥-elim (PerState.meta-sha256-cr st step hb)
...| inj₂ refl
with stPeer
...| step-msg _ initP
with pid ≟ pid'
...| yes refl = refl
...| no pid≢ = ⊥-elim (pid≢ (peerCanSignPK-Inj step pkH pcs pcsN refl))
msg∈pool⇒initd {pid'} (step-s r step@(step-peer {pid} (step-honest stPeer))) pcs pkH sig ¬gen msv
| refl
| inj₂ msb4
with pid ≟ pid'
...| yes refl = refl
...| no pid≢ = let pcsmsb4 = peerCanSign-Msb4 r step pcs pkH sig msb4
in msg∈pool⇒initd r pcsmsb4 pkH sig ¬gen msb4
msg∈pool⇒initd {pid'} (step-s r step@(step-peer {pid} cheat@(step-cheat c))) pcs pkH sig ¬gen msv
with msgSameSig msv
...| refl
with ¬cheatForgeNew cheat refl unit pkH msv ¬gen
...| msb4
= let pcsmsb4 = peerCanSign-Msb4 r step pcs pkH sig msb4
initPre = msg∈pool⇒initd r pcsmsb4 pkH sig ¬gen msb4
in peersRemainInitialized (step-peer cheat) initPre
noEpochChange : ∀ {pid s' outs v pk}{st : SystemState}
→ ReachableSystemState st
→ (stP : StepPeerState pid (msgPool st) (initialised st)
(peerStates st pid) (s' , outs))
→ PeerCanSignForPK st v pid pk
→ Meta-Honest-PK pk → (sig : WithVerSig pk v)
→ ¬ ∈GenInfo (ver-signature sig)
→ MsgWithSig∈ pk (ver-signature sig) (msgPool st)
→ (₋rmEC s') ^∙ rmEpoch ≡ (v ^∙ vEpoch)
→ (₋rmEC (peerStates st pid)) ^∙ rmEpoch ≡ (v ^∙ vEpoch)
noEpochChange r (step-init uni) pcs pkH sig ∉gen msv eid≡
= ⊥-elim (uninitd≢initd (trans (sym uni) (msg∈pool⇒initd r pcs pkH sig ∉gen msv)))
noEpochChange r sm@(step-msg _ ini) pcs pkH sig ∉gen msv eid≡
rewrite noEpochIdChangeYet r refl sm ini = eid≡
oldVoteRound≤lvr : ∀ {pid pk v}{pre : SystemState}
→ (r : ReachableSystemState pre)
→ Meta-Honest-PK pk → (sig : WithVerSig pk v)
→ ¬ (∈GenInfo (ver-signature sig))
→ MsgWithSig∈ pk (ver-signature sig) (msgPool pre)
→ PeerCanSignForPK pre v pid pk
→ (₋rmEC (peerStates pre pid)) ^∙ rmEpoch ≡ (v ^∙ vEpoch)
→ v ^∙ vRound ≤ (₋rmEC (peerStates pre pid)) ^∙ rmLastVotedRound
oldVoteRound≤lvr {pid'} (step-s r step@(step-peer {pid = pid} cheat@(step-cheat c)))
pkH sig ¬gen msv vspk eid≡
with ¬cheatForgeNew cheat refl unit pkH msv (¬subst ¬gen (msgSameSig msv))
...| msb4 rewrite cheatStepDNMPeerStates₁ {pid = pid} {pid' = pid'} cheat unit
= let pcsmsb4 = peerCanSign-Msb4 r step vspk pkH sig msb4
in oldVoteRound≤lvr r pkH sig ¬gen msb4 pcsmsb4 eid≡
oldVoteRound≤lvr {pid'} step@(step-s r stP@(step-peer {pid} (step-honest stPeer)))
pkH sig ¬gen msv vspk eid≡
with msgSameSig msv
...| refl
with newMsg⊎msgSentB4 r stPeer pkH (msgSigned msv) ¬gen (msg⊆ msv) (msg∈pool msv)
...| inj₂ msb4 rewrite msgSameSig msv
with peerCanSign-Msb4 r stP vspk pkH sig msb4
...| pcsmsb4
with pid ≟ pid'
...| no pid≢ = oldVoteRound≤lvr r pkH sig ¬gen msb4 pcsmsb4 eid≡
...| yes refl = let initP = msg∈pool⇒initd r pcsmsb4 pkH sig ¬gen msb4
ep≡ = noEpochChange r stPeer pcsmsb4 pkH sig ¬gen msb4 eid≡
lvr≤ = lastVoteRound-mono r refl stPeer initP (trans ep≡ (sym eid≡))
in ≤-trans (oldVoteRound≤lvr r pkH sig ¬gen msb4 pcsmsb4 ep≡) lvr≤
oldVoteRound≤lvr {pid = pid'} {pre = pre}
step@(step-s r (step-peer {pid} (step-honest stPeer)))
pkH sig ¬gen msv vspk eid≡
| refl
| inj₁ (m∈outs , vspkN , newV)
with sameSig⇒sameVoteData (msgSigned msv) sig (msgSameSig msv)
...| inj₁ hb = ⊥-elim (PerState.meta-sha256-cr pre step hb)
...| inj₂ refl
with pid ≟ pid'
...| yes refl = ≡⇒≤ (newVoteEpoch≡⇒Round≡ r stPeer (msg⊆ msv) m∈outs (msgSigned msv)
pkH ¬gen newV (sym eid≡))
...| no pid≢ = ⊥-elim (pid≢ (peerCanSignPK-Inj step pkH vspk vspkN refl))
votesOnce₁ : VO.ImplObligation₁
votesOnce₁ {pid' = pid'} r stMsg@(step-msg {_ , P m} m∈pool psI) {v' = v'} {m' = m'}
pkH v⊂m (here refl) sv ¬gen ¬msb vspkv v'⊂m' m'∈pool sv' ¬gen' eid≡ r≡
with v⊂m
...| vote∈vm = let m'mwsb = mkMsgWithSig∈ m' v' v'⊂m' pid' m'∈pool sv' refl
vspkv' = peerCanSignEp≡ {v' = v'} vspkv eid≡
step = step-peer (step-honest stMsg)
vspre' = peerCanSign-Msb4 r step vspkv' pkH sv' m'mwsb
rv'<rv = oldVoteRound≤lvr r pkH sv' ¬gen' m'mwsb vspre' eid≡
in ⊥-elim (<⇒≢ (s≤s rv'<rv) (sym r≡))
...| vote∈qc vs∈qc v≈rbld (inV qc∈m) rewrite cong ₋vSignature v≈rbld
= let qc∈rm = VoteMsgQCsFromRoundManager r stMsg pkH v⊂m (here refl) qc∈m
in ⊥-elim (¬msb (qcVotesSentB4 r psI qc∈rm vs∈qc ¬gen))
votesOnce₂ : VO.ImplObligation₂
votesOnce₂ {pk = pk} {st} r stMsg@(step-msg {_ , P m} m∈pool psI) pkH v⊂m m∈outs sig ¬gen vnew
vpk v'⊂m' m'∈outs sig' ¬gen' v'new vpk' es≡ rnds≡
with m∈outs | m'∈outs
...| here refl | here refl
with v⊂m | v'⊂m'
...| vote∈vm | vote∈vm = refl
...| vote∈vm | vote∈qc vs∈qc' v≈rbld' (inV qc∈m')
rewrite cong ₋vSignature v≈rbld'
= let qc∈rm' = VoteMsgQCsFromRoundManager r stMsg pkH v'⊂m' (here refl) qc∈m'
in ⊥-elim (v'new (qcVotesSentB4 r psI qc∈rm' vs∈qc' ¬gen'))
...| vote∈qc vs∈qc v≈rbld (inV qc∈m) | _
rewrite cong ₋vSignature v≈rbld
= let qc∈rm = VoteMsgQCsFromRoundManager r stMsg pkH v⊂m (here refl) qc∈m
in ⊥-elim (vnew (qcVotesSentB4 r psI qc∈rm vs∈qc ¬gen))
| {
"alphanum_fraction": 0.5788492707,
"avg_line_length": 49.5582329317,
"ext": "agda",
"hexsha": "666b37c79a0c72751f6ad9db8fa6620372c60a77",
"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": "LibraBFT/Impl/Properties/VotesOnceDirect.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": "LibraBFT/Impl/Properties/VotesOnceDirect.agda",
"max_line_length": 146,
"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": "LibraBFT/Impl/Properties/VotesOnceDirect.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 4290,
"size": 12340
} |
{-# OPTIONS --without-K --safe #-}
module Categories.Category.Core where
open import Level
open import Function using (flip)
open import Relation.Binary hiding (_⇒_)
import Relation.Binary.PropositionalEquality as ≡
import Relation.Binary.Reasoning.Setoid as SetoidR
-- Basic definition of a |Category| with a Hom setoid.
-- Also comes with some reasoning combinators (see HomReasoning)
record Category (o ℓ e : Level) : Set (suc (o ⊔ ℓ ⊔ e)) where
eta-equality
infix 4 _≈_ _⇒_
infixr 9 _∘_
field
Obj : Set o
_⇒_ : Rel Obj ℓ
_≈_ : ∀ {A B} → Rel (A ⇒ B) e
id : ∀ {A} → (A ⇒ A)
_∘_ : ∀ {A B C} → (B ⇒ C) → (A ⇒ B) → (A ⇒ C)
field
assoc : ∀ {A B C D} {f : A ⇒ B} {g : B ⇒ C} {h : C ⇒ D} → (h ∘ g) ∘ f ≈ h ∘ (g ∘ f)
-- We add a symmetric proof of associativity so that the opposite category of the
-- opposite category is definitionally equal to the original category. See how
-- `op` is implemented.
sym-assoc : ∀ {A B C D} {f : A ⇒ B} {g : B ⇒ C} {h : C ⇒ D} → h ∘ (g ∘ f) ≈ (h ∘ g) ∘ f
identityˡ : ∀ {A B} {f : A ⇒ B} → id ∘ f ≈ f
identityʳ : ∀ {A B} {f : A ⇒ B} → f ∘ id ≈ f
-- We add a proof of "neutral" identity proof, in order to ensure the opposite of
-- constant functor is definitionally equal to itself.
identity² : ∀ {A} → id ∘ id {A} ≈ id {A}
equiv : ∀ {A B} → IsEquivalence (_≈_ {A} {B})
∘-resp-≈ : ∀ {A B C} {f h : B ⇒ C} {g i : A ⇒ B} → f ≈ h → g ≈ i → f ∘ g ≈ h ∘ i
module Equiv {A B : Obj} = IsEquivalence (equiv {A} {B})
open Equiv
dom : ∀ {A B} → (A ⇒ B) → Obj
dom {A} _ = A
cod : ∀ {A B} → (A ⇒ B) → Obj
cod {B = B} _ = B
∘-resp-≈ˡ : ∀ {A B C} {f h : B ⇒ C} {g : A ⇒ B} → f ≈ h → f ∘ g ≈ h ∘ g
∘-resp-≈ˡ pf = ∘-resp-≈ pf refl
∘-resp-≈ʳ : ∀ {A B C} {f h : A ⇒ B} {g : B ⇒ C} → f ≈ h → g ∘ f ≈ g ∘ h
∘-resp-≈ʳ pf = ∘-resp-≈ refl pf
hom-setoid : ∀ {A B} → Setoid _ _
hom-setoid {A} {B} = record
{ Carrier = A ⇒ B
; _≈_ = _≈_
; isEquivalence = equiv
}
-- Reasoning combinators. _≈⟨_⟩_ and _≈˘⟨_⟩_ from SetoidR.
-- Also some useful combinators for doing reasoning on _∘_ chains
module HomReasoning {A B : Obj} where
open SetoidR (hom-setoid {A} {B}) public
open Equiv {A = A} {B = B} public
infixr 4 _⟩∘⟨_ refl⟩∘⟨_
infixl 5 _⟩∘⟨refl
_⟩∘⟨_ : ∀ {M} {f h : M ⇒ B} {g i : A ⇒ M} → f ≈ h → g ≈ i → f ∘ g ≈ h ∘ i
_⟩∘⟨_ = ∘-resp-≈
refl⟩∘⟨_ : ∀ {M} {f : M ⇒ B} {g i : A ⇒ M} → g ≈ i → f ∘ g ≈ f ∘ i
refl⟩∘⟨_ = Equiv.refl ⟩∘⟨_
_⟩∘⟨refl : ∀ {M} {f h : M ⇒ B} {g : A ⇒ M} → f ≈ h → f ∘ g ≈ h ∘ g
_⟩∘⟨refl = _⟩∘⟨ Equiv.refl
-- convenient inline versions
infix 2 ⟺
infixr 3 _○_
⟺ : {f g : A ⇒ B} → f ≈ g → g ≈ f
⟺ = Equiv.sym
_○_ : {f g h : A ⇒ B} → f ≈ g → g ≈ h → f ≈ h
_○_ = Equiv.trans
-- for reasoning in the Strict cases
≡⇒≈ : {f g : A ⇒ B} → f ≡.≡ g → f ≈ g
≡⇒≈ ≡.refl = Equiv.refl
subst₂≈ : {C D : Obj} {f g : A ⇒ B} → f ≈ g → (eq₁ : A ≡.≡ C) (eq₂ : B ≡.≡ D) →
≡.subst₂ (_⇒_) eq₁ eq₂ f ≈ ≡.subst₂ (_⇒_) eq₁ eq₂ g
subst₂≈ f≈g ≡.refl ≡.refl = f≈g
-- Combinators for commutative diagram
-- The idea is to use the combinators to write commutations in a more readable way.
-- It starts with [_⇒_]⟨_≈_⟩, and within the third and fourth places, use _⇒⟨_⟩_ to
-- connect morphisms with the intermediate object specified.
module Commutation where
infix 1 [_⇒_]⟨_≈_⟩
[_⇒_]⟨_≈_⟩ : ∀ (A B : Obj) → A ⇒ B → A ⇒ B → Set _
[ A ⇒ B ]⟨ f ≈ g ⟩ = f ≈ g
infixl 2 connect
connect : ∀ {A C : Obj} (B : Obj) → A ⇒ B → B ⇒ C → A ⇒ C
connect B f g = g ∘ f
syntax connect B f g = f ⇒⟨ B ⟩ g
op : Category o ℓ e
op = record
{ Obj = Obj
; _⇒_ = flip _⇒_
; _≈_ = _≈_
; _∘_ = flip _∘_
; id = id
; assoc = sym-assoc
; sym-assoc = assoc
; identityˡ = identityʳ
; identityʳ = identityˡ
; identity² = identity²
; equiv = equiv
; ∘-resp-≈ = flip ∘-resp-≈
}
-- Q: Should this really be defined here?
CommutativeSquare : ∀ {A B C D} → (f : A ⇒ B) (g : A ⇒ C) (h : B ⇒ D) (i : C ⇒ D) → Set _
CommutativeSquare f g h i = h ∘ f ≈ i ∘ g
-- Since we add extra proofs in the definition of `Category` (i.e. `sym-assoc` and
-- `identity²`), we might still want to construct a `Category` in its originally
-- easier manner. Thus, this redundant definition is here to ease the construction.
record CategoryHelper (o ℓ e : Level) : Set (suc (o ⊔ ℓ ⊔ e)) where
infix 4 _≈_ _⇒_
infixr 9 _∘_
field
Obj : Set o
_⇒_ : Rel Obj ℓ
_≈_ : ∀ {A B} → Rel (A ⇒ B) e
id : ∀ {A} → (A ⇒ A)
_∘_ : ∀ {A B C} → (B ⇒ C) → (A ⇒ B) → (A ⇒ C)
field
assoc : ∀ {A B C D} {f : A ⇒ B} {g : B ⇒ C} {h : C ⇒ D} → (h ∘ g) ∘ f ≈ h ∘ (g ∘ f)
identityˡ : ∀ {A B} {f : A ⇒ B} → id ∘ f ≈ f
identityʳ : ∀ {A B} {f : A ⇒ B} → f ∘ id ≈ f
equiv : ∀ {A B} → IsEquivalence (_≈_ {A} {B})
∘-resp-≈ : ∀ {A B C} {f h : B ⇒ C} {g i : A ⇒ B} → f ≈ h → g ≈ i → f ∘ g ≈ h ∘ i
categoryHelper : ∀ {o ℓ e} → CategoryHelper o ℓ e → Category o ℓ e
categoryHelper C = record
{ Obj = Obj
; _⇒_ = _⇒_
; _≈_ = _≈_
; id = id
; _∘_ = _∘_
; assoc = assoc
; sym-assoc = sym assoc
; identityˡ = identityˡ
; identityʳ = identityʳ
; identity² = identityˡ
; equiv = equiv
; ∘-resp-≈ = ∘-resp-≈
}
where open CategoryHelper C
module _ {A B} where
open IsEquivalence (equiv {A} {B}) public
| {
"alphanum_fraction": 0.4986469421,
"avg_line_length": 32.4152046784,
"ext": "agda",
"hexsha": "a0db2e6a25850c8eab204567f0e94b71ccdc8fc1",
"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/Core.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/Core.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/Core.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2440,
"size": 5543
} |
-- Andreas, 2018-04-10, issue #3662.
-- Regression in the termination checker introduced together
-- with collecting function calls also in the type signatures
-- (fix of #1556).
record T : Set₂ where
field
Carr : Set₁
op : Carr → Carr
test : T
T.Carr test = Set
T.op test c = Aux
where
postulate Aux : Set
-- Aux : (c : T.Carr test) → Set
-- ^^^^^^^^^^^
-- Since c as a module parameter to the where-module is parameter of Aux,
-- it contains a recursive call if we also mine type signatures for calls
-- (#1556).
--
-- We get then
--
-- test .op c --> test .Carr
--
-- which is not a decreasing call.
-- However, the call does not compose with itself, thus, with
-- Hyvernat-termination it would not give a false termination alarm.
-- Should termination check.
| {
"alphanum_fraction": 0.6522277228,
"avg_line_length": 23.7647058824,
"ext": "agda",
"hexsha": "6f2f294e7161ca9f098da2b7507bc0b4c1792864",
"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/Issue3662.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/Issue3662.agda",
"max_line_length": 73,
"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/Issue3662.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": 221,
"size": 808
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Propositional (intensional) equality
------------------------------------------------------------------------
module Relation.Binary.PropositionalEquality where
open import Function
open import Function.Equality using (Π; _⟶_; ≡-setoid)
open import Data.Product
open import Data.Unit.Core
open import Level
open import Relation.Binary
import Relation.Binary.Indexed as I
open import Relation.Binary.Consequences
open import Relation.Binary.HeterogeneousEquality.Core as H using (_≅_)
-- Some of the definitions can be found in the following modules:
open import Relation.Binary.Core public using (_≡_; refl; _≢_)
open import Relation.Binary.PropositionalEquality.Core public
------------------------------------------------------------------------
-- Some properties
subst₂ : ∀ {a b p} {A : Set a} {B : Set b} (P : A → B → Set p)
{x₁ x₂ y₁ y₂} → x₁ ≡ x₂ → y₁ ≡ y₂ → P x₁ y₁ → P x₂ y₂
subst₂ P refl refl p = p
cong : ∀ {a b} {A : Set a} {B : Set b}
(f : A → B) {x y} → x ≡ y → f x ≡ f y
cong f refl = refl
cong-app : ∀ {a b} {A : Set a} {B : A → Set b} {f g : (x : A) → B x} →
f ≡ g → (x : A) → f x ≡ g x
cong-app refl x = refl
cong₂ : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c}
(f : A → B → C) {x y u v} → x ≡ y → u ≡ v → f x u ≡ f y v
cong₂ f refl refl = refl
proof-irrelevance : ∀ {a} {A : Set a} {x y : A} (p q : x ≡ y) → p ≡ q
proof-irrelevance refl refl = refl
setoid : ∀ {a} → Set a → Setoid _ _
setoid A = record
{ Carrier = A
; _≈_ = _≡_
; isEquivalence = isEquivalence
}
decSetoid : ∀ {a} {A : Set a} → Decidable (_≡_ {A = A}) → DecSetoid _ _
decSetoid dec = record
{ _≈_ = _≡_
; isDecEquivalence = record
{ isEquivalence = isEquivalence
; _≟_ = dec
}
}
isPreorder : ∀ {a} {A : Set a} → IsPreorder {A = A} _≡_ _≡_
isPreorder = record
{ isEquivalence = isEquivalence
; reflexive = id
; trans = trans
}
preorder : ∀ {a} → Set a → Preorder _ _ _
preorder A = record
{ Carrier = A
; _≈_ = _≡_
; _∼_ = _≡_
; isPreorder = isPreorder
}
------------------------------------------------------------------------
-- Pointwise equality
infix 4 _≗_
_→-setoid_ : ∀ {a b} (A : Set a) (B : Set b) → Setoid _ _
A →-setoid B = ≡-setoid A (Setoid.indexedSetoid (setoid B))
_≗_ : ∀ {a b} {A : Set a} {B : Set b} (f g : A → B) → Set _
_≗_ {A = A} {B} = Setoid._≈_ (A →-setoid B)
:→-to-Π : ∀ {a b₁ b₂} {A : Set a} {B : I.Setoid _ b₁ b₂} →
((x : A) → I.Setoid.Carrier B x) → Π (setoid A) B
:→-to-Π {B = B} f = record { _⟨$⟩_ = f; cong = cong′ }
where
open I.Setoid B using (_≈_)
cong′ : ∀ {x y} → x ≡ y → f x ≈ f y
cong′ refl = I.Setoid.refl B
→-to-⟶ : ∀ {a b₁ b₂} {A : Set a} {B : Setoid b₁ b₂} →
(A → Setoid.Carrier B) → setoid A ⟶ B
→-to-⟶ = :→-to-Π
------------------------------------------------------------------------
-- The old inspect idiom
-- The old inspect idiom has been deprecated, and may be removed in
-- the future. Use inspect on steroids instead.
module Deprecated-inspect where
-- The inspect idiom can be used when you want to pattern match on
-- the result r of some expression e, and you also need to
-- "remember" that r ≡ e.
-- The inspect idiom has a problem: sometimes you can only pattern
-- match on the p part of p with-≡ eq if you also pattern match on
-- the eq part, and then you no longer have access to the equality.
-- Inspect on steroids solves this problem.
data Inspect {a} {A : Set a} (x : A) : Set a where
_with-≡_ : (y : A) (eq : x ≡ y) → Inspect x
inspect : ∀ {a} {A : Set a} (x : A) → Inspect x
inspect x = x with-≡ refl
-- Example usage:
-- f x y with inspect (g x)
-- f x y | c z with-≡ eq = ...
------------------------------------------------------------------------
-- Inspect on steroids
-- Inspect on steroids can be used when you want to pattern match on
-- the result r of some expression e, and you also need to "remember"
-- that r ≡ e.
data Reveal_is_ {a} {A : Set a} (x : Hidden A) (y : A) : Set a where
[_] : (eq : reveal x ≡ y) → Reveal x is y
inspect : ∀ {a b} {A : Set a} {B : A → Set b}
(f : (x : A) → B x) (x : A) → Reveal (hide f x) is (f x)
inspect f x = [ refl ]
-- Example usage:
-- f x y with g x | inspect g x
-- f x y | c z | [ eq ] = ...
------------------------------------------------------------------------
-- Convenient syntax for equational reasoning
import Relation.Binary.EqReasoning as EqR
-- Relation.Binary.EqReasoning is more convenient to use with _≡_ if
-- the combinators take the type argument (a) as a hidden argument,
-- instead of being locked to a fixed type at module instantiation
-- time.
module ≡-Reasoning where
module _ {a} {A : Set a} where
open EqR (setoid A) public
hiding (_≡⟨_⟩_) renaming (_≈⟨_⟩_ to _≡⟨_⟩_)
infixr 2 _≅⟨_⟩_
_≅⟨_⟩_ : ∀ {a} {A : Set a} (x : A) {y z : A} →
x ≅ y → y IsRelatedTo z → x IsRelatedTo z
_ ≅⟨ x≅y ⟩ y≡z = _ ≡⟨ H.≅-to-≡ x≅y ⟩ y≡z
------------------------------------------------------------------------
-- Functional extensionality
-- If _≡_ were extensional, then the following statement could be
-- proved.
Extensionality : (a b : Level) → Set _
Extensionality a b =
{A : Set a} {B : A → Set b} {f g : (x : A) → B x} →
(∀ x → f x ≡ g x) → f ≡ g
-- If extensionality holds for a given universe level, then it also
-- holds for lower ones.
extensionality-for-lower-levels :
∀ {a₁ b₁} a₂ b₂ →
Extensionality (a₁ ⊔ a₂) (b₁ ⊔ b₂) → Extensionality a₁ b₁
extensionality-for-lower-levels a₂ b₂ ext f≡g =
cong (λ h → lower ∘ h ∘ lift) $
ext (cong (lift {ℓ = b₂}) ∘ f≡g ∘ lower {ℓ = a₂})
-- Functional extensionality implies a form of extensionality for
-- Π-types.
∀-extensionality :
∀ {a b} →
Extensionality a (suc b) →
{A : Set a} (B₁ B₂ : A → Set b) →
(∀ x → B₁ x ≡ B₂ x) → (∀ x → B₁ x) ≡ (∀ x → B₂ x)
∀-extensionality ext B₁ B₂ B₁≡B₂ with ext B₁≡B₂
∀-extensionality ext B .B B₁≡B₂ | refl = refl
| {
"alphanum_fraction": 0.5310311126,
"avg_line_length": 30.695,
"ext": "agda",
"hexsha": "9db5feef519f3a89014877b9c28701a7816c415d",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "qwe2/try-agda",
"max_forks_repo_path": "agda-stdlib-0.9/src/Relation/Binary/PropositionalEquality.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "qwe2/try-agda",
"max_issues_repo_path": "agda-stdlib-0.9/src/Relation/Binary/PropositionalEquality.agda",
"max_line_length": 72,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "qwe2/try-agda",
"max_stars_repo_path": "agda-stdlib-0.9/src/Relation/Binary/PropositionalEquality.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": 2129,
"size": 6139
} |
{-# OPTIONS --without-K #-}
open import Type
open import Type.Identities
open import Level.NP
open import Explore.Core
open import Explore.Properties
open import Explore.Explorable
open import Data.One
open import Data.Fin
open import Function.NP
open import Data.Product
open import HoTT
open import Relation.Binary.PropositionalEquality.NP using (refl; _≡_; !_)
import Explore.Monad
module Explore.One where
module _ {ℓ} where
open Explore.Monad {₀} ℓ
𝟙ᵉ : Explore ℓ 𝟙
𝟙ᵉ = return _
{- or
𝟙ᵉ _ f = f _
-}
𝟙ⁱ : ∀ {p} → ExploreInd p 𝟙ᵉ
𝟙ⁱ = return-ind _
{- or
𝟙ⁱ _ _ Pf = Pf _
-}
module _ {ℓ₁ ℓ₂ ℓᵣ} {R : 𝟙 → 𝟙 → ★₀} {r : R _ _} where
⟦𝟙ᵉ⟧ : ⟦Explore⟧ {ℓ₁} {ℓ₂} ℓᵣ R 𝟙ᵉ 𝟙ᵉ
⟦𝟙ᵉ⟧ _ _ _∙ᵣ_ fᵣ = fᵣ r
module 𝟙ⁱ = FromExploreInd 𝟙ⁱ
open 𝟙ⁱ public using ()
renaming (sum to 𝟙ˢ
;product to 𝟙ᵖ
;reify to 𝟙ʳ
;unfocus to 𝟙ᵘ
)
open Adequacy _≡_
module _ {{_ : UA}} where
Σᵉ𝟙-ok : ∀ {ℓ} → Adequate-Σ {ℓ} (Σᵉ 𝟙ᵉ)
Σᵉ𝟙-ok _ = ! Σ𝟙-snd
Πᵉ𝟙-ok : ∀ {ℓ} → Adequate-Π {ℓ} (Πᵉ 𝟙ᵉ)
Πᵉ𝟙-ok _ = ! Π𝟙-uniq _
𝟙ˢ-ok : Adequate-sum 𝟙ˢ
𝟙ˢ-ok _ = ! 𝟙×-snd
𝟙ᵖ-ok : Adequate-product 𝟙ᵖ
𝟙ᵖ-ok _ = ! Π𝟙-uniq _
adequate-sum𝟙 = 𝟙ˢ-ok
adequate-product𝟙 = 𝟙ᵖ-ok
module _ {ℓ} where
𝟙ˡ : Lookup {ℓ} 𝟙ᵉ
𝟙ˡ = const
𝟙ᶠ : Focus {ℓ} 𝟙ᵉ
𝟙ᶠ = proj₂
explore𝟙 = 𝟙ᵉ
explore𝟙-ind = 𝟙ⁱ
lookup𝟙 = 𝟙ˡ
reify𝟙 = 𝟙ʳ
focus𝟙 = 𝟙ᶠ
unfocus𝟙 = 𝟙ᵘ
sum𝟙 = 𝟙ˢ
product𝟙 = 𝟙ᵖ
| {
"alphanum_fraction": 0.5673076923,
"avg_line_length": 19.746835443,
"ext": "agda",
"hexsha": "adeb8680a09774c9acdd5609415caae51c95fa21",
"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": "16bc8333503ff9c00d47d56f4ec6113b9269a43e",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "crypto-agda/explore",
"max_forks_repo_path": "lib/Explore/One.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e",
"max_issues_repo_issues_event_max_datetime": "2019-03-16T14:24:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-03-16T14:24:04.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "crypto-agda/explore",
"max_issues_repo_path": "lib/Explore/One.agda",
"max_line_length": 74,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "crypto-agda/explore",
"max_stars_repo_path": "lib/Explore/One.agda",
"max_stars_repo_stars_event_max_datetime": "2017-06-28T19:19:29.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-06-05T09:25:32.000Z",
"num_tokens": 851,
"size": 1560
} |
module MissingDefinition where
open import Agda.Builtin.Equality
Q : Set
data U : Set
S : Set
S = U
T : S → Set
T _ = U
V : Set
W : V → Set
private
X : Set
module AB where
data A : Set
B : (a b : A) → a ≡ b
mutual
U₂ : Set
data T₂ : U₂ → Set
V₂ : (u₂ : U₂) → T₂ u₂ → Set
data W₂ (u₂ : U₂) (t₂ : T₂ u₂) : V₂ u₂ t₂ → Set
| {
"alphanum_fraction": 0.5539358601,
"avg_line_length": 11.064516129,
"ext": "agda",
"hexsha": "cb937946de8b8b80721fcfb693e9cc60ee69bbbd",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "alhassy/agda",
"max_forks_repo_path": "test/Succeed/MissingDefinition.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "alhassy/agda",
"max_issues_repo_path": "test/Succeed/MissingDefinition.agda",
"max_line_length": 49,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "alhassy/agda",
"max_stars_repo_path": "test/Succeed/MissingDefinition.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 152,
"size": 343
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.