Search is not available for this dataset
text
string | meta
dict |
---|---|
{-# OPTIONS --without-K --safe #-}
module Categories.Functor.Instance.SetoidDiscrete where
-- Discrete Functor
-- from Setoids to Cats.
open import Categories.Category
open import Categories.Functor
open import Categories.Category.Instance.Setoids
open import Categories.Category.Instance.Cats
open import Categories.NaturalTransformation.NaturalIsomorphism
hiding (refl)
import Categories.Category.SetoidDiscrete as D
open import Relation.Binary
open import Function renaming (id to idf; _∘_ to _●_)
open import Function.Equality renaming (id to id⟶)
Discrete : ∀ {o ℓ e} → Functor (Setoids o ℓ) (Cats o ℓ e)
Discrete {o} {ℓ} {e} = record
{ F₀ = D.Discrete
; F₁ = DiscreteFunctor
; identity = λ {A} → DiscreteId {A}
; homomorphism = λ {X} {Y} {Z} {g} {h} → PointwiseHom {X} {Y} {Z} {g} {h}
; F-resp-≈ = λ {A} {B} {f} {g} → ExtensionalityNI {A} {B} {f} {g}
}
where
DiscreteFunctor : {A B : Setoid o ℓ} → (A ⟶ B) → Cats o ℓ e [ D.Discrete A , D.Discrete B ]
DiscreteFunctor f = record
{ F₀ = f ⟨$⟩_
; F₁ = cong f
; identity = _
; homomorphism = _
; F-resp-≈ = _
}
DiscreteId : {A : Setoid o ℓ} → NaturalIsomorphism (DiscreteFunctor {A} id⟶) id
DiscreteId {A} = record
{ F⇒G = record { η = λ _ → refl ; commute = _ }
; F⇐G = record { η = λ _ → refl ; commute = _ }
} where open Setoid A
PointwiseHom : {X Y Z : Setoid o ℓ} {g : X ⟶ Y} {h : Y ⟶ Z} →
NaturalIsomorphism (DiscreteFunctor (h ∘ g)) (DiscreteFunctor h ∘F DiscreteFunctor g)
PointwiseHom {_} {_} {Z} = record
{ F⇒G = record { η = λ _ → refl }
; F⇐G = record { η = λ _ → refl }
}
where open Setoid Z
ExtensionalityNI : {A B : Setoid o ℓ} {f g : A ⟶ B} → let open Setoid A in
({x y : Carrier} → x ≈ y → Setoid._≈_ B (f ⟨$⟩ x) (g ⟨$⟩ y)) →
NaturalIsomorphism (DiscreteFunctor f) (DiscreteFunctor g)
ExtensionalityNI {A} {B} cong≈ = record
{ F⇒G = record { η = λ X → cong≈ A.refl }
; F⇐G = record { η = λ X → B.sym (cong≈ A.refl) }
}
where
module A = Setoid A
module B = Setoid B
|
{
"alphanum_fraction": 0.5856148492,
"avg_line_length": 37.1551724138,
"ext": "agda",
"hexsha": "c42ddc3887c9675bff14a7c446af86939c332e7e",
"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": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bblfish/agda-categories",
"max_forks_repo_path": "src/Categories/Functor/Instance/SetoidDiscrete.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a",
"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": "bblfish/agda-categories",
"max_issues_repo_path": "src/Categories/Functor/Instance/SetoidDiscrete.agda",
"max_line_length": 96,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bblfish/agda-categories",
"max_stars_repo_path": "src/Categories/Functor/Instance/SetoidDiscrete.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": 770,
"size": 2155
}
|
module plfa.part1.Relations where
import Relation.Binary.PropositionalEquality as Eq
open Eq using (_≡_; refl; cong)
open import Data.Nat using (ℕ; zero; suc; _+_)
open import Data.Nat.Properties using (+-comm)
-- z≤n, s≤s - constructor names (with no spaces)
-- zero ≤ n - types (with spaces) indexed by
-- suc m ≤ suc n - 2 naturals: m and n
-- "-----------" - is just a comment (to make it look
-- like math notation for inference rule)
data _≤_ : ℕ → ℕ → Set where
-- base case
z≤n : ∀ {n : ℕ}
-------------
→ zero ≤ n
-- inductive case
s≤s : ∀ {m n : ℕ}
→ m ≤ n
-------------
→ suc m ≤ suc n
-- Base case: for all naturals n, the constructor
-- z≤n produces evidence that zero ≤ n holds.
-- Inductive case: for all naturals m and n,
-- the constructor s≤s takes evidence that m ≤ n
-- holds into evidence that suc m ≤ suc n holds.
_ : 2 ≤ 4
_ = s≤s (s≤s z≤n)
-- z≤n -----
-- 0 ≤ 2
-- s≤s -------
-- 1 ≤ 3
-- s≤s ---------
-- 2 ≤ 4
-- We can provide implicit arguments
-- explicitly by writing them inside curly braces
_ : 2 ≤ 4
_ = s≤s {1} {3} (s≤s {0} {2} (z≤n {2}))
-- 2 ≤ 4
-- suc m ≤ suc n
-- suc 1 ≤ suc 3
-- One may also identify implicit arugments by name
_ : 2 ≤ 4
_ = s≤s {n = 3} (s≤s {n = 2} z≤n)
-- Precedence
infix 4 _≤_
inv-s≤s : ∀ {m n : ℕ}
→ suc m ≤ suc n
--------------
→ m ≤ n
inv-s≤s (s≤s m≤n) = m≤n
inv-z≤n : ∀ {m : ℕ}
→ m ≤ zero
--------
→ m ≡ zero
inv-z≤n z≤n = refl
-- z≤n : zero ≤ n
-- z≤n : zero ≤ (n : ℕ)
-- (zero : ℕ)
-- z≤n : zero ≤ zero
-- refl : m ≡ m
-- refl : zero ≡ zero
|
{
"alphanum_fraction": 0.4958530806,
"avg_line_length": 21.1,
"ext": "agda",
"hexsha": "05c38ce459c3f6ee0dfef07d7fa8c66639175f77",
"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": "3429c5ef0a2636330f2d4e5e77b22605102a2247",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "vyorkin/plfa",
"max_forks_repo_path": "part1/Relations.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "3429c5ef0a2636330f2d4e5e77b22605102a2247",
"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": "vyorkin/plfa",
"max_issues_repo_path": "part1/Relations.agda",
"max_line_length": 58,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "3429c5ef0a2636330f2d4e5e77b22605102a2247",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "vyorkin/plfa",
"max_stars_repo_path": "part1/Relations.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 639,
"size": 1688
}
|
module Type{ℓ} where
open import Agda.Primitive public
using ()
renaming (Set to TYPE ; Setω to Typeω)
Type : TYPE(_)
Type = TYPE(ℓ)
{-# INLINE Type #-}
module Type where
-- Returns the type of a certain value
of : ∀{T : Type} → T → Type
of {T} _ = T
{-# INLINE of #-}
|
{
"alphanum_fraction": 0.6161971831,
"avg_line_length": 17.75,
"ext": "agda",
"hexsha": "4ea42d201de8c6d9727bcf83986fe00c4e1eea55",
"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": "Type.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": "Type.agda",
"max_line_length": 40,
"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": "Type.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": 91,
"size": 284
}
|
module _ where
open import Agda.Builtin.List
open import Agda.Builtin.Reflection
open import Agda.Builtin.Unit
postulate
A : Set
module _ (X : Set) where
macro
give : Name → Term → TC ⊤
give x goal = unify (def x []) goal
B : Set
B = give A
|
{
"alphanum_fraction": 0.6577946768,
"avg_line_length": 13.8421052632,
"ext": "agda",
"hexsha": "071d631a445053aae17eddb8b0d196c172e663cc",
"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/Issue2240.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/Issue2240.agda",
"max_line_length": 39,
"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/Issue2240.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 83,
"size": 263
}
|
{-# OPTIONS --copatterns #-}
module Issue1290 where
record R : Set1 where
constructor con
field
A : Set
open R
postulate
X : Set
x : R
A x = X
exp : R -> R
A (exp x) = A x
|
{
"alphanum_fraction": 0.5935828877,
"avg_line_length": 9.8421052632,
"ext": "agda",
"hexsha": "42b0deeb81b8bb92183500c3620d34526c860773",
"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/Issue1290.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/Issue1290.agda",
"max_line_length": 28,
"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/Issue1290.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": 67,
"size": 187
}
|
{-# OPTIONS --without-K --safe #-}
module Categories.Category.Instance.FamilyOfSetoids where
-- The Category of "Families of Setoids"
-- This fits into this library much better than the Families of Sets
-- This particular formalization should be considered alpha, i.e. its
-- names will change once things settle.
open import Level
open import Relation.Binary
using (Rel; Setoid; module Setoid; Reflexive; Symmetric; Transitive)
open import Function.Base renaming (id to idf; _∘_ to _⊚_)
open import Function.Equality
open import Function.Inverse using (_InverseOf_)
import Relation.Binary.Reasoning.Setoid as SetoidR
open import Categories.Category
module _ {a b c d : Level} where
record Fam : Set (suc (a ⊔ b ⊔ c ⊔ d)) where
constructor fam
open Setoid using () renaming (Carrier to ∣_∣; _≈_ to _≈≈_)
field
U : Setoid a b
open Setoid U hiding (Carrier)
field
T : ∣ U ∣ → Setoid c d
reindex : {x y : ∣ U ∣} (P : x ≈ y) → T y ⟶ T x
-- the following coherence laws are needed to make _≃_ below an equivalence
reindex-refl : {x : ∣ U ∣} {bx : ∣ T x ∣} → _≈≈_ (T x) (reindex refl ⟨$⟩ bx) bx
reindex-sym : {x y : ∣ U ∣} → (p : x ≈ y) → (reindex (sym p)) InverseOf (reindex p)
reindex-trans : {x y z : ∣ U ∣} {b : ∣ T z ∣} → (p : x ≈ y) → (q : y ≈ z) →
Setoid._≈_ (T x) (reindex (trans p q) ⟨$⟩ b)
(reindex p ∘ reindex q ⟨$⟩ b)
open Fam
record Hom (B B′ : Fam) : Set (a ⊔ b ⊔ c ⊔ d) where
constructor fhom
open Setoid (U B) using (_≈_)
field
map : U B ⟶ U B′
transport : (x : Setoid.Carrier (U B)) → T B x ⟶ T B′ (map ⟨$⟩ x)
transport-coh : {x y : Setoid.Carrier (U B)} → (p : x ≈ y) →
Setoid._≈_ (T B y ⇨ T B′ (map ⟨$⟩ x))
(transport x ∘ reindex B p)
(reindex B′ (Π.cong map p) ∘ transport y)
record _≈≈_ {X Y} (F F′ : (Hom X Y)) : Set (a ⊔ b ⊔ c ⊔ d) where
constructor feq
open Hom
open Setoid (U X) renaming (Carrier to A) hiding (refl; _≈_)
open Setoid (U Y)
-- the order below is chosen to simplify some of the later reasoning
field
g≈f : {x : A} → map F ⟨$⟩ x ≈ map F′ ⟨$⟩ x
φ≈γ : {x : A} → let C = T X x
D = T Y (map F ⟨$⟩ x) in
{bx : Setoid.Carrier C} → Setoid._≈_ D ((reindex Y g≈f ∘ transport F′ x) ⟨$⟩ bx) (transport F x ⟨$⟩ bx)
fam-id : {A : Fam} → Hom A A
fam-id {A} = fhom id (λ _ → id) λ p x≈y → Π.cong (reindex A p) x≈y
comp : {A B C : Fam} → Hom B C → Hom A B → Hom A C
comp {B = B} {C} (fhom map₀ trans₀ coh₀) (fhom map₁ trans₁ coh₁) =
fhom (map₀ ∘ map₁) (λ x → trans₀ (map₁ ⟨$⟩ x) ∘ (trans₁ x))
λ {a} {b} p {x} {y} x≈y →
let open Setoid (T C (map₀ ∘ map₁ ⟨$⟩ a)) renaming (trans to _⟨≈⟩_) in
Π.cong (trans₀ (map₁ ⟨$⟩ a)) (coh₁ p x≈y) ⟨≈⟩
coh₀ (Π.cong map₁ p) (Setoid.refl (T B (map₁ ⟨$⟩ b)))
≈≈-refl : ∀ {A B} → Reflexive (_≈≈_ {A} {B})
≈≈-refl {B = B} = feq refl (reindex-refl B)
where open Setoid (U B)
≈≈-sym : ∀ {A B} → Symmetric (_≈≈_ {A} {B})
≈≈-sym {A} {B} {F} {G} (feq g≈f φ≈γ) = feq (sym g≈f)
λ {x} {bx} → Setoid.trans ( T B (map G ⟨$⟩ x) )
(Π.cong (reindex B (sym g≈f)) (Setoid.sym (T B (map F ⟨$⟩ x)) φ≈γ))
(left-inverse-of (reindex-sym B g≈f) (transport G x ⟨$⟩ bx))
where
open Setoid (U B) using (sym; Carrier)
open Hom
open _InverseOf_
≈≈-trans : ∀ {A B} → Transitive (_≈≈_ {A} {B})
≈≈-trans {A} {B} {F} {G} {H} (feq ≈₁ t₁) (feq ≈₂ t₂) =
feq (trans ≈₁ ≈₂) (λ {x} {bx} →
let open Setoid (T B (Hom.map F ⟨$⟩ x)) renaming (trans to _⟨≈⟩_) in
reindex-trans B ≈₁ ≈₂ ⟨≈⟩ (Π.cong (reindex B ≈₁) t₂ ⟨≈⟩ t₁))
where
open Setoid (U B) using (trans)
comp-resp-≈≈ : {A B C : Fam} {f h : Hom B C} {g i : Hom A B} →
f ≈≈ h → g ≈≈ i → comp f g ≈≈ comp h i
comp-resp-≈≈ {A} {B} {C} {f} {h} {g} {i} (feq f≈h t-f≈h) (feq g≈i t-g≈i) =
feq (trans (Π.cong (map f) g≈i) f≈h)
λ {x} → let open Setoid (T C (map (comp f g) ⟨$⟩ x)) renaming (trans to _⟨≈⟩_; sym to ≈sym) in
reindex-trans C (cong (map f) g≈i) f≈h ⟨≈⟩
(Π.cong (reindex C (cong (map f) g≈i)) t-f≈h ⟨≈⟩
(≈sym (transport-coh {B} {C} f g≈i (Setoid.refl (T B (map i ⟨$⟩ x)))) ⟨≈⟩
Π.cong (transport f (map g ⟨$⟩ x)) t-g≈i))
where
open _≈≈_
open Setoid (U C)
open Hom
Cat : Category (suc (a ⊔ b ⊔ c ⊔ d)) (a ⊔ b ⊔ c ⊔ d) (a ⊔ b ⊔ c ⊔ d)
Cat = record
{ Obj = Fam
; _⇒_ = Hom
; _≈_ = _≈≈_
; id = fam-id
; _∘_ = comp
; assoc = λ {_} {_} {_} {_} {f} {g} {h} → assoc′ {f = f} {g} {h}
; sym-assoc = λ {_} {_} {_} {_} {f} {g} {h} → ≈≈-sym (assoc′ {f = f} {g} {h})
; identityˡ = λ {_} {B} → feq (Setoid.refl (U B)) (reindex-refl B)
; identityʳ = λ {_} {B} → feq (Setoid.refl (U B)) (reindex-refl B)
; identity² = λ {A} → feq (Setoid.refl (U A)) (reindex-refl A)
; equiv = λ {A} {B} → let open Setoid (U B) in record
{ refl = ≈≈-refl
; sym = ≈≈-sym
; trans = ≈≈-trans
}
; ∘-resp-≈ = comp-resp-≈≈
}
where
open _InverseOf_
assoc′ : {A B C D : Fam} {f : Hom A B} {g : Hom B C} {h : Hom C D} →
comp (comp h g) f ≈≈ comp h (comp g f)
assoc′ {D = D} = feq (Setoid.refl (U D)) (reindex-refl D)
open Category Cat public
FamilyOfSetoids : ∀ a b c d → Category (suc (a ⊔ b ⊔ c ⊔ d)) (a ⊔ b ⊔ c ⊔ d) (a ⊔ b ⊔ c ⊔ d)
FamilyOfSetoids a b c d = Cat {a} {b} {c} {d}
|
{
"alphanum_fraction": 0.5138253067,
"avg_line_length": 39.5724637681,
"ext": "agda",
"hexsha": "cdd98317cf042b558cc643eb0b4ae4df07a574bb",
"lang": "Agda",
"max_forks_count": 64,
"max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z",
"max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Code-distancing/agda-categories",
"max_forks_repo_path": "src/Categories/Category/Instance/FamilyOfSetoids.agda",
"max_issues_count": 236,
"max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Code-distancing/agda-categories",
"max_issues_repo_path": "src/Categories/Category/Instance/FamilyOfSetoids.agda",
"max_line_length": 115,
"max_stars_count": 279,
"max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Trebor-Huang/agda-categories",
"max_stars_repo_path": "src/Categories/Category/Instance/FamilyOfSetoids.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": 2365,
"size": 5461
}
|
-- | In this module, we proof that the 2-category of endofunctors
-- inherits locally all colimits from underlying category.
-- More precisely, for a functor F : C → C, we compute in Endo(F, F)
-- colimits point-wise from those in C.
module UpToColim where
open import Level
open import Relation.Binary using (Rel; IsEquivalence)
open import Data.Product
open import Categories.Support.Equivalence
open import Categories.Category
open import Categories.2-Category
open import Categories.Functor
open import Categories.NaturalTransformation
renaming (id to natId; _≡_ to _≡N_; setoid to natSetoid)
hiding (_∘ˡ_; _∘ʳ_)
open import Categories.Support.EqReasoning
open import Categories.Colimit
open import Categories.Cocones
open import Categories.Cocone
open import Categories.Object.Initial
open import Categories.Functor.Constant
open import NaturalTransFacts
open import UpTo
-- _⇒_ = NaturalTransformation
EndoDiagram : (C : Cat₀) → (F : EndoFunctor C) → (I : Cat₀) → Set
EndoDiagram C F I = Functor I (EndoMor (C , F) (C , F))
PW-Diagram : {C : Cat₀} → {F : EndoFunctor C} → {I : Cat₀} →
EndoDiagram C F I → (X : Category.Obj C) →
Functor I C
PW-Diagram {C} {F} {I} D X =
record
{ F₀ = λ i → Functor.F₀ (Endo⇒.T (D.F₀ i)) X
; F₁ = λ h → NaturalTransformation.η (UpTo⇒.γ (D.F₁ h)) X
; identity = ≡U-proof D.identity
; homomorphism = ≡U-proof D.homomorphism
; F-resp-≡ = λ x → ≡U-proof (D.F-resp-≡ x)
}
where
module C = Category C
module D = Functor D
module I = Category I
open _≡U_
EndoMor-inherit-colim : {C : Cat₀} → (F : EndoFunctor C) →
{I : Cat₀} → (D : EndoDiagram C F I) →
((X : Category.Obj C) → Colimit (PW-Diagram D X)) →
Colimit D
EndoMor-inherit-colim {C} F {I} D c =
record
{ initial = record
{ ⊥ = colim-D
; ! = out
; !-unique = out-unique
}
}
where
-- Notations
module C = Category C
module I = Category I
module CC-D = Category (Cocones D)
-- Components of F
F₀ = Functor.F₀ F
F₁ = Functor.F₁ F
-- Components of the diagram D
D₀ = Functor.F₀ D
D₁ = Functor.F₁ D
-- Tᵢ = π₁(D(i))
T : (i : I.Obj) → Functor C C
T i = Endo⇒.T (D₀ i)
-- Components of T
T₀ = λ i → Functor.F₀ (T i)
T₁ = λ i {A} {B} → Functor.F₁ (T i) {A} {B}
-- ρᵢA = π₂(D(i))
ρ : (i : I.Obj) → (T i ∘ F) ⇒ (F ∘ T i)
ρ i = Endo⇒.ρ (D₀ i)
ρη : (i : I.Obj) → (A : C.Obj) → C [ T₀ i (F₀ A) , F₀ (T₀ i A) ]
ρη i A = NaturalTransformation.η (ρ i) A
-- The natural transformation (w/o proof) D(f) : D(i) ⇒ D(i)
D₁η : ∀ {i j} → (f : I [ i , j ]) →
(A : C.Obj) → C [ T₀ i A , T₀ j A ]
D₁η f A = NaturalTransformation.η (UpTo⇒.γ (D₁ f)) A
----- Construction of the colimit -----
-- It is given by the cocone (colim-T, ρ).
-- Action of colim-T on objects
colim-T₀ : C.Obj → C.Obj
colim-T₀ A = CL.∃F
where
module CL = Colimit (c A)
-- Injection into colim DX
κ : (i : I.Obj) → (X : C.Obj) → C [ T₀ i X , Colimit.∃F (c X) ]
κ i X = Colimit.Ic.ψ (c X) i
-- Given a morphism u : A → B in C, we construct a cocone DA ⇒ colim DB,
-- which will give us then T(u) by the universal property of colim DA.
-- The components of the cocone are given by κBᵢ ∘ Tᵢ(u) : T₁(A) → colim DB,
-- where we use that Tᵢ(A) = DA(i).
cocone-T₁ : {A B : C.Obj} →
C [ A , B ] → Category.Obj (Cocones (PW-Diagram D A))
cocone-T₁ {A} {B} u = record
{ N = colim-T₀ B
; ψ = λ i → C [ κB i ∘ T₁ i u ]
; commute = comm
}
where
module CA = Colimit (c A)
module PW-Cocones-A = Category (Cocones (PW-Diagram D A))
module CB = Colimit (c B)
DA = PW-Diagram D A
module DA = Functor DA
DB = PW-Diagram D B
module DB = Functor DB
-- Injection into colim DB
κB : (i : I.Obj) → C [ T₀ i B , CB.∃F ]
κB i = NaturalTransformation.η CB.ι i
.comm : {i j : I.Obj} (f : I [ i , j ]) →
C [ κB i ∘ T₁ i u ] C.≡ C [ κB j ∘ T₁ j u ] C.∘ DA.F₁ f
comm {i} {j} f =
begin
C [ κB i ∘ T₁ i u ]
↓⟨ C.∘-resp-≡ˡ (Colimit.Ic.commute (c B) f) ⟩
(κB j C.∘ DB.F₁ f) C.∘ T₁ i u
↓⟨ C.assoc ⟩
κB j C.∘ (DB.F₁ f C.∘ T₁ i u)
↓⟨ C.∘-resp-≡ʳ
(NaturalTransformation.commute (UpTo⇒.γ (D₁ f)) u)
⟩
κB j C.∘ (T₁ j u C.∘ DA.F₁ f)
↑⟨ C.assoc ⟩
C [ κB j ∘ T₁ j u ] C.∘ DA.F₁ f
∎
where
open SetoidReasoning (C.hom-setoid {DA.F₀ i} {colim-T₀ B})
-- Action of colim-T on morphisms
colim-T₁ : {A B : C.Obj} → C [ A , B ] → C [ colim-T₀ A , colim-T₀ B ]
colim-T₁ {A} {B} u = CoconeMorphism.f (CA.I.! {cocone-T₁ u})
where
module CA = Colimit (c A)
-- Proof that T(id_A) = id_{T(A)}
.colim-T-id : ∀ {A : C.Obj} →
C [ colim-T₁ (C.id {A}) ≡ C.id {colim-T₀ A} ]
colim-T-id {A} = CA.I.⊥-id (record
{ f = colim-T₁ (C.id {A})
; commute = λ {i} →
let open SetoidReasoning (C.hom-setoid {DA.F₀ i} {colim-T₀ A})
in begin
C [ colim-T₁ (C.id {A}) ∘ κ i A ]
-- colimit property of T(id) = [κ i A ∘ id]_{i ∈ I}
↓⟨ CoconeMorphism.commute (CA.I.! {cocone-T₁ (C.id {A})}) ⟩
C [ κ i A ∘ T₁ i (C.id {A}) ]
-- Functoriality of Tᵢ
↓⟨ C.∘-resp-≡ʳ (Functor.identity (T i)) ⟩
C [ κ i A ∘ C.id {T₀ i A} ]
↓⟨ C.identityʳ ⟩
κ i A
∎
})
where
module CA = Colimit (c A)
module DA = Functor (PW-Diagram D A)
-- Proof that T(g ∘ f) = Tg ∘ Tf
.colim-T-hom : {X Y Z : C.Obj} {f : C [ X , Y ]} {g : C [ Y , Z ]} →
colim-T₁ (C [ g ∘ f ]) C.≡ C [ colim-T₁ g ∘ colim-T₁ f ]
colim-T-hom {X} {Y} {Z} {f} {g} = CX.I.!-unique CX⇒TgTf
where
module CX = Colimit (c X)
module CY = Colimit (c Y)
module DX = Functor (PW-Diagram D X)
module CC-DX = Category (Cocones (PW-Diagram D X))
-- Show that Tg ∘ Tf is a cocone for T(g ∘ f), which implies that
-- Tg ∘ Tf = T(g ∘ f).
-- To achieve this, we need to show that for each i ∈ I, we have
-- Tg ∘ Tf ∘ κ i X = κ i Z ∘ Tᵢ (g ∘ f).
CX⇒TgTf : Colimit.I.⊥ (c X) CC-DX.⇒ cocone-T₁ (C [ g ∘ f ])
CX⇒TgTf = record
{ f = C [ colim-T₁ g ∘ colim-T₁ f ]
; commute = λ {i : I.Obj} →
let open SetoidReasoning (C.hom-setoid {DX.F₀ i} {colim-T₀ Z})
in begin
C [ colim-T₁ g ∘ colim-T₁ f ] C.∘ κ i X
↓⟨ C.assoc ⟩
colim-T₁ g C.∘ (colim-T₁ f C.∘ κ i X)
↓⟨ C.∘-resp-≡ʳ
(CoconeMorphism.commute (CX.I.! {cocone-T₁ f}))
⟩
colim-T₁ g C.∘ (κ i Y C.∘ T₁ i f)
↑⟨ C.assoc ⟩
(colim-T₁ g C.∘ κ i Y) C.∘ T₁ i f
↓⟨ C.∘-resp-≡ˡ
(CoconeMorphism.commute (CY.I.! {cocone-T₁ g}))
⟩
(κ i Z C.∘ T₁ i g) C.∘ T₁ i f
↓⟨ C.assoc ⟩
κ i Z C.∘ (T₁ i g C.∘ T₁ i f)
↑⟨ C.∘-resp-≡ʳ (Functor.homomorphism (T i)) ⟩
C [ κ i Z ∘ T₁ i (g C.∘ f) ]
∎
}
-- Proof that T respects the equality of C.
.colim-T-resp-≡ : {A B : C.Obj} {f : C [ A , B ]} {g : C [ A , B ]} →
C [ f ≡ g ] → C [ colim-T₁ f ≡ colim-T₁ g ]
colim-T-resp-≡ {A} {B} {f} {g} f≡g = CA.I.!-unique CA⇒Tg
where
module CA = Colimit (c A)
module DA = Functor (PW-Diagram D A)
module CC-DA = Category (Cocones (PW-Diagram D A))
-- That T respects ≡ is inherited point-wise from the fact that
-- each Tᵢ respects ≡.
CA⇒Tg : Colimit.I.⊥ (c A) CC-DA.⇒ cocone-T₁ f
CA⇒Tg = record
{ f = colim-T₁ g
; commute = λ {i} →
let open SetoidReasoning (C.hom-setoid {DA.F₀ i} {colim-T₀ B})
in begin
C [ colim-T₁ g ∘ κ i A ]
↓⟨ CoconeMorphism.commute (CA.I.! {cocone-T₁ g}) ⟩
C [ κ i B ∘ T₁ i g ]
↑⟨ C.∘-resp-≡ʳ (Functor.F-resp-≡ (T i) f≡g) ⟩
C [ κ i B ∘ T₁ i f ]
∎
}
-- The colimiting up-to technique
colim-T : Functor C C
colim-T = record
{ F₀ = colim-T₀
; F₁ = colim-T₁
; identity = colim-T-id
; homomorphism = colim-T-hom
; F-resp-≡ = colim-T-resp-≡
}
-- Cocone to construct ρ = [F₁ (κᵢ A) ∘ ρᵢ A]_{i ∈ I}
cocone-ρ : {A : C.Obj} →
Category.Obj (Cocones (PW-Diagram D (F₀ A)))
cocone-ρ {A} = record
{ N = F₀ (colim-T₀ A)
; ψ = λ i → C [ F₁ (κ i A) ∘ ρη i A ]
; commute = λ {i} {j} f →
let open SetoidReasoning (C.hom-setoid {T₀ i (F₀ A)} {F₀ (colim-T₀ A)})
in begin
C [ F₁ (κ i A) ∘ ρη i A ]
↓⟨ C.∘-resp-≡ˡ (Functor.F-resp-≡ F (CA.Ic.commute f)) ⟩
C [ F₁ ((κ j A) C.∘ (DA.F₁ f)) ∘ ρη i A ]
↓⟨ C.∘-resp-≡ˡ (Functor.homomorphism F) ⟩
C [ C [ F₁ (κ j A) ∘ F₁ (DA.F₁ f) ] ∘ ρη i A ]
↓⟨ C.assoc ⟩
C [ F₁ (κ j A) ∘ C [ F₁ (DA.F₁ f) ∘ ρη i A ] ]
↓⟨ C.∘-resp-≡ʳ (lemma f) ⟩
C [ F₁ (κ j A) ∘ C [ ρη j A ∘ DFA.F₁ f ] ]
↑⟨ C.assoc ⟩
C [ F₁ (κ j A) ∘ ρη j A ] C.∘ DFA.F₁ f
∎
}
where
module CA = Colimit (c A)
module DA = Functor (PW-Diagram D A)
module DFA = Functor (PW-Diagram D (F₀ A))
-- Lemma to turn the commuting square for ρ into the equation we need
.lemma : {i j : I.Obj} → (f : I [ i , j ]) →
C [ F₁ (DA.F₁ f) ∘ ρη i A ] C.≡ C [ ρη j A ∘ DFA.F₁ f ]
lemma {i} {j} f =
begin
C [ F₁ (DA.F₁ f) ∘ ρη i A ]
↑⟨ C.∘-resp-≡ˡ C.identityʳ ⟩
C [ C [ F₁ (DA.F₁ f) ∘ C.id {F₀ (DA.F₀ i)} ] ∘ ρη i A ]
↑⟨ UpTo⇒.square (D₁ f) {A} ⟩
C [ ρη j A ∘ C [ T₁ j (C.id {F₀ A}) ∘ (DFA.F₁ f) ] ]
↓⟨ C.∘-resp-≡ʳ (C.∘-resp-≡ˡ
(Functor.identity (T j)))
⟩
C [ ρη j A ∘ C [ C.id {T₀ j (F₀ A)} ∘ (DFA.F₁ f) ] ]
↓⟨ C.∘-resp-≡ʳ C.identityˡ ⟩
C [ ρη j A ∘ DFA.F₁ f ]
∎
where
open SetoidReasoning (C.hom-setoid {T₀ i (F₀ A)} {F₀ (T₀ j A)})
colim-ρ-η : (A : C.Obj) → C [ colim-T₀ (F₀ A) , F₀ (colim-T₀ A) ]
colim-ρ-η A = CoconeMorphism.f (CFA.I.! {cocone-ρ})
where
module CFA = Colimit (c (F₀ A))
-- Natural transformation to make colim-T indeed an up-to technique
colim-ρ : (colim-T ∘ F) ⇒ (F ∘ colim-T)
colim-ρ = record
{ η = colim-ρ-η
; commute = λ {A} {B} f →
let open SetoidReasoning
(C.hom-setoid {colim-T₀ (F₀ A)} {F₀ (colim-T₀ B)})
in begin
C [ colim-ρ-η B ∘ colim-T₁ (F₁ f) ]
↓⟨ {!!} ⟩
C [ F₁ (colim-T₁ f) ∘ colim-ρ-η A ]
∎
}
where
colim-Endo : Endo⇒ C F C F
colim-Endo = record
{ T = colim-T
; ρ = colim-ρ
}
colim-ψ : (i : I.Obj) → UpTo⇒ (D₀ i) colim-Endo
colim-ψ i = record
{ γ = record
{ η = λ X → κ i X
; commute = {!!}
}
; square = {!!}
}
colim-D : CC-D.Obj
colim-D =
record
{ N = colim-Endo
; ψ = colim-ψ
; commute = {!!}
}
out : ∀ {A : CC-D.Obj} → colim-D CC-D.⇒ A
out = {!!}
out-unique : {A : CC-D.Obj} (f : colim-D CC-D.⇒ A) → out CC-D.≡ f
out-unique = {!!}
|
{
"alphanum_fraction": 0.4713212701,
"avg_line_length": 33.1898016997,
"ext": "agda",
"hexsha": "60ea5973410aa6f3419935e9e767c08513344880",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "hbasold/Sandbox",
"max_forks_repo_path": "UpTo-Properties/UpToColim.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "hbasold/Sandbox",
"max_issues_repo_path": "UpTo-Properties/UpToColim.agda",
"max_line_length": 80,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "hbasold/Sandbox",
"max_stars_repo_path": "UpTo-Properties/UpToColim.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 4627,
"size": 11716
}
|
module _ where
open import Agda.Builtin.Equality
module MM1 (A : Set) where
postulate a0 : A
module M1 (a : A) where
postulate
x : A
module M = M1 a0
module MM2 (A : Set) where
open module MM1A = MM1 A
check : M1.x ≡ (λ a → a)
check = refl -- used to be internal error
|
{
"alphanum_fraction": 0.618729097,
"avg_line_length": 14.95,
"ext": "agda",
"hexsha": "a1565b8be26fddded38020b93f43474be2252de7",
"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/Issue2247.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/Issue2247.agda",
"max_line_length": 44,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/Issue2247.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 107,
"size": 299
}
|
{-# OPTIONS --without-K --rewriting #-}
{- Remember to keep CodeAP.agda in sync. -}
open import HoTT
import homotopy.RelativelyConstantToSetExtendsViaSurjection as SurjExt
module homotopy.vankampen.CodeBP {i j k l}
(span : Span {i} {j} {k})
{D : Type l} (h : D → Span.C span) (h-is-surj : is-surj h) where
open Span span
data precodeBB (b₀ : B) : B → Type (lmax (lmax (lmax i j) k) l)
data precodeBA (b₀ : B) (a₁ : A) : Type (lmax (lmax (lmax i j) k) l)
data precodeBB b₀ where
pc-b : ∀ {b₁} (pB : b₀ =₀ b₁) → precodeBB b₀ b₁
pc-bab : ∀ d {b₁} (pc : precodeBA b₀ (f (h d))) (pB : g (h d) =₀ b₁) → precodeBB b₀ b₁
infix 66 pc-b
syntax pc-b p = ⟧b p
infixl 65 pc-bab
syntax pc-bab d pcBA pB = pcBA ba⟦ d ⟧b pB
data precodeBA b₀ a₁ where
pc-bba : ∀ d (pc : precodeBB b₀ (g (h d))) (pA : f (h d) =₀ a₁) → precodeBA b₀ a₁
infixl 65 pc-bba
syntax pc-bba d pcBB pA = pcBB bb⟦ d ⟧a pA
data precodeBB-rel {b₀ : B} : {b₁ : B}
→ precodeBB b₀ b₁ → precodeBB b₀ b₁ → Type (lmax (lmax (lmax i j) k) l)
data precodeBA-rel {b₀ : B} : {a₁ : A}
→ precodeBA b₀ a₁ → precodeBA b₀ a₁ → Type (lmax (lmax (lmax i j) k) l)
data precodeBB-rel {b₀} where
pcBBr-idp₀-idp₀ : ∀ {d} pcBB → precodeBB-rel (pcBB bb⟦ d ⟧a idp₀ ba⟦ d ⟧b idp₀) pcBB
pcBBr-switch : ∀ {d₀ d₁ : D} pcBB (pC : h d₀ =₀ h d₁)
→ precodeBB-rel (pcBB bb⟦ d₀ ⟧a ap₀ f pC ba⟦ d₁ ⟧b idp₀) (pcBB bb⟦ d₀ ⟧a idp₀ ba⟦ d₀ ⟧b ap₀ g pC)
pcBBr-cong : ∀ {d b₁ pcBA₁ pcBA₂} (r : precodeBA-rel pcBA₁ pcBA₂) (pB : g (h d) =₀ b₁)
→ precodeBB-rel (pcBA₁ ba⟦ d ⟧b pB) (pcBA₂ ba⟦ d ⟧b pB)
data precodeBA-rel {b₀} where
pcBAr-idp₀-idp₀ : ∀ {d} pcBA → precodeBA-rel (pcBA ba⟦ d ⟧b idp₀ bb⟦ d ⟧a idp₀) pcBA
pcBAr-cong : ∀ {d a₁ pcBB₁ pcBB₂} (r : precodeBB-rel pcBB₁ pcBB₂) (pA : f (h d) =₀ a₁)
→ precodeBA-rel (pcBB₁ bb⟦ d ⟧a pA) (pcBB₂ bb⟦ d ⟧a pA)
codeBB : B → B → Type (lmax (lmax (lmax i j) k) l)
codeBB b₀ b₁ = SetQuot (precodeBB-rel {b₀} {b₁})
codeBA : B → A → Type (lmax (lmax (lmax i j) k) l)
codeBA b₀ a₁ = SetQuot (precodeBA-rel {b₀} {a₁})
c-bba : ∀ {a₀} d {a₁} (pc : codeBB a₀ (g (h d))) (pA : f (h d) =₀ a₁) → codeBA a₀ a₁
c-bba d {a₁} c pA = SetQuot-rec SetQuot-is-set
(λ pc → q[ pc-bba d pc pA ])
(λ r → quot-rel $ pcBAr-cong r pA) c
c-bab : ∀ {a₀} d {b₁} (pc : codeBA a₀ (f (h d))) (pB : g (h d) =₀ b₁) → codeBB a₀ b₁
c-bab d {a₁} c pB = SetQuot-rec SetQuot-is-set
(λ pc → q[ pc-bab d pc pB ])
(λ r → quot-rel $ pcBBr-cong r pB) c
-- codeBP
abstract
pcBB-idp₀-idp₀-head : ∀ {d₀ b} (pB : g (h d₀) =₀ b)
→ q[ ⟧b idp₀ bb⟦ d₀ ⟧a idp₀ ba⟦ d₀ ⟧b pB ] == q[ ⟧b pB ] :> codeBB _ b
pcBB-idp₀-idp₀-head {d₀} = Trunc-elim (λ _ → =-preserves-set SetQuot-is-set) lemma where
lemma : ∀ {b} (pB : g (h d₀) == b)
→ q[ ⟧b idp₀ bb⟦ d₀ ⟧a idp₀ ba⟦ d₀ ⟧b [ pB ] ] == q[ ⟧b [ pB ] ] :> codeBB _ b
lemma idp = quot-rel $ pcBBr-idp₀-idp₀ (⟧b idp₀)
pcBA-prepend : ∀ {b₀} d₁ {b₂} → b₀ =₀ g (h d₁) → precodeBA (g (h d₁)) b₂ → precodeBA b₀ b₂
pcBB-prepend : ∀ {b₀} d₁ {a₂} → b₀ =₀ g (h d₁) → precodeBB (g (h d₁)) a₂ → precodeBB b₀ a₂
pcBA-prepend d₁ pB (pc-bba d pc pA) = pc-bba d (pcBB-prepend d₁ pB pc) pA
pcBB-prepend d₁ pB (pc-b pB₁) = pc-bab d₁ (pc-bba d₁ (pc-b pB) idp₀) pB₁
pcBB-prepend d₁ pB (pc-bab d pc pB₁) = pc-bab d (pcBA-prepend d₁ pB pc) pB₁
abstract
pcBA-prepend-idp₀ : ∀ {d₀ b₁} (pcBA : precodeBA (g (h d₀)) b₁)
→ q[ pcBA-prepend d₀ idp₀ pcBA ] == q[ pcBA ] :> codeBA (g (h d₀)) b₁
pcBB-prepend-idp₀ : ∀ {d₀ a₁} (pcBB : precodeBB (g (h d₀)) a₁)
→ q[ pcBB-prepend d₀ idp₀ pcBB ] == q[ pcBB ] :> codeBB (g (h d₀)) a₁
pcBA-prepend-idp₀ (pc-bba d pc pB) = pcBB-prepend-idp₀ pc |in-ctx λ c → c-bba d c pB
pcBB-prepend-idp₀ (pc-b pB) = pcBB-idp₀-idp₀-head pB
pcBB-prepend-idp₀ (pc-bab d pc pB) = pcBA-prepend-idp₀ pc |in-ctx λ c → c-bab d c pB
transp-cBA-l : ∀ d {b₀ a₁} (p : g (h d) == b₀) (pcBA : precodeBA (g (h d)) a₁)
→ transport (λ x → codeBA x a₁) p q[ pcBA ] == q[ pcBA-prepend d [ ! p ] pcBA ]
transp-cBA-l d idp pcBA = ! $ pcBA-prepend-idp₀ pcBA
transp-cBB-l : ∀ d {b₀ b₁} (p : g (h d) == b₀) (pcBB : precodeBB (g (h d)) b₁)
→ transport (λ x → codeBB x b₁) p q[ pcBB ] == q[ pcBB-prepend d [ ! p ] pcBB ]
transp-cBB-l d idp pcBB = ! $ pcBB-prepend-idp₀ pcBB
transp-cBA-r : ∀ d {b₀ a₁} (p : f (h d) == a₁) (pcBA : precodeBA b₀ (f (h d)))
→ transport (λ x → codeBA b₀ x) p q[ pcBA ] == q[ pcBA ba⟦ d ⟧b idp₀ bb⟦ d ⟧a [ p ] ]
transp-cBA-r d idp pcBA = ! $ quot-rel $ pcBAr-idp₀-idp₀ pcBA
transp-cBB-r : ∀ d {b₀ b₁} (p : g (h d) == b₁) (pcBB : precodeBB b₀ (g (h d)))
→ transport (λ x → codeBB b₀ x) p q[ pcBB ] == q[ pcBB bb⟦ d ⟧a idp₀ ba⟦ d ⟧b [ p ] ]
transp-cBB-r d idp pcBB = ! $ quot-rel $ pcBBr-idp₀-idp₀ pcBB
module CodeBAEquivCodeBB (b₀ : B) where
eqv-on-image : (d : D) → codeBA b₀ (f (h d)) ≃ codeBB b₀ (g (h d))
eqv-on-image d = equiv to from to-from from-to where
to = λ c → c-bab d c idp₀
from = λ c → c-bba d c idp₀
abstract
from-to : ∀ cBA → from (to cBA) == cBA
from-to = SetQuot-elim
(λ _ → =-preserves-set SetQuot-is-set)
(λ pcBA → quot-rel (pcBAr-idp₀-idp₀ pcBA))
(λ _ → prop-has-all-paths-↓ (SetQuot-is-set _ _))
to-from : ∀ cBB → to (from cBB) == cBB
to-from = SetQuot-elim
(λ _ → =-preserves-set SetQuot-is-set)
(λ pcBB → quot-rel (pcBBr-idp₀-idp₀ pcBB))
(λ _ → prop-has-all-paths-↓ (SetQuot-is-set _ _))
abstract
eqv-is-const : ∀ d₁ d₂ (p : h d₁ == h d₂)
→ eqv-on-image d₁ == eqv-on-image d₂
[ (λ c → codeBA b₀ (f c) ≃ codeBB b₀ (g c)) ↓ p ]
eqv-is-const d₁ d₂ p = ↓-Subtype-in (λ d → is-equiv-prop) $
↓-→-from-transp $ λ= $
SetQuot-elim (λ _ → =-preserves-set SetQuot-is-set)
(λ pcBA →
transport (λ c → codeBB b₀ (g c)) p q[ pcBA ba⟦ d₁ ⟧b idp₀ ]
=⟨ ap-∘ (codeBB b₀) g p |in-ctx (λ p → coe p q[ pcBA ba⟦ d₁ ⟧b idp₀ ]) ⟩
transport (codeBB b₀) (ap g p) q[ pcBA ba⟦ d₁ ⟧b idp₀ ]
=⟨ transp-cBB-r d₁ (ap g p) (pcBA ba⟦ d₁ ⟧b idp₀) ⟩
q[ pcBA ba⟦ d₁ ⟧b idp₀ bb⟦ d₁ ⟧a idp₀ ba⟦ d₁ ⟧b [ ap g p ] ]
=⟨ ! $ quot-rel $ pcBBr-switch (pcBA ba⟦ d₁ ⟧b idp₀) [ p ] ⟩
q[ pcBA ba⟦ d₁ ⟧b idp₀ bb⟦ d₁ ⟧a [ ap f p ] ba⟦ d₂ ⟧b idp₀ ]
=⟨ ! $ transp-cBA-r d₁ (ap f p) pcBA |in-ctx (λ c → c-bab d₂ c idp₀) ⟩
c-bab d₂ (transport (codeBA b₀) (ap f p) q[ pcBA ]) idp₀
=⟨ ∘-ap (codeBA b₀) f p |in-ctx (λ p → coe p q[ pcBA ]) |in-ctx (λ c → c-bab d₂ c idp₀) ⟩
c-bab d₂ (transport (λ c → codeBA b₀ (f c)) p q[ pcBA ]) idp₀
=∎)
(λ _ → prop-has-all-paths-↓ (SetQuot-is-set _ _))
module SE = SurjExt
(λ c → ≃-is-set SetQuot-is-set SetQuot-is-set)
h h-is-surj
eqv-on-image
eqv-is-const
abstract
eqv : ∀ c → codeBA b₀ (f c) ≃ codeBB b₀ (g c)
eqv = SE.ext
eqv-β : ∀ d → eqv (h d) == eqv-on-image d
eqv-β = SE.β
module CodeBP (b₀ : B) = PushoutRec (codeBA b₀) (codeBB b₀)
(ua ∘ CodeBAEquivCodeBB.eqv b₀)
codeBP : B → Pushout span → Type (lmax (lmax (lmax i j) k) l)
codeBP = CodeBP.f
abstract
codeBP-level : ∀ {a₀ p₁} → is-set (codeBP a₀ p₁)
codeBP-level {a₀} {p₁} = Pushout-elim
{P = λ p₁ → is-set (codeBP a₀ p₁)}
(λ a₁ → SetQuot-is-set)
(λ b₁ → SetQuot-is-set)
(λ c₁ → prop-has-all-paths-↓ is-set-is-prop)
p₁
codeBP-is-set = codeBP-level
abstract
transp-cBP-glue : ∀ {b₀} d₁ (pcBA : precodeBA b₀ (f (h d₁)))
→ transport (codeBP b₀) (glue (h d₁)) q[ pcBA ] == q[ pcBA ba⟦ d₁ ⟧b idp₀ ]
transp-cBP-glue {b₀} d₁ pcBA =
transport (codeBP b₀) (glue (h d₁)) q[ pcBA ]
=⟨ ap (λ e → coe e q[ pcBA ]) (CodeBP.glue-β b₀ (h d₁) ∙ ap ua (CodeBAEquivCodeBB.eqv-β b₀ d₁)) ⟩
coe (ua (CodeBAEquivCodeBB.eqv-on-image b₀ d₁)) q[ pcBA ]
=⟨ coe-β (CodeBAEquivCodeBB.eqv-on-image b₀ d₁) q[ pcBA ] ⟩
q[ pcBA ba⟦ d₁ ⟧b idp₀ ]
=∎
transp-cBP-!glue : ∀ {b₀} d₁ (pcBB : precodeBB b₀ (g (h d₁)))
→ transport (codeBP b₀) (! (glue (h d₁))) q[ pcBB ] == q[ pcBB bb⟦ d₁ ⟧a idp₀ ]
transp-cBP-!glue {b₀} d₁ pcBB =
transport (codeBP b₀) (! (glue (h d₁))) q[ pcBB ]
=⟨ ap (λ e → coe e q[ pcBB ]) (ap-! (codeBP b₀) (glue (h d₁)))
∙ coe-! (ap (codeBP b₀) (glue (h d₁))) q[ pcBB ] ⟩
transport! (codeBP b₀) (glue (h d₁)) q[ pcBB ]
=⟨ ap (λ e → coe! e q[ pcBB ]) (CodeBP.glue-β b₀ (h d₁) ∙ ap ua (CodeBAEquivCodeBB.eqv-β b₀ d₁)) ⟩
coe! (ua (CodeBAEquivCodeBB.eqv-on-image b₀ d₁)) q[ pcBB ]
=⟨ coe!-β (CodeBAEquivCodeBB.eqv-on-image b₀ d₁) q[ pcBB ] ⟩
q[ pcBB bb⟦ d₁ ⟧a idp₀ ]
=∎
-- code to path
pcBA-to-path : ∀ {b₀ a₁} → precodeBA b₀ a₁ → right b₀ =₀ left a₁ :> Pushout span
pcBB-to-path : ∀ {b₀ b₁} → precodeBB b₀ b₁ → right b₀ =₀ right b₁ :> Pushout span
pcBA-to-path (pc-bba d pc pA) = pcBB-to-path pc ∙₀' !₀ [ glue (h d) ] ∙₀' ap₀ left pA
pcBB-to-path (pc-b pB) = ap₀ right pB
pcBB-to-path (pc-bab d pc pB) = pcBA-to-path pc ∙₀' [ glue (h d) ] ∙₀' ap₀ right pB
abstract
pcBA-to-path-rel : ∀ {b₀ a₁} {pcBA₀ pcBA₁ : precodeBA b₀ a₁}
→ precodeBA-rel pcBA₀ pcBA₁ → pcBA-to-path pcBA₀ == pcBA-to-path pcBA₁
pcBB-to-path-rel : ∀ {b₀ b₁} {pcBB₀ pcBB₁ : precodeBB b₀ b₁}
→ precodeBB-rel pcBB₀ pcBB₁ → pcBB-to-path pcBB₀ == pcBB-to-path pcBB₁
pcBA-to-path-rel (pcBAr-idp₀-idp₀ pcBA) =
∙₀'-assoc (pcBA-to-path pcBA) [ glue (h _) ] [ ! (glue (h _)) ]
∙ ap (λ p → pcBA-to-path pcBA ∙₀' [ p ]) (!-inv'-r (glue (h _)))
∙ ∙₀'-unit-r (pcBA-to-path pcBA)
pcBA-to-path-rel (pcBAr-cong pcBB pA) = pcBB-to-path-rel pcBB |in-ctx _∙₀' !₀ [ glue (h _) ] ∙₀' ap₀ left pA
pcBB-to-path-rel (pcBBr-idp₀-idp₀ pcBB) =
∙₀'-assoc (pcBB-to-path pcBB) [ ! (glue (h _)) ] [ glue (h _) ]
∙ ap (λ p → pcBB-to-path pcBB ∙₀' [ p ]) (!-inv'-l (glue (h _)))
∙ ∙₀'-unit-r (pcBB-to-path pcBB)
pcBB-to-path-rel (pcBBr-switch pcBB pC) =
ap (_∙₀' [ glue (h _) ]) (! (∙₀'-assoc (pcBB-to-path pcBB) [ ! (glue (h _)) ] (ap₀ left (ap₀ f pC))))
∙ ∙₀'-assoc (pcBB-to-path pcBB ∙₀' [ ! (glue (h _)) ]) (ap₀ left (ap₀ f pC)) [ glue (h _) ]
∙ ap ((pcBB-to-path pcBB ∙₀' [ ! (glue (h _)) ]) ∙₀'_) (natural₀ pC)
where
natural : ∀ {c₀ c₁} (p : c₀ == c₁)
→ (ap left (ap f p) ∙' glue c₁) == (glue c₀ ∙' ap right (ap g p))
:> (left (f c₀) == right (g c₁) :> Pushout span)
natural idp = ∙'-unit-l (glue _)
natural₀ : ∀ {c₀ c₁} (p : c₀ =₀ c₁)
→ (ap₀ left (ap₀ f p) ∙₀' [ glue c₁ ]) == ([ glue c₀ ] ∙₀' ap₀ right (ap₀ g p))
:> (left (f c₀) =₀ right (g c₁) :> Pushout span)
natural₀ = Trunc-elim (λ _ → =-preserves-set Trunc-level) (ap [_] ∘ natural)
pcBB-to-path-rel (pcBBr-cong pcBA pB) = pcBA-to-path-rel pcBA |in-ctx _∙₀' [ glue (h _) ] ∙₀' ap₀ right pB
decodeBA : ∀ {b₀ a₁} → codeBA b₀ a₁ → right b₀ =₀ left a₁ :> Pushout span
decodeBB : ∀ {b₀ b₁} → codeBB b₀ b₁ → right b₀ =₀ right b₁ :> Pushout span
decodeBA = SetQuot-rec Trunc-level pcBA-to-path pcBA-to-path-rel
decodeBB = SetQuot-rec Trunc-level pcBB-to-path pcBB-to-path-rel
abstract
decodeBA-is-decodeBB : ∀ {b₀} c₁ →
decodeBA {b₀} {f c₁} == decodeBB {b₀} {g c₁}
[ (λ p₁ → codeBP b₀ p₁ → right b₀ =₀ p₁) ↓ glue c₁ ]
decodeBA-is-decodeBB {b₀ = b₀} = SurjExt.ext
(λ _ → ↓-preserves-level $ Π-is-set λ _ → Trunc-level) h h-is-surj
(λ d₁ → ↓-→-from-transp $ λ= $ SetQuot-elim
{P = λ cBA → transport (right b₀ =₀_) (glue (h d₁)) (decodeBA cBA)
== decodeBB (transport (codeBP b₀) (glue (h d₁)) cBA)}
(λ _ → =-preserves-set Trunc-level)
(λ pcBA →
transport (right b₀ =₀_) (glue (h d₁)) (pcBA-to-path pcBA)
=⟨ transp₀-cst=₀idf [ glue (h d₁) ] (pcBA-to-path pcBA) ⟩
pcBA-to-path pcBA ∙₀' [ glue (h d₁) ]
=⟨ ! $ ap (λ e → decodeBB (–> e q[ pcBA ])) (CodeBAEquivCodeBB.eqv-β b₀ d₁) ⟩
decodeBB (–> (CodeBAEquivCodeBB.eqv b₀ (h d₁)) q[ pcBA ])
=⟨ ! $ ap decodeBB (coe-β (CodeBAEquivCodeBB.eqv b₀ (h d₁)) q[ pcBA ]) ⟩
decodeBB (coe (ua (CodeBAEquivCodeBB.eqv b₀ (h d₁))) q[ pcBA ])
=⟨ ! $ ap (λ p → decodeBB (coe p q[ pcBA ])) (CodeBP.glue-β b₀ (h d₁)) ⟩
decodeBB (transport (codeBP b₀) (glue (h d₁)) q[ pcBA ])
=∎)
(λ _ → prop-has-all-paths-↓ $ Trunc-level {n = 0} _ _))
(λ _ _ _ → prop-has-all-paths-↓ $ ↓-level $ Π-is-set λ _ → Trunc-level)
decodeBP : ∀ {b₀ p₁} → codeBP b₀ p₁ → right b₀ =₀ p₁
decodeBP {p₁ = p₁} = Pushout-elim
(λ a₁ → decodeBA) (λ b₁ → decodeBB)
decodeBA-is-decodeBB
p₁
|
{
"alphanum_fraction": 0.5407482148,
"avg_line_length": 47.7185185185,
"ext": "agda",
"hexsha": "18db204ee459d244d3352f9fb864451465b18c7a",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z",
"max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mikeshulman/HoTT-Agda",
"max_forks_repo_path": "theorems/homotopy/vankampen/CodeBP.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "mikeshulman/HoTT-Agda",
"max_issues_repo_path": "theorems/homotopy/vankampen/CodeBP.agda",
"max_line_length": 112,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mikeshulman/HoTT-Agda",
"max_stars_repo_path": "theorems/homotopy/vankampen/CodeBP.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 5715,
"size": 12884
}
|
------------------------------------------------------------------------
-- Two eliminators for Delay-monad.Alternative.Delay (A / R)
------------------------------------------------------------------------
-- This module is largely based on (but perhaps not quite identical
-- to) the development underlying Theorem 1 in "Quotienting the Delay
-- Monad by Weak Bisimilarity" by Chapman, Uustalu and Veltri.
{-# OPTIONS --cubical --sized-types #-}
module Delay-monad.Alternative.Eliminators where
open import Equality.Propositional.Cubical
open import Logical-equivalence using (_⇔_)
open import Prelude hiding (↑)
open import Bijection equality-with-J using (_↔_)
open import Equality.Path.Isomorphisms.Univalence equality-with-paths
import Equivalence equality-with-J as Eq
open import Equivalence-relation equality-with-J
open import Function-universe equality-with-J hiding (id; _∘_)
open import H-level equality-with-J
open import H-level.Truncation.Propositional equality-with-paths
open import Quotient equality-with-paths
open import Surjection equality-with-J using (_↠_)
open import Univalence-axiom equality-with-J
open import Delay-monad.Alternative
open import Delay-monad.Alternative.Equivalence
open import Delay-monad.Alternative.Properties
------------------------------------------------------------------------
-- A map function
private
module _ {a b} {A : Type a} {B : Type b} where
-- A map function for Maybe.
mapᴹ : (A → B) → Maybe A → Maybe B
mapᴹ = ⊎-map id
-- If mapᴹ f x does not have a value, then x does not have a
-- value.
mapᴹ-↑ : ∀ {f : A → B} x → mapᴹ f x ↑ → x ↑
mapᴹ-↑ nothing _ = refl
mapᴹ-↑ (just _) ()
-- The function mapᴹ f preserves LE.
mapᴹ-LE : ∀ {f : A → B} {x y} →
LE x y → LE (mapᴹ f x) (mapᴹ f y)
mapᴹ-LE =
⊎-map (cong (mapᴹ _)) (Σ-map (cong (mapᴹ _)) (_∘ mapᴹ-↑ _))
-- The function mapᴹ f ∘_ preserves Increasing.
mapᴹ-Increasing : ∀ {f : A → B} {g} →
Increasing g → Increasing (mapᴹ f ∘ g)
mapᴹ-Increasing = mapᴹ-LE ∘_
-- A map function for Delay.
map : ∀ {a b} {A : Type a} {B : Type b} →
(A → B) → Delay A → Delay B
map f = Σ-map (mapᴹ f ∘_) mapᴹ-Increasing
------------------------------------------------------------------------
-- The first eliminator
private
variable
a r : Level
A B : Type a
R : A → A → Type r
f : A → B
-- Some abstract redefinitions, intended to make the code type-check
-- faster.
private
abstract
ℕ→/-comm-to′ : (ℕ → A) / (ℕ →ᴾ R) → (ℕ → A / R)
ℕ→/-comm-to′ = ℕ→/-comm-to
ℕ→/-comm-to′-[] : ℕ→/-comm-to′ {R = R} [ f ] ≡ [_] ∘ f
ℕ→/-comm-to′-[] = refl
ℕ→/-comm′ :
{A : Type a} {R : A → A → Type r} →
Axiom-of-countable-choice (a ⊔ r) →
Is-equivalence-relation R →
(∀ {x y} → Is-proposition (R x y)) →
(ℕ → A) / (ℕ →ᴾ R) ↔ (ℕ → A / R)
ℕ→/-comm′ {A = A} {R} cc R-equiv R-prop = record
{ surjection = record
{ logical-equivalence = record
{ to = ℕ→/-comm-to′
; from = from
}
; right-inverse-of = to∘from
}
; left-inverse-of = from∘to
}
where
iso = ℕ→/-comm cc prop-ext R-equiv R-prop
abstract
from : (ℕ → A / R) → (ℕ → A) / (ℕ →ᴾ R)
from = _↔_.from iso
to∘from : ∀ f → ℕ→/-comm-to′ (from f) ≡ f
to∘from = _↔_.right-inverse-of iso
from∘to : ∀ f → from (ℕ→/-comm-to′ f) ≡ f
from∘to = _↔_.left-inverse-of iso
abstract
Maybe/-comm′ : Maybe A / Maybeᴾ R ↔ Maybe (A / R)
Maybe/-comm′ = Maybe/-comm
Maybe/-comm′-[] :
_↔_.to Maybe/-comm′ ∘ [_] ≡ ⊎-map id ([_] {R = R})
Maybe/-comm′-[] = Maybe/-comm-[]
-- There is a function from (ℕ → Maybe A) / (ℕ →ᴾ Maybeᴾ R) to
-- Delay (A / R).
→Maybe/→ : (ℕ → Maybe A) / (ℕ →ᴾ Maybeᴾ R) → Delay (A / R)
→Maybe/→ f =
_↠_.to →↠Delay-function (_↔_.to Maybe/-comm′ ∘ ℕ→/-comm-to′ f)
-- A "computation" rule for →Maybe/→.
→Maybe/→-[] :
→Maybe/→ [ f ] ≡
_↠_.to →↠Delay-function (_↔_.to (Maybe/-comm′ {R = R}) ∘ [_] ∘ f)
→Maybe/→-[] =
cong (λ g → _↠_.to →↠Delay-function (_↔_.to Maybe/-comm′ ∘ g))
ℕ→/-comm-to′-[]
-- The definitions below make use of some assumptions: countable
-- choice and a propositional equivalence relation R.
module _
{a r} {A : Type a} {R : A → A → Type r}
(cc : Axiom-of-countable-choice (a ⊔ r))
(R-equiv : Is-equivalence-relation R)
(R-prop : ∀ {x y} → Is-proposition (R x y))
where
private
-- An abbreviation.
ℕ→/-comm″ =
ℕ→/-comm′ cc
(Maybeᴾ-preserves-Is-equivalence-relation R-equiv)
(λ {x} → Maybeᴾ-preserves-Is-proposition R-prop {x = x})
-- →Maybe/→ has a right inverse.
→Maybe/↠ :
(ℕ → Maybe A) / (ℕ →ᴾ Maybeᴾ R) ↠ Delay (A / R)
→Maybe/↠ =
(ℕ → Maybe A) / (ℕ →ᴾ Maybeᴾ R) ↔⟨ ℕ→/-comm″ ⟩
(ℕ → Maybe A / Maybeᴾ R) ↔⟨ ∀-cong ext (λ _ → Maybe/-comm′) ⟩
(ℕ → Maybe (A / R)) ↝⟨ →↠Delay-function ⟩□
Delay (A / R) □
private
to-→Maybe/↠ : _↠_.to →Maybe/↠ ≡ →Maybe/→
to-→Maybe/↠ = refl
-- On part of the domain of →Maybe/→ the right inverse is also a
-- left inverse.
→Maybe/↠-partial-left-inverse :
(x : Delay A) →
_↠_.from →Maybe/↠ (→Maybe/→ [ proj₁ x ]) ≡ [ proj₁ x ]
→Maybe/↠-partial-left-inverse (f , inc) =
_↠_.from →Maybe/↠ (→Maybe/→ [ f ]) ≡⟨ cong (_↠_.from →Maybe/↠) →Maybe/→-[] ⟩
_↔_.from ℕ→/-comm″ (λ n →
_↔_.from Maybe/-comm′ $
_↠_.from →↠Delay-function
(_↠_.to →↠Delay-function (_↔_.to Maybe/-comm′ ∘ [_] ∘ f))
n) ≡⟨ cong (λ g → _↔_.from ℕ→/-comm″ λ n →
_↔_.from Maybe/-comm′ (_↠_.from →↠Delay-function
(_↠_.to →↠Delay-function (g ∘ f))
n)) $
Maybe/-comm′-[] ⟩
_↔_.from ℕ→/-comm″ (λ n →
_↔_.from Maybe/-comm′ $
_↠_.from →↠Delay-function
(_↠_.to →↠Delay-function (mapᴹ [_] ∘ f))
n) ≡⟨⟩
_↔_.from ℕ→/-comm″ (λ n →
_↔_.from Maybe/-comm′ $
_↠_.from →↠Delay-function
(_↠_.to →↠Delay-function
(_↠_.from →↠Delay-function (map [_] (f , inc))))
n) ≡⟨ cong (λ x → _↔_.from ℕ→/-comm″ λ n →
_↔_.from Maybe/-comm′ (_↠_.from →↠Delay-function x n)) $
_↠_.right-inverse-of →↠Delay-function (map [_] (f , inc)) ⟩
_↔_.from ℕ→/-comm″ (λ n →
_↔_.from Maybe/-comm′ $
_↠_.from →↠Delay-function (map [_] (f , inc)) n) ≡⟨⟩
_↔_.from ℕ→/-comm″ (λ n → _↔_.from Maybe/-comm′ $ mapᴹ [_] (f n)) ≡⟨ cong (λ g → _↔_.from ℕ→/-comm″ λ n → _↔_.from Maybe/-comm′ (g (f n))) $
sym Maybe/-comm′-[] ⟩
_↔_.from ℕ→/-comm″ (λ n →
_↔_.from Maybe/-comm′ (_↔_.to Maybe/-comm′ [ f n ])) ≡⟨ cong (_↔_.from ℕ→/-comm″) (⟨ext⟩ λ n →
_↔_.left-inverse-of Maybe/-comm′ [ f n ]) ⟩
_↔_.from ℕ→/-comm″ (λ n → [ f n ]) ≡⟨ cong (_↔_.from ℕ→/-comm″) $ sym ℕ→/-comm-to′-[] ⟩
_↔_.from ℕ→/-comm″ (ℕ→/-comm-to′ [ f ]) ≡⟨ _↔_.left-inverse-of ℕ→/-comm″ [ f ] ⟩∎
[ f ] ∎
-- A quotient-like eliminator for Delay (A / R).
Delay/-elim₁ :
∀ {p} (P : Delay (A / R) → Type p)
(p-[] : (f : ℕ → Maybe A) → P (→Maybe/→ [ f ])) →
(∀ {f g} (r : (ℕ →ᴾ Maybeᴾ R) f g) →
subst P (cong →Maybe/→
([]-respects-relation {x = f} {y = g} r))
(p-[] f) ≡
p-[] g) →
(∀ x → Is-set (P x)) →
∀ x → P x
Delay/-elim₁ = ↠-eliminator →Maybe/↠
-- Simplification lemma for Delay/-elim₁.
Delay/-elim₁-[] :
∀ {p} (P : Delay (A / R) → Type p)
(p-[] : (f : ℕ → Maybe A) → P (→Maybe/→ [ f ]))
(ok :
∀ {f g} (r : (ℕ →ᴾ Maybeᴾ R) f g) →
subst P (cong →Maybe/→
([]-respects-relation {x = f} {y = g} r))
(p-[] f) ≡
p-[] g)
(P-set : ∀ x → Is-set (P x)) (x : Delay A) →
Delay/-elim₁ P p-[] ok P-set (→Maybe/→ [ proj₁ x ]) ≡
p-[] (proj₁ x)
Delay/-elim₁-[] P p-[] ok P-set x =
↠-eliminator-[] →Maybe/↠ P p-[] ok P-set
(_↠_.from →↠Delay-function x)
(→Maybe/↠-partial-left-inverse x)
------------------------------------------------------------------------
-- The second eliminator
-- Pointwise lifting of binary relations to the delay monad.
Delayᴾ :
∀ {a r} {A : Type a} →
(A → A → Type r) →
Delay A → Delay A → Type r
Delayᴾ R = (ℕ →ᴾ Maybeᴾ R) on proj₁
module _
{a r} {A : Type a} {R : A → A → Type r}
where
-- The function map ([_] {R = R}) respects Delayᴾ R.
map-[]-cong :
∀ x y → Delayᴾ R x y → map ([_] {R = R}) x ≡ map [_] y
map-[]-cong x y r =
_↔_.to (equality-characterisation /-is-set)
(⟨ext⟩ λ n → lemma (proj₁ x n) (proj₁ y n) (r n))
where
lemma : ∀ x y → Maybeᴾ R x y →
mapᴹ [_] x ≡ mapᴹ [_] y
lemma nothing nothing = const refl
lemma (just x) (just y) = cong inj₂ ∘ []-respects-relation
lemma nothing (just y) ()
lemma (just x) nothing ()
-- The function
-- _↠_.from →↠Delay-function ∘ _↠_.to →↠Delay-function respects
-- ℕ →ᴾ Maybeᴾ R.
from-to-→↠Delay-function-cong :
let open _↠_ →↠Delay-function in
(f g : ℕ → Maybe A) →
(ℕ →ᴾ Maybeᴾ R) f g →
(ℕ →ᴾ Maybeᴾ R) (from (to f)) (from (to g))
from-to-→↠Delay-function-cong f g r =
helper f g r (f 0) (g 0) (r 0)
where
helper :
∀ f g → (ℕ →ᴾ Maybeᴾ R) f g →
∀ x y → Maybeᴾ R x y →
(ℕ →ᴾ Maybeᴾ R)
(proj₁ (Delay⇔Delay.from (Delay⇔Delay.To.to′ f x)))
(proj₁ (Delay⇔Delay.from (Delay⇔Delay.To.to′ g y)))
helper f g rs (just x) (just y) r n = r
helper f g rs nothing nothing r zero = r
helper f g rs nothing nothing r (suc n) =
helper (f ∘ suc) (g ∘ suc) (rs ∘ suc) (f 1) (g 1) (rs 1) n
helper _ _ _ (just _) nothing ()
helper _ _ _ nothing (just _) ()
-- A simplification lemma for →Maybe/→.
→Maybe/→-[]′ :
(f : ℕ → Maybe A) →
→Maybe/→ [ f ] ≡
map ([_] {R = R}) (_↠_.to →↠Delay-function f)
→Maybe/→-[]′ f = _↔_.to (equality-characterisation /-is-set)
(proj₁ (→Maybe/→ [ f ]) ≡⟨ cong proj₁ →Maybe/→-[] ⟩
proj₁ (_↠_.to →↠Delay-function (_↔_.to Maybe/-comm′ ∘ [_] ∘ f)) ≡⟨ cong (λ g → proj₁ (_↠_.to →↠Delay-function (g ∘ f))) $ Maybe/-comm′-[] ⟩
proj₁ (_↠_.to →↠Delay-function (mapᴹ [_] ∘ f)) ≡⟨ ⟨ext⟩ (helper f (f 0)) ⟩
mapᴹ [_] ∘ proj₁ (_↠_.to →↠Delay-function f) ≡⟨⟩
proj₁ (map [_] (_↠_.to →↠Delay-function f)) ∎)
where
helper :
∀ f x n →
proj₁ (Delay⇔Delay.from
(Delay⇔Delay.To.to′ (mapᴹ [_] ∘ f) (mapᴹ [_] x))) n ≡
mapᴹ [_] (proj₁ (Delay⇔Delay.from (Delay⇔Delay.To.to′ f x)) n)
helper f (just x) n = refl
helper f nothing zero = refl
helper f nothing (suc n) = helper (f ∘ suc) (f 1) n
-- The definitions below make use of some assumptions: countable
-- choice and a propositional equivalence relation R.
module _
{a p r} {A : Type a} {R : A → A → Type r}
(cc : Axiom-of-countable-choice (a ⊔ r))
(R-equiv : Is-equivalence-relation R)
(R-prop : ∀ {x y} → Is-proposition (R x y))
(P : Delay (A / R) → Type p)
(p-[] : (x : Delay A) → P (map [_] x))
(ok : ∀ {x y} (r : Delayᴾ R x y) →
subst P (map-[]-cong x y r) (p-[] x) ≡ p-[] y)
(P-set : ∀ x → Is-set (P x))
where
private
lemma₁ = sym ∘ →Maybe/→-[]′ {R = R}
lemma₂ :
∀ {f g} r →
subst P
(cong →Maybe/→ ([]-respects-relation {x = f} {y = g} r))
(subst P (lemma₁ f) (p-[] (_↠_.to →↠Delay-function f))) ≡
subst P (lemma₁ g) (p-[] (_↠_.to →↠Delay-function g))
lemma₂ {f} {g} r =
let p = p-[] (_↠_.to →↠Delay-function f)
r′ = cong →Maybe/→ ([]-respects-relation {x = f} {y = g} r)
r″ = trans (trans (lemma₁ f) r′) (sym (lemma₁ g))
in
subst P r′ (subst P (lemma₁ f) p) ≡⟨ subst-subst P (lemma₁ f) r′ p ⟩
subst P (trans (lemma₁ f) r′) p ≡⟨ cong (λ eq → subst P eq p) $
sym $ trans-[trans-sym]- _ (lemma₁ g) ⟩
subst P (trans r″ (lemma₁ g)) p ≡⟨ sym $ subst-subst P
(trans (trans (lemma₁ f) r′) (sym (lemma₁ g)))
(lemma₁ g)
p ⟩
subst P (lemma₁ g) (subst P r″ p) ≡⟨ cong (λ eq → subst P (lemma₁ g) (subst P eq p)) $
Delay-closure 0 /-is-set
r″
(map-[]-cong (_↠_.to →↠Delay-function f)
(_↠_.to →↠Delay-function g)
(from-to-→↠Delay-function-cong f g r)) ⟩
subst P (lemma₁ g)
(subst P (map-[]-cong (_↠_.to →↠Delay-function f)
(_↠_.to →↠Delay-function g)
(from-to-→↠Delay-function-cong f g r))
p) ≡⟨ cong (subst P (lemma₁ g)) (ok _) ⟩∎
subst P (lemma₁ g) (p-[] (_↠_.to →↠Delay-function g)) ∎
-- A second quotient-like eliminator for Delay (A / R).
--
-- This eliminator corresponds to Theorem 1 in "Quotienting the
-- Delay Monad by Weak Bisimilarity" by Chapman, Uustalu and
-- Veltri.
Delay/-elim₂ : ∀ x → P x
Delay/-elim₂ =
Delay/-elim₁ cc R-equiv R-prop P
(λ f → subst P (lemma₁ f) (p-[] (_↠_.to →↠Delay-function f)))
lemma₂ P-set
-- Simplification lemma for Delay/-elim₂.
Delay/-elim₂-[] : ∀ x → Delay/-elim₂ (map [_] x) ≡ p-[] x
Delay/-elim₂-[] x =
Delay/-elim₁ cc R-equiv R-prop P
(λ f → subst P (lemma₁ f) (p-[] (_↠_.to →↠Delay-function f)))
lemma₂ P-set (map [_] x) ≡⟨ sym $ dcong
(Delay/-elim₁ cc R-equiv R-prop P
(λ f → subst P (lemma₁ f)
(p-[] (_↠_.to →↠Delay-function f)))
lemma₂ P-set)
lemma₃ ⟩
subst P lemma₃
(Delay/-elim₁ cc R-equiv R-prop P
(λ f → subst P (lemma₁ f) (p-[] (_↠_.to →↠Delay-function f)))
lemma₂ P-set (→Maybe/→ [ proj₁ x ])) ≡⟨ cong (subst P lemma₃) $
Delay/-elim₁-[] cc R-equiv R-prop P _ lemma₂ P-set x ⟩
subst P lemma₃
(subst P (lemma₁ (proj₁ x))
(p-[] (_↠_.to →↠Delay-function (proj₁ x)))) ≡⟨ subst-subst P (lemma₁ (proj₁ x)) lemma₃ _ ⟩
subst P (trans (lemma₁ (proj₁ x)) lemma₃)
(p-[] (_↠_.to →↠Delay-function (proj₁ x))) ≡⟨ cong (λ p → subst P p (p-[] (_↠_.to →↠Delay-function (proj₁ x)))) $
trans--[trans-sym]
(lemma₁ (proj₁ x))
(cong (map [_]) $ _↠_.right-inverse-of →↠Delay-function x) ⟩
subst P (cong (map [_]) $ _↠_.right-inverse-of →↠Delay-function x)
(p-[] (_↠_.to →↠Delay-function (proj₁ x))) ≡⟨ sym $ subst-∘ P (map [_]) (_↠_.right-inverse-of →↠Delay-function x) ⟩
subst (P ∘ map [_]) (_↠_.right-inverse-of →↠Delay-function x)
(p-[] (_↠_.to →↠Delay-function (proj₁ x))) ≡⟨ dcong p-[] (_↠_.right-inverse-of →↠Delay-function x) ⟩∎
p-[] x ∎
where
lemma₃ =
→Maybe/→ [ proj₁ x ] ≡⟨ sym $ lemma₁ (proj₁ x) ⟩
map [_] (_↠_.to →↠Delay-function (proj₁ x)) ≡⟨ cong (map [_]) $ _↠_.right-inverse-of →↠Delay-function x ⟩∎
map [_] x ∎
|
{
"alphanum_fraction": 0.4272289839,
"avg_line_length": 39.8758465011,
"ext": "agda",
"hexsha": "7f66710aa14cc415be8acedfcf8ab01cca4abb54",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/partiality-monad",
"max_forks_repo_path": "src/Delay-monad/Alternative/Eliminators.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/partiality-monad",
"max_issues_repo_path": "src/Delay-monad/Alternative/Eliminators.agda",
"max_line_length": 146,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/partiality-monad",
"max_stars_repo_path": "src/Delay-monad/Alternative/Eliminators.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:08.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-05-21T22:59:18.000Z",
"num_tokens": 5756,
"size": 17665
}
|
module test.Negation where
open import Type
open import Declarative
open import Builtin
open import Builtin.Constant.Type
open import Builtin.Constant.Term Ctx⋆ Kind * # _⊢⋆_ con size⋆
-- zerepoch/zerepoch-core/test/data/negation.plc
open import Declarative.StdLib.Bool
negate : ∀{Γ} → Γ ⊢ boolean ⇒ boolean
negate {Γ} = ƛ (if ·⋆ boolean · ` Z · false · true)
|
{
"alphanum_fraction": 0.7362637363,
"avg_line_length": 24.2666666667,
"ext": "agda",
"hexsha": "7c411a69241eb336b9b50d680142e1a899bccff9",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-02-21T16:38:59.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-13T21:25:19.000Z",
"max_forks_repo_head_hexsha": "c8cf4619e6e496930c9092cf6d64493eff300177",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "Quantum-One-DLT/zerepoch",
"max_forks_repo_path": "zerepoch-metatheory/test/Negation.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c8cf4619e6e496930c9092cf6d64493eff300177",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "Quantum-One-DLT/zerepoch",
"max_issues_repo_path": "zerepoch-metatheory/test/Negation.agda",
"max_line_length": 62,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "c8cf4619e6e496930c9092cf6d64493eff300177",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "Quantum-One-DLT/zerepoch",
"max_stars_repo_path": "zerepoch-metatheory/test/Negation.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 125,
"size": 364
}
|
module Structure.Logic where
|
{
"alphanum_fraction": 0.8620689655,
"avg_line_length": 14.5,
"ext": "agda",
"hexsha": "76e5e6513666f522368cc5819fb25262e0cb693e",
"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/Logic.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/Logic.agda",
"max_line_length": 28,
"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/Logic.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": 5,
"size": 29
}
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Data.Int.Base where
open import Cubical.Core.Everything
open import Cubical.Data.Nat
data Int : Type₀ where
pos : (n : ℕ) → Int
negsuc : (n : ℕ) → Int
neg : (n : ℕ) → Int
neg zero = pos zero
neg (suc n) = negsuc n
sucInt : Int → Int
sucInt (pos n) = pos (suc n)
sucInt (negsuc zero) = pos zero
sucInt (negsuc (suc n)) = negsuc n
predInt : Int → Int
predInt (pos zero) = negsuc zero
predInt (pos (suc n)) = pos n
predInt (negsuc n) = negsuc (suc n)
-- Natural number and negative integer literals for Int
open import Cubical.Data.Nat.Literals public
instance
fromNatInt : HasFromNat Int
fromNatInt = record { Constraint = λ _ → Unit ; fromNat = λ n → pos n }
instance
fromNegInt : HasFromNeg Int
fromNegInt = record { Constraint = λ _ → Unit ; fromNeg = λ n → neg n }
|
{
"alphanum_fraction": 0.6575342466,
"avg_line_length": 23.6756756757,
"ext": "agda",
"hexsha": "4ebe23f9b5e55544f59f879d02d967b2266f505c",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dan-iel-lee/cubical",
"max_forks_repo_path": "Cubical/Data/Int/Base.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "dan-iel-lee/cubical",
"max_issues_repo_path": "Cubical/Data/Int/Base.agda",
"max_line_length": 73,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "dan-iel-lee/cubical",
"max_stars_repo_path": "Cubical/Data/Int/Base.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 296,
"size": 876
}
|
{-
This file proves the higher groupoid structure of types
for homogeneous and heterogeneous paths
-}
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Foundations.GroupoidLaws where
open import Cubical.Foundations.Prelude
private
variable
ℓ : Level
A : Type ℓ
x y z w v : A
_⁻¹ : (x ≡ y) → (y ≡ x)
x≡y ⁻¹ = sym x≡y
infix 40 _⁻¹
-- homogeneous groupoid laws
symInvo : (p : x ≡ y) → p ≡ p ⁻¹ ⁻¹
symInvo p = refl
rUnit : (p : x ≡ y) → p ≡ p ∙ refl
rUnit p j i = compPath-filler p refl j i
-- The filler of left unit: lUnit-filler p =
-- PathP (λ i → PathP (λ j → PathP (λ k → A) x (p (~ j ∨ i)))
-- (refl i) (λ j → compPath-filler refl p i j)) (λ k i → (p (~ k ∧ i ))) (lUnit p)
lUnit-filler : {x y : A} (p : x ≡ y) → I → I → I → A
lUnit-filler {x = x} p j k i =
hfill (λ j → λ { (i = i0) → x
; (i = i1) → p (~ k ∨ j )
; (k = i0) → p i
-- ; (k = i1) → compPath-filler refl p j i
}) (inS (p (~ k ∧ i ))) j
lUnit : (p : x ≡ y) → p ≡ refl ∙ p
lUnit p j i = lUnit-filler p i1 j i
symRefl : refl {x = x} ≡ refl ⁻¹
symRefl i = refl
compPathRefl : refl {x = x} ≡ refl ∙ refl
compPathRefl = rUnit refl
-- The filler of right cancellation: rCancel-filler p =
-- PathP (λ i → PathP (λ j → PathP (λ k → A) x (p (~ j ∧ ~ i)))
-- (λ j → compPath-filler p (p ⁻¹) i j) (refl i)) (λ j i → (p (i ∧ ~ j))) (rCancel p)
rCancel-filler : ∀ {x y : A} (p : x ≡ y) → (k j i : I) → A
rCancel-filler {x = x} p k j i =
hfill (λ k → λ { (i = i0) → x
; (i = i1) → p (~ k ∧ ~ j)
-- ; (j = i0) → compPath-filler p (p ⁻¹) k i
; (j = i1) → x
}) (inS (p (i ∧ ~ j))) k
rCancel : (p : x ≡ y) → p ∙ p ⁻¹ ≡ refl
rCancel {x = x} p j i = rCancel-filler p i1 j i
rCancel-filler' : ∀ {ℓ} {A : Type ℓ} {x y : A} (p : x ≡ y) → (i j k : I) → A
rCancel-filler' {x = x} {y} p i j k =
hfill
(λ i → λ
{ (j = i1) → p (~ i ∧ k)
; (k = i0) → x
; (k = i1) → p (~ i)
})
(inS (p k))
(~ i)
rCancel' : ∀ {ℓ} {A : Type ℓ} {x y : A} (p : x ≡ y) → p ∙ p ⁻¹ ≡ refl
rCancel' p j k = rCancel-filler' p i0 j k
lCancel : (p : x ≡ y) → p ⁻¹ ∙ p ≡ refl
lCancel p = rCancel (p ⁻¹)
assoc : (p : x ≡ y) (q : y ≡ z) (r : z ≡ w) →
p ∙ q ∙ r ≡ (p ∙ q) ∙ r
assoc p q r k = (compPath-filler p q k) ∙ compPath-filler' q r (~ k)
-- heterogeneous groupoid laws
symInvoP : {A : I → Type ℓ} → {x : A i0} → {y : A i1} → (p : PathP A x y) →
PathP (λ j → PathP (λ i → symInvo (λ i → A i) j i) x y) p (symP (symP p))
symInvoP p = refl
rUnitP : {A : I → Type ℓ} → {x : A i0} → {y : A i1} → (p : PathP A x y) →
PathP (λ j → PathP (λ i → rUnit (λ i → A i) j i) x y) p (compPathP p refl)
rUnitP p j i = compPathP-filler p refl j i
lUnitP : {A : I → Type ℓ} → {x : A i0} → {y : A i1} → (p : PathP A x y) →
PathP (λ j → PathP (λ i → lUnit (λ i → A i) j i) x y) p (compPathP refl p)
lUnitP {A = A} {x = x} p k i =
comp (λ j → lUnit-filler (λ i → A i) j k i)
(λ j → λ { (i = i0) → x
; (i = i1) → p (~ k ∨ j )
; (k = i0) → p i
}) (p (~ k ∧ i ))
rCancelP : {A : I → Type ℓ} → {x : A i0} → {y : A i1} → (p : PathP A x y) →
PathP (λ j → PathP (λ i → rCancel (λ i → A i) j i) x x) (compPathP p (symP p)) refl
rCancelP {A = A} {x = x} p j i =
comp (λ k → rCancel-filler (λ i → A i) k j i)
(λ k → λ { (i = i0) → x
; (i = i1) → p (~ k ∧ ~ j)
; (j = i1) → x
}) (p (i ∧ ~ j))
lCancelP : {A : I → Type ℓ} → {x : A i0} → {y : A i1} → (p : PathP A x y) →
PathP (λ j → PathP (λ i → lCancel (λ i → A i) j i) y y) (compPathP (symP p) p) refl
lCancelP p = rCancelP (symP p)
assocP : {A : I → Type ℓ} {x : A i0} {y : A i1} {B_i1 : Type ℓ} {B : (A i1) ≡ B_i1} {z : B i1}
{C_i1 : Type ℓ} {C : (B i1) ≡ C_i1} {w : C i1} (p : PathP A x y) (q : PathP (λ i → B i) y z) (r : PathP (λ i → C i) z w) →
PathP (λ j → PathP (λ i → assoc (λ i → A i) B C j i) x w) (compPathP p (compPathP q r)) (compPathP (compPathP p q) r)
assocP {A = A} {B = B} {C = C} p q r k i =
comp (\ j' → hfill (λ j → λ {
(i = i0) → A i0
; (i = i1) → compPath-filler' (λ i₁ → B i₁) (λ i₁ → C i₁) (~ k) j })
(inS (compPath-filler (λ i₁ → A i₁) (λ i₁ → B i₁) k i)) j')
(λ j → λ
{ (i = i0) → p i0
; (i = i1) →
comp (\ j' → hfill ((λ l → λ
{ (j = i0) → B k
; (j = i1) → C l
; (k = i1) → C (j ∧ l)
})) (inS (B ( j ∨ k)) ) j')
(λ l → λ
{ (j = i0) → q k
; (j = i1) → r l
; (k = i1) → r (j ∧ l)
})
(q (j ∨ k))
})
(compPathP-filler p q k i)
-- Loic's code below
-- some exchange law for doubleCompPath and refl
invSides-filler : {x y z : A} (p : x ≡ y) (q : x ≡ z) → Square p (sym q) q (sym p)
invSides-filler {x = x} p q i j =
hcomp (λ k → λ { (i = i0) → p (k ∧ j)
; (i = i1) → q (~ j ∧ k)
; (j = i0) → q (i ∧ k)
; (j = i1) → p (~ i ∧ k)})
x
leftright : {ℓ : Level} {A : Type ℓ} {x y z : A} (p : x ≡ y) (q : y ≡ z) →
(refl ∙∙ p ∙∙ q) ≡ (p ∙∙ q ∙∙ refl)
leftright p q i j =
hcomp (λ t → λ { (j = i0) → p (i ∧ (~ t))
; (j = i1) → q (t ∨ i) })
(invSides-filler q (sym p) (~ i) j)
-- equating doubleCompPath and a succession of two compPath
split-leftright : {ℓ : Level} {A : Type ℓ} {w x y z : A} (p : w ≡ x) (q : x ≡ y) (r : y ≡ z) →
(p ∙∙ q ∙∙ r) ≡ (refl ∙∙ (p ∙∙ q ∙∙ refl) ∙∙ r)
split-leftright p q r j i =
hcomp (λ t → λ { (i = i0) → p (~ j ∧ ~ t)
; (i = i1) → r t })
(doubleCompPath-filler p q refl j i)
split-leftright' : {ℓ : Level} {A : Type ℓ} {w x y z : A} (p : w ≡ x) (q : x ≡ y) (r : y ≡ z) →
(p ∙∙ q ∙∙ r) ≡ (p ∙∙ (refl ∙∙ q ∙∙ r) ∙∙ refl)
split-leftright' p q r j i =
hcomp (λ t → λ { (i = i0) → p (~ t)
; (i = i1) → r (j ∨ t) })
(doubleCompPath-filler refl q r j i)
doubleCompPath-elim : {ℓ : Level} {A : Type ℓ} {w x y z : A} (p : w ≡ x) (q : x ≡ y)
(r : y ≡ z) → (p ∙∙ q ∙∙ r) ≡ (p ∙ q) ∙ r
doubleCompPath-elim p q r = (split-leftright p q r) ∙ (λ i → (leftright p q (~ i)) ∙ r)
doubleCompPath-elim' : {ℓ : Level} {A : Type ℓ} {w x y z : A} (p : w ≡ x) (q : x ≡ y)
(r : y ≡ z) → (p ∙∙ q ∙∙ r) ≡ p ∙ (q ∙ r)
doubleCompPath-elim' p q r = (split-leftright' p q r) ∙ (sym (leftright p (q ∙ r)))
cong-∙ : ∀ {B : Type ℓ} (f : A → B) (p : x ≡ y) (q : y ≡ z)
→ cong f (p ∙ q) ≡ (cong f p) ∙ (cong f q)
cong-∙ f p q j i = hcomp (λ k → λ { (j = i0) → f (compPath-filler p q k i)
; (i = i0) → f (p i0)
; (i = i1) → f (q k) })
(f (p i))
cong-∙∙ : ∀ {B : Type ℓ} (f : A → B) (p : w ≡ x) (q : x ≡ y) (r : y ≡ z)
→ cong f (p ∙∙ q ∙∙ r) ≡ (cong f p) ∙∙ (cong f q) ∙∙ (cong f r)
cong-∙∙ f p q r j i = hcomp (λ k → λ { (j = i0) → f (doubleCompPath-filler p q r k i)
; (i = i0) → f (p (~ k))
; (i = i1) → f (r k) })
(f (q i))
hcomp-unique : ∀ {ℓ} {A : Type ℓ} {φ} → (u : I → Partial φ A) → (u0 : A [ φ ↦ u i0 ]) →
(h2 : ∀ i → A [ (φ ∨ ~ i) ↦ (\ { (φ = i1) → u i 1=1; (i = i0) → outS u0}) ])
→ (hcomp u (outS u0) ≡ outS (h2 i1)) [ φ ↦ (\ { (φ = i1) → (\ i → u i1 1=1)}) ]
hcomp-unique {φ = φ} u u0 h2 = inS (\ i → hcomp (\ k → \ { (φ = i1) → u k 1=1
; (i = i1) → outS (h2 k) })
(outS u0))
lid-unique : ∀ {ℓ} {A : Type ℓ} {φ} → (u : I → Partial φ A) → (u0 : A [ φ ↦ u i0 ]) →
(h1 h2 : ∀ i → A [ (φ ∨ ~ i) ↦ (\ { (φ = i1) → u i 1=1; (i = i0) → outS u0}) ])
→ (outS (h1 i1) ≡ outS (h2 i1)) [ φ ↦ (\ { (φ = i1) → (\ i → u i1 1=1)}) ]
lid-unique {φ = φ} u u0 h1 h2 = inS (\ i → hcomp (\ k → \ { (φ = i1) → u k 1=1
; (i = i0) → outS (h1 k)
; (i = i1) → outS (h2 k) })
(outS u0))
transp-hcomp : ∀ {ℓ} (φ : I) {A' : Type ℓ}
(A : (i : I) → Type ℓ [ φ ↦ (λ _ → A') ]) (let B = \ (i : I) → outS (A i))
→ ∀ {ψ} (u : I → Partial ψ (B i0)) → (u0 : B i0 [ ψ ↦ u i0 ]) →
(transp (\ i → B i) φ (hcomp u (outS u0)) ≡ hcomp (\ i o → transp (\ i → B i) φ (u i o)) (transp (\ i → B i) φ (outS u0)))
[ ψ ↦ (\ { (ψ = i1) → (\ i → transp (\ i → B i) φ (u i1 1=1))}) ]
transp-hcomp φ A u u0 = inS (sym (outS (hcomp-unique
((\ i o → transp (\ i → B i) φ (u i o))) (inS (transp (\ i → B i) φ (outS u0)))
\ i → inS (transp (\ i → B i) φ (hfill u u0 i)))))
where
B = \ (i : I) → outS (A i)
hcomp-cong : ∀ {ℓ} {A : Type ℓ} {φ} → (u : I → Partial φ A) → (u0 : A [ φ ↦ u i0 ]) →
(u' : I → Partial φ A) → (u0' : A [ φ ↦ u' i0 ]) →
(ueq : ∀ i → PartialP φ (\ o → u i o ≡ u' i o)) → (outS u0 ≡ outS u0') [ φ ↦ (\ { (φ = i1) → ueq i0 1=1}) ]
→ (hcomp u (outS u0) ≡ hcomp u' (outS u0')) [ φ ↦ (\ { (φ = i1) → ueq i1 1=1 }) ]
hcomp-cong u u0 u' u0' ueq 0eq = inS (\ j → hcomp (\ i o → ueq i o j) (outS 0eq j))
congFunct-filler : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} {x y z : A} (f : A → B) (p : x ≡ y) (q : y ≡ z)
→ I → I → I → B
congFunct-filler {x = x} f p q i j z =
hfill (λ k → λ { (i = i0) → f x
; (i = i1) → f (q k)
; (j = i0) → f (compPath-filler p q k i)})
(inS (f (p i)))
z
congFunct : ∀ {ℓ} {B : Type ℓ} (f : A → B) (p : x ≡ y) (q : y ≡ z) → cong f (p ∙ q) ≡ cong f p ∙ cong f q
congFunct f p q j i = congFunct-filler f p q i j i1
-- congFunct for dependent types
congFunct-dep : ∀ {ℓ ℓ'} {A : Type ℓ} {B : A → Type ℓ'} {x y z : A} (f : (a : A) → B a) (p : x ≡ y) (q : y ≡ z)
→ PathP (λ i → PathP (λ j → B (compPath-filler p q i j)) (f x) (f (q i))) (cong f p) (cong f (p ∙ q))
congFunct-dep {B = B} {x = x} f p q i j = f (compPath-filler p q i j)
cong₂Funct : ∀ {ℓ ℓ'} {A : Type ℓ} {x y : A} {B : Type ℓ'} (f : A → A → B) →
(p : x ≡ y) →
{u v : A} (q : u ≡ v) →
cong₂ f p q ≡ cong (λ x → f x u) p ∙ cong (f y) q
cong₂Funct {x = x} {y = y} f p {u = u} {v = v} q j i =
hcomp (λ k → λ { (i = i0) → f x u
; (i = i1) → f y (q k)
; (j = i0) → f (p i) (q (i ∧ k))})
(f (p i) u)
symDistr-filler : ∀ {ℓ} {A : Type ℓ} {x y z : A} (p : x ≡ y) (q : y ≡ z) → I → I → I → A
symDistr-filler {A = A} {z = z} p q i j k =
hfill (λ k → λ { (i = i0) → q (k ∨ j)
; (i = i1) → p (~ k ∧ j) })
(inS (invSides-filler q (sym p) i j))
k
symDistr : ∀ {ℓ} {A : Type ℓ} {x y z : A} (p : x ≡ y) (q : y ≡ z) → sym (p ∙ q) ≡ sym q ∙ sym p
symDistr p q i j = symDistr-filler p q j i i1
-- we can not write hcomp-isEquiv : {ϕ : I} → (p : I → Partial ϕ A) → isEquiv (λ (a : A [ ϕ ↦ p i0 ]) → hcomp p a)
-- due to size issues. But what we can write (compare to hfill) is:
hcomp-equivFillerSub : {ϕ : I} → (p : I → Partial ϕ A) → (a : A [ ϕ ↦ p i0 ])
→ (i : I)
→ A [ ϕ ∨ i ∨ ~ i ↦ (λ { (i = i0) → outS a
; (i = i1) → hcomp (λ i → p (~ i)) (hcomp p (outS a))
; (ϕ = i1) → p i0 1=1 }) ]
hcomp-equivFillerSub {ϕ = ϕ} p a i =
inS (hcomp (λ k → λ { (i = i1) → hfill (λ j → p (~ j)) (inS (hcomp p (outS a))) k
; (i = i0) → outS a
; (ϕ = i1) → p (~ k ∧ i) 1=1 })
(hfill p a i))
hcomp-equivFiller : {ϕ : I} → (p : I → Partial ϕ A) → (a : A [ ϕ ↦ p i0 ])
→ (i : I) → A
hcomp-equivFiller p a i = outS (hcomp-equivFillerSub p a i)
pentagonIdentity : (p : x ≡ y) → (q : y ≡ z) → (r : z ≡ w) → (s : w ≡ v)
→
(assoc p q (r ∙ s) ∙ assoc (p ∙ q) r s)
≡
cong (p ∙_) (assoc q r s) ∙∙ assoc p (q ∙ r) s ∙∙ cong (_∙ s) (assoc p q r)
pentagonIdentity {x = x} {y} p q r s =
(λ i →
(λ j → cong (p ∙_) (assoc q r s) (i ∧ j))
∙∙ (λ j → lemma₀₀ i j ∙ lemma₀₁ i j)
∙∙ (λ j → lemma₁₀ i j ∙ lemma₁₁ i j)
)
where
lemma₀₀ : ( i j : I) → _ ≡ _
lemma₀₀ i j i₁ =
hcomp
(λ k → λ { (j = i0) → p i₁
; (i₁ = i0) → x
; (i₁ = i1) → hcomp
(λ k₁ → λ { (i = i0) → (q (j ∧ k))
; (k = i0) → y
; (j = i0) → y
; (j = i1)(k = i1) → r (k₁ ∧ i)})
(q (j ∧ k))
}) (p i₁)
lemma₀₁ : ( i j : I) → hcomp
(λ k → λ {(i = i0) → q j
; (j = i0) → y
; (j = i1) → r (k ∧ i)
})
(q j) ≡ _
lemma₀₁ i j i₁ = (hcomp
(λ k → λ { (j = i1) → hcomp
(λ k₁ → λ { (i₁ = i0) → r i
; (k = i0) → r i
; (i = i1) → s (k₁ ∧ k ∧ i₁)
; (i₁ = i1)(k = i1) → s k₁ })
(r ((i₁ ∧ k) ∨ i))
; (i₁ = i0) → compPath-filler q r i j
; (i₁ = i1) → hcomp
(λ k₁ → λ { (k = i0) → r i
; (k = i1) → s k₁
; (i = i1) → s (k ∧ k₁)})
(r (i ∨ k))})
(hfill
(λ k → λ { (j = i1) → r k
; (i₁ = i1) → r k
; (i₁ = i0)(j = i0) → y })
(inS (q (i₁ ∨ j))) i))
lemma₁₁ : ( i j : I) → (r (i ∨ j)) ≡ _
lemma₁₁ i j i₁ =
hcomp
(λ k → λ { (i = i1) → s (i₁ ∧ k)
; (j = i1) → s (i₁ ∧ k)
; (i₁ = i0) → r (i ∨ j)
; (i₁ = i1) → s k
}) (r (i ∨ j ∨ i₁))
lemma₁₀-back : I → I → I → _
lemma₁₀-back i j i₁ =
hcomp
(λ k → λ {
(i₁ = i0) → x
; (i₁ = i1) → hcomp
(λ k₁ → λ { (k = i0) → q (j ∨ ~ i)
; (k = i1) → r (k₁ ∧ j)
; (j = i0) → q (k ∨ ~ i)
; (j = i1) → r (k₁ ∧ k)
; (i = i0) → r (k ∧ j ∧ k₁)
})
(q (k ∨ j ∨ ~ i))
; (i = i0)(j = i0) → (p ∙ q) i₁
})
(hcomp
(λ k → λ { (i₁ = i0) → x
; (i₁ = i1) → q ((j ∨ ~ i ) ∧ k)
; (j = i0)(i = i1) → p i₁
})
(p i₁))
lemma₁₀-front : I → I → I → _
lemma₁₀-front i j i₁ =
(((λ _ → x) ∙∙ compPath-filler p q j ∙∙
(λ i₁ →
hcomp
(λ k → λ { (i₁ = i0) → q j
; (i₁ = i1) → r (k ∧ (j ∨ i))
; (j = i0)(i = i0) → q i₁
; (j = i1) → r (i₁ ∧ k)
})
(q (j ∨ i₁))
)) i₁)
compPath-filler-in-filler :
(p : _ ≡ y) → (q : _ ≡ _ )
→ _≡_ {A = Square (p ∙ q) (p ∙ q) (λ _ → x) (λ _ → z)}
(λ i j → hcomp
(λ i₂ →
λ { (j = i0) → x
; (j = i1) → q (i₂ ∨ ~ i)
; (i = i0) → (p ∙ q) j
})
(compPath-filler p q (~ i) j))
(λ _ → p ∙ q)
compPath-filler-in-filler p q z i j =
hcomp
(λ k → λ {
(j = i0) → p i0
; (j = i1) → q (k ∨ ~ i ∧ ~ z)
; (i = i0) → hcomp
(λ i₂ → λ {
(j = i0) → p i0
;(j = i1) → q ((k ∨ ~ z) ∧ i₂)
;(z = i1) (k = i0) → p j
})
(p j)
; (i = i1) → compPath-filler p (λ i₁ → q (k ∧ i₁)) k j
; (z = i0) → hfill
((λ i₂ → λ { (j = i0) → p i0
; (j = i1) → q (i₂ ∨ ~ i)
; (i = i0) → (p ∙ q) j
}))
(inS ((compPath-filler p q (~ i) j))) k
; (z = i1) → compPath-filler p q k j
})
(compPath-filler p q (~ i ∧ ~ z) j)
cube-comp₋₀₋ :
(c : I → I → I → A)
→ {a' : Square _ _ _ _}
→ (λ i i₁ → c i i0 i₁) ≡ a'
→ (I → I → I → A)
cube-comp₋₀₋ c p i j k =
hcomp
(λ l → λ {
(i = i0) → c i0 j k
;(i = i1) → c i1 j k
;(j = i0) → p l i k
;(j = i1) → c i i1 k
;(k = i0) → c i j i0
;(k = i1) → c i j i1
})
(c i j k)
cube-comp₀₋₋ :
(c : I → I → I → A)
→ {a' : Square _ _ _ _}
→ (λ i i₁ → c i0 i i₁) ≡ a'
→ (I → I → I → A)
cube-comp₀₋₋ c p i j k =
hcomp
(λ l → λ {
(i = i0) → p l j k
;(i = i1) → c i1 j k
;(j = i0) → c i i0 k
;(j = i1) → c i i1 k
;(k = i0) → c i j i0
;(k = i1) → c i j i1
})
(c i j k)
lemma₁₀-back' : _
lemma₁₀-back' k j i₁ =
(cube-comp₋₀₋ (lemma₁₀-back)
(compPath-filler-in-filler p q)) k j i₁
lemma₁₀ : ( i j : I) → _ ≡ _
lemma₁₀ i j i₁ =
(cube-comp₀₋₋ lemma₁₀-front (sym lemma₁₀-back')) i j i₁
|
{
"alphanum_fraction": 0.3327557264,
"avg_line_length": 38.5532359081,
"ext": "agda",
"hexsha": "0e3686e5f8340df0a230d8c0eb3c39bf966149e9",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "knrafto/cubical",
"max_forks_repo_path": "Cubical/Foundations/GroupoidLaws.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "knrafto/cubical",
"max_issues_repo_path": "Cubical/Foundations/GroupoidLaws.agda",
"max_line_length": 139,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "knrafto/cubical",
"max_stars_repo_path": "Cubical/Foundations/GroupoidLaws.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 7503,
"size": 18467
}
|
{-# OPTIONS --rewriting #-}
-- {-# OPTIONS -v rewriting:100 -v tc.conv.atom:30 -v tc.inj.use:30 #-}
open import Common.Equality
{-# BUILTIN REWRITE _≡_ #-}
data Nat : Set where
zero : Nat
suc : Nat → Nat
_+_ : Nat → Nat → Nat
zero + n = n
(suc m) + n = suc (m + n)
postulate
plus-zero : ∀ x → (x + zero) ≡ x
{-# REWRITE plus-zero #-}
mutual
secret-number : Nat
secret-number = _
test : ∀ x → (x + secret-number) ≡ x
test x = refl
reveal : secret-number ≡ zero
reveal = refl
|
{
"alphanum_fraction": 0.578528827,
"avg_line_length": 16.2258064516,
"ext": "agda",
"hexsha": "aa4b205a55a464ca6e5eb83a71611909984dcce8",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "alhassy/agda",
"max_forks_repo_path": "test/Succeed/RewritingBlocked.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "alhassy/agda",
"max_issues_repo_path": "test/Succeed/RewritingBlocked.agda",
"max_line_length": 71,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "alhassy/agda",
"max_stars_repo_path": "test/Succeed/RewritingBlocked.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": 169,
"size": 503
}
|
-- Andreas and James, 2013-11-19
{-# OPTIONS --copatterns #-}
-- {-# OPTIONS -v tc.cover.splittree:15 -v tc.cc:15 #-}
open import Common.Level
open import Common.Product
mutual
data Delay (A : Set) : Set where
later : ∞Delay A → Delay A
record ∞Delay (A : Set) : Set where
coinductive
constructor delay
field
force : Delay A
open ∞Delay public
data Def {A : Set} : Delay A → Set where
later⇓ : ∀ (x : ∞Delay A) → Def (force x) → Def (later x)
data Ty : Set where
_⇒_ : (a b : Ty) → Ty
data Tm (Γ : Ty) : (a : Ty) → Set where
abs : ∀ a b (t : Tm (Γ ⇒ a) b) → Tm Γ (a ⇒ b)
data Val : (a : Ty) → Set where
lam : ∀ Γ a b (t : Tm (Γ ⇒ a) b) → Val (a ⇒ b)
postulate
eval : ∀ Γ a → Tm Γ a → Delay (Val a)
∞apply : ∀ a b → Val (a ⇒ b) → ∞Delay (Val b)
force (∞apply .a .b (lam Γ a b t)) = eval (Γ ⇒ a) b t
β-expand : ∀ Γ a b (t : Tm (Γ ⇒ a) b) →
Def (eval (Γ ⇒ a) b t) → Def (later (∞apply a b (lam Γ a b t)))
β-expand Γ a b t = later⇓ (∞apply a b (lam Γ a b t))
-- This line failed because of a missing reduction (due to wrong split tree).
|
{
"alphanum_fraction": 0.557195572,
"avg_line_length": 25.2093023256,
"ext": "agda",
"hexsha": "429fd89c69b3acde3f9d5cbc8bbd2c86f1a12031",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Succeed/CopatternsAndDotPatterns.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Succeed/CopatternsAndDotPatterns.agda",
"max_line_length": 77,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/CopatternsAndDotPatterns.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": 423,
"size": 1084
}
|
open import Prelude
open import Level using (Level) renaming (zero to lz; suc to ls)
open import Data.List.Properties as ListProps renaming (∷-injective to ∷-inj)
open import Data.String
open import Data.Nat as Nat using (decTotalOrder; _≤_; s≤s; z≤n)
open import Relation.Binary using (module DecTotalOrder)
module RW.Language.RTerm where
open import Reflection renaming (Term to AgTerm; Type to AgType)
public
open DecTotalOrder Nat.decTotalOrder using (total)
postulate
unsuportedSyntax : ∀{a}{A : Set a} → String → A
error : ∀{a}{A : Set a} → String → A
open Eq {{...}}
-- We'll consider constructor and definitions
-- as just names; we just need to know how to
-- translate them back into a correct AgTerm.
--
-- Function type is represented with the impl constructor.
data RTermName : Set where
rcon : Name → RTermName
rdef : Name → RTermName
impl : RTermName
showRTermName : RTermName → String
showRTermName (rcon x) = showName x
showRTermName (rdef x) = showName x
showRTermName impl = "→"
----------------------------------------
-- Equalities associated with RTermNames
rcon-inj : ∀{x y} → rcon x ≡ rcon y → x ≡ y
rcon-inj refl = refl
rdef-inj : ∀{x y} → rdef x ≡ rdef y → x ≡ y
rdef-inj refl = refl
_≟-RTermName_ : (n m : RTermName) → Dec (n ≡ m)
rcon x ≟-RTermName rcon y with x ≟-Name y
...| yes x≡y = yes (cong rcon x≡y)
...| no x≢y = no (x≢y ∘ rcon-inj)
rdef x ≟-RTermName rdef y with x ≟-Name y
...| yes x≡y = yes (cong rdef x≡y)
...| no x≢y = no (x≢y ∘ rdef-inj)
impl ≟-RTermName impl = yes refl
rcon _ ≟-RTermName rdef _ = no (λ ())
rcon _ ≟-RTermName impl = no (λ ())
rdef _ ≟-RTermName rcon _ = no (λ ())
rdef _ ≟-RTermName impl = no (λ ())
impl ≟-RTermName rcon _ = no (λ ())
impl ≟-RTermName rdef _ = no (λ ())
-- Now we'll define a very handy term representation.
-- We aim to reduce the amount of boilerplate code
-- needed to handle Agda's complex term representation.
--
-- The phantom A will allow us to use multiple representations
-- for unification variables and still prove termination
-- by using a (Fin n), before unifying.
data RTerm {a}(A : Set a) : Set a where
-- Out-of-bound variables. We use a phantom type A
-- to be able to (almost) seamless convert from
-- ℕ to (Fin n).
ovar : (x : A) → RTerm A
-- Variables bound inside the term itself, from
-- rlam's.
ivar : (n : ℕ) → RTerm A
-- Agda Literals
rlit : (l : Literal) → RTerm A
-- Lambda Abstraction
rlam : RTerm A → RTerm A
-- Applications
rapp : (n : RTermName)(ts : List (RTerm A)) → RTerm A
-- Equality Rules induced by RTerm's constructors
ovar-inj : ∀{a}{A : Set a}{x y : A} → ovar {a} {A} x ≡ ovar {a} {A} y → x ≡ y
ovar-inj refl = refl
ivar-inj : ∀{a A x y} → ivar {a} {A} x ≡ ivar {a} {A} y → x ≡ y
ivar-inj refl = refl
rlit-inj : ∀{a A x y} → rlit {a} {A} x ≡ rlit {a} {A} y → x ≡ y
rlit-inj refl = refl
rlam-inj : ∀{a A x y} → rlam {a} {A} x ≡ rlam {a} {A} y → x ≡ y
rlam-inj refl = refl
rapp-inj : ∀{a A n₁ n₂ l₁ l₂}
→ rapp {a} {A} n₁ l₁ ≡ rapp {a} {A} n₂ l₂
→ n₁ ≡ n₂ × l₁ ≡ l₂
rapp-inj refl = refl , refl
--------------------------
-- Generalized Comparison
mutual
compRTerm : ∀{A} ⦃ eqA : Eq A ⦄
→ (m n : RTerm A)
→ Dec (m ≡ n)
compRTerm ⦃ eq f ⦄ (ovar x) (ovar y) with f x y
...| yes x≡y = yes (cong ovar x≡y)
...| no x≢y = no (x≢y ∘ ovar-inj)
compRTerm (ivar x) (ivar y) with x ≟-ℕ y
...| yes x≡y = yes (cong ivar x≡y)
...| no x≢y = no (x≢y ∘ ivar-inj)
compRTerm (rlit x) (rlit y) with x ≟-Lit y
...| yes x≡y = yes (cong rlit x≡y)
...| no x≢y = no (x≢y ∘ rlit-inj)
compRTerm (rlam x) (rlam y) with compRTerm x y
...| yes x≡y = yes (cong rlam x≡y)
...| no x≢y = no (x≢y ∘ rlam-inj)
compRTerm (rapp x ax) (rapp y ay) with x ≟-RTermName y
...| no x≢y = no (x≢y ∘ p1 ∘ rapp-inj)
...| yes x≡y rewrite x≡y with compRTerm* ax ay
...| no ax≢ay = no (ax≢ay ∘ p2 ∘ rapp-inj)
...| yes ax≡ay = yes (cong (rapp y) ax≡ay)
compRTerm (ovar _) (ivar _) = no (λ ())
compRTerm (ovar _) (rlit _) = no (λ ())
compRTerm (ovar _) (rlam _) = no (λ ())
compRTerm (ovar _) (rapp _ _) = no (λ ())
compRTerm (ivar _) (ovar _) = no (λ ())
compRTerm (ivar _) (rlit _) = no (λ ())
compRTerm (ivar _) (rlam _) = no (λ ())
compRTerm (ivar _) (rapp _ _) = no (λ ())
compRTerm (rlit _) (ovar _) = no (λ ())
compRTerm (rlit _) (ivar _) = no (λ ())
compRTerm (rlit _) (rlam _) = no (λ ())
compRTerm (rlit _) (rapp _ _) = no (λ ())
compRTerm (rlam _) (ovar _) = no (λ ())
compRTerm (rlam _) (ivar _) = no (λ ())
compRTerm (rlam _) (rlit _) = no (λ ())
compRTerm (rlam _) (rapp _ _) = no (λ ())
compRTerm (rapp _ _) (ovar _) = no (λ ())
compRTerm (rapp _ _) (ivar _) = no (λ ())
compRTerm (rapp _ _) (rlit _) = no (λ ())
compRTerm (rapp _ _) (rlam _) = no (λ ())
compRTerm* : ∀{A} ⦃ eqA : Eq A ⦄
→ (x y : List (RTerm A))
→ Dec (x ≡ y)
compRTerm* [] [] = yes refl
compRTerm* (_ ∷ _) [] = no (λ ())
compRTerm* [] (_ ∷ _) = no (λ ())
compRTerm* (x ∷ xs) (y ∷ ys)
with compRTerm x y
...| no x≢y = no (x≢y ∘ p1 ∘ ∷-inj)
...| yes x≡y rewrite x≡y with compRTerm* xs ys
...| no xs≢ys = no (xs≢ys ∘ p2 ∘ ∷-inj)
...| yes xs≡ys = yes (cong (_∷_ y) xs≡ys)
instance
eq-RTerm : {A : Set}{{ eqA : Eq A }} → Eq (RTerm A)
eq-RTerm = eq compRTerm
-- Infix version
_≟-RTerm_ : ∀{A} ⦃ eqA : Eq A ⦄ → (x y : RTerm A) → Dec (x ≡ y)
_≟-RTerm_ = compRTerm
------------------------------
-- Term Replacement Functions
{-# TERMINATING #-}
replace : ∀{a b}{A : Set a}{B : Set b}
→ (ovar-f : A → RTerm B)
→ (ivar-f : ℕ → RTerm B)
→ RTerm A → RTerm B
replace f g (ovar x) = f x
replace f g (ivar n) = g n
replace _ _ (rlit l) = rlit l
replace f g (rlam x) = rlam (replace f g x)
replace f g (rapp n ts) = rapp n (map (replace f g) ts)
-- This is basically fmap...
replace-A : ∀{a b}{A : Set a}{B : Set b}
→ (A → RTerm B) → RTerm A → RTerm B
replace-A f = replace f ivar
-- equipped with a few usefull functor lemmas.
lemma-replace-rlam : ∀{a b}{A : Set a}{B : Set b}{f : A → RTerm B}{t : RTerm A}
→ replace-A f (rlam t) ≡ rlam (replace-A f t)
lemma-replace-rlam = refl
lemma-replace-rapp : ∀{a b}{A : Set a}{B : Set b}{f : A → RTerm B}{ts : List (RTerm A)}{n : RTermName}
→ replace-A f (rapp n ts) ≡ rapp n (map (replace-A f) ts)
lemma-replace-rapp = refl
_◇-A_ : ∀{a b c}{A : Set a}{B : Set b}{C : Set c}
→ (B → RTerm C) → (A → RTerm B)
→ A → RTerm C
f ◇-A g = replace-A f ∘ g
replace-ivar : ∀{a}{A : Set a}
→ (ℕ → RTerm A) → RTerm A → RTerm A
replace-ivar f = replace ovar f
----------------------
-- Counting utilities
{-# TERMINATING #-}
count : ∀{a}{A : Set a} → RTerm A → ℕ × ℕ
count (ovar _) = 1 , 0
count (ivar _) = 0 , 1
count (rlit _) = 0 , 0
count (rlam x) = count x
count (rapp _ xs) = sum2 (map count xs)
where
sum2 : List (ℕ × ℕ) → ℕ × ℕ
sum2 [] = 0 , 0
sum2 ((a , b) ∷ xs) with sum2 xs
...| a' , b' = a + a' , b + b'
#-A : ∀{a}{A : Set a} → RTerm A → ℕ
#-A = p1 ∘ count
#-ivar : ∀{a}{A : Set a} → RTerm A → ℕ
#-ivar = p2 ∘ count
-----------------------------------
-- Conversion from AgTerm to RTerm
-- compute the difference between two natural numbers, given an
-- ordering between them.
Δ_ : ∀ {m n} → m ≤ n → ℕ
Δ z≤n {k} = k
Δ s≤s p = Δ p
-- correctness proof of the difference operator Δ.
Δ-correct : ∀ {m n} (p : m ≤ n) → n ≡ m + Δ p
Δ-correct z≤n = refl
Δ-correct (s≤s p) = cong suc (Δ-correct p)
_-Δ-_ : ∀{m}(n : ℕ)(p : m ≤ n) → ℕ
n -Δ- z≤n = n
(suc n) -Δ- s≤s prf = n -Δ- prf
private
convertℕ : ∀{a}{A : Set a} → ℕ → RTerm A
convertℕ zero = rapp (rcon (quote zero)) []
convertℕ (suc n) = rapp (rcon (quote suc)) (convertℕ n ∷ [])
mutual
convert' : ℕ → AgTerm → RTerm ⊥
convert' d (var x []) with total d x
...| i1 d≤x = ivar (x ∸ d)
...| i2 d>x = ivar x
convert' d (lit (nat n)) = convertℕ n
convert' d (con c args)
= rapp (rcon c) (convertChildren d args)
convert' d (def c args)
= rapp (rdef c) (convertChildren d args)
convert' d (pi (arg (arg-info visible _) (el _ t₁)) (abs _ (el _ t₂)))
= rapp impl (convert' d t₁ ∷ convert' (suc d) t₂ ∷ [])
convert' d (pi _ (abs _ (el _ t₂))) = convert' (suc d) t₂
convert' d (lam _ (abs _ l))
= rlam (convert' (suc d) l)
convert' _ (pat-lam _ _)
= unsuportedSyntax "Pattern-Matching lambdas."
convert' _ (sort _)
= unsuportedSyntax "Sorts."
convert' _ unknown
= unsuportedSyntax "Unknown."
convert' _ (var _ (_ ∷ _))
= unsuportedSyntax "Variables with arguments."
convert' _ (lit _)
= unsuportedSyntax "Non-ℕ literals."
convert' _ (quote-goal _)
= unsuportedSyntax "Reflection constructs not supported"
convert' _ (quote-term _)
= unsuportedSyntax "Reflection constructs not supported"
convert' _ quote-context
= unsuportedSyntax "Reflection constructs not supported"
convert' _ (unquote-term _ _)
= unsuportedSyntax "Reflection constructs not supported"
convertChildren : ℕ → List (Arg AgTerm) → List (RTerm ⊥)
convertChildren d [] = []
convertChildren d (arg (arg-info visible _) x ∷ xs)
= convert' d x ∷ convertChildren d xs
convertChildren d (_ ∷ xs) = convertChildren d xs
Ag2RTerm : AgTerm → RTerm ⊥
Ag2RTerm a = convert' 0 a
------------------------------------------
-- Handling Types
Ag2RType : AgType → RTerm ⊥
Ag2RType (el _ t) = Ag2RTerm t
-----------------------------------------
-- Converting Back to Agda
open import RW.Utils.Monads using (MonadState; ST; get; inc) renaming (module Monad to MonadClass)
open MonadClass {{...}}
private
mutual
trevnoc' : RTerm ⊥ → AgTerm
trevnoc' (ovar ())
trevnoc' (ivar n) = var n []
trevnoc' (rlit l) = lit l
trevnoc' (rlam t) = lam visible (abs "_" (trevnoc' t))
trevnoc' (rapp (rcon x) ts) = con x (trevnocChildren ts)
trevnoc' (rapp (rdef x) ts) = def x (trevnocChildren ts)
trevnoc' (rapp impl (t1 ∷ t2 ∷ [])) = pi (arg (arg-info visible relevant)
(el unknown (trevnoc' t1)))
(abs "_" (el unknown (trevnoc' t2)))
trevnoc' (rapp impl _) = error "impl should have two arguments... always."
trevnocChildren : List (RTerm ⊥) → List (Arg AgTerm)
trevnocChildren [] = []
trevnocChildren (x ∷ xs) = arg (arg-info visible relevant) (trevnoc' x) ∷ trevnocChildren xs
R2AgTerm : RTerm ⊥ → AgTerm
R2AgTerm = trevnoc'
|
{
"alphanum_fraction": 0.5353109876,
"avg_line_length": 33.914893617,
"ext": "agda",
"hexsha": "844a10d75633493ceb528386d554cdda9e46e95a",
"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": "2856afd12b7dbbcc908482975638d99220f38bf2",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "VictorCMiraldo/agda-rw",
"max_forks_repo_path": "RW/Language/RTerm.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "2856afd12b7dbbcc908482975638d99220f38bf2",
"max_issues_repo_issues_event_max_datetime": "2015-05-28T14:48:03.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-02-06T15:03:33.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "VictorCMiraldo/agda-rw",
"max_issues_repo_path": "RW/Language/RTerm.agda",
"max_line_length": 104,
"max_stars_count": 16,
"max_stars_repo_head_hexsha": "2856afd12b7dbbcc908482975638d99220f38bf2",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "VictorCMiraldo/agda-rw",
"max_stars_repo_path": "RW/Language/RTerm.agda",
"max_stars_repo_stars_event_max_datetime": "2019-10-24T17:38:20.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-02-09T15:43:38.000Z",
"num_tokens": 4148,
"size": 11158
}
|
{-# OPTIONS --without-K --exact-split --allow-unsolved-metas #-}
module 21-image where
import 20-sequences
open 20-sequences public
{- We give the formal specification of propositional truncation. -}
precomp-Prop :
{ l1 l2 l3 : Level} {A : UU l1} (P : hProp l2) →
(A → type-Prop P) → (Q : hProp l3) →
(type-Prop P → type-Prop Q) → A → type-Prop Q
precomp-Prop P f Q g = g ∘ f
universal-property-propositional-truncation :
( l : Level) {l1 l2 : Level} {A : UU l1} (P : hProp l2) →
( A → type-Prop P) → UU (lsuc l ⊔ l1 ⊔ l2)
universal-property-propositional-truncation l P f =
(Q : hProp l) → is-equiv (precomp-Prop P f Q)
universal-property-propositional-truncation' :
( l : Level) {l1 l2 : Level} {A : UU l1} (P : hProp l2) →
( A → type-Prop P) → UU (lsuc l ⊔ l1 ⊔ l2)
universal-property-propositional-truncation' l {A = A} P f =
(Q : hProp l) → (A → type-Prop Q) → (type-Prop P → type-Prop Q)
universal-property-propositional-truncation-simplify :
{ l1 l2 : Level} {A : UU l1} (P : hProp l2)
( f : A → type-Prop P) →
( (l : Level) → universal-property-propositional-truncation' l P f) →
( (l : Level) → universal-property-propositional-truncation l P f)
universal-property-propositional-truncation-simplify P f up-P l Q =
is-equiv-is-prop
( is-prop-Π (λ x → is-prop-type-Prop Q))
( is-prop-Π (λ x → is-prop-type-Prop Q))
( up-P l Q)
precomp-Π-Prop :
{ l1 l2 l3 : Level} {A : UU l1} (P : hProp l2) →
( f : A → type-Prop P) (Q : type-Prop P → hProp l3) →
( g : (p : type-Prop P) → type-Prop (Q p)) → (x : A) → type-Prop (Q (f x))
precomp-Π-Prop P f Q g x = g (f x)
dependent-universal-property-propositional-truncation :
( l : Level) {l1 l2 : Level} {A : UU l1} (P : hProp l2) →
( A → type-Prop P) → UU (lsuc l ⊔ l1 ⊔ l2)
dependent-universal-property-propositional-truncation l P f =
(Q : type-Prop P → hProp l) → is-equiv (precomp-Π-Prop P f Q)
{- We introduce the image inclusion of a map. -}
precomp-emb :
{ l1 l2 l3 l4 : Level} {X : UU l1} {A : UU l2} (f : A → X)
{B : UU l3} ( i : B ↪ X) (q : hom-slice f (map-emb i)) →
{C : UU l4} ( j : C ↪ X) (r : hom-slice (map-emb i) (map-emb j)) →
hom-slice f (map-emb j)
precomp-emb f i q j r =
pair
( ( map-hom-slice (map-emb i) (map-emb j) r) ∘
( map-hom-slice f (map-emb i) q))
( ( triangle-hom-slice f (map-emb i) q) ∙h
( ( triangle-hom-slice (map-emb i) (map-emb j) r) ·r
( map-hom-slice f (map-emb i) q)))
is-prop-hom-slice :
{ l1 l2 l3 : Level} {X : UU l1} {A : UU l2} (f : A → X) →
{ B : UU l3} (i : B ↪ X) → is-prop (hom-slice f (map-emb i))
is-prop-hom-slice {X = X} f i =
is-prop-is-equiv
( (x : X) → fib f x → fib (map-emb i) x)
( fiberwise-hom-hom-slice f (map-emb i))
( is-equiv-fiberwise-hom-hom-slice f (map-emb i))
( is-prop-Π
( λ x → is-prop-Π
( λ p → is-prop-map-is-emb (map-emb i) (is-emb-map-emb i) x)))
universal-property-image :
( l : Level) {l1 l2 l3 : Level} {X : UU l1} {A : UU l2} (f : A → X) →
{ B : UU l3} (i : B ↪ X) (q : hom-slice f (map-emb i)) →
UU (lsuc l ⊔ l1 ⊔ l2 ⊔ l3)
universal-property-image l {X = X} f i q =
( C : UU l) (j : C ↪ X) → is-equiv (precomp-emb f i q j)
universal-property-image' :
( l : Level) {l1 l2 l3 : Level} {X : UU l1} {A : UU l2} (f : A → X) →
{ B : UU l3} (i : B ↪ X) (q : hom-slice f (map-emb i)) →
UU (lsuc l ⊔ l1 ⊔ l2 ⊔ l3)
universal-property-image' l {X = X} f i q =
( C : UU l) (j : C ↪ X) →
hom-slice f (map-emb j) → hom-slice (map-emb i) (map-emb j)
universal-property-image-universal-property-image' :
( l : Level) {l1 l2 l3 : Level} {X : UU l1} {A : UU l2} (f : A → X) →
{ B : UU l3} (i : B ↪ X) (q : hom-slice f (map-emb i)) →
universal-property-image' l f i q → universal-property-image l f i q
universal-property-image-universal-property-image' l f i q up' C j =
is-equiv-is-prop
( is-prop-hom-slice (map-emb i) j)
( is-prop-hom-slice f j)
( up' C j)
|
{
"alphanum_fraction": 0.5737041719,
"avg_line_length": 38.0288461538,
"ext": "agda",
"hexsha": "c5e80facfd6612ae63401016388fd6c7d91fa432",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "f4228d6ecfc6cdb119c6e8b0e711fea05b98b2d5",
"max_forks_repo_licenses": [
"CC-BY-4.0"
],
"max_forks_repo_name": "tadejpetric/HoTT-Intro",
"max_forks_repo_path": "Agda/21-image.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f4228d6ecfc6cdb119c6e8b0e711fea05b98b2d5",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"CC-BY-4.0"
],
"max_issues_repo_name": "tadejpetric/HoTT-Intro",
"max_issues_repo_path": "Agda/21-image.agda",
"max_line_length": 76,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "f4228d6ecfc6cdb119c6e8b0e711fea05b98b2d5",
"max_stars_repo_licenses": [
"CC-BY-4.0"
],
"max_stars_repo_name": "tadejpetric/HoTT-Intro",
"max_stars_repo_path": "Agda/21-image.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1637,
"size": 3955
}
|
open import Agda.Primitive
open import Common.Reflection
open import Common.Prelude
macro
deBruijn : Nat → Term → TC ⊤
deBruijn n = unify (lam visible (abs "x" (var n [])))
data Vec {a} (A : Set a) : Nat → Set a where
[] : Vec A 0
_∷_ : ∀ {n} → A → Vec A n → Vec A (suc n)
module _ {n} {a} {A : Set a} (xs : Vec A n) where
ok : Nat → Nat → Nat
ok k = deBruijn 5
-- Should give a nice error, not 'panic: variable @6 out of scope'.
not-ok : Nat → Nat → Nat
not-ok k = deBruijn 6
|
{
"alphanum_fraction": 0.5948103792,
"avg_line_length": 22.7727272727,
"ext": "agda",
"hexsha": "6a27d80f840b5ec49e1bedf09e9e7049481d915b",
"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/Issue2006.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/Issue2006.agda",
"max_line_length": 69,
"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/Issue2006.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": 190,
"size": 501
}
|
{- Other common operations and lemmas. -}
module TemporalOps.Common.Other where
open import Relation.Binary.HeterogeneousEquality as ≅ hiding (inspect)
open import Relation.Binary.PropositionalEquality hiding (inspect)
-- Time indexing (for clarity, synonym of function appliation at any level)
_at_ : ∀ {a b} {A : Set a} {B : A → Set b} →
((x : A) → B x) → ((x : A) → B x)
f at n = f n
infixl 45 _at_
-- Inspect idiom
data Singleton {a} {A : Set a} (x : A) : Set a where
_with≡_ : (y : A) → x ≡ y → Singleton x
inspect : ∀ {a} {A : Set a} (x : A) → Singleton x
inspect x = x with≡ refl
|
{
"alphanum_fraction": 0.6439267887,
"avg_line_length": 28.619047619,
"ext": "agda",
"hexsha": "0e9264be68f7f26e811519ba29cd8eb2fe6877d1",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DimaSamoz/temporal-type-systems",
"max_forks_repo_path": "src/TemporalOps/Common/Other.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DimaSamoz/temporal-type-systems",
"max_issues_repo_path": "src/TemporalOps/Common/Other.agda",
"max_line_length": 75,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DimaSamoz/temporal-type-systems",
"max_stars_repo_path": "src/TemporalOps/Common/Other.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-04T09:33:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-05-31T20:37:04.000Z",
"num_tokens": 199,
"size": 601
}
|
module Selective.Examples.Fibonacci where
open import Selective.ActorMonad
open import Prelude
open import Debug
open import Data.Nat.Show using (show)
data End : Set where
END : End
ℕ-message : MessageType
ℕ-message = [ ValueType ℕ ]ˡ
End-message : MessageType
End-message = [ ValueType End ]ˡ
Client-to-Server : InboxShape
Client-to-Server = ℕ-message ∷ [ End-message ]ˡ
Server-to-Client : InboxShape
Server-to-Client = [ ℕ-message ]ˡ
ServerInterface : InboxShape
ServerInterface = [ ReferenceType Server-to-Client ]ˡ ∷ Client-to-Server
ClientInterface : InboxShape
ClientInterface = [ ReferenceType Client-to-Server ]ˡ ∷ Server-to-Client
ServerRefs : TypingContext
ServerRefs = [ Server-to-Client ]ˡ
constServerRefs : {A : Set₁} → (A → TypingContext)
constServerRefs _ = ServerRefs
data ServerAction : Set₁ where
Next : ℕ → ServerAction
Done : ServerAction
server : ∀ {i} → ActorM i ServerInterface ⊤₁ [] constServerRefs
server = wait-for-client ∞>> run-fibonacci 1
where
wait-for-client = selective-receive (λ {
(Msg Z _) → true
; (Msg (S _) _) → false }) >>= λ {
record { msg = (Msg Z _) } → return tt
; record { msg = (Msg (S _) _) ; msg-ok = () } }
wait-for-value : ∀ {i} → ∞ActorM i ServerInterface ServerAction ServerRefs constServerRefs
wait-for-value = selective-receive (λ {
(Msg Z _) → false
; (Msg (S Z) _) → true
; (Msg (S (S Z)) _) → true
; (Msg (S (S (S ()))) x₁) }) >>= λ {
record { msg = (Msg Z _) ; msg-ok = () }
; record { msg = (Msg (S Z) (n ∷ [])) } → return₁ (Next n)
; record { msg = (Msg (S (S Z)) _) } → return₁ Done
; record { msg = (Msg (S (S (S ()))) _) }
}
run-fibonacci : ℕ → ∀ {i} → ∞ActorM i ServerInterface ⊤₁ ServerRefs constServerRefs
run-fibonacci x .force = begin do
Next n ← wait-for-value
where Done → return _
let next = x + n
Z ![t: Z ] [ lift next ]ᵃ
(run-fibonacci next)
ClientRefs : TypingContext
ClientRefs = [ Client-to-Server ]ˡ
constClientRefs : {A : Set₁} → (A → TypingContext)
constClientRefs _ = ClientRefs
client : ∀ {i} → ActorM i ClientInterface ⊤₁ [] constClientRefs
client = wait-for-server ∞>> run 10 0
where
wait-for-server : ∀ {i} → ∞ActorM i ClientInterface ⊤₁ [] constClientRefs
wait-for-server = selective-receive (λ {
(Msg Z _) → true
; (Msg (S _) _) → false }) >>= λ {
record { msg = (Msg Z _) ; msg-ok = msg-ok } → return tt
; record { msg = (Msg (S _) _) ; msg-ok = () }
}
wait-for-value : ∀ {i} → ∞ActorM i ClientInterface (Lift (lsuc lzero) ℕ) ClientRefs constClientRefs
wait-for-value = do
record { msg = Msg (S Z) (n ∷ []) } ← selective-receive (λ {
(Msg Z _) → false
; (Msg (S Z) _) → true
; (Msg (S (S ())) _) })
where
record { msg = (Msg Z _) ; msg-ok = () }
record { msg = (Msg (S (S ())) x₁) }
return n
run : ℕ → ℕ → ∀ {i} → ∞ActorM i ClientInterface ⊤₁ ClientRefs constClientRefs
run zero x = Z ![t: S Z ] [ lift END ]ᵃ
run (suc todo) x .force = begin do
(Z ![t: Z ] ((lift x) ∷ []))
(lift n) ← wait-for-value
let next = x + n
run (debug (show next) todo) next
spawner : ∀ {i} → ∞ActorM i [] ⊤₁ [] (λ _ → ClientInterface ∷ [ ServerInterface ]ˡ)
spawner = do
spawn server
spawn client
S Z ![t: Z ] [ [ Z ]>: ⊆-suc ⊆-refl ]ᵃ
Z ![t: Z ] [ [ S Z ]>: ⊆-suc ⊆-refl ]ᵃ
|
{
"alphanum_fraction": 0.564124057,
"avg_line_length": 33.1388888889,
"ext": "agda",
"hexsha": "ebc5743c98759bc15700f2ea7e3382a371638bf6",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "ae541df13d069df4eb1464f29fbaa9804aad439f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Zalastax/singly-typed-actors",
"max_forks_repo_path": "src/Selective/Examples/Fibonacci.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ae541df13d069df4eb1464f29fbaa9804aad439f",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Zalastax/singly-typed-actors",
"max_issues_repo_path": "src/Selective/Examples/Fibonacci.agda",
"max_line_length": 104,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "ae541df13d069df4eb1464f29fbaa9804aad439f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Zalastax/thesis",
"max_stars_repo_path": "src/Selective/Examples/Fibonacci.agda",
"max_stars_repo_stars_event_max_datetime": "2018-02-02T16:44:43.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-02-02T16:44:43.000Z",
"num_tokens": 1127,
"size": 3579
}
|
module Issue427 where
data T : Set where
tt : T
test = (λ {s : T} {t : T} → t) {tt} {tt}
f : {s t : T} → T
f = tt
test₂ = (let x = tt in λ {s : T} {t : T} → x) {tt} {tt}
|
{
"alphanum_fraction": 0.4494382022,
"avg_line_length": 12.7142857143,
"ext": "agda",
"hexsha": "fdaebb196f18a0040742d3acfcfbc7cc8c958e42",
"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/Issue427.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/Issue427.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": "test/Succeed/Issue427.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 83,
"size": 178
}
|
module ColDivSeq where
open import Data.Nat using (ℕ; zero; suc)
-- -----------------------------------------------
data OneCounter : Set where
ZeroCounter : OneCounter
data LTOneCounter : ℕ → Set where
Is : (ℕ → LTOneCounter 0) → OneCounter → LTOneCounter 0
data CollatzIsTrue : Set where
-- 再帰する時に引数を減らしたから、こっちも減らすべき?
-- いやちがうな
Is : (LTOneCounter 0) → CollatzIsTrue
data Hoge : Set where
Is : CollatzIsTrue → Hoge
-- 1x+1&3x+1DoNotHave2Counter : ℕ → (m : ℕ) → n:ℕ → (Hoge) →「R(m)=1かつR(n)=1かつm≠nかつR(m)≠R(n)」🔴
-- ↑ m, nは存在量化する
1x+1&3x+1isLT1Counter : ℕ → (m : ℕ) → ℕ → (Hoge) → LTOneCounter m
1x+1&3x+1isLT1Counter d m n = {!!}
fToA : ℕ → Hoge
-- ↓CollatzIsTrueにdがあらわれてないと、
-- 1x+1と3x+1のどちらを証明したか分からない
final : ℕ → CollatzIsTrue
fToA d = Is (final d)
final zero = {!!}
final (suc d) = Is (1x+1&3x+1isLT1Counter 1 0 2 (fToA d))
|
{
"alphanum_fraction": 0.5928008999,
"avg_line_length": 22.7948717949,
"ext": "agda",
"hexsha": "02810a92e349e85241c7f8e6bbcc297477717bda",
"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": "9117b6bec9880d8c0a5d6ee4399fd841c3544d84",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "righ1113/Agda",
"max_forks_repo_path": "ColDivSeq.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9117b6bec9880d8c0a5d6ee4399fd841c3544d84",
"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": "righ1113/Agda",
"max_issues_repo_path": "ColDivSeq.agda",
"max_line_length": 93,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "9117b6bec9880d8c0a5d6ee4399fd841c3544d84",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "righ1113/Agda",
"max_stars_repo_path": "ColDivSeq.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 417,
"size": 889
}
|
module Numeral.Natural.Coprime where
open import Logic
import Lvl
open import Numeral.Natural
open import Numeral.Natural.Relation.Divisibility
open import Relator.Equals
private variable n x y : ℕ
-- Two numbers are coprime when their only divisor is 1.
record Coprime (x : ℕ) (y : ℕ) : Stmt{Lvl.𝟎} where
constructor intro
field proof : (n ∣ x) → (n ∣ y) → (n ≡ 1)
|
{
"alphanum_fraction": 0.7150395778,
"avg_line_length": 23.6875,
"ext": "agda",
"hexsha": "99a2c02eb7456822dcbbb7eb139f90e6d49bd844",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Numeral/Natural/Coprime.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Numeral/Natural/Coprime.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": "Numeral/Natural/Coprime.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": 122,
"size": 379
}
|
open import Data.Empty
open import Data.List renaming (_∷_ to _∷ₗ_ ; [_] to [_]ₗ)
open import Data.Maybe
open import Data.Product
open import Data.Sum
open import Data.Unit
open import AEff
open import AwaitingComputations
open import EffectAnnotations
open import Finality
open import Preservation
open import ProcessPreservation
open import ProcessProgress
open import Progress
open import Renamings
open import Substitutions
open import Types
open import Relation.Binary.PropositionalEquality hiding ([_])
open import Relation.Nullary
open import Relation.Nullary.Negation
module ProcessFinality where
-- SMALL-STEP OPERATIONAL SEMANTICS FOR WELL-TYPED PROCESSES
-- WITH INLINED EVALUATION CONTEXT RULES
infix 10 _[_]↝↝_
data _[_]↝↝_ {Γ : Ctx} : {o o' : O} {PP : PType o} {QQ : PType o'} → Γ ⊢P⦂ PP → PP ⇝ QQ → Γ ⊢P⦂ QQ → Set where
-- RUNNING INDIVIDUAL COMPUTATIONS
run : {X : VType}
{o : O}
{i : I}
{M N : Γ ⊢M⦂ X ! (o , i)} →
M ↝↝ N →
---------------------------
(run M) [ id ]↝↝ (run N)
-- BROADCAST RULES
↑-∥ₗ : {o o' : O}
{PP : PType o}
{QQ : PType o'}
{op : Σₛ} →
(p : op ∈ₒ o) →
(V : Γ ⊢V⦂ `` (payload op)) →
(P : Γ ⊢P⦂ PP) →
(Q : Γ ⊢P⦂ QQ) →
------------------------------------------
((↑ op p V P) ∥ Q)
[ par ⇝-refl (⇝-↓ₚ {op = op}) ]↝↝
↑ op (∪ₒ-inl op p) V (P ∥ ↓ op V Q)
↑-∥ᵣ : {o o' : O}
{PP : PType o}
{QQ : PType o'}
{op : Σₛ} →
(p : op ∈ₒ o') →
(V : Γ ⊢V⦂ `` (payload op)) →
(P : Γ ⊢P⦂ PP) →
(Q : Γ ⊢P⦂ QQ) →
------------------------------------------
(P ∥ (↑ op p V Q))
[ par (⇝-↓ₚ {op = op}) ⇝-refl ]↝↝
↑ op (∪ₒ-inr op p) V (↓ op V P ∥ Q)
-- INTERRUPT PROPAGATION RULES
↓-run : {X : VType}
{o : O}
{i : I}
{op : Σₛ} →
(V : Γ ⊢V⦂ `` (payload op)) →
(M : Γ ⊢M⦂ X ! (o , i)) →
-----------------------------
↓ op V (run M)
[ id ]↝↝
run (↓ op V M)
↓-∥ : {o o' : O}
{PP : PType o}
{QQ : PType o'}
{op : Σₛ}
(V : Γ ⊢V⦂ `` (payload op)) →
(P : Γ ⊢P⦂ PP) →
(Q : Γ ⊢P⦂ QQ) →
-----------------------------
↓ op V (P ∥ Q)
[ ⇝-refl ]↝↝
((↓ op V P) ∥ (↓ op V Q))
↓-↑ : {o : O}
{PP : PType o}
{op : Σₛ}
{op' : Σₛ} →
(p : op' ∈ₒ o) →
(V : Γ ⊢V⦂ ``(payload op)) →
(W : Γ ⊢V⦂ ``(payload op')) →
(P : Γ ⊢P⦂ PP) →
-----------------------------------
↓ op V (↑ op' p W P)
[ ⇝-refl ]↝↝
↑ op' (↓ₚₚ-⊑ₒ PP op' p) W (↓ op V P)
-- SIGNAL HOISTING RULE
↑ : {X : VType}
{o : O}
{i : I} →
{op : Σₛ} →
(p : op ∈ₒ o) →
(V : Γ ⊢V⦂ `` (payload op)) →
(M : Γ ⊢M⦂ X ! (o , i)) →
-----------------------------
run (↑ op p V M)
[ id ]↝↝
↑ op p V (run M)
-- EVALUATION CONTEXT RULES
context-∥ₗ : {o o' o'' : O}
{PP : PType o}
{PP' : PType o''}
{QQ : PType o'}
{P : Γ ⊢P⦂ PP}
{P' : Γ ⊢P⦂ PP'}
{Q : Γ ⊢P⦂ QQ}
{p : PP ⇝ PP'} →
P [ p ]↝↝ P' →
------------------
P ∥ Q
[ par p ⇝-refl ]↝↝
P' ∥ Q
context-∥ᵣ : {o o' o'' : O}
{PP : PType o}
{QQ : PType o'}
{QQ' : PType o''}
{P : Γ ⊢P⦂ PP}
{Q : Γ ⊢P⦂ QQ}
{Q' : Γ ⊢P⦂ QQ'}
{r : QQ ⇝ QQ'} →
Q [ r ]↝↝ Q' →
------------------
P ∥ Q
[ par ⇝-refl r ]↝↝
P ∥ Q'
context-↑ : {o o' : O}
{PP : PType o}
{PP' : PType o'}
{op : Σₛ}
{p : op ∈ₒ o} →
{V : Γ ⊢V⦂ ``(payload op)}
{P : Γ ⊢P⦂ PP}
{P' : Γ ⊢P⦂ PP'}
{r : PP ⇝ PP'} →
P [ r ]↝↝ P' →
--------------------------
↑ op p V P
[ r ]↝↝
↑ op (⇝-⊑ₒ r op p) V P'
context-↓ : {o o' : O}
{PP : PType o}
{PP' : PType o'}
{op : Σₛ}
{V : Γ ⊢V⦂ ``(payload op)}
{P : Γ ⊢P⦂ PP}
{P' : Γ ⊢P⦂ PP'}
{r : PP ⇝ PP'} →
P [ r ]↝↝ P' →
----------------------
↓ op V P
[ ⇝-↓ₚ-cong r ]↝↝
↓ op V P'
-- ONE-TO-ONE CORRESPONDENCE BETWEEN THE TWO SETS OF REDUCTION RULES
[]↝↝-to-[]↝ : {Γ : Ctx}
{o o' : O}
{PP : PType o}
{QQ : PType o'}
{P : Γ ⊢P⦂ PP}
{Q : Γ ⊢P⦂ QQ}
{r : PP ⇝ QQ} →
P [ r ]↝↝ Q →
-----------------
P [ r ]↝ Q
[]↝↝-to-[]↝ (run r) =
run (↝↝-to-↝ r)
[]↝↝-to-[]↝ (↑-∥ₗ p V P Q) =
↑-∥ₗ p V P Q
[]↝↝-to-[]↝ (↑-∥ᵣ p V P Q) =
↑-∥ᵣ p V P Q
[]↝↝-to-[]↝ (↓-run V M) =
↓-run V M
[]↝↝-to-[]↝ (↓-∥ V P Q) =
↓-∥ V P Q
[]↝↝-to-[]↝ (↓-↑ p V W P) =
↓-↑ p V W P
[]↝↝-to-[]↝ (↑ p V M) =
↑ p V M
[]↝↝-to-[]↝ (context-∥ₗ r) =
context (_ ∥ₗ _) ([]↝↝-to-[]↝ r)
[]↝↝-to-[]↝ (context-∥ᵣ r) =
context (_ ∥ᵣ _) ([]↝↝-to-[]↝ r)
[]↝↝-to-[]↝ (context-↑ r) =
context (↑ _ _ _ _) ([]↝↝-to-[]↝ r)
[]↝↝-to-[]↝ (context-↓ r) =
context (↓ _ _ _) ([]↝↝-to-[]↝ r)
≡-app₂ : {X : Set}
{Y Z : X → Set}
{f g : (x : X) → Y x → Z x} →
f ≡ g →
(x : X) →
(y : Y x) →
-----------------------------
f x y ≡ g x y
≡-app₂ refl x y =
refl
[]↝-context-to-[]↝↝-aux : {Γ : Ctx}
{o o' : O}
{op : Σₛ}
{p : op ∈ₒ o}
{PP : PType o}
{QQ : PType o'} →
(F : Γ ⊢F⦂ PP) →
(r : proj₂ (hole-ty-f F) ⇝ QQ) →
----------------------------------------------------------
⇝-⊑ₒ (proj₂ (proj₂ (⇝-f-⇝ F r))) op p ≡ ⇝-f-∈ₒ F r op p
[]↝-context-to-[]↝↝-aux {Γ} {o} {o'} {op} {p} F r =
≡-app₂ (⊑ₒ-irrelevant (⇝-⊑ₒ (proj₂ (proj₂ (⇝-f-⇝ F r)))) (⇝-f-∈ₒ F r)) op p
mutual
[]↝-context-to-[]↝↝ : {Γ : Ctx}
{o o' : O}
{PP : PType o}
{QQ : PType o'} →
(F : Γ ⊢F⦂ PP) →
{P : Γ ⊢P⦂ proj₂ (hole-ty-f F)}
{Q : Γ ⊢P⦂ QQ}
{r : proj₂ (hole-ty-f F) ⇝ QQ} →
P [ r ]↝ Q →
-----------------------------------------------------------------------------
F [ P ]f
[ proj₂ (proj₂ (⇝-f-⇝ F r)) ]↝↝
(⇝-f F r) [ subst-i PType (λ o QQ → Γ ⊢P⦂ QQ) (⇝-f-tyₒ F r) (⇝-f-ty F r) Q ]f
[]↝-context-to-[]↝↝ [-] r =
[]↝-to-[]↝↝ r
[]↝-context-to-[]↝↝ (F ∥ₗ Q) r =
context-∥ₗ ([]↝-context-to-[]↝↝ F r)
[]↝-context-to-[]↝↝ (P ∥ᵣ F) r =
context-∥ᵣ ([]↝-context-to-[]↝↝ F r)
[]↝-context-to-[]↝↝ {Γ} {o} {o'} {PP} {QQ} (↑ op p V F) {P} {Q} {r'} r
rewrite sym ([]↝-context-to-[]↝↝-aux {op = op} {p = p} F r') =
context-↑ ([]↝-context-to-[]↝↝ F r)
[]↝-context-to-[]↝↝ (↓ op V F) r =
context-↓ ([]↝-context-to-[]↝↝ F r)
[]↝-to-[]↝↝ : {Γ : Ctx}
{o o' : O}
{PP : PType o}
{QQ : PType o'}
{P : Γ ⊢P⦂ PP}
{Q : Γ ⊢P⦂ QQ}
{r : PP ⇝ QQ} →
P [ r ]↝ Q →
-----------------
P [ r ]↝↝ Q
[]↝-to-[]↝↝ (run r) =
run (↝-to-↝↝ r)
[]↝-to-[]↝↝ (↑-∥ₗ p V P Q) =
↑-∥ₗ p V P Q
[]↝-to-[]↝↝ (↑-∥ᵣ p V P Q) =
↑-∥ᵣ p V P Q
[]↝-to-[]↝↝ (↓-run V M) =
↓-run V M
[]↝-to-[]↝↝ (↓-∥ V P Q) =
↓-∥ V P Q
[]↝-to-[]↝↝ (↓-↑ p V W P) =
↓-↑ p V W P
[]↝-to-[]↝↝ (↑ p V M) =
↑ p V M
[]↝-to-[]↝↝ (context F r) =
[]↝-context-to-[]↝↝ _ r
-- FINALITY OF RESULT FORMS
par-finality-↝↝ : {o o' : O}
{PP : PType o}
{QQ : PType o'}
{P : [] ⊢P⦂ PP} →
{Q : [] ⊢P⦂ QQ} →
ParResult⟨ P ⟩ →
(r : PP ⇝ QQ) →
P [ r ]↝↝ Q →
-----------------
⊥
par-finality-↝↝ (run R) .id (run r) =
run-finality-↝↝ R r
par-finality-↝↝ (run R) .id (↑ p V M) =
run-↑-⊥ R
par-finality-↝↝ (par R S) .(par _ ⇝-refl) (context-∥ₗ r') =
par-finality-↝↝ R _ r'
par-finality-↝↝ (par R S) .(par ⇝-refl _) (context-∥ᵣ r') =
par-finality-↝↝ S _ r'
proc-finality-↝↝ : {o o' : O}
{PP : PType o}
{QQ : PType o'}
{P : [] ⊢P⦂ PP} →
{Q : [] ⊢P⦂ QQ} →
ProcResult⟨ P ⟩ →
(r : PP ⇝ QQ) →
P [ r ]↝↝ Q →
-----------------
⊥
proc-finality-↝↝ (proc R) r r' =
par-finality-↝↝ R r r'
proc-finality-↝↝ (signal R) r (context-↑ r') =
proc-finality-↝↝ R r r'
{- LEMMA 4.2 -}
proc-finality : {o o' : O}
{PP : PType o}
{QQ : PType o'}
{P : [] ⊢P⦂ PP} →
{Q : [] ⊢P⦂ QQ} →
ProcResult⟨ P ⟩ →
(r : PP ⇝ QQ) →
P [ r ]↝ Q →
-----------------
⊥
proc-finality R r r' =
proc-finality-↝↝ R r ([]↝-to-[]↝↝ r')
|
{
"alphanum_fraction": 0.2910485417,
"avg_line_length": 27.4487534626,
"ext": "agda",
"hexsha": "9404f0da5e93684f90e76a60d22024ae98cdd912",
"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": "71ebed9f90a3eb37ae6cd209457bae23a4d122d1",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "danelahman/aeff-agda",
"max_forks_repo_path": "ProcessFinality.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "71ebed9f90a3eb37ae6cd209457bae23a4d122d1",
"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": "danelahman/aeff-agda",
"max_issues_repo_path": "ProcessFinality.agda",
"max_line_length": 110,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "71ebed9f90a3eb37ae6cd209457bae23a4d122d1",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "danelahman/aeff-agda",
"max_stars_repo_path": "ProcessFinality.agda",
"max_stars_repo_stars_event_max_datetime": "2021-03-22T22:48:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-07-17T00:15:00.000Z",
"num_tokens": 3957,
"size": 9909
}
|
{-
This file contains:
- Properties of groupoid truncations
-}
{-# OPTIONS --cubical --safe #-}
module Cubical.HITs.GroupoidTruncation.Properties where
open import Cubical.Foundations.Prelude
open import Cubical.HITs.GroupoidTruncation.Base
recGroupoidTrunc : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} (gB : isGroupoid B) → (A → B) → (∥ A ∥₁ → B)
recGroupoidTrunc gB f ∣ x ∣₁ = f x
recGroupoidTrunc gB f (squash₁ _ _ _ _ r s i j k) =
gB _ _ _ _
(λ m n → recGroupoidTrunc gB f (r m n))
(λ m n → recGroupoidTrunc gB f (s m n))
i j k
groupoidTruncFib : ∀ {ℓ ℓ'} {A : Type ℓ} (P : A → Type ℓ')
{a b : A} (sPb : isGroupoid (P b))
{p q : a ≡ b} {r s : p ≡ q} (u : r ≡ s) {a1 : P a} {b1 : P b}
{p1 : PathP (λ i → P (p i)) a1 b1}
{q1 : PathP (λ i → P (q i)) a1 b1}
(r1 : PathP (λ i → PathP (λ j → P (r i j)) a1 b1) p1 q1)
(s1 : PathP (λ i → PathP (λ j → P (s i j)) a1 b1) p1 q1)
→ PathP (λ i → PathP (λ j → PathP (λ k → P (u i j k)) a1 b1) p1 q1) r1 s1
groupoidTruncFib P {a} {b} sPb u {a1} {b1} {p1} {q1} r1 s1 i j k =
hcomp (λ l → λ { (i = i0) → r1 j k
; (i = i1) → s1 j k
; (j = i0) → p1 k
; (j = i1) → q1 k
; (k = i0) → a1
; (k = i1) → sPb b1 b1 refl refl (λ i j → Lb i j i1) refl l i j
})
(Lb i j k)
where
L : (i j : I) → P b
L i j = comp (λ k → P (u i j k))
(λ k → λ { (i = i0) → r1 j k
; (i = i1) → s1 j k
; (j = i0) → p1 k
; (j = i1) → q1 k })
a1
Lb : PathP (λ i → PathP (λ j → PathP (λ k → P (u i j k)) a1 (L i j)) p1 q1) r1 s1
Lb i j k = fill (λ k → P (u i j k))
(λ k → λ { (i = i0) → r1 j k
; (i = i1) → s1 j k
; (j = i0) → p1 k
; (j = i1) → q1 k })
(inS a1) k
groupoidTruncElim : ∀ {ℓ ℓ'} (A : Type ℓ) (B : ∥ A ∥₁ → Type ℓ')
(bG : (x : ∥ A ∥₁) → isGroupoid (B x))
(f : (x : A) → B ∣ x ∣₁) (x : ∥ A ∥₁) → B x
groupoidTruncElim A B bG f (∣ x ∣₁) = f x
groupoidTruncElim A B bG f (squash₁ x y p q r s i j k) =
groupoidTruncFib B (bG y)
(squash₁ x y p q r s)
(λ i j → groupoidTruncElim A B bG f (r i j))
(λ i j → groupoidTruncElim A B bG f (s i j))
i j k
|
{
"alphanum_fraction": 0.4091089109,
"avg_line_length": 38.8461538462,
"ext": "agda",
"hexsha": "e792c409e9edbe38227869aa6fa50ba06fb1fbb6",
"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": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "limemloh/cubical",
"max_forks_repo_path": "Cubical/HITs/GroupoidTruncation/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1",
"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": "limemloh/cubical",
"max_issues_repo_path": "Cubical/HITs/GroupoidTruncation/Properties.agda",
"max_line_length": 99,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "limemloh/cubical",
"max_stars_repo_path": "Cubical/HITs/GroupoidTruncation/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1041,
"size": 2525
}
|
module Thesis.SIRelBigStep.Lang where
open import Thesis.SIRelBigStep.Types public
open import Thesis.SIRelBigStep.Syntax public
open import Thesis.SIRelBigStep.DenSem public
open import Thesis.SIRelBigStep.OpSem public
open import Thesis.SIRelBigStep.SemEquiv public
|
{
"alphanum_fraction": 0.8661710037,
"avg_line_length": 33.625,
"ext": "agda",
"hexsha": "ecbbdad55ede7fbf080e31773eef7a7fe8aad1af",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z",
"max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "inc-lc/ilc-agda",
"max_forks_repo_path": "Thesis/SIRelBigStep/Lang.agda",
"max_issues_count": 6,
"max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "inc-lc/ilc-agda",
"max_issues_repo_path": "Thesis/SIRelBigStep/Lang.agda",
"max_line_length": 47,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "inc-lc/ilc-agda",
"max_stars_repo_path": "Thesis/SIRelBigStep/Lang.agda",
"max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z",
"num_tokens": 71,
"size": 269
}
|
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
open import Categories.Category.CartesianClosed.Locally
module Categories.Category.CartesianClosed.Locally.Properties {o ℓ e} {C : Category o ℓ e}
(LCCC : Locally C) where
open import Categories.Category.CartesianClosed
open import Categories.Category.Slice
open import Categories.Category.Slice.Properties
open import Categories.Functor
open import Categories.Functor.Slice
private
module C = Category C
open C
open Locally LCCC
variable
A B : Obj
module _ (f : A ⇒ B) where
open CartesianClosed (sliceCCC B)
private
C/A = Slice C A
C/B = Slice C B
C/B/f = Slice C/B (sliceobj f)
fObj : SliceObj C B
fObj = sliceobj f
i : Slice⇒ C ⊤ (fObj ^ fObj)
i = λg π₂
J : Functor C/A C/B/f
J = slice⇒slice-slice C f
I : Functor (Slice C/B (fObj ^ fObj)) C/B
I = pullback-functorial C/B slice-pullbacks i
K : Functor C/B/f (Slice C/B (fObj ^ fObj))
K = Base-F C/B (fObj ⇨-)
-- this functor should be the right adjoint functor of (BaseChange* C pullbacks f).
BaseChange⁎ : Functor C/A C/B
BaseChange⁎ = I ∘F K ∘F J
|
{
"alphanum_fraction": 0.6669505963,
"avg_line_length": 24.4583333333,
"ext": "agda",
"hexsha": "d66eb61ed5dbcd8d19d804ed2a0aeb790a6bdbb1",
"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": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bblfish/agda-categories",
"max_forks_repo_path": "src/Categories/Category/CartesianClosed/Locally/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a",
"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": "bblfish/agda-categories",
"max_issues_repo_path": "src/Categories/Category/CartesianClosed/Locally/Properties.agda",
"max_line_length": 90,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bblfish/agda-categories",
"max_stars_repo_path": "src/Categories/Category/CartesianClosed/Locally/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z",
"num_tokens": 360,
"size": 1174
}
|
------------------------------------------------------------------------
-- Types used (only) when calling out to Haskell via the FFI
------------------------------------------------------------------------
module Foreign.Haskell where
open import Coinduction
open import Data.Colist as C using ([]; _∷_)
------------------------------------------------------------------------
-- Simple types
-- A unit type.
data Unit : Set where
unit : Unit
{-# COMPILED_DATA Unit () () #-}
-- Potentially infinite lists.
infixr 5 _∷_
codata Colist (A : Set) : Set where
[] : Colist A
_∷_ : (x : A) (xs : Colist A) → Colist A
{-# COMPILED_DATA Colist [] [] (:) #-}
fromColist : ∀ {A} → C.Colist A → Colist A
fromColist [] = []
fromColist (x ∷ xs) = x ∷ fromColist (♭ xs)
toColist : ∀ {A} → Colist A → C.Colist A
toColist [] = []
toColist (x ∷ xs) = x ∷ ♯ toColist xs
|
{
"alphanum_fraction": 0.4536199095,
"avg_line_length": 23.8918918919,
"ext": "agda",
"hexsha": "5e31433dab42d82a85b04acd0c8ef470999868fd",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z",
"max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "isabella232/Lemmachine",
"max_forks_repo_path": "vendor/stdlib/src/Foreign/Haskell.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "larrytheliquid/Lemmachine",
"max_issues_repo_path": "vendor/stdlib/src/Foreign/Haskell.agda",
"max_line_length": 72,
"max_stars_count": 56,
"max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "isabella232/Lemmachine",
"max_stars_repo_path": "vendor/stdlib/src/Foreign/Haskell.agda",
"max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z",
"num_tokens": 240,
"size": 884
}
|
-- {-# OPTIONS -v tc.meta:100 #-}
-- Andreas, 2011-04-20
-- see Abel Pientka TLCA 2011
module PruningNonMillerPattern where
data _≡_ {A : Set}(a : A) : A -> Set where
refl : a ≡ a
data Nat : Set where
zero : Nat
suc : Nat -> Nat
test : let X : Nat -> Nat -> Nat
X = _
Y : Nat -> Nat -> Nat
Y = _
in (C : Set) ->
(({x y : Nat} -> X x x ≡ suc (Y x y)) ->
({x y : Nat} -> Y x x ≡ x) ->
({x y : Nat} -> X (Y x y) y ≡ X x x) -> C) -> C
test C k = k refl refl refl
{- none of these equations is immediately solvable. However,
from 1. we deduce that Y does not depend on its second argument, thus
from 2. we solve Y x y = x, and then
eqn. 3. simplifies to X x y = X x x, thus, X does not depend on its second arg,
we can then solve using 1. X x y = suc x
-}
-- a variant, where pruning is even triggered from a non-pattern
test' : let X : Nat -> Nat -> Nat
X = _
Y : Nat -> Nat -> Nat
Y = _
in (C : Set) ->
(({x y : Nat} -> X x (suc x) ≡ suc (Y x y)) -> -- non-pattern lhs
({x y : Nat} -> Y x x ≡ x) ->
({x y : Nat} -> X (Y x y) y ≡ X x x) -> C) -> C
test' C k = k refl refl refl
|
{
"alphanum_fraction": 0.4734375,
"avg_line_length": 32.8205128205,
"ext": "agda",
"hexsha": "1b57b2289bf5504aeb7b3da9e6b7776f211b5bf9",
"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/PruningNonMillerPattern.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/PruningNonMillerPattern.agda",
"max_line_length": 82,
"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/PruningNonMillerPattern.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 436,
"size": 1280
}
|
{-# OPTIONS --without-K --safe #-}
module Categories.Category.Cocomplete where
open import Level
open import Categories.Category using (Category)
open import Categories.Functor using (Functor)
open import Categories.Diagram.Colimit using (Colimit)
Cocomplete : (o ℓ e : Level) {o′ ℓ′ e′ : Level} (C : Category o′ ℓ′ e′) → Set _
Cocomplete o ℓ e C = ∀ {J : Category o ℓ e} (F : Functor J C) → Colimit F
|
{
"alphanum_fraction": 0.7019704433,
"avg_line_length": 31.2307692308,
"ext": "agda",
"hexsha": "13afc28ca4e2899bdde637a0d7521e11c9baced7",
"lang": "Agda",
"max_forks_count": 64,
"max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z",
"max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Code-distancing/agda-categories",
"max_forks_repo_path": "src/Categories/Category/Cocomplete.agda",
"max_issues_count": 236,
"max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Code-distancing/agda-categories",
"max_issues_repo_path": "src/Categories/Category/Cocomplete.agda",
"max_line_length": 79,
"max_stars_count": 279,
"max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Trebor-Huang/agda-categories",
"max_stars_repo_path": "src/Categories/Category/Cocomplete.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": 117,
"size": 406
}
|
------------------------------------------------------------------------------
-- Some proofs related to the power function
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOT.FOTC.Data.Nat.Pow.PropertiesATP where
open import FOT.FOTC.Data.Nat.Pow
open import FOTC.Base
open import FOTC.Data.Nat
open import FOTC.Data.Nat.Inequalities
open import FOTC.Data.Nat.UnaryNumbers
open import FOTC.Data.Nat.UnaryNumbers.TotalityATP
------------------------------------------------------------------------------
postulate 0^0≡1 : 0' ^ 0' ≡ 1'
{-# ATP prove 0^0≡1 #-}
0^Sx≡0 : ∀ {n} → N n → 0' ^ succ₁ n ≡ 0'
0^Sx≡0 {.zero} nzero = prf
where postulate prf : 0' ^ succ₁ zero ≡ 0'
{-# ATP prove prf #-}
0^Sx≡0 (nsucc {n} Nn) = prf
where postulate prf : 0' ^ succ₁ (succ₁ n) ≡ 0'
{-# ATP prove prf #-}
thm₁ : ∀ {n} → N n → 5' ≤ n → n ^ 5' ≤ 5' ^ n
thm₁ nzero h = prf
where postulate prf : zero ^ 5' ≤ 5' ^ zero
{-# ATP prove prf #-}
thm₁ (nsucc {n} Nn) h = prf (thm₁ Nn) h
where
postulate prf : (5' ≤ n → n ^ 5' ≤ 5' ^ n) →
5' ≤ succ₁ n →
succ₁ n ^ 5' ≤ 5' ^ succ₁ n
-- 2018-06-28: The ATPs could not prove the theorem (300 sec).
-- {-# ATP prove prf 5-N #-}
thm₂ : ∀ {n} → N n →
((2' ^ n) ∸ 1') + 1' + ((2' ^ n) ∸ 1') ≡ 2' ^ (n + 1') ∸ 1'
thm₂ nzero = prf
where
postulate prf : ((2' ^ zero) ∸ 1') + 1' + ((2' ^ zero) ∸ 1') ≡
2' ^ (zero + 1') ∸ 1'
{-# ATP prove prf #-}
thm₂ (nsucc {n} Nn) = prf (thm₂ Nn)
where
postulate prf : ((2' ^ n) ∸ 1') + 1' + ((2' ^ n) ∸ 1') ≡
2' ^ (n + 1') ∸ 1' →
((2' ^ succ₁ n) ∸ 1') + 1' + ((2' ^ succ₁ n) ∸ 1') ≡
2' ^ (succ₁ n + 1') ∸ 1'
-- 2018-06-28: The ATPs could not prove the theorem (300 sec).
-- {-# ATP prove prf #-}
|
{
"alphanum_fraction": 0.4330708661,
"avg_line_length": 33.3114754098,
"ext": "agda",
"hexsha": "b2e5c5fdcc23ae40249d1f7c7a713e73d5d27c97",
"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/Data/Nat/Pow/PropertiesATP.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/Data/Nat/Pow/PropertiesATP.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/Data/Nat/Pow/PropertiesATP.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": 761,
"size": 2032
}
|
module induction where
import Relation.Binary.PropositionalEquality as Eq
open Eq using (_≡_; refl; cong; sym)
open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; step-≡; _∎)
open import Data.Nat using (ℕ; zero; suc; _+_; _*_; _∸_; _^_)
-- -------------------------------
-- (zero + n) + p ≡ zero + (n + p)
--
-- (m + n) + p ≡ m + (n + p)
-- ---------------------------------
-- (suc m + n) + p ≡ suc m + (n + p)
-- 1)
-- In the beginning, we know nothing.
-- On the first day, we know zero.
-- 0 : ℕ
-- On the second day, we know one and about associativity of 0.
-- 0 : ℕ
-- 1 : ℕ (0 + 0) + 0 ≡ 0 + (0 + 0)
-- On the third day, we know two and about associativity of 1.
-- 0 : ℕ
-- 1 : ℕ (0 + 0) + 0 ≡ 0 + (0 + 0)
-- 2 : ℕ (0 + 1) + 0 ≡ 0 + (1 + 0) (0 + 1) + 1 ≡ 0 + (1 + 1) (0 + 0) + 1 ≡ 0 + (0 + 1) (1 + 0) + 0 ≡ 1 + (0 + 0)
-- On the fourth day, we know two and about associativity of 2.
-- 0 : ℕ
-- 1 : ℕ (0 + 0) + 0 ≡ 0 + (0 + 0)
-- 2 : ℕ (0 + 1) + 0 ≡ 0 + (1 + 0) (0 + 1) + 1 ≡ 0 + (1 + 1) (0 + 0) + 1 ≡ 0 + (0 + 1) (1 + 0) + 0 ≡ 1 + (0 + 0) (1 + 0) + 1 ≡ 1 + (0 + 1) (1 + 1) + 0 ≡ 1 + (1 + 0) (1 + 1) + 1 ≡ 1 + (1 + 1)
-- 3 : ℕ (0 + 2) + 0 ≡ 0 + (2 + 0) (0 + 2) + 2 ≡ 0 + (2 + 2) (0 + 0) + 2 ≡ 0 + (0 + 2) (0 + 2) + 1 ≡ 0 + (2 + 1) (0 + 1) + 2 ≡ 0 + (1 + 2) (2 + 0) + 0 ≡ 2 + (0 + 0) (2 + 1) + 0 ≡ 2 + (1 + 0) (2 + 2) + 0 ≡ 2 + (2 + 0) (2 + 0) + 1 ≡ 2 + (0 + 1) (2 + 0) + 2 ≡ 2 + (0 + 2) (2 + 1) + 1 ≡ 2 + (1 + 1) (2 + 1) + 2 ≡ 2 + (1 + 2) (2 + 2) + 1 ≡ 2 + (2 + 1) (2 + 2) + 2 ≡ 2 + (2 + 2)
-- 2)
+-assoc : ∀ (m n p : ℕ) → (m + n) + p ≡ m + (n + p)
+-assoc zero n p =
begin
(zero + n) + p
≡⟨⟩
n + p
≡⟨⟩
zero + (n + p)
∎
+-assoc (suc m) n p =
begin
(suc m + n) + p
≡⟨⟩
suc (m + n) + p
≡⟨⟩
suc ((m + n) + p)
≡⟨ cong suc (+-assoc m n p) ⟩
suc (m + (n + p))
≡⟨⟩
suc m + (n + p)
∎
+-identityʳ : ∀ (m : ℕ) → m + zero ≡ m
+-identityʳ zero =
begin
zero + zero
≡⟨⟩
zero
∎
+-identityʳ (suc m) =
begin
suc m + zero
≡⟨⟩
suc (m + zero)
≡⟨ cong suc (+-identityʳ m) ⟩
suc m
∎
+-suc : ∀ (m n : ℕ) → m + suc n ≡ suc (m + n)
+-suc zero n =
begin
zero + suc n
≡⟨⟩
suc n
≡⟨⟩
suc (zero + n)
∎
+-suc (suc m) n =
begin
suc m + suc n
≡⟨⟩
suc (m + suc n)
≡⟨ cong suc (+-suc m n) ⟩
suc (suc (m + n))
≡⟨⟩
suc (suc m + n)
∎
+-comm : ∀ (m n : ℕ) → m + n ≡ n + m
+-comm m zero =
begin
m + zero
≡⟨ +-identityʳ m ⟩
m
≡⟨⟩
zero + m
∎
+-comm m (suc n) =
begin
m + suc n
≡⟨ +-suc m n ⟩
suc (m + n)
≡⟨ cong suc (+-comm m n) ⟩
suc (n + m)
≡⟨⟩
suc n + m
∎
+-swap : ∀ (m n p : ℕ) → m + (n + p) ≡ n + (m + p)
+-swap m n p =
begin
m + (n + p)
≡⟨ sym (+-assoc m n p) ⟩
(m + n) + p
≡⟨ cong (_+ p) (+-comm m n) ⟩
(n + m) + p
≡⟨ +-assoc n m p ⟩
n + (m + p)
∎
-- +-swap : ∀ (m n p : ℕ) → m + (n + p) ≡ n + (m + p)
-- +-swap m n p rewrite sym (+-assoc m n p)
-- | cong (_+ p) (+-comm m n)
-- | +-assoc n m p
-- = refl
-- 3)
*-distrib-+ : ∀ (m n p : ℕ) → (m + n) * p ≡ m * p + n * p
*-distrib-+ zero n p =
begin
(zero + n) * p
≡⟨⟩
n * p
≡⟨⟩
zero * p + n * p
∎
*-distrib-+ (suc m) n p =
begin
((suc m) + n) * p
≡⟨⟩
suc (m + n) * p
≡⟨⟩
p + ((m + n) * p)
≡⟨ cong (p +_) (*-distrib-+ m n p) ⟩
p + (m * p + n * p)
≡⟨ sym (+-assoc p (m * p) (n * p))⟩
(p + m * p) + n * p
≡⟨⟩
(suc m) * p + n * p
∎
-- 4)
*-assoc : ∀ (m n p : ℕ) → (m * n) * p ≡ m * (n * p)
*-assoc zero n p =
begin
(zero * n) * p
≡⟨⟩
zero * p
≡⟨⟩
zero
≡⟨⟩
zero * n
≡⟨⟩
zero * (n * p)
∎
*-assoc (suc m) n p =
begin
(suc m * n) * p
≡⟨⟩
(n + m * n) * p
≡⟨ *-distrib-+ n (m * n) p ⟩
(n * p) + (m * n) * p
≡⟨ cong ((n * p) +_) (*-assoc m n p) ⟩
(n * p) + m * (n * p)
≡⟨⟩
suc m * (n * p)
∎
-- 5)
*-absorbingʳ : ∀ (m : ℕ) → m * zero ≡ zero
*-absorbingʳ zero =
begin
zero * zero
≡⟨⟩
zero
∎
*-absorbingʳ (suc m) =
begin
suc m * zero
≡⟨⟩
zero + m * zero
≡⟨ cong (zero +_) (*-absorbingʳ m) ⟩
zero + zero
≡⟨⟩
zero
∎
*-suc : ∀ (m n : ℕ) → m * suc n ≡ m + m * n
*-suc zero n =
begin
zero * (suc n)
≡⟨⟩
zero
≡⟨⟩
zero * n
≡⟨⟩
zero + zero * n
∎
*-suc (suc m) n =
begin
suc m * suc n
≡⟨⟩
(suc n) + (m * suc n)
≡⟨ cong ((suc n) +_) (*-suc m n) ⟩
(suc n) + (m + m * n)
≡⟨⟩
suc (n + (m + m * n))
≡⟨ cong suc (sym (+-assoc n m (m * n))) ⟩
suc ((n + m) + m * n)
≡⟨ cong (λ {term → suc (term + m * n)}) (+-comm n m) ⟩
suc ((m + n) + m * n)
≡⟨ cong suc (+-assoc m n (m * n)) ⟩
suc (m + (n + m * n))
≡⟨⟩
suc (m + (suc m * n))
≡⟨⟩
suc m + suc m * n
∎
*-comm : ∀ (m n : ℕ) → m * n ≡ n * m
*-comm m zero =
begin
m * zero
≡⟨ *-absorbingʳ m ⟩
zero
≡⟨⟩
zero * m
∎
*-comm m (suc n) =
begin
m * suc n
≡⟨ *-suc m n ⟩
m + m * n
≡⟨ cong (m +_) (*-comm m n) ⟩
m + n * m
≡⟨⟩
suc n * m
∎
-- 6)
0∸n≡0 : ∀ (n : ℕ) → zero ∸ n ≡ zero
0∸n≡0 zero =
begin
zero ∸ zero
≡⟨⟩
zero
∎
0∸n≡0 (suc n) =
begin
zero ∸ suc n
≡⟨⟩
zero
∎
-- No induction needed, just prove it holds for 0 and for suc n. (Holds because of definition of ∸)
-- 7)
0∸n≡0∸n+p : ∀ (n p : ℕ) → zero ∸ n ≡ zero ∸ (n + p)
0∸n≡0∸n+p n zero =
begin
zero ∸ n
≡⟨ cong (zero ∸_) (sym (+-identityʳ n)) ⟩
zero ∸ (n + zero)
∎
0∸n≡0∸n+p n (suc p) =
begin
zero ∸ n
≡⟨ 0∸n≡0 n ⟩
zero
≡⟨⟩
zero ∸ suc (n + p)
≡⟨ cong (zero ∸_) (sym (+-suc n p)) ⟩
zero ∸ (n + suc p)
∎
∸-+-assoc : ∀ (m n p : ℕ) → (m ∸ n) ∸ p ≡ m ∸ (n + p)
∸-+-assoc zero n p =
begin
(zero ∸ n) ∸ p
≡⟨ cong (_∸ p) (0∸n≡0 n) ⟩
zero ∸ p
≡⟨ 0∸n≡0 p ⟩
zero
≡⟨ sym (0∸n≡0 n) ⟩
zero ∸ n
≡⟨ 0∸n≡0∸n+p n p ⟩
zero ∸ (n + p)
∎
∸-+-assoc (suc m) zero p =
begin
(suc m ∸ zero) ∸ p
≡⟨⟩
suc m ∸ (zero + p)
∎
∸-+-assoc (suc m) (suc n) p =
begin
(suc m ∸ suc n) ∸ p
≡⟨⟩
(m ∸ n) ∸ p
≡⟨ ∸-+-assoc m n p ⟩
m ∸ (n + p)
≡⟨⟩
suc m ∸ suc (n + p)
≡⟨⟩
suc m ∸ (suc n + p)
∎
-- 8)
*-identityˡ : ∀ (n : ℕ) → 1 * n ≡ n
*-identityˡ n =
begin
1 * n
≡⟨⟩
(suc zero) * n
≡⟨⟩
n + (zero * n)
≡⟨⟩
n + zero
≡⟨ +-identityʳ n ⟩
n
∎
^-distribˡ-+-* : ∀ (m n p : ℕ) → m ^ (n + p) ≡ (m ^ n) * (m ^ p)
^-distribˡ-+-* m zero p =
begin
m ^ (zero + p)
≡⟨⟩
m ^ p
≡⟨ sym (*-identityˡ (m ^ p)) ⟩
1 * m ^ p
≡⟨⟩
(m ^ zero) * (m ^ p)
∎
^-distribˡ-+-* m (suc n) p =
begin
m ^ (suc n + p)
≡⟨⟩
m ^ suc (n + p)
≡⟨⟩
m * (m ^ (n + p))
≡⟨ cong (m *_) (^-distribˡ-+-* m n p) ⟩
m * (m ^ n * m ^ p)
≡⟨ sym (*-assoc m (m ^ n) (m ^ p)) ⟩
(m * m ^ n) * m ^ p
≡⟨⟩
(m ^ suc n) * (m ^ p)
∎
^-distribʳ-* : ∀ (m n p : ℕ) → (m * n) ^ p ≡ (m ^ p) * (n ^ p)
^-distribʳ-* m n zero =
begin
(m * n) ^ zero
≡⟨⟩
1
≡⟨⟩
1 * 1
≡⟨⟩
(m ^ zero) * (n ^ zero)
∎
^-distribʳ-* m n (suc p) =
begin
(m * n) ^ (suc p)
≡⟨⟩
(m * n) * (m * n) ^ p
≡⟨ cong ((m * n) *_) (^-distribʳ-* m n p) ⟩
(m * n) * ((m ^ p) * (n ^ p))
≡⟨ sym (*-assoc (m * n) (m ^ p) (n ^ p)) ⟩
((m * n) * (m ^ p)) * (n ^ p)
≡⟨ cong (_* (n ^ p)) (*-assoc m n (m ^ p)) ⟩
(m * (n * (m ^ p))) * (n ^ p)
≡⟨ cong (λ {term → (m * term) * (n ^ p)}) (*-comm n (m ^ p)) ⟩
(m * ((m ^ p) * n)) * (n ^ p)
≡⟨ cong (_* (n ^ p)) (sym (*-assoc m (m ^ p) n)) ⟩
(m * (m ^ p) * n) * (n ^ p)
≡⟨ *-assoc (m * (m ^ p)) n (n ^ p) ⟩
m * (m ^ p) * (n * (n ^ p))
≡⟨⟩
(m ^ suc p) * (n ^ suc p)
∎
^-*-assoc : ∀ (m n p : ℕ) → (m ^ n) ^ p ≡ m ^ (n * p)
^-*-assoc m n zero =
begin
(m ^ n) ^ zero
≡⟨⟩
1
≡⟨⟩
m ^ zero
≡⟨ cong (m ^_) (sym (*-absorbingʳ n)) ⟩
m ^ (n * zero)
∎
^-*-assoc m n (suc p) =
begin
(m ^ n) ^ suc p
≡⟨⟩
(m ^ n) * (m ^ n) ^ p
≡⟨ cong ((m ^ n) *_) (^-*-assoc m n p) ⟩
(m ^ n) * (m ^ (n * p))
≡⟨ cong (λ {term → (m ^ n) * (m ^ term)}) (*-comm n p) ⟩
(m ^ n) * (m ^ (p * n))
≡⟨ sym (^-distribˡ-+-* m n (p * n)) ⟩
m ^ (n + p * n)
≡⟨⟩
m ^ (suc p * n)
≡⟨ cong (m ^_) (*-comm (suc p) n) ⟩
m ^ (n * suc p)
∎
-- 9)
data Bin : Set where
- : Bin
_O : Bin → Bin
_I : Bin → Bin
inc : Bin → Bin
inc - = - I
inc (rest O) = rest I
inc (rest I) = (inc rest) O
to : ℕ → Bin
to zero = - O
to (suc n) = inc (to n)
from : Bin → ℕ
from - = 0
from (rest O) = 2 * from rest
from (rest I) = 2 * from rest + 1
bin-inverse-suc-inc : ∀ (b : Bin) → from (inc b) ≡ suc (from b)
bin-inverse-suc-inc - =
begin
from (inc -)
≡⟨⟩
from (- I)
≡⟨⟩
2 * from - + 1
≡⟨⟩
2 * 0 + 1
≡⟨⟩
0 + 1
≡⟨⟩
1
≡⟨⟩
suc 0
≡⟨⟩
suc (from -)
∎
bin-inverse-suc-inc (b O) =
begin
from (inc (b O))
≡⟨⟩
from (b I)
≡⟨⟩
2 * from b + 1
≡⟨ +-comm (2 * from b) 1 ⟩
suc (2 * from b)
≡⟨⟩
suc (from (b O))
∎
bin-inverse-suc-inc (b I) =
begin
from (inc (b I))
≡⟨⟩
from ((inc b) O)
≡⟨⟩
2 * from (inc b)
≡⟨ cong (2 *_) (bin-inverse-suc-inc b) ⟩
2 * suc (from b)
≡⟨ *-comm 2 (suc (from b)) ⟩
suc (from b) * 2
≡⟨⟩
(1 + from b) * 2
≡⟨ *-distrib-+ 1 (from b) 2 ⟩
1 * 2 + from b * 2
≡⟨ cong (1 * 2 +_) (*-comm (from b) 2) ⟩
1 * 2 + 2 * from b
≡⟨⟩
2 + 2 * from b
≡⟨⟩
suc 1 + 2 * from b
≡⟨⟩
suc (1 + 2 * from b)
≡⟨ cong (suc) (+-comm 1 (2 * from b)) ⟩
suc (2 * from b + 1)
≡⟨⟩
suc (from (b I))
∎
-- ∀ (b : Bin) → to (from b) ≡ b
-- This does not work, as "from" is a surjective function. Both "-" and "- O" from Bin map into 0 from ℕ. Surjective functions have no left inverse.
-- 0 would have to map into two values, making the inverse of "from" not a function.
-- This works, as "to" is an injective function. 0 from ℕ maps (according to our definition) into "- O" in Bin. Injective functions have a left inverse.
-- "from" is a left inverse to "to". Note that there are infinitely many left inverses, since "-" could be mapped to any value in ℕ.
from∘to≡idₗ : ∀ (n : ℕ) → from (to n) ≡ n
from∘to≡idₗ zero =
begin
from (to zero)
≡⟨⟩
from (- O)
≡⟨⟩
2 * from -
≡⟨⟩
2 * 0
≡⟨⟩
zero
∎
from∘to≡idₗ (suc n) =
begin
from (to (suc n))
≡⟨⟩
from (inc (to n))
≡⟨ bin-inverse-suc-inc (to n) ⟩
suc (from (to n))
≡⟨ cong suc (from∘to≡idₗ n) ⟩
suc n
∎
|
{
"alphanum_fraction": 0.3785796105,
"avg_line_length": 19.6179775281,
"ext": "agda",
"hexsha": "7300e638625217f9bbee465ffc9dff0a2751f4e3",
"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": "64a00f1f97f053d246d5b9deab090e75d923fe8f",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "aronerben/agda-playground",
"max_forks_repo_path": "plfa/induction.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "64a00f1f97f053d246d5b9deab090e75d923fe8f",
"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": "aronerben/agda-playground",
"max_issues_repo_path": "plfa/induction.agda",
"max_line_length": 414,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "64a00f1f97f053d246d5b9deab090e75d923fe8f",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "aronerben/agda-playground",
"max_stars_repo_path": "plfa/induction.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 5575,
"size": 10476
}
|
module LecDiff where
open import CS410-Prelude
open import CS410-Nat
open import LecSigma
data Data : Set1 where
_+D_ _*D_ : Data -> Data -> Data
label : Set -> Data
rec : Data
infixr 4 _+D_
infixr 5 _*D_
[[_]] : Data -> Set -> Set
[[ S +D T ]] R = [[ S ]] R + [[ T ]] R
[[ S *D T ]] R = [[ S ]] R * [[ T ]] R
[[ label X ]] R = X
[[ rec ]] R = R
data Mu (D : Data) : Set where
<_> : [[ D ]] (Mu D) -> Mu D
-- example: Natural Numbers
NAT : Data
NAT = label One +D rec
pattern ZERO = < inl <> >
pattern SUC n = < inr n >
#_ : Nat -> Mu NAT
# zero = ZERO
# (suc n) = SUC (# n)
_+DN_ : Mu NAT -> Mu NAT -> Mu NAT
ZERO +DN n = n
SUC m +DN n = SUC (m +DN n)
_<=DN_ : Mu NAT -> Mu NAT -> Two
ZERO <=DN n = tt
SUC m <=DN ZERO = ff
SUC m <=DN SUC n = m <=DN n
-- example: binary trees with nodes labelled by numbers
BST : Data
BST = label One +D rec *D label (Mu NAT) *D rec
pattern LEAF = < inl <> >
pattern NODE l n r = < inr (l , n , r) >
insert : Mu NAT -> Mu BST -> Mu BST
insert x LEAF = NODE LEAF x LEAF
insert x (NODE l y r) with x <=DN y
insert x (NODE l y r) | tt = NODE (insert x l) y r
insert x (NODE l y r) | ff = NODE l y (insert x r)
myBST : Mu BST
myBST = NODE (NODE (NODE LEAF (# 1) LEAF) (# 2) LEAF)
(# 4)
(NODE (NODE LEAF (# 5) LEAF) (# 7) LEAF)
myBST' : Mu BST
myBST' = insert (# 3) myBST
------------------------
Diff : Data -> Data
Diff (S +D T) = Diff S +D Diff T
Diff (S *D T) = Diff S *D T +D S *D Diff T
Diff (label X) = label Zero
Diff rec = label One
plug : {R : Set}(D : Data) -> [[ Diff D ]] R -> R -> [[ D ]] R
plug (S +D T) (inl s') r = inl (plug S s' r)
plug (S +D T) (inr t') r = inr (plug T t' r)
plug (S *D T) (inl (s' , t)) r = plug S s' r , t
plug (S *D T) (inr (s , t')) r = s , plug T t' r
plug (label X) () r
plug rec <> r = r
Shape : Data -> Set
Shape D = [[ D ]] One
Positions : (D : Data) -> Shape D -> Set
Positions (D +D E) (inl d) = Positions D d
Positions (D +D E) (inr e) = Positions E e
Positions (D *D E) (d , e) = Positions D d + Positions E e
Positions (label X) x = Zero
Positions rec <> = One
|
{
"alphanum_fraction": 0.5155963303,
"avg_line_length": 23.4408602151,
"ext": "agda",
"hexsha": "a6ad7b385647eeeaf765cf2a946d3b37f9462a74",
"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": "523a8749f49c914bcd28402116dcbe79a78dbbf4",
"max_forks_repo_licenses": [
"CC0-1.0"
],
"max_forks_repo_name": "clarkdm/CS410",
"max_forks_repo_path": "LecDiff.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "523a8749f49c914bcd28402116dcbe79a78dbbf4",
"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": "clarkdm/CS410",
"max_issues_repo_path": "LecDiff.agda",
"max_line_length": 62,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "523a8749f49c914bcd28402116dcbe79a78dbbf4",
"max_stars_repo_licenses": [
"CC0-1.0"
],
"max_stars_repo_name": "clarkdm/CS410",
"max_stars_repo_path": "LecDiff.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 851,
"size": 2180
}
|
module Integer8 where
open import Data.Nat
open import Data.Nat.Properties
open import Data.Product
open import Relation.Binary.PropositionalEquality as PropEq
-- ---------- record ----------
record IsSemiGroup (A : Set) (_∙_ : A → A → A) : Set where
field
assoc : ∀ x y z → (x ∙ y) ∙ z ≡ x ∙ (y ∙ z)
record IsMonoid (A : Set) (_∙_ : A → A → A) (e : A) : Set where
field
isSemiGroup : IsSemiGroup A _∙_
identity : (∀ x → e ∙ x ≡ x) × (∀ x → x ∙ e ≡ x)
record IsGroup (A : Set) (_∙_ : A → A → A) (e : A) (iF : A → A) : Set where
field
isMonoid : IsMonoid A _∙_ e
inv : (∀ x → (iF x) ∙ x ≡ e) × (∀ x → x ∙ (iF x) ≡ e)
record IsAbelianGroup (A : Set) (_∙_ : A → A → A) (e : A) (iF : A → A) : Set where
field
isGroup : IsGroup A _∙_ e iF
comm : ∀ x y → x ∙ y ≡ y ∙ x
record IsRing (A : Set) (_⊕_ _⊗_ : A → A → A) (eP eT : A) (iF : A → A) : Set where
field
⊕isAbelianGroup : IsAbelianGroup A _⊕_ eP iF
⊗isMonoid : IsMonoid A _⊗_ eT
isDistR : (x y z : A) → (x ⊕ y) ⊗ z ≡ (x ⊗ z) ⊕ (y ⊗ z)
isDistL : (x y z : A) → x ⊗ (y ⊕ z) ≡ (x ⊗ y) ⊕ (x ⊗ z)
-- ----------------------------
-- ---------- practice nat ----------
ℕ+-isSemiGroup : IsSemiGroup ℕ _+_
ℕ+-isSemiGroup = record { assoc = ℕ+-assoc }
where
ℕ+-assoc : ∀ x y z → (x + y) + z ≡ x + (y + z)
ℕ+-assoc zero y z = refl
ℕ+-assoc (suc x) y z = cong suc (ℕ+-assoc x y z)
ℕ+0-isMonoid : IsMonoid ℕ _+_ 0
ℕ+0-isMonoid = record { isSemiGroup = ℕ+-isSemiGroup ; identity = (0+x≡x , x+0≡x) }
where
0+x≡x : ∀ x → 0 + x ≡ x
0+x≡x x = refl
x+0≡x : ∀ x → x + 0 ≡ x
x+0≡x zero = refl
x+0≡x (suc x) = cong suc (x+0≡x x)
-- -------------------------
-- ---------- Int ----------
data ℤ : Set where
O : ℤ
I : ℕ → ℕ → ℤ
postulate
zeroZ : (x : ℕ) → I x x ≡ O
zeroZ₂ : (x y : ℕ) → I (x + y) (y + x) ≡ O
-- plusInt
_++_ : ℤ → ℤ → ℤ
O ++ O = O
O ++ X = X
X ++ O = X
I x y ++ I z w = I (x + z) (y + w)
-- productInt
_**_ : ℤ → ℤ → ℤ
O ** O = O
O ** _ = O
_ ** O = O
I x y ** I z w = I (x * z + y * w) (x * w + y * z)
-- -------------------------
-- ---------- Int + ----------
ℤ++-isSemiGroup : IsSemiGroup ℤ _++_
ℤ++-isSemiGroup = record { assoc = ℤ++-assoc }
where
open IsSemiGroup
ℤ++-assoc : ∀ x y z → (x ++ y) ++ z ≡ x ++ (y ++ z)
ℤ++-assoc O O O = refl
ℤ++-assoc O O (I x x₁) = refl
ℤ++-assoc O (I x x₁) O = refl
ℤ++-assoc O (I x x₁) (I x₂ x₃) = refl
ℤ++-assoc (I x x₁) O O = refl
ℤ++-assoc (I x x₁) O (I x₂ x₃) = refl
ℤ++-assoc (I x x₁) (I x₂ x₃) O = refl
ℤ++-assoc (I x x₁) (I x₂ x₃) (I x₄ x₅)
= cong₂ I ((assoc ℕ+-isSemiGroup) x x₂ x₄) ((assoc ℕ+-isSemiGroup) x₁ x₃ x₅)
ℤ++O-isMonoid : IsMonoid ℤ _++_ O
ℤ++O-isMonoid = record { isSemiGroup = ℤ++-isSemiGroup ; identity = (O++x≡x , x++O≡x) }
where
O++x≡x : (x : ℤ) → (O ++ x) ≡ x
O++x≡x O = refl
O++x≡x (I x x₁) = refl
x++O≡x : (x : ℤ) → (x ++ O) ≡ x
x++O≡x O = refl
x++O≡x (I x x₁) = refl
invℤ : ℤ → ℤ
invℤ O = O
invℤ (I x x₁) = I x₁ x
ℤ++Oinvℤ-isGroup : IsGroup ℤ _++_ O invℤ
ℤ++Oinvℤ-isGroup = record { isMonoid = ℤ++O-isMonoid ; inv = (leftInv , rightInv) }
where
leftInv : (x : ℤ) → (invℤ x ++ x) ≡ O
leftInv O = refl
leftInv (I x x₁) = zeroZ₂ x₁ x
rightInv : (x : ℤ) → (x ++ invℤ x) ≡ O
rightInv O = refl
rightInv (I x x₁) = zeroZ₂ x x₁
ℤ++Oinvℤ-isAbelianGroup : IsAbelianGroup ℤ _++_ O invℤ
ℤ++Oinvℤ-isAbelianGroup = record { isGroup = ℤ++Oinvℤ-isGroup ; comm = ℤ++Oinvℤ-Comm }
where
ℤ++Oinvℤ-Comm : (x y : ℤ) → (x ++ y) ≡ (y ++ x)
ℤ++Oinvℤ-Comm O O = refl
ℤ++Oinvℤ-Comm O (I x x₁) = refl
ℤ++Oinvℤ-Comm (I x x₁) O = refl
ℤ++Oinvℤ-Comm (I x x₁) (I x₂ x₃) = cong₂ I (+-comm x x₂) (+-comm x₁ x₃)
-- ---------------------------
-- ---------- Int * ----------
ℤ**-isSemiGroup : IsSemiGroup ℤ _**_
ℤ**-isSemiGroup = record { assoc = ℤ**-assoc }
where
ℤ**-assoc : ∀ x y z → (x ** y) ** z ≡ x ** (y ** z)
ℤ**-assoc O O O = refl
ℤ**-assoc O O (I x x₁) = refl
ℤ**-assoc O (I x x₁) O = refl
ℤ**-assoc O (I x x₁) (I x₂ x₃) = refl
ℤ**-assoc (I x x₁) O O = refl
ℤ**-assoc (I x x₁) O (I x₂ x₃) = refl
ℤ**-assoc (I x x₁) (I x₂ x₃) O = refl
ℤ**-assoc (I x x₁) (I x₂ x₃) (I x₄ x₅)
= cong₂ I (ℤ**-assoc₁ x x₁ x₂ x₃ x₄ x₅) (ℤ**-assoc₁ x x₁ x₂ x₃ x₅ x₄)
where
open PropEq.≡-Reasoning
open IsSemiGroup
ℤ**-assoc₁ : ∀ x y z u v w →
(x * z + y * u) * v + (x * u + y * z) * w ≡ x * (z * v + u * w) + y * (z * w + u * v)
ℤ**-assoc₁ x y z u v w = begin
(x * z + y * u) * v + (x * u + y * z) * w
≡⟨ cong (\ t → (t + (x * u + y * z) * w)) (*-distribʳ-+ v (x * z) (y * u)) ⟩
x * z * v + y * u * v + (x * u + y * z) * w
≡⟨ cong (\ t → (x * z * v + y * u * v + t)) (*-distribʳ-+ w (x * u) (y * z)) ⟩
x * z * v + y * u * v + (x * u * w + y * z * w)
≡⟨ +-assoc (x * z * v) (y * u * v) (x * u * w + y * z * w) ⟩
x * z * v + (y * u * v + (x * u * w + y * z * w))
≡⟨ cong (\ t → ((x * z * v) + t)) (+-comm (y * u * v) (x * u * w + y * z * w)) ⟩
x * z * v + ((x * u * w + y * z * w) + y * u * v)
≡⟨ sym (+-assoc (x * z * v) (x * u * w + y * z * w) (y * u * v)) ⟩
x * z * v + (x * u * w + y * z * w) + y * u * v
≡⟨ sym (cong (\ t → (t + y * u * v)) ((assoc ℕ+-isSemiGroup) (x * z * v) (x * u * w) (y * z * w))) ⟩
x * z * v + x * u * w + y * z * w + y * u * v
≡⟨ cong (\ t → t + x * u * w + y * z * w + y * u * v) (*-assoc x z v) ⟩
x * (z * v) + x * u * w + y * z * w + y * u * v
≡⟨ cong (\ t → x * (z * v) + t + y * z * w + y * u * v) (*-assoc x u w) ⟩
x * (z * v) + x * (u * w) + y * z * w + y * u * v
≡⟨ cong (\ t → x * (z * v) + x * (u * w) + t + y * u * v) (*-assoc y z w) ⟩
x * (z * v) + x * (u * w) + y * (z * w) + y * u * v
≡⟨ cong (\ t → x * (z * v) + x * (u * w) + y * (z * w) + t) (*-assoc y u v) ⟩
x * (z * v) + x * (u * w) + y * (z * w) + y * (u * v)
≡⟨ sym (cong (\ t → (t + y * (z * w) + y * (u * v))) (*-distribˡ-+ x (z * v) (u * w))) ⟩
x * (z * v + u * w) + y * (z * w) + y * (u * v)
≡⟨ +-assoc (x * (z * v + u * w)) (y * (z * w)) (y * (u * v)) ⟩
x * (z * v + u * w) + (y * (z * w) + y * (u * v))
≡⟨ sym (cong (\ t → (x * (z * v + u * w) + t)) (*-distribˡ-+ y (z * w) (u * v))) ⟩
x * (z * v + u * w) + y * (z * w + u * v)
∎
ℤ**1-isMonoid : IsMonoid ℤ _**_ (I 1 0)
ℤ**1-isMonoid = record { isSemiGroup = ℤ**-isSemiGroup ; identity = (1**x≡x , x**1≡x) }
where
1**x≡x : (x : ℤ) → (I 1 0 ** x) ≡ x
1**x≡x O = refl
1**x≡x (I x x₁) = cong₂ I (x+z+z≡x x) (x+z+z≡x x₁)
where
x+z+z≡x : (x : ℕ) → x + 0 + 0 ≡ x
x+z+z≡x zero = refl
x+z+z≡x (suc x) = cong suc (x+z+z≡x x)
x**1≡x : (x : ℤ) → (x ** I 1 0) ≡ x
x**1≡x O = refl
x**1≡x (I x x₁) = cong₂ I (x*1+x*0≡x x x₁) (x*0+x*1=x x x₁)
where
x*1+x*0≡x : (x x₁ : ℕ) → x * 1 + x₁ * 0 ≡ x
x*1+x*0≡x zero zero = refl
x*1+x*0≡x zero (suc x₁) = x*1+x*0≡x zero x₁
x*1+x*0≡x (suc x) zero = cong suc (x*1+x*0≡x x zero)
x*1+x*0≡x (suc x) (suc x₁) = x*1+x*0≡x (suc x) x₁
x*0+x*1=x : (x x₁ : ℕ) → x * 0 + x₁ * 1 ≡ x₁
x*0+x*1=x zero zero = refl
x*0+x*1=x zero (suc x₁) = cong suc (x*0+x*1=x zero x₁)
x*0+x*1=x (suc x) zero = x*0+x*1=x x zero
x*0+x*1=x (suc x) (suc x₁) = x*0+x*1=x x (suc x₁)
-- ---------------------------
-- ---------- Int + * ----------
ℤ++0invℤ-**1-isRing : IsRing ℤ _++_ _**_ O (I 1 0) invℤ
ℤ++0invℤ-**1-isRing =
record
{ ⊕isAbelianGroup = ℤ++Oinvℤ-isAbelianGroup
; ⊗isMonoid = ℤ**1-isMonoid
; isDistR = ℤdistR
; isDistL = ℤdistL }
where
ℤdistR : (x y z : ℤ) → (x ++ y) ** z ≡ (x ** z) ++ (y ** z)
ℤdistR O O O = refl
ℤdistR O O (I x x₁) = refl
ℤdistR O (I x x₁) O = refl
ℤdistR O (I x x₁) (I x₂ x₃) = refl
ℤdistR (I x x₁) O O = refl
ℤdistR (I x x₁) O (I x₂ x₃) = refl
ℤdistR (I x x₁) (I x₂ x₃) O = refl
ℤdistR (I x x₁) (I x₂ x₃) (I x₄ x₅) = cong₂ I (ℤdistR₁ x x₂ x₄ x₁ x₃ x₅) (ℤdistR₁ x x₂ x₅ x₁ x₃ x₄)
where
open PropEq.≡-Reasoning
open IsSemiGroup
ℤdistR₁ : (x y z u v w : ℕ) →
(x + y) * z + (u + v) * w ≡ x * z + u * w + (y * z + v * w)
ℤdistR₁ x y z u v w = begin
(x + y) * z + (u + v) * w
≡⟨ cong (\ t → t + (u + v) * w) (*-distribʳ-+ z x y) ⟩
x * z + y * z + (u + v) * w
≡⟨ cong (\ t → (x * z + y * z + t)) (*-distribʳ-+ w u v) ⟩
x * z + y * z + (u * w + v * w)
≡⟨ +-assoc (x * z) (y * z) (u * w + v * w) ⟩
x * z + (y * z + (u * w + v * w))
≡⟨ cong (\ t → x * z + t) (+-comm (y * z) (u * w + v * w)) ⟩
x * z + ((u * w + v * w) + y * z)
≡⟨ cong (\ t → x * z + t) ((assoc ℕ+-isSemiGroup) (u * w) (v * w) (y * z)) ⟩
x * z + (u * w + (v * w + y * z))
≡⟨ cong (\ t → x * z + (u * w + t)) (+-comm (v * w) (y * z)) ⟩
x * z + (u * w + (y * z + v * w))
≡⟨ sym ((assoc ℕ+-isSemiGroup) (x * z) (u * w) (y * z + v * w)) ⟩
x * z + u * w + (y * z + v * w)
∎
ℤdistL : (x y z : ℤ) → x ** (y ++ z) ≡ (x ** y) ++ (x ** z)
ℤdistL O O O = refl
ℤdistL O O (I x x₁) = refl
ℤdistL O (I x x₁) O = refl
ℤdistL O (I x x₁) (I x₂ x₃) = refl
ℤdistL (I x x₁) O O = refl
ℤdistL (I x x₁) O (I x₂ x₃) = refl
ℤdistL (I x x₁) (I x₂ x₃) O = refl
ℤdistL (I x x₁) (I x₂ x₃) (I x₄ x₅) = cong₂ I (ℤdistL₁ x x₁ x₂ x₃ x₄ x₅) (ℤdistL₁ x x₁ x₃ x₂ x₅ x₄)
where
open PropEq.≡-Reasoning
open IsSemiGroup
ℤdistL₁ : (x y z u v w : ℕ) →
x * (z + v) + y * (u + w) ≡ x * z + y * u + (x * v + y * w)
ℤdistL₁ x y z u v w = begin
x * (z + v) + y * (u + w)
≡⟨ cong (\ t → t + y * (u + w)) (*-distribˡ-+ x z v) ⟩
x * z + x * v + y * (u + w)
≡⟨ cong (\ t → x * z + x * v + t) (*-distribˡ-+ y u w) ⟩
x * z + x * v + (y * u + y * w)
≡⟨ +-assoc (x * z) (x * v) (y * u + y * w) ⟩
x * z + (x * v + (y * u + y * w))
≡⟨ sym (cong (\ t → x * z + t) ((assoc ℕ+-isSemiGroup) (x * v) (y * u) (y * w))) ⟩
x * z + ((x * v + y * u) + y * w)
≡⟨ cong (\ t → x * z + (t + y * w)) (+-comm (x * v) (y * u)) ⟩
x * z + ((y * u + x * v) + y * w)
≡⟨ cong (\ t → x * z + t) ((assoc ℕ+-isSemiGroup) (y * u) (x * v) (y * w)) ⟩
x * z + (y * u + (x * v + y * w))
≡⟨ sym ((assoc ℕ+-isSemiGroup) (x * z) (y * u) (x * v + y * w)) ⟩
x * z + y * u + (x * v + y * w)
∎
-- ---------------------------
-- (-1) * (-1) = 1
minus : I 0 1 ** I 0 1 ≡ I 1 0
minus = refl
|
{
"alphanum_fraction": 0.3741838715,
"avg_line_length": 40.623655914,
"ext": "agda",
"hexsha": "59f43c2cfe62b9ea4d3adeaf9a8fb21a3011b4ea",
"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": "9117b6bec9880d8c0a5d6ee4399fd841c3544d84",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "righ1113/Agda",
"max_forks_repo_path": "Integer8.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9117b6bec9880d8c0a5d6ee4399fd841c3544d84",
"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": "righ1113/Agda",
"max_issues_repo_path": "Integer8.agda",
"max_line_length": 111,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "9117b6bec9880d8c0a5d6ee4399fd841c3544d84",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "righ1113/Agda",
"max_stars_repo_path": "Integer8.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 5335,
"size": 11334
}
|
{-# OPTIONS --rewriting #-}
open import Agda.Builtin.Equality
open import Agda.Builtin.Bool
open import Agda.Builtin.Nat
{-# BUILTIN REWRITE _≡_ #-}
not : Bool → Bool
not true = false
not false = true
data Unit : Set where
unit : Unit
postulate
X : Unit → Set
X-Nat : X unit ≡ Nat
X-Bool : (u : Unit) → X u ≡ Bool
{-# REWRITE X-Nat #-}
0' : (u : Unit) → X u
0' unit = 0
{-# REWRITE X-Bool #-}
test : (u : Unit) → not (0' u) ≡ true
test unit = refl
|
{
"alphanum_fraction": 0.6056034483,
"avg_line_length": 16,
"ext": "agda",
"hexsha": "b0c2ff4d0af1d87087f4f75a941bac93b2f7e0da",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "cagix/agda",
"max_forks_repo_path": "test/Fail/Issue5396.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "cagix/agda",
"max_issues_repo_path": "test/Fail/Issue5396.agda",
"max_line_length": 37,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "cagix/agda",
"max_stars_repo_path": "test/Fail/Issue5396.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": 163,
"size": 464
}
|
open import Data.String using ( _++_ )
open import System.IO using ( _>>_ ; _>>=_ ; getStr ; putStr ; commit )
module System.IO.Examples.HelloUser where
main =
putStr "What is your name?\n" >>
commit >>
getStr >>= λ name →
putStr ("Hello, " ++ name ++ "\n") >>
commit
|
{
"alphanum_fraction": 0.6077738516,
"avg_line_length": 23.5833333333,
"ext": "agda",
"hexsha": "5b0ffd1153e7e391d039896f02a4361941233cc4",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:23.000Z",
"max_forks_repo_forks_event_min_datetime": "2017-08-10T06:12:54.000Z",
"max_forks_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "ilya-fiveisky/agda-system-io",
"max_forks_repo_path": "src/System/IO/Examples/HelloUser.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "ilya-fiveisky/agda-system-io",
"max_issues_repo_path": "src/System/IO/Examples/HelloUser.agda",
"max_line_length": 71,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "ilya-fiveisky/agda-system-io",
"max_stars_repo_path": "src/System/IO/Examples/HelloUser.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-15T04:35:41.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-04T13:45:16.000Z",
"num_tokens": 88,
"size": 283
}
|
{-
Agda Implementors' Meeting VI
Göteborg
May 24 - 30, 2007
Hello Agda!
Ulf Norell
-}
-- This is where the fun begins.
-- Unleashing datatypes, pattern matching and recursion.
module Datatypes where
{-
Simple datatypes.
-}
-- Now which datatype should we start with...?
data Nat : Set where
zero : Nat
suc : Nat -> Nat
-- Let's start simple.
pred : Nat -> Nat
pred zero = zero
pred (suc n) = n
-- Now let's do recursion.
_+_ : Nat -> Nat -> Nat
zero + m = m
suc n + m = suc (n + m)
-- An aside on infix operators:
-- Any name containing _ can be used as a mixfix operator.
-- The arguments simply go in place of the _. For instance:
data Bool : Set where
true : Bool
false : Bool
if_then_else_ : {A : Set} -> Bool -> A -> A -> A
if true then x else y = x
if false then x else y = y
-- To declare the associativity and precedence of an operator
-- we write. In this case we need parenthesis around the else branch
-- if its precedence is lower than 10. For the condition and the then
-- branch we only need parenthesis for things like λs.
infix 10 if_then_else_
{-
Parameterised datatypes
-}
data List (A : Set) : Set where
[] : List A
_::_ : A -> List A -> List A
infixr 50 _::_
-- The parameters are implicit arguments to the constructors.
nil : (A : Set) -> List A
nil A = [] {A}
map : {A B : Set} -> (A -> B) -> List A -> List B
map f [] = []
map f (x :: xs) = f x :: map f xs
{-
Empty datatypes
-}
-- A very useful guy is the empty datatype.
data False : Set where
-- When pattern matching on an element of an empty type, something
-- interesting happens:
elim-False : {A : Set} -> False -> A
elim-False () -- Look Ma, no right hand side!
-- The pattern () is called an absurd pattern and matches elements
-- of an empty type.
{-
What's next?
-}
-- Fun as they are, eventually you'll get bored with
-- inductive datatypes.
-- Move on to: Families.agda
|
{
"alphanum_fraction": 0.6243756244,
"avg_line_length": 18.537037037,
"ext": "agda",
"hexsha": "4dba1b778b155dca3d1ffb370adc9d4780dc60c2",
"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/AIM6/HelloAgda/Datatypes.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/AIM6/HelloAgda/Datatypes.agda",
"max_line_length": 69,
"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/AIM6/HelloAgda/Datatypes.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": 564,
"size": 2002
}
|
{-# OPTIONS --safe --warning=error #-}
open import Numbers.Naturals.Semiring
open import Groups.FreeProduct.Definition
open import Groups.FreeProduct.Setoid
open import Groups.FreeProduct.Group
open import Groups.Definition
open import Groups.Homomorphisms.Definition
open import Groups.Isomorphisms.Definition
open import LogicalFormulae
open import Numbers.Integers.Addition
open import Numbers.Integers.Definition
open import Groups.FreeGroup.Definition
open import Groups.FreeGroup.Word
open import Groups.FreeGroup.Group
open import Groups.FreeGroup.UniversalProperty
open import Setoids.Setoids
module Groups.FreeProduct.Lemmas {i : _} {I : Set i} (decidableIndex : (x y : I) → ((x ≡ y) || ((x ≡ y) → False))) where
private
f : ReducedWord decidableIndex → ReducedSequence decidableIndex (λ _ → ℤDecideEquality) (λ _ → ℤGroup)
f = universalPropertyFunction decidableIndex (FreeProductGroup decidableIndex (λ _ → ℤDecideEquality) (λ _ → ℤGroup)) λ i → nonempty i (ofEmpty i (nonneg 1) λ ())
freeProductIso : GroupHom (freeGroup decidableIndex) (FreeProductGroup decidableIndex (λ _ → ℤDecideEquality) (λ _ → ℤGroup)) f
freeProductIso = universalPropertyHom decidableIndex (FreeProductGroup decidableIndex (λ _ → ℤDecideEquality) (λ _ → ℤGroup)) (λ i → nonempty i (ofEmpty i (nonneg 1) λ ()))
freeProductInj : (x y : ReducedWord decidableIndex) → (decidableIndex =RP λ _ → ℤDecideEquality) (λ _ → ℤGroup) (f x) (f y) → x ≡ y
freeProductInj empty empty pr = refl
freeProductInj empty (prependLetter (ofLetter x₁) y x) pr = exFalso {!!}
freeProductInj empty (prependLetter (ofInv x₁) y x) pr = {!!}
freeProductInj (prependLetter letter x x₁) y pr = {!!}
freeProductZ : GroupsIsomorphic (freeGroup decidableIndex) (FreeProductGroup decidableIndex (λ _ → ℤDecideEquality) (λ _ → ℤGroup))
GroupsIsomorphic.isomorphism (freeProductZ) = universalPropertyFunction decidableIndex (FreeProductGroup decidableIndex (λ _ → ℤDecideEquality) (λ _ → ℤGroup)) λ i → nonempty i (ofEmpty i (nonneg 1) λ ())
GroupIso.groupHom (GroupsIsomorphic.proof (freeProductZ)) = freeProductIso
SetoidInjection.wellDefined (SetoidBijection.inj (GroupIso.bij (GroupsIsomorphic.proof (freeProductZ)))) = GroupHom.wellDefined (freeProductIso)
SetoidInjection.injective (SetoidBijection.inj (GroupIso.bij (GroupsIsomorphic.proof (freeProductZ)))) {x} {y} = freeProductInj x y
SetoidSurjection.wellDefined (SetoidBijection.surj (GroupIso.bij (GroupsIsomorphic.proof (freeProductZ)))) = GroupHom.wellDefined freeProductIso
SetoidSurjection.surjective (SetoidBijection.surj (GroupIso.bij (GroupsIsomorphic.proof (freeProductZ)))) {empty} = empty , record {}
SetoidSurjection.surjective (SetoidBijection.surj (GroupIso.bij (GroupsIsomorphic.proof (freeProductZ)))) {nonempty i (ofEmpty .i (nonneg zero) nonZero)} = exFalso (nonZero refl)
SetoidSurjection.surjective (SetoidBijection.surj (GroupIso.bij (GroupsIsomorphic.proof (freeProductZ)))) {nonempty i (ofEmpty .i (nonneg (succ x)) nonZero)} = prependLetter (ofLetter i) empty (wordEmpty refl) , {!!}
SetoidSurjection.surjective (SetoidBijection.surj (GroupIso.bij (GroupsIsomorphic.proof (freeProductZ)))) {nonempty i (ofEmpty .i (negSucc x) nonZero)} = {!!}
SetoidSurjection.surjective (SetoidBijection.surj (GroupIso.bij (GroupsIsomorphic.proof (freeProductZ)))) {nonempty i (prependLetter .i g nonZero x x₁)} = {!!}
freeProductNonAbelian : {!!}
freeProductNonAbelian = {!!}
|
{
"alphanum_fraction": 0.7735242548,
"avg_line_length": 71.2916666667,
"ext": "agda",
"hexsha": "0dcee7e1078dab604e2fedec478478e758d5de8c",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Smaug123/agdaproofs",
"max_forks_repo_path": "Groups/FreeProduct/Lemmas.agda",
"max_issues_count": 14,
"max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Smaug123/agdaproofs",
"max_issues_repo_path": "Groups/FreeProduct/Lemmas.agda",
"max_line_length": 216,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Smaug123/agdaproofs",
"max_stars_repo_path": "Groups/FreeProduct/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": 1023,
"size": 3422
}
|
module Issue121 where
bad : Set → Set
bad A = A → A
data Bool : Set where
true : Bool
false : Bool
F : Bool → Set → Set
F true = bad
F false = λ A → A
data D : Set where
nop : (b : Bool) → F b D → D
|
{
"alphanum_fraction": 0.5633802817,
"avg_line_length": 11.8333333333,
"ext": "agda",
"hexsha": "01f85e6caf80381118cf7cbd09989fce1c43feb9",
"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/Issue121.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/Issue121.agda",
"max_line_length": 30,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Fail/Issue121.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": 79,
"size": 213
}
|
open import Relation.Binary.Core
module PLRTree.Insert.Permutation {A : Set}
(_≤_ : A → A → Set)
(tot≤ : Total _≤_) where
open import Data.List
open import Data.Product renaming (_×_ to _∧_)
open import Data.Sum
open import List.Permutation.Base A
open import List.Permutation.Base.Concatenation A
open import List.Permutation.Base.Equivalence A
open import PLRTree {A}
open import PLRTree.Complete {A}
open import PLRTree.Compound {A}
open import PLRTree.Insert _≤_ tot≤
open import PLRTree.Insert.Properties _≤_ tot≤
mutual
lemma-insert-/ : {t : PLRTree}(x : A) → Complete t → ∃ (λ xs → flatten (insert x t) / x ⟶ xs ∧ xs ∼ flatten t)
lemma-insert-/ x leaf = [] , /head , ∼[]
lemma-insert-/ x (perfect {l} {r} y cl _ l≃r)
with tot≤ x y | l | r | l≃r
... | inj₁ x≤y | leaf | leaf | _ = y ∷ [] , /head , refl∼
... | inj₁ x≤y | leaf | node _ _ _ _ | ()
... | inj₁ x≤y | node perfect _ _ _ | leaf | ()
... | inj₁ x≤y | node perfect y' l' r' | node perfect y'' l'' r'' | _ =
let _l = node perfect y' l' r' ;
_r = node perfect y'' l'' r'' ;
flᵢfr∼yflfr = lemma++∼r (lemma-insert-∼ y cl)
in flatten (insert y _l) ++ flatten _r , /head , flᵢfr∼yflfr
... | inj₁ x≤y | node perfect _ _ _ | node left _ _ _ | ()
... | inj₁ x≤y | node perfect _ _ _ | node right _ _ _ | ()
... | inj₁ x≤y | node left _ _ _ | _ | ()
... | inj₁ x≤y | node right _ _ _ | _ | ()
... | inj₂ y≤x | leaf | leaf | _ = y ∷ [] , /tail /head , refl∼
... | inj₂ y≤x | leaf | node _ _ _ _ | ()
... | inj₂ y≤x | node perfect _ _ _ | leaf | ()
... | inj₂ y≤x | node perfect y' l' r' | node perfect y'' l'' r'' | _
with lemma-insert-/ x cl
... | xs , flᵢ/x⟶xs , xs∼fl =
let _l = node perfect y' l' r' ;
_r = node perfect y'' l'' r'' ;
yflᵢfr/x⟶yxsfr = /tail (lemma++/r flᵢ/x⟶xs) ;
yflᵢfr∼yxsfr = ∼x /head /head (lemma++∼r xs∼fl)
in y ∷ xs ++ flatten _r , yflᵢfr/x⟶yxsfr , yflᵢfr∼yxsfr
lemma-insert-/ x (perfect y cl _ l≃r) | inj₂ y≤x | node perfect _ _ _ | node left _ _ _ | ()
lemma-insert-/ x (perfect y cl _ l≃r) | inj₂ y≤x | node perfect _ _ _ | node right _ _ _ | ()
lemma-insert-/ x (perfect y cl _ l≃r) | inj₂ y≤x | node left _ _ _ | _ | ()
lemma-insert-/ x (perfect y cl _ l≃r) | inj₂ y≤x | node right _ _ _ | _ | ()
lemma-insert-/ x (left {l} {r} y cl _ _)
with tot≤ x y
... | inj₁ x≤y
with insert y l | lemma-insert-∼ y cl | lemma-insert-compound y l
... | node perfect y' l' r' | flᵢ∼yfl | compound =
let flᵢfr∼yflfr = lemma++∼r flᵢ∼yfl
in flatten (node perfect y' l' r') ++ flatten r , /head , flᵢfr∼yflfr
... | node left y' l' r' | flᵢ∼yfl | compound =
let flᵢfr∼yflfr = lemma++∼r flᵢ∼yfl
in flatten (node left y' l' r') ++ flatten r , /head , flᵢfr∼yflfr
... | node right y' l' r' | flᵢ∼yfl | compound =
let flᵢfr∼yflfr = lemma++∼r flᵢ∼yfl
in flatten (node right y' l' r') ++ flatten r , /head , flᵢfr∼yflfr
lemma-insert-/ x (left {l} {r} y cl _ _) | inj₂ y≤x
with insert x l | lemma-insert-/ x cl | lemma-insert-compound x l
... | node perfect _ _ _ | xs , flᵢ/x⟶xs , xs∼fl | compound =
let yflᵢfr/x⟶yxsfr = /tail (lemma++/r flᵢ/x⟶xs) ;
yflᵢfr∼yxsfr = ∼x /head /head (lemma++∼r xs∼fl)
in y ∷ xs ++ flatten r , yflᵢfr/x⟶yxsfr , yflᵢfr∼yxsfr
... | node left _ _ _ | xs , flᵢ/x⟶xs , xs∼fl | compound =
let yflᵢfr/x⟶yxsfr = /tail (lemma++/r flᵢ/x⟶xs) ;
yflᵢfr∼yxsfr = ∼x /head /head (lemma++∼r xs∼fl)
in y ∷ xs ++ flatten r , yflᵢfr/x⟶yxsfr , yflᵢfr∼yxsfr
... | node right _ _ _ | xs , flᵢ/x⟶xs , xs∼fl | compound =
let yflᵢfr/x⟶yxsfr = /tail (lemma++/r flᵢ/x⟶xs) ;
yflᵢfr∼yxsfr = ∼x /head /head (lemma++∼r xs∼fl)
in y ∷ xs ++ flatten r , yflᵢfr/x⟶yxsfr , yflᵢfr∼yxsfr
lemma-insert-/ x (right {l} {r} y _ cr _)
with tot≤ x y
... | inj₁ x≤y
with insert y r | lemma-insert-∼ y cr | lemma-insert-compound y r
... | node perfect y' l' r' | frᵢ∼yfr | compound =
let flfrᵢ∼flyfr = lemma++∼l {flatten l} frᵢ∼yfr ;
flyfr∼yflfr = ∼x (lemma++/ {y} {flatten l}) /head refl∼ ;
flfrᵢ∼yflfr = trans∼ flfrᵢ∼flyfr flyfr∼yflfr
in flatten l ++ flatten (node perfect y' l' r') , /head , flfrᵢ∼yflfr
... | node left y' l' r' | frᵢ∼yfr | compound =
let flfrᵢ∼flyfr = lemma++∼l {flatten l} frᵢ∼yfr ;
flyfr∼yflfr = ∼x (lemma++/ {y} {flatten l}) /head refl∼ ;
flfrᵢ∼yflfr = trans∼ flfrᵢ∼flyfr flyfr∼yflfr
in flatten l ++ flatten (node left y' l' r') , /head , flfrᵢ∼yflfr
... | node right y' l' r' | frᵢ∼yfr | compound =
let flfrᵢ∼flyfr = lemma++∼l {flatten l} frᵢ∼yfr ;
flyfr∼yflfr = ∼x (lemma++/ {y} {flatten l}) /head refl∼ ;
flfrᵢ∼yflfr = trans∼ flfrᵢ∼flyfr flyfr∼yflfr
in flatten l ++ flatten (node right y' l' r') , /head , flfrᵢ∼yflfr
lemma-insert-/ x (right {l} {r} y _ cr _) | inj₂ y≤x
with insert x r | lemma-insert-/ x cr | lemma-insert-compound x r
... | node perfect y' l' r' | xs , frᵢ/x⟶xs , xs∼fr | compound =
let yflfrᵢ/x⟶yflxs = /tail (lemma++/l {x} {flatten l} frᵢ/x⟶xs) ;
yflfrᵢ∼yflxs = ∼x /head /head (lemma++∼l {flatten l} xs∼fr)
in y ∷ flatten l ++ xs , yflfrᵢ/x⟶yflxs , yflfrᵢ∼yflxs
... | node left y' l' r' | xs , frᵢ/x⟶xs , xs∼fr | compound =
let yflfrᵢ/x⟶yflxs = /tail (lemma++/l {x} {flatten l} frᵢ/x⟶xs) ;
yflfrᵢ∼yflxs = ∼x /head /head (lemma++∼l {flatten l} xs∼fr)
in y ∷ flatten l ++ xs , yflfrᵢ/x⟶yflxs , yflfrᵢ∼yflxs
... | node right y' l' r' | xs , frᵢ/x⟶xs , xs∼fr | compound =
let yflfrᵢ/x⟶yflxs = /tail (lemma++/l {x} {flatten l} frᵢ/x⟶xs) ;
yflfrᵢ∼yflxs = ∼x /head /head (lemma++∼l {flatten l} xs∼fr)
in y ∷ flatten l ++ xs , yflfrᵢ/x⟶yflxs , yflfrᵢ∼yflxs
lemma-insert-∼ : {t : PLRTree}(x : A) → Complete t → flatten (insert x t) ∼ (x ∷ flatten t)
lemma-insert-∼ x leaf = ∼x /head /head ∼[]
lemma-insert-∼ x (perfect {l} {r} y cl _ l≃r)
with tot≤ x y | l | r | l≃r
... | inj₁ x≤y | leaf | leaf | _ = ∼x /head /head (∼x /head /head ∼[])
... | inj₁ x≤y | leaf | node _ _ _ _ | ()
... | inj₁ x≤y | node perfect _ _ _ | leaf | ()
... | inj₁ x≤y | node perfect _ _ _ | node perfect _ _ _ | _ =
let flᵢfr∼yflfr = lemma++∼r (lemma-insert-∼ y cl)
in ∼x /head /head flᵢfr∼yflfr
... | inj₁ x≤y | node perfect _ _ _ | node left _ _ _ | ()
... | inj₁ x≤y | node perfect _ _ _ | node right _ _ _ | ()
... | inj₁ x≤y | node left _ _ _ | _ | ()
... | inj₁ x≤y | node right _ _ _ | _ | ()
... | inj₂ y≤x | leaf | leaf | _ = ∼x /head (/tail /head) (∼x /head /head ∼[])
... | inj₂ y≤x | leaf | node _ _ _ _ | ()
... | inj₂ y≤x | node perfect _ _ _ | leaf | ()
... | inj₂ y≤x | node perfect _ _ _ | node perfect _ _ _ | _
with lemma-insert-/ x cl
... | xs , flᵢ/x⟶xs , xs∼fl =
let yflᵢfr/x⟶yxsfr = /tail (lemma++/r flᵢ/x⟶xs) ;
yxsfr∼yflfr = ∼x /head /head (lemma++∼r xs∼fl)
in ∼x yflᵢfr/x⟶yxsfr /head yxsfr∼yflfr
lemma-insert-∼ x (perfect y cl _ l≃r) | inj₂ y≤x | node perfect _ _ _ | node left _ _ _ | ()
lemma-insert-∼ x (perfect y cl _ l≃r) | inj₂ y≤x | node perfect _ _ _ | node right _ _ _ | ()
lemma-insert-∼ x (perfect y cl _ l≃r) | inj₂ y≤x | node left _ _ _ | _ | ()
lemma-insert-∼ x (perfect y cl _ l≃r) | inj₂ y≤x | node right _ _ _ | _ | ()
lemma-insert-∼ x (left {l} {r} y cl _ _)
with tot≤ x y
... | inj₁ x≤y
with insert y l | lemma-insert-∼ y cl | lemma-insert-compound y l
... | node perfect _ _ _ | flᵢ∼yfl | compound =
let flᵢfr∼yflfr = lemma++∼r flᵢ∼yfl
in ∼x /head /head flᵢfr∼yflfr
... | node left _ _ _ | flᵢ∼yfl | compound =
let flᵢfr∼yflfr = lemma++∼r flᵢ∼yfl
in ∼x /head /head flᵢfr∼yflfr
... | node right _ _ _ | flᵢ∼yfl | compound =
let flᵢfr∼yflfr = lemma++∼r flᵢ∼yfl
in ∼x /head /head flᵢfr∼yflfr
lemma-insert-∼ x (left {l} {r} y cl _ _) | inj₂ y≤x
with insert x l | lemma-insert-/ x cl | lemma-insert-compound x l
... | node perfect _ _ _ | xs , flᵢ/x⟶xs , xs∼fl | compound =
let yflᵢfr/x⟶yxsfr = /tail (lemma++/r flᵢ/x⟶xs) ;
yxsfr∼yflfr = ∼x /head /head (lemma++∼r xs∼fl)
in ∼x yflᵢfr/x⟶yxsfr /head yxsfr∼yflfr
... | node left _ _ _ | xs , flᵢ/x⟶xs , xs∼fl | compound =
let yflᵢfr/x⟶yxsfr = /tail (lemma++/r flᵢ/x⟶xs) ;
yxsfr∼yflfr = ∼x /head /head (lemma++∼r xs∼fl)
in ∼x yflᵢfr/x⟶yxsfr /head yxsfr∼yflfr
... | node right _ _ _ | xs , flᵢ/x⟶xs , xs∼fl | compound =
let yflᵢfr/x⟶yxsfr = /tail (lemma++/r flᵢ/x⟶xs) ;
yxsfr∼yflfr = ∼x /head /head (lemma++∼r xs∼fl)
in ∼x yflᵢfr/x⟶yxsfr /head yxsfr∼yflfr
lemma-insert-∼ x (right {l} {r} y _ cr _)
with tot≤ x y
... | inj₁ x≤y
with insert y r | lemma-insert-∼ y cr | lemma-insert-compound y r
... | node perfect _ _ _ | frᵢ∼yfr | compound =
let flyfr∼yflfr = ∼x (lemma++/ {y} {flatten l}) /head refl∼ ;
flfrᵢ∼flyfr = lemma++∼l {flatten l} frᵢ∼yfr ;
flfrᵢ∼yflfr = trans∼ flfrᵢ∼flyfr flyfr∼yflfr
in ∼x /head /head flfrᵢ∼yflfr
... | node left _ _ _ | frᵢ∼yfr | compound =
let flyfr∼yflfr = ∼x (lemma++/ {y} {flatten l}) /head refl∼ ;
flfrᵢ∼flyfr = lemma++∼l {flatten l} frᵢ∼yfr ;
flfrᵢ∼yflfr = trans∼ flfrᵢ∼flyfr flyfr∼yflfr
in ∼x /head /head flfrᵢ∼yflfr
... | node right _ _ _ | frᵢ∼yfr | compound =
let flyfr∼yflfr = ∼x (lemma++/ {y} {flatten l}) /head refl∼ ;
flfrᵢ∼flyfr = lemma++∼l {flatten l} frᵢ∼yfr ;
flfrᵢ∼yflfr = trans∼ flfrᵢ∼flyfr flyfr∼yflfr
in ∼x /head /head flfrᵢ∼yflfr
lemma-insert-∼ x (right {l} {r} y _ cr _) | inj₂ y≤x
with insert x r | lemma-insert-/ x cr | lemma-insert-compound x r
... | node perfect y' l' r' | xs , frᵢ/x⟶xs , xs∼fr | compound =
let yflfrᵢ/x⟶yflxs = /tail (lemma++/l {x} {flatten l} frᵢ/x⟶xs) ;
yflxs∼yflfr = ∼x /head /head (lemma++∼l {flatten l} xs∼fr)
in ∼x yflfrᵢ/x⟶yflxs /head yflxs∼yflfr
... | node left y' l' r' | xs , frᵢ/x⟶xs , xs∼fr | compound =
let yflfrᵢ/x⟶yflxs = /tail (lemma++/l {x} {flatten l} frᵢ/x⟶xs) ;
yflxs∼yflfr = ∼x /head /head (lemma++∼l {flatten l} xs∼fr)
in ∼x yflfrᵢ/x⟶yflxs /head yflxs∼yflfr
... | node right y' l' r' | xs , frᵢ/x⟶xs , xs∼fr | compound =
let yflfrᵢ/x⟶yflxs = /tail (lemma++/l {x} {flatten l} frᵢ/x⟶xs) ;
yflxs∼yflfr = ∼x /head /head (lemma++∼l {flatten l} xs∼fr)
in ∼x yflfrᵢ/x⟶yflxs /head yflxs∼yflfr
|
{
"alphanum_fraction": 0.4977379428,
"avg_line_length": 58.575,
"ext": "agda",
"hexsha": "1abd86ae5996eb556e0475a845fb4967a92b7605",
"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/PLRTree/Insert/Permutation.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/PLRTree/Insert/Permutation.agda",
"max_line_length": 112,
"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/PLRTree/Insert/Permutation.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": 4841,
"size": 11715
}
|
-- Andreas, 2020-09-09, issue #4880
-- Parse all interleavings of hiding and irrelevance in non-dependent function space
module Issue4880 (A B : Set) where
postulate
-- dependent
-- * visible
_ : A → (_ : B) → A
_ : A → .(_ : B) → A
_ : A → ..(_ : B) → A
-- * hidden
_ : A → {_ : B} → A
_ : A → .{_ : B} → A
_ : A → ..{_ : B} → A
-- * instance
_ : A → ⦃ _ : B ⦄ → A
_ : A → .⦃ _ : B ⦄ → A
_ : A → ..⦃ _ : B ⦄ → A
-- non-dependent
-- * visible
_ : A → B → A
_ : A → .B → A
_ : A → ..B → A
-- * visible, parenthesized
_ : A → .(B) → A
_ : A → ..(B) → A
_ : A → (.B) → A
_ : A → (..B) → A
-- * hidden
_ : A → {B} → A
_ : A → .{B} → A
_ : A → ..{B} → A
_ : A → {.B} → A
_ : A → {..B} → A
-- * instance
_ : A → ⦃ B ⦄ → A
_ : A → .⦃ B ⦄ → A
_ : A → ..⦃ B ⦄ → A
_ : A → ⦃ .B ⦄ → A
_ : A → ⦃ ..B ⦄ → A
|
{
"alphanum_fraction": 0.3644544432,
"avg_line_length": 20.6744186047,
"ext": "agda",
"hexsha": "1b202986808d0d0b17245dc46b6961338573e3de",
"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/Issue4880.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/Issue4880.agda",
"max_line_length": 84,
"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/Issue4880.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": 452,
"size": 889
}
|
module OverloadedConstructors where
data Nat : Set where
zero : Nat
suc : Nat -> Nat
data Fin : Nat -> Set where
zero : {n : Nat} -> Fin (suc n)
suc : {n : Nat} -> Fin n -> Fin (suc n)
three : Nat
three = suc (suc (suc zero))
ftwo : Fin three
ftwo = suc (suc zero)
inc : Nat -> Nat
inc = suc
{-
{-# BUILTIN NATURAL Nat #-}
{-# BUILTIN ZERO zero #-}
{-# BUILTIN SUC suc #-}
-}
|
{
"alphanum_fraction": 0.5790816327,
"avg_line_length": 15.0769230769,
"ext": "agda",
"hexsha": "cdb132893a5715b43acd1d854ac6df5c91bae5b3",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "np/agda-git-experiment",
"max_forks_repo_path": "test/succeed/OverloadedConstructors.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "np/agda-git-experiment",
"max_issues_repo_path": "test/succeed/OverloadedConstructors.agda",
"max_line_length": 42,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "test/succeed/OverloadedConstructors.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": 132,
"size": 392
}
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.HITs.Truncation.Properties where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.Equiv.HalfAdjoint
open import Cubical.Foundations.Equiv.PathSplit
open isPathSplitEquiv
open import Cubical.Modalities.Modality
open Modality
open import Cubical.Data.Empty as ⊥ using (⊥)
open import Cubical.Data.Nat hiding (elim)
open import Cubical.Data.NatMinusOne as ℕ₋₁
open import Cubical.Data.Sigma
open import Cubical.HITs.Sn
open import Cubical.HITs.Susp
open import Cubical.HITs.Nullification as Null hiding (rec; elim)
open import Cubical.HITs.Truncation.Base
open import Cubical.HITs.PropositionalTruncation as PropTrunc
renaming (∥_∥ to ∥_∥₁; ∣_∣ to ∣_∣₁; squash to squash₁) using ()
open import Cubical.HITs.SetTruncation as SetTrunc using (∥_∥₂; ∣_∣₂; squash₂)
open import Cubical.HITs.GroupoidTruncation as GpdTrunc using (∥_∥₃; ∣_∣₃; squash₃)
open import Cubical.HITs.2GroupoidTruncation as 2GpdTrunc using (∥_∥₄; ∣_∣₄; squash₄)
private
variable
ℓ ℓ' : Level
A B : Type ℓ
sphereFill : (n : ℕ₋₁) (f : S n → A) → Type _
sphereFill {A = A} n f = Σ[ top ∈ A ] ((x : S n) → top ≡ f x)
isSphereFilled : ℕ₋₁ → Type ℓ → Type ℓ
isSphereFilled n A = (f : S n → A) → sphereFill n f
isSphereFilledTrunc : {n : HLevel} → isSphereFilled (-1+ n) (hLevelTrunc n A)
isSphereFilledTrunc {n = zero} f = hub f , ⊥.elim
isSphereFilledTrunc {n = suc n} f = hub f , spoke f
isSphereFilled→isOfHLevelSuc : {n : HLevel} → isSphereFilled (ℕ→ℕ₋₁ n) A → isOfHLevel (suc n) A
isSphereFilled→isOfHLevelSuc {A = A} {zero} h x y = sym (snd (h f) north) ∙ snd (h f) south
where
f : Susp ⊥ → A
f north = x
f south = y
isSphereFilled→isOfHLevelSuc {A = A} {suc n} h x y = isSphereFilled→isOfHLevelSuc (helper h x y)
where
helper : isSphereFilled (ℕ→ℕ₋₁ (suc n)) A → (x y : A) → isSphereFilled (ℕ→ℕ₋₁ n) (x ≡ y)
helper h x y f = sym p ∙ q , r
where
f' : Susp (S (ℕ→ℕ₋₁ n)) → A
f' north = x
f' south = y
f' (merid u i) = f u i
p = snd (h f') north
q = snd (h f') south
r : (s : S (ℕ→ℕ₋₁ n)) → sym p ∙ q ≡ f s
r s i j = hcomp (λ k → λ { (i = i0) → compPath-filler (sym p) q k j
; (i = i1) → snd (h f') (merid s j) k
; (j = i0) → p (k ∨ ~ i)
; (j = i1) → q k })
(p (~ i ∧ ~ j))
isOfHLevel→isSphereFilled : {n : HLevel} → isOfHLevel n A → isSphereFilled (-1+ n) A
isOfHLevel→isSphereFilled {n = zero} h f = fst h , λ _ → snd h _
isOfHLevel→isSphereFilled {n = suc zero} h f = f north , λ _ → h _ _
isOfHLevel→isSphereFilled {A = A} {suc (suc n)} h = helper λ x y → isOfHLevel→isSphereFilled (h x y)
where
helper : {n : HLevel} → ((x y : A) → isSphereFilled (-1+ n) (x ≡ y)) → isSphereFilled (suc₋₁ (-1+ n)) A
helper {n} h f = l , r
where
l : A
l = f north
f' : S (-1+ n) → f north ≡ f south
f' x i = f (merid x i)
h' : sphereFill (-1+ n) f'
h' = h (f north) (f south) f'
r : (x : S (suc₋₁ (-1+ n))) → l ≡ f x
r north = refl
r south = h' .fst
r (merid x i) j = hcomp (λ k → λ { (i = i0) → f north
; (i = i1) → h' .snd x (~ k) j
; (j = i0) → f north
; (j = i1) → f (merid x i) })
(f (merid x (i ∧ j)))
-- isNull (S n) A ≃ (isSphereFilled n A) × (∀ (x y : A) → isSphereFilled n (x ≡ y))
isOfHLevel→isSnNull : {n : HLevel} → isOfHLevel n A → isNull (S (-1+ n)) A
fst (sec (isOfHLevel→isSnNull h)) f = fst (isOfHLevel→isSphereFilled h f)
snd (sec (isOfHLevel→isSnNull h)) f i s = snd (isOfHLevel→isSphereFilled h f) s i
fst (secCong (isOfHLevel→isSnNull h) x y) p = fst (isOfHLevel→isSphereFilled (isOfHLevelPath _ h x y) (funExt⁻ p))
snd (secCong (isOfHLevel→isSnNull h) x y) p i j s = snd (isOfHLevel→isSphereFilled (isOfHLevelPath _ h x y) (funExt⁻ p)) s i j
isSnNull→isOfHLevel : {n : HLevel} → isNull (S (-1+ n)) A → isOfHLevel n A
isSnNull→isOfHLevel {n = zero} nA = fst (sec nA) ⊥.rec , λ y → fst (secCong nA _ y) (funExt ⊥.elim)
isSnNull→isOfHLevel {n = suc n} nA = isSphereFilled→isOfHLevelSuc (λ f → fst (sec nA) f , λ s i → snd (sec nA) f i s)
isOfHLevelTrunc : (n : HLevel) → isOfHLevel n (hLevelTrunc n A)
isOfHLevelTrunc zero = hub ⊥.rec , λ _ → ≡hub ⊥.rec
isOfHLevelTrunc (suc n) = isSphereFilled→isOfHLevelSuc isSphereFilledTrunc
-- isOfHLevelTrunc n = isSnNull→isOfHLevel isNull-Null
-- hLevelTrunc n is a modality
rec : {n : HLevel}
{B : Type ℓ'} →
isOfHLevel n B →
(A → B) →
hLevelTrunc n A →
B
rec h = Null.rec (isOfHLevel→isSnNull h)
elim : {n : HLevel}
{B : hLevelTrunc n A → Type ℓ'}
(hB : (x : hLevelTrunc n A) → isOfHLevel n (B x))
(g : (a : A) → B (∣ a ∣))
(x : hLevelTrunc n A) →
B x
elim hB = Null.elim (λ x → isOfHLevel→isSnNull (hB x))
elim2 : {n : HLevel}
{B : hLevelTrunc n A → hLevelTrunc n A → Type ℓ'}
(hB : ((x y : hLevelTrunc n A) → isOfHLevel n (B x y)))
(g : (a b : A) → B ∣ a ∣ ∣ b ∣)
(x y : hLevelTrunc n A) →
B x y
elim2 {n = n} hB g =
elim (λ _ → isOfHLevelΠ n (λ _ → hB _ _))
(λ a → elim (λ _ → hB _ _) (λ b → g a b))
elim3 : {n : HLevel}
{B : (x y z : hLevelTrunc n A) → Type ℓ'}
(hB : ((x y z : hLevelTrunc n A) → isOfHLevel n (B x y z)))
(g : (a b c : A) → B (∣ a ∣) ∣ b ∣ ∣ c ∣)
(x y z : hLevelTrunc n A) →
B x y z
elim3 {n = n} hB g =
elim2 (λ _ _ → isOfHLevelΠ n (hB _ _))
(λ a b → elim (λ _ → hB _ _ _) (λ c → g a b c))
HLevelTruncModality : ∀ {ℓ} (n : HLevel) → Modality ℓ
isModal (HLevelTruncModality n) = isOfHLevel n
isModalIsProp (HLevelTruncModality n) = isPropIsOfHLevel n
◯ (HLevelTruncModality n) = hLevelTrunc n
◯-isModal (HLevelTruncModality n) = isOfHLevelTrunc n
η (HLevelTruncModality n) = ∣_∣
◯-elim (HLevelTruncModality n) = elim
◯-elim-β (HLevelTruncModality n) = λ _ _ _ → refl
◯-=-isModal (HLevelTruncModality n) = isOfHLevelPath n (isOfHLevelTrunc n)
truncIdempotentIso : (n : HLevel) → isOfHLevel n A → Iso A (hLevelTrunc n A)
truncIdempotentIso n hA = isModalToIso (HLevelTruncModality n) hA
truncIdempotent≃ : (n : HLevel) → isOfHLevel n A → A ≃ hLevelTrunc n A
truncIdempotent≃ n hA = ∣_∣ , isModalToIsEquiv (HLevelTruncModality n) hA
truncIdempotent : (n : HLevel) → isOfHLevel n A → hLevelTrunc n A ≡ A
truncIdempotent n hA = ua (invEquiv (truncIdempotent≃ n hA))
-- universal property
univTrunc : ∀ {ℓ} (n : HLevel) {B : TypeOfHLevel ℓ n} → Iso (hLevelTrunc n A → B .fst) (A → B .fst)
Iso.fun (univTrunc n {B , lev}) g a = g ∣ a ∣
Iso.inv (univTrunc n {B , lev}) = elim λ _ → lev
Iso.rightInv (univTrunc n {B , lev}) b = refl
Iso.leftInv (univTrunc n {B , lev}) b = funExt (elim (λ x → isOfHLevelPath _ lev _ _)
λ a → refl)
-- functorial action
map : {n : HLevel} {B : Type ℓ'} (g : A → B)
→ hLevelTrunc n A → hLevelTrunc n B
map g = rec (isOfHLevelTrunc _) (λ a → ∣ g a ∣)
mapCompIso : {n : HLevel} {B : Type ℓ'} → (Iso A B) → Iso (hLevelTrunc n A) (hLevelTrunc n B)
Iso.fun (mapCompIso g) = map (Iso.fun g)
Iso.inv (mapCompIso g) = map (Iso.inv g)
Iso.rightInv (mapCompIso g) = elim (λ x → isOfHLevelPath _ (isOfHLevelTrunc _) _ _) λ b → cong ∣_∣ (Iso.rightInv g b)
Iso.leftInv (mapCompIso g) = elim (λ x → isOfHLevelPath _ (isOfHLevelTrunc _) _ _) λ a → cong ∣_∣ (Iso.leftInv g a)
mapId : {n : HLevel} → ∀ t → map {n = n} (idfun A) t ≡ t
mapId {n = n} =
elim (λ _ → isOfHLevelPath n (isOfHLevelTrunc n) _ _) (λ _ → refl)
-- equivalences to prop/set/groupoid truncations
propTruncTrunc1Iso : Iso ∥ A ∥₁ (∥ A ∥ 1)
Iso.fun propTruncTrunc1Iso = PropTrunc.elim (λ _ → isOfHLevelTrunc 1) ∣_∣
Iso.inv propTruncTrunc1Iso = elim (λ _ → squash₁) ∣_∣₁
Iso.rightInv propTruncTrunc1Iso = elim (λ _ → isOfHLevelPath 1 (isOfHLevelTrunc 1) _ _) (λ _ → refl)
Iso.leftInv propTruncTrunc1Iso = PropTrunc.elim (λ _ → isOfHLevelPath 1 squash₁ _ _) (λ _ → refl)
propTrunc≃Trunc1 : ∥ A ∥₁ ≃ ∥ A ∥ 1
propTrunc≃Trunc1 = isoToEquiv propTruncTrunc1Iso
propTrunc≡Trunc1 : ∥ A ∥₁ ≡ ∥ A ∥ 1
propTrunc≡Trunc1 = ua propTrunc≃Trunc1
setTruncTrunc2Iso : Iso ∥ A ∥₂ (∥ A ∥ 2)
Iso.fun setTruncTrunc2Iso = SetTrunc.elim (λ _ → isOfHLevelTrunc 2) ∣_∣
Iso.inv setTruncTrunc2Iso = elim (λ _ → squash₂) ∣_∣₂
Iso.rightInv setTruncTrunc2Iso = elim (λ _ → isOfHLevelPath 2 (isOfHLevelTrunc 2) _ _) (λ _ → refl)
Iso.leftInv setTruncTrunc2Iso = SetTrunc.elim (λ _ → isOfHLevelPath 2 squash₂ _ _) (λ _ → refl)
setTrunc≃Trunc2 : ∥ A ∥₂ ≃ ∥ A ∥ 2
setTrunc≃Trunc2 = isoToEquiv setTruncTrunc2Iso
propTrunc≡Trunc2 : ∥ A ∥₂ ≡ ∥ A ∥ 2
propTrunc≡Trunc2 = ua setTrunc≃Trunc2
groupoidTrunc≃Trunc3Iso : Iso ∥ A ∥₃ (∥ A ∥ 3)
Iso.fun groupoidTrunc≃Trunc3Iso = GpdTrunc.elim (λ _ → isOfHLevelTrunc 3) ∣_∣
Iso.inv groupoidTrunc≃Trunc3Iso = elim (λ _ → squash₃) ∣_∣₃
Iso.rightInv groupoidTrunc≃Trunc3Iso = elim (λ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _) (λ _ → refl)
Iso.leftInv groupoidTrunc≃Trunc3Iso = GpdTrunc.elim (λ _ → isOfHLevelPath 3 squash₃ _ _) (λ _ → refl)
groupoidTrunc≃Trunc3 : ∥ A ∥₃ ≃ ∥ A ∥ 3
groupoidTrunc≃Trunc3 = isoToEquiv groupoidTrunc≃Trunc3Iso
groupoidTrunc≡Trunc3 : ∥ A ∥₃ ≡ ∥ A ∥ 3
groupoidTrunc≡Trunc3 = ua groupoidTrunc≃Trunc3
2GroupoidTrunc≃Trunc4Iso : Iso ∥ A ∥₄ (∥ A ∥ 4)
Iso.fun 2GroupoidTrunc≃Trunc4Iso = 2GpdTrunc.elim (λ _ → isOfHLevelTrunc 4) ∣_∣
Iso.inv 2GroupoidTrunc≃Trunc4Iso = elim (λ _ → squash₄) ∣_∣₄
Iso.rightInv 2GroupoidTrunc≃Trunc4Iso = elim (λ _ → isOfHLevelPath 4 (isOfHLevelTrunc 4) _ _) (λ _ → refl)
Iso.leftInv 2GroupoidTrunc≃Trunc4Iso = 2GpdTrunc.elim (λ _ → isOfHLevelPath 4 squash₄ _ _) (λ _ → refl)
2GroupoidTrunc≃Trunc4 : ∥ A ∥₄ ≃ ∥ A ∥ 4
2GroupoidTrunc≃Trunc4 =
isoToEquiv
(iso
(2GpdTrunc.elim (λ _ → isOfHLevelTrunc 4) ∣_∣)
(elim (λ _ → squash₄) ∣_∣₄)
(elim (λ _ → isOfHLevelPath 4 (isOfHLevelTrunc 4) _ _) (λ _ → refl))
(2GpdTrunc.elim (λ _ → isOfHLevelPath 4 squash₄ _ _) (λ _ → refl)))
2GroupoidTrunc≡Trunc4 : ∥ A ∥₄ ≡ ∥ A ∥ 4
2GroupoidTrunc≡Trunc4 = ua 2GroupoidTrunc≃Trunc4
isContr→isContrTrunc : ∀ {ℓ} {A : Type ℓ} (n : ℕ) → isContr A → isContr (hLevelTrunc n A)
isContr→isContrTrunc n contr = ∣ fst contr ∣ , (elim (λ _ → isOfHLevelPath n (isOfHLevelTrunc n) _ _) λ a → cong ∣_∣ (snd contr a))
truncOfProdIso : (n : ℕ) → Iso (hLevelTrunc n (A × B)) (hLevelTrunc n A × hLevelTrunc n B)
Iso.fun (truncOfProdIso n) = rec (isOfHLevelΣ n (isOfHLevelTrunc n) (λ _ → isOfHLevelTrunc n)) λ {(a , b) → ∣ a ∣ , ∣ b ∣}
Iso.inv (truncOfProdIso n) (a , b) = rec (isOfHLevelTrunc n)
(λ a → rec (isOfHLevelTrunc n)
(λ b → ∣ a , b ∣)
b)
a
Iso.rightInv (truncOfProdIso n) (a , b) =
elim {B = λ a → Iso.fun (truncOfProdIso n) (Iso.inv (truncOfProdIso n) (a , b)) ≡ (a , b)}
(λ _ → isOfHLevelPath n (isOfHLevelΣ n (isOfHLevelTrunc n) (λ _ → isOfHLevelTrunc n)) _ _)
(λ a → elim {B = λ b → Iso.fun (truncOfProdIso n) (Iso.inv (truncOfProdIso n) (∣ a ∣ , b)) ≡ (∣ a ∣ , b)}
(λ _ → isOfHLevelPath n (isOfHLevelΣ n (isOfHLevelTrunc n) (λ _ → isOfHLevelTrunc n)) _ _)
(λ b → refl) b) a
Iso.leftInv (truncOfProdIso n) = elim (λ _ → isOfHLevelPath n (isOfHLevelTrunc n) _ _) λ a → refl
---- ∥ Ω A ∥ ₙ ≡ Ω ∥ A ∥ₙ₊₁ ----
abstract
isOfHLevelTypeOfHLevel2 : ∀ n → isOfHLevel (suc n) (TypeOfHLevel ℓ n)
isOfHLevelTypeOfHLevel2 n = isOfHLevelTypeOfHLevel n
{- Proofs of Theorem 7.3.12. and Corollary 7.3.13. in the HoTT book -}
module ΩTrunc where
{- We define the fibration P to show a more general result -}
P : {X : Type ℓ} {n : HLevel} → ∥ X ∥ (suc n) → ∥ X ∥ (suc n) → Type ℓ
P {n = n} x y = elim2 (λ _ _ → isOfHLevelTypeOfHLevel2 (n))
(λ a b → ∥ a ≡ b ∥ n , isOfHLevelTrunc (n)) x y .fst
{- We will need P to be of hLevel n + 3 -}
hLevelP : {n : HLevel} (a b : ∥ B ∥ (suc n)) → isOfHLevel ((suc n)) (P a b)
hLevelP {n = n} =
elim2 (λ x y → isProp→isOfHLevelSuc (n) (isPropIsOfHLevel (suc n)))
(λ a b → isOfHLevelSuc (n) (isOfHLevelTrunc (n)))
{- decode function from P x y to x ≡ y -}
decode-fun : {n : HLevel} (x y : ∥ B ∥ (suc n)) → P x y → x ≡ y
decode-fun {n = n} =
elim2 (λ u v → isOfHLevelΠ (suc n)
(λ _ → isOfHLevelSuc (suc n) (isOfHLevelTrunc (suc n)) u v))
decode*
where
decode* : ∀ {n : HLevel} (u v : B)
→ P {n = n} ∣ u ∣ ∣ v ∣ → Path (∥ B ∥ (suc n)) ∣ u ∣ ∣ v ∣
decode* {B = B} {n = zero} u v =
rec ( isOfHLevelTrunc 1 ∣ u ∣ ∣ v ∣
, λ _ → isOfHLevelSuc 1 (isOfHLevelTrunc 1) _ _ _ _) (cong ∣_∣)
decode* {n = suc n} u v =
rec (isOfHLevelTrunc (suc (suc n)) ∣ u ∣ ∣ v ∣) (cong ∣_∣)
{- auxiliary function r used to define encode -}
r : {m : HLevel} (u : ∥ B ∥ (suc m)) → P u u
r = elim (λ x → hLevelP x x) (λ a → ∣ refl ∣)
{- encode function from x ≡ y to P x y -}
encode-fun : {n : HLevel} (x y : ∥ B ∥ (suc n)) → x ≡ y → P x y
encode-fun x y p = transport (λ i → P x (p i)) (r x)
{- We need the following two lemmas on the functions behaviour for refl -}
dec-refl : {n : HLevel} (x : ∥ B ∥ (suc n)) → decode-fun x x (r x) ≡ refl
dec-refl {n = zero} =
elim (λ x → isOfHLevelSuc 1 (isOfHLevelSuc 1 (isOfHLevelTrunc 1) x x) _ _) (λ _ → refl)
dec-refl {n = suc n} =
elim (λ x → isOfHLevelSuc (suc n)
(isOfHLevelSuc (suc n)
(isOfHLevelTrunc (suc (suc n)) x x)
(decode-fun x x (r x)) refl))
(λ _ → refl)
enc-refl : {n : HLevel} (x : ∥ B ∥ (suc n)) → encode-fun x x refl ≡ r x
enc-refl x j = transp (λ _ → P x x) j (r x)
{- decode-fun is a right-inverse -}
P-rinv : {n : HLevel} (u v : ∥ B ∥ (suc n)) (x : Path (∥ B ∥ (suc n)) u v)
→ decode-fun u v (encode-fun u v x) ≡ x
P-rinv u v = J (λ y p → decode-fun u y (encode-fun u y p) ≡ p)
(cong (decode-fun u u) (enc-refl u) ∙ dec-refl u)
{- decode-fun is a left-inverse -}
P-linv : {n : HLevel} (u v : ∥ B ∥ (suc n )) (x : P u v)
→ encode-fun u v (decode-fun u v x) ≡ x
P-linv {n = n} =
elim2 (λ x y → isOfHLevelΠ (suc n)
(λ z → isOfHLevelSuc (suc n) (hLevelP x y) _ _))
helper
where
helper : {n : HLevel} (a b : B) (p : P {n = n} ∣ a ∣ ∣ b ∣)
→ encode-fun _ _ (decode-fun ∣ a ∣ ∣ b ∣ p) ≡ p
helper {n = zero} a b =
elim (λ x → ( sym (isOfHLevelTrunc 0 .snd _) ∙ isOfHLevelTrunc 0 .snd x
, λ y → isOfHLevelSuc 1 (isOfHLevelSuc 0 (isOfHLevelTrunc 0)) _ _ _ _))
(J (λ y p → encode-fun ∣ a ∣ ∣ y ∣ (decode-fun _ _ ∣ p ∣) ≡ ∣ p ∣)
(enc-refl ∣ a ∣))
helper {n = suc n} a b =
elim (λ x → hLevelP {n = suc n} ∣ a ∣ ∣ b ∣ _ _)
(J (λ y p → encode-fun {n = suc n} ∣ a ∣ ∣ y ∣ (decode-fun _ _ ∣ p ∣) ≡ ∣ p ∣)
(enc-refl ∣ a ∣))
{- The final Iso established -}
IsoFinal : (n : HLevel) (x y : ∥ B ∥ (suc n)) → Iso (x ≡ y) (P x y)
Iso.fun (IsoFinal _ x y) = encode-fun x y
Iso.inv (IsoFinal _ x y) = decode-fun x y
Iso.rightInv (IsoFinal _ x y) = P-linv x y
Iso.leftInv (IsoFinal _ x y) = P-rinv x y
PathIdTrunc : {a b : A} (n : HLevel) → (Path (∥ A ∥ (suc n)) ∣ a ∣ ∣ b ∣) ≡ (∥ a ≡ b ∥ n)
PathIdTrunc n = isoToPath (ΩTrunc.IsoFinal n _ _)
PathΩ : {a : A} (n : HLevel) → (Path (∥ A ∥ (suc n)) ∣ a ∣ ∣ a ∣) ≡ (∥ a ≡ a ∥ n)
PathΩ n = PathIdTrunc n
{- Special case using direct defs of truncations -}
PathIdTrunc₀Iso : {a b : A} → Iso (∣ a ∣₂ ≡ ∣ b ∣₂) ∥ a ≡ b ∥₁
PathIdTrunc₀Iso = compIso (congIso setTruncTrunc2Iso)
(compIso (ΩTrunc.IsoFinal _ ∣ _ ∣ ∣ _ ∣)
(invIso propTruncTrunc1Iso))
-------------------------
truncOfTruncIso : (n m : HLevel) → Iso (hLevelTrunc n A) (hLevelTrunc n (hLevelTrunc (m + n) A))
Iso.fun (truncOfTruncIso n m) = elim (λ _ → isOfHLevelTrunc n) λ a → ∣ ∣ a ∣ ∣
Iso.inv (truncOfTruncIso {A = A} n m) =
elim (λ _ → isOfHLevelTrunc n)
(elim (λ _ → (isOfHLevelPlus m (isOfHLevelTrunc n )))
λ a → ∣ a ∣)
Iso.rightInv (truncOfTruncIso {A = A} n m) =
elim (λ x → isOfHLevelPath n (isOfHLevelTrunc n) _ _ )
(elim (λ x → isOfHLevelPath (m + n) (isOfHLevelPlus m (isOfHLevelTrunc n)) _ _ )
λ a → refl)
Iso.leftInv (truncOfTruncIso n m) = elim (λ x → isOfHLevelPath n (isOfHLevelTrunc n) _ _) λ a → refl
truncOfTruncEq : (n m : ℕ) → (hLevelTrunc n A) ≃ (hLevelTrunc n (hLevelTrunc (m + n) A))
truncOfTruncEq n m = isoToEquiv (truncOfTruncIso n m)
|
{
"alphanum_fraction": 0.5787047841,
"avg_line_length": 43.1738035264,
"ext": "agda",
"hexsha": "dcf4e68d4b2f3eb99fba732a19a1cadf54fb742d",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "knrafto/cubical",
"max_forks_repo_path": "Cubical/HITs/Truncation/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "knrafto/cubical",
"max_issues_repo_path": "Cubical/HITs/Truncation/Properties.agda",
"max_line_length": 131,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "knrafto/cubical",
"max_stars_repo_path": "Cubical/HITs/Truncation/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 7155,
"size": 17140
}
|
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import cohomology.Theory
open import cohomology.PtdMapSequence
open import groups.ExactSequence
open import groups.Exactness
open import groups.HomSequence
open import groups.KernelImageUniqueFactorization
open import cw.CW
module cw.cohomology.FirstCohomologyGroup {i} (OT : OrdinaryTheory i)
(⊙skel : ⊙Skeleton {i} 2) (ac : ⊙has-cells-with-choice 0 ⊙skel i) where
open OrdinaryTheory OT
open import cw.cohomology.TipAndAugment OT (⊙cw-take (lteSR lteS) ⊙skel)
open import cw.cohomology.WedgeOfCells OT
open import cw.cohomology.TipCoboundary OT (⊙cw-init ⊙skel)
open import cw.cohomology.HigherCoboundary OT ⊙skel
open import cw.cohomology.HigherCoboundaryGrid OT ⊙skel ac
open import cw.cohomology.GridPtdMap (⊙cw-incl-last (⊙cw-init ⊙skel)) (⊙cw-incl-last ⊙skel)
open import cw.cohomology.TipGrid OT (⊙cw-init ⊙skel) (⊙init-has-cells-with-choice ⊙skel ac)
open import cw.cohomology.TopGrid OT 1 (⊙cw-incl-last (⊙cw-init ⊙skel)) (⊙cw-incl-last ⊙skel)
open import cohomology.LongExactSequence cohomology-theory
private
0≤2 : 0 ≤ 2
0≤2 = lteSR lteS
ac₀ = ⊙take-has-cells-with-choice 0≤2 ⊙skel ac
{-
H
Coker ≃ C(X₁)<------C(X₂) = C(X)
^ ^
| |
| |
C(X₁/X₀)<---C(X₂/X₀) ≃ Ker
WoC G
WoC := Wedges of Cells
-}
private
G : Group i
G = C 1 (⊙Cofiber (⊙cw-incl-tail 0≤2 ⊙skel))
G-iso-Ker : G ≃ᴳ Ker.grp cw-co∂-last
G-iso-Ker = Ker-cw-co∂-last
H : Group i
H = C 1 ⊙⟦ ⊙cw-init ⊙skel ⟧
Coker-iso-H : CokerCo∂Head.grp ≃ᴳ H
Coker-iso-H = Coker-cw-co∂-head
G-to-C-cw : G →ᴳ C 1 ⊙⟦ ⊙skel ⟧
G-to-C-cw = C-fmap 1 (⊙cfcod' (⊙cw-incl-tail 0≤2 ⊙skel))
abstract
G-to-C-cw-is-surj : is-surjᴳ G-to-C-cw
G-to-C-cw-is-surj = Exact.K-trivial-implies-φ-is-surj
(exact-seq-index 2 $ C-cofiber-exact-seq 0 (⊙cw-incl-tail 0≤2 ⊙skel))
(CX₀-≠-is-trivial (pos-≠ (ℕ-S≠O 0)) ac₀)
C-cw-to-H : C 1 ⊙⟦ ⊙skel ⟧ →ᴳ H
C-cw-to-H = C-fmap 1 (⊙cw-incl-last ⊙skel)
abstract
C-cw-to-H-is-inj : is-injᴳ C-cw-to-H
C-cw-to-H-is-inj = Exact.G-trivial-implies-ψ-is-inj
(exact-seq-index 2 $ C-cofiber-exact-seq 0 (⊙cw-incl-last ⊙skel))
(CXₙ/Xₙ₋₁-<-is-trivial ⊙skel ltS ac)
C-WoC : Group i
C-WoC = C 1 (⊙Cofiber (⊙cw-incl-last (⊙cw-init ⊙skel)))
G-to-C-WoC : G →ᴳ C-WoC
G-to-C-WoC = C-fmap 1 Y/X-to-Z/X
C-WoC-to-H : C-WoC →ᴳ H
C-WoC-to-H = C-fmap 1 (⊙cfcod' (⊙cw-incl-last (⊙cw-init ⊙skel)))
open import groups.KernelImage cw-co∂-last cw-co∂-head CX₁/X₀-is-abelian
C-cw-iso-ker/im : C 1 ⊙⟦ ⊙skel ⟧ ≃ᴳ Ker/Im
C-cw-iso-ker/im = H-iso-Ker/Im
cw-co∂-last cw-co∂-head CX₁/X₀-is-abelian
φ₁ φ₁-is-surj φ₂ φ₂-is-inj lemma-comm
where
φ₁ = G-to-C-cw ∘ᴳ GroupIso.g-hom G-iso-Ker
abstract
φ₁-is-surj : is-surjᴳ φ₁
φ₁-is-surj = ∘-is-surj G-to-C-cw-is-surj (equiv-is-surj (GroupIso.g-is-equiv G-iso-Ker))
φ₂ = GroupIso.g-hom Coker-iso-H ∘ᴳ C-cw-to-H
abstract
φ₂-is-inj : is-injᴳ φ₂
φ₂-is-inj = ∘-is-inj (equiv-is-inj (GroupIso.g-is-equiv Coker-iso-H)) C-cw-to-H-is-inj
abstract
lemma-comm : ∀ g →
GroupIso.g Coker-iso-H (GroupHom.f (C-cw-to-H ∘ᴳ G-to-C-cw) (GroupIso.g G-iso-Ker g))
== q[ fst g ]
lemma-comm g =
GroupIso.g Coker-iso-H (GroupHom.f C-cw-to-H (GroupHom.f G-to-C-cw (GroupIso.g G-iso-Ker g)))
=⟨ ap (GroupIso.g Coker-iso-H) (! (C-top-grid-commutes □$ᴳ GroupIso.g G-iso-Ker g)) ⟩
GroupIso.g Coker-iso-H (GroupHom.f C-WoC-to-H (GroupHom.f G-to-C-WoC (GroupIso.g G-iso-Ker g)))
=⟨ ap (GroupIso.g Coker-iso-H ∘ GroupHom.f C-WoC-to-H ∘ fst) (GroupIso.f-g G-iso-Ker g) ⟩
GroupIso.g Coker-iso-H (GroupHom.f C-WoC-to-H (fst g))
=⟨ GroupIso.g-f Coker-iso-H q[ fst g ] ⟩
q[ fst g ]
=∎
|
{
"alphanum_fraction": 0.6129032258,
"avg_line_length": 33.6956521739,
"ext": "agda",
"hexsha": "3e6b3b632c2d653f654bd57a170637e11b6488ae",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z",
"max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mikeshulman/HoTT-Agda",
"max_forks_repo_path": "theorems/cw/cohomology/FirstCohomologyGroup.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "mikeshulman/HoTT-Agda",
"max_issues_repo_path": "theorems/cw/cohomology/FirstCohomologyGroup.agda",
"max_line_length": 103,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mikeshulman/HoTT-Agda",
"max_stars_repo_path": "theorems/cw/cohomology/FirstCohomologyGroup.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1682,
"size": 3875
}
|
{-# OPTIONS --safe #-}
module Cubical.Algebra.Module.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Equiv.HalfAdjoint
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.SIP
open import Cubical.Data.Sigma
open import Cubical.Displayed.Base
open import Cubical.Displayed.Auto
open import Cubical.Displayed.Record
open import Cubical.Displayed.Universe
open import Cubical.Reflection.RecordEquiv
open import Cubical.Algebra.Ring
open import Cubical.Algebra.AbGroup
open import Cubical.Algebra.Group
open Iso
private
variable
ℓ ℓ' : Level
record IsLeftModule (R : Ring ℓ) {M : Type ℓ'}
(0m : M)
(_+_ : M → M → M)
(-_ : M → M)
(_⋆_ : ⟨ R ⟩ → M → M) : Type (ℓ-max ℓ ℓ') where
constructor ismodule
open RingStr (snd R) using (_·_; 1r) renaming (_+_ to _+r_)
field
+-isAbGroup : IsAbGroup 0m _+_ -_
⋆-assoc : (r s : ⟨ R ⟩) (x : M) → (r · s) ⋆ x ≡ r ⋆ (s ⋆ x)
⋆-ldist : (r s : ⟨ R ⟩) (x : M) → (r +r s) ⋆ x ≡ (r ⋆ x) + (s ⋆ x)
⋆-rdist : (r : ⟨ R ⟩) (x y : M) → r ⋆ (x + y) ≡ (r ⋆ x) + (r ⋆ y)
⋆-lid : (x : M) → 1r ⋆ x ≡ x
open IsAbGroup +-isAbGroup public
renaming
( assoc to +-assoc
; identity to +-identity
; lid to +-lid
; rid to +-rid
; inverse to +-inv
; invl to +-linv
; invr to +-rinv
; comm to +-comm
; isSemigroup to +-isSemigroup
; isMonoid to +-isMonoid
; isGroup to +-isGroup
)
unquoteDecl IsLeftModuleIsoΣ = declareRecordIsoΣ IsLeftModuleIsoΣ (quote IsLeftModule)
record LeftModuleStr (R : Ring ℓ) (A : Type ℓ') : Type (ℓ-max ℓ ℓ') where
constructor leftmodulestr
field
0m : A
_+_ : A → A → A
-_ : A → A
_⋆_ : ⟨ R ⟩ → A → A
isLeftModule : IsLeftModule R 0m _+_ -_ _⋆_
open IsLeftModule isLeftModule public
LeftModule : (R : Ring ℓ) → ∀ ℓ' → Type (ℓ-max ℓ (ℓ-suc ℓ'))
LeftModule R ℓ' = Σ[ A ∈ Type ℓ' ] LeftModuleStr R A
module _ {R : Ring ℓ} where
LeftModule→AbGroup : (M : LeftModule R ℓ') → AbGroup ℓ'
LeftModule→AbGroup (_ , leftmodulestr _ _ _ _ isLeftModule) =
_ , abgroupstr _ _ _ (IsLeftModule.+-isAbGroup isLeftModule)
isSetLeftModule : (M : LeftModule R ℓ') → isSet ⟨ M ⟩
isSetLeftModule M = isSetAbGroup (LeftModule→AbGroup M)
open RingStr (snd R) using (1r) renaming (_+_ to _+r_; _·_ to _·s_)
makeIsLeftModule : {M : Type ℓ'} {0m : M}
{_+_ : M → M → M} { -_ : M → M} {_⋆_ : ⟨ R ⟩ → M → M}
(isSet-M : isSet M)
(+-assoc : (x y z : M) → x + (y + z) ≡ (x + y) + z)
(+-rid : (x : M) → x + 0m ≡ x)
(+-rinv : (x : M) → x + (- x) ≡ 0m)
(+-comm : (x y : M) → x + y ≡ y + x)
(⋆-assoc : (r s : ⟨ R ⟩) (x : M) → (r ·s s) ⋆ x ≡ r ⋆ (s ⋆ x))
(⋆-ldist : (r s : ⟨ R ⟩) (x : M) → (r +r s) ⋆ x ≡ (r ⋆ x) + (s ⋆ x))
(⋆-rdist : (r : ⟨ R ⟩) (x y : M) → r ⋆ (x + y) ≡ (r ⋆ x) + (r ⋆ y))
(⋆-lid : (x : M) → 1r ⋆ x ≡ x)
→ IsLeftModule R 0m _+_ -_ _⋆_
makeIsLeftModule isSet-M +-assoc +-rid +-rinv +-comm ⋆-assoc ⋆-ldist ⋆-rdist ⋆-lid =
ismodule (makeIsAbGroup isSet-M +-assoc +-rid +-rinv +-comm) ⋆-assoc ⋆-ldist ⋆-rdist ⋆-lid
record IsLeftModuleHom {R : Ring ℓ} {A B : Type ℓ'}
(M : LeftModuleStr R A) (f : A → B) (N : LeftModuleStr R B)
: Type (ℓ-max ℓ ℓ')
where
-- Shorter qualified names
private
module M = LeftModuleStr M
module N = LeftModuleStr N
field
pres0 : f M.0m ≡ N.0m
pres+ : (x y : A) → f (x M.+ y) ≡ f x N.+ f y
pres- : (x : A) → f (M.- x) ≡ N.- (f x)
pres⋆ : (r : ⟨ R ⟩) (y : A) → f (r M.⋆ y) ≡ r N.⋆ f y
LeftModuleHom : {R : Ring ℓ} (M N : LeftModule R ℓ') → Type (ℓ-max ℓ ℓ')
LeftModuleHom M N = Σ[ f ∈ (⟨ M ⟩ → ⟨ N ⟩) ] IsLeftModuleHom (M .snd) f (N .snd)
IsLeftModuleEquiv : {R : Ring ℓ} {A B : Type ℓ'}
(M : LeftModuleStr R A) (e : A ≃ B) (N : LeftModuleStr R B)
→ Type (ℓ-max ℓ ℓ')
IsLeftModuleEquiv M e N = IsLeftModuleHom M (e .fst) N
LeftModuleEquiv : {R : Ring ℓ} (M N : LeftModule R ℓ') → Type (ℓ-max ℓ ℓ')
LeftModuleEquiv M N = Σ[ e ∈ ⟨ M ⟩ ≃ ⟨ N ⟩ ] IsLeftModuleEquiv (M .snd) e (N .snd)
isPropIsLeftModule : (R : Ring ℓ) {M : Type ℓ'}
(0m : M)
(_+_ : M → M → M)
(-_ : M → M)
(_⋆_ : ⟨ R ⟩ → M → M)
→ isProp (IsLeftModule R 0m _+_ -_ _⋆_)
isPropIsLeftModule R _ _ _ _ =
isOfHLevelRetractFromIso 1 IsLeftModuleIsoΣ
(isPropΣ (isPropIsAbGroup _ _ _)
(λ ab →
isProp× (isPropΠ3 λ _ _ _ → ab .is-set _ _)
(isProp× (isPropΠ3 λ _ _ _ → ab .is-set _ _)
(isProp× (isPropΠ3 λ _ _ _ → ab .is-set _ _)
(isPropΠ λ _ → ab .is-set _ _)))))
where
open IsAbGroup
𝒮ᴰ-LeftModule : (R : Ring ℓ) → DUARel (𝒮-Univ ℓ') (LeftModuleStr R) (ℓ-max ℓ ℓ')
𝒮ᴰ-LeftModule R =
𝒮ᴰ-Record (𝒮-Univ _) (IsLeftModuleEquiv {R = R})
(fields:
data[ 0m ∣ autoDUARel _ _ ∣ pres0 ]
data[ _+_ ∣ autoDUARel _ _ ∣ pres+ ]
data[ -_ ∣ autoDUARel _ _ ∣ pres- ]
data[ _⋆_ ∣ autoDUARel _ _ ∣ pres⋆ ]
prop[ isLeftModule ∣ (λ _ _ → isPropIsLeftModule _ _ _ _ _) ])
where
open LeftModuleStr
open IsLeftModuleHom
LeftModulePath : {R : Ring ℓ} (M N : LeftModule R ℓ') → (LeftModuleEquiv M N) ≃ (M ≡ N)
LeftModulePath {R = R} = ∫ (𝒮ᴰ-LeftModule R) .UARel.ua
|
{
"alphanum_fraction": 0.5402903811,
"avg_line_length": 33.1927710843,
"ext": "agda",
"hexsha": "4c9eaab428f9cf2286445e6a24022f0c60774fbd",
"lang": "Agda",
"max_forks_count": 134,
"max_forks_repo_forks_event_max_datetime": "2022-03-23T16:22:13.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-11-16T06:11:03.000Z",
"max_forks_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "marcinjangrzybowski/cubical",
"max_forks_repo_path": "Cubical/Algebra/Module/Base.agda",
"max_issues_count": 584,
"max_issues_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237",
"max_issues_repo_issues_event_max_datetime": "2022-03-30T12:09:17.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-10-15T09:49:02.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "marcinjangrzybowski/cubical",
"max_issues_repo_path": "Cubical/Algebra/Module/Base.agda",
"max_line_length": 94,
"max_stars_count": 301,
"max_stars_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "marcinjangrzybowski/cubical",
"max_stars_repo_path": "Cubical/Algebra/Module/Base.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-24T02:10:47.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-10-17T18:00:24.000Z",
"num_tokens": 2278,
"size": 5510
}
|
open import Prelude
open import Nat
open import List
open import Int
open import Bij
open import delta-lemmas
open import Delta
open import NatDelta
|
{
"alphanum_fraction": 0.8322147651,
"avg_line_length": 16.5555555556,
"ext": "agda",
"hexsha": "09af0e0c576c6798fc9d10e06ba01df502711561",
"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": "db857f3e7dc9a4793f68504e6365d93ed75d7f88",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nickcollins/dependent-dicts-agda",
"max_forks_repo_path": "all.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "db857f3e7dc9a4793f68504e6365d93ed75d7f88",
"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": "nickcollins/dependent-dicts-agda",
"max_issues_repo_path": "all.agda",
"max_line_length": 24,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "db857f3e7dc9a4793f68504e6365d93ed75d7f88",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nickcollins/dependent-dicts-agda",
"max_stars_repo_path": "all.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 36,
"size": 149
}
|
module BasicIPC.Metatheory.Gentzen-BasicTarski where
open import BasicIPC.Syntax.Gentzen public
open import BasicIPC.Semantics.BasicTarski public
-- Soundness with respect to all models, or evaluation.
eval : ∀ {A Γ} → Γ ⊢ A → Γ ⊨ A
eval (var i) γ = lookup i γ
eval (lam t) γ = λ a → eval t (γ , a)
eval (app t u) γ = eval t γ $ eval u γ
eval (pair t u) γ = eval t γ , eval u γ
eval (fst t) γ = π₁ (eval t γ)
eval (snd t) γ = π₂ (eval t γ)
eval unit γ = ∙
-- Correctness of evaluation with respect to conversion.
-- FIXME: How to show this?
postulate
oops₁ : ∀ {{_ : Model}} {A B Γ} {t : Γ , A ⊢ B} {u : Γ ⊢ A}
→ eval ([ top ≔ u ] t) ≡ (λ γ → eval t (γ , eval u γ))
oops₂ : ∀ {{_ : Model}} {A B Γ} {t : Γ ⊢ A ▻ B}
→ eval t ≡ (λ γ a → eval (mono⊢ (weak⊆ {A = A}) t) (γ , a) a)
eval✓ : ∀ {{_ : Model}} {A Γ} {t t′ : Γ ⊢ A} → t ⋙ t′ → eval t ≡ eval t′
eval✓ refl⋙ = refl
eval✓ (trans⋙ p q) = trans (eval✓ p) (eval✓ q)
eval✓ (sym⋙ p) = sym (eval✓ p)
eval✓ (conglam⋙ {A} {B} p) = cong (⟦λ⟧ {A} {B}) (eval✓ p)
eval✓ (congapp⋙ {A} {B} p q) = cong² (_⟦$⟧_ {A} {B}) (eval✓ p) (eval✓ q)
eval✓ (congpair⋙ {A} {B} p q) = cong² (_⟦,⟧_ {A} {B}) (eval✓ p) (eval✓ q)
eval✓ (congfst⋙ {A} {B} p) = cong (⟦π₁⟧ {A} {B}) (eval✓ p)
eval✓ (congsnd⋙ {A} {B} p) = cong (⟦π₂⟧ {A} {B}) (eval✓ p)
eval✓ (beta▻⋙ {A} {B} {t} {u}) = sym (oops₁ {A} {B} {_} {t} {u})
eval✓ (eta▻⋙ {A} {B} {t}) = oops₂ {A} {B} {_} {t}
eval✓ beta∧₁⋙ = refl
eval✓ beta∧₂⋙ = refl
eval✓ eta∧⋙ = refl
eval✓ eta⊤⋙ = refl
|
{
"alphanum_fraction": 0.4767090139,
"avg_line_length": 38.4418604651,
"ext": "agda",
"hexsha": "4dafe24d626379cda66d4c38bd7f8897416ce5da",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_forks_repo_licenses": [
"X11"
],
"max_forks_repo_name": "mietek/hilbert-gentzen",
"max_forks_repo_path": "BasicIPC/Metatheory/Gentzen-BasicTarski.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_issues_repo_issues_event_max_datetime": "2018-06-10T09:11:22.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-06-10T09:11:22.000Z",
"max_issues_repo_licenses": [
"X11"
],
"max_issues_repo_name": "mietek/hilbert-gentzen",
"max_issues_repo_path": "BasicIPC/Metatheory/Gentzen-BasicTarski.agda",
"max_line_length": 74,
"max_stars_count": 29,
"max_stars_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_stars_repo_licenses": [
"X11"
],
"max_stars_repo_name": "mietek/hilbert-gentzen",
"max_stars_repo_path": "BasicIPC/Metatheory/Gentzen-BasicTarski.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-01T10:29:18.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-07-03T18:51:56.000Z",
"num_tokens": 757,
"size": 1653
}
|
module Functional.Combinations where
open import Type
-- TODO: Generalize these. Probably by lists and foldᵣ of combination and rotation construction functions. Also categorically or dependently
rotate₃Fn₃Op₂ : ∀{ℓ₁ ℓ₂}{A : Type{ℓ₁}}{B : Type{ℓ₂}} → (A → A → A → B) → (B → B → B) → (A → A → A → B)
rotate₃Fn₃Op₂(F)(_▫_) a b c = (F a b c) ▫ ((F b c a) ▫ (F c a b))
combine₃Fn₂Op₂ : ∀{ℓ₁ ℓ₂}{A : Type{ℓ₁}}{B : Type{ℓ₂}} → (A → A → B) → (B → B → B) → (A → A → A → B)
combine₃Fn₂Op₂(F)(_▫_) a b c = (F a b) ▫ ((F a c) ▫ (F b c))
all₃Fn₁Op₂ : ∀{ℓ₁ ℓ₂}{A : Type{ℓ₁}}{B : Type{ℓ₂}} → (A → B) → (B → B → B) → (A → A → A → B)
all₃Fn₁Op₂(F)(_▫_) a b c = (F a) ▫ ((F b) ▫ (F c))
combine₄Fn₃Op₂ : ∀{ℓ₁ ℓ₂}{A : Type{ℓ₁}}{B : Type{ℓ₂}} → (A → A → A → B) → (B → B → B) → (A → A → A → A → B)
combine₄Fn₃Op₂(F)(_▫_) a b c d = (F a b c) ▫ ((F a b d) ▫ ((F a c d) ▫ (F b c d)))
|
{
"alphanum_fraction": 0.5185185185,
"avg_line_length": 50.8235294118,
"ext": "agda",
"hexsha": "3daa4936860ce8a7b51f6b72243e615a90b4ce91",
"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": "Functional/Combinations.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": "Functional/Combinations.agda",
"max_line_length": 140,
"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": "Functional/Combinations.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": 440,
"size": 864
}
|
-- Andreas, 2013-03-15
-- Paolo Capriotti's formalization of Russell's paradox
{-# OPTIONS --cubical-compatible --type-in-type #-}
module Russell where
open import Common.Product
open import Common.Equality
data ⊥ : Set where
¬ : Set → Set
¬ A = A → ⊥
-- a model of set theory, uses Set : Set
data U : Set where
set : (I : Set) → (I → U) → U
-- a set is regular if it doesn't contain itself
regular : U → Set
regular (set I f) = (i : I) → ¬ (f i ≡ set I f)
-- Russell's set: the set of all regular sets
R : U
R = set (Σ U regular) proj₁
-- R is not regular
R-nonreg : ¬ (regular R)
R-nonreg reg = reg (R , reg) refl
-- R is regular
R-reg : regular R
R-reg (x , reg) p = subst regular p reg (x , reg) p
-- contradiction
absurd : ⊥
absurd = R-nonreg R-reg
|
{
"alphanum_fraction": 0.635770235,
"avg_line_length": 20.1578947368,
"ext": "agda",
"hexsha": "6690cbaf1196a60f475d457e01de1eae135dde99",
"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/Russell.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/Russell.agda",
"max_line_length": 55,
"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/Russell.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 253,
"size": 766
}
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
open import Cubical.Core.Everything
open import Cubical.Relation.Binary
module Cubical.Relation.Binary.Construct.NonStrictToStrict
{a ℓ} {A : Type a} (_≤_ : Rel A ℓ) where
open import Cubical.Relation.Binary.Properties
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Logic hiding (_⇒_; ¬_)
open import Cubical.Data.Sigma
open import Cubical.Data.Sum.Base using (inl; inr)
open import Cubical.Data.Empty
open import Cubical.Foundations.Function using (_∘_; flip; id)
open import Cubical.Relation.Nullary
import Cubical.HITs.PropositionalTruncation as PT
------------------------------------------------------------------------
-- _≤_ can be turned into _<_ as follows:
_<_ : Rel A _
x < y = x ≤ y ⊓ x ≢ₚ y
------------------------------------------------------------------------
-- Relationship between relations
<⇒≤ : _<_ ⇒ _≤_
<⇒≤ = fst
<⇒≢ : _<_ ⇒ _≢ₚ_
<⇒≢ = snd
≤∧≢⇒< : ∀ {x y} → ⟨ x ≤ y ⟩ → ⟨ x ≢ₚ y ⟩ → ⟨ x < y ⟩
≤∧≢⇒< = _,_
<⇒≱ : Antisymmetric _≤_ → ∀ {x y} → ⟨ x < y ⟩ → ¬ ⟨ y ≤ x ⟩
<⇒≱ antisym (x≤y , x≢y) y≤x = x≢y (antisym x≤y y≤x)
≤⇒≯ : Antisymmetric _≤_ → ∀ {x y} → ⟨ x ≤ y ⟩ → ¬ ⟨ y < x ⟩
≤⇒≯ antisym x≤y y<x = <⇒≱ antisym y<x x≤y
≰⇒> : Reflexive _≤_ → Total _≤_ →
∀ {x y} → ¬ ⟨ x ≤ y ⟩ → ⟨ y < x ⟩
≰⇒> rfl total {x} {y} x≰y = PT.rec ((y < x) .snd) (λ {
(inl x≤y) → elim (x≰y x≤y)
; (inr y≤x) → y≤x , x≰y ∘ reflx→fromeq _≤_ rfl ∘ PT.map sym
}) (total x y)
≮⇒≥ : Discrete A → Reflexive _≤_ → Total _≤_ →
∀ {x y} → ¬ ⟨ x < y ⟩ → ⟨ y ≤ x ⟩
≮⇒≥ _≟_ ≤-refl _≤?_ {x} {y} x≮y with x ≟ y
... | yes x≈y = reflx→fromeq _≤_ ≤-refl ∣ sym x≈y ∣
... | no x≢y = PT.rec ((y ≤ x) .snd) (λ {
(inl y≤x) → y≤x
; (inr x≤y) → elim (x≮y (x≤y , x≢y ∘ PT.rec (Discrete→isSet _≟_ _ _) id))
}) (y ≤? x)
------------------------------------------------------------------------
-- Relational properties
<-toNotEq : ToNotEq _<_
<-toNotEq (_ , x≢y) x≡y = x≢y x≡y
<-irrefl : Irreflexive _<_
<-irrefl = tonoteq→irrefl _<_ <-toNotEq
<-transitive : IsPartialOrder _≤_ → Transitive _<_
<-transitive po (x≤y , x≢y) (y≤z , y≉z) =
(transitive x≤y y≤z , x≢y ∘ antisym x≤y ∘ transitive y≤z ∘ fromEq ∘ PT.map sym)
where open IsPartialOrder po
<-≤-trans : Transitive _≤_ → Antisymmetric _≤_ →
Trans _<_ _≤_ _<_
<-≤-trans transitive antisym (x≤y , x≢y) y≤z =
transitive x≤y y≤z , (λ x≡z → x≢y (antisym x≤y (Respectsʳ≡ₚ _≤_ (PT.map sym x≡z) y≤z)))
≤-<-trans : Transitive _≤_ → Antisymmetric _≤_ →
Trans _≤_ _<_ _<_
≤-<-trans trans antisym x≤y (y≤z , y≢z) =
trans x≤y y≤z , (λ x≡z → y≢z (antisym y≤z (Respectsˡ≡ₚ _≤_ x≡z x≤y)))
<-asym : Antisymmetric _≤_ → Asymmetric _<_
<-asym antisym (x≤y , x≢y) (y≤x , _) = x≢y (antisym x≤y y≤x)
{-
<-trichotomous : Discrete A → Antisymmetric _≤_ → Total _≤_ → Trichotomous _<_
<-trichotomous _≟_ antisym total x y with x ≟ y
... | yes x≡y = tri≡ (λ x<y → ?) x≡y (λ y<x → <-toNotEq y<x (PT.map sym x≡y))
... | no x≢y with total x y
... | inl x≤y = tri< (x≤y , x≢y) x≢y (x≢y ∘ antisym x≤y ∘ proj₁)
... | inr y≤x = tri> (x≢y ∘ flip antisym y≤x ∘ proj₁) x≢y (y≤x , x≢y ∘ sym)
-}
<-decidable : Discrete A → Decidable _≤_ → Decidable _<_
<-decidable _≟_ _≤?_ x y with x ≤? y
... | no ¬p = no (¬p ∘ fst)
... | yes p with x ≟ y
... | yes q = no (λ x<y → snd x<y ∣ q ∣)
... | no ¬q = yes (p , ¬q ∘ PT.rec (Discrete→isSet _≟_ _ _) id)
------------------------------------------------------------------------
-- Structures
{-
isStrictPartialOrder : IsPartialOrder _≤_ → IsStrictPartialOrder _<_
isStrictPartialOrder po = record
{ irrefl = <-irrefl
; transitive = <-transitive po
} where open IsPartialOrder po
isStrictTotalOrder₁ : Discrete A → IsTotalOrder _≤_ →
IsStrictTotalOrder _<_
isStrictTotalOrder₁ ≟ tot = record
{ transitive = <-transitive isPartialOrder
; compare = <-trichotomous ≟ antisym total
} where open IsTotalOrder tot
isStrictTotalOrder₂ : IsDecTotalOrder _≤_ → IsStrictTotalOrder _<_
isStrictTotalOrder₂ dtot = isStrictTotalOrder₁ _≟_ isTotalOrder
where open IsDecTotalOrder dtot
-}
|
{
"alphanum_fraction": 0.5479020131,
"avg_line_length": 34.0743801653,
"ext": "agda",
"hexsha": "4f782afe47437221a8ec4cc5438b30077ee95fa1",
"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/Construct/NonStrictToStrict.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/Construct/NonStrictToStrict.agda",
"max_line_length": 89,
"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/Construct/NonStrictToStrict.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1780,
"size": 4123
}
|
------------------------------------------------------------------------
-- INCREMENTAL λ-CALCULUS
--
-- Connecting Nehemiah.Change.Term and Nehemiah.Change.Value.
------------------------------------------------------------------------
module Nehemiah.Change.Evaluation where
open import Nehemiah.Syntax.Type
open import Nehemiah.Syntax.Term
open import Nehemiah.Change.Type
open import Nehemiah.Change.Term
open import Nehemiah.Change.Value
open import Nehemiah.Denotation.Value
open import Nehemiah.Denotation.Evaluation
open import Relation.Binary.PropositionalEquality
open import Base.Denotation.Notation
import Parametric.Change.Evaluation
⟦_⟧Base ⟦_⟧Const ΔBase apply-base diff-base nil-base ⟦apply-base⟧ ⟦diff-base⟧ ⟦nil-base⟧
as ChangeEvaluation
meaning-⊕-base : ChangeEvaluation.ApplyStructure
meaning-⊕-base base-int = refl
meaning-⊕-base base-bag = refl
meaning-⊝-base : ChangeEvaluation.DiffStructure
meaning-⊝-base base-int = refl
meaning-⊝-base base-bag = refl
meaning-onil-base : ChangeEvaluation.NilStructure
meaning-onil-base base-int = refl
meaning-onil-base base-bag = refl
open ChangeEvaluation.Structure meaning-⊕-base meaning-⊝-base meaning-onil-base public
|
{
"alphanum_fraction": 0.7056856187,
"avg_line_length": 32.3243243243,
"ext": "agda",
"hexsha": "764a6d22eb463517d4f713a2e073d4f6ebfa1e63",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z",
"max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "inc-lc/ilc-agda",
"max_forks_repo_path": "Nehemiah/Change/Evaluation.agda",
"max_issues_count": 6,
"max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "inc-lc/ilc-agda",
"max_issues_repo_path": "Nehemiah/Change/Evaluation.agda",
"max_line_length": 92,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "inc-lc/ilc-agda",
"max_stars_repo_path": "Nehemiah/Change/Evaluation.agda",
"max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z",
"num_tokens": 290,
"size": 1196
}
|
module Data.String where
import Data.List
import Data.Char
open Data.List using (List)
open Data.Char
postulate String : Set
{-# BUILTIN STRING String #-}
infixr 50 _++_
private
primitive
primStringAppend : String -> String -> String
primStringToList : String -> List Char
primStringFromList : List Char -> String
_++_ = primStringAppend
toList = primStringToList
fromList = primStringFromList
|
{
"alphanum_fraction": 0.7139534884,
"avg_line_length": 17.2,
"ext": "agda",
"hexsha": "cf5c1d55659481ebb1d3261e1a50594ca502e46b",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/String.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/String.agda",
"max_line_length": 51,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/String.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": 110,
"size": 430
}
|
module Dave.Algebra.Naturals.Excercises where
open import Dave.Algebra.Naturals.Addition
+-rearrange : ∀ (m n p q : ℕ) → (m + n) + (p + q) ≡ m + (n + p) + q
+-rearrange m n p q = begin
(m + n) + (p + q) ≡⟨ IsSemigroup.assoc ℕ-+-IsSemigroup m n (p + q) ⟩
m + (n + (p + q)) ≡⟨ cong (λ a → m + a) (sym (IsSemigroup.assoc ℕ-+-IsSemigroup n p q)) ⟩
m + ((n + p) + q) ≡⟨ sym (IsSemigroup.assoc ℕ-+-IsSemigroup m (n + p) q) ⟩
(m + (n + p)) + q ∎
+-swap : ∀ (m n p : ℕ) → m + (n + p) ≡ n + (m + p)
+-swap m n p = begin
m + (n + p) ≡⟨ +-comm m (n + p) ⟩
(n + p) + m ≡⟨ IsSemigroup.assoc ℕ-+-IsSemigroup n p m ⟩
n + (p + m) ≡⟨ cong (λ a → n + a) (+-comm p m) ⟩
n + (m + p) ∎
|
{
"alphanum_fraction": 0.4689265537,
"avg_line_length": 44.25,
"ext": "agda",
"hexsha": "35c337cd42c463e91dfd7978f68e5f032bbe5251",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "05213fb6ab1f51f770f9858b61526ba950e06232",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DavidStahl97/formal-proofs",
"max_forks_repo_path": "Dave/Algebra/Naturals/Excercises.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "05213fb6ab1f51f770f9858b61526ba950e06232",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DavidStahl97/formal-proofs",
"max_issues_repo_path": "Dave/Algebra/Naturals/Excercises.agda",
"max_line_length": 93,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "05213fb6ab1f51f770f9858b61526ba950e06232",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DavidStahl97/formal-proofs",
"max_stars_repo_path": "Dave/Algebra/Naturals/Excercises.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 340,
"size": 708
}
|
------------------------------------------------------------------------
-- Canonically kinded hereditary substitutions in Fω with interval kinds
------------------------------------------------------------------------
{-# OPTIONS --safe --without-K #-}
module FOmegaInt.Kinding.Canonical.HereditarySubstitution where
open import Data.Fin using (Fin; zero; suc; raise; lift)
open import Data.Fin.Substitution
open import Data.Fin.Substitution.Lemmas
open import Data.Fin.Substitution.ExtraLemmas
open import Data.Fin.Substitution.Typed
open import Data.Product as Prod using (∃; _,_; _×_; proj₁; proj₂)
open import Data.Vec as Vec using ([]; _∷_)
import Data.Vec.Properties as VecProps
open import Function using (_∘_)
open import Relation.Binary.PropositionalEquality
open ≡-Reasoning
open import FOmegaInt.Syntax
open import FOmegaInt.Syntax.SingleVariableSubstitution
open import FOmegaInt.Syntax.HereditarySubstitution
open import FOmegaInt.Syntax.Normalization
open import FOmegaInt.Kinding.Canonical as CanonicalKinding
open import FOmegaInt.Kinding.Simple as SimpleKinding
open Syntax
open ElimCtx
open SimpleCtx using (⌊_⌋Asc; kd; tp)
open ContextConversions using (⌊_⌋Ctx)
open Substitution hiding (_↑; sub; subst)
open RenamingCommutes
open SimpHSubstLemmas
open SimpleKinding.Kinding using (_⊢_kds; kds-Π)
open CanonicalKinding.Kinding
open KindedHereditarySubstitution
using (_⊢/⟨_⟩_∈_; ∈-hsub; ∈-H↑; kds-/⟨⟩; kds-[]-/⟨⟩-↑⋆)
open CanonicalKinding.KindedRenaming
using (typedVarSubst; kd-/Var; ≃-/Var; <∷-/Var; kd-weaken; <∷-weaken)
module TV = TypedVarSubst typedVarSubst
open ContextNarrowing
----------------------------------------------------------------------
-- Ascription order: a wrapper judgment that combines subtyping and
-- subkinding.
--
-- NOTE. Subtyping instances are always trivial, i.e. they only
-- support (syntactic) reflexivity.
infix 4 _⊢_≤_
data _⊢_≤_ {n} (Γ : Ctx n) : ElimAsc n → ElimAsc n → Set where
≤-<∷ : ∀ {j k} → Γ ⊢ j <∷ k → Γ ⊢ k kd → Γ ⊢ kd j ≤ kd k
≤-refl : ∀ {a} → Γ ⊢ a ≤ a
-- Transitivity of the ascription order.
≤-trans : ∀ {n} {Γ : Ctx n} {a b c} → Γ ⊢ a ≤ b → Γ ⊢ b ≤ c → Γ ⊢ a ≤ c
≤-trans (≤-<∷ j<∷k _) (≤-<∷ k<∷l l-kd) = ≤-<∷ (<∷-trans j<∷k k<∷l) l-kd
≤-trans (≤-<∷ j<∷k k-kd) ≤-refl = ≤-<∷ j<∷k k-kd
≤-trans ≤-refl a≤c = a≤c
-- Kinds in related ascriptions have the same shape.
≤-⌊⌋ : ∀ {n} {Γ : Ctx n} {j k} → Γ ⊢ kd j ≤ kd k → ⌊ j ⌋ ≡ ⌊ k ⌋
≤-⌊⌋ (≤-<∷ j<∷k _) = <∷-⌊⌋ j<∷k
≤-⌊⌋ ≤-refl = refl
-- Renamings preserve the ascription order.
≤-/Var : ∀ {m n Γ Δ a b} {ρ : Sub Fin m n} →
Γ ⊢ a ≤ b → Δ TV.⊢/Var ρ ∈ Γ → Δ ⊢ a ElimAsc/Var ρ ≤ b ElimAsc/Var ρ
≤-/Var (≤-<∷ j<∷k k-kd) ρ∈Γ = ≤-<∷ (<∷-/Var j<∷k ρ∈Γ) (kd-/Var k-kd ρ∈Γ)
≤-/Var ≤-refl ρ∈Γ = ≤-refl
-- Admissible subsumption rules w.r.t. the ascription order.
Nf⇇-⇑-≤ : ∀ {n} {Γ : Ctx n} {a k j} →
Γ ⊢Nf a ⇇ k → Γ ⊢ kd k ≤ kd j → Γ ⊢Nf a ⇇ j
Nf⇇-⇑-≤ a⇇k (≤-<∷ k<∷j j-kd) = Nf⇇-⇑ a⇇k k<∷j
Nf⇇-⇑-≤ a⇇k ≤-refl = a⇇k
≃-⇑-≤ : ∀ {n} {Γ : Ctx n} {a b k j} →
Γ ⊢ a ≃ b ⇇ k → Γ ⊢ kd k ≤ kd j → Γ ⊢ a ≃ b ⇇ j
≃-⇑-≤ a≃b⇇k (≤-<∷ k<∷j j-kd) = ≃-⇑ a≃b⇇k k<∷j j-kd
≃-⇑-≤ a≃b⇇k ≤-refl = a≃b⇇k
-- An admissible variable rule based on the ascription order.
Var∈-⇑-≤ : ∀ {n} {Γ : Ctx n} {a k} x →
Γ ctx → lookup Γ x ≡ a → Γ ⊢ a ≤ kd k → Γ ⊢Var x ∈ k
Var∈-⇑-≤ x Γ-ctx Γ[x]≡j (≤-<∷ j<∷k k-kd) = ⇇-⇑ (⇉-var x Γ-ctx Γ[x]≡j) j<∷k k-kd
Var∈-⇑-≤ x Γ-ctx Γ[x]≡k ≤-refl = ⇉-var x Γ-ctx Γ[x]≡k
----------------------------------------------------------------------
-- Well-kinded hereditary substitutions (i.e. substitution lemmas) in
-- canonical types
infix 4 _⊢/⟨_⟩_⇇_ _⊢/⟨_⟩_≃_⇇_ _⊢?⟨_⟩_⇇_ _⊢?⟨_⟩_≃_⇇_
-- Well-kinded pointwise equality of hereditary substitutions and
-- their lookup results.
data _⊢/⟨_⟩_≃_⇇_ : ∀ {m n} →
Ctx n → SKind → SVSub m n → SVSub m n → Ctx m → Set where
≃-hsub : ∀ {n} {Γ : Ctx n} {k a b j} →
Γ ⊢ a ≃ b ⇇ j → ⌊ j ⌋≡ k →
Γ ⊢/⟨ k ⟩ sub a ≃ sub b ⇇ kd j ∷ Γ
≃-H↑ : ∀ {m n Δ k Γ} {σ τ : SVSub m n} {j l} →
Δ ⊢ j ≅ l Kind/⟨ k ⟩ σ → Δ ⊢ j ≅ l Kind/⟨ k ⟩ τ →
Δ ⊢/⟨ k ⟩ σ ≃ τ ⇇ Γ → kd j ∷ Δ ⊢/⟨ k ⟩ σ ↑ ≃ τ ↑ ⇇ kd l ∷ Γ
data _⊢?⟨_⟩_≃_⇇_ {n} (Γ : Ctx n) (k : SKind)
: SVRes n → SVRes n → ElimAsc n → Set where
≃-hit : ∀ {a b j} →
Γ ⊢ a ≃ b ⇇ j → ⌊ j ⌋≡ k → Γ ⊢?⟨ k ⟩ hit a ≃ hit b ⇇ kd j
≃-miss : ∀ y {a b} → Γ ctx → lookup Γ y ≡ a → Γ ⊢ a ≤ b →
Γ ⊢?⟨ k ⟩ miss y ≃ miss y ⇇ b
-- Well-kinded suspended hereditary substations are just a degenerate
-- case of equal hereditary substitutions where the underlying
-- substitutions coincide (syntactically).
_⊢/⟨_⟩_⇇_ : ∀ {m n} → Ctx n → SKind → SVSub m n → Ctx m → Set
Δ ⊢/⟨ k ⟩ σ ⇇ Γ = Δ ⊢/⟨ k ⟩ σ ≃ σ ⇇ Γ
⇇-hsub : ∀ {n} {Γ : Ctx n} {k a j} →
Γ ⊢Nf a ⇇ j → Γ ⊢ j kd → ⌊ j ⌋≡ k →
Γ ⊢/⟨ k ⟩ sub a ⇇ kd j ∷ Γ
⇇-hsub a⇇j j-kd ⌊j⌋≡k = ≃-hsub (≃-reflNf⇇ a⇇j j-kd) ⌊j⌋≡k
⇇-H↑ : ∀ {m n Δ k Γ} {σ : SVSub m n} {j l} →
Δ ⊢ j ≅ l Kind/⟨ k ⟩ σ → Δ ⊢/⟨ k ⟩ σ ⇇ Γ →
kd j ∷ Δ ⊢/⟨ k ⟩ σ ↑ ⇇ kd l ∷ Γ
⇇-H↑ j≅l/σ σ⇇Γ = ≃-H↑ j≅l/σ j≅l/σ σ⇇Γ
_⊢?⟨_⟩_⇇_ : ∀ {n} → Ctx n → SKind → SVRes n → ElimAsc n → Set
Δ ⊢?⟨ k ⟩ σ ⇇ Γ = Δ ⊢?⟨ k ⟩ σ ≃ σ ⇇ Γ
⇇-hit : ∀ {n} {Γ : Ctx n} {k a j} →
Γ ⊢Nf a ⇇ j → Γ ⊢ j kd → ⌊ j ⌋≡ k → Γ ⊢?⟨ k ⟩ hit a ⇇ kd j
⇇-hit a⇇j j-kd ⌊j⌋≡k = ≃-hit (≃-reflNf⇇ a⇇j j-kd) ⌊j⌋≡k
⇇-miss = λ {n} {Γ} {k} → ≃-miss {n} {Γ} {k}
-- Renamings preserve equality of SV results.
?≃-/Var : ∀ {m n Γ k Δ r₁ r₂ a} {ρ : Sub Fin m n} →
Γ ⊢?⟨ k ⟩ r₁ ≃ r₂ ⇇ a → Δ TV.⊢/Var ρ ∈ Γ →
Δ ⊢?⟨ k ⟩ r₁ ?/Var ρ ≃ r₂ ?/Var ρ ⇇ a ElimAsc/Var ρ
?≃-/Var (≃-hit a≃b∈k ⌊j⌋≡k) ρ∈Γ =
≃-hit (≃-/Var a≃b∈k ρ∈Γ) (⌊⌋≡-/Var ⌊j⌋≡k)
?≃-/Var {Γ = Γ} {k} {Δ} {ρ = ρ} (≃-miss y {a} {b} _ Γ[x]≡a a≤b) ρ∈Γ =
helper (cong (_ElimAsc/Var ρ) Γ[x]≡a) (TV.lookup ρ∈Γ y)
where
helper : ∀ {x c} → c ≡ a ElimAsc/Var ρ → Δ TV.⊢Var x ∈ c →
Δ ⊢?⟨ k ⟩ miss x ≃ miss x ⇇ b ElimAsc/Var ρ
helper Δ[x]≡a/ρ (TV.∈-var x Δ-ctx) =
≃-miss x (TV./∈-wf ρ∈Γ) Δ[x]≡a/ρ (≤-/Var a≤b ρ∈Γ)
?≃-weaken : ∀ {n} {Γ : Ctx n} {k r₁ r₂ a b} →
Γ ⊢ a wf → Γ ⊢?⟨ k ⟩ r₁ ≃ r₂ ⇇ b →
(a ∷ Γ) ⊢?⟨ k ⟩ weakenSVRes r₁ ≃ weakenSVRes r₂ ⇇ weakenElimAsc b
?≃-weaken a-wf r₁≃r₂⇇a = ?≃-/Var r₁≃r₂⇇a (TV.∈-wk a-wf)
-- Look up a variable in a pair of well-kinded pointwise equal
-- hereditary substitution.
lookup-/⟨⟩≃ : ∀ {m n Δ k Γ} {σ τ : SVSub m n} →
Δ ⊢/⟨ k ⟩ σ ≃ τ ⇇ Γ → (x : Fin m) →
Δ ⊢?⟨ k ⟩ lookupSV σ x ≃ lookupSV τ x ⇇ lookup Γ x Asc/⟨ k ⟩ σ
lookup-/⟨⟩≃ (≃-hsub {_} {Γ} {k} {a} {b} {j} a≃b⇇k ⌊j⌋≡k) zero =
subst (Γ ⊢?⟨ k ⟩ hit a ≃ hit b ⇇_)
(cong kd (sym (Kind/Var-wk-↑⋆-hsub-vanishes 0 j))) (≃-hit a≃b⇇k ⌊j⌋≡k)
lookup-/⟨⟩≃ (≃-hsub {Γ = Γ} {k} {a} {_} {j} a≃b⇇k ⌊j⌋≡k) (suc x) =
subst (Γ ⊢?⟨ k ⟩ miss x ≃ miss x ⇇_) (begin
lookup Γ x
≡˘⟨ Asc/Var-wk-↑⋆-hsub-vanishes 0 (lookup Γ x) ⟩
weakenElimAsc (lookup Γ x) Asc/⟨ k ⟩ sub a
≡˘⟨ cong (_Asc/⟨ k ⟩ sub a) (VecProps.lookup-map x weakenElimAsc (toVec Γ)) ⟩
lookup (kd j ∷ Γ) (suc x) Asc/⟨ k ⟩ sub a
∎) (≃-miss x (≃-ctx a≃b⇇k) refl ≤-refl)
lookup-/⟨⟩≃ (≃-H↑ {Δ = Δ} {k} {j = j} {l} j≅l/σ j≅l/τ σ≃τ⇇Γ) zero =
let j-kd , l/σ-kd = ≅-valid j≅l/σ
j-wf = wf-kd j-kd
j≤l/σ = ≤-<∷ (<∷-weaken j-wf (≅⇒<∷ j≅l/σ)) (kd-weaken j-wf l/σ-kd)
in subst (kd j ∷ Δ ⊢?⟨ k ⟩ miss zero ≃ miss zero ⇇_)
(sym (wk-Asc/⟨⟩-↑⋆ 0 (kd l)))
(≃-miss zero (j-wf ∷ (kd-ctx j-kd)) refl j≤l/σ)
lookup-/⟨⟩≃ (≃-H↑ {k = k} {Γ} {σ} {_} {_} {l} j≅l/σ _ σ≃τ⇇Γ) (suc x) =
subst (_ ⊢?⟨ k ⟩ _ ≃ _ ⇇_) (begin
weakenElimAsc (lookup Γ x Asc/⟨ k ⟩ σ)
≡˘⟨ wk-Asc/⟨⟩-↑⋆ 0 (lookup Γ x) ⟩
weakenElimAsc (lookup Γ x) Asc/⟨ k ⟩ σ ↑
≡˘⟨ cong (_Asc/⟨ k ⟩ σ ↑)
(VecProps.lookup-map x weakenElimAsc (toVec Γ)) ⟩
lookup (kd l ∷ Γ) (suc x) Asc/⟨ k ⟩ σ ↑
∎) (?≃-weaken (wf-kd (proj₁ (≅-valid j≅l/σ))) (lookup-/⟨⟩≃ σ≃τ⇇Γ x))
-- Equation and context validity lemmas for hereditary substitutions.
/⟨⟩≃-valid₁ : ∀ {k m n Δ Γ} {σ τ : SVSub m n} →
Δ ⊢/⟨ k ⟩ σ ≃ τ ⇇ Γ → Δ ⊢/⟨ k ⟩ σ ⇇ Γ
/⟨⟩≃-valid₁ (≃-hsub a≃b⇇j ⌊j⌋≡k) =
⇇-hsub (proj₁ (≃-valid a≃b⇇j)) (≃-valid-kd a≃b⇇j) ⌊j⌋≡k
/⟨⟩≃-valid₁ (≃-H↑ a≅b/σ _ σ≃τ∈Γ) = ⇇-H↑ a≅b/σ (/⟨⟩≃-valid₁ σ≃τ∈Γ)
/⟨⟩≃-valid₂ : ∀ {k m n Δ Γ} {σ τ : SVSub m n} →
Δ ⊢/⟨ k ⟩ σ ≃ τ ⇇ Γ → Δ ⊢/⟨ k ⟩ τ ⇇ Γ
/⟨⟩≃-valid₂ (≃-hsub a≃b⇇j ⌊j⌋≡k) =
⇇-hsub (proj₂ (≃-valid a≃b⇇j)) (≃-valid-kd a≃b⇇j) ⌊j⌋≡k
/⟨⟩≃-valid₂ (≃-H↑ _ a≅b/τ σ≃τ∈Γ) = ⇇-H↑ a≅b/τ (/⟨⟩≃-valid₂ σ≃τ∈Γ)
/⟨⟩≃-ctx : ∀ {k m n Γ Δ} {σ τ : SVSub m n} →
Γ ctx → Δ ⊢/⟨ k ⟩ σ ≃ τ ⇇ Γ → Δ ctx
/⟨⟩≃-ctx j∷Γ-ctx (≃-hsub a≃b⇇j ⌊j⌋≡k) = wf-∷₂ j∷Γ-ctx
/⟨⟩≃-ctx l∷Γ-ctx (≃-H↑ j≅l/σ j≅l/τ σ≃τ⇇Γ) =
let j-kd , _ = ≅-valid j≅l/σ
Γ-ctx = wf-∷₂ l∷Γ-ctx
in (wf-kd j-kd) ∷ /⟨⟩≃-ctx Γ-ctx σ≃τ⇇Γ
-- Symmetry of hereditary substitution equality.
/⟨⟩≃-sym : ∀ {k m n Δ Γ} {σ τ : SVSub m n} →
Δ ⊢/⟨ k ⟩ σ ≃ τ ⇇ Γ → Δ ⊢/⟨ k ⟩ τ ≃ σ ⇇ Γ
/⟨⟩≃-sym (≃-hsub a≃b⇇j ⌊j⌋≡k) = ≃-hsub (≃-sym a≃b⇇j) ⌊j⌋≡k
/⟨⟩≃-sym (≃-H↑ a≅b/σ a≅b/τ σ≃τ∈Γ) = ≃-H↑ a≅b/τ a≅b/σ (/⟨⟩≃-sym σ≃τ∈Γ)
-- Simplification of kinded substitutions.
--
-- NOTE. The second substitution τ is ignored by the simplification.
-- It is tempting to rephrase the lemma in terms of _⊢/⟨_⟩_⇇_ instead
-- of _⊢/⟨_⟩_≃_⇇_ but that introduces extra constraints for the Agda
-- pattern matcher that require UIP (aka axiom K) to resolve. Since
-- this assumption is unnecessary, we prove the more general version
-- instead. (See the Agda documentation about the --without-K option
-- for more info).
/⟨⟩⇇-/⟨⟩∈ : ∀ {k m n Δ Γ} {σ τ : SVSub m n} →
Δ ⊢/⟨ k ⟩ σ ≃ τ ⇇ Γ → ⌊ Δ ⌋Ctx ⊢/⟨ k ⟩ σ ∈ ⌊ Γ ⌋Ctx
/⟨⟩⇇-/⟨⟩∈ (≃-hsub a≃b⇇j ⌊j⌋≡k) =
subst (_ ⊢/⟨_⟩ _ ∈ _) (⌊⌋≡⇒⌊⌋-≡ ⌊j⌋≡k)
(∈-hsub (Nf⇇-Nf∈ (proj₁ (≃-valid a≃b⇇j))))
/⟨⟩⇇-/⟨⟩∈ (≃-H↑ {Δ = Δ} {k} {Γ} {σ} {_} {j} {l} j≅l/σ _ σ≃σ∈Γ) =
subst ((_⊢/⟨ k ⟩ σ ↑ ∈ ⌊ kd l ∷ Γ ⌋Ctx) ∘ (_∷ ⌊ Δ ⌋Ctx)) (begin
⌊ kd l ⌋Asc ≡˘⟨ ⌊⌋-Asc/⟨⟩ (kd l) ⟩
⌊ kd l Asc/⟨ k ⟩ σ ⌋Asc ≡˘⟨ cong kd (≅-⌊⌋ j≅l/σ) ⟩
⌊ kd j ⌋Asc ∎)
(∈-H↑ (/⟨⟩⇇-/⟨⟩∈ σ≃σ∈Γ))
-- TODO: explain why we need to track shapes explicitly.
module TrackSimpleKindsSubst where
-- TODO: explain how/why preservation of (sub)kinding/subtyping
-- under reducing applications, hereditary substitution and equal
-- hereditary substitutions circularly depend on each other.
mutual
-- Hereditary substitutions preserve well-formedness of kinds.
kd-/⟨⟩ : ∀ {k m n Γ Δ} {σ : SVSub m n} {j} →
Γ ⊢ j kd → Δ ⊢/⟨ k ⟩ σ ⇇ Γ → Δ ⊢ j Kind/⟨ k ⟩ σ kd
kd-/⟨⟩ (kd-⋯ a⇉a⋯a b⇉b⋯b) σ⇇Γ =
kd-⋯ (Nf⇉-/⟨⟩ a⇉a⋯a σ⇇Γ) (Nf⇉-/⟨⟩ b⇉b⋯b σ⇇Γ)
kd-/⟨⟩ (kd-Π j-kd k-kd) σ⇇Γ =
let j/σ-kd = kd-/⟨⟩ j-kd σ⇇Γ
in kd-Π j/σ-kd (kd-/⟨⟩ k-kd (⇇-H↑ (≅-refl j/σ-kd) σ⇇Γ))
-- Hereditary substitutions preserve synthesized kinds of normal
-- types.
Nf⇉-/⟨⟩ : ∀ {k m n Γ Δ} {σ : SVSub m n} {a j} →
Γ ⊢Nf a ⇉ j → Δ ⊢/⟨ k ⟩ σ ⇇ Γ → Δ ⊢Nf a /⟨ k ⟩ σ ⇉ j Kind/⟨ k ⟩ σ
Nf⇉-/⟨⟩ (⇉-⊥-f Γ-ctx) σ⇇Γ = ⇉-⊥-f (/⟨⟩≃-ctx Γ-ctx σ⇇Γ)
Nf⇉-/⟨⟩ (⇉-⊤-f Γ-ctx) σ⇇Γ = ⇉-⊤-f (/⟨⟩≃-ctx Γ-ctx σ⇇Γ)
Nf⇉-/⟨⟩ (⇉-∀-f k-kd a⇉a⋯a) σ⇇Γ =
let k/σ-kd = kd-/⟨⟩ k-kd σ⇇Γ
in ⇉-∀-f k/σ-kd (Nf⇉-/⟨⟩ a⇉a⋯a (⇇-H↑ (≅-refl k/σ-kd) σ⇇Γ))
Nf⇉-/⟨⟩ (⇉-→-f a⇉a⋯a b⇉b⋯b) σ⇇Γ =
⇉-→-f (Nf⇉-/⟨⟩ a⇉a⋯a σ⇇Γ) (Nf⇉-/⟨⟩ b⇉b⋯b σ⇇Γ)
Nf⇉-/⟨⟩ (⇉-Π-i k-kd a⇉a⋯a) σ⇇Γ =
let k/σ-kd = kd-/⟨⟩ k-kd σ⇇Γ
in ⇉-Π-i k/σ-kd (Nf⇉-/⟨⟩ a⇉a⋯a (⇇-H↑ (≅-refl k/σ-kd) σ⇇Γ))
Nf⇉-/⟨⟩ (⇉-s-i a∈b⋯c) σ⇇Γ = Nf⇇-s-i (Ne∈-/⟨⟩ a∈b⋯c σ⇇Γ)
-- Neutral proper types kind-check against their synthesized kinds
-- after substitution.
Ne∈-/⟨⟩ : ∀ {k m n Γ Δ} {σ : SVSub m n} {a b c} →
Γ ⊢Ne a ∈ b ⋯ c → Δ ⊢/⟨ k ⟩ σ ⇇ Γ →
Δ ⊢Nf a /⟨ k ⟩ σ ⇇ b /⟨ k ⟩ σ ⋯ c /⟨ k ⟩ σ
Ne∈-/⟨⟩ (∈-∙ {x} x∈j j⇉as⇉b⋯c) σ⇇Γ =
let j-kds = kd-kds (Var∈-valid x∈j)
in Var∈-/⟨⟩-⇑-?∙∙ x∈j σ⇇Γ ≤-refl (Sp⇉-/⟨⟩ j-kds j⇉as⇉b⋯c σ⇇Γ)
Var∈-/⟨⟩-⇑-?∙∙ : ∀ {k m n Γ Δ} {σ : SVSub m n} {x j l as b c} →
Γ ⊢Var x ∈ j → Δ ⊢/⟨ k ⟩ σ ⇇ Γ →
Δ ⊢ kd j Asc/⟨ k ⟩ σ ≤ kd l → Δ ⊢ l ⇉∙ as ⇉ b ⋯ c →
Δ ⊢Nf lookupSV σ x ?∙∙⟨ k ⟩ as ⇇ b ⋯ c
Var∈-/⟨⟩-⇑-?∙∙ (⇉-var x _ Γ[x]≡kd-j) σ⇇Γ j/σ≤l l⇉as⇉b⋯c =
?⇇-⇑-?∙∙ (subst (_ ⊢?⟨ _ ⟩ _ ⇇_) (cong (_Asc/⟨ _ ⟩ _) Γ[x]≡kd-j)
(lookup-/⟨⟩≃ σ⇇Γ x))
j/σ≤l l⇉as⇉b⋯c
Var∈-/⟨⟩-⇑-?∙∙ (⇇-⇑ x∈j₁ j₁<∷j₂ j₂-kd) σ⇇Γ j₂/σ≤l l⇉as⇉b⋯c =
let j₁/σ≤j₂/σ = ≤-<∷ (<∷-/⟨⟩≃ j₁<∷j₂ σ⇇Γ) (kd-/⟨⟩ j₂-kd σ⇇Γ)
in Var∈-/⟨⟩-⇑-?∙∙ x∈j₁ σ⇇Γ (≤-trans j₁/σ≤j₂/σ j₂/σ≤l) l⇉as⇉b⋯c
-- Hereditary substitutions preserve synthesized kinds of spines.
Sp⇉-/⟨⟩ : ∀ {k m n Γ Δ} {σ : SVSub m n} {as j₁ j₂} →
⌊ Γ ⌋Ctx ⊢ j₁ kds → Γ ⊢ j₁ ⇉∙ as ⇉ j₂ → Δ ⊢/⟨ k ⟩ σ ⇇ Γ →
Δ ⊢ j₁ Kind/⟨ k ⟩ σ ⇉∙ as //⟨ k ⟩ σ ⇉ j₂ Kind/⟨ k ⟩ σ
Sp⇉-/⟨⟩ _ ⇉-[] σ⇇Γ = ⇉-[]
Sp⇉-/⟨⟩ {k} (kds-Π j₁-kds j₂-kds)
(⇉-∷ {a} {_} {j₁} {j₂} a⇇j₁ j₁-kd j₂[a]⇉as⇉j₃) σ⇇Γ =
⇉-∷ (Nf⇇-/⟨⟩ a⇇j₁ σ⇇Γ) (kd-/⟨⟩ j₁-kd σ⇇Γ)
(subst (_ ⊢_⇉∙ _ ⇉ _) j₂[a]/σ≡j₂/σ[a/σ]
(Sp⇉-/⟨⟩ (kds-/⟨⟩ j₂-kds (∈-hsub a∈⌊j₁⌋)) j₂[a]⇉as⇉j₃ σ⇇Γ))
where
a∈⌊j₁⌋ = Nf⇇-Nf∈ a⇇j₁
j₂[a]/σ≡j₂/σ[a/σ] = begin
j₂ Kind[ a ∈ ⌊ j₁ ⌋ ] Kind/⟨ k ⟩ _
≡⟨ kds-[]-/⟨⟩-↑⋆ [] j₂-kds a∈⌊j₁⌋ (/⟨⟩⇇-/⟨⟩∈ σ⇇Γ) ⟩
j₂ Kind/⟨ k ⟩ _ ↑ Kind/⟨ ⌊ j₁ ⌋ ⟩ sub (a /⟨ k ⟩ _)
≡⟨ cong (_ Kind[ a /⟨ k ⟩ _ ∈_]) (sym (⌊⌋-Kind/⟨⟩ j₁)) ⟩
(j₂ Kind/⟨ k ⟩ _ ↑) Kind[ a /⟨ k ⟩ _ ∈ ⌊ j₁ Kind/⟨ k ⟩ _ ⌋ ]
∎
-- Hereditary substitutions preserve checked kinds of normal
-- types.
Nf⇇-/⟨⟩ : ∀ {k m n Γ Δ} {σ : SVSub m n} {a j} →
Γ ⊢Nf a ⇇ j → Δ ⊢/⟨ k ⟩ σ ⇇ Γ → Δ ⊢Nf a /⟨ k ⟩ σ ⇇ j Kind/⟨ k ⟩ σ
Nf⇇-/⟨⟩ (⇇-⇑ a⇉j j<∷k) σ⇇Γ = ⇇-⇑ (Nf⇉-/⟨⟩ a⇉j σ⇇Γ) (<∷-/⟨⟩≃ j<∷k σ⇇Γ)
-- Equal hereditary substitutions well-formed kinds to subkinds.
kd-/⟨⟩≃-<∷ : ∀ {m n Γ k Δ} {σ τ : SVSub m n} {j} →
Γ ⊢ j kd → Δ ⊢/⟨ k ⟩ σ ≃ τ ⇇ Γ →
Δ ⊢ j Kind/⟨ k ⟩ σ <∷ j Kind/⟨ k ⟩ τ
kd-/⟨⟩≃-<∷ (kd-⋯ a⇉a⋯a b⇉b⋯b) σ≃τ⇇Γ =
<∷-⋯ (Nf⇉-⋯-/⟨⟩≃ a⇉a⋯a (/⟨⟩≃-sym σ≃τ⇇Γ)) (Nf⇉-⋯-/⟨⟩≃ b⇉b⋯b σ≃τ⇇Γ)
kd-/⟨⟩≃-<∷ (kd-Π j-kd k-kd) σ≃τ⇇Γ =
let σ⇇Γ = /⟨⟩≃-valid₁ σ≃τ⇇Γ
τ⇇Γ = /⟨⟩≃-valid₂ σ≃τ⇇Γ
τ≃σ⇇Γ = /⟨⟩≃-sym σ≃τ⇇Γ
j/σ≅j/σ = kd-/⟨⟩≃-≅ j-kd σ⇇Γ
j/τ≅j/τ = kd-/⟨⟩≃-≅ j-kd τ⇇Γ
j/τ≅j/σ = kd-/⟨⟩≃-≅ j-kd τ≃σ⇇Γ
in <∷-Π (kd-/⟨⟩≃-<∷ j-kd τ≃σ⇇Γ)
(kd-/⟨⟩≃-<∷ k-kd (≃-H↑ j/τ≅j/σ j/τ≅j/τ σ≃τ⇇Γ))
(kd-Π (kd-/⟨⟩ j-kd σ⇇Γ) (kd-/⟨⟩ k-kd (⇇-H↑ j/σ≅j/σ σ⇇Γ)))
-- Equal hereditary substitutions map well-formed kinds to kind
-- identities.
kd-/⟨⟩≃-≅ : ∀ {m n Γ k Δ} {σ τ : SVSub m n} {j} →
Γ ⊢ j kd → Δ ⊢/⟨ k ⟩ σ ≃ τ ⇇ Γ →
Δ ⊢ j Kind/⟨ k ⟩ σ ≅ j Kind/⟨ k ⟩ τ
kd-/⟨⟩≃-≅ k-kd σ≃τ⇇Γ =
<∷-antisym (kd-/⟨⟩ k-kd (/⟨⟩≃-valid₁ σ≃τ⇇Γ))
(kd-/⟨⟩ k-kd (/⟨⟩≃-valid₂ σ≃τ⇇Γ))
(kd-/⟨⟩≃-<∷ k-kd σ≃τ⇇Γ) (kd-/⟨⟩≃-<∷ k-kd (/⟨⟩≃-sym σ≃τ⇇Γ))
-- Equal hereditary substitutions map normal forms to subtypes.
Nf⇉-⋯-/⟨⟩≃ : ∀ {k m n Γ Δ} {σ τ : SVSub m n} {a b c} →
Γ ⊢Nf a ⇉ b ⋯ c → Δ ⊢/⟨ k ⟩ σ ≃ τ ⇇ Γ →
Δ ⊢ a /⟨ k ⟩ σ <: a /⟨ k ⟩ τ
Nf⇉-⋯-/⟨⟩≃ (⇉-⊥-f Γ-ctx) σ≃τ⇇Γ =
<:-⊥ (⇉-⊥-f (/⟨⟩≃-ctx Γ-ctx (/⟨⟩≃-valid₁ σ≃τ⇇Γ)))
Nf⇉-⋯-/⟨⟩≃ (⇉-⊤-f Γ-ctx) σ≃τ⇇Γ =
<:-⊤ (⇉-⊤-f (/⟨⟩≃-ctx Γ-ctx (/⟨⟩≃-valid₂ σ≃τ⇇Γ)))
Nf⇉-⋯-/⟨⟩≃ (⇉-∀-f k-kd a⇉a⋯a) σ≃τ⇇Γ =
let σ⇇Γ = /⟨⟩≃-valid₁ σ≃τ⇇Γ
τ⇇Γ = /⟨⟩≃-valid₂ σ≃τ⇇Γ
τ≃σ⇇Γ = /⟨⟩≃-sym σ≃τ⇇Γ
k/τ≅k/τ = kd-/⟨⟩≃-≅ k-kd τ⇇Γ
k/σ≅k/σ = kd-/⟨⟩≃-≅ k-kd σ⇇Γ
k/τ≅k/σ = kd-/⟨⟩≃-≅ k-kd τ≃σ⇇Γ
σ≃τ⇇j/τ∷Γ = ≃-H↑ k/τ≅k/σ k/τ≅k/τ σ≃τ⇇Γ
in <:-∀ (≅⇒<∷ k/τ≅k/σ) (Nf⇉-⋯-/⟨⟩≃ a⇉a⋯a σ≃τ⇇j/τ∷Γ)
(⇉-∀-f (kd-/⟨⟩ k-kd σ⇇Γ)
(Nf⇉-/⟨⟩ a⇉a⋯a (⇇-H↑ k/σ≅k/σ σ⇇Γ)))
Nf⇉-⋯-/⟨⟩≃ (⇉-→-f a⇉a⋯a b⇉b⋯b) σ≃τ⇇Γ =
<:-→ (Nf⇉-⋯-/⟨⟩≃ a⇉a⋯a (/⟨⟩≃-sym σ≃τ⇇Γ)) (Nf⇉-⋯-/⟨⟩≃ b⇉b⋯b σ≃τ⇇Γ)
Nf⇉-⋯-/⟨⟩≃ (⇉-s-i a∈b⋯c) σ≃τ⇇Γ = Ne∈-/⟨⟩≃ a∈b⋯c σ≃τ⇇Γ
Nf⇉-/⟨⟩≃ : ∀ {k m n Γ Δ} {σ τ : SVSub m n} {a j} →
Γ ⊢Nf a ⇉ j → Γ ⊢ j kd → Δ ⊢/⟨ k ⟩ σ ≃ τ ⇇ Γ →
Δ ⊢ a /⟨ k ⟩ σ <: a /⟨ k ⟩ τ ⇇ j Kind/⟨ k ⟩ σ
Nf⇉-/⟨⟩≃ a⇉b⋯c (kd-⋯ b⇉b⋯b c⇉c⋯c) σ≃τ⇇Γ =
let σ⇇Γ = /⟨⟩≃-valid₁ σ≃τ⇇Γ
τ⇇Γ = /⟨⟩≃-valid₂ σ≃τ⇇Γ
τ≃σ⇇Γ = /⟨⟩≃-sym σ≃τ⇇Γ
in <:-⇇ (Nf⇉⇒Nf⇇ (Nf⇉-/⟨⟩ a⇉b⋯c σ⇇Γ))
(⇇-⇑ (Nf⇉-/⟨⟩ a⇉b⋯c τ⇇Γ)
(<∷-⋯ (Nf⇉-⋯-/⟨⟩≃ b⇉b⋯b σ≃τ⇇Γ) (Nf⇉-⋯-/⟨⟩≃ c⇉c⋯c τ≃σ⇇Γ)))
(Nf⇉-⋯-/⟨⟩≃ a⇉b⋯c σ≃τ⇇Γ)
Nf⇉-/⟨⟩≃ (⇉-Π-i _ a⇉l) (kd-Π j-kd l-kd) σ≃τ⇇Γ =
let τ≃σ⇇Γ = /⟨⟩≃-sym σ≃τ⇇Γ
σ⇇Γ = /⟨⟩≃-valid₁ σ≃τ⇇Γ
τ⇇Γ = /⟨⟩≃-valid₂ σ≃τ⇇Γ
j/σ-kd = kd-/⟨⟩ j-kd σ⇇Γ
j/τ-kd = kd-/⟨⟩ j-kd τ⇇Γ
j/σ≅j/σ = kd-/⟨⟩≃-≅ j-kd σ⇇Γ
j/τ≅j/τ = kd-/⟨⟩≃-≅ j-kd τ⇇Γ
j/σ≅j/τ = kd-/⟨⟩≃-≅ j-kd σ≃τ⇇Γ
a/σ⇉l/σ = Nf⇉-/⟨⟩ a⇉l (⇇-H↑ j/σ≅j/σ σ⇇Γ)
a/τ⇉l/τ = Nf⇉-/⟨⟩ a⇉l (⇇-H↑ j/τ≅j/τ τ⇇Γ)
a/σ<:a/τ⇇l/σ = Nf⇉-/⟨⟩≃ a⇉l l-kd (≃-H↑ j/σ≅j/σ j/σ≅j/τ σ≃τ⇇Γ)
Πjl/τ<∷Πjl/σ = kd-/⟨⟩≃-<∷ (kd-Π j-kd l-kd) τ≃σ⇇Γ
Λja/σ⇇Πjl/σ = Nf⇉⇒Nf⇇ (⇉-Π-i j/σ-kd a/σ⇉l/σ)
Λja/τ⇇Πjl/σ = ⇇-⇑ (⇉-Π-i j/τ-kd a/τ⇉l/τ) Πjl/τ<∷Πjl/σ
in <:-λ a/σ<:a/τ⇇l/σ Λja/σ⇇Πjl/σ Λja/τ⇇Πjl/σ
-- Equal hereditary substitutions map proper neutrals to subtypes.
Ne∈-/⟨⟩≃ : ∀ {k m n Γ Δ} {σ τ : SVSub m n} {a b c} →
Γ ⊢Ne a ∈ b ⋯ c → Δ ⊢/⟨ k ⟩ σ ≃ τ ⇇ Γ →
Δ ⊢ a /⟨ k ⟩ σ <: a /⟨ k ⟩ τ
Ne∈-/⟨⟩≃ (∈-∙ {x} x∈j j⇉as⇉b⋯c) σ≃τ⇇Γ =
let j-kds = kd-kds (Var∈-valid x∈j)
in Var∈-/⟨⟩≃-⇑-?∙∙ x∈j σ≃τ⇇Γ ≤-refl (Sp⇉-/⟨⟩≃ j-kds j⇉as⇉b⋯c σ≃τ⇇Γ)
Var∈-/⟨⟩≃-⇑-?∙∙ : ∀ {k m n Γ Δ} {σ τ : SVSub m n} {x j l as bs b c} →
Γ ⊢Var x ∈ j → Δ ⊢/⟨ k ⟩ σ ≃ τ ⇇ Γ →
Δ ⊢ kd j Asc/⟨ k ⟩ σ ≤ kd l → Δ ⊢ l ⇉∙ as ≃ bs ⇉ b ⋯ c →
Δ ⊢ lookupSV σ x ?∙∙⟨ k ⟩ as <: lookupSV τ x ?∙∙⟨ k ⟩ bs
Var∈-/⟨⟩≃-⇑-?∙∙ (⇉-var x _ Γ[x]≡kd-j) σ≃τ⇇Γ j/σ≤l l⇉as≃bs⇉b⋯c =
?≃-⇑-?∙∙ (subst (_ ⊢?⟨ _ ⟩ _ ≃ _ ⇇_) (cong (_Asc/⟨ _ ⟩ _) Γ[x]≡kd-j)
(lookup-/⟨⟩≃ σ≃τ⇇Γ x))
j/σ≤l l⇉as≃bs⇉b⋯c
Var∈-/⟨⟩≃-⇑-?∙∙ (⇇-⇑ x∈j₁ j₁<∷j₂ j₂-kd) σ≃τ⇇Γ j₂/σ≤l l⇉as≃bs⇉b⋯c =
let σ⇇Γ = /⟨⟩≃-valid₁ σ≃τ⇇Γ
j₁/σ≤j₂/σ = ≤-<∷ (<∷-/⟨⟩≃ j₁<∷j₂ σ⇇Γ) (kd-/⟨⟩ j₂-kd σ⇇Γ)
in Var∈-/⟨⟩≃-⇑-?∙∙ x∈j₁ σ≃τ⇇Γ (≤-trans j₁/σ≤j₂/σ j₂/σ≤l) l⇉as≃bs⇉b⋯c
-- Equal hereditary substitutions map spines to spine identities.
Sp⇉-/⟨⟩≃ : ∀ {k m n Γ Δ} {σ τ : SVSub m n} {as j₁ j₂} →
⌊ Γ ⌋Ctx ⊢ j₁ kds → Γ ⊢ j₁ ⇉∙ as ⇉ j₂ → Δ ⊢/⟨ k ⟩ σ ≃ τ ⇇ Γ →
Δ ⊢ j₁ Kind/⟨ k ⟩ σ ⇉∙ as //⟨ k ⟩ σ ≃
as //⟨ k ⟩ τ ⇉ j₂ Kind/⟨ k ⟩ σ
Sp⇉-/⟨⟩≃ _ ⇉-[] σ⇇Γ = ≃-[]
Sp⇉-/⟨⟩≃ {k} (kds-Π j₁-kds j₂-kds)
(⇉-∷ {a} {_} {j₁} {j₂} a⇇j₁ j₁-kd j₂[a]⇉as⇉j₃) σ⇇Γ =
≃-∷ (Nf⇇-/⟨⟩≃-≃ a⇇j₁ j₁-kd σ⇇Γ)
(subst (_ ⊢_⇉∙ _ ≃ _ ⇉ _) j₂[a]/σ≡j₂/σ[a/σ]
(Sp⇉-/⟨⟩≃ (kds-/⟨⟩ j₂-kds (∈-hsub a∈⌊j₁⌋)) j₂[a]⇉as⇉j₃ σ⇇Γ))
where
a∈⌊j₁⌋ = Nf⇇-Nf∈ a⇇j₁
j₂[a]/σ≡j₂/σ[a/σ] = begin
j₂ Kind[ a ∈ ⌊ j₁ ⌋ ] Kind/⟨ k ⟩ _
≡⟨ kds-[]-/⟨⟩-↑⋆ [] j₂-kds a∈⌊j₁⌋ (/⟨⟩⇇-/⟨⟩∈ (/⟨⟩≃-valid₁ σ⇇Γ)) ⟩
j₂ Kind/⟨ k ⟩ _ ↑ Kind/⟨ ⌊ j₁ ⌋ ⟩ sub (a /⟨ k ⟩ _)
≡⟨ cong (_ Kind[ a /⟨ k ⟩ _ ∈_]) (sym (⌊⌋-Kind/⟨⟩ j₁)) ⟩
(j₂ Kind/⟨ k ⟩ _ ↑) Kind[ a /⟨ k ⟩ _ ∈ ⌊ j₁ Kind/⟨ k ⟩ _ ⌋ ]
∎
-- Equal hereditary substitutions map checked normal forms to
-- subtypes.
Nf⇇-/⟨⟩≃-<: : ∀ {k m n Γ Δ} {σ τ : SVSub m n} {a j} →
Γ ⊢Nf a ⇇ j → Γ ⊢ j kd → Δ ⊢/⟨ k ⟩ σ ≃ τ ⇇ Γ →
Δ ⊢ a /⟨ k ⟩ σ <: a /⟨ k ⟩ τ ⇇ j Kind/⟨ k ⟩ σ
Nf⇇-/⟨⟩≃-<: (⇇-⇑ a⇉b₁⋯c₁ (<∷-⋯ b₂<:b₁ c₁<:c₂)) _ σ≃τ⇇Γ =
let σ⇇Γ = /⟨⟩≃-valid₁ σ≃τ⇇Γ
τ⇇Γ = /⟨⟩≃-valid₂ σ≃τ⇇Γ
τ≃σ⇇Γ = /⟨⟩≃-sym σ≃τ⇇Γ
in <:-⇇ (⇇-⇑ (Nf⇉-/⟨⟩ a⇉b₁⋯c₁ σ⇇Γ) (<∷-/⟨⟩≃ (<∷-⋯ b₂<:b₁ c₁<:c₂) σ⇇Γ))
(⇇-⇑ (Nf⇉-/⟨⟩ a⇉b₁⋯c₁ τ⇇Γ) (<∷-/⟨⟩≃ (<∷-⋯ b₂<:b₁ c₁<:c₂) τ≃σ⇇Γ))
(Nf⇉-⋯-/⟨⟩≃ a⇉b₁⋯c₁ σ≃τ⇇Γ)
Nf⇇-/⟨⟩≃-<: (⇇-⇑ a⇉Πj₁l₁ (<∷-Π j₂<∷j₁ l₁<∷l₂ Πj₁l₁-kd)) Πj₂k₂-kd σ≃τ⇇Γ =
let σ⇇Γ = /⟨⟩≃-valid₁ σ≃τ⇇Γ
Πj₁l₁/σ<∷Πj₂l₂/σ = <∷-/⟨⟩≃ (<∷-Π j₂<∷j₁ l₁<∷l₂ Πj₁l₁-kd) σ⇇Γ
Πj₂l₂/σ-kd = kd-/⟨⟩ Πj₂k₂-kd σ⇇Γ
in <:⇇-⇑ (Nf⇉-/⟨⟩≃ a⇉Πj₁l₁ Πj₁l₁-kd σ≃τ⇇Γ) Πj₁l₁/σ<∷Πj₂l₂/σ Πj₂l₂/σ-kd
-- Equal hereditary substitutions map checked normal forms to type
-- identities.
Nf⇇-/⟨⟩≃-≃ : ∀ {m n Γ k Δ} {σ τ : SVSub m n} {a j} →
Γ ⊢Nf a ⇇ j → Γ ⊢ j kd → Δ ⊢/⟨ k ⟩ σ ≃ τ ⇇ Γ →
Δ ⊢ a /⟨ k ⟩ σ ≃ a /⟨ k ⟩ τ ⇇ j Kind/⟨ k ⟩ σ
Nf⇇-/⟨⟩≃-≃ a⇇k k-kd σ≃τ⇇Γ =
let τ≃σ⇇Γ = /⟨⟩≃-sym σ≃τ⇇Γ
k/σ-kd = kd-/⟨⟩ k-kd (/⟨⟩≃-valid₁ σ≃τ⇇Γ)
in <:-antisym k/σ-kd (Nf⇇-/⟨⟩≃-<: a⇇k k-kd σ≃τ⇇Γ)
(<:⇇-⇑ (Nf⇇-/⟨⟩≃-<: a⇇k k-kd τ≃σ⇇Γ)
(kd-/⟨⟩≃-<∷ k-kd τ≃σ⇇Γ) k/σ-kd)
-- Equal hereditary substitutions preserve subkinding.
<∷-/⟨⟩≃ : ∀ {k m n Γ Δ} {σ τ : SVSub m n} {j₁ j₂} →
Γ ⊢ j₁ <∷ j₂ → Δ ⊢/⟨ k ⟩ σ ≃ τ ⇇ Γ →
Δ ⊢ j₁ Kind/⟨ k ⟩ σ <∷ j₂ Kind/⟨ k ⟩ τ
<∷-/⟨⟩≃ (<∷-⋯ a₂<:a₁ b₁<:b₂) σ≃τ⇇Γ =
<∷-⋯ (<:-/⟨⟩≃ a₂<:a₁ (/⟨⟩≃-sym σ≃τ⇇Γ)) (<:-/⟨⟩≃ b₁<:b₂ σ≃τ⇇Γ)
<∷-/⟨⟩≃ (<∷-Π j₂<∷j₁ k₁<∷k₂ Πj₁k₁-kd) σ≃τ⇇Γ =
let τ≃σ⇇Γ = /⟨⟩≃-sym σ≃τ⇇Γ
τ≃τ⇇Γ = /⟨⟩≃-valid₂ σ≃τ⇇Γ
in <∷-Π (<∷-/⟨⟩≃ j₂<∷j₁ (/⟨⟩≃-sym σ≃τ⇇Γ))
(<∷-/⟨⟩≃ k₁<∷k₂ (≃-H↑ (<∷-/⟨⟩≃-wf k₁<∷k₂ τ≃σ⇇Γ)
(<∷-/⟨⟩≃-wf k₁<∷k₂ τ≃τ⇇Γ) σ≃τ⇇Γ))
(kd-/⟨⟩ Πj₁k₁-kd (/⟨⟩≃-valid₁ σ≃τ⇇Γ))
-- Equal hereditary substitutions preserve subtyping.
<:-/⟨⟩≃ : ∀ {k m n Γ Δ} {σ τ : SVSub m n} {a₁ a₂} →
Γ ⊢ a₁ <: a₂ → Δ ⊢/⟨ k ⟩ σ ≃ τ ⇇ Γ →
Δ ⊢ a₁ /⟨ k ⟩ σ <: a₂ /⟨ k ⟩ τ
<:-/⟨⟩≃ (<:-trans a<:b b<:c) σ≃τ⇇Γ =
<:-trans (<:-/⟨⟩≃ a<:b (/⟨⟩≃-valid₁ σ≃τ⇇Γ)) (<:-/⟨⟩≃ b<:c σ≃τ⇇Γ)
<:-/⟨⟩≃ (<:-⊥ a⇉a⋯a) σ≃τ⇇Γ = <:-⊥ (Nf⇉-/⟨⟩ a⇉a⋯a (/⟨⟩≃-valid₂ σ≃τ⇇Γ))
<:-/⟨⟩≃ (<:-⊤ a⇉a⋯a) σ≃τ⇇Γ = <:-⊤ (Nf⇉-/⟨⟩ a⇉a⋯a (/⟨⟩≃-valid₁ σ≃τ⇇Γ))
<:-/⟨⟩≃ (<:-∀ k₂<∷k₁ a₁<:a₂ Πk₁a₁⇉Πk₁a₁⋯Πk₁a₁) σ≃τ⇇Γ =
let τ≃σ⇇Γ = /⟨⟩≃-sym σ≃τ⇇Γ
τ≃τ⇇Γ = /⟨⟩≃-valid₂ σ≃τ⇇Γ
in <:-∀ (<∷-/⟨⟩≃ k₂<∷k₁ τ≃σ⇇Γ)
(<:-/⟨⟩≃ a₁<:a₂ (≃-H↑ (<:-/⟨⟩≃-wf a₁<:a₂ τ≃σ⇇Γ)
(<:-/⟨⟩≃-wf a₁<:a₂ τ≃τ⇇Γ) σ≃τ⇇Γ))
(Nf⇉-/⟨⟩ Πk₁a₁⇉Πk₁a₁⋯Πk₁a₁ (/⟨⟩≃-valid₁ σ≃τ⇇Γ))
<:-/⟨⟩≃ (<:-→ a₂<:a₁ b₁<:b₂) σ≃τ⇇Γ =
<:-→ (<:-/⟨⟩≃ a₂<:a₁ (/⟨⟩≃-sym σ≃τ⇇Γ)) (<:-/⟨⟩≃ b₁<:b₂ σ≃τ⇇Γ)
<:-/⟨⟩≃ {σ = σ} (<:-∙ {x} x∈j j⇉as≃bs⇉c⋯d) σ≃τ⇇Γ =
let j-kds = kd-kds (Var∈-valid x∈j)
in Var∈-/⟨⟩≃-⇑-?∙∙ x∈j σ≃τ⇇Γ ≤-refl (Sp≃-/⟨⟩≃ j-kds j⇉as≃bs⇉c⋯d σ≃τ⇇Γ)
<:-/⟨⟩≃ (<:-⟨| a∈b⋯c) σ≃τ⇇Γ =
let a/σ⇉b/σ⋯c/σ = Ne∈-/⟨⟩ a∈b⋯c (/⟨⟩≃-valid₁ σ≃τ⇇Γ)
in <:-trans (<:-⟨|-Nf⇇ a/σ⇉b/σ⋯c/σ) (Ne∈-/⟨⟩≃ a∈b⋯c σ≃τ⇇Γ)
<:-/⟨⟩≃ (<:-|⟩ a∈b⋯c) σ≃τ⇇Γ =
let a/τ⇉b/τ⋯c/τ = Ne∈-/⟨⟩ a∈b⋯c (/⟨⟩≃-valid₂ σ≃τ⇇Γ)
in <:-trans (Ne∈-/⟨⟩≃ a∈b⋯c σ≃τ⇇Γ) (<:-|⟩-Nf⇇ a/τ⇉b/τ⋯c/τ)
<:⇇-/⟨⟩≃ : ∀ {k m n Γ Δ} {σ τ : SVSub m n} {a₁ a₂ j} →
Γ ⊢ a₁ <: a₂ ⇇ j → Γ ⊢ j kd → Δ ⊢/⟨ k ⟩ σ ≃ τ ⇇ Γ →
Δ ⊢ a₁ /⟨ k ⟩ σ <: a₂ /⟨ k ⟩ τ ⇇ j Kind/⟨ k ⟩ σ
<:⇇-/⟨⟩≃ (<:-⇇ a₁⇇b⋯c a₂⇇b⋯c a₁<:a₂) b⋯c-kd σ≃τ⇇Γ =
let σ⇇Γ = /⟨⟩≃-valid₁ σ≃τ⇇Γ
τ⇇Γ = /⟨⟩≃-valid₂ σ≃τ⇇Γ
τ≃σ⇇Γ = /⟨⟩≃-sym σ≃τ⇇Γ
in <:-⇇ (Nf⇇-/⟨⟩ a₁⇇b⋯c σ⇇Γ)
(Nf⇇-⇑ (Nf⇇-/⟨⟩ a₂⇇b⋯c τ⇇Γ) (kd-/⟨⟩≃-<∷ b⋯c-kd τ≃σ⇇Γ))
(<:-/⟨⟩≃ a₁<:a₂ σ≃τ⇇Γ)
<:⇇-/⟨⟩≃ (<:-λ a₁<:a₂⇇l Λj₁a₁⇇Πjl Λj₂a₂⇇Πjl) (kd-Π j-kd l-kd) σ≃τ⇇Γ =
let σ⇇Γ = /⟨⟩≃-valid₁ σ≃τ⇇Γ
τ⇇Γ = /⟨⟩≃-valid₂ σ≃τ⇇Γ
τ≃σ⇇Γ = /⟨⟩≃-sym σ≃τ⇇Γ
j/σ≅j/σ = kd-/⟨⟩≃-≅ j-kd σ⇇Γ
j/σ≅j/τ = kd-/⟨⟩≃-≅ j-kd σ≃τ⇇Γ
in <:-λ (<:⇇-/⟨⟩≃ a₁<:a₂⇇l l-kd (≃-H↑ j/σ≅j/σ j/σ≅j/τ σ≃τ⇇Γ))
(Nf⇇-/⟨⟩ Λj₁a₁⇇Πjl σ⇇Γ)
(Nf⇇-⇑ (Nf⇇-/⟨⟩ Λj₂a₂⇇Πjl τ⇇Γ) (kd-/⟨⟩≃-<∷ (kd-Π j-kd l-kd) τ≃σ⇇Γ))
-- Equal hereditary substitutions preserve spine equality.
Sp≃-/⟨⟩≃ : ∀ {k m n Γ Δ} {σ τ : SVSub m n} {as₁ as₂ j₁ j₂} →
⌊ Γ ⌋Ctx ⊢ j₁ kds →
Γ ⊢ j₁ ⇉∙ as₁ ≃ as₂ ⇉ j₂ → Δ ⊢/⟨ k ⟩ σ ≃ τ ⇇ Γ →
Δ ⊢ j₁ Kind/⟨ k ⟩ σ ⇉∙ as₁ //⟨ k ⟩ σ ≃
as₂ //⟨ k ⟩ τ ⇉ j₂ Kind/⟨ k ⟩ σ
Sp≃-/⟨⟩≃ _ ≃-[] σ≃τ⇇Γ = ≃-[]
Sp≃-/⟨⟩≃ {k} (kds-Π j₁-kds j₂-kds)
(≃-∷ {a} {j = j₁} {j₂} a≃b as≃bs) σ≃τ⇇Γ =
let a∈⌊j₁⌋ = Nf⇇-Nf∈ (proj₁ (≃-valid a≃b))
j₂[a]/σ≡j₂/σ[a/σ] = begin
j₂ Kind[ a ∈ ⌊ j₁ ⌋ ] Kind/⟨ k ⟩ _
≡⟨ kds-[]-/⟨⟩-↑⋆ [] j₂-kds a∈⌊j₁⌋ (/⟨⟩⇇-/⟨⟩∈ (/⟨⟩≃-valid₁ σ≃τ⇇Γ)) ⟩
j₂ Kind/⟨ k ⟩ _ ↑ Kind/⟨ ⌊ j₁ ⌋ ⟩ sub (a /⟨ k ⟩ _)
≡⟨ cong (_ Kind[ a /⟨ k ⟩ _ ∈_]) (sym (⌊⌋-Kind/⟨⟩ j₁)) ⟩
(j₂ Kind/⟨ k ⟩ _ ↑) Kind[ a /⟨ k ⟩ _ ∈ ⌊ j₁ Kind/⟨ k ⟩ _ ⌋ ]
∎
in ≃-∷ (≃-/⟨⟩≃ a≃b σ≃τ⇇Γ)
(subst (_ ⊢_⇉∙ _ ≃ _ ⇉ _) j₂[a]/σ≡j₂/σ[a/σ]
(Sp≃-/⟨⟩≃ (kds-/⟨⟩ j₂-kds (∈-hsub a∈⌊j₁⌋)) as≃bs σ≃τ⇇Γ))
-- Equal hereditary substitutions preserve type equality.
≃-/⟨⟩≃ : ∀ {k m n Γ Δ} {σ τ : SVSub m n} {a₁ a₂ j} →
Γ ⊢ a₁ ≃ a₂ ⇇ j → Δ ⊢/⟨ k ⟩ σ ≃ τ ⇇ Γ →
Δ ⊢ a₁ /⟨ k ⟩ σ ≃ a₂ /⟨ k ⟩ τ ⇇ j Kind/⟨ k ⟩ σ
≃-/⟨⟩≃ (<:-antisym k-kd a<:b⇇k b<:a⇇k) σ≃τ⇇Γ =
let τ≃σ⇇Γ = /⟨⟩≃-sym σ≃τ⇇Γ
k/σ-kd = kd-/⟨⟩ k-kd (/⟨⟩≃-valid₁ σ≃τ⇇Γ)
in <:-antisym k/σ-kd (<:⇇-/⟨⟩≃ a<:b⇇k k-kd σ≃τ⇇Γ)
(<:⇇-⇑ (<:⇇-/⟨⟩≃ b<:a⇇k k-kd τ≃σ⇇Γ)
(kd-/⟨⟩≃-<∷ k-kd τ≃σ⇇Γ) k/σ-kd)
-- Applications in canonical kind checking are admissible.
--
-- NOTE. In the ?⇇-⇑-?∙∙ lemma, the second result r₂ is ignored.
-- See the comment above on /⟨⟩⇇-/⟨⟩∈ for an explanation.
?⇇-⇑-?∙∙ : ∀ {k n} {Γ : Ctx n} {r₁ r₂ a j as b c} →
Γ ⊢?⟨ k ⟩ r₁ ≃ r₂ ⇇ a → Γ ⊢ a ≤ kd j →
Γ ⊢ j ⇉∙ as ⇉ b ⋯ c → Γ ⊢Nf r₁ ?∙∙⟨ k ⟩ as ⇇ b ⋯ c
?⇇-⇑-?∙∙ (≃-hit a≃a⇇j ⌊j⌋≡k) j≤l l⇉as⇉b⋯c =
Nf⇇-∙∙ (Nf⇇-⇑-≤ (proj₁ (≃-valid a≃a⇇j)) j≤l) l⇉as⇉b⋯c
(⌊⌋≡-trans (sym (≤-⌊⌋ j≤l)) ⌊j⌋≡k)
?⇇-⇑-?∙∙ (≃-miss y Γ-ctx Γ[y]≡a₁ a₁≤a₂) a₂≤l l⇉as⇉b⋯c =
Nf⇇-ne (∈-∙ (Var∈-⇑-≤ y Γ-ctx Γ[y]≡a₁ (≤-trans a₁≤a₂ a₂≤l)) l⇉as⇉b⋯c)
Nf⇇-∙∙ : ∀ {n} {Γ : Ctx n} {a as j₁ j₂ k} →
Γ ⊢Nf a ⇇ j₁ → Γ ⊢ j₁ ⇉∙ as ⇉ j₂ → ⌊ j₁ ⌋≡ k →
Γ ⊢Nf a ∙∙⟨ k ⟩ as ⇇ j₂
Nf⇇-∙∙ a⇇j₁ ⇉-[] ⌊j₁⌋≡k = a⇇j₁
Nf⇇-∙∙ a⇇Πj₁j₂ (⇉-∷ b⇇j₁ j₁-kd j₂[b]⇉as⇉j₃) (is-⇒ ⌊j₁⌋≡k₁ ⌊j₂⌋≡k₂) =
Nf⇇-∙∙ (Nf⇇-Π-e a⇇Πj₁j₂ b⇇j₁ j₁-kd (is-⇒ ⌊j₁⌋≡k₁ ⌊j₂⌋≡k₂))
j₂[b]⇉as⇉j₃ (⌊⌋≡-/⟨⟩ ⌊j₂⌋≡k₂)
Nf⇇-Π-e : ∀ {n} {Γ : Ctx n} {a b j₁ j₂ k} →
Γ ⊢Nf a ⇇ Π j₁ j₂ → Γ ⊢Nf b ⇇ j₁ → Γ ⊢ j₁ kd →
⌊ Π j₁ j₂ ⌋≡ k → Γ ⊢Nf a ⌜·⌝⟨ k ⟩ b ⇇ j₂ Kind[ b ∈ ⌊ j₁ ⌋ ]
Nf⇇-Π-e {_} {Γ} {_} {b}
(⇇-⇑ (⇉-Π-i j₁-kd a⇉l₁)
(<∷-Π {j₁} {j₂} {l₁} {l₂} j₂<∷j₁ l₁<∷l₂ Πj₁l₁-kd))
b⇇j₂ j₂-kd (is-⇒ {_} {_} {k₁} ⌊j₂⌋≡k₁ ⌊l₂⌋≡k₂) =
let σ⇇j₂∷Γ = ⇇-hsub b⇇j₂ j₂-kd ⌊j₂⌋≡k₁
in ⇇-⇑ (Nf⇉-/⟨⟩ (⇓-Nf⇉ j₂-kd j₂<∷j₁ a⇉l₁) σ⇇j₂∷Γ)
(subst (λ k → Γ ⊢ l₁ Kind[ b ∈ k₁ ] <∷ l₂ Kind[ b ∈ k ])
(sym (⌊⌋≡⇒⌊⌋-≡ ⌊j₂⌋≡k₁))
(<∷-/⟨⟩≃ l₁<∷l₂ σ⇇j₂∷Γ))
-- Applications in checked type equality are admissible.
?≃-⇑-?∙∙ : ∀ {k n} {Γ : Ctx n} {r₁ r₂ a j as bs c d} →
Γ ⊢?⟨ k ⟩ r₁ ≃ r₂ ⇇ a → Γ ⊢ a ≤ kd j →
Γ ⊢ j ⇉∙ as ≃ bs ⇉ c ⋯ d →
Γ ⊢ r₁ ?∙∙⟨ k ⟩ as <: r₂ ?∙∙⟨ k ⟩ bs
?≃-⇑-?∙∙ (≃-hit a≃b⇇j ⌊j⌋≡k) j≤l l⇉as≃bs⇉c⋯d =
≃⇒<:-⋯ (≃-∙∙ (≃-⇑-≤ a≃b⇇j j≤l) l⇉as≃bs⇉c⋯d
(⌊⌋≡-trans (sym (≤-⌊⌋ j≤l)) ⌊j⌋≡k))
?≃-⇑-?∙∙ (≃-miss y Γ-ctx Γ[y]≡a₁ a₁≤a₂) a₂≤l l⇉as≃bs⇉c⋯d =
<:-∙ (Var∈-⇑-≤ y Γ-ctx Γ[y]≡a₁ (≤-trans a₁≤a₂ a₂≤l)) l⇉as≃bs⇉c⋯d
≃-∙∙ : ∀ {n} {Γ : Ctx n} {a b as bs j₁ j₂ k} →
Γ ⊢ a ≃ b ⇇ j₁ → Γ ⊢ j₁ ⇉∙ as ≃ bs ⇉ j₂ → ⌊ j₁ ⌋≡ k →
Γ ⊢ a ∙∙⟨ k ⟩ as ≃ b ∙∙⟨ k ⟩ bs ⇇ j₂
≃-∙∙ a≃b⇇j₁ ≃-[] ⌊j₁⌋≡k = a≃b⇇j₁
≃-∙∙ a≃b⇇Πj₁j₂ (≃-∷ c≃d⇇j₁ j₂[b]⇉cs≃ds⇉j₃) (is-⇒ ⌊j₁⌋≡k₁ ⌊j₂⌋≡k₂) =
≃-∙∙ (≃-Π-e a≃b⇇Πj₁j₂ c≃d⇇j₁ (is-⇒ ⌊j₁⌋≡k₁ ⌊j₂⌋≡k₂))
j₂[b]⇉cs≃ds⇉j₃ (⌊⌋≡-/⟨⟩ ⌊j₂⌋≡k₂)
≃-Π-e : ∀ {n} {Γ : Ctx n} {a₁ a₂ b₁ b₂ j₁ j₂ k} →
Γ ⊢ a₁ ≃ a₂ ⇇ Π j₁ j₂ → Γ ⊢ b₁ ≃ b₂ ⇇ j₁ → ⌊ Π j₁ j₂ ⌋≡ k →
Γ ⊢ a₁ ⌜·⌝⟨ k ⟩ b₁ ≃ a₂ ⌜·⌝⟨ k ⟩ b₂ ⇇ j₂ Kind[ b₁ ∈ ⌊ j₁ ⌋ ]
≃-Π-e a₁≃a₂⇇Πj₁j₂ b₁≃b₂⇇j₂ (is-⇒ ⌊j₂⌋≡k₁ ⌊j₂⌋≡k₂) with ≃-Π-can a₁≃a₂⇇Πj₁j₂
≃-Π-e {_} {Γ} {_} {_} {b₁} {b₂} Λl₁a₁≃Λl₂a₂⇇Πj₁j₂ b₁≃b₂⇇j₁
(is-⇒ ⌊j₁⌋≡k₁ ⌊j₂⌋≡k₂)
| l₁ , a₁ , l₂ , a₂ , Λl₁a₁⇇Πj₁j₂ , Λl₂a₂⇇Πj₁j₂ , kd-Π j₁-kd j₂-kd ,
j₁<∷l₁ , l₁≅l₂ , a₁<:a₂⇇j₂ , a₂<:a₁⇇j₂ , refl , refl =
let ⌊Πj₁j₂⌋≡k = is-⇒ ⌊j₁⌋≡k₁ ⌊j₂⌋≡k₂
k₁≡⌊j₁⌋ = sym (⌊⌋≡⇒⌊⌋-≡ ⌊j₁⌋≡k₁)
b₁⇇j₁ , b₂⇇j₁ = ≃-valid b₁≃b₂⇇j₁
σ≃τ⇇j₁∷Γ = ≃-hsub b₁≃b₂⇇j₁ ⌊j₁⌋≡k₁
τ≃σ⇇j₁∷Γ = /⟨⟩≃-sym σ≃τ⇇j₁∷Γ
σ⇇j₁∷Γ = /⟨⟩≃-valid₁ σ≃τ⇇j₁∷Γ
in <:-antisym (subst (λ k → _ ⊢ _ Kind[ _ ∈ k ] kd)
(sym (⌊⌋≡⇒⌊⌋-≡ ⌊j₁⌋≡k₁))
(kd-/⟨⟩ j₂-kd (/⟨⟩≃-valid₁ σ≃τ⇇j₁∷Γ)))
(subst (λ k → _ ⊢ _ <: _ ⇇ _ Kind[ _ ∈ k ]) k₁≡⌊j₁⌋
(<:⇇-/⟨⟩≃ a₁<:a₂⇇j₂ j₂-kd σ≃τ⇇j₁∷Γ))
(<:⇇-⇑ (<:⇇-/⟨⟩≃ a₂<:a₁⇇j₂ j₂-kd τ≃σ⇇j₁∷Γ)
(subst (λ k → Γ ⊢ _ <∷ _ Kind[ _ ∈ k ]) k₁≡⌊j₁⌋
(kd-/⟨⟩≃-<∷ j₂-kd τ≃σ⇇j₁∷Γ))
(subst (λ k → Γ ⊢ _ Kind[ _ ∈ k ] kd) k₁≡⌊j₁⌋
(kd-/⟨⟩ j₂-kd σ⇇j₁∷Γ)))
-- Helpers (to satisfy the termination checker).
--
-- These are simply (manual) expansions of the form
--
-- XX-/⟨⟩≃-wf x σ≃τ⇇Γ = kd-/⟨⟩≃-≅ (wf-kd-inv (wf-∷₁ (XX-ctx x))) σ≃τ⇇Γ
--
-- to ensure the above definitions remain structurally recursive
-- in the various derivations.
kd-/⟨⟩≃-wf : ∀ {m n Γ l Δ} {σ τ : SVSub m n} {j k} →
kd j ∷ Γ ⊢ k kd → Δ ⊢/⟨ l ⟩ σ ≃ τ ⇇ Γ →
Δ ⊢ j Kind/⟨ l ⟩ σ ≅ j Kind/⟨ l ⟩ τ
kd-/⟨⟩≃-wf (kd-⋯ a⇉a⋯a _) σ≃τ⇇Γ = Nf⇉-/⟨⟩≃-wf a⇉a⋯a σ≃τ⇇Γ
kd-/⟨⟩≃-wf (kd-Π j-kd _) σ≃τ⇇Γ = kd-/⟨⟩≃-wf j-kd σ≃τ⇇Γ
Nf⇉-/⟨⟩≃-wf : ∀ {m n Γ l Δ} {σ τ : SVSub m n} {j a k} →
kd j ∷ Γ ⊢Nf a ⇉ k → Δ ⊢/⟨ l ⟩ σ ≃ τ ⇇ Γ →
Δ ⊢ j Kind/⟨ l ⟩ σ ≅ j Kind/⟨ l ⟩ τ
Nf⇉-/⟨⟩≃-wf (⇉-⊥-f (wf-kd j-kd ∷ Γ-ctx)) σ≃τ⇇Γ = kd-/⟨⟩≃-≅ j-kd σ≃τ⇇Γ
Nf⇉-/⟨⟩≃-wf (⇉-⊤-f (wf-kd j-kd ∷ Γ-ctx)) σ≃τ⇇Γ = kd-/⟨⟩≃-≅ j-kd σ≃τ⇇Γ
Nf⇉-/⟨⟩≃-wf (⇉-∀-f k-kd _) σ≃τ⇇Γ = kd-/⟨⟩≃-wf k-kd σ≃τ⇇Γ
Nf⇉-/⟨⟩≃-wf (⇉-→-f a⇉a⋯a _) σ≃τ⇇Γ = Nf⇉-/⟨⟩≃-wf a⇉a⋯a σ≃τ⇇Γ
Nf⇉-/⟨⟩≃-wf (⇉-Π-i j-kd _) σ≃τ⇇Γ = kd-/⟨⟩≃-wf j-kd σ≃τ⇇Γ
Nf⇉-/⟨⟩≃-wf (⇉-s-i a∈b⋯c) σ≃τ⇇Γ = Ne∈-/⟨⟩≃-wf a∈b⋯c σ≃τ⇇Γ
Ne∈-/⟨⟩≃-wf : ∀ {m n Γ l Δ} {σ τ : SVSub m n} {j a k} →
kd j ∷ Γ ⊢Ne a ∈ k → Δ ⊢/⟨ l ⟩ σ ≃ τ ⇇ Γ →
Δ ⊢ j Kind/⟨ l ⟩ σ ≅ j Kind/⟨ l ⟩ τ
Ne∈-/⟨⟩≃-wf (∈-∙ x∈k _) σ≃τ⇇Γ = Var∈-/⟨⟩≃-wf x∈k σ≃τ⇇Γ
Var∈-/⟨⟩≃-wf : ∀ {m n Γ l Δ} {σ τ : SVSub m n} {j a k} →
kd j ∷ Γ ⊢Var a ∈ k → Δ ⊢/⟨ l ⟩ σ ≃ τ ⇇ Γ →
Δ ⊢ j Kind/⟨ l ⟩ σ ≅ j Kind/⟨ l ⟩ τ
Var∈-/⟨⟩≃-wf (⇉-var x (wf-kd j-kd ∷ Γ-ctx) _) σ≃τ⇇Γ = kd-/⟨⟩≃-≅ j-kd σ≃τ⇇Γ
Var∈-/⟨⟩≃-wf (⇇-⇑ x∈k _ _) σ≃τ⇇Γ = Var∈-/⟨⟩≃-wf x∈k σ≃τ⇇Γ
<∷-/⟨⟩≃-wf : ∀ {m n Γ l Δ} {σ τ : SVSub m n} {j k₁ k₂} →
kd j ∷ Γ ⊢ k₁ <∷ k₂ → Δ ⊢/⟨ l ⟩ σ ≃ τ ⇇ Γ →
Δ ⊢ j Kind/⟨ l ⟩ σ ≅ j Kind/⟨ l ⟩ τ
<∷-/⟨⟩≃-wf (<∷-⋯ a₂<:a₁ _) σ≃τ⇇Γ = <:-/⟨⟩≃-wf a₂<:a₁ σ≃τ⇇Γ
<∷-/⟨⟩≃-wf (<∷-Π j₁<∷j₂ _ _) σ≃τ⇇Γ = <∷-/⟨⟩≃-wf j₁<∷j₂ σ≃τ⇇Γ
<:-/⟨⟩≃-wf : ∀ {m n Γ l Δ} {σ τ : SVSub m n} {j a₁ a₂} →
kd j ∷ Γ ⊢ a₁ <: a₂ → Δ ⊢/⟨ l ⟩ σ ≃ τ ⇇ Γ →
Δ ⊢ j Kind/⟨ l ⟩ σ ≅ j Kind/⟨ l ⟩ τ
<:-/⟨⟩≃-wf (<:-trans a<:b _) σ≃τ⇇Γ = <:-/⟨⟩≃-wf a<:b σ≃τ⇇Γ
<:-/⟨⟩≃-wf (<:-⊥ a⇉a⋯a) σ≃τ⇇Γ = Nf⇉-/⟨⟩≃-wf a⇉a⋯a σ≃τ⇇Γ
<:-/⟨⟩≃-wf (<:-⊤ a⇉a⋯a) σ≃τ⇇Γ = Nf⇉-/⟨⟩≃-wf a⇉a⋯a σ≃τ⇇Γ
<:-/⟨⟩≃-wf (<:-∀ k₂<∷k₁ _ _) σ≃τ⇇Γ = <∷-/⟨⟩≃-wf k₂<∷k₁ σ≃τ⇇Γ
<:-/⟨⟩≃-wf (<:-→ a₂<:a₁ _) σ≃τ⇇Γ = <:-/⟨⟩≃-wf a₂<:a₁ σ≃τ⇇Γ
<:-/⟨⟩≃-wf (<:-∙ x∈j _) σ≃τ⇇Γ = Var∈-/⟨⟩≃-wf x∈j σ≃τ⇇Γ
<:-/⟨⟩≃-wf (<:-⟨| a∈b⋯c) σ≃τ⇇Γ = Ne∈-/⟨⟩≃-wf a∈b⋯c σ≃τ⇇Γ
<:-/⟨⟩≃-wf (<:-|⟩ a∈b⋯c) σ≃τ⇇Γ = Ne∈-/⟨⟩≃-wf a∈b⋯c σ≃τ⇇Γ
-- Equal hereditary substitutions preserve kind equality.
≅-/⟨⟩≃ : ∀ {k m n Γ Δ} {σ τ : SVSub m n} {k₁ k₂} →
Γ ⊢ k₁ ≅ k₂ → Δ ⊢/⟨ k ⟩ σ ≃ τ ⇇ Γ →
Δ ⊢ k₁ Kind/⟨ k ⟩ σ ≅ k₂ Kind/⟨ k ⟩ τ
≅-/⟨⟩≃ (<∷-antisym j-kd k-kd j<∷k k<∷j) σ≃τ⇇Γ =
<∷-antisym (kd-/⟨⟩ j-kd (/⟨⟩≃-valid₁ σ≃τ⇇Γ))
(kd-/⟨⟩ k-kd (/⟨⟩≃-valid₂ σ≃τ⇇Γ))
(<∷-/⟨⟩≃ j<∷k σ≃τ⇇Γ) (<∷-/⟨⟩≃ k<∷j (/⟨⟩≃-sym σ≃τ⇇Γ))
|
{
"alphanum_fraction": 0.3881505925,
"avg_line_length": 45.7898351648,
"ext": "agda",
"hexsha": "6ce55a05f792b26ae93af08f5a97652d72ca8b4d",
"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": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Blaisorblade/f-omega-int-agda",
"max_forks_repo_path": "src/FOmegaInt/Kinding/Canonical/HereditarySubstitution.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f",
"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": "Blaisorblade/f-omega-int-agda",
"max_issues_repo_path": "src/FOmegaInt/Kinding/Canonical/HereditarySubstitution.agda",
"max_line_length": 81,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Blaisorblade/f-omega-int-agda",
"max_stars_repo_path": "src/FOmegaInt/Kinding/Canonical/HereditarySubstitution.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 22074,
"size": 33335
}
|
{-# OPTIONS --without-K #-}
open import HoTT.Base
open import HoTT.Equivalence
open import HoTT.Identity.Product
module HoTT.Equivalence.Product where
private
variable
i : Level
A A' B B' : 𝒰 i
×-swap : A × B → B × A
×-swap x = pr₂ x , pr₁ x
×-comm : A × B ≃ B × A
×-comm = ×-swap , qinv→isequiv (×-swap , ×-uniq , ×-uniq)
×-equiv₁ : A ≃ A' → A × B ≃ A' × B
×-equiv₁ {A = A} {A' = A'} {B = B} (f₁ , e₁) = f , qinv→isequiv (g , η , ε)
where
open qinv (isequiv→qinv e₁) renaming (g to g₁ ; η to η₁ ; ε to ε₁)
f : A × B → A' × B
f (a , b) = f₁ a , b
g : A' × B → A × B
g (a' , b) = g₁ a' , b
η : g ∘ f ~ id
η (a , b) = ×-pair⁼ (η₁ a , refl)
ε : f ∘ g ~ id
ε (a' , b) = ×-pair⁼ (ε₁ a' , refl)
×-equiv₂ : B ≃ B' → A × B ≃ A × B'
×-equiv₂ {B = B} {B' = B'} {A = A} (f₂ , e₂) = f , qinv→isequiv (g , η , ε)
where
open qinv (isequiv→qinv e₂) renaming (g to g₂ ; η to η₂ ; ε to ε₂)
f : A × B → A × B'
f (a , b) = a , f₂ b
g : A × B' → A × B
g (a , b') = a , g₂ b'
η : g ∘ f ~ id
η (a , b) = ×-pair⁼ (refl , η₂ b)
ε : f ∘ g ~ id
ε (a , b') = ×-pair⁼ (refl , ε₂ b')
|
{
"alphanum_fraction": 0.4635463546,
"avg_line_length": 25.25,
"ext": "agda",
"hexsha": "bd9ca10fb77570c9a883b26f42ef87c4aa54f31a",
"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": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508",
"max_forks_repo_licenses": [
"0BSD"
],
"max_forks_repo_name": "michaelforney/hott",
"max_forks_repo_path": "HoTT/Equivalence/Product.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"0BSD"
],
"max_issues_repo_name": "michaelforney/hott",
"max_issues_repo_path": "HoTT/Equivalence/Product.agda",
"max_line_length": 75,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508",
"max_stars_repo_licenses": [
"0BSD"
],
"max_stars_repo_name": "michaelforney/hott",
"max_stars_repo_path": "HoTT/Equivalence/Product.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 554,
"size": 1111
}
|
{-# OPTIONS --cubical --safe #-}
module Algebra where
open import Prelude
module _ {a} {A : Type a} (_∙_ : A → A → A) where
Associative : Type a
Associative = ∀ x y z → (x ∙ y) ∙ z ≡ x ∙ (y ∙ z)
Commutative : Type _
Commutative = ∀ x y → x ∙ y ≡ y ∙ x
Idempotent : Type _
Idempotent = ∀ x → x ∙ x ≡ x
module _ {a b} {A : Type a} {B : Type b} where
Identityˡ : (A → B → B) → A → Type _
Identityˡ _∙_ x = ∀ y → x ∙ y ≡ y
Zeroˡ : (A → B → A) → A → Type _
Zeroˡ _∙_ x = ∀ y → x ∙ y ≡ x
Zeroʳ : (A → B → B) → B → Type _
Zeroʳ _∙_ x = ∀ y → y ∙ x ≡ x
Identityʳ : (A → B → A) → B → Type _
Identityʳ _∙_ x = ∀ y → y ∙ x ≡ y
_Distributesʳ_ : (A → B → B) → (B → B → B) → Type _
_⊗_ Distributesʳ _⊕_ = ∀ x y z → x ⊗ (y ⊕ z) ≡ (x ⊗ y) ⊕ (x ⊗ z)
_Distributesˡ_ : (B → A → B) → (B → B → B) → Type _
_⊗_ Distributesˡ _⊕_ = ∀ x y z → (x ⊕ y) ⊗ z ≡ (x ⊗ z) ⊕ (y ⊗ z)
record Semigroup ℓ : Type (ℓsuc ℓ) where
infixl 6 _∙_
field
𝑆 : Type ℓ
_∙_ : 𝑆 → 𝑆 → 𝑆
assoc : ∀ x y z → (x ∙ y) ∙ z ≡ x ∙ (y ∙ z)
record Monoid ℓ : Type (ℓsuc ℓ) where
infixl 6 _∙_
field
𝑆 : Type ℓ
_∙_ : 𝑆 → 𝑆 → 𝑆
ε : 𝑆
assoc : ∀ x y z → (x ∙ y) ∙ z ≡ x ∙ (y ∙ z)
ε∙ : ∀ x → ε ∙ x ≡ x
∙ε : ∀ x → x ∙ ε ≡ x
semigroup : Semigroup ℓ
semigroup = record
{ 𝑆 = 𝑆; _∙_ = _∙_; assoc = assoc }
record MonoidHomomorphism_⟶_
{ℓ₁ ℓ₂}
(from : Monoid ℓ₁)
(to : Monoid ℓ₂)
: Type (ℓsuc (ℓ₁ ℓ⊔ ℓ₂)) where
open Monoid from
open Monoid to
renaming ( 𝑆 to 𝑅
; _∙_ to _⊙_
; ε to ⓔ
)
field
f : 𝑆 → 𝑅
∙-homo : ∀ x y → f (x ∙ y) ≡ f x ⊙ f y
ε-homo : f ε ≡ ⓔ
record Group ℓ : Type (ℓsuc ℓ) where
field
monoid : Monoid ℓ
open Monoid monoid public
field
inv : 𝑆 → 𝑆
∙⁻ : ∀ x → x ∙ inv x ≡ ε
⁻∙ : ∀ x → inv x ∙ x ≡ ε
record CommutativeMonoid ℓ : Type (ℓsuc ℓ) where
field
monoid : Monoid ℓ
open Monoid monoid public
field
comm : Commutative _∙_
record Semilattice ℓ : Type (ℓsuc ℓ) where
field
commutativeMonoid : CommutativeMonoid ℓ
open CommutativeMonoid commutativeMonoid public
field
idem : Idempotent _∙_
record NearSemiring ℓ : Type (ℓsuc ℓ) where
infixl 6 _+_
infixl 7 _*_
field
𝑅 : Type ℓ
_+_ : 𝑅 → 𝑅 → 𝑅
_*_ : 𝑅 → 𝑅 → 𝑅
1# : 𝑅
0# : 𝑅
+-assoc : Associative _+_
*-assoc : Associative _*_
0+ : Identityˡ _+_ 0#
+0 : Identityʳ _+_ 0#
1* : Identityˡ _*_ 1#
*1 : Identityʳ _*_ 1#
0* : Zeroˡ _*_ 0#
⟨+⟩* : _*_ Distributesˡ _+_
record Semiring ℓ : Type (ℓsuc ℓ) where
field
nearSemiring : NearSemiring ℓ
open NearSemiring nearSemiring public
field
+-comm : Commutative _+_
*0 : Zeroʳ _*_ 0#
*⟨+⟩ : _*_ Distributesʳ _+_
record IdempotentSemiring ℓ : Type (ℓsuc ℓ) where
field
semiring : Semiring ℓ
open Semiring semiring public
field
+-idem : Idempotent _+_
record CommutativeSemiring ℓ : Type (ℓsuc ℓ) where
field
semiring : Semiring ℓ
open Semiring semiring public
field
*-comm : Commutative _*_
record LeftSemimodule ℓ₁ ℓ₂ : Type (ℓsuc (ℓ₁ ℓ⊔ ℓ₂)) where
field
semiring : Semiring ℓ₁
open Semiring semiring public
field
semimodule : CommutativeMonoid ℓ₂
open CommutativeMonoid semimodule renaming (_∙_ to _∪_) public
renaming (𝑆 to 𝑉
; assoc to ∪-assoc
; ε∙ to ∅∪
; ∙ε to ∪∅
; ε to ∅
)
infixr 7 _⋊_
field
_⋊_ : 𝑅 → 𝑉 → 𝑉
⟨*⟩⋊ : ∀ x y z → (x * y) ⋊ z ≡ x ⋊ (y ⋊ z)
⟨+⟩⋊ : ∀ x y z → (x + y) ⋊ z ≡ (x ⋊ z) ∪ (y ⋊ z)
⋊⟨∪⟩ : _⋊_ Distributesʳ _∪_
1⋊ : Identityˡ _⋊_ 1#
0⋊ : ∀ x → 0# ⋊ x ≡ ∅
record StarSemiring ℓ : Type (ℓsuc ℓ) where
field
semiring : Semiring ℓ
open Semiring semiring public
field
_⋆ : 𝑅 → 𝑅
star-iterʳ : ∀ x → x ⋆ ≡ 1# + x * x ⋆
star-iterˡ : ∀ x → x ⋆ ≡ 1# + x ⋆ * x
_⁺ : 𝑅 → 𝑅
x ⁺ = x * x ⋆
record Functor ℓ₁ ℓ₂ : Type (ℓsuc (ℓ₁ ℓ⊔ ℓ₂)) where
field
𝐹 : Type ℓ₁ → Type ℓ₂
map : (A → B) → 𝐹 A → 𝐹 B
map-id : map (id {ℓ₁} {A}) ≡ id
map-comp : (f : B → C) → (g : A → B) → map (f ∘ g) ≡ map f ∘ map g
record Applicative ℓ₁ ℓ₂ : Type (ℓsuc (ℓ₁ ℓ⊔ ℓ₂)) where
field
functor : Functor ℓ₁ ℓ₂
open Functor functor public
infixl 5 _<*>_
field
pure : A → 𝐹 A
_<*>_ : 𝐹 (A → B) → 𝐹 A → 𝐹 B
map-ap : (f : A → B) → map f ≡ pure f <*>_
pure-homo : (f : A → B) → (x : A) → map f (pure x) ≡ pure (f x)
<*>-interchange : (u : 𝐹 (A → B)) → (y : A) → u <*> pure y ≡ map (_$ y) u
<*>-comp : (u : 𝐹 (B → C)) → (v : 𝐹 (A → B)) → (w : 𝐹 A) → pure _∘′_ <*> u <*> v <*> w ≡ u <*> (v <*> w)
record Monad ℓ₁ ℓ₂ : Type (ℓsuc (ℓ₁ ℓ⊔ ℓ₂)) where
field
applicative : Applicative ℓ₁ ℓ₂
open Applicative applicative public
infixl 1 _>>=_
field
_>>=_ : 𝐹 A → (A → 𝐹 B) → 𝐹 B
>>=-idˡ : (f : A → 𝐹 B) → (x : A) → (pure x >>= f) ≡ f x
>>=-idʳ : (x : 𝐹 A) → (x >>= pure) ≡ x
>>=-assoc : (xs : 𝐹 A) (f : A → 𝐹 B) (g : B → 𝐹 C) → ((xs >>= f) >>= g) ≡ (xs >>= (λ x → f x >>= g))
return : A → 𝐹 A
return = pure
record Alternative ℓ₁ ℓ₂ : Type (ℓsuc (ℓ₁ ℓ⊔ ℓ₂)) where
field
applicative : Applicative ℓ₁ ℓ₂
open Applicative applicative public
field
0# : 𝐹 A
_<|>_ : 𝐹 A → 𝐹 A → 𝐹 A
<|>-idˡ : (x : 𝐹 A) → 0# <|> x ≡ x
<|>-idʳ : (x : 𝐹 A) → x <|> 0# ≡ x
0-annˡ : (x : 𝐹 A) → 0# <*> x ≡ 0# {B}
<|>-distrib : (x y : 𝐹 (A → B)) → (z : 𝐹 A) → (x <|> y) <*> z ≡ (x <*> z) <|> (y <*> z)
record MonadPlus ℓ₁ ℓ₂ : Type (ℓsuc (ℓ₁ ℓ⊔ ℓ₂)) where
field
monad : Monad ℓ₁ ℓ₂
open Monad monad public
field
0# : 𝐹 A
_<|>_ : 𝐹 A → 𝐹 A → 𝐹 A
<|>-idˡ : (x : 𝐹 A) → 0# <|> x ≡ x
<|>-idʳ : (x : 𝐹 A) → x <|> 0# ≡ x
0-annˡ : (x : A → 𝐹 B) → (0# >>= x) ≡ 0#
<|>-distrib : (x y : 𝐹 A) → (z : A → 𝐹 B) → ((x <|> y) >>= z) ≡ (x >>= z) <|> (y >>= z)
Endo : Type a → Type a
Endo A = A → A
endoMonoid : ∀ {a} → Type a → Monoid a
endoMonoid A .Monoid.𝑆 = Endo A
endoMonoid A .Monoid.ε x = x
endoMonoid A .Monoid._∙_ f g x = f (g x)
endoMonoid A .Monoid.assoc _ _ _ = refl
endoMonoid A .Monoid.ε∙ _ = refl
endoMonoid A .Monoid.∙ε _ = refl
record Foldable ℓ₁ ℓ₂ : Type (ℓsuc (ℓ₁ ℓ⊔ ℓ₂)) where
field
𝐹 : Type ℓ₁ → Type ℓ₂
open Monoid ⦃ ... ⦄
field
foldMap : {A : Type ℓ₁} ⦃ _ : Monoid ℓ₁ ⦄ → (A → 𝑆) → 𝐹 A → 𝑆
foldr : {A B : Type ℓ₁} → (A → B → B) → B → 𝐹 A → B
foldr f b xs = foldMap ⦃ endoMonoid _ ⦄ f xs b
|
{
"alphanum_fraction": 0.4945258288,
"avg_line_length": 26.3617886179,
"ext": "agda",
"hexsha": "d48508cbb1a8525dbd484d2b8e0c66d2ce42124f",
"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/Algebra.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/Algebra.agda",
"max_line_length": 108,
"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/Algebra.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": 3214,
"size": 6485
}
|
module syntax-util where
open import lib
open import cedille-types
open import general-util
open import constants
posinfo-gen : posinfo
posinfo-gen = "generated"
first-position : posinfo
first-position = "1"
dummy-var : var
dummy-var = "_dummy"
id-term : term
id-term = Lam posinfo-gen NotErased posinfo-gen "x" NoClass (Var posinfo-gen "x")
compileFailType : type
compileFailType = Abs posinfo-gen Erased posinfo-gen "X" (Tkk (Star posinfo-gen)) (TpVar posinfo-gen "X")
qualif-info : Set
qualif-info = var × args
qualif : Set
qualif = trie qualif-info
tag : Set
tag = string × rope
tagged-val : Set
tagged-val = string × rope × 𝕃 tag
tags-to-rope : 𝕃 tag → rope
tags-to-rope [] = [[]]
tags-to-rope ((t , v) :: []) = [[ "\"" ^ t ^ "\":" ]] ⊹⊹ v
tags-to-rope ((t , v) :: ts) = [[ "\"" ^ t ^ "\":" ]] ⊹⊹ v ⊹⊹ [[ "," ]] ⊹⊹ tags-to-rope ts
-- We number these when so we can sort them back in emacs
tagged-val-to-rope : ℕ → tagged-val → rope
tagged-val-to-rope n (t , v , []) = [[ "\"" ^ t ^ "\":[\"" ^ ℕ-to-string n ^ "\",\"" ]] ⊹⊹ v ⊹⊹ [[ "\"]" ]]
tagged-val-to-rope n (t , v , tags) = [[ "\"" ^ t ^ "\":[\"" ^ ℕ-to-string n ^ "\",\"" ]] ⊹⊹ v ⊹⊹ [[ "\",{" ]] ⊹⊹ tags-to-rope tags ⊹⊹ [[ "}]" ]]
tagged-vals-to-rope : ℕ → 𝕃 tagged-val → rope
tagged-vals-to-rope n [] = [[]]
tagged-vals-to-rope n (s :: []) = tagged-val-to-rope n s
tagged-vals-to-rope n (s :: (s' :: ss)) = tagged-val-to-rope n s ⊹⊹ [[ "," ]] ⊹⊹ tagged-vals-to-rope (suc n) (s' :: ss)
make-tag : (name : string) → (values : 𝕃 tag) → (start : ℕ) → (end : ℕ) → tag
make-tag name vs start end = name , [[ "{\"start\":\"" ^ ℕ-to-string start ^ "\",\"end\":\"" ^ ℕ-to-string end ^ "\"" ]] ⊹⊹ vs-to-rope vs ⊹⊹ [[ "}" ]]
where
vs-to-rope : 𝕃 tag → rope
vs-to-rope [] = [[]]
vs-to-rope ((t , v) :: ts) = [[ ",\"" ^ t ^ "\":\"" ]] ⊹⊹ v ⊹⊹ [[ "\"" ]] ⊹⊹ vs-to-rope ts
posinfo-to-ℕ : posinfo → ℕ
posinfo-to-ℕ pi with string-to-ℕ pi
posinfo-to-ℕ pi | just n = n
posinfo-to-ℕ pi | nothing = 0 -- should not happen
posinfo-plus : posinfo → ℕ → posinfo
posinfo-plus pi n = ℕ-to-string (posinfo-to-ℕ pi + n)
posinfo-plus-str : posinfo → string → posinfo
posinfo-plus-str pi s = posinfo-plus pi (string-length s)
star : kind
star = Star posinfo-gen
-- qualify variable by module name
_#_ : string → string → string
fn # v = fn ^ qual-global-str ^ v
_%_ : posinfo → var → string
pi % v = pi ^ qual-local-str ^ v
compileFail : var
compileFail = "compileFail"
compileFail-qual = "" % compileFail
mk-inst : params → args → trie arg × params
mk-inst (ParamsCons (Decl _ _ _ x _ _) ps) (ArgsCons a as) with mk-inst ps as
...| σ , ps' = trie-insert σ x a , ps'
mk-inst ps as = empty-trie , ps
apps-term : term → args → term
apps-term f (ArgsNil) = f
apps-term f (ArgsCons (TermArg me t) as) = apps-term (App f me t) as
apps-term f (ArgsCons (TypeArg t) as) = apps-term (AppTp f t) as
apps-type : type → args → type
apps-type f (ArgsNil) = f
apps-type f (ArgsCons (TermArg _ t) as) = apps-type (TpAppt f t) as
apps-type f (ArgsCons (TypeArg t) as) = apps-type (TpApp f t) as
append-params : params → params → params
append-params (ParamsCons p ps) qs = ParamsCons p (append-params ps qs)
append-params ParamsNil qs = qs
append-args : args → args → args
append-args (ArgsCons p ps) qs = ArgsCons p (append-args ps qs)
append-args (ArgsNil) qs = qs
append-cmds : cmds → cmds → cmds
append-cmds CmdsStart = id
append-cmds (CmdsNext c cs) = CmdsNext c ∘ append-cmds cs
qualif-lookup-term : qualif → string → term
qualif-lookup-term σ x with trie-lookup σ x
... | just (x' , as) = apps-term (Var posinfo-gen x') as
... | _ = Var posinfo-gen x
qualif-lookup-type : qualif → string → type
qualif-lookup-type σ x with trie-lookup σ x
... | just (x' , as) = apps-type (TpVar posinfo-gen x') as
... | _ = TpVar posinfo-gen x
qualif-lookup-kind : args → qualif → string → kind
qualif-lookup-kind xs σ x with trie-lookup σ x
... | just (x' , as) = KndVar posinfo-gen x' (append-args as xs)
... | _ = KndVar posinfo-gen x xs
inst-lookup-term : trie arg → string → term
inst-lookup-term σ x with trie-lookup σ x
... | just (TermArg me t) = t
... | _ = Var posinfo-gen x
inst-lookup-type : trie arg → string → type
inst-lookup-type σ x with trie-lookup σ x
... | just (TypeArg t) = t
... | _ = TpVar posinfo-gen x
params-to-args : params → args
params-to-args ParamsNil = ArgsNil
params-to-args (ParamsCons (Decl _ p me v (Tkt t) _) ps) = ArgsCons (TermArg me (Var posinfo-gen v)) (params-to-args ps)
params-to-args (ParamsCons (Decl _ p _ v (Tkk k) _) ps) = ArgsCons (TypeArg (TpVar posinfo-gen v)) (params-to-args ps)
qualif-insert-params : qualif → var → var → params → qualif
qualif-insert-params σ qv v ps = trie-insert σ v (qv , params-to-args ps)
qualif-insert-import : qualif → var → optAs → 𝕃 string → args → qualif
qualif-insert-import σ mn oa [] as = σ
qualif-insert-import σ mn oa (v :: vs) as = qualif-insert-import (trie-insert σ (import-as v oa) (mn # v , as)) mn oa vs as
where
import-as : var → optAs → var
import-as v NoOptAs = v
import-as v (SomeOptAs _ pfx) = pfx # v
tk-is-type : tk → 𝔹
tk-is-type (Tkt _) = tt
tk-is-type (Tkk _) = ff
me-unerased : maybeErased → 𝔹
me-unerased Erased = ff
me-unerased NotErased = tt
me-erased : maybeErased → 𝔹
me-erased x = ~ (me-unerased x)
term-start-pos : term → posinfo
type-start-pos : type → posinfo
kind-start-pos : kind → posinfo
liftingType-start-pos : liftingType → posinfo
term-start-pos (App t x t₁) = term-start-pos t
term-start-pos (AppTp t tp) = term-start-pos t
term-start-pos (Hole pi) = pi
term-start-pos (Lam pi x _ x₁ x₂ t) = pi
term-start-pos (Let pi _ _) = pi
term-start-pos (Open pi _ _) = pi
term-start-pos (Parens pi t pi') = pi
term-start-pos (Var pi x₁) = pi
term-start-pos (Beta pi _ _) = pi
term-start-pos (IotaPair pi _ _ _ _) = pi
term-start-pos (IotaProj t _ _) = term-start-pos t
term-start-pos (Epsilon pi _ _ _) = pi
term-start-pos (Phi pi _ _ _ _) = pi
term-start-pos (Rho pi _ _ _ _ _) = pi
term-start-pos (Chi pi _ _) = pi
term-start-pos (Delta pi _ _) = pi
term-start-pos (Sigma pi _) = pi
term-start-pos (Theta pi _ _ _) = pi
term-start-pos (Mu pi _ _ _ _ _ _) = pi
term-start-pos (Mu' pi _ _ _ _ _) = pi
type-start-pos (Abs pi _ _ _ _ _) = pi
type-start-pos (TpLambda pi _ _ _ _) = pi
type-start-pos (Iota pi _ _ _ _) = pi
type-start-pos (Lft pi _ _ _ _) = pi
type-start-pos (TpApp t t₁) = type-start-pos t
type-start-pos (TpAppt t x) = type-start-pos t
type-start-pos (TpArrow t _ t₁) = type-start-pos t
type-start-pos (TpEq pi _ _ pi') = pi
type-start-pos (TpParens pi _ pi') = pi
type-start-pos (TpVar pi x₁) = pi
type-start-pos (NoSpans t _) = type-start-pos t -- we are not expecting this on input
type-start-pos (TpHole pi) = pi --ACG
type-start-pos (TpLet pi _ _) = pi
kind-start-pos (KndArrow k k₁) = kind-start-pos k
kind-start-pos (KndParens pi k pi') = pi
kind-start-pos (KndPi pi _ x x₁ k) = pi
kind-start-pos (KndTpArrow x k) = type-start-pos x
kind-start-pos (KndVar pi x₁ _) = pi
kind-start-pos (Star pi) = pi
liftingType-start-pos (LiftArrow l l') = liftingType-start-pos l
liftingType-start-pos (LiftParens pi l pi') = pi
liftingType-start-pos (LiftPi pi x₁ x₂ l) = pi
liftingType-start-pos (LiftStar pi) = pi
liftingType-start-pos (LiftTpArrow t l) = type-start-pos t
term-end-pos : term → posinfo
type-end-pos : type → posinfo
kind-end-pos : kind → posinfo
liftingType-end-pos : liftingType → posinfo
tk-end-pos : tk → posinfo
lterms-end-pos : lterms → posinfo
args-end-pos : (if-nil : posinfo) → args → posinfo
arg-end-pos : arg → posinfo
kvar-end-pos : posinfo → var → args → posinfo
term-end-pos (App t x t') = term-end-pos t'
term-end-pos (AppTp t tp) = type-end-pos tp
term-end-pos (Hole pi) = posinfo-plus pi 1
term-end-pos (Lam pi x _ x₁ x₂ t) = term-end-pos t
term-end-pos (Let _ _ t) = term-end-pos t
term-end-pos (Open pi _ t) = term-end-pos t
term-end-pos (Parens pi t pi') = pi'
term-end-pos (Var pi x) = posinfo-plus-str pi x
term-end-pos (Beta pi _ (SomeTerm t pi')) = pi'
term-end-pos (Beta pi (SomeTerm t pi') _) = pi'
term-end-pos (Beta pi NoTerm NoTerm) = posinfo-plus pi 1
term-end-pos (IotaPair _ _ _ _ pi) = pi
term-end-pos (IotaProj _ _ pi) = pi
term-end-pos (Epsilon pi _ _ t) = term-end-pos t
term-end-pos (Phi _ _ _ _ pi) = pi
term-end-pos (Rho pi _ _ _ t t') = term-end-pos t'
term-end-pos (Chi pi T t') = term-end-pos t'
term-end-pos (Delta pi oT t) = term-end-pos t
term-end-pos (Sigma pi t) = term-end-pos t
term-end-pos (Theta _ _ _ ls) = lterms-end-pos ls
term-end-pos (Mu _ _ _ _ _ _ pi) = pi
term-end-pos (Mu' _ _ _ _ _ pi) = pi
type-end-pos (Abs pi _ _ _ _ t) = type-end-pos t
type-end-pos (TpLambda _ _ _ _ t) = type-end-pos t
type-end-pos (Iota _ _ _ _ tp) = type-end-pos tp
type-end-pos (Lft pi _ _ _ t) = liftingType-end-pos t
type-end-pos (TpApp t t') = type-end-pos t'
type-end-pos (TpAppt t x) = term-end-pos x
type-end-pos (TpArrow t _ t') = type-end-pos t'
type-end-pos (TpEq pi _ _ pi') = pi'
type-end-pos (TpParens pi _ pi') = pi'
type-end-pos (TpVar pi x) = posinfo-plus-str pi x
type-end-pos (TpHole pi) = posinfo-plus pi 1
type-end-pos (NoSpans t pi) = pi
type-end-pos (TpLet _ _ t) = type-end-pos t
kind-end-pos (KndArrow k k') = kind-end-pos k'
kind-end-pos (KndParens pi k pi') = pi'
kind-end-pos (KndPi pi _ x x₁ k) = kind-end-pos k
kind-end-pos (KndTpArrow x k) = kind-end-pos k
kind-end-pos (KndVar pi x ys) = args-end-pos (posinfo-plus-str pi x) ys
kind-end-pos (Star pi) = posinfo-plus pi 1
tk-end-pos (Tkt T) = type-end-pos T
tk-end-pos (Tkk k) = kind-end-pos k
args-end-pos pi (ArgsCons x ys) = args-end-pos (arg-end-pos x) ys
args-end-pos pi ArgsNil = pi
arg-end-pos (TermArg me t) = term-end-pos t
arg-end-pos (TypeArg T) = type-end-pos T
kvar-end-pos pi v = args-end-pos (posinfo-plus-str pi v)
liftingType-end-pos (LiftArrow l l') = liftingType-end-pos l'
liftingType-end-pos (LiftParens pi l pi') = pi'
liftingType-end-pos (LiftPi x x₁ x₂ l) = liftingType-end-pos l
liftingType-end-pos (LiftStar pi) = posinfo-plus pi 1
liftingType-end-pos (LiftTpArrow x l) = liftingType-end-pos l
lterms-end-pos (LtermsNil pi) = posinfo-plus pi 1 -- must add one for the implicit Beta that we will add at the end
lterms-end-pos (LtermsCons _ _ ls) = lterms-end-pos ls
{- return the end position of the given term if it is there, otherwise
the given posinfo -}
optTerm-end-pos : posinfo → optTerm → posinfo
optTerm-end-pos pi NoTerm = pi
optTerm-end-pos pi (SomeTerm x x₁) = x₁
optTerm-end-pos-beta : posinfo → optTerm → optTerm → posinfo
optTerm-end-pos-beta pi _ (SomeTerm x pi') = pi'
optTerm-end-pos-beta pi (SomeTerm x pi') NoTerm = pi'
optTerm-end-pos-beta pi NoTerm NoTerm = posinfo-plus pi 1
optAs-or : optAs → posinfo → var → posinfo × var
optAs-or NoOptAs pi x = pi , x
optAs-or (SomeOptAs pi x) _ _ = pi , x
tk-arrow-kind : tk → kind → kind
tk-arrow-kind (Tkk k) k' = KndArrow k k'
tk-arrow-kind (Tkt t) k = KndTpArrow t k
TpApp-tk : type → var → tk → type
TpApp-tk tp x (Tkk _) = TpApp tp (TpVar posinfo-gen x)
TpApp-tk tp x (Tkt _) = TpAppt tp (Var posinfo-gen x)
-- expression descriptor
data exprd : Set where
TERM : exprd
TYPE : exprd
KIND : exprd
LIFTINGTYPE : exprd
TK : exprd
ARG : exprd
QUALIF : exprd
⟦_⟧ : exprd → Set
⟦ TERM ⟧ = term
⟦ TYPE ⟧ = type
⟦ KIND ⟧ = kind
⟦ LIFTINGTYPE ⟧ = liftingType
⟦ TK ⟧ = tk
⟦ ARG ⟧ = arg
⟦ QUALIF ⟧ = qualif-info
exprd-name : exprd → string
exprd-name TERM = "term"
exprd-name TYPE = "type"
exprd-name KIND = "kind"
exprd-name LIFTINGTYPE = "lifting type"
exprd-name TK = "type-kind"
exprd-name ARG = "argument"
exprd-name QUALIF = "qualification"
-- checking-sythesizing enum
data checking-mode : Set where
checking : checking-mode
synthesizing : checking-mode
untyped : checking-mode
maybe-to-checking : {A : Set} → maybe A → checking-mode
maybe-to-checking (just _) = checking
maybe-to-checking nothing = synthesizing
is-app : {ed : exprd} → ⟦ ed ⟧ → 𝔹
is-app{TERM} (App _ _ _) = tt
is-app{TERM} (AppTp _ _) = tt
is-app{TYPE} (TpApp _ _) = tt
is-app{TYPE} (TpAppt _ _) = tt
is-app _ = ff
is-term-level-app : {ed : exprd} → ⟦ ed ⟧ → 𝔹
is-term-level-app{TERM} (App _ _ _) = tt
is-term-level-app{TERM} (AppTp _ _) = tt
is-term-level-app _ = ff
is-type-level-app : {ed : exprd} → ⟦ ed ⟧ → 𝔹
is-type-level-app{TYPE} (TpApp _ _) = tt
is-type-level-app{TYPE} (TpAppt _ _) = tt
is-type-level-app _ = ff
is-parens : {ed : exprd} → ⟦ ed ⟧ → 𝔹
is-parens{TERM} (Parens _ _ _) = tt
is-parens{TYPE} (TpParens _ _ _) = tt
is-parens{KIND} (KndParens _ _ _) = tt
is-parens{LIFTINGTYPE} (LiftParens _ _ _) = tt
is-parens _ = ff
is-arrow : {ed : exprd} → ⟦ ed ⟧ → 𝔹
is-arrow{TYPE} (TpArrow _ _ _) = tt
is-arrow{KIND} (KndTpArrow _ _) = tt
is-arrow{KIND} (KndArrow _ _) = tt
is-arrow{LIFTINGTYPE} (LiftArrow _ _) = tt
is-arrow{LIFTINGTYPE} (LiftTpArrow _ _) = tt
is-arrow _ = ff
is-abs : {ed : exprd} → ⟦ ed ⟧ → 𝔹
is-abs{TERM} (Let _ _ _) = tt
is-abs{TERM} (Lam _ _ _ _ _ _) = tt
is-abs{TYPE} (Abs _ _ _ _ _ _) = tt
is-abs{TYPE} (TpLambda _ _ _ _ _) = tt
is-abs{TYPE} (Iota _ _ _ _ _) = tt
is-abs{KIND} (KndPi _ _ _ _ _) = tt
is-abs{LIFTINGTYPE} (LiftPi _ _ _ _) = tt
is-abs _ = ff
is-eq-op : {ed : exprd} → ⟦ ed ⟧ → 𝔹
is-eq-op{TERM} (Sigma _ _) = tt
is-eq-op{TERM} (Epsilon _ _ _ _) = tt
is-eq-op{TERM} (Rho _ _ _ _ _ _) = tt
is-eq-op{TERM} (Chi _ _ _) = tt
is-eq-op{TERM} (Phi _ _ _ _ _) = tt
is-eq-op{TERM} (Delta _ _ _) = tt
is-eq-op _ = ff
is-beta : {ed : exprd} → ⟦ ed ⟧ → 𝔹
is-beta{TERM} (Beta _ _ _) = tt
is-beta _ = ff
is-hole : {ed : exprd} → ⟦ ed ⟧ → 𝔹
is-hole{TERM} (Hole _) = tt
is-hole{TERM} _ = ff
is-hole{TYPE} (TpHole _) = tt
is-hole{TYPE} _ = ff
is-hole{KIND} e = ff
is-hole{LIFTINGTYPE} e = ff
is-hole{TK} (Tkk x) = is-hole x
is-hole{TK} (Tkt x) = is-hole x
is-hole{ARG} (TermArg e? t) = is-hole t
is-hole{ARG} (TypeArg tp) = is-hole tp
is-hole{QUALIF} _ = ff
eq-maybeErased : maybeErased → maybeErased → 𝔹
eq-maybeErased Erased Erased = tt
eq-maybeErased Erased NotErased = ff
eq-maybeErased NotErased Erased = ff
eq-maybeErased NotErased NotErased = tt
eq-checking-mode : (m₁ m₂ : checking-mode) → 𝔹
eq-checking-mode checking checking = tt
eq-checking-mode checking synthesizing = ff
eq-checking-mode checking untyped = ff
eq-checking-mode synthesizing checking = ff
eq-checking-mode synthesizing synthesizing = tt
eq-checking-mode synthesizing untyped = ff
eq-checking-mode untyped checking = ff
eq-checking-mode untyped synthesizing = ff
eq-checking-mode untyped untyped = tt
optPublic-is-public : optPublic → 𝔹
optPublic-is-public IsPublic = tt
optPublic-is-public NotPublic = ff
------------------------------------------------------
-- functions intended for building terms for testing
------------------------------------------------------
mlam : var → term → term
mlam x t = Lam posinfo-gen NotErased posinfo-gen x NoClass t
Mlam : var → term → term
Mlam x t = Lam posinfo-gen Erased posinfo-gen x NoClass t
mappe : term → term → term
mappe t1 t2 = App t1 Erased t2
mapp : term → term → term
mapp t1 t2 = App t1 NotErased t2
mvar : var → term
mvar x = Var posinfo-gen x
mtpvar : var → type
mtpvar x = TpVar posinfo-gen x
mall : var → tk → type → type
mall x tk tp = Abs posinfo-gen All posinfo-gen x tk tp
mtplam : var → tk → type → type
mtplam x tk tp = TpLambda posinfo-gen posinfo-gen x tk tp
{- strip off lambda-abstractions from the term, return the lambda-bound vars and the innermost body.
The intention is to call this with at least the erasure of a term, if not the hnf -- so we do
not check for parens, etc. -}
decompose-lams : term → (𝕃 var) × term
decompose-lams (Lam _ _ _ x _ t) with decompose-lams t
decompose-lams (Lam _ _ _ x _ t) | vs , body = (x :: vs) , body
decompose-lams t = [] , t
{- decompose a term into spine form consisting of a non-applications head and arguments.
The outer arguments will come earlier in the list than the inner ones.
As for decompose-lams, we assume the term is at least erased. -}
decompose-apps : term → term × (𝕃 term)
decompose-apps (App t _ t') with decompose-apps t
decompose-apps (App t _ t') | h , args = h , (t' :: args)
decompose-apps t = t , []
decompose-var-headed : (var → 𝔹) → term → maybe (var × (𝕃 term))
decompose-var-headed is-bound t with decompose-apps t
decompose-var-headed is-bound t | Var _ x , args = if is-bound x then nothing else (just (x , args))
decompose-var-headed is-bound t | _ = nothing
data tty : Set where
tterm : term → tty
ttype : type → tty
decompose-tpapps : type → type × 𝕃 tty
decompose-tpapps (TpApp t t') with decompose-tpapps t
decompose-tpapps (TpApp t t') | h , args = h , (ttype t') :: args
decompose-tpapps (TpAppt t t') with decompose-tpapps t
decompose-tpapps (TpAppt t t') | h , args = h , (tterm t') :: args
decompose-tpapps (TpParens _ t _) = decompose-tpapps t
decompose-tpapps t = t , []
recompose-tpapps : type × 𝕃 tty → type
recompose-tpapps (h , []) = h
recompose-tpapps (h , ((tterm t') :: args)) = TpAppt (recompose-tpapps (h , args)) t'
recompose-tpapps (h , ((ttype t') :: args)) = TpApp (recompose-tpapps (h , args)) t'
recompose-apps : maybeErased → 𝕃 tty → term → term
recompose-apps me [] h = h
recompose-apps me ((tterm t') :: args) h = App (recompose-apps me args h) me t'
recompose-apps me ((ttype t') :: args) h = AppTp (recompose-apps me args h) t'
vars-to-𝕃 : vars → 𝕃 var
vars-to-𝕃 (VarsStart v) = [ v ]
vars-to-𝕃 (VarsNext v vs) = v :: vars-to-𝕃 vs
{- lambda-abstract the input variables in reverse order around the
given term (so closest to the top of the list is bound deepest in
the resulting term). -}
Lam* : 𝕃 var → term → term
Lam* [] t = t
Lam* (x :: xs) t = Lam* xs (Lam posinfo-gen NotErased posinfo-gen x NoClass t)
App* : term → 𝕃 (maybeErased × term) → term
App* t [] = t
App* t ((m , arg) :: args) = App (App* t args) m arg
App*' : term → 𝕃 term → term
App*' t [] = t
App*' t (arg :: args) = App*' (App t NotErased arg) args
TpApp* : type → 𝕃 type → type
TpApp* t [] = t
TpApp* t (arg :: args) = (TpApp (TpApp* t args) arg)
LiftArrow* : 𝕃 liftingType → liftingType → liftingType
LiftArrow* [] l = l
LiftArrow* (l' :: ls) l = LiftArrow* ls (LiftArrow l' l)
is-intro-form : term → 𝔹
is-intro-form (Lam _ _ _ _ _ _) = tt
--is-intro-form (IotaPair _ _ _ _ _) = tt
is-intro-form _ = ff
erase : { ed : exprd } → ⟦ ed ⟧ → ⟦ ed ⟧
erase-term : term → term
erase-type : type → type
erase-kind : kind → kind
erase-lterms : term → lterms → term
erase-tk : tk → tk
-- erase-optType : optType → optType
erase-liftingType : liftingType → liftingType
erase-cases : cases → cases
erase-varargs : varargs → varargs
erase-if : 𝔹 → { ed : exprd } → ⟦ ed ⟧ → ⟦ ed ⟧
erase-if tt = erase
erase-if ff = id
erase-term (Parens _ t _) = erase-term t
erase-term (App t1 Erased t2) = erase-term t1
erase-term (App t1 NotErased t2) = App (erase-term t1) NotErased (erase-term t2)
erase-term (AppTp t tp) = erase-term t
erase-term (Lam _ Erased _ _ _ t) = erase-term t
erase-term (Lam _ NotErased _ x oc t) = Lam posinfo-gen NotErased posinfo-gen x NoClass (erase-term t)
erase-term (Let _ (DefTerm _ x _ t) t') = Let posinfo-gen (DefTerm posinfo-gen x NoType (erase-term t)) (erase-term t')
erase-term (Let _ (DefType _ _ _ _) t) = erase-term t
erase-term (Open _ _ t) = erase-term t
erase-term (Var _ x) = Var posinfo-gen x
erase-term (Beta _ _ NoTerm) = id-term
erase-term (Beta _ _ (SomeTerm t _)) = erase-term t
erase-term (IotaPair _ t1 t2 _ _) = erase-term t1
erase-term (IotaProj t n _) = erase-term t
erase-term (Epsilon _ lr _ t) = erase-term t
erase-term (Sigma _ t) = erase-term t
erase-term (Hole _) = Hole posinfo-gen
erase-term (Phi _ t t₁ t₂ _) = erase-term t₂
erase-term (Rho _ _ _ t _ t') = erase-term t'
erase-term (Chi _ T t') = erase-term t'
erase-term (Delta _ T t) = id-term
erase-term (Theta _ u t ls) = erase-lterms (erase-term t) ls
erase-term (Mu _ x t ot _ c _) = Mu posinfo-gen x (erase-term t) NoType posinfo-gen (erase-cases c) posinfo-gen
erase-term (Mu' _ t ot _ c _) = Mu' posinfo-gen (erase-term t) NoType posinfo-gen (erase-cases c) posinfo-gen
erase-cases NoCase = NoCase
erase-cases (SomeCase _ x varargs t cs) = SomeCase posinfo-gen x (erase-varargs varargs) (erase-term t) (erase-cases cs)
erase-varargs NoVarargs = NoVarargs
erase-varargs (NormalVararg x varargs) = NormalVararg x (erase-varargs varargs)
erase-varargs (ErasedVararg x varargs) = erase-varargs varargs
erase-varargs (TypeVararg x varargs ) = erase-varargs varargs
-- Only erases TERMS in types, leaving the structure of types the same
erase-type (Abs _ b _ v atk tp) = Abs posinfo-gen b posinfo-gen v (erase-tk atk) (erase-type tp)
erase-type (Iota _ _ v otp tp) = Iota posinfo-gen posinfo-gen v (erase-type otp) (erase-type tp)
erase-type (Lft _ _ v t lt) = Lft posinfo-gen posinfo-gen v (erase-term t) (erase-liftingType lt)
erase-type (NoSpans tp _) = NoSpans (erase-type tp) posinfo-gen
erase-type (TpApp tp tp') = TpApp (erase-type tp) (erase-type tp')
erase-type (TpAppt tp t) = TpAppt (erase-type tp) (erase-term t)
erase-type (TpArrow tp at tp') = TpArrow (erase-type tp) at (erase-type tp')
erase-type (TpEq _ t t' _) = TpEq posinfo-gen (erase-term t) (erase-term t') posinfo-gen
erase-type (TpLambda _ _ v atk tp) = TpLambda posinfo-gen posinfo-gen v (erase-tk atk) (erase-type tp)
erase-type (TpParens _ tp _) = erase-type tp
erase-type (TpHole _) = TpHole posinfo-gen
erase-type (TpVar _ x) = TpVar posinfo-gen x
erase-type (TpLet _ (DefTerm _ x _ t) T) = TpLet posinfo-gen (DefTerm posinfo-gen x NoType (erase-term t)) (erase-type T)
erase-type (TpLet _ (DefType _ x k T) T') = TpLet posinfo-gen (DefType posinfo-gen x (erase-kind k) (erase-type T)) (erase-type T')
-- Only erases TERMS in types in kinds, leaving the structure of kinds and types in those kinds the same
erase-kind (KndArrow k k') = KndArrow (erase-kind k) (erase-kind k')
erase-kind (KndParens _ k _) = erase-kind k
erase-kind (KndPi _ _ v atk k) = KndPi posinfo-gen posinfo-gen v (erase-tk atk) (erase-kind k)
erase-kind (KndTpArrow tp k) = KndTpArrow (erase-type tp) (erase-kind k)
erase-kind (KndVar _ x ps) = KndVar posinfo-gen x ps
erase-kind (Star _) = Star posinfo-gen
erase{TERM} t = erase-term t
erase{TYPE} tp = erase-type tp
erase{KIND} k = erase-kind k
erase{LIFTINGTYPE} lt = erase-liftingType lt
erase{TK} atk = erase-tk atk
erase{ARG} a = a
erase{QUALIF} q = q
erase-tk (Tkt tp) = Tkt (erase-type tp)
erase-tk (Tkk k) = Tkk (erase-kind k)
erase-liftingType (LiftArrow lt lt') = LiftArrow (erase-liftingType lt) (erase-liftingType lt')
erase-liftingType (LiftParens _ lt _) = erase-liftingType lt
erase-liftingType (LiftPi _ v tp lt) = LiftPi posinfo-gen v (erase-type tp) (erase-liftingType lt)
erase-liftingType (LiftTpArrow tp lt) = LiftTpArrow (erase-type tp) (erase-liftingType lt)
erase-liftingType lt = lt
erase-lterms t (LtermsNil _) = t
erase-lterms t (LtermsCons Erased t' ls) = erase-lterms t ls
erase-lterms t (LtermsCons NotErased t' ls) = erase-lterms (App t NotErased (erase-term t')) ls
lterms-to-term : theta → term → lterms → term
lterms-to-term AbstractEq t (LtermsNil _) = App t Erased (Beta posinfo-gen NoTerm NoTerm)
lterms-to-term _ t (LtermsNil _) = t
lterms-to-term u t (LtermsCons e t' ls) = lterms-to-term u (App t e t') ls
imps-to-cmds : imports → cmds
imps-to-cmds ImportsStart = CmdsStart
imps-to-cmds (ImportsNext i is) = CmdsNext (ImportCmd i) (imps-to-cmds is)
-- TODO handle qualif & module args
get-imports : start → 𝕃 string
get-imports (File _ is _ _ mn _ cs _) = imports-to-include is ++ get-imports-cmds cs
where import-to-include : imprt → string
import-to-include (Import _ _ _ x oa _ _) = x
imports-to-include : imports → 𝕃 string
imports-to-include ImportsStart = []
imports-to-include (ImportsNext x is) = import-to-include x :: imports-to-include is
singleton-if-include : cmd → 𝕃 string
singleton-if-include (ImportCmd imp) = [ import-to-include imp ]
singleton-if-include _ = []
get-imports-cmds : cmds → 𝕃 string
get-imports-cmds (CmdsNext c cs) = singleton-if-include c ++ get-imports-cmds cs
get-imports-cmds CmdsStart = []
data language-level : Set where
ll-term : language-level
ll-type : language-level
ll-kind : language-level
ll-to-string : language-level → string
ll-to-string ll-term = "term"
ll-to-string ll-type = "type"
ll-to-string ll-kind = "kind"
is-rho-plus : optPlus → 𝔹
is-rho-plus RhoPlus = tt
is-rho-plus _ = ff
split-var-h : 𝕃 char → 𝕃 char × 𝕃 char
split-var-h [] = [] , []
split-var-h (qual-global-chr :: xs) = [] , xs
split-var-h (x :: xs) with split-var-h xs
... | xs' , ys = (x :: xs') , ys
split-var : var → var × var
split-var v with split-var-h (reverse (string-to-𝕃char v))
... | xs , ys = 𝕃char-to-string (reverse ys) , 𝕃char-to-string (reverse xs)
var-suffix : var → maybe var
var-suffix v with split-var v
... | "" , _ = nothing
... | _ , sfx = just sfx
-- unique qualif domain prefixes
qual-pfxs : qualif → 𝕃 var
qual-pfxs q = uniq (prefixes (trie-strings q))
where
uniq : 𝕃 var → 𝕃 var
uniq vs = stringset-strings (stringset-insert* empty-stringset vs)
prefixes : 𝕃 var → 𝕃 var
prefixes [] = []
prefixes (v :: vs) with split-var v
... | "" , sfx = vs
... | pfx , sfx = pfx :: prefixes vs
unqual-prefix : qualif → 𝕃 var → var → var → var
unqual-prefix q [] sfx v = v
unqual-prefix q (pfx :: pfxs) sfx v
with trie-lookup q (pfx # sfx)
... | just (v' , _) = if v =string v' then pfx # sfx else v
... | nothing = v
unqual-bare : qualif → var → var → var
unqual-bare q sfx v with trie-lookup q sfx
... | just (v' , _) = if v =string v' then sfx else v
... | nothing = v
unqual-local : var → var
unqual-local v = f' (string-to-𝕃char v) where
f : 𝕃 char → maybe (𝕃 char)
f [] = nothing
f ('@' :: t) = f t maybe-or just t
f (h :: t) = f t
f' : 𝕃 char → string
f' (meta-var-pfx :: t) = maybe-else' (f t) v (𝕃char-to-string ∘ _::_ meta-var-pfx)
f' t = maybe-else' (f t) v 𝕃char-to-string
unqual-all : qualif → var → string
unqual-all q v with var-suffix v
... | nothing = v
... | just sfx = unqual-bare q sfx (unqual-prefix q (qual-pfxs q) sfx v)
erased-params : params → 𝕃 string
erased-params (ParamsCons (Decl _ _ Erased x (Tkt _) _) ps) with var-suffix x
... | nothing = x :: erased-params ps
... | just x' = x' :: erased-params ps
erased-params (ParamsCons p ps) = erased-params ps
erased-params ParamsNil = []
lam-expand-term : params → term → term
lam-expand-term (ParamsCons (Decl _ _ me x tk _) ps) t =
Lam posinfo-gen (if tk-is-type tk then me else Erased) posinfo-gen x (SomeClass tk) (lam-expand-term ps t)
lam-expand-term ParamsNil t = t
lam-expand-type : params → type → type
lam-expand-type (ParamsCons (Decl _ _ me x tk _) ps) t =
TpLambda posinfo-gen posinfo-gen x tk (lam-expand-type ps t)
lam-expand-type ParamsNil t = t
abs-expand-type : params → type → type
abs-expand-type (ParamsCons (Decl _ _ me x tk _) ps) t =
Abs posinfo-gen (if tk-is-type tk then me else All) posinfo-gen x tk (abs-expand-type ps t)
abs-expand-type ParamsNil t = t
abs-expand-type' : params → type → type
abs-expand-type' (ParamsCons (Decl _ _ me x tk _) ps) t =
Abs posinfo-gen (if tk-is-type tk then me else All) posinfo-gen x tk (abs-expand-type' ps t)
abs-expand-type' ParamsNil t = t
abs-expand-kind : params → kind → kind
abs-expand-kind (ParamsCons (Decl _ _ me x tk _) ps) k =
KndPi posinfo-gen posinfo-gen x tk (abs-expand-kind ps k)
abs-expand-kind ParamsNil k = k
args-length : args → ℕ
args-length (ArgsCons p ps) = suc (args-length ps)
args-length ArgsNil = 0
erased-args-length : args → ℕ
erased-args-length (ArgsCons (TermArg NotErased _) ps) = suc (erased-args-length ps)
erased-args-length (ArgsCons (TermArg Erased _) ps) = erased-args-length ps
erased-args-length (ArgsCons (TypeArg _) ps) = erased-args-length ps
erased-args-length ArgsNil = 0
me-args-length : maybeErased → args → ℕ
me-args-length Erased = erased-args-length
me-args-length NotErased = args-length
spineApp : Set
spineApp = qvar × 𝕃 arg
term-to-spapp : term → maybe spineApp
term-to-spapp (App t me t') = term-to-spapp t ≫=maybe
(λ { (v , as) → just (v , TermArg me t' :: as) })
term-to-spapp (AppTp t T) = term-to-spapp t ≫=maybe
(λ { (v , as) → just (v , TypeArg T :: as) })
term-to-spapp (Var _ v) = just (v , [])
term-to-spapp _ = nothing
type-to-spapp : type → maybe spineApp
type-to-spapp (TpApp T T') = type-to-spapp T ≫=maybe
(λ { (v , as) → just (v , TypeArg T' :: as) })
type-to-spapp (TpAppt T t) = type-to-spapp T ≫=maybe
(λ { (v , as) → just (v , TermArg NotErased t :: as) })
type-to-spapp (TpVar _ v) = just (v , [])
type-to-spapp _ = nothing
spapp-term : spineApp → term
spapp-term (v , []) = Var posinfo-gen v
spapp-term (v , TermArg me t :: as) = App (spapp-term (v , as)) me t
spapp-term (v , TypeArg T :: as) = AppTp (spapp-term (v , as)) T
spapp-type : spineApp → type
spapp-type (v , []) = TpVar posinfo-gen v
spapp-type (v , TermArg me t :: as) = TpAppt (spapp-type (v , as)) t
spapp-type (v , TypeArg T :: as) = TpApp (spapp-type (v , as)) T
num-gt : num → ℕ → 𝕃 string
num-gt n n' = maybe-else [] (λ n'' → if n'' > n' then [ n ] else []) (string-to-ℕ n)
nums-gt : nums → ℕ → 𝕃 string
nums-gt (NumsStart n) n' = num-gt n n'
nums-gt (NumsNext n ns) n' =
maybe-else [] (λ n'' → if n'' > n' || iszero n'' then [ n ] else []) (string-to-ℕ n)
++ nums-gt ns n'
nums-to-stringset : nums → stringset × 𝕃 string {- Repeated numbers -}
nums-to-stringset (NumsStart n) = stringset-insert empty-stringset n , []
nums-to-stringset (NumsNext n ns) with nums-to-stringset ns
...| ss , rs = if stringset-contains ss n
then ss , n :: rs
else stringset-insert ss n , rs
optNums-to-stringset : optNums → maybe stringset × (ℕ → maybe string)
optNums-to-stringset NoNums = nothing , λ _ → nothing
optNums-to-stringset (SomeNums ns) with nums-to-stringset ns
...| ss , [] = just ss , λ n → case nums-gt ns n of λ where
[] → nothing
ns-g → just ("Occurrences not found: " ^ 𝕃-to-string id ", " ns-g ^ " (total occurrences: " ^ ℕ-to-string n ^ ")")
...| ss , rs = just ss , λ n →
just ("The list of occurrences contains the following repeats: " ^ 𝕃-to-string id ", " rs)
------------------------------------------------------
-- any delta contradiction → boolean contradiction
------------------------------------------------------
nlam : ℕ → term → term
nlam 0 t = t
nlam (suc n) t = mlam ignored-var (nlam n t)
delta-contra-app : ℕ → (ℕ → term) → term
delta-contra-app 0 nt = mvar "x"
delta-contra-app (suc n) nt = mapp (delta-contra-app n nt) (nt n)
delta-contrahh : ℕ → trie ℕ → trie ℕ → var → var → 𝕃 term → 𝕃 term → maybe term
delta-contrahh n ls rs x1 x2 as1 as2 with trie-lookup ls x1 | trie-lookup rs x2
...| just n1 | just n2 =
let t1 = nlam (length as1) (mlam "x" (mlam "y" (mvar "x")))
t2 = nlam (length as2) (mlam "x" (mlam "y" (mvar "y"))) in
if n1 =ℕ n2
then nothing
else just (mlam "x" (delta-contra-app n
(λ n → if n =ℕ n1 then t1 else if n =ℕ n2 then t2 else id-term)))
...| _ | _ = nothing
{-# TERMINATING #-}
delta-contrah : ℕ → trie ℕ → trie ℕ → term → term → maybe term
delta-contrah n ls rs (Lam _ _ _ x1 _ t1) (Lam _ _ _ x2 _ t2) =
delta-contrah (suc n) (trie-insert ls x1 n) (trie-insert rs x2 n) t1 t2
delta-contrah n ls rs (Lam _ _ _ x1 _ t1) t2 =
delta-contrah (suc n) (trie-insert ls x1 n) (trie-insert rs x1 n) t1 (mapp t2 (mvar x1))
delta-contrah n ls rs t1 (Lam _ _ _ x2 _ t2) =
delta-contrah (suc n) (trie-insert ls x2 n) (trie-insert rs x2 n) (mapp t1 (mvar x2)) t2
delta-contrah n ls rs t1 t2 with decompose-apps t1 | decompose-apps t2
...| Var _ x1 , as1 | Var _ x2 , as2 = delta-contrahh n ls rs x1 x2 as1 as2
...| _ | _ = nothing
-- For terms t1 and t2, given that check-beta-inequiv t1 t2 ≡ tt,
-- delta-contra produces a function f such that f t1 ≡ tt and f t2 ≡ ff
-- If it returns nothing, no contradiction could be found
delta-contra : term → term → maybe term
delta-contra = delta-contrah 0 empty-trie empty-trie
-- postulate: check-beta-inequiv t1 t2 ≡ isJust (delta-contra t1 t2)
check-beta-inequiv : term → term → 𝔹
check-beta-inequiv t1 t2 = isJust (delta-contra t1 t2)
tk-map : tk → (type → type) → (kind → kind) → tk
tk-map (Tkt T) fₜ fₖ = Tkt $ fₜ T
tk-map (Tkk k) fₜ fₖ = Tkk $ fₖ k
tk-map2 : tk → (∀ {ed} → ⟦ ed ⟧ → ⟦ ed ⟧) → tk
tk-map2 atk f = tk-map atk f f
optTerm-map : optTerm → (term → term) → optTerm
optTerm-map NoTerm f = NoTerm
optTerm-map (SomeTerm t pi) f = SomeTerm (f t) pi
optType-map : optType → (type → type) → optType
optType-map NoType f = NoType
optType-map (SomeType T) f = SomeType $ f T
optGuide-map : optGuide → (var → type → type) → optGuide
optGuide-map NoGuide f = NoGuide
optGuide-map (Guide pi x T) f = Guide pi x $ f x T
optClass-map : optClass → (tk → tk) → optClass
optClass-map NoClass f = NoClass
optClass-map (SomeClass atk) f = SomeClass $ f atk
|
{
"alphanum_fraction": 0.6549752076,
"avg_line_length": 36.8531390135,
"ext": "agda",
"hexsha": "50d25037fc1fedd9c144f0a64779d626e3360cff",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "acf691e37210607d028f4b19f98ec26c4353bfb5",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "xoltar/cedille",
"max_forks_repo_path": "src/syntax-util.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "acf691e37210607d028f4b19f98ec26c4353bfb5",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "xoltar/cedille",
"max_issues_repo_path": "src/syntax-util.agda",
"max_line_length": 150,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "acf691e37210607d028f4b19f98ec26c4353bfb5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "xoltar/cedille",
"max_stars_repo_path": "src/syntax-util.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 11486,
"size": 32873
}
|
module SizedPolyIO.Object where
open import Data.Product
open import Level using (_⊔_) renaming (suc to lsuc)
record Interface μ ρ : Set (lsuc (μ ⊔ ρ)) where
field
Method : Set μ
Result : (m : Method) → Set ρ
open Interface public
-- A simple object just returns for a method the response
-- and the object itself
record Object {μ ρ} (i : Interface μ ρ) : Set (μ ⊔ ρ) where
coinductive
field
objectMethod : (m : Method i) → Result i m × Object i
open Object public
|
{
"alphanum_fraction": 0.6857142857,
"avg_line_length": 23.3333333333,
"ext": "agda",
"hexsha": "3d3fd86dc6f55a9e1f4792efb174014130cf7cd0",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z",
"max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "agda/ooAgda",
"max_forks_repo_path": "src/SizedPolyIO/Object.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "agda/ooAgda",
"max_issues_repo_path": "src/SizedPolyIO/Object.agda",
"max_line_length": 59,
"max_stars_count": 23,
"max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "agda/ooAgda",
"max_stars_repo_path": "src/SizedPolyIO/Object.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z",
"num_tokens": 150,
"size": 490
}
|
open import Prelude
module Implicits.Resolution.Stack.Algorithm where
open import Induction.WellFounded
open import Induction.Nat
open import Data.Fin.Substitution
open import Data.Nat.Base using (_<′_)
open import Data.List.Any
open Membership-≡
open import Implicits.Syntax
open import Implicits.Substitutions
open import Implicits.Substitutions.Lemmas
open import Implicits.Resolution.Stack.Resolution
open import Implicits.Resolution.Termination
open import Implicits.Syntax.Type.Unification
open import Function.Inverse as Inv using (_↔_; module Inverse)
open import Function.Equality hiding (cong; flip; const)
open import Data.List.Any.Properties using (Any↔)
open import Data.Nat hiding (_<_)
open import Data.Nat.Properties
open import Relation.Binary using (module DecTotalOrder)
open DecTotalOrder decTotalOrder using () renaming (refl to ≤-refl)
module M = MetaTypeMetaSubst
module Lemmas where
postulate lem₄ : ∀ {m ν} (a : MetaType m (suc ν)) u us → from-meta ((M.open-meta a) M./ (us M.↑) M./ (M.sub u)) ≡ (from-meta (a M./ (us M.↑tp))) tp[/tp from-meta u ]
open Lemmas
_s<'_ : ∀ {ν} → (∃ λ (Δ : ICtx ν) → Stack Δ) → (∃ λ (Δ' : ICtx ν) → Stack Δ') → Set
s s<' t = {!!}
module Arg<-well-founded where
open Lexicographic (_s<_) (const _sρ<_)
arg<-well-founded : Well-founded _<_
arg<-well-founded = well-founded s<-well-founded sρ<-well-founded
_arg<_ = _<_
open Lexicographic using (left; right)
open Arg<-well-founded
{-# NO_TERMINATION_CHECK #-}
mutual
match' : ∀ {m ν ρ} (Δ : ICtx ν) s (r∈Δ : ρ List.∈ Δ) τ → (r : MetaType m ν) →
Acc _arg<_ (s , (, simpl τ)) →
Acc _m<_ (, , r) →
Maybe (∃ λ u → Δ & s , r∈Δ ⊢ from-meta (r M./ u) ↓ τ)
match' Δ s r∈Δ τ (simpl x) (acc f) _ with mgu (simpl x) τ
match' Δ s r∈Δ τ (simpl x) (acc f) _ | just (u , p) =
just (
(asub u) ,
subst (λ a → Δ & s , r∈Δ ⊢ a ↓ τ) (sym $ mgu-unifies (simpl x) τ (u , p)) (i-simp τ)
)
match' Δ s r∈Δ τ (simpl x) (acc f) _ | nothing = nothing
match' Δ s r∈Δ τ (a ⇒ b) (acc f) (acc g) with match' Δ s r∈Δ τ b (acc f) (g _ (b-m<-a⇒b a b))
match' Δ s r∈Δ τ (a ⇒ b) (acc f) (acc g) | nothing = nothing
match' Δ s r∈Δ τ (a ⇒ b) (acc f) (acc g) | just (u , b/u↓τ) with
(from-meta (a M./ u)) for r∈Δ ?⊬dom s
match' Δ s r∈Δ τ (a ⇒ b) (acc f) (acc g) | just (u , b/u↓τ) | yes p
with
let a' = from-meta (a M./ u) in
let s' = (s push a' for r∈Δ) in
resolve' Δ s' a' (f (s' , _ , a') (left {!!}))
match' Δ s r∈Δ τ (a ⇒ b) (acc f) (acc g) | just (u , b/u↓τ) | yes p | just ⊢ᵣa = just (u , i-iabs p ⊢ᵣa b/u↓τ)
match' Δ s r∈Δ τ (a ⇒ b) (acc f) (acc g) | just (u , b/u↓τ) | yes p | nothing = nothing
match' Δ s r∈Δ τ (a ⇒ b) (acc f) (acc g) | just (u , b/u↓τ) | no ¬p = nothing
-- The following with clause fails to satisfy termination checking.
-- Somehow we have to prove to Agda that (open-meta a) is structurally smaller than (∀' a)
match' Δ s r∈Δ τ (∀' a) (acc f) (acc g) with
match' Δ s r∈Δ τ (open-meta a) (acc f) (g _ (open-meta-a-m<-∀'a a))
match' Δ s r∈Δ τ (∀' a) (acc f) (acc g) | just p = just $ lem p
where
lem : (∃ λ u → Δ & s , r∈Δ ⊢ (from-meta ((open-meta a) M./ u)) ↓ τ) →
∃ λ u' → Δ & s , r∈Δ ⊢ (from-meta (∀' a M./ u')) ↓ τ
lem (u ∷ us , p) = us , (i-tabs (from-meta u) (subst (λ v → Δ & s , r∈Δ ⊢ v ↓ τ) (begin
from-meta (M._/_ (open-meta a) (u ∷ us))
≡⟨ cong (λ v → from-meta (M._/_ (open-meta a) v)) (sym $ us↑-⊙-sub-u≡u∷us u us) ⟩
from-meta ((open-meta a) M./ (us M.↑ M.⊙ (M.sub u)))
≡⟨ cong from-meta (/-⊙ (open-meta a)) ⟩
from-meta ((open-meta a) M./ us M.↑ M./ (M.sub u))
≡⟨ lem₄ a u us ⟩
from-meta (a M./ (us M.↑tp)) tp[/tp from-meta u ] ∎) p))
where open MetaTypeMetaLemmas hiding (subst)
match' Δ s r∈Δ τ (∀' r) (acc f) (acc g) | nothing = nothing
-- match defers to match', which concerns itself with MetaTypes.
-- If match' finds a match, we can use the fact that we have zero unification variables open here
-- to show that we found the right thing.
match : ∀ {ν ρ} (Δ : ICtx ν) s (r∈Δ : ρ List.∈ Δ) r τ → Acc _arg<_ (s , _ , simpl τ) →
Maybe (Δ & s , r∈Δ ⊢ r ↓ τ)
match Δ s r∈Δ a τ ac with match' Δ s r∈Δ τ (to-meta {zero} a) ac (m<-well-founded _)
match Δ s r∈Δ a τ ac | just x = just (lem x)
where
eq : ∀ {ν} {a : Type ν} {s} → from-meta (to-meta {zero} a M./ s) ≡ a
eq {a = a} {s = []} = begin
from-meta (M._/_ (to-meta {zero} a) [])
≡⟨ cong (λ q → from-meta q) (MetaTypeMetaLemmas.id-vanishes (to-meta {zero} a)) ⟩
from-meta (to-meta {zero} a)
≡⟨ to-meta-zero-vanishes ⟩
a ∎
lem : ∃ (λ u → Δ & s , r∈Δ ⊢ from-meta (to-meta {zero} a M./ u) ↓ τ) →
Δ & s , r∈Δ ⊢ a ↓ τ
lem ([] , proj₂) = subst (λ u → Δ & s , r∈Δ ⊢ u ↓ τ) eq proj₂
match Δ s r∈Δ a τ ac | nothing = nothing
match1st : ∀ {ν} (Δ : ICtx ν) (s : Stack Δ) τ → Acc _arg<_ (s , _ , simpl τ) →
Maybe (∃₂ λ r (r∈Δ : r List.∈ Δ) → Δ & s , r∈Δ ⊢ r ↓ τ)
match1st Δ s τ ac = match1st' Δ Δ Prelude.id s τ ac -- any (λ r → match Δ r τ)
where
match1st' : ∀ {ν} (Δ ρs : ICtx ν) → ρs ⊆ Δ → (s : Stack Δ) → (τ : SimpleType ν) →
Acc _arg<_ (s , _ , simpl τ) →
Maybe (∃₂ λ r (r∈Δ : r List.∈ Δ) → Δ & s , r∈Δ ⊢ r ↓ τ)
match1st' Δ List.[] sub s τ ac = nothing
match1st' Δ (x List.∷ xs) sub s τ ac with match Δ s (sub (here refl)) x τ ac
match1st' Δ (x List.∷ xs) sub s τ ac | just px = just (x , ((sub (here refl)) , px))
match1st' Δ (x List.∷ xs) sub s τ ac | nothing with
match1st' Δ xs {!!} s τ ac
match1st' Δ (x List.∷ xs) sub s τ ac | nothing | just p = just p
match1st' Δ (x List.∷ xs) sub s τ ac | nothing | nothing = nothing
resolve' : ∀ {ν} (Δ : ICtx ν) s r → Acc _arg<_ (s , _ , r) → (Maybe (Δ & s ⊢ᵣ r))
resolve' Δ s (simpl x) ac with match1st Δ s x ac
resolve' Δ s (simpl x) ac | just (_ , r∈Δ , r↓x) = just (r-simp r∈Δ r↓x)
resolve' Δ s (simpl x) ac | nothing = nothing
-- no (λ{ (r-simp x₁ x₂) → ¬p (_⟨$⟩_ (Inverse.to Any↔) (_ , (x₁ , x₂))) })
resolve' Δ s (a ⇒ b) (acc f) with resolve' (a List.∷ Δ) (s prepend a) b {!f!}
resolve' Δ s (a ⇒ b) (acc f) | just p = just (r-iabs p)
resolve' Δ s (a ⇒ b) (acc f) | nothing = nothing -- no (λ{ (r-iabs x) → ¬p x })
resolve' Δ s (∀' r) (acc f) with resolve' (ictx-weaken Δ) (stack-weaken s) r {!f ? ?!}
resolve' Δ s (∀' r) (acc f) | just p = just (r-tabs p)
resolve' Δ s (∀' r) (acc f) | nothing = nothing --no (λ{ (r-tabs x) → ¬p x })
resolve : ∀ {ν} (Δ : ICtx ν) r → (Maybe (Δ ⊢ᵣ r))
resolve Δ r = resolve' Δ (All.tabulate (const r)) r (arg<-well-founded _)
|
{
"alphanum_fraction": 0.5447585395,
"avg_line_length": 47.4965034965,
"ext": "agda",
"hexsha": "5f9b8361af298497f0b47011acb5f8066e037379",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "metaborg/ts.agda",
"max_forks_repo_path": "src/Implicits/Resolution/Stack/Algorithm.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "metaborg/ts.agda",
"max_issues_repo_path": "src/Implicits/Resolution/Stack/Algorithm.agda",
"max_line_length": 167,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "metaborg/ts.agda",
"max_stars_repo_path": "src/Implicits/Resolution/Stack/Algorithm.agda",
"max_stars_repo_stars_event_max_datetime": "2021-05-07T04:08:41.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-04-05T17:57:11.000Z",
"num_tokens": 2730,
"size": 6792
}
|
{-# OPTIONS --cubical-compatible #-}
module Common.Bool where
open import Agda.Builtin.Bool public
not : Bool -> Bool
not true = false
not false = true
notnot : Bool -> Bool
notnot true = not (not true)
notnot false = not (not false)
if_then_else_ : ∀ {a} {A : Set a} → Bool → A → A → A
if true then t else f = t
if false then t else f = f
|
{
"alphanum_fraction": 0.6551724138,
"avg_line_length": 19.3333333333,
"ext": "agda",
"hexsha": "0b23c146cc2c04909f07dd492cef030970354b0d",
"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/Common/Bool.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/Common/Bool.agda",
"max_line_length": 52,
"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/Common/Bool.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 108,
"size": 348
}
|
{- This file shows a natural attempt to do formatted printing, and where
that attempt goes wrong. See string-format.agda for a (working) solution
to this problem. -}
module string-format-issue where
open import char
open import eq
open import list
open import nat
open import nat-to-string
open import string
format-th : 𝕃 char → Set
format-th ('%' :: 'n' :: f) = ℕ → format-th f
format-th ('%' :: 's' :: f) = string → format-th f
format-th (c :: f) = format-th f
format-th [] = string
format-t : string → Set
format-t s = format-th (string-to-𝕃char s)
test-format-t : format-t "The %n% %s are %s." ≡ (ℕ → string → string → string)
test-format-t = refl
format-h : 𝕃 char → (f : 𝕃 char) → format-th f
format-h s ('%' :: 'n' :: f) = λ n → format-h (s ++ (string-to-𝕃char (ℕ-to-string n))) f
format-h s ('%' :: 's' :: f) = λ s' → format-h (s ++ (string-to-𝕃char s')) f
format-h s (c :: f) = {!!}
format-h s [] = 𝕃char-to-string s
format : (f : string) → format-t f
format f = format-h [] (string-to-𝕃char f)
|
{
"alphanum_fraction": 0.6209598433,
"avg_line_length": 29.1714285714,
"ext": "agda",
"hexsha": "e28ac162e0a0829e337565a333093527506bbf9f",
"lang": "Agda",
"max_forks_count": 17,
"max_forks_repo_forks_event_max_datetime": "2021-11-28T20:13:21.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-12-03T22:38:15.000Z",
"max_forks_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "rfindler/ial",
"max_forks_repo_path": "string-format-issue.agda",
"max_issues_count": 8,
"max_issues_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6",
"max_issues_repo_issues_event_max_datetime": "2022-03-22T03:43:34.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-07-09T22:53:38.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "rfindler/ial",
"max_issues_repo_path": "string-format-issue.agda",
"max_line_length": 88,
"max_stars_count": 29,
"max_stars_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "rfindler/ial",
"max_stars_repo_path": "string-format-issue.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-04T15:05:12.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-02-06T13:09:31.000Z",
"num_tokens": 341,
"size": 1021
}
|
{-# 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.Prespectrum where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Pointed
open import Cubical.Data.Unit.Pointed
open import Cubical.Structures.Successor
open import Cubical.Data.Nat
open import Cubical.Data.Int
open import Cubical.HITs.Susp
open import Cubical.Homotopy.Loopspace
private
variable
ℓ ℓ' : Level
record GenericPrespectrum (S : SuccStr ℓ) (ℓ' : Level) : Type (ℓ-max (ℓ-suc ℓ') ℓ) where
open SuccStr S
field
space : Index → Pointed ℓ'
map : (i : Index) → (space i →∙ Ω (space (succ i)))
Prespectrum = GenericPrespectrum ℤ+
Unit∙→ΩUnit∙ : {ℓ : Level} → (Unit∙ {ℓ = ℓ}) →∙ Ω (Unit∙ {ℓ = ℓ})
Unit∙→ΩUnit∙ = (λ {tt* → refl}) , refl
makeℤPrespectrum : (space : ℕ → Pointed ℓ)
(map : (i : ℕ) → (space i) →∙ Ω (space (suc i)))
→ Prespectrum ℓ
GenericPrespectrum.space (makeℤPrespectrum space map) (pos n) = space n
GenericPrespectrum.space (makeℤPrespectrum space map) (negsuc n) = Unit∙
GenericPrespectrum.map (makeℤPrespectrum space map) (pos n) = map n
GenericPrespectrum.map (makeℤPrespectrum space map) (negsuc zero) = (λ {tt* → refl}) , refl
GenericPrespectrum.map (makeℤPrespectrum space map) (negsuc (suc n)) = Unit∙→ΩUnit∙
SuspensionPrespectrum : Pointed ℓ → Prespectrum ℓ
SuspensionPrespectrum A = makeℤPrespectrum space map
where
space : ℕ → Pointed _
space zero = A
space (suc n) = Susp∙ (typ (space n))
map : (n : ℕ) → _
map n = toSuspPointed (space n)
|
{
"alphanum_fraction": 0.6730769231,
"avg_line_length": 32.1454545455,
"ext": "agda",
"hexsha": "7e41ae0d5c203282fbafcbd877fe844a966e8d4a",
"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/Prespectrum.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/Prespectrum.agda",
"max_line_length": 91,
"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/Prespectrum.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": 578,
"size": 1768
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Alternative definition of divisibility without using modulus.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Integer.Divisibility.Signed where
open import Function
open import Data.Integer
open import Data.Integer.Properties
open import Data.Integer.Divisibility as Unsigned
using (divides)
renaming (_∣_ to _∣ᵤ_)
import Data.Nat as ℕ
import Data.Nat.Divisibility as ℕ
import Data.Nat.Coprimality as ℕ
import Data.Nat.Properties as ℕ
import Data.Sign as S
import Data.Sign.Properties as SProp
open import Level
open import Relation.Binary
open import Relation.Binary.PropositionalEquality
import Relation.Binary.Reasoning.Preorder as PreorderReasoning
open import Relation.Nullary using (yes; no)
import Relation.Nullary.Decidable as DEC
------------------------------------------------------------------------
-- Type
infix 4 _∣_
record _∣_ (k z : ℤ) : Set where
constructor divides
field quotient : ℤ
equality : z ≡ quotient * k
open _∣_ using (quotient) public
------------------------------------------------------------------------
-- Conversion between signed and unsigned divisibility
∣ᵤ⇒∣ : ∀ {k i} → k ∣ᵤ i → k ∣ i
∣ᵤ⇒∣ {k} {i} (divides 0 eq) = divides (+ 0) (∣n∣≡0⇒n≡0 eq)
∣ᵤ⇒∣ {k} {i} (divides q@(ℕ.suc q') eq) with k ≟ + 0
... | yes refl = divides (+ 0) (∣n∣≡0⇒n≡0 (trans eq (ℕ.*-zeroʳ q)))
... | no ¬k≠0 = divides ((S._*_ on sign) i k ◃ q) (◃-≡ sign-eq abs-eq) where
k' = ℕ.suc (ℕ.pred ∣ k ∣)
ikq' = sign i S.* sign k ◃ ℕ.suc q'
sign-eq : sign i ≡ sign (((S._*_ on sign) i k ◃ q) * k)
sign-eq = sym $ begin
sign (((S._*_ on sign) i k ◃ ℕ.suc q') * k)
≡⟨ cong (λ m → sign (sign ikq' S.* sign k ◃ ∣ ikq' ∣ ℕ.* m))
(sym (ℕ.m≢0⇒suc[pred[m]]≡m (¬k≠0 ∘ ∣n∣≡0⇒n≡0))) ⟩
sign (sign ikq' S.* sign k ◃ ∣ ikq' ∣ ℕ.* k')
≡⟨ cong (λ m → sign (sign ikq' S.* sign k ◃ m ℕ.* k'))
(abs-◃ (sign i S.* sign k) (ℕ.suc q')) ⟩
sign (sign ikq' S.* sign k ◃ _)
≡⟨ sign-◃ (sign ikq' S.* sign k) (ℕ.pred ∣ k ∣ ℕ.+ q' ℕ.* k') ⟩
sign ikq' S.* sign k
≡⟨ cong (S._* sign k) (sign-◃ (sign i S.* sign k) q') ⟩
sign i S.* sign k S.* sign k
≡⟨ SProp.*-assoc (sign i) (sign k) (sign k) ⟩
sign i S.* (sign k S.* sign k)
≡⟨ cong (sign i S.*_) (SProp.s*s≡+ (sign k)) ⟩
sign i S.* S.+
≡⟨ SProp.*-identityʳ (sign i) ⟩
sign i
∎ where open ≡-Reasoning
abs-eq : ∣ i ∣ ≡ ∣ ((S._*_ on sign) i k ◃ q) * k ∣
abs-eq = sym $ begin
∣ ((S._*_ on sign) i k ◃ ℕ.suc q') * k ∣
≡⟨ abs-◃ (sign ikq' S.* sign k) (∣ ikq' ∣ ℕ.* ∣ k ∣) ⟩
∣ ikq' ∣ ℕ.* ∣ k ∣
≡⟨ cong (ℕ._* ∣ k ∣) (abs-◃ (sign i S.* sign k) (ℕ.suc q')) ⟩
ℕ.suc q' ℕ.* ∣ k ∣
≡⟨ sym eq ⟩
∣ i ∣
∎ where open ≡-Reasoning
∣⇒∣ᵤ : ∀ {k i} → k ∣ i → k ∣ᵤ i
∣⇒∣ᵤ {k} {i} (divides q eq) = divides ∣ q ∣ $′ begin
∣ i ∣ ≡⟨ cong ∣_∣ eq ⟩
∣ q * k ∣ ≡⟨ abs-*-commute q k ⟩
∣ q ∣ ℕ.* ∣ k ∣ ∎ where open ≡-Reasoning
------------------------------------------------------------------------
-- _∣_ is a preorder
∣-refl : Reflexive _∣_
∣-refl = ∣ᵤ⇒∣ ℕ.∣-refl
∣-reflexive : _≡_ ⇒ _∣_
∣-reflexive refl = ∣-refl
∣-trans : Transitive _∣_
∣-trans i∣j j∣k = ∣ᵤ⇒∣ (ℕ.∣-trans (∣⇒∣ᵤ i∣j) (∣⇒∣ᵤ j∣k))
∣-isPreorder : IsPreorder _≡_ _∣_
∣-isPreorder = record
{ isEquivalence = isEquivalence
; reflexive = ∣-reflexive
; trans = ∣-trans
}
∣-preorder : Preorder _ _ _
∣-preorder = record { isPreorder = ∣-isPreorder }
module ∣-Reasoning = PreorderReasoning ∣-preorder
hiding (_≈⟨_⟩_)
renaming (_∼⟨_⟩_ to _∣⟨_⟩_)
------------------------------------------------------------------------
-- Other properties of _∣_
_∣?_ : Decidable _∣_
k ∣? m = DEC.map′ ∣ᵤ⇒∣ ∣⇒∣ᵤ (∣ k ∣ ℕ.∣? ∣ m ∣)
0∣⇒≡0 : ∀ {m} → + 0 ∣ m → m ≡ + 0
0∣⇒≡0 0|m = ∣n∣≡0⇒n≡0 (ℕ.0∣⇒≡0 (∣⇒∣ᵤ 0|m))
m∣∣m∣ : ∀ {m} → m ∣ (+ ∣ m ∣)
m∣∣m∣ = ∣ᵤ⇒∣ ℕ.∣-refl
∣m∣∣m : ∀ {m} → (+ ∣ m ∣) ∣ m
∣m∣∣m = ∣ᵤ⇒∣ ℕ.∣-refl
∣m∣n⇒∣m+n : ∀ {i m n} → i ∣ m → i ∣ n → i ∣ m + n
∣m∣n⇒∣m+n (divides q refl) (divides p refl) =
divides (q + p) (sym (*-distribʳ-+ _ q p))
∣m⇒∣-m : ∀ {i m} → i ∣ m → i ∣ - m
∣m⇒∣-m {i} {m} i∣m = ∣ᵤ⇒∣ $′ begin
∣ i ∣ ∣⟨ ∣⇒∣ᵤ i∣m ⟩
∣ m ∣ ≡⟨ sym (∣-n∣≡∣n∣ m) ⟩
∣ - m ∣ ∎
where open ℕ.∣-Reasoning
∣m∣n⇒∣m-n : ∀ {i m n} → i ∣ m → i ∣ n → i ∣ m - n
∣m∣n⇒∣m-n i∣m i∣n = ∣m∣n⇒∣m+n i∣m (∣m⇒∣-m i∣n)
∣m+n∣m⇒∣n : ∀ {i m n} → i ∣ m + n → i ∣ m → i ∣ n
∣m+n∣m⇒∣n {i} {m} {n} i∣m+n i∣m = begin
i ∣⟨ ∣m∣n⇒∣m-n i∣m+n i∣m ⟩
m + n - m ≡⟨ +-comm (m + n) (- m) ⟩
- m + (m + n) ≡⟨ sym (+-assoc (- m) m n) ⟩
- m + m + n ≡⟨ cong (_+ n) (+-inverseˡ m) ⟩
+ 0 + n ≡⟨ +-identityˡ n ⟩
n ∎
where open ∣-Reasoning
∣m+n∣n⇒∣m : ∀ {i m n} → i ∣ m + n → i ∣ n → i ∣ m
∣m+n∣n⇒∣m {i} {m} {n} i|m+n i|n
rewrite +-comm m n
= ∣m+n∣m⇒∣n i|m+n i|n
∣n⇒∣m*n : ∀ {i} m {n} → i ∣ n → i ∣ m * n
∣n⇒∣m*n {i} m {n} (divides q eq) = divides (m * q) $′ begin
m * n ≡⟨ cong (m *_) eq ⟩
m * (q * i) ≡⟨ sym (*-assoc m q i) ⟩
m * q * i ∎
where open ≡-Reasoning
∣m⇒∣m*n : ∀ {i m} n → i ∣ m → i ∣ m * n
∣m⇒∣m*n {i} {m} n i|m
rewrite *-comm m n
= ∣n⇒∣m*n {i} n {m} i|m
*-monoʳ-∣ : ∀ k → (k *_) Preserves _∣_ ⟶ _∣_
*-monoʳ-∣ k i∣j = ∣ᵤ⇒∣ (Unsigned.*-monoʳ-∣ k (∣⇒∣ᵤ i∣j))
*-monoˡ-∣ : ∀ k → (_* k) Preserves _∣_ ⟶ _∣_
*-monoˡ-∣ k {i} {j} i∣j = ∣ᵤ⇒∣ (Unsigned.*-monoˡ-∣ k {i} {j} (∣⇒∣ᵤ i∣j))
*-cancelˡ-∣ : ∀ k {i j} → k ≢ + 0 → k * i ∣ k * j → i ∣ j
*-cancelˡ-∣ k k≢0 = ∣ᵤ⇒∣ ∘ Unsigned.*-cancelˡ-∣ k k≢0 ∘ ∣⇒∣ᵤ
*-cancelʳ-∣ : ∀ k {i j} → k ≢ + 0 → i * k ∣ j * k → i ∣ j
*-cancelʳ-∣ k {i} {j} k≢0 = ∣ᵤ⇒∣ ∘′ Unsigned.*-cancelʳ-∣ k {i} {j} k≢0 ∘′ ∣⇒∣ᵤ
|
{
"alphanum_fraction": 0.448908902,
"avg_line_length": 31.3804347826,
"ext": "agda",
"hexsha": "494eef8291861dab72e967a37143b1a594fe704b",
"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/Integer/Divisibility/Signed.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/Integer/Divisibility/Signed.agda",
"max_line_length": 78,
"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/Integer/Divisibility/Signed.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2975,
"size": 5774
}
|
module Numeral.Natural.Relation.Order.Classical where
import Lvl
open import Logic.Propositional
open import Numeral.Natural
open import Numeral.Natural.Relation.Order
open import Numeral.Natural.Relation.Order.Decidable
open import Numeral.Natural.Relation.Order.Proofs
open import Relator.Equals
open import Relator.Equals.Proofs
open import Structure.Relator.Properties
open import Relator.Ordering.Proofs
open import Type.Properties.Decidable.Proofs
open import Type
instance
[≰][>]-sub : (_≰_) ⊆₂ (_>_)
[≰][>]-sub = From-[≤][<].ByReflTriSub.[≰][>]-sub (_≤_)(_<_) ⦃ [<][≤]-sub = intro(sub₂(_<_)(_≤_)) ⦄ ⦃ [<]-classical = decider-classical _ ⦄
instance
[≯][≤]-sub : (_≯_) ⊆₂ (_≤_)
[≯][≤]-sub = From-[≤][<].ByReflTriSub.[≯][≤]-sub (_≤_)(_<_) ⦃ [<][≤]-sub = intro(sub₂(_<_)(_≤_)) ⦄ ⦃ [≤]-classical = decider-classical _ ⦄
instance
[≱][<]-sub : (_≱_) ⊆₂ (_<_)
[≱][<]-sub = From-[≤][<].ByReflTriSub.[≱][<]-sub (_≤_)(_<_) ⦃ [<][≤]-sub = intro(sub₂(_<_)(_≤_)) ⦄ ⦃ [<]-classical = decider-classical _ ⦄
instance
[≮][≥]-sub : (_≮_) ⊆₂ (_≥_)
[≮][≥]-sub = From-[≤][<].ByReflTriSub.[≮][≥]-sub (_≤_)(_<_) ⦃ [<][≤]-sub = intro(sub₂(_<_)(_≤_)) ⦄ ⦃ [≤]-classical = decider-classical _ ⦄
[≤]-or-[>] : ∀{a b : ℕ} → (a ≤ b) ∨ (a > b)
[≤]-or-[>] = From-[≤][<].ByReflTriSub.[≤]-or-[>] (_≤_)(_<_) ⦃ [<][≤]-sub = intro(sub₂(_<_)(_≤_)) ⦄ ⦃ [≤]-classical = decider-classical _ ⦄ ⦃ [<]-classical = decider-classical _ ⦄
[≥]-or-[<] : ∀{a b : ℕ} → (a ≥ b) ∨ (a < b)
[≥]-or-[<] = From-[≤][<].ByReflTriSub.[≥]-or-[<] (_≤_)(_<_) ⦃ [<][≤]-sub = intro(sub₂(_<_)(_≤_)) ⦄ ⦃ [≤]-classical = decider-classical _ ⦄ ⦃ [<]-classical = decider-classical _ ⦄
|
{
"alphanum_fraction": 0.5742092457,
"avg_line_length": 44.4324324324,
"ext": "agda",
"hexsha": "1283623cd7d638ee7eebcb463b8e2e1386f3877c",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Numeral/Natural/Relation/Order/Classical.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Numeral/Natural/Relation/Order/Classical.agda",
"max_line_length": 178,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Numeral/Natural/Relation/Order/Classical.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": 746,
"size": 1644
}
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Algebra.Base where
open import Cubical.Core.Everything
------------------------------------------------------------------------
-- Unary and binary operations
Op₁ : ∀ {ℓ} → Type ℓ → Type ℓ
Op₁ A = A → A
Op₂ : ∀ {ℓ} → Type ℓ → Type ℓ
Op₂ A = A → A → A
------------------------------------------------------------------------
-- Left and right actions
Opₗ : ∀ {a b} → Type a → Type b → Type _
Opₗ A B = A → B → B
Opᵣ : ∀ {a b} → Type a → Type b → Type _
Opᵣ A B = B → A → B
|
{
"alphanum_fraction": 0.423853211,
"avg_line_length": 23.6956521739,
"ext": "agda",
"hexsha": "6a51daa2b67604241c5faca49481b1c0d5691a4a",
"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/Algebra/Base.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/Algebra/Base.agda",
"max_line_length": 72,
"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/Algebra/Base.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 161,
"size": 545
}
|
------------------------------------------------------------------------
-- Safe modules that use --erased-cubical and --prop
------------------------------------------------------------------------
{-# OPTIONS --safe --erased-cubical --prop #-}
module README.Safe.Cubical.Erased.Prop where
-- Squashing.
import Squash
|
{
"alphanum_fraction": 0.386996904,
"avg_line_length": 26.9166666667,
"ext": "agda",
"hexsha": "1686b2d273976a73a328f0d5fe22b7fbc344acca",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/equality",
"max_forks_repo_path": "README/Safe/Cubical/Erased/Prop.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/equality",
"max_issues_repo_path": "README/Safe/Cubical/Erased/Prop.agda",
"max_line_length": 72,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/equality",
"max_stars_repo_path": "README/Safe/Cubical/Erased/Prop.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z",
"num_tokens": 52,
"size": 323
}
|
open import Agda.Primitive using (lzero; lsuc; _⊔_)
open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; trans; cong; cong₂; subst; setoid)
open import Data.Product using (_×_; Σ; _,_; proj₁; proj₂; zip; map; <_,_>; swap)
import Function.Equality
open import Relation.Binary using (Setoid)
import Relation.Binary.Reasoning.Setoid as SetoidR
import Categories.Category
import Categories.Functor
import Categories.Category.Instance.Setoids
import Categories.Monad.Relative
import Categories.Category.Equivalence
import Categories.Category.Cocartesian
import Categories.Category.Construction.Functors
import Categories.Category.Product
import Categories.NaturalTransformation
import Categories.NaturalTransformation.NaturalIsomorphism
import SecondOrder.Arity
import SecondOrder.Signature
import SecondOrder.Metavariable
import SecondOrder.VRenaming
import SecondOrder.MRenaming
import SecondOrder.Term
import SecondOrder.Substitution
import SecondOrder.RelativeMonadMorphism
import SecondOrder.Instantiation
import SecondOrder.IndexedCategory
import SecondOrder.RelativeKleisli
import SecondOrder.Mslot
import SecondOrder.MRelativeMonad
import SecondOrder.VRelativeMonad
module SecondOrder.VRelMonMorphism
{ℓ}
{𝔸 : SecondOrder.Arity.Arity}
(Σ : SecondOrder.Signature.Signature ℓ 𝔸)
where
open SecondOrder.RelativeMonadMorphism
open SecondOrder.Metavariable Σ
open SecondOrder.VRelativeMonad Σ
open SecondOrder.Instantiation Σ
open SecondOrder.MRenaming Σ
open SecondOrder.VRenaming Σ
open SecondOrder.Term Σ
open SecondOrder.Substitution Σ
-- In this file, the goal is to show that given two variable relative monads
-- on different metacontexts, metarenaming from one of the metacontexts to the other
-- we can define a relative monad morphism between the two variable relative monads
Fⱽ : ∀ (Θ Θ′ : MContext) (μ : Θ ⇒ᵐ Θ′) → RMonadMorph (VMonad {Θ}) (VMonad {Θ′})
Fⱽ Θ Θ′ μ = record
{ morph = λ A →
record
{ _⟨$⟩_ = [ μ ]ᵐ_
; cong = λ s≈t → []ᵐ-resp-≈ s≈t
}
; law-unit = λ A x≡y → ≈-≡ (σ-resp-≡ {σ = tm-var} x≡y)
; law-extend = λ {Γ} {Δ} {k} A {s} {t} s≈t →
≈-trans
(≈-sym ([ᵐ∘ˢ] s))
(≈-trans
([]ˢ-resp-≈ˢ ([ μ ]ᵐ s) λ x → ≈-refl )
([]ˢ-resp-≈ (λ {B} x → [ μ ]ᵐ (k B Function.Equality.⟨$⟩ x)) ([]ᵐ-resp-≈ s≈t)))
}
|
{
"alphanum_fraction": 0.6498493976,
"avg_line_length": 38.4927536232,
"ext": "agda",
"hexsha": "c5856fe59e30c160bdfd614aa8657a2145049de3",
"lang": "Agda",
"max_forks_count": 6,
"max_forks_repo_forks_event_max_datetime": "2021-05-24T02:51:43.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-02-16T13:43:07.000Z",
"max_forks_repo_head_hexsha": "0a9d25e6e3965913d9b49a47c88cdfb94b55ffeb",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cilinder/formaltt",
"max_forks_repo_path": "src/SecondOrder/VRelMonMorphism.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "0a9d25e6e3965913d9b49a47c88cdfb94b55ffeb",
"max_issues_repo_issues_event_max_datetime": "2021-05-14T16:15:17.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-04-30T14:18:25.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cilinder/formaltt",
"max_issues_repo_path": "src/SecondOrder/VRelMonMorphism.agda",
"max_line_length": 126,
"max_stars_count": 21,
"max_stars_repo_head_hexsha": "0a9d25e6e3965913d9b49a47c88cdfb94b55ffeb",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cilinder/formaltt",
"max_stars_repo_path": "src/SecondOrder/VRelMonMorphism.agda",
"max_stars_repo_stars_event_max_datetime": "2021-11-19T15:50:08.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-02-16T14:07:06.000Z",
"num_tokens": 745,
"size": 2656
}
|
module Example1 where
data Nat : Set where
zero : Nat
suc : Nat -> Nat
{-# BUILTIN NATURAL Nat #-}
data _==_ {l} {a : Set l} : a -> a -> Set l where
refl : ∀{x} -> x == x
{-# BUILTIN EQUALITY _==_ #-}
cong : ∀{l} -> {A B : Set l} {x y : A} -> (f : A -> B) -> x == y -> f x == f y
cong f refl = refl
sym : ∀{l} {A : Set l} {x y : A} -> x == y -> y == x
sym refl = refl
_+_ : Nat -> Nat -> Nat
x + zero = x
x + suc y = suc (x + y)
_+₂_ : Nat -> Nat -> Nat
zero +₂ y = y
suc x +₂ y = {!!}
plus-right-identity : ∀{n} -> (n + 0) == n
plus-right-identity {n} = refl
plus-left-identity : (n : Nat) -> (0 + n) == n
plus-left-identity zero = refl
plus-left-identity (suc n) = cong suc (plus-left-identity n)
plus-comm : (m n : Nat) -> (m + n) == (n + m)
plus-comm m zero = sym (plus-left-identity m)
plus-comm m (suc n) = {!!}
plus-succ : ∀{m n} -> (m + suc n) == suc (m + n)
plus-succ = refl
data Vec (A : Set) : Nat -> Set where
[] : Vec A 0
_∷_ : ∀{n} -> A -> Vec A n -> Vec A (suc n)
replicate : ∀{A} -> (n : Nat) -> A -> Vec A n
replicate zero x = []
replicate (suc n) x = x ∷ replicate n x
data Pair (A B : Set) : Set where
_,_ : A -> B -> Pair A B
zip : ∀{n A B} -> Vec A n -> Vec B n -> Vec (Pair A B) n
zip [] ys = []
zip {suc n} (x ∷ xs) (y ∷ ys) = replicate (suc n) (x , y)
map : ∀{n A B} -> (A -> B) -> Vec A n -> Vec B n
map f [] = []
map {suc n} f (x ∷ xs) = (f x) ∷ (map f xs) -- f x ∷ map f xs -- replicate (suc n) (f x)
id : {A : Set} -> A -> A
id x = x
map-id : ∀{n A} (xs : Vec A n) -> map id xs == xs
map-id [] = refl
map-id (x ∷ xs) = cong (_∷_ x) (map-id xs)
data Bool : Set where
false true : Bool
not : Bool -> Bool
not false = true
not true = false
not-self-inverse : {x : Bool} -> not (not x) == x
not-self-inverse {false} = refl
not-self-inverse {true} = refl
data Empty : Set where
not-not-id : {x : Bool} -> not x == id x -> Empty
not-not-id {false} ()
not-not-id {true} ()
|
{
"alphanum_fraction": 0.5095706156,
"avg_line_length": 23.0119047619,
"ext": "agda",
"hexsha": "5586865352c18aab03db173bf77f5015c6dc1174",
"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": "baf979ef78b5ec0f4783240b03f9547490bc5d42",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "carlostome/martin",
"max_forks_repo_path": "doc/Example1.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "baf979ef78b5ec0f4783240b03f9547490bc5d42",
"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": "carlostome/martin",
"max_issues_repo_path": "doc/Example1.agda",
"max_line_length": 88,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "baf979ef78b5ec0f4783240b03f9547490bc5d42",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "carlostome/martin",
"max_stars_repo_path": "doc/Example1.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 766,
"size": 1933
}
|
module Issue482 where
open import Common.Level using (_⊔_)
postulate
P : ∀ a b → Set a → Set b → Set (a ⊔ b)
F : ∀ ℓ → Set ℓ
p : ∀ a (A : Set a) → P a a A (F a)
Q : ∀ a → Set a → ∀ b → Set (a ⊔ b)
P-to-Q : ∀ a b (A : Set a) (B : Set b) → P a b A B → Q a A b
q : ∀ a (A : Set a) → Q a A _
q a A = P-to-Q _ _ _ _ (p _ _)
{-
There was a bug in the level constraint solver that looks
at pairs of constraints.
-}
|
{
"alphanum_fraction": 0.4910714286,
"avg_line_length": 21.3333333333,
"ext": "agda",
"hexsha": "f78069593b8063ecf296ebe45999e3ddb2789863",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "test/succeed/Issue482.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "test/succeed/Issue482.agda",
"max_line_length": 62,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "test/succeed/Issue482.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": 180,
"size": 448
}
|
{-# OPTIONS --cubical --safe #-}
module Demos.Cantor where
open import Prelude
open import Data.Bool.Properties using (false≢true; true≢false)
Stream : Type a → Type a
Stream A = ℕ → A
_∈_ : ∀ {A : Type a} (x : A) → Stream A → Type a
x ∈ xs = ∃ i × (xs i ≡ x)
Countable : Type a → Type a
Countable A = Σ[ xs ⦂ Stream A ] × (∀ x → x ∈ xs)
x≢¬x : ∀ x → x ≢ not x
x≢¬x false = false≢true
x≢¬x true = true≢false
cantor : ¬ (Countable (Stream Bool))
cantor (support , cover) =
let p , ps = cover (λ i → not (support i i))
q = cong (_$ p) ps
in x≢¬x _ q
|
{
"alphanum_fraction": 0.5795053004,
"avg_line_length": 21.7692307692,
"ext": "agda",
"hexsha": "22f39244a257302012a37762afefd41bf6a9de36",
"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": "Demos/Cantor.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": "Demos/Cantor.agda",
"max_line_length": 63,
"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": "Demos/Cantor.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": 218,
"size": 566
}
|
{-# OPTIONS --rewriting --prop #-}
open import common
open import syntx
{- The sort corresponding to judgments -}
data JudgmentSort : Set where
Ty : JudgmentSort
Tm : JudgmentSort
Ty= : JudgmentSort
Tm= : JudgmentSort
JudgmentArityArgs = ArityArgs JudgmentSort
JudgmentArity = Arity JudgmentSort
{-
Judgments are indexed by the signature, their ambient context, the length of their local context,
and their sort.
We can see judgments as consisting of two contexts, one normal context (the ambient context) and
then one dependent context (the local context). The reason is that all typing rules occur in an
ambient context which never changes, and sometimes add new assumptions (to the local context).
Therefore we will never have to check that the ambient contexts are equal, it will be forced by the
typing.
Indexing judgments by sorts is very good to get rid of absurd cases, when giving typing rules and
that some judgments are supposed to have certain sorts.
-}
data Judgment (Σ : Signature) {m : ℕ} (Γ : Ctx Σ m) (n : ℕ) : JudgmentSort → Set where
_⊢_ : (Δ : DepCtx Σ m n) → TyExpr Σ (m + n) → Judgment Σ Γ n Ty
_⊢_:>_ : (Δ : DepCtx Σ m n) → TmExpr Σ (m + n) → TyExpr Σ (m + n) → Judgment Σ Γ n Tm
_⊢_==_ : (Δ : DepCtx Σ m n) → TyExpr Σ (m + n) → TyExpr Σ (m + n) → Judgment Σ Γ n Ty=
_⊢_==_:>_ : (Δ : DepCtx Σ m n) → TmExpr Σ (m + n) → TmExpr Σ (m + n) → TyExpr Σ (m + n)
→ Judgment Σ Γ n Tm=
{-
A derivation rule consists of a partial function taking a tuple of judgments (of the correct
arities) and returning another judgment. Moreover, a derivation rule is extendable to any other
signature the original signature maps to.
The type [DerivationRulePremises Σ Γ args] represents tuples of judgments of arities [args] (and in
signature [Σ] and with ambient context [Γ])
The type [DerivationRule Σ ar n] represents derivation rules in signature [Σ], of arity [ar] and in
scope [n]. It lives in [Set₁] because it quantifies over arbitrary signatures that [Σ] maps into.
-}
data DerivationRulePremises (Σ : Signature) {n : ℕ} (Γ : Ctx Σ n) : JudgmentArityArgs → Set where
[] : DerivationRulePremises Σ Γ []
_,_ : {m : ℕ} {k : JudgmentSort} {args : JudgmentArityArgs}
→ DerivationRulePremises Σ Γ args
→ Judgment Σ Γ m k
→ DerivationRulePremises Σ Γ (args , (m , k))
record DerivationRule (Σ : Signature) (ar : JudgmentArity) : Set₁ where
field
rule : {Σ' : Signature} {n : ℕ} → (Σ →Sig Σ') n → (Γ : Ctx Σ' n)
→ DerivationRulePremises Σ' Γ (args ar) → Partial (Judgment Σ' Γ 0 (sort ar))
open DerivationRule public
{- A derivability structure consists of a bunch of derivation rules, indexed by their arities -}
data Tag : Set where
S T C Eq : Tag
record DerivabilityStructure (Σ : Signature) : Set₁ where
field
Rules : Tag → JudgmentArity → Set
derivationRule : {t : Tag} {ar : JudgmentArity} (r : Rules t ar) → DerivationRule Σ ar
open DerivabilityStructure public
{- We can move the local context to the end of the ambient context -}
module _ {Σ : Signature} {m : ℕ} {Γ : Ctx Σ m} where
Γ+ : {l : ℕ} (Δ : DepCtx Σ m l) → Ctx Σ (m + l)
Γ+ ◇ = Γ
Γ+ (Δ , A) = (Γ+ Δ , A)
exchangeCtx : {n : ℕ} {k : JudgmentSort} → Judgment Σ Γ n k → Ctx Σ (m + n)
exchangeCtx (Δ ⊢ A) = Γ+ Δ
exchangeCtx (Δ ⊢ u :> A) = Γ+ Δ
exchangeCtx (Δ ⊢ A == B) = Γ+ Δ
exchangeCtx (Δ ⊢ u == v :> A) = Γ+ Δ
exchange : {n : ℕ} {k : JudgmentSort} → (j : Judgment Σ Γ n k) → Judgment Σ (exchangeCtx j) 0 k
exchange (Δ ⊢ A) = ◇ ⊢ A
exchange (Δ ⊢ u :> A) = ◇ ⊢ u :> A
exchange (Δ ⊢ A == B) = ◇ ⊢ A == B
exchange (Δ ⊢ u == v :> A) = ◇ ⊢ u == v :> A
{-
A judgment can be derivable in one different way:
- if it has a trivial local context, then it should be obtained by applying a rule [r] from the
derivability structure to a list of judgments [js] which are all derivable [js-der] and for which
the rule is defined [def].
The type [DerivableArgs E js] represents the fact that all of the judgments in [js] are derivables.
The type [Derivable E j] represents the fact that the judgment [j] is derivable.
-}
data Derivable {Σ : Signature} (E : DerivabilityStructure Σ)
: {m : ℕ} {Γ : Ctx Σ m} {k : JudgmentSort} → Judgment Σ Γ 0 k → Prop
data DerivableArgs {Σ : Signature} (E : DerivabilityStructure Σ) {m : ℕ} {Γ : Ctx Σ m}
: {ar : JudgmentArityArgs} → DerivationRulePremises Σ Γ ar → Prop where
[] : DerivableArgs E []
_,_ : {n : ℕ} {k : JudgmentSort} {j : Judgment Σ Γ n k}
{ar : JudgmentArityArgs} {js : DerivationRulePremises Σ Γ ar}
→ DerivableArgs E js
→ Derivable E (exchange j)
→ DerivableArgs E (js , j)
data Derivable {Σ} E where
apr : (t : Tag) {ar : JudgmentArity} (r : Rules E t ar) {m : ℕ} {Γ : Ctx Σ m}
{js : DerivationRulePremises Σ Γ (args ar)}
(js-der : DerivableArgs E js) {{def : isDefined (rule (derivationRule E r) idSig Γ js)}}
→ Derivable E (rule (derivationRule E r) idSig Γ js $ def)
{- Special cases of [_,_], used to make Agda not blow up -}
_,0Ty_ : ∀ {Σ} {E} {m} {Γ : Ctx Σ m} {A : TyExpr Σ m}
{ar : JudgmentArityArgs} {js : DerivationRulePremises Σ Γ ar}
→ DerivableArgs E js
→ Derivable E (◇ ⊢ A)
→ DerivableArgs E (js , ◇ ⊢ A)
djs ,0Ty dj = djs , dj
_,0Ty=_ : ∀ {Σ} {E} {m} {Γ : Ctx Σ m} {A B : _}
{ar : JudgmentArityArgs} {js : DerivationRulePremises Σ Γ ar}
→ DerivableArgs E js
→ Derivable E (◇ ⊢ A == B)
→ DerivableArgs E (js , ◇ ⊢ A == B)
djs ,0Ty= dj = djs , dj
_,0Tm_ : ∀ {Σ} {E} {m} {Γ : Ctx Σ m} {u : _} {A : _}
{ar : JudgmentArityArgs} {js : DerivationRulePremises Σ Γ ar}
→ DerivableArgs E js
→ Derivable E (◇ ⊢ u :> A)
→ DerivableArgs E (js , ◇ ⊢ u :> A)
djs ,0Tm dj = djs , dj
_,0Tm=_ : ∀ {Σ} {E} {m} {Γ : Ctx Σ m} {u v : _} {A : _}
{ar : JudgmentArityArgs} {js : DerivationRulePremises Σ Γ ar}
→ DerivableArgs E js
→ Derivable E (◇ ⊢ u == v :> A)
→ DerivableArgs E (js , ◇ ⊢ u == v :> A)
djs ,0Tm= dj = djs , dj
_,1Ty_ : ∀ {Σ} {E} {m} {Γ : Ctx Σ m} {A} {B}
{ar : JudgmentArityArgs} {js : DerivationRulePremises Σ Γ ar}
→ DerivableArgs E js
→ Derivable E (exchange ((◇ , A) ⊢ B))
→ DerivableArgs E (js , (◇ , A) ⊢ B)
djs ,1Ty dj = djs , dj
_,1Ty=_ : ∀ {Σ} {E} {m} {Γ : Ctx Σ m} {A} {B C}
{ar : JudgmentArityArgs} {js : DerivationRulePremises Σ Γ ar}
→ DerivableArgs E js
→ Derivable E (exchange ((◇ , A) ⊢ B == C))
→ DerivableArgs E (js , (◇ , A) ⊢ B == C)
djs ,1Ty= dj = djs , dj
_,1Tm_ : ∀ {Σ} {E} {m} {Γ : Ctx Σ m} {u : _} {A : _} {B : _}
{ar : JudgmentArityArgs} {js : DerivationRulePremises Σ Γ ar}
→ DerivableArgs E js
→ Derivable E (exchange ((◇ , B) ⊢ u :> A))
→ DerivableArgs E (js , (◇ , B) ⊢ u :> A)
djs ,1Tm dj = djs , dj
_,1Tm=_ : ∀ {Σ} {E} {m} {Γ : Ctx Σ m} {u v : _} {A : _} {B : _}
{ar : JudgmentArityArgs} {js : DerivationRulePremises Σ Γ ar}
→ DerivableArgs E js
→ Derivable E (exchange ((◇ , B) ⊢ u == v :> A))
→ DerivableArgs E (js , (◇ , B) ⊢ u == v :> A)
djs ,1Tm= dj = djs , dj
_,2Tm_ : ∀ {Σ} {E} {m} {Γ : Ctx Σ m} {u : _} {A : _} {B : _} {C : _}
{ar : JudgmentArityArgs} {js : DerivationRulePremises Σ Γ ar}
→ DerivableArgs E js
→ Derivable E (exchange ((◇ , B , C) ⊢ u :> A))
→ DerivableArgs E (js , (◇ , B , C) ⊢ u :> A)
djs ,2Tm dj = djs , dj
infixl 4 _,0Ty_ _,0Ty=_ _,0Tm_ _,0Tm=_
_,1Ty_ _,1Ty=_ _,1Tm_ _,1Tm=_
_,2Tm_
|
{
"alphanum_fraction": 0.5943581037,
"avg_line_length": 39.0663265306,
"ext": "agda",
"hexsha": "3e0c63e785baaf2836658e4087760b60f6c49827",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "f9bfefd0a70ae5bdc3906829ee1165c731882bca",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "guillaumebrunerie/general-type-theories",
"max_forks_repo_path": "derivability.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f9bfefd0a70ae5bdc3906829ee1165c731882bca",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "guillaumebrunerie/general-type-theories",
"max_issues_repo_path": "derivability.agda",
"max_line_length": 99,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "f9bfefd0a70ae5bdc3906829ee1165c731882bca",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "guillaumebrunerie/general-type-theories",
"max_stars_repo_path": "derivability.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2801,
"size": 7657
}
|
{-# OPTIONS --cubical --safe #-}
module Path where
open import Cubical.Foundations.Everything
using ( _≡_
; sym
; refl
; subst
; transport
; Path
; PathP
; I
; i0
; i1
; funExt
; cong
; toPathP
; cong₂
; ~_
; _∧_
; _∨_
; hcomp
; transp
; J
)
renaming (_∙_ to _;_)
public
open import Data.Empty using (¬_)
open import Level
infix 4 _≢_
_≢_ : {A : Type a} → A → A → Type a
x ≢ y = ¬ (x ≡ y)
infix 4 PathP-syntax
PathP-syntax = PathP
syntax PathP-syntax (λ i → Ty) lhs rhs = lhs ≡[ i ≔ Ty ]≡ rhs
|
{
"alphanum_fraction": 0.4631578947,
"avg_line_length": 16.2195121951,
"ext": "agda",
"hexsha": "784047c5f24bfea8209c0d4b58b7fae864b20363",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z",
"max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/combinatorics-paper",
"max_forks_repo_path": "agda/Path.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "oisdk/combinatorics-paper",
"max_issues_repo_path": "agda/Path.agda",
"max_line_length": 61,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/combinatorics-paper",
"max_stars_repo_path": "agda/Path.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": 228,
"size": 665
}
|
{-# OPTIONS --without-K #-}
module overloading.core where
-- ## Coercions
--
-- The overloading system implemented in this module is based on
-- **coercions**. A coercion is simply a function converting a type into
-- another. In object-oriented parliance, a coercion embodies an *is-a*
-- relationship. The two types involved in a coercions are called `Source` and
-- `Target` respectively, and the coercion itself is a function `Source →
-- Target`.
--
-- Coercions are implemented as terms of type `Coercion`, which is a record
-- parameterized over the `Source` and `Target` types, with a single field for
-- the actual coercion function. Of course, the type `Coercion X Y` is
-- isomorphic to `X → Y`, but using a record prevents possible ambiguities when
-- using coercions as implicit parameters, and potentially makes instance
-- resolution faster.
--
-- The typical scenario where coercions are used is when defining a subtype
-- relationships between types. Although Agda has no built-in support for
-- subtypes, it is possible to achieve a reasonable level of syntactical
-- convenience with the help of some boilerplace code that specifies the
-- subtyping relation explicitly. See `category.graph.core` for a detailed
-- example.
--
-- This module also contains some functions to help reduce the amount of
-- boilerplate needed for defining all the coercions necessary for a given type.
-- See `coerce-self` and `coerce-parent` below.
--
-- ## Methods
--
-- The strategy employed by this library to implement overloading goes as
-- follows. Every type (denoted by `Target` in the following) defines a set of
-- "methods" that constitute its interface, and are inherited by every subtype
-- of `Target`. Methods are divided into 2 groups:
--
-- - **static methods** are functions that take an argument `X` of a type
-- convertible to `Target`. The typical example of a static method is an
-- explicit coercion function, like `∣_∣` below, which returns the "underlying
-- set" of `X`. Another example of static method is the `total` function for
-- graphs (see `category.graph.core`).
--
-- - **instance methods** are functions that work without requiring an explicit
-- parameter of type `Target`. A typical example of instance method is
-- composition in a category (`_∘_`): there's no need to pass the category
-- itself when composing two morphisms. In order to use instance methods, they
-- have to be enabled explicitly for each instance for which they are used.
-- Every type defines a special module (whose name is by convention always
-- `as-target`, where `target` is replaced with the actual lowercase name of
-- type) which allows instance methods to be enabled. For example, to use the
-- composition operator for morphisms of a category `C`, one can write:
--
-- open as-category C
--
-- The `as-target` module itself behaves like a *static* method, so it can be
-- used to enable instance methods for any superclass of a given instance.
-- Furthermore, enabling instance methods for `Target` enables instance methods
-- for all superclasses of it in its principal inheritance path (see
-- "Inheritance Model" below).
--
-- ## Implementation
--
-- The implementation of static methods is relatively straightforward. A static
-- method is defined as a function taking a coercion to `Target` as an instance
-- argument, and uses the coercion to convert its argument to the correct type.
--
-- As for instance methods, they are implemented as functions that take a record
-- with the full interface of `Target` (called **instance record** below) as an
-- implicit argument (see "Alternative Notations" below for details), and just
-- return the appropriate field. This can be accomplished very easily using
-- Agda's module system.
--
-- The `as-target` module, used to enable instance methods, is defined as a
-- static method, and works simply by putting the record above into scope.
--
-- ## Alternative Notations
--
-- Some types have an interface which supports alternative notations. For
-- example, monoids have a "default" notation (`unit` and `_*_`), and an
-- additive notation (`zero` and `_+_`).
--
-- To implement multiple notations, a `Styled` record is used as the implicit
-- parameter for instance methods. The `Styled` record is parameterized over a
-- `style` parameter (normally `default`), and contains the interface record as
-- its only field.
--
-- The `Styled` record thus serves two purposes:
--
-- - It prevents ambiguities in the resolution of instance arguments: if an
-- interface record is in scope for reasons unrelated to the overloading system,
-- then it will not be accidentally used as the argument of an instance methods,
-- as it's not wrapped in a `Styled` record.
--
-- - It allows instance methods to specify an alternative style parameter for
-- the record in which the interface record is wrapped. Thus, multiple
-- `as-target` module can be defined, one per supported style, that put the
-- interface record in scope wrapped in the appropriate `Styled` record. The
-- `styled` function can be used to wrap an interface record using a given
-- style.
--
-- ## Inheritance Model
--
-- Subtyping relations can form an arbitrary directed graph, with a
-- distinguished spanning forest, whose edges we call *principal*.
--
-- Coercions are defined for every pair of connected nodes in the full graph.
-- Exactly one coercion per pair should be defined, regardless of the number of
-- paths that connect it. Static methods are inherited automatically through
-- paths in the full DAG, since the existence of a coercion is enough for static
-- methods to propagate.
--
-- The principal subgraph is used for inheritance of instance methods. Namely,
-- the `as-target` record enables all instance methods for the ancestors of
-- `Target` in the principal subgraph. This is accomplished by simply
-- re-exporting the `as-target` module for the immediate parent of
-- `Target`. Extra edges coming out of `Target` can optionally be added as well
-- for convenience.
open import level
open import overloading.bundle
record Coercion {i}{j}(Source : Set i)(Target : Set j) : Set (i ⊔ j) where
constructor coercion
field
coerce : Source → Target
open Coercion public
data Style : Set where default : Style
record Styled {i}(style : Style)(X : Set i) : Set i where
field value : X
styled : ∀ {i}{X : Set i} → (s : Style) → X → Styled s X
styled s x = record { value = x }
-- Trivial coercion: any type can be coerced into itself.
coerce-self : ∀ {i} (X : Set i) → Coercion X X
coerce-self {i} _ = record
{ coerce = λ x → x }
-- Transport a coercion to a `Bundle` subtype. See `overloading.bundle` for
-- more details on bundles.
coerce-parent : ∀ {i j k}
{X : Set i}
{Y : Set j}
→ ⦃ c : Coercion X Y ⦄
→ {Struct : X → Set k}
→ Coercion (Bundle Struct) Y
coerce-parent ⦃ c ⦄ = record
{ coerce = λ x → coerce c (Bundle.parent x) }
instance
set-is-set : ∀ {i} → Coercion (Set i) (Set i)
set-is-set {i} = coerce-self _
∣_∣ : ∀ {i j}{Source : Set i} ⦃ o : Coercion Source (Set j) ⦄
→ Source → Set j
∣_∣ ⦃ c ⦄ = coerce c
|
{
"alphanum_fraction": 0.7200444815,
"avg_line_length": 44.9625,
"ext": "agda",
"hexsha": "d8788e790b0be20360dcff3726a79c0424f9606b",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2019-02-26T06:17:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-04-11T17:19:12.000Z",
"max_forks_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "HoTT/M-types",
"max_forks_repo_path": "overloading/core.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c",
"max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "pcapriotti/agda-base",
"max_issues_repo_path": "src/overloading/core.agda",
"max_line_length": 80,
"max_stars_count": 27,
"max_stars_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "HoTT/M-types",
"max_stars_repo_path": "overloading/core.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-09T07:26:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-14T15:47:03.000Z",
"num_tokens": 1753,
"size": 7194
}
|
module Issue606 where
infixr 1 _,_
record _×_ (A B : Set) : Set where
constructor _,_
field fst : A
snd : B
postulate A B C : Set
test : A × (B × C)
test = {!!} , {!!}
-- refining the second hole should give "? , ?" (no enclosing parens!)
|
{
"alphanum_fraction": 0.58203125,
"avg_line_length": 17.0666666667,
"ext": "agda",
"hexsha": "639d909843041beb31dadea3276a2e057db793a1",
"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/Issue606.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/Issue606.agda",
"max_line_length": 71,
"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/Issue606.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 83,
"size": 256
}
|
{-# OPTIONS --no-positivity-check #-}
module Section7 where
open import Section6 public
-- 7. Correspondence between proof trees and terms
-- ===============================================
--
-- We define a function that translates the proof trees to the corresponding untyped terms nad
-- likewise for the substitutions, we write `M ⁻` and `γ ⁻ˢ` for these operations. The definitions
-- are:
mutual
_⁻ : ∀ {Γ A} → Γ ⊢ A → 𝕋
(ν x i) ⁻ = ν x
(ƛ x M) ⁻ = ƛ x (M ⁻)
(M ∙ N) ⁻ = (M ⁻) ∙ (N ⁻)
(M ▶ γ) ⁻ = (M ⁻) ▶ (γ ⁻ˢ)
_⁻ˢ : ∀ {Δ Γ} → Δ ⋙ Γ → 𝕊
π⟨ c ⟩ ⁻ˢ = []
(γ ● γ′) ⁻ˢ = (γ ⁻ˢ) ● (γ′ ⁻ˢ)
[ γ , x ≔ M ] ⁻ˢ = [ γ ⁻ˢ , x ≔ M ⁻ ]
-- It is easy to prove that the translation of a proof tree is well-typed:
-- Lemma 12.
mutual
lem₁₂ : ∀ {Γ A} → (M : Γ ⊢ A) → Γ ⊢ M ⁻ ∷ A
lem₁₂ (ν x i) = ν x i
lem₁₂ (ƛ x M) = ƛ x (lem₁₂ M)
lem₁₂ (M ∙ N) = lem₁₂ M ∙ lem₁₂ N
lem₁₂ (M ▶ γ) = lem₁₂ M ▶ lem₁₂ₛ γ
lem₁₂ₛ : ∀ {Γ Γ′} → (γ : Γ′ ⋙ Γ) → Γ′ ⋙ γ ⁻ˢ ∷ Γ
lem₁₂ₛ π⟨ c ⟩ = ↑⟨ c ⟩ refl⋙∷
lem₁₂ₛ (γ ● γ′) = lem₁₂ₛ γ ● lem₁₂ₛ γ′
lem₁₂ₛ [ γ , x ≔ M ] = [ lem₁₂ₛ γ , x ≔ lem₁₂ M ]
-- In general, we may have `M ⁻ ≡ N ⁻` but `M` different from `N`. Take for example
-- `(λ(y : B ⊃ B).z) ∙ λ(x : B).x : [ z : A ] ⊢ A` and `(λ(y : C ⊃ C).z ∙ λ(x : C).x : [ z : A ] ⊢ A`
-- which are both
-- translated into `(λ y.z) ∙ λ x.x`. This shows that a given term can be decorated into different
-- proof trees.
--
-- We define a relation between terms and their possible decorations (and likewise for the
-- substitutions) as an inductively defined set. (…)
--
-- The introduction rules are: (…)
mutual
infix 3 _𝒟_
data _𝒟_ : ∀ {Γ A} → 𝕋 → Γ ⊢ A → Set where
ν : ∀ {Γ A} →
(x : Name) (i : Γ ∋ x ∷ A) →
ν x 𝒟 ν x i
_∙_ : ∀ {Γ A B t₁ t₂} {M : Γ ⊢ A ⊃ B} {N : Γ ⊢ A} →
t₁ 𝒟 M → t₂ 𝒟 N →
t₁ ∙ t₂ 𝒟 M ∙ N
π⟨_⟩ : ∀ {Γ Δ A t} {M : Δ ⊢ A} →
(c : Γ ⊇ Δ) → t 𝒟 M →
t 𝒟 M ▶ π⟨ c ⟩
_▶_ : ∀ {Γ Δ A s t} {M : Δ ⊢ A} {γ : Γ ⋙ Δ} →
t 𝒟 M → s 𝒟ₛ γ →
t ▶ s 𝒟 M ▶ γ
ƛ : ∀ {Γ A B t} →
(x : Name) {{_ : T (fresh x Γ)}} {M : [ Γ , x ∷ A ] ⊢ B} → t 𝒟 M →
ƛ x t 𝒟 ƛ x M
infix 3 _𝒟ₛ_
data _𝒟ₛ_ : ∀ {Γ Δ} → 𝕊 → Γ ⋙ Δ → Set where
π⟨_⟩ : ∀ {Γ Δ} →
(c : Γ ⊇ Δ) →
[] 𝒟ₛ π⟨ c ⟩
[_,_≔_] : ∀ {Γ Δ A s t} {γ : Δ ⋙ Γ} {M : Δ ⊢ A} →
s 𝒟ₛ γ → (x : Name) {{_ : T (fresh x Γ)}} → t 𝒟 M →
[ s , x ≔ t ] 𝒟ₛ [ γ , x ≔ M ]
↓⟨_⟩𝒟ₛ : ∀ {Γ Δ Θ s} {γ : Θ ⋙ Γ} →
(c : Γ ⊇ Δ) → s 𝒟ₛ γ →
s 𝒟ₛ ↓⟨ c ⟩ γ
↑⟨_⟩𝒟ₛ : ∀ {Γ Δ Θ s} {γ : Γ ⋙ Δ} →
(c : Θ ⊇ Γ) → s 𝒟ₛ γ →
s 𝒟ₛ ↑⟨ c ⟩ γ
_●_ : ∀ {Γ Δ Θ s₁ s₂} {γ₂ : Γ ⋙ Δ} {γ₁ : Θ ⋙ Γ} →
s₂ 𝒟ₛ γ₂ → s₁ 𝒟ₛ γ₁ →
s₂ ● s₁ 𝒟ₛ γ₂ ● γ₁
-- It is straightforward to prove Lemma 13
-- mutually with a corresponding lemma for substitutions.
-- Lemma 13.
mutual
lem₁₃ : ∀ {Γ A} → (M : Γ ⊢ A) → M ⁻ 𝒟 M
lem₁₃ (ν x i) = ν x i
lem₁₃ (ƛ x M) = ƛ x (lem₁₃ M)
lem₁₃ (M ∙ N) = lem₁₃ M ∙ lem₁₃ N
lem₁₃ (M ▶ γ) = lem₁₃ M ▶ lem₁₃ₛ γ
lem₁₃ₛ : ∀ {Γ Γ′} → (γ : Γ′ ⋙ Γ) → γ ⁻ˢ 𝒟ₛ γ
lem₁₃ₛ π⟨ c ⟩ = π⟨ c ⟩
lem₁₃ₛ (γ ● γ′) = lem₁₃ₛ γ ● lem₁₃ₛ γ′
lem₁₃ₛ [ γ , x ≔ M ] = [ lem₁₃ₛ γ , x ≔ lem₁₃ M ]
-- Using the discussion in Section 3.3 on how to define the monotonicity and projection
-- rules with `π⟨_⟩` we can find a proof tree that corresponds to a well-typed term:
-- Lemma 14.
postulate
lem₁₄ : ∀ {Γ A t} → Γ ⊢ t ∷ A → Σ (Γ ⊢ A) (λ M → M ⁻ ≡ t)
-- As a direct consequence of this lemma and Lemma 13 we know that every well-typed term
-- has a decoration.
-- Lemma 15.
lem₁₅ : ∀ {Γ A t} → Γ ⊢ t ∷ A → Σ (Γ ⊢ A) (λ M → t 𝒟 M)
lem₁₅ D with lem₁₄ D
… | (M , refl) = M , lem₁₃ M
-- As a consequence of this lemma we can now define the semantics of a well-typed term in
-- a Kripke model as the semantics of the decorated term. In the remaining text, however, we
-- study only the correspondence between terms and proof trees since the translation to the
-- semantics is direct.
--
-- TODO: What to do about the above paragraph?
--
-- As we mentioned above a well-typed term may be decorated to several proof trees. We
-- can however prove that if two proof trees are in η-normal form and they are decorations of
-- the same term, then the two proof trees are convertible. We prove Lemma 16
-- together with two corresponding lemmas for proof trees in applicative normal form:
-- Lemma 16.
mutual
postulate
lem₁₆ : ∀ {Γ A t} {M M′ : Γ ⊢ A} {{_ : enf M}} {{_ : enf M′}} →
t 𝒟 M → t 𝒟 M′ →
M ≡ M′
postulate
lem₁₆′ : ∀ {Γ A A′ t} {M : Γ ⊢ A} {N : Γ ⊢ A′} {{_ : anf M}} {{_ : anf N}} →
t 𝒟 M → t 𝒟 N →
A ≡ A′
-- TODO: Uh oh. Heterogeneous equality?
-- postulate
-- lem₁₆″ : ∀ {Γ A A′ t} {M : Γ ⊢ A} {M′ : Γ ⊢ A′} {{_ : anf M}} {{_ : anf M′}} →
-- t 𝒟 M → t 𝒟 M′ →
-- M ≡ M′
postulate
lem₁₆″ : ∀ {Γ A t} {M M′ : Γ ⊢ A} {{_ : anf M}} {{_ : anf M′}} →
t 𝒟 M → t 𝒟 M′ →
M ≡ M′
-- As a consequence we get that if `nf M ⁻` and `nf N ⁻` are the same, then `M ≅ N`.
-- Corollary 2.
postulate
cor₂ : ∀ {Γ A} → (M M′ : Γ ⊢ A) → nf M ⁻ ≡ nf M′ ⁻ → M ≅ M′
-- Proof: By Lemma 16 and Theorem 7 we get `nf N ≡ nf M` and by Theorem 5 we get `M ≅ N`.
-- 7.1. Reduction
-- --------------
--
-- We mutually inductively define when a term is in weak head normal form (abbreviated
-- `whnf`) and in weak head applicative normal form (abbreviated `whanf`) by:
mutual
data whnf : 𝕋 → Set where
ƛ : ∀ {t} →
(x : Name) → whnf t →
whnf (ƛ x t)
α : ∀ {t} → whanf t →
whnf t
data whanf : 𝕋 → Set where
ν : (x : Name) →
whanf (ν x)
_∙_ : ∀ {t u} →
whanf t → whnf u →
whanf (t ∙ u)
-- We inductively define a deterministic untyped one-step reduction on terms and
-- substitutions: (…)
mutual
infix 3 _⟶_
data _⟶_ : 𝕋 → 𝕋 → Set where
red₁ : ∀ {a s t x} →
(ƛ x t ▶ s) ∙ a ⟶ t ▶ [ s , x ≔ a ]
red₂ : ∀ {t t₁ t₂} →
t₁ ⟶ t₂ →
t₁ ∙ t ⟶ t₂ ∙ t
red₃ : ∀ {s t x} →
ν x ▶ [ s , x ≔ t ] ⟶ t
red₄ : ∀ {s t x y} {{_ : x ≢ y}} →
ν x ▶ [ s , y ≔ t ] ⟶ ν x ▶ s
red₅ : ∀ {x} →
ν x ▶ [] ⟶ ν x
red₆ : ∀ {s₁ s₂ x} →
s₁ ⟶ₛ s₂ →
x ▶ s₁ ⟶ x ▶ s₂
red₇ : ∀ {s t₁ t₂} →
(t₁ ∙ t₂) ▶ s ⟶ (t₁ ▶ s) ∙ (t₂ ▶ s)
red₈ : ∀ {s₁ s₂ t} →
(t ▶ s₁) ▶ s₂ ⟶ t ▶ (s₁ ● s₂)
infix 3 _⟶ₛ_
data _⟶ₛ_ : 𝕊 → 𝕊 → Set where
red₁ₛ : ∀ {s₀ s₁ t x} →
[ s₀ , x ≔ t ] ● s₁ ⟶ₛ [ s₀ ● s₁ , x ≔ t ▶ s₁ ]
red₂ₛ : ∀ {s₁ s₂ s₃} →
(s₁ ● s₂) ● s₃ ⟶ₛ s₁ ● (s₂ ● s₃)
red₃ₛ : ∀ {s} →
[] ● s ⟶ₛ s
-- The untyped evaluation to `whnf`, `_⟹_`, is inductively defined by:
infix 3 _⟹_
data _⟹_ : 𝕋 → 𝕋 → Set where
eval₁ : ∀ {t} {{_ : whnf t}} →
t ⟹ t
eval₂ : ∀ {t₁ t₂ t₃} →
t₁ ⟶ t₂ → t₂ ⟹ t₃ →
t₁ ⟹ t₃
-- It is easy to see that this relation is deterministic.
--
-- TODO: What to do about the above paragraph?
--
-- In order to define a deterministic reduction that gives a term on long η-normal form
-- we need to use its type. We define this typed reduction, `_⊢_↓_∷_`, simultaneously with `_⊢_↓ₛ_∷_` which
-- η-expands the arguments in an application on `whnf`:
mutual
infix 3 _⊢_↓_∷_
data _⊢_↓_∷_ : 𝒞 → 𝕋 → 𝕋 → 𝒯 → Set where
red₁ : ∀ {Γ t₀ t₂} →
Σ 𝕋 (λ t₁ → t₀ ⟹ t₁ × Γ ⊢ t₁ ↓ₛ t₂ ∷ •) →
Γ ⊢ t₀ ↓ t₂ ∷ •
red₂ : ∀ {Γ A B t₁ t₂} →
let z , φ = gensym Γ in
let instance _ = φ in
[ Γ , z ∷ A ] ⊢ t₁ ∙ ν z ↓ t₂ ∷ B →
Γ ⊢ t₁ ↓ ƛ z t₂ ∷ A ⊃ B
infix 3 _⊢_↓ₛ_∷_
data _⊢_↓ₛ_∷_ : 𝒞 → 𝕋 → 𝕋 → 𝒯 → Set where
red₁ₛ : ∀ {Γ A x} →
Γ ∋ x ∷ A →
Γ ⊢ ν x ↓ₛ ν x ∷ A
red₂ₛ : ∀ {Γ B t₁ t₂ t₁′ t₂′} →
Σ 𝒯 (λ A → Γ ⊢ t₁ ↓ₛ t₁′ ∷ A ⊃ B × Γ ⊢ t₂ ↓ t₂′ ∷ A) →
Γ ⊢ t₁ ∙ t₂ ↓ₛ t₁′ ∙ t₂′ ∷ B
-- Finally we define `Γ ⊢ t ⇓ t′ ∷ A` to hold if `Γ ⊢ t [] ↓ t′ ∷ A`.
_⊢_⇓_∷_ : 𝒞 → 𝕋 → 𝕋 → 𝒯 → Set
Γ ⊢ t ⇓ t′ ∷ A = Γ ⊢ t ▶ [] ↓ t′ ∷ A
-- 7.2. Equivalence between proof trees and terms
-- ----------------------------------------------
--
-- We can prove that if `M : Γ ⊢ A`, then `Γ ⊢ M ⁻ ⇓ nf M ⁻ ∷ A`. This we do by defining a
-- Kripke logical relation, `_ℛ_`. (…)
--
-- When `f : Γ ⊩ •` we intuitively have that `t ℛ f` holds if `Γ ⊢ t ↓ f ⁻`.
--
-- When `f : Γ ⊩ A ⊃ B`, then `t ℛ f` holds if for all `t′` and `a : Γ ⊩ A` such that `t′ ℛ a`, we
-- have that `t ∙ t′ ℛ f ⟦∙⟧ a`.
infix 3 _ℛ_
data _ℛ_ : ∀ {Γ A} → 𝕋 → Γ ⊩ A → Set where
𝓇• : ∀ {Δ} →
(t : 𝕋) (f : Δ ⊩ •) →
(∀ {Γ} →
(c : Γ ⊇ Δ) (t′ : 𝕋) → t′ 𝒟 f ⟦g⟧⟨ c ⟩ →
Γ ⊢ t ↓ t′ ∷ •) →
t ℛ f
𝓇⊃ : ∀ {Δ A B} →
(t : 𝕋) (f : Δ ⊩ A ⊃ B) →
(∀ {Γ} →
(c : Γ ⊇ Δ) (a : Γ ⊩ A) (t′ : 𝕋) → Γ ⊢ t′ ∷ A → t′ ℛ a →
t ∙ t′ ℛ f ⟦∙⟧⟨ c ⟩ a) →
t ℛ f
-- For the substitutions we define correspondingly:
infix 3 _ℛₛ_
data _ℛₛ_ : ∀ {Γ Δ} → 𝕊 → Γ ⊩⋆ Δ → Set where
𝓇ₛ[] : ∀ {Δ s} →
Δ ⋙ s ∷ [] →
s ℛₛ ([] {w = Δ})
-- NOTE: Mistake in paper? Changed `v : Δ ⊩ A` to `a : Γ ⊩ A`.
rₛ≔ : ∀ {Γ Δ A s x} {{_ : T (fresh x Γ)}} {{_ : T (fresh x Δ)}} →
Δ ⋙ s ∷ [ Γ , x ∷ A ] → (ρ : Γ ⊩⋆ Δ) (a : Γ ⊩ A) → s ℛₛ ρ → ν x ▶ s ℛ a →
s ℛₛ [ ρ , x ≔ a ]
-- The following lemmas are straightforward to prove:
postulate
aux₇₂₁ : ∀ {Γ A t₁ t₂} →
(a : Γ ⊩ A) → t₁ ℛ a → t₂ ⟶ t₁ →
t₂ ℛ a
postulate
aux₇₂₂ : ∀ {Γ Δ s₁ s₂} →
(ρ : Γ ⊩⋆ Δ) → Δ ⋙ s₁ ∷ Γ → s₁ ⟶ₛ s₂ → s₂ ℛₛ ρ →
s₁ ℛₛ ρ
-- NOTE: Mistake in paper? Changed `Occur(x, A, Γ)` to `Δ ∋ x ∷ A`.
postulate
aux₇₂₃ : ∀ {Γ Δ A s x} →
(ρ : Γ ⊩⋆ Δ) (i : Δ ∋ x ∷ A) → Δ ⋙ s ∷ Γ →
ν x ▶ s ℛ lookup ρ i
postulate
aux₇₂₄⟨_⟩ : ∀ {Γ Δ A t} →
(c : Γ ⊇ Δ) (a : Δ ⊩ A) → t ℛ a →
t ℛ ↑⟨ c ⟩ a
-- NOTE: Mistake in paper? Changed `ρ ∈ Γ ⊩ Δ` to `ρ : Δ ⊩⋆ Γ`.
postulate
aux₇₂₅⟨_⟩ : ∀ {Γ Δ Θ s} →
(c : Θ ⊇ Δ) → Δ ⋙ s ∷ Γ → (ρ : Δ ⊩⋆ Γ) → s ℛₛ ρ →
s ℛₛ ↑⟨ c ⟩ ρ
-- NOTE: Mistake in paper? Changed `ρ ∈ Γ ⊩ Δ` to `ρ : Δ ⊩⋆ Γ`.
postulate
aux₇₂₆⟨_⟩ : ∀ {Γ Δ Θ s} →
(c : Γ ⊇ Θ) → Δ ⋙ s ∷ Γ → (ρ : Δ ⊩⋆ Γ) → s ℛₛ ρ →
s ℛₛ ↓⟨ c ⟩ ρ
postulate
aux₇₂₇ : ∀ {Γ Δ A s t x} →
Γ ⊢ t ∷ A → Γ ⋙ s ∷ Δ → (ρ : Γ ⊩⋆ Δ) → s ℛₛ ρ →
[ s , x ≔ t ] ℛₛ ρ
-- Using these lemmas we can prove by mutual induction on the proof tree of terms and
-- substitutions that:
-- NOTE: Mistake in paper? Changed `ρ ∈ Γ ⊩ Δ` to `ρ : Δ ⊩⋆ Γ`.
postulate
aux₇₂₈ : ∀ {Γ Δ A s t} →
(M : Γ ⊢ A) (ρ : Δ ⊩⋆ Γ) → Δ ⋙ s ∷ Γ → t 𝒟 M → s ℛₛ ρ →
t ▶ s ℛ ⟦ M ⟧ ρ
postulate
aux₇₂₉ : ∀ {Γ Δ Θ s₁ s₂} →
(γ : Γ ⋙ Θ) (ρ : Δ ⊩⋆ Γ) → Δ ⋙ s₂ ∷ Γ → s₁ 𝒟ₛ γ → s₂ ℛₛ ρ →
s₂ ● s₁ ℛₛ ⟦ γ ⟧ₛ ρ
-- We also show, intuitively, that if `t ℛ a`, `a : Γ ⊩ A`, then `Γ ⊢ t ↓ reify a ⁻ ∷ A`
-- together with a corresponding lemma for `val`:
-- Lemma 17.
mutual
postulate
lem₁₇ : ∀ {Γ A t₀ t₁} →
Γ ⊢ t₀ ∷ A → (a : Γ ⊩ A) → t₀ ℛ a → t₁ 𝒟 reify a →
Γ ⊢ t₀ ↓ t₁ ∷ A
-- NOTE: Mistake in paper? Changed `t ℛ val(f)` to `t₀ ℛ val f`.
postulate
aux₇₂₁₀ : ∀ {Γ A t₀} →
Γ ⊢ t₀ ∷ A → whanf t₀ →
(f : ∀ {Δ} → (c : Δ ⊇ Γ) → Δ ⊢ A) →
(∀ {Δ} → (c : Δ ⊇ Γ) → Δ ⊢ t₀ ↓ₛ f c ⁻ ∷ A) →
t₀ ℛ val f
-- The proof that the translation of proof trees reduces to the translation of its normal form
-- follows directly:
-- Theorem 8.
postulate
thm₈ : ∀ {Γ A t} →
(M : Γ ⊢ A) → t 𝒟 M →
Γ ⊢ t ⇓ nf M ⁻ ∷ A
-- As a consequence we get that if two proof trees are decorations of the same term, then they
-- are convertible with each other:
-- Corollary 3.
postulate
cor₃ : ∀ {Γ A t} →
(M N : Γ ⊢ A) → t 𝒟 M → t 𝒟 N →
M ≅ N
-- Proof: By Theorem 8 we get that `Γ ⊢ t ⇓ nf M ⁻ ∷ A` and `Γ ⊢ t ⇓ nf N ⁻ ∷ A`. Since
-- the reduction is deterministic we get `nf M ⁻ ≡ nf N ⁻` and by Corollary 2 we get that
-- `M ≅ N`.
|
{
"alphanum_fraction": 0.4419796588,
"avg_line_length": 31.5328282828,
"ext": "agda",
"hexsha": "de7be3e41add2d065a688daabba426f045e41f5f",
"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": "7c000654c4f97024d2939c412702f64dc821d4ec",
"max_forks_repo_licenses": [
"X11"
],
"max_forks_repo_name": "mietek/coquand",
"max_forks_repo_path": "src/Section7.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7c000654c4f97024d2939c412702f64dc821d4ec",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"X11"
],
"max_issues_repo_name": "mietek/coquand",
"max_issues_repo_path": "src/Section7.agda",
"max_line_length": 108,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "7c000654c4f97024d2939c412702f64dc821d4ec",
"max_stars_repo_licenses": [
"X11"
],
"max_stars_repo_name": "mietek/coquand",
"max_stars_repo_path": "src/Section7.agda",
"max_stars_repo_stars_event_max_datetime": "2017-09-07T12:44:40.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-03-27T01:29:58.000Z",
"num_tokens": 5847,
"size": 12487
}
|
{-# OPTIONS --universe-polymorphism #-}
open import Categories.Category
open import Categories.Support.Equivalence
module Categories.Object.Indexed {o ℓ e c q} (C : Category o ℓ e) (B : Setoid c q) where
open import Categories.Support.SetoidFunctions
open Category C
open _⟶_ public using () renaming (cong to cong₀; _⟨$⟩_ to _!_)
Objoid = set→setoid Obj
Dust = B ⟶ Objoid
dust-setoid = B ⇨ Objoid
|
{
"alphanum_fraction": 0.736318408,
"avg_line_length": 26.8,
"ext": "agda",
"hexsha": "294f6a6f1a826f6c98df878eec1e18df8dfdcc5b",
"lang": "Agda",
"max_forks_count": 23,
"max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z",
"max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "p-pavel/categories",
"max_forks_repo_path": "Categories/Object/Indexed.agda",
"max_issues_count": 19,
"max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2",
"max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "p-pavel/categories",
"max_issues_repo_path": "Categories/Object/Indexed.agda",
"max_line_length": 88,
"max_stars_count": 98,
"max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "copumpkin/categories",
"max_stars_repo_path": "Categories/Object/Indexed.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": 121,
"size": 402
}
|
-- Andreas, 2018-10-16, erased lambda-arguments
applyErased : {@0 A B : Set} → (@0 A → B) → @0 A → B
applyErased f x = f x
test : {A : Set} → A → A
test x = applyErased (λ y → y) x
-- Expected error:
--
-- Variable y is declared erased, so it cannot be used here
-- when checking that the expression y has type _B_7
|
{
"alphanum_fraction": 0.6363636364,
"avg_line_length": 24.5384615385,
"ext": "agda",
"hexsha": "5b9f40710e265cdfe37b5f574e201d098bdae524",
"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/Erasure-Lambda.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/Erasure-Lambda.agda",
"max_line_length": 59,
"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/Erasure-Lambda.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": 109,
"size": 319
}
|
module RandomAccessList.Standard.Numeral where
open import Data.List
open import Data.Nat
open import Data.Nat.Properties.Simple
open import Data.Unit using (⊤)
open import Data.Empty using (⊥; ⊥-elim)
open import Relation.Nullary.Negation using (contraposition)
open import Relation.Binary.PropositionalEquality as PropEq
using (_≡_; _≢_; refl; cong; trans; sym; inspect)
open PropEq.≡-Reasoning
data Digit : Set where
zero : Digit
one : Digit
Binary : Set
Binary = List Digit
incr : Binary → Binary
incr [] = one ∷ []
incr (zero ∷ xs) = one ∷ xs
incr (one ∷ xs) = zero ∷ incr xs
⟦_⟧ : Binary → ℕ
⟦ [] ⟧ = 0
⟦ zero ∷ xs ⟧ = 2 * ⟦ xs ⟧
⟦ one ∷ xs ⟧ = 1 + 2 * ⟦ xs ⟧
*-0-absorb : (n m : ℕ) → n ≡ 0 → m * n ≡ 0
*-0-absorb n m p =
begin
m * n
≡⟨ cong (_*_ m) p ⟩
m * 0
≡⟨ *-right-zero m ⟩
0
∎
decr : (xs : Binary) → ⟦ xs ⟧ ≢ 0 → Binary
decr [] p = ⊥-elim (p refl)
decr (zero ∷ xs) p = one ∷ decr xs (contraposition (*-0-absorb ⟦ xs ⟧ 2) p)
decr (one ∷ xs) p = zero ∷ xs
|
{
"alphanum_fraction": 0.5725047081,
"avg_line_length": 24.1363636364,
"ext": "agda",
"hexsha": "afd17efcddbda6679b52dc67f6c5f984ab4e1db8",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z",
"max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "banacorn/numeral",
"max_forks_repo_path": "legacy/RandomAccessList/Standard/Numeral.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "banacorn/numeral",
"max_issues_repo_path": "legacy/RandomAccessList/Standard/Numeral.agda",
"max_line_length": 76,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "banacorn/numeral",
"max_stars_repo_path": "legacy/RandomAccessList/Standard/Numeral.agda",
"max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z",
"num_tokens": 410,
"size": 1062
}
|
open import Prelude
open import core
module ground-decidable where
-- every type is either ground or not
ground-decidable : (τ : typ) → (τ ground) + ((τ ground) → ⊥)
ground-decidable b = Inl GBase
ground-decidable ⦇·⦈ = Inr (λ ())
ground-decidable (b ==> b) = Inr (λ ())
ground-decidable (b ==> ⦇·⦈) = Inr (λ ())
ground-decidable (b ==> τ' ==> τ'') = Inr (λ ())
ground-decidable (b ==> τ₁ ⊗ τ₂) = Inr (λ ())
ground-decidable (⦇·⦈ ==> b) = Inr (λ ())
ground-decidable (⦇·⦈ ==> ⦇·⦈) = Inl GHole
ground-decidable (⦇·⦈ ==> τ' ==> τ'') = Inr (λ ())
ground-decidable ((τ ==> τ₁) ==> b) = Inr (λ ())
ground-decidable ((τ ==> τ₁) ==> ⦇·⦈) = Inr (λ ())
ground-decidable ((τ ==> τ₁) ==> τ' ==> τ'') = Inr (λ ())
ground-decidable ((τ ⊗ τ₂) ==> τ₁) = Inr (λ ())
ground-decidable (τ ⊗ b) = Inr (λ ())
ground-decidable (b ⊗ ⦇·⦈) = Inr (λ ())
ground-decidable (⦇·⦈ ⊗ ⦇·⦈) = Inl GProd
ground-decidable (⦇·⦈ ==> τ₁ ⊗ τ₂) = Inr (λ ())
ground-decidable ((τ ⊗ τ₁) ⊗ ⦇·⦈) = Inr (λ ())
ground-decidable ((τ ==> τ₁) ⊗ ⦇·⦈) = Inr (λ ())
ground-decidable ((τ ==> τ₂) ==> τ₁ ⊗ τ₃) = Inr (λ ())
ground-decidable (τ ⊗ τ₁ ==> τ₂) = Inr (λ ())
ground-decidable (τ ⊗ τ₁ ⊗ τ₂) = Inr (λ ())
|
{
"alphanum_fraction": 0.5053852527,
"avg_line_length": 41.6206896552,
"ext": "agda",
"hexsha": "ce87fd6d0a944d22d071d865b3c4ee77672e6cf5",
"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": "c3225acc3c94c56376c6842b82b8b5d76912df2a",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "hazelgrove/hazelnut-livelits-agda",
"max_forks_repo_path": "ground-decidable.agda",
"max_issues_count": 9,
"max_issues_repo_head_hexsha": "c3225acc3c94c56376c6842b82b8b5d76912df2a",
"max_issues_repo_issues_event_max_datetime": "2020-10-20T20:44:13.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-09-30T20:27:56.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "hazelgrove/hazel-palette-agda",
"max_issues_repo_path": "ground-decidable.agda",
"max_line_length": 62,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "c3225acc3c94c56376c6842b82b8b5d76912df2a",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "hazelgrove/hazel-palette-agda",
"max_stars_repo_path": "ground-decidable.agda",
"max_stars_repo_stars_event_max_datetime": "2021-12-19T15:38:31.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-04T06:45:06.000Z",
"num_tokens": 547,
"size": 1207
}
|
-- Generated by src/templates/TemplatesCompiler
module templates where
open import lib
open import cedille-types
-- src/templates/Mendler.ced
MendlerTemplate = File "1" ImportsStart "1" "8" "Mendler" (ParamsCons (Decl "16" "17" NotErased "Indices" (Tkk (Star "27")) "29") ParamsNil) (CmdsNext (DefTermOrType OpacTrans (DefType "32" "Sigma" (KndPi "40" "42" "A" (Tkk (Star "46")) (KndArrow (KndParens "49" (KndTpArrow (TpVar "50" "A") (Star "54")) "56") (Star "59"))) (TpLambda "63" "65" "A" (Tkk (Star "69")) (TpLambda "72" "74" "B" (Tkk (KndTpArrow (TpVar "78" "A") (Star "82"))) (Iota "87" "89" "x" (TpEq "93" (Beta "94" NoTerm NoTerm) (Beta "98" NoTerm NoTerm) "100") (Abs "102" Erased "104" "X" (Tkk (KndTpArrow (TpEq "108" (Beta "109" NoTerm NoTerm) (Beta "113" NoTerm NoTerm) "115") (Star "118"))) (TpArrow (TpParens "121" (Abs "122" NotErased "124" "a" (Tkt (TpVar "128" "A")) (Abs "131" NotErased "133" "b" (Tkt (TpAppt (TpVar "137" "B") (Var "139" "a"))) (TpAppt (TpVar "142" "X") (Beta "144" NoTerm (SomeTerm (Lam "146" NotErased "148" "f" NoClass (App (App (Var "151" "f") NotErased (Var "153" "a")) NotErased (Var "155" "b"))) "157"))))) "158") NotErased (TpAppt (TpVar "161" "X") (Var "163" "x")))))))) "165") (CmdsNext (DefTermOrType OpacTrans (DefType "166" "Product" (KndArrow (Star "176") (KndArrow (Star "180") (Star "184"))) (TpLambda "188" "190" "A" (Tkk (Star "194")) (TpLambda "197" "199" "B" (Tkk (Star "203")) (TpApp (TpApp (TpVar "206" "Sigma") (TpVar "214" "A")) (TpParens "218" (TpLambda "219" "221" "_" (Tkt (TpVar "225" "A")) (TpVar "228" "B")) "230"))))) "231") (CmdsNext (DefTermOrType OpacTrans (DefTerm "233" "sigma" (SomeType (Abs "241" Erased "243" "A" (Tkk (Star "247")) (Abs "250" Erased "252" "B" (Tkk (KndTpArrow (TpVar "256" "A") (Star "260"))) (Abs "263" NotErased "265" "a" (Tkt (TpVar "269" "A")) (TpArrow (TpAppt (TpVar "272" "B") (Var "274" "a")) NotErased (TpApp (TpApp (TpVar "278" "Sigma") (TpVar "286" "A")) (TpVar "290" "B"))))))) (Lam "296" Erased "298" "A" NoClass (Lam "301" Erased "303" "B" NoClass (Lam "306" NotErased "308" "a" NoClass (Lam "311" NotErased "313" "b" NoClass (IotaPair "316" (Beta "317" NoTerm (SomeTerm (Lam "319" NotErased "321" "f" NoClass (App (App (Var "324" "f") NotErased (Var "326" "a")) NotErased (Var "328" "b"))) "330")) (Lam "332" Erased "334" "X" NoClass (Lam "337" NotErased "339" "f" NoClass (App (App (Var "342" "f") NotErased (Var "344" "a")) NotErased (Var "346" "b")))) NoGuide "348")))))) "349") (CmdsNext (DefTermOrType OpacTrans (DefTerm "351" "SigmaInd" (SomeType (Abs "366" Erased "368" "A" (Tkk (Star "372")) (Abs "379" Erased "381" "B" (Tkk (KndTpArrow (TpVar "385" "A") (Star "389"))) (Abs "396" NotErased "398" "x" (Tkt (TpApp (TpApp (TpVar "402" "Sigma") (TpVar "410" "A")) (TpVar "414" "B"))) (Abs "421" Erased "423" "Q" (Tkk (KndTpArrow (TpApp (TpApp (TpVar "427" "Sigma") (TpVar "435" "A")) (TpVar "439" "B")) (Star "443"))) (TpArrow (TpParens "450" (Abs "451" NotErased "453" "a" (Tkt (TpVar "457" "A")) (Abs "460" NotErased "462" "b" (Tkt (TpAppt (TpVar "466" "B") (Var "468" "a"))) (TpAppt (TpVar "471" "Q") (Parens "473" (App (App (AppTp (AppTp (Var "474" "sigma") (TpVar "482" "A")) (TpVar "486" "B")) NotErased (Var "488" "a")) NotErased (Var "490" "b")) "492")))) "493") NotErased (TpAppt (TpVar "500" "Q") (Var "502" "x")))))))) (Lam "508" Erased "510" "A" NoClass (Lam "513" Erased "515" "B" NoClass (Lam "518" NotErased "520" "x" NoClass (Lam "523" Erased "525" "Q" NoClass (Lam "528" NotErased "530" "f" NoClass (App (App (App (AppTp (IotaProj (Var "537" "x") "2" "540") (TpParens "543" (TpLambda "544" "546" "x" (Tkt (TpEq "550" (Beta "551" NoTerm NoTerm) (Beta "555" NoTerm NoTerm) "557")) (Abs "559" Erased "561" "x'" (Tkt (TpApp (TpApp (TpVar "566" "Sigma") (TpVar "574" "A")) (TpVar "578" "B"))) (TpArrow (TpEq "581" (Var "582" "x'") (Var "587" "x") "589") Erased (TpAppt (TpVar "592" "Q") (Var "594" "x'"))))) "597")) NotErased (Parens "604" (Lam "605" NotErased "607" "a" NoClass (Lam "610" NotErased "612" "b" NoClass (Lam "615" Erased "617" "x'" NoClass (Lam "621" Erased "623" "e" NoClass (Rho "626" RhoPlain NoNums (Var "628" "e") NoGuide (App (App (Var "632" "f") NotErased (Var "634" "a")) NotErased (Var "636" "b"))))))) "638")) Erased (Var "640" "x")) Erased (Beta "643" NoTerm NoTerm)))))))) "645") (CmdsNext (DefTermOrType OpacTrans (DefTerm "647" "fst" (SomeType (Abs "653" Erased "655" "A" (Tkk (Star "659")) (Abs "662" Erased "664" "B" (Tkk (KndTpArrow (TpVar "668" "A") (Star "672"))) (TpArrow (TpApp (TpApp (TpVar "675" "Sigma") (TpVar "683" "A")) (TpVar "687" "B")) NotErased (TpVar "691" "A"))))) (Lam "695" Erased "697" "A" NoClass (Lam "700" Erased "702" "B" NoClass (Lam "705" NotErased "707" "x" NoClass (App (AppTp (App (Var "712" "SigmaInd") NotErased (Var "721" "x")) (TpParens "725" (TpLambda "726" "728" "x" (Tkt (TpApp (TpApp (TpVar "732" "Sigma") (TpVar "740" "A")) (TpVar "744" "B"))) (TpVar "747" "A")) "749")) NotErased (Parens "750" (Lam "751" NotErased "753" "a" NoClass (Lam "756" NotErased "758" "b" NoClass (Var "761" "a"))) "763")))))) "764") (CmdsNext (DefTermOrType OpacTrans (DefTerm "766" "snd" (SomeType (Abs "772" Erased "774" "A" (Tkk (Star "778")) (Abs "781" Erased "783" "B" (Tkk (KndTpArrow (TpVar "787" "A") (Star "791"))) (Abs "794" NotErased "796" "x" (Tkt (TpApp (TpApp (TpVar "800" "Sigma") (TpVar "808" "A")) (TpVar "812" "B"))) (TpAppt (TpVar "815" "B") (Parens "817" (App (Var "818" "fst") NotErased (Var "822" "x")) "824")))))) (Lam "827" Erased "829" "A" NoClass (Lam "832" Erased "834" "B" NoClass (Lam "837" NotErased "839" "x" NoClass (App (AppTp (App (Var "844" "SigmaInd") NotErased (Var "853" "x")) (TpParens "857" (TpLambda "858" "860" "x" (Tkt (TpApp (TpApp (TpVar "864" "Sigma") (TpVar "872" "A")) (TpVar "876" "B"))) (TpAppt (TpVar "879" "B") (Parens "881" (App (Var "882" "fst") NotErased (Var "886" "x")) "888"))) "889")) NotErased (Parens "890" (Lam "891" NotErased "893" "a" NoClass (Lam "896" NotErased "898" "b" NoClass (Var "901" "b"))) "903")))))) "904") (CmdsNext (DefTermOrType OpacTrans (DefType "907" "Cast" (KndArrow (KndParens "914" (KndTpArrow (TpVar "915" "Indices") (Star "925")) "927") (KndArrow (KndParens "930" (KndTpArrow (TpVar "931" "Indices") (Star "941")) "943") (Star "946"))) (TpLambda "950" "952" "A" (Tkk (KndTpArrow (TpVar "956" "Indices") (Star "966"))) (TpLambda "969" "971" "B" (Tkk (KndTpArrow (TpVar "975" "Indices") (Star "985"))) (Iota "990" "992" "cast" (Abs "999" Erased "1001" "indices" (Tkt (TpVar "1011" "Indices")) (TpArrow (TpAppt (TpVar "1020" "A") (Var "1022" "indices")) NotErased (TpAppt (TpVar "1032" "B") (Var "1034" "indices")))) (TpEq "1043" (Var "1044" "cast") (Lam "1051" NotErased "1053" "x" NoClass (Var "1056" "x")) "1058"))))) "1059") (CmdsNext (DefTermOrType OpacTrans (DefTerm "1061" "cast" (SomeType (Abs "1072" Erased "1074" "A" (Tkk (KndTpArrow (TpVar "1078" "Indices") (Star "1088"))) (Abs "1091" Erased "1093" "B" (Tkk (KndTpArrow (TpVar "1097" "Indices") (Star "1107"))) (TpArrow (TpApp (TpApp (TpVar "1110" "Cast") (TpVar "1117" "A")) (TpVar "1121" "B")) Erased (Abs "1129" Erased "1131" "indices" (Tkt (TpVar "1141" "Indices")) (TpArrow (TpAppt (TpVar "1150" "A") (Var "1152" "indices")) NotErased (TpAppt (TpVar "1162" "B") (Var "1164" "indices")))))))) (Lam "1176" Erased "1178" "A" NoClass (Lam "1181" Erased "1183" "B" NoClass (Lam "1186" Erased "1188" "c" NoClass (Phi "1191" (IotaProj (Var "1193" "c") "2" "1196") (IotaProj (Var "1199" "c") "1" "1202") (Lam "1204" NotErased "1206" "x" NoClass (Var "1209" "x")) "1211"))))) "1212") (CmdsNext (DefTermOrType OpacTrans (DefType "1214" "Functor" (KndArrow (KndParens "1224" (KndArrow (KndParens "1225" (KndTpArrow (TpVar "1226" "Indices") (Star "1236")) "1238") (KndTpArrow (TpVar "1241" "Indices") (Star "1251"))) "1253") (Star "1256")) (TpLambda "1262" "1264" "F" (Tkk (KndArrow (KndParens "1268" (KndTpArrow (TpVar "1269" "Indices") (Star "1279")) "1281") (KndTpArrow (TpVar "1284" "Indices") (Star "1294")))) (Abs "1297" Erased "1299" "X" (Tkk (KndTpArrow (TpVar "1303" "Indices") (Star "1313"))) (Abs "1316" Erased "1318" "Y" (Tkk (KndTpArrow (TpVar "1322" "Indices") (Star "1332"))) (TpArrow (TpApp (TpApp (TpVar "1339" "Cast") (TpVar "1346" "X")) (TpVar "1350" "Y")) Erased (TpApp (TpApp (TpVar "1354" "Cast") (TpParens "1361" (TpApp (TpVar "1362" "F") (TpVar "1366" "X")) "1368")) (TpParens "1371" (TpApp (TpVar "1372" "F") (TpVar "1376" "Y")) "1378"))))))) "1379") (CmdsNext (DefTermOrType OpacTrans (DefType "1382" "AlgM" (KndArrow (KndParens "1389" (KndArrow (KndParens "1390" (KndTpArrow (TpVar "1391" "Indices") (Star "1401")) "1403") (KndTpArrow (TpVar "1406" "Indices") (Star "1416"))) "1418") (KndArrow (Star "1421") (KndTpArrow (TpVar "1425" "Indices") (Star "1435")))) (TpLambda "1441" "1443" "F" (Tkk (KndArrow (KndParens "1447" (KndTpArrow (TpVar "1448" "Indices") (Star "1458")) "1460") (KndTpArrow (TpVar "1463" "Indices") (Star "1473")))) (TpLambda "1476" "1478" "A" (Tkk (Star "1482")) (TpLambda "1485" "1487" "indices" (Tkt (TpVar "1497" "Indices")) (Abs "1510" Erased "1512" "R" (Tkk (KndTpArrow (TpVar "1516" "Indices") (Star "1526"))) (TpArrow (TpParens "1529" (TpArrow (TpAppt (TpVar "1530" "R") (Var "1532" "indices")) NotErased (TpVar "1542" "A")) "1544") NotErased (TpArrow (TpAppt (TpApp (TpVar "1547" "F") (TpVar "1551" "R")) (Var "1553" "indices")) NotErased (TpVar "1563" "A")))))))) "1565") (CmdsNext (DefTermOrType OpacTrans (DefType "1567" "FixM" (KndArrow (KndParens "1574" (KndArrow (KndParens "1575" (KndTpArrow (TpVar "1576" "Indices") (Star "1586")) "1588") (KndTpArrow (TpVar "1591" "Indices") (Star "1601"))) "1603") (KndTpArrow (TpVar "1606" "Indices") (Star "1616"))) (TpLambda "1622" "1624" "F" (Tkk (KndArrow (KndParens "1628" (KndTpArrow (TpVar "1629" "Indices") (Star "1639")) "1641") (KndTpArrow (TpVar "1644" "Indices") (Star "1654")))) (TpLambda "1657" "1659" "indices" (Tkt (TpVar "1669" "Indices")) (Abs "1678" Erased "1680" "A" (Tkk (Star "1684")) (TpArrow (TpAppt (TpApp (TpApp (TpVar "1687" "AlgM") (TpVar "1694" "F")) (TpVar "1698" "A")) (Var "1700" "indices")) NotErased (TpVar "1710" "A")))))) "1712") (CmdsNext (DefTermOrType OpacTrans (DefTerm "1714" "foldM" (SomeType (Abs "1726" Erased "1728" "F" (Tkk (KndArrow (KndParens "1732" (KndTpArrow (TpVar "1733" "Indices") (Star "1743")) "1745") (KndTpArrow (TpVar "1748" "Indices") (Star "1758")))) (Abs "1761" Erased "1763" "A" (Tkk (Star "1767")) (Abs "1770" Erased "1772" "indices" (Tkt (TpVar "1782" "Indices")) (TpArrow (TpAppt (TpApp (TpApp (TpVar "1795" "AlgM") (TpVar "1802" "F")) (TpVar "1806" "A")) (Var "1808" "indices")) NotErased (TpArrow (TpAppt (TpApp (TpVar "1818" "FixM") (TpVar "1825" "F")) (Var "1827" "indices")) NotErased (TpVar "1837" "A"))))))) (Lam "1843" Erased "1845" "F" NoClass (Lam "1848" Erased "1850" "A" NoClass (Lam "1853" Erased "1855" "indices" NoClass (Lam "1864" NotErased "1866" "alg" NoClass (Lam "1871" NotErased "1873" "fix" NoClass (App (Var "1878" "fix") NotErased (Var "1882" "alg")))))))) "1886") (CmdsNext (DefTermOrType OpacTrans (DefTerm "1888" "inFixM" (SomeType (Abs "1901" Erased "1903" "F" (Tkk (KndArrow (KndParens "1907" (KndTpArrow (TpVar "1908" "Indices") (Star "1918")) "1920") (KndTpArrow (TpVar "1923" "Indices") (Star "1933")))) (Abs "1936" Erased "1938" "indices" (Tkt (TpVar "1948" "Indices")) (TpArrow (TpAppt (TpApp (TpVar "1961" "F") (TpParens "1965" (TpApp (TpVar "1966" "FixM") (TpVar "1973" "F")) "1975")) (Var "1976" "indices")) NotErased (TpAppt (TpApp (TpVar "1986" "FixM") (TpVar "1993" "F")) (Var "1995" "indices")))))) (Lam "2007" Erased "2009" "F" NoClass (Lam "2012" Erased "2014" "indices" NoClass (Lam "2023" NotErased "2025" "fexp" NoClass (Lam "2031" Erased "2033" "A" NoClass (Lam "2036" NotErased "2038" "alg" NoClass (App (App (Var "2043" "alg") NotErased (Parens "2047" (App (App (AppTp (AppTp (Var "2048" "foldM") (TpVar "2056" "F")) (TpVar "2060" "A")) Erased (Var "2063" "indices")) NotErased (Var "2071" "alg")) "2075")) NotErased (Var "2076" "fexp")))))))) "2081") (CmdsNext (DefTermOrType OpacTrans (DefType "2083" "PrfAlgM" (KndPi "2097" "2099" "F" (Tkk (KndArrow (KndParens "2103" (KndTpArrow (TpVar "2104" "Indices") (Star "2114")) "2116") (KndTpArrow (TpVar "2119" "Indices") (Star "2129")))) (KndTpArrow (TpApp (TpVar "2136" "Functor") (TpVar "2146" "F")) (KndPi "2154" "2156" "X" (Tkk (KndTpArrow (TpVar "2160" "Indices") (Star "2170"))) (KndArrow (KndParens "2177" (KndPi "2178" "2180" "indices" (Tkt (TpVar "2190" "Indices")) (KndTpArrow (TpAppt (TpVar "2199" "X") (Var "2201" "indices")) (Star "2211"))) "2213") (KndTpArrow (TpParens "2220" (Abs "2221" Erased "2223" "indices" (Tkt (TpVar "2233" "Indices")) (TpArrow (TpAppt (TpApp (TpVar "2242" "F") (TpVar "2246" "X")) (Var "2248" "indices")) NotErased (TpAppt (TpVar "2258" "X") (Var "2260" "indices")))) "2268") (Star "2275")))))) (TpLambda "2281" "2283" "F" (Tkk (KndArrow (KndParens "2287" (KndTpArrow (TpVar "2288" "Indices") (Star "2298")) "2300") (KndTpArrow (TpVar "2303" "Indices") (Star "2313")))) (TpLambda "2316" "2318" "fmap" (Tkt (TpApp (TpVar "2325" "Functor") (TpVar "2335" "F"))) (TpLambda "2338" "2340" "X" (Tkk (KndTpArrow (TpVar "2344" "Indices") (Star "2354"))) (TpLambda "2361" "2363" "Q" (Tkk (KndPi "2367" "2369" "indices" (Tkt (TpVar "2379" "Indices")) (KndTpArrow (TpAppt (TpVar "2388" "X") (Var "2390" "indices")) (Star "2400")))) (TpLambda "2409" "2411" "alg" (Tkt (TpParens "2417" (Abs "2418" Erased "2420" "indices" (Tkt (TpVar "2430" "Indices")) (TpArrow (TpAppt (TpApp (TpVar "2439" "F") (TpVar "2443" "X")) (Var "2445" "indices")) NotErased (TpAppt (TpVar "2455" "X") (Var "2457" "indices")))) "2465")) (Abs "2476" Erased "2478" "R" (Tkk (KndTpArrow (TpVar "2482" "Indices") (Star "2492"))) (Abs "2495" Erased "2497" "c" (Tkt (TpApp (TpApp (TpVar "2501" "Cast") (TpVar "2508" "R")) (TpVar "2512" "X"))) (TpArrow (TpParens "2524" (Abs "2525" Erased "2527" "indices" (Tkt (TpVar "2537" "Indices")) (Abs "2546" NotErased "2548" "r" (Tkt (TpAppt (TpVar "2552" "R") (Var "2554" "indices"))) (TpAppt (TpAppt (TpVar "2563" "Q") (Var "2565" "indices")) (Parens "2573" (App (App (App (Var "2574" "cast") Erased (Var "2580" "c")) Erased (Var "2583" "indices")) NotErased (Var "2591" "r")) "2593")))) "2594") NotErased (Abs "2605" Erased "2607" "indices" (Tkt (TpVar "2617" "Indices")) (Abs "2626" NotErased "2628" "gr" (Tkt (TpAppt (TpApp (TpVar "2633" "F") (TpVar "2637" "R")) (Var "2639" "indices"))) (TpAppt (TpAppt (TpVar "2656" "Q") (Var "2658" "indices")) (Parens "2666" (App (App (Var "2667" "alg") Erased (Var "2672" "indices")) NotErased (Parens "2680" (App (App (App (Var "2681" "cast") Erased (Parens "2687" (App (Var "2688" "fmap") Erased (Var "2694" "c")) "2696")) Erased (Var "2698" "indices")) NotErased (Var "2706" "gr")) "2709")) "2710"))))))))))))) "2711") (CmdsNext (DefTermOrType OpacTrans (DefType "2713" "IsIndFixM" (KndPi "2729" "2731" "F" (Tkk (KndArrow (KndParens "2735" (KndTpArrow (TpVar "2736" "Indices") (Star "2746")) "2748") (KndTpArrow (TpVar "2751" "Indices") (Star "2761")))) (KndTpArrow (TpApp (TpVar "2768" "Functor") (TpVar "2778" "F")) (KndPi "2786" "2788" "indices" (Tkt (TpVar "2798" "Indices")) (KndTpArrow (TpAppt (TpApp (TpVar "2811" "FixM") (TpVar "2818" "F")) (Var "2820" "indices")) (Star "2834"))))) (TpLambda "2840" "2842" "F" (Tkk (KndArrow (KndParens "2846" (KndTpArrow (TpVar "2847" "Indices") (Star "2857")) "2859") (KndTpArrow (TpVar "2862" "Indices") (Star "2872")))) (TpLambda "2875" "2877" "fmap" (Tkt (TpApp (TpVar "2884" "Functor") (TpVar "2894" "F"))) (TpLambda "2901" "2903" "indices" (Tkt (TpVar "2913" "Indices")) (TpLambda "2922" "2924" "x" (Tkt (TpAppt (TpApp (TpVar "2928" "FixM") (TpVar "2935" "F")) (Var "2937" "indices"))) (Abs "2952" Erased "2954" "Q" (Tkk (KndPi "2958" "2960" "indices" (Tkt (TpVar "2970" "Indices")) (KndTpArrow (TpAppt (TpApp (TpVar "2979" "FixM") (TpVar "2986" "F")) (Var "2988" "indices")) (Star "2998")))) (TpArrow (TpAppt (TpApp (TpApp (TpAppt (TpApp (TpVar "3007" "PrfAlgM") (TpVar "3017" "F")) (Var "3019" "fmap")) (TpParens "3026" (TpApp (TpVar "3027" "FixM") (TpVar "3034" "F")) "3036")) (TpVar "3039" "Q")) (Parens "3041" (AppTp (Var "3042" "inFixM") (TpVar "3051" "F")) "3053")) NotErased (TpAppt (TpAppt (TpVar "3056" "Q") (Var "3058" "indices")) (Var "3066" "x"))))))))) "3068") (CmdsNext (DefTermOrType OpacTrans (DefType "3070" "FixIndM" (KndPi "3080" "3082" "F" (Tkk (KndArrow (KndParens "3086" (KndTpArrow (TpVar "3087" "Indices") (Star "3097")) "3099") (KndTpArrow (TpVar "3102" "Indices") (Star "3112")))) (KndTpArrow (TpApp (TpVar "3115" "Functor") (TpVar "3125" "F")) (KndTpArrow (TpVar "3129" "Indices") (Star "3139")))) (TpLambda "3145" "3147" "F" (Tkk (KndArrow (KndParens "3151" (KndTpArrow (TpVar "3152" "Indices") (Star "3162")) "3164") (KndTpArrow (TpVar "3167" "Indices") (Star "3177")))) (TpLambda "3180" "3182" "fmap" (Tkt (TpApp (TpVar "3189" "Functor") (TpVar "3199" "F"))) (TpLambda "3202" "3204" "indices" (Tkt (TpVar "3214" "Indices")) (Iota "3227" "3229" "x" (TpAppt (TpApp (TpVar "3233" "FixM") (TpVar "3240" "F")) (Var "3242" "indices")) (TpAppt (TpAppt (TpAppt (TpApp (TpVar "3251" "IsIndFixM") (TpVar "3263" "F")) (Var "3265" "fmap")) (Var "3270" "indices")) (Var "3278" "x"))))))) "3280") (CmdsNext (DefTermOrType OpacTrans (DefTerm "3282" "inFixIndM" (SomeType (Abs "3294" Erased "3296" "F" (Tkk (KndArrow (KndParens "3300" (KndTpArrow (TpVar "3301" "Indices") (Star "3311")) "3313") (KndTpArrow (TpVar "3316" "Indices") (Star "3326")))) (Abs "3329" Erased "3331" "fmap" (Tkt (TpApp (TpVar "3338" "Functor") (TpVar "3348" "F"))) (Abs "3355" Erased "3357" "indices" (Tkt (TpVar "3367" "Indices")) (TpArrow (TpAppt (TpApp (TpVar "3376" "F") (TpParens "3380" (TpAppt (TpApp (TpVar "3381" "FixIndM") (TpVar "3391" "F")) (Var "3393" "fmap")) "3398")) (Var "3399" "indices")) NotErased (TpAppt (TpAppt (TpApp (TpVar "3409" "FixIndM") (TpVar "3419" "F")) (Var "3421" "fmap")) (Var "3426" "indices"))))))) (Lam "3438" Erased "3440" "F" NoClass (Lam "3443" Erased "3445" "fmap" NoClass (Lam "3451" Erased "3453" "indices" NoClass (Lam "3462" NotErased "3464" "v" NoClass (Let "3471" (DefTerm "3472" "outInd" (SomeType (TpApp (TpApp (TpVar "3481" "Cast") (TpParens "3488" (TpAppt (TpApp (TpVar "3489" "FixIndM") (TpVar "3499" "F")) (Var "3501" "fmap")) "3506")) (TpParens "3509" (TpApp (TpVar "3510" "FixM") (TpVar "3517" "F")) "3519"))) (IotaPair "3522" (Lam "3523" Erased "3525" "indices" NoClass (Lam "3534" NotErased "3536" "x" NoClass (IotaProj (Var "3539" "x") "1" "3542"))) (Beta "3544" NoTerm NoTerm) NoGuide "3546")) (IotaPair "3554" (App (App (AppTp (Var "3555" "inFixM") (TpVar "3564" "F")) Erased (Var "3567" "indices")) NotErased (Parens "3575" (App (App (App (Var "3576" "cast") Erased (Parens "3582" (App (Var "3583" "fmap") Erased (Var "3589" "outInd")) "3596")) Erased (Var "3598" "indices")) NotErased (Var "3606" "v")) "3608")) (Lam "3615" Erased "3617" "Q" NoClass (Lam "3620" NotErased "3622" "q" NoClass (App (App (App (App (Var "3625" "q") Erased (Var "3628" "outInd")) NotErased (Parens "3635" (Lam "3636" Erased "3638" "indices" NoClass (Lam "3647" NotErased "3649" "r" NoClass (App (IotaProj (Var "3652" "r") "2" "3655") NotErased (Var "3656" "q")))) "3658")) Erased (Var "3660" "indices")) NotErased (Var "3668" "v")))) NoGuide "3671"))))))) "3672") (CmdsNext (DefTermOrType OpacTrans (DefType "3674" "WithWitness" (KndPi "3688" "3690" "X" (Tkk (Star "3694")) (KndPi "3697" "3699" "Y" (Tkk (Star "3703")) (KndArrow (KndParens "3706" (KndTpArrow (TpVar "3707" "X") (Star "3711")) "3713") (KndTpArrow (TpVar "3716" "Y") (Star "3720"))))) (TpLambda "3726" "3728" "X" (Tkk (Star "3732")) (TpLambda "3735" "3737" "Y" (Tkk (Star "3741")) (TpLambda "3744" "3746" "Q" (Tkk (KndTpArrow (TpVar "3750" "X") (Star "3754"))) (TpLambda "3757" "3759" "y" (Tkt (TpVar "3763" "Y")) (TpApp (TpApp (TpVar "3770" "Sigma") (TpParens "3778" (Iota "3779" "3781" "x" (TpVar "3785" "X") (TpEq "3788" (Var "3789" "y") (Var "3793" "x") "3795")) "3796")) (TpParens "3799" (TpLambda "3800" "3802" "x" (Tkt (TpParens "3806" (Iota "3807" "3809" "x" (TpVar "3813" "X") (TpEq "3816" (Var "3817" "y") (Var "3821" "x") "3823")) "3824")) (TpAppt (TpVar "3826" "Q") (IotaProj (Var "3828" "x") "1" "3831"))) "3832"))))))) "3833") (CmdsNext (DefTermOrType OpacTrans (DefType "3835" "Lift" (KndPi "3846" "3848" "F" (Tkk (KndArrow (KndParens "3852" (KndTpArrow (TpVar "3853" "Indices") (Star "3863")) "3865") (KndTpArrow (TpVar "3868" "Indices") (Star "3878")))) (KndPi "3881" "3883" "fmap" (Tkt (TpApp (TpVar "3890" "Functor") (TpVar "3900" "F"))) (KndArrow (KndParens "3907" (KndPi "3908" "3910" "indices" (Tkt (TpVar "3920" "Indices")) (KndTpArrow (TpAppt (TpAppt (TpApp (TpVar "3929" "FixIndM") (TpVar "3939" "F")) (Var "3941" "fmap")) (Var "3946" "indices")) (Star "3956"))) "3958") (KndPi "3965" "3967" "indices" (Tkt (TpVar "3977" "Indices")) (KndTpArrow (TpAppt (TpApp (TpVar "3986" "FixM") (TpVar "3993" "F")) (Var "3995" "indices")) (Star "4009")))))) (TpLambda "4015" "4017" "F" (Tkk (KndArrow (KndParens "4021" (KndTpArrow (TpVar "4022" "Indices") (Star "4032")) "4034") (KndTpArrow (TpVar "4037" "Indices") (Star "4047")))) (TpLambda "4050" "4052" "fmap" (Tkt (TpApp (TpVar "4059" "Functor") (TpVar "4069" "F"))) (TpLambda "4076" "4078" "Q" (Tkk (KndPi "4082" "4084" "indices" (Tkt (TpVar "4094" "Indices")) (KndTpArrow (TpAppt (TpAppt (TpApp (TpVar "4103" "FixIndM") (TpVar "4113" "F")) (Var "4115" "fmap")) (Var "4120" "indices")) (Star "4130")))) (TpLambda "4139" "4141" "indices" (Tkt (TpVar "4151" "Indices")) (TpLambda "4160" "4162" "e" (Tkt (TpAppt (TpApp (TpVar "4166" "FixM") (TpVar "4173" "F")) (Var "4175" "indices"))) (TpAppt (TpApp (TpApp (TpApp (TpVar "4192" "WithWitness") (TpParens "4206" (TpAppt (TpAppt (TpApp (TpVar "4207" "FixIndM") (TpVar "4217" "F")) (Var "4219" "fmap")) (Var "4224" "indices")) "4232")) (TpParens "4235" (TpAppt (TpApp (TpVar "4236" "FixM") (TpVar "4243" "F")) (Var "4245" "indices")) "4253")) (TpParens "4256" (TpAppt (TpVar "4257" "Q") (Var "4259" "indices")) "4267")) (Var "4268" "e")))))))) "4270") (CmdsNext (DefTermOrType OpacTrans (DefTerm "4272" "LiftProp1" (SomeType (Abs "4288" Erased "4290" "F" (Tkk (KndArrow (KndParens "4294" (KndTpArrow (TpVar "4295" "Indices") (Star "4305")) "4307") (KndTpArrow (TpVar "4310" "Indices") (Star "4320")))) (Abs "4323" Erased "4325" "fmap" (Tkt (TpApp (TpVar "4332" "Functor") (TpVar "4342" "F"))) (Abs "4349" Erased "4351" "Q" (Tkk (KndPi "4355" "4357" "indices" (Tkt (TpVar "4367" "Indices")) (KndTpArrow (TpAppt (TpAppt (TpApp (TpVar "4376" "FixIndM") (TpVar "4386" "F")) (Var "4388" "fmap")) (Var "4393" "indices")) (Star "4403")))) (Abs "4410" Erased "4412" "indices" (Tkt (TpVar "4422" "Indices")) (Abs "4431" Erased "4433" "e" (Tkt (TpAppt (TpAppt (TpApp (TpVar "4437" "FixIndM") (TpVar "4447" "F")) (Var "4449" "fmap")) (Var "4454" "indices"))) (TpArrow (TpAppt (TpAppt (TpApp (TpAppt (TpApp (TpVar "4467" "Lift") (TpVar "4474" "F")) (Var "4476" "fmap")) (TpVar "4483" "Q")) (Var "4485" "indices")) (IotaProj (Var "4493" "e") "1" "4496")) NotErased (TpAppt (TpAppt (TpVar "4499" "Q") (Var "4501" "indices")) (Var "4509" "e"))))))))) (Lam "4515" Erased "4517" "F" NoClass (Lam "4520" Erased "4522" "fmap" NoClass (Lam "4528" Erased "4530" "Q" NoClass (Lam "4533" Erased "4535" "indices" NoClass (Lam "4544" Erased "4546" "e" NoClass (Lam "4549" NotErased "4551" "pr" NoClass (Rho "4555" RhoPlain NoNums (IotaProj (Parens "4557" (App (Var "4558" "fst") NotErased (Var "4562" "pr")) "4565") "2" "4567") NoGuide (App (Var "4570" "snd") NotErased (Var "4574" "pr")))))))))) "4577") (CmdsNext (DefTermOrType OpacTrans (DefTerm "4579" "LiftProp2" (SomeType (Abs "4595" Erased "4597" "F" (Tkk (KndArrow (KndParens "4601" (KndTpArrow (TpVar "4602" "Indices") (Star "4612")) "4614") (KndTpArrow (TpVar "4617" "Indices") (Star "4627")))) (Abs "4630" Erased "4632" "fmap" (Tkt (TpApp (TpVar "4639" "Functor") (TpVar "4649" "F"))) (Abs "4656" Erased "4658" "Q" (Tkk (KndPi "4662" "4664" "indices" (Tkt (TpVar "4674" "Indices")) (KndTpArrow (TpAppt (TpAppt (TpApp (TpVar "4683" "FixIndM") (TpVar "4693" "F")) (Var "4695" "fmap")) (Var "4700" "indices")) (Star "4710")))) (Abs "4717" Erased "4719" "indices" (Tkt (TpVar "4729" "Indices")) (Abs "4738" NotErased "4740" "e" (Tkt (TpAppt (TpAppt (TpApp (TpVar "4744" "FixIndM") (TpVar "4754" "F")) (Var "4756" "fmap")) (Var "4761" "indices"))) (TpArrow (TpAppt (TpAppt (TpVar "4774" "Q") (Var "4776" "indices")) (Var "4784" "e")) NotErased (TpAppt (TpAppt (TpApp (TpAppt (TpApp (TpVar "4788" "Lift") (TpVar "4795" "F")) (Var "4797" "fmap")) (TpVar "4804" "Q")) (Var "4806" "indices")) (IotaProj (Var "4814" "e") "1" "4817"))))))))) (Lam "4822" Erased "4824" "F" NoClass (Lam "4827" Erased "4829" "fmap" NoClass (Lam "4835" Erased "4837" "Q" NoClass (Lam "4840" Erased "4842" "indices" NoClass (Lam "4851" NotErased "4853" "e" NoClass (App (AppTp (AppTp (Var "4856" "sigma") (TpParens "4868" (Iota "4869" "4871" "x" (TpAppt (TpAppt (TpApp (TpVar "4875" "FixIndM") (TpVar "4885" "F")) (Var "4887" "fmap")) (Var "4892" "indices")) (TpEq "4901" (Var "4902" "e") (Var "4906" "x") "4908")) "4909")) (TpParens "4916" (TpLambda "4917" "4919" "x" (Tkt (Iota "4923" "4925" "x" (TpAppt (TpAppt (TpApp (TpVar "4929" "FixIndM") (TpVar "4939" "F")) (Var "4941" "fmap")) (Var "4946" "indices")) (TpEq "4955" (Var "4956" "e") (Var "4960" "x") "4962"))) (TpAppt (TpAppt (TpVar "4964" "Q") (Var "4966" "indices")) (IotaProj (Var "4974" "x") "1" "4977"))) "4978")) NotErased (IotaPair "4983" (Var "4984" "e") (Beta "4987" NoTerm (SomeTerm (Var "4989" "e") "4991")) NoGuide "4992")))))))) "4993") (CmdsNext (DefTermOrType OpacTrans (DefTerm "4995" "LiftProp3" (SomeType (Abs "5011" Erased "5013" "F" (Tkk (KndArrow (KndParens "5017" (KndTpArrow (TpVar "5018" "Indices") (Star "5028")) "5030") (KndTpArrow (TpVar "5033" "Indices") (Star "5043")))) (Abs "5046" Erased "5048" "fmap" (Tkt (TpApp (TpVar "5055" "Functor") (TpVar "5065" "F"))) (Abs "5072" Erased "5074" "Q" (Tkk (KndPi "5078" "5080" "indices" (Tkt (TpVar "5090" "Indices")) (KndTpArrow (TpAppt (TpAppt (TpApp (TpVar "5099" "FixIndM") (TpVar "5109" "F")) (Var "5111" "fmap")) (Var "5116" "indices")) (Star "5126")))) (Abs "5133" Erased "5135" "indices" (Tkt (TpVar "5145" "Indices")) (Abs "5154" Erased "5156" "e" (Tkt (TpAppt (TpApp (TpVar "5160" "FixM") (TpVar "5167" "F")) (Var "5169" "indices"))) (TpArrow (TpAppt (TpAppt (TpApp (TpAppt (TpApp (TpVar "5182" "Lift") (TpVar "5189" "F")) (Var "5191" "fmap")) (TpVar "5198" "Q")) (Var "5200" "indices")) (Var "5208" "e")) NotErased (TpAppt (TpAppt (TpApp (TpVar "5212" "FixIndM") (TpVar "5222" "F")) (Var "5224" "fmap")) (Var "5229" "indices"))))))))) (Lam "5241" Erased "5243" "F" NoClass (Lam "5246" Erased "5248" "fmap" NoClass (Lam "5254" Erased "5256" "Q" NoClass (Lam "5259" Erased "5261" "indices" NoClass (Lam "5270" Erased "5272" "e" NoClass (Lam "5275" NotErased "5277" "pr" NoClass (IotaProj (Parens "5281" (App (Var "5282" "fst") NotErased (Var "5286" "pr")) "5289") "1" "5291")))))))) "5292") (CmdsNext (DefTermOrType OpacTrans (DefTerm "5294" "LiftProp4" (SomeType (Abs "5310" Erased "5312" "F" (Tkk (KndArrow (KndParens "5316" (KndTpArrow (TpVar "5317" "Indices") (Star "5327")) "5329") (KndTpArrow (TpVar "5332" "Indices") (Star "5342")))) (Abs "5345" Erased "5347" "fmap" (Tkt (TpApp (TpVar "5354" "Functor") (TpVar "5364" "F"))) (Abs "5371" Erased "5373" "Q" (Tkk (KndPi "5377" "5379" "indices" (Tkt (TpVar "5389" "Indices")) (KndTpArrow (TpAppt (TpAppt (TpApp (TpVar "5398" "FixIndM") (TpVar "5408" "F")) (Var "5410" "fmap")) (Var "5415" "indices")) (Star "5425")))) (Abs "5432" Erased "5434" "indices" (Tkt (TpVar "5444" "Indices")) (Abs "5453" Erased "5455" "e" (Tkt (TpAppt (TpApp (TpVar "5459" "FixM") (TpVar "5466" "F")) (Var "5468" "indices"))) (Abs "5481" Erased "5483" "p" (Tkt (TpAppt (TpAppt (TpApp (TpAppt (TpApp (TpVar "5487" "Lift") (TpVar "5494" "F")) (Var "5496" "fmap")) (TpVar "5503" "Q")) (Var "5505" "indices")) (Var "5513" "e"))) (TpEq "5516" (App (Var "5517" "LiftProp3") NotErased (Var "5527" "p")) (Var "5531" "e") "5533")))))))) (Lam "5538" Erased "5540" "F" NoClass (Lam "5543" Erased "5545" "fmap" NoClass (Lam "5551" Erased "5553" "Q" NoClass (Lam "5556" Erased "5558" "indices" NoClass (Lam "5567" Erased "5569" "e" NoClass (Lam "5572" Erased "5574" "pr" NoClass (Rho "5578" RhoPlain NoNums (IotaProj (Parens "5580" (App (Var "5581" "fst") NotErased (Var "5585" "pr")) "5588") "2" "5590") NoGuide (Beta "5593" NoTerm NoTerm))))))))) "5595") (CmdsNext (DefTermOrType OpacTrans (DefTerm "5597" "convIH" (SomeType (Abs "5607" Erased "5609" "F" (Tkk (KndArrow (KndParens "5613" (KndTpArrow (TpVar "5614" "Indices") (Star "5624")) "5626") (KndTpArrow (TpVar "5629" "Indices") (Star "5639")))) (Abs "5642" Erased "5644" "fmap" (Tkt (TpApp (TpVar "5651" "Functor") (TpVar "5661" "F"))) (Abs "5665" Erased "5667" "Q" (Tkk (KndPi "5671" "5673" "indices" (Tkt (TpVar "5683" "Indices")) (KndTpArrow (TpAppt (TpAppt (TpApp (TpVar "5692" "FixIndM") (TpVar "5702" "F")) (Var "5704" "fmap")) (Var "5709" "indices")) (Star "5719")))) (Abs "5723" Erased "5725" "Y" (Tkk (KndPi "5729" "5731" "indices" (Tkt (TpVar "5741" "Indices")) (KndTpArrow (TpAppt (TpApp (TpVar "5750" "FixM") (TpVar "5757" "F")) (Var "5759" "indices")) (Star "5769")))) (Abs "5773" NotErased "5775" "Yprop1" (Tkt (Abs "5784" Erased "5786" "indices" (Tkt (TpVar "5796" "Indices")) (Abs "5805" Erased "5807" "e" (Tkt (TpAppt (TpAppt (TpApp (TpVar "5811" "FixIndM") (TpVar "5821" "F")) (Var "5823" "fmap")) (Var "5828" "indices"))) (TpArrow (TpAppt (TpAppt (TpVar "5837" "Y") (Var "5839" "indices")) (IotaProj (Var "5847" "e") "1" "5850")) NotErased (TpAppt (TpAppt (TpVar "5853" "Q") (Var "5855" "indices")) (Var "5863" "e")))))) (Abs "5867" NotErased "5869" "Yprop2" (Tkt (Abs "5878" Erased "5880" "indices" (Tkt (TpVar "5890" "Indices")) (Abs "5899" NotErased "5901" "e" (Tkt (TpAppt (TpAppt (TpApp (TpVar "5905" "FixIndM") (TpVar "5915" "F")) (Var "5917" "fmap")) (Var "5922" "indices"))) (TpArrow (TpAppt (TpAppt (TpVar "5931" "Q") (Var "5933" "indices")) (Var "5941" "e")) NotErased (TpAppt (TpAppt (TpVar "5945" "Y") (Var "5947" "indices")) (IotaProj (Var "5955" "e") "1" "5958")))))) (Abs "5961" NotErased "5963" "Yprop3" (Tkt (Abs "5972" Erased "5974" "indices" (Tkt (TpVar "5984" "Indices")) (Abs "5993" Erased "5995" "e" (Tkt (TpAppt (TpApp (TpVar "5999" "FixM") (TpVar "6006" "F")) (Var "6008" "indices"))) (TpArrow (TpAppt (TpAppt (TpVar "6017" "Y") (Var "6019" "indices")) (Var "6027" "e")) NotErased (TpAppt (TpAppt (TpApp (TpVar "6031" "FixIndM") (TpVar "6041" "F")) (Var "6043" "fmap")) (Var "6048" "indices")))))) (Abs "6058" NotErased "6060" "Yprop4" (Tkt (Abs "6069" Erased "6071" "indices" (Tkt (TpVar "6081" "Indices")) (Abs "6090" Erased "6092" "e" (Tkt (TpAppt (TpApp (TpVar "6096" "FixM") (TpVar "6103" "F")) (Var "6105" "indices"))) (Abs "6114" Erased "6116" "p" (Tkt (TpAppt (TpAppt (TpVar "6120" "Y") (Var "6122" "indices")) (Var "6130" "e"))) (TpEq "6133" (App (Var "6134" "Yprop3") NotErased (Var "6141" "p")) (Var "6145" "e") "6147"))))) (TpArrow (TpAppt (TpApp (TpApp (TpAppt (TpApp (TpVar "6150" "PrfAlgM") (TpVar "6160" "F")) (Var "6162" "fmap")) (TpParens "6169" (TpAppt (TpApp (TpVar "6170" "FixIndM") (TpVar "6180" "F")) (Var "6182" "fmap")) "6187")) (TpVar "6190" "Q")) (Parens "6192" (App (AppTp (Var "6193" "inFixIndM") (TpVar "6205" "F")) Erased (Var "6208" "fmap")) "6213")) NotErased (TpAppt (TpApp (TpApp (TpAppt (TpApp (TpVar "6217" "PrfAlgM") (TpVar "6227" "F")) (Var "6229" "fmap")) (TpParens "6236" (TpApp (TpVar "6237" "FixM") (TpVar "6244" "F")) "6246")) (TpVar "6249" "Y")) (Parens "6251" (AppTp (Var "6252" "inFixM") (TpVar "6261" "F")) "6263")))))))))))) (Lam "6268" Erased "6270" "F" NoClass (Lam "6273" Erased "6275" "fmap" NoClass (Lam "6281" Erased "6283" "Q" NoClass (Lam "6286" Erased "6288" "Y" NoClass (Lam "6291" NotErased "6293" "qp3" NoClass (Lam "6298" NotErased "6300" "qp4" NoClass (Lam "6305" NotErased "6307" "qp1" NoClass (Lam "6312" NotErased "6314" "qp2" NoClass (Lam "6319" NotErased "6321" "q" NoClass (Lam "6324" Erased "6326" "R" NoClass (Lam "6329" Erased "6331" "cst" NoClass (Lam "6336" NotErased "6338" "ih" NoClass (Lam "6342" Erased "6344" "indices" NoClass (Lam "6353" NotErased "6355" "gr" NoClass (Let "6363" (DefTerm "6364" "cst2" (SomeType (TpApp (TpApp (TpVar "6371" "Cast") (TpVar "6378" "R")) (TpParens "6382" (TpAppt (TpApp (TpVar "6383" "FixIndM") (TpVar "6393" "F")) (Var "6395" "fmap")) "6400"))) (IotaPair "6409" (Lam "6410" Erased "6412" "indices" NoClass (Lam "6421" NotErased "6423" "r" NoClass (Phi "6426" (Parens "6428" (App (App (App (Var "6429" "qp2") Erased (Var "6434" "indices")) Erased (Parens "6443" (App (App (App (Var "6444" "cast") Erased (Var "6450" "cst")) Erased (Var "6455" "indices")) NotErased (Var "6463" "r")) "6465")) Erased (Parens "6467" (App (App (Var "6468" "ih") Erased (Var "6472" "indices")) NotErased (Var "6480" "r")) "6482")) "6483") (Parens "6494" (App (App (App (Var "6495" "qp1") Erased (Var "6500" "indices")) Erased (Parens "6509" (App (App (App (Var "6510" "cast") Erased (Var "6516" "cst")) Erased (Var "6521" "indices")) NotErased (Var "6529" "r")) "6531")) NotErased (Parens "6532" (App (App (Var "6533" "ih") Erased (Var "6537" "indices")) NotErased (Var "6545" "r")) "6547")) "6548") (Var "6550" "r") "6552"))) (Beta "6554" NoTerm NoTerm) NoGuide "6556")) (App (App (App (Var "6564" "qp4") Erased (Var "6569" "indices")) NotErased (Parens "6577" (App (App (App (Var "6578" "inFixIndM") Erased (Var "6589" "fmap")) Erased (Var "6595" "indices")) NotErased (Parens "6603" (App (App (App (Var "6604" "cast") Erased (Parens "6610" (App (Var "6611" "fmap") Erased (Var "6617" "cst2")) "6622")) Erased (Var "6624" "indices")) NotErased (Var "6632" "gr")) "6635")) "6636")) NotErased (Parens "6643" (App (App (App (App (Var "6644" "q") Erased (Var "6647" "cst2")) NotErased (Parens "6652" (Lam "6653" Erased "6655" "indices" NoClass (Lam "6664" NotErased "6666" "r" NoClass (App (App (App (Var "6669" "qp3") Erased (Var "6674" "indices")) Erased (Parens "6683" (App (App (App (Var "6684" "cast") Erased (Var "6690" "cst2")) Erased (Var "6696" "indices")) NotErased (Var "6704" "r")) "6706")) NotErased (Parens "6707" (App (App (Var "6708" "ih") Erased (Var "6712" "indices")) NotErased (Var "6720" "r")) "6722")))) "6723")) Erased (Var "6733" "indices")) NotErased (Var "6741" "gr")) "6744")))))))))))))))))) "6745") (CmdsNext (DefTermOrType OpacTrans (DefTerm "6747" "indFixIndM" (SomeType (Abs "6760" Erased "6762" "F" (Tkk (KndArrow (KndParens "6766" (KndTpArrow (TpVar "6767" "Indices") (Star "6777")) "6779") (KndTpArrow (TpVar "6782" "Indices") (Star "6792")))) (Abs "6795" Erased "6797" "fmap" (Tkt (TpApp (TpVar "6804" "Functor") (TpVar "6814" "F"))) (Abs "6830" Erased "6832" "indices" (Tkt (TpVar "6842" "Indices")) (Abs "6851" NotErased "6853" "e" (Tkt (TpAppt (TpAppt (TpApp (TpVar "6857" "FixIndM") (TpVar "6867" "F")) (Var "6869" "fmap")) (Var "6874" "indices"))) (Abs "6896" Erased "6898" "Q" (Tkk (KndPi "6902" "6904" "indices" (Tkt (TpVar "6914" "Indices")) (KndTpArrow (TpAppt (TpAppt (TpApp (TpVar "6923" "FixIndM") (TpVar "6933" "F")) (Var "6935" "fmap")) (Var "6940" "indices")) (Star "6950")))) (TpArrow (TpAppt (TpApp (TpApp (TpAppt (TpApp (TpVar "6966" "PrfAlgM") (TpVar "6976" "F")) (Var "6978" "fmap")) (TpParens "6985" (TpAppt (TpApp (TpVar "6986" "FixIndM") (TpVar "6996" "F")) (Var "6998" "fmap")) "7003")) (TpVar "7006" "Q")) (Parens "7008" (App (AppTp (Var "7009" "inFixIndM") (TpVar "7021" "F")) Erased (Var "7024" "fmap")) "7029")) NotErased (TpAppt (TpAppt (TpVar "7045" "Q") (Var "7047" "indices")) (Var "7055" "e"))))))))) (Lam "7062" Erased "7064" "F" NoClass (Lam "7067" Erased "7069" "fmap" NoClass (Lam "7075" Erased "7077" "indices" NoClass (Lam "7086" NotErased "7088" "e" NoClass (Lam "7091" Erased "7093" "Q" NoClass (Lam "7096" NotErased "7098" "q" NoClass (App (App (App (AppTp (App (Var "7101" "LiftProp1") Erased (Var "7112" "fmap")) (TpVar "7119" "Q")) Erased (Var "7122" "indices")) Erased (Var "7131" "e")) NotErased (Parens "7137" (App (IotaProj (Var "7138" "e") "2" "7141") NotErased (Parens "7142" (App (App (App (App (App (App (Var "7143" "convIH") Erased (Var "7151" "fmap")) NotErased (Parens "7162" (AppTp (App (Var "7163" "LiftProp1") Erased (Var "7174" "fmap")) (TpVar "7181" "Q")) "7183")) NotErased (Parens "7190" (AppTp (App (Var "7191" "LiftProp2") Erased (Var "7202" "fmap")) (TpVar "7209" "Q")) "7211")) NotErased (Parens "7218" (AppTp (App (Var "7219" "LiftProp3") Erased (Var "7230" "fmap")) (TpVar "7237" "Q")) "7239")) NotErased (Parens "7246" (AppTp (App (Var "7247" "LiftProp4") Erased (Var "7258" "fmap")) (TpVar "7265" "Q")) "7267")) NotErased (Var "7274" "q")) "7276")) "7277"))))))))) "7278") (CmdsNext (DefTermOrType OpacTrans (DefTerm "7281" "outAlgM" (SomeType (Abs "7295" Erased "7297" "F" (Tkk (KndArrow (KndParens "7301" (KndTpArrow (TpVar "7302" "Indices") (Star "7312")) "7314") (KndTpArrow (TpVar "7317" "Indices") (Star "7327")))) (Abs "7330" Erased "7332" "fmap" (Tkt (TpApp (TpVar "7339" "Functor") (TpVar "7349" "F"))) (TpAppt (TpApp (TpApp (TpAppt (TpApp (TpVar "7352" "PrfAlgM") (TpVar "7362" "F")) (Var "7364" "fmap")) (TpParens "7377" (TpAppt (TpApp (TpVar "7378" "FixIndM") (TpVar "7388" "F")) (Var "7390" "fmap")) "7395")) (TpParens "7398" (TpLambda "7399" "7401" "indices" (Tkt (TpVar "7411" "Indices")) (TpLambda "7420" "7422" "_" (Tkt (TpAppt (TpAppt (TpApp (TpVar "7426" "FixIndM") (TpVar "7436" "F")) (Var "7438" "fmap")) (Var "7443" "indices"))) (TpAppt (TpApp (TpVar "7483" "F") (TpParens "7487" (TpAppt (TpApp (TpVar "7488" "FixIndM") (TpVar "7498" "F")) (Var "7500" "fmap")) "7505")) (Var "7506" "indices")))) "7514")) (Parens "7515" (App (AppTp (Var "7516" "inFixIndM") (TpVar "7528" "F")) Erased (Var "7531" "fmap")) "7536"))))) (Lam "7541" Erased "7543" "F" NoClass (Lam "7546" Erased "7548" "fmap" NoClass (Lam "7554" Erased "7556" "R" NoClass (Lam "7559" Erased "7561" "c" NoClass (Lam "7564" NotErased "7566" "x" NoClass (App (Var "7569" "cast") Erased (Parens "7575" (App (Var "7576" "fmap") Erased (Var "7582" "c")) "7584")))))))) "7585") (CmdsNext (DefTermOrType OpacTrans (DefTerm "7587" "outFixIndM" (SomeType (Abs "7604" Erased "7606" "F" (Tkk (KndArrow (KndParens "7610" (KndTpArrow (TpVar "7611" "Indices") (Star "7621")) "7623") (KndTpArrow (TpVar "7626" "Indices") (Star "7636")))) (Abs "7639" Erased "7641" "fmap" (Tkt (TpApp (TpVar "7648" "Functor") (TpVar "7658" "F"))) (Abs "7661" Erased "7663" "indices" (Tkt (TpVar "7673" "Indices")) (TpArrow (TpAppt (TpAppt (TpApp (TpVar "7686" "FixIndM") (TpVar "7696" "F")) (Var "7698" "fmap")) (Var "7703" "indices")) NotErased (TpAppt (TpApp (TpVar "7713" "F") (TpParens "7717" (TpAppt (TpApp (TpVar "7718" "FixIndM") (TpVar "7728" "F")) (Var "7730" "fmap")) "7735")) (Var "7736" "indices"))))))) (Lam "7748" Erased "7750" "F" NoClass (Lam "7753" Erased "7755" "fmap" NoClass (Lam "7761" Erased "7763" "indices" NoClass (Lam "7772" NotErased "7774" "e" NoClass (App (AppTp (App (App (App (Var "7777" "indFixIndM") Erased (Var "7789" "fmap")) Erased (Var "7795" "indices")) NotErased (Var "7803" "e")) (TpParens "7811" (TpLambda "7812" "7814" "indices" (Tkt (TpVar "7824" "Indices")) (TpLambda "7833" "7835" "_" (Tkt (TpAppt (TpAppt (TpApp (TpVar "7839" "FixIndM") (TpVar "7849" "F")) (Var "7851" "fmap")) (Var "7856" "indices"))) (TpAppt (TpApp (TpVar "7865" "F") (TpParens "7869" (TpAppt (TpApp (TpVar "7870" "FixIndM") (TpVar "7880" "F")) (Var "7882" "fmap")) "7887")) (Var "7888" "indices")))) "7896")) NotErased (Parens "7901" (App (AppTp (Var "7902" "outAlgM") (TpVar "7912" "F")) Erased (Var "7915" "fmap")) "7920"))))))) "7921") (CmdsNext (DefTermOrType OpacTrans (DefType "7924" "Cowedge" (KndArrow (KndParens "7934" (KndArrow (KndParens "7935" (KndTpArrow (TpVar "7936" "Indices") (Star "7946")) "7948") (KndTpArrow (TpVar "7951" "Indices") (Star "7961"))) "7963") (KndArrow (KndParens "7966" (KndTpArrow (TpVar "7967" "Indices") (Star "7977")) "7979") (KndTpArrow (TpVar "7982" "Indices") (Star "7992")))) (TpLambda "7998" "8000" "F" (Tkk (KndArrow (KndParens "8004" (KndTpArrow (TpVar "8005" "Indices") (Star "8015")) "8017") (KndTpArrow (TpVar "8020" "Indices") (Star "8030")))) (TpLambda "8033" "8035" "D" (Tkk (KndTpArrow (TpVar "8039" "Indices") (Star "8049"))) (TpLambda "8052" "8054" "indices" (Tkt (TpVar "8064" "Indices")) (Abs "8077" Erased "8079" "A" (Tkk (KndTpArrow (TpVar "8083" "Indices") (Star "8093"))) (TpArrow (TpParens "8100" (Abs "8101" Erased "8103" "indices" (Tkt (TpVar "8113" "Indices")) (TpArrow (TpAppt (TpVar "8122" "A") (Var "8124" "indices")) NotErased (TpAppt (TpVar "8134" "D") (Var "8136" "indices")))) "8144") NotErased (TpArrow (TpAppt (TpApp (TpVar "8151" "F") (TpVar "8155" "A")) (Var "8157" "indices")) NotErased (TpAppt (TpVar "8171" "D") (Var "8173" "indices"))))))))) "8181") (CmdsNext (DefTermOrType OpacTrans (DefType "8182" "Coend" (KndArrow (KndParens "8190" (KndArrow (KndParens "8191" (KndTpArrow (TpVar "8192" "Indices") (Star "8202")) "8204") (KndTpArrow (TpVar "8207" "Indices") (Star "8217"))) "8219") (KndArrow (KndParens "8222" (KndTpArrow (TpVar "8223" "Indices") (Star "8233")) "8235") (KndTpArrow (TpVar "8238" "Indices") (Star "8248")))) (TpLambda "8254" "8256" "F" (Tkk (KndArrow (KndParens "8260" (KndTpArrow (TpVar "8261" "Indices") (Star "8271")) "8273") (KndTpArrow (TpVar "8276" "Indices") (Star "8286")))) (TpLambda "8289" "8291" "A" (Tkk (KndTpArrow (TpVar "8295" "Indices") (Star "8305"))) (TpLambda "8308" "8310" "indices" (Tkt (TpVar "8320" "Indices")) (Abs "8333" Erased "8335" "Y" (Tkk (Star "8339")) (TpArrow (TpParens "8346" (Abs "8347" Erased "8349" "R" (Tkk (KndTpArrow (TpVar "8353" "Indices") (Star "8363"))) (TpArrow (TpParens "8366" (Abs "8367" Erased "8369" "indices" (Tkt (TpVar "8379" "Indices")) (TpArrow (TpAppt (TpVar "8388" "R") (Var "8390" "indices")) NotErased (TpAppt (TpVar "8400" "A") (Var "8402" "indices")))) "8410") NotErased (TpArrow (TpAppt (TpApp (TpVar "8413" "F") (TpVar "8417" "R")) (Var "8419" "indices")) NotErased (TpVar "8429" "Y")))) "8431") NotErased (TpVar "8438" "Y"))))))) "8440") (CmdsNext (DefTermOrType OpacTrans (DefTerm "8442" "intrCoend" (SomeType (Abs "8458" Erased "8460" "F" (Tkk (KndArrow (KndParens "8464" (KndTpArrow (TpVar "8465" "Indices") (Star "8475")) "8477") (KndTpArrow (TpVar "8480" "Indices") (Star "8490")))) (Abs "8497" Erased "8499" "C" (Tkk (KndTpArrow (TpVar "8503" "Indices") (Star "8513"))) (Abs "8520" Erased "8522" "R" (Tkk (KndTpArrow (TpVar "8526" "Indices") (Star "8536"))) (Abs "8543" Erased "8545" "indices" (Tkt (TpVar "8555" "Indices")) (TpArrow (TpParens "8568" (Abs "8569" Erased "8571" "indices" (Tkt (TpVar "8581" "Indices")) (TpArrow (TpAppt (TpVar "8590" "R") (Var "8592" "indices")) NotErased (TpAppt (TpVar "8602" "C") (Var "8604" "indices")))) "8612") NotErased (TpArrow (TpAppt (TpApp (TpVar "8619" "F") (TpVar "8623" "R")) (Var "8625" "indices")) NotErased (TpAppt (TpApp (TpApp (TpVar "8639" "Coend") (TpVar "8647" "F")) (TpVar "8651" "C")) (Var "8653" "indices"))))))))) (Lam "8665" Erased "8667" "F" NoClass (Lam "8670" Erased "8672" "C" NoClass (Lam "8675" Erased "8677" "R" NoClass (Lam "8680" Erased "8682" "indices" NoClass (Lam "8691" NotErased "8693" "ac" NoClass (Lam "8697" NotErased "8699" "ga" NoClass (Lam "8703" Erased "8705" "Y" NoClass (Lam "8708" NotErased "8710" "q" NoClass (App (App (Var "8713" "q") NotErased (Var "8715" "ac")) NotErased (Var "8718" "ga"))))))))))) "8721") (CmdsNext (DefTermOrType OpacTrans (DefTerm "8723" "elimCoend" (SomeType (Abs "8739" Erased "8741" "F" (Tkk (KndArrow (KndParens "8745" (KndTpArrow (TpVar "8746" "Indices") (Star "8756")) "8758") (KndTpArrow (TpVar "8761" "Indices") (Star "8771")))) (Abs "8778" Erased "8780" "A" (Tkk (KndTpArrow (TpVar "8784" "Indices") (Star "8794"))) (Abs "8801" Erased "8803" "D" (Tkk (Star "8807")) (Abs "8814" Erased "8816" "indices" (Tkt (TpVar "8826" "Indices")) (TpArrow (TpParens "8839" (Abs "8840" Erased "8842" "R" (Tkk (KndTpArrow (TpVar "8846" "Indices") (Star "8856"))) (TpArrow (TpParens "8859" (Abs "8860" Erased "8862" "indices" (Tkt (TpVar "8872" "Indices")) (TpArrow (TpAppt (TpVar "8881" "R") (Var "8883" "indices")) NotErased (TpAppt (TpVar "8893" "A") (Var "8895" "indices")))) "8903") NotErased (TpArrow (TpAppt (TpApp (TpVar "8906" "F") (TpVar "8910" "R")) (Var "8912" "indices")) NotErased (TpVar "8922" "D")))) "8924") NotErased (TpArrow (TpAppt (TpApp (TpApp (TpVar "8931" "Coend") (TpVar "8939" "F")) (TpVar "8943" "A")) (Var "8945" "indices")) NotErased (TpVar "8959" "D")))))))) (Lam "8965" Erased "8967" "F" NoClass (Lam "8970" Erased "8972" "A" NoClass (Lam "8975" Erased "8977" "D" NoClass (Lam "8980" Erased "8982" "indices" NoClass (Lam "8991" NotErased "8993" "phi" NoClass (Lam "8998" NotErased "9000" "e" NoClass (App (Var "9003" "e") NotErased (Var "9005" "phi"))))))))) "9009") (CmdsNext (DefTermOrType OpacTrans (DefType "9011" "CoendInductive" (KndPi "9032" "9034" "F" (Tkk (KndArrow (KndParens "9038" (KndTpArrow (TpVar "9039" "Indices") (Star "9049")) "9051") (KndTpArrow (TpVar "9054" "Indices") (Star "9064")))) (KndPi "9067" "9069" "C" (Tkk (KndTpArrow (TpVar "9073" "Indices") (Star "9083"))) (KndPi "9090" "9092" "indices" (Tkt (TpVar "9102" "Indices")) (KndTpArrow (TpAppt (TpApp (TpApp (TpVar "9111" "Coend") (TpVar "9119" "F")) (TpVar "9123" "C")) (Var "9125" "indices")) (Star "9135"))))) (TpLambda "9141" "9143" "F" (Tkk (KndArrow (KndParens "9147" (KndTpArrow (TpVar "9148" "Indices") (Star "9158")) "9160") (KndTpArrow (TpVar "9163" "Indices") (Star "9173")))) (TpLambda "9176" "9178" "C" (Tkk (KndTpArrow (TpVar "9182" "Indices") (Star "9192"))) (TpLambda "9199" "9201" "indices" (Tkt (TpVar "9211" "Indices")) (TpLambda "9220" "9222" "e" (Tkt (TpAppt (TpApp (TpApp (TpVar "9226" "Coend") (TpVar "9234" "F")) (TpVar "9238" "C")) (Var "9240" "indices"))) (Abs "9255" Erased "9257" "Q" (Tkk (KndPi "9261" "9263" "indices" (Tkt (TpVar "9273" "Indices")) (KndTpArrow (TpAppt (TpApp (TpApp (TpVar "9282" "Coend") (TpVar "9290" "F")) (TpVar "9294" "C")) (Var "9296" "indices")) (Star "9306")))) (TpArrow (TpParens "9315" (Abs "9316" Erased "9318" "R" (Tkk (KndTpArrow (TpVar "9322" "Indices") (Star "9332"))) (Abs "9335" Erased "9337" "indices" (Tkt (TpVar "9347" "Indices")) (Abs "9356" NotErased "9358" "c" (Tkt (TpApp (TpApp (TpVar "9362" "Cast") (TpVar "9369" "R")) (TpVar "9373" "C"))) (Abs "9384" NotErased "9386" "gr" (Tkt (TpAppt (TpApp (TpVar "9391" "F") (TpVar "9395" "R")) (Var "9397" "indices"))) (TpAppt (TpAppt (TpVar "9406" "Q") (Var "9408" "indices")) (Parens "9416" (App (App (App (AppTp (AppTp (AppTp (Var "9417" "intrCoend") (TpVar "9429" "F")) (TpVar "9433" "C")) (TpVar "9437" "R")) Erased (Var "9440" "indices")) NotErased (Parens "9448" (App (Var "9449" "cast") Erased (Var "9455" "c")) "9457")) NotErased (Var "9458" "gr")) "9461")))))) "9462") NotErased (TpAppt (TpAppt (TpVar "9471" "Q") (Var "9473" "indices")) (Var "9481" "e"))))))))) "9483") (CmdsNext (DefTermOrType OpacTrans (DefType "9485" "CoendInd" (KndArrow (KndParens "9496" (KndArrow (KndParens "9497" (KndTpArrow (TpVar "9498" "Indices") (Star "9508")) "9510") (KndTpArrow (TpVar "9513" "Indices") (Star "9523"))) "9525") (KndArrow (KndParens "9528" (KndTpArrow (TpVar "9529" "Indices") (Star "9539")) "9541") (KndTpArrow (TpVar "9544" "Indices") (Star "9554")))) (TpLambda "9560" "9562" "G" (Tkk (KndArrow (KndParens "9566" (KndTpArrow (TpVar "9567" "Indices") (Star "9577")) "9579") (KndTpArrow (TpVar "9582" "Indices") (Star "9592")))) (TpLambda "9595" "9597" "C" (Tkk (KndTpArrow (TpVar "9601" "Indices") (Star "9611"))) (TpLambda "9614" "9616" "indices" (Tkt (TpVar "9626" "Indices")) (Iota "9639" "9641" "x" (TpAppt (TpApp (TpApp (TpVar "9645" "Coend") (TpVar "9653" "G")) (TpVar "9657" "C")) (Var "9659" "indices")) (TpAppt (TpAppt (TpApp (TpApp (TpVar "9668" "CoendInductive") (TpVar "9686" "G")) (TpVar "9690" "C")) (Var "9692" "indices")) (Var "9700" "x"))))))) "9702") (CmdsNext (DefTermOrType OpacTrans (DefTerm "9705" "intrCoendInd" (SomeType (Abs "9724" Erased "9726" "F" (Tkk (KndArrow (KndParens "9730" (KndTpArrow (TpVar "9731" "Indices") (Star "9741")) "9743") (KndTpArrow (TpVar "9746" "Indices") (Star "9756")))) (Abs "9763" Erased "9765" "C" (Tkk (KndTpArrow (TpVar "9769" "Indices") (Star "9779"))) (Abs "9782" Erased "9784" "R" (Tkk (KndTpArrow (TpVar "9788" "Indices") (Star "9798"))) (Abs "9801" Erased "9803" "indices" (Tkt (TpVar "9813" "Indices")) (TpArrow (TpApp (TpApp (TpVar "9826" "Cast") (TpVar "9833" "R")) (TpVar "9837" "C")) Erased (TpArrow (TpAppt (TpApp (TpVar "9841" "F") (TpVar "9845" "R")) (Var "9847" "indices")) NotErased (TpAppt (TpApp (TpApp (TpVar "9857" "CoendInd") (TpVar "9868" "F")) (TpVar "9872" "C")) (Var "9874" "indices"))))))))) (Lam "9886" Erased "9888" "F" NoClass (Lam "9891" Erased "9893" "C" NoClass (Lam "9896" Erased "9898" "R" NoClass (Lam "9901" Erased "9903" "indices" NoClass (Lam "9912" Erased "9914" "f" NoClass (Lam "9917" NotErased "9919" "gr" NoClass (IotaPair "9927" (App (App (App (AppTp (AppTp (AppTp (Var "9928" "intrCoend") (TpVar "9940" "F")) (TpVar "9944" "C")) (TpVar "9948" "R")) Erased (Var "9951" "indices")) NotErased (Parens "9959" (App (Var "9960" "cast") Erased (Var "9966" "f")) "9968")) NotErased (Var "9969" "gr")) (Lam "9973" Erased "9975" "Q" NoClass (Lam "9978" NotErased "9980" "q" NoClass (App (App (App (AppTp (Var "9983" "q") (TpVar "9987" "R")) Erased (Var "9990" "indices")) NotErased (IotaPair "9998" (App (Var "9999" "cast") Erased (Var "10005" "f")) (Beta "10008" NoTerm NoTerm) NoGuide "10010")) NotErased (Var "10011" "gr")))) NoGuide "10014")))))))) "10015") (CmdsNext (DefTermOrType OpacTrans (DefTerm "10018" "indCoend'" (SomeType (Abs "10034" Erased "10036" "F" (Tkk (KndArrow (KndParens "10040" (KndTpArrow (TpVar "10041" "Indices") (Star "10051")) "10053") (KndTpArrow (TpVar "10056" "Indices") (Star "10066")))) (Abs "10069" Erased "10071" "C" (Tkk (KndTpArrow (TpVar "10075" "Indices") (Star "10085"))) (Abs "10088" Erased "10090" "indices" (Tkt (TpVar "10100" "Indices")) (Abs "10113" NotErased "10115" "e" (Tkt (TpAppt (TpApp (TpApp (TpVar "10119" "CoendInd") (TpVar "10130" "F")) (TpVar "10134" "C")) (Var "10136" "indices"))) (Abs "10149" Erased "10151" "Q" (Tkk (KndPi "10155" "10157" "indices" (Tkt (TpVar "10167" "Indices")) (KndTpArrow (TpAppt (TpApp (TpApp (TpVar "10176" "CoendInd") (TpVar "10187" "F")) (TpVar "10191" "C")) (Var "10193" "indices")) (Star "10203")))) (TpArrow (TpParens "10210" (Abs "10211" Erased "10213" "R" (Tkk (KndTpArrow (TpVar "10217" "Indices") (Star "10227"))) (Abs "10230" Erased "10232" "indices" (Tkt (TpVar "10242" "Indices")) (Abs "10251" Erased "10253" "c" (Tkt (TpApp (TpApp (TpVar "10257" "Cast") (TpVar "10264" "R")) (TpVar "10268" "C"))) (Abs "10277" NotErased "10279" "gr" (Tkt (TpAppt (TpApp (TpVar "10284" "F") (TpVar "10288" "R")) (Var "10290" "indices"))) (TpAppt (TpAppt (TpVar "10299" "Q") (Var "10301" "indices")) (Parens "10309" (App (App (App (AppTp (AppTp (AppTp (Var "10310" "intrCoendInd") (TpVar "10325" "F")) (TpVar "10329" "C")) (TpVar "10333" "R")) Erased (Var "10336" "indices")) Erased (Var "10345" "c")) NotErased (Var "10347" "gr")) "10350")))))) "10351") NotErased (Abs "10358" Erased "10360" "X" (Tkk (KndPi "10364" "10366" "indices" (Tkt (TpVar "10376" "Indices")) (KndTpArrow (TpAppt (TpApp (TpApp (TpVar "10385" "CoendInd") (TpVar "10396" "F")) (TpVar "10400" "C")) (Var "10402" "indices")) (Star "10412")))) (TpArrow (TpParens "10419" (Abs "10420" Erased "10422" "indices" (Tkt (TpVar "10432" "Indices")) (Abs "10441" Erased "10443" "x'" (Tkt (TpAppt (TpApp (TpApp (TpVar "10448" "CoendInd") (TpVar "10459" "F")) (TpVar "10463" "C")) (Var "10465" "indices"))) (TpArrow (TpAppt (TpAppt (TpVar "10474" "Q") (Var "10476" "indices")) (Var "10484" "x'")) NotErased (TpAppt (TpAppt (TpVar "10489" "X") (Var "10491" "indices")) (Var "10499" "x'"))))) "10502") NotErased (TpAppt (TpAppt (TpVar "10509" "X") (Var "10511" "indices")) (Var "10519" "e"))))))))))) (Lam "10525" Erased "10527" "F" NoClass (Lam "10530" Erased "10532" "C" NoClass (Lam "10535" Erased "10537" "indices" NoClass (Lam "10546" NotErased "10548" "e" NoClass (Lam "10551" Erased "10553" "Q" NoClass (Lam "10556" NotErased "10558" "q" NoClass (Theta "10561" (AbstractVars (VarsNext "indices" (VarsStart "e"))) (IotaProj (Var "10574" "e") "2" "10577") (LtermsCons NotErased (Parens "10582" (Lam "10583" Erased "10585" "R" NoClass (Lam "10588" Erased "10590" "indices" NoClass (Lam "10599" NotErased "10601" "ar" NoClass (Lam "10605" NotErased "10607" "gr" NoClass (Lam "10611" Erased "10613" "X" NoClass (Lam "10616" NotErased "10618" "qq" NoClass (App (App (App (Var "10622" "qq") Erased (Var "10626" "indices")) Erased (Parens "10641" (App (App (App (AppTp (AppTp (AppTp (Var "10642" "intrCoendInd") (TpVar "10657" "F")) (TpVar "10661" "C")) (TpVar "10665" "R")) Erased (Var "10668" "indices")) Erased (Var "10677" "ar")) NotErased (Var "10680" "gr")) "10683")) NotErased (Parens "10684" (App (App (App (AppTp (Var "10685" "q") (TpVar "10689" "R")) Erased (Var "10692" "indices")) Erased (Var "10701" "ar")) NotErased (Var "10704" "gr")) "10707")))))))) "10708") (LtermsNil "10707")))))))))) "10709") (CmdsNext (DefTermOrType OpacTrans (DefTerm "10712" "indCoend" (SomeType (Abs "10727" Erased "10729" "F" (Tkk (KndArrow (KndParens "10733" (KndTpArrow (TpVar "10734" "Indices") (Star "10744")) "10746") (KndTpArrow (TpVar "10749" "Indices") (Star "10759")))) (Abs "10762" Erased "10764" "C" (Tkk (KndTpArrow (TpVar "10768" "Indices") (Star "10778"))) (Abs "10781" Erased "10783" "indices" (Tkt (TpVar "10793" "Indices")) (Abs "10806" NotErased "10808" "e" (Tkt (TpAppt (TpApp (TpApp (TpVar "10812" "CoendInd") (TpVar "10823" "F")) (TpVar "10827" "C")) (Var "10829" "indices"))) (Abs "10842" Erased "10844" "Q" (Tkk (KndPi "10848" "10850" "indices" (Tkt (TpVar "10860" "Indices")) (KndTpArrow (TpAppt (TpApp (TpApp (TpVar "10869" "CoendInd") (TpVar "10880" "F")) (TpVar "10884" "C")) (Var "10886" "indices")) (Star "10896")))) (TpArrow (TpParens "10903" (Abs "10904" Erased "10906" "R" (Tkk (KndTpArrow (TpVar "10910" "Indices") (Star "10920"))) (Abs "10923" Erased "10925" "indices" (Tkt (TpVar "10935" "Indices")) (Abs "10944" Erased "10946" "c" (Tkt (TpApp (TpApp (TpVar "10950" "Cast") (TpVar "10957" "R")) (TpVar "10961" "C"))) (Abs "10970" NotErased "10972" "gr" (Tkt (TpAppt (TpApp (TpVar "10977" "F") (TpVar "10981" "R")) (Var "10983" "indices"))) (TpAppt (TpAppt (TpVar "10992" "Q") (Var "10994" "indices")) (Parens "11002" (App (App (App (AppTp (AppTp (AppTp (Var "11003" "intrCoendInd") (TpVar "11018" "F")) (TpVar "11022" "C")) (TpVar "11026" "R")) Erased (Var "11029" "indices")) Erased (Var "11038" "c")) NotErased (Var "11040" "gr")) "11043")))))) "11044") NotErased (TpAppt (TpAppt (TpVar "11051" "Q") (Var "11053" "indices")) (Var "11061" "e"))))))))) (Lam "11067" Erased "11069" "F" NoClass (Lam "11072" Erased "11074" "C" NoClass (Lam "11077" Erased "11079" "indices" NoClass (Lam "11088" NotErased "11090" "e" NoClass (Lam "11093" Erased "11095" "Q" NoClass (Lam "11098" NotErased "11100" "i" NoClass (App (AppTp (App (AppTp (App (App (AppTp (AppTp (Var "11107" "indCoend'") (TpVar "11119" "F")) (TpVar "11123" "C")) Erased (Var "11126" "indices")) NotErased (Var "11134" "e")) (TpVar "11138" "Q")) NotErased (Var "11140" "i")) (TpVar "11144" "Q")) NotErased (Parens "11146" (Lam "11147" Erased "11149" "indices" NoClass (Lam "11158" Erased "11160" "x'" NoClass (Lam "11164" NotErased "11166" "u" NoClass (Var "11169" "u")))) "11171"))))))))) "11172") (CmdsNext (DefTermOrType OpacTrans (DefTerm "11174" "fmapCoend" (SomeType (Abs "11186" Erased "11188" "F" (Tkk (KndArrow (KndParens "11192" (KndTpArrow (TpVar "11193" "Indices") (Star "11203")) "11205") (KndTpArrow (TpVar "11208" "Indices") (Star "11218")))) (TpApp (TpVar "11221" "Functor") (TpParens "11231" (TpApp (TpVar "11232" "CoendInd") (TpVar "11243" "F")) "11245")))) (Lam "11250" Erased "11252" "F" NoClass (Lam "11255" Erased "11257" "A" NoClass (Lam "11260" Erased "11262" "B" NoClass (Lam "11265" Erased "11267" "f" NoClass (IotaPair "11274" (Lam "11275" Erased "11277" "indices" NoClass (Lam "11286" NotErased "11288" "c" NoClass (Phi "11297" (Parens "11299" (Theta "11300" (AbstractVars (VarsNext "indices" (VarsStart "c"))) (Parens "11313" (App (App (AppTp (AppTp (Var "11314" "indCoend") (TpVar "11325" "F")) (TpVar "11329" "A")) Erased (Var "11332" "indices")) NotErased (Var "11340" "c")) "11342") (LtermsCons NotErased (Parens "11343" (Lam "11344" Erased "11346" "R" NoClass (Lam "11349" Erased "11351" "indices" NoClass (Lam "11360" Erased "11362" "i" NoClass (Lam "11365" NotErased "11367" "gr" NoClass (Beta "11371" NoTerm NoTerm))))) "11373") (LtermsNil "11372"))) "11374") (Theta "11386" (AbstractVars (VarsNext "indices" (VarsStart "c"))) (Parens "11399" (App (App (AppTp (AppTp (Var "11400" "indCoend") (TpVar "11411" "F")) (TpVar "11415" "A")) Erased (Var "11418" "indices")) NotErased (Var "11426" "c")) "11428") (LtermsCons NotErased (Parens "11429" (Lam "11430" Erased "11432" "R" NoClass (Lam "11435" Erased "11437" "indices" NoClass (Lam "11446" Erased "11448" "i" NoClass (Lam "11451" NotErased "11453" "gr" NoClass (App (App (App (AppTp (AppTp (AppTp (Var "11468" "intrCoendInd") (TpVar "11483" "F")) (TpVar "11487" "B")) (TpVar "11491" "R")) Erased (Var "11494" "indices")) Erased (IotaPair "11516" (Lam "11517" Erased "11519" "indices" NoClass (Lam "11528" NotErased "11530" "r" NoClass (App (App (App (Var "11533" "cast") Erased (Var "11539" "f")) Erased (Var "11542" "indices")) NotErased (Parens "11550" (App (App (App (Var "11551" "cast") Erased (Var "11557" "i")) Erased (Var "11560" "indices")) NotErased (Var "11568" "r")) "11570")))) (Beta "11572" NoTerm NoTerm) NoGuide "11574")) NotErased (Var "11575" "gr")))))) "11578") (LtermsNil "11578"))) (Var "11580" "c") "11582"))) (Beta "11584" NoTerm NoTerm) NoGuide "11586")))))) "11587") (CmdsNext (DefTermOrType OpacTrans (DefType "11590" "AlgCVM" (KndArrow (KndParens "11599" (KndArrow (KndParens "11600" (KndTpArrow (TpVar "11601" "Indices") (Star "11611")) "11613") (KndTpArrow (TpVar "11616" "Indices") (Star "11626"))) "11628") (KndArrow (Star "11631") (KndTpArrow (TpVar "11635" "Indices") (Star "11645")))) (TpLambda "11651" "11653" "F" (Tkk (KndArrow (KndParens "11657" (KndTpArrow (TpVar "11658" "Indices") (Star "11668")) "11670") (KndTpArrow (TpVar "11673" "Indices") (Star "11683")))) (TpLambda "11686" "11688" "X" (Tkk (Star "11692")) (TpLambda "11695" "11697" "indices" (Tkt (TpVar "11707" "Indices")) (Abs "11720" Erased "11722" "R" (Tkk (KndTpArrow (TpVar "11726" "Indices") (Star "11736"))) (TpArrow (TpParens "11739" (TpArrow (TpAppt (TpVar "11740" "R") (Var "11742" "indices")) NotErased (TpAppt (TpApp (TpVar "11752" "F") (TpVar "11756" "R")) (Var "11758" "indices"))) "11766") NotErased (TpArrow (TpParens "11769" (TpArrow (TpAppt (TpVar "11770" "R") (Var "11772" "indices")) NotErased (TpVar "11782" "X")) "11784") NotErased (TpArrow (TpAppt (TpApp (TpVar "11787" "F") (TpVar "11791" "R")) (Var "11793" "indices")) NotErased (TpVar "11803" "X"))))))))) "11805") (CmdsNext (DefTermOrType OpacTrans (DefType "11808" "FixCVM" (KndArrow (KndParens "11817" (KndArrow (KndParens "11818" (KndTpArrow (TpVar "11819" "Indices") (Star "11829")) "11831") (KndTpArrow (TpVar "11834" "Indices") (Star "11844"))) "11846") (KndTpArrow (TpVar "11849" "Indices") (Star "11859"))) (TpLambda "11865" "11867" "F" (Tkk (KndArrow (KndParens "11871" (KndTpArrow (TpVar "11872" "Indices") (Star "11882")) "11884") (KndTpArrow (TpVar "11887" "Indices") (Star "11897")))) (TpLambda "11900" "11902" "indices" (Tkt (TpVar "11912" "Indices")) (Abs "11925" Erased "11927" "R" (Tkk (Star "11931")) (TpArrow (TpAppt (TpApp (TpApp (TpVar "11934" "AlgCVM") (TpVar "11943" "F")) (TpVar "11947" "R")) (Var "11949" "indices")) NotErased (TpVar "11959" "R")))))) "11961") (CmdsNext (DefTermOrType OpacTrans (DefTerm "11963" "foldCVM" (SomeType (Abs "11977" Erased "11979" "F" (Tkk (KndArrow (KndParens "11983" (KndTpArrow (TpVar "11984" "Indices") (Star "11994")) "11996") (KndTpArrow (TpVar "11999" "Indices") (Star "12009")))) (Abs "12012" Erased "12014" "A" (Tkk (Star "12018")) (Abs "12021" Erased "12023" "indices" (Tkt (TpVar "12033" "Indices")) (TpArrow (TpAppt (TpApp (TpApp (TpVar "12046" "AlgCVM") (TpVar "12055" "F")) (TpVar "12059" "A")) (Var "12061" "indices")) NotErased (TpArrow (TpAppt (TpApp (TpVar "12071" "FixCVM") (TpVar "12080" "F")) (Var "12082" "indices")) NotErased (TpVar "12092" "A"))))))) (Lam "12098" Erased "12100" "F" NoClass (Lam "12103" Erased "12105" "A" NoClass (Lam "12108" Erased "12110" "indices" NoClass (Lam "12119" NotErased "12121" "alg" NoClass (Lam "12126" NotErased "12128" "fix" NoClass (App (Var "12133" "fix") NotErased (Var "12137" "alg")))))))) "12141") (CmdsNext (DefTermOrType OpacTrans (DefType "12143" "CVProduct'" (KndArrow (KndParens "12157" (KndArrow (KndParens "12158" (KndTpArrow (TpVar "12159" "Indices") (Star "12169")) "12171") (KndTpArrow (TpVar "12174" "Indices") (Star "12184"))) "12186") (KndArrow (KndParens "12189" (KndTpArrow (TpVar "12190" "Indices") (Star "12200")) "12202") (KndTpArrow (TpVar "12205" "Indices") (Star "12215")))) (TpLambda "12221" "12223" "F" (Tkk (KndArrow (KndParens "12227" (KndTpArrow (TpVar "12228" "Indices") (Star "12238")) "12240") (KndTpArrow (TpVar "12243" "Indices") (Star "12253")))) (TpLambda "12256" "12258" "X" (Tkk (KndTpArrow (TpVar "12262" "Indices") (Star "12272"))) (TpLambda "12275" "12277" "indices" (Tkt (TpVar "12287" "Indices")) (TpApp (TpApp (TpVar "12300" "Sigma") (TpParens "12308" (TpAppt (TpApp (TpVar "12309" "F") (TpVar "12313" "X")) (Var "12315" "indices")) "12323")) (TpParens "12326" (TpLambda "12327" "12329" "_" (Tkt (TpAppt (TpApp (TpVar "12333" "F") (TpVar "12337" "X")) (Var "12339" "indices"))) (TpArrow (TpAppt (TpVar "12348" "X") (Var "12350" "indices")) NotErased (TpAppt (TpApp (TpVar "12360" "F") (TpVar "12364" "X")) (Var "12366" "indices")))) "12374")))))) "12375") (CmdsNext (DefTermOrType OpacTrans (DefType "12376" "CVF'" (KndArrow (KndParens "12389" (KndArrow (KndParens "12390" (KndTpArrow (TpVar "12391" "Indices") (Star "12401")) "12403") (KndTpArrow (TpVar "12406" "Indices") (Star "12416"))) "12418") (KndArrow (KndParens "12421" (KndTpArrow (TpVar "12422" "Indices") (Star "12432")) "12434") (KndTpArrow (TpVar "12437" "Indices") (Star "12447")))) (TpLambda "12453" "12455" "F" (Tkk (KndArrow (KndParens "12459" (KndTpArrow (TpVar "12460" "Indices") (Star "12470")) "12472") (KndTpArrow (TpVar "12475" "Indices") (Star "12485")))) (TpApp (TpVar "12488" "CoendInd") (TpParens "12499" (TpApp (TpVar "12500" "CVProduct'") (TpVar "12513" "F")) "12515")))) "12516") (CmdsNext (DefTermOrType OpacTrans (DefType "12517" "CVFixIndM'" (KndArrow (KndParens "12530" (KndArrow (KndParens "12531" (KndTpArrow (TpVar "12532" "Indices") (Star "12542")) "12544") (KndTpArrow (TpVar "12547" "Indices") (Star "12557"))) "12559") (KndTpArrow (TpVar "12562" "Indices") (Star "12572"))) (TpLambda "12578" "12580" "F" (Tkk (KndArrow (KndParens "12584" (KndTpArrow (TpVar "12585" "Indices") (Star "12595")) "12597") (KndTpArrow (TpVar "12600" "Indices") (Star "12610")))) (TpAppt (TpApp (TpVar "12613" "FixIndM") (TpParens "12623" (TpApp (TpVar "12624" "CVF'") (TpVar "12631" "F")) "12633")) (Parens "12634" (AppTp (Var "12635" "fmapCoend") (TpParens "12647" (TpApp (TpVar "12648" "CVProduct'") (TpVar "12661" "F")) "12663")) "12664")))) "12665") (CmdsNext (DefTermOrType OpacTrans (DefTerm "12667" "cvOutFixIndM'" (SomeType (Abs "12687" Erased "12689" "F" (Tkk (KndArrow (KndParens "12693" (KndTpArrow (TpVar "12694" "Indices") (Star "12704")) "12706") (KndTpArrow (TpVar "12709" "Indices") (Star "12719")))) (Abs "12722" Erased "12724" "fmap" (Tkt (TpApp (TpVar "12731" "Functor") (TpVar "12741" "F"))) (Abs "12744" Erased "12746" "indices" (Tkt (TpVar "12756" "Indices")) (TpArrow (TpAppt (TpApp (TpVar "12769" "CVFixIndM'") (TpVar "12782" "F")) (Var "12784" "indices")) NotErased (TpAppt (TpApp (TpVar "12794" "F") (TpParens "12798" (TpApp (TpVar "12799" "CVFixIndM'") (TpVar "12812" "F")) "12814")) (Var "12815" "indices"))))))) (Lam "12827" Erased "12829" "F" NoClass (Lam "12832" Erased "12834" "fmap" NoClass (Lam "12840" Erased "12842" "indices" NoClass (Lam "12851" NotErased "12853" "v" NoClass (App (AppTp (App (App (AppTp (AppTp (Var "12856" "indCoend") (TpParens "12871" (TpApp (TpVar "12872" "CVProduct'") (TpVar "12885" "F")) "12887")) (TpParens "12894" (TpAppt (TpApp (TpVar "12895" "FixIndM") (TpParens "12905" (TpApp (TpVar "12906" "CoendInd") (TpParens "12917" (TpApp (TpVar "12918" "CVProduct'") (TpVar "12931" "F")) "12933")) "12934")) (Parens "12935" (AppTp (Var "12936" "fmapCoend") (TpParens "12948" (TpApp (TpVar "12949" "CVProduct'") (TpVar "12962" "F")) "12964")) "12965")) "12966")) Erased (Var "12972" "indices")) NotErased (Parens "12980" (App (App (App (Var "12981" "outFixIndM") Erased (Parens "12993" (AppTp (Var "12994" "fmapCoend") (TpParens "13006" (TpApp (TpVar "13007" "CVProduct'") (TpVar "13020" "F")) "13022")) "13023")) Erased (Var "13025" "indices")) NotErased (Var "13033" "v")) "13035")) (TpParens "13043" (TpLambda "13044" "13046" "indices" (Tkt (TpVar "13056" "Indices")) (TpLambda "13065" "13067" "_" (Tkt (TpAppt (TpApp (TpApp (TpVar "13071" "CoendInd") (TpParens "13082" (TpApp (TpVar "13083" "CVProduct'") (TpVar "13096" "F")) "13098")) (TpParens "13101" (TpApp (TpVar "13102" "CVFixIndM'") (TpVar "13115" "F")) "13117")) (Var "13118" "indices"))) (TpAppt (TpApp (TpVar "13135" "F") (TpParens "13139" (TpApp (TpVar "13140" "CVFixIndM'") (TpVar "13153" "F")) "13155")) (Var "13156" "indices")))) "13164")) NotErased (Parens "13166" (Lam "13167" Erased "13169" "R" NoClass (Lam "13172" Erased "13174" "indices" NoClass (Lam "13183" Erased "13185" "c" NoClass (Lam "13188" NotErased "13190" "v" NoClass (App (App (App (Var "13193" "cast") Erased (Parens "13199" (App (Var "13200" "fmap") Erased (Var "13206" "c")) "13208")) Erased (Var "13210" "indices")) NotErased (Parens "13218" (App (Var "13219" "fst") NotErased (Var "13223" "v")) "13225")))))) "13226"))))))) "13227") (CmdsNext (DefTermOrType OpacTrans (DefType "13229" "CVProduct" (KndArrow (KndParens "13241" (KndArrow (KndParens "13242" (KndTpArrow (TpVar "13243" "Indices") (Star "13253")) "13255") (KndTpArrow (TpVar "13258" "Indices") (Star "13268"))) "13270") (KndArrow (KndParens "13273" (KndTpArrow (TpVar "13274" "Indices") (Star "13284")) "13286") (KndTpArrow (TpVar "13289" "Indices") (Star "13299")))) (TpLambda "13305" "13307" "F" (Tkk (KndArrow (KndParens "13311" (KndTpArrow (TpVar "13312" "Indices") (Star "13322")) "13324") (KndTpArrow (TpVar "13327" "Indices") (Star "13337")))) (TpLambda "13340" "13342" "X" (Tkk (KndTpArrow (TpVar "13346" "Indices") (Star "13356"))) (TpLambda "13359" "13361" "indices" (Tkt (TpVar "13371" "Indices")) (TpApp (TpApp (TpVar "13380" "Product") (TpParens "13394" (TpAppt (TpApp (TpVar "13395" "F") (TpVar "13399" "X")) (Var "13401" "indices")) "13409")) (TpParens "13416" (Iota "13417" "13419" "o" (Abs "13423" Erased "13425" "indices" (Tkt (TpVar "13435" "Indices")) (TpArrow (TpAppt (TpVar "13444" "X") (Var "13446" "indices")) NotErased (TpAppt (TpApp (TpVar "13456" "F") (TpVar "13460" "X")) (Var "13462" "indices")))) (TpEq "13471" (Var "13472" "o") (Var "13476" "cvOutFixIndM'") "13490")) "13491")))))) "13492") (CmdsNext (DefTermOrType OpacTrans (DefType "13493" "CVF" (KndArrow (KndParens "13500" (KndArrow (KndParens "13501" (KndTpArrow (TpVar "13502" "Indices") (Star "13512")) "13514") (KndTpArrow (TpVar "13517" "Indices") (Star "13527"))) "13529") (KndArrow (KndParens "13532" (KndTpArrow (TpVar "13533" "Indices") (Star "13543")) "13545") (KndTpArrow (TpVar "13548" "Indices") (Star "13558")))) (TpLambda "13564" "13566" "F" (Tkk (KndArrow (KndParens "13570" (KndTpArrow (TpVar "13571" "Indices") (Star "13581")) "13583") (KndTpArrow (TpVar "13586" "Indices") (Star "13596")))) (TpApp (TpVar "13599" "CoendInd") (TpParens "13610" (TpApp (TpVar "13611" "CVProduct") (TpVar "13623" "F")) "13625")))) "13626") (CmdsNext (DefTermOrType OpacTrans (DefType "13627" "CVFixIndM" (KndPi "13639" "13641" "F" (Tkk (KndArrow (KndParens "13645" (KndTpArrow (TpVar "13646" "Indices") (Star "13656")) "13658") (KndTpArrow (TpVar "13661" "Indices") (Star "13671")))) (KndTpArrow (TpApp (TpVar "13674" "Functor") (TpVar "13684" "F")) (KndTpArrow (TpVar "13688" "Indices") (Star "13698")))) (TpLambda "13704" "13706" "F" (Tkk (KndArrow (KndParens "13710" (KndTpArrow (TpVar "13711" "Indices") (Star "13721")) "13723") (KndTpArrow (TpVar "13726" "Indices") (Star "13736")))) (TpLambda "13739" "13741" "fmap" (Tkt (TpApp (TpVar "13748" "Functor") (TpVar "13758" "F"))) (TpAppt (TpApp (TpVar "13765" "FixIndM") (TpParens "13775" (TpApp (TpVar "13776" "CVF") (TpVar "13782" "F")) "13784")) (Parens "13785" (AppTp (Var "13786" "fmapCoend") (TpParens "13798" (TpApp (TpVar "13799" "CVProduct") (TpVar "13811" "F")) "13813")) "13814"))))) "13815") (CmdsNext (DefTermOrType OpacTrans (DefTerm "13817" "cvOutFixIndM" (SomeType (Abs "13836" Erased "13838" "F" (Tkk (KndArrow (KndParens "13842" (KndTpArrow (TpVar "13843" "Indices") (Star "13853")) "13855") (KndTpArrow (TpVar "13858" "Indices") (Star "13868")))) (Abs "13871" Erased "13873" "fmap" (Tkt (TpApp (TpVar "13880" "Functor") (TpVar "13890" "F"))) (Abs "13893" Erased "13895" "indices" (Tkt (TpVar "13905" "Indices")) (TpArrow (TpAppt (TpAppt (TpApp (TpVar "13918" "CVFixIndM") (TpVar "13930" "F")) (Var "13932" "fmap")) (Var "13937" "indices")) NotErased (TpAppt (TpApp (TpVar "13947" "F") (TpParens "13951" (TpAppt (TpApp (TpVar "13952" "CVFixIndM") (TpVar "13964" "F")) (Var "13966" "fmap")) "13971")) (Var "13972" "indices"))))))) (Lam "13984" Erased "13986" "F" NoClass (Lam "13989" Erased "13991" "fmap" NoClass (Lam "13997" Erased "13999" "indices" NoClass (Lam "14008" NotErased "14010" "v" NoClass (App (AppTp (App (App (AppTp (AppTp (Var "14013" "indCoend") (TpParens "14028" (TpApp (TpVar "14029" "CVProduct") (TpVar "14041" "F")) "14043")) (TpParens "14050" (TpAppt (TpApp (TpVar "14051" "FixIndM") (TpParens "14061" (TpApp (TpVar "14062" "CoendInd") (TpParens "14073" (TpApp (TpVar "14074" "CVProduct") (TpVar "14086" "F")) "14088")) "14089")) (Parens "14090" (AppTp (Var "14091" "fmapCoend") (TpParens "14103" (TpApp (TpVar "14104" "CVProduct") (TpVar "14116" "F")) "14118")) "14119")) "14120")) Erased (Var "14126" "indices")) NotErased (Parens "14138" (App (App (App (Var "14139" "outFixIndM") Erased (Parens "14151" (AppTp (Var "14152" "fmapCoend") (TpParens "14164" (TpApp (TpVar "14165" "CVProduct") (TpVar "14177" "F")) "14179")) "14180")) Erased (Var "14182" "indices")) NotErased (Var "14190" "v")) "14192")) (TpParens "14199" (TpLambda "14200" "14202" "indices" (Tkt (TpVar "14212" "Indices")) (TpLambda "14221" "14223" "_" (Tkt (TpAppt (TpApp (TpApp (TpVar "14227" "CoendInd") (TpParens "14238" (TpApp (TpVar "14239" "CVProduct") (TpVar "14251" "F")) "14253")) (TpParens "14256" (TpAppt (TpApp (TpVar "14257" "CVFixIndM") (TpVar "14269" "F")) (Var "14271" "fmap")) "14276")) (Var "14277" "indices"))) (TpAppt (TpApp (TpVar "14294" "F") (TpParens "14298" (TpAppt (TpApp (TpVar "14299" "CVFixIndM") (TpVar "14311" "F")) (Var "14313" "fmap")) "14318")) (Var "14319" "indices")))) "14327")) NotErased (Parens "14332" (Lam "14333" Erased "14335" "R" NoClass (Lam "14338" Erased "14340" "indices" NoClass (Lam "14349" Erased "14351" "c" NoClass (Lam "14354" NotErased "14356" "v" NoClass (App (App (App (Var "14359" "cast") Erased (Parens "14365" (App (Var "14366" "fmap") Erased (Var "14372" "c")) "14374")) Erased (Var "14376" "indices")) NotErased (Parens "14384" (App (Var "14385" "fst") NotErased (Var "14389" "v")) "14391")))))) "14392"))))))) "14393") (CmdsNext (DefTermOrType OpacTrans (DefTerm "14395" "cvInFixIndM" (SomeType (Abs "14413" Erased "14415" "F" (Tkk (KndArrow (KndParens "14419" (KndTpArrow (TpVar "14420" "Indices") (Star "14430")) "14432") (KndTpArrow (TpVar "14435" "Indices") (Star "14445")))) (Abs "14448" Erased "14450" "fmap" (Tkt (TpApp (TpVar "14457" "Functor") (TpVar "14467" "F"))) (Abs "14470" Erased "14472" "indices" (Tkt (TpVar "14482" "Indices")) (TpArrow (TpAppt (TpApp (TpVar "14495" "F") (TpParens "14499" (TpAppt (TpApp (TpVar "14500" "CVFixIndM") (TpVar "14512" "F")) (Var "14514" "fmap")) "14519")) (Var "14520" "indices")) NotErased (TpAppt (TpAppt (TpApp (TpVar "14530" "CVFixIndM") (TpVar "14542" "F")) (Var "14544" "fmap")) (Var "14549" "indices"))))))) (Lam "14561" Erased "14563" "F" NoClass (Lam "14566" Erased "14568" "fmap" NoClass (Lam "14574" Erased "14576" "indices" NoClass (Lam "14585" NotErased "14587" "fcv" NoClass (App (App (App (Var "14592" "inFixIndM") Erased (Parens "14603" (AppTp (Var "14604" "fmapCoend") (TpParens "14616" (TpApp (TpVar "14617" "CVProduct") (TpVar "14629" "F")) "14631")) "14632")) Erased (Var "14634" "indices")) NotErased (Parens "14646" (App (App (App (AppTp (AppTp (AppTp (Var "14647" "intrCoendInd") (TpParens "14662" (TpApp (TpVar "14663" "CVProduct") (TpVar "14675" "F")) "14677")) (TpParens "14680" (TpAppt (TpApp (TpVar "14681" "CVFixIndM") (TpVar "14693" "F")) (Var "14695" "fmap")) "14700")) (TpParens "14703" (TpAppt (TpApp (TpVar "14704" "CVFixIndM") (TpVar "14716" "F")) (Var "14718" "fmap")) "14723")) Erased (Var "14731" "indices")) Erased (IotaPair "14740" (Lam "14741" Erased "14743" "indices" NoClass (Lam "14752" NotErased "14754" "x" NoClass (Var "14757" "x"))) (Beta "14760" NoTerm NoTerm) NoGuide "14762")) NotErased (Parens "14769" (App (App (Var "14770" "sigma") NotErased (Var "14776" "fcv")) NotErased (IotaPair "14780" (App (Var "14781" "cvOutFixIndM") Erased (Var "14795" "fmap")) (Beta "14801" NoTerm (SomeTerm (Var "14803" "cvOutFixIndM") "14816")) NoGuide "14817")) "14818")) "14819"))))))) "14820") (CmdsNext (DefTermOrType OpacTrans (DefTerm "14822" "cvIndFixIndM" (SomeType (Abs "14841" Erased "14843" "F" (Tkk (KndArrow (KndParens "14847" (KndTpArrow (TpVar "14848" "Indices") (Star "14858")) "14860") (KndTpArrow (TpVar "14863" "Indices") (Star "14873")))) (Abs "14876" Erased "14878" "fmap" (Tkt (TpApp (TpVar "14885" "Functor") (TpVar "14895" "F"))) (Abs "14902" Erased "14904" "indices" (Tkt (TpVar "14914" "Indices")) (Abs "14923" NotErased "14925" "e" (Tkt (TpAppt (TpAppt (TpApp (TpVar "14929" "CVFixIndM") (TpVar "14941" "F")) (Var "14943" "fmap")) (Var "14948" "indices"))) (Abs "14961" Erased "14963" "Q" (Tkk (KndPi "14967" "14969" "indices" (Tkt (TpVar "14979" "Indices")) (KndTpArrow (TpAppt (TpAppt (TpApp (TpVar "14988" "CVFixIndM") (TpVar "15000" "F")) (Var "15002" "fmap")) (Var "15007" "indices")) (Star "15017")))) (TpArrow (TpParens "15024" (Abs "15025" Erased "15027" "R" (Tkk (KndTpArrow (TpVar "15031" "Indices") (Star "15041"))) (Abs "15044" Erased "15046" "c" (Tkt (TpApp (TpApp (TpVar "15050" "Cast") (TpVar "15057" "R")) (TpParens "15061" (TpAppt (TpApp (TpVar "15062" "CVFixIndM") (TpVar "15074" "F")) (Var "15076" "fmap")) "15081"))) (Abs "15088" Erased "15090" "out" (Tkt (Abs "15096" Erased "15098" "indices" (Tkt (TpVar "15108" "Indices")) (TpArrow (TpAppt (TpVar "15117" "R") (Var "15119" "indices")) NotErased (TpAppt (TpApp (TpVar "15129" "F") (TpVar "15133" "R")) (Var "15135" "indices"))))) (TpArrow (TpEq "15144" (Var "15145" "out") (Var "15151" "cvOutFixIndM") "15164") Erased (TpArrow (TpParens "15172" (Abs "15173" Erased "15175" "indices" (Tkt (TpVar "15185" "Indices")) (Abs "15194" NotErased "15196" "r" (Tkt (TpAppt (TpVar "15200" "R") (Var "15202" "indices"))) (TpAppt (TpAppt (TpVar "15211" "Q") (Var "15213" "indices")) (Parens "15221" (App (App (App (Var "15222" "cast") Erased (Var "15228" "c")) Erased (Var "15231" "indices")) NotErased (Var "15239" "r")) "15241")))) "15242") NotErased (Abs "15250" Erased "15252" "indices" (Tkt (TpVar "15262" "Indices")) (Abs "15271" NotErased "15273" "gr" (Tkt (TpAppt (TpApp (TpVar "15278" "F") (TpVar "15282" "R")) (Var "15284" "indices"))) (TpAppt (TpAppt (TpVar "15298" "Q") (Var "15300" "indices")) (Parens "15308" (App (App (App (Var "15309" "cvInFixIndM") Erased (Var "15322" "fmap")) Erased (Var "15328" "indices")) NotErased (Parens "15336" (App (App (App (Var "15337" "cast") Erased (Parens "15343" (App (Var "15344" "fmap") Erased (Var "15350" "c")) "15352")) Erased (Var "15354" "indices")) NotErased (Var "15362" "gr")) "15365")) "15366"))))))))) "15367") NotErased (TpAppt (TpAppt (TpVar "15374" "Q") (Var "15376" "indices")) (Var "15384" "e"))))))))) (Lam "15390" Erased "15392" "F" NoClass (Lam "15395" Erased "15397" "fmap" NoClass (Lam "15403" Erased "15405" "indices" NoClass (Lam "15414" NotErased "15416" "e" NoClass (Lam "15419" Erased "15421" "Q" NoClass (Lam "15424" NotErased "15426" "prf" NoClass (App (AppTp (App (App (App (Var "15435" "indFixIndM") Erased (Parens "15447" (AppTp (Var "15448" "fmapCoend") (TpParens "15460" (TpApp (TpVar "15461" "CVProduct") (TpVar "15473" "F")) "15475")) "15476")) Erased (Var "15478" "indices")) NotErased (Var "15486" "e")) (TpVar "15490" "Q")) NotErased (Parens "15498" (Lam "15499" Erased "15501" "R" NoClass (Lam "15504" Erased "15506" "i" NoClass (Lam "15509" NotErased "15511" "ih" NoClass (Lam "15515" Erased "15517" "indices" NoClass (Lam "15526" NotErased "15528" "gr" NoClass (Theta "15540" (AbstractVars (VarsNext "indices" (VarsStart "gr"))) (Parens "15554" (App (App (AppTp (AppTp (Var "15555" "indCoend") (TpParens "15566" (TpApp (TpVar "15567" "CVProduct") (TpVar "15579" "F")) "15581")) (TpVar "15584" "R")) Erased (Var "15587" "indices")) NotErased (Var "15595" "gr")) "15598") (LtermsCons NotErased (Parens "15609" (Lam "15610" Erased "15612" "R'" NoClass (Lam "15616" Erased "15618" "indices" NoClass (Lam "15627" Erased "15629" "i2" NoClass (Lam "15633" NotErased "15635" "fr" NoClass (Theta "15639" (AbstractVars (VarsStart "fr")) (Parens "15645" (App (Var "15646" "SigmaInd") NotErased (Var "15655" "fr")) "15658") (LtermsCons NotErased (Parens "15671" (Lam "15672" NotErased "15674" "a" NoClass (Lam "15677" NotErased "15679" "b" NoClass (Rho "15682" RhoPlain NoNums (IotaProj (Var "15684" "b") "2" "15687") NoGuide (App (App (App (App (App (App (AppTp (Var "15690" "prf") (TpVar "15696" "R'")) Erased (IotaPair "15714" (Lam "15715" Erased "15717" "indices" NoClass (Lam "15726" NotErased "15728" "r" NoClass (App (App (App (Var "15731" "cast") Erased (Var "15737" "i")) Erased (Var "15740" "indices")) NotErased (Parens "15748" (App (App (App (Var "15749" "cast") Erased (Var "15755" "i2")) Erased (Var "15759" "indices")) NotErased (Var "15767" "r")) "15769")))) (Beta "15771" NoTerm NoTerm) NoGuide "15773")) Erased (IotaProj (Var "15775" "b") "1" "15778")) Erased (IotaProj (Var "15780" "b") "2" "15783")) NotErased (Parens "15798" (Lam "15799" Erased "15801" "indices" NoClass (Lam "15810" NotErased "15812" "r'" NoClass (App (App (Var "15816" "ih") Erased (Var "15820" "indices")) NotErased (Parens "15828" (App (App (App (Var "15829" "cast") Erased (Var "15835" "i2")) Erased (Var "15839" "indices")) NotErased (Var "15847" "r'")) "15850")))) "15851")) Erased (Var "15853" "indices")) NotErased (Var "15861" "a"))))) "15863") (LtermsNil "15862"))))))) "15864") (LtermsNil "15863")))))))) "15865"))))))))) "15866") CmdsStart)))))))))))))))))))))))))))))))))))))))))))))))))) "15866"
-- src/templates/MendlerSimple.ced
MendlerSimpleTemplate = File "1" ImportsStart "1" "8" "MendlerSimple" (ParamsCons (Decl "22" "23" NotErased "Indices" (Tkk (Star "33")) "35") ParamsNil) (CmdsNext (DefTermOrType OpacTrans (DefType "38" "Top" (Star "44") (TpEq "48" (Beta "49" NoTerm NoTerm) (Beta "53" NoTerm NoTerm) "55")) "56") (CmdsNext (DefTermOrType OpacTrans (DefType "58" "Cast" (KndArrow (KndParens "65" (KndTpArrow (TpVar "66" "Indices") (Star "76")) "78") (KndArrow (KndParens "81" (KndTpArrow (TpVar "82" "Indices") (Star "92")) "94") (Star "97"))) (TpLambda "101" "103" "A" (Tkk (KndTpArrow (TpVar "107" "Indices") (Star "117"))) (TpLambda "120" "122" "B" (Tkk (KndTpArrow (TpVar "126" "Indices") (Star "136"))) (Iota "141" "143" "cast" (Abs "150" Erased "152" "indices" (Tkt (TpVar "162" "Indices")) (TpArrow (TpAppt (TpVar "171" "A") (Var "173" "indices")) NotErased (TpAppt (TpVar "183" "B") (Var "185" "indices")))) (TpEq "194" (Var "195" "cast") (Lam "202" NotErased "204" "x" NoClass (Var "207" "x")) "209"))))) "210") (CmdsNext (DefTermOrType OpacTrans (DefTerm "212" "cast" (SomeType (Abs "219" Erased "221" "A" (Tkk (KndTpArrow (TpVar "225" "Indices") (Star "235"))) (Abs "238" Erased "240" "B" (Tkk (KndTpArrow (TpVar "244" "Indices") (Star "254"))) (TpArrow (TpApp (TpApp (TpVar "257" "Cast") (TpVar "264" "A")) (TpVar "268" "B")) Erased (Abs "276" Erased "278" "indices" (Tkt (TpVar "288" "Indices")) (TpArrow (TpAppt (TpVar "297" "A") (Var "299" "indices")) NotErased (TpAppt (TpVar "309" "B") (Var "311" "indices")))))))) (Lam "323" Erased "325" "A" NoClass (Lam "328" Erased "330" "B" NoClass (Lam "333" Erased "335" "c" NoClass (Phi "338" (IotaProj (Var "340" "c") "2" "343") (IotaProj (Var "346" "c") "1" "349") (Lam "351" NotErased "353" "x" NoClass (Var "356" "x")) "358"))))) "359") (CmdsNext (DefTermOrType OpacTrans (DefType "361" "RecFunctor" (KndArrow (KndParens "374" (KndArrow (KndParens "375" (KndTpArrow (TpVar "376" "Indices") (Star "386")) "388") (KndTpArrow (TpVar "391" "Indices") (Star "401"))) "403") (Star "406")) (TpLambda "412" "414" "F" (Tkk (KndArrow (KndParens "418" (KndTpArrow (TpVar "419" "Indices") (Star "429")) "431") (KndTpArrow (TpVar "434" "Indices") (Star "444")))) (Abs "447" Erased "449" "X" (Tkk (KndTpArrow (TpVar "453" "Indices") (Star "463"))) (Abs "466" Erased "468" "Y" (Tkk (KndTpArrow (TpVar "472" "Indices") (Star "482"))) (TpArrow (TpApp (TpApp (TpVar "489" "Cast") (TpVar "496" "X")) (TpVar "500" "Y")) Erased (TpApp (TpApp (TpVar "504" "Cast") (TpParens "511" (TpApp (TpVar "512" "F") (TpVar "516" "X")) "518")) (TpParens "521" (TpApp (TpVar "522" "F") (TpVar "526" "Y")) "528"))))))) "529") (CmdsNext (DefTermOrType OpacTrans (DefType "531" "Rec" (KndArrow (KndParens "537" (KndArrow (KndParens "538" (KndTpArrow (TpVar "539" "Indices") (Star "549")) "551") (KndTpArrow (TpVar "554" "Indices") (Star "564"))) "566") (KndTpArrow (TpVar "569" "Indices") (Star "579"))) (TpLambda "585" "587" "F" (Tkk (KndArrow (KndParens "591" (KndTpArrow (TpVar "592" "Indices") (Star "602")) "604") (KndTpArrow (TpVar "607" "Indices") (Star "617")))) (TpLambda "620" "622" "indices" (Tkt (TpVar "632" "Indices")) (Abs "645" Erased "647" "X" (Tkk (KndTpArrow (TpVar "651" "Indices") (Star "661"))) (TpArrow (TpApp (TpApp (TpVar "664" "Cast") (TpParens "671" (TpApp (TpVar "672" "F") (TpVar "676" "X")) "678")) (TpVar "681" "X")) Erased (TpAppt (TpVar "685" "X") (Var "687" "indices"))))))) "695") (CmdsNext (DefTermOrType OpacTrans (DefTerm "698" "recCast" (SomeType (Abs "708" Erased "710" "F" (Tkk (KndArrow (KndParens "714" (KndTpArrow (TpVar "715" "Indices") (Star "725")) "727") (KndTpArrow (TpVar "730" "Indices") (Star "740")))) (Abs "743" Erased "745" "X" (Tkk (KndTpArrow (TpVar "749" "Indices") (Star "759"))) (TpArrow (TpApp (TpApp (TpVar "766" "Cast") (TpParens "773" (TpApp (TpVar "774" "F") (TpVar "778" "X")) "780")) (TpVar "783" "X")) Erased (TpApp (TpApp (TpVar "787" "Cast") (TpParens "794" (TpApp (TpVar "795" "Rec") (TpVar "801" "F")) "803")) (TpVar "806" "X")))))) (Lam "812" Erased "814" "F" NoClass (Lam "817" Erased "819" "X" NoClass (Lam "822" Erased "824" "c" NoClass (IotaPair "827" (Lam "828" Erased "830" "indices" NoClass (Lam "839" NotErased "841" "a" NoClass (App (AppTp (Var "844" "a") (TpVar "848" "X")) Erased (Var "851" "c")))) (Beta "854" NoTerm NoTerm) NoGuide "856"))))) "857") (CmdsNext (DefTermOrType OpacTrans (DefTerm "859" "recIn" (SomeType (Abs "867" Erased "869" "F" (Tkk (KndArrow (KndParens "873" (KndTpArrow (TpVar "874" "Indices") (Star "884")) "886") (KndTpArrow (TpVar "889" "Indices") (Star "899")))) (TpArrow (TpApp (TpVar "902" "RecFunctor") (TpVar "915" "F")) Erased (TpApp (TpApp (TpVar "923" "Cast") (TpParens "930" (TpApp (TpVar "931" "F") (TpParens "935" (TpApp (TpVar "936" "Rec") (TpVar "942" "F")) "944")) "945")) (TpParens "948" (TpApp (TpVar "949" "Rec") (TpVar "955" "F")) "957"))))) (Lam "962" Erased "964" "F" NoClass (Lam "967" Erased "969" "fmap" NoClass (IotaPair "979" (Lam "980" Erased "982" "indices" NoClass (Lam "991" NotErased "993" "a" NoClass (Lam "996" Erased "998" "X" NoClass (Lam "1001" Erased "1003" "c" NoClass (App (App (App (Var "1006" "cast") Erased (Var "1012" "c")) Erased (Var "1015" "indices")) NotErased (Parens "1023" (App (App (App (Var "1024" "cast") Erased (Parens "1030" (App (Var "1031" "fmap") Erased (Parens "1037" (App (Var "1038" "recCast") Erased (Var "1047" "c")) "1049")) "1050")) Erased (Var "1052" "indices")) NotErased (Var "1060" "a")) "1062")))))) (Beta "1064" NoTerm NoTerm) NoGuide "1066")))) "1067") (CmdsNext (DefTermOrType OpacTrans (DefTerm "1069" "recOut" (SomeType (Abs "1078" Erased "1080" "F" (Tkk (KndArrow (KndParens "1084" (KndTpArrow (TpVar "1085" "Indices") (Star "1095")) "1097") (KndTpArrow (TpVar "1100" "Indices") (Star "1110")))) (TpArrow (TpApp (TpVar "1113" "RecFunctor") (TpVar "1126" "F")) Erased (TpApp (TpApp (TpVar "1140" "Cast") (TpParens "1147" (TpApp (TpVar "1148" "Rec") (TpVar "1154" "F")) "1156")) (TpParens "1159" (TpApp (TpVar "1160" "F") (TpParens "1164" (TpApp (TpVar "1165" "Rec") (TpVar "1171" "F")) "1173")) "1174"))))) (Lam "1179" Erased "1181" "F" NoClass (Lam "1184" Erased "1186" "fmap" NoClass (IotaPair "1192" (Lam "1193" Erased "1195" "indices" NoClass (Lam "1204" NotErased "1206" "a" NoClass (App (Var "1209" "a") Erased (Parens "1212" (App (Var "1213" "fmap") Erased (Parens "1219" (App (Var "1220" "recIn") Erased (Var "1227" "fmap")) "1232")) "1233")))) (Beta "1235" NoTerm NoTerm) NoGuide "1237")))) "1238") (CmdsNext (DefTermOrType OpacTrans (DefType "1240" "FixMF" (KndPi "1248" "1250" "F" (Tkk (KndArrow (KndParens "1254" (KndTpArrow (TpVar "1255" "Indices") (Star "1265")) "1267") (KndTpArrow (TpVar "1270" "Indices") (Star "1280")))) (KndTpArrow (TpApp (TpVar "1283" "RecFunctor") (TpVar "1296" "F")) (KndArrow (KndParens "1300" (KndTpArrow (TpVar "1301" "Indices") (Star "1311")) "1313") (KndTpArrow (TpVar "1316" "Indices") (Star "1326"))))) (TpLambda "1332" "1334" "F" (Tkk (KndArrow (KndParens "1338" (KndTpArrow (TpVar "1339" "Indices") (Star "1349")) "1351") (KndTpArrow (TpVar "1354" "Indices") (Star "1364")))) (TpLambda "1367" "1369" "fm" (Tkt (TpApp (TpVar "1374" "RecFunctor") (TpVar "1387" "F"))) (TpLambda "1394" "1396" "FixM" (Tkk (KndTpArrow (TpVar "1403" "Indices") (Star "1413"))) (TpLambda "1416" "1418" "indices" (Tkt (TpVar "1428" "Indices")) (Iota "1444" "1446" "x" (TpVar "1450" "Top") (Abs "1455" Erased "1457" "X" (Tkk (KndTpArrow (TpVar "1461" "Top") (KndTpArrow (TpVar "1467" "Indices") (Star "1477")))) (TpArrow (TpParens "1488" (Iota "1489" "1491" "alg" (TpVar "1497" "Top") (Abs "1511" Erased "1513" "R" (Tkk (KndTpArrow (TpVar "1517" "Indices") (Star "1527"))) (TpArrow (TpApp (TpApp (TpVar "1539" "Cast") (TpVar "1546" "R")) (TpVar "1550" "FixM")) Erased (TpArrow (TpParens "1566" (Iota "1567" "1569" "o" (Abs "1573" Erased "1575" "indices" (Tkt (TpVar "1585" "Indices")) (TpArrow (TpAppt (TpVar "1594" "R") (Var "1596" "indices")) NotErased (TpAppt (TpApp (TpVar "1606" "F") (TpVar "1610" "R")) (Var "1612" "indices")))) (TpEq "1632" (Var "1633" "o") (Lam "1637" NotErased "1639" "d" NoClass (App (Var "1642" "d") NotErased (Parens "1644" (Lam "1645" NotErased "1647" "e" NoClass (Lam "1650" NotErased "1652" "p" NoClass (Lam "1655" NotErased "1657" "d" NoClass (Var "1660" "d")))) "1662"))) "1663")) "1664") NotErased (TpArrow (TpParens "1676" (Iota "1677" "1679" "ih" (Abs "1684" Erased "1686" "indices" (Tkt (TpVar "1696" "Indices")) (Abs "1705" NotErased "1707" "r" (Tkt (TpAppt (TpVar "1711" "R") (Var "1713" "indices"))) (TpAppt (TpAppt (TpVar "1722" "X") (Beta "1724" NoTerm (SomeTerm (Var "1726" "r") "1728"))) (Var "1729" "indices")))) (TpEq "1738" (Var "1739" "ih") (Lam "1744" NotErased "1746" "d" NoClass (App (Var "1749" "d") NotErased (Var "1751" "alg"))) "1755")) "1756") NotErased (Abs "1768" Erased "1770" "indices" (Tkt (TpVar "1780" "Indices")) (Abs "1798" NotErased "1800" "x" (Tkt (TpAppt (TpApp (TpVar "1804" "F") (TpVar "1808" "R")) (Var "1810" "indices"))) (TpAppt (TpAppt (TpVar "1828" "X") (Beta "1830" NoTerm (SomeTerm (Lam "1832" NotErased "1834" "alg" NoClass (App (App (App (Var "1839" "alg") NotErased (Parens "1843" (Lam "1844" NotErased "1846" "d" NoClass (App (Var "1849" "d") NotErased (Parens "1851" (Lam "1852" NotErased "1854" "p" NoClass (Lam "1857" NotErased "1859" "e" NoClass (Lam "1862" NotErased "1864" "d" NoClass (Var "1867" "d")))) "1869"))) "1870")) NotErased (Parens "1871" (Lam "1872" NotErased "1874" "d" NoClass (App (Var "1877" "d") NotErased (Var "1879" "alg"))) "1883")) NotErased (Var "1884" "x"))) "1886"))) (Var "1887" "indices"))))))))) "1895") NotErased (TpAppt (TpAppt (TpVar "1906" "X") (Var "1908" "x")) (Var "1910" "indices")))))))))) "1918") (CmdsNext (DefTermOrType OpacTrans (DefType "1920" "FixM" (KndPi "1927" "1929" "F" (Tkk (KndArrow (KndParens "1933" (KndTpArrow (TpVar "1934" "Indices") (Star "1944")) "1946") (KndTpArrow (TpVar "1949" "Indices") (Star "1959")))) (KndTpArrow (TpApp (TpVar "1962" "RecFunctor") (TpVar "1975" "F")) (KndTpArrow (TpVar "1979" "Indices") (Star "1989")))) (TpLambda "1995" "1997" "F" (Tkk (KndArrow (KndParens "2001" (KndTpArrow (TpVar "2002" "Indices") (Star "2012")) "2014") (KndTpArrow (TpVar "2017" "Indices") (Star "2027")))) (TpLambda "2030" "2032" "fm" (Tkt (TpApp (TpVar "2037" "RecFunctor") (TpVar "2050" "F"))) (TpApp (TpVar "2053" "Rec") (TpParens "2059" (TpAppt (TpApp (TpVar "2060" "FixMF") (TpVar "2068" "F")) (Var "2070" "fm")) "2073"))))) "2074") (CmdsNext (DefTermOrType OpacTrans (DefTerm "2076" "FixFmap" (SomeType (Abs "2090" Erased "2092" "F" (Tkk (KndArrow (KndParens "2096" (KndTpArrow (TpVar "2097" "Indices") (Star "2107")) "2109") (KndTpArrow (TpVar "2112" "Indices") (Star "2122")))) (Abs "2125" Erased "2127" "fm" (Tkt (TpApp (TpVar "2132" "RecFunctor") (TpVar "2145" "F"))) (TpApp (TpVar "2148" "RecFunctor") (TpParens "2161" (TpAppt (TpApp (TpVar "2162" "FixMF") (TpVar "2170" "F")) (Var "2172" "fm")) "2175"))))) (Lam "2180" Erased "2182" "F" NoClass (Lam "2185" Erased "2187" "fm" NoClass (Lam "2191" Erased "2193" "D" NoClass (Lam "2196" Erased "2198" "D'" NoClass (Lam "2202" Erased "2204" "c" NoClass (IotaPair "2211" (Lam "2212" Erased "2214" "indices" NoClass (Lam "2223" NotErased "2225" "d" NoClass (IotaPair "2228" (IotaProj (Var "2229" "d") "1" "2232") (Lam "2234" Erased "2236" "X" NoClass (Lam "2239" NotErased "2241" "alg" NoClass (App (AppTp (IotaProj (Var "2246" "d") "2" "2249") (TpVar "2252" "X")) NotErased (IotaPair "2260" (IotaProj (Var "2261" "alg") "1" "2266") (Lam "2268" Erased "2270" "R" NoClass (Lam "2273" Erased "2275" "reveal" NoClass (App (AppTp (IotaProj (Var "2283" "alg") "2" "2288") (TpVar "2291" "R")) Erased (IotaPair "2302" (Lam "2303" Erased "2305" "indices" NoClass (Lam "2314" NotErased "2316" "r" NoClass (App (App (App (Var "2319" "cast") Erased (Var "2325" "c")) Erased (Var "2328" "indices")) NotErased (Parens "2336" (App (App (App (Var "2337" "cast") Erased (Var "2343" "reveal")) Erased (Var "2351" "indices")) NotErased (Var "2359" "r")) "2361")))) (Beta "2363" NoTerm NoTerm) NoGuide "2365")))) NoGuide "2366")))) NoGuide "2367"))) (Beta "2369" NoTerm NoTerm) NoGuide "2371"))))))) "2372") (CmdsNext (DefTermOrType OpacTrans (DefTerm "2374" "inFixM" (SomeType (Abs "2387" Erased "2389" "F" (Tkk (KndArrow (KndParens "2393" (KndTpArrow (TpVar "2394" "Indices") (Star "2404")) "2406") (KndTpArrow (TpVar "2409" "Indices") (Star "2419")))) (Abs "2422" Erased "2424" "fm" (Tkt (TpApp (TpVar "2429" "RecFunctor") (TpVar "2442" "F"))) (Abs "2449" Erased "2451" "indices" (Tkt (TpVar "2461" "Indices")) (TpArrow (TpAppt (TpApp (TpAppt (TpApp (TpVar "2470" "FixMF") (TpVar "2478" "F")) (Var "2480" "fm")) (TpParens "2485" (TpAppt (TpApp (TpVar "2486" "FixM") (TpVar "2493" "F")) (Var "2495" "fm")) "2498")) (Var "2499" "indices")) NotErased (TpAppt (TpAppt (TpApp (TpVar "2509" "FixM") (TpVar "2516" "F")) (Var "2518" "fm")) (Var "2521" "indices"))))))) (Lam "2533" Erased "2535" "F" NoClass (Lam "2538" Erased "2540" "fm" NoClass (App (Var "2544" "cast") Erased (Parens "2550" (App (Var "2551" "recIn") Erased (Parens "2558" (App (Var "2559" "FixFmap") NotErased (Var "2567" "fm")) "2570")) "2571"))))) "2572") (CmdsNext (DefTermOrType OpacTrans (DefTerm "2573" "outFixM" (SomeType (Abs "2583" Erased "2585" "F" (Tkk (KndArrow (KndParens "2589" (KndTpArrow (TpVar "2590" "Indices") (Star "2600")) "2602") (KndTpArrow (TpVar "2605" "Indices") (Star "2615")))) (Abs "2618" Erased "2620" "fm" (Tkt (TpApp (TpVar "2625" "RecFunctor") (TpVar "2638" "F"))) (Abs "2645" Erased "2647" "indices" (Tkt (TpVar "2657" "Indices")) (TpArrow (TpAppt (TpAppt (TpApp (TpVar "2666" "FixM") (TpVar "2673" "F")) (Var "2675" "fm")) (Var "2678" "indices")) NotErased (TpAppt (TpApp (TpAppt (TpApp (TpVar "2688" "FixMF") (TpVar "2696" "F")) (Var "2698" "fm")) (TpParens "2703" (TpAppt (TpApp (TpVar "2704" "FixM") (TpVar "2711" "F")) (Var "2713" "fm")) "2716")) (Var "2717" "indices"))))))) (Lam "2729" Erased "2731" "F" NoClass (Lam "2734" Erased "2736" "fm" NoClass (App (Var "2740" "cast") Erased (Parens "2746" (App (Var "2747" "recOut") Erased (Parens "2755" (App (Var "2756" "FixFmap") NotErased (Var "2764" "fm")) "2767")) "2768"))))) "2769") (CmdsNext (DefTermOrType OpacTrans (DefTerm "2771" "inFix" (SomeType (Abs "2783" Erased "2785" "F" (Tkk (KndArrow (KndParens "2789" (KndTpArrow (TpVar "2790" "Indices") (Star "2800")) "2802") (KndTpArrow (TpVar "2805" "Indices") (Star "2815")))) (Abs "2818" Erased "2820" "fm" (Tkt (TpApp (TpVar "2825" "RecFunctor") (TpVar "2838" "F"))) (Abs "2845" Erased "2847" "indices" (Tkt (TpVar "2857" "Indices")) (TpArrow (TpAppt (TpApp (TpVar "2866" "F") (TpParens "2870" (TpAppt (TpApp (TpVar "2871" "FixM") (TpVar "2878" "F")) (Var "2880" "fm")) "2883")) (Var "2884" "indices")) NotErased (TpAppt (TpAppt (TpApp (TpVar "2894" "FixM") (TpVar "2901" "F")) (Var "2903" "fm")) (Var "2906" "indices"))))))) (Lam "2918" Erased "2920" "F" NoClass (Lam "2923" Erased "2925" "fm" NoClass (Lam "2929" Erased "2931" "indices" NoClass (Lam "2940" NotErased "2942" "d" NoClass (App (App (App (Var "2945" "inFixM") Erased (Var "2953" "fm")) Erased (Var "2957" "indices")) NotErased (IotaPair "2967" (Beta "2968" NoTerm (SomeTerm (Lam "2970" NotErased "2972" "alg" NoClass (App (App (App (Var "2977" "alg") NotErased (Parens "2981" (Lam "2982" NotErased "2984" "d" NoClass (App (Var "2987" "d") NotErased (Parens "2989" (Lam "2990" NotErased "2992" "p" NoClass (Lam "2995" NotErased "2997" "e" NoClass (Lam "3000" NotErased "3002" "d" NoClass (Var "3005" "d")))) "3007"))) "3008")) NotErased (Parens "3009" (Lam "3010" NotErased "3012" "d" NoClass (App (Var "3015" "d") NotErased (Var "3017" "alg"))) "3021")) NotErased (Var "3022" "d"))) "3024")) (Lam "3029" Erased "3031" "X" NoClass (Lam "3034" NotErased "3036" "alg" NoClass (App (App (App (App (App (AppTp (IotaProj (Var "3041" "alg") "2" "3046") (TpParens "3049" (TpAppt (TpApp (TpVar "3050" "FixM") (TpVar "3057" "F")) (Var "3059" "fm")) "3062")) Erased (IotaPair "3064" (Lam "3065" Erased "3067" "indices" NoClass (Lam "3076" NotErased "3078" "d" NoClass (Var "3081" "d"))) (Beta "3084" NoTerm NoTerm) NoGuide "3086")) NotErased (IotaPair "3092" (Lam "3093" Erased "3095" "indices" NoClass (Lam "3104" NotErased "3106" "d" NoClass (App (AppTp (IotaProj (Parens "3109" (App (App (App (Var "3110" "outFixM") Erased (Var "3119" "fm")) Erased (Var "3123" "indices")) NotErased (Var "3131" "d")) "3133") "2" "3135") (TpParens "3138" (TpLambda "3139" "3141" "x" (Tkt (TpVar "3145" "Top")) (TpApp (TpVar "3150" "F") (TpParens "3154" (TpAppt (TpApp (TpVar "3155" "FixM") (TpVar "3162" "F")) (Var "3164" "fm")) "3167"))) "3168")) NotErased (IotaPair "3176" (Beta "3177" NoTerm (SomeTerm (Lam "3179" NotErased "3181" "p" NoClass (Lam "3184" NotErased "3186" "e" NoClass (Lam "3189" NotErased "3191" "d" NoClass (Var "3194" "d")))) "3196")) (Lam "3198" Erased "3200" "X" NoClass (Lam "3203" Erased "3205" "reveal" NoClass (Lam "3213" NotErased "3215" "p" NoClass (Lam "3218" NotErased "3220" "e" NoClass (App (Var "3223" "cast") Erased (Parens "3229" (App (Var "3230" "fm") Erased (Var "3234" "reveal")) "3241")))))) NoGuide "3242")))) (Beta "3252" NoTerm (SomeTerm (Lam "3254" NotErased "3256" "d" NoClass (App (Var "3259" "d") NotErased (Parens "3261" (Lam "3262" NotErased "3264" "p" NoClass (Lam "3267" NotErased "3269" "e" NoClass (Lam "3272" NotErased "3274" "d" NoClass (Var "3277" "d")))) "3279"))) "3280")) NoGuide "3281")) NotErased (IotaPair "3287" (Lam "3288" Erased "3290" "indices" NoClass (Lam "3299" NotErased "3301" "d" NoClass (App (AppTp (IotaProj (Parens "3304" (App (App (App (Var "3305" "outFixM") Erased (Var "3314" "fm")) Erased (Var "3318" "indices")) NotErased (Var "3326" "d")) "3328") "2" "3330") (TpVar "3333" "X")) NotErased (Var "3335" "alg")))) (Beta "3340" NoTerm (SomeTerm (Lam "3342" NotErased "3344" "d" NoClass (App (Var "3347" "d") NotErased (Var "3349" "alg"))) "3353")) NoGuide "3354")) Erased (Var "3356" "indices")) NotErased (Var "3364" "d")))) NoGuide "3366"))))))) "3367") (CmdsNext (DefTermOrType OpacTrans (DefTerm "3369" "IndFixM" (SomeType (Abs "3383" Erased "3385" "F" (Tkk (KndArrow (KndParens "3389" (KndTpArrow (TpVar "3390" "Indices") (Star "3400")) "3402") (KndTpArrow (TpVar "3405" "Indices") (Star "3415")))) (Abs "3422" Erased "3424" "fm" (Tkt (TpApp (TpVar "3429" "RecFunctor") (TpVar "3442" "F"))) (Abs "3449" Erased "3451" "indices" (Tkt (TpVar "3461" "Indices")) (Abs "3474" NotErased "3476" "d" (Tkt (TpAppt (TpAppt (TpApp (TpVar "3480" "FixM") (TpVar "3487" "F")) (Var "3489" "fm")) (Var "3492" "indices"))) (Abs "3505" Erased "3507" "Q" (Tkk (KndPi "3511" "3513" "indices" (Tkt (TpVar "3523" "Indices")) (KndTpArrow (TpAppt (TpAppt (TpApp (TpVar "3532" "FixM") (TpVar "3539" "F")) (Var "3541" "fm")) (Var "3544" "indices")) (Star "3554")))) (TpArrow (TpParens "3561" (Iota "3562" "3564" "alg" (TpVar "3570" "Top") (Abs "3582" Erased "3584" "R" (Tkk (KndTpArrow (TpVar "3588" "Indices") (Star "3598"))) (Abs "3608" Erased "3610" "reveal" (Tkt (TpApp (TpApp (TpVar "3619" "Cast") (TpVar "3626" "R")) (TpParens "3630" (TpAppt (TpApp (TpVar "3631" "FixM") (TpVar "3638" "F")) (Var "3640" "fm")) "3643"))) (TpArrow (TpParens "3652" (Iota "3653" "3655" "o" (Abs "3659" Erased "3661" "indices" (Tkt (TpVar "3671" "Indices")) (TpArrow (TpAppt (TpVar "3680" "R") (Var "3682" "indices")) NotErased (TpAppt (TpApp (TpVar "3692" "F") (TpVar "3696" "R")) (Var "3698" "indices")))) (TpEq "3717" (Var "3718" "o") (Lam "3722" NotErased "3724" "d" NoClass (App (Var "3727" "d") NotErased (Parens "3729" (Lam "3730" NotErased "3732" "p" NoClass (Lam "3735" NotErased "3737" "e" NoClass (Lam "3740" NotErased "3742" "d" NoClass (Var "3745" "d")))) "3747"))) "3748")) "3749") NotErased (TpArrow (TpParens "3759" (Iota "3760" "3762" "ih" (Abs "3767" Erased "3769" "indices" (Tkt (TpVar "3779" "Indices")) (Abs "3788" NotErased "3790" "r" (Tkt (TpAppt (TpVar "3794" "R") (Var "3796" "indices"))) (TpAppt (TpAppt (TpVar "3814" "Q") (Var "3816" "indices")) (Parens "3824" (App (App (App (Var "3825" "cast") Erased (Var "3831" "reveal")) Erased (Var "3839" "indices")) NotErased (Var "3847" "r")) "3849")))) (TpEq "3851" (Var "3852" "ih") (Lam "3857" NotErased "3859" "d" NoClass (App (Var "3862" "d") NotErased (Var "3864" "alg"))) "3868")) "3869") NotErased (Abs "3879" Erased "3881" "indices" (Tkt (TpVar "3891" "Indices")) (Abs "3907" NotErased "3909" "x" (Tkt (TpAppt (TpApp (TpVar "3913" "F") (TpVar "3917" "R")) (Var "3919" "indices"))) (TpAppt (TpAppt (TpVar "3935" "Q") (Var "3937" "indices")) (Parens "3945" (App (App (App (Var "3946" "inFix") Erased (Var "3953" "fm")) Erased (Var "3957" "indices")) NotErased (Parens "3965" (App (App (App (Var "3966" "cast") Erased (Parens "3972" (App (Var "3973" "fm") Erased (Var "3977" "reveal")) "3984")) Erased (Var "3986" "indices")) NotErased (Var "3994" "x")) "3996")) "3997"))))))))) "3998") NotErased (TpAppt (TpAppt (TpVar "4005" "Q") (Var "4007" "indices")) (Var "4015" "d"))))))))) (Lam "4021" Erased "4023" "F" NoClass (Lam "4026" Erased "4028" "fm" NoClass (Lam "4032" Erased "4034" "indices" NoClass (Lam "4043" NotErased "4045" "d" NoClass (Lam "4048" Erased "4050" "Q" NoClass (Lam "4053" NotErased "4055" "alg" NoClass (App (App (App (AppTp (IotaProj (Parens "4060" (App (App (App (Var "4061" "outFixM") Erased (Var "4070" "fm")) Erased (Var "4074" "indices")) NotErased (Var "4082" "d")) "4084") "2" "4086") (TpParens "4093" (TpLambda "4094" "4096" "d" (Tkt (TpVar "4100" "Top")) (TpLambda "4105" "4107" "indices" (Tkt (TpVar "4117" "Indices")) (Abs "4135" Erased "4137" "d'" (Tkt (TpAppt (TpAppt (TpApp (TpVar "4142" "FixM") (TpVar "4149" "F")) (Var "4151" "fm")) (Var "4154" "indices"))) (Abs "4163" Erased "4165" "e" (Tkt (TpEq "4169" (Var "4170" "d'") (Var "4175" "d") "4177")) (TpAppt (TpAppt (TpVar "4179" "Q") (Var "4181" "indices")) (Parens "4189" (Phi "4190" (Var "4192" "e") (Var "4196" "d'") (Var "4200" "d") "4202") "4203")))))) "4204")) NotErased (IotaPair "4209" (Beta "4210" NoTerm (SomeTerm (Var "4212" "alg") "4216")) (Lam "4218" Erased "4220" "R" NoClass (Lam "4223" Erased "4225" "reveal" NoClass (Lam "4233" NotErased "4235" "out" NoClass (Lam "4240" NotErased "4242" "ih" NoClass (Lam "4246" Erased "4248" "indices" NoClass (Lam "4257" NotErased "4259" "d" NoClass (Lam "4262" Erased "4264" "d'" NoClass (Lam "4268" Erased "4270" "e" NoClass (App (App (App (App (App (AppTp (IotaProj (Var "4273" "alg") "2" "4278") (TpVar "4281" "R")) Erased (Var "4284" "reveal")) NotErased (Var "4291" "out")) NotErased (IotaPair "4301" (Lam "4302" Erased "4304" "indices" NoClass (Lam "4313" NotErased "4315" "r" NoClass (App (App (App (App (IotaProj (Var "4318" "ih") "1" "4322") Erased (Var "4324" "indices")) NotErased (Var "4332" "r")) Erased (Parens "4335" (App (App (App (Var "4336" "cast") Erased (Var "4342" "reveal")) Erased (Var "4350" "indices")) NotErased (Var "4358" "r")) "4360")) Erased (Beta "4362" NoTerm NoTerm)))) (IotaProj (Var "4365" "ih") "2" "4369") NoGuide "4370")) Erased (Var "4372" "indices")) NotErased (Var "4380" "d")))))))))) NoGuide "4382")) Erased (Var "4389" "d")) Erased (Beta "4392" NoTerm NoTerm))))))))) "4394") CmdsStart))))))))))))))) "4394"
|
{
"alphanum_fraction": 0.6312593514,
"avg_line_length": 7917.3846153846,
"ext": "agda",
"hexsha": "113b5a1fc1f10318a0ba8c4867231ae6fa9e0150",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "acf691e37210607d028f4b19f98ec26c4353bfb5",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "xoltar/cedille",
"max_forks_repo_path": "src/templates.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "acf691e37210607d028f4b19f98ec26c4353bfb5",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "xoltar/cedille",
"max_issues_repo_path": "src/templates.agda",
"max_line_length": 79494,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "acf691e37210607d028f4b19f98ec26c4353bfb5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "xoltar/cedille",
"max_stars_repo_path": "src/templates.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 45097,
"size": 102926
}
|
module Esterel.Lang.CanFunction.MergePotentialRuleLeftInductive where
open import utility
renaming (_U̬_ to _∪_ ; _|̌_ to _-_)
open import Esterel.Lang
open import Esterel.Lang.Binding
open import Esterel.Lang.CanFunction
open import Esterel.Lang.CanFunction.Base
open import Esterel.Lang.CanFunction.CanThetaContinuation
open import Esterel.Lang.CanFunction.MergePotentialRuleCan
open import Esterel.Lang.CanFunction.MergePotentialRuleLeftBase
open import Esterel.Context
using (EvaluationContext1 ; EvaluationContext ; _⟦_⟧e ; _≐_⟦_⟧e)
open import Esterel.Context.Properties
using (plug ; unplug)
open import Esterel.Environment as Env
using (Env ; Θ ; _←_ ; Dom ; module SigMap ; module ShrMap ; module VarMap)
open import Esterel.CompletionCode as Code
using () renaming (CompletionCode to Code)
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 EvaluationContext1
open _≐_⟦_⟧e
open import Data.Bool
using (Bool ; not ; if_then_else_)
open import Data.Empty
using (⊥ ; ⊥-elim)
open import Data.List
using (List ; [] ; _∷_ ; _++_ ; map ; concatMap ; foldr)
open import Data.List.Properties
using (map-id)
open import Data.List.Any
using (Any ; any ; here ; there)
open import Data.List.Any.Properties
using ()
renaming (++⁺ˡ to ++ˡ ; ++⁺ʳ to ++ʳ)
open import Data.Maybe
using (Maybe ; maybe ; just ; nothing)
open import Data.Nat
using (ℕ ; zero ; suc ; _≟_ ; _+_)
open import Data.Nat.Properties.Simple
using (+-comm)
open import Data.Product
using (Σ ; proj₁ ; proj₂ ; ∃ ; _,_ ; _,′_ ; _×_)
open import Data.Sum
using (_⊎_ ; inj₁ ; inj₂)
open import Function
using (_∘_ ; id ; _∋_)
open import Relation.Nullary
using (¬_ ; Dec ; yes ; no)
open import Relation.Nullary.Decidable
using (⌊_⌋)
open import Relation.Binary.PropositionalEquality
using (_≡_ ; _≢_ ; refl ; trans ; sym ; cong ; subst ; module ≡-Reasoning)
open ListSet Data.Nat._≟_
using (set-subtract ; set-subtract-[] ; set-subtract-split ; set-subtract-merge
; set-subtract-notin
; set-remove ; set-remove-mono-∈ ; set-remove-removed ; set-remove-not-removed
; set-subtract-[a]≡set-remove)
open import Data.OrderedListMap Signal Signal.unwrap Signal.Status as SigM
open import Data.OrderedListMap SharedVar SharedVar.unwrap (Σ SharedVar.Status (λ _ → ℕ)) as ShrM
open import Data.OrderedListMap SeqVar SeqVar.unwrap ℕ as SeqM
open ≡-Reasoning
canθₖ-mergeˡ-E-induction : ∀ {E E⟦nothin⟧ BV FV A} sigs' shrs' vars' r θ →
E⟦nothin⟧ ≐ E ⟦ nothin ⟧e →
CorrectBinding E⟦nothin⟧ BV FV →
distinct' (SigMap.keys sigs') (proj₁ FV) →
Canθₖ sigs' 0 (E ⟦ r ⟧e) θ ≡
Canₖ (E ⟦ ρ⟨ Θ sigs' shrs' vars' , A ⟩· r ⟧e) θ
canθₖ-mergeˡ-sigs-induction : ∀ {E E⟦nothin⟧ BV FV A} sigs S sigs' shrs' vars' r θ →
E⟦nothin⟧ ≐ E ⟦ nothin ⟧e →
CorrectBinding E⟦nothin⟧ BV FV →
distinct' (SigMap.keys sigs') (proj₁ FV) →
∀ k →
k ∈ proj₁ (proj₂ (Canθ' sigs S (Canθ sigs' 0 (E ⟦ r ⟧e)) θ)) →
k ∈ Canθₖ sigs S (E ⟦ ρ⟨ Θ sigs' shrs' vars' , A ⟩· r ⟧e) θ
canθₛ-mergeˡ-E-induction : ∀ {E E⟦nothin⟧ BV FV A} sigs' shrs' vars' r θ →
E⟦nothin⟧ ≐ E ⟦ nothin ⟧e →
CorrectBinding E⟦nothin⟧ BV FV →
distinct' (SigMap.keys sigs') (proj₁ FV) →
∀ S' →
S' ∉ SigMap.keys sigs' →
S' ∈ Canθₛ sigs' 0 (E ⟦ r ⟧e) θ →
S' ∈ Canₛ (E ⟦ ρ⟨ Θ sigs' shrs' vars' , A ⟩· r ⟧e) θ
canθₛ-mergeˡ-E-induction {[]} sigs' shrs' vars' r θ
E⟦nothin⟧ cb sigs'≠FV
S' S'∉sigs' S'∈canθ-sigs'-E⟦r⟧-θ =
set-subtract-notin S'∈canθ-sigs'-E⟦r⟧-θ S'∉sigs'
canθₛ-mergeˡ-E-induction {epar₁ q ∷ E} {A = A} sigs' shrs' vars' r θ
(depar₁ E⟦nothin⟧) cb@(CBpar cbp _ _ _ _ _) sigs'≠FV
S' S'∉sigs' S'∈canθ-sigs'-E⟦r⟧-θ
rewrite Env.←-comm Env.[]env θ distinct-empty-left
with canθₛ-mergeˡ-E-induction-base-par₁ sigs' 0 r θ Env.[]env (depar₁ E⟦nothin⟧) cb
(subst (distinct' _)
(sym (map-id (SigMap.keys sigs')))
(distinct'-sym sigs'≠FV))
S' S'∈canθ-sigs'-E⟦r⟧-θ
... | inj₁ S'∈canθ'-sigs'-E⟦r⟧-θ←[] =
++ˡ (canθₛ-mergeˡ-E-induction sigs' shrs' vars' r (θ ← Env.[]env)
E⟦nothin⟧ cbp (dist'++ˡ sigs'≠FV)
S' S'∉sigs' S'∈canθ'-sigs'-E⟦r⟧-θ←[])
... | inj₂ S'∈can-q-θ←[] =
++ʳ (Canₛ (E ⟦ ρ⟨ Θ sigs' shrs' vars' , A ⟩· r ⟧e) (θ ← Env.[]env))
S'∈can-q-θ←[]
canθₛ-mergeˡ-E-induction {epar₂ p ∷ E} sigs' shrs' vars' r θ
(depar₂ E⟦nothin⟧) cb@(CBpar {FVp = FVp} _ cbq _ _ _ _) sigs'≠FV
S' S'∉sigs' S'∈canθ-sigs'-E⟦r⟧-θ
rewrite Env.←-comm Env.[]env θ distinct-empty-left
with canθₛ-mergeˡ-E-induction-base-par₂ sigs' 0 r θ Env.[]env (depar₂ E⟦nothin⟧) cb
(subst (distinct' _)
(sym (map-id (SigMap.keys sigs')))
(distinct'-sym sigs'≠FV))
S' S'∈canθ-sigs'-E⟦r⟧-θ
... | inj₁ S'∈canθ'-sigs'-E⟦r⟧-θ←[] =
++ʳ (Canₛ p (θ ← Env.[]env))
(canθₛ-mergeˡ-E-induction sigs' shrs' vars' r (θ ← Env.[]env)
E⟦nothin⟧ cbq (dist'++ʳ {V2 = proj₁ FVp} sigs'≠FV)
S' S'∉sigs' S'∈canθ'-sigs'-E⟦r⟧-θ←[])
... | inj₂ S'∈can-q-θ←[] =
++ˡ S'∈can-q-θ←[]
canθₛ-mergeˡ-E-induction {eseq q ∷ E} sigs' shrs' vars' r θ
(deseq E⟦nothin⟧) cb@(CBseq cbp _ _) sigs'≠FV
S' S'∉sigs' S'∈canθ-sigs'-E⟦r⟧-θ
rewrite Env.←-comm Env.[]env θ distinct-empty-left
with canθₛ-mergeˡ-E-induction-base-seq sigs' 0 r θ Env.[]env (deseq E⟦nothin⟧) cb
(subst (distinct' _)
(sym (map-id (SigMap.keys sigs')))
(distinct'-sym sigs'≠FV))
S' S'∈canθ-sigs'-E⟦r⟧-θ
canθₛ-mergeˡ-E-induction {eseq q ∷ E} {A = A} sigs' shrs' vars' r θ
(deseq E⟦nothin⟧) cb@(CBseq cbp _ _) sigs'≠FV
S' S'∉sigs' S'∈canθ-sigs'-E⟦r⟧-θ
| inj₁ S'∈canθ'-sigs'-E⟦r⟧-θ←[]
with any (Code._≟_ Code.nothin) (Canₖ (E ⟦ ρ⟨ Θ sigs' shrs' vars' , A ⟩· r ⟧e) (θ ← Env.[]env))
... | yes nothin∈can-E⟦ρΘ⟧-θ←[] =
++ˡ (canθₛ-mergeˡ-E-induction sigs' shrs' vars' r (θ ← Env.[]env)
E⟦nothin⟧ cbp (dist'++ˡ sigs'≠FV)
S' S'∉sigs' S'∈canθ'-sigs'-E⟦r⟧-θ←[])
... | no nothin∉can-E⟦ρΘ⟧-θ←[] =
canθₛ-mergeˡ-E-induction sigs' shrs' vars' r (θ ← Env.[]env)
E⟦nothin⟧ cbp (dist'++ˡ sigs'≠FV)
S' S'∉sigs' S'∈canθ'-sigs'-E⟦r⟧-θ←[]
canθₛ-mergeˡ-E-induction {eseq q ∷ E} {A = A} sigs' shrs' vars' r θ
(deseq E⟦nothin⟧) cb@(CBseq cbp _ _) sigs'≠FV
S' S'∉sigs' S'∈canθ-sigs'-E⟦r⟧-θ
| inj₂ (S'∈can-q-θ←[] , nothin∈canθ-sigs'-E⟦r⟧-θ←[])
with any (Code._≟_ Code.nothin) (Canₖ (E ⟦ ρ⟨ Θ sigs' shrs' vars' , A ⟩· r ⟧e) (θ ← Env.[]env))
... | yes nothin∈can-E⟦ρΘ⟧-θ←[] =
++ʳ (Canₛ (E ⟦ ρ⟨ Θ sigs' shrs' vars' , A ⟩· r ⟧e) (θ ← Env.[]env))
S'∈can-q-θ←[]
... | no nothin∉can-E⟦ρΘ⟧-θ←[]
rewrite canθₖ-mergeˡ-E-induction {A = A} sigs' shrs' vars' r (θ ← Env.[]env)
E⟦nothin⟧ cbp (dist'++ˡ sigs'≠FV)
= ⊥-elim (nothin∉can-E⟦ρΘ⟧-θ←[] nothin∈canθ-sigs'-E⟦r⟧-θ←[])
canθₛ-mergeˡ-E-induction {eloopˢ q ∷ E} sigs' shrs' vars' r θ
(deloopˢ E⟦nothin⟧) cb@(CBloopˢ cbp cbq _ _) sigs'≠FV
S' S'∉sigs' S'∈canθ-sigs'-E⟦r⟧-θ
rewrite unfold sigs' 0 (loopˢ (E ⟦ r ⟧e) q) θ
| sym (unfold sigs' 0 (E ⟦ r ⟧e) θ)
= canθₛ-mergeˡ-E-induction sigs' shrs' vars' r θ E⟦nothin⟧ cbp
(dist'++ˡ sigs'≠FV)
S' S'∉sigs' S'∈canθ-sigs'-E⟦r⟧-θ
canθₛ-mergeˡ-E-induction {esuspend S ∷ E} sigs' shrs' vars' r θ
(desuspend E⟦nothin⟧) cb@(CBsusp cb' _) sigs'≠FV
S' S'∉sigs' S'∈canθ-sigs'-E⟦r⟧-θ
rewrite unfold sigs' 0 (suspend (E ⟦ r ⟧e) S) θ
| sym (unfold sigs' 0 (E ⟦ r ⟧e) θ)
= canθₛ-mergeˡ-E-induction sigs' shrs' vars' r θ E⟦nothin⟧ cb'
(dist'++ʳ {V2 = Signal.unwrap S ∷ []} sigs'≠FV)
S' S'∉sigs' S'∈canθ-sigs'-E⟦r⟧-θ
canθₛ-mergeˡ-E-induction {etrap ∷ E} sigs' shrs' vars' r θ
(detrap E⟦nothin⟧) cb@(CBtrap cb') sigs'≠FV
S' S'∉sigs' S'∈canθ-sigs'-E⟦r⟧-θ
rewrite unfold sigs' 0 (trap (E ⟦ r ⟧e)) θ
| canθ'-map-comm (map Code.↓*) sigs' 0 (Can (E ⟦ r ⟧e)) θ
| sym (unfold sigs' 0 (E ⟦ r ⟧e) θ)
= canθₛ-mergeˡ-E-induction sigs' shrs' vars' r θ E⟦nothin⟧ cb' sigs'≠FV
S' S'∉sigs' S'∈canθ-sigs'-E⟦r⟧-θ
canθₛ-mergeˡ-sigs-induction : ∀ {E E⟦nothin⟧ BV FV A} sigs S sigs' shrs' vars' r θ →
E⟦nothin⟧ ≐ E ⟦ nothin ⟧e →
CorrectBinding E⟦nothin⟧ BV FV →
distinct' (SigMap.keys sigs') (proj₁ FV) →
∀ S' →
S' ∉ SigMap.keys sigs' →
S' ∈ proj₁ (Canθ' sigs S (Canθ sigs' 0 (E ⟦ r ⟧e)) θ) →
S' ∈ Canθₛ sigs S (E ⟦ ρ⟨ Θ sigs' shrs' vars' , A ⟩· r ⟧e) θ
canθₛ-mergeˡ-sigs-induction [] S sigs' shrs' vars' r θ
E⟦nothin⟧ cb sigs'≠FV S' S'∉sigs' S'∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ =
canθₛ-mergeˡ-E-induction sigs' shrs' vars'
r θ E⟦nothin⟧ cb sigs'≠FV
S' S'∉sigs' S'∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ
canθₛ-mergeˡ-sigs-induction (nothing ∷ sigs) S sigs' shrs' vars' r θ
E⟦nothin⟧ cb sigs'≠FV S' S'∉sigs' S'∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ =
canθₛ-mergeˡ-sigs-induction sigs (suc S) sigs' shrs' vars'
r θ E⟦nothin⟧ cb sigs'≠FV
S' S'∉sigs' S'∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ
canθₛ-mergeˡ-sigs-induction (just Signal.present ∷ sigs) S sigs' shrs' vars' r θ
E⟦nothin⟧ cb sigs'≠FV S' S'∉sigs' S'∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ =
canθₛ-mergeˡ-sigs-induction sigs (suc S) sigs' shrs' vars'
r (θ ← [S]-env-present (S ₛ)) E⟦nothin⟧ cb sigs'≠FV
S' S'∉sigs' S'∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ
canθₛ-mergeˡ-sigs-induction (just Signal.absent ∷ sigs) S sigs' shrs' vars' r θ
E⟦nothin⟧ cb sigs'≠FV S' S'∉sigs' S'∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ =
canθₛ-mergeˡ-sigs-induction sigs (suc S) sigs' shrs' vars'
r (θ ← [S]-env-absent (S ₛ)) E⟦nothin⟧ cb sigs'≠FV
S' S'∉sigs' S'∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ
canθₛ-mergeˡ-sigs-induction {E} {A = A} (just Signal.unknown ∷ sigs) S sigs' shrs' vars' r θ
E⟦nothin⟧ cb sigs'≠FV S' S'∉sigs' S'∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ
with any (_≟_ S) (proj₁
(Canθ' sigs (suc S) (Canθ sigs' 0 (E ⟦ r ⟧e))
(θ ← [S]-env (S ₛ))))
| any (_≟_ S) (proj₁
(Canθ sigs (suc S) (E ⟦ ρ⟨ Θ sigs' shrs' vars' , A ⟩· r ⟧e)
(θ ← [S]-env (S ₛ))))
... | yes S∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ←[S] | yes S∈canθ-sigs-E⟦ρΘsigs'⟧-θ←[S] =
canθₛ-mergeˡ-sigs-induction sigs (suc S) sigs' shrs' vars'
r (θ ← [S]-env (S ₛ)) E⟦nothin⟧ cb sigs'≠FV
S' S'∉sigs' S'∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ
... | no S∉canθ'-sigs-canθ-sigs'-E⟦r⟧-θ←[S] | no S∉canθ-sigs-E⟦ρΘsigs'⟧-θ←[S] =
canθₛ-mergeˡ-sigs-induction sigs (suc S) sigs' shrs' vars'
r (θ ← [S]-env-absent (S ₛ)) E⟦nothin⟧ cb sigs'≠FV
S' S'∉sigs' S'∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ
... | no S∉canθ'-sigs-canθ-sigs'-E⟦r⟧-θ←[S] | yes S∈canθ-sigs-E⟦ρΘsigs'⟧-θ←[S] =
canθₛ-add-sig-monotonic sigs (suc S) (E ⟦ ρ⟨ Θ sigs' shrs' vars' , A ⟩· r ⟧e) θ
(S ₛ) Signal.absent S'
(canθₛ-mergeˡ-sigs-induction sigs (suc S) sigs' shrs' vars'
r (θ ← [S]-env-absent (S ₛ)) E⟦nothin⟧ cb sigs'≠FV
S' S'∉sigs' S'∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ)
... | yes S∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ←[S] | no S∉canθ-sigs-E⟦ρΘsigs'⟧-θ←[S]
with any (_≟_ S) (SigMap.keys sigs')
... | yes S∈sigs' =
canθₛ-mergeˡ-sigs-induction sigs (suc S) sigs' shrs' vars'
r (θ ← [S]-env-absent (S ₛ)) E⟦nothin⟧ cb sigs'≠FV
S' S'∉sigs'
(subst (S' ∈_)
(cong proj₁
(trans
(canθ'-inner-shadowing-irr sigs (suc S) sigs' (E ⟦ r ⟧e)
S Signal.unknown θ S∈sigs')
(sym (canθ'-inner-shadowing-irr sigs (suc S) sigs' (E ⟦ r ⟧e)
S Signal.absent θ S∈sigs'))))
S'∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ)
... | no S∉sigs' =
⊥-elim
(S∉canθ-sigs-E⟦ρΘsigs'⟧-θ←[S]
(canθₛ-mergeˡ-sigs-induction sigs (suc S) sigs' shrs' vars'
r (θ ← [S]-env (S ₛ)) E⟦nothin⟧ cb sigs'≠FV
S S∉sigs' S∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ←[S]))
canθₛₕ-mergeˡ-E-induction : ∀ {E E⟦nothin⟧ BV FV A} sigs' shrs' vars' r θ →
E⟦nothin⟧ ≐ E ⟦ nothin ⟧e →
CorrectBinding E⟦nothin⟧ BV FV →
distinct' (SigMap.keys sigs') (proj₁ FV) →
∀ s' →
s' ∉ ShrMap.keys shrs' →
s' ∈ Canθₛₕ sigs' 0 (E ⟦ r ⟧e) θ →
s' ∈ Canₛₕ (E ⟦ ρ⟨ Θ sigs' shrs' vars' , A ⟩· r ⟧e) θ
canθₛₕ-mergeˡ-E-induction {[]} sigs' shrs' vars' r θ
E⟦nothin⟧ cb sigs'≠FV
s' s'∉shrs' s'∈canθ-sigs'-E⟦r⟧-θ =
set-subtract-notin s'∈canθ-sigs'-E⟦r⟧-θ s'∉shrs'
canθₛₕ-mergeˡ-E-induction {epar₁ q ∷ E} {A = A} sigs' shrs' vars' r θ
(depar₁ E⟦nothin⟧) cb@(CBpar cbp _ _ _ _ _) sigs'≠FV
s' s'∉shrs' s'∈canθ-sigs'-E⟦r⟧-θ
rewrite Env.←-comm Env.[]env θ distinct-empty-left
with canθₛₕ-mergeˡ-E-induction-base-par₁ sigs' 0 r θ Env.[]env (depar₁ E⟦nothin⟧) cb
(subst (distinct' _)
(sym (map-id (SigMap.keys sigs')))
(distinct'-sym sigs'≠FV))
s' s'∈canθ-sigs'-E⟦r⟧-θ
... | inj₁ s'∈canθ'-sigs'-E⟦r⟧-θ←[] =
++ˡ (canθₛₕ-mergeˡ-E-induction sigs' shrs' vars' r (θ ← Env.[]env)
E⟦nothin⟧ cbp (dist'++ˡ sigs'≠FV)
s' s'∉shrs' s'∈canθ'-sigs'-E⟦r⟧-θ←[])
... | inj₂ s'∈can-q-θ←[] =
++ʳ (Canₛₕ (E ⟦ ρ⟨ Θ sigs' shrs' vars' , A ⟩· r ⟧e) (θ ← Env.[]env))
s'∈can-q-θ←[]
canθₛₕ-mergeˡ-E-induction {epar₂ p ∷ E} sigs' shrs' vars' r θ
(depar₂ E⟦nothin⟧) cb@(CBpar {FVp = FVp} _ cbq _ _ _ _) sigs'≠FV
s' s'∉shrs' s'∈canθ-sigs'-E⟦r⟧-θ
rewrite Env.←-comm Env.[]env θ distinct-empty-left
with canθₛₕ-mergeˡ-E-induction-base-par₂ sigs' 0 r θ Env.[]env (depar₂ E⟦nothin⟧) cb
(subst (distinct' _)
(sym (map-id (SigMap.keys sigs')))
(distinct'-sym sigs'≠FV))
s' s'∈canθ-sigs'-E⟦r⟧-θ
... | inj₁ s'∈canθ'-sigs'-E⟦r⟧-θ←[] =
++ʳ (Canₛₕ p (θ ← Env.[]env))
(canθₛₕ-mergeˡ-E-induction sigs' shrs' vars' r (θ ← Env.[]env)
E⟦nothin⟧ cbq (dist'++ʳ {V2 = proj₁ FVp} sigs'≠FV)
s' s'∉shrs' s'∈canθ'-sigs'-E⟦r⟧-θ←[])
... | inj₂ s'∈can-q-θ←[] =
++ˡ s'∈can-q-θ←[]
canθₛₕ-mergeˡ-E-induction {eseq q ∷ E} sigs' shrs' vars' r θ
(deseq E⟦nothin⟧) cb@(CBseq cbp _ _) sigs'≠FV
s' s'∉shrs' s'∈canθ-sigs'-E⟦r⟧-θ
rewrite Env.←-comm Env.[]env θ distinct-empty-left
with canθₛₕ-mergeˡ-E-induction-base-seq sigs' 0 r θ Env.[]env (deseq E⟦nothin⟧) cb
(subst (distinct' _)
(sym (map-id (SigMap.keys sigs')))
(distinct'-sym sigs'≠FV))
s' s'∈canθ-sigs'-E⟦r⟧-θ
canθₛₕ-mergeˡ-E-induction {eseq q ∷ E} {A = A} sigs' shrs' vars' r θ
(deseq E⟦nothin⟧) cb@(CBseq cbp _ _) sigs'≠FV
s' s'∉shrs' s'∈canθ-sigs'-E⟦r⟧-θ
| inj₁ s'∈canθ'-sigs'-E⟦r⟧-θ←[]
with any (Code._≟_ Code.nothin) (Canₖ (E ⟦ ρ⟨ Θ sigs' shrs' vars' , A ⟩· r ⟧e) (θ ← Env.[]env))
... | yes nothin∈can-E⟦ρΘ⟧-θ←[] =
++ˡ (canθₛₕ-mergeˡ-E-induction sigs' shrs' vars' r (θ ← Env.[]env)
E⟦nothin⟧ cbp (dist'++ˡ sigs'≠FV)
s' s'∉shrs' s'∈canθ'-sigs'-E⟦r⟧-θ←[])
... | no nothin∉can-E⟦ρΘ⟧-θ←[] =
canθₛₕ-mergeˡ-E-induction sigs' shrs' vars' r (θ ← Env.[]env)
E⟦nothin⟧ cbp (dist'++ˡ sigs'≠FV)
s' s'∉shrs' s'∈canθ'-sigs'-E⟦r⟧-θ←[]
canθₛₕ-mergeˡ-E-induction {eseq q ∷ E} {A = A} sigs' shrs' vars' r θ
(deseq E⟦nothin⟧) cb@(CBseq cbp _ _) sigs'≠FV
s' s'∉shrs' s'∈canθ-sigs'-E⟦r⟧-θ
| inj₂ (s'∈can-q-θ←[] , nothin∈canθ-sigs'-E⟦r⟧-θ←[])
with any (Code._≟_ Code.nothin) (Canₖ (E ⟦ ρ⟨ Θ sigs' shrs' vars' , A ⟩· r ⟧e) (θ ← Env.[]env))
... | yes nothin∈can-E⟦ρΘ⟧-θ←[] =
++ʳ (Canₛₕ (E ⟦ ρ⟨ Θ sigs' shrs' vars' , A ⟩· r ⟧e) (θ ← Env.[]env))
s'∈can-q-θ←[]
... | no nothin∉can-E⟦ρΘ⟧-θ←[]
rewrite canθₖ-mergeˡ-E-induction {A = A} sigs' shrs' vars' r (θ ← Env.[]env)
E⟦nothin⟧ cbp (dist'++ˡ sigs'≠FV)
= ⊥-elim (nothin∉can-E⟦ρΘ⟧-θ←[] nothin∈canθ-sigs'-E⟦r⟧-θ←[])
canθₛₕ-mergeˡ-E-induction {eloopˢ q ∷ E} sigs' shrs' vars' r θ
(deloopˢ E⟦nothin⟧) cb@(CBloopˢ cbp cbq _ _) sigs'≠FV
s' s'∉shrs' s'∈canθ-sigs'-E⟦r⟧-θ
rewrite unfold sigs' 0 (loopˢ (E ⟦ r ⟧e) q) θ
| sym (unfold sigs' 0 (E ⟦ r ⟧e) θ)
= canθₛₕ-mergeˡ-E-induction sigs' shrs' vars' r θ E⟦nothin⟧ cbp
(dist'++ˡ sigs'≠FV)
s' s'∉shrs' s'∈canθ-sigs'-E⟦r⟧-θ
canθₛₕ-mergeˡ-E-induction {esuspend S ∷ E} sigs' shrs' vars' r θ
(desuspend E⟦nothin⟧) cb@(CBsusp cb' _) sigs'≠FV
s' s'∉shrs' s'∈canθ-sigs'-E⟦r⟧-θ
rewrite unfold sigs' 0 (suspend (E ⟦ r ⟧e) S) θ
| sym (unfold sigs' 0 (E ⟦ r ⟧e) θ)
= canθₛₕ-mergeˡ-E-induction sigs' shrs' vars' r θ E⟦nothin⟧ cb'
(dist'++ʳ {V2 = Signal.unwrap S ∷ []} sigs'≠FV)
s' s'∉shrs' s'∈canθ-sigs'-E⟦r⟧-θ
canθₛₕ-mergeˡ-E-induction {etrap ∷ E} sigs' shrs' vars' r θ
(detrap E⟦nothin⟧) cb@(CBtrap cb') sigs'≠FV
s' s'∉shrs' s'∈canθ-sigs'-E⟦r⟧-θ
rewrite unfold sigs' 0 (trap (E ⟦ r ⟧e)) θ
| canθ'-map-comm (map Code.↓*) sigs' 0 (Can (E ⟦ r ⟧e)) θ
| sym (unfold sigs' 0 (E ⟦ r ⟧e) θ)
= canθₛₕ-mergeˡ-E-induction sigs' shrs' vars' r θ E⟦nothin⟧ cb' sigs'≠FV
s' s'∉shrs' s'∈canθ-sigs'-E⟦r⟧-θ
canθₛₕ-mergeˡ-sigs-induction : ∀ {E E⟦nothin⟧ BV FV A} sigs S sigs' shrs' vars' r θ →
E⟦nothin⟧ ≐ E ⟦ nothin ⟧e →
CorrectBinding E⟦nothin⟧ BV FV →
distinct' (SigMap.keys sigs') (proj₁ FV) →
∀ s' →
s' ∉ ShrMap.keys shrs' →
s' ∈ proj₂ (proj₂ (Canθ' sigs S (Canθ sigs' 0 (E ⟦ r ⟧e)) θ)) →
s' ∈ Canθₛₕ sigs S (E ⟦ ρ⟨ Θ sigs' shrs' vars' , A ⟩· r ⟧e) θ
canθₛₕ-mergeˡ-sigs-induction [] S sigs' shrs' vars' r θ
E⟦nothin⟧ cb sigs'≠FV s' s'∉shrs' s'∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ =
canθₛₕ-mergeˡ-E-induction sigs' shrs' vars'
r θ E⟦nothin⟧ cb sigs'≠FV
s' s'∉shrs' s'∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ
canθₛₕ-mergeˡ-sigs-induction (nothing ∷ sigs) S sigs' shrs' vars' r θ
E⟦nothin⟧ cb sigs'≠FV s' s'∉shrs' s'∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ =
canθₛₕ-mergeˡ-sigs-induction sigs (suc S) sigs' shrs' vars'
r θ E⟦nothin⟧ cb sigs'≠FV
s' s'∉shrs' s'∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ
canθₛₕ-mergeˡ-sigs-induction (just Signal.present ∷ sigs) S sigs' shrs' vars' r θ
E⟦nothin⟧ cb sigs'≠FV s' s'∉shrs' s'∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ =
canθₛₕ-mergeˡ-sigs-induction sigs (suc S) sigs' shrs' vars'
r (θ ← [S]-env-present (S ₛ)) E⟦nothin⟧ cb sigs'≠FV
s' s'∉shrs' s'∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ
canθₛₕ-mergeˡ-sigs-induction (just Signal.absent ∷ sigs) S sigs' shrs' vars' r θ
E⟦nothin⟧ cb sigs'≠FV s' s'∉shrs' s'∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ =
canθₛₕ-mergeˡ-sigs-induction sigs (suc S) sigs' shrs' vars'
r (θ ← [S]-env-absent (S ₛ)) E⟦nothin⟧ cb sigs'≠FV
s' s'∉shrs' s'∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ
canθₛₕ-mergeˡ-sigs-induction {E} {A = A} (just Signal.unknown ∷ sigs) S sigs' shrs' vars' r θ
E⟦nothin⟧ cb sigs'≠FV s' s'∉shrs' s'∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ
with any (_≟_ S) (proj₁
(Canθ' sigs (suc S) (Canθ sigs' 0 (E ⟦ r ⟧e))
(θ ← [S]-env (S ₛ))))
| any (_≟_ S) (proj₁
(Canθ sigs (suc S) (E ⟦ ρ⟨ Θ sigs' shrs' vars' , A ⟩· r ⟧e)
(θ ← [S]-env (S ₛ))))
... | yes S∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ←[S] | yes S∈canθ-sigs-E⟦ρΘsigs'⟧-θ←[S] =
canθₛₕ-mergeˡ-sigs-induction sigs (suc S) sigs' shrs' vars'
r (θ ← [S]-env (S ₛ)) E⟦nothin⟧ cb sigs'≠FV
s' s'∉shrs' s'∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ
... | no S∉canθ'-sigs-canθ-sigs'-E⟦r⟧-θ←[S] | no S∉canθ-sigs-E⟦ρΘsigs'⟧-θ←[S] =
canθₛₕ-mergeˡ-sigs-induction sigs (suc S) sigs' shrs' vars'
r (θ ← [S]-env-absent (S ₛ)) E⟦nothin⟧ cb sigs'≠FV
s' s'∉shrs' s'∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ
... | no S∉canθ'-sigs-canθ-sigs'-E⟦r⟧-θ←[S] | yes S∈canθ-sigs-E⟦ρΘsigs'⟧-θ←[S] =
canθₛₕ-add-sig-monotonic sigs (suc S) (E ⟦ ρ⟨ Θ sigs' shrs' vars' , A ⟩· r ⟧e) θ
(S ₛ) Signal.absent s'
(canθₛₕ-mergeˡ-sigs-induction sigs (suc S) sigs' shrs' vars'
r (θ ← [S]-env-absent (S ₛ)) E⟦nothin⟧ cb sigs'≠FV
s' s'∉shrs' s'∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ)
... | yes S∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ←[S] | no S∉canθ-sigs-E⟦ρΘsigs'⟧-θ←[S]
with any (_≟_ S) (SigMap.keys sigs')
... | yes S∈sigs' =
canθₛₕ-mergeˡ-sigs-induction sigs (suc S) sigs' shrs' vars'
r (θ ← [S]-env-absent (S ₛ)) E⟦nothin⟧ cb sigs'≠FV
s' s'∉shrs'
(subst (s' ∈_)
(cong (proj₂ ∘ proj₂)
(trans
(canθ'-inner-shadowing-irr sigs (suc S) sigs' (E ⟦ r ⟧e)
S Signal.unknown θ S∈sigs')
(sym (canθ'-inner-shadowing-irr sigs (suc S) sigs' (E ⟦ r ⟧e)
S Signal.absent θ S∈sigs'))))
s'∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ)
... | no S∉sigs' =
⊥-elim
(S∉canθ-sigs-E⟦ρΘsigs'⟧-θ←[S]
(canθₛ-mergeˡ-sigs-induction sigs (suc S) sigs' shrs' vars'
r (θ ← [S]-env (S ₛ)) E⟦nothin⟧ cb sigs'≠FV
S S∉sigs' S∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ←[S]))
canθₖ-mergeˡ-E-induction {[]} sigs' shrs' vars' r θ
E⟦nothin⟧ cb sigs'≠FV =
refl
canθₖ-mergeˡ-E-induction {epar₁ q ∷ E} sigs' shrs' vars' r θ
(depar₁ E⟦nothin⟧) cb@(CBpar cbp cbq _ _ _ _) sigs'≠FV
rewrite canθₖ-mergeˡ-E-induction-base-par₁ sigs' 0 r θ
(depar₁ E⟦nothin⟧) cb
(subst (distinct' _)
(sym (map-id (SigMap.keys sigs')))
(distinct'-sym sigs'≠FV))
| canθₖ-mergeˡ-E-induction sigs' shrs' vars' r θ
E⟦nothin⟧ cbp (dist'++ˡ sigs'≠FV)
= refl
canθₖ-mergeˡ-E-induction {epar₂ p ∷ E} sigs' shrs' vars' r θ
(depar₂ E⟦nothin⟧) cb@(CBpar {FVp = FVp} cbp cbq _ _ _ _) sigs'≠FV
rewrite canθₖ-mergeˡ-E-induction-base-par₂ sigs' 0 r θ
(depar₂ E⟦nothin⟧) cb
(subst (distinct' _)
(sym (map-id (SigMap.keys sigs')))
(distinct'-sym sigs'≠FV))
| canθₖ-mergeˡ-E-induction sigs' shrs' vars' r θ
E⟦nothin⟧ cbq (dist'++ʳ {V2 = proj₁ FVp} sigs'≠FV)
= refl
canθₖ-mergeˡ-E-induction {eseq q ∷ E} {A = A} sigs' shrs' vars' r θ
(deseq E⟦nothin⟧) cb@(CBseq cbp cbq _) sigs'≠FV
with any (Code._≟_ Code.nothin) (Canₖ (E ⟦ ρ⟨ Θ sigs' shrs' vars' , A ⟩· r ⟧e) θ)
... | no nothin∉can-E⟦ρΘ⟧-θ
rewrite sym (canθₖ-mergeˡ-E-induction {A = A} sigs' shrs' vars' r θ
E⟦nothin⟧ cbp (dist'++ˡ sigs'≠FV))
| canθₖ-mergeˡ-E-induction-base-seq-notin sigs' 0 r θ
(deseq E⟦nothin⟧) cb
(subst (distinct' _)
(sym (map-id (SigMap.keys sigs')))
(distinct'-sym sigs'≠FV))
nothin∉can-E⟦ρΘ⟧-θ
= refl
... | yes nothin∈can-E⟦ρΘ⟧-θ
rewrite sym (canθₖ-mergeˡ-E-induction {A = A} sigs' shrs' vars' r θ
E⟦nothin⟧ cbp (dist'++ˡ sigs'≠FV))
| canθₖ-mergeˡ-E-induction-base-seq-in sigs' 0 r θ
(deseq E⟦nothin⟧) cb
(subst (distinct' _)
(sym (map-id (SigMap.keys sigs')))
(distinct'-sym sigs'≠FV))
nothin∈can-E⟦ρΘ⟧-θ
= refl
canθₖ-mergeˡ-E-induction {eloopˢ q ∷ E} {A = A} sigs' shrs' vars' r θ
(deloopˢ E⟦nothin⟧) cb@(CBloopˢ cbp cbq _ _) sigs'≠FV
rewrite sym (canθₖ-mergeˡ-E-induction {A = A} sigs' shrs' vars' r θ
E⟦nothin⟧ cbp (dist'++ˡ sigs'≠FV))
| unfold sigs' 0 (loopˢ (E ⟦ r ⟧e) q) θ
| unfold sigs' 0 (E ⟦ r ⟧e) θ
= refl
canθₖ-mergeˡ-E-induction {esuspend S ∷ E} {A = A} sigs' shrs' vars' r θ
(desuspend E⟦nothin⟧) cb@(CBsusp cb' _) sigs'≠FV
rewrite sym (canθₖ-mergeˡ-E-induction {A = A} sigs' shrs' vars' r θ
E⟦nothin⟧ cb' (dist'++ʳ {V2 = Signal.unwrap S ∷ []} sigs'≠FV))
| unfold sigs' 0 (suspend (E ⟦ r ⟧e) S) θ
| unfold sigs' 0 (E ⟦ r ⟧e) θ
= refl
canθₖ-mergeˡ-E-induction {etrap ∷ E} {A = A} sigs' shrs' vars' r θ
(detrap E⟦nothin⟧) cb@(CBtrap cb') sigs'≠FV
rewrite sym (canθₖ-mergeˡ-E-induction {A = A} sigs' shrs' vars' r θ E⟦nothin⟧ cb' sigs'≠FV)
| unfold sigs' 0 (trap (E ⟦ r ⟧e)) θ
| unfold sigs' 0 (E ⟦ r ⟧e) θ
| canθ'-map-comm (map Code.↓*) sigs' 0 (Can (E ⟦ r ⟧e)) θ
= refl
canθₖ-mergeˡ-sigs-induction {A = A} [] S sigs' shrs' vars' r θ
E⟦nothin⟧ cb sigs'≠FV k k∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ
rewrite canθₖ-mergeˡ-E-induction {A = A} sigs' shrs' vars'
r θ E⟦nothin⟧ cb sigs'≠FV
= k∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ
canθₖ-mergeˡ-sigs-induction (nothing ∷ sigs) S sigs' shrs' vars' r θ
E⟦nothin⟧ cb sigs'≠FV k k∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ =
canθₖ-mergeˡ-sigs-induction sigs (suc S) sigs' shrs' vars'
r θ E⟦nothin⟧ cb sigs'≠FV
k k∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ
canθₖ-mergeˡ-sigs-induction (just Signal.present ∷ sigs) S sigs' shrs' vars' r θ
E⟦nothin⟧ cb sigs'≠FV k k∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ =
canθₖ-mergeˡ-sigs-induction sigs (suc S) sigs' shrs' vars'
r (θ ← [S]-env-present (S ₛ)) E⟦nothin⟧ cb sigs'≠FV
k k∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ
canθₖ-mergeˡ-sigs-induction (just Signal.absent ∷ sigs) S sigs' shrs' vars' r θ
E⟦nothin⟧ cb sigs'≠FV k k∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ =
canθₖ-mergeˡ-sigs-induction sigs (suc S) sigs' shrs' vars'
r (θ ← [S]-env-absent (S ₛ)) E⟦nothin⟧ cb sigs'≠FV
k k∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ
canθₖ-mergeˡ-sigs-induction {E} {A = A} (just Signal.unknown ∷ sigs) S sigs' shrs' vars' r θ
E⟦nothin⟧ cb sigs'≠FV k k∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ
with any (_≟_ S) (proj₁
(Canθ' sigs (suc S) (Canθ sigs' 0 (E ⟦ r ⟧e))
(θ ← [S]-env (S ₛ))))
| any (_≟_ S) (proj₁
(Canθ sigs (suc S) (E ⟦ ρ⟨ Θ sigs' shrs' vars' , A ⟩· r ⟧e)
(θ ← [S]-env (S ₛ))))
... | yes S∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ←[S] | yes S∈canθ-sigs-E⟦ρΘsigs'⟧-θ←[S] =
canθₖ-mergeˡ-sigs-induction sigs (suc S) sigs' shrs' vars'
r (θ ← [S]-env (S ₛ)) E⟦nothin⟧ cb sigs'≠FV
k k∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ
... | no S∉canθ'-sigs-canθ-sigs'-E⟦r⟧-θ←[S] | no S∉canθ-sigs-E⟦ρΘsigs'⟧-θ←[S] =
canθₖ-mergeˡ-sigs-induction sigs (suc S) sigs' shrs' vars'
r (θ ← [S]-env-absent (S ₛ)) E⟦nothin⟧ cb sigs'≠FV
k k∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ
... | no S∉canθ'-sigs-canθ-sigs'-E⟦r⟧-θ←[S] | yes S∈canθ-sigs-E⟦ρΘsigs'⟧-θ←[S] =
canθₖ-add-sig-monotonic sigs (suc S) (E ⟦ ρ⟨ Θ sigs' shrs' vars' , A ⟩· r ⟧e) θ
(S ₛ) Signal.absent k
(canθₖ-mergeˡ-sigs-induction sigs (suc S) sigs' shrs' vars'
r (θ ← [S]-env-absent (S ₛ)) E⟦nothin⟧ cb sigs'≠FV
k k∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ)
... | yes S∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ←[S] | no S∉canθ-sigs-E⟦ρΘsigs'⟧-θ←[S]
with any (_≟_ S) (SigMap.keys sigs')
... | yes S∈sigs' =
canθₖ-mergeˡ-sigs-induction sigs (suc S) sigs' shrs' vars'
r (θ ← [S]-env-absent (S ₛ)) E⟦nothin⟧ cb sigs'≠FV
k
(subst (k ∈_)
(cong (proj₁ ∘ proj₂)
(trans
(canθ'-inner-shadowing-irr sigs (suc S) sigs' (E ⟦ r ⟧e)
S Signal.unknown θ S∈sigs')
(sym (canθ'-inner-shadowing-irr sigs (suc S) sigs' (E ⟦ r ⟧e)
S Signal.absent θ S∈sigs'))))
k∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ)
... | no S∉sigs' =
⊥-elim
(S∉canθ-sigs-E⟦ρΘsigs'⟧-θ←[S]
(canθₛ-mergeˡ-sigs-induction sigs (suc S) sigs' shrs' vars'
r (θ ← [S]-env (S ₛ)) E⟦nothin⟧ cb sigs'≠FV
S S∉sigs' S∈canθ'-sigs-canθ-sigs'-E⟦r⟧-θ←[S]))
|
{
"alphanum_fraction": 0.5742816308,
"avg_line_length": 46.1597222222,
"ext": "agda",
"hexsha": "86ed74f1deb0dc549594c891841460a050850f3d",
"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/Lang/CanFunction/MergePotentialRuleLeftInductive.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/Lang/CanFunction/MergePotentialRuleLeftInductive.agda",
"max_line_length": 97,
"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/Lang/CanFunction/MergePotentialRuleLeftInductive.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": 13686,
"size": 26588
}
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.DStructures.Equivalences.PreXModReflGraph where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.Structure
open import Cubical.Functions.FunExtEquiv
open import Cubical.Homotopy.Base
open import Cubical.Data.Sigma
open import Cubical.Data.Unit
open import Cubical.Relation.Binary
open import Cubical.Structures.Subtype
open import Cubical.Algebra.Group
open import Cubical.Structures.LeftAction
open import Cubical.Algebra.Group.Semidirect
open import Cubical.DStructures.Base
open import Cubical.DStructures.Meta.Properties
open import Cubical.DStructures.Meta.Isomorphism
open import Cubical.DStructures.Structures.Constant
open import Cubical.DStructures.Structures.Type
open import Cubical.DStructures.Structures.Group
open import Cubical.DStructures.Structures.SplitEpi
open import Cubical.DStructures.Structures.ReflGraph
open import Cubical.DStructures.Structures.Action
open import Cubical.DStructures.Structures.XModule
open import Cubical.DStructures.Equivalences.GroupSplitEpiAction
private
variable
ℓ ℓ' ℓ'' ℓ₁ ℓ₁' ℓ₁'' ℓ₂ ℓA ℓA' ℓ≅A ℓ≅A' ℓB ℓB' ℓ≅B ℓC ℓ≅C ℓ≅ᴰ ℓ≅ᴰ' ℓ≅B' : Level
open Kernel
open GroupHom -- such .fun!
open GroupLemmas
open MorphismLemmas
open ActionLemmas
{-
After associating, we have
B × isEqui - B × isSecRet
| / |
| / |
Action ≃ SplitMono
Fix any action and its
corresponding split mono
α π₂
G₀ --> H ↦ G₀ ↔ H ⋊⟨ α ⟩ G₀
ι₂
Precrossed module
α : G₀ --> H
φ : G₀ ← H
isEquivariant (α , φ)
gives internal reflexive graph
ι₂ : G₀ → H⋊⟨ α ⟩ G₀
G₀ ← H⋊⟨ α ⟩ G₀ : π₂
G₀ ← H⋊⟨ α ⟩ G₀ : τ_φ
τ_φ (h , g) := φ h + g
isSecRet (ι₂ , π₂)
isSecRet (ι₂ , τ_φ)
Conversely, a internal reflexive graph
ι₂ : G₀ → H⋊⟨ α ⟩ G₀
G₀ ← H⋊⟨ α ⟩ G₀ : π₂
G₀ ← H⋊⟨ α ⟩ G₀ : τ
isSecRet (ι₂ , π₂)
isSecRet (ι₂ , τ)
Then
ι₁ : H ≃ ker σ ↪ H ⋊⟨ α ⟩ G₀
α : G₀ --> H
G₀ ← H : φ
φ := τ ∘ ι₁ is equivariant
-}
module _ (ℓ ℓ' : Level) where
private
ℓℓ' = ℓ-max ℓ ℓ'
F = Iso.fun (IsoActionSplitEpi ℓ ℓℓ')
-- reassociate: Display B + isSplitEpi over SplitEpi
ReflGraph' = Σ[ (((G₀ , G₁) , (ι , σ)) , split-σ) ∈ SplitEpi ℓ ℓℓ' ] Σ[ τ ∈ GroupHom G₁ G₀ ] isGroupSplitEpi ι τ
𝒮ᴰ-ReflGraph' : URGStrᴰ (𝒮-SplitEpi ℓ ℓℓ')
(λ (((G₀ , G₁) , (ι , σ)) , split-σ) → Σ[ τ ∈ GroupHom G₁ G₀ ] isGroupSplitEpi ι τ)
ℓℓ'
𝒮ᴰ-ReflGraph' = splitTotal-𝒮ᴰ (𝒮-SplitEpi ℓ ℓℓ') (𝒮ᴰ-G²FBSplit\B ℓ ℓℓ') (𝒮ᴰ-ReflGraph ℓ ℓℓ')
-- reassociate: Display B + isEquivar over Action
PreXModule' = Σ[ (((G₀ , H) , _α_) , isAct) ∈ Action ℓ ℓℓ' ] Σ[ φ ∈ GroupHom H G₀ ] (isEquivariant (((G₀ , H) , _α_) , isAct) φ)
𝒮ᴰ-PreXModule' : URGStrᴰ (𝒮-Action ℓ ℓℓ')
(λ (((G₀ , H) , _α_) , isAct) → Σ[ φ ∈ GroupHom H G₀ ] (isEquivariant (((G₀ , H) , _α_) , isAct) φ))
ℓℓ'
𝒮ᴰ-PreXModule' = splitTotal-𝒮ᴰ (𝒮-Action ℓ ℓℓ') (𝒮ᴰ-Action\PreXModuleStr ℓ ℓℓ') (𝒮ᴰ-PreXModule ℓ ℓℓ')
-- Establish ♭-relational isomorphism of precrossed modules and reflexive graphs
-- over the isomorphism of actions and split epis
𝒮ᴰ-♭PIso-PreXModule'-ReflGraph' : 𝒮ᴰ-♭PIso F 𝒮ᴰ-PreXModule' 𝒮ᴰ-ReflGraph'
RelIso.fun (𝒮ᴰ-♭PIso-PreXModule'-ReflGraph' (((G₀ , H) , _α_) , isAct)) (φ , isEqui) .fst = τ
where
-- notation
open GroupNotation₀ G₀
open GroupNotationᴴ H
f = GroupHom.fun φ
A = groupaction _α_ isAct
H⋊G₀ : Group {ℓ-max ℓ ℓ'}
H⋊G₀ = H ⋊⟨ A ⟩ G₀
-- define the morphism τ
τ : GroupHom H⋊G₀ G₀
τ .fun (h , g) = f h +₀ g
τ .isHom (h , g) (h' , g') = q
where
abstract
q = f (h +ᴴ (g α h')) +₀ (g +₀ g')
≡⟨ cong (_+₀ (g +₀ g')) (φ .isHom h (g α h')) ⟩
(f h +₀ f (g α h')) +₀ (g +₀ g')
≡⟨ cong (λ z → (f h +₀ z) +₀ (g +₀ g')) (isEqui g h') ⟩
(f h +₀ ((g +₀ (f h')) -₀ g)) +₀ (g +₀ g')
≡⟨ cong (λ z → (f h +₀ z) +₀ (g +₀ g') ) (sym (assoc₀ g (f h') (-₀ g))) ⟩
(f h +₀ (g +₀ (f h' +₀ (-₀ g)))) +₀ (g +₀ g')
≡⟨ cong (_+₀ (g +₀ g')) (assoc₀ (f h) g (f h' +₀ (-₀ g))) ⟩
((f h +₀ g) +₀ (f h' +₀ (-₀ g))) +₀ (g +₀ g')
≡⟨ sym (assoc₀ (f h +₀ g) (f h' +₀ (-₀ g)) (g +₀ g')) ⟩
(f h +₀ g) +₀ ((f h' +₀ (-₀ g)) +₀ (g +₀ g'))
≡⟨ cong ((f h +₀ g) +₀_)
(sym (assoc₀ (f h') (-₀ g) (g +₀ g'))
∙ (cong (f h' +₀_)
(assoc₀ (-₀ g) g g'
∙∙ cong (_+₀ g') (lCancel₀ g)
∙∙ lId₀ g')))⟩
(f h +₀ g) +₀ (f h' +₀ g') ∎
RelIso.fun (𝒮ᴰ-♭PIso-PreXModule'-ReflGraph' (((G₀ , H) , _α_) , isAct)) (φ , isEqui) .snd = q
where
-- notation
open GroupNotation₀ G₀
open GroupNotationᴴ H
f = GroupHom.fun φ
τ = RelIso.fun (𝒮ᴰ-♭PIso-PreXModule'-ReflGraph' (((G₀ , H) , _α_) , isAct)) (φ , isEqui) .fst
ι = Iso.fun (IsoActionSplitEpi ℓ ℓℓ') (((G₀ , H) , _α_) , isAct) .fst .snd .fst
-- prove that τ as constructed above is split
abstract
q : isGroupSplitEpi ι τ
q = GroupMorphismExt λ g → f 0ᴴ +₀ g
≡⟨ cong (_+₀ g) (mapId φ) ⟩
0₀ +₀ g
≡⟨ lId₀ g ⟩
g ∎
-- end of RelIso.fun (𝒮ᴰ-♭PIso-PreXModule'-ReflGraph' (((G₀ , H) , _α_) , isAct)) (φ , isEqui)
RelIso.inv (𝒮ᴰ-♭PIso-PreXModule'-ReflGraph' (((G₀ , H) , _α_) , isAct)) (τ , split-τ) = φ , isEqui
where
-- notation
ℬ = F (((G₀ , H) , _α_) , isAct)
A = groupaction _α_ isAct
-- σ = snd (snd (fst ℬ))
-- φ should be τ| ker σ
-- but ker σ ≅ H so we "restrict" τ to that
-- by precomposing with the inclusion H → H⋊G₀
ι1 = ι₁ A
𝒾 = ι1 .fun
t = τ .fun
H⋊G₀ = H ⋊⟨ A ⟩ G₀
_+α_ = GroupStr._+_ (snd H⋊G₀)
open GroupNotationᴴ H
open GroupNotation₀ G₀
-- define φ
φ : GroupHom H G₀
φ = compGroupHom ι1 τ
f = φ .fun
-- prove equivariance
abstract
isEqui : isEquivariant (((G₀ , H) , _α_) , isAct) φ
isEqui g h = f (g α h)
≡⟨ refl ⟩
t (g α h , 0₀)
≡⟨ cong t
(g α h , 0₀
≡⟨ ΣPathP (sym ((cong (_+ᴴ ((g +₀ 0₀) α 0ᴴ)) (lIdᴴ (g α h)))
∙∙ cong ((g α h) +ᴴ_) (actOnUnit A (g +₀ 0₀))
∙∙ rIdᴴ (g α h))
, sym (cong (_+₀ (-₀ g)) (rId₀ g) ∙ rCancel₀ g)) ⟩
(0ᴴ +ᴴ (g α h)) +ᴴ ((g +₀ 0₀) α 0ᴴ) , (g +₀ 0₀) -₀ g
≡⟨ refl ⟩
((0ᴴ , g) +α (h , 0₀)) +α (0ᴴ , -₀ g) ∎) ⟩
t (((0ᴴ , g) +α (h , 0₀)) +α (0ᴴ , -₀ g))
≡⟨ hom-homl τ (0ᴴ , g) (h , 0₀) (0ᴴ , -₀ g) ⟩
((t (0ᴴ , g)) +₀ t (h , 0₀)) +₀ t (0ᴴ , -₀ g)
≡⟨ cong (((t (0ᴴ , g)) +₀ t (h , 0₀)) +₀_) (funExt⁻ (cong fun split-τ) (-₀ g)) ⟩
((t (0ᴴ , g)) +₀ t (h , 0₀)) -₀ g
≡⟨ cong (λ z → (z +₀ t (h , 0₀)) -₀ g) (funExt⁻ (cong fun split-τ) g) ⟩
(g +₀ f h) -₀ g ∎
-- RelIso.inv (𝒮ᴰ-♭PIso-PreXModule'-ReflGraph' (((G₀ , H) , _α_) , isAct)) (τ , split-τ)
RelIso.leftInv (𝒮ᴰ-♭PIso-PreXModule'-ReflGraph' (((G₀ , H) , _α_) , isAct)) (φ , isEqui) .fst = φ-≅
where
open GroupNotation₀ G₀
abstract
-- φ ≅ inv (fun φ) ≡ τ ∘ ι₁
φ-≅ : (h : ⟨ H ⟩) → φ .fun h +₀ 0₀ ≡ φ .fun h
φ-≅ h = rId₀ (φ .fun h)
RelIso.leftInv (𝒮ᴰ-♭PIso-PreXModule'-ReflGraph' (((G₀ , H) , _α_) , isAct)) (φ , isEqui) .snd = isEqui-≅
where
abstract
isEqui-≅ : Unit
isEqui-≅ = tt
-- end of RelIso.leftInv (𝒮ᴰ-♭PIso-PreXModule'-ReflGraph' (((G₀ , H) , _α_) , isAct)) (φ , isEqui)
RelIso.rightInv (𝒮ᴰ-♭PIso-PreXModule'-ReflGraph' (((G₀ , H) , _α_) , isAct)) (τ , split-τ) .fst = τ-≅
where
A = groupaction _α_ isAct
H⋊G₀ = H ⋊⟨ A ⟩ G₀
t = τ .fun
open GroupNotation₀ G₀
open GroupNotationᴴ H
abstract
τ-≅ : ((h , g) : ⟨ H⋊G₀ ⟩) → t (h , 0₀) +₀ g ≡ t (h , g)
τ-≅ (h , g) = t (h , 0₀) +₀ g
≡⟨ cong (t (h , 0₀) +₀_) (sym (funExt⁻ (cong GroupHom.fun split-τ) g)) ⟩
t (h , 0₀) +₀ t (0ᴴ , g)
≡⟨ sym (τ .isHom (h , 0₀) (0ᴴ , g)) ⟩
t (h +ᴴ (0₀ α 0ᴴ) , 0₀ +₀ g)
≡⟨ cong t (ΣPathP (cong (h +ᴴ_) (actOnUnit A 0₀) ∙ rIdᴴ h , lId₀ g)) ⟩
t (h , g) ∎
RelIso.rightInv (𝒮ᴰ-♭PIso-PreXModule'-ReflGraph' (((G₀ , H) , _α_) , isAct)) (τ , split-τ) .snd = split-τ-≅
where
abstract
split-τ-≅ : Unit
split-τ-≅ = tt
-- end of RelIso.rightInv (𝒮ᴰ-♭PIso-PreXModule'-ReflGraph' (((G₀ , H) , _α_) , isAct)) (τ , split-τ)
-- end of 𝒮ᴰ-♭PIso-PreXModule'-ReflGraph' : 𝒮ᴰ-♭PIso F 𝒮ᴰ-PreXModule' 𝒮ᴰ-ReflGraph'
-- turn the ♭-relational isomorphism into a (normal) iso
Iso-PreXModule-ReflGraph' : Iso PreXModule' ReflGraph'
Iso-PreXModule-ReflGraph' = 𝒮ᴰ-♭PIso-Over→TotalIso (IsoActionSplitEpi ℓ ℓℓ') 𝒮ᴰ-PreXModule' 𝒮ᴰ-ReflGraph' 𝒮ᴰ-♭PIso-PreXModule'-ReflGraph'
-- reassociate on both sides
Iso-PreXModule-ReflGraph : Iso (PreXModule ℓ ℓℓ') (ReflGraph ℓ ℓℓ')
Iso-PreXModule-ReflGraph = compIso (compIso Σ-assoc-Iso
Iso-PreXModule-ReflGraph')
(invIso Σ-assoc-Iso)
|
{
"alphanum_fraction": 0.4953151198,
"avg_line_length": 35.5754385965,
"ext": "agda",
"hexsha": "c2d15e6f95f52bde87bba02899ef6dfb50595209",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Schippmunk/cubical",
"max_forks_repo_path": "Cubical/DStructures/Equivalences/PreXModReflGraph.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Schippmunk/cubical",
"max_issues_repo_path": "Cubical/DStructures/Equivalences/PreXModReflGraph.agda",
"max_line_length": 139,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Schippmunk/cubical",
"max_stars_repo_path": "Cubical/DStructures/Equivalences/PreXModReflGraph.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 4211,
"size": 10139
}
|
------------------------------------------------------------------------
-- Well-typed polymorphic and iso-recursive lambda terms
------------------------------------------------------------------------
module SystemF.WtTerm where
import Category.Functor as Functor
import Category.Applicative.Indexed as Applicative
open Functor.Morphism using (op-<$>)
open import Data.Fin using (Fin; zero; suc; inject+)
open import Data.Fin.Substitution
open import Data.Fin.Substitution.Lemmas
open import Data.List using (List; _∷_)
open import Data.List.All using (All; []; _∷_)
open import Data.Nat using (zero; suc; ℕ; _+_)
open import Data.Product using (_,_)
open import Data.Vec using (Vec; []; _∷_; _++_; lookup; map; toList; zip)
open import Data.Vec.Properties
using (map-∘; map-cong; lookup-++-inject+)
open import Data.Vec.Categorical
using (lookup-functor-morphism)
open import Function as Fun using (_∘_)
open import Relation.Binary.PropositionalEquality as PropEq
using (_≡_; refl; cong; cong₂; subst; sym)
open PropEq.≡-Reasoning
open import Relation.Nullary using (¬_)
open import SystemF.Type
open import SystemF.Term
------------------------------------------------------------------------
-- Typing derivations for polymorphic and iso-recursive lambda terms
-- Typing contexts mapping free (term) variables to types. A context
-- of type Ctx m n maps m free variables to types containing up to n
-- free type variables each.
Ctx : ℕ → ℕ → Set
Ctx m n = Vec (Type n) m
-- Type and variable substitutions lifted to typing contexts
module CtxSubst where
infixl 8 _/_ _/Var_
-- Type substitution lifted to typing contexts
_/_ : ∀ {m n k} → Ctx m n → Sub Type n k → Ctx m k
Γ / σ = Γ TypeSubst.⊙ σ
-- Weakening of typing contexts with additional type variables
weaken : ∀ {m n} → Ctx m n → Ctx m (1 + n)
weaken Γ = map TypeSubst.weaken Γ
-- Variable substitution (renaming) lifted to typing contexts
_/Var_ : ∀ {m n k} → Sub Fin m k → Ctx k n → Ctx m n
σ /Var Γ = map (λ x → lookup Γ x) σ
open TypeSubst using () renaming (_[/_] to _[/tp_])
open CtxSubst using () renaming (weaken to weakenCtx)
infix 4 _⊢_∈_ _⊢_∉_ _⊢val_∈_ _⊢ⁿ_∈_
infixl 9 _·_ _[_]
-- Typing derivations for well-typed terms
data _⊢_∈_ {m n} (Γ : Ctx m n) : Term m n → Type n → Set where
var : (x : Fin m) → Γ ⊢ var x ∈ lookup Γ x
Λ : ∀ {t a} → (weakenCtx Γ) ⊢ t ∈ a → Γ ⊢ Λ t ∈ ∀' a
λ' : ∀ {t b} → (a : Type n) → a ∷ Γ ⊢ t ∈ b → Γ ⊢ λ' a t ∈ a →' b
μ : ∀ {t} → (a : Type n) → a ∷ Γ ⊢ t ∈ a → Γ ⊢ μ a t ∈ a
_[_] : ∀ {t a} → Γ ⊢ t ∈ ∀' a → (b : Type n) → Γ ⊢ t [ b ] ∈ a [/tp b ]
_·_ : ∀ {s t a b} → Γ ⊢ s ∈ a →' b → Γ ⊢ t ∈ a → Γ ⊢ s · t ∈ b
fold : ∀ {t} → (a : Type (1 + n)) → Γ ⊢ t ∈ a [/tp μ a ] →
Γ ⊢ fold a t ∈ μ a
unfold : ∀ {t} → (a : Type (1 + n)) → Γ ⊢ t ∈ μ a →
Γ ⊢ unfold a t ∈ a [/tp μ a ]
-- Negation of well-typedness.
_⊢_∉_ : ∀ {m n} → Ctx m n → Term m n → Type n → Set
Γ ⊢ t ∉ a = ¬ Γ ⊢ t ∈ a
-- Typing derivations for well-typed values.
data _⊢val_∈_ {m n} (Γ : Ctx m n) : Val m n → Type n → Set where
Λ : ∀ {t a} → (weakenCtx Γ) ⊢ t ∈ a → Γ ⊢val Λ t ∈ ∀' a
λ' : ∀ {t b} → (a : Type n) → a ∷ Γ ⊢ t ∈ b → Γ ⊢val λ' a t ∈ a →' b
fold : ∀ {v} → (a : Type (1 + n)) → Γ ⊢val v ∈ a [/tp μ a ] →
Γ ⊢val fold a v ∈ μ a
-- Conversion from well-typed values to well-typed terms.
⊢⌜_⌝ : ∀ {m n} {Γ : Ctx m n} {v a} → Γ ⊢val v ∈ a → Γ ⊢ ⌜ v ⌝ ∈ a
⊢⌜ Λ x ⌝ = Λ x
⊢⌜ λ' a t ⌝ = λ' a t
⊢⌜ fold a t ⌝ = fold a ⊢⌜ t ⌝
-- Collections of typing derivations for well-typed terms.
data _⊢ⁿ_∈_ {m n} (Γ : Ctx m n) :
∀ {k} → Vec (Term m n) k → Vec (Type n) k → Set where
[] : Γ ⊢ⁿ [] ∈ []
_∷_ : ∀ {t a k} {ts : Vec (Term m n) k} {as : Vec (Type n) k} →
Γ ⊢ t ∈ a → Γ ⊢ⁿ ts ∈ as → Γ ⊢ⁿ t ∷ ts ∈ a ∷ as
-- Lookup a well-typed term in a collection thereof.
lookup-⊢ : ∀ {m n k} {Γ : Ctx m n} {ts : Vec (Term m n) k}
{as : Vec (Type n) k} →
(x : Fin k) → Γ ⊢ⁿ ts ∈ as → Γ ⊢ lookup ts x ∈ lookup as x
lookup-⊢ zero (⊢t ∷ ⊢ts) = ⊢t
lookup-⊢ (suc x) (⊢t ∷ ⊢ts) = lookup-⊢ x ⊢ts
------------------------------------------------------------------------
-- Lemmas about type and variable substitutions (renaming) lifted to
-- typing contexts
module CtxLemmas where
open CtxSubst public
private module Tp = TypeLemmas
private module Var = VarSubst
-- Term variable substitution (renaming) commutes with type
-- substitution.
/Var-/ : ∀ {m n k l} (ρ : Sub Fin m k) (Γ : Ctx k n) (σ : Sub Type n l) →
(ρ /Var Γ) / σ ≡ ρ /Var (Γ / σ)
/Var-/ ρ Γ σ = begin
(ρ /Var Γ) / σ
≡⟨ sym (map-∘ _ _ ρ) ⟩
map (λ x → (lookup Γ x) Tp./ σ) ρ
≡⟨ map-cong (λ x → sym (Tp.lookup-⊙ x {ρ₁ = Γ})) ρ ⟩
map (λ x → lookup (Γ / σ) x) ρ
∎
-- Term variable substitution (renaming) commutes with weakening of
-- typing contexts with an additional type variable.
/Var-weaken : ∀ {m n k} (ρ : Sub Fin m k) (Γ : Ctx k n) →
weaken (ρ /Var Γ) ≡ ρ /Var (weaken Γ)
/Var-weaken ρ Γ = begin
weaken (ρ /Var Γ) ≡⟨ Tp.map-weaken ⟩
(ρ /Var Γ) / Tp.wk ≡⟨ /Var-/ ρ Γ Tp.wk ⟩
ρ /Var (Γ / Tp.wk) ≡⟨ sym (cong (_/Var_ ρ) (Tp.map-weaken {ρ = Γ})) ⟩
ρ /Var (weaken Γ) ∎
-- Term variable substitution (renaming) commutes with term variable
-- lookup in typing context.
/Var-lookup : ∀ {m n k} (x : Fin m) (ρ : Sub Fin m k) (Γ : Ctx k n) →
lookup (ρ /Var Γ) x ≡ lookup Γ (lookup ρ x)
/Var-lookup x ρ Γ = op-<$> (lookup-functor-morphism x) (λ x → lookup Γ x) ρ
-- Term variable substitution (renaming) commutes with weakening of
-- typing contexts with an additional term variable.
/Var-∷ : ∀ {m n k} (a : Type n) (ρ : Sub Fin m k) (Γ : Ctx k n) →
a ∷ (ρ /Var Γ) ≡ (ρ Var.↑) /Var (a ∷ Γ)
/Var-∷ a [] Γ = refl
/Var-∷ a (x ∷ ρ) Γ = cong (_∷_ a) (cong (_∷_ (lookup Γ x)) (begin
map (λ x → lookup Γ x) ρ ≡⟨ refl ⟩
map (λ x → lookup (a ∷ Γ) (suc x)) ρ ≡⟨ map-∘ _ _ ρ ⟩
map (λ x → lookup (a ∷ Γ) x) (map suc ρ) ∎))
-- Invariants of term variable substitution (renaming)
idVar-/Var : ∀ {m n} (Γ : Ctx m n) → Γ ≡ (Var.id /Var Γ)
wkVar-/Var-∷ : ∀ {m n} (Γ : Ctx m n) (a : Type n) → Γ ≡ (Var.wk /Var (a ∷ Γ))
idVar-/Var [] = refl
idVar-/Var (a ∷ Γ) = cong (_∷_ a) (wkVar-/Var-∷ Γ a)
wkVar-/Var-∷ Γ a = begin
Γ ≡⟨ idVar-/Var Γ ⟩
Var.id /Var Γ ≡⟨ map-∘ _ _ VarSubst.id ⟩
Var.wk /Var (a ∷ Γ) ∎
------------------------------------------------------------------------
-- Substitutions in well-typed terms
-- Helper lemmas for applying type and term equalities in typing
-- derivations
⊢subst : ∀ {m n} {Γ₁ Γ₂ : Ctx m n} {t₁ t₂ : Term m n} {a₁ a₂ : Type n} →
Γ₁ ≡ Γ₂ → t₁ ≡ t₂ → a₁ ≡ a₂ → Γ₁ ⊢ t₁ ∈ a₁ → Γ₂ ⊢ t₂ ∈ a₂
⊢subst refl refl refl hyp = hyp
⊢substCtx : ∀ {m n} {Γ₁ Γ₂ : Ctx m n} {t : Term m n} {a : Type n} →
Γ₁ ≡ Γ₂ → Γ₁ ⊢ t ∈ a → Γ₂ ⊢ t ∈ a
⊢substCtx refl hyp = hyp
⊢substTp : ∀ {m n} {Γ : Ctx m n} {t : Term m n} {a₁ a₂ : Type n} →
a₁ ≡ a₂ → Γ ⊢ t ∈ a₁ → Γ ⊢ t ∈ a₂
⊢substTp refl hyp = hyp
-- Type substitutions lifted to well-typed terms
module WtTermTypeSubst where
open TypeLemmas hiding (_/_; _[/_]; weaken)
private
module Tp = TypeLemmas
module Tm = TermTypeLemmas
module C = CtxSubst
infixl 8 _/_
-- Type substitutions lifted to well-typed terms
_/_ : ∀ {m n k} {Γ : Ctx m n} {t : Term m n} {a : Type n} →
Γ ⊢ t ∈ a → (σ : Sub Type n k) → Γ C./ σ ⊢ t Tm./ σ ∈ a Tp./ σ
_/_ {Γ = Γ} (var x) σ = ⊢substTp (lookup-⊙ x {ρ₁ = Γ}) (var x)
_/_ {Γ = Γ} (Λ ⊢t) σ =
Λ (⊢substCtx (sym (map-weaken-⊙ Γ σ)) (⊢t / σ ↑))
λ' a ⊢t / σ = λ' (a Tp./ σ) (⊢t / σ)
μ a ⊢t / σ = μ (a Tp./ σ) (⊢t / σ)
_[_] {a = a} ⊢t b / σ =
⊢substTp (sym (sub-commutes a)) ((⊢t / σ) [ b Tp./ σ ])
⊢s · ⊢t / σ = (⊢s / σ) · (⊢t / σ)
fold a ⊢t / σ =
fold (a Tp./ σ ↑) (⊢substTp (sub-commutes a) (⊢t / σ))
unfold a ⊢t / σ =
⊢substTp (sym (sub-commutes a)) (unfold (a Tp./ σ ↑) (⊢t / σ))
-- Weakening of terms with additional type variables lifted to
-- well-typed terms.
weaken : ∀ {m n} {Γ : Ctx m n} {t : Term m n} {a : Type n} →
Γ ⊢ t ∈ a → C.weaken Γ ⊢ Tm.weaken t ∈ Tp.weaken a
weaken {t = t} {a = a} ⊢t =
⊢subst (sym map-weaken) (Tm./-wk t) (/-wk {t = a}) (⊢t / wk)
-- Weakening of terms with additional type variables lifted to
-- collections of well-typed terms.
weakenAll : ∀ {m n k} {Γ : Ctx m n} {ts : Vec (Term m n) k}
{as : Vec (Type n) k} → Γ ⊢ⁿ ts ∈ as →
C.weaken Γ ⊢ⁿ map Tm.weaken ts ∈ map Tp.weaken as
weakenAll {ts = []} {[]} [] = []
weakenAll {ts = _ ∷ _} {_ ∷ _} (⊢t ∷ ⊢ts) = weaken ⊢t ∷ weakenAll ⊢ts
-- Shorthand for single-variable type substitutions in well-typed
-- terms.
_[/_] : ∀ {m n} {Γ : Ctx m (1 + n)} {t a} →
Γ ⊢ t ∈ a → (b : Type n) → Γ C./ sub b ⊢ t Tm./ sub b ∈ a Tp./ sub b
⊢t [/ b ] = ⊢t / sub b
-- A weakened version of the shorthand for single-variable type
-- substitutions that fits well with well-typed type application.
_[/_]′ : ∀ {m n} {Γ : Ctx m n} {t a} → C.weaken Γ ⊢ t ∈ a →
(b : Type n) → Γ ⊢ t Tm./ sub b ∈ a Tp./ sub b
⊢t [/ b ]′ = ⊢substCtx Tp.map-weaken-⊙-sub (⊢t / sub b)
-- Term substitutions lifted to well-typed terms
module WtTermTermSubst where
private
module Tp = TermTypeSubst
module Tm = TermTermSubst
module Var = VarSubst
module C = CtxLemmas
TmSub = Tm.TermSub Term
infix 4 _⇒_⊢_
-- Well-typed term substitutions are collections of well-typed terms.
_⇒_⊢_ : ∀ {m n k} → Ctx m n → Ctx k n → TmSub m n k → Set
Γ ⇒ Δ ⊢ ρ = Δ ⊢ⁿ ρ ∈ Γ
infixl 8 _/_ _/Var_
infix 10 _↑
-- Application of term variable substitutions (renaming) lifted to
-- well-typed terms.
_/Var_ : ∀ {m n k} {Γ : Ctx k n} {t : Term m n} {a : Type n}
(ρ : Sub Fin m k) → ρ C./Var Γ ⊢ t ∈ a → Γ ⊢ t Tm./Var ρ ∈ a
_/Var_ {Γ = Γ} ρ (var x) =
⊢substTp (sym (C./Var-lookup x ρ Γ)) (var (lookup ρ x))
_/Var_ {Γ = Γ} ρ (Λ ⊢t) =
Λ (ρ /Var ⊢substCtx (C./Var-weaken ρ Γ) ⊢t)
_/Var_ {Γ = Γ} ρ (λ' a ⊢t) =
λ' a (ρ Var.↑ /Var ⊢substCtx (C./Var-∷ a ρ Γ) ⊢t)
_/Var_ {Γ = Γ} ρ (μ a ⊢t) =
μ a (ρ Var.↑ /Var ⊢substCtx (C./Var-∷ a ρ Γ) ⊢t)
ρ /Var (⊢t [ b ]) = (ρ /Var ⊢t) [ b ]
ρ /Var (⊢s · ⊢t) = (ρ /Var ⊢s) · (ρ /Var ⊢t)
ρ /Var (fold a ⊢t) = fold a (ρ /Var ⊢t)
ρ /Var (unfold a ⊢t) = unfold a (ρ /Var ⊢t)
-- Weakening of terms with additional term variables lifted to
-- well-typed terms.
weaken : ∀ {m n} {Γ : Ctx m n} {t : Term m n} {a b : Type n} →
Γ ⊢ t ∈ a → b ∷ Γ ⊢ Tm.weaken t ∈ a
weaken {Γ = Γ} {b = b} ⊢t =
Var.wk /Var ⊢substCtx (C.wkVar-/Var-∷ Γ b) ⊢t
-- Weakening of terms with additional term variables lifted to
-- collections of well-typed terms.
weakenAll : ∀ {m n k} {Γ : Ctx m n} {ts : Vec (Term m n) k}
{as : Vec (Type n) k} {b : Type n} →
Γ ⊢ⁿ ts ∈ as → b ∷ Γ ⊢ⁿ map Tm.weaken ts ∈ as
weakenAll {ts = []} {[]} [] = []
weakenAll {ts = _ ∷ _} {_ ∷ _} (⊢t ∷ ⊢ts) = weaken ⊢t ∷ weakenAll ⊢ts
-- Lifting of well-typed term substitutions.
_↑ : ∀ {m n k} {Γ : Ctx m n} {Δ : Ctx k n} {ρ b} →
Γ ⇒ Δ ⊢ ρ → b ∷ Γ ⇒ b ∷ Δ ⊢ ρ Tm.↑
⊢ρ ↑ = var zero ∷ weakenAll ⊢ρ
-- The well-typed identity substitution.
id : ∀ {m n} {Γ : Ctx m n} → Γ ⇒ Γ ⊢ Tm.id
id {zero} {Γ = []} = []
id {suc m} {Γ = a ∷ Γ} = id ↑
-- Well-typed weakening (as a substitution).
wk : ∀ {m n} {Γ : Ctx m n} {a} → Γ ⇒ a ∷ Γ ⊢ Tm.wk
wk = weakenAll id
-- A well-typed substitution which only replaces the first variable.
sub : ∀ {m n} {Γ : Ctx m n} {t a} → Γ ⊢ t ∈ a → a ∷ Γ ⇒ Γ ⊢ Tm.sub t
sub ⊢t = ⊢t ∷ id
-- Application of term substitutions lifted to well-typed terms
_/_ : ∀ {m n k} {Γ : Ctx m n} {Δ : Ctx k n} {t a ρ} →
Γ ⊢ t ∈ a → Γ ⇒ Δ ⊢ ρ → Δ ⊢ t Tm./ ρ ∈ a
var x / ⊢ρ = lookup-⊢ x ⊢ρ
Λ ⊢t / ⊢ρ = Λ (⊢t / (WtTermTypeSubst.weakenAll ⊢ρ))
λ' a ⊢t / ⊢ρ = λ' a (⊢t / ⊢ρ ↑)
μ a ⊢t / ⊢ρ = μ a (⊢t / ⊢ρ ↑)
(⊢t [ a ]) / ⊢ρ = (⊢t / ⊢ρ) [ a ]
(⊢s · ⊢t) / ⊢ρ = (⊢s / ⊢ρ) · (⊢t / ⊢ρ)
fold a ⊢t / ⊢ρ = fold a (⊢t / ⊢ρ)
unfold a ⊢t / ⊢ρ = unfold a (⊢t / ⊢ρ)
-- Shorthand for well-typed single-variable term substitutions.
_[/_] : ∀ {m n} {Γ : Ctx m n} {s t a b} →
b ∷ Γ ⊢ s ∈ a → Γ ⊢ t ∈ b → Γ ⊢ s Tm./ Tm.sub t ∈ a
⊢s [/ ⊢t ] = ⊢s / sub ⊢t
------------------------------------------------------------------------
-- Encoding of additional well-typed term operators
--
-- These correspond to admissible typing rules for the asscociated
-- term operators.
module WtTermOperators where
open TypeOperators renaming (id to idTp)
open TypeOperatorLemmas
open TypeLemmas hiding (id)
private
module Ut = TermOperators
module ⊢Tp = WtTermTypeSubst
module ⊢Tm = WtTermTermSubst
-- Polymorphic identity function
id : ∀ {m n} {Γ : Ctx m n} → Γ ⊢ Ut.id ∈ idTp
id = Λ (λ' (var (zero)) (var zero))
-- Bottom elimination/univeral property of the initial type
⊥-elim : ∀ {m n} {Γ : Ctx m n} (a : Type n) → Γ ⊢ Ut.⊥-elim a ∈ ⊥ →' a
⊥-elim a = λ' ⊥ ((var zero) [ a ])
-- Unit value
tt : ∀ {m n} {Γ : Ctx m n} → Γ ⊢ Ut.tt ∈ ⊤
tt = id
-- Top introduction/universal property of the terminal type
⊤-intro : ∀ {m n} {Γ : Ctx m n} → (a : Type n) → Γ ⊢ Ut.⊤-intro a ∈ a →' ⊤
⊤-intro {n = n} a = λ' a (id {n = n})
-- Packing existential types
as-∃_pack_,_ : ∀ {m n} {Γ : Ctx m n}
(a : Type (1 + n)) (b : Type n) {t : Term m n} →
Γ ⊢ t ∈ a [/tp b ] → Γ ⊢ Ut.as-∃ a pack b , t ∈ ∃ a
as-∃ a pack b , ⊢t =
Λ (λ' (∀' (weaken↑ a →' var (suc zero))) ((var zero [ weaken b ]) · ⊢t′))
where ⊢t′ = ⊢Tm.weaken (⊢substTp (weaken-sub a b) (⊢Tp.weaken ⊢t))
-- Unpacking existential types
unpack_in'_ : ∀ {m n} {Γ : Ctx m n} {s : Term m n}
{t : Term (1 + m) (1 + n)} {a : Type (1 + n)} {b : Type n} →
Γ ⊢ s ∈ ∃ a → a ∷ weakenCtx Γ ⊢ t ∈ weaken b →
Γ ⊢ Ut.unpack_in'_ s t {a} {b} ∈ b
unpack_in'_ {a = a} {b = b} ⊢s ⊢t = (⊢s [ b ]) · Λ (⊢substTp a≡ (λ' a ⊢t))
where
a≡ : a →' weaken b ≡ weaken↑ a / (sub b) ↑ →' weaken b
a≡ = cong (λ a → a →' weaken b) (begin
a ≡⟨ sym (id-vanishes a) ⟩
a / TypeLemmas.id ≡⟨ cong (λ σ → a / σ) (sym (id-↑⋆ 1)) ⟩
a / (TypeLemmas.id) ↑ ≡⟨ cong (λ σ → a / σ ↑) (sym wk-⊙-sub) ⟩
a / (wk ⊙ sub b) ↑ ≡⟨ cong (λ σ → a / σ) (↑⋆-distrib 1) ⟩
a / wk ↑ ⊙ (sub b) ↑ ≡⟨ /-⊙ a ⟩
a / wk ↑ / (sub b) ↑ ∎)
-- n-ary term abstraction
λⁿ : ∀ {m n k} {Γ : Ctx m n} (as : Vec (Type n) k) {b : Type n}
{t : Term (k + m) n} → as ++ Γ ⊢ t ∈ b → Γ ⊢ Ut.λⁿ as t ∈ as →ⁿ b
λⁿ [] ⊢t = ⊢t
λⁿ (a ∷ as) ⊢t = λⁿ as (λ' a ⊢t)
infixl 9 _·ⁿ_
-- n-ary term application
_·ⁿ_ : ∀ {m n k} {Γ : Ctx m n} {s : Term m n} {ts : Vec (Term m n) k}
{as : Vec (Type n) k} {b : Type n} →
Γ ⊢ s ∈ as →ⁿ b → Γ ⊢ⁿ ts ∈ as → Γ ⊢ s Ut.·ⁿ ts ∈ b
_·ⁿ_ {ts = []} {[]} ⊢s [] = ⊢s
_·ⁿ_ {ts = _ ∷ _} {_ ∷ _} ⊢s (⊢t ∷ ⊢ts) = ⊢s ·ⁿ ⊢ts · ⊢t
-- Record/tuple constructor
new : ∀ {m n k} {Γ : Ctx m n} {ts : Vec (Term m n) k} {as : Vec (Type n) k} →
Γ ⊢ⁿ ts ∈ as → Γ ⊢ Ut.new ts {as} ∈ rec as
new {ts = []} {[]} [] = tt
new {ts = _ ∷ _} {a ∷ as} (⊢t ∷ ⊢ts) =
Λ (λ' (map weaken (a ∷ as) →ⁿ var zero)
(var zero ·ⁿ ⊢Tm.weakenAll (⊢Tp.weakenAll (⊢t ∷ ⊢ts))))
-- Field access/projection
π : ∀ {m n k} {Γ : Ctx m n} (x : Fin k) {t : Term m n}
{as : Vec (Type n) k} →
Γ ⊢ t ∈ rec as → Γ ⊢ Ut.π x t {as} ∈ lookup as x
π () {as = []} ⊢t
π {m} {Γ = Γ} x {as = a ∷ as} ⊢t =
(⊢t [ b ]) · ⊢substTp as′→ⁿb′≡ (λⁿ as′ (var x′))
where
as′ = a ∷ as
x′ = inject+ m x
b = lookup as′ x
b′ = lookup (as′ ++ Γ) x′
as′→ⁿb′≡ : as′ →ⁿ b′ ≡ (map weaken as′ →ⁿ var zero) [/tp b ]
as′→ⁿb′≡ = begin
as′ →ⁿ b′
≡⟨ cong (λ b → as′ →ⁿ b) (lookup-++-inject+ as′ Γ x) ⟩
as′ →ⁿ b
≡⟨ cong (λ as′ → as′ →ⁿ b) (sym (map-weaken-⊙-sub {ρ = as′})) ⟩
map weaken as′ ⊙ sub b →ⁿ b
≡⟨ sym (/-→ⁿ (map weaken as′) (var zero) (sub b)) ⟩
(map weaken as′ →ⁿ var zero) [/tp b ]
∎
|
{
"alphanum_fraction": 0.4900670249,
"avg_line_length": 38.7845433255,
"ext": "agda",
"hexsha": "f0396d170fa707bcff47118ced40039296767087",
"lang": "Agda",
"max_forks_count": 8,
"max_forks_repo_forks_event_max_datetime": "2021-07-06T23:12:48.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-05-29T12:24:46.000Z",
"max_forks_repo_head_hexsha": "ea262cf7714cdb762643f10275c568596f57cd1d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "sstucki/system-f-agda",
"max_forks_repo_path": "src/SystemF/WtTerm.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "ea262cf7714cdb762643f10275c568596f57cd1d",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T19:23:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2017-05-30T06:43:04.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "sstucki/system-f-agda",
"max_issues_repo_path": "src/SystemF/WtTerm.agda",
"max_line_length": 79,
"max_stars_count": 68,
"max_stars_repo_head_hexsha": "ea262cf7714cdb762643f10275c568596f57cd1d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "sstucki/system-f-agda",
"max_stars_repo_path": "src/SystemF/WtTerm.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-01T01:25:16.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-05-26T13:12:56.000Z",
"num_tokens": 7075,
"size": 16561
}
|
{-# OPTIONS --without-K --rewriting #-}
open import lib.Basics
open import lib.types.Paths
open import lib.types.Pointed
open import lib.types.Pushout
open import lib.types.PushoutFmap
open import lib.types.Sigma
open import lib.types.Span
module lib.types.Join where
module _ {i j} (A : Type i) (B : Type j) where
*-span : Span
*-span = span A B (A × B) fst snd
infix 80 _*_
_*_ : Type _
_*_ = Pushout *-span
module _ {i j} {A : Type i} {B : Type j} where
jleft : A → A * B
jleft = left
jright : B → A * B
jright = right
jglue : ∀ a b → jleft a == jright b
jglue = curry glue
module JoinElim {k} {P : A * B → Type k}
(jleft* : (a : A) → P (jleft a)) (jright* : (b : B) → P (jright b))
(jglue* : ∀ a b → jleft* a == jright* b [ P ↓ jglue a b ]) where
private
module M = PushoutElim {d = *-span A B} {P = P} jleft* jright* (uncurry jglue*)
f = M.f
glue-β = curry M.glue-β
Join-elim = JoinElim.f
module JoinRec {k} {C : Type k}
(jleft* : (a : A) → C) (jright* : (b : B) → C)
(jglue* : ∀ a b → jleft* a == jright* b) where
private
module M = PushoutRec jleft* jright* (uncurry jglue*)
f = M.f
glue-β = curry M.glue-β
Join-rec = JoinRec.f
module _ {i j} (X : Ptd i) (Y : Ptd j) where
⊙*-span : ⊙Span
⊙*-span = ⊙span X Y (X ⊙× Y) ⊙fst ⊙snd
infix 80 _⊙*_
_⊙*_ : Ptd _
_⊙*_ = ⊙Pushout ⊙*-span
module _ {i i' j j'} {A : Type i} {A' : Type i'} {B : Type j} {B' : Type j'}
(eqA : A ≃ A') (eqB : B ≃ B') where
*-span-emap : SpanEquiv (*-span A B) (*-span A' B')
*-span-emap = ( span-map (fst eqA) (fst eqB) (×-fmap (fst eqA) (fst eqB)) (comm-sqr λ _ → idp) (comm-sqr λ _ → idp)
, snd eqA , snd eqB , ×-isemap (snd eqA) (snd eqB))
*-emap : A * B ≃ A' * B'
*-emap = Pushout-emap *-span-emap
module _ {i i' j j'} {X : Ptd i} {X' : Ptd i'} {Y : Ptd j} {Y' : Ptd j'} where
⊙*-emap : X ⊙≃ X' → Y ⊙≃ Y' → X ⊙* Y ⊙≃ X' ⊙* Y'
⊙*-emap ⊙eqX ⊙eqY = ≃-to-⊙≃ (*-emap (⊙≃-to-≃ ⊙eqX) (⊙≃-to-≃ ⊙eqY)) (ap left (snd (⊙–> ⊙eqX)))
|
{
"alphanum_fraction": 0.529555447,
"avg_line_length": 25.9113924051,
"ext": "agda",
"hexsha": "9680ada16f91c8ea750b4530beae56545f16c47e",
"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": "core/lib/types/Join.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": "core/lib/types/Join.agda",
"max_line_length": 117,
"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": "core/lib/types/Join.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": 901,
"size": 2047
}
|
module OlderBasicILP.Indirect.Hilbert.Sequential where
open import OlderBasicILP.Indirect public
-- Derivations, as Hilbert-style combinator sequences.
mutual
data Tm : Set where
NIL : Tm
VAR : ℕ → Tm → Tm
MP : ℕ → ℕ → Tm → Tm
CI : Tm → Tm
CK : Tm → Tm
CS : Tm → Tm
NEC : Tm → Tm → Tm
CDIST : Tm → Tm
CUP : Tm → Tm
CDOWN : Tm → Tm
CPAIR : Tm → Tm
CFST : Tm → Tm
CSND : Tm → Tm
UNIT : Tm → Tm
_⧻ᵀᵐ_ : Tm → Tm → Tm
US ⧻ᵀᵐ NIL = US
US ⧻ᵀᵐ VAR I TS = VAR I (US ⧻ᵀᵐ TS)
US ⧻ᵀᵐ MP I J TS = MP I J (US ⧻ᵀᵐ TS)
US ⧻ᵀᵐ CI TS = CI (US ⧻ᵀᵐ TS)
US ⧻ᵀᵐ CK TS = CK (US ⧻ᵀᵐ TS)
US ⧻ᵀᵐ CS TS = CS (US ⧻ᵀᵐ TS)
US ⧻ᵀᵐ NEC SS TS = NEC SS (US ⧻ᵀᵐ TS)
US ⧻ᵀᵐ CDIST TS = CDIST (US ⧻ᵀᵐ TS)
US ⧻ᵀᵐ CUP TS = CUP (US ⧻ᵀᵐ TS)
US ⧻ᵀᵐ CDOWN TS = CDOWN (US ⧻ᵀᵐ TS)
US ⧻ᵀᵐ CPAIR TS = CPAIR (US ⧻ᵀᵐ TS)
US ⧻ᵀᵐ CFST TS = CFST (US ⧻ᵀᵐ TS)
US ⧻ᵀᵐ CSND TS = CSND (US ⧻ᵀᵐ TS)
US ⧻ᵀᵐ UNIT TS = UNIT (US ⧻ᵀᵐ TS)
APP : Tm → Tm → Tm
APP TS US = MP 0 0 (US ⧻ᵀᵐ TS)
BOX : Tm → Tm
BOX TS = NEC TS NIL
infix 3 _⊢×_
data _⊢×_ (Γ : Cx (Ty Tm)) : Cx (Ty Tm) → Set where
nil : Γ ⊢× ∅
var : ∀ {Ξ A} → A ∈ Γ → Γ ⊢× Ξ → Γ ⊢× Ξ , A
mp : ∀ {Ξ A B} → A ▻ B ∈ Ξ → A ∈ Ξ → Γ ⊢× Ξ → Γ ⊢× Ξ , B
ci : ∀ {Ξ A} → Γ ⊢× Ξ → Γ ⊢× Ξ , A ▻ A
ck : ∀ {Ξ A B} → Γ ⊢× Ξ → Γ ⊢× Ξ , A ▻ B ▻ A
cs : ∀ {Ξ A B C} → Γ ⊢× Ξ → Γ ⊢× Ξ , (A ▻ B ▻ C) ▻ (A ▻ B) ▻ A ▻ C
nec : ∀ {Ξ Ξ′ A} → (ss : ∅ ⊢× Ξ′ , A) → Γ ⊢× Ξ → Γ ⊢× Ξ , [ ss ]× ⦂ A
cdist : ∀ {Ξ A B TS US} → Γ ⊢× Ξ → Γ ⊢× Ξ , TS ⦂ (A ▻ B) ▻ US ⦂ A ▻ APP TS US ⦂ B
cup : ∀ {Ξ A TS} → Γ ⊢× Ξ → Γ ⊢× Ξ , TS ⦂ A ▻ BOX TS ⦂ TS ⦂ A
cdown : ∀ {Ξ A TS} → Γ ⊢× Ξ → Γ ⊢× Ξ , TS ⦂ A ▻ A
cpair : ∀ {Ξ A B} → Γ ⊢× Ξ → Γ ⊢× Ξ , A ▻ B ▻ A ∧ B
cfst : ∀ {Ξ A B} → Γ ⊢× Ξ → Γ ⊢× Ξ , A ∧ B ▻ A
csnd : ∀ {Ξ A B} → Γ ⊢× Ξ → Γ ⊢× Ξ , A ∧ B ▻ B
unit : ∀ {Ξ} → Γ ⊢× Ξ → Γ ⊢× Ξ , ⊤
[_]× : ∀ {Ξ Γ} → Γ ⊢× Ξ → Tm
[ nil ]× = NIL
[ var i ts ]× = VAR [ i ]ⁱ [ ts ]×
[ mp i j ts ]× = MP [ i ]ⁱ [ j ]ⁱ [ ts ]×
[ ci ts ]× = CI [ ts ]×
[ ck ts ]× = CK [ ts ]×
[ cs ts ]× = CS [ ts ]×
[ nec ss ts ]× = NEC [ ss ]× [ ts ]×
[ cdist ts ]× = CDIST [ ts ]×
[ cup ts ]× = CUP [ ts ]×
[ cdown ts ]× = CDOWN [ ts ]×
[ cpair ts ]× = CPAIR [ ts ]×
[ cfst ts ]× = CFST [ ts ]×
[ csnd ts ]× = CSND [ ts ]×
[ unit ts ]× = UNIT [ ts ]×
infix 3 _⊢_
_⊢_ : Cx (Ty Tm) → Ty Tm → Set
Γ ⊢ A = ∃ (λ Ξ → Γ ⊢× Ξ , A)
[_] : ∀ {A Γ} → Γ ⊢ A → Tm
[ Ξ , ts ] = [ ts ]×
-- Monotonicity with respect to context inclusion.
mono⊢× : ∀ {Ξ Γ Γ′} → Γ ⊆ Γ′ → Γ ⊢× Ξ → Γ′ ⊢× Ξ
mono⊢× η nil = nil
mono⊢× η (var i ts) = var (mono∈ η i) (mono⊢× η ts)
mono⊢× η (mp i j ts) = mp i j (mono⊢× η ts)
mono⊢× η (ci ts) = ci (mono⊢× η ts)
mono⊢× η (ck ts) = ck (mono⊢× η ts)
mono⊢× η (cs ts) = cs (mono⊢× η ts)
mono⊢× η (nec ss ts) = nec ss (mono⊢× η ts)
mono⊢× η (cdist ts) = cdist (mono⊢× η ts)
mono⊢× η (cup ts) = cup (mono⊢× η ts)
mono⊢× η (cdown ts) = cdown (mono⊢× η ts)
mono⊢× η (cpair ts) = cpair (mono⊢× η ts)
mono⊢× η (cfst ts) = cfst (mono⊢× η ts)
mono⊢× η (csnd ts) = csnd (mono⊢× η ts)
mono⊢× η (unit ts) = unit (mono⊢× η ts)
mono⊢ : ∀ {A Γ Γ′} → Γ ⊆ Γ′ → Γ ⊢ A → Γ′ ⊢ A
mono⊢ η (Ξ , ts) = Ξ , mono⊢× η ts
-- Concatenation of derivations.
_⧻_ : ∀ {Γ Ξ Ξ′} → Γ ⊢× Ξ → Γ ⊢× Ξ′ → Γ ⊢× Ξ ⧺ Ξ′
us ⧻ nil = us
us ⧻ var i ts = var i (us ⧻ ts)
us ⧻ mp i j ts = mp (mono∈ weak⊆⧺₂ i) (mono∈ weak⊆⧺₂ j) (us ⧻ ts)
us ⧻ ci ts = ci (us ⧻ ts)
us ⧻ ck ts = ck (us ⧻ ts)
us ⧻ cs ts = cs (us ⧻ ts)
us ⧻ nec ss ts = nec ss (us ⧻ ts)
us ⧻ cdist ts = cdist (us ⧻ ts)
us ⧻ cup ts = cup (us ⧻ ts)
us ⧻ cdown ts = cdown (us ⧻ ts)
us ⧻ cpair ts = cpair (us ⧻ ts)
us ⧻ cfst ts = cfst (us ⧻ ts)
us ⧻ csnd ts = csnd (us ⧻ ts)
us ⧻ unit ts = unit (us ⧻ ts)
-- Modus ponens and necessitation in expanded form.
app : ∀ {A B Γ} → Γ ⊢ A ▻ B → Γ ⊢ A → Γ ⊢ B
app {A} {B} (Ξ , ts) (Ξ′ , us) = Ξ″ , vs
where Ξ″ = (Ξ′ , A) ⧺ (Ξ , A ▻ B)
vs = mp top (mono∈ (weak⊆⧺₁ (Ξ , A ▻ B)) top) (us ⧻ ts)
box : ∀ {A Γ} → (t : ∅ ⊢ A) → Γ ⊢ [ t ] ⦂ A
box (Ξ , ts) = ∅ , nec ts nil
|
{
"alphanum_fraction": 0.418934636,
"avg_line_length": 31.152173913,
"ext": "agda",
"hexsha": "ba6ccc85113ca23385450fdf7cf7e477cd578406",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_forks_repo_licenses": [
"X11"
],
"max_forks_repo_name": "mietek/hilbert-gentzen",
"max_forks_repo_path": "OlderBasicILP/Indirect/Hilbert/Sequential.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_issues_repo_issues_event_max_datetime": "2018-06-10T09:11:22.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-06-10T09:11:22.000Z",
"max_issues_repo_licenses": [
"X11"
],
"max_issues_repo_name": "mietek/hilbert-gentzen",
"max_issues_repo_path": "OlderBasicILP/Indirect/Hilbert/Sequential.agda",
"max_line_length": 85,
"max_stars_count": 29,
"max_stars_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_stars_repo_licenses": [
"X11"
],
"max_stars_repo_name": "mietek/hilbert-gentzen",
"max_stars_repo_path": "OlderBasicILP/Indirect/Hilbert/Sequential.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-01T10:29:18.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-07-03T18:51:56.000Z",
"num_tokens": 2499,
"size": 4299
}
|
{-# OPTIONS --without-K --safe --overlapping-instances #-}
module SmallInterpreter where
open import Data.Char hiding (_≤_)
open import Data.Bool hiding (_≤_)
open import Data.Nat hiding (_≤_)
open import Data.Unit
import Data.Nat as N
open import Data.Product
open import Data.Sum
open import Relation.Binary.PropositionalEquality
open import Relation.Nullary
import Data.String as Str
open import Data.Nat.Show
import Data.List as List
open import Data.Empty
infix 3 _:::_,_
infix 2 _∈_
infix 1 _⊢_
data `Set : Set where
`Bool : `Set
_`⇨_ : `Set → `Set → `Set
`⊤ : `Set
_`×_ : `Set → `Set → `Set
infixr 2 _`⇨_
data Var : Set where
x' : Var
y' : Var
z' : Var
-- Inequality proofs on variables
data _≠_ : Var → Var → Set where
x≠y : x' ≠ y'
x≠z : x' ≠ z'
y≠x : y' ≠ x'
y≠z : y' ≠ z'
z≠x : z' ≠ x'
z≠y : z' ≠ y'
⟦_⟧ : `Set → Set
⟦ `Bool ⟧ = Bool
⟦ (t `⇨ s) ⟧ = ⟦ t ⟧ → ⟦ s ⟧
⟦ `⊤ ⟧ = ⊤
⟦ (t `× s) ⟧ = ⟦ t ⟧ × ⟦ s ⟧
data Γ : Set where
· : Γ
_:::_,_ : Var → `Set → Γ → Γ
data _∈_ : Var → Γ → Set where
H : ∀ {x Δ t } → x ∈ x ::: t , Δ
TH : ∀ {x y Δ t } → ⦃ prf : x ∈ Δ ⦄ → ⦃ neprf : x ≠ y ⦄ → x ∈ y ::: t , Δ
!Γ_[_] : ∀ {x} → (Δ : Γ) → x ∈ Δ → `Set
!Γ_[_] · ()
!Γ _ ::: t , Δ [ H ] = t
!Γ _ ::: _ , Δ [ TH ⦃ prf = i ⦄ ] = !Γ Δ [ i ]
infix 30 `v_
infix 30 `not_
infix 27 _`∧_
infix 26 _`∨_
infix 25 _`xor_
infix 24 _`,_
infixl 22 _`₋_
data _⊢_ : Γ → `Set → Set where
`false : ∀ {Δ} → Δ ⊢ `Bool
`true : ∀ {Δ} → Δ ⊢ `Bool
`v_ : ∀ {Δ} → (x : Var) → ⦃ i : x ∈ Δ ⦄ → Δ ⊢ !Γ Δ [ i ]
_`₋_ : ∀ {Δ t s} → Δ ⊢ t `⇨ s → Δ ⊢ t → Δ ⊢ s --application
`λ_`:_⇨_ : ∀ {Δ tr} → (x : Var) → (tx : `Set)
→ x ::: tx , Δ ⊢ tr → Δ ⊢ tx `⇨ tr
`not_ : ∀ {Δ} → Δ ⊢ `Bool → Δ ⊢ `Bool
_`∧_ : ∀ {Δ} → Δ ⊢ `Bool → Δ ⊢ `Bool → Δ ⊢ `Bool
_`∨_ : ∀ {Δ} → Δ ⊢ `Bool → Δ ⊢ `Bool → Δ ⊢ `Bool
_`xor_ : ∀ {Δ} → Δ ⊢ `Bool → Δ ⊢ `Bool → Δ ⊢ `Bool
_`,_ : ∀ {Δ t s} → Δ ⊢ t → Δ ⊢ s → Δ ⊢ t `× s
`fst : ∀ {Δ t s} → Δ ⊢ t `× s → Δ ⊢ t
`snd : ∀ {Δ t s} → Δ ⊢ t `× s → Δ ⊢ s
`tt : ∀ {Δ} → Δ ⊢ `⊤
data ⟨_⟩ : Γ → Set₁ where
[] : ⟨ · ⟩
_∷_ : ∀ {x t Δ} → ⟦ t ⟧ → ⟨ Δ ⟩ → ⟨ x ::: t , Δ ⟩
!_[_] : ∀ {x Δ} → ⟨ Δ ⟩ → (i : x ∈ Δ) → ⟦ !Γ Δ [ i ] ⟧
!_[_] [] ()
!_[_] (val ∷ env) H = val
!_[_] (val ∷ env) (TH ⦃ prf = i ⦄) = ! env [ i ]
interpret : ∀ {t} → · ⊢ t → ⟦ t ⟧
interpret = interpret' []
where interpret' : ∀ {Δ t} → ⟨ Δ ⟩ → Δ ⊢ t → ⟦ t ⟧
interpret' env `true = true
interpret' env `false = false
interpret' env `tt = tt
interpret' env ((`v x) ⦃ i = idx ⦄) = ! env [ idx ]
interpret' env (f `₋ x) = (interpret' env f) (interpret' env x)
interpret' env (`λ _ `: tx ⇨ body) = λ (x : ⟦ tx ⟧) → interpret' (x ∷ env) body
interpret' env (`not x) = not (interpret' env x)
interpret' env (l `∧ r) = interpret' env l ∧ interpret' env r
interpret' env (l `∨ r) = interpret' env l ∨ interpret' env r
interpret' env (l `xor r ) = interpret' env l xor interpret' env r
interpret' env (f `, s) = interpret' env f ,′ interpret' env s
interpret' env (`fst p) with interpret' env p
interpret' env (`fst p) | f , s = f
interpret' env (`snd p) with interpret' env p
interpret' env (`snd p) | f , s = s
instance
v_type₁ : ∀ {x Δ t} → x ∈ x ::: t , Δ
v_type₁ = H
v_type₂ : ∀ {x y Δ t} → ⦃ prf : x ∈ Δ ⦄ → ⦃ x ≠ y ⦄ → x ∈ y ::: t , Δ
v_type₂ = TH
instance
xy : x' ≠ y'
xy = x≠y
xz : x' ≠ z'
xz = x≠z
yx : y' ≠ x'
yx = y≠x
yz : y' ≠ z'
yz = y≠z
zx : z' ≠ x'
zx = z≠x
zy : z' ≠ y'
zy = z≠y
pf : interpret (`λ x' `: `Bool ⇨ `v x') ≡ λ x → x
pf = refl
|
{
"alphanum_fraction": 0.4267612772,
"avg_line_length": 27.0273972603,
"ext": "agda",
"hexsha": "32379ec0a7f6995601a4b5a6ec1783303f7731fc",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2021-06-18T12:31:11.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-06-18T06:14:18.000Z",
"max_forks_repo_head_hexsha": "2a85cc82934be9433648bca0b49b77db18de524c",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "sseefried/well-typed-agda-interpreter",
"max_forks_repo_path": "SmallInterpreter.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "2a85cc82934be9433648bca0b49b77db18de524c",
"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": "sseefried/well-typed-agda-interpreter",
"max_issues_repo_path": "SmallInterpreter.agda",
"max_line_length": 88,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "2a85cc82934be9433648bca0b49b77db18de524c",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "sseefried/well-typed-agda-interpreter",
"max_stars_repo_path": "SmallInterpreter.agda",
"max_stars_repo_stars_event_max_datetime": "2021-06-18T12:37:46.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-06-18T12:06:14.000Z",
"num_tokens": 1724,
"size": 3946
}
|
-- Intuitionistic propositional calculus.
-- Hilbert-style formalisation of closed syntax.
-- Nested terms.
module IPC.Syntax.ClosedHilbert where
open import IPC.Syntax.Common public
-- Derivations.
infix 3 ⊢_
data ⊢_ : Ty → Set where
app : ∀ {A B} → ⊢ A ▻ B → ⊢ A → ⊢ B
ci : ∀ {A} → ⊢ A ▻ A
ck : ∀ {A B} → ⊢ A ▻ B ▻ A
cs : ∀ {A B C} → ⊢ (A ▻ B ▻ C) ▻ (A ▻ B) ▻ A ▻ C
cpair : ∀ {A B} → ⊢ A ▻ B ▻ A ∧ B
cfst : ∀ {A B} → ⊢ A ∧ B ▻ A
csnd : ∀ {A B} → ⊢ A ∧ B ▻ B
unit : ⊢ ⊤
cboom : ∀ {C} → ⊢ ⊥ ▻ C
cinl : ∀ {A B} → ⊢ A ▻ A ∨ B
cinr : ∀ {A B} → ⊢ B ▻ A ∨ B
ccase : ∀ {A B C} → ⊢ A ∨ B ▻ (A ▻ C) ▻ (B ▻ C) ▻ C
infix 3 ⊢⋆_
⊢⋆_ : Cx Ty → Set
⊢⋆ ∅ = 𝟙
⊢⋆ Ξ , A = ⊢⋆ Ξ × ⊢ A
-- Cut and multicut.
cut : ∀ {A B} → ⊢ A → ⊢ A ▻ B → ⊢ B
cut t u = app u t
multicut : ∀ {Ξ A} → ⊢⋆ Ξ → ⊢ Ξ ▻⋯▻ A → ⊢ A
multicut {∅} ∙ u = u
multicut {Ξ , B} (ts , t) u = app (multicut ts u) t
-- Contraction.
ccont : ∀ {A B} → ⊢ (A ▻ A ▻ B) ▻ A ▻ B
ccont = app (app cs cs) (app ck ci)
cont : ∀ {A B} → ⊢ A ▻ A ▻ B → ⊢ A ▻ B
cont t = app ccont t
-- Exchange, or Schönfinkel’s C combinator.
cexch : ∀ {A B C} → ⊢ (A ▻ B ▻ C) ▻ B ▻ A ▻ C
cexch = app (app cs (app (app cs (app ck cs))
(app (app cs (app ck ck)) cs)))
(app ck ck)
exch : ∀ {A B C} → ⊢ A ▻ B ▻ C → ⊢ B ▻ A ▻ C
exch t = app cexch t
-- Composition, or Schönfinkel’s B combinator.
ccomp : ∀ {A B C} → ⊢ (B ▻ C) ▻ (A ▻ B) ▻ A ▻ C
ccomp = app (app cs (app ck cs)) ck
comp : ∀ {A B C} → ⊢ B ▻ C → ⊢ A ▻ B → ⊢ A ▻ C
comp t u = app (app ccomp t) u
-- Useful theorems in functional form.
pair : ∀ {A B} → ⊢ A → ⊢ B → ⊢ A ∧ B
pair t u = app (app cpair t) u
fst : ∀ {A B} → ⊢ A ∧ B → ⊢ A
fst t = app cfst t
snd : ∀ {A B} → ⊢ A ∧ B → ⊢ B
snd t = app csnd t
boom : ∀ {C} → ⊢ ⊥ → ⊢ C
boom t = app cboom t
inl : ∀ {A B} → ⊢ A → ⊢ A ∨ B
inl t = app cinl t
inr : ∀ {A B} → ⊢ B → ⊢ A ∨ B
inr t = app cinr t
case : ∀ {A B C} → ⊢ A ∨ B → ⊢ A ▻ C → ⊢ B ▻ C → ⊢ C
case t u v = app (app (app ccase t) u) v
-- Convertibility.
data _⋙_ : ∀ {A} → ⊢ A → ⊢ A → Set where
refl⋙ : ∀ {A} → {t : ⊢ A}
→ t ⋙ t
trans⋙ : ∀ {A} → {t t′ t″ : ⊢ A}
→ t ⋙ t′ → t′ ⋙ t″
→ t ⋙ t″
sym⋙ : ∀ {A} → {t t′ : ⊢ A}
→ t ⋙ t′
→ t′ ⋙ t
congapp⋙ : ∀ {A B} → {t t′ : ⊢ A ▻ B} → {u u′ : ⊢ A}
→ t ⋙ t′ → u ⋙ u′
→ app t u ⋙ app t′ u′
congi⋙ : ∀ {A} → {t t′ : ⊢ A}
→ t ⋙ t′
→ app ci t ⋙ app ci t′
congk⋙ : ∀ {A B} → {t t′ : ⊢ A} → {u u′ : ⊢ B}
→ t ⋙ t′ → u ⋙ u′
→ app (app ck t) u ⋙ app (app ck t′) u′
congs⋙ : ∀ {A B C} → {t t′ : ⊢ A ▻ B ▻ C} → {u u′ : ⊢ A ▻ B} → {v v′ : ⊢ A}
→ t ⋙ t′ → u ⋙ u′ → v ⋙ v′
→ app (app (app cs t) u) v ⋙ app (app (app cs t′) u′) v′
congpair⋙ : ∀ {A B} → {t t′ : ⊢ A} → {u u′ : ⊢ B}
→ t ⋙ t′ → u ⋙ u′
→ app (app cpair t) u ⋙ app (app cpair t′) u′
congfst⋙ : ∀ {A B} → {t t′ : ⊢ A ∧ B}
→ t ⋙ t′
→ app cfst t ⋙ app cfst t′
congsnd⋙ : ∀ {A B} → {t t′ : ⊢ A ∧ B}
→ t ⋙ t′
→ app csnd t ⋙ app csnd t′
congboom⋙ : ∀ {C} → {t t′ : ⊢ ⊥}
→ t ⋙ t′
→ app (cboom {C = C}) t ⋙ app cboom t′
conginl⋙ : ∀ {A B} → {t t′ : ⊢ A}
→ t ⋙ t′
→ app (cinl {A = A} {B}) t ⋙ app cinl t′
conginr⋙ : ∀ {A B} → {t t′ : ⊢ B}
→ t ⋙ t′
→ app (cinr {A = A} {B}) t ⋙ app cinr t′
congcase⋙ : ∀ {A B C} → {t t′ : ⊢ A ∨ B} → {u u′ : ⊢ A ▻ C} → {v v′ : ⊢ B ▻ C}
→ t ⋙ t′ → u ⋙ u′ → v ⋙ v′
→ app (app (app ccase t) u) v ⋙ app (app (app ccase t′) u′) v′
-- TODO: Verify this.
beta▻ₖ⋙ : ∀ {A B} → {t : ⊢ A} → {u : ⊢ B}
→ app (app ck t) u ⋙ t
-- TODO: Verify this.
beta▻ₛ⋙ : ∀ {A B C} → {t : ⊢ A ▻ B ▻ C} → {u : ⊢ A ▻ B} → {v : ⊢ A}
→ app (app (app cs t) u) v ⋙ app (app t v) (app u v)
-- TODO: What about eta for ▻?
beta∧₁⋙ : ∀ {A B} → {t : ⊢ A} → {u : ⊢ B}
→ app cfst (app (app cpair t) u) ⋙ t
beta∧₂⋙ : ∀ {A B} → {t : ⊢ A} → {u : ⊢ B}
→ app csnd (app (app cpair t) u) ⋙ u
eta∧⋙ : ∀ {A B} → {t : ⊢ A ∧ B}
→ t ⋙ app (app cpair (app cfst t)) (app csnd t)
eta⊤⋙ : ∀ {t : ⊢ ⊤} → t ⋙ unit
-- TODO: Verify this.
beta∨₁⋙ : ∀ {A B C} → {t : ⊢ A} → {u : ⊢ A ▻ C} → {v : ⊢ B ▻ C}
→ app (app (app ccase (app cinl t)) u) v ⋙ app u t
-- TODO: Verify this.
beta∨₂⋙ : ∀ {A B C} → {t : ⊢ B} → {u : ⊢ A ▻ C} → {v : ⊢ B ▻ C}
→ app (app (app ccase (app cinr t)) u) v ⋙ app v t
-- TODO: What about eta and commuting conversions for ∨? What about ⊥?
|
{
"alphanum_fraction": 0.3433969614,
"avg_line_length": 27.902173913,
"ext": "agda",
"hexsha": "2d361f3c5fc20be7b2be49ec3ff319581a1df069",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_forks_repo_licenses": [
"X11"
],
"max_forks_repo_name": "mietek/hilbert-gentzen",
"max_forks_repo_path": "IPC/Syntax/ClosedHilbert.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_issues_repo_issues_event_max_datetime": "2018-06-10T09:11:22.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-06-10T09:11:22.000Z",
"max_issues_repo_licenses": [
"X11"
],
"max_issues_repo_name": "mietek/hilbert-gentzen",
"max_issues_repo_path": "IPC/Syntax/ClosedHilbert.agda",
"max_line_length": 87,
"max_stars_count": 29,
"max_stars_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_stars_repo_licenses": [
"X11"
],
"max_stars_repo_name": "mietek/hilbert-gentzen",
"max_stars_repo_path": "IPC/Syntax/ClosedHilbert.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-01T10:29:18.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-07-03T18:51:56.000Z",
"num_tokens": 2413,
"size": 5134
}
|
{-# OPTIONS --without-K --safe #-}
module Cats.Category.Sets.Facts.Product where
open import Data.Bool using (Bool ; true ; false)
open import Data.Product using (_×_ ; _,_ ; proj₁ ; proj₂)
open import Relation.Binary.PropositionalEquality using (_≡_ ; refl ; cong₂)
open import Cats.Category
open import Cats.Category.Sets using (Sets)
import Cats.Category.Sets.Facts.Terminal
instance
hasBinaryProducts : ∀ {l} → HasBinaryProducts (Sets l)
hasBinaryProducts .HasBinaryProducts._×′_ A B = record
{ prod = A × B
; proj = λ where
true → proj₁
false → proj₂
; isProduct = λ p → record
{ arr = λ x → p true x , p false x
; prop = λ where
true → λ _ → refl
false → λ _ → refl
; unique = λ eq x → cong₂ _,_ (eq true x) (eq false x)
}
}
hasFiniteProducts : ∀ {l} → HasFiniteProducts (Sets l)
hasFiniteProducts = record {}
|
{
"alphanum_fraction": 0.625,
"avg_line_length": 27.8787878788,
"ext": "agda",
"hexsha": "9fee3eebd4151780b5f4be086eb84ab1ec3d5a91",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-18T15:35:07.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-18T15:35:07.000Z",
"max_forks_repo_head_hexsha": "1ad7b243acb622d46731e9ae7029408db6e561f1",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "JLimperg/cats",
"max_forks_repo_path": "Cats/Category/Sets/Facts/Product.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "1ad7b243acb622d46731e9ae7029408db6e561f1",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "JLimperg/cats",
"max_issues_repo_path": "Cats/Category/Sets/Facts/Product.agda",
"max_line_length": 76,
"max_stars_count": 24,
"max_stars_repo_head_hexsha": "1ad7b243acb622d46731e9ae7029408db6e561f1",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "JLimperg/cats",
"max_stars_repo_path": "Cats/Category/Sets/Facts/Product.agda",
"max_stars_repo_stars_event_max_datetime": "2021-08-06T05:00:46.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-11-03T15:18:57.000Z",
"num_tokens": 254,
"size": 920
}
|
open import Agda.Builtin.Nat
open import Agda.Builtin.Equality
open import Agda.Builtin.String
open import Agda.Builtin.List
Id : (A : Set) → A → A → Set
Id _ = _≡_
pattern suc² n = suc (suc n)
pattern suc³ n = suc (suc² n)
_ : (n : Nat) → Id Nat (suc³ n) (suc (suc n))
_ = {!!}
data Vec {a} (A : Set a) : Nat → Set a where
[] : Vec A 0
_∷_ : ∀ {n} → A → Vec A n → Vec A (suc n)
pattern [_] x = x ∷ []
foo : List Nat → List Nat
foo [] = {!!}
foo (x ∷ xs) = {!!}
bar : Nat → Nat
bar zero = {!!}
bar (suc zero) = {!!}
bar (suc² n) = {!!}
_ : ∀ x → Id (Vec Nat _) [ x ] [ x ]
_ = {!!}
|
{
"alphanum_fraction": 0.5268456376,
"avg_line_length": 18.0606060606,
"ext": "agda",
"hexsha": "ed5da5487345f7f4f62f8f1bb098a977debad023",
"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/Issue2762.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/Issue2762.agda",
"max_line_length": 45,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/interaction/Issue2762.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": 240,
"size": 596
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Integer division
------------------------------------------------------------------------
module Issue846.OldDivMod where
open import Data.Nat as Nat
open import Data.Nat.Properties
open SemiringSolver
open import Data.Fin as Fin using (Fin; zero; suc; toℕ; fromℕ)
import Data.Fin.Properties as Fin
open import Induction.Nat
open import Relation.Nullary.Decidable
open import Relation.Binary.PropositionalEquality
open ≡-Reasoning
open import Function
------------------------------------------------------------------------
-- Some boring lemmas
private
lem₁ : (m k : ℕ) →
Nat.suc m ≡ suc (toℕ (Fin.inject+ k (fromℕ m)) + 0)
lem₁ m k = cong suc $ begin
m
≡⟨ sym $ Fin.to-from m ⟩
toℕ (fromℕ m)
≡⟨ Fin.inject+-lemma k (fromℕ m) ⟩
toℕ (Fin.inject+ k (fromℕ m))
≡⟨ solve 1 (λ x → x := x :+ con 0) refl _ ⟩
toℕ (Fin.inject+ k (fromℕ m)) + 0
∎
lem₂ : ∀ n → _
lem₂ = solve 1 (λ n → con 1 :+ n := con 1 :+ (n :+ con 0)) refl
lem₃ : ∀ n k q (r : Fin n) eq → suc n + k ≡ toℕ r + suc q * n
lem₃ n k q r eq = begin
suc n + k
≡⟨ solve 2 (λ n k → con 1 :+ n :+ k := n :+ (con 1 :+ k))
refl n k ⟩
n + suc k
≡⟨ cong (_+_ n) eq ⟩
n + (toℕ r + q * n)
≡⟨ solve 3 (λ n r q → n :+ (r :+ q :* n) :=
r :+ (con 1 :+ q) :* n)
refl n (toℕ r) q ⟩
toℕ r + suc q * n
∎
------------------------------------------------------------------------
-- Division
infixl 7 _divMod_ _div_ _mod_
-- A specification of integer division.
record DivMod (dividend divisor : ℕ) : Set where
constructor result
field
quotient : ℕ
remainder : Fin divisor
property : dividend ≡ toℕ remainder + quotient * divisor
-- Integer division with remainder.
-- Note that Induction.Nat.<-rec is used to establish termination of
-- division. The run-time complexity of this implementation of integer
-- division should be linear in the size of the dividend, assuming
-- that well-founded recursion and the equality type are optimised
-- properly (see "Inductive Families Need Not Store Their Indices"
-- (Brady, McBride, McKinna, TYPES 2003)).
_divMod_ : (dividend divisor : ℕ) {≢0 : False (divisor ≟ 0)} →
DivMod dividend divisor
_divMod_ m n {≢0} = <-rec Pred dm m n {≢0}
where
Pred : ℕ → Set
Pred dividend = (divisor : ℕ) {≢0 : False (divisor ≟ 0)} →
DivMod dividend divisor
1+_ : ∀ {k n} → DivMod (suc k) n → DivMod (suc n + k) n
1+_ {k} {n} (result q r eq) = result (1 + q) r (lem₃ n k q r eq)
dm : (dividend : ℕ) → <-Rec Pred dividend → Pred dividend
dm m rec zero {≢0 = ()}
dm zero rec (suc n) = result 0 zero refl
dm (suc m) rec (suc n) with compare m n
dm (suc m) rec (suc .(suc m + k)) | less .m k = result 0 r (lem₁ m k)
where r = suc (Fin.inject+ k (fromℕ m))
dm (suc m) rec (suc .m) | equal .m = result 1 zero (lem₂ m)
dm (suc .(suc n + k)) rec (suc n) | greater .n k =
1+ rec (suc k) le (suc n)
where le = s≤′s (s≤′s (n≤′m+n n k))
-- Integer division.
_div_ : (dividend divisor : ℕ) {≢0 : False (divisor ≟ 0)} → ℕ
_div_ m n {≢0} = DivMod.quotient $ _divMod_ m n {≢0}
-- The remainder after integer division.
_mod_ : (dividend divisor : ℕ) {≢0 : False (divisor ≟ 0)} → Fin divisor
_mod_ m n {≢0} = DivMod.remainder $ _divMod_ m n {≢0}
|
{
"alphanum_fraction": 0.5219457646,
"avg_line_length": 33.1203703704,
"ext": "agda",
"hexsha": "56030c1b6c8b44903cdd9db4979de0d7e7ac2d56",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "redfish64/autonomic-agda",
"max_forks_repo_path": "test/LibSucceed/Issue846/OldDivMod.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "redfish64/autonomic-agda",
"max_issues_repo_path": "test/LibSucceed/Issue846/OldDivMod.agda",
"max_line_length": 79,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "redfish64/autonomic-agda",
"max_stars_repo_path": "test/LibSucceed/Issue846/OldDivMod.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": 1192,
"size": 3577
}
|
postulate
A : Set
T : A → Set
g : {{a : A}} → Set → T a
test : {{a b : A}} → Set
test {{a}} {{b}} = {!g A!} -- C-u C-u C-c C-d gives T b
|
{
"alphanum_fraction": 0.4068965517,
"avg_line_length": 16.1111111111,
"ext": "agda",
"hexsha": "4d1fe4041df7e4a585de9400ef0b8d143ecc3376",
"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/Issue2568.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/Issue2568.agda",
"max_line_length": 55,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/interaction/Issue2568.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": 67,
"size": 145
}
|
module _ where
module A where
syntax c x = ⟦ x
data D₁ : Set where
b : D₁
c : D₁ → D₁
module B where
syntax c x = ⟦ x ⟧
data D₂ : Set where
c : A.D₁ → D₂
open A
open B
test₁ : D₂
test₁ = ⟦ (⟦ c b) ⟧
test₂ : D₂ → D₁
test₂ ⟦ x ⟧ = ⟦ x
test₃ : D₁ → D₂
test₃ b = c b
test₃ (⟦ x) = ⟦ x ⟧
test₄ : D₁ → D₂
test₄ A.b = B.c A.b
test₄ (A.⟦ x) = B.⟦ x ⟧
test₅ : D₂ → D₁
test₅ B.⟦ x ⟧ = A.⟦ x
-- Should work.
|
{
"alphanum_fraction": 0.49543379,
"avg_line_length": 11.2307692308,
"ext": "agda",
"hexsha": "837b73c4a2632e08762eccc4ff44047453e8b7f5",
"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/Issue1194e.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/Issue1194e.agda",
"max_line_length": 23,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/Issue1194e.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": 226,
"size": 438
}
|
module simpleAgda where
-- main : IO ()
-- main = putStrLn "Testing simple Idris"
--
-- Some simple equivalent Idris and Agda code.
--
-- data N = Z | Suc N
data N : Set where
Z : N
suc : N -> N
-- one : N
-- one = Suc Z
one : N
one = suc Z
-- addOne : N -> N
-- addOne Z = Suc Z
-- addOne (Suc n) = Suc (Suc n)
addOne : N -> N
addOne Z = suc Z
addOne (suc a) = suc (suc a)
-- add : N -> N -> N
-- add Z s = s
-- add (Suc a) b = add a (Suc b)
add : N -> N -> N
add Z s = s
add (suc a) b = add a (suc b)
-- data Vec : Type -> N -> Type where
-- Nil : Vec a Z
-- (::) : a -> Vec a n -> Vec a (Suc n)
data Vec (A : Set) : N -> Set where
Nil : Vec A Z
cons : {n : N} -> A -> Vec A n -> Vec A (suc n)
-- empt : Vec N Z
-- empt = Nil
empt : Vec N Z
empt = Nil
open import Agda.Builtin.Nat
-- test : Vec Nat (Suc Main.one)
-- test = 1 :: 2 :: Nil
test : Vec Nat (suc (suc Z))
test = cons 1 (cons 2 Nil)
-- test2 : Vec Nat (Suc (Suc Main.one))
-- test2 = 3 :: 4 :: 5 :: Nil
test2 : Vec Nat (suc (suc (suc Z)))
test2 = cons 3 (cons 4 (cons 5 Nil))
-- concat : Vec g a -> Vec g b -> Vec g (add a b)
-- concat Nil rest = rest
-- concat (a :: rest) b = concat rest (a :: b)
concat : {a b : N} {g : Set} -> (Vec g a) -> (Vec g b) -> (Vec g (add a b))
concat Nil rest = rest
concat (cons a rest) b = concat rest (cons a b)
-- t3 : Vec (addOne $ addOne $ addOne $ addOne Main.one) Nat
-- t3 = concat test test2
t3 : Vec Nat (addOne (addOne (addOne (addOne one))))
t3 = concat test test2
|
{
"alphanum_fraction": 0.5439414115,
"avg_line_length": 21.768115942,
"ext": "agda",
"hexsha": "4ae8c4c37f722608110d621384f8130f94efb44e",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-11-27T16:25:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-11-27T16:25:18.000Z",
"max_forks_repo_head_hexsha": "a5f65e28cc9fdfefde49e7d8cf84486601b9e7b1",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "hjorthjort/IdrisToAgda",
"max_forks_repo_path": "simpleAgda.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "a5f65e28cc9fdfefde49e7d8cf84486601b9e7b1",
"max_issues_repo_issues_event_max_datetime": "2019-11-28T17:52:42.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-11-28T17:52:42.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "hjorthjort/IdrisToAgda",
"max_issues_repo_path": "simpleAgda.agda",
"max_line_length": 75,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "a5f65e28cc9fdfefde49e7d8cf84486601b9e7b1",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "hjorthjort/IdrisToAgda",
"max_stars_repo_path": "simpleAgda.agda",
"max_stars_repo_stars_event_max_datetime": "2020-06-29T20:42:43.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-02-16T23:22:50.000Z",
"num_tokens": 567,
"size": 1502
}
|
-- Andreas, 2015-07-10, issue reported by asr
-- {-# OPTIONS -v scope:20 #-}
-- {-# OPTIONS -v scope.createModule:10 #-}
module _ where
module A where
module Y where
module B where
-- FAILS:
module X = A
open X public
-- open A public --WORKS
module C = B
-- On maint and master:
-- An internal error has occurred. Please report this as a bug.
-- Location of the error: src/full/Agda/Syntax/Scope/Monad.hs:107
{-
createModule Issue1607.C
module macro
ScopeInfo
current = Issue1607
context = TopCtx
modules
scope
scope Issue1607
public
modules
A --> [Issue1607.A]
B --> [Issue1607.B]
scope Issue1607.A
public
modules
Y --> [Issue1607.A.Y]
scope Issue1607.A.Y
scope Issue1607.B
public
modules
X --> [Issue1607.B.X]
Y --> [Issue1607.B.X.Y]
scope Issue1607.B.X
public
modules
Y --> [Issue1607.B.X.Y]
scope Issue1607.B.X.Y
scope Issue1607.C
Copying scope Issue1607.B to Issue1607.C
createModule Issue1607.C.X
Copying scope Issue1607.B.X to Issue1607.C.X
createModule Issue1607.C.X.Y
Copying scope Issue1607.B.X.Y to Issue1607.C.X.Y
createModule Issue1607.C.X.Y
Copying scope Issue1607.B.X.Y to Issue1607.C.X.Y
-}
|
{
"alphanum_fraction": 0.6387802971,
"avg_line_length": 21.6779661017,
"ext": "agda",
"hexsha": "032b0674aab4bd51a629655b6c817fa029099c5a",
"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/Issue1607.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/Issue1607.agda",
"max_line_length": 65,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/Issue1607.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": 385,
"size": 1279
}
|
module Foundation.Bottom where
open import Foundation.Primitive
record IsBottom {ℓ-⊥} (⊥ : Set ℓ-⊥) ℓ-elim : ℞ ⟰ ℓ-elim ⊔ ℓ-⊥ where
field
⊥-elim : ⊥ → {A : Set ℓ-elim} → A
open IsBottom ⦃ … ⦄ public
record Bottom ℓ-⊥ ℓ-elim : ℞₁ ℓ-elim ⊔ ℓ-⊥ where
field
⊥ : Set ℓ-⊥
instance ⦃ isBottom ⦄ : IsBottom ⊥ ℓ-elim
¬_ : ∀ {a} → Set a → ℞ a ⊔ ℓ-⊥
¬_ p = p → ⊥
open Bottom ⦃ … ⦄ public
|
{
"alphanum_fraction": 0.551980198,
"avg_line_length": 19.2380952381,
"ext": "agda",
"hexsha": "b4777c70063590a895d185589be976bf947d24c2",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_forks_repo_licenses": [
"RSA-MD"
],
"max_forks_repo_name": "m0davis/oscar",
"max_forks_repo_path": "archive/agda-1/Foundation/Bottom.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z",
"max_issues_repo_licenses": [
"RSA-MD"
],
"max_issues_repo_name": "m0davis/oscar",
"max_issues_repo_path": "archive/agda-1/Foundation/Bottom.agda",
"max_line_length": 67,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_stars_repo_licenses": [
"RSA-MD"
],
"max_stars_repo_name": "m0davis/oscar",
"max_stars_repo_path": "archive/agda-1/Foundation/Bottom.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 205,
"size": 404
}
|
{-
Define finitely generated ideals of commutative rings and
show that they are an ideal.
Parts of this should be reusable for explicit constructions
of free modules over a finite set.
-}
{-# OPTIONS --safe #-}
module Cubical.Algebra.CommRing.FGIdeal where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Powerset
open import Cubical.Foundations.HLevels
open import Cubical.Data.Sigma
open import Cubical.Data.FinData hiding (elim)
open import Cubical.Data.Nat using (ℕ)
open import Cubical.HITs.PropositionalTruncation
open import Cubical.Algebra.CommRing
open import Cubical.Algebra.CommRing.Ideal
open import Cubical.Algebra.Ring.QuotientRing
open import Cubical.Algebra.Ring.Properties
open import Cubical.Algebra.Ring.BigOps
open import Cubical.Algebra.RingSolver.ReflectionSolving
private
variable
ℓ : Level
module _ (Ring@(R , str) : CommRing ℓ) where
infixr 5 _holds
_holds : hProp ℓ → Type ℓ
P holds = fst P
open CommRingStr str
open RingTheory (CommRing→Ring Ring)
open Sum (CommRing→Ring Ring)
linearCombination : {n : ℕ} → FinVec R n → FinVec R n → R
linearCombination α V = ∑ (λ i → α i · V i)
sumDist+ : ∀ {n : ℕ} (α β V : FinVec R n)
→ linearCombination (λ i → α i + β i) V ≡ linearCombination α V + linearCombination β V
sumDist+ α β V = ∑Ext (λ i → ·Ldist+ (α i) (β i) (V i)) ∙ ∑Split (λ i → α i · V i) (λ i → β i · V i)
dist- : ∀ {n : ℕ} (α V : FinVec R n)
→ linearCombination (λ i → - α i) V ≡ - linearCombination α V
dist- α V = ∑Ext (λ i → -DistL· (α i) (V i)) ∙ ∑Dist- (λ i → α i · V i)
dist0 : ∀ {n : ℕ} (V : FinVec R n)
→ linearCombination (replicateFinVec n 0r) V ≡ 0r
dist0 {n = n} V = ∑Ext (λ i → 0LeftAnnihilates (V i)) ∙ ∑0r n
isLinearCombination : {n : ℕ} → FinVec R n → R → Type ℓ
isLinearCombination V x = ∃[ α ∈ FinVec R _ ] x ≡ linearCombination α V
{- If x and y are linear combinations of l, then (x + y) is
a linear combination. -}
isLinearCombination+ : {n : ℕ} {x y : R} (V : FinVec R n)
→ isLinearCombination V x
→ isLinearCombination V y
→ isLinearCombination V (x + y)
isLinearCombination+ V = map2 λ α β → (λ i → α .fst i + β .fst i)
, cong₂ (_+_) (α .snd) (β .snd) ∙ sym (sumDist+ _ _ V)
{- If x is a linear combinations of l, then -x is
a linear combination. -}
isLinearCombination- : {n : ℕ} {x : R} (V : FinVec R n)
→ isLinearCombination V x → isLinearCombination V (- x)
isLinearCombination- V = map λ α → (λ i → - α .fst i) , cong (-_) (α .snd) ∙ sym (dist- _ V)
{- 0r is the trivial linear Combination -}
isLinearCombination0 : {n : ℕ} (V : FinVec R n)
→ isLinearCombination V 0r
isLinearCombination0 V = ∣ _ , sym (dist0 V) ∣
{- Linear combinations are stable under left multiplication -}
isLinearCombinationL· : {n : ℕ} (V : FinVec R n) (r : R) {x : R}
→ isLinearCombination V x → isLinearCombination V (r · x)
isLinearCombinationL· V r = map λ α → (λ i → r · α .fst i) , cong (r ·_) (α .snd)
∙∙ ∑Mulrdist r (λ i → α .fst i · V i)
∙∙ ∑Ext λ i → ·Assoc r (α .fst i) (V i)
generatedIdeal : {n : ℕ} → FinVec R n → IdealsIn Ring
generatedIdeal V = makeIdeal Ring
(λ x → isLinearCombination V x , isPropPropTrunc)
(isLinearCombination+ V)
(isLinearCombination0 V)
λ r → isLinearCombinationL· V r
open isCommIdeal
genIdeal : {n : ℕ} (R : CommRing ℓ) → FinVec (fst R) n → CommIdeal R
fst (genIdeal R V) x = isLinearCombination R V x , isPropPropTrunc
+Closed (snd (genIdeal R V)) = isLinearCombination+ R V
contains0 (snd (genIdeal R V)) = isLinearCombination0 R V
·Closed (snd (genIdeal R V)) r = isLinearCombinationL· R V r
syntax genIdeal R V = ⟨ V ⟩[ R ]
FGIdealIn : (R : CommRing ℓ) → Type (ℓ-suc ℓ)
FGIdealIn R = Σ[ I ∈ CommIdeal R ] ∃[ n ∈ ℕ ] ∃[ V ∈ FinVec (fst R) n ] I ≡ ⟨ V ⟩[ R ]
|
{
"alphanum_fraction": 0.5900047371,
"avg_line_length": 40.2095238095,
"ext": "agda",
"hexsha": "155828212dfb936e09bc1de6b9af34708d70f698",
"lang": "Agda",
"max_forks_count": 134,
"max_forks_repo_forks_event_max_datetime": "2022-03-23T16:22:13.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-11-16T06:11:03.000Z",
"max_forks_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "marcinjangrzybowski/cubical",
"max_forks_repo_path": "Cubical/Algebra/CommRing/FGIdeal.agda",
"max_issues_count": 584,
"max_issues_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237",
"max_issues_repo_issues_event_max_datetime": "2022-03-30T12:09:17.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-10-15T09:49:02.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "marcinjangrzybowski/cubical",
"max_issues_repo_path": "Cubical/Algebra/CommRing/FGIdeal.agda",
"max_line_length": 102,
"max_stars_count": 301,
"max_stars_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "marcinjangrzybowski/cubical",
"max_stars_repo_path": "Cubical/Algebra/CommRing/FGIdeal.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-24T02:10:47.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-10-17T18:00:24.000Z",
"num_tokens": 1374,
"size": 4222
}
|
open import Prelude
open import Nat
open import dynamics-core
open import contexts
module lemmas-gcomplete where
-- if you add a complete type to a complete context, the result is also a
-- complete context
gcomp-extend : ∀{Γ τ x} → Γ gcomplete → τ tcomplete → x # Γ → (Γ ,, (x , τ)) gcomplete
gcomp-extend {Γ} {τ} {x} gc tc apart x_query τ_query x₁ with natEQ x x_query
gcomp-extend {Γ} {τ} {x} gc tc apart .x τ_query x₂ | Inl refl = tr (λ qq → qq tcomplete) (someinj x₂) tc
gcomp-extend {Γ} {τ} {x} gc tc apart x_query τ_query x₂ | Inr x₁ = gc x_query τ_query x₂
|
{
"alphanum_fraction": 0.6903114187,
"avg_line_length": 44.4615384615,
"ext": "agda",
"hexsha": "ab574168bea29ca8fae0a20e7b820692ac5c8acc",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "hazelgrove/hazelnut-agda",
"max_forks_repo_path": "lemmas-gcomplete.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "hazelgrove/hazelnut-agda",
"max_issues_repo_path": "lemmas-gcomplete.agda",
"max_line_length": 106,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "hazelgrove/hazelnut-agda",
"max_stars_repo_path": "lemmas-gcomplete.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 202,
"size": 578
}
|
{-# OPTIONS --without-K #-}
module FinVecProperties where
open import Data.Nat using (ℕ; _+_; _*_)
open import Data.Fin using (Fin; zero; suc; inject+; raise)
open import Data.Sum using (inj₁; inj₂; [_,_]′)
open import Data.Product using (_×_; proj₁; proj₂; _,′_)
open import Data.Vec
using (Vec; []; _∷_; tabulate; allFin)
renaming (_++_ to _++V_; concat to concatV; map to mapV)
open import Data.Vec.Properties
using (tabulate∘lookup; lookup∘tabulate; lookup-allFin;
lookup-++-inject+; tabulate-∘)
open import Relation.Binary.PropositionalEquality
using (_≡_; refl; sym; trans; cong; cong₂; module ≡-Reasoning)
open import Function using (_∘_; id)
--
open import Equiv using (_∼_; p∘!p≡id)
open import FinEquiv using (module Plus; module Times; module PlusTimes)
open import FinVec using (FinVec; 0C; 1C; _∘̂_; _⊎c_; _×c_;
unite+; uniti+; unite+r; uniti+r;
swap+cauchy; assocl+; assocr+;
unite*; uniti*; unite*r; uniti*r;
swap⋆cauchy; assocl*; assocr*;
dist*+; factor*+; distl*+; factorl*+;
right-zero*l; right-zero*r
)
open import Proofs using (
-- FiniteFunctions
finext;
-- VectorLemmas
_!!_; lookupassoc; unSplit; lookup-++-raise; tabulate-split;
concat-map; left!!; right!!; map-map-map; lookup-map; map-∘
)
------------------------------------------------------------------------------
-- Two ways for reasoning about permutations: we use whichever is more
-- convenient in each context
-- I: we can reason about permutations by looking at their action at
-- every index. This exposes the underlying raw vectors...
infix 4 _∼p_
_∼p_ : {n m : ℕ} (p₁ p₂ : Vec (Fin m) n) → Set
_∼p_ {n} p₁ p₂ = (i : Fin n) → p₁ !! i ≡ p₂ !! i
∼p⇒≡ : {n : ℕ} {p₁ p₂ : Vec (Fin n) n} → (p₁ ∼p p₂) → p₁ ≡ p₂
∼p⇒≡ {n} {p₁} {p₂} eqv =
begin (
p₁ ≡⟨ sym (tabulate∘lookup p₁) ⟩
tabulate (_!!_ p₁) ≡⟨ finext eqv ⟩
tabulate (_!!_ p₂) ≡⟨ tabulate∘lookup p₂ ⟩
p₂ ∎)
where open ≡-Reasoning
cauchyext : {m n : ℕ} (π : FinVec m n) → tabulate (_!!_ π) ≡ π
-- this is just tabulate∘lookup, but it hides the details; should this
-- be called 'join' or 'flatten' ?
cauchyext π = tabulate∘lookup π
1C!!i≡i : ∀ {m} {i : Fin m} → 1C {m} !! i ≡ i
1C!!i≡i = lookup∘tabulate id _
!!⇒∘̂ : {n₁ n₂ n₃ : ℕ} →
(π₁ : Vec (Fin n₁) n₂) → (π₂ : Vec (Fin n₂) n₃) → (i : Fin n₃) →
π₁ !! (π₂ !! i) ≡ (π₂ ∘̂ π₁) !! i
!!⇒∘̂ π₁ π₂ i =
begin (
π₁ !! (π₂ !! i)
≡⟨ sym (lookup∘tabulate (λ j → (π₁ !! (π₂ !! j))) i) ⟩
tabulate (λ i → π₁ !! (π₂ !! i)) !! i
≡⟨ refl ⟩
(π₂ ∘̂ π₁) !! i ∎)
where open ≡-Reasoning
-- II: we can relate compositions of permutations of type equivalences
-- and pull back properties of permutations from properties of
-- equivalences
∘̂⇒∘ : {m n o : ℕ} → (f : Fin m → Fin n) → (g : Fin n → Fin o) →
tabulate f ∘̂ tabulate g ∼p tabulate (g ∘ f)
-- note the flip!
∘̂⇒∘ f g i =
begin (
(tabulate f ∘̂ tabulate g) !! i
≡⟨ lookup∘tabulate _ i ⟩
(tabulate g) !! (tabulate f !! i)
≡⟨ lookup∘tabulate _ (tabulate f !! i) ⟩
g (tabulate f !! i)
≡⟨ cong g (lookup∘tabulate f i) ⟩
g (f i)
≡⟨ sym (lookup∘tabulate (g ∘ f) i) ⟩
tabulate (g ∘ f) !! i ∎)
where open ≡-Reasoning
-- we could go through ~p, but this works better in practice
~⇒≡ : {m n : ℕ} {f : Fin m → Fin n} {g : Fin n → Fin m} →
(f ∘ g ∼ id) → (tabulate g ∘̂ tabulate f ≡ 1C)
~⇒≡ {f = f} {g} β =
∼p⇒≡ (λ i → trans (∘̂⇒∘ g f i) (cong (λ x → x !! i) (finext β)))
------------------------------------------------------------------------------
-- A permutation and its inverse compose to the identity
--
-- Here we just exploit the connection to type equivalences to get all
-- the properties for free.
-- additives
unite+∘̂uniti+~id : ∀ {m} → (unite+ {m}) ∘̂ uniti+ ≡ 1C {m}
unite+∘̂uniti+~id {m} = ~⇒≡ {m} {n = m} (p∘!p≡id {p = Plus.unite+ {m}})
uniti+∘̂unite+~id : ∀ {m} → (uniti+ {m}) ∘̂ unite+ ≡ 1C {m}
uniti+∘̂unite+~id {m} = ~⇒≡ {m} {n = m} (p∘!p≡id {p = Plus.uniti+})
unite+r∘̂uniti+r~id : ∀ {m} → (unite+r {m}) ∘̂ uniti+r ≡ 1C {m + 0}
unite+r∘̂uniti+r~id {m} = ~⇒≡ {m} (p∘!p≡id {p = Plus.unite+r {m}})
uniti+r∘̂unite+r~id : ∀ {m} → (uniti+r {m}) ∘̂ unite+r ≡ 1C {m}
uniti+r∘̂unite+r~id {m} = ~⇒≡ (p∘!p≡id {p = Plus.uniti+r})
swap+-inv : ∀ {m n} → swap+cauchy m n ∘̂ swap+cauchy n m ≡ 1C
swap+-inv {m} {n} = ~⇒≡ (Plus.swap-inv m n)
assocl+∘̂assocr+~id : ∀ {m n o} → assocl+ {m} {n} {o} ∘̂ assocr+ {m} ≡ 1C
assocl+∘̂assocr+~id {m} {_} {o} = ~⇒≡ (p∘!p≡id {p = Plus.assocl+ {m}})
assocr+∘̂assocl+~id : ∀ {m n o} → assocr+ {m} {n} {o} ∘̂ assocl+ {m} ≡ 1C
assocr+∘̂assocl+~id {m} {_} {o} = ~⇒≡ (p∘!p≡id {p = Plus.assocr+ {m}})
-- multiplicatives
unite*∘̂uniti*~id : ∀ {m} → (unite* {m}) ∘̂ uniti* ≡ 1C {1 * m}
unite*∘̂uniti*~id {m} = ~⇒≡ {m} {n = 1 * m} (p∘!p≡id {p = Times.unite* {m}})
uniti*∘̂unite*~id : ∀ {m} → (uniti* {m}) ∘̂ unite* ≡ 1C {m}
uniti*∘̂unite*~id {m} = ~⇒≡ {1 * m} {n = m} (p∘!p≡id {p = Times.uniti* {m}})
unite*r∘̂uniti*r~id : ∀ {m} → (unite*r {m}) ∘̂ uniti*r ≡ 1C {m * 1}
unite*r∘̂uniti*r~id {m} = ~⇒≡ {m} {n = m * 1} (p∘!p≡id {p = Times.unite*r {m}})
uniti*r∘̂unite*r~id : ∀ {m} → (uniti*r {m}) ∘̂ unite*r ≡ 1C {m}
uniti*r∘̂unite*r~id {m} = ~⇒≡ {m * 1} {n = m} (p∘!p≡id {p = Times.uniti*r {m}})
swap*-inv : ∀ {m n} → swap⋆cauchy m n ∘̂ swap⋆cauchy n m ≡ 1C
swap*-inv {m} {n} = ~⇒≡ (Times.swap-inv m n)
assocl*∘̂assocr*~id : ∀ {m n o} → assocl* {m} {n} {o} ∘̂ assocr* {m} ≡ 1C
assocl*∘̂assocr*~id {m} {_} {o} = ~⇒≡ (p∘!p≡id {p = Times.assocl* {m}})
assocr*∘̂assocl*~id : ∀ {m n o} → assocr* {m} {n} {o} ∘̂ assocl* {m} ≡ 1C
assocr*∘̂assocl*~id {m} {_} {o} = ~⇒≡ (p∘!p≡id {p = Times.assocr* {m}})
-- Distributivity
right-zero*l∘̂right-zero*r~id : ∀ {m} →
right-zero*l {m} ∘̂ right-zero*r {m} ≡ 1C {m * 0}
right-zero*l∘̂right-zero*r~id {m} =
~⇒≡ {f = proj₁ (PlusTimes.factorzr {m})} (p∘!p≡id {p = PlusTimes.distzr {m}})
right-zero*r∘̂right-zero*l~id : ∀ {m} → right-zero*r {m} ∘̂ right-zero*l {m} ≡ 1C
right-zero*r∘̂right-zero*l~id {m} =
~⇒≡ { f = proj₁ (PlusTimes.factorz {m})} (p∘!p≡id {p = PlusTimes.distz {m}})
dist*+∘̂factor*+~id : ∀ {m n o} → dist*+ {m} {n} {o} ∘̂ factor*+ {m} ≡ 1C
dist*+∘̂factor*+~id {m} {_} {o} = ~⇒≡ (p∘!p≡id {p = PlusTimes.dist {m}})
factor*+∘̂dist*+~id : ∀ {m n o} → factor*+ {m} {n} {o} ∘̂ dist*+ {m} ≡ 1C
factor*+∘̂dist*+~id {m} {_} {o} = ~⇒≡ (p∘!p≡id {p = PlusTimes.factor {m}})
distl*+∘̂factorl*+~id : ∀ {m n o} → distl*+ {m} {n} {o} ∘̂ factorl*+ {m} ≡ 1C
distl*+∘̂factorl*+~id {m} {_} {o} = ~⇒≡ (p∘!p≡id {p = PlusTimes.distl {m}})
factorl*+∘̂distl*+~id : ∀ {m n o} → factorl*+ {m} {n} {o} ∘̂ distl*+ {m} ≡ 1C
factorl*+∘̂distl*+~id {m} {_} {o} = ~⇒≡ (p∘!p≡id {p = PlusTimes.factorl {m}})
------------------------------------------------------------------------------
-- Now the main properties of sequential composition
0C∘̂0C≡0C : 1C {0} ∘̂ 1C {0} ≡ 1C {0}
0C∘̂0C≡0C = refl
∘̂-assoc : {m₁ m₂ m₃ m₄ : ℕ} →
(a : Vec (Fin m₂) m₁) (b : Vec (Fin m₃) m₂) (c : Vec (Fin m₄) m₃) →
a ∘̂ (b ∘̂ c) ≡ (a ∘̂ b) ∘̂ c
∘̂-assoc a b c = finext (lookupassoc a b c)
∘̂-rid : {m n : ℕ} → (π : Vec (Fin m) n) → π ∘̂ 1C ≡ π
∘̂-rid π = trans (finext (λ i → lookup-allFin (π !! i))) (cauchyext π)
∘̂-lid : {m n : ℕ} → (π : Vec (Fin m) n) → 1C ∘̂ π ≡ π
∘̂-lid π = trans (finext (λ i → cong (_!!_ π) (lookup-allFin i))) (cauchyext π)
--
1C₀⊎x≡x : ∀ {m n} {x : FinVec m n} → 1C {0} ⊎c x ≡ x
1C₀⊎x≡x {x = x} = cauchyext x
unite+∘[0⊎x]≡x∘unite+ : ∀ {m n} {x : FinVec m n} →
unite+ ∘̂ (1C {0} ⊎c x) ≡ x ∘̂ unite+
unite+∘[0⊎x]≡x∘unite+ {m} {n} {x} = finext pf
where
pf : (i : Fin n) → (0C ⊎c x) !! (unite+ !! i) ≡ unite+ !! (x !! i)
pf i =
begin (
tabulate (λ y → x !! y) !! (tabulate id !! i)
≡⟨ cong (λ j → tabulate (λ y → x !! y) !! j) (lookup∘tabulate id i) ⟩
tabulate (λ y → x !! y) !! i
≡⟨ lookup∘tabulate (_!!_ x) i ⟩
x !! i
≡⟨ sym (lookup∘tabulate id (x !! i)) ⟩
tabulate id !! (x !! i) ∎)
where open ≡-Reasoning
uniti+∘x≡[0⊎x]∘uniti+ : ∀ {m n} {x : FinVec m n} →
uniti+ ∘̂ x ≡ (1C {0} ⊎c x) ∘̂ uniti+
uniti+∘x≡[0⊎x]∘uniti+ {m} {n} {x} = finext pf
where
pf : (i : Fin n) → x !! (uniti+ !! i) ≡ uniti+ !! ((0C ⊎c x) !! i)
pf i = begin (
x !! (tabulate id !! i)
≡⟨ cong (_!!_ x) (lookup∘tabulate id i) ⟩
x !! i
≡⟨ sym (lookup∘tabulate (λ y → x !! y) i) ⟩
tabulate (λ y → x !! y) !! i
≡⟨ sym (lookup∘tabulate id _) ⟩
tabulate id !! (tabulate (λ y → x !! y) !! i) ∎)
where open ≡-Reasoning
1C⊎1C≡1C : ∀ {m n} → 1C {m} ⊎c 1C {n} ≡ 1C
1C⊎1C≡1C {m} {n} =
begin (
tabulate {m} (inject+ n ∘ _!!_ 1C) ++V tabulate {n} (raise m ∘ _!!_ 1C)
≡⟨ cong₂ (_++V_ {m = m})
(finext (λ i → cong (inject+ n) (lookup-allFin i)))
(finext (λ i → cong (raise m) (lookup-allFin i))) ⟩
tabulate {m} (inject+ n) ++V tabulate {n} (raise m)
≡⟨ unSplit {m} id ⟩
tabulate {m + n} id ∎)
where open ≡-Reasoning
idˡ⊕ : ∀ {m n} {x : FinVec m n} → uniti+ ∘̂ (1C {0} ⊎c x) ≡ x ∘̂ uniti+
idˡ⊕ {m} {n} {x} = finext pf
where
open ≡-Reasoning
pf : (i : Fin n) → (1C {0} ⊎c x) !! (uniti+ !! i) ≡ (uniti+ !! (x !! i))
pf i = begin (
tabulate (λ y → x !! y) !! (tabulate id !! i)
≡⟨ cong (_!!_ (tabulate λ y → x !! y)) (lookup∘tabulate id i) ⟩
(tabulate (λ y → x !! y)) !! i
≡⟨ lookup∘tabulate (λ y → x !! y) i ⟩
x !! i
≡⟨ sym (lookup∘tabulate id (x !! i)) ⟩
tabulate id !! (x !! i) ∎)
-- [,]-commute : {A B C D E : Set} → {f : A → C} → {g : B → C} → {h : C → D} →
-- ∀ x → h ([ f , g ]′ x) ≡ [ (h ∘ f) , (h ∘ g) ]′ x
-- [,]-commute (inj₁ x) = refl
-- [,]-commute (inj₂ y) = refl
--
private
left⊎⊎!! : ∀ {m₁ m₂ m₃ m₄ n₁ n₂} → (p₁ : FinVec m₁ n₁) → (p₂ : FinVec m₂ n₂)
→ (p₃ : FinVec m₃ m₁) → (p₄ : FinVec m₄ m₂) → (i : Fin n₁) →
(p₃ ⊎c p₄) !! ( (p₁ ⊎c p₂) !! inject+ n₂ i ) ≡ inject+ m₄ ( (p₁ ∘̂ p₃) !! i)
left⊎⊎!! {m₁} {m₂} {_} {m₄} {_} {n₂} p₁ p₂ p₃ p₄ i =
let pp = p₃ ⊎c p₄ in
let qq = p₁ ⊎c p₂ in
begin (
pp !! (qq !! inject+ n₂ i)
≡⟨ cong
(_!!_ pp)
(lookup-++-inject+
(tabulate (inject+ m₂ ∘ _!!_ p₁))
(tabulate (raise m₁ ∘ _!!_ p₂))
i) ⟩
pp !! (tabulate (inject+ m₂ ∘ _!!_ p₁ ) !! i)
≡⟨ cong (_!!_ pp) (lookup∘tabulate _ i) ⟩
pp !! (inject+ m₂ (p₁ !! i))
≡⟨ left!! (p₁ !! i) (inject+ m₄ ∘ (_!!_ p₃)) ⟩
inject+ m₄ (p₃ !! (p₁ !! i))
≡⟨ cong (inject+ m₄) (sym (lookup∘tabulate _ i)) ⟩
inject+ m₄ ((p₁ ∘̂ p₃) !! i) ∎ )
where open ≡-Reasoning
right⊎⊎!! : ∀ {m₁ m₂ m₃ m₄ n₁ n₂} → (p₁ : FinVec m₁ n₁) → (p₂ : FinVec m₂ n₂)
→ (p₃ : FinVec m₃ m₁) → (p₄ : FinVec m₄ m₂) → (i : Fin n₂) →
(p₃ ⊎c p₄) !! ( (p₁ ⊎c p₂) !! raise n₁ i ) ≡ raise m₃ ( (p₂ ∘̂ p₄) !! i)
right⊎⊎!! {m₁} {m₂} {m₃} {_} {n₁} {_} p₁ p₂ p₃ p₄ i =
let pp = p₃ ⊎c p₄ in
let qq = p₁ ⊎c p₂ in
begin (
pp !! (qq !! raise n₁ i)
≡⟨ cong
(_!!_ pp)
(lookup-++-raise
(tabulate (inject+ m₂ ∘ _!!_ p₁))
(tabulate (raise m₁ ∘ _!!_ p₂))
i) ⟩
pp !! (tabulate (raise m₁ ∘ _!!_ p₂) !! i)
≡⟨ cong (_!!_ pp) (lookup∘tabulate _ i) ⟩
pp !! raise m₁ (p₂ !! i)
≡⟨ right!! {m₁} (p₂ !! i) (raise m₃ ∘ (_!!_ p₄)) ⟩
raise m₃ (p₄ !! (p₂ !! i))
≡⟨ cong (raise m₃) (sym (lookup∘tabulate _ i)) ⟩
raise m₃ ((p₂ ∘̂ p₄) !! i) ∎ )
where open ≡-Reasoning
⊎c-distrib : ∀ {m₁ m₂ m₃ m₄ n₁ n₂} → {p₁ : FinVec m₁ n₁} → {p₂ : FinVec m₂ n₂}
→ {p₃ : FinVec m₃ m₁} → {p₄ : FinVec m₄ m₂} →
(p₁ ⊎c p₂) ∘̂ (p₃ ⊎c p₄) ≡ (p₁ ∘̂ p₃) ⊎c (p₂ ∘̂ p₄)
⊎c-distrib {m₁} {m₂} {m₃} {m₄} {n₁} {n₂} {p₁} {p₂} {p₃} {p₄} =
let p₃₄ = p₃ ⊎c p₄ in let p₁₂ = p₁ ⊎c p₂ in
let lhs = λ i → p₃₄ !! (p₁₂ !! i) in
begin (
tabulate lhs
≡⟨ tabulate-split {n₁} {n₂} ⟩
tabulate {n₁} (lhs ∘ inject+ n₂) ++V tabulate {n₂} (lhs ∘ raise n₁)
≡⟨ cong₂ _++V_
(finext (left⊎⊎!! p₁ _ _ _))
(finext (right⊎⊎!! p₁ _ _ _)) ⟩
tabulate {n₁} (λ i → inject+ m₄ ((p₁ ∘̂ p₃) !! i)) ++V
tabulate {n₂} (λ i → raise m₃ ((p₂ ∘̂ p₄) !! i))
≡⟨ refl ⟩
(p₁ ∘̂ p₃) ⊎c (p₂ ∘̂ p₄) ∎)
where open ≡-Reasoning
private
concat!! : {A : Set} {m n : ℕ} → (a : Fin m) → (b : Fin n) →
(xss : Vec (Vec A n) m) →
concatV xss !! (Times.fwd (a ,′ b)) ≡ (xss !! a) !! b
concat!! zero b (xs ∷ xss) = lookup-++-inject+ xs (concatV xss) b
concat!! (suc a) b (xs ∷ xss) =
trans
(lookup-++-raise xs (concatV xss) (Times.fwd (a ,′ b)))
(concat!! a b xss)
×c-equiv : {m₁ m₂ n₁ n₂ : ℕ} (p₁ : FinVec m₁ n₁) (p₂ : FinVec m₂ n₂) →
(p₁ ×c p₂) ≡
concatV (mapV (λ y → mapV Times.fwd (mapV (λ x → y ,′ x) p₂)) p₁)
×c-equiv p₁ p₂ =
let zss = mapV (λ b → mapV (λ x → b ,′ x) p₂) p₁ in
begin (
(p₁ ×c p₂)
≡⟨ refl ⟩
mapV Times.fwd (concatV zss)
≡⟨ sym (concat-map zss Times.fwd) ⟩
concatV (mapV (mapV Times.fwd) zss)
≡⟨ cong concatV
(map-map-map Times.fwd (λ b → mapV (λ x → b ,′ x) p₂) p₁) ⟩
concatV (mapV (λ y → mapV Times.fwd (mapV (λ x → y ,′ x) p₂)) p₁) ∎)
where open ≡-Reasoning
lookup-2d : {A : Set} (m n : ℕ) → (k : Fin (m * n)) →
{f : Fin m × Fin n → A} →
concatV (tabulate {m} (λ i → tabulate {n} (λ j → f (i ,′ j)))) !! k ≡
f (Times.bwd k)
lookup-2d m n k {f} =
let lhs = concatV (tabulate {m} (λ i → tabulate {n} (λ j → f (i ,′ j))))
a = proj₁ (Times.bwd {m} {n} k)
b = proj₂ (Times.bwd {m} {n} k) in
begin (
lhs !! k
≡⟨ cong (_!!_ lhs) (sym (Times.fwd∘bwd~id {m} k)) ⟩
lhs !! (Times.fwd (a ,′ b))
≡⟨ concat!! a b _ ⟩
(tabulate {m} (λ i → tabulate {n} (λ j → f (i ,′ j))) !! a) !! b
≡⟨ cong (λ x → x !! b) (lookup∘tabulate _ a) ⟩
tabulate {n} (λ j → f (a ,′ j)) !! b
≡⟨ lookup∘tabulate _ b ⟩
f (a ,′ b)
≡⟨ refl ⟩
f (Times.bwd k) ∎)
where open ≡-Reasoning
×c!! : {m₁ m₂ n₁ n₂ : ℕ} (p₁ : FinVec m₁ n₁) (p₂ : FinVec m₂ n₂)
(k : Fin (n₁ * n₂)) →
(p₁ ×c p₂) !! k ≡
Times.fwd (p₁ !! proj₁ (Times.bwd k) ,′ p₂ !! proj₂ (Times.bwd {n₁} k))
×c!! {n₁ = n₁} p₁ p₂ k =
let a = proj₁ (Times.bwd {n₁} k) in
let b = proj₂ (Times.bwd {n₁} k) in
begin (
(p₁ ×c p₂) !! k
≡⟨ cong₂ _!!_ (×c-equiv p₁ p₂) (sym (Times.fwd∘bwd~id {n₁} k)) ⟩
concatV (mapV (λ y → mapV Times.fwd (mapV (λ x → y ,′ x) p₂)) p₁) !!
Times.fwd (a ,′ b)
≡⟨ concat!! a b _ ⟩
((mapV (λ y → mapV Times.fwd (mapV (λ x → y ,′ x) p₂)) p₁) !! a) !! b
≡⟨ cong (λ x → x !! b) (lookup-map a _ p₁) ⟩
mapV Times.fwd (mapV (λ x → p₁ !! a ,′ x) p₂) !! b
≡⟨ cong (λ x → x !! b) (sym (map-∘ Times.fwd _ p₂)) ⟩
mapV (Times.fwd ∘ (λ x → p₁ !! a ,′ x)) p₂ !! b
≡⟨ lookup-map b _ p₂ ⟩
Times.fwd (p₁ !! a ,′ p₂ !! b) ∎)
where open ≡-Reasoning
×c-distrib : ∀ {m₁ m₂ m₃ m₄ n₁ n₂} → {p₁ : FinVec m₁ n₁} → {p₂ : FinVec m₂ n₂}
→ {p₃ : FinVec m₃ m₁} → {p₄ : FinVec m₄ m₂} →
(p₁ ×c p₂) ∘̂ (p₃ ×c p₄) ≡ (p₁ ∘̂ p₃) ×c (p₂ ∘̂ p₄)
×c-distrib {m₁} {m₂} {m₃} {m₄} {n₁} {n₂} {p₁} {p₂} {p₃} {p₄} =
let p₃₄ = p₃ ×c p₄ in let p₁₂ = p₁ ×c p₂ in
let p₂₄ = p₂ ∘̂ p₄ in let p₁₃ = p₁ ∘̂ p₃ in
let lhs = λ i → p₃₄ !! (p₁₂ !! i) in
let zss = mapV (λ b → mapV (λ x → b ,′ x) (p₂ ∘̂ p₄)) (p₁ ∘̂ p₃) in
begin (
tabulate {n₁ * n₂} (λ i → p₃₄ !! (p₁₂ !! i))
≡⟨ finext (λ j → cong (_!!_ p₃₄) (×c!! p₁ p₂ j)) ⟩
tabulate {n₁ * n₂}
(λ i → p₃₄ !! Times.fwd (p₁ !! proj₁ (Times.bwd i) ,′
p₂ !! proj₂ (Times.bwd i)))
≡⟨ finext (λ j → ×c!! p₃ p₄ _) ⟩
tabulate (λ i →
let k = Times.fwd (p₁ !! proj₁ (Times.bwd i) ,′
p₂ !! proj₂ (Times.bwd i)) in
Times.fwd (p₃ !! proj₁ (Times.bwd k) ,′ p₄ !! proj₂ (Times.bwd k)))
≡⟨ finext (λ i → cong₂
(λ x y → Times.fwd (p₃ !! proj₁ x ,′ p₄ !! proj₂ y))
(Times.bwd∘fwd~id {m₁} {m₂} (p₁ !! proj₁ (Times.bwd i) ,′ _))
(Times.bwd∘fwd~id (_ ,′ p₂ !! proj₂ (Times.bwd i)))) ⟩
tabulate (λ i → Times.fwd (p₃ !! (p₁ !! proj₁ (Times.bwd i)) ,′
(p₄ !! (p₂ !! proj₂ (Times.bwd i)))))
≡⟨ finext (λ k → sym (lookup-2d n₁ n₂ k)) ⟩
tabulate (λ k →
concatV (tabulate {n₁} (λ z →
tabulate {n₂} (λ w →
Times.fwd ((p₃ !! (p₁ !! z)) ,′ (p₄ !! (p₂ !! w))))))
!! k)
≡⟨ tabulate∘lookup _ ⟩
concatV (tabulate {n₁} (λ z →
tabulate {n₂} (λ w →
Times.fwd ((p₃ !! (p₁ !! z)) ,′ (p₄ !! (p₂ !! w))))))
≡⟨ cong
concatV
(finext (λ i →
tabulate-∘ Times.fwd
(λ w → ((p₃ !! (p₁ !! i)) ,′ (p₄ !! (p₂ !! w)))))) ⟩
concatV (tabulate (λ z →
mapV Times.fwd
(tabulate (λ w → (p₃ !! (p₁ !! z)) ,′ (p₄ !! (p₂ !! w))))))
≡⟨ cong
concatV
(finext (λ i →
cong
(mapV Times.fwd)
(tabulate-∘
(λ x → (p₃ !! (p₁ !! i)) ,′ x)
(_!!_ p₄ ∘ _!!_ p₂)))) ⟩
concatV
(tabulate
(λ z → mapV Times.fwd (mapV (λ x → (p₃ !! (p₁ !! z)) ,′ x) p₂₄)))
≡⟨ cong concatV (tabulate-∘ _ (_!!_ p₃ ∘ _!!_ p₁)) ⟩
concatV (mapV (λ y → mapV Times.fwd (mapV (λ x → y ,′ x) p₂₄)) p₁₃)
≡⟨ sym (×c-equiv p₁₃ p₂₄) ⟩
(p₁ ∘̂ p₃) ×c (p₂ ∘̂ p₄) ∎)
where open ≡-Reasoning
-- there might be a simpler proofs of this using tablate∘lookup
1C×1C≡1C : ∀ {m n} → (1C {m} ×c 1C {n}) ≡ 1C {m * n}
1C×1C≡1C {m} {n} =
begin (
1C {m} ×c 1C
≡⟨ ×c-equiv 1C 1C ⟩
concatV (mapV (λ y → mapV Times.fwd (mapV (_,′_ y) (1C {n}))) (1C {m}))
≡⟨ cong (concatV {n = m}) (sym (tabulate-∘ _ id)) ⟩
concatV {n = m} (tabulate (λ y → mapV Times.fwd (mapV (_,′_ y) (1C {n}))))
≡⟨ cong (concatV {n = m})
(finext (λ y → sym (map-∘ Times.fwd (λ x → y ,′ x) 1C))) ⟩
concatV (tabulate {n = m} (λ y → mapV (Times.fwd ∘ (_,′_ y)) (1C {n})))
≡⟨ cong
(concatV {m = n} {m})
(finext (λ y → sym (tabulate-∘ (Times.fwd ∘ (_,′_ y)) id))) ⟩
concatV (tabulate {n = m}
(λ a → tabulate {n = n} (λ b → Times.fwd (a ,′ b))))
≡⟨ sym (tabulate∘lookup _) ⟩
tabulate (λ k →
concatV (tabulate {n = m}
(λ a → tabulate {n = n} (λ b → Times.fwd (a ,′ b)))) !! k)
≡⟨ finext (λ k → lookup-2d m n k) ⟩
tabulate (λ k → Times.fwd {m} {n} (Times.bwd k))
≡⟨ finext (Times.fwd∘bwd~id {m} {n}) ⟩
1C {m * n} ∎ )
where open ≡-Reasoning
------------------------------------------------------------------------------
-- A few "reveal" functions, to let us peek into the representation
reveal1C : ∀ {m} → allFin m ≡ 1C
reveal1C = refl
reveal0C : [] ≡ 1C {0}
reveal0C = refl
reveal⊎c : ∀ {m₁ n₁ m₂ n₂} → {α : FinVec m₁ m₂} → {β : FinVec n₁ n₂} →
α ⊎c β ≡
tabulate (Plus.fwd ∘ inj₁ ∘ _!!_ α) ++V
tabulate (Plus.fwd {m₁} ∘ inj₂ ∘ _!!_ β)
reveal⊎c = refl
------------------------------------------------------------------------------
|
{
"alphanum_fraction": 0.4605446029,
"avg_line_length": 37.0744274809,
"ext": "agda",
"hexsha": "fdb796c951b2066a55ca1d1f0668bbb171f21226",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z",
"max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "JacquesCarette/pi-dual",
"max_forks_repo_path": "Univalence/Obsolete/FinVecProperties.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "JacquesCarette/pi-dual",
"max_issues_repo_path": "Univalence/Obsolete/FinVecProperties.agda",
"max_line_length": 81,
"max_stars_count": 14,
"max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "JacquesCarette/pi-dual",
"max_stars_repo_path": "Univalence/Obsolete/FinVecProperties.agda",
"max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z",
"num_tokens": 9286,
"size": 19427
}
|
module Agda.Builtin.String where
open import Agda.Builtin.Bool
open import Agda.Builtin.List
open import Agda.Builtin.Char
postulate String : Set
{-# BUILTIN STRING String #-}
primitive
primStringToList : String → List Char
primStringFromList : List Char → String
primStringAppend : String → String → String
primStringEquality : String → String → Bool
primShowChar : Char → String
primShowString : String → String
|
{
"alphanum_fraction": 0.7364864865,
"avg_line_length": 24.6666666667,
"ext": "agda",
"hexsha": "23307b665dfaacc542141a98fcc6c08a659a4b7c",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "redfish64/autonomic-agda",
"max_forks_repo_path": "src/data/lib/prim/Agda/Builtin/String.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "redfish64/autonomic-agda",
"max_issues_repo_path": "src/data/lib/prim/Agda/Builtin/String.agda",
"max_line_length": 47,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "redfish64/autonomic-agda",
"max_stars_repo_path": "src/data/lib/prim/Agda/Builtin/String.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 112,
"size": 444
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.