Search is not available for this dataset
text
string | meta
dict |
---|---|
module std-reduction.Base where
open import Esterel.Lang
open import Esterel.Lang.Properties
open import Esterel.Context
using (EvaluationContext ; EvaluationContext1 ; _⟦_⟧e ; _≐_⟦_⟧e ;
Context ; Context1 ; _⟦_⟧c ; _≐_⟦_⟧c)
open EvaluationContext1
open import Esterel.Lang
open import Esterel.Environment as Env
using (Env)
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 import Esterel.Lang.CanFunction
using (Canₛ ; Canₛₕ)
open import Data.List
using (List; _∷_ ; [] ; mapMaybe)
open import Data.List.Any
using (any)
open import blocked
open import Data.Sum
using (_⊎_ ; inj₁ ; inj₂)
open import Data.Product using (_×_ ; proj₁ ; proj₂ ; _,_ ; ∃-syntax; Σ-syntax)
open import Relation.Binary.PropositionalEquality
using (_≡_ ; sym)
open _≡_
import Data.Nat as Nat
open import Relation.Nullary using (yes ; no ; ¬_)
open import Function using (_∘_ ; id ; _$_)
open import Data.Maybe
using (Maybe)
open Maybe
open import Relation.Nullary.Decidable
using (⌊_⌋)
open import Data.Bool
using (if_then_else_)
blocked-or-done : Env → Ctrl → Term → Set
blocked-or-done θ A p = (done p) ⊎ (blocked θ A p)
mutual
set-all-absent : (θ : Env) → (List (∃[ S ] Env.isSig∈ S θ)) → Env
set-all-absent θ [] = θ
set-all-absent θ ((S , S∈) ∷ Ss)
= Env.set-sig{S} (set-all-absent θ Ss) (set-all-absent∈ θ S Ss S∈) Signal.absent
set-all-absent∈ : ∀ θ S Ss → Env.isSig∈ S θ → Env.isSig∈ S (set-all-absent θ Ss)
set-all-absent∈ θ S [] S∈ = S∈
set-all-absent∈ θ S (x ∷ Ss) S∈
= Env.sig-set-mono'{S = S}{S' = (proj₁ x)}{θ = set-all-absent θ Ss}{S'∈ = S'∈2} S∈2
where
S∈2 = (set-all-absent∈ θ S Ss S∈)
S'∈2 = (set-all-absent∈ θ (proj₁ x) Ss (proj₂ x))
mutual
set-all-ready : (θ : Env) → (List (∃[ s ] Env.isShr∈ s θ)) → Env
set-all-ready θ [] = θ
set-all-ready θ ((s , s∈) ∷ ss)
= Env.set-shr {s} θ2 s∈2 SharedVar.ready (Env.shr-vals{s} θ s∈)
where
s∈2 = (set-all-ready∈ θ s ss s∈)
θ2 = (set-all-ready θ ss)
set-all-ready∈ : ∀ θ s ss → Env.isShr∈ s θ → Env.isShr∈ s (set-all-ready θ ss)
set-all-ready∈ θ s [] s∈ = s∈
set-all-ready∈ θ s (x ∷ ss) s∈
= Env.shr-set-mono' {s = s} {s' = proj₁ x} {θ = set-all-ready θ ss}
{s'∈ = set-all-ready∈ θ (proj₁ x) ss (proj₂ x)} (set-all-ready∈ θ s ss s∈)
shr-val-same-after-all-ready : ∀ s θ ss →
(s∈ : Env.isShr∈ s θ) →
(s∈2 : Env.isShr∈ s (set-all-ready θ ss)) →
(Env.shr-vals {s} θ s∈) ≡ (Env.shr-vals {s} (set-all-ready θ ss) s∈2)
shr-val-same-after-all-ready s θ [] s∈ s∈2 = Env.shr-vals-∈-irr{s}{θ} s∈ s∈2
shr-val-same-after-all-ready s θ ((s' , s'∈) ∷ ss) s∈ s∈2 with (SharedVar._≟_ s' s)
... | yes p rewrite p | Env.shr∈-eq{s}{θ} s∈ s'∈
= sym (proj₂ (Env.shr-putget{s}{(set-all-ready θ ss)}{SharedVar.ready}{(Env.shr-vals {s} θ s'∈)} (set-all-ready∈ θ s ss s∈) s∈2))
... | no ¬s'≡s
= sym
(proj₂
(Env.shr-putputget{θ = (set-all-ready θ ss)}{v1l = Env.shr-stats{s} (set-all-ready θ ss) ((set-all-ready∈ θ s ss s∈))}
(¬s'≡s ∘ sym)
(set-all-ready∈ θ s ss s∈)
(set-all-ready∈ θ s' ss s'∈)
s∈2
refl
(sym (shr-val-same-after-all-ready s θ ss s∈ (set-all-ready∈ θ s ss s∈))) ))
--
can-set-absent' : (θ : Env) → Term →
List (∃[ S ] (Σ[ S∈ ∈ (Env.isSig∈ S θ) ] (Env.sig-stats{S} θ S∈ ≡ Signal.unknown)))
can-set-absent' θ p = mapMaybe id $ Env.SigDomMap θ get-res
where
get-res : (S : Signal) → Env.isSig∈ S θ → Maybe (∃[ S ] (Σ[ S∈ ∈ (Env.isSig∈ S θ) ] (Env.sig-stats{S} θ S∈ ≡ Signal.unknown)))
get-res S S∈ with any (Nat._≟_ (Signal.unwrap S)) (Canₛ p θ) | Signal._≟ₛₜ_ (Env.sig-stats{S} θ S∈) Signal.unknown
... | no _ | yes eq = just $ S , (S∈ , eq)
... | _ | _ = nothing
can-set-absent : (θ : Env) → Term → List (∃[ S ] Env.isSig∈ S θ)
can-set-absent θ p
= Data.List.map (λ x → proj₁ x , proj₁ (proj₂ x))
(can-set-absent' θ p)
CanSetToReady : Env → Set
CanSetToReady θ = (∃[ s ] (Σ[ S∈ ∈ (Env.isShr∈ s θ) ] (Env.shr-stats{s} θ S∈ ≡ SharedVar.old ⊎ Env.shr-stats{s} θ S∈ ≡ SharedVar.new)))
can-set-ready' : (θ : Env) → Term → List (CanSetToReady θ)
can-set-ready' θ p = mapMaybe id $ Env.ShrDomMap θ get-res
where
get-res : (s : SharedVar) → Env.isShr∈ s θ → Maybe (CanSetToReady θ)
get-res s s∈ with any (Nat._≟_ (SharedVar.unwrap s)) (Canₛₕ p θ)
| SharedVar._≟ₛₜ_ (Env.shr-stats{s} θ s∈) SharedVar.old
| SharedVar._≟ₛₜ_ (Env.shr-stats{s} θ s∈) SharedVar.new
... | no _ | yes eq | _ = just $ s , (s∈ , inj₁ eq)
... | no _ | no _ | yes eq = just $ s , (s∈ , inj₂ eq)
... | _ | yes _ | yes _ = nothing
... | _ | yes _ | no _ = nothing
... | _ | no _ | yes _ = nothing
... | _ | no _ | no _ = nothing
can-set-ready : (θ : Env) → Term → List (∃[ s ] Env.isShr∈ s θ)
can-set-ready θ p = Data.List.map (λ x → proj₁ x , proj₁ (proj₂ x)) (can-set-ready' θ p)
data left-most : Env → EvaluationContext → Set where
lhole : ∀{θ} → left-most θ []
lseq : ∀{θ E q} → left-most θ E → left-most θ ((eseq q) ∷ E)
lloopˢ : ∀{θ E q} → left-most θ E → left-most θ ((eloopˢ q) ∷ E)
lparl : ∀{θ E q} → left-most θ E → left-most θ ((epar₁ q) ∷ E)
lparrdone : ∀{θ E p} → done p → left-most θ E → left-most θ ((epar₂ p) ∷ E)
lparrblocked : ∀{θ A E p} → blocked θ A p → left-most θ E → left-most θ ((epar₂ p) ∷ E)
lsuspend : ∀{θ E S} → left-most θ E → left-most θ ((esuspend S) ∷ E)
ltrap : ∀{θ E} → left-most θ E → left-most θ (etrap ∷ E)
| {
"alphanum_fraction": 0.5614936622,
"avg_line_length": 40.5416666667,
"ext": "agda",
"hexsha": "096e599dfa508e4667cf105cda6d4cb467e43b4e",
"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/std-reduction/Base.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/std-reduction/Base.agda",
"max_line_length": 135,
"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/std-reduction/Base.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": 2350,
"size": 5838
} |
module examples.Vec where
{- Computed datatypes -}
data One : Set where
unit : One
data Nat : Set where
zero : Nat
suc : Nat -> Nat
data _*_ (A B : Set) : Set where
pair : A -> B -> A * B
infixr 20 _=>_
data _=>_ (A B : Set) : Set where
lam : (A -> B) -> A => B
lam2 : {A B C : Set} -> (A -> B -> C) -> (A => B => C)
lam2 f = lam (\x -> lam (f x))
app : {A B : Set} -> (A => B) -> A -> B
app (lam f) x = f x
Vec : Nat -> Set -> Set
Vec zero X = One
Vec (suc n) X = X * Vec n X
{- ... construct the vectors of a given length -}
vHead : {X : Set} -> (n : Nat)-> Vec (suc n) X -> X
vHead n (pair a b) = a
vTail : {X : Set} -> (n : Nat)-> Vec (suc n) X -> Vec n X
vTail n (pair a b) = b
{- safe destructors for nonempty vectors -}
{- useful vector programming operators -}
vec : {X : Set} -> (n : Nat) -> X -> Vec n X
vec zero x = unit
vec (suc n) x = pair x (vec n x)
vapp : {S T : Set} -> (n : Nat) -> Vec n (S => T) -> Vec n S -> Vec n T
vapp zero unit unit = unit
vapp (suc n) (pair f fs) (pair s ss) = pair (app f s) (vapp n fs ss)
{- mapping and zipping come from these -}
vMap : {S T : Set} -> (n : Nat) -> (S -> T) -> Vec n S -> Vec n T
vMap n f ss = vapp n (vec n (lam f)) ss
{- transposition gets the type it deserves -}
transpose : {X : Set} -> (m n : Nat)-> Vec m (Vec n X) -> Vec n (Vec m X)
transpose zero n xss = vec n unit
transpose (suc m) n (pair xs xss) =
vapp n (vapp n (vec n (lam2 pair)) xs)
(transpose m n xss)
{- Sets of a given finite size may be computed as follows... -}
{- Resist the temptation to mention idioms. -}
data Zero : Set where
data _+_ (A B : Set) : Set where
inl : A -> A + B
inr : B -> A + B
Fin : Nat -> Set
Fin zero = Zero
Fin (suc n) = One + Fin n
{- We can use these sets to index vectors safely. -}
vProj : {X : Set} -> (n : Nat)-> Vec n X -> Fin n -> X
-- vProj zero () we can pretend that there is an exhaustiveness check
vProj (suc n) (pair x xs) (inl unit) = x
vProj (suc n) (pair x xs) (inr i) = vProj n xs i
{- We can also tabulate a function as a vector. Resist
the temptation to mention logarithms. -}
vTab : {X : Set} -> (n : Nat)-> (Fin n -> X) -> Vec n X
vTab zero _ = unit
vTab (suc n) f = pair (f (inl unit)) (vTab n (\x -> f (inr x)))
{- Question to ponder in your own time:
if we use functional vectors what are vec and vapp -}
{- Answer: K and S -}
{- Inductive datatypes of the unfocused variety -}
{- Every constructor must target the whole family rather
than focusing on specific indices. -}
data Tm (n : Nat) : Set where
evar : Fin n -> Tm n
eapp : Tm n -> Tm n -> Tm n
elam : Tm (suc n) -> Tm n
{- Renamings -}
Ren : Nat -> Nat -> Set
Ren m n = Vec m (Fin n)
_`Ren`_ = Ren
{- identity and composition -}
idR : (n : Nat) -> n `Ren` n
idR n = vTab n (\i -> i)
coR : (l m n : Nat) -> m `Ren` n -> l `Ren` m -> l `Ren` n
coR l m n m2n l2m = vMap l (vProj m m2n) l2m
{- what theorems should we prove -}
{- the lifting functor for Ren -}
liftR : (m n : Nat) -> m `Ren` n -> suc m `Ren` suc n
liftR m n m2n = pair (inl unit) (vMap m inr m2n)
{- what theorems should we prove -}
{- the functor from Ren to Tm-arrows -}
rename : {m n : Nat} -> (m `Ren` n) -> Tm m -> Tm n
rename {m}{n} m2n (evar i) = evar (vProj m m2n i)
rename {m}{n} m2n (eapp f s) = eapp (rename m2n f) (rename m2n s)
rename {m}{n} m2n (elam t) = elam (rename (liftR m n m2n) t)
{- Substitutions -}
Sub : Nat -> Nat -> Set
Sub m n = Vec m (Tm n)
_`Sub`_ = Sub
{- identity; composition must wait; why -}
idS : (n : Nat) -> n `Sub` n
idS n = vTab n (evar {n})
{- functor from renamings to substitutions -}
Ren2Sub : (m n : Nat) -> m `Ren` n -> m `Sub` n
Ren2Sub m n m2n = vMap m evar m2n
{- lifting functor for substitution -}
liftS : (m n : Nat) -> m `Sub` n -> suc m `Sub` suc n
liftS m n m2n = pair (evar (inl unit))
(vMap m (rename (vMap n inr (idR n))) m2n)
{- functor from Sub to Tm-arrows -}
subst : {m n : Nat} -> m `Sub` n -> Tm m -> Tm n
subst {m}{n} m2n (evar i) = vProj m m2n i
subst {m}{n} m2n (eapp f s) = eapp (subst m2n f) (subst m2n s)
subst {m}{n} m2n (elam t) = elam (subst (liftS m n m2n) t)
{- and now we can define composition -}
coS : (l m n : Nat) -> m `Sub` n -> l `Sub` m -> l `Sub` n
coS l m n m2n l2m = vMap l (subst m2n) l2m
| {
"alphanum_fraction": 0.5399424651,
"avg_line_length": 26.7396449704,
"ext": "agda",
"hexsha": "afe5ee1d7b10e1db5673712b7bdc987f0459cd69",
"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": "examples/outdated-and-incorrect/Alonzo/Vec.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": "examples/outdated-and-incorrect/Alonzo/Vec.agda",
"max_line_length": 75,
"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": "examples/outdated-and-incorrect/Alonzo/Vec.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1743,
"size": 4519
} |
open import Level
open import Ordinals
module OrdUtil {n : Level} (O : Ordinals {n} ) where
open import logic
open import nat
open import Data.Nat renaming ( zero to Zero ; suc to Suc ; ℕ to Nat ; _⊔_ to _n⊔_ )
open import Data.Empty
open import Relation.Binary.PropositionalEquality
open import Relation.Nullary
open import Relation.Binary hiding (_⇔_)
open Ordinals.Ordinals O
open Ordinals.IsOrdinals isOrdinal
open Ordinals.IsNext isNext
o<-dom : { x y : Ordinal } → x o< y → Ordinal
o<-dom {x} _ = x
o<-cod : { x y : Ordinal } → x o< y → Ordinal
o<-cod {_} {y} _ = y
o<-subst : {Z X z x : Ordinal } → Z o< X → Z ≡ z → X ≡ x → z o< x
o<-subst df refl refl = df
o<¬≡ : { ox oy : Ordinal } → ox ≡ oy → ox o< oy → ⊥
o<¬≡ {ox} {oy} eq lt with trio< ox oy
o<¬≡ {ox} {oy} eq lt | tri< a ¬b ¬c = ¬b eq
o<¬≡ {ox} {oy} eq lt | tri≈ ¬a b ¬c = ¬a lt
o<¬≡ {ox} {oy} eq lt | tri> ¬a ¬b c = ¬b eq
o<> : {x y : Ordinal } → y o< x → x o< y → ⊥
o<> {ox} {oy} lt tl with trio< ox oy
o<> {ox} {oy} lt tl | tri< a ¬b ¬c = ¬c lt
o<> {ox} {oy} lt tl | tri≈ ¬a b ¬c = ¬a tl
o<> {ox} {oy} lt tl | tri> ¬a ¬b c = ¬a tl
osuc-< : { x y : Ordinal } → y o< osuc x → x o< y → ⊥
osuc-< {x} {y} y<ox x<y with osuc-≡< y<ox
osuc-< {x} {y} y<ox x<y | case1 refl = o<¬≡ refl x<y
osuc-< {x} {y} y<ox x<y | case2 y<x = o<> x<y y<x
osucc : {ox oy : Ordinal } → oy o< ox → osuc oy o< osuc ox
---- y < osuc y < x < osuc x
---- y < osuc y = x < osuc x
---- y < osuc y > x < osuc x -> y = x ∨ x < y → ⊥
osucc {ox} {oy} oy<ox with trio< (osuc oy) ox
osucc {ox} {oy} oy<ox | tri< a ¬b ¬c = ordtrans a <-osuc
osucc {ox} {oy} oy<ox | tri≈ ¬a refl ¬c = <-osuc
osucc {ox} {oy} oy<ox | tri> ¬a ¬b c with osuc-≡< c
osucc {ox} {oy} oy<ox | tri> ¬a ¬b c | case1 eq = ⊥-elim (o<¬≡ (sym eq) oy<ox)
osucc {ox} {oy} oy<ox | tri> ¬a ¬b c | case2 lt = ⊥-elim (o<> lt oy<ox)
osucprev : {ox oy : Ordinal } → osuc oy o< osuc ox → oy o< ox
osucprev {ox} {oy} oy<ox with trio< oy ox
osucprev {ox} {oy} oy<ox | tri< a ¬b ¬c = a
osucprev {ox} {oy} oy<ox | tri≈ ¬a b ¬c = ⊥-elim (o<¬≡ (cong (λ k → osuc k) b) oy<ox )
osucprev {ox} {oy} oy<ox | tri> ¬a ¬b c = ⊥-elim (o<> (osucc c) oy<ox )
open _∧_
osuc2 : ( x y : Ordinal ) → ( osuc x o< osuc (osuc y )) ⇔ (x o< osuc y)
proj2 (osuc2 x y) lt = osucc lt
proj1 (osuc2 x y) ox<ooy with osuc-≡< ox<ooy
proj1 (osuc2 x y) ox<ooy | case1 ox=oy = o<-subst <-osuc refl ox=oy
proj1 (osuc2 x y) ox<ooy | case2 ox<oy = ordtrans <-osuc ox<oy
_o≤_ : Ordinal → Ordinal → Set n
a o≤ b = a o< osuc b -- (a ≡ b) ∨ ( a o< b )
xo<ab : {oa ob : Ordinal } → ( {ox : Ordinal } → ox o< oa → ox o< ob ) → oa o< osuc ob
xo<ab {oa} {ob} a→b with trio< oa ob
xo<ab {oa} {ob} a→b | tri< a ¬b ¬c = ordtrans a <-osuc
xo<ab {oa} {ob} a→b | tri≈ ¬a refl ¬c = <-osuc
xo<ab {oa} {ob} a→b | tri> ¬a ¬b c = ⊥-elim ( o<¬≡ refl (a→b c ) )
maxα : Ordinal → Ordinal → Ordinal
maxα x y with trio< x y
maxα x y | tri< a ¬b ¬c = y
maxα x y | tri> ¬a ¬b c = x
maxα x y | tri≈ ¬a refl ¬c = x
omin : Ordinal → Ordinal → Ordinal
omin x y with trio< x y
omin x y | tri< a ¬b ¬c = x
omin x y | tri> ¬a ¬b c = y
omin x y | tri≈ ¬a refl ¬c = x
min1 : {x y z : Ordinal } → z o< x → z o< y → z o< omin x y
min1 {x} {y} {z} z<x z<y with trio< x y
min1 {x} {y} {z} z<x z<y | tri< a ¬b ¬c = z<x
min1 {x} {y} {z} z<x z<y | tri≈ ¬a refl ¬c = z<x
min1 {x} {y} {z} z<x z<y | tri> ¬a ¬b c = z<y
--
-- max ( osuc x , osuc y )
--
omax : ( x y : Ordinal ) → Ordinal
omax x y with trio< x y
omax x y | tri< a ¬b ¬c = osuc y
omax x y | tri> ¬a ¬b c = osuc x
omax x y | tri≈ ¬a refl ¬c = osuc x
omax< : ( x y : Ordinal ) → x o< y → osuc y ≡ omax x y
omax< x y lt with trio< x y
omax< x y lt | tri< a ¬b ¬c = refl
omax< x y lt | tri≈ ¬a b ¬c = ⊥-elim (¬a lt )
omax< x y lt | tri> ¬a ¬b c = ⊥-elim (¬a lt )
omax≤ : ( x y : Ordinal ) → x o≤ y → osuc y ≡ omax x y
omax≤ x y le with trio< x y
omax≤ x y le | tri< a ¬b ¬c = refl
omax≤ x y le | tri≈ ¬a refl ¬c = refl
omax≤ x y le | tri> ¬a ¬b c with osuc-≡< le
omax≤ x y le | tri> ¬a ¬b c | case1 eq = ⊥-elim (¬b eq)
omax≤ x y le | tri> ¬a ¬b c | case2 x<y = ⊥-elim (¬a x<y)
omax≡ : ( x y : Ordinal ) → x ≡ y → osuc y ≡ omax x y
omax≡ x y eq with trio< x y
omax≡ x y eq | tri< a ¬b ¬c = ⊥-elim (¬b eq )
omax≡ x y eq | tri≈ ¬a refl ¬c = refl
omax≡ x y eq | tri> ¬a ¬b c = ⊥-elim (¬b eq )
omax-x : ( x y : Ordinal ) → x o< omax x y
omax-x x y with trio< x y
omax-x x y | tri< a ¬b ¬c = ordtrans a <-osuc
omax-x x y | tri> ¬a ¬b c = <-osuc
omax-x x y | tri≈ ¬a refl ¬c = <-osuc
omax-y : ( x y : Ordinal ) → y o< omax x y
omax-y x y with trio< x y
omax-y x y | tri< a ¬b ¬c = <-osuc
omax-y x y | tri> ¬a ¬b c = ordtrans c <-osuc
omax-y x y | tri≈ ¬a refl ¬c = <-osuc
omxx : ( x : Ordinal ) → omax x x ≡ osuc x
omxx x with trio< x x
omxx x | tri< a ¬b ¬c = ⊥-elim (¬b refl )
omxx x | tri> ¬a ¬b c = ⊥-elim (¬b refl )
omxx x | tri≈ ¬a refl ¬c = refl
omxxx : ( x : Ordinal ) → omax x (omax x x ) ≡ osuc (osuc x)
omxxx x = trans ( cong ( λ k → omax x k ) (omxx x )) (sym ( omax< x (osuc x) <-osuc ))
open _∧_
o≤-refl : { i j : Ordinal } → i ≡ j → i o≤ j
o≤-refl {i} {j} eq = subst (λ k → i o< osuc k ) eq <-osuc
OrdTrans : Transitive _o≤_
OrdTrans a≤b b≤c with osuc-≡< a≤b | osuc-≡< b≤c
OrdTrans a≤b b≤c | case1 refl | case1 refl = <-osuc
OrdTrans a≤b b≤c | case1 refl | case2 a≤c = ordtrans a≤c <-osuc
OrdTrans a≤b b≤c | case2 a≤c | case1 refl = ordtrans a≤c <-osuc
OrdTrans a≤b b≤c | case2 a<b | case2 b<c = ordtrans (ordtrans a<b b<c) <-osuc
OrdPreorder : Preorder n n n
OrdPreorder = record { Carrier = Ordinal
; _≈_ = _≡_
; _∼_ = _o≤_
; isPreorder = record {
isEquivalence = record { refl = refl ; sym = sym ; trans = trans }
; reflexive = o≤-refl
; trans = OrdTrans
}
}
FExists : {m l : Level} → ( ψ : Ordinal → Set m )
→ {p : Set l} ( P : { y : Ordinal } → ψ y → ¬ p )
→ (exists : ¬ (∀ y → ¬ ( ψ y ) ))
→ ¬ p
FExists {m} {l} ψ {p} P = contra-position ( λ p y ψy → P {y} ψy p )
nexto∅ : {x : Ordinal} → o∅ o< next x
nexto∅ {x} with trio< o∅ x
nexto∅ {x} | tri< a ¬b ¬c = ordtrans a x<nx
nexto∅ {x} | tri≈ ¬a b ¬c = subst (λ k → k o< next x) (sym b) x<nx
nexto∅ {x} | tri> ¬a ¬b c = ⊥-elim ( ¬x<0 c )
next< : {x y z : Ordinal} → x o< next z → y o< next x → y o< next z
next< {x} {y} {z} x<nz y<nx with trio< y (next z)
next< {x} {y} {z} x<nz y<nx | tri< a ¬b ¬c = a
next< {x} {y} {z} x<nz y<nx | tri≈ ¬a b ¬c = ⊥-elim (¬nx<nx x<nz (subst (λ k → k o< next x) b y<nx)
(λ w nz=ow → o<¬≡ nz=ow (subst₂ (λ j k → j o< k ) (sym nz=ow) nz=ow (osuc<nx (subst (λ k → w o< k ) (sym nz=ow) <-osuc) ))))
next< {x} {y} {z} x<nz y<nx | tri> ¬a ¬b c = ⊥-elim (¬nx<nx x<nz (ordtrans c y<nx )
(λ w nz=ow → o<¬≡ (sym nz=ow) (osuc<nx (subst (λ k → w o< k ) (sym nz=ow) <-osuc ))))
osuc< : {x y : Ordinal} → osuc x ≡ y → x o< y
osuc< {x} {y} refl = <-osuc
nexto=n : {x y : Ordinal} → x o< next (osuc y) → x o< next y
nexto=n {x} {y} x<noy = next< (osuc<nx x<nx) x<noy
nexto≡ : {x : Ordinal} → next x ≡ next (osuc x)
nexto≡ {x} with trio< (next x) (next (osuc x) )
-- next x o< next (osuc x ) -> osuc x o< next x o< next (osuc x) -> next x ≡ osuc z -> z o o< next x -> osuc z o< next x -> next x o< next x
nexto≡ {x} | tri< a ¬b ¬c = ⊥-elim (¬nx<nx (osuc<nx x<nx ) a
(λ z eq → o<¬≡ (sym eq) (osuc<nx (osuc< (sym eq)))))
nexto≡ {x} | tri≈ ¬a b ¬c = b
-- next (osuc x) o< next x -> osuc x o< next (osuc x) o< next x -> next (osuc x) ≡ osuc z -> z o o< next (osuc x) ...
nexto≡ {x} | tri> ¬a ¬b c = ⊥-elim (¬nx<nx (ordtrans <-osuc x<nx) c
(λ z eq → o<¬≡ (sym eq) (osuc<nx (osuc< (sym eq)))))
next-is-limit : {x y : Ordinal} → ¬ (next x ≡ osuc y)
next-is-limit {x} {y} eq = o<¬≡ (sym eq) (osuc<nx y<nx) where
y<nx : y o< next x
y<nx = osuc< (sym eq)
omax<next : {x y : Ordinal} → x o< y → omax x y o< next y
omax<next {x} {y} x<y = subst (λ k → k o< next y ) (omax< _ _ x<y ) (osuc<nx x<nx)
x<ny→≡next : {x y : Ordinal} → x o< y → y o< next x → next x ≡ next y
x<ny→≡next {x} {y} x<y y<nx with trio< (next x) (next y)
x<ny→≡next {x} {y} x<y y<nx | tri< a ¬b ¬c = -- x < y < next x < next y ∧ next x = osuc z
⊥-elim ( ¬nx<nx y<nx a (λ z eq → o<¬≡ (sym eq) (osuc<nx (subst (λ k → z o< k ) (sym eq) <-osuc ))))
x<ny→≡next {x} {y} x<y y<nx | tri≈ ¬a b ¬c = b
x<ny→≡next {x} {y} x<y y<nx | tri> ¬a ¬b c = -- x < y < next y < next x
⊥-elim ( ¬nx<nx (ordtrans x<y x<nx) c (λ z eq → o<¬≡ (sym eq) (osuc<nx (subst (λ k → z o< k ) (sym eq) <-osuc ))))
≤next : {x y : Ordinal} → x o≤ y → next x o≤ next y
≤next {x} {y} x≤y with trio< (next x) y
≤next {x} {y} x≤y | tri< a ¬b ¬c = ordtrans a (ordtrans x<nx <-osuc )
≤next {x} {y} x≤y | tri≈ ¬a refl ¬c = (ordtrans x<nx <-osuc )
≤next {x} {y} x≤y | tri> ¬a ¬b c with osuc-≡< x≤y
≤next {x} {y} x≤y | tri> ¬a ¬b c | case1 refl = o≤-refl refl -- x = y < next x
≤next {x} {y} x≤y | tri> ¬a ¬b c | case2 x<y = o≤-refl (x<ny→≡next x<y c) -- x ≤ y < next x
x<ny→≤next : {x y : Ordinal} → x o< next y → next x o≤ next y
x<ny→≤next {x} {y} x<ny with trio< x y
x<ny→≤next {x} {y} x<ny | tri< a ¬b ¬c = ≤next (ordtrans a <-osuc )
x<ny→≤next {x} {y} x<ny | tri≈ ¬a refl ¬c = o≤-refl refl
x<ny→≤next {x} {y} x<ny | tri> ¬a ¬b c = o≤-refl (sym ( x<ny→≡next c x<ny ))
omax<nomax : {x y : Ordinal} → omax x y o< next (omax x y )
omax<nomax {x} {y} with trio< x y
omax<nomax {x} {y} | tri< a ¬b ¬c = subst (λ k → osuc y o< k ) nexto≡ (osuc<nx x<nx )
omax<nomax {x} {y} | tri≈ ¬a refl ¬c = subst (λ k → osuc x o< k ) nexto≡ (osuc<nx x<nx )
omax<nomax {x} {y} | tri> ¬a ¬b c = subst (λ k → osuc x o< k ) nexto≡ (osuc<nx x<nx )
omax<nx : {x y z : Ordinal} → x o< next z → y o< next z → omax x y o< next z
omax<nx {x} {y} {z} x<nz y<nz with trio< x y
omax<nx {x} {y} {z} x<nz y<nz | tri< a ¬b ¬c = osuc<nx y<nz
omax<nx {x} {y} {z} x<nz y<nz | tri≈ ¬a refl ¬c = osuc<nx y<nz
omax<nx {x} {y} {z} x<nz y<nz | tri> ¬a ¬b c = osuc<nx x<nz
nn<omax : {x nx ny : Ordinal} → x o< next nx → x o< next ny → x o< next (omax nx ny)
nn<omax {x} {nx} {ny} xnx xny with trio< nx ny
nn<omax {x} {nx} {ny} xnx xny | tri< a ¬b ¬c = subst (λ k → x o< k ) nexto≡ xny
nn<omax {x} {nx} {ny} xnx xny | tri≈ ¬a refl ¬c = subst (λ k → x o< k ) nexto≡ xny
nn<omax {x} {nx} {ny} xnx xny | tri> ¬a ¬b c = subst (λ k → x o< k ) nexto≡ xnx
record OrdinalSubset (maxordinal : Ordinal) : Set (suc n) where
field
os→ : (x : Ordinal) → x o< maxordinal → Ordinal
os← : Ordinal → Ordinal
os←limit : (x : Ordinal) → os← x o< maxordinal
os-iso← : {x : Ordinal} → os→ (os← x) (os←limit x) ≡ x
os-iso→ : {x : Ordinal} → (lt : x o< maxordinal ) → os← (os→ x lt) ≡ x
module o≤-Reasoning {n : Level} (O : Ordinals {n} ) where
-- open inOrdinal O
resp-o< : _o<_ Respects₂ _≡_
resp-o< = resp₂ _o<_
trans1 : {i j k : Ordinal} → i o< j → j o< osuc k → i o< k
trans1 {i} {j} {k} i<j j<ok with osuc-≡< j<ok
trans1 {i} {j} {k} i<j j<ok | case1 refl = i<j
trans1 {i} {j} {k} i<j j<ok | case2 j<k = ordtrans i<j j<k
trans2 : {i j k : Ordinal} → i o< osuc j → j o< k → i o< k
trans2 {i} {j} {k} i<oj j<k with osuc-≡< i<oj
trans2 {i} {j} {k} i<oj j<k | case1 refl = j<k
trans2 {i} {j} {k} i<oj j<k | case2 i<j = ordtrans i<j j<k
open import Relation.Binary.Reasoning.Base.Triple
(Preorder.isPreorder OrdPreorder)
ordtrans --<-trans
(resp₂ _o<_) --(resp₂ _<_)
(λ x → ordtrans x <-osuc ) --<⇒≤
trans1 --<-transˡ
trans2 --<-transʳ
public
-- hiding (_≈⟨_⟩_)
| {
"alphanum_fraction": 0.5145481075,
"avg_line_length": 40.4548611111,
"ext": "agda",
"hexsha": "fc0e463c0df2c05a025c53839bdc9811c9886425",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "shinji-kono/zf-in-agda",
"max_forks_repo_path": "src/OrdUtil.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "shinji-kono/zf-in-agda",
"max_issues_repo_path": "src/OrdUtil.agda",
"max_line_length": 144,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "shinji-kono/zf-in-agda",
"max_stars_repo_path": "src/OrdUtil.agda",
"max_stars_repo_stars_event_max_datetime": "2021-01-10T13:27:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-10-02T13:46:23.000Z",
"num_tokens": 5674,
"size": 11651
} |
module Prelude where
open import Agda.Primitive using (Level; lzero; lsuc) renaming (_⊔_ to lmax)
open import Relation.Binary.PropositionalEquality as Eq
open import Data.List
open import Data.Nat.Properties
open import Data.List.Membership.DecSetoid ≡-decSetoid
open import Data.List.Relation.Unary.Any
open import Data.Empty
open import Data.List.Relation.Unary.All
-- sums
data _+̇_ (A B : Set) : Set where
Inl : A → A +̇ B
Inr : B → A +̇ B
-- Basic properties of lists
emptyListIsEmpty : ∀ {x}
→ x ∉ []
emptyListIsEmpty ()
listNoncontainment : ∀ {x x' L}
→ x ∉ L
→ x' ∈ L
→ x ≢ x'
listNoncontainment {x} {x'} {L} xNotInL x'InL = λ xEqx' → xNotInL (Eq.subst (λ a → a ∈ L) (Eq.sym xEqx') x'InL)
listConcatNoncontainment : ∀ {x x' L}
→ x ≢ x'
→ x ∉ L
→ x ∉ (x' ∷ L)
listConcatNoncontainment {x} {x'} {L} xNeqx' xNotInL (here xEqx') = xNeqx' xEqx'
listConcatNoncontainment {x} {x'} {L} xNeqx' xNotInL (there xInConcat) = xNotInL xInConcat
listConcatContainment : ∀ {x x' t}
→ x ∈ (x' ∷ t)
→ x' ≢ x
→ x ∈ t
listConcatContainment {x} {x'} {t} (here px) x'Neqx = ⊥-elim (x'Neqx (Eq.sym px))
listConcatContainment {x} {x'} {t} (there xInCons) x'Neqx = xInCons
-- Basic properties of equality
≢-sym : ∀ {a} {A : Set a} → {x x' : A}
→ x ≢ x'
→ x' ≢ x
≢-sym xNeqx' = λ x'Eqx → xNeqx' (Eq.sym x'Eqx)
-- Congruence
cong₃ : ∀ {a b c d} {A : Set a} {B : Set b} {C : Set c} {D : Set d}
(f : A → B → C → D) {x y u v w t} → x ≡ y → u ≡ v → w ≡ t → f x u w ≡ f y v t
cong₃ f refl refl refl = refl
-- All
allInsideOut : {A : Set}
→ {L L' : List A}
→ {P : A → A → Set}
→ (∀ {T T'} → P T T' → P T' T)
→ All (λ T → All (λ T' → P T T') L) L'
→ All (λ T → All (λ T' → P T T') L') L
allInsideOut {A} {[]} {.[]} sym [] = []
allInsideOut {A} {x ∷ L} {.[]} sym [] = [] ∷ allRelatedToEmpty
where
allRelatedToEmpty : {A : Set}
→ {L : List A}
→ {P : A → A → Set}
→ All (λ T → All (P T) []) L
allRelatedToEmpty {A} {[]} {P} = []
allRelatedToEmpty {A} {x ∷ L} {P} = [] ∷ allRelatedToEmpty
allInsideOut {A} {[]} {.(_ ∷ _)} sym (all₁ ∷ all₂) = []
allInsideOut {A} {x ∷ L} {(x' ∷ L')} {P} sym (all₁ ∷ all₂) =
((sym (Data.List.Relation.Unary.All.head all₁)) ∷ unwrap L' all₂) ∷
allInsideOut sym (Data.List.Relation.Unary.All.tail all₁ ∷ unwrap2 L' all₂)
where
unwrap : (M : List A)
→ All (λ T → All (P T) (x ∷ L)) M
→ All (λ T' → P x T') M
unwrap .[] [] = []
unwrap (x ∷ r) (h ∷ t) = (sym (Data.List.Relation.Unary.All.head h)) ∷ unwrap r t
unwrap2 : (M : List A)
→ All (λ T → All (P T) (x ∷ L)) M
→ All (λ T → All (P T) L) M
unwrap2 [] all = []
unwrap2 (x ∷ M) (all₁ ∷ all₂) = (Data.List.Relation.Unary.All.tail all₁) ∷ unwrap2 M all₂
{-
-- equality of naturals is decidable. we represent this as computing a
-- choice of units, with inl <> meaning that the naturals are indeed the
-- same and inr <> that they are not.
natEQ : (x y : ℕ) → ((x ≡ y) + ((x ≡ y) → ⊥))
natEQ Z Z = Inl refl
natEQ Z (1+ y) = Inr (λ ())
natEQ (1+ x) Z = Inr (λ ())
natEQ (1+ x) (1+ y) with natEQ x y
natEQ (1+ x) (1+ .x) | Inl refl = Inl refl
... | Inr b = Inr (λ x₁ → b (1+inj x y x₁))
-- nat equality as a predicate. this saves some very repetative casing.
natEQp : (x y : ℕ) → Set
natEQp x y with natEQ x y
natEQp x .x | Inl refl = ⊥
natEQp x y | Inr x₁ = ⊤
-}
{-
-- equality
data _≡_ {l : Level} {A : Set l} (M : A) : A → Set l where
refl : M ≡ M
infixr 9 _≡_
{-# BUILTIN EQUALITY _≡_ #-}
-- transitivity of equality
_·_ : {l : Level} {α : Set l} {x y z : α} → x ≡ y → y ≡ z → x ≡ z
refl · refl = refl
-- symmetry of equality
! : {l : Level} {α : Set l} {x y : α} → x ≡ y → y ≡ x
! refl = refl
-- ap, in the sense of HoTT, that all functions respect equality in their
-- arguments. named in a slightly non-standard way to avoid naming
-- clashes with hazelnut constructors.
ap1 : {l1 l2 : Level} {α : Set l1} {β : Set l2} {x y : α} (F : α → β)
→ x ≡ y → F x ≡ F y
ap1 F refl = refl
-- transport, in the sense of HoTT, that fibrations respect equality
tr : {l1 l2 : Level} {α : Set l1} {x y : α}
(B : α → Set l2)
→ x ≡ y
→ B x
→ B y
tr B refl x₁ = x₁
-- options
data Maybe (A : Set) : Set where
Some : A → Maybe A
None : Maybe A
-- the some constructor is injective. perhaps unsurprisingly.
someinj : {A : Set} {x y : A} → Some x ≡ Some y → x ≡ y
someinj refl = refl
-- some isn't none.
somenotnone : {A : Set} {x : A} → Some x ≡ None → ⊥
somenotnone ()
-- function extensionality, used to reason about contexts as finite
-- functions.
postulate
funext : {A : Set} {B : A → Set} {f g : (x : A) → (B x)} →
((x : A) → f x ≡ g x) → f ≡ g
-- non-equality is commutative
flip : {A : Set} {x y : A} → (x ≡ y → ⊥) → (y ≡ x → ⊥)
flip neq eq = neq (! eq)
-- two types are said to be equivalent, or isomorphic, if there is a pair
-- of functions between them where both round-trips are stable up to ≡
_≃_ : Set → Set → Set
_≃_ A B = Σ[ f ∈ (A → B) ] Σ[ g ∈ (B → A) ]
(((a : A) → g (f a) ≡ a) × (((b : B) → f (g b) ≡ b)))
-}
| {
"alphanum_fraction": 0.4883399551,
"avg_line_length": 32.5224719101,
"ext": "agda",
"hexsha": "fe6b409ad24cf78df7871736762bc982348c0031",
"lang": "Agda",
"max_forks_count": 11,
"max_forks_repo_forks_event_max_datetime": "2021-06-09T18:40:19.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-05-24T08:20:52.000Z",
"max_forks_repo_head_hexsha": "bda0fac3aadfbce2eacdb89095d100125fa4fdd6",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "ivoysey/Obsidian",
"max_forks_repo_path": "formalization/Prelude.agda",
"max_issues_count": 259,
"max_issues_repo_head_hexsha": "bda0fac3aadfbce2eacdb89095d100125fa4fdd6",
"max_issues_repo_issues_event_max_datetime": "2022-03-29T18:20:05.000Z",
"max_issues_repo_issues_event_min_datetime": "2017-08-18T19:50:41.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "ivoysey/Obsidian",
"max_issues_repo_path": "formalization/Prelude.agda",
"max_line_length": 113,
"max_stars_count": 79,
"max_stars_repo_head_hexsha": "bda0fac3aadfbce2eacdb89095d100125fa4fdd6",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "ivoysey/Obsidian",
"max_stars_repo_path": "formalization/Prelude.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-27T10:34:28.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-08-19T16:24:10.000Z",
"num_tokens": 2135,
"size": 5789
} |
-- Andreas, 2020-02-06, issue #906, and #942 #2068 #3136 #3431 #4391 #4418
--
-- Termination checker now tries to reduce calls away
-- using non-recursive clauses.
--
-- This fixes the problem that for dependent copattern definitions
-- the earlier, non-recursive clauses get into non-guarded positions
-- in later clauses via Agda's constraint solver, and there confuse
-- the termination checker.
module Issue906EtAl where
module Issue906 where
{- Globular types as a coinductive record -}
record Glob : Set1 where
coinductive
field
Ob : Set
Hom : (a b : Ob) → Glob
open Glob
record Unit : Set where
data _==_ {A : Set} (a : A) : A → Set where
refl : a == a
{- The terminal globular type -}
Unit-glob : Glob
Ob Unit-glob = Unit
Hom Unit-glob _ _ = Unit-glob
{- The tower of identity types -}
Id-glob : (A : Set) → Glob
Ob (Id-glob A) = A
Hom (Id-glob A) a b = Id-glob (a == b)
module Issue907 where
data _==_ {A : Set} (a : A) : A → Set where
idp : a == a
-- Coinductive equivalences
record CoEq (A B : Set) : Set where
coinductive
constructor coEq
field to : A → B
from : B → A
eq : (a : A) (b : B) → CoEq (a == from b) (to a == b)
open CoEq public
id-CoEq : (A : Set) → CoEq A A
to (id-CoEq A) a = a
from (id-CoEq A) b = b
eq (id-CoEq A) a b = id-CoEq _ -- Keep underscore!
-- Solution: (a == from (id-CoEq A) b)
-- contains recursive call
module Issue942 where
record Sigma (A : Set)(P : A → Set) : Set where
constructor _,_
field
fst : A
snd : P fst
open Sigma
postulate
A : Set
x : A
P Q : A → Set
Px : P x
f : ∀ {x} → P x → Q x
ex : Sigma A Q
ex = record
{ fst = x
; snd = f Px -- goal: P x
}
ex' : Sigma A Q
ex' = x , f Px -- goal: P x
ex'' : Sigma A Q
fst ex'' = x
snd ex'' = f Px -- goal: P (fst ex'')
module Issue2068-OP where
data _==_ {A : Set} : A → A → Set where
refl : {a : A} → a == a
data Bool : Set where
tt : Bool
ff : Bool
record TwoEqualFunctions : Set₁ where
field
A : Set
B : Set
f : A → B
g : A → B
p : f == g
postulate
funext : {A B : Set} {f g : A → B} → ((a : A) → f a == g a) → f == g
identities : TwoEqualFunctions
TwoEqualFunctions.A identities = Bool
TwoEqualFunctions.B identities = Bool
TwoEqualFunctions.f identities x = x
TwoEqualFunctions.g identities = λ{tt → tt ; ff → ff}
TwoEqualFunctions.p identities = funext (λ{tt → refl ; ff → refl})
module Issue2068b where
data _==_ {A : Set} : (a : A) → A → Set where
refl : (a : A) → a == a
data Unit : Set where
unit : Unit
record R : Set₁ where
field
f : Unit → Unit
p : f == λ x → x
postulate
extId : (f : Unit → Unit) → (∀ a → f a == a) → f == λ x → x
test : R
R.f test = λ{ unit → unit }
R.p test = extId _ λ{ unit → refl _ }
-- R.p test = extId {! R.f test !} λ{unit → refl {! R.f test unit !}}
module Issue2068c where
record _×_ (A B : Set) : Set where
field fst : A
snd : B
open _×_
test : ∀{A} (a : A) → (A → A) × (A → A)
fst (test a) x = a
snd (test a) x = fst (test a) (snd (test a) x)
module Issue3136 (A : Set) where
-- Andreas, 2018-07-22, issue #3136
-- WAS: Internal error when printing termination errors
postulate
any : {X : Set} → X
x : A
P : A → Set
record C : Set where
field
a : A
b : P a
c : C
c = λ where
.C.a → x
.C.b → λ where
→ any
-- NOW: succeeds
module Issue3413 where
open import Agda.Builtin.Sigma
open import Agda.Builtin.Equality
postulate
A : Set
P : ∀{X : Set} → X → Set
record Bob : Set₁ where
field
RE : Set
resp : RE → Set
open Bob
bob : Bob
bob .RE = A
bob .resp e = Σ (P e) λ {x → A}
module Issue4391 where
record GlobSet : Set₁ where
coinductive
field
cells : Set
morphisms : cells → cells → GlobSet
open GlobSet public
record GlobSetMorphism (G H : GlobSet) : Set where
coinductive
field
func : cells G → cells H
funcMorphisms : (x y : cells G)
→ GlobSetMorphism (morphisms G x y)
(morphisms H (func x) (func y))
open GlobSetMorphism public
gComp : {G H I : GlobSet} → GlobSetMorphism H I → GlobSetMorphism G H → GlobSetMorphism G I
func (gComp ϕ ψ) x = func ϕ (func ψ x)
funcMorphisms (gComp ϕ ψ) x y = gComp (funcMorphisms ϕ (func ψ x) (func ψ y)) (funcMorphisms ψ x y)
module Issue4391Nisse where
record GlobSet : Set₁ where
coinductive
field
cells : Set
morphisms : cells → cells → GlobSet
open GlobSet public
mutual
record GlobSetMorphism (G H : GlobSet) : Set where
inductive
field
func : cells G → cells H
funcMorphisms : (x y : cells G) →
GlobSetMorphism′
(morphisms G x y)
(morphisms H (func x) (func y))
record GlobSetMorphism′ (G H : GlobSet) : Set where
coinductive
field
force : GlobSetMorphism G H
open GlobSetMorphism public
open GlobSetMorphism′ public
works fails :
{G H I : GlobSet} →
GlobSetMorphism H I → GlobSetMorphism G H → GlobSetMorphism G I
works ϕ ψ = record
{ func = λ x → func ϕ (func ψ x)
; funcMorphisms = λ { x y .force →
works (funcMorphisms ϕ (func ψ x) (func ψ y) .force)
(funcMorphisms ψ x y .force) }
}
fails ϕ ψ .func = λ x → func ϕ (func ψ x)
fails ϕ ψ .funcMorphisms = λ { x y .force →
fails (funcMorphisms ϕ (func ψ x) (func ψ y) .force)
(funcMorphisms ψ x y .force) }
module Issue4418 {l}
(Index : Set l)
(Shape : Index → Set l)
(Position : (i : Index) → Shape i → Set l)
(index : (i : Index) → (s : Shape i) → Position i s → Index) where
record M (i : Index) : Set l where
coinductive
field shape : Shape i
field children : (p : Position i shape) → M (index i shape p)
open M
record MBase (Rec : Index → Set l) (i : Index) : Set l where
coinductive
field shapeB : Shape i
field childrenB : (p : Position i shapeB) → Rec (index i shapeB p)
open MBase
module _ (S : Index → Set l) (u : ∀ {i} → S i → MBase S i) where
unroll : ∀ i → S i → M i
unroll i s .shape = u s .shapeB
unroll i s .children p = unroll _ (u s .childrenB p)
-- Underscore solved as: index i (u s .shapeB) p
| {
"alphanum_fraction": 0.5593811618,
"avg_line_length": 22.8923611111,
"ext": "agda",
"hexsha": "20bffa998f42584346e9a9aea0a76f580bcac2dc",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2015-09-15T14:36:15.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-09-15T14:36:15.000Z",
"max_forks_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "shlevy/agda",
"max_forks_repo_path": "test/Succeed/Issue906EtAl.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2015-09-15T15:49:15.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-09-15T15:49:15.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Succeed/Issue906EtAl.agda",
"max_line_length": 101,
"max_stars_count": 1,
"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/Issue906EtAl.agda",
"max_stars_repo_stars_event_max_datetime": "2016-05-20T13:58:52.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-05-20T13:58:52.000Z",
"num_tokens": 2245,
"size": 6593
} |
open import Formalization.PredicateLogic.Signature
module Formalization.PredicateLogic.Syntax.Tree (𝔏 : Signature) where
open Signature(𝔏)
open import Data.DependentWidthTree as Tree hiding (height)
import Functional.Dependent
import Lvl
open import Formalization.PredicateLogic.Syntax(𝔏)
open import Formalization.PredicateLogic.Syntax.Substitution(𝔏)
open import Functional using (_∘_ ; _∘₂_ ; _∘₃_ ; _∘₄_ ; swap ; _←_ ; _on₂_)
open import Numeral.Finite
open import Numeral.Natural.Function.Proofs
open import Numeral.Natural.Inductions
open import Numeral.Natural.Relation.Order
open import Numeral.Natural.Relation.Order.Proofs
open import Numeral.Natural
open import Relator.Equals
open import Structure.Relator
open import Structure.Relator.Ordering
open import Structure.Relator.Ordering.Proofs
open import Type.Dependent
open import Type
private variable ℓ : Lvl.Level
private variable vars vars₁ vars₂ : ℕ
private variable φ ψ : Formula(vars)
tree : Formula(vars) → FiniteTreeStructure
tree (_ $ _) = Node 0 \()
tree ⊤ = Node 0 \()
tree ⊥ = Node 0 \()
tree (φ ∧ ψ) = Node 2 \{𝟎 → tree φ; (𝐒 𝟎) → tree ψ}
tree (φ ∨ ψ) = Node 2 \{𝟎 → tree φ; (𝐒 𝟎) → tree ψ}
tree (φ ⟶ ψ) = Node 2 \{𝟎 → tree φ; (𝐒 𝟎) → tree ψ}
tree (Ɐ φ) = Node 1 \{𝟎 → tree φ}
tree (∃ φ) = Node 1 \{𝟎 → tree φ}
height : Formula(vars) → ℕ
height = Tree.height ∘ tree
-- Ordering on formulas based on the height of their tree representation.
_<↑_ : (Σ ℕ Formula) → (Σ ℕ Formula) → Type
_<↑_ = (_<_) on₂ (height Functional.Dependent.∘ Σ.right)
substitute-height : ∀{t} → (height(substitute{vars₁ = vars₁}{vars₂ = vars₂} t φ) ≡ height φ)
substitute-height {φ = f $ x} = [≡]-intro
substitute-height {φ = ⊤} = [≡]-intro
substitute-height {φ = ⊥} = [≡]-intro
substitute-height {φ = φ ∧ ψ} {t} rewrite substitute-height {φ = φ}{t} rewrite substitute-height {φ = ψ}{t} = [≡]-intro
substitute-height {φ = φ ∨ ψ} {t} rewrite substitute-height {φ = φ}{t} rewrite substitute-height {φ = ψ}{t} = [≡]-intro
substitute-height {φ = φ ⟶ ψ} {t} rewrite substitute-height {φ = φ}{t} rewrite substitute-height {φ = ψ}{t} = [≡]-intro
substitute-height {φ = Ɐ φ} {t} rewrite substitute-height {φ = φ}{termMapper𝐒 t} = [≡]-intro
substitute-height {φ = ∃ φ} {t} rewrite substitute-height {φ = φ}{termMapper𝐒 t} = [≡]-intro
instance
[<↑]-wellfounded : Strict.Properties.WellFounded(_<↑_)
[<↑]-wellfounded = wellfounded-image-by-trans {f = height Functional.Dependent.∘ Σ.right}
induction-on-height : (P : ∀{vars} → Formula(vars) → Type{ℓ}) → (∀{vars}{φ : Formula(vars)} → (∀{vars}{ψ : Formula(vars)} → (height ψ < height φ) → P(ψ)) → P(φ)) → ∀{vars}{φ : Formula(vars)} → P(φ)
induction-on-height P step {vars}{φ} = Strict.Properties.wellfounded-induction(_<↑_) (\{ {intro vars φ} p → step{vars}{φ} \{vars}{ψ} ph → p{intro vars ψ} ⦃ ph ⦄}) {intro vars φ}
⊤-height-order : (height{vars} ⊤ ≤ height φ)
⊤-height-order = [≤]-minimum
⊥-height-order : (height{vars} ⊥ ≤ height φ)
⊥-height-order = [≤]-minimum
∧-height-orderₗ : (height φ < height(φ ∧ ψ))
∧-height-orderₗ = [≤]-with-[𝐒]
∧-height-orderᵣ : (height ψ < height(φ ∧ ψ))
∧-height-orderᵣ = [≤]-with-[𝐒]
∨-height-orderₗ : (height φ < height(φ ∨ ψ))
∨-height-orderₗ = [≤]-with-[𝐒]
∨-height-orderᵣ : (height ψ < height(φ ∨ ψ))
∨-height-orderᵣ = [≤]-with-[𝐒]
⟶-height-orderₗ : (height φ < height(φ ⟶ ψ))
⟶-height-orderₗ = [≤]-with-[𝐒]
⟶-height-orderᵣ : (height ψ < height(φ ⟶ ψ))
⟶-height-orderᵣ = [≤]-with-[𝐒]
Ɐ-height-order : (height φ < height(Ɐ φ))
Ɐ-height-order = [<]-of-[𝐒]
∃-height-order : (height φ < height(∃ φ))
∃-height-order = [<]-of-[𝐒]
-- induction-on-height : ∀{P : ∀{vars} → Formula(vars) → Type{ℓ}} → (∀{vars} → P{vars}(⊤)) → (∀{vars} → P{vars}(⊥)) → ((∀{vars}{ψ : Formula(vars)} → (height ψ < height φ) → P(ψ)) → P(φ)) → P(φ)
-- induction-on-height {φ = φ} base⊤ base⊥ step = step {!Strict.Properties.wellfounded-induction(_<↑_)!}
| {
"alphanum_fraction": 0.6494370522,
"avg_line_length": 41.1368421053,
"ext": "agda",
"hexsha": "1bb0c5782ae14689e56d95066bc438e717bdee4d",
"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/Syntax/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/Syntax/Tree.agda",
"max_line_length": 197,
"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/Syntax/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": 1469,
"size": 3908
} |
{-# OPTIONS --sized-types #-}
open import Relation.Binary.Core
module Mergesort.Impl1.Correctness.Order {A : Set}
(_≤_ : A → A → Set)
(tot≤ : Total _≤_) where
open import Data.List
open import Function using (_∘_)
open import List.Sorted _≤_
open import Mergesort.Impl1 _≤_ tot≤
open import SList
open import SOList.Lower _≤_
open import SOList.Lower.Properties _≤_
theorem-mergesort-sorted : (xs : List A) → Sorted (forget (mergesort (size A xs)))
theorem-mergesort-sorted = lemma-solist-sorted ∘ mergesort ∘ (size A)
| {
"alphanum_fraction": 0.6821428571,
"avg_line_length": 31.1111111111,
"ext": "agda",
"hexsha": "b5ee4b8f6b35b9571c81446eb78440901044f704",
"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/Mergesort/Impl1/Correctness/Order.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/Mergesort/Impl1/Correctness/Order.agda",
"max_line_length": 82,
"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/Mergesort/Impl1/Correctness/Order.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": 172,
"size": 560
} |
module Fough where
open import Agda.Primitive renaming (_⊔_ to lmax)
record Setoid l : Set (lsuc l) where
field
El : Set l
Eq : El -> El -> Set l
Rf : (x : El) -> Eq x x
Sy : (x y : El) -> Eq x y -> Eq y x
Tr : (x y z : El) -> Eq x y -> Eq y z -> Eq x z
open Setoid
module PACKQ {l}(X : Setoid l) where
record _|-_~~_ (x y : El X) : Set l where
constructor eq
field
qe : Eq X x y
open _|-_~~_ public
qprf = qe
module _ {l}{X : Setoid l} where
open PACKQ X
infixr 5 _~[_>~_ _~<_]~_
infixr 6 _[SQED]
_~[_>~_ : forall x {y z} -> _|-_~~_ x y -> _|-_~~_ y z -> _|-_~~_ x z
x ~[ eq q >~ eq q' = eq (Tr X _ _ _ q q')
_~<_]~_ : forall x {y z} -> _|-_~~_ y x -> _|-_~~_ y z -> _|-_~~_ x z
x ~< eq q ]~ eq q' = eq (Tr X _ _ _ (Sy X _ _ q) q')
_[SQED] : forall x -> _|-_~~_ x x
_[SQED] x = eq (Rf X x)
rS : forall {x} -> _|-_~~_ x x
rS {x} = eq (Rf X x)
open PACKQ public
module _ {l}{X : Set l} where
data _~_ (x : X) : X -> Set l where
r~ : x ~ x
{-# BUILTIN EQUALITY _~_ #-}
module _ {l}(X : Set l) where
IN : Setoid l
El IN = X
Eq IN = _~_
Rf IN x = r~
Sy IN x y r~ = r~
Tr IN x y z r~ q = q
module _ {k l}(S : Set k)(T : S -> Set l) where
record _><_ : Set (lmax k l) where
constructor _,_
field
fst : S
snd : T fst
open _><_ public
infixr 10 _,_
infixr 20 _><_
module _ (l : Level) where
record One : Set l where constructor <>
infixr 20 _*_
_*_ : forall {k l} -> Set k -> Set l -> Set (lmax k l)
S * T = S >< \ _ -> T
infix 22 <_>
<_> : forall {k l}{S : Set k}(T : S -> Set l) -> Set (lmax k l)
< T > = _ >< T
infixr 23 _:*_
_:*_ : forall {k l}{S : Set k}(T U : S -> Set l) -> S -> Set l
(T :* U) s = T s * U s
infixr 11 _&_
pattern _&_ s t = _ , s , t
infixr 9 _/\_
_/\_ : forall {k l}{S : Set k}{T : Set l} -> S -> T -> S * T
s /\ t = s , t
module _ {k l}(S : Set k)(T : S -> Setoid l) where
PI : Setoid (lmax k l)
El PI = (s : S) -> El (T s)
Eq PI f g = (s : S) -> Eq (T s) (f s) (g s)
Rf PI f s = Rf (T s) (f s)
Sy PI f g q s = Sy (T s) (f s) (g s) (q s)
Tr PI f g h p q s = Tr (T s) (f s) (g s) (h s) (p s) (q s)
IM : Setoid (lmax k l)
El IM = {s : S} -> El (T s)
Eq IM f g = (s : S) -> Eq (T s) (f {s}) (g {s})
Rf IM f s = Rf (T s) f
Sy IM f g q s = Sy (T s) f g (q s)
Tr IM f g h p q s = Tr (T s) f g h (p s) (q s)
SG : Setoid (lmax k l)
El SG = S >< \ s -> El (T s)
Eq SG (s0 , t0) (s1 , t1) = (s0 ~ s1) >< \ { r~ -> Eq (T s0) t0 t1 }
Rf SG (s , t) = r~ , Rf (T s) t
Sy SG (s0 , t0) (.s0 , t1) (r~ , q) = r~ , Sy (T s0) t0 t1 q
fst (Tr SG (s0 , t0) (.s0 , t1) (s2 , t2) (r~ , q01) (q , q12)) = q
snd (Tr SG (s0 , t0) (.s0 , t1) (.s0 , t2) (r~ , q01) (r~ , q12)) = Tr (T s0) t0 t1 t2 q01 q12
module _ {k l}(T : Setoid k)(P : El T -> Set l) where
EX : Setoid (lmax k l)
El EX = El T >< P
Eq EX (t0 , _) (t1 , _) = Eq T t0 t1 * One l
Rf EX (t , _) = Rf T t , <>
Sy EX (t0 , _) (t1 , _) (q , <>) = Sy T t0 t1 q , <>
Tr EX (t0 , _) (t1 , _) (t2 , _) (q01 , <>) (q12 , <>) =
Tr T t0 t1 t2 q01 q12 , <>
module _ (k l : Level) where
record Cat : Set (lsuc (lmax k l)) where
field
Obj : Set k
Arr : Obj -> Obj -> Setoid l
_~>_ : Obj -> Obj -> Set l
S ~> T = El (Arr S T)
_~~_ : {S T : Obj}(f g : S ~> T) -> Set l
_~~_ {S}{T} = _|-_~~_ (Arr S T)
field
id : {T : Obj} -> T ~> T
_-_ : {R S T : Obj} -> R ~> S -> S ~> T -> R ~> T
coex : {R S T : Obj}{f f' : R ~> S}{g g' : S ~> T} ->
f ~~ f' -> g ~~ g' -> (f - g) ~~ (f' - g')
idco : {S T : Obj}(f : S ~> T) -> (id - f) ~~ f
coid : {S T : Obj}(f : S ~> T) -> (f - id) ~~ f
coco : {R S T U : Obj}(f : R ~> S)(g : S ~> T)(h : T ~> U) ->
(f - (g - h)) ~~ ((f - g) - h)
module _ (l : Level) where
open Cat
SET : Cat (lsuc l) l
Obj SET = Set l
Arr SET S T = PI S \ _ -> IN T
id SET x = x
_-_ SET f g x = g (f x)
qe (coex SET (eq qf) (eq qg)) x rewrite qf x = qg _
qe (idco SET f) x = r~
qe (coid SET f) x = r~
qe (coco SET f g h) x = r~
module _ {l k l' k'}(C : Cat l k)(D : Cat l' k') where
private module C = Cat C ; module D = Cat D
Fun : Setoid (lmax l (lmax k (lmax l' k')))
Fun = SG (C.Obj -> D.Obj) \ Map ->
EX (IM C.Obj \ S -> IM C.Obj \ T ->
PI (S C.~> T) \ _ -> D.Arr (Map S) (Map T)) \ map ->
({S T : C.Obj}{f g : S C.~> T} -> f C.~~ g -> map f D.~~ map g)
* ({X : C.Obj} -> map (C.id {X}) D.~~ D.id {Map X})
* ({R S T : C.Obj}(f : R C.~> S)(g : S C.~> T) ->
map (f C.- g) D.~~ (map f D.- map g))
module _ (l k : Level) where
CAT : Cat (lsuc (lmax l k)) (lmax l k)
Cat.Obj CAT = Cat l k
Cat.Arr CAT = Fun
Cat.id CAT {C}
= (\ X -> X) , (\ f -> f)
, (\ q -> q)
, rS
, \ _ _ -> rS
where open Cat C
Cat._-_ CAT {C}{D}{E} (F , fm , fx , fi , fc) (G , gm , gx , gi , gc)
= (\ X -> G (F X)) , (\ a -> gm (fm a))
, (\ q -> gx (fx q))
, (gm (fm C.id) ~[ gx fi >~
gm (D.id) ~[ gi >~
E.id [SQED])
, \ f g ->
gm (fm (f C.- g)) ~[ gx (fc _ _) >~
gm (fm f D.- fm g) ~[ gc _ _ >~
(gm (fm f) E.- gm (fm g)) [SQED]
where private module C = Cat C ; module D = Cat D ; module E = Cat E
qe (Cat.coex CAT {C} {D} {E} {F , fm , fz} {F' , fm' , fz'} {G , gm , gx , gz} {G' , gm' , gz'}
(eq (r~ , qf , <>)) (eq (r~ , qg , <>)))
= r~
, (\ S T f -> qe {X = Cat.Arr E (G (F S)) (G (F T))}
(gm (fm f) ~[ gx (eq (qf _ _ _)) >~
gm (fm' f) ~[ eq (qg _ _ _) >~
gm' (fm' f) [SQED]))
, <>
qe (Cat.idco CAT {C}{D} (F , fm , fz)) =
r~ , (\ S T f -> qprf (D.Arr (F S) (F T)) rS) , <>
where private module C = Cat C ; module D = Cat D
qe (Cat.coid CAT {C} {D} (F , fm , fz)) =
r~ , (\ S T f -> qprf (D.Arr (F S) (F T)) rS) , <>
where private module C = Cat C ; module D = Cat D
qe (Cat.coco CAT {B} {C} {D} {E} (F , fm , fz) (G , gm , gz) (H , hm , hz))
= r~
, (\ S T f -> qprf (Cat.Arr E (H (G (F S))) (H (G (F T)))) rS )
, <>
module _ {l k l' k' : Level}(C : Cat l k)(D : Cat l' k') where
private module C = Cat C ; module D = Cat D
_=>_ : Cat (lmax l (lmax k (lmax l' k'))) (lmax l (lmax k k'))
Cat.Obj _=>_ = El (Fun C D)
Cat.Arr _=>_ (F , fm , _) (G , gm , _) =
EX (IM C.Obj \ X -> D.Arr (F X) (G X)) \ n ->
{S T : C.Obj}(f : S C.~> T) -> (fm f D.- n {T}) D.~~ (n {S} D.- gm f)
Cat.id _=>_ {F , fm , _}
= D.id
, \ f ->
fm f D.- D.id ~[ D.coid _ >~
fm f ~< D.idco _ ]~
(D.id D.- fm f) [SQED]
Cat._-_ _=>_ {F , fm , fx , fi , fc} {G , gm , gx , gi , gc} {H , hm , hx , hi , hc}
(n , na) (p , pa)
= n D.- p
, \ f ->
fm f D.- (n D.- p) ~[ D.coco _ _ _ >~
(fm f D.- n) D.- p ~[ D.coex (na f) rS >~
(n D.- gm f) D.- p ~< D.coco _ _ _ ]~
n D.- (gm f D.- p) ~[ D.coex rS (pa f) >~
n D.- (p D.- hm f) ~[ D.coco _ _ _ >~
((n D.- p) D.- hm f [SQED])
qe (Cat.coex _=>_ (eq (nq , <>)) (eq (pq , <>)))
= (\ X -> qe (D.coex (eq (nq X)) (eq (pq X))))
, <>
qe (Cat.idco _=>_ _) = (\ _ -> qe (D.idco _)) , <>
qe (Cat.coid _=>_ _) = (\ _ -> qe (D.coid _)) , <>
qe (Cat.coco _=>_ _ _ _) = (\ _ -> qe (D.coco _ _ _)) , <>
module _ {l k : Level}(C : Cat l k)(I : Cat.Obj C) where
open Cat C
_/_ : Cat (lmax l k) k
Cat.Obj _/_ = Obj >< \ X -> X ~> I
Cat.Arr _/_ (X , f) (Y , g) = EX (Arr X Y) \ h -> (h - g) ~~ f
Cat.id _/_ = id , idco _
Cat._-_ _/_ {R , r}{S , s}{T , t} (f , p) (g , q)
= (f - g)
, ((f - g) - t ~< coco _ _ _ ]~
f - (g - t) ~[ coex rS q >~
f - s ~[ p >~
r [SQED])
qe (Cat.coex _/_ (eq (q , <>)) (eq (q' , <>))) = qe (coex (eq q) (eq q')) , <>
qe (Cat.idco _/_ _) = qe (idco _) , <>
qe (Cat.coid _/_ _) = qe (coid _) , <>
qe (Cat.coco _/_ _ _ _) = qe (coco _ _ _) , <>
module BWD (X : Set) where
data Bwd : Set where
_-,_ : Bwd -> X -> Bwd
[] : Bwd
infixl 30 _-,_
module _ {X : Set} where
open BWD X
data _<=_ : Bwd -> Bwd -> Set where
_-^_ : forall {ga de} -> ga <= de -> forall x -> ga <= (de -, x)
_-,_ : forall {ga de} -> ga <= de -> forall x -> (ga -, x) <= (de -, x)
[] : [] <= []
infixl 30 _-^_
data <_-_>~_ : forall {ga de ze}(th : ga <= de)(ph : de <= ze)(ps : ga <= ze) -> Set where
_-^_ : forall {ga de ze}{th : ga <= de}{ph : de <= ze}{ps : ga <= ze} ->
< th - ph >~ ps -> forall x -> < th - ph -^ x >~ ps -^ x
_-^,_ : forall {ga de ze}{th : ga <= de}{ph : de <= ze}{ps : ga <= ze} ->
< th - ph >~ ps -> forall x -> < th -^ x - ph -, x >~ ps -^ x
_-,_ : forall {ga de ze}{th : ga <= de}{ph : de <= ze}{ps : ga <= ze} ->
< th - ph >~ ps -> forall x -> < th -, x - ph -, x >~ ps -, x
[] : < [] - [] >~ []
infix 25 <_-_>~_
infixl 30 _-^,_
io : forall {ga} -> ga <= ga
io {ga -, x} = io {ga} -, x
io {[]} = []
mkCo : forall {ga de ze}(th : ga <= de)(ph : de <= ze) -> <(< th - ph >~_)>
mkCo th (ph -^ x) = let _ , v = mkCo th ph in _ , v -^ x
mkCo (th -^ .x) (ph -, x) = let _ , v = mkCo th ph in _ , v -^, x
mkCo (th -, .x) (ph -, x) = let _ , v = mkCo th ph in _ , v -, x
mkCo [] [] = _ , []
_~-~_ : forall {ga de ze}{th : ga <= de}{ph : de <= ze}{ps0 ps1 : ga <= ze} ->
(v0 : < th - ph >~ ps0)(v1 : < th - ph >~ ps1) ->
(ps0 ~ ps1) >< \ { r~ -> v0 ~ v1 }
(v0 -^ x) ~-~ (v1 -^ .x) with r~ , r~ <- v0 ~-~ v1 = r~ , r~
(v0 -^, x) ~-~ (v1 -^, .x) with r~ , r~ <- v0 ~-~ v1 = r~ , r~
(v0 -, x) ~-~ (v1 -, .x) with r~ , r~ <- v0 ~-~ v1 = r~ , r~
[] ~-~ [] = r~ , r~
_-<=_ : forall {ga de ze} -> ga <= de -> de <= ze -> ga <= ze
th -<= ph = fst (mkCo th ph)
io- : forall {ga de}(th : ga <= de) -> < io - th >~ th
io- (th -^ x) = io- th -^ x
io- (th -, x) = io- th -, x
io- [] = []
infixl 30 _-io
_-io : forall {ga de}(th : ga <= de) -> < th - io >~ th
th -^ x -io = th -io -^, x
th -, x -io = th -io -, x
[] -io = []
assoc02 : forall {ga0 ga1 ga2 ga3}
{th01 : ga0 <= ga1}{th23 : ga2 <= ga3}
{th03 : ga0 <= ga3}{th12 : ga1 <= ga2} ->
<(< th01 -_>~ th03) :* (< th12 - th23 >~_)> ->
<(< th01 - th12 >~_) :* (<_- th23 >~ th03)>
assoc02 (v -^ .x & w -^ x) = let v' & w' = assoc02 (v & w) in v' & w' -^ x
assoc02 (v -^ .x & w -^, x) = let v' & w' = assoc02 (v & w) in v' -^ x & w' -^, x
assoc02 (v -^, .x & w -, x) = let v' & w' = assoc02 (v & w) in v' -^, x & w' -^, x
assoc02 (v -, .x & w -, x) = let v' & w' = assoc02 (v & w) in v' -, x & w' -, x
assoc02 ([] & []) = [] & []
assoc03 : forall {ga0 ga1 ga2 ga3}
{th01 : ga0 <= ga1}{th23 : ga2 <= ga3}
{th02 : ga0 <= ga2}{th13 : ga1 <= ga3} ->
<(< th01 -_>~ th02) :* (<_- th23 >~ th13)> ->
<(< th01 - th13 >~_) :* (< th02 - th23 >~_)>
assoc03 {th01 = th}{th13 = ph} (v & w) with _ , v' <- mkCo th ph |
v0 & v1 <- assoc02 (v' & w) | r~ , r~ <- v ~-~ v0 = v' & v1
assoc13 : forall {ga0 ga1 ga2 ga3}
{th01 : ga0 <= ga1}{th23 : ga2 <= ga3}
{th03 : ga0 <= ga3}{th12 : ga1 <= ga2} ->
<(< th01 - th12 >~_) :* (<_- th23 >~ th03)> ->
<(< th01 -_>~ th03) :* (< th12 - th23 >~_)>
assoc13 {th23 = ph}{th12 = th} (v & w) with _ , v' <- mkCo th ph |
v0 & v1 <- assoc03 (v & v') | r~ , r~ <- w ~-~ v1 = v0 & v'
THIN : Cat lzero lzero
Cat.Obj THIN = Bwd
Cat.Arr THIN ga de = IN (ga <= de)
Cat.id THIN = io
Cat._-_ THIN = _-<=_
Cat.coex THIN (eq r~) (eq r~) = eq r~
Cat.idco THIN th with v <- io- th | _ , w <- mkCo io th | r~ , r~ <- v ~-~ w
= rS
Cat.coid THIN ph with v <- ph -io | _ , w <- mkCo ph io | r~ , r~ <- v ~-~ w
= rS
Cat.coco THIN th ph ps with thph , v <- mkCo th ph | phps , w <- mkCo ph ps |
_ , v1 <- mkCo thph ps | _ , w1 <- mkCo th phps |
v2 & w2 <- assoc02 (w1 & w) | r~ , r~ <- v ~-~ v2 | r~ , r~ <- v1 ~-~ w2
= rS
THIN/ : Bwd -> Cat lzero lzero
Cat.Obj (THIN/ de) = <(_<= de)>
Cat.Arr (THIN/ de) (_ , th0) (_ , th1) = EX (IN _) (<_- th1 >~ th0)
Cat.id (THIN/ de) = io , io- _
Cat._-_ (THIN/ de) (th0 , v0) (th1 , v1) with w0 & w1 <- assoc02 (v0 & v1)
= _ , w1
qe (Cat.coex (THIN/ de) {f = _ , v0} {._ , w0} {_ , v1} {._ , w1}
(eq (r~ , <>)) (eq (r~ , <>))) with
(r~ , r~) , (r~ , r~) <- v0 ~-~ w0 /\ v1 ~-~ w1
= r~ , <>
qe (Cat.idco (THIN/ de) {_ , ph} (th , v)) with
w <- io- th | w' & _ <- assoc02 (io- ph & v) | r~ , r~ <- w ~-~ w'
= r~ , <>
qe (Cat.coid (THIN/ de) {T = _ , ph} (th , v)) with
w <- th -io | w' & _ <- assoc02 (v & io- ph) | r~ , r~ <- w ~-~ w'
= r~ , <>
qe (Cat.coco (THIN/ de) (_ , v01) (_ , v12) (_ , v23)) with
w13 & v13 <- assoc02 (v12 & v23) | w02 & v02 <- assoc02 (v01 & v12) |
w013 & v013 <- assoc02 (v01 & v13) | w023 & v023 <- assoc02 (v02 & v23) |
w013' & w023' <- assoc03 (w02 & w13) |
(r~ , r~) , (r~ , r~) <- w013' ~-~ w013 /\ w023' ~-~ w023
= r~ , <>
| {
"alphanum_fraction": 0.4014951295,
"avg_line_length": 34.2196382429,
"ext": "agda",
"hexsha": "62f3e940cea01a196cbeef60c65bee4a24677620",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2019-09-21T18:45:46.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-09-11T09:55:10.000Z",
"max_forks_repo_head_hexsha": "2e32d399ce35be1106a75c81f43e94aef182d97a",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "gallais/EGTBS",
"max_forks_repo_path": "extended/Fough.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "2e32d399ce35be1106a75c81f43e94aef182d97a",
"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": "gallais/EGTBS",
"max_issues_repo_path": "extended/Fough.agda",
"max_line_length": 97,
"max_stars_count": 25,
"max_stars_repo_head_hexsha": "2e32d399ce35be1106a75c81f43e94aef182d97a",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "gallais/EGTBS",
"max_stars_repo_path": "extended/Fough.agda",
"max_stars_repo_stars_event_max_datetime": "2021-11-08T14:46:37.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-03-22T10:17:36.000Z",
"num_tokens": 5967,
"size": 13243
} |
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import groups.ExactSequence
open import homotopy.FunctionOver
open import homotopy.PtdAdjoint
open import homotopy.SuspAdjointLoop
open import cohomology.MayerVietoris
open import cohomology.Theory
{- Standard Mayer-Vietoris exact sequence (algebraic) derived from
- the result in cohomology.MayerVietoris (topological).
- This is a whole bunch of algebra which is not very interesting.
-}
module cohomology.MayerVietorisExact {i} (CT : CohomologyTheory i)
(n : ℤ) (ps : ⊙Span {i} {i} {i}) where
open MayerVietorisFunctions ps
module MV = MayerVietoris ps
open ⊙Span ps
open CohomologyTheory CT
open import cohomology.BaseIndependence CT
open import cohomology.Functor CT
open import cohomology.InverseInSusp CT
open import cohomology.LongExactSequence CT n ⊙reglue
open import cohomology.Wedge CT
mayer-vietoris-seq : HomSequence _ _
mayer-vietoris-seq =
C n (⊙Pushout ps)
⟨ ×ᴳ-fanout (CF-hom n (⊙left ps)) (CF-hom n (⊙right ps)) ⟩→
C n X ×ᴳ C n Y
⟨ ×ᴳ-fanin (C-is-abelian _ _) (CF-hom n f)
(inv-hom _ (C-is-abelian _ _) ∘ᴳ (CF-hom n g)) ⟩→
C n Z
⟨ CF-hom (succ n) ⊙extract-glue ∘ᴳ fst ((C-Susp n Z)⁻¹ᴳ) ⟩→
C (succ n) (⊙Pushout ps)
⟨ ×ᴳ-fanout (CF-hom _ (⊙left ps)) (CF-hom _ (⊙right ps)) ⟩→
C (succ n) X ×ᴳ C (succ n) Y ⊣|
mayer-vietoris-exact : is-exact-seq mayer-vietoris-seq
mayer-vietoris-exact =
transport (λ {(r , s) → is-exact-seq s})
(pair= _ $ sequence= _ _ $
idp
∥⟨ ↓-over-×-in _→ᴳ_ idp (CWedge.⊙Wedge-rec-over n X Y _ _) ⟩∥
CWedge.path n X Y
∥⟨ ↓-over-×-in' _→ᴳ_
(ap↓ (λ φ → φ ∘ᴳ fst (C-Susp n (X ⊙∨ Y) ⁻¹ᴳ))
(CF-↓cod= (succ n) MV.ext-over)
∙ᵈ codomain-over-iso {χ = diff'} (codomain-over-equiv _ _))
(CWedge.Wedge-hom-η n X Y _
▹ ap2 (×ᴳ-fanin (C-is-abelian n Z)) inl-lemma inr-lemma) ⟩∥
ap (C (succ n)) MV.⊙path ∙ uaᴳ (C-Susp n Z)
∥⟨ ↓-over-×-in _→ᴳ_
(CF-↓dom= (succ n) MV.cfcod-over
∙ᵈ domain-over-iso
(! (ap (λ h → CF _ ⊙extract-glue ∘ h)
(λ= (is-equiv.g-f (snd (C-Susp n Z)))))
◃ domain-over-equiv _ _))
idp ⟩∥
idp
∥⟨ ↓-over-×-in _→ᴳ_ idp (CWedge.⊙Wedge-rec-over (succ n) X Y _ _) ⟩∥
CWedge.path (succ n) X Y ∥⊣|)
long-cofiber-exact
where
{- shorthand -}
diff' = fst (C-Susp n Z) ∘ᴳ CF-hom (succ n) MV.⊙mv-diff
∘ᴳ fst (C-Susp n (X ⊙∨ Y) ⁻¹ᴳ)
{- Variations on suspension axiom naturality -}
natural-lemma₁ : {X Y : Ptd i} (n : ℤ) (f : X ⊙→ Y)
→ (fst (C-Susp n X) ∘ᴳ CF-hom _ (⊙Susp-fmap f)) ∘ᴳ fst (C-Susp n Y ⁻¹ᴳ)
== CF-hom n f
natural-lemma₁ {X} {Y} n f =
ap (λ φ → φ ∘ᴳ fst (C-Susp n Y ⁻¹ᴳ)) (C-SuspF n f)
∙ group-hom= (λ= (ap (CF n f) ∘ is-equiv.f-g (snd (C-Susp n Y))))
natural-lemma₂ : {X Y : Ptd i} (n : ℤ) (f : X ⊙→ Y)
→ CF-hom _ (⊙Susp-fmap f) ∘ᴳ fst (C-Susp n Y ⁻¹ᴳ)
== fst (C-Susp n X ⁻¹ᴳ) ∘ᴳ CF-hom n f
natural-lemma₂ {X} {Y} n f =
group-hom= (λ= (! ∘ is-equiv.g-f (snd (C-Susp n X))
∘ CF _ (⊙Susp-fmap f)
∘ GroupHom.f (fst (C-Susp n Y ⁻¹ᴳ))))
∙ ap (λ φ → fst (C-Susp n X ⁻¹ᴳ) ∘ᴳ φ) (natural-lemma₁ n f)
{- Associativity lemmas -}
assoc-lemma : ∀ {i} {G H K L J : Group i}
(φ : L →ᴳ J) (ψ : K →ᴳ L) (χ : H →ᴳ K) (ξ : G →ᴳ H)
→ (φ ∘ᴳ ψ) ∘ᴳ χ ∘ᴳ ξ == φ ∘ᴳ ((ψ ∘ᴳ χ) ∘ᴳ ξ)
assoc-lemma _ _ _ _ = group-hom= idp
assoc-lemma₂ : ∀ {i} {G H K L J : Group i}
(φ : L →ᴳ J) (ψ : K →ᴳ L) (χ : H →ᴳ K) (ξ : G →ᴳ H)
→ (φ ∘ᴳ ψ ∘ᴳ χ) ∘ᴳ ξ == φ ∘ᴳ ψ ∘ᴳ χ ∘ᴳ ξ
assoc-lemma₂ _ _ _ _ = group-hom= idp
inl-lemma : diff' ∘ᴳ CF-hom n (⊙projl X Y) == CF-hom n f
inl-lemma =
assoc-lemma₂
(fst (C-Susp n Z)) (CF-hom (succ n) MV.⊙mv-diff)
(fst (C-Susp n (X ⊙∨ Y) ⁻¹ᴳ)) (CF-hom n (⊙projl X Y))
∙ ap (λ φ → fst (C-Susp n Z) ∘ᴳ CF-hom (succ n) MV.⊙mv-diff ∘ᴳ φ)
(! (natural-lemma₂ n (⊙projl X Y)))
∙ ! (assoc-lemma₂
(fst (C-Susp n Z)) (CF-hom _ MV.⊙mv-diff)
(CF-hom _ (⊙Susp-fmap (⊙projl X Y)))
(fst (C-Susp n X ⁻¹ᴳ)))
∙ ap (λ φ → (fst (C-Susp n Z) ∘ᴳ φ) ∘ᴳ fst (C-Susp n X ⁻¹ᴳ))
(! (CF-comp _ (⊙Susp-fmap (⊙projl X Y)) MV.⊙mv-diff))
∙ ap (λ φ → (fst (C-Susp n Z) ∘ᴳ φ) ∘ᴳ fst (C-Susp n X ⁻¹ᴳ))
(CF-λ= (succ n) projl-mv-diff)
∙ natural-lemma₁ n f
where
{- Compute the left projection of mv-diff -}
projl-mv-diff : (σz : fst (⊙Susp Z))
→ Susp-fmap (projl X Y) (MV.mv-diff σz)
== Susp-fmap (fst f) σz
projl-mv-diff = Susp-elim idp (merid (pt X)) $
↓-='-from-square ∘ λ z →
(ap-∘ (Susp-fmap (projl X Y)) MV.mv-diff (merid z)
∙ ap (ap (Susp-fmap (projl X Y))) (MV.MVDiff.merid-β z)
∙ ap-∙ (Susp-fmap (projl X Y))
(merid (winl (fst f z))) (! (merid (winr (fst g z))))
∙ (SuspFmap.merid-β (projl X Y) (winl (fst f z))
∙2 (ap-! (Susp-fmap _) (merid (winr (fst g z)))
∙ ap ! (SuspFmap.merid-β (projl X Y) (winr (fst g z))))))
∙v⊡ (vid-square {p = merid (fst f z)}
⊡h rt-square (merid (pt X)))
⊡v∙ (∙-unit-r _ ∙ ! (SuspFmap.merid-β (fst f) z))
inr-lemma : diff' ∘ᴳ CF-hom n (⊙projr X Y)
== inv-hom _ (C-is-abelian n Z) ∘ᴳ CF-hom n g
inr-lemma =
assoc-lemma₂
(fst (C-Susp n Z)) (CF-hom (succ n) MV.⊙mv-diff)
(fst (C-Susp n (X ⊙∨ Y) ⁻¹ᴳ)) (CF-hom n (⊙projr X Y))
∙ ap (λ φ → fst (C-Susp n Z) ∘ᴳ CF-hom (succ n) MV.⊙mv-diff ∘ᴳ φ)
(! (natural-lemma₂ n (⊙projr X Y)))
∙ ! (assoc-lemma₂
(fst (C-Susp n Z)) (CF-hom _ MV.⊙mv-diff)
(CF-hom _ (⊙Susp-fmap (⊙projr X Y)))
(fst (C-Susp n Y ⁻¹ᴳ)))
∙ ap (λ φ → (fst (C-Susp n Z) ∘ᴳ φ) ∘ᴳ fst (C-Susp n Y ⁻¹ᴳ))
(! (CF-comp _ (⊙Susp-fmap (⊙projr X Y)) MV.⊙mv-diff))
∙ ∘ᴳ-assoc (fst (C-Susp n Z))
(CF-hom _ (⊙Susp-fmap (⊙projr X Y) ⊙∘ MV.⊙mv-diff))
(fst (C-Susp n Y ⁻¹ᴳ))
∙ ap (λ φ → fst (C-Susp n Z) ∘ᴳ φ ∘ᴳ fst (C-Susp n Y ⁻¹ᴳ))
(CF-λ= (succ n) projr-mv-diff)
∙ ap (λ φ → fst (C-Susp n Z) ∘ᴳ φ ∘ᴳ fst (C-Susp n Y ⁻¹ᴳ))
(CF-comp _ (⊙Susp-fmap g) (⊙Susp-flip Z))
∙ ! (assoc-lemma (fst (C-Susp n Z)) (CF-hom _ (⊙Susp-flip Z))
(CF-hom _ (⊙Susp-fmap g)) (fst (C-Susp n Y ⁻¹ᴳ)))
∙ ap (λ φ → (fst (C-Susp n Z) ∘ᴳ φ)
∘ᴳ CF-hom _ (⊙Susp-fmap g) ∘ᴳ fst (C-Susp n Y ⁻¹ᴳ))
(C-Susp-flip-is-inv (succ n))
∙ ap (λ φ → φ ∘ᴳ CF-hom _ (⊙Susp-fmap g) ∘ᴳ fst (C-Susp n Y ⁻¹ᴳ))
(inv-hom-natural (C-is-abelian _ _) (C-is-abelian _ _)
(fst (C-Susp n Z)))
∙ assoc-lemma (inv-hom _ (C-is-abelian n Z)) (fst (C-Susp n Z))
(CF-hom _ (⊙Susp-fmap g)) (fst (C-Susp n Y ⁻¹ᴳ))
∙ ap (λ φ → inv-hom _ (C-is-abelian n Z) ∘ᴳ φ) (natural-lemma₁ n g)
where
{- Compute the right projection of mv-diff -}
projr-mv-diff : (σz : fst (⊙Susp Z))
→ Susp-fmap (projr X Y) (MV.mv-diff σz)
== Susp-fmap (fst g) (Susp-flip σz)
projr-mv-diff = Susp-elim (merid (pt Y)) idp $
↓-='-from-square ∘ λ z →
(ap-∘ (Susp-fmap (projr X Y)) MV.mv-diff (merid z)
∙ ap (ap (Susp-fmap (projr X Y))) (MV.MVDiff.merid-β z)
∙ ap-∙ (Susp-fmap (projr X Y))
(merid (winl (fst f z))) (! (merid (winr (fst g z))))
∙ (SuspFmap.merid-β (projr X Y) (winl (fst f z))
∙2 (ap-! (Susp-fmap (projr X Y))
(merid (winr (fst g z)))
∙ ap ! (SuspFmap.merid-β (projr X Y) (winr (fst g z))))))
∙v⊡ ((lt-square (merid (pt Y))
⊡h vid-square {p = ! (merid (fst g z))}))
⊡v∙ ! (ap-∘ (Susp-fmap (fst g)) Susp-flip (merid z)
∙ ap (ap (Susp-fmap (fst g))) (FlipSusp.merid-β z)
∙ ap-! (Susp-fmap (fst g)) (merid z)
∙ ap ! (SuspFmap.merid-β (fst g) z))
| {
"alphanum_fraction": 0.5060375949,
"avg_line_length": 42.7287234043,
"ext": "agda",
"hexsha": "addcb729e997b5c8ce690a2f1e9378ba337dd512",
"lang": "Agda",
"max_forks_count": 50,
"max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z",
"max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "timjb/HoTT-Agda",
"max_forks_repo_path": "theorems/stash/cohomology/MayerVietorisExact.agda",
"max_issues_count": 31,
"max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "timjb/HoTT-Agda",
"max_issues_repo_path": "theorems/stash/cohomology/MayerVietorisExact.agda",
"max_line_length": 76,
"max_stars_count": 294,
"max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "timjb/HoTT-Agda",
"max_stars_repo_path": "theorems/stash/cohomology/MayerVietorisExact.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z",
"num_tokens": 3626,
"size": 8033
} |
module x03relations where
import Relation.Binary.PropositionalEquality as Eq
open Eq using (_≡_; refl; cong; sym)
open import Data.Nat using (ℕ; zero; suc; _+_; _*_)
open import Data.Nat.Properties using (+-comm; +-identityʳ; *-comm; +-suc)
{-
------------------------------------------------------------------------------
-- DEFINING RELATIONS : INEQUALITY ≤
z≤n --------
zero ≤ n
m ≤ n
s≤s -------------
suc m ≤ suc n
-}
-- INDEXED datatype : the type m ≤ n is indexed by two naturals, m and n
data _≤_ : ℕ → ℕ → Set where
-- base case holds for all naturals
z≤n : ∀ {n : ℕ} -- IMPLICIT args
--------
→ zero ≤ n
-- inductive case holds if m ≤ n
s≤s : ∀ {m n : ℕ} -- IMPLICIT args
→ m ≤ n
-------------
→ suc m ≤ suc n
{-
proof 2 ≤ 4
z≤n -----
0 ≤ 2
s≤s -------
1 ≤ 3
s≤s ---------
2 ≤ 4
-}
_ : 2 ≤ 4
_ = s≤s (s≤s z≤n) -- no explicit 'n' arg to z≤n because implicit
-- no explicit 'm' 'n' args to s≤s because implicit
-- can be explicit
_ : 2 ≤ 4 -- with implicit args
_ = s≤s {1} {3} (s≤s {0} {2} (z≤n {2}))
_ : 2 ≤ 4 -- with named implicit args
_ = s≤s {m = 1} {n = 3} (s≤s {m = 0} {n = 2} (z≤n {n = 2}))
_ : 2 ≤ 4 -- with some implicit named args
_ = s≤s {n = 3} (s≤s {n = 2} z≤n)
-- infer explicit term via _
-- e.g., +-identityʳ variant with implicit arguments
+-identityʳ′ : ∀ {m : ℕ} → m + zero ≡ m
+-identityʳ′ = +-identityʳ _ -- agda infers _ from context (if it can)
-- precedence
infix 4 _≤_
------------------------------------------------------------------------------
-- DECIDABILITY : can compute ≤ : see Chapter Decidable
{-
------------------------------------------------------------------------------
-- INVERSION
above def goes from smaller to larger things (e.g., m ≤ n to suc m ≤ suc n)
sometimes go from bigger to smaller things.
only one way to prove suc m ≤ suc n, for any m n
use it to invert rule
-}
inv-s≤s : ∀ {m n : ℕ}
→ suc m ≤ suc n
-------------
→ m ≤ n
inv-s≤s (s≤s m≤n) = m≤n
{- ^
variable name (m ≤ n (with spaces) is a type)
m≤n is of type m ≤ n
convention : var name from type
not every rule is invertible
e.g., rule for z≤n has no non-implicit hypotheses, so nothing to invert
another example inversion
-}
inv-z≤n : ∀ {m : ℕ}
→ m ≤ zero
--------
→ m ≡ zero -- only one way a number can be ≤ zero
inv-z≤n z≤n = refl
{-
------------------------------------------------------------------------------
-- PROPERTIES OF ORDERING RELATIONS
- REFLEXIVE : ∀ n , n ≤ n
- TRANSITIVE : ∀ m n p, if m ≤ n && n ≤ p then m ≤ p
- ANTI-SYMMETRIC : ∀ m n , if m ≤ n && n ≤ m then m ≡ n
- TOTAL : ∀ m n , either m ≤ n or n ≤ m
_≤_ satisfies all 4
names for some combinations:
PREORDER : reflexive and transitive
PARTIAL ORDER : preorder that is also anti-symmetric
TOTAL ORDER : partial order that is also total
Exercise orderings (practice)
preorder that is not a partial order:
-- https://math.stackexchange.com/a/2217969
partial order that is not a total order:
-- https://math.stackexchange.com/a/367590
-- other properties
- SYMMETRIC : ∀ x y, if x R y then y R x
------------------------------------------------------------------------------
REFLEXIVITY
-}
-- proof is via induction on implicit arg n
≤-refl : ∀ {n : ℕ} -- implicit arg to make it easier to invoke
-----
→ n ≤ n
≤-refl {zero} = z≤n -- zero ≤ zero
-- inductive case applies IH '≤-refl {n}' for a proof of n ≤ n to 's≤s' giving proof suc n ≤ suc n
≤-refl {suc n} = s≤s ≤-refl -- suc n ≤ suc n
{-
------------------------------------------------------------------------------
TRANSITIVITY
-}
-- inductive proof using evidence m ≤ n
≤-trans : ∀ {m n p : ℕ}
→ m ≤ n
→ n ≤ p
-----
→ m ≤ p
-- base
-- 1st first inequality holds by z≤n
-- v
≤-trans z≤n _ = z≤n
{- ^ ^
| now must show zero ≤ p; follows by z≤n
n ≤ p case is irrelevant (written _)
-}
{-
inductive
-- 1st inequality
-- | 2nd inequality
v v -}
≤-trans (s≤s m≤n) (s≤s n≤p) = s≤s (≤-trans m≤n n≤p)
{-
1st proves
suc m ≤ suc n
2nd proves
suc n ≤ suc p
must now show
suc m ≤ suc p
IH '≤-trans m≤n n≤p' establishes m ≤ p
goal follows by applying s≤s
≤-trans (s≤s m≤n) z≤n case cannot arise since
- 1st inequality implies middle value is suc n
- 2nd inequality implies that it is zero
-}
≤-trans′ : ∀ (m n p : ℕ) -- ALTERNATIVE with explicit args
→ m ≤ n
→ n ≤ p
-----
→ m ≤ p
≤-trans′ zero _ _ z≤n _ = z≤n
≤-trans′ (suc m) (suc n) (suc p) (s≤s m≤n) (s≤s n≤p) = s≤s (≤-trans′ m n p m≤n n≤p)
{-
technique of induction on evidence that a property holds
- e.g., inducting on evidence that m ≤ n
rather than induction on values of which the property holds
- e.g., inducting on m
is often used
------------------------------------------------------------------------------
ANTI-SYMMETRY
-}
-- 842
-- proof via rewrite
≤-antisym' : ∀ {m n : ℕ}
→ m ≤ n
→ n ≤ m
-----
→ m ≡ n
≤-antisym' z≤n z≤n = refl
≤-antisym' (s≤s m≤n) (s≤s n≤m) rewrite ≤-antisym' m≤n n≤m = refl
-- proof via induction over the evidence that m ≤ n and n ≤ m hold
≤-antisym : ∀ {m n : ℕ}
→ m ≤ n
→ n ≤ m
-----
→ m ≡ n
≤-antisym z≤n z≤n = refl
≤-antisym (s≤s m≤n) (s≤s n≤m) = cong suc (≤-antisym m≤n n≤m)
{-
base : both inequalities hold by z≤n
- so given zero ≤ zero and zero ≤ zero
- shows zero ≡ zero (via Reflexivity of equality)
inductive
- after using evidence for 1st and 2nd inequalities
- have suc m ≤ suc n and suc n ≤ suc m
- must show suc m ≡ suc n
- IH '≤-antisym m≤n n≤m' establishes m ≡ n
- goal follows by congruence
Exercise ≤-antisym-cases (practice) TODO : describe why missing case OK
The above proof omits cases where one argument is z≤n and one argument is s≤s.
Why is it ok to omit them?
-- Your code goes here
------------------------------------------------------------------------------
TOTAL
-}
-- datatype with PARAMETERS
data Total (m n : ℕ) : Set where
forward :
m ≤ n
---------
→ Total m n
flipped :
n ≤ m
---------
→ Total m n
{-
Evidence that Total m n holds is either of the form
- forward m≤n or
- flipped n≤m
where m≤n and n≤m are evidence of m ≤ n and n ≤ m respectively
(above definition could also be written as a disjunction; see Chapter Connectives.)
above data type uses PARAMETERS m n --- equivalent to following INDEXED datatype:
-}
data Total′ : ℕ → ℕ → Set where
forward′ : ∀ {m n : ℕ}
→ m ≤ n
----------
→ Total′ m n
flipped′ : ∀ {m n : ℕ}
→ n ≤ m
----------
→ Total′ m n
{-
Each parameter of the type translates as an implicit parameter of each constructor.
Unlike an indexed datatype, where the indexes can vary (as in zero ≤ n and suc m ≤ suc n),
in a parameterised datatype the parameters must always be the same (as in Total m n).
Parameterised declarations are shorter, easier to read,
and occasionally aid Agda’s termination checker.
Use them in preference to indexed types when possible.
-------------------------
show ≤ is a total order by induction over 1st and 2nd args
uses WITH
-}
≤-total : ∀ (m n : ℕ) → Total m n
-- base : 1st arg zero so forward case holds with z≤n as evidence that zero ≤ n
≤-total zero n = forward z≤n
-- base : 2nd arg zero so flipped case holds with z≤n as evidence that zero ≤ suc m
≤-total (suc m) zero = flipped z≤n
-- inductive : IH establishes one of
≤-total (suc m) (suc n) with ≤-total m n
-- forward case of IH with m≤n as evidence that m ≤ n
-- follows that forward case of prop holds with s≤s m≤n as evidence that suc m ≤ suc n
... | forward m≤n = forward (s≤s m≤n)
-- flipped case of IH with n≤m as evidence that n ≤ m
-- follows that flipped case of prop holds with s≤s n≤m as evidence that suc n ≤ suc m
... | flipped n≤m = flipped (s≤s n≤m)
{-
WITH expression and one or more subsequent lines
each line begins ... | followed by pattern and right-hand side
WITH equivalent to defining a helper function:
-}
≤-total′ : ∀ (m n : ℕ) → Total m n
≤-total′ zero n = forward z≤n
≤-total′ (suc m) zero = flipped z≤n
≤-total′ (suc m) (suc n) = helper (≤-total′ m n)
where
helper : Total m n → Total (suc m) (suc n)
helper (forward m≤n) = forward (s≤s m≤n)
helper (flipped n≤m) = flipped (s≤s n≤m)
{-
WHERE
vars bound on the left-hand side of the preceding equation (e.g., m n) in scope in nested def
any identifiers bound in nested definition (e.g., helper)
in scope in right-hand side of preceding equation
If both arguments are equal, then both cases hold and we could return evidence of either.
In the code above we return the forward case, but there is a variant that returns the flipped case:
-}
≤-total″ : ∀ (m n : ℕ) → Total m n
≤-total″ m zero = flipped z≤n
≤-total″ zero (suc n) = forward z≤n
≤-total″ (suc m) (suc n) with ≤-total″ m n
... | forward m≤n = forward (s≤s m≤n)
... | flipped n≤m = flipped (s≤s n≤m)
-- differs from original : pattern matches on 2nd arg before 1st
{-
------------------------------------------------------------------------------
MONOTONICITY ∀ {m n p q : ℕ} → m ≤ n → p ≤ q → m + p ≤ n + q
addition is monotonic on the right
proof by induction on 1st arg
-}
+-monoʳ-≤ : ∀ (n p q : ℕ)
→ p ≤ q
-------------
→ n + p ≤ n + q
-- base : 1st is zero; zero + p ≤ zero + q
-- def/eq p ≤ q
-- evidence given by arg p≤q
+-monoʳ-≤ zero p q p≤q = p≤q
-- inductive : 1st is suc n; suc n + p ≤ suc n + q
-- def/eq; suc (n + p) ≤ suc (n + q)
-- IH +-monoʳ-≤ n p q p≤q establishes n + p ≤ n + q
-- goal follows by applying s≤s
+-monoʳ-≤ (suc n) p q p≤q = s≤s (+-monoʳ-≤ n p q p≤q)
{-
addition is monotonic on the left
via previous result and commutativity of addition:
-}
+-monoˡ-≤ : ∀ (m n p : ℕ)
→ m ≤ n
-------------
→ m + p ≤ n + p
+-monoˡ-≤ m n p m≤n -- m + p ≤ n + p
rewrite
+-comm m p -- p + m ≤ n + p
| +-comm n p -- p + m ≤ p + n
= +-monoʳ-≤ p m n m≤n
-- combine above results:
+-mono-≤ : ∀ (m n p q : ℕ)
→ m ≤ n
→ p ≤ q
-------------
→ m + p ≤ n + q
+-mono-≤ m n p q m≤n p≤q
= ≤-trans -- combining below via transitivity proves m + p ≤ n + q
(+-monoˡ-≤ m n p m≤n) -- proves m + p ≤ n + p
(+-monoʳ-≤ n p q p≤q) -- proves n + p ≤ n + q
{-
------------------------------------------------------------------------------
Exercise *-mono-≤ (stretch) Show that multiplication is monotonic with regard to inequality.
-}
-------------------------
-- multiplication is monotonic on the right
*-monoʳ-≤ : ∀ (n p q : ℕ)
→ p ≤ q
-------------
→ n * p ≤ n * q
*-monoʳ-≤ zero p q p≤q -- zero * p ≤ zero * q
-- zero ≤ zero
= z≤n
*-monoʳ-≤ n zero q p≤q -- n * zero ≤ n * q
rewrite
*-comm n zero -- 0 ≤ n * q
= z≤n
*-monoʳ-≤ n p zero p≤q -- n * p ≤ n * zero
rewrite
*-comm n zero -- n * p ≤ 0
| inv-z≤n p≤q -- n * 0 ≤ 0
| *-comm n zero -- 0 ≤ 0
= z≤n
*-monoʳ-≤ n (suc p) (suc q) p≤q -- n * suc p ≤ n * suc q
rewrite
*-comm n (suc p) -- n + p * n ≤ n * suc q
| *-comm n (suc q) -- n + p * n ≤ n + q * n
| *-comm p n -- n + n * p ≤ n + q * n
| *-comm q n -- n + n * p ≤ n + n * q
= +-monoʳ-≤ n (n * p) (n * q) (*-monoʳ-≤ n p q (inv-s≤s p≤q))
-------------------------
-- multiplication is monotonic on the left
*-monoˡ-≤ : ∀ (m n p : ℕ)
→ m ≤ n
-------------
→ m * p ≤ n * p
*-monoˡ-≤ zero n p m≤n -- zero * p ≤ n * p
-- zero ≤ n * p
= z≤n
*-monoˡ-≤ m zero p m≤n -- m * p ≤ zero * p
-- m * p ≤ zero
rewrite inv-z≤n m≤n -- 0 * p ≤ 0
-- zero ≤ 0
= z≤n
*-monoˡ-≤ (suc m) (suc n) p m≤n -- suc m * p ≤ suc n * p
-- p + m * p ≤ p + n * p
= +-monoʳ-≤ p (m * p) (n * p) (*-monoˡ-≤ m n p (inv-s≤s m≤n))
-------------------------
*-mono-≤ : ∀ (m n p q : ℕ)
→ m ≤ n
→ p ≤ q
-------------
→ m * p ≤ n * q
*-mono-≤ m n p q m≤n p≤q
= ≤-trans
(*-monoˡ-≤ m n p m≤n)
(*-monoʳ-≤ n p q p≤q)
{-
------------------------------------------------------------------------------
STRICT INEQUALITY <
-}
infix 4 _<_
data _<_ : ℕ → ℕ → Set where
z<s : ∀ {n : ℕ}
------------
→ zero < suc n -- diff from '≤' : 'zero ≤ n'
s<s : ∀ {m n : ℕ}
→ m < n
-------------
→ suc m < suc n
{-
NOT REFLEXIVE
IRREFLEXIVE : n < n never holds for any n
TRANSITIVE
NOT TOTAL
TRICHOTOMY: ∀ m n, one of m < n, m ≡ n, or m > n holds
- where m > n hold when n < m
MONOTONIC with regards to ADDITION and MULTIPLICATION
negation required to prove (so deferred to Chapter Negation)
- irreflexivity
- trichotomy case are mutually exclusive
------------------------------------------------------------------------------
show suc m ≤ n implies m < n (and conversely)
-}
m≤n→m<n : ∀ {m n : ℕ}
→ suc m ≤ n
---------
→ m < n
m≤n→m<n {zero} {zero} ()
m≤n→m<n {zero} {suc n} m≤n = z<s
m≤n→m<n {suc m} {suc n} m≤n = s<s (m≤n→m<n {m} {n} (inv-s≤s m≤n))
inv-s<s : ∀ {m n : ℕ}
→ suc m < suc n
-------------
→ m < n
inv-s<s (s<s m<n) = m<n
m<n→m≤n : ∀ {m n : ℕ}
→ m < n
→ m ≤ n
m<n→m≤n {zero} {suc n} m<n = z≤n
m<n→m≤n {suc m} {suc n} m<n = s≤s (m<n→m≤n {m} {n} (inv-s<s m<n))
{-
can then give an alternative derivation of the properties of strict inequality
(e.g., transitivity) by exploiting the corresponding properties of inequality
------------------------------------------------------------------------------
Exercise <-trans (recommended) : strict inequality is transitive.
-}
<-trans : ∀ {m n p : ℕ}
→ m < n
→ n < p
-----
→ m < p
<-trans {zero} {n} {p} z<s (s<s n<p) = z<s
<-trans {suc m} {suc n} {suc p} (s<s m<n) (s<s n<p) = s<s (<-trans {m} {n} {p} m<n n<p)
<-trans' : ∀ {m n p : ℕ}
→ m < n
→ n < p
-----
→ m < p
<-trans' z<s (s<s n<p) = z<s
<-trans' (s<s m<n) (s<s n<p) = s<s (<-trans' m<n n<p)
{-
------------------------------------------------------------------------------
Exercise trichotomy (practice)
Show that strict inequality satisfies a weak version of trichotomy,
in the sense that for any m and n that one of the following holds:
- m < n
- m ≡ n
- m > n
Define m > n to be the same as n < m.
Need a data declaration, similar to that used for totality.
(Later will show that the three cases are exclusive after negation is introduced.)
-}
-- from 842
data Trichotomy (m n : ℕ) : Set where
is-< : m < n → Trichotomy m n
is-≡ : m ≡ n → Trichotomy m n
is-> : n < m → Trichotomy m n
-- hc
<-trichotomy : ∀ (m n : ℕ) → Trichotomy m n
<-trichotomy zero zero = is-≡ refl
<-trichotomy zero (suc n) = is-< z<s
<-trichotomy (suc m) zero = is-> z<s
<-trichotomy (suc m) (suc n) = helper (<-trichotomy m n)
where
helper : Trichotomy m n -> Trichotomy (suc m) (suc n)
helper (is-< x) = is-< (s<s x)
helper (is-≡ x) = is-≡ (cong suc x)
helper (is-> x) = is-> (s<s x)
{-
------------------------------------------------------------------------------
Exercise +-mono-< (practice)
Show that addition is monotonic with respect to strict inequality.
As with inequality, some additional definitions may be required.
-}
-- HC
-- these proof are literal cut/paste/change '≤' to '<'
-- no additional defs were required
+-monoʳ-< : ∀ (n p q : ℕ)
→ p < q
-------------
→ n + p < n + q
+-monoʳ-< zero p q p<q = p<q
+-monoʳ-< (suc n) p q p<q = s<s (+-monoʳ-< n p q p<q)
+-monoˡ-< : ∀ (m n p : ℕ)
→ m < n
-------------
→ m + p < n + p
+-monoˡ-< m n p m<n
rewrite
+-comm m p
| +-comm n p
= +-monoʳ-< p m n m<n
+-mono-< : ∀ (m n p q : ℕ)
→ m < n
→ p < q
-------------
→ m + p < n + q
+-mono-< m n p q m<n p<q
= <-trans
(+-monoˡ-< m n p m<n)
(+-monoʳ-< n p q p<q)
{-
------------------------------------------------------------------------------
Exercise ≤-iff-< (recommended) : suc m ≤ n implies m < n, and conversely
-}
-- 842 exercise: LEtoLTS (1 point) ≤-<-to
m≤n→m<sucn : ∀ {m n : ℕ}
→ m ≤ n
→ m < suc n
m≤n→m<sucn {zero} m≤n = z<s
m≤n→m<sucn {suc m} {suc n} m≤n = s<s (m≤n→m<sucn {m} {n} (inv-s≤s m≤n))
-- 842 exercise: LEStoLT (1 point) ≤-<--to′
sucm≤n→m<n : ∀ {m n : ℕ}
→ suc m ≤ n
→ m < n
sucm≤n→m<n {zero} {suc n} sucm≤n = z<s
sucm≤n→m<n {suc m} {suc n} sucm≤n = s<s (sucm≤n→m<n {m} {n} (inv-s≤s sucm≤n))
-- 842 exercise: LTtoSLE (1 point) ≤-<-from
m<n→sucm≤n : ∀ {m n : ℕ}
→ m < n
→ suc m ≤ n
m<n→sucm≤n {zero} {suc n} m<n = s≤s z≤n
m<n→sucm≤n {suc m} {suc n} m<n = s≤s (m<n→sucm≤n {m} {n} (inv-s<s m<n))
-- 842 exercise: LTStoLE (1 point) ≤-<-from′
m<sucn→m≤n : ∀ {m n : ℕ}
→ m < suc n
→ m ≤ n
m<sucn→m≤n {zero} z<n = z≤n
m<sucn→m≤n {suc m} {suc n} (s<s m<n) = s≤s (m<sucn→m≤n {m} {n} m<n)
-- ^
-- critical move
{-
------------------------------------------------------------------------------
Exercise <-trans-revisited (practice)
Give an alternative proof that strict inequality is transitive,
using the relation between strict inequality and inequality
and the fact that inequality is transitive.
-- 842: use the above to give a proof of <-trans that uses ≤-trans
-}
n<p→n<sucp : ∀ {n p : ℕ}
→ n < p
→ n < suc p
n<p→n<sucp z<s = z<s
n<p→n<sucp {suc n} {suc p} n<p = s<s (n<p→n<sucp {n} {p} (inv-s<s n<p))
<-trans'' : ∀ {m n p : ℕ}
→ m < n
→ n < p
-----
→ m < p
<-trans'' {zero} {suc n} {suc p} z<s _ = z<s
<-trans'' {suc m} {suc n} {suc p} (s<s m<n) (s<s n<p)
= sucm≤n→m<n
(≤-trans (m<n→sucm≤n (s<s m<n))
(m<sucn→m≤n (s<s (n<p→n<sucp n<p))))
{-
------------------------------------------------------------------------------
EVEN and ODD : MUTUALLY RECURSIVE DATATYPE DECLARATION and OVERLOADED CONSTRUCTORS
inequality and strict inequality are BINARY RELATIONS
even and odd are UNARY RELATIONS, sometimes called PREDICATES
-}
-- identifier must be defined before it is used, so declare both before giving constructors.
data even : ℕ → Set
data odd : ℕ → Set
data even where
zero : -- overloaded with nat def
---------
even zero
suc : ∀ {n : ℕ}
→ odd n
------------
→ even (suc n)
data odd where
suc : ∀ {n : ℕ} -- suc is overloaded with one above and nat def
→ even n
-----------
→ odd (suc n)
{-
overloading constructors is OK (handled by type inference
overloading defined names NOT OK
best practice : only overload related meanings
-}
-- mutually recursive proof functions : give types first, then impls
-- sum of two even numbers is even
e+e≡e : ∀ {m n : ℕ}
→ even m
→ even n
------------
→ even (m + n)
-- sum of even and odd is odd
o+e≡o : ∀ {m n : ℕ}
→ odd m
→ even n
-----------
→ odd (m + n)
-- given: zero is evidence that 1st is even
-- given: 2nd is even
-- result: even because 2nd is even
e+e≡e zero en = en
-- given: 1st is even because it is suc of odd
-- given: 2nd is even
-- result: even because it is suc of sum of odd and even number, which is odd
e+e≡e (suc om) en = suc (o+e≡o om en)
-- given: 1st odd because it is suc of even
-- given: 2nd is event
-- result: odd because it is suc of sum of two evens, which is even
o+e≡o (suc em) en = suc (e+e≡e em en)
------------------------------------------------------------------------------
-- Exercise o+o≡e (stretch) : sum of two odd numbers is even
-- 842 Hint: need to define another theorem and prove both by mutual induction
-- sum of odd and even is odd
e+o≡o : ∀ {m n : ℕ}
→ even m
→ odd n
-----------
→ odd (m + n)
-- sum of odd and odd is even
o+o≡e : ∀ {m n : ℕ}
→ odd m
→ odd n
--------------
→ even (m + n)
e+o≡o zero on = on
e+o≡o (suc em) on = suc (o+o≡e em on)
o+o≡e (suc om) on = suc (e+o≡o om on)
{-
------------------------------------------------------------------------------
Exercise Bin-predicates (stretch)
representations not unique due to leading zeros
eleven:
⟨⟩ I O I I -- canonical
⟨⟩ O O I O I I -- not canonical
-}
data Bin : Set where
⟨⟩ : Bin
_O : Bin → Bin
_I : Bin → Bin
inc : Bin → Bin
inc ⟨⟩ = ⟨⟩ I
inc (b O) = b I
inc (b I) = (inc b) O
to : ℕ → Bin
to zero = ⟨⟩ O
to (suc m) = inc (to m)
dbl : ℕ → ℕ
dbl zero = zero
dbl (suc m) = suc (suc (dbl m))
from : Bin → ℕ
from ⟨⟩ = 0
from (b O) = dbl (from b)
from (b I) = suc (dbl (from b))
-- httpS://www.reddit.com/r/agda/comments/hrvk07/plfa_quantifiers_help_with_binisomorphism/
-- holds if bitstring has a leading one
data One : Bin → Set where
one : One (⟨⟩ I)
_withO : ∀ {b} → One b → One (b O)
_withI : ∀ {b} → One b → One (b I)
{-
Hint: to prove below
- first state/prove properties of One
-}
n≤1+n : ∀ (n : ℕ) → n ≤ 1 + n
n≤1+n zero = z≤n
n≤1+n (suc n) = s≤s (n≤1+n n)
dbl-mono : ∀ (n : ℕ) → n ≤ dbl n
dbl-mono zero = z≤n
dbl-mono (suc n) = s≤s (≤-trans (dbl-mono n) (n≤1+n (dbl n)))
-- not used; I thought it would be useful; first try
n≤fromb→n≤dblfromb' : ∀ {n : ℕ} {b : Bin} → n ≤ from b → n ≤ dbl (from b)
n≤fromb→n≤dblfromb' {zero} {b} p = z≤n
n≤fromb→n≤dblfromb' {suc n} {b O} p =
≤-trans p (dbl-mono (from (b O)))
n≤fromb→n≤dblfromb' {suc n} {b I} (s≤s p) =
s≤s (≤-trans (≤-trans p (dbl-mono (dbl (from b))))
(n≤1+n (dbl (dbl (from b)))))
-- not used; above cleaned up
n≤fromb→n≤dblfromb : ∀ {n : ℕ} {b : Bin}
→ n ≤ from b
→ n ≤ dbl (from b)
n≤fromb→n≤dblfromb {_} {b} p = ≤-trans p (dbl-mono (from b))
-- HINT: prove if One b then 1 is less or equal to the result of from b
oneb→1≤fromb : ∀ {b : Bin} → One b → 1 ≤ from b
oneb→1≤fromb {b I} _ = s≤s z≤n
oneb→1≤fromb {b O} (p withO) = ≤-trans (oneb→1≤fromb p) (dbl-mono (from b))
oneb→0<fromb : ∀ {b : Bin} → One b → 0 < from b
oneb→0<fromb p = m≤n→m<n (oneb→1≤fromb p)
-- not used
num-trailing-zeros : (b : Bin) {p : One b} → ℕ
num-trailing-zeros (b I) = 0
num-trailing-zeros (b O) {p withO} = 1 + num-trailing-zeros b {p}
-- not used
do-dbls : ℕ -> ℕ
do-dbls zero = suc zero
do-dbls (suc n) = dbl (do-dbls n)
{-
xxx : {b : Bin} {n : ℕ}
→ (p : One b)
→ n ≡ num-trailing-zeros b {p}
→ do-dbls n ≤ from b
xxx {⟨⟩ I} {zero} one ntz = s≤s z≤n
xxx {b I} {zero} (ob withI) ntz = s≤s z≤n
xxx {b O} {zero} (ob withO) ntz = ≤-trans (oneb→1≤fromb ob) (dbl-mono (from b))
xxx {b O} {suc n} (ob withO) ntz = {!!}
-}
-- bitstring is canonical if
data Can : Bin → Set where
czero : Can (⟨⟩ O) -- it consists of a single zero (representing zero)
cone : ∀ {b : Bin}
→ One b -- it has a leading one (representing a positive number)
-----
→ Can b
{-
--------------------------------------------------
show that increment preserves canonical bitstrings
-}
oneb→one-incb : ∀ {b : Bin} → One b → One (inc b)
oneb→one-incb one = one withO
oneb→one-incb (p withO) = p withI
oneb→one-incb (p withI) = oneb→one-incb p withO
canb→canincb : ∀ {b : Bin}
→ Can b
----------
→ Can (inc b)
canb→canincb {.(⟨⟩ O)} czero = cone one
canb→canincb {b} (cone p) = cone (oneb→one-incb p)
{-
--------------------------------------------------
show that converting a natural to a bitstring always yields a canonical bitstring
-}
can-to-n : ∀ {n : ℕ} → Can (to n)
can-to-n {zero} = czero
can-to-n {suc n} = canb→canincb (can-to-n {n})
{-
--------------------------------------------------
show that converting a canonical bitstring to a natural and back is the identity TODO
-}
ob→obO : ∀ {b : Bin} → One b → One (b O)
ob→obI : ∀ {b : Bin} → One b → One (b I)
ob→obI {.(⟨⟩ I)} one = one withI
ob→obI {.(_ O)} (p withO) = ob→obO p withI
ob→obI {(b I)} (p withI) = ob→obI {b} p withI
ob→obO {.(⟨⟩ I)} one = one withO
ob→obO {.(_ O)} (p withO) = (ob→obO p) withO
ob→obO {(b I)} (p withI) = ob→obI {b} p withO
dblb : Bin → Bin
dblb ⟨⟩ = ⟨⟩
dblb (⟨⟩ O) = ⟨⟩ O
dblb b = b O
dblbo : ∀ {b} → One b → Bin → Bin
dblbo _ b = b O
dblbc : ∀ {b} → Can b → Bin → Bin
dblbc czero _ = ⟨⟩ O
dblbc (cone _) b = b O
xxxx : ∀ {b : Bin} {n : ℕ}
→ b ≡ (⟨⟩ I)
→ b ≡ to n
→ n ≡ 1
→ (⟨⟩ I O) ≡ to (dbl n)
xxxx p1 p2 p3 rewrite p3 = refl
xx : ∀ {b : Bin} → One b -> to (dbl (from b)) ≡ b O
xx one = refl
xx {b O} (p withO) -- to (dbl (from (b O))) ≡ ((b O) O)
-- to (dbl (dbl (from b))) ≡ ((b O) O)
rewrite
sym (xx p) -- to (dbl (dbl (from b))) ≡ (to (dbl (from b)) O)
= {!!}
xx {b I} (p withI) -- to (dbl (from (b I)) ≡ ((b I) O)
-- inc (inc (to (dbl (dbl (from b))))) ≡ ((b I) O)
= {!!}
can-b→to-from-b≡b : ∀ {b : Bin}
→ Can b
---------------
→ to (from b) ≡ b
can-b→to-from-b≡b czero = refl
can-b→to-from-b≡b {.⟨⟩ I} (cone one) = refl
can-b→to-from-b≡b {b O} (cone (p withO)) -- to (dbl (from b)) ≡ (b O)
= xx p
can-b→to-from-b≡b {b I} (cone (p withI)) -- inc (to (dbl (from b))) ≡ (b I)
rewrite xx p -- (b I) ≡ (b I)
= refl
{-
------------------------------------------------------------------------------
Standard library
defs in this chapter in standard library:
import Data.Nat using (_≤_; z≤n; s≤s)
import Data.Nat.Properties using (≤-refl; ≤-trans; ≤-antisym; ≤-total;
+-monoʳ-≤; +-monoˡ-≤; +-mono-≤)
------------------------------------------------------------------------------
Unicode
≤ U+2264 LESS-THAN OR EQUAL TO (\<=, \le)
≥ U+2265 GREATER-THAN OR EQUAL TO (\>=, \ge)
ˡ U+02E1 MODIFIER LETTER SMALL L (\^l)
ʳ U+02B3 MODIFIER LETTER SMALL R (\^r)
-}
| {
"alphanum_fraction": 0.4840215305,
"avg_line_length": 26.4875373878,
"ext": "agda",
"hexsha": "b6177650f804f01739877b08b170b691e02c64f5",
"lang": "Agda",
"max_forks_count": 8,
"max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z",
"max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225",
"max_forks_repo_licenses": [
"Unlicense"
],
"max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc",
"max_forks_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x03relations.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Unlicense"
],
"max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc",
"max_issues_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x03relations.agda",
"max_line_length": 99,
"max_stars_count": 36,
"max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225",
"max_stars_repo_licenses": [
"Unlicense"
],
"max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc",
"max_stars_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x03relations.agda",
"max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z",
"num_tokens": 9606,
"size": 26567
} |
module Data.Boolean.Numeral where
open import Data
open import Data.Boolean
open import Data.Boolean.Stmt
import Lvl
open import Numeral.Natural
open import Numeral.Natural.Oper.Comparisons
open import Syntax.Number
open import Type
Bool-to-ℕ : Bool → ℕ
Bool-to-ℕ 𝐹 = 0
Bool-to-ℕ 𝑇 = 1
ℕ-to-Bool : (n : ℕ) → . ⦃ _ : IsTrue(n <? 2) ⦄ → Bool
ℕ-to-Bool 0 = 𝐹
ℕ-to-Bool 1 = 𝑇
instance
Bool-from-ℕ : Numeral(Bool)
Numeral.restriction-ℓ Bool-from-ℕ = Lvl.𝟎
Numeral.restriction Bool-from-ℕ n = IsTrue(n <? 2)
num ⦃ Bool-from-ℕ ⦄ n = ℕ-to-Bool n
| {
"alphanum_fraction": 0.6632124352,
"avg_line_length": 23.16,
"ext": "agda",
"hexsha": "78ba368a24cf027250ac6d628466658753f1e537",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Data/Boolean/Numeral.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Data/Boolean/Numeral.agda",
"max_line_length": 56,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Data/Boolean/Numeral.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z",
"num_tokens": 224,
"size": 579
} |
module Lib.Vec where
open import Common.Nat
open import Lib.Fin
open import Common.Unit
import Common.List as List; open List using (List ; [] ; _∷_)
data Vec (A : Set) : Nat → Set where
_∷_ : {n : Nat} → A → Vec A n → Vec A (suc n)
[] : Vec A zero
infixr 30 _++_
_++_ : {A : Set}{m n : Nat} → Vec A m → Vec A n → Vec A (m + n)
[] ++ ys = ys
(x ∷ xs) ++ ys = x ∷ (xs ++ ys)
snoc : {A : Set}{n : Nat} → Vec A n → A → Vec A (suc n)
snoc [] e = e ∷ []
snoc (x ∷ xs) e = x ∷ snoc xs e
-- Recursive length.
length : {A : Set}{n : Nat} → Vec A n → Nat
length [] = zero
length (x ∷ xs) = 1 + length xs
length' : {A : Set}{n : Nat} → Vec A n → Nat
length' {n = n} _ = n
zipWith3 : ∀ {A B C D n} → (A → B → C → D) → Vec A n → Vec B n → Vec C n → Vec D n
zipWith3 f [] [] [] = []
zipWith3 f (x ∷ xs) (y ∷ ys) (z ∷ zs) = f x y z ∷ zipWith3 f xs ys zs
zipWith : ∀ {A B C n} → (A → B → C) → Vec A n → Vec B n → {u : Unit} → Vec C n
zipWith _ [] [] = []
zipWith f (x ∷ xs) (y ∷ ys) = f x y ∷ zipWith f xs ys {u = unit}
_!_ : ∀ {A n} → Vec A n → Fin n → A
(x ∷ xs) ! fz = x
(_ ∷ xs) ! fs n = xs ! n
[] ! ()
-- Update vector at index
_[_]=_ : {A : Set}{n : Nat} → Vec A n → Fin n → A → Vec A n
(a ∷ as) [ fz ]= e = e ∷ as
(a ∷ as) [ fs n ]= e = a ∷ (as [ n ]= e)
[] [ () ]= e
map : ∀ {A B n}(f : A → B)(xs : Vec A n) → Vec B n
map f [] = []
map f (x ∷ xs) = f x ∷ map f xs
-- Vector to List, forget the length.
forgetL : {A : Set}{n : Nat} → Vec A n → List A
forgetL [] = []
forgetL (x ∷ xs) = x ∷ forgetL xs
-- List to Vector, "rem"member the length.
rem : {A : Set}(xs : List A) → Vec A (List.length xs)
rem [] = []
rem (x ∷ xs) = x ∷ rem xs
| {
"alphanum_fraction": 0.475573867,
"avg_line_length": 25.7424242424,
"ext": "agda",
"hexsha": "87dd1689eb4f1d416419afdd6883892d735a5dab",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Compiler/simple/Lib/Vec.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Compiler/simple/Lib/Vec.agda",
"max_line_length": 82,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Compiler/simple/Lib/Vec.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": 714,
"size": 1699
} |
{-# OPTIONS --cubical --safe #-}
module Lens.Composition where
open import Prelude
open import Lens.Definition
open import Lens.Operators
infixr 9 _⋯_
_⋯_ : Lens A B → Lens B C → Lens A C
fst (ab ⋯ bc) xs = ac
where
ab-xs : LensPart _ _
ab-xs = fst ab xs
bc-ys : LensPart _ _
bc-ys = fst bc (get ab-xs)
ac : LensPart _ _
get ac = get bc-ys
set ac v = set ab-xs (set bc-ys v)
get-set (snd (ab ⋯ bc)) s v = cong (getter bc) (get-set (snd ab) s _) ; bc .snd .get-set (get (fst ab s)) v
set-get (snd (ab ⋯ bc)) s = cong (setter ab s) (set-get (snd bc) (get (fst ab s))) ; set-get (snd ab) s
set-set (snd (ab ⋯ bc)) s v₁ v₂ = set-set (snd ab) s _ _ ; cong (setter ab s) (cong (flip (setter bc) v₂) (get-set (snd ab) _ _) ; set-set (snd bc) _ _ _)
| {
"alphanum_fraction": 0.6068152031,
"avg_line_length": 30.52,
"ext": "agda",
"hexsha": "5b3e17f44e9b9934966597e1b334a7285d2d9dd4",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z",
"max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/agda-playground",
"max_forks_repo_path": "Lens/Composition.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "oisdk/agda-playground",
"max_issues_repo_path": "Lens/Composition.agda",
"max_line_length": 154,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/agda-playground",
"max_stars_repo_path": "Lens/Composition.agda",
"max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z",
"num_tokens": 301,
"size": 763
} |
module InstanceArgumentsAmbiguous where
postulate A B : Set
f : {{a : A}} → B
a₁ a₂ : A
test : B
test = f
| {
"alphanum_fraction": 0.546875,
"avg_line_length": 14.2222222222,
"ext": "agda",
"hexsha": "878e850c0cd87fe537e2a59d3370b650505f23a4",
"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/InstanceArgumentsAmbiguous.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/InstanceArgumentsAmbiguous.agda",
"max_line_length": 39,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "test/fail/InstanceArgumentsAmbiguous.agda",
"max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z",
"num_tokens": 41,
"size": 128
} |
{-# OPTIONS --without-K --rewriting #-}
open import Basics
open import lib.Basics
open import Flat
module Axiom.C1 {@♭ i j : ULevel} (@♭ I : Type i) (@♭ R : I → Type j) where
open import Axiom.C0 I R
postulate C1 : (index : I) → R index
| {
"alphanum_fraction": 0.6209677419,
"avg_line_length": 22.5454545455,
"ext": "agda",
"hexsha": "cba18ad0c2195c0a1b7fa3e0d38c62844e91fa93",
"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": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a",
"max_forks_repo_licenses": [
"CC0-1.0"
],
"max_forks_repo_name": "glangmead/formalization",
"max_forks_repo_path": "cohesion/david_jaz_261/Axiom/C1.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a",
"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": "glangmead/formalization",
"max_issues_repo_path": "cohesion/david_jaz_261/Axiom/C1.agda",
"max_line_length": 75,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a",
"max_stars_repo_licenses": [
"CC0-1.0"
],
"max_stars_repo_name": "glangmead/formalization",
"max_stars_repo_path": "cohesion/david_jaz_261/Axiom/C1.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-13T05:51:12.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-10-06T17:39:22.000Z",
"num_tokens": 84,
"size": 248
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- A Categorical view of the Sum type (Right-biased)
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Level
module Data.Sum.Categorical.Right (a : Level) {b} (B : Set b) where
open import Data.Sum
open import Category.Functor
open import Category.Applicative
open import Category.Monad
open import Function
import Function.Identity.Categorical as Id
Sumᵣ : Set (a ⊔ b) → Set (a ⊔ b)
Sumᵣ A = A ⊎ B
functor : RawFunctor Sumᵣ
functor = record { _<$>_ = map₁ }
applicative : RawApplicative Sumᵣ
applicative = record
{ pure = inj₁
; _⊛_ = [ map₁ , const ∘ inj₂ ]′
}
monadT : RawMonadT (_∘′ Sumᵣ)
monadT M = record
{ return = M.pure ∘′ inj₁
; _>>=_ = λ ma f → ma M.>>= [ f , M.pure ∘′ inj₂ ]′
} where module M = RawMonad M
monad : RawMonad Sumᵣ
monad = monadT Id.monad
------------------------------------------------------------------------
-- Get access to other monadic functions
module _ {F} (App : RawApplicative {a ⊔ b} F) where
open RawApplicative App
sequenceA : ∀ {A} → Sumᵣ (F A) → F (Sumᵣ A)
sequenceA (inj₂ a) = pure (inj₂ a)
sequenceA (inj₁ x) = inj₁ <$> x
mapA : ∀ {A B} → (A → F B) → Sumᵣ A → F (Sumᵣ B)
mapA f = sequenceA ∘ map₁ f
forA : ∀ {A B} → Sumᵣ A → (A → F B) → F (Sumᵣ B)
forA = flip mapA
module _ {M} (Mon : RawMonad {a ⊔ b} M) where
private App = RawMonad.rawIApplicative Mon
sequenceM : ∀ {A} → Sumᵣ (M A) → M (Sumᵣ A)
sequenceM = sequenceA App
mapM : ∀ {A B} → (A → M B) → Sumᵣ A → M (Sumᵣ B)
mapM = mapA App
forM : ∀ {A B} → Sumᵣ A → (A → M B) → M (Sumᵣ B)
forM = forA App
| {
"alphanum_fraction": 0.5365572827,
"avg_line_length": 24.4647887324,
"ext": "agda",
"hexsha": "f33b068aaf95dc66352481be5d3d0e86d3828b1a",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "omega12345/agda-mode",
"max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Sum/Categorical/Right.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "omega12345/agda-mode",
"max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Sum/Categorical/Right.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Sum/Categorical/Right.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 615,
"size": 1737
} |
{-# OPTIONS --without-K --safe #-}
module ProMonoid where
open import Level
open import Algebra.Core using (Op₂)
open import Algebra.Definitions using (Congruent₂)
open import Algebra.Structures
open import Algebra.Bundles
open import Relation.Binary
-- Pre-ordered monoids, additively written
record ProMonoid c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
infix 4 _≈_ _≼_
infixl 7 _∙_
field
Carrier : Set c
_≈_ : Rel Carrier ℓ₁ -- The underlying equality.
_≼_ : Rel Carrier ℓ₂ -- The relation.
isPreorder : IsPreorder _≈_ _≼_
_∙_ : Op₂ Carrier -- The monoid operations.
ε : Carrier
isMonoid : IsMonoid _≈_ _∙_ ε
∙-mon : Congruent₂ _≼_ _∙_
open IsPreorder isPreorder public
hiding (module Eq)
module Eq where
setoid : Setoid c ℓ₁
setoid = record { isEquivalence = isEquivalence }
open Setoid setoid public
monoid : Monoid c ℓ₁
monoid = record { isMonoid = isMonoid }
open IsMonoid isMonoid public -- using (∙-cong)
hiding (reflexive; refl)
| {
"alphanum_fraction": 0.6559849199,
"avg_line_length": 24.1136363636,
"ext": "agda",
"hexsha": "7b5dbc2af703be28c42397147164c11ecab20f7b",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2021-02-25T20:39:03.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-11-13T16:01:46.000Z",
"max_forks_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a",
"max_forks_repo_licenses": [
"Unlicense"
],
"max_forks_repo_name": "andreasabel/ipl",
"max_forks_repo_path": "src-cbpv/ProMonoid.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Unlicense"
],
"max_issues_repo_name": "andreasabel/ipl",
"max_issues_repo_path": "src-cbpv/ProMonoid.agda",
"max_line_length": 60,
"max_stars_count": 19,
"max_stars_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a",
"max_stars_repo_licenses": [
"Unlicense"
],
"max_stars_repo_name": "andreasabel/ipl",
"max_stars_repo_path": "src-cbpv/ProMonoid.agda",
"max_stars_repo_stars_event_max_datetime": "2021-04-27T19:10:49.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-05-16T08:08:51.000Z",
"num_tokens": 349,
"size": 1061
} |
-- Andreas, 2016-01-13, highlighting of import directives
-- {-# OPTIONS -v highlighting.names:100 -v scope.decl:70 -v tc.decl:10 #-}
module _ where
import Common.Product as Prod hiding (proj₁) -- proj₁ should be highlighted as field
open Prod using (_×_) -- _×_ should be highlighted as record type
module M (A : Set) = Prod
using (_,_) -- highlighted as constructor
renaming (proj₂ to snd) -- highlighted as projections
| {
"alphanum_fraction": 0.6143141153,
"avg_line_length": 38.6923076923,
"ext": "agda",
"hexsha": "90705bca7611678980fdde30f199cc217cdaa5e0",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/interaction/Issue1714.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/Issue1714.agda",
"max_line_length": 88,
"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/Issue1714.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": 116,
"size": 503
} |
{-# OPTIONS --cubical --safe #-}
module Cubical.Data.Everything where
import Cubical.Data.BinNat
import Cubical.Data.Bool
import Cubical.Data.Empty
import Cubical.Data.Equality
import Cubical.Data.Fin
import Cubical.Data.Nat
import Cubical.Data.Nat.Algebra
import Cubical.Data.Nat.Order
import Cubical.Data.NatMinusOne
import Cubical.Data.NatMinusTwo
import Cubical.Data.NatPlusOne
import Cubical.Data.Int
import Cubical.Data.Sum
import Cubical.Data.Prod
import Cubical.Data.Unit
import Cubical.Data.Sigma
import Cubical.Data.DiffInt
import Cubical.Data.Group
import Cubical.Data.HomotopyGroup
import Cubical.Data.List
import Cubical.Data.Graph
import Cubical.Data.InfNat
import Cubical.Data.Queue
| {
"alphanum_fraction": 0.8354792561,
"avg_line_length": 25.8888888889,
"ext": "agda",
"hexsha": "cb16a7eca93e62d2f0ce622188d0ed1140f3c17d",
"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/Data/Everything.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/Data/Everything.agda",
"max_line_length": 36,
"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/Data/Everything.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 183,
"size": 699
} |
{-# OPTIONS --warning=error --safe --without-K #-}
open import LogicalFormulae
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import Functions.Definition
open import Setoids.Setoids
open import Setoids.Subset
open import Graphs.Definition
module Graphs.InducedSubgraph {a b c : _} {V' : Set a} {V : Setoid {a} {b} V'} (G : Graph c V) where
open Graph G
inducedSubgraph : {d : _} {pred : V' → Set d} (sub : subset V pred) → Graph c (subsetSetoid V sub)
Graph._<->_ (inducedSubgraph sub) (x , _) (y , _) = x <-> y
Graph.noSelfRelation (inducedSubgraph sub) (x , _) x=x = noSelfRelation x x=x
Graph.symmetric (inducedSubgraph sub) {x , _} {y , _} x=y = symmetric x=y
Graph.wellDefined (inducedSubgraph sub) {x , _} {y , _} {z , _} {w , _} x=y z=w x-z = wellDefined x=y z=w x-z
| {
"alphanum_fraction": 0.6742138365,
"avg_line_length": 41.8421052632,
"ext": "agda",
"hexsha": "179f2c0ea84e846a389b4edb3f63846252ec8533",
"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": "Graphs/InducedSubgraph.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": "Graphs/InducedSubgraph.agda",
"max_line_length": 109,
"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": "Graphs/InducedSubgraph.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": 272,
"size": 795
} |
{-# OPTIONS --allow-unsolved-metas #-}
-- Andreas, 2016-12-19, issue #2344, reported by oinkium, shrunk by Ulf
-- The function Agda.TypeChecking.Telescope.permuteTel
-- used in the unifier was buggy.
-- {-# OPTIONS -v tc.meta:25 #-}
-- {-# OPTIONS -v tc.lhs:10 #-}
-- {-# OPTIONS -v tc.lhs.unify:100 #-}
-- {-# OPTIONS -v tc.cover:20 #-}
data Nat : Set where
zero : Nat
suc : Nat → Nat
data Fin : Nat → Set where
zero : ∀ n → Fin (suc n)
postulate
T : Nat → Set
mkT : ∀{l} → T l
toNat : ∀ m → Fin m → Nat
-- The underscore in the type signature is originally dependent on A,X,i
-- but then pruned to be dependent on A,X only.
-- The unifier had a problem with this.
toNat-injective : ∀ (A : Set) X i → T (toNat _ i) -- Yellow expected.
toNat-injective A X (zero n) = mkT
-- Should pass.
| {
"alphanum_fraction": 0.6240786241,
"avg_line_length": 26.2580645161,
"ext": "agda",
"hexsha": "20d7c937857be83965e20328d4daabe352b12cd7",
"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": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "pthariensflame/agda",
"max_forks_repo_path": "test/Succeed/Issue2344.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4",
"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": "pthariensflame/agda",
"max_issues_repo_path": "test/Succeed/Issue2344.agda",
"max_line_length": 72,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "pthariensflame/agda",
"max_stars_repo_path": "test/Succeed/Issue2344.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": 265,
"size": 814
} |
module Data.Boolean.NaryOperators where
open import Data.Boolean
import Data.Boolean.Operators
open Data.Boolean.Operators.Logic
open import Function.DomainRaise
open import Numeral.Natural
private variable n : ℕ
-- N-ary conjunction (AND).
-- Every term is true.
∧₊ : (n : ℕ) → (Bool →̂ Bool)(n)
∧₊(0) = 𝑇
∧₊(1) x = x
∧₊(𝐒(𝐒(n))) x = (x ∧_) ∘ (∧₊(𝐒(n)))
-- N-ary disjunction (OR).
-- There is a term which is true.
∨₊ : (n : ℕ) → (Bool →̂ Bool)(n)
∨₊(0) = 𝐹
∨₊(1) x = x
∨₊(𝐒(𝐒(n))) x = (x ∨_) ∘ (∨₊(𝐒(n)))
-- N-ary implication.
-- All left terms together imply the right-most term.
⟶₊ : (n : ℕ) → (Bool →̂ Bool)(n)
⟶₊(0) = 𝑇
⟶₊(1) x = x
⟶₊(𝐒(𝐒(n))) x = (x ⟶_) ∘ (⟶₊(𝐒(n)))
-- N-ary NAND.
-- Not every term is true.
-- There is a term which is false.
⊼₊ : (n : ℕ) → (Bool →̂ Bool)(n)
⊼₊(0) = 𝐹
⊼₊(1) x = ¬ x
⊼₊(𝐒(𝐒(n))) x = (x ⊼_) ∘ ((¬) ∘ (⊼₊(𝐒(n))))
-- N-ary NOR.
-- There are no terms that are true.
-- Every term is false.
⊽₊ : (n : ℕ) → (Bool →̂ Bool)(n)
⊽₊(0) = 𝐹
⊽₊(1) x = ¬ x
⊽₊(𝐒(𝐒(n))) x = (x ⊽_) ∘ ((¬) ∘ (⊽₊(𝐒(n))))
| {
"alphanum_fraction": 0.5052531041,
"avg_line_length": 22.2765957447,
"ext": "agda",
"hexsha": "299e6b66bb23e7aaf5f9e6b8d3eac0d49568a7bd",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Data/Boolean/NaryOperators.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Data/Boolean/NaryOperators.agda",
"max_line_length": 53,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Data/Boolean/NaryOperators.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": 543,
"size": 1047
} |
{-# OPTIONS --safe --warning=error --without-K #-}
open import LogicalFormulae
open import Decidable.Sets
module Decidable.Lemmas {a : _} {A : Set a} (dec : DecidableSet A) where
squash : {x y : A} → .(x ≡ y) → x ≡ y
squash {x} {y} x=y with dec x y
... | inl pr = pr
... | inr bad = exFalso (bad x=y)
| {
"alphanum_fraction": 0.6085526316,
"avg_line_length": 25.3333333333,
"ext": "agda",
"hexsha": "707a6ebc36d9d161a06724117d986f5a0bf970d5",
"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": "Decidable/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": "Decidable/Lemmas.agda",
"max_line_length": 72,
"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": "Decidable/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": 112,
"size": 304
} |
{-# OPTIONS --without-K #-}
open import Relation.Binary.PropositionalEquality
open import Data.Product
open import Data.Unit
open import Data.Empty
open import Function
-- some HoTT-inspired combinators
_&_ = cong
_⁻¹ = sym
_◾_ = trans
coe : {A B : Set} → A ≡ B → A → B
coe refl a = a
_⊗_ : ∀ {A B : Set}{f g : A → B}{a a'} → f ≡ g → a ≡ a' → f a ≡ g a'
refl ⊗ refl = refl
infix 6 _⁻¹
infixr 4 _◾_
infixl 9 _&_
infixl 8 _⊗_
-- Syntax
--------------------------------------------------------------------------------
infixr 4 _⇒_
infixr 4 _,_
data Ty : Set where
ι : Ty
_⇒_ : Ty → Ty → Ty
data Con : Set where
∙ : Con
_,_ : Con → Ty → Con
data _∈_ (A : Ty) : Con → Set where
vz : ∀ {Γ} → A ∈ (Γ , A)
vs : ∀ {B Γ} → A ∈ Γ → A ∈ (Γ , B)
data Tm Γ : Ty → Set where
var : ∀ {A} → A ∈ Γ → Tm Γ A
lam : ∀ {A B} → Tm (Γ , A) B → Tm Γ (A ⇒ B)
app : ∀ {A B} → Tm Γ (A ⇒ B) → Tm Γ A → Tm Γ B
-- Embedding
--------------------------------------------------------------------------------
-- Order-preserving embedding
data OPE : Con → Con → Set where
∙ : OPE ∙ ∙
drop : ∀ {A Γ Δ} → OPE Γ Δ → OPE (Γ , A) Δ
keep : ∀ {A Γ Δ} → OPE Γ Δ → OPE (Γ , A) (Δ , A)
-- OPE is a category
idₑ : ∀ {Γ} → OPE Γ Γ
idₑ {∙} = ∙
idₑ {Γ , A} = keep (idₑ {Γ})
wk : ∀ {A Γ} → OPE (Γ , A) Γ
wk = drop idₑ
_∘ₑ_ : ∀ {Γ Δ Σ} → OPE Δ Σ → OPE Γ Δ → OPE Γ Σ
σ ∘ₑ ∙ = σ
σ ∘ₑ drop δ = drop (σ ∘ₑ δ)
drop σ ∘ₑ keep δ = drop (σ ∘ₑ δ)
keep σ ∘ₑ keep δ = keep (σ ∘ₑ δ)
idlₑ : ∀ {Γ Δ}(σ : OPE Γ Δ) → idₑ ∘ₑ σ ≡ σ
idlₑ ∙ = refl
idlₑ (drop σ) = drop & idlₑ σ
idlₑ (keep σ) = keep & idlₑ σ
idrₑ : ∀ {Γ Δ}(σ : OPE Γ Δ) → σ ∘ₑ idₑ ≡ σ
idrₑ ∙ = refl
idrₑ (drop σ) = drop & idrₑ σ
idrₑ (keep σ) = keep & idrₑ σ
assₑ :
∀ {Γ Δ Σ Ξ}(σ : OPE Σ Ξ)(δ : OPE Δ Σ)(ν : OPE Γ Δ)
→ (σ ∘ₑ δ) ∘ₑ ν ≡ σ ∘ₑ (δ ∘ₑ ν)
assₑ σ δ ∙ = refl
assₑ σ δ (drop ν) = drop & assₑ σ δ ν
assₑ σ (drop δ) (keep ν) = drop & assₑ σ δ ν
assₑ (drop σ) (keep δ) (keep ν) = drop & assₑ σ δ ν
assₑ (keep σ) (keep δ) (keep ν) = keep & assₑ σ δ ν
∈ₑ : ∀ {A Γ Δ} → OPE Γ Δ → A ∈ Δ → A ∈ Γ
∈ₑ ∙ v = v
∈ₑ (drop σ) v = vs (∈ₑ σ v)
∈ₑ (keep σ) vz = vz
∈ₑ (keep σ) (vs v) = vs (∈ₑ σ v)
∈-idₑ : ∀ {A Γ}(v : A ∈ Γ) → ∈ₑ idₑ v ≡ v
∈-idₑ vz = refl
∈-idₑ (vs v) = vs & ∈-idₑ v
∈-∘ₑ : ∀ {A Γ Δ Σ}(σ : OPE Δ Σ)(δ : OPE Γ Δ)(v : A ∈ Σ) → ∈ₑ (σ ∘ₑ δ) v ≡ ∈ₑ δ (∈ₑ σ v)
∈-∘ₑ ∙ ∙ v = refl
∈-∘ₑ σ (drop δ) v = vs & ∈-∘ₑ σ δ v
∈-∘ₑ (drop σ) (keep δ) v = vs & ∈-∘ₑ σ δ v
∈-∘ₑ (keep σ) (keep δ) vz = refl
∈-∘ₑ (keep σ) (keep δ) (vs v) = vs & ∈-∘ₑ σ δ v
Tmₑ : ∀ {A Γ Δ} → OPE Γ Δ → Tm Δ A → Tm Γ A
Tmₑ σ (var v) = var (∈ₑ σ v)
Tmₑ σ (lam t) = lam (Tmₑ (keep σ) t)
Tmₑ σ (app f a) = app (Tmₑ σ f) (Tmₑ σ a)
Tm-idₑ : ∀ {A Γ}(t : Tm Γ A) → Tmₑ idₑ t ≡ t
Tm-idₑ (var v) = var & ∈-idₑ v
Tm-idₑ (lam t) = lam & Tm-idₑ t
Tm-idₑ (app f a) = app & Tm-idₑ f ⊗ Tm-idₑ a
Tm-∘ₑ : ∀ {A Γ Δ Σ}(σ : OPE Δ Σ)(δ : OPE Γ Δ)(t : Tm Σ A) → Tmₑ (σ ∘ₑ δ) t ≡ Tmₑ δ (Tmₑ σ t)
Tm-∘ₑ σ δ (var v) = var & ∈-∘ₑ σ δ v
Tm-∘ₑ σ δ (lam t) = lam & Tm-∘ₑ (keep σ) (keep δ) t
Tm-∘ₑ σ δ (app f a) = app & Tm-∘ₑ σ δ f ⊗ Tm-∘ₑ σ δ a
-- Theory of substitution & embedding
--------------------------------------------------------------------------------
infixr 6 _ₑ∘ₛ_ _ₛ∘ₑ_ _∘ₛ_
data Sub (Γ : Con) : Con → Set where
∙ : Sub Γ ∙
_,_ : ∀ {A : Ty}{Δ : Con} → Sub Γ Δ → Tm Γ A → Sub Γ (Δ , A)
_ₛ∘ₑ_ : ∀ {Γ Δ Σ} → Sub Δ Σ → OPE Γ Δ → Sub Γ Σ
∙ ₛ∘ₑ δ = ∙
(σ , t) ₛ∘ₑ δ = σ ₛ∘ₑ δ , Tmₑ δ t
_ₑ∘ₛ_ : ∀ {Γ Δ Σ} → OPE Δ Σ → Sub Γ Δ → Sub Γ Σ
∙ ₑ∘ₛ δ = δ
drop σ ₑ∘ₛ (δ , t) = σ ₑ∘ₛ δ
keep σ ₑ∘ₛ (δ , t) = σ ₑ∘ₛ δ , t
dropₛ : ∀ {A Γ Δ} → Sub Γ Δ → Sub (Γ , A) Δ
dropₛ σ = σ ₛ∘ₑ wk
keepₛ : ∀ {A Γ Δ} → Sub Γ Δ → Sub (Γ , A) (Δ , A)
keepₛ σ = dropₛ σ , var vz
⌜_⌝ᵒᵖᵉ : ∀ {Γ Δ} → OPE Γ Δ → Sub Γ Δ
⌜ ∙ ⌝ᵒᵖᵉ = ∙
⌜ drop σ ⌝ᵒᵖᵉ = dropₛ ⌜ σ ⌝ᵒᵖᵉ
⌜ keep σ ⌝ᵒᵖᵉ = keepₛ ⌜ σ ⌝ᵒᵖᵉ
∈ₛ : ∀ {A Γ Δ} → Sub Γ Δ → A ∈ Δ → Tm Γ A
∈ₛ (σ , t) vz = t
∈ₛ (σ , t)(vs v) = ∈ₛ σ v
Tmₛ : ∀ {A Γ Δ} → Sub Γ Δ → Tm Δ A → Tm Γ A
Tmₛ σ (var v) = ∈ₛ σ v
Tmₛ σ (lam t) = lam (Tmₛ (keepₛ σ) t)
Tmₛ σ (app f a) = app (Tmₛ σ f) (Tmₛ σ a)
idₛ : ∀ {Γ} → Sub Γ Γ
idₛ {∙} = ∙
idₛ {Γ , A} = (idₛ {Γ} ₛ∘ₑ drop idₑ) , var vz
_∘ₛ_ : ∀ {Γ Δ Σ} → Sub Δ Σ → Sub Γ Δ → Sub Γ Σ
∙ ∘ₛ δ = ∙
(σ , t) ∘ₛ δ = σ ∘ₛ δ , Tmₛ δ t
assₛₑₑ :
∀ {Γ Δ Σ Ξ}(σ : Sub Σ Ξ)(δ : OPE Δ Σ)(ν : OPE Γ Δ)
→ (σ ₛ∘ₑ δ) ₛ∘ₑ ν ≡ σ ₛ∘ₑ (δ ∘ₑ ν)
assₛₑₑ ∙ δ ν = refl
assₛₑₑ (σ , t) δ ν = _,_ & assₛₑₑ σ δ ν ⊗ (Tm-∘ₑ δ ν t ⁻¹)
assₑₛₑ :
∀ {Γ Δ Σ Ξ}(σ : OPE Σ Ξ)(δ : Sub Δ Σ)(ν : OPE Γ Δ)
→ (σ ₑ∘ₛ δ) ₛ∘ₑ ν ≡ σ ₑ∘ₛ (δ ₛ∘ₑ ν)
assₑₛₑ ∙ δ ν = refl
assₑₛₑ (drop σ) (δ , t) ν = assₑₛₑ σ δ ν
assₑₛₑ (keep σ) (δ , t) ν = (_, Tmₑ ν t) & assₑₛₑ σ δ ν
idlₑₛ : ∀ {Γ Δ}(σ : Sub Γ Δ) → idₑ ₑ∘ₛ σ ≡ σ
idlₑₛ ∙ = refl
idlₑₛ (σ , t) = (_, t) & idlₑₛ σ
idlₛₑ : ∀ {Γ Δ}(σ : OPE Γ Δ) → idₛ ₛ∘ₑ σ ≡ ⌜ σ ⌝ᵒᵖᵉ
idlₛₑ ∙ = refl
idlₛₑ (drop σ) =
((idₛ ₛ∘ₑ_) ∘ drop) & idrₑ σ ⁻¹
◾ assₛₑₑ idₛ σ wk ⁻¹
◾ dropₛ & idlₛₑ σ
idlₛₑ (keep σ) =
(_, var vz) &
(assₛₑₑ idₛ wk (keep σ)
◾ ((idₛ ₛ∘ₑ_) ∘ drop) & (idlₑ σ ◾ idrₑ σ ⁻¹)
◾ assₛₑₑ idₛ σ wk ⁻¹
◾ (_ₛ∘ₑ wk) & idlₛₑ σ )
idrₑₛ : ∀ {Γ Δ}(σ : OPE Γ Δ) → σ ₑ∘ₛ idₛ ≡ ⌜ σ ⌝ᵒᵖᵉ
idrₑₛ ∙ = refl
idrₑₛ (drop σ) = assₑₛₑ σ idₛ wk ⁻¹ ◾ dropₛ & idrₑₛ σ
idrₑₛ (keep σ) = (_, var vz) & (assₑₛₑ σ idₛ wk ⁻¹ ◾ (_ₛ∘ₑ wk) & idrₑₛ σ)
∈-ₑ∘ₛ : ∀ {A Γ Δ Σ}(σ : OPE Δ Σ)(δ : Sub Γ Δ)(v : A ∈ Σ) → ∈ₛ (σ ₑ∘ₛ δ) v ≡ ∈ₛ δ (∈ₑ σ v)
∈-ₑ∘ₛ ∙ δ v = refl
∈-ₑ∘ₛ (drop σ) (δ , t) v = ∈-ₑ∘ₛ σ δ v
∈-ₑ∘ₛ (keep σ) (δ , t) vz = refl
∈-ₑ∘ₛ (keep σ) (δ , t) (vs v) = ∈-ₑ∘ₛ σ δ v
Tm-ₑ∘ₛ : ∀ {A Γ Δ Σ}(σ : OPE Δ Σ)(δ : Sub Γ Δ)(t : Tm Σ A) → Tmₛ (σ ₑ∘ₛ δ) t ≡ Tmₛ δ (Tmₑ σ t)
Tm-ₑ∘ₛ σ δ (var v) = ∈-ₑ∘ₛ σ δ v
Tm-ₑ∘ₛ σ δ (lam t) =
lam & ((λ x → Tmₛ (x , var vz) t) & assₑₛₑ σ δ wk ◾ Tm-ₑ∘ₛ (keep σ) (keepₛ δ) t)
Tm-ₑ∘ₛ σ δ (app f a) = app & Tm-ₑ∘ₛ σ δ f ⊗ Tm-ₑ∘ₛ σ δ a
∈-ₛ∘ₑ : ∀ {A Γ Δ Σ}(σ : Sub Δ Σ)(δ : OPE Γ Δ)(v : A ∈ Σ) → ∈ₛ (σ ₛ∘ₑ δ) v ≡ Tmₑ δ (∈ₛ σ v)
∈-ₛ∘ₑ (σ , _) δ vz = refl
∈-ₛ∘ₑ (σ , _) δ (vs v) = ∈-ₛ∘ₑ σ δ v
Tm-ₛ∘ₑ : ∀ {A Γ Δ Σ}(σ : Sub Δ Σ)(δ : OPE Γ Δ)(t : Tm Σ A) → Tmₛ (σ ₛ∘ₑ δ) t ≡ Tmₑ δ (Tmₛ σ t)
Tm-ₛ∘ₑ σ δ (var v) = ∈-ₛ∘ₑ σ δ v
Tm-ₛ∘ₑ σ δ (lam t) =
lam &
((λ x → Tmₛ (x , var vz) t) &
(assₛₑₑ σ δ wk
◾ (σ ₛ∘ₑ_) & (drop & (idrₑ δ ◾ idlₑ δ ⁻¹))
◾ assₛₑₑ σ wk (keep δ) ⁻¹)
◾ Tm-ₛ∘ₑ (keepₛ σ) (keep δ) t)
Tm-ₛ∘ₑ σ δ (app f a) = app & Tm-ₛ∘ₑ σ δ f ⊗ Tm-ₛ∘ₑ σ δ a
assₛₑₛ :
∀ {Γ Δ Σ Ξ}(σ : Sub Σ Ξ)(δ : OPE Δ Σ)(ν : Sub Γ Δ)
→ (σ ₛ∘ₑ δ) ∘ₛ ν ≡ σ ∘ₛ (δ ₑ∘ₛ ν)
assₛₑₛ ∙ δ ν = refl
assₛₑₛ (σ , t) δ ν = _,_ & assₛₑₛ σ δ ν ⊗ (Tm-ₑ∘ₛ δ ν t ⁻¹)
assₛₛₑ :
∀ {Γ Δ Σ Ξ}(σ : Sub Σ Ξ)(δ : Sub Δ Σ)(ν : OPE Γ Δ)
→ (σ ∘ₛ δ) ₛ∘ₑ ν ≡ σ ∘ₛ (δ ₛ∘ₑ ν)
assₛₛₑ ∙ δ ν = refl
assₛₛₑ (σ , t) δ ν = _,_ & assₛₛₑ σ δ ν ⊗ (Tm-ₛ∘ₑ δ ν t ⁻¹)
∈-idₛ : ∀ {A Γ}(v : A ∈ Γ) → ∈ₛ idₛ v ≡ var v
∈-idₛ vz = refl
∈-idₛ (vs v) = ∈-ₛ∘ₑ idₛ wk v ◾ Tmₑ wk & ∈-idₛ v ◾ (var ∘ vs) & ∈-idₑ v
∈-∘ₛ : ∀ {A Γ Δ Σ}(σ : Sub Δ Σ)(δ : Sub Γ Δ)(v : A ∈ Σ) → ∈ₛ (σ ∘ₛ δ) v ≡ Tmₛ δ (∈ₛ σ v)
∈-∘ₛ (σ , _) δ vz = refl
∈-∘ₛ (σ , _) δ (vs v) = ∈-∘ₛ σ δ v
Tm-idₛ : ∀ {A Γ}(t : Tm Γ A) → Tmₛ idₛ t ≡ t
Tm-idₛ (var v) = ∈-idₛ v
Tm-idₛ (lam t) = lam & Tm-idₛ t
Tm-idₛ (app f a) = app & Tm-idₛ f ⊗ Tm-idₛ a
Tm-∘ₛ : ∀ {A Γ Δ Σ}(σ : Sub Δ Σ)(δ : Sub Γ Δ)(t : Tm Σ A) → Tmₛ (σ ∘ₛ δ) t ≡ Tmₛ δ (Tmₛ σ t)
Tm-∘ₛ σ δ (var v) = ∈-∘ₛ σ δ v
Tm-∘ₛ σ δ (lam t) =
lam &
((λ x → Tmₛ (x , var vz) t) &
(assₛₛₑ σ δ wk
◾ (σ ∘ₛ_) & (idlₑₛ (dropₛ δ) ⁻¹) ◾ assₛₑₛ σ wk (keepₛ δ) ⁻¹)
◾ Tm-∘ₛ (keepₛ σ) (keepₛ δ) t)
Tm-∘ₛ σ δ (app f a) = app & Tm-∘ₛ σ δ f ⊗ Tm-∘ₛ σ δ a
idrₛ : ∀ {Γ Δ}(σ : Sub Γ Δ) → σ ∘ₛ idₛ ≡ σ
idrₛ ∙ = refl
idrₛ (σ , t) = _,_ & idrₛ σ ⊗ Tm-idₛ t
idlₛ : ∀ {Γ Δ}(σ : Sub Γ Δ) → idₛ ∘ₛ σ ≡ σ
idlₛ ∙ = refl
idlₛ (σ , t) = (_, t) & (assₛₑₛ idₛ wk (σ , t) ◾ (idₛ ∘ₛ_) & idlₑₛ σ ◾ idlₛ σ)
-- Reduction
--------------------------------------------------------------------------------
data _~>_ {Γ} : ∀ {A} → Tm Γ A → Tm Γ A → Set where
β : ∀ {A B}(t : Tm (Γ , A) B) t' → app (lam t) t' ~> Tmₛ (idₛ , t') t
lam : ∀ {A B}{t t' : Tm (Γ , A) B} → t ~> t' → lam t ~> lam t'
app₁ : ∀ {A B}{f}{f' : Tm Γ (A ⇒ B)}{a} → f ~> f' → app f a ~> app f' a
app₂ : ∀ {A B}{f : Tm Γ (A ⇒ B)} {a a'} → a ~> a' → app f a ~> app f a'
infix 3 _~>_
~>ₛ : ∀ {Γ Δ A}{t t' : Tm Γ A}(σ : Sub Δ Γ) → t ~> t' → Tmₛ σ t ~> Tmₛ σ t'
~>ₛ σ (β t t') =
coe ((app (lam (Tmₛ (keepₛ σ) t)) (Tmₛ σ t') ~>_) &
(Tm-∘ₛ (keepₛ σ) (idₛ , Tmₛ σ t') t ⁻¹
◾ (λ x → Tmₛ (x , Tmₛ σ t') t) &
(assₛₑₛ σ wk (idₛ , Tmₛ σ t')
◾ ((σ ∘ₛ_) & idlₑₛ idₛ ◾ idrₛ σ) ◾ idlₛ σ ⁻¹)
◾ Tm-∘ₛ (idₛ , t') σ t))
(β (Tmₛ (keepₛ σ) t) (Tmₛ σ t'))
~>ₛ σ (lam step) = lam (~>ₛ (keepₛ σ) step)
~>ₛ σ (app₁ step) = app₁ (~>ₛ σ step)
~>ₛ σ (app₂ step) = app₂ (~>ₛ σ step)
~>ₑ : ∀ {Γ Δ A}{t t' : Tm Γ A}(σ : OPE Δ Γ) → t ~> t' → Tmₑ σ t ~> Tmₑ σ t'
~>ₑ σ (β t t') =
coe ((app (lam (Tmₑ (keep σ) t)) (Tmₑ σ t') ~>_)
& (Tm-ₑ∘ₛ (keep σ) (idₛ , Tmₑ σ t') t ⁻¹
◾ (λ x → Tmₛ (x , Tmₑ σ t') t) & (idrₑₛ σ ◾ idlₛₑ σ ⁻¹)
◾ Tm-ₛ∘ₑ (idₛ , t') σ t))
(β (Tmₑ (keep σ) t) (Tmₑ σ t'))
~>ₑ σ (lam step) = lam (~>ₑ (keep σ) step)
~>ₑ σ (app₁ step) = app₁ (~>ₑ σ step)
~>ₑ σ (app₂ step) = app₂ (~>ₑ σ step)
Tmₑ~> :
∀ {Γ Δ A}{t : Tm Γ A}{σ : OPE Δ Γ}{t'}
→ Tmₑ σ t ~> t' → ∃ λ t'' → (t ~> t'') × (Tmₑ σ t'' ≡ t')
Tmₑ~> {t = var x} ()
Tmₑ~> {t = lam t} (lam step) with Tmₑ~> step
... | t'' , (p , refl) = lam t'' , lam p , refl
Tmₑ~> {t = app (var v) a} (app₁ ())
Tmₑ~> {t = app (var v) a} (app₂ step) with Tmₑ~> step
... | t'' , (p , refl) = app (var v) t'' , app₂ p , refl
Tmₑ~> {t = app (lam f) a} {σ} (β _ _) =
Tmₛ (idₛ , a) f , β _ _ ,
Tm-ₛ∘ₑ (idₛ , a) σ f ⁻¹
◾ (λ x → Tmₛ (x , Tmₑ σ a) f) & (idlₛₑ σ ◾ idrₑₛ σ ⁻¹)
◾ Tm-ₑ∘ₛ (keep σ) (idₛ , Tmₑ σ a) f
Tmₑ~> {t = app (lam f) a} (app₁ (lam step)) with Tmₑ~> step
... | t'' , (p , refl) = app (lam t'') a , app₁ (lam p) , refl
Tmₑ~> {t = app (lam f) a} (app₂ step) with Tmₑ~> step
... | t'' , (p , refl) = app (lam f) t'' , app₂ p , refl
Tmₑ~> {t = app (app f a) a'} (app₁ step) with Tmₑ~> step
... | t'' , (p , refl) = app t'' a' , app₁ p , refl
Tmₑ~> {t = app (app f a) a''} (app₂ step) with Tmₑ~> step
... | t'' , (p , refl) = app (app f a) t'' , app₂ p , refl
-- Strong normalization/neutrality definition
--------------------------------------------------------------------------------
data SN {Γ A} (t : Tm Γ A) : Set where
sn : (∀ {t'} → t ~> t' → SN t') → SN t
SNₑ→ : ∀ {Γ Δ A}{t : Tm Γ A}(σ : OPE Δ Γ) → SN t → SN (Tmₑ σ t)
SNₑ→ σ (sn s) = sn λ {t'} step →
let (t'' , (p , q)) = Tmₑ~> step in coe (SN & q) (SNₑ→ σ (s p))
SNₑ← : ∀ {Γ Δ A}{t : Tm Γ A}(σ : OPE Δ Γ) → SN (Tmₑ σ t) → SN t
SNₑ← σ (sn s) = sn λ step → SNₑ← σ (s (~>ₑ σ step))
SN-app₁ : ∀ {Γ A B}{f : Tm Γ (A ⇒ B)}{a} → SN (app f a) → SN f
SN-app₁ (sn s) = sn λ f~>f' → SN-app₁ (s (app₁ f~>f'))
neu : ∀ {Γ A} → Tm Γ A → Set
neu (lam _) = ⊥
neu _ = ⊤
neuₑ : ∀ {Γ Δ A}(σ : OPE Δ Γ)(t : Tm Γ A) → neu t → neu (Tmₑ σ t)
neuₑ σ (lam t) nt = nt
neuₑ σ (var v) nt = tt
neuₑ σ (app f a) nt = tt
-- The actual proof, by Kripke logical predicate
--------------------------------------------------------------------------------
Tmᴾ : ∀ {Γ A} → Tm Γ A → Set
Tmᴾ {Γ}{ι} t = SN t
Tmᴾ {Γ}{A ⇒ B} t = ∀ {Δ}(σ : OPE Δ Γ){a} → Tmᴾ a → Tmᴾ (app (Tmₑ σ t) a)
data Subᴾ {Γ} : ∀ {Δ} → Sub Γ Δ → Set where
∙ : Subᴾ ∙
_,_ : ∀ {A Δ}{σ : Sub Γ Δ}{t : Tm Γ A}(σᴾ : Subᴾ σ)(tᴾ : Tmᴾ t) → Subᴾ (σ , t)
Tmᴾₑ : ∀ {Γ Δ A}{t : Tm Γ A}(σ : OPE Δ Γ) → Tmᴾ t → Tmᴾ (Tmₑ σ t)
Tmᴾₑ {A = ι} σ tᴾ = SNₑ→ σ tᴾ
Tmᴾₑ {A = A ⇒ B}{t} σ tᴾ δ aᴾ rewrite Tm-∘ₑ σ δ t ⁻¹ = tᴾ (σ ∘ₑ δ) aᴾ
Subᴾₑ : ∀ {Γ Δ Σ}{σ : Sub Δ Σ}(δ : OPE Γ Δ) → Subᴾ σ → Subᴾ (σ ₛ∘ₑ δ)
Subᴾₑ σ ∙ = ∙
Subᴾₑ σ (δ , tᴾ) = Subᴾₑ σ δ , Tmᴾₑ σ tᴾ
~>ᴾ : ∀ {Γ A}{t t' : Tm Γ A} → t ~> t' → Tmᴾ t → Tmᴾ t'
~>ᴾ {A = ι} t~>t' (sn tˢⁿ) = tˢⁿ t~>t'
~>ᴾ {A = A ⇒ B} t~>t' tᴾ = λ σ aᴾ → ~>ᴾ (app₁ (~>ₑ σ t~>t')) (tᴾ σ aᴾ)
mutual
-- quote
qᴾ : ∀ {Γ A}{t : Tm Γ A} → Tmᴾ t → SN t
qᴾ {A = ι} tᴾ = tᴾ
qᴾ {A = A ⇒ B} tᴾ = SNₑ← wk $ SN-app₁ (qᴾ $ tᴾ wk (uᴾ (var vz) (λ ())))
-- unquote
uᴾ : ∀ {Γ A}(t : Tm Γ A){nt : neu t} → (∀ {t'} → t ~> t' → Tmᴾ t') → Tmᴾ t
uᴾ {Γ} {A = ι} t f = sn f
uᴾ {Γ} {A ⇒ B} t {nt} f {Δ} σ {a} aᴾ =
uᴾ (app (Tmₑ σ t) a) (go (Tmₑ σ t) (neuₑ σ t nt) f' a aᴾ (qᴾ aᴾ))
where
f' : ∀ {t'} → Tmₑ σ t ~> t' → Tmᴾ t'
f' step δ aᴾ with Tmₑ~> step
... | t'' , step' , refl rewrite Tm-∘ₑ σ δ t'' ⁻¹ = f step' (σ ∘ₑ δ) aᴾ
go :
∀ {Γ A B}(t : Tm Γ (A ⇒ B)) → neu t → (∀ {t'} → t ~> t' → Tmᴾ t')
→ ∀ a → Tmᴾ a → SN a → ∀ {t'} → app t a ~> t' → Tmᴾ t'
go _ () _ _ _ _ (β _ _)
go t nt f a aᴾ sna (app₁ {f' = f'} step) =
coe ((λ x → Tmᴾ (app x a)) & Tm-idₑ f') (f step idₑ aᴾ)
go t nt f a aᴾ (sn aˢⁿ) (app₂ {a' = a'} step) =
uᴾ (app t a') (go t nt f a' (~>ᴾ step aᴾ) (aˢⁿ step))
fundThm-∈ : ∀ {Γ A}(v : A ∈ Γ) → ∀ {Δ}{σ : Sub Δ Γ} → Subᴾ σ → Tmᴾ (∈ₛ σ v)
fundThm-∈ vz (σᴾ , tᴾ) = tᴾ
fundThm-∈ (vs v) (σᴾ , tᴾ) = fundThm-∈ v σᴾ
fundThm-lam :
∀ {Γ A B}
(t : Tm (Γ , A) B)
→ SN t
→ (∀ {a} → Tmᴾ a → Tmᴾ (Tmₛ (idₛ , a) t))
→ ∀ a → SN a → Tmᴾ a → Tmᴾ (app (lam t) a)
fundThm-lam {Γ} t (sn tˢⁿ) hyp a (sn aˢⁿ) aᴾ = uᴾ (app (lam t) a)
λ {(β _ _) → hyp aᴾ;
(app₁ (lam {t' = t'} t~>t')) →
fundThm-lam t' (tˢⁿ t~>t') (λ aᴾ → ~>ᴾ (~>ₛ _ t~>t') (hyp aᴾ)) a (sn aˢⁿ) aᴾ;
(app₂ a~>a') →
fundThm-lam t (sn tˢⁿ) hyp _ (aˢⁿ a~>a') (~>ᴾ a~>a' aᴾ)}
fundThm : ∀ {Γ A}(t : Tm Γ A) → ∀ {Δ}{σ : Sub Δ Γ} → Subᴾ σ → Tmᴾ (Tmₛ σ t)
fundThm (var v) σᴾ = fundThm-∈ v σᴾ
fundThm (lam {A} t) {σ = σ} σᴾ δ {a} aᴾ
rewrite Tm-ₛ∘ₑ (keepₛ σ) (keep δ) t ⁻¹ | assₛₑₑ σ (wk {A}) (keep δ) | idlₑ δ
= fundThm-lam
(Tmₛ (σ ₛ∘ₑ drop δ , var vz) t)
(qᴾ (fundThm t (Subᴾₑ (drop δ) σᴾ , uᴾ (var vz) (λ ()))))
(λ aᴾ → coe (Tmᴾ & sub-sub-lem) (fundThm t (Subᴾₑ δ σᴾ , aᴾ)))
a (qᴾ aᴾ) aᴾ
where
sub-sub-lem : ∀ {a} → Tmₛ (σ ₛ∘ₑ δ , a) t ≡ Tmₛ (idₛ , a) (Tmₛ (σ ₛ∘ₑ drop δ , var vz) t)
sub-sub-lem {a} =
(λ x → Tmₛ (x , a) t) &
(idrₛ (σ ₛ∘ₑ δ) ⁻¹ ◾ assₛₑₛ σ δ idₛ ◾ assₛₑₛ σ (drop δ) (idₛ , a) ⁻¹)
◾ Tm-∘ₛ (σ ₛ∘ₑ drop δ , var vz) (idₛ , a) t
fundThm (app f a) {σ = σ} σᴾ
rewrite Tm-idₑ (Tmₛ σ f) ⁻¹
= fundThm f σᴾ idₑ (fundThm a σᴾ)
idₛᴾ : ∀ {Γ} → Subᴾ (idₛ {Γ})
idₛᴾ {∙} = ∙
idₛᴾ {Γ , A} = Subᴾₑ wk idₛᴾ , uᴾ (var vz) (λ ())
strongNorm : ∀ {Γ A}(t : Tm Γ A) → SN t
strongNorm t = qᴾ (coe (Tmᴾ & Tm-idₛ t) (fundThm t idₛᴾ))
| {
"alphanum_fraction": 0.4268715578,
"avg_line_length": 32.9753363229,
"ext": "agda",
"hexsha": "fa6d8ab5b2b3c190d9602b347b789be9229bdc0b",
"lang": "Agda",
"max_forks_count": 304,
"max_forks_repo_forks_event_max_datetime": "2022-03-28T11:35:02.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-07-16T18:24:59.000Z",
"max_forks_repo_head_hexsha": "5468837f55cbea38d5c5a163e1ea5d48edb92bcc",
"max_forks_repo_licenses": [
"CC-BY-4.0"
],
"max_forks_repo_name": "andorp/plfa.github.io",
"max_forks_repo_path": "extra/KovacsSTLCnorm.agda",
"max_issues_count": 323,
"max_issues_repo_head_hexsha": "5468837f55cbea38d5c5a163e1ea5d48edb92bcc",
"max_issues_repo_issues_event_max_datetime": "2022-03-30T07:42:57.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-07-05T22:34:34.000Z",
"max_issues_repo_licenses": [
"CC-BY-4.0"
],
"max_issues_repo_name": "andorp/plfa.github.io",
"max_issues_repo_path": "extra/KovacsSTLCnorm.agda",
"max_line_length": 94,
"max_stars_count": 1003,
"max_stars_repo_head_hexsha": "5468837f55cbea38d5c5a163e1ea5d48edb92bcc",
"max_stars_repo_licenses": [
"CC-BY-4.0"
],
"max_stars_repo_name": "andorp/plfa.github.io",
"max_stars_repo_path": "extra/KovacsSTLCnorm.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-27T07:03:28.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-07-05T18:15:14.000Z",
"num_tokens": 8956,
"size": 14707
} |
{-# OPTIONS --without-K --safe #-}
-- define a less-than-great equivalence on natural transformations
module Categories.NaturalTransformation.Equivalence where
open import Level
open import Relation.Binary using (Rel; IsEquivalence; Setoid)
open import Categories.Category
open import Categories.Functor
open import Categories.NaturalTransformation.Core
private
variable
o ℓ e o′ ℓ′ e′ : Level
C D E : Category o ℓ e
-- This ad hoc equivalence for NaturalTransformation should really be 'modification'
-- (yep, tricategories!). What is below is only part of the definition of a 'modification'. TODO
infix 4 _≃_
_≃_ : ∀ {F G : Functor C D} → Rel (NaturalTransformation F G) _
_≃_ {D = D} X Y = ∀ {x} → D [ NaturalTransformation.η X x ≈ NaturalTransformation.η Y x ]
≃-isEquivalence : ∀ {F G : Functor C D} → IsEquivalence (_≃_ {F = F} {G})
≃-isEquivalence {D = D} {F} {G} = record
{ refl = refl
; sym = λ f → sym f -- need to eta-expand to get things to line up properly
; trans = λ f g → trans f g
}
where open Category.Equiv D
≃-setoid : ∀ (F G : Functor C D) → Setoid _ _
≃-setoid F G = record
{ Carrier = NaturalTransformation F G
; _≈_ = _≃_
; isEquivalence = ≃-isEquivalence
}
| {
"alphanum_fraction": 0.6771589992,
"avg_line_length": 31.7692307692,
"ext": "agda",
"hexsha": "fd27ebe9c4b64b87f501a5295cd3112f10c91254",
"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/NaturalTransformation/Equivalence.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/NaturalTransformation/Equivalence.agda",
"max_line_length": 98,
"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/NaturalTransformation/Equivalence.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": 377,
"size": 1239
} |
{-
Computable stuff constructed from the Combinatorics of Finite Sets
-}
{-# OPTIONS --safe #-}
module Cubical.Experiments.Combinatorics where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Data.Nat
open import Cubical.Data.Sum
open import Cubical.Data.Sigma
open import Cubical.Data.Fin
open import Cubical.Data.FinSet
open import Cubical.Data.FinSet.Constructors
open import Cubical.Functions.Embedding
open import Cubical.Functions.Surjection
-- some computable functions
-- this should be addtion
card+ : ℕ → ℕ → ℕ
card+ m n = card (Fin m ⊎ Fin n , isFinSet⊎ (Fin m , isFinSetFin) (Fin n , isFinSetFin))
-- this should be multiplication
card× : ℕ → ℕ → ℕ
card× m n = card (Fin m × Fin n , isFinSet× (Fin m , isFinSetFin) (Fin n , isFinSetFin))
-- this should be exponential
card→ : ℕ → ℕ → ℕ
card→ m n = card ((Fin m → Fin n) , isFinSet→ (Fin m , isFinSetFin) (Fin n , isFinSetFin))
-- this should be factorial or zero
card≃ : ℕ → ℕ → ℕ
card≃ m n = card ((Fin m ≃ Fin n) , isFinSet≃ (Fin m , isFinSetFin) (Fin n , isFinSetFin))
-- this should be binomial coeffient
card↪ : ℕ → ℕ → ℕ
card↪ m n = card ((Fin m ↪ Fin n) , isFinSet↪ (Fin m , isFinSetFin) (Fin n , isFinSetFin))
-- this should be something that I don't know the name
card↠ : ℕ → ℕ → ℕ
card↠ m n = card ((Fin m ↠ Fin n) , isFinSet↠ (Fin m , isFinSetFin) (Fin n , isFinSetFin))
-- explicit numbers
s2 : card≃ 2 2 ≡ 2
s2 = refl
s3 : card≃ 3 3 ≡ 6
s3 = refl
c3,2 : card↪ 2 3 ≡ 6
c3,2 = refl
| {
"alphanum_fraction": 0.6846254928,
"avg_line_length": 25.3666666667,
"ext": "agda",
"hexsha": "2c45bda19e73160049311386a09fa75fe2d53820",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Seanpm2001-web/cubical",
"max_forks_repo_path": "Cubical/Experiments/Combinatorics.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Seanpm2001-web/cubical",
"max_issues_repo_path": "Cubical/Experiments/Combinatorics.agda",
"max_line_length": 90,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "9acdecfa6437ec455568be4e5ff04849cc2bc13b",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "FernandoLarrain/cubical",
"max_stars_repo_path": "Cubical/Experiments/Combinatorics.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-05T00:28:39.000Z",
"max_stars_repo_stars_event_min_datetime": "2022-03-05T00:28:39.000Z",
"num_tokens": 530,
"size": 1522
} |
module FFI.Data.Maybe where
open import Agda.Builtin.Equality using (_≡_; refl)
{-# FOREIGN GHC import qualified Data.Maybe #-}
data Maybe (A : Set) : Set where
nothing : Maybe A
just : A → Maybe A
{-# COMPILE GHC Maybe = data Data.Maybe.Maybe (Data.Maybe.Nothing|Data.Maybe.Just) #-}
just-inv : ∀ {A} {x y : A} → (just x ≡ just y) → (x ≡ y)
just-inv refl = refl
| {
"alphanum_fraction": 0.6505376344,
"avg_line_length": 24.8,
"ext": "agda",
"hexsha": "58fd14861092bce37bc6823ada5a24db427d7b9b",
"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": "362428f8b4b6f5c9d43f4daf55bcf7873f536c3f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "XanderYZZ/luau",
"max_forks_repo_path": "prototyping/FFI/Data/Maybe.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "362428f8b4b6f5c9d43f4daf55bcf7873f536c3f",
"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": "XanderYZZ/luau",
"max_issues_repo_path": "prototyping/FFI/Data/Maybe.agda",
"max_line_length": 86,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "72d8d443431875607fd457a13fe36ea62804d327",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "TheGreatSageEqualToHeaven/luau",
"max_stars_repo_path": "prototyping/FFI/Data/Maybe.agda",
"max_stars_repo_stars_event_max_datetime": "2021-12-05T21:53:03.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-12-05T21:53:03.000Z",
"num_tokens": 112,
"size": 372
} |
module JVM.Syntax where
open import JVM.Syntax.Instructions public
| {
"alphanum_fraction": 0.8382352941,
"avg_line_length": 17,
"ext": "agda",
"hexsha": "1581f3b0976cd555fa60f7450379b5be66098a56",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-12-28T17:37:15.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-12-28T17:37:15.000Z",
"max_forks_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "ajrouvoet/jvm.agda",
"max_forks_repo_path": "src/JVM/Syntax.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a",
"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": "ajrouvoet/jvm.agda",
"max_issues_repo_path": "src/JVM/Syntax.agda",
"max_line_length": 42,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "ajrouvoet/jvm.agda",
"max_stars_repo_path": "src/JVM/Syntax.agda",
"max_stars_repo_stars_event_max_datetime": "2021-02-28T21:49:08.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-07T14:07:17.000Z",
"num_tokens": 13,
"size": 68
} |
module DotPatternTermination where
data Nat : Set where
zero : Nat
suc : Nat -> Nat
-- A simple example.
module Test1 where
data D : Nat -> Set where
cz : D zero
c1 : forall {n} -> D n -> D (suc n)
c2 : forall {n} -> D n -> D n
-- To see that this is terminating the termination checker has to look at the
-- natural number index, which is in a dot pattern.
f : forall {n} -> D n -> Nat
f cz = zero
f (c1 d) = f (c2 d)
f (c2 d) = f d
-- There was a bug with dot patterns having the wrong context which manifested
-- itself in the following example.
module Test2 where
data P : Nat -> Nat -> Set where
c : forall {d r} -> P d r -> P (suc d) r
c' : forall {d r} -> P d r -> P d r
g : forall {d r} -> P d r -> Nat
g .{suc d} {r} (c {d} .{r} x) = g (c' x)
g (c' _) = zero
-- Another bug where the dot patterns weren't substituted properly.
module Test3 where
data Parser : Nat -> Set where
alt : (d : Nat) -> Nat -> Parser d -> Parser (suc d)
! : (d : Nat) -> Parser (suc d)
pp : (d : Nat) -> Parser d
parse₀ : (d : Nat) -> Parser d -> Nat
parse₀ .(suc d) (alt d zero p) = parse₀ d p
parse₀ .(suc d) (alt d _ p) = parse₀ d p
parse₀ ._ (! d) = parse₀ d (pp d)
parse₀ ._ (pp d) = zero
| {
"alphanum_fraction": 0.5522273425,
"avg_line_length": 28.3043478261,
"ext": "agda",
"hexsha": "f63b6853e2166e3757ab16aed5c302328b714f7a",
"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/DotPatternTermination.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/DotPatternTermination.agda",
"max_line_length": 79,
"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/DotPatternTermination.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 456,
"size": 1302
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Characters
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Char where
------------------------------------------------------------------------
-- Re-export base definitions and decidability of equality
open import Data.Char.Base public
open import Data.Char.Properties using (_≟_; _==_) public
| {
"alphanum_fraction": 0.3953974895,
"avg_line_length": 29.875,
"ext": "agda",
"hexsha": "64208d29f79510bb7c5149f43d04c8a581bf5937",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "omega12345/agda-mode",
"max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Char.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "omega12345/agda-mode",
"max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Char.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Char.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 63,
"size": 478
} |
-- All 256 ASCII characters
module LineEndings.LexASCII where
{- In Block comment:
Control characters 0-31
Rest of 7-bit ASCII
!"#$%&'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
`abcdefghijklmnopqrstuvwxyz{|}~
8-Bit ASCII
¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿
ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞß
àáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ
-}
-- In line comments
--
--
--
-- !"#$%&'()*+,-./0123456789:;<=>?
-- @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
-- `abcdefghijklmnopqrstuvwxyz{|}~
--
-- Note: Agda translates the following character (decimal: 133 xd: x85)
-- into a new line, see function convertLineEndings.
--
--
--
--
--
-- ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿
-- ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞß
-- àáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ
-- -}
| {
"alphanum_fraction": 0.5454545455,
"avg_line_length": 15.3620689655,
"ext": "agda",
"hexsha": "d1893206262ff42db0b49dd1af9b6ebba3dc227f",
"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/LineEndings/LexASCII.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/LineEndings/LexASCII.agda",
"max_line_length": 71,
"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/LineEndings/LexASCII.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": 593,
"size": 891
} |
module Esterel.Context where
open import Esterel.Lang
open import Esterel.Environment
using (Env)
open import Esterel.Variable.Signal as Signal
using (Signal ; _ₛ) renaming (_≟ₛₜ_ to _≟ₛₜₛ_)
open import Esterel.Variable.Shared as SharedVar
using (SharedVar ; _ₛₕ) renaming (_≟ₛₜ_ to _≟ₛₜₛₕ_)
open import Esterel.Variable.Sequential as SeqVar
using (SeqVar ; _ᵥ)
open import Data.List
using (List ; _∷_ ; [])
infix 7 _⟦_⟧e
infix 7 _⟦_⟧c
infix 4 _≐_⟦_⟧e
infix 4 _≐_⟦_⟧c
data EvaluationContext1 : Set where
epar₁ : (q : Term) → EvaluationContext1
epar₂ : (p : Term) → EvaluationContext1
eseq : (q : Term) → EvaluationContext1
eloopˢ : (q : Term) → EvaluationContext1
esuspend : (S : Signal) → EvaluationContext1
etrap : EvaluationContext1
EvaluationContext : Set
EvaluationContext = List EvaluationContext1
_⟦_⟧e : EvaluationContext → Term → Term
[] ⟦ p ⟧e = p
(epar₁ q ∷ E) ⟦ p ⟧e = (E ⟦ p ⟧e) ∥ q
(epar₂ p ∷ E) ⟦ q ⟧e = p ∥ (E ⟦ q ⟧e)
(eseq q ∷ E) ⟦ p ⟧e = (E ⟦ p ⟧e) >> q
(eloopˢ q ∷ E) ⟦ p ⟧e = loopˢ (E ⟦ p ⟧e) q
(esuspend S ∷ E) ⟦ p ⟧e = suspend (E ⟦ p ⟧e) S
(etrap ∷ E) ⟦ p ⟧e = trap (E ⟦ p ⟧e)
data _≐_⟦_⟧e : Term → EvaluationContext → Term → Set where
dehole : ∀{p} → (p ≐ [] ⟦ p ⟧e)
depar₁ : ∀{p r q E} → (p ≐ E ⟦ r ⟧e) → (p ∥ q ≐ (epar₁ q ∷ E) ⟦ r ⟧e)
depar₂ : ∀{p r q E} → (q ≐ E ⟦ r ⟧e) → (p ∥ q ≐ (epar₂ p ∷ E) ⟦ r ⟧e)
deseq : ∀{p r q E} → (p ≐ E ⟦ r ⟧e) → (p >> q ≐ (eseq q ∷ E) ⟦ r ⟧e)
deloopˢ : ∀{p r q E} → (p ≐ E ⟦ r ⟧e) → (loopˢ p q ≐ (eloopˢ q ∷ E) ⟦ r ⟧e)
desuspend : ∀{p E r S} → (p ≐ E ⟦ r ⟧e) → (suspend p S ≐ (esuspend S ∷ E) ⟦ r ⟧e)
detrap : ∀{p E r} → (p ≐ E ⟦ r ⟧e) → (trap p ≐ (etrap ∷ E) ⟦ r ⟧e)
-- Should we just not use inclusion from EvaluationContext?
data Context1 : Set where
ceval : (E1 : EvaluationContext1) → Context1
csignl : (S : Signal) → Context1
cpresent₁ : (S : Signal) → (q : Term) → Context1
cpresent₂ : (S : Signal) → (p : Term) → Context1
cloop : Context1
cloopˢ₂ : (p : Term) → Context1
cseq₂ : (p : Term) → Context1
cshared : (s : SharedVar) → (e : Expr) → Context1
cvar : (x : SeqVar) → (e : Expr) → Context1
cif₁ : (x : SeqVar) → (q : Term) → Context1
cif₂ : (x : SeqVar) → (p : Term) → Context1
cenv : (θ : Env) → (A : Ctrl) → Context1
Context : Set
Context = List Context1
_⟦_⟧c : Context → Term → Term
[] ⟦ p ⟧c = p
(ceval (epar₁ q) ∷ C) ⟦ p ⟧c = (C ⟦ p ⟧c) ∥ q
(ceval (epar₂ p) ∷ C) ⟦ q ⟧c = p ∥ (C ⟦ q ⟧c)
(ceval (eseq q) ∷ C) ⟦ p ⟧c = (C ⟦ p ⟧c) >> q
(ceval (eloopˢ q) ∷ C) ⟦ p ⟧c = loopˢ (C ⟦ p ⟧c) q
(cseq₂ p ∷ C) ⟦ q ⟧c = p >> (C ⟦ q ⟧c)
(ceval (esuspend S) ∷ C) ⟦ p ⟧c = suspend (C ⟦ p ⟧c) S
(ceval etrap ∷ C) ⟦ p ⟧c = trap (C ⟦ p ⟧c)
(csignl S ∷ C) ⟦ p ⟧c = signl S (C ⟦ p ⟧c)
(cpresent₁ S q ∷ C) ⟦ p ⟧c = present S ∣⇒ (C ⟦ p ⟧c) ∣⇒ q
(cpresent₂ S p ∷ C) ⟦ q ⟧c = present S ∣⇒ p ∣⇒ (C ⟦ q ⟧c)
(cloop ∷ C) ⟦ p ⟧c = loop (C ⟦ p ⟧c)
(cloopˢ₂ p ∷ C) ⟦ q ⟧c = loopˢ p (C ⟦ q ⟧c)
(cshared s e ∷ C) ⟦ p ⟧c = shared s ≔ e in: (C ⟦ p ⟧c)
(cvar x e ∷ C) ⟦ p ⟧c = var x ≔ e in: (C ⟦ p ⟧c)
(cif₁ x q ∷ C) ⟦ p ⟧c = if x ∣⇒ (C ⟦ p ⟧c) ∣⇒ q
(cif₂ x p ∷ C) ⟦ q ⟧c = if x ∣⇒ p ∣⇒ (C ⟦ q ⟧c)
(cenv θ A ∷ C) ⟦ p ⟧c = ρ⟨ θ , A ⟩· (C ⟦ p ⟧c)
data _≐_⟦_⟧c : Term → Context → Term → Set where
dchole : ∀{p} → (p ≐ [] ⟦ p ⟧c)
dcpar₁ : ∀{p r q C} → (p ≐ C ⟦ r ⟧c) → (p ∥ q ≐ (ceval (epar₁ q) ∷ C) ⟦ r ⟧c)
dcpar₂ : ∀{p r q C} → (q ≐ C ⟦ r ⟧c) → (p ∥ q ≐ (ceval (epar₂ p) ∷ C) ⟦ r ⟧c)
dcseq₁ : ∀{p r q C} → (p ≐ C ⟦ r ⟧c) → (p >> q ≐ (ceval (eseq q) ∷ C) ⟦ r ⟧c)
dcseq₂ : ∀{p r q C} → (q ≐ C ⟦ r ⟧c) → (p >> q ≐ (cseq₂ p ∷ C) ⟦ r ⟧c)
dcsuspend : ∀{p C r S} → (p ≐ C ⟦ r ⟧c) → (suspend p S ≐ (ceval (esuspend S) ∷ C) ⟦ r ⟧c)
dctrap : ∀{p C r} → (p ≐ C ⟦ r ⟧c) → (trap p ≐ (ceval etrap ∷ C) ⟦ r ⟧c)
dcsignl : ∀{p C r S} → (p ≐ C ⟦ r ⟧c) → (signl S p ≐ (csignl S ∷ C) ⟦ r ⟧c)
dcpresent₁ : ∀{p r q C S} → (p ≐ C ⟦ r ⟧c) → (present S ∣⇒ p ∣⇒ q ≐ (cpresent₁ S q ∷ C) ⟦ r ⟧c)
dcpresent₂ : ∀{p r q C S} → (q ≐ C ⟦ r ⟧c) → (present S ∣⇒ p ∣⇒ q ≐ (cpresent₂ S p ∷ C) ⟦ r ⟧c)
dcloop : ∀{p C r} → (p ≐ C ⟦ r ⟧c) → (loop p ≐ (cloop ∷ C) ⟦ r ⟧c)
dcloopˢ₁ : ∀{p q C r} → (p ≐ C ⟦ r ⟧c) → (loopˢ p q ≐ (ceval (eloopˢ q) ∷ C) ⟦ r ⟧c)
dcloopˢ₂ : ∀{p q C r} → (q ≐ C ⟦ r ⟧c) → (loopˢ p q ≐ (cloopˢ₂ p ∷ C) ⟦ r ⟧c)
dcshared : ∀{p C r s e} → (p ≐ C ⟦ r ⟧c) → (shared s ≔ e in: p ≐ (cshared s e ∷ C) ⟦ r ⟧c)
dcvar : ∀{p C r x e} → (p ≐ C ⟦ r ⟧c) → (var x ≔ e in: p ≐ (cvar x e ∷ C) ⟦ r ⟧c)
dcif₁ : ∀{p r q x C} → (p ≐ C ⟦ r ⟧c) → (if x ∣⇒ p ∣⇒ q ≐ (cif₁ x q ∷ C) ⟦ r ⟧c)
dcif₂ : ∀{p r q x C} → (q ≐ C ⟦ r ⟧c) → (if x ∣⇒ p ∣⇒ q ≐ (cif₂ x p ∷ C) ⟦ r ⟧c)
dcenv : ∀{p C r θ A} → (p ≐ C ⟦ r ⟧c) → (ρ⟨ θ , A ⟩· p ≐ (cenv θ A ∷ C) ⟦ r ⟧c)
| {
"alphanum_fraction": 0.4127269459,
"avg_line_length": 51.5092592593,
"ext": "agda",
"hexsha": "c60d606cb710a5648bbff7e5620362e8d7a0f856",
"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/Esterel/Context.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/Esterel/Context.agda",
"max_line_length": 109,
"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/Esterel/Context.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": 2745,
"size": 5563
} |
module Cats.Category.Constructions.Terminal where
open import Data.Product using (proj₁ ; proj₂)
open import Level
open import Cats.Category.Base
import Cats.Category.Constructions.Iso as Iso
import Cats.Category.Constructions.Unique as Unique
module Build {lo la l≈} (Cat : Category lo la l≈) where
open Category Cat
open Iso.Build Cat
open Unique.Build Cat
IsTerminal : Obj → Set (lo ⊔ la ⊔ l≈)
IsTerminal One = ∀ X → ∃! X One
terminal→id-unique : ∀ {A} → IsTerminal A → IsUnique (id {A})
terminal→id-unique {A} term id′ with term A
... | ∃!-intro id″ _ id″-uniq = ≈.trans (≈.sym (id″-uniq _)) (id″-uniq _)
terminal-unique : ∀ {A B} → IsTerminal A → IsTerminal B → A ≅ B
terminal-unique {A} {B} A-term B-term = record
{ forth = ∃!′.arr (B-term A)
; back = ∃!′.arr (A-term B)
; back-forth = ≈.sym (terminal→id-unique A-term _)
; forth-back = ≈.sym (terminal→id-unique B-term _)
}
X⇒Terminal-unique : ∀ {One} → IsTerminal One → ∀ {X} {f g : X ⇒ One} → f ≈ g
X⇒Terminal-unique term {X} {f} {g} with term X
... | ∃!-intro x _ x-uniq = ≈.trans (≈.sym (x-uniq _)) (x-uniq _)
record HasTerminal {lo la l≈} (Cat : Category lo la l≈)
: Set (lo ⊔ la ⊔ l≈) where
open Category Cat
open Build Cat
field
One : Obj
isTerminal : IsTerminal One
| {
"alphanum_fraction": 0.6196969697,
"avg_line_length": 26.4,
"ext": "agda",
"hexsha": "e235538068088a6ab54da8642911f3e0e1099d92",
"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/Constructions/Terminal.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/Constructions/Terminal.agda",
"max_line_length": 78,
"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/Constructions/Terminal.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 465,
"size": 1320
} |
{-
This second-order equational theory was created from the following second-order syntax description:
syntax Combinatory | CL
type
* : 0-ary
term
app : * * -> * | _$_ l20
i : *
k : *
s : *
theory
(IA) x |> app (i, x) = x
(KA) x y |> app (app(k, x), y) = x
(SA) x y z |> app (app (app (s, x), y), z) = app (app(x, z), app(y, z))
-}
module Combinatory.Equality where
open import SOAS.Common
open import SOAS.Context
open import SOAS.Variable
open import SOAS.Families.Core
open import SOAS.Families.Build
open import SOAS.ContextMaps.Inductive
open import Combinatory.Signature
open import Combinatory.Syntax
open import SOAS.Metatheory.SecondOrder.Metasubstitution CL:Syn
open import SOAS.Metatheory.SecondOrder.Equality CL:Syn
private
variable
α β γ τ : *T
Γ Δ Π : Ctx
infix 1 _▹_⊢_≋ₐ_
-- Axioms of equality
data _▹_⊢_≋ₐ_ : ∀ 𝔐 Γ {α} → (𝔐 ▷ CL) α Γ → (𝔐 ▷ CL) α Γ → Set where
IA : ⁅ * ⁆̣ ▹ ∅ ⊢ I $ 𝔞 ≋ₐ 𝔞
KA : ⁅ * ⁆ ⁅ * ⁆̣ ▹ ∅ ⊢ (K $ 𝔞) $ 𝔟 ≋ₐ 𝔞
SA : ⁅ * ⁆ ⁅ * ⁆ ⁅ * ⁆̣ ▹ ∅ ⊢ ((S $ 𝔞) $ 𝔟) $ 𝔠 ≋ₐ (𝔞 $ 𝔠) $ (𝔟 $ 𝔠)
open EqLogic _▹_⊢_≋ₐ_
open ≋-Reasoning
| {
"alphanum_fraction": 0.5773913043,
"avg_line_length": 22.5490196078,
"ext": "agda",
"hexsha": "519f71880546123ee100558bce2c22e98bb31d91",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z",
"max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "JoeyEremondi/agda-soas",
"max_forks_repo_path": "out/Combinatory/Equality.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8",
"max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "JoeyEremondi/agda-soas",
"max_issues_repo_path": "out/Combinatory/Equality.agda",
"max_line_length": 99,
"max_stars_count": 39,
"max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "JoeyEremondi/agda-soas",
"max_stars_repo_path": "out/Combinatory/Equality.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z",
"num_tokens": 501,
"size": 1150
} |
-- Andreas, 2019-06-25, issue #3855 reported by nad
-- Constraint solver needs to respect erasure.
module _
(_≡_ : {A : Set₁} → A → A → Set)
(refl : {A : Set₁} (x : A) → x ≡ x)
where
-- rejected : (@0 A : Set) → A ≡ A
-- rejected A = refl A
should-also-be-rejected : (@0 A : Set) → A ≡ A
should-also-be-rejected A = refl _
| {
"alphanum_fraction": 0.5813253012,
"avg_line_length": 23.7142857143,
"ext": "agda",
"hexsha": "6c43d8577b4f22a738293802bf64239dc8a8c9b9",
"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/Issue3855b.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/Issue3855b.agda",
"max_line_length": 51,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Fail/Issue3855b.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": 125,
"size": 332
} |
-- Agda is an /interactive/ language;
-- that's very important difference (compared to language-pts)
module J where
open import Level
open import Data.Bool using (Bool; true; false)
data ⊤ : Set where
I : ⊤
data ⊥ : Set where
data Eq {ℓ : Level} (A : Set ℓ) : A → A → Set ℓ where
refl : {x : A} → Eq A x x
J : ∀ {ℓ ℓ′} (A : Set ℓ)
→ (C : (x : A) → (y : A) → (p : Eq A x y) → Set ℓ′)
→ (r : (x : A) → C x x refl)
→ (u : A)
→ (v : A)
→ (p : Eq A u v)
→ C u v p
J A C r u .u refl = r u
Eq-sym : ∀ {ℓ} (A : Set ℓ) (x y : A) → Eq A x y → Eq A y x
Eq-sym A x .x refl = refl
Eq-sym-with-J : ∀ {ℓ} (A : Set ℓ) (x y : A) → Eq A x y → Eq A y x
Eq-sym-with-J A = J A (λ x y _ → Eq A y x) (λ x → refl)
Eq-trans-with-J : ∀ {ℓ} (A : Set ℓ) (x y z : A) → Eq A x y → Eq A y z → Eq A x z
Eq-trans-with-J A x y z p = J A (λ u v _ → Eq A v z → Eq A u z) (λ _ r → r) x y p
Bool-elim : ∀ {ℓ} (P : Bool → Set ℓ) → P true → P false → (b : Bool) → P b
Bool-elim P t f false = f
Bool-elim P t f true = t
if1 : (r : Set1) → Bool → r → r → r
if1 r b t f = Bool-elim (λ _ → r) t f b
lemma-motive : Bool → Bool → Set
lemma-motive u v = if1 Set u (if1 Set v ⊤ ⊥) ⊤
lemma : Eq Bool true false → ⊥
lemma p = J Bool
(λ u v _ → lemma-motive u v)
(λ b → Bool-elim (λ c → lemma-motive c c) I I b )
true false p
| {
"alphanum_fraction": 0.5156369184,
"avg_line_length": 26.7551020408,
"ext": "agda",
"hexsha": "288b91c0413a097a66f77f160117e681a73342f6",
"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": "761e5b92b14506b75164bd3162487df2d7fbfa93",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "phadej/language-pts",
"max_forks_repo_path": "notes/J.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "761e5b92b14506b75164bd3162487df2d7fbfa93",
"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": "phadej/language-pts",
"max_issues_repo_path": "notes/J.agda",
"max_line_length": 81,
"max_stars_count": 9,
"max_stars_repo_head_hexsha": "761e5b92b14506b75164bd3162487df2d7fbfa93",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "phadej/language-pts",
"max_stars_repo_path": "notes/J.agda",
"max_stars_repo_stars_event_max_datetime": "2019-11-27T04:35:55.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-10-11T07:34:45.000Z",
"num_tokens": 577,
"size": 1311
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Unsafe String operations and proofs
------------------------------------------------------------------------
{-# OPTIONS --with-K #-}
module Data.String.Unsafe where
open import Data.String.Base
open import Relation.Binary.PropositionalEquality using (_≡_)
open import Relation.Binary.PropositionalEquality.TrustMe using (trustMe)
------------------------------------------------------------------------
-- Properties of conversion functions
toList∘fromList : ∀ s → toList (fromList s) ≡ s
toList∘fromList s = trustMe
fromList∘toList : ∀ s → fromList (toList s) ≡ s
fromList∘toList s = trustMe
| {
"alphanum_fraction": 0.5204513399,
"avg_line_length": 29.5416666667,
"ext": "agda",
"hexsha": "9e00c6118aa4903d07a9cd989f4b1299131a3a8c",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "omega12345/agda-mode",
"max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/String/Unsafe.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "omega12345/agda-mode",
"max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/String/Unsafe.agda",
"max_line_length": 73,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/String/Unsafe.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 134,
"size": 709
} |
------------------------------------------------------------------------
-- A coinductive definition of weak bisimilarity
------------------------------------------------------------------------
{-# OPTIONS --sized-types #-}
open import Labelled-transition-system
module Bisimilarity.Weak {ℓ} (lts : LTS ℓ) where
open import Equality.Propositional
open import Prelude
open import Prelude.Size
import Function-universe equality-with-J as F
import Bisimilarity
import Bisimilarity.Equational-reasoning-instances
import Bisimilarity.General
open import Equational-reasoning
import Expansion
import Expansion.Equational-reasoning-instances
open import Indexed-container using (Container; ν; ν′)
open import Relation
open import Up-to
open LTS lts
private
open module SB = Bisimilarity lts
using (_∼_; _∼′_; [_]_∼_; [_]_∼′_)
open module E = Expansion lts
using (_≳_; _≳′_; _≲_; [_]_≳_; [_]_≳′_)
private
module General = Bisimilarity.General lts _[_]⇒̂_ _[_]⇒̂_ ⟶→⇒̂ ⟶→⇒̂
open General public
using (module StepC; ⟨_,_⟩; left-to-right; right-to-left; force;
[_]_≡_; [_]_≡′_; []≡↔; Extensionality; extensionality)
renaming ( reflexive-∼ to reflexive-≈
; reflexive-∼′ to reflexive-≈′
; ≡⇒∼ to ≡⇒≈
; ∼:_ to ≈:_
; ∼′:_ to ≈′:_
; module Bisimilarity-of-∼ to Bisimilarity-of-≈
)
-- StepC is given in the following way, rather than via open public,
-- to make hyperlinks to it more informative.
StepC : Container (Proc × Proc) (Proc × Proc)
StepC = General.StepC
-- The following definitions are given explicitly, to make the code
-- easier to follow for readers of the paper.
Weak-bisimilarity : Size → Rel₂ ℓ Proc
Weak-bisimilarity = ν StepC
Weak-bisimilarity′ : Size → Rel₂ ℓ Proc
Weak-bisimilarity′ = ν′ StepC
infix 4 [_]_≈_ [_]_≈′_ _≈_ _≈′_
[_]_≈_ : Size → Proc → Proc → Type ℓ
[ i ] p ≈ q = ν StepC i (p , q)
[_]_≈′_ : Size → Proc → Proc → Type ℓ
[ i ] p ≈′ q = ν′ StepC i (p , q)
_≈_ : Proc → Proc → Type ℓ
_≈_ = [ ∞ ]_≈_
_≈′_ : Proc → Proc → Type ℓ
_≈′_ = [ ∞ ]_≈′_
private
-- However, these definitions are definitionally equivalent to
-- corresponding definitions in General.
indirect-Weak-bisimilarity :
Weak-bisimilarity ≡ General.Bisimilarity
indirect-Weak-bisimilarity = refl
indirect-Weak-bisimilarity′ :
Weak-bisimilarity′ ≡ General.Bisimilarity′
indirect-Weak-bisimilarity′ = refl
indirect-[]≈ : [_]_≈_ ≡ General.[_]_∼_
indirect-[]≈ = refl
indirect-[]≈′ : [_]_≈′_ ≡ General.[_]_∼′_
indirect-[]≈′ = refl
indirect-≈ : _≈_ ≡ General._∼_
indirect-≈ = refl
indirect-≈′ : _≈′_ ≡ General._∼′_
indirect-≈′ = refl
-- Combinators that can perhaps make the code a bit nicer to read.
infix -3 lr-result rl-result
lr-result : ∀ {i p′ q q′} μ → [ i ] p′ ≈′ q′ → q [ μ ]⇒̂ q′ →
∃ λ q′ → q [ μ ]⇒̂ q′ × [ i ] p′ ≈′ q′
lr-result _ p′≈′q′ q⇒̂q′ = _ , q⇒̂q′ , p′≈′q′
rl-result : ∀ {i p p′ q′} μ → p [ μ ]⇒̂ p′ → [ i ] p′ ≈′ q′ →
∃ λ p′ → p [ μ ]⇒̂ p′ × [ i ] p′ ≈′ q′
rl-result _ p⇒̂p′ p′≈′q′ = _ , p⇒̂p′ , p′≈′q′
syntax lr-result μ p′≈′q′ q⇒̂q′ = p′≈′q′ ⇐̂[ μ ] q⇒̂q′
syntax rl-result μ p⇒̂p′ p′≈′q′ = p⇒̂p′ ⇒̂[ μ ] p′≈′q′
-- Processes that are related by the expansion ordering are weakly
-- bisimilar.
mutual
≳⇒≈ : ∀ {i p q} → [ i ] p ≳ q → [ i ] p ≈ q
≳⇒≈ {i} = λ p≳q → StepC.⟨ lr p≳q , rl p≳q ⟩
where
lr : ∀ {p p′ q μ} →
[ i ] p ≳ q → p [ μ ]⟶ p′ →
∃ λ q′ → q [ μ ]⇒̂ q′ × [ i ] p′ ≈′ q′
lr p≳q q⟶q′ =
let p′ , p⟶̂p′ , p′≳′q′ = E.left-to-right p≳q q⟶q′
in p′ , ⟶̂→⇒̂ p⟶̂p′ , ≳⇒≈′ p′≳′q′
rl : ∀ {p q q′ μ} →
[ i ] p ≳ q → q [ μ ]⟶ q′ →
∃ λ p′ → p [ μ ]⇒̂ p′ × [ i ] p′ ≈′ q′
rl p≳q q⟶q′ =
let p′ , p⇒p′ , p′≳′q′ = E.right-to-left p≳q q⟶q′
in p′ , ⇒→⇒̂ p⇒p′ , ≳⇒≈′ p′≳′q′
≳⇒≈′ : ∀ {i p q} → [ i ] p ≳′ q → [ i ] p ≈′ q
force (≳⇒≈′ p≳′q) = ≳⇒≈ (SB.force p≳′q)
-- Strongly bisimilar processes are weakly bisimilar.
∼⇒≈ : ∀ {i p q} → [ i ] p ∼ q → [ i ] p ≈ q
∼⇒≈ = ≳⇒≈ ∘ convert {a = ℓ}
∼⇒≈′ : ∀ {i p q} → [ i ] p ∼′ q → [ i ] p ≈′ q
∼⇒≈′ = ≳⇒≈′ ∘ convert {a = ℓ}
-- Weak bisimilarity is a weak simulation (of one kind).
weak-is-weak⇒ :
∀ {p p′ q} →
p ≈ q → p ⇒ p′ →
∃ λ q′ → q ⇒ q′ × p′ ≈ q′
weak-is-weak⇒ = is-weak⇒ StepC.left-to-right (λ p≈′q → force p≈′q) ⇒̂→⇒
-- Weak bisimilarity is a weak simulation (of another kind).
weak-is-weak⇒̂ :
∀ {p p′ q μ} →
p ≈ q → p [ μ ]⇒̂ p′ →
∃ λ q′ → q [ μ ]⇒̂ q′ × p′ ≈ q′
weak-is-weak⇒̂ =
is-weak⇒̂ StepC.left-to-right (λ p≈′q → force p≈′q) ⇒̂→⇒ id
mutual
-- Weak bisimilarity is symmetric.
symmetric-≈ : ∀ {i p q} → [ i ] p ≈ q → [ i ] q ≈ p
symmetric-≈ p≈q =
StepC.⟨ Σ-map id (Σ-map id symmetric-≈′) ∘ StepC.right-to-left p≈q
, Σ-map id (Σ-map id symmetric-≈′) ∘ StepC.left-to-right p≈q
⟩
symmetric-≈′ : ∀ {i p q} → [ i ] p ≈′ q → [ i ] q ≈′ p
force (symmetric-≈′ p≈q) = symmetric-≈ (force p≈q)
private
-- An alternative proof of symmetry.
alternative-proof-of-symmetry : ∀ {i p q} → [ i ] p ≈ q → [ i ] q ≈ p
alternative-proof-of-symmetry {i} =
uncurry [ i ]_≈_ ⁻¹ ⊆⟨ ν-symmetric _ _ swap refl F.id ⟩∎
uncurry [ i ]_≈_ ∎
mutual
-- Weak bisimilarity is transitive.
--
-- Note that the transitivity proof is not claimed to be
-- size-preserving. For proofs showing that transitivity cannot, in
-- general, be size-preserving in any of its arguments, see
-- Bisimilarity.Weak.Delay-monad.size-preserving-transitivityʳ⇔uninhabited
-- and size-preserving-transitivityˡ⇔uninhabited.
transitive-≈ : ∀ {i p q r} → p ≈ q → q ≈ r → [ i ] p ≈ r
transitive-≈ {i} = λ p≈q q≈r →
StepC.⟨ lr p≈q q≈r
, Σ-map id (Σ-map id symmetric-≈′) ∘
lr (symmetric-≈ q≈r) (symmetric-≈ p≈q)
⟩
where
lr : ∀ {p p′ q r μ} →
p ≈ q → q ≈ r → p [ μ ]⟶ p′ →
∃ λ r′ → r [ μ ]⇒̂ r′ × [ i ] p′ ≈′ r′
lr p≈q q≈r p⟶p′ =
let q′ , q⇒̂q′ , p′≈′q′ = StepC.left-to-right p≈q p⟶p′
r′ , r⇒̂r′ , q′≈r′ = weak-is-weak⇒̂ q≈r q⇒̂q′
in r′ , r⇒̂r′ , transitive-≈′ p′≈′q′ q′≈r′
transitive-≈′ : ∀ {i p q r} → p ≈′ q → q ≈ r → [ i ] p ≈′ r
force (transitive-≈′ p≈q q≈r) = transitive-≈ (force p≈q) q≈r
-- The following variants of transitivity are partially
-- size-preserving.
--
-- For proofs showing that they cannot, in general, be size-preserving
-- in the "other" argument, see the following lemmas in
-- Bisimilarity.Weak.Delay-monad:
-- size-preserving-transitivity-≳≈ˡ⇔uninhabited,
-- size-preserving-transitivity-≈≲ʳ⇔uninhabited and
-- size-preserving-transitivity-≈∼ʳ⇔uninhabited.
mutual
transitive-≳≈ : ∀ {i p q r} →
p ≳ q → [ i ] q ≈ r → [ i ] p ≈ r
transitive-≳≈ {i} {p} {r = r} p≳q q≈r = StepC.⟨ lr , rl ⟩
where
lr : ∀ {p′ μ} → p [ μ ]⟶ p′ →
∃ λ r′ → r [ μ ]⇒̂ r′ × [ i ] p′ ≈′ r′
lr p⟶p′ with E.left-to-right p≳q p⟶p′
... | _ , done s , p≳′q′ =
r , silent s done
, transitive-≳≈′ p≳′q′ (record { force = λ { {_} → q≈r } })
... | q′ , step q⟶q′ , p′≳′q′ =
let r′ , r⇒̂r′ , q′≈′r′ = StepC.left-to-right q≈r q⟶q′
in r′ , r⇒̂r′ , transitive-≳≈′ p′≳′q′ q′≈′r′
rl : ∀ {r′ μ} → r [ μ ]⟶ r′ →
∃ λ p′ → p [ μ ]⇒̂ p′ × [ i ] p′ ≈′ r′
rl r⟶r′ =
let q′ , q⇒̂q′ , q′≈′r′ = StepC.right-to-left q≈r r⟶r′
p′ , p⇒̂p′ , p′≳q′ = E.converse-of-expansion-is-weak⇒̂ p≳q q⇒̂q′
in p′ , p⇒̂p′ , transitive-≳≈′ (record { force = p′≳q′ }) q′≈′r′
transitive-≳≈′ : ∀ {i p q r} →
p ≳′ q → [ i ] q ≈′ r → [ i ] p ≈′ r
force (transitive-≳≈′ p≳′q q≈′r) =
transitive-≳≈ (force p≳′q) (force q≈′r)
transitive-≈≲ : ∀ {i p q r} →
[ i ] p ≈ q → q ≲ r → [ i ] p ≈ r
transitive-≈≲ p≈q q≲r =
symmetric-≈ (transitive-≳≈ q≲r (symmetric-≈ p≈q))
transitive-≈∼ : ∀ {i p q r} →
[ i ] p ≈ q → q ∼ r → [ i ] p ≈ r
transitive-≈∼ p≈q q∼r =
symmetric-≈ $
transitive-≳≈ (convert {a = ℓ} (symmetric q∼r)) (symmetric-≈ p≈q)
| {
"alphanum_fraction": 0.5127182045,
"avg_line_length": 30.2641509434,
"ext": "agda",
"hexsha": "c9645d571e56709c6afcf6b248196a937bdc072f",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/up-to",
"max_forks_repo_path": "src/Bisimilarity/Weak.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/up-to",
"max_issues_repo_path": "src/Bisimilarity/Weak.agda",
"max_line_length": 76,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/up-to",
"max_stars_repo_path": "src/Bisimilarity/Weak.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3686,
"size": 8020
} |
module Itse.Grammar where
open import Relation.Binary.PropositionalEquality
open import Relation.Nullary
open import Relation.Unary
open import Data.List
open import Data.Maybe
open import Data.String
open import Data.Empty
data ExprVari : Set
Prgm : Set
data Stmt : Set
data Expr : ExprVari → Set
data Name : ExprVari → Set
data ExprVari where
s : ExprVari -- sort
k : ExprVari -- kind
p : ExprVari -- type
t : ExprVari -- term
_≟-ExprVari_ : ∀ (e : ExprVari) (e′ : ExprVari) → Dec (e ≡ e′)
TypeOf : ExprVari → ExprVari
TypeOf s = s
TypeOf k = s
TypeOf p = k
TypeOf t = p
Kind : Set
Type : Set
Term : Set
Nameₚ : Set
Nameₜ : Set
Sort = Expr s
Kind = Expr k
Type = Expr p
Term = Expr t
Nameₚ = Name p
Nameₜ = Name t
Prgm = List Stmt
infixr 10 `defnₚ_⦂_≔_ `defnₚ_⦂_≔_
infixr 11 _`→_
infixr 12 `λₖₚ[_⦂_]_ `λₖₜ[_⦂_]_ `λₚₚ[_⦂_]_ `λₚₜ[_⦂_]_ `λₜₚ[_⦂_]_ `λₜₜ[_⦂_]_
infixr 13 _`∙ₚₚ_ _`∙ₚₜ_ _`∙ₜₚ_ _`∙ₜₜ_
infixr 14 `ₚ_ `ₜ_
data Stmt where
`defnₚ_⦂_≔_ : Nameₚ → Kind → Type → Stmt
`defnₜ_⦂_≔_ : Nameₜ → Type → Term → Stmt
data Expr where
-- sort
`□ₛ : Sort
-- kind
`●ₖ : Kind
`λₖₚ[_⦂_]_ : Nameₚ → Kind → Kind → Kind
`λₖₜ[_⦂_]_ : Nameₜ → Type → Kind → Kind
-- p
`ₚ_ : Nameₚ → Type
`λₚₚ[_⦂_]_ : Nameₚ → Kind → Type → Type
`λₚₜ[_⦂_]_ : Nameₜ → Type → Type → Type
_`∙ₚₚ_ : Type → Type → Type
_`∙ₚₜ_ : Type → Term → Type
`ι[_]_ : Nameₜ → Type → Type
-- t
`ₜ_ : Nameₜ → Term
`λₜₚ[_⦂_]_ : Nameₚ → Kind → Term → Term
`λₜₜ[_⦂_]_ : Nameₜ → Type → Term → Term
_`∙ₜₚ_ : Term → Type → Term
_`∙ₜₜ_ : Term → Term → Term
data Name where
nameₚ : Maybe String → Nameₚ
nameₜ : Maybe String → Nameₜ
postulate
_≟-Name_ : ∀ {e} (n : Name e) → (n′ : Name e) → Dec (n ≡ n′)
s ≟-ExprVari s = yes refl
s ≟-ExprVari k = no λ ()
s ≟-ExprVari p = no λ ()
s ≟-ExprVari t = no λ ()
k ≟-ExprVari s = no λ ()
k ≟-ExprVari k = yes refl
k ≟-ExprVari p = no λ ()
k ≟-ExprVari t = no λ ()
p ≟-ExprVari s = no λ ()
p ≟-ExprVari k = no λ ()
p ≟-ExprVari p = yes refl
p ≟-ExprVari t = no λ ()
t ≟-ExprVari s = no λ ()
t ≟-ExprVari k = no λ ()
t ≟-ExprVari p = no λ ()
t ≟-ExprVari t = yes refl
_`→_ : Type → Type → Type
α `→ β = `λₚₜ[ nameₜ nothing ⦂ α ] β
| {
"alphanum_fraction": 0.59503386,
"avg_line_length": 21.5048543689,
"ext": "agda",
"hexsha": "286468a4cde67316bc117de81776668fab9d2341",
"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": "4ee714b707b72e4ed8373c49ee739d576aafb70a",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Riib11/itse",
"max_forks_repo_path": "agda/Itse/Grammar.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "4ee714b707b72e4ed8373c49ee739d576aafb70a",
"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": "Riib11/itse",
"max_issues_repo_path": "agda/Itse/Grammar.agda",
"max_line_length": 75,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "4ee714b707b72e4ed8373c49ee739d576aafb70a",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "Riib11/itse",
"max_stars_repo_path": "agda/Itse/Grammar.agda",
"max_stars_repo_stars_event_max_datetime": "2021-04-14T15:09:19.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-04-14T15:09:19.000Z",
"num_tokens": 1027,
"size": 2215
} |
-- Andreas, 2016-07-27, issue #2117 reported by Guillermo Calderon
-- {-# OPTIONS -v tc:10 #-}
record R : Set₁ where
field
A : Set
open R {{...}}
record S (r : R) : Set where
instance i = r
field f : A
-- ERROR WAS:
-- No instance of type R was found in scope.
-- when checking that the expression A has type Set
-- Should succeed!
| {
"alphanum_fraction": 0.632183908,
"avg_line_length": 17.4,
"ext": "agda",
"hexsha": "ad35e96a9f32585f8fd28f745ac78388f461c4a3",
"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/Issue2117.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/Issue2117.agda",
"max_line_length": 66,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/Issue2117.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": 105,
"size": 348
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Order morphisms
------------------------------------------------------------------------
module Relation.Binary.OrderMorphism where
open import Relation.Binary
open Poset
import Function as F
open import Level
record _⇒-Poset_ {p₁ p₂ p₃ p₄ p₅ p₆}
(P₁ : Poset p₁ p₂ p₃)
(P₂ : Poset p₄ p₅ p₆) : Set (p₁ ⊔ p₃ ⊔ p₄ ⊔ p₆) where
field
fun : Carrier P₁ → Carrier P₂
monotone : _≤_ P₁ =[ fun ]⇒ _≤_ P₂
_⇒-DTO_ : ∀ {p₁ p₂ p₃ p₄ p₅ p₆} →
DecTotalOrder p₁ p₂ p₃ →
DecTotalOrder p₄ p₅ p₆ → Set _
DTO₁ ⇒-DTO DTO₂ = poset DTO₁ ⇒-Poset poset DTO₂
where open DecTotalOrder
open _⇒-Poset_
id : ∀ {p₁ p₂ p₃} {P : Poset p₁ p₂ p₃} → P ⇒-Poset P
id = record
{ fun = F.id
; monotone = F.id
}
_∘_ : ∀ {p₁ p₂ p₃ p₄ p₅ p₆ p₇ p₈ p₉}
{P₁ : Poset p₁ p₂ p₃}
{P₂ : Poset p₄ p₅ p₆}
{P₃ : Poset p₇ p₈ p₉} →
P₂ ⇒-Poset P₃ → P₁ ⇒-Poset P₂ → P₁ ⇒-Poset P₃
f ∘ g = record
{ fun = F._∘_ (fun f) (fun g)
; monotone = F._∘_ (monotone f) (monotone g)
}
const : ∀ {p₁ p₂ p₃ p₄ p₅ p₆}
{P₁ : Poset p₁ p₂ p₃}
{P₂ : Poset p₄ p₅ p₆} →
Carrier P₂ → P₁ ⇒-Poset P₂
const {P₂ = P₂} x = record
{ fun = F.const x
; monotone = F.const (refl P₂)
}
| {
"alphanum_fraction": 0.4887436456,
"avg_line_length": 25.9811320755,
"ext": "agda",
"hexsha": "706742d4f88e2e7005d2b0267300cad766cf6950",
"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/OrderMorphism.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/OrderMorphism.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/OrderMorphism.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": 583,
"size": 1377
} |
module MJSF.Examples.Integer where
open import Prelude
open import Data.Maybe
open import Data.Star
open import Data.Bool
open import Data.List
open import Data.Integer
open import Data.List.Membership.Propositional
open import Data.List.Relation.Unary.Any
open import Data.List.Relation.Unary.All as All hiding (lookup)
open import Data.Product hiding (Σ)
open import Relation.Binary.PropositionalEquality
open import Relation.Nullary.Decidable
k : ℕ
k = 5
open import MJSF.Syntax k
open import ScopesFrames.ScopesFrames k Ty
{-
class Integer {
int x = 0;
void set(Integer b) {
this.x = b.get()
}
}
-}
classes : List Ty
classes = (cᵗ (# 0) (# 1) ∷ [])
intmethods intfields : List Ty
intfields =
{- x -} vᵗ int
∷ []
intmethods =
{- set -} mᵗ ((ref (# 1)) ∷ []) void
∷ []
Integer : Scope
Integer = # 1
g : Graph
-- root scope
g zero = classes , []
-- class scope of Integer class
g (suc zero)= (intmethods ++ intfields) , zero ∷ []
-- scope of Integer.set method
g (suc (suc zero)) = (vᵗ (ref (# 1)) ∷ []) , # 1 ∷ []
-- scopes of main
g (suc (suc (suc zero))) = vᵗ (ref Integer) ∷ [] , (# 0 ∷ [])
g (suc (suc (suc (suc zero)))) = vᵗ (ref Integer) ∷ [] , # 3 ∷ []
g (suc (suc (suc (suc (suc ())))))
open SyntaxG g
open UsesGraph g
IntegerImpl : Class (# 0) (# 1)
IntegerImpl = class0 {ms = intmethods}{intfields}{[]}
(-- methods
(#m' (meth (# 2) (body-void
(set
(this [] (here refl))
(path [] (there (here refl)))
(get (var (path [] (here refl))) (path [] (there (here refl))))
◅ ε)))) ∷ [])
(-- fields
(#v' tt) ∷ [])
[]
{-
int main() {
Integer x;
Integer y;
x = new Integer();
y = new Integer();
x.x = 9;
y.x = 18;
y.set(x);
return y.x;
}
-}
main : Body (# 0) int
main = body
(
loc (# 3) (ref Integer)
◅ loc (# 4) (ref Integer)
◅ asgn (path (here refl ∷ []) (here refl)) (new (path (here refl ∷ here refl ∷ []) (here refl)))
◅ asgn (path [] (here refl)) (new (path (here refl ∷ here refl ∷ []) (here refl)))
◅ set (var (path (here refl ∷ []) (here refl))) (path [] (there (here refl))) (num (+ 9))
◅ set (var (path [] (here refl))) (path [] (there (here refl))) (num (+ 18))
◅ run (call (var (path [] (here refl))) (path [] (here refl)) (var (path (here refl ∷ []) (here refl)) ∷ []))
◅ ε
)
(get (var (path [] (here refl))) (path [] (there (here refl))))
p : Program (# 0) int
p = program classes (#c' (IntegerImpl , # 1 , obj (# 1) ⦃ refl ⦄) ∷ []) main
open import MJSF.Semantics
open Semantics _ g
open import MJSF.Values
open ValuesG _ g
test : p ⇓⟨ 100 ⟩ (λ v → v ≡ num (+ 9) )
test = refl
| {
"alphanum_fraction": 0.5628720238,
"avg_line_length": 24.6605504587,
"ext": "agda",
"hexsha": "32700508a1ed49664ae7654a756d7b102ef35d78",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z",
"max_forks_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "metaborg/mj.agda",
"max_forks_repo_path": "src/MJSF/Examples/Integer.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z",
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "metaborg/mj.agda",
"max_issues_repo_path": "src/MJSF/Examples/Integer.agda",
"max_line_length": 115,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "metaborg/mj.agda",
"max_stars_repo_path": "src/MJSF/Examples/Integer.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z",
"num_tokens": 921,
"size": 2688
} |
{-# OPTIONS --universe-polymorphism #-}
module Categories.Groupoid.Coproduct where
open import Level
open import Data.Sum
open import Categories.Category
open import Categories.Groupoid
open import Categories.Morphisms
import Categories.Coproduct as CoproductC
Coproduct : ∀ {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′}
→ Groupoid C → Groupoid D → Groupoid (CoproductC.Coproduct C D)
Coproduct C D = record
{ _⁻¹ = λ { {inj₁ _} {inj₁ _} → λ { {lift f} → lift (C._⁻¹ f) }
; {inj₁ _} {inj₂ _} (lift ())
; {inj₂ _} {inj₁ _} (lift ())
; {inj₂ _} {inj₂ _} → λ { {lift f} → lift (D._⁻¹ f) }
}
; iso = λ { {inj₁ _} {inj₁ _} → record { isoˡ = lift (Iso.isoˡ C.iso)
; isoʳ = lift (Iso.isoʳ C.iso) }
; {inj₁ _} {inj₂ _} {lift ()}
; {inj₂ _} {inj₁ _} {lift ()}
; {inj₂ _} {inj₂ _} → record { isoˡ = lift (Iso.isoˡ D.iso)
; isoʳ = lift (Iso.isoʳ D.iso) }
}
}
where
module C = Groupoid C
module D = Groupoid D
| {
"alphanum_fraction": 0.5169946333,
"avg_line_length": 34.9375,
"ext": "agda",
"hexsha": "12f85fc96c2f6c11292737fc200ce9b1bca53e60",
"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": "36f4181d751e2ecb54db219911d8c69afe8ba892",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "copumpkin/categories",
"max_forks_repo_path": "Categories/Groupoid/Coproduct.agda",
"max_issues_count": 19,
"max_issues_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892",
"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": "copumpkin/categories",
"max_issues_repo_path": "Categories/Groupoid/Coproduct.agda",
"max_line_length": 75,
"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/Groupoid/Coproduct.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": 388,
"size": 1118
} |
module nat where
open import Data.Nat renaming ( zero to Zero ; suc to Suc ; ℕ to Nat ; _⊔_ to _n⊔_ )
open import Data.Empty
open import Relation.Nullary
open import Relation.Binary.PropositionalEquality
open import logic
nat-<> : { x y : Nat } → x < y → y < x → ⊥
nat-<> (s≤s x<y) (s≤s y<x) = nat-<> x<y y<x
nat-<≡ : { x : Nat } → x < x → ⊥
nat-<≡ (s≤s lt) = nat-<≡ lt
nat-≡< : { x y : Nat } → x ≡ y → x < y → ⊥
nat-≡< refl lt = nat-<≡ lt
¬a≤a : {la : Nat} → Suc la ≤ la → ⊥
¬a≤a (s≤s lt) = ¬a≤a lt
a<sa : {la : Nat} → la < Suc la
a<sa {Zero} = s≤s z≤n
a<sa {Suc la} = s≤s a<sa
=→¬< : {x : Nat } → ¬ ( x < x )
=→¬< {Zero} ()
=→¬< {Suc x} (s≤s lt) = =→¬< lt
>→¬< : {x y : Nat } → (x < y ) → ¬ ( y < x )
>→¬< (s≤s x<y) (s≤s y<x) = >→¬< x<y y<x
<-∨ : { x y : Nat } → x < Suc y → ( (x ≡ y ) ∨ (x < y) )
<-∨ {Zero} {Zero} (s≤s z≤n) = case1 refl
<-∨ {Zero} {Suc y} (s≤s lt) = case2 (s≤s z≤n)
<-∨ {Suc x} {Zero} (s≤s ())
<-∨ {Suc x} {Suc y} (s≤s lt) with <-∨ {x} {y} lt
<-∨ {Suc x} {Suc y} (s≤s lt) | case1 eq = case1 (cong (λ k → Suc k ) eq)
<-∨ {Suc x} {Suc y} (s≤s lt) | case2 lt1 = case2 (s≤s lt1)
max : (x y : Nat) → Nat
max Zero Zero = Zero
max Zero (Suc x) = (Suc x)
max (Suc x) Zero = (Suc x)
max (Suc x) (Suc y) = Suc ( max x y )
| {
"alphanum_fraction": 0.4630071599,
"avg_line_length": 26.7446808511,
"ext": "agda",
"hexsha": "83b751e38f15561b725861c4d7ae332f897ef993",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "shinji-kono/zf-in-agda",
"max_forks_repo_path": "src/nat.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "shinji-kono/zf-in-agda",
"max_issues_repo_path": "src/nat.agda",
"max_line_length": 86,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "shinji-kono/zf-in-agda",
"max_stars_repo_path": "src/nat.agda",
"max_stars_repo_stars_event_max_datetime": "2021-01-10T13:27:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-10-02T13:46:23.000Z",
"num_tokens": 644,
"size": 1257
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- "Evaluating" a polynomial, using Horner's method.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Tactic.RingSolver.Core.Polynomial.Parameters
module Tactic.RingSolver.Core.Polynomial.Semantics
{r₁ r₂ r₃ r₄}
(homo : Homomorphism r₁ r₂ r₃ r₄)
where
open import Data.Nat using (ℕ; suc; zero; _≤′_; ≤′-step; ≤′-refl)
open import Data.Vec using (Vec; []; _∷_; uncons)
open import Data.List using ([]; _∷_)
open import Data.Product using (_,_; _×_)
open import Data.List.Kleene using (_+; _*; ∹_; _&_; [])
open Homomorphism homo
open import Tactic.RingSolver.Core.Polynomial.Base from
open import Algebra.Operations.Ring rawRing
drop : ∀ {i n} → i ≤′ n → Vec Carrier n → Vec Carrier i
drop ≤′-refl xs = xs
drop (≤′-step i+1≤n) (_ ∷ xs) = drop i+1≤n xs
drop-1 : ∀ {i n} → suc i ≤′ n → Vec Carrier n → Carrier × Vec Carrier i
drop-1 si≤n xs = uncons (drop si≤n xs)
{-# INLINE drop-1 #-}
_*⟨_⟩^_ : Carrier → Carrier → ℕ → Carrier
x *⟨ ρ ⟩^ zero = x
x *⟨ ρ ⟩^ suc i = ρ ^ i +1 * x
{-# INLINE _*⟨_⟩^_ #-}
--------------------------------------------------------------------------------
-- Evaluation
--------------------------------------------------------------------------------
-- Why do we have three functions here? Why are they so weird looking?
--
-- These three functions are the main bottleneck for all of the proofs: as such,
-- slight changes can dramatically affect the length of proof code.
mutual
_⟦∷⟧_ : ∀ {n} → Poly n × Coeff n * → Carrier × Vec Carrier n → Carrier
(x , []) ⟦∷⟧ (ρ , ρs) = ⟦ x ⟧ ρs
(x , (∹ xs)) ⟦∷⟧ (ρ , ρs) = ρ * ⅀⟦ xs ⟧ (ρ , ρs) + ⟦ x ⟧ ρs
⅀⟦_⟧ : ∀ {n} → Coeff n + → (Carrier × Vec Carrier n) → Carrier
⅀⟦ x ≠0 Δ i & xs ⟧ (ρ , ρs) = ((x , xs) ⟦∷⟧ (ρ , ρs)) *⟨ ρ ⟩^ i
{-# INLINE ⅀⟦_⟧ #-}
⟦_⟧ : ∀ {n} → Poly n → Vec Carrier n → Carrier
⟦ Κ x ⊐ i≤n ⟧ _ = ⟦ x ⟧ᵣ
⟦ ⅀ xs ⊐ i≤n ⟧ Ρ = ⅀⟦ xs ⟧ (drop-1 i≤n Ρ)
{-# INLINE ⟦_⟧ #-}
--------------------------------------------------------------------------------
-- Performance
--------------------------------------------------------------------------------
-- As you might imagine, the implementation of the functions above seriously
-- affect performance. What you might not realise, though, is that the most
-- important component is the *order of the arguments*. For instance, if
-- we change:
--
-- (x , xs) ⟦∷⟧ (ρ , ρs) = ρ * ⅀⟦ xs ⟧ (ρ , ρs) + ⟦ x ⟧ ρs
--
-- To:
--
-- (x , xs) ⟦∷⟧ (ρ , ρs) = ⟦ x ⟧ ρs + ⅀⟦ xs ⟧ (ρ , ρs) * ρ
--
-- We get a function that's several orders of magnitude slower!
| {
"alphanum_fraction": 0.4801324503,
"avg_line_length": 35.2987012987,
"ext": "agda",
"hexsha": "e746c1aa70a567c8c20ae6236ad9cfd57342f74b",
"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/Tactic/RingSolver/Core/Polynomial/Semantics.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/Tactic/RingSolver/Core/Polynomial/Semantics.agda",
"max_line_length": 80,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DreamLinuxer/popl21-artifact",
"max_stars_repo_path": "agda-stdlib/src/Tactic/RingSolver/Core/Polynomial/Semantics.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": 922,
"size": 2718
} |
-- Andreas, 2016-08-08, issue #2132 reported by effectfully
-- Pattern synonyms in lhss of display form definitions
-- {-# OPTIONS -v scope:50 -v tc.decl:10 #-}
open import Common.Equality
data D : Set where
C c : D
g : D → D
pattern C′ = C
{-# DISPLAY C′ = C′ #-}
{-# DISPLAY g C′ = c #-}
-- Since pattern synonyms are now expanded on lhs of DISPLAY,
-- this behaves as
-- {-# DISPLAY C = C′ #-}
-- {-# DISPLAY g C = c #-}
test : C ≡ g C
test = refl
-- Expected error:
-- C′ != c of type D
-- when checking that the expression refl has type C′ ≡ c
| {
"alphanum_fraction": 0.6131907308,
"avg_line_length": 20.0357142857,
"ext": "agda",
"hexsha": "859c411eeee6d20662dbf06e0817f49c27ffea23",
"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/Issue2132.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/Issue2132.agda",
"max_line_length": 61,
"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/Issue2132.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": 170,
"size": 561
} |
{-# OPTIONS --prop --rewriting #-}
open import Examples.Sorting.Parallel.Comparable
module Examples.Sorting.Parallel.Core (M : Comparable) where
open import Calf.CostMonoid
open ParCostMonoid parCostMonoid
hiding (costMonoid)
renaming (
_≤_ to _≤ₚ_;
≤-refl to ≤ₚ-refl;
≤-trans to ≤ₚ-trans;
module ≤-Reasoning to ≤ₚ-Reasoning
) public
open import Examples.Sorting.Core costMonoid fromℕ M public
| {
"alphanum_fraction": 0.7261904762,
"avg_line_length": 23.3333333333,
"ext": "agda",
"hexsha": "7ee364ffb903371f711e511feea2d1f397ef5546",
"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/Parallel/Core.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/Parallel/Core.agda",
"max_line_length": 60,
"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/Parallel/Core.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": 128,
"size": 420
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Some boring lemmas used by the ring solver
------------------------------------------------------------------------
-- Note that these proofs use all "almost commutative ring" properties.
{-# OPTIONS --without-K --safe #-}
open import Algebra
open import Algebra.Solver.Ring.AlmostCommutativeRing
module Algebra.Solver.Ring.Lemmas
{r₁ r₂ r₃}
(coeff : RawRing r₁)
(r : AlmostCommutativeRing r₂ r₃)
(morphism : coeff -Raw-AlmostCommutative⟶ r)
where
private
module C = RawRing coeff
open AlmostCommutativeRing r
open import Algebra.Morphism
open _-Raw-AlmostCommutative⟶_ morphism
open import Relation.Binary.Reasoning.Setoid setoid
open import Function
lemma₀ : ∀ a b c x →
(a + b) * x + c ≈ a * x + (b * x + c)
lemma₀ a b c x = begin
(a + b) * x + c ≈⟨ distribʳ _ _ _ ⟨ +-cong ⟩ refl ⟩
(a * x + b * x) + c ≈⟨ +-assoc _ _ _ ⟩
a * x + (b * x + c) ∎
lemma₁ : ∀ a b c d x →
(a + b) * x + (c + d) ≈ (a * x + c) + (b * x + d)
lemma₁ a b c d x = begin
(a + b) * x + (c + d) ≈⟨ lemma₀ _ _ _ _ ⟩
a * x + (b * x + (c + d)) ≈⟨ refl ⟨ +-cong ⟩ sym (+-assoc _ _ _) ⟩
a * x + ((b * x + c) + d) ≈⟨ refl ⟨ +-cong ⟩ (+-comm _ _ ⟨ +-cong ⟩ refl) ⟩
a * x + ((c + b * x) + d) ≈⟨ refl ⟨ +-cong ⟩ +-assoc _ _ _ ⟩
a * x + (c + (b * x + d)) ≈⟨ sym $ +-assoc _ _ _ ⟩
(a * x + c) + (b * x + d) ∎
lemma₂ : ∀ a b c x → a * c * x + b * c ≈ (a * x + b) * c
lemma₂ a b c x = begin
a * c * x + b * c ≈⟨ lem ⟨ +-cong ⟩ refl ⟩
a * x * c + b * c ≈⟨ sym $ distribʳ _ _ _ ⟩
(a * x + b) * c ∎
where
lem = begin
a * c * x ≈⟨ *-assoc _ _ _ ⟩
a * (c * x) ≈⟨ refl ⟨ *-cong ⟩ *-comm _ _ ⟩
a * (x * c) ≈⟨ sym $ *-assoc _ _ _ ⟩
a * x * c ∎
lemma₃ : ∀ a b c x → a * b * x + a * c ≈ a * (b * x + c)
lemma₃ a b c x = begin
a * b * x + a * c ≈⟨ *-assoc _ _ _ ⟨ +-cong ⟩ refl ⟩
a * (b * x) + a * c ≈⟨ sym $ distribˡ _ _ _ ⟩
a * (b * x + c) ∎
lemma₄ : ∀ a b c d x →
(a * c * x + (a * d + b * c)) * x + b * d ≈
(a * x + b) * (c * x + d)
lemma₄ a b c d x = begin
(a * c * x + (a * d + b * c)) * x + b * d ≈⟨ distribʳ _ _ _ ⟨ +-cong ⟩ refl ⟩
(a * c * x * x + (a * d + b * c) * x) + b * d ≈⟨ refl ⟨ +-cong ⟩ ((refl ⟨ +-cong ⟩ refl) ⟨ *-cong ⟩ refl) ⟨ +-cong ⟩ refl ⟩
(a * c * x * x + (a * d + b * c) * x) + b * d ≈⟨ +-assoc _ _ _ ⟩
a * c * x * x + ((a * d + b * c) * x + b * d) ≈⟨ lem₁ ⟨ +-cong ⟩ (lem₂ ⟨ +-cong ⟩ refl) ⟩
a * x * (c * x) + (a * x * d + b * (c * x) + b * d) ≈⟨ refl ⟨ +-cong ⟩ +-assoc _ _ _ ⟩
a * x * (c * x) + (a * x * d + (b * (c * x) + b * d)) ≈⟨ sym $ +-assoc _ _ _ ⟩
a * x * (c * x) + a * x * d + (b * (c * x) + b * d) ≈⟨ sym $ distribˡ _ _ _ ⟨ +-cong ⟩ distribˡ _ _ _ ⟩
a * x * (c * x + d) + b * (c * x + d) ≈⟨ sym $ distribʳ _ _ _ ⟩
(a * x + b) * (c * x + d) ∎
where
lem₁′ = begin
a * c * x ≈⟨ *-assoc _ _ _ ⟩
a * (c * x) ≈⟨ refl ⟨ *-cong ⟩ *-comm _ _ ⟩
a * (x * c) ≈⟨ sym $ *-assoc _ _ _ ⟩
a * x * c ∎
lem₁ = begin
a * c * x * x ≈⟨ lem₁′ ⟨ *-cong ⟩ refl ⟩
a * x * c * x ≈⟨ *-assoc _ _ _ ⟩
a * x * (c * x) ∎
lem₂ = begin
(a * d + b * c) * x ≈⟨ distribʳ _ _ _ ⟩
a * d * x + b * c * x ≈⟨ *-assoc _ _ _ ⟨ +-cong ⟩ *-assoc _ _ _ ⟩
a * (d * x) + b * (c * x) ≈⟨ (refl ⟨ *-cong ⟩ *-comm _ _) ⟨ +-cong ⟩ refl ⟩
a * (x * d) + b * (c * x) ≈⟨ sym $ *-assoc _ _ _ ⟨ +-cong ⟩ refl ⟩
a * x * d + b * (c * x) ∎
lemma₅ : ∀ x → (0# * x + 1#) * x + 0# ≈ x
lemma₅ x = begin
(0# * x + 1#) * x + 0# ≈⟨ ((zeroˡ _ ⟨ +-cong ⟩ refl) ⟨ *-cong ⟩ refl) ⟨ +-cong ⟩ refl ⟩
(0# + 1#) * x + 0# ≈⟨ (+-identityˡ _ ⟨ *-cong ⟩ refl) ⟨ +-cong ⟩ refl ⟩
1# * x + 0# ≈⟨ +-identityʳ _ ⟩
1# * x ≈⟨ *-identityˡ _ ⟩
x ∎
lemma₆ : ∀ a x → 0# * x + a ≈ a
lemma₆ a x = begin
0# * x + a ≈⟨ zeroˡ _ ⟨ +-cong ⟩ refl ⟩
0# + a ≈⟨ +-identityˡ _ ⟩
a ∎
lemma₇ : ∀ x → - 1# * x ≈ - x
lemma₇ x = begin
- 1# * x ≈⟨ -‿*-distribˡ _ _ ⟩
- (1# * x) ≈⟨ -‿cong (*-identityˡ _) ⟩
- x ∎
| {
"alphanum_fraction": 0.3843632959,
"avg_line_length": 37.147826087,
"ext": "agda",
"hexsha": "865a56ee3105e15b166a4ee47009bf2fb60b0c92",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "omega12345/agda-mode",
"max_forks_repo_path": "test/asset/agda-stdlib-1.0/Algebra/Solver/Ring/Lemmas.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "omega12345/agda-mode",
"max_issues_repo_path": "test/asset/agda-stdlib-1.0/Algebra/Solver/Ring/Lemmas.agda",
"max_line_length": 134,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Algebra/Solver/Ring/Lemmas.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2013,
"size": 4272
} |
{-# OPTIONS --without-K --safe #-}
module Data.Binary.Tests.Helpers where
open import Data.List as List using (List; _∷_; [])
open import Data.Product
open import Data.Nat as Nat using (ℕ; suc; zero)
open import Data.Binary.Definitions
open import Data.Binary.Operations.Semantics
open import Relation.Binary.PropositionalEquality
_≡⌈_⌉≡_ : (𝔹 → 𝔹) → ℕ → (ℕ → ℕ) → Set
fᵇ ≡⌈ n ⌉≡ fⁿ = let xs = List.upTo n in List.map (λ x → ⟦ fᵇ ⟦ x ⇑⟧ ⇓⟧ ) xs ≡ List.map fⁿ xs
prod : ∀ {a b} {A : Set a} {B : Set b} → List A → List B → List (A × B)
prod [] ys = []
prod (x ∷ xs) ys = List.foldr (λ y ys → (x , y) ∷ ys) (prod xs ys) ys
_≡⌈_⌉₂≡_ : (𝔹 → 𝔹 → 𝔹) → ℕ → (ℕ → ℕ → ℕ) → Set
fᵇ ≡⌈ n ⌉₂≡ fⁿ = List.map (λ { (x , y) → ⟦ fᵇ ⟦ x ⇑⟧ ⟦ y ⇑⟧ ⇓⟧ }) ys ≡ List.map (uncurry fⁿ) ys
where
xs : List ℕ
xs = List.upTo n
ys = prod xs xs
| {
"alphanum_fraction": 0.574185766,
"avg_line_length": 30.7037037037,
"ext": "agda",
"hexsha": "afd2b74da32e08b40854035067965252d4b6935f",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "92af4d620febd47a9791d466d747278dc4a417aa",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/agda-binary",
"max_forks_repo_path": "Data/Binary/Tests/Helpers.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "92af4d620febd47a9791d466d747278dc4a417aa",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "oisdk/agda-binary",
"max_issues_repo_path": "Data/Binary/Tests/Helpers.agda",
"max_line_length": 95,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "92af4d620febd47a9791d466d747278dc4a417aa",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/agda-binary",
"max_stars_repo_path": "Data/Binary/Tests/Helpers.agda",
"max_stars_repo_stars_event_max_datetime": "2019-03-21T21:30:10.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-03-21T21:30:10.000Z",
"num_tokens": 380,
"size": 829
} |
module Data.Tuple.Equivalence where
import Lvl
open import Data using (Unit ; <>)
open import Data.Tuple as Tuple using (_⨯_ ; _,_)
open import Logic.Propositional
open import Structure.Setoid
open import Structure.Function
open import Structure.Operator
open import Structure.Relator.Equivalence
open import Structure.Relator.Properties
open import Type
private variable ℓₒ ℓₒ₁ ℓₒ₂ ℓₒ₃ ℓₒ₄ ℓₑ ℓₑ₁ ℓₑ₂ ℓₑ₃ ℓₑ₄ : Lvl.Level
module _ {A : Type{ℓₒ₁}} ⦃ _ : Equiv{ℓₑ₁}(A) ⦄ {B : Type{ℓₒ₂}} ⦃ _ : Equiv{ℓₑ₂}(B) ⦄ where
instance
Tuple-equiv : Equiv(A ⨯ B)
_≡_ ⦃ Tuple-equiv ⦄ (x₁ , y₁) (x₂ , y₂) = (x₁ ≡ x₂) ∧ (y₁ ≡ y₂)
Equiv-equivalence ⦃ Tuple-equiv ⦄ = intro where
instance
[≡]-reflexivity : Reflexivity(_≡_ ⦃ Tuple-equiv ⦄)
Reflexivity.proof([≡]-reflexivity) = [∧]-intro (reflexivity(_≡_)) (reflexivity(_≡_))
instance
[≡]-symmetry : Symmetry(_≡_ ⦃ Tuple-equiv ⦄)
Symmetry.proof([≡]-symmetry) ([∧]-intro l r) = [∧]-intro (symmetry(_≡_) l) (symmetry(_≡_) r)
instance
[≡]-transitivity : Transitivity(_≡_ ⦃ Tuple-equiv ⦄)
Transitivity.proof([≡]-transitivity) ([∧]-intro l1 r1) ([∧]-intro l2 r2) = [∧]-intro (transitivity(_≡_) l1 l2) (transitivity(_≡_) r1 r2)
instance
left-function : Function(Tuple.left)
Function.congruence left-function = Tuple.left
instance
right-function : Function(Tuple.right)
Function.congruence right-function = Tuple.right
instance
[,]-function : BinaryOperator(_,_)
BinaryOperator.congruence [,]-function a b = (a , b)
module _ {A : Type{ℓₒ₁}} ⦃ equiv-A : Equiv{ℓₑ₁}(A) ⦄ {B : Type{ℓₒ₂}} ⦃ equiv-B : Equiv{ℓₑ₂}(B) ⦄ where
instance
swap-function : Function ⦃ Tuple-equiv ⦃ equiv-A ⦄ ⦃ equiv-B ⦄ ⦄ ⦃ Tuple-equiv ⦄ (Tuple.swap)
Function.congruence swap-function = Tuple.swap
module _ {A : Type{ℓₒ}} ⦃ equiv : Equiv{ℓₑ}(A) ⦄ where
instance
repeat-function : Function(Tuple.repeat{A = A})
Function.congruence repeat-function = Tuple.repeat
module _
{A₁ : Type{ℓₒ₁}} ⦃ equiv-A₁ : Equiv{ℓₑ₁}(A₁) ⦄
{A₂ : Type{ℓₒ₂}} ⦃ equiv-A₂ : Equiv{ℓₑ₂}(A₂) ⦄
{B₁ : Type{ℓₒ₃}} ⦃ equiv-B₁ : Equiv{ℓₑ₃}(B₁) ⦄
{B₂ : Type{ℓₒ₄}} ⦃ equiv-B₂ : Equiv{ℓₑ₄}(B₂) ⦄
{f : A₁ → A₂} ⦃ func-f : Function(f) ⦄
{g : B₁ → B₂} ⦃ func-g : Function(g) ⦄
where
instance
map-function : Function(Tuple.map f g)
Function.congruence map-function = Tuple.map (congruence₁(f)) (congruence₁(g))
module _
{A : Type{ℓₒ₁}} ⦃ equiv-A : Equiv{ℓₑ₁}(A) ⦄
{B : Type{ℓₒ₂}} ⦃ equiv-B : Equiv{ℓₑ₂}(B) ⦄
{C : Type{ℓₒ₃}} ⦃ equiv-C : Equiv{ℓₑ₃}(C) ⦄
where
instance
associateLeft-function : Function(Tuple.associateLeft {A = A}{B = B}{C = C})
Function.congruence associateLeft-function = Tuple.associateLeft
instance
associateRight-function : Function(Tuple.associateRight {A = A}{B = B}{C = C})
Function.congruence associateRight-function = Tuple.associateRight
| {
"alphanum_fraction": 0.6456477039,
"avg_line_length": 36.024691358,
"ext": "agda",
"hexsha": "17d9f8e8a651f5d4bebf493df6ee33958ab0769e",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Data/Tuple/Equivalence.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Data/Tuple/Equivalence.agda",
"max_line_length": 144,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Data/Tuple/Equivalence.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": 1195,
"size": 2918
} |
{-# OPTIONS --safe --experimental-lossy-unification #-}
module Cubical.ZCohomology.Groups.CP2 where
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Function
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Pointed
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Equiv
open import Cubical.Relation.Nullary
open import Cubical.Data.Empty as ⊥
open import Cubical.Data.Unit
open import Cubical.Data.Nat renaming (_+_ to _+ℕ_)
open import Cubical.Data.Nat.Order
open import Cubical.Data.Int
open import Cubical.Data.Sigma
open import Cubical.Algebra.Group
open import Cubical.Algebra.Group.Instances.Int
open import Cubical.Algebra.Group.Morphisms
open import Cubical.Algebra.Group.MorphismProperties
open import Cubical.Algebra.Group.Instances.Unit
open import Cubical.HITs.Pushout
open import Cubical.HITs.S1
open import Cubical.HITs.Sn
open import Cubical.HITs.Susp
open import Cubical.HITs.Join
open import Cubical.HITs.SetTruncation as ST
open import Cubical.HITs.PropositionalTruncation as PT
open import Cubical.HITs.Truncation
open import Cubical.Homotopy.Hopf
open import Cubical.ZCohomology.Base
open import Cubical.ZCohomology.Groups.Connected
open import Cubical.ZCohomology.GroupStructure
open import Cubical.ZCohomology.Properties
open import Cubical.ZCohomology.MayerVietorisUnreduced
open import Cubical.ZCohomology.Groups.Unit
open import Cubical.ZCohomology.Groups.Sn
open import Cubical.ZCohomology.RingStructure.CupProduct
open S¹Hopf
open IsGroupHom
open Iso
CP² : Type
CP² = Pushout {A = TotalHopf} fst λ _ → tt
characFunSpaceCP² : ∀ {ℓ} {A : Type ℓ}
→ Iso (CP² → A) (Σ[ x ∈ A ] Σ[ f ∈ (S₊ (suc (suc zero)) → A) ]
((y : TotalHopf) → f (fst y) ≡ x))
fun characFunSpaceCP² f = (f (inr tt)) , ((f ∘ inl ) , (λ a → cong f (push a)))
inv characFunSpaceCP² (a , f , p) (inl x) = f x
inv characFunSpaceCP² (a , f , p) (inr x) = a
inv characFunSpaceCP² (a , f , p) (push b i) = p b i
rightInv characFunSpaceCP² _ = refl
leftInv characFunSpaceCP² _ =
funExt λ { (inl x) → refl
; (inr x) → refl
; (push a i) → refl}
H⁰CP²≅ℤ : GroupIso (coHomGr 0 CP²) ℤGroup
H⁰CP²≅ℤ =
H⁰-connected (inr tt)
(PushoutToProp (λ _ → squash₁)
(sphereElim _ (λ _ → isOfHLevelSuc 1 squash₁)
∣ sym (push (north , base)) ∣₁)
λ _ → ∣ refl ∣₁)
module M = MV (S₊ 2) Unit TotalHopf fst (λ _ → tt)
H²CP²≅ℤ : GroupIso (coHomGr 2 CP²) ℤGroup
H²CP²≅ℤ = compGroupIso (BijectionIso→GroupIso bij)
(compGroupIso (invGroupIso trivIso) (Hⁿ-Sⁿ≅ℤ 1))
where
isContrH¹TotalHopf : isContr (coHom 1 TotalHopf)
isContrH¹TotalHopf =
isOfHLevelRetractFromIso 0 (setTruncIso (domIso (invIso (IsoS³TotalHopf))))
(isOfHLevelRetractFromIso 0 ((fst (H¹-Sⁿ≅0 1))) isContrUnit)
isContrH²TotalHopf : isContr (coHom 2 TotalHopf)
isContrH²TotalHopf =
isOfHLevelRetractFromIso 0 (setTruncIso (domIso (invIso (IsoS³TotalHopf))))
((isOfHLevelRetractFromIso 0
(fst (Hⁿ-Sᵐ≅0 1 2 λ p → snotz (sym (cong predℕ p)))) isContrUnit))
trivIso : GroupIso (coHomGr 2 (Susp S¹)) (×coHomGr 2 (Susp S¹) Unit)
fun (fst trivIso) x = x , 0ₕ _
inv (fst trivIso) = fst
rightInv (fst trivIso) (x , p) =
ΣPathP (refl , isContr→isProp (isContrHⁿ-Unit 1) _ _)
leftInv (fst trivIso) x = refl
snd trivIso = makeIsGroupHom λ _ _ → refl
bij : BijectionIso (coHomGr 2 CP²) (×coHomGr 2 (Susp S¹) Unit)
BijectionIso.fun bij = M.i 2
BijectionIso.inj bij x p =
PT.rec (squash₂ _ _)
(uncurry (λ z q
→ sym q
∙∙ cong (fst (M.d 1)) (isContr→isProp isContrH¹TotalHopf z (0ₕ _))
∙∙ (M.d 1) .snd .pres1))
(M.Ker-i⊂Im-d 1 x p)
where
help : isInIm (M.d 1) x
help = M.Ker-i⊂Im-d 1 x p
BijectionIso.surj bij y =
M.Ker-Δ⊂Im-i 2 y (isContr→isProp isContrH²TotalHopf _ _)
H⁴CP²≅ℤ : GroupIso (coHomGr 4 CP²) ℤGroup
H⁴CP²≅ℤ = compGroupIso (invGroupIso (BijectionIso→GroupIso bij))
(compGroupIso help (Hⁿ-Sⁿ≅ℤ 2))
where
help : GroupIso (coHomGr 3 TotalHopf) (coHomGr 3 (S₊ 3))
help = isoType→isoCohom 3 (invIso IsoS³TotalHopf)
bij : BijectionIso (coHomGr 3 TotalHopf) (coHomGr 4 CP²)
BijectionIso.fun bij = M.d 3
BijectionIso.inj bij x p =
PT.rec (squash₂ _ _)
(uncurry (λ z q →
sym q
∙∙ cong (M.Δ 3 .fst)
(isOfHLevelΣ 1 (isContr→isProp
(isOfHLevelRetractFromIso 0
(fst (Hⁿ-Sᵐ≅0 2 1 λ p → snotz (cong predℕ p))) isContrUnit))
(λ _ → isContr→isProp (isContrHⁿ-Unit 2))
z (0ₕ _ , 0ₕ _))
∙∙ M.Δ 3 .snd .pres1))
(M.Ker-d⊂Im-Δ _ x p)
BijectionIso.surj bij y =
M.Ker-i⊂Im-d 3 y (isOfHLevelΣ 1
(isContr→isProp (isOfHLevelRetractFromIso 0
(fst (Hⁿ-Sᵐ≅0 3 1 λ p → snotz (cong predℕ p))) isContrUnit))
(λ _ → isContr→isProp (isContrHⁿ-Unit _)) _ _)
-- Characterisations of the trivial groups
private
elim-TotalHopf : (B : TotalHopf → Type)
→ ((x : _) → isOfHLevel 3 (B x)) → B (north , base)
→ (x : _) → B x
elim-TotalHopf =
transport (λ i → (B : isoToPath IsoS³TotalHopf i → Type)
→ ((x : _) → isOfHLevel 3 (B x))
→ B (transp (λ j → isoToPath IsoS³TotalHopf (i ∨ ~ j)) i (north , base)) → (x : _) → B x)
λ B hLev elim-TotalHopf → sphereElim _ (λ _ → hLev _) elim-TotalHopf
H¹-CP²≅0 : GroupIso (coHomGr 1 CP²) UnitGroup₀
H¹-CP²≅0 =
contrGroupIsoUnit
(isOfHLevelRetractFromIso 0 (setTruncIso characFunSpaceCP²)
(isOfHLevelRetractFromIso 0 lem₂ lem₃))
where
lem₁ : (f : (Susp S¹ → coHomK 1)) → ∥ (λ _ → 0ₖ _) ≡ f ∥₁
lem₁ f = PT.map (λ p → p)
(Iso.fun PathIdTrunc₀Iso (isOfHLevelRetractFromIso 1
(fst (Hⁿ-Sᵐ≅0 0 1 (λ p → snotz (sym p)))) isPropUnit (0ₕ _) ∣ f ∣₂))
lem₂ : Iso ∥ (Σ[ x ∈ coHomK 1 ] ( Σ[ f ∈ (Susp S¹ → coHomK 1) ] ((y : TotalHopf) → f (fst y) ≡ x))) ∥₂
∥ (Σ[ f ∈ (Susp S¹ → coHomK 1) ] ((y : TotalHopf) → f (fst y) ≡ 0ₖ 1)) ∥₂
fun lem₂ = ST.map (uncurry λ x → uncurry λ f p → (λ y → (-ₖ x) +ₖ f y) , λ y → cong ((-ₖ x) +ₖ_) (p y) ∙ lCancelₖ _ x)
inv lem₂ = ST.map λ p → 0ₖ _ , p
rightInv lem₂ =
ST.elim (λ _ → isOfHLevelPath 2 squash₂ _ _)
λ {(f , p) → cong ∣_∣₂ (ΣPathP ((funExt (λ x → lUnitₖ _ (f x)))
, (funExt (λ y → sym (rUnit (λ i → (-ₖ 0ₖ 1) +ₖ p y i)))
◁ λ j y i → lUnitₖ _ (p y i) j)))}
leftInv lem₂ =
ST.elim (λ _ → isOfHLevelPath 2 squash₂ _ _)
(uncurry (coHomK-elim _ (λ _ → isPropΠ (λ _ → squash₂ _ _))
(uncurry λ f p → cong ∣_∣₂ (ΣPathP (refl , (ΣPathP ((funExt (λ x → lUnitₖ _ (f x)))
, ((funExt (λ y → sym (rUnit (λ i → (-ₖ 0ₖ 1) +ₖ p y i)))
◁ λ j y i → lUnitₖ _ (p y i) j)))))))))
lem₃ : isContr _
fst lem₃ = ∣ (λ _ → 0ₖ 1) , (λ _ → refl) ∣₂
snd lem₃ =
ST.elim (λ _ → isOfHLevelPath 2 squash₂ _ _)
(uncurry λ f → PT.rec (isPropΠ (λ _ → squash₂ _ _))
(J (λ f _ → (y : (y₁ : TotalHopf) → f (fst y₁) ≡ 0ₖ 1) →
∣ (λ _ → 0ₖ 1) , (λ _ _ → 0ₖ 1) ∣₂ ≡ ∣ f , y ∣₂)
(λ y → cong ∣_∣₂ (ΣPathP ((funExt (λ z → sym (y (north , base)))) , toPathP (s y)))))
(lem₁ f))
where
s : (y : TotalHopf → 0ₖ 1 ≡ 0ₖ 1)
→ transport (λ i → (_ : TotalHopf) → y (north , base) (~ i) ≡ ∣ base ∣)
(λ _ _ → 0ₖ 1) ≡ y
s y = funExt (elim-TotalHopf _ (λ _ → isOfHLevelPath 3 (isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _) _ _)
λ k → transp (λ i → y (north , base) (~ i ∧ ~ k) ≡ ∣ base ∣) k
λ j → y (north , base) (~ k ∨ j))
Hⁿ-CP²≅0-higher : (n : ℕ) → ¬ (n ≡ 1) → GroupIso (coHomGr (3 +ℕ n) CP²) UnitGroup₀
Hⁿ-CP²≅0-higher n p = contrGroupIsoUnit ((0ₕ _) , (λ x → sym (main x)))
where
h : GroupHom (coHomGr (2 +ℕ n) TotalHopf) (coHomGr (3 +ℕ n) CP²)
h = M.d (2 +ℕ n)
propᵣ : isProp (fst (×coHomGr (3 +ℕ n) (Susp S¹) Unit))
propᵣ =
isPropΣ
(isOfHLevelRetractFromIso 1
(fst (Hⁿ-Sᵐ≅0 (2 +ℕ n) 1 λ p → ⊥.rec (snotz (cong predℕ p)))) isPropUnit)
λ _ → isContr→isProp (isContrHⁿ-Unit _)
propₗ : isProp (coHom (2 +ℕ n) TotalHopf)
propₗ = subst (λ x → isProp (coHom (2 +ℕ n) x)) (isoToPath IsoS³TotalHopf)
(isOfHLevelRetractFromIso 1
(fst (Hⁿ-Sᵐ≅0 (suc n) 2 λ q → p (cong predℕ q))) isPropUnit)
inIm : (x : coHom (3 +ℕ n) CP²) → isInIm h x
inIm x = M.Ker-i⊂Im-d (2 +ℕ n) x (propᵣ _ _)
main : (x : coHom (3 +ℕ n) CP²) → x ≡ 0ₕ _
main x =
PT.rec (squash₂ _ _)
(uncurry (λ f p → sym p ∙∙ cong (h .fst) (propₗ f (0ₕ _)) ∙∙ pres1 (snd h)))
(inIm x)
-- All trivial groups:
Hⁿ-CP²≅0 : (n : ℕ) → ¬ suc n ≡ 2 → ¬ suc n ≡ 4
→ GroupIso (coHomGr (suc n) CP²) UnitGroup₀
Hⁿ-CP²≅0 zero p q = H¹-CP²≅0
Hⁿ-CP²≅0 (suc zero) p q = ⊥.rec (p refl)
Hⁿ-CP²≅0 (suc (suc zero)) p q = Hⁿ-CP²≅0-higher 0 λ p → snotz (sym p)
Hⁿ-CP²≅0 (suc (suc (suc zero))) p q = ⊥.rec (q refl)
Hⁿ-CP²≅0 (suc (suc (suc (suc n)))) p q =
Hⁿ-CP²≅0-higher (suc (suc n))
λ p → snotz (cong predℕ p)
-- Another Brunerie number
ℤ→HⁿCP²→ℤ : ℤ → ℤ
ℤ→HⁿCP²→ℤ x =
Iso.fun (fst H⁴CP²≅ℤ)
(Iso.inv (fst H²CP²≅ℤ) x ⌣ Iso.inv (fst H²CP²≅ℤ) x)
brunerie2 : ℤ
brunerie2 = ℤ→HⁿCP²→ℤ 1
{-
|brunerie2|≡1 : abs (ℤ→HⁿCP²→ℤ 1) ≡ 1
|brunerie2|≡1 = refl
-}
| {
"alphanum_fraction": 0.6101260414,
"avg_line_length": 37.1507936508,
"ext": "agda",
"hexsha": "73d8f0d679e9d65fe0eb60f005f7929783b23546",
"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/ZCohomology/Groups/CP2.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/ZCohomology/Groups/CP2.agda",
"max_line_length": 120,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "thomas-lamiaux/cubical",
"max_stars_repo_path": "Cubical/ZCohomology/Groups/CP2.agda",
"max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z",
"num_tokens": 4031,
"size": 9362
} |
{-
This second-order equational theory was created from the following second-order syntax description:
syntax FOL
type
* : 0-ary
N : 0-ary
term
false : * | ⊥
or : * * -> * | _∨_ l20
true : * | ⊤
and : * * -> * | _∧_ l20
not : * -> * | ¬_ r50
eq : N N -> * | _≟_ l20
all : N.* -> * | ∀′
ex : N.* -> * | ∃′
theory
(⊥U∨ᴸ) a |> or (false, a) = a
(⊥U∨ᴿ) a |> or (a, false) = a
(∨A) a b c |> or (or(a, b), c) = or (a, or(b, c))
(∨C) a b |> or(a, b) = or(b, a)
(⊤U∧ᴸ) a |> and (true, a) = a
(⊤U∧ᴿ) a |> and (a, true) = a
(∧A) a b c |> and (and(a, b), c) = and (a, and(b, c))
(∧D∨ᴸ) a b c |> and (a, or (b, c)) = or (and(a, b), and(a, c))
(∧D∨ᴿ) a b c |> and (or (a, b), c) = or (and(a, c), and(b, c))
(⊥X∧ᴸ) a |> and (false, a) = false
(⊥X∧ᴿ) a |> and (a, false) = false
(¬N∨ᴸ) a |> or (not (a), a) = false
(¬N∨ᴿ) a |> or (a, not (a)) = false
(∧C) a b |> and(a, b) = and(b, a)
(∨I) a |> or(a, a) = a
(∧I) a |> and(a, a) = a
(¬²) a |> not(not (a)) = a
(∨D∧ᴸ) a b c |> or (a, and (b, c)) = and (or(a, b), or(a, c))
(∨D∧ᴿ) a b c |> or (and (a, b), c) = and (or(a, c), or(b, c))
(∨B∧ᴸ) a b |> or (and (a, b), a) = a
(∨B∧ᴿ) a b |> or (a, and (a, b)) = a
(∧B∨ᴸ) a b |> and (or (a, b), a) = a
(∧B∨ᴿ) a b |> and (a, or (a, b)) = a
(⊤X∨ᴸ) a |> or (true, a) = true
(⊤X∨ᴿ) a |> or (a, true) = true
(¬N∧ᴸ) a |> and (not (a), a) = false
(¬N∧ᴿ) a |> and (a, not (a)) = false
(DM∧) a b |> not (and (a, b)) = or (not(a), not(b))
(DM∨) a b |> not (or (a, b)) = and (not(a), not(b))
(DM∀) p : N.* |> not (all (x. p[x])) = ex (x. not(p[x]))
(DM∃) p : N.* |> not (ex (x. p[x])) = all (x. not(p[x]))
(∀D∧) p q : N.* |> all (x. and(p[x], q[x])) = and (all(x.p[x]), all(x.q[x]))
(∃D∨) p q : N.* |> ex (x. or(p[x], q[x])) = or (ex(x.p[x]), ex(x.q[x]))
(∧P∀ᴸ) p : * q : N.* |> and (p, all(x.q[x])) = all (x. and(p, q[x]))
(∧P∃ᴸ) p : * q : N.* |> and (p, ex (x.q[x])) = ex (x. and(p, q[x]))
(∨P∀ᴸ) p : * q : N.* |> or (p, all(x.q[x])) = all (x. or (p, q[x]))
(∨P∃ᴸ) p : * q : N.* |> or (p, ex (x.q[x])) = ex (x. or (p, q[x]))
(∧P∀ᴿ) p : N.* q : * |> and (all(x.p[x]), q) = all (x. and(p[x], q))
(∧P∃ᴿ) p : N.* q : * |> and (ex (x.p[x]), q) = ex (x. and(p[x], q))
(∨P∀ᴿ) p : N.* q : * |> or (all(x.p[x]), q) = all (x. or (p[x], q))
(∨P∃ᴿ) p : N.* q : * |> or (ex (x.p[x]), q) = ex (x. or (p[x], q))
(∀Eᴸ) p : N.* n : N |> all (x.p[x]) = and (p[n], all(x.p[x]))
(∃Eᴸ) p : N.* n : N |> ex (x.p[x]) = or (p[n], ex (x.p[x]))
(∀Eᴿ) p : N.* n : N |> all (x.p[x]) = and (all(x.p[x]), p[n])
(∃Eᴿ) p : N.* n : N |> ex (x.p[x]) = or (ex (x.p[x]), p[n])
(∃⟹) p : N.* q : * |> imp (ex (x.p[x]), q) = all (x. imp(p[x], q))
(∀⟹) p : N.* q : * |> imp (all(x.p[x]), q) = ex (x. imp(p[x], q))
-}
module FOL.Equality where
open import SOAS.Common
open import SOAS.Context
open import SOAS.Variable
open import SOAS.Families.Core
open import SOAS.Families.Build
open import SOAS.ContextMaps.Inductive
open import FOL.Signature
open import FOL.Syntax
open import SOAS.Metatheory.SecondOrder.Metasubstitution FOL:Syn
open import SOAS.Metatheory.SecondOrder.Equality FOL:Syn
private
variable
α β γ τ : FOLT
Γ Δ Π : Ctx
infix 1 _▹_⊢_≋ₐ_
-- Axioms of equality
data _▹_⊢_≋ₐ_ : ∀ 𝔐 Γ {α} → (𝔐 ▷ FOL) α Γ → (𝔐 ▷ FOL) α Γ → Set where
⊥U∨ᴸ : ⁅ * ⁆̣ ▹ ∅ ⊢ ⊥ ∨ 𝔞 ≋ₐ 𝔞
∨A : ⁅ * ⁆ ⁅ * ⁆ ⁅ * ⁆̣ ▹ ∅ ⊢ (𝔞 ∨ 𝔟) ∨ 𝔠 ≋ₐ 𝔞 ∨ (𝔟 ∨ 𝔠)
∨C : ⁅ * ⁆ ⁅ * ⁆̣ ▹ ∅ ⊢ 𝔞 ∨ 𝔟 ≋ₐ 𝔟 ∨ 𝔞
⊤U∧ᴸ : ⁅ * ⁆̣ ▹ ∅ ⊢ ⊤ ∧ 𝔞 ≋ₐ 𝔞
∧A : ⁅ * ⁆ ⁅ * ⁆ ⁅ * ⁆̣ ▹ ∅ ⊢ (𝔞 ∧ 𝔟) ∧ 𝔠 ≋ₐ 𝔞 ∧ (𝔟 ∧ 𝔠)
∧D∨ᴸ : ⁅ * ⁆ ⁅ * ⁆ ⁅ * ⁆̣ ▹ ∅ ⊢ 𝔞 ∧ (𝔟 ∨ 𝔠) ≋ₐ (𝔞 ∧ 𝔟) ∨ (𝔞 ∧ 𝔠)
⊥X∧ᴸ : ⁅ * ⁆̣ ▹ ∅ ⊢ ⊥ ∧ 𝔞 ≋ₐ ⊥
¬N∨ᴸ : ⁅ * ⁆̣ ▹ ∅ ⊢ (¬ 𝔞) ∨ 𝔞 ≋ₐ ⊥
∧C : ⁅ * ⁆ ⁅ * ⁆̣ ▹ ∅ ⊢ 𝔞 ∧ 𝔟 ≋ₐ 𝔟 ∧ 𝔞
∨I : ⁅ * ⁆̣ ▹ ∅ ⊢ 𝔞 ∨ 𝔞 ≋ₐ 𝔞
∧I : ⁅ * ⁆̣ ▹ ∅ ⊢ 𝔞 ∧ 𝔞 ≋ₐ 𝔞
¬² : ⁅ * ⁆̣ ▹ ∅ ⊢ ¬ (¬ 𝔞) ≋ₐ 𝔞
∨D∧ᴸ : ⁅ * ⁆ ⁅ * ⁆ ⁅ * ⁆̣ ▹ ∅ ⊢ 𝔞 ∨ (𝔟 ∧ 𝔠) ≋ₐ (𝔞 ∨ 𝔟) ∧ (𝔞 ∨ 𝔠)
∨B∧ᴸ : ⁅ * ⁆ ⁅ * ⁆̣ ▹ ∅ ⊢ (𝔞 ∧ 𝔟) ∨ 𝔞 ≋ₐ 𝔞
∧B∨ᴸ : ⁅ * ⁆ ⁅ * ⁆̣ ▹ ∅ ⊢ (𝔞 ∨ 𝔟) ∧ 𝔞 ≋ₐ 𝔞
⊤X∨ᴸ : ⁅ * ⁆̣ ▹ ∅ ⊢ ⊤ ∨ 𝔞 ≋ₐ ⊤
¬N∧ᴸ : ⁅ * ⁆̣ ▹ ∅ ⊢ (¬ 𝔞) ∧ 𝔞 ≋ₐ ⊥
DM∧ : ⁅ * ⁆ ⁅ * ⁆̣ ▹ ∅ ⊢ ¬ (𝔞 ∧ 𝔟) ≋ₐ (¬ 𝔞) ∨ (¬ 𝔟)
DM∨ : ⁅ * ⁆ ⁅ * ⁆̣ ▹ ∅ ⊢ ¬ (𝔞 ∨ 𝔟) ≋ₐ (¬ 𝔞) ∧ (¬ 𝔟)
DM∀ : ⁅ N ⊩ * ⁆̣ ▹ ∅ ⊢ ¬ (∀′ (𝔞⟨ x₀ ⟩)) ≋ₐ ∃′ (¬ 𝔞⟨ x₀ ⟩)
DM∃ : ⁅ N ⊩ * ⁆̣ ▹ ∅ ⊢ ¬ (∃′ (𝔞⟨ x₀ ⟩)) ≋ₐ ∀′ (¬ 𝔞⟨ x₀ ⟩)
∀D∧ : ⁅ N ⊩ * ⁆ ⁅ N ⊩ * ⁆̣ ▹ ∅ ⊢ ∀′ (𝔞⟨ x₀ ⟩ ∧ 𝔟⟨ x₀ ⟩) ≋ₐ (∀′ (𝔞⟨ x₀ ⟩)) ∧ (∀′ (𝔟⟨ x₀ ⟩))
∃D∨ : ⁅ N ⊩ * ⁆ ⁅ N ⊩ * ⁆̣ ▹ ∅ ⊢ ∃′ (𝔞⟨ x₀ ⟩ ∨ 𝔟⟨ x₀ ⟩) ≋ₐ (∃′ (𝔞⟨ x₀ ⟩)) ∨ (∃′ (𝔟⟨ x₀ ⟩))
∧P∀ᴸ : ⁅ * ⁆ ⁅ N ⊩ * ⁆̣ ▹ ∅ ⊢ 𝔞 ∧ (∀′ (𝔟⟨ x₀ ⟩)) ≋ₐ ∀′ (𝔞 ∧ 𝔟⟨ x₀ ⟩)
∧P∃ᴸ : ⁅ * ⁆ ⁅ N ⊩ * ⁆̣ ▹ ∅ ⊢ 𝔞 ∧ (∃′ (𝔟⟨ x₀ ⟩)) ≋ₐ ∃′ (𝔞 ∧ 𝔟⟨ x₀ ⟩)
∨P∀ᴸ : ⁅ * ⁆ ⁅ N ⊩ * ⁆̣ ▹ ∅ ⊢ 𝔞 ∨ (∀′ (𝔟⟨ x₀ ⟩)) ≋ₐ ∀′ (𝔞 ∨ 𝔟⟨ x₀ ⟩)
∨P∃ᴸ : ⁅ * ⁆ ⁅ N ⊩ * ⁆̣ ▹ ∅ ⊢ 𝔞 ∨ (∃′ (𝔟⟨ x₀ ⟩)) ≋ₐ ∃′ (𝔞 ∨ 𝔟⟨ x₀ ⟩)
∀Eᴸ : ⁅ N ⊩ * ⁆ ⁅ N ⁆̣ ▹ ∅ ⊢ ∀′ (𝔞⟨ x₀ ⟩) ≋ₐ 𝔞⟨ 𝔟 ⟩ ∧ (∀′ (𝔞⟨ x₀ ⟩))
∃Eᴸ : ⁅ N ⊩ * ⁆ ⁅ N ⁆̣ ▹ ∅ ⊢ ∃′ (𝔞⟨ x₀ ⟩) ≋ₐ 𝔞⟨ 𝔟 ⟩ ∨ (∃′ (𝔞⟨ x₀ ⟩))
open EqLogic _▹_⊢_≋ₐ_
open ≋-Reasoning
-- Derived equations
⊥U∨ᴿ : ⁅ * ⁆̣ ▹ ∅ ⊢ 𝔞 ∨ ⊥ ≋ 𝔞
⊥U∨ᴿ = tr (ax ∨C with《 𝔞 ◃ ⊥ 》) (ax ⊥U∨ᴸ with《 𝔞 》)
⊤U∧ᴿ : ⁅ * ⁆̣ ▹ ∅ ⊢ 𝔞 ∧ ⊤ ≋ 𝔞
⊤U∧ᴿ = tr (ax ∧C with《 𝔞 ◃ ⊤ 》) (ax ⊤U∧ᴸ with《 𝔞 》)
∧D∨ᴿ : ⁅ * ⁆ ⁅ * ⁆ ⁅ * ⁆̣ ▹ ∅ ⊢ (𝔞 ∨ 𝔟) ∧ 𝔠 ≋ (𝔞 ∧ 𝔠) ∨ (𝔟 ∧ 𝔠)
∧D∨ᴿ = begin
(𝔞 ∨ 𝔟) ∧ 𝔠 ≋⟨ ax ∧C with《 𝔞 ∨ 𝔟 ◃ 𝔠 》 ⟩
𝔠 ∧ (𝔞 ∨ 𝔟) ≋⟨ ax ∧D∨ᴸ with《 𝔠 ◃ 𝔞 ◃ 𝔟 》 ⟩
(𝔠 ∧ 𝔞) ∨ (𝔠 ∧ 𝔟) ≋⟨ cong₂[ ax ∧C with《 𝔠 ◃ 𝔞 》 ][ ax ∧C with《 𝔠 ◃ 𝔟 》 ]inside ◌ᵈ ∨ ◌ᵉ ⟩
(𝔞 ∧ 𝔠) ∨ (𝔟 ∧ 𝔠) ∎
⊥X∧ᴿ : ⁅ * ⁆̣ ▹ ∅ ⊢ 𝔞 ∧ ⊥ ≋ ⊥
⊥X∧ᴿ = tr (ax ∧C with《 𝔞 ◃ ⊥ 》) (ax ⊥X∧ᴸ with《 𝔞 》)
¬N∨ᴿ : ⁅ * ⁆̣ ▹ ∅ ⊢ 𝔞 ∨ (¬ 𝔞) ≋ ⊥
¬N∨ᴿ = tr (ax ∨C with《 𝔞 ◃ (¬ 𝔞) 》) (ax ¬N∨ᴸ with《 𝔞 》)
∨D∧ᴿ : ⁅ * ⁆ ⁅ * ⁆ ⁅ * ⁆̣ ▹ ∅ ⊢ (𝔞 ∧ 𝔟) ∨ 𝔠 ≋ (𝔞 ∨ 𝔠) ∧ (𝔟 ∨ 𝔠)
∨D∧ᴿ = begin
(𝔞 ∧ 𝔟) ∨ 𝔠 ≋⟨ ax ∨C with《 𝔞 ∧ 𝔟 ◃ 𝔠 》 ⟩
𝔠 ∨ (𝔞 ∧ 𝔟) ≋⟨ ax ∨D∧ᴸ with《 𝔠 ◃ 𝔞 ◃ 𝔟 》 ⟩
(𝔠 ∨ 𝔞) ∧ (𝔠 ∨ 𝔟) ≋⟨ cong₂[ ax ∨C with《 𝔠 ◃ 𝔞 》 ][ ax ∨C with《 𝔠 ◃ 𝔟 》 ]inside ◌ᵈ ∧ ◌ᵉ ⟩
(𝔞 ∨ 𝔠) ∧ (𝔟 ∨ 𝔠) ∎
⊤X∨ᴿ : ⁅ * ⁆̣ ▹ ∅ ⊢ 𝔞 ∨ ⊤ ≋ ⊤
⊤X∨ᴿ = tr (ax ∨C with《 𝔞 ◃ ⊤ 》) (ax ⊤X∨ᴸ with《 𝔞 》)
¬N∧ᴿ : ⁅ * ⁆̣ ▹ ∅ ⊢ 𝔞 ∧ (¬ 𝔞) ≋ ⊥
¬N∧ᴿ = tr (ax ∧C with《 𝔞 ◃ (¬ 𝔞) 》) (ax ¬N∧ᴸ with《 𝔞 》)
∧P∀ᴿ : ⁅ N ⊩ * ⁆ ⁅ * ⁆̣ ▹ ∅ ⊢ (∀′ (𝔞⟨ x₀ ⟩)) ∧ 𝔟 ≋ ∀′ (𝔞⟨ x₀ ⟩ ∧ 𝔟)
∧P∀ᴿ = begin
(∀′ (𝔞⟨ x₀ ⟩)) ∧ 𝔟 ≋⟨ ax ∧C with《 ∀′ (𝔞⟨ x₀ ⟩) ◃ 𝔟 》 ⟩
𝔟 ∧ (∀′ (𝔞⟨ x₀ ⟩)) ≋⟨ ax ∧P∀ᴸ with《 𝔟 ◃ 𝔞⟨ x₀ ⟩ 》 ⟩
∀′ (𝔟 ∧ 𝔞⟨ x₀ ⟩) ≋⟨ cong[ ax ∧C with《 𝔟 ◃ 𝔞⟨ x₀ ⟩ 》 ]inside ∀′ (◌ᶜ⟨ x₀ ⟩) ⟩
∀′ (𝔞⟨ x₀ ⟩ ∧ 𝔟) ∎
∧P∃ᴿ : ⁅ N ⊩ * ⁆ ⁅ * ⁆̣ ▹ ∅ ⊢ (∃′ (𝔞⟨ x₀ ⟩)) ∧ 𝔟 ≋ ∃′ (𝔞⟨ x₀ ⟩ ∧ 𝔟)
∧P∃ᴿ = begin
(∃′ (𝔞⟨ x₀ ⟩)) ∧ 𝔟 ≋⟨ ax ∧C with《 ∃′ (𝔞⟨ x₀ ⟩) ◃ 𝔟 》 ⟩
𝔟 ∧ (∃′ (𝔞⟨ x₀ ⟩)) ≋⟨ ax ∧P∃ᴸ with《 𝔟 ◃ 𝔞⟨ x₀ ⟩ 》 ⟩
∃′ (𝔟 ∧ 𝔞⟨ x₀ ⟩) ≋⟨ cong[ ax ∧C with《 𝔟 ◃ 𝔞⟨ x₀ ⟩ 》 ]inside ∃′ (◌ᶜ⟨ x₀ ⟩) ⟩
∃′ (𝔞⟨ x₀ ⟩ ∧ 𝔟) ∎
∨P∀ᴿ : ⁅ N ⊩ * ⁆ ⁅ * ⁆̣ ▹ ∅ ⊢ (∀′ (𝔞⟨ x₀ ⟩)) ∨ 𝔟 ≋ ∀′ (𝔞⟨ x₀ ⟩ ∨ 𝔟)
∨P∀ᴿ = begin
(∀′ (𝔞⟨ x₀ ⟩)) ∨ 𝔟 ≋⟨ ax ∨C with《 ∀′ (𝔞⟨ x₀ ⟩) ◃ 𝔟 》 ⟩
𝔟 ∨ (∀′ (𝔞⟨ x₀ ⟩)) ≋⟨ ax ∨P∀ᴸ with《 𝔟 ◃ 𝔞⟨ x₀ ⟩ 》 ⟩
∀′ (𝔟 ∨ 𝔞⟨ x₀ ⟩) ≋⟨ cong[ ax ∨C with《 𝔟 ◃ 𝔞⟨ x₀ ⟩ 》 ]inside ∀′ (◌ᶜ⟨ x₀ ⟩) ⟩
∀′ (𝔞⟨ x₀ ⟩ ∨ 𝔟) ∎
∨P∃ᴿ : ⁅ N ⊩ * ⁆ ⁅ * ⁆̣ ▹ ∅ ⊢ (∃′ (𝔞⟨ x₀ ⟩)) ∨ 𝔟 ≋ ∃′ (𝔞⟨ x₀ ⟩ ∨ 𝔟)
∨P∃ᴿ = begin
(∃′ (𝔞⟨ x₀ ⟩)) ∨ 𝔟 ≋⟨ ax ∨C with《 ∃′ (𝔞⟨ x₀ ⟩) ◃ 𝔟 》 ⟩
𝔟 ∨ (∃′ (𝔞⟨ x₀ ⟩)) ≋⟨ ax ∨P∃ᴸ with《 𝔟 ◃ 𝔞⟨ x₀ ⟩ 》 ⟩
∃′ (𝔟 ∨ 𝔞⟨ x₀ ⟩) ≋⟨ cong[ ax ∨C with《 𝔟 ◃ 𝔞⟨ x₀ ⟩ 》 ]inside ∃′ (◌ᶜ⟨ x₀ ⟩) ⟩
∃′ (𝔞⟨ x₀ ⟩ ∨ 𝔟) ∎
∀Eᴿ : ⁅ N ⊩ * ⁆ ⁅ N ⁆̣ ▹ ∅ ⊢ ∀′ (𝔞⟨ x₀ ⟩) ≋ (∀′ (𝔞⟨ x₀ ⟩)) ∧ 𝔞⟨ 𝔟 ⟩
∀Eᴿ = tr (ax ∀Eᴸ with《 𝔞⟨ x₀ ⟩ ◃ 𝔟 》) (ax ∧C with《 𝔞⟨ 𝔟 ⟩ ◃ ∀′ (𝔞⟨ x₀ ⟩) 》)
∃Eᴿ : ⁅ N ⊩ * ⁆ ⁅ N ⁆̣ ▹ ∅ ⊢ ∃′ (𝔞⟨ x₀ ⟩) ≋ (∃′ (𝔞⟨ x₀ ⟩)) ∨ 𝔞⟨ 𝔟 ⟩
∃Eᴿ = tr (ax ∃Eᴸ with《 𝔞⟨ x₀ ⟩ ◃ 𝔟 》) (ax ∨C with《 𝔞⟨ 𝔟 ⟩ ◃ ∃′ (𝔞⟨ x₀ ⟩) 》)
∃⟹ : ⁅ N ⊩ * ⁆ ⁅ * ⁆̣ ▹ ∅ ⊢ (∃′ (𝔞⟨ x₀ ⟩)) ⟹ 𝔟 ≋ ∀′ (𝔞⟨ x₀ ⟩ ⟹ 𝔟)
∃⟹ = begin
(∃′ (𝔞⟨ x₀ ⟩)) ⟹ 𝔟 ≡⟨⟩
(¬ (∃′ (𝔞⟨ x₀ ⟩))) ∨ 𝔟 ≋⟨ cong[ ax DM∃ with《 𝔞⟨ x₀ ⟩ 》 ]inside (◌ᶜ ∨ 𝔟) ⟩
(∀′ (¬ (𝔞⟨ x₀ ⟩))) ∨ 𝔟 ≋⟨ thm ∨P∀ᴿ with《 ¬ 𝔞⟨ x₀ ⟩ ◃ 𝔟 》 ⟩
∀′ (¬ (𝔞⟨ x₀ ⟩) ∨ 𝔟) ≡⟨⟩
∀′ (𝔞⟨ x₀ ⟩ ⟹ 𝔟) ∎
∀⟹ : ⁅ N ⊩ * ⁆ ⁅ * ⁆̣ ▹ ∅ ⊢ (∀′ (𝔞⟨ x₀ ⟩)) ⟹ 𝔟 ≋ ∃′ (𝔞⟨ x₀ ⟩ ⟹ 𝔟)
∀⟹ = begin
(∀′ (𝔞⟨ x₀ ⟩)) ⟹ 𝔟 ≡⟨⟩
(¬ (∀′ (𝔞⟨ x₀ ⟩))) ∨ 𝔟 ≋⟨ cong[ ax DM∀ with《 𝔞⟨ x₀ ⟩ 》 ]inside (◌ᶜ ∨ 𝔟) ⟩
(∃′ (¬ (𝔞⟨ x₀ ⟩))) ∨ 𝔟 ≋⟨ thm ∨P∃ᴿ with《 ¬ 𝔞⟨ x₀ ⟩ ◃ 𝔟 》 ⟩
∃′ (¬ (𝔞⟨ x₀ ⟩) ∨ 𝔟) ≡⟨⟩
∃′ (𝔞⟨ x₀ ⟩ ⟹ 𝔟) ∎
| {
"alphanum_fraction": 0.2954155711,
"avg_line_length": 45.087628866,
"ext": "agda",
"hexsha": "be111a4f61035332eddfde8b9f4e0f8cac6eaff9",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z",
"max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "JoeyEremondi/agda-soas",
"max_forks_repo_path": "out/FOL/Equality.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8",
"max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "JoeyEremondi/agda-soas",
"max_issues_repo_path": "out/FOL/Equality.agda",
"max_line_length": 99,
"max_stars_count": 39,
"max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "JoeyEremondi/agda-soas",
"max_stars_repo_path": "out/FOL/Equality.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z",
"num_tokens": 6412,
"size": 8747
} |
{-# OPTIONS --without-K --safe #-}
module Categories.Category.Instance.Properties.Setoids where
open import Level
open import Data.Product using (Σ; proj₁; proj₂; _,_; Σ-syntax; _×_; -,_)
open import Function.Equality using (Π)
open import Relation.Binary using (Setoid; Preorder; Rel)
open import Relation.Binary.PropositionalEquality as ≡ using (_≡_)
open import Relation.Binary.Indexed.Heterogeneous using (_=[_]⇒_)
open import Relation.Binary.Construct.Closure.SymmetricTransitive as ST using (Plus⇔; minimal)
open Plus⇔
open import Categories.Category using (Category; _[_,_])
open import Categories.Functor
open import Categories.Category.Instance.Setoids
open import Categories.Category.Complete
open import Categories.Category.Cocomplete
import Categories.Category.Construction.Cocones as Coc
import Categories.Category.Construction.Cones as Co
import Relation.Binary.Reasoning.Setoid as RS
open Π using (_⟨$⟩_)
module _ {o ℓ e} c ℓ′ {J : Category o ℓ e} (F : Functor J (Setoids (o ⊔ c) (o ⊔ ℓ ⊔ c ⊔ ℓ′))) where
private
module J = Category J
open Functor F
module F₀ j = Setoid (F₀ j)
open F₀ using () renaming (_≈_ to _[_≈_])
vertex-carrier : Set (o ⊔ c)
vertex-carrier = Σ J.Obj F₀.Carrier
coc : Rel vertex-carrier (o ⊔ ℓ ⊔ c ⊔ ℓ′)
coc (X , x) (Y , y) = Σ[ f ∈ J [ X , Y ] ] Y [ (F₁ f ⟨$⟩ x) ≈ y ]
coc-preorder : Preorder (o ⊔ c) (o ⊔ c) (o ⊔ ℓ ⊔ c ⊔ ℓ′)
coc-preorder = record
{ Carrier = vertex-carrier
; _≈_ = _≡_
; _∼_ = coc
; isPreorder = record
{ isEquivalence = ≡.isEquivalence
; reflexive = λ { {j , _} ≡.refl → J.id , (identity (F₀.refl j)) }
; trans = λ { {a , Sa} {b , Sb} {c , Sc} (f , eq₁) (g , eq₂) →
let open RS (F₀ c)
in g J.∘ f , (begin
F₁ (g J.∘ f) ⟨$⟩ Sa ≈⟨ homomorphism (F₀.refl a) ⟩
F₁ g ⟨$⟩ (F₁ f ⟨$⟩ Sa) ≈⟨ Π.cong (F₁ g) eq₁ ⟩
F₁ g ⟨$⟩ Sb ≈⟨ eq₂ ⟩
Sc ∎) }
}
}
Setoids-Cocomplete : (o ℓ e c ℓ′ : Level) → Cocomplete o ℓ e (Setoids (o ⊔ c) (o ⊔ ℓ ⊔ c ⊔ ℓ′))
Setoids-Cocomplete o ℓ e c ℓ′ {J} F = record
{ initial =
record
{ ⊥ = record
{ N = ⇛-Setoid
; coapex = record
{ ψ = λ j → record
{ _⟨$⟩_ = j ,_
; cong = λ i≈k → forth (-, identity i≈k)
}
; commute = λ {X} X⇒Y x≈y → back (-, Π.cong (F₁ X⇒Y) (F₀.sym X x≈y))
}
}
; ! = λ {K} →
let module K = Cocone K
in record
{ arr = record
{ _⟨$⟩_ = to-coapex K
; cong = minimal (coc c ℓ′ F) K.N (to-coapex K) (coapex-cong K)
}
; commute = λ {X} x≈y → Π.cong (Coapex.ψ (Cocone.coapex K) X) x≈y
}
; !-unique = λ { {K} f {a , Sa} {b , Sb} eq →
let module K = Cocone K
module f = Cocone⇒ f
open RS K.N
in begin
K.ψ a ⟨$⟩ Sa ≈˘⟨ f.commute (F₀.refl a) ⟩
f.arr ⟨$⟩ (a , Sa) ≈⟨ Π.cong f.arr eq ⟩
f.arr ⟨$⟩ (b , Sb) ∎ }
}
}
where open Functor F
open Coc F
module J = Category J
module F₀ j = Setoid (F₀ j)
open F₀ using () renaming (_≈_ to _[_≈_])
-- this is essentially a symmetric transitive closure of coc
⇛-Setoid : Setoid (o ⊔ c) (o ⊔ ℓ ⊔ c ⊔ ℓ′)
⇛-Setoid = ST.setoid (coc c ℓ′ F) (Preorder.refl (coc-preorder c ℓ′ F))
to-coapex : ∀ K → vertex-carrier c ℓ′ F → Setoid.Carrier (Cocone.N K)
to-coapex K (j , Sj) = K.ψ j ⟨$⟩ Sj
where module K = Cocone K
coapex-cong : ∀ K → coc c ℓ′ F =[ to-coapex K ]⇒ (Setoid._≈_ (Cocone.N K))
coapex-cong K {X , x} {Y , y} (f , fx≈y) = begin
K.ψ X ⟨$⟩ x ≈˘⟨ K.commute f (F₀.refl X) ⟩
K.ψ Y ⟨$⟩ (F₁ f ⟨$⟩ x) ≈⟨ Π.cong (K.ψ Y) fx≈y ⟩
K.ψ Y ⟨$⟩ y ∎
where module K = Cocone K
open RS K.N
Setoids-Complete : (o ℓ e c ℓ′ : Level) → Complete o ℓ e (Setoids (c ⊔ ℓ ⊔ o ⊔ ℓ′) (o ⊔ ℓ′))
Setoids-Complete o ℓ e c ℓ′ {J} F =
record
{ terminal = record
{ ⊤ = record
{ N = record
{ Carrier = Σ (∀ j → F₀.Carrier j)
(λ S → ∀ {X Y} (f : J [ X , Y ]) → [ F₀ Y ] F₁ f ⟨$⟩ S X ≈ S Y)
; _≈_ = λ { (S₁ , _) (S₂ , _) → ∀ j → [ F₀ j ] S₁ j ≈ S₂ j }
; isEquivalence = record
{ refl = λ j → F₀.refl j
; sym = λ a≈b j → F₀.sym j (a≈b j)
; trans = λ a≈b b≈c j → F₀.trans j (a≈b j) (b≈c j)
}
}
; apex = record
{ ψ = λ j → record
{ _⟨$⟩_ = λ { (S , _) → S j }
; cong = λ eq → eq j
}
; commute = λ { {X} {Y} X⇒Y {_ , eq} {y} f≈g → F₀.trans Y (eq X⇒Y) (f≈g Y) }
}
}
; ! = λ {K} →
let module K = Cone K
in record
{ arr = record
{ _⟨$⟩_ = λ x → (λ j → K.ψ j ⟨$⟩ x) , λ f → K.commute f (Setoid.refl K.N)
; cong = λ a≈b j → Π.cong (K.ψ j) a≈b
}
; commute = λ x≈y → Π.cong (K.ψ _) x≈y
}
; !-unique = λ {K} f x≈y j →
let module K = Cone K
in F₀.sym j (Cone⇒.commute f (Setoid.sym K.N x≈y))
}
}
where open Functor F
open Co F
module J = Category J
module F₀ j = Setoid (F₀ j)
[_]_≈_ = Setoid._≈_
| {
"alphanum_fraction": 0.4831397527,
"avg_line_length": 34.6623376623,
"ext": "agda",
"hexsha": "fa4f959d0603469cb1fb41aa4c9c771128879d07",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "MirceaS/agda-categories",
"max_forks_repo_path": "src/Categories/Category/Instance/Properties/Setoids.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "MirceaS/agda-categories",
"max_issues_repo_path": "src/Categories/Category/Instance/Properties/Setoids.agda",
"max_line_length": 99,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "MirceaS/agda-categories",
"max_stars_repo_path": "src/Categories/Category/Instance/Properties/Setoids.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2084,
"size": 5338
} |
open import Agda.Primitive
variable
ℓ : Level
A : Set ℓ
P : A → Set ℓ
f : (x : A) → P x
postulate
R : (a : Level) → Set (lsuc a)
r : (a : Level) → R a
Id : (a : Level) (A : Set a) → A → A → Set a
cong₂ : (a b c : Level) (A : Set a) (B : Set b) (C : Set c) (x y : A) (u v : B)
(f : A → B → C) → Id c C (f x u) (f y v)
foo : (x y u v : A) (g : A → A) →
let a = _ in
Id a (Id _ _ _ _)
(cong₂ _ _ _ _ _ _ x y u v (λ x → f (g x)))
(cong₂ _ _ _ _ _ _ (g x) (g y) u v f)
| {
"alphanum_fraction": 0.397810219,
"avg_line_length": 24.9090909091,
"ext": "agda",
"hexsha": "c5df27b7349587527475155402bc4502b3f177a5",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "shlevy/agda",
"max_forks_repo_path": "test/Succeed/Issue4893.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/Issue4893.agda",
"max_line_length": 81,
"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/Issue4893.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": 245,
"size": 548
} |
open import Oscar.Prelude
open import Oscar.Class
open import Oscar.Class.Reflexivity
module Oscar.Class.Reflexivity.Function where
module _
{a}
where
instance
𝓡eflexivityFunction : Reflexivity.class Function⟦ a ⟧
𝓡eflexivityFunction .⋆ = ¡
| {
"alphanum_fraction": 0.7576923077,
"avg_line_length": 16.25,
"ext": "agda",
"hexsha": "85999e23c4f708086562e294d75ef66b01c0d782",
"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/Reflexivity/Function.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z",
"max_issues_repo_licenses": [
"RSA-MD"
],
"max_issues_repo_name": "m0davis/oscar",
"max_issues_repo_path": "archive/agda-3/src/Oscar/Class/Reflexivity/Function.agda",
"max_line_length": 57,
"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/Reflexivity/Function.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 75,
"size": 260
} |
-- https://github.com/idris-lang/Idris-dev/blob/4e704011fb805fcb861cc9a1bd68a2e727cefdde/libs/contrib/Data/Nat/Fib.idr
{-# OPTIONS --without-K --safe #-}
-- agda-stdlib
open import Algebra
module Math.NumberTheory.Fibonacci.Generic
{c e} (CM : CommutativeMonoid c e)
(v0 v1 : CommutativeMonoid.Carrier CM)
where
-- agda-stdlib
open import Data.Nat
open import Function
import Relation.Binary.PropositionalEquality as ≡
import Relation.Binary.Reasoning.Setoid as SetoidReasoning
open CommutativeMonoid CM
renaming
( Carrier to A
)
open SetoidReasoning setoid
fibRec : ℕ → A
fibRec 0 = v0
fibRec 1 = v1
fibRec (suc (suc n)) = fibRec (suc n) ∙ fibRec n
fibAcc : ℕ → A → A → A
fibAcc 0 a b = a
fibAcc (suc n) a b = fibAcc n b (a ∙ b)
fib : ℕ → A
fib n = fibAcc n v0 v1
lemma : ∀ m n o p → (m ∙ n) ∙ (o ∙ p) ≈ (m ∙ o) ∙ (n ∙ p)
lemma m n o p = begin
(m ∙ n) ∙ (o ∙ p) ≈⟨ assoc m n (o ∙ p) ⟩
m ∙ (n ∙ (o ∙ p)) ≈⟨ sym $ ∙-congˡ $ assoc n o p ⟩
m ∙ ((n ∙ o) ∙ p) ≈⟨ ∙-congˡ $ ∙-congʳ $ comm n o ⟩
m ∙ ((o ∙ n) ∙ p) ≈⟨ ∙-congˡ $ assoc o n p ⟩
m ∙ (o ∙ (n ∙ p)) ≈⟨ sym $ assoc m o (n ∙ p) ⟩
(m ∙ o) ∙ (n ∙ p) ∎
fibAcc-cong : ∀ {m n o p q r} →
m ≡.≡ n → o ≈ p → q ≈ r → fibAcc m o q ≈ fibAcc n p r
fibAcc-cong {zero} {.0} {o} {p} {q} {r} ≡.refl o≈p q≈r = o≈p
fibAcc-cong {suc m} {.(suc m)} {o} {p} {q} {r} ≡.refl o≈p q≈r =
fibAcc-cong {m = m} ≡.refl q≈r (∙-cong o≈p q≈r)
fibAdd : ∀ m n o p q → fibAcc m n o ∙ fibAcc m p q ≈ fibAcc m (n ∙ p) (o ∙ q)
fibAdd 0 n o p q = refl
fibAdd 1 n o p q = refl
fibAdd (suc (suc m)) n o p q = begin
fibAcc (2 + m) n o ∙ fibAcc (2 + m) p q ≡⟨⟩
fibAcc (1 + m) o (n ∙ o) ∙ fibAcc (1 + m) q (p ∙ q) ≡⟨⟩
fibAcc m (n ∙ o) (o ∙ (n ∙ o)) ∙ fibAcc m (p ∙ q) (q ∙ (p ∙ q)) ≈⟨ fibAdd m (n ∙ o) (o ∙ (n ∙ o)) (p ∙ q) (q ∙ (p ∙ q)) ⟩
fibAcc m ((n ∙ o) ∙ (p ∙ q)) ((o ∙ (n ∙ o)) ∙ (q ∙ (p ∙ q))) ≈⟨ fibAcc-cong {m = m} ≡.refl (lemma n o p q) (lemma o (n ∙ o) q (p ∙ q)) ⟩
fibAcc m ((n ∙ p) ∙ (o ∙ q)) ((o ∙ q) ∙ ((n ∙ o) ∙ (p ∙ q))) ≈⟨ fibAcc-cong {m = m} ≡.refl refl (∙-congˡ $ lemma n o p q) ⟩
fibAcc m ((n ∙ p) ∙ (o ∙ q)) ((o ∙ q) ∙ ((n ∙ p) ∙ (o ∙ q))) ≡⟨⟩
fibAcc (1 + m) (o ∙ q) ((n ∙ p) ∙ (o ∙ q)) ≡⟨⟩
fibAcc (2 + m) (n ∙ p) (o ∙ q) ∎
fibRec≈fib : ∀ n → fibRec n ≈ fib n
fibRec≈fib 0 = refl
fibRec≈fib 1 = refl
fibRec≈fib (suc (suc n)) = begin
fibRec (2 + n) ≡⟨⟩
fibRec (1 + n) ∙ fibRec n ≈⟨ ∙-cong (fibRec≈fib (suc n)) (fibRec≈fib n) ⟩
fib (1 + n) ∙ fib n ≡⟨⟩
fibAcc (1 + n) v0 v1 ∙ fibAcc n v0 v1 ≡⟨⟩
fibAcc n v1 (v0 ∙ v1) ∙ fibAcc n v0 v1 ≈⟨ fibAdd n v1 (v0 ∙ v1) v0 v1 ⟩
fibAcc n (v1 ∙ v0) ((v0 ∙ v1) ∙ v1) ≈⟨ fibAcc-cong {m = n} ≡.refl (comm v1 v0) (trans (∙-congʳ (comm v0 v1)) (assoc v1 v0 v1)) ⟩
fibAcc n (v0 ∙ v1) (v1 ∙ (v0 ∙ v1)) ≡⟨⟩
fib (2 + n) ∎
fib[2+n]≈fib[1+n]∙fib[n] : ∀ n → fib (suc (suc n)) ≈ fib (suc n) ∙ fib n
fib[2+n]≈fib[1+n]∙fib[n] n =
trans (sym $ fibRec≈fib (suc (suc n)))
(∙-cong (fibRec≈fib (suc n)) (fibRec≈fib n))
fib[1+n]∙fib[n]≈fib[2+n] : ∀ n → fib (suc n) ∙ fib n ≈ fib (suc (suc n))
fib[1+n]∙fib[n]≈fib[2+n] n = sym $ fib[2+n]≈fib[1+n]∙fib[n] n
fib[n]∙fib[1+n]≈fib[2+n] : ∀ n → fib n ∙ fib (suc n) ≈ fib (suc (suc n))
fib[n]∙fib[1+n]≈fib[2+n] n = trans (comm (fib n) (fib (suc n))) (fib[1+n]∙fib[n]≈fib[2+n] n)
| {
"alphanum_fraction": 0.4755820557,
"avg_line_length": 39.5730337079,
"ext": "agda",
"hexsha": "64ba2d7715e55abcca5c65d3aabafa6c090d7248",
"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": "Math/NumberTheory/Fibonacci/Generic.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": "Math/NumberTheory/Fibonacci/Generic.agda",
"max_line_length": 141,
"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": "Math/NumberTheory/Fibonacci/Generic.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": 1794,
"size": 3522
} |
module Lib.Maybe where
data Maybe (A : Set) : Set where
nothing : Maybe A
just : A -> Maybe A
{-# COMPILE GHC Maybe = data Maybe (Nothing | Just) #-}
| {
"alphanum_fraction": 0.6149068323,
"avg_line_length": 16.1,
"ext": "agda",
"hexsha": "e563a6717d7872b79b0d83a9dd8d1914811385a9",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "examples/simple-lib/Lib/Maybe.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "examples/simple-lib/Lib/Maybe.agda",
"max_line_length": 55,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "examples/simple-lib/Lib/Maybe.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": 46,
"size": 161
} |
module Subst where
open import Prelude
open import Lambda
infix 100 _[_] _[_:=_] _↑
infixl 100 _↑_ _↑ˢ_ _↑ˣ_ _↓ˣ_
infixl 60 _-_
{-
_-_ : {τ : Type}(Γ : Ctx) -> Var Γ τ -> Ctx
ε - ()
Γ , τ - vz = Γ
Γ , τ - vs x = (Γ - x) , τ
wkˣ : {Γ : Ctx}{σ τ : Type}
(x : Var Γ σ) -> Var (Γ - x) τ -> Var Γ τ
wkˣ vz y = vs y
wkˣ (vs x) vz = vz
wkˣ (vs x) (vs y) = vs (wkˣ x y)
wk : {Γ : Ctx}{σ τ : Type}
(x : Var Γ σ) -> Term (Γ - x) τ -> Term Γ τ
wk x (var y) = var (wkˣ x y)
wk x (s • t) = wk x s • wk x t
wk x (ƛ t) = ƛ wk (vs x) t
_↑ : {Γ : Ctx}{σ τ : Type} -> Term Γ τ -> Term (Γ , σ) τ
t ↑ = wk vz t
_↑_ : {Γ : Ctx}{τ : Type} -> Term Γ τ -> (Δ : Ctx) -> Term (Γ ++ Δ) τ
t ↑ ε = t
t ↑ (Δ , σ) = (t ↑ Δ) ↑
data Cmpˣ {Γ : Ctx}{τ : Type}(x : Var Γ τ) :
{σ : Type} -> Var Γ σ -> Set where
same : Cmpˣ x x
diff : {σ : Type}(y : Var (Γ - x) σ) -> Cmpˣ x (wkˣ x y)
_≟_ : {Γ : Ctx}{σ τ : Type}(x : Var Γ σ)(y : Var Γ τ) -> Cmpˣ x y
vz ≟ vz = same
vz ≟ vs y = diff y
vs x ≟ vz = diff vz
vs x ≟ vs y with x ≟ y
vs x ≟ vs .x | same = same
vs x ≟ vs .(wkˣ x y) | diff y = diff (vs y)
_[_:=_] : {Γ : Ctx}{σ τ : Type} ->
Term Γ σ -> (x : Var Γ τ) -> Term (Γ - x) τ ->
Term (Γ - x) σ
var y [ x := u ] with x ≟ y
var .x [ x := u ] | same = u
var .(wkˣ x y) [ x := u ] | diff y = var y
(s • t) [ x := u ] = s [ x := u ] • t [ x := u ]
(ƛ t) [ x := u ] = ƛ t [ vs x := u ↑ ]
-}
infix 30 _─⟶_
infixl 90 _/_
_─⟶_ : Ctx -> Ctx -> Set
Γ ─⟶ Δ = Terms Γ Δ
idS : forall {Γ} -> Γ ─⟶ Γ
idS = tabulate var
infixr 80 _∘ˢ_
[_] : forall {Γ σ } -> Term Γ σ -> Γ ─⟶ Γ , σ
[ t ] = idS ◄ t
wkS : forall {Γ Δ τ} -> Γ ─⟶ Δ -> Γ , τ ─⟶ Δ
wkS ∅ = ∅
wkS (θ ◄ t) = wkS θ ◄ wk t
_↑ : forall {Γ Δ τ} -> (Γ ─⟶ Δ) -> Γ , τ ─⟶ Δ , τ
θ ↑ = wkS θ ◄ vz
_/_ : forall {Γ Δ τ} -> Term Δ τ -> Γ ─⟶ Δ -> Term Γ τ
vz / (θ ◄ u) = u
wk t / (θ ◄ u) = t / θ
(s • t) / θ = s / θ • t / θ
(ƛ t) / θ = ƛ t / θ ↑
_∘ˢ_ : forall {Γ Δ Θ} -> Δ ─⟶ Θ -> Γ ─⟶ Δ -> Γ ─⟶ Θ
∅ ∘ˢ θ = ∅
(δ ◄ t) ∘ˢ θ = δ ∘ˢ θ ◄ t / θ
inj : forall {Γ Δ τ} Θ -> Term Γ τ -> Γ ─⟶ Δ ++ Θ -> Γ ─⟶ Δ , τ ++ Θ
inj ε t θ = θ ◄ t
inj (Θ , σ) t (θ ◄ u) = inj Θ t θ ◄ u
[_⟵_] : forall {Γ τ} Δ -> Term (Γ ++ Δ) τ -> Γ ++ Δ ─⟶ Γ , τ ++ Δ
[ Δ ⟵ t ] = inj Δ t idS
_↑_ : forall {Γ σ} -> Term Γ σ -> (Δ : Ctx) -> Term (Γ ++ Δ) σ
t ↑ ε = t
t ↑ (Δ , τ) = wk (t ↑ Δ)
_↑ˢ_ : forall {Γ Δ} -> Terms Γ Δ -> (Θ : Ctx) -> Terms (Γ ++ Θ) Δ
∅ ↑ˢ Θ = ∅
(ts ◄ t) ↑ˢ Θ = ts ↑ˢ Θ ◄ t ↑ Θ
_↑ˣ_ : forall {Γ τ} -> Var Γ τ -> (Δ : Ctx) -> Var (Γ ++ Δ) τ
x ↑ˣ ε = x
x ↑ˣ (Δ , σ) = vsuc (x ↑ˣ Δ)
lem-var-↑ˣ : forall {Γ τ}(x : Var Γ τ)(Δ : Ctx) ->
var (x ↑ˣ Δ) ≡ var x ↑ Δ
lem-var-↑ˣ x ε = refl
lem-var-↑ˣ x (Δ , σ) = cong wk (lem-var-↑ˣ x Δ)
{- Not true!
lem-•-↑ : forall {Γ σ τ}(t : Term Γ (σ ⟶ τ))(u : Term Γ σ) Δ ->
(t ↑ Δ) • (u ↑ Δ) ≡ (t • u) ↑ Δ
lem-•-↑ t u ε = refl
lem-•-↑ t u (Δ , δ) = {! !}
lem-•ˢ-↑ : forall {Γ Θ τ}(t : Term Γ (Θ ⇒ τ))(ts : Terms Γ Θ) Δ ->
(t ↑ Δ) •ˢ (ts ↑ˢ Δ) ≡ (t •ˢ ts) ↑ Δ
lem-•ˢ-↑ t ∅ Δ = refl
lem-•ˢ-↑ t (u ◄ us) Δ = {! !}
-}
{-
_[_] : {Γ : Ctx}{σ τ : Type} ->
Term (Γ , τ) σ -> Term Γ τ -> Term Γ σ
t [ u ] = t / [ u ]
-}
{-
vz [ u ] = u
wk t [ u ] = {! !}
(s • t) [ u ] = {! !}
(ƛ_ {τ = ρ} t) [ u ] = ƛ {! !}
-}
{-
_↓ˣ_ : {Γ : Ctx}{σ τ : Type}
(y : Var Γ σ)(x : Var (Γ - y) τ) -> Var (Γ - wkˣ y x) σ
vz ↓ˣ x = vz
vs y ↓ˣ vz = y
vs y ↓ˣ vs x = vs (y ↓ˣ x)
lem-commute-minus :
{Γ : Ctx}{σ τ : Type}(y : Var Γ σ)(x : Var (Γ - y) τ) ->
Γ - y - x ≡ Γ - wkˣ y x - (y ↓ˣ x)
lem-commute-minus vz x = refl
lem-commute-minus (vs y) vz = refl
lem-commute-minus (vs {Γ} y) (vs x) with Γ - y - x | lem-commute-minus y x
... | ._ | refl = refl
Lem-wk-[] :
{Γ : Ctx}{τ σ ρ : Type}
(y : Var Γ τ)
(x : Var (Γ - y) σ)
(t : Term (Γ - wkˣ y x) ρ)
(u : Term (Γ - y - x) τ) -> Set
Lem-wk-[] {Γ}{τ}{σ}{ρ} y x t u =
wk (wkˣ y x) t [ y := wk x u ]
≡ wk x t[u']'
where
u' : Term (Γ - wkˣ y x - y ↓ˣ x) τ
u' = subst (\Δ -> Term Δ τ) (sym (lem-commute-minus y x)) u
t[u']' : Term (Γ - y - x) ρ
t[u']' = subst (\Δ -> Term Δ ρ) (lem-commute-minus y x)
(t [ y ↓ˣ x := u' ])
postulate
lem-wk-[] : {Γ : Ctx}{σ τ ρ : Type}
(y : Var Γ τ)(x : Var (Γ - y) σ)
(t : Term (Γ - wkˣ y x) ρ){u : Term (Γ - y - x) τ} ->
Lem-wk-[] y x t u
{-
lem-wk-[] y x (var z) = {! !}
lem-wk-[] y x (t • u) = {! !}
lem-wk-[] y x (ƛ t) = {! !}
-}
lem-wk-[]' : {Γ : Ctx}{σ τ ρ : Type}
(x : Var Γ σ)(t : Term (Γ - x , ρ) τ){u : Term (Γ - x) ρ} ->
wk x (t [ vz := u ]) ≡ wk (vs x) t [ vz := wk x u ]
lem-wk-[]' x t = sym (lem-wk-[] vz x t)
-} | {
"alphanum_fraction": 0.3877466251,
"avg_line_length": 25.6117021277,
"ext": "agda",
"hexsha": "d25509ae650c0de596d00b7166c2dd44469910b4",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "examples/outdated-and-incorrect/tait/Subst.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "examples/outdated-and-incorrect/tait/Subst.agda",
"max_line_length": 74,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "examples/outdated-and-incorrect/tait/Subst.agda",
"max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z",
"num_tokens": 2468,
"size": 4815
} |
{-# OPTIONS --safe #-}
open import Definition.Typed.EqualityRelation
module Definition.LogicalRelation.Substitution.Introductions.IdUniv {{eqrel : EqRelSet}} where
open EqRelSet {{...}}
open import Definition.Untyped
open import Definition.Untyped.Properties
open import Definition.Typed
open import Definition.Typed.Properties
import Definition.Typed.Weakening as Twk
open import Definition.Typed.EqualityRelation
open import Definition.Typed.RedSteps
open import Definition.LogicalRelation
open import Definition.LogicalRelation.ShapeView
open import Definition.LogicalRelation.Irrelevance
open import Definition.LogicalRelation.Properties
open import Definition.LogicalRelation.Application
open import Definition.LogicalRelation.Substitution
import Definition.LogicalRelation.Weakening as Lwk
open import Definition.LogicalRelation.Substitution.Properties
import Definition.LogicalRelation.Substitution.Irrelevance as S
open import Definition.LogicalRelation.Substitution.Reflexivity
open import Definition.LogicalRelation.Substitution.Weakening
-- open import Definition.LogicalRelation.Substitution.Introductions.Nat
open import Definition.LogicalRelation.Substitution.Introductions.Empty
open import Definition.LogicalRelation.Substitution.Introductions.Pi
open import Definition.LogicalRelation.Substitution.Introductions.Idlemmas
open import Definition.LogicalRelation.Substitution.MaybeEmbed
-- open import Definition.LogicalRelation.Substitution.Introductions.SingleSubst
open import Definition.LogicalRelation.Substitution.Introductions.Universe
open import Tools.Product
open import Tools.Empty
import Tools.Unit as TU
import Tools.PropositionalEquality as PE
import Data.Nat as Nat
[Id]SProp : ∀ {t u Γ}
(⊢Γ : ⊢ Γ)
([t] : Γ ⊩⟨ ι ⁰ ⟩ t ^ [ % , ι ⁰ ])
([u] : Γ ⊩⟨ ι ⁰ ⟩ u ^ [ % , ι ⁰ ])
→ Γ ⊩⟨ ι ¹ ⟩ Id (SProp ⁰) t u ^ [ % , ι ¹ ]
[Id]SProp {t} {u} {Γ} ⊢Γ [t] [u] =
let
⊢t = escape [t]
⊢u = escape [u]
⊢wkt = Twk.wk (Twk.step Twk.id) (⊢Γ ∙ ⊢u) ⊢t
⊢wku = Twk.wk (Twk.step Twk.id) (⊢Γ ∙ ⊢t) ⊢u
[wkt] = λ {ρ} {Δ} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → Lwk.wk [ρ] ⊢Δ [t]
[wku] = λ {ρ} {Δ} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → Lwk.wk [ρ] ⊢Δ [u]
[t▹u] : Γ ⊩⟨ ι ⁰ ⟩ t ^ % ° ⁰ ▹▹ u ° ⁰ ° ¹ ^ [ % , ι ¹ ]
[t▹u] = Πᵣ′ % ⁰ ⁰ (<is≤ 0<1) (<is≤ 0<1) t (wk1 u)
(idRed:*: (univ (Πⱼ <is≤ 0<1 ▹ <is≤ 0<1 ▹ un-univ ⊢t ▹ un-univ ⊢wku))) ⊢t ⊢wku
(≅-univ (≅ₜ-Π-cong (<is≤ 0<1) (<is≤ 0<1) ⊢t (≅-un-univ (escapeEqRefl [t])) (≅-un-univ (≅-wk (Twk.step Twk.id) (⊢Γ ∙ ⊢t) (escapeEqRefl [u])))))
[wkt] ([nondep] [u] [wkt]) ([nondepext] [u] [wkt])
[u▹t] : Γ ⊩⟨ ι ⁰ ⟩ u ^ % ° ⁰ ▹▹ t ° ⁰ ° ¹ ^ [ % , ι ¹ ]
[u▹t] = Πᵣ′ % ⁰ ⁰ (<is≤ 0<1) (<is≤ 0<1) u (wk1 t)
(idRed:*: (univ (Πⱼ <is≤ 0<1 ▹ <is≤ 0<1 ▹ un-univ ⊢u ▹ un-univ ⊢wkt))) ⊢u ⊢wkt
(≅-univ (≅ₜ-Π-cong (<is≤ 0<1) (<is≤ 0<1) ⊢u (≅-un-univ (escapeEqRefl [u])) (≅-un-univ (≅-wk (Twk.step Twk.id) (⊢Γ ∙ ⊢u) (escapeEqRefl [t])))))
[wku] ([nondep] [t] [wku]) ([nondepext] [t] [wku])
[wkt▹u] = λ {ρ} {Δ} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → Lwk.wk [ρ] ⊢Δ (emb emb< [t▹u])
⊢t▹u = escape [t▹u]
⊢u▹t = Twk.wk (Twk.step Twk.id) (⊢Γ ∙ ⊢t▹u) (escape [u▹t])
⊢Id = univ (Idⱼ (univ 0<1 ⊢Γ) (un-univ ⊢t) (un-univ ⊢u))
⊢Eq = univ (∃ⱼ un-univ ⊢t▹u ▹ un-univ ⊢u▹t)
in ∃ᵣ′ (t ^ % ° ⁰ ▹▹ u ° ⁰ ° ¹) (wk1 (u ^ % ° ⁰ ▹▹ t ° ⁰ ° ¹))
[[ ⊢Id , ⊢Eq , univ (Id-SProp (un-univ ⊢t) (un-univ ⊢u)) ⇨ id ⊢Eq ]] ⊢t▹u ⊢u▹t
(≅-univ (≅ₜ-∃-cong ⊢t▹u (≅-un-univ (escapeEqRefl [t▹u])) (≅-un-univ (≅-wk (Twk.step Twk.id) (⊢Γ ∙ ⊢t▹u) (escapeEqRefl [u▹t])))))
[wkt▹u] ([nondep] (emb emb< [u▹t]) [wkt▹u]) ([nondepext] (emb emb< [u▹t]) [wkt▹u])
[IdExt]SProp : ∀ {t t′ u u′ Γ}
(⊢Γ : ⊢ Γ)
([t] : Γ ⊩⟨ ι ⁰ ⟩ t ^ [ % , ι ⁰ ])
([t′] : Γ ⊩⟨ ι ⁰ ⟩ t′ ^ [ % , ι ⁰ ])
([t≡t′] : Γ ⊩⟨ ι ⁰ ⟩ t ≡ t′ ^ [ % , ι ⁰ ] / [t])
([u] : Γ ⊩⟨ ι ⁰ ⟩ u ^ [ % , ι ⁰ ])
([u′] : Γ ⊩⟨ ι ⁰ ⟩ u′ ^ [ % , ι ⁰ ])
([u≡u′] : Γ ⊩⟨ ι ⁰ ⟩ u ≡ u′ ^ [ % , ι ⁰ ] / [u])
→ Γ ⊩⟨ ι ¹ ⟩ Id (SProp ⁰) t u ≡ Id (SProp ⁰) t′ u′ ^ [ % , ι ¹ ] / [Id]SProp ⊢Γ [t] [u]
[IdExt]SProp {t} {t′} {u} {u′} {Γ} ⊢Γ [t] [t′] [t≡t′] [u] [u′] [u≡u′] =
let ⊢t = escape [t]
⊢t′ = escape [t′]
⊢u = escape [u]
⊢u′ = escape [u′]
⊢t≡t′ = ≅-un-univ (escapeEq [t] [t≡t′])
⊢u≡u′ = ≅-un-univ (escapeEq [u] [u≡u′])
⊢wkt = Twk.wk (Twk.step Twk.id) (⊢Γ ∙ ⊢u) ⊢t
⊢wku = Twk.wk (Twk.step Twk.id) (⊢Γ ∙ ⊢t) ⊢u
[wkt] = λ {ρ} {Δ} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → Lwk.wk [ρ] ⊢Δ [t]
[wku] = λ {ρ} {Δ} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → Lwk.wk [ρ] ⊢Δ [u]
⊢wkt′ = Twk.wk (Twk.step Twk.id) (⊢Γ ∙ ⊢u′) ⊢t′
⊢wku′ = Twk.wk (Twk.step Twk.id) (⊢Γ ∙ ⊢t′) ⊢u′
[wkt′] = λ {ρ} {Δ} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → Lwk.wk [ρ] ⊢Δ [t′]
[wku′] = λ {ρ} {Δ} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → Lwk.wk [ρ] ⊢Δ [u′]
[t▹u] : Γ ⊩⟨ ι ⁰ ⟩ t ^ % ° ⁰ ▹▹ u ° ⁰ ° ¹ ^ [ % , ι ¹ ]
[t▹u] = Πᵣ′ % ⁰ ⁰ (<is≤ 0<1) (<is≤ 0<1) t (wk1 u)
(idRed:*: (univ (Πⱼ <is≤ 0<1 ▹ <is≤ 0<1 ▹ un-univ ⊢t ▹ un-univ ⊢wku))) ⊢t ⊢wku
(≅-univ (≅ₜ-Π-cong (<is≤ 0<1) (<is≤ 0<1) ⊢t (≅-un-univ (escapeEqRefl [t])) (≅-un-univ (≅-wk (Twk.step Twk.id) (⊢Γ ∙ ⊢t) (escapeEqRefl [u])))))
[wkt] ([nondep] [u] [wkt]) ([nondepext] [u] [wkt])
[u▹t] : Γ ⊩⟨ ι ⁰ ⟩ u ^ % ° ⁰ ▹▹ t ° ⁰ ° ¹ ^ [ % , ι ¹ ]
[u▹t] = Πᵣ′ % ⁰ ⁰ (<is≤ 0<1) (<is≤ 0<1) u (wk1 t)
(idRed:*: (univ (Πⱼ <is≤ 0<1 ▹ <is≤ 0<1 ▹ un-univ ⊢u ▹ un-univ ⊢wkt))) ⊢u ⊢wkt
(≅-univ (≅ₜ-Π-cong (<is≤ 0<1) (<is≤ 0<1) ⊢u (≅-un-univ (escapeEqRefl [u])) (≅-un-univ (≅-wk (Twk.step Twk.id) (⊢Γ ∙ ⊢u) (escapeEqRefl [t])))))
[wku] ([nondep] [t] [wku]) ([nondepext] [t] [wku])
[t▹u′] : Γ ⊩⟨ ι ⁰ ⟩ t′ ^ % ° ⁰ ▹▹ u′ ° ⁰ ° ¹ ^ [ % , ι ¹ ]
[t▹u′] = Πᵣ′ % ⁰ ⁰ (<is≤ 0<1) (<is≤ 0<1) t′ (wk1 u′)
(idRed:*: (univ (Πⱼ <is≤ 0<1 ▹ <is≤ 0<1 ▹ un-univ ⊢t′ ▹ un-univ ⊢wku′))) ⊢t′ ⊢wku′
(≅-univ (≅ₜ-Π-cong (<is≤ 0<1) (<is≤ 0<1) ⊢t′ (≅-un-univ (escapeEqRefl [t′])) (≅-un-univ (≅-wk (Twk.step Twk.id) (⊢Γ ∙ ⊢t′) (escapeEqRefl [u′])))))
[wkt′] ([nondep] [u′] [wkt′]) ([nondepext] [u′] [wkt′])
[u▹t′] : Γ ⊩⟨ ι ⁰ ⟩ u′ ^ % ° ⁰ ▹▹ t′ ° ⁰ ° ¹ ^ [ % , ι ¹ ]
[u▹t′] = Πᵣ′ % ⁰ ⁰ (<is≤ 0<1) (<is≤ 0<1) u′ (wk1 t′)
(idRed:*: (univ (Πⱼ <is≤ 0<1 ▹ <is≤ 0<1 ▹ un-univ ⊢u′ ▹ un-univ ⊢wkt′)))
⊢u′ ⊢wkt′
(≅-univ (≅ₜ-Π-cong (<is≤ 0<1) (<is≤ 0<1) ⊢u′ (≅-un-univ (escapeEqRefl [u′])) (≅-un-univ (≅-wk (Twk.step Twk.id) (⊢Γ ∙ ⊢u′) (escapeEqRefl [t′])))))
[wku′] ([nondep] [t′] [wku′]) ([nondepext] [t′] [wku′])
[t▹u≡t▹u′] : Γ ⊩⟨ ι ⁰ ⟩ t ^ % ° ⁰ ▹▹ u ° ⁰ ° ¹ ≡ t′ ^ % ° ⁰ ▹▹ u′ ° ⁰ ° ¹ ^ [ % , ι ¹ ] / [t▹u]
[t▹u≡t▹u′] = Π₌ t′ (wk1 u′) (id (univ (Πⱼ <is≤ 0<1 ▹ <is≤ 0<1 ▹ un-univ ⊢t′ ▹ un-univ ⊢wku′)))
(≅-univ (≅ₜ-Π-cong (<is≤ 0<1) (<is≤ 0<1) ⊢t ⊢t≡t′ (≅ₜ-wk (Twk.step Twk.id) (⊢Γ ∙ ⊢t) ⊢u≡u′)))
(λ {ρ} {Δ} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → Lwk.wkEq [ρ] ⊢Δ (emb emb< [t]) [t≡t′])
([nondepext'] [u] [u′] [u≡u′] [wkt] [wkt′])
[u▹t≡u▹t′] : Γ ⊩⟨ ι ⁰ ⟩ u ^ % ° ⁰ ▹▹ t ° ⁰ ° ¹ ≡ u′ ^ % ° ⁰ ▹▹ t′ ° ⁰ ° ¹ ^ [ % , ι ¹ ] / [u▹t]
[u▹t≡u▹t′] = Π₌ u′ (wk1 t′) (id (univ (Πⱼ <is≤ 0<1 ▹ <is≤ 0<1 ▹ un-univ ⊢u′ ▹ un-univ ⊢wkt′)))
(≅-univ (≅ₜ-Π-cong (<is≤ 0<1) (<is≤ 0<1) ⊢u ⊢u≡u′ (≅ₜ-wk (Twk.step Twk.id) (⊢Γ ∙ ⊢u) ⊢t≡t′)))
(λ {ρ} {Δ} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → Lwk.wkEq [ρ] ⊢Δ (emb emb< [u]) [u≡u′])
([nondepext'] [t] [t′] [t≡t′] [wku] [wku′])
⊢t▹u = escape [t▹u]
in ∃₌ {l′ = ¹} (t′ ^ % ° ⁰ ▹▹ u′ ° ⁰ ° ¹ ) (wk1 (u′ ^ % ° ⁰ ▹▹ t′ ° ⁰ ° ¹ ))
(univ (Id-SProp (un-univ ⊢t′) (un-univ ⊢u′)) ⇨ id (univ (××ⱼ (▹▹ⱼ <is≤ 0<1 ▹ <is≤ 0<1 ▹ un-univ ⊢t′ ▹ un-univ ⊢u′) ▹
(▹▹ⱼ <is≤ 0<1 ▹ <is≤ 0<1 ▹ un-univ ⊢u′ ▹ un-univ ⊢t′))))
(≅-univ (≅ₜ-∃-cong ⊢t▹u
(≅ₜ-Π-cong (<is≤ 0<1) (<is≤ 0<1) ⊢t ⊢t≡t′ (≅ₜ-wk (Twk.step Twk.id) (⊢Γ ∙ ⊢t) ⊢u≡u′))
(≅ₜ-Π-cong (<is≤ 0<1) (<is≤ 0<1) (Twk.wk (Twk.step Twk.id) (⊢Γ ∙ ⊢t▹u) ⊢u)
(≅ₜ-wk (Twk.step Twk.id) (⊢Γ ∙ ⊢t▹u) ⊢u≡u′)
(≅ₜ-wk (Twk.lift (Twk.step Twk.id)) ((⊢Γ ∙ ⊢t▹u) ∙
(Twk.wk (Twk.step Twk.id) (⊢Γ ∙ ⊢t▹u) ⊢u))
(≅ₜ-wk (Twk.step Twk.id) (⊢Γ ∙ ⊢u) ⊢t≡t′)) )))
(λ {ρ} {Δ} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → Lwk.wkEq [ρ] ⊢Δ [t▹u] [t▹u≡t▹u′])
([nondepext'] (emb emb< [u▹t]) (emb emb< [u▹t′]) [u▹t≡u▹t′]
(λ {ρ} {Δ} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → Lwk.wk [ρ] ⊢Δ (emb emb< [t▹u]))
(λ {ρ} {Δ} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → Lwk.wk [ρ] ⊢Δ (emb emb< [t▹u′])))
[Id]U : ∀ {A B Γ}
(⊢Γ : ⊢ Γ)
([A] : Γ ⊩⟨ ι ⁰ ⟩ A ^ [ ! , ι ⁰ ])
([B] : Γ ⊩⟨ ι ⁰ ⟩ B ^ [ ! , ι ⁰ ])
→ Γ ⊩⟨ ι ¹ ⟩ Id (U ⁰) A B ^ [ % , ι ¹ ]
[IdExtShape]U : ∀ {A A′ B B′ Γ}
(⊢Γ : ⊢ Γ)
([A] : Γ ⊩⟨ ι ⁰ ⟩ A ^ [ ! , ι ⁰ ])
([A′] : Γ ⊩⟨ ι ⁰ ⟩ A′ ^ [ ! , ι ⁰ ])
(ShapeA : ShapeView Γ (ι ⁰) (ι ⁰) A A′ [ ! , ι ⁰ ] [ ! , ι ⁰ ] [A] [A′])
([A≡A′] : Γ ⊩⟨ ι ⁰ ⟩ A ≡ A′ ^ [ ! , ι ⁰ ] / [A])
([B] : Γ ⊩⟨ ι ⁰ ⟩ B ^ [ ! , ι ⁰ ])
([B′] : Γ ⊩⟨ ι ⁰ ⟩ B′ ^ [ ! , ι ⁰ ])
(ShapeB : ShapeView Γ (ι ⁰) (ι ⁰) B B′ [ ! , ι ⁰ ] [ ! , ι ⁰ ] [B] [B′])
([B≡B′] : Γ ⊩⟨ ι ⁰ ⟩ B ≡ B′ ^ [ ! , ι ⁰ ] / [B])
→ Γ ⊩⟨ ι ¹ ⟩ Id (U ⁰) A B ≡ Id (U ⁰) A′ B′ ^ [ % , ι ¹ ] / [Id]U ⊢Γ [A] [B]
[IdExt]U : ∀ {A A′ B B′ Γ}
(⊢Γ : ⊢ Γ)
([A] : Γ ⊩⟨ ι ⁰ ⟩ A ^ [ ! , ι ⁰ ])
([A′] : Γ ⊩⟨ ι ⁰ ⟩ A′ ^ [ ! , ι ⁰ ])
([A≡A′] : Γ ⊩⟨ ι ⁰ ⟩ A ≡ A′ ^ [ ! , ι ⁰ ] / [A])
([B] : Γ ⊩⟨ ι ⁰ ⟩ B ^ [ ! , ι ⁰ ])
([B′] : Γ ⊩⟨ ι ⁰ ⟩ B′ ^ [ ! , ι ⁰ ])
([B≡B′] : Γ ⊩⟨ ι ⁰ ⟩ B ≡ B′ ^ [ ! , ι ⁰ ] / [B])
→ Γ ⊩⟨ ι ¹ ⟩ Id (U ⁰) A B ≡ Id (U ⁰) A′ B′ ^ [ % , ι ¹ ] / [Id]U ⊢Γ [A] [B]
[Id]U {A} {B} ⊢Γ (ne′ K D neK K≡K) [B] =
let ⊢B = escape [B]
B≡B = escapeEqRefl [B]
in ne (ne (Id (U ⁰) K B) (univ:⇒*: (IdURed*Term (un-univ:⇒*: D) (un-univ ⊢B))) (IdUₙ neK) (~-IdU ⊢Γ K≡K (≅-un-univ B≡B)))
[Id]U ⊢Γ (ℕᵣ [[ ⊢A , ⊢K , D ]]) (ℕᵣ [[ ⊢B , ⊢L , D₁ ]]) =
let
⊢tA = (subset* D)
in proj₁ (redSubst* (trans⇒* (univ⇒* (IdURed*Term′ (un-univ ⊢A) (un-univ ⊢K) (un-univ⇒* D) (un-univ ⊢B)))
(trans⇒* (univ⇒* (IdUℕRed*Term′ (un-univ ⊢B) (un-univ ⊢L) (un-univ⇒* D₁))) (univ (Id-U-ℕℕ ⊢Γ) ⇨ id (univ (Unitⱼ ⊢Γ))))) (UnitType ⊢Γ))
[Id]U ⊢Γ (ℕᵣ D) (ne′ K D₁ neK K≡K) =
let [B] = ne′ K D₁ neK K≡K
⊢B = escape {l = ι ¹} [B]
in ne′ (Id (U ⁰) ℕ K) (univ:⇒*: (transTerm:⇒:* (IdURed*Term (un-univ:⇒*: D) (un-univ ⊢B) ) (IdUℕRed*Term (un-univ:⇒*: D₁))))
(IdUℕₙ neK) (~-IdUℕ ⊢Γ K≡K)
[Id]U ⊢Γ (ℕᵣ [[ ⊢A , ⊢ℕ , D ]]) (Πᵣ′ rF lF lG (≡is≤ PE.refl) (≡is≤ PE.refl) F G D′ ⊢F ⊢G A≡A [F] [G] G-ext) =
let [B] = Πᵣ′ rF lF lG (≡is≤ PE.refl) (≡is≤ PE.refl) F G D′ ⊢F ⊢G A≡A [F] [G] G-ext
⊢B = escape [B]
in proj₁ (redSubst* (trans⇒* (univ⇒* (IdURed*Term′ (un-univ ⊢A) (un-univ ⊢ℕ) (un-univ⇒* D) (un-univ ⊢B)))
(trans⇒* (univ⇒* (IdUℕRed*Term′ (un-univ ⊢B) (Πⱼ ≡is≤ PE.refl ▹ ≡is≤ PE.refl ▹ (un-univ ⊢F) ▹ (un-univ ⊢G)) (un-univ⇒* (red D′))))
(univ (Id-U-ℕΠ (un-univ ⊢F) (un-univ ⊢G)) ⇨ id (univ (Emptyⱼ ⊢Γ))))) (EmptyType ⊢Γ))
[Id]U ⊢Γ (Πᵣ′ rF lF lG (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢A , ⊢Π , D ]] ⊢F ⊢G A≡A [F] [G] G-ext) (ℕᵣ [[ ⊢B , ⊢ℕ , D' ]]) =
proj₁ (redSubst* (trans⇒* (univ⇒* (IdURed*Term′ (un-univ ⊢A) (un-univ ⊢Π) (un-univ⇒* D) (un-univ ⊢B)))
(trans⇒* (univ⇒* (IdUΠRed*Term′ (un-univ ⊢F) (un-univ ⊢G) (un-univ ⊢B) (un-univ ⊢ℕ) (un-univ⇒* D')))
(univ (Id-U-Πℕ (un-univ ⊢F) (un-univ ⊢G)) ⇨ id (univ (Emptyⱼ ⊢Γ))))) (EmptyType ⊢Γ))
[Id]U ⊢Γ (Πᵣ′ rF lF lG (≡is≤ PE.refl) (≡is≤ PE.refl) F G D ⊢F ⊢G A≡A [F] [G] G-ext) (ne′ K D₁ neK K≡K) =
let [B] = ne′ K D₁ neK K≡K
⊢B = escape {l = ι ¹} [B]
-- [F]' = PE.subst (λ X → _ ⊩⟨ _ ⟩ X ^ [ _ , _ ]) (wk-id F) ([F] Twk.id ⊢Γ)
-- ⊢F≅F = ≅-un-univ (escapeEqRefl [F]')
-- [G]' = PE.subst (λ X → _ ⊩⟨ _ ⟩ X ^ [ _ , _ ]) (wkSingleSubstId G) ([G] {a = var 0} (Twk.step Twk.id) (⊢Γ ∙ ⊢F) {!!})
-- ⊢G≅G = ≅-un-univ (escapeEqRefl [G]')
in ne′ (Id (U ⁰) (Π F ^ rF ° lF ▹ G ° lG ° ⁰) K)
(univ:⇒*: (transTerm:⇒:* (IdURed*Term (un-univ:⇒*: D) (un-univ ⊢B) ) (IdUΠRed*Term (un-univ ⊢F) (un-univ ⊢G) (un-univ:⇒*: D₁))))
(IdUΠₙ neK) (~-IdUΠ (≅-un-univ A≡A) K≡K)
[Id]U {A} {B} {Γ} ⊢Γ (Πᵣ′ ! .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢A , ⊢ΠFG , D ]] ⊢F ⊢G A≡A [F] [G] G-ext)
(Πᵣ′ ! .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ [[ ⊢B , ⊢ΠF₁G₁ , D₁ ]] ⊢F₁ ⊢G₁ B≡B [F₁] [G₁] G₁-ext) =
∃ᵣ′ (Id (U ⁰) F F₁) (IdGG₁ (step id) (var 0))
[[ (univ (Idⱼ (univ 0<1 ⊢Γ) (un-univ ⊢A) (un-univ ⊢B))) , ⊢∃ , D∃ ]]
⊢IdFF₁ ⊢IdGG₁ ∃≡∃ [IdFF₁]
(λ {ρ} {Δ} {a} [ρ] ⊢Δ [a] → PE.subst (λ X → Δ ⊩⟨ ι ¹ ⟩ X ^ [ % , ι ¹ ]) (PE.sym (wksubst-IdTel ρ a)) ([IdGG₁] [ρ] ⊢Δ [a]))
(λ {ρ} {Δ} {a} {b} [ρ] ⊢Δ [a] [b] [a≡b] → irrelevanceEq″ (PE.sym (wksubst-IdTel ρ a)) (PE.sym (wksubst-IdTel ρ b)) PE.refl PE.refl
([IdGG₁] [ρ] ⊢Δ [a]) (PE.subst (λ X → Δ ⊩⟨ ι ¹ ⟩ X ^ [ % , ι ¹ ]) (PE.sym (wksubst-IdTel ρ a)) ([IdGG₁] [ρ] ⊢Δ [a]))
([IdGG₁-ext] [ρ] ⊢Δ [a] [b] [a≡b]))
where
open IdTypeU-lemmas ⊢Γ ⊢A ⊢ΠFG D ⊢F ⊢G A≡A [F] [G] G-ext ⊢B ⊢ΠF₁G₁ D₁ ⊢F₁ ⊢G₁ B≡B [F₁] [G₁] G₁-ext
(λ [ρ] ⊢Δ → [Id]U ⊢Δ ([F] [ρ] ⊢Δ) ([F₁] [ρ] ⊢Δ))
(λ [ρ] ⊢Δ [x] [y] → [Id]U ⊢Δ ([G] [ρ] ⊢Δ [x]) ([G₁] [ρ] ⊢Δ [y]))
(λ [ρ] ⊢Δ [x] [x′] [x≡x′] [y] [y′] [y≡y′] →
[IdExt]U ⊢Δ ([G] [ρ] ⊢Δ [x]) ([G] [ρ] ⊢Δ [x′]) (G-ext [ρ] ⊢Δ [x] [x′] [x≡x′]) ([G₁] [ρ] ⊢Δ [y]) ([G₁] [ρ] ⊢Δ [y′]) (G₁-ext [ρ] ⊢Δ [y] [y′] [y≡y′]))
[Id]U {A} {B} {Γ} ⊢Γ (Πᵣ′ % .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢A , ⊢ΠFG , D ]] ⊢F ⊢G A≡A [F] [G] G-ext)
(Πᵣ′ % .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ [[ ⊢B , ⊢ΠF₁G₁ , D₁ ]] ⊢F₁ ⊢G₁ B≡B [F₁] [G₁] G₁-ext) =
∃ᵣ′ (Id (SProp ⁰) F F₁) (IdGG₁ (step id) (var 0))
[[ (univ (Idⱼ (univ 0<1 ⊢Γ) (un-univ ⊢A) (un-univ ⊢B))) , ⊢∃ , D∃ ]]
⊢IdFF₁ ⊢IdGG₁ ∃≡∃ [IdFF₁]
(λ {ρ} {Δ} {a} [ρ] ⊢Δ [a] → PE.subst (λ X → Δ ⊩⟨ ι ¹ ⟩ X ^ [ % , ι ¹ ]) (PE.sym (wksubst-IdTel ρ a)) ([IdGG₁] [ρ] ⊢Δ [a]))
(λ {ρ} {Δ} {a} {b} [ρ] ⊢Δ [a] [b] [a≡b] → irrelevanceEq″ (PE.sym (wksubst-IdTel ρ a)) (PE.sym (wksubst-IdTel ρ b)) PE.refl PE.refl
([IdGG₁] [ρ] ⊢Δ [a]) (PE.subst (λ X → Δ ⊩⟨ ι ¹ ⟩ X ^ [ % , ι ¹ ]) (PE.sym (wksubst-IdTel ρ a)) ([IdGG₁] [ρ] ⊢Δ [a]))
([IdGG₁-ext] [ρ] ⊢Δ [a] [b] [a≡b]))
where
open IdTypeU-lemmas ⊢Γ ⊢A ⊢ΠFG D ⊢F ⊢G A≡A [F] [G] G-ext ⊢B ⊢ΠF₁G₁ D₁ ⊢F₁ ⊢G₁ B≡B [F₁] [G₁] G₁-ext
(λ [ρ] ⊢Δ → [Id]SProp ⊢Δ ([F] [ρ] ⊢Δ) ([F₁] [ρ] ⊢Δ))
(λ [ρ] ⊢Δ [x] [y] → [Id]U ⊢Δ ([G] [ρ] ⊢Δ [x]) ([G₁] [ρ] ⊢Δ [y]))
(λ [ρ] ⊢Δ [x] [x′] [x≡x′] [y] [y′] [y≡y′] →
[IdExt]U ⊢Δ ([G] [ρ] ⊢Δ [x]) ([G] [ρ] ⊢Δ [x′]) (G-ext [ρ] ⊢Δ [x] [x′] [x≡x′]) ([G₁] [ρ] ⊢Δ [y]) ([G₁] [ρ] ⊢Δ [y′]) (G₁-ext [ρ] ⊢Δ [y] [y′] [y≡y′]))
[Id]U ⊢Γ (Πᵣ′ ! .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢A , ⊢ΠFG , D ]] ⊢F ⊢G A≡A [F] [G] G-ext)
(Πᵣ′ % .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ [[ ⊢B , ⊢ΠF₁G₁ , D' ]] ⊢F₁ ⊢G₁ B≡B [F₁] [G₁] G₁-ext) =
proj₁ (redSubst* (trans⇒* (univ⇒* (IdURed*Term′ (un-univ ⊢A) (un-univ ⊢ΠFG) (un-univ⇒* D) (un-univ ⊢B)))
(trans⇒* (univ⇒* (IdUΠRed*Term′ (un-univ ⊢F) (un-univ ⊢G) (un-univ ⊢B) (un-univ ⊢ΠF₁G₁) (un-univ⇒* D')))
(univ (Id-U-ΠΠ!% !≢% (un-univ ⊢F) (un-univ ⊢G) (un-univ ⊢F₁) (un-univ ⊢G₁)) ⇨ id (univ (Emptyⱼ ⊢Γ))))) (EmptyType ⊢Γ))
[Id]U ⊢Γ (Πᵣ′ % .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢A , ⊢ΠFG , D ]] ⊢F ⊢G A≡A [F] [G] G-ext)
(Πᵣ′ ! .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ [[ ⊢B , ⊢ΠF₁G₁ , D' ]] ⊢F₁ ⊢G₁ B≡B [F₁] [G₁] G₁-ext) =
proj₁ (redSubst* (trans⇒* (univ⇒* (IdURed*Term′ (un-univ ⊢A) (un-univ ⊢ΠFG) (un-univ⇒* D) (un-univ ⊢B)))
(trans⇒* (univ⇒* (IdUΠRed*Term′ (un-univ ⊢F) (un-univ ⊢G) (un-univ ⊢B) (un-univ ⊢ΠF₁G₁) (un-univ⇒* D')))
(univ (Id-U-ΠΠ!% (λ e → !≢% (PE.sym e)) (un-univ ⊢F) (un-univ ⊢G) (un-univ ⊢F₁) (un-univ ⊢G₁)) ⇨ id (univ (Emptyⱼ ⊢Γ))))) (EmptyType ⊢Γ))
[IdExtShape]U ⊢Γ _ _ (ℕᵥ ℕA [[ ⊢A , ⊢K , D ]]) [A≡A′] _ _ (ℕᵥ NB [[ ⊢B , ⊢L , D₁ ]]) [B≡B′] =
Π₌ (Empty _) (Empty _)
(trans⇒* (univ⇒* (IdURed*Term′ (un-univ ⊢A) (un-univ ⊢K) (un-univ⇒* D) (un-univ ⊢B)))
(trans⇒* (univ⇒* (IdUℕRed*Term′ (un-univ ⊢B) (un-univ ⊢L) (un-univ⇒* D₁))) (univ (Id-U-ℕℕ ⊢Γ) ⇨ id (univ (Unitⱼ ⊢Γ)))))
(≅-univ (Unit≡Unit ⊢Γ))
(λ [ρ] ⊢Δ → id (univ (Emptyⱼ ⊢Δ)))
λ [ρ] ⊢Δ [a] → id (univ (Emptyⱼ ⊢Δ))
[IdExtShape]U ⊢Γ _ _ (ℕᵥ ℕA D) [A≡A′] _ _ (ne neB neB') (ne₌ M D′ neM K≡M) =
let [[ ⊢B , _ , _ ]] = D′
in ne₌ (Id (U ⁰) ℕ M) (univ:⇒*: (transTerm:⇒:* (IdURed*Term (un-univ:⇒*: D) (un-univ ⊢B) ) (IdUℕRed*Term (un-univ:⇒*: D′))))
(IdUℕₙ neM) (~-IdUℕ ⊢Γ K≡M)
[IdExtShape]U ⊢Γ _ _ (ℕᵥ [[ ⊢A , ⊢ℕ , D ]] [[ ⊢A' , ⊢ℕ' , D' ]]) [A≡A′] _ _
(Πᵥ (Πᵣ rF lF lG (≡is≤ PE.refl) (≡is≤ PE.refl) F G D′ ⊢F ⊢G A≡A [F] [G] G-ext)
(Πᵣ rF' lF' lG' (≡is≤ PE.refl) (≡is≤ PE.refl) F' G' D′' ⊢F' ⊢G' A≡A' [F]' [G]' G-ext')) [B≡B′] =
let [B]' = Πᵣ′ rF' lF' lG' (≡is≤ PE.refl) (≡is≤ PE.refl) F' G' D′' ⊢F' ⊢G' A≡A' [F]' [G]' G-ext'
⊢B' = escape [B]'
in trans⇒* (univ⇒* (IdURed*Term′ (un-univ ⊢A') (un-univ ⊢ℕ') (un-univ⇒* D') (un-univ ⊢B')))
(trans⇒* (univ⇒* (IdUℕRed*Term′ (un-univ ⊢B') (Πⱼ ≡is≤ PE.refl ▹ ≡is≤ PE.refl ▹ (un-univ ⊢F') ▹ (un-univ ⊢G')) (un-univ⇒* (red D′'))))
(univ (Id-U-ℕΠ (un-univ ⊢F') (un-univ ⊢G')) ⇨ id (univ (Emptyⱼ ⊢Γ))))
[IdExtShape]U {A} {A′} {B} {B′} ⊢Γ _ _ (ne neA neA') (ne₌ M D neM K≡M) [B] [B'] [ShapeB] [B≡B′] =
let ⊢B' = escape [B']
B≡B' = escapeEq [B] [B≡B′]
in ne₌ (Id (U ⁰) M B′) (univ:⇒*: (IdURed*Term (un-univ:⇒*: D) (un-univ ⊢B')))
(IdUₙ neM) (~-IdU ⊢Γ K≡M (≅-un-univ B≡B'))
[IdExtShape]U ⊢Γ _ _ (Πᵥ (Πᵣ rF lF lG (≡is≤ PE.refl) (≡is≤ PE.refl) F G D′ ⊢F ⊢G A≡A [F] [G] G-ext)
(Πᵣ rF' lF' lG' (≡is≤ PE.refl) (≡is≤ PE.refl) F' G' [[ ⊢A' , ⊢Π' , DΠ' ]] ⊢F' ⊢G' A≡A' [F]' [G]' G-ext')) [A≡A′] _ _
(ℕᵥ [[ ⊢A , ⊢ℕ , D ]] [[ ⊢B' , ⊢ℕ' , D' ]]) [B≡B′] =
trans⇒* (univ⇒* (IdURed*Term′ (un-univ ⊢A') (un-univ ⊢Π') (un-univ⇒* DΠ') (un-univ ⊢B')))
(trans⇒* (univ⇒* (IdUΠRed*Term′ (un-univ ⊢F') (un-univ ⊢G') (un-univ ⊢B') (un-univ ⊢ℕ') (un-univ⇒* D')))
(univ (Id-U-Πℕ (un-univ ⊢F') (un-univ ⊢G')) ⇨ id (univ (Emptyⱼ ⊢Γ))))
[IdExtShape]U ⊢Γ _ _ (Πᵥ (Πᵣ rF' .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F' G' De' ⊢F' ⊢G' A≡A' [F]' [G]' G-ext')
(Πᵣ rF .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F G D ⊢F ⊢G A≡A [F] [G] G-ext)) (Π₌ F′ G′ D′₁ A≡B [F≡F′] [G≡G′])
_ _ (ne neA neB) (ne₌ M D′ neM K≡M) =
let [[ ⊢B , _ , _ ]] = D′
Π≡Π = whrDet* (red D , Whnf.Πₙ) (D′₁ , Whnf.Πₙ)
F≡F' , rF≡rF' , _ , G≡G' , _ = Π-PE-injectivity Π≡Π
in ne₌ (Id (U ⁰) (Π F ^ rF ° ⁰ ▹ G ° ⁰ ° ⁰) M)
(univ:⇒*: (transTerm:⇒:* (IdURed*Term (un-univ:⇒*: D) (un-univ ⊢B) ) (IdUΠRed*Term (un-univ ⊢F) (un-univ ⊢G) (un-univ:⇒*: D′))))
(IdUΠₙ neM) (PE.subst (λ X → _ ⊢ Id (U ⁰) (Π F' ^ rF' ° ⁰ ▹ G' ° ⁰ ° ⁰) _ ~ Id (U ⁰) (Π F ^ X ° ⁰ ▹ G ° ⁰ ° ⁰) M ∷ SProp _ ^ _) (PE.sym rF≡rF')
(~-IdUΠ (≅-un-univ
(PE.subst (λ X → _ ⊢ Π F' ^ rF' ° ⁰ ▹ G' ° ⁰ ° ⁰ ≅ Π F ^ rF' ° ⁰ ▹ X ° ⁰ ° ⁰ ^ _ ) (PE.sym G≡G')
(PE.subst (λ X → _ ⊢ Π F' ^ rF' ° ⁰ ▹ G' ° ⁰ ° ⁰ ≅ Π X ^ rF' ° ⁰ ▹ G′ ° ⁰ ° ⁰ ^ _ ) (PE.sym F≡F') A≡B))) K≡M))
[IdExtShape]U ⊢Γ _ _ (Πᵥ (Πᵣ % .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ [[ ⊢A₁ , ⊢ΠF₁G₁ , D₁ ]] ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext)
(Πᵣ ! .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₂ G₂ [[ ⊢A₂ , ⊢ΠF₂G₂ , D₂ ]] ⊢F₂ ⊢G₂ A₂≡A₂ [F₂] [G₂] G₂-ext))
(Π₌ F′ G′ D′ A≡B [F≡F′] [G≡G′])
_ _ (Πᵥ _ _) (Π₌ F′₁ G′₁ D′₁ A≡B₁ [F≡F′]₁ [G≡G′]₁) =
let ΠFG′≡ΠFG′₁ = whrDet* (D₂ , Πₙ) (D′ , Πₙ)
F′≡F′₁ , rF≡rF′ , _ , G′≡G′₁ , _ = Π-PE-injectivity ΠFG′≡ΠFG′₁
in ⊥-elim (!≢% rF≡rF′)
[IdExtShape]U ⊢Γ _ _ (Πᵥ (Πᵣ ! .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ [[ ⊢A₁ , ⊢ΠF₁G₁ , D₁ ]] ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext)
(Πᵣ % .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₂ G₂ [[ ⊢A₂ , ⊢ΠF₂G₂ , D₂ ]] ⊢F₂ ⊢G₂ A₂≡A₂ [F₂] [G₂] G₂-ext))
(Π₌ F′ G′ D′ A≡B [F≡F′] [G≡G′])
_ _ (Πᵥ _ _) (Π₌ F′₁ G′₁ D′₁ A≡B₁ [F≡F′]₁ [G≡G′]₁) =
let ΠFG′≡ΠFG′₁ = whrDet* (D₂ , Πₙ) (D′ , Πₙ)
F′≡F′₁ , rF≡rF′ , _ , G′≡G′₁ , _ = Π-PE-injectivity ΠFG′≡ΠFG′₁
in ⊥-elim (!≢% (PE.sym rF≡rF′))
[IdExtShape]U ⊢Γ _ _ (Πᵥ _ _)
(Π₌ F′ G′ D′ A≡B [F≡F′] [G≡G′])
_ _ (Πᵥ (Πᵣ % .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ [[ ⊢A₁ , ⊢ΠF₁G₁ , D₁ ]] ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext)
(Πᵣ ! .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₂ G₂ [[ ⊢A₂ , ⊢ΠF₂G₂ , D₂ ]] ⊢F₂ ⊢G₂ A₂≡A₂ [F₂] [G₂] G₂-ext)) (Π₌ F′₁ G′₁ D′₁ A≡B₁ [F≡F′]₁ [G≡G′]₁) =
let ΠFG′≡ΠFG′₁ = whrDet* (D₂ , Πₙ) (D′₁ , Πₙ)
F′≡F′₁ , rF≡rF′ , _ , G′≡G′₁ , _ = Π-PE-injectivity ΠFG′≡ΠFG′₁
in ⊥-elim (!≢% rF≡rF′)
[IdExtShape]U ⊢Γ _ _ (Πᵥ _ _)
(Π₌ F′ G′ D′ A≡B [F≡F′] [G≡G′])
_ _ (Πᵥ (Πᵣ ! .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ [[ ⊢A₁ , ⊢ΠF₁G₁ , D₁ ]] ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext)
(Πᵣ % .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₂ G₂ [[ ⊢A₂ , ⊢ΠF₂G₂ , D₂ ]] ⊢F₂ ⊢G₂ A₂≡A₂ [F₂] [G₂] G₂-ext)) (Π₌ F′₁ G′₁ D′₁ A≡B₁ [F≡F′]₁ [G≡G′]₁) =
let ΠFG′≡ΠFG′₁ = whrDet* (D₂ , Πₙ) (D′₁ , Πₙ)
F′≡F′₁ , rF≡rF′ , _ , G′≡G′₁ , _ = Π-PE-injectivity ΠFG′≡ΠFG′₁
in ⊥-elim (!≢% (PE.sym rF≡rF′))
[IdExtShape]U ⊢Γ _ _ (Πᵥ (Πᵣ ! .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ [[ ⊢A₁ , ⊢ΠF₁G₁ , D₁ ]] ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext)
(Πᵣ ! .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₂ G₂ [[ ⊢A₂ , ⊢ΠF₂G₂ , D₂ ]] ⊢F₂ ⊢G₂ A₂≡A₂ [F₂] [G₂] G₂-ext))
(Π₌ F′ G′ D′ A≡B [F≡F′] [G≡G′])
_ _ (Πᵥ (Πᵣ % .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₃ G₃ [[ ⊢A₃ , ⊢ΠF₃G₃ , D₃ ]] ⊢F₃ ⊢G₃ A₃≡A₃ [F₃] [G₃] G₃-ext)
(Πᵣ % .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₄ G₄ [[ ⊢A₄ , ⊢ΠF₄G₄ , D₄ ]] ⊢F₄ ⊢G₄ A₄≡A₄ [F₄] [G₄] G₄-ext)) (Π₌ F′₁ G′₁ D′₁ A≡B₁ [F≡F′]₁ [G≡G′]₁) =
trans⇒* (univ⇒* (IdURed*Term′ (un-univ ⊢A₂) (un-univ ⊢ΠF₂G₂) (un-univ⇒* D₂) (un-univ ⊢A₄)))
(trans⇒* (univ⇒* (IdUΠRed*Term′ (un-univ ⊢F₂) (un-univ ⊢G₂) (un-univ ⊢A₄) (un-univ ⊢ΠF₄G₄) (un-univ⇒* D₄)))
(univ (Id-U-ΠΠ!% !≢% (un-univ ⊢F₂) (un-univ ⊢G₂) (un-univ ⊢F₄) (un-univ ⊢G₄)) ⇨ id (univ (Emptyⱼ ⊢Γ))))
[IdExtShape]U ⊢Γ _ _ (Πᵥ (Πᵣ % .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ [[ ⊢A₁ , ⊢ΠF₁G₁ , D₁ ]] ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext)
(Πᵣ % .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₂ G₂ [[ ⊢A₂ , ⊢ΠF₂G₂ , D₂ ]] ⊢F₂ ⊢G₂ A₂≡A₂ [F₂] [G₂] G₂-ext))
(Π₌ F′ G′ D′ A≡B [F≡F′] [G≡G′])
_ _ (Πᵥ (Πᵣ ! .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₃ G₃ [[ ⊢A₃ , ⊢ΠF₃G₃ , D₃ ]] ⊢F₃ ⊢G₃ A₃≡A₃ [F₃] [G₃] G₃-ext)
(Πᵣ ! .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₄ G₄ [[ ⊢A₄ , ⊢ΠF₄G₄ , D₄ ]] ⊢F₄ ⊢G₄ A₄≡A₄ [F₄] [G₄] G₄-ext)) (Π₌ F′₁ G′₁ D′₁ A≡B₁ [F≡F′]₁ [G≡G′]₁) =
trans⇒* (univ⇒* (IdURed*Term′ (un-univ ⊢A₂) (un-univ ⊢ΠF₂G₂) (un-univ⇒* D₂) (un-univ ⊢A₄)))
(trans⇒* (univ⇒* (IdUΠRed*Term′ (un-univ ⊢F₂) (un-univ ⊢G₂) (un-univ ⊢A₄) (un-univ ⊢ΠF₄G₄) (un-univ⇒* D₄)))
(univ (Id-U-ΠΠ!% (λ e → !≢% (PE.sym e)) (un-univ ⊢F₂) (un-univ ⊢G₂) (un-univ ⊢F₄) (un-univ ⊢G₄)) ⇨ id (univ (Emptyⱼ ⊢Γ))))
[IdExtShape]U {A₁} {A₂} {A₃} {A₄} {Γ} ⊢Γ _ _
(Πᵥ (Πᵣ ! .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ [[ ⊢A₁ , ⊢ΠF₁G₁ , D₁ ]] ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext)
(Πᵣ ! .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₂ G₂ [[ ⊢A₂ , ⊢ΠF₂G₂ , D₂ ]] ⊢F₂ ⊢G₂ A₂≡A₂ [F₂] [G₂] G₂-ext))
(Π₌ F₂′ G₂′ D₂′ A₁≡A₂′ [F₁≡F₂′] [G₁≡G₂′])
_ _ (Πᵥ (Πᵣ ! .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₃ G₃ [[ ⊢A₃ , ⊢ΠF₃G₃ , D₃ ]] ⊢F₃ ⊢G₃ A₃≡A₃ [F₃] [G₃] G₃-ext)
(Πᵣ ! .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₄ G₄ [[ ⊢A₄ , ⊢ΠF₄G₄ , D₄ ]] ⊢F₄ ⊢G₄ A₄≡A₄ [F₄] [G₄] G₄-ext))
(Π₌ F₄′ G₄′ D₄′ A₃≡A₄′ [F₃≡F₄′] [G₃≡G₄′]) =
∃₌ (Id (U ⁰) F₂ F₄) (E₂.IdGG₁ (step id) (var 0))
E₂.D∃ ∃₁≡∃₂
[IdFF₁≡IdFF₂]
(λ {ρ} {Δ} {e} [ρ] ⊢Δ [e] → irrelevanceEq″ (PE.sym (E₁.wksubst-IdTel ρ e)) (PE.sym (E₂.wksubst-IdTel ρ e)) PE.refl PE.refl
(E₁.[IdGG₁] [ρ] ⊢Δ [e]) (PE.subst (λ X → Δ ⊩⟨ ι ¹ ⟩ X ^ [ % , ι ¹ ]) (PE.sym (E₁.wksubst-IdTel ρ e)) (E₁.[IdGG₁] [ρ] ⊢Δ [e]))
([IdGG₁≡IdGG₂] [ρ] ⊢Δ [e]))
where
Π≡Π = whrDet* (D₂ , Whnf.Πₙ) (D₂′ , Whnf.Πₙ)
F₂≡F₂′ = let x , _ , _ , _ , _ = Π-PE-injectivity Π≡Π in x
G₂≡G₂′ = let _ , _ , _ , x , _ = Π-PE-injectivity Π≡Π in x
Π≡Π′ = whrDet* (D₄ , Whnf.Πₙ) (D₄′ , Whnf.Πₙ)
F₄≡F₄′ = let x , _ , _ , _ , _ = Π-PE-injectivity Π≡Π′ in x
G₄≡G₄′ = let _ , _ , _ , x , _ = Π-PE-injectivity Π≡Π′ in x
A₁≡A₂ = PE.subst₂ (λ X Y → Γ ⊢ Π F₁ ^ ! ° ⁰ ▹ G₁ ° ⁰ ° ⁰ ≅ Π X ^ ! ° ⁰ ▹ Y ° ⁰ ° ⁰ ^ [ ! , ι ⁰ ]) (PE.sym F₂≡F₂′) (PE.sym G₂≡G₂′) A₁≡A₂′
A₃≡A₄ = PE.subst₂ (λ X Y → Γ ⊢ Π F₃ ^ ! ° ⁰ ▹ G₃ ° ⁰ ° ⁰ ≅ Π X ^ ! ° ⁰ ▹ Y ° ⁰ ° ⁰ ^ [ ! , ι ⁰ ]) (PE.sym F₄≡F₄′) (PE.sym G₄≡G₄′) A₃≡A₄′
[F₁≡F₂] = PE.subst (λ X → ∀ {ρ Δ} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → Δ ⊩⟨ ι ⁰ ⟩ wk ρ F₁ ≡ wk ρ X ^ [ ! , ι ⁰ ] / [F₁] [ρ] ⊢Δ)
(PE.sym F₂≡F₂′) [F₁≡F₂′]
[F₃≡F₄] = PE.subst (λ X → ∀ {ρ Δ} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → Δ ⊩⟨ ι ⁰ ⟩ wk ρ F₃ ≡ wk ρ X ^ [ ! , ι ⁰ ] / [F₃] [ρ] ⊢Δ)
(PE.sym F₄≡F₄′) [F₃≡F₄′]
[G₁≡G₂] = PE.subst (λ X → ∀ {ρ Δ a} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ)
→ ([a] : Δ ⊩⟨ ι ⁰ ⟩ a ∷ wk ρ F₁ ^ [ ! , ι ⁰ ] / [F₁] [ρ] ⊢Δ)
→ Δ ⊩⟨ ι ⁰ ⟩ wk (lift ρ) G₁ [ a ] ≡ wk (lift ρ) X [ a ] ^ [ ! , ι ⁰ ] / [G₁] [ρ] ⊢Δ [a])
(PE.sym G₂≡G₂′) [G₁≡G₂′]
[G₃≡G₄] = PE.subst (λ X → ∀ {ρ Δ a} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ)
→ ([a] : Δ ⊩⟨ ι ⁰ ⟩ a ∷ wk ρ F₃ ^ [ ! , ι ⁰ ] / [F₃] [ρ] ⊢Δ)
→ Δ ⊩⟨ ι ⁰ ⟩ wk (lift ρ) G₃ [ a ] ≡ wk (lift ρ) X [ a ] ^ [ ! , ι ⁰ ] / [G₃] [ρ] ⊢Δ [a])
(PE.sym G₄≡G₄′) [G₃≡G₄′]
open IdTypeU-lemmas-2 ⊢Γ ⊢A₁ ⊢ΠF₁G₁ D₁ ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext
⊢A₂ ⊢ΠF₂G₂ D₂ ⊢F₂ ⊢G₂ A₂≡A₂ [F₂] [G₂] G₂-ext
⊢A₃ ⊢ΠF₃G₃ D₃ ⊢F₃ ⊢G₃ A₃≡A₃ [F₃] [G₃] G₃-ext
⊢A₄ ⊢ΠF₄G₄ D₄ ⊢F₄ ⊢G₄ A₄≡A₄ [F₄] [G₄] G₄-ext
A₁≡A₂ A₃≡A₄ [F₁≡F₂] [F₃≡F₄] [G₁≡G₂] [G₃≡G₄]
(λ [ρ] ⊢Δ → [Id]U ⊢Δ ([F₁] [ρ] ⊢Δ) ([F₃] [ρ] ⊢Δ))
(λ [ρ] ⊢Δ [x] [y] → [Id]U ⊢Δ ([G₁] [ρ] ⊢Δ [x]) ([G₃] [ρ] ⊢Δ [y]))
(λ [ρ] ⊢Δ → [Id]U ⊢Δ ([F₂] [ρ] ⊢Δ) ([F₄] [ρ] ⊢Δ))
(λ [ρ] ⊢Δ [x] [y] → [Id]U ⊢Δ ([G₂] [ρ] ⊢Δ [x]) ([G₄] [ρ] ⊢Δ [y]))
(λ [ρ] ⊢Δ [x] [x′] [x≡x′] [y] [y′] [y≡y′] →
[IdExt]U ⊢Δ ([G₁] [ρ] ⊢Δ [x]) ([G₁] [ρ] ⊢Δ [x′]) (G₁-ext [ρ] ⊢Δ [x] [x′] [x≡x′]) ([G₃] [ρ] ⊢Δ [y]) ([G₃] [ρ] ⊢Δ [y′]) (G₃-ext [ρ] ⊢Δ [y] [y′] [y≡y′]))
(λ [ρ] ⊢Δ [x] [x′] [x≡x′] [y] [y′] [y≡y′] →
[IdExt]U ⊢Δ ([G₂] [ρ] ⊢Δ [x]) ([G₂] [ρ] ⊢Δ [x′]) (G₂-ext [ρ] ⊢Δ [x] [x′] [x≡x′]) ([G₄] [ρ] ⊢Δ [y]) ([G₄] [ρ] ⊢Δ [y′]) (G₄-ext [ρ] ⊢Δ [y] [y′] [y≡y′]))
(λ [ρ] ⊢Δ → [IdExt]U ⊢Δ ([F₁] [ρ] ⊢Δ) ([F₂] [ρ] ⊢Δ) ([F₁≡F₂] [ρ] ⊢Δ) ([F₃] [ρ] ⊢Δ) ([F₄] [ρ] ⊢Δ) ([F₃≡F₄] [ρ] ⊢Δ))
(λ [ρ] ⊢Δ [x₁] [x₂] [G₁x₁≡G₂x₂] [x₃] [x₄] [G₃x₃≡G₄x₄] → [IdExt]U ⊢Δ ([G₁] [ρ] ⊢Δ [x₁]) ([G₂] [ρ] ⊢Δ [x₂]) [G₁x₁≡G₂x₂] ([G₃] [ρ] ⊢Δ [x₃]) ([G₄] [ρ] ⊢Δ [x₄]) [G₃x₃≡G₄x₄])
[IdExtShape]U {A₁} {A₂} {A₃} {A₄} {Γ} ⊢Γ _ _
(Πᵥ (Πᵣ % .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ [[ ⊢A₁ , ⊢ΠF₁G₁ , D₁ ]] ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext)
(Πᵣ % .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₂ G₂ [[ ⊢A₂ , ⊢ΠF₂G₂ , D₂ ]] ⊢F₂ ⊢G₂ A₂≡A₂ [F₂] [G₂] G₂-ext))
(Π₌ F₂′ G₂′ D₂′ A₁≡A₂′ [F₁≡F₂′] [G₁≡G₂′])
_ _ (Πᵥ (Πᵣ % .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₃ G₃ [[ ⊢A₃ , ⊢ΠF₃G₃ , D₃ ]] ⊢F₃ ⊢G₃ A₃≡A₃ [F₃] [G₃] G₃-ext)
(Πᵣ % .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₄ G₄ [[ ⊢A₄ , ⊢ΠF₄G₄ , D₄ ]] ⊢F₄ ⊢G₄ A₄≡A₄ [F₄] [G₄] G₄-ext))
(Π₌ F₄′ G₄′ D₄′ A₃≡A₄′ [F₃≡F₄′] [G₃≡G₄′]) =
∃₌ (Id (SProp ⁰) F₂ F₄) (E₂.IdGG₁ (step id) (var 0))
E₂.D∃ ∃₁≡∃₂
[IdFF₁≡IdFF₂]
(λ {ρ} {Δ} {e} [ρ] ⊢Δ [e] → irrelevanceEq″ (PE.sym (E₁.wksubst-IdTel ρ e)) (PE.sym (E₂.wksubst-IdTel ρ e)) PE.refl PE.refl
(E₁.[IdGG₁] [ρ] ⊢Δ [e]) (PE.subst (λ X → Δ ⊩⟨ ι ¹ ⟩ X ^ [ % , ι ¹ ]) (PE.sym (E₁.wksubst-IdTel ρ e)) (E₁.[IdGG₁] [ρ] ⊢Δ [e]))
([IdGG₁≡IdGG₂] [ρ] ⊢Δ [e]))
where
Π≡Π = whrDet* (D₂ , Whnf.Πₙ) (D₂′ , Whnf.Πₙ)
F₂≡F₂′ = let x , _ , _ , _ , _ = Π-PE-injectivity Π≡Π in x
G₂≡G₂′ = let _ , _ , _ , x , _ = Π-PE-injectivity Π≡Π in x
Π≡Π′ = whrDet* (D₄ , Whnf.Πₙ) (D₄′ , Whnf.Πₙ)
F₄≡F₄′ = let x , _ , _ , _ , _ = Π-PE-injectivity Π≡Π′ in x
G₄≡G₄′ = let _ , _ , _ , x , _ = Π-PE-injectivity Π≡Π′ in x
A₁≡A₂ = PE.subst₂ (λ X Y → Γ ⊢ Π F₁ ^ % ° ⁰ ▹ G₁ ° ⁰ ° ⁰ ≅ Π X ^ % ° ⁰ ▹ Y ° ⁰ ° ⁰ ^ [ ! , ι ⁰ ]) (PE.sym F₂≡F₂′) (PE.sym G₂≡G₂′) A₁≡A₂′
A₃≡A₄ = PE.subst₂ (λ X Y → Γ ⊢ Π F₃ ^ % ° ⁰ ▹ G₃ ° ⁰ ° ⁰ ≅ Π X ^ % ° ⁰ ▹ Y ° ⁰ ° ⁰ ^ [ ! , ι ⁰ ]) (PE.sym F₄≡F₄′) (PE.sym G₄≡G₄′) A₃≡A₄′
[F₁≡F₂] = PE.subst (λ X → ∀ {ρ Δ} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → Δ ⊩⟨ ι ⁰ ⟩ wk ρ F₁ ≡ wk ρ X ^ [ % , ι ⁰ ] / [F₁] [ρ] ⊢Δ)
(PE.sym F₂≡F₂′) [F₁≡F₂′]
[F₃≡F₄] = PE.subst (λ X → ∀ {ρ Δ} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → Δ ⊩⟨ ι ⁰ ⟩ wk ρ F₃ ≡ wk ρ X ^ [ % , ι ⁰ ] / [F₃] [ρ] ⊢Δ)
(PE.sym F₄≡F₄′) [F₃≡F₄′]
[G₁≡G₂] = PE.subst (λ X → ∀ {ρ Δ a} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ)
→ ([a] : Δ ⊩⟨ ι ⁰ ⟩ a ∷ wk ρ F₁ ^ [ % , ι ⁰ ] / [F₁] [ρ] ⊢Δ)
→ Δ ⊩⟨ ι ⁰ ⟩ wk (lift ρ) G₁ [ a ] ≡ wk (lift ρ) X [ a ] ^ [ ! , ι ⁰ ] / [G₁] [ρ] ⊢Δ [a])
(PE.sym G₂≡G₂′) [G₁≡G₂′]
[G₃≡G₄] = PE.subst (λ X → ∀ {ρ Δ a} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ)
→ ([a] : Δ ⊩⟨ ι ⁰ ⟩ a ∷ wk ρ F₃ ^ [ % , ι ⁰ ] / [F₃] [ρ] ⊢Δ)
→ Δ ⊩⟨ ι ⁰ ⟩ wk (lift ρ) G₃ [ a ] ≡ wk (lift ρ) X [ a ] ^ [ ! , ι ⁰ ] / [G₃] [ρ] ⊢Δ [a])
(PE.sym G₄≡G₄′) [G₃≡G₄′]
open IdTypeU-lemmas-2 ⊢Γ ⊢A₁ ⊢ΠF₁G₁ D₁ ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext
⊢A₂ ⊢ΠF₂G₂ D₂ ⊢F₂ ⊢G₂ A₂≡A₂ [F₂] [G₂] G₂-ext
⊢A₃ ⊢ΠF₃G₃ D₃ ⊢F₃ ⊢G₃ A₃≡A₃ [F₃] [G₃] G₃-ext
⊢A₄ ⊢ΠF₄G₄ D₄ ⊢F₄ ⊢G₄ A₄≡A₄ [F₄] [G₄] G₄-ext
A₁≡A₂ A₃≡A₄ [F₁≡F₂] [F₃≡F₄] [G₁≡G₂] [G₃≡G₄]
(λ [ρ] ⊢Δ → [Id]SProp ⊢Δ ([F₁] [ρ] ⊢Δ) ([F₃] [ρ] ⊢Δ))
(λ [ρ] ⊢Δ [x] [y] → [Id]U ⊢Δ ([G₁] [ρ] ⊢Δ [x]) ([G₃] [ρ] ⊢Δ [y]))
(λ [ρ] ⊢Δ → [Id]SProp ⊢Δ ([F₂] [ρ] ⊢Δ) ([F₄] [ρ] ⊢Δ))
(λ [ρ] ⊢Δ [x] [y] → [Id]U ⊢Δ ([G₂] [ρ] ⊢Δ [x]) ([G₄] [ρ] ⊢Δ [y]))
(λ [ρ] ⊢Δ [x] [x′] [x≡x′] [y] [y′] [y≡y′] →
[IdExt]U ⊢Δ ([G₁] [ρ] ⊢Δ [x]) ([G₁] [ρ] ⊢Δ [x′]) (G₁-ext [ρ] ⊢Δ [x] [x′] [x≡x′]) ([G₃] [ρ] ⊢Δ [y]) ([G₃] [ρ] ⊢Δ [y′]) (G₃-ext [ρ] ⊢Δ [y] [y′] [y≡y′]))
(λ [ρ] ⊢Δ [x] [x′] [x≡x′] [y] [y′] [y≡y′] →
[IdExt]U ⊢Δ ([G₂] [ρ] ⊢Δ [x]) ([G₂] [ρ] ⊢Δ [x′]) (G₂-ext [ρ] ⊢Δ [x] [x′] [x≡x′]) ([G₄] [ρ] ⊢Δ [y]) ([G₄] [ρ] ⊢Δ [y′]) (G₄-ext [ρ] ⊢Δ [y] [y′] [y≡y′]))
(λ [ρ] ⊢Δ → [IdExt]SProp ⊢Δ ([F₁] [ρ] ⊢Δ) ([F₂] [ρ] ⊢Δ) ([F₁≡F₂] [ρ] ⊢Δ) ([F₃] [ρ] ⊢Δ) ([F₄] [ρ] ⊢Δ) ([F₃≡F₄] [ρ] ⊢Δ))
(λ [ρ] ⊢Δ [x₁] [x₂] [G₁x₁≡G₂x₂] [x₃] [x₄] [G₃x₃≡G₄x₄] → [IdExt]U ⊢Δ ([G₁] [ρ] ⊢Δ [x₁]) ([G₂] [ρ] ⊢Δ [x₂]) [G₁x₁≡G₂x₂] ([G₃] [ρ] ⊢Δ [x₃]) ([G₄] [ρ] ⊢Δ [x₄]) [G₃x₃≡G₄x₄])
[IdExt]U ⊢Γ [A] [A′] [A≡A′] [B] [B′] [B≡B′] = [IdExtShape]U ⊢Γ [A] [A′] (goodCases [A] [A′] [A≡A′]) [A≡A′] [B] [B′] (goodCases [B] [B′] [B≡B′]) [B≡B′]
Ugen' : ∀ {Γ rU l} → (⊢Γ : ⊢ Γ) → ((next l) LogRel.⊩¹U logRelRec (next l) ^ Γ) (Univ rU l) (next l)
Ugen' {Γ} {rU} {⁰} ⊢Γ = Uᵣ rU ⁰ emb< PE.refl ((idRed:*: (Ugenⱼ ⊢Γ)))
Ugen' {Γ} {rU} {¹} ⊢Γ = Uᵣ rU ¹ ∞< PE.refl (idRed:*: (Uⱼ ⊢Γ))
[Id]UGen : ∀ {A t u Γ l}
(⊢Γ : ⊢ Γ)
([A] : (l LogRel.⊩¹U logRelRec l ^ Γ) A (ι ¹))
([t] : Γ ⊩⟨ l ⟩ t ∷ A ^ [ ! , ι ¹ ] / Uᵣ [A])
([u] : Γ ⊩⟨ l ⟩ u ∷ A ^ [ ! , ι ¹ ] / Uᵣ [A])
→ Γ ⊩⟨ l ⟩ Id A t u ^ [ % , ι ¹ ]
[Id]UGen {A} {t} {u} {Γ} {ι .¹} ⊢Γ (Uᵣ ! ⁰ emb< PE.refl [[ ⊢A , ⊢B , D ]]) (Uₜ K d typeK K≡K [t]) (Uₜ M d₁ typeM M≡M [u]) =
let
[t0] : Γ ⊩⟨ ι ⁰ ⟩ t ^ [ ! , ι ⁰ ]
[t0] = PE.subst (λ X → Γ ⊩⟨ ι ⁰ ⟩ X ^ [ ! , ι ⁰ ]) (wk-id t) ([t] Twk.id ⊢Γ)
[u0] = PE.subst (λ X → Γ ⊩⟨ ι ⁰ ⟩ X ^ [ ! , ι ⁰ ]) (wk-id u) ([u] Twk.id ⊢Γ)
⊢tA = conv (un-univ (escape [t0])) (sym (subset* D))
⊢uA = conv (un-univ (escape [u0])) (sym (subset* D))
in proj₁ (redSubst* (IdRed* ⊢tA ⊢uA D) ([Id]U ⊢Γ [t0] [u0]))
[Id]UGen {A} {t} {u} {Γ} {ι .¹} ⊢Γ (Uᵣ % ⁰ emb< PE.refl [[ ⊢A , ⊢B , D ]]) (Uₜ K d typeK K≡K [t]) (Uₜ M d₁ typeM M≡M [u]) =
let
[t0] : Γ ⊩⟨ ι ⁰ ⟩ t ^ [ % , ι ⁰ ]
[t0] = PE.subst (λ X → Γ ⊩⟨ ι ⁰ ⟩ X ^ [ % , ι ⁰ ]) (wk-id t) ([t] Twk.id ⊢Γ)
[u0] = PE.subst (λ X → Γ ⊩⟨ ι ⁰ ⟩ X ^ [ % , ι ⁰ ]) (wk-id u) ([u] Twk.id ⊢Γ)
⊢tA = conv (un-univ (escape [t0])) (sym (subset* D))
⊢uA = conv (un-univ (escape [u0])) (sym (subset* D))
in proj₁ (redSubst* (IdRed* ⊢tA ⊢uA D) ([Id]SProp ⊢Γ [t0] [u0]))
[IdExt]UGen : ∀ {A B t v u w Γ l l'}
(⊢Γ : ⊢ Γ)
([A] : (l LogRel.⊩¹U logRelRec l ^ Γ) A (ι ¹))
([B] : (l' LogRel.⊩¹U logRelRec l' ^ Γ) B (ι ¹))
([A≡B] : Γ ⊩⟨ l ⟩ A ≡ B ^ [ ! , ι ¹ ] / Uᵣ [A])
([t] : Γ ⊩⟨ l ⟩ t ∷ A ^ [ ! , ι ¹ ] / Uᵣ [A])
([v] : Γ ⊩⟨ l' ⟩ v ∷ B ^ [ ! , ι ¹ ] / Uᵣ [B])
([t≡v] : Γ ⊩⟨ l ⟩ t ≡ v ∷ A ^ [ ! , ι ¹ ] / Uᵣ [A])
([u] : Γ ⊩⟨ l ⟩ u ∷ A ^ [ ! , ι ¹ ] / Uᵣ [A])
([w] : Γ ⊩⟨ l' ⟩ w ∷ B ^ [ ! , ι ¹ ] / Uᵣ [B])
([u≡w] : Γ ⊩⟨ l ⟩ u ≡ w ∷ A ^ [ ! , ι ¹ ] / Uᵣ [A])
→ Γ ⊩⟨ l ⟩ Id A t u ≡ Id B v w ^ [ % , ι ¹ ] / [Id]UGen ⊢Γ [A] [t] [u]
[IdExt]UGen {A} {B} {t} {v} {u} {w} {Γ} {.(ι ¹)} {.(ι ¹)} ⊢Γ (Uᵣ ! ⁰ emb< PE.refl d) (Uᵣ r₁ ⁰ emb< PE.refl d₁) [A≡B] [t] [v] [t≡v] [u] [w] [u≡w] =
let U≡U = whrDet* (red d₁ , Uₙ) ([A≡B] , Uₙ)
r≡r , _ = Univ-PE-injectivity U≡U
[UA] = Uᵣ ! ⁰ emb< PE.refl d
[UB] = Uᵣ r₁ ⁰ emb< PE.refl d₁
[U] = Ugen' ⊢Γ
[U]' = Ugen' ⊢Γ
[UA]' , [UAeq] = redSubst* (red d) (Uᵣ [U])
[UB]' , [UBeq] = redSubst* (PE.subst (λ X → Γ ⊢ _ ⇒* Univ X _ ^ _) r≡r (red d₁)) (Uᵣ [U]')
[t]′ = convTerm₁ {t = t} [UA]' (Uᵣ [U]) [UAeq] (irrelevanceTerm (Uᵣ [UA]) [UA]' [t])
[t^] = univEq (Uᵣ [U]) [t]′
[v]′ = convTerm₁ {t = v} [UB]' (Uᵣ [U]) [UBeq] (irrelevanceTerm (Uᵣ [UB]) [UB]' [v])
[v^] = univEq (Uᵣ [U]) [v]′
[t≡v]′ = convEqTerm₁ {t = t} {u = v} [UA]' (Uᵣ [U]) [UAeq] (irrelevanceEqTerm (Uᵣ [UA]) [UA]' [t≡v])
[t≡v^] = univEqEq (Uᵣ [U]) [t^] [t≡v]′
[u]′ = convTerm₁ {t = u} [UA]' (Uᵣ [U]) [UAeq] (irrelevanceTerm (Uᵣ [UA]) [UA]' [u])
[u^] = univEq (Uᵣ [U]) [u]′
[w]′ = convTerm₁ {t = w} [UB]' (Uᵣ [U]) [UBeq] (irrelevanceTerm (Uᵣ [UB]) [UB]' [w])
[w^] = univEq (Uᵣ [U]) [w]′
[u≡w]′ = convEqTerm₁ {t = u} {u = w} [UA]' (Uᵣ [U]) [UAeq] (irrelevanceEqTerm (Uᵣ [UA]) [UA]' [u≡w])
[u≡w^] = univEqEq (Uᵣ [U]) [u^] [u≡w]′
X = irrelevanceEq {A = Id (U ⁰) t u} {B = Id (U ⁰) v w} ([Id]U ⊢Γ [t^] [u^]) ([Id]UGen ⊢Γ [U] [t]′ [u]′) ([IdExt]U ⊢Γ [t^] [v^] [t≡v^] [u^] [w^] [u≡w^])
[IdA] , [IdA≡U] = redSubst* (IdRed* (escapeTerm (Uᵣ [UA]) [t]) (escapeTerm (Uᵣ [UA]) [u]) (red d)) ([Id]UGen ⊢Γ [U] [t]′ [u]′)
[IdB] , [IdB≡U] = redSubst* (IdRed* (escapeTerm (Uᵣ [UB]) [v]) (escapeTerm (Uᵣ [UB]) [w]) (PE.subst (λ X → Γ ⊢ _ ⇒* Univ X _ ^ _) r≡r (red d₁))) ([Id]UGen ⊢Γ [U] [v]′ [w]′)
[IdA≡U]′ = irrelevanceEq {A = Id A t u} {B = Id (U ⁰) t u} [IdA] ([Id]UGen ⊢Γ [UA] [t] [u]) [IdA≡U]
[IdB≡U]′ = irrelevanceEq {A = Id B v w} {B = Id (U ⁰) v w} [IdB] ([Id]UGen ⊢Γ [UB] [v] [w]) [IdB≡U]
in transEq {A = Id A t u} {B = Id (U _) t u} {C = Id B v w} ([Id]UGen ⊢Γ [UA] [t] [u]) ([Id]UGen ⊢Γ [U] [t]′ [u]′) ([Id]UGen ⊢Γ [UB] [v] [w])
[IdA≡U]′
(transEq {A = Id (U _) t u} {B = Id (U _) v w} {C = Id B v w} ([Id]UGen ⊢Γ [U] [t]′ [u]′) ([Id]UGen ⊢Γ [U] [v]′ [w]′) ([Id]UGen ⊢Γ [UB] [v] [w])
X (symEq {A = Id B v w} {B = Id (U _) v w} ([Id]UGen ⊢Γ [UB] [v] [w]) ([Id]UGen ⊢Γ [U] [v]′ [w]′) [IdB≡U]′))
[IdExt]UGen {A} {B} {t} {v} {u} {w} {Γ} {.(ι ¹)} {.(ι ¹)} ⊢Γ (Uᵣ % ⁰ emb< PE.refl d) (Uᵣ r₁ ⁰ emb< PE.refl d₁) [A≡B] [t] [v] [t≡v] [u] [w] [u≡w] =
let U≡U = whrDet* (red d₁ , Uₙ) ([A≡B] , Uₙ)
r≡r , _ = Univ-PE-injectivity U≡U
[UA] = Uᵣ % ⁰ emb< PE.refl d
[UB] = Uᵣ r₁ ⁰ emb< PE.refl d₁
[U] = Ugen' ⊢Γ
[U]' = Ugen' ⊢Γ
[UA]' , [UAeq] = redSubst* (red d) (Uᵣ [U])
[UB]' , [UBeq] = redSubst* (PE.subst (λ X → Γ ⊢ _ ⇒* Univ X _ ^ _) r≡r (red d₁)) (Uᵣ [U]')
[t]′ = convTerm₁ {t = t} [UA]' (Uᵣ [U]) [UAeq] (irrelevanceTerm (Uᵣ [UA]) [UA]' [t])
[t^] = univEq (Uᵣ [U]) [t]′
[v]′ = convTerm₁ {t = v} [UB]' (Uᵣ [U]) [UBeq] (irrelevanceTerm (Uᵣ [UB]) [UB]' [v])
[v^] = univEq (Uᵣ [U]) [v]′
[t≡v]′ = convEqTerm₁ {t = t} {u = v} [UA]' (Uᵣ [U]) [UAeq] (irrelevanceEqTerm (Uᵣ [UA]) [UA]' [t≡v])
[t≡v^] = univEqEq (Uᵣ [U]) [t^] [t≡v]′
[u]′ = convTerm₁ {t = u} [UA]' (Uᵣ [U]) [UAeq] (irrelevanceTerm (Uᵣ [UA]) [UA]' [u])
[u^] = univEq (Uᵣ [U]) [u]′
[w]′ = convTerm₁ {t = w} [UB]' (Uᵣ [U]) [UBeq] (irrelevanceTerm (Uᵣ [UB]) [UB]' [w])
[w^] = univEq (Uᵣ [U]) [w]′
[u≡w]′ = convEqTerm₁ {t = u} {u = w} [UA]' (Uᵣ [U]) [UAeq] (irrelevanceEqTerm (Uᵣ [UA]) [UA]' [u≡w])
[u≡w^] = univEqEq (Uᵣ [U]) [u^] [u≡w]′
X = irrelevanceEq {A = Id (SProp ⁰) t u} {B = Id (SProp ⁰) v w} ([Id]SProp ⊢Γ [t^] [u^]) ([Id]UGen ⊢Γ [U] [t]′ [u]′) ([IdExt]SProp ⊢Γ [t^] [v^] [t≡v^] [u^] [w^] [u≡w^])
[IdA] , [IdA≡U] = redSubst* (IdRed* (escapeTerm (Uᵣ [UA]) [t]) (escapeTerm (Uᵣ [UA]) [u]) (red d)) ([Id]UGen ⊢Γ [U] [t]′ [u]′)
[IdB] , [IdB≡U] = redSubst* (IdRed* (escapeTerm (Uᵣ [UB]) [v]) (escapeTerm (Uᵣ [UB]) [w]) (PE.subst (λ X → Γ ⊢ _ ⇒* Univ X _ ^ _) r≡r (red d₁))) ([Id]UGen ⊢Γ [U] [v]′ [w]′)
[IdA≡U]′ = irrelevanceEq {A = Id A t u} {B = Id (SProp ⁰) t u} [IdA] ([Id]UGen ⊢Γ [UA] [t] [u]) [IdA≡U]
[IdB≡U]′ = irrelevanceEq {A = Id B v w} {B = Id (SProp ⁰) v w} [IdB] ([Id]UGen ⊢Γ [UB] [v] [w]) [IdB≡U]
in transEq {A = Id A t u} {B = Id (SProp _) t u} {C = Id B v w} ([Id]UGen ⊢Γ [UA] [t] [u]) ([Id]UGen ⊢Γ [U] [t]′ [u]′) ([Id]UGen ⊢Γ [UB] [v] [w])
[IdA≡U]′
(transEq {A = Id (SProp _) t u} {B = Id (SProp _) v w} {C = Id B v w} ([Id]UGen ⊢Γ [U] [t]′ [u]′) ([Id]UGen ⊢Γ [U] [v]′ [w]′) ([Id]UGen ⊢Γ [UB] [v] [w])
X (symEq {A = Id B v w} {B = Id (SProp _) v w} ([Id]UGen ⊢Γ [UB] [v] [w]) ([Id]UGen ⊢Γ [U] [v]′ [w]′) [IdB≡U]′))
| {
"alphanum_fraction": 0.4061318241,
"avg_line_length": 68.1678200692,
"ext": "agda",
"hexsha": "87b048d3e4f0cacf7f61a9dfcf7a535f04d85fe4",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-02-15T19:42:19.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-01-26T14:55:51.000Z",
"max_forks_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "CoqHott/logrel-mltt",
"max_forks_repo_path": "Definition/LogicalRelation/Substitution/Introductions/IdUniv.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "CoqHott/logrel-mltt",
"max_issues_repo_path": "Definition/LogicalRelation/Substitution/Introductions/IdUniv.agda",
"max_line_length": 178,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "CoqHott/logrel-mltt",
"max_stars_repo_path": "Definition/LogicalRelation/Substitution/Introductions/IdUniv.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-17T16:13:53.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-06-21T08:39:01.000Z",
"num_tokens": 24723,
"size": 39401
} |
{-# OPTIONS --cubical --safe --postfix-projections #-}
module Cardinality.Finite.Structure where
open import Prelude
open import Data.Fin
open import Data.Nat
open import Data.Nat.Properties
private
variable
n m : ℕ
liftˡ : ∀ n m → Fin m → Fin (n + m)
liftˡ zero m x = x
liftˡ (suc n) m x = fs (liftˡ n m x)
liftʳ : ∀ n m → Fin n → Fin (n + m)
liftʳ (suc n) m f0 = f0
liftʳ (suc n) m (fs x) = fs (liftʳ n m x)
mapl : (A → B) → A ⊎ C → B ⊎ C
mapl f (inl x) = inl (f x)
mapl f (inr x) = inr x
fin-sum-to : ∀ n m → Fin n ⊎ Fin m → Fin (n + m)
fin-sum-to n m = either (liftʳ n m) (liftˡ n m)
fin-sum-from : ∀ n m → Fin (n + m) → Fin n ⊎ Fin m
fin-sum-from zero m x = inr x
fin-sum-from (suc n) m f0 = inl f0
fin-sum-from (suc n) m (fs x) = mapl fs (fin-sum-from n m x)
mapl-distrib : ∀ {a b c d} {A : Type a} {B : Type b} {C : Type c} {D : Type d} (xs : A ⊎ B) (h : A → C) (f : C → D) (g : B → D) → either′ f g (mapl h xs) ≡ either′ (f ∘′ h) g xs
mapl-distrib (inl x) h f g = refl
mapl-distrib (inr x) h f g = refl
either-distrib : ∀ {d} {D : Type d} (f : A → C) (g : B → C) (h : C → D) (xs : A ⊎ B) → either′ (h ∘ f) (h ∘ g) xs ≡ h (either′ f g xs)
either-distrib f g h (inl x) = refl
either-distrib f g h (inr x) = refl
open import Path.Reasoning
fin-sum-to-from : ∀ n m x → fin-sum-to n m (fin-sum-from n m x) ≡ x
fin-sum-to-from zero m x = refl
fin-sum-to-from (suc n) m f0 = refl
fin-sum-to-from (suc n) m (fs x) =
fin-sum-to (suc n) m (mapl fs (fin-sum-from n m x)) ≡⟨ mapl-distrib (fin-sum-from n m x) fs (liftʳ (suc n) m) (liftˡ (suc n) m) ⟩
either (liftʳ (suc n) m ∘ fs) (liftˡ (suc n) m) (fin-sum-from n m x) ≡⟨⟩
either (fs ∘ liftʳ n m) (fs ∘ liftˡ n m) (fin-sum-from n m x) ≡⟨ either-distrib (liftʳ n m) (liftˡ n m) fs (fin-sum-from n m x) ⟩
fs (either (liftʳ n m) (liftˡ n m) (fin-sum-from n m x)) ≡⟨ cong fs (fin-sum-to-from n m x) ⟩
fs x ∎
-- fin-sum-from-to : ∀ n m x → fin-sum-from n m (fin-sum-to n m x) ≡ x
-- fin-sum-from-to n m (inl x) = {!!}
-- fin-sum-from-to n m (inr x) = {!!}
-- fin-sum : ∀ n m → Fin n ⊎ Fin m ⇔ Fin (n + m)
-- fin-sum n m .fun = fin-sum-to n m
-- fin-sum n m .inv = fin-sum-from n m
-- fin-sum n m .rightInv = fin-sum-to-from n m
-- fin-sum n m .leftInv = fin-sum-from-to n m
| {
"alphanum_fraction": 0.5582822086,
"avg_line_length": 33.5588235294,
"ext": "agda",
"hexsha": "c5278de3bfbf1eb20ab2560c6814bfcafc3b73e5",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z",
"max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/combinatorics-paper",
"max_forks_repo_path": "agda/Cardinality/Finite/Structure.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "oisdk/combinatorics-paper",
"max_issues_repo_path": "agda/Cardinality/Finite/Structure.agda",
"max_line_length": 177,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/combinatorics-paper",
"max_stars_repo_path": "agda/Cardinality/Finite/Structure.agda",
"max_stars_repo_stars_event_max_datetime": "2021-01-05T15:32:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-01-05T14:07:44.000Z",
"num_tokens": 980,
"size": 2282
} |
module Data.Signed where
open import Data.Bit using
(Bit
; b0
; b1
; Bits-num
; Bits-neg
; Overflowing
; _overflow:_
; result
; carry
; WithCarry
; _with-carry:_
; toBool
; tryToFinₙ
; !ₙ
; _⊕_
; _↔_
) renaming
( _+_ to bit+
; _-_ to bit-
; ! to bit!
; _&_ to bit&
; _~|_ to bit|
; _^_ to bit^
; _>>_ to bit>>
; _<<_ to bit<<
)
open import Data.Unit using (⊤)
open import Data.Nat using (ℕ; suc; zero) renaming (_≤_ to ℕ≤)
open import Data.Vec using (Vec; _∷_; []; head; tail; replicate)
open import Data.Nat.Literal using (Number)
open import Data.Int.Literal using (Negative)
open import Data.Maybe using (just; nothing)
open import Data.Empty using (⊥)
infixl 8 _-_ _+_
infixl 7 _<<_ _>>_
infixl 6 _&_
infixl 5 _^_
infixl 4 _~|_
record Signed (n : ℕ) : Set where
constructor mk-int
field
bits : Vec Bit n
open Signed public
instance
Signed-num : {m : ℕ} → Number (Signed m)
Signed-num {zero} .Number.Constraint = Number.Constraint (Bits-num {zero})
Signed-num {suc m} .Number.Constraint = Number.Constraint (Bits-num {m})
Signed-num {zero} .Number.fromNat zero ⦃ p ⦄ = mk-int [] where
Signed-num {zero} .Number.fromNat (suc _) ⦃ ℕ≤.s≤s () ⦄
Signed-num {suc m} .Number.fromNat n ⦃ p ⦄ = mk-int (mk-bits p) where
mk-bits : Number.Constraint (Bits-num {m}) n → Vec Bit (suc m)
mk-bits p = b0 ∷ Number.fromNat Bits-num n ⦃ p ⦄
instance
Signed-neg : {m : ℕ} → Negative (Signed (suc m))
Signed-neg {m} .Negative.Constraint = Negative.Constraint (Bits-neg {m})
Signed-neg {m} .Negative.fromNeg n ⦃ p ⦄ = mk-int bitVec where
bitVec : Vec Bit (suc m)
bitVec = Negative.fromNeg (Bits-neg {m}) n ⦃ p ⦄
_+_ : {n : ℕ} → Signed n → Signed n → Overflowing (Signed n)
p + q = mk-int (result sum) overflow: toBool overflow where
sum = bit+ (bits p) (bits q)
last-carry : {n : ℕ} → Vec Bit n → Bit
last-carry [] = b0
last-carry (b ∷ _) = b
overflow = head (carry sum) ⊕ last-carry (tail (carry sum))
_-_ : {n : ℕ} → Signed n → Signed n → Overflowing (Signed n)
p - q = mk-int (result sub) overflow: toBool overflow where
sub = bit- (bits p) (bits q)
last-carry : {n : ℕ} → Vec Bit n → Bit
last-carry [] = b0
last-carry (b ∷ _) = b
overflow = head (carry sub) ↔ last-carry (tail (carry sub))
rotr : {n : ℕ} → Signed n → Signed n → WithCarry (Signed n) (Signed n)
rotr {n} (mk-int ps) (mk-int qs) = new-result with-carry: new-carry where
shifted : WithCarry (Vec Bit n) (Vec Bit n)
shifted with tryToFinₙ qs
... | just i = bit>> ps i
... | nothing = replicate b0 with-carry: ps
new-result : Signed n
new-result = mk-int (result shifted)
new-carry : Signed n
new-carry = mk-int (carry shifted)
rotl : {n : ℕ} → Signed n → Signed n → WithCarry (Signed n) (Signed n)
rotl {n} (mk-int ps) (mk-int qs) = new-result with-carry: new-carry where
shifted : WithCarry (Vec Bit n) (Vec Bit n)
shifted with tryToFinₙ qs
... | just i = bit<< ps i
... | nothing = replicate b0 with-carry: ps
new-result : Signed n
new-result = mk-int (result shifted)
new-carry : Signed n
new-carry = mk-int (carry shifted)
_>>_ : {n : ℕ} → Signed n → Signed n → Signed n
ps >> qs = result (rotr ps qs)
_<<_ : {n : ℕ} → Signed n → Signed n → Signed n
ps << qs = result (rotl ps qs)
arotr : {n : ℕ} → Signed n → Signed n → WithCarry (Signed n) (Signed n)
arotr {n} (mk-int []) _ = mk-int [] with-carry: mk-int []
arotr {suc n} (mk-int (p ∷ ps)) (mk-int qs) = new-result with-carry: new-carry
where
shifted : WithCarry (Vec Bit n) (Vec Bit n)
shifted with tryToFinₙ qs
... | just i = bit>> ps i
... | nothing = replicate b0 with-carry: ps
new-result : Signed (suc n)
new-result = mk-int (p ∷ result shifted)
new-carry : Signed (suc n)
new-carry = mk-int (b0 ∷ carry shifted)
arotl : {n : ℕ} → Signed n → Signed n → WithCarry (Signed n) (Signed n)
arotl {n} (mk-int []) _ = mk-int [] with-carry: mk-int []
arotl {suc n} (mk-int (p ∷ ps)) (mk-int qs) = new-result with-carry: new-carry
where
shifted : WithCarry (Vec Bit n) (Vec Bit n)
shifted with tryToFinₙ qs
... | just i = bit<< ps i
... | nothing = replicate b0 with-carry: ps
new-result : Signed (suc n)
new-result = mk-int (p ∷ result shifted)
new-carry : Signed (suc n)
new-carry = mk-int (b0 ∷ carry shifted)
_a>>_ : {n : ℕ} → Signed n → Signed n → Signed n
ps a>> qs = result (rotr ps qs)
_a<<_ : {n : ℕ} → Signed n → Signed n → Signed n
ps a<< qs = result (rotl ps qs)
! : {n : ℕ} → Signed n → Signed n
! (mk-int ps) = mk-int (!ₙ ps)
_&_ : {n : ℕ} → Signed n → Signed n → Signed n
(mk-int ps) & (mk-int qs) = mk-int (bit& ps qs)
_~|_ : {n : ℕ} → Signed n → Signed n → Signed n
(mk-int ps) ~| (mk-int qs) = mk-int (bit| ps qs)
_^_ : {n : ℕ} → Signed n → Signed n → Signed n
(mk-int ps) ^ (mk-int qs) = mk-int (bit^ ps qs)
| {
"alphanum_fraction": 0.6,
"avg_line_length": 31.7741935484,
"ext": "agda",
"hexsha": "53f8736d78ac5b37caaaa70c0680902b874ff255",
"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": "9f5129d97ee7b89fb8e43136779a78806b7506ab",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "brunoczim/Celeste",
"max_forks_repo_path": "formalization/Data/Signed.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9f5129d97ee7b89fb8e43136779a78806b7506ab",
"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": "brunoczim/Celeste",
"max_issues_repo_path": "formalization/Data/Signed.agda",
"max_line_length": 78,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "9f5129d97ee7b89fb8e43136779a78806b7506ab",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "brunoczim/Celeste",
"max_stars_repo_path": "formalization/Data/Signed.agda",
"max_stars_repo_stars_event_max_datetime": "2020-09-16T17:31:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-09-16T17:31:57.000Z",
"num_tokens": 1768,
"size": 4925
} |
{-# OPTIONS --warning=error --safe --without-K #-}
open import LogicalFormulae
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import Functions
open import Setoids.Setoids
open import Setoids.Subset
open import Graphs.Definition
open import Sets.FinSet.Definition
open import Numbers.Naturals.Semiring
open import Numbers.Naturals.Order
open import Sets.EquivalenceRelations
open import Graphs.CompleteGraph
open import Graphs.Colouring
module Graphs.RamseyTriangle where
hasMonochromaticTriangle : {a : _} {n : ℕ} (G : Graph a (reflSetoid (FinSet n))) → Set (lsuc lzero)
hasMonochromaticTriangle {n = n} G = Sg (FinSet n → Set) λ pred → (subset (reflSetoid (FinSet n)) pred) && {!!}
ramseyForTriangle : (k : ℕ) → Sg ℕ (λ N → (n : ℕ) → (N <N n) → (c : Colouring k (Kn n)) → {!!})
ramseyForTriangle k = {!!}
| {
"alphanum_fraction": 0.7246376812,
"avg_line_length": 34.5,
"ext": "agda",
"hexsha": "8610d6331637094af1708d9bc1b59f0fe3efe821",
"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": "Graphs/RamseyTriangle.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": "Graphs/RamseyTriangle.agda",
"max_line_length": 111,
"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": "Graphs/RamseyTriangle.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": 255,
"size": 828
} |
{-# OPTIONS --sized-types #-}
module SizedTypesRigidVarClash where
postulate
Size : Set
_^ : Size -> Size
∞ : Size
{-# BUILTIN SIZE Size #-}
{-# BUILTIN SIZESUC _^ #-}
{-# BUILTIN SIZEINF ∞ #-}
data Nat : {size : Size} -> Set where
zero : {size : Size} -> Nat {size ^}
suc : {size : Size} -> Nat {size} -> Nat {size ^}
inc : {i j : Size} -> Nat {i} -> Nat {j ^}
inc x = suc x
| {
"alphanum_fraction": 0.5413533835,
"avg_line_length": 19.95,
"ext": "agda",
"hexsha": "5216954232310dc5aa62648ceac3a4cada316838",
"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/fail/SizedTypesRigidVarClash.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/fail/SizedTypesRigidVarClash.agda",
"max_line_length": 52,
"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/fail/SizedTypesRigidVarClash.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 137,
"size": 399
} |
-- Andreas, 2017-01-18, issue #2413
-- As-patterns of variable patterns
data Bool : Set where
true false : Bool
test : Bool → Bool
test x@y = {!x!} -- split on x
test1 : Bool → Bool
test1 x@_ = {!x!} -- split on x
test2 : Bool → Bool
test2 x@y = {!y!} -- split on y
| {
"alphanum_fraction": 0.6080586081,
"avg_line_length": 18.2,
"ext": "agda",
"hexsha": "41b4ab767d76019a85de84f3c3f5b21f726d147d",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/interaction/Issue2413.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/interaction/Issue2413.agda",
"max_line_length": 35,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/interaction/Issue2413.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 101,
"size": 273
} |
module reverse_string where
open import Data.String
open import Data.List
reverse_string : String → String
reverse_string s = fromList (reverse (toList s))
| {
"alphanum_fraction": 0.7974683544,
"avg_line_length": 19.75,
"ext": "agda",
"hexsha": "36d529693dc9ac6a423c03b8795149b789c17298",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z",
"max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d",
"max_forks_repo_licenses": [
"Info-ZIP"
],
"max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData",
"max_forks_repo_path": "Task/Reverse-a-string/Agda/reverse-a-string.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Info-ZIP"
],
"max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData",
"max_issues_repo_path": "Task/Reverse-a-string/Agda/reverse-a-string.agda",
"max_line_length": 48,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d",
"max_stars_repo_licenses": [
"Info-ZIP"
],
"max_stars_repo_name": "LaudateCorpus1/RosettaCodeData",
"max_stars_repo_path": "Task/Reverse-a-string/Agda/reverse-a-string.agda",
"max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z",
"num_tokens": 34,
"size": 158
} |
{-# OPTIONS --safe --without-K #-}
open import Algebra.Bundles using (Monoid)
module Categories.Category.Construction.MonoidAsCategory o {c ℓ} (M : Monoid c ℓ) where
open import Data.Unit.Polymorphic
open import Level
open import Categories.Category.Core
open Monoid M
-- A monoid is a category with one object
MonoidAsCategory : Category o c ℓ
MonoidAsCategory = record
{ Obj = ⊤
; assoc = assoc _ _ _
; sym-assoc = sym (assoc _ _ _)
; identityˡ = identityˡ _
; identityʳ = identityʳ _
; identity² = identityˡ _
; equiv = isEquivalence
; ∘-resp-≈ = ∙-cong
}
| {
"alphanum_fraction": 0.7010309278,
"avg_line_length": 23.28,
"ext": "agda",
"hexsha": "904e2ea5d36b76424c52f8fdc7343f686cf6d45d",
"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": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Code-distancing/agda-categories",
"max_forks_repo_path": "src/Categories/Category/Construction/MonoidAsCategory.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"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": "Code-distancing/agda-categories",
"max_issues_repo_path": "src/Categories/Category/Construction/MonoidAsCategory.agda",
"max_line_length": 87,
"max_stars_count": 5,
"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/Construction/MonoidAsCategory.agda",
"max_stars_repo_stars_event_max_datetime": "2019-05-22T03:54:24.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-05-21T17:07:19.000Z",
"num_tokens": 180,
"size": 582
} |
------------------------------------------------------------------------------
-- Non-terminating GCD
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOT.FOTC.Program.GCD.GCD-NT where
open import Data.Nat
open import Relation.Nullary
------------------------------------------------------------------------------
{-# TERMINATING #-}
gcd : ℕ → ℕ → ℕ
gcd 0 0 = 0
gcd (suc m) 0 = suc m
gcd 0 (suc n) = suc n
gcd (suc m) (suc n) with suc m ≤? suc n
gcd (suc m) (suc n) | yes p = gcd (suc m) (suc n ∸ suc m)
gcd (suc m) (suc n) | no ¬p = gcd (suc m ∸ suc n) (suc n)
| {
"alphanum_fraction": 0.37625,
"avg_line_length": 32,
"ext": "agda",
"hexsha": "f82cc4bf5890c80197f9a2625987d47c72373ace",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z",
"max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/fotc",
"max_forks_repo_path": "notes/FOT/FOTC/Program/GCD/GCD-NT.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/fotc",
"max_issues_repo_path": "notes/FOT/FOTC/Program/GCD/GCD-NT.agda",
"max_line_length": 78,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "notes/FOT/FOTC/Program/GCD/GCD-NT.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": 202,
"size": 800
} |
module Structure.Signature where
open import Data.Tuple.Raise
open import Data.Tuple.Raiseᵣ.Functions
import Lvl
open import Numeral.Natural
open import Structure.Function
open import Structure.Setoid
open import Structure.Relator
open import Type
private variable ℓ ℓᵢ ℓᵢ₁ ℓᵢ₂ ℓᵢ₃ ℓd ℓd₁ ℓd₂ ℓᵣ ℓᵣ₁ ℓᵣ₂ ℓₑ ℓₑ₁ ℓₑ₂ : Lvl.Level
private variable n : ℕ
-- A signature consists of a countable family of sets of function and relation symbols.
-- `functions(n)` and `relations(n)` should be interpreted as the indices for functions/relations of arity `n`.
record Signature : Type{Lvl.𝐒(ℓᵢ₁ Lvl.⊔ ℓᵢ₂)} where
field
functions : ℕ → Type{ℓᵢ₁}
relations : ℕ → Type{ℓᵢ₂}
private variable s : Signature{ℓᵢ₁}{ℓᵢ₂}
import Data.Tuple.Equiv as Tuple
-- A structure with a signature `s` consists of a domain and interpretations of the function/relation symbols in `s`.
record Structure (s : Signature{ℓᵢ₁}{ℓᵢ₂}) : Type{Lvl.𝐒(ℓₑ Lvl.⊔ ℓd Lvl.⊔ ℓᵣ) Lvl.⊔ ℓᵢ₁ Lvl.⊔ ℓᵢ₂} where
open Signature(s)
field
domain : Type{ℓd}
⦃ equiv ⦄ : ∀{n} → Equiv{ℓₑ}(domain ^ n)
⦃ ext ⦄ : ∀{n} → Tuple.Extensionality(equiv{𝐒(𝐒 n)})
function : functions(n) → ((domain ^ n) → domain)
⦃ function-func ⦄ : ∀{fi} → Function(function{n} fi)
relation : relations(n) → ((domain ^ n) → Type{ℓᵣ})
⦃ relation-func ⦄ : ∀{ri} → UnaryRelator(relation{n} ri)
open Structure public using() renaming (domain to dom ; function to fn ; relation to rel)
open import Logic.Predicate
module _ {s : Signature{ℓᵢ₁}{ℓᵢ₂}} where
private variable A B C S : Structure{ℓd = ℓd}{ℓᵣ = ℓᵣ}(s)
private variable fi : Signature.functions s n
private variable ri : Signature.relations s n
private variable xs : dom(S) ^ n
record Homomorphism
(A : Structure{ℓₑ = ℓₑ₁}{ℓd = ℓd₁}{ℓᵣ = ℓᵣ₁}(s))
(B : Structure{ℓₑ = ℓₑ₂}{ℓd = ℓd₂}{ℓᵣ = ℓᵣ₂}(s))
(f : dom(A) → dom(B))
: Type{ℓₑ₁ Lvl.⊔ ℓₑ₂ Lvl.⊔ ℓd₁ Lvl.⊔ ℓd₂ Lvl.⊔ ℓᵣ₁ Lvl.⊔ ℓᵣ₂ Lvl.⊔ Lvl.ofType(Type.of s)}
where
field
⦃ function ⦄ : Function(f)
preserve-functions : ∀{xs : dom(A) ^ n} → (f(fn(A) fi xs) ≡ fn(B) fi (map f xs))
preserve-relations : ∀{xs : dom(A) ^ n} → (rel(A) ri xs) → (rel(B) ri (map f xs))
_→ₛₜᵣᵤ_ : Structure{ℓₑ = ℓₑ₁}{ℓd = ℓd₁}{ℓᵣ = ℓᵣ₁}(s) → Structure{ℓₑ = ℓₑ₂}{ℓd = ℓd₂}{ℓᵣ = ℓᵣ₂}(s) → Type
A →ₛₜᵣᵤ B = ∃(Homomorphism A B)
open import Data
open import Data.Tuple as Tuple using (_,_)
open import Data.Tuple.Raiseᵣ.Proofs
open import Functional
open import Function.Proofs
open import Lang.Instance
open import Structure.Operator
open import Structure.Relator.Properties
open import Syntax.Transitivity
idₛₜᵣᵤ : A →ₛₜᵣᵤ A
∃.witness idₛₜᵣᵤ = id
Homomorphism.preserve-functions (∃.proof (idₛₜᵣᵤ {A = A})) {n} {fi} {xs} = congruence₁(fn A fi) (symmetry(Equiv._≡_ (Structure.equiv A)) ⦃ Equiv.symmetry infer ⦄ map-id)
Homomorphism.preserve-relations (∃.proof (idₛₜᵣᵤ {A = A})) {n} {ri} {xs} = substitute₁ₗ(rel A ri) map-id
_∘ₛₜᵣᵤ_ : let _ = A , B , C in (B →ₛₜᵣᵤ C) → (A →ₛₜᵣᵤ B) → (A →ₛₜᵣᵤ C)
∃.witness (([∃]-intro f) ∘ₛₜᵣᵤ ([∃]-intro g)) = f ∘ g
Homomorphism.function (∃.proof ([∃]-intro f ∘ₛₜᵣᵤ [∃]-intro g)) = [∘]-function {f = f}{g = g}
Homomorphism.preserve-functions (∃.proof (_∘ₛₜᵣᵤ_ {A = A} {B = B} {C = C} ([∃]-intro f ⦃ hom-f ⦄) ([∃]-intro g ⦃ hom-g ⦄))) {fi = fi} = transitivity(_≡_) ⦃ Equiv.transitivity infer ⦄ (transitivity(_≡_) ⦃ Equiv.transitivity infer ⦄ (congruence₁(f) (Homomorphism.preserve-functions hom-g)) (Homomorphism.preserve-functions hom-f)) (congruence₁(fn C fi) (symmetry(Equiv._≡_ (Structure.equiv C)) ⦃ Equiv.symmetry infer ⦄ (map-[∘] {f = f}{g = g})))
Homomorphism.preserve-relations (∃.proof (_∘ₛₜᵣᵤ_ {A = A} {B = B} {C = C} ([∃]-intro f ⦃ hom-f ⦄) ([∃]-intro g ⦃ hom-g ⦄))) {ri = ri} = substitute₁ₗ (rel C ri) map-[∘] ∘ Homomorphism.preserve-relations hom-f ∘ Homomorphism.preserve-relations hom-g
open import Function.Equals
open import Function.Equals.Proofs
open import Logic.Predicate.Equiv
open import Structure.Category
open import Structure.Categorical.Properties
Structure-Homomorphism-category : Category(_→ₛₜᵣᵤ_ {ℓₑ}{ℓd}{ℓᵣ})
Category._∘_ Structure-Homomorphism-category = _∘ₛₜᵣᵤ_
Category.id Structure-Homomorphism-category = idₛₜᵣᵤ
BinaryOperator.congruence (Category.binaryOperator Structure-Homomorphism-category) = [⊜][∘]-binaryOperator-raw
_⊜_.proof (Morphism.Associativity.proof (Category.associativity Structure-Homomorphism-category) {_} {_} {_} {_} {[∃]-intro f} {[∃]-intro g} {[∃]-intro h}) {x} = reflexivity(_≡_) ⦃ Equiv.reflexivity infer ⦄ {f(g(h(x)))}
_⊜_.proof (Morphism.Identityₗ.proof (Tuple.left (Category.identity Structure-Homomorphism-category)) {f = [∃]-intro f}) {x} = reflexivity(_≡_) ⦃ Equiv.reflexivity infer ⦄ {f(x)}
_⊜_.proof (Morphism.Identityᵣ.proof (Tuple.right (Category.identity Structure-Homomorphism-category)) {f = [∃]-intro f}) {x} = reflexivity(_≡_) ⦃ Equiv.reflexivity infer ⦄ {f(x)}
module _ (s : Signature{ℓᵢ₁}{ℓᵢ₂}) where
data Term : Type{ℓᵢ₁} where
var : ℕ → Term
func : (Signature.functions s n) → (Term ^ n) → Term
| {
"alphanum_fraction": 0.6686297605,
"avg_line_length": 49.9411764706,
"ext": "agda",
"hexsha": "4dc3787469a3c7b69c0022807fdd10853201c31c",
"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/Signature.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/Signature.agda",
"max_line_length": 445,
"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/Signature.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": 2166,
"size": 5094
} |
module Issue292-19 where
postulate
I : Set
i₁ i₂ : I
J : Set
j : I → J
data D : I → Set where
d₁ : D i₁
d₂ : D i₂
data P : ∀ i → D i → Set where
p₁ : P i₁ d₁
p₂ : P i₂ d₂
data P′ : ∀ i → D i → Set where
p₁ : P′ i₁ d₁
data E : J → Set where
e₁ : E (j i₁)
e₂ : E (j i₂)
data Q : ∀ i → E i → Set where
q₁ : Q (j i₁) e₁
q₂ : Q (j i₂) e₂
Ok : Q (j i₁) e₁ → Set₁
Ok q₁ = Set
AlsoOk : P i₁ d₁ → Set₁
AlsoOk p₁ = Set
Foo : ∀ {i} (d : D i) → P′ i d → Set₁
Foo d₁ _ = Set
Foo d₂ ()
| {
"alphanum_fraction": 0.4875239923,
"avg_line_length": 13.7105263158,
"ext": "agda",
"hexsha": "29eeb695ef9aaabc671715b96b5e98e6aed743db",
"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/Issue292-19.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/Issue292-19.agda",
"max_line_length": 37,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/Issue292-19.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": 257,
"size": 521
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Data.List.Any.Membership instantiated with propositional equality,
-- along with some additional definitions.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.List.Membership.Propositional {a} {A : Set a} where
open import Data.List.Relation.Unary.Any using (Any)
open import Relation.Binary.PropositionalEquality using (setoid; subst)
import Data.List.Membership.Setoid as SetoidMembership
------------------------------------------------------------------------
-- Re-export contents of setoid membership
open SetoidMembership (setoid A) public hiding (lose)
------------------------------------------------------------------------
-- Other operations
lose : ∀ {p} {P : A → Set p} {x xs} → x ∈ xs → P x → Any P xs
lose = SetoidMembership.lose (setoid A) (subst _)
| {
"alphanum_fraction": 0.5099685205,
"avg_line_length": 35.2962962963,
"ext": "agda",
"hexsha": "2c485fa2a844d5c7afe2f38dd3364872e36458bd",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "omega12345/agda-mode",
"max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Membership/Propositional.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "omega12345/agda-mode",
"max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Membership/Propositional.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Membership/Propositional.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 175,
"size": 953
} |
module TelescopingLet2 where
f : (let ★ = Set) (A : ★) → A → Set₁
f A x = ★
-- should fail, since ★ is not in scope in the definition
| {
"alphanum_fraction": 0.6222222222,
"avg_line_length": 22.5,
"ext": "agda",
"hexsha": "6e833ca7f01d0a4572a5d228742fc6ead898ea91",
"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/TelescopingLet2.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/TelescopingLet2.agda",
"max_line_length": 57,
"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/TelescopingLet2.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": 47,
"size": 135
} |
module Ag05 where
open import Agda.Builtin.Nat
open import Agda.Builtin.Equality
open import Agda.Builtin.Bool
{-
data _≡_ {A : Set} (x : A) : A → Set where
refl : x ≡ x
-}
data Refine : (A : Set) → (A → Set) → Set where
MkRefine : ∀ {A : Set} {f : A → Set} → (a : A) → (f a) → Refine A f
data _∧_ : Set → Set → Set where
and : ∀ (A B : Set) → A ∧ B
-- hl-suc : ∀ {a : Nat} → Refine Nat (λ )
silly : Set
silly = Refine Nat (_≡_ 0)
sillySon : silly
sillySon = MkRefine zero refl
data _≤_ : Nat → Nat → Set where
z≤s : ∀ {b : Nat} → 0 ≤ b
s≤s : ∀ {m n : Nat} → m ≤ n → suc m ≤ suc n
data le-Total (x y : Nat) : Set where
le-left : x ≤ y → le-Total x y
le-right : y ≤ x → le-Total x y
le : Nat → Nat → Bool
le zero zero = true
le zero (suc n) = true
le (suc m) zero = false
le (suc m) (suc n) = le m n
le-wtf : ∀ (x y : Nat) → le-Total x y
le-wtf zero zero = le-left z≤s
le-wtf zero (suc y) = le-left z≤s
le-wtf (suc x) zero = le-right z≤s
le-wtf (suc x) (suc y) with le-wtf x y
... | le-left P = le-left (s≤s P)
... | le-right Q = le-right (s≤s Q)
{- with le x y -- x ≤ y
... | true = {!!}
... | false = {!!}
-}
_⟨_⟩ : (A : Set) → (A → Set) → Set
_⟨_⟩ = Refine
and-refine : ∀ {A : Set} (f g : A → Set)
→ (a : A) → f a → g a
→ Refine A (λ x → (f x) ∧ (g x))
and-refine f g x Pa Pb = MkRefine x (and (f x) (g x))
hSuc : ∀ {m : Nat} → ( Nat ⟨ (λ x → x ≤ m ) ⟩ )
→ ( Nat ⟨ (λ x → x ≤ suc m ) ⟩ )
hSuc (MkRefine a P) = MkRefine (suc a) (s≤s P)
postulate
≤-trans : ∀ {x y z : Nat} → x ≤ y → y ≤ z → x ≤ z
min : ∀ {m n : Nat} → ( Nat ⟨ (λ x → x ≤ m) ⟩ )
→ ( Nat ⟨ (λ x → x ≤ n) ⟩ )
→ ( Nat ⟨ (λ x → (x ≤ m) ∧ (x ≤ n)) ⟩ )
min (MkRefine a Pa) (MkRefine b Pb) with le-wtf a b
... {- a ≤ b -} | le-left P = {!and-refine ? ? Pa ? !}
... {- b ≤ a -} | le-right Q = {!and-refine _ _ ? Pb !}
{-
with le-Total a b
... | le-left a = {!!}
... | le-right b = ? -}
{-
min {m} {n} (MkRefine a P₀) (MkRefine b P₁) with (le a b)
... | true = {!!}
... | false = {!!}
-}
{-
min {m} {n} (MkRefine zero x) (MkRefine b y) = MkRefine 0 (and (zero ≤ m) (zero ≤ n))
min {m} {n} (MkRefine (suc a) x) (MkRefine zero y) = MkRefine 0 (and (zero ≤ m) (zero ≤ n))
min {suc m} {suc n} (MkRefine (suc a) x) (MkRefine (suc b) y) = {!hSuc (min (MkRefine a ?) (MkRefine b ?))!}
-}
| {
"alphanum_fraction": 0.4308450171,
"avg_line_length": 30.6860465116,
"ext": "agda",
"hexsha": "e16ead6ddcd74a26774736dab4a00ae50dfb792a",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-12-13T04:50:46.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-12-13T04:50:46.000Z",
"max_forks_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Brethland/LEARNING-STUFF",
"max_forks_repo_path": "Agda/Ag05.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Brethland/LEARNING-STUFF",
"max_issues_repo_path": "Agda/Ag05.agda",
"max_line_length": 108,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Brethland/LEARNING-STUFF",
"max_stars_repo_path": "Agda/Ag05.agda",
"max_stars_repo_stars_event_max_datetime": "2020-03-11T10:35:42.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-02-03T05:05:52.000Z",
"num_tokens": 1068,
"size": 2639
} |
{-# OPTIONS --without-K --safe #-}
-- the usual notion of mate is defined by two isomorphisms between hom set(oid)s are natural,
-- but due to explicit universe level, a different definition is used.
module Categories.Adjoint.Mate where
open import Level
open import Data.Product using (Σ; _,_)
open import Function.Equality using (Π; _⟶_; _⇨_) renaming (_∘_ to _∙_)
open import Relation.Binary using (Setoid; IsEquivalence)
open import Categories.Category
open import Categories.Category.Instance.Setoids
open import Categories.Functor
open import Categories.Functor.Hom
open import Categories.NaturalTransformation renaming (id to idN)
open import Categories.NaturalTransformation.Equivalence using (_≃_)
open import Categories.Adjoint
import Categories.Morphism.Reasoning as MR
private
variable
o ℓ e : Level
C D : Category o ℓ e
L L′ R R′ : Functor C D
-- this notion of mate can be seen in MacLane in which this notion is shown equivalent to the
-- definition via naturally isomorphic hom setoids.
record Mate {L : Functor C D}
(L⊣R : L ⊣ R) (L′⊣R′ : L′ ⊣ R′)
(α : NaturalTransformation L L′)
(β : NaturalTransformation R′ R) : Set (levelOfTerm L⊣R ⊔ levelOfTerm L′⊣R′) where
private
module L⊣R = Adjoint L⊣R
module L′⊣R′ = Adjoint L′⊣R′
module C = Category C
module D = Category D
field
commute₁ : (R ∘ˡ α) ∘ᵥ L⊣R.unit ≃ (β ∘ʳ L′) ∘ᵥ L′⊣R′.unit
commute₂ : L⊣R.counit ∘ᵥ L ∘ˡ β ≃ L′⊣R′.counit ∘ᵥ (α ∘ʳ R′)
-- there are two equivalent commutative diagram
open NaturalTransformation renaming (commute to η-commute)
open Functor
module _ where
open D
open HomReasoning
open MR D
commute₃ : ∀ {X} → L⊣R.counit.η (F₀ L′ X) ∘ F₁ L (η β (F₀ L′ X)) ∘ F₁ L (L′⊣R′.unit.η X) ≈ η α X
commute₃ {X} = begin
L⊣R.counit.η (F₀ L′ X) ∘ F₁ L (η β (F₀ L′ X)) ∘ F₁ L (L′⊣R′.unit.η X)
≈˘⟨ refl⟩∘⟨ homomorphism L ⟩
L⊣R.counit.η (F₀ L′ X) ∘ F₁ L (η β (F₀ L′ X) C.∘ L′⊣R′.unit.η X)
≈˘⟨ refl⟩∘⟨ F-resp-≈ L commute₁ ⟩
L⊣R.counit.η (F₀ L′ X) ∘ F₁ L (F₁ R (η α X) C.∘ L⊣R.unit.η X)
≈⟨ L⊣R.RLadjunct≈id ⟩
η α X
∎
module _ where
open C
open HomReasoning
open MR C
commute₄ : ∀ {X} → F₁ R (L′⊣R′.counit.η X) ∘ F₁ R (η α (F₀ R′ X)) ∘ L⊣R.unit.η (F₀ R′ X) ≈ η β X
commute₄ {X} = begin
F₁ R (L′⊣R′.counit.η X) ∘ F₁ R (η α (F₀ R′ X)) ∘ L⊣R.unit.η (F₀ R′ X)
≈˘⟨ pushˡ (homomorphism R) ⟩
F₁ R (L′⊣R′.counit.η X D.∘ η α (F₀ R′ X)) ∘ L⊣R.unit.η (F₀ R′ X)
≈˘⟨ F-resp-≈ R commute₂ ⟩∘⟨refl ⟩
F₁ R (L⊣R.counit.η X D.∘ F₁ L (η β X)) ∘ L⊣R.unit.η (F₀ R′ X)
≈⟨ L⊣R.LRadjunct≈id ⟩
η β X
∎
record HaveMate {L L′ : Functor C D} {R R′ : Functor D C}
(L⊣R : L ⊣ R) (L′⊣R′ : L′ ⊣ R′) : Set (levelOfTerm L⊣R ⊔ levelOfTerm L′⊣R′) where
field
α : NaturalTransformation L L′
β : NaturalTransformation R′ R
mate : Mate L⊣R L′⊣R′ α β
module α = NaturalTransformation α
module β = NaturalTransformation β
open Mate mate public
-- show that the commutative diagram implies natural isomorphism between homsetoids.
-- the problem is that two homsetoids live in two universe level, in a situation similar to the definition
-- of adjoint via naturally isomorphic homsetoids.
module _ {L L′ : Functor C D} {R R′ : Functor D C}
{L⊣R : L ⊣ R} {L′⊣R′ : L′ ⊣ R′}
{α : NaturalTransformation L L′}
{β : NaturalTransformation R′ R}
(mate : Mate L⊣R L′⊣R′ α β) where
private
open Mate mate
open Functor
module C = Category C
module D = Category D
module α = NaturalTransformation α
module β = NaturalTransformation β
module L⊣R = Adjoint L⊣R
module L′⊣R′ = Adjoint L′⊣R′
-- there are two squares to show
module _ {X : C.Obj} {Y : D.Obj} where
open Setoid (L′⊣R′.Hom[L-,-].F₀ (X , Y) ⇨ L⊣R.Hom[-,R-].F₀ (X , Y))
open C hiding (_≈_)
open MR C
open C.HomReasoning
module DH = D.HomReasoning
mate-commute₁ : F₁ Hom[ C ][-,-] (C.id , β.η Y) ∙ L′⊣R′.Hom-inverse.to {X} {Y}
≈ L⊣R.Hom-inverse.to {X} {Y} ∙ F₁ Hom[ D ][-,-] (α.η X , D.id)
mate-commute₁ {f} {g} f≈g = begin
β.η Y ∘ (F₁ R′ f ∘ L′⊣R′.unit.η X) ∘ C.id ≈⟨ refl⟩∘⟨ identityʳ ⟩
β.η Y ∘ F₁ R′ f ∘ L′⊣R′.unit.η X ≈⟨ pullˡ (β.commute f) ⟩
(F₁ R f ∘ β.η (F₀ L′ X)) ∘ L′⊣R′.unit.η X ≈˘⟨ pushʳ commute₁ ⟩
F₁ R f ∘ F₁ R (α.η X) ∘ L⊣R.unit.η X ≈˘⟨ pushˡ (homomorphism R) ⟩
F₁ R (f D.∘ α.η X) ∘ L⊣R.unit.η X ≈⟨ F-resp-≈ R (D.∘-resp-≈ˡ f≈g DH.○ DH.⟺ D.identityˡ) ⟩∘⟨refl ⟩
F₁ R (D.id D.∘ g D.∘ α.η X) ∘ L⊣R.unit.η X ∎
module _ {X : C.Obj} {Y : D.Obj} where
open Setoid (L′⊣R′.Hom[-,R-].F₀ (X , Y) ⇨ L⊣R.Hom[L-,-].F₀ (X , Y))
open D hiding (_≈_)
open MR D
open D.HomReasoning
module CH = C.HomReasoning
mate-commute₂ : F₁ Hom[ D ][-,-] (α.η X , D.id) ∙ L′⊣R′.Hom-inverse.from {X} {Y}
≈ L⊣R.Hom-inverse.from {X} {Y} ∙ F₁ Hom[ C ][-,-] (C.id , β.η Y)
mate-commute₂ {f} {g} f≈g = begin
D.id ∘ (L′⊣R′.counit.η Y ∘ F₁ L′ f) ∘ α.η X ≈⟨ identityˡ ⟩
(L′⊣R′.counit.η Y ∘ F₁ L′ f) ∘ α.η X ≈˘⟨ pushʳ (α.commute f) ⟩
L′⊣R′.counit.η Y ∘ α.η (F₀ R′ Y) ∘ F₁ L f ≈˘⟨ pushˡ commute₂ ⟩
(L⊣R.counit.η Y ∘ F₁ L (β.η Y)) ∘ F₁ L f ≈˘⟨ pushʳ (homomorphism L) ⟩
L⊣R.counit.η Y ∘ F₁ L (β.η Y C.∘ f) ≈⟨ refl⟩∘⟨ F-resp-≈ L (C.∘-resp-≈ʳ (f≈g CH.○ CH.⟺ C.identityʳ)) ⟩
L⊣R.counit.η Y ∘ F₁ L (β.η Y C.∘ g C.∘ C.id) ∎
-- alternatively, if commute₃ and commute₄ are shown, then a Mate can be constructed.
module _ {L L′ : Functor C D} {R R′ : Functor D C}
{L⊣R : L ⊣ R} {L′⊣R′ : L′ ⊣ R′}
{α : NaturalTransformation L L′}
{β : NaturalTransformation R′ R} where
private
open Functor
module C = Category C
module D = Category D
module α = NaturalTransformation α
module β = NaturalTransformation β
module L⊣R = Adjoint L⊣R
module L′⊣R′ = Adjoint L′⊣R′
module _ (commute₃ : ∀ {X} → L⊣R.counit.η (F₀ L′ X) D.∘ F₁ L (β.η (F₀ L′ X)) D.∘ F₁ L (L′⊣R′.unit.η X) D.≈ α.η X) where
open C
open HomReasoning
commute₁ : ∀ {X} → F₁ R (α.η X) ∘ L⊣R.unit.η X ≈ β.η (F₀ L′ X) ∘ L′⊣R′.unit.η X
commute₁ {X} = begin
F₁ R (α.η X) ∘ L⊣R.unit.η X
≈˘⟨ F-resp-≈ R commute₃ ⟩∘⟨refl ⟩
F₁ R (L⊣R.counit.η (F₀ L′ X) D.∘ F₁ L (β.η (F₀ L′ X)) D.∘ F₁ L (L′⊣R′.unit.η X)) ∘ L⊣R.unit.η X
≈˘⟨ F-resp-≈ R (D.∘-resp-≈ʳ (homomorphism L)) ⟩∘⟨refl ⟩
F₁ R (L⊣R.counit.η (F₀ L′ X) D.∘ F₁ L (β.η (F₀ L′ X) ∘ L′⊣R′.unit.η X)) ∘ L⊣R.unit.η X
≈⟨ L⊣R.LRadjunct≈id ⟩
β.η (F₀ L′ X) ∘ L′⊣R′.unit.η X
∎
module _ (commute₄ : ∀ {X} → F₁ R (L′⊣R′.counit.η X) C.∘ F₁ R (α.η (F₀ R′ X)) C.∘ L⊣R.unit.η (F₀ R′ X) C.≈ β.η X) where
open D
open HomReasoning
open MR C
commute₂ : ∀ {X} → L⊣R.counit.η X ∘ F₁ L (β.η X) ≈ L′⊣R′.counit.η X ∘ α.η (F₀ R′ X)
commute₂ {X} = begin
L⊣R.counit.η X ∘ F₁ L (β.η X)
≈˘⟨ refl⟩∘⟨ F-resp-≈ L commute₄ ⟩
L⊣R.counit.η X ∘ F₁ L (F₁ R (L′⊣R′.counit.η X) C.∘ F₁ R (α.η (F₀ R′ X)) C.∘ L⊣R.unit.η (F₀ R′ X))
≈˘⟨ refl⟩∘⟨ F-resp-≈ L (pushˡ (homomorphism R)) ⟩
L⊣R.counit.η X ∘ F₁ L (F₁ R (L′⊣R′.counit.η X ∘ α.η (F₀ R′ X)) C.∘ L⊣R.unit.η (F₀ R′ X))
≈⟨ L⊣R.RLadjunct≈id ⟩
L′⊣R′.counit.η X ∘ α.η (F₀ R′ X)
∎
mate′ : (∀ {X} → L⊣R.counit.η (F₀ L′ X) D.∘ F₁ L (β.η (F₀ L′ X)) D.∘ F₁ L (L′⊣R′.unit.η X) D.≈ α.η X) →
(∀ {X} → F₁ R (L′⊣R′.counit.η X) C.∘ F₁ R (α.η (F₀ R′ X)) C.∘ L⊣R.unit.η (F₀ R′ X) C.≈ β.η X) →
Mate L⊣R L′⊣R′ α β
mate′ commute₃ commute₄ = record
{ commute₁ = commute₁ commute₃
; commute₂ = commute₂ commute₄
}
| {
"alphanum_fraction": 0.5419387886,
"avg_line_length": 39.6395939086,
"ext": "agda",
"hexsha": "e2e725cb4f8983d6f6535e0e0d1c614219e77f38",
"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/Adjoint/Mate.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/Adjoint/Mate.agda",
"max_line_length": 121,
"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/Adjoint/Mate.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": 3777,
"size": 7809
} |
open import Agda.Builtin.List
map : ∀ {a b} {A : Set a} {B : Set b} → (A → B) → List A → List B
map f [] = []
map f (x ∷ xs) = f x ∷ map f xs
foldr : ∀ {a b} {A : Set a} {B : Set b} → (A → B → B) → B → List A → B
foldr c n [] = n
foldr c n (x ∷ xs) = c x (foldr c n xs)
data Rose (A : Set) : Set where
leaf : (a : A) → Rose A
node : (rs : List (Rose A)) → Rose A
record IsSeq (A S : Set) : Set where
field
nil : S
sg : (a : A) → S
_∙_ : (s t : S) → S
concat : (ss : List S) → S
concat = foldr _∙_ nil
open IsSeq {{...}}
{-# TERMINATING #-}
flatten : ∀{A S} {{_ : IsSeq A S}} → Rose A → S
flatten (leaf a) = sg a
flatten (node rs) = concat (map flatten rs)
| {
"alphanum_fraction": 0.4885386819,
"avg_line_length": 23.2666666667,
"ext": "agda",
"hexsha": "7ba773f267d1699b339075e94bf242692164809a",
"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/Issue3175.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/Issue3175.agda",
"max_line_length": 70,
"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/Issue3175.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": 289,
"size": 698
} |
{-# OPTIONS --safe --experimental-lossy-unification #-}
{-
This file contains:
1. The long exact sequence of loop spaces Ωⁿ (fib f) → Ωⁿ A → Ωⁿ B
2. The long exact sequence of homotopy groups πₙ(fib f) → πₙ A → πₙ B
3. Some lemmas relating the map in the sequence to maps using the
other definition of πₙ (maps from Sⁿ)
-}
module Cubical.Homotopy.Group.LES where
open import Cubical.Homotopy.Loopspace
open import Cubical.Homotopy.Group.Base
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Pointed
open import Cubical.Foundations.Pointed.Homogeneous
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.GroupoidLaws renaming (assoc to ∙assoc)
open import Cubical.Foundations.Path
open import Cubical.Foundations.Isomorphism
open Iso
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Function
open import Cubical.HITs.SetTruncation
renaming (rec to sRec
; elim to sElim ; elim2 to sElim2
; map to sMap)
open import Cubical.HITs.PropositionalTruncation
renaming (rec to pRec)
open import Cubical.Data.Sigma
open import Cubical.Data.Nat
open import Cubical.Algebra.Group
open import Cubical.Algebra.Group.Morphisms
open import Cubical.Algebra.Group.MorphismProperties
open import Cubical.Algebra.Group.GroupPath
-- We will need an explicitly defined equivalence
-- (PathP (λ i → p i ≡ y) q q) ≃ (sym q ∙∙ p ∙∙ q ≡ refl)
-- This is given by →∙∙lCancel below
module _ {ℓ : Level} {A : Type ℓ} {x y : A} (p : x ≡ x) (q : x ≡ y) where
→∙∙lCancel-fill : PathP (λ i → p i ≡ y) q q → I → I → I → A
→∙∙lCancel-fill PP k i j =
hfill (λ k → λ {(i = i0) → doubleCompPath-filler (sym q) p q k j
; (i = i1) → y
; (j = i0) → q (i ∨ k)
; (j = i1) → q (i ∨ k)})
(inS (PP j i))
k
←∙∙lCancel-fill : sym q ∙∙ p ∙∙ q ≡ refl → I → I → I → A
←∙∙lCancel-fill PP k i j =
hfill (λ k → λ {(i = i0) → q (j ∨ ~ k)
; (i = i1) → q (j ∨ ~ k)
; (j = i0) → doubleCompPath-filler (sym q) p q (~ k) i
; (j = i1) → y})
(inS (PP j i))
k
→∙∙lCancel : PathP (λ i → p i ≡ y) q q → sym q ∙∙ p ∙∙ q ≡ refl
→∙∙lCancel PP i j = →∙∙lCancel-fill PP i1 i j
←∙∙lCancel : sym q ∙∙ p ∙∙ q ≡ refl → PathP (λ i → p i ≡ y) q q
←∙∙lCancel PP i j = ←∙∙lCancel-fill PP i1 i j
←∙∙lCancel→∙∙lCancel : (PP : PathP (λ i → p i ≡ y) q q)
→ ←∙∙lCancel (→∙∙lCancel PP) ≡ PP
←∙∙lCancel→∙∙lCancel PP r i j =
hcomp (λ k → λ {(r = i0) → ←∙∙lCancel-fill (→∙∙lCancel PP) k i j
; (r = i1) → PP i j
; (j = i0) → doubleCompPath-filler (sym q) p q (~ k ∧ ~ r) i
; (j = i1) → y
; (i = i0) → q (j ∨ ~ k ∧ ~ r)
; (i = i1) → q (j ∨ ~ k ∧ ~ r)})
(hcomp (λ k → λ {(r = i0) → →∙∙lCancel-fill PP k j i
; (r = i1) → PP i j
; (j = i0) → doubleCompPath-filler (sym q) p q (k ∧ ~ r) i
; (j = i1) → y
; (i = i0) → q (j ∨ k ∧ ~ r)
; (i = i1) → q (j ∨ k ∧ ~ r)})
(PP i j))
→∙∙lCancel←∙∙lCancel : (PP : sym q ∙∙ p ∙∙ q ≡ refl)
→ →∙∙lCancel (←∙∙lCancel PP) ≡ PP
→∙∙lCancel←∙∙lCancel PP r i j =
hcomp (λ k → λ {(r = i0) → →∙∙lCancel-fill (←∙∙lCancel PP) k i j
; (r = i1) → PP i j
; (j = i0) → q (i ∨ k ∨ r)
; (j = i1) → q (i ∨ k ∨ r)
; (i = i0) → doubleCompPath-filler (sym q) p q (r ∨ k) j
; (i = i1) → y})
(hcomp (λ k → λ {(r = i0) → ←∙∙lCancel-fill PP k j i
; (r = i1) → PP i j
; (j = i0) → q (i ∨ r ∨ ~ k)
; (j = i1) → q (i ∨ r ∨ ~ k)
; (i = i0) → doubleCompPath-filler (sym q) p q (r ∨ ~ k) j
; (i = i1) → y})
(PP i j))
←∙∙lCancel-refl-refl :
{ℓ : Level} {A : Type ℓ} {x : A} (p : refl {x = x} ≡ refl)
→ ←∙∙lCancel {x = x} {y = x} refl refl (sym (rUnit refl) ∙ p)
≡ flipSquare p
←∙∙lCancel-refl-refl p k i j =
hcomp (λ r → λ { (i = i0) → p i0 i0
; (i = i1) → p i0 i0
; (j = i0) → rUnit (λ _ → p i0 i0) (~ r) i
; (j = i1) → p i0 i0
; (k = i0) → ←∙∙lCancel-fill refl refl (sym (rUnit refl) ∙ p) r i j
; (k = i1) → compPath-filler' (sym (rUnit refl)) p (~ r) j i})
((sym (rUnit refl) ∙ p) j i)
{- We need an iso Ω(fib f) ≅ fib(Ω f) -}
ΩFibreIso : {ℓ ℓ' : Level} {A : Pointed ℓ} {B : Pointed ℓ'} (f : A →∙ B)
→ Iso (typ (Ω (fiber (fst f) (pt B) , (pt A) , snd f)))
(fiber (Ω→ f .fst) refl)
fun (ΩFibreIso f) p = (cong fst p) ,
→∙∙lCancel (cong (fst f) (cong fst p)) (snd f)
(cong snd p)
fst (inv (ΩFibreIso f) (p , q) i) = p i
snd (inv (ΩFibreIso f) (p , q) i) = ←∙∙lCancel (cong (fst f) p) (snd f) q i
rightInv (ΩFibreIso f) (p , q) = ΣPathP (refl , →∙∙lCancel←∙∙lCancel _ _ q)
fst (leftInv (ΩFibreIso f) p i j) = fst (p j)
snd (leftInv (ΩFibreIso f) p i j) k =
←∙∙lCancel→∙∙lCancel _ _ (cong snd p) i j k
{- Some homomorphism properties of the above iso -}
ΩFibreIsopres∙fst : {ℓ ℓ' : Level} {A : Pointed ℓ} {B : Pointed ℓ'} (f : A →∙ B)
→ (p q : (typ (Ω (fiber (fst f) (pt B) , (pt A) , snd f))))
→ fst (fun (ΩFibreIso f) (p ∙ q))
≡ fst (fun (ΩFibreIso f) p) ∙ fst (fun (ΩFibreIso f) q)
ΩFibreIsopres∙fst f p q = cong-∙ fst p q
ΩFibreIso⁻pres∙snd : {ℓ ℓ' : Level} {A : Pointed ℓ} {B : Pointed ℓ'}
(f : A →∙ B) (p q : typ (Ω (Ω B)))
→ inv (ΩFibreIso f) (refl , (Ω→ f .snd ∙ p ∙ q))
≡ inv (ΩFibreIso f) (refl , Ω→ f .snd ∙ p)
∙ inv (ΩFibreIso f) (refl , Ω→ f .snd ∙ q)
ΩFibreIso⁻pres∙snd {A = A} {B = B}=
→∙J (λ b₀ f → (p q : typ (Ω (Ω (fst B , b₀))))
→ inv (ΩFibreIso f) (refl , (Ω→ f .snd ∙ p ∙ q))
≡ inv (ΩFibreIso f) (refl , Ω→ f .snd ∙ p)
∙ inv (ΩFibreIso f) (refl , Ω→ f .snd ∙ q))
ind
where
ind : (f : typ A → typ B) (p q : typ (Ω (Ω (fst B , f (pt A)))))
→ inv (ΩFibreIso (f , refl)) (refl , (sym (rUnit refl) ∙ p ∙ q))
≡ inv (ΩFibreIso (f , refl)) (refl , sym (rUnit refl) ∙ p)
∙ inv (ΩFibreIso (f , refl)) (refl , sym (rUnit refl) ∙ q)
fst (ind f p q i j) =
(rUnit refl
∙ sym (cong-∙ fst
(inv (ΩFibreIso (f , refl)) (refl , sym (rUnit refl) ∙ p))
(inv (ΩFibreIso (f , refl)) (refl , sym (rUnit refl) ∙ q)))) i j
snd (ind f p q i j) k =
hcomp (λ r
→ λ {(i = i0) → ←∙∙lCancel-refl-refl (p ∙ q) (~ r) j k --
; (i = i1) →
snd (compPath-filler
(inv (ΩFibreIso (f , refl))
(refl , sym (rUnit refl) ∙ p))
(inv (ΩFibreIso (f , refl))
(refl , sym (rUnit refl) ∙ q)) r j) k
; (j = i0) → f (snd A)
; (j = i1) → snd (inv (ΩFibreIso (f , refl))
(refl , sym (rUnit refl) ∙ q) (r ∨ ~ i)) k
; (k = i0) → main r i j
; (k = i1) → f (snd A)})
(hcomp (λ r → λ {(i = i0) → (p ∙ q) k j
; (i = i1) → ←∙∙lCancel-refl-refl p (~ r) j k
; (j = i0) → f (snd A)
; (j = i1) → ←∙∙lCancel-refl-refl q (~ r) (~ i) k
; (k = i0) → f (pt A)
; (k = i1) → f (snd A)})
(hcomp (λ r → λ {(i = i0) → (compPath-filler' p q r) k j
; (i = i1) → p (k ∨ ~ r) j
; (j = i0) → f (snd A)
; (j = i1) → q k (~ i)
; (k = i0) → p (k ∨ ~ r) j
; (k = i1) → f (snd A)})
(q k (~ i ∧ j))))
where
P = (inv (ΩFibreIso (f , refl)) (refl , sym (rUnit refl) ∙ p))
Q = (inv (ΩFibreIso (f , refl)) (refl , sym (rUnit refl) ∙ q))
main : I → I → I → fst B
main r i j =
hcomp (λ k → λ {(i = i0) → f (snd A)
; (i = i1) → f (fst (compPath-filler P Q (r ∨ ~ k) j))
; (j = i0) → f (snd A)
; (j = i1) → f (snd A)
; (r = i0) → f (fst (compPath-filler P Q (i ∧ ~ k) j))
; (r = i1) → f ((rUnit refl ∙ sym (cong-∙ fst P Q)) i j)})
(hcomp (λ k → λ {(i = i0) → f (rUnit (λ _ → pt A) (~ k ∧ r) j)
; (i = i1) → f (fst ((P ∙ Q) j))
; (j = i0) → f (snd A)
; (j = i1) → f (snd A)
; (r = i0) → f (fst (compPath-filler P Q i j))
; (r = i1) → f ((compPath-filler' (rUnit refl)
(sym (cong-∙ fst P Q)) k) i j)})
(hcomp (λ k → λ {(i = i0) → f (rUnit (λ _ → pt A) (k ∧ r) j)
; (i = i1) → f (fst (compPath-filler P Q k j))
; (j = i0) → f (snd A)
; (j = i1) → f (snd A)
; (r = i0) → f (fst (compPath-filler P Q (i ∧ k) j))
; (r = i1) → f ((cong-∙∙-filler fst refl P Q) k (~ i) j)})
(f (snd A))))
ΩFibreIso∙ : {ℓ ℓ' : Level} {A : Pointed ℓ} {B : Pointed ℓ'} (f : A →∙ B)
→ Iso.fun (ΩFibreIso f) refl ≡ (refl , (∙∙lCancel (snd f)))
ΩFibreIso∙ {A = A} {B = B} =
→∙J (λ b f → Iso.fun (ΩFibreIso f) refl ≡ (refl , (∙∙lCancel (snd f))))
λ f → ΣPathP (refl , help f)
where
help : (f : fst A → fst B) →
→∙∙lCancel (λ i → f (snd A)) refl (λ i → refl)
≡ ∙∙lCancel refl
help f i j r =
hcomp (λ k → λ {(i = i0) →
→∙∙lCancel-fill (λ _ → f (snd A)) refl refl k j r
; (i = i1) → ∙∙lCancel-fill (λ _ → f (snd A)) j r k
; (j = i0) → rUnit (λ _ → f (snd A)) k r
; (j = i1) → f (snd A)
; (r = i1) → f (snd A)
; (r = i0) → f (snd A)})
(f (snd A))
ΩFibreIso⁻∙ : {ℓ ℓ' : Level} {A : Pointed ℓ} {B : Pointed ℓ'} (f : A →∙ B)
→ Iso.inv (ΩFibreIso f) (refl , (∙∙lCancel (snd f))) ≡ refl
ΩFibreIso⁻∙ f =
cong (Iso.inv (ΩFibreIso f)) (sym (ΩFibreIso∙ f)) ∙ leftInv (ΩFibreIso f) refl
{- Ωⁿ (fib f) ≃∙ fib (Ωⁿ f) -}
Ω^Fibre≃∙ : {ℓ ℓ' : Level} {A : Pointed ℓ} {B : Pointed ℓ'} (n : ℕ) (f : A →∙ B)
→ ((Ω^ n) (fiber (fst f) (pt B) , (pt A) , snd f))
≃∙ ((fiber (Ω^→ n f .fst) (snd ((Ω^ n) B)))
, (snd ((Ω^ n) A)) , (Ω^→ n f .snd))
Ω^Fibre≃∙ zero f = (idEquiv _) , refl
Ω^Fibre≃∙ (suc n) f =
compEquiv∙
(Ω≃∙ (Ω^Fibre≃∙ n f))
((isoToEquiv (ΩFibreIso (Ω^→ n f))) , ΩFibreIso∙ (Ω^→ n f))
{- Its inverse iso directly defined -}
Ω^Fibre≃∙⁻ : {ℓ ℓ' : Level} {A : Pointed ℓ} {B : Pointed ℓ'}
(n : ℕ) (f : A →∙ B)
→ ((fiber (Ω^→ n f .fst) (snd ((Ω^ n) B)))
, (snd ((Ω^ n) A)) , (Ω^→ n f .snd))
≃∙ ((Ω^ n) (fiber (fst f) (pt B) , (pt A) , snd f))
Ω^Fibre≃∙⁻ zero f = (idEquiv _) , refl
Ω^Fibre≃∙⁻ (suc n) f =
compEquiv∙
((isoToEquiv (invIso (ΩFibreIso (Ω^→ n f))))
, (ΩFibreIso⁻∙ (Ω^→ n f)))
(Ω≃∙ (Ω^Fibre≃∙⁻ n f))
isHomogeneousΩ^→fib : {ℓ ℓ' : Level} {A : Pointed ℓ} {B : Pointed ℓ'}
(n : ℕ) (f : A →∙ B)
→ isHomogeneous
((fiber (Ω^→ (suc n) f .fst) (snd ((Ω^ (suc n)) B)))
, (snd ((Ω^ (suc n)) A)) , (Ω^→ (suc n) f .snd))
isHomogeneousΩ^→fib n f =
subst isHomogeneous (ua∙ ((fst (Ω^Fibre≃∙ (suc n) f)))
(snd (Ω^Fibre≃∙ (suc n) f)))
(isHomogeneousPath _ _)
Ω^Fibre≃∙sect : {ℓ ℓ' : Level} {A : Pointed ℓ} {B : Pointed ℓ'}
(n : ℕ) (f : A →∙ B)
→ (≃∙map (Ω^Fibre≃∙⁻ n f) ∘∙ ≃∙map (Ω^Fibre≃∙ n f))
≡ idfun∙ _
Ω^Fibre≃∙sect zero f = ΣPathP (refl , (sym (rUnit refl)))
Ω^Fibre≃∙sect (suc n) f =
→∙Homogeneous≡ (isHomogeneousPath _ _)
(funExt
λ p → cong (fst (fst (Ω≃∙ (Ω^Fibre≃∙⁻ n f))))
(leftInv (ΩFibreIso (Ω^→ n f))
((fst (fst (Ω≃∙ (Ω^Fibre≃∙ n f))) p)))
∙ sym (Ω→∘ (≃∙map (Ω^Fibre≃∙⁻ n f))
(≃∙map (Ω^Fibre≃∙ n f)) p)
∙ (λ i → (Ω→ (Ω^Fibre≃∙sect n f i)) .fst p)
∙ sym (rUnit p))
Ω^Fibre≃∙retr : {ℓ ℓ' : Level} {A : Pointed ℓ} {B : Pointed ℓ'}
(n : ℕ) (f : A →∙ B)
→ (≃∙map (Ω^Fibre≃∙ n f) ∘∙ ≃∙map (Ω^Fibre≃∙⁻ n f))
≡ idfun∙ _
Ω^Fibre≃∙retr zero f = ΣPathP (refl , (sym (rUnit refl)))
Ω^Fibre≃∙retr (suc n) f =
→∙Homogeneous≡ (isHomogeneousΩ^→fib n f)
(funExt (λ p →
cong (fun (ΩFibreIso (Ω^→ n f)))
((sym (Ω→∘ (≃∙map (Ω^Fibre≃∙ n f))
(≃∙map (Ω^Fibre≃∙⁻ n f))
(inv (ΩFibreIso (Ω^→ n f)) p)))
∙ (λ i → Ω→ (Ω^Fibre≃∙retr n f i) .fst (inv (ΩFibreIso (Ω^→ n f)) p))
∙ sym (rUnit (inv (ΩFibreIso (Ω^→ n f)) p)))
∙ rightInv (ΩFibreIso (Ω^→ n f)) p))
Ω^Fibre≃∙' : {ℓ ℓ' : Level} {A : Pointed ℓ} {B : Pointed ℓ'}
(n : ℕ) (f : A →∙ B)
→ ((Ω^ n) (fiber (fst f) (pt B) , (pt A) , snd f))
≃∙ ((fiber (Ω^→ n f .fst) (snd ((Ω^ n) B)))
, (snd ((Ω^ n) A)) , (Ω^→ n f .snd))
Ω^Fibre≃∙' zero f = idEquiv _ , refl
Ω^Fibre≃∙' (suc zero) f =
(isoToEquiv (ΩFibreIso (Ω^→ zero f))) , ΩFibreIso∙ (Ω^→ zero f)
Ω^Fibre≃∙' (suc (suc n)) f =
compEquiv∙
(Ω≃∙ (Ω^Fibre≃∙ (suc n) f))
((isoToEquiv (ΩFibreIso (Ω^→ (suc n) f))) , ΩFibreIso∙ (Ω^→ (suc n) f))
-- The long exact sequence of loop spaces.
module ΩLES {ℓ ℓ' : Level} {A : Pointed ℓ} {B : Pointed ℓ'} (f : A →∙ B) where
{- Fibre of f -}
fibf : Pointed _
fibf = fiber (fst f) (pt B) , (pt A , snd f)
{- Fibre of Ωⁿ f -}
fibΩ^f : (n : ℕ) → Pointed _
fst (fibΩ^f n) = fiber (Ω^→ n f .fst) (snd ((Ω^ n) B))
snd (fibΩ^f n) = (snd ((Ω^ n) A)) , (Ω^→ n f .snd)
Ω^fibf : (n : ℕ) → Pointed _
Ω^fibf n = (Ω^ n) fibf
{- Helper function fib (Ωⁿ f) → Ωⁿ A -}
fibΩ^f→A : (n : ℕ) → fibΩ^f n →∙ (Ω^ n) A
fst (fibΩ^f→A n) = fst
snd (fibΩ^f→A n) = refl
{- The main function Ωⁿ(fib f) → Ωⁿ A, which is just the composition
Ωⁿ(fib f) ≃ fib (Ωⁿ f) → Ωⁿ A, where the last function is
fibΩ^f→A. Hence most proofs will concern fibΩ^f→A, since it is easier to
work with. -}
Ω^fibf→A : (n : ℕ) → Ω^fibf n →∙ (Ω^ n) A
Ω^fibf→A n = fibΩ^f→A n ∘∙ ≃∙map (Ω^Fibre≃∙ n f)
{- The function preserves path composition -}
Ω^fibf→A-pres∙ : (n : ℕ) → (p q : Ω^fibf (suc n) .fst)
→ Ω^fibf→A (suc n) .fst (p ∙ q)
≡ Ω^fibf→A (suc n) .fst p
∙ Ω^fibf→A (suc n) .fst q
Ω^fibf→A-pres∙ n p q =
cong (fst (fibΩ^f→A (suc n)))
(cong (fun (ΩFibreIso (Ω^→ n f)))
(Ω→pres∙ (≃∙map (Ω^Fibre≃∙ n f)) p q))
∙ ΩFibreIsopres∙fst (Ω^→ n f)
(fst (Ω→ (≃∙map (Ω^Fibre≃∙ n f))) p)
(fst (Ω→ (≃∙map (Ω^Fibre≃∙ n f))) q)
{- The function Ωⁿ A → Ωⁿ B -}
A→B : (n : ℕ) → (Ω^ n) A →∙ (Ω^ n) B
A→B n = Ω^→ n f
{- It preserves path composition -}
A→B-pres∙ : (n : ℕ) → (p q : typ ((Ω^ (suc n)) A))
→ fst (A→B (suc n)) (p ∙ q)
≡ fst (A→B (suc n)) p ∙ fst (A→B (suc n)) q
A→B-pres∙ n p q = Ω^→pres∙ f n p q
{- Helper function Ωⁿ⁺¹ B → fib (Ωⁿ f) -}
ΩB→fibΩ^f : (n : ℕ) → ((Ω^ (suc n)) B) →∙ fibΩ^f n
fst (ΩB→fibΩ^f n) x = (snd ((Ω^ n) A)) , (Ω^→ n f .snd ∙ x)
snd (ΩB→fibΩ^f n) = ΣPathP (refl , (sym (rUnit _)))
{- The main function Ωⁿ⁺¹ B → Ωⁿ (fib f),
factoring through the above function -}
ΩB→Ω^fibf : (n : ℕ) → (Ω^ (suc n)) B →∙ Ω^fibf n
ΩB→Ω^fibf n =
(≃∙map (Ω^Fibre≃∙⁻ n f))
∘∙ ΩB→fibΩ^f n
{- It preserves path composition -}
ΩB→Ω^fibf-pres∙ : (n : ℕ) → (p q : typ ((Ω^ (2 + n)) B))
→ fst (ΩB→Ω^fibf (suc n)) (p ∙ q)
≡ fst (ΩB→Ω^fibf (suc n)) p ∙ fst (ΩB→Ω^fibf (suc n)) q
ΩB→Ω^fibf-pres∙ n p q =
cong (fst (fst (Ω^Fibre≃∙⁻ (suc n) f)))
refl
∙ cong (fst (fst (Ω≃∙ (Ω^Fibre≃∙⁻ n f))))
(cong (fun (invIso (ΩFibreIso (Ω^→ n f))))
(λ _ → snd ((Ω^ suc n) A) , Ω^→ (suc n) f .snd ∙ p ∙ q))
∙ cong (fst (fst (Ω≃∙ (Ω^Fibre≃∙⁻ n f))))
(ΩFibreIso⁻pres∙snd (Ω^→ n f) p q)
∙ Ω≃∙pres∙ (Ω^Fibre≃∙⁻ n f)
(inv (ΩFibreIso (Ω^→ n f)) (refl , Ω→ (Ω^→ n f) .snd ∙ p))
(inv (ΩFibreIso (Ω^→ n f)) (refl , Ω→ (Ω^→ n f) .snd ∙ q))
{- Hence we have our sequence
... → Ωⁿ⁺¹B → Ωⁿ(fib f) → Ωⁿ A → Ωⁿ B → ... (*)
We first prove the exactness properties for the helper functions
ΩB→fibΩ^f and fibΩ^f→A, and then deduce exactness of the whole sequence
by noting that the functions in (*) are just ΩB→fibΩ^f, fibΩ^f→A but
composed with equivalences
-}
private
Im-fibΩ^f→A⊂Ker-A→B : (n : ℕ) (x : _)
→ isInIm∙ (fibΩ^f→A n) x
→ isInKer∙ (A→B n) x
Im-fibΩ^f→A⊂Ker-A→B n x =
uncurry λ p → J (λ x _ → isInKer∙ (A→B n) x)
(snd p)
Ker-fibΩ^f→A⊂Im-ΩB→fibΩ^f : (n : ℕ) (x : _)
→ isInKer∙ (fibΩ^f→A n) x
→ isInIm∙ (ΩB→fibΩ^f n) x
Ker-fibΩ^f→A⊂Im-ΩB→fibΩ^f n x ker =
(sym (Ω^→ n f .snd)
∙ cong (Ω^→ n f .fst) (sym ker) ∙ snd x) , ΣPathP ((sym ker) ,
((∙assoc (Ω^→ n f .snd)
(sym (Ω^→ n f .snd))
(sym (cong (Ω^→ n f .fst) ker) ∙ snd x)
∙∙ cong (_∙ (sym (cong (Ω^→ n f .fst) ker) ∙ snd x))
(rCancel (Ω^→ n f .snd))
∙∙ sym (lUnit (sym (cong (Ω^→ n f .fst) ker) ∙ snd x)))
◁ (λ i j → compPath-filler'
(cong (Ω^→ n f .fst) (sym ker)) (snd x) (~ i) j)))
Im-A→B⊂Ker-ΩB→fibΩ^f : (n : ℕ) (x : fst (((Ω^ (suc n)) B)))
→ isInIm∙ (A→B (suc n)) x
→ isInKer∙ (ΩB→fibΩ^f n) x
Im-A→B⊂Ker-ΩB→fibΩ^f n x =
uncurry λ p
→ J (λ x _ → isInKer∙ (ΩB→fibΩ^f n) x)
(ΣPathP (p , (((λ i → (λ j → Ω^→ n f .snd (j ∧ ~ i))
∙ ((λ j → Ω^→ n f .snd (~ j ∧ ~ i))
∙∙ cong (Ω^→ n f .fst) p
∙∙ Ω^→ n f .snd))
∙ sym (lUnit (cong (Ω^→ n f .fst) p ∙ Ω^→ n f .snd)))
◁ λ i j → compPath-filler'
(cong (Ω^→ n f .fst) p) (Ω^→ n f .snd) (~ i) j)))
Ker-ΩB→fibΩ^f⊂Im-A→B : (n : ℕ) (x : fst (((Ω^ (suc n)) B)))
→ isInKer∙ (ΩB→fibΩ^f n) x
→ isInIm∙ (A→B (suc n)) x
fst (Ker-ΩB→fibΩ^f⊂Im-A→B n x inker) = cong fst inker
snd (Ker-ΩB→fibΩ^f⊂Im-A→B n x inker) = lem
where
lem : fst (A→B (suc n)) (λ i → fst (inker i)) ≡ x
lem i j =
hcomp (λ k → λ { (i = i0) → doubleCompPath-filler
(sym (snd (Ω^→ n f)))
((λ i → Ω^→ n f .fst (fst (inker i))))
(snd (Ω^→ n f)) k j
; (i = i1) → compPath-filler' (Ω^→ n f .snd) x (~ k) j
; (j = i0) → snd (Ω^→ n f) k
; (j = i1) → snd (Ω^→ n f) (k ∨ i)})
(hcomp (λ k → λ { (i = i0) → (snd (inker j)) (~ k)
; (i = i1) → ((Ω^→ n f .snd) ∙ x) (j ∨ ~ k)
; (j = i0) → ((Ω^→ n f .snd) ∙ x) (~ k)
; (j = i1) → snd (Ω^→ n f) (i ∨ ~ k)})
(snd ((Ω^ n) B)))
{- Finally, we get exactness of the sequence
we are interested in -}
Im-Ω^fibf→A⊂Ker-A→B : (n : ℕ) (x : _)
→ isInIm∙ (Ω^fibf→A n) x
→ isInKer∙ (A→B n) x
Im-Ω^fibf→A⊂Ker-A→B n x x₁ =
Im-fibΩ^f→A⊂Ker-A→B n x
(((fst (fst (Ω^Fibre≃∙ n f))) (fst x₁))
, snd x₁)
Ker-A→B⊂Im-Ω^fibf→A : (n : ℕ) (x : _)
→ isInKer∙ (A→B n) x
→ isInIm∙ (Ω^fibf→A n) x
Ker-A→B⊂Im-Ω^fibf→A n x ker =
invEq (fst (Ω^Fibre≃∙ n f)) (x , ker)
, (cong fst (secEq (fst (Ω^Fibre≃∙ n f)) (x , ker)))
Ker-Ω^fibf→A⊂Im-ΩB→Ω^fibf : (n : ℕ) (x : _)
→ isInKer∙ (Ω^fibf→A n) x
→ isInIm∙ (ΩB→Ω^fibf n) x
Ker-Ω^fibf→A⊂Im-ΩB→Ω^fibf n x p =
fst r
, cong (fst ((fst (Ω^Fibre≃∙⁻ n f)))) (snd r)
∙ funExt⁻ (cong fst (Ω^Fibre≃∙sect n f)) x
where
r : isInIm∙ (ΩB→fibΩ^f n) (fst (fst (Ω^Fibre≃∙ n f)) x)
r = Ker-fibΩ^f→A⊂Im-ΩB→fibΩ^f n (fst (fst (Ω^Fibre≃∙ n f)) x) p
Im-ΩB→Ω^fibf⊂Ker-Ω^fibf→A : (n : ℕ) (x : _)
→ isInIm∙ (ΩB→Ω^fibf n) x
→ isInKer∙ (Ω^fibf→A n) x
Im-ΩB→Ω^fibf⊂Ker-Ω^fibf→A n x =
uncurry λ p →
J (λ x _ → isInKer∙ (Ω^fibf→A n) x)
(cong (fst (fibΩ^f→A n))
(funExt⁻ (cong fst (Ω^Fibre≃∙retr n f)) _))
Im-A→B⊂Ker-ΩB→Ω^fibf : (n : ℕ) (x : fst (((Ω^ (suc n)) B)))
→ isInIm∙ (A→B (suc n)) x
→ isInKer∙ (ΩB→Ω^fibf n) x
Im-A→B⊂Ker-ΩB→Ω^fibf n x p =
cong (fst ((fst (Ω^Fibre≃∙⁻ n f))))
(Im-A→B⊂Ker-ΩB→fibΩ^f n x p)
∙ snd (Ω^Fibre≃∙⁻ n f)
Ker-ΩB→Ω^fibf⊂Im-A→B : (n : ℕ) (x : fst (((Ω^ (suc n)) B)))
→ isInKer∙ (ΩB→Ω^fibf n) x
→ isInIm∙ (A→B (suc n)) x
Ker-ΩB→Ω^fibf⊂Im-A→B n x p =
Ker-ΩB→fibΩ^f⊂Im-A→B n x
(funExt⁻ (cong fst (sym (Ω^Fibre≃∙retr n f))) (ΩB→fibΩ^f n .fst x)
∙ cong (fst (fst (Ω^Fibre≃∙ n f))) p
∙ snd (Ω^Fibre≃∙ n f))
{- Some useful lemmas for converting the above sequence a
a sequence of homotopy groups -}
module setTruncLemmas {ℓ ℓ' ℓ'' : Level}
{A : Pointed ℓ} {B : Pointed ℓ'} {C : Pointed ℓ''}
(n m l : ℕ)
(f : (Ω ((Ω^ n) A)) →∙ (Ω ((Ω^ m) B)))
(g : (Ω ((Ω^ m) B)) →∙ (Ω ((Ω^ l) C)))
(e₁ : IsGroupHom (snd (πGr n A)) (sMap (fst f)) (snd (πGr m B)))
(e₂ : IsGroupHom (snd (πGr m B)) (sMap (fst g)) (snd (πGr l C))) where
ker⊂im : ((x : typ (Ω ((Ω^ m) B))) → isInKer∙ g x → isInIm∙ f x)
→ (x : π (suc m) B) → isInKer (_ , e₂) x → isInIm (_ , e₁) x
ker⊂im ind =
sElim (λ _ → isSetΠ λ _ → isProp→isSet squash₁)
λ p ker →
pRec squash₁
(λ ker∙ → ∣ ∣ ind p ker∙ .fst ∣₂ , cong ∣_∣₂ (ind p ker∙ .snd) ∣₁ )
(fun PathIdTrunc₀Iso ker)
im⊂ker : ((x : typ (Ω ((Ω^ m) B))) → isInIm∙ f x → isInKer∙ g x)
→ (x : π (suc m) B) → isInIm (_ , e₁) x → isInKer (_ , e₂) x
im⊂ker ind =
sElim (λ _ → isSetΠ λ _ → isSetPathImplicit)
λ p →
pRec (squash₂ _ _)
(uncurry (sElim (λ _ → isSetΠ λ _ → isSetPathImplicit)
λ a q → pRec (squash₂ _ _)
(λ q → cong ∣_∣₂ (ind p (a , q)))
(fun PathIdTrunc₀Iso q)))
{- The long exact sequence of homotopy groups -}
module πLES {ℓ ℓ' : Level} {A : Pointed ℓ} {B : Pointed ℓ'} (f : A →∙ B) where
module Ωs = ΩLES f
open Ωs renaming (A→B to A→B')
fib = fibf
fib→A : (n : ℕ) → GroupHom (πGr n fib) (πGr n A)
fst (fib→A n) = sMap (fst (Ω^fibf→A (suc n)))
snd (fib→A n) =
makeIsGroupHom
(sElim2 (λ _ _ → isSetPathImplicit)
λ p q → cong ∣_∣₂ (Ω^fibf→A-pres∙ n p q))
A→B : (n : ℕ) → GroupHom (πGr n A) (πGr n B)
fst (A→B n) = sMap (fst (A→B' (suc n)))
snd (A→B n) =
makeIsGroupHom
(sElim2 (λ _ _ → isSetPathImplicit)
λ g h → cong ∣_∣₂ (Ω^→pres∙ f n g h))
B→fib : (n : ℕ) → GroupHom (πGr (suc n) B) (πGr n fib)
fst (B→fib n) = sMap (fst (ΩB→Ω^fibf (suc n)))
snd (B→fib n) =
makeIsGroupHom
(sElim2
(λ _ _ → isSetPathImplicit)
λ p q → cong ∣_∣₂ (ΩB→Ω^fibf-pres∙ n p q))
Ker-A→B⊂Im-fib→A : (n : ℕ) (x : π (suc n) A)
→ isInKer (A→B n) x
→ isInIm (fib→A n) x
Ker-A→B⊂Im-fib→A n =
setTruncLemmas.ker⊂im n n n
(Ω^fibf→A (suc n)) (A→B' (suc n))
(snd (fib→A n)) (snd (A→B n))
(Ker-A→B⊂Im-Ω^fibf→A (suc n))
Im-fib→A⊂Ker-A→B : (n : ℕ) (x : π (suc n) A)
→ isInIm (fib→A n) x
→ isInKer (A→B n) x
Im-fib→A⊂Ker-A→B n =
setTruncLemmas.im⊂ker n n n
(Ω^fibf→A (suc n)) (A→B' (suc n))
(snd (fib→A n)) (snd (A→B n))
(Im-Ω^fibf→A⊂Ker-A→B (suc n))
Ker-fib→A⊂Im-B→fib : (n : ℕ) (x : π (suc n) fib)
→ isInKer (fib→A n) x
→ isInIm (B→fib n) x
Ker-fib→A⊂Im-B→fib n =
setTruncLemmas.ker⊂im (suc n) n n
(ΩB→Ω^fibf (suc n)) (Ω^fibf→A (suc n))
(snd (B→fib n)) (snd (fib→A n))
(Ker-Ω^fibf→A⊂Im-ΩB→Ω^fibf (suc n))
Im-B→fib⊂Ker-fib→A : (n : ℕ) (x : π (suc n) fib)
→ isInIm (B→fib n) x
→ isInKer (fib→A n) x
Im-B→fib⊂Ker-fib→A n =
setTruncLemmas.im⊂ker (suc n) n n
(ΩB→Ω^fibf (suc n)) (Ω^fibf→A (suc n))
(snd (B→fib n)) (snd (fib→A n))
(Im-ΩB→Ω^fibf⊂Ker-Ω^fibf→A (suc n))
Im-A→B⊂Ker-B→fib : (n : ℕ) (x : π (suc (suc n)) B)
→ isInIm (A→B (suc n)) x
→ isInKer (B→fib n) x
Im-A→B⊂Ker-B→fib n =
setTruncLemmas.im⊂ker (suc n) (suc n) n
(A→B' (suc (suc n))) (ΩB→Ω^fibf (suc n))
(snd (A→B (suc n))) (snd (B→fib n))
(Im-A→B⊂Ker-ΩB→Ω^fibf (suc n))
Ker-B→fib⊂Im-A→B : (n : ℕ) (x : π (suc (suc n)) B)
→ isInKer (B→fib n) x
→ isInIm (A→B (suc n)) x
Ker-B→fib⊂Im-A→B n =
setTruncLemmas.ker⊂im (suc n) (suc n) n
(A→B' (suc (suc n))) (ΩB→Ω^fibf (suc n))
(snd (A→B (suc n))) (snd (B→fib n))
(Ker-ΩB→Ω^fibf⊂Im-A→B (suc n))
{- We prove that the map Ωⁿ(fib f) → Ωⁿ A indeed is just the map
Ωⁿ fst -}
private
Ω^fibf→A-ind : ∀ {ℓ ℓ'} {A : Pointed ℓ} {B : Pointed ℓ'} (n : ℕ) (f : A →∙ B)
→ ΩLES.Ω^fibf→A f (suc n) ≡ Ω→ (ΩLES.Ω^fibf→A f n)
Ω^fibf→A-ind {A = A} {B = B} n f =
(λ _ → πLES.Ωs.fibΩ^f→A f (suc n)
∘∙ ≃∙map (Ω^Fibre≃∙ (suc n) f))
∙ →∙Homogeneous≡ (isHomogeneousPath _ _)
(funExt λ p →
(λ j → cong fst (Ω→ (≃∙map (Ω^Fibre≃∙ n f)) .fst p))
∙ rUnit ((λ i → fst
(Ω→ (≃∙map (Ω^Fibre≃∙ n f)) .fst p i)))
∙ sym (Ω→∘ (πLES.Ωs.fibΩ^f→A f n) (≃∙map (Ω^Fibre≃∙ n f)) p))
Ω^fibf→A≡ : ∀ {ℓ ℓ'} {A : Pointed ℓ} {B : Pointed ℓ'} (n : ℕ) (f : A →∙ B)
→ ΩLES.Ω^fibf→A f n ≡ Ω^→ n (fst , refl)
Ω^fibf→A≡ zero f = ΣPathP (refl , (sym (lUnit refl)))
Ω^fibf→A≡ (suc n) f = Ω^fibf→A-ind n f ∙ cong Ω→ (Ω^fibf→A≡ n f)
{- We now get a nice characterisation of the functions in the induced LES
of homotopy groups defined using (Sⁿ →∙ A) -}
π∘∙A→B-PathP : ∀ {ℓ ℓ'} {A : Pointed ℓ} {B : Pointed ℓ'} (n : ℕ) (f : A →∙ B)
→ PathP (λ i → GroupHomπ≅π'PathP A B n i)
(πLES.A→B f n)
(π'∘∙Hom n f)
π∘∙A→B-PathP n f =
toPathP (Σ≡Prop (λ _ → isPropIsGroupHom _ _) (π'∘∙Hom'≡π'∘∙fun n f))
π∘∙fib→A-PathP : ∀ {ℓ ℓ'} {A : Pointed ℓ} {B : Pointed ℓ'} (n : ℕ) (f : A →∙ B)
→ PathP (λ i → GroupHomπ≅π'PathP (ΩLES.fibf f) A n i)
(πLES.fib→A f n)
(π'∘∙Hom n (fst , refl))
π∘∙fib→A-PathP {A = A} {B = B} n f =
toPathP (Σ≡Prop (λ _ → isPropIsGroupHom _ _)
(cong (transport
(λ i → (fst (GroupPath _ _)
(GroupIso→GroupEquiv (π'Gr≅πGr n (ΩLES.fibf f))) (~ i)) .fst
→ (fst (GroupPath _ _)
(GroupIso→GroupEquiv (π'Gr≅πGr n A)) (~ i)) .fst))
lem
∙ π'∘∙Hom'≡π'∘∙fun n (fst , refl)))
where
lem : πLES.fib→A f n .fst ≡ sMap (Ω^→ (suc n) (fst , refl) .fst)
lem = cong sMap (cong fst (Ω^fibf→A≡ (suc n) f))
| {
"alphanum_fraction": 0.4439345718,
"avg_line_length": 40.3916292975,
"ext": "agda",
"hexsha": "72363726ec2492d8778d4ac18b3e139b1b830927",
"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/Homotopy/Group/LES.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/Homotopy/Group/LES.agda",
"max_line_length": 80,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "thomas-lamiaux/cubical",
"max_stars_repo_path": "Cubical/Homotopy/Group/LES.agda",
"max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z",
"num_tokens": 12729,
"size": 27022
} |
{-# OPTIONS --cubical --safe #-}
module CubicalAbsurd where
open import Cubical.Core.Everything
open import Cubical.Data.Nat
open import Cubical.Data.Empty
theWrongThing : 1 + 1 ≡ 3 → ⊥
theWrongThing thatMoney = znots (injSuc (injSuc thatMoney))
| {
"alphanum_fraction": 0.7540322581,
"avg_line_length": 24.8,
"ext": "agda",
"hexsha": "f476f8e394bafd11190adadd759ab76111acde83",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-12-13T04:50:46.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-12-13T04:50:46.000Z",
"max_forks_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Brethland/LEARNING-STUFF",
"max_forks_repo_path": "Agda/CubicalAbsurd.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Brethland/LEARNING-STUFF",
"max_issues_repo_path": "Agda/CubicalAbsurd.agda",
"max_line_length": 59,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Brethland/LEARNING-STUFF",
"max_stars_repo_path": "Agda/CubicalAbsurd.agda",
"max_stars_repo_stars_event_max_datetime": "2020-03-11T10:35:42.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-02-03T05:05:52.000Z",
"num_tokens": 77,
"size": 248
} |
{-# OPTIONS --cubical --no-import-sorts #-}
module Number.Prelude.QuoInt where
open import Cubical.HITs.Ints.QuoInt public using
( ℤ
; HasFromNat
; HasFromNeg
; Int≡ℤ
; signed
; posneg
; ℤ→Int
; sucℤ
; predℤ
; pos
; neg
; sucℤ-+ʳ
; Sign
; spos
; sneg
) renaming
( isSetℤ to is-setᶻ
; _+_ to _+ᶻ_
; _*_ to _·ᶻ_
; -_ to infixl 6 -ᶻ_
; *-comm to ·ᶻ-comm
; *-assoc to ·ᶻ-assoc
; +-comm to +ᶻ-comm
; +-assoc to +ᶻ-assoc
; sign to signᶻ
; abs to absᶻ
; _*S_ to _·ˢ_
)
open import Number.Instances.QuoInt public using
( ℤlattice
; ⊕-identityʳ
) renaming
( is-LinearlyOrderedCommRing to is-LinearlyOrderedCommRingᶻ
; min to minᶻ
; max to maxᶻ
; _<_ to _<ᶻ_
; ·-reflects-< to ·ᶻ-reflects-<ᶻ
; ·-reflects-<ˡ to ·ᶻ-reflects-<ᶻˡ
; 0<1 to 0<1
; +-reflects-< to +ᶻ-reflects-<ᶻ
; +-preserves-< to +ᶻ-preserves-<ᶻ
; +-creates-< to +ᶻ-creates-<ᶻ
; suc-creates-< to suc-creates-<ᶻ
; +-creates-≤ to +ᶻ-creates-≤ᶻ
; ·-creates-< to ·ᶻ-creates-<ᶻ
; ·-creates-≤ to ·ᶻ-creates-≤ᶻ
; ·-creates-≤-≡ to ·ᶻ-creates-≤ᶻ-≡
; ·-creates-<ˡ-≡ to ·ᶻ-creates-<ᶻˡ-≡
; ·-creates-<-flippedˡ-≡ to ·ᶻ-creates-<ᶻ-flippedˡ-≡
; ·-creates-<-flippedʳ-≡ to ·ᶻ-creates-<ᶻ-flippedʳ-≡
; ≤-dicho to ≤ᶻ-dicho
; ≤-min-+ to ≤ᶻ-minᶻ-+ᶻ
; ≤-max-+ to ≤ᶻ-maxᶻ-+ᶻ
; ≤-min-· to ≤ᶻ-minᶻ-·ᶻ
; ≤-max-· to ≤ᶻ-maxᶻ-·ᶻ
; +-min-distribʳ to +ᶻ-minᶻ-distribʳ
; ·-min-distribʳ to ·ᶻ-minᶻ-distribʳ
; +-max-distribʳ to +ᶻ-maxᶻ-distribʳ
; ·-max-distribʳ to ·ᶻ-maxᶻ-distribʳ
; +-min-distribˡ to +ᶻ-minᶻ-distribˡ
; ·-min-distribˡ to ·ᶻ-minᶻ-distribˡ
; +-max-distribˡ to +ᶻ-maxᶻ-distribˡ
; ·-max-distribˡ to ·ᶻ-maxᶻ-distribˡ
; pos<pos[suc] to pos<ᶻpos[suc]
; 0<ᶻpos[suc] to 0<ᶻpos[suc]
; ·-nullifiesˡ to ·ᶻ-nullifiesˡ
; ·-nullifiesʳ to ·ᶻ-nullifiesʳ
; ·-preserves-0< to ·ᶻ-preserves-0<ᶻ
; ·-reflects-0< to ·ᶻ-reflects-0<ᶻ
; ·-creates-<-≡ to ·ᶻ-creates-<ᶻ-≡
; -flips-<0 to -flips-<ᶻ0
; -flips-< to -ᶻ-flips-<ᶻ
; -identity-· to -ᶻ-identity-·ᶻ
; -distˡ to -ᶻ-distˡ
; ·-reflects-<-flippedˡ to ·ᶻ-reflects-<ᶻ-flippedˡ
; ·-reflects-<-flippedʳ to ·ᶻ-reflects-<ᶻ-flippedʳ
; #-dicho to #ᶻ-dicho
; ·-preserves-signˡ to ·ᶻ-preserves-signᶻˡ
; #⇒≢ to #ᶻ⇒≢
; <-split-pos to <ᶻ-split-pos
; <-split-neg to <ᶻ-split-neg
; <0-sign to <ᶻ0-signᶻ
; 0<-sign to 0<ᶻ-signᶻ
; sign-pos to signᶻ-pos
; ·-reflects-≡ˡ to ·ᶻ-reflects-≡ˡ
; ·-reflects-≡ʳ to ·ᶻ-reflects-≡ʳ
)
open import Number.Structures2
open IsLinearlyOrderedCommRing is-LinearlyOrderedCommRingᶻ public using () renaming
( _-_ to _-ᶻ_
-- ; is-LinearlyOrderedCommSemiring to is-LinearlyOrderedCommSemiringᶻ
; _≤_ to _≤ᶻ_ -- NOTE: somehow this get an ugly prefix turning `0 ≤ᶻ aᶻ` into `(is-LinearlyOrderedCommSemiringᶻ IsLinearlyOrderedCommSemiring.≤ pos 0) aⁿᶻ`
; _#_ to _#ᶻ_ -- but some-other-how _#ᶻ_ works fine ... ?
; <-irrefl to <ᶻ-irrefl -- turns out that this was due to `p = [ 0 ≤ᶻ aⁿᶻ ] ∋ is-0≤ⁿᶻ` instead of `p : [ 0 ≤ᶻ aⁿᶻ ]; p = is-0≤ⁿᶻ`
; <-trans to <ᶻ-trans
; +-<-ext to +ᶻ-<ᶻ-ext
; +-rinv to +ᶻ-rinv
; +-identity to +ᶻ-identity
; ·-preserves-< to ·ᶻ-preserves-<ᶻ
; <-tricho to <ᶻ-tricho
; <-asym to <ᶻ-asym
; ·-identity to ·ᶻ-identity
; is-min to is-minᶻ
; is-max to is-maxᶻ
; is-dist to is-distᶻ
)
-- open IsLinearlyOrderedCommSemiring is-LinearlyOrderedCommSemiringᶻ public using () renaming
-- ( _≤_ to _≤ᶻ_ )
open import MorePropAlgebra.Properties.Lattice ℤlattice
open OnSet is-setᶻ public using () renaming
( min-≤ to minᶻ-≤ᶻ
; max-≤ to maxᶻ-≤ᶻ
; ≤-reflectsʳ-≡ to ≤ᶻ-reflectsʳ-≡
; ≤-reflectsˡ-≡ to ≤ᶻ-reflectsˡ-≡
; min-identity to minᶻ-identity
; min-identity-≤ to minᶻ-identity-≤ᶻ
; max-identity-≤ to maxᶻ-identity-≤ᶻ
; min-comm to minᶻ-comm
; min-assoc to minᶻ-assoc
; max-identity to maxᶻ-identity
; max-comm to maxᶻ-comm
; max-assoc to maxᶻ-assoc
; min-max-absorptive to minᶻ-maxᶻ-absorptive
; max-min-absorptive to maxᶻ-minᶻ-absorptive
)
| {
"alphanum_fraction": 0.5119390696,
"avg_line_length": 35.9851851852,
"ext": "agda",
"hexsha": "098de6c4c443c31e52d44a20da37b61e318cef81",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mchristianl/synthetic-reals",
"max_forks_repo_path": "agda/Number/Prelude/QuoInt.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "mchristianl/synthetic-reals",
"max_issues_repo_path": "agda/Number/Prelude/QuoInt.agda",
"max_line_length": 172,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mchristianl/synthetic-reals",
"max_stars_repo_path": "agda/Number/Prelude/QuoInt.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-19T12:15:21.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-07-31T18:15:26.000Z",
"num_tokens": 2204,
"size": 4858
} |
-- Andreas, 2015-07-18
-- Postpone checking of record expressions when type is blocked.
-- Guess type of record expressions when type is blocked.
open import Common.Product
open import Common.Prelude
open import Common.Equality
T : Bool → Set
T true = Bool × Nat
T false = ⊥
works : (P : ∀{b} → b ≡ true → T b → Set) → Set
works P = P refl record{ proj₁ = true; proj₂ = 0 }
-- Guess or postpone.
test : (P : ∀{b} → T b → b ≡ true → Set) → Set
test P = P record{ proj₁ = true; proj₂ = 0 } refl
guess : (P : ∀{b} → T b → Set) → Set
guess P = P record{ proj₁ = true; proj₂ = 0 }
record R : Set where
field
f : Bool
record S : Set where
field
f : Bool
U : Bool → Set
U true = R
U false = S
postpone : (P : ∀{b} → U b → b ≡ true → Set) → Set
postpone P = P record{ f = false } refl
-- ambiguous : (P : ∀{b} → U b → Set) → Set
-- ambiguous P = P record{ f = false }
| {
"alphanum_fraction": 0.6002265006,
"avg_line_length": 22.075,
"ext": "agda",
"hexsha": "8c7ab7d0a106183733a8a81392d3163b957f20c8",
"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/PostponeRecordExpr.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/PostponeRecordExpr.agda",
"max_line_length": 64,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/PostponeRecordExpr.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": 305,
"size": 883
} |
-- Some tests for the Agda Abstract Machine.
open import Agda.Builtin.Nat
open import Agda.Builtin.Equality
open import Agda.Builtin.Sigma
_×_ : Set → Set → Set
A × B = Σ A λ _ → B
id : Nat → Nat
id x = x
-- Applying id should not break sharing
double : Nat → Nat
double n = id n + id n
pow : Nat → Nat
pow zero = 1
pow (suc n) = double (pow n)
test-pow : pow 64 ≡ 18446744073709551616
test-pow = refl
-- Projections should not break sharing
addPair : Nat × Nat → Nat
addPair p = fst p + snd p
dup : Nat → Nat × Nat
dup x .fst = x
dup x .snd = x
smush : Nat × Nat → Nat × Nat
smush p = dup (addPair p)
iter : {A : Set} → (A → A) → Nat → A → A
iter f zero x = x
iter f (suc n) x = f (iter f n x)
pow' : Nat → Nat
pow' n = addPair (iter smush n (0 , 1))
test-pow' : pow' 64 ≡ pow 64
test-pow' = refl
-- Should not be linear (not quadratic) for neutral n.
builtin : Nat → Nat → Nat
builtin k n = k + n - k
test-builtin : ∀ n → builtin 50000 n ≡ n
test-builtin n = refl
| {
"alphanum_fraction": 0.6247464503,
"avg_line_length": 19.3333333333,
"ext": "agda",
"hexsha": "6abf878bc1e3178418a5366676a163918ca2e11b",
"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/AgdaAbstractMachine.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/AgdaAbstractMachine.agda",
"max_line_length": 54,
"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/AgdaAbstractMachine.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": 356,
"size": 986
} |
module Oscar.Instance where
open import Oscar.Class.Associativity
open import Oscar.Class.Congruity
open import Oscar.Class.Equivalence
open import Oscar.Class.Extensionality
open import Oscar.Class.Injectivity
open import Oscar.Class.Preservativity
open import Oscar.Class.Reflexivity
open import Oscar.Class.Semifunctor
open import Oscar.Class.Semigroup
open import Oscar.Class.Symmetry
open import Oscar.Class.Transitivity
open import Oscar.Data.Equality
open import Oscar.Data.Fin
open import Oscar.Data.Nat
open import Oscar.Function
open import Oscar.Relation
open import Oscar.Data.Equality.properties
using (≡̇-sym; ≡̇-trans)
renaming (sym to ≡-sym
;trans to ≡-trans)
instance InjectivityFinSuc : ∀ {n} → Injectivity _≡_ _≡_ (Fin.suc {n}) suc
Injectivity.injectivity InjectivityFinSuc refl = refl
data D : Set where
d1 : Nat → D
d2 : Nat → Nat → D
pattern d2l r l = d2 l r
instance InjectivityDd1 : Injectivity _≡_ _≡_ d1 d1
Injectivity.injectivity InjectivityDd1 refl = refl
instance InjectivityD2l : ∀ {r1 r2} → Injectivity _≡_ _≡_ (d2l r1) (flip d2 r2)
Injectivity.injectivity InjectivityD2l refl = refl
instance InjectivityoidD2l : ∀ {r1} {r2} → Injectivityoid _ _ _ _ _
Injectivityoid.A InjectivityoidD2l = D
Injectivityoid.B InjectivityoidD2l = D
Injectivityoid._≋₁_ InjectivityoidD2l = _≡_
Injectivityoid.I InjectivityoidD2l = Nat
Injectivityoid._≋₂_ InjectivityoidD2l = _≡_
Injectivityoid.μₗ (InjectivityoidD2l {r1} {r2}) = d2l r1
Injectivityoid.μᵣ (InjectivityoidD2l {r1} {r2}) = flip d2 r2
Injectivityoid.`injectivity InjectivityoidD2l refl = refl
instance InjectivityoidD2r : ∀ {r1} {r2} → Injectivityoid _ _ _ _ _
Injectivityoid.A InjectivityoidD2r = D
Injectivityoid.B InjectivityoidD2r = D
Injectivityoid._≋₁_ InjectivityoidD2r = _≡_
Injectivityoid.I InjectivityoidD2r = Nat
Injectivityoid._≋₂_ InjectivityoidD2r = _≡_
Injectivityoid.μₗ (InjectivityoidD2r {r1} {r2}) = d2 r1
Injectivityoid.μᵣ (InjectivityoidD2r {r1} {r2}) = d2 r2
Injectivityoid.`injectivity InjectivityoidD2r refl = refl
open Injectivityoid ⦃ … ⦄ using (`injectivity)
instance InjectivityD2r : ∀ {l1 l2} → Injectivity _≡_ _≡_ (d2 l1) (d2 l2)
Injectivity.injectivity InjectivityD2r refl = refl
pattern d2' {l} r = d2 l r
injectivity-test : (k l m n : Nat) → (d2 k m ≡ d2 l n) → (d1 k ≡ d1 l) → Set
injectivity-test k l m n eq1 eq2 with injectivity {_≋₁_ = _≡_} {_≋₂_ = _≡_} {f = d2'} eq1
injectivity-test k l m n eq1 eq2 | ref with injectivity {_≋₁_ = _≡_} {_≋₂_ = _≡_} {f = d1} eq2
… | ref2 = {!!}
-- with `injectivity ⦃ ? ⦄ eq2
-- … | ref3 = {!ref!}
instance
≡-Reflexivity : ∀
{a} {A : Set a}
→ Reflexivity (_≡_ {A = A})
Reflexivity.reflexivity ≡-Reflexivity = refl
≡̇-Reflexivity : ∀
{a} {A : Set a} {b} {B : A → Set b}
→ Reflexivity (_≡̇_ {B = B})
Reflexivity.reflexivity ≡̇-Reflexivity _ = refl
≡-flip≡-Extensionality : ∀
{a} {A : Set a}
→ Extensionality {B = const A} _≡_ (λ ⋆ → flip _≡_ ⋆) id id
Extensionality.extensionality ≡-flip≡-Extensionality = ≡-sym
≡̇-flip≡̇-Extensionality : ∀
{a} {A : Set a} {b} {B : A → Set b}
→ Extensionality {B = const ((x : A) → B x)} _≡̇_ (λ ⋆ → flip _≡̇_ ⋆) id id
Extensionality.extensionality ≡̇-flip≡̇-Extensionality = ≡̇-sym
≡-Transitivity : ∀ {a} {A : Set a} → Transitivity {A = A} _≡_
Transitivity.transitivity ≡-Transitivity = λ ⋆ → ≡-trans ⋆
≡̇-Transitivity : ∀ {a} {A : Set a} {b} {B : A → Set b} → Transitivity {A = (x : A) → B x} _≡̇_
Transitivity.transitivity ≡̇-Transitivity = ≡̇-trans
≡-Congruity : ∀
{a} {A : Set a} {b} {B : Set b} {ℓ₂} {_≋₂_ : B → B → Set ℓ₂}
⦃ _ : Reflexivity _≋₂_ ⦄
→ Congruity (_≡_ {A = A}) _≋₂_
Congruity.congruity ≡-Congruity μ refl = reflexivity
module Term {𝔣} (FunctionName : Set 𝔣) where
open import Oscar.Data.Term FunctionName
open import Oscar.Data.Term.internal.SubstituteAndSubstitution FunctionName as ⋆
instance
◇-≡̇-Associativity : Associativity _◇_ _≡̇_
Associativity.associativity ◇-≡̇-Associativity = ◇-associativity
∘-≡̇-Associativity : ∀ {a} {A : Set a} {b} {B : A → Set b} → Associativity {_►_ = _⟨ B ⟩→_} (λ ⋆ → _∘_ ⋆) _≡̇_
Associativity.associativity ∘-≡̇-Associativity _ _ _ _ = refl
◇-∘-≡̇-◃-◃-◃-Preservativity : ∀ {l m n} → Preservativity (λ ⋆ → _◇_ (m ⊸ n ∋ ⋆)) (_∘′_ {A = Term l}) _≡̇_ _◃_ _◃_ _◃_
Preservativity.preservativity ◇-∘-≡̇-◃-◃-◃-Preservativity g f τ = symmetry (◃-associativity τ f g)
≡̇-≡̇-◃-◃-Extensionality : ∀ {m n} → Extensionality _≡̇_ (λ ⋆ → _≡̇_ ⋆) (_◃_ {m} {n}) (λ ⋆ → _◃_ ⋆)
Extensionality.extensionality ≡̇-≡̇-◃-◃-Extensionality = ◃-extensionality
semifunctor-◃ : Semifunctor _◇_ _≡̇_ (λ ⋆ → _∘_ ⋆) _≡̇_ id _◃_
semifunctor-◃ = it
open import Oscar.Data.AList FunctionName
postulate
_++_ : ∀ {m n} → AList m n → ∀ {l} → AList l m → AList l n
sub : ∀ {m n} → AList m n → m ⊸ n
++-assoc : ∀ {l m n o} (ρ : AList l m) (σ : AList n _) (τ : AList o _) → ρ ++ (σ ++ τ) ≡ (ρ ++ σ) ++ τ
subfact1 : ∀ {l m n} (ρ : AList m n) (σ : AList l m) → sub (ρ ++ σ) ≡̇ (sub ρ ◇ sub σ)
instance
++-≡-Associativity : Associativity _++_ _≡_
Associativity.associativity ++-≡-Associativity f g h = ++-assoc h g f
++-◇-sub-sub-sub : ∀ {l m n} → Preservativity (λ ⋆ → _++_ (AList m n ∋ ⋆)) (λ ⋆ → _◇_ ⋆ {l = l}) _≡̇_ sub sub sub
Preservativity.preservativity ++-◇-sub-sub-sub = subfact1
semifunctor-sub : Semifunctor _++_ _≡_ _◇_ _≡̇_ id sub
semifunctor-sub = it
-- ≡̇-extension : ∀
-- {a} {A : Set a} {b} {B : A → Set b}
-- {ℓ₁} {_≤₁_ : (x : A) → B x → Set ℓ₁}
-- {c} {C : Set c}
-- {d} {D : C → Set d}
-- {μ₁ : A → (z : C) → D z}
-- {μ₂ : ∀ {x} → B x → (z : C) → D z}
-- ⦃ _ : Extensionality _≤₁_ (λ ⋆ → _≡̇_ ⋆) μ₁ μ₂ ⦄
-- {x} {y : B x}
-- → x ≤₁ y → μ₁ x ≡̇ μ₂ y
-- ≡̇-extension = extension (λ ⋆ → _≡̇_ ⋆)
-- test-◃-extensionality : ∀ {m n} {f g : m ⊸ n} → f ≡̇ g → f ◃_ ≡̇ g ◃_
-- test-◃-extensionality = ≡̇-extension -- ≡̇-extension -- ⦃ ? ⦄ -- extension (λ ⋆ → _≡̇_ ⋆)
-- postulate
-- R : Set
-- S : Set
-- _◀_ : ∀ {m n} → m ⊸ n → R → S
-- _◀'_ : ∀ {m n} → m ⊸ n → R → S
-- _◆_ : ∀ {m n} → m ⊸ n → ∀ {l} → l ⊸ m → l ⊸ n
-- instance ≡̇-≡̇-◀-◀'-Extensionality : ∀ {m n} → Extensionality _≡̇_ (λ ⋆ → _≡̇_ ⋆) ((m ⊸ n → _) ∋ _◀_) _◀'_
-- instance ≡̇-≡̇-◀-◀-Extensionality : ∀ {m n} → Extensionality _≡̇_ (λ ⋆ → _≡̇_ ⋆) ((m ⊸ n → _) ∋ _◀_) _◀_
-- instance ◆-◇-≡̇-Associativity : ∀ {k} → Associativity _◆_ (λ ⋆ → _◇_ ⋆) ((k ⊸ _ → _) ∋ _≡̇_)
-- instance ◆-◇-≡̇-Associativity' : ∀ {k} → Associativity _◇_ (λ ⋆ → _◆_ ⋆) ((k ⊸ _ → _) ∋ _≡̇_)
-- test-◀-extensionality : ∀ {m n} {f g : m ⊸ n} → f ≡̇ g → f ◀_ ≡̇ g ◀_
-- test-◀-extensionality {m} {n} = ≡̇-extension
-- -- extensionality {_≤₁_ = _≡̇_} {μ₁ = ((m ⊸ n → _) ∋ _◀_)} {μ₂ = _◀_}
-- test-◀'-extensionality : ∀ {m n} {f g : m ⊸ n} → f ≡̇ g → f ◀_ ≡̇ g ◀'_
-- test-◀'-extensionality = ≡̇-extension
-- test-◃-associativity : ∀ {l} (t : Term l) {m} (f : l ⊸ m) {n} (g : m ⊸ n) → g ◃ (f ◃ t) ≡ (g ◇ f) ◃ t
-- test-◃-associativity = association _◇_ _≡_
-- test-◇-associativity : ∀ {k l} (f : k ⊸ l) {m} (g : l ⊸ m) {n} (h : m ⊸ n) → h ◇ (g ◇ f) ≡̇ (h ◇ g) ◇ f
-- test-◇-associativity = association _◇_ _≡̇_
-- test-◆-associativity : ∀ {k l} (f : k ⊸ l) {m} (g : l ⊸ m) {n} (h : m ⊸ n) → h ◇ (g ◇ f) ≡̇ (h ◆ g) ◇ f
-- test-◆-associativity = association _◆_ _≡̇_
-- test-◆-associativity' : ∀ {k l} (f : k ⊸ l) {m} (g : l ⊸ m) {n} (h : m ⊸ n) → h ◆ (g ◆ f) ≡̇ (h ◇ g) ◆ f
-- test-◆-associativity' = association _◇_ _≡̇_
| {
"alphanum_fraction": 0.5817750856,
"avg_line_length": 38.9435897436,
"ext": "agda",
"hexsha": "6e54c7487f5e4e4792f3a211968b528608637a63",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_forks_repo_licenses": [
"RSA-MD"
],
"max_forks_repo_name": "m0davis/oscar",
"max_forks_repo_path": "archive/agda-2/Oscar/Instance.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z",
"max_issues_repo_licenses": [
"RSA-MD"
],
"max_issues_repo_name": "m0davis/oscar",
"max_issues_repo_path": "archive/agda-2/Oscar/Instance.agda",
"max_line_length": 121,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_stars_repo_licenses": [
"RSA-MD"
],
"max_stars_repo_name": "m0davis/oscar",
"max_stars_repo_path": "archive/agda-2/Oscar/Instance.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3462,
"size": 7594
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
open import Cubical.Core.Everything
open import Cubical.Relation.Binary.Raw
module Cubical.Relation.Binary.Raw.Construct.StrictToNonStrict
{a ℓ} {A : Type a}
(_<_ : RawRel A ℓ)
where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Data.Prod
open import Cubical.Data.Sum.Base renaming (rec to ⊎-rec)
open import Cubical.Data.Empty renaming (elim to ⊥-elim) using ()
open import Cubical.Relation.Binary.Raw.Properties
open import Cubical.Relation.Nullary
------------------------------------------------------------------------
-- Conversion
-- _<_ can be turned into _≤_ as follows:
_≤_ : RawRel A _
x ≤ y = (x < y) ⊎ (x ≡ y)
------------------------------------------------------------------------
-- The converted relations have certain properties
-- (if the original relations have certain other properties)
≤-isPropValued : isSet A → isPropValued _<_ → Irreflexive _<_ → isPropValued _≤_
≤-isPropValued isSetA propv irrefl x y (inl p) (inl q) = cong inl (propv x y p q)
≤-isPropValued isSetA propv irrefl x y (inl p) (inr q) = ⊥-elim (irrefl→tonoteq _<_ irrefl p q)
≤-isPropValued isSetA propv irrefl x y (inr p) (inl q) = ⊥-elim (irrefl→tonoteq _<_ irrefl q p)
≤-isPropValued isSetA propv irrefl x y (inr p) (inr q) = cong inr (isSetA x y p q)
<⇒≤ : _<_ ⇒ _≤_
<⇒≤ = inl
≤-fromEq : FromEq _≤_
≤-fromEq = inr
≤-reflexive : Reflexive _≤_
≤-reflexive = fromeq→reflx _≤_ ≤-fromEq
≤-antisym : Transitive _<_ → Irreflexive _<_ → Antisymmetric _≤_
≤-antisym transitive irrefl (inl x<y) (inl y<x) = ⊥-elim (trans∧irr→asym _<_ transitive irrefl x<y y<x)
≤-antisym _ _ _ (inr y≡x) = sym y≡x
≤-antisym _ _ (inr x≡y) _ = x≡y
≤-transitive : Transitive _<_ → Transitive _≤_
≤-transitive <-trans (inl x<y) (inl y<z) = inl $ <-trans x<y y<z
≤-transitive _ (inl x<y) (inr y≡z) = inl $ Respectsʳ≡ _<_ y≡z x<y
≤-transitive _ (inr x≡y) (inl y<z) = inl $ Respectsˡ≡ _<_ (sym x≡y) y<z
≤-transitive _ (inr x≡y) (inr y≡z) = inr $ x≡y ∙ y≡z
<-≤-trans : Transitive _<_ → Trans _<_ _≤_ _<_
<-≤-trans transitive x<y (inl y<z) = transitive x<y y<z
<-≤-trans transitive x<y (inr y≡z) = Respectsʳ≡ _<_ y≡z x<y
≤-<-trans : Transitive _<_ → Trans _≤_ _<_ _<_
≤-<-trans transitive (inl x<y) y<z = transitive x<y y<z
≤-<-trans transitive (inr x≡y) y<z = Respectsˡ≡ _<_ (sym x≡y) y<z
≤-total : Trichotomous _<_ → Total _≤_
≤-total <-tri x y with <-tri x y
... | tri< x<y x≢y x≯y = inl (inl x<y)
... | tri≡ x≮y x≡y x≯y = inl (inr x≡y)
... | tri> x≮y x≢y x>y = inr (inl x>y)
≤-decidable : Discrete A → Decidable _<_ → Decidable _≤_
≤-decidable _≟_ _<?_ x y with x ≟ y
... | yes p = yes (inr p)
... | no ¬p with x <? y
... | yes q = yes (inl q)
... | no ¬q = no (⊎-rec ¬q ¬p)
≤-decidable′ : Trichotomous _<_ → Decidable _≤_
≤-decidable′ compare x y with compare x y
... | tri< x<y _ _ = yes (inl x<y)
... | tri≡ _ x≡y _ = yes (inr x≡y)
... | tri> x≮y x≢y _ = no (⊎-rec x≮y x≢y)
------------------------------------------------------------------------
-- Converting structures
isPreorder : Transitive _<_ → IsPreorder _≤_
isPreorder transitive = record
{ reflexive = ≤-reflexive
; transitive = ≤-transitive transitive
}
isPartialOrder : IsStrictPartialOrder _<_ → IsPartialOrder _≤_
isPartialOrder spo = record
{ isPreorder = isPreorder S.transitive
; antisym = ≤-antisym S.transitive S.irrefl
}
where module S = IsStrictPartialOrder spo
isTotalOrder : IsStrictTotalOrder _<_ → IsTotalOrder _≤_
isTotalOrder sto = record
{ isPartialOrder = isPartialOrder S.isStrictPartialOrder
; total = λ x y → ∣ ≤-total S.compare x y ∣
}
where module S = IsStrictTotalOrder sto
isDecTotalOrder : IsStrictTotalOrder _<_ → IsDecTotalOrder _≤_
isDecTotalOrder sto = record
{ isTotalOrder = isTotalOrder sto
; _≤?_ = ≤-decidable′ S.compare
}
where module S = IsStrictTotalOrder sto
| {
"alphanum_fraction": 0.6193253868,
"avg_line_length": 34.2869565217,
"ext": "agda",
"hexsha": "f32ff40bc23f9e2ef263937d1e44d41da3446bdf",
"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": "737f922d925da0cd9a875cb0c97786179f1f4f61",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bijan2005/univalent-foundations",
"max_forks_repo_path": "Cubical/Relation/Binary/Raw/Construct/StrictToNonStrict.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61",
"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": "bijan2005/univalent-foundations",
"max_issues_repo_path": "Cubical/Relation/Binary/Raw/Construct/StrictToNonStrict.agda",
"max_line_length": 103,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bijan2005/univalent-foundations",
"max_stars_repo_path": "Cubical/Relation/Binary/Raw/Construct/StrictToNonStrict.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1529,
"size": 3943
} |
------------------------------------------------------------------------
-- The "time complexity" of the compiled program matches the one
-- obtained from the instrumented interpreter
------------------------------------------------------------------------
open import Prelude hiding (_+_; _*_)
import Lambda.Syntax
module Lambda.Compiler-correctness.Steps-match
{Name : Type}
(open Lambda.Syntax Name)
(def : Name → Tm 1)
where
import Equality.Propositional as E
open import Logical-equivalence using (_⇔_)
import Tactic.By.Propositional as By
open import Prelude.Size
open import Conat E.equality-with-J as Conat
using (Conat; zero; suc; force; ⌜_⌝; _+_; _*_; max;
[_]_≤_; step-≤; step-∼≤; _∎≤)
open import Function-universe E.equality-with-J hiding (_∘_)
open import List E.equality-with-J using (_++_)
open import Monad E.equality-with-J using (return; _>>=_; _⟨$⟩_)
open import Vec.Data E.equality-with-J
open import Delay-monad
open import Delay-monad.Bisimilarity
open import Delay-monad.Quantitative-weak-bisimilarity
open import Lambda.Compiler def
open import Lambda.Delay-crash
open import Lambda.Interpreter.Steps def
open import Lambda.Virtual-machine.Instructions Name hiding (crash)
open import Lambda.Virtual-machine comp-name
private
module C = Closure Code
module T = Closure Tm
------------------------------------------------------------------------
-- Some lemmas
-- A rearrangement lemma for ⟦_⟧.
⟦⟧-· :
∀ {n} (t₁ t₂ : Tm n) {ρ} {k : T.Value → Delay-crash C.Value ∞} →
⟦ t₁ · t₂ ⟧ ρ >>= k ∼
⟦ t₁ ⟧ ρ >>= λ v₁ → ⟦ t₂ ⟧ ρ >>= λ v₂ → v₁ ∙ v₂ >>= k
⟦⟧-· t₁ t₂ {ρ} {k} =
⟦ t₁ · t₂ ⟧ ρ >>= k ∼⟨⟩
(do v₁ ← ⟦ t₁ ⟧ ρ
v₂ ← ⟦ t₂ ⟧ ρ
v₁ ∙ v₂) >>= k ∼⟨ symmetric (associativity (⟦ t₁ ⟧ _) _ _) ⟩
(do v₁ ← ⟦ t₁ ⟧ ρ
(do v₂ ← ⟦ t₂ ⟧ ρ
v₁ ∙ v₂) >>= k) ∼⟨ (⟦ t₁ ⟧ _ ∎) >>=-cong (λ _ → symmetric (associativity (⟦ t₂ ⟧ _) _ _)) ⟩
(do v₁ ← ⟦ t₁ ⟧ ρ
v₂ ← ⟦ t₂ ⟧ ρ
v₁ ∙ v₂ >>= k) ∎
-- Lemmas related to conatural numbers.
private
lemma₁ : ∀ {δ} → [ ∞ ] δ ≤ ⌜ 1 ⌝ + δ
lemma₁ = Conat.≤suc
lemma₂ : ∀ {δ} → [ ∞ ] δ ≤ max ⌜ 1 ⌝ δ
lemma₂ = Conat.ʳ≤max ⌜ 1 ⌝ _
lemma₃ : ∀ {δ} → [ ∞ ] max ⌜ 1 ⌝ δ ≤ max ⌜ 1 ⌝ δ + ⌜ 1 ⌝
lemma₃ = Conat.m≤m+n
lemma₄ : ∀ {δ} → [ ∞ ] δ ≤ max ⌜ 1 ⌝ δ + ⌜ 1 ⌝
lemma₄ {δ} =
δ ≤⟨ lemma₂ ⟩
max ⌜ 1 ⌝ δ ≤⟨ lemma₃ {δ = δ} ⟩
max ⌜ 1 ⌝ δ + ⌜ 1 ⌝ ∎≤
lemma₅ : ∀ {δ} → [ ∞ ] ⌜ 1 ⌝ + δ ≤ δ + ⌜ 1 ⌝
lemma₅ {δ} =
⌜ 1 ⌝ + δ ∼⟨ Conat.+-comm ⌜ 1 ⌝ ⟩≤
δ + ⌜ 1 ⌝ ∎≤
lemma₆ : ∀ {δ} → [ ∞ ] ⌜ 1 ⌝ + δ ≤ max ⌜ 1 ⌝ δ + ⌜ 1 ⌝
lemma₆ {δ} =
⌜ 1 ⌝ + δ ≤⟨ lemma₅ ⟩
δ + ⌜ 1 ⌝ ≤⟨ lemma₂ Conat.+-mono (⌜ 1 ⌝ ∎≤) ⟩
max ⌜ 1 ⌝ δ + ⌜ 1 ⌝ ∎≤
lemma₇ : ∀ {δ} → [ ∞ ] max ⌜ 1 ⌝ (⌜ 1 ⌝ + δ) ≤ ⌜ 1 ⌝ + δ
lemma₇ {δ} = suc λ { .force →
δ ∎≤ }
lemma₈ : ∀ {δ} → [ ∞ ] max ⌜ 1 ⌝ (max ⌜ 1 ⌝ δ) ≤ max ⌜ 1 ⌝ δ
lemma₈ {δ} = suc λ { .force →
Conat.pred δ ∎≤ }
lemma₉ :
∀ {δ} → [ ∞ ] max ⌜ 1 ⌝ (max ⌜ 1 ⌝ (max ⌜ 1 ⌝ δ)) ≤ max ⌜ 1 ⌝ δ
lemma₉ {δ} =
max ⌜ 1 ⌝ (max ⌜ 1 ⌝ (max ⌜ 1 ⌝ δ)) ≤⟨ lemma₈ ⟩
max ⌜ 1 ⌝ (max ⌜ 1 ⌝ δ) ≤⟨ lemma₈ ⟩
max ⌜ 1 ⌝ δ ∎≤
lemma₁₀ : ∀ {δ} → [ ∞ ] ⌜ 1 ⌝ + ⌜ 0 ⌝ ≤ max ⌜ 1 ⌝ δ
lemma₁₀ = suc λ { .force → zero }
lemma₁₁ : Conat.[ ∞ ] max ⌜ 1 ⌝ ⌜ 1 ⌝ ∼ ⌜ 1 ⌝
lemma₁₁ = suc λ { .force → zero }
lemma₁₂ : Conat.[ ∞ ] ⌜ 1 ⌝ + ⌜ 1 ⌝ ∼ ⌜ 2 ⌝
lemma₁₂ = Conat.symmetric-∼ (Conat.⌜⌝-+ 1)
------------------------------------------------------------------------
-- Well-formed continuations and stacks
-- A continuation is OK with respect to a certain state and conatural
-- number if the following property is satisfied.
Cont-OK :
Size → State → (T.Value → Delay-crash C.Value ∞) → Conat ∞ → Type
Cont-OK i ⟨ c , s , ρ ⟩ k δ =
∀ v → [ i ∣ ⌜ 1 ⌝ ∣ δ ] exec ⟨ c , val (comp-val v) ∷ s , ρ ⟩ ≳ k v
-- If the In-tail-context parameter indicates that we are in a tail
-- context, then the stack must have a certain shape, and it must be
-- related to the continuation and the conatural number in a certain
-- way.
data Stack-OK
(i : Size) (k : T.Value → Delay-crash C.Value ∞) (δ : Conat ∞) :
In-tail-context → Stack → Type where
unrestricted : ∀ {s} → Stack-OK i k δ false s
restricted : ∀ {s n} {c : Code n} {ρ : C.Env n} →
Cont-OK i ⟨ c , s , ρ ⟩ k δ →
Stack-OK i k δ true (ret c ρ ∷ s)
-- A lemma that can be used to show that certain stacks are OK.
ret-ok :
∀ {p i s n c} {ρ : C.Env n} {k δ} →
Cont-OK i ⟨ c , s , ρ ⟩ k δ →
Stack-OK i k (⌜ 1 ⌝ + δ) p (ret c ρ ∷ s)
ret-ok {true} c-ok = restricted (weakenˡ lemma₁ ∘ c-ok)
ret-ok {false} _ = unrestricted
------------------------------------------------------------------------
-- The semantics of the compiled program matches that of the source
-- code
mutual
-- Some lemmas making up the main part of the compiler correctness
-- result.
⟦⟧-correct :
∀ {i n} (t : Tm n) (ρ : T.Env n) {c s}
{k : T.Value → Delay-crash C.Value ∞} {tc δ} →
Stack-OK i k δ tc s →
Cont-OK i ⟨ c , s , comp-env ρ ⟩ k δ →
[ i ∣ ⌜ 1 ⌝ ∣ max ⌜ 1 ⌝ δ ]
exec ⟨ comp tc t c , s , comp-env ρ ⟩ ≳ ⟦ t ⟧ ρ >>= k
⟦⟧-correct (var x) ρ {c} {s} {k} _ c-ok =
exec ⟨ var x ∷ c , s , comp-env ρ ⟩ ≳⟨ later (λ { .force →
exec ⟨ c , val By.⟨ index (comp-env ρ) x ⟩ ∷ s , comp-env ρ ⟩ ≡⟨ By.⟨by⟩ (comp-index ρ x) ⟩ˢ
exec ⟨ c , val (comp-val (index ρ x)) ∷ s , comp-env ρ ⟩ ≳⟨ weakenˡ lemma₄ (c-ok (index ρ x)) ⟩ˢ
k (index ρ x) ∎ }) ⟩ˢ
⟦ var x ⟧ ρ >>= k ∎
⟦⟧-correct (lam t) ρ {c} {s} {k} _ c-ok =
exec ⟨ clo (comp-body t) ∷ c , s , comp-env ρ ⟩ ≳⟨ later (λ { .force →
exec ⟨ c , val (comp-val (T.lam t ρ)) ∷ s , comp-env ρ ⟩ ≳⟨ weakenˡ lemma₄ (c-ok (T.lam t ρ)) ⟩ˢ
k (T.lam t ρ) ∎ }) ⟩ˢ
⟦ lam t ⟧ ρ >>= k ∎
⟦⟧-correct (t₁ · t₂) ρ {c} {s} {k} _ c-ok =
exec ⟨ comp false t₁ (comp false t₂ (app ∷ c))
, s
, comp-env ρ
⟩ ≳⟨ weakenˡ lemma₉ (⟦⟧-correct t₁ _ unrestricted λ v₁ →
exec ⟨ comp false t₂ (app ∷ c)
, val (comp-val v₁) ∷ s
, comp-env ρ
⟩ ≳⟨ (⟦⟧-correct t₂ _ unrestricted λ v₂ →
exec ⟨ app ∷ c
, val (comp-val v₂) ∷ val (comp-val v₁) ∷ s
, comp-env ρ
⟩ ≳⟨ ∙-correct v₁ v₂ c-ok ⟩ˢ
v₁ ∙ v₂ >>= k ∎) ⟩ˢ
(⟦ t₂ ⟧ ρ >>= λ v₂ → v₁ ∙ v₂ >>= k) ∎) ⟩ˢ
(⟦ t₁ ⟧ ρ >>= λ v₁ → ⟦ t₂ ⟧ ρ >>= λ v₂ → v₁ ∙ v₂ >>= k) ∼⟨ symmetric (⟦⟧-· t₁ t₂) ⟩
⟦ t₁ · t₂ ⟧ ρ >>= k ∎
⟦⟧-correct (call f t) ρ {c} {s} {k} unrestricted c-ok =
exec ⟨ comp false (call f t) c , s , comp-env ρ ⟩ ∼⟨⟩ˢ
exec ⟨ comp false t (cal f ∷ c) , s , comp-env ρ ⟩ ≳⟨ (⟦⟧-correct t _ unrestricted λ v →
exec ⟨ cal f ∷ c , val (comp-val v) ∷ s , comp-env ρ ⟩ ≳⟨ (later λ { .force → weakenˡ lemma₅ (
exec ⟨ comp-name f
, ret c (comp-env ρ) ∷ s
, comp-val v ∷ []
⟩ ≳⟨ body-lemma (def f) [] c-ok ⟩ˢ
(⟦ def f ⟧ (v ∷ []) >>= k) ∎) }) ⟩ˢ
(T.lam (def f) [] ∙ v >>= k) ∎) ⟩ˢ
(⟦ t ⟧ ρ >>= λ v → T.lam (def f) [] ∙ v >>= k) ∼⟨ associativity (⟦ t ⟧ ρ) _ _ ⟩
(⟦ t ⟧ ρ >>= λ v → T.lam (def f) [] ∙ v) >>= k ∼⟨⟩
⟦ call f t ⟧ ρ >>= k ∎
⟦⟧-correct (call f t) ρ {c} {ret c′ ρ′ ∷ s} {k} (restricted c-ok) _ =
exec ⟨ comp true (call f t) c , ret c′ ρ′ ∷ s , comp-env ρ ⟩ ∼⟨⟩ˢ
exec ⟨ comp false t (tcl f ∷ c) , ret c′ ρ′ ∷ s , comp-env ρ ⟩ ≳⟨ (⟦⟧-correct t _ unrestricted λ v →
exec ⟨ tcl f ∷ c
, val (comp-val v) ∷ ret c′ ρ′ ∷ s
, comp-env ρ
⟩ ≳⟨ (later λ { .force → weakenˡ lemma₅ (
exec ⟨ comp-name f
, ret c′ ρ′ ∷ s
, comp-val v ∷ []
⟩ ≳⟨ body-lemma (def f) [] c-ok ⟩ˢ
⟦ def f ⟧ (v ∷ []) >>= k ∎) }) ⟩ˢ
T.lam (def f) [] ∙ v >>= k ∎) ⟩ˢ
(⟦ t ⟧ ρ >>= λ v → T.lam (def f) [] ∙ v >>= k) ∼⟨ associativity (⟦ t ⟧ ρ) _ _ ⟩
(⟦ t ⟧ ρ >>= λ v → T.lam (def f) [] ∙ v) >>= k ∼⟨⟩
⟦ call f t ⟧ ρ >>= k ∎
⟦⟧-correct (con b) ρ {c} {s} {k} _ c-ok =
exec ⟨ con b ∷ c , s , comp-env ρ ⟩ ≳⟨ later (λ { .force →
exec ⟨ c , val (comp-val (T.con b)) ∷ s , comp-env ρ ⟩ ≳⟨ weakenˡ lemma₄ (c-ok (T.con b)) ⟩ˢ
k (T.con b) ∎ }) ⟩ˢ
⟦ con b ⟧ ρ >>= k ∎
⟦⟧-correct (if t₁ t₂ t₃) ρ {c} {s} {k} {tc} s-ok c-ok =
exec ⟨ comp false t₁ (bra (comp tc t₂ []) (comp tc t₃ []) ∷ c)
, s
, comp-env ρ
⟩ ≳⟨ weakenˡ lemma₈
(⟦⟧-correct t₁ _ unrestricted λ v₁ → ⟦if⟧-correct v₁ t₂ t₃ s-ok c-ok) ⟩ˢ
(⟦ t₁ ⟧ ρ >>= λ v₁ → ⟦if⟧ v₁ t₂ t₃ ρ >>= k) ∼⟨ associativity (⟦ t₁ ⟧ ρ) _ _ ⟩
(⟦ t₁ ⟧ ρ >>= λ v₁ → ⟦if⟧ v₁ t₂ t₃ ρ) >>= k ∼⟨⟩
⟦ if t₁ t₂ t₃ ⟧ ρ >>= k ∎
body-lemma :
∀ {i n n′} (t : Tm (suc n)) ρ {ρ′ : C.Env n′} {c s v}
{k : T.Value → Delay-crash C.Value ∞} {δ} →
Cont-OK i ⟨ c , s , ρ′ ⟩ k δ →
[ i ∣ ⌜ 1 ⌝ ∣ ⌜ 1 ⌝ + δ ]
exec ⟨ comp-body t , ret c ρ′ ∷ s , comp-val v ∷ comp-env ρ ⟩ ≳
⟦ t ⟧ (v ∷ ρ) >>= k
body-lemma t ρ {ρ′} {c} {s} {v} {k} c-ok =
exec ⟨ comp-body t , ret c ρ′ ∷ s , comp-val v ∷ comp-env ρ ⟩ ∼⟨⟩ˢ
exec ⟨ comp-body t , ret c ρ′ ∷ s , comp-env (v ∷ ρ) ⟩ ≳⟨ weakenˡ lemma₇ (⟦⟧-correct t (_ ∷ _) (ret-ok c-ok) λ v′ →
exec ⟨ ret ∷ []
, val (comp-val v′) ∷ ret c ρ′ ∷ s
, comp-env (v ∷ ρ)
⟩ ≳⟨⟩ˢ
exec ⟨ c , val (comp-val v′) ∷ s , ρ′ ⟩ ≳⟨ c-ok v′ ⟩ˢ
k v′ ∎) ⟩ˢ
⟦ t ⟧ (v ∷ ρ) >>= k ∎
∙-correct :
∀ {i n} v₁ v₂ {ρ : C.Env n} {c s}
{k : T.Value → Delay-crash C.Value ∞} {δ} →
Cont-OK i ⟨ c , s , ρ ⟩ k δ →
[ i ∣ ⌜ 1 ⌝ ∣ max ⌜ 1 ⌝ δ ]
exec ⟨ app ∷ c , val (comp-val v₂) ∷ val (comp-val v₁) ∷ s , ρ ⟩ ≳
v₁ ∙ v₂ >>= k
∙-correct (T.lam t₁ ρ₁) v₂ {ρ} {c} {s} {k} c-ok =
exec ⟨ app ∷ c
, val (comp-val v₂) ∷ val (comp-val (T.lam t₁ ρ₁)) ∷ s
, ρ
⟩ ≳⟨ later (λ { .force → weakenˡ lemma₆ (
exec ⟨ comp-body t₁ , ret c ρ ∷ s , comp-val v₂ ∷ comp-env ρ₁ ⟩ ≳⟨ body-lemma t₁ _ c-ok ⟩ˢ
⟦ t₁ ⟧ (v₂ ∷ ρ₁) >>= k ∎) }) ⟩ˢ
T.lam t₁ ρ₁ ∙ v₂ >>= k ∎
∙-correct (T.con b) v₂ {ρ} {c} {s} {k} _ = weakenˡ lemma₁₀ (
exec ⟨ app ∷ c
, val (comp-val v₂) ∷ val (comp-val (T.con b)) ∷ s
, ρ
⟩ ≳⟨⟩ˢ
crash ∼⟨⟩ˢ
T.con b ∙ v₂ >>= k ∎ˢ)
⟦if⟧-correct :
∀ {i n} v₁ (t₂ t₃ : Tm n) {ρ : T.Env n} {c s}
{k : T.Value → Delay-crash C.Value ∞} {tc δ} →
Stack-OK i k δ tc s →
Cont-OK i ⟨ c , s , comp-env ρ ⟩ k δ →
[ i ∣ ⌜ 1 ⌝ ∣ max ⌜ 1 ⌝ δ ]
exec ⟨ bra (comp tc t₂ []) (comp tc t₃ []) ∷ c
, val (comp-val v₁) ∷ s
, comp-env ρ
⟩ ≳
⟦if⟧ v₁ t₂ t₃ ρ >>= k
⟦if⟧-correct (T.lam t₁ ρ₁) t₂ t₃ {ρ} {c} {s} {k} {tc} _ _ =
weakenˡ lemma₁₀ (
exec ⟨ bra (comp tc t₂ []) (comp tc t₃ []) ∷ c
, val (comp-val (T.lam t₁ ρ₁)) ∷ s
, comp-env ρ
⟩ ≳⟨⟩ˢ
crash ∼⟨⟩ˢ
⟦if⟧ (T.lam t₁ ρ₁) t₂ t₃ ρ >>= k ∎ˢ)
⟦if⟧-correct (T.con true) t₂ t₃ {ρ} {c} {s} {k} {tc} s-ok c-ok =
exec ⟨ bra (comp tc t₂ []) (comp tc t₃ []) ∷ c
, val (comp-val (T.con true)) ∷ s
, comp-env ρ
⟩ ≳⟨ later (λ { .force → weakenˡ lemma₃ (
exec ⟨ comp tc t₂ [] ++ c , s , comp-env ρ ⟩ ≡⟨ By.by (comp-++ _ t₂) ⟩ˢ
exec ⟨ comp tc t₂ c , s , comp-env ρ ⟩ ≳⟨ ⟦⟧-correct t₂ _ s-ok c-ok ⟩ˢ
⟦ t₂ ⟧ ρ >>= k ∎) }) ⟩ˢ
⟦if⟧ (T.con true) t₂ t₃ ρ >>= k ∎
⟦if⟧-correct (T.con false) t₂ t₃ {ρ} {c} {s} {k} {tc} s-ok c-ok =
exec ⟨ bra (comp tc t₂ []) (comp tc t₃ []) ∷ c
, val (comp-val (T.con false)) ∷ s
, comp-env ρ
⟩ ≳⟨ later (λ { .force → weakenˡ lemma₃ (
exec ⟨ comp tc t₃ [] ++ c , s , comp-env ρ ⟩ ≡⟨ By.by (comp-++ _ t₃) ⟩ˢ
exec ⟨ comp tc t₃ c , s , comp-env ρ ⟩ ≳⟨ ⟦⟧-correct t₃ _ s-ok c-ok ⟩ˢ
⟦ t₃ ⟧ ρ >>= k ∎) }) ⟩ˢ
⟦if⟧ (T.con false) t₂ t₃ ρ >>= k ∎
-- The "time complexity" of the compiled program is linear in the time
-- complexity obtained from the instrumented interpreter, and vice
-- versa.
steps-match :
(t : Tm 0) →
[ ∞ ] steps (⟦ t ⟧ []) ≤ steps (exec ⟨ comp₀ t , [] , [] ⟩)
×
[ ∞ ] steps (exec ⟨ comp₀ t , [] , [] ⟩) ≤
⌜ 1 ⌝ + ⌜ 2 ⌝ * steps (⟦ t ⟧ [])
steps-match t = $⟨ ⟦⟧-correct t [] unrestricted (λ v → laterˡ (return (comp-val v) ∎ˢ)) ⟩
[ ∞ ∣ ⌜ 1 ⌝ ∣ max ⌜ 1 ⌝ ⌜ 1 ⌝ ]
exec ⟨ comp₀ t , [] , [] ⟩ ≳ comp-val ⟨$⟩ ⟦ t ⟧ [] ↝⟨ proj₂ ∘ _⇔_.to ≳⇔≈×steps≤steps² ⟩
[ ∞ ] steps (comp-val ⟨$⟩ ⟦ t ⟧ []) ≤
steps (exec ⟨ comp₀ t , [] , [] ⟩) ×
[ ∞ ] steps (exec ⟨ comp₀ t , [] , [] ⟩) ≤
max ⌜ 1 ⌝ ⌜ 1 ⌝ +
(⌜ 1 ⌝ + ⌜ 1 ⌝) * steps (comp-val ⟨$⟩ ⟦ t ⟧ []) ↝⟨ _⇔_.to (steps-⟨$⟩ Conat.≤-cong-∼ (_ Conat.∎∼)
×-cong
(_ Conat.∎∼)
Conat.≤-cong-∼
lemma₁₁ Conat.+-cong lemma₁₂ Conat.*-cong steps-⟨$⟩) ⟩□
[ ∞ ] steps (⟦ t ⟧ []) ≤ steps (exec ⟨ comp₀ t , [] , [] ⟩) ×
[ ∞ ] steps (exec ⟨ comp₀ t , [] , [] ⟩) ≤
⌜ 1 ⌝ + ⌜ 2 ⌝ * steps (⟦ t ⟧ []) □
| {
"alphanum_fraction": 0.3702799897,
"avg_line_length": 38.449382716,
"ext": "agda",
"hexsha": "cb9287e951298f7a1571cb90cad92433c2fd7f47",
"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": "dec8cd2d2851340840de25acb0feb78f7b5ffe96",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/definitional-interpreters",
"max_forks_repo_path": "src/Lambda/Compiler-correctness/Steps-match.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "dec8cd2d2851340840de25acb0feb78f7b5ffe96",
"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/definitional-interpreters",
"max_issues_repo_path": "src/Lambda/Compiler-correctness/Steps-match.agda",
"max_line_length": 145,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "dec8cd2d2851340840de25acb0feb78f7b5ffe96",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/definitional-interpreters",
"max_stars_repo_path": "src/Lambda/Compiler-correctness/Steps-match.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 6144,
"size": 15572
} |
module _ where
{- NOTE: To run move to adga directory or figure out how `agda -I` works -}
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
import Relation.Binary.PropositionalEquality as Prop
open import Data.Empty
open import calculus
open import context-properties
open import Esterel.Lang.Binding
open import Data.Maybe using (just ; nothing)
open import Esterel.Variable.Signal as Signal using (Signal ; _ₛ)
open import Esterel.Variable.Sequential as SeqVar using (SeqVar ; _ᵥ)
open import Esterel.Variable.Shared as ShVar using (SharedVar ; _ₛₕ)
open import Data.List.Any
S : Signal
S = 0 ₛ
start : Term
start = signl S ((emit S) >> (present S ∣⇒ pause ∣⇒ nothin))
step1 = ρ (Θ [ (just Signal.unknown) ] [] []) · ((emit S) >> (present S ∣⇒ pause ∣⇒ nothin))
step2 = ρ (Θ [ (just Signal.present) ] [] []) · (nothin >> (present S ∣⇒ pause ∣⇒ nothin))
step3 = ρ (Θ [ (just Signal.present) ] [] []) · (present S ∣⇒ pause ∣⇒ nothin)
end : Term
end = ρ (Θ [ (just Signal.present) ] [] []) · pause
red : start ⟶* end
red = rstep{start}{step1}
(⟶-inclusion (rraise-signal{((emit S) >> (present S ∣⇒ pause ∣⇒ nothin))}{S}) )
(rstep {step1} {step2}
(⟶-inclusion (remit (Data.List.Any.Any.here Prop.refl)
(deseq{p = (emit S)}{q = (present S ∣⇒ pause ∣⇒ nothin)} (dehole{emit S}))))
(rstep {step2} {step3}
(rcontext (cenv (Θ (just Signal.present ∷ []) [] []) ∷ [])
(dcenv dchole) rseq-done)
(rstep {step3} {end}
(rcontext [] dchole
(ris-present (Data.List.Any.Any.here Prop.refl) Prop.refl dehole)) rrefl)))
| {
"alphanum_fraction": 0.610542477,
"avg_line_length": 39.8775510204,
"ext": "agda",
"hexsha": "a03022058b8c820fad0d6756f10e6c0d7e7ff4e9",
"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": "cross-tests/examples/test.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": "cross-tests/examples/test.agda",
"max_line_length": 114,
"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": "cross-tests/examples/test.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": 596,
"size": 1954
} |
postulate
I : Set
f : Set → I
mutual
data P : I → Set where
Q : I → Set
Q x = P (f (P x))
| {
"alphanum_fraction": 0.4757281553,
"avg_line_length": 9.3636363636,
"ext": "agda",
"hexsha": "9015e79903cd9f20b39c198fd4aea01930a79eb8",
"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/Issue3592-1.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/Issue3592-1.agda",
"max_line_length": 24,
"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/Issue3592-1.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 45,
"size": 103
} |
{-# OPTIONS --without-K #-}
module WithoutK8 where
data I : Set where
i : I
module M (x : I) where
data D : Set where
d : D
data P : D → Set where
postulate x : I
open module M′ = M x
Foo : P d → Set
Foo ()
| {
"alphanum_fraction": 0.5688888889,
"avg_line_length": 10.7142857143,
"ext": "agda",
"hexsha": "bf5d43cf64cfb6b3b508e0f70d81246fce1b0b74",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "np/agda-git-experiment",
"max_forks_repo_path": "test/fail/WithoutK8.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "np/agda-git-experiment",
"max_issues_repo_path": "test/fail/WithoutK8.agda",
"max_line_length": 27,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "np/agda-git-experiment",
"max_stars_repo_path": "test/fail/WithoutK8.agda",
"max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z",
"num_tokens": 76,
"size": 225
} |
module Human.List where
open import Human.Nat
infixr 5 _,_
data List {a} (A : Set a) : Set a where
end : List A
_,_ : (x : A) (xs : List A) → List A
{-# BUILTIN LIST List #-}
{-# COMPILE JS List = function(x,v) { if (x.length < 1) { return v["[]"](); } else { return v["_∷_"](x[0], x.slice(1)); } } #-}
{-# COMPILE JS end = Array() #-}
{-# COMPILE JS _,_ = function (x) { return function(y) { return Array(x).concat(y); }; } #-}
foldr : ∀ {A : Set} {B : Set} → (A → B → B) → B → List A → B
foldr c n end = n
foldr c n (x , xs) = c x (foldr c n xs)
length : ∀ {A : Set} → List A → Nat
length = foldr (λ a n → suc n) zero
-- TODO --
-- filter
-- reduce
-- Receives a function that transforms each element of A, a function A and a new list, B.
map : ∀ {A : Set} {B : Set} → (f : A → B) → List A → List B
map f end = end
map f (x , xs) = (f x) , (map f xs) -- f transforms element x, return map to do a new transformation
-- Sum all numbers in a list
sum : List Nat → Nat
sum end = zero
sum (x , l) = x + (sum l)
remove-last : ∀ {A : Set} → List A → List A
remove-last end = end
remove-last (x , l) = l
| {
"alphanum_fraction": 0.5516328332,
"avg_line_length": 28.325,
"ext": "agda",
"hexsha": "21cc7c58c4b6dd20c7f624fa65c4983af33ff34c",
"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": "b509eb4c4014605facfb4ee5c807cd07753d4477",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "MaisaMilena/JuiceMaker",
"max_forks_repo_path": "src/Human/List.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b509eb4c4014605facfb4ee5c807cd07753d4477",
"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": "MaisaMilena/JuiceMaker",
"max_issues_repo_path": "src/Human/List.agda",
"max_line_length": 128,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "b509eb4c4014605facfb4ee5c807cd07753d4477",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "MaisaMilena/JuiceMaker",
"max_stars_repo_path": "src/Human/List.agda",
"max_stars_repo_stars_event_max_datetime": "2020-11-28T05:46:27.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-03-29T17:35:20.000Z",
"num_tokens": 401,
"size": 1133
} |
{-# OPTIONS --safe #-}
module Cubical.Data.Vec.Properties where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Univalence
import Cubical.Data.Empty as ⊥
open import Cubical.Data.Unit
open import Cubical.Data.Nat
open import Cubical.Data.Sigma
open import Cubical.Data.Sum
open import Cubical.Data.Vec.Base
open import Cubical.Data.FinData
open import Cubical.Relation.Nullary
open Iso
private
variable
ℓ : Level
A : Type ℓ
-- This is really cool!
-- Compare with: https://github.com/agda/agda-stdlib/blob/master/src/Data/Vec/Properties/WithK.agda#L32
++-assoc : ∀ {m n k} (xs : Vec A m) (ys : Vec A n) (zs : Vec A k) →
PathP (λ i → Vec A (+-assoc m n k (~ i))) ((xs ++ ys) ++ zs) (xs ++ ys ++ zs)
++-assoc {m = zero} [] ys zs = refl
++-assoc {m = suc m} (x ∷ xs) ys zs i = x ∷ ++-assoc xs ys zs i
-- Equivalence between Fin n → A and Vec A n
FinVec→Vec : {n : ℕ} → FinVec A n → Vec A n
FinVec→Vec {n = zero} xs = []
FinVec→Vec {n = suc _} xs = xs zero ∷ FinVec→Vec (λ x → xs (suc x))
Vec→FinVec : {n : ℕ} → Vec A n → FinVec A n
Vec→FinVec xs f = lookup f xs
FinVec→Vec→FinVec : {n : ℕ} (xs : FinVec A n) → Vec→FinVec (FinVec→Vec xs) ≡ xs
FinVec→Vec→FinVec {n = zero} xs = funExt λ f → ⊥.rec (¬Fin0 f)
FinVec→Vec→FinVec {n = suc n} xs = funExt goal
where
goal : (f : Fin (suc n))
→ Vec→FinVec (xs zero ∷ FinVec→Vec (λ x → xs (suc x))) f ≡ xs f
goal zero = refl
goal (suc f) i = FinVec→Vec→FinVec (λ x → xs (suc x)) i f
Vec→FinVec→Vec : {n : ℕ} (xs : Vec A n) → FinVec→Vec (Vec→FinVec xs) ≡ xs
Vec→FinVec→Vec {n = zero} [] = refl
Vec→FinVec→Vec {n = suc n} (x ∷ xs) i = x ∷ Vec→FinVec→Vec xs i
FinVecIsoVec : (n : ℕ) → Iso (FinVec A n) (Vec A n)
FinVecIsoVec n = iso FinVec→Vec Vec→FinVec Vec→FinVec→Vec FinVec→Vec→FinVec
FinVec≃Vec : (n : ℕ) → FinVec A n ≃ Vec A n
FinVec≃Vec n = isoToEquiv (FinVecIsoVec n)
FinVec≡Vec : (n : ℕ) → FinVec A n ≡ Vec A n
FinVec≡Vec n = ua (FinVec≃Vec n)
isContrVec0 : isContr (Vec A 0)
isContrVec0 = [] , λ { [] → refl }
-- encode - decode Vec
module VecPath {A : Type ℓ}
where
code : {n : ℕ} → (v v' : Vec A n) → Type ℓ
code [] [] = Unit*
code (a ∷ v) (a' ∷ v') = (a ≡ a') × (v ≡ v')
-- encode
reflEncode : {n : ℕ} → (v : Vec A n) → code v v
reflEncode [] = tt*
reflEncode (a ∷ v) = refl , refl
encode : {n : ℕ} → (v v' : Vec A n) → (v ≡ v') → code v v'
encode v v' p = J (λ v' _ → code v v') (reflEncode v) p
encodeRefl : {n : ℕ} → (v : Vec A n) → encode v v refl ≡ reflEncode v
encodeRefl v = JRefl (λ v' _ → code v v') (reflEncode v)
-- decode
decode : {n : ℕ} → (v v' : Vec A n) → (r : code v v') → (v ≡ v')
decode [] [] _ = refl
decode (a ∷ v) (a' ∷ v') (p , q) = cong₂ _∷_ p q
decodeRefl : {n : ℕ} → (v : Vec A n) → decode v v (reflEncode v) ≡ refl
decodeRefl [] = refl
decodeRefl (a ∷ v) = refl
-- equiv
≡Vec≃codeVec : {n : ℕ} → (v v' : Vec A n) → (v ≡ v') ≃ (code v v')
≡Vec≃codeVec v v' = isoToEquiv is
where
is : Iso (v ≡ v') (code v v')
fun is = encode v v'
inv is = decode v v'
rightInv is = sect v v'
where
sect : {n : ℕ} → (v v' : Vec A n) → (r : code v v')
→ encode v v' (decode v v' r) ≡ r
sect [] [] tt* = encodeRefl []
sect (a ∷ v) (a' ∷ v') (p , q) = J (λ a' p → encode (a ∷ v) (a' ∷ v') (decode (a ∷ v) (a' ∷ v') (p , q)) ≡ (p , q))
(J (λ v' q → encode (a ∷ v) (a ∷ v') (decode (a ∷ v) (a ∷ v') (refl , q)) ≡ (refl , q))
(encodeRefl (a ∷ v)) q) p
leftInv is = retr v v'
where
retr : {n : ℕ} → (v v' : Vec A n) → (p : v ≡ v')
→ decode v v' (encode v v' p) ≡ p
retr v v' p = J (λ v' p → decode v v' (encode v v' p) ≡ p)
(cong (decode v v) (encodeRefl v) ∙ decodeRefl v) p
isOfHLevelVec : (h : HLevel) (n : ℕ)
→ isOfHLevel (suc (suc h)) A → isOfHLevel (suc (suc h)) (Vec A n)
isOfHLevelVec h zero ofLevelA [] [] = isOfHLevelRespectEquiv (suc h) (invEquiv (≡Vec≃codeVec [] []))
(isOfHLevelUnit* (suc h))
isOfHLevelVec h (suc n) ofLevelA (x ∷ v) (x' ∷ v') = isOfHLevelRespectEquiv (suc h) (invEquiv (≡Vec≃codeVec _ _))
(isOfHLevelΣ (suc h) (ofLevelA x x') (λ _ → isOfHLevelVec h n ofLevelA v v'))
discreteA→discreteVecA : Discrete A → (n : ℕ) → Discrete (Vec A n)
discreteA→discreteVecA DA zero [] [] = yes refl
discreteA→discreteVecA DA (suc n) (a ∷ v) (a' ∷ v') with (DA a a') | (discreteA→discreteVecA DA n v v')
... | yes p | yes q = yes (invIsEq (snd (≡Vec≃codeVec (a ∷ v) (a' ∷ v'))) (p , q))
... | yes p | no ¬q = no (λ r → ¬q (snd (funIsEq (snd (≡Vec≃codeVec (a ∷ v) (a' ∷ v'))) r)))
... | no ¬p | yes q = no (λ r → ¬p (fst (funIsEq (snd (≡Vec≃codeVec (a ∷ v) (a' ∷ v'))) r)))
... | no ¬p | no ¬q = no (λ r → ¬q (snd (funIsEq (snd (≡Vec≃codeVec (a ∷ v) (a' ∷ v'))) r)))
≢-∷ : {m : ℕ} → (Discrete A) → (a : A) → (v : Vec A m) → (a' : A) → (v' : Vec A m) →
(a ∷ v ≡ a' ∷ v' → ⊥.⊥) → (a ≡ a' → ⊥.⊥) ⊎ (v ≡ v' → ⊥.⊥)
≢-∷ {m} discreteA a v a' v' ¬r with (discreteA a a')
| (discreteA→discreteVecA discreteA m v v')
... | yes p | yes q = ⊥.rec (¬r (cong₂ _∷_ p q))
... | yes p | no ¬q = inr ¬q
... | no ¬p | y = inl ¬p
| {
"alphanum_fraction": 0.525136612,
"avg_line_length": 38.661971831,
"ext": "agda",
"hexsha": "4059ed3cb3481f0e98e66a52fad77aca56474f1c",
"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/Data/Vec/Properties.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/Data/Vec/Properties.agda",
"max_line_length": 132,
"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/Data/Vec/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2257,
"size": 5490
} |
module Oscar.Data.AList where
open import Oscar.Data.Equality
open import Oscar.Data.Nat
open import Oscar.Level
module _ {a} (A : Nat → Set a) where
data AList (n : Nat) : Nat → Set a where
[] : AList n n
_∷_ : ∀ {m} → A m → AList n m → AList n (suc m)
open import Oscar.Category
module Category' {a} {A : Nat → Set a} where
_⊸_ = AList A
infix 4 _≋_
_≋_ : ∀ {m n} → m ⊸ n → m ⊸ n → Set a
_≋_ = _≡_
infixr 9 _∙_
_∙_ : ∀ {m n} → m ⊸ n → ∀ {l} → l ⊸ m → l ⊸ n
[] ∙ ρ = ρ
(x ∷ σ) ∙ ρ = x ∷ (σ ∙ ρ)
∙-associativity : ∀ {k l} (f : k ⊸ l) {m} (g : l ⊸ m) {n} (h : m ⊸ n) → (h ∙ g) ∙ f ≋ h ∙ g ∙ f
∙-associativity f g [] = refl
∙-associativity f g (x ∷ h) = cong (x ∷_) (∙-associativity f g h)
ε : ∀ {n} → n ⊸ n
ε = []
∙-left-identity : ∀ {m n} (σ : m ⊸ n) → ε ∙ σ ≋ σ
∙-left-identity _ = refl
∙-right-identity : ∀ {m n} (σ : m ⊸ n) → σ ∙ ε ≋ σ
∙-right-identity [] = refl
∙-right-identity (x ∷ σ) = cong (x ∷_) (∙-right-identity σ)
semigroupoidAList : Semigroupoid (AList A) (λ {x y} → ≡-setoid (AList A x y))
Semigroupoid._∙_ semigroupoidAList = _∙_
Semigroupoid.∙-extensionality semigroupoidAList refl refl = refl
Semigroupoid.∙-associativity semigroupoidAList = ∙-associativity
categoryAList : Category semigroupoidAList
Category.ε categoryAList = ε
Category.ε-left-identity categoryAList = ∙-left-identity _
Category.ε-right-identity categoryAList = ∙-right-identity _
-- ∙-associativity σ _ [] = refl
-- ∙-associativity (τ asnoc t / x) ρ σ = cong (λ s → s asnoc t / x) (∙-associativity τ ρ σ)
-- -- semigroupoid : ∀ {a} (A : Nat → Set a) → Semigroupoid a a ∅̂
-- -- Semigroupoid._∙_ = semigroupoid
-- -- -- record Semigroupoid
-- -- -- {𝔬} {𝔒 :
-- -- -- -- module Oscar.Data.AList {𝔣} (FunctionName : Set 𝔣) where
-- -- -- -- open import Oscar.Data.Fin
-- -- -- -- open import Oscar.Data.Nat
-- -- -- -- open import Oscar.Data.Product
-- -- -- -- open import Oscar.Data.Term FunctionName
-- -- -- -- open import Oscar.Data.IList
-- -- -- -- pattern anil = []
-- -- -- -- pattern _asnoc_/_ σ t' x = (t' , x) ∷ σ
-- -- -- -- AList : Nat → Nat → Set 𝔣
-- -- -- -- AList m n = IList (λ m → Term m × Fin (suc m)) n m
-- -- -- -- -- data AList' (n : Nat) : Nat -> Set 𝔣 where
-- -- -- -- -- anil : AList' n n
-- -- -- -- -- _asnoc_/_ : ∀ {m} (σ : AList' n m) (t' : Term m) (x : Fin (suc m))
-- -- -- -- -- -> AList' n (suc m)
-- -- -- -- -- open import Oscar.Function
-- -- -- -- -- --AList = flip AList'
-- -- -- -- -- -- data AList : Nat -> Nat -> Set 𝔣 where
-- -- -- -- -- -- anil : ∀ {n} -> AList n n
-- -- -- -- -- -- _asnoc_/_ : ∀ {m n} (σ : AList m n) (t' : Term m) (x : Fin (suc m))
-- -- -- -- -- -- -> AList (suc m) n
-- -- -- -- -- -- -- open import Relation.Binary.PropositionalEquality renaming ([_] to [[_]])
-- -- -- -- -- -- -- open ≡-Reasoning
-- -- -- -- -- -- -- step-prop : ∀ {m n} (s t : Term (suc m)) (σ : AList m n) r z ->
-- -- -- -- -- -- -- (Unifies s t [-◇ sub (σ asnoc r / z) ]) ⇔ (Unifies ((r for z) ◃ s) ((r for z) ◃ t) [-◇ sub σ ])
-- -- -- -- -- -- -- step-prop s t σ r z f = to , from
-- -- -- -- -- -- -- where
-- -- -- -- -- -- -- lemma1 : ∀ t -> (f ◇ sub σ) ◃ ((r for z) ◃ t) ≡ (f ◇ (sub σ ◇ (r for z))) ◃ t
-- -- -- -- -- -- -- lemma1 t = bind-assoc f (sub σ) (r for z) t
-- -- -- -- -- -- -- to = λ a → begin
-- -- -- -- -- -- -- (f ◇ sub σ) ◃ ((r for z) ◃ s) ≡⟨ lemma1 s ⟩
-- -- -- -- -- -- -- (f ◇ (sub σ ◇ (r for z))) ◃ s ≡⟨ a ⟩
-- -- -- -- -- -- -- (f ◇ (sub σ ◇ (r for z))) ◃ t ≡⟨ sym (lemma1 t) ⟩
-- -- -- -- -- -- -- (f ◇ sub σ) ◃ ((r for z) ◃ t) ∎
-- -- -- -- -- -- -- from = λ a → begin
-- -- -- -- -- -- -- (f ◇ (sub σ ◇ (r for z))) ◃ s ≡⟨ sym (lemma1 s) ⟩
-- -- -- -- -- -- -- (f ◇ sub σ) ◃ ((r for z) ◃ s) ≡⟨ a ⟩
-- -- -- -- -- -- -- (f ◇ sub σ) ◃ ((r for z) ◃ t) ≡⟨ lemma1 t ⟩
-- -- -- -- -- -- -- (f ◇ (sub σ ◇ (r for z))) ◃ t ∎
-- -- -- -- -- -- -- record ⋆amgu (T : ℕ → Set) : Set where
-- -- -- -- -- -- -- field amgu : ∀ {m} (s t : T m) (acc : ∃ (AList m)) -> Maybe (∃ (AList m))
-- -- -- -- -- -- -- open ⋆amgu ⦃ … ⦄ public
-- -- -- -- -- -- -- open import Category.Monad using (RawMonad)
-- -- -- -- -- -- -- import Level
-- -- -- -- -- -- -- open RawMonad (Data.Maybe.monad {Level.zero})
-- -- -- -- -- -- -- open import Relation.Binary using (IsDecEquivalence)
-- -- -- -- -- -- -- open import Relation.Nullary using (Dec; yes; no)
-- -- -- -- -- -- -- open import Data.Nat using (ℕ; _≟_)
-- -- -- -- -- -- -- open import Data.Product using () renaming (Σ to Σ₁)
-- -- -- -- -- -- -- open Σ₁ renaming (proj₁ to π₁; proj₂ to π₂)
-- -- -- -- -- -- -- open import Data.Product using (Σ)
-- -- -- -- -- -- -- open Σ
-- -- -- -- -- -- -- open import Data.Sum
-- -- -- -- -- -- -- open import Function
-- -- -- -- -- -- -- NothingForkLeft : ∀ {m l} (s1 t1 : Term m) (ρ : AList m l) (s2 t2 : Term m) →
-- -- -- -- -- -- -- Nothing⋆ $ Unifies⋆ s1 t1 [-◇⋆ sub ρ ] →
-- -- -- -- -- -- -- Nothing⋆ $ Unifies⋆ (s1 fork s2) (t1 fork t2) [-◇⋆ sub ρ ]
-- -- -- -- -- -- -- NothingForkLeft s1 t1 ρ s2 t2 nounify = No[Q◇ρ]→No[P◇ρ] No[Q◇ρ]
-- -- -- -- -- -- -- where
-- -- -- -- -- -- -- P = Unifies⋆ (s1 fork s2) (t1 fork t2)
-- -- -- -- -- -- -- Q = (Unifies⋆ s1 t1 ∧⋆ Unifies⋆ s2 t2)
-- -- -- -- -- -- -- Q⇔P : Q ⇔⋆ P
-- -- -- -- -- -- -- Q⇔P = switch⋆ P Q (Properties.fact1' {_} {s1} {s2} {t1} {t2})
-- -- -- -- -- -- -- No[Q◇ρ]→No[P◇ρ] : Nothing⋆ (Q [-◇⋆ sub ρ ]) -> Nothing⋆ (P [-◇⋆ sub ρ ])
-- -- -- -- -- -- -- No[Q◇ρ]→No[P◇ρ] = Properties.fact2⋆ (Q [-◇⋆ sub ρ ]) (P [-◇⋆ sub ρ ]) (Properties.fact5⋆ Q P (sub ρ) Q⇔P)
-- -- -- -- -- -- -- No[Q◇ρ] : Nothing⋆ (Q [-◇⋆ sub ρ ])
-- -- -- -- -- -- -- No[Q◇ρ] = failure-propagation.first⋆ (sub ρ) (Unifies⋆ s1 t1) (Unifies⋆ s2 t2) nounify
-- -- -- -- -- -- -- NothingForkRight : ∀ {m l n} (σ : AList l n)
-- -- -- -- -- -- -- (s1 s2 : Term m)
-- -- -- -- -- -- -- (t1 t2 : Term m) →
-- -- -- -- -- -- -- (ρ : AList m l) →
-- -- -- -- -- -- -- Max⋆ (Unifies⋆ s1 t1 [-◇⋆ sub ρ ]) $ sub σ →
-- -- -- -- -- -- -- Nothing⋆ $ Unifies⋆ s2 t2 [-◇⋆ sub (σ ++ ρ) ] →
-- -- -- -- -- -- -- Nothing⋆ $ Unifies⋆ (s1 fork s2) (t1 fork t2) [-◇⋆ sub ρ ]
-- -- -- -- -- -- -- NothingForkRight σ s1 s2 t1 t2 ρ a nounify = No[Q◇ρ]→No[P◇ρ]⋆ No[Q◇ρ]⋆
-- -- -- -- -- -- -- where
-- -- -- -- -- -- -- P⋆ = Unifies⋆ (s1 fork s2) (t1 fork t2)
-- -- -- -- -- -- -- Q⋆ = (Unifies⋆ s1 t1 ∧⋆ Unifies⋆ s2 t2)
-- -- -- -- -- -- -- Q⇔P⋆ : Q⋆ ⇔⋆ P⋆
-- -- -- -- -- -- -- Q⇔P⋆ = switch⋆ P⋆ Q⋆ (Properties.fact1'⋆ {_} {s1} {s2} {t1} {t2})
-- -- -- -- -- -- -- No[Q◇ρ]→No[P◇ρ]⋆ : Nothing⋆ (Q⋆ [-◇⋆ sub ρ ]) -> Nothing⋆ (P⋆ [-◇⋆ sub ρ ])
-- -- -- -- -- -- -- No[Q◇ρ]→No[P◇ρ]⋆ = Properties.fact2⋆ (Q⋆ [-◇⋆ sub ρ ]) (P⋆ [-◇⋆ sub ρ ]) (Properties.fact5⋆ Q⋆ P⋆ (sub ρ) Q⇔P⋆)
-- -- -- -- -- -- -- No[Q◇ρ]⋆ : Nothing⋆ (Q⋆ [-◇⋆ sub ρ ])
-- -- -- -- -- -- -- No[Q◇ρ]⋆ = failure-propagation.second⋆ (sub ρ) (sub σ) (Unifies⋆ s1 t1) (Unifies s2 t2) a
-- -- -- -- -- -- -- (λ f → nounify f ∘ π₂ (Unifies s2 t2) (cong (f ◃_) ∘ sym ∘ SubList.fact1 σ ρ))
-- -- -- -- -- -- -- MaxFork : ∀ {m l n n1} (s1 s2 t1 t2 : Term m)
-- -- -- -- -- -- -- (ρ : AList m l) (σ : AList l n) →
-- -- -- -- -- -- -- Max⋆ (Unifies⋆ s1 t1 [-◇⋆ sub ρ ]) $ sub σ →
-- -- -- -- -- -- -- (σ1 : AList n n1) →
-- -- -- -- -- -- -- Max⋆ (Unifies⋆ s2 t2 [-◇⋆ sub (σ ++ ρ) ]) $ sub σ1 →
-- -- -- -- -- -- -- Max⋆ (Unifies⋆ (s1 fork s2) (t1 fork t2) [-◇⋆ sub ρ ]) $ sub (σ1 ++ σ)
-- -- -- -- -- -- -- MaxFork s1 s2 t1 t2 ρ σ a σ1 b = Max[P∧Q◇ρ][σ1++σ]
-- -- -- -- -- -- -- where
-- -- -- -- -- -- -- P = Unifies s1 t1
-- -- -- -- -- -- -- Q = Unifies s2 t2
-- -- -- -- -- -- -- P∧Q = P ∧ Q
-- -- -- -- -- -- -- C = Unifies (s1 fork s2) (t1 fork t2)
-- -- -- -- -- -- -- Max[C◇ρ]⇔Max[P∧Q◇ρ] : Max (C [-◇ sub ρ ]) ⇔ Max (P∧Q [-◇ sub ρ ])
-- -- -- -- -- -- -- Max[C◇ρ]⇔Max[P∧Q◇ρ] = Max.fact (C [-◇ sub ρ ]) (P∧Q [-◇ sub ρ ]) (Properties.fact5 C P∧Q (sub ρ)
-- -- -- -- -- -- -- (Properties.fact1' {_} {s1} {s2} {t1} {t2}))
-- -- -- -- -- -- -- Max[Q◇σ++ρ]⇔Max[Q◇σ◇ρ] : Max (Q [-◇ sub (σ ++ ρ)]) ⇔ Max (Q [-◇ sub σ ◇ sub ρ ])
-- -- -- -- -- -- -- Max[Q◇σ++ρ]⇔Max[Q◇σ◇ρ] = Max.fact (Q [-◇ sub (σ ++ ρ)]) (Q [-◇ sub σ ◇ sub ρ ]) (Properties.fact6 Q (SubList.fact1 σ ρ))
-- -- -- -- -- -- -- Max[P∧Q◇ρ][σ1++σ] : π₁ (Max (C [-◇ sub ρ ])) (sub (σ1 ++ σ))
-- -- -- -- -- -- -- Max[P∧Q◇ρ][σ1++σ] = π₂ (Max (C [-◇ sub ρ ])) (≐-sym (SubList.fact1 σ1 σ))
-- -- -- -- -- -- -- (proj₂ (Max[C◇ρ]⇔Max[P∧Q◇ρ] (sub σ1 ◇ sub σ))
-- -- -- -- -- -- -- (optimist (sub ρ) (sub σ) (sub σ1) P Q (DClosed.fact1 s1 t1) a (proj₁ (Max[Q◇σ++ρ]⇔Max[Q◇σ◇ρ] (sub σ1)) b)))
-- -- -- -- -- -- -- NothingVecHead : ∀ {m l} (t₁ t₂ : Term m) (ρ : AList m l) {N} (ts₁ ts₂ : Vec (Term m) N) →
-- -- -- -- -- -- -- Nothing⋆ $ Unifies⋆ t₁ t₂ [-◇⋆ sub ρ ] →
-- -- -- -- -- -- -- Nothing⋆ $ Unifies⋆V (t₁ ∷ ts₁) (t₂ ∷ ts₂) [-◇⋆ sub ρ ]
-- -- -- -- -- -- -- NothingVecHead t₁ t₂ ρ ts₁ ts₂ nounify = No[Q◇ρ]→No[P◇ρ] No[Q◇ρ]
-- -- -- -- -- -- -- where
-- -- -- -- -- -- -- P = Unifies⋆V (t₁ ∷ ts₁) (t₂ ∷ ts₂)
-- -- -- -- -- -- -- Q = (Unifies⋆ t₁ t₂ ∧⋆ Unifies⋆V ts₁ ts₂)
-- -- -- -- -- -- -- Q⇔P : Q ⇔⋆ P
-- -- -- -- -- -- -- Q⇔P = switch⋆ P Q (Properties.fact1'V {_} {t₁} {t₂} {_} {ts₁} {ts₂})
-- -- -- -- -- -- -- No[Q◇ρ]→No[P◇ρ] : Nothing⋆ (Q [-◇⋆ sub ρ ]) -> Nothing⋆ (P [-◇⋆ sub ρ ])
-- -- -- -- -- -- -- No[Q◇ρ]→No[P◇ρ] = Properties.fact2⋆ (Q [-◇⋆ sub ρ ]) (P [-◇⋆ sub ρ ]) (Properties.fact5⋆ Q P (sub ρ) Q⇔P)
-- -- -- -- -- -- -- No[Q◇ρ] : Nothing⋆ (Q [-◇⋆ sub ρ ])
-- -- -- -- -- -- -- No[Q◇ρ] = failure-propagation.first⋆ (sub ρ) (Unifies⋆ t₁ t₂) (Unifies⋆V ts₁ ts₂) nounify
-- -- -- -- -- -- -- NothingVecTail : ∀ {m l n} (σ : AList l n)
-- -- -- -- -- -- -- (t₁ t₂ : Term m)
-- -- -- -- -- -- -- {N}
-- -- -- -- -- -- -- (ts₁ ts₂ : Vec (Term m) N) →
-- -- -- -- -- -- -- (ρ : AList m l) →
-- -- -- -- -- -- -- Max⋆ (Unifies⋆ t₁ t₂ [-◇⋆ sub ρ ]) $ sub σ →
-- -- -- -- -- -- -- Nothing⋆ $ Unifies⋆V ts₁ ts₂ [-◇⋆ sub (σ ++ ρ) ] →
-- -- -- -- -- -- -- Nothing⋆ $ Unifies⋆V (t₁ ∷ ts₁) (t₂ ∷ ts₂) [-◇⋆ sub ρ ]
-- -- -- -- -- -- -- NothingVecTail σ t₁ t₂ ts₁ ts₂ ρ a nounify = No[Q◇ρ]→No[P◇ρ]⋆ No[Q◇ρ]⋆
-- -- -- -- -- -- -- where
-- -- -- -- -- -- -- P⋆ = Unifies⋆V (t₁ ∷ ts₁) (t₂ ∷ ts₂)
-- -- -- -- -- -- -- Q⋆ = (Unifies⋆ t₁ t₂ ∧⋆ Unifies⋆V ts₁ ts₂)
-- -- -- -- -- -- -- Q⇔P⋆ : Q⋆ ⇔⋆ P⋆
-- -- -- -- -- -- -- Q⇔P⋆ = switch⋆ P⋆ Q⋆ (Properties.fact1'V {_} {t₁} {t₂} {_} {ts₁} {ts₂})
-- -- -- -- -- -- -- -- Q⇔P⋆ = switch⋆ P⋆ Q⋆ (Properties.fact1'⋆ {_} {s1} {s2} {t1} {t2})
-- -- -- -- -- -- -- No[Q◇ρ]→No[P◇ρ]⋆ : Nothing⋆ (Q⋆ [-◇⋆ sub ρ ]) -> Nothing⋆ (P⋆ [-◇⋆ sub ρ ])
-- -- -- -- -- -- -- No[Q◇ρ]→No[P◇ρ]⋆ = Properties.fact2⋆ (Q⋆ [-◇⋆ sub ρ ]) (P⋆ [-◇⋆ sub ρ ]) (Properties.fact5⋆ Q⋆ P⋆ (sub ρ) Q⇔P⋆)
-- -- -- -- -- -- -- No[Q◇ρ]⋆ : Nothing⋆ (Q⋆ [-◇⋆ sub ρ ])
-- -- -- -- -- -- -- No[Q◇ρ]⋆ = failure-propagation.second⋆ (sub ρ) (sub σ) (Unifies⋆ t₁ t₂) (UnifiesV ts₁ ts₂) a
-- -- -- -- -- -- -- (λ f → nounify f ∘ π₂ (UnifiesV ts₁ ts₂) (cong (f ◃_) ∘ sym ∘ SubList.fact1 σ ρ))
-- -- -- -- -- -- -- MaxVec : ∀ {m l n n1} (t₁ t₂ : Term m) {N} (ts₁ ts₂ : Vec (Term m) N)
-- -- -- -- -- -- -- (ρ : AList m l) (σ : AList l n) →
-- -- -- -- -- -- -- Max⋆ (Unifies⋆ t₁ t₂ [-◇⋆ sub ρ ]) $ sub σ →
-- -- -- -- -- -- -- (σ1 : AList n n1) →
-- -- -- -- -- -- -- Max⋆ (Unifies⋆V ts₁ ts₂ [-◇⋆ sub (σ ++ ρ) ]) $ sub σ1 →
-- -- -- -- -- -- -- Max⋆ (Unifies⋆V (t₁ ∷ ts₁) (t₂ ∷ ts₂) [-◇⋆ sub ρ ]) $ sub (σ1 ++ σ)
-- -- -- -- -- -- -- MaxVec t₁ t₂ ts₁ ts₂ ρ σ a σ1 b = Max[P∧Q◇ρ][σ1++σ]
-- -- -- -- -- -- -- where
-- -- -- -- -- -- -- P = Unifies t₁ t₂
-- -- -- -- -- -- -- Q = UnifiesV ts₁ ts₂
-- -- -- -- -- -- -- P∧Q = P ∧ Q
-- -- -- -- -- -- -- C = UnifiesV (t₁ ∷ ts₁) (t₂ ∷ ts₂)
-- -- -- -- -- -- -- Max[C◇ρ]⇔Max[P∧Q◇ρ] : Max (C [-◇ sub ρ ]) ⇔ Max (P∧Q [-◇ sub ρ ])
-- -- -- -- -- -- -- Max[C◇ρ]⇔Max[P∧Q◇ρ] = Max.fact (C [-◇ sub ρ ]) (P∧Q [-◇ sub ρ ]) (Properties.fact5 C P∧Q (sub ρ)
-- -- -- -- -- -- -- (Properties.fact1'V {_} {t₁} {t₂} {_} {ts₁} {ts₂}))
-- -- -- -- -- -- -- Max[Q◇σ++ρ]⇔Max[Q◇σ◇ρ] : Max (Q [-◇ sub (σ ++ ρ)]) ⇔ Max (Q [-◇ sub σ ◇ sub ρ ])
-- -- -- -- -- -- -- Max[Q◇σ++ρ]⇔Max[Q◇σ◇ρ] = Max.fact (Q [-◇ sub (σ ++ ρ)]) (Q [-◇ sub σ ◇ sub ρ ]) (Properties.fact6 Q (SubList.fact1 σ ρ))
-- -- -- -- -- -- -- Max[P∧Q◇ρ][σ1++σ] : π₁ (Max (C [-◇ sub ρ ])) (sub (σ1 ++ σ))
-- -- -- -- -- -- -- Max[P∧Q◇ρ][σ1++σ] = π₂ (Max (C [-◇ sub ρ ])) (≐-sym (SubList.fact1 σ1 σ))
-- -- -- -- -- -- -- (proj₂ (Max[C◇ρ]⇔Max[P∧Q◇ρ] (sub σ1 ◇ sub σ))
-- -- -- -- -- -- -- (optimist (sub ρ) (sub σ) (sub σ1) P Q (DClosed.fact1 t₁ t₂) a (proj₁ (Max[Q◇σ++ρ]⇔Max[Q◇σ◇ρ] (sub σ1)) b)))
-- -- -- -- -- -- -- NothingFor→NothingComposition : ∀ {m l} (s t : Term (suc m)) (ρ : AList m l)
-- -- -- -- -- -- -- (r : Term m) (z : Fin (suc m)) →
-- -- -- -- -- -- -- Nothing⋆ (Unifies⋆ ((r for z) ◃ s) ((r for z) ◃ t) [-◇⋆ sub ρ ]) →
-- -- -- -- -- -- -- Nothing⋆ (Unifies⋆ s t [-◇⋆ sub (ρ asnoc r / z) ])
-- -- -- -- -- -- -- NothingFor→NothingComposition s t ρ r z nounify = NoQ→NoP nounify
-- -- -- -- -- -- -- where
-- -- -- -- -- -- -- P = Unifies s t [-◇ sub (ρ asnoc r / z) ]
-- -- -- -- -- -- -- Q = Unifies ((r for z) ◃ s) ((r for z) ◃ t) [-◇ sub ρ ]
-- -- -- -- -- -- -- NoQ→NoP : Nothing Q → Nothing P
-- -- -- -- -- -- -- NoQ→NoP = Properties.fact2 Q P (switch P Q (step-prop s t ρ r z))
-- -- -- -- -- -- -- MaxFor→MaxComposition : ∀ {m l n} (s t : Term (suc m)) (ρ : AList m l)
-- -- -- -- -- -- -- (r : Term m) (z : Fin (suc m)) (σ : AList l n) →
-- -- -- -- -- -- -- Max⋆ (Unifies⋆ ((r for z) ◃ s) ((r for z) ◃ t) [-◇⋆ sub ρ ]) $ sub σ →
-- -- -- -- -- -- -- Max⋆ (Unifies⋆ s t [-◇⋆ sub (ρ asnoc r / z) ]) $ sub σ
-- -- -- -- -- -- -- MaxFor→MaxComposition s t ρ r z σ a = proj₂ (MaxP⇔MaxQ (sub σ)) a
-- -- -- -- -- -- -- where
-- -- -- -- -- -- -- P = Unifies s t [-◇ sub (ρ asnoc r / z) ]
-- -- -- -- -- -- -- Q = Unifies ((r for z) ◃ s) ((r for z) ◃ t) [-◇ sub ρ ]
-- -- -- -- -- -- -- MaxP⇔MaxQ : Max P ⇔ Max Q
-- -- -- -- -- -- -- MaxP⇔MaxQ = Max.fact P Q (step-prop s t ρ r z)
-- -- -- -- -- -- -- module _ ⦃ isDecEquivalenceA : IsDecEquivalence (_≡_ {A = FunctionName}) ⦄ where
-- -- -- -- -- -- -- open IsDecEquivalence isDecEquivalenceA using () renaming (_≟_ to _≟F_)
-- -- -- -- -- -- -- mutual
-- -- -- -- -- -- -- instance ⋆amguTerm : ⋆amgu Term
-- -- -- -- -- -- -- ⋆amgu.amgu ⋆amguTerm leaf leaf acc = just acc
-- -- -- -- -- -- -- ⋆amgu.amgu ⋆amguTerm leaf (function _ _) acc = nothing
-- -- -- -- -- -- -- ⋆amgu.amgu ⋆amguTerm leaf (s' fork t') acc = nothing
-- -- -- -- -- -- -- ⋆amgu.amgu ⋆amguTerm (s' fork t') leaf acc = nothing
-- -- -- -- -- -- -- ⋆amgu.amgu ⋆amguTerm (s' fork t') (function _ _) acc = nothing
-- -- -- -- -- -- -- ⋆amgu.amgu ⋆amguTerm (s1 fork s2) (t1 fork t2) acc =
-- -- -- -- -- -- -- amgu s2 t2 =<< amgu s1 t1 acc
-- -- -- -- -- -- -- ⋆amgu.amgu ⋆amguTerm (function fn₁ ts₁) leaf acc = nothing
-- -- -- -- -- -- -- ⋆amgu.amgu ⋆amguTerm (function fn₁ {n₁} ts₁) (function fn₂ {n₂} ts₂) acc
-- -- -- -- -- -- -- with fn₁ ≟F fn₂
-- -- -- -- -- -- -- … | no _ = nothing
-- -- -- -- -- -- -- … | yes _ with n₁ ≟ n₂
-- -- -- -- -- -- -- … | no _ = nothing
-- -- -- -- -- -- -- … | yes refl = amgu ts₁ ts₂ acc
-- -- -- -- -- -- -- ⋆amgu.amgu ⋆amguTerm (function fn₁ ts₁) (_ fork _) acc = nothing
-- -- -- -- -- -- -- ⋆amgu.amgu ⋆amguTerm (i x) (i y) (m , anil) = just (flexFlex x y)
-- -- -- -- -- -- -- ⋆amgu.amgu ⋆amguTerm (i x) t (m , anil) = flexRigid x t
-- -- -- -- -- -- -- ⋆amgu.amgu ⋆amguTerm t (i x) (m , anil) = flexRigid x t
-- -- -- -- -- -- -- ⋆amgu.amgu ⋆amguTerm s t (n , σ asnoc r / z) =
-- -- -- -- -- -- -- (λ σ -> σ ∃asnoc r / z) <$>
-- -- -- -- -- -- -- amgu ((r for z) ◃ s) ((r for z) ◃ t) (n , σ)
-- -- -- -- -- -- -- instance ⋆amguVecTerm : ∀ {N} → ⋆amgu (flip Vec N ∘ Term)
-- -- -- -- -- -- -- ⋆amgu.amgu ⋆amguVecTerm [] [] acc = just acc
-- -- -- -- -- -- -- ⋆amgu.amgu ⋆amguVecTerm (t₁ ∷ t₁s) (t₂ ∷ t₂s) acc = amgu t₁s t₂s =<< amgu t₁ t₂ acc
-- -- -- -- -- -- -- mgu : ∀ {m} -> (s t : Term m) -> Maybe (∃ (AList m))
-- -- -- -- -- -- -- mgu {m} s t = amgu s t (m , anil)
-- -- -- -- -- -- -- mutual
-- -- -- -- -- -- -- -- We use a view so that we need to handle fewer cases in the main proof
-- -- -- -- -- -- -- data AmguT : {m : ℕ} -> (s t : Term m) -> ∃ (AList m) -> Maybe (∃ (AList m)) -> Set where
-- -- -- -- -- -- -- Flip : ∀ {m s t acc} -> amgu t s acc ≡ amgu s t acc ->
-- -- -- -- -- -- -- AmguT {m} t s acc (amgu t s acc) -> AmguT s t acc (amgu s t acc)
-- -- -- -- -- -- -- leaf-leaf : ∀ {m acc} -> AmguT {m} leaf leaf acc (just acc)
-- -- -- -- -- -- -- fn-name : ∀ {m fn₁ fn₂ N₁ N₂ acc} {ts₁ : Vec (Term m) N₁} {ts₂ : Vec (Term m) N₂} →
-- -- -- -- -- -- -- fn₁ ≢ fn₂ →
-- -- -- -- -- -- -- AmguT {m} (function fn₁ ts₁)
-- -- -- -- -- -- -- (function fn₂ ts₂)
-- -- -- -- -- -- -- acc nothing
-- -- -- -- -- -- -- fn-size : ∀ {m fn₁ fn₂ N₁ N₂ acc} {ts₁ : Vec (Term m) N₁} {ts₂ : Vec (Term m) N₂} →
-- -- -- -- -- -- -- N₁ ≢ N₂ →
-- -- -- -- -- -- -- AmguT {m} (function fn₁ ts₁)
-- -- -- -- -- -- -- (function fn₂ ts₂)
-- -- -- -- -- -- -- acc nothing
-- -- -- -- -- -- -- fn-fn : ∀ {m fn N acc} {ts₁ ts₂ : Vec (Term m) N} →
-- -- -- -- -- -- -- AmguT {m} (function fn ts₁)
-- -- -- -- -- -- -- (function fn ts₂)
-- -- -- -- -- -- -- acc (amgu ts₁ ts₂ acc)
-- -- -- -- -- -- -- leaf-fork : ∀ {m s t acc} -> AmguT {m} leaf (s fork t) acc nothing
-- -- -- -- -- -- -- leaf-fn : ∀ {m fn N} {ts : Vec (Term _) N} {acc} -> AmguT {m} leaf (function fn ts) acc nothing
-- -- -- -- -- -- -- fork-fn : ∀ {m s t fn N} {ts : Vec (Term _) N} {acc} -> AmguT {m} (s fork t) (function fn ts) acc nothing
-- -- -- -- -- -- -- fork-fork : ∀ {m s1 s2 t1 t2 acc} -> AmguT {m} (s1 fork s2) (t1 fork t2) acc (amgu s2 t2 =<< amgu s1 t1 acc)
-- -- -- -- -- -- -- var-var : ∀ {m x y} -> AmguT (i x) (i y) (m , anil) (just (flexFlex x y))
-- -- -- -- -- -- -- var-t : ∀ {m x t} -> i x ≢ t -> AmguT (i x) t (m , anil) (flexRigid x t)
-- -- -- -- -- -- -- s-t : ∀{m s t n σ r z} -> AmguT {suc m} s t (n , σ asnoc r / z) ((λ σ -> σ ∃asnoc r / z) <$>
-- -- -- -- -- -- -- amgu ((r for z) ◃ s) ((r for z) ◃ t) (n , σ))
-- -- -- -- -- -- -- data AmguTV : {m : ℕ} -> ∀ {N} (ss ts : Vec (Term m) N) -> ∃ (AList m) -> Maybe (∃ (AList m)) -> Set where
-- -- -- -- -- -- -- fn0-fn0 : ∀ {m acc} →
-- -- -- -- -- -- -- AmguTV {m} ([])
-- -- -- -- -- -- -- ([])
-- -- -- -- -- -- -- acc (just acc)
-- -- -- -- -- -- -- fns-fns : ∀ {m N acc} {t₁ t₂ : Term m} {ts₁ ts₂ : Vec (Term m) N} →
-- -- -- -- -- -- -- AmguTV {m} ((t₁ ∷ ts₁))
-- -- -- -- -- -- -- ((t₂ ∷ ts₂))
-- -- -- -- -- -- -- acc (amgu ts₁ ts₂ =<< amgu t₁ t₂ acc)
-- -- -- -- -- -- -- view : ∀ {m : ℕ} -> (s t : Term m) -> (acc : ∃ (AList m)) -> AmguT s t acc (amgu s t acc)
-- -- -- -- -- -- -- view leaf leaf acc = leaf-leaf
-- -- -- -- -- -- -- view leaf (s fork t) acc = leaf-fork
-- -- -- -- -- -- -- view (s fork t) leaf acc = Flip refl leaf-fork
-- -- -- -- -- -- -- view (s1 fork s2) (t1 fork t2) acc = fork-fork
-- -- -- -- -- -- -- view (function fn₁ {n₁} ts₁) (function fn₂ {n₂} ts₂) acc with
-- -- -- -- -- -- -- fn₁ ≟F fn₂
-- -- -- -- -- -- -- … | no neq = fn-name neq
-- -- -- -- -- -- -- … | yes refl with n₁ ≟ n₂
-- -- -- -- -- -- -- … | yes refl = fn-fn
-- -- -- -- -- -- -- … | no neq = fn-size neq
-- -- -- -- -- -- -- view leaf (function fn ts) acc = leaf-fn
-- -- -- -- -- -- -- view (function fn ts) leaf acc = Flip refl leaf-fn
-- -- -- -- -- -- -- view (function fn ts) (_ fork _) acc = Flip refl fork-fn
-- -- -- -- -- -- -- view (s fork t) (function fn ts) acc = fork-fn
-- -- -- -- -- -- -- view (i x) (i y) (m , anil) = var-var
-- -- -- -- -- -- -- view (i x) leaf (m , anil) = var-t (λ ())
-- -- -- -- -- -- -- view (i x) (s fork t) (m , anil) = var-t (λ ())
-- -- -- -- -- -- -- view (i x) (function fn ts) (m , anil) = var-t (λ ())
-- -- -- -- -- -- -- view leaf (i x) (m , anil) = Flip refl (var-t (λ ()))
-- -- -- -- -- -- -- view (s fork t) (i x) (m , anil) = Flip refl (var-t (λ ()))
-- -- -- -- -- -- -- view (function fn ts) (i x) (m , anil) = Flip refl (var-t (λ ()))
-- -- -- -- -- -- -- view (i x) (i x') (n , σ asnoc r / z) = s-t
-- -- -- -- -- -- -- view (i x) leaf (n , σ asnoc r / z) = s-t
-- -- -- -- -- -- -- view (i x) (s fork t) (n , σ asnoc r / z) = s-t
-- -- -- -- -- -- -- view leaf (i x) (n , σ asnoc r / z) = s-t
-- -- -- -- -- -- -- view (s fork t) (i x) (n , σ asnoc r / z) = s-t
-- -- -- -- -- -- -- view (function fn ts) (i x) (n , σ asnoc r / z) = s-t
-- -- -- -- -- -- -- view (i x) (function fn ts) (n , σ asnoc r / z) = s-t
-- -- -- -- -- -- -- viewV : ∀ {m : ℕ} {N} -> (ss ts : Vec (Term m) N) -> (acc : ∃ (AList m)) -> AmguTV ss ts acc (amgu ss ts acc)
-- -- -- -- -- -- -- viewV [] [] acc = fn0-fn0
-- -- -- -- -- -- -- viewV (t ∷ ts₁) (t₂ ∷ ts₂) acc = fns-fns
-- -- -- -- -- -- -- amgu-Correctness : {m : ℕ} -> (s t : Term m) -> ∃ (AList m) -> Set
-- -- -- -- -- -- -- amgu-Correctness s t (l , ρ) =
-- -- -- -- -- -- -- (∃ λ n → ∃ λ σ → π₁ (Max (Unifies s t [-◇ sub ρ ])) (sub σ) × amgu s t (l , ρ) ≡ just (n , σ ++ ρ ))
-- -- -- -- -- -- -- ⊎ (Nothing ((Unifies s t) [-◇ sub ρ ]) × amgu s t (l , ρ) ≡ nothing)
-- -- -- -- -- -- -- amgu-Correctness⋆ : {m : ℕ} -> (s t : Term m) -> ∃ (AList m) -> Set
-- -- -- -- -- -- -- amgu-Correctness⋆ s t (l , ρ) =
-- -- -- -- -- -- -- (∃ λ n → ∃ λ σ → π₁ (Max (Unifies s t [-◇ sub ρ ])) (sub σ) × amgu s t (l , ρ) ≡ just (n , σ ++ ρ ))
-- -- -- -- -- -- -- ⊎ (Nothing ((Unifies s t) [-◇ sub ρ ]) × amgu s t (l , ρ) ≡ nothing)
-- -- -- -- -- -- -- amgu-Ccomm : ∀ {m} s t acc -> amgu {m = m} s t acc ≡ amgu t s acc -> amgu-Correctness s t acc -> amgu-Correctness t s acc
-- -- -- -- -- -- -- amgu-Ccomm s t (l , ρ) st≡ts = lemma
-- -- -- -- -- -- -- where
-- -- -- -- -- -- -- Unst = (Unifies s t) [-◇ sub ρ ]
-- -- -- -- -- -- -- Unts = (Unifies t s) [-◇ sub ρ ]
-- -- -- -- -- -- -- Unst⇔Unts : ((Unifies s t) [-◇ sub ρ ]) ⇔ ((Unifies t s) [-◇ sub ρ ])
-- -- -- -- -- -- -- Unst⇔Unts = Properties.fact5 (Unifies s t) (Unifies t s) (sub ρ) (Properties.fact1 {_} {s} {t})
-- -- -- -- -- -- -- lemma : amgu-Correctness s t (l , ρ) -> amgu-Correctness t s (l , ρ)
-- -- -- -- -- -- -- lemma (inj₁ (n , σ , MaxUnst , amgu≡just)) =
-- -- -- -- -- -- -- inj₁ (n , σ , proj₁ (Max.fact Unst Unts Unst⇔Unts (sub σ)) MaxUnst , trans (sym st≡ts) amgu≡just)
-- -- -- -- -- -- -- lemma (inj₂ (NoUnst , amgu≡nothing)) =
-- -- -- -- -- -- -- inj₂ ((λ {_} → Properties.fact2 Unst Unts Unst⇔Unts NoUnst) , trans (sym st≡ts) amgu≡nothing)
-- -- -- -- -- -- -- amgu-Ccomm⋆ : ∀ {m} s t acc -> amgu {m = m} s t acc ≡ amgu t s acc -> amgu-Correctness⋆ s t acc -> amgu-Correctness⋆ t s acc
-- -- -- -- -- -- -- amgu-Ccomm⋆ s t (l , ρ) st≡ts = lemma
-- -- -- -- -- -- -- where
-- -- -- -- -- -- -- Unst = (Unifies s t) [-◇ sub ρ ]
-- -- -- -- -- -- -- Unts = (Unifies t s) [-◇ sub ρ ]
-- -- -- -- -- -- -- Unst⇔Unts : ((Unifies s t) [-◇ sub ρ ]) ⇔ ((Unifies t s) [-◇ sub ρ ])
-- -- -- -- -- -- -- Unst⇔Unts = Properties.fact5 (Unifies s t) (Unifies t s) (sub ρ) (Properties.fact1 {_} {s} {t})
-- -- -- -- -- -- -- lemma : amgu-Correctness s t (l , ρ) -> amgu-Correctness t s (l , ρ)
-- -- -- -- -- -- -- lemma (inj₁ (n , σ , MaxUnst , amgu≡just)) =
-- -- -- -- -- -- -- inj₁ (n , σ , proj₁ (Max.fact Unst Unts Unst⇔Unts (sub σ)) MaxUnst , trans (sym st≡ts) amgu≡just)
-- -- -- -- -- -- -- lemma (inj₂ (NoUnst , amgu≡nothing)) =
-- -- -- -- -- -- -- inj₂ ((λ {_} → Properties.fact2 Unst Unts Unst⇔Unts NoUnst) , trans (sym st≡ts) amgu≡nothing)
-- -- -- -- -- -- -- mutual
-- -- -- -- -- -- -- amguV-c : ∀ {m N} {ss ts : Vec (Term m) N} {l ρ} -> AmguTV ss ts (l , ρ) (amgu ss ts (l , ρ)) ->
-- -- -- -- -- -- -- (∃ λ n → ∃ λ σ → Max⋆ (Unifies⋆V ss ts [-◇⋆ sub ρ ]) (sub σ) × amgu {m = m} ss ts (l , ρ) ≡ just (n , σ ++ ρ ))
-- -- -- -- -- -- -- ⊎ (Nothing⋆ (Unifies⋆V ss ts [-◇⋆ sub ρ ]) × amgu {m = m} ss ts (l , ρ) ≡ nothing)
-- -- -- -- -- -- -- amguV-c {m} {N} {ss} {ts} {l} {ρ} amg with amgu ss ts (l , ρ)
-- -- -- -- -- -- -- amguV-c {m} {0} {.[]} {.[]} {l} {ρ} fn0-fn0 | .(just (l , ρ)) = inj₁ (_ , anil , trivial-problemV {_} {_} {_} {[]} {sub ρ} , cong (just ∘ _,_ l) (sym (SubList.anil-id-l ρ)))
-- -- -- -- -- -- -- amguV-c {m} {.(suc _)} {(t₁ ∷ ts₁)} {(t₂ ∷ ts₂)} {l} {ρ} fns-fns | _ with amgu t₁ t₂ (l , ρ) | amgu-c $ view t₁ t₂ (l , ρ)
-- -- -- -- -- -- -- amguV-c {m} {.(suc _)} {(t₁ ∷ ts₁)} {(t₂ ∷ ts₂)} {l} {ρ} fns-fns | _ | am | inj₂ (nounify , refl) = inj₂ ((λ {_} → NothingVecHead t₁ t₂ ρ _ _ nounify) , refl)
-- -- -- -- -- -- -- amguV-c {m} {.(suc _)} {(t₁ ∷ ts₁)} {(t₂ ∷ ts₂)} {l} {ρ} fns-fns | _ | am | inj₁ (n , σ , a , refl)
-- -- -- -- -- -- -- with amgu ts₁ ts₂ (n , σ ++ ρ) | amguV-c (viewV (ts₁) (ts₂) (n , (σ ++ ρ)))
-- -- -- -- -- -- -- … | _ | inj₂ (nounify , refl) = inj₂ ((λ {_} → NothingVecTail σ t₁ t₂ _ _ ρ a nounify) , refl)
-- -- -- -- -- -- -- … | _ | inj₁ (n1 , σ1 , a1 , refl) = inj₁ (n1 , σ1 ++ σ , MaxVec t₁ t₂ _ _ ρ σ a σ1 a1 , cong (λ σ -> just (n1 , σ)) (++-assoc σ1 σ ρ))
-- -- -- -- -- -- -- amgu-c : ∀ {m s t l ρ} -> AmguT s t (l , ρ) (amgu s t (l , ρ)) ->
-- -- -- -- -- -- -- (∃ λ n → ∃ λ σ → Max⋆ (Unifies⋆ s t [-◇⋆ sub ρ ]) (sub σ) × amgu {m = m} s t (l , ρ) ≡ just (n , σ ++ ρ ))
-- -- -- -- -- -- -- ⊎ (Nothing⋆ (Unifies⋆ s t [-◇⋆ sub ρ ]) × amgu {m = m} s t (l , ρ) ≡ nothing)
-- -- -- -- -- -- -- amgu-c {m} {s} {t} {l} {ρ} amg with amgu s t (l , ρ)
-- -- -- -- -- -- -- amgu-c {l = l} {ρ} leaf-leaf | ._
-- -- -- -- -- -- -- = inj₁ (l , anil , trivial-problem {_} {_} {leaf} {sub ρ} , cong (λ x -> just (l , x)) (sym (SubList.anil-id-l ρ)) )
-- -- -- -- -- -- -- amgu-c (fn-name neq) | _ = inj₂ ((λ f x → neq (Term-function-inj-FunctionName x)) , refl)
-- -- -- -- -- -- -- amgu-c (fn-size neq) | _ = inj₂ ((λ f x → neq (Term-function-inj-VecSize x)) , refl)
-- -- -- -- -- -- -- amgu-c {s = function fn ts₁} {t = function .fn ts₂} {l = l} {ρ = ρ} fn-fn | _ with amgu ts₁ ts₂ | amguV-c (viewV ts₁ ts₂ (l , ρ))
-- -- -- -- -- -- -- … | _ | inj₂ (nounify , refl!) rewrite refl! = inj₂ ((λ {_} f feq → nounify f (Term-function-inj-Vector feq)) , refl)
-- -- -- -- -- -- -- … | _ | inj₁ (n , σ , (b , c) , refl!) rewrite refl! = inj₁ (_ , _ , ((cong (function fn) b) , (λ {_} f' feq → c f' (Term-function-inj-Vector feq))) , refl )
-- -- -- -- -- -- -- amgu-c leaf-fork | .nothing = inj₂ ((λ _ () ) , refl)
-- -- -- -- -- -- -- amgu-c leaf-fn | _ = inj₂ ((λ _ () ) , refl)
-- -- -- -- -- -- -- amgu-c fork-fn | _ = inj₂ ((λ _ () ) , refl)
-- -- -- -- -- -- -- amgu-c {m} {s1 fork s2} {t1 fork t2} {l} {ρ} fork-fork | ._
-- -- -- -- -- -- -- with amgu s1 t1 (l , ρ) | amgu-c $ view s1 t1 (l , ρ)
-- -- -- -- -- -- -- … | .nothing | inj₂ (nounify , refl) = inj₂ ((λ {_} -> NothingForkLeft s1 t1 ρ s2 t2 nounify) , refl)
-- -- -- -- -- -- -- … | .(just (n , σ ++ ρ)) | inj₁ (n , σ , a , refl)
-- -- -- -- -- -- -- with amgu s2 t2 (n , σ ++ ρ) | amgu-c (view s2 t2 (n , (σ ++ ρ)))
-- -- -- -- -- -- -- … | .nothing | inj₂ (nounify , refl) = inj₂ ( (λ {_} -> NothingForkRight σ s1 s2 t1 t2 ρ a nounify) , refl)
-- -- -- -- -- -- -- … | .(just (n1 , σ1 ++ (σ ++ ρ))) | inj₁ (n1 , σ1 , b , refl)
-- -- -- -- -- -- -- = inj₁ (n1 , σ1 ++ σ , MaxFork s1 s2 t1 t2 ρ σ a σ1 b , cong (λ σ -> just (n1 , σ)) (++-assoc σ1 σ ρ))
-- -- -- -- -- -- -- amgu-c {suc l} {i x} {i y} (var-var) | .(just (flexFlex x y))
-- -- -- -- -- -- -- with thick? x y | Thick.fact1 x y (thick? x y) refl
-- -- -- -- -- -- -- … | .(just y') | inj₂ (y' , thinxy'≡y , refl )
-- -- -- -- -- -- -- = inj₁ (l , anil asnoc i y' / x , var-elim-i-≡ x (i y) (sym (cong i thinxy'≡y)) , refl )
-- -- -- -- -- -- -- … | .nothing | inj₁ ( x≡y , refl ) rewrite sym x≡y
-- -- -- -- -- -- -- = inj₁ (suc l , anil , trivial-problem {_} {_} {i x} {sub anil} , refl)
-- -- -- -- -- -- -- amgu-c {suc l} {i x} {t} (var-t ix≢t) | .(flexRigid x t)
-- -- -- -- -- -- -- with check x t | check-prop x t
-- -- -- -- -- -- -- … | .nothing | inj₂ ( ps , r , refl) = inj₂ ( (λ {_} -> NothingStep x t ix≢t ps r ) , refl)
-- -- -- -- -- -- -- … | .(just t') | inj₁ (t' , r , refl) = inj₁ ( l , anil asnoc t' / x , var-elim-i-≡ x t r , refl )
-- -- -- -- -- -- -- amgu-c {suc m} {s} {t} {l} {ρ asnoc r / z} s-t
-- -- -- -- -- -- -- | .((λ x' → x' ∃asnoc r / z) <$>
-- -- -- -- -- -- -- (amgu ((r for z) ◃ s) ((r for z) ◃ t) (l , ρ)))
-- -- -- -- -- -- -- with amgu-c (view ((r for z) ◃ s) ((r for z) ◃ t) (l , ρ))
-- -- -- -- -- -- -- … | inj₂ (nounify , ra) = inj₂ ( (λ {_} -> NothingFor→NothingComposition s t ρ r z nounify) , cong (_<$>_ (λ x' → x' ∃asnoc r / z)) ra )
-- -- -- -- -- -- -- … | inj₁ (n , σ , a , ra) = inj₁ (n , σ , MaxFor→MaxComposition s t ρ r z σ a , cong (_<$>_ (λ x' → x' ∃asnoc r / z)) ra)
-- -- -- -- -- -- -- amgu-c {m} {s} {t} {l} {ρ} (Flip amguts≡amgust amguts) | ._ = amgu-Ccomm⋆ t s (l , ρ) amguts≡amgust (amgu-c amguts)
-- -- -- -- -- -- -- amgu-c {zero} {i ()} _ | _
-- -- -- -- -- -- -- mgu-c : ∀ {m} (s t : Term m) ->
-- -- -- -- -- -- -- (∃ λ n → ∃ λ σ → (Max⋆ (Unifies⋆ s t)) (sub σ) × mgu s t ≡ just (n , σ))
-- -- -- -- -- -- -- ⊎ (Nothing⋆ (Unifies⋆ s t) × mgu s t ≡ nothing)
-- -- -- -- -- -- -- mgu-c {m} s t = amgu-c (view s t (m , anil))
-- -- -- -- -- -- -- unify : ∀ {m} (s t : Term m) ->
-- -- -- -- -- -- -- (∃ λ n → ∃ λ (σ : AList m n) → Max⋆ (Unifies⋆ s t) $ sub σ)
-- -- -- -- -- -- -- ⊎ Nothing⋆ (Unifies⋆ s t)
-- -- -- -- -- -- -- unify {m} s t with amgu-c (view s t (m , anil))
-- -- -- -- -- -- -- unify {m} s₁ t | inj₁ (proj₃ , proj₄ , proj₅ , proj₆) = inj₁ (proj₃ , proj₄ , proj₅)
-- -- -- -- -- -- -- unify {m} s t | inj₂ (proj₃ , _) = inj₂ proj₃
-- -- -- -- -- -- -- unifyV : ∀ {m N} (s t : Vec (Term m) N) ->
-- -- -- -- -- -- -- (∃ λ n → ∃ λ (σ : AList m n) → Max⋆ (Unifies⋆V s t) $ sub σ)
-- -- -- -- -- -- -- ⊎ Nothing⋆ (Unifies⋆V s t)
-- -- -- -- -- -- -- unifyV {m} {N} s t with amguV-c (viewV s t (m , anil))
-- -- -- -- -- -- -- … | inj₁ (proj₃ , proj₄ , proj₅ , proj₆) = inj₁ (proj₃ , proj₄ , proj₅)
-- -- -- -- -- -- -- … | inj₂ (proj₃ , _) = inj₂ proj₃
-- -- -- -- -- -- -- open import Oscar.Data.Permutation
-- -- -- -- -- -- -- unifyWith : ∀ {m N} (p q : Term m) (X Y : Vec (Term m) N) →
-- -- -- -- -- -- -- (∃ λ X* → X* ≡ordering' X × ∃ λ n → ∃ λ (σ : AList m n) → Max⋆ (Unifies⋆V (p ∷ X*) (q ∷ Y)) $ sub σ)
-- -- -- -- -- -- -- ⊎
-- -- -- -- -- -- -- (∀ X* → X* ≡ordering' X → Nothing⋆ (Unifies⋆V (p ∷ X*) (q ∷ Y)))
-- -- -- -- -- -- -- unifyWith p q X Y = {!!}
| {
"alphanum_fraction": 0.3592898166,
"avg_line_length": 68.0575396825,
"ext": "agda",
"hexsha": "a3e076a01589982c5bd76c49ea50f20d5e84870a",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_forks_repo_licenses": [
"RSA-MD"
],
"max_forks_repo_name": "m0davis/oscar",
"max_forks_repo_path": "archive/agda-2/Oscar/Data/AList.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z",
"max_issues_repo_licenses": [
"RSA-MD"
],
"max_issues_repo_name": "m0davis/oscar",
"max_issues_repo_path": "archive/agda-2/Oscar/Data/AList.agda",
"max_line_length": 198,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_stars_repo_licenses": [
"RSA-MD"
],
"max_stars_repo_name": "m0davis/oscar",
"max_stars_repo_path": "archive/agda-2/Oscar/Data/AList.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 14227,
"size": 34301
} |
module AKS.Primality where
open import AKS.Primality.Base public
open import AKS.Primality.Properties public
| {
"alphanum_fraction": 0.8454545455,
"avg_line_length": 22,
"ext": "agda",
"hexsha": "243e64c438dfeb57aa1611fa7488f7f15d3dc69b",
"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": "ddad4c0d5f384a0219b2177461a68dae06952dde",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mckeankylej/thesis",
"max_forks_repo_path": "proofs/AKS/Primality.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde",
"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": "mckeankylej/thesis",
"max_issues_repo_path": "proofs/AKS/Primality.agda",
"max_line_length": 43,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mckeankylej/thesis",
"max_stars_repo_path": "proofs/AKS/Primality.agda",
"max_stars_repo_stars_event_max_datetime": "2020-12-01T22:38:27.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-12-01T22:38:27.000Z",
"num_tokens": 28,
"size": 110
} |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category.Core using (Category)
open import Categories.Comonad
-- Verbatim dual of Categories.Adjoint.Construction.Kleisli
module Categories.Adjoint.Construction.CoKleisli {o ℓ e} {C : Category o ℓ e} (M : Comonad C) where
open import Categories.Category.Construction.CoKleisli
open import Categories.Adjoint
open import Categories.Functor
open import Categories.Functor.Properties
open import Categories.NaturalTransformation.Core
open import Categories.NaturalTransformation.NaturalIsomorphism using (_≃_)
open import Categories.Morphism.Reasoning C
private
module C = Category C
module M = Comonad M
open M.F
open C
open HomReasoning
open Equiv
Forgetful : Functor (CoKleisli M) C
Forgetful =
record
{ F₀ = λ X → F₀ X
; F₁ = λ f → F₁ f ∘ M.δ.η _
; identity = Comonad.identityˡ M
; homomorphism = λ {X Y Z} {f g} → hom-proof {X} {Y} {Z} {f} {g}
; F-resp-≈ = λ eq → ∘-resp-≈ˡ (F-resp-≈ eq)
}
where
trihom : {X Y Z W : Obj} {f : X ⇒ Y} {g : Y ⇒ Z} {h : Z ⇒ W} → F₁ (h ∘ g ∘ f) ≈ F₁ h ∘ F₁ g ∘ F₁ f
trihom {X} {Y} {Z} {W} {f} {g} {h} = begin
F₁ (h ∘ g ∘ f) ≈⟨ homomorphism ⟩
F₁ h ∘ F₁ (g ∘ f) ≈⟨ refl⟩∘⟨ homomorphism ⟩
F₁ h ∘ F₁ g ∘ F₁ f ∎
hom-proof :
{X Y Z : Obj} {f : F₀ X ⇒ Y} {g : F₀ Y ⇒ Z} →
(F₁ (g ∘ F₁ f ∘ M.δ.η X)) ∘ M.δ.η X ≈ (F₁ g ∘ M.δ.η Y) ∘ F₁ f ∘ M.δ.η X
hom-proof {X} {Y} {Z} {f} {g} = begin
(F₁ (g ∘ F₁ f ∘ M.δ.η X)) ∘ M.δ.η X ≈⟨ pushˡ trihom ⟩
F₁ g ∘ (F₁ (F₁ f) ∘ F₁ (M.δ.η X)) ∘ M.δ.η X ≈⟨ refl⟩∘⟨ (pullʳ (sym M.assoc)) ⟩
F₁ g ∘ F₁ (F₁ f) ∘ M.δ.η (F₀ X) ∘ M.δ.η X ≈⟨ refl⟩∘⟨ pullˡ (sym (M.δ.commute f)) ⟩
F₁ g ∘ (M.δ.η Y ∘ F₁ f) ∘ M.δ.η X ≈⟨ assoc²'' ⟩
(F₁ g ∘ M.δ.η Y) ∘ F₁ f ∘ M.δ.η X ∎
Cofree : Functor C (CoKleisli M)
Cofree =
record
{ F₀ = λ X → X
; F₁ = λ f → f ∘ M.ε.η _
; identity = λ {A} → identityˡ
; homomorphism = λ {X Y Z} {f g} → hom-proof {X} {Y} {Z} {f} {g}
; F-resp-≈ = λ x → ∘-resp-≈ˡ x
}
where
hom-proof :
{X Y Z : Obj} {f : X ⇒ Y} {g : Y ⇒ Z} →
(g ∘ f) ∘ M.ε.η X ≈ (g ∘ M.ε.η Y) ∘ (F₁ (f ∘ M.ε.η X) ∘ M.δ.η X)
hom-proof {X} {Y} {Z} {f} {g} = begin
(g ∘ f) ∘ M.ε.η X ≈⟨ pullʳ (sym (M.ε.commute f)) ⟩
g ∘ M.ε.η Y ∘ F₁ f ≈⟨ sym (pullʳ (refl⟩∘⟨ elimʳ (Comonad.identityˡ M))) ⟩
(g ∘ M.ε.η Y) ∘ (F₁ f ∘ F₁ (M.ε.η X) ∘ M.δ.η X) ≈⟨ refl⟩∘⟨ pullˡ (sym homomorphism) ⟩
(g ∘ M.ε.η Y) ∘ (F₁ (f ∘ M.ε.η X) ∘ M.δ.η X) ∎
FC≃M : Forgetful ∘F Cofree ≃ M.F
FC≃M =
record
{ F⇒G = ntHelper record
{ η = λ X → F₁ C.id
; commute = λ {X Y} f → to-commute {X} {Y} f
}
; F⇐G = ntHelper record
{ η = λ X → F₁ C.id
; commute = λ {X Y} f → from-commute {X} {Y} f
}
; iso = λ X → record
{ isoˡ = elimʳ identity ○ identity
; isoʳ = elimʳ identity ○ identity
}
}
where
to-commute : {X Y : Obj} → (f : X ⇒ Y) → F₁ C.id ∘ F₁ (f ∘ M.ε.η X) ∘ M.δ.η X ≈ F₁ f ∘ F₁ C.id
to-commute {X} {Y} f = begin
F₁ C.id ∘ F₁ (f ∘ M.ε.η X) ∘ M.δ.η X ≈⟨ elimˡ identity ⟩
F₁ (f ∘ M.ε.η X) ∘ M.δ.η X ≈⟨ pushˡ homomorphism ⟩
F₁ f ∘ F₁ (M.ε.η X) ∘ M.δ.η X ≈⟨ refl⟩∘⟨ Comonad.identityˡ M ⟩
F₁ f ∘ C.id ≈⟨ refl⟩∘⟨ sym identity ⟩
F₁ f ∘ F₁ C.id ∎
from-commute : {X Y : Obj} → (f : X ⇒ Y) → F₁ C.id ∘ F₁ f ≈ (F₁ (f ∘ M.ε.η X) ∘ M.δ.η X) ∘ F₁ C.id
from-commute {X} {Y} f = begin
F₁ C.id ∘ F₁ f ≈⟨ [ M.F ]-resp-square id-comm-sym ⟩
F₁ f ∘ F₁ C.id ≈⟨ introʳ (Comonad.identityˡ M) ⟩∘⟨refl ⟩
(F₁ f ∘ F₁ (M.ε.η X) ∘ M.δ.η X) ∘ F₁ C.id ≈⟨ pullˡ (sym homomorphism) ⟩∘⟨refl ⟩
(F₁ (f ∘ M.ε.η X) ∘ M.δ.η X) ∘ F₁ C.id ∎
-- useful lemma:
FF1≈1 : {X : Obj} → F₁ (F₁ (C.id {X})) ≈ C.id
FF1≈1 {X} = begin
F₁ (F₁ (C.id {X})) ≈⟨ F-resp-≈ identity ⟩
F₁ (C.id) ≈⟨ identity ⟩
C.id ∎
Forgetful⊣Cofree : Forgetful ⊣ Cofree
Forgetful⊣Cofree =
record
{ unit = ntHelper record
{ η = λ X → F₁ C.id
; commute = λ {X Y} f → unit-commute {X} {Y} f
}
; counit = ntHelper record
{ η = M.ε.η
; commute = λ {X Y} f → counit-commute {X} {Y} f
}
; zig = λ {A} → zig-proof {A}
; zag = λ {B} → zag-proof {B}
}
where
unit-commute : ∀ {X Y : Obj} →
(f : F₀ X ⇒ Y) →
F₁ C.id ∘ F₁ f ∘ M.δ.η X ≈ ((F₁ f ∘ M.δ.η X) ∘ M.ε.η (F₀ X)) ∘ F₁ (F₁ C.id) ∘ M.δ.η X
unit-commute {X} {Y} f = begin
F₁ C.id ∘ F₁ f ∘ M.δ.η X ≈⟨ elimˡ identity ⟩
F₁ f ∘ M.δ.η X ≈⟨ introʳ (Comonad.identityʳ M) ⟩
(F₁ f ∘ M.δ.η X) ∘ M.ε.η (F₀ X) ∘ M.δ.η X ≈⟨ sym assoc ⟩
((F₁ f ∘ M.δ.η X) ∘ M.ε.η (F₀ X)) ∘ M.δ.η X ≈⟨ intro-center FF1≈1 ⟩
((F₁ f ∘ M.δ.η X) ∘ M.ε.η (F₀ X)) ∘ F₁ (F₁ C.id) ∘ M.δ.η X ∎
counit-commute : ∀ {X Y : Obj} →
(f : X ⇒ Y) →
M.ε.η Y ∘ (F₁ (f ∘ M.ε.η X) ∘ M.δ.η X) ≈ f ∘ M.ε.η X
counit-commute {X} {Y} f = begin
M.ε.η Y ∘ F₁ (f ∘ M.ε.η X) ∘ M.δ.η X ≈⟨ refl⟩∘⟨ pushˡ homomorphism ⟩
M.ε.η Y ∘ (F₁ f ∘ F₁ (M.ε.η X) ∘ M.δ.η X) ≈⟨ refl⟩∘⟨ elimʳ (Comonad.identityˡ M) ⟩
M.ε.η Y ∘ F₁ f ≈⟨ M.ε.commute f ⟩
f ∘ M.ε.η X ∎
zig-proof : {A : Obj} → M.ε.η (F₀ A) ∘ F₁ (F₁ C.id) ∘ M.δ.η _ ≈ C.id
zig-proof {A} = begin
M.ε.η (F₀ A) ∘ F₁ (F₁ C.id) ∘ M.δ.η _ ≈⟨ elim-center FF1≈1 ⟩
M.ε.η (F₀ A) ∘ M.δ.η _ ≈⟨ Comonad.identityʳ M ⟩
C.id ∎
zag-proof : {B : Obj} → (M.ε.η B ∘ M.ε.η (F₀ B)) ∘ (F₁ (F₁ C.id) ∘ M.δ.η _) ≈ M.ε.η B
zag-proof {B} = begin
(M.ε.η B ∘ M.ε.η (F₀ B)) ∘ (F₁ (F₁ C.id) ∘ M.δ.η _) ≈⟨ assoc ⟩
M.ε.η B ∘ (M.ε.η (F₀ B) ∘ (F₁ (F₁ C.id) ∘ M.δ.η _)) ≈⟨ refl⟩∘⟨ elim-center FF1≈1 ⟩
M.ε.η B ∘ (M.ε.η (F₀ B) ∘ M.δ.η _) ≈⟨ elimʳ (Comonad.identityʳ M) ⟩
M.ε.η B ∎ | {
"alphanum_fraction": 0.4658520254,
"avg_line_length": 40.0939597315,
"ext": "agda",
"hexsha": "d4217d5c6475cc5b069b22d4fccbd8cb40a4e93d",
"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": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Code-distancing/agda-categories",
"max_forks_repo_path": "src/Categories/Adjoint/Construction/CoKleisli.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"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": "Code-distancing/agda-categories",
"max_issues_repo_path": "src/Categories/Adjoint/Construction/CoKleisli.agda",
"max_line_length": 105,
"max_stars_count": 5,
"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/Adjoint/Construction/CoKleisli.agda",
"max_stars_repo_stars_event_max_datetime": "2019-05-22T03:54:24.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-05-21T17:07:19.000Z",
"num_tokens": 2997,
"size": 5974
} |
{-# OPTIONS --safe #-}
{-
This uses ideas from Floris van Doorn's phd thesis and the code in
https://github.com/cmu-phil/Spectral/blob/master/spectrum/basic.hlean
-}
module Cubical.Homotopy.Spectrum where
open import Cubical.Foundations.Prelude
open import Cubical.Data.Unit.Pointed
open import Cubical.Foundations.Equiv
open import Cubical.Data.Int
open import Cubical.Homotopy.Prespectrum
private
variable
ℓ : Level
record Spectrum (ℓ : Level) : Type (ℓ-suc ℓ) where
open GenericPrespectrum
field
prespectrum : Prespectrum ℓ
equiv : (k : ℤ) → isEquiv (fst (map prespectrum k))
open GenericPrespectrum prespectrum public
| {
"alphanum_fraction": 0.7542242704,
"avg_line_length": 25.0384615385,
"ext": "agda",
"hexsha": "bd628ac6c27102b00637821fcfac09513b387f60",
"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/Homotopy/Spectrum.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/Homotopy/Spectrum.agda",
"max_line_length": 71,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "thomas-lamiaux/cubical",
"max_stars_repo_path": "Cubical/Homotopy/Spectrum.agda",
"max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z",
"num_tokens": 185,
"size": 651
} |
{-
This file contains:
- the abelianization of groups as a HIT as proposed in https://arxiv.org/abs/2007.05833
The definition of the abelianization is not as a set-quotient, since the relation of abelianization is cumbersome to work with.
-}
{-# OPTIONS --safe #-}
module Cubical.Algebra.Group.Abelianization.Base where
open import Cubical.Data.Sigma
open import Cubical.Algebra.Group.Base
open import Cubical.Algebra.Group.Properties
private
variable
ℓ : Level
module _ (G : Group ℓ) where
open GroupStr {{...}}
open GroupTheory G
private
instance
_ = snd G
{-
The definition of the abelianization of a group as a higher inductive type.
The generality of the comm relation will be needed to define the group structure on the abelianization.
-}
data Abelianization : Type ℓ where
η : (g : fst G) → Abelianization
comm : (a b c : fst G) → η (a · (b · c)) ≡ η (a · (c · b))
isset : (x y : Abelianization) → (p q : x ≡ y) → p ≡ q
| {
"alphanum_fraction": 0.6849037487,
"avg_line_length": 27.4166666667,
"ext": "agda",
"hexsha": "868d98c3c273baa2116d59ffe2d33646b5a41464",
"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/Group/Abelianization/Base.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "thomas-lamiaux/cubical",
"max_issues_repo_path": "Cubical/Algebra/Group/Abelianization/Base.agda",
"max_line_length": 127,
"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/Group/Abelianization/Base.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 289,
"size": 987
} |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
module Categories.Category.Construction.Properties.Presheaves.Complete {o ℓ e} (C : Category o ℓ e) where
open import Data.Product
open import Function.Equality using (Π) renaming (_∘_ to _∙_)
open import Relation.Binary
open import Relation.Binary.Construct.Closure.SymmetricTransitive as ST using (Plus⇔)
open Plus⇔
open import Categories.Category.Complete
open import Categories.Category.Cocomplete
open import Categories.Category.Construction.Presheaves
open import Categories.Category.Instance.Setoids
open import Categories.Category.Instance.Properties.Setoids
open import Categories.Diagram.Limit as Lim
open import Categories.Diagram.Colimit
open import Categories.Functor
open import Categories.NaturalTransformation
import Categories.Category.Construction.Cones as Co
import Categories.Category.Construction.Cocones as Coc
import Relation.Binary.Reasoning.Setoid as SetoidR
private
module C = Category C
open C
open Π using (_⟨$⟩_)
module _ o′ where
private
P = Presheaves′ o′ o′ C
module P = Category P
module _ {J : Category o′ o′ o′} (F : Functor J P) where
module J = Category J
module F = Functor F
open F
module F₀ j = Functor (F₀ j)
module F₁ {a b} (f : a J.⇒ b) = NaturalTransformation (F₁ f)
open Setoid using () renaming (_≈_ to [_]_≈_)
F[-,_] : Obj → Functor J (Setoids o′ o′)
F[-, X ] = record
{ F₀ = λ j → F₀.₀ j X
; F₁ = λ f → F₁.η f X
; identity = identity
; homomorphism = homomorphism
; F-resp-≈ = λ eq → F-resp-≈ eq -- this application cannot be eta reduced
}
-- limit related definitions
module LimFX X = Limit (Setoids-Complete _ _ _ o′ o′ F[-, X ])
module FCone (K : Co.Cone F) where
open Co.Cone F K public
module N = Functor N
module ψ j = NaturalTransformation (ψ j)
module FCone⇒ {K K′ : Co.Cone F} (K⇒K′ : Co.Cone⇒ F K K′) where
open Co.Cone⇒ F K⇒K′ public
module arr = NaturalTransformation arr
FXcone : ∀ X → (K : Co.Cone F) → Co.Cone F[-, X ]
FXcone X K = record
{ N = N.₀ X
; apex = record
{ ψ = λ j → ψ.η j X
; commute = λ f → commute f -- this application cannot be eta reduced
}
}
where open FCone K
⊤ : Co.Cone F
⊤ = record
{ N = record
{ F₀ = λ X → LimFX.apex X
; F₁ = λ {A B} f → record
{ _⟨$⟩_ = λ { (S , eq) → (λ j → F₀.₁ j f ⟨$⟩ S j) , λ {X Y} g →
let open SetoidR (F₀.₀ Y B)
in begin
F₁.η g B ⟨$⟩ (F₀.₁ X f ⟨$⟩ S X) ≈⟨ F₁.commute g f (Setoid.refl (F₀.₀ X A)) ⟩
F₀.₁ Y f ⟨$⟩ (F₁.η g A ⟨$⟩ S X) ≈⟨ Π.cong (F₀.₁ Y f) (eq g) ⟩
F₀.₁ Y f ⟨$⟩ S Y ∎ }
; cong = λ eq j → Π.cong (F₀.₁ j f) (eq j)
}
; identity = λ eq j → F₀.identity j (eq j)
; homomorphism = λ eq j → F₀.homomorphism j (eq j)
; F-resp-≈ = λ eq eq′ j → F₀.F-resp-≈ j eq (eq′ j)
}
; apex = record
{ ψ = λ j → ntHelper record
{ η = λ X → record
{ _⟨$⟩_ = λ { (S , eq) → S j }
; cong = λ eq → eq j
}
; commute = λ f eq → Π.cong (F₀.₁ j f) (eq j)
}
; commute = λ { {Y} {Z} f {W} {S₁ , eq₁} {S₂ , eq₂} eq →
let open SetoidR (F₀.₀ Z W)
in begin
F₁.η f W ⟨$⟩ S₁ Y ≈⟨ eq₁ f ⟩
S₁ Z ≈⟨ eq Z ⟩
S₂ Z ∎ }
}
}
K⇒⊤′ : ∀ X {K} → Co.Cones F [ K , ⊤ ] → Co.Cones F[-, X ] [ FXcone X K , LimFX.limit X ]
K⇒⊤′ X {K} K⇒⊤ = record
{ arr = arr.η X
; commute = comm
}
where open FCone⇒ K⇒⊤ renaming (commute to comm)
complete : Limit F
complete = record
{ terminal = record
{ ⊤ = ⊤
; ! = λ {K} →
let module K = FCone K
in record
{ arr = ntHelper record
{ η = λ X → LimFX.rep X (FXcone X K)
; commute = λ {X Y} f eq j → K.ψ.commute j f eq
}
; commute = λ eq → Π.cong (K.ψ.η _ _) eq
}
; !-unique = λ K⇒⊤ {X} → LimFX.terminal.!-unique X (K⇒⊤′ X K⇒⊤)
}
}
-- colimit related definitions
module ColimFX X = Colimit (Setoids-Cocomplete _ _ _ o′ o′ F[-, X ])
module FCocone (K : Coc.Cocone F) where
open Coc.Cocone F K public
module N = Functor N
module ψ j = NaturalTransformation (ψ j)
module FCocone⇒ {K K′ : Coc.Cocone F} (K⇒K′ : Coc.Cocone⇒ F K K′) where
open Coc.Cocone⇒ F K⇒K′ public
module arr = NaturalTransformation arr
FXcocone : ∀ X → (K : Coc.Cocone F) → Coc.Cocone F[-, X ]
FXcocone X K = record
{ N = N.₀ X
; coapex = record
{ ψ = λ j → ψ.η j X
; commute = λ f → commute f -- this application cannot be eta reduced
}
}
where open FCocone K
⊥ : Coc.Cocone F
⊥ = record
{ N = record
{ F₀ = λ X → ColimFX.coapex X
; F₁ = λ {A B} f → record
{ _⟨$⟩_ = λ { (j , Sj) → j , F₀.₁ j f ⟨$⟩ Sj }
; cong = λ { {a , Sa} {b , Sb} →
ST.map (λ { (j , Sj) → j , F₀.₁ j f ⟨$⟩ Sj }) (helper f) }
}
; identity = λ { {A} {j , _} eq → forth⁺ (J.id , identity (F₀.identity j (Setoid.refl (F₀.₀ j A)))) eq }
; homomorphism = λ {X Y Z} {f g} → λ { {_} {j , Sj} eq →
let open Setoid (F₀.₀ j Z)
in ST.trans (coc o′ o′ F[-, Z ])
(ST.map (hom-map f g) (helper (f ∘ g)) eq)
(forth (J.id , trans (identity refl) (F₀.homomorphism j (Setoid.refl (F₀.₀ j X))))) }
; F-resp-≈ = λ {A B} {f g} eq → λ { {j , Sj} eq′ →
let open Setoid (F₀.₀ j B)
in ST.trans (coc o′ o′ F[-, B ])
(forth (J.id , trans (identity refl) (F₀.F-resp-≈ j eq (Setoid.refl (F₀.₀ j A)))))
(ST.map (λ { (j , Sj) → (j , F₀.₁ j g ⟨$⟩ Sj) }) (helper g) eq′) }
}
; coapex = record
{ ψ = λ j → ntHelper record
{ η = λ X → record
{ _⟨$⟩_ = j ,_
; cong = λ eq → forth (-, identity eq)
}
; commute = λ {X Y} f eq → back (-, identity (Π.cong (F₀.₁ j f) (Setoid.sym (F₀.₀ j X) eq)))
}
; commute = λ {a b} f {X} {x y} eq →
let open ST.Plus⇔Reasoning (coc o′ o′ F[-, X ])
in back (f , Π.cong (F₁.η f X) (Setoid.sym (F₀.₀ a X) eq))
}
}
where helper : ∀ {A B} (f : B C.⇒ A) {a Sa b Sb} →
Σ (a J.⇒ b) (λ g → [ F₀.₀ b A ] F₁.η g A ⟨$⟩ Sa ≈ Sb) →
Σ (a J.⇒ b) λ h → [ F₀.₀ b B ] F₁.η h B ⟨$⟩ (F₀.₁ a f ⟨$⟩ Sa) ≈ F₀.₁ b f ⟨$⟩ Sb
helper {A} {B} f {a} {Sa} {b} {Sb} (g , eq′) =
let open SetoidR (F₀.₀ b B)
in g , (begin
F₁.η g B ⟨$⟩ (F₀.₁ a f ⟨$⟩ Sa) ≈⟨ F₁.commute g f (Setoid.refl (F₀.₀ a A)) ⟩
F₀.₁ b f ⟨$⟩ (F₁.η g A ⟨$⟩ Sa) ≈⟨ Π.cong (F₀.₁ b f) eq′ ⟩
F₀.₁ b f ⟨$⟩ Sb ∎)
hom-map : ∀ {X Y Z} → Y C.⇒ X → Z C.⇒ Y → Σ J.Obj (λ j → Setoid.Carrier (F₀.₀ j X)) → Σ J.Obj (λ j → Setoid.Carrier (F₀.₀ j Z))
hom-map f g (j , Sj) = j , F₀.₁ j (f ∘ g) ⟨$⟩ Sj
⊥⇒K′ : ∀ X {K} → Coc.Cocones F [ ⊥ , K ] → Coc.Cocones F[-, X ] [ ColimFX.colimit X , FXcocone X K ]
⊥⇒K′ X {K} ⊥⇒K = record
{ arr = arr.η X
; commute = comm
}
where open FCocone⇒ ⊥⇒K renaming (commute to comm)
! : {K : Coc.Cocone F} → Coc.Cocone⇒ F ⊥ K
! {K} = record
{ arr = ntHelper record
{ η = λ X → ColimFX.rep X (FXcocone X K)
; commute = λ {X Y} f → λ { {a , Sa} {b , Sb} eq →
let open SetoidR (K.N.F₀ Y)
in begin
K.ψ.η a Y ⟨$⟩ (F₀.₁ a f ⟨$⟩ Sa) ≈⟨ K.ψ.commute a f (Setoid.refl (F₀.₀ a X)) ⟩
K.N.F₁ f ⟨$⟩ (K.ψ.η a X ⟨$⟩ Sa) ≈⟨ Π.cong (K.N.F₁ f) (ST.minimal (coc o′ o′ F[-, X ]) (K.N.₀ X) (Kψ X) (helper X) eq) ⟩
K.N.F₁ f ⟨$⟩ (K.ψ.η b X ⟨$⟩ Sb) ∎ }
}
; commute = λ eq → Π.cong (K.ψ.η _ _) eq
}
where module K = FCocone K
Kψ : ∀ X → Σ J.Obj (λ j → Setoid.Carrier (F₀.₀ j X)) → Setoid.Carrier (K.N.F₀ X)
Kψ X (j , S) = K.ψ.η j X ⟨$⟩ S
helper : ∀ X → coc o′ o′ F[-, X ] =[ Kψ X ]⇒ [ K.N.₀ X ]_≈_
helper X {a , Sa} {b , Sb} (f , eq) = begin
K.ψ.η a X ⟨$⟩ Sa ≈˘⟨ K.commute f (Setoid.refl (F₀.₀ a X)) ⟩
K.ψ.η b X ⟨$⟩ (F₁.η f X ⟨$⟩ Sa) ≈⟨ Π.cong (K.ψ.η b X) eq ⟩
K.ψ.η b X ⟨$⟩ Sb ∎
where open SetoidR (K.N.₀ X)
cocomplete : Colimit F
cocomplete = record
{ initial = record
{ ⊥ = ⊥
; ! = !
; !-unique = λ ⊥⇒K {X} → ColimFX.initial.!-unique X (⊥⇒K′ X ⊥⇒K)
}
}
Presheaves-Complete : Complete o′ o′ o′ P
Presheaves-Complete F = complete F
Presheaves-Cocomplete : Cocomplete o′ o′ o′ P
Presheaves-Cocomplete F = cocomplete F
| {
"alphanum_fraction": 0.4486098094,
"avg_line_length": 38.412,
"ext": "agda",
"hexsha": "ad7b4be74ff18140ee77051c13b405ffaa4f7c2d",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "MirceaS/agda-categories",
"max_forks_repo_path": "src/Categories/Category/Construction/Properties/Presheaves/Complete.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "MirceaS/agda-categories",
"max_issues_repo_path": "src/Categories/Category/Construction/Properties/Presheaves/Complete.agda",
"max_line_length": 141,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "MirceaS/agda-categories",
"max_stars_repo_path": "src/Categories/Category/Construction/Properties/Presheaves/Complete.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3507,
"size": 9603
} |
{-# OPTIONS --cubical-compatible #-}
data ℕ : Set where
zero : ℕ
suc : ℕ → ℕ
Test : Set
Test = ℕ
test : Test → ℕ
test zero = zero
test (suc n) = test n
| {
"alphanum_fraction": 0.5849056604,
"avg_line_length": 12.2307692308,
"ext": "agda",
"hexsha": "d629c2196b05ee034b01b4637408839acba8620b",
"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/Issue1214.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/Issue1214.agda",
"max_line_length": 36,
"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/Issue1214.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 55,
"size": 159
} |
module Serializer where
open import Data.List
open import Data.Fin hiding (_+_)
open import Data.Nat
open import Data.Product
open import Data.Bool
open import Function using (_∘_ ; _$_ ; _∋_)
open import Function.Injection hiding (_∘_)
open import Function.Surjection hiding (_∘_)
open import Function.Bijection hiding (_∘_)
open import Relation.Binary.PropositionalEquality hiding ( [_] )
open import Reflection
open import Helper.Fin
open import Helper.CodeGeneration
-----------------------------------
-- Generic
-----------------------------------
-- Finite
record Serializer (T : Set) : Set where
constructor serializer
field
size : ℕ
from : T -> Fin size
to : Fin size -> T
bijection : Bijection (setoid T) (setoid (Fin size))
| {
"alphanum_fraction": 0.6684210526,
"avg_line_length": 24.5161290323,
"ext": "agda",
"hexsha": "c113d616537308b72783c5193b32b0e2c74e42f2",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "cb95986b772b7a01195619be5e8e590f2429c759",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mathijsb/generic-in-agda",
"max_forks_repo_path": "Serializer.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "cb95986b772b7a01195619be5e8e590f2429c759",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "mathijsb/generic-in-agda",
"max_issues_repo_path": "Serializer.agda",
"max_line_length": 64,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "cb95986b772b7a01195619be5e8e590f2429c759",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mathijsb/generic-in-agda",
"max_stars_repo_path": "Serializer.agda",
"max_stars_repo_stars_event_max_datetime": "2016-08-04T16:05:24.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-06-09T09:59:27.000Z",
"num_tokens": 178,
"size": 760
} |
------------------------------------------------------------------------------
-- Test the consistency of FOTC.Data.List
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
-- In the module FOTC.Data.List we declare Agda postulates as FOL
-- axioms. We test if it is possible to prove an unprovable theorem
-- from these axioms.
module FOTC.Data.List.Consistency.Axioms where
open import FOTC.Base
open import FOTC.Data.List
------------------------------------------------------------------------------
postulate impossible : ∀ d e → d ≡ e
{-# ATP prove impossible #-}
| {
"alphanum_fraction": 0.4529032258,
"avg_line_length": 33.6956521739,
"ext": "agda",
"hexsha": "24492e0943a22bd11263f5f2c44d99f14230e066",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z",
"max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/fotc",
"max_forks_repo_path": "src/fot/FOTC/Data/List/Consistency/Axioms.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/fotc",
"max_issues_repo_path": "src/fot/FOTC/Data/List/Consistency/Axioms.agda",
"max_line_length": 78,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "src/fot/FOTC/Data/List/Consistency/Axioms.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": 138,
"size": 775
} |
open import Data.Product using ( _×_ ; _,_ )
open import Data.Sum using ( inj₁ ; inj₂ )
open import Relation.Binary.PropositionalEquality using ( _≡_ ; refl )
open import Relation.Unary using ( _∈_ ; _⊆_ )
open import Web.Semantic.DL.ABox using
( ABox ; Assertions ; ⟨ABox⟩ ; ε ; _,_ ; _∼_ ; _∈₁_ ; _∈₂_ )
open import Web.Semantic.DL.ABox.Interp using ( Interp ; _,_ ; ⌊_⌋ ; ind ; _*_ )
open import Web.Semantic.DL.ABox.Interp.Morphism using
( _≲_ ; _,_ ; ≲⌊_⌋ ; ≲-resp-ind ; ≡³-impl-≲ )
open import Web.Semantic.DL.Signature using ( Signature )
open import Web.Semantic.DL.TBox.Interp using
( Δ ; _⊨_≈_ ; ≈-refl ; ≈-sym ; ≈-trans ; con ; rol ; con-≈ ; rol-≈ )
open import Web.Semantic.DL.TBox.Interp.Morphism using
( ≲-image ; ≲-resp-≈ ; ≲-resp-con ; ≲-resp-rol ; ≲-refl )
open import Web.Semantic.Util using
( True ; tt ; id ; _∘_ ; _⊕_⊕_ ; inode ; bnode ; enode ; →-dist-⊕ )
module Web.Semantic.DL.ABox.Model {Σ : Signature} where
infix 2 _⊨a_ _⊨b_
infixr 5 _,_
_⟦_⟧₀ : ∀ {X} (I : Interp Σ X) → X → (Δ ⌊ I ⌋)
I ⟦ x ⟧₀ = ind I x
_⊨a_ : ∀ {X} → Interp Σ X → ABox Σ X → Set
I ⊨a ε = True
I ⊨a (A , B) = (I ⊨a A) × (I ⊨a B)
I ⊨a x ∼ y = ⌊ I ⌋ ⊨ ind I x ≈ ind I y
I ⊨a x ∈₁ c = ind I x ∈ con ⌊ I ⌋ c
I ⊨a (x , y) ∈₂ r = (ind I x , ind I y) ∈ rol ⌊ I ⌋ r
Assertions✓ : ∀ {X} (I : Interp Σ X) A {a} →
(a ∈ Assertions A) → (I ⊨a A) → (I ⊨a a)
Assertions✓ I ε () I⊨A
Assertions✓ I (A , B) (inj₁ a∈A) (I⊨A , I⊨B) = Assertions✓ I A a∈A I⊨A
Assertions✓ I (A , B) (inj₂ a∈B) (I⊨A , I⊨B) = Assertions✓ I B a∈B I⊨B
Assertions✓ I (i ∼ j) refl I⊨A = I⊨A
Assertions✓ I (i ∈₁ c) refl I⊨A = I⊨A
Assertions✓ I (ij ∈₂ r) refl I⊨A = I⊨A
⊨a-resp-⊇ : ∀ {X} (I : Interp Σ X) A B →
(Assertions A ⊆ Assertions B) → (I ⊨a B) → (I ⊨a A)
⊨a-resp-⊇ I ε B A⊆B I⊨B = tt
⊨a-resp-⊇ I (A₁ , A₂) B A⊆B I⊨B =
( ⊨a-resp-⊇ I A₁ B (A⊆B ∘ inj₁) I⊨B
, ⊨a-resp-⊇ I A₂ B (A⊆B ∘ inj₂) I⊨B )
⊨a-resp-⊇ I (x ∼ y) B A⊆B I⊨B = Assertions✓ I B (A⊆B refl) I⊨B
⊨a-resp-⊇ I (x ∈₁ c) B A⊆B I⊨B = Assertions✓ I B (A⊆B refl) I⊨B
⊨a-resp-⊇ I (xy ∈₂ r) B A⊆B I⊨B = Assertions✓ I B (A⊆B refl) I⊨B
⊨a-resp-≲ : ∀ {X} {I J : Interp Σ X} → (I ≲ J) → ∀ A → (I ⊨a A) → (J ⊨a A)
⊨a-resp-≲ {X} {I} {J} I≲J ε I⊨A =
tt
⊨a-resp-≲ {X} {I} {J} I≲J (A , B) (I⊨A , I⊨B) =
(⊨a-resp-≲ I≲J A I⊨A , ⊨a-resp-≲ I≲J B I⊨B)
⊨a-resp-≲ {X} {I} {J} I≲J (x ∼ y) I⊨x∼y =
≈-trans ⌊ J ⌋ (≈-sym ⌊ J ⌋ (≲-resp-ind I≲J x))
(≈-trans ⌊ J ⌋ (≲-resp-≈ ≲⌊ I≲J ⌋ I⊨x∼y)
(≲-resp-ind I≲J y))
⊨a-resp-≲ {X} {I} {J} I≲J (x ∈₁ c) I⊨x∈c =
con-≈ ⌊ J ⌋ c (≲-resp-con ≲⌊ I≲J ⌋ I⊨x∈c) (≲-resp-ind I≲J x)
⊨a-resp-≲ {X} {I} {J} I≲J ((x , y) ∈₂ r) I⊨xy∈r =
rol-≈ ⌊ J ⌋ r (≈-sym ⌊ J ⌋ (≲-resp-ind I≲J x))
(≲-resp-rol ≲⌊ I≲J ⌋ I⊨xy∈r) (≲-resp-ind I≲J y)
⊨a-resp-≡ : ∀ {X : Set} (I : Interp Σ X) j →
(ind I ≡ j) → ∀ A → (I ⊨a A) → (⌊ I ⌋ , j ⊨a A)
⊨a-resp-≡ (I , i) .i refl A I⊨A = I⊨A
⊨a-resp-≡³ : ∀ {V X Y : Set} (I : Interp Σ (X ⊕ V ⊕ Y)) j →
(→-dist-⊕ (ind I) ≡ →-dist-⊕ j) → ∀ A → (I ⊨a A) → (⌊ I ⌋ , j ⊨a A)
⊨a-resp-≡³ I j i≡j = ⊨a-resp-≲ (≡³-impl-≲ I j i≡j)
⟨ABox⟩-Assertions : ∀ {X Y a} (f : X → Y) (A : ABox Σ X) →
(a ∈ Assertions A) → (⟨ABox⟩ f a ∈ Assertions (⟨ABox⟩ f A))
⟨ABox⟩-Assertions f ε ()
⟨ABox⟩-Assertions f (A , B) (inj₁ a∈A) = inj₁ (⟨ABox⟩-Assertions f A a∈A)
⟨ABox⟩-Assertions f (A , B) (inj₂ a∈B) = inj₂ (⟨ABox⟩-Assertions f B a∈B)
⟨ABox⟩-Assertions f (x ∼ y) refl = refl
⟨ABox⟩-Assertions f (x ∈₁ c) refl = refl
⟨ABox⟩-Assertions f ((x , y) ∈₂ r) refl = refl
⟨ABox⟩-resp-⊨ : ∀ {X Y} {I : Interp Σ X} {j : Y → Δ ⌊ I ⌋}
(f : X → Y) → (∀ x → ⌊ I ⌋ ⊨ ind I x ≈ j (f x)) →
∀ A → (I ⊨a A) → (⌊ I ⌋ , j ⊨a ⟨ABox⟩ f A)
⟨ABox⟩-resp-⊨ {X} {Y} {I} f i≈j∘f ε I⊨ε =
tt
⟨ABox⟩-resp-⊨ {X} {Y} {I} f i≈j∘f (A , B) (I⊨A , I⊨B) =
(⟨ABox⟩-resp-⊨ f i≈j∘f A I⊨A , ⟨ABox⟩-resp-⊨ f i≈j∘f B I⊨B)
⟨ABox⟩-resp-⊨ {X} {Y} {I} f i≈j∘f (x ∼ y) x≈y =
≈-trans ⌊ I ⌋ (≈-sym ⌊ I ⌋ (i≈j∘f x)) (≈-trans ⌊ I ⌋ x≈y (i≈j∘f y))
⟨ABox⟩-resp-⊨ {X} {Y} {I} f i≈j∘f (x ∈₁ c) x∈⟦c⟧ =
con-≈ ⌊ I ⌋ c x∈⟦c⟧ (i≈j∘f x)
⟨ABox⟩-resp-⊨ {X} {Y} {I} f i≈j∘f ((x , y) ∈₂ r) xy∈⟦r⟧ =
rol-≈ ⌊ I ⌋ r (≈-sym ⌊ I ⌋ (i≈j∘f x)) xy∈⟦r⟧ (i≈j∘f y)
*-resp-⟨ABox⟩ : ∀ {X Y} (f : Y → X) I A →
(I ⊨a ⟨ABox⟩ f A) → (f * I ⊨a A)
*-resp-⟨ABox⟩ f (I , i) ε I⊨ε =
tt
*-resp-⟨ABox⟩ f (I , i) (A , B) (I⊨A , I⊨B) =
(*-resp-⟨ABox⟩ f (I , i) A I⊨A , *-resp-⟨ABox⟩ f (I , i) B I⊨B )
*-resp-⟨ABox⟩ f (I , i) (x ∼ y) x≈y =
x≈y
*-resp-⟨ABox⟩ f (I , i) (x ∈₁ c) x∈⟦c⟧ =
x∈⟦c⟧
*-resp-⟨ABox⟩ f (I , i) ((x , y) ∈₂ r) xy∈⟦c⟧ =
xy∈⟦c⟧
-- bnodes I f is the same as I, except that f is used as the interpretation
-- for bnodes.
on-bnode : ∀ {V W X Y Z : Set} → (W → Z) → ((X ⊕ V ⊕ Y) → Z) →
((X ⊕ W ⊕ Y) → Z)
on-bnode f g (inode x) = g (inode x)
on-bnode f g (bnode w) = f w
on-bnode f g (enode y) = g (enode y)
bnodes : ∀ {V W X Y} → (I : Interp Σ (X ⊕ V ⊕ Y)) → (W → Δ ⌊ I ⌋) →
Interp Σ (X ⊕ W ⊕ Y)
bnodes I f = (⌊ I ⌋ , on-bnode f (ind I))
bnodes-resp-≲ : ∀ {V W X Y} (I J : Interp Σ (X ⊕ V ⊕ Y)) →
(I≲J : I ≲ J) → (f : W → Δ ⌊ I ⌋) →
(bnodes I f ≲ bnodes J (≲-image ≲⌊ I≲J ⌋ ∘ f))
bnodes-resp-≲ (I , i) (J , j) (I≲J , i≲j) f = (I≲J , lemma) where
lemma : ∀ x →
J ⊨ ≲-image I≲J (on-bnode f i x) ≈ on-bnode (≲-image I≲J ∘ f) j x
lemma (inode x) = i≲j (inode x)
lemma (bnode v) = ≈-refl J
lemma (enode y) = i≲j (enode y)
-- I ⊨b A whenever there exists an f such that bnodes I f ⊨a A
data _⊨b_ {V W X Y} (I : Interp Σ (X ⊕ V ⊕ Y))
(A : ABox Σ (X ⊕ W ⊕ Y)) : Set where
_,_ : ∀ f → (bnodes I f ⊨a A) → (I ⊨b A)
inb : ∀ {V W X Y} {I : Interp Σ (X ⊕ V ⊕ Y)} {A : ABox Σ (X ⊕ W ⊕ Y)} →
(I ⊨b A) → W → Δ ⌊ I ⌋
inb (f , I⊨A) = f
⊨b-impl-⊨a : ∀ {V W X Y} {I : Interp Σ (X ⊕ V ⊕ Y)} {A : ABox Σ (X ⊕ W ⊕ Y)} →
(I⊨A : I ⊨b A) → (bnodes I (inb I⊨A) ⊨a A)
⊨b-impl-⊨a (f , I⊨A) = I⊨A
⊨a-impl-⊨b : ∀ {V X Y} (I : Interp Σ (X ⊕ V ⊕ Y)) A → (I ⊨a A) → (I ⊨b A)
⊨a-impl-⊨b I A I⊨A =
(ind I ∘ bnode , ⊨a-resp-≲ (≲-refl ⌊ I ⌋ , lemma) A I⊨A) where
lemma : ∀ x → ⌊ I ⌋ ⊨ ind I x ≈ on-bnode (ind I ∘ bnode) (ind I) x
lemma (inode x) = ≈-refl ⌊ I ⌋
lemma (bnode v) = ≈-refl ⌊ I ⌋
lemma (enode y) = ≈-refl ⌊ I ⌋
⊨b-resp-≲ : ∀ {V W X Y} {I J : Interp Σ (X ⊕ V ⊕ Y)} → (I ≲ J)
→ ∀ (A : ABox Σ (X ⊕ W ⊕ Y)) → (I ⊨b A) → (J ⊨b A)
⊨b-resp-≲ I≲J A (f , I⊨A) =
((≲-image ≲⌊ I≲J ⌋ ∘ f) , ⊨a-resp-≲ (bnodes-resp-≲ _ _ I≲J f) A I⊨A)
| {
"alphanum_fraction": 0.46203125,
"avg_line_length": 39.263803681,
"ext": "agda",
"hexsha": "aebec4544a56bd10a78e08023d1c8a2f88e7d759",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:03.000Z",
"max_forks_repo_forks_event_min_datetime": "2017-12-03T14:52:09.000Z",
"max_forks_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "agda/agda-web-semantic",
"max_forks_repo_path": "src/Web/Semantic/DL/ABox/Model.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab",
"max_issues_repo_issues_event_max_datetime": "2021-01-04T20:57:19.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T02:32:28.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "agda/agda-web-semantic",
"max_issues_repo_path": "src/Web/Semantic/DL/ABox/Model.agda",
"max_line_length": 80,
"max_stars_count": 9,
"max_stars_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "agda/agda-web-semantic",
"max_stars_repo_path": "src/Web/Semantic/DL/ABox/Model.agda",
"max_stars_repo_stars_event_max_datetime": "2020-03-14T14:21:08.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-13T17:46:41.000Z",
"num_tokens": 3954,
"size": 6400
} |
{-# OPTIONS --allow-unsolved-metas --no-termination-check
#-}
module Bag where
import Prelude
import Equiv
import Datoid
import Eq
import Nat
import List
import Pos
open Prelude
open Equiv
open Datoid
open Eq
open Nat
open List
abstract
----------------------------------------------------------------------
-- Bag type
private
-- If this were Coq then the invariant should be a Prop. Similar
-- remarks apply to some definitions below. Since I have to write
-- the supporting library myself I can't be bothered to
-- distinguish Set and Prop right now though.
data BagType (a : Datoid) : Set where
bt : (pairs : List (Pair Pos.Pos (El a)))
→ NoDuplicates a (map snd pairs)
→ BagType a
list : {a : Datoid} → BagType a → List (Pair Pos.Pos (El a))
list (bt l _) = l
contents : {a : Datoid} → BagType a → List (El a)
contents b = map snd (list b)
invariant : {a : Datoid} → (b : BagType a)
→ NoDuplicates a (contents b)
invariant (bt _ i) = i
private
elemDatoid : Datoid → Datoid
elemDatoid a = pairDatoid Pos.posDatoid a
BagEq : (a : Datoid) → BagType a → BagType a → Set
BagEq a b1 b2 = rel' (Permutation (elemDatoid a)) (list b1) (list b2)
eqRefl : {a : Datoid} → (x : BagType a) → BagEq a x x
eqRefl {a} x = refl (Permutation (elemDatoid a)) {list x}
eqSym : {a : Datoid} → (x y : BagType a)
→ BagEq a x y → BagEq a y x
eqSym {a} x y = sym (Permutation (elemDatoid a)) {list x} {list y}
eqTrans : {a : Datoid} → (x y z : BagType a)
→ BagEq a x y → BagEq a y z → BagEq a x z
eqTrans {a} x y z = trans (Permutation (elemDatoid a))
{list x} {list y} {list z}
eqDec : {a : Datoid} → (x y : BagType a)
→ Either (BagEq a x y) _
eqDec {a} x y = decRel (Permutation (elemDatoid a)) (list x) (list y)
BagEquiv : (a : Datoid) → DecidableEquiv (BagType a)
BagEquiv a = decEquiv (equiv (BagEq a) eqRefl eqSym eqTrans) (dec eqDec)
Bag : Datoid → Datoid
Bag a = datoid (BagType a) (BagEquiv a)
----------------------------------------------------------------------
-- Bag primitives
empty : {a : Datoid} → El (Bag a)
empty = bt nil unit
private
data LookupResult (a : Datoid) (x : El a) (b : El (Bag a)) : Set where
lr : Nat
→ (b' : El (Bag a))
→ Not (member a x (contents b'))
→ ({y : El a} → Not (member a y (contents b))
→ Not (member a y (contents b')))
→ LookupResult a x b
lookup1 : {a : Datoid}
→ (n : Pos.Pos)
→ (y : El a)
→ (b' : El (Bag a))
→ (nyb' : Not (member a y (contents b')))
→ (x : El a)
→ Either (datoidRel a x y) _
→ LookupResult a x b'
→ LookupResult a x (bt (pair n y :: list b')
(pair nyb' (invariant b')))
lookup1 n y b' nyb' x (left xy) _ =
lr (Pos.toNat n) b'
(contrapositive (memberPreservesEq xy (contents b')) nyb')
(\{y'} ny'b → snd (notDistribIn ny'b))
lookup1 {a} n y b' nyb' x (right nxy)
(lr n' (bt b'' ndb'') nxb'' nmPres) =
lr n' (bt (pair n y :: b'') (pair (nmPres nyb') ndb''))
(notDistribOut {datoidRel a x y} nxy nxb'')
(\{y'} ny'b → notDistribOut (fst (notDistribIn ny'b))
(nmPres (snd (notDistribIn ny'b))))
lookup2
: {a : Datoid}
→ (x : El a)
→ (b : El (Bag a))
→ LookupResult a x b
lookup2 x (bt nil nd) = lr zero (bt nil nd) (not id) (\{_} _ → not id)
lookup2 {a} x (bt (pair n y :: b) (pair nyb ndb)) =
lookup1 n y (bt b ndb) nyb x
(decRel (datoidEq a) x y)
(lookup2 x (bt b ndb))
lookup3 : {a : Datoid} → {x : El a} → {b : El (Bag a)}
→ LookupResult a x b → Pair Nat (El (Bag a))
lookup3 (lr n b _ _) = pair n b
lookup : {a : Datoid} → El a → El (Bag a) → Pair Nat (El (Bag a))
lookup x b = lookup3 (lookup2 x b)
private
insert' : {a : Datoid} → (x : El a) → {b : El (Bag a)}
→ LookupResult a x b → El (Bag a)
insert' x (lr n (bt b ndb) nxb _) =
bt (pair (Pos.suc' n) x :: b) (pair nxb ndb)
insert : {a : Datoid} → El a → El (Bag a) → El (Bag a)
insert x b = insert' x (lookup2 x b)
private
postulate
insertLemma1
: {a : Datoid}
→ (x : El a)
→ (b : El (Bag a))
→ (nxb : Not (member a x (contents b)))
→ datoidRel (Bag a)
(insert x b)
(bt (pair Pos.one x :: list b) (pair nxb (invariant b)))
insertLemma2
: {a : Datoid}
→ (n : Pos.Pos)
→ (x : El a)
→ (b : El (Bag a))
→ (nxb : Not (member a x (contents b)))
→ datoidRel (Bag a)
(insert x (bt (pair n x :: list b)
(pair nxb (invariant b))))
(bt (pair (Pos.suc n) x :: list b)
(pair nxb (invariant b)))
----------------------------------------------------------------------
-- Bag traversals
data Traverse (a : Datoid) : Set where
Empty : Traverse a
Insert : (x : El a) → (b : El (Bag a)) → Traverse a
run : {a : Datoid} → Traverse a → El (Bag a)
run Empty = empty
run (Insert x b) = insert x b
abstract
traverse : {a : Datoid} → El (Bag a) → Traverse a
traverse (bt nil _) = Empty
traverse {a} (bt (pair n x :: b) (pair nxb ndb)) = traverse' (Pos.pred n)
where
private
traverse' : Maybe Pos.Pos → Traverse a
traverse' Nothing = Insert x (bt b ndb)
traverse' (Just n) = Insert x (bt (pair n x :: b) (pair nxb ndb))
traverseTraverses
: {a : Datoid} → (b : El (Bag a))
→ datoidRel (Bag a) (run (traverse b)) b
traverseTraverses {a} (bt nil unit) = dRefl (Bag a) {empty}
traverseTraverses {a} (bt (pair n x :: b) (pair nxb ndb)) =
tT (Pos.pred n) (Pos.predOK n)
where
private
postulate
subst' : {a : Datoid} → (P : El a → Set) → (x y : El a)
→ datoidRel a x y → P x → P y
tT : (predN : Maybe Pos.Pos)
→ Pos.Pred n predN
→ datoidRel (Bag a)
(run (traverse (bt (pair n x :: b) (pair nxb ndb))))
(bt (pair n x :: b) (pair nxb ndb))
tT Nothing (Pos.ok eq) = {!!}
-- subst' (\p → datoidRel (Bag a)
-- (run (traverse (bt (pair p x :: b) (pair nxb ndb))))
-- (bt (pair p x :: b) (pair nxb ndb)))
-- Pos.one n eq (insertLemma1 x (bt b ndb) nxb)
-- eq : one == n
-- data Pred (p : Pos) (mP : Maybe Pos) : Set where
-- ok : datoidRel posDatoid (sucPred mP) p → Pred p mP
-- insert x (bt b ndb) == bt (pair n x :: b) (pair nxb ndb)
tT (Just n) (Pos.ok eq) = {!!} -- insertLemma2 n x (bt b ndb) nxb
-- insert x (bt (pair n x :: b) (pair nxb btb) ==
-- bt (pair (suc n) x :: b) (pair nxb btb)
bagElim
: {a : Datoid}
→ (P : El (Bag a) → Set)
→ Respects (Bag a) P
→ P empty
→ ((x : El a) → (b : El (Bag a)) → P b → P (insert x b))
→ (b : El (Bag a))
→ P b
bagElim {a} P Prespects e i b =
bagElim' b (traverse b) (traverseTraverses b)
where
private
bagElim'
: (b : El (Bag a))
→ (t : Traverse a)
→ datoidRel (Bag a) (run t) b
→ P b
bagElim' b Empty eq = subst Prespects empty b eq e
bagElim' b (Insert x b') eq =
subst Prespects (insert x b') b eq
(i x b' (bagElim' b' (traverse b') (traverseTraverses b')))
----------------------------------------------------------------------
-- Respect and equality preservation lemmas
postulate
insertPreservesRespect
: {a : Datoid}
→ (P : El (Bag a) → Set)
→ (x : El a)
→ Respects (Bag a) P
→ Respects (Bag a) (\b → P (insert x b))
lookupPreservesRespect
: {a : Datoid}
→ (P : El (Bag a) → Set)
→ (x : El a)
→ Respects (Bag a) P
→ Respects (Bag a) (\b → P (snd $ lookup x b))
-- This doesn't type check without John Major equality or some
-- ugly substitutions...
-- bagElimPreservesEquality
-- : {a : Datoid}
-- → (P : El (Bag a) → Set)
-- → (r : Respects (Bag a) P)
-- → (e : P empty)
-- → (i : (x : El a) → (b : El (Bag a)) → P b → P (insert x b))
-- → ( (x1 x2 : El a) → (b1 b2 : El (Bag a))
-- → (p1 : P b1) → (p2 : P b2)
-- → (eqX : datoidRel a x1 x2) → (eqB : datoidRel (Bag a) b1 b2)
-- → i x1 b1 p1 =^= i x2 b2 p2
-- )
-- → (b1 b2 : El (Bag a))
-- → datoidRel (Bag a) b1 b2
-- → bagElim P r e i b1 =^= bagElim P r e i b2
| {
"alphanum_fraction": 0.4779345878,
"avg_line_length": 32.9446494465,
"ext": "agda",
"hexsha": "7fd912057e6379f5bd1f30c4a037fe7478738531",
"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": "examples/AIM4/bag/Bag.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": "examples/AIM4/bag/Bag.agda",
"max_line_length": 79,
"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": "examples/AIM4/bag/Bag.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": 2954,
"size": 8928
} |
{-# OPTIONS --without-K --safe #-}
-- | Operations that ensure a cycle traverses a particular element
-- at most once.
module Dodo.Binary.Cycle where
-- Stdlib import
import Relation.Binary.PropositionalEquality as Eq
open Eq using (_≡_; _≢_; refl)
open import Level using (Level; _⊔_)
open import Function using (_∘_)
open import Data.Product using (_×_; _,_; proj₁; proj₂)
open import Data.Sum using (_⊎_; inj₁; inj₂)
open import Relation.Nullary using (yes; no)
open import Relation.Binary using (Rel)
open import Relation.Binary.Construct.Closure.Transitive using (TransClosure; [_]; _∷_; _∷ʳ_; _++_)
-- Local imports
open import Dodo.Unary.Dec
open import Dodo.Binary.Transitive
-- # Definitions
-- | The given relation, with proofs that neither element equals `z`.
ExcludeRel : {a ℓ : Level} {A : Set a} → (R : Rel A ℓ) → (z : A) → Rel A (a ⊔ ℓ)
ExcludeRel R z x y = R x y × x ≢ z × y ≢ z
-- | A cycle of R which passes through `z` /exactly once/.
data PassCycle {a ℓ : Level} {A : Set a} (R : Rel A ℓ) (z : A) : Set (a ⊔ ℓ) where
cycle₁ : R z z → PassCycle R z
cycle₂ : {x : A} → x ≢ z → R z x → R x z → PassCycle R z
cycleₙ : {x y : A} → R z x → TransClosure (ExcludeRel R z) x y → R y z → PassCycle R z
-- # Functions
-- | A cycle of a relation either /does not/ pass through an element `y`, or it
-- can be made to pass through `y` /exactly once/.
--
-- Note that if the original cycle passes `y` /more than once/, then only one
-- cycle of the multi-cycle through `y` may be taken.
divert-cycle : {a ℓ : Level} {A : Set a}
→ {R : Rel A ℓ}
→ {x : A}
→ TransClosure R x x
→ {y : A}
→ DecPred (_≡ y)
→ PassCycle R y ⊎ TransClosure (ExcludeRel R y) x x
divert-cycle {x = x} [ Rxx ] eq-xm with eq-xm x
... | yes refl = inj₁ (cycle₁ Rxx)
... | no x≢y = inj₂ [ ( Rxx , x≢y , x≢y ) ]
divert-cycle {A = A} {R = R} {x} ( Rxw ∷ R⁺wx ) {y} eq-dec = lemma Rxw R⁺wx
where
-- Chain that starts with `y`.
--
-- `Ryx` and `R⁺xz` are acculumators.
lemma-incl : {x z : A} → R y x → TransClosure (ExcludeRel R y) x z → TransClosure R z y → PassCycle R y
lemma-incl Ryx R⁺xz [ Rzy ] = cycleₙ Ryx R⁺xz Rzy
lemma-incl Ryx R⁺xz (_∷_ {_} {w} Rzw R⁺wy) with eq-dec w
lemma-incl Ryx R⁺xz (_∷_ {_} {w} Rzw R⁺wy) | yes refl = cycleₙ Ryx R⁺xz Rzw
lemma-incl Ryx R⁺xz (_∷_ {_} {w} Rzw R⁺wy) | no w≢y =
let z≢y = ⁺-lift-predʳ (proj₂ ∘ proj₂) R⁺xz
in lemma-incl Ryx (R⁺xz ∷ʳ (Rzw , z≢y , w≢y)) R⁺wy
-- First step of a chain that starts with `y`.
lemma-incl₀ : {x : A} → R y x → TransClosure R x y → PassCycle R y
lemma-incl₀ {x} Ryx R⁺xy with eq-dec x
lemma-incl₀ {x} Ryx R⁺xy | yes refl = cycle₁ Ryx
lemma-incl₀ {x} Ryx [ Rxy ] | no x≢y = cycle₂ x≢y Ryx Rxy
lemma-incl₀ {x} Ryx (_∷_ {_} {z} Rxz R⁺zy) | no x≢y with eq-dec z
lemma-incl₀ {x} Ryx (_∷_ {x} {z} Rxz R⁺zy) | no x≢y | yes refl = cycle₂ x≢y Ryx Rxz
lemma-incl₀ {x} Ryx (_∷_ {x} {z} Rxz R⁺zy) | no x≢y | no z≢y = lemma-incl Ryx [ Rxz , x≢y , z≢y ] R⁺zy
-- Chain that does /not/ (yet) pass through `y`.
lemma-excl : {z : A} → TransClosure (ExcludeRel R y) x z → TransClosure R z x → PassCycle R y ⊎ TransClosure (ExcludeRel R y) x x
lemma-excl R⁺xz [ Rzx ] =
let z≢y = ⁺-lift-predʳ (proj₂ ∘ proj₂) R⁺xz
x≢y = ⁺-lift-predˡ (proj₁ ∘ proj₂) R⁺xz
in inj₂ (R⁺xz ∷ʳ (Rzx , z≢y , x≢y))
lemma-excl R⁺xz (_∷_ {_} {w} Rzw R⁺wx) with eq-dec w
lemma-excl R⁺xz (_∷_ {_} {_} Rzw [ Rwx ]) | yes refl = inj₁ (cycleₙ Rwx R⁺xz Rzw)
lemma-excl R⁺xz (_∷_ {_} {_} Rzw (Rwq ∷ R⁺qx)) | yes refl = inj₁ (lemma-incl₀ Rwq (R⁺qx ++ (⁺-map _ proj₁ R⁺xz) ∷ʳ Rzw))
lemma-excl R⁺xz (_∷_ {_} {_} Rzw R⁺wx) | no w≢y =
let z≢y = ⁺-lift-predʳ (proj₂ ∘ proj₂) R⁺xz
in lemma-excl (R⁺xz ∷ʳ (Rzw , z≢y , w≢y)) R⁺wx
lemma : {w : A} → R x w → TransClosure R w x → PassCycle R y ⊎ TransClosure (ExcludeRel R y) x x
lemma {_} Rxw R⁺wx with eq-dec x
lemma {_} Rxw R⁺wx | yes refl = inj₁ (lemma-incl₀ Rxw R⁺wx)
lemma {w} Rxw R⁺wx | no x≢y with eq-dec w
lemma {_} Rxw [ Rwx ] | no x≢y | yes refl = inj₁ (cycle₂ x≢y Rwx Rxw)
lemma {_} Rxw ( Rwz ∷ R⁺zx ) | no x≢y | yes refl = inj₁ (lemma-incl₀ Rwz (R⁺zx ∷ʳ Rxw))
lemma {_} Rxw R⁺wx | no x≢y | no w≢y = lemma-excl [ Rxw , x≢y , w≢y ] R⁺wx
| {
"alphanum_fraction": 0.5893978145,
"avg_line_length": 45.7553191489,
"ext": "agda",
"hexsha": "d73ab4df3527f4f64ab1f64faca745fc9bf6c4be",
"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": "376f0ccee1e1aa31470890e494bcb534324f598a",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "sourcedennis/agda-dodo",
"max_forks_repo_path": "src/Dodo/Binary/Cycle.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a",
"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": "sourcedennis/agda-dodo",
"max_issues_repo_path": "src/Dodo/Binary/Cycle.agda",
"max_line_length": 131,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "sourcedennis/agda-dodo",
"max_stars_repo_path": "src/Dodo/Binary/Cycle.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1822,
"size": 4301
} |
{-# OPTIONS --without-K --safe #-}
-- A "canonical" presentation of limits in Setoid.
--
-- These limits are obviously isomorphic to those created by
-- the Completeness proof, but are far less unweildy to work with.
-- This isomorphism is witnessed by Categories.Diagram.Pullback.up-to-iso
module Categories.Category.Instance.Properties.Setoids.Limits.Canonical where
open import Level
open import Data.Product using (_,_; _×_)
open import Relation.Binary.Bundles using (Setoid)
open import Function.Equality as SΠ renaming (id to ⟶-id)
import Relation.Binary.Reasoning.Setoid as SR
open import Categories.Diagram.Pullback
open import Categories.Category.Instance.Setoids
open Setoid renaming (_≈_ to [_][_≈_])
--------------------------------------------------------------------------------
-- Pullbacks
record FiberProduct {o ℓ} {X Y Z : Setoid o ℓ} (f : X ⟶ Z) (g : Y ⟶ Z) : Set (o ⊔ ℓ) where
field
elem₁ : Carrier X
elem₂ : Carrier Y
commute : [ Z ][ f ⟨$⟩ elem₁ ≈ g ⟨$⟩ elem₂ ]
open FiberProduct
pullback : ∀ (o ℓ : Level) {X Y Z : Setoid (o ⊔ ℓ) ℓ} → (f : X ⟶ Z) → (g : Y ⟶ Z) → Pullback (Setoids (o ⊔ ℓ) ℓ) f g
pullback _ _ {X = X} {Y = Y} {Z = Z} f g = record
{ P = record
{ Carrier = FiberProduct f g
; _≈_ = λ p q → [ X ][ elem₁ p ≈ elem₁ q ] × [ Y ][ elem₂ p ≈ elem₂ q ]
; isEquivalence = record
{ refl = (refl X) , (refl Y)
; sym = λ (eq₁ , eq₂) → sym X eq₁ , sym Y eq₂
; trans = λ (eq₁ , eq₂) (eq₁′ , eq₂′) → (trans X eq₁ eq₁′) , (trans Y eq₂ eq₂′)
}
}
; p₁ = record { _⟨$⟩_ = elem₁ ; cong = λ (eq₁ , _) → eq₁ }
; p₂ = record { _⟨$⟩_ = elem₂ ; cong = λ (_ , eq₂) → eq₂ }
; isPullback = record
{ commute = λ {p} {q} (eq₁ , eq₂) → trans Z (cong f eq₁) (commute q)
; universal = λ {A} {h₁} {h₂} eq → record
{ _⟨$⟩_ = λ a → record
{ elem₁ = h₁ ⟨$⟩ a
; elem₂ = h₂ ⟨$⟩ a
; commute = eq (refl A)
}
; cong = λ eq → cong h₁ eq , cong h₂ eq }
; unique = λ eq₁ eq₂ x≈y → eq₁ x≈y , eq₂ x≈y
; p₁∘universal≈h₁ = λ {_} {h₁} {_} eq → cong h₁ eq
; p₂∘universal≈h₂ = λ {_} {_} {h₂} eq → cong h₂ eq
}
}
| {
"alphanum_fraction": 0.548045977,
"avg_line_length": 34.5238095238,
"ext": "agda",
"hexsha": "5d746ca2f723cfe6b74a36c5d7347d3961e67433",
"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": "d07746023503cc8f49670e309a6170dc4b404b95",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "andrejbauer/agda-categories",
"max_forks_repo_path": "src/Categories/Category/Instance/Properties/Setoids/Limits/Canonical.agda",
"max_issues_count": 236,
"max_issues_repo_head_hexsha": "d07746023503cc8f49670e309a6170dc4b404b95",
"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": "andrejbauer/agda-categories",
"max_issues_repo_path": "src/Categories/Category/Instance/Properties/Setoids/Limits/Canonical.agda",
"max_line_length": 116,
"max_stars_count": 279,
"max_stars_repo_head_hexsha": "cfa6aefd3069d4db995191b458c886edcfba8294",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "tetrapharmakon/agda-categories",
"max_stars_repo_path": "src/Categories/Category/Instance/Properties/Setoids/Limits/Canonical.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": 769,
"size": 2175
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.