hexsha
stringlengths 40
40
| size
int64 3
1.05M
| ext
stringclasses 163
values | lang
stringclasses 53
values | max_stars_repo_path
stringlengths 3
945
| max_stars_repo_name
stringlengths 4
112
| max_stars_repo_head_hexsha
stringlengths 40
78
| max_stars_repo_licenses
listlengths 1
10
| max_stars_count
float64 1
191k
⌀ | max_stars_repo_stars_event_min_datetime
stringlengths 24
24
⌀ | max_stars_repo_stars_event_max_datetime
stringlengths 24
24
⌀ | max_issues_repo_path
stringlengths 3
945
| max_issues_repo_name
stringlengths 4
113
| max_issues_repo_head_hexsha
stringlengths 40
78
| max_issues_repo_licenses
listlengths 1
10
| max_issues_count
float64 1
116k
⌀ | max_issues_repo_issues_event_min_datetime
stringlengths 24
24
⌀ | max_issues_repo_issues_event_max_datetime
stringlengths 24
24
⌀ | max_forks_repo_path
stringlengths 3
945
| max_forks_repo_name
stringlengths 4
113
| max_forks_repo_head_hexsha
stringlengths 40
78
| max_forks_repo_licenses
listlengths 1
10
| max_forks_count
float64 1
105k
⌀ | max_forks_repo_forks_event_min_datetime
stringlengths 24
24
⌀ | max_forks_repo_forks_event_max_datetime
stringlengths 24
24
⌀ | content
stringlengths 3
1.05M
| avg_line_length
float64 1
966k
| max_line_length
int64 1
977k
| alphanum_fraction
float64 0
1
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
398d030c38156cf5e14e1a3516d3aed5f0a8e2a8
| 1,804
|
agda
|
Agda
|
test/Succeed/Issue3621.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue3621.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue3621.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2019-03-18, AIM XXIX, performance regression in 2.5.4
-- The following was quick in 2.5.3
postulate
Bool : Set
Foo : Bool → Bool → Bool → Bool → Bool → Bool → Bool → Bool → Bool → Set
data FooRel
: (x1 x1' : Bool)
(x2 x2' : Bool)
(x3 x3' : Bool)
(x4 x4' : Bool)
(x5 x5' : Bool)
(x6 x6' : Bool)
(x7 x7' : Bool)
(x8 x8' : Bool)
(x9 x9' : Bool)
→ Foo x1 x2 x3 x4 x5 x6 x7 x8 x9
→ Foo x1' x2' x3' x4' x5' x6' x7' x8' x9'
→ Set
where
tran
: (x1 x1' x1'' : Bool)
(x2 x2' x2'' : Bool)
(x3 x3' x3'' : Bool)
(x4 x4' x4'' : Bool)
(x5 x5' x5'' : Bool)
(x6 x6' x6'' : Bool)
(x7 x7' x7'' : Bool)
(x8 x8' x8'' : Bool)
(x9 x9' x9'' : Bool)
(t : Foo x1 x2 x3 x4 x5 x6 x7 x8 x9)
(t' : Foo x1' x2' x3' x4' x5' x6' x7' x8' x9')
(t'' : Foo x1'' x2'' x3'' x4'' x5'' x6'' x7'' x8'' x9'')
→ FooRel x1 x1' x2 x2' x3 x3' x4 x4' x5 x5' x6 x6' x7 x7' x8 x8' x9 x9' t t'
→ FooRel x1' x1'' x2' x2'' x3' x3'' x4' x4'' x5' x5'' x6' x6'' x7' x7'' x8' x8'' x9' x9'' t' t''
→ FooRel x1 x1'' x2 x2'' x3 x3'' x4 x4'' x5 x5'' x6 x6'' x7 x7'' x8 x8'' x9 x9'' t t''
foo
: (x1 x1' : Bool)
(x2 x2' : Bool)
(x3 x3' : Bool)
(x4 x4' : Bool)
(x5 x5' : Bool)
(x6 x6' : Bool)
(x7 x7' : Bool)
(x8 x8' : Bool)
(x9 x9' : Bool)
(t : Foo x1 x2 x3 x4 x5 x6 x7 x8 x9)
(t' : Foo x1' x2' x3' x4' x5' x6' x7' x8' x9')
→ FooRel x1 x1' x2 x2' x3 x3' x4 x4' x5 x5' x6 x6' x7 x7' x8 x8' x9 x9' t t'
→ Set
foo x1 x1' x2 x2' x3 x3' x4 x4' x5 x5' x6 x6' x7 x7' x8 x8' x9 x9' t t' (tran .x1 x1'' .x1' .x2 x2'' .x2' .x3 x3'' .x3' .x4 x4'' .x4' .x5 x5'' .x5' .x6 x6'' .x6' .x7 x7'' .x7' .x8 x8'' .x8' .x9 x9'' .x9' .t t'' .t' xy yz) = Bool
-- Should check quickly again in 2.6.0
| 32.214286
| 228
| 0.476164
|
a13e0384d1bdb73931e1214f63f79f45adb1d24f
| 2,715
|
agda
|
Agda
|
RecursiveTypes/Subtyping/Semantic/Equivalence.agda
|
nad/codata
|
1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e
|
[
"MIT"
] | 1
|
2021-02-13T14:48:45.000Z
|
2021-02-13T14:48:45.000Z
|
RecursiveTypes/Subtyping/Semantic/Equivalence.agda
|
nad/codata
|
1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e
|
[
"MIT"
] | null | null | null |
RecursiveTypes/Subtyping/Semantic/Equivalence.agda
|
nad/codata
|
1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- The two semantical definitions of subtyping are equivalent
------------------------------------------------------------------------
module RecursiveTypes.Subtyping.Semantic.Equivalence where
open import Data.Nat
open import Codata.Musical.Notation
open import Function.Base
open import RecursiveTypes.Syntax
open import RecursiveTypes.Subtyping.Semantic.Inductive
open import RecursiveTypes.Subtyping.Semantic.Coinductive
mutual
≤∞⇒≤↓ : ∀ {n} {σ τ : Tree n} → σ ≤∞ τ → σ ≤↓ τ
≤∞⇒≤↓ le zero = ⊥
≤∞⇒≤↓ ⊥ (suc k) = ⊥
≤∞⇒≤↓ ⊤ (suc k) = ⊤
≤∞⇒≤↓ var (suc k) = refl
≤∞⇒≤↓ (τ₁≤σ₁ ⟶ σ₂≤τ₂) (suc k) = ≤∞⇒≤↑ (♭ τ₁≤σ₁) k ⟶ ≤∞⇒≤↓ (♭ σ₂≤τ₂) k
≤∞⇒≤↑ : ∀ {n} {σ τ : Tree n} → σ ≤∞ τ → σ ≤↑ τ
≤∞⇒≤↑ le zero = ⊤
≤∞⇒≤↑ ⊥ (suc k) = ⊥
≤∞⇒≤↑ ⊤ (suc k) = ⊤
≤∞⇒≤↑ var (suc k) = refl
≤∞⇒≤↑ (τ₁≤σ₁ ⟶ σ₂≤τ₂) (suc k) = ≤∞⇒≤↓ (♭ τ₁≤σ₁) k ⟶ ≤∞⇒≤↑ (♭ σ₂≤τ₂) k
domain : ∀ {n} {σ₁ σ₂ τ₁ τ₂ : FinTree n} →
σ₁ ⟶ σ₂ ≤Fin τ₁ ⟶ τ₂ → σ₂ ≤Fin τ₂
domain refl = refl
domain (τ₁≤σ₁ ⟶ σ₂≤τ₂) = σ₂≤τ₂
codomain : ∀ {n} {σ₁ σ₂ τ₁ τ₂ : FinTree n} →
σ₁ ⟶ σ₂ ≤Fin τ₁ ⟶ τ₂ → τ₁ ≤Fin σ₁
codomain refl = refl
codomain (τ₁≤σ₁ ⟶ σ₂≤τ₂) = τ₁≤σ₁
mutual
≤↑⇒≤∞ : ∀ {n} (σ τ : Tree n) → σ ≤↑ τ → σ ≤∞ τ
≤↑⇒≤∞ ⊥ _ le = ⊥
≤↑⇒≤∞ _ ⊤ le = ⊤
≤↑⇒≤∞ ⊤ ⊥ le with le 1
... | ()
≤↑⇒≤∞ ⊤ (var x) le with le 1
... | ()
≤↑⇒≤∞ ⊤ (σ ⟶ τ) le with le 1
... | ()
≤↑⇒≤∞ (var x) ⊥ le with le 1
... | ()
≤↑⇒≤∞ (var x) (var x′) le with le 1
≤↑⇒≤∞ (var x) (var .x) le | refl = var
≤↑⇒≤∞ (var x) (σ ⟶ τ) le with le 1
... | ()
≤↑⇒≤∞ (σ₁ ⟶ τ₁) ⊥ le with le 1
... | ()
≤↑⇒≤∞ (σ₁ ⟶ τ₁) (var x) le with le 1
... | ()
≤↑⇒≤∞ (σ₁ ⟶ τ₁) (σ₂ ⟶ τ₂) le =
♯ ≤↓⇒≤∞ (♭ σ₂) (♭ σ₁) (codomain ∘ le ∘ suc) ⟶
♯ ≤↑⇒≤∞ (♭ τ₁) (♭ τ₂) (domain ∘ le ∘ suc)
≤↓⇒≤∞ : ∀ {n} (σ τ : Tree n) → σ ≤↓ τ → σ ≤∞ τ
≤↓⇒≤∞ ⊥ _ le = ⊥
≤↓⇒≤∞ _ ⊤ le = ⊤
≤↓⇒≤∞ ⊤ ⊥ le with le 1
... | ()
≤↓⇒≤∞ ⊤ (var x) le with le 1
... | ()
≤↓⇒≤∞ ⊤ (σ ⟶ τ) le with le 1
... | ()
≤↓⇒≤∞ (var x) ⊥ le with le 1
... | ()
≤↓⇒≤∞ (var x) (var x′) le with le 1
≤↓⇒≤∞ (var x) (var .x) le | refl = var
≤↓⇒≤∞ (var x) (σ ⟶ τ) le with le 1
... | ()
≤↓⇒≤∞ (σ₁ ⟶ τ₁) ⊥ le with le 1
... | ()
≤↓⇒≤∞ (σ₁ ⟶ τ₁) (var x) le with le 1
... | ()
≤↓⇒≤∞ (σ₁ ⟶ τ₁) (σ₂ ⟶ τ₂) le =
♯ ≤↑⇒≤∞ (♭ σ₂) (♭ σ₁) (codomain ∘ le ∘ suc) ⟶
♯ ≤↓⇒≤∞ (♭ τ₁) (♭ τ₂) (domain ∘ le ∘ suc)
Ind⇒Coind : ∀ {n} {σ τ : Ty n} → σ ≤Ind τ → σ ≤Coind τ
Ind⇒Coind = ≤↓⇒≤∞ _ _
Coind⇒Ind : ∀ {n} {σ τ : Ty n} → σ ≤Coind τ → σ ≤Ind τ
Coind⇒Ind = ≤∞⇒≤↓
| 28.882979
| 72
| 0.378637
|
592519970e2c4af0f76a520f418acf107d57354c
| 2,321
|
agda
|
Agda
|
src/Implicits/Substitutions/Type.agda
|
metaborg/ts.agda
|
7fe638b87de26df47b6437f5ab0a8b955384958d
|
[
"MIT"
] | 4
|
2019-04-05T17:57:11.000Z
|
2021-05-07T04:08:41.000Z
|
src/Implicits/Substitutions/Type.agda
|
metaborg/ts.agda
|
7fe638b87de26df47b6437f5ab0a8b955384958d
|
[
"MIT"
] | null | null | null |
src/Implicits/Substitutions/Type.agda
|
metaborg/ts.agda
|
7fe638b87de26df47b6437f5ab0a8b955384958d
|
[
"MIT"
] | null | null | null |
open import Prelude
module Implicits.Substitutions.Type where
open import Implicits.Syntax.Type
open import Data.Fin.Substitution
open import Data.Star as Star hiding (map)
open import Data.Star.Properties
open import Data.Vec
module TypeApp {T} (l : Lift T Type) where
open Lift l hiding (var)
infixl 8 _/_
mutual
_simple/_ : ∀ {m n} → SimpleType m → Sub T m n → Type n
tc c simple/ σ = simpl (tc c)
tvar x simple/ σ = lift (lookup x σ)
(a →' b) simple/ σ = simpl ((a / σ) →' (b / σ))
_/_ : ∀ {m n} → Type m → Sub T m n → Type n
(simpl c) / σ = (c simple/ σ)
(a ⇒ b) / σ = (a / σ) ⇒ (b / σ)
(∀' a) / σ = ∀' (a / σ ↑)
open Application (record { _/_ = _/_ }) using (_/✶_)
→'-/✶-↑✶ : ∀ k {m n a b} (ρs : Subs T m n) →
(simpl (a →' b)) /✶ ρs ↑✶ k ≡ simpl ((a /✶ ρs ↑✶ k) →' (b /✶ ρs ↑✶ k))
→'-/✶-↑✶ k ε = refl
→'-/✶-↑✶ k (r ◅ ρs) = cong₂ _/_ (→'-/✶-↑✶ k ρs) refl
⇒-/✶-↑✶ : ∀ k {m n a b} (ρs : Subs T m n) →
(a ⇒ b) /✶ ρs ↑✶ k ≡ (a /✶ ρs ↑✶ k) ⇒ (b /✶ ρs ↑✶ k)
⇒-/✶-↑✶ k ε = refl
⇒-/✶-↑✶ k (r ◅ ρs) = cong₂ _/_ (⇒-/✶-↑✶ k ρs) refl
tc-/✶-↑✶ : ∀ k {c m n} (ρs : Subs T m n) →
(simpl (tc c)) /✶ ρs ↑✶ k ≡ simpl (tc c)
tc-/✶-↑✶ k ε = refl
tc-/✶-↑✶ k (r ◅ ρs) = cong₂ _/_ (tc-/✶-↑✶ k ρs) refl
∀'-/✶-↑✶ : ∀ k {m n a} (ρs : Subs T m n) →
(∀' a) /✶ ρs ↑✶ k ≡ ∀' (a /✶ ρs ↑✶ (suc k))
∀'-/✶-↑✶ k ε = refl
∀'-/✶-↑✶ k (x ◅ ρs) = cong₂ _/_ (∀'-/✶-↑✶ k ρs) refl
typeSubst : TermSubst Type
typeSubst = record { var = (λ n → simpl (tvar n)); app = TypeApp._/_ }
open TermSubst typeSubst public hiding (var)
open TypeApp termLift public using (_simple/_)
open TypeApp varLift public using () renaming (_simple/_ to _simple/Var_)
infix 8 _[/_]
-- Shorthand for single-variable type substitutions
_[/_] : ∀ {n} → Type (suc n) → Type n → Type n
a [/ b ] = a / sub b
-- shorthand for type application
infixl 8 _∙_
_∙_ : ∀ {ν} → (a : Type ν) → {is∀ : is-∀' a} → Type ν → Type ν
_∙_ (simpl (tvar n)) {is∀ = ()} _
_∙_ (simpl (tc c)) b = simpl (tc c)
_∙_ (simpl (_ →' _)) {is∀ = ()} _
_∙_ (∀' x) b = x [/ b ]
_∙_ (_ ⇒ _) {is∀ = ()} _
stp-weaken : ∀ {ν} → SimpleType ν → SimpleType (suc ν)
stp-weaken (tc x) = tc x
stp-weaken (tvar n) = tvar (suc n)
stp-weaken (a →' b) = weaken a →' weaken b
| 30.539474
| 83
| 0.490306
|
0bc67cac4dcae8e189789bb14f93897d84f532e2
| 1,708
|
agda
|
Agda
|
src/Human/Humanity.agda
|
MaisaMilena/JuiceMaker
|
b509eb4c4014605facfb4ee5c807cd07753d4477
|
[
"MIT"
] | 6
|
2019-03-29T17:35:20.000Z
|
2020-11-28T05:46:27.000Z
|
src/Human/Humanity.agda
|
MaisaMilena/AgdaCalculator
|
e977a5f2a005682cee123568b49462dd7d7b11ad
|
[
"MIT"
] | null | null | null |
src/Human/Humanity.agda
|
MaisaMilena/AgdaCalculator
|
e977a5f2a005682cee123568b49462dd7d7b11ad
|
[
"MIT"
] | null | null | null |
module Human.Humanity where
-- Use agda-prelude instead of agda-stdlib?
open import Human.JS public
open import Human.Unit public
open import Human.Nat public
open import Human.List public
open import Human.Bool public
open import Human.String public
open import Human.IO public
open import Human.Float public
open import Human.Int public
Lazy : ∀ (A : Set) → Set
Lazy A = Unit → A
then:_ : ∀ {A : Set} → A → Lazy A
then: a = λ x → a
else:_ : ∀ {A : Set} → A → Lazy A
else: a = λ x → a
if : ∀ {A : Set} → Bool → Lazy A → Lazy A → A
if true t f = t unit
if false t f = f unit
init-to : ∀ {A : Set} → Nat → A → (Nat → A → A) → A
init-to zero x fn = x
init-to (suc i) x fn = init-to i (fn zero x) (λ i → fn (suc i))
{-# COMPILE JS init-to = A => n => x => fn => { for (var i = 0, l = n.toJSValue(); i < l; ++i) x = fn(agdaRTS.primIntegerFromString(String(i)))(x); return x; } #-}
syntax init-to m x (λ i → b) = init x for i to m do: b
init-from-to : ∀ {A : Set} → Nat → A → Nat → (Nat → A → A) → A
init-from-to n x m f = init-to (m - n) x (λ i x → f (n + i) x)
syntax init-from-to n x m (λ i → b) = init x for i from n to m do: b
for-to : Nat → (Nat → IO Unit) → IO Unit
for-to zero act = return unit
for-to (suc n) act = act zero >> for-to n (λ i → act (suc i))
syntax for-from-to n m (λ i → b) = for i from n to m do: b
for-from-to : Nat → Nat → (Nat → IO Unit) → IO Unit
for-from-to n m f = for-to (m - n) (λ i → f (n + i))
syntax for-to m (λ i → b) = for i to m do: b
_++_ : String → String → String
_++_ = primStringAppend
show : Nat → String
show zero = "Z"
show (suc n) = "S" ++ show n
Program : Set
Program = Lazy (IO Unit)
_f+_ : Float → Float → Float
_f+_ = primFloatPlus
| 26.6875
| 163
| 0.591335
|
2348ff954ff9791a18a3e73feb7b8fd739c84b7b
| 1,277
|
agda
|
Agda
|
Agda/univalent-hott/1-type-theory.agda
|
hemangandhi/HoTT-Intro
|
09c710bf9c31ba88be144cc950bd7bc19c22a934
|
[
"CC-BY-4.0"
] | null | null | null |
Agda/univalent-hott/1-type-theory.agda
|
hemangandhi/HoTT-Intro
|
09c710bf9c31ba88be144cc950bd7bc19c22a934
|
[
"CC-BY-4.0"
] | null | null | null |
Agda/univalent-hott/1-type-theory.agda
|
hemangandhi/HoTT-Intro
|
09c710bf9c31ba88be144cc950bd7bc19c22a934
|
[
"CC-BY-4.0"
] | null | null | null |
{-# OPTIONS --without-K --exact-split #-}
module 1-type-theory where
import 00-preamble
open 00-preamble public
-- Exercise 1.1 (From ../02-pi.agda)
_∘-1-1_ :
{i j k : Level} {A : UU i} {B : UU j} {C : UU k} →
(B → C) → ((A → B) → (A → C))
(g ∘-1-1 f) a = g (f a)
import 04-inductive-types
open 04-inductive-types public
-- Exercise 1.2
recursorOfProjections :
{i j k : Level} {A : UU i} {B : UU j} {C : UU k} →
(A → B → C) → (prod A B) → C
recursorOfProjections f p = f (pr1 p) (pr2 p)
-- Exercise 1.11 is neg-triple-neg
exercise-1-12-i : {i j : Level} {A : UU i} {B : UU j} → A → B → A
exercise-1-12-i x y = x
exercise-1-12-ii : {i : Level} {A : UU i} → A → ¬ (¬ A)
exercise-1-12-ii a = (\ f → f a)
exercise-1-12-iii :
{i j : Level} {A : UU i} {B : UU j} →
(coprod (¬ A) (¬ B)) → (¬ (prod A B))
exercise-1-12-iii (inl fa) = (\ p → fa (pr1 p))
exercise-1-12-iii (inr fb) = (\ p → fb (pr2 p))
kian-ex-1-13 :
{i : Level} {A : UU i}
→ ¬ (¬ (coprod A (¬ A)))
kian-ex-1-13 = (\ f → (\ g → f (inr g)) (\ a → f (inl a)))
import 05-identity-types
open 05-identity-types public
exercise-1-15 :
{i j : Level} {A : UU i} (C : A → UU j) (x : A) (y : A) → (Id x y) → (C x) → (C y)
exercise-1-15 C x y eq = ind-Id x (\ y' eq' → (C(x) → C(y'))) (\ x → x) y eq
| 26.604167
| 84
| 0.516053
|
106a7928cc93b598085d495cdc11a029bf37081a
| 413
|
agda
|
Agda
|
notes/agda-interface/OptionPragmaCommandLine.agda
|
asr/apia
|
a66c5ddca2ab470539fd68c42c4fbd45f720d682
|
[
"MIT"
] | 10
|
2015-09-03T20:54:16.000Z
|
2019-12-03T13:44:25.000Z
|
notes/agda-interface/OptionPragmaCommandLine.agda
|
asr/apia
|
a66c5ddca2ab470539fd68c42c4fbd45f720d682
|
[
"MIT"
] | 121
|
2015-01-25T13:22:12.000Z
|
2018-04-22T06:01:44.000Z
|
notes/agda-interface/OptionPragmaCommandLine.agda
|
asr/apia
|
a66c5ddca2ab470539fd68c42c4fbd45f720d682
|
[
"MIT"
] | 4
|
2016-05-10T23:06:19.000Z
|
2016-08-03T03:54:55.000Z
|
-- Testing how the pragmas are saved in the agda interface files (using
-- the program dump-agdai) when they are used from the command-line:
-- $ agda --no-termination-check OptionPragmaCommandLine.agda
-- 17 October 2012. Because the PragmaOption --no-termination-check
-- was used from the command-line it is *not* saved in the interface
-- file.
-- iPragmaOptions = []
module OptionPragmaCommandLine where
| 31.769231
| 71
| 0.757869
|
23e0a1257901658e8a9df4f50662fcca190e78ee
| 345
|
agda
|
Agda
|
test/Succeed/ForeignPragma.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/ForeignPragma.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/ForeignPragma.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Check that FOREIGN code can have nested pragmas.
module _ where
open import Common.Prelude
{-# FOREIGN GHC
{-# NOINLINE plusOne #-}
plusOne :: Integer -> Integer
plusOne n = n + 1
{-# INLINE plusTwo #-}
plusTwo :: Integer -> Integer
plusTwo = plusOne . plusOne
#-}
postulate
plusOne : Nat → Nat
{-# COMPILE GHC plusOne = plusOne #-}
| 15.681818
| 51
| 0.672464
|
06abedb3fd65bbb3907e00fafa5d62d3ca6d7342
| 41,064
|
agda
|
Agda
|
Cubical/ZCohomology/GroupStructure.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 1
|
2022-02-05T01:25:02.000Z
|
2022-02-05T01:25:02.000Z
|
Cubical/ZCohomology/GroupStructure.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | null | null | null |
Cubical/ZCohomology/GroupStructure.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --safe --experimental-lossy-unification #-}
module Cubical.ZCohomology.GroupStructure where
open import Cubical.ZCohomology.Base
open import Cubical.HITs.S1
open import Cubical.HITs.Sn
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Function
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Pointed hiding (id)
open import Cubical.Foundations.Path
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.GroupoidLaws renaming (assoc to assoc∙)
open import Cubical.Data.Sigma
open import Cubical.HITs.Susp
open import Cubical.HITs.SetTruncation renaming (rec to sRec ; rec2 to sRec2 ; elim to sElim ; elim2 to sElim2 ; isSetSetTrunc to §)
open import Cubical.Data.Int renaming (_+_ to _ℤ+_ ; -_ to -ℤ_)
open import Cubical.Data.Nat renaming (+-assoc to +-assocℕ ; +-comm to +-commℕ)
open import Cubical.HITs.Truncation renaming (elim to trElim ; map to trMap ; rec to trRec ; elim3 to trElim3 ; map2 to trMap2)
open import Cubical.Homotopy.Loopspace
open import Cubical.Algebra.Group renaming (ℤ to ℤGroup)
open import Cubical.Algebra.AbGroup
open import Cubical.Algebra.Semigroup
open import Cubical.Algebra.Monoid
open Iso renaming (inv to inv')
private
variable
ℓ ℓ' : Level
A : Type ℓ
B : Type ℓ'
A' : Pointed ℓ
infixr 34 _+ₖ_
infixr 34 _+ₕ_
infixr 34 _+ₕ∙_
-- Addition in the Eilenberg-Maclane spaces is uniquely determined if we require it to have left- and right-unit laws,
-- such that these agree on 0. In particular, any h-structure (see http://ericfinster.github.io/files/emhott.pdf) is unique.
+ₖ-unique : (n : ℕ) → (comp1 comp2 : coHomK (suc n) → coHomK (suc n) → coHomK (suc n))
→ (rUnit1 : (x : _) → comp1 x (coHom-pt (suc n)) ≡ x)
→ (lUnit1 : (x : _) → comp1 (coHom-pt (suc n)) x ≡ x)
→ (rUnit2 : (x : _) → comp2 x (coHom-pt (suc n)) ≡ x)
→ (lUnit2 : (x : _) → comp2 (coHom-pt (suc n)) x ≡ x)
→ (unId1 : rUnit1 (coHom-pt (suc n)) ≡ lUnit1 (coHom-pt (suc n)))
→ (unId2 : rUnit2 (coHom-pt (suc n)) ≡ lUnit2 (coHom-pt (suc n)))
→ (x y : _) → comp1 x y ≡ comp2 x y
+ₖ-unique n comp1 comp2 rUnit1 lUnit1 rUnit2 lUnit2 unId1 unId2 =
elim2 (λ _ _ → isOfHLevelPath (3 + n) (isOfHLevelTrunc (3 + n)) _ _)
(wedgeconFun _ _
(λ _ _ → help _ _)
(λ x → lUnit1 ∣ x ∣ ∙ sym (lUnit2 ∣ x ∣))
(λ x → rUnit1 ∣ x ∣ ∙ sym (rUnit2 ∣ x ∣))
(cong₂ _∙_ unId1 (cong sym unId2)))
where
help : isOfHLevel (2 + (n + suc n)) (coHomK (suc n))
help = subst (λ x → isOfHLevel x (coHomK (suc n))) (+-suc n (2 + n) ∙ +-suc (suc n) (suc n))
(isOfHLevelPlus n (isOfHLevelTrunc (3 + n)))
wedgeConHLev : (n : ℕ) → isOfHLevel ((2 + n) + (2 + n)) (coHomK (2 + n))
wedgeConHLev n = subst (λ x → isOfHLevel x (coHomK (2 + n)))
(sym (+-suc (2 + n) (suc n) ∙ +-suc (3 + n) n))
(isOfHLevelPlus' {n = n} (4 + n) (isOfHLevelTrunc (4 + n)))
wedgeConHLev' : (n : ℕ) → isOfHLevel ((2 + n) + (2 + n)) (typ (Ω (coHomK-ptd (3 + n))))
wedgeConHLev' n = subst (λ x → isOfHLevel x (typ (Ω (coHomK-ptd (3 + n)))))
(sym (+-suc (2 + n) (suc n) ∙ +-suc (3 + n) n))
(isOfHLevelPlus' {n = n} (4 + n) (isOfHLevelTrunc (5 + n) _ _))
wedgeConHLevPath : (n : ℕ) → (x y : coHomK (suc n)) → isOfHLevel ((suc n) + (suc n)) (x ≡ y)
wedgeConHLevPath zero x y = isOfHLevelTrunc 3 _ _
wedgeConHLevPath (suc n) x y = isOfHLevelPath ((2 + n) + (2 + n)) (wedgeConHLev n) _ _
-- addition for n ≥ 2 together with the left- and right-unit laws (modulo truncations)
preAdd : (n : ℕ) → (S₊ (2 + n) → S₊ (2 + n) → coHomK (2 + n))
preAdd n =
wedgeconFun _ _
(λ _ _ → wedgeConHLev n)
∣_∣
∣_∣
refl
preAdd-l : (n : ℕ) → (x : (S₊ (2 + n))) → preAdd n north x ≡ ∣ x ∣
preAdd-l n _ = refl
preAdd-r : (n : ℕ) → (x : (S₊ (2 + n))) → preAdd n x north ≡ ∣ x ∣
preAdd-r n =
wedgeconRight _ (suc n)
(λ _ _ → wedgeConHLev n)
∣_∣
∣_∣
refl
-- addition for n = 1
wedgeMapS¹ : S¹ → S¹ → S¹
wedgeMapS¹ base y = y
wedgeMapS¹ (loop i) base = loop i
wedgeMapS¹ (loop i) (loop j) =
hcomp (λ k → λ { (i = i0) → loop j
; (i = i1) → loop (j ∧ k)
; (j = i0) → loop i
; (j = i1) → loop (i ∧ k)})
(loop (i ∨ j))
---------- Algebra/Group stuff --------
0ₖ : (n : ℕ) → coHomK n
0ₖ = coHom-pt
_+ₖ_ : {n : ℕ} → coHomK n → coHomK n → coHomK n
_+ₖ_ {n = zero} x y = x ℤ+ y
_+ₖ_ {n = suc zero} = trMap2 wedgeMapS¹
_+ₖ_ {n = suc (suc n)} = trRec (isOfHLevelΠ (4 + n) λ _ → isOfHLevelTrunc (4 + n))
λ x → trRec (isOfHLevelTrunc (4 + n)) (preAdd n x)
private
isEquiv+ : (n : ℕ) → (x : coHomK (suc n)) → isEquiv (_+ₖ_ {n = (suc n)} x)
isEquiv+ zero =
trElim (λ _ → isProp→isOfHLevelSuc 2 (isPropIsEquiv _))
(toPropElim (λ _ → isPropIsEquiv _)
(subst isEquiv (sym help) (idIsEquiv _)))
where
help : _+ₖ_ {n = 1} (coHom-pt 1) ≡ idfun _
help = funExt (trElim (λ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _)
λ _ → refl)
isEquiv+ (suc n) =
trElim (λ _ → isProp→isOfHLevelSuc (3 + n) (isPropIsEquiv _))
(suspToPropElim (ptSn (suc n)) (λ _ → isPropIsEquiv _)
(subst isEquiv (sym help) (idIsEquiv _)))
where
help : _+ₖ_ {n = (2 + n)} (coHom-pt (2 + n)) ≡ idfun _
help = funExt (trElim (λ _ → isOfHLevelPath (4 + n) (isOfHLevelTrunc (4 + n)) _ _) λ _ → refl)
Kₙ≃Kₙ : (n : ℕ) (x : coHomK (suc n)) → coHomK (suc n) ≃ coHomK (suc n)
Kₙ≃Kₙ n x = _ , isEquiv+ n x
-ₖ_ : {n : ℕ} → coHomK n → coHomK n
-ₖ_ {n = zero} x = 0 - x
-ₖ_ {n = suc zero} = trMap λ {base → base ; (loop i) → (loop (~ i))}
-ₖ_ {n = suc (suc n)} = trMap λ {north → north
; south → north
; (merid a i) → ((merid (ptSn (suc n)) ∙ sym (merid a))) i}
_-ₖ_ : {n : ℕ} → coHomK n → coHomK n → coHomK n
_-ₖ_ {n = n} x y = _+ₖ_ {n = n} x (-ₖ_ {n = n} y)
+ₖ-syntax : (n : ℕ) → coHomK n → coHomK n → coHomK n
+ₖ-syntax n = _+ₖ_ {n = n}
-ₖ-syntax : (n : ℕ) → coHomK n → coHomK n
-ₖ-syntax n = -ₖ_ {n = n}
-'ₖ-syntax : (n : ℕ) → coHomK n → coHomK n → coHomK n
-'ₖ-syntax n = _-ₖ_ {n = n}
syntax +ₖ-syntax n x y = x +[ n ]ₖ y
syntax -ₖ-syntax n x = -[ n ]ₖ x
syntax -'ₖ-syntax n x y = x -[ n ]ₖ y
-ₖ^2 : {n : ℕ} → (x : coHomK n) → (-ₖ (-ₖ x)) ≡ x
-ₖ^2 {n = zero} x =
+Comm (pos zero) (-ℤ (pos zero ℤ+ (-ℤ x))) ∙∙ -Dist+ (pos zero) (-ℤ x)
∙∙ (+Comm (pos zero) (-ℤ (-ℤ x)) ∙ -Involutive x)
-ₖ^2 {n = suc zero} =
trElim (λ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _) λ { base → refl ; (loop i) → refl}
-ₖ^2 {n = suc (suc n)} =
trElim (λ _ → isOfHLevelPath (4 + n) (isOfHLevelTrunc (4 + n)) _ _)
λ { north → refl
; south j → ∣ merid (ptSn _) j ∣ₕ
; (merid a i) j
→ hcomp (λ k → λ { (i = i0) → ∣ north ∣
; (i = i1) → ∣ compPath-filler' (merid a) (sym (merid (ptSn _))) (~ k) (~ j) ∣ₕ
; (j = i0) → help a (~ k) i
; (j = i1) → ∣ merid a (i ∧ k) ∣})
∣ (merid a ∙ sym (merid (ptSn _))) (i ∧ ~ j) ∣ₕ}
where
help : (a : _) → cong (-ₖ_ ∘ (-ₖ_ {n = suc (suc n)})) (cong ∣_∣ₕ (merid a))
≡ cong ∣_∣ₕ (merid a ∙ sym (merid (ptSn _)))
help a = cong (cong ((-ₖ_ {n = suc (suc n)}))) (cong-∙ ∣_∣ₕ (merid (ptSn (suc n))) (sym (merid a)))
∙∙ cong-∙ (-ₖ_ {n = suc (suc n)}) (cong ∣_∣ₕ (merid (ptSn (suc n)))) (cong ∣_∣ₕ (sym (merid a)))
∙∙ (λ i → (λ j → ∣ rCancel (merid (ptSn (suc n))) i j ∣ₕ)
∙ λ j → ∣ symDistr (merid (ptSn (suc n))) (sym (merid a)) i j ∣ₕ)
∙ sym (lUnit _)
------- Groupoid Laws for Kₙ ---------
commₖ : (n : ℕ) → (x y : coHomK n) → x +[ n ]ₖ y ≡ y +[ n ]ₖ x
commₖ zero = +Comm
commₖ (suc zero) =
elim2 (λ _ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _)
(wedgeconFun _ _
(λ _ _ → isOfHLevelTrunc 3 _ _)
(λ {base → refl ; (loop i) → refl})
(λ {base → refl ; (loop i) → refl})
refl)
commₖ (suc (suc n)) =
elim2 (λ _ _ → isOfHLevelPath (4 + n) (isOfHLevelTrunc (4 + n)) _ _)
(wedgeconFun _ _
(λ x y → isOfHLevelPath ((2 + n) + (2 + n)) (wedgeConHLev n) _ _)
(λ x → preAdd-l n x ∙ sym (preAdd-r n x))
(λ x → preAdd-r n x ∙ sym (preAdd-l n x))
refl)
commₖ-base : (n : ℕ) → commₖ n (coHom-pt n) (coHom-pt n) ≡ refl
commₖ-base zero = refl
commₖ-base (suc zero) = refl
commₖ-base (suc (suc n)) = sym (rUnit _)
rUnitₖ : (n : ℕ) → (x : coHomK n) → x +[ n ]ₖ coHom-pt n ≡ x
rUnitₖ zero x = refl
rUnitₖ (suc zero) =
trElim (λ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _)
λ {base → refl
; (loop i) → refl}
rUnitₖ (suc (suc n)) =
trElim (λ _ → isOfHLevelPath (4 + n) (isOfHLevelTrunc (4 + n)) _ _)
(preAdd-r n)
lUnitₖ : (n : ℕ) → (x : coHomK n) → coHom-pt n +[ n ]ₖ x ≡ x
lUnitₖ zero x = sym (pos0+ x)
lUnitₖ (suc zero) =
trElim (λ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _)
λ {base → refl
; (loop i) → refl}
lUnitₖ (suc (suc n)) =
trElim (λ _ → isOfHLevelPath (4 + n) (isOfHLevelTrunc (4 + n)) _ _)
λ x → refl
∙≡+₁ : (p q : typ (Ω (coHomK-ptd 1))) → p ∙ q ≡ cong₂ _+ₖ_ p q
∙≡+₁ p q = (λ i → (λ j → rUnitₖ 1 (p j) (~ i)) ∙ λ j → lUnitₖ 1 (q j) (~ i)) ∙ sym (cong₂Funct _+ₖ_ p q)
∙≡+₂ : (n : ℕ) (p q : typ (Ω (coHomK-ptd (suc (suc n))))) → p ∙ q ≡ cong₂ _+ₖ_ p q
∙≡+₂ n p q = (λ i → (λ j → rUnitₖ (2 + n) (p j) (~ i)) ∙ λ j → lUnitₖ (2 + n) (q j) (~ i)) ∙ sym (cong₂Funct _+ₖ_ p q)
lCancelₖ : (n : ℕ) → (x : coHomK n) → (-ₖ_ {n = n} x) +ₖ x ≡ coHom-pt n
lCancelₖ zero x = minusPlus x 0
lCancelₖ (suc zero) =
trElim (λ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _)
λ {base → refl ; (loop i) j → help j i}
where
help : cong₂ _+ₖ_ (sym (cong ∣_∣ loop)) (cong ∣_∣ loop) ≡ refl
help = sym (∙≡+₁ (sym (cong ∣_∣ loop)) (cong ∣_∣ loop)) ∙ lCancel _
lCancelₖ (suc (suc n)) =
trElim (λ _ → isOfHLevelPath (4 + n) (isOfHLevelTrunc (4 + n)) _ _)
λ {north → refl ; south → cong ∣_∣ (sym (merid (ptSn (suc n)))) ; (merid a i) → help a i }
where
s : (a : _) → _ ≡ _
s x = cong₂ _+ₖ_ (sym (cong ∣_∣ (merid (ptSn (suc n)) ∙ sym (merid x)))) (cong ∣_∣ (sym (merid x)))
help : (a : _) → PathP (λ i → (preAdd n ((merid (ptSn (suc n)) ∙ (λ i₁ → merid a (~ i₁))) i)
(merid a i)) ≡ ∣ north ∣) refl λ i₁ → ∣ merid (ptSn (suc n)) (~ i₁) ∣
help x =
compPathR→PathP
((sym (lCancel _)
∙∙ (λ i → ∙≡+₂ _ (cong ∣_∣ (symDistr (merid x) (sym (merid (ptSn (suc n)))) i)) (cong ∣_∣ ((merid x) ∙ sym (merid (ptSn (suc n))))) i)
∙∙ rUnit _)
∙∙ (λ j → cong₂ _+ₖ_ ((cong ∣_∣ (merid (ptSn (suc n)) ∙ sym (merid x))))
(λ i → ∣ compPath-filler ((merid x)) ((sym (merid (ptSn (suc n))))) (~ j) i ∣)
∙ λ i → ∣ merid (ptSn (suc n)) (~ i ∧ j) ∣)
∙∙ λ i → sym (s x) ∙ rUnit (cong ∣_∣ (sym (merid (ptSn (suc n))))) i)
rCancelₖ : (n : ℕ) → (x : coHomK n) → x +ₖ (-ₖ_ {n = n} x) ≡ coHom-pt n
rCancelₖ zero x = +Comm x (pos 0 - x) ∙ minusPlus x 0 -- +-comm x (pos 0 - x) ∙ minusPlus x 0
rCancelₖ (suc zero) = trElim (λ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _)
λ {base → refl ; (loop i) j → help j i}
where
help : (λ i → ∣ loop i ∣ₕ +ₖ (-ₖ ∣ loop i ∣ₕ)) ≡ refl
help = sym (∙≡+₁ (cong ∣_∣ₕ loop) (sym (cong ∣_∣ₕ loop))) ∙ rCancel _
rCancelₖ (suc (suc n)) x = commₖ _ x (-ₖ x) ∙ lCancelₖ _ x
rCancel≡refl : (n : ℕ) → rCancelₖ (2 + n) (0ₖ _) ≡ refl
rCancel≡refl n i = rUnit (rUnit refl (~ i)) (~ i)
assocₖ : (n : ℕ) → (x y z : coHomK n) → x +[ n ]ₖ (y +[ n ]ₖ z) ≡ (x +[ n ]ₖ y) +[ n ]ₖ z
assocₖ zero = +Assoc
assocₖ (suc zero) =
trElim3 (λ _ _ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _)
λ x → wedgeconFun _ _
(λ _ _ → isOfHLevelTrunc 3 _ _)
(λ y i → rUnitₖ 1 ∣ x ∣ (~ i) +ₖ ∣ y ∣)
(λ z → cong (∣ x ∣ +ₖ_) (rUnitₖ 1 ∣ z ∣) ∙ sym (rUnitₖ 1 (∣ x ∣ +ₖ ∣ z ∣)))
(helper x)
where
helper : (x : S¹) → cong (∣ x ∣ +ₖ_) (rUnitₖ 1 ∣ base ∣) ∙ sym (rUnitₖ 1 (∣ x ∣ +ₖ ∣ base ∣))
≡ (cong (_+ₖ ∣ base ∣) (sym (rUnitₖ 1 ∣ x ∣)))
helper = toPropElim (λ _ → isOfHLevelTrunc 3 _ _ _ _)
(sym (lUnit refl))
assocₖ (suc (suc n)) =
trElim3 (λ _ _ _ → isOfHLevelPath (4 + n) (isOfHLevelTrunc (4 + n)) _ _)
(wedgeConSn-×3 _
(λ x z i → preAdd-r n x (~ i) +ₖ ∣ z ∣)
(λ x y → cong (∣ x ∣ +ₖ_) (rUnitₖ (2 + n) ∣ y ∣) ∙ sym (rUnitₖ (2 + n) (∣ x ∣ +ₖ ∣ y ∣)))
(lUnit (sym (rUnitₖ (2 + n) (∣ north ∣ +ₖ ∣ north ∣)))))
where
wedgeConSn-×3 : (n : ℕ)
→ (f : (x z : S₊ (2 + n))→ ∣ x ∣ +ₖ ((0ₖ _) +ₖ ∣ z ∣) ≡ (∣ x ∣ +ₖ (0ₖ _)) +ₖ ∣ z ∣)
→ (g : (x y : S₊ (2 + n)) → ∣ x ∣ +ₖ (∣ y ∣ +ₖ 0ₖ _) ≡ (∣ x ∣ +ₖ ∣ y ∣) +ₖ 0ₖ _)
→ (f (ptSn _) (ptSn _) ≡ g (ptSn _) (ptSn _))
→ (x y z : S₊ (2 + n)) → ∣ x ∣ +ₖ (∣ y ∣ +ₖ ∣ z ∣) ≡ (∣ x ∣ +ₖ ∣ y ∣) +ₖ ∣ z ∣
wedgeConSn-×3 n f g d x =
wedgeconFun _ _ (λ _ _ → isOfHLevelPath ((2 + n) + (2 + n)) (wedgeConHLev n) _ _)
(f x)
(g x)
(sphereElim _ {A = λ x → g x (ptSn (suc (suc n))) ≡ f x (ptSn (suc (suc n))) }
(λ _ → isOfHLevelTrunc (4 + n) _ _ _ _)
(sym d) x)
{-
This was the original proof for the case n ≥ 2:
For some reason it doesn't check in reasonable time anymore:
assocₖ (suc (suc n)) =
trElim3 (λ _ _ _ → isOfHLevelPath (4 + n) (isOfHLevelTrunc (4 + n)) _ _)
λ x → wedgeConSn _ _ (λ _ _ → isOfHLevelPath ((2 + n) + (2 + n)) (wedgeConHLev n) _ _)
(λ z i → preAdd n .snd .snd x (~ i) +ₖ ∣ z ∣)
(λ y → cong (∣ x ∣ +ₖ_) (rUnitₖ (2 + n) ∣ y ∣) ∙ sym (rUnitₖ (2 + n) (∣ x ∣ +ₖ ∣ y ∣)))
(helper x) .fst
where
helper : (x : S₊ (2 + n)) → cong (∣ x ∣ +ₖ_) (rUnitₖ (2 + n) ∣ north ∣) ∙ sym (rUnitₖ (2 + n) (∣ x ∣ +ₖ ∣ north ∣))
≡ cong (_+ₖ ∣ north ∣) (sym (preAdd n .snd .snd x))
helper = sphereElim (suc n) (λ _ → isOfHLevelTrunc (4 + n) _ _ _ _)
(sym (lUnit (sym (rUnitₖ (2 + n) (∣ north ∣ +ₖ ∣ north ∣)))))
-}
lUnitₖ≡rUnitₖ : (n : ℕ) → lUnitₖ n (coHom-pt n) ≡ rUnitₖ n (coHom-pt n)
lUnitₖ≡rUnitₖ zero = isSetℤ _ _ _ _
lUnitₖ≡rUnitₖ (suc zero) = refl
lUnitₖ≡rUnitₖ (suc (suc n)) = refl
------ Commutativity of ΩKₙ
-- We show that p ∙ q ≡ (λ i → (p i) +ₖ (q i)) for any p q : ΩKₙ₊₁. This allows us to prove that p ∙ q ≡ q ∙ p
-- without having to use the equivalence Kₙ ≃ ΩKₙ₊₁
cong+ₖ-comm : (n : ℕ) (p q : typ (Ω (coHomK-ptd (suc n)))) → cong₂ _+ₖ_ p q ≡ cong₂ _+ₖ_ q p
cong+ₖ-comm zero p q =
rUnit (cong₂ _+ₖ_ p q)
∙∙ (λ i → (λ j → commₖ 1 ∣ base ∣ ∣ base ∣ (i ∧ j))
∙∙ (λ j → commₖ 1 (p j) (q j) i)
∙∙ λ j → commₖ 1 ∣ base ∣ ∣ base ∣ (i ∧ ~ j))
∙∙ ((λ i → commₖ-base 1 i ∙∙ cong₂ _+ₖ_ q p ∙∙ sym (commₖ-base 1 i))
∙ sym (rUnit (cong₂ _+ₖ_ q p)))
cong+ₖ-comm (suc n) p q =
rUnit (cong₂ _+ₖ_ p q)
∙∙ (λ i → (λ j → commₖ (2 + n) ∣ north ∣ ∣ north ∣ (i ∧ j))
∙∙ (λ j → commₖ (2 + n) (p j) (q j) i )
∙∙ λ j → commₖ (2 + n) ∣ north ∣ ∣ north ∣ (i ∧ ~ j))
∙∙ ((λ i → commₖ-base (2 + n) i ∙∙ cong₂ _+ₖ_ q p ∙∙ sym (commₖ-base (2 + n) i))
∙ sym (rUnit (cong₂ _+ₖ_ q p)))
isCommΩK : (n : ℕ) → isComm∙ (coHomK-ptd n)
isCommΩK zero p q = isSetℤ _ _ (p ∙ q) (q ∙ p)
isCommΩK (suc zero) p q = ∙≡+₁ p q ∙∙ cong+ₖ-comm 0 p q ∙∙ sym (∙≡+₁ q p)
isCommΩK (suc (suc n)) p q = ∙≡+₂ n p q ∙∙ cong+ₖ-comm (suc n) p q ∙∙ sym (∙≡+₂ n q p)
----- some other useful lemmas about algebra in Kₙ
-0ₖ : {n : ℕ} → -[ n ]ₖ (0ₖ n) ≡ (0ₖ n)
-0ₖ {n = zero} = refl
-0ₖ {n = suc zero} = refl
-0ₖ {n = suc (suc n)} = refl
-distrₖ : (n : ℕ) (x y : coHomK n) → -[ n ]ₖ (x +[ n ]ₖ y) ≡ (-[ n ]ₖ x) +[ n ]ₖ (-[ n ]ₖ y)
-distrₖ zero x y = GroupTheory.invDistr ℤGroup x y ∙ +Comm (0 - y) (0 - x)
-distrₖ (suc zero) =
elim2 (λ _ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _)
(wedgeconFun _ _ (λ _ _ → isOfHLevelTrunc 3 _ _)
(λ x → sym (lUnitₖ 1 (-[ 1 ]ₖ ∣ x ∣)))
(λ x → cong (λ x → -[ 1 ]ₖ x) (rUnitₖ 1 ∣ x ∣) ∙ sym (rUnitₖ 1 (-[ 1 ]ₖ ∣ x ∣)))
(sym (rUnit refl)))
-distrₖ (suc (suc n)) =
elim2 (λ _ _ → isOfHLevelPath (4 + n) (isOfHLevelTrunc (4 + n)) _ _)
(wedgeconFun _ _ (λ _ _ → isOfHLevelPath ((2 + n) + (2 + n)) (wedgeConHLev n) _ _)
(λ x → sym (lUnitₖ (2 + n) (-[ (2 + n) ]ₖ ∣ x ∣)))
(λ x → cong (λ x → -[ (2 + n) ]ₖ x) (rUnitₖ (2 + n) ∣ x ∣ ) ∙ sym (rUnitₖ (2 + n) (-[ (2 + n) ]ₖ ∣ x ∣)))
(sym (rUnit refl)))
-cancelRₖ : (n : ℕ) (x y : coHomK n) → (y +[ n ]ₖ x) -[ n ]ₖ x ≡ y
-cancelRₖ zero x y = sym (+Assoc y x (0 - x))
∙∙ cong (y ℤ+_) (+Comm x (0 - x))
∙∙ cong (y ℤ+_) (minusPlus x (pos 0))
-cancelRₖ (suc zero) =
elim2 (λ _ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _)
(wedgeconFun _ _ (λ _ _ → wedgeConHLevPath 0 _ _)
(λ x → cong (_+ₖ ∣ base ∣) (rUnitₖ 1 ∣ x ∣) ∙ rUnitₖ 1 ∣ x ∣)
(λ x → rCancelₖ 1 ∣ x ∣)
(rUnit refl))
-cancelRₖ (suc (suc n)) =
elim2 (λ _ _ → isOfHLevelPath (4 + n) (isOfHLevelTrunc (4 + n)) _ _)
(wedgeconFun _ _ (λ _ _ → wedgeConHLevPath (suc n) _ _)
(λ x → cong (_+ₖ ∣ north ∣) (rUnitₖ (2 + n) ∣ x ∣) ∙ rUnitₖ (2 + n) ∣ x ∣)
(λ x → rCancelₖ (2 + n) ∣ x ∣)
(sym (rUnit _)))
-cancelLₖ : (n : ℕ) (x y : coHomK n) → (x +[ n ]ₖ y) -[ n ]ₖ x ≡ y
-cancelLₖ n x y = cong (λ z → z -[ n ]ₖ x) (commₖ n x y) ∙ -cancelRₖ n x y
-+cancelₖ : (n : ℕ) (x y : coHomK n) → (x -[ n ]ₖ y) +[ n ]ₖ y ≡ x
-+cancelₖ zero x y = sym (+Assoc x (0 - y) y) ∙ cong (x ℤ+_) (minusPlus y (pos 0))
-+cancelₖ (suc zero) =
elim2 (λ _ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _)
(wedgeconFun _ _ (λ _ _ → wedgeConHLevPath 0 _ _)
(λ x → cong (_+ₖ ∣ x ∣) (lUnitₖ 1 (-ₖ ∣ x ∣)) ∙ lCancelₖ 1 ∣ x ∣)
(λ x → cong (_+ₖ ∣ base ∣) (rUnitₖ 1 ∣ x ∣) ∙ rUnitₖ 1 ∣ x ∣)
refl)
-+cancelₖ (suc (suc n)) =
elim2 (λ _ _ → isOfHLevelPath (4 + n) (isOfHLevelTrunc (4 + n)) _ _)
(wedgeconFun _ _ (λ _ _ → wedgeConHLevPath (suc n) _ _)
(λ x → cong (_+ₖ ∣ x ∣) (lUnitₖ (2 + n) (-ₖ ∣ x ∣)) ∙ lCancelₖ (2 + n) ∣ x ∣)
(λ x → cong (_+ₖ ∣ north ∣) (rUnitₖ (2 + n) ∣ x ∣) ∙ rUnitₖ (2 + n) ∣ x ∣)
refl)
---- Group structure of cohomology groups
_+ₕ_ : {n : ℕ} → coHom n A → coHom n A → coHom n A
_+ₕ_ {n = n} = sRec2 § λ a b → ∣ (λ x → a x +[ n ]ₖ b x) ∣₂
-ₕ_ : {n : ℕ} → coHom n A → coHom n A
-ₕ_ {n = n} = sRec § λ a → ∣ (λ x → -[ n ]ₖ a x) ∣₂
_-ₕ_ : {n : ℕ} → coHom n A → coHom n A → coHom n A
_-ₕ_ {n = n} = sRec2 § λ a b → ∣ (λ x → a x -[ n ]ₖ b x) ∣₂
+ₕ-syntax : (n : ℕ) → coHom n A → coHom n A → coHom n A
+ₕ-syntax n = _+ₕ_ {n = n}
-ₕ-syntax : (n : ℕ) → coHom n A → coHom n A
-ₕ-syntax n = -ₕ_ {n = n}
-ₕ'-syntax : (n : ℕ) → coHom n A → coHom n A → coHom n A
-ₕ'-syntax n = _-ₕ_ {n = n}
syntax +ₕ-syntax n x y = x +[ n ]ₕ y
syntax -ₕ-syntax n x = -[ n ]ₕ x
syntax -ₕ'-syntax n x y = x -[ n ]ₕ y
0ₕ : (n : ℕ) → coHom n A
0ₕ n = ∣ (λ _ → (0ₖ n)) ∣₂
_+'ₕ_ : {n : ℕ} → coHom n A → coHom n A → coHom n A
_+'ₕ_ {n = n} x y = (x +ₕ 0ₕ _) +ₕ y +ₕ 0ₕ _
rUnitₕ : (n : ℕ) (x : coHom n A) → x +[ n ]ₕ (0ₕ n) ≡ x
rUnitₕ n = sElim (λ _ → isOfHLevelPath 1 (§ _ _))
λ a i → ∣ funExt (λ x → rUnitₖ n (a x)) i ∣₂
lUnitₕ : (n : ℕ) (x : coHom n A) → (0ₕ n) +[ n ]ₕ x ≡ x
lUnitₕ n = sElim (λ _ → isOfHLevelPath 1 (§ _ _))
λ a i → ∣ funExt (λ x → lUnitₖ n (a x)) i ∣₂
rCancelₕ : (n : ℕ) (x : coHom n A) → x +[ n ]ₕ (-[ n ]ₕ x) ≡ 0ₕ n
rCancelₕ n = sElim (λ _ → isOfHLevelPath 1 (§ _ _))
λ a i → ∣ funExt (λ x → rCancelₖ n (a x)) i ∣₂
lCancelₕ : (n : ℕ) (x : coHom n A) → (-[ n ]ₕ x) +[ n ]ₕ x ≡ 0ₕ n
lCancelₕ n = sElim (λ _ → isOfHLevelPath 1 (§ _ _))
λ a i → ∣ funExt (λ x → lCancelₖ n (a x)) i ∣₂
assocₕ : (n : ℕ) (x y z : coHom n A) → (x +[ n ]ₕ (y +[ n ]ₕ z)) ≡ ((x +[ n ]ₕ y) +[ n ]ₕ z)
assocₕ n = elim3 (λ _ _ _ → isOfHLevelPath 1 (§ _ _))
λ a b c i → ∣ funExt (λ x → assocₖ n (a x) (b x) (c x)) i ∣₂
commₕ : (n : ℕ) (x y : coHom n A) → (x +[ n ]ₕ y) ≡ (y +[ n ]ₕ x)
commₕ n = sElim2 (λ _ _ → isOfHLevelPath 1 (§ _ _))
λ a b i → ∣ funExt (λ x → commₖ n (a x) (b x)) i ∣₂
-cancelLₕ : (n : ℕ) (x y : coHom n A) → (x +[ n ]ₕ y) -[ n ]ₕ x ≡ y
-cancelLₕ n = sElim2 (λ _ _ → isOfHLevelPath 1 (§ _ _))
λ a b i → ∣ (λ x → -cancelLₖ n (a x) (b x) i) ∣₂
-cancelRₕ : (n : ℕ) (x y : coHom n A) → (y +[ n ]ₕ x) -[ n ]ₕ x ≡ y
-cancelRₕ n = sElim2 (λ _ _ → isOfHLevelPath 1 (§ _ _))
λ a b i → ∣ (λ x → -cancelRₖ n (a x) (b x) i) ∣₂
-+cancelₕ : (n : ℕ) (x y : coHom n A) → (x -[ n ]ₕ y) +[ n ]ₕ y ≡ x
-+cancelₕ n = sElim2 (λ _ _ → isOfHLevelPath 1 (§ _ _))
λ a b i → ∣ (λ x → -+cancelₖ n (a x) (b x) i) ∣₂
-- Group structure of reduced cohomology groups (in progress - might need K to compute properly first)
_+ₕ∙_ : {A : Pointed ℓ} {n : ℕ} → coHomRed n A → coHomRed n A → coHomRed n A
_+ₕ∙_ {n = zero} = sRec2 § λ { (a , pa) (b , pb) → ∣ (λ x → a x +[ zero ]ₖ b x)
, (λ i → (pa i +[ zero ]ₖ pb i)) ∣₂ }
_+ₕ∙_ {n = (suc zero)} = sRec2 § λ { (a , pa) (b , pb) → ∣ (λ x → a x +[ 1 ]ₖ b x)
, (λ i → pa i +[ 1 ]ₖ pb i) ∣₂ }
_+ₕ∙_ {n = (suc (suc n))} =
sRec2 § λ { (a , pa) (b , pb) → ∣ (λ x → a x +[ (2 + n) ]ₖ b x)
, (λ i → pa i +[ (2 + n) ]ₖ pb i) ∣₂ }
-ₕ∙_ : {A : Pointed ℓ} {n : ℕ} → coHomRed n A → coHomRed n A
-ₕ∙_ {n = zero} = sRec § λ {(f , p) → ∣ (λ x → -[ 0 ]ₖ (f x))
, cong (λ x → -[ 0 ]ₖ x) p ∣₂}
-ₕ∙_ {n = suc zero} = sRec § λ {(f , p) → ∣ (λ x → -ₖ (f x))
, cong -ₖ_ p ∣₂}
-ₕ∙_ {n = suc (suc n)} = sRec § λ {(f , p) → ∣ (λ x → -ₖ (f x))
, cong -ₖ_ p ∣₂}
0ₕ∙ : {A : Pointed ℓ} (n : ℕ) → coHomRed n A
0ₕ∙ n = ∣ (λ _ → 0ₖ n) , refl ∣₂
+ₕ∙-syntax : {A : Pointed ℓ} (n : ℕ) → coHomRed n A → coHomRed n A → coHomRed n A
+ₕ∙-syntax n = _+ₕ∙_ {n = n}
-ₕ∙-syntax : {A : Pointed ℓ} (n : ℕ) → coHomRed n A → coHomRed n A
-ₕ∙-syntax n = -ₕ∙_ {n = n}
-'ₕ∙-syntax : {A : Pointed ℓ} (n : ℕ) → coHomRed n A → coHomRed n A → coHomRed n A
-'ₕ∙-syntax n x y = _+ₕ∙_ {n = n} x (-ₕ∙_ {n = n} y)
syntax +ₕ∙-syntax n x y = x +[ n ]ₕ∙ y
syntax -ₕ∙-syntax n x = -[ n ]ₕ∙ x
syntax -'ₕ∙-syntax n x y = x -[ n ]ₕ∙ y
commₕ∙ : {A : Pointed ℓ} (n : ℕ) (x y : coHomRed n A) → x +[ n ]ₕ∙ y ≡ y +[ n ]ₕ∙ x
commₕ∙ zero =
sElim2 (λ _ _ → isOfHLevelPath 2 § _ _)
λ {(f , p) (g , q)
→ cong ∣_∣₂ (Σ≡Prop (λ _ → isSetℤ _ _) λ i x → commₖ 0 (f x) (g x) i)}
commₕ∙ (suc zero) =
sElim2 (λ _ _ → isOfHLevelPath 2 § _ _)
λ {(f , p) (g , q)
→ cong ∣_∣₂ (ΣPathP ((λ i x → commₖ 1 (f x) (g x) i)
, λ i j → commₖ 1 (p j) (q j) i))}
commₕ∙ {A = A} (suc (suc n)) =
sElim2 (λ _ _ → isOfHLevelPath 2 § _ _)
λ {(f , p) (g , q)
→ cong ∣_∣₂ (ΣPathP ((λ i x → commₖ (2 + n) (f x) (g x) i)
, λ i j → hcomp (λ k → λ {(i = i0) → p j +ₖ q j
; (i = i1) → q j +ₖ p j
; (j = i0) → commₖ (2 + n) (f (pt A)) (g (pt A)) i
; (j = i1) → rUnit (refl {x = 0ₖ (2 + n)}) (~ k) i})
(commₖ (2 + n) (p j) (q j) i)))}
rUnitₕ∙ : {A : Pointed ℓ} (n : ℕ) (x : coHomRed n A) → x +[ n ]ₕ∙ 0ₕ∙ n ≡ x
rUnitₕ∙ zero =
sElim (λ _ → isOfHLevelPath 2 § _ _)
λ {(f , p) → cong ∣_∣₂ (Σ≡Prop (λ _ → isSetℤ _ _) λ i x → rUnitₖ zero (f x) i)}
rUnitₕ∙ (suc zero) =
sElim (λ _ → isOfHLevelPath 2 § _ _)
λ {(f , p) → cong ∣_∣₂ (ΣPathP ((λ i x → rUnitₖ 1 (f x) i) , λ i j → rUnitₖ 1 (p j) i))}
rUnitₕ∙ (suc (suc n)) =
sElim (λ _ → isOfHLevelPath 2 § _ _)
λ {(f , p) → cong ∣_∣₂ (ΣPathP ((λ i x → rUnitₖ (2 + n) (f x) i) , λ i j → rUnitₖ (2 + n) (p j) i))}
lUnitₕ∙ : {A : Pointed ℓ} (n : ℕ) (x : coHomRed n A) → 0ₕ∙ n +[ n ]ₕ∙ x ≡ x
lUnitₕ∙ zero =
sElim (λ _ → isOfHLevelPath 2 § _ _)
λ {(f , p) → cong ∣_∣₂ (Σ≡Prop (λ _ → isSetℤ _ _) λ i x → lUnitₖ zero (f x) i)}
lUnitₕ∙ (suc zero) =
sElim (λ _ → isOfHLevelPath 2 § _ _)
λ {(f , p) → cong ∣_∣₂ (ΣPathP ((λ i x → lUnitₖ 1 (f x) i) , λ i j → lUnitₖ 1 (p j) i))}
lUnitₕ∙ (suc (suc n)) =
sElim (λ _ → isOfHLevelPath 2 § _ _)
λ {(f , p) → cong ∣_∣₂ (ΣPathP ((λ i x → lUnitₖ (2 + n) (f x) i) , λ i j → lUnitₖ (2 + n) (p j) i))}
private
pp : {A : Pointed ℓ} (n : ℕ) → (f : fst A → coHomK (suc (suc n)))
→ (p : f (snd A) ≡ snd (coHomK-ptd (suc (suc n))))
→ PathP (λ i → rCancelₖ (2 + n) (f (snd A)) i ≡ 0ₖ (suc (suc n)))
(λ i → (p i) +ₖ (-ₖ p i)) (λ _ → 0ₖ (suc (suc n)))
pp {A = A} n f p i j =
hcomp (λ k → λ {(i = i0) → rCancelₖ (suc (suc n)) (p j) (~ k)
; (i = i1) → 0ₖ (suc (suc n))
; (j = i0) → rCancelₖ (2 + n) (f (snd A)) (i ∨ ~ k)
; (j = i1) → rUnit (rUnit (λ _ → 0ₖ (suc (suc n))) (~ i)) (~ i) k})
(0ₖ (suc (suc n)))
rCancelₕ∙ : {A : Pointed ℓ} (n : ℕ) (x : coHomRed n A) → x +[ n ]ₕ∙ (-[ n ]ₕ∙ x) ≡ 0ₕ∙ n
rCancelₕ∙ zero =
sElim (λ _ → isOfHLevelPath 2 § _ _)
λ {(f , p) → cong ∣_∣₂ (Σ≡Prop (λ _ → isSetℤ _ _) λ i x → rCancelₖ zero (f x) i)}
rCancelₕ∙ {A = A} (suc zero) =
sElim (λ _ → isOfHLevelPath 2 § _ _)
λ {(f , p) → cong ∣_∣₂ (ΣPathP ((λ i x → rCancelₖ 1 (f x) i) , λ i j → rCancelₖ 1 (p j) i))}
rCancelₕ∙ {A = A} (suc (suc n)) =
sElim (λ _ → isOfHLevelPath 2 § _ _)
λ {(f , p)
→ cong ∣_∣₂ (ΣPathP ((λ i x → rCancelₖ (2 + n) (f x) i)
, pp n f p))}
lCancelₕ∙ : {A : Pointed ℓ} (n : ℕ) (x : coHomRed n A) → (-[ n ]ₕ∙ x) +[ n ]ₕ∙ x ≡ 0ₕ∙ n
lCancelₕ∙ zero =
sElim (λ _ → isOfHLevelPath 2 § _ _)
λ {(f , p) → cong ∣_∣₂ (Σ≡Prop (λ _ → isSetℤ _ _) λ i x → lCancelₖ zero (f x) i)}
lCancelₕ∙ {A = A} (suc zero) =
sElim (λ _ → isOfHLevelPath 2 § _ _)
λ {(f , p)
→ cong ∣_∣₂ (ΣPathP ((λ i x → lCancelₖ 1 (f x) i)
, λ i j → (lCancelₖ 1 (p j) i)))}
lCancelₕ∙ {A = A} (suc (suc n)) =
sElim (λ _ → isOfHLevelPath 2 § _ _)
λ {(f , p)
→ cong ∣_∣₂ (ΣPathP ((λ i x → lCancelₖ (2 + n) (f x) i)
, λ i j → lCancelₖ (2 + n) (p j) i))}
assocₕ∙ : {A : Pointed ℓ} (n : ℕ) (x y z : coHomRed n A)
→ (x +[ n ]ₕ∙ (y +[ n ]ₕ∙ z)) ≡ ((x +[ n ]ₕ∙ y) +[ n ]ₕ∙ z)
assocₕ∙ zero =
elim3 (λ _ _ _ → isOfHLevelPath 2 § _ _)
λ {(f , p) (g , q) (h , r)
→ cong ∣_∣₂ (Σ≡Prop (λ _ → isSetℤ _ _)
(λ i x → assocₖ zero (f x) (g x) (h x) i))}
assocₕ∙ (suc zero) =
elim3 (λ _ _ _ → isOfHLevelPath 2 § _ _)
λ {(f , p) (g , q) (h , r)
→ cong ∣_∣₂ (ΣPathP ((λ i x → assocₖ 1 (f x) (g x) (h x) i)
, λ i j → assocₖ 1 (p j) (q j) (r j) i))}
assocₕ∙ (suc (suc n)) =
elim3 (λ _ _ _ → isOfHLevelPath 2 § _ _)
λ {(f , p) (g , q) (h , r)
→ cong ∣_∣₂ (ΣPathP ((λ i x → assocₖ (2 + n) (f x) (g x) (h x) i)
, λ i j → assocₖ (2 + n) (p j) (q j) (r j) i))}
open IsSemigroup
open IsMonoid
open GroupStr
open IsGroupHom
coHomGr : (n : ℕ) (A : Type ℓ) → Group ℓ
coHomGr n A = coHom n A , coHomGrnA
where
coHomGrnA : GroupStr (coHom n A)
1g coHomGrnA = 0ₕ n
GroupStr._·_ coHomGrnA = λ x y → x +[ n ]ₕ y
inv coHomGrnA = λ x → -[ n ]ₕ x
isGroup coHomGrnA = helper
where
abstract
helper : IsGroup {G = coHom n A} (0ₕ n) (λ x y → x +[ n ]ₕ y) (λ x → -[ n ]ₕ x)
helper = makeIsGroup § (assocₕ n) (rUnitₕ n) (lUnitₕ n) (rCancelₕ n) (lCancelₕ n)
×coHomGr : (n : ℕ) (A : Type ℓ) (B : Type ℓ') → Group _
×coHomGr n A B = DirProd (coHomGr n A) (coHomGr n B)
coHomGroup : (n : ℕ) (A : Type ℓ) → AbGroup ℓ
fst (coHomGroup n A) = coHom n A
AbGroupStr.0g (snd (coHomGroup n A)) = 0ₕ n
AbGroupStr._+_ (snd (coHomGroup n A)) = _+ₕ_ {n = n}
AbGroupStr.- snd (coHomGroup n A) = -ₕ_ {n = n}
IsAbGroup.isGroup (AbGroupStr.isAbGroup (snd (coHomGroup n A))) = isGroup (snd (coHomGr n A))
IsAbGroup.comm (AbGroupStr.isAbGroup (snd (coHomGroup n A))) = commₕ n
-- Reduced cohomology group (direct def)
coHomRedGroupDir : (n : ℕ) (A : Pointed ℓ) → AbGroup ℓ
fst (coHomRedGroupDir n A) = coHomRed n A
AbGroupStr.0g (snd (coHomRedGroupDir n A)) = 0ₕ∙ n
AbGroupStr._+_ (snd (coHomRedGroupDir n A)) = _+ₕ∙_ {n = n}
AbGroupStr.- snd (coHomRedGroupDir n A) = -ₕ∙_ {n = n}
IsAbGroup.isGroup (AbGroupStr.isAbGroup (snd (coHomRedGroupDir n A))) = helper
where
abstract
helper : IsGroup {G = coHomRed n A} (0ₕ∙ n) (_+ₕ∙_ {n = n}) (-ₕ∙_ {n = n})
helper = makeIsGroup § (assocₕ∙ n) (rUnitₕ∙ n) (lUnitₕ∙ n) (rCancelₕ∙ n) (lCancelₕ∙ n)
IsAbGroup.comm (AbGroupStr.isAbGroup (snd (coHomRedGroupDir n A))) = commₕ∙ n
coHomRedGrDir : (n : ℕ) (A : Pointed ℓ) → Group ℓ
coHomRedGrDir n A = AbGroup→Group (coHomRedGroupDir n A)
-- Induced map
coHomFun : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} (n : ℕ) (f : A → B) → coHom n B → coHom n A
coHomFun n f = sRec § λ β → ∣ β ∘ f ∣₂
coHomMorph : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} (n : ℕ) (f : A → B) → GroupHom (coHomGr n B) (coHomGr n A)
fst (coHomMorph n f) = coHomFun n f
snd (coHomMorph n f) = makeIsGroupHom (helper n)
where
helper : ℕ → _
helper zero = sElim2 (λ _ _ → isOfHLevelPath 2 § _ _) λ _ _ → refl
helper (suc zero) = sElim2 (λ _ _ → isOfHLevelPath 2 § _ _) λ _ _ → refl
helper (suc (suc n)) = sElim2 (λ _ _ → isOfHLevelPath 2 § _ _) λ _ _ → refl
-- Alternative definition of cohomology using ΩKₙ instead. Useful for breaking proofs of group isos
-- up into smaller parts
coHomGrΩ : ∀ {ℓ} (n : ℕ) (A : Type ℓ) → Group ℓ
coHomGrΩ n A = ∥ (A → typ (Ω (coHomK-ptd (suc n)))) ∥₂ , coHomGrnA
where
coHomGrnA : GroupStr ∥ (A → typ (Ω (coHomK-ptd (suc n)))) ∥₂
1g coHomGrnA = ∣ (λ _ → refl) ∣₂
GroupStr._·_ coHomGrnA = sRec2 § λ p q → ∣ (λ x → p x ∙ q x) ∣₂
inv coHomGrnA = map λ f x → sym (f x)
isGroup coHomGrnA = helper
where
abstract
helper :
IsGroup {G = ∥ (A → typ (Ω (coHomK-ptd (suc n)))) ∥₂}
(∣ (λ _ → refl) ∣₂) (sRec2 § λ p q → ∣ (λ x → p x ∙ q x) ∣₂) (map λ f x → sym (f x))
helper = makeIsGroup § (elim3 (λ _ _ _ → isOfHLevelPath 2 § _ _)
(λ p q r → cong ∣_∣₂ (funExt λ x → assoc∙ (p x) (q x) (r x))))
(sElim (λ _ → isOfHLevelPath 2 § _ _) λ p → cong ∣_∣₂ (funExt λ x → sym (rUnit (p x))))
(sElim (λ _ → isOfHLevelPath 2 § _ _) λ p → cong ∣_∣₂ (funExt λ x → sym (lUnit (p x))))
(sElim (λ _ → isOfHLevelPath 2 § _ _) λ p → cong ∣_∣₂ (funExt λ x → rCancel (p x)))
(sElim (λ _ → isOfHLevelPath 2 § _ _) λ p → cong ∣_∣₂ (funExt λ x → lCancel (p x)))
--- the loopspace of Kₙ is commutative regardless of base
addIso : (n : ℕ) (x : coHomK n) → Iso (coHomK n) (coHomK n)
fun (addIso n x) y = y +[ n ]ₖ x
inv' (addIso n x) y = y -[ n ]ₖ x
rightInv (addIso n x) y = -+cancelₖ n y x
leftInv (addIso n x) y = -cancelRₖ n x y
baseChange : (n : ℕ) (x : coHomK (suc n)) → (0ₖ (suc n) ≡ 0ₖ (suc n)) ≃ (x ≡ x)
baseChange n x = isoToEquiv is
where
f : (n : ℕ) (x : coHomK (suc n)) → (0ₖ (suc n) ≡ 0ₖ (suc n)) → (x ≡ x)
f n x p = sym (rUnitₖ _ x) ∙∙ cong (x +ₖ_) p ∙∙ rUnitₖ _ x
g : (n : ℕ) (x : coHomK (suc n)) → (x ≡ x) → (0ₖ (suc n) ≡ 0ₖ (suc n))
g n x p = sym (rCancelₖ _ x) ∙∙ cong (λ y → y -ₖ x) p ∙∙ rCancelₖ _ x
f-g : (n : ℕ) (x : coHomK (suc n)) (p : x ≡ x) → f n x (g n x p) ≡ p
f-g n =
trElim (λ _ → isOfHLevelΠ (3 + n) λ _ → isOfHLevelPath (3 + n)
(isOfHLevelPath (3 + n) (isOfHLevelTrunc (3 + n)) _ _) _ _)
(ind n)
where
ind : (n : ℕ) (a : S₊ (suc n)) (p : ∣ a ∣ₕ ≡ ∣ a ∣ₕ) → f n ∣ a ∣ₕ (g n ∣ a ∣ₕ p) ≡ p
ind zero =
toPropElim (λ _ → isPropΠ λ _ → isOfHLevelTrunc 3 _ _ _ _)
λ p → cong (f zero (0ₖ 1)) (sym (rUnit _) ∙ (λ k i → rUnitₖ _ (p i) k))
∙∙ sym (rUnit _)
∙∙ λ k i → lUnitₖ _ (p i) k
ind (suc n) =
sphereElim (suc n) (λ _ → isOfHLevelΠ (2 + n) λ _ → isOfHLevelTrunc (4 + n) _ _ _ _)
λ p → cong (f (suc n) (0ₖ (2 + n)))
((λ k → (sym (rUnit (refl ∙ refl)) ∙ sym (rUnit refl)) k
∙∙ (λ i → p i +ₖ 0ₖ (2 + n)) ∙∙ (sym (rUnit (refl ∙ refl)) ∙ sym (rUnit refl)) k)
∙ (λ k → rUnit (λ i → rUnitₖ _ (p i) k) (~ k)))
∙ λ k → rUnit (λ i → lUnitₖ _ (p i) k) (~ k)
g-f : (n : ℕ) (x : coHomK (suc n)) (p : 0ₖ _ ≡ 0ₖ _) → g n x (f n x p) ≡ p
g-f n =
trElim (λ _ → isOfHLevelΠ (3 + n) λ _ → isOfHLevelPath (3 + n)
(isOfHLevelPath (3 + n) (isOfHLevelTrunc (3 + n)) _ _) _ _)
(ind n)
where
ind : (n : ℕ) (a : S₊ (suc n)) (p : 0ₖ (suc n) ≡ 0ₖ (suc n)) → g n ∣ a ∣ₕ (f n ∣ a ∣ₕ p) ≡ p
ind zero =
toPropElim (λ _ → isPropΠ λ _ → isOfHLevelTrunc 3 _ _ _ _)
λ p → cong (g zero (0ₖ 1)) (λ k → rUnit (λ i → lUnitₖ _ (p i) k) (~ k))
∙ (λ k → rUnit (λ i → rUnitₖ _ (p i) k) (~ k))
ind (suc n) =
sphereElim (suc n) (λ _ → isOfHLevelΠ (2 + n) λ _ → isOfHLevelTrunc (4 + n) _ _ _ _)
λ p → cong (g (suc n) (0ₖ (2 + n)))
(λ k → rUnit (λ i → lUnitₖ _ (p i) k) (~ k))
∙∙ (λ k → (sym (rUnit (refl ∙ refl)) ∙ sym (rUnit refl)) k
∙∙ (λ i → p i +ₖ 0ₖ (2 + n))
∙∙ (sym (rUnit (refl ∙ refl)) ∙ sym (rUnit refl)) k)
∙∙ λ k → rUnit (λ i → rUnitₖ _ (p i) k) (~ k)
is : Iso _ _
fun is = f n x
inv' is = g n x
rightInv is = f-g n x
leftInv is = g-f n x
isCommΩK-based : (n : ℕ) (x : coHomK n) → isComm∙ (coHomK n , x)
isCommΩK-based zero x p q = isSetℤ _ _ (p ∙ q) (q ∙ p)
isCommΩK-based (suc zero) x =
subst isComm∙ (λ i → coHomK 1 , lUnitₖ 1 x i)
(ptdIso→comm {A = (_ , 0ₖ 1)} (addIso 1 x)
(isCommΩK 1))
isCommΩK-based (suc (suc n)) x =
subst isComm∙ (λ i → coHomK (suc (suc n)) , lUnitₖ (suc (suc n)) x i)
(ptdIso→comm {A = (_ , 0ₖ (suc (suc n)))} (addIso (suc (suc n)) x)
(isCommΩK (suc (suc n))))
-- hidden versions of cohom stuff using the "lock" hack. The locked versions can be used when proving things.
-- Swapping "key" for "tt*" will then give computing functions.
Unit' : Type₀
Unit' = lockUnit {ℓ-zero}
lock : ∀ {ℓ} {A : Type ℓ} → Unit' → A → A
lock unlock = λ x → x
module lockedCohom (key : Unit') where
+K : (n : ℕ) → coHomK n → coHomK n → coHomK n
+K n = lock key (_+ₖ_ {n = n})
-K : (n : ℕ) → coHomK n → coHomK n
-K n = lock key (-ₖ_ {n = n})
-Kbin : (n : ℕ) → coHomK n → coHomK n → coHomK n
-Kbin n x y = +K n x (-K n y)
rUnitK : (n : ℕ) (x : coHomK n) → +K n x (0ₖ n) ≡ x
rUnitK n x = pm key
where
pm : (t : Unit') → lock t (_+ₖ_ {n = n}) x (0ₖ n) ≡ x
pm unlock = rUnitₖ n x
lUnitK : (n : ℕ) (x : coHomK n) → +K n (0ₖ n) x ≡ x
lUnitK n x = pm key
where
pm : (t : Unit') → lock t (_+ₖ_ {n = n}) (0ₖ n) x ≡ x
pm unlock = lUnitₖ n x
rCancelK : (n : ℕ) (x : coHomK n) → +K n x (-K n x) ≡ 0ₖ n
rCancelK n x = pm key
where
pm : (t : Unit') → lock t (_+ₖ_ {n = n}) x (lock t (-ₖ_ {n = n}) x) ≡ 0ₖ n
pm unlock = rCancelₖ n x
lCancelK : (n : ℕ) (x : coHomK n) → +K n (-K n x) x ≡ 0ₖ n
lCancelK n x = pm key
where
pm : (t : Unit') → lock t (_+ₖ_ {n = n}) (lock t (-ₖ_ {n = n}) x) x ≡ 0ₖ n
pm unlock = lCancelₖ n x
-cancelRK : (n : ℕ) (x y : coHomK n) → -Kbin n (+K n y x) x ≡ y
-cancelRK n x y = pm key
where
pm : (t : Unit') → lock t (_+ₖ_ {n = n}) (lock t (_+ₖ_ {n = n}) y x) (lock t (-ₖ_ {n = n}) x) ≡ y
pm unlock = -cancelRₖ n x y
-cancelLK : (n : ℕ) (x y : coHomK n) → -Kbin n (+K n x y) x ≡ y
-cancelLK n x y = pm key
where
pm : (t : Unit') → lock t (_+ₖ_ {n = n}) (lock t (_+ₖ_ {n = n}) x y) (lock t (-ₖ_ {n = n}) x) ≡ y
pm unlock = -cancelLₖ n x y
-+cancelK : (n : ℕ) (x y : coHomK n) → +K n (-Kbin n x y) y ≡ x
-+cancelK n x y = pm key
where
pm : (t : Unit') → lock t (_+ₖ_ {n = n}) (lock t (_+ₖ_ {n = n}) x (lock t (-ₖ_ {n = n}) y)) y ≡ x
pm unlock = -+cancelₖ n x y
assocK : (n : ℕ) (x y z : coHomK n) → +K n x (+K n y z) ≡ +K n (+K n x y) z
assocK n x y z = pm key
where
pm : (t : Unit') → lock t (_+ₖ_ {n = n}) x (lock t (_+ₖ_ {n = n}) y z)
≡ lock t (_+ₖ_ {n = n}) (lock t (_+ₖ_ {n = n}) x y) z
pm unlock = assocₖ n x y z
commK : (n : ℕ) (x y : coHomK n) → +K n x y ≡ +K n y x
commK n x y = pm key
where
pm : (t : Unit') → lock t (_+ₖ_ {n = n}) x y ≡ lock t (_+ₖ_ {n = n}) y x
pm unlock = commₖ n x y
-- cohom
+H : (n : ℕ) (x y : coHom n A) → coHom n A
+H n = sRec2 § λ a b → ∣ (λ x → +K n (a x) (b x)) ∣₂
-H : (n : ℕ) (x : coHom n A) → coHom n A
-H n = sRec § λ a → ∣ (λ x → -K n (a x)) ∣₂
-Hbin : (n : ℕ) → coHom n A → coHom n A → coHom n A
-Hbin n = sRec2 § λ a b → ∣ (λ x → -Kbin n (a x) (b x)) ∣₂
rUnitH : (n : ℕ) (x : coHom n A) → +H n x (0ₕ n) ≡ x
rUnitH n = sElim (λ _ → isOfHLevelPath 1 (§ _ _))
λ a i → ∣ funExt (λ x → rUnitK n (a x)) i ∣₂
lUnitH : (n : ℕ) (x : coHom n A) → +H n (0ₕ n) x ≡ x
lUnitH n = sElim (λ _ → isOfHLevelPath 1 (§ _ _))
λ a i → ∣ funExt (λ x → lUnitK n (a x)) i ∣₂
rCancelH : (n : ℕ) (x : coHom n A) → +H n x (-H n x) ≡ 0ₕ n
rCancelH n = sElim (λ _ → isOfHLevelPath 1 (§ _ _))
λ a i → ∣ funExt (λ x → rCancelK n (a x)) i ∣₂
lCancelH : (n : ℕ) (x : coHom n A) → +H n (-H n x) x ≡ 0ₕ n
lCancelH n = sElim (λ _ → isOfHLevelPath 1 (§ _ _))
λ a i → ∣ funExt (λ x → lCancelK n (a x)) i ∣₂
assocH : (n : ℕ) (x y z : coHom n A) → (+H n x (+H n y z)) ≡ (+H n (+H n x y) z)
assocH n = elim3 (λ _ _ _ → isOfHLevelPath 1 (§ _ _))
λ a b c i → ∣ funExt (λ x → assocK n (a x) (b x) (c x)) i ∣₂
commH : (n : ℕ) (x y : coHom n A) → (+H n x y) ≡ (+H n y x)
commH n = sElim2 (λ _ _ → isOfHLevelPath 1 (§ _ _))
λ a b i → ∣ funExt (λ x → commK n (a x) (b x)) i ∣₂
-cancelRH : (n : ℕ) (x y : coHom n A) → -Hbin n (+H n y x) x ≡ y
-cancelRH n = sElim2 (λ _ _ → isOfHLevelPath 1 (§ _ _))
λ a b i → ∣ (λ x → -cancelRK n (a x) (b x) i) ∣₂
-cancelLH : (n : ℕ) (x y : coHom n A) → -Hbin n (+H n x y) x ≡ y
-cancelLH n = sElim2 (λ _ _ → isOfHLevelPath 1 (§ _ _))
λ a b i → ∣ (λ x → -cancelLK n (a x) (b x) i) ∣₂
-+cancelH : (n : ℕ) (x y : coHom n A) → +H n (-Hbin n x y) y ≡ x
-+cancelH n = sElim2 (λ _ _ → isOfHLevelPath 1 (§ _ _))
λ a b i → ∣ (λ x → -+cancelK n (a x) (b x) i) ∣₂
lUnitK≡rUnitK : (key : Unit') (n : ℕ) → lockedCohom.lUnitK key n (0ₖ n) ≡ lockedCohom.rUnitK key n (0ₖ n)
lUnitK≡rUnitK unlock = lUnitₖ≡rUnitₖ
open GroupStr renaming (_·_ to _+gr_)
open IsGroupHom
-- inducedCoHom : ∀ {ℓ ℓ'} {A : Type ℓ} {G : Group {ℓ'}} {n : ℕ}
-- → GroupIso (coHomGr n A) G
-- → Group
-- inducedCoHom {A = A} {G = G} {n = n} e =
-- InducedGroup (coHomGr n A)
-- (coHom n A , λ x y → Iso.inv (isom e) (_+gr_ (snd G) (fun (isom e) x)
-- (fun (isom e) y)))
-- (idEquiv _)
-- λ x y → sym (leftInv (isom e) _)
-- ∙ cong (Iso.inv (isom e)) (isHom e x y)
-- induced+ : ∀ {ℓ ℓ'} {A : Type ℓ} {G : Group {ℓ'}} {n : ℕ}
-- → (e : GroupIso (coHomGr n A) G)
-- → fst (inducedCoHom e) → fst (inducedCoHom e) → fst (inducedCoHom e)
-- induced+ e = _+gr_ (snd (inducedCoHom e))
-- inducedCoHomIso : ∀ {ℓ ℓ'} {A : Type ℓ} {G : Group {ℓ'}} {n : ℕ}
-- → (e : GroupIso (coHomGr n A) G)
-- → GroupIso (coHomGr n A) (inducedCoHom e)
-- isom (inducedCoHomIso e) = idIso
-- isHom (inducedCoHomIso e) x y = sym (leftInv (isom e) _)
-- ∙ cong (Iso.inv (isom e)) (isHom e x y)
-- inducedCoHomPath : ∀ {ℓ ℓ'} {A : Type ℓ} {G : Group {ℓ'}} {n : ℕ}
-- → (e : GroupIso (coHomGr n A) G)
-- → coHomGr n A ≡ inducedCoHom e
-- inducedCoHomPath e = InducedGroupPath _ _ _ _
| 44.586319
| 138
| 0.4765
|
a16f302cd11d2409538d58165a44e540572965ec
| 3,385
|
agda
|
Agda
|
agda-stdlib/src/Algebra/Properties/Ring.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/src/Algebra/Properties/Ring.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Algebra/Properties/Ring.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Some basic properties of Rings
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Algebra
module Algebra.Properties.Ring {r₁ r₂} (R : Ring r₁ r₂) where
open Ring R
import Algebra.Properties.AbelianGroup as AbelianGroupProperties
open import Function using (_$_)
open import Relation.Binary.Reasoning.Setoid setoid
------------------------------------------------------------------------
-- Export properties of abelian groups
open AbelianGroupProperties +-abelianGroup public
renaming
( ε⁻¹≈ε to -0#≈0#
; ∙-cancelˡ to +-cancelˡ
; ∙-cancelʳ to +-cancelʳ
; ∙-cancel to +-cancel
; ⁻¹-involutive to -‿involutive
; ⁻¹-injective to -‿injective
; ⁻¹-anti-homo-∙ to -‿anti-homo-+
; identityˡ-unique to +-identityˡ-unique
; identityʳ-unique to +-identityʳ-unique
; identity-unique to +-identity-unique
; inverseˡ-unique to +-inverseˡ-unique
; inverseʳ-unique to +-inverseʳ-unique
; ⁻¹-∙-comm to -‿+-comm
-- DEPRECATED
; left-identity-unique to +-left-identity-unique
; right-identity-unique to +-right-identity-unique
; left-inverse-unique to +-left-inverse-unique
; right-inverse-unique to +-right-inverse-unique
)
------------------------------------------------------------------------
-- Properties of -_
-‿distribˡ-* : ∀ x y → - (x * y) ≈ - x * y
-‿distribˡ-* x y = sym $ begin
- x * y ≈⟨ sym $ +-identityʳ _ ⟩
- x * y + 0# ≈⟨ +-congˡ $ sym (-‿inverseʳ _) ⟩
- x * y + (x * y + - (x * y)) ≈⟨ sym $ +-assoc _ _ _ ⟩
- x * y + x * y + - (x * y) ≈⟨ +-congʳ $ sym (distribʳ _ _ _) ⟩
(- x + x) * y + - (x * y) ≈⟨ +-congʳ $ *-congʳ $ -‿inverseˡ _ ⟩
0# * y + - (x * y) ≈⟨ +-congʳ $ zeroˡ _ ⟩
0# + - (x * y) ≈⟨ +-identityˡ _ ⟩
- (x * y) ∎
-‿distribʳ-* : ∀ x y → - (x * y) ≈ x * - y
-‿distribʳ-* x y = sym $ begin
x * - y ≈⟨ sym $ +-identityˡ _ ⟩
0# + x * - y ≈⟨ +-congʳ $ sym (-‿inverseˡ _) ⟩
- (x * y) + x * y + x * - y ≈⟨ +-assoc _ _ _ ⟩
- (x * y) + (x * y + x * - y) ≈⟨ +-congˡ $ sym (distribˡ _ _ _) ⟩
- (x * y) + x * (y + - y) ≈⟨ +-congˡ $ *-congˡ $ -‿inverseʳ _ ⟩
- (x * y) + x * 0# ≈⟨ +-congˡ $ zeroʳ _ ⟩
- (x * y) + 0# ≈⟨ +-identityʳ _ ⟩
- (x * y) ∎
------------------------------------------------------------------------
-- DEPRECATED NAMES
------------------------------------------------------------------------
-- Please use the new names as continuing support for the old names is
-- not guaranteed.
-- Version 1.1
-‿*-distribˡ : ∀ x y → - x * y ≈ - (x * y)
-‿*-distribˡ x y = sym (-‿distribˡ-* x y)
{-# WARNING_ON_USAGE -‿*-distribˡ
"Warning: -‿*-distribˡ was deprecated in v1.1.
Please use -‿distribˡ-* instead.
NOTE: the equality is flipped so you will need sym (-‿distribˡ-* ...)."
#-}
-‿*-distribʳ : ∀ x y → x * - y ≈ - (x * y)
-‿*-distribʳ x y = sym (-‿distribʳ-* x y)
{-# WARNING_ON_USAGE -‿*-distribʳ
"Warning: -‿*-distribʳ was deprecated in v1.1.
Please use -‿distribʳ-* instead.
NOTE: the equality is flipped so you will need sym (-‿distribʳ-* ...)."
#-}
| 36.793478
| 72
| 0.458789
|
500c028baa3002d38b1cd69b3b8c22e8010a6675
| 4,952
|
agda
|
Agda
|
src/exercices/stack.agda
|
d-plaindoux/colca
|
a81447af3ab2ba898bb7d57be71369abbba12d81
|
[
"MIT"
] | 2
|
2021-03-12T18:31:14.000Z
|
2021-05-04T09:35:36.000Z
|
src/exercices/stack.agda
|
d-plaindoux/colca
|
a81447af3ab2ba898bb7d57be71369abbba12d81
|
[
"MIT"
] | null | null | null |
src/exercices/stack.agda
|
d-plaindoux/colca
|
a81447af3ab2ba898bb7d57be71369abbba12d81
|
[
"MIT"
] | null | null | null |
module Stack where
open import Data.Bool using (Bool; true; false)
open import Data.Nat using (ℕ; zero; suc)
import Relation.Binary.PropositionalEquality as Eq
open Eq using (_≡_; refl; cong)
open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _∎; step-≡)
module V1 where
{-
This first version introduces the Stack abstract data type.
-}
data Stack (A : Set) : Set where
∅ : Stack A
_>>_ : A → Stack A → Stack A
infixr 50 _>>_
push : ∀ {A} → A → Stack A → Stack A
push a s = a >> s
peek : ∀ {A} → (S : Stack A) → A
-- May be absurd can be used here but how?
peek (a >> _) = a
pop : ∀ {A} → (S : Stack A) → Stack A
-- May be absurd can be used here but how?
pop (a >> s) = s
module Example where
_ : Stack Bool
_ = true >> false >> ∅
module Laws where
law1 : ∀ {A} (a : A) (s : Stack A) -> peek (push a s) ≡ a
law1 a s =
begin
peek (push a s)
≡⟨⟩
peek (a >> s)
≡⟨⟩
a
∎
law2 : ∀ {A} {a : A} {s : Stack A} → pop (push a s) ≡ s
law2 = refl
module V2 where
{-
This second version introduces the expression as constraint in the type definition.
This prevents incomplete pattern matching for peek and pop.
For this purpose we first design empty? predicate and then we use it in the type definition
of peek and pop.
-}
data Stack (A : Set) : Set where
∅ : Stack A
_>>_ : A → Stack A → Stack A
infixr 50 _>>_
empty? : ∀ {A} → Stack A → Bool
empty? ∅ = true
empty? _ = false
push : ∀ {A} → A → Stack A → Stack A
push a s = a >> s
peek : ∀ {A} → (S : Stack A) -> {empty? S ≡ false} → A
peek (a >> _) = a
pop : ∀ {A} → (S : Stack A) -> {empty? S ≡ false} → Stack A
pop (a >> s) = s
module Example where
_ : Stack Bool
_ = pop (push true ∅) {refl}
module Laws where
law1 : ∀ {A} {a : A} {s : Stack A} → peek (push a s) {refl} ≡ a
law1 = refl
law2 : ∀ {A} {a : A} {s : Stack A} → pop (push a s) {refl} ≡ s
law2 = refl
module V3 where
{-
In this third version we use a GADT for the Stack data representation.
A Kind then is design on purpose and a phantom type is used for the
association between the stack and the kind.
-}
data Kind : Set where
Empty : Kind
NotEmpty : Kind
data Stack (A : Set) : Kind → Set where
∅ : Stack A Empty
_>>_ : ∀ {B} → A → Stack A B → Stack A NotEmpty
infixr 50 _>>_
push : ∀ {A B} → A → Stack A B → Stack A NotEmpty
push a s = a >> s
peek : ∀ {A} → Stack A NotEmpty → A
peek (a >> _) = a
{-
B is in the ouput only! => No constraint with the input.
Writing such pop function is impossible as is.
pop : ∀ {A B} → Stack A NotEmpty → Stack A B
pop (_ >> s) = s
-}
module Example where
_ : Stack Bool NotEmpty
_ = push true ∅
module Laws where
law1 : ∀ {A B} {a : A} {s : Stack A B} → peek (push a s) ≡ a
law1 = refl
-- law2 cannot be expressed ...
module V4 where
{-
In this fourth version we slightly review the NotEmpty construction.
This opens the opportunity to express the pop function since a
dependency can by modeled in the corresponding type definition.
-}
data Kind : Set where
Empty : Kind
NotEmpty : Kind → Kind
data Stack (A : Set) : Kind → Set where
∅ : Stack A Empty
_>>_ : ∀ {B} → A → Stack A B → Stack A (NotEmpty B)
infixr 50 _>>_
push : ∀ {A B} → A → Stack A B → Stack A (NotEmpty B)
push a s = a >> s
peek : ∀ {A B} → Stack A (NotEmpty B) → A
peek (a >> _) = a
pop : ∀ {A B} → Stack A (NotEmpty B) → Stack A B
pop (_ >> s) = s
module Example where
_ : Stack Bool (NotEmpty Empty)
_ = push true ∅
module Laws where
law1 : ∀ {A B} {a : A} {s : Stack A B} → peek (push a s) ≡ a
law1 = refl
law2 : ∀ {A B} {a : A} {s : Stack A B} → pop (push a s) ≡ s
law2 = refl
module V5 where
{-
In this last version we show that previous Kind definiton is isomorphic
with the Natural.
-}
data Stack (A : Set) : ℕ → Set where
∅ : Stack A 0
_>>_ : ∀ {B} → A → Stack A B → Stack A (suc B)
infixr 50 _>>_
push : ∀ {A B} → A → Stack A B → Stack A (suc B)
push a s = a >> s
peek : ∀ {A B} → Stack A (suc B) → A
peek (a >> _) = a
pop : ∀ {A B} → Stack A (suc B) → Stack A B
pop (_ >> s) = s
module Example where
_ : Stack Bool 1
_ = push true ∅
module Laws where
law1 : ∀ {A B} {a : A} {s : Stack A B} → peek (push a s) ≡ a
law1 = refl
law2 : ∀ {A B} {a : A} {s : Stack A B} → pop (push a s) ≡ s
law2 = refl
| 25.137056
| 95
| 0.510299
|
4df73cbdc3ac3eb61f8e2807e7c25789acb88366
| 1,699
|
agda
|
Agda
|
Cubical/Foundations/Pointed/FunExt.agda
|
L-TChen/cubical
|
60226aacd7b386aef95d43a0c29c4eec996348a8
|
[
"MIT"
] | null | null | null |
Cubical/Foundations/Pointed/FunExt.agda
|
L-TChen/cubical
|
60226aacd7b386aef95d43a0c29c4eec996348a8
|
[
"MIT"
] | null | null | null |
Cubical/Foundations/Pointed/FunExt.agda
|
L-TChen/cubical
|
60226aacd7b386aef95d43a0c29c4eec996348a8
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Foundations.Pointed.FunExt where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Pointed.Base
open import Cubical.Foundations.Pointed.Properties
open import Cubical.Foundations.Pointed.Homotopy
private
variable
ℓ ℓ' : Level
module _ {A : Pointed ℓ} {B : typ A → Type ℓ'} {ptB : B (pt A)} where
-- pointed function extensionality
funExt∙P : {f g : Π∙ A B ptB} → f ∙∼P g → f ≡ g
funExt∙P (h , h∙) i .fst x = h x i
funExt∙P (h , h∙) i .snd = h∙ i
-- inverse of pointed function extensionality
funExt∙P⁻ : {f g : Π∙ A B ptB} → f ≡ g → f ∙∼P g
funExt∙P⁻ p .fst a i = p i .fst a
funExt∙P⁻ p .snd i = p i .snd
-- function extensionality is an isomorphism, PathP version
funExt∙PIso : (f g : Π∙ A B ptB) → Iso (f ∙∼P g) (f ≡ g)
Iso.fun (funExt∙PIso f g) = funExt∙P {f = f} {g = g}
Iso.inv (funExt∙PIso f g) = funExt∙P⁻ {f = f} {g = g}
Iso.rightInv (funExt∙PIso f g) p i j = p j
Iso.leftInv (funExt∙PIso f g) h _ = h
-- transformed to equivalence
funExt∙P≃ : (f g : Π∙ A B ptB) → (f ∙∼P g) ≃ (f ≡ g)
funExt∙P≃ f g = isoToEquiv (funExt∙PIso f g)
-- funExt∙≃ using the other kind of pointed homotopy
funExt∙≃ : (f g : Π∙ A B ptB) → (f ∙∼ g) ≃ (f ≡ g)
funExt∙≃ f g = compEquiv (∙∼≃∙∼P f g) (funExt∙P≃ f g)
-- standard pointed function extensionality and its inverse
funExt∙ : {f g : Π∙ A B ptB} → f ∙∼ g → f ≡ g
funExt∙ {f = f} {g = g} = equivFun (funExt∙≃ f g)
funExt∙⁻ : {f g : Π∙ A B ptB} → f ≡ g → f ∙∼ g
funExt∙⁻ {f = f} {g = g} = equivFun (invEquiv (funExt∙≃ f g))
| 34.673469
| 69
| 0.60977
|
0646bfb31569989a210da5d4c8d12296a3450a6a
| 589
|
agda
|
Agda
|
test/asset/agda-stdlib-1.0/Data/W/WithK.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
test/asset/agda-stdlib-1.0/Data/W/WithK.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Data/W/WithK.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Some code related to the W type that relies on the K rule
------------------------------------------------------------------------
{-# OPTIONS --with-K --safe #-}
module Data.W.WithK where
open import Data.Product
open import Data.Container.Core
open import Data.W
open import Agda.Builtin.Equality
module _ {s p} {C : Container s p}
{s : Shape C} {f : Position C s → W C} where
sup-injective₂ : ∀ {g} → sup (s , f) ≡ sup (s , g) → f ≡ g
sup-injective₂ refl = refl
| 28.047619
| 72
| 0.490662
|
4db915116fd0c58215c133850b5bdf23b0b6ef55
| 7,384
|
agda
|
Agda
|
src/FRP/LTL/Time.agda
|
agda/agda-frp-ltl
|
e88107d7d192cbfefd0a94505e6a5793afe1a7a5
|
[
"MIT"
] | 21
|
2015-07-02T20:25:05.000Z
|
2020-06-15T02:51:13.000Z
|
src/FRP/LTL/Time.agda
|
agda/agda-frp-ltl
|
e88107d7d192cbfefd0a94505e6a5793afe1a7a5
|
[
"MIT"
] | 2
|
2015-03-01T07:01:31.000Z
|
2015-03-02T15:23:53.000Z
|
src/FRP/LTL/Time.agda
|
agda/agda-frp-ltl
|
e88107d7d192cbfefd0a94505e6a5793afe1a7a5
|
[
"MIT"
] | 3
|
2015-03-01T07:33:00.000Z
|
2022-03-12T11:39:04.000Z
|
open import Function using ( _∘_ )
open import Data.Product using ( ∃ ; _×_ ; _,_ )
open import Data.Sum using ( _⊎_ ; inj₁ ; inj₂ )
open import Data.Empty using ( ⊥ ; ⊥-elim )
open import Data.Nat using ( ℕ ; zero ; suc ) renaming ( _+_ to _+ℕ_ ; _≤_ to _≤ℕ_ )
open import Relation.Binary.PropositionalEquality using
( _≡_ ; _≢_ ; refl ; sym ; cong ; cong₂ ; subst₂ ; inspect ; [_] )
open import Relation.Nullary using ( ¬_ ; Dec ; yes ; no )
open import FRP.LTL.Util using ( _trans_ ; _∋_ ; m+n≡0-impl-m≡0 ; ≤0-impl-≡0 ; 1+n≰n )
renaming ( +-comm to +ℕ-comm ; +-assoc to +ℕ-assoc )
open Relation.Binary.PropositionalEquality.≡-Reasoning using ( begin_ ; _≡⟨_⟩_ ; _∎ )
module FRP.LTL.Time where
infix 2 _≤_ _≥_ _≰_ _≱_ _<_ _>_
infixr 4 _,_
infixr 5 _≤-trans_ _<-transˡ_ _<-transʳ_ _≤-asym_ _≤-total_
infixl 6 _+_ _∸_
-- Time has a cancellative action _+_ which respects the monoid structure of ℕ
postulate
Time : Set
_+_ : Time → ℕ → Time
+-unit : ∀ t → (t + 0 ≡ t)
+-assoc : ∀ t m n → ((t + m) + n ≡ t + (m +ℕ n))
+-cancelˡ : ∀ t {m n} → (t + m ≡ t + n) → (m ≡ n)
+-cancelʳ : ∀ {s t} n → (s + n ≡ t + n) → (s ≡ t)
-- The order on time is derived from +
data _≤_ (t u : Time) : Set where
_,_ : ∀ n → (t + n ≡ u) → (t ≤ u)
-- Floored subtraction t ∸ u is the smallest n such that t ≤ u + n
postulate
_∸_ : Time → Time → ℕ
t≤u+t∸u : ∀ {t u} → (t ≤ u + (t ∸ u))
∸-min : ∀ {t u n} → (t ≤ u + n) → (t ∸ u ≤ℕ n)
-- End of postulates.
suc-cancelʳ : ∀ {t u m n} → (t + suc m ≡ u + suc n) → (t + m ≡ u + n)
suc-cancelʳ {t} {u} {m} {n} t+1+m≡u+1+n =
+-cancelʳ 1
(+-assoc t m 1 trans
cong₂ _+_ refl (+ℕ-comm m 1) trans
t+1+m≡u+1+n trans
cong₂ _+_ refl (+ℕ-comm 1 n) trans
sym (+-assoc u n 1))
-- Syntax sugar for ≤
_≥_ : Time → Time → Set
t ≥ u = u ≤ t
_≰_ : Time → Time → Set
t ≰ u = ¬(t ≤ u)
_≱_ : Time → Time → Set
t ≱ u = u ≰ t
_<_ : Time → Time → Set
t < u = (t ≤ u) × (u ≰ t)
_>_ : Time → Time → Set
t > u = u < t
-- ≤ is a decidable total order
≤-refl : ∀ {t} → (t ≤ t)
≤-refl {t} = (0 , +-unit t)
_≤-trans_ : ∀ {t u v} → (t ≤ u) → (u ≤ v) → (t ≤ v)
_≤-trans_ {t} {u} {v} (m , t+m≡u) (n , u+n≡v) =
(m +ℕ n , (sym (+-assoc t m n)) trans (cong₂ _+_ t+m≡u refl) trans u+n≡v)
≡-impl-≤ : ∀ {t u} → (t ≡ u) → (t ≤ u)
≡-impl-≤ refl = ≤-refl
≡-impl-≥ : ∀ {t u} → (t ≡ u) → (t ≥ u)
≡-impl-≥ refl = ≤-refl
_≤-asym_ : ∀ {t u} → (t ≤ u) → (u ≤ t) → (t ≡ u)
(m , t+m≡u) ≤-asym (n , u+n≡t) =
sym (+-unit _) trans cong₂ _+_ refl (sym m≡0) trans t+m≡u where
m≡0 : m ≡ 0
m≡0 = m+n≡0-impl-m≡0 m n (+-cancelˡ _
(sym (+-assoc _ m n) trans
cong₂ _+_ t+m≡u refl trans
u+n≡t trans sym (+-unit _)))
≤-impl-∸≡0 : ∀ {t u} → (t ≤ u) → (t ∸ u ≡ 0)
≤-impl-∸≡0 t≤u with (∸-min (t≤u ≤-trans ≡-impl-≤ (sym (+-unit _))))
≤-impl-∸≡0 t≤u | t∸u≤0 = ≤0-impl-≡0 t∸u≤0
∸≡0-impl-≤ : ∀ {t u} → (t ∸ u ≡ 0) → (t ≤ u)
∸≡0-impl-≤ t∸u≡0 = t≤u+t∸u ≤-trans ≡-impl-≤ (cong₂ _+_ refl t∸u≡0 trans +-unit _)
∸≢0-impl-≰ : ∀ {t u n} → (t ∸ u ≡ suc n) → (t ≰ u)
∸≢0-impl-≰ t∸u≡1+n t≤u
with sym t∸u≡1+n trans ≤0-impl-≡0 (∸-min (t≤u ≤-trans ≡-impl-≤ (sym (+-unit _))))
∸≢0-impl-≰ t∸u≡1+n t≤u
| ()
t∸u≢0-impl-u∸t≡0 : ∀ t u {n} → (t ∸ u ≡ suc n) → (u ∸ t ≡ 0)
t∸u≢0-impl-u∸t≡0 t u {n} t∸u≡1+n with t≤u+t∸u {t} {u}
t∸u≢0-impl-u∸t≡0 t u {n} t∸u≡1+n | (zero , t+0≡u+t∸u) =
≤-impl-∸≡0 (t ∸ u , sym t+0≡u+t∸u trans +-unit t)
t∸u≢0-impl-u∸t≡0 t u {n} t∸u≡1+n | (suc m , t+1+m≡u+t∸u) =
⊥-elim (1+n≰n n (subst₂ _≤ℕ_ t∸u≡1+n refl
(∸-min (m , suc-cancelʳ (t+1+m≡u+t∸u trans cong₂ _+_ refl t∸u≡1+n)))))
_≤-total_ : ∀ t u → (t ≤ u) ⊎ (u < t)
t ≤-total u with t ∸ u | inspect (_∸_ t) u
t ≤-total u | zero | [ t∸u≡0 ] = inj₁ (∸≡0-impl-≤ t∸u≡0)
t ≤-total u | suc n | [ t∸u≡1+n ] with t∸u≢0-impl-u∸t≡0 t u t∸u≡1+n
t ≤-total u | suc n | [ t∸u≡1+n ] | u∸t≡0 = inj₂ (∸≡0-impl-≤ u∸t≡0 , ∸≢0-impl-≰ t∸u≡1+n)
-- Case analysis on ≤
data _≤-Case_ (t u : Time) : Set where
lt : .(t < u) → (t ≤-Case u)
eq : .(t ≡ u) → (t ≤-Case u)
gt : .(u < t) → (t ≤-Case u)
_≤-case_ : ∀ t u → (t ≤-Case u)
t ≤-case u with (t ∸ u) | inspect (_∸_ t) u | u ∸ t | inspect (_∸_ u) t
t ≤-case u | zero | [ t∸u≡0 ] | zero | [ u∸t≡0 ] = eq (∸≡0-impl-≤ t∸u≡0 ≤-asym ∸≡0-impl-≤ u∸t≡0)
t ≤-case u | suc n | [ t∸u≡1+n ] | zero | [ u∸t≡0 ] = gt (∸≡0-impl-≤ u∸t≡0 , ∸≢0-impl-≰ t∸u≡1+n)
t ≤-case u | zero | [ t∸u≡0 ] | suc w₁ | [ u∸t≡1+n ] = lt (∸≡0-impl-≤ t∸u≡0 , ∸≢0-impl-≰ u∸t≡1+n)
t ≤-case u | suc m | [ t∸u≡1+m ] | suc n | [ u∸t≡1+n ] with sym u∸t≡1+n trans t∸u≢0-impl-u∸t≡0 t u t∸u≡1+m
t ≤-case u | suc m | [ t∸u≡1+m ] | suc n | [ u∸t≡1+n ] | ()
-- + is monotone
+-resp-≤ : ∀ {t u} → (t ≤ u) → ∀ n → (t + n ≤ u + n)
+-resp-≤ (m , t+m≡u) n =
( m
, +-assoc _ n m trans
cong₂ _+_ refl (+ℕ-comm n m) trans
sym (+-assoc _ m n) trans
cong₂ _+_ t+m≡u refl )
+-refl-≤ : ∀ {t u} n → (t + n ≤ u + n) → (t ≤ u)
+-refl-≤ n (m , t+n+m≡u+n) =
( m
, +-cancelʳ n
(+-assoc _ m n trans
cong₂ _+_ refl (+ℕ-comm m n) trans
sym (+-assoc _ n m) trans
t+n+m≡u+n) )
-- Lemmas about <
<-impl-≤ : ∀ {t u} → (t < u) → (t ≤ u)
<-impl-≤ (t≤u , u≰t) = t≤u
<-impl-≱ : ∀ {t u} → (t < u) → (u ≰ t)
<-impl-≱ (t≤u , u≰t) = u≰t
_<-transˡ_ : ∀ {t u v} → (t < u) → (u ≤ v) → (t < v)
_<-transˡ_ (t≤u , u≰t) u≤v = (t≤u ≤-trans u≤v , λ v≤t → u≰t (u≤v ≤-trans v≤t))
_<-transʳ_ : ∀ {t u v} → (t ≤ u) → (u < v) → (t < v)
_<-transʳ_ t≤u (u≤v , v≰u) = (t≤u ≤-trans u≤v , λ v≤t → v≰u (v≤t ≤-trans t≤u))
≤-proof-irrel′ : ∀ {t u m n} → (m ≡ n) → (t+m≡u : t + m ≡ u) → (t+n≡u : t + n ≡ u) →
(t ≤ u) ∋ (m , t+m≡u) ≡ (n , t+n≡u)
≤-proof-irrel′ refl refl refl = refl
t≤t+1 : ∀ {t} → (t ≤ t + 1)
t≤t+1 = (1 , refl)
t≱t+1 : ∀ {t} → (t ≱ t + 1)
t≱t+1 {t} (m , t+1+m≡t) with +-cancelˡ t (sym (+-assoc t 1 m) trans t+1+m≡t trans sym (+-unit t))
t≱t+1 (m , t+1+m≡t) | ()
t<t+1 : ∀ {t} → (t < t + 1)
t<t+1 = (t≤t+1 , t≱t+1)
<-impl-+1≤ : ∀ {t u} → (t < u) → (t + 1 ≤ u)
<-impl-+1≤ {t} ((zero , t+0≡u) , u≰t) = ⊥-elim (u≰t (≡-impl-≥ (sym (+-unit t) trans t+0≡u)))
<-impl-+1≤ {t} ((suc n , t+1+n≡u) , u≰t) = (n , +-assoc t 1 n trans t+1+n≡u)
+-resp-< : ∀ {t u} → (t < u) → ∀ n → (t + n < u + n)
+-resp-< (t≤u , t≱u) n = (+-resp-≤ t≤u n , λ u+n≤t+n → t≱u (+-refl-≤ n u+n≤t+n))
-- Proof irrelevance for ≤
≤-proof-irrel : ∀ {t u} → (p q : t ≤ u) → (p ≡ q)
≤-proof-irrel {t} (m , t+m≡u) (n , t+n≡u) =
≤-proof-irrel′ (+-cancelˡ t (t+m≡u trans (sym t+n≡u))) t+m≡u t+n≡u
-- Well ordering of < on an interval
_≮[_]_ : Time → ℕ → Time → Set
s ≮[ zero ] u = ⊥
s ≮[ suc n ] u = ∀ {t} → (s ≤ t) → (t < u) → (s ≮[ n ] t)
<-wo′ : ∀ n {s u} → (s ≤ u) → (u ≤ s + n) → (s ≮[ suc n ] u)
<-wo′ zero {s} s≤u u≤s+0 s≤t t<u =
<-impl-≱ t<u (u≤s+0 ≤-trans ≡-impl-≤ (+-unit s) ≤-trans s≤t)
<-wo′ (suc n) s≤u u≤s+1+n {t} s≤t ((zero , t+0≡u) , t≱u) =
⊥-elim (t≱u (≡-impl-≤ ((sym t+0≡u) trans (+-unit t))))
<-wo′ (suc n) {s} {u} s≤u (l , u+l≡s+1+n) {t} s≤t ((suc m , t+1+m≡u) , t≱u) =
<-wo′ n s≤t (l +ℕ m , suc-cancelʳ t+1+l+m≡s+1+n) where
t+1+l+m≡s+1+n : t + suc (l +ℕ m) ≡ s + suc n
t+1+l+m≡s+1+n =
cong₂ _+_ refl (cong suc (+ℕ-comm l m)) trans
sym (+-assoc t (1 +ℕ m) l) trans
cong₂ _+_ t+1+m≡u refl trans
u+l≡s+1+n
<-wo : ∀ {s u} → (s ≤ u) → ∃ λ n → (s ≮[ n ] u)
<-wo (n , s+n≡u) = (suc n , λ {t} → <-wo′ n (n , s+n≡u) (≡-impl-≤ (sym s+n≡u)) {t})
| 33.112108
| 107
| 0.452465
|
501df080b3a93eb2593455383c90633fa5418c90
| 5,010
|
agda
|
Agda
|
Cubical/Displayed/Function.agda
|
maxdore/cubical
|
ef62b84397396d48135d73ba7400b71c721ddc94
|
[
"MIT"
] | null | null | null |
Cubical/Displayed/Function.agda
|
maxdore/cubical
|
ef62b84397396d48135d73ba7400b71c721ddc94
|
[
"MIT"
] | null | null | null |
Cubical/Displayed/Function.agda
|
maxdore/cubical
|
ef62b84397396d48135d73ba7400b71c721ddc94
|
[
"MIT"
] | null | null | null |
{-
Functions building UARels and DUARels on function types
-}
{-# OPTIONS --no-exact-split --safe #-}
module Cubical.Displayed.Function where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Function
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Path
open import Cubical.Functions.FunExtEquiv
open import Cubical.Functions.Implicit
open import Cubical.Displayed.Base
open import Cubical.Displayed.Constant
open import Cubical.Displayed.Morphism
open import Cubical.Displayed.Subst
open import Cubical.Displayed.Sigma
private
variable
ℓA ℓ≅A ℓB ℓ≅B ℓC ℓ≅C : Level
-- UARel on dependent function type
-- from UARel on domain and DUARel on codomain
module _ {A : Type ℓA} (𝒮-A : UARel A ℓ≅A) {B : A → Type ℓB} (𝒮ᴰ-B : DUARel 𝒮-A B ℓ≅B) where
open UARel 𝒮-A
open DUARel 𝒮ᴰ-B
𝒮-Π : UARel ((a : A) → B a) (ℓ-max ℓA ℓ≅B)
UARel._≅_ 𝒮-Π f f' = ∀ a → f a ≅ᴰ⟨ ρ a ⟩ f' a
UARel.ua 𝒮-Π f f' =
compEquiv
(equivΠCod λ a → uaᴰρ (f a) (f' a))
funExtEquiv
-- Parameterize UARel by type
_→𝒮_ : (A : Type ℓA) {B : Type ℓB} (𝒮-B : UARel B ℓ≅B) → UARel (A → B) (ℓ-max ℓA ℓ≅B)
(A →𝒮 𝒮-B) .UARel._≅_ f f' = ∀ a → 𝒮-B .UARel._≅_ (f a) (f' a)
(A →𝒮 𝒮-B) .UARel.ua f f' =
compEquiv
(equivΠCod λ a → 𝒮-B .UARel.ua (f a) (f' a))
funExtEquiv
𝒮-app : {A : Type ℓA} {B : Type ℓB} {𝒮-B : UARel B ℓ≅B}
→ A → UARelHom (A →𝒮 𝒮-B) 𝒮-B
𝒮-app a .UARelHom.fun f = f a
𝒮-app a .UARelHom.rel h = h a
𝒮-app a .UARelHom.ua h = refl
-- DUARel on dependent function type
-- from DUARels on domain and codomain
module _ {A : Type ℓA} {𝒮-A : UARel A ℓ≅A}
{B : A → Type ℓB} (𝒮ᴰ-B : DUARel 𝒮-A B ℓ≅B)
{C : (a : A) → B a → Type ℓC} (𝒮ᴰ-C : DUARel (∫ 𝒮ᴰ-B) (uncurry C) ℓ≅C)
where
open UARel 𝒮-A
private
module B = DUARel 𝒮ᴰ-B
module C = DUARel 𝒮ᴰ-C
𝒮ᴰ-Π : DUARel 𝒮-A (λ a → (b : B a) → C a b) (ℓ-max (ℓ-max ℓB ℓ≅B) ℓ≅C)
DUARel._≅ᴰ⟨_⟩_ 𝒮ᴰ-Π f p f' =
∀ {b b'} (q : b B.≅ᴰ⟨ p ⟩ b') → f b C.≅ᴰ⟨ p , q ⟩ f' b'
DUARel.uaᴰ 𝒮ᴰ-Π f p f' =
compEquiv
(equivImplicitΠCod λ {b} →
(equivImplicitΠCod λ {b'} →
(equivΠ (B.uaᴰ b p b') (λ q → C.uaᴰ (f b) (p , q) (f' b')))))
funExtDepEquiv
_→𝒮ᴰ_ : {A : Type ℓA} {𝒮-A : UARel A ℓ≅A}
{B : A → Type ℓB} (𝒮ᴰ-B : DUARel 𝒮-A B ℓ≅B)
{C : A → Type ℓC} (𝒮ᴰ-C : DUARel 𝒮-A C ℓ≅C)
→ DUARel 𝒮-A (λ a → B a → C a) (ℓ-max (ℓ-max ℓB ℓ≅B) ℓ≅C)
𝒮ᴰ-B →𝒮ᴰ 𝒮ᴰ-C =
𝒮ᴰ-Π 𝒮ᴰ-B (𝒮ᴰ-Lift _ 𝒮ᴰ-C 𝒮ᴰ-B)
-- DUARel on dependent function type
-- from a SubstRel on the domain and DUARel on the codomain
module _ {A : Type ℓA} {𝒮-A : UARel A ℓ≅A}
{B : A → Type ℓB} (𝒮ˢ-B : SubstRel 𝒮-A B)
{C : (a : A) → B a → Type ℓC} (𝒮ᴰ-C : DUARel (∫ˢ 𝒮ˢ-B) (uncurry C) ℓ≅C)
where
open UARel 𝒮-A
open SubstRel 𝒮ˢ-B
open DUARel 𝒮ᴰ-C
𝒮ᴰ-Πˢ : DUARel 𝒮-A (λ a → (b : B a) → C a b) (ℓ-max ℓB ℓ≅C)
DUARel._≅ᴰ⟨_⟩_ 𝒮ᴰ-Πˢ f p f' =
(b : B _) → f b ≅ᴰ⟨ p , refl ⟩ f' (act p .fst b)
DUARel.uaᴰ 𝒮ᴰ-Πˢ f p f' =
compEquiv
(compEquiv
(equivΠCod λ b → Jequiv (λ b' q → f b ≅ᴰ⟨ p , q ⟩ f' b'))
(invEquiv implicit≃Explicit))
(DUARel.uaᴰ (𝒮ᴰ-Π (Subst→DUA 𝒮ˢ-B) 𝒮ᴰ-C) f p f')
-- SubstRel on a dependent function type
-- from a SubstRel on the domain and SubstRel on the codomain
equivΠ' : ∀ {ℓA ℓA' ℓB ℓB'} {A : Type ℓA} {A' : Type ℓA'}
{B : A → Type ℓB} {B' : A' → Type ℓB'}
(eA : A ≃ A')
(eB : {a : A} {a' : A'} → eA .fst a ≡ a' → B a ≃ B' a')
→ ((a : A) → B a) ≃ ((a' : A') → B' a')
equivΠ' {B' = B'} eA eB = isoToEquiv isom
where
open Iso
isom : Iso _ _
isom .fun f a' =
eB (retEq eA a') .fst (f (invEq eA a'))
isom .inv f' a =
invEq (eB refl) (f' (eA .fst a))
isom .rightInv f' =
funExt λ a' →
J (λ a'' p → eB p .fst (invEq (eB refl) (f' (p i0))) ≡ f' a'')
(retEq (eB refl) (f' (eA .fst (invEq eA a'))))
(retEq eA a')
isom .leftInv f =
funExt λ a →
subst
(λ p → invEq (eB refl) (eB p .fst (f (invEq eA (eA .fst a)))) ≡ f a)
(sym (commPathIsEq (eA .snd) a))
(J (λ a'' p → invEq (eB refl) (eB (cong (eA .fst) p) .fst (f (invEq eA (eA .fst a)))) ≡ f a'')
(secEq (eB refl) (f (invEq eA (eA .fst a))))
(secEq eA a))
module _ {A : Type ℓA} {𝒮-A : UARel A ℓ≅A}
{B : A → Type ℓB} (𝒮ˢ-B : SubstRel 𝒮-A B)
{C : Σ A B → Type ℓC} (𝒮ˢ-C : SubstRel (∫ˢ 𝒮ˢ-B) C)
where
open UARel 𝒮-A
open SubstRel
private
module B = SubstRel 𝒮ˢ-B
module C = SubstRel 𝒮ˢ-C
𝒮ˢ-Π : SubstRel 𝒮-A (λ a → (b : B a) → C (a , b))
𝒮ˢ-Π .act p = equivΠ' (B.act p) (λ q → C.act (p , q))
𝒮ˢ-Π .uaˢ p f =
fromPathP
(DUARel.uaᴰ (𝒮ᴰ-Π (Subst→DUA 𝒮ˢ-B) (Subst→DUA 𝒮ˢ-C)) f p (equivFun (𝒮ˢ-Π .act p) f) .fst
(λ {b} →
J (λ b' q →
equivFun (C.act (p , q)) (f b)
≡ equivFun (equivΠ' (𝒮ˢ-B .act p) (λ q → C.act (p , q))) f b')
(λ i →
C.act (p , λ j → commSqIsEq (𝒮ˢ-B .act p .snd) b (~ i) j) .fst
(f (secEq (𝒮ˢ-B .act p) b (~ i))))))
| 30.54878
| 100
| 0.547305
|
1dd1c054a64bc2094ce3cb55a002c843a24916ba
| 374
|
agda
|
Agda
|
test/Succeed/Issue2429-subtyping.agda
|
vlopezj/agda
|
ff4d89e75970cf27599fb9f572bd43c9455cbb56
|
[
"BSD-3-Clause"
] | 3
|
2015-03-28T14:51:03.000Z
|
2015-12-07T20:14:00.000Z
|
test/Succeed/Issue2429-subtyping.agda
|
vikfret/agda
|
49ad0b3f0d39c01bc35123478b857e702b29fb9d
|
[
"BSD-3-Clause"
] | 3
|
2018-11-14T15:31:44.000Z
|
2019-04-01T19:39:26.000Z
|
test/Succeed/Issue2429-subtyping.agda
|
vikfret/agda
|
49ad0b3f0d39c01bc35123478b857e702b29fb9d
|
[
"BSD-3-Clause"
] | 1
|
2019-03-05T20:02:38.000Z
|
2019-03-05T20:02:38.000Z
|
-- Andreas, 2017-01-24, issue #2429
-- Respect subtyping also for irrelevant lambdas!
-- Subtyping: (.A → B) ≤ (A → B)
-- Where a function is expected, we can put one which does not use its argument.
id : ∀{A B : Set} → (.A → B) → A → B
id f = f
test : ∀{A B : Set} → (.A → B) → A → B
test f = λ .a → f a
-- Should work!
-- The eta-expansion should not change anything!
| 24.933333
| 80
| 0.596257
|
59dc43967ecd8dcf237b5d3c5cdf44730003683e
| 421
|
agda
|
Agda
|
Math/NumberTheory/Summation/Generic/Properties/Lemma.agda
|
rei1024/agda-misc
|
37200ea91d34a6603d395d8ac81294068303f577
|
[
"MIT"
] | 3
|
2020-04-07T17:49:42.000Z
|
2020-04-21T00:03:43.000Z
|
Math/NumberTheory/Summation/Generic/Properties/Lemma.agda
|
rei1024/agda-misc
|
37200ea91d34a6603d395d8ac81294068303f577
|
[
"MIT"
] | null | null | null |
Math/NumberTheory/Summation/Generic/Properties/Lemma.agda
|
rei1024/agda-misc
|
37200ea91d34a6603d395d8ac81294068303f577
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
module Math.NumberTheory.Summation.Generic.Properties.Lemma where
-- agda-stdlib
open import Data.Nat
open import Data.Nat.Properties
open import Data.Nat.Solver
open import Relation.Binary.PropositionalEquality
open import Function.Base
lemma₁ : ∀ m n → 2 + m + n ≡ suc m + suc n
lemma₁ = solve 2 (λ m n → con 2 :+ m :+ n := con 1 :+ m :+ (con 1 :+ n)) refl
where open +-*-Solver
| 28.066667
| 77
| 0.688836
|
296979e7ce9e87a80be902e7d074f66e971da4d3
| 8,118
|
agda
|
Agda
|
Cubical/HITs/Cylinder/Base.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | null | null | null |
Cubical/HITs/Cylinder/Base.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | 1
|
2022-01-27T02:07:48.000Z
|
2022-01-27T02:07:48.000Z
|
Cubical/HITs/Cylinder/Base.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | 1
|
2021-11-22T02:02:01.000Z
|
2021-11-22T02:02:01.000Z
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.HITs.Cylinder.Base where
open import Cubical.Core.Everything
open import Cubical.Foundations.Everything
open import Cubical.Data.Sigma
open import Cubical.Data.Unit
open import Cubical.Data.Sum using (_⊎_; inl; inr)
open import Cubical.HITs.PropositionalTruncation using (∥_∥; ∣_∣; squash)
open import Cubical.HITs.Interval using (Interval; zero; one; seg)
-- Cylinder A is a cylinder object in the category of cubical types.
--
-- https://ncatlab.org/nlab/show/cylinder+object
data Cylinder {ℓ} (A : Type ℓ) : Type ℓ where
inl : A → Cylinder A
inr : A → Cylinder A
cross : ∀ x → inl x ≡ inr x
-- Dual to this is the cocylinder or path space object.
--
-- https://ncatlab.org/nlab/show/path+space+object
Cocylinder : ∀ {ℓ} → Type ℓ → Type ℓ
Cocylinder A = Interval → A
module _ {ℓ} {A : Type ℓ} where
-- The cylinder is part of a factorization of the obvious mapping
-- of type A ⊎ A → A into a pair of mappings:
--
-- A ⊎ A → Cylinder A ≃ A
--
-- include is the first part of the factorization.
include : A ⊎ A → Cylinder A
include (inl x) = inl x
include (inr x) = inr x
-- The above inclusion is surjective
includeSurjective : ∀ c → ∃[ s ∈ A ⊎ A ] include s ≡ c
includeSurjective (inl x) = ∣ inl x , refl ∣
includeSurjective (inr x) = ∣ inr x , refl ∣
includeSurjective (cross x i) =
squash
∣ inl x , (λ j → cross x (i ∧ j)) ∣
∣ inr x , (λ j → cross x (i ∨ ~ j)) ∣
i
elim
: ∀{ℓ'} {B : Cylinder A → Type ℓ'}
→ (f : (x : A) → B (inl x))
→ (g : (x : A) → B (inr x))
→ (p : ∀ x → PathP (λ i → B (cross x i)) (f x) (g x))
→ (c : Cylinder A) → B c
elim f _ _ (inl x) = f x
elim _ g _ (inr x) = g x
elim _ _ p (cross x i) = p x i
private
out : Cylinder A → A
out (inl x) = x
out (inr x) = x
out (cross x i) = x
inl-out : (c : Cylinder A) → inl (out c) ≡ c
inl-out (inl x) = refl
inl-out (inr x) = cross x
inl-out (cross x i) = λ j → cross x (i ∧ j)
out-inl : ∀(x : A) → out (inl x) ≡ x
out-inl x = refl
-- The second part of the factorization above.
CylinderA≃A : Cylinder A ≃ A
CylinderA≃A = isoToEquiv (iso out inl out-inl inl-out)
-- The cocylinder has a similar equivalence that is part
-- of factorizing the diagonal mapping.
private
inco : A → Cocylinder A
inco x _ = x
outco : Cocylinder A → A
outco f = f zero
A→CocylinderA→A : (x : A) → outco (inco x) ≡ x
A→CocylinderA→A x = refl
CocylinderA→A→CocylinderA : (c : Cocylinder A) → inco (outco c) ≡ c
CocylinderA→A→CocylinderA c j zero = c zero
CocylinderA→A→CocylinderA c j one = c (seg j)
CocylinderA→A→CocylinderA c j (seg i) = c (seg (j ∧ i))
A≃CocylinderA : A ≃ Cocylinder A
A≃CocylinderA =
isoToEquiv (iso inco outco CocylinderA→A→CocylinderA A→CocylinderA→A)
project : Cocylinder A → A × A
project c = c zero , c one
-- Since we can construct cylinders for every type, Cylinder actually
-- constitutes a cylinder functor:
--
-- https://ncatlab.org/nlab/show/cylinder+functor
--
-- e₀ = inl
-- e₁ = inr
-- σ = out
module Functorial where
private
variable
ℓa ℓb ℓc : Level
A : Type ℓa
B : Type ℓb
C : Type ℓc
map : (A → B) → Cylinder A → Cylinder B
map f (inl x) = inl (f x)
map f (inr x) = inr (f x)
map f (cross x i) = cross (f x) i
mapId : map (λ(x : A) → x) ≡ (λ x → x)
mapId i (inl x) = inl x
mapId i (inr x) = inr x
mapId i (cross x j) = cross x j
map∘
: (f : A → B) → (g : B → C)
→ map (λ x → g (f x)) ≡ (λ x → map g (map f x))
map∘ f g i (inl x) = inl (g (f x))
map∘ f g i (inr x) = inr (g (f x))
map∘ f g i (cross x j) = cross (g (f x)) j
-- There is an adjunction between the cylinder and coyclinder
-- functors.
--
-- Cylinder ⊣ Cocylinder
adj₁ : (Cylinder A → B) → A → Cocylinder B
adj₁ f x zero = f (inl x)
adj₁ f x one = f (inr x)
adj₁ f x (seg i) = f (cross x i)
adj₂ : (A → Cocylinder B) → Cylinder A → B
adj₂ g (inl x) = g x zero
adj₂ g (inr x) = g x one
adj₂ g (cross x i) = g x (seg i)
adj₁₂ : (g : A → Cocylinder B) → adj₁ (adj₂ g) ≡ g
adj₁₂ g _ x zero = g x zero
adj₁₂ g _ x one = g x one
adj₁₂ g _ x (seg i) = g x (seg i)
adj₂₁ : (f : Cylinder A → B) → adj₂ (adj₁ f) ≡ f
adj₂₁ f j (inl x) = f (inl x)
adj₂₁ f j (inr x) = f (inr x)
adj₂₁ f j (cross x i) = f (cross x i)
module IntervalEquiv where
-- There is an equivalence between the interval and the
-- cylinder over the unit type.
Interval→CylinderUnit : Interval → Cylinder Unit
Interval→CylinderUnit zero = inl _
Interval→CylinderUnit one = inr _
Interval→CylinderUnit (seg i) = cross _ i
CylinderUnit→Interval : Cylinder Unit → Interval
CylinderUnit→Interval (inl _) = zero
CylinderUnit→Interval (inr _) = one
CylinderUnit→Interval (cross _ i) = seg i
Interval→CylinderUnit→Interval
: ∀ i → CylinderUnit→Interval (Interval→CylinderUnit i) ≡ i
Interval→CylinderUnit→Interval zero = refl
Interval→CylinderUnit→Interval one = refl
Interval→CylinderUnit→Interval (seg i) = refl
CylinderUnit→Interval→CylinderUnit
: ∀ c → Interval→CylinderUnit (CylinderUnit→Interval c) ≡ c
CylinderUnit→Interval→CylinderUnit (inl _) = refl
CylinderUnit→Interval→CylinderUnit (inr _) = refl
CylinderUnit→Interval→CylinderUnit (cross _ i) = refl
CylinderUnit≃Interval : Cylinder Unit ≃ Interval
CylinderUnit≃Interval =
isoToEquiv (iso CylinderUnit→Interval Interval→CylinderUnit Interval→CylinderUnit→Interval CylinderUnit→Interval→CylinderUnit)
-- More generally, there is an equivalence between the cylinder
-- over any type A and the product of A and the interval.
module _ {ℓ} {A : Type ℓ} where
private
Cyl : Type ℓ
Cyl = A × Interval
CylinderA→A×Interval : Cylinder A → Cyl
CylinderA→A×Interval (inl x) = x , zero
CylinderA→A×Interval (inr x) = x , one
CylinderA→A×Interval (cross x i) = x , seg i
A×Interval→CylinderA : Cyl → Cylinder A
A×Interval→CylinderA (x , zero) = inl x
A×Interval→CylinderA (x , one) = inr x
A×Interval→CylinderA (x , seg i) = cross x i
A×Interval→CylinderA→A×Interval
: ∀ c → CylinderA→A×Interval (A×Interval→CylinderA c) ≡ c
A×Interval→CylinderA→A×Interval (x , zero) = refl
A×Interval→CylinderA→A×Interval (x , one) = refl
A×Interval→CylinderA→A×Interval (x , seg i) = refl
CylinderA→A×Interval→CylinderA
: ∀ c → A×Interval→CylinderA (CylinderA→A×Interval c) ≡ c
CylinderA→A×Interval→CylinderA (inl x) = refl
CylinderA→A×Interval→CylinderA (inr x) = refl
CylinderA→A×Interval→CylinderA (cross x i) = refl
CylinderA≃A×Interval : Cylinder A ≃ Cyl
CylinderA≃A×Interval =
isoToEquiv
(iso CylinderA→A×Interval
A×Interval→CylinderA
A×Interval→CylinderA→A×Interval
CylinderA→A×Interval→CylinderA)
-- The cylinder is also the pushout of the identity on A with itself.
module Push {ℓ} {A : Type ℓ} where
open import Cubical.HITs.Pushout
private
Push : Type ℓ
Push = Pushout (λ(x : A) → x) (λ x → x)
Cyl : Type ℓ
Cyl = Cylinder A
Cylinder→Pushout : Cyl → Push
Cylinder→Pushout (inl x) = inl x
Cylinder→Pushout (inr x) = inr x
Cylinder→Pushout (cross x i) = push x i
Pushout→Cylinder : Push → Cyl
Pushout→Cylinder (inl x) = inl x
Pushout→Cylinder (inr x) = inr x
Pushout→Cylinder (push x i) = cross x i
Pushout→Cylinder→Pushout : ∀ p → Cylinder→Pushout (Pushout→Cylinder p) ≡ p
Pushout→Cylinder→Pushout (inl x) = refl
Pushout→Cylinder→Pushout (inr x) = refl
Pushout→Cylinder→Pushout (push x i) = refl
Cylinder→Pushout→Cylinder : ∀ c → Pushout→Cylinder (Cylinder→Pushout c) ≡ c
Cylinder→Pushout→Cylinder (inl x) = refl
Cylinder→Pushout→Cylinder (inr x) = refl
Cylinder→Pushout→Cylinder (cross x i) = refl
Pushout≃Cylinder : Push ≃ Cyl
Pushout≃Cylinder =
isoToEquiv
(iso Pushout→Cylinder
Cylinder→Pushout
Cylinder→Pushout→Cylinder
Pushout→Cylinder→Pushout)
| 30.518797
| 130
| 0.631683
|
2fff73fe5f79b867e2128c46d647d3673a55f7e1
| 10,039
|
agda
|
Agda
|
TypeTheory/HoTT/Partiality2.agda
|
hbasold/Sandbox
|
8fc7a6cd878f37f9595124ee8dea62258da28aa4
|
[
"MIT"
] | null | null | null |
TypeTheory/HoTT/Partiality2.agda
|
hbasold/Sandbox
|
8fc7a6cd878f37f9595124ee8dea62258da28aa4
|
[
"MIT"
] | null | null | null |
TypeTheory/HoTT/Partiality2.agda
|
hbasold/Sandbox
|
8fc7a6cd878f37f9595124ee8dea62258da28aa4
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --copatterns --sized-types #-}
open import lib.Basics
open import lib.PathGroupoid
open import lib.types.Paths
open import lib.Funext
open import Size
{-
-- | Coinductive delay type. This is the functor νπ̂ : Set → Set arising
-- as the fixed point of π̂(H) = π ∘ ⟨Id, H⟩, where π : Set × Set → Set
-- with π(X, Y) = X.
record D (S : Set) : Set where
coinductive
field
force : S
open D
-- | Action of D on morphisms
D₁ : ∀ {X Y} → (X → Y) → D X → D Y
force (D₁ f x) = f (force x)
-- | D lifted to dependent functions
↑D₁ : ∀ {A} → (B : A → Set) → ((x : A) → B x) → (y : D A) → D (B (force y))
force (↑D₁ B f y) = f (force y)
D-intro : ∀ {H : Set → Set} → (∀ {X} → H X → X) → (∀ {X} → H X → D X)
force (D-intro f x) = f x
D-intro2 : ∀ {X S : Set} → (X → S) → X → D S
force (D-intro2 f x) = f x
postulate
-- | We'll need coinduction to prove such equalities in the future, or prove
-- it from univalence.
D-coind : ∀ {S} {x y : D S} → force x == force y → x == y
D-coind2 : ∀ {S} {x y : D S} → D (force x == force y) → x == y
D-coind2 p = D-coind (force p
-}
module _ where
private
mutual
data #D (A : Set) (P : Set) : Set where
#p : #D-aux A P → (Unit → Unit) → #D A P
data #D-aux (A : Set) (P : Set) : Set where
#now : A → #D-aux A P
#later : P → #D-aux A P
D : Set → Set → Set
D A X = #D A X
now : ∀ {A X} → A → D A X
now a = #p (#now a) _
later : ∀ {A X} → X → D A X
later x = #p (#later x) _
D₁ : ∀ {A P₁ P₂} → (P₁ → P₂) → (D A P₁ → D A P₂)
D₁ f (#p (#now a) _) = now a
D₁ f (#p (#later x) _) = later (f x)
record P {i : Size} (A : Set) : Set where
coinductive
field
#force : ∀ {j : Size< i} → D A (P {j} A)
open P
force : ∀ {A} → P A → D A (P A)
force x = #force x
P-intro : ∀ {A X : Set} → (X → D A X) → (X → P A)
P-intro {A} {X} f = P-intro'
where
P-intro' : ∀ {i} → X → P {i} A
#force (P-intro' x) {j} = D₁ (P-intro' {j}) (f x)
postulate -- HIT
weak~ : ∀{A X : Set} → (force* : X → D A X) →
(x : X) → (later x == force* x)
-- | Extra module for recursion using sized types.
-- This is convenient, as we can use the functor D in the definition, which
-- in turn simplifies proofs.
module DRec {A B : Set} {P' Y : Set}
(now* : A → D B Y)
(later* : P A → D B Y)
(force* : Y → D B Y)
(weak~* : (x : P A) → (later* x == force x))
where
f : D A P' → D B Y
f = f-aux phantom where
f-aux : Phantom weak~* → D A P' → D B Y
f-aux phantom (#p (#now a) _) = now* a
f-aux phantom (#p (#later x) _) = later* x
postulate -- HIT
weak~-β : (x : P') → ap f (weak~ force* x) == weak~* x
{-
module PElim {A X} {S : D A X → Set}
(now* : (a : A) → S (now a))
(later* : (x : X) → S (later x))
(force*₁ : (x : X) → D A X)
(force*₂ : (x : X) → S (force*₁ x))
(weak~* : (x : X) → -- (x_rec : S
(later* x == (force*₂ x) [ S ↓ (weak~ force*₁ x) ]))
where
f : (x : D A X) → S x
f = f-aux phantom
where
f-aux : Phantom weak~* → (x : D A X) → S x
f-aux phantom (#p (#now a) _) = now* a
f-aux phantom (#p (#later x) _) = later* x
-}
-- postulate -- HIT
-- weak~-β : (x : X) → apd f (weak~ force*₁ x) == weak~* x
{-
weak~-β₂ : (x : ∞P A) →
apd f (weak~ x) == weak~* x (↑D₁ S f x)
-- transport (weak~* x) g-is-D₁f (↑D₁ S f x)
weak~-β₂ = ?
-}
open DRec public renaming (f to D-rec)
{-
open PElim public
renaming (f to P-elim; g to ∞P-elim; f-homomorphism to P-elim-hom;
weak~-β to elim-weak~-β)
-}
module Bla where
⊥ : ∀ {A} → P A
⊥ = P-intro later unit
-- | Copairing of morphisms
[_,_] : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k}
(l : A → C) (r : B → C) → (x : Coprod A B) → C
[ f , g ] x = match x withl f withr g
id-D : ∀ {A} → D A (P A) → D A (P A)
id-D {A} = D-rec now later force (weak~ force)
--(idf A) (idf (P A)) (λ x → force x) (weak~ (λ x → force x))
D₁-force : ∀ {A P₁ P₂} → (force* : P₁ → D A P₁) → (f : P₁ → P₂) → (x : P₁)
→ later (f x) == D₁ f (force* x)
D₁-force force* f x =
later (f x)
=⟨ idp ⟩
D₁ f (later x)
=⟨ weak~ force* x |in-ctx (D₁ f) ⟩
D₁ f (force* x)
∎
-- | Direct definition of bind
bind : ∀ {A B} → (A → P B) → (P A → P B)
bind {A} {B} f x = P-intro {X = P A ⊔ P B} [ u , v ] (inl x)
where
elim-A : A → D B (P A ⊔ P B)
elim-A a =
D-rec now
(later ∘ inr)
(D₁ inr ∘ force)
(D₁-force force inr)
(force (f a))
u : P A → D B (P A ⊔ P B)
u x = D-rec
elim-A
(later ∘ inl)
(later ∘ inl) -- this should be force ...
(λ _ → idp)
(force x)
v : P B → D B (P A ⊔ P B)
v = D₁ inr ∘ force
{-
-- | Copairing of morphisms
[_,_] : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k}
(l : A → C) (r : B → C) → (x : Coprod A B) → C
[ f , g ] x = match x withl f withr g
-- | Inverse of [now, later] à la Lambek,
-- given by extending id + D ([now, later]) : A ⊔ D(A ⊔ ∞P A) → A ⊔ ∞P A.
out : ∀ {A} → P A → A ⊔ ∞P A
out {A} = P-rec inl force (λ _ → idp)
-- (inr ∘ D₁ [ now , later ]) resp-weak~
where
resp-weak~ : (x : D (A ⊔ ∞P A)) →
(inr ∘ D₁ [ now , later ]) x == force x
resp-weak~ x =
(inr ∘ D₁ [ now , later ]) x
=⟨ {!!} ⟩
inr (D₁ [ now , later ] x)
=⟨ {!!} ⟩
force x
∎
⊥' : ∀ {A} → ∞P A
⊥ : ∀ {A} → P A
⊥ = later (D-intro (λ _ → {!!}) unit)
force ⊥' = {!!} -- ⊥
-- | Action of P on morphisms
P₁ : ∀ {A B} → (A → B) → (P A → P B)
P₁ f = P-rec (now ∘ f) later weak~
-- | Unit for the monad
η : ∀ {A} → A → P A
η = now
-- | Monad multiplication
μ : ∀ {A} → P (P A) → P A
μ {A} = P-rec (idf (P A)) later weak~
-- | Direct definition of bind
bind : ∀ {A B} → (A → P B) → (P A → P B)
bind {A} {B} f = P-rec f later weak~
η-natural : ∀ {A B} → (f : A → B) →
η ∘ f == P₁ f ∘ η
η-natural f = λ=-nondep (λ x → idp)
where
n open FunextNonDep
μ-natural : ∀ {A B} → (f : A → B) →
μ ∘ P₁ (P₁ f) == P₁ f ∘ μ
μ-natural {A} f = λ=-nondep q
where
open FunextNonDep
T : P (P A) → Set
T x = μ ( P₁ (P₁ f) x) == P₁ f (μ x)
=-later : (x : ∞P (P A)) → D (T (force x)) → T (later x)
=-later x p = transport T (! (weak~ x)) (force p)
r : (x : ∞P (P A)) → (p : D (T (force x))) →
(=-later x p) == (force p) [ T ↓ (weak~ x) ]
r x p = trans-↓ T (weak~ x) (force p)
q : (x : P (P A)) → μ ( P₁ (P₁ f) x) == P₁ f (μ x)
q = P-elim {S = λ x → μ ( P₁ (P₁ f) x) == P₁ f (μ x)}
(λ a → idp) =-later r
-- | Termination predicate on P A
data _↓_ {A} (x : P A) : A → Set where
now↓ : (a : A) → now a == x → x ↓ a
later↓ : (a : A) → (u : ∞P A) → (later u == x) → (force u) ↓ a → x ↓ a
mutual
-- | Weak bisimilarity proofs
data ~proof {A} (x y : P A) : Set where
terminating : (a : A) → x ↓ a → y ↓ a → ~proof x y
-- A bit awkward, but otherwise we cannot pattern matching on ~proof
step : (u v : ∞P A) → (later u == x) → (later v == y) → force u ~ force v →
~proof x y
-- | Weak bisimilarity for P A
record _~_ {A} (x y : P A) : Set where
coinductive
field
out~ : ~proof x y
open _~_
terminate→=now : ∀{A} → (a : A) → (x : P A) → x ↓ a → now a == x
terminate→=now a x (now↓ .a na=x) = na=x
terminate→=now a x (later↓ .a u lu=x fu↓a) =
now a
=⟨ terminate→=now a (force u) fu↓a ⟩
force u
=⟨ ! (weak~ u) ⟩
later u
=⟨ lu=x ⟩
x
∎
lemma : ∀{A} → (a : A) → (x y : P A) → x ↓ a → y ↓ a → x == y
lemma a x y x↓a y↓a =
x
=⟨ ! (terminate→=now a x x↓a) ⟩
now a
=⟨ terminate→=now a y y↓a ⟩
y
∎
inr-inj : ∀ {i} {A B : Set i} →
(x y : B) → Path {i} {A ⊔ B} (inr x) (inr y) → x == y
inr-inj x .x idp = idp
later-inj : ∀ {A} → (u v : ∞P A) → later u == later v → u == v
later-inj u v p = inr-inj u v lem
where
lem : inr u == inr v
lem = transport (λ z → inr u == P-out z) {later u} {later v} p idp
-- | Weak bisimilarity implies equality for P A
~→= : ∀{A} → (x y : P A) → x ~ y → x == y
~→= {A} x y = P-elim {S = λ x' → x' ~ y → x' == y} now-= later-= weak~-= x
where
now-= : (a : A) → now a ~ y → now a == y
now-= a p = lem (out~ p)
where
lem : ~proof (now a) y → now a == y
lem (terminating b (now↓ .b nb=na) y↓b) =
now a
=⟨ ! nb=na ⟩
now b
=⟨ terminate→=now b y y↓b ⟩
y
∎
lem (terminating b (later↓ .b u () now_a↓b) y↓b)
lem (step u v () x₂ x₃)
later-= : (u : ∞P A) →
D (force u ~ y → force u == y) → later u ~ y → later u == y
later-= u p later_u~y = lem (out~ later_u~y)
where
lem : ~proof (later u) y → later u == y
lem (terminating a later_u↓a y↓a) = lemma a (later u) y later_u↓a y↓a
lem (step u' v later_u'=later_u later_v=y force_u'~force_v) =
later u
=⟨ weak~ u ⟩
force u
=⟨ force p force_u~y ⟩
y ∎
where
force_u'=force_u : force u' == force u
force_u'=force_u =
force u'
=⟨ later-inj u' u later_u'=later_u |in-ctx force ⟩
force u
∎
y=force_v : y == force v
y=force_v =
y
=⟨ ! later_v=y ⟩
later v
=⟨ weak~ v ⟩
force v
∎
force_u~y : force u ~ y
force_u~y = transport
(λ z → z ~ y)
force_u'=force_u
(transport! (λ z → force u' ~ z) y=force_v force_u'~force_v)
weak~-= : (u : ∞P A) (p : D (force u ~ y → force u == y)) →
(later-= u p)
== (force p) [ (λ x' → x' ~ y → x' == y) ↓ (weak~ u) ]
weak~-= u p = {!!}
-}
| 27.57967
| 79
| 0.441578
|
318b6174a49ec4de279fb1b5e9e72f65e595df33
| 2,832
|
agda
|
Agda
|
Cubical/Data/Fin/Arithmetic.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 1
|
2022-02-05T01:25:26.000Z
|
2022-02-05T01:25:26.000Z
|
Cubical/Data/Fin/Arithmetic.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | null | null | null |
Cubical/Data/Fin/Arithmetic.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --safe #-}
module Cubical.Data.Fin.Arithmetic where
open import Cubical.Foundations.Prelude
open import Cubical.Data.Nat
open import Cubical.Data.Nat.Mod
open import Cubical.Data.Nat.Order
open import Cubical.Data.Fin
open import Cubical.Data.Sigma
infixl 6 _+ₘ_ _-ₘ_ _·ₘ_
infix 7 -ₘ_
-- Addition, subtraction and multiplication
_+ₘ_ : {n : ℕ} → Fin (suc n) → Fin (suc n) → Fin (suc n)
fst (_+ₘ_ {n = n} x y) = ((fst x) + (fst y)) mod (suc n)
snd (_+ₘ_ {n = n} x y) = mod< _ ((fst x) + (fst y))
-ₘ_ : {n : ℕ} → (x : Fin (suc n)) → Fin (suc n)
fst (-ₘ_ {n = n} x) =
(+induction n _ (λ x _ → ((suc n) ∸ x) mod (suc n)) λ _ x → x) (fst x)
snd (-ₘ_ {n = n} x) = lem (fst x)
where
≡<-trans : {x y z : ℕ} → x < y → x ≡ z → z < y
≡<-trans (k , p) q = k , cong (λ x → k + suc x) (sym q) ∙ p
lem : {n : ℕ} (x : ℕ)
→ (+induction n _ _ _) x < suc n
lem {n = n} =
+induction n _
(λ x p → ≡<-trans (mod< n (suc n ∸ x))
(sym (+inductionBase n _ _ _ x p)))
λ x p → ≡<-trans p
(sym (+inductionStep n _ _ _ x))
_-ₘ_ : {n : ℕ} → (x y : Fin (suc n)) → Fin (suc n)
_-ₘ_ x y = x +ₘ (-ₘ y)
_·ₘ_ : {n : ℕ} → (x y : Fin (suc n)) → Fin (suc n)
fst (_·ₘ_ {n = n} x y) = (fst x · fst y) mod (suc n)
snd (_·ₘ_ {n = n} x y) = mod< n (fst x · fst y)
-- Group laws
+ₘ-assoc : {n : ℕ} (x y z : Fin (suc n))
→ (x +ₘ y) +ₘ z ≡ (x +ₘ (y +ₘ z))
+ₘ-assoc {n = n} x y z =
Σ≡Prop (λ _ → m≤n-isProp)
((mod-rCancel (suc n) ((fst x + fst y) mod (suc n)) (fst z))
∙∙ sym (mod+mod≡mod (suc n) (fst x + fst y) (fst z))
∙∙ cong (_mod suc n) (sym (+-assoc (fst x) (fst y) (fst z)))
∙∙ mod+mod≡mod (suc n) (fst x) (fst y + fst z)
∙∙ sym (mod-lCancel (suc n) (fst x) ((fst y + fst z) mod suc n)))
+ₘ-comm : {n : ℕ} (x y : Fin (suc n)) → (x +ₘ y) ≡ (y +ₘ x)
+ₘ-comm {n = n} x y =
Σ≡Prop (λ _ → m≤n-isProp)
(cong (_mod suc n) (+-comm (fst x) (fst y)))
+ₘ-lUnit : {n : ℕ} (x : Fin (suc n)) → 0 +ₘ x ≡ x
+ₘ-lUnit {n = n} (x , p) =
Σ≡Prop (λ _ → m≤n-isProp)
(+inductionBase n _ _ _ x p)
+ₘ-rUnit : {n : ℕ} (x : Fin (suc n)) → x +ₘ 0 ≡ x
+ₘ-rUnit x = +ₘ-comm x 0 ∙ (+ₘ-lUnit x)
+ₘ-rCancel : {n : ℕ} (x : Fin (suc n)) → x -ₘ x ≡ 0
+ₘ-rCancel {n = n} x =
Σ≡Prop (λ _ → m≤n-isProp)
(cong (λ z → (fst x + z) mod (suc n))
(+inductionBase n _ _ _ (fst x) (snd x))
∙∙ sym (mod-rCancel (suc n) (fst x) ((suc n) ∸ (fst x)))
∙∙ cong (_mod (suc n)) (+-comm (fst x) ((suc n) ∸ (fst x)))
∙∙ cong (_mod (suc n)) (≤-∸-+-cancel (<-weaken (snd x)))
∙∙ zero-charac (suc n))
+ₘ-lCancel : {n : ℕ} (x : Fin (suc n)) → (-ₘ x) +ₘ x ≡ 0
+ₘ-lCancel {n = n} x = +ₘ-comm (-ₘ x) x ∙ +ₘ-rCancel x
-- TODO : Ring laws
private
test₁ : Path (Fin 11) (5 +ₘ 10) 4
test₁ = refl
test₂ : Path (Fin 11) (-ₘ 7 +ₘ 5 +ₘ 10) 8
test₂ = refl
| 32.181818
| 72
| 0.491172
|
18601ac944ba24cd8cd923ef865baa7050a8cf84
| 6,618
|
agda
|
Agda
|
InterpreterWithConstants.agda
|
sseefried/well-typed-agda-interpreter
|
2a85cc82934be9433648bca0b49b77db18de524c
|
[
"MIT"
] | 3
|
2021-06-18T12:06:14.000Z
|
2021-06-18T12:37:46.000Z
|
InterpreterWithConstants.agda
|
sseefried/well-typed-agda-interpreter
|
2a85cc82934be9433648bca0b49b77db18de524c
|
[
"MIT"
] | null | null | null |
InterpreterWithConstants.agda
|
sseefried/well-typed-agda-interpreter
|
2a85cc82934be9433648bca0b49b77db18de524c
|
[
"MIT"
] | 2
|
2021-06-18T06:14:18.000Z
|
2021-06-18T12:31:11.000Z
|
{-# OPTIONS --without-K --safe --overlapping-instances #-}
-- Reference to check out
--
-- Simply Typed Lambda Calculus in Agda, without Shortcuts
-- https://gergo.erdi.hu/blog/2013-05-01-simply_typed_lambda_calculus_in_agda,_without_shortcuts/
module InterpreterWithConstants 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 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'
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
⟦_⟧ : `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 , Δ
instance
∈_type₁ : ∀ {x Δ t} → x ∈ x ::: t , Δ
∈_type₁ = H
∈_type₂ : ∀ {x y Δ t} → ⦃ prf : x ∈ Δ ⦄ → ⦃ x ≠ y ⦄ → x ∈ y ::: t , Δ
∈_type₂ = TH
data _∉_ : Var → Γ → Set where
H : ∀ {x} → x ∉ ·
TH : ∀ {x y Δ t} → ⦃ prf : x ∉ Δ ⦄ → ⦃ neprf : x ≠ y ⦄ → x ∉ y ::: t , Δ
instance
∉_type₁ : ∀ {x} → x ∉ ·
∉_type₁ = H
∉_type₂ : ∀ {x y Δ t} → ⦃ prf : x ∉ Δ ⦄ → ⦃ x ≠ y ⦄ → x ∉ y ::: t , Δ
∉_type₂ = TH
!Γ_[_] : ∀ {x} → (Δ : Γ) → x ∈ Δ → `Set
!Γ_[_] · ()
!Γ _ ::: t , Δ [ H ] = t
!Γ _ ::: _ , Δ [ TH ⦃ prf = i ⦄ ] = !Γ Δ [ i ]
infix 30 `v_
infix 30 `c_
infix 24 _`,_
infixl 22 _`₋_
data Constant : `Set → Set where
`not : Constant (`Bool `⇨ `Bool)
`∧ : Constant (`Bool `× `Bool `⇨ `Bool)
`∨ : Constant (`Bool `× `Bool `⇨ `Bool)
`xor : Constant (`Bool `× `Bool `⇨ `Bool)
data _⊢_ : Γ → `Set → Set where
`false : ∀ {Δ} → Δ ⊢ `Bool
`true : ∀ {Δ} → Δ ⊢ `Bool
`v_ : ∀ {Δ} → (x : Var) → ⦃ i : x ∈ Δ ⦄ → Δ ⊢ !Γ Δ [ i ]
`c_ : ∀ {Δ t} → Constant t → Δ ⊢ t
_`₋_ : ∀ {Δ t s} → Δ ⊢ t `⇨ s → Δ ⊢ t → Δ ⊢ s --application
`λ_`:_⇨_ : ∀ {Δ tr} → (x : Var) → (tx : `Set)
→ x ::: tx , Δ ⊢ tr → Δ ⊢ tx `⇨ tr
_`,_ : ∀ {Δ 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 ]
interpretConstant : ∀ {t} → Constant t → ⟦ t ⟧
interpretConstant `not = not
interpretConstant `∧ = uncurry _∧_
interpretConstant `∨ = uncurry _∨_
interpretConstant `xor = uncurry _xor_
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 (`c f) = interpretConstant f
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
-----
and₁ : · ⊢ `Bool `× `Bool `⇨ `Bool
and₁ = `λ x' `: `Bool `× `Bool ⇨ `c `∧ `₋ `v x'
and₂ : · ⊢ `Bool `× `Bool `⇨ `Bool
and₂ = `c `∧
{-
I want to write a function called eta-reduce that one could prove the following:
pf : eta-reduce and₁ ≡ and₂
pf = refl
This function will eta-reduce when it can, and do nothing when it can't.
For instance the following should be true:
eta-reduce-constant : ∀ {c} → eta-reduce (`c c) ≡ `c c
However, I get stuck even on this case. Uncomment the definition below and try to
type check this module:
-}
-- eta-reduce : ∀ {t₁ t₂} → · ⊢ t₁ `⇨ t₂ → · ⊢ t₁ `⇨ t₂
-- eta-reduce (`c c) = ?
{-
You will get the following error message:
I'm not sure if there should be a case for the constructor `v_,
because I get stuck when trying to solve the following unification
problems (inferred index ≟ expected index):
Δ ≟ ·
!Γ Δ [ i ] ≟ t₁ `⇨ t₂
when checking the definition of eta-reduce
I did a bit of searching on the Internet and the only source I could find
that I could understand was this one: https://doisinkidney.com/posts/2018-09-20-agda-tips.html
It seems to be suggesting that one of the indices for a type is not in constructor form but is,
rather, a function.
Looking at the definition of _⊢_ we see that the `v_` constructor is most likely at fault:
`v_ : ∀ {Δ} → (x : Var) → ⦃ i : x ∈ Δ ⦄ → Δ ⊢ !Γ Δ [ i ]
The result type is `Δ ⊢ !Γ Δ [ i ]`. Clearly the index `!Γ Δ [ i ]` is referring to a
user-defined function.
My question is, "how can I fix this?". How would I modify the _⊢_ data structure
- I would be open to an alternative interpreter for the Simply Typed Lambda Calculus
- This interpreter is a modified form of this code base. ttps://github.com/ahmadsalim/well-typed-agda-interpreter
It has had instance declarations added and the syntactic form of terms has changed a little. I pulled out
the constant functions into their own data structure called `Constant` and changed their types a little to work
on products (_×_) instead of a curried form.
-}
{-
The instance based searching for _∈_ proofs might be a problem. I'm uncomfortable
with the use of --overlapping-instances
-}
-- eta-reduce : ∀ {t₁ t₂} → · ⊢ t₁ `⇨ t₂ → · ⊢ t₁ `⇨ t₂
-- eta-reduce (`λ x `: _ ⇨ f `₋ y) = {!!}
-- eta-reduce t = t
| 26.261905
| 113
| 0.526594
|
31c6a4af94679326887fcff9e5658eee607981bc
| 754
|
agda
|
Agda
|
agda/hott/core/universe.agda
|
piyush-kurur/hott
|
876ecdcfddca1abf499e8f00db321c6dc3d5b2bc
|
[
"BSD-3-Clause"
] | null | null | null |
agda/hott/core/universe.agda
|
piyush-kurur/hott
|
876ecdcfddca1abf499e8f00db321c6dc3d5b2bc
|
[
"BSD-3-Clause"
] | null | null | null |
agda/hott/core/universe.agda
|
piyush-kurur/hott
|
876ecdcfddca1abf499e8f00db321c6dc3d5b2bc
|
[
"BSD-3-Clause"
] | null | null | null |
{-# OPTIONS --without-K #-}
-- The universe of all types
module hott.core.universe where
open import Agda.Primitive public using (Level; lzero; lsuc; _⊔_)
-- We give an new name for Set
Type : (ℓ : Level) → Set (lsuc ℓ)
Type ℓ = Set ℓ
lone : Level; lone = lsuc lzero
ltwo : Level; ltwo = lsuc lone
lthree : Level; lthree = lsuc ltwo
lfour : Level; lfour = lsuc lthree
lfive : Level; lfive = lsuc lfour
lsix : Level; lsix = lsuc lfive
lseven : Level; lseven = lsuc lsix
leight : Level; leight = lsuc lseven
lnine : Level; lnine = lsuc leight
Type₀ = Type lzero
Type₁ = Type lone
Type₂ = Type ltwo
Type₃ = Type lthree
Type₄ = Type lfour
Type₅ = Type lfive
Type₆ = Type lsix
Type₇ = Type lseven
Type₈ = Type leight
Type₉ = Type lnine
| 23.5625
| 65
| 0.685676
|
a12bd13d60a5db10678b774d4f2d2349e216f95f
| 854
|
agda
|
Agda
|
function/extensionality/core.agda
|
HoTT/M-types
|
beebe176981953ab48f37de5eb74557cfc5402f4
|
[
"BSD-3-Clause"
] | 27
|
2015-04-14T15:47:03.000Z
|
2022-01-09T07:26:57.000Z
|
src/function/extensionality/core.agda
|
pcapriotti/agda-base
|
bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c
|
[
"BSD-3-Clause"
] | 4
|
2015-02-02T14:32:16.000Z
|
2016-10-26T11:57:26.000Z
|
function/extensionality/core.agda
|
HoTT/M-types
|
beebe176981953ab48f37de5eb74557cfc5402f4
|
[
"BSD-3-Clause"
] | 4
|
2015-04-11T17:19:12.000Z
|
2019-02-26T06:17:38.000Z
|
{-# OPTIONS --without-K #-}
module function.extensionality.core where
open import level using (lsuc; _⊔_)
open import equality.core
Extensionality : ∀ i j → Set (lsuc (i ⊔ j))
Extensionality i j = {X : Set i}{Y : Set j}
→ {f g : X → Y}
→ ((x : X) → f x ≡ g x)
→ f ≡ g
Extensionality' : ∀ i j → Set (lsuc (i ⊔ j))
Extensionality' i j = {X : Set i}{Y : X → Set j}
→ {f g : (x : X) → Y x}
→ ((x : X) → f x ≡ g x)
→ f ≡ g
StrongExt : ∀ i j → Set (lsuc (i ⊔ j))
StrongExt i j = {X : Set i}{Y : X → Set j}
→ {f g : (x : X) → Y x}
→ (∀ x → f x ≡ g x) ≡ (f ≡ g)
funext-inv : ∀ {i j}{X : Set i}{Y : X → Set j}
→ {f g : (x : X) → Y x}
→ f ≡ g
→ (x : X) → f x ≡ g x
funext-inv refl x = refl
| 29.448276
| 48
| 0.395785
|
292920876b47a7cb25264c5352c144eb479d19ee
| 4,975
|
agda
|
Agda
|
src/LibraBFT/Abstract/Properties.agda
|
LaudateCorpus1/bft-consensus-agda
|
a4674fc473f2457fd3fe5123af48253cfb2404ef
|
[
"UPL-1.0"
] | null | null | null |
src/LibraBFT/Abstract/Properties.agda
|
LaudateCorpus1/bft-consensus-agda
|
a4674fc473f2457fd3fe5123af48253cfb2404ef
|
[
"UPL-1.0"
] | null | null | null |
src/LibraBFT/Abstract/Properties.agda
|
LaudateCorpus1/bft-consensus-agda
|
a4674fc473f2457fd3fe5123af48253cfb2404ef
|
[
"UPL-1.0"
] | null | null | null |
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2020, 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
open import LibraBFT.Abstract.Types
open import LibraBFT.Abstract.Types.EpochConfig
open import Util.Lemmas
open import Util.Prelude
open WithAbsVote
-- For each desired property (VotesOnce and PreferredRoundRule), we have a
-- module containing a Type that defines a property that an implementation
-- should prove, and a proof that it implies the corresponding rule used by
-- the abstract proofs. Then, we use those proofs to instantiate thmS5,
-- and the use thmS5 to prove a number of correctness conditions.
--
-- TODO-1: refactor this file to separate the definitions and proofs of
-- VotesOnce and PreferredRoundRule from their use in proving the correctness
-- properties.
module LibraBFT.Abstract.Properties
(UID : Set)
(_≟UID_ : (u₀ u₁ : UID) → Dec (u₀ ≡ u₁))
(NodeId : Set)
(𝓔 : EpochConfig UID NodeId)
(𝓥 : VoteEvidence UID NodeId 𝓔)
where
open import LibraBFT.Abstract.Records UID _≟UID_ NodeId 𝓔 𝓥
open import LibraBFT.Abstract.Records.Extends UID _≟UID_ NodeId 𝓔 𝓥
open import LibraBFT.Abstract.RecordChain UID _≟UID_ NodeId 𝓔 𝓥
open import LibraBFT.Abstract.RecordChain.Assumptions UID _≟UID_ NodeId 𝓔 𝓥
open import LibraBFT.Abstract.System UID _≟UID_ NodeId 𝓔 𝓥
open import LibraBFT.Abstract.RecordChain.Properties UID _≟UID_ NodeId 𝓔 𝓥
open EpochConfig 𝓔
module WithAssumptions {ℓ}
(InSys : Record → Set ℓ)
(no-collisions-InSys : NoCollisions InSys)
(votes-once : VotesOnlyOnceRule InSys)
(preferred-round : PreferredRoundRule InSys)
where
open All-InSys-props InSys
CommitsDoNotConflict : ∀{q q'}
→ {rc : RecordChain (Q q)} → All-InSys rc
→ {rc' : RecordChain (Q q')} → All-InSys rc'
→ {b b' : Block}
→ CommitRule rc b
→ CommitRule rc' b'
→ (B b) ∈RC rc' ⊎ (B b') ∈RC rc
CommitsDoNotConflict ais ais' cr cr'
with WithInvariants.thmS5 InSys votes-once preferred-round ais ais' cr cr'
-- We use the implementation-provided evidence that Block ids are injective among
-- Block actually in the system to dismiss the first possibility
...| inj₁ ((_ , neq , h≡) , (is1 , is2)) = ⊥-elim (neq (no-collisions-InSys is1 is2 h≡))
...| inj₂ corr = corr
-- When we are dealing with a /Complete/ InSys predicate, we can go a few steps
-- further and prove that commits do not conflict even if we have only partial
-- knowledge about Records represented in the system.
module _ (∈QC⇒AllSent : Complete InSys) where
-- For a /complete/ system (i.e., one in which peers vote for a Block only if
-- they know of a RecordChain up to that Block whose Records are all InSys), we
-- can prove that CommitRules based on RecordChainFroms similarly do not
-- conflict, provided all of the Records in the RecordChainFroms are InSys.
-- This enables peers not participating in consensus to confirm commits even if
-- they are sent only a "commit certificate" that contains enough of a
-- RecordChain to confirm the CommitRule. Note that it is this "sending" that
-- justfies the assumption that the RecordChainFroms on which the CommitRules
-- are based are All-InSys.
CommitsDoNotConflict'
: ∀{o o' q q'}
→ {rcf : RecordChainFrom o (Q q)} → All-InSys rcf
→ {rcf' : RecordChainFrom o' (Q q')} → All-InSys rcf'
→ {b b' : Block}
→ CommitRuleFrom rcf b
→ CommitRuleFrom rcf' b'
→ Σ (RecordChain (Q q')) ((B b) ∈RC_)
⊎ Σ (RecordChain (Q q)) ((B b') ∈RC_)
CommitsDoNotConflict' {cb} {q = q} {q'} {rcf} rcfAll∈sys {rcf'} rcf'All∈sys crf crf'
with bft-property (qVotes-C1 q) (qVotes-C1 q')
...| α , α∈qmem , α∈q'mem , hα
with Any-sym (Any-map⁻ α∈qmem) | Any-sym (Any-map⁻ α∈q'mem)
...| α∈q | α∈q'
with ∈QC⇒AllSent {q = q} hα α∈q (rcfAll∈sys here) | ∈QC⇒AllSent {q = q'} hα α∈q' (rcf'All∈sys here)
...| ab , (arc , ais) , ab←q | ab' , (arc' , ais') , ab←q'
with crf⇒cr rcf (step arc ab←q) crf | crf⇒cr rcf' (step arc' ab←q') crf'
...| inj₁ ((_ , neq , h≡) , (is1 , is2)) | _ = ⊥-elim (neq (no-collisions-InSys (rcfAll∈sys is1) (ais (∈RC-simple-¬here arc ab←q (λ ()) is2)) h≡))
...| inj₂ _ | inj₁ ((_ , neq , h≡) , (is1 , is2)) = ⊥-elim (neq (no-collisions-InSys (rcf'All∈sys is1) (ais' (∈RC-simple-¬here arc' ab←q' (λ ()) is2)) h≡))
...| inj₂ cr | inj₂ cr'
with CommitsDoNotConflict (All-InSys-step ais ab←q (rcfAll∈sys here)) (All-InSys-step ais' ab←q' (rcf'All∈sys here)) cr cr'
...| inj₁ b∈arc' = inj₁ (step arc' ab←q' , b∈arc')
...| inj₂ b'∈arc = inj₂ (step arc ab←q , b'∈arc)
| 50.252525
| 174
| 0.642814
|
12b29a64e5c67de4c95bff25c64055721691110f
| 6,568
|
agda
|
Agda
|
TotalParserCombinators/Semantics.agda
|
yurrriq/parser-combinators
|
b396d35cc2cb7e8aea50b982429ee385f001aa88
|
[
"MIT"
] | 7
|
2016-12-13T05:23:14.000Z
|
2021-06-22T05:35:31.000Z
|
TotalParserCombinators/Semantics.agda
|
yurrriq/parser-combinators
|
b396d35cc2cb7e8aea50b982429ee385f001aa88
|
[
"MIT"
] | 1
|
2018-01-22T22:21:41.000Z
|
2018-01-24T16:39:37.000Z
|
TotalParserCombinators/Semantics.agda
|
yurrriq/parser-combinators
|
b396d35cc2cb7e8aea50b982429ee385f001aa88
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- Semantics of the parsers
------------------------------------------------------------------------
module TotalParserCombinators.Semantics where
open import Coinduction
open import Data.List hiding (drop)
open import Data.List.Any.Membership.Propositional
using (bag) renaming (_∼[_]_ to _List-∼[_]_)
open import Data.Maybe using (Maybe); open Data.Maybe.Maybe
open import Data.Product
open import Data.Unit using (⊤; tt)
open import Function
open import Function.Equality using (_⟨$⟩_)
open import Function.Equivalence as Eq using (_⇔_; module Equivalence)
open import Function.Inverse using (_↔_; module Inverse)
open import Function.Related as Related using (Related)
open import Level
import Relation.Binary.HeterogeneousEquality as H
open import Relation.Binary.PropositionalEquality as P using (_≡_)
open import Relation.Nullary
open import TotalParserCombinators.Parser
------------------------------------------------------------------------
-- Semantics
-- The semantics of the parsers. x ∈ p · s means that x can be the
-- result of applying the parser p to the string s. Note that the
-- semantics is defined inductively.
infix 60 <$>_
infixl 50 _⊛_ [_-_]_⊛_
infixl 10 _>>=_ [_-_]_>>=_
infix 4 _∈_·_
data _∈_·_ {Tok} :
∀ {R xs} → R → Parser Tok R xs → List Tok → Set₁ where
return : ∀ {R} {x : R} → x ∈ return x · []
token : ∀ {x} → x ∈ token · [ x ]
∣-left : ∀ {R x xs₁ xs₂ s}
{p₁ : Parser Tok R xs₁} {p₂ : Parser Tok R xs₂}
(x∈p₁ : x ∈ p₁ · s) → x ∈ p₁ ∣ p₂ · s
∣-right : ∀ {R x xs₂ s} xs₁
{p₁ : Parser Tok R xs₁} {p₂ : Parser Tok R xs₂}
(x∈p₂ : x ∈ p₂ · s) → x ∈ p₁ ∣ p₂ · s
<$>_ : ∀ {R₁ R₂ x s xs} {p : Parser Tok R₁ xs} {f : R₁ → R₂}
(x∈p : x ∈ p · s) → f x ∈ f <$> p · s
_⊛_ : ∀ {R₁ R₂ f x s₁ s₂ fs xs}
{p₁ : ∞⟨ xs ⟩Parser Tok (R₁ → R₂) (flatten fs)}
{p₂ : ∞⟨ fs ⟩Parser Tok R₁ (flatten xs)} →
(f∈p₁ : f ∈ ♭? p₁ · s₁)
(x∈p₂ : x ∈ ♭? p₂ · s₂) →
f x ∈ p₁ ⊛ p₂ · s₁ ++ s₂
_>>=_ : ∀ {R₁ R₂ x y s₁ s₂ xs} {f : Maybe (R₁ → List R₂)}
{p₁ : ∞⟨ f ⟩Parser Tok R₁ (flatten xs)}
{p₂ : (x : R₁) → ∞⟨ xs ⟩Parser Tok R₂ (apply f x)}
(x∈p₁ : x ∈ ♭? p₁ · s₁)
(y∈p₂x : y ∈ ♭? (p₂ x) · s₂) →
y ∈ p₁ >>= p₂ · s₁ ++ s₂
nonempty : ∀ {R xs x y s} {p : Parser Tok R xs}
(x∈p : y ∈ p · x ∷ s) → y ∈ nonempty p · x ∷ s
cast : ∀ {R xs₁ xs₂ x s}
{xs₁≈xs₂ : xs₁ List-∼[ bag ] xs₂} {p : Parser Tok R xs₁}
(x∈p : x ∈ p · s) → x ∈ cast xs₁≈xs₂ p · s
-- Some variants with fewer implicit arguments. (The arguments xs and
-- fs can usually not be inferred, but I do not want to mention them
-- in the paper, so I have made them implicit in the definition
-- above.)
[_-_]_⊛_ : ∀ {Tok R₁ R₂ f x s₁ s₂} xs fs
{p₁ : ∞⟨ xs ⟩Parser Tok (R₁ → R₂) (flatten fs)}
{p₂ : ∞⟨ fs ⟩Parser Tok R₁ (flatten xs)} →
f ∈ ♭? p₁ · s₁ → x ∈ ♭? p₂ · s₂ → f x ∈ p₁ ⊛ p₂ · s₁ ++ s₂
[ xs - fs ] f∈p₁ ⊛ x∈p₂ = _⊛_ {fs = fs} {xs = xs} f∈p₁ x∈p₂
[_-_]_>>=_ : ∀ {Tok R₁ R₂ x y s₁ s₂} (f : Maybe (R₁ → List R₂)) xs
{p₁ : ∞⟨ f ⟩Parser Tok R₁ (flatten xs)}
{p₂ : (x : R₁) → ∞⟨ xs ⟩Parser Tok R₂ (apply f x)} →
x ∈ ♭? p₁ · s₁ → y ∈ ♭? (p₂ x) · s₂ →
y ∈ p₁ >>= p₂ · s₁ ++ s₂
[ f - xs ] x∈p₁ >>= y∈p₂x = _>>=_ {xs = xs} {f = f} x∈p₁ y∈p₂x
------------------------------------------------------------------------
-- Parser and language equivalence
infix 4 _∼[_]_ _≈_ _≅_ _≲_
-- There are two kinds of equivalences. Parser equivalences are
-- stronger, and correspond to bag equality. Language equivalences are
-- weaker, and correspond to set equality.
open Data.List.Any.Membership.Propositional public
using (Kind)
renaming ( bag to parser
; set to language
; subbag to subparser
; subset to sublanguage
; superbag to superparser
; superset to superlanguage
)
-- General definition of equivalence between parsers. (Note that this
-- definition also gives access to some ordering relations.)
_∼[_]_ : ∀ {Tok R xs₁ xs₂} →
Parser Tok R xs₁ → Kind → Parser Tok R xs₂ → Set₁
p₁ ∼[ k ] p₂ = ∀ {x s} → Related k (x ∈ p₁ · s) (x ∈ p₂ · s)
-- Language equivalence. (Corresponds to set equality.)
_≈_ : ∀ {Tok R xs₁ xs₂} → Parser Tok R xs₁ → Parser Tok R xs₂ → Set₁
p₁ ≈ p₂ = p₁ ∼[ language ] p₂
-- Parser equivalence. (Corresponds to bag equality.)
_≅_ : ∀ {Tok R xs₁ xs₂} → Parser Tok R xs₁ → Parser Tok R xs₂ → Set₁
p₁ ≅ p₂ = p₁ ∼[ parser ] p₂
-- p₁ ≲ p₂ means that the language defined by p₂ contains all the
-- string/result pairs contained in the language defined by p₁.
_≲_ : ∀ {Tok R xs₁ xs₂} → Parser Tok R xs₁ → Parser Tok R xs₂ → Set₁
p₁ ≲ p₂ = p₁ ∼[ sublanguage ] p₂
-- p₁ ≈ p₂ iff both p₁ ≲ p₂ and p₂ ≲ p₁.
≈⇔≲≳ : ∀ {Tok R xs₁ xs₂}
{p₁ : Parser Tok R xs₁} {p₂ : Parser Tok R xs₂} →
p₁ ≈ p₂ ⇔ (p₁ ≲ p₂ × p₂ ≲ p₁)
≈⇔≲≳ = Eq.equivalence
(λ p₁≈p₂ →
((λ {x s} → _⟨$⟩_ (Equivalence.to (p₁≈p₂ {x = x} {s = s})))
, λ {x s} → _⟨$⟩_ (Equivalence.from (p₁≈p₂ {x = x} {s = s}))))
(λ p₁≲≳p₂ → λ {x s} → Eq.equivalence (proj₁ p₁≲≳p₂ {s = s})
(proj₂ p₁≲≳p₂ {s = s}))
-- Parser equivalence implies language equivalence.
≅⇒≈ : ∀ {Tok R xs₁ xs₂}
{p₁ : Parser Tok R xs₁} {p₂ : Parser Tok R xs₂} →
p₁ ≅ p₂ → p₁ ≈ p₂
≅⇒≈ p₁≅p₂ = Related.↔⇒ p₁≅p₂
-- Language equivalence does not (in general) imply parser
-- equivalence.
¬≈⇒≅ : ¬ (∀ {Tok R xs₁ xs₂}
{p₁ : Parser Tok R xs₁} {p₂ : Parser Tok R xs₂} →
p₁ ≈ p₂ → p₁ ≅ p₂)
¬≈⇒≅ hyp with Inverse.injective p₁≅p₂
{∣-left return} {∣-right [ tt ] return} (lemma _ _)
where
p₁ : Parser ⊤ ⊤ _
p₁ = return tt ∣ return tt
p₂ : Parser ⊤ ⊤ _
p₂ = return tt
p₁≲p₂ : p₁ ≲ p₂
p₁≲p₂ (∣-left return) = return
p₁≲p₂ (∣-right ._ return) = return
p₁≅p₂ : p₁ ≅ p₂
p₁≅p₂ = hyp $ Eq.equivalence p₁≲p₂ ∣-left
lemma : ∀ {x s} (x∈₁ x∈₂ : x ∈ p₂ · s) → x∈₁ ≡ x∈₂
lemma return return = P.refl
... | ()
------------------------------------------------------------------------
-- A simple cast lemma
cast∈ : ∀ {Tok R xs} {p p′ : Parser Tok R xs} {x x′ s s′} →
x ≡ x′ → p ≡ p′ → s ≡ s′ → x ∈ p · s → x′ ∈ p′ · s′
cast∈ P.refl P.refl P.refl x∈ = x∈
| 36.488889
| 72
| 0.510201
|
06a91371398e142c40f5fa8782abfe5b045906fc
| 1,359
|
agda
|
Agda
|
test/fail/Issue399.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | 1
|
2019-11-27T07:26:06.000Z
|
2019-11-27T07:26:06.000Z
|
test/fail/Issue399.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
test/fail/Issue399.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
-- 2011-04-12 AIM XIII fixed this issue by freezing metas after declaration (Andreas & Ulf)
module Issue399 where
open import Common.Prelude
data Maybe (A : Set) : Set where
nothing : Maybe A
just : A → Maybe A
_++_ : {A : Set} → List A → List A → List A
[] ++ ys = ys
(x ∷ xs) ++ ys = x ∷ (xs ++ ys)
record MyMonadPlus m : Set₁ where
field mzero : {a : Set} → m a → List a
mplus : {a : Set} → m a → m a → List a
-- this produces an unsolved meta variable, because it is not clear which
-- level m has. m could be in Set -> Set or in Set -> Set1
-- if you uncomment the rest of the files, you get unsolved metas here
{- Old error, without freezing:
--Emacs error: and the 10th line is the above line
--/home/j/dev/apps/haskell/agda/learn/bug-in-record.agda:10,36-39
--Set != Set₁
--when checking that the expression m a has type Set₁
-}
mymaybemzero : {a : Set} → Maybe a → List a
mymaybemzero nothing = []
mymaybemzero (just x) = x ∷ []
mymaybemplus : {a : Set} → Maybe a → Maybe a → List a
mymaybemplus x y = (mymaybemzero x) ++ (mymaybemzero y)
-- the following def gives a type error because of unsolved metas in MyMonadPlus
-- if you uncomment it, you see m in MyMonadPlus yellow
mymaybeMonadPlus : MyMonadPlus Maybe
mymaybeMonadPlus = record { mzero = mymaybemzero
; mplus = mymaybemplus }
| 32.357143
| 91
| 0.660044
|
1cb0bbbb20fa027665048e9436f70e0c00f77c4a
| 1,435
|
agda
|
Agda
|
test/Fail/Issue2101.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 3
|
2015-03-28T14:51:03.000Z
|
2015-12-07T20:14:00.000Z
|
test/Fail/Issue2101.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 3
|
2018-11-14T15:31:44.000Z
|
2019-04-01T19:39:26.000Z
|
test/Fail/Issue2101.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1
|
2015-09-15T14:36:15.000Z
|
2015-09-15T14:36:15.000Z
|
-- Andreas, 2016-07-17 issue 2101
-- It should be possible to place a single function with a where block
-- inside `abstract`.
-- This will work if type signatures inside a where-block
-- are considered private, since in private type signatures,
-- abstract definitions are transparent.
-- (Unlike in public type signatures.)
record Wrap (A : Set) : Set where
field unwrap : A
postulate
P : ∀{A : Set} → A → Set
module AbstractPrivate (A : Set) where
abstract
B : Set
B = Wrap A
postulate
b : B
private -- this makes abstract defs transparent in type signatures
postulate
test : P (Wrap.unwrap b) -- should succeed
abstract
unnamedWhere : (A : Set) → Set
unnamedWhere A = A
where -- the following definitions are private!
B : Set
B = Wrap A
postulate
b : B
test : P (Wrap.unwrap b) -- should succeed
namedWherePrivate : (A : Set) → Set
namedWherePrivate A = A
module MP where
B : Set
B = Wrap A
private
postulate
b : B
test : P (Wrap.unwrap b) -- should succeed
namedWhere : (A : Set) → Set
namedWhere A = A
module M where -- the definitions in this module are not private!
B : Set
B = Wrap A
postulate
b : B
test : P (Wrap.unwrap b) -- should fail!
access = M.b -- should be in scope
outside : ∀ {A} → M.B A → A
outside = Wrap.unwrap -- should fail and does so
--
| 20.797101
| 70
| 0.620906
|
294f6a6f1a826f6c98df878eec1e18df8dfdcc5b
| 402
|
agda
|
Agda
|
Categories/Object/Indexed.agda
|
copumpkin/categories
|
36f4181d751e2ecb54db219911d8c69afe8ba892
|
[
"BSD-3-Clause"
] | 98
|
2015-04-15T14:57:33.000Z
|
2022-03-08T05:20:36.000Z
|
Categories/Object/Indexed.agda
|
p-pavel/categories
|
e41aef56324a9f1f8cf3cd30b2db2f73e01066f2
|
[
"BSD-3-Clause"
] | 19
|
2015-05-23T06:47:10.000Z
|
2019-08-09T16:31:40.000Z
|
Categories/Object/Indexed.agda
|
p-pavel/categories
|
e41aef56324a9f1f8cf3cd30b2db2f73e01066f2
|
[
"BSD-3-Clause"
] | 23
|
2015-02-05T13:03:09.000Z
|
2021-11-11T13:50:56.000Z
|
{-# 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
| 26.8
| 88
| 0.736318
|
fbb4ad2c41be89a23b8031ea354ae56d5876ee56
| 3,807
|
agda
|
Agda
|
src/Web/Semantic/DL/TBox/Interp/Morphism.agda
|
agda/agda-web-semantic
|
8ddbe83965a616bff6fc7a237191fa261fa78bab
|
[
"MIT"
] | 9
|
2015-09-13T17:46:41.000Z
|
2020-03-14T14:21:08.000Z
|
src/Web/Semantic/DL/TBox/Interp/Morphism.agda
|
agda/agda-web-semantic
|
8ddbe83965a616bff6fc7a237191fa261fa78bab
|
[
"MIT"
] | 4
|
2018-11-14T02:32:28.000Z
|
2021-01-04T20:57:19.000Z
|
src/Web/Semantic/DL/TBox/Interp/Morphism.agda
|
agda/agda-web-semantic
|
8ddbe83965a616bff6fc7a237191fa261fa78bab
|
[
"MIT"
] | 3
|
2017-12-03T14:52:09.000Z
|
2022-03-12T11:40:03.000Z
|
open import Data.Product using ( ∃ ; _×_ ; _,_ ; proj₁ ; proj₂ )
open import Relation.Unary using ( _∈_ )
open import Web.Semantic.DL.TBox.Interp using
( Interp ; Δ ; _⊨_≈_ ; con ; rol ; ≈-refl ; ≈-sym ; ≈-trans ; con-≈ ; rol-≈ )
open import Web.Semantic.DL.Signature using ( Signature )
open import Web.Semantic.Util using ( id ; _∘_ )
module Web.Semantic.DL.TBox.Interp.Morphism {Σ : Signature} where
infix 2 _≲_ _≃_
-- I ≲ J whenever J respects all the properties of I
data _≲_ (I J : Interp Σ) : Set where
morph :
(f : Δ I → Δ J) →
(≲-resp-≈ : ∀ {x y} → (I ⊨ x ≈ y) → (J ⊨ f x ≈ f y)) →
(≲-resp-con : ∀ {c x} → (x ∈ con I c) → (f x ∈ con J c)) →
(≲-resp-rol : ∀ {r x y} → ((x , y) ∈ rol I r) → ((f x , f y) ∈ rol J r)) →
(I ≲ J)
≲-image : ∀ {I J} → (I ≲ J) → Δ I → Δ J
≲-image (morph f ≲-resp-≈ ≲-resp-con ≲-resp-rol) = f
≲-image² : ∀ {I J} → (I ≲ J) → (Δ I × Δ I) → (Δ J × Δ J)
≲-image² I≲J (x , y) = (≲-image I≲J x , ≲-image I≲J y)
≲-resp-≈ : ∀ {I J} → (I≲J : I ≲ J) → ∀ {x y} → (I ⊨ x ≈ y) →
(J ⊨ ≲-image I≲J x ≈ ≲-image I≲J y)
≲-resp-≈ (morph f ≲-resp-≈ ≲-resp-con ≲-resp-rol) = ≲-resp-≈
≲-resp-con : ∀ {I J} → (I≲J : I ≲ J) → ∀ {c x} → (x ∈ con I c) →
(≲-image I≲J x ∈ con J c)
≲-resp-con (morph f ≲-resp-≈ ≲-resp-con ≲-resp-rol) = ≲-resp-con
≲-resp-rol : ∀ {I J} → (I≲J : I ≲ J) → ∀ {r xy} → (xy ∈ rol I r) →
(≲-image² I≲J xy ∈ rol J r)
≲-resp-rol (morph f ≲-resp-≈ ≲-resp-con ≲-resp-rol) {r} {x , y} = ≲-resp-rol
≲-refl : ∀ I → (I ≲ I)
≲-refl I = morph id id id id
≲-trans : ∀ {I J K} → (I ≲ J) → (J ≲ K) → (I ≲ K)
≲-trans I≲J J≲K = morph
(≲-image J≲K ∘ ≲-image I≲J)
(≲-resp-≈ J≲K ∘ ≲-resp-≈ I≲J)
(≲-resp-con J≲K ∘ ≲-resp-con I≲J)
(≲-resp-rol J≲K ∘ ≲-resp-rol I≲J)
-- I ≃ J whenever there is an isomprhism between I and J
data _≃_ (I J : Interp Σ) : Set where
iso :
(≃-impl-≲ : I ≲ J) →
(≃-impl-≳ : J ≲ I) →
(≃-iso : ∀ x → I ⊨ (≲-image ≃-impl-≳ (≲-image ≃-impl-≲ x)) ≈ x) →
(≃-iso⁻¹ : ∀ x → J ⊨ (≲-image ≃-impl-≲ (≲-image ≃-impl-≳ x)) ≈ x) →
(I ≃ J)
≃-impl-≲ : ∀ {I J} → (I ≃ J) → (I ≲ J)
≃-impl-≲ (iso ≃-impl-≲ ≃-impl-≳ ≃-iso ≃-iso⁻¹) = ≃-impl-≲
≃-impl-≳ : ∀ {I J} → (I ≃ J) → (J ≲ I)
≃-impl-≳ (iso ≃-impl-≲ ≃-impl-≳ ≃-iso ≃-iso⁻¹) = ≃-impl-≳
≃-image : ∀ {I J} → (I ≃ J) → Δ I → Δ J
≃-image I≃J = ≲-image (≃-impl-≲ I≃J)
≃-image² : ∀ {I J} → (I ≃ J) → (Δ I × Δ I) → (Δ J × Δ J)
≃-image² I≃J = ≲-image² (≃-impl-≲ I≃J)
≃-image⁻¹ : ∀ {I J} → (I ≃ J) → Δ J → Δ I
≃-image⁻¹ I≃J = ≲-image (≃-impl-≳ I≃J)
≃-image²⁻¹ : ∀ {I J} → (I ≃ J) → (Δ J × Δ J) → (Δ I × Δ I)
≃-image²⁻¹ I≃J = ≲-image² (≃-impl-≳ I≃J)
≃-iso : ∀ {I J} → (I≃J : I ≃ J) → ∀ x → (I ⊨ (≃-image⁻¹ I≃J (≃-image I≃J x)) ≈ x)
≃-iso (iso ≃-impl-≲ ≃-impl-≳ ≃-iso ≃-iso⁻¹) = ≃-iso
≃-iso⁻¹ : ∀ {I J} → (I≃J : I ≃ J) → ∀ x → (J ⊨ (≃-image I≃J (≃-image⁻¹ I≃J x)) ≈ x)
≃-iso⁻¹ (iso ≃-impl-≲ ≃-impl-≳ ≃-iso ≃-iso⁻¹) = ≃-iso⁻¹
≃-resp-≈ : ∀ {I J} → (I≃J : I ≃ J) → ∀ {x y} →
(I ⊨ x ≈ y) → (J ⊨ ≃-image I≃J x ≈ ≃-image I≃J y)
≃-resp-≈ I≃J = ≲-resp-≈ (≃-impl-≲ I≃J)
≃-refl-≈ : ∀ {I J} → (I≃J : I ≃ J) → ∀ {x y} →
(I ⊨ ≃-image⁻¹ I≃J x ≈ ≃-image⁻¹ I≃J y) → (J ⊨ x ≈ y)
≃-refl-≈ {I} {J} I≃J {x} {y} x≈y =
≈-trans J (≈-sym J (≃-iso⁻¹ I≃J x))
(≈-trans J (≃-resp-≈ I≃J x≈y) (≃-iso⁻¹ I≃J y))
≃-refl : ∀ I → (I ≃ I)
≃-refl I = iso (≲-refl I) (≲-refl I) (λ x → ≈-refl I) (λ x → ≈-refl I)
≃-sym : ∀ {I J} → (I ≃ J) → (J ≃ I)
≃-sym I≃J = iso (≃-impl-≳ I≃J) (≃-impl-≲ I≃J) (≃-iso⁻¹ I≃J) (≃-iso I≃J)
≃-trans : ∀ {I J K} → (I ≃ J) → (J ≃ K) → (I ≃ K)
≃-trans {I} {J} {K} I≃J J≃K = iso
(≲-trans (≃-impl-≲ I≃J) (≃-impl-≲ J≃K))
(≲-trans (≃-impl-≳ J≃K) (≃-impl-≳ I≃J))
(λ x → ≈-trans I (≲-resp-≈ (≃-impl-≳ I≃J) (≃-iso J≃K (≃-image I≃J x)))
(≃-iso I≃J x))
(λ x → ≈-trans K (≲-resp-≈ (≃-impl-≲ J≃K) (≃-iso⁻¹ I≃J (≃-image⁻¹ J≃K x)))
(≃-iso⁻¹ J≃K x))
| 35.25
| 83
| 0.430785
|
31d016568af6bb255bf3b84be4f7b96609a49fca
| 387
|
agda
|
Agda
|
test/Succeed/Issue479.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue479.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue479.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2012-03-15, example by Ulf
-- {-# OPTIONS -v tc.meta:20 #-}
module Issue479 where
import Common.Level
open import Common.Equality
data ⊥ : Set where
data Bool : Set where true false : Bool
X : Bool
X=true : X ≡ true
X≠false : X ≡ false → ⊥
X = _
X≠false ()
X=true = refl
-- The emptyness check for X ≡ false should be postponed until
-- X has been solved to true.
| 19.35
| 62
| 0.661499
|
df3ac23248224561f3bc542b3e449966675f5bac
| 3,702
|
agda
|
Agda
|
test/asset/agda-stdlib-1.0/Function/Surjection.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
test/asset/agda-stdlib-1.0/Function/Surjection.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Function/Surjection.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Surjections
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Function.Surjection where
open import Level
open import Function.Equality as F
using (_⟶_) renaming (_∘_ to _⟪∘⟫_)
open import Function.Equivalence using (Equivalence)
open import Function.Injection hiding (id; _∘_; injection)
open import Function.LeftInverse as Left hiding (id; _∘_)
open import Data.Product
open import Relation.Binary
open import Relation.Binary.PropositionalEquality as P using (_≡_)
------------------------------------------------------------------------
-- Surjective functions.
record Surjective {f₁ f₂ t₁ t₂}
{From : Setoid f₁ f₂} {To : Setoid t₁ t₂}
(to : From ⟶ To) :
Set (f₁ ⊔ f₂ ⊔ t₁ ⊔ t₂) where
field
from : To ⟶ From
right-inverse-of : from RightInverseOf to
------------------------------------------------------------------------
-- The set of all surjections from one setoid to another.
record Surjection {f₁ f₂ t₁ t₂}
(From : Setoid f₁ f₂) (To : Setoid t₁ t₂) :
Set (f₁ ⊔ f₂ ⊔ t₁ ⊔ t₂) where
field
to : From ⟶ To
surjective : Surjective to
open Surjective surjective public
right-inverse : RightInverse From To
right-inverse = record
{ to = from
; from = to
; left-inverse-of = right-inverse-of
}
open LeftInverse right-inverse public
using () renaming (to-from to from-to)
injective : Injective from
injective = LeftInverse.injective right-inverse
injection : Injection To From
injection = LeftInverse.injection right-inverse
equivalence : Equivalence From To
equivalence = record
{ to = to
; from = from
}
-- Right inverses can be turned into surjections.
fromRightInverse :
∀ {f₁ f₂ t₁ t₂} {From : Setoid f₁ f₂} {To : Setoid t₁ t₂} →
RightInverse From To → Surjection From To
fromRightInverse r = record
{ to = from
; surjective = record
{ from = to
; right-inverse-of = left-inverse-of
}
} where open LeftInverse r
------------------------------------------------------------------------
-- The set of all surjections from one set to another (i.e. sujections
-- with propositional equality)
infix 3 _↠_
_↠_ : ∀ {f t} → Set f → Set t → Set _
From ↠ To = Surjection (P.setoid From) (P.setoid To)
surjection : ∀ {f t} {From : Set f} {To : Set t} →
(to : From → To) (from : To → From) →
(∀ x → to (from x) ≡ x) →
From ↠ To
surjection to from surjective = record
{ to = P.→-to-⟶ to
; surjective = record
{ from = P.→-to-⟶ from
; right-inverse-of = surjective
}
}
------------------------------------------------------------------------
-- Identity and composition.
id : ∀ {s₁ s₂} {S : Setoid s₁ s₂} → Surjection S S
id {S = S} = record
{ to = F.id
; surjective = record
{ from = LeftInverse.to id′
; right-inverse-of = LeftInverse.left-inverse-of id′
}
} where id′ = Left.id {S = S}
infixr 9 _∘_
_∘_ : ∀ {f₁ f₂ m₁ m₂ t₁ t₂}
{F : Setoid f₁ f₂} {M : Setoid m₁ m₂} {T : Setoid t₁ t₂} →
Surjection M T → Surjection F M → Surjection F T
f ∘ g = record
{ to = to f ⟪∘⟫ to g
; surjective = record
{ from = LeftInverse.to g∘f
; right-inverse-of = LeftInverse.left-inverse-of g∘f
}
}
where
open Surjection
g∘f = Left._∘_ (right-inverse g) (right-inverse f)
| 29.149606
| 72
| 0.52188
|
12efdf290f0672f9d934e2197809b89a7897cb70
| 102
|
agda
|
Agda
|
test/Succeed/OpBind.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/OpBind.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/OpBind.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module OpBind where
postulate _∘_ : Set -> Set -> Set
Homomorphic₀ : Set → Set
Homomorphic₀ ∘ = ∘
| 11.333333
| 33
| 0.656863
|
a1292ffbcfba5c7a71d384f870509d1593fdf99e
| 1,727
|
agda
|
Agda
|
src/STLC/Term.agda
|
johnyob/agda-types
|
aeb2be63381d891fabe5317e3c27553deb6bca6d
|
[
"MIT"
] | null | null | null |
src/STLC/Term.agda
|
johnyob/agda-types
|
aeb2be63381d891fabe5317e3c27553deb6bca6d
|
[
"MIT"
] | null | null | null |
src/STLC/Term.agda
|
johnyob/agda-types
|
aeb2be63381d891fabe5317e3c27553deb6bca6d
|
[
"MIT"
] | null | null | null |
module STLC.Term where
open import Data.Fin using (Fin)
open import Data.Fin.Substitution
open import Data.Nat using (ℕ; _+_)
open import Relation.Binary.Construct.Closure.ReflexiveTransitive
using (Star; ε; _◅_)
open import Data.Vec using (Vec; []; _∷_; lookup)
open import Relation.Binary.PropositionalEquality
using (refl; _≡_; cong₂)
-- --------------------------------------------------------------------
-- Untyped terms and values
-- --------------------------------------------------------------------
infix 7 _·_
data Term (n : ℕ) : Set where
# : (x : Fin n) -> Term n
ƛ : Term (1 + n) -> Term n
_·_ : Term n -> Term n -> Term n
data Value {n : ℕ} : Term n -> Set where
ƛ :
∀ { t }
-- -----------
-> Value (ƛ t)
-- --------------------------------------------------------------------
module Substitution where
-- This sub module defines application of the subtitution
-- TODO: Rename for consistency
module SubstApplication { T : ℕ -> Set } ( l : Lift T Term ) where
open Lift l hiding (var)
-- Application of substitution to term
infixl 8 _/_
_/_ : ∀ { m n : ℕ } -> Term m -> Sub T m n -> Term n
# x / ρ = lift (lookup ρ x)
(ƛ t) / ρ = ƛ (t / ρ ↑)
(t₁ · t₂) / ρ = (t₁ / ρ) · (t₂ / ρ)
open Application (record { _/_ = _/_ }) using (_/✶_)
open TermSubst (record { var = #; app = SubstApplication._/_ }) public hiding (var)
infix 8 _[/_]
-- Shorthand for single-variable term substitutions
_[/_] : ∀ { n } → Term (1 + n) → Term n → Term n
t₁ [/ t₂ ] = t₁ / sub t₂
-- --------------------------------------------------------------------
-- TODO: Add additional operators
-- TODO: Add constants w/ delta-rules
| 23.657534
| 85
| 0.493341
|
295cdf7cd7845789e4ba416771b96215abc99bc7
| 4,122
|
agda
|
Agda
|
Agda/quotient-groups.agda
|
UlrikBuchholtz/HoTT-Intro
|
1e1f8def50f9359928e52ebb2ee53ed1166487d9
|
[
"CC-BY-4.0"
] | 333
|
2018-09-26T08:33:30.000Z
|
2022-03-22T23:50:15.000Z
|
Agda/quotient-groups.agda
|
UlrikBuchholtz/HoTT-Intro
|
1e1f8def50f9359928e52ebb2ee53ed1166487d9
|
[
"CC-BY-4.0"
] | 8
|
2019-06-18T04:16:04.000Z
|
2020-10-16T15:27:01.000Z
|
Agda/quotient-groups.agda
|
UlrikBuchholtz/HoTT-Intro
|
1e1f8def50f9359928e52ebb2ee53ed1166487d9
|
[
"CC-BY-4.0"
] | 30
|
2018-09-26T09:08:57.000Z
|
2022-03-16T00:33:50.000Z
|
{-# OPTIONS --without-K --exact-split #-}
module quotient-groups where
import subgroups
open subgroups public
{- The left and right coset relation -}
left-coset-relation :
{l1 l2 : Level} (G : Group l1) (H : Subgroup l2 G) →
(x y : type-Group G) → UU (l1 ⊔ l2)
left-coset-relation G H x =
fib ((mul-Group G x) ∘ (incl-group-Subgroup G H))
right-coset-relation :
{l1 l2 : Level} (G : Group l1) (H : Subgroup l2 G) →
(x y : type-Group G) → UU (l1 ⊔ l2)
right-coset-relation G H x =
fib ((mul-Group' G x) ∘ (incl-group-Subgroup G H))
{- We show that the left coset relation is an equivalence relation -}
is-prop-left-coset-relation :
{l1 l2 : Level} (G : Group l1) (H : Subgroup l2 G) →
(x y : type-Group G) → is-prop (left-coset-relation G H x y)
is-prop-left-coset-relation G H x =
is-prop-map-is-emb
( (mul-Group G x) ∘ (incl-group-Subgroup G H))
( is-emb-comp'
( mul-Group G x)
( incl-group-Subgroup G H)
( is-emb-is-equiv (mul-Group G x) (is-equiv-mul-Group G x))
( is-emb-incl-group-Subgroup G H))
is-reflexive-left-coset-relation :
{l1 l2 : Level} (G : Group l1) (H : Subgroup l2 G) →
(x : type-Group G) → left-coset-relation G H x x
is-reflexive-left-coset-relation G H x =
pair ( unit-group-Subgroup G H)
( right-unit-law-Group G x)
is-symmetric-left-coset-relation :
{l1 l2 : Level} (G : Group l1) (H : Subgroup l2 G) →
(x y : type-Group G) →
left-coset-relation G H x y → left-coset-relation G H y x
is-symmetric-left-coset-relation G H x y (pair z p) =
pair ( inv-group-Subgroup G H z)
( ap ( λ t → mul-Group G t
( incl-group-Subgroup G H
( inv-group-Subgroup G H z)))
( inv p) ∙
( ( is-associative-mul-Group G _ _ _) ∙
( ( ap (mul-Group G x) (right-inverse-law-Group G _)) ∙
( right-unit-law-Group G x))))
is-transitive-left-coset-relation :
{l1 l2 : Level} (G : Group l1) (H : Subgroup l2 G) →
(x y z : type-Group G) →
left-coset-relation G H x y → left-coset-relation G H y z →
left-coset-relation G H x z
is-transitive-left-coset-relation G H x y z (pair h1 p1) (pair h2 p2) =
pair ( mul-group-Subgroup G H h1 h2)
( ( inv (is-associative-mul-Group G _ _ _)) ∙
( ( ap (λ t → mul-Group G t (incl-group-Subgroup G H h2)) p1) ∙ p2))
{- We show that the right coset relation is an equivalence relation -}
is-prop-right-coset-relation :
{l1 l2 : Level} (G : Group l1) (H : Subgroup l2 G) →
(x y : type-Group G) → is-prop (right-coset-relation G H x y)
is-prop-right-coset-relation G H x =
is-prop-map-is-emb
( (mul-Group' G x) ∘ (incl-group-Subgroup G H))
( is-emb-comp'
( mul-Group' G x)
( incl-group-Subgroup G H)
( is-emb-is-equiv (mul-Group' G x) (is-equiv-mul-Group' G x))
( is-emb-incl-group-Subgroup G H))
is-reflexive-right-coset-relation :
{l1 l2 : Level} (G : Group l1) (H : Subgroup l2 G) →
(x : type-Group G) → right-coset-relation G H x x
is-reflexive-right-coset-relation G H x =
pair ( unit-group-Subgroup G H)
( left-unit-law-Group G x)
is-symmetric-right-coset-relation :
{l1 l2 : Level} (G : Group l1) (H : Subgroup l2 G) →
(x y : type-Group G) →
right-coset-relation G H x y → right-coset-relation G H y x
is-symmetric-right-coset-relation G H x y (pair z p) =
pair ( inv-group-Subgroup G H z)
( ( ap
( mul-Group G (incl-group-Subgroup G H (inv-group-Subgroup G H z)))
( inv p)) ∙
( ( inv (is-associative-mul-Group G _ _ _)) ∙
( ( ap (λ t → mul-Group G t x) (left-inverse-law-Group G _)) ∙
( left-unit-law-Group G x))))
is-transitive-right-coset-relation :
{l1 l2 : Level} (G : Group l1) (H : Subgroup l2 G) →
(x y z : type-Group G) →
right-coset-relation G H x y → right-coset-relation G H y z →
right-coset-relation G H x z
is-transitive-right-coset-relation G H x y z (pair h1 p1) (pair h2 p2) =
pair ( mul-group-Subgroup G H h2 h1)
( ( is-associative-mul-Group G _ _ _) ∙
( ( ap (mul-Group G (incl-group-Subgroup G H h2)) p1) ∙ p2))
| 37.472727
| 78
| 0.600194
|
59142c1d33da5100d1ac715f5f1cae389d607978
| 1,490
|
agda
|
Agda
|
Prelude/Eq.agda
|
bbarenblat/B
|
c1fd2daa41aa1b915f74b4c09c6e62c79320e8ec
|
[
"Apache-2.0"
] | 1
|
2017-06-30T15:59:38.000Z
|
2017-06-30T15:59:38.000Z
|
Prelude/Eq.agda
|
bbarenblat/B
|
c1fd2daa41aa1b915f74b4c09c6e62c79320e8ec
|
[
"Apache-2.0"
] | null | null | null |
Prelude/Eq.agda
|
bbarenblat/B
|
c1fd2daa41aa1b915f74b4c09c6e62c79320e8ec
|
[
"Apache-2.0"
] | null | null | null |
{- Copyright © 2015 Benjamin Barenblat
Licensed under the Apache License, Version 2.0 (the ‘License’); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an ‘AS IS’ BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License. -}
module B.Prelude.Eq where
import Data.Bool as Bool
open Bool using (Bool)
import Data.Char as Char
open Char using (Char)
import Data.Nat as ℕ
open ℕ using (ℕ)
open import Function using (_$_)
import Level
open Level using (_⊔_)
open import Relation.Nullary.Decidable using (⌊_⌋)
open import Relation.Binary using (DecSetoid)
record Eq {c} {ℓ} (t : Set c) : Set (Level.suc $ c ⊔ ℓ) where
field
decSetoid : DecSetoid c ℓ
_≟_ = DecSetoid._≟_ decSetoid
_==_ : DecSetoid.Carrier decSetoid
→ DecSetoid.Carrier decSetoid
→ Bool
x == y = ⌊ x ≟ y ⌋
open Eq ⦃...⦄ public
instance
Eq-Bool : Eq Bool
Eq-Bool = record { decSetoid = Bool.decSetoid }
Eq-Char : Eq Char
Eq-Char = record { decSetoid = Char.decSetoid }
-- TODO: Float
Eq-ℕ : Eq ℕ
Eq-ℕ =
let module DecTotalOrder = Relation.Binary.DecTotalOrder in
record { decSetoid = DecTotalOrder.Eq.decSetoid ℕ.decTotalOrder }
| 27.592593
| 79
| 0.719463
|
1d49422474c1181033fb9d7678a311a3ff552f56
| 2,462
|
agda
|
Agda
|
agda-stdlib-0.9/src/Algebra/FunctionProperties.agda
|
qwe2/try-agda
|
9d4c43b1609d3f085636376fdca73093481ab882
|
[
"Apache-2.0"
] | 1
|
2016-10-20T15:52:05.000Z
|
2016-10-20T15:52:05.000Z
|
agda-stdlib-0.9/src/Algebra/FunctionProperties.agda
|
qwe2/try-agda
|
9d4c43b1609d3f085636376fdca73093481ab882
|
[
"Apache-2.0"
] | null | null | null |
agda-stdlib-0.9/src/Algebra/FunctionProperties.agda
|
qwe2/try-agda
|
9d4c43b1609d3f085636376fdca73093481ab882
|
[
"Apache-2.0"
] | null | null | null |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Properties of functions, such as associativity and commutativity
------------------------------------------------------------------------
-- These properties can (for instance) be used to define algebraic
-- structures.
open import Level
open import Relation.Binary
-- The properties are specified using the following relation as
-- "equality".
module Algebra.FunctionProperties
{a ℓ} {A : Set a} (_≈_ : Rel A ℓ) where
open import Data.Product
------------------------------------------------------------------------
-- Unary and binary operations
open import Algebra.FunctionProperties.Core public
------------------------------------------------------------------------
-- Properties of operations
Associative : Op₂ A → Set _
Associative _∙_ = ∀ x y z → ((x ∙ y) ∙ z) ≈ (x ∙ (y ∙ z))
Commutative : Op₂ A → Set _
Commutative _∙_ = ∀ x y → (x ∙ y) ≈ (y ∙ x)
LeftIdentity : A → Op₂ A → Set _
LeftIdentity e _∙_ = ∀ x → (e ∙ x) ≈ x
RightIdentity : A → Op₂ A → Set _
RightIdentity e _∙_ = ∀ x → (x ∙ e) ≈ x
Identity : A → Op₂ A → Set _
Identity e ∙ = LeftIdentity e ∙ × RightIdentity e ∙
LeftZero : A → Op₂ A → Set _
LeftZero z _∙_ = ∀ x → (z ∙ x) ≈ z
RightZero : A → Op₂ A → Set _
RightZero z _∙_ = ∀ x → (x ∙ z) ≈ z
Zero : A → Op₂ A → Set _
Zero z ∙ = LeftZero z ∙ × RightZero z ∙
LeftInverse : A → Op₁ A → Op₂ A → Set _
LeftInverse e _⁻¹ _∙_ = ∀ x → (x ⁻¹ ∙ x) ≈ e
RightInverse : A → Op₁ A → Op₂ A → Set _
RightInverse e _⁻¹ _∙_ = ∀ x → (x ∙ (x ⁻¹)) ≈ e
Inverse : A → Op₁ A → Op₂ A → Set _
Inverse e ⁻¹ ∙ = LeftInverse e ⁻¹ ∙ × RightInverse e ⁻¹ ∙
_DistributesOverˡ_ : Op₂ A → Op₂ A → Set _
_*_ DistributesOverˡ _+_ =
∀ x y z → (x * (y + z)) ≈ ((x * y) + (x * z))
_DistributesOverʳ_ : Op₂ A → Op₂ A → Set _
_*_ DistributesOverʳ _+_ =
∀ x y z → ((y + z) * x) ≈ ((y * x) + (z * x))
_DistributesOver_ : Op₂ A → Op₂ A → Set _
* DistributesOver + = (* DistributesOverˡ +) × (* DistributesOverʳ +)
_IdempotentOn_ : Op₂ A → A → Set _
_∙_ IdempotentOn x = (x ∙ x) ≈ x
Idempotent : Op₂ A → Set _
Idempotent ∙ = ∀ x → ∙ IdempotentOn x
IdempotentFun : Op₁ A → Set _
IdempotentFun f = ∀ x → f (f x) ≈ f x
_Absorbs_ : Op₂ A → Op₂ A → Set _
_∙_ Absorbs _∘_ = ∀ x y → (x ∙ (x ∘ y)) ≈ x
Absorptive : Op₂ A → Op₂ A → Set _
Absorptive ∙ ∘ = (∙ Absorbs ∘) × (∘ Absorbs ∙)
Involutive : Op₁ A → Set _
Involutive f = ∀ x → f (f x) ≈ x
| 27.355556
| 72
| 0.529651
|
3906dd9cd11971a5175dfd5047bb04b464a7ecf7
| 1,257
|
agda
|
Agda
|
RefactorAgdaEngine/AgdaHelperFunctions.agda
|
omega12345/RefactorAgda
|
52d1034aed14c578c9e077fb60c3db1d0791416b
|
[
"BSD-3-Clause"
] | 5
|
2019-01-31T14:10:18.000Z
|
2019-05-03T10:03:36.000Z
|
RefactorAgdaEngine/AgdaHelperFunctions.agda
|
omega12345/RefactorAgda
|
52d1034aed14c578c9e077fb60c3db1d0791416b
|
[
"BSD-3-Clause"
] | 3
|
2019-01-31T08:03:07.000Z
|
2019-02-05T12:53:36.000Z
|
RefactorAgdaEngine/AgdaHelperFunctions.agda
|
omega12345/RefactorAgda
|
52d1034aed14c578c9e077fb60c3db1d0791416b
|
[
"BSD-3-Clause"
] | 1
|
2019-01-31T08:40:41.000Z
|
2019-01-31T08:40:41.000Z
|
-- stuff I did not find in the standard library, but which
-- I might just not have noticed.
module AgdaHelperFunctions where
open import Data.String
open import Data.Sum
open import Category.Monad
infixr 0 _$_
_$_ : {A B : Set} -> (A -> B) -> A -> B
x $ y = x y
bind : {error x y : Set} -> error ⊎ x -> (x -> error ⊎ y) -> error ⊎ y
bind (inj₁ x) f = inj₁ x
bind (inj₂ y) f = f y
SumMonad : {error : Set} -> RawMonad (error ⊎_)
SumMonad = record
{ return = inj₂
; _>>=_ = bind
}
bindT : {monadType : Set -> Set}(underlyingMonad : RawMonad monadType){error x y : Set} -> (monadType (error ⊎ x)) -> (x -> monadType (error ⊎ y)) -> monadType (error ⊎ y)
bindT underlyingMonad x f = do
inj₂ content <- x
where inj₁ e -> return $ inj₁ e
f content
where open RawMonad underlyingMonad
SumMonadT : {monadType : Set -> Set}(underlyingMonad : RawMonad monadType)(error : Set) -> RawMonad (λ x -> monadType (error ⊎ x))
SumMonadT underlyingMonad error = record
{ return = λ x -> r $ inj₂ x
; _>>=_ = bindT underlyingMonad
}
where open RawMonad underlyingMonad renaming (return to r)
import IO.Primitive as Prim
IOMonad : RawMonad (λ (x : Set) -> Prim.IO x)
IOMonad = record
{ return = Prim.return
; _>>=_ = Prim._>>=_
}
| 27.933333
| 171
| 0.638823
|
292887218748123ddfd1721e7be70d43a2d1bcc3
| 2,269
|
agda
|
Agda
|
presentationsAndExampleCode/agdaImplementorsMeetingGlasgow22April2016AntonSetzer/interfaceExtensionAndDelegation.agda
|
agda/ooAgda
|
7cc45e0148a4a508d20ed67e791544c30fecd795
|
[
"MIT"
] | 23
|
2016-06-19T12:57:55.000Z
|
2020-10-12T23:15:25.000Z
|
presentationsAndExampleCode/agdaImplementorsMeetingGlasgow22April2016AntonSetzer/interfaceExtensionAndDelegation.agda
|
agda/ooAgda
|
7cc45e0148a4a508d20ed67e791544c30fecd795
|
[
"MIT"
] | null | null | null |
presentationsAndExampleCode/agdaImplementorsMeetingGlasgow22April2016AntonSetzer/interfaceExtensionAndDelegation.agda
|
agda/ooAgda
|
7cc45e0148a4a508d20ed67e791544c30fecd795
|
[
"MIT"
] | 2
|
2018-09-01T15:02:37.000Z
|
2022-03-12T11:41:00.000Z
|
module interfaceExtensionAndDelegation where
open import Data.Product
open import Data.Nat.Base
open import Data.Nat.Show
open import Data.String.Base using (String; _++_)
open import Size
open import NativeIO
open import interactiveProgramsAgda using (ConsoleInterface; _>>=_; do;
IO; return; putStrLn;
translateIOConsole )
open import objectsInAgda using (Interface; Method; Result; CellMethod;
get; put; CellResult; cellI; IOObject;
CellC; method; simpleCell )
data CounterMethod A : Set where
super : (m : CellMethod A) → CounterMethod A
stats : CounterMethod A
statsCellI : (A : Set) → Interface
Method (statsCellI A) = CounterMethod A
Result (statsCellI A) (super m) = Result (cellI A) m
Result (statsCellI A) stats = Unit
CounterC : (i : Size) → Set
CounterC = IOObject ConsoleInterface (statsCellI String)
pattern getᶜ = super get
pattern putᶜ x = super (put x)
{- Methods of CounterC are now
getᶜ (putᶜ x) stats
-}
counterCell : ∀{i} (c : CellC i) (ngets nputs : ℕ) → CounterC i
method (counterCell c ngets nputs) getᶜ =
method c get >>= λ { (s , c') →
return (s , counterCell c' (1 + ngets) nputs) }
method (counterCell c ngets nputs) (putᶜ x) =
method c (put x) >>= λ { (_ , c') →
return (_ , counterCell c' ngets (1 + nputs)) }
method (counterCell c ngets nputs) stats =
do (putStrLn ("Counted "
++ show ngets ++ " calls to get and "
++ show nputs ++ " calls to put.")) λ _ →
return (_ , counterCell c ngets nputs)
program : String → IO ConsoleInterface ∞ Unit
program arg =
let c₀ = counterCell (simpleCell "Start") 0 0 in
method c₀ getᶜ >>= λ{ (s , c₁) →
do (putStrLn s) λ _ →
method c₁ (putᶜ arg) >>= λ{ (_ , c₂) →
method c₂ getᶜ >>= λ{ (s' , c₃) →
do (putStrLn s') λ _ →
method c₃ (putᶜ "Over!") >>= λ{ (_ , c₄) →
method c₄ stats >>= λ{ (_ , c₅) →
return _ }}}}}
main : NativeIO Unit
main = translateIOConsole (program "Hello")
| 33.367647
| 72
| 0.560599
|
20a01ef9cc23f176aa52df98acf2480cd4316d72
| 4,673
|
agda
|
Agda
|
agda-stdlib/src/Algebra/Solver/Ring/AlmostCommutativeRing.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/src/Algebra/Solver/Ring/AlmostCommutativeRing.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Algebra/Solver/Ring/AlmostCommutativeRing.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Commutative semirings with some additional structure ("almost"
-- commutative rings), used by the ring solver
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Algebra.Solver.Ring.AlmostCommutativeRing where
open import Algebra
open import Algebra.Structures
open import Algebra.Definitions
import Algebra.Morphism as Morphism
import Algebra.Morphism.Definitions as MorphismDefinitions
open import Function
open import Level
open import Relation.Binary
record IsAlmostCommutativeRing {a ℓ} {A : Set a} (_≈_ : Rel A ℓ)
(_+_ _*_ : Op₂ A) (-_ : Op₁ A)
(0# 1# : A) : Set (a ⊔ ℓ) where
field
isCommutativeSemiring : IsCommutativeSemiring _≈_ _+_ _*_ 0# 1#
-‿cong : Congruent₁ _≈_ -_
-‿*-distribˡ : ∀ x y → ((- x) * y) ≈ (- (x * y))
-‿+-comm : ∀ x y → ((- x) + (- y)) ≈ (- (x + y))
open IsCommutativeSemiring isCommutativeSemiring public
record AlmostCommutativeRing c ℓ : Set (suc (c ⊔ ℓ)) where
infix 8 -_
infixl 7 _*_
infixl 6 _+_
infix 4 _≈_
field
Carrier : Set c
_≈_ : Rel Carrier ℓ
_+_ : Op₂ Carrier
_*_ : Op₂ Carrier
-_ : Op₁ Carrier
0# : Carrier
1# : Carrier
isAlmostCommutativeRing : IsAlmostCommutativeRing _≈_ _+_ _*_ -_ 0# 1#
open IsAlmostCommutativeRing isAlmostCommutativeRing public
commutativeSemiring : CommutativeSemiring _ _
commutativeSemiring = record
{ isCommutativeSemiring = isCommutativeSemiring
}
open CommutativeSemiring commutativeSemiring public
using
( +-magma; +-semigroup
; *-magma; *-semigroup; *-commutativeSemigroup
; +-monoid; +-commutativeMonoid
; *-monoid; *-commutativeMonoid
; semiring
)
rawRing : RawRing _ _
rawRing = record
{ _≈_ = _≈_
; _+_ = _+_
; _*_ = _*_
; -_ = -_
; 0# = 0#
; 1# = 1#
}
------------------------------------------------------------------------
-- Homomorphisms
record _-Raw-AlmostCommutative⟶_
{r₁ r₂ r₃ r₄}
(From : RawRing r₁ r₄)
(To : AlmostCommutativeRing r₂ r₃) : Set (r₁ ⊔ r₂ ⊔ r₃) where
private
module F = RawRing From
module T = AlmostCommutativeRing To
open MorphismDefinitions F.Carrier T.Carrier T._≈_
field
⟦_⟧ : Morphism
+-homo : Homomorphic₂ ⟦_⟧ F._+_ T._+_
*-homo : Homomorphic₂ ⟦_⟧ F._*_ T._*_
-‿homo : Homomorphic₁ ⟦_⟧ F.-_ T.-_
0-homo : Homomorphic₀ ⟦_⟧ F.0# T.0#
1-homo : Homomorphic₀ ⟦_⟧ F.1# T.1#
-raw-almostCommutative⟶ :
∀ {r₁ r₂} (R : AlmostCommutativeRing r₁ r₂) →
AlmostCommutativeRing.rawRing R -Raw-AlmostCommutative⟶ R
-raw-almostCommutative⟶ R = record
{ ⟦_⟧ = id
; +-homo = λ _ _ → refl
; *-homo = λ _ _ → refl
; -‿homo = λ _ → refl
; 0-homo = refl
; 1-homo = refl
}
where open AlmostCommutativeRing R
Induced-equivalence : ∀ {c₁ c₂ ℓ₁ ℓ₂} {Coeff : RawRing c₁ ℓ₁}
{R : AlmostCommutativeRing c₂ ℓ₂} →
Coeff -Raw-AlmostCommutative⟶ R →
Rel (RawRing.Carrier Coeff) ℓ₂
Induced-equivalence {R = R} morphism a b = ⟦ a ⟧ ≈ ⟦ b ⟧
where
open AlmostCommutativeRing R
open _-Raw-AlmostCommutative⟶_ morphism
------------------------------------------------------------------------
-- Conversions
-- Commutative rings are almost commutative rings.
fromCommutativeRing : ∀ {r₁ r₂} → CommutativeRing r₁ r₂ → AlmostCommutativeRing r₁ r₂
fromCommutativeRing CR = record
{ isAlmostCommutativeRing = record
{ isCommutativeSemiring = isCommutativeSemiring
; -‿cong = -‿cong
; -‿*-distribˡ = -‿*-distribˡ
; -‿+-comm = ⁻¹-∙-comm
}
}
where
open CommutativeRing CR
open import Algebra.Properties.Ring ring
open import Algebra.Properties.AbelianGroup +-abelianGroup
-- Commutative semirings can be viewed as almost commutative rings by
-- using identity as the "almost negation".
fromCommutativeSemiring : ∀ {r₁ r₂} → CommutativeSemiring r₁ r₂ → AlmostCommutativeRing _ _
fromCommutativeSemiring CS = record
{ -_ = id
; isAlmostCommutativeRing = record
{ isCommutativeSemiring = isCommutativeSemiring
; -‿cong = id
; -‿*-distribˡ = λ _ _ → refl
; -‿+-comm = λ _ _ → refl
}
}
where open CommutativeSemiring CS
| 31.153333
| 91
| 0.562166
|
39f46096f129d02593a8bfde9d5039e53b6158ee
| 970
|
agda
|
Agda
|
test/succeed/Issue826-2.agda
|
larrytheliquid/agda
|
477c8c37f948e6038b773409358fd8f38395f827
|
[
"MIT"
] | 1
|
2018-10-10T17:08:44.000Z
|
2018-10-10T17:08:44.000Z
|
test/succeed/Issue826-2.agda
|
masondesu/agda
|
70c8a575c46f6a568c7518150a1a64fcd03aa437
|
[
"MIT"
] | null | null | null |
test/succeed/Issue826-2.agda
|
masondesu/agda
|
70c8a575c46f6a568c7518150a1a64fcd03aa437
|
[
"MIT"
] | 1
|
2022-03-12T11:35:18.000Z
|
2022-03-12T11:35:18.000Z
|
module Issue826-2 where
open import Common.Coinduction
data _≡_ {A : Set} (x y : A) : Set where
data D : Set where
c : ∞ D → D
delay : D → ∞ D
delay = ♯_
data P : D → Set where
o : (x : ∞ D) → P (♭ x) → P (c x)
postulate
h : (x : D) → P x → P x
f : (x : D) → P (c (delay x)) → P x
f x (o .(delay x) p) = h x p
g : (x : D) → P x → P (c (delay x))
g x p = h (c (delay x)) (o (delay x) p)
postulate
bar : (x : ∞ D) (p : P (♭ x)) →
h (c x) (o x (h (♭ x) p)) ≡ o x p
foo : (x : D) (p : P (c (delay x))) → g x (f x p) ≡ p
foo x (o .(delay x) p) = goal
where
x′ = _
goal : _ ≡ o x′ p
goal = bar x′ p
-- The following error message seems to indicate that an expression is
-- not forced properly:
--
-- Bug.agda:30,26-30
-- ♭ (.Bug.♯-0 x) != x of type D
-- when checking that the expression goal has type
-- g x (f x (o (.Bug.♯-0 x) p)) ≡ o (.Bug.♯-0 x) p
--
-- Thus it seems as if this problem affects plain type-checking as
-- well.
| 20.638298
| 70
| 0.510309
|
0bd8d8bab6d69824c787510726b0ed9181ac50bc
| 4,846
|
agda
|
Agda
|
Cubical/DStructures/Structures/ReflGraph.agda
|
Schippmunk/cubical
|
c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a
|
[
"MIT"
] | null | null | null |
Cubical/DStructures/Structures/ReflGraph.agda
|
Schippmunk/cubical
|
c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a
|
[
"MIT"
] | null | null | null |
Cubical/DStructures/Structures/ReflGraph.agda
|
Schippmunk/cubical
|
c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.DStructures.Structures.ReflGraph 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.Structure
open import Cubical.Functions.FunExtEquiv
open import Cubical.Homotopy.Base
open import Cubical.Data.Sigma
open import Cubical.Relation.Binary
open import Cubical.Algebra.Group
open import Cubical.Structures.LeftAction
open import Cubical.DStructures.Base
open import Cubical.DStructures.Meta.Properties
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 GroupLemmas
open MorphismLemmas
private
variable
ℓ ℓ' : Level
---------------------------------------------
-- Reflexive graphs in the category of groups
--
-- ReflGraph
-- |
-- SplitEpiB
--
---------------------------------------------
module _ (ℓ ℓ' : Level) where
-- type of internal reflexive graphs in the category of groups
ReflGraph = Σ[ ((((G₀ , G₁) , ι , σ) , split-σ) , τ) ∈ (SplitEpiB ℓ ℓ') ] isGroupSplitEpi ι τ
-- reflexive graphs displayed over split epimorphisms with an
-- extra morphism back
𝒮ᴰ-ReflGraph : URGStrᴰ (𝒮-SplitEpiB ℓ ℓ')
(λ ((((G , H) , f , b) , isRet) , b')
→ isGroupSplitEpi f b')
ℓ-zero
𝒮ᴰ-ReflGraph = Subtype→Sub-𝒮ᴰ (λ ((((G , H) , f , b) , isRet) , b')
→ isGroupSplitEpi f b' , isPropIsGroupSplitEpi f b')
(𝒮-SplitEpiB ℓ ℓ')
-- the URG structure on the type of reflexive graphs
𝒮-ReflGraph : URGStr ReflGraph (ℓ-max ℓ ℓ')
𝒮-ReflGraph = ∫⟨ (𝒮-SplitEpiB ℓ ℓ') ⟩ 𝒮ᴰ-ReflGraph
--------------------------------------------------
-- This module introduces convenient notation
-- when working with a single reflexive graph
---------------------------------------------------
module ReflGraphNotation (𝒢 : ReflGraph ℓ ℓ') where
-- extract the components of the Σ-type
G₁ = snd (fst (fst (fst (fst 𝒢))))
G₀ = fst (fst (fst (fst (fst 𝒢))))
σ = snd (snd (fst (fst (fst 𝒢))))
τ = snd (fst 𝒢)
ι = fst (snd (fst (fst (fst 𝒢))))
split-τ = snd 𝒢
split-σ = snd (fst (fst 𝒢))
-- open other modules containing convenient notation
open SplitEpiNotation ι σ split-σ public
open GroupNotation₁ G₁ public
open GroupNotation₀ G₀ public
open GroupHom public
-- underlying maps
t = GroupHom.fun τ
-- combinations of maps to reduce
-- amount of parentheses in proofs
𝒾s = λ (g : ⟨ G₁ ⟩) → 𝒾 (s g) -- TODO: remove
𝒾t = λ (g : ⟨ G₁ ⟩) → 𝒾 (t g) -- TODO: remove
it = λ (g : ⟨ G₁ ⟩) → 𝒾 (t g)
ti = λ (g : ⟨ G₀ ⟩) → t (𝒾 g)
-it = λ (x : ⟨ G₁ ⟩) → -₁ (𝒾t x)
it- = λ (x : ⟨ G₁ ⟩) → 𝒾t (-₁ x)
ι∘τ : GroupHom G₁ G₁
ι∘τ = compGroupHom τ ι
-- extract what it means for σ and τ to be split
σι-≡-fun : (g : ⟨ G₀ ⟩) → si g ≡ g
σι-≡-fun = λ (g : ⟨ G₀ ⟩) → funExt⁻ (cong GroupHom.fun split-σ) g
τι-≡-fun : (g : ⟨ G₀ ⟩) → ti g ≡ g
τι-≡-fun = λ (g : ⟨ G₀ ⟩) → funExt⁻ (cong GroupHom.fun split-τ) g
-------------------------------------------
-- Lemmas about reflexive graphs in groups
-------------------------------------------
module ReflGraphLemmas (𝒢 : ReflGraph ℓ ℓ') where
open ReflGraphNotation 𝒢
-- the property for two morphisms to be composable
isComposable : (g f : ⟨ G₁ ⟩) → Type ℓ
isComposable g f = s g ≡ t f
-- isComposable is a proposition, because G₀ is a set
isPropIsComposable : (g f : ⟨ G₁ ⟩) → isProp (isComposable g f)
isPropIsComposable g f c c' = set₀ (s g) (t f) c c'
-- further reductions that are used often
abstract
-- σ (g -₁ ι (σ g)) ≡ 0₀
σ-g--isg : (g : ⟨ G₁ ⟩) → s (g -₁ (𝒾s g)) ≡ 0₀
σ-g--isg g = s (g -₁ (𝒾s g))
≡⟨ σ .isHom g (-₁ 𝒾s g) ⟩
s g +₀ s (-₁ 𝒾s g)
≡⟨ cong (s g +₀_)
(mapInv σ (𝒾s g)) ⟩
s g -₀ s (𝒾s g)
≡⟨ cong (λ z → s g -₀ z)
(σι-≡-fun (s g)) ⟩
s g -₀ s g
≡⟨ rCancel₀ (s g) ⟩
0₀ ∎
-- g is composable with ι (σ g)
isComp-g-isg : (g : ⟨ G₁ ⟩) → isComposable g (𝒾s g)
isComp-g-isg g = sym (τι-≡-fun (s g))
-- ι (τ f) is composable with f
isComp-itf-f : (f : ⟨ G₁ ⟩) → isComposable (it f) f
isComp-itf-f f = σι-≡-fun (t f)
-- ι (σ (-₁ ι g)) ≡ -₁ (ι g)
ισ-ι : (g : ⟨ G₀ ⟩) → 𝒾s (-₁ (𝒾 g)) ≡ -₁ (𝒾 g)
ισ-ι g = mapInv ι∘σ (𝒾 g) ∙ cong (λ z → -₁ (𝒾 z)) (σι-≡-fun g)
| 32.743243
| 95
| 0.535493
|
cb25daa96908fe0feac180d21db72a56391b45e8
| 67,003
|
agda
|
Agda
|
agda/Esterel/Lang/CanFunction/CanThetaContinuation.agda
|
florence/esterel-calculus
|
4340bef3f8df42ab8167735d35a4cf56243a45cd
|
[
"MIT"
] | 3
|
2020-04-16T10:58:53.000Z
|
2020-07-01T03:59:31.000Z
|
agda/Esterel/Lang/CanFunction/CanThetaContinuation.agda
|
florence/esterel-calculus
|
4340bef3f8df42ab8167735d35a4cf56243a45cd
|
[
"MIT"
] | null | null | null |
agda/Esterel/Lang/CanFunction/CanThetaContinuation.agda
|
florence/esterel-calculus
|
4340bef3f8df42ab8167735d35a4cf56243a45cd
|
[
"MIT"
] | 1
|
2020-04-15T20:02:49.000Z
|
2020-04-15T20:02:49.000Z
|
{-
The module CanThetaContinuation contains the continuation-passing
variant of Canθ, which is used as a tool to simplify Canθ-Can
expressions.
The lemmas are mainly about the function Canθ' defined by the equation
unfold : ∀ sigs S'' p θ →
Canθ sigs S'' p θ ≡ Canθ' sigs S'' (Can p) θ
The main property proved here is that the search function
Canθ is distributive over the environment:
canθ'-←-distribute : ∀ sigs sigs' S'' r θ →
Canθ (SigMap.union sigs sigs') S'' r θ ≡
Canθ' sigs S'' (Canθ sigs' S'' r) θ
Other properties about how the search is performed are:
canθ'-inner-shadowing-irr : ∀ sigs S'' sigs' p S status θ →
S ∈ SigMap.keys sigs' →
Canθ' sigs S'' (Canθ sigs' 0 p) (θ ← [ (S ₛ) ↦ status ]) ≡
Canθ' sigs S'' (Canθ sigs' 0 p) θ
canθ'-search-acc : ∀ sigs S κ θ →
∀ S'' status →
S'' ∉ map (_+_ S) (SigMap.keys sigs) →
Canθ' sigs S κ (θ ← [ (S'' ₛ) ↦ status ]) ≡
Canθ' sigs S (κ ∘ (_← [ (S'' ₛ) ↦ status ])) θ
-}
module Esterel.Lang.CanFunction.CanThetaContinuation where
open import utility
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.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
-- equation: Canθ sig S'' p θ = Canθ' sig S'' (Can p) θ
Canθ' : SigMap.Map Signal.Status → ℕ →
(Env → SigSet.ST × CodeSet.ST × ShrSet.ST) →
Env → SigSet.ST × CodeSet.ST × ShrSet.ST
Canθ' [] S κ θ = κ θ
Canθ' (nothing ∷ sig') S κ θ = Canθ' sig' (suc S) κ θ
Canθ' (just Signal.present ∷ sig') S κ θ = Canθ' sig' (suc S) κ (θ ← [S]-env-present (S ₛ))
Canθ' (just Signal.absent ∷ sig') S κ θ = Canθ' sig' (suc S) κ (θ ← [S]-env-absent (S ₛ))
Canθ' (just Signal.unknown ∷ sig') S κ θ with
any (_≟_ S) (proj₁ (Canθ' sig' (suc S) κ (θ ← [S]-env (S ₛ))))
... | yes S∈can-p-θ←[S] = Canθ' sig' (suc S) κ (θ ← [S]-env (S ₛ))
... | no S∉can-p-θ←[S] = Canθ' sig' (suc S) κ (θ ← [S]-env-absent (S ₛ))
unfold : ∀ sigs S'' p θ → Canθ sigs S'' p θ ≡ Canθ' sigs S'' (Can p) θ
unfold [] S'' p θ = refl
unfold (nothing ∷ sigs) S'' p θ = unfold sigs (suc S'') p θ
unfold (just Signal.present ∷ sigs) S'' p θ =
unfold sigs (suc S'') p (θ ← [S]-env-present (S'' ₛ))
unfold (just Signal.absent ∷ sigs) S'' p θ =
unfold sigs (suc S'') p (θ ← [S]-env-absent (S'' ₛ))
unfold (just Signal.unknown ∷ sigs) S'' p θ
with any (_≟_ S'') (proj₁ (Canθ sigs (suc S'') p (θ ← [S]-env (S'' ₛ))))
| any (_≟_ S'') (proj₁ (Canθ' sigs (suc S'') (Can p) (θ ← [S]-env (S'' ₛ))))
... | yes S''∈canθ-sigs-θ←[S''] | yes S''∈canθ'-sigs-θ←[S''] =
unfold sigs (suc S'') p (θ ← [S]-env (S'' ₛ))
... | no S''∉canθ-sigs-θ←[S''] | no S''∉canθ'-sigs-θ←[S''] =
unfold sigs (suc S'') p (θ ← [S]-env-absent (S'' ₛ))
... | yes S''∈canθ-sigs-θ←[S''] | no S''∉canθ'-sigs-θ←[S'']
rewrite unfold sigs (suc S'') p (θ ← [S]-env (S'' ₛ))
= ⊥-elim (S''∉canθ'-sigs-θ←[S''] S''∈canθ-sigs-θ←[S''])
... | no S''∉canθ-sigs-θ←[S''] | yes S''∈canθ'-sigs-θ←[S'']
rewrite unfold sigs (suc S'') p (θ ← [S]-env (S'' ₛ))
= ⊥-elim (S''∉canθ-sigs-θ←[S''] S''∈canθ'-sigs-θ←[S''])
canθ'-cong : ∀ sigs S'' κ κ' θ →
(∀ θ* → κ θ* ≡ κ' θ*) →
Canθ' sigs S'' κ θ ≡ Canθ' sigs S'' κ' θ
canθ'-cong [] S'' κ κ' θ κ≗κ' = κ≗κ' θ
canθ'-cong (nothing ∷ sigs) S'' κ κ' θ κ≗κ' =
canθ'-cong sigs (suc S'') κ κ' θ κ≗κ'
canθ'-cong (just Signal.present ∷ sigs) S'' κ κ' θ κ≗κ' =
canθ'-cong sigs (suc S'') κ κ' (θ ← [S]-env-present (S'' ₛ)) κ≗κ'
canθ'-cong (just Signal.absent ∷ sigs) S'' κ κ' θ κ≗κ' =
canθ'-cong sigs (suc S'') κ κ' (θ ← [S]-env-absent (S'' ₛ)) κ≗κ'
canθ'-cong (just Signal.unknown ∷ sigs) S'' κ κ' θ κ≗κ'
with any (_≟_ S'') (proj₁ (Canθ' sigs (suc S'') κ (θ ← [S]-env (S'' ₛ))))
| any (_≟_ S'') (proj₁ (Canθ' sigs (suc S'') κ' (θ ← [S]-env (S'' ₛ))))
... | yes S''∈canθ'-sigs-κ-θ←[S''] | yes S''∈canθ'-sigs-κ'-θ←[S''] =
canθ'-cong sigs (suc S'') κ κ' (θ ← [S]-env (S'' ₛ)) κ≗κ'
... | no S''∉canθ'-sigs-κ-θ←[S''] | no S''∉canθ'-sigs-κ'-θ←[S''] =
canθ'-cong sigs (suc S'') κ κ' (θ ← [S]-env-absent (S'' ₛ)) κ≗κ'
... | yes S''∈canθ'-sigs-κ-θ←[S''] | no S''∉canθ'-sigs-κ'-θ←[S'']
rewrite canθ'-cong sigs (suc S'') κ κ' (θ ← [S]-env (S'' ₛ)) κ≗κ'
= ⊥-elim (S''∉canθ'-sigs-κ'-θ←[S''] S''∈canθ'-sigs-κ-θ←[S''])
... | no S''∉canθ'-sigs-κ-θ←[S''] | yes S''∈canθ'-sigs-κ'-θ←[S'']
rewrite canθ'-cong sigs (suc S'') κ κ' (θ ← [S]-env (S'' ₛ)) κ≗κ'
= ⊥-elim (S''∉canθ'-sigs-κ-θ←[S''] S''∈canθ'-sigs-κ'-θ←[S''])
canθₛ'-cong : ∀ sigs S'' κ κ' θ →
(∀ θ* → proj₁ (κ θ*) ≡ proj₁ (κ' θ*)) →
proj₁ (Canθ' sigs S'' κ θ) ≡ proj₁ (Canθ' sigs S'' κ' θ)
canθₛ'-cong [] S'' κ κ' θ κ≗κ' = κ≗κ' θ
canθₛ'-cong (nothing ∷ sigs) S'' κ κ' θ κ≗κ' =
canθₛ'-cong sigs (suc S'') κ κ' θ κ≗κ'
canθₛ'-cong (just Signal.present ∷ sigs) S'' κ κ' θ κ≗κ' =
canθₛ'-cong sigs (suc S'') κ κ' (θ ← [S]-env-present (S'' ₛ)) κ≗κ'
canθₛ'-cong (just Signal.absent ∷ sigs) S'' κ κ' θ κ≗κ' =
canθₛ'-cong sigs (suc S'') κ κ' (θ ← [S]-env-absent (S'' ₛ)) κ≗κ'
canθₛ'-cong (just Signal.unknown ∷ sigs) S'' κ κ' θ κ≗κ'
with any (_≟_ S'') (proj₁ (Canθ' sigs (suc S'') κ (θ ← [S]-env (S'' ₛ))))
| any (_≟_ S'') (proj₁ (Canθ' sigs (suc S'') κ' (θ ← [S]-env (S'' ₛ))))
... | yes S''∈canθ'-sigs-κ-θ←[S''] | yes S''∈canθ'-sigs-κ'-θ←[S''] =
canθₛ'-cong sigs (suc S'') κ κ' (θ ← [S]-env (S'' ₛ)) κ≗κ'
... | no S''∉canθ'-sigs-κ-θ←[S''] | no S''∉canθ'-sigs-κ'-θ←[S''] =
canθₛ'-cong sigs (suc S'') κ κ' (θ ← [S]-env-absent (S'' ₛ)) κ≗κ'
... | yes S''∈canθ'-sigs-κ-θ←[S''] | no S''∉canθ'-sigs-κ'-θ←[S'']
rewrite canθₛ'-cong sigs (suc S'') κ κ' (θ ← [S]-env (S'' ₛ)) κ≗κ'
= ⊥-elim (S''∉canθ'-sigs-κ'-θ←[S''] S''∈canθ'-sigs-κ-θ←[S''])
... | no S''∉canθ'-sigs-κ-θ←[S''] | yes S''∈canθ'-sigs-κ'-θ←[S'']
rewrite canθₛ'-cong sigs (suc S'') κ κ' (θ ← [S]-env (S'' ₛ)) κ≗κ'
= ⊥-elim (S''∉canθ'-sigs-κ-θ←[S''] S''∈canθ'-sigs-κ'-θ←[S''])
canθ'-map-comm : ∀ f sigs S κ θ →
Canθ' sigs S (map-second f ∘ κ) θ ≡ map-second f (Canθ' sigs S κ θ)
canθ'-map-comm f [] S κ θ = refl
canθ'-map-comm f (nothing ∷ sigs) S κ θ =
canθ'-map-comm f sigs (suc S) κ θ
canθ'-map-comm f (just Signal.present ∷ sigs) S κ θ =
canθ'-map-comm f sigs (suc S) κ (θ ← [S]-env-present (S ₛ))
canθ'-map-comm f (just Signal.absent ∷ sigs) S κ θ =
canθ'-map-comm f sigs (suc S) κ (θ ← [S]-env-absent (S ₛ))
canθ'-map-comm f (just Signal.unknown ∷ sigs) S κ θ
with any (_≟_ S) (proj₁ (Canθ' sigs (suc S) (map-second f ∘ κ) (θ ← [S]-env (S ₛ))))
| any (_≟_ S) (proj₁ (Canθ' sigs (suc S) κ (θ ← [S]-env (S ₛ))))
... | yes S∈canθ'-sigs-f∘κ-θ←[S] | yes S∈canθ'-sigs-κ-θ←[S] =
canθ'-map-comm f sigs (suc S) κ (θ ← [S]-env (S ₛ))
... | no S∉canθ'-sigs-f∘κ-θ←[S] | no S∉canθ'-sigs-κ-θ←[S] =
canθ'-map-comm f sigs (suc S) κ (θ ← [S]-env-absent (S ₛ))
... | yes S∈canθ'-sigs-f∘κ-θ←[S] | no S∉canθ'-sigs-κ-θ←[S]
rewrite canθ'-map-comm f sigs (suc S) κ (θ ← [S]-env (S ₛ))
= ⊥-elim (S∉canθ'-sigs-κ-θ←[S] S∈canθ'-sigs-f∘κ-θ←[S])
... | no S∉canθ'-sigs-f∘κ-θ←[S] | yes S∈canθ'-sigs-κ-θ←[S]
rewrite canθ'-map-comm f sigs (suc S) κ (θ ← [S]-env (S ₛ))
= ⊥-elim (S∉canθ'-sigs-f∘κ-θ←[S] S∈canθ'-sigs-κ-θ←[S])
canθ'ₛ-add-sig-monotonic : ∀ sigs S'' κ θ S status →
(∀ θ S status S' →
S' ∈ proj₁ (κ (θ ← Θ SigMap.[ S ↦ status ] ShrMap.empty VarMap.empty)) →
S' ∈ proj₁ (κ (θ ← [S]-env S))) →
∀ S' →
S' ∈ proj₁ (Canθ' sigs S'' κ (θ ← Θ SigMap.[ S ↦ status ] ShrMap.empty VarMap.empty)) →
S' ∈ proj₁ (Canθ' sigs S'' κ (θ ← [S]-env S))
canθ'ₛ-add-sig-monotonic [] S'' κ θ S status κ-add-sig-monotonic
S' S'∈canθ'-sigs-p-θ←[S↦status] =
κ-add-sig-monotonic θ S status S' S'∈canθ'-sigs-p-θ←[S↦status]
canθ'ₛ-add-sig-monotonic (nothing ∷ sigs) S'' κ θ S status
κ-add-sig-monotonic S' S'∈canθ'-sigs-p-θ←[S↦status] =
canθ'ₛ-add-sig-monotonic sigs (suc S'') κ θ S status
κ-add-sig-monotonic S' S'∈canθ'-sigs-p-θ←[S↦status]
canθ'ₛ-add-sig-monotonic (just x ∷ sigs) S'' κ θ S status
κ-add-sig-monotonic S' S'∈canθ'-sigs-p-θ←[S↦status] with Signal.unwrap S ≟ S''
canθ'ₛ-add-sig-monotonic (just Signal.present ∷ sigs) S'' κ θ S status
κ-add-sig-monotonic S' S'∈canθ'-sigs-p-θ←[S↦status] | yes refl
rewrite Env.sig-single-←-←-overwrite θ (S'' ₛ) Signal.unknown Signal.present
| Env.sig-single-←-←-overwrite θ (S'' ₛ) status Signal.present
= S'∈canθ'-sigs-p-θ←[S↦status]
canθ'ₛ-add-sig-monotonic (just Signal.absent ∷ sigs) S'' κ θ S status
κ-add-sig-monotonic S' S'∈canθ'-sigs-p-θ←[S↦status] | yes refl
rewrite Env.sig-single-←-←-overwrite θ (S'' ₛ) Signal.unknown Signal.absent
| Env.sig-single-←-←-overwrite θ (S'' ₛ) status Signal.absent
= S'∈canθ'-sigs-p-θ←[S↦status]
canθ'ₛ-add-sig-monotonic (just Signal.unknown ∷ sigs) S'' κ θ S status
κ-add-sig-monotonic S' S'∈canθ'-sigs-p-θ←[S↦status] | yes refl
with any (_≟_ S'') (proj₁ (Canθ' sigs (suc S'') κ ((θ ← [S]-env (S'' ₛ)) ← [S]-env (S'' ₛ))))
| any (_≟_ S'') (proj₁ (Canθ' sigs (suc S'') κ ((θ ← [ (S'' ₛ) ↦ status ]) ← [S]-env (S'' ₛ))))
... | yes S''∈canθ'-sigs-κ-θ←[S''↦unknown]←[S''] | yes S''∈canθ'-sigs-κ-θ←[S''↦status]←[S'']
rewrite Env.sig-single-←-←-overwrite θ (S'' ₛ) Signal.unknown Signal.unknown
| Env.sig-single-←-←-overwrite θ (S'' ₛ) status Signal.unknown
= S'∈canθ'-sigs-p-θ←[S↦status]
... | no S''∉canθ'-sigs-κ-θ←[S''↦unknown]←[S''] | no S''∉canθ'-sigs-κ-θ←[S''↦status]←[S'']
rewrite Env.sig-single-←-←-overwrite θ (S'' ₛ) Signal.unknown Signal.absent
| Env.sig-single-←-←-overwrite θ (S'' ₛ) status Signal.absent
= S'∈canθ'-sigs-p-θ←[S↦status]
... | yes S''∈canθ'-sigs-κ-θ←[S''↦unknown]←[S''] | no S''∉canθ'-sigs-κ-θ←[S''↦status]←[S'']
rewrite Env.sig-single-←-←-overwrite θ (S'' ₛ) Signal.unknown Signal.unknown
| Env.sig-single-←-←-overwrite θ (S'' ₛ) status Signal.unknown
= ⊥-elim (S''∉canθ'-sigs-κ-θ←[S''↦status]←[S'']
S''∈canθ'-sigs-κ-θ←[S''↦unknown]←[S''])
... | no S''∉canθ'-sigs-κ-θ←[S''↦unknown]←[S''] | yes S''∈canθ'-sigs-κ-θ←[S''↦status]←[S'']
rewrite Env.sig-single-←-←-overwrite θ (S'' ₛ) Signal.unknown Signal.unknown
| Env.sig-single-←-←-overwrite θ (S'' ₛ) status Signal.unknown
= ⊥-elim (S''∉canθ'-sigs-κ-θ←[S''↦unknown]←[S'']
S''∈canθ'-sigs-κ-θ←[S''↦status]←[S''])
canθ'ₛ-add-sig-monotonic (just Signal.present ∷ sigs) S'' κ θ S status
κ-add-sig-monotonic S' S'∈canθ'-sigs-p-θ←[S↦status] | no S≢S''
rewrite Env.←-assoc-comm θ ([S]-env S) ([S]-env-present (S'' ₛ))
(Env.sig-single-noteq-distinct S Signal.unknown
(S'' ₛ) Signal.present S≢S'')
= canθ'ₛ-add-sig-monotonic sigs (suc S'') κ
(θ ← [S]-env-present (S'' ₛ)) S status κ-add-sig-monotonic S'
(subst (S' ∈_)
(cong (proj₁ ∘ Canθ' sigs (suc S'') κ)
(Env.←-assoc-comm θ [ S ↦ status ] ([S]-env-present (S'' ₛ))
(Env.sig-single-noteq-distinct S status
(S'' ₛ) Signal.present S≢S'')))
S'∈canθ'-sigs-p-θ←[S↦status])
canθ'ₛ-add-sig-monotonic (just Signal.absent ∷ sigs) S'' κ θ S status
κ-add-sig-monotonic S' S'∈canθ'-sigs-p-θ←[S↦status] | no S≢S''
rewrite Env.←-assoc-comm θ ([S]-env S) ([S]-env-absent (S'' ₛ))
(Env.sig-single-noteq-distinct S Signal.unknown
(S'' ₛ) Signal.absent S≢S'')
= canθ'ₛ-add-sig-monotonic sigs (suc S'') κ
(θ ← [S]-env-absent (S'' ₛ)) S status κ-add-sig-monotonic S'
(subst (S' ∈_)
(cong (proj₁ ∘ Canθ' sigs (suc S'') κ)
(Env.←-assoc-comm θ [ S ↦ status ] ([S]-env-absent (S'' ₛ))
(Env.sig-single-noteq-distinct S status
(S'' ₛ) Signal.absent S≢S'')))
S'∈canθ'-sigs-p-θ←[S↦status])
canθ'ₛ-add-sig-monotonic (just Signal.unknown ∷ sigs) S'' κ θ S status
κ-add-sig-monotonic S' S'∈canθ'-sigs-p-θ←[S↦status] | no S≢S''
with any (_≟_ S'') (proj₁ (Canθ' sigs (suc S'') κ ((θ ← [S]-env S) ← [S]-env (S'' ₛ))))
| any (_≟_ S'') (proj₁ (Canθ' sigs (suc S'') κ ((θ ← [ S ↦ status ]) ← [S]-env (S'' ₛ))))
... | yes S''∈canθ'-sigs-κ-θ←[S↦unknown]←[S''] | yes S''∈canθ'-sigs-κ-θ←[S↦status]←[S'']
rewrite Env.←-assoc-comm θ ([S]-env S) ([S]-env (S'' ₛ))
(Env.sig-single-noteq-distinct S Signal.unknown
(S'' ₛ) Signal.unknown S≢S'')
= canθ'ₛ-add-sig-monotonic sigs (suc S'') κ
(θ ← [S]-env (S'' ₛ)) S status κ-add-sig-monotonic S'
(subst (S' ∈_)
(cong (proj₁ ∘ Canθ' sigs (suc S'') κ)
(Env.←-assoc-comm θ [ S ↦ status ] ([S]-env (S'' ₛ))
(Env.sig-single-noteq-distinct S status
(S'' ₛ) Signal.unknown S≢S'')))
S'∈canθ'-sigs-p-θ←[S↦status])
... | no S''∉canθ'-sigs-κ-θ←[S↦unknown]←[S''] | no S''∉canθ'-sigs-κ-θ←[S↦status]←[S'']
rewrite Env.←-assoc-comm θ ([S]-env S) ([S]-env-absent (S'' ₛ))
(Env.sig-single-noteq-distinct S Signal.unknown
(S'' ₛ) Signal.absent S≢S'')
= canθ'ₛ-add-sig-monotonic sigs (suc S'') κ
(θ ← [S]-env-absent (S'' ₛ)) S status κ-add-sig-monotonic S'
(subst (S' ∈_)
(cong (proj₁ ∘ Canθ' sigs (suc S'') κ)
(Env.←-assoc-comm θ [ S ↦ status ] ([S]-env-absent (S'' ₛ))
(Env.sig-single-noteq-distinct S status
(S'' ₛ) Signal.absent S≢S'')))
S'∈canθ'-sigs-p-θ←[S↦status])
... | yes S''∈canθ'-sigs-κ-θ←[S↦unknown]←[S''] | no S''∉canθ'-sigs-κ-θ←[S↦status]←[S'']
rewrite Env.←-assoc-comm θ ([S]-env S) ([S]-env (S'' ₛ))
(Env.sig-single-noteq-distinct S Signal.unknown
(S'' ₛ) Signal.unknown S≢S'')
= canθ'ₛ-add-sig-monotonic sigs (suc S'') κ (θ ← [S]-env (S'' ₛ))
S status κ-add-sig-monotonic S'
(subst (S' ∈_)
(cong (proj₁ ∘ Canθ' sigs (suc S'') κ)
(Env.←-assoc-comm θ [ S ↦ status ] ([S]-env (S'' ₛ))
(Env.sig-single-noteq-distinct S status
(S'' ₛ) Signal.unknown S≢S'')))
(canθ'ₛ-add-sig-monotonic sigs (suc S'') κ (θ ← [ S ↦ status ])
(S'' ₛ) Signal.absent κ-add-sig-monotonic
S' S'∈canθ'-sigs-p-θ←[S↦status]))
... | no S''∉canθ'-sigs-κ-θ←[S↦unknown]←[S''] | yes S''∈canθ'-sigs-κ-θ←[S↦status]←[S'']
rewrite Env.←-assoc-comm θ ([S]-env S) ([S]-env (S'' ₛ))
(Env.sig-single-noteq-distinct S Signal.unknown
(S'' ₛ) Signal.unknown S≢S'')
= ⊥-elim
(S''∉canθ'-sigs-κ-θ←[S↦unknown]←[S'']
(canθ'ₛ-add-sig-monotonic sigs (suc S'') κ (θ ← [S]-env (S'' ₛ)) S
status κ-add-sig-monotonic S''
(subst (S'' ∈_)
(cong (proj₁ ∘ Canθ' sigs (suc S'') κ)
(Env.←-assoc-comm θ [ S ↦ status ] ([S]-env (S'' ₛ))
(Env.sig-single-noteq-distinct S status
(S'' ₛ) Signal.unknown S≢S'')))
S''∈canθ'-sigs-κ-θ←[S↦status]←[S''])))
canθ'ₛ-canθ-add-sig-monotonic : ∀ sigs S sigs' S' p θ S''' status →
∀ S'' →
S'' ∈ proj₁ (Canθ' sigs S (Canθ sigs' S' p)
(θ ← Θ SigMap.[ S''' ↦ status ] ShrMap.empty VarMap.empty)) →
S'' ∈ proj₁ (Canθ' sigs S (Canθ sigs' S' p)
(θ ← [S]-env S'''))
canθ'ₛ-canθ-add-sig-monotonic sigs S sigs' S' p θ S''' status
S'' S''∈canθ'-sigs-p-θ←[S↦status] =
canθ'ₛ-add-sig-monotonic sigs S (Canθ sigs' S' p) θ S''' status
(canθₛ-add-sig-monotonic sigs' S' p)
S'' S''∈canθ'-sigs-p-θ←[S↦status]
canθ'ₛ-subset-lemma : ∀ sigs S'' κ κ' θ →
(∀ θ' S → S ∈ proj₁ (κ θ') → S ∈ proj₁ (κ' θ')) →
(∀ θ S status S' →
S' ∈ proj₁ (κ' (θ ← Θ SigMap.[ S ↦ status ] ShrMap.empty VarMap.empty)) →
S' ∈ proj₁ (κ' (θ ← [S]-env S))) →
∀ S → S ∈ proj₁ (Canθ' sigs S'' κ θ) → S ∈ proj₁ (Canθ' sigs S'' κ' θ)
canθ'ₛ-subset-lemma [] S'' κ κ' θ κ⊆κ' κ'-add-sig-monotonic S S∈canθ'-κ-θ =
κ⊆κ' θ S S∈canθ'-κ-θ
canθ'ₛ-subset-lemma (nothing ∷ sigs) S'' κ κ' θ
κ⊆κ' κ'-add-sig-monotonic S S∈canθ'-κ-θ =
canθ'ₛ-subset-lemma sigs (suc S'') κ κ' θ κ⊆κ' κ'-add-sig-monotonic S S∈canθ'-κ-θ
canθ'ₛ-subset-lemma (just Signal.present ∷ sigs) S'' κ κ' θ
κ⊆κ' κ'-add-sig-monotonic S S∈canθ'-κ-θ =
canθ'ₛ-subset-lemma sigs (suc S'') κ κ' (θ ← [S]-env-present (S'' ₛ))
κ⊆κ' κ'-add-sig-monotonic S S∈canθ'-κ-θ
canθ'ₛ-subset-lemma (just Signal.absent ∷ sigs) S'' κ κ' θ
κ⊆κ' κ'-add-sig-monotonic S S∈canθ'-κ-θ =
canθ'ₛ-subset-lemma sigs (suc S'') κ κ' (θ ← [S]-env-absent (S'' ₛ)) κ⊆κ' κ'-add-sig-monotonic S S∈canθ'-κ-θ
canθ'ₛ-subset-lemma (just Signal.unknown ∷ sigs) S'' κ κ' θ
κ⊆κ' κ'-add-sig-monotonic S S∈canθ'-κ-θ
with any (_≟_ S'') (proj₁ (Canθ' sigs (suc S'') κ (θ ← [S]-env (S'' ₛ))))
| any (_≟_ S'') (proj₁ (Canθ' sigs (suc S'') κ' (θ ← [S]-env (S'' ₛ))))
... | yes S''∈canθ'-κ-θ' | yes S''∈canθ-κ'-θ' =
canθ'ₛ-subset-lemma sigs (suc S'') κ κ' (θ ← [S]-env (S'' ₛ))
κ⊆κ' κ'-add-sig-monotonic S S∈canθ'-κ-θ
... | no S''∉canθ'-κ-θ' | no S''∉canθ-q-θ' =
canθ'ₛ-subset-lemma sigs (suc S'') κ κ' (θ ← [S]-env-absent (S'' ₛ))
κ⊆κ' κ'-add-sig-monotonic S S∈canθ'-κ-θ
... | yes S''∈canθ'-κ-θ' | no S''∉canθ-q-θ' =
⊥-elim
(S''∉canθ-q-θ'
(canθ'ₛ-subset-lemma sigs (suc S'') κ κ' (θ ← [S]-env (S'' ₛ)) κ⊆κ'
κ'-add-sig-monotonic S'' S''∈canθ'-κ-θ'))
... | no S''∉canθ'-κ-θ' | yes S''∈canθ-κ'-θ' =
canθ'ₛ-add-sig-monotonic sigs (suc S'') κ' θ (S'' ₛ) Signal.absent
κ'-add-sig-monotonic S
(canθ'ₛ-subset-lemma sigs (suc S'') κ κ' (θ ← [S]-env-absent (S'' ₛ)) κ⊆κ'
κ'-add-sig-monotonic S S∈canθ'-κ-θ)
canθ'-inner-shadowing-irr' : ∀ sigs S'' sigs' p S status θ θo →
S ∈ SigMap.keys sigs' →
Canθ' sigs S'' (Canθ sigs' 0 p) ((θ ← [ (S ₛ) ↦ status ]) ← θo) ≡
Canθ' sigs S'' (Canθ sigs' 0 p) (θ ← θo)
canθ'-inner-shadowing-irr' [] S'' sigs' p S status θ θo S∈sigs'
rewrite sym (map-id (SigMap.keys sigs'))
= canθ-shadowing-irr' sigs' 0 p S status θ θo S∈sigs'
canθ'-inner-shadowing-irr' (nothing ∷ sigs) S'' sigs' p S status θ θo S∈sigs' = canθ'-inner-shadowing-irr' sigs (suc S'') sigs' p S status θ θo S∈sigs'
canθ'-inner-shadowing-irr' (just Signal.present ∷ sigs) S'' sigs' p S status θ θo S∈sigs'
rewrite sym (Env.←-assoc (θ ← [ (S ₛ) ↦ status ]) θo ([S]-env-present (S'' ₛ)))
| sym (Env.←-assoc θ θo ([S]-env-present (S'' ₛ)))
= canθ'-inner-shadowing-irr' sigs (suc S'') sigs' p S status θ (θo ← ([S]-env-present (S'' ₛ))) S∈sigs'
canθ'-inner-shadowing-irr' (just Signal.absent ∷ sigs) S'' sigs' p S status θ θo S∈sigs'
rewrite sym (Env.←-assoc (θ ← [ (S ₛ) ↦ status ]) θo ([S]-env-absent (S'' ₛ)))
| sym (Env.←-assoc θ θo ([S]-env-absent (S'' ₛ)))
= canθ'-inner-shadowing-irr' sigs (suc S'') sigs' p S status θ (θo ← ([S]-env-absent (S'' ₛ))) S∈sigs'
canθ'-inner-shadowing-irr' (just Signal.unknown ∷ sigs) S'' sigs' p S status θ θo S∈sigs'
with any (_≟_ S'') (proj₁ (Canθ' sigs (suc S'') (Canθ sigs' 0 p) (((θ ← [ (S ₛ) ↦ status ]) ← θo) ← [S]-env (S'' ₛ))))
| any (_≟_ S'') (proj₁ (Canθ' sigs (suc S'') (Canθ sigs' 0 p) ((θ ← θo) ← [S]-env (S'' ₛ))))
... | yes S''∈canθ'-sigs-Canθ-θ←[S]-absent←S←θo←[S''] | yes S''∈canθ'-sigs-Canθ-θ←[S]←S←θo←[S'']
rewrite sym (Env.←-assoc (θ ← [ (S ₛ) ↦ status ]) θo ([S]-env (S'' ₛ)))
| sym (Env.←-assoc θ θo ([S]-env (S'' ₛ)))
= canθ'-inner-shadowing-irr' sigs (suc S'') sigs' p S status θ (θo ← ([S]-env (S'' ₛ))) S∈sigs'
... | no S''∉canθ'-sigs-Canθ-θ←[S]-absent←S←θo←[S''] | no S''∉canθ'-sigs-Canθ-θ←[S]←S←θo←[S'']
rewrite sym (Env.←-assoc (θ ← [ (S ₛ) ↦ status ]) θo ([S]-env-absent (S'' ₛ)))
| sym (Env.←-assoc θ θo ([S]-env-absent (S'' ₛ)))
= canθ'-inner-shadowing-irr' sigs (suc S'') sigs' p S status θ (θo ← ([S]-env-absent (S'' ₛ))) S∈sigs'
... | yes S''∈canθ'-sigs-Canθ-θ←[S]-absent←S←θo←[S''] | no S''∉canθ'-sigs-Canθ-θ←[S]←S←θo←[S'']
rewrite sym (Env.←-assoc (θ ← [ (S ₛ) ↦ status ]) θo ([S]-env (S'' ₛ)))
| sym (Env.←-assoc θ θo ([S]-env (S'' ₛ)))
| canθ'-inner-shadowing-irr' sigs (suc S'') sigs' p S status θ (θo ← ([S]-env (S'' ₛ))) S∈sigs'
= ⊥-elim (S''∉canθ'-sigs-Canθ-θ←[S]←S←θo←[S'']
S''∈canθ'-sigs-Canθ-θ←[S]-absent←S←θo←[S''])
... | no S''∉canθ'-sigs-Canθ-θ←[S]-absent←S←θo←[S''] | yes S''∈canθ'-sigs-Canθ-θ←[S]←S←θo←[S'']
rewrite sym (Env.←-assoc (θ ← [ (S ₛ) ↦ status ]) θo ([S]-env (S'' ₛ)))
| sym (Env.←-assoc θ θo ([S]-env (S'' ₛ)))
| canθ'-inner-shadowing-irr' sigs (suc S'') sigs' p S status θ (θo ← ([S]-env (S'' ₛ))) S∈sigs'
= ⊥-elim (S''∉canθ'-sigs-Canθ-θ←[S]-absent←S←θo←[S'']
S''∈canθ'-sigs-Canθ-θ←[S]←S←θo←[S''])
canθ'-inner-shadowing-irr : ∀ sigs S'' sigs' p S status θ →
S ∈ SigMap.keys sigs' →
Canθ' sigs S'' (Canθ sigs' 0 p) (θ ← [ (S ₛ) ↦ status ]) ≡
Canθ' sigs S'' (Canθ sigs' 0 p) θ
canθ'-inner-shadowing-irr sigs S'' sigs' p S status θ S∈sigs'
rewrite cong (Canθ' sigs S'' (Canθ sigs' 0 p))
(Env.←-comm Env.[]env θ distinct-empty-left)
| cong (Canθ' sigs S'' (Canθ sigs' 0 p))
(Env.←-comm Env.[]env (θ ← [ (S ₛ) ↦ status ]) distinct-empty-left)
= canθ'-inner-shadowing-irr' sigs S'' sigs' p S status θ Env.[]env S∈sigs'
canθ'-search-acc : ∀ sigs S κ θ →
∀ S'' status →
S'' ∉ map (_+_ S) (SigMap.keys sigs) →
Canθ' sigs S κ (θ ← [ (S'' ₛ) ↦ status ]) ≡
Canθ' sigs S (κ ∘ (_← [ (S'' ₛ) ↦ status ])) θ
canθ'-search-acc [] S κ θ S'' status S''∉map-+-S-sigs =
refl
canθ'-search-acc (nothing ∷ sigs) S κ θ S'' status S''∉map-+-S-sigs
rewrite map-+-compose-suc S (SigMap.keys sigs)
= canθ'-search-acc sigs (suc S) κ θ S'' status S''∉map-+-S-sigs
canθ'-search-acc (just Signal.present ∷ sigs) S κ θ S'' status S''∉map-+-S-sigs
rewrite map-+-compose-suc S (SigMap.keys sigs)
| +-comm S 0
| Env.←-assoc-comm θ [ (S'' ₛ) ↦ status ] ([S]-env-present (S ₛ))
(Env.sig-single-noteq-distinct (S'' ₛ) status (S ₛ) Signal.present (S''∉map-+-S-sigs ∘ here))
= canθ'-search-acc sigs (suc S) κ (θ ← [S]-env-present (S ₛ)) S'' status
(S''∉map-+-S-sigs ∘ there)
canθ'-search-acc (just Signal.absent ∷ sigs) S κ θ S'' status S''∉map-+-S-sigs
rewrite map-+-compose-suc S (SigMap.keys sigs)
| +-comm S 0
| Env.←-assoc-comm θ [ (S'' ₛ) ↦ status ] ([S]-env-absent (S ₛ))
(Env.sig-single-noteq-distinct (S'' ₛ) status (S ₛ) Signal.absent (S''∉map-+-S-sigs ∘ here))
= canθ'-search-acc sigs (suc S) κ (θ ← [S]-env-absent (S ₛ)) S'' status
(S''∉map-+-S-sigs ∘ there)
canθ'-search-acc (just Signal.unknown ∷ sigs) S κ θ S'' status S''∉map-+-S-sigs
with any (_≟_ S) (proj₁ (Canθ' sigs (suc S) (λ θ* → κ (θ* ← [ (S'' ₛ) ↦ status ])) (θ ← [S]-env (S ₛ))))
| any (_≟_ S) (proj₁ (Canθ' sigs (suc S) κ ((θ ← [ (S'' ₛ) ↦ status ]) ← [S]-env (S ₛ))))
... | yes S∈canθ'-⟨canθ-←[S'']⟩-θ←[S] | yes S∈canθ'-canθ-θ←[S'']←[S]
rewrite map-+-compose-suc S (SigMap.keys sigs)
| +-comm S 0
| Env.←-assoc-comm θ [ (S'' ₛ) ↦ status ] ([S]-env (S ₛ))
(Env.sig-single-noteq-distinct (S'' ₛ) status (S ₛ) Signal.unknown (S''∉map-+-S-sigs ∘ here))
= canθ'-search-acc sigs (suc S) κ (θ ← [S]-env (S ₛ)) S'' status
(S''∉map-+-S-sigs ∘ there)
... | no S∉canθ'-⟨canθ-←[S'']⟩-θ←[S] | no S∉canθ'-canθ-θ←[S'']←[S]
rewrite map-+-compose-suc S (SigMap.keys sigs)
| +-comm S 0
| Env.←-assoc-comm θ [ (S'' ₛ) ↦ status ] ([S]-env-absent (S ₛ))
(Env.sig-single-noteq-distinct (S'' ₛ) status (S ₛ) Signal.absent (S''∉map-+-S-sigs ∘ here))
= canθ'-search-acc sigs (suc S) κ (θ ← [S]-env-absent (S ₛ)) S'' status
(S''∉map-+-S-sigs ∘ there)
... | yes S∈canθ'-⟨canθ-←[S'']⟩-θ←[S] | no S∉canθ'-canθ-θ←[S'']←[S]
rewrite map-+-compose-suc S (SigMap.keys sigs)
| +-comm S 0
| Env.←-assoc-comm θ [ (S'' ₛ) ↦ status ] ([S]-env (S ₛ))
(Env.sig-single-noteq-distinct (S'' ₛ) status (S ₛ) Signal.unknown (S''∉map-+-S-sigs ∘ here))
| canθ'-search-acc sigs (suc S) κ (θ ← [S]-env (S ₛ)) S'' status
(S''∉map-+-S-sigs ∘ there)
= ⊥-elim (S∉canθ'-canθ-θ←[S'']←[S] S∈canθ'-⟨canθ-←[S'']⟩-θ←[S])
... | no S∉canθ'-⟨canθ-←[S'']⟩-θ←[S] | yes S∈canθ'-canθ-θ←[S'']←[S]
rewrite map-+-compose-suc S (SigMap.keys sigs)
| +-comm S 0
| Env.←-assoc-comm θ [ (S'' ₛ) ↦ status ] ([S]-env (S ₛ))
(Env.sig-single-noteq-distinct (S'' ₛ) status (S ₛ) Signal.unknown (S''∉map-+-S-sigs ∘ here))
| canθ'-search-acc sigs (suc S) κ (θ ← [S]-env (S ₛ)) S'' status
(S''∉map-+-S-sigs ∘ there)
= ⊥-elim (S∉canθ'-⟨canθ-←[S'']⟩-θ←[S] S∈canθ'-canθ-θ←[S'']←[S])
canθ'-search-acc-set-irr : ∀ sigs S κ θ →
∀ S'' status status' →
S'' ∉ map (_+_ S) (SigMap.keys sigs) →
Canθ' sigs S κ (θ ← [ (S'' ₛ) ↦ status ]) ≡
Canθ' sigs S (κ ∘ (_← [ (S'' ₛ) ↦ status ])) (θ ← [ (S'' ₛ) ↦ status' ])
canθ'-search-acc-set-irr [] S κ θ S'' status status' S''∉map-+-S-sigs
rewrite sym (Env.←-assoc θ [ (S'' ₛ) ↦ status' ] [ (S'' ₛ) ↦ status ])
| cong (θ ←_) (Env.←-single-overwrite-sig (S'' ₛ) status' [ (S'' ₛ) ↦ status ]
(Env.sig-∈-single (S'' ₛ) status))
= refl
canθ'-search-acc-set-irr (nothing ∷ sigs) S κ θ S'' status status' S''∉map-+-S-sigs
rewrite map-+-compose-suc S (SigMap.keys sigs)
= canθ'-search-acc-set-irr sigs (suc S) κ θ S'' status status' S''∉map-+-S-sigs
canθ'-search-acc-set-irr (just Signal.present ∷ sigs) S κ θ S'' status status' S''∉map-+-S-sigs
rewrite map-+-compose-suc S (SigMap.keys sigs)
| +-comm S 0
| Env.←-assoc-comm θ [ (S'' ₛ) ↦ status ] ([S]-env-present (S ₛ))
(Env.sig-single-noteq-distinct (S'' ₛ) status (S ₛ) Signal.present (S''∉map-+-S-sigs ∘ here))
| Env.←-assoc-comm θ [ (S'' ₛ) ↦ status' ] ([S]-env-present (S ₛ))
(Env.sig-single-noteq-distinct (S'' ₛ) status' (S ₛ) Signal.present (S''∉map-+-S-sigs ∘ here))
= canθ'-search-acc-set-irr sigs (suc S) κ (θ ← [S]-env-present (S ₛ)) S'' status status'
(S''∉map-+-S-sigs ∘ there)
canθ'-search-acc-set-irr (just Signal.absent ∷ sigs) S κ θ S'' status status' S''∉map-+-S-sigs
rewrite map-+-compose-suc S (SigMap.keys sigs)
| +-comm S 0
| Env.←-assoc-comm θ [ (S'' ₛ) ↦ status ] ([S]-env-absent (S ₛ))
(Env.sig-single-noteq-distinct (S'' ₛ) status (S ₛ) Signal.absent (S''∉map-+-S-sigs ∘ here))
| Env.←-assoc-comm θ [ (S'' ₛ) ↦ status' ] ([S]-env-absent (S ₛ))
(Env.sig-single-noteq-distinct (S'' ₛ) status' (S ₛ) Signal.absent (S''∉map-+-S-sigs ∘ here))
= canθ'-search-acc-set-irr sigs (suc S) κ (θ ← [S]-env-absent (S ₛ)) S'' status status'
(S''∉map-+-S-sigs ∘ there)
canθ'-search-acc-set-irr (just Signal.unknown ∷ sigs) S κ θ S'' status status' S''∉map-+-S-sigs
with any (_≟_ S) (proj₁ (Canθ' sigs (suc S) (λ θ* → κ (θ* ← [ (S'' ₛ) ↦ status ])) ((θ ← [ (S'' ₛ) ↦ status' ]) ← [S]-env (S ₛ))))
| any (_≟_ S) (proj₁ (Canθ' sigs (suc S) κ ((θ ← [ (S'' ₛ) ↦ status ]) ← [S]-env (S ₛ))))
... | yes S∈canθ'-⟨canθ-←[S'']⟩-θ←[S'']←[S] | yes S∈canθ'-canθ-θ←[S'']←[S]
rewrite map-+-compose-suc S (SigMap.keys sigs)
| +-comm S 0
| Env.←-assoc-comm θ [ (S'' ₛ) ↦ status ] ([S]-env (S ₛ))
(Env.sig-single-noteq-distinct (S'' ₛ) status (S ₛ) Signal.unknown (S''∉map-+-S-sigs ∘ here))
| Env.←-assoc-comm θ [ (S'' ₛ) ↦ status' ] ([S]-env (S ₛ))
(Env.sig-single-noteq-distinct (S'' ₛ) status' (S ₛ) Signal.unknown (S''∉map-+-S-sigs ∘ here))
= canθ'-search-acc-set-irr sigs (suc S) κ (θ ← [S]-env (S ₛ)) S'' status status'
(S''∉map-+-S-sigs ∘ there)
... | no S∉canθ'-⟨canθ-←[S'']⟩-θ←[S'']←[S] | no S∉canθ'-canθ-θ←[S'']←[S]
rewrite map-+-compose-suc S (SigMap.keys sigs)
| +-comm S 0
| Env.←-assoc-comm θ [ (S'' ₛ) ↦ status ] ([S]-env-absent (S ₛ))
(Env.sig-single-noteq-distinct (S'' ₛ) status (S ₛ) Signal.absent (S''∉map-+-S-sigs ∘ here))
| Env.←-assoc-comm θ [ (S'' ₛ) ↦ status' ] ([S]-env-absent (S ₛ))
(Env.sig-single-noteq-distinct (S'' ₛ) status' (S ₛ) Signal.absent (S''∉map-+-S-sigs ∘ here))
= canθ'-search-acc-set-irr sigs (suc S) κ (θ ← [S]-env-absent (S ₛ)) S'' status status'
(S''∉map-+-S-sigs ∘ there)
... | yes S∈canθ'-⟨canθ-←[S'']⟩-θ←[S'']←[S] | no S∉canθ'-canθ-θ←[S'']←[S]
rewrite map-+-compose-suc S (SigMap.keys sigs)
| +-comm S 0
| Env.←-assoc-comm θ [ (S'' ₛ) ↦ status ] ([S]-env (S ₛ))
(Env.sig-single-noteq-distinct (S'' ₛ) status (S ₛ) Signal.unknown (S''∉map-+-S-sigs ∘ here))
| Env.←-assoc-comm θ [ (S'' ₛ) ↦ status' ] ([S]-env (S ₛ))
(Env.sig-single-noteq-distinct (S'' ₛ) status' (S ₛ) Signal.unknown (S''∉map-+-S-sigs ∘ here))
| canθ'-search-acc-set-irr sigs (suc S) κ (θ ← [S]-env (S ₛ)) S'' status status'
(S''∉map-+-S-sigs ∘ there)
= ⊥-elim (S∉canθ'-canθ-θ←[S'']←[S] S∈canθ'-⟨canθ-←[S'']⟩-θ←[S'']←[S])
... | no S∉canθ'-⟨canθ-←[S'']⟩-θ←[S'']←[S] | yes S∈canθ'-canθ-θ←[S'']←[S]
rewrite map-+-compose-suc S (SigMap.keys sigs)
| +-comm S 0
| Env.←-assoc-comm θ [ (S'' ₛ) ↦ status ] ([S]-env (S ₛ))
(Env.sig-single-noteq-distinct (S'' ₛ) status (S ₛ) Signal.unknown (S''∉map-+-S-sigs ∘ here))
| Env.←-assoc-comm θ [ (S'' ₛ) ↦ status' ] ([S]-env (S ₛ))
(Env.sig-single-noteq-distinct (S'' ₛ) status' (S ₛ) Signal.unknown (S''∉map-+-S-sigs ∘ here))
| canθ'-search-acc-set-irr sigs (suc S) κ (θ ← [S]-env (S ₛ)) S'' status status'
(S''∉map-+-S-sigs ∘ there)
= ⊥-elim (S∉canθ'-⟨canθ-←[S'']⟩-θ←[S'']←[S] S∈canθ'-canθ-θ←[S'']←[S])
canθ'-canθ-propagate-up-in : ∀ sigs S r θ →
∀ sigs' S' S'' →
S' ∈ proj₁ (Canθ' sigs S (λ θ* → Canθ sigs' (suc S') r (θ* ← [S]-env (S' ₛ))) θ) →
S'' ∈ proj₁ (Canθ' sigs S (λ θ* → Canθ sigs' (suc S') r (θ* ← [S]-env (S' ₛ))) θ) →
S'' ∈ proj₁ (Canθ' sigs S (λ θ* → Canθ (just Signal.unknown ∷ sigs') S' r θ*) θ)
canθ'-canθ-propagate-up-in [] S r θ sigs' S' S'' S'∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩ S''∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩
with any (_≟_ S') (Canθₛ sigs' (suc S') r (θ ← [S]-env (S' ₛ)))
... | yes S'∈canθ-sigs'-r-θ*←[S'] =
S''∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩
... | no S'∉canθ-sigs'-r-θ*←[S'] =
⊥-elim (S'∉canθ-sigs'-r-θ*←[S'] S'∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩)
canθ'-canθ-propagate-up-in (nothing ∷ sigs) S r θ sigs' S' S'' S'∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩ S''∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩ =
canθ'-canθ-propagate-up-in sigs (suc S) r θ sigs' S' S'' S'∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩ S''∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩
canθ'-canθ-propagate-up-in (just Signal.present ∷ sigs) S r θ sigs' S' S'' S'∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩ S''∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩ =
canθ'-canθ-propagate-up-in sigs (suc S) r (θ ← [S]-env-present (S ₛ)) sigs' S' S'' S'∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩ S''∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩
canθ'-canθ-propagate-up-in (just Signal.absent ∷ sigs) S r θ sigs' S' S'' S'∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩ S''∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩ =
canθ'-canθ-propagate-up-in sigs (suc S) r (θ ← [S]-env-absent (S ₛ)) sigs' S' S'' S'∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩ S''∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩
canθ'-canθ-propagate-up-in (just Signal.unknown ∷ sigs) S r θ sigs' S' S'' S'∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩ S''∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩
with any (_≟_ S)
(proj₁
(Canθ' sigs (suc S) (Canθ (just Signal.unknown ∷ sigs') S' r) (θ ← [S]-env (S ₛ))))
| any (_≟_ S)
(proj₁
(Canθ' sigs (suc S) (λ θ* → Canθ sigs' (suc S') r (θ* ← [S]-env (S' ₛ))) (θ ← [S]-env (S ₛ))))
... | yes S∈canθ'-sigs-⟨canθ-u∷sigs'-r⟩-θ←[S] | yes S∈canθ'-sigs-⟨canθ-sigs'-θ*←[S']⟩-θ←[S] =
canθ'-canθ-propagate-up-in sigs (suc S) r (θ ← [S]-env (S ₛ)) sigs' S' S'' S'∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩ S''∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩
... | no S∉canθ'-sigs-⟨canθ-u∷sigs'-r⟩-θ←[S] | no S∉canθ'-sigs-⟨canθ-sigs'-θ*←[S']⟩-θ←[S] =
canθ'-canθ-propagate-up-in sigs (suc S) r (θ ← [S]-env-absent (S ₛ)) sigs' S' S'' S'∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩ S''∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩
... | yes S∈canθ'-sigs-⟨canθ-u∷sigs'-r⟩-θ←[S] | no S∉canθ'-sigs-⟨canθ-sigs'-θ*←[S']⟩-θ←[S] =
canθ'ₛ-canθ-add-sig-monotonic sigs (suc S) (just Signal.unknown ∷ sigs') S' r θ
(S ₛ) Signal.absent S''
(canθ'-canθ-propagate-up-in sigs (suc S) r (θ ← [S]-env-absent (S ₛ)) sigs' S' S''
S'∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩
S''∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩)
... | no S∉canθ'-sigs-⟨canθ-u∷sigs'-r⟩-θ←[S] | yes S∈canθ'-sigs-⟨canθ-sigs'-θ*←[S']⟩-θ←[S] =
⊥-elim
(S∉canθ'-sigs-⟨canθ-u∷sigs'-r⟩-θ←[S]
(canθ'-canθ-propagate-up-in sigs (suc S) r (θ ← [S]-env (S ₛ)) sigs' S' S
S'∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩
S∈canθ'-sigs-⟨canθ-sigs'-θ*←[S']⟩-θ←[S]))
canθₛ-a∷s⊆canθₛ-u∷s : ∀ sigs r S' θ S →
S ∈ Canθₛ (just Signal.absent ∷ sigs) S' r θ →
S ∈ Canθₛ (just Signal.unknown ∷ sigs) S' r θ
canθₛ-a∷s⊆canθₛ-u∷s sigs r S' θ S S∈can-sigs-r-θ←[S↦absent]
with any (_≟_ S') (Canθₛ sigs (suc S') r (θ ← [S]-env (S' ₛ)))
... | yes a = canθₛ-add-sig-monotonic sigs (suc S') r θ (S' ₛ) Signal.absent S
S∈can-sigs-r-θ←[S↦absent]
... | no na = S∈can-sigs-r-θ←[S↦absent]
canθ'-canθ-propagate-down-not-in : ∀ sigs S r θ →
∀ S' sigs' →
S' ∉ proj₁ (Canθ' sigs S (λ θ* → Canθ (just Signal.unknown ∷ sigs') S' r θ*) θ) →
Canθ' sigs S (λ θ* → Canθ (just Signal.unknown ∷ sigs') S' r θ*) θ ≡
Canθ' sigs S (λ θ* → Canθ sigs' (suc S') r (θ* ← [S]-env-absent (S' ₛ))) θ
canθ'-canθ-propagate-down-not-in [] S r θ S' sigs' S'∉canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩
with any (_≟_ S') (Canθₛ sigs' (suc S') r (θ ← [S]-env (S' ₛ)))
... | yes S'∈canθ-sigs'-r-θ←[S'] =
⊥-elim (S'∉canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩ S'∈canθ-sigs'-r-θ←[S'])
... | no S'∉canθ-sigs'-r-θ←[S'] = refl
canθ'-canθ-propagate-down-not-in (nothing ∷ sigs) S r θ S' sigs' S'∉canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩ =
canθ'-canθ-propagate-down-not-in sigs (suc S) r θ S' sigs' S'∉canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩
canθ'-canθ-propagate-down-not-in (just Signal.present ∷ sigs) S r θ S' sigs' S'∉canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩ =
canθ'-canθ-propagate-down-not-in sigs (suc S) r (θ ← [S]-env-present (S ₛ)) S' sigs' S'∉canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩
canθ'-canθ-propagate-down-not-in (just Signal.absent ∷ sigs) S r θ S' sigs' S'∉canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩ =
canθ'-canθ-propagate-down-not-in sigs (suc S) r (θ ← [S]-env-absent (S ₛ)) S' sigs' S'∉canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩
canθ'-canθ-propagate-down-not-in (just Signal.unknown ∷ sigs) S r θ S' sigs' S'∉canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩
with any (_≟_ S)
(proj₁
(Canθ' sigs (suc S)
(λ θ* → Canθ (just Signal.unknown ∷ sigs') S' r θ*)
(θ ← [S]-env (S ₛ))))
| any (_≟_ S)
(proj₁
(Canθ' sigs (suc S)
(λ θ* → Canθ sigs' (suc S') r (θ* ← [S]-env-absent (S' ₛ)))
(θ ← [S]-env (S ₛ))))
... | yes a | yes b =
canθ'-canθ-propagate-down-not-in sigs (suc S) r (θ ← [S]-env (S ₛ)) S' sigs' S'∉canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩
... | no na | no nb =
canθ'-canθ-propagate-down-not-in sigs (suc S) r (θ ← [S]-env-absent (S ₛ)) S' sigs' S'∉canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩
... | yes a | no nb
rewrite sym (canθ'-canθ-propagate-down-not-in sigs (suc S) r (θ ← [S]-env (S ₛ)) S' sigs' S'∉canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩)
= ⊥-elim (nb a)
... | no na | yes b
= ⊥-elim (na (canθ'ₛ-subset-lemma sigs (suc S) (Canθ (just Signal.absent ∷ sigs') S' r) (Canθ (just Signal.unknown ∷ sigs') S' r) (θ ← [S]-env (S ₛ)) (canθₛ-a∷s⊆canθₛ-u∷s sigs' r S') (canθₛ-add-sig-monotonic (just Signal.unknown ∷ sigs') S' r) S b))
canθ'-canθ-propagate-down-in : ∀ sigs S r θ →
∀ S' sigs' →
S' ∈ proj₁ (Canθ' sigs S (λ θ* → Canθ (just Signal.unknown ∷ sigs') S' r θ*) θ) →
Canθ' sigs S (λ θ* → Canθ (just Signal.unknown ∷ sigs') S' r θ*) θ ≡
Canθ' sigs S (λ θ* → Canθ sigs' (suc S') r (θ* ← [S]-env (S' ₛ))) θ
canθ'-canθ-propagate-down-in [] S r θ S' sigs' S'∈canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩
with any (_≟_ S') (Canθₛ sigs' (suc S') r (θ ← [S]-env (S' ₛ)))
... | yes S'∈canθ-sigs'-r-θ←[S'] = refl
... | no S'∉canθ-sigs'-r-θ←[S'] =
⊥-elim
(S'∉canθ-sigs'-r-θ←[S']
(canθₛ-add-sig-monotonic sigs' (suc S') r θ (S' ₛ) Signal.absent S'
S'∈canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩))
canθ'-canθ-propagate-down-in (nothing ∷ sigs) S r θ S' sigs' S'∈canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩ =
canθ'-canθ-propagate-down-in sigs (suc S) r θ S' sigs' S'∈canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩
canθ'-canθ-propagate-down-in (just Signal.present ∷ sigs) S r θ S' sigs' S'∈canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩ =
canθ'-canθ-propagate-down-in sigs (suc S) r (θ ← [S]-env-present (S ₛ)) S' sigs' S'∈canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩
canθ'-canθ-propagate-down-in (just Signal.absent ∷ sigs) S r θ S' sigs' S'∈canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩ =
canθ'-canθ-propagate-down-in sigs (suc S) r (θ ← [S]-env-absent (S ₛ)) S' sigs' S'∈canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩
canθ'-canθ-propagate-down-in (just Signal.unknown ∷ sigs) S r θ S' sigs' S'∈canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩
with any (_≟_ S)
(proj₁
(Canθ' sigs (suc S)
(Canθ (just Signal.unknown ∷ sigs') S' r)
(θ ← [S]-env (S ₛ))))
| any (_≟_ S)
(proj₁
(Canθ' sigs (suc S)
(λ θ* → Canθ sigs' (suc S') r (θ* ← [S]-env (S' ₛ)))
(θ ← [S]-env (S ₛ))))
... | yes S∈canθ'-sigs-⟨canθ-u∷sigs'-r⟩-θ←[S] | yes S∈canθ'-sigs-⟨canθ-sigs'-θ*←[S']⟩-θ←[S] =
canθ'-canθ-propagate-down-in sigs (suc S) r (θ ← [S]-env (S ₛ)) S' sigs' S'∈canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩
... | no S∉canθ'-sigs-⟨canθ-u∷sigs'-r⟩-θ←[S] | no S∉canθ'-sigs-⟨canθ-sigs'-θ*←[S']⟩-θ←[S] =
canθ'-canθ-propagate-down-in sigs (suc S) r (θ ← [S]-env-absent (S ₛ)) S' sigs' S'∈canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩
... | yes S∈canθ'-sigs-⟨canθ-u∷sigs'-r⟩-θ←[S] | no S∉canθ'-sigs-⟨canθ-sigs'-θ*←[S']⟩-θ←[S]
= ⊥-elim
(S∉canθ'-sigs-⟨canθ-sigs'-θ*←[S']⟩-θ←[S]
(subst (S ∈_)
(cong proj₁
(canθ'-canθ-propagate-down-in sigs (suc S) r (θ ← [S]-env (S ₛ)) S' sigs'
S'∈canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩))
S∈canθ'-sigs-⟨canθ-u∷sigs'-r⟩-θ←[S]))
... | no S∉canθ'-sigs-⟨canθ-u∷sigs'-r⟩-θ←[S] | yes S∈canθ'-sigs-⟨canθ-sigs'-θ*←[S']⟩-θ←[S]
= ⊥-elim
(S∉canθ'-sigs-⟨canθ-u∷sigs'-r⟩-θ←[S]
(subst (S ∈_)
(cong proj₁
(sym (canθ'-canθ-propagate-down-in sigs (suc S) r (θ ← [S]-env (S ₛ)) S' sigs'
(canθ'ₛ-canθ-add-sig-monotonic sigs (suc S) (just Signal.unknown ∷ sigs') S'
r θ (S ₛ) Signal.absent S'
S'∈canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩))))
S∈canθ'-sigs-⟨canθ-sigs'-θ*←[S']⟩-θ←[S]))
canθ'-canθ-propagate-up-in-set-irr : ∀ sigs S r θ status →
∀ sigs' S' S'' →
S' ∈ proj₁ (Canθ' sigs S (λ θ* → Canθ sigs' (suc S') r (θ* ← [S]-env (S' ₛ))) θ) →
S'' ∈ proj₁ (Canθ' sigs S (λ θ* → Canθ sigs' (suc S') r (θ* ← [S]-env (S' ₛ))) θ) →
S'' ∈ proj₁ (Canθ' sigs S (λ θ* → Canθ (just Signal.unknown ∷ sigs') S' r (θ* ← [ (S' ₛ) ↦ status ])) θ)
canθ'-canθ-propagate-up-in-set-irr [] S r θ status sigs' S' S'' S'∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩ S''∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩
with any (_≟_ S') (Canθₛ sigs' (suc S') r ((θ ← [ (S' ₛ) ↦ status ]) ← [S]-env (S' ₛ)))
... | yes S'∈canθ-sigs'-r-θ*←[S']
rewrite Env.sig-single-←-←-overwrite θ (S' ₛ) status Signal.unknown
= S''∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩
... | no S'∉canθ-sigs'-r-θ*←[S']
rewrite Env.sig-single-←-←-overwrite θ (S' ₛ) status Signal.unknown
= ⊥-elim (S'∉canθ-sigs'-r-θ*←[S'] S'∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩)
canθ'-canθ-propagate-up-in-set-irr (nothing ∷ sigs) S r θ status sigs' S' S'' S'∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩ S''∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩ =
canθ'-canθ-propagate-up-in-set-irr sigs (suc S) r θ status sigs' S' S'' S'∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩ S''∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩
canθ'-canθ-propagate-up-in-set-irr (just Signal.present ∷ sigs) S r θ status sigs' S' S'' S'∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩ S''∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩ =
canθ'-canθ-propagate-up-in-set-irr sigs (suc S) r (θ ← [S]-env-present (S ₛ)) status sigs' S' S'' S'∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩ S''∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩
canθ'-canθ-propagate-up-in-set-irr (just Signal.absent ∷ sigs) S r θ status sigs' S' S'' S'∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩ S''∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩ =
canθ'-canθ-propagate-up-in-set-irr sigs (suc S) r (θ ← [S]-env-absent (S ₛ)) status sigs' S' S'' S'∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩ S''∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩
canθ'-canθ-propagate-up-in-set-irr (just Signal.unknown ∷ sigs) S r θ status sigs' S' S'' S'∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩ S''∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩
with any (_≟_ S)
(proj₁
(Canθ' sigs (suc S) (λ θ* → Canθ (just Signal.unknown ∷ sigs') S' r (θ* ← [ (S' ₛ) ↦ status ])) (θ ← [S]-env (S ₛ))))
| any (_≟_ S)
(proj₁
(Canθ' sigs (suc S) (λ θ* → Canθ sigs' (suc S') r (θ* ← [S]-env (S' ₛ))) (θ ← [S]-env (S ₛ))))
... | yes S∈canθ'-sigs-⟨canθ-u∷sigs'-r⟩-θ←[S] | yes S∈canθ'-sigs-⟨canθ-sigs'-θ*←[S']⟩-θ←[S] =
canθ'-canθ-propagate-up-in-set-irr sigs (suc S) r (θ ← [S]-env (S ₛ)) status sigs' S' S'' S'∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩ S''∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩
... | no S∉canθ'-sigs-⟨canθ-u∷sigs'-r⟩-θ←[S] | no S∉canθ'-sigs-⟨canθ-sigs'-θ*←[S']⟩-θ←[S] =
canθ'-canθ-propagate-up-in-set-irr sigs (suc S) r (θ ← [S]-env-absent (S ₛ)) status sigs' S' S'' S'∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩ S''∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩
... | yes S∈canθ'-sigs-⟨canθ-u∷sigs'-r⟩-θ←[S] | no S∉canθ'-sigs-⟨canθ-sigs'-θ*←[S']⟩-θ←[S]
= canθ'ₛ-add-sig-monotonic sigs (suc S)
(Canθ (just Signal.unknown ∷ sigs') S' r ∘ (_← [ (S' ₛ) ↦ status ]))
θ (S ₛ) Signal.absent
(λ θ* S* status* S'' S''∈ →
canθₛ-cong-←-add-sig-monotonic (just Signal.unknown ∷ sigs') S' r
θ* [ (S' ₛ) ↦ status ] S* status* S'' S''∈) S''
(canθ'-canθ-propagate-up-in-set-irr sigs (suc S) r (θ ← [S]-env-absent (S ₛ))
status sigs' S' S''
S'∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩
S''∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩)
... | no S∉canθ'-sigs-⟨canθ-u∷sigs'-r⟩-θ←[S] | yes S∈canθ'-sigs-⟨canθ-sigs'-θ*←[S']⟩-θ←[S] =
⊥-elim
(S∉canθ'-sigs-⟨canθ-u∷sigs'-r⟩-θ←[S]
(canθ'-canθ-propagate-up-in-set-irr sigs (suc S) r (θ ← [S]-env (S ₛ)) status sigs' S' S
S'∈canθ'-sigs-⟨canθ-sigs'-r-θ*←[S']⟩
S∈canθ'-sigs-⟨canθ-sigs'-θ*←[S']⟩-θ←[S]))
canθ'-canθ-propagate-down-in-set-irr : ∀ sigs S r θ status →
∀ S' sigs' →
S' ∈ proj₁ (Canθ' sigs S (λ θ* → Canθ (just Signal.unknown ∷ sigs') S' r (θ* ← [ (S' ₛ) ↦ status ])) θ) →
Canθ' sigs S (λ θ* → Canθ (just Signal.unknown ∷ sigs') S' r (θ* ← [ (S' ₛ) ↦ status ])) θ ≡
Canθ' sigs S (λ θ* → Canθ sigs' (suc S') r (θ* ← [S]-env (S' ₛ))) θ
canθ'-canθ-propagate-down-in-set-irr [] S r θ status S' sigs' S'∈canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩
with any (_≟_ S') (Canθₛ sigs' (suc S') r ((θ ← [ (S' ₛ) ↦ status ]) ← [S]-env (S' ₛ)))
... | yes S'∈canθ-sigs'-r-θ←[S'] rewrite Env.sig-single-←-←-overwrite θ (S' ₛ) status Signal.unknown = refl
... | no S'∉canθ-sigs'-r-θ←[S'] =
⊥-elim
(S'∉canθ-sigs'-r-θ←[S']
(canθₛ-add-sig-monotonic sigs' (suc S') r (θ ← [ (S' ₛ) ↦ status ]) (S' ₛ) Signal.absent S'
S'∈canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩))
canθ'-canθ-propagate-down-in-set-irr (nothing ∷ sigs) S r θ status S' sigs' S'∈canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩ =
canθ'-canθ-propagate-down-in-set-irr sigs (suc S) r θ status S' sigs' S'∈canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩
canθ'-canθ-propagate-down-in-set-irr (just Signal.present ∷ sigs) S r θ status S' sigs' S'∈canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩ =
canθ'-canθ-propagate-down-in-set-irr sigs (suc S) r (θ ← [S]-env-present (S ₛ)) status S' sigs' S'∈canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩
canθ'-canθ-propagate-down-in-set-irr (just Signal.absent ∷ sigs) S r θ status S' sigs' S'∈canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩ =
canθ'-canθ-propagate-down-in-set-irr sigs (suc S) r (θ ← [S]-env-absent (S ₛ)) status S' sigs' S'∈canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩
canθ'-canθ-propagate-down-in-set-irr (just Signal.unknown ∷ sigs) S r θ status S' sigs' S'∈canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩
with any (_≟_ S)
(proj₁
(Canθ' sigs (suc S)
(λ θ* → Canθ (just Signal.unknown ∷ sigs') S' r (θ* ← [ (S' ₛ) ↦ status ]))
(θ ← [S]-env (S ₛ))))
| any (_≟_ S)
(proj₁
(Canθ' sigs (suc S)
(λ θ* → Canθ sigs' (suc S') r (θ* ← [S]-env (S' ₛ)))
(θ ← [S]-env (S ₛ))))
... | yes S∈canθ'-sigs-⟨canθ-u∷sigs'-r⟩-θ←[S] | yes S∈canθ'-sigs-⟨canθ-sigs'-θ*←[S']⟩-θ←[S] =
canθ'-canθ-propagate-down-in-set-irr sigs (suc S) r (θ ← [S]-env (S ₛ)) status S' sigs' S'∈canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩
... | no S∉canθ'-sigs-⟨canθ-u∷sigs'-r⟩-θ←[S] | no S∉canθ'-sigs-⟨canθ-sigs'-θ*←[S']⟩-θ←[S] =
canθ'-canθ-propagate-down-in-set-irr sigs (suc S) r (θ ← [S]-env-absent (S ₛ)) status S' sigs' S'∈canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩
... | yes S∈canθ'-sigs-⟨canθ-u∷sigs'-r⟩-θ←[S] | no S∉canθ'-sigs-⟨canθ-sigs'-θ*←[S']⟩-θ←[S]
= ⊥-elim
(S∉canθ'-sigs-⟨canθ-sigs'-θ*←[S']⟩-θ←[S]
(subst (S ∈_)
(cong proj₁
(canθ'-canθ-propagate-down-in-set-irr sigs (suc S) r (θ ← [S]-env (S ₛ)) status S' sigs'
S'∈canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩))
S∈canθ'-sigs-⟨canθ-u∷sigs'-r⟩-θ←[S]))
... | no S∉canθ'-sigs-⟨canθ-u∷sigs'-r⟩-θ←[S] | yes S∈canθ'-sigs-⟨canθ-sigs'-θ*←[S']⟩-θ←[S]
= ⊥-elim
(S∉canθ'-sigs-⟨canθ-u∷sigs'-r⟩-θ←[S]
(subst (S ∈_)
(cong proj₁
(sym (canθ'-canθ-propagate-down-in-set-irr sigs (suc S) r (θ ← [S]-env (S ₛ)) status S' sigs'
(canθ'ₛ-add-sig-monotonic sigs (suc S)
(Canθ (just Signal.unknown ∷ sigs') S' r ∘
(λ section → section ← [ (S' ₛ) ↦ status ]))
θ (S ₛ) Signal.absent
(λ θ* S* status* →
canθₛ-cong-←-add-sig-monotonic (just Signal.unknown ∷ sigs') S' r
θ* [ (S' ₛ) ↦ status ] S* status*)
S' S'∈canθ'-sigs-⟨Canθ-u∷sigs'-θ*⟩))))
S∈canθ'-sigs-⟨canθ-sigs'-θ*←[S']⟩-θ←[S]))
canθ'-←-distribute : ∀ sigs sigs' S'' r θ →
Canθ (SigMap.union sigs sigs') S'' r θ ≡
Canθ' sigs S'' (Canθ sigs' S'' r) θ
canθ'-←-distribute [] sigs' S'' r θ = refl
canθ'-←-distribute sigs [] S'' r θ
rewrite SigMap.union-comm sigs SigMap.empty (λ _ _ ())
| unfold sigs S'' r θ
= refl
canθ'-←-distribute (nothing ∷ sigs) (nothing ∷ sigs') S'' r θ =
canθ'-←-distribute sigs sigs' (suc S'') r θ
canθ'-←-distribute (just Signal.present ∷ sigs) (nothing ∷ sigs') S'' r θ =
canθ'-←-distribute sigs sigs' (suc S'') r
(θ ← [S]-env-present (S'' ₛ))
canθ'-←-distribute (just Signal.absent ∷ sigs) (nothing ∷ sigs') S'' r θ =
canθ'-←-distribute sigs sigs' (suc S'') r
(θ ← [S]-env-absent (S'' ₛ))
canθ'-←-distribute (just Signal.unknown ∷ sigs) (nothing ∷ sigs') S'' r θ
with any (_≟_ S'') (proj₁ (Canθ (SigMap.union sigs sigs') (suc S'') r (θ ← [S]-env (S'' ₛ))))
| any (_≟_ S'') (proj₁ (Canθ' sigs (suc S'') (Canθ sigs' (suc S'') r) (θ ← [S]-env (S'' ₛ))))
... | yes S''∈canθ'-sigs←sigs'-r-θ←[S''] | yes S''∈canθ'-sigs-⟨canθ-sigs'⟩-θ←[S''] =
canθ'-←-distribute sigs sigs' (suc S'') r
(θ ← [S]-env (S'' ₛ))
... | no S''∉canθ'-sigs←sigs'-r-θ←[S''] | no S''∉canθ'-sigs-⟨canθ-sigs'⟩-θ←[S''] =
canθ'-←-distribute sigs sigs' (suc S'') r
(θ ← [S]-env-absent (S'' ₛ))
... | yes S''∈canθ'-sigs←sigs'-r-θ←[S''] | no S''∉canθ'-sigs-⟨canθ-sigs'⟩-θ←[S'']
rewrite canθ'-←-distribute sigs sigs' (suc S'') r (θ ← [S]-env (S'' ₛ))
= ⊥-elim (S''∉canθ'-sigs-⟨canθ-sigs'⟩-θ←[S''] S''∈canθ'-sigs←sigs'-r-θ←[S''])
... | no S''∉canθ'-sigs←sigs'-r-θ←[S''] | yes S''∈canθ'-sigs-⟨canθ-sigs'⟩-θ←[S'']
rewrite canθ'-←-distribute sigs sigs' (suc S'') r (θ ← [S]-env (S'' ₛ))
= ⊥-elim (S''∉canθ'-sigs←sigs'-r-θ←[S''] S''∈canθ'-sigs-⟨canθ-sigs'⟩-θ←[S''])
canθ'-←-distribute (nothing ∷ sigs) (just Signal.present ∷ sigs') S'' r θ =
trans
(canθ'-←-distribute sigs sigs' (suc S'') r
(θ ← [S]-env-present (S'' ₛ)))
(canθ'-search-acc sigs (suc S'') (Canθ sigs' (suc S'') r) θ S'' Signal.present
(n∉map-suc-n-+ S'' (SigMap.keys sigs)))
canθ'-←-distribute (nothing ∷ sigs) (just Signal.absent ∷ sigs') S'' r θ =
trans
(canθ'-←-distribute sigs sigs' (suc S'') r
(θ ← [S]-env-absent (S'' ₛ)))
(canθ'-search-acc sigs (suc S'') (Canθ sigs' (suc S'') r) θ S'' Signal.absent
(n∉map-suc-n-+ S'' (SigMap.keys sigs)))
canθ'-←-distribute (nothing ∷ sigs) (just Signal.unknown ∷ sigs') S'' r θ
with any (_≟_ S'') (proj₁ (Canθ (SigMap.union sigs sigs') (suc S'') r (θ ← [S]-env (S'' ₛ))))
| any (_≟_ S'') (proj₁ (Canθ' sigs (suc S'') (Canθ (just Signal.unknown ∷ sigs') S'' r) θ))
... | yes S''∈canθ'-sigs←sigs'-r-θ←[S''] | yes S''∈canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩
rewrite canθ'-canθ-propagate-down-in sigs (suc S'') r θ S'' sigs' S''∈canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩
= trans
(canθ'-←-distribute sigs sigs' (suc S'') r
(θ ← [S]-env (S'' ₛ)))
(canθ'-search-acc sigs (suc S'') (Canθ sigs' (suc S'') r) θ S'' Signal.unknown
(n∉map-suc-n-+ S'' (SigMap.keys sigs)))
... | no S''∉canθ'-sigs←sigs'-r-θ←[S''] | no S''∉canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩
rewrite canθ'-canθ-propagate-down-not-in sigs (suc S'') r θ S'' sigs' S''∉canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩
= trans
(canθ'-←-distribute sigs sigs' (suc S'') r
(θ ← [S]-env-absent (S'' ₛ)))
(canθ'-search-acc sigs (suc S'') (Canθ sigs' (suc S'') r) θ S'' Signal.absent
(n∉map-suc-n-+ S'' (SigMap.keys sigs)))
... | yes S''∈canθ'-sigs←sigs'-r-θ←[S''] | no S''∉canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩
rewrite trans
(canθ'-←-distribute sigs sigs' (suc S'') r
(θ ← [S]-env (S'' ₛ)))
(canθ'-search-acc sigs (suc S'') (Canθ sigs' (suc S'') r) θ S'' Signal.unknown
(n∉map-suc-n-+ S'' (SigMap.keys sigs)))
= ⊥-elim
(S''∉canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩
(canθ'-canθ-propagate-up-in sigs (suc S'') r θ sigs' S'' S'' S''∈canθ'-sigs←sigs'-r-θ←[S''] S''∈canθ'-sigs←sigs'-r-θ←[S'']))
... | no S''∉canθ'-sigs←sigs'-r-θ←[S''] | yes S''∈canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩
rewrite trans
(canθ'-←-distribute sigs sigs' (suc S'') r
(θ ← [S]-env (S'' ₛ)))
(canθ'-search-acc sigs (suc S'') (Canθ sigs' (suc S'') r) θ S'' Signal.unknown
(n∉map-suc-n-+ S'' (SigMap.keys sigs)))
= ⊥-elim
(S''∉canθ'-sigs←sigs'-r-θ←[S'']
(subst (S'' ∈_)
(cong proj₁
(canθ'-canθ-propagate-down-in sigs (suc S'') r θ S'' sigs' S''∈canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩))
S''∈canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩))
canθ'-←-distribute (just Signal.present ∷ sigs) (just Signal.present ∷ sigs') S'' r θ =
trans
(canθ'-←-distribute sigs sigs' (suc S'') r
(θ ← [S]-env-present (S'' ₛ)))
(canθ'-search-acc-set-irr sigs (suc S'') (Canθ sigs' (suc S'') r) θ S'' Signal.present Signal.present
(n∉map-suc-n-+ S'' (SigMap.keys sigs)))
canθ'-←-distribute (just Signal.absent ∷ sigs) (just Signal.present ∷ sigs') S'' r θ =
trans
(canθ'-←-distribute sigs sigs' (suc S'') r
(θ ← [S]-env-present (S'' ₛ)))
(canθ'-search-acc-set-irr sigs (suc S'') (Canθ sigs' (suc S'') r) θ S'' Signal.present Signal.absent
(n∉map-suc-n-+ S'' (SigMap.keys sigs)))
canθ'-←-distribute (just Signal.unknown ∷ sigs) (just Signal.present ∷ sigs') S'' r θ
with any (_≟_ S'')
(proj₁
(Canθ' sigs (suc S'')
(λ θ* → Canθ sigs' (suc S'') r (θ* ← [S]-env-present (S'' ₛ)))
(θ ← [S]-env (S'' ₛ))))
... | yes S''∈canθ'-sigs-⟨Canθ-sigs'-r-θ*←[S'']⟩-θ←[S''] =
trans
(canθ'-←-distribute sigs sigs' (suc S'') r
(θ ← [S]-env-present (S'' ₛ)))
(canθ'-search-acc-set-irr sigs (suc S'') (Canθ sigs' (suc S'') r) θ S'' Signal.present Signal.unknown
(n∉map-suc-n-+ S'' (SigMap.keys sigs)))
... | no S''∉canθ'-sigs-⟨Canθ-sigs'-r-θ*←[S'']⟩-θ←[S''] =
trans
(canθ'-←-distribute sigs sigs' (suc S'') r
(θ ← [S]-env-present (S'' ₛ)))
(canθ'-search-acc-set-irr sigs (suc S'') (Canθ sigs' (suc S'') r) θ S'' Signal.present Signal.absent
(n∉map-suc-n-+ S'' (SigMap.keys sigs)))
canθ'-←-distribute (just Signal.present ∷ sigs) (just Signal.absent ∷ sigs') S'' r θ =
trans
(canθ'-←-distribute sigs sigs' (suc S'') r
(θ ← [S]-env-absent (S'' ₛ)))
(canθ'-search-acc-set-irr sigs (suc S'') (Canθ sigs' (suc S'') r) θ S'' Signal.absent Signal.present
(n∉map-suc-n-+ S'' (SigMap.keys sigs)))
canθ'-←-distribute (just Signal.absent ∷ sigs) (just Signal.absent ∷ sigs') S'' r θ =
trans
(canθ'-←-distribute sigs sigs' (suc S'') r
(θ ← [S]-env-absent (S'' ₛ)))
(canθ'-search-acc-set-irr sigs (suc S'') (Canθ sigs' (suc S'') r) θ S'' Signal.absent Signal.absent
(n∉map-suc-n-+ S'' (SigMap.keys sigs)))
canθ'-←-distribute (just Signal.unknown ∷ sigs) (just Signal.absent ∷ sigs') S'' r θ
with any (_≟_ S'')
(proj₁
(Canθ' sigs (suc S'')
(λ θ* → Canθ sigs' (suc S'') r (θ* ← [S]-env-absent (S'' ₛ)))
(θ ← [S]-env (S'' ₛ))))
... | yes S''∈canθ'-sigs-⟨Canθ-sigs'-r-θ*←[S'']⟩-θ←[S''] =
trans
(canθ'-←-distribute sigs sigs' (suc S'') r
(θ ← [S]-env-absent (S'' ₛ)))
(canθ'-search-acc-set-irr sigs (suc S'') (Canθ sigs' (suc S'') r) θ S'' Signal.absent Signal.unknown
(n∉map-suc-n-+ S'' (SigMap.keys sigs)))
... | no S''∉canθ'-sigs-⟨Canθ-sigs'-r-θ*←[S'']⟩-θ←[S''] =
trans
(canθ'-←-distribute sigs sigs' (suc S'') r
(θ ← [S]-env-absent (S'' ₛ)))
(canθ'-search-acc-set-irr sigs (suc S'') (Canθ sigs' (suc S'') r) θ S'' Signal.absent Signal.absent
(n∉map-suc-n-+ S'' (SigMap.keys sigs)))
canθ'-←-distribute (just Signal.present ∷ sigs) (just Signal.unknown ∷ sigs') S'' r θ
with any (_≟_ S'') (proj₁ (Canθ (SigMap.union sigs sigs') (suc S'') r (θ ← [S]-env (S'' ₛ))))
| any (_≟_ S'') (proj₁ (Canθ' sigs (suc S'') (Canθ (just Signal.unknown ∷ sigs') S'' r) (θ ← [S]-env-present (S'' ₛ))))
... | yes S''∈canθ'-sigs←sigs'-r-θ←[S''] | yes S''∈canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩
rewrite canθ'-canθ-propagate-down-in sigs (suc S'') r (θ ← [S]-env-present (S'' ₛ)) S'' sigs' S''∈canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩
= trans
(canθ'-←-distribute sigs sigs' (suc S'') r
(θ ← [S]-env (S'' ₛ)))
(canθ'-search-acc-set-irr sigs (suc S'') (Canθ sigs' (suc S'') r) θ S'' Signal.unknown Signal.present
(n∉map-suc-n-+ S'' (SigMap.keys sigs)))
... | no S''∉canθ'-sigs←sigs'-r-θ←[S''] | no S''∉canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩
rewrite canθ'-canθ-propagate-down-not-in sigs (suc S'') r (θ ← [S]-env-present (S'' ₛ)) S'' sigs' S''∉canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩
= trans
(canθ'-←-distribute sigs sigs' (suc S'') r
(θ ← [S]-env-absent (S'' ₛ)))
(canθ'-search-acc-set-irr sigs (suc S'') (Canθ sigs' (suc S'') r) θ S'' Signal.absent Signal.present
(n∉map-suc-n-+ S'' (SigMap.keys sigs)))
... | yes S''∈canθ'-sigs←sigs'-r-θ←[S''] | no S''∉canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩
rewrite trans
(canθ'-←-distribute sigs sigs' (suc S'') r
(θ ← [S]-env (S'' ₛ)))
(canθ'-search-acc sigs (suc S'') (Canθ sigs' (suc S'') r) θ S'' Signal.unknown
(n∉map-suc-n-+ S'' (SigMap.keys sigs)))
= ⊥-elim
(S''∉canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩
(subst (S'' ∈_)
(sym
(cong proj₁
(canθ'-search-acc sigs (suc S'') (Canθ (just Signal.unknown ∷ sigs') S'' r) θ
S'' Signal.present
(n∉map-suc-n-+ S'' (SigMap.keys sigs)))))
(canθ'-canθ-propagate-up-in-set-irr sigs (suc S'') r θ Signal.present sigs' S'' S'' S''∈canθ'-sigs←sigs'-r-θ←[S''] S''∈canθ'-sigs←sigs'-r-θ←[S''])))
... | no S''∉canθ'-sigs←sigs'-r-θ←[S''] | yes S''∈canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩
rewrite trans
(canθ'-←-distribute sigs sigs' (suc S'') r
(θ ← [S]-env (S'' ₛ)))
(canθ'-search-acc sigs (suc S'') (Canθ sigs' (suc S'') r) θ S'' Signal.unknown
(n∉map-suc-n-+ S'' (SigMap.keys sigs)))
| canθ'-search-acc sigs (suc S'') (Canθ (just Signal.unknown ∷ sigs') S'' r) θ
S'' Signal.present
(n∉map-suc-n-+ S'' (SigMap.keys sigs))
= ⊥-elim
(S''∉canθ'-sigs←sigs'-r-θ←[S'']
(subst (S'' ∈_)
(cong proj₁
(canθ'-canθ-propagate-down-in-set-irr sigs (suc S'') r θ Signal.present S'' sigs' S''∈canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩))
S''∈canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩))
canθ'-←-distribute (just Signal.absent ∷ sigs) (just Signal.unknown ∷ sigs') S'' r θ
with any (_≟_ S'') (proj₁ (Canθ (SigMap.union sigs sigs') (suc S'') r (θ ← [S]-env (S'' ₛ))))
| any (_≟_ S'') (proj₁ (Canθ' sigs (suc S'') (Canθ (just Signal.unknown ∷ sigs') S'' r) (θ ← [S]-env-absent (S'' ₛ))))
... | yes S''∈canθ'-sigs←sigs'-r-θ←[S''] | yes S''∈canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩
rewrite canθ'-canθ-propagate-down-in sigs (suc S'') r (θ ← [S]-env-absent (S'' ₛ)) S'' sigs' S''∈canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩
= trans
(canθ'-←-distribute sigs sigs' (suc S'') r
(θ ← [S]-env (S'' ₛ)))
(canθ'-search-acc-set-irr sigs (suc S'') (Canθ sigs' (suc S'') r) θ S'' Signal.unknown Signal.absent
(n∉map-suc-n-+ S'' (SigMap.keys sigs)))
... | no S''∉canθ'-sigs←sigs'-r-θ←[S''] | no S''∉canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩
rewrite canθ'-canθ-propagate-down-not-in sigs (suc S'') r (θ ← [S]-env-absent (S'' ₛ)) S'' sigs' S''∉canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩
= trans
(canθ'-←-distribute sigs sigs' (suc S'') r
(θ ← [S]-env-absent (S'' ₛ)))
(canθ'-search-acc-set-irr sigs (suc S'') (Canθ sigs' (suc S'') r) θ S'' Signal.absent Signal.absent
(n∉map-suc-n-+ S'' (SigMap.keys sigs)))
... | yes S''∈canθ'-sigs←sigs'-r-θ←[S''] | no S''∉canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩
rewrite trans
(canθ'-←-distribute sigs sigs' (suc S'') r
(θ ← [S]-env (S'' ₛ)))
(canθ'-search-acc sigs (suc S'') (Canθ sigs' (suc S'') r) θ S'' Signal.unknown
(n∉map-suc-n-+ S'' (SigMap.keys sigs)))
= ⊥-elim
(S''∉canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩
(subst (S'' ∈_)
(sym
(cong proj₁
(canθ'-search-acc sigs (suc S'') (Canθ (just Signal.unknown ∷ sigs') S'' r) θ
S'' Signal.absent
(n∉map-suc-n-+ S'' (SigMap.keys sigs)))))
(canθ'-canθ-propagate-up-in-set-irr sigs (suc S'') r θ Signal.absent sigs' S'' S'' S''∈canθ'-sigs←sigs'-r-θ←[S''] S''∈canθ'-sigs←sigs'-r-θ←[S''])))
... | no S''∉canθ'-sigs←sigs'-r-θ←[S''] | yes S''∈canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩
rewrite trans
(canθ'-←-distribute sigs sigs' (suc S'') r
(θ ← [S]-env (S'' ₛ)))
(canθ'-search-acc sigs (suc S'') (Canθ sigs' (suc S'') r) θ S'' Signal.unknown
(n∉map-suc-n-+ S'' (SigMap.keys sigs)))
| canθ'-search-acc sigs (suc S'') (Canθ (just Signal.unknown ∷ sigs') S'' r) θ
S'' Signal.absent
(n∉map-suc-n-+ S'' (SigMap.keys sigs))
= ⊥-elim
(S''∉canθ'-sigs←sigs'-r-θ←[S'']
(subst (S'' ∈_)
(cong proj₁
(canθ'-canθ-propagate-down-in-set-irr sigs (suc S'') r θ Signal.absent S'' sigs' S''∈canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩))
S''∈canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩))
canθ'-←-distribute (just Signal.unknown ∷ sigs) (just Signal.unknown ∷ sigs') S'' r θ
with any (_≟_ S'') (proj₁ (Canθ' sigs (suc S'') (λ θ* → Canθ (just Signal.unknown ∷ sigs') S'' r θ*) (θ ← [S]-env (S'' ₛ))))
canθ'-←-distribute (just Signal.unknown ∷ sigs) (just Signal.unknown ∷ sigs') S'' r θ | yes p
with any (_≟_ S'') (proj₁ (Canθ (SigMap.union sigs sigs') (suc S'') r (θ ← [S]-env (S'' ₛ))))
| any (_≟_ S'') (proj₁ (Canθ' sigs (suc S'') (Canθ (just Signal.unknown ∷ sigs') S'' r) (θ ← [S]-env (S'' ₛ))))
... | yes S''∈canθ'-sigs←sigs'-r-θ←[S''] | yes S''∈canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩
rewrite canθ'-canθ-propagate-down-in sigs (suc S'') r (θ ← [S]-env (S'' ₛ)) S'' sigs' S''∈canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩
= trans
(canθ'-←-distribute sigs sigs' (suc S'') r
(θ ← [S]-env (S'' ₛ)))
(canθ'-search-acc-set-irr sigs (suc S'') (Canθ sigs' (suc S'') r) θ S'' Signal.unknown Signal.unknown
(n∉map-suc-n-+ S'' (SigMap.keys sigs)))
... | no S''∉canθ'-sigs←sigs'-r-θ←[S''] | no S''∉canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩
rewrite canθ'-canθ-propagate-down-not-in sigs (suc S'') r (θ ← [S]-env (S'' ₛ)) S'' sigs' S''∉canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩
= trans
(canθ'-←-distribute sigs sigs' (suc S'') r
(θ ← [S]-env-absent (S'' ₛ)))
(canθ'-search-acc-set-irr sigs (suc S'') (Canθ sigs' (suc S'') r) θ S'' Signal.absent Signal.unknown
(n∉map-suc-n-+ S'' (SigMap.keys sigs)))
... | yes S''∈canθ'-sigs←sigs'-r-θ←[S''] | no S''∉canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩
rewrite trans
(canθ'-←-distribute sigs sigs' (suc S'') r
(θ ← [S]-env (S'' ₛ)))
(canθ'-search-acc sigs (suc S'') (Canθ sigs' (suc S'') r) θ S'' Signal.unknown
(n∉map-suc-n-+ S'' (SigMap.keys sigs)))
= ⊥-elim
(S''∉canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩
(subst (S'' ∈_)
(sym
(cong proj₁
(canθ'-search-acc sigs (suc S'') (Canθ (just Signal.unknown ∷ sigs') S'' r) θ
S'' Signal.unknown
(n∉map-suc-n-+ S'' (SigMap.keys sigs)))))
(canθ'-canθ-propagate-up-in-set-irr sigs (suc S'') r θ Signal.unknown sigs' S'' S'' S''∈canθ'-sigs←sigs'-r-θ←[S''] S''∈canθ'-sigs←sigs'-r-θ←[S''])))
... | no S''∉canθ'-sigs←sigs'-r-θ←[S''] | yes S''∈canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩
rewrite trans
(canθ'-←-distribute sigs sigs' (suc S'') r
(θ ← [S]-env (S'' ₛ)))
(canθ'-search-acc sigs (suc S'') (Canθ sigs' (suc S'') r) θ S'' Signal.unknown
(n∉map-suc-n-+ S'' (SigMap.keys sigs)))
| canθ'-search-acc sigs (suc S'') (Canθ (just Signal.unknown ∷ sigs') S'' r) θ
S'' Signal.unknown
(n∉map-suc-n-+ S'' (SigMap.keys sigs))
= ⊥-elim
(S''∉canθ'-sigs←sigs'-r-θ←[S'']
(subst (S'' ∈_)
(cong proj₁
(canθ'-canθ-propagate-down-in-set-irr sigs (suc S'') r θ Signal.unknown S'' sigs' S''∈canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩))
S''∈canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩))
canθ'-←-distribute (just Signal.unknown ∷ sigs) (just Signal.unknown ∷ sigs') S'' r θ | no ¬p
with any (_≟_ S'') (proj₁ (Canθ (SigMap.union sigs sigs') (suc S'') r (θ ← [S]-env (S'' ₛ))))
| any (_≟_ S'') (proj₁ (Canθ' sigs (suc S'') (Canθ (just Signal.unknown ∷ sigs') S'' r) (θ ← [S]-env-absent (S'' ₛ))))
... | yes S''∈canθ'-sigs←sigs'-r-θ←[S''] | yes S''∈canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩
rewrite canθ'-canθ-propagate-down-in sigs (suc S'') r (θ ← [S]-env-absent (S'' ₛ)) S'' sigs' S''∈canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩
= trans
(canθ'-←-distribute sigs sigs' (suc S'') r
(θ ← [S]-env (S'' ₛ)))
(canθ'-search-acc-set-irr sigs (suc S'') (Canθ sigs' (suc S'') r) θ S'' Signal.unknown Signal.absent
(n∉map-suc-n-+ S'' (SigMap.keys sigs)))
... | no S''∉canθ'-sigs←sigs'-r-θ←[S''] | no S''∉canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩
rewrite canθ'-canθ-propagate-down-not-in sigs (suc S'') r (θ ← [S]-env-absent (S'' ₛ)) S'' sigs' S''∉canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩
= trans
(canθ'-←-distribute sigs sigs' (suc S'') r
(θ ← [S]-env-absent (S'' ₛ)))
(canθ'-search-acc-set-irr sigs (suc S'') (Canθ sigs' (suc S'') r) θ S'' Signal.absent Signal.absent
(n∉map-suc-n-+ S'' (SigMap.keys sigs)))
... | yes S''∈canθ'-sigs←sigs'-r-θ←[S''] | no S''∉canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩
rewrite trans
(canθ'-←-distribute sigs sigs' (suc S'') r
(θ ← [S]-env (S'' ₛ)))
(canθ'-search-acc sigs (suc S'') (Canθ sigs' (suc S'') r) θ S'' Signal.unknown
(n∉map-suc-n-+ S'' (SigMap.keys sigs)))
= ⊥-elim
(S''∉canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩
(subst (S'' ∈_)
(sym
(cong proj₁
(canθ'-search-acc sigs (suc S'') (Canθ (just Signal.unknown ∷ sigs') S'' r) θ
S'' Signal.absent
(n∉map-suc-n-+ S'' (SigMap.keys sigs)))))
(canθ'-canθ-propagate-up-in-set-irr sigs (suc S'') r θ Signal.absent sigs' S'' S'' S''∈canθ'-sigs←sigs'-r-θ←[S''] S''∈canθ'-sigs←sigs'-r-θ←[S''])))
... | no S''∉canθ'-sigs←sigs'-r-θ←[S''] | yes S''∈canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩
rewrite trans
(canθ'-←-distribute sigs sigs' (suc S'') r
(θ ← [S]-env (S'' ₛ)))
(canθ'-search-acc sigs (suc S'') (Canθ sigs' (suc S'') r) θ S'' Signal.unknown
(n∉map-suc-n-+ S'' (SigMap.keys sigs)))
| canθ'-search-acc sigs (suc S'') (Canθ (just Signal.unknown ∷ sigs') S'' r) θ
S'' Signal.absent
(n∉map-suc-n-+ S'' (SigMap.keys sigs))
= ⊥-elim
(S''∉canθ'-sigs←sigs'-r-θ←[S'']
(subst (S'' ∈_)
(cong proj₁
(canθ'-canθ-propagate-down-in-set-irr sigs (suc S'') r θ Signal.absent S'' sigs' S''∈canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩))
S''∈canθ'-sigs-⟨Canθ-u∷sigs'-r-θ⟩))
| 57.218617
| 251
| 0.533454
|
1c4a1de2c88c4cfb80f2d0f7ed2e44dc743dad46
| 1,032
|
agda
|
Agda
|
examples/outdated-and-incorrect/AIM6/Cat/lib/Logic/Relations.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
examples/outdated-and-incorrect/AIM6/Cat/lib/Logic/Relations.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
examples/outdated-and-incorrect/AIM6/Cat/lib/Logic/Relations.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module Logic.Relations where
import Logic.Base
import Data.Bool
Rel : Set -> Set1
Rel A = A -> A -> Set
Reflexive : {A : Set} -> Rel A -> Set
Reflexive {A} _R_ = {x : A} -> x R x
Symmetric : {A : Set} -> Rel A -> Set
Symmetric {A} _R_ = {x y : A} -> x R y -> y R x
Transitive : {A : Set} -> Rel A -> Set
Transitive {A} _R_ = {x y z : A} -> x R y -> y R z -> x R z
Congruent : {A : Set} -> Rel A -> Set
Congruent {A} _R_ = (f : A -> A)(x y : A) -> x R y -> f x R f y
Substitutive : {A : Set} -> Rel A -> Set1
Substitutive {A} _R_ = (P : A -> Set)(x y : A) -> x R y -> P x -> P y
module PolyEq (_≡_ : {A : Set} -> Rel A) where
Antisymmetric : {A : Set} -> Rel A -> Set
Antisymmetric {A} _R_ = (x y : A) -> x R y -> y R x -> x ≡ y
module MonoEq {A : Set}(_≡_ : Rel A) where
Antisymmetric : Rel A -> Set
Antisymmetric _R_ = (x y : A) -> x R y -> y R x -> x ≡ y
open Logic.Base
Total : {A : Set} -> Rel A -> Set
Total {A} _R_ = (x y : A) -> (x R y) \/ (y R x)
Decidable : (P : Set) -> Set
Decidable P = P \/ ¬ P
| 24
| 69
| 0.514535
|
df38eb987d8e9bc7a5d87312752e0df168d068a2
| 34
|
agda
|
Agda
|
test/Succeed/ValidNamePartSet.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/ValidNamePartSet.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/ValidNamePartSet.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
test = forall (_Set_ : Set) → Set
| 17
| 33
| 0.617647
|
188b73cd1a4e0f12d03dc5f85b5b9a9944531f08
| 140
|
agda
|
Agda
|
test/Fail/UnequalHiding.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/UnequalHiding.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/UnequalHiding.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module UnequalHiding where
data One : Set where one : One
f : ({A : Set} -> A -> A) -> One
f = \(id : (A : Set) -> A -> A) -> id One one
| 17.5
| 45
| 0.514286
|
12ec94499394b4a24e2b520bad5c3e2c0b00c284
| 31,064
|
agda
|
Agda
|
BTA6.agda
|
luminousfennell/polybta
|
ef878f7fa5afa51fb7a14cd8f7f75da0af1b9deb
|
[
"BSD-3-Clause"
] | 1
|
2019-10-15T04:35:29.000Z
|
2019-10-15T04:35:29.000Z
|
BTA6.agda
|
luminousfennell/polybta
|
ef878f7fa5afa51fb7a14cd8f7f75da0af1b9deb
|
[
"BSD-3-Clause"
] | null | null | null |
BTA6.agda
|
luminousfennell/polybta
|
ef878f7fa5afa51fb7a14cd8f7f75da0af1b9deb
|
[
"BSD-3-Clause"
] | 1
|
2019-10-15T09:01:37.000Z
|
2019-10-15T09:01:37.000Z
|
module BTA6 where
----------------------------------------------
-- Preliminaries: Imports and List-utilities
----------------------------------------------
open import Data.Nat hiding (_<_)
open import Data.Bool
open import Function using (_∘_)
open import Data.List
open import Relation.Nullary
open import Relation.Binary.PropositionalEquality
open import Category.Functor
-- Pointer into a list. It is similar to list membership as defined in
-- Data.List.AnyMembership, rather than going through propositional
-- equality, it asserts the existence of the referenced element
-- directly.
module ListReference where
infix 4 _∈_
data _∈_ {A : Set} : A → List A → Set where
hd : ∀ {x xs} → x ∈ (x ∷ xs)
tl : ∀ {x y xs} → x ∈ xs → x ∈ (y ∷ xs)
open ListReference
mapIdx : {A B : Set} → (f : A → B) →
{x : A} {xs : List A} → x ∈ xs → f x ∈ map f xs
mapIdx f hd = hd
mapIdx f (tl x₁) = tl (mapIdx f x₁)
-- Extension of lists at the front and, as a generalization, extension
-- of lists somewhere in the middle.
module ListExtension where
open import Relation.Binary.PropositionalEquality
-- Extension of a list by consing elements at the front.
data _↝_ {A : Set} : List A → List A → Set where
↝-refl : ∀ {Γ} → Γ ↝ Γ
↝-extend : ∀ {Γ Γ' τ} → Γ ↝ Γ' → Γ ↝ (τ ∷ Γ')
-- Combining two transitive extensions.
↝-trans : ∀ {A : Set}{Γ Γ' Γ'' : List A} → Γ ↝ Γ' → Γ' ↝ Γ'' → Γ ↝ Γ''
↝-trans Γ↝Γ' ↝-refl = Γ↝Γ'
↝-trans Γ↝Γ' (↝-extend Γ'↝Γ'') = ↝-extend (↝-trans Γ↝Γ' Γ'↝Γ'')
-- Of course, ↝-refl is the identity for combining two extensions.
lem-↝-refl-id : ∀ {A : Set} {Γ Γ' : List A} →
(Γ↝Γ' : Γ ↝ Γ') →
Γ↝Γ' ≡ (↝-trans ↝-refl Γ↝Γ')
lem-↝-refl-id ↝-refl = refl
lem-↝-refl-id (↝-extend Γ↝Γ') =
cong ↝-extend (lem-↝-refl-id Γ↝Γ')
-- TODO: why does this work?
-- lem-↝-refl-id (↝-extend Γ↝Γ') = lem-↝-refl-id (↝-extend Γ↝Γ')
-- Extending a list in the middle:
data _↝_↝_ {A : Set} : List A → List A → List A → Set where
-- First prepend the extension list to the common suffix
↝↝-base : ∀ {Γ Γ''} → Γ ↝ Γ'' → Γ ↝ [] ↝ Γ''
-- ... and then add the common prefix
↝↝-extend : ∀ {Γ Γ' Γ'' τ} →
Γ ↝ Γ' ↝ Γ'' → (τ ∷ Γ) ↝ (τ ∷ Γ') ↝ (τ ∷ Γ'')
open ListExtension
---------------------------------------
-- Start of the development:
---------------------------------------
-- Intro/Objective:
-------------------
-- The following development defines a (verified) specializer/partial
-- evaluator for a simply typed lambda calculus embedded in Agda using
-- deBruijn indices.
-- The residual language.
-------------------------
-- The residual language is a standard simply typed λ-calculus. The
-- types are integers and functions.
data Type : Set where
Int : Type
Fun : Type → Type → Type
Ctx = List Type
-- The type Exp describes the typed residual expressions. Variables
-- are represented by deBruijn indices that form references into the
-- typing context. The constructors and typing constraints are
-- standard.
-- TODO: citations for ``as usual'' and ``standard''
data Exp (Γ : Ctx) : Type → Set where
EVar : ∀ {τ} → τ ∈ Γ → Exp Γ τ
EInt : ℕ → Exp Γ Int
EAdd : Exp Γ Int → Exp Γ Int -> Exp Γ Int
ELam : ∀ {τ τ'} → Exp (τ ∷ Γ) τ' → Exp Γ (Fun τ τ')
EApp : ∀ {τ τ'} → Exp Γ (Fun τ τ') → Exp Γ τ → Exp Γ τ'
-- The standard functional semantics of the residual expressions.
-- TODO: citations for ``as usual'' and ``standard''
module Exp-Eval where
-- interpretation of Exp types
EImp : Type → Set
EImp Int = ℕ
EImp (Fun τ₁ τ₂) = EImp τ₁ → EImp τ₂
-- Environments containing values for free variables. An environment
-- is indexed by a typing context that provides the types for the
-- contained values.
data Env : Ctx → Set where
[] : Env []
_∷_ : ∀ {τ Γ} → EImp τ → Env Γ → Env (τ ∷ Γ)
-- Lookup a value in the environment, given a reference into the
-- associated typing context.
lookupE : ∀ { τ Γ } → τ ∈ Γ → Env Γ → EImp τ
lookupE hd (x ∷ env) = x
lookupE (tl v) (x ∷ env) = lookupE v env
-- Evaluation of residual terms, given a suitably typed environment.
ev : ∀ {τ Γ} → Exp Γ τ → Env Γ → EImp τ
ev (EVar x) env = lookupE x env
ev (EInt x) env = x
ev (EAdd e f) env = ev e env + ev f env
ev (ELam e) env = λ x → ev e (x ∷ env)
ev (EApp e f) env = ev e env (ev f env)
-- The binding-time-annotated language.
---------------------------------------
-- The type of a term determines the term's binding time. The type
-- constructors with an A-prefix denote statically bound integers and
-- functions. Terms with dynamic binding time have a `D' type. The `D'
-- type constructor simply wraps up a residual type.
data AType : Set where
AInt : AType
AFun : AType → AType → AType
D : Type → AType
ACtx = List AType
-- The mapping from annotated types to residual types is straightforward.
typeof : AType → Type
typeof AInt = Int
typeof (AFun α₁ α₂) = Fun (typeof α₁) (typeof α₂)
typeof (D x) = x
-- ATypes are stratified such that that dynamically bound
-- functions can only have dynamically bound parameters.
-- TODO: why exactly is that necessary?
-- The following well-formedness relation as an alternative representation
-- for this constraint:
module AType-WF where
open import Relation.Binary.PropositionalEquality
-- Static and dynamic binding times
data BT : Set where
stat : BT
dyn : BT
-- Ordering on binding times: dynamic binding time subsumes static
-- binding time.
data _≤-bt_ : BT → BT → Set where
bt≤bt : ∀ bt → bt ≤-bt bt
stat≤bt : ∀ bt → stat ≤-bt bt
module WF (ATy : Set) (typeof : ATy → Type) (btof : ATy → BT) where
data wf : ATy → Set where
wf-int : ∀ α → typeof α ≡ Int → wf α
wf-fun : ∀ α α₁ α₂ →
typeof α ≡ Fun (typeof α₁) (typeof α₂) →
btof α ≤-bt btof α₁ →
btof α ≤-bt btof α₂ →
wf α₁ → wf α₂ →
wf α
-- It is easy to check that the stratification respects the
-- well-formedness, given the intended mapping from ATypes to
-- binding times expained above:
btof : AType → BT
btof AInt = stat
btof (AFun _ _) = stat
btof (D x) = dyn
open WF AType typeof btof using (wf-fun; wf-int) renaming (wf to wf-AType)
lem-wf-AType : ∀ α → wf-AType α
lem-wf-AType AInt = WF.wf-int AInt refl
lem-wf-AType (AFun α α₁) = WF.wf-fun (AFun α α₁) α α₁ refl (stat≤bt (btof α))
(stat≤bt (btof α₁))
(lem-wf-AType α)
(lem-wf-AType α₁)
lem-wf-AType (D Int) = WF.wf-int (D Int) refl
lem-wf-AType (D (Fun x x₁)) = WF.wf-fun (D (Fun x x₁))
(D x) (D x₁)
refl (bt≤bt dyn) (bt≤bt dyn)
(lem-wf-AType (D x))
(lem-wf-AType (D x₁))
-- The typed annotated terms: The binding times of variables is
-- determined by the corresponding type-binding in the context. In the
-- other cases, the A- and D-prefixes on term constructors inidicate
-- the corresponding binding times for the resulting terms.
data AExp (Δ : ACtx) : AType → Set where
Var : ∀ {α} → α ∈ Δ → AExp Δ α
AInt : ℕ → AExp Δ AInt
AAdd : AExp Δ AInt → AExp Δ AInt → AExp Δ AInt
ALam : ∀ {α₁ α₂} → AExp (α₁ ∷ Δ) α₂ → AExp Δ (AFun α₁ α₂)
AApp : ∀ {α₁ α₂} → AExp Δ (AFun α₂ α₁) → AExp Δ α₂ → AExp Δ α₁
DInt : ℕ → AExp Δ (D Int)
DAdd : AExp Δ (D Int) → AExp Δ (D Int) → AExp Δ (D Int)
DLam : ∀ {σ₁ σ₂} → AExp ((D σ₁) ∷ Δ) (D σ₂) → AExp Δ (D (Fun σ₁ σ₂))
DApp : ∀ {α₁ α₂} → AExp Δ (D (Fun α₂ α₁)) → AExp Δ (D α₂) → AExp Δ (D α₁)
Lift : AExp Δ AInt → AExp Δ (D Int)
-- The terms of AExp assign a binding time to each subterm. For
-- program specialization, we interpret terms with dynamic binding
-- time as the programs subject to specialization, and their subterms
-- with static binding time as statically known inputs. A partial
-- evaluation function (or specializer) then compiles the program into
-- a residual term for that is specialized for the static inputs. The
-- main complication when defining partial evaluation as a total,
-- primitively recursive function will be the treatment of the De
-- Bruijn variables of non-closed residual expressions.
-- Before diving into the precise definition, it is instructive to
-- investigate the expected result of partial evaluation on some
-- examples.
module ApplicativeMaybe where
open import Data.Maybe public
open import Category.Functor public
import Level
open RawFunctor {Level.zero} functor public
infixl 4 _⊛_
_⊛_ : {A B : Set} → Maybe (A → B) → Maybe A → Maybe B
just f ⊛ just x = just (f x)
_ ⊛ _ = nothing
liftA2 : {A B C : Set} → (A → B → C) → Maybe A → Maybe B → Maybe C
liftA2 f mx my = just f ⊛ mx ⊛ my
module AExp-Examples where
open import Data.Product hiding (map)
open ApplicativeMaybe
open import Data.Empty
open Relation.Binary.PropositionalEquality
-- (We pre-define some De Bruijn indices to improve
-- readability of the examples:)
x : ∀ {α Δ} → AExp (α ∷ Δ) α
x = Var hd
x' : ∀ {α Δ} → Exp (α ∷ Δ) α
x' = EVar hd
y : ∀ {α₁ α Δ} → AExp (α₁ ∷ α ∷ Δ) α
y = Var (tl hd)
z : ∀ {α₁ α₂ α Δ} → AExp (α₁ ∷ α₂ ∷ α ∷ Δ) α
z = Var (tl (tl hd))
-- A rather trivial case is the specialization of base-type
-- calulations. Here, we simply want to emit the result of a static
-- addition as a constant:
-- Lift (5S +S 5S) --specializes to --> 5E
ex0 : AExp [] (D Int)
ex0 = (Lift (AAdd (AInt 5) (AInt 5)))
ex0' : AExp [] (D Int)
ex0' = DAdd (DInt 6) (Lift (AAdd (AInt 5) (AInt 5)))
ex0-spec : Exp [] Int
ex0-spec = (EInt 10)
ex0'-spec : Exp [] Int
ex0'-spec = (EAdd (EInt 6) (EInt 10))
-- The partial evaluation for this case is of course
-- straightforward. We use Agda's ℕ as an implementation type for
-- static integers and residual expressions Exp for dynamic ones.
Imp0 : AType → Set
Imp0 AInt = ℕ
Imp0 (D σ) = Exp [] σ
Imp0 _ = ⊥
pe-ex0 : ∀ { α } → AExp [] α → Maybe (Imp0 α)
pe-ex0 (AInt x) = just (x)
pe-ex0 (DInt x) = just (EInt x)
pe-ex0 (AAdd e f) = liftA2 _+_ (pe-ex0 e) (pe-ex0 f)
pe-ex0 (DAdd e f) = liftA2 EAdd (pe-ex0 e) (pe-ex0 f)
pe-ex0 (Lift e) = EInt <$> (pe-ex0 e)
pe-ex0 _ = nothing
ex0-test : pe-ex0 ex0 ≡ just ex0-spec
ex0-test = refl
ex0'-test : pe-ex0 ex0' ≡ just ex0'-spec
ex0'-test = refl
-- Specializing open terms is also straightforward. This situation
-- typically arises when specializing the body of a lambda
-- abstraction.
-- (Dλ x → x +D Lift (5S + 5S)) ---specializes to--> Eλ x → EInt 10
ex1 : AExp [] (D (Fun Int Int))
ex1 = (DLam (DAdd x (Lift (AAdd (AInt 5) (AInt 5)))))
ex1-spec : Exp [] (Fun Int Int)
ex1-spec = ELam (EAdd x' (EInt 10))
ex1' : AExp (D Int ∷ []) (D Int)
ex1' = (Lift (AAdd (AInt 5) (AInt 5)))
ex1'-spec : Exp (Int ∷ []) Int
ex1'-spec = (EAdd x' (EInt 10))
-- The implementation type now also has to hold open residual terms,
-- which arise as the result of partially evaluating an open term
-- with with dynamic binding time. The calculation of the
-- implementation type thus requires a typing context as a
-- parameter.
Imp1 : Ctx → AType → Set
Imp1 _ AInt = ℕ
Imp1 Γ (D τ) = Exp Γ τ
Imp1 _ _ = ⊥
erase = typeof
-- Unsurprisingly, Partial evaluation of open terms emits
-- implementations that are typed under the erased context.
pe-ex1 : ∀ {α Δ} → AExp Δ α → Maybe (Imp1 (map erase Δ) α)
pe-ex1 (AInt x) = just (x)
pe-ex1 (DInt x) = just (EInt x)
pe-ex1 (AAdd e f) = liftA2 _+_ (pe-ex1 e) (pe-ex1 f)
pe-ex1 (DAdd e f) = liftA2 EAdd (pe-ex1 e) (pe-ex1 f)
pe-ex1 (Lift e) = EInt <$> (pe-ex1 e)
pe-ex1 (DLam {τ} e) = ELam <$> pe-ex1 e
-- Technical note: In the case for variables we can simply exploit
-- the fact that variables are functorial in the actual type of
-- their contexts' elements
pe-ex1 (Var {D _} x) = just (EVar (mapIdx typeof x))
pe-ex1 _ = nothing
ex1-test : pe-ex1 ex1 ≡ just ex1-spec
ex1-test = refl
data Static : AType → Set where
SInt : Static AInt
SFun : ∀ { α₁ α₂ } → Static α₂ → Static (AFun α₁ α₂)
is-static : (α : AType) → Dec (Static α)
is-static α = {!!}
Imp2 : Ctx → AType → Set
Imp2 _ AInt = ℕ
Imp2 Γ (D τ) = Exp Γ τ
Imp2 Γ (AFun α₁ α₂) = Imp2 Γ α₁ → Imp2 Γ α₂
-- The interpretation of annotated types.
Imp : Ctx → AType → Set
Imp Γ (AInt) = ℕ
Imp Γ (AFun α₁ α₂) = ∀ {Γ'} → Γ ↝ Γ' → (Imp Γ' α₁ → Imp Γ' α₂)
Imp Γ (D σ) = Exp Γ σ
elevate-var : ∀ {Γ Γ'} {τ : Type} → Γ ↝ Γ' → τ ∈ Γ → τ ∈ Γ'
elevate-var ↝-refl x = x
elevate-var (↝-extend Γ↝Γ') x = tl (elevate-var Γ↝Γ' x)
elevate-var2 : ∀ {Γ Γ' Γ'' τ} → Γ ↝ Γ' ↝ Γ'' → τ ∈ Γ → τ ∈ Γ''
elevate-var2 (↝↝-base x) x₁ = elevate-var x x₁
elevate-var2 (↝↝-extend Γ↝Γ'↝Γ'') hd = hd
elevate-var2 (↝↝-extend Γ↝Γ'↝Γ'') (tl x) = tl (elevate-var2 Γ↝Γ'↝Γ'' x)
elevate : ∀ {Γ Γ' Γ'' τ} → Γ ↝ Γ' ↝ Γ'' → Exp Γ τ → Exp Γ'' τ
elevate Γ↝Γ'↝Γ'' (EVar x) = EVar (elevate-var2 Γ↝Γ'↝Γ'' x)
elevate Γ↝Γ'↝Γ'' (EInt x) = EInt x
elevate Γ↝Γ'↝Γ'' (EAdd e e₁) = EAdd (elevate Γ↝Γ'↝Γ'' e) (elevate Γ↝Γ'↝Γ'' e₁)
elevate Γ↝Γ'↝Γ'' (ELam e) = ELam (elevate (↝↝-extend Γ↝Γ'↝Γ'') e)
elevate Γ↝Γ'↝Γ'' (EApp e e₁) = EApp (elevate Γ↝Γ'↝Γ'' e) (elevate Γ↝Γ'↝Γ'' e₁)
lift : ∀ {Γ Γ'} α → Γ ↝ Γ' → Imp Γ α → Imp Γ' α
lift AInt p v = v
lift (AFun x x₁) Γ↝Γ' v = λ Γ'↝Γ'' → v (↝-trans Γ↝Γ' Γ'↝Γ'')
lift (D x₁) Γ↝Γ' v = elevate (↝↝-base Γ↝Γ') v
module SimpleAEnv where
-- A little weaker, but much simpler
data AEnv (Γ : Ctx) : ACtx → Set where
[] : AEnv Γ []
cons : ∀ {Δ} (α : AType) → Imp Γ α → AEnv Γ Δ → AEnv Γ (α ∷ Δ)
lookup : ∀ {α Δ Γ} → AEnv Γ Δ → α ∈ Δ → Imp Γ α
lookup (cons α v env) hd = v
lookup (cons α₁ v env) (tl x) = lookup env x
liftEnv : ∀ {Γ Γ' Δ} → Γ ↝ Γ' → AEnv Γ Δ → AEnv Γ' Δ
liftEnv Γ↝Γ' [] = []
liftEnv Γ↝Γ' (cons α x env) = cons α (lift α Γ↝Γ' x) (liftEnv Γ↝Γ' env)
consD : ∀ {Γ Δ} σ → AEnv Γ Δ → AEnv (σ ∷ Γ) (D σ ∷ Δ)
consD σ env = (cons (D σ) (EVar hd) (liftEnv (↝-extend {τ = σ} ↝-refl) env))
pe : ∀ {α Δ Γ} → AExp Δ α → AEnv Γ Δ → Imp Γ α
pe (Var x) env = lookup env x
pe (AInt x) env = x
pe (AAdd e₁ e₂) env = pe e₁ env + pe e₂ env
pe (ALam {α} e) env = λ Γ↝Γ' → λ y → pe e (cons α y (liftEnv Γ↝Γ' env))
pe (AApp e₁ e₂) env = ((pe e₁ env) ↝-refl) (pe e₂ env)
pe (DInt x) env = EInt x
pe (DAdd e e₁) env = EAdd (pe e env) (pe e₁ env)
pe (DLam {σ} e) env = ELam (pe e (consD σ env))
pe (DApp e e₁) env = EApp (pe e env) (pe e₁ env)
pe (Lift e) env = EInt (pe e env)
module CheckExamples where
open import Relation.Binary.PropositionalEquality hiding ([_])
open SimpleAEnv
open AExp-Examples
check-ex1 : pe ex1 [] ≡ ex1-spec
check-ex1 = refl
check-ex0 : pe ex0 [] ≡ ex0-spec
check-ex0 = refl
check-ex0' : pe ex0' [] ≡ ex0'-spec
check-ex0' = refl
module Examples where
open SimpleAEnv
open import Relation.Binary.PropositionalEquality
x : ∀ {α Δ} → AExp (α ∷ Δ) α
x = Var hd
y : ∀ {α₁ α Δ} → AExp (α₁ ∷ α ∷ Δ) α
y = Var (tl hd)
z : ∀ {α₁ α₂ α Δ} → AExp (α₁ ∷ α₂ ∷ α ∷ Δ) α
z = Var (tl (tl hd))
-- Dλ y → let f = λ x → x D+ y in Dλ z → f z
term1 : AExp [] (D (Fun Int (Fun Int Int)))
term1 = DLam (AApp (ALam (DLam (AApp (ALam y) x)))
((ALam (DAdd x y))))
-- Dλ y → let f = λ x → (Dλ w → x D+ y) in Dλ z → f z
-- Dλ y → (λ f → Dλ z → f z) (λ x → (Dλ w → x D+ y))
term2 : AExp [] (D (Fun Int (Fun Int Int)))
term2 = DLam (AApp (ALam (DLam (AApp (ALam y) x)))
((ALam (DLam {σ₁ = Int} (DAdd y z)))))
-- closed pe. In contrast to BTA5, it is now not clear what Γ is
-- given an expression. So perhaps AEnv has it's merrits after all?
pe[] : ∀ {α} → AExp [] α → Imp [] α
pe[] e = pe e []
ex-pe-term1 : pe[] term1 ≡ ELam (ELam (EVar hd))
ex-pe-term1 = refl
ex-pe-term2 : pe[] term2 ≡ ELam (ELam (EVar hd))
ex-pe-term2 = refl
module Correctness where
open SimpleAEnv
open Exp-Eval
-- TODO: rename occurences of stripα to typeof
stripα = typeof
stripΔ : ACtx → Ctx
stripΔ = map stripα
strip-lookup : ∀ { α Δ} → α ∈ Δ → stripα α ∈ stripΔ Δ
strip-lookup hd = hd
strip-lookup (tl x) = tl (strip-lookup x)
strip : ∀ {α Δ} → AExp Δ α → Exp (stripΔ Δ) (stripα α)
strip (Var x) = EVar (strip-lookup x)
strip (AInt x) = EInt x
strip (AAdd e f) = EAdd (strip e) (strip f)
strip (ALam e) = ELam (strip e)
strip (AApp e f) = EApp (strip e) (strip f)
strip (DInt x) = EInt x
strip (DAdd e f) = EAdd (strip e) (strip f)
strip (DLam e) = ELam (strip e)
strip (DApp e f) = EApp (strip e) (strip f)
strip (Lift e) = strip e
liftE : ∀ {τ Γ Γ'} → Γ ↝ Γ' → Exp Γ τ → Exp Γ' τ
liftE Γ↝Γ' e = elevate (↝↝-base Γ↝Γ') e
stripLift : ∀ {α Δ Γ} → stripΔ Δ ↝ Γ → AExp Δ α → Exp Γ (stripα α)
stripLift Δ↝Γ = liftE Δ↝Γ ∘ strip
-- We want to show that pe preserves the semantics of the
-- program. Roughly, Exp-Eval.ev-ing a stripped program is
-- equivalent to first pe-ing a program and then Exp-Eval.ev-ing the
-- result. But as the pe-result of a static function ``can do more''
-- than the (ev ∘ strip)ped function we need somthing more refined.
module Equiv where
open import Relation.Binary.PropositionalEquality
-- Extending a value environment according to an extension of a
-- type environment
data _⊢_↝_ {Γ} : ∀ {Γ'} → Γ ↝ Γ' → Env Γ → Env Γ' → Set where
refl : ∀ env → ↝-refl ⊢ env ↝ env
extend : ∀ {τ Γ' env env'} → {Γ↝Γ' : Γ ↝ Γ'} →
(v : EImp τ) → (Γ↝Γ' ⊢ env ↝ env') →
↝-extend Γ↝Γ' ⊢ env ↝ (v ∷ env')
env↝trans : ∀ {Γ Γ' Γ''} {Γ↝Γ' : Γ ↝ Γ'} {Γ'↝Γ'' : Γ' ↝ Γ''}
{env env' env''} →
Γ↝Γ' ⊢ env ↝ env' →
Γ'↝Γ'' ⊢ env' ↝ env'' →
let Γ↝Γ'' = ↝-trans Γ↝Γ' Γ'↝Γ'' in
Γ↝Γ'' ⊢ env ↝ env''
-- env↝trans {Γ} {.Γ''} {Γ''} {Γ↝Γ'} {.↝-refl} {env} {.env''} {env''} env↝env' (refl .env'') = env↝env'
-- env↝trans env↝env' (extend v env'↝env'') = extend v (env↝trans env↝env' env'↝env'')
-- TODO: why does this work???
env↝trans {.Γ'} {Γ'} {Γ''} {.↝-refl} {Γ'↝Γ''} {.env'} {env'} (refl .env') env'↝env''
rewrite sym (lem-↝-refl-id Γ'↝Γ'') = env'↝env''
env↝trans (extend v env↝env') env'↝env'' = env↝trans (extend v env↝env') env'↝env''
-- Equivalent Imp Γ α and EImp τ values (where τ = stripα α). As
-- (v : Imp Γ α) is not necessarily closed, equivalence is defined for
-- the closure (Env Γ, ImpΓ α)
Equiv : ∀ {α Γ} → Env Γ → Imp Γ α → EImp (stripα α) → Set
Equiv {AInt} env av v = av ≡ v
Equiv {AFun α₁ α₂} {Γ} env af f = -- extensional equality, given -- an extended context
∀ {Γ' env' Γ↝Γ'} → (Γ↝Γ' ⊢ env ↝ env') →
{ax : Imp Γ' α₁} → {x : EImp (stripα α₁)} →
Equiv env' ax x → Equiv env' (af Γ↝Γ' ax) (f x)
Equiv {D x} {Γ} env av v = ev av env ≡ v -- actually we mean extensional equality
-- Equivalence of AEnv and Env environments. They need to provide
-- Equivalent bindings for a context Δ/stripΔ Δ. Again, the
-- equivalence is defined for a closure (Env Γ', AEnv Γ' Δ).
data Equiv-Env {Γ' : _} (env' : Env Γ') :
∀ {Δ} → let Γ = stripΔ Δ in
AEnv Γ' Δ → Env Γ → Set where
[] : Equiv-Env env' [] []
cons : ∀ {α Δ} → let τ = stripα α
Γ = stripΔ Δ in
{env : Env Γ} → {aenv : AEnv Γ' Δ} →
Equiv-Env env' aenv env →
(va : Imp (Γ') α) → (v : EImp τ) →
Equiv env' va v →
Equiv-Env env' (cons α va (aenv)) (v ∷ env)
-- Now for the proof...
module Proof where
open Equiv
open import Relation.Binary.PropositionalEquality
-- Extensional equality as an axiom to prove the Equivalence of
-- function values. We could (should?) define it locally for
-- Equiv.
postulate ext : ∀ {τ₁ τ₂} {f g : EImp τ₁ → EImp τ₂} →
(∀ x → f x ≡ g x) → f ≡ g
-- Ternary helper relation for environment extensions, analogous to _↝_↝_ for contexts
data _⊢_↝_↝_⊣ : ∀ { Γ Γ' Γ''} → Γ ↝ Γ' ↝ Γ'' → Env Γ → Env Γ' → Env Γ'' → Set where
refl : ∀ {Γ Γ''} {Γ↝Γ'' : Γ ↝ Γ''} { env env'' } →
Γ↝Γ'' ⊢ env ↝ env'' →
↝↝-base Γ↝Γ'' ⊢ env ↝ [] ↝ env'' ⊣
extend : ∀ {Γ Γ' Γ'' τ} {Γ↝Γ'↝Γ'' : Γ ↝ Γ' ↝ Γ''} { env env' env'' } →
Γ↝Γ'↝Γ'' ⊢ env ↝ env' ↝ env'' ⊣ →
(v : EImp τ) → ↝↝-extend Γ↝Γ'↝Γ'' ⊢ (v ∷ env) ↝ (v ∷ env') ↝ (v ∷ env'') ⊣
-- the following lemmas are strong versions of the shifting
-- functions, proving that consistent variable renaming preserves
-- equivalence (and not just typing).
lookup-elevate-≡ : ∀ {τ Γ Γ'} {Γ↝Γ' : Γ ↝ Γ'}
{env : Env Γ} {env' : Env Γ'} →
Γ↝Γ' ⊢ env ↝ env' →
(x : τ ∈ Γ) → lookupE x env ≡ lookupE (elevate-var Γ↝Γ' x) env'
lookup-elevate-≡ {τ} {.Γ'} {Γ'} {.↝-refl} {.env'} {env'} (refl .env') x = refl
lookup-elevate-≡ (extend v env↝env') x = lookup-elevate-≡ env↝env' x
lookup-elevate2-≡ : ∀ {τ Γ Γ' Γ''} {Γ↝Γ'↝Γ'' : Γ ↝ Γ' ↝ Γ''}
{env : Env Γ} {env' : Env Γ'} {env'' : Env Γ''} →
Γ↝Γ'↝Γ'' ⊢ env ↝ env' ↝ env'' ⊣ →
(x : τ ∈ Γ) → lookupE x env ≡ lookupE (elevate-var2 Γ↝Γ'↝Γ'' x) env''
lookup-elevate2-≡ (refl Γ↝Γ') x = lookup-elevate-≡ Γ↝Γ' x
lookup-elevate2-≡ (extend env↝env'↝env'' v) hd = refl
lookup-elevate2-≡ (extend env↝env'↝env'' _) (tl x)
rewrite lookup-elevate2-≡ env↝env'↝env'' x = refl
lem-elevate-≡ : ∀ {τ Γ Γ' Γ''}
{Γ↝Γ'↝Γ'' : Γ ↝ Γ' ↝ Γ''}
{env : Env Γ} {env' : Env Γ'} {env'' : Env Γ''} →
Γ↝Γ'↝Γ'' ⊢ env ↝ env' ↝ env'' ⊣ →
(e : Exp Γ τ) →
ev e env ≡ ev (elevate Γ↝Γ'↝Γ'' e) env''
lem-elevate-≡ env↝env' (EVar x) = lookup-elevate2-≡ env↝env' x
lem-elevate-≡ env↝env' (EInt x) = refl
lem-elevate-≡ env↝env' (EAdd e f) with lem-elevate-≡ env↝env' e | lem-elevate-≡ env↝env' f
... | IA1 | IA2 = cong₂ _+_ IA1 IA2
lem-elevate-≡ {Γ↝Γ'↝Γ'' = Γ↝Γ'↝Γ''}
{env = env}
{env'' = env''}
env↝env' (ELam e) = ext lem-elevate-≡-body
where lem-elevate-≡-body : ∀ x → ev e (x ∷ env) ≡ ev (elevate (↝↝-extend Γ↝Γ'↝Γ'') e) (x ∷ env'')
lem-elevate-≡-body x = lem-elevate-≡ (extend env↝env' x) e
lem-elevate-≡ env↝env' (EApp e f) with lem-elevate-≡ env↝env' e | lem-elevate-≡ env↝env' f
... | IA1 | IA2 = cong₂ (λ f₁ x → f₁ x) IA1 IA2
lem-lift-refl-id : ∀ {α Γ} → let τ = stripα α in
(env : Env Γ) →
(v : EImp τ) (va : Imp Γ α) →
Equiv env va v →
Equiv env (lift α ↝-refl va) v
lem-lift-refl-id {AInt} env v va eq = eq
lem-lift-refl-id {AFun α α₁} {Γ} env v va eq = body
where body : ∀ {Γ'} {env' : Env Γ'} {Γ↝Γ' : Γ ↝ Γ'} →
Γ↝Γ' ⊢ env ↝ env' →
{av' : Imp Γ' α} {v' : EImp (stripα α)} →
Equiv env' av' v' → Equiv env' (va (↝-trans ↝-refl Γ↝Γ') av') (v v')
body {Γ↝Γ' = Γ↝Γ'} env↝env' eq' rewrite sym (lem-↝-refl-id Γ↝Γ') = eq env↝env' eq'
lem-lift-refl-id {D x} env v e eq rewrite sym eq = sym (lem-elevate-≡ (refl (refl env)) e)
-- lifting an Imp does not affect equivalence
lem-lift-equiv : ∀ {α Γ Γ'} → let τ = stripα α in
{Γ↝Γ' : Γ ↝ Γ'} →
(va : Imp Γ α) (v : EImp τ) →
{env : Env Γ} {env' : Env Γ'} →
Γ↝Γ' ⊢ env ↝ env' →
Equiv env va v →
Equiv env' (lift α Γ↝Γ' va) v
lem-lift-equiv va v {.env'} {env'} (refl .env') eq = lem-lift-refl-id env' v va eq
lem-lift-equiv {AInt} va v (extend v₁ env↝env') eq = eq
lem-lift-equiv {AFun α α₁} va v (extend v₁ env↝env') eq =
λ v₁env₁↝env' eq₁ → eq (env↝trans (extend v₁ env↝env') v₁env₁↝env') eq₁
lem-lift-equiv {D x} va v (extend v₁ env↝env') eq
rewrite sym eq = sym (lem-elevate-≡ (refl (extend v₁ env↝env')) va)
lem-equiv-lookup : ∀ {α Δ Γ'} → let Γ = stripΔ Δ in
{ aenv : AEnv Γ' Δ } {env : Env Γ} →
(env' : Env Γ') →
Equiv-Env env' aenv env →
∀ x → Equiv {α} env' (lookup aenv x) (lookupE (strip-lookup x) env)
lem-equiv-lookup env' [] ()
lem-equiv-lookup env' (cons enveq va v eq) hd = eq
lem-equiv-lookup env' (cons enveq va v eq) (tl x) = lem-equiv-lookup env' enveq x
lem-equiv-env-lift-extend :
∀ {σ Γ' Δ} (env' : Env Γ') → let Γ = stripΔ Δ in
{env : Env Γ} {aenv : AEnv Γ' Δ} →
Equiv-Env env' aenv env → (x : EImp σ) →
Equiv-Env (x ∷ env') (liftEnv (↝-extend ↝-refl) aenv) env
lem-equiv-env-lift-extend _ [] x = []
lem-equiv-env-lift-extend env' (cons {α} eqenv va v x) x₁ =
cons (lem-equiv-env-lift-extend env' eqenv x₁)
(lift α (↝-extend ↝-refl) va) v (lem-lift-equiv va v (extend x₁ (refl env')) x)
lem-equiv-env-lift-lift :
∀ {Γ' Γ'' Δ} → let Γ = stripΔ Δ in
{Γ↝Γ' : Γ' ↝ Γ''}
{env' : Env Γ'} {env'' : Env Γ''}
(env'↝env'' : Γ↝Γ' ⊢ env' ↝ env'') →
{env : Env Γ} {aenv : AEnv Γ' Δ} →
Equiv-Env env' aenv env →
Equiv-Env env'' (liftEnv Γ↝Γ' aenv) env
lem-equiv-env-lift-lift env'↝env'' [] = []
lem-equiv-env-lift-lift {Γ↝Γ' = Γ↝Γ'} env'↝env'' (cons {α} eqenv va v x)
with lem-equiv-env-lift-lift env'↝env'' eqenv
... | IA = cons IA (lift α Γ↝Γ' va) v (lem-lift-equiv va v env'↝env'' x)
-- When we partially evaluate somthing under an environment , it
-- will give equivalent results to a ``complete'' evaluation under
-- an equivalent environment
pe-correct : ∀ { α Δ Γ' } → (e : AExp Δ α) →
let Γ = stripΔ Δ in
{aenv : AEnv Γ' Δ} → {env : Env Γ} →
(env' : Env Γ') →
Equiv-Env env' aenv env →
Equiv env' (pe e aenv) (ev (strip e) env)
pe-correct (Var x) env' eqenv = lem-equiv-lookup env' eqenv x
pe-correct (AInt x) env' eqenv = refl
pe-correct (AAdd e f) env' eqenv
rewrite pe-correct e env' eqenv | pe-correct f env' eqenv = refl
pe-correct (ALam e) env' eqenv =
λ {_} {env''} env'↝env'' {av'} {v'} eq →
let eqenv' = (lem-equiv-env-lift-lift env'↝env'' eqenv)
eqenv'' = (cons eqenv' av' v' eq)
in pe-correct e env'' eqenv''
pe-correct (AApp e f) env' eqenv
with pe-correct e env' eqenv | pe-correct f env' eqenv
... | IAe | IAf = IAe (refl env') IAf
pe-correct (DInt x) env' eqenv = refl
pe-correct (DAdd e f) env' eqenv
rewrite pe-correct e env' eqenv | pe-correct f env' eqenv = refl
pe-correct (DLam e) env' eqenv =
ext (λ x → let eqenv' = (lem-equiv-env-lift-extend env' eqenv x)
eqenv'' = (cons eqenv' (EVar hd) x refl)
in pe-correct e (x ∷ env') eqenv'')
pe-correct (DApp e f) {env = env} env' eqenv
with pe-correct f env' eqenv | pe-correct e env' eqenv
... | IA' | IA = cong₂ (λ f x → f x) IA IA'
pe-correct (Lift e) env' eqenv
with pe-correct e env' eqenv
... | IA = IA
-- module PreciseAEnv where
-- open Exp-Eval
-- open import Relation.Binary.PropositionalEquality
-- data AEnv : Ctx → ACtx → Set where
-- [] : AEnv [] []
-- cons : ∀ { Γ Γ' Δ } (α : AType) → Γ ↝ Γ' → Imp Γ' α → AEnv Γ Δ → AEnv Γ' (α ∷ Δ)
-- consD : ∀ {Γ Δ} σ → AEnv Γ Δ → AEnv (σ ∷ Γ) (D σ ∷ Δ)
-- consD σ env = (cons (D σ) (↝-extend {τ = σ} ↝-refl) (EVar hd) (env))
-- lookup : ∀ {α Δ Γ} → AEnv Γ Δ → α ∈ Δ → Imp Γ α
-- lookup (cons α _ v env) hd = v
-- lookup (cons α₁ Γ↝Γ' v env) (tl x) = lookup (cons α₁ Γ↝Γ' v env) (tl x)
-- pe : ∀ {α Δ Γ} → AExp Δ α → AEnv Γ Δ → Imp Γ α
-- pe (Var x) env = lookup env x
-- pe (AInt x) env = x
-- pe (AAdd e₁ e₂) env = pe e₁ env + pe e₂ env
-- pe (ALam {α} e) env = λ Γ↝Γ' → λ y → pe e (cons α Γ↝Γ' y env)
-- pe (AApp e₁ e₂) env = ((pe e₁ env) ↝-refl) (pe e₂ env)
-- pe (DInt x) env = EInt x
-- pe (DAdd e e₁) env = EAdd (pe e env) (pe e₁ env)
-- pe (DLam {σ} e) env = ELam (pe e (consD σ env))
-- pe (DApp e e₁) env = EApp (pe e env) (pe e₁ env)
-- -- What is a suitable environment to interpret an AExp without pe?
-- -- 1-1 mapping from AExp into Exp
-- stripα : AType → Type
-- stripα AInt = Int
-- stripα (AFun α₁ α₂) = Fun (stripα α₁) (stripα α₂)
-- stripα (D x) = x
-- stripΔ : ACtx → Ctx
-- stripΔ = map stripα
-- stripEnv : ∀ {Δ} →
-- let Γ = stripΔ Δ
-- in AEnv Γ Δ → Env Γ
-- stripEnv [] = []
-- stripEnv (cons AInt Γ↝Γ' v env) = v ∷ (stripEnv {!!})
-- stripEnv (cons (AFun α α₁) Γ↝Γ' v env) = {!!}
-- stripEnv (cons (D x) Γ↝Γ' v env) = {!!}
-- -- Extending a value environment according to an extension of a type environment
-- data _⊢_↝_ {Γ} : ∀ {Γ'} → Γ ↝ Γ' → Env Γ → Env Γ' → Set where
-- refl : ∀ env → ↝-refl ⊢ env ↝ env
-- extend : ∀ {τ Γ' env env'} → {Γ↝Γ' : Γ ↝ Γ'} →
-- (v : EImp τ) → (Γ↝Γ' ⊢ env ↝ env') →
-- ↝-extend Γ↝Γ' ⊢ env ↝ (v ∷ env')
-- -- It turns out that we have to shift Exp also
-- liftE : ∀ {τ Γ Γ'} → Γ ↝ Γ' → Exp Γ τ → Exp Γ' τ
-- liftE Γ↝Γ' e = elevate (↝↝-base Γ↝Γ') e
-- Equiv : ∀ {α Γ} → Env Γ → Imp Γ α → EImp (stripα α) → Set
-- Equiv {AInt} env av v = av ≡ v
-- Equiv {AFun α₁ α₂} {Γ} env av v = -- an pe-d static function is
-- -- equivalent to an EImp value
-- -- if given an suitably extended
-- -- environment, evaluating the
-- -- body yields something
-- -- equivalent to the EImp-value
-- ∀ {Γ' env' Γ↝Γ'} → (Γ↝Γ' ⊢ env ↝ env') →
-- {av' : Imp Γ' α₁} → {v' : EImp (stripα α₁)} →
-- Equiv env' av' v' → Equiv env' (av Γ↝Γ' av') (v v')
-- Equiv {D x} {Γ} env av v = ev av env ≡ v
-- data Equiv-Env : ∀ {Δ} → let Γ = stripΔ Δ in
-- AEnv Γ Δ → Env Γ → Set where
-- [] : Equiv-Env [] []
-- -- cons : ∀ {α Δ} → let Γ = stripΔ Δ in
-- -- (va : Imp Γ α) → (v : EImp (stripα α)) →
-- -- (env : Env Γ) → Equiv env v va →
-- -- (aenv : AEnv Γ Δ) →
-- -- Equiv-Env aenv env →
-- -- Equiv-Env {α ∷ Δ} (cons α (lift α (↝-extend ↝-refl) va)
-- -- (liftEnv (↝-extend ↝-refl) aenv))
-- -- (v ∷ env)
| 39.371356
| 107
| 0.53657
|
502bd202274fd2aaf9c1721b8ff9498d6a485694
| 5,098
|
agda
|
Agda
|
src/DTGP.agda
|
larrytheliquid/dtgp
|
31d79242908f2d80ea8e0c02931f4fdc5a3e5d1f
|
[
"MIT"
] | 9
|
2015-07-20T16:46:00.000Z
|
2022-03-19T21:39:58.000Z
|
src/DTGP.agda
|
larrytheliquid/dtgp
|
31d79242908f2d80ea8e0c02931f4fdc5a3e5d1f
|
[
"MIT"
] | null | null | null |
src/DTGP.agda
|
larrytheliquid/dtgp
|
31d79242908f2d80ea8e0c02931f4fdc5a3e5d1f
|
[
"MIT"
] | 2
|
2018-04-17T02:02:58.000Z
|
2022-03-12T11:53:14.000Z
|
open import Relation.Nullary
open import Relation.Binary.PropositionalEquality
module DTGP
{Domain Word : Set}
(pre post : Word → Domain → Domain)
(_≟_ : (x y : Domain) → Dec (x ≡ y))
where
open import Function
open import Relation.Binary
open import Data.Bool hiding (_≟_)
open import Data.Nat hiding (_≥_; _≟_)
open import Data.Fin hiding (_+_; raise)
open import Data.Maybe
open import Data.Product hiding (map; swap)
open import Data.List hiding (length) renaming (_++_ to _l++_)
open import Data.Vec hiding (_++_; _>>=_; concat; map; init)
open import DTGP.Rand
infixr 5 _∷_ _++_ _++'_
data Term (inp : Domain) : Domain → Set where
[] : Term inp inp
_∷_ : ∀ {d} (w : Word) →
Term inp (pre w d) → Term inp (post w d)
_++_ : ∀ {inp mid out} →
Term mid out →
Term inp mid →
Term inp out
[] ++ ys = ys
(x ∷ xs) ++ ys = x ∷ (xs ++ ys)
data Split {inp out} mid : Term inp out → Set where
_++'_ :
(xs : Term mid out)
(ys : Term inp mid) →
Split mid (xs ++ ys)
swap₁ : ∀ {inp mid out} {xs ys : Term inp out} →
Split mid xs → Split mid ys → Term inp out
swap₁ (xs ++' ys) (as ++' bs) = xs ++ bs
swap₂ : ∀ {inp mid out} {xs ys : Term inp out} →
Split mid xs → Split mid ys → Term inp out
swap₂ (xs ++' ys) (as ++' bs) = as ++ ys
swaps : ∀ {inp mid out} {xs ys : Term inp out} →
Split mid xs → Split mid ys →
Term inp out × Term inp out
swaps xs ys = swap₁ xs ys , swap₂ xs ys
split : ∀ {inp out} (n : ℕ) (xs : Term inp out) → ∃ λ mid → Split mid xs
split zero xs = _ , [] ++' xs
split (suc n) [] = _ , [] ++' []
split (suc n) (x ∷ xs) with split n xs
split (suc n) (x ∷ ._) | _ , xs ++' ys = _ , (x ∷ xs) ++' ys
splits : ∀ {inp out} (n : ℕ) mid → (xs : Term inp out) → ∃ (Vec (Split mid xs))
splits zero mid xs with split zero xs
... | mid' , ys with mid ≟ mid'
... | yes p rewrite p = _ , ys ∷ []
... | no p = _ , []
splits (suc n) mid xs with split (suc n) xs
... | mid' , ys with mid ≟ mid' | splits n mid xs
... | yes p | _ , yss rewrite p = _ , ys ∷ yss
... | no p | _ , yss = _ , yss
length : ∀ {inp out} → Term inp out → ℕ
length [] = 0
length (x ∷ xs) = suc (length xs)
split♀ : ∀ {inp out} → (xs : Term inp out) → Rand (∃ λ mid → Split mid xs)
split♀ xs =
rand >>= λ r →
let i = r mod (suc (length xs))
in return (split (toℕ i) xs)
split♂ : ∀ {inp out} (xs : Term inp out) mid →
Maybe (Rand (Split mid xs))
split♂ xs B
with splits (length xs) B xs
... | zero , [] = nothing
... | suc n , xss = just (
rand >>= λ r →
return (lookup (r mod suc n) xss)
)
crossover : ∀ {inp out} (♀ ♂ : Term inp out) →
Rand (Term inp out × Term inp out)
crossover ♀ ♂ =
split♀ ♀ >>= λ b,xs →
maybe′
(_=<<_ (return ∘ (swaps (proj₂ b,xs))))
(return (♀ , ♂))
(split♂ ♂ (proj₁ b,xs))
Population : ∀ inp out n → Set
Population inp out n = Vec (Term inp out) (2 + n)
module Initialization
(match : ∀ w out → Dec (∃ λ d → out ≡ pre w d))
where
toMaybe : ∀ {w inp out} →
Term inp out →
Dec (∃ λ d → out ≡ pre w d) →
Maybe (∃ λ d → Term inp d)
toMaybe {w = w} ws (no _) = nothing
toMaybe {w = w} ws (yes (_ , p))
rewrite p = just (_ , w ∷ ws)
enum-inp : ∀ (n : ℕ) inp → List Word → List (∃ λ out → Term inp out)
enum-inp zero inp ws = gfilter (λ w → toMaybe [] (match w inp)) ws
enum-inp (suc n) A ws
with enum-inp n A ws
... | ih = concat (map (λ out,t → gfilter (λ w →
toMaybe (proj₂ out,t) (match w (proj₁ out,t))
) ws) ih) l++ ih
filter-out : ∀ {inp} out → List (∃ (Term inp)) → List (Term inp out)
filter-out out [] = []
filter-out out ((out' , x) ∷ xs)
with out' ≟ out
... | no p = filter-out out xs
... | yes p rewrite p = x ∷ filter-out out xs
init : ∀ (n : ℕ) inp out → List Word → List (Term inp out)
init n inp out ws = filter-out out (enum-inp n inp ws)
module Evolution {inp out} (score : Term inp out → ℕ) where
_≥_ : ℕ → ℕ → Bool
zero ≥ zero = true
zero ≥ (suc n) = false
(suc m) ≥ zero = true
(suc m) ≥ (suc n) = m ≥ n
select : ∀ {n} →
Population inp out n → Rand (Term inp out)
select {n = n} xss =
rand >>= λ ii →
rand >>= λ jj →
let ♀ = lookup (ii mod (2 + n)) xss
♂ = lookup (jj mod (2 + n)) xss
in return $
if score ♀ ≥ score ♂
then ♀ else ♂
breed2 : ∀ {n} →
Population inp out n →
Rand (Term inp out × Term inp out)
breed2 xss =
select xss >>= λ ♀ →
select xss >>= λ ♂ →
crossover ♀ ♂
breedN : ∀ {m} → (n : ℕ) →
Population inp out m →
Rand (Vec (Term inp out) n)
breedN zero xss = return []
breedN (suc n) xss =
breed2 xss >>= λ offspring →
breedN n xss >>= λ ih →
return (proj₁ offspring ∷ ih)
evolve1 : ∀ {n} →
Population inp out n → Rand (Population inp out n)
evolve1 xss = breedN _ xss
evolveN : ∀ {n} → (gens : ℕ) →
Population inp out n → Rand (Population inp out n)
evolveN zero xss = return xss
evolveN (suc gens) xss =
evolveN gens xss >>= evolve1
evolve : ∀ {n} → (seed gens : ℕ) →
Population inp out n → Population inp out n
evolve seed gens xss =
runRand (evolveN gens xss) seed
| 28.010989
| 79
| 0.557866
|
12fdbed078bbf844e97548c684d16aebeab15679
| 536
|
agda
|
Agda
|
test/Succeed/Issue4010.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | null | null | null |
test/Succeed/Issue4010.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | null | null | null |
test/Succeed/Issue4010.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | null | null | null |
-- Andreas, 2019-08-19, issue #4010
-- unquoteDef and unquoteDecl should also work in abstract blocks.
open import Agda.Builtin.Reflection renaming (bindTC to _>>=_)
open import Agda.Builtin.List
abstract
data D : Set where
c : D
f : D
unquoteDef f = do
qc ← quoteTC c -- Previously, there was a complaint here about c.
defineFun f (clause [] [] qc ∷ [])
unquoteDecl g = do
ty ← quoteTC D
_ ← declareDef (arg (arg-info visible relevant) g) ty
qc ← quoteTC c
defineFun g (clause [] [] qc ∷ [])
| 24.363636
| 70
| 0.647388
|
1ddc31778804f4e778e6acad4d2a02f3fbfb603f
| 3,337
|
agda
|
Agda
|
agda-stdlib/src/Reflection/Pattern.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/src/Reflection/Pattern.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Reflection/Pattern.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Patterns used in the reflection machinery
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Reflection.Pattern where
open import Data.List.Base hiding (_++_)
open import Data.List.Properties
open import Data.Product
open import Data.String as String using (String; braces; parens; _++_; _<+>_)
import Reflection.Literal as Literal
import Reflection.Name as Name
open import Relation.Nullary
open import Relation.Nullary.Decidable as Dec
open import Relation.Nullary.Product using (_×-dec_)
open import Relation.Binary
open import Relation.Binary.PropositionalEquality
open import Reflection.Argument
open import Reflection.Argument.Visibility using (Visibility); open Visibility
open import Reflection.Argument.Relevance using (Relevance); open Relevance
open import Reflection.Argument.Information using (ArgInfo); open ArgInfo
------------------------------------------------------------------------
-- Re-exporting the builtin type and constructors
open import Agda.Builtin.Reflection public using (Pattern)
open Pattern public
------------------------------------------------------------------------
-- Decidable equality
con-injective₁ : ∀ {c c′ args args′} → con c args ≡ con c′ args′ → c ≡ c′
con-injective₁ refl = refl
con-injective₂ : ∀ {c c′ args args′} → con c args ≡ con c′ args′ → args ≡ args′
con-injective₂ refl = refl
con-injective : ∀ {c c′ args args′} → con c args ≡ con c′ args′ → c ≡ c′ × args ≡ args′
con-injective = < con-injective₁ , con-injective₂ >
var-injective : ∀ {x y} → var x ≡ var y → x ≡ y
var-injective refl = refl
lit-injective : ∀ {x y} → Pattern.lit x ≡ lit y → x ≡ y
lit-injective refl = refl
proj-injective : ∀ {x y} → proj x ≡ proj y → x ≡ y
proj-injective refl = refl
_≟s_ : Decidable (_≡_ {A = Args Pattern})
_≟_ : Decidable (_≡_ {A = Pattern})
con c ps ≟ con c′ ps′ = Dec.map′ (uncurry (cong₂ con)) con-injective (c Name.≟ c′ ×-dec ps ≟s ps′)
var s ≟ var s′ = Dec.map′ (cong var) var-injective (s String.≟ s′)
lit l ≟ lit l′ = Dec.map′ (cong lit) lit-injective (l Literal.≟ l′)
proj a ≟ proj a′ = Dec.map′ (cong proj) proj-injective (a Name.≟ a′)
con x x₁ ≟ dot = no (λ ())
con x x₁ ≟ var x₂ = no (λ ())
con x x₁ ≟ lit x₂ = no (λ ())
con x x₁ ≟ proj x₂ = no (λ ())
con x x₁ ≟ absurd = no (λ ())
dot ≟ con x x₁ = no (λ ())
dot ≟ dot = yes refl
dot ≟ var x = no (λ ())
dot ≟ lit x = no (λ ())
dot ≟ proj x = no (λ ())
dot ≟ absurd = no (λ ())
var s ≟ con x x₁ = no (λ ())
var s ≟ dot = no (λ ())
var s ≟ lit x = no (λ ())
var s ≟ proj x = no (λ ())
var s ≟ absurd = no (λ ())
lit x ≟ con x₁ x₂ = no (λ ())
lit x ≟ dot = no (λ ())
lit x ≟ var _ = no (λ ())
lit x ≟ proj x₁ = no (λ ())
lit x ≟ absurd = no (λ ())
proj x ≟ con x₁ x₂ = no (λ ())
proj x ≟ dot = no (λ ())
proj x ≟ var _ = no (λ ())
proj x ≟ lit x₁ = no (λ ())
proj x ≟ absurd = no (λ ())
absurd ≟ con x x₁ = no (λ ())
absurd ≟ dot = no (λ ())
absurd ≟ var _ = no (λ ())
absurd ≟ lit x = no (λ ())
absurd ≟ proj x = no (λ ())
absurd ≟ absurd = yes refl
[] ≟s [] = yes refl
(arg i p ∷ xs) ≟s (arg j q ∷ ys) = ∷-dec (unArg-dec (p ≟ q)) (xs ≟s ys)
[] ≟s (_ ∷ _) = no λ()
(_ ∷ _) ≟s [] = no λ()
| 33.039604
| 98
| 0.560084
|
2f8a98ee76fefb80066a50ca9a9e97c7b69d0414
| 312
|
agda
|
Agda
|
Data/Binary/Proofs.agda
|
oisdk/agda-binary
|
92af4d620febd47a9791d466d747278dc4a417aa
|
[
"MIT"
] | 1
|
2019-03-21T21:30:10.000Z
|
2019-03-21T21:30:10.000Z
|
Data/Binary/Proofs.agda
|
oisdk/agda-binary
|
92af4d620febd47a9791d466d747278dc4a417aa
|
[
"MIT"
] | null | null | null |
Data/Binary/Proofs.agda
|
oisdk/agda-binary
|
92af4d620febd47a9791d466d747278dc4a417aa
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
module Data.Binary.Proofs where
open import Data.Binary.Proofs.Multiplication using (*-homo)
open import Data.Binary.Proofs.Addition using (+-homo)
open import Data.Binary.Proofs.Unary using (inc-homo)
open import Data.Binary.Proofs.Bijection using (𝔹↔ℕ)
| 34.666667
| 62
| 0.714744
|
59945a9d43a0c12fb38fbbe1f82be6bc31ad1dcf
| 883
|
agda
|
Agda
|
test/fail/Issue503.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | 1
|
2019-11-27T07:26:06.000Z
|
2019-11-27T07:26:06.000Z
|
test/fail/Issue503.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
test/fail/Issue503.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
-- div shouldn't termination check, but it also shouldn't make the termination
-- checker loop.
module Issue503 where
data Bool : Set where
true : Bool
false : Bool
if_then_else_ : {C : Set} -> Bool -> C -> C -> C
if true then a else b = a
if false then a else b = b
data Nat : Set where
zero : Nat
succ : Nat -> Nat
pred : Nat -> Nat
pred zero = zero
pred (succ n) = n
_+_ : Nat -> Nat -> Nat
zero + b = b
succ a + b = succ (a + b)
_*_ : Nat -> Nat -> Nat
zero * _ = zero
succ a * b = (a * b) + b
{-# BUILTIN NATURAL Nat #-}
{-# BUILTIN ZERO zero #-}
{-# BUILTIN SUC succ #-}
{-# BUILTIN NATPLUS _+_ #-}
{-# BUILTIN NATTIMES _*_ #-}
_-_ : Nat -> Nat -> Nat
a - zero = a
a - succ b = pred (a - b)
_<_ : Nat -> Nat -> Bool
a < zero = false
zero < succ b = true
succ a < succ b = a < b
div : Nat -> Nat -> Nat
div m n = if (m < n) then zero else succ (div (m - n) n)
| 19.195652
| 78
| 0.570781
|
fba4250e9a7d132dfbbeceb8ba9e389f78ad831f
| 357
|
agda
|
Agda
|
test/Fail/IrrelevantFin.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/IrrelevantFin.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/IrrelevantFin.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2011-04-07
module IrrelevantFin 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)
-- this should not type check, since irrelevant n cannot appear in Fin n
-- or Fin (suc c)
-- note: this is possible in ICC*, but not in Agda!
| 23.8
| 72
| 0.619048
|
31bab9ded5314949c629f47299cf3f70319f6a3e
| 17,169
|
agda
|
Agda
|
agda/course/2017-conor_mcbride_cs410/CS410-17-master/lectures/Lec4.agda
|
haroldcarr/learn-haskell-coq-ml-etc
|
3dc7abca7ad868316bb08f31c77fbba0d3910225
|
[
"Unlicense"
] | 36
|
2015-01-29T14:37:15.000Z
|
2021-07-30T06:55:03.000Z
|
agda/course/2017-conor_mcbride_cs410/CS410-17-master/lectures/Lec4.agda
|
haroldcarr/learn-haskell-coq-ml-etc
|
3dc7abca7ad868316bb08f31c77fbba0d3910225
|
[
"Unlicense"
] | null | null | null |
agda/course/2017-conor_mcbride_cs410/CS410-17-master/lectures/Lec4.agda
|
haroldcarr/learn-haskell-coq-ml-etc
|
3dc7abca7ad868316bb08f31c77fbba0d3910225
|
[
"Unlicense"
] | 8
|
2015-04-13T21:40:15.000Z
|
2021-09-21T15:58:10.000Z
|
{-# OPTIONS --type-in-type #-} -- yes, there will be some cheating in this lecture
module Lec4 where
open import Lec1Done
open import Lec2Done
open import Lec3Done
-- the identity functor (the identity action on objects and arrows)
ID : {C : Category} -> C => C
ID = id~> where open Category CATEGORY
-- composition of functors (composition of actions on objects and arrows)
_>F>_ : {C D E : Category} -> (C => D) -> (D => E) -> (C => E)
F >F> G = F >~> G where open Category CATEGORY
-- EXAMPLES
data Maybe (X : Set) : Set where
yes : (x : X) -> Maybe X
no : Maybe X
{-# COMPILE GHC Maybe = data Maybe (Just | Nothing) #-}
maybe : {X Y : Set} -> (X -> Y) -> Maybe X -> Maybe Y
maybe f (yes x) = yes (f x)
maybe f no = no
MAYBE : SET => SET
MAYBE = record
{ F-Obj = Maybe
; F-map = maybe
; F-map-id~> = extensionality \ { (yes x) -> refl (yes x) ; no -> refl no }
-- extensionality \ { (yes x) -> refl (yes x) ; no -> refl no }
; F-map->~> = \ f g -> extensionality \ { (yes x) -> refl (yes (g (f x))) ; no -> refl no }
}
module MAYBE-CAT where
open Category SET
open _=>_ MAYBE
{-
unMaybe : {T : Set} -> Maybe T -> T
unMaybe (yes t) = t
unMaybe no = {!!}
-}
joinMaybe : {T : Set} -> Maybe (Maybe T) -> Maybe T
joinMaybe (yes mt) = mt
joinMaybe no = no
MAYBE-CAT : Category
MAYBE-CAT = record
{ Obj = Set
; _~>_ = \ S T -> S -> Maybe T
; id~> = yes
; _>~>_ = \ f g -> f >> (F-map g >> joinMaybe)
; law-id~>>~> = \ f -> refl f
; law->~>id~> = \ f -> extensionality \ x -> help f x
; law->~>>~> = \ f g h -> extensionality \ x -> yelp f g h x
} where
help : forall {S T} (f : S -> Maybe T)
(x : S) ->
joinMaybe (maybe yes (f x)) == f x
help f x with f x
help f x | yes y = refl (yes y)
help f x | no = refl no
yelp : forall {Q R S T}
(f : Q -> Maybe R) (g : R -> Maybe S)(h : S -> Maybe T)
(x : Q) ->
joinMaybe (maybe h (joinMaybe (maybe g (f x)))) ==
joinMaybe
(maybe (\ y → joinMaybe (maybe h (g y))) (f x))
yelp f g h x with f x
yelp f g h x | yes y = refl (joinMaybe (maybe h (g y)))
yelp f g h x | no = refl no
open MAYBE-CAT
module NATURAL-TRANSFORMATION {C D : Category} where
open Category
open _=>_
record _~~>_ (F G : C => D) : Set where
field
-- one operation
xf : {X : Obj C} -> _~>_ D (F-Obj F X) (F-Obj G X)
-- one law
naturality : {X Y : Obj C}(f : _~>_ C X Y) ->
_>~>_ D (F-map F f) (xf {Y})
==
_>~>_ D (xf {X}) (F-map G f)
module FUNCTOR-CP {C D E : Category} where
open _=>_
open Category
_>=>_ : C => D -> D => E -> C => E
F-Obj (F >=> G) = F-Obj F >> F-Obj G
F-map (F >=> G) = F-map F >> F-map G
F-map-id~> (F >=> G) =
F-map G (F-map F (id~> C))
=[ refl (F-map G) =$= F-map-id~> F >=
F-map G (id~> D)
=[ F-map-id~> G >=
id~> E
[QED]
F-map->~> (F >=> G) f g =
F-map G (F-map F (_>~>_ C f g))
=[ refl (F-map G) =$= F-map->~> F f g >=
F-map G (_>~>_ D (F-map F f) (F-map F g))
=[ F-map->~> G (F-map F f) (F-map F g) >=
_>~>_ E (F-map G (F-map F f)) (F-map G (F-map F g))
[QED]
open FUNCTOR-CP
open NATURAL-TRANSFORMATION public
open _~~>_ public
UNIT-MAYBE : ID ~~> MAYBE
xf UNIT-MAYBE = yes
naturality UNIT-MAYBE f = refl _
MULT-MAYBE : (MAYBE >=> MAYBE) ~~> MAYBE
MULT-MAYBE = record { xf = joinMaybe
; naturality = \ f -> extensionality \ {
(yes x) → refl (maybe f x)
; no → refl no } }
module MONAD {C : Category}(M : C => C) where
open Category C
open _=>_ M
record Monad : Set where
field
unit : ID ~~> M
mult : (M >=> M) ~~> M
unitMult : {X : Obj} -> (xf unit >~> xf mult) == id~> {F-Obj X}
multUnit : {X : Obj} -> (F-map (xf unit) >~> xf mult) == id~> {F-Obj X}
multMult : {X : Obj} -> (xf mult >~> xf mult) == (F-map (xf mult) >~> xf mult {X})
KLEISLI : Category
KLEISLI = record
{ Obj = Obj
; _~>_ = \ S T -> S ~> F-Obj T
; id~> = xf unit
; _>~>_ = \ f g -> f >~> F-map g >~> xf mult
; law-id~>>~> = \ f ->
xf unit >~> F-map f >~> xf mult
=< law->~>>~> _ _ _ ]=
(xf unit >~> F-map f) >~> xf mult
=< refl (_>~> xf mult) =$= naturality unit f ]=
(f >~> xf unit) >~> xf mult
=[ law->~>>~> _ _ _ >=
f >~> (xf unit >~> xf mult)
=[ refl (f >~>_) =$= unitMult >=
f >~> id~>
=[ law->~>id~> f >=
f [QED]
; law->~>id~> = \ f ->
f >~> (F-map (xf unit) >~> xf mult)
=[ refl (f >~>_) =$= multUnit >=
f >~> id~>
=[ law->~>id~> f >=
f [QED]
; law->~>>~> = \ f g h ->
(f >~> F-map g >~> xf mult) >~> F-map h >~> xf mult
=[ law->~>>~> _ _ _ >=
f >~> (F-map g >~> xf mult) >~> (F-map h >~> xf mult)
=[ refl (\ x -> _ >~> x) =$= law->~>>~> _ _ _ >=
f >~> F-map g >~> xf mult >~> F-map h >~> xf mult
=< refl (\ x -> _ >~> _ >~> x) =$= assocn (naturality mult _) ]=
f >~> F-map g >~> F-map (F-map h) >~> xf mult >~> xf mult
=[ refl (\ x -> _ >~> _ >~> _ >~> x) =$= multMult >=
f >~> F-map g >~> F-map (F-map h) >~> F-map (xf mult) >~> xf mult
=< refl (\ x -> _ >~> _ >~> x) =$= law->~>>~> _ _ _ ]=
f >~> F-map g >~> (F-map (F-map h) >~> F-map (xf mult)) >~> xf mult
=< refl (\ x -> _ >~> _ >~> x >~> _) =$= F-map->~> _ _ ]=
f >~> F-map g >~> F-map (F-map h >~> xf mult) >~> xf mult
=< refl (\ x -> _ >~> x) =$= law->~>>~> _ _ _ ]=
f >~> (F-map g >~> F-map (F-map h >~> xf mult)) >~> xf mult
=< refl (\ x -> _ >~> x >~> _) =$= F-map->~> _ _ ]=
f >~> F-map (g >~> F-map h >~> xf mult) >~> xf mult
[QED]
}
open MONAD public
MAYBE-Monad : Monad MAYBE
MAYBE-Monad = record
{ unit = UNIT-MAYBE
; mult = MULT-MAYBE
; unitMult = refl _
; multUnit = extensionality \ { (yes x) -> refl _ ; no -> refl _ }
; multMult = extensionality \ { (yes mmx) -> refl _ ; no -> refl _ }
}
data List (X : Set) : Set where
[] : List X
_,-_ : (x : X)(xs : List X) -> List X
{-# COMPILE GHC List = data [] ([] | (:)) #-}
list : {X Y : Set} -> (X -> Y) -> List X -> List Y
list f [] = []
list f (x ,- xs) = f x ,- list f xs
LIST : SET => SET
LIST = record
{ F-Obj = List
; F-map = list
; F-map-id~> = extensionality listId
; F-map->~> = \ f g -> extensionality (listCp f g)
} where
open Category SET
listId : {T : Set}(xs : List T) -> list id xs == xs
listId [] = refl []
listId (x ,- xs) = refl (_,-_ x) =$= listId xs
listCp : {R S T : Set} (f : R -> S) (g : S -> T) (xs : List R) →
list (f >~> g) xs == (list f >~> list g) xs
listCp f g [] = refl []
listCp f g (x ,- xs) = refl (_,-_ (g (f x))) =$= listCp f g xs
data Two : Set where tt ff : Two
{- BUILTIN BOOL Two -}
{- BUILTIN FALSE ff -}
{- BUILTIN TRUE tt -}
{-# COMPILE GHC Two = data Bool (True | False) #-}
data BitProcess (X : Set) : Set where -- in what way is X used?
stop : (x : X) -> BitProcess X -- stop with value x
send : (b : Two)(k : BitProcess X) -> BitProcess X -- send b, continue as k
recv : (kt kf : BitProcess X) -> BitProcess X -- receive bit, continue as
-- kt if tt, kf if ff
{-(-}
send1 : (b : Two) -> BitProcess One
send1 b = send b (stop <>)
{-)-}
{-(-}
recv1 : BitProcess Two
recv1 = recv (stop tt) (stop ff)
{-)-}
{-(-}
bpRun : forall {X} -> BitProcess X -- a process to run
-> List Two -- a list of bits waiting to be input
-> List Two -- the list of bits output
* Maybe -- and, if we don't run out of input
( X -- the resulting value
* List Two -- and the unused input
)
bpRun (stop x) bs = [] , yes (x , bs)
bpRun (send b px) bs = let os , mz = bpRun px bs in (b ,- os) , mz
bpRun (recv pxt pxf) [] = [] , no
bpRun (recv pxt pxf) (tt ,- bs) = bpRun pxt bs
bpRun (recv pxt pxf) (ff ,- bs) = bpRun pxf bs
{-)-}
example = bpRun recv1 (tt ,- [])
bitProcess : {X Y : Set} -> (X -> Y) -> BitProcess X -> BitProcess Y
bitProcess f (stop x) = stop (f x)
bitProcess f (send b k) = send b (bitProcess f k)
bitProcess f (recv kt kf) = recv (bitProcess f kt) (bitProcess f kf)
BITPROCESS : SET => SET -- actions on *values* lift to processes
BITPROCESS = record
{ F-Obj = BitProcess
; F-map = bitProcess
; F-map-id~> = extensionality helpId
; F-map->~> = \ f g -> extensionality (helpCp f g)
} where
open Category SET
helpId : {T : Set} (p : BitProcess T) -> bitProcess id p == p
helpId (stop x) = refl (stop x)
helpId (send b k) rewrite helpId k = refl (send b k)
helpId (recv kt kf) rewrite helpId kt | helpId kf = refl (recv kt kf)
helpCp : {R S T : Set} (f : R -> S)(g : S -> T) (p : BitProcess R) ->
bitProcess (f >~> g) p == (bitProcess f >~> bitProcess g) p
helpCp f g (stop x) = refl (stop (g (f x)))
helpCp f g (send b k) rewrite helpCp f g k = refl (send b (bitProcess g (bitProcess f k)))
helpCp f g (recv kt kf) rewrite helpCp f g kt | helpCp f g kf
= refl (recv (bitProcess g (bitProcess f kt)) (bitProcess g (bitProcess f kf)))
{-(-}
UNIT-BP : ID ~~> BITPROCESS
UNIT-BP = record { xf = stop
; naturality = \ f -> refl _
}
{-)-}
join-BP : {X : Set} -> BitProcess (BitProcess X) -> BitProcess X
join-BP (stop px) = px
join-BP (send b ppx) = send b (join-BP ppx)
join-BP (recv ppxt ppxf) = recv (join-BP ppxt) (join-BP ppxf)
{-(-}
MULT-BP : (BITPROCESS >=> BITPROCESS) ~~> BITPROCESS
MULT-BP = record
{ xf = join-BP
; naturality = \ f -> extensionality (help f )
} where
help : ∀ {X Y} (f : X → Y) (x : BitProcess (BitProcess X)) →
join-BP (bitProcess (bitProcess f) x) == bitProcess f (join-BP x)
help f (stop x) = refl (bitProcess f x)
help f (send b p) rewrite help f p
= refl (send b (bitProcess f (join-BP p)))
help f (recv pt pf) rewrite help f pf | help f pt
= refl (recv (bitProcess f (join-BP pt)) (bitProcess f (join-BP pf)))
{-)-}
{-(-}
BITPROCESS-Monad : Monad BITPROCESS
BITPROCESS-Monad = record
{ unit = UNIT-BP
; mult = MULT-BP
; unitMult = refl id
; multUnit = extensionality help
; multMult = extensionality yelp
} where
help : ∀ {X} (x : BitProcess X) → join-BP (bitProcess stop x) == x
help (stop x) = refl (stop x)
help (send b p) rewrite help p = refl (send b p)
help (recv pt pf) rewrite help pt | help pf = refl (recv pt pf)
yelp : ∀ {X} (x : BitProcess (BitProcess (BitProcess X))) →
join-BP (join-BP x) == join-BP (bitProcess join-BP x)
yelp (stop x) = refl _
yelp (send b p) rewrite yelp p = refl _
yelp (recv pt pf) rewrite yelp pt | yelp pf = refl _
{-)-}
module BIND {F : SET => SET}(M : Monad F) where
open _=>_ F public
open Monad M public
open Category KLEISLI public
{-(-}
_>>=_ : {S T : Set} -> F-Obj S -> (S -> F-Obj T) -> F-Obj T
fs >>= k = (id >~> k) fs
{-)-}
open BIND BITPROCESS-Monad
bpEcho : BitProcess One
bpEcho = recv1 >>= \ b ->
send1 b
BP-SEM : Set -> Set
BP-SEM X = List Two -- a list of bits waiting to be input
-> List Two -- the list of bits output
* Maybe -- and, if we don't run out of input
( X -- the resulting value
* List Two -- and the unused input
)
record _**_ (S T : Set) : Set where
constructor _,_
field
outl : S
outr : T
open _**_
{-# COMPILE GHC _**_ = data (,) ((,)) #-}
infixr 4 _**_ _,_
postulate -- Haskell has a monad for doing IO, which we use at the top level
IO : Set -> Set
mainLoop : {S : Set} -> S -> (S -> Two -> (List Two ** Maybe S)) -> IO One
mainOutIn : {S : Set} -> S -> (S -> (List Two ** Maybe (Two -> S))) -> IO One
{-# BUILTIN IO IO #-}
{-# COMPILE GHC IO = type IO #-}
{-# COMPILE GHC mainLoop = (\ _ -> Lec4HS.mainLoop) #-}
{-# COMPILE GHC mainOutIn = (\ _ -> Lec4HS.mainOutIn) #-}
{-# FOREIGN GHC import qualified Lec4HS #-}
STATE : Set
STATE = Two -> BitProcess One
step : STATE -> Two -> (List Two ** Maybe STATE)
step s b = go (s b)
where
go : BitProcess One → List Two ** Maybe (Two → BitProcess One)
go (stop <>) = [] , no
go (send b p) with go p
... | bs , ms = (b ,- bs) , ms
go (recv pt pf) = [] , yes \ { tt → pt ; ff → pf }
myState : STATE
myState tt = bpEcho >>= \ _ -> bpEcho
myState ff = bpEcho
{-
main : IO One
main = mainLoop myState step
-}
example2 = bpRun (myState ff) (tt ,- ff ,- [])
outIn : BitProcess One -> List Two ** Maybe (Two -> BitProcess One)
outIn (stop <>) = [] , no
outIn (send b p) with outIn p
... | os , mk = (b ,- os) , mk
outIn (recv pt pf) = [] , yes \ { tt → pt ; ff → pf }
main : IO One
main = mainOutIn (send1 ff >>= \ _ -> bpEcho >>= \ _ -> bpEcho) outIn
_-:>_ : {I : Set} -> (I -> Set) -> (I -> Set) -> (I -> Set)
(S -:> T) i = S i -> T i
[_] : {I : Set} -> (I -> Set) -> Set
[ P ] = forall i -> P i -- [_] {I} P = (i : I) -> P i
_->SET : Set -> Category
I ->SET = record
{ Obj = I -> Set -- I-indexed sets
; _~>_ = \ S T -> [ S -:> T ] -- index-respecting functions
; id~> = \ i -> id -- the identity at every index
; _>~>_ = \ f g i -> f i >> g i -- composition at every index
; law-id~>>~> = refl -- and the laws are very boring
; law->~>id~> = refl
; law->~>>~> = \ f g h -> refl _
}
All : {X : Set} -> (X -> Set) -> (List X -> Set)
All P [] = One
All P (x ,- xs) = P x * All P xs
example3 : All (Vec Two) (1 ,- 2 ,- 3 ,- [])
example3 = (tt ,- [])
, (tt ,- ff ,- [])
, (tt ,- ff ,- tt ,- [])
, <>
record _|>_ (I O : Set) : Set where
field
Cuts : O -> Set -- given o : O, how may we cut it?
inners : {o : O} -> Cuts o -> List I -- given how we cut it, what are
-- the shapes of its pieces?
-- Let us have some examples right away!
copy : Nat -> List One
copy zero = []
copy (suc n) = <> ,- copy n
VecCut : One |> Nat -- cut numbers into boring pieces
VecCut = record
{ Cuts = \ n -> One -- there is one way to cut n
; inners = \ {n} _ -> copy n -- and you get n pieces
}
-- Here's a less boring example. You can cut a number into *two* pieces
-- by finding two numbers that add to it.
NatCut : Nat |> Nat
NatCut = record
{ Cuts = \ mn -> Sg Nat \ m -> Sg Nat \ n -> (m +N n) == mn
; inners = \ { (m , n , _) -> m ,- n ,- [] }
}
-- The point is that we can make data structures that record how we
-- built an O-shaped thing from I-shaped pieces.
record Cutting {I O}(C : I |> O)(P : I -> Set)(o : O) : Set where
constructor _8><_ -- "scissors"
open _|>_ C
field
cut : Cuts o -- we decide how to cut o
pieces : All P (inners cut) -- then we give all the pieces.
infixr 3 _8><_
example4 : Cutting NatCut (Vec Two) 5
example4 = (3 , 2 , refl 5) 8>< ((tt ,- tt ,- tt ,- []) , (ff ,- ff ,- []) , <>)
data Interior {I}(C : I |> I)(T : I -> Set)(i : I) : Set where
-- either...
tile : T i -> Interior C T i -- we have a tile that fits, or...
<_> : Cutting C (Interior C T) i -> -- ...we cut, then tile the pieces.
Interior C T i
MayC : One |> One
MayC = record { Cuts = \ _ -> One ; inners = \ _ -> [] }
Maybe' : Set -> Set
Maybe' X = Interior MayC (\ _ -> X) <>
yes' : {X : Set} -> X -> Maybe' X
yes' x = tile x
no' : {X : Set} -> Maybe' X
no' = < <> 8>< <> >
BPC : One |> One
BPC = record { Cuts = \ _ -> Two + One
; inners = \ { (inl x) → <> ,- []
; (inr x) → <> ,- <> ,- []
}
}
data Type : Set where nat two : Type
Val : Type -> Set
Val nat = Nat
Val two = Two
data Op : Type -> Set where
val : {T : Type} -> Val T -> Op T
add : Op nat
if : {T : Type} -> Op T
Syntax : Type |> Type
_|>_.Cuts Syntax T = Op T
_|>_.inners Syntax {T} (val x) = []
_|>_.inners Syntax {.nat} add = nat ,- nat ,- []
_|>_.inners Syntax {T} if = two ,- T ,- T ,- []
eval : {T : Type}{X : Type -> Set} -> Interior Syntax X T ->
({T : Type} -> X T -> Val T) -> Val T
eval (tile x) g = g x
eval < val v 8>< <> > g = v
eval < add 8>< e1 , e2 , <> > g = eval e1 g +N eval e2 g
eval < if 8>< e1 , e2 , e3 , <> > g with eval e1 g
eval < if 8>< e1 , e2 , e3 , <> > g | tt = eval e2 g
eval < if 8>< e1 , e2 , e3 , <> > g | ff = eval e3 g
| 31.273224
| 93
| 0.478362
|
1de94c62b949743b2b972fe536cbbbbfe82fc982
| 6,035
|
agda
|
Agda
|
src/CategoryTheory/BCCCs/Cartesian.agda
|
DimaSamoz/temporal-type-systems
|
7d993ba55e502d5ef8707ca216519012121a08dd
|
[
"MIT"
] | 4
|
2018-05-31T20:37:04.000Z
|
2022-01-04T09:33:48.000Z
|
src/CategoryTheory/BCCCs/Cartesian.agda
|
DimaSamoz/temporal-type-systems
|
7d993ba55e502d5ef8707ca216519012121a08dd
|
[
"MIT"
] | null | null | null |
src/CategoryTheory/BCCCs/Cartesian.agda
|
DimaSamoz/temporal-type-systems
|
7d993ba55e502d5ef8707ca216519012121a08dd
|
[
"MIT"
] | null | null | null |
-- Products and Cartesian categories
module CategoryTheory.BCCCs.Cartesian where
open import CategoryTheory.Categories
open import Relation.Binary using (IsEquivalence)
module _ {n} (ℂ : Category n) where
open Category ℂ
-- Terminal object in a category
record TerminalObj : Set (lsuc n) where
field
-- | Data
-- The terminal object
⊤ : obj
-- Canonical morphism
! : {A : obj} -> (A ~> ⊤)
-- | Laws
-- Need to show that the canonical morphism ! is unique
!-unique : {A : obj} -> (m : A ~> ⊤)
-> m ≈ !
-- Product of two objects
-- Based on github.com/copumpkin/categories
record Product (A B : obj) : Set (lsuc n) where
infix 10 ⟨_,_⟩
field
-- | Data
-- Product of A and B
A⊗B : obj
-- First projection
π₁ : A⊗B ~> A
-- Second projection
π₂ : A⊗B ~> B
-- Canonical mediator
⟨_,_⟩ : ∀{P} -> (P ~> A) -> (P ~> B) -> (P ~> A⊗B)
-- | Laws
-- ⟨_,_⟩ expresses that given another candidate product C
-- and candidate projections to A and B there is a morphism
-- from P to A⊗B. We need to check that this mediator makes
-- the product diagram commute and is unique.
π₁-comm : ∀{P} -> {p₁ : P ~> A} {p₂ : P ~> B}
-> π₁ ∘ ⟨ p₁ , p₂ ⟩ ≈ p₁
π₂-comm : ∀{P} -> {p₁ : P ~> A} {p₂ : P ~> B}
-> π₂ ∘ ⟨ p₁ , p₂ ⟩ ≈ p₂
⊗-unique : ∀{P} -> {p₁ : P ~> A} {p₂ : P ~> B} {m : P ~> A⊗B}
-> π₁ ∘ m ≈ p₁ -> π₂ ∘ m ≈ p₂ -> ⟨ p₁ , p₂ ⟩ ≈ m
-- η-expansion of function pairs (via morphisms)
⊗-η-exp : ∀{P} -> {m : P ~> A⊗B}
-> ⟨ π₁ ∘ m , π₂ ∘ m ⟩ ≈ m
⊗-η-exp = ⊗-unique r≈ r≈
-- Pairing of projection functions is the identity
⊗-η-id : ⟨ π₁ , π₂ ⟩ ≈ id
⊗-η-id = ⊗-unique id-right id-right
-- Congruence over function pairing
⟨,⟩-cong : ∀{P} -> {p₁ q₁ : P ~> A} {p₂ q₂ : P ~> B}
-> p₁ ≈ q₁ -> p₂ ≈ q₂
-> ⟨ p₁ , p₂ ⟩ ≈ ⟨ q₁ , q₂ ⟩
⟨,⟩-cong pr1 pr2 = ⊗-unique (π₁-comm ≈> pr1 [sym]) (π₂-comm ≈> pr2 [sym])
⟨,⟩-distrib : ∀{P Q} -> {h : P ~> Q} {f : Q ~> A} {g : Q ~> B}
-> ⟨ f , g ⟩ ∘ h ≈ ⟨ f ∘ h , g ∘ h ⟩
⟨,⟩-distrib = ⊗-unique (∘-assoc [sym] ≈> ≈-cong-left π₁-comm)
(∘-assoc [sym] ≈> ≈-cong-left π₂-comm) [sym]
-- Type class for Cartesian categories
record Cartesian {n} (ℂ : Category n) : Set (lsuc n) where
open Category ℂ
field
-- | Data
-- Terminal object
term : TerminalObj ℂ
-- Binary products for all pairs of objects
prod : ∀(A B : obj) -> Product ℂ A B
open TerminalObj term public
open module P {A} {B} = Product (prod A B) public
-- Shorthand for sum object
infixl 25 _⊗_
_⊗_ : (A B : obj) -> obj
A ⊗ B = A⊗B {A} {B}
-- Parallel product of morphisms
infixl 65 _*_
_*_ : {A B P Q : obj} -> (A ~> P) -> (B ~> Q)
-> (A ⊗ B ~> P ⊗ Q)
_*_ {A} {B} {P} {Q} f g = ⟨ f ∘ π₁ , g ∘ π₂ ⟩
-- Parallel product with an idempotent morphism distributes over ∘
*-idemp-dist-∘ : {A B C D : obj}{g : B ~> C}{f : A ~> B}{h : D ~> D}
-> h ∘ h ≈ h
-> g * h ∘ f * h ≈ (g ∘ f) * h
*-idemp-dist-∘ {g = g}{f}{h} idemp = ⊗-unique u₁ u₂ [sym]
where
u₁ : π₁ ∘ (g * h ∘ f * h) ≈ (g ∘ f) ∘ π₁
u₁ = ∘-assoc [sym] ≈> ≈-cong-left π₁-comm
≈> ∘-assoc ≈> ≈-cong-right π₁-comm ≈> ∘-assoc [sym]
u₂ : π₂ ∘ (g * h ∘ f * h) ≈ h ∘ π₂
u₂ = ∘-assoc [sym] ≈> ≈-cong-left π₂-comm
≈> ∘-assoc ≈> ≈-cong-right π₂-comm
≈> ∘-assoc [sym] ≈> ≈-cong-left idemp
-- Parallel product with an idempotent morphism distributes over ∘
*-id-dist-∘ : {A B C : obj}{g : B ~> C}{f : A ~> B}
-> (_*_ {B = B} g id) ∘ f * id ≈ (g ∘ f) * id
*-id-dist-∘ = *-idemp-dist-∘ id-right
-- Commutativity of product
comm : {A B : obj} -> A ⊗ B ~> B ⊗ A
comm {A}{B} = ⟨ π₂ , π₁ ⟩
-- Associativity of product
assoc-left : {A B C : obj} -> A ⊗ (B ⊗ C) ~> (A ⊗ B) ⊗ C
assoc-left = ⟨ ⟨ π₁ , (π₁ ∘ π₂) ⟩ , π₂ ∘ π₂ ⟩
assoc-right : {A B C : obj} -> (A ⊗ B) ⊗ C ~> A ⊗ (B ⊗ C)
assoc-right = ⟨ π₁ ∘ π₁ , ⟨ (π₂ ∘ π₁) , π₂ ⟩ ⟩
-- Left and right unit for product
unit-left : {A : obj} -> ⊤ ⊗ A ~> A
unit-left = π₂
unit-right : {A : obj} -> A ⊗ ⊤ ~> A
unit-right = π₁
-- The terminal object is the unit for product
⊤-left-cancel : ∀{A} -> ⊤ ⊗ A <~> A
⊤-left-cancel {A} = record
{ iso~> = π₂
; iso<~ = ⟨ ! , id ⟩
; iso-id₁ = iso-id₁-⊤
; iso-id₂ = π₂-comm
}
where
iso-id₁-⊤ : ⟨ ! , id ⟩ ∘ π₂ ≈ id
iso-id₁-⊤ =
begin
⟨ ! , id ⟩ ∘ π₂
≈⟨ ⟨,⟩-distrib ⟩
⟨ ! ∘ π₂ , id ∘ π₂ ⟩
≈⟨ ⟨,⟩-cong r≈ id-left ⟩
⟨ ! ∘ π₂ , π₂ ⟩
≈⟨ ⟨,⟩-cong (!-unique (! ∘ π₂)) r≈ ⟩
⟨ ! , π₂ ⟩
≈⟨ ⟨,⟩-cong ((!-unique π₁) [sym]) r≈ ⟩
⟨ π₁ , π₂ ⟩
≈⟨ ⊗-η-id ⟩
id
∎
⊤-right-cancel : ∀{A} -> A ⊗ ⊤ <~> A
⊤-right-cancel {A} = record
{ iso~> = π₁
; iso<~ = ⟨ id , ! ⟩
; iso-id₁ = iso-id₁-⊤
; iso-id₂ = π₁-comm
}
where
iso-id₁-⊤ : ⟨ id , ! ⟩ ∘ π₁ ≈ id
iso-id₁-⊤ =
begin
⟨ id , ! ⟩ ∘ π₁
≈⟨ ⟨,⟩-distrib ⟩
⟨ id ∘ π₁ , ! ∘ π₁ ⟩
≈⟨ ⟨,⟩-cong id-left r≈ ⟩
⟨ π₁ , ! ∘ π₁ ⟩
≈⟨ ⟨,⟩-cong r≈ (!-unique (! ∘ π₁)) ⟩
⟨ π₁ , ! ⟩
≈⟨ ⟨,⟩-cong r≈ ((!-unique π₂) [sym]) ⟩
⟨ π₁ , π₂ ⟩
≈⟨ ⊗-η-id ⟩
id
∎
| 32.798913
| 81
| 0.401491
|
5965d4e8a8d274a19bf56e94da7b9c1aa30ec488
| 71
|
agda
|
Agda
|
test/Succeed/Issue2007.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue2007.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue2007.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module _ where
record R : Set₁ where
constructor c
open R {{...}}
| 8.875
| 21
| 0.633803
|
4d4aa5269fdd5fc763cfae1573f41a8f6d33ad35
| 12,810
|
agda
|
Agda
|
Eq/Theory.agda
|
msullivan/godels-t
|
7412725cf27873b2b23f7e411a236a97dd99ef91
|
[
"MIT"
] | 4
|
2016-12-25T01:52:57.000Z
|
2021-03-22T00:28:03.000Z
|
Eq/Theory.agda
|
msullivan/godels-t
|
7412725cf27873b2b23f7e411a236a97dd99ef91
|
[
"MIT"
] | null | null | null |
Eq/Theory.agda
|
msullivan/godels-t
|
7412725cf27873b2b23f7e411a236a97dd99ef91
|
[
"MIT"
] | 3
|
2015-04-26T11:39:14.000Z
|
2021-05-04T22:37:18.000Z
|
module Eq.Theory where
open import Prelude
open import T
open import DynTheory
open import SubstTheory
open import Contexts
open import Eq.Defs
open import Eq.KleeneTheory
open import Eq.ObsTheory
open import Eq.LogicalTheory
-- Theory about the interactions between the relationships between the equivs
-- Now that we have shown that logical equivalence is a consistent congruence,
-- it follows that it is contained in observational equivalence.
obs-contains-logical : ∀{Γ} {A} → OLogicalEq Γ A ⊆ ObservEq Γ A
obs-contains-logical = obs-is-coarsest OLogicalEq log-is-con-congruence
obs-contains-clogical : ∀{A} → (LogicalEq A) ⊆ (ObservEq [] A)
obs-contains-clogical leq = obs-contains-logical (closed-logical-imp-open leq)
-- Show that observational equivalence implies logical for closed terms.
obs-implies-closed-logical : ∀{A} {e e' : TCExp A} →
[] ⊢ e ≅ e' :: A →
e ~ e' :: A
obs-implies-closed-logical {nat} oeq = ObservEq.observe oeq ∘
obs-implies-closed-logical {A ⇒ B} {e} {e'} oeq = body
where body : (e₁ e₁' : TExp [] A) → LogicalEq A e₁ e₁' → LogicalEq B (e $ e₁) (e' $ e₁')
body e₁ e₁' leq with obs-contains-clogical leq
... | oeq' with obs-trans (obs-congruence oeq' (e e$ ∘)) (obs-congruence oeq (∘ $e e₁'))
... | oeq'' = obs-implies-closed-logical oeq''
obs-contains-logical-subst : ∀{Γ} → SubstRel LogicalEq Γ ⊆ SubstRel (ObservEq []) Γ
obs-contains-logical-subst η x = obs-contains-clogical (η x)
-- Since observational implies logical for closed terms and
-- respects substitution of observational equivalent terms,
-- logical equivalence contains observational.
logical-contains-obs : ∀{Γ} {A} → ObservEq Γ A ⊆ OLogicalEq Γ A
logical-contains-obs {Γ} {A} {e} {e'} oeq {γ} {γ'} η
with substs-respect-obs oeq (obs-contains-logical-subst η)
... | coeq = obs-implies-closed-logical coeq
-- This is sort of silly. We need these lemmas to prove that logical
-- equivalence contains definitional.
nat-val-weakening : ∀{Γ} {n : TNat} → TVal n →
Σ[ e :: TExp Γ nat ] (∀{γ : TSubst Γ []} → n ≡ ssubst γ e)
nat-val-weakening val-zero = zero , (λ {γ} → Refl)
nat-val-weakening {Γ} {suc n} (val-suc v) with nat-val-weakening {Γ} v
... | e , subst-thing = (suc e) , (λ {γ} → resp suc subst-thing)
nat-logical-equiv-val : ∀{Γ} (γ : TSubst Γ []) (e : TExp Γ nat) →
Σ[ n :: TExp Γ nat ] ((ssubst γ n ~ ssubst γ e :: nat) × TVal (ssubst γ n))
nat-logical-equiv-val {Γ} γ e with kleene-refl {ssubst γ e}
... | kleeneq n val E1 E2 with nat-val-weakening {Γ} val
... | n' , is-val = n' , ((kleeneq n val (ID.coe1 (λ x → x ~>* n) is-val eval-refl) E1) ,
ID.coe1 TVal is-val val)
-- Logical equivalence contains definitional equivalence.
logical-contains-def : ∀{Γ} {A} → DefEq Γ A ⊆ OLogicalEq Γ A
logical-contains-def {y = e} def-refl η = ological-refl e η
logical-contains-def {x = e} {y = e'} (def-sym defeq) η =
ological-sym {_} {_} {e'} {e} (logical-contains-def defeq) η
logical-contains-def {x = e} {y = e''} (def-trans {e' = e'} defeq1 defeq2) η
with logical-contains-def defeq1 | logical-contains-def defeq2
... | leq1 | leq2 = ological-trans {_} {_} {e} {e'} {e''} leq1 leq2 η
logical-contains-def (def-cong defeq C) η = ological-is-congruence (logical-contains-def defeq) C η
logical-contains-def {Γ} {A} (def-beta {e = e} {e' = e'}) {γ} {γ'} η
with step-beta {e = (ssubst (liftγ γ) e)} {e' = ssubst γ e'}
... | step with ological-refl e (extendLogicalEQΓ η (ological-refl e' η))
... | leq with subeq (compose-subst-noob γ' e') e ≡≡ subcomp γ' (singγ e') e
... | subeq-r with subcomp (singγ (ssubst γ e')) (liftγ γ) e
... | subeq-l with ID.coe2 (LogicalEq A) subeq-l subeq-r leq
... | leq' = logical-converse-evaluation-1 leq' (eval-step step)
logical-contains-def {Γ} {A} (def-rec-z {e0 = e0} {es = es}) {γ} {γ'} η with ological-refl e0 η
... | leq = logical-converse-evaluation-1 leq (eval-step step-rec-z)
-- This is super nasty. It has some code duplication when handling the congruence stuff.
-- And it also needs to deal with a bunch of nasty substitution crap.
-- The main source of nonstupid complication is that the step rule requires
-- n to be a value, and definitional equivalence does not.
logical-contains-def {Γ} {A} (def-rec-s {e = en} {e0 = e0} {es = es}) {γ} {γ'} η
with nat-logical-equiv-val γ en
... | n , num-leq , is-val with ological-refl (rec en e0 es) η
... | full-leq with ological-is-congruence {e = ssubst γ n} {e' = ssubst γ en}
(closed-logical-imp-open num-leq) (rec1 ∘ (ssubst γ e0) (ssubst (liftγ γ) es))
(emptyLogicalEqΓ {γ = emptyγ} {γ' = emptyγ})
... | eq-with-γn-and-nasty-subst with ID.coe2 (LogicalEq A) (subid _) (subid _) eq-with-γn-and-nasty-subst
... | eq-with-γn with logical-trans eq-with-γn full-leq
... | leq-subrec with ological-refl (rec (suc en) e0 es) (logicalγ-refl {x = γ})
... | full-leq-s with ological-is-congruence {e = ssubst γ n} {e' = ssubst γ en}
(closed-logical-imp-open num-leq) (rec1 (suc ∘) (ssubst γ e0) (ssubst (liftγ γ) es))
(emptyLogicalEqΓ {γ = emptyγ} {γ' = emptyγ})
... | eq-with-sγn-and-nasty-subst with ID.coe2 (LogicalEq A) (subid _) (subid _) eq-with-sγn-and-nasty-subst
... | eq-with-sγn with logical-trans eq-with-sγn full-leq-s
... | leq-subrec-2 with ological-refl es (extendLogicalEQΓ η leq-subrec)
... | leq-unrolled with subeq (compose-subst-noob γ' (rec en e0 es)) es ≡≡
subcomp γ' (singγ (rec en e0 es)) es
... | subeq-l with subcomp (singγ (ssubst γ (rec n e0 es))) (liftγ γ) es
... | subeq-r with ID.coe2 (LogicalEq A) subeq-r subeq-l leq-unrolled
... | leq with step-rec-s {e = ssubst γ n} {e₀ = ssubst γ e0} {es = ssubst (liftγ γ) es} is-val
... | step with logical-converse-evaluation-1 leq (eval-step step)
... | leq-stepped = logical-trans (logical-sym leq-subrec-2) leq-stepped
-- Obvious corollary that observational equivalence contains definitional.
obs-contains-def : ∀{Γ} {A} → DefEq Γ A ⊆ ObservEq Γ A
obs-contains-def = obs-contains-logical o logical-contains-def
-- Proving this mostly out of spite, because one formulation
-- of my theory needed this for observational equivalence,
-- and there wasn't a good way to prove it other than appealing
-- to observational equivalence coinciding with logical, which
-- was what we were trying to prove.
weakened-equiv-log : ∀{Γ} {A} {e e' : TCExp A} →
e ~ e' :: A →
Γ ⊢ weaken-closed e ~ weaken-closed e' :: A
weakened-equiv-log {Γ} {A} {e} {e'} leq {γ} {γ'} η with subren γ closed-wkγ e | subren γ' closed-wkγ e'
... | eq1 | eq2 with closed-subst (γ o closed-wkγ) e | closed-subst (γ' o closed-wkγ) e'
... | eq1' | eq2' = ID.coe2 (LogicalEq A) (symm eq1' ≡≡ symm eq1) (symm eq2' ≡≡ symm eq2) leq
weakened-equiv-obs : ∀{Γ} {A} {e e' : TCExp A} →
[] ⊢ e ≅ e' :: A →
Γ ⊢ weaken-closed e ≅ weaken-closed e' :: A
weakened-equiv-obs {Γ} {A} {e} {e'} oeq = obs-contains-logical (weakened-equiv-log {Γ} {A} {e} {e'} (obs-implies-closed-logical oeq))
-- Some more stuff about renaming.
wkren1 : ∀{Γ A} → TRen Γ (A :: Γ)
wkren1 = (λ x → S x)
weaken1 : ∀{Γ A B} → TExp Γ B → TExp (A :: Γ) B
weaken1 e = ren wkren1 e
weakening-ignores : ∀{Γ A} (e₁ : TCExp A) (γ : TSubst Γ []) →
Sub≡ (λ x₁ → ssubst (singγ e₁) (ren wkren1 (γ x₁))) γ
weakening-ignores e₁ γ x = subren (singγ e₁) wkren1 (γ x) ≡≡ subid (γ x)
-- Functional extensionality
function-ext-log : ∀{Γ A B} {e e' : TExp Γ (A ⇒ B)} →
(A :: Γ) ⊢ weaken1 e $ var Z ~ weaken1 e' $ var Z :: B →
Γ ⊢ e ~ e' :: A ⇒ B
function-ext-log {Γ} {A} {B} {e} {e'} leq {γ} {γ'} η e₁ e₁' leq'
with leq (extendLogicalEQΓ η leq')
... | leq'' with subren (subComp (singγ e₁) (liftγ γ)) wkren1 e |
subren (subComp (singγ e₁') (liftγ γ')) wkren1 e'
... | eq1' | eq2' with eq1' ≡≡ subeq (weakening-ignores e₁ γ) e |
eq2' ≡≡ subeq (weakening-ignores e₁' γ') e'
... | eq1 | eq2 = ID.coe2 (LogicalEq B) (resp (λ x → x $ e₁) eq1) (resp (λ x → x $ e₁') eq2) leq''
function-ext-obs : ∀{Γ A B} {e e' : TExp Γ (A ⇒ B)} →
(A :: Γ) ⊢ weaken1 e $ var Z ≅ weaken1 e' $ var Z :: B →
Γ ⊢ e ≅ e' :: A ⇒ B
function-ext-obs {e = e} {e' = e'} oeq = obs-contains-logical
(function-ext-log {e = e} {e' = e'} (logical-contains-obs oeq))
-- Eta, essentially
-- The important part of the proof is the def-beta and the function-ext-obs,
-- but most of the actual work is fucking around with substitutions.
function-eta-obs : ∀{Γ A B} (e : TExp Γ (A ⇒ B)) →
Γ ⊢ e ≅ (Λ (weaken1 e $ var Z)) :: A ⇒ B
function-eta-obs {Γ} {A} {B} e with
obs-sym (obs-contains-def (def-beta {e = ren (wk wkren1) (ren wkren1 e) $ var Z} {e' = var Z}))
... | beta-eq with (subren (singγ (var Z)) (wk wkren1) (weaken1 e)) ≡≡
(subren (λ x → singγ (var Z) (wk wkren1 x)) wkren1 e) ≡≡
symm (subren emptyγ wkren1 e) ≡≡
subid (weaken1 e)
... | eq2 with resp (λ x → x $ var Z) eq2
... | eq with ID.coe2 (ObservEq (A :: Γ) B) eq refl beta-eq
... | oeq = function-ext-obs oeq
obs-equiv-nat-val : (e : TNat) → Σ[ n :: TNat ] (TVal n × ([] ⊢ e ≅ n :: nat))
obs-equiv-nat-val e with ological-equiv-nat-val e
obs-equiv-nat-val e | n , val , eq = n , val , obs-contains-logical eq
-- OK, maybe we are trying this with numerals again. Argh.
t-numeral : ∀{Γ} → Nat → TExp Γ nat
t-numeral Z = zero
t-numeral (S n) = suc (t-numeral n)
numeral-val : ∀{Γ} → (n : Nat) → TVal {Γ} (t-numeral n)
numeral-val Z = val-zero
numeral-val (S n) = val-suc (numeral-val n)
val-numeral : ∀{Γ} {e : TExp Γ nat} → TVal e → Σ[ n :: Nat ] (e ≡ t-numeral n)
val-numeral val-zero = Z , Refl
val-numeral (val-suc v) with val-numeral v
... | n , eq = (S n) , (resp suc eq)
numeral-subst-dontcare : ∀{Γ Γ'} (n : Nat) (γ : TSubst Γ Γ') → ssubst γ (t-numeral n) ≡ t-numeral n
numeral-subst-dontcare Z γ = Refl
numeral-subst-dontcare (S n) γ = resp suc (numeral-subst-dontcare n γ)
--
obs-equiv-numeral : (e : TNat) → Σ[ n :: Nat ] ([] ⊢ e ≅ t-numeral n :: nat)
obs-equiv-numeral e with obs-equiv-nat-val e
obs-equiv-numeral e | en , val , oeq with val-numeral val
... | n , eq = n , (ID.coe1 (ObservEq [] nat e) eq oeq)
dropSubstRel : ∀(R : CRel) {Γ A} {γ γ' : TSubst (A :: Γ) []} →
SubstRel R (A :: Γ) γ γ' →
SubstRel R Γ (dropγ γ) (dropγ γ')
dropSubstRel R η n = η (S n)
dropLogicalEqΓ = dropSubstRel LogicalEq
-- Allow induction over nats, essentially
function-induction-log : ∀{Γ A} {e e' : TExp (nat :: Γ) A} →
((n : Nat) → Γ ⊢ ssubst (singγ (t-numeral n)) e ~
ssubst (singγ (t-numeral n)) e' :: A) →
(nat :: Γ) ⊢ e ~ e' :: A
function-induction-log {Γ} {A} {e} {e'} f {γ} {γ'} η
with η Z | obs-equiv-numeral (γ Z)
... | n-eq | n , oeq-n with f n (dropLogicalEqΓ η)
... | butt with subcomp (dropγ γ) (singγ (t-numeral n)) e | subcomp (dropγ γ') (singγ (t-numeral n)) e'
... | lol1 | lol2 with subeq (compose-subst-noob (dropγ γ) (t-numeral n)) e |
subeq (compose-subst-noob (dropγ γ') (t-numeral n)) e'
... | lol1' | lol2' with ID.coe2 (LogicalEq A) (symm lol1 ≡≡ symm lol1') (symm lol2 ≡≡ symm lol2') butt
... | wtf with ID.coe2
(λ x y → LogicalEq A
(ssubst (extendγ (dropγ γ) x) e)
(ssubst (extendγ (dropγ γ') y) e'))
(numeral-subst-dontcare n (dropγ γ)) (numeral-subst-dontcare n (dropγ γ')) wtf
... | wtf' with ological-refl e (extendLogicalEQΓ (dropLogicalEqΓ (logicalγ-refl {x = γ})) (obs-consistent oeq-n))
... | leq-e with ID.coe2 (LogicalEq A) (symm (subeq (drop-fix γ) e)) Refl leq-e
... | leq-e' with ological-refl e' (extendLogicalEQΓ (dropLogicalEqΓ (logicalγ-refl {x = γ'}))
(kleene-trans (kleene-sym n-eq) (obs-consistent oeq-n)))
... | leq-e2 with ID.coe2 (LogicalEq A) (symm (subeq (drop-fix γ') e')) Refl leq-e2
... | leq-e2' = logical-trans leq-e' (logical-trans wtf' (logical-sym leq-e2'))
function-induction-obs : ∀{Γ A} {e e' : TExp (nat :: Γ) A} →
((n : Nat) → Γ ⊢ ssubst (singγ (t-numeral n)) e ≅
ssubst (singγ (t-numeral n)) e' :: A) →
(nat :: Γ) ⊢ e ≅ e' :: A
function-induction-obs {Γ} {A} {e} {e'} f =
obs-contains-logical
(function-induction-log {Γ} {A} {e} {e'}
(λ n → logical-contains-obs (f n)))
| 50.833333
| 133
| 0.588993
|
3980488e59af79655d05ed09085b6bc72a18f024
| 4,091
|
agda
|
Agda
|
typed-elaboration.agda
|
hazelgrove/hazelnut-agda
|
a3640d7b0f76cdac193afd382694197729ed6d57
|
[
"MIT"
] | null | null | null |
typed-elaboration.agda
|
hazelgrove/hazelnut-agda
|
a3640d7b0f76cdac193afd382694197729ed6d57
|
[
"MIT"
] | null | null | null |
typed-elaboration.agda
|
hazelgrove/hazelnut-agda
|
a3640d7b0f76cdac193afd382694197729ed6d57
|
[
"MIT"
] | null | null | null |
open import Nat
open import Prelude
open import dynamics-core
open import contexts
open import lemmas-consistency
open import lemmas-disjointness
open import lemmas-matching
open import weakening
module typed-elaboration where
mutual
typed-elaboration-synth : {Γ : tctx} {e : hexp} {τ : htyp} {d : ihexp} {Δ : hctx} →
Γ ⊢ e ⇒ τ ~> d ⊣ Δ →
Δ , Γ ⊢ d :: τ
typed-elaboration-synth ESNum = TANum
typed-elaboration-synth (ESPlus dis apt x₁ x₂)
with typed-elaboration-ana x₁ | typed-elaboration-ana x₂
... | con1 , ih1 | con2 , ih2 = TAPlus (TACast (weaken-ta-Δ1 apt ih1) con1) (TACast (weaken-ta-Δ2 apt ih2) con2)
typed-elaboration-synth (ESVar x₁) = TAVar x₁
typed-elaboration-synth (ESLam x₁ ex) = TALam x₁ (typed-elaboration-synth ex)
typed-elaboration-synth (ESAp {Δ1 = Δ1} _ d x₁ x₂ x₃ x₄)
with typed-elaboration-ana x₃ | typed-elaboration-ana x₄
... | con1 , ih1 | con2 , ih2 = TAAp (TACast (weaken-ta-Δ1 d ih1) con1) (TACast (weaken-ta-Δ2 {Δ1 = Δ1} d ih2) con2)
typed-elaboration-synth (ESEHole {Γ = Γ} {u = u}) with natEQ u u
... | Inr u≠u = abort (u≠u refl)
... | Inl refl = TAEHole (x∈■ u (Γ , ⦇-⦈)) (STAId (λ x τ z → z))
typed-elaboration-synth (ESNEHole {Γ = Γ} {τ = τ} {u = u} {Δ = Δ} (d1 , d2) ex)
with typed-elaboration-synth ex
... | ih1 = TANEHole {Δ = Δ ,, (u , Γ , ⦇-⦈)} (ctx-top Δ u (Γ , ⦇-⦈) (d2 u (lem-domsingle _ _))) (weaken-ta-Δ2 (d2 , d1) ih1) (STAId (λ x τ₁ z → z))
typed-elaboration-synth (ESAsc x)
with typed-elaboration-ana x
... | con , ih = TACast ih con
typed-elaboration-synth (ESPair x x₁ x₂ x₃)
with typed-elaboration-synth x₂ | typed-elaboration-synth x₃
... | ih1 | ih2 = TAPair (weaken-ta-Δ1 x₁ ih1) (weaken-ta-Δ2 x₁ ih2)
typed-elaboration-synth (ESFst x x₁ x₂)
with typed-elaboration-ana x₂
... | con , ih = TAFst (TACast ih con)
typed-elaboration-synth (ESSnd x x₁ x₂)
with typed-elaboration-ana x₂
... | con , ih = TASnd (TACast ih con)
typed-elaboration-ana : {Γ : tctx} {e : hexp} {τ τ' : htyp} {d : ihexp} {Δ : hctx} →
Γ ⊢ e ⇐ τ ~> d :: τ' ⊣ Δ →
(τ' ~ τ) × (Δ , Γ ⊢ d :: τ')
typed-elaboration-ana (EALam x₁ MAHole ex)
with typed-elaboration-ana ex
... | con , D = TCHole1 , TALam x₁ D
typed-elaboration-ana (EALam x₁ MAArr ex)
with typed-elaboration-ana ex
... | con , D = TCArr TCRefl con , TALam x₁ D
typed-elaboration-ana (EASubsume x x₁ x₂ x₃) = ~sym x₃ , typed-elaboration-synth x₂
typed-elaboration-ana (EAEHole {Γ = Γ} {u = u}) = TCRefl , TAEHole (x∈■ u (Γ , _)) (STAId (λ x τ z → z))
typed-elaboration-ana (EANEHole {Γ = Γ} {u = u} {τ = τ} {Δ = Δ} (d1 , d2) x)
with typed-elaboration-synth x
... | ih1 = TCRefl , TANEHole {Δ = Δ ,, (u , Γ , τ)} (ctx-top Δ u (Γ , τ) (d2 u (lem-domsingle _ _)) ) (weaken-ta-Δ2 (d2 , d1) ih1) (STAId (λ x₁ τ₁ z → z))
typed-elaboration-ana (EAInl MSHole x₁)
with typed-elaboration-ana x₁
... | con , D = TCHole1 , TAInl D
typed-elaboration-ana (EAInl MSSum x₁)
with typed-elaboration-ana x₁
... | con , D = TCSum con TCRefl , TAInl D
typed-elaboration-ana (EAInr MSHole x₁)
with typed-elaboration-ana x₁
... | con , D = TCHole1 , TAInr D
typed-elaboration-ana (EAInr MSSum x₁)
with typed-elaboration-ana x₁
... | con , D = TCSum TCRefl con , TAInr D
typed-elaboration-ana (EACase x x₁ x₂ x₃ x₄ x₅ x₆ x₇ x₈ x₉ x₁₀ x₁₁)
with typed-elaboration-synth x₈ |
typed-elaboration-ana x₁₀ | typed-elaboration-ana x₁₁
... | D | con1 , D1 | con2 , D2 =
let Δ##Δ1∪Δ2 = ##-comm (disjoint-parts (##-comm x₃) (##-comm x₄))
in let wtd = TACast (weaken-ta-Δ1 Δ##Δ1∪Δ2 D) (▸sum-consist x₉)
in let wtd1 = TACast (weaken-ta-Δ2 Δ##Δ1∪Δ2 (weaken-ta-Δ1 x₅ D1)) con1
in let wtd2 = TACast (weaken-ta-Δ2 Δ##Δ1∪Δ2 (weaken-ta-Δ2 x₅ D2)) con2
in let wt = TACase wtd x₆ wtd1 x₇ wtd2
in TCRefl , wt
| 51.78481
| 159
| 0.587631
|
20d9d5020a7a0746d95c4cd010733b58f0f77283
| 1,011
|
agda
|
Agda
|
Cubical/Relation/Binary/Reasoning/Equality.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | null | null | null |
Cubical/Relation/Binary/Reasoning/Equality.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | null | null | null |
Cubical/Relation/Binary/Reasoning/Equality.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Relation.Binary.Reasoning.Equality where
open import Cubical.Core.Everything
open import Cubical.Foundations.Prelude
private
variable
ℓ : Level
A : Type ℓ
infixr 1 _≡⟨⟩_ _≡⟨_⟩_ _≡˘⟨_⟩_
infix 2 _∎
-- Step with a non-trivial propositional equality
_≡⟨_⟩_ : ∀ x {y z : A} → x ≡ y → y ≡ z → x ≡ z
_≡⟨_⟩_ x = _∙_
-- Step with a flipped non-trivial propositional equality
_≡˘⟨_⟩_ : ∀ x {y z : A} → y ≡ x → y ≡ z → x ≡ z
x ≡˘⟨ y≡x ⟩ y≡z = x ≡⟨ sym y≡x ⟩ y≡z
-- Step with a trivial propositional equality
_≡⟨⟩_ : ∀ x {y : A} → x ≡ y → x ≡ y
_ ≡⟨⟩ x≡y = x≡y
-- Syntax for path definition
≡⟨⟩-syntax : ∀ x {y z : A} → x ≡ y → y ≡ z → x ≡ z
≡⟨⟩-syntax = _≡⟨_⟩_
infixr 1 ≡⟨⟩-syntax
syntax ≡⟨⟩-syntax x (λ i → B) y = x ≡[ i ]⟨ B ⟩ y
≡˘⟨⟩-syntax : ∀ x {y z : A} → y ≡ x → y ≡ z → x ≡ z
≡˘⟨⟩-syntax = _≡˘⟨_⟩_
infixr 1 ≡˘⟨⟩-syntax
syntax ≡˘⟨⟩-syntax x (λ i → B) y = x ≡˘[ i ]⟨ B ⟩ y
-- Termination step
_∎ : ∀ (x : A) → x ≡ x
x ∎ = refl
| 21.978261
| 57
| 0.538081
|
59b551fa69f581476c2f012f5d2041a3201469ed
| 4,361
|
agda
|
Agda
|
Mixfix/Expr.agda
|
nad/parser-combinators
|
76774f54f466cfe943debf2da731074fe0c33644
|
[
"MIT"
] | 1
|
2020-07-03T08:56:13.000Z
|
2020-07-03T08:56:13.000Z
|
Mixfix/Expr.agda
|
nad/parser-combinators
|
76774f54f466cfe943debf2da731074fe0c33644
|
[
"MIT"
] | null | null | null |
Mixfix/Expr.agda
|
nad/parser-combinators
|
76774f54f466cfe943debf2da731074fe0c33644
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- Precedence-correct expressions
------------------------------------------------------------------------
module Mixfix.Expr where
open import Data.Vec using (Vec)
open import Data.List using (List; []; _∷_)
open import Data.List.Membership.Propositional using (_∈_)
open import Data.List.Relation.Unary.Any using (here; there)
open import Data.Product using (∃; _,_)
open import Mixfix.Fixity
open import Mixfix.Operator
------------------------------------------------------------------------
-- An abstract definition of precedence graphs
-- The interface of precedence graphs.
record PrecedenceGraphInterface : Set₁ where
field
-- Precedence graphs.
PrecedenceGraph : Set
-- Precedence levels.
Precedence : PrecedenceGraph → Set
-- The operators of the given precedence.
ops : (g : PrecedenceGraph) →
Precedence g → (fix : Fixity) → List (∃ (Operator fix))
-- The immediate successors of the precedence level.
↑ : (g : PrecedenceGraph) → Precedence g → List (Precedence g)
-- All precedence levels in the graph.
anyPrecedence : (g : PrecedenceGraph) → List (Precedence g)
-- When a precedence graph is given the following module may be
-- convenient to avoid having to write "g" all the time.
module PrecedenceGraph
(i : PrecedenceGraphInterface)
(g : PrecedenceGraphInterface.PrecedenceGraph i)
where
PrecedenceGraph : Set
PrecedenceGraph = PrecedenceGraphInterface.PrecedenceGraph i
Precedence : Set
Precedence = PrecedenceGraphInterface.Precedence i g
ops : Precedence → (fix : Fixity) → List (∃ (Operator fix))
ops = PrecedenceGraphInterface.ops i g
↑ : Precedence → List Precedence
↑ = PrecedenceGraphInterface.↑ i g
anyPrecedence : List Precedence
anyPrecedence = PrecedenceGraphInterface.anyPrecedence i g
------------------------------------------------------------------------
-- Precedence-correct operator applications
-- Parameterised on a precedence graph.
module PrecedenceCorrect
(i : PrecedenceGraphInterface)
(g : PrecedenceGraphInterface.PrecedenceGraph i)
where
open PrecedenceGraph i g public
mutual
infixl 4 _⟨_⟩ˡ_
infixr 4 _⟨_⟩ʳ_
infix 4 _⟨_⟩_ _⟨_⟫ ⟪_⟩_ _∙_
-- Expr ps contains expressions where the outermost operator has
-- one of the precedences in ps.
data Expr (ps : List Precedence) : Set where
_∙_ : ∀ {p assoc} (p∈ps : p ∈ ps) (e : ExprIn p assoc) → Expr ps
-- ExprIn p assoc contains expressions where the outermost
-- operator has precedence p (is /in/ precedence level p) and the
-- associativity assoc.
data ExprIn (p : Precedence) : Associativity → Set where
⟪_⟫ : (op : Inner (ops p closed )) → ExprIn p non
_⟨_⟫ : (l : Outer p left) (op : Inner (ops p postfx )) → ExprIn p left
⟪_⟩_ : (op : Inner (ops p prefx )) (r : Outer p right) → ExprIn p right
_⟨_⟩_ : (l : Expr (↑ p) ) (op : Inner (ops p (infx non ))) (r : Expr (↑ p) ) → ExprIn p non
_⟨_⟩ˡ_ : (l : Outer p left) (op : Inner (ops p (infx left ))) (r : Expr (↑ p) ) → ExprIn p left
_⟨_⟩ʳ_ : (l : Expr (↑ p) ) (op : Inner (ops p (infx right))) (r : Outer p right) → ExprIn p right
-- Outer p fix contains expressions where the head operator either
-- ⑴ has precedence p and associativity assoc or
-- ⑵ binds strictly tighter than p.
data Outer (p : Precedence) (assoc : Associativity) : Set where
similar : (e : ExprIn p assoc) → Outer p assoc
tighter : (e : Expr (↑ p)) → Outer p assoc
-- Inner ops contains the internal parts (operator plus
-- internal arguments) of operator applications. The operators
-- have to be members of ops.
data Inner {fix} (ops : List (∃ (Operator fix))) : Set where
_∙_ : ∀ {arity op}
(op∈ops : (arity , op) ∈ ops)
(args : Vec (Expr anyPrecedence) arity) →
Inner ops
-- "Weakening".
weakenE : ∀ {p ps} → Expr ps → Expr (p ∷ ps)
weakenE (p∈ps ∙ e) = there p∈ps ∙ e
weakenI : ∀ {fix ops} {op : ∃ (Operator fix)} →
Inner ops → Inner (op ∷ ops)
weakenI (op∈ops ∙ args) = there op∈ops ∙ args
| 35.169355
| 104
| 0.588397
|
2948e814c478e47b4d98b27593f53631fe215043
| 3,309
|
agda
|
Agda
|
archive/agda-1/TermCode.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | null | null | null |
archive/agda-1/TermCode.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | 1
|
2019-04-29T00:35:04.000Z
|
2019-05-11T23:33:04.000Z
|
archive/agda-1/TermCode.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | null | null | null |
{-# OPTIONS --allow-unsolved-metas #-}
module TermCode where
open import OscarPrelude
open import VariableName
open import FunctionName
open import Arity
open import Term
open import Vector
data TermCode : Set
where
variable : VariableName → TermCode
function : FunctionName → Arity → TermCode
termCode-function-inj₁ : ∀ {𝑓₁ 𝑓₂ arity₁ arity₂} → TermCode.function 𝑓₁ arity₁ ≡ function 𝑓₂ arity₂ → 𝑓₁ ≡ 𝑓₂
termCode-function-inj₁ refl = refl
termCode-function-inj₂ : ∀ {𝑓₁ 𝑓₂ arity₁ arity₂} → TermCode.function 𝑓₁ arity₁ ≡ function 𝑓₂ arity₂ → arity₁ ≡ arity₂
termCode-function-inj₂ refl = refl
instance
EqTermCode : Eq TermCode
Eq._==_ EqTermCode (variable 𝑥₁) (variable 𝑥₂) with 𝑥₁ ≟ 𝑥₂
… | yes 𝑥₁≡𝑥₂ rewrite 𝑥₁≡𝑥₂ = yes refl
… | no 𝑥₁≢𝑥₂ = no (λ { refl → 𝑥₁≢𝑥₂ refl})
Eq._==_ EqTermCode (variable x) (function x₁ x₂) = no (λ ())
Eq._==_ EqTermCode (function x x₁) (variable x₂) = no (λ ())
Eq._==_ EqTermCode (function 𝑓₁ 𝑎₁) (function 𝑓₂ 𝑎₂) = decEq₂ termCode-function-inj₁ termCode-function-inj₂ (𝑓₁ ≟ 𝑓₂) (𝑎₁ ≟ 𝑎₂)
mutual
encodeTerm : Term → List TermCode
encodeTerm (variable 𝑥) = variable 𝑥 ∷ []
encodeTerm (function 𝑓 (⟨_⟩ {arity} τs)) = function 𝑓 arity ∷ encodeTerms τs
encodeTerms : {arity : Arity} → Vector Term arity → List TermCode
encodeTerms ⟨ [] ⟩ = []
encodeTerms ⟨ τ ∷ τs ⟩ = encodeTerm τ ++ encodeTerms ⟨ τs ⟩
mutual
decodeTerm : Nat → StateT (List TermCode) Maybe Term
decodeTerm zero = lift nothing
decodeTerm (suc n) = do
caseM get of λ
{ [] → lift nothing
; (variable 𝑥 ∷ _) →
modify (drop 1) ~|
return (variable 𝑥)
; (function 𝑓 arity ∷ _) →
modify (drop 1) ~|
decodeFunction n 𝑓 arity }
decodeFunction : Nat → FunctionName → Arity → StateT (List TermCode) Maybe Term
decodeFunction n 𝑓 arity = do
τs ← decodeTerms n arity -|
return (function 𝑓 ⟨ τs ⟩)
decodeTerms : Nat → (arity : Arity) → StateT (List TermCode) Maybe (Vector Term arity)
decodeTerms n ⟨ zero ⟩ = return ⟨ [] ⟩
decodeTerms n ⟨ suc arity ⟩ = do
τ ← decodeTerm n -|
τs ← decodeTerms n ⟨ arity ⟩ -|
return ⟨ τ ∷ vector τs ⟩
.decode-is-inverse-of-encode : ∀ τ → runStateT (decodeTerm ∘ length $ encodeTerm τ) (encodeTerm τ) ≡ (just $ τ , [])
decode-is-inverse-of-encode (variable 𝑥) = refl
decode-is-inverse-of-encode (function 𝑓 ⟨ ⟨ [] ⟩ ⟩) = {!!}
decode-is-inverse-of-encode (function 𝑓 ⟨ ⟨ variable 𝑥 ∷ τs ⟩ ⟩) = {!!}
decode-is-inverse-of-encode (function 𝑓 ⟨ ⟨ function 𝑓' τs' ∷ τs ⟩ ⟩) = {!!}
module ExampleEncodeDecode where
example-Term : Term
example-Term =
(function ⟨ 2 ⟩
⟨ ⟨ ( variable ⟨ 0 ⟩ ∷
function ⟨ 3 ⟩ ⟨ ⟨ variable ⟨ 2 ⟩ ∷ [] ⟩ ⟩ ∷
variable ⟨ 5 ⟩ ∷ [] )
⟩ ⟩
)
-- function ⟨ 2 ⟩ ⟨ 3 ⟩ ∷ variable ⟨ 0 ⟩ ∷ function ⟨ 3 ⟩ ⟨ 1 ⟩ ∷ variable ⟨ 2 ⟩ ∷ variable ⟨ 5 ⟩ ∷ []
example-TermCodes : List TermCode
example-TermCodes = encodeTerm example-Term
example-TermDecode : Maybe (Term × List TermCode)
example-TermDecode = runStateT (decodeTerm (length example-TermCodes)) example-TermCodes
example-verified : example-TermDecode ≡ (just $ example-Term , [])
example-verified = refl
example-bad : runStateT (decodeTerm 2) (function ⟨ 2 ⟩ ⟨ 2 ⟩ ∷ variable ⟨ 0 ⟩ ∷ []) ≡ nothing
example-bad = refl
| 35.202128
| 129
| 0.638259
|
502e8960bca26ea7776492be629133fd658a160b
| 6,845
|
agda
|
Agda
|
Cubical/Foundations/Transport.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 1
|
2022-02-05T01:25:26.000Z
|
2022-02-05T01:25:26.000Z
|
Cubical/Foundations/Transport.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | null | null | null |
Cubical/Foundations/Transport.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | null | null | null |
{- Basic theory about transport:
- transport is invertible
- transport is an equivalence ([transportEquiv])
-}
{-# OPTIONS --safe #-}
module Cubical.Foundations.Transport where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Function using (_∘_)
-- Direct definition of transport filler, note that we have to
-- explicitly tell Agda that the type is constant (like in CHM)
transpFill : ∀ {ℓ} {A : Type ℓ}
(φ : I)
(A : (i : I) → Type ℓ [ φ ↦ (λ _ → A) ])
(u0 : outS (A i0))
→ --------------------------------------
PathP (λ i → outS (A i)) u0 (transp (λ i → outS (A i)) φ u0)
transpFill φ A u0 i = transp (λ j → outS (A (i ∧ j))) (~ i ∨ φ) u0
transport⁻ : ∀ {ℓ} {A B : Type ℓ} → A ≡ B → B → A
transport⁻ p = transport (λ i → p (~ i))
subst⁻ : ∀ {ℓ ℓ'} {A : Type ℓ} {x y : A} (B : A → Type ℓ') (p : x ≡ y) → B y → B x
subst⁻ B p pa = transport⁻ (λ i → B (p i)) pa
transport-fillerExt : ∀ {ℓ} {A B : Type ℓ} (p : A ≡ B)
→ PathP (λ i → A → p i) (λ x → x) (transport p)
transport-fillerExt p i x = transport-filler p x i
transport⁻-fillerExt : ∀ {ℓ} {A B : Type ℓ} (p : A ≡ B)
→ PathP (λ i → p i → A) (λ x → x) (transport⁻ p)
transport⁻-fillerExt p i x = transp (λ j → p (i ∧ ~ j)) (~ i) x
transport-fillerExt⁻ : ∀ {ℓ} {A B : Type ℓ} (p : A ≡ B)
→ PathP (λ i → p i → B) (transport p) (λ x → x)
transport-fillerExt⁻ p = symP (transport⁻-fillerExt (sym p))
transport⁻-fillerExt⁻ : ∀ {ℓ} {A B : Type ℓ} (p : A ≡ B)
→ PathP (λ i → B → p i) (transport⁻ p) (λ x → x)
transport⁻-fillerExt⁻ p = symP (transport-fillerExt (sym p))
transport⁻-filler : ∀ {ℓ} {A B : Type ℓ} (p : A ≡ B) (x : B)
→ PathP (λ i → p (~ i)) x (transport⁻ p x)
transport⁻-filler p x = transport-filler (λ i → p (~ i)) x
transport⁻Transport : ∀ {ℓ} {A B : Type ℓ} → (p : A ≡ B) → (a : A) →
transport⁻ p (transport p a) ≡ a
transport⁻Transport p a j = transport⁻-fillerExt p (~ j) (transport-fillerExt p (~ j) a)
transportTransport⁻ : ∀ {ℓ} {A B : Type ℓ} → (p : A ≡ B) → (b : B) →
transport p (transport⁻ p b) ≡ b
transportTransport⁻ p b j = transport-fillerExt⁻ p j (transport⁻-fillerExt⁻ p j b)
-- Transport is an equivalence
isEquivTransport : ∀ {ℓ} {A B : Type ℓ} (p : A ≡ B) → isEquiv (transport p)
isEquivTransport {A = A} {B = B} p =
transport (λ i → isEquiv (transport-fillerExt p i)) (idIsEquiv A)
transportEquiv : ∀ {ℓ} {A B : Type ℓ} → A ≡ B → A ≃ B
transportEquiv p = (transport p , isEquivTransport p)
substEquiv : ∀ {ℓ ℓ'} {A : Type ℓ} {a a' : A} (P : A → Type ℓ') (p : a ≡ a') → P a ≃ P a'
substEquiv P p = (subst P p , isEquivTransport (λ i → P (p i)))
liftEquiv : ∀ {ℓ ℓ'} {A B : Type ℓ} (P : Type ℓ → Type ℓ') (e : A ≃ B) → P A ≃ P B
liftEquiv P e = substEquiv P (ua e)
transpEquiv : ∀ {ℓ} {A B : Type ℓ} (p : A ≡ B) → ∀ i → p i ≃ B
transpEquiv P i .fst = transp (λ j → P (i ∨ j)) i
transpEquiv P i .snd
= transp (λ k → isEquiv (transp (λ j → P (i ∨ (j ∧ k))) (i ∨ ~ k)))
i (idIsEquiv (P i))
uaTransportη : ∀ {ℓ} {A B : Type ℓ} (P : A ≡ B) → ua (transportEquiv P) ≡ P
uaTransportη P i j
= Glue (P i1) λ where
(j = i0) → P i0 , transportEquiv P
(i = i1) → P j , transpEquiv P j
(j = i1) → P i1 , idEquiv (P i1)
pathToIso : ∀ {ℓ} {A B : Type ℓ} → A ≡ B → Iso A B
Iso.fun (pathToIso x) = transport x
Iso.inv (pathToIso x) = transport⁻ x
Iso.rightInv (pathToIso x) = transportTransport⁻ x
Iso.leftInv (pathToIso x) = transport⁻Transport x
isInjectiveTransport : ∀ {ℓ : Level} {A B : Type ℓ} {p q : A ≡ B}
→ transport p ≡ transport q → p ≡ q
isInjectiveTransport {p = p} {q} α i =
hcomp
(λ j → λ
{ (i = i0) → retEq univalence p j
; (i = i1) → retEq univalence q j
})
(invEq univalence ((λ a → α i a) , t i))
where
t : PathP (λ i → isEquiv (λ a → α i a)) (pathToEquiv p .snd) (pathToEquiv q .snd)
t = isProp→PathP (λ i → isPropIsEquiv (λ a → α i a)) _ _
transportUaInv : ∀ {ℓ} {A B : Type ℓ} (e : A ≃ B) → transport (ua (invEquiv e)) ≡ transport (sym (ua e))
transportUaInv e = cong transport (uaInvEquiv e)
-- notice that transport (ua e) would reduce, thus an alternative definition using EquivJ can give
-- refl for the case of idEquiv:
-- transportUaInv e = EquivJ (λ _ e → transport (ua (invEquiv e)) ≡ transport (sym (ua e))) refl e
isSet-subst : ∀ {ℓ ℓ′} {A : Type ℓ} {B : A → Type ℓ′}
→ (isSet-A : isSet A)
→ ∀ {a : A}
→ (p : a ≡ a) → (x : B a) → subst B p x ≡ x
isSet-subst {B = B} isSet-A p x = subst (λ p′ → subst B p′ x ≡ x) (isSet-A _ _ refl p) (substRefl {B = B} x)
-- substituting along a composite path is equivalent to substituting twice
substComposite : ∀ {ℓ ℓ′} {A : Type ℓ} → (B : A → Type ℓ′)
→ {x y z : A} (p : x ≡ y) (q : y ≡ z) (u : B x)
→ subst B (p ∙ q) u ≡ subst B q (subst B p u)
substComposite B p q Bx i =
transport (cong B (compPath-filler' p q (~ i))) (transport-fillerExt (cong B p) i Bx)
-- transporting along a composite path is equivalent to transporting twice
transportComposite : ∀ {ℓ} {A B C : Type ℓ} (p : A ≡ B) (q : B ≡ C) (x : A)
→ transport (p ∙ q) x ≡ transport q (transport p x)
transportComposite = substComposite (λ D → D)
-- substitution commutes with morphisms in slices
substCommSlice : ∀ {ℓ ℓ′} {A : Type ℓ}
→ (B C : A → Type ℓ′)
→ (F : ∀ i → B i → C i)
→ {x y : A} (p : x ≡ y) (u : B x)
→ subst C p (F x u) ≡ F y (subst B p u)
substCommSlice B C F p Bx i =
transport-fillerExt⁻ (cong C p) i (F _ (transport-fillerExt (cong B p) i Bx))
-- transporting over (λ i → B (p i) → C (p i)) divides the transport into
-- transports over (λ i → C (p i)) and (λ i → B (p (~ i)))
funTypeTransp : ∀ {ℓ ℓ'} {A : Type ℓ} (B C : A → Type ℓ') {x y : A} (p : x ≡ y) (f : B x → C x)
→ PathP (λ i → B (p i) → C (p i)) f (subst C p ∘ f ∘ subst B (sym p))
funTypeTransp B C {x = x} p f i b =
transp (λ j → C (p (j ∧ i))) (~ i) (f (transp (λ j → B (p (i ∧ ~ j))) (~ i) b))
-- transports between loop spaces preserve path composition
overPathFunct : ∀ {ℓ} {A : Type ℓ} {x y : A} (p q : x ≡ x) (P : x ≡ y)
→ transport (λ i → P i ≡ P i) (p ∙ q)
≡ transport (λ i → P i ≡ P i) p ∙ transport (λ i → P i ≡ P i) q
overPathFunct p q =
J (λ y P → transport (λ i → P i ≡ P i) (p ∙ q) ≡ transport (λ i → P i ≡ P i) p ∙ transport (λ i → P i ≡ P i) q)
(transportRefl (p ∙ q) ∙ cong₂ _∙_ (sym (transportRefl p)) (sym (transportRefl q)))
| 44.16129
| 113
| 0.540979
|
59f5de4d3f5330b3d95e4a4f7d9ae69862da9934
| 4,866
|
agda
|
Agda
|
src/hott/truncation/equality.agda
|
pcapriotti/agda-base
|
bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c
|
[
"BSD-3-Clause"
] | 20
|
2015-06-12T12:20:17.000Z
|
2022-02-01T11:25:54.000Z
|
src/hott/truncation/equality.agda
|
pcapriotti/agda-base
|
bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c
|
[
"BSD-3-Clause"
] | 4
|
2015-02-02T14:32:16.000Z
|
2016-10-26T11:57:26.000Z
|
src/hott/truncation/equality.agda
|
pcapriotti/agda-base
|
bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c
|
[
"BSD-3-Clause"
] | 4
|
2015-02-02T12:17:00.000Z
|
2019-05-04T19:31:00.000Z
|
{-# OPTIONS --without-K #-}
module hott.truncation.equality where
open import sum
open import equality
open import function.extensionality
open import function.isomorphism
open import function.overloading
open import sets.nat
open import hott.equivalence
open import hott.level.core
open import hott.level.closure
open import hott.truncation.core
module _ {i}{X : Set i}(n-1 : ℕ) where
private
n : ℕ
n = suc n-1
Trunc-dep-iso₂ : ∀ {j} (Z : Trunc n X → Trunc n X → Set j)
→ ((c c' : Trunc n X) → h n (Z c c'))
→ ((c c' : Trunc n X) → Z c c')
≅ ((x y : X) → Z [ x ] [ y ])
Trunc-dep-iso₂ Z hZ = begin
((c c' : Trunc n X) → Z c c')
≅⟨ (Π-ap-iso refl≅ λ c → Trunc-dep-iso n (Z c) (hZ c)) ⟩
((c : Trunc n X)(y : X) → Z c [ y ])
≅⟨ Trunc-dep-iso n (λ c → (y : X) → Z c [ y ]) (λ c → Π-level λ y → hZ c [ y ]) ⟩
((x y : X) → Z [ x ] [ y ])
∎
where open ≅-Reasoning
P₀ : X → X → Type i (n-1)
P₀ x y = Trunc (n-1) (x ≡ y) , Trunc-level n-1
abstract
r₀ : (x : X) → proj₁ (P₀ x x)
r₀ x = [ refl ]
abstract
P-iso' : (Trunc n X → Trunc n X → Type i (n-1))
≅ (X → X → Type i (n-1))
P-iso' = Trunc-dep-iso₂ (λ _ _ → Type i (n-1))
(λ _ _ → type-level)
P-iso-we : weak-equiv (λ (Z : Trunc n X → Trunc n X → Type i (n-1)) x y → Z [ x ] [ y ])
P-iso-we = proj₂ (≅⇒≈ P-iso')
P-iso : (Trunc n X → Trunc n X → Type i (n-1))
≅ (X → X → Type i (n-1))
P-iso = ≈⇒≅ ((λ Z x y → Z [ x ] [ y ]) , P-iso-we)
module impl (P : Trunc n X → Trunc n X → Type i (n-1))
(P-β : (x y : X) → P [ x ] [ y ] ≡ P₀ x y) where
r' : (P : Trunc n X → Trunc n X → Type i (n-1))
→ (∀ x y → P [ x ] [ y ] ≡ P₀ x y)
→ (c : Trunc n X) → proj₁ (P c c)
r' P q = Trunc-dep-elim n (λ c → proj₁ (P c c))
(λ c → h↑ (proj₂ (P c c)))
λ x → subst proj₁ (sym (q x x)) (r₀ x)
r : (c : Trunc n X) → proj₁ (P c c)
r = r' P P-β
abstract
P-elim-iso : (Z : Trunc n X → Trunc n X → Type i (n-1))
→ ((c c' : Trunc n X) → proj₁ (P c c') → proj₁ (Z c c'))
≅ ((c : Trunc n X) → proj₁ (Z c c))
P-elim-iso Z = begin
((c c' : Trunc n X) → proj₁ (P c c') → proj₁ (Z c c'))
≅⟨ Trunc-dep-iso₂ (λ c c' → proj₁ (P c c') → proj₁ (Z c c'))
(λ c c' → Π-level λ p → h↑ (proj₂ (Z c c'))) ⟩
((x y : X) → proj₁ (P [ x ] [ y ]) → proj₁ (Z [ x ] [ y ]))
≅⟨ ( Π-ap-iso refl≅ λ x
→ Π-ap-iso refl≅ λ y
→ Π-ap-iso (≡⇒≅ (ap proj₁ (P-β x y))) λ _
→ refl≅ ) ⟩
((x y : X) → Trunc (n-1) (x ≡ y) → proj₁ (Z [ x ] [ y ]))
≅⟨ ( Π-ap-iso refl≅ λ x
→ Π-ap-iso refl≅ λ y
→ Trunc-elim-iso (n-1) (x ≡ y) _ (proj₂ (Z [ x ] [ y ])) ) ⟩
((x y : X) → x ≡ y → proj₁ (Z [ x ] [ y ]))
≅⟨ ( Π-ap-iso refl≅ λ x → sym≅ J-iso ) ⟩
((x : X) → proj₁ (Z [ x ] [ x ]))
≅⟨ sym≅ (Trunc-dep-iso n (λ c → proj₁ (Z c c)) (λ c → h↑ (proj₂ (Z c c)))) ⟩
((c : Trunc n X) → proj₁ (Z c c))
∎
where open ≅-Reasoning
Eq : Trunc n X → Trunc n X → Type i (n-1)
Eq c c' = (c ≡ c') , Trunc-level n c c'
abstract
f₀ : (c c' : Trunc n X) → proj₁ (P c c') → c ≡ c'
f₀ = _≅_.from (P-elim-iso Eq) (λ _ → refl)
abstract
f : (c c' : Trunc n X) → proj₁ (P c c') → c ≡ c'
f c c' p = f₀ c c' p · sym (f₀ c' c' (r c'))
f-β : (c : Trunc n X) → f c c (r c) ≡ refl
f-β c = left-inverse (f₀ c c (r c))
g : (c c' : Trunc n X) → c ≡ c' → proj₁ (P c c')
g c .c refl = r c
-- α : (c c' : Trunc n X)(p : proj₁ (P c c')) → g c c' (f c c' p) ≡ p
-- α = _≅_.from (P-elim-dep-iso Z) λ c → ap (g c c) (f-β c)
-- where
-- Z : (c c' : Trunc n X) → proj₁ (P c c') → Type i (n-1)
-- Z c c' p = (g c c' (f c c' p) ≡ p) , h↑ (proj₂ (P c c')) _ _
β : (c c' : Trunc n X)(q : c ≡ c') → f c c' (g c c' q) ≡ q
β c .c refl = f-β c
trunc-equality : {x y : X} → _≡_ {A = Trunc n X} [ x ] [ y ] → Trunc (n-1) (x ≡ y)
trunc-equality {x}{y} p = subst (λ Z → Z) (ap proj₁ (P-β x y)) (g [ x ] [ y ] p)
P : Trunc n X → Trunc n X → Type i (n-1)
P = _≅_.from P-iso P₀
P-β' : (λ x y → P [ x ] [ y ]) ≡ P₀
P-β' = _≅_.iso₂ P-iso P₀
P-β : (x y : X) → P [ x ] [ y ] ≡ P₀ x y
P-β x y = funext-inv (funext-inv P-β' x) y
open impl P P-β using (trunc-equality) public
| 37.430769
| 96
| 0.394986
|
2073a9070726ee3ba5f653b4dc03f5c91b1ef454
| 536
|
agda
|
Agda
|
neg-datatype-nonterm.agda
|
rfindler/ial
|
f3f0261904577e930bd7646934f756679a6cbba6
|
[
"MIT"
] | 29
|
2019-02-06T13:09:31.000Z
|
2022-03-04T15:05:12.000Z
|
neg-datatype-nonterm.agda
|
rfindler/ial
|
f3f0261904577e930bd7646934f756679a6cbba6
|
[
"MIT"
] | 8
|
2018-07-09T22:53:38.000Z
|
2022-03-22T03:43:34.000Z
|
neg-datatype-nonterm.agda
|
rfindler/ial
|
f3f0261904577e930bd7646934f756679a6cbba6
|
[
"MIT"
] | 17
|
2018-12-03T22:38:15.000Z
|
2021-11-28T20:13:21.000Z
|
{-# OPTIONS --no-positivity-check #-}
{- This file gives a standard example showing that if arguments to
constructors can use the datatype in a negative position (to the
left of one or an odd number of arrows), then termination and
logical consistency is lost. -}
module neg-datatype-nonterm where
open import empty
data Bad : Set where
bad : (Bad → ⊥) → Bad
badFunc : Bad → ⊥
badFunc (bad f) = f (bad f)
-- if you try to normalize the following, it will diverge
inconsistency : ⊥
inconsistency = badFunc (bad badFunc)
| 26.8
| 67
| 0.714552
|
12f85fc96c2f6c11292737fc200ce9b1bca53e60
| 1,118
|
agda
|
Agda
|
Categories/Groupoid/Coproduct.agda
|
copumpkin/categories
|
36f4181d751e2ecb54db219911d8c69afe8ba892
|
[
"BSD-3-Clause"
] | 98
|
2015-04-15T14:57:33.000Z
|
2022-03-08T05:20:36.000Z
|
Categories/Groupoid/Coproduct.agda
|
copumpkin/categories
|
36f4181d751e2ecb54db219911d8c69afe8ba892
|
[
"BSD-3-Clause"
] | 19
|
2015-05-23T06:47:10.000Z
|
2019-08-09T16:31:40.000Z
|
Categories/Groupoid/Coproduct.agda
|
copumpkin/categories
|
36f4181d751e2ecb54db219911d8c69afe8ba892
|
[
"BSD-3-Clause"
] | 23
|
2015-02-05T13:03:09.000Z
|
2021-11-11T13:50:56.000Z
|
{-# OPTIONS --universe-polymorphism #-}
module Categories.Groupoid.Coproduct where
open import Level
open import Data.Sum
open import Categories.Category
open import Categories.Groupoid
open import Categories.Morphisms
import Categories.Coproduct as CoproductC
Coproduct : ∀ {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′}
→ Groupoid C → Groupoid D → Groupoid (CoproductC.Coproduct C D)
Coproduct C D = record
{ _⁻¹ = λ { {inj₁ _} {inj₁ _} → λ { {lift f} → lift (C._⁻¹ f) }
; {inj₁ _} {inj₂ _} (lift ())
; {inj₂ _} {inj₁ _} (lift ())
; {inj₂ _} {inj₂ _} → λ { {lift f} → lift (D._⁻¹ f) }
}
; iso = λ { {inj₁ _} {inj₁ _} → record { isoˡ = lift (Iso.isoˡ C.iso)
; isoʳ = lift (Iso.isoʳ C.iso) }
; {inj₁ _} {inj₂ _} {lift ()}
; {inj₂ _} {inj₁ _} {lift ()}
; {inj₂ _} {inj₂ _} → record { isoˡ = lift (Iso.isoˡ D.iso)
; isoʳ = lift (Iso.isoʳ D.iso) }
}
}
where
module C = Groupoid C
module D = Groupoid D
| 34.9375
| 75
| 0.516995
|
5932c8d17f4b9023e0e3dea0f20916a4d4a3d2e0
| 2,412
|
agda
|
Agda
|
test/Succeed/Erasure-succeed-Issue3855.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 2
|
2019-10-29T09:40:30.000Z
|
2020-09-20T00:28:57.000Z
|
test/Succeed/Erasure-succeed-Issue3855.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 3
|
2018-11-14T15:31:44.000Z
|
2019-04-01T19:39:26.000Z
|
test/Succeed/Erasure-succeed-Issue3855.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1
|
2015-09-15T14:36:15.000Z
|
2015-09-15T14:36:15.000Z
|
-- Andreas, 2019-06-18, LAIM 2019, issue #3855:
-- Successful tests for the erasure (@0) modality.
module _ where
open import Agda.Builtin.Bool
open import Agda.Builtin.Nat
open import Agda.Builtin.Equality
open import Agda.Builtin.Coinduction
open import Common.IO
module WhereInErasedDeclaration where
@0 n : Nat
n = 4711
@0 m : Nat
m = n'
where
n' = n
module ErasedDeclarationInWhere where
F : (G : @0 Set → Set) (@0 A : Set) → Set
F G A = G B
where
@0 B : Set
B = A
module FlatErasure where
@0 resurrect-λ : (A : Set) (@0 x : A) → A
resurrect-λ A = λ x → x
-- Andreas, 2019-10-01:
-- An extended lambda now lives in @ω by default,
-- making this test fail.
-- We need to find a way to tell when an extended lambda
-- should be created in @0. Often, when it is created
-- in the type world, we still want to use it in the term
-- world (in solutions found by the constraint solver).
-- Thus, we cannot simply inherit the current quantity
-- for the extended lambda.
-- @0 resurrect-λ-where : (A : Set) (@0 x : A) → A
-- resurrect-λ-where A = λ where x → x
@0 resurrect-app : (A : Set) (@0 x : A) → A
resurrect-app A x = x
module ErasedEquality where
-- Should maybe not work --without-K
-- should definitely not work in --cubical
cast : ∀{A B : Set} → @0 A ≡ B → A → B
cast refl x = x
J : ∀{A : Set} {a : A} (P : (x : A) → a ≡ x → Set) {b : A}
(@0 eq : a ≡ b) → P a refl → P b eq
J P refl p = p
module ParametersAreErased where
test : (@0 A : Set) → A ≡ A
test A = refl {x = _} -- TODO: A instead of _
module Records where
record R (A : Set) : Set where
field
el : A
Par : Set
Par = A -- record module parameters are NOT erased, so, this should be accepted
proj : (A : Set) → R A → A -- TODO: @0 A instead of A
proj A r = R.el {A = _} r
MyPar : (A : Set) → R A → Set
MyPar A = R.Par {A = A}
record RB (b : Bool) : Set where
bPar : Bool
bPar = b
myBPar : (b : Bool) → RB b → Bool
myBPar b r = RB.bPar {b = b} r
module CoinductionWithErasure (A : Set) where
data Stream : Set where
cons : (x : A) (xs : ∞ Stream) → Stream
-- Andreas, 2019-10-01:
-- A #-auxiliary function lives in @ω by default,
-- making this test fail.
-- @0 repeat : (@0 a : A) → Stream
-- repeat a = cons a (♯ (repeat a))
main = putStrLn "Hello, world!"
| 23.647059
| 86
| 0.592869
|
298bad9e4988aa3d4cdf4f8174a8417e3eb7e987
| 700
|
agda
|
Agda
|
test/Succeed/Issue1366a.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue1366a.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue1366a.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2014-11-25, variant of Issue 1366
{-# OPTIONS --copatterns #-}
open import Common.Prelude using (Nat; zero; suc; Unit; unit)
data Vec (A : Set) : Nat → Set where
[] : Vec A zero
_∷_ : ∀ {n} → A → Vec A n → Vec A (suc n)
-- Singleton type
data Sg {A : Set} (x : A) : Set where
sg : Sg x
-- Generalizing Unit → Nat
record DNat : Set₁ where
field
D : Set
force : D → Nat
open DNat
nonNil : ∀ {n} → Vec Unit n → Nat
nonNil [] = zero
nonNil (i ∷ is) = suc (force f i) where
f : DNat
D f = Unit
force f unit = zero
g : ∀ {n} {v : Vec Unit n} → Sg (nonNil v) → Sg v
g sg = sg
one : Sg (suc zero)
one = sg
test : Sg (unit ∷ [])
test = g one
| 17.948718
| 61
| 0.55
|
1d2eca79b897778275812cea41852f92b29cc410
| 16,736
|
agda
|
Agda
|
Cubical/Data/BinNat/BinNat.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 301
|
2018-10-17T18:00:24.000Z
|
2022-03-24T02:10:47.000Z
|
Cubical/Data/BinNat/BinNat.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 584
|
2018-10-15T09:49:02.000Z
|
2022-03-30T12:09:17.000Z
|
Cubical/Data/BinNat/BinNat.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 134
|
2018-11-16T06:11:03.000Z
|
2022-03-23T16:22:13.000Z
|
{- Binary natural numbers (Anders Mörtberg, Jan. 2019)
This file defines two representations of binary numbers. We prove that
they are equivalent to unary numbers and univalence is then used to
transport both programs and properties between the representations.
This is an example of how having computational univalence can be
useful for practical programming.
The first definition is [Binℕ] and the numbers are essentially lists
of 0/1 with no trailing zeroes (in little-endian format). The main
definitions and examples are:
- Equivalence between Binℕ and ℕ ([Binℕ≃ℕ]) with an equality obtained
using univalence ([Binℕ≡ℕ]).
- Addition on Binℕ defined by transporting addition on ℕ to Binℕ
([_+Binℕ_]) along Binℕ≡ℕ together with a proof that addition on Binℕ
is associative obtained by transporting the proof for ℕ ([+Binℕ-assoc]).
- Functions testing whether a binary number is odd or even in O(1)
([oddBinℕ], [evenBinℕ]) and the corresponding functions for ℕ
obtained by transport. Proof that odd numbers are not even
transported from Binℕ to ℕ ([oddℕnotEvenℕ]).
- An example of the structure identity principle for natural number
structures ([NatImpl]). We first prove that Binℕ≡ℕ lifts to natural
number structures ([NatImplℕ≡Binℕ]) and we then use this to
transport "+-suc : m + suc n ≡ suc (m + n)" from ℕ to Binℕ ([+Binℕ-suc]).
- An example of program/data refinement using the structure identity
principle where we transport a property that is infeasible to prove
by computation for ℕ ([propDoubleℕ]):
2^20 · 2^10 = 2^5 · (2^15 · 2^10)
from the corresponding result on Binℕ which is proved instantly by
refl ([propDoubleBinℕ]).
These examples are inspired from an old cubicaltt formalization:
https://github.com/mortberg/cubicaltt/blob/master/examples/binnat.ctt
which itself is based on an even older cubical formalization (from 2014):
https://github.com/simhu/cubical/blob/master/examples/binnat.cub
The second representation is more non-standard and inspired by:
https://github.com/RedPRL/redtt/blob/master/library/cool/nats.red
Only some of the experiments have been done for this representation,
but it has the virtue of being a bit simpler to prove equivalent to
ℕ. The same representation can be found in:
http://www.cs.bham.ac.uk/~mhe/agda-new/BinaryNaturals.html
-}
{-# OPTIONS --no-exact-split --safe #-}
module Cubical.Data.BinNat.BinNat where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.Isomorphism
open import Cubical.Data.Nat
open import Cubical.Data.Bool
open import Cubical.Data.Empty
open import Cubical.Relation.Nullary
data Binℕ : Type₀
data Pos : Type₀
-- Binary natural numbers
data Binℕ where
binℕ0 : Binℕ
binℕpos : Pos → Binℕ
-- Positive binary numbers
data Pos where
x0 : Pos → Pos
x1 : Binℕ → Pos
pattern pos1 = x1 binℕ0
pattern x1-pos n = x1 (binℕpos n)
-- Note on notation:
-- We use "⇒" for functions that are equivalences (and therefore
-- they don't preserve the numerical value where the ranges don't
-- match, as with Binℕ⇒Pos).
--
-- We use "→" for the opposite situation (numerical value is preserved,
-- but the function is not necessarily an equivalence)
Binℕ⇒Pos : Binℕ → Pos
sucPos : Pos → Pos
Binℕ⇒Pos binℕ0 = pos1
Binℕ⇒Pos (binℕpos n) = sucPos n
sucPos (x0 ps) = x1-pos ps
sucPos (x1 ps) = x0 (Binℕ⇒Pos ps)
Binℕ→ℕ : Binℕ → ℕ
Pos⇒ℕ : Pos → ℕ
Pos→ℕ : Pos → ℕ
Binℕ→ℕ binℕ0 = zero
Binℕ→ℕ (binℕpos x) = Pos→ℕ x
Pos→ℕ ps = suc (Pos⇒ℕ ps)
Pos⇒ℕ (x0 ps) = suc (doubleℕ (Pos⇒ℕ ps))
Pos⇒ℕ (x1 ps) = doubleℕ (Binℕ→ℕ ps)
posInd : {P : Pos → Type₀} → P pos1 → ((p : Pos) → P p → P (sucPos p)) → (p : Pos) → P p
posInd {P} h1 hs ps = f ps
where
H : (p : Pos) → P (x0 p) → P (x0 (sucPos p))
H p hx0p = hs (x1-pos p) (hs (x0 p) hx0p)
f : (ps : Pos) → P ps
f pos1 = h1
f (x0 ps) = posInd (hs pos1 h1) H ps
f (x1-pos ps) = hs (x0 ps) (posInd (hs pos1 h1) H ps)
Binℕ⇒Pos⇒ℕ : (p : Binℕ) → Pos⇒ℕ (Binℕ⇒Pos p) ≡ Binℕ→ℕ p
Binℕ⇒Pos⇒ℕ binℕ0 = refl
Binℕ⇒Pos⇒ℕ (binℕpos (x0 p)) = refl
Binℕ⇒Pos⇒ℕ (binℕpos (x1 x)) = λ i → suc (doubleℕ (Binℕ⇒Pos⇒ℕ x i))
Pos⇒ℕsucPos : (p : Pos) → Pos⇒ℕ (sucPos p) ≡ suc (Pos⇒ℕ p)
Pos⇒ℕsucPos p = Binℕ⇒Pos⇒ℕ (binℕpos p)
Pos→ℕsucPos : (p : Pos) → Pos→ℕ (sucPos p) ≡ suc (Pos→ℕ p)
Pos→ℕsucPos p = cong suc (Binℕ⇒Pos⇒ℕ (binℕpos p))
ℕ⇒Pos : ℕ → Pos
ℕ⇒Pos zero = pos1
ℕ⇒Pos (suc n) = sucPos (ℕ⇒Pos n)
ℕ→Pos : ℕ → Pos
ℕ→Pos zero = pos1
ℕ→Pos (suc n) = ℕ⇒Pos n
Pos⇒ℕ⇒Pos : (p : Pos) → ℕ⇒Pos (Pos⇒ℕ p) ≡ p
Pos⇒ℕ⇒Pos p = posInd refl hs p
where
hs : (p : Pos) → ℕ⇒Pos (Pos⇒ℕ p) ≡ p → ℕ⇒Pos (Pos⇒ℕ (sucPos p)) ≡ sucPos p
hs p hp =
ℕ⇒Pos (Pos⇒ℕ (sucPos p)) ≡⟨ cong ℕ⇒Pos (Pos⇒ℕsucPos p) ⟩
sucPos (ℕ⇒Pos (Pos⇒ℕ p)) ≡⟨ cong sucPos hp ⟩
sucPos p ∎
ℕ⇒Pos⇒ℕ : (n : ℕ) → Pos⇒ℕ (ℕ⇒Pos n) ≡ n
ℕ⇒Pos⇒ℕ zero = refl
ℕ⇒Pos⇒ℕ (suc n) =
Pos⇒ℕ (ℕ⇒Pos (suc n)) ≡⟨ Pos⇒ℕsucPos (ℕ⇒Pos n) ⟩
suc (Pos⇒ℕ (ℕ⇒Pos n)) ≡⟨ cong suc (ℕ⇒Pos⇒ℕ n) ⟩
suc n ∎
ℕ→Binℕ : ℕ → Binℕ
ℕ→Binℕ zero = binℕ0
ℕ→Binℕ (suc n) = binℕpos (ℕ⇒Pos n)
ℕ→Binℕ→ℕ : (n : ℕ) → Binℕ→ℕ (ℕ→Binℕ n) ≡ n
ℕ→Binℕ→ℕ zero = refl
ℕ→Binℕ→ℕ (suc n) = cong suc (ℕ⇒Pos⇒ℕ n)
Binℕ→ℕ→Binℕ : (n : Binℕ) → ℕ→Binℕ (Binℕ→ℕ n) ≡ n
Binℕ→ℕ→Binℕ binℕ0 = refl
Binℕ→ℕ→Binℕ (binℕpos p) = cong binℕpos (Pos⇒ℕ⇒Pos p)
Binℕ≃ℕ : Binℕ ≃ ℕ
Binℕ≃ℕ = isoToEquiv (iso Binℕ→ℕ ℕ→Binℕ ℕ→Binℕ→ℕ Binℕ→ℕ→Binℕ)
-- Use univalence (in fact only "ua") to get an equality from the
-- above equivalence
Binℕ≡ℕ : Binℕ ≡ ℕ
Binℕ≡ℕ = ua Binℕ≃ℕ
sucBinℕ : Binℕ → Binℕ
sucBinℕ x = binℕpos (Binℕ⇒Pos x)
Binℕ→ℕsuc : (x : Binℕ) → suc (Binℕ→ℕ x) ≡ Binℕ→ℕ (sucBinℕ x)
Binℕ→ℕsuc binℕ0 = refl
Binℕ→ℕsuc (binℕpos x) = sym (Pos→ℕsucPos x)
-- We can transport addition on ℕ to Binℕ
_+Binℕ_ : Binℕ → Binℕ → Binℕ
_+Binℕ_ = transport (λ i → Binℕ≡ℕ (~ i) → Binℕ≡ℕ (~ i) → Binℕ≡ℕ (~ i)) _+_
-- Test: 4 + 1 = 5
private
_ : binℕpos (x0 (x0 pos1)) +Binℕ binℕpos pos1 ≡ binℕpos (x1-pos (x0 pos1))
_ = refl
-- It is easy to test if binary numbers are odd
oddBinℕ : Binℕ → Bool
oddBinℕ binℕ0 = false
oddBinℕ (binℕpos (x0 _)) = false
oddBinℕ (binℕpos (x1 _)) = true
evenBinℕ : Binℕ → Bool
evenBinℕ n = oddBinℕ (sucBinℕ n)
-- And prove the following property (without induction)
oddBinℕnotEvenBinℕ : (n : Binℕ) → oddBinℕ n ≡ not (evenBinℕ n)
oddBinℕnotEvenBinℕ binℕ0 = refl
oddBinℕnotEvenBinℕ (binℕpos (x0 x)) = refl
oddBinℕnotEvenBinℕ (binℕpos (x1 x)) = refl
-- It is also easy to define and prove the property for unary numbers,
-- however the definition uses recursion and the proof induction
private
oddn : ℕ → Bool
oddn zero = true
oddn (suc x) = not (oddn x)
evenn : ℕ → Bool
evenn n = not (oddn n)
oddnSuc : (n : ℕ) → oddn n ≡ not (evenn n)
oddnSuc zero = refl
oddnSuc (suc n) = cong not (oddnSuc n)
-- So what we can do instead is to transport the odd test from Binℕ to
-- ℕ along the equality
oddℕ : ℕ → Bool
oddℕ = transport (λ i → Binℕ≡ℕ i → Bool) oddBinℕ
evenℕ : ℕ → Bool
evenℕ = transport (λ i → Binℕ≡ℕ i → Bool) evenBinℕ
-- We can then also transport the property
oddℕnotEvenℕ : (n : ℕ) → oddℕ n ≡ not (evenℕ n)
oddℕnotEvenℕ =
let -- We first build a path from oddBinℕ to oddℕ. When i=1 this is
-- "transp (λ j → Binℕ≡ℕ j → Bool) i0 oddBinℕ" (i.e. oddℕ)
oddp : PathP (λ i → Binℕ≡ℕ i → Bool) oddBinℕ oddℕ
oddp i = transp (λ j → Binℕ≡ℕ (i ∧ j) → Bool) (~ i) oddBinℕ
-- We then build a path from evenBinℕ to evenℕ
evenp : PathP (λ i → Binℕ≡ℕ i → Bool) evenBinℕ evenℕ
evenp i = transp (λ j → Binℕ≡ℕ (i ∧ j) → Bool) (~ i) evenBinℕ
in -- Then transport oddBinℕnotEvenBinℕ in a suitable equality type
-- When i=0 this is "(n : Binℕ) → oddBinℕ n ≡ not (evenBinℕ n)"
-- When i=1 this is "(n : ℕ) → oddℕ n ≡ not (evenℕ n)"
transport (λ i → (n : Binℕ≡ℕ i) → oddp i n ≡ not (evenp i n)) oddBinℕnotEvenBinℕ
-- We can do the same for natural numbers:
-- First construct the path
addp : PathP (λ i → Binℕ≡ℕ (~ i) → Binℕ≡ℕ (~ i) → Binℕ≡ℕ (~ i)) _+_ _+Binℕ_
addp i = transp (λ j → Binℕ≡ℕ (~ i ∨ ~ j) → Binℕ≡ℕ (~ i ∨ ~ j) → Binℕ≡ℕ (~ i ∨ ~ j)) (~ i) _+_
-- Then transport associativity:
+Binℕ-assoc : ∀ m n o → m +Binℕ (n +Binℕ o) ≡ (m +Binℕ n) +Binℕ o
+Binℕ-assoc =
transport (λ i → (m n o : Binℕ≡ℕ (~ i))
→ addp i m (addp i n o) ≡ addp i (addp i m n) o) +-assoc
-- We can also define what it means to be an implementation of natural
-- numbers and use this to transport properties between different
-- implementation of natural numbers. This can be seen as a special
-- case of the structure identity principle: any property that holds
-- for one structure also holds for an equivalent one.
-- An implementation of natural numbers (i.e. a "natural number
-- structure") has a zero and successor.
record NatImpl (A : Type₀) : Type₀ where
field
z : A
s : A → A
open NatImpl
NatImplℕ : NatImpl ℕ
z NatImplℕ = zero
s NatImplℕ = suc
NatImplBinℕ : NatImpl Binℕ
z NatImplBinℕ = binℕ0
s NatImplBinℕ = sucBinℕ
-- Using the equality between binary and unary numbers we can get an
-- equality between the two implementations of the NatImpl interface
NatImplℕ≡Binℕ : PathP (λ i → NatImpl (Binℕ≡ℕ (~ i))) NatImplℕ NatImplBinℕ
z (NatImplℕ≡Binℕ i) = transp (λ j → Binℕ≡ℕ (~ i ∨ ~ j)) (~ i) zero
s (NatImplℕ≡Binℕ i) =
λ x → glue (λ { (i = i0) → suc x
; (i = i1) → sucBinℕ x })
-- We need to do use and hcomp to do and endpoint
-- correction as "suc (unglue x)" connects "suc x"
-- with "suc (Binℕ→ℕ x)" along i (which makes sense as
-- x varies from ℕ to Binℕ along i), but we need
-- something from "suc x" to "Binℕ→ℕ (sucBinℕ x)" for
-- the glue to be well-formed
(hcomp (λ j → λ { (i = i0) → suc x
; (i = i1) → Binℕ→ℕsuc x j })
(suc (unglue (i ∨ ~ i) x)))
-- We then use this to transport +-suc from unary to binary numbers
+Binℕ-suc : ∀ m n → m +Binℕ sucBinℕ n ≡ sucBinℕ (m +Binℕ n)
+Binℕ-suc =
transport (λ i → (m n : Binℕ≡ℕ (~ i))
→ addp i m (NatImplℕ≡Binℕ i .s n) ≡ NatImplℕ≡Binℕ i .s (addp i m n)) +-suc
-- Doubling experiment: we define a notion of "doubling structure" and
-- transport a proof that is proved directly using refl for binary
-- numbers to unary numbers. This is an example of program/data
-- refinement: we can use univalence to prove properties about
-- inefficient data-structures using efficient ones.
-- Doubling structures
record Double {ℓ} (A : Type ℓ) : Type (ℓ-suc ℓ) where
field
-- doubling function computing 2 · x
double : A → A
-- element to double
elt : A
open Double
-- Compute: 2^n · x
doubles : ∀ {ℓ} {A : Type ℓ} (D : Double A) → ℕ → A → A
doubles D n x = iter n (double D) x
Doubleℕ : Double ℕ
double Doubleℕ = doubleℕ
elt Doubleℕ = n1024
where
-- 1024 = 2^8 · 2^2 = 2^10
n1024 : ℕ
n1024 = doublesℕ 8 4
-- The doubling operation on binary numbers is O(1), while for unary
-- numbers it is O(n). What is of course even more problematic is that
-- we cannot handle very big unary natural numbers, but with binary
-- there is no problem to represent very big numbers
doubleBinℕ : Binℕ → Binℕ
doubleBinℕ binℕ0 = binℕ0
doubleBinℕ (binℕpos x) = binℕpos (x0 x)
DoubleBinℕ : Double Binℕ
double DoubleBinℕ = doubleBinℕ
elt DoubleBinℕ = bin1024
where
-- 1024 = 2^10 = 10000000000₂
bin1024 : Binℕ
bin1024 = binℕpos (x0 (x0 (x0 (x0 (x0 (x0 (x0 (x0 (x0 (x0 pos1))))))))))
-- As these function don't commute strictly we have to prove it
-- separately and insert it in the proof of DoubleBinℕ≡Doubleℕ below
-- (just like we had to in NatImplℕ≡NatImplBinℕ
Binℕ→ℕdouble : (x : Binℕ) → doubleℕ (Binℕ→ℕ x) ≡ Binℕ→ℕ (doubleBinℕ x)
Binℕ→ℕdouble binℕ0 = refl
Binℕ→ℕdouble (binℕpos x) = refl
-- We use the equality between Binℕ and ℕ to get an equality of
-- doubling structures
DoubleBinℕ≡Doubleℕ : PathP (λ i → Double (Binℕ≡ℕ i)) DoubleBinℕ Doubleℕ
double (DoubleBinℕ≡Doubleℕ i) =
λ x → glue (λ { (i = i0) → doubleBinℕ x
; (i = i1) → doubleℕ x })
(hcomp (λ j → λ { (i = i0) → Binℕ→ℕdouble x j
; (i = i1) → doubleℕ x })
(doubleℕ (unglue (i ∨ ~ i) x)))
elt (DoubleBinℕ≡Doubleℕ i) = transp (λ j → Binℕ≡ℕ (i ∨ ~ j)) i (Doubleℕ .elt)
-- We can now use transport to prove a property that is too slow to
-- check with unary numbers. We define the property we want to check
-- as a record so that Agda does not try to unfold it eagerly.
record propDouble {ℓ} {A : Type ℓ} (D : Double A) : Type ℓ where
field
-- 2^20 · e = 2^5 · (2^15 · e)
proof : doubles D 20 (elt D) ≡ doubles D 5 (doubles D 15 (elt D))
open propDouble
-- The property we want to prove takes too long to typecheck for ℕ:
-- propDoubleℕ : propDouble Doubleℕ
-- propDoubleℕ = refl
-- With binary numbers it is instant
propDoubleBinℕ : propDouble DoubleBinℕ
proof propDoubleBinℕ = refl
-- By transporting the proof along the equality we then get it for
-- unary numbers
propDoubleℕ : propDouble Doubleℕ
propDoubleℕ = transport (λ i → propDouble (DoubleBinℕ≡Doubleℕ i)) propDoubleBinℕ
--------------------------------------------------------------------------------
--
-- Alternative encoding of binary natural numbers inspired by:
-- https://github.com/RedPRL/redtt/blob/master/library/cool/nats.red
--
-- This representation makes the equivalence with ℕ a bit easier to
-- prove, but the doubling example wouldn't work as nicely as we
-- cannot define it as an O(1) operation
data binnat : Type₀ where
zero : binnat -- 0
consOdd : binnat → binnat -- 2·n + 1
consEven : binnat → binnat -- 2·{n+1}
binnat→ℕ : binnat → ℕ
binnat→ℕ zero = 0
binnat→ℕ (consOdd n) = suc (doubleℕ (binnat→ℕ n))
binnat→ℕ (consEven n) = suc (suc (doubleℕ (binnat→ℕ n)))
suc-binnat : binnat → binnat
suc-binnat zero = consOdd zero
suc-binnat (consOdd n) = consEven n
suc-binnat (consEven n) = consOdd (suc-binnat n)
ℕ→binnat : ℕ → binnat
ℕ→binnat zero = zero
ℕ→binnat (suc n) = suc-binnat (ℕ→binnat n)
binnat→ℕ-suc : (n : binnat) → binnat→ℕ (suc-binnat n) ≡ suc (binnat→ℕ n)
binnat→ℕ-suc zero = refl
binnat→ℕ-suc (consOdd n) = refl
binnat→ℕ-suc (consEven n) = λ i → suc (doubleℕ (binnat→ℕ-suc n i))
ℕ→binnat→ℕ : (n : ℕ) → binnat→ℕ (ℕ→binnat n) ≡ n
ℕ→binnat→ℕ zero = refl
ℕ→binnat→ℕ (suc n) = (binnat→ℕ-suc (ℕ→binnat n)) ∙ (cong suc (ℕ→binnat→ℕ n))
suc-ℕ→binnat-double : (n : ℕ) → suc-binnat (ℕ→binnat (doubleℕ n)) ≡ consOdd (ℕ→binnat n)
suc-ℕ→binnat-double zero = refl
suc-ℕ→binnat-double (suc n) = λ i → suc-binnat (suc-binnat (suc-ℕ→binnat-double n i))
binnat→ℕ→binnat : (n : binnat) → ℕ→binnat (binnat→ℕ n) ≡ n
binnat→ℕ→binnat zero = refl
binnat→ℕ→binnat (consOdd n) =
(suc-ℕ→binnat-double (binnat→ℕ n)) ∙ (cong consOdd (binnat→ℕ→binnat n))
binnat→ℕ→binnat (consEven n) =
(λ i → suc-binnat (suc-ℕ→binnat-double (binnat→ℕ n) i)) ∙ (cong consEven (binnat→ℕ→binnat n))
ℕ≃binnat : ℕ ≃ binnat
ℕ≃binnat = isoToEquiv (iso ℕ→binnat binnat→ℕ binnat→ℕ→binnat ℕ→binnat→ℕ)
ℕ≡binnat : ℕ ≡ binnat
ℕ≡binnat = ua ℕ≃binnat
-- We can transport addition on ℕ to binnat
_+binnat_ : binnat → binnat → binnat
_+binnat_ = transport (λ i → ℕ≡binnat i → ℕ≡binnat i → ℕ≡binnat i) _+_
-- Test: 4 + 1 = 5
_ : consEven (consOdd zero) +binnat consOdd zero ≡ consOdd (consEven zero)
_ = refl
oddbinnat : binnat → Bool
oddbinnat zero = false
oddbinnat (consOdd _) = true
oddbinnat (consEven _) = false
oddℕ' : ℕ → Bool
oddℕ' = transport (λ i → ℕ≡binnat (~ i) → Bool) oddbinnat
-- The NatImpl example for this representation of binary numbers
private
NatImplbinnat : NatImpl binnat
z NatImplbinnat = zero
s NatImplbinnat = suc-binnat
-- Note that the s case is a bit simpler as no end-point correction
-- is necessary (things commute strictly)
NatImplℕ≡NatImplbinnat : PathP (λ i → NatImpl (ℕ≡binnat i)) NatImplℕ NatImplbinnat
z (NatImplℕ≡NatImplbinnat i) = transp (λ j → ℕ≡binnat (i ∨ ~ j)) i zero
s (NatImplℕ≡NatImplbinnat i) =
λ x → glue (λ { (i = i0) → suc x
; (i = i1) → suc-binnat x })
(suc-binnat (unglue (i ∨ ~ i) x))
oddSuc : (n : binnat) → oddbinnat n ≡ not (oddbinnat (suc-binnat n))
oddSuc zero = refl
oddSuc (consOdd _) = refl
oddSuc (consEven _) = refl
oddℕSuc' : (n : ℕ) → oddℕ' n ≡ not (oddℕ' (suc n))
oddℕSuc' =
let eq : (i : I) → ℕ≡binnat (~ i) → Bool
eq i = transp (λ j → ℕ≡binnat (~ i ∨ ~ j) → Bool) (~ i) oddbinnat
in transport
(λ i → (n : ℕ≡binnat (~ i)) → eq i n ≡ not (eq i (NatImplℕ≡NatImplbinnat (~ i) .NatImpl.s n)))
oddSuc
| 33.947262
| 104
| 0.645734
|
0b73e4b7836da7cc0aca3b16bb39b2dafcce8b17
| 23
|
agda
|
Agda
|
test/Fail/Issue3448.agda
|
zgrannan/agda
|
5953ce337eb6b77b29ace7180478f49c541aea1c
|
[
"BSD-3-Clause"
] | null | null | null |
test/Fail/Issue3448.agda
|
zgrannan/agda
|
5953ce337eb6b77b29ace7180478f49c541aea1c
|
[
"BSD-3-Clause"
] | null | null | null |
test/Fail/Issue3448.agda
|
zgrannan/agda
|
5953ce337eb6b77b29ace7180478f49c541aea1c
|
[
"BSD-3-Clause"
] | null | null | null |
data D : _ where
D : _
| 7.666667
| 16
| 0.565217
|
fb417a5cd852d20ab35c3ae8a05d4e7e81f9f609
| 3,523
|
agda
|
Agda
|
theorems/homotopy/SuspSmashJoin.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 294
|
2015-01-09T16:23:23.000Z
|
2022-03-20T13:54:45.000Z
|
theorems/homotopy/SuspSmashJoin.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 31
|
2015-03-05T20:09:00.000Z
|
2021-10-03T19:15:25.000Z
|
theorems/homotopy/SuspSmashJoin.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 50
|
2015-01-10T01:48:08.000Z
|
2022-02-14T03:03:25.000Z
|
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import homotopy.elims.SuspSmash
open import homotopy.elims.CofPushoutSection
-- Σ(X∧Y) ≃ X * Y
module homotopy.SuspSmashJoin {i j} (X : Ptd i) (Y : Ptd j) where
private
{- path lemmas -}
private
reduce-x : ∀ {i} {A : Type i} {x y z : A} (p : x == y) (q : z == y)
→ p ∙ ! q ∙ q ∙ ! p ∙ p == p
reduce-x idp idp = idp
reduce-y : ∀ {i} {A : Type i} {x y z : A} (p : x == y) (q : x == z)
→ p ∙ ! p ∙ q ∙ ! q ∙ p == p
reduce-y idp idp = idp
module Into = SuspRec {A = Smash X Y}
{C = de⊙ X * de⊙ Y}
(left (pt X))
(right (pt Y))
(Smash-rec
(λ x y →
jglue (pt X) (pt Y) ∙ ! (jglue x (pt Y))
∙ jglue x y
∙ ! (jglue (pt X) y) ∙ jglue (pt X) (pt Y))
(jglue (pt X) (pt Y))
(jglue (pt X) (pt Y))
(λ x → reduce-x (jglue (pt X) (pt Y)) (jglue x (pt Y)))
(λ y → reduce-y (jglue (pt X) (pt Y)) (jglue (pt X) y)))
into = Into.f
module Out = JoinRec
{C = Susp (Smash X Y)}
(λ _ → north)
(λ _ → south)
(λ x y → merid (smin x y))
out = Out.f
abstract
into-out : (j : de⊙ X * de⊙ Y) → into (out j) == j
into-out = Join-elim
(λ x → glue (pt X , pt Y) ∙ ! (glue (x , pt Y)))
(λ y → ! (glue (pt X , pt Y)) ∙ glue (pt X , y))
(λ x y → ↓-∘=idf-from-square into out $
(ap (ap into) (Out.glue-β x y)
∙ Into.merid-β (smin x y))
∙v⊡ lemma (glue (pt X , pt Y)) (glue (x , pt Y))
(glue (pt X , y)) (glue (x , y)))
where
lemma : ∀ {i} {A : Type i} {x y z w : A}
(p : x == y) (q : z == y) (r : x == w) (s : z == w)
→ Square (p ∙ ! q) (p ∙ ! q ∙ s ∙ ! r ∙ p) s (! p ∙ r)
lemma idp idp idp s =
vert-degen-square (∙-unit-r s)
out-into : (σ : Susp (Smash X Y)) → out (into σ) == σ
out-into = SuspSmash-elim
idp
idp
(λ x y → ↓-∘=idf-in' out into $
ap (ap out) (Into.merid-β (smin x y))
∙ lemma₁ out (Out.glue-β (pt X) (pt Y))
(Out.glue-β x (pt Y))
(Out.glue-β x y)
(Out.glue-β (pt X) y)
(Out.glue-β (pt X) (pt Y))
∙ lemma₂ {p = merid (smin (pt X) (pt Y))}
{q = merid (smin x (pt Y))}
{r = merid (smin x y)}
{s = merid (smin (pt X) y)}
{t = merid (smin (pt X) (pt Y))}
(ap merid (smgluel (pt X) ∙ ! (smgluel x)))
(ap merid (smgluer y ∙ ! (smgluer (pt Y)))))
where
lemma₁ : ∀ {i j} {A : Type i} {B : Type j} (f : A → B)
{x y z u v w : A}
{p : x == y} {q : z == y} {r : z == u} {s : v == u} {t : v == w}
{p' : f x == f y} {q' : f z == f y} {r' : f z == f u}
{s' : f v == f u} {t' : f v == f w}
(α : ap f p == p') (β : ap f q == q') (γ : ap f r == r')
(δ : ap f s == s') (ε : ap f t == t')
→ ap f (p ∙ ! q ∙ r ∙ ! s ∙ t) == p' ∙ ! q' ∙ r' ∙ ! s' ∙ t'
lemma₁ f {p = idp} {q = idp} {r = idp} {s = idp} {t = idp}
idp idp idp idp idp
= idp
lemma₂ : ∀ {i} {A : Type i} {x y z u : A}
{p q : x == y} {r : x == z} {s t : u == z}
(α : p == q) (β : s == t)
→ p ∙ ! q ∙ r ∙ ! s ∙ t == r
lemma₂ {p = idp} {r = idp} {s = idp} idp idp = idp
module SuspSmashJoin where
eq : Susp (Smash X Y) ≃ (de⊙ X * de⊙ Y)
eq = equiv into out into-out out-into
⊙eq : ⊙Susp (X ∧ Y) ⊙≃ (X ⊙* Y)
⊙eq = ≃-to-⊙≃ eq idp
| 32.62037
| 72
| 0.400511
|
299e6b66bb23e7aaf5f9e6b8d3eac0d49568a7bd
| 1,047
|
agda
|
Agda
|
Data/Boolean/NaryOperators.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | 6
|
2020-04-07T17:58:13.000Z
|
2022-02-05T06:53:22.000Z
|
Data/Boolean/NaryOperators.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
Data/Boolean/NaryOperators.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
module Data.Boolean.NaryOperators where
open import Data.Boolean
import Data.Boolean.Operators
open Data.Boolean.Operators.Logic
open import Function.DomainRaise
open import Numeral.Natural
private variable n : ℕ
-- N-ary conjunction (AND).
-- Every term is true.
∧₊ : (n : ℕ) → (Bool →̂ Bool)(n)
∧₊(0) = 𝑇
∧₊(1) x = x
∧₊(𝐒(𝐒(n))) x = (x ∧_) ∘ (∧₊(𝐒(n)))
-- N-ary disjunction (OR).
-- There is a term which is true.
∨₊ : (n : ℕ) → (Bool →̂ Bool)(n)
∨₊(0) = 𝐹
∨₊(1) x = x
∨₊(𝐒(𝐒(n))) x = (x ∨_) ∘ (∨₊(𝐒(n)))
-- N-ary implication.
-- All left terms together imply the right-most term.
⟶₊ : (n : ℕ) → (Bool →̂ Bool)(n)
⟶₊(0) = 𝑇
⟶₊(1) x = x
⟶₊(𝐒(𝐒(n))) x = (x ⟶_) ∘ (⟶₊(𝐒(n)))
-- N-ary NAND.
-- Not every term is true.
-- There is a term which is false.
⊼₊ : (n : ℕ) → (Bool →̂ Bool)(n)
⊼₊(0) = 𝐹
⊼₊(1) x = ¬ x
⊼₊(𝐒(𝐒(n))) x = (x ⊼_) ∘ ((¬) ∘ (⊼₊(𝐒(n))))
-- N-ary NOR.
-- There are no terms that are true.
-- Every term is false.
⊽₊ : (n : ℕ) → (Bool →̂ Bool)(n)
⊽₊(0) = 𝐹
⊽₊(1) x = ¬ x
⊽₊(𝐒(𝐒(n))) x = (x ⊽_) ∘ ((¬) ∘ (⊽₊(𝐒(n))))
| 22.276596
| 53
| 0.505253
|
4d47f7b1749217bb1f56e83b4acfcc9dcbef3a7b
| 799
|
agda
|
Agda
|
agda-stdlib-0.9/src/Data/W.agda
|
qwe2/try-agda
|
9d4c43b1609d3f085636376fdca73093481ab882
|
[
"Apache-2.0"
] | 1
|
2016-10-20T15:52:05.000Z
|
2016-10-20T15:52:05.000Z
|
agda-stdlib-0.9/src/Data/W.agda
|
qwe2/try-agda
|
9d4c43b1609d3f085636376fdca73093481ab882
|
[
"Apache-2.0"
] | null | null | null |
agda-stdlib-0.9/src/Data/W.agda
|
qwe2/try-agda
|
9d4c43b1609d3f085636376fdca73093481ab882
|
[
"Apache-2.0"
] | null | null | null |
------------------------------------------------------------------------
-- The Agda standard library
--
-- W-types
------------------------------------------------------------------------
module Data.W where
open import Level
open import Relation.Nullary
-- The family of W-types.
data W {a b} (A : Set a) (B : A → Set b) : Set (a ⊔ b) where
sup : (x : A) (f : B x → W A B) → W A B
-- Projections.
head : ∀ {a b} {A : Set a} {B : A → Set b} →
W A B → A
head (sup x f) = x
tail : ∀ {a b} {A : Set a} {B : A → Set b} →
(x : W A B) → B (head x) → W A B
tail (sup x f) = f
-- If B is always inhabited, then W A B is empty.
inhabited⇒empty : ∀ {a b} {A : Set a} {B : A → Set b} →
(∀ x → B x) → ¬ W A B
inhabited⇒empty b (sup x f) = inhabited⇒empty b (f (b x))
| 24.96875
| 72
| 0.413016
|
29f98d512e1cec626a8f546f27f8f2955b25b15b
| 25,788
|
agda
|
Agda
|
src/Equality/Path/Isomorphisms.agda
|
nad/equality
|
402b20615cfe9ca944662380d7b2d69b0f175200
|
[
"MIT"
] | 3
|
2020-05-21T22:58:50.000Z
|
2021-09-02T17:18:15.000Z
|
src/Equality/Path/Isomorphisms.agda
|
nad/equality
|
402b20615cfe9ca944662380d7b2d69b0f175200
|
[
"MIT"
] | null | null | null |
src/Equality/Path/Isomorphisms.agda
|
nad/equality
|
402b20615cfe9ca944662380d7b2d69b0f175200
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- Isomorphisms and equalities relating an arbitrary "equality with J"
-- to path equality, along with a proof of extensionality for the
-- "equality with J"
------------------------------------------------------------------------
{-# OPTIONS --erased-cubical --safe #-}
import Equality.Path as P
module Equality.Path.Isomorphisms
{e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where
open P.Derived-definitions-and-properties eq
open import Prelude
import Bijection
import Embedding
import Equivalence
import Equivalence.Contractible-preimages
import Equivalence.Half-adjoint
import Function-universe
import H-level
import Surjection
import Univalence-axiom
private
module B = Bijection equality-with-J
module CP = Equivalence.Contractible-preimages equality-with-J
module HA = Equivalence.Half-adjoint equality-with-J
module Eq = Equivalence equality-with-J
module F = Function-universe equality-with-J
module PB = Bijection P.equality-with-J
module PM = Embedding P.equality-with-J
module PE = Equivalence P.equality-with-J
module PCP = Equivalence.Contractible-preimages P.equality-with-J
module PHA = Equivalence.Half-adjoint P.equality-with-J
module PF = Function-universe P.equality-with-J
module PH = H-level P.equality-with-J
module PS = Surjection P.equality-with-J
module PU = Univalence-axiom P.equality-with-J
open B using (_↔_)
open Embedding equality-with-J hiding (id; _∘_)
open Eq using (_≃_; Is-equivalence)
open F hiding (id; _∘_)
open H-level equality-with-J
open Surjection equality-with-J using (_↠_)
open Univalence-axiom equality-with-J
private
variable
a b c p q ℓ : Level
A : Type a
B : A → Type b
u v x y z : A
f g h : (x : A) → B x
n : ℕ
------------------------------------------------------------------------
-- Extensionality
-- The proof bad-ext is perhaps not less "good" than ext (I don't
-- know), it is called this simply because it is not defined using
-- good-ext.
bad-ext : Extensionality a b
apply-ext bad-ext {f = f} {g = g} =
(∀ x → f x ≡ g x) ↝⟨ (λ p x → _↔_.to ≡↔≡ (p x)) ⟩
(∀ x → f x P.≡ g x) ↝⟨ P.apply-ext P.ext ⟩
f P.≡ g ↔⟨ inverse ≡↔≡ ⟩□
f ≡ g □
-- Extensionality.
ext : Extensionality a b
ext = Eq.good-ext bad-ext
⟨ext⟩ : Extensionality′ A B
⟨ext⟩ = apply-ext ext
abstract
-- The function ⟨ext⟩ is an equivalence.
ext-is-equivalence : Is-equivalence {A = ∀ x → f x ≡ g x} ⟨ext⟩
ext-is-equivalence = Eq.good-ext-is-equivalence bad-ext
-- Equality rearrangement lemmas for ⟨ext⟩.
ext-refl : ⟨ext⟩ (λ x → refl (f x)) ≡ refl f
ext-refl = Eq.good-ext-refl bad-ext _
ext-const :
(x≡y : x ≡ y) →
⟨ext⟩ (const {B = A} x≡y) ≡ cong const x≡y
ext-const = Eq.good-ext-const bad-ext
cong-ext :
∀ (f≡g : ∀ x → f x ≡ g x) {x} →
cong (_$ x) (⟨ext⟩ f≡g) ≡ f≡g x
cong-ext = Eq.cong-good-ext bad-ext
ext-cong :
{B : Type b} {C : B → Type c}
{f : A → (x : B) → C x} {x≡y : x ≡ y} →
⟨ext⟩ (λ z → cong (flip f z) x≡y) ≡ cong f x≡y
ext-cong = Eq.good-ext-cong bad-ext
subst-ext :
∀ {f g : (x : A) → B x}
(P : B x → Type p) {p} (f≡g : ∀ x → f x ≡ g x) →
subst (λ f → P (f x)) (⟨ext⟩ f≡g) p ≡ subst P (f≡g x) p
subst-ext = Eq.subst-good-ext bad-ext
elim-ext :
(P : B x → B x → Type p)
(p : (y : B x) → P y y)
{f g : (x : A) → B x}
(f≡g : ∀ x → f x ≡ g x) →
elim (λ {f g} _ → P (f x) (g x)) (p ∘ (_$ x)) (⟨ext⟩ f≡g) ≡
elim (λ {x y} _ → P x y) p (f≡g x)
elim-ext = Eq.elim-good-ext bad-ext
-- I based the statements of the following three lemmas on code in
-- the Lean Homotopy Type Theory Library with Jakob von Raumer and
-- Floris van Doorn listed as authors. The file was claimed to have
-- been ported from the Coq HoTT library. (The third lemma has later
-- been generalised.)
ext-sym :
(f≡g : ∀ x → f x ≡ g x) →
⟨ext⟩ (sym ∘ f≡g) ≡ sym (⟨ext⟩ f≡g)
ext-sym = Eq.good-ext-sym bad-ext
ext-trans :
(f≡g : ∀ x → f x ≡ g x) (g≡h : ∀ x → g x ≡ h x) →
⟨ext⟩ (λ x → trans (f≡g x) (g≡h x)) ≡ trans (⟨ext⟩ f≡g) (⟨ext⟩ g≡h)
ext-trans = Eq.good-ext-trans bad-ext
cong-post-∘-ext :
(f≡g : ∀ x → f x ≡ g x) →
cong (h ∘_) (⟨ext⟩ f≡g) ≡ ⟨ext⟩ (cong h ∘ f≡g)
cong-post-∘-ext = Eq.cong-post-∘-good-ext bad-ext bad-ext
cong-pre-∘-ext :
(f≡g : ∀ x → f x ≡ g x) →
cong (_∘ h) (⟨ext⟩ f≡g) ≡ ⟨ext⟩ (f≡g ∘ h)
cong-pre-∘-ext = Eq.cong-pre-∘-good-ext bad-ext bad-ext
cong-∘-ext :
{A : Type a} {B : Type b} {C : Type c} {f g : B → C}
(f≡g : ∀ x → f x ≡ g x) →
cong {B = (A → B) → (A → C)}
(λ f → f ∘_) (⟨ext⟩ f≡g) ≡
⟨ext⟩ λ h → ⟨ext⟩ λ x → f≡g (h x)
cong-∘-ext = Eq.cong-∘-good-ext bad-ext bad-ext bad-ext
------------------------------------------------------------------------
-- More isomorphisms and related properties
-- Split surjections expressed using equality are equivalent to split
-- surjections expressed using paths.
↠≃↠ :
{A : Type a} {B : Type b} →
(A ↠ B) ≃ (A PS.↠ B)
↠≃↠ = Eq.↔→≃
(λ A↠B → record
{ logical-equivalence = _↠_.logical-equivalence A↠B
; right-inverse-of = _↔_.to ≡↔≡ ∘ _↠_.right-inverse-of A↠B
})
(λ A↠B → record
{ logical-equivalence = PS._↠_.logical-equivalence A↠B
; right-inverse-of = _↔_.from ≡↔≡ ∘ PS._↠_.right-inverse-of A↠B
})
(λ A↠B →
cong (λ r → record
{ logical-equivalence = PS._↠_.logical-equivalence A↠B
; right-inverse-of = r
}) $
⟨ext⟩ λ _ → _↔_.right-inverse-of ≡↔≡ _)
(λ A↠B →
cong (λ r → record
{ logical-equivalence = _↠_.logical-equivalence A↠B
; right-inverse-of = r
}) $
⟨ext⟩ λ _ → _↔_.left-inverse-of ≡↔≡ _)
private
-- Bijections expressed using paths can be converted into bijections
-- expressed using equality.
↔→↔ : {A B : Type ℓ} → A PB.↔ B → A ↔ B
↔→↔ A↔B = record
{ surjection = _≃_.from ↠≃↠ $ PB._↔_.surjection A↔B
; left-inverse-of = _↔_.from ≡↔≡ ∘ PB._↔_.left-inverse-of A↔B
}
-- Bijections expressed using equality are equivalent to bijections
-- expressed using paths.
↔≃↔ :
{A : Type a} {B : Type b} →
(A ↔ B) ≃ (A PB.↔ B)
↔≃↔ {A = A} {B = B} =
A ↔ B ↔⟨ B.↔-as-Σ ⟩
(∃ λ (f : A → B) → ∃ λ (f⁻¹ : B → A) →
(∀ x → f (f⁻¹ x) ≡ x) × (∀ x → f⁻¹ (f x) ≡ x)) ↔⟨ (∃-cong λ _ → ∃-cong λ _ →
(∀-cong ext λ _ → ≡↔≡)
×-cong
(∀-cong ext λ _ → ≡↔≡)) ⟩
(∃ λ (f : A → B) → ∃ λ (f⁻¹ : B → A) →
(∀ x → f (f⁻¹ x) P.≡ x) × (∀ x → f⁻¹ (f x) P.≡ x)) ↔⟨ inverse $ ↔→↔ $ PB.↔-as-Σ ⟩□
A PB.↔ B □
-- H-level expressed using equality is isomorphic to H-level expressed
-- using paths.
H-level↔H-level : ∀ n → H-level n A ↔ PH.H-level n A
H-level↔H-level {A = A} zero =
H-level 0 A ↔⟨⟩
(∃ λ (x : A) → ∀ y → x ≡ y) ↝⟨ (∃-cong λ _ → ∀-cong ext λ _ → ≡↔≡) ⟩
(∃ λ (x : A) → ∀ y → x P.≡ y) ↔⟨⟩
PH.H-level 0 A □
H-level↔H-level {A = A} (suc n) =
H-level (suc n) A ↝⟨ inverse $ ≡↔+ _ ext ⟩
(∀ x y → H-level n (x ≡ y)) ↝⟨ (∀-cong ext λ _ → ∀-cong ext λ _ → H-level-cong ext _ ≡↔≡) ⟩
(∀ x y → H-level n (x P.≡ y)) ↝⟨ (∀-cong ext λ _ → ∀-cong ext λ _ → H-level↔H-level n) ⟩
(∀ x y → PH.H-level n (x P.≡ y)) ↝⟨ ↔→↔ $ PF.≡↔+ _ P.ext ⟩
PH.H-level (suc n) A □
-- CP.Is-equivalence is isomorphic to PCP.Is-equivalence.
Is-equivalence-CP↔Is-equivalence-CP :
CP.Is-equivalence f ↔ PCP.Is-equivalence f
Is-equivalence-CP↔Is-equivalence-CP {f = f} =
CP.Is-equivalence f ↔⟨⟩
(∀ y → Contractible (∃ λ x → f x ≡ y)) ↝⟨ (∀-cong ext λ _ → H-level-cong ext _ $ ∃-cong λ _ → ≡↔≡) ⟩
(∀ y → Contractible (∃ λ x → f x P.≡ y)) ↝⟨ (∀-cong ext λ _ → H-level↔H-level _) ⟩
(∀ y → P.Contractible (∃ λ x → f x P.≡ y)) ↔⟨⟩
PCP.Is-equivalence f □
-- Is-equivalence expressed using equality is isomorphic to
-- Is-equivalence expressed using paths.
Is-equivalence↔Is-equivalence :
Is-equivalence f ↔ PE.Is-equivalence f
Is-equivalence↔Is-equivalence {f = f} =
Is-equivalence f ↝⟨ HA.Is-equivalence↔Is-equivalence-CP ext ⟩
CP.Is-equivalence f ↝⟨ Is-equivalence-CP↔Is-equivalence-CP ⟩
PCP.Is-equivalence f ↝⟨ inverse $ ↔→↔ $ PHA.Is-equivalence↔Is-equivalence-CP P.ext ⟩□
PE.Is-equivalence f □
-- The type of equivalences, expressed using equality, is isomorphic
-- to the type of equivalences, expressed using paths.
≃↔≃ :
{A : Type a} {B : Type b} →
A ≃ B ↔ A PE.≃ B
≃↔≃ {A = A} {B = B} =
A ≃ B ↝⟨ Eq.≃-as-Σ ⟩
∃ Is-equivalence ↝⟨ (∃-cong λ _ → Is-equivalence↔Is-equivalence) ⟩
∃ PE.Is-equivalence ↝⟨ inverse $ ↔→↔ PE.≃-as-Σ ⟩□
A PE.≃ B □
private
-- ≃↔≃ computes in the "right" way.
to-≃↔≃ :
{A : Type a} {B : Type b} {A≃B : A ≃ B} →
PE._≃_.logical-equivalence (_↔_.to ≃↔≃ A≃B) ≡
_≃_.logical-equivalence A≃B
to-≃↔≃ = refl _
from-≃↔≃ :
{A : Type a} {B : Type b} {A≃B : A PE.≃ B} →
_≃_.logical-equivalence (_↔_.from ≃↔≃ A≃B) ≡
PE._≃_.logical-equivalence A≃B
from-≃↔≃ = refl _
-- The type of equivalences, expressed using "contractible preimages"
-- and equality, is isomorphic to the type of equivalences, expressed
-- using contractible preimages and paths.
≃-CP↔≃-CP :
{A : Type a} {B : Type b} →
A CP.≃ B ↔ A PCP.≃ B
≃-CP↔≃-CP {A = A} {B = B} =
∃ CP.Is-equivalence ↝⟨ (∃-cong λ _ → Is-equivalence-CP↔Is-equivalence-CP) ⟩□
∃ PCP.Is-equivalence □
-- The cong function for paths can be expressed in terms of the cong
-- function for equality.
cong≡cong :
{A : Type a} {B : Type b} {f : A → B} {x y : A} {x≡y : x P.≡ y} →
cong f (_↔_.from ≡↔≡ x≡y) ≡ _↔_.from ≡↔≡ (P.cong f x≡y)
cong≡cong {f = f} {x≡y = x≡y} = P.elim
(λ x≡y → cong f (_↔_.from ≡↔≡ x≡y) ≡ _↔_.from ≡↔≡ (P.cong f x≡y))
(λ x →
cong f (_↔_.from ≡↔≡ P.refl) ≡⟨ cong (cong f) from-≡↔≡-refl ⟩
cong f (refl x) ≡⟨ cong-refl _ ⟩
refl (f x) ≡⟨ sym $ from-≡↔≡-refl ⟩
_↔_.from ≡↔≡ P.refl ≡⟨ cong (_↔_.from ≡↔≡) $ sym $ _↔_.from ≡↔≡ $ P.cong-refl f ⟩∎
_↔_.from ≡↔≡ (P.cong f P.refl) ∎)
x≡y
-- The sym function for paths can be expressed in terms of the sym
-- function for equality.
sym≡sym :
{x≡y : x P.≡ y} →
sym (_↔_.from ≡↔≡ x≡y) ≡ _↔_.from ≡↔≡ (P.sym x≡y)
sym≡sym {x≡y = x≡y} = P.elim₁
(λ x≡y → sym (_↔_.from ≡↔≡ x≡y) ≡ _↔_.from ≡↔≡ (P.sym x≡y))
(sym (_↔_.from ≡↔≡ P.refl) ≡⟨ cong sym from-≡↔≡-refl ⟩
sym (refl _) ≡⟨ sym-refl ⟩
refl _ ≡⟨ sym from-≡↔≡-refl ⟩
_↔_.from ≡↔≡ P.refl ≡⟨ cong (_↔_.from ≡↔≡) $ sym $ _↔_.from ≡↔≡ P.sym-refl ⟩∎
_↔_.from ≡↔≡ (P.sym P.refl) ∎)
x≡y
-- The trans function for paths can be expressed in terms of the trans
-- function for equality.
trans≡trans :
{x≡y : x P.≡ y} {y≡z : y P.≡ z} →
trans (_↔_.from ≡↔≡ x≡y) (_↔_.from ≡↔≡ y≡z) ≡
_↔_.from ≡↔≡ (P.trans x≡y y≡z)
trans≡trans {x≡y = x≡y} {y≡z = y≡z} = P.elim₁
(λ x≡y → trans (_↔_.from ≡↔≡ x≡y) (_↔_.from ≡↔≡ y≡z) ≡
_↔_.from ≡↔≡ (P.trans x≡y y≡z))
(trans (_↔_.from ≡↔≡ P.refl) (_↔_.from ≡↔≡ y≡z) ≡⟨ cong (flip trans _) from-≡↔≡-refl ⟩
trans (refl _) (_↔_.from ≡↔≡ y≡z) ≡⟨ trans-reflˡ _ ⟩
_↔_.from ≡↔≡ y≡z ≡⟨ cong (_↔_.from ≡↔≡) $ sym $ _↔_.from ≡↔≡ $ P.trans-reflˡ _ ⟩∎
_↔_.from ≡↔≡ (P.trans P.refl y≡z) ∎)
x≡y
-- The type of embeddings, expressed using equality, is isomorphic to
-- the type of embeddings, expressed using paths.
Embedding↔Embedding :
{A : Type a} {B : Type b} →
Embedding A B ↔ PM.Embedding A B
Embedding↔Embedding {A = A} {B = B} =
Embedding A B ↝⟨ Embedding-as-Σ ⟩
(∃ λ f → ∀ x y → Is-equivalence (cong f)) ↔⟨ (∃-cong λ f → ∀-cong ext λ x → ∀-cong ext λ y →
Eq.⇔→≃ (Eq.propositional ext _) (Eq.propositional ext _)
(λ is → _≃_.is-equivalence $
Eq.with-other-function
(
x P.≡ y ↔⟨ inverse ≡↔≡ ⟩
x ≡ y ↝⟨ Eq.⟨ _ , is ⟩ ⟩
f x ≡ f y ↔⟨ ≡↔≡ ⟩□
f x P.≡ f y □)
(P.cong f)
(λ eq →
_↔_.to ≡↔≡ (cong f (_↔_.from ≡↔≡ eq)) ≡⟨ cong (_↔_.to ≡↔≡) cong≡cong ⟩
_↔_.to ≡↔≡ (_↔_.from ≡↔≡ (P.cong f eq)) ≡⟨ _↔_.right-inverse-of ≡↔≡ _ ⟩∎
P.cong f eq ∎))
(λ is → _≃_.is-equivalence $
Eq.with-other-function
(
x ≡ y ↔⟨ ≡↔≡ ⟩
x P.≡ y ↝⟨ Eq.⟨ _ , is ⟩ ⟩
f x P.≡ f y ↔⟨ inverse ≡↔≡ ⟩□
f x ≡ f y □)
(cong f)
(λ eq →
_↔_.from ≡↔≡ (P.cong f (_↔_.to ≡↔≡ eq)) ≡⟨ sym cong≡cong ⟩
cong f (_↔_.from ≡↔≡ (_↔_.to ≡↔≡ eq)) ≡⟨ cong (cong f) $ _↔_.left-inverse-of ≡↔≡ _ ⟩∎
cong f eq ∎))) ⟩
(∃ λ f → ∀ x y → Is-equivalence (P.cong f)) ↝⟨ (∃-cong λ _ → ∀-cong ext λ _ → ∀-cong ext λ _ → Is-equivalence↔Is-equivalence) ⟩
(∃ λ f → ∀ x y → PE.Is-equivalence (P.cong f)) ↝⟨ inverse $ ↔→↔ PM.Embedding-as-Σ ⟩□
PM.Embedding A B □
-- The subst function for paths can be expressed in terms of the subst
-- function for equality.
subst≡subst :
∀ {P : A → Type p} {x≡y : x P.≡ y} {p} →
subst P (_↔_.from ≡↔≡ x≡y) p ≡ P.subst P x≡y p
subst≡subst {P = P} {x≡y} = P.elim
(λ x≡y → ∀ {p} → subst P (_↔_.from ≡↔≡ x≡y) p ≡ P.subst P x≡y p)
(λ x {p} →
subst P (_↔_.from ≡↔≡ P.refl) p ≡⟨ cong (λ eq → subst P eq p) from-≡↔≡-refl ⟩
subst P (refl x) p ≡⟨ subst-refl _ _ ⟩
p ≡⟨ sym $ _↔_.from ≡↔≡ $ P.subst-refl P _ ⟩∎
P.subst P P.refl p ∎)
x≡y
-- A "computation" rule for subst≡subst.
subst≡subst-refl :
∀ {P : A → Type p} {p : P x} →
subst≡subst {x≡y = P.refl} ≡
trans (cong (λ eq → subst P eq p) from-≡↔≡-refl)
(trans (subst-refl _ _) (sym $ _↔_.from ≡↔≡ $ P.subst-refl P _))
subst≡subst-refl {P = P} = cong (λ f → f {p = _}) $ _↔_.from ≡↔≡ $
P.elim-refl
(λ x≡y → ∀ {p} → subst P (_↔_.from ≡↔≡ x≡y) p ≡ P.subst P x≡y p)
(λ _ → trans (cong (λ eq → subst P eq _) from-≡↔≡-refl)
(trans (subst-refl _ _)
(sym $ _↔_.from ≡↔≡ $ P.subst-refl P _)))
-- Some corollaries.
subst≡↔subst≡ :
∀ {eq : x P.≡ y} →
subst B (_↔_.from ≡↔≡ eq) u ≡ v ↔
P.subst B eq u P.≡ v
subst≡↔subst≡ {B = B} {u = u} {v = v} {eq = eq} =
subst B (_↔_.from ≡↔≡ eq) u ≡ v ↝⟨ ≡⇒↝ _ $ cong (_≡ _) subst≡subst ⟩
P.subst B eq u ≡ v ↝⟨ ≡↔≡ ⟩□
P.subst B eq u P.≡ v □
subst≡↔[]≡ :
{eq : x P.≡ y} →
subst B (_↔_.from ≡↔≡ eq) u ≡ v ↔
P.[ (λ i → B (eq i)) ] u ≡ v
subst≡↔[]≡ {B = B} {u = u} {v = v} {eq = eq} =
subst B (_↔_.from ≡↔≡ eq) u ≡ v ↝⟨ subst≡↔subst≡ ⟩
P.subst B eq u P.≡ v ↝⟨ ↔→↔ $ PB.inverse $ P.heterogeneous↔homogeneous _ ⟩□
P.[ (λ i → B (eq i)) ] u ≡ v □
-- The dcong function for paths can be expressed using dcong for
-- equality (up to pointwise equality).
dcong≡dcong :
{f : (x : A) → B x} {x≡y : x P.≡ y} →
_↔_.to subst≡↔subst≡ (dcong f (_↔_.from ≡↔≡ x≡y)) ≡
P.dcong f x≡y
dcong≡dcong {B = B} {f = f} {x≡y} = P.elim
(λ x≡y → _↔_.to subst≡↔subst≡ (dcong f (_↔_.from ≡↔≡ x≡y)) ≡
P.dcong f x≡y)
(λ x →
_↔_.to subst≡↔subst≡ (dcong f (_↔_.from ≡↔≡ P.refl)) ≡⟨⟩
_↔_.to ≡↔≡ (_↔_.to (≡⇒↝ _ $ cong (_≡ _) subst≡subst) $
dcong f (_↔_.from ≡↔≡ P.refl)) ≡⟨ cong (_↔_.to ≡↔≡) $ lemma x ⟩
_↔_.to ≡↔≡ (_↔_.from ≡↔≡ $ P.subst-refl B (f x)) ≡⟨ _↔_.right-inverse-of ≡↔≡ _ ⟩
P.subst-refl B (f x) ≡⟨ sym $ _↔_.from ≡↔≡ $ P.dcong-refl f ⟩∎
P.dcong f P.refl ∎)
x≡y
where
lemma : ∀ _ → _
lemma _ =
_↔_.to (≡⇒↝ _ $ cong (_≡ _) subst≡subst)
(dcong f (_↔_.from ≡↔≡ P.refl)) ≡⟨ sym $ subst-in-terms-of-≡⇒↝ bijection _ _ _ ⟩
subst (_≡ _) subst≡subst (dcong f (_↔_.from ≡↔≡ P.refl)) ≡⟨ cong (λ p → subst (_≡ _) p $ dcong f _) $ sym $ sym-sym _ ⟩
subst (_≡ _) (sym $ sym subst≡subst)
(dcong f (_↔_.from ≡↔≡ P.refl)) ≡⟨ subst-trans _ ⟩
trans (sym (subst≡subst {x≡y = P.refl}))
(dcong f (_↔_.from ≡↔≡ P.refl)) ≡⟨ cong (λ p → trans (sym p) (dcong f (_↔_.from ≡↔≡ P.refl)))
subst≡subst-refl ⟩
trans
(sym $ trans (cong (λ eq → subst B eq _) from-≡↔≡-refl)
(trans (subst-refl _ _)
(sym $ _↔_.from ≡↔≡ $ P.subst-refl B _)))
(dcong f (_↔_.from ≡↔≡ P.refl)) ≡⟨ elim₁ (λ {x} p →
trans (sym $ trans (cong (λ eq → subst B eq _) p)
(trans (subst-refl _ _)
(sym $ _↔_.from ≡↔≡ $ P.subst-refl B _)))
(dcong f x) ≡
trans (sym $ trans (cong (λ eq → subst B eq _) (refl _))
(trans (subst-refl _ _)
(sym $ _↔_.from ≡↔≡ $ P.subst-refl B _)))
(dcong f (refl _)))
(refl _)
from-≡↔≡-refl ⟩
trans
(sym $ trans (cong (λ eq → subst B eq _) (refl _))
(trans (subst-refl _ _)
(sym $ _↔_.from ≡↔≡ $ P.subst-refl B _)))
(dcong f (refl _)) ≡⟨ cong₂ (λ p → trans $ sym $ trans p $ trans (subst-refl _ _) $ sym $
_↔_.from ≡↔≡ $ P.subst-refl B _)
(cong-refl _)
(dcong-refl _) ⟩
trans
(sym $ trans (refl _)
(trans (subst-refl _ _)
(sym $ _↔_.from ≡↔≡ $ P.subst-refl B _)))
(subst-refl B _) ≡⟨ cong (λ p → trans (sym p) (subst-refl _ _)) $ trans-reflˡ _ ⟩
trans
(sym $ trans (subst-refl _ _)
(sym $ _↔_.from ≡↔≡ $ P.subst-refl B _))
(subst-refl B _) ≡⟨ cong (λ p → trans p (subst-refl _ _)) $ sym-trans _ _ ⟩
trans
(trans (sym $ sym $ _↔_.from ≡↔≡ $ P.subst-refl B _)
(sym $ subst-refl _ _))
(subst-refl B _) ≡⟨ trans-[trans-sym]- _ _ ⟩
sym $ sym $ _↔_.from ≡↔≡ $ P.subst-refl B _ ≡⟨ sym-sym _ ⟩∎
_↔_.from ≡↔≡ $ P.subst-refl B _ ∎
-- A lemma relating dcong and hcong (for paths).
dcong≡hcong :
{x≡y : x P.≡ y} (f : (x : A) → B x) →
dcong f (_↔_.from ≡↔≡ x≡y) ≡ _↔_.from subst≡↔[]≡ (P.hcong f x≡y)
dcong≡hcong {x≡y = x≡y} f =
dcong f (_↔_.from ≡↔≡ x≡y) ≡⟨ sym $ _↔_.from-to (inverse subst≡↔subst≡) dcong≡dcong ⟩
_↔_.from subst≡↔subst≡ (P.dcong f x≡y) ≡⟨ cong (_↔_.from subst≡↔subst≡) $ _↔_.from ≡↔≡ $ P.dcong≡hcong f ⟩
_↔_.from subst≡↔subst≡
(PB._↔_.to (P.heterogeneous↔homogeneous _) (P.hcong f x≡y)) ≡⟨⟩
_↔_.from subst≡↔[]≡ (P.hcong f x≡y) ∎
-- Three corollaries, intended to be used in the implementation of
-- eliminators for HITs. For some examples, see Interval and
-- Quotient.HIT.
subst≡→[]≡ :
{eq : x P.≡ y} →
subst B (_↔_.from ≡↔≡ eq) u ≡ v →
P.[ (λ i → B (eq i)) ] u ≡ v
subst≡→[]≡ = _↔_.to subst≡↔[]≡
dcong-subst≡→[]≡ :
{eq₁ : x P.≡ y} {eq₂ : subst B (_↔_.from ≡↔≡ eq₁) (f x) ≡ f y} →
P.hcong f eq₁ ≡ subst≡→[]≡ eq₂ →
dcong f (_↔_.from ≡↔≡ eq₁) ≡ eq₂
dcong-subst≡→[]≡ {B = B} {f = f} {eq₁} {eq₂} hyp =
dcong f (_↔_.from ≡↔≡ eq₁) ≡⟨ dcong≡hcong f ⟩
_↔_.from subst≡↔[]≡ (P.hcong f eq₁) ≡⟨ cong (_↔_.from subst≡↔[]≡) hyp ⟩
_↔_.from subst≡↔[]≡ (_↔_.to subst≡↔[]≡ eq₂) ≡⟨ _↔_.left-inverse-of subst≡↔[]≡ _ ⟩∎
eq₂ ∎
cong-≡↔≡ :
{eq₁ : x P.≡ y} {eq₂ : f x ≡ f y} →
P.cong f eq₁ ≡ _↔_.to ≡↔≡ eq₂ →
cong f (_↔_.from ≡↔≡ eq₁) ≡ eq₂
cong-≡↔≡ {f = f} {eq₁ = eq₁} {eq₂} hyp =
cong f (_↔_.from ≡↔≡ eq₁) ≡⟨ cong≡cong ⟩
_↔_.from ≡↔≡ $ P.cong f eq₁ ≡⟨ cong (_↔_.from ≡↔≡) hyp ⟩
_↔_.from ≡↔≡ $ _↔_.to ≡↔≡ eq₂ ≡⟨ _↔_.left-inverse-of ≡↔≡ _ ⟩∎
eq₂ ∎
------------------------------------------------------------------------
-- Univalence
-- CP.Univalence′ is pointwise equivalent to PCP.Univalence′.
Univalence′-CP≃Univalence′-CP :
{A B : Type ℓ} →
CP.Univalence′ A B ≃ PCP.Univalence′ A B
Univalence′-CP≃Univalence′-CP {A = A} {B = B} =
((A≃B : A CP.≃ B) →
∃ λ (x : ∃ λ A≡B → CP.≡⇒≃ A≡B ≡ A≃B) → ∀ y → x ≡ y) ↔⟨⟩
((A≃B : ∃ λ (f : A → B) → CP.Is-equivalence f) →
∃ λ (x : ∃ λ A≡B → CP.≡⇒≃ A≡B ≡ A≃B) →
∀ y → x ≡ y) ↝⟨ (Π-cong ext (∃-cong λ _ → Is-equivalence-CP↔Is-equivalence-CP) λ A≃B →
Σ-cong (lemma₁ A≃B) λ _ →
Π-cong ext (lemma₁ A≃B) λ _ →
inverse $ Eq.≃-≡ (lemma₁ A≃B)) ⟩
((A≃B : ∃ λ (f : A → B) → PCP.Is-equivalence f) →
∃ λ (x : ∃ λ A≡B → PCP.≡⇒≃ A≡B ≡ A≃B) →
∀ y → x ≡ y) ↔⟨⟩
((A≃B : A PCP.≃ B) →
∃ λ (x : ∃ λ A≡B → PCP.≡⇒≃ A≡B ≡ A≃B) → ∀ y → x ≡ y) ↔⟨ Is-equivalence-CP↔Is-equivalence-CP ⟩□
((A≃B : A PCP.≃ B) →
∃ λ (x : ∃ λ A≡B → PCP.≡⇒≃ A≡B P.≡ A≃B) → ∀ y → x P.≡ y) □
where
lemma₃ :
(A≡B : A ≡ B) →
_↔_.to ≃-CP↔≃-CP (CP.≡⇒≃ A≡B) ≡ PCP.≡⇒≃ (_↔_.to ≡↔≡ A≡B)
lemma₃ = elim¹
(λ A≡B → _↔_.to ≃-CP↔≃-CP (CP.≡⇒≃ A≡B) ≡ PCP.≡⇒≃ (_↔_.to ≡↔≡ A≡B))
(_↔_.to ≃-CP↔≃-CP (CP.≡⇒≃ (refl _)) ≡⟨ cong (_↔_.to ≃-CP↔≃-CP) CP.≡⇒≃-refl ⟩
_↔_.to ≃-CP↔≃-CP CP.id ≡⟨ _↔_.from ≡↔≡ $ P.Σ-≡,≡→≡ P.refl (PCP.propositional P.ext _ _ _) ⟩
PCP.id ≡⟨ sym $ _↔_.from ≡↔≡ PCP.≡⇒≃-refl ⟩
PCP.≡⇒≃ P.refl ≡⟨ sym $ cong PCP.≡⇒≃ to-≡↔≡-refl ⟩∎
PCP.≡⇒≃ (_↔_.to ≡↔≡ (refl _)) ∎)
lemma₂ : ∀ _ _ → _ ≃ _
lemma₂ A≡B (f , f-eq) =
CP.≡⇒≃ A≡B ≡ (f , f-eq) ↝⟨ inverse $ Eq.≃-≡ (Eq.↔⇒≃ ≃-CP↔≃-CP) ⟩
_↔_.to ≃-CP↔≃-CP (CP.≡⇒≃ A≡B) ≡
(f , _↔_.to Is-equivalence-CP↔Is-equivalence-CP f-eq) ↝⟨ ≡⇒≃ $ cong (_≡ (f , _↔_.to Is-equivalence-CP↔Is-equivalence-CP f-eq)) $
lemma₃ A≡B ⟩□
PCP.≡⇒≃ (_↔_.to ≡↔≡ A≡B) ≡
(f , _↔_.to Is-equivalence-CP↔Is-equivalence-CP f-eq) □
lemma₁ :
∀ A≃B →
(∃ λ A≡B → CP.≡⇒≃ A≡B ≡ A≃B) ≃
(∃ λ A≡B →
PCP.≡⇒≃ A≡B ≡
( proj₁ A≃B
, _↔_.to Is-equivalence-CP↔Is-equivalence-CP (proj₂ A≃B)
))
lemma₁ A≃B = Σ-cong ≡↔≡ λ A≡B → lemma₂ A≡B A≃B
-- Univalence′ expressed using equality is equivalent to Univalence′
-- expressed using paths.
Univalence′≃Univalence′ :
{A B : Type ℓ} →
Univalence′ A B ≃ PU.Univalence′ A B
Univalence′≃Univalence′ {A = A} {B = B} =
Univalence′ A B ↝⟨ Univalence′≃Univalence′-CP ext ⟩
CP.Univalence′ A B ↝⟨ Univalence′-CP≃Univalence′-CP ⟩
PCP.Univalence′ A B ↝⟨ inverse $ _↔_.from ≃↔≃ $ PU.Univalence′≃Univalence′-CP P.ext ⟩□
PU.Univalence′ A B □
-- Univalence expressed using equality is equivalent to univalence
-- expressed using paths.
Univalence≃Univalence : Univalence ℓ ≃ PU.Univalence ℓ
Univalence≃Univalence {ℓ = ℓ} =
({A B : Type ℓ} → Univalence′ A B) ↝⟨ implicit-∀-cong ext $ implicit-∀-cong ext Univalence′≃Univalence′ ⟩□
({A B : Type ℓ} → PU.Univalence′ A B) □
| 40.54717
| 134
| 0.436017
|
59d78ae566f6729bf42bc757d228d7bbe5971418
| 356
|
agda
|
Agda
|
test/Succeed/Issue1115.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue1115.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue1115.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
{-# OPTIONS --without-K #-}
open import Agda.Builtin.Nat
open import Agda.Builtin.Equality
data Fin : Nat → Set where
zero : {n : Nat} → Fin (suc n)
suc : {n : Nat} (i : Fin n) → Fin (suc n)
-- From Data.Fin.Properties in the standard library (2016-12-30).
suc-injective : ∀ {o} {m n : Fin o} → Fin.suc m ≡ suc n → m ≡ n
suc-injective refl = refl
| 25.428571
| 65
| 0.620787
|
066aeba8e3817ad1165f521418254bb3ccbfc2c9
| 9,937
|
agda
|
Agda
|
src/Delay-monad/Bisimilarity/Observation.agda
|
nad/delay-monad
|
495f9996673d0f1f34ce202902daaa6c39f8925e
|
[
"MIT"
] | null | null | null |
src/Delay-monad/Bisimilarity/Observation.agda
|
nad/delay-monad
|
495f9996673d0f1f34ce202902daaa6c39f8925e
|
[
"MIT"
] | null | null | null |
src/Delay-monad/Bisimilarity/Observation.agda
|
nad/delay-monad
|
495f9996673d0f1f34ce202902daaa6c39f8925e
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- An observation about weak bisimilarity
------------------------------------------------------------------------
{-# OPTIONS --sized-types #-}
module Delay-monad.Bisimilarity.Observation where
open import Equality.Propositional
open import Logical-equivalence using (_⇔_)
open import Prelude
open import Prelude.Size
open import Function-universe equality-with-J as F hiding (_∘_)
open import H-level.Closure equality-with-J
------------------------------------------------------------------------
-- The D type
mutual
-- A mixed inductive-coinductive type.
data D (i : Size) : Type where
-- Output a boolean and continue. Note that this constructor is
-- inductive.
put : Bool → D i → D i
-- Wait. The intention is that finite delay should not be
-- "observable" (as captured by weak bisimilarity).
later : D′ i → D i
record D′ (i : Size) : Type where
coinductive
field
force : {j : Size< i} → D j
open D′ public
private
variable
b b′ : Bool
n : ℕ
i : Size
x y z : D ∞
x′ y′ : D′ ∞
-- Making put inductive is a bit strange, because one can construct a
-- coinductive variant of it by using later.
put′ : Bool → D′ i → D i
put′ b x = later λ { .force → put b (x .force) }
------------------------------------------------------------------------
-- Weak bisimilarity
-- The output relation: x [ n ]≡ b means that x can output at least n
-- times, and the n-th output is b.
data _[_]≡_ : D ∞ → ℕ → Bool → Type where
put-zero : put b x [ zero ]≡ b
put-suc : x [ n ]≡ b → put b′ x [ suc n ]≡ b
later : x′ .force [ n ]≡ b → later x′ [ n ]≡ b
-- The output relation is propositional.
[]≡-propositional : Is-proposition (x [ n ]≡ b)
[]≡-propositional {b = true} put-zero put-zero = refl
[]≡-propositional {b = false} put-zero put-zero = refl
[]≡-propositional (put-suc p) (put-suc q) =
cong put-suc ([]≡-propositional p q)
[]≡-propositional (later p) (later q) =
cong later ([]≡-propositional p q)
-- Weak bisimilarity. Two computations are weakly bisimilar if the
-- output relation cannot distinguish between them.
_≈_ : D ∞ → D ∞ → Type
x ≈ y = ∀ {n b} → x [ n ]≡ b ⇔ y [ n ]≡ b
-- Weak bisimilarity is propositional (assuming extensionality).
≈-propositional :
Extensionality lzero lzero →
Is-proposition (x ≈ y)
≈-propositional ext =
implicit-Π-closure ext 1 λ _ →
implicit-Π-closure ext 1 λ _ →
⇔-closure ext 1 []≡-propositional []≡-propositional
-- The put constructor and the function put′ are closely related.
put≈put′ : put b (x′ .force) ≈ put′ b x′
put≈put′ ._⇔_.to q = later q
put≈put′ ._⇔_.from (later q) = q
-- Weak bisimilarity is an equivalence relation.
reflexive-≈ : x ≈ x
reflexive-≈ = F.id
symmetric-≈ : x ≈ y → y ≈ x
symmetric-≈ x≈y = F.inverse x≈y
transitive-≈ : x ≈ y → y ≈ z → x ≈ z
transitive-≈ x≈y y≈z = y≈z F.∘ x≈y
-- The later constructor can be removed to the left and to the right.
laterˡ⁻¹ : later x′ ≈ y → x′ .force ≈ y
laterˡ⁻¹ p ._⇔_.to q = _⇔_.to p (later q)
laterˡ⁻¹ p ._⇔_.from q with _⇔_.from p q
… | later q′ = q′
laterʳ⁻¹ : x ≈ later y′ → x ≈ y′ .force
laterʳ⁻¹ = symmetric-≈ ∘ laterˡ⁻¹ ∘ symmetric-≈
later⁻¹ : later x′ ≈ later y′ → x′ .force ≈ y′ .force
later⁻¹ = laterˡ⁻¹ ∘ laterʳ⁻¹
-- The put constructor can be removed if it is removed on both sides
-- at the same time.
put⁻¹ : put b x ≈ put b′ y → x ≈ y
put⁻¹ p ._⇔_.to q with _⇔_.to p (put-suc q)
… | put-suc q′ = q′
put⁻¹ p ._⇔_.from q with _⇔_.from p (put-suc q)
… | put-suc q′ = q′
------------------------------------------------------------------------
-- Not weak bisimilarity
module Not-weak-bisimilarity where
mutual
infix 4 [_]_≈_ [_]_≈′_
-- After having seen the definition of weak bisimilarity in
-- Delay-monad.Bisimilarity one might believe that weak
-- bisimilarity for D can be defined in the following way:
data [_]_≈_ (i : Size) : D ∞ → D ∞ → Type where
put : [ i ] x ≈ y → [ i ] put b x ≈ put b y
later : [ i ] x′ .force ≈′ y′ .force → [ i ] later x′ ≈ later y′
laterˡ : [ i ] x′ .force ≈ y → [ i ] later x′ ≈ y
laterʳ : [ i ] x ≈ y′ .force → [ i ] x ≈ later y′
record [_]_≈′_ (i : Size) (x y : D ∞) : Type where
coinductive
field
force : {j : Size< i} → [ j ] x ≈ y
open [_]_≈′_ public
-- The relation [ i ]_≈_ is reflexive and symmetric.
reflexive-[]≈ : [ i ] x ≈ x
reflexive-[]≈ {x = put _ _} = put reflexive-[]≈
reflexive-[]≈ {x = later _} = later λ { .force → reflexive-[]≈ }
symmetric-[]≈ : [ i ] x ≈ y → [ i ] y ≈ x
symmetric-[]≈ (put p) = put (symmetric-[]≈ p)
symmetric-[]≈ (later p) = later λ { .force →
symmetric-[]≈ (p .force) }
symmetric-[]≈ (laterˡ p) = laterʳ (symmetric-[]≈ p)
symmetric-[]≈ (laterʳ p) = laterˡ (symmetric-[]≈ p)
-- However, the relation [ ∞ ]_≈_ is not transitive.
¬-transitive-≈ :
¬ (∀ {x y z} → [ ∞ ] x ≈ y → [ ∞ ] y ≈ z → [ ∞ ] x ≈ z)
¬-transitive-≈ trans = x≉z x≈z
where
x̲ : D i
x̲ = later λ { .force → put true (put true x̲) }
y̲ : D i
y̲ = later λ { .force → put true y̲ }
z̲ : D i
z̲ = put true (later λ { .force → put true z̲ })
x≈y : [ i ] x̲ ≈ y̲
x≈y = later λ { .force → put (laterʳ (put x≈y)) }
y≈z : [ i ] y̲ ≈ z̲
y≈z = laterˡ (put (later λ { .force → put y≈z }))
x≉z : ¬ [ ∞ ] x̲ ≈ z̲
x≉z (laterˡ (put (laterʳ (put p)))) = x≉z p
x≈z : [ ∞ ] x̲ ≈ z̲
x≈z = trans x≈y y≈z
-- Thus the two relations _≈_ and [ ∞ ]_≈_ are not pointwise
-- logically equivalent.
¬≈⇔[]≈ : ¬ (∀ {x y} → x ≈ y ⇔ [ ∞ ] x ≈ y)
¬≈⇔[]≈ =
(∀ {x y} → x ≈ y ⇔ [ ∞ ] x ≈ y) ↝⟨ (λ hyp x≈y y≈z → _⇔_.to hyp (transitive-≈ (_⇔_.from hyp x≈y) (_⇔_.from hyp y≈z))) ⟩
(∀ {x y z} → [ ∞ ] x ≈ y → [ ∞ ] y ≈ z → [ ∞ ] x ≈ z) ↝⟨ ¬-transitive-≈ ⟩□
⊥ □
-- The relation [ ∞ ]_≈_ is contained in _≈_.
[]≈→≈ : [ ∞ ] x ≈ y → x ≈ y
[]≈→≈ = λ p → record { to = ≈→→ p; from = ≈→→ (symmetric-[]≈ p) }
where
≈→→ : [ ∞ ] x ≈ y → x [ n ]≡ b → y [ n ]≡ b
≈→→ (put p) put-zero = put-zero
≈→→ (put p) (put-suc q) = put-suc (≈→→ p q)
≈→→ (later p) (later q) = later (≈→→ (p .force) q)
≈→→ (laterˡ p) (later q) = ≈→→ p q
≈→→ (laterʳ p) q = later (≈→→ p q)
-- The relation _≈_ is not contained in [ ∞ ]_≈_.
¬≈→[]≈ : ¬ (∀ {x y} → x ≈ y → [ ∞ ] x ≈ y)
¬≈→[]≈ =
(∀ {x y} → x ≈ y → [ ∞ ] x ≈ y) ↝⟨ (λ hyp → record { to = hyp; from = []≈→≈ }) ⟩
(∀ {x y} → x ≈ y ⇔ [ ∞ ] x ≈ y) ↝⟨ ¬≈⇔[]≈ ⟩□
⊥ □
------------------------------------------------------------------------
-- An alternative definition of weak bisimilarity
mutual
infix 4 [_]_≈_ [_]_≈′_
-- The problem with Not-weak-bisimilarity.[_]_≈_ is that its put
-- constructor is inductive. The put constructor of D is inductive,
-- but as noted above (put′, put≈put′) this is a bit strange, and it
-- might make more sense to make put coinductive.
--
-- The following definition of weak bisimilarity uses a coinductive
-- put constructor.
data [_]_≈_ (i : Size) : D ∞ → D ∞ → Type where
put : [ i ] x ≈′ y → [ i ] put b x ≈ put b y
later : [ i ] x′ .force ≈′ y′ .force → [ i ] later x′ ≈ later y′
laterˡ : [ i ] x′ .force ≈ y → [ i ] later x′ ≈ y
laterʳ : [ i ] x ≈ y′ .force → [ i ] x ≈ later y′
record [_]_≈′_ (i : Size) (x y : D ∞) : Type where
coinductive
field
force : {j : Size< i} → [ j ] x ≈ y
open [_]_≈′_ public
-- The relation [ ∞ ]_≈_ is not propositional.
¬-≈[]-propositional : ¬ (∀ {x y} → Is-proposition ([ ∞ ] x ≈ y))
¬-≈[]-propositional =
(∀ {x y} → Is-proposition ([ ∞ ] x ≈ y)) ↝⟨ (λ prop → prop _ _) ⟩
proof₁ ≡ proof₂ ↝⟨ (λ ()) ⟩□
⊥ □
where
never : D i
never = later λ { .force → never }
proof₁ : ∀ {i} → [ i ] never ≈ never
proof₁ = later λ { .force → proof₁ }
proof₂ : ∀ {i} → [ i ] never ≈ never
proof₂ = laterˡ proof₁
-- The relation [ i ]_≈_ is reflexive and symmetric.
reflexive-[]≈ : [ i ] x ≈ x
reflexive-[]≈ {x = put _ _} = put λ { .force → reflexive-[]≈ }
reflexive-[]≈ {x = later _} = later λ { .force → reflexive-[]≈ }
symmetric-[]≈ : [ i ] x ≈ y → [ i ] y ≈ x
symmetric-[]≈ (put p) = put λ { .force → symmetric-[]≈ (p .force) }
symmetric-[]≈ (later p) = later λ { .force → symmetric-[]≈ (p .force) }
symmetric-[]≈ (laterˡ p) = laterʳ (symmetric-[]≈ p)
symmetric-[]≈ (laterʳ p) = laterˡ (symmetric-[]≈ p)
-- The two relations _≈_ and [ ∞ ]_≈_ are pointwise logically
-- equivalent.
≈⇔[]≈ : x ≈ y ⇔ [ ∞ ] x ≈ y
≈⇔[]≈ = record
{ to = to _ _
; from = λ p → record { to = from p; from = from (symmetric-[]≈ p) }
}
where
from : [ ∞ ] x ≈ y → x [ n ]≡ b → y [ n ]≡ b
from (put p) put-zero = put-zero
from (put p) (put-suc q) = put-suc (from (p .force) q)
from (later p) (later q) = later (from (p .force) q)
from (laterˡ p) (later q) = from p q
from (laterʳ p) q = later (from p q)
mutual
to : ∀ x y → x ≈ y → [ i ] x ≈ y
to (put b x) y p = symmetric-[]≈ (to′ (symmetric-≈ p)
(_⇔_.to p put-zero))
to x (put b y) p = to′ p (_⇔_.from p put-zero)
to (later x) (later y) p = later λ { .force → to _ _ (later⁻¹ p) }
to′ : x ≈ put b y → x [ zero ]≡ b → [ i ] x ≈ put b y
to′ p put-zero = put λ { .force → to _ _ (put⁻¹ p) }
to′ p (later q) = laterˡ (to′ (laterˡ⁻¹ p) q)
-- The relation [ ∞ ]_≈_ is transitive.
transitive-[]≈ : [ ∞ ] x ≈ y → [ ∞ ] y ≈ z → [ ∞ ] x ≈ z
transitive-[]≈ p q =
_⇔_.to ≈⇔[]≈ (transitive-≈ (_⇔_.from ≈⇔[]≈ p) (_⇔_.from ≈⇔[]≈ q))
| 31.546032
| 145
| 0.491597
|
2f60c8d7bf72d8198da23f31ef4345d378570c29
| 83
|
agda
|
Agda
|
Ferros/Resource/CNode.agda
|
auxoncorp/ferros-spec
|
8759d36ac9ec24c53f226a60fa3811eb1d4e5d93
|
[
"Apache-2.0"
] | 3
|
2021-09-11T01:06:56.000Z
|
2022-01-27T23:18:55.000Z
|
Ferros/Resource/CNode.agda
|
auxoncorp/ferros-spec
|
8759d36ac9ec24c53f226a60fa3811eb1d4e5d93
|
[
"Apache-2.0"
] | null | null | null |
Ferros/Resource/CNode.agda
|
auxoncorp/ferros-spec
|
8759d36ac9ec24c53f226a60fa3811eb1d4e5d93
|
[
"Apache-2.0"
] | null | null | null |
module Ferros.Resource.CNode where
open import Ferros.Resource.CNode.Base public
| 20.75
| 46
| 0.831325
|
0ee3ca34c200c76c1853cf00370049847677d4db
| 38,948
|
agda
|
Agda
|
agda/Text/Greek/SBLGNT/2Thess.agda
|
scott-fleischman/GreekGrammar
|
915c46c27c7f8aad5907474d8484f2685a4cd6a7
|
[
"MIT"
] | 44
|
2015-05-29T14:48:51.000Z
|
2022-03-06T15:41:57.000Z
|
agda/Text/Greek/SBLGNT/2Thess.agda
|
scott-fleischman/GreekGrammar
|
915c46c27c7f8aad5907474d8484f2685a4cd6a7
|
[
"MIT"
] | 13
|
2015-05-28T20:04:08.000Z
|
2020-09-07T11:58:38.000Z
|
agda/Text/Greek/SBLGNT/2Thess.agda
|
scott-fleischman/GreekGrammar
|
915c46c27c7f8aad5907474d8484f2685a4cd6a7
|
[
"MIT"
] | 5
|
2015-02-27T22:34:13.000Z
|
2017-06-11T11:25:09.000Z
|
module Text.Greek.SBLGNT.2Thess where
open import Data.List
open import Text.Greek.Bible
open import Text.Greek.Script
open import Text.Greek.Script.Unicode
ΠΡΟΣ-ΘΕΣΣΑΛΟΝΙΚΕΙΣ-Β : List (Word)
ΠΡΟΣ-ΘΕΣΣΑΛΟΝΙΚΕΙΣ-Β =
word (Π ∷ α ∷ ῦ ∷ ∙λ ∷ ο ∷ ς ∷ []) "2Thess.1.1"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.1"
∷ word (Σ ∷ ι ∷ ∙λ ∷ ο ∷ υ ∷ α ∷ ν ∷ ὸ ∷ ς ∷ []) "2Thess.1.1"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.1"
∷ word (Τ ∷ ι ∷ μ ∷ ό ∷ θ ∷ ε ∷ ο ∷ ς ∷ []) "2Thess.1.1"
∷ word (τ ∷ ῇ ∷ []) "2Thess.1.1"
∷ word (ἐ ∷ κ ∷ κ ∷ ∙λ ∷ η ∷ σ ∷ ί ∷ ᾳ ∷ []) "2Thess.1.1"
∷ word (Θ ∷ ε ∷ σ ∷ σ ∷ α ∷ ∙λ ∷ ο ∷ ν ∷ ι ∷ κ ∷ έ ∷ ω ∷ ν ∷ []) "2Thess.1.1"
∷ word (ἐ ∷ ν ∷ []) "2Thess.1.1"
∷ word (θ ∷ ε ∷ ῷ ∷ []) "2Thess.1.1"
∷ word (π ∷ α ∷ τ ∷ ρ ∷ ὶ ∷ []) "2Thess.1.1"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.1"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.1"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ῳ ∷ []) "2Thess.1.1"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "2Thess.1.1"
∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ῷ ∷ []) "2Thess.1.1"
∷ word (χ ∷ ά ∷ ρ ∷ ι ∷ ς ∷ []) "2Thess.1.2"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "2Thess.1.2"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.2"
∷ word (ε ∷ ἰ ∷ ρ ∷ ή ∷ ν ∷ η ∷ []) "2Thess.1.2"
∷ word (ἀ ∷ π ∷ ὸ ∷ []) "2Thess.1.2"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "2Thess.1.2"
∷ word (π ∷ α ∷ τ ∷ ρ ∷ ὸ ∷ ς ∷ []) "2Thess.1.2"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.2"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.1.2"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "2Thess.1.2"
∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.2"
∷ word (Ε ∷ ὐ ∷ χ ∷ α ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ε ∷ ῖ ∷ ν ∷ []) "2Thess.1.3"
∷ word (ὀ ∷ φ ∷ ε ∷ ί ∷ ∙λ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.1.3"
∷ word (τ ∷ ῷ ∷ []) "2Thess.1.3"
∷ word (θ ∷ ε ∷ ῷ ∷ []) "2Thess.1.3"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ ο ∷ τ ∷ ε ∷ []) "2Thess.1.3"
∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "2Thess.1.3"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.3"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "2Thess.1.3"
∷ word (κ ∷ α ∷ θ ∷ ὼ ∷ ς ∷ []) "2Thess.1.3"
∷ word (ἄ ∷ ξ ∷ ι ∷ ό ∷ ν ∷ []) "2Thess.1.3"
∷ word (ἐ ∷ σ ∷ τ ∷ ι ∷ ν ∷ []) "2Thess.1.3"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "2Thess.1.3"
∷ word (ὑ ∷ π ∷ ε ∷ ρ ∷ α ∷ υ ∷ ξ ∷ ά ∷ ν ∷ ε ∷ ι ∷ []) "2Thess.1.3"
∷ word (ἡ ∷ []) "2Thess.1.3"
∷ word (π ∷ ί ∷ σ ∷ τ ∷ ι ∷ ς ∷ []) "2Thess.1.3"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.3"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.3"
∷ word (π ∷ ∙λ ∷ ε ∷ ο ∷ ν ∷ ά ∷ ζ ∷ ε ∷ ι ∷ []) "2Thess.1.3"
∷ word (ἡ ∷ []) "2Thess.1.3"
∷ word (ἀ ∷ γ ∷ ά ∷ π ∷ η ∷ []) "2Thess.1.3"
∷ word (ἑ ∷ ν ∷ ὸ ∷ ς ∷ []) "2Thess.1.3"
∷ word (ἑ ∷ κ ∷ ά ∷ σ ∷ τ ∷ ο ∷ υ ∷ []) "2Thess.1.3"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ ω ∷ ν ∷ []) "2Thess.1.3"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.3"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.1.3"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ή ∷ ∙λ ∷ ο ∷ υ ∷ ς ∷ []) "2Thess.1.3"
∷ word (ὥ ∷ σ ∷ τ ∷ ε ∷ []) "2Thess.1.4"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ὺ ∷ ς ∷ []) "2Thess.1.4"
∷ word (ἡ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.1.4"
∷ word (ἐ ∷ ν ∷ []) "2Thess.1.4"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "2Thess.1.4"
∷ word (ἐ ∷ γ ∷ κ ∷ α ∷ υ ∷ χ ∷ ᾶ ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "2Thess.1.4"
∷ word (ἐ ∷ ν ∷ []) "2Thess.1.4"
∷ word (τ ∷ α ∷ ῖ ∷ ς ∷ []) "2Thess.1.4"
∷ word (ἐ ∷ κ ∷ κ ∷ ∙λ ∷ η ∷ σ ∷ ί ∷ α ∷ ι ∷ ς ∷ []) "2Thess.1.4"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.4"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "2Thess.1.4"
∷ word (ὑ ∷ π ∷ ὲ ∷ ρ ∷ []) "2Thess.1.4"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.1.4"
∷ word (ὑ ∷ π ∷ ο ∷ μ ∷ ο ∷ ν ∷ ῆ ∷ ς ∷ []) "2Thess.1.4"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.4"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.4"
∷ word (π ∷ ί ∷ σ ∷ τ ∷ ε ∷ ω ∷ ς ∷ []) "2Thess.1.4"
∷ word (ἐ ∷ ν ∷ []) "2Thess.1.4"
∷ word (π ∷ ᾶ ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.1.4"
∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "2Thess.1.4"
∷ word (δ ∷ ι ∷ ω ∷ γ ∷ μ ∷ ο ∷ ῖ ∷ ς ∷ []) "2Thess.1.4"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.4"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.4"
∷ word (τ ∷ α ∷ ῖ ∷ ς ∷ []) "2Thess.1.4"
∷ word (θ ∷ ∙λ ∷ ί ∷ ψ ∷ ε ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.1.4"
∷ word (α ∷ ἷ ∷ ς ∷ []) "2Thess.1.4"
∷ word (ἀ ∷ ν ∷ έ ∷ χ ∷ ε ∷ σ ∷ θ ∷ ε ∷ []) "2Thess.1.4"
∷ word (ἔ ∷ ν ∷ δ ∷ ε ∷ ι ∷ γ ∷ μ ∷ α ∷ []) "2Thess.1.5"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.1.5"
∷ word (δ ∷ ι ∷ κ ∷ α ∷ ί ∷ α ∷ ς ∷ []) "2Thess.1.5"
∷ word (κ ∷ ρ ∷ ί ∷ σ ∷ ε ∷ ω ∷ ς ∷ []) "2Thess.1.5"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.5"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "2Thess.1.5"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.1.5"
∷ word (τ ∷ ὸ ∷ []) "2Thess.1.5"
∷ word (κ ∷ α ∷ τ ∷ α ∷ ξ ∷ ι ∷ ω ∷ θ ∷ ῆ ∷ ν ∷ α ∷ ι ∷ []) "2Thess.1.5"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.1.5"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.1.5"
∷ word (β ∷ α ∷ σ ∷ ι ∷ ∙λ ∷ ε ∷ ί ∷ α ∷ ς ∷ []) "2Thess.1.5"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.5"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "2Thess.1.5"
∷ word (ὑ ∷ π ∷ ὲ ∷ ρ ∷ []) "2Thess.1.5"
∷ word (ἧ ∷ ς ∷ []) "2Thess.1.5"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.5"
∷ word (π ∷ ά ∷ σ ∷ χ ∷ ε ∷ τ ∷ ε ∷ []) "2Thess.1.5"
∷ word (ε ∷ ἴ ∷ π ∷ ε ∷ ρ ∷ []) "2Thess.1.6"
∷ word (δ ∷ ί ∷ κ ∷ α ∷ ι ∷ ο ∷ ν ∷ []) "2Thess.1.6"
∷ word (π ∷ α ∷ ρ ∷ ὰ ∷ []) "2Thess.1.6"
∷ word (θ ∷ ε ∷ ῷ ∷ []) "2Thess.1.6"
∷ word (ἀ ∷ ν ∷ τ ∷ α ∷ π ∷ ο ∷ δ ∷ ο ∷ ῦ ∷ ν ∷ α ∷ ι ∷ []) "2Thess.1.6"
∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "2Thess.1.6"
∷ word (θ ∷ ∙λ ∷ ί ∷ β ∷ ο ∷ υ ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.1.6"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.1.6"
∷ word (θ ∷ ∙λ ∷ ῖ ∷ ψ ∷ ι ∷ ν ∷ []) "2Thess.1.6"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.7"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "2Thess.1.7"
∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "2Thess.1.7"
∷ word (θ ∷ ∙λ ∷ ι ∷ β ∷ ο ∷ μ ∷ έ ∷ ν ∷ ο ∷ ι ∷ ς ∷ []) "2Thess.1.7"
∷ word (ἄ ∷ ν ∷ ε ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.1.7"
∷ word (μ ∷ ε ∷ θ ∷ []) "2Thess.1.7"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.7"
∷ word (ἐ ∷ ν ∷ []) "2Thess.1.7"
∷ word (τ ∷ ῇ ∷ []) "2Thess.1.7"
∷ word (ἀ ∷ π ∷ ο ∷ κ ∷ α ∷ ∙λ ∷ ύ ∷ ψ ∷ ε ∷ ι ∷ []) "2Thess.1.7"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.7"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.1.7"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "2Thess.1.7"
∷ word (ἀ ∷ π ∷ []) "2Thess.1.7"
∷ word (ο ∷ ὐ ∷ ρ ∷ α ∷ ν ∷ ο ∷ ῦ ∷ []) "2Thess.1.7"
∷ word (μ ∷ ε ∷ τ ∷ []) "2Thess.1.7"
∷ word (ἀ ∷ γ ∷ γ ∷ έ ∷ ∙λ ∷ ω ∷ ν ∷ []) "2Thess.1.7"
∷ word (δ ∷ υ ∷ ν ∷ ά ∷ μ ∷ ε ∷ ω ∷ ς ∷ []) "2Thess.1.7"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.7"
∷ word (ἐ ∷ ν ∷ []) "2Thess.1.8"
∷ word (φ ∷ ∙λ ∷ ο ∷ γ ∷ ὶ ∷ []) "2Thess.1.8"
∷ word (π ∷ υ ∷ ρ ∷ ό ∷ ς ∷ []) "2Thess.1.8"
∷ word (δ ∷ ι ∷ δ ∷ ό ∷ ν ∷ τ ∷ ο ∷ ς ∷ []) "2Thess.1.8"
∷ word (ἐ ∷ κ ∷ δ ∷ ί ∷ κ ∷ η ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.1.8"
∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "2Thess.1.8"
∷ word (μ ∷ ὴ ∷ []) "2Thess.1.8"
∷ word (ε ∷ ἰ ∷ δ ∷ ό ∷ σ ∷ ι ∷ []) "2Thess.1.8"
∷ word (θ ∷ ε ∷ ὸ ∷ ν ∷ []) "2Thess.1.8"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.8"
∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "2Thess.1.8"
∷ word (μ ∷ ὴ ∷ []) "2Thess.1.8"
∷ word (ὑ ∷ π ∷ α ∷ κ ∷ ο ∷ ύ ∷ ο ∷ υ ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.1.8"
∷ word (τ ∷ ῷ ∷ []) "2Thess.1.8"
∷ word (ε ∷ ὐ ∷ α ∷ γ ∷ γ ∷ ε ∷ ∙λ ∷ ί ∷ ῳ ∷ []) "2Thess.1.8"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.8"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.1.8"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.8"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "2Thess.1.8"
∷ word (ο ∷ ἵ ∷ τ ∷ ι ∷ ν ∷ ε ∷ ς ∷ []) "2Thess.1.9"
∷ word (δ ∷ ί ∷ κ ∷ η ∷ ν ∷ []) "2Thess.1.9"
∷ word (τ ∷ ί ∷ σ ∷ ο ∷ υ ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.1.9"
∷ word (ὄ ∷ ∙λ ∷ ε ∷ θ ∷ ρ ∷ ο ∷ ν ∷ []) "2Thess.1.9"
∷ word (α ∷ ἰ ∷ ώ ∷ ν ∷ ι ∷ ο ∷ ν ∷ []) "2Thess.1.9"
∷ word (ἀ ∷ π ∷ ὸ ∷ []) "2Thess.1.9"
∷ word (π ∷ ρ ∷ ο ∷ σ ∷ ώ ∷ π ∷ ο ∷ υ ∷ []) "2Thess.1.9"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.9"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.1.9"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.9"
∷ word (ἀ ∷ π ∷ ὸ ∷ []) "2Thess.1.9"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.1.9"
∷ word (δ ∷ ό ∷ ξ ∷ η ∷ ς ∷ []) "2Thess.1.9"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.1.9"
∷ word (ἰ ∷ σ ∷ χ ∷ ύ ∷ ο ∷ ς ∷ []) "2Thess.1.9"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.9"
∷ word (ὅ ∷ τ ∷ α ∷ ν ∷ []) "2Thess.1.10"
∷ word (ἔ ∷ ∙λ ∷ θ ∷ ῃ ∷ []) "2Thess.1.10"
∷ word (ἐ ∷ ν ∷ δ ∷ ο ∷ ξ ∷ α ∷ σ ∷ θ ∷ ῆ ∷ ν ∷ α ∷ ι ∷ []) "2Thess.1.10"
∷ word (ἐ ∷ ν ∷ []) "2Thess.1.10"
∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "2Thess.1.10"
∷ word (ἁ ∷ γ ∷ ί ∷ ο ∷ ι ∷ ς ∷ []) "2Thess.1.10"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.10"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.10"
∷ word (θ ∷ α ∷ υ ∷ μ ∷ α ∷ σ ∷ θ ∷ ῆ ∷ ν ∷ α ∷ ι ∷ []) "2Thess.1.10"
∷ word (ἐ ∷ ν ∷ []) "2Thess.1.10"
∷ word (π ∷ ᾶ ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.1.10"
∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "2Thess.1.10"
∷ word (π ∷ ι ∷ σ ∷ τ ∷ ε ∷ ύ ∷ σ ∷ α ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.1.10"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "2Thess.1.10"
∷ word (ἐ ∷ π ∷ ι ∷ σ ∷ τ ∷ ε ∷ ύ ∷ θ ∷ η ∷ []) "2Thess.1.10"
∷ word (τ ∷ ὸ ∷ []) "2Thess.1.10"
∷ word (μ ∷ α ∷ ρ ∷ τ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ν ∷ []) "2Thess.1.10"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.10"
∷ word (ἐ ∷ φ ∷ []) "2Thess.1.10"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.1.10"
∷ word (ἐ ∷ ν ∷ []) "2Thess.1.10"
∷ word (τ ∷ ῇ ∷ []) "2Thess.1.10"
∷ word (ἡ ∷ μ ∷ έ ∷ ρ ∷ ᾳ ∷ []) "2Thess.1.10"
∷ word (ἐ ∷ κ ∷ ε ∷ ί ∷ ν ∷ ῃ ∷ []) "2Thess.1.10"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.1.11"
∷ word (ὃ ∷ []) "2Thess.1.11"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.11"
∷ word (π ∷ ρ ∷ ο ∷ σ ∷ ε ∷ υ ∷ χ ∷ ό ∷ μ ∷ ε ∷ θ ∷ α ∷ []) "2Thess.1.11"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ ο ∷ τ ∷ ε ∷ []) "2Thess.1.11"
∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "2Thess.1.11"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.11"
∷ word (ἵ ∷ ν ∷ α ∷ []) "2Thess.1.11"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.1.11"
∷ word (ἀ ∷ ξ ∷ ι ∷ ώ ∷ σ ∷ ῃ ∷ []) "2Thess.1.11"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.1.11"
∷ word (κ ∷ ∙λ ∷ ή ∷ σ ∷ ε ∷ ω ∷ ς ∷ []) "2Thess.1.11"
∷ word (ὁ ∷ []) "2Thess.1.11"
∷ word (θ ∷ ε ∷ ὸ ∷ ς ∷ []) "2Thess.1.11"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.11"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.11"
∷ word (π ∷ ∙λ ∷ η ∷ ρ ∷ ώ ∷ σ ∷ ῃ ∷ []) "2Thess.1.11"
∷ word (π ∷ ᾶ ∷ σ ∷ α ∷ ν ∷ []) "2Thess.1.11"
∷ word (ε ∷ ὐ ∷ δ ∷ ο ∷ κ ∷ ί ∷ α ∷ ν ∷ []) "2Thess.1.11"
∷ word (ἀ ∷ γ ∷ α ∷ θ ∷ ω ∷ σ ∷ ύ ∷ ν ∷ η ∷ ς ∷ []) "2Thess.1.11"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.11"
∷ word (ἔ ∷ ρ ∷ γ ∷ ο ∷ ν ∷ []) "2Thess.1.11"
∷ word (π ∷ ί ∷ σ ∷ τ ∷ ε ∷ ω ∷ ς ∷ []) "2Thess.1.11"
∷ word (ἐ ∷ ν ∷ []) "2Thess.1.11"
∷ word (δ ∷ υ ∷ ν ∷ ά ∷ μ ∷ ε ∷ ι ∷ []) "2Thess.1.11"
∷ word (ὅ ∷ π ∷ ω ∷ ς ∷ []) "2Thess.1.12"
∷ word (ἐ ∷ ν ∷ δ ∷ ο ∷ ξ ∷ α ∷ σ ∷ θ ∷ ῇ ∷ []) "2Thess.1.12"
∷ word (τ ∷ ὸ ∷ []) "2Thess.1.12"
∷ word (ὄ ∷ ν ∷ ο ∷ μ ∷ α ∷ []) "2Thess.1.12"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.12"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.1.12"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.12"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "2Thess.1.12"
∷ word (ἐ ∷ ν ∷ []) "2Thess.1.12"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "2Thess.1.12"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.12"
∷ word (ὑ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "2Thess.1.12"
∷ word (ἐ ∷ ν ∷ []) "2Thess.1.12"
∷ word (α ∷ ὐ ∷ τ ∷ ῷ ∷ []) "2Thess.1.12"
∷ word (κ ∷ α ∷ τ ∷ ὰ ∷ []) "2Thess.1.12"
∷ word (τ ∷ ὴ ∷ ν ∷ []) "2Thess.1.12"
∷ word (χ ∷ ά ∷ ρ ∷ ι ∷ ν ∷ []) "2Thess.1.12"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.12"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "2Thess.1.12"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.12"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.12"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.1.12"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "2Thess.1.12"
∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.12"
∷ word (Ἐ ∷ ρ ∷ ω ∷ τ ∷ ῶ ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.2.1"
∷ word (δ ∷ ὲ ∷ []) "2Thess.2.1"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.2.1"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "2Thess.2.1"
∷ word (ὑ ∷ π ∷ ὲ ∷ ρ ∷ []) "2Thess.2.1"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.2.1"
∷ word (π ∷ α ∷ ρ ∷ ο ∷ υ ∷ σ ∷ ί ∷ α ∷ ς ∷ []) "2Thess.2.1"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.1"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.2.1"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.2.1"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "2Thess.2.1"
∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.1"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.1"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.2.1"
∷ word (ἐ ∷ π ∷ ι ∷ σ ∷ υ ∷ ν ∷ α ∷ γ ∷ ω ∷ γ ∷ ῆ ∷ ς ∷ []) "2Thess.2.1"
∷ word (ἐ ∷ π ∷ []) "2Thess.2.1"
∷ word (α ∷ ὐ ∷ τ ∷ ό ∷ ν ∷ []) "2Thess.2.1"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.2.2"
∷ word (τ ∷ ὸ ∷ []) "2Thess.2.2"
∷ word (μ ∷ ὴ ∷ []) "2Thess.2.2"
∷ word (τ ∷ α ∷ χ ∷ έ ∷ ω ∷ ς ∷ []) "2Thess.2.2"
∷ word (σ ∷ α ∷ ∙λ ∷ ε ∷ υ ∷ θ ∷ ῆ ∷ ν ∷ α ∷ ι ∷ []) "2Thess.2.2"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.2.2"
∷ word (ἀ ∷ π ∷ ὸ ∷ []) "2Thess.2.2"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.2"
∷ word (ν ∷ ο ∷ ὸ ∷ ς ∷ []) "2Thess.2.2"
∷ word (μ ∷ η ∷ δ ∷ ὲ ∷ []) "2Thess.2.2"
∷ word (θ ∷ ρ ∷ ο ∷ ε ∷ ῖ ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "2Thess.2.2"
∷ word (μ ∷ ή ∷ τ ∷ ε ∷ []) "2Thess.2.2"
∷ word (δ ∷ ι ∷ ὰ ∷ []) "2Thess.2.2"
∷ word (π ∷ ν ∷ ε ∷ ύ ∷ μ ∷ α ∷ τ ∷ ο ∷ ς ∷ []) "2Thess.2.2"
∷ word (μ ∷ ή ∷ τ ∷ ε ∷ []) "2Thess.2.2"
∷ word (δ ∷ ι ∷ ὰ ∷ []) "2Thess.2.2"
∷ word (∙λ ∷ ό ∷ γ ∷ ο ∷ υ ∷ []) "2Thess.2.2"
∷ word (μ ∷ ή ∷ τ ∷ ε ∷ []) "2Thess.2.2"
∷ word (δ ∷ ι ∷ []) "2Thess.2.2"
∷ word (ἐ ∷ π ∷ ι ∷ σ ∷ τ ∷ ο ∷ ∙λ ∷ ῆ ∷ ς ∷ []) "2Thess.2.2"
∷ word (ὡ ∷ ς ∷ []) "2Thess.2.2"
∷ word (δ ∷ ι ∷ []) "2Thess.2.2"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.2.2"
∷ word (ὡ ∷ ς ∷ []) "2Thess.2.2"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "2Thess.2.2"
∷ word (ἐ ∷ ν ∷ έ ∷ σ ∷ τ ∷ η ∷ κ ∷ ε ∷ ν ∷ []) "2Thess.2.2"
∷ word (ἡ ∷ []) "2Thess.2.2"
∷ word (ἡ ∷ μ ∷ έ ∷ ρ ∷ α ∷ []) "2Thess.2.2"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.2"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.2.2"
∷ word (μ ∷ ή ∷ []) "2Thess.2.3"
∷ word (τ ∷ ι ∷ ς ∷ []) "2Thess.2.3"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.2.3"
∷ word (ἐ ∷ ξ ∷ α ∷ π ∷ α ∷ τ ∷ ή ∷ σ ∷ ῃ ∷ []) "2Thess.2.3"
∷ word (κ ∷ α ∷ τ ∷ ὰ ∷ []) "2Thess.2.3"
∷ word (μ ∷ η ∷ δ ∷ έ ∷ ν ∷ α ∷ []) "2Thess.2.3"
∷ word (τ ∷ ρ ∷ ό ∷ π ∷ ο ∷ ν ∷ []) "2Thess.2.3"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "2Thess.2.3"
∷ word (ἐ ∷ ὰ ∷ ν ∷ []) "2Thess.2.3"
∷ word (μ ∷ ὴ ∷ []) "2Thess.2.3"
∷ word (ἔ ∷ ∙λ ∷ θ ∷ ῃ ∷ []) "2Thess.2.3"
∷ word (ἡ ∷ []) "2Thess.2.3"
∷ word (ἀ ∷ π ∷ ο ∷ σ ∷ τ ∷ α ∷ σ ∷ ί ∷ α ∷ []) "2Thess.2.3"
∷ word (π ∷ ρ ∷ ῶ ∷ τ ∷ ο ∷ ν ∷ []) "2Thess.2.3"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.3"
∷ word (ἀ ∷ π ∷ ο ∷ κ ∷ α ∷ ∙λ ∷ υ ∷ φ ∷ θ ∷ ῇ ∷ []) "2Thess.2.3"
∷ word (ὁ ∷ []) "2Thess.2.3"
∷ word (ἄ ∷ ν ∷ θ ∷ ρ ∷ ω ∷ π ∷ ο ∷ ς ∷ []) "2Thess.2.3"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.2.3"
∷ word (ἀ ∷ ν ∷ ο ∷ μ ∷ ί ∷ α ∷ ς ∷ []) "2Thess.2.3"
∷ word (ὁ ∷ []) "2Thess.2.3"
∷ word (υ ∷ ἱ ∷ ὸ ∷ ς ∷ []) "2Thess.2.3"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.2.3"
∷ word (ἀ ∷ π ∷ ω ∷ ∙λ ∷ ε ∷ ί ∷ α ∷ ς ∷ []) "2Thess.2.3"
∷ word (ὁ ∷ []) "2Thess.2.4"
∷ word (ἀ ∷ ν ∷ τ ∷ ι ∷ κ ∷ ε ∷ ί ∷ μ ∷ ε ∷ ν ∷ ο ∷ ς ∷ []) "2Thess.2.4"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.4"
∷ word (ὑ ∷ π ∷ ε ∷ ρ ∷ α ∷ ι ∷ ρ ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ς ∷ []) "2Thess.2.4"
∷ word (ἐ ∷ π ∷ ὶ ∷ []) "2Thess.2.4"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ α ∷ []) "2Thess.2.4"
∷ word (∙λ ∷ ε ∷ γ ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ν ∷ []) "2Thess.2.4"
∷ word (θ ∷ ε ∷ ὸ ∷ ν ∷ []) "2Thess.2.4"
∷ word (ἢ ∷ []) "2Thess.2.4"
∷ word (σ ∷ έ ∷ β ∷ α ∷ σ ∷ μ ∷ α ∷ []) "2Thess.2.4"
∷ word (ὥ ∷ σ ∷ τ ∷ ε ∷ []) "2Thess.2.4"
∷ word (α ∷ ὐ ∷ τ ∷ ὸ ∷ ν ∷ []) "2Thess.2.4"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.2.4"
∷ word (τ ∷ ὸ ∷ ν ∷ []) "2Thess.2.4"
∷ word (ν ∷ α ∷ ὸ ∷ ν ∷ []) "2Thess.2.4"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.4"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "2Thess.2.4"
∷ word (κ ∷ α ∷ θ ∷ ί ∷ σ ∷ α ∷ ι ∷ []) "2Thess.2.4"
∷ word (ἀ ∷ π ∷ ο ∷ δ ∷ ε ∷ ι ∷ κ ∷ ν ∷ ύ ∷ ν ∷ τ ∷ α ∷ []) "2Thess.2.4"
∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ὸ ∷ ν ∷ []) "2Thess.2.4"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "2Thess.2.4"
∷ word (ἔ ∷ σ ∷ τ ∷ ι ∷ ν ∷ []) "2Thess.2.4"
∷ word (θ ∷ ε ∷ ό ∷ ς ∷ []) "2Thess.2.4"
∷ word (ο ∷ ὐ ∷ []) "2Thess.2.5"
∷ word (μ ∷ ν ∷ η ∷ μ ∷ ο ∷ ν ∷ ε ∷ ύ ∷ ε ∷ τ ∷ ε ∷ []) "2Thess.2.5"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "2Thess.2.5"
∷ word (ἔ ∷ τ ∷ ι ∷ []) "2Thess.2.5"
∷ word (ὢ ∷ ν ∷ []) "2Thess.2.5"
∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "2Thess.2.5"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.2.5"
∷ word (τ ∷ α ∷ ῦ ∷ τ ∷ α ∷ []) "2Thess.2.5"
∷ word (ἔ ∷ ∙λ ∷ ε ∷ γ ∷ ο ∷ ν ∷ []) "2Thess.2.5"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "2Thess.2.5"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.6"
∷ word (ν ∷ ῦ ∷ ν ∷ []) "2Thess.2.6"
∷ word (τ ∷ ὸ ∷ []) "2Thess.2.6"
∷ word (κ ∷ α ∷ τ ∷ έ ∷ χ ∷ ο ∷ ν ∷ []) "2Thess.2.6"
∷ word (ο ∷ ἴ ∷ δ ∷ α ∷ τ ∷ ε ∷ []) "2Thess.2.6"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.2.6"
∷ word (τ ∷ ὸ ∷ []) "2Thess.2.6"
∷ word (ἀ ∷ π ∷ ο ∷ κ ∷ α ∷ ∙λ ∷ υ ∷ φ ∷ θ ∷ ῆ ∷ ν ∷ α ∷ ι ∷ []) "2Thess.2.6"
∷ word (α ∷ ὐ ∷ τ ∷ ὸ ∷ ν ∷ []) "2Thess.2.6"
∷ word (ἐ ∷ ν ∷ []) "2Thess.2.6"
∷ word (τ ∷ ῷ ∷ []) "2Thess.2.6"
∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.6"
∷ word (κ ∷ α ∷ ι ∷ ρ ∷ ῷ ∷ []) "2Thess.2.6"
∷ word (τ ∷ ὸ ∷ []) "2Thess.2.7"
∷ word (γ ∷ ὰ ∷ ρ ∷ []) "2Thess.2.7"
∷ word (μ ∷ υ ∷ σ ∷ τ ∷ ή ∷ ρ ∷ ι ∷ ο ∷ ν ∷ []) "2Thess.2.7"
∷ word (ἤ ∷ δ ∷ η ∷ []) "2Thess.2.7"
∷ word (ἐ ∷ ν ∷ ε ∷ ρ ∷ γ ∷ ε ∷ ῖ ∷ τ ∷ α ∷ ι ∷ []) "2Thess.2.7"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.2.7"
∷ word (ἀ ∷ ν ∷ ο ∷ μ ∷ ί ∷ α ∷ ς ∷ []) "2Thess.2.7"
∷ word (μ ∷ ό ∷ ν ∷ ο ∷ ν ∷ []) "2Thess.2.7"
∷ word (ὁ ∷ []) "2Thess.2.7"
∷ word (κ ∷ α ∷ τ ∷ έ ∷ χ ∷ ω ∷ ν ∷ []) "2Thess.2.7"
∷ word (ἄ ∷ ρ ∷ τ ∷ ι ∷ []) "2Thess.2.7"
∷ word (ἕ ∷ ω ∷ ς ∷ []) "2Thess.2.7"
∷ word (ἐ ∷ κ ∷ []) "2Thess.2.7"
∷ word (μ ∷ έ ∷ σ ∷ ο ∷ υ ∷ []) "2Thess.2.7"
∷ word (γ ∷ έ ∷ ν ∷ η ∷ τ ∷ α ∷ ι ∷ []) "2Thess.2.7"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.8"
∷ word (τ ∷ ό ∷ τ ∷ ε ∷ []) "2Thess.2.8"
∷ word (ἀ ∷ π ∷ ο ∷ κ ∷ α ∷ ∙λ ∷ υ ∷ φ ∷ θ ∷ ή ∷ σ ∷ ε ∷ τ ∷ α ∷ ι ∷ []) "2Thess.2.8"
∷ word (ὁ ∷ []) "2Thess.2.8"
∷ word (ἄ ∷ ν ∷ ο ∷ μ ∷ ο ∷ ς ∷ []) "2Thess.2.8"
∷ word (ὃ ∷ ν ∷ []) "2Thess.2.8"
∷ word (ὁ ∷ []) "2Thess.2.8"
∷ word (κ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ς ∷ []) "2Thess.2.8"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ ς ∷ []) "2Thess.2.8"
∷ word (ἀ ∷ ν ∷ ε ∷ ∙λ ∷ ε ∷ ῖ ∷ []) "2Thess.2.8"
∷ word (τ ∷ ῷ ∷ []) "2Thess.2.8"
∷ word (π ∷ ν ∷ ε ∷ ύ ∷ μ ∷ α ∷ τ ∷ ι ∷ []) "2Thess.2.8"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.8"
∷ word (σ ∷ τ ∷ ό ∷ μ ∷ α ∷ τ ∷ ο ∷ ς ∷ []) "2Thess.2.8"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.8"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.8"
∷ word (κ ∷ α ∷ τ ∷ α ∷ ρ ∷ γ ∷ ή ∷ σ ∷ ε ∷ ι ∷ []) "2Thess.2.8"
∷ word (τ ∷ ῇ ∷ []) "2Thess.2.8"
∷ word (ἐ ∷ π ∷ ι ∷ φ ∷ α ∷ ν ∷ ε ∷ ί ∷ ᾳ ∷ []) "2Thess.2.8"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.2.8"
∷ word (π ∷ α ∷ ρ ∷ ο ∷ υ ∷ σ ∷ ί ∷ α ∷ ς ∷ []) "2Thess.2.8"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.8"
∷ word (ο ∷ ὗ ∷ []) "2Thess.2.9"
∷ word (ἐ ∷ σ ∷ τ ∷ ι ∷ ν ∷ []) "2Thess.2.9"
∷ word (ἡ ∷ []) "2Thess.2.9"
∷ word (π ∷ α ∷ ρ ∷ ο ∷ υ ∷ σ ∷ ί ∷ α ∷ []) "2Thess.2.9"
∷ word (κ ∷ α ∷ τ ∷ []) "2Thess.2.9"
∷ word (ἐ ∷ ν ∷ έ ∷ ρ ∷ γ ∷ ε ∷ ι ∷ α ∷ ν ∷ []) "2Thess.2.9"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.9"
∷ word (Σ ∷ α ∷ τ ∷ α ∷ ν ∷ ᾶ ∷ []) "2Thess.2.9"
∷ word (ἐ ∷ ν ∷ []) "2Thess.2.9"
∷ word (π ∷ ά ∷ σ ∷ ῃ ∷ []) "2Thess.2.9"
∷ word (δ ∷ υ ∷ ν ∷ ά ∷ μ ∷ ε ∷ ι ∷ []) "2Thess.2.9"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.9"
∷ word (σ ∷ η ∷ μ ∷ ε ∷ ί ∷ ο ∷ ι ∷ ς ∷ []) "2Thess.2.9"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.9"
∷ word (τ ∷ έ ∷ ρ ∷ α ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.2.9"
∷ word (ψ ∷ ε ∷ ύ ∷ δ ∷ ο ∷ υ ∷ ς ∷ []) "2Thess.2.9"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.10"
∷ word (ἐ ∷ ν ∷ []) "2Thess.2.10"
∷ word (π ∷ ά ∷ σ ∷ ῃ ∷ []) "2Thess.2.10"
∷ word (ἀ ∷ π ∷ ά ∷ τ ∷ ῃ ∷ []) "2Thess.2.10"
∷ word (ἀ ∷ δ ∷ ι ∷ κ ∷ ί ∷ α ∷ ς ∷ []) "2Thess.2.10"
∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "2Thess.2.10"
∷ word (ἀ ∷ π ∷ ο ∷ ∙λ ∷ ∙λ ∷ υ ∷ μ ∷ έ ∷ ν ∷ ο ∷ ι ∷ ς ∷ []) "2Thess.2.10"
∷ word (ἀ ∷ ν ∷ θ ∷ []) "2Thess.2.10"
∷ word (ὧ ∷ ν ∷ []) "2Thess.2.10"
∷ word (τ ∷ ὴ ∷ ν ∷ []) "2Thess.2.10"
∷ word (ἀ ∷ γ ∷ ά ∷ π ∷ η ∷ ν ∷ []) "2Thess.2.10"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.2.10"
∷ word (ἀ ∷ ∙λ ∷ η ∷ θ ∷ ε ∷ ί ∷ α ∷ ς ∷ []) "2Thess.2.10"
∷ word (ο ∷ ὐ ∷ κ ∷ []) "2Thess.2.10"
∷ word (ἐ ∷ δ ∷ έ ∷ ξ ∷ α ∷ ν ∷ τ ∷ ο ∷ []) "2Thess.2.10"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.2.10"
∷ word (τ ∷ ὸ ∷ []) "2Thess.2.10"
∷ word (σ ∷ ω ∷ θ ∷ ῆ ∷ ν ∷ α ∷ ι ∷ []) "2Thess.2.10"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ύ ∷ ς ∷ []) "2Thess.2.10"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.11"
∷ word (δ ∷ ι ∷ ὰ ∷ []) "2Thess.2.11"
∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ []) "2Thess.2.11"
∷ word (π ∷ έ ∷ μ ∷ π ∷ ε ∷ ι ∷ []) "2Thess.2.11"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῖ ∷ ς ∷ []) "2Thess.2.11"
∷ word (ὁ ∷ []) "2Thess.2.11"
∷ word (θ ∷ ε ∷ ὸ ∷ ς ∷ []) "2Thess.2.11"
∷ word (ἐ ∷ ν ∷ έ ∷ ρ ∷ γ ∷ ε ∷ ι ∷ α ∷ ν ∷ []) "2Thess.2.11"
∷ word (π ∷ ∙λ ∷ ά ∷ ν ∷ η ∷ ς ∷ []) "2Thess.2.11"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.2.11"
∷ word (τ ∷ ὸ ∷ []) "2Thess.2.11"
∷ word (π ∷ ι ∷ σ ∷ τ ∷ ε ∷ ῦ ∷ σ ∷ α ∷ ι ∷ []) "2Thess.2.11"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ὺ ∷ ς ∷ []) "2Thess.2.11"
∷ word (τ ∷ ῷ ∷ []) "2Thess.2.11"
∷ word (ψ ∷ ε ∷ ύ ∷ δ ∷ ε ∷ ι ∷ []) "2Thess.2.11"
∷ word (ἵ ∷ ν ∷ α ∷ []) "2Thess.2.12"
∷ word (κ ∷ ρ ∷ ι ∷ θ ∷ ῶ ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.2.12"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "2Thess.2.12"
∷ word (ο ∷ ἱ ∷ []) "2Thess.2.12"
∷ word (μ ∷ ὴ ∷ []) "2Thess.2.12"
∷ word (π ∷ ι ∷ σ ∷ τ ∷ ε ∷ ύ ∷ σ ∷ α ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "2Thess.2.12"
∷ word (τ ∷ ῇ ∷ []) "2Thess.2.12"
∷ word (ἀ ∷ ∙λ ∷ η ∷ θ ∷ ε ∷ ί ∷ ᾳ ∷ []) "2Thess.2.12"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "2Thess.2.12"
∷ word (ε ∷ ὐ ∷ δ ∷ ο ∷ κ ∷ ή ∷ σ ∷ α ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "2Thess.2.12"
∷ word (τ ∷ ῇ ∷ []) "2Thess.2.12"
∷ word (ἀ ∷ δ ∷ ι ∷ κ ∷ ί ∷ ᾳ ∷ []) "2Thess.2.12"
∷ word (Ἡ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "2Thess.2.13"
∷ word (δ ∷ ὲ ∷ []) "2Thess.2.13"
∷ word (ὀ ∷ φ ∷ ε ∷ ί ∷ ∙λ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.2.13"
∷ word (ε ∷ ὐ ∷ χ ∷ α ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ε ∷ ῖ ∷ ν ∷ []) "2Thess.2.13"
∷ word (τ ∷ ῷ ∷ []) "2Thess.2.13"
∷ word (θ ∷ ε ∷ ῷ ∷ []) "2Thess.2.13"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ ο ∷ τ ∷ ε ∷ []) "2Thess.2.13"
∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "2Thess.2.13"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.2.13"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ὶ ∷ []) "2Thess.2.13"
∷ word (ἠ ∷ γ ∷ α ∷ π ∷ η ∷ μ ∷ έ ∷ ν ∷ ο ∷ ι ∷ []) "2Thess.2.13"
∷ word (ὑ ∷ π ∷ ὸ ∷ []) "2Thess.2.13"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.2.13"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "2Thess.2.13"
∷ word (ε ∷ ἵ ∷ ∙λ ∷ α ∷ τ ∷ ο ∷ []) "2Thess.2.13"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.2.13"
∷ word (ὁ ∷ []) "2Thess.2.13"
∷ word (θ ∷ ε ∷ ὸ ∷ ς ∷ []) "2Thess.2.13"
∷ word (ἀ ∷ π ∷ α ∷ ρ ∷ χ ∷ ὴ ∷ ν ∷ []) "2Thess.2.13"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.2.13"
∷ word (σ ∷ ω ∷ τ ∷ η ∷ ρ ∷ ί ∷ α ∷ ν ∷ []) "2Thess.2.13"
∷ word (ἐ ∷ ν ∷ []) "2Thess.2.13"
∷ word (ἁ ∷ γ ∷ ι ∷ α ∷ σ ∷ μ ∷ ῷ ∷ []) "2Thess.2.13"
∷ word (π ∷ ν ∷ ε ∷ ύ ∷ μ ∷ α ∷ τ ∷ ο ∷ ς ∷ []) "2Thess.2.13"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.13"
∷ word (π ∷ ί ∷ σ ∷ τ ∷ ε ∷ ι ∷ []) "2Thess.2.13"
∷ word (ἀ ∷ ∙λ ∷ η ∷ θ ∷ ε ∷ ί ∷ α ∷ ς ∷ []) "2Thess.2.13"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.2.14"
∷ word (ὃ ∷ []) "2Thess.2.14"
∷ word (ἐ ∷ κ ∷ ά ∷ ∙λ ∷ ε ∷ σ ∷ ε ∷ ν ∷ []) "2Thess.2.14"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.2.14"
∷ word (δ ∷ ι ∷ ὰ ∷ []) "2Thess.2.14"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.14"
∷ word (ε ∷ ὐ ∷ α ∷ γ ∷ γ ∷ ε ∷ ∙λ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.2.14"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.2.14"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.2.14"
∷ word (π ∷ ε ∷ ρ ∷ ι ∷ π ∷ ο ∷ ί ∷ η ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.2.14"
∷ word (δ ∷ ό ∷ ξ ∷ η ∷ ς ∷ []) "2Thess.2.14"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.14"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.2.14"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.2.14"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "2Thess.2.14"
∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.14"
∷ word (ἄ ∷ ρ ∷ α ∷ []) "2Thess.2.15"
∷ word (ο ∷ ὖ ∷ ν ∷ []) "2Thess.2.15"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "2Thess.2.15"
∷ word (σ ∷ τ ∷ ή ∷ κ ∷ ε ∷ τ ∷ ε ∷ []) "2Thess.2.15"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.15"
∷ word (κ ∷ ρ ∷ α ∷ τ ∷ ε ∷ ῖ ∷ τ ∷ ε ∷ []) "2Thess.2.15"
∷ word (τ ∷ ὰ ∷ ς ∷ []) "2Thess.2.15"
∷ word (π ∷ α ∷ ρ ∷ α ∷ δ ∷ ό ∷ σ ∷ ε ∷ ι ∷ ς ∷ []) "2Thess.2.15"
∷ word (ἃ ∷ ς ∷ []) "2Thess.2.15"
∷ word (ἐ ∷ δ ∷ ι ∷ δ ∷ ά ∷ χ ∷ θ ∷ η ∷ τ ∷ ε ∷ []) "2Thess.2.15"
∷ word (ε ∷ ἴ ∷ τ ∷ ε ∷ []) "2Thess.2.15"
∷ word (δ ∷ ι ∷ ὰ ∷ []) "2Thess.2.15"
∷ word (∙λ ∷ ό ∷ γ ∷ ο ∷ υ ∷ []) "2Thess.2.15"
∷ word (ε ∷ ἴ ∷ τ ∷ ε ∷ []) "2Thess.2.15"
∷ word (δ ∷ ι ∷ []) "2Thess.2.15"
∷ word (ἐ ∷ π ∷ ι ∷ σ ∷ τ ∷ ο ∷ ∙λ ∷ ῆ ∷ ς ∷ []) "2Thess.2.15"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.2.15"
∷ word (Α ∷ ὐ ∷ τ ∷ ὸ ∷ ς ∷ []) "2Thess.2.16"
∷ word (δ ∷ ὲ ∷ []) "2Thess.2.16"
∷ word (ὁ ∷ []) "2Thess.2.16"
∷ word (κ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ς ∷ []) "2Thess.2.16"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.2.16"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ ς ∷ []) "2Thess.2.16"
∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ὸ ∷ ς ∷ []) "2Thess.2.16"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.16"
∷ word (θ ∷ ε ∷ ὸ ∷ ς ∷ []) "2Thess.2.16"
∷ word (ὁ ∷ []) "2Thess.2.16"
∷ word (π ∷ α ∷ τ ∷ ὴ ∷ ρ ∷ []) "2Thess.2.16"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.2.16"
∷ word (ὁ ∷ []) "2Thess.2.16"
∷ word (ἀ ∷ γ ∷ α ∷ π ∷ ή ∷ σ ∷ α ∷ ς ∷ []) "2Thess.2.16"
∷ word (ἡ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.2.16"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.16"
∷ word (δ ∷ ο ∷ ὺ ∷ ς ∷ []) "2Thess.2.16"
∷ word (π ∷ α ∷ ρ ∷ ά ∷ κ ∷ ∙λ ∷ η ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.2.16"
∷ word (α ∷ ἰ ∷ ω ∷ ν ∷ ί ∷ α ∷ ν ∷ []) "2Thess.2.16"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.16"
∷ word (ἐ ∷ ∙λ ∷ π ∷ ί ∷ δ ∷ α ∷ []) "2Thess.2.16"
∷ word (ἀ ∷ γ ∷ α ∷ θ ∷ ὴ ∷ ν ∷ []) "2Thess.2.16"
∷ word (ἐ ∷ ν ∷ []) "2Thess.2.16"
∷ word (χ ∷ ά ∷ ρ ∷ ι ∷ τ ∷ ι ∷ []) "2Thess.2.16"
∷ word (π ∷ α ∷ ρ ∷ α ∷ κ ∷ α ∷ ∙λ ∷ έ ∷ σ ∷ α ∷ ι ∷ []) "2Thess.2.17"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.2.17"
∷ word (τ ∷ ὰ ∷ ς ∷ []) "2Thess.2.17"
∷ word (κ ∷ α ∷ ρ ∷ δ ∷ ί ∷ α ∷ ς ∷ []) "2Thess.2.17"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.17"
∷ word (σ ∷ τ ∷ η ∷ ρ ∷ ί ∷ ξ ∷ α ∷ ι ∷ []) "2Thess.2.17"
∷ word (ἐ ∷ ν ∷ []) "2Thess.2.17"
∷ word (π ∷ α ∷ ν ∷ τ ∷ ὶ ∷ []) "2Thess.2.17"
∷ word (ἔ ∷ ρ ∷ γ ∷ ῳ ∷ []) "2Thess.2.17"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.17"
∷ word (∙λ ∷ ό ∷ γ ∷ ῳ ∷ []) "2Thess.2.17"
∷ word (ἀ ∷ γ ∷ α ∷ θ ∷ ῷ ∷ []) "2Thess.2.17"
∷ word (Τ ∷ ὸ ∷ []) "2Thess.3.1"
∷ word (∙λ ∷ ο ∷ ι ∷ π ∷ ὸ ∷ ν ∷ []) "2Thess.3.1"
∷ word (π ∷ ρ ∷ ο ∷ σ ∷ ε ∷ ύ ∷ χ ∷ ε ∷ σ ∷ θ ∷ ε ∷ []) "2Thess.3.1"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "2Thess.3.1"
∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "2Thess.3.1"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.3.1"
∷ word (ἵ ∷ ν ∷ α ∷ []) "2Thess.3.1"
∷ word (ὁ ∷ []) "2Thess.3.1"
∷ word (∙λ ∷ ό ∷ γ ∷ ο ∷ ς ∷ []) "2Thess.3.1"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.3.1"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.3.1"
∷ word (τ ∷ ρ ∷ έ ∷ χ ∷ ῃ ∷ []) "2Thess.3.1"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.1"
∷ word (δ ∷ ο ∷ ξ ∷ ά ∷ ζ ∷ η ∷ τ ∷ α ∷ ι ∷ []) "2Thess.3.1"
∷ word (κ ∷ α ∷ θ ∷ ὼ ∷ ς ∷ []) "2Thess.3.1"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.1"
∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "2Thess.3.1"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.3.1"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.2"
∷ word (ἵ ∷ ν ∷ α ∷ []) "2Thess.3.2"
∷ word (ῥ ∷ υ ∷ σ ∷ θ ∷ ῶ ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.2"
∷ word (ἀ ∷ π ∷ ὸ ∷ []) "2Thess.3.2"
∷ word (τ ∷ ῶ ∷ ν ∷ []) "2Thess.3.2"
∷ word (ἀ ∷ τ ∷ ό ∷ π ∷ ω ∷ ν ∷ []) "2Thess.3.2"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.2"
∷ word (π ∷ ο ∷ ν ∷ η ∷ ρ ∷ ῶ ∷ ν ∷ []) "2Thess.3.2"
∷ word (ἀ ∷ ν ∷ θ ∷ ρ ∷ ώ ∷ π ∷ ω ∷ ν ∷ []) "2Thess.3.2"
∷ word (ο ∷ ὐ ∷ []) "2Thess.3.2"
∷ word (γ ∷ ὰ ∷ ρ ∷ []) "2Thess.3.2"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ ω ∷ ν ∷ []) "2Thess.3.2"
∷ word (ἡ ∷ []) "2Thess.3.2"
∷ word (π ∷ ί ∷ σ ∷ τ ∷ ι ∷ ς ∷ []) "2Thess.3.2"
∷ word (π ∷ ι ∷ σ ∷ τ ∷ ὸ ∷ ς ∷ []) "2Thess.3.3"
∷ word (δ ∷ έ ∷ []) "2Thess.3.3"
∷ word (ἐ ∷ σ ∷ τ ∷ ι ∷ ν ∷ []) "2Thess.3.3"
∷ word (ὁ ∷ []) "2Thess.3.3"
∷ word (κ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ς ∷ []) "2Thess.3.3"
∷ word (ὃ ∷ ς ∷ []) "2Thess.3.3"
∷ word (σ ∷ τ ∷ η ∷ ρ ∷ ί ∷ ξ ∷ ε ∷ ι ∷ []) "2Thess.3.3"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.3.3"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.3"
∷ word (φ ∷ υ ∷ ∙λ ∷ ά ∷ ξ ∷ ε ∷ ι ∷ []) "2Thess.3.3"
∷ word (ἀ ∷ π ∷ ὸ ∷ []) "2Thess.3.3"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.3.3"
∷ word (π ∷ ο ∷ ν ∷ η ∷ ρ ∷ ο ∷ ῦ ∷ []) "2Thess.3.3"
∷ word (π ∷ ε ∷ π ∷ ο ∷ ί ∷ θ ∷ α ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.4"
∷ word (δ ∷ ὲ ∷ []) "2Thess.3.4"
∷ word (ἐ ∷ ν ∷ []) "2Thess.3.4"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ῳ ∷ []) "2Thess.3.4"
∷ word (ἐ ∷ φ ∷ []) "2Thess.3.4"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.3.4"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "2Thess.3.4"
∷ word (ἃ ∷ []) "2Thess.3.4"
∷ word (π ∷ α ∷ ρ ∷ α ∷ γ ∷ γ ∷ έ ∷ ∙λ ∷ ∙λ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.4"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.4"
∷ word (π ∷ ο ∷ ι ∷ ε ∷ ῖ ∷ τ ∷ ε ∷ []) "2Thess.3.4"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.4"
∷ word (π ∷ ο ∷ ι ∷ ή ∷ σ ∷ ε ∷ τ ∷ ε ∷ []) "2Thess.3.4"
∷ word (ὁ ∷ []) "2Thess.3.5"
∷ word (δ ∷ ὲ ∷ []) "2Thess.3.5"
∷ word (κ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ς ∷ []) "2Thess.3.5"
∷ word (κ ∷ α ∷ τ ∷ ε ∷ υ ∷ θ ∷ ύ ∷ ν ∷ α ∷ ι ∷ []) "2Thess.3.5"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.3.5"
∷ word (τ ∷ ὰ ∷ ς ∷ []) "2Thess.3.5"
∷ word (κ ∷ α ∷ ρ ∷ δ ∷ ί ∷ α ∷ ς ∷ []) "2Thess.3.5"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.3.5"
∷ word (τ ∷ ὴ ∷ ν ∷ []) "2Thess.3.5"
∷ word (ἀ ∷ γ ∷ ά ∷ π ∷ η ∷ ν ∷ []) "2Thess.3.5"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.3.5"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "2Thess.3.5"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.5"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.3.5"
∷ word (τ ∷ ὴ ∷ ν ∷ []) "2Thess.3.5"
∷ word (ὑ ∷ π ∷ ο ∷ μ ∷ ο ∷ ν ∷ ὴ ∷ ν ∷ []) "2Thess.3.5"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.3.5"
∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.3.5"
∷ word (Π ∷ α ∷ ρ ∷ α ∷ γ ∷ γ ∷ έ ∷ ∙λ ∷ ∙λ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.6"
∷ word (δ ∷ ὲ ∷ []) "2Thess.3.6"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "2Thess.3.6"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "2Thess.3.6"
∷ word (ἐ ∷ ν ∷ []) "2Thess.3.6"
∷ word (ὀ ∷ ν ∷ ό ∷ μ ∷ α ∷ τ ∷ ι ∷ []) "2Thess.3.6"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.3.6"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.3.6"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.3.6"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "2Thess.3.6"
∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.3.6"
∷ word (σ ∷ τ ∷ έ ∷ ∙λ ∷ ∙λ ∷ ε ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "2Thess.3.6"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.3.6"
∷ word (ἀ ∷ π ∷ ὸ ∷ []) "2Thess.3.6"
∷ word (π ∷ α ∷ ν ∷ τ ∷ ὸ ∷ ς ∷ []) "2Thess.3.6"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ῦ ∷ []) "2Thess.3.6"
∷ word (ἀ ∷ τ ∷ ά ∷ κ ∷ τ ∷ ω ∷ ς ∷ []) "2Thess.3.6"
∷ word (π ∷ ε ∷ ρ ∷ ι ∷ π ∷ α ∷ τ ∷ ο ∷ ῦ ∷ ν ∷ τ ∷ ο ∷ ς ∷ []) "2Thess.3.6"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.6"
∷ word (μ ∷ ὴ ∷ []) "2Thess.3.6"
∷ word (κ ∷ α ∷ τ ∷ ὰ ∷ []) "2Thess.3.6"
∷ word (τ ∷ ὴ ∷ ν ∷ []) "2Thess.3.6"
∷ word (π ∷ α ∷ ρ ∷ ά ∷ δ ∷ ο ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.3.6"
∷ word (ἣ ∷ ν ∷ []) "2Thess.3.6"
∷ word (π ∷ α ∷ ρ ∷ ε ∷ ∙λ ∷ ά ∷ β ∷ ο ∷ σ ∷ α ∷ ν ∷ []) "2Thess.3.6"
∷ word (π ∷ α ∷ ρ ∷ []) "2Thess.3.6"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.3.6"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ὶ ∷ []) "2Thess.3.7"
∷ word (γ ∷ ὰ ∷ ρ ∷ []) "2Thess.3.7"
∷ word (ο ∷ ἴ ∷ δ ∷ α ∷ τ ∷ ε ∷ []) "2Thess.3.7"
∷ word (π ∷ ῶ ∷ ς ∷ []) "2Thess.3.7"
∷ word (δ ∷ ε ∷ ῖ ∷ []) "2Thess.3.7"
∷ word (μ ∷ ι ∷ μ ∷ ε ∷ ῖ ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "2Thess.3.7"
∷ word (ἡ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.3.7"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "2Thess.3.7"
∷ word (ο ∷ ὐ ∷ κ ∷ []) "2Thess.3.7"
∷ word (ἠ ∷ τ ∷ α ∷ κ ∷ τ ∷ ή ∷ σ ∷ α ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.7"
∷ word (ἐ ∷ ν ∷ []) "2Thess.3.7"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "2Thess.3.7"
∷ word (ο ∷ ὐ ∷ δ ∷ ὲ ∷ []) "2Thess.3.8"
∷ word (δ ∷ ω ∷ ρ ∷ ε ∷ ὰ ∷ ν ∷ []) "2Thess.3.8"
∷ word (ἄ ∷ ρ ∷ τ ∷ ο ∷ ν ∷ []) "2Thess.3.8"
∷ word (ἐ ∷ φ ∷ ά ∷ γ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.8"
∷ word (π ∷ α ∷ ρ ∷ ά ∷ []) "2Thess.3.8"
∷ word (τ ∷ ι ∷ ν ∷ ο ∷ ς ∷ []) "2Thess.3.8"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ []) "2Thess.3.8"
∷ word (ἐ ∷ ν ∷ []) "2Thess.3.8"
∷ word (κ ∷ ό ∷ π ∷ ῳ ∷ []) "2Thess.3.8"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.8"
∷ word (μ ∷ ό ∷ χ ∷ θ ∷ ῳ ∷ []) "2Thess.3.8"
∷ word (ν ∷ υ ∷ κ ∷ τ ∷ ὸ ∷ ς ∷ []) "2Thess.3.8"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.8"
∷ word (ἡ ∷ μ ∷ έ ∷ ρ ∷ α ∷ ς ∷ []) "2Thess.3.8"
∷ word (ἐ ∷ ρ ∷ γ ∷ α ∷ ζ ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "2Thess.3.8"
∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "2Thess.3.8"
∷ word (τ ∷ ὸ ∷ []) "2Thess.3.8"
∷ word (μ ∷ ὴ ∷ []) "2Thess.3.8"
∷ word (ἐ ∷ π ∷ ι ∷ β ∷ α ∷ ρ ∷ ῆ ∷ σ ∷ α ∷ ί ∷ []) "2Thess.3.8"
∷ word (τ ∷ ι ∷ ν ∷ α ∷ []) "2Thess.3.8"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.3.8"
∷ word (ο ∷ ὐ ∷ χ ∷ []) "2Thess.3.9"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "2Thess.3.9"
∷ word (ο ∷ ὐ ∷ κ ∷ []) "2Thess.3.9"
∷ word (ἔ ∷ χ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.9"
∷ word (ἐ ∷ ξ ∷ ο ∷ υ ∷ σ ∷ ί ∷ α ∷ ν ∷ []) "2Thess.3.9"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ []) "2Thess.3.9"
∷ word (ἵ ∷ ν ∷ α ∷ []) "2Thess.3.9"
∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ο ∷ ὺ ∷ ς ∷ []) "2Thess.3.9"
∷ word (τ ∷ ύ ∷ π ∷ ο ∷ ν ∷ []) "2Thess.3.9"
∷ word (δ ∷ ῶ ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.9"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "2Thess.3.9"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.3.9"
∷ word (τ ∷ ὸ ∷ []) "2Thess.3.9"
∷ word (μ ∷ ι ∷ μ ∷ ε ∷ ῖ ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "2Thess.3.9"
∷ word (ἡ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.3.9"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.10"
∷ word (γ ∷ ὰ ∷ ρ ∷ []) "2Thess.3.10"
∷ word (ὅ ∷ τ ∷ ε ∷ []) "2Thess.3.10"
∷ word (ἦ ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.10"
∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "2Thess.3.10"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.3.10"
∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ []) "2Thess.3.10"
∷ word (π ∷ α ∷ ρ ∷ η ∷ γ ∷ γ ∷ έ ∷ ∙λ ∷ ∙λ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.10"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "2Thess.3.10"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "2Thess.3.10"
∷ word (ε ∷ ἴ ∷ []) "2Thess.3.10"
∷ word (τ ∷ ι ∷ ς ∷ []) "2Thess.3.10"
∷ word (ο ∷ ὐ ∷ []) "2Thess.3.10"
∷ word (θ ∷ έ ∷ ∙λ ∷ ε ∷ ι ∷ []) "2Thess.3.10"
∷ word (ἐ ∷ ρ ∷ γ ∷ ά ∷ ζ ∷ ε ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "2Thess.3.10"
∷ word (μ ∷ η ∷ δ ∷ ὲ ∷ []) "2Thess.3.10"
∷ word (ἐ ∷ σ ∷ θ ∷ ι ∷ έ ∷ τ ∷ ω ∷ []) "2Thess.3.10"
∷ word (ἀ ∷ κ ∷ ο ∷ ύ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.11"
∷ word (γ ∷ ά ∷ ρ ∷ []) "2Thess.3.11"
∷ word (τ ∷ ι ∷ ν ∷ α ∷ ς ∷ []) "2Thess.3.11"
∷ word (π ∷ ε ∷ ρ ∷ ι ∷ π ∷ α ∷ τ ∷ ο ∷ ῦ ∷ ν ∷ τ ∷ α ∷ ς ∷ []) "2Thess.3.11"
∷ word (ἐ ∷ ν ∷ []) "2Thess.3.11"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "2Thess.3.11"
∷ word (ἀ ∷ τ ∷ ά ∷ κ ∷ τ ∷ ω ∷ ς ∷ []) "2Thess.3.11"
∷ word (μ ∷ η ∷ δ ∷ ὲ ∷ ν ∷ []) "2Thess.3.11"
∷ word (ἐ ∷ ρ ∷ γ ∷ α ∷ ζ ∷ ο ∷ μ ∷ έ ∷ ν ∷ ο ∷ υ ∷ ς ∷ []) "2Thess.3.11"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "2Thess.3.11"
∷ word (π ∷ ε ∷ ρ ∷ ι ∷ ε ∷ ρ ∷ γ ∷ α ∷ ζ ∷ ο ∷ μ ∷ έ ∷ ν ∷ ο ∷ υ ∷ ς ∷ []) "2Thess.3.11"
∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "2Thess.3.12"
∷ word (δ ∷ ὲ ∷ []) "2Thess.3.12"
∷ word (τ ∷ ο ∷ ι ∷ ο ∷ ύ ∷ τ ∷ ο ∷ ι ∷ ς ∷ []) "2Thess.3.12"
∷ word (π ∷ α ∷ ρ ∷ α ∷ γ ∷ γ ∷ έ ∷ ∙λ ∷ ∙λ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.12"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.12"
∷ word (π ∷ α ∷ ρ ∷ α ∷ κ ∷ α ∷ ∙λ ∷ ο ∷ ῦ ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.12"
∷ word (ἐ ∷ ν ∷ []) "2Thess.3.12"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ῳ ∷ []) "2Thess.3.12"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "2Thess.3.12"
∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ῷ ∷ []) "2Thess.3.12"
∷ word (ἵ ∷ ν ∷ α ∷ []) "2Thess.3.12"
∷ word (μ ∷ ε ∷ τ ∷ ὰ ∷ []) "2Thess.3.12"
∷ word (ἡ ∷ σ ∷ υ ∷ χ ∷ ί ∷ α ∷ ς ∷ []) "2Thess.3.12"
∷ word (ἐ ∷ ρ ∷ γ ∷ α ∷ ζ ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "2Thess.3.12"
∷ word (τ ∷ ὸ ∷ ν ∷ []) "2Thess.3.12"
∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ῶ ∷ ν ∷ []) "2Thess.3.12"
∷ word (ἄ ∷ ρ ∷ τ ∷ ο ∷ ν ∷ []) "2Thess.3.12"
∷ word (ἐ ∷ σ ∷ θ ∷ ί ∷ ω ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.3.12"
∷ word (ὑ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "2Thess.3.13"
∷ word (δ ∷ έ ∷ []) "2Thess.3.13"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "2Thess.3.13"
∷ word (μ ∷ ὴ ∷ []) "2Thess.3.13"
∷ word (ἐ ∷ γ ∷ κ ∷ α ∷ κ ∷ ή ∷ σ ∷ η ∷ τ ∷ ε ∷ []) "2Thess.3.13"
∷ word (κ ∷ α ∷ ∙λ ∷ ο ∷ π ∷ ο ∷ ι ∷ ο ∷ ῦ ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "2Thess.3.13"
∷ word (Ε ∷ ἰ ∷ []) "2Thess.3.14"
∷ word (δ ∷ έ ∷ []) "2Thess.3.14"
∷ word (τ ∷ ι ∷ ς ∷ []) "2Thess.3.14"
∷ word (ο ∷ ὐ ∷ χ ∷ []) "2Thess.3.14"
∷ word (ὑ ∷ π ∷ α ∷ κ ∷ ο ∷ ύ ∷ ε ∷ ι ∷ []) "2Thess.3.14"
∷ word (τ ∷ ῷ ∷ []) "2Thess.3.14"
∷ word (∙λ ∷ ό ∷ γ ∷ ῳ ∷ []) "2Thess.3.14"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.3.14"
∷ word (δ ∷ ι ∷ ὰ ∷ []) "2Thess.3.14"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.3.14"
∷ word (ἐ ∷ π ∷ ι ∷ σ ∷ τ ∷ ο ∷ ∙λ ∷ ῆ ∷ ς ∷ []) "2Thess.3.14"
∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ ν ∷ []) "2Thess.3.14"
∷ word (σ ∷ η ∷ μ ∷ ε ∷ ι ∷ ο ∷ ῦ ∷ σ ∷ θ ∷ ε ∷ []) "2Thess.3.14"
∷ word (μ ∷ ὴ ∷ []) "2Thess.3.14"
∷ word (σ ∷ υ ∷ ν ∷ α ∷ ν ∷ α ∷ μ ∷ ί ∷ γ ∷ ν ∷ υ ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "2Thess.3.14"
∷ word (α ∷ ὐ ∷ τ ∷ ῷ ∷ []) "2Thess.3.14"
∷ word (ἵ ∷ ν ∷ α ∷ []) "2Thess.3.14"
∷ word (ἐ ∷ ν ∷ τ ∷ ρ ∷ α ∷ π ∷ ῇ ∷ []) "2Thess.3.14"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.15"
∷ word (μ ∷ ὴ ∷ []) "2Thess.3.15"
∷ word (ὡ ∷ ς ∷ []) "2Thess.3.15"
∷ word (ἐ ∷ χ ∷ θ ∷ ρ ∷ ὸ ∷ ν ∷ []) "2Thess.3.15"
∷ word (ἡ ∷ γ ∷ ε ∷ ῖ ∷ σ ∷ θ ∷ ε ∷ []) "2Thess.3.15"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "2Thess.3.15"
∷ word (ν ∷ ο ∷ υ ∷ θ ∷ ε ∷ τ ∷ ε ∷ ῖ ∷ τ ∷ ε ∷ []) "2Thess.3.15"
∷ word (ὡ ∷ ς ∷ []) "2Thess.3.15"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ό ∷ ν ∷ []) "2Thess.3.15"
∷ word (Α ∷ ὐ ∷ τ ∷ ὸ ∷ ς ∷ []) "2Thess.3.16"
∷ word (δ ∷ ὲ ∷ []) "2Thess.3.16"
∷ word (ὁ ∷ []) "2Thess.3.16"
∷ word (κ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ς ∷ []) "2Thess.3.16"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.3.16"
∷ word (ε ∷ ἰ ∷ ρ ∷ ή ∷ ν ∷ η ∷ ς ∷ []) "2Thess.3.16"
∷ word (δ ∷ ῴ ∷ η ∷ []) "2Thess.3.16"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "2Thess.3.16"
∷ word (τ ∷ ὴ ∷ ν ∷ []) "2Thess.3.16"
∷ word (ε ∷ ἰ ∷ ρ ∷ ή ∷ ν ∷ η ∷ ν ∷ []) "2Thess.3.16"
∷ word (δ ∷ ι ∷ ὰ ∷ []) "2Thess.3.16"
∷ word (π ∷ α ∷ ν ∷ τ ∷ ὸ ∷ ς ∷ []) "2Thess.3.16"
∷ word (ἐ ∷ ν ∷ []) "2Thess.3.16"
∷ word (π ∷ α ∷ ν ∷ τ ∷ ὶ ∷ []) "2Thess.3.16"
∷ word (τ ∷ ρ ∷ ό ∷ π ∷ ῳ ∷ []) "2Thess.3.16"
∷ word (ὁ ∷ []) "2Thess.3.16"
∷ word (κ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ς ∷ []) "2Thess.3.16"
∷ word (μ ∷ ε ∷ τ ∷ ὰ ∷ []) "2Thess.3.16"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ ω ∷ ν ∷ []) "2Thess.3.16"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.3.16"
∷ word (Ὁ ∷ []) "2Thess.3.17"
∷ word (ἀ ∷ σ ∷ π ∷ α ∷ σ ∷ μ ∷ ὸ ∷ ς ∷ []) "2Thess.3.17"
∷ word (τ ∷ ῇ ∷ []) "2Thess.3.17"
∷ word (ἐ ∷ μ ∷ ῇ ∷ []) "2Thess.3.17"
∷ word (χ ∷ ε ∷ ι ∷ ρ ∷ ὶ ∷ []) "2Thess.3.17"
∷ word (Π ∷ α ∷ ύ ∷ ∙λ ∷ ο ∷ υ ∷ []) "2Thess.3.17"
∷ word (ὅ ∷ []) "2Thess.3.17"
∷ word (ἐ ∷ σ ∷ τ ∷ ι ∷ ν ∷ []) "2Thess.3.17"
∷ word (σ ∷ η ∷ μ ∷ ε ∷ ῖ ∷ ο ∷ ν ∷ []) "2Thess.3.17"
∷ word (ἐ ∷ ν ∷ []) "2Thess.3.17"
∷ word (π ∷ ά ∷ σ ∷ ῃ ∷ []) "2Thess.3.17"
∷ word (ἐ ∷ π ∷ ι ∷ σ ∷ τ ∷ ο ∷ ∙λ ∷ ῇ ∷ []) "2Thess.3.17"
∷ word (ο ∷ ὕ ∷ τ ∷ ω ∷ ς ∷ []) "2Thess.3.17"
∷ word (γ ∷ ρ ∷ ά ∷ φ ∷ ω ∷ []) "2Thess.3.17"
∷ word (ἡ ∷ []) "2Thess.3.18"
∷ word (χ ∷ ά ∷ ρ ∷ ι ∷ ς ∷ []) "2Thess.3.18"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.3.18"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.3.18"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.3.18"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "2Thess.3.18"
∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.3.18"
∷ word (μ ∷ ε ∷ τ ∷ ὰ ∷ []) "2Thess.3.18"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ ω ∷ ν ∷ []) "2Thess.3.18"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.3.18"
∷ []
| 46.868833
| 91
| 0.369518
|
1caea53527969f970c7ce4a1da2e1164ca814a02
| 1,838
|
agda
|
Agda
|
test/Succeed/Issue795.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue795.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue795.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- {-# OPTIONS -v tc.term.args:30 -v tc.meta:50 #-}
module Issue795 where
data Q (A : Set) : Set where
F : (N : Set → Set) → Set₁
F N = (A : Set) → N (Q A) → N A
postulate
N : Set → Set
f : F N
R : (N : Set → Set) → Set
funny-term : ∀ N → (f : F N) → R N
-- This should work now: WAS: "Refuse to construct infinite term".
thing : R N
thing = funny-term _ (λ A → f _)
-- funny-term ?N : F ?N -> R ?N
-- funny-term ?N : ((A : Set) -> ?N (Q A) -> ?N A) -> R ?N
-- A : F ?N |- f (?A A) :=> ?N (Q (?A A)) -> ?N (?A A)
-- |- λ A → f (?A A) <=: (A : Set) -> N (Q A) -> N A
{- What is happening here?
Agda first creates a (closed) meta variable
?N : Set -> Set
Then it checks
λ A → f ? against type F ?N = (A : Set) -> ?N (Q A) -> ?N A
(After what it does now, it still needs to check that
R ?N is a subtype of R N
It would be smart if that was done first.)
In context A : Set, continues to check
f ? against type ?N (Q A) -> ?N A
Since the type of f is F N = (A : Set) -> N (Q A) -> N A, the created meta,
dependent on A : Set is
?A : Set -> Set
and we are left with checking that the inferred type of f (?A A),
N (Q (?A A)) -> N (?A A)
is a subtype of
?N (Q A) -> ?N A
This yields two equations
?N (Q A) = N (Q (?A A))
?N A = N (?A A)
The second one is solved as
?N = λ z → N (?A z)
simpliying the remaining equation to
N (?A (Q A)) = N (Q (?A A))
and further to
?A (Q A) = Q (?A A)
The expected solution is, of course, the identity, but it cannot be
found mechanically from this equation.
At this point, another solution is ?A = Q.
In general, any power of Q is a solution.
If Agda postponed here, it would come to the problem
R ?N = R N
simplified to ?N = N and instantiated to
λ z → N (?A z) = N
This would solve ?A to be the identity.
-}
| 20.197802
| 75
| 0.555495
|
29c40d6569aa11b859be9bd7563ff1ced9700cc6
| 1,615
|
agda
|
Agda
|
Cubical/Data/HomotopyGroup/Base.agda
|
maxdore/cubical
|
ef62b84397396d48135d73ba7400b71c721ddc94
|
[
"MIT"
] | null | null | null |
Cubical/Data/HomotopyGroup/Base.agda
|
maxdore/cubical
|
ef62b84397396d48135d73ba7400b71c721ddc94
|
[
"MIT"
] | null | null | null |
Cubical/Data/HomotopyGroup/Base.agda
|
maxdore/cubical
|
ef62b84397396d48135d73ba7400b71c721ddc94
|
[
"MIT"
] | 1
|
2021-03-12T20:08:45.000Z
|
2021-03-12T20:08:45.000Z
|
{-# OPTIONS --safe #-}
module Cubical.Data.HomotopyGroup.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
import Cubical.Foundations.GroupoidLaws as GL
open import Cubical.Foundations.Pointed
open import Cubical.Data.Nat
open import Cubical.Algebra.Group
open import Cubical.Homotopy.Loopspace
open import Cubical.HITs.SetTruncation as SetTrunc
π^_ : ∀ {ℓ} → ℕ → Pointed ℓ → Group ℓ
π^_ {ℓ} n p = makeGroup e _⨀_ _⁻¹ setTruncIsSet assoc rUnit lUnit rCancel lCancel
where
n' : ℕ
n' = suc n
A : Type ℓ
A = typ ((Ω^ n') p)
e : ∥ A ∥₂
e = ∣ pt ((Ω^ n') p) ∣₂
_⁻¹ : ∥ A ∥₂ → ∥ A ∥₂
_⁻¹ = SetTrunc.elim {B = λ _ → ∥ A ∥₂} (λ x → squash₂) λ a → ∣ sym a ∣₂
_⨀_ : ∥ A ∥₂ → ∥ A ∥₂ → ∥ A ∥₂
_⨀_ = SetTrunc.elim2 (λ _ _ → squash₂) λ a₀ a₁ → ∣ a₀ ∙ a₁ ∣₂
lUnit : (a : ∥ A ∥₂) → (e ⨀ a) ≡ a
lUnit = SetTrunc.elim (λ _ → isProp→isSet (squash₂ _ _))
(λ a → cong ∣_∣₂ (sym (GL.lUnit a) ))
rUnit : (a : ∥ A ∥₂) → a ⨀ e ≡ a
rUnit = SetTrunc.elim (λ _ → isProp→isSet (squash₂ _ _))
(λ a → cong ∣_∣₂ (sym (GL.rUnit a) ))
assoc : (a b c : ∥ A ∥₂) → a ⨀ (b ⨀ c) ≡ (a ⨀ b) ⨀ c
assoc = SetTrunc.elim3 (λ _ _ _ → isProp→isSet (squash₂ _ _))
(λ a b c → cong ∣_∣₂ (GL.assoc _ _ _))
lCancel : (a : ∥ A ∥₂) → ((a ⁻¹) ⨀ a) ≡ e
lCancel = SetTrunc.elim (λ _ → isProp→isSet (squash₂ _ _))
λ a → cong ∣_∣₂ (GL.lCancel _)
rCancel : (a : ∥ A ∥₂) → (a ⨀ (a ⁻¹)) ≡ e
rCancel = SetTrunc.elim (λ _ → isProp→isSet (squash₂ _ _))
λ a → cong ∣_∣₂ (GL.rCancel _)
| 30.471698
| 81
| 0.548607
|
2fd053889e58887a3b3e85bfb52e4e88f013a3f0
| 5,436
|
agda
|
Agda
|
Cubical/Algebra/Ring/Properties.agda
|
knrafto/cubical
|
f6771617374bfe65a7043d00731fed5a673aa729
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/Ring/Properties.agda
|
knrafto/cubical
|
f6771617374bfe65a7043d00731fed5a673aa729
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/Ring/Properties.agda
|
knrafto/cubical
|
f6771617374bfe65a7043d00731fed5a673aa729
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Algebra.Ring.Properties 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.Univalence
open import Cubical.Foundations.Transport
open import Cubical.Foundations.SIP
open import Cubical.Data.Sigma
open import Cubical.Structures.Axioms
open import Cubical.Structures.Auto
open import Cubical.Structures.Macro
open import Cubical.Algebra.Semigroup hiding (⟨_⟩)
open import Cubical.Algebra.Monoid hiding (⟨_⟩)
open import Cubical.Algebra.AbGroup hiding (⟨_⟩)
open import Cubical.Algebra.Ring.Base
private
variable
ℓ : Level
{-
some basic calculations (used for example in QuotientRing.agda),
that should become obsolete or subject to change once we have a
ring solver (see https://github.com/agda/cubical/issues/297)
-}
module Theory (R' : Ring {ℓ}) where
open Ring R' renaming ( Carrier to R )
implicitInverse : (x y : R)
→ x + y ≡ 0r
→ y ≡ - x
implicitInverse x y p =
y ≡⟨ sym (+-lid y) ⟩
0r + y ≡⟨ cong (λ u → u + y) (sym (+-linv x)) ⟩
(- x + x) + y ≡⟨ sym (+-assoc _ _ _) ⟩
(- x) + (x + y) ≡⟨ cong (λ u → (- x) + u) p ⟩
(- x) + 0r ≡⟨ +-rid _ ⟩
- x ∎
0-selfinverse : - 0r ≡ 0r
0-selfinverse = sym (implicitInverse _ _ (+-rid 0r))
0-idempotent : 0r + 0r ≡ 0r
0-idempotent = +-lid 0r
+-idempotency→0 : (x : R) → x ≡ x + x → 0r ≡ x
+-idempotency→0 x p =
0r ≡⟨ sym (+-rinv _) ⟩
x + (- x) ≡⟨ cong (λ u → u + (- x)) p ⟩
(x + x) + (- x) ≡⟨ sym (+-assoc _ _ _) ⟩
x + (x + (- x)) ≡⟨ cong (λ u → x + u) (+-rinv _) ⟩
x + 0r ≡⟨ +-rid x ⟩
x ∎
0-rightNullifies : (x : R) → x · 0r ≡ 0r
0-rightNullifies x =
let x·0-is-idempotent : x · 0r ≡ x · 0r + x · 0r
x·0-is-idempotent =
x · 0r ≡⟨ cong (λ u → x · u) (sym 0-idempotent) ⟩
x · (0r + 0r) ≡⟨ ·-rdist-+ _ _ _ ⟩
(x · 0r) + (x · 0r) ∎
in sym (+-idempotency→0 _ x·0-is-idempotent)
0-leftNullifies : (x : R) → 0r · x ≡ 0r
0-leftNullifies x =
let 0·x-is-idempotent : 0r · x ≡ 0r · x + 0r · x
0·x-is-idempotent =
0r · x ≡⟨ cong (λ u → u · x) (sym 0-idempotent) ⟩
(0r + 0r) · x ≡⟨ ·-ldist-+ _ _ _ ⟩
(0r · x) + (0r · x) ∎
in sym (+-idempotency→0 _ 0·x-is-idempotent)
-commutesWithRight-· : (x y : R) → x · (- y) ≡ - (x · y)
-commutesWithRight-· x y = implicitInverse (x · y) (x · (- y))
(x · y + x · (- y) ≡⟨ sym (·-rdist-+ _ _ _) ⟩
x · (y + (- y)) ≡⟨ cong (λ u → x · u) (+-rinv y) ⟩
x · 0r ≡⟨ 0-rightNullifies x ⟩
0r ∎)
-commutesWithLeft-· : (x y : R) → (- x) · y ≡ - (x · y)
-commutesWithLeft-· x y = implicitInverse (x · y) ((- x) · y)
(x · y + (- x) · y ≡⟨ sym (·-ldist-+ _ _ _) ⟩
(x - x) · y ≡⟨ cong (λ u → u · y) (+-rinv x) ⟩
0r · y ≡⟨ 0-leftNullifies y ⟩
0r ∎)
-isDistributive : (x y : R) → (- x) + (- y) ≡ - (x + y)
-isDistributive x y =
implicitInverse _ _
((x + y) + ((- x) + (- y)) ≡⟨ sym (+-assoc _ _ _) ⟩
x + (y + ((- x) + (- y))) ≡⟨ cong
(λ u → x + (y + u))
(+-comm _ _) ⟩
x + (y + ((- y) + (- x))) ≡⟨ cong (λ u → x + u) (+-assoc _ _ _) ⟩
x + ((y + (- y)) + (- x)) ≡⟨ cong (λ u → x + (u + (- x)))
(+-rinv _) ⟩
x + (0r + (- x)) ≡⟨ cong (λ u → x + u) (+-lid _) ⟩
x + (- x) ≡⟨ +-rinv _ ⟩
0r ∎)
translatedDifference : (x a b : R) → a - b ≡ (x + a) - (x + b)
translatedDifference x a b =
a - b ≡⟨ cong (λ u → a + u)
(sym (+-lid _)) ⟩
(a + (0r + (- b))) ≡⟨ cong (λ u → a + (u + (- b)))
(sym (+-rinv _)) ⟩
(a + ((x + (- x)) + (- b))) ≡⟨ cong (λ u → a + u)
(sym (+-assoc _ _ _)) ⟩
(a + (x + ((- x) + (- b)))) ≡⟨ (+-assoc _ _ _) ⟩
((a + x) + ((- x) + (- b))) ≡⟨ cong (λ u → u + ((- x) + (- b)))
(+-comm _ _) ⟩
((x + a) + ((- x) + (- b))) ≡⟨ cong (λ u → (x + a) + u)
(-isDistributive _ _) ⟩
((x + a) - (x + b)) ∎
+-assoc-comm1 : (x y z : R) → x + (y + z) ≡ y + (x + z)
+-assoc-comm1 x y z = +-assoc x y z ∙∙ cong (λ x → x + z) (+-comm x y) ∙∙ sym (+-assoc y x z)
+-assoc-comm2 : (x y z : R) → x + (y + z) ≡ z + (y + x)
+-assoc-comm2 x y z = +-assoc-comm1 x y z ∙∙ cong (λ x → y + x) (+-comm x z) ∙∙ +-assoc-comm1 y z x
| 41.815385
| 101
| 0.392752
|
c5aaea1a9a142a73766ad5b5d0d72c03564f899b
| 5,858
|
agda
|
Agda
|
src/Extensions/List.agda
|
metaborg/ts.agda
|
7fe638b87de26df47b6437f5ab0a8b955384958d
|
[
"MIT"
] | null | null | null |
src/Extensions/List.agda
|
metaborg/ts.agda
|
7fe638b87de26df47b6437f5ab0a8b955384958d
|
[
"MIT"
] | null | null | null |
src/Extensions/List.agda
|
metaborg/ts.agda
|
7fe638b87de26df47b6437f5ab0a8b955384958d
|
[
"MIT"
] | null | null | null |
module Extensions.List where
open import Prelude
open import Data.List
open import Data.Fin using (fromℕ≤; zero; suc)
open import Data.List.All hiding (lookup; map)
open import Data.Maybe hiding (All; map)
open import Relation.Nullary
open import Relation.Nullary.Decidable using (map′)
open import Relation.Binary.Core using (REL; Reflexive; Transitive)
open import Relation.Binary.List.Pointwise hiding (refl; map)
data _[_]=_ {a} {A : Set a} : List A → ℕ → A → Set where
here : ∀ {x xs} → (x ∷ xs) [ 0 ]= x
there : ∀ {x y xs n} → xs [ n ]= x → (y ∷ xs) [ suc n ]= x
[]=-functional : ∀ {a} {A : Set a} → (l : List A) → (i : ℕ) →
∀ {x y : A} → l [ i ]= x → l [ i ]= y → x ≡ y
[]=-functional .(_ ∷ _) .0 here here = refl
[]=-functional .(_ ∷ _) .(suc _) (there p) (there q) = []=-functional _ _ p q
[]=-map : ∀ {a b}{A : Set a}{B : Set b}{l : List A}{i x}{f : A → B} →
l [ i ]= x → (map f l) [ i ]= (f x)
[]=-map here = here
[]=-map (there p) = there ([]=-map p)
maybe-lookup : ∀ {a}{A : Set a} → ℕ → List A → Maybe A
maybe-lookup n [] = nothing
maybe-lookup zero (x ∷ μ) = just x
maybe-lookup (suc n) (x ∷ μ) = maybe-lookup n μ
maybe-lookup-safe : ∀ {a}{A : Set a}{l : List A} {i x} → l [ i ]= x → maybe-lookup i l ≡ just x
maybe-lookup-safe here = refl
maybe-lookup-safe (there p) = maybe-lookup-safe p
lookup : ∀ {a} {A : Set a} → (l : List A) → Fin (length l) → A
lookup [] ()
lookup (x ∷ l) zero = x
lookup (x ∷ l) (suc p) = lookup l p
dec-lookup : ∀ {a} {A : Set a} → (i : ℕ) → (l : List A) → Dec (∃ λ x → l [ i ]= x)
dec-lookup _ [] = no (λ{ (_ , ())})
dec-lookup zero (x ∷ l) = yes (x , here)
dec-lookup (suc i) (_ ∷ l) = map′
(λ{ (x , p) → x , there p})
(λ{ (x , there p) → x , p})
(dec-lookup i l)
all-lookup : ∀ {a} {A : Set a} {l : List A} {i x p P} → l [ i ]= x → All {p = p} P l → P x
all-lookup here (px ∷ l) = px
all-lookup (there i) (px ∷ l) = all-lookup i l
infixl 10 _[_]≔_
_[_]≔_ : ∀ {a} {A : Set a} → (l : List A) → Fin (length l) → A → List A
[] [ () ]≔ x
(x ∷ xs) [ zero ]≔ x' = x' ∷ xs
(x ∷ xs) [ suc i ]≔ y = xs [ i ]≔ y
module _ where
open import Data.List.Any
open Membership-≡
_[_]≔'_ : ∀ {a} {A : Set a}{x} → (l : List A) → x ∈ l → A → List A
[] [ () ]≔' y
(x ∷ l) [ here px ]≔' y = y ∷ l
(x ∷ l) [ there px ]≔' y = x ∷ (l [ px ]≔' y)
≔'-[]= : ∀ {a} {A : Set a}{x}{l : List A} (p : x ∈ l) → ∀ {y} → y ∈ (l [ p ]≔' y)
≔'-[]= (here px) = here refl
≔'-[]= (there p) = there (≔'-[]= p)
-- proof matters; update a particular witness of a property
_All[_]≔_ : ∀ {a p} {A : Set a} {P : A → Set p} {xs : List A} {i x} →
All P xs → xs [ i ]= x → P x → All P xs
[] All[ () ]≔ px
(px ∷ xs) All[ here ]≔ px' = px' ∷ xs
(px ∷ xs) All[ there i ]≔ px' = px ∷ (xs All[ i ]≔ px')
-- prefix predicate for lists
infix 4 _⊑_
data _⊑_ {a} {A : Set a} : List A → List A → Set where
[] : ∀ {ys} → [] ⊑ ys
_∷_ : ∀ x {xs ys} → xs ⊑ ys → x ∷ xs ⊑ x ∷ ys
⊑-refl : ∀ {a} {A : Set a} → Reflexive (_⊑_ {A = A})
⊑-refl {x = []} = []
⊑-refl {x = x ∷ xs} = x ∷ ⊑-refl
⊑-trans : ∀ {a} {A : Set a} → Transitive (_⊑_ {A = A})
⊑-trans [] _ = []
⊑-trans (x ∷ p) (.x ∷ q) = x ∷ ⊑-trans p q
-- list extensions; reverse prefix relation
infix 4 _⊒_
_⊒_ : ∀ {a} {A : Set a} → List A → List A → Set
xs ⊒ ys = ys ⊑ xs
-- appending to a list gives a list extension;
-- or, appending to a list makes the original a prefix
∷ʳ-⊒ : ∀ {a} {A : Set a} (x : A) xs → xs ∷ʳ x ⊒ xs
∷ʳ-⊒ x [] = []
∷ʳ-⊒ x (x₁ ∷ Σ₁) = x₁ ∷ (∷ʳ-⊒ x Σ₁)
-- indexes into a prefix point to the same element in extensions
xs⊒ys[i] : ∀ {a} {A : Set a} {xs : List A} {ys : List A} {i y} →
xs [ i ]= y → (p : ys ⊒ xs) → ys [ i ]= y
xs⊒ys[i] here (x ∷ q) = here
xs⊒ys[i] (there p) (x ∷ q) = there (xs⊒ys[i] p q)
-- prefix is preserved by map
⊑-map : ∀ {a b} {A : Set a} {B : Set b} {xs ys : List A} {f : A → B} →
xs ⊑ ys → map f xs ⊑ map f ys
⊑-map [] = []
⊑-map {f = f} (x ∷ p) = f x ∷ (⊑-map p)
module Pointwise where
pointwise-length : ∀ {a b ℓ A B P l m} → Rel {a} {b} {ℓ} {A} {B} P l m → length l ≡ length m
pointwise-length [] = refl
pointwise-length (x∼y ∷ p) = cong suc (pointwise-length p)
[]=-length : ∀ {a} {A : Set a} {L : List A} {i x} → L [ i ]= x → i < length L
[]=-length here = s≤s z≤n
[]=-length (there p) = s≤s ([]=-length p)
∷ʳ[length] : ∀ {a} {A : Set a} (l : List A) x → (l ∷ʳ x) [ length l ]= x
∷ʳ[length] [] y = here
∷ʳ[length] (x ∷ Σ) y = there (∷ʳ[length] Σ y)
all-∷ʳ : ∀ {a p} {A : Set a} {l : List A} {x} {P : A → Set p} → All P l → P x → All P (l ∷ʳ x)
all-∷ʳ [] q = q ∷ []
all-∷ʳ (px ∷ p) q = px ∷ (all-∷ʳ p q)
pointwise-∷ʳ : ∀ {a b ℓ A B P l m x y} → Rel {a} {b} {ℓ} {A} {B} P l m → P x y →
Rel {a} {b} {ℓ} {A} {B} P (l ∷ʳ x) (m ∷ʳ y)
pointwise-∷ʳ [] q = q ∷ []
pointwise-∷ʳ (x∼y ∷ p) q = x∼y ∷ (pointwise-∷ʳ p q)
pointwise-lookup : ∀ {a b ℓ A B P l m i x} → Rel {a} {b} {ℓ} {A} {B} P l m →
l [ i ]= x → ∃ λ y → P x y
pointwise-lookup (x∼y ∷ r) here = , x∼y
pointwise-lookup (x∼y ∷ r) (there p) = pointwise-lookup r p
pointwise-maybe-lookup : ∀ {a b ℓ A B P l m i x} → Rel {a} {b} {ℓ} {A} {B} P l m →
l [ i ]= x → ∃ λ y → maybe-lookup i m ≡ just y × P x y
pointwise-maybe-lookup [] ()
pointwise-maybe-lookup (x∼y ∷ r) here = , refl , x∼y
pointwise-maybe-lookup (x∼y ∷ r) (there p) = pointwise-maybe-lookup r p
postulate
pointwise-[]≔ : ∀ {a b ℓ A B P l m i x y} →
Rel {a} {b} {ℓ} {A} {B} P l m → (p : l [ i ]= x) → (q : i < length m) → P x y →
Rel {a} {b} {ℓ} {A} {B} P l (m [ fromℕ≤ q ]≔ y)
{-}
pointwise-[]≔ [] () r
pointwise-[]≔ (x∼y ∷ r) here (s≤s z≤n) z = z ∷ r
pointwise-[]≔ (x∼y ∷ r) (there p) (s≤s q) z = subst (λ x → Rel _ _ x) {!!} (x∼y ∷ pointwise-[]≔ r p q z)
-}
open Pointwise public
| 36.385093
| 107
| 0.481564
|
29e59f1f76608bccd33b807f34e5df51a82c822f
| 520
|
agda
|
Agda
|
Cubical/Algebra/CommRing/Integers.agda
|
maxdore/cubical
|
ef62b84397396d48135d73ba7400b71c721ddc94
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/CommRing/Integers.agda
|
maxdore/cubical
|
ef62b84397396d48135d73ba7400b71c721ddc94
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/CommRing/Integers.agda
|
maxdore/cubical
|
ef62b84397396d48135d73ba7400b71c721ddc94
|
[
"MIT"
] | 1
|
2021-03-12T20:08:45.000Z
|
2021-03-12T20:08:45.000Z
|
{-# OPTIONS --safe #-}
module Cubical.Algebra.CommRing.Integers where
open import Cubical.Foundations.Prelude
open import Cubical.Algebra.CommRing
open import Cubical.HITs.Ints.BiInvInt
renaming (
_+_ to _+ℤ_;
-_ to _-ℤ_;
+-assoc to +ℤ-assoc;
+-comm to +ℤ-comm
)
BiInvIntAsCommRing : CommRing ℓ-zero
BiInvIntAsCommRing =
makeCommRing
zero (suc zero) _+ℤ_ _·_ _-ℤ_
isSetBiInvInt
+ℤ-assoc +-zero +-invʳ +ℤ-comm
·-assoc ·-identityʳ
(λ x y z → sym (·-distribˡ x y z))
·-comm
| 21.666667
| 46
| 0.663462
|
50b915177c809cd12b69c0196d24cc00e2885236
| 1,229
|
agda
|
Agda
|
Structure/Category/NaturalTransformation/Equiv.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | 6
|
2020-04-07T17:58:13.000Z
|
2022-02-05T06:53:22.000Z
|
Structure/Category/NaturalTransformation/Equiv.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
Structure/Category/NaturalTransformation/Equiv.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
module Structure.Category.NaturalTransformation.Equiv where
import Function.Equals
open Function.Equals.Dependent
import Lvl
open import Logic
open import Logic.Predicate
open import Structure.Category
open import Structure.Category.Functor
open import Structure.Category.NaturalTransformation
open import Structure.Setoid
open import Structure.Relator.Equivalence
open import Structure.Relator.Properties
open import Type
module _
{ℓₗₒ ℓₗₘ ℓₗₑ ℓᵣₒ ℓᵣₘ ℓᵣₑ}
{catₗ : CategoryObject{ℓₗₒ}{ℓₗₘ}{ℓₗₑ}}
{catᵣ : CategoryObject{ℓᵣₒ}{ℓᵣₘ}{ℓᵣₑ}}
{F₁ : catₗ →ᶠᵘⁿᶜᵗᵒʳ catᵣ}
{F₂ : catₗ →ᶠᵘⁿᶜᵗᵒʳ catᵣ}
where
_≡ᴺᵀ_ : (F₁ →ᴺᵀ F₂) → (F₁ →ᴺᵀ F₂) → Stmt
[∃]-intro N₁ ≡ᴺᵀ [∃]-intro N₂ = N₁ ⊜ N₂
instance
[≡ᴺᵀ]-reflexivity : Reflexivity(_≡ᴺᵀ_)
Reflexivity.proof [≡ᴺᵀ]-reflexivity = reflexivity(_⊜_)
instance
[≡ᴺᵀ]-symmetry : Symmetry(_≡ᴺᵀ_)
Symmetry.proof [≡ᴺᵀ]-symmetry = symmetry(_⊜_)
instance
[≡ᴺᵀ]-transitivity : Transitivity(_≡ᴺᵀ_)
Transitivity.proof [≡ᴺᵀ]-transitivity = transitivity(_⊜_)
instance
[≡ᴺᵀ]-equivalence : Equivalence(_≡ᴺᵀ_)
[≡ᴺᵀ]-equivalence = intro
instance
[→ᴺᵀ]-equiv : Equiv(F₁ →ᴺᵀ F₂)
[→ᴺᵀ]-equiv = intro(_≡ᴺᵀ_) ⦃ [≡ᴺᵀ]-equivalence ⦄
| 26.148936
| 61
| 0.70057
|
29d8ea9310c99795cfde7ce2d245a4681a3aa6e2
| 2,335
|
agda
|
Agda
|
test/LibSucceed/Issue1382.agda
|
zgrannan/agda
|
5953ce337eb6b77b29ace7180478f49c541aea1c
|
[
"BSD-3-Clause"
] | null | null | null |
test/LibSucceed/Issue1382.agda
|
zgrannan/agda
|
5953ce337eb6b77b29ace7180478f49c541aea1c
|
[
"BSD-3-Clause"
] | null | null | null |
test/LibSucceed/Issue1382.agda
|
zgrannan/agda
|
5953ce337eb6b77b29ace7180478f49c541aea1c
|
[
"BSD-3-Clause"
] | null | null | null |
{-# OPTIONS --allow-unsolved-metas #-}
-- Andreas, 2014-12-06
-- Reported by sanzhiyan, Dec 4 2014
open import Data.Vec
open import Data.Fin
open import Data.Nat renaming (_+_ to _+N_)
open import Data.Nat.Solver
open import Relation.Binary.PropositionalEquality hiding ([_])
open +-*-Solver using (prove; solve; _:=_; con; var; _:+_; _:*_; :-_; _:-_)
data prop : Set where
F T : prop
_∧_ _∨_ : prop → prop → prop
infixl 4 _∧_ _∨_
Γ : (n : ℕ) → Set
Γ n = Vec prop n
infix 1 _⊢_
data _⊢_ : ∀ {n} → Γ n → prop → Set where
hyp : ∀ {n}(C : Γ n)(v : Fin n) → C ⊢ (lookup v C)
andI : ∀ {n}{C : Γ n}{p p' : prop} → C ⊢ p → C ⊢ p' → C ⊢ p ∧ p'
andEL : ∀ {n}{C : Γ n}{p p' : prop} → C ⊢ p ∧ p' → C ⊢ p
andER : ∀ {n}{C : Γ n}{p p' : prop} → C ⊢ p ∧ p' → C ⊢ p'
orIL : ∀ {n}{C : Γ n}{p : prop}(p' : prop) → C ⊢ p → C ⊢ p ∨ p'
orIR : ∀ {n}{C : Γ n}{p' : prop}(p : prop) → C ⊢ p' → C ⊢ p ∨ p'
orE : ∀ {n}{C : Γ n}{p p' c : prop} → C ⊢ p ∨ p' → p ∷ C ⊢ c → p' ∷ C ⊢ c → C ⊢ c
-- WAS:
-- The first two _ could not be solved before today's (2014-12-06) improvement of pruning.
-- Except for variables, they were applied to a huge neutral proof term coming from the ring solver.
-- Agda could not prune before the improved neutrality check implemented by Andrea(s) 2014-12-05/06.
--
-- As a consequence, Agda would often reattempt solving, each time doing the expensive
-- occurs check. This would extremely slow down Agda.
weakening : ∀ {n m p p'}(C : Γ n)(C' : Γ m) → C ++ C' ⊢ p → C ++ [ p' ] ++ C' ⊢ p
weakening {n} {m} {p' = p'} C C' (hyp .(C ++ C') v) = subst (λ R → C ++ (_ ∷ C') ⊢ R) {!!}
(hyp (C ++ (_ ∷ C')) (subst (λ x → Fin x) proof (inject₁ v))) where
proof : suc (n +N m) ≡ n +N suc m
proof = (solve 2 (λ n₁ m₁ → con 1 :+ (n₁ :+ m₁) := n₁ :+ (con 1 :+ m₁)) refl n m)
weakening C C' (andI prf prf') = andI (weakening C C' prf) (weakening C C' prf')
weakening C C' (andEL prf) = andEL (weakening C C' prf)
weakening C C' (andER prf) = andER (weakening C C' prf)
weakening C C' (orIL p'' prf) = orIL p'' (weakening C C' prf)
weakening C C' (orIR p prf) = orIR p (weakening C C' prf)
weakening C C' (orE prf prf₁ prf₂) = orE (weakening C C' prf) (weakening (_ ∷ C) C' prf₁) (weakening (_ ∷ C) C' prf₂)
-- Should check fast now and report the ? as unsolved meta.
| 43.240741
| 117
| 0.558887
|
2f3805f23dd84ddd28698077701ff78be93f28cc
| 63,312
|
agda
|
Agda
|
agda-stdlib/src/Data/Integer/Properties.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/src/Data/Integer/Properties.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Data/Integer/Properties.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Some properties about integers
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
-- Disabled to prevent warnings from deprecated names
{-# OPTIONS --warn=noUserWarning #-}
module Data.Integer.Properties where
open import Algebra.Bundles
import Algebra.Morphism as Morphism
import Algebra.Properties.AbelianGroup
open import Data.Integer.Base renaming (suc to sucℤ)
open import Data.Nat as ℕ
using (ℕ; suc; zero; _∸_; s≤s; z≤n)
hiding (module ℕ)
import Data.Nat.Properties as ℕₚ
open import Data.Nat.Solver
open import Data.Product using (proj₁; proj₂; _,_)
open import Data.Sum.Base as Sum using (inj₁; inj₂)
open import Data.Sign as Sign using () renaming (_*_ to _𝕊*_)
import Data.Sign.Properties as 𝕊ₚ
open import Function using (_∘_; _$_)
open import Level using (0ℓ)
open import Relation.Binary
open import Relation.Binary.PropositionalEquality
open import Relation.Nullary using (yes; no)
open import Relation.Nullary.Negation using (contradiction)
import Relation.Nullary.Decidable as Dec
open import Algebra.Definitions {A = ℤ} _≡_
open import Algebra.FunctionProperties.Consequences.Propositional
open import Algebra.Structures {A = ℤ} _≡_
module ℤtoℕ = Morphism.Definitions ℤ ℕ _≡_
module ℕtoℤ = Morphism.Definitions ℕ ℤ _≡_
open +-*-Solver
------------------------------------------------------------------------
-- Equality
------------------------------------------------------------------------
+-injective : ∀ {m n} → + m ≡ + n → m ≡ n
+-injective refl = refl
-[1+-injective : ∀ {m n} → -[1+ m ] ≡ -[1+ n ] → m ≡ n
-[1+-injective refl = refl
+[1+-injective : ∀ {m n} → +[1+ m ] ≡ +[1+ n ] → m ≡ n
+[1+-injective refl = refl
infix 4 _≟_
_≟_ : Decidable {A = ℤ} _≡_
+ m ≟ + n = Dec.map′ (cong (+_)) +-injective (m ℕ.≟ n)
+ m ≟ -[1+ n ] = no λ()
-[1+ m ] ≟ + n = no λ()
-[1+ m ] ≟ -[1+ n ] = Dec.map′ (cong -[1+_]) -[1+-injective (m ℕ.≟ n)
≡-setoid : Setoid 0ℓ 0ℓ
≡-setoid = setoid ℤ
≡-decSetoid : DecSetoid 0ℓ 0ℓ
≡-decSetoid = decSetoid _≟_
------------------------------------------------------------------------
-- Properties of _≤_
------------------------------------------------------------------------
drop‿+≤+ : ∀ {m n} → + m ≤ + n → m ℕ.≤ n
drop‿+≤+ (+≤+ m≤n) = m≤n
drop‿-≤- : ∀ {m n} → -[1+ m ] ≤ -[1+ n ] → n ℕ.≤ m
drop‿-≤- (-≤- n≤m) = n≤m
------------------------------------------------------------------------
-- Relational properties
≤-reflexive : _≡_ ⇒ _≤_
≤-reflexive { -[1+ n ]} refl = -≤- ℕₚ.≤-refl
≤-reflexive {+ n} refl = +≤+ ℕₚ.≤-refl
≤-refl : Reflexive _≤_
≤-refl = ≤-reflexive refl
≤-trans : Transitive _≤_
≤-trans -≤+ (+≤+ n≤m) = -≤+
≤-trans (-≤- n≤m) -≤+ = -≤+
≤-trans (-≤- n≤m) (-≤- k≤n) = -≤- (ℕₚ.≤-trans k≤n n≤m)
≤-trans (+≤+ m≤n) (+≤+ n≤k) = +≤+ (ℕₚ.≤-trans m≤n n≤k)
≤-antisym : Antisymmetric _≡_ _≤_
≤-antisym (-≤- n≤m) (-≤- m≤n) = cong -[1+_] $ ℕₚ.≤-antisym m≤n n≤m
≤-antisym (+≤+ m≤n) (+≤+ n≤m) = cong (+_) $ ℕₚ.≤-antisym m≤n n≤m
≤-total : Total _≤_
≤-total (-[1+ m ]) (-[1+ n ]) = Sum.map -≤- -≤- (ℕₚ.≤-total n m)
≤-total (-[1+ m ]) (+ n ) = inj₁ -≤+
≤-total (+ m ) (-[1+ n ]) = inj₂ -≤+
≤-total (+ m ) (+ n ) = Sum.map +≤+ +≤+ (ℕₚ.≤-total m n)
infix 4 _≤?_
_≤?_ : Decidable _≤_
-[1+ m ] ≤? -[1+ n ] = Dec.map′ -≤- drop‿-≤- (n ℕ.≤? m)
-[1+ m ] ≤? + n = yes -≤+
+ m ≤? -[1+ n ] = no λ ()
+ m ≤? + n = Dec.map′ +≤+ drop‿+≤+ (m ℕ.≤? n)
≤-irrelevant : Irrelevant _≤_
≤-irrelevant -≤+ -≤+ = refl
≤-irrelevant (-≤- n≤m₁) (-≤- n≤m₂) = cong -≤- (ℕₚ.≤-irrelevant n≤m₁ n≤m₂)
≤-irrelevant (+≤+ n≤m₁) (+≤+ n≤m₂) = cong +≤+ (ℕₚ.≤-irrelevant n≤m₁ n≤m₂)
------------------------------------------------------------------------
-- Structures
≤-isPreorder : IsPreorder _≡_ _≤_
≤-isPreorder = record
{ isEquivalence = isEquivalence
; reflexive = ≤-reflexive
; trans = ≤-trans
}
≤-isPartialOrder : IsPartialOrder _≡_ _≤_
≤-isPartialOrder = record
{ isPreorder = ≤-isPreorder
; antisym = ≤-antisym
}
≤-isTotalOrder : IsTotalOrder _≡_ _≤_
≤-isTotalOrder = record
{ isPartialOrder = ≤-isPartialOrder
; total = ≤-total
}
≤-isDecTotalOrder : IsDecTotalOrder _≡_ _≤_
≤-isDecTotalOrder = record
{ isTotalOrder = ≤-isTotalOrder
; _≟_ = _≟_
; _≤?_ = _≤?_
}
------------------------------------------------------------------------
-- Bundles
≤-preorder : Preorder 0ℓ 0ℓ 0ℓ
≤-preorder = record
{ isPreorder = ≤-isPreorder
}
≤-poset : Poset 0ℓ 0ℓ 0ℓ
≤-poset = record
{ isPartialOrder = ≤-isPartialOrder
}
≤-totalOrder : TotalOrder 0ℓ 0ℓ 0ℓ
≤-totalOrder = record
{ isTotalOrder = ≤-isTotalOrder
}
≤-decTotalOrder : DecTotalOrder 0ℓ 0ℓ 0ℓ
≤-decTotalOrder = record
{ isDecTotalOrder = ≤-isDecTotalOrder
}
------------------------------------------------------------------------
-- Properties _<_
------------------------------------------------------------------------
drop‿+<+ : ∀ {m n} → + m < + n → m ℕ.< n
drop‿+<+ (+<+ m<n) = m<n
drop‿-<- : ∀ {m n} → -[1+ m ] < -[1+ n ] → n ℕ.< m
drop‿-<- (-<- n<m) = n<m
+≮0 : ∀ {n} → + n ≮ +0
+≮0 (+<+ ())
+≮- : ∀ {m n} → + m ≮ -[1+ n ]
+≮- ()
------------------------------------------------------------------------
-- Relationship between other operators
<⇒≤ : ∀ {i j} → i < j → i ≤ j
<⇒≤ (-<- i<j) = -≤- (ℕₚ.<⇒≤ i<j)
<⇒≤ -<+ = -≤+
<⇒≤ (+<+ i<j) = +≤+ (ℕₚ.<⇒≤ i<j)
>⇒≰ : ∀ {i j} → i > j → i ≰ j
>⇒≰ (-<- n<m) = ℕₚ.<⇒≱ n<m ∘ drop‿-≤-
>⇒≰ (+<+ m<n) = ℕₚ.<⇒≱ m<n ∘ drop‿+≤+
≰⇒> : ∀ {i j} → i ≰ j → i > j
≰⇒> {+ n} {+_ n₁} i≰j = +<+ (ℕₚ.≰⇒> (i≰j ∘ +≤+))
≰⇒> {+ n} { -[1+_] n₁} i≰j = -<+
≰⇒> { -[1+_] n} {+_ n₁} i≰j = contradiction -≤+ i≰j
≰⇒> { -[1+_] n} { -[1+_] n₁} i≰j = -<- (ℕₚ.≰⇒> (i≰j ∘ -≤-))
------------------------------------------------------------------------
-- Relational properties
<-irrefl : Irreflexive _≡_ _<_
<-irrefl { -[1+ n ]} refl = ℕₚ.<-irrefl refl ∘ drop‿-<-
<-irrefl { +0} refl (+<+ ())
<-irrefl { +[1+ n ]} refl = ℕₚ.<-irrefl refl ∘ drop‿+<+
<-asym : Asymmetric _<_
<-asym (-<- n<m) = ℕₚ.<-asym n<m ∘ drop‿-<-
<-asym (+<+ m<n) = ℕₚ.<-asym m<n ∘ drop‿+<+
≤-<-trans : Trans _≤_ _<_ _<_
≤-<-trans (-≤- n≤m) (-<- o<n) = -<- (ℕₚ.<-transˡ o<n n≤m)
≤-<-trans (-≤- n≤m) -<+ = -<+
≤-<-trans -≤+ (+<+ m<o) = -<+
≤-<-trans (+≤+ m≤n) (+<+ n<o) = +<+ (ℕₚ.<-transʳ m≤n n<o)
<-≤-trans : Trans _<_ _≤_ _<_
<-≤-trans (-<- n<m) (-≤- o≤n) = -<- (ℕₚ.<-transʳ o≤n n<m)
<-≤-trans (-<- n<m) -≤+ = -<+
<-≤-trans -<+ (+≤+ m≤n) = -<+
<-≤-trans (+<+ m<n) (+≤+ n≤o) = +<+ (ℕₚ.<-transˡ m<n n≤o)
<-trans : Transitive _<_
<-trans m<n n<p = ≤-<-trans (<⇒≤ m<n) n<p
<-cmp : Trichotomous _≡_ _<_
<-cmp +0 +0 = tri≈ +≮0 refl +≮0
<-cmp +0 +[1+ n ] = tri< (+<+ (s≤s z≤n)) (λ()) +≮0
<-cmp +[1+ n ] +0 = tri> +≮0 (λ()) (+<+ (s≤s z≤n))
<-cmp (+ m) -[1+ n ] = tri> +≮- (λ()) -<+
<-cmp -[1+ m ] (+ n) = tri< -<+ (λ()) +≮-
<-cmp -[1+ m ] -[1+ n ] with ℕₚ.<-cmp m n
... | tri< m<n m≢n n≯m = tri> (n≯m ∘ drop‿-<-) (m≢n ∘ -[1+-injective) (-<- m<n)
... | tri≈ m≮n m≡n n≯m = tri≈ (n≯m ∘ drop‿-<-) (cong -[1+_] m≡n) (m≮n ∘ drop‿-<-)
... | tri> m≮n m≢n n>m = tri< (-<- n>m) (m≢n ∘ -[1+-injective) (m≮n ∘ drop‿-<-)
<-cmp +[1+ m ] +[1+ n ] with ℕₚ.<-cmp m n
... | tri< m<n m≢n n≯m = tri< (+<+ (s≤s m<n)) (m≢n ∘ +[1+-injective) (n≯m ∘ ℕₚ.≤-pred ∘ drop‿+<+)
... | tri≈ m≮n m≡n n≯m = tri≈ (m≮n ∘ ℕₚ.≤-pred ∘ drop‿+<+) (cong (+_ ∘ suc) m≡n) (n≯m ∘ ℕₚ.≤-pred ∘ drop‿+<+)
... | tri> m≮n m≢n n>m = tri> (m≮n ∘ ℕₚ.≤-pred ∘ drop‿+<+) (m≢n ∘ +[1+-injective) (+<+ (s≤s n>m))
infix 4 _<?_
_<?_ : Decidable _<_
-[1+ m ] <? -[1+ n ] = Dec.map′ -<- drop‿-<- (n ℕ.<? m)
-[1+ m ] <? + n = yes -<+
+ m <? -[1+ n ] = no λ()
+ m <? + n = Dec.map′ +<+ drop‿+<+ (m ℕ.<? n)
<-irrelevant : Irrelevant _<_
<-irrelevant (-<- n<m₁) (-<- n<m₂) = cong -<- (ℕₚ.<-irrelevant n<m₁ n<m₂)
<-irrelevant -<+ -<+ = refl
<-irrelevant (+<+ m<n₁) (+<+ m<n₂) = cong +<+ (ℕₚ.<-irrelevant m<n₁ m<n₂)
------------------------------------------------------------------------
-- Structures
<-isStrictPartialOrder : IsStrictPartialOrder _≡_ _<_
<-isStrictPartialOrder = record
{ isEquivalence = isEquivalence
; irrefl = <-irrefl
; trans = <-trans
; <-resp-≈ = subst (_ <_) , subst (_< _)
}
<-isStrictTotalOrder : IsStrictTotalOrder _≡_ _<_
<-isStrictTotalOrder = record
{ isEquivalence = isEquivalence
; trans = <-trans
; compare = <-cmp
}
------------------------------------------------------------------------
-- Bundles
<-strictPartialOrder : StrictPartialOrder 0ℓ 0ℓ 0ℓ
<-strictPartialOrder = record
{ isStrictPartialOrder = <-isStrictPartialOrder
}
<-strictTotalOrder : StrictTotalOrder 0ℓ 0ℓ 0ℓ
<-strictTotalOrder = record
{ isStrictTotalOrder = <-isStrictTotalOrder
}
------------------------------------------------------------------------
-- Other properties of _<_
n≮n : ∀ {n} → n ≮ n
n≮n {n} = <-irrefl refl
>-irrefl : Irreflexive _≡_ _>_
>-irrefl = <-irrefl ∘ sym
------------------------------------------------------------------------
-- A specialised module for reasoning about the _≤_ and _<_ relations
------------------------------------------------------------------------
module ≤-Reasoning where
open import Relation.Binary.Reasoning.Base.Triple
≤-isPreorder
<-trans
(resp₂ _<_)
<⇒≤
<-≤-trans
≤-<-trans
public
hiding (step-≈; step-≈˘)
------------------------------------------------------------------------
-- Properties of -_
------------------------------------------------------------------------
neg-involutive : ∀ n → - - n ≡ n
neg-involutive -[1+ n ] = refl
neg-involutive +0 = refl
neg-involutive +[1+ n ] = refl
neg-injective : ∀ {m n} → - m ≡ - n → m ≡ n
neg-injective {m} {n} -m≡-n = begin
m ≡⟨ sym (neg-involutive m) ⟩
- - m ≡⟨ cong -_ -m≡-n ⟩
- - n ≡⟨ neg-involutive n ⟩
n ∎ where open ≡-Reasoning
neg-≤-pos : ∀ {m n} → - (+ m) ≤ + n
neg-≤-pos {zero} = +≤+ z≤n
neg-≤-pos {suc m} = -≤+
neg-mono-<-> : -_ Preserves _<_ ⟶ _>_
neg-mono-<-> { -[1+ _ ]} { -[1+ _ ]} (-<- n<m) = +<+ (s≤s n<m)
neg-mono-<-> { -[1+ _ ]} { +0} -<+ = +<+ (s≤s z≤n)
neg-mono-<-> { -[1+ _ ]} { +[1+ n ]} -<+ = -<+
neg-mono-<-> { +0} { +[1+ n ]} (+<+ _) = -<+
neg-mono-<-> { +[1+ m ]} { +[1+ n ]} (+<+ m<n) = -<- (ℕₚ.≤-pred m<n)
------------------------------------------------------------------------
-- Properties of ∣_∣
------------------------------------------------------------------------
∣n∣≡0⇒n≡0 : ∀ {n} → ∣ n ∣ ≡ 0 → n ≡ + 0
∣n∣≡0⇒n≡0 {+0} refl = refl
∣-n∣≡∣n∣ : ∀ n → ∣ - n ∣ ≡ ∣ n ∣
∣-n∣≡∣n∣ -[1+ n ] = refl
∣-n∣≡∣n∣ +0 = refl
∣-n∣≡∣n∣ +[1+ n ] = refl
0≤n⇒+∣n∣≡n : ∀ {n} → + 0 ≤ n → + ∣ n ∣ ≡ n
0≤n⇒+∣n∣≡n (+≤+ 0≤n) = refl
+∣n∣≡n⇒0≤n : ∀ {n} → + ∣ n ∣ ≡ n → + 0 ≤ n
+∣n∣≡n⇒0≤n {+ n} _ = +≤+ z≤n
------------------------------------------------------------------------
-- Properties of sign and _◃_
◃-inverse : ∀ i → sign i ◃ ∣ i ∣ ≡ i
◃-inverse -[1+ n ] = refl
◃-inverse +0 = refl
◃-inverse +[1+ n ] = refl
◃-cong : ∀ {i j} → sign i ≡ sign j → ∣ i ∣ ≡ ∣ j ∣ → i ≡ j
◃-cong {i} {j} sign-≡ abs-≡ = begin
i ≡⟨ sym $ ◃-inverse i ⟩
sign i ◃ ∣ i ∣ ≡⟨ cong₂ _◃_ sign-≡ abs-≡ ⟩
sign j ◃ ∣ j ∣ ≡⟨ ◃-inverse j ⟩
j ∎ where open ≡-Reasoning
+◃n≡+n : ∀ n → Sign.+ ◃ n ≡ + n
+◃n≡+n zero = refl
+◃n≡+n (suc _) = refl
-◃n≡-n : ∀ n → Sign.- ◃ n ≡ - + n
-◃n≡-n zero = refl
-◃n≡-n (suc _) = refl
sign-◃ : ∀ s n → sign (s ◃ suc n) ≡ s
sign-◃ Sign.- _ = refl
sign-◃ Sign.+ _ = refl
abs-◃ : ∀ s n → ∣ s ◃ n ∣ ≡ n
abs-◃ _ zero = refl
abs-◃ Sign.- (suc n) = refl
abs-◃ Sign.+ (suc n) = refl
signₙ◃∣n∣≡n : ∀ n → sign n ◃ ∣ n ∣ ≡ n
signₙ◃∣n∣≡n (+ n) = +◃n≡+n n
signₙ◃∣n∣≡n -[1+ n ] = refl
sign-cong : ∀ {s₁ s₂ n₁ n₂} →
s₁ ◃ suc n₁ ≡ s₂ ◃ suc n₂ → s₁ ≡ s₂
sign-cong {s₁} {s₂} {n₁} {n₂} eq = begin
s₁ ≡⟨ sym $ sign-◃ s₁ n₁ ⟩
sign (s₁ ◃ suc n₁) ≡⟨ cong sign eq ⟩
sign (s₂ ◃ suc n₂) ≡⟨ sign-◃ s₂ n₂ ⟩
s₂ ∎ where open ≡-Reasoning
abs-cong : ∀ {s₁ s₂ n₁ n₂} → s₁ ◃ n₁ ≡ s₂ ◃ n₂ → n₁ ≡ n₂
abs-cong {s₁} {s₂} {n₁} {n₂} eq = begin
n₁ ≡⟨ sym $ abs-◃ s₁ n₁ ⟩
∣ s₁ ◃ n₁ ∣ ≡⟨ cong ∣_∣ eq ⟩
∣ s₂ ◃ n₂ ∣ ≡⟨ abs-◃ s₂ n₂ ⟩
n₂ ∎ where open ≡-Reasoning
∣s◃m∣*∣t◃n∣≡m*n : ∀ s t m n → ∣ s ◃ m ∣ ℕ.* ∣ t ◃ n ∣ ≡ m ℕ.* n
∣s◃m∣*∣t◃n∣≡m*n s t m n = cong₂ ℕ._*_ (abs-◃ s m) (abs-◃ t n)
◃-≡ : ∀ {m n} → sign m ≡ sign n → ∣ m ∣ ≡ ∣ n ∣ → m ≡ n
◃-≡ {+ m} {+ n } ≡-sign refl = refl
◃-≡ { -[1+ m ]} { -[1+ n ]} ≡-sign refl = refl
+◃-mono-< : ∀ {m n} → m ℕ.< n → Sign.+ ◃ m < Sign.+ ◃ n
+◃-mono-< {zero} {suc n} m<n = +<+ m<n
+◃-mono-< {suc m} {suc n} m<n = +<+ m<n
+◃-cancel-< : ∀ {m n} → Sign.+ ◃ m < Sign.+ ◃ n → m ℕ.< n
+◃-cancel-< {zero} {zero} (+<+ ())
+◃-cancel-< {suc m} {zero} (+<+ ())
+◃-cancel-< {zero} {suc n} (+<+ m<n) = m<n
+◃-cancel-< {suc m} {suc n} (+<+ m<n) = m<n
neg◃-cancel-< : ∀ {m n} → Sign.- ◃ m < Sign.- ◃ n → n ℕ.< m
neg◃-cancel-< {zero} {suc n} ()
neg◃-cancel-< {zero} {zero} (+<+ ())
neg◃-cancel-< {suc m} {zero} -<+ = s≤s z≤n
neg◃-cancel-< {suc m} {suc n} (-<- n<m) = s≤s n<m
-◃<+◃ : ∀ m n → Sign.- ◃ (suc m) < Sign.+ ◃ n
-◃<+◃ m zero = -<+
-◃<+◃ m (suc n) = -<+
+◃≮-◃ : ∀ {m n} → Sign.+ ◃ m ≮ Sign.- ◃ n
+◃≮-◃ {zero} {zero} (+<+ ())
+◃≮-◃ {suc m} {zero} (+<+ ())
------------------------------------------------------------------------
-- Properties of _⊖_
------------------------------------------------------------------------
n⊖n≡0 : ∀ n → n ⊖ n ≡ + 0
n⊖n≡0 zero = refl
n⊖n≡0 (suc n) = n⊖n≡0 n
⊖-swap : ∀ a b → a ⊖ b ≡ - (b ⊖ a)
⊖-swap zero zero = refl
⊖-swap (suc _) zero = refl
⊖-swap zero (suc _) = refl
⊖-swap (suc a) (suc b) = ⊖-swap a b
⊖-≥ : ∀ {m n} → m ℕ.≥ n → m ⊖ n ≡ + (m ∸ n)
⊖-≥ z≤n = refl
⊖-≥ (ℕ.s≤s n≤m) = ⊖-≥ n≤m
⊖-< : ∀ {m n} → m ℕ.< n → m ⊖ n ≡ - + (n ∸ m)
⊖-< {zero} (ℕ.s≤s z≤n) = refl
⊖-< {suc m} (ℕ.s≤s m<n) = ⊖-< m<n
⊖-≰ : ∀ {m n} → n ℕ.≰ m → m ⊖ n ≡ - + (n ∸ m)
⊖-≰ = ⊖-< ∘ ℕₚ.≰⇒>
∣⊖∣-< : ∀ {m n} → m ℕ.< n → ∣ m ⊖ n ∣ ≡ n ∸ m
∣⊖∣-< {zero} (ℕ.s≤s z≤n) = refl
∣⊖∣-< {suc n} (ℕ.s≤s m<n) = ∣⊖∣-< m<n
∣⊖∣-≰ : ∀ {m n} → n ℕ.≰ m → ∣ m ⊖ n ∣ ≡ n ∸ m
∣⊖∣-≰ = ∣⊖∣-< ∘ ℕₚ.≰⇒>
-[n⊖m]≡-m+n : ∀ m n → - (m ⊖ n) ≡ (- (+ m)) + (+ n)
-[n⊖m]≡-m+n zero zero = refl
-[n⊖m]≡-m+n zero (suc n) = refl
-[n⊖m]≡-m+n (suc m) zero = refl
-[n⊖m]≡-m+n (suc m) (suc n) = sym (⊖-swap n m)
∣m⊖n∣≡∣n⊖m∣ : ∀ x y → ∣ x ⊖ y ∣ ≡ ∣ y ⊖ x ∣
∣m⊖n∣≡∣n⊖m∣ zero zero = refl
∣m⊖n∣≡∣n⊖m∣ zero (suc _) = refl
∣m⊖n∣≡∣n⊖m∣ (suc _) zero = refl
∣m⊖n∣≡∣n⊖m∣ (suc x) (suc y) = ∣m⊖n∣≡∣n⊖m∣ x y
+-cancelˡ-⊖ : ∀ a b c → (a ℕ.+ b) ⊖ (a ℕ.+ c) ≡ b ⊖ c
+-cancelˡ-⊖ zero b c = refl
+-cancelˡ-⊖ (suc a) b c = +-cancelˡ-⊖ a b c
m⊖n≤m : ∀ m n → m ⊖ n ≤ + m
m⊖n≤m m zero = ≤-refl
m⊖n≤m zero (suc n) = -≤+
m⊖n≤m (suc m) (suc n) = ≤-trans (m⊖n≤m m n) (+≤+ (ℕₚ.n≤1+n m))
m⊖n<1+m : ∀ m n → m ⊖ n < +[1+ m ]
m⊖n<1+m m zero = +<+ ℕₚ.≤-refl
m⊖n<1+m zero (suc n) = -<+
m⊖n<1+m (suc m) (suc n) = <-trans (m⊖n<1+m m n) (+<+ ℕₚ.≤-refl)
m⊖1+n<m : ∀ m n → m ⊖ suc n < + m
m⊖1+n<m zero n = -<+
m⊖1+n<m (suc m) n = m⊖n<1+m m n
-1+m<n⊖m : ∀ m n → -[1+ m ] < n ⊖ m
-1+m<n⊖m zero n = -<+
-1+m<n⊖m (suc m) zero = -<- ℕₚ.≤-refl
-1+m<n⊖m (suc m) (suc n) = <-trans (-<- ℕₚ.≤-refl) (-1+m<n⊖m m n)
-[1+m]≤n⊖m+1 : ∀ m n → -[1+ m ] ≤ n ⊖ suc m
-[1+m]≤n⊖m+1 m zero = ≤-refl
-[1+m]≤n⊖m+1 m (suc n) = <⇒≤ (-1+m<n⊖m m n)
-1+m≤n⊖m : ∀ m n → -[1+ m ] ≤ n ⊖ m
-1+m≤n⊖m m n = <⇒≤ (-1+m<n⊖m m n)
0⊖m≤+ : ∀ m {n} → 0 ⊖ m ≤ + n
0⊖m≤+ zero = +≤+ z≤n
0⊖m≤+ (suc m) = -≤+
sign-⊖-< : ∀ {m n} → m ℕ.< n → sign (m ⊖ n) ≡ Sign.-
sign-⊖-< {zero} (ℕ.s≤s z≤n) = refl
sign-⊖-< {suc n} (ℕ.s≤s m<n) = sign-⊖-< m<n
sign-⊖-≰ : ∀ {m n} → n ℕ.≰ m → sign (m ⊖ n) ≡ Sign.-
sign-⊖-≰ = sign-⊖-< ∘ ℕₚ.≰⇒>
⊖-monoʳ-≥-≤ : ∀ p → (p ⊖_) Preserves ℕ._≥_ ⟶ _≤_
⊖-monoʳ-≥-≤ zero (z≤n {n}) = 0⊖m≤+ n
⊖-monoʳ-≥-≤ zero (s≤s m≤n) = -≤- m≤n
⊖-monoʳ-≥-≤ (suc p) (z≤n {zero}) = ≤-refl
⊖-monoʳ-≥-≤ (suc p) (z≤n {suc n}) = ≤-trans (⊖-monoʳ-≥-≤ p (z≤n {n})) (+≤+ (ℕₚ.n≤1+n p))
⊖-monoʳ-≥-≤ (suc p) (s≤s m≤n) = ⊖-monoʳ-≥-≤ p m≤n
⊖-monoˡ-≤ : ∀ p → (_⊖ p) Preserves ℕ._≤_ ⟶ _≤_
⊖-monoˡ-≤ zero m≤n = +≤+ m≤n
⊖-monoˡ-≤ (suc p) (z≤n {0}) = ≤-refl
⊖-monoˡ-≤ (suc p) (z≤n {(suc m)}) = ≤-trans (⊖-monoʳ-≥-≤ 0 (ℕₚ.n≤1+n p)) (⊖-monoˡ-≤ p z≤n)
⊖-monoˡ-≤ (suc p) (s≤s m≤n) = ⊖-monoˡ-≤ p m≤n
⊖-monoʳ->-< : ∀ p → (p ⊖_) Preserves ℕ._>_ ⟶ _<_
⊖-monoʳ->-< zero {_} (s≤s z≤n) = -<+
⊖-monoʳ->-< zero {_} (s≤s (s≤s m≤n)) = -<- (s≤s m≤n)
⊖-monoʳ->-< (suc p) {suc m} (s≤s z≤n) = m⊖n<1+m p m
⊖-monoʳ->-< (suc p) {_} (s≤s (s≤s m≤n)) = ⊖-monoʳ->-< p (s≤s m≤n)
⊖-monoˡ-< : ∀ p → (_⊖ p) Preserves ℕ._<_ ⟶ _<_
⊖-monoˡ-< zero m<n = +<+ m<n
⊖-monoˡ-< (suc p) (s≤s z≤n) = -1+m<n⊖m p _
⊖-monoˡ-< (suc p) (s≤s (s≤s m<n)) = ⊖-monoˡ-< p (s≤s m<n)
------------------------------------------------------------------------
-- Properties of _+_
------------------------------------------------------------------------
------------------------------------------------------------------------
-- Algebraic properties of _+_
+-comm : Commutative _+_
+-comm -[1+ a ] -[1+ b ] = cong (-[1+_] ∘ suc) (ℕₚ.+-comm a b)
+-comm (+ a ) (+ b ) = cong +_ (ℕₚ.+-comm a b)
+-comm -[1+ _ ] (+ _ ) = refl
+-comm (+ _ ) -[1+ _ ] = refl
+-identityˡ : LeftIdentity +0 _+_
+-identityˡ -[1+ _ ] = refl
+-identityˡ (+ _ ) = refl
+-identityʳ : RightIdentity +0 _+_
+-identityʳ = comm+idˡ⇒idʳ +-comm +-identityˡ
+-identity : Identity +0 _+_
+-identity = +-identityˡ , +-identityʳ
distribˡ-⊖-+-pos : ∀ a b c → b ⊖ c + + a ≡ b ℕ.+ a ⊖ c
distribˡ-⊖-+-pos _ zero zero = refl
distribˡ-⊖-+-pos _ zero (suc _) = refl
distribˡ-⊖-+-pos _ (suc _) zero = refl
distribˡ-⊖-+-pos a (suc b) (suc c) = distribˡ-⊖-+-pos a b c
distribˡ-⊖-+-neg : ∀ a b c → b ⊖ c + -[1+ a ] ≡ b ⊖ (suc c ℕ.+ a)
distribˡ-⊖-+-neg _ zero zero = refl
distribˡ-⊖-+-neg _ zero (suc _) = refl
distribˡ-⊖-+-neg _ (suc _) zero = refl
distribˡ-⊖-+-neg a (suc b) (suc c) = distribˡ-⊖-+-neg a b c
distribʳ-⊖-+-pos : ∀ a b c → + a + (b ⊖ c) ≡ a ℕ.+ b ⊖ c
distribʳ-⊖-+-pos a b c = begin
+ a + (b ⊖ c) ≡⟨ +-comm (+ a) (b ⊖ c) ⟩
(b ⊖ c) + + a ≡⟨ distribˡ-⊖-+-pos a b c ⟩
b ℕ.+ a ⊖ c ≡⟨ cong (_⊖ c) (ℕₚ.+-comm b a) ⟩
a ℕ.+ b ⊖ c ∎ where open ≡-Reasoning
distribʳ-⊖-+-neg : ∀ a b c → -[1+ a ] + (b ⊖ c) ≡ b ⊖ (suc a ℕ.+ c)
distribʳ-⊖-+-neg a b c = begin
-[1+ a ] + (b ⊖ c) ≡⟨ +-comm -[1+ a ] (b ⊖ c) ⟩
(b ⊖ c) + -[1+ a ] ≡⟨ distribˡ-⊖-+-neg a b c ⟩
b ⊖ suc (c ℕ.+ a) ≡⟨ cong (λ x → b ⊖ suc x) (ℕₚ.+-comm c a) ⟩
b ⊖ suc (a ℕ.+ c) ∎ where open ≡-Reasoning
+-assoc : Associative _+_
+-assoc +0 y z rewrite +-identityˡ y | +-identityˡ (y + z) = refl
+-assoc x +0 z rewrite +-identityʳ x | +-identityˡ z = refl
+-assoc x y +0 rewrite +-identityʳ (x + y) | +-identityʳ y = refl
+-assoc -[1+ a ] -[1+ b ] +[1+ c ] = sym (distribʳ-⊖-+-neg a c b)
+-assoc -[1+ a ] +[1+ b ] +[1+ c ] = distribˡ-⊖-+-pos (suc c) b a
+-assoc +[1+ a ] -[1+ b ] -[1+ c ] = distribˡ-⊖-+-neg c a b
+-assoc +[1+ a ] -[1+ b ] +[1+ c ]
rewrite distribˡ-⊖-+-pos (suc c) a b
| distribʳ-⊖-+-pos (suc a) c b
| sym (ℕₚ.+-assoc a 1 c)
| ℕₚ.+-comm a 1
= refl
+-assoc +[1+ a ] +[1+ b ] -[1+ c ]
rewrite distribʳ-⊖-+-pos (suc a) b c
| sym (ℕₚ.+-assoc a 1 b)
| ℕₚ.+-comm a 1
= refl
+-assoc -[1+ a ] -[1+ b ] -[1+ c ]
rewrite sym (ℕₚ.+-assoc a 1 (b ℕ.+ c))
| ℕₚ.+-comm a 1
| ℕₚ.+-assoc a b c
= refl
+-assoc -[1+ a ] +[1+ b ] -[1+ c ]
rewrite distribʳ-⊖-+-neg a b c
| distribˡ-⊖-+-neg c b a
= refl
+-assoc +[1+ a ] +[1+ b ] +[1+ c ]
rewrite ℕₚ.+-assoc (suc a) (suc b) (suc c)
= refl
+-inverseˡ : LeftInverse +0 -_ _+_
+-inverseˡ -[1+ n ] = n⊖n≡0 n
+-inverseˡ +0 = refl
+-inverseˡ +[1+ n ] = n⊖n≡0 n
+-inverseʳ : RightInverse +0 -_ _+_
+-inverseʳ = comm+invˡ⇒invʳ +-comm +-inverseˡ
+-inverse : Inverse +0 -_ _+_
+-inverse = +-inverseˡ , +-inverseʳ
------------------------------------------------------------------------
-- Structures
+-isMagma : IsMagma _+_
+-isMagma = record
{ isEquivalence = isEquivalence
; ∙-cong = cong₂ _+_
}
+-isSemigroup : IsSemigroup _+_
+-isSemigroup = record
{ isMagma = +-isMagma
; assoc = +-assoc
}
+-isCommutativeSemigroup : IsCommutativeSemigroup _+_
+-isCommutativeSemigroup = record
{ isSemigroup = +-isSemigroup
; comm = +-comm
}
+-0-isMonoid : IsMonoid _+_ +0
+-0-isMonoid = record
{ isSemigroup = +-isSemigroup
; identity = +-identity
}
+-0-isCommutativeMonoid : IsCommutativeMonoid _+_ +0
+-0-isCommutativeMonoid = record
{ isMonoid = +-0-isMonoid
; comm = +-comm
}
+-0-isGroup : IsGroup _+_ +0 (-_)
+-0-isGroup = record
{ isMonoid = +-0-isMonoid
; inverse = +-inverse
; ⁻¹-cong = cong (-_)
}
+-isAbelianGroup : IsAbelianGroup _+_ +0 (-_)
+-isAbelianGroup = record
{ isGroup = +-0-isGroup
; comm = +-comm
}
------------------------------------------------------------------------
-- Bundles
+-magma : Magma 0ℓ 0ℓ
+-magma = record
{ isMagma = +-isMagma
}
+-semigroup : Semigroup 0ℓ 0ℓ
+-semigroup = record
{ isSemigroup = +-isSemigroup
}
+-commutativeSemigroup : CommutativeSemigroup 0ℓ 0ℓ
+-commutativeSemigroup = record
{ isCommutativeSemigroup = +-isCommutativeSemigroup
}
+-0-monoid : Monoid 0ℓ 0ℓ
+-0-monoid = record
{ isMonoid = +-0-isMonoid
}
+-0-commutativeMonoid : CommutativeMonoid 0ℓ 0ℓ
+-0-commutativeMonoid = record
{ isCommutativeMonoid = +-0-isCommutativeMonoid
}
+-0-abelianGroup : AbelianGroup 0ℓ 0ℓ
+-0-abelianGroup = record
{ isAbelianGroup = +-isAbelianGroup
}
------------------------------------------------------------------------
-- Properties of _+_ and +_/-_.
pos-+-commute : ℕtoℤ.Homomorphic₂ +_ ℕ._+_ _+_
pos-+-commute zero n = refl
pos-+-commute (suc m) n = cong sucℤ (pos-+-commute m n)
neg-distrib-+ : ∀ m n → - (m + n) ≡ (- m) + (- n)
neg-distrib-+ +0 +0 = refl
neg-distrib-+ +0 +[1+ n ] = refl
neg-distrib-+ +[1+ m ] +0 = cong -[1+_] (ℕₚ.+-identityʳ m)
neg-distrib-+ +[1+ m ] +[1+ n ] = cong -[1+_] (ℕₚ.+-suc m n)
neg-distrib-+ -[1+ m ] -[1+ n ] = cong (λ v → + suc v) (sym (ℕₚ.+-suc m n))
neg-distrib-+ (+ m) -[1+ n ] = -[n⊖m]≡-m+n m (suc n)
neg-distrib-+ -[1+ m ] (+ n) =
trans (-[n⊖m]≡-m+n n (suc m)) (+-comm (- + n) (+ suc m))
◃-distrib-+ : ∀ s m n → s ◃ (m ℕ.+ n) ≡ (s ◃ m) + (s ◃ n)
◃-distrib-+ Sign.- m n = begin
Sign.- ◃ (m ℕ.+ n) ≡⟨ -◃n≡-n (m ℕ.+ n) ⟩
- (+ (m ℕ.+ n)) ≡⟨⟩
- ((+ m) + (+ n)) ≡⟨ neg-distrib-+ (+ m) (+ n) ⟩
(- (+ m)) + (- (+ n)) ≡⟨ sym (cong₂ _+_ (-◃n≡-n m) (-◃n≡-n n)) ⟩
(Sign.- ◃ m) + (Sign.- ◃ n) ∎ where open ≡-Reasoning
◃-distrib-+ Sign.+ m n = begin
Sign.+ ◃ (m ℕ.+ n) ≡⟨ +◃n≡+n (m ℕ.+ n) ⟩
+ (m ℕ.+ n) ≡⟨⟩
(+ m) + (+ n) ≡⟨ sym (cong₂ _+_ (+◃n≡+n m) (+◃n≡+n n)) ⟩
(Sign.+ ◃ m) + (Sign.+ ◃ n) ∎ where open ≡-Reasoning
------------------------------------------------------------------------
-- Properties of _+_ and _≤_
+-pos-monoʳ-≤ : ∀ n → (_+_ (+ n)) Preserves _≤_ ⟶ _≤_
+-pos-monoʳ-≤ n {_} (-≤- o≤m) = ⊖-monoʳ-≥-≤ n (s≤s o≤m)
+-pos-monoʳ-≤ n { -[1+ m ]} -≤+ = ≤-trans (m⊖n≤m n (suc m)) (+≤+ (ℕₚ.m≤m+n n _))
+-pos-monoʳ-≤ n {_} (+≤+ m≤o) = +≤+ (ℕₚ.+-monoʳ-≤ n m≤o)
+-neg-monoʳ-≤ : ∀ n → (_+_ (-[1+ n ])) Preserves _≤_ ⟶ _≤_
+-neg-monoʳ-≤ n {_} {_} (-≤- n≤m) = -≤- (ℕₚ.+-monoʳ-≤ (suc n) n≤m)
+-neg-monoʳ-≤ n {_} {+ m} -≤+ = ≤-trans (-≤- (ℕₚ.m≤m+n (suc n) _)) (-1+m≤n⊖m (suc n) m)
+-neg-monoʳ-≤ n {_} {_} (+≤+ m≤n) = ⊖-monoˡ-≤ (suc n) m≤n
+-monoʳ-≤ : ∀ n → (_+_ n) Preserves _≤_ ⟶ _≤_
+-monoʳ-≤ (+ n) = +-pos-monoʳ-≤ n
+-monoʳ-≤ -[1+ n ] = +-neg-monoʳ-≤ n
+-monoˡ-≤ : ∀ n → (_+ n) Preserves _≤_ ⟶ _≤_
+-monoˡ-≤ n {i} {j} i≤j
rewrite +-comm i n
| +-comm j n
= +-monoʳ-≤ n i≤j
+-mono-≤ : _+_ Preserves₂ _≤_ ⟶ _≤_ ⟶ _≤_
+-mono-≤ {m} {n} {i} {j} m≤n i≤j = begin
m + i ≤⟨ +-monoˡ-≤ i m≤n ⟩
n + i ≤⟨ +-monoʳ-≤ n i≤j ⟩
n + j ∎
where open ≤-Reasoning
≤-steps : ∀ {m n} p → m ≤ n → m ≤ + p + n
≤-steps p m≤n = subst (_≤ _) (+-identityˡ _) (+-mono-≤ (+≤+ z≤n) m≤n)
m≤m+n : ∀ {m} n → m ≤ m + + n
m≤m+n {m} n = begin
m ≡⟨ sym (+-identityʳ m) ⟩
m + + 0 ≤⟨ +-monoʳ-≤ m (+≤+ z≤n) ⟩
m + + n ∎
where open ≤-Reasoning
n≤m+n : ∀ m {n} → n ≤ + m + n
n≤m+n m {n} rewrite +-comm (+ m) n = m≤m+n m
------------------------------------------------------------------------
-- Properties of _+_ and _<_
+-monoʳ-< : ∀ n → (_+_ n) Preserves _<_ ⟶ _<_
+-monoʳ-< (+ n) {_} {_} (-<- o<m) = ⊖-monoʳ->-< n (s≤s o<m)
+-monoʳ-< (+ n) {_} {_} -<+ = <-≤-trans (m⊖1+n<m n _) (+≤+ (ℕₚ.m≤m+n n _))
+-monoʳ-< (+ n) {_} {_} (+<+ m<o) = +<+ (ℕₚ.+-monoʳ-< n m<o)
+-monoʳ-< -[1+ n ] {_} {_} (-<- o<m) = -<- (ℕₚ.+-monoʳ-< (suc n) o<m)
+-monoʳ-< -[1+ n ] {_} {+ o} -<+ = <-≤-trans (-<- (ℕₚ.m≤m+n (suc n) _)) (-[1+m]≤n⊖m+1 n o)
+-monoʳ-< -[1+ n ] {_} {_} (+<+ m<o) = ⊖-monoˡ-< (suc n) m<o
+-monoˡ-< : ∀ n → (_+ n) Preserves _<_ ⟶ _<_
+-monoˡ-< n {i} {j} i<j
rewrite +-comm i n
| +-comm j n
= +-monoʳ-< n i<j
+-mono-< : _+_ Preserves₂ _<_ ⟶ _<_ ⟶ _<_
+-mono-< {m} {n} {i} {j} m<n i<j = begin-strict
m + i <⟨ +-monoˡ-< i m<n ⟩
n + i <⟨ +-monoʳ-< n i<j ⟩
n + j ∎
where open ≤-Reasoning
+-mono-≤-< : _+_ Preserves₂ _≤_ ⟶ _<_ ⟶ _<_
+-mono-≤-< {m} {n} {i} m≤n i<j = ≤-<-trans (+-monoˡ-≤ i m≤n) (+-monoʳ-< n i<j)
+-mono-<-≤ : _+_ Preserves₂ _<_ ⟶ _≤_ ⟶ _<_
+-mono-<-≤ {m} {n} {i} m<n i≤j = <-≤-trans (+-monoˡ-< i m<n) (+-monoʳ-≤ n i≤j)
------------------------------------------------------------------------
-- Properties of _-_
------------------------------------------------------------------------
neg-minus-pos : ∀ x y → -[1+ x ] - (+ y) ≡ -[1+ (y ℕ.+ x) ]
neg-minus-pos x zero = refl
neg-minus-pos zero (suc y) = cong (-[1+_] ∘ suc) (sym (ℕₚ.+-identityʳ y))
neg-minus-pos (suc x) (suc y) = cong (-[1+_] ∘ suc) (ℕₚ.+-comm (suc x) y)
+-minus-telescope : ∀ x y z → (x - y) + (y - z) ≡ x - z
+-minus-telescope x y z = begin
(x - y) + (y - z) ≡⟨ +-assoc x (- y) (y - z) ⟩
x + (- y + (y - z)) ≡⟨ cong (λ v → x + v) (sym (+-assoc (- y) y _)) ⟩
x + ((- y + y) - z) ≡⟨ sym (+-assoc x (- y + y) (- z)) ⟩
x + (- y + y) - z ≡⟨ cong (λ a → x + a - z) (+-inverseˡ y) ⟩
x + +0 - z ≡⟨ cong (_- z) (+-identityʳ x) ⟩
x - z ∎ where open ≡-Reasoning
[+m]-[+n]≡m⊖n : ∀ x y → (+ x) - (+ y) ≡ x ⊖ y
[+m]-[+n]≡m⊖n zero zero = refl
[+m]-[+n]≡m⊖n zero (suc y) = refl
[+m]-[+n]≡m⊖n (suc x) zero = cong (+_ ∘ suc) (ℕₚ.+-identityʳ x)
[+m]-[+n]≡m⊖n (suc x) (suc y) = refl
∣m-n∣≡∣n-m∣ : (x y : ℤ) → ∣ x - y ∣ ≡ ∣ y - x ∣
∣m-n∣≡∣n-m∣ -[1+ x ] -[1+ y ] = ∣m⊖n∣≡∣n⊖m∣ y x
∣m-n∣≡∣n-m∣ -[1+ x ] (+ y) = begin
∣ -[1+ x ] - (+ y) ∣ ≡⟨ cong ∣_∣ (neg-minus-pos x y) ⟩
suc (y ℕ.+ x) ≡⟨ sym (ℕₚ.+-suc y x) ⟩
y ℕ.+ suc x ∎ where open ≡-Reasoning
∣m-n∣≡∣n-m∣ (+ x) -[1+ y ] = begin
x ℕ.+ suc y ≡⟨ ℕₚ.+-suc x y ⟩
suc (x ℕ.+ y) ≡⟨ cong ∣_∣ (sym (neg-minus-pos y x)) ⟩
∣ -[1+ y ] + - (+ x) ∣ ∎ where open ≡-Reasoning
∣m-n∣≡∣n-m∣ (+ x) (+ y) = begin
∣ (+ x) - (+ y) ∣ ≡⟨ cong ∣_∣ ([+m]-[+n]≡m⊖n x y) ⟩
∣ x ⊖ y ∣ ≡⟨ ∣m⊖n∣≡∣n⊖m∣ x y ⟩
∣ y ⊖ x ∣ ≡⟨ cong ∣_∣ (sym ([+m]-[+n]≡m⊖n y x)) ⟩
∣ (+ y) - (+ x) ∣ ∎ where open ≡-Reasoning
m≡n⇒m-n≡0 : ∀ m n → m ≡ n → m - n ≡ + 0
m≡n⇒m-n≡0 m m refl = +-inverseʳ m
m-n≡0⇒m≡n : ∀ m n → m - n ≡ + 0 → m ≡ n
m-n≡0⇒m≡n m n m-n≡0 = begin
m ≡⟨ sym (+-identityʳ m) ⟩
m + + 0 ≡⟨ cong (_+_ m) (sym (+-inverseˡ n)) ⟩
m + (- n + n) ≡⟨ sym (+-assoc m (- n) n) ⟩
(m - n) + n ≡⟨ cong (_+ n) m-n≡0 ⟩
+ 0 + n ≡⟨ +-identityˡ n ⟩
n ∎ where open ≡-Reasoning
≤-steps-neg : ∀ {m n} p → m ≤ n → m - + p ≤ n
≤-steps-neg {m} zero m≤n rewrite +-identityʳ m = m≤n
≤-steps-neg {+ m} (suc p) m≤n = ≤-trans (m⊖n≤m m (suc p)) m≤n
≤-steps-neg { -[1+ n ]} (suc p) m≤n = ≤-trans (-≤- (ℕₚ.≤-trans (ℕₚ.m≤m+n n p) (ℕₚ.n≤1+n _))) m≤n
neg-mono-≤-≥ : -_ Preserves _≤_ ⟶ _≥_
neg-mono-≤-≥ -≤+ = neg-≤-pos
neg-mono-≤-≥ (-≤- n≤m) = +≤+ (s≤s n≤m)
neg-mono-≤-≥ (+≤+ z≤n) = neg-≤-pos
neg-mono-≤-≥ (+≤+ (s≤s m≤n)) = -≤- m≤n
m-n≤m : ∀ m n → m - + n ≤ m
m-n≤m m n = ≤-steps-neg n ≤-refl
m≤n⇒m-n≤0 : ∀ {m n} → m ≤ n → m - n ≤ + 0
m≤n⇒m-n≤0 (-≤+ {n = n}) = ≤-steps-neg n -≤+
m≤n⇒m-n≤0 (-≤- {n = n} n≤m) = ≤-trans (⊖-monoʳ-≥-≤ n n≤m) (≤-reflexive (n⊖n≡0 n))
m≤n⇒m-n≤0 {n = + 0} (+≤+ z≤n) = +≤+ z≤n
m≤n⇒m-n≤0 {n = + suc n} (+≤+ z≤n) = -≤+
m≤n⇒m-n≤0 (+≤+ (s≤s {m} m≤n)) = ≤-trans (⊖-monoʳ-≥-≤ m m≤n) (≤-reflexive (n⊖n≡0 m))
m-n≤0⇒m≤n : ∀ {m n} → m - n ≤ + 0 → m ≤ n
m-n≤0⇒m≤n {m} {n} m-n≤0 = begin
m ≡⟨ sym (+-identityʳ m) ⟩
m + + 0 ≡⟨ cong (_+_ m) (sym (+-inverseˡ n)) ⟩
m + (- n + n) ≡⟨ sym (+-assoc m (- n) n) ⟩
(m - n) + n ≤⟨ +-monoˡ-≤ n m-n≤0 ⟩
+ 0 + n ≡⟨ +-identityˡ n ⟩
n ∎
where open ≤-Reasoning
m≤n⇒0≤n-m : ∀ {m n} → m ≤ n → + 0 ≤ n - m
m≤n⇒0≤n-m {m} {n} m≤n = begin
+ 0 ≡⟨ sym (+-inverseʳ m) ⟩
m - m ≤⟨ +-monoˡ-≤ (- m) m≤n ⟩
n - m ∎
where open ≤-Reasoning
0≤n-m⇒m≤n : ∀ {m n} → + 0 ≤ n - m → m ≤ n
0≤n-m⇒m≤n {m} {n} 0≤n-m = begin
m ≡⟨ sym (+-identityˡ m) ⟩
+ 0 + m ≤⟨ +-monoˡ-≤ m 0≤n-m ⟩
n - m + m ≡⟨ +-assoc n (- m) m ⟩
n + (- m + m) ≡⟨ cong (_+_ n) (+-inverseˡ m) ⟩
n + + 0 ≡⟨ +-identityʳ n ⟩
n ∎
where open ≤-Reasoning
------------------------------------------------------------------------
-- Properties of suc
------------------------------------------------------------------------
≤-step : ∀ {n m} → n ≤ m → n ≤ sucℤ m
≤-step = ≤-steps 1
n≤1+n : ∀ n → n ≤ sucℤ n
n≤1+n n = ≤-steps 1 ≤-refl
suc-+ : ∀ m n → + suc m + n ≡ sucℤ (+ m + n)
suc-+ m (+ n) = refl
suc-+ m (-[1+ n ]) = sym (distribʳ-⊖-+-pos 1 m (suc n))
n≢1+n : ∀ {n} → n ≢ sucℤ n
n≢1+n {+ _} ()
n≢1+n { -[1+ 0 ]} ()
n≢1+n { -[1+ suc n ]} ()
1-[1+n]≡-n : ∀ n → sucℤ -[1+ n ] ≡ - (+ n)
1-[1+n]≡-n zero = refl
1-[1+n]≡-n (suc n) = refl
suc-mono : sucℤ Preserves _≤_ ⟶ _≤_
suc-mono (-≤+ {m}) = 0⊖m≤+ m
suc-mono (-≤- n≤m) = ⊖-monoʳ-≥-≤ zero n≤m
suc-mono (+≤+ m≤n) = +≤+ (s≤s m≤n)
suc[i]≤j⇒i<j : ∀ {i j} → sucℤ i ≤ j → i < j
suc[i]≤j⇒i<j {+ i} {+ _} (+≤+ i≤j) = +<+ i≤j
suc[i]≤j⇒i<j { -[1+ 0 ]} {+ j} p = -<+
suc[i]≤j⇒i<j { -[1+ suc i ]} {+ j} -≤+ = -<+
suc[i]≤j⇒i<j { -[1+ suc i ]} { -[1+ j ]} (-≤- j≤i) = -<- (ℕ.s≤s j≤i)
i<j⇒suc[i]≤j : ∀ {i j} → i < j → sucℤ i ≤ j
i<j⇒suc[i]≤j {+ _} {+ _} (+<+ i<j) = +≤+ i<j
i<j⇒suc[i]≤j { -[1+ 0 ]} {+ _} -<+ = +≤+ z≤n
i<j⇒suc[i]≤j { -[1+ suc i ]} { -[1+ _ ]} (-<- j<i) = -≤- (ℕ.≤-pred j<i)
i<j⇒suc[i]≤j { -[1+ suc i ]} {+ _} -<+ = -≤+
------------------------------------------------------------------------
-- Properties of pred
------------------------------------------------------------------------
suc-pred : ∀ m → sucℤ (pred m) ≡ m
suc-pred m = begin
sucℤ (pred m) ≡⟨ sym (+-assoc (+ 1) (- + 1) m) ⟩
+ 0 + m ≡⟨ +-identityˡ m ⟩
m ∎ where open ≡-Reasoning
pred-suc : ∀ m → pred (sucℤ m) ≡ m
pred-suc m = begin
pred (sucℤ m) ≡⟨ sym (+-assoc (- + 1) (+ 1) m) ⟩
+ 0 + m ≡⟨ +-identityˡ m ⟩
m ∎ where open ≡-Reasoning
+-pred : ∀ m n → m + pred n ≡ pred (m + n)
+-pred m n = begin
m + (-[1+ 0 ] + n) ≡⟨ sym (+-assoc m -[1+ 0 ] n) ⟩
m + -[1+ 0 ] + n ≡⟨ cong (_+ n) (+-comm m -[1+ 0 ]) ⟩
-[1+ 0 ] + m + n ≡⟨ +-assoc -[1+ 0 ] m n ⟩
-[1+ 0 ] + (m + n) ∎ where open ≡-Reasoning
pred-+ : ∀ m n → pred m + n ≡ pred (m + n)
pred-+ m n = begin
pred m + n ≡⟨ +-comm (pred m) n ⟩
n + pred m ≡⟨ +-pred n m ⟩
pred (n + m) ≡⟨ cong pred (+-comm n m) ⟩
pred (m + n) ∎ where open ≡-Reasoning
neg-suc : ∀ m → - + suc m ≡ pred (- + m)
neg-suc zero = refl
neg-suc (suc m) = refl
minus-suc : ∀ m n → m - + suc n ≡ pred (m - + n)
minus-suc m n = begin
m + - + suc n ≡⟨ cong (_+_ m) (neg-suc n) ⟩
m + pred (- (+ n)) ≡⟨ +-pred m (- + n) ⟩
pred (m - + n) ∎ where open ≡-Reasoning
m≤pred[n]⇒m<n : ∀ {m n} → m ≤ pred n → m < n
m≤pred[n]⇒m<n {m} { + n} m≤predn = ≤-<-trans m≤predn (m⊖1+n<m n 0)
m≤pred[n]⇒m<n {m} { -[1+ n ]} m≤predn = ≤-<-trans m≤predn (-<- ℕₚ.≤-refl)
m<n⇒m≤pred[n] : ∀ {m n} → m < n → m ≤ pred n
m<n⇒m≤pred[n] {_} { +0} -<+ = -≤- z≤n
m<n⇒m≤pred[n] {_} { +[1+ n ]} -<+ = -≤+
m<n⇒m≤pred[n] {_} { +[1+ n ]} (+<+ m<n) = +≤+ (ℕₚ.≤-pred m<n)
m<n⇒m≤pred[n] {_} { -[1+ n ]} (-<- n<m) = -≤- n<m
≤-step-neg : ∀ {m n} → m ≤ n → pred m ≤ n
≤-step-neg -≤+ = -≤+
≤-step-neg (-≤- n≤m) = -≤- (ℕₚ.≤-step n≤m)
≤-step-neg (+≤+ z≤n) = -≤+
≤-step-neg (+≤+ (s≤s m≤n)) = +≤+ (ℕₚ.≤-step m≤n)
pred-mono : pred Preserves _≤_ ⟶ _≤_
pred-mono (-≤+ {n = 0}) = -≤- z≤n
pred-mono (-≤+ {n = suc n}) = -≤+
pred-mono (-≤- n≤m) = -≤- (s≤s n≤m)
pred-mono (+≤+ m≤n) = ⊖-monoˡ-≤ 1 m≤n
------------------------------------------------------------------------
-- Properties of _*_
------------------------------------------------------------------------
------------------------------------------------------------------------
-- Algebraic properties
*-comm : Commutative _*_
*-comm -[1+ a ] -[1+ b ] rewrite ℕₚ.*-comm (suc a) (suc b) = refl
*-comm -[1+ a ] (+ b ) rewrite ℕₚ.*-comm (suc a) b = refl
*-comm (+ a ) -[1+ b ] rewrite ℕₚ.*-comm a (suc b) = refl
*-comm (+ a ) (+ b ) rewrite ℕₚ.*-comm a b = refl
*-identityˡ : LeftIdentity (+ 1) _*_
*-identityˡ -[1+ n ] rewrite ℕₚ.+-identityʳ n = refl
*-identityˡ +0 = refl
*-identityˡ +[1+ n ] rewrite ℕₚ.+-identityʳ n = refl
*-identityʳ : RightIdentity (+ 1) _*_
*-identityʳ = comm+idˡ⇒idʳ *-comm *-identityˡ
*-identity : Identity (+ 1) _*_
*-identity = *-identityˡ , *-identityʳ
*-zeroˡ : LeftZero +0 _*_
*-zeroˡ n = refl
*-zeroʳ : RightZero +0 _*_
*-zeroʳ = comm+zeˡ⇒zeʳ *-comm *-zeroˡ
*-zero : Zero +0 _*_
*-zero = *-zeroˡ , *-zeroʳ
private
lemma : ∀ a b c → c ℕ.+ (b ℕ.+ a ℕ.* suc b) ℕ.* suc c
≡ c ℕ.+ b ℕ.* suc c ℕ.+ a ℕ.* suc (c ℕ.+ b ℕ.* suc c)
lemma =
solve 3 (λ a b c → c :+ (b :+ a :* (con 1 :+ b)) :* (con 1 :+ c)
:= c :+ b :* (con 1 :+ c) :+
a :* (con 1 :+ (c :+ b :* (con 1 :+ c))))
refl
*-assoc : Associative _*_
*-assoc +0 _ _ = refl
*-assoc x +0 z rewrite ℕₚ.*-zeroʳ ∣ x ∣ = refl
*-assoc x y +0 rewrite
ℕₚ.*-zeroʳ ∣ y ∣
| ℕₚ.*-zeroʳ ∣ x ∣
| ℕₚ.*-zeroʳ ∣ sign x 𝕊* sign y ◃ ∣ x ∣ ℕ.* ∣ y ∣ ∣
= refl
*-assoc -[1+ a ] -[1+ b ] +[1+ c ] = cong (+_ ∘ suc) (lemma a b c)
*-assoc -[1+ a ] +[1+ b ] -[1+ c ] = cong (+_ ∘ suc) (lemma a b c)
*-assoc +[1+ a ] +[1+ b ] +[1+ c ] = cong (+_ ∘ suc) (lemma a b c)
*-assoc +[1+ a ] -[1+ b ] -[1+ c ] = cong (+_ ∘ suc) (lemma a b c)
*-assoc -[1+ a ] -[1+ b ] -[1+ c ] = cong -[1+_] (lemma a b c)
*-assoc -[1+ a ] +[1+ b ] +[1+ c ] = cong -[1+_] (lemma a b c)
*-assoc +[1+ a ] -[1+ b ] +[1+ c ] = cong -[1+_] (lemma a b c)
*-assoc +[1+ a ] +[1+ b ] -[1+ c ] = cong -[1+_] (lemma a b c)
private
-- lemma used to prove distributivity.
distrib-lemma :
∀ a b c → (c ⊖ b) * -[1+ a ] ≡ a ℕ.+ b ℕ.* suc a ⊖ (a ℕ.+ c ℕ.* suc a)
distrib-lemma a b c
rewrite +-cancelˡ-⊖ a (b ℕ.* suc a) (c ℕ.* suc a)
| ⊖-swap (b ℕ.* suc a) (c ℕ.* suc a)
with b ℕ.≤? c
... | yes b≤c
rewrite ⊖-≥ b≤c
| ⊖-≥ (ℕₚ.*-mono-≤ b≤c (ℕₚ.≤-refl {x = suc a}))
| -◃n≡-n ((c ∸ b) ℕ.* suc a)
| ℕₚ.*-distribʳ-∸ (suc a) c b
= refl
... | no b≰c
rewrite sign-⊖-≰ b≰c
| ∣⊖∣-≰ b≰c
| +◃n≡+n ((b ∸ c) ℕ.* suc a)
| ⊖-≰ (b≰c ∘ ℕₚ.*-cancelʳ-≤ b c a)
| neg-involutive (+ (b ℕ.* suc a ∸ c ℕ.* suc a))
| ℕₚ.*-distribʳ-∸ (suc a) b c
= refl
*-distribʳ-+ : _*_ DistributesOverʳ _+_
*-distribʳ-+ +0 y z
rewrite ℕₚ.*-zeroʳ ∣ y ∣
| ℕₚ.*-zeroʳ ∣ z ∣
| ℕₚ.*-zeroʳ ∣ y + z ∣
= refl
*-distribʳ-+ x +0 z
rewrite +-identityˡ z
| +-identityˡ (sign z 𝕊* sign x ◃ ∣ z ∣ ℕ.* ∣ x ∣)
= refl
*-distribʳ-+ x y +0
rewrite +-identityʳ y
| +-identityʳ (sign y 𝕊* sign x ◃ ∣ y ∣ ℕ.* ∣ x ∣)
= refl
*-distribʳ-+ -[1+ a ] -[1+ b ] -[1+ c ] = cong (+_) $
solve 3 (λ a b c → (con 2 :+ b :+ c) :* (con 1 :+ a)
:= (con 1 :+ b) :* (con 1 :+ a) :+
(con 1 :+ c) :* (con 1 :+ a))
refl a b c
*-distribʳ-+ (+ suc a) (+ suc b) (+ suc c) = cong (+_) $
solve 3 (λ a b c → (con 1 :+ b :+ (con 1 :+ c)) :* (con 1 :+ a)
:= (con 1 :+ b) :* (con 1 :+ a) :+
(con 1 :+ c) :* (con 1 :+ a))
refl a b c
*-distribʳ-+ -[1+ a ] (+ suc b) (+ suc c) = cong -[1+_] $
solve 3 (λ a b c → a :+ (b :+ (con 1 :+ c)) :* (con 1 :+ a)
:= (con 1 :+ b) :* (con 1 :+ a) :+
(a :+ c :* (con 1 :+ a)))
refl a b c
*-distribʳ-+ (+ suc a) -[1+ b ] -[1+ c ] = cong -[1+_] $
solve 3 (λ a b c → a :+ (con 1 :+ a :+ (b :+ c) :* (con 1 :+ a))
:= (con 1 :+ b) :* (con 1 :+ a) :+
(a :+ c :* (con 1 :+ a)))
refl a b c
*-distribʳ-+ -[1+ a ] -[1+ b ] (+ suc c) = distrib-lemma a b c
*-distribʳ-+ -[1+ a ] (+ suc b) -[1+ c ] = distrib-lemma a c b
*-distribʳ-+ (+ suc a) -[1+ b ] (+ suc c) with b ℕ.≤? c
... | yes b≤c
rewrite +-cancelˡ-⊖ a (c ℕ.* suc a) (b ℕ.* suc a)
| ⊖-≥ b≤c
| +-comm (- (+ (a ℕ.+ b ℕ.* suc a))) (+ (a ℕ.+ c ℕ.* suc a))
| ⊖-≥ (ℕₚ.*-mono-≤ b≤c (ℕₚ.≤-refl {x = suc a}))
| ℕₚ.*-distribʳ-∸ (suc a) c b
| +◃n≡+n (c ℕ.* suc a ∸ b ℕ.* suc a)
= refl
... | no b≰c
rewrite +-cancelˡ-⊖ a (c ℕ.* suc a) (b ℕ.* suc a)
| sign-⊖-≰ b≰c
| ∣⊖∣-≰ b≰c
| -◃n≡-n ((b ∸ c) ℕ.* suc a)
| ⊖-≰ (b≰c ∘ ℕₚ.*-cancelʳ-≤ b c a)
| ℕₚ.*-distribʳ-∸ (suc a) b c
= refl
*-distribʳ-+ (+ suc c) (+ suc a) -[1+ b ] with b ℕ.≤? a
... | yes b≤a
rewrite +-cancelˡ-⊖ c (a ℕ.* suc c) (b ℕ.* suc c)
| ⊖-≥ b≤a
| ⊖-≥ (ℕₚ.*-mono-≤ b≤a (ℕₚ.≤-refl {x = suc c}))
| +◃n≡+n ((a ∸ b) ℕ.* suc c)
| ℕₚ.*-distribʳ-∸ (suc c) a b
= refl
... | no b≰a
rewrite +-cancelˡ-⊖ c (a ℕ.* suc c) (b ℕ.* suc c)
| sign-⊖-≰ b≰a
| ∣⊖∣-≰ b≰a
| ⊖-≰ (b≰a ∘ ℕₚ.*-cancelʳ-≤ b a c)
| -◃n≡-n ((b ∸ a) ℕ.* suc c)
| ℕₚ.*-distribʳ-∸ (suc c) b a
= refl
*-distribˡ-+ : _*_ DistributesOverˡ _+_
*-distribˡ-+ = comm+distrʳ⇒distrˡ *-comm *-distribʳ-+
*-distrib-+ : _*_ DistributesOver _+_
*-distrib-+ = *-distribˡ-+ , *-distribʳ-+
------------------------------------------------------------------------
-- Structures
*-isMagma : IsMagma _*_
*-isMagma = record
{ isEquivalence = isEquivalence
; ∙-cong = cong₂ _*_
}
*-isSemigroup : IsSemigroup _*_
*-isSemigroup = record
{ isMagma = *-isMagma
; assoc = *-assoc
}
*-isCommutativeSemigroup : IsCommutativeSemigroup _*_
*-isCommutativeSemigroup = record
{ isSemigroup = *-isSemigroup
; comm = *-comm
}
*-1-isMonoid : IsMonoid _*_ (+ 1)
*-1-isMonoid = record
{ isSemigroup = *-isSemigroup
; identity = *-identity
}
*-1-isCommutativeMonoid : IsCommutativeMonoid _*_ (+ 1)
*-1-isCommutativeMonoid = record
{ isMonoid = *-1-isMonoid
; comm = *-comm
}
+-*-isSemiring : IsSemiring _+_ _*_ +0 (+ 1)
+-*-isSemiring = record
{ isSemiringWithoutAnnihilatingZero = record
{ +-isCommutativeMonoid = +-0-isCommutativeMonoid
; *-isMonoid = *-1-isMonoid
; distrib = *-distrib-+
}
; zero = *-zero
}
+-*-isCommutativeSemiring : IsCommutativeSemiring _+_ _*_ +0 (+ 1)
+-*-isCommutativeSemiring = record
{ isSemiring = +-*-isSemiring
; *-comm = *-comm
}
+-*-isRing : IsRing _+_ _*_ -_ +0 (+ 1)
+-*-isRing = record
{ +-isAbelianGroup = +-isAbelianGroup
; *-isMonoid = *-1-isMonoid
; distrib = *-distrib-+
; zero = *-zero
}
+-*-isCommutativeRing : IsCommutativeRing _+_ _*_ -_ +0 (+ 1)
+-*-isCommutativeRing = record
{ isRing = +-*-isRing
; *-comm = *-comm
}
------------------------------------------------------------------------
-- Bundles
*-magma : Magma 0ℓ 0ℓ
*-magma = record
{ isMagma = *-isMagma
}
*-semigroup : Semigroup 0ℓ 0ℓ
*-semigroup = record
{ isSemigroup = *-isSemigroup
}
*-commutativeSemigroup : CommutativeSemigroup 0ℓ 0ℓ
*-commutativeSemigroup = record
{ isCommutativeSemigroup = *-isCommutativeSemigroup
}
*-1-monoid : Monoid 0ℓ 0ℓ
*-1-monoid = record
{ isMonoid = *-1-isMonoid
}
*-1-commutativeMonoid : CommutativeMonoid 0ℓ 0ℓ
*-1-commutativeMonoid = record
{ isCommutativeMonoid = *-1-isCommutativeMonoid
}
+-*-semiring : Semiring 0ℓ 0ℓ
+-*-semiring = record
{ isSemiring = +-*-isSemiring
}
+-*-ring : Ring 0ℓ 0ℓ
+-*-ring = record
{ isRing = +-*-isRing
}
+-*-commutativeRing : CommutativeRing 0ℓ 0ℓ
+-*-commutativeRing = record
{ isCommutativeRing = +-*-isCommutativeRing
}
------------------------------------------------------------------------
-- Other properties of _*_ and _≡_
abs-*-commute : ℤtoℕ.Homomorphic₂ ∣_∣ _*_ ℕ._*_
abs-*-commute i j = abs-◃ _ _
*-cancelʳ-≡ : ∀ i j k → k ≢ + 0 → i * k ≡ j * k → i ≡ j
*-cancelʳ-≡ i j k ≢0 eq with signAbs k
*-cancelʳ-≡ i j .+0 ≢0 eq | s ◂ zero = contradiction refl ≢0
*-cancelʳ-≡ i j .(s ◃ suc n) ≢0 eq | s ◂ suc n
with ∣ s ◃ suc n ∣ | abs-◃ s (suc n) | sign (s ◃ suc n) | sign-◃ s n
... | .(suc n) | refl | .s | refl =
◃-cong (sign-i≡sign-j i j eq) $
ℕₚ.*-cancelʳ-≡ ∣ i ∣ ∣ j ∣ $ abs-cong eq
where
sign-i≡sign-j : ∀ i j →
(sign i 𝕊* s) ◃ (∣ i ∣ ℕ.* suc n) ≡
(sign j 𝕊* s) ◃ (∣ j ∣ ℕ.* suc n) →
sign i ≡ sign j
sign-i≡sign-j i j eq with signAbs i | signAbs j
sign-i≡sign-j .+0 .+0 eq | s₁ ◂ zero | s₂ ◂ zero = refl
sign-i≡sign-j .+0 .(s₂ ◃ suc n₂) eq | s₁ ◂ zero | s₂ ◂ suc n₂
with ∣ s₂ ◃ suc n₂ ∣ | abs-◃ s₂ (suc n₂)
... | .(suc n₂) | refl
with abs-cong {s₁} {sign (s₂ ◃ suc n₂) 𝕊* s} {0} {suc n₂ ℕ.* suc n} eq
... | ()
sign-i≡sign-j .(s₁ ◃ suc n₁) .+0 eq | s₁ ◂ suc n₁ | s₂ ◂ zero
with ∣ s₁ ◃ suc n₁ ∣ | abs-◃ s₁ (suc n₁)
... | .(suc n₁) | refl
with abs-cong {sign (s₁ ◃ suc n₁) 𝕊* s} {s₁} {suc n₁ ℕ.* suc n} {0} eq
... | ()
sign-i≡sign-j .(s₁ ◃ suc n₁) .(s₂ ◃ suc n₂) eq | s₁ ◂ suc n₁ | s₂ ◂ suc n₂
with ∣ s₁ ◃ suc n₁ ∣ | abs-◃ s₁ (suc n₁)
| sign (s₁ ◃ suc n₁) | sign-◃ s₁ n₁
| ∣ s₂ ◃ suc n₂ ∣ | abs-◃ s₂ (suc n₂)
| sign (s₂ ◃ suc n₂) | sign-◃ s₂ n₂
... | .(suc n₁) | refl | .s₁ | refl | .(suc n₂) | refl | .s₂ | refl =
𝕊ₚ.*-cancelʳ-≡ s₁ s₂ (sign-cong eq)
*-cancelˡ-≡ : ∀ i j k → i ≢ + 0 → i * j ≡ i * k → j ≡ k
*-cancelˡ-≡ i j k
rewrite *-comm i j
| *-comm i k
= *-cancelʳ-≡ j k i
suc-* : ∀ m n → sucℤ m * n ≡ n + m * n
suc-* m n = begin
sucℤ m * n ≡⟨ *-distribʳ-+ n (+ 1) m ⟩
+ 1 * n + m * n ≡⟨ cong (_+ m * n) (*-identityˡ n) ⟩
n + m * n ∎
where open ≡-Reasoning
*-suc : ∀ m n → m * sucℤ n ≡ m + m * n
*-suc m n = begin
m * sucℤ n ≡⟨ *-comm m _ ⟩
sucℤ n * m ≡⟨ suc-* n m ⟩
m + n * m ≡⟨ cong (λ v → m + v) (*-comm n m) ⟩
m + m * n ∎
where open ≡-Reasoning
-1*n≡-n : ∀ n → -[1+ 0 ] * n ≡ - n
-1*n≡-n -[1+ n ] = cong (λ v → + suc v) (ℕₚ.+-identityʳ n)
-1*n≡-n +0 = refl
-1*n≡-n +[1+ n ] = cong -[1+_] (ℕₚ.+-identityʳ n)
------------------------------------------------------------------------
-- Properties of _*_ and +_/-_
pos-distrib-* : ∀ x y → (+ x) * (+ y) ≡ + (x ℕ.* y)
pos-distrib-* zero y = refl
pos-distrib-* (suc x) zero = pos-distrib-* x zero
pos-distrib-* (suc x) (suc y) = refl
neg-distribˡ-* : ∀ x y → - (x * y) ≡ (- x) * y
neg-distribˡ-* x y = begin
- (x * y) ≡⟨ sym (-1*n≡-n (x * y)) ⟩
-[1+ 0 ] * (x * y) ≡⟨ sym (*-assoc -[1+ 0 ] x y) ⟩
-[1+ 0 ] * x * y ≡⟨ cong (_* y) (-1*n≡-n x) ⟩
- x * y ∎ where open ≡-Reasoning
neg-distribʳ-* : ∀ x y → - (x * y) ≡ x * (- y)
neg-distribʳ-* x y = begin
- (x * y) ≡⟨ cong -_ (*-comm x y) ⟩
- (y * x) ≡⟨ neg-distribˡ-* y x ⟩
- y * x ≡⟨ *-comm (- y) x ⟩
x * (- y) ∎ where open ≡-Reasoning
------------------------------------------------------------------------
-- Properties of _*_ and _◃_
◃-distrib-* : ∀ s t m n → (s 𝕊* t) ◃ (m ℕ.* n) ≡ (s ◃ m) * (t ◃ n)
◃-distrib-* s t zero zero = refl
◃-distrib-* s t zero (suc n) = refl
◃-distrib-* s t (suc m) zero =
trans
(cong₂ _◃_ (𝕊ₚ.*-comm s t) (ℕₚ.*-comm m 0))
(*-comm (t ◃ zero) (s ◃ suc m))
◃-distrib-* s t (suc m) (suc n) =
sym (cong₂ _◃_
(cong₂ _𝕊*_ (sign-◃ s m) (sign-◃ t n))
(∣s◃m∣*∣t◃n∣≡m*n s t (suc m) (suc n)))
------------------------------------------------------------------------
-- Properties of _*_ and _≤_
*-cancelʳ-≤-pos : ∀ m n o → m * + suc o ≤ n * + suc o → m ≤ n
*-cancelʳ-≤-pos (-[1+ m ]) (-[1+ n ]) o (-≤- n≤m) =
-≤- (ℕₚ.≤-pred (ℕₚ.*-cancelʳ-≤ (suc n) (suc m) o (s≤s n≤m)))
*-cancelʳ-≤-pos -[1+ _ ] (+ _) _ _ = -≤+
*-cancelʳ-≤-pos +0 +0 _ _ = +≤+ z≤n
*-cancelʳ-≤-pos +0 (+ suc _) _ _ = +≤+ z≤n
*-cancelʳ-≤-pos (+ suc _) +0 _ (+≤+ ())
*-cancelʳ-≤-pos (+ suc m) (+ suc n) o (+≤+ m≤n) =
+≤+ (ℕₚ.*-cancelʳ-≤ (suc m) (suc n) o m≤n)
*-cancelˡ-≤-pos : ∀ m n o → + suc m * n ≤ + suc m * o → n ≤ o
*-cancelˡ-≤-pos m n o
rewrite *-comm (+ suc m) n
| *-comm (+ suc m) o
= *-cancelʳ-≤-pos n o m
*-monoʳ-≤-pos : ∀ n → (_* + suc n) Preserves _≤_ ⟶ _≤_
*-monoʳ-≤-pos _ (-≤+ {n = 0}) = -≤+
*-monoʳ-≤-pos _ (-≤+ {n = suc _}) = -≤+
*-monoʳ-≤-pos x (-≤- n≤m) =
-≤- (ℕₚ.≤-pred (ℕₚ.*-mono-≤ (s≤s n≤m) (ℕₚ.≤-refl {x = suc x})))
*-monoʳ-≤-pos k {+ 0} {+ 0} (+≤+ m≤n) = +≤+ m≤n
*-monoʳ-≤-pos k {+ 0} {+ suc _} (+≤+ m≤n) = +≤+ z≤n
*-monoʳ-≤-pos x (+≤+ {m = suc _} {n = suc _} m≤n) =
+≤+ ((ℕₚ.*-mono-≤ m≤n (ℕₚ.≤-refl {x = suc x})))
*-monoʳ-≤-non-neg : ∀ n → (_* + n) Preserves _≤_ ⟶ _≤_
*-monoʳ-≤-non-neg (suc n) = *-monoʳ-≤-pos n
*-monoʳ-≤-non-neg zero {i} {j} i≤j
rewrite *-zeroʳ i
| *-zeroʳ j
= +≤+ z≤n
*-monoˡ-≤-non-neg : ∀ n → (+ n *_) Preserves _≤_ ⟶ _≤_
*-monoˡ-≤-non-neg n {i} {j} i≤j
rewrite *-comm (+ n) i
| *-comm (+ n) j
= *-monoʳ-≤-non-neg n i≤j
*-monoˡ-≤-pos : ∀ n → (+ suc n *_) Preserves _≤_ ⟶ _≤_
*-monoˡ-≤-pos n = *-monoˡ-≤-non-neg (suc n)
------------------------------------------------------------------------
-- Properties of _*_ and _≤_
*-monoˡ-<-pos : ∀ n → (+[1+ n ] *_) Preserves _<_ ⟶ _<_
*-monoˡ-<-pos n {+ m} {+ o} (+<+ m<o) = +◃-mono-< (ℕₚ.+-mono-<-≤ m<o (ℕₚ.*-monoʳ-≤ n (ℕₚ.<⇒≤ m<o)))
*-monoˡ-<-pos n { -[1+ m ]} {+ o} leq = -◃<+◃ _ (suc n ℕ.* o)
*-monoˡ-<-pos n { -[1+ m ]} { -[1+ o ]} (-<- o<m) = -<- (ℕₚ.+-mono-<-≤ o<m (ℕₚ.*-monoʳ-≤ n (ℕₚ.<⇒≤ (s≤s o<m))))
*-monoʳ-<-pos : ∀ n → (_* +[1+ n ]) Preserves _<_ ⟶ _<_
*-monoʳ-<-pos n {m} {o} rewrite *-comm m +[1+ n ] | *-comm o +[1+ n ]
= *-monoˡ-<-pos n
*-cancelˡ-<-non-neg : ∀ n {i j} → + n * i < + n * j → i < j
*-cancelˡ-<-non-neg n {+ i} {+ j} leq = +<+ (ℕₚ.*-cancelˡ-< n (+◃-cancel-< leq))
*-cancelˡ-<-non-neg n {+ i} { -[1+ j ]} leq = contradiction leq +◃≮-◃
*-cancelˡ-<-non-neg n { -[1+ i ]} {+ j} leq = -<+
*-cancelˡ-<-non-neg n { -[1+ i ]} { -[1+ j ]} leq = -<- (ℕₚ.≤-pred (ℕₚ.*-cancelˡ-< n (neg◃-cancel-< leq)))
*-cancelʳ-<-non-neg : ∀ {i j} n → i * + n < j * + n → i < j
*-cancelʳ-<-non-neg {i} {j} n rewrite *-comm i (+ n) | *-comm j (+ n)
= *-cancelˡ-<-non-neg n
------------------------------------------------------------------------
-- Properties of _⊓_
------------------------------------------------------------------------
------------------------------------------------------------------------
-- Algebraic properties
⊓-comm : Commutative _⊓_
⊓-comm -[1+ m ] -[1+ n ] = cong -[1+_] (ℕₚ.⊔-comm m n)
⊓-comm -[1+ m ] (+ n) = refl
⊓-comm (+ m) -[1+ n ] = refl
⊓-comm (+ m) (+ n) = cong +_ (ℕₚ.⊓-comm m n)
⊓-assoc : Associative _⊓_
⊓-assoc -[1+ m ] -[1+ n ] -[1+ p ] = cong -[1+_] (ℕₚ.⊔-assoc m n p)
⊓-assoc -[1+ m ] -[1+ n ] (+ p) = refl
⊓-assoc -[1+ m ] (+ n) -[1+ p ] = refl
⊓-assoc -[1+ m ] (+ n) (+ p) = refl
⊓-assoc (+ m) -[1+ n ] -[1+ p ] = refl
⊓-assoc (+ m) -[1+ n ] (+ p) = refl
⊓-assoc (+ m) (+ n) -[1+ p ] = refl
⊓-assoc (+ m) (+ n) (+ p) = cong +_ (ℕₚ.⊓-assoc m n p)
⊓-idem : Idempotent _⊓_
⊓-idem (+ m) = cong +_ (ℕₚ.⊓-idem m)
⊓-idem -[1+ m ] = cong -[1+_] (ℕₚ.⊔-idem m)
⊓-sel : Selective _⊓_
⊓-sel -[1+ m ] -[1+ n ] = Sum.map (cong -[1+_]) (cong -[1+_]) $ ℕₚ.⊔-sel m n
⊓-sel -[1+ m ] (+ n) = inj₁ refl
⊓-sel (+ m) -[1+ n ] = inj₂ refl
⊓-sel (+ m) (+ n) = Sum.map (cong ℤ.pos) (cong ℤ.pos) $ ℕₚ.⊓-sel m n
------------------------------------------------------------------------
-- Other properties
m≤n⇒m⊓n≡m : ∀ {m n} → m ≤ n → m ⊓ n ≡ m
m≤n⇒m⊓n≡m -≤+ = refl
m≤n⇒m⊓n≡m (-≤- n≤m) = cong -[1+_] (ℕₚ.m≤n⇒n⊔m≡n n≤m)
m≤n⇒m⊓n≡m (+≤+ m≤n) = cong +_ (ℕₚ.m≤n⇒m⊓n≡m m≤n)
m⊓n≡m⇒m≤n : ∀ {m n} → m ⊓ n ≡ m → m ≤ n
m⊓n≡m⇒m≤n { -[1+ m ]} { -[1+ n ]} eq = -≤- (ℕₚ.n⊔m≡n⇒m≤n (-[1+-injective eq))
m⊓n≡m⇒m≤n { -[1+ m ]} {+ n} eq = -≤+
m⊓n≡m⇒m≤n {+ m} {+ n} eq = +≤+ (ℕₚ.m⊓n≡m⇒m≤n (+-injective eq))
m≥n⇒m⊓n≡n : ∀ {m n} → m ≥ n → m ⊓ n ≡ n
m≥n⇒m⊓n≡n {m} {n} pr rewrite ⊓-comm m n = m≤n⇒m⊓n≡m pr
m⊓n≡n⇒m≥n : ∀ {m n} → m ⊓ n ≡ n → m ≥ n
m⊓n≡n⇒m≥n {m} {n} eq rewrite ⊓-comm m n = m⊓n≡m⇒m≤n eq
m⊓n≤n : ∀ m n → m ⊓ n ≤ n
m⊓n≤n -[1+ m ] -[1+ n ] = -≤- (ℕₚ.n≤m⊔n m n)
m⊓n≤n -[1+ m ] (+ n) = -≤+
m⊓n≤n (+ m) -[1+ n ] = -≤- ℕₚ.≤-refl
m⊓n≤n (+ m) (+ n) = +≤+ (ℕₚ.m⊓n≤n m n)
m⊓n≤m : ∀ m n → m ⊓ n ≤ m
m⊓n≤m m n rewrite ⊓-comm m n = m⊓n≤n n m
------------------------------------------------------------------------
-- Properties _⊔_
------------------------------------------------------------------------
------------------------------------------------------------------------
-- Algebraic properties
⊔-assoc : Associative _⊔_
⊔-assoc -[1+ m ] -[1+ n ] -[1+ p ] = cong -[1+_] (ℕₚ.⊓-assoc m n p)
⊔-assoc -[1+ m ] -[1+ n ] (+ p) = refl
⊔-assoc -[1+ m ] (+ n) -[1+ p ] = refl
⊔-assoc -[1+ m ] (+ n) (+ p) = refl
⊔-assoc (+ m) -[1+ n ] -[1+ p ] = refl
⊔-assoc (+ m) -[1+ n ] (+ p) = refl
⊔-assoc (+ m) (+ n) -[1+ p ] = refl
⊔-assoc (+ m) (+ n) (+ p) = cong +_ (ℕₚ.⊔-assoc m n p)
⊔-comm : Commutative _⊔_
⊔-comm -[1+ m ] -[1+ n ] = cong -[1+_] (ℕₚ.⊓-comm m n)
⊔-comm -[1+ m ] (+ n) = refl
⊔-comm (+ m) -[1+ n ] = refl
⊔-comm (+ m) (+ n) = cong +_ (ℕₚ.⊔-comm m n)
⊔-idem : Idempotent _⊔_
⊔-idem (+ m) = cong +_ (ℕₚ.⊔-idem m)
⊔-idem -[1+ m ] = cong -[1+_] (ℕₚ.⊓-idem m)
⊔-sel : Selective _⊔_
⊔-sel -[1+ m ] -[1+ n ] = Sum.map (cong -[1+_]) (cong -[1+_]) $ ℕₚ.⊓-sel m n
⊔-sel -[1+ m ] (+ n) = inj₂ refl
⊔-sel (+ m) -[1+ n ] = inj₁ refl
⊔-sel (+ m) (+ n) = Sum.map (cong ℤ.pos) (cong ℤ.pos) $ ℕₚ.⊔-sel m n
------------------------------------------------------------------------
-- Other properties
m≤n⇒m⊔n≡n : ∀ {m n} → m ≤ n → m ⊔ n ≡ n
m≤n⇒m⊔n≡n -≤+ = refl
m≤n⇒m⊔n≡n (-≤- n≤m) = cong -[1+_] (ℕₚ.m≤n⇒n⊓m≡m n≤m)
m≤n⇒m⊔n≡n (+≤+ m≤n) = cong +_ (ℕₚ.m≤n⇒m⊔n≡n m≤n)
m⊔n≡n⇒m≤n : ∀ {m n} → m ⊔ n ≡ n → m ≤ n
m⊔n≡n⇒m≤n { -[1+ m ]} { -[1+ n ]} eq = -≤- (ℕₚ.m⊓n≡n⇒n≤m (-[1+-injective eq))
m⊔n≡n⇒m≤n { -[1+ m ]} {+ n} eq = -≤+
m⊔n≡n⇒m≤n {+ m} {+ n} eq = +≤+ (ℕₚ.n⊔m≡m⇒n≤m (+-injective eq))
m≥n⇒m⊔n≡m : ∀ {m n} → m ≥ n → m ⊔ n ≡ m
m≥n⇒m⊔n≡m {m} {n} pr rewrite ⊔-comm m n = m≤n⇒m⊔n≡n pr
m⊔n≡m⇒m≥n : ∀ {m n} → m ⊔ n ≡ m → m ≥ n
m⊔n≡m⇒m≥n {m} {n} eq rewrite ⊔-comm m n = m⊔n≡n⇒m≤n eq
m≤m⊔n : ∀ m n → m ≤ m ⊔ n
m≤m⊔n -[1+ m ] -[1+ n ] = -≤- (ℕₚ.m⊓n≤m m n)
m≤m⊔n -[1+ m ] (+ n) = -≤+
m≤m⊔n (+ m) -[1+ n ] = +≤+ ℕₚ.≤-refl
m≤m⊔n (+ m) (+ n) = +≤+ (ℕₚ.m≤m⊔n m n)
n≤m⊔n : ∀ m n → n ≤ m ⊔ n
n≤m⊔n m n rewrite ⊔-comm m n = m≤m⊔n n m
neg-distrib-⊔-⊓ : ∀ m n → - (m ⊔ n) ≡ - m ⊓ - n
neg-distrib-⊔-⊓ -[1+ m ] -[1+ n ] = refl
neg-distrib-⊔-⊓ -[1+ m ] +0 = refl
neg-distrib-⊔-⊓ -[1+ m ] +[1+ n ] = refl
neg-distrib-⊔-⊓ +0 -[1+ n ] = refl
neg-distrib-⊔-⊓ +0 +0 = refl
neg-distrib-⊔-⊓ +0 +[1+ n ] = refl
neg-distrib-⊔-⊓ +[1+ m ] -[1+ n ] = refl
neg-distrib-⊔-⊓ +[1+ m ] +0 = refl
neg-distrib-⊔-⊓ +[1+ m ] +[1+ n ] = refl
neg-distrib-⊓-⊔ : ∀ m n → - (m ⊓ n) ≡ - m ⊔ - n
neg-distrib-⊓-⊔ -[1+ m ] -[1+ n ] = refl
neg-distrib-⊓-⊔ -[1+ m ] +0 = refl
neg-distrib-⊓-⊔ -[1+ m ] +[1+ n ] = refl
neg-distrib-⊓-⊔ +0 -[1+ n ] = refl
neg-distrib-⊓-⊔ +0 +0 = refl
neg-distrib-⊓-⊔ +0 +[1+ n ] = refl
neg-distrib-⊓-⊔ +[1+ m ] -[1+ n ] = refl
neg-distrib-⊓-⊔ +[1+ m ] +0 = refl
neg-distrib-⊓-⊔ +[1+ m ] +[1+ n ] = refl
------------------------------------------------------------------------
-- DEPRECATED NAMES
------------------------------------------------------------------------
-- Please use the new names as continuing support for the old names is
-- not guaranteed.
-- Version 0.15
inverseˡ = +-inverseˡ
{-# WARNING_ON_USAGE inverseˡ
"Warning: inverseˡ was deprecated in v0.15.
Please use +-inverseˡ instead."
#-}
inverseʳ = +-inverseʳ
{-# WARNING_ON_USAGE inverseʳ
"Warning: inverseʳ was deprecated in v0.15.
Please use +-inverseʳ instead."
#-}
distribʳ = *-distribʳ-+
{-# WARNING_ON_USAGE distribʳ
"Warning: distribʳ was deprecated in v0.15.
Please use *-distribʳ-+ instead."
#-}
isCommutativeSemiring = +-*-isCommutativeSemiring
{-# WARNING_ON_USAGE isCommutativeSemiring
"Warning: isCommutativeSemiring was deprecated in v0.15.
Please use +-*-isCommutativeSemiring instead."
#-}
commutativeRing = +-*-commutativeRing
{-# WARNING_ON_USAGE commutativeRing
"Warning: commutativeRing was deprecated in v0.15.
Please use +-*-commutativeRing instead."
#-}
*-+-right-mono = *-monoʳ-≤-pos
{-# WARNING_ON_USAGE *-+-right-mono
"Warning: *-+-right-mono was deprecated in v0.15.
Please use *-monoʳ-≤-pos instead."
#-}
cancel-*-+-right-≤ = *-cancelʳ-≤-pos
{-# WARNING_ON_USAGE cancel-*-+-right-≤
"Warning: cancel-*-+-right-≤ was deprecated in v0.15.
Please use *-cancelʳ-≤-pos instead."
#-}
cancel-*-right = *-cancelʳ-≡
{-# WARNING_ON_USAGE cancel-*-right
"Warning: cancel-*-right was deprecated in v0.15.
Please use *-cancelʳ-≡ instead."
#-}
doubleNeg = neg-involutive
{-# WARNING_ON_USAGE doubleNeg
"Warning: doubleNeg was deprecated in v0.15.
Please use neg-involutive instead."
#-}
-‿involutive = neg-involutive
{-# WARNING_ON_USAGE -‿involutive
"Warning: -‿involutive was deprecated in v0.15.
Please use neg-involutive instead."
#-}
+-⊖-left-cancel = +-cancelˡ-⊖
{-# WARNING_ON_USAGE +-⊖-left-cancel
"Warning: +-⊖-left-cancel was deprecated in v0.15.
Please use +-cancelˡ-⊖ instead."
#-}
-- Version 1.0
≰→> = ≰⇒>
{-# WARNING_ON_USAGE ≰→>
"Warning: ≰→> was deprecated in v1.0.
Please use ≰⇒> instead."
#-}
≤-irrelevance = ≤-irrelevant
{-# WARNING_ON_USAGE ≤-irrelevance
"Warning: ≤-irrelevance was deprecated in v1.0.
Please use ≤-irrelevant instead."
#-}
<-irrelevance = <-irrelevant
{-# WARNING_ON_USAGE <-irrelevance
"Warning: <-irrelevance was deprecated in v1.0.
Please use <-irrelevant instead."
#-}
-- Version 1.1
-- Not all of the below have deprecation warnings attached as they are
-- reused by other deprecated results.
-<′+ : ∀ {m n} → -[1+ m ] <′ + n
-<′+ {0} = +≤+ z≤n
-<′+ {suc _} = -≤+
{-# WARNING_ON_USAGE -<′+
"Warning: _<′_ was deprecated in v1.1.
Please use _<_ instead."
#-}
<′-irrefl : Irreflexive _≡_ _<′_
<′-irrefl { + n} refl (+≤+ 1+n≤n) = ℕₚ.<-irrefl refl 1+n≤n
<′-irrefl { -[1+ suc n ]} refl (-≤- 1+n≤n) = ℕₚ.<-irrefl refl 1+n≤n
{-# WARNING_ON_USAGE <′-irrefl
"Warning: _<′_ was deprecated in v1.1.
Please use _<_ instead."
#-}
>′-irrefl : Irreflexive _≡_ _>′_
>′-irrefl = <′-irrefl ∘ sym
{-# WARNING_ON_USAGE >′-irrefl
"Warning: _>′_ was deprecated in v1.1.
Please use _>_ instead."
#-}
<′-asym : Asymmetric _<′_
<′-asym {+ n} {+ m} (+≤+ n<m) (+≤+ m<n) = ℕₚ.<-asym n<m m<n
<′-asym { -[1+ suc n ]} { -[1+ suc m ]} (-≤- n<m) (-≤- m<n) = ℕₚ.<-asym n<m m<n
{-# WARNING_ON_USAGE <′-asym
"Warning: _<′_ was deprecated in v1.1.
Please use _<_ instead."
#-}
≤-<′-trans : Trans _≤_ _<′_ _<′_
≤-<′-trans { -[1+ m ]} {+ n} {+ p} -≤+ (+≤+ 1+n≤p) = -<′+ {m} {p}
≤-<′-trans {+ m} {+ n} {+ p} (+≤+ m≤n) (+≤+ 1+n≤p) = +≤+ (ℕₚ.≤-trans (ℕ.s≤s m≤n) 1+n≤p)
≤-<′-trans { -[1+ m ]} { -[1+ n ]} (-≤- n≤m) n<p = ≤-trans (⊖-monoʳ-≥-≤ 0 n≤m) n<p
{-# WARNING_ON_USAGE ≤-<′-trans
"Warning: _<′_ was deprecated in v1.1.
Please use _<_ instead."
#-}
<′-≤-trans : Trans _<′_ _≤_ _<′_
<′-≤-trans = ≤-trans
{-# WARNING_ON_USAGE <′-≤-trans
"Warning: _<′_ was deprecated in v1.1.
Please use _<_ instead."
#-}
<′⇒≤ : ∀ {m n} → m <′ n → m ≤ n
<′⇒≤ m<n = ≤-trans (n≤1+n _) m<n
{-# WARNING_ON_USAGE <′⇒≤
"Warning: _<′_ was deprecated in v1.1.
Please use _<_ instead."
#-}
<′-trans : Transitive _<′_
<′-trans {m} {n} {p} m<n n<p = ≤-<′-trans {m} {n} {p} (<′⇒≤ m<n) n<p
{-# WARNING_ON_USAGE <′-trans
"Warning: _<′_ was deprecated in v1.1.
Please use _<_ instead."
#-}
<′-cmp : Trichotomous _≡_ _<′_
<′-cmp (+ m) (+ n) with ℕₚ.<-cmp m n
... | tri< m<n m≢n m≯n =
tri< (+≤+ m<n) (m≢n ∘ +-injective) (m≯n ∘ drop‿+≤+)
... | tri≈ m≮n m≡n m≯n =
tri≈ (m≮n ∘ drop‿+≤+) (cong (+_) m≡n) (m≯n ∘ drop‿+≤+)
... | tri> m≮n m≢n m>n =
tri> (m≮n ∘ drop‿+≤+) (m≢n ∘ +-injective) (+≤+ m>n)
<′-cmp (+_ m) -[1+ 0 ] = tri> (λ()) (λ()) (+≤+ z≤n)
<′-cmp (+_ m) -[1+ suc n ] = tri> (λ()) (λ()) -≤+
<′-cmp -[1+ 0 ] (+ n) = tri< (+≤+ z≤n) (λ()) (λ())
<′-cmp -[1+ suc m ] (+ n) = tri< -≤+ (λ()) (λ())
<′-cmp -[1+ 0 ] -[1+ 0 ] = tri≈ (λ()) refl (λ())
<′-cmp -[1+ 0 ] -[1+ suc n ] = tri> (λ()) (λ()) (-≤- z≤n)
<′-cmp -[1+ suc m ] -[1+ 0 ] = tri< (-≤- z≤n) (λ()) (λ())
<′-cmp -[1+ suc m ] -[1+ suc n ] with ℕₚ.<-cmp (suc m) (suc n)
... | tri< m<n m≢n m≯n =
tri> (m≯n ∘ s≤s ∘ drop‿-≤-) (m≢n ∘ -[1+-injective) (-≤- (ℕₚ.≤-pred m<n))
... | tri≈ m≮n m≡n m≯n =
tri≈ (m≯n ∘ ℕ.s≤s ∘ drop‿-≤-) (cong -[1+_] m≡n) (m≮n ∘ ℕ.s≤s ∘ drop‿-≤-)
... | tri> m≮n m≢n m>n =
tri< (-≤- (ℕₚ.≤-pred m>n)) (m≢n ∘ -[1+-injective) (m≮n ∘ s≤s ∘ drop‿-≤-)
{-# WARNING_ON_USAGE <′-cmp
"Warning: _<′_ was deprecated in v1.1.
Please use _<_ instead."
#-}
<′-isStrictPartialOrder : IsStrictPartialOrder _≡_ _<′_
<′-isStrictPartialOrder = record
{ isEquivalence = isEquivalence
; irrefl = <′-irrefl
; trans = λ {i} → <′-trans {i}
; <-resp-≈ = (λ {x} → subst (x <′_)) , subst (_<′ _)
}
{-# WARNING_ON_USAGE <′-isStrictPartialOrder
"Warning: _<′_ was deprecated in v1.1.
Please use _<_ instead."
#-}
<′-strictPartialOrder : StrictPartialOrder _ _ _
<′-strictPartialOrder = record
{ isStrictPartialOrder = <′-isStrictPartialOrder
}
{-# WARNING_ON_USAGE <′-strictPartialOrder
"Warning: _<′_ was deprecated in v1.1.
Please use _<_ instead."
#-}
<′-isStrictTotalOrder : IsStrictTotalOrder _≡_ _<′_
<′-isStrictTotalOrder = record
{ isEquivalence = isEquivalence
; trans = λ {i} → <′-trans {i}
; compare = <′-cmp
}
{-# WARNING_ON_USAGE <′-isStrictTotalOrder
"Warning: _<′_ was deprecated in v1.1.
Please use _<_ instead."
#-}
<′-strictTotalOrder : StrictTotalOrder _ _ _
<′-strictTotalOrder = record
{ isStrictTotalOrder = <′-isStrictTotalOrder
}
{-# WARNING_ON_USAGE <′-strictTotalOrder
"Warning: _<′_ was deprecated in v1.1.
Please use _<_ instead."
#-}
n≮′n : ∀ {n} → n ≮′ n
n≮′n {+ n} (+≤+ n<n) = contradiction n<n ℕₚ.1+n≰n
n≮′n { -[1+ suc n ]} (-≤- n<n) = contradiction n<n ℕₚ.1+n≰n
{-# WARNING_ON_USAGE n≮′n
"Warning: n≮′n was deprecated in v1.1.
Please use n≮n instead."
#-}
>′⇒≰′ : ∀ {x y} → x >′ y → x ≰ y
>′⇒≰′ {y = y} x>y x≤y = contradiction (<′-≤-trans {i = y} x>y x≤y) n≮′n
{-# WARNING_ON_USAGE >′⇒≰′
"Warning: _<′_ was deprecated in v1.1.
Please use _<_ instead."
#-}
≰⇒>′ : ∀ {x y} → x ≰ y → x >′ y
≰⇒>′ {+ m} {+ n} m≰n = +≤+ (ℕₚ.≰⇒> (m≰n ∘ +≤+))
≰⇒>′ {+ m} { -[1+ n ]} _ = -<′+ {n} {m}
≰⇒>′ { -[1+ m ]} {+ _} m≰n = contradiction -≤+ m≰n
≰⇒>′ { -[1+ 0 ]} { -[1+ 0 ]} m≰n = contradiction ≤-refl m≰n
≰⇒>′ { -[1+ suc _ ]} { -[1+ 0 ]} m≰n = contradiction (-≤- z≤n) m≰n
≰⇒>′ { -[1+ m ]} { -[1+ suc n ]} m≰n with m ℕ.≤? n
... | yes m≤n = -≤- m≤n
... | no m≰n' = contradiction (-≤- (ℕₚ.≰⇒> m≰n')) m≰n
{-# WARNING_ON_USAGE ≰⇒>′
"Warning: _<′_ was deprecated in v1.1.
Please use _<_ instead."
#-}
<′-irrelevant : Irrelevant _<′_
<′-irrelevant = ≤-irrelevant
{-# WARNING_ON_USAGE <′-irrelevant
"Warning: _<′_ was deprecated in v1.1.
Please use _<_ instead."
#-}
+-monoˡ-<′ : ∀ n → (_+ n) Preserves _<′_ ⟶ _<′_
+-monoˡ-<′ n {i} {j} i<j
rewrite sym (+-assoc (+ 1) i n)
= +-monoˡ-≤ n i<j
{-# WARNING_ON_USAGE +-monoˡ-<′
"Warning: _<′_ was deprecated in v1.1.
Please use _<_ instead."
#-}
+-monoʳ-<′ : ∀ n → (_+_ n) Preserves _<′_ ⟶ _<′_
+-monoʳ-<′ n {i} {j} i<j
rewrite +-comm n i
| +-comm n j
= +-monoˡ-<′ n {i} {j} i<j
{-# WARNING_ON_USAGE +-monoʳ-<′
"Warning: _<′_ was deprecated in v1.1.
Please use _<_ instead."
#-}
+-mono-<′ : _+_ Preserves₂ _<′_ ⟶ _<′_ ⟶ _<′_
+-mono-<′ {m} {n} {i} {j} m<n i<j = begin
sucℤ (m + i) ≤⟨ suc-mono {m + i} (<′⇒≤ (+-monoˡ-<′ i {m} {n} m<n)) ⟩
sucℤ (n + i) ≤⟨ +-monoʳ-<′ n i<j ⟩
n + j ∎
where open ≤-Reasoning
{-# WARNING_ON_USAGE +-mono-<′
"Warning: _<′_ was deprecated in v1.1.
Please use _<_ instead."
#-}
+-mono-≤-<′ : _+_ Preserves₂ _≤_ ⟶ _<′_ ⟶ _<′_
+-mono-≤-<′ {m} {n} {i} {j} m≤n i<j = ≤-<′-trans (+-monoˡ-≤ i m≤n) (+-monoʳ-<′ n i<j)
{-# WARNING_ON_USAGE +-mono-≤-<′
"Warning: _<′_ was deprecated in v1.1.
Please use _<_ instead."
#-}
+-mono-<′-≤ : _+_ Preserves₂ _<′_ ⟶ _≤_ ⟶ _<′_
+-mono-<′-≤ {m} {n} {i} {j} m<n i≤j =
<′-≤-trans {m + i} {n + i} {n + j} (+-monoˡ-<′ i {m} {n} m<n) (+-monoʳ-≤ n i≤j)
{-# WARNING_ON_USAGE +-mono-<′-≤
"Warning: _<′_ was deprecated in v1.1.
Please use _<_ instead."
#-}
m≤pred[n]⇒m<′n : ∀ {m n} → m ≤ pred n → m <′ n
m≤pred[n]⇒m<′n {m} {n} m≤predn = begin
sucℤ m ≤⟨ +-monoʳ-≤ (+ 1) m≤predn ⟩
+ 1 + pred n ≡⟨ sym (+-assoc (+ 1) -[1+ 0 ] n) ⟩
(+ 1 + -[1+ 0 ]) + n ≡⟨ cong (_+ n) (+-inverseʳ (+ 1)) ⟩
+ 0 + n ≡⟨ +-identityˡ n ⟩
n ∎
where open ≤-Reasoning
{-# WARNING_ON_USAGE m≤pred[n]⇒m<′n
"Warning: _<′_ was deprecated in v1.1.
Please use _<_ instead."
#-}
m<′n⇒m≤pred[n] : ∀ {m n} → m <′ n → m ≤ pred n
m<′n⇒m≤pred[n] {m} {n} m<n = begin
m ≡⟨ sym (pred-suc m) ⟩
pred (sucℤ m) ≤⟨ pred-mono m<n ⟩
pred n ∎
where open ≤-Reasoning
{-# WARNING_ON_USAGE m<′n⇒m≤pred[n]
"Warning: _<′_ was deprecated in v1.1.
Please use _<_ instead."
#-}
-- Version 1.2
[1+m]*n≡n+m*n = suc-*
{-# WARNING_ON_USAGE [1+m]*n≡n+m*n
"Warning: [1+m]*n≡n+m*n was deprecated in v1.2.
Please use suc-* instead."
#-}
| 33.19979
| 111
| 0.425922
|
31250c2cdb40ce4e6071dccacfa02c662062da0b
| 841
|
agda
|
Agda
|
test/succeed/Test0.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 294
|
2015-01-09T16:23:23.000Z
|
2022-03-20T13:54:45.000Z
|
test/succeed/Test0.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 31
|
2015-03-05T20:09:00.000Z
|
2021-10-03T19:15:25.000Z
|
test/succeed/Test0.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 50
|
2015-01-10T01:48:08.000Z
|
2022-02-14T03:03:25.000Z
|
{-# OPTIONS --without-K #-}
open import lib.Base
module succeed.Test0 where
module _ where
private
data #I : Type₀ where
#zero : #I
#one : #I
I : Type₀
I = #I
zero : I
zero = #zero
one : I
one = #one
postulate
seg : zero == one
I-elim : ∀ {i} {P : I → Type i} (zero* : P zero) (one* : P one)
(seg* : zero* == one* [ P ↓ seg ]) → Π I P
I-elim zero* one* seg* #zero = zero*
I-elim zero* one* seg* #one = one*
postulate
I-seg-β : ∀ {i} {P : I → Type i} (zero* : P zero) (one* : P one)
(seg* : zero* == one* [ P ↓ seg ])
→ apd (I-elim zero* one* seg*) seg == seg*
test : ∀ {i} {P : I → Type i} (zero* : P zero) (one* : P one)
(seg* : zero* == one* [ P ↓ seg ]) →
(I-elim zero* one* seg*) zero == zero*
test zero* one* seg* = idp
| 21.025
| 68
| 0.470868
|
2f4579f990805bf4ae7a2a1c297128caef7cfddf
| 7,296
|
agda
|
Agda
|
Cubical/Modalities/Lex.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | 1
|
2021-10-31T17:32:49.000Z
|
2021-10-31T17:32:49.000Z
|
Cubical/Modalities/Lex.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
Cubical/Modalities/Lex.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --safe --postfix-projections #-}
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function renaming (uncurry to λ⟨,⟩_)
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.Transport
open import Cubical.Foundations.CartesianKanOps
open import Cubical.Data.Sigma.Properties
module Cubical.Modalities.Lex
(◯ : ∀ {ℓ} → Type ℓ → Type ℓ)
(η : ∀ {ℓ} {A : Type ℓ} → A → ◯ A)
(isModal : ∀ {ℓ} → Type ℓ → Type ℓ)
(let isModalFam = λ {ℓ ℓ' : Level} {A : Type ℓ} (B : A → Type ℓ') → (x : A) → isModal (B x))
(idemp : ∀ {ℓ} {A : Type ℓ} → isModal (◯ A))
(≡-modal : ∀ {ℓ} {A : Type ℓ} {x y : A} (A-mod : isModal A) → isModal (x ≡ y))
(◯-ind : ∀ {ℓ ℓ'} {A : Type ℓ} {B : ◯ A → Type ℓ'} (B-mod : isModalFam B) (f : (x : A) → B (η x)) → ([x] : ◯ A) → B [x])
(◯-ind-β : ∀ {ℓ ℓ'} {A : Type ℓ} {B : ◯ A → Type ℓ'} (B-mod : isModalFam B) (f : (x : A) → B (η x)) (x : A) → ◯-ind B-mod f (η x) ≡ f x)
(let Type◯ = λ (ℓ : Level) → Σ (Type ℓ) isModal)
(◯-lex : ∀ {ℓ} → isModal (Type◯ ℓ))
where
private
variable
ℓ ℓ' : Level
η-at : (A : Type ℓ) → A → ◯ A
η-at _ = η
module _ where
private
variable
A : Type ℓ
B : Type ℓ'
module ◯-rec (B-mod : isModal B) (f : A → B) where
abstract
◯-rec : ◯ A → B
◯-rec = ◯-ind (λ _ → B-mod) f
◯-rec-β : (x : A) → ◯-rec (η x) ≡ f x
◯-rec-β = ◯-ind-β (λ _ → B-mod) f
open ◯-rec
module ◯-map (f : A → B) where
abstract
◯-map : ◯ A → ◯ B
◯-map = ◯-rec idemp λ x → η (f x)
◯-map-β : (x : A) → ◯-map (η x) ≡ η (f x)
◯-map-β x = ◯-rec-β idemp _ x
open ◯-rec
open ◯-map
module IsModalToUnitIsEquiv (A : Type ℓ) (A-mod : isModal A) where
abstract
inv : ◯ A → A
inv = ◯-rec A-mod λ x → x
η-retract : retract η inv
η-retract = ◯-rec-β _ _
η-section : section η inv
η-section = ◯-ind (λ _ → ≡-modal idemp) λ x i → η (η-retract x i)
η-iso : Iso A (◯ A)
Iso.fun η-iso = η
Iso.inv η-iso = inv
Iso.rightInv η-iso = η-section
Iso.leftInv η-iso = η-retract
η-is-equiv : isEquiv (η-at A)
η-is-equiv = isoToIsEquiv η-iso
abstract
unit-is-equiv-to-is-modal : {A : Type ℓ} → isEquiv (η-at A) → isModal A
unit-is-equiv-to-is-modal p = transport (cong isModal (sym (ua (η , p)))) idemp
retract-is-modal
: {A : Type ℓ} {B : Type ℓ'}
→ (A-mod : isModal A) (f : A → B) (g : B → A) (r : retract g f)
→ isModal B
retract-is-modal {A = A} {B = B} A-mod f g r =
unit-is-equiv-to-is-modal (isoToIsEquiv (iso η η-inv η-section η-retract))
where
η-inv : ◯ B → B
η-inv = f ∘ ◯-rec A-mod g
η-retract : retract η η-inv
η-retract b = cong f (◯-rec-β A-mod g b) ∙ r b
η-section : section η η-inv
η-section = ◯-ind (λ _ → ≡-modal idemp) (cong η ∘ η-retract)
module LiftFam {A : Type ℓ} (B : A → Type ℓ') where
module M = IsModalToUnitIsEquiv (Type◯ ℓ') ◯-lex
abstract
◯-lift-fam : ◯ A → Type◯ ℓ'
◯-lift-fam = M.inv ∘ ◯-map (λ a → ◯ (B a) , idemp)
⟨◯⟩ : ◯ A → Type ℓ'
⟨◯⟩ [a] = ◯-lift-fam [a] .fst
⟨◯⟩-modal : isModalFam ⟨◯⟩
⟨◯⟩-modal [a] = ◯-lift-fam [a] .snd
⟨◯⟩-compute : (x : A) → ⟨◯⟩ (η x) ≡ ◯ (B x)
⟨◯⟩-compute x =
⟨◯⟩ (η x)
≡⟨ cong (fst ∘ M.inv) (◯-map-β _ _) ⟩
M.inv (η (◯ (B x) , idemp)) .fst
≡⟨ cong fst (M.η-retract _) ⟩
◯ (B x) ∎
open LiftFam using (⟨◯⟩; ⟨◯⟩-modal; ⟨◯⟩-compute)
module LiftFamExtra {A : Type ℓ} {B : A → Type ℓ'} where
⟨◯⟩←◯ : ∀ {a} → ◯ (B a) → ⟨◯⟩ B (η a)
⟨◯⟩←◯ = transport (sym (⟨◯⟩-compute B _))
⟨◯⟩→◯ : ∀ {a} → ⟨◯⟩ B (η a) → ◯ (B a)
⟨◯⟩→◯ = transport (⟨◯⟩-compute B _)
⟨η⟩ : ∀ {a} → B a → ⟨◯⟩ B (η a)
⟨η⟩ = ⟨◯⟩←◯ ∘ η
abstract
⟨◯⟩→◯-section : ∀ {a} → section (⟨◯⟩→◯ {a}) ⟨◯⟩←◯
⟨◯⟩→◯-section = transport⁻Transport (sym (⟨◯⟩-compute _ _))
module Combinators where
private
variable
ℓ'' : Level
A A′ : Type ℓ
B : A → Type ℓ'
C : Σ A B → Type ℓ''
λ/coe⟨_⟩_ : (p : A ≡ A′) → ((x : A′) → B (coe1→0 (λ i → p i) x)) → ((x : A) → B x)
λ/coe⟨_⟩_ {B = B} p f = coe1→0 (λ i → (x : p i) → B (coei→0 (λ j → p j) i x)) f
open Combinators
module _ {A : Type ℓ} {B : A → Type ℓ'} where
abstract
Π-modal : isModalFam B → isModal ((x : A) → B x)
Π-modal B-mod = retract-is-modal idemp η-inv η retr
where
η-inv : ◯ ((x : A) → B x) → (x : A) → B x
η-inv [f] x = ◯-rec (B-mod x) (λ f → f x) [f]
retr : retract η η-inv
retr f = funExt λ x → ◯-rec-β (B-mod x) _ f
Σ-modal : isModal A → isModalFam B → isModal (Σ A B)
Σ-modal A-mod B-mod = retract-is-modal idemp η-inv η retr
where
h : ◯ (Σ A B) → A
h = ◯-rec A-mod fst
h-β : (x : Σ A B) → h (η x) ≡ fst x
h-β = ◯-rec-β A-mod fst
f : (i : I) (x : Σ A B) → B (h-β x i)
f i x = coe1→i (λ j → B (h-β x j)) i (snd x)
η-inv : ◯ (Σ A B) → Σ A B
η-inv y = h y , ◯-ind (B-mod ∘ h) (f i0) y
retr : (p : Σ A B) → η-inv (η p) ≡ p
retr p =
η-inv (η p)
≡⟨ ΣPathP (refl , ◯-ind-β _ _ _) ⟩
h (η p) , f i0 p
≡⟨ ΣPathP (h-β _ , λ i → f i p) ⟩
p ∎
module Σ-commute {A : Type ℓ} (B : A → Type ℓ') where
open LiftFamExtra
◯Σ = ◯ (Σ A B)
module Σ◯ where
Σ◯ = Σ (◯ A) (⟨◯⟩ B)
abstract
Σ◯-modal : isModal Σ◯
Σ◯-modal = Σ-modal idemp (⟨◯⟩-modal _)
open Σ◯
η-Σ◯ : Σ A B → Σ◯
η-Σ◯ (x , y) = η x , ⟨η⟩ y
module Push where
abstract
fun : ◯Σ → Σ◯
fun = ◯-rec Σ◯-modal η-Σ◯
compute : fun ∘ η ≡ η-Σ◯
compute = funExt (◯-rec-β _ _)
module Unpush where
abstract
fun : Σ◯ → ◯Σ
fun =
λ⟨,⟩ ◯-ind (λ _ → Π-modal λ _ → idemp) λ x →
λ/coe⟨ ⟨◯⟩-compute B x ⟩ ◯-map (x ,_)
compute : fun ∘ η-Σ◯ ≡ η
compute =
funExt λ p →
fun (η-Σ◯ p)
≡⟨ funExt⁻ (◯-ind-β _ _ _) _ ⟩
transport refl (◯-map _ _)
≡⟨ transportRefl _ ⟩
◯-map _ (⟨◯⟩→◯ (⟨η⟩ _))
≡⟨ cong (◯-map _) (⟨◯⟩→◯-section _) ⟩
◯-map _ (η _)
≡⟨ ◯-map-β _ _ ⟩
η p ∎
push-unpush-compute : Push.fun ∘ Unpush.fun ∘ η-Σ◯ ≡ η-Σ◯
push-unpush-compute =
Push.fun ∘ Unpush.fun ∘ η-Σ◯
≡⟨ cong (Push.fun ∘_) Unpush.compute ⟩
Push.fun ∘ η
≡⟨ Push.compute ⟩
η-Σ◯ ∎
unpush-push-compute : Unpush.fun ∘ Push.fun ∘ η ≡ η
unpush-push-compute =
Unpush.fun ∘ Push.fun ∘ η
≡⟨ cong (Unpush.fun ∘_) Push.compute ⟩
Unpush.fun ∘ η-Σ◯
≡⟨ Unpush.compute ⟩
η ∎
is-section : section Unpush.fun Push.fun
is-section = ◯-ind (λ x → ≡-modal idemp) λ x i → unpush-push-compute i x
is-retract : retract Unpush.fun Push.fun
is-retract =
λ⟨,⟩ ◯-ind (λ _ → Π-modal λ _ → ≡-modal Σ◯-modal) λ x →
λ/coe⟨ ⟨◯⟩-compute B x ⟩
◯-ind
(λ _ → ≡-modal Σ◯-modal)
(λ y i → push-unpush-compute i (x , y))
push-sg-is-equiv : isEquiv Push.fun
push-sg-is-equiv = isoToIsEquiv (iso Push.fun Unpush.fun is-retract is-section)
isConnected : Type ℓ → Type ℓ
isConnected A = isContr (◯ A)
module FormalDiskBundle {A : Type ℓ} where
𝔻 : A → Type ℓ
𝔻 a = Σ[ x ∈ A ] η a ≡ η x
| 26.150538
| 138
| 0.488624
|
4dbecffc043af9188d9ef0acd9f7633f9c609729
| 20,018
|
agda
|
Agda
|
theorems/groups/CoefficientExtensionality.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 294
|
2015-01-09T16:23:23.000Z
|
2022-03-20T13:54:45.000Z
|
theorems/groups/CoefficientExtensionality.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 31
|
2015-03-05T20:09:00.000Z
|
2021-10-03T19:15:25.000Z
|
theorems/groups/CoefficientExtensionality.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 50
|
2015-01-10T01:48:08.000Z
|
2022-02-14T03:03:25.000Z
|
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
module groups.CoefficientExtensionality where
module _ {i} {A : Type i} (dec : has-dec-eq A) where
open FreeAbelianGroup A
Word-coef : Word A → (A → ℤ)
Word-coef nil a = 0
Word-coef (inl a' :: w) a with dec a' a
Word-coef (inl a' :: w) a | inl a'=a = succ $ Word-coef w a
Word-coef (inl a' :: w) a | inr a'≠a = Word-coef w a
Word-coef (inr a' :: w) a with dec a' a
Word-coef (inr a' :: w) a | inl a'=a = pred $ Word-coef w a
Word-coef (inr a' :: w) a | inr a'≠a = Word-coef w a
abstract
Word-coef-++ : ∀ w₁ w₂ a → Word-coef (w₁ ++ w₂) a
== Word-coef w₁ a ℤ+ Word-coef w₂ a
Word-coef-++ nil w₂ a = idp
Word-coef-++ (inl a' :: w₁) w₂ a with dec a' a
Word-coef-++ (inl a' :: w₁) w₂ a | inl a'=a =
ap succ (Word-coef-++ w₁ w₂ a)
∙ ! (succ-+ (Word-coef w₁ a) (Word-coef w₂ a))
Word-coef-++ (inl a' :: w₁) w₂ a | inr a'≠a = Word-coef-++ w₁ w₂ a
Word-coef-++ (inr a' :: w₁) w₂ a with dec a' a
Word-coef-++ (inr a' :: w₁) w₂ a | inl a'=a =
ap pred (Word-coef-++ w₁ w₂ a)
∙ ! (pred-+ (Word-coef w₁ a) (Word-coef w₂ a))
Word-coef-++ (inr a' :: w₁) w₂ a | inr a'≠a = Word-coef-++ w₁ w₂ a
Word-coef-flip : ∀ w a → Word-coef (Word-flip w) a == ℤ~ (Word-coef w a)
Word-coef-flip nil a = idp
Word-coef-flip (inl a' :: w) a with dec a' a
Word-coef-flip (inl a' :: w) a | inl a'=a =
ap pred (Word-coef-flip w a) ∙ ! (ℤ~-succ (Word-coef w a))
Word-coef-flip (inl a' :: w) a | inr a'≠a = Word-coef-flip w a
Word-coef-flip (inr a' :: w) a with dec a' a
Word-coef-flip (inr a' :: w) a | inl a'=a =
ap succ (Word-coef-flip w a) ∙ ! (ℤ~-pred (Word-coef w a))
Word-coef-flip (inr a' :: w) a | inr a'≠a = Word-coef-flip w a
private
abstract
FormalSum-coef-rel : {w₁ w₂ : Word A} → FormalSumRel w₁ w₂
→ ∀ a → Word-coef w₁ a == Word-coef w₂ a
FormalSum-coef-rel (qwr-refl p) a = ap (λ w → Word-coef w a) p
FormalSum-coef-rel (qwr-trans r r') a =
FormalSum-coef-rel r a ∙ FormalSum-coef-rel r' a
FormalSum-coef-rel (qwr-sym r) a = ! (FormalSum-coef-rel r a)
FormalSum-coef-rel (qwr-cong {w₁} {w₂} {w₃} {w₄} r r') a =
Word-coef (w₁ ++ w₃) a
=⟨ Word-coef-++ w₁ w₃ a ⟩
Word-coef w₁ a ℤ+ Word-coef w₃ a
=⟨ ap2 _ℤ+_ (FormalSum-coef-rel r a) (FormalSum-coef-rel r' a) ⟩
Word-coef w₂ a ℤ+ Word-coef w₄ a
=⟨ ! (Word-coef-++ w₂ w₄ a) ⟩
Word-coef (w₂ ++ w₄) a =∎
FormalSum-coef-rel (qwr-flip-r x) a =
Word-coef (x :: flip x :: nil) a
=⟨ Word-coef-++ (x :: nil) (flip x :: nil) a ⟩
Word-coef (x :: nil) a ℤ+ Word-coef (flip x :: nil) a
=⟨ ap (Word-coef (x :: nil) a ℤ+_) (Word-coef-flip (x :: nil) a) ⟩
Word-coef (x :: nil) a ℤ+ ℤ~ (Word-coef (x :: nil) a)
=⟨ ℤ~-inv-r (Word-coef (x :: nil) a) ⟩
pos 0 =∎
FormalSum-coef-rel (qwr-rel (agr-rel ())) a
FormalSum-coef-rel (qwr-rel (agr-commutes w₁ w₂)) a =
Word-coef (w₁ ++ w₂) a
=⟨ Word-coef-++ w₁ w₂ a ⟩
Word-coef w₁ a ℤ+ Word-coef w₂ a
=⟨ ℤ+-comm (Word-coef w₁ a) (Word-coef w₂ a) ⟩
Word-coef w₂ a ℤ+ Word-coef w₁ a
=⟨ ! (Word-coef-++ w₂ w₁ a) ⟩
Word-coef (w₂ ++ w₁) a =∎
FormalSum-coef : FormalSum → (A → ℤ)
FormalSum-coef = QuotWord-rec Word-coef (λ r → λ= $ FormalSum-coef-rel r)
-- Theorem : if coef w a == 0 then FormalSumRel w nil
private
abstract
Word-exp-succ : ∀ (a : A) z → FormalSumRel (inl a :: Word-exp a z) (Word-exp a (succ z))
Word-exp-succ a (pos _) = qwr-refl idp
Word-exp-succ a (negsucc 0) = qwr-flip-r (inl a)
Word-exp-succ a (negsucc (S n)) = qwr-cong-l (qwr-flip-r (inl a)) (Word-exp a (negsucc n))
Word-exp-pred : ∀ (a : A) z → FormalSumRel (inr a :: Word-exp a z) (Word-exp a (pred z))
Word-exp-pred a (pos 0) = qwr-refl idp
Word-exp-pred a (pos (S n)) = qwr-cong-l (qwr-flip-r (inr a)) (Word-exp a (pos n))
Word-exp-pred a (negsucc _) = qwr-refl idp
Word-coef-inl-eq : ∀ {a b} (p : b == a) w
→ Word-coef (inl b :: w) a == succ (Word-coef w a)
Word-coef-inl-eq {a} {b} p w with dec b a
Word-coef-inl-eq {a} {b} p w | inl _ = idp
Word-coef-inl-eq {a} {b} p w | inr ¬p = ⊥-rec (¬p p)
Word-coef-inr-eq : ∀ {a b} (p : b == a) w
→ Word-coef (inr b :: w) a == pred (Word-coef w a)
Word-coef-inr-eq {a} {b} p w with dec b a
Word-coef-inr-eq {a} {b} p w | inl _ = idp
Word-coef-inr-eq {a} {b} p w | inr ¬p = ⊥-rec (¬p p)
Word-coef-inl-neq : ∀ {a b} (p : b ≠ a) w
→ Word-coef (inl b :: w) a == Word-coef w a
Word-coef-inl-neq {a} {b} ¬p w with dec b a
Word-coef-inl-neq {a} {b} ¬p w | inl p = ⊥-rec (¬p p)
Word-coef-inl-neq {a} {b} ¬p w | inr _ = idp
Word-coef-inr-neq : ∀ {a b} (p : b ≠ a) w
→ Word-coef (inr b :: w) a == Word-coef w a
Word-coef-inr-neq {a} {b} ¬p w with dec b a
Word-coef-inr-neq {a} {b} ¬p w | inl p = ⊥-rec (¬p p)
Word-coef-inr-neq {a} {b} ¬p w | inr _ = idp
-- TODO maybe there is a better way to prove the final theorem?
-- Here we are collecting all elements [inl a] and [inr a], and recurse on the rest.
-- The [right-shorter] field makes sure that it is terminating.
record CollectSplitIH (a : A) {n : ℕ} (w : Word A) (len : length w == n) : Type i where
field
left-exponent : ℤ
left-captures-all : Word-coef w a == left-exponent
right-list : Word A
right-shorter : length right-list ≤ n
fsr : FormalSumRel w (Word-exp a left-exponent ++ right-list)
abstract
collect-split : ∀ a {n} w (len=n : length w == n) → CollectSplitIH a w len=n
collect-split a nil idp = record {
left-exponent = 0;
left-captures-all = idp;
right-list = nil;
right-shorter = inl idp;
fsr = qwr-refl idp}
collect-split a (inl b :: w) idp with dec b a
... | inl b=a = record {
left-exponent = succ left-exponent;
left-captures-all = Word-coef-inl-eq b=a w ∙ ap succ left-captures-all;
right-list = right-list;
right-shorter = ≤-trans right-shorter (inr ltS);
fsr =
inl b :: w
qwr⟨ qwr-refl (ap (λ a → inl a :: w) b=a) ⟩
inl a :: w
qwr⟨ qwr-cong-r (inl a :: nil) fsr ⟩
inl a :: Word-exp a left-exponent ++ right-list
qwr⟨ qwr-cong-l (Word-exp-succ a left-exponent) right-list ⟩
Word-exp a (succ left-exponent) ++ right-list qwr∎}
where open CollectSplitIH (collect-split a w idp)
... | inr b≠a = record {
left-exponent = left-exponent;
left-captures-all = Word-coef-inl-neq b≠a w ∙ left-captures-all;
right-list = inl b :: right-list;
right-shorter = ≤-ap-S right-shorter;
fsr =
inl b :: w
qwr⟨ qwr-cong-r (inl b :: nil) fsr ⟩
inl b :: Word-exp a left-exponent ++ right-list
qwr⟨ qwr-cong-l (qwr-rel (agr-commutes (inl b :: nil) (Word-exp a left-exponent))) right-list ⟩
(Word-exp a left-exponent ++ (inl b :: nil)) ++ right-list
qwr⟨ qwr-refl (++-assoc (Word-exp a left-exponent) _ _) ⟩
Word-exp a left-exponent ++ (inl b :: right-list) qwr∎}
where open CollectSplitIH (collect-split a w idp)
collect-split a (inr b :: w) idp with dec b a
... | inl b=a = record {
left-exponent = pred left-exponent;
left-captures-all = Word-coef-inr-eq b=a w ∙ ap pred left-captures-all;
right-list = right-list;
right-shorter = ≤-trans right-shorter (inr ltS);
fsr =
inr b :: w
qwr⟨ qwr-refl (ap (λ a → inr a :: w) b=a) ⟩
inr a :: w
qwr⟨ qwr-cong-r (inr a :: nil) fsr ⟩
inr a :: Word-exp a left-exponent ++ right-list
qwr⟨ qwr-cong-l (Word-exp-pred a left-exponent) right-list ⟩
Word-exp a (pred left-exponent) ++ right-list qwr∎}
where open CollectSplitIH (collect-split a w idp)
... | inr b≠a = record {
left-exponent = left-exponent;
left-captures-all = Word-coef-inr-neq b≠a w ∙ left-captures-all;
right-list = inr b :: right-list;
right-shorter = ≤-ap-S right-shorter;
fsr =
inr b :: w
qwr⟨ qwr-cong-r (inr b :: nil) fsr ⟩
inr b :: Word-exp a left-exponent ++ right-list
qwr⟨ qwr-cong-l (qwr-rel (agr-commutes (inr b :: nil) (Word-exp a left-exponent))) right-list ⟩
(Word-exp a left-exponent ++ (inr b :: nil)) ++ right-list
qwr⟨ qwr-refl (++-assoc (Word-exp a left-exponent) _ _) ⟩
Word-exp a left-exponent ++ (inr b :: right-list) qwr∎}
where open CollectSplitIH (collect-split a w idp)
-- We simulate strong induction by recursing on both [m] and [n≤m].
-- We could develop a general framework for strong induction but I am lazy. -Favonia
zero-coef-is-ident' : ∀ {m n} (n≤m : n ≤ m) (w : Word A) (len : length w == n)
→ (∀ a → Word-coef w a == 0) → FormalSumRel w nil
zero-coef-is-ident' (inr ltS) w len zero-coef
= zero-coef-is-ident' (inl idp) w len zero-coef
zero-coef-is-ident' (inr (ltSR lt)) w len zero-coef
= zero-coef-is-ident' (inr lt) w len zero-coef
zero-coef-is-ident' {m = O} (inl idp) nil _ _ = qwr-refl idp
zero-coef-is-ident' {m = O} (inl idp) (_ :: _) len _ = ⊥-rec $ ℕ-S≠O _ len
zero-coef-is-ident' {m = S m} (inl idp) nil len _ = ⊥-rec $ ℕ-S≠O _ (! len)
zero-coef-is-ident' {m = S m} (inl idp) (inl a :: w) len zero-coef =
inl a :: w
qwr⟨ whole-is-right ⟩
right-list
qwr⟨ (zero-coef-is-ident' right-shorter right-list idp right-zero-coef) ⟩
nil qwr∎
where
open CollectSplitIH (collect-split a w (ℕ-S-is-inj _ _ len))
left-exponent-is-minus-one : left-exponent == -1
left-exponent-is-minus-one = succ-is-inj left-exponent -1 $
ap succ (! left-captures-all) ∙ ! (Word-coef-inl-eq idp w) ∙ zero-coef a
whole-is-right : FormalSumRel (inl a :: w) right-list
whole-is-right =
inl a :: w
qwr⟨ qwr-cong-r (inl a :: nil) fsr ⟩
inl a :: Word-exp a left-exponent ++ right-list
qwr⟨ qwr-refl (ap (λ e → inl a :: Word-exp a e ++ right-list) left-exponent-is-minus-one) ⟩
inl a :: inr a :: right-list
qwr⟨ qwr-cong-l (qwr-flip-r (inl a)) right-list ⟩
right-list qwr∎
right-zero-coef : ∀ a' → Word-coef right-list a' == 0
right-zero-coef a' = ! (FormalSum-coef-rel whole-is-right a') ∙ zero-coef a'
zero-coef-is-ident' {m = S m} (inl idp) (inr a :: w) len zero-coef =
inr a :: w
qwr⟨ whole-is-right ⟩
right-list
qwr⟨ zero-coef-is-ident' right-shorter right-list idp right-zero-coef ⟩
nil qwr∎
where
open CollectSplitIH (collect-split a w (ℕ-S-is-inj _ _ len))
left-exponent-is-one : left-exponent == 1
left-exponent-is-one = pred-is-inj left-exponent 1 $
ap pred (! left-captures-all) ∙ ! (Word-coef-inr-eq idp w) ∙ zero-coef a
whole-is-right : FormalSumRel (inr a :: w) right-list
whole-is-right =
inr a :: w
qwr⟨ qwr-cong-r (inr a :: nil) fsr ⟩
inr a :: Word-exp a left-exponent ++ right-list
qwr⟨ qwr-refl (ap (λ e → inr a :: Word-exp a e ++ right-list) left-exponent-is-one) ⟩
inr a :: inl a :: right-list
qwr⟨ qwr-cong-l (qwr-flip-r (inr a)) right-list ⟩
right-list qwr∎
right-zero-coef : ∀ a' → Word-coef right-list a' == 0
right-zero-coef a' = ! (FormalSum-coef-rel whole-is-right a') ∙ zero-coef a'
zero-coef-is-ident : ∀ (w : Word A)
→ (∀ a → Word-coef w a == 0)
→ FormalSumRel w nil
zero-coef-is-ident w = zero-coef-is-ident' (inl idp) w idp
abstract
FormalSum-coef-ext' : ∀ w₁ w₂
→ (∀ a → Word-coef w₁ a == Word-coef w₂ a)
→ qw[ w₁ ] == qw[ w₂ ]
FormalSum-coef-ext' w₁ w₂ same-coef = FreeAbGroup.inv-is-inj qw[ w₁ ] qw[ w₂ ] $
FreeAbGroup.inv-unique-l (FreeAbGroup.inv qw[ w₂ ]) qw[ w₁ ] $ quot-rel $
reverse (Word-flip w₂) ++ w₁
qwr⟨ qwr-cong-l (agr-reverse (Word-flip w₂)) w₁ ⟩
Word-flip w₂ ++ w₁
qwr⟨ zero-coef-is-ident (Word-flip w₂ ++ w₁)
(λ a → Word-coef-++ (Word-flip w₂) w₁ a
∙ ap2 _ℤ+_ (Word-coef-flip w₂ a) (same-coef a)
∙ ℤ~-inv-l (Word-coef w₂ a)) ⟩
nil qwr∎
FormalSum-coef-ext : ∀ fs₁ fs₂
→ (∀ a → FormalSum-coef fs₁ a == FormalSum-coef fs₂ a)
→ fs₁ == fs₂
FormalSum-coef-ext = QuotWord-elim
(λ w₁ → QuotWord-elim
(λ w₂ → FormalSum-coef-ext' w₁ w₂)
(λ _ → prop-has-all-paths-↓))
(λ _ → prop-has-all-paths-↓)
has-finite-support : (A → ℤ) → Type i
has-finite-support f = Σ FormalSum λ fs → ∀ a → f a == FormalSum-coef fs a
module _ {i} {A : Type i} {dec : has-dec-eq A} where
abstract
has-finite-support-is-prop : ∀ f → is-prop (has-finite-support dec f)
has-finite-support-is-prop f = all-paths-is-prop
λ{(fs₁ , match₁) (fs₂ , match₂) → pair=
(FormalSum-coef-ext dec fs₁ fs₂ λ a → ! (match₁ a) ∙ match₂ a)
prop-has-all-paths-↓}
module _ where
private
abstract
Word-coef-exp-diag-pos : ∀ {I} (<I : Fin I) n →
Word-coef Fin-has-dec-eq (Word-exp <I (pos n)) <I == pos n
Word-coef-exp-diag-pos <I O = idp
Word-coef-exp-diag-pos <I (S n) with Fin-has-dec-eq <I <I
... | inl _ = ap succ (Word-coef-exp-diag-pos <I n)
... | inr ¬p = ⊥-rec (¬p idp)
Word-coef-exp-diag-negsucc : ∀ {I} (<I : Fin I) n →
Word-coef Fin-has-dec-eq (Word-exp <I (negsucc n)) <I == negsucc n
Word-coef-exp-diag-negsucc <I O with Fin-has-dec-eq <I <I
... | inl _ = idp
... | inr ¬p = ⊥-rec (¬p idp)
Word-coef-exp-diag-negsucc <I (S n) with Fin-has-dec-eq <I <I
... | inl _ = ap pred (Word-coef-exp-diag-negsucc <I n)
... | inr ¬p = ⊥-rec (¬p idp)
Word-coef-exp-diag : ∀ {I} (<I : Fin I) z →
Word-coef Fin-has-dec-eq (Word-exp <I z) <I == z
Word-coef-exp-diag <I (pos n) = Word-coef-exp-diag-pos <I n
Word-coef-exp-diag <I (negsucc n) = Word-coef-exp-diag-negsucc <I n
Word-coef-exp-≠-pos : ∀ {I} {<I <I' : Fin I} (_ : <I ≠ <I') n →
Word-coef Fin-has-dec-eq (Word-exp <I (pos n)) <I' == 0
Word-coef-exp-≠-pos _ O = idp
Word-coef-exp-≠-pos {<I = <I} {<I'} neq (S n) with Fin-has-dec-eq <I <I'
... | inl p = ⊥-rec (neq p)
... | inr ¬p = Word-coef-exp-≠-pos neq n
Word-coef-exp-≠-negsucc : ∀ {I} {<I <I' : Fin I} (_ : <I ≠ <I') n →
Word-coef Fin-has-dec-eq (Word-exp <I (negsucc n)) <I' == 0
Word-coef-exp-≠-negsucc {<I = <I} {<I'} neq O with Fin-has-dec-eq <I <I'
... | inl p = ⊥-rec (neq p)
... | inr ¬p = idp
Word-coef-exp-≠-negsucc {<I = <I} {<I'} neq (S n) with Fin-has-dec-eq <I <I'
... | inl p = ⊥-rec (neq p)
... | inr ¬p = Word-coef-exp-≠-negsucc neq n
Word-coef-exp-≠ : ∀ {I} {<I <I' : Fin I} (_ : <I ≠ <I') z →
Word-coef Fin-has-dec-eq (Word-exp <I z) <I' == 0
Word-coef-exp-≠ neq (pos n) = Word-coef-exp-≠-pos neq n
Word-coef-exp-≠ neq (negsucc n) = Word-coef-exp-≠-negsucc neq n
Word-sum' : ∀ (I : ℕ) {A : Type₀} (F : Fin I → A) (f : Fin I → ℤ) → Word A
Word-sum' 0 F f = nil
Word-sum' (S I) F f = Word-sum' I (F ∘ Fin-S) (f ∘ Fin-S) ++ Word-exp (F (I , ltS)) (f (I , ltS))
Word-sum : ∀ {I : ℕ} (f : Fin I → ℤ) → Word (Fin I)
Word-sum {I} f = Word-sum' I (idf (Fin I)) f
abstract
Word-coef-sum'-late : ∀ n m (I : ℕ) (f : Fin I → ℤ)
→ Word-coef Fin-has-dec-eq (Word-sum' I (Fin-S^' (S n) ∘ Fin-S^' m) f) (Fin-S^' n (ℕ-S^' m I , ltS)) == 0
Word-coef-sum'-late n m 0 f = idp
Word-coef-sum'-late n m (S I) f =
Word-coef Fin-has-dec-eq
(Word-sum' I (Fin-S^' (S n) ∘ Fin-S^' (S m)) (f ∘ Fin-S) ++ Word-exp (Fin-S^' (S n) (Fin-S^' m (I , ltS))) (f (I , ltS)))
(Fin-S^' n (ℕ-S^' (S m) I , ltS))
=⟨ Word-coef-++ Fin-has-dec-eq
(Word-sum' I (Fin-S^' (S n) ∘ Fin-S^' (S m)) (f ∘ Fin-S))
(Word-exp (Fin-S^' (S n) (Fin-S^' m (I , ltS))) (f (I , ltS)))
(Fin-S^' n (ℕ-S^' (S m) I , ltS)) ⟩
Word-coef Fin-has-dec-eq (Word-sum' I (Fin-S^' (S n) ∘ Fin-S^' (S m)) (f ∘ Fin-S)) (Fin-S^' n (ℕ-S^' (S m) I , ltS))
ℤ+
Word-coef Fin-has-dec-eq (Word-exp (Fin-S^' (S n) (Fin-S^' m (I , ltS))) (f (I , ltS))) (Fin-S^' n (ℕ-S^' (S m) I , ltS))
=⟨ ap2 _ℤ+_
(Word-coef-sum'-late n (S m) I (f ∘ Fin-S))
(Word-coef-exp-≠ (Fin-S^'-≠ n (ltSR≠ltS _)) (f (I , ltS))) ⟩
0
=∎
Word-coef-sum' : ∀ n {I} (f : Fin I → ℤ) <I
→ Word-coef Fin-has-dec-eq (Word-sum' I (Fin-S^' n) f) (Fin-S^' n <I) == f <I
Word-coef-sum' n f (I , ltS) =
Word-coef Fin-has-dec-eq
(Word-sum' I (Fin-S^' (S n)) (f ∘ Fin-S) ++ Word-exp (Fin-S^' n (I , ltS)) (f (I , ltS)))
(Fin-S^' n (I , ltS))
=⟨ Word-coef-++ Fin-has-dec-eq
(Word-sum' I (Fin-S^' (S n)) (f ∘ Fin-S))
(Word-exp (Fin-S^' n (I , ltS)) (f (I , ltS)))
(Fin-S^' n (I , ltS)) ⟩
Word-coef Fin-has-dec-eq (Word-sum' I (Fin-S^' (S n)) (f ∘ Fin-S)) (Fin-S^' n (I , ltS))
ℤ+
Word-coef Fin-has-dec-eq (Word-exp (Fin-S^' n (I , ltS)) (f (I , ltS))) (Fin-S^' n (I , ltS))
=⟨ ap2 _ℤ+_
(Word-coef-sum'-late n 0 I (f ∘ Fin-S))
(Word-coef-exp-diag (Fin-S^' n (I , ltS)) (f (I , ltS))) ⟩
f (I , ltS)
=∎
Word-coef-sum' n {I = S I} f (m , ltSR m<I) =
Word-coef Fin-has-dec-eq
(Word-sum' I (Fin-S^' (S n)) (f ∘ Fin-S) ++ Word-exp (Fin-S^' n (I , ltS)) (f (I , ltS)))
(Fin-S^' (S n) (m , m<I))
=⟨ Word-coef-++ Fin-has-dec-eq
(Word-sum' I (Fin-S^' (S n)) (f ∘ Fin-S))
(Word-exp (Fin-S^' n (I , ltS)) (f (I , ltS)))
(Fin-S^' (S n) (m , m<I)) ⟩
Word-coef Fin-has-dec-eq (Word-sum' I (Fin-S^' (S n)) (f ∘ Fin-S)) (Fin-S^' (S n) (m , m<I))
ℤ+
Word-coef Fin-has-dec-eq (Word-exp (Fin-S^' n (I , ltS)) (f (I , ltS))) (Fin-S^' (S n) (m , m<I))
=⟨ ap2 _ℤ+_
(Word-coef-sum' (S n) {I} (f ∘ Fin-S) (m , m<I))
(Word-coef-exp-≠ (Fin-S^'-≠ n (ltS≠ltSR (m , m<I))) (f (I , ltS))) ⟩
f (m , ltSR m<I) ℤ+ 0
=⟨ ℤ+-unit-r _ ⟩
f (m , ltSR m<I)
=∎
FormalSum-sum' : ∀ n (I : ℕ) (f : Fin I → ℤ) → FreeAbelianGroup.FormalSum (Fin (ℕ-S^' n I))
FormalSum-sum' n I f =
FreeAbGroup.sum (λ <I → FreeAbGroup.exp qw[ inl (Fin-S^' n <I) :: nil ] (f <I))
where open FreeAbelianGroup (Fin (ℕ-S^' n I))
FormalSum-sum : ∀ {I : ℕ} (f : Fin I → ℤ) → FreeAbelianGroup.FormalSum (Fin I)
FormalSum-sum {I} = FormalSum-sum' 0 I
private
abstract
FormalSum-sum'-β : ∀ n (I : ℕ) (f : Fin I → ℤ)
→ FormalSum-sum' n I f == FreeAbelianGroup.qw[_] (Fin (ℕ-S^' n I)) (Word-sum' I (Fin-S^' n) f)
FormalSum-sum'-β n O f = idp
FormalSum-sum'-β n (S I) f =
ap2 FreeAbGroup.comp
(FormalSum-sum'-β (S n) I (f ∘ Fin-S))
(! (pres-exp (Fin-S^' n (I , ltS)) (f (I , ltS))))
where open FreeAbelianGroup (Fin (ℕ-S^' (S n) I))
Fin→-has-finite-support : ∀ {I} (f : Fin I → ℤ) → has-finite-support Fin-has-dec-eq f
Fin→-has-finite-support {I} f = FormalSum-sum f , lemma
where abstract lemma = λ <I → ! (ap (λ fs → FormalSum-coef Fin-has-dec-eq fs <I) (FormalSum-sum'-β 0 I f) ∙ Word-coef-sum' 0 f <I)
| 46.230947
| 134
| 0.512139
|
50ba1282587dbb247faede0d79314e22e0c9daf6
| 5,321
|
agda
|
Agda
|
core/lib/types/TLevel.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 294
|
2015-01-09T16:23:23.000Z
|
2022-03-20T13:54:45.000Z
|
core/lib/types/TLevel.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 31
|
2015-03-05T20:09:00.000Z
|
2021-10-03T19:15:25.000Z
|
core/lib/types/TLevel.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 50
|
2015-01-10T01:48:08.000Z
|
2022-02-14T03:03:25.000Z
|
{-# OPTIONS --without-K --rewriting #-}
open import lib.Base
open import lib.PathGroupoid
open import lib.types.Empty
open import lib.types.Nat
module lib.types.TLevel where
⟨_⟩₋₁ : ℕ → ℕ₋₂
⟨ n ⟩₋₁ = S ⟨ n ⟩₋₂
⟨_⟩ : ℕ → ℕ₋₂
⟨ n ⟩ = S (S ⟨ n ⟩₋₂)
infixl 80 _+2+_
_+2+_ : ℕ₋₂ → ℕ₋₂ → ℕ₋₂
⟨-2⟩ +2+ n = n
S m +2+ n = S (m +2+ n)
+2+-unit-r : (m : ℕ₋₂) → m +2+ ⟨-2⟩ == m
+2+-unit-r ⟨-2⟩ = idp
+2+-unit-r (S m) = ap S (+2+-unit-r m)
+2+-βr : (m n : ℕ₋₂) → m +2+ (S n) == S (m +2+ n)
+2+-βr ⟨-2⟩ n = idp
+2+-βr (S m) n = ap S (+2+-βr m n)
+2+-comm : (m n : ℕ₋₂) → m +2+ n == n +2+ m
+2+-comm m ⟨-2⟩ = +2+-unit-r m
+2+-comm m (S n) = +2+-βr m n ∙ ap S (+2+-comm m n)
+2+0 : (n : ℕ₋₂) → n +2+ 0 == S (S n)
+2+0 n = +2+-comm n 0
+-+2+ : ∀ (n m : ℕ) → ⟨ n + m ⟩₋₂ == ⟨ n ⟩₋₂ +2+ ⟨ m ⟩₋₂
+-+2+ O m = idp
+-+2+ (S n) m = ap S (+-+2+ n m)
{- Inequalities -}
infix 40 _<T_
infix 40 _≤T_
data _<T_ : ℕ₋₂ → ℕ₋₂ → Type₀ where
ltS : {m : ℕ₋₂} → m <T (S m)
ltSR : {m n : ℕ₋₂} → m <T n → m <T (S n)
_≤T_ : ℕ₋₂ → ℕ₋₂ → Type₀
m ≤T n = Coprod (m == n) (m <T n)
-2<T : (m : ℕ₋₂) → ⟨-2⟩ <T S m
-2<T ⟨-2⟩ = ltS
-2<T (S m) = ltSR (-2<T m)
-2≤T : (m : ℕ₋₂) → ⟨-2⟩ ≤T m
-2≤T ⟨-2⟩ = inl idp
-2≤T (S m) = inr (-2<T m)
<T-trans : {m n k : ℕ₋₂} → m <T n → n <T k → m <T k
<T-trans lt₁ ltS = ltSR lt₁
<T-trans lt₁ (ltSR lt₂) = ltSR (<T-trans lt₁ lt₂)
≤T-refl : {m : ℕ₋₂} → m ≤T m
≤T-refl = inl idp
≤T-trans : {m n k : ℕ₋₂} → m ≤T n → n ≤T k → m ≤T k
≤T-trans {k = k} (inl p₁) lte₂ = transport (λ t → t ≤T k) (! p₁) lte₂
≤T-trans {m = m} lte₁ (inl p₂) = transport (λ t → m ≤T t) p₂ lte₁
≤T-trans (inr lt₁) (inr lt₂) = inr (<T-trans lt₁ lt₂)
<T-ap-S : {m n : ℕ₋₂} → m <T n → S m <T S n
<T-ap-S ltS = ltS
<T-ap-S (ltSR lt) = ltSR (<T-ap-S lt)
≤T-ap-S : {m n : ℕ₋₂} → m ≤T n → S m ≤T S n
≤T-ap-S (inl p) = inl (ap S p)
≤T-ap-S (inr lt) = inr (<T-ap-S lt)
<T-cancel-S : {m n : ℕ₋₂} → S m <T S n → m <T n
<T-cancel-S ltS = ltS
<T-cancel-S (ltSR lt) = <T-trans ltS lt
<T-+2+-l : {m n : ℕ₋₂} (k : ℕ₋₂) → m <T n → (k +2+ m) <T (k +2+ n)
<T-+2+-l ⟨-2⟩ lt = lt
<T-+2+-l (S k) lt = <T-ap-S (<T-+2+-l k lt)
≤T-+2+-l : {m n : ℕ₋₂} (k : ℕ₋₂) → m ≤T n → (k +2+ m) ≤T (k +2+ n)
≤T-+2+-l k (inl p) = inl (ap (λ t → k +2+ t) p)
≤T-+2+-l k (inr lt) = inr (<T-+2+-l k lt)
<T-+2+-r : {m n : ℕ₋₂} (k : ℕ₋₂) → m <T n → (m +2+ k) <T (n +2+ k)
<T-+2+-r k ltS = ltS
<T-+2+-r k (ltSR lt) = ltSR (<T-+2+-r k lt)
≤T-+2+-r : {m n : ℕ₋₂} (k : ℕ₋₂) → m ≤T n → (m +2+ k) ≤T (n +2+ k)
≤T-+2+-r k (inl p) = inl (ap (λ t → t +2+ k) p)
≤T-+2+-r k (inr lt) = inr (<T-+2+-r k lt)
private
T-get-S : ℕ₋₂ → ℕ₋₂
T-get-S ⟨-2⟩ = ⟨ 42 ⟩
T-get-S (S n) = n
T-S≠⟨-2⟩-type : ℕ₋₂ → Type₀
T-S≠⟨-2⟩-type ⟨-2⟩ = Empty
T-S≠⟨-2⟩-type (S n) = Unit
T-S≠⟨-2⟩ : (n : ℕ₋₂) → S n ≠ ⟨-2⟩
T-S≠⟨-2⟩ n p = transport T-S≠⟨-2⟩-type p unit
T-S≠ : (n : ℕ₋₂) → S n ≠ n
T-S≠ ⟨-2⟩ p = T-S≠⟨-2⟩ ⟨-2⟩ p
T-S≠ (S n) p = T-S≠ n (ap T-get-S p)
T-S+2+≠ : (n k : ℕ₋₂) → S (k +2+ n) ≠ n
T-S+2+≠ ⟨-2⟩ k p = T-S≠⟨-2⟩ (k +2+ ⟨-2⟩) p
T-S+2+≠ (S n) k p = T-S+2+≠ n k (ap T-get-S (ap S (! (+2+-βr k n)) ∙ p))
<T-witness : {m n : ℕ₋₂} → (m <T n) → Σ ℕ₋₂ (λ k → S k +2+ m == n)
<T-witness ltS = (⟨-2⟩ , idp)
<T-witness (ltSR lt) = let w' = <T-witness lt in (S (fst w') , ap S (snd w'))
≤T-witness : {m n : ℕ₋₂} → (m ≤T n) → Σ ℕ₋₂ (λ k → k +2+ m == n)
≤T-witness (inl p) = (⟨-2⟩ , p)
≤T-witness (inr lt) = let w' = <T-witness lt in (S (fst w') , snd w')
<T-to-≤T : {m n : ℕ₋₂} → m <T S n → m ≤T n
<T-to-≤T ltS = inl idp
<T-to-≤T (ltSR lt) = inr lt
<T-to-≠ : {m n : ℕ₋₂} → (m <T n) → m ≠ n
<T-to-≠ {m} {n} lt p = T-S+2+≠ m (fst w) (snd w ∙ ! p)
where w = <T-witness lt
=-to-≮T : {m n : ℕ₋₂} → (m == n) → ¬ (m <T n)
=-to-≮T p lt = <T-to-≠ lt p
<T-to-≯T : {m n : ℕ₋₂} → (m <T n) → ¬ (n <T m)
<T-to-≯T lt gt = =-to-≮T idp (<T-trans lt gt)
<T-to-≱T : {m n : ℕ₋₂} → (m <T n) → ¬ (n ≤T m)
<T-to-≱T lt (inl p) = <T-to-≠ lt (! p)
<T-to-≱T lt (inr gt) = <T-to-≯T lt gt
{-
-2-monotone-< : {m n : ℕ} → (m < n) → (m -2 <T n -2)
-2-monotone-< ltS = ltS
-2-monotone-< (ltSR lt) = ltSR (-2-monotone-< lt)
-2-monotone-≤ : {m n : ℕ} → (m ≤ n) → (m -2 ≤T n -2)
-2-monotone-≤ (inl p) = inl (ap _-2 p)
-2-monotone-≤ (inr lt) = inr (-2-monotone-< lt)
-}
⟨⟩-monotone-< : {m n : ℕ} → (m < n) → (⟨ m ⟩ <T ⟨ n ⟩)
⟨⟩-monotone-< ltS = ltS
⟨⟩-monotone-< (ltSR lt) = ltSR (⟨⟩-monotone-< lt)
⟨⟩-monotone-≤ : {m n : ℕ} → (m ≤ n) → (⟨ m ⟩ ≤T ⟨ n ⟩)
⟨⟩-monotone-≤ (inl p) = inl (ap ⟨_⟩ p)
⟨⟩-monotone-≤ (inr lt) = inr (⟨⟩-monotone-< lt)
minT : ℕ₋₂ → ℕ₋₂ → ℕ₋₂
minT ⟨-2⟩ n = ⟨-2⟩
minT (S m) ⟨-2⟩ = ⟨-2⟩
minT (S m) (S n) = S (minT m n)
minT≤l : (m n : ℕ₋₂) → minT m n ≤T m
minT≤l ⟨-2⟩ n = inl idp
minT≤l (S m) ⟨-2⟩ = -2≤T (S m)
minT≤l (S m) (S n) = ≤T-ap-S (minT≤l m n)
minT≤r : (m n : ℕ₋₂) → minT m n ≤T n
minT≤r ⟨-2⟩ n = -2≤T n
minT≤r (S m) ⟨-2⟩ = inl idp
minT≤r (S m) (S n) = ≤T-ap-S (minT≤r m n)
minT-out : (m n : ℕ₋₂) → Coprod (minT m n == m) (minT m n == n)
minT-out ⟨-2⟩ _ = inl idp
minT-out (S _) ⟨-2⟩ = inr idp
minT-out (S m) (S n) with minT-out m n
minT-out (S m) (S n) | inl p = inl (ap S p)
minT-out (S m) (S n) | inr q = inr (ap S q)
minT-out-l : {m n : ℕ₋₂} → (m ≤T n) → minT m n == m
minT-out-l {m} {n} lte with minT-out m n
minT-out-l lte | inl eqm = eqm
minT-out-l (inl p) | inr eqn = eqn ∙ ! p
minT-out-l {m} {n} (inr lt) | inr eq =
⊥-rec (<T-to-≱T (transport (λ k → m <T k) (! eq) lt) (minT≤l m n))
| 27.858639
| 77
| 0.440707
|
298d64711ed604760b2432dc45e60487d1b4978b
| 8,220
|
agda
|
Agda
|
Cubical/HITs/FiniteMultiset/CountExtensionality.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | null | null | null |
Cubical/HITs/FiniteMultiset/CountExtensionality.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | 1
|
2022-01-27T02:07:48.000Z
|
2022-01-27T02:07:48.000Z
|
Cubical/HITs/FiniteMultiset/CountExtensionality.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | 1
|
2021-11-22T02:02:01.000Z
|
2021-11-22T02:02:01.000Z
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.HITs.FiniteMultiset.CountExtensionality where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Data.Nat
open import Cubical.Data.Nat.Order
open import Cubical.Data.Empty as ⊥
open import Cubical.Data.Sum
open import Cubical.Relation.Nullary
open import Cubical.HITs.FiniteMultiset.Base
open import Cubical.HITs.FiniteMultiset.Properties as FMS
open import Cubical.Structures.MultiSet
open import Cubical.Relation.Nullary.DecidableEq
private
variable
ℓ : Level
-- We define a partial order on FMSet A and use it to proof
-- a strong induction principle for finite multi-sets.
-- Finally, we use this stronger elimination principle to show
-- that any two FMSets can be identified, if they have the same count for every a : A
module _{A : Type ℓ} (discA : Discrete A) where
_≼_ : FMSet A → FMSet A → Type ℓ
xs ≼ ys = ∀ a → FMScount discA a xs ≤ FMScount discA a ys
≼-refl : ∀ xs → xs ≼ xs
≼-refl xs a = ≤-refl
≼-trans : ∀ xs ys zs → xs ≼ ys → ys ≼ zs → xs ≼ zs
≼-trans xs ys zs xs≼ys ys≼zs a = ≤-trans (xs≼ys a) (ys≼zs a)
≼[]→≡[] : ∀ xs → xs ≼ [] → xs ≡ []
≼[]→≡[] xs xs≼[] = FMScount-0-lemma discA xs λ a → ≤0→≡0 (xs≼[] a)
≼-remove1 : ∀ a xs → remove1 discA a xs ≼ xs
≼-remove1 a xs b with discA a b
... | yes a≡b = subst (λ n → n ≤ FMScount discA b xs) (sym path) (≤-predℕ)
where
path : FMScount discA b (remove1 discA a xs) ≡ predℕ (FMScount discA b xs)
path = cong (λ c → FMScount discA b (remove1 discA c xs)) a≡b ∙ remove1-predℕ-lemma discA b xs
... | no a≢b = subst (λ n → n ≤ FMScount discA b xs)
(sym (FMScount-remove1-≢-lemma discA xs λ b≡a → a≢b (sym b≡a))) ≤-refl
≼-remove1-lemma : ∀ x xs ys → ys ≼ (x ∷ xs) → (remove1 discA x ys) ≼ xs
≼-remove1-lemma x xs ys ys≼x∷xs a with discA a x
... | yes a≡x = ≤-trans (≤-trans (0 , p₁) (predℕ-≤-predℕ (ys≼x∷xs a)))
(0 , cong predℕ (FMScount-≡-lemma discA xs a≡x))
where
p₁ : FMScount discA a (remove1 discA x ys) ≡ predℕ (FMScount discA a ys)
p₁ = subst (λ b → FMScount discA a (remove1 discA b ys) ≡ predℕ (FMScount discA a ys)) a≡x (remove1-predℕ-lemma discA a ys)
... | no a≢x = ≤-trans (≤-trans (0 , FMScount-remove1-≢-lemma discA ys a≢x) (ys≼x∷xs a))
(0 , FMScount-≢-lemma discA xs a≢x)
≼-Dichotomy : ∀ x xs ys → ys ≼ (x ∷ xs) → (ys ≼ xs) ⊎ (ys ≡ x ∷ (remove1 discA x ys))
≼-Dichotomy x xs ys ys≼x∷xs with (FMScount discA x ys) ≟ suc (FMScount discA x xs)
... | lt <suc = inl ys≼xs
where
ys≼xs : ys ≼ xs
ys≼xs a with discA a x
... | yes a≡x = pred-≤-pred (subst (λ b → (FMScount discA b ys) < suc (FMScount discA b xs)) (sym a≡x) <suc)
... | no a≢x = ≤-trans (ys≼x∷xs a) (subst (λ n → FMScount discA a (x ∷ xs) ≤ n) (FMScount-≢-lemma discA xs a≢x) ≤-refl)
... | eq ≡suc = inr (remove1-suc-lemma discA x (FMScount discA x xs) ys ≡suc)
... | gt >suc = ⊥.rec (¬m<m strict-ineq)
where
strict-ineq : suc (FMScount discA x xs) < suc (FMScount discA x xs)
strict-ineq = <≤-trans (<≤-trans >suc (ys≼x∷xs x)) (0 , FMScount-≡-lemma-refl discA xs)
-- proving a strong elimination principle for finite multisets
module ≼-ElimProp {ℓ'} {B : FMSet A → Type ℓ'}
(BisProp : ∀ {xs} → isProp (B xs)) (b₀ : B [])
(B-≼-hyp : ∀ x xs → (∀ ys → ys ≼ xs → B ys) → B (x ∷ xs)) where
C : FMSet A → Type (ℓ-max ℓ ℓ')
C xs = ∀ ys → ys ≼ xs → B ys
g : ∀ xs → C xs
g = ElimProp.f (isPropΠ2 (λ _ _ → BisProp)) c₀ θ
where
c₀ : C []
c₀ ys ys≼[] = subst B (sym (≼[]→≡[] ys ys≼[])) b₀
θ : ∀ x {xs} → C xs → C (x ∷ xs)
θ x {xs} hyp ys ys≼x∷xs with ≼-Dichotomy x xs ys ys≼x∷xs
... | inl ys≼xs = hyp ys ys≼xs
... | inr ys≡x∷zs = subst B (sym ys≡x∷zs) (B-≼-hyp x zs χ)
where
zs = remove1 discA x ys
χ : ∀ vs → vs ≼ zs → B vs
χ vs vs≼zs = hyp vs (≼-trans vs zs xs vs≼zs (≼-remove1-lemma x xs ys ys≼x∷xs))
f : ∀ xs → B xs
f = C→B g
where
C→B : (∀ xs → C xs) → (∀ xs → B xs)
C→B C-hyp xs = C-hyp xs xs (≼-refl xs)
≼-ElimPropBin : ∀ {ℓ'} {B : FMSet A → FMSet A → Type ℓ'}
→ (∀ {xs} {ys} → isProp (B xs ys))
→ (B [] [])
→ (∀ x xs ys → (∀ vs ws → vs ≼ xs → ws ≼ ys → B vs ws) → B (x ∷ xs) ys)
→ (∀ x xs ys → (∀ vs ws → vs ≼ xs → ws ≼ ys → B vs ws) → B xs (x ∷ ys))
-------------------------------------------------------------------------------
→ (∀ xs ys → B xs ys)
≼-ElimPropBin {B = B} BisProp b₀₀ left-hyp right-hyp = ≼-ElimProp.f (isPropΠ (λ _ → BisProp)) θ χ
where
θ : ∀ ys → B [] ys
θ = ≼-ElimProp.f BisProp b₀₀ h₁
where
h₁ : ∀ x ys → (∀ ws → ws ≼ ys → B [] ws) → B [] (x ∷ ys)
h₁ x ys mini-h = right-hyp x [] ys h₂
where
h₂ : ∀ vs ws → vs ≼ [] → ws ≼ ys → B vs ws
h₂ vs ws vs≼[] ws≼ys = subst (λ zs → B zs ws) (sym (≼[]→≡[] vs vs≼[])) (mini-h ws ws≼ys)
χ : ∀ x xs → (∀ zs → zs ≼ xs → (∀ ys → B zs ys)) → ∀ ys → B (x ∷ xs) ys
χ x xs h ys = left-hyp x xs ys λ vs ws vs≼xs _ → h vs vs≼xs ws
≼-ElimPropBinSym : ∀ {ℓ'} {B : FMSet A → FMSet A → Type ℓ'}
→ (∀ {xs} {ys} → isProp (B xs ys))
→ (∀ {xs} {ys} → B xs ys → B ys xs)
→ (B [] [])
→ (∀ x xs ys → (∀ vs ws → vs ≼ xs → ws ≼ ys → B vs ws) → B (x ∷ xs) ys)
----------------------------------------------------------------------------
→ (∀ xs ys → B xs ys)
≼-ElimPropBinSym {B = B} BisProp BisSym b₀₀ left-hyp = ≼-ElimPropBin BisProp b₀₀ left-hyp right-hyp
where
right-hyp : ∀ x xs ys → (∀ vs ws → vs ≼ xs → ws ≼ ys → B vs ws) → B xs (x ∷ ys)
right-hyp x xs ys h₁ = BisSym (left-hyp x ys xs (λ vs ws vs≼ys ws≼xs → BisSym (h₁ ws vs ws≼xs vs≼ys)))
-- The main result
module FMScountExt where
B : FMSet A → FMSet A → Type ℓ
B xs ys = (∀ a → FMScount discA a xs ≡ FMScount discA a ys) → xs ≡ ys
BisProp : ∀ {xs} {ys} → isProp (B xs ys)
BisProp = isPropΠ λ _ → trunc _ _
BisSym : ∀ {xs} {ys} → B xs ys → B ys xs
BisSym {xs} {ys} b h = sym (b (λ a → sym (h a)))
b₀₀ : B [] []
b₀₀ _ = refl
left-hyp : ∀ x xs ys → (∀ vs ws → vs ≼ xs → ws ≼ ys → B vs ws) → B (x ∷ xs) ys
left-hyp x xs ys hyp h₁ = (λ i → x ∷ (hyp-path i)) ∙ sym path
where
eq₁ : FMScount discA x ys ≡ suc (FMScount discA x xs)
eq₁ = sym (h₁ x) ∙ FMScount-≡-lemma-refl discA xs
path : ys ≡ x ∷ (remove1 discA x ys)
path = remove1-suc-lemma discA x (FMScount discA x xs) ys eq₁
hyp-path : xs ≡ remove1 discA x ys
hyp-path = hyp xs (remove1 discA x ys) (≼-refl xs) (≼-remove1 x ys) θ
where
θ : ∀ a → FMScount discA a xs ≡ FMScount discA a (remove1 discA x ys)
θ a with discA a x
... | yes a≡x = subst (λ b → FMScount discA b xs ≡ FMScount discA b (remove1 discA x ys)) (sym a≡x) eq₂
where
eq₂ : FMScount discA x xs ≡ FMScount discA x (remove1 discA x ys)
eq₂ = FMScount discA x xs ≡⟨ cong predℕ (sym (FMScount-≡-lemma-refl discA xs)) ⟩
predℕ (FMScount discA x (x ∷ xs)) ≡⟨ cong predℕ (h₁ x) ⟩
predℕ (FMScount discA x ys) ≡⟨ sym (remove1-predℕ-lemma discA x ys) ⟩
FMScount discA x (remove1 discA x ys) ∎
... | no a≢x =
FMScount discA a xs ≡⟨ sym (FMScount-≢-lemma discA xs a≢x) ⟩
FMScount discA a (x ∷ xs) ≡⟨ h₁ a ⟩
FMScount discA a ys ≡⟨ cong (FMScount discA a) path ⟩
FMScount discA a (x ∷ (remove1 discA x ys)) ≡⟨ FMScount-≢-lemma discA (remove1 discA x ys) a≢x ⟩
FMScount discA a (remove1 discA x ys) ∎
Thm : ∀ xs ys → (∀ a → FMScount discA a xs ≡ FMScount discA a ys) → xs ≡ ys
Thm = ≼-ElimPropBinSym BisProp BisSym b₀₀ left-hyp
| 42.8125
| 126
| 0.509854
|
294de7e13ce27566c48cc7868a767ed948726ad4
| 136
|
agda
|
Agda
|
test/interaction/Issue835.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/interaction/Issue835.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/interaction/Issue835.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module Issue835 where
data _≡_ {A : Set} (x : A) : A → Set where
refl : x ≡ x
postulate
A : Set
x y : A
F : x ≡ y → Set
F ()
| 9.714286
| 42
| 0.507353
|
4da4acc0d914449b06258226971051f3f4959e9a
| 358
|
agda
|
Agda
|
src/Calf/Prelude.agda
|
jonsterling/agda-calf
|
e51606f9ca18d8b4cf9a63c2d6caa2efc5516146
|
[
"Apache-2.0"
] | 29
|
2021-07-14T03:18:28.000Z
|
2022-03-22T20:35:11.000Z
|
src/Calf/Prelude.agda
|
jonsterling/agda-calf
|
e51606f9ca18d8b4cf9a63c2d6caa2efc5516146
|
[
"Apache-2.0"
] | null | null | null |
src/Calf/Prelude.agda
|
jonsterling/agda-calf
|
e51606f9ca18d8b4cf9a63c2d6caa2efc5516146
|
[
"Apache-2.0"
] | 2
|
2021-10-06T10:28:24.000Z
|
2022-01-29T08:12:01.000Z
|
{-# OPTIONS --prop --without-K --rewriting #-}
module Calf.Prelude where
open import Agda.Builtin.Equality
open import Agda.Builtin.Equality.Rewrite public
Ω = Prop
□ = Set
postulate
funext : ∀ {a b} {A : Set a} {B : A → Set b} {f g : (a : A) → B a} → (∀ x → f x ≡ g x) → f ≡ g
funext/Ω : {A : Prop} {B : □} {f g : A → B} → (∀ x → f x ≡ g x) → f ≡ g
| 25.571429
| 96
| 0.541899
|
18f29788b940c4eb0211e45645b991954ea25623
| 588
|
agda
|
Agda
|
test/Fail/Issue3855OccursErasedDefinition.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/Issue3855OccursErasedDefinition.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/Issue3855OccursErasedDefinition.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2019-10-01, continuing issue #3855 (erasure modality @0)
-- Test case by Nisse at https://github.com/agda/agda/issues/3855#issuecomment-527164352
-- Occurs check needs to take erasure status of definitions
-- (here: postulates) into account.
postulate
P : Set → Set
p : (A : Set) → P A
@0 A : Set
-- fails : P A
-- fails = p A
test : P A
test = p _
-- Should fail with error like:
--
-- Cannot instantiate the metavariable _2 to solution A
-- since (part of) the solution was created in an erased context
-- when checking that the expression p _ has type P A
| 25.565217
| 88
| 0.687075
|
4118df13c7463e5d3f471e7b31b14ea61320f998
| 138
|
agda
|
Agda
|
Cubical/Codata/M/AsLimit/Coalg.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 301
|
2018-10-17T18:00:24.000Z
|
2022-03-24T02:10:47.000Z
|
Cubical/Codata/M/AsLimit/Coalg.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 584
|
2018-10-15T09:49:02.000Z
|
2022-03-30T12:09:17.000Z
|
Cubical/Codata/M/AsLimit/Coalg.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 134
|
2018-11-16T06:11:03.000Z
|
2022-03-23T16:22:13.000Z
|
{-# OPTIONS --guardedness --safe #-}
module Cubical.Codata.M.AsLimit.Coalg where
open import Cubical.Codata.M.AsLimit.Coalg.Base public
| 23
| 54
| 0.76087
|
185e4d553236541997fc5b066df92f784b13ded5
| 1,914
|
agda
|
Agda
|
agda/Number/InclusionModules.agda
|
mchristianl/synthetic-reals
|
10206b5c3eaef99ece5d18bf703c9e8b2371bde4
|
[
"MIT"
] | 3
|
2020-07-31T18:15:26.000Z
|
2022-02-19T12:15:21.000Z
|
agda/Number/InclusionModules.agda
|
mchristianl/synthetic-reals
|
10206b5c3eaef99ece5d18bf703c9e8b2371bde4
|
[
"MIT"
] | null | null | null |
agda/Number/InclusionModules.agda
|
mchristianl/synthetic-reals
|
10206b5c3eaef99ece5d18bf703c9e8b2371bde4
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --no-import-sorts #-}
module Number.InclusionModules where
import Number.Postulates
import Number.Inclusions
-- NOTE: the following takes a very long time to typecheck
-- see https://lists.chalmers.se/pipermail/agda-dev/2015-September/000201.html
-- see https://github.com/agda/agda/issues/1646
-- Exponential module chain leads to infeasible scope checking
module Isℕ↪ℤ = Number.Inclusions.IsROrderedCommSemiringInclusion Number.Postulates.ℕ↪ℤinc
module Isℕ↪ℚ = Number.Inclusions.IsROrderedCommSemiringInclusion Number.Postulates.ℕ↪ℚinc
module Isℕ↪ℂ = Number.Inclusions.Isℕ↪ℂ Number.Postulates.ℕ↪ℂinc
module Isℕ↪ℝ = Number.Inclusions.IsROrderedCommSemiringInclusion Number.Postulates.ℕ↪ℝinc
module Isℤ↪ℚ = Number.Inclusions.IsROrderedCommRingInclusion Number.Postulates.ℤ↪ℚinc
module Isℤ↪ℝ = Number.Inclusions.IsROrderedCommRingInclusion Number.Postulates.ℤ↪ℝinc
module Isℤ↪ℂ = Number.Inclusions.Isℤ↪ℂ Number.Postulates.ℤ↪ℂinc
module Isℚ↪ℝ = Number.Inclusions.IsROrderedFieldInclusion Number.Postulates.ℚ↪ℝinc
module Isℚ↪ℂ = Number.Inclusions.IsRFieldInclusion Number.Postulates.ℚ↪ℂinc
module Isℝ↪ℂ = Number.Inclusions.IsRFieldInclusion Number.Postulates.ℝ↪ℂinc
{-
-- NOTE: the following is a little faster but does not help us
module Isℕ↪ℤ = Number.Inclusions.IsROrderedCommSemiringInclusion
module Isℕ↪ℚ = Number.Inclusions.IsROrderedCommSemiringInclusion
module Isℕ↪ℂ = Number.Inclusions.Isℕ↪ℂ
module Isℕ↪ℝ = Number.Inclusions.IsROrderedCommSemiringInclusion
module Isℤ↪ℚ = Number.Inclusions.IsROrderedCommRingInclusion
module Isℤ↪ℝ = Number.Inclusions.IsROrderedCommRingInclusion
module Isℤ↪ℂ = Number.Inclusions.Isℤ↪ℂ
module Isℚ↪ℝ = Number.Inclusions.IsROrderedFieldInclusion
module Isℚ↪ℂ = Number.Inclusions.IsRFieldInclusion
module Isℝ↪ℂ = Number.Inclusions.IsRFieldInclusion
-}
| 50.368421
| 89
| 0.784222
|
20baf87b539733db297ad34dd41aa8e1f01c1905
| 1,468
|
agda
|
Agda
|
test/Fail/Issue5531.agda
|
cagix/agda
|
cc026a6a97a3e517bb94bafa9d49233b067c7559
|
[
"BSD-2-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/Issue5531.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/Issue5531.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
{-# OPTIONS --type-in-type --rewriting #-}
open import Agda.Builtin.Sigma
open import Agda.Builtin.Equality
coe : {A B : Set} → A ≡ B → A → B
coe refl x = x
{-# BUILTIN REWRITE _≡_ #-}
Tel = Set
U = Set
variable
Δ : Tel
A B : Δ → U
δ₀ δ₁ : Δ
postulate
IdTel : (Δ : Tel)(δ₀ δ₁ : Δ) → Tel
Id : (A : Δ → U){δ₀ δ₁ : Δ}(δ₂ : IdTel Δ δ₀ δ₁) → A δ₀ → A δ₁ → U
ap : {A : Δ → U}(a : (δ : Δ) → A δ)
→ {δ₀ δ₁ : Δ}(δ₂ : IdTel Δ δ₀ δ₁) → Id A δ₂ (a δ₀) (a δ₁)
idTel-sigma : {a₀ : A δ₀}{a₁ : A δ₁}
→ IdTel (Σ Δ A) (δ₀ , a₀) (δ₁ , a₁)
≡ Σ (IdTel Δ δ₀ δ₁) (λ δ₂ → Id A δ₂ a₀ a₁)
{-# REWRITE idTel-sigma #-}
id-u : {A₀ A₁ : U}{δ₂ : IdTel Δ δ₀ δ₁}
→ Id {Δ = Δ}(λ _ → U) δ₂ A₀ A₁ ≡ (A₀ → A₁ → U)
{-# REWRITE id-u #-}
id-ap : {δ₂ : IdTel Δ δ₀ δ₁}{a₀ : A δ₀}{a₁ : A δ₁}
→ Id A δ₂ a₀ a₁ ≡ ap {A = λ _ → U} A δ₂ a₀ a₁
ap-sigma : {δ₂ : IdTel Δ δ₀ δ₁}{a₀ : A δ₀}{a₁ : A δ₁}
{B : (δ : Δ) → A δ → U}
{b₀ : B δ₀ a₀}{b₁ : B δ₁ a₁}→
ap {Δ = Δ}{A = λ _ → U} (λ δ → Σ (A δ) (B δ))
δ₂ (a₀ , b₀) (a₁ , b₁) ≡
Σ (Id A δ₂ a₀ a₁) λ a₂ → Id {Δ = Σ Δ A} (λ (δ , a) → B δ a) (δ₂ , a₂) b₀ b₁
{-# REWRITE ap-sigma #-}
{-# REWRITE id-ap #-}
ap-proj₁ : {δ₂ : IdTel Δ δ₀ δ₁}
{B : (δ : Δ) → A δ → U}
{ab : (δ : Δ) → Σ (A δ) (B δ)}
→ ap {Δ = Δ}{A = A}(λ δ → fst (ab δ)) δ₂
≡ fst (ap ab δ₂)
| 28.784314
| 91
| 0.412125
|
12cdf0d63ffd93f82a1910bd40b41e7546c65c92
| 1,953
|
agda
|
Agda
|
src/Categories/Functor/Monoidal/Symmetric.agda
|
o1lo01ol1o/agda-categories
|
5fc007768264a270b8ff319570225986773da601
|
[
"MIT"
] | null | null | null |
src/Categories/Functor/Monoidal/Symmetric.agda
|
o1lo01ol1o/agda-categories
|
5fc007768264a270b8ff319570225986773da601
|
[
"MIT"
] | null | null | null |
src/Categories/Functor/Monoidal/Symmetric.agda
|
o1lo01ol1o/agda-categories
|
5fc007768264a270b8ff319570225986773da601
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category.Monoidal.Structure
using (SymmetricMonoidalCategory)
module Categories.Functor.Monoidal.Symmetric {o o′ ℓ ℓ′ e e′}
(C : SymmetricMonoidalCategory o ℓ e) (D : SymmetricMonoidalCategory o′ ℓ′ e′)
where
open import Level
open import Data.Product using (_,_)
open import Categories.Functor using (Functor)
open import Categories.Functor.Monoidal
private
module C = SymmetricMonoidalCategory C renaming (braidedMonoidalCategory to B)
module D = SymmetricMonoidalCategory D renaming (braidedMonoidalCategory to B)
import Categories.Functor.Monoidal.Braided C.B D.B as Braided
module Lax where
open Braided.Lax
-- Lax symmetric monoidal functors are just lax braided monoidal
-- functors between symmetric monoidal categories.
record SymmetricMonoidalFunctor : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where
field
F : Functor C.U D.U
isBraidedMonoidal : IsBraidedMonoidalFunctor F
open Functor F public
open IsBraidedMonoidalFunctor isBraidedMonoidal public
monoidalFunctor : MonoidalFunctor C.monoidalCategory D.monoidalCategory
monoidalFunctor = record { isMonoidal = isMonoidal }
module Strong where
open Braided.Strong
-- Strong symmetric monoidal functors are just strong braided
-- monoidal functors between symmetric monoidal categories.
record SymmetricMonoidalFunctor : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where
field
F : Functor C.U D.U
isBraidedMonoidal : IsBraidedMonoidalFunctor F
open Functor F public
open IsBraidedMonoidalFunctor isBraidedMonoidal public
monoidalFunctor : StrongMonoidalFunctor C.monoidalCategory D.monoidalCategory
monoidalFunctor = record { isStrongMonoidal = isStrongMonoidal }
laxSymmetricMonoidalFunctor : Lax.SymmetricMonoidalFunctor
laxSymmetricMonoidalFunctor = record
{ isBraidedMonoidal = isLaxBraidedMonoidal }
| 33.101695
| 81
| 0.75064
|
cb3ff8fa9679b48e65965f64f244d794c540fa5d
| 1,206
|
agda
|
Agda
|
src/Categories/Minus2-Category.agda
|
turion/agda-categories
|
ad0f94b6cf18d8a448b844b021aeda58e833d152
|
[
"MIT"
] | 279
|
2019-06-01T14:36:40.000Z
|
2022-03-22T00:40:14.000Z
|
src/Categories/Minus2-Category.agda
|
seanpm2001/agda-categories
|
d9e4f578b126313058d105c61707d8c8ae987fa8
|
[
"MIT"
] | 236
|
2019-06-01T14:53:54.000Z
|
2022-03-28T14:31:43.000Z
|
src/Categories/Minus2-Category.agda
|
seanpm2001/agda-categories
|
d9e4f578b126313058d105c61707d8c8ae987fa8
|
[
"MIT"
] | 64
|
2019-06-02T16:58:15.000Z
|
2022-03-14T02:00:59.000Z
|
{-# OPTIONS --without-K --safe #-}
-- 'Traditionally', meaning in nLab and in
-- "Lectures on n-Categories and Cohomology" by Baez and Shulman
-- https://arxiv.org/abs/math/0608420
-- (-2)-Categories are defined to be just a single value, with trivial Hom
-- But that's hardly a definition of a class of things, it's a definition of
-- a single structure! What we want is the definition of a class which turns
-- out to be (essentially) unique. Rather like the reals are (essentially) the
-- only ordered complete archimedean field.
-- So we will take a -2-Category to be a full-fledge Category, but where
-- 1. |Obj| is (Categorically) contractible
-- 2. |Hom| is connected (all arrows are equal)
-- Note that we don't need to say anything at all about ≈
module Categories.Minus2-Category where
open import Level
open import Categories.Category
open import Data.Product using (Σ)
import Categories.Morphism as M
private
variable
o ℓ e : Level
record -2-Category : Set (suc (o ⊔ ℓ ⊔ e)) where
field
cat : Category o ℓ e
open Category cat public
open M cat using (_≅_)
field
Obj-Contr : Σ Obj (λ x → (y : Obj) → x ≅ y)
Hom-Conn : {x y : Obj} {f g : x ⇒ y} → f ≈ g
| 31.736842
| 78
| 0.689055
|
c591b069716d5f353eb93b0fc5c18143566c5856
| 26
|
agda
|
Agda
|
test/interaction/space in the path/BehindSpaces.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/interaction/space in the path/BehindSpaces.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/interaction/space in the path/BehindSpaces.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module BehindSpaces where
| 13
| 25
| 0.884615
|
2316d1a470eeedbd50933749858b01472d803920
| 4,944
|
agda
|
Agda
|
Structure/Operator/Vector/LinearCombination/Proofs.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | 6
|
2020-04-07T17:58:13.000Z
|
2022-02-05T06:53:22.000Z
|
Structure/Operator/Vector/LinearCombination/Proofs.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
Structure/Operator/Vector/LinearCombination/Proofs.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
import Lvl
open import Structure.Operator.Vector
open import Structure.Setoid
open import Type
module Structure.Operator.Vector.LinearCombination.Proofs
{ℓᵥ ℓₛ ℓᵥₑ ℓₛₑ}
{V : Type{ℓᵥ}} ⦃ equiv-V : Equiv{ℓᵥₑ}(V) ⦄
{S : Type{ℓₛ}} ⦃ equiv-S : Equiv{ℓₛₑ}(S) ⦄
{_+ᵥ_ : V → V → V}
{_⋅ₛᵥ_ : S → V → V}
{_+ₛ_ _⋅ₛ_ : S → S → S}
⦃ vectorSpace : VectorSpace(_+ᵥ_)(_⋅ₛᵥ_)(_+ₛ_)(_⋅ₛ_) ⦄
where
open VectorSpace(vectorSpace)
import Lvl
open import Function.Equals
open import Logic.Predicate
open import Numeral.CoordinateVector as Vec using () renaming (Vector to Vec)
open import Numeral.Finite
open import Numeral.Natural
open import Structure.Function.Multi
import Structure.Function.Names as Names
open import Structure.Operator.Proofs.Util
open import Structure.Operator.Properties
open import Structure.Operator
open import Structure.Operator.Vector.LinearCombination ⦃ vectorSpace = vectorSpace ⦄
open import Structure.Operator.Vector.Proofs
open import Structure.Relator.Properties
open import Syntax.Function
open import Syntax.Number
open import Syntax.Transitivity
open import Type
private variable ℓ ℓ₁ ℓ₂ ℓₗ : Lvl.Level
private variable n n₁ n₂ : ℕ
private variable i j k : 𝕟(n)
private variable vf vf₁ vf₂ : Vec(n)(V)
private variable sf sf₁ sf₂ : Vec(n)(S)
instance
linearCombination-binaryOperator : BinaryOperator(linearCombination{n})
linearCombination-binaryOperator = intro p where
p : Names.Congruence₂(linearCombination{n})
p {𝟎} {vf₁} {vf₂} (intro vfeq) {sf₁} {sf₂} (intro sfeq) = reflexivity(_≡_)
p {𝐒(𝟎)} {vf₁} {vf₂} (intro vfeq) {sf₁} {sf₂} (intro sfeq) = congruence₂(_⋅ₛᵥ_) sfeq vfeq
p {𝐒(𝐒(n))} {vf₁} {vf₂} (intro vfeq) {sf₁} {sf₂} (intro sfeq) =
(sf₁(𝟎) ⋅ₛᵥ vf₁(𝟎)) +ᵥ linearCombination(Vec.tail vf₁) (Vec.tail sf₁) 🝖[ _≡_ ]-[ congruence₂(_+ᵥ_) (congruence₂(_⋅ₛᵥ_) sfeq vfeq) (p {𝐒(n)} (intro vfeq) (intro sfeq)) ]
(sf₂(𝟎) ⋅ₛᵥ vf₂(𝟎)) +ᵥ linearCombination(Vec.tail vf₂) (Vec.tail sf₂) 🝖-end
instance
linearCombination-scalar-preserves-[+] : Preserving₂(linearCombination vf) (Vec.map₂(_+ₛ_)) (_+ᵥ_)
linearCombination-scalar-preserves-[+] {vf = vf} = intro(p{vf = vf}) where
p : ∀{n}{vf : Vec(n)(V)} → Names.Preserving₂(linearCombination vf) (Vec.map₂(_+ₛ_)) (_+ᵥ_)
p {𝟎}{vf} {sf₁} {sf₂} =
𝟎ᵥ 🝖[ _≡_ ]-[ identityₗ(_+ᵥ_)(𝟎ᵥ) ]-sym
𝟎ᵥ +ᵥ 𝟎ᵥ 🝖-end
p {𝐒(𝟎)}{vf} {sf₁} {sf₂} =
(Vec.map₂(_+ₛ_) sf₁ sf₂ 𝟎) ⋅ₛᵥ vf(𝟎) 🝖[ _≡_ ]-[]
(sf₁(𝟎) +ₛ sf₂(𝟎)) ⋅ₛᵥ vf(𝟎) 🝖[ _≡_ ]-[ [⋅ₛᵥ][+ₛ][+ᵥ]-distributivityᵣ ]
(sf₁(𝟎) ⋅ₛᵥ vf(𝟎)) +ᵥ (sf₂(𝟎) ⋅ₛᵥ vf(𝟎)) 🝖-end
p {𝐒(𝐒(n))}{vf} {sf₁} {sf₂} =
((Vec.map₂(_+ₛ_) sf₁ sf₂ 𝟎) ⋅ₛᵥ vf(𝟎)) +ᵥ (linearCombination {𝐒(n)} (Vec.tail vf) (Vec.tail(Vec.map₂(_+ₛ_) sf₁ sf₂))) 🝖[ _≡_ ]-[]
((sf₁(𝟎) +ₛ sf₂(𝟎)) ⋅ₛᵥ vf(𝟎)) +ᵥ (linearCombination {𝐒(n)} (Vec.tail vf) (Vec.tail(Vec.map₂(_+ₛ_) sf₁ sf₂))) 🝖[ _≡_ ]-[ congruence₂(_+ᵥ_) [⋅ₛᵥ][+ₛ][+ᵥ]-distributivityᵣ (p {𝐒(n)}{Vec.tail vf} {Vec.tail sf₁} {Vec.tail sf₂}) ]
((sf₁(𝟎) ⋅ₛᵥ vf(𝟎)) +ᵥ (sf₂(𝟎) ⋅ₛᵥ vf(𝟎))) +ᵥ ((linearCombination {𝐒(n)} (Vec.tail vf) (Vec.tail sf₁)) +ᵥ (linearCombination {𝐒(n)} (Vec.tail vf) (Vec.tail sf₂))) 🝖[ _≡_ ]-[ One.associate-commute4 (commutativity(_+ᵥ_)) ]
(((sf₁(𝟎) ⋅ₛᵥ vf(𝟎)) +ᵥ (linearCombination {𝐒(n)} (Vec.tail vf) (Vec.tail sf₁))) +ᵥ ((sf₂(𝟎) ⋅ₛᵥ vf(𝟎)) +ᵥ (linearCombination {𝐒(n)} (Vec.tail vf) (Vec.tail sf₂)))) 🝖-end
instance
linearCombination-scalar-preserves-[⋅] : ∀{s} → Preserving₁(linearCombination vf) (Vec.map(s ⋅ₛ_)) (s ⋅ₛᵥ_)
linearCombination-scalar-preserves-[⋅] {vf = vf} {s = s} = intro(p{vf = vf}) where
p : ∀{n}{vf : Vec(n)(V)} → Names.Preserving₁(linearCombination vf) (Vec.map(s ⋅ₛ_)) (s ⋅ₛᵥ_)
p {𝟎} {vf} {sf} =
𝟎ᵥ 🝖[ _≡_ ]-[ [⋅ₛᵥ]-absorberᵣ ]-sym
s ⋅ₛᵥ 𝟎ᵥ 🝖-end
p {𝐒(𝟎)} {vf} {sf} =
(s ⋅ₛ sf(𝟎)) ⋅ₛᵥ vf(𝟎) 🝖[ _≡_ ]-[ [⋅ₛ][⋅ₛᵥ]-compatibility ]
s ⋅ₛᵥ (sf(𝟎) ⋅ₛᵥ vf(𝟎)) 🝖-end
p {𝐒(𝐒(n))} {vf} {sf} =
linearCombination vf (Vec.map (s ⋅ₛ_) sf) 🝖[ _≡_ ]-[]
((s ⋅ₛ sf(𝟎)) ⋅ₛᵥ vf(𝟎)) +ᵥ (linearCombination (Vec.tail vf) (Vec.map (s ⋅ₛ_) (Vec.tail sf))) 🝖[ _≡_ ]-[ congruence₂(_+ᵥ_) ⦃ [+ᵥ]-binary-operator ⦄ [⋅ₛ][⋅ₛᵥ]-compatibility (p {𝐒(n)} {Vec.tail vf} {Vec.tail sf}) ]
(s ⋅ₛᵥ (sf(𝟎) ⋅ₛᵥ vf(𝟎))) +ᵥ (s ⋅ₛᵥ (linearCombination (Vec.tail vf) (Vec.tail sf))) 🝖[ _≡_ ]-[ distributivityₗ(_⋅ₛᵥ_)(_+ᵥ_) ]-sym
s ⋅ₛᵥ ((sf(𝟎) ⋅ₛᵥ vf(𝟎)) +ᵥ (linearCombination (Vec.tail vf) (Vec.tail sf))) 🝖[ _≡_ ]-[]
s ⋅ₛᵥ (linearCombination vf sf) 🝖-end
-- linearCombination-of-unit : linearCombination vf (Vec.fill 𝟏ₛ) ≡ (foldᵣ(_+_) 𝟎ᵥ vf)
postulate linearCombination-of-indexProject : (linearCombination vf (Vec.indexProject i 𝟏ₛ 𝟎ₛ) ≡ vf(i))
| 55.550562
| 285
| 0.591828
|
18af3d0e94e08557428b7293ad64c1b83bb314cc
| 582
|
agda
|
Agda
|
Agda/RevRev.agda
|
Brethland/LEARNING-STUFF
|
eb2cef0556efb9a4ce11783f8516789ea48cc344
|
[
"MIT"
] | 2
|
2020-02-03T05:05:52.000Z
|
2020-03-11T10:35:42.000Z
|
Agda/RevRev.agda
|
Brethland/LEARNING-STUFF
|
eb2cef0556efb9a4ce11783f8516789ea48cc344
|
[
"MIT"
] | null | null | null |
Agda/RevRev.agda
|
Brethland/LEARNING-STUFF
|
eb2cef0556efb9a4ce11783f8516789ea48cc344
|
[
"MIT"
] | 1
|
2019-12-13T04:50:46.000Z
|
2019-12-13T04:50:46.000Z
|
{-# OPTIONS --safe #-}
module RevRev where
open import Relation.Binary.PropositionalEquality
open import Data.List
open import Data.List.Properties
rev : ∀ {ℓ} {A : Set ℓ} → List A → List A
rev [] = []
rev (x ∷ xs) = rev xs ++ x ∷ []
lemma : ∀ {ℓ} {A : Set ℓ} (a b : List A) → rev (a ++ b) ≡ rev b ++ rev a
lemma [] b rewrite ++-identityʳ (rev b) = refl
lemma (x ∷ a) b rewrite lemma a b | ++-assoc (rev b) (rev a) (x ∷ []) = refl
revrevid : ∀ {ℓ} {A : Set ℓ} (a : List A) → rev (rev a) ≡ a
revrevid [] = refl
revrevid (x ∷ a) rewrite lemma (rev a) (x ∷ []) | revrevid a = refl
| 30.631579
| 76
| 0.573883
|
a1f6f46ecd6fd03c588834a85c90a84751640b37
| 8,181
|
agda
|
Agda
|
test/asset/agda-stdlib-1.0/Data/Product/Relation/Binary/Lex/NonStrict.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Data/Product/Relation/Binary/Lex/NonStrict.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Data/Product/Relation/Binary/Lex/NonStrict.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Lexicographic products of binary relations
------------------------------------------------------------------------
-- The definition of lexicographic product used here is suitable if
-- the left-hand relation is a (non-strict) partial order.
{-# OPTIONS --without-K --safe #-}
module Data.Product.Relation.Binary.Lex.NonStrict where
open import Data.Product using (_×_; _,_; proj₁; proj₂)
open import Data.Sum using (inj₁; inj₂)
open import Relation.Binary
open import Relation.Binary.Consequences
import Relation.Binary.Construct.NonStrictToStrict as Conv
open import Data.Product.Relation.Binary.Pointwise.NonDependent as Pointwise
using (Pointwise)
import Data.Product.Relation.Binary.Lex.Strict as Strict
module _ {a₁ a₂ ℓ₁ ℓ₂} {A₁ : Set a₁} {A₂ : Set a₂} where
------------------------------------------------------------------------
-- A lexicographic ordering over products
×-Lex : (_≈₁_ _≤₁_ : Rel A₁ ℓ₁) (_≤₂_ : Rel A₂ ℓ₂) → Rel (A₁ × A₂) _
×-Lex _≈₁_ _≤₁_ _≤₂_ = Strict.×-Lex _≈₁_ (Conv._<_ _≈₁_ _≤₁_) _≤₂_
------------------------------------------------------------------------
-- Some properties which are preserved by ×-Lex (under certain
-- assumptions).
×-reflexive : ∀ _≈₁_ _≤₁_ {_≈₂_} _≤₂_ →
_≈₂_ ⇒ _≤₂_ →
(Pointwise _≈₁_ _≈₂_) ⇒ (×-Lex _≈₁_ _≤₁_ _≤₂_)
×-reflexive _≈₁_ _≤₁_ _≤₂_ refl₂ =
Strict.×-reflexive _≈₁_ (Conv._<_ _≈₁_ _≤₁_) _≤₂_ refl₂
×-transitive : ∀ {_≈₁_ _≤₁_} → IsPartialOrder _≈₁_ _≤₁_ →
∀ {_≤₂_} → Transitive _≤₂_ →
Transitive (×-Lex _≈₁_ _≤₁_ _≤₂_)
×-transitive {_≈₁_} {_≤₁_} po₁ {_≤₂_} trans₂ =
Strict.×-transitive
{_<₁_ = Conv._<_ _≈₁_ _≤₁_}
isEquivalence (Conv.<-resp-≈ _ _ isEquivalence ≤-resp-≈)
(Conv.<-trans _ _ po₁)
{_≤₂_} trans₂
where open IsPartialOrder po₁
×-antisymmetric :
∀ {_≈₁_ _≤₁_} → IsPartialOrder _≈₁_ _≤₁_ →
∀ {_≈₂_ _≤₂_} → Antisymmetric _≈₂_ _≤₂_ →
Antisymmetric (Pointwise _≈₁_ _≈₂_) (×-Lex _≈₁_ _≤₁_ _≤₂_)
×-antisymmetric {_≈₁_} {_≤₁_}
po₁ {_≤₂_ = _≤₂_} antisym₂ =
Strict.×-antisymmetric {_<₁_ = Conv._<_ _≈₁_ _≤₁_}
≈-sym₁ irrefl₁ asym₁
{_≤₂_ = _≤₂_} antisym₂
where
open IsPartialOrder po₁
open Eq renaming (refl to ≈-refl₁; sym to ≈-sym₁)
irrefl₁ : Irreflexive _≈₁_ (Conv._<_ _≈₁_ _≤₁_)
irrefl₁ = Conv.<-irrefl _≈₁_ _≤₁_
asym₁ : Asymmetric (Conv._<_ _≈₁_ _≤₁_)
asym₁ = trans∧irr⟶asym {_≈_ = _≈₁_}
≈-refl₁ (Conv.<-trans _ _ po₁) irrefl₁
×-respects₂ :
∀ {_≈₁_ _≤₁_} → IsEquivalence _≈₁_ → _≤₁_ Respects₂ _≈₁_ →
∀ {_≈₂_ _≤₂_ : Rel A₂ ℓ₂} → _≤₂_ Respects₂ _≈₂_ →
(×-Lex _≈₁_ _≤₁_ _≤₂_) Respects₂ (Pointwise _≈₁_ _≈₂_)
×-respects₂ eq₁ resp₁ resp₂ =
Strict.×-respects₂ eq₁ (Conv.<-resp-≈ _ _ eq₁ resp₁) resp₂
×-decidable : ∀ {_≈₁_ _≤₁_} → Decidable _≈₁_ → Decidable _≤₁_ →
∀ {_≤₂_} → Decidable _≤₂_ →
Decidable (×-Lex _≈₁_ _≤₁_ _≤₂_)
×-decidable dec-≈₁ dec-≤₁ dec-≤₂ =
Strict.×-decidable dec-≈₁ (Conv.<-decidable _ _ dec-≈₁ dec-≤₁)
dec-≤₂
×-total : ∀ {_≈₁_ _≤₁_} → Symmetric _≈₁_ → Decidable _≈₁_ →
Antisymmetric _≈₁_ _≤₁_ → Total _≤₁_ →
∀ {_≤₂_} → Total _≤₂_ →
Total (×-Lex _≈₁_ _≤₁_ _≤₂_)
×-total {_≈₁_} {_≤₁_} sym₁ dec₁ antisym₁ total₁ {_≤₂_} total₂ =
total
where
tri₁ : Trichotomous _≈₁_ (Conv._<_ _≈₁_ _≤₁_)
tri₁ = Conv.<-trichotomous _ _ sym₁ dec₁ antisym₁ total₁
total : Total (×-Lex _≈₁_ _≤₁_ _≤₂_)
total x y with tri₁ (proj₁ x) (proj₁ y)
... | tri< x₁<y₁ x₁≉y₁ x₁≯y₁ = inj₁ (inj₁ x₁<y₁)
... | tri> x₁≮y₁ x₁≉y₁ x₁>y₁ = inj₂ (inj₁ x₁>y₁)
... | tri≈ x₁≮y₁ x₁≈y₁ x₁≯y₁ with total₂ (proj₂ x) (proj₂ y)
... | inj₁ x₂≤y₂ = inj₁ (inj₂ (x₁≈y₁ , x₂≤y₂))
... | inj₂ x₂≥y₂ = inj₂ (inj₂ (sym₁ x₁≈y₁ , x₂≥y₂))
-- Some collections of properties which are preserved by ×-Lex
-- (under certain assumptions).
×-isPartialOrder :
∀ {_≈₁_ _≤₁_} → IsPartialOrder _≈₁_ _≤₁_ →
∀ {_≈₂_ _≤₂_} → IsPartialOrder _≈₂_ _≤₂_ →
IsPartialOrder (Pointwise _≈₁_ _≈₂_) (×-Lex _≈₁_ _≤₁_ _≤₂_)
×-isPartialOrder {_≈₁_} {_≤₁_} po₁
{_≤₂_ = _≤₂_} po₂ = record
{ isPreorder = record
{ isEquivalence = Pointwise.×-isEquivalence
(isEquivalence po₁)
(isEquivalence po₂)
; reflexive = ×-reflexive _≈₁_ _≤₁_ _≤₂_ (reflexive po₂)
; trans = ×-transitive po₁ {_≤₂_ = _≤₂_} (trans po₂)
}
; antisym = ×-antisymmetric {_≤₁_ = _≤₁_} po₁
{_≤₂_ = _≤₂_} (antisym po₂)
}
where open IsPartialOrder
×-isTotalOrder :
∀ {_≈₁_ _≤₁_} → Decidable _≈₁_ → IsTotalOrder _≈₁_ _≤₁_ →
∀ {_≈₂_ _≤₂_} → IsTotalOrder _≈₂_ _≤₂_ →
IsTotalOrder (Pointwise _≈₁_ _≈₂_) (×-Lex _≈₁_ _≤₁_ _≤₂_)
×-isTotalOrder {_≤₁_ = _≤₁_} ≈₁-dec to₁ {_≤₂_ = _≤₂_} to₂ = record
{ isPartialOrder = ×-isPartialOrder
(isPartialOrder to₁) (isPartialOrder to₂)
; total = ×-total {_≤₁_ = _≤₁_} (Eq.sym to₁) ≈₁-dec
(antisym to₁) (total to₁)
{_≤₂_ = _≤₂_} (total to₂)
}
where open IsTotalOrder
×-isDecTotalOrder :
∀ {_≈₁_ _≤₁_} → IsDecTotalOrder _≈₁_ _≤₁_ →
∀ {_≈₂_ _≤₂_} → IsDecTotalOrder _≈₂_ _≤₂_ →
IsDecTotalOrder (Pointwise _≈₁_ _≈₂_) (×-Lex _≈₁_ _≤₁_ _≤₂_)
×-isDecTotalOrder {_≤₁_ = _≤₁_} to₁ {_≤₂_ = _≤₂_} to₂ = record
{ isTotalOrder = ×-isTotalOrder (_≟_ to₁)
(isTotalOrder to₁)
(isTotalOrder to₂)
; _≟_ = Pointwise.×-decidable (_≟_ to₁) (_≟_ to₂)
; _≤?_ = ×-decidable (_≟_ to₁) (_≤?_ to₁) (_≤?_ to₂)
}
where open IsDecTotalOrder
------------------------------------------------------------------------
-- "Packages" can also be combined.
module _ {ℓ₁ ℓ₂ ℓ₃ ℓ₄} where
×-poset : Poset ℓ₁ ℓ₂ _ → Poset ℓ₃ ℓ₄ _ → Poset _ _ _
×-poset p₁ p₂ = record
{ isPartialOrder = ×-isPartialOrder
(isPartialOrder p₁) (isPartialOrder p₂)
} where open Poset
×-totalOrder : DecTotalOrder ℓ₁ ℓ₂ _ → TotalOrder ℓ₃ ℓ₄ _ →
TotalOrder _ _ _
×-totalOrder t₁ t₂ = record
{ isTotalOrder = ×-isTotalOrder T₁._≟_ T₁.isTotalOrder T₂.isTotalOrder
}
where
module T₁ = DecTotalOrder t₁
module T₂ = TotalOrder t₂
×-decTotalOrder : DecTotalOrder ℓ₁ ℓ₂ _ → DecTotalOrder ℓ₃ ℓ₄ _ →
DecTotalOrder _ _ _
×-decTotalOrder t₁ t₂ = record
{ isDecTotalOrder = ×-isDecTotalOrder
(isDecTotalOrder t₁) (isDecTotalOrder t₂)
} where open DecTotalOrder
------------------------------------------------------------------------
-- DEPRECATED NAMES
------------------------------------------------------------------------
-- Please use the new names as continuing support for the old names is
-- not guaranteed.
-- Version 0.15
_×-isPartialOrder_ = ×-isPartialOrder
{-# WARNING_ON_USAGE _×-isPartialOrder_
"Warning: _×-isPartialOrder_ was deprecated in v0.15.
Please use ×-isPartialOrder instead."
#-}
_×-isDecTotalOrder_ = ×-isDecTotalOrder
{-# WARNING_ON_USAGE _×-isDecTotalOrder_
"Warning: _×-isDecTotalOrder_ was deprecated in v0.15.
Please use ×-isDecTotalOrder instead."
#-}
_×-poset_ = ×-poset
{-# WARNING_ON_USAGE _×-poset_
"Warning: _×-poset_ was deprecated in v0.15.
Please use ×-poset instead."
#-}
_×-totalOrder_ = ×-totalOrder
{-# WARNING_ON_USAGE _×-totalOrder_
"Warning: _×-totalOrder_ was deprecated in v0.15.
Please use ×-totalOrder instead."
#-}
_×-decTotalOrder_ = ×-decTotalOrder
{-# WARNING_ON_USAGE _×-decTotalOrder_
"Warning: _×-decTotalOrder_ was deprecated in v0.15.
Please use ×-decTotalOrder instead."
#-}
×-≈-respects₂ = ×-respects₂
{-# WARNING_ON_USAGE ×-≈-respects₂
"Warning: ×-≈-respects₂ was deprecated in v0.15.
Please use ×-respects₂ instead."
#-}
| 37.875
| 76
| 0.554455
|
Subsets and Splits
HTML Code Excluding Scripts
The query retrieves a limited set of HTML content entries that are longer than 8 characters and do not contain script tags, offering only basic filtering with minimal analytical value.