Search is not available for this dataset
text
string | meta
dict |
---|---|
module Sets.IterativeSet.Relator where
import Lvl
open import Logic.Propositional
open import Logic.Predicate
open import Numeral.Natural
open import Sets.IterativeSet
open import Syntax.Function
open import Type
module _ where
private variable {ℓ ℓ₁ ℓ₂} : Lvl.Level
private variable {A B} : Iset{ℓ}
open Iset
_≡_ : (A : Iset{ℓ₁}) → (B : Iset{ℓ₂}) → Type{ℓ₁ Lvl.⊔ ℓ₂}
record _⊆_ (A : Iset{ℓ₁}) (B : Iset{ℓ₂}) : Type{ℓ₁ Lvl.⊔ ℓ₂}
_⊇_ : Iset{ℓ₁} → Iset{ℓ₂} → Type{ℓ₁ Lvl.⊔ ℓ₂}
-- Set equality is by definition the antisymmetric property of the subset relation.
_≡_ A B = (A ⊇ B) ∧ (A ⊆ B)
-- Set membership is the existence of an index in the set that points to a set equal element to the element.
_∈_ : Iset{ℓ₁} → Iset{ℓ₂} → Type{ℓ₁ Lvl.⊔ ℓ₂}
a ∈ B = ∃{Obj = Index(B)} (ib ↦ a ≡ elem(B)(ib))
-- Set subset is a mapping between the indices such that they point to the same element in both sets.
record _⊆_ A B where
constructor intro
inductive
eta-equality
field
map : Index(A) → Index(B)
proof : ∀{ia} → (elem(A)(ia) ≡ elem(B)(map(ia)))
A ⊇ B = B ⊆ A
module _⊇_ where
open _⊆_ public
_∉_ : Iset{ℓ₁} → Iset{ℓ₂} → Type{ℓ₁ Lvl.⊔ ℓ₂}
a ∉ B = ¬(a ∈ B)
|
{
"alphanum_fraction": 0.6334693878,
"avg_line_length": 29.1666666667,
"ext": "agda",
"hexsha": "f08f12a7a217f69bafee8b9bc66130f9a14e0008",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Sets/IterativeSet/Relator.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Sets/IterativeSet/Relator.agda",
"max_line_length": 110,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Sets/IterativeSet/Relator.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z",
"num_tokens": 497,
"size": 1225
}
|
module SizedIO.Object where
open import Data.Product
record Interface : Set₁ where
field
Method : Set
Result : (m : Method) → Set
open Interface public
-- A simple object just returns for a method the response
-- and the object itself
record Object (i : Interface) : Set where
coinductive
field
objectMethod : (m : Method i) → Result i m × Object i
open Object public
_▹_ : {A : Set} → {B : Set} → A → (A → B) → B
a ▹ f = f a
|
{
"alphanum_fraction": 0.6548672566,
"avg_line_length": 19.652173913,
"ext": "agda",
"hexsha": "2882d3943169078ea7330b332b9d02fa1a8589a0",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z",
"max_forks_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "stephanadls/state-dependent-gui",
"max_forks_repo_path": "src/SizedIO/Object.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "stephanadls/state-dependent-gui",
"max_issues_repo_path": "src/SizedIO/Object.agda",
"max_line_length": 57,
"max_stars_count": 23,
"max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "agda/ooAgda",
"max_stars_repo_path": "src/SizedIO/Object.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z",
"num_tokens": 137,
"size": 452
}
|
A : Set
B : Set₁
B = Set
C : Set
|
{
"alphanum_fraction": 0.4857142857,
"avg_line_length": 5,
"ext": "agda",
"hexsha": "9d2c7e45adb0f338e9a5dcad041d0c3c33d72bc7",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/Issue3233.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Fail/Issue3233.agda",
"max_line_length": 8,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/Issue3233.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 17,
"size": 35
}
|
-- Andreas, AIM XXIII, 2016-04-26 flight EDI-GOT home
-- {-# OPTIONS -v impossible:10 #-}
-- Parameter arguments of overloaded projection applications
-- should not be skipped!
record R A : Set where
field f : A
open R
record S A : Set where
field f : A
open S
module _ (A B : Set) (a : A) where
r : R A
f r = a
test1 = f {A = A} r
test2 = f {A} r
test = f {A = B} r
|
{
"alphanum_fraction": 0.6041131105,
"avg_line_length": 15.56,
"ext": "agda",
"hexsha": "cde49fe14cffe540e0811e4d76c653ff3518c2ef",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "pthariensflame/agda",
"max_forks_repo_path": "test/Fail/Issue1944-checkParams2.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "pthariensflame/agda",
"max_issues_repo_path": "test/Fail/Issue1944-checkParams2.agda",
"max_line_length": 60,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "pthariensflame/agda",
"max_stars_repo_path": "test/Fail/Issue1944-checkParams2.agda",
"max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z",
"num_tokens": 137,
"size": 389
}
|
-- Andreas, 2011-10-03
{-# OPTIONS --experimental-irrelevance #-}
module MatchOnIrrelevantData1 where
data Nat : Set where
zero : Nat
suc : Nat -> Nat
-- the index does not determine the constructor
data Fin : Nat -> Set where
zero : (n : Nat) -> Fin (suc n)
suc : (n : Nat) -> Fin n -> Fin (suc n)
-- should fail:
toNat : (n : Nat) → .(Fin n) -> Nat
toNat (suc n) (zero .n) = zero
toNat (suc n) (suc .n i) = suc (toNat n i)
-- Cannot split on argument of irrelevant datatype Fin (suc @0)
-- when checking the definition of toNat
|
{
"alphanum_fraction": 0.6348623853,
"avg_line_length": 24.7727272727,
"ext": "agda",
"hexsha": "f161a8c28bffb42814225b3499faed73dadd65e6",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "test/fail/MatchOnIrrelevantData1.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "test/fail/MatchOnIrrelevantData1.agda",
"max_line_length": 63,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "redfish64/autonomic-agda",
"max_stars_repo_path": "test/Fail/MatchOnIrrelevantData1.agda",
"max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z",
"num_tokens": 181,
"size": 545
}
|
module Ints.Add.Comm where
open import Ints
open import Nats.Add.Comm
open import Equality
------------------------------------------------------------------------
-- internal stuffs
private
a+b=b+a : ∀ a b → a + b ≡ b + a
a+b=b+a (+ a) (+ b) = + (a :+: b)
≡⟨ cong +_ (nat-add-comm a b) ⟩ + (b :+: a) QED
a+b=b+a (+ a ) (-[1+ b ])
rewrite nat-add-comm a b = refl
a+b=b+a (-[1+ a ]) (+ b )
rewrite nat-add-comm a b = refl
a+b=b+a (-[1+ a ]) (-[1+ b ])
rewrite nat-add-comm a b = refl
------------------------------------------------------------------------
-- public aliases
int-add-comm : ∀ a b → a + b ≡ b + a
int-add-comm = a+b=b+a
|
{
"alphanum_fraction": 0.4,
"avg_line_length": 24.1071428571,
"ext": "agda",
"hexsha": "24259fb94f3a3fde5ba42e57d6df4fbf89ba576f",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "ice1k/Theorems",
"max_forks_repo_path": "src/Ints/Add/Comm.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "ice1k/Theorems",
"max_issues_repo_path": "src/Ints/Add/Comm.agda",
"max_line_length": 72,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "ice1k/Theorems",
"max_stars_repo_path": "src/Ints/Add/Comm.agda",
"max_stars_repo_stars_event_max_datetime": "2020-04-15T15:28:03.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-15T15:28:03.000Z",
"num_tokens": 206,
"size": 675
}
|
-- 2010-09-07 Andreas
-- 2011-10-04 may not work even in the presence of experimental irr.
{-# OPTIONS --experimental-irrelevance #-}
module SplitOnIrrelevant where
data Bool : Set where
true false : Bool
not : .Bool -> Bool
not true = false -- needs to fail
not false = true
|
{
"alphanum_fraction": 0.7117437722,
"avg_line_length": 23.4166666667,
"ext": "agda",
"hexsha": "18a798bc9d9a243ea3d9fa7e6ebf5235cad9a238",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Fail/SplitOnIrrelevant.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Fail/SplitOnIrrelevant.agda",
"max_line_length": 68,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Fail/SplitOnIrrelevant.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 79,
"size": 281
}
|
{-# OPTIONS --cubical --safe #-}
module Cubical.Algebra.BasicProp where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.HLevels
open import Cubical.Data.Sigma
open import Cubical.Structures.Group
private
variable
ℓ ℓ' : Level
---------------------------------------------------------------------
-- Groups basic properties
---------------------------------------------------------------------
-- We will use the multiplicative notation for groups
module _ (G : Group {ℓ}) where
open group-·syntax G
private
₁· = group-lid G
·₁ = group-rid G
·-assoc = group-assoc G
⁻¹· = group-linv G
·⁻¹ = group-rinv G
id-is-unique : isContr (Σ[ x ∈ ⟨ G ⟩ ] ∀ (y : ⟨ G ⟩) → (x · y ≡ y) × (y · x ≡ y))
id-is-unique = (₁ , λ y → ₁· y , ·₁ y) ,
λ { (e , is-unit) → ΣProp≡ (λ x → isPropΠ λ y → isPropΣ (group-is-set G _ _)
λ _ → group-is-set G _ _)
(₁ ≡⟨ sym (snd (is-unit ₁)) ⟩
₁ · e ≡⟨ ₁· e ⟩
e ∎
)}
are-inverses : ∀ (x y : ⟨ G ⟩)
→ x · y ≡ ₁
→ (y ≡ x ⁻¹) × (x ≡ y ⁻¹)
are-inverses x y eq = (y ≡⟨ sym (₁· y) ⟩
₁ · y ≡⟨ sym (·-assoc _ _ _ ∙ cong (_· y) (⁻¹· _)) ⟩
(x ⁻¹) · (x · y) ≡⟨ cong ((x ⁻¹) ·_) eq ⟩
(x ⁻¹) · ₁ ≡⟨ ·₁ _ ⟩
x ⁻¹ ∎)
, (x ≡⟨ sym (·₁ x) ⟩
x · ₁ ≡⟨ cong (x ·_) (sym (·⁻¹ y)) ∙ ·-assoc _ _ _ ⟩
(x · y) · (y ⁻¹) ≡⟨ cong (_· (y ⁻¹)) eq ⟩
₁ · (y ⁻¹) ≡⟨ ₁· _ ⟩
y ⁻¹ ∎)
inv-involutive : ∀ (x : ⟨ G ⟩)
→ (x ⁻¹) ⁻¹ ≡ x
inv-involutive x = sym (snd (are-inverses x (x ⁻¹) (·⁻¹ x)))
inv-distr : ∀ (x y : ⟨ G ⟩) → (x · y) ⁻¹ ≡ (y ⁻¹) · (x ⁻¹)
inv-distr x y = sym (fst (are-inverses _ _ γ))
where γ : (x · y) · ((y ⁻¹) · (x ⁻¹)) ≡ ₁
γ = (x · y) · ((y ⁻¹) · (x ⁻¹)) ≡⟨ sym (cong (x ·_) (sym (·-assoc _ _ _)) ∙ ·-assoc _ _ _) ⟩
x · ((y · (y ⁻¹)) · (x ⁻¹)) ≡⟨ cong (λ - → x · (- · (x ⁻¹))) (·⁻¹ y) ⟩
x · (₁ · (x ⁻¹)) ≡⟨ cong (x ·_) (₁· (x ⁻¹)) ⟩
x · (x ⁻¹) ≡⟨ ·⁻¹ x ⟩
₁ ∎
left-cancel : ∀ (x y z : ⟨ G ⟩) → x · y ≡ x · z → y ≡ z
left-cancel x y z eq = y ≡⟨ sym (cong (_· y) (⁻¹· x) ∙ ₁· y) ⟩
((x ⁻¹) · x) · y ≡⟨ sym (·-assoc _ _ _) ⟩
(x ⁻¹) · (x · y) ≡⟨ cong ((x ⁻¹) ·_) eq ⟩
(x ⁻¹) · (x · z) ≡⟨ ·-assoc _ _ _ ⟩
((x ⁻¹) · x) · z ≡⟨ cong (_· z) (⁻¹· x) ∙ ₁· z ⟩
z ∎
right-cancel : ∀ (x y z : ⟨ G ⟩) → x · z ≡ y · z → x ≡ y
right-cancel x y z eq = x ≡⟨ sym (cong (x ·_) (·⁻¹ z) ∙ ·₁ x) ⟩
x · (z · (z ⁻¹)) ≡⟨ ·-assoc _ _ _ ⟩
(x · z) · (z ⁻¹) ≡⟨ cong (_· (z ⁻¹)) eq ⟩
(y · z) · (z ⁻¹) ≡⟨ sym (·-assoc _ _ _) ⟩
y · (z · (z ⁻¹)) ≡⟨ cong (y ·_) (·⁻¹ z) ∙ ·₁ y ⟩
y ∎
|
{
"alphanum_fraction": 0.3027681661,
"avg_line_length": 38.9662921348,
"ext": "agda",
"hexsha": "804248b8d8ddcbe8369c448ea30f20e459140352",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cmester0/cubical",
"max_forks_repo_path": "Cubical/Algebra/BasicProp.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cmester0/cubical",
"max_issues_repo_path": "Cubical/Algebra/BasicProp.agda",
"max_line_length": 102,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cmester0/cubical",
"max_stars_repo_path": "Cubical/Algebra/BasicProp.agda",
"max_stars_repo_stars_event_max_datetime": "2020-03-23T23:52:11.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-03-23T23:52:11.000Z",
"num_tokens": 1309,
"size": 3468
}
|
{-# OPTIONS --without-K #-}
module overloading where
-- An overloading system based on instance arguments. See `overloading.core` for
-- more details and documentation.
open import overloading.bundle public
open import overloading.core public
open import overloading.level public
|
{
"alphanum_fraction": 0.7915194346,
"avg_line_length": 25.7272727273,
"ext": "agda",
"hexsha": "5b5b3ba7afee200ee70551a0ac6c5f8cc569e56c",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z",
"max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "pcapriotti/agda-base",
"max_forks_repo_path": "src/overloading.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c",
"max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "pcapriotti/agda-base",
"max_issues_repo_path": "src/overloading.agda",
"max_line_length": 80,
"max_stars_count": 20,
"max_stars_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "pcapriotti/agda-base",
"max_stars_repo_path": "src/overloading.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-01T11:25:54.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-06-12T12:20:17.000Z",
"num_tokens": 56,
"size": 283
}
|
-- Raw terms, weakening (renaming) and substitution.
{-# OPTIONS --without-K --safe #-}
module Definition.Untyped where
open import Tools.Fin
open import Tools.Nat
open import Tools.Product
open import Tools.List
import Tools.PropositionalEquality as PE
infixl 30 _∙_
infix 30 Π_▹_
infixr 22 _▹▹_
infix 30 Σ_▹_
infixr 22 _××_
infix 30 ⟦_⟧_▹_
infixl 30 _ₛ•ₛ_ _•ₛ_ _ₛ•_
infix 25 _[_]
infix 25 _[_]↑
-- Typing contexts (length indexed snoc-lists, isomorphic to lists).
-- Terms added to the context are well scoped in the sense that it cannot
-- contain more unbound variables than can be looked up in the context.
data Con (A : Nat → Set) : Nat → Set where
ε : Con A 0 -- Empty context.
_∙_ : {n : Nat} → Con A n → A n → Con A (1+ n) -- Context extension.
private
variable
n m ℓ : Nat
-- Representation of sub terms using a list of binding levels
data GenTs (A : Nat → Set) : Nat → List Nat → Set where
[] : {n : Nat} → GenTs A n []
_∷_ : {n b : Nat} {bs : List Nat} (t : A (b + n)) (ts : GenTs A n bs) → GenTs A n (b ∷ bs)
-- Kinds are indexed on the number of expected sub terms
-- and the number of new variables bound by each sub term
data Kind : (ns : List Nat) → Set where
Ukind : Kind []
Pikind : Kind (0 ∷ 1 ∷ [])
Lamkind : Kind (1 ∷ [])
Appkind : Kind (0 ∷ 0 ∷ [])
Sigmakind : Kind (0 ∷ 1 ∷ [])
Prodkind : Kind (0 ∷ 0 ∷ [])
Fstkind : Kind (0 ∷ [])
Sndkind : Kind (0 ∷ [])
Natkind : Kind []
Zerokind : Kind []
Suckind : Kind (0 ∷ [])
Natreckind : Kind (1 ∷ 0 ∷ 0 ∷ 0 ∷ [])
Unitkind : Kind []
Starkind : Kind []
Emptykind : Kind []
Emptyreckind : Kind (0 ∷ 0 ∷ [])
-- Terms are indexed by its number of unbound variables and are either:
-- de Bruijn style variables or
-- generic terms, formed by their kind and sub terms
data Term (n : Nat) : Set where
var : (x : Fin n) → Term n
gen : {bs : List Nat} (k : Kind bs) (c : GenTs Term n bs) → Term n
private
variable
A F H t u v : Term n
B E G : Term (1+ n)
-- The Grammar of our language.
-- We represent the expressions of our language as de Bruijn terms.
-- Variables are natural numbers interpreted as de Bruijn indices.
-- Π, lam, and natrec are binders.
-- Type constructors.
U : Term n -- Universe.
U = gen Ukind []
Π_▹_ : (A : Term n) (B : Term (1+ n)) → Term n -- Dependent function type (B is a binder).
Π A ▹ B = gen Pikind (A ∷ B ∷ [])
Σ_▹_ : (A : Term n) (B : Term (1+ n)) → Term n -- Dependent sum type (B is a binder).
Σ A ▹ B = gen Sigmakind (A ∷ B ∷ [])
ℕ : Term n -- Type of natural numbers.
ℕ = gen Natkind []
Empty : Term n -- Empty type
Empty = gen Emptykind []
Unit : Term n -- Unit type
Unit = gen Unitkind []
lam : (t : Term (1+ n)) → Term n -- Function abstraction (binder).
lam t = gen Lamkind (t ∷ [])
_∘_ : (t u : Term n) → Term n -- Application.
t ∘ u = gen Appkind (t ∷ u ∷ [])
prod : (t u : Term n) → Term n -- Dependent products
prod t u = gen Prodkind (t ∷ u ∷ [])
fst : (t : Term n) → Term n -- First projection
fst t = gen Fstkind (t ∷ [])
snd : (t : Term n) → Term n -- Second projection
snd t = gen Sndkind (t ∷ [])
-- Introduction and elimination of natural numbers.
zero : Term n -- Natural number zero.
zero = gen Zerokind []
suc : (t : Term n) → Term n -- Successor.
suc t = gen Suckind (t ∷ [])
natrec : (A : Term (1+ n)) (t u v : Term n) → Term n -- Natural number recursor (A is a binder).
natrec A t u v = gen Natreckind (A ∷ t ∷ u ∷ v ∷ [])
star : Term n -- Unit element
star = gen Starkind []
Emptyrec : (A e : Term n) → Term n -- Empty type recursor
Emptyrec A e = gen Emptyreckind (A ∷ e ∷ [])
-- Binding types
data BindingType : Set where
BΠ : BindingType
BΣ : BindingType
⟦_⟧_▹_ : BindingType → Term n → Term (1+ n) → Term n
⟦ BΠ ⟧ F ▹ G = Π F ▹ G
⟦ BΣ ⟧ F ▹ G = Σ F ▹ G
-- Injectivity of term constructors w.r.t. propositional equality.
-- If W F G = W H E then F = H and G = E.
B-PE-injectivity : ∀ W → ⟦ W ⟧ F ▹ G PE.≡ ⟦ W ⟧ H ▹ E → F PE.≡ H × G PE.≡ E
B-PE-injectivity BΠ PE.refl = PE.refl , PE.refl
B-PE-injectivity BΣ PE.refl = PE.refl , PE.refl
-- If suc n = suc m then n = m.
suc-PE-injectivity : suc t PE.≡ suc u → t PE.≡ u
suc-PE-injectivity PE.refl = PE.refl
-- Neutral terms.
-- A term is neutral if it has a variable in head position.
-- The variable blocks reduction of such terms.
data Neutral : Term n → Set where
var : (x : Fin n) → Neutral (var x)
∘ₙ : Neutral t → Neutral (t ∘ u)
fstₙ : Neutral t → Neutral (fst t)
sndₙ : Neutral t → Neutral (snd t)
natrecₙ : Neutral v → Neutral (natrec G t u v)
Emptyrecₙ : Neutral t → Neutral (Emptyrec A t)
-- Weak head normal forms (whnfs).
-- These are the (lazy) values of our language.
data Whnf {n : Nat} : Term n → Set where
-- Type constructors are whnfs.
Uₙ : Whnf U
Πₙ : Whnf (Π A ▹ B)
Σₙ : Whnf (Σ A ▹ B)
ℕₙ : Whnf ℕ
Unitₙ : Whnf Unit
Emptyₙ : Whnf Empty
-- Introductions are whnfs.
lamₙ : Whnf (lam t)
zeroₙ : Whnf zero
sucₙ : Whnf (suc t)
starₙ : Whnf star
prodₙ : Whnf (prod t u)
-- Neutrals are whnfs.
ne : Neutral t → Whnf t
-- Whnf inequalities.
-- Different whnfs are trivially distinguished by propositional equality.
-- (The following statements are sometimes called "no-confusion theorems".)
U≢ne : Neutral A → U PE.≢ A
U≢ne () PE.refl
ℕ≢ne : Neutral A → ℕ PE.≢ A
ℕ≢ne () PE.refl
Empty≢ne : Neutral A → Empty PE.≢ A
Empty≢ne () PE.refl
Unit≢ne : Neutral A → Unit PE.≢ A
Unit≢ne () PE.refl
B≢ne : ∀ W → Neutral A → ⟦ W ⟧ F ▹ G PE.≢ A
B≢ne BΠ () PE.refl
B≢ne BΣ () PE.refl
U≢B : ∀ W → U PE.≢ ⟦ W ⟧ F ▹ G
U≢B BΠ ()
U≢B BΣ ()
ℕ≢B : ∀ W → ℕ PE.≢ ⟦ W ⟧ F ▹ G
ℕ≢B BΠ ()
ℕ≢B BΣ ()
Empty≢B : ∀ W → Empty PE.≢ ⟦ W ⟧ F ▹ G
Empty≢B BΠ ()
Empty≢B BΣ ()
Unit≢B : ∀ W → Unit PE.≢ ⟦ W ⟧ F ▹ G
Unit≢B BΠ ()
Unit≢B BΣ ()
zero≢ne : Neutral t → zero PE.≢ t
zero≢ne () PE.refl
suc≢ne : Neutral t → suc u PE.≢ t
suc≢ne () PE.refl
-- Several views on whnfs (note: not recursive).
-- A whnf of type ℕ is either zero, suc t, or neutral.
data Natural {n : Nat} : Term n → Set where
zeroₙ : Natural zero
sucₙ : Natural (suc t)
ne : Neutral t → Natural t
-- A (small) type in whnf is either Π A B, Σ A B, ℕ, Empty, Unit or neutral.
-- Large types could also be U.
data Type {n : Nat} : Term n → Set where
Πₙ : Type (Π A ▹ B)
Σₙ : Type (Σ A ▹ B)
ℕₙ : Type ℕ
Emptyₙ : Type Empty
Unitₙ : Type Unit
ne : Neutral t → Type t
⟦_⟧-type : ∀ (W : BindingType) → Type (⟦ W ⟧ F ▹ G)
⟦ BΠ ⟧-type = Πₙ
⟦ BΣ ⟧-type = Σₙ
-- A whnf of type Π A ▹ B is either lam t or neutral.
data Function {n : Nat} : Term n → Set where
lamₙ : Function (lam t)
ne : Neutral t → Function t
-- A whnf of type Σ A ▹ B is either prod t u or neutral.
data Product {n : Nat} : Term n → Set where
prodₙ : Product (prod t u)
ne : Neutral t → Product t
-- These views classify only whnfs.
-- Natural, Type, Function and Product are a subsets of Whnf.
naturalWhnf : Natural t → Whnf t
naturalWhnf sucₙ = sucₙ
naturalWhnf zeroₙ = zeroₙ
naturalWhnf (ne x) = ne x
typeWhnf : Type A → Whnf A
typeWhnf Πₙ = Πₙ
typeWhnf Σₙ = Σₙ
typeWhnf ℕₙ = ℕₙ
typeWhnf Emptyₙ = Emptyₙ
typeWhnf Unitₙ = Unitₙ
typeWhnf (ne x) = ne x
functionWhnf : Function t → Whnf t
functionWhnf lamₙ = lamₙ
functionWhnf (ne x) = ne x
productWhnf : Product t → Whnf t
productWhnf prodₙ = prodₙ
productWhnf (ne x) = ne x
⟦_⟧ₙ : (W : BindingType) → Whnf (⟦ W ⟧ F ▹ G)
⟦_⟧ₙ BΠ = Πₙ
⟦_⟧ₙ BΣ = Σₙ
------------------------------------------------------------------------
-- Weakening
-- In the following we define untyped weakenings η : Wk.
-- The typed form could be written η : Γ ≤ Δ with the intention
-- that η transport a term t living in context Δ to a context Γ
-- that can bind additional variables (which cannot appear in t).
-- Thus, if Δ ⊢ t : A and η : Γ ≤ Δ then Γ ⊢ wk η t : wk η A.
--
-- Even though Γ is "larger" than Δ we write Γ ≤ Δ to be conformant
-- with subtyping A ≤ B. With subtyping, relation Γ ≤ Δ could be defined as
-- ``for all x ∈ dom(Δ) have Γ(x) ≤ Δ(x)'' (in the sense of subtyping)
-- and this would be the natural extension of weakenings.
data Wk : Nat → Nat → Set where
id : {n : Nat} → Wk n n -- η : Γ ≤ Γ.
step : {n m : Nat} → Wk m n → Wk (1+ m) n -- If η : Γ ≤ Δ then step η : Γ∙A ≤ Δ.
lift : {n m : Nat} → Wk m n → Wk (1+ m) (1+ n) -- If η : Γ ≤ Δ then lift η : Γ∙A ≤ Δ∙A.
-- Composition of weakening.
-- If η : Γ ≤ Δ and η′ : Δ ≤ Φ then η • η′ : Γ ≤ Φ.
infixl 30 _•_
_•_ : {l m n : Nat} → Wk l m → Wk m n → Wk l n
id • η′ = η′
step η • η′ = step (η • η′)
lift η • id = lift η
lift η • step η′ = step (η • η′)
lift η • lift η′ = lift (η • η′)
liftn : {k m : Nat} → Wk k m → (n : Nat) → Wk (n + k) (n + m)
liftn ρ Nat.zero = ρ
liftn ρ (1+ n) = lift (liftn ρ n)
-- Weakening of variables.
-- If η : Γ ≤ Δ and x ∈ dom(Δ) then wkVar η x ∈ dom(Γ).
wkVar : {m n : Nat} (ρ : Wk m n) (x : Fin n) → Fin m
wkVar id x = x
wkVar (step ρ) x = (wkVar ρ x) +1
wkVar (lift ρ) x0 = x0
wkVar (lift ρ) (x +1) = (wkVar ρ x) +1
-- Weakening of terms.
-- If η : Γ ≤ Δ and Δ ⊢ t : A then Γ ⊢ wk η t : wk η A.
mutual
wkGen : {m n : Nat} {bs : List Nat} (ρ : Wk m n) (c : GenTs Term n bs) → GenTs Term m bs
wkGen ρ [] = []
wkGen ρ (_∷_ {b = b} t c) = (wk (liftn ρ b) t) ∷ (wkGen ρ c)
wk : {m n : Nat} (ρ : Wk m n) (t : Term n) → Term m
wk ρ (var x) = var (wkVar ρ x)
wk ρ (gen k c) = gen k (wkGen ρ c)
-- Adding one variable to the context requires wk1.
-- If Γ ⊢ t : B then Γ∙A ⊢ wk1 t : wk1 B.
wk1 : Term n → Term (1+ n)
wk1 = wk (step id)
-- Weakening of a neutral term.
wkNeutral : ∀ ρ → Neutral t → Neutral {n} (wk ρ t)
wkNeutral ρ (var n) = var (wkVar ρ n)
wkNeutral ρ (∘ₙ n) = ∘ₙ (wkNeutral ρ n)
wkNeutral ρ (fstₙ n) = fstₙ (wkNeutral ρ n)
wkNeutral ρ (sndₙ n) = sndₙ (wkNeutral ρ n)
wkNeutral ρ (natrecₙ n) = natrecₙ (wkNeutral ρ n)
wkNeutral ρ (Emptyrecₙ e) = Emptyrecₙ (wkNeutral ρ e)
-- Weakening can be applied to our whnf views.
wkNatural : ∀ ρ → Natural t → Natural {n} (wk ρ t)
wkNatural ρ sucₙ = sucₙ
wkNatural ρ zeroₙ = zeroₙ
wkNatural ρ (ne x) = ne (wkNeutral ρ x)
wkType : ∀ ρ → Type t → Type {n} (wk ρ t)
wkType ρ Πₙ = Πₙ
wkType ρ Σₙ = Σₙ
wkType ρ ℕₙ = ℕₙ
wkType ρ Emptyₙ = Emptyₙ
wkType ρ Unitₙ = Unitₙ
wkType ρ (ne x) = ne (wkNeutral ρ x)
wkFunction : ∀ ρ → Function t → Function {n} (wk ρ t)
wkFunction ρ lamₙ = lamₙ
wkFunction ρ (ne x) = ne (wkNeutral ρ x)
wkProduct : ∀ ρ → Product t → Product {n} (wk ρ t)
wkProduct ρ prodₙ = prodₙ
wkProduct ρ (ne x) = ne (wkNeutral ρ x)
wkWhnf : ∀ ρ → Whnf t → Whnf {n} (wk ρ t)
wkWhnf ρ Uₙ = Uₙ
wkWhnf ρ Πₙ = Πₙ
wkWhnf ρ Σₙ = Σₙ
wkWhnf ρ ℕₙ = ℕₙ
wkWhnf ρ Emptyₙ = Emptyₙ
wkWhnf ρ Unitₙ = Unitₙ
wkWhnf ρ lamₙ = lamₙ
wkWhnf ρ prodₙ = prodₙ
wkWhnf ρ zeroₙ = zeroₙ
wkWhnf ρ sucₙ = sucₙ
wkWhnf ρ starₙ = starₙ
wkWhnf ρ (ne x) = ne (wkNeutral ρ x)
-- Non-dependent version of Π.
_▹▹_ : Term n → Term n → Term n
A ▹▹ B = Π A ▹ wk1 B
-- Non-dependent products.
_××_ : Term n → Term n → Term n
A ×× B = Σ A ▹ wk1 B
------------------------------------------------------------------------
-- Substitution
-- The substitution operation subst σ t replaces the free de Bruijn indices
-- of term t by chosen terms as specified by σ.
-- The substitution σ itself is a map from natural numbers to terms.
Subst : Nat → Nat → Set
Subst m n = Fin n → Term m
-- Given closed contexts ⊢ Γ and ⊢ Δ,
-- substitutions may be typed via Γ ⊢ σ : Δ meaning that
-- Γ ⊢ σ(x) : (subst σ Δ)(x) for all x ∈ dom(Δ).
--
-- The substitution operation is then typed as follows:
-- If Γ ⊢ σ : Δ and Δ ⊢ t : A, then Γ ⊢ subst σ t : subst σ A.
--
-- Although substitutions are untyped, typing helps us
-- to understand the operation on substitutions.
-- We may view σ as the infinite stream σ 0, σ 1, ...
-- Extract the substitution of the first variable.
--
-- If Γ ⊢ σ : Δ∙A then Γ ⊢ head σ : subst σ A.
head : Subst m (1+ n) → Term m
head σ = σ x0
-- Remove the first variable instance of a substitution
-- and shift the rest to accommodate.
--
-- If Γ ⊢ σ : Δ∙A then Γ ⊢ tail σ : Δ.
tail : Subst m (1+ n) → Subst m n
tail σ x = σ (x +1)
-- Substitution of a variable.
--
-- If Γ ⊢ σ : Δ then Γ ⊢ substVar σ x : (subst σ Δ)(x).
substVar : (σ : Subst m n) (x : Fin n) → Term m
substVar σ x = σ x
-- Identity substitution.
-- Replaces each variable by itself.
--
-- Γ ⊢ idSubst : Γ.
idSubst : Subst n n
idSubst = var
-- Weaken a substitution by one.
--
-- If Γ ⊢ σ : Δ then Γ∙A ⊢ wk1Subst σ : Δ.
wk1Subst : Subst m n → Subst (1+ m) n
wk1Subst σ x = wk1 (σ x)
-- Lift a substitution.
--
-- If Γ ⊢ σ : Δ then Γ∙A ⊢ liftSubst σ : Δ∙A.
liftSubst : (σ : Subst m n) → Subst (1+ m) (1+ n)
liftSubst σ x0 = var x0
liftSubst σ (x +1) = wk1Subst σ x
liftSubstn : {k m : Nat} → Subst k m → (n : Nat) → Subst (n + k) (n + m)
liftSubstn σ Nat.zero = σ
liftSubstn σ (1+ n) = liftSubst (liftSubstn σ n)
-- Transform a weakening into a substitution.
--
-- If ρ : Γ ≤ Δ then Γ ⊢ toSubst ρ : Δ.
toSubst : Wk m n → Subst m n
toSubst pr x = var (wkVar pr x)
-- Apply a substitution to a term.
--
-- If Γ ⊢ σ : Δ and Δ ⊢ t : A then Γ ⊢ subst σ t : subst σ A.
mutual
substGen : {bs : List Nat} (σ : Subst m n) (g : GenTs Term n bs) → GenTs Term m bs
substGen σ [] = []
substGen σ (_∷_ {b = b} t ts) = subst (liftSubstn σ b) t ∷ (substGen σ ts)
subst : (σ : Subst m n) (t : Term n) → Term m
subst σ (var x) = substVar σ x
subst σ (gen x c) = gen x (substGen σ c)
-- Extend a substitution by adding a term as
-- the first variable substitution and shift the rest.
--
-- If Γ ⊢ σ : Δ and Γ ⊢ t : subst σ A then Γ ⊢ consSubst σ t : Δ∙A.
consSubst : Subst m n → Term m → Subst m (1+ n)
consSubst σ t x0 = t
consSubst σ t (x +1) = σ x
-- Singleton substitution.
--
-- If Γ ⊢ t : A then Γ ⊢ sgSubst t : Γ∙A.
sgSubst : Term n → Subst n (1+ n)
sgSubst = consSubst idSubst
-- Compose two substitutions.
--
-- If Γ ⊢ σ : Δ and Δ ⊢ σ′ : Φ then Γ ⊢ σ ₛ•ₛ σ′ : Φ.
_ₛ•ₛ_ : Subst ℓ m → Subst m n → Subst ℓ n
_ₛ•ₛ_ σ σ′ x = subst σ (σ′ x)
-- Composition of weakening and substitution.
--
-- If ρ : Γ ≤ Δ and Δ ⊢ σ : Φ then Γ ⊢ ρ •ₛ σ : Φ.
_•ₛ_ : Wk ℓ m → Subst m n → Subst ℓ n
_•ₛ_ ρ σ x = wk ρ (σ x)
-- If Γ ⊢ σ : Δ and ρ : Δ ≤ Φ then Γ ⊢ σ ₛ• ρ : Φ.
_ₛ•_ : Subst ℓ m → Wk m n → Subst ℓ n
_ₛ•_ σ ρ x = σ (wkVar ρ x)
-- Substitute the first variable of a term with an other term.
--
-- If Γ∙A ⊢ t : B and Γ ⊢ s : A then Γ ⊢ t[s] : B[s].
_[_] : (t : Term (1+ n)) (s : Term n) → Term n
t [ s ] = subst (sgSubst s) t
-- Substitute the first variable of a term with an other term,
-- but let the two terms share the same context.
--
-- If Γ∙A ⊢ t : B and Γ∙A ⊢ s : A then Γ∙A ⊢ t[s]↑ : B[s]↑.
_[_]↑ : (t : Term (1+ n)) (s : Term (1+ n)) → Term (1+ n)
t [ s ]↑ = subst (consSubst (wk1Subst idSubst) s) t
B-subst : (σ : Subst m n) (W : BindingType) (F : Term n) (G : Term (1+ n))
→ subst σ (⟦ W ⟧ F ▹ G) PE.≡ ⟦ W ⟧ (subst σ F) ▹ (subst (liftSubst σ) G)
B-subst σ BΠ F G = PE.refl
B-subst σ BΣ F G = PE.refl
|
{
"alphanum_fraction": 0.5697226502,
"avg_line_length": 26.9015544041,
"ext": "agda",
"hexsha": "b8658d985f26d897f85d7c88527a22ffde1c711d",
"lang": "Agda",
"max_forks_count": 8,
"max_forks_repo_forks_event_max_datetime": "2021-11-27T15:58:33.000Z",
"max_forks_repo_forks_event_min_datetime": "2017-10-18T14:18:20.000Z",
"max_forks_repo_head_hexsha": "ea83fc4f618d1527d64ecac82d7d17e2f18ac391",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "fhlkfy/logrel-mltt",
"max_forks_repo_path": "Definition/Untyped.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "ea83fc4f618d1527d64ecac82d7d17e2f18ac391",
"max_issues_repo_issues_event_max_datetime": "2021-02-22T10:37:24.000Z",
"max_issues_repo_issues_event_min_datetime": "2017-06-22T12:49:23.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "fhlkfy/logrel-mltt",
"max_issues_repo_path": "Definition/Untyped.agda",
"max_line_length": 97,
"max_stars_count": 30,
"max_stars_repo_head_hexsha": "ea83fc4f618d1527d64ecac82d7d17e2f18ac391",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "fhlkfy/logrel-mltt",
"max_stars_repo_path": "Definition/Untyped.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:01:07.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-05-20T03:05:21.000Z",
"num_tokens": 6105,
"size": 15576
}
|
module A.Issue1635 (A : Set₁) where
data Foo : Set where
foo : Foo
|
{
"alphanum_fraction": 0.661971831,
"avg_line_length": 11.8333333333,
"ext": "agda",
"hexsha": "d672e39013eba47b178961db3741389c840655fe",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/A/Issue1635.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Fail/A/Issue1635.agda",
"max_line_length": 35,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/A/Issue1635.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 26,
"size": 71
}
|
module _ where
import Agda.Builtin.Equality
open import Agda.Builtin.Sigma
open import Agda.Builtin.Unit
open import Agda.Primitive
open import Common.IO
data ⊥ : Set where
record R₁ a : Set (lsuc a) where
field
R : {A : Set a} → A → A → Set a
r : {A : Set a} (x : A) → R x x
P : Set a → Set a
P A = (x y : A) → R x y
record R₂ (r : ∀ ℓ → R₁ ℓ) : Set₁ where
field
f :
{X Y : Σ Set (R₁.P (r lzero))} →
R₁.R (r (lsuc lzero)) X Y → fst X → fst Y
module M (r₁ : ∀ ℓ → R₁ ℓ) (r₂ : R₂ r₁) where
open module R₁′ {ℓ} = R₁ (r₁ ℓ) public using (P)
open module R₂′ = R₂ r₂ public
⊥-elim : {A : Set} → ⊥ → A
⊥-elim ()
p : P ⊥
p x = ⊥-elim x
open Agda.Builtin.Equality
r₁ : ∀ ℓ → R₁ ℓ
R₁.R (r₁ _) = _≡_
R₁.r (r₁ _) = λ _ → refl
r₂ : R₂ r₁
R₂.f r₂ refl x = x
open M r₁ r₂
data Unit : Set where
unit : Unit
g : Σ Unit λ _ → P (Σ Set P) → ⊥
g = unit , λ h → f (h (⊤ , λ _ _ → refl) (⊥ , p)) tt
main : IO ⊤
main = return _
|
{
"alphanum_fraction": 0.5338114754,
"avg_line_length": 17.7454545455,
"ext": "agda",
"hexsha": "a0cd97c142725e09ae2d31bbcae32e057a06271c",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Compiler/simple/Issue4169-2.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Compiler/simple/Issue4169-2.agda",
"max_line_length": 52,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Compiler/simple/Issue4169-2.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 436,
"size": 976
}
|
module kripke-semantics where
open import level
open import bool
open import closures
open import empty
open import eq
open import level
open import list
open import list-thms
open import nat
open import product
open import relations
open import string
open import sum
open import unit
data formula : Set where
$ : string → formula
True : formula
Implies : formula → formula → formula
And : formula → formula → formula
ctxt : Set
ctxt = 𝕃 formula
data _⊢_ : ctxt → formula → Set where
Assume : ∀{Γ f} → (f :: Γ) ⊢ f
Weaken : ∀{Γ f f'} → Γ ⊢ f → (f' :: Γ) ⊢ f
ImpliesI : ∀{f1 f2 Γ} → (f1 :: Γ) ⊢ f2 → Γ ⊢ (Implies f1 f2)
ImpliesE : ∀{f1 f2 Γ} → Γ ⊢ (Implies f1 f2) → Γ ⊢ f1 → Γ ⊢ f2
TrueI : ∀ {Γ} → Γ ⊢ True
AndI : ∀{f1 f2 Γ} → Γ ⊢ f1 → Γ ⊢ f2 → Γ ⊢ (And f1 f2)
AndE : ∀(b : 𝔹){f1 f2 Γ} → Γ ⊢ (And f1 f2) → Γ ⊢ (if b then f1 else f2)
sample-pf : [] ⊢ Implies ($ "p") (And ($ "p") ($ "p"))
sample-pf = ImpliesI{$ "p"} (AndI (Assume{[]}) (Assume))
record struct : Set1 where
field W : Set -- a set of worlds
R : W → W → Set
preorderR : preorder R -- a proof that R is a preorder (reflexive and transitive)
V : W → string → Set -- a valuation telling whether atomic formula i is true or false in a given world
monoV : ∀ { w w' } → R w w' → ∀ { i } → V w i → V w' i
reflR : reflexive R
reflR = fst preorderR
transR : transitive R
transR = snd preorderR
open struct
_,_⊨_ : ∀(k : struct) → W k → formula → Set
k , w ⊨ ($ x) = V k w x
k , w ⊨ True = ⊤
k , w ⊨ Implies f1 f2 = ∀ {w' : W k} → R k w w' → k , w' ⊨ f1 → k , w' ⊨ f2
k , w ⊨ And f1 f2 = k , w ⊨ f1 ∧ k , w ⊨ f2
module ⊨-example where
data world : Set where
w0 : world
w1 : world
w2 : world
data rel : world → world → Set where
r00 : rel w0 w0
r11 : rel w1 w1
r22 : rel w2 w2
r01 : rel w0 w1
r02 : rel w0 w2
rel-refl : reflexive rel
rel-refl {w0} = r00
rel-refl {w1} = r11
rel-refl {w2} = r22
rel-trans : transitive rel
rel-trans r00 r00 = r00
rel-trans r00 r01 = r01
rel-trans r00 r02 = r02
rel-trans r11 r11 = r11
rel-trans r22 r22 = r22
rel-trans r01 r11 = r01
rel-trans r02 r22 = r02
data val : world → string → Set where
v1p : val w1 "p"
v1q : val w1 "q"
v2p : val w2 "p"
v2q : val w2 "q"
mono-val : ∀{w w'} → rel w w' → ∀ { i } → val w i → val w' i
mono-val r00 p = p
mono-val r11 p = p
mono-val r22 p = p
mono-val r01 ()
mono-val r02 ()
k : struct
k = record { W = world ; R = rel ; preorderR = (rel-refl , rel-trans) ; V = val ; monoV = mono-val }
test-sem : Set
test-sem = k , w0 ⊨ Implies ($ "p") ($ "q")
pf-test-sem : k , w0 ⊨ Implies ($ "p") ($ "q")
pf-test-sem r00 ()
pf-test-sem r01 p = v1q
pf-test-sem r02 p = v2q
mono⊨ : ∀{k : struct}{w1 w2 : W k}{f : formula} →
R k w1 w2 →
k , w1 ⊨ f →
k , w2 ⊨ f
mono⊨{k} {f = $ x} r p = monoV k r p
mono⊨{k} {f = True} r p = triv
mono⊨{k} {f = Implies f1 f2} r p r' p' = p (transR k r r') p'
mono⊨{k} {f = And f1 f2} r (p1 , p2) = mono⊨{f = f1} r p1 , mono⊨{f = f2} r p2
_,_⊨ctxt_ : ∀(k : struct) → W k → ctxt → Set
k , w ⊨ctxt [] = ⊤
k , w ⊨ctxt (f :: Γ) = (k , w ⊨ f) ∧ (k , w ⊨ctxt Γ)
mono⊨ctxt : ∀{k : struct}{Γ : ctxt}{w1 w2 : W k} →
R k w1 w2 →
k , w1 ⊨ctxt Γ →
k , w2 ⊨ctxt Γ
mono⊨ctxt{k}{[]} _ _ = triv
mono⊨ctxt{k}{f :: Γ} r (u , v) = mono⊨{k}{f = f} r u , mono⊨ctxt{k}{Γ} r v
_⊩_ : ctxt → formula → Set1
Γ ⊩ f = ∀{k : struct}{w : W k} → k , w ⊨ctxt Γ → k , w ⊨ f
Soundness : ∀{Γ : ctxt}{f : formula} → Γ ⊢ f → Γ ⊩ f
Soundness Assume g = fst g
Soundness (Weaken p) g = Soundness p (snd g)
Soundness (ImpliesI p) g r u' = Soundness p (u' , mono⊨ctxt r g)
Soundness (ImpliesE p p') {k} g = (Soundness p g) (reflR k) (Soundness p' g)
Soundness TrueI g = triv
Soundness (AndI p p') g = (Soundness p g , Soundness p' g)
Soundness (AndE tt p) g = fst (Soundness p g)
Soundness (AndE ff p) g = snd (Soundness p g)
data _≼_ : 𝕃 formula → 𝕃 formula → Set where
≼-refl : ∀ {Γ} → Γ ≼ Γ
≼-cons : ∀ {Γ Γ' f} → Γ ≼ Γ' → Γ ≼ (f :: Γ')
≼-trans : ∀ {Γ Γ' Γ''} → Γ ≼ Γ' → Γ' ≼ Γ'' → Γ ≼ Γ''
≼-trans u ≼-refl = u
≼-trans u (≼-cons u') = ≼-cons (≼-trans u u')
Weaken≼ : ∀ {Γ Γ'}{f : formula} → Γ ≼ Γ' → Γ ⊢ f → Γ' ⊢ f
Weaken≼ ≼-refl p = p
Weaken≼ (≼-cons d) p = Weaken (Weaken≼ d p)
U : struct
U = record { W = ctxt ;
R = _≼_ ;
preorderR = ≼-refl , ≼-trans ;
V = λ Γ n → Γ ⊢ $ n ;
monoV = λ d p → Weaken≼ d p }
CompletenessU : ∀{f : formula}{Γ : W U} → U , Γ ⊨ f → Γ ⊢ f
SoundnessU : ∀{f : formula}{Γ : W U} → Γ ⊢ f → U , Γ ⊨ f
CompletenessU {$ x} u = u
CompletenessU {True} u = TrueI
CompletenessU {And f f'} u = AndI (CompletenessU{f} (fst u)) (CompletenessU{f'} (snd u))
CompletenessU {Implies f f'}{Γ} u =
ImpliesI
(CompletenessU {f'}
(u (≼-cons ≼-refl) (SoundnessU {f} (Assume {Γ}))))
SoundnessU {$ x} p = p
SoundnessU {True} p = triv
SoundnessU {And f f'} p = SoundnessU{f} (AndE tt p) , SoundnessU{f'} (AndE ff p)
SoundnessU {Implies f f'} p r u = SoundnessU (ImpliesE (Weaken≼ r p) (CompletenessU {f} u))
ctxt-id : ∀{Γ : ctxt} → U , Γ ⊨ctxt Γ
ctxt-id{[]} = triv
ctxt-id{f :: Γ} = SoundnessU{f} Assume , mono⊨ctxt (≼-cons ≼-refl) (ctxt-id {Γ})
Completeness : ∀{Γ : ctxt}{f : formula} → Γ ⊩ f → Γ ⊢ f
Completeness{Γ} p = CompletenessU (p{U}{Γ} (ctxt-id{Γ}))
Universality1 : ∀{Γ : ctxt}{f : formula} → Γ ⊩ f → U , Γ ⊨ f
Universality1{Γ}{f} p = SoundnessU (Completeness{Γ}{f} p)
Universality2 : ∀{Γ : ctxt}{f : formula} → U , Γ ⊨ f → Γ ⊩ f
Universality2{Γ}{f} p = Soundness (CompletenessU{f}{Γ} p)
nbe : ∀ {Γ f} → Γ ⊢ f → Γ ⊢ f
nbe {Γ} p = Completeness (Soundness p)
module tests where
-- here we see several proofs which normalize to just TrueI using the nbe function
a : [] ⊢ True
a = AndE tt (AndI TrueI TrueI)
a' = nbe a
b : [] ⊢ True
b = ImpliesE (ImpliesE (ImpliesI (ImpliesI (Assume))) TrueI) TrueI
b' = nbe b
c : [] ⊢ (Implies ($ "p") ($ "p"))
c = ImpliesI (ImpliesE (ImpliesI Assume) Assume)
c' = nbe c
d : [ $ "q" ] ⊢ (Implies ($ "p") ($ "q"))
d = ImpliesI (ImpliesE (ImpliesI (Weaken (Weaken Assume))) Assume)
d' = nbe d
e : [] ⊢ (Implies (And ($ "p") ($ "q")) (And ($ "p") ($ "q")))
e = ImpliesI Assume
e' = nbe e
f : [] ⊢ (Implies (Implies ($ "p") ($ "q")) (Implies ($ "p") ($ "q")))
f = ImpliesI Assume
f' = nbe f
|
{
"alphanum_fraction": 0.5370456303,
"avg_line_length": 29.5205479452,
"ext": "agda",
"hexsha": "cab35fbc27b7b94309b54cf43dc48f9082c1c2f3",
"lang": "Agda",
"max_forks_count": 17,
"max_forks_repo_forks_event_max_datetime": "2021-11-28T20:13:21.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-12-03T22:38:15.000Z",
"max_forks_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "rfindler/ial",
"max_forks_repo_path": "kripke-semantics.agda",
"max_issues_count": 8,
"max_issues_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6",
"max_issues_repo_issues_event_max_datetime": "2022-03-22T03:43:34.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-07-09T22:53:38.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "rfindler/ial",
"max_issues_repo_path": "kripke-semantics.agda",
"max_line_length": 118,
"max_stars_count": 29,
"max_stars_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "rfindler/ial",
"max_stars_repo_path": "kripke-semantics.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-04T15:05:12.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-02-06T13:09:31.000Z",
"num_tokens": 2778,
"size": 6465
}
|
{-# OPTIONS --without-K #-}
open import HoTT hiding (_::_)
module algebra.DecidableFreeGroupIsReducedWord {i} (A : Type i) (dec : has-dec-eq A) where
open import algebra.Word A
open import algebra.ReducedWord A dec
-- Some helper functions.
tail-is-reduced : (x : A) (w : Word) → is-reduced (x :: w) → is-reduced w
tail-is-reduced x nil red = lift unit
tail-is-reduced x (y :: w) red = red
tail-is-reduced x (y inv:: w) red = snd red
tail'-is-reduced : (x : A) (w : Word) → is-reduced (x inv:: w) → is-reduced w
tail'-is-reduced x nil red = lift unit
tail'-is-reduced x (y :: w) red = snd red
tail'-is-reduced x (y inv:: w) red = red
-- Conversion function.
ReducedWord→FreeGroup : ReducedWord → FreeGroup A
ReducedWord→FreeGroup (w , red) = f w red
where
f : (w : Word) → is-reduced w → FreeGroup A
f nil _ = fg-nil
f (x :: w) r = x fg:: f w (tail-is-reduced x w r)
f (x inv:: w) r = x fg-inv:: f w (tail'-is-reduced x w r)
infixr 60 _rw::_ _rw-inv::_
_rw::_ : A → ReducedWord → ReducedWord
x rw:: (nil , red) = ((x :: nil) , lift unit)
x rw:: ((y :: w) , red) = ((x :: y :: w) , red)
x rw:: ((y inv:: w) , red) with dec x y
x rw:: ((y inv:: w) , red) | inl x=y = (w , tail'-is-reduced y w red)
x rw:: ((y inv:: w) , red) | inr x≠y = ((x :: y inv:: w) , (x≠y , red))
_rw-inv::_ : A → ReducedWord → ReducedWord
x rw-inv:: (nil , red) = ((x inv:: nil) , lift unit)
x rw-inv:: ((y inv:: w) , red) = ((x inv:: y inv:: w) , red)
x rw-inv:: ((y :: w) , red) with dec x y
x rw-inv:: ((y :: w) , red) | inl eq = (w , tail-is-reduced y w red)
x rw-inv:: ((y :: w) , red) | inr neq = ((x inv:: y :: w) , (neq , red))
abstract
rw-inv-r : ∀ x w → x rw:: x rw-inv:: w == w
rw-inv-r x (nil , red) with dec x x
rw-inv-r x (nil , red) | inl x=x = idp
rw-inv-r x (nil , red) | inr x≠x = ⊥-rec (x≠x idp)
rw-inv-r x ((y :: w) , red) with dec x y
rw-inv-r x ((y :: nil) , red) | inl x=y = x=y |in-ctx _
rw-inv-r x ((y :: z :: w) , red) | inl x=y = x=y |in-ctx _
rw-inv-r x ((y :: z inv:: w) , red) | inl x=y with dec x z
rw-inv-r x ((y :: z inv:: w) , red) | inl x=y | inl x=z = ⊥-rec (fst red (! x=y ∙ x=z))
rw-inv-r x ((y :: z inv:: w) , red) | inl x=y | inr x≠z = ReducedWord=-in (x=y |in-ctx _)
rw-inv-r x ((y :: w) , red) | inr x≠y with dec x x
rw-inv-r x ((y :: w) , red) | inr x≠y | inl x=x = idp
rw-inv-r x ((y :: w) , red) | inr x≠y | inr x≠x = ⊥-rec (x≠x idp)
rw-inv-r x ((y inv:: w) , red) with dec x x
rw-inv-r x ((y inv:: w) , red) | inl x=x = idp
rw-inv-r x ((y inv:: w) , red) | inr x≠x = ⊥-rec (x≠x idp)
abstract
rw-inv-l : ∀ x w → x rw-inv:: x rw:: w == w
rw-inv-l x (nil , red) with dec x x
rw-inv-l x (nil , red) | inl x=x = idp
rw-inv-l x (nil , red) | inr x≠x = ⊥-rec (x≠x idp)
rw-inv-l x ((y inv:: w) , red) with dec x y
rw-inv-l x ((y inv:: nil) , red) | inl x=y = x=y |in-ctx _
rw-inv-l x ((y inv:: z inv:: w) , red) | inl x=y = x=y |in-ctx _
rw-inv-l x ((y inv:: z :: w) , red) | inl x=y with dec x z
rw-inv-l x ((y inv:: z :: w) , red) | inl x=y | inl x=z = ⊥-rec (fst red (! x=y ∙ x=z))
rw-inv-l x ((y inv:: z :: w) , red) | inl x=y | inr x≠z = ReducedWord=-in (x=y |in-ctx _)
rw-inv-l x ((y inv:: w) , red) | inr x≠y with dec x x
rw-inv-l x ((y inv:: w) , red) | inr x≠y | inl x=x = idp
rw-inv-l x ((y inv:: w) , red) | inr x≠y | inr x≠x = ⊥-rec (x≠x idp)
rw-inv-l x ((y :: w) , red) with dec x x
rw-inv-l x ((y :: w) , red) | inl x=x = idp
rw-inv-l x ((y :: w) , red) | inr x≠x = ⊥-rec (x≠x idp)
FreeGroup→ReducedWord : FreeGroup A → ReducedWord
FreeGroup→ReducedWord = FreeGroup-rec ReducedWord-is-set
(nil , lift unit)
(λ x _ rw → x rw:: rw)
(λ x _ rw → x rw-inv:: rw)
(λ x {_} rw → rw-inv-l x rw)
(λ x {_} rw → rw-inv-r x rw)
abstract
rw::-reduced : ∀ x w (red : is-reduced (x :: w))
→ x rw:: (w , tail-is-reduced x w red) == ((x :: w) , red)
rw::-reduced x nil red = idp
rw::-reduced x (y :: w) red = idp
rw::-reduced x (y inv:: w) red with dec x y
rw::-reduced x (y inv:: w) red | inl x=y = ⊥-rec (fst red x=y)
rw::-reduced x (y inv:: w) red | inr x≠y = ReducedWord=-in idp
abstract
rw-inv::-reduced : ∀ x w (red : is-reduced (x inv:: w))
→ x rw-inv:: (w , tail'-is-reduced x w red) == ((x inv:: w) , red)
rw-inv::-reduced x nil red = idp
rw-inv::-reduced x (y inv:: w) red = idp
rw-inv::-reduced x (y :: w) red with dec x y
rw-inv::-reduced x (y :: w) red | inl x=y = ⊥-rec (fst red x=y)
rw-inv::-reduced x (y :: w) red | inr x≠y = ReducedWord=-in idp
ReducedWord→FreeGroup→ReducedWord :
∀ w → FreeGroup→ReducedWord (ReducedWord→FreeGroup w) == w
ReducedWord→FreeGroup→ReducedWord (w , red) = f w red
where
f : ∀ w red → FreeGroup→ReducedWord (ReducedWord→FreeGroup (w , red)) == w , red
f nil _ = idp
f (x :: w) red =
x rw:: FreeGroup→ReducedWord (ReducedWord→FreeGroup (w , tail-is-reduced x w red))
=⟨ f w (tail-is-reduced x w red) |in-ctx (λ w → x rw:: w) ⟩
x rw:: (w , tail-is-reduced x w red)
=⟨ rw::-reduced x w red ⟩
(x :: w) , red
∎
f (x inv:: w) red =
x rw-inv:: FreeGroup→ReducedWord (ReducedWord→FreeGroup (w , tail'-is-reduced x w red))
=⟨ f w (tail'-is-reduced x w red) |in-ctx (λ w → x rw-inv:: w) ⟩
x rw-inv:: (w , tail'-is-reduced x w red)
=⟨ rw-inv::-reduced x w red ⟩
(x inv:: w) , red
∎
ReducedWord→FreeGroup-rw:: : ∀ x w
→ ReducedWord→FreeGroup (x rw:: w) == x fg:: ReducedWord→FreeGroup w
ReducedWord→FreeGroup-rw:: x (nil , red) = idp
ReducedWord→FreeGroup-rw:: x ((y :: w) , red) = idp
ReducedWord→FreeGroup-rw:: x ((y inv:: w) , red) with dec x y
ReducedWord→FreeGroup-rw:: x ((.x inv:: w) , red) | inl idp =
! (fg-inv-r x (ReducedWord→FreeGroup (w , tail'-is-reduced x w red)))
ReducedWord→FreeGroup-rw:: x ((y inv:: w) , red) | inr x≠y = idp
ReducedWord→FreeGroup-rw-inv:: : ∀ x w
→ ReducedWord→FreeGroup (x rw-inv:: w) == x fg-inv:: ReducedWord→FreeGroup w
ReducedWord→FreeGroup-rw-inv:: x (nil , red) = idp
ReducedWord→FreeGroup-rw-inv:: x ((y inv:: w) , red) = idp
ReducedWord→FreeGroup-rw-inv:: x ((y :: w) , red) with dec x y
ReducedWord→FreeGroup-rw-inv:: x ((.x :: w) , red) | inl idp =
! (fg-inv-l x (ReducedWord→FreeGroup (w , tail-is-reduced x w red)))
ReducedWord→FreeGroup-rw-inv:: x ((y :: w) , red) | inr x≠y = idp
FreeGroup→ReducedWord→FreeGroup : ∀ fg
→ ReducedWord→FreeGroup (FreeGroup→ReducedWord fg) == fg
FreeGroup→ReducedWord→FreeGroup = FreeGroup-elim
(λ _ → =-preserves-set FreeGroup-is-set)
idp
(λ x {fg} fg* →
ReducedWord→FreeGroup (x rw:: FreeGroup→ReducedWord fg)
=⟨ ReducedWord→FreeGroup-rw:: x (FreeGroup→ReducedWord fg) ⟩
x fg:: ReducedWord→FreeGroup (FreeGroup→ReducedWord fg)
=⟨ fg* |in-ctx (_fg::_ x) ⟩
x fg:: fg
∎)
(λ x {fg} fg* →
ReducedWord→FreeGroup (x rw-inv:: FreeGroup→ReducedWord fg)
=⟨ ReducedWord→FreeGroup-rw-inv:: x (FreeGroup→ReducedWord fg) ⟩
x fg-inv:: ReducedWord→FreeGroup (FreeGroup→ReducedWord fg)
=⟨ fg* |in-ctx (_fg-inv::_ x) ⟩
x fg-inv:: fg
∎)
(λ x {fg} fg* → prop-has-all-paths-↓ (FreeGroup-is-set _ _))
(λ x {fg} fg* → prop-has-all-paths-↓ (FreeGroup-is-set _ _))
FreeGroup≃ReducedWord : FreeGroup A ≃ ReducedWord
FreeGroup≃ReducedWord = FreeGroup→ReducedWord ,
is-eq
_
ReducedWord→FreeGroup
ReducedWord→FreeGroup→ReducedWord
FreeGroup→ReducedWord→FreeGroup
|
{
"alphanum_fraction": 0.5293969533,
"avg_line_length": 44.6235955056,
"ext": "agda",
"hexsha": "d7ca5b7d08fc947b3a51143a32a50c6f49b93aa7",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cmknapp/HoTT-Agda",
"max_forks_repo_path": "theorems/algebra/DecidableFreeGroupIsReducedWord.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cmknapp/HoTT-Agda",
"max_issues_repo_path": "theorems/algebra/DecidableFreeGroupIsReducedWord.agda",
"max_line_length": 96,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cmknapp/HoTT-Agda",
"max_stars_repo_path": "theorems/algebra/DecidableFreeGroupIsReducedWord.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3059,
"size": 7943
}
|
module GotoDefinition where
data ℕ : Set where
Z : ℕ
S : ℕ → ℕ
_+_ : ℕ → ℕ → ℕ
x + y = {! !}
|
{
"alphanum_fraction": 0.5050505051,
"avg_line_length": 14.1428571429,
"ext": "agda",
"hexsha": "43238f6610951cbe639a7b8863bd9e148a7f45c0",
"lang": "Agda",
"max_forks_count": 22,
"max_forks_repo_forks_event_max_datetime": "2022-03-15T11:37:47.000Z",
"max_forks_repo_forks_event_min_datetime": "2020-05-29T12:07:13.000Z",
"max_forks_repo_head_hexsha": "7628c254e87374a924a781cf15ea3abd715fd2d3",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "SNU-2D/agda-mode-vscode",
"max_forks_repo_path": "test/tests/assets/GotoDefinition.agda",
"max_issues_count": 84,
"max_issues_repo_head_hexsha": "7628c254e87374a924a781cf15ea3abd715fd2d3",
"max_issues_repo_issues_event_max_datetime": "2022-03-26T11:43:19.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-06-03T13:16:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "SNU-2D/agda-mode-vscode",
"max_issues_repo_path": "test/tests/assets/GotoDefinition.agda",
"max_line_length": 27,
"max_stars_count": 98,
"max_stars_repo_head_hexsha": "7628c254e87374a924a781cf15ea3abd715fd2d3",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "EdNutting/agda-mode-vscode",
"max_stars_repo_path": "test/tests/assets/GotoDefinition.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-18T09:35:55.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-05-29T07:46:51.000Z",
"num_tokens": 41,
"size": 99
}
|
{-# OPTIONS --no-unicode #-}
module Issue2937.NoUnicode where
foo : _ -> _ -> Set
foo bar x = \x -> foo (bar x {!!}) x
|
{
"alphanum_fraction": 0.5702479339,
"avg_line_length": 17.2857142857,
"ext": "agda",
"hexsha": "ed4456a7e9ba1cb761cbc51579256e770a778fb3",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "shlevy/agda",
"max_forks_repo_path": "test/interaction/Issue2937/NoUnicode.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/interaction/Issue2937/NoUnicode.agda",
"max_line_length": 36,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/interaction/Issue2937/NoUnicode.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 38,
"size": 121
}
|
-- Possible improvements:
-- * Parts of the code are not reachable from main.
-- * The following primitives are not used at all: primPOr, primComp,
-- primHComp, prim^glueU and prim^unglueU.
{-# OPTIONS --erased-cubical --save-metas #-}
-- The code from Agda.Builtin.Cubical.Glue should not be compiled.
open import Agda.Builtin.Cubical.Glue
open import Agda.Builtin.Cubical.HCompU
open import Agda.Builtin.Cubical.Id
open import Agda.Builtin.Cubical.Path
open import Agda.Builtin.Cubical.Sub
open import Agda.Builtin.IO
open import Agda.Builtin.Nat
open import Agda.Builtin.Sigma
open import Agda.Builtin.String
open import Agda.Builtin.Unit
open import Agda.Primitive.Cubical
open import Erased-cubical-Cubical
postulate
putStr : String → IO ⊤
{-# FOREIGN GHC import qualified Data.Text.IO #-}
{-# COMPILE GHC putStr = Data.Text.IO.putStr #-}
{-# COMPILE JS putStr =
function (x) {
return function(cb) {
process.stdout.write(x); cb(0); }; } #-}
i₁ : I
i₁ = primIMax (primIMax (primINeg i0) i1) (primIMin i1 i0)
i₁-1 : IsOne i₁
i₁-1 = IsOne1 (primIMax (primINeg i0) i1) (primIMin i1 i0)
(IsOne2 (primINeg i0) i1 itIsOne)
p₁ : Partial i1 Nat
p₁ = λ _ → 12
p₂ : PartialP i1 (λ _ → Nat)
p₂ = λ _ → 12
p₃ : PartialP i0 (λ _ → Nat)
p₃ = isOneEmpty
p₄ : 12 ≡ 12
p₄ = λ _ → 12
n₁ : Nat
n₁ = p₄ i0
s : Sub Nat i1 (λ _ → 13)
s = inc 13
n₂ : Nat
n₂ = primSubOut s
i₂ : I
i₂ = primFaceForall (λ _ → i1)
i₃ : Id 12 12
i₃ = conid i0 p₄
i₄ : I
i₄ = primDepIMin i1 (λ _ → i0)
i₅ : I
i₅ = primIdFace i₃
p₅ : 12 ≡ 12
p₅ = primIdPath i₃
n₃ : Nat
n₃ = primIdJ (λ _ _ → Nat) 14 i₃
n₄ : Nat
n₄ = primIdElim (λ _ _ → Nat) (λ _ _ _ → 14) i₃
infix 2 _⊎_
data _⊎_ (A B : Set) : Set where
inj₁ : A → A ⊎ B
inj₂ : B → A ⊎ B
data ⊥ : Set where
⊥-elim : {A : Set} → ⊥ → A
⊥-elim ()
-- Some "standard" path functions.
refl : {A : Set} (x : A) → x ≡ x
refl x = λ _ → x
sym : {A : Set} {x y : A} → x ≡ y → y ≡ x
sym p i = p (primINeg i)
cong : {A B : Set} {x y : A} (f : A → B) → x ≡ y → f x ≡ f y
cong f p i = f (p i)
J :
{A : Set} {x y : A}
(P : (x y : A) → x ≡ y → Set) →
(∀ x → P x x (refl x)) →
(x≡y : x ≡ y) → P x y x≡y
J {x = x} P p x≡y =
primTransp (λ i → P _ _ (λ j → x≡y (primIMin i j))) i0 (p x)
subst :
{A : Set} {x y : A}
(P : A → Set) → x ≡ y → P x → P y
subst P eq p = primTransp (λ i → P (eq i)) i0 p
subst-refl :
{A : Set} {x : A}
(P : A → Set) {p : P x} →
subst P (refl x) p ≡ p
subst-refl {x = x} P {p = p} i =
primTransp (λ _ → P x) i p
-- The following definitions are perhaps less standard when paths are
-- used.
trans : {A : Set} {x y z : A} → x ≡ y → y ≡ z → x ≡ z
trans x≡y y≡z = subst (_ ≡_) y≡z x≡y
trans-refl-refl :
{A : Set}
(x : A) → trans (refl x) (refl x) ≡ refl x
trans-refl-refl x = subst-refl (x ≡_)
trans-sym :
{A : Set} {x y : A} (x≡y : x ≡ y) →
trans x≡y (sym x≡y) ≡ refl x
trans-sym =
J (λ x y x≡y → trans x≡y (sym x≡y) ≡ refl x)
trans-refl-refl
-- Propositions and sets.
Is-proposition : Set → Set
Is-proposition A = (x y : A) → x ≡ y
Is-set : Set → Set
Is-set A = (x y : A) → Is-proposition (x ≡ y)
-- Following Hedberg's "A coherence theorem for Martin-Löf's type
-- theory".
decidable-equality→is-set :
{A : Set} →
((x y : A) → x ≡ y ⊎ (x ≡ y → ⊥)) →
Is-set A
decidable-equality→is-set dec =
constant⇒set (λ x y → decidable⇒constant (dec x y))
where
Constant : {A B : Set} → (A → B) → Set
Constant f = ∀ x y → f x ≡ f y
_Left-inverse-of_ : {A B : Set} → (B → A) → (A → B) → Set
g Left-inverse-of f = ∀ x → g (f x) ≡ x
proposition : {A : Set} →
(f : Σ (A → A) Constant) →
Σ _ (_Left-inverse-of (fst f)) →
Is-proposition A
proposition (f , constant) (g , left-inverse) x y =
trans (sym (left-inverse x))
(trans (cong g (constant x y)) (left-inverse y))
left-inverse :
{A : Set}
(f : (x y : A) → x ≡ y → x ≡ y) →
∀ {x y} → Σ _ (_Left-inverse-of (f x y))
left-inverse {A = A} f {x = x} {y = y} =
(λ x≡y → trans x≡y (sym (f y y (refl y))))
, J (λ x y x≡y → trans (f x y x≡y) (sym (f y y (refl y))) ≡ x≡y)
(λ _ → trans-sym _)
constant⇒set :
{A : Set} →
((x y : A) → Σ (x ≡ y → x ≡ y) Constant) →
Is-set A
constant⇒set constant x y =
proposition (constant x y)
(left-inverse λ x y → fst (constant x y))
decidable⇒constant :
{A : Set} →
A ⊎ (A → ⊥) →
Σ (A → A) Constant
decidable⇒constant (inj₁ x) =
(λ _ → x) , (λ _ _ → refl x)
decidable⇒constant (inj₂ ¬A) =
(λ x → x) , (λ x → ⊥-elim (¬A x))
if_then_else_ : {A : Set₁} → Bool → A → A → A
if true then x else y = x
if false then x else y = y
Bool-set : Is-set Bool
Bool-set = decidable-equality→is-set λ where
false false → inj₁ λ _ → false
true true → inj₁ λ _ → true
false true → inj₂ λ eq →
primTransp (λ i → if eq i then ⊥ else ⊤) i0 _
true false → inj₂ λ eq →
primTransp (λ i → if eq i then ⊤ else ⊥) i0 _
data ∥_∥ᴱ (A : Set) : Set where
∣_∣ : A → ∥ A ∥ᴱ
@0 trivial : Is-proposition ∥ A ∥ᴱ
recᴱ : {A B : Set} → @0 Is-proposition B → (A → B) → ∥ A ∥ᴱ → B
recᴱ p f ∣ x ∣ = f x
recᴱ p f (trivial x y i) = p (recᴱ p f x) (recᴱ p f y) i
-- Following Vezzosi, Mörtberg and Abel's "Cubical Agda: A Dependently
-- Typed Programming Language with Univalence and Higher Inductive
-- Types".
data _/_ (A : Set) (R : A → A → Set) : Set where
[_] : A → A / R
[]-respects-relation : (x y : A) → R x y → [ x ] ≡ [ y ]
is-set : Is-set (A / R)
rec :
{A B : Set} {R : A → A → Set} →
Is-set B →
(f : A → B) →
((x y : A) → R x y → f x ≡ f y) →
A / R → B
rec s f g [ x ] = f x
rec s f g ([]-respects-relation x y r i) = g x y r i
rec s f g (is-set x y p q i j) =
s (rec s f g x) (rec s f g y)
(λ k → rec s f g (p k)) (λ k → rec s f g (q k)) i j
const-true : I → Bool
const-true i =
rec
{R = _≡_}
Bool-set
(λ x → x)
(λ _ _ x≡y → x≡y)
(is-set
_ _
([]-respects-relation true true (refl true))
(refl _)
i i)
main : IO ⊤
main =
putStr
(recᴱ
easy
(λ where
true → "Success\n"
false → "Failure\n")
∣ const-true i0 ∣)
-- It should be possible to mention things that are not compiled in
-- type signatures.
u₁ : Not-compiled → ⊤
u₁ _ = tt
@0 A : Set₁
A = Set
u₂ : A → ⊤
u₂ _ = tt
|
{
"alphanum_fraction": 0.5359901143,
"avg_line_length": 23.2877697842,
"ext": "agda",
"hexsha": "b6a174dd36ee1d85873a81d9e88e8dcbe918cd40",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "b5b3b1657556f720a7310cb7744edb1fac71eaf4",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "Seanpm2001-Agda-lang/agda",
"max_forks_repo_path": "test/Compiler/simple/Erased-cubical.agda",
"max_issues_count": 6,
"max_issues_repo_head_hexsha": "b5b3b1657556f720a7310cb7744edb1fac71eaf4",
"max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "Seanpm2001-Agda-lang/agda",
"max_issues_repo_path": "test/Compiler/simple/Erased-cubical.agda",
"max_line_length": 70,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "KDr2/agda",
"max_stars_repo_path": "test/Compiler/simple/Erased-cubical.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-05T00:25:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2022-03-05T00:25:14.000Z",
"num_tokens": 2703,
"size": 6474
}
|
{-# OPTIONS --prop --rewriting #-}
module Examples.Gcd.Euclid where
open import Calf.CostMonoid
import Calf.CostMonoids as CM
{- This file defines the parameters of the analysis of Euclid's algorithm for gcd
and its cost recurrence relation. -}
open import Calf CM.ℕ-CostMonoid
open import Calf.Types.Nat
open import Data.Nat
open import Relation.Binary.PropositionalEquality as P
open import Induction.WellFounded
open import Induction
open import Data.Nat.Properties
open import Data.Nat.DivMod
open import Relation.Nullary.Decidable using (False)
open import Data.Nat.Induction using (<-wellFounded)
open import Data.Product
open import Agda.Builtin.Nat using (div-helper; mod-helper)
open import Relation.Binary using (Rel)
open import Relation.Unary using (Pred; _⊆′_)
mod-tp : (x y : val nat) → cmp (meta (False (y ≟ 0))) → tp pos
mod-tp x y h = Σ++ nat λ z → (U (meta (z ≡ _%_ x y {h})))
mod : cmp (
Π nat λ x →
Π nat λ y →
Π (U (meta (False (y ≟ 0)))) λ h →
F (mod-tp x y h))
mod x y h = step (F (mod-tp x y h)) 1 (ret {mod-tp x y h} (_%_ x y {h} , refl))
gcd/depth/helper : ∀ n → ((m : ℕ) → m < n → (k : ℕ) → (k > m) → ℕ) → (m : ℕ) → (m > n) → ℕ
gcd/depth/helper zero h m h' = 0
gcd/depth/helper n@(suc n') h m h' = suc (h (m % n) (m%n<n m n') n (m%n<n m n'))
gcd/i = Σ++ nat λ x → Σ++ nat λ y → U (meta (x > y))
m>n = val gcd/i
gcd/depth : m>n → ℕ
gcd/depth (x , (y , g)) = All.wfRec <-wellFounded _ (λ y → (x : ℕ) → x > y → ℕ)
gcd/depth/helper y x g
gcd/depth/helper-ext : (x₁ : ℕ)
{IH IH′ : WfRec _<_ (λ y₁ → (x₂ : ℕ) → x₂ > y₁ → ℕ) x₁} →
({y = y₁ : ℕ} (y<x : y₁ < x₁) → IH y₁ y<x ≡ IH′ y₁ y<x) →
gcd/depth/helper x₁ IH ≡ gcd/depth/helper x₁ IH′
gcd/depth/helper-ext zero h = refl
gcd/depth/helper-ext (suc x) h =
funext λ m → funext λ h1 → P.cong suc (
let g = h {m % suc x} (m%n<n m x) in
P.cong-app (P.cong-app g _) _
)
module irr
{a r ℓ}
{A : Set a}
{_<_ : Rel A r} (wf : WellFounded _<_)
(P : Pred A ℓ) (f : WfRec _<_ P ⊆′ P)
(f-ext : (x : A) {IH IH′ : WfRec _<_ P x} → (∀ {y} y<x → IH y y<x ≡ IH′ y y<x) → f x IH ≡ f x IH′)
where
some-wfRecBuilder-irrelevant : ∀ x → (q q′ : Acc _<_ x) → Some.wfRecBuilder P f x q ≡ Some.wfRecBuilder P f x q′
some-wfRecBuilder-irrelevant = All.wfRec wf _
((λ x → (q q′ : Acc _<_ x) → Some.wfRecBuilder P f x q ≡ Some.wfRecBuilder P f x q′))
((λ { x IH (acc rs) (acc rs') → funext λ y → funext λ h → f-ext y λ {y'} h' →
let g = IH y h (rs y h) (rs' y h) in
P.cong-app (P.cong-app g y') h'
}))
gcd/depth-unfold-zero : ∀ {x h} → gcd/depth (x , 0 , h) ≡ 0
gcd/depth-unfold-zero = refl
gcd/depth-unfold-suc : ∀ {x y h} → gcd/depth (x , suc y , h) ≡
suc (gcd/depth (suc y , x % suc y , m%n<n x y))
gcd/depth-unfold-suc {x} {y} {h} = P.cong suc
( P.subst (λ ih →
gcd/depth/helper (mod-helper 0 y x y) (ih) (suc y) (m%n<n x y) ≡
gcd/depth/helper (mod-helper 0 y x y)
(All.wfRecBuilder <-wellFounded _
(λ y₁ → (x₁ : ℕ) → x₁ > y₁ → ℕ) gcd/depth/helper
(mod-helper 0 y x y))
(suc y) (m%n<n x y))
(irr.some-wfRecBuilder-irrelevant <-wellFounded (λ y → (x : ℕ) → x > y → ℕ)
gcd/depth/helper (gcd/depth/helper-ext) (x % suc y)
(<-wellFounded (mod-helper 0 y x y))
(Subrelation.accessible ≤⇒≤′
(Data.Nat.Induction.<′-wellFounded′ (suc y)
(mod-helper 0 y x y) (≤⇒≤′ (m%n<n x y)))))
refl
)
m%n<n' : ∀ m n h → _%_ m n {h} < n
m%n<n' m (suc n) h = m%n<n m n
|
{
"alphanum_fraction": 0.5424143556,
"avg_line_length": 36.78,
"ext": "agda",
"hexsha": "1bb26fd9736409da86a171d2c015390676f88ce7",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-01-29T08:12:01.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-10-06T10:28:24.000Z",
"max_forks_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "jonsterling/agda-calf",
"max_forks_repo_path": "src/Examples/Gcd/Euclid.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "jonsterling/agda-calf",
"max_issues_repo_path": "src/Examples/Gcd/Euclid.agda",
"max_line_length": 119,
"max_stars_count": 29,
"max_stars_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "jonsterling/agda-calf",
"max_stars_repo_path": "src/Examples/Gcd/Euclid.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-22T20:35:11.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-07-14T03:18:28.000Z",
"num_tokens": 1390,
"size": 3678
}
|
data Bin : Set where
⟨⟩ : Bin
_O : Bin → Bin
_I : Bin → Bin
inc : Bin → Bin
inc n = ?
|
{
"alphanum_fraction": 0.5053763441,
"avg_line_length": 11.625,
"ext": "agda",
"hexsha": "d94e123e6ea790d06c12ce15ca142d6abe18a852",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "64a93f8639a1029e5635fe426991d2936868e83a",
"max_forks_repo_licenses": [
"CC-BY-4.0"
],
"max_forks_repo_name": "FintanH/plfa.github.io",
"max_forks_repo_path": "src/plfa/part1/Bin.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "64a93f8639a1029e5635fe426991d2936868e83a",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"CC-BY-4.0"
],
"max_issues_repo_name": "FintanH/plfa.github.io",
"max_issues_repo_path": "src/plfa/part1/Bin.agda",
"max_line_length": 20,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "64a93f8639a1029e5635fe426991d2936868e83a",
"max_stars_repo_licenses": [
"CC-BY-4.0"
],
"max_stars_repo_name": "FintanH/plfa.github.io",
"max_stars_repo_path": "src/plfa/part1/Bin.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 38,
"size": 93
}
|
module Generic where
import Category.Functor
import Category.Monad
open import Data.List using (List ; length ; replicate) renaming ([] to []L ; _∷_ to _∷L_)
open import Data.Maybe using (Maybe ; just ; nothing) renaming (setoid to MaybeEq)
open import Data.Nat using (ℕ ; zero ; suc)
open import Data.Product using (_×_ ; _,_)
open import Data.Vec using (Vec ; toList ; fromList ; map) renaming ([] to []V ; _∷_ to _∷V_)
open import Data.Vec.Equality using () renaming (module Equality to VecEq)
open import Data.Vec.Properties using (map-cong)
open import Function using (_∘_ ; id ; flip)
open import Function.Equality using (_⟶_)
open import Level using () renaming (zero to ℓ₀)
open import Relation.Binary using (Setoid ; module Setoid)
open import Relation.Binary.Core using (_≡_ ; refl)
open import Relation.Binary.Indexed using (_at_) renaming (Setoid to ISetoid)
open import Relation.Binary.PropositionalEquality using (_≗_ ; cong ; subst ; trans ; cong₂) renaming (setoid to EqSetoid)
open Setoid using () renaming (_≈_ to _∋_≈_)
open Category.Functor.RawFunctor {Level.zero} Data.Maybe.functor using (_<$>_)
open Category.Monad.RawMonad {Level.zero} Data.Maybe.monad using (_>>=_)
≡-to-Π : {A B : Set} → (A → B) → EqSetoid A ⟶ EqSetoid B
≡-to-Π f = record { _⟨$⟩_ = f; cong = cong f }
just-injective : {A : Set} → {x y : A} → Maybe.just x ≡ Maybe.just y → x ≡ y
just-injective refl = refl
length-replicate : {A : Set} {a : A} → (n : ℕ) → length (replicate n a) ≡ n
length-replicate zero = refl
length-replicate (suc n) = cong suc (length-replicate n)
sequenceV : {A : Set} {n : ℕ} → Vec (Maybe A) n → Maybe (Vec A n)
sequenceV []V = just []V
sequenceV (x ∷V xs) = x >>= (λ y → (_∷V_ y) <$> sequenceV xs)
mapMV : {A B : Set} {n : ℕ} → (A → Maybe B) → Vec A n → Maybe (Vec B n)
mapMV f = sequenceV ∘ map f
mapMV-cong : {A B : Set} {f g : A → Maybe B} → f ≗ g → {n : ℕ} → mapMV {n = n} f ≗ mapMV g
mapMV-cong f≗g v = cong sequenceV (map-cong f≗g v)
mapMV-purity : {A B : Set} {n : ℕ} → (f : A → B) → (v : Vec A n) → mapMV (Maybe.just ∘ f) v ≡ just (map f v)
mapMV-purity f []V = refl
mapMV-purity f (x ∷V xs) = cong (_<$>_ (_∷V_ (f x))) (mapMV-purity f xs)
maybeEq-from-≡ : {A : Set} {a b : Maybe A} → a ≡ b → MaybeEq (EqSetoid A) ∋ a ≈ b
maybeEq-from-≡ {a = just x} {b = .(just x)} refl = just refl
maybeEq-from-≡ {a = nothing} {b = .nothing} refl = nothing
maybeEq-to-≡ : {A : Set} {a b : Maybe A} → MaybeEq (EqSetoid A) ∋ a ≈ b → a ≡ b
maybeEq-to-≡ (just refl) = refl
maybeEq-to-≡ nothing = refl
subst-cong : {A : Set} → (T : A → Set) → {g : A → A} → {a b : A} → (f : {c : A} → T c → T (g c)) → (p : a ≡ b) →
f ∘ subst T p ≗ subst T (cong g p) ∘ f
subst-cong T f refl _ = refl
subst-fromList : {A : Set} {x y : List A} → (p : y ≡ x) →
subst (Vec A) (cong length p) (fromList y) ≡ fromList x
subst-fromList refl = refl
subst-subst : {A : Set} (T : A → Set) {a b c : A} → (p : a ≡ b) → (p′ : b ≡ c) → (x : T a) →
subst T p′ (subst T p x) ≡ subst T (trans p p′) x
subst-subst T refl p′ x = refl
toList-fromList : {A : Set} → (l : List A) → toList (fromList l) ≡ l
toList-fromList []L = refl
toList-fromList (x ∷L xs) = cong (_∷L_ x) (toList-fromList xs)
toList-subst : {A : Set} → {n m : ℕ} (v : Vec A n) → (p : n ≡ m) →
toList (subst (Vec A) p v) ≡ toList v
toList-subst v refl = refl
VecISetoid : Setoid ℓ₀ ℓ₀ → ISetoid ℕ ℓ₀ ℓ₀
VecISetoid S = record
{ Carrier = Vec (Setoid.Carrier S)
; _≈_ = λ x → VecEq._≈_ S x
; isEquivalence = record
{ refl = VecEq.refl S _
; sym = VecEq.sym S
; trans = VecEq.trans S }
}
|
{
"alphanum_fraction": 0.6013179572,
"avg_line_length": 42.8470588235,
"ext": "agda",
"hexsha": "9f1172db868b626d799e90b0a0ad87d659a6cadd",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "a5abbd177f032523d1d9d3fa4b9137aefe88dee0",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "jvoigtlaender/bidiragda",
"max_forks_repo_path": "Generic.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a5abbd177f032523d1d9d3fa4b9137aefe88dee0",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "jvoigtlaender/bidiragda",
"max_issues_repo_path": "Generic.agda",
"max_line_length": 122,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a5abbd177f032523d1d9d3fa4b9137aefe88dee0",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "jvoigtlaender/bidiragda",
"max_stars_repo_path": "Generic.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1358,
"size": 3642
}
|
-- WARNING: This file was generated automatically by Vehicle
-- and should not be modified manually!
-- Metadata
-- - Agda version: 2.6.2
-- - AISEC version: 0.1.0.1
-- - Time generated: ???
{-# OPTIONS --allow-exec #-}
open import Vehicle
open import Vehicle.Data.Tensor
open import Data.Product
open import Data.Integer as ℤ using (ℤ)
open import Data.Rational as ℚ using (ℚ)
open import Data.List
open import Relation.Binary.PropositionalEquality
module reachability-temp-output where
postulate f : Tensor ℚ (2 ∷ []) → Tensor ℚ (1 ∷ [])
abstract
reachable : ∃ λ (x : Tensor ℚ (2 ∷ [])) → f x ≡ ℤ.+ 0 ℚ./ 1 ∷ []
reachable = checkSpecification record
{ proofCache = "/home/matthew/Code/AISEC/vehicle/proofcache.vclp"
}
|
{
"alphanum_fraction": 0.689608637,
"avg_line_length": 28.5,
"ext": "agda",
"hexsha": "5e08f17255e7c09dfd22a05adc344f78c12712ac",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "vehicle-lang/vehicle",
"max_forks_repo_path": "test/Test/Compile/Golden/reachability/reachability-output.agda",
"max_issues_count": 19,
"max_issues_repo_head_hexsha": "25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T20:49:39.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-03-07T14:09:13.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "vehicle-lang/vehicle",
"max_issues_repo_path": "test/Test/Compile/Golden/reachability/reachability-output.agda",
"max_line_length": 71,
"max_stars_count": 9,
"max_stars_repo_head_hexsha": "25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "vehicle-lang/vehicle",
"max_stars_repo_path": "test/Test/Compile/Golden/reachability/reachability-output.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-17T18:51:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2022-02-10T12:56:42.000Z",
"num_tokens": 220,
"size": 741
}
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Algebra.Group.Higher where
open import Cubical.Core.Everything
open import Cubical.Data.Nat
open import Cubical.Data.Sigma
open import Cubical.Data.Unit
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Prelude hiding (comp)
open import Cubical.Foundations.Pointed
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.Homotopy.Loopspace
open import Cubical.Homotopy.Connected
open import Cubical.Homotopy.Base
open import Cubical.Homotopy.PointedFibration
open import Cubical.Algebra.Group.Base
open import Cubical.Algebra.Group.EilenbergMacLane1
open import Cubical.HITs.EilenbergMacLane1
open import Cubical.Algebra.Group.Base
open import Cubical.Algebra.Group.Morphism
open import Cubical.Algebra.Group.MorphismProperties
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Equiv.Properties
open import Cubical.HITs.PropositionalTruncation renaming (rec to propRec)
open import Cubical.HITs.Truncation.FromNegOne as Trunc renaming (rec to trRec)
open import Cubical.HITs.SetTruncation
open import Cubical.Functions.Surjection
open import Cubical.Functions.Embedding
import Cubical.Foundations.GroupoidLaws as GL
private
variable
ℓ ℓ' : Level
record HigherGroup ℓ : Type (ℓ-suc ℓ) where
constructor highergroup
field
base : Pointed ℓ
isConn : isConnected 2 (typ base)
record BGroup ℓ (n k : ℕ) : Type (ℓ-suc ℓ) where
no-eta-equality
constructor bgroup
field
base : Pointed ℓ
isConn : isConnected (k + 1) (typ base)
isTrun : isOfHLevel (n + k + 2) (typ base)
BGroupΣ : {ℓ : Level} (n k : ℕ) → Type (ℓ-suc ℓ)
BGroupΣ {ℓ} n k = Σ[ A ∈ Type ℓ ] A × (isConnected (k + 1) A) × (isOfHLevel (n + k + 2) A)
module _ where
open BGroup
η-BGroup : {n k : ℕ} {BG BH : BGroup ℓ n k}
→ (p : typ (base BG) ≡ typ (base BH))
→ (q : PathP (λ i → p i) (pt (base BG)) (pt (base BH)))
→ BG ≡ BH
base (η-BGroup p q i) .fst = p i
base (η-BGroup p q i) .snd = q i
isConn (η-BGroup {k = k} {BG = BG} {BH = BH} p q i) = r i
where
r : PathP (λ i → isConnected (k + 1) (p i)) (isConn BG) (isConn BH)
r = isProp→PathP (λ _ → isPropIsOfHLevel 0) (isConn BG) (isConn BH)
isTrun (η-BGroup {n = n} {k = k} {BG = BG} {BH = BH} p q i) = s i
where
s : PathP (λ i → isOfHLevel (n + k + 2) (p i)) (isTrun BG) (isTrun BH)
s = isProp→PathP (λ i → isPropIsOfHLevel (n + k + 2)) (isTrun BG) (isTrun BH)
-- morphisms
BGroupHom : {n k : ℕ} (G : BGroup ℓ n k) (H : BGroup ℓ' n k) → Type (ℓ-max ℓ ℓ')
BGroupHom G H = (BGroup.base G) →∙ (BGroup.base H)
BGroupHomΣ : {n k : ℕ} (BG : BGroupΣ {ℓ} n k) (BH : BGroupΣ {ℓ'} n k) → Type (ℓ-max ℓ ℓ')
BGroupHomΣ (base , pt , _) (base' , pt' , _) = (base , pt) →∙ (base' , pt')
isOfHLevel-BGroupHomΣ : {n k : ℕ} (BG : BGroupΣ {ℓ} n k) (BH : BGroupΣ {ℓ'} n k)
→ isOfHLevel (n + 2) (BGroupHomΣ BG BH)
isOfHLevel-BGroupHomΣ {n = n} {k = k} BG BH = x'
where
z : isOfHLevel (n + k + 2) (fst BH)
z = snd (snd (snd BH))
z' : isOfHLevel (n + 1 + 1 + k) (fst BH)
z' = subst (λ m → isOfHLevel m (fst BH))
(n + k + 2 ≡⟨ sym (+-assoc n k 2) ⟩
n + (k + 2) ≡⟨ cong (n +_) (+-comm k 2) ⟩
n + (2 + k) ≡⟨ +-assoc n 2 k ⟩
(n + 2) + k ≡⟨ cong (_+ k) (+-assoc n 1 1) ⟩
n + 1 + 1 + k ∎)
z
x : isOfHLevel (n + 1 + 1) (BGroupHomΣ BG BH)
x = sec∙Trunc (fst BG , fst (snd BG)) (fst (snd (snd BG))) λ _ → (fst BH , fst (snd BH)) , z'
x' : isOfHLevel (n + 2) (BGroupHomΣ BG BH)
x' = subst (λ m → isOfHLevel m (BGroupHomΣ BG BH)) (sym (+-assoc n 1 1)) x
BGroupIso : {n k : ℕ} (G : BGroup ℓ n k) (H : BGroup ℓ' n k) → Type (ℓ-max ℓ ℓ')
BGroupIso G H = (BGroup.base G) ≃∙ (BGroup.base H)
BGroupIdIso : {n k : ℕ} (BG : BGroup ℓ n k) → BGroupIso BG BG
BGroupIdIso BG = idEquiv∙ (BGroup.base BG)
BGroupIso→≡ : {n k : ℕ} {BG BH : BGroup ℓ n k}
(f : BGroupIso BG BH)
→ BG ≡ BH
BGroupIso→≡ {BG = BG} {BH = BH} f = η-BGroup (ua (≃∙→≃ f)) (toPathP ((uaβ ((≃∙→≃ f)) (pt (BGroup.base BG))) ∙ f .fst .snd))
-- getters
carrier : {ℓ : Level} {n k : ℕ} (G : BGroup ℓ n k) → Pointed ℓ
carrier {k = k} BG = (Ω^ k) base
where
open BGroup BG
basetype : {ℓ : Level} {n k : ℕ} (BG : BGroup ℓ n k) → Type ℓ
basetype BG = typ (BGroup.base BG)
basepoint : {ℓ : Level} {n k : ℕ} (BG : BGroup ℓ n k) → basetype BG
basepoint BG = pt (BGroup.base BG)
baseΣ : {ℓ : Level} {n k : ℕ} (BG : BGroupΣ {ℓ} n k) → Σ[ A ∈ Type ℓ ] A
baseΣ (base , * , _ , _) = (base , *)
-- special cases
1BGroup : (ℓ : Level) → Type (ℓ-suc ℓ)
1BGroup ℓ = BGroup ℓ 0 1
1BGroupΣ : {ℓ : Level} → Type (ℓ-suc ℓ)
1BGroupΣ {ℓ} = BGroupΣ {ℓ} 0 1
-- first fundamental group of 1BGroups
π₁-1BGroup : {ℓ : Level} (BG : 1BGroup ℓ) → Group {ℓ}
π₁-1BGroup BG =
makeGroup {G = (pt base) ≡ (pt base)}
refl
_∙_
sym
(isTrun (pt base) (pt base))
GL.assoc
(λ a → sym (GL.rUnit a))
(λ g → sym (GL.lUnit g))
GL.rCancel
GL.lCancel
where
open BGroup BG
π₁-1BGroupΣ : {ℓ : Level} (BG : BGroupΣ {ℓ} 0 1) → Group {ℓ}
π₁-1BGroupΣ (BG , pt , conn , trunc) = π₁-1BGroup (bgroup (BG , pt) conn trunc)
-- coercions
Group→1BGroup : (G : Group {ℓ}) → 1BGroup ℓ
BGroup.base (Group→1BGroup G) .fst = EM₁ G
BGroup.base (Group→1BGroup G) .snd = embase
BGroup.isConn (Group→1BGroup G) = EM₁Connected G
BGroup.isTrun (Group→1BGroup G) = EM₁Groupoid G
-- functoriality of π₁ on 1BGroups
module _ (BG : 1BGroup ℓ) (BH : 1BGroup ℓ') where
private
π₁BG = π₁-1BGroup BG
π₁BH = π₁-1BGroup BH
π₁-1BGroup-functor : BGroupHom BG BH → GroupHom π₁BG π₁BH
GroupHom.fun (π₁-1BGroup-functor f) g = sym (snd f) ∙∙ cong (fst f) g ∙∙ snd f
GroupHom.isHom (π₁-1BGroup-functor f) g g' = q
where
f₁ = fst f
f₂ = snd f
f₂- = sym (snd f)
abstract
q = (f₂- ∙∙ cong f₁ (g ∙ g') ∙∙ f₂)
≡⟨ doubleCompPath-elim' f₂- (cong f₁ (g ∙ g')) f₂ ⟩
f₂- ∙ cong f₁ (g ∙ g') ∙ f₂
≡⟨ cong (λ z → (f₂- ∙ z ∙ f₂))
(congFunct f₁ g g') ⟩
f₂- ∙ (cong f₁ g ∙ cong f₁ g') ∙ f₂
≡⟨ cong (λ z → (f₂- ∙ (cong f₁ g ∙ z) ∙ f₂))
(lUnit (cong f₁ g')) ⟩
f₂- ∙ (cong f₁ g ∙ refl ∙ cong f₁ g') ∙ f₂
≡⟨ cong (λ z → (f₂- ∙ (cong f₁ g ∙ z ∙ cong f₁ g') ∙ f₂))
(sym (rCancel f₂)) ⟩
f₂- ∙ (cong f₁ g ∙ (f₂ ∙ f₂-) ∙ cong f₁ g') ∙ f₂
≡⟨ cong (λ z → (f₂- ∙ (cong f₁ g ∙ z) ∙ f₂))
(sym (assoc _ _ _)) ⟩
f₂- ∙ (cong f₁ g ∙ (f₂ ∙ (f₂- ∙ cong f₁ g'))) ∙ f₂
≡⟨ cong (λ z → (f₂- ∙ z ∙ f₂))
(assoc _ _ _) ⟩
(f₂- ∙ ((cong f₁ g ∙ f₂) ∙ (f₂- ∙ cong f₁ g')) ∙ f₂)
≡⟨ cong (f₂- ∙_)
(sym (assoc _ _ _)) ⟩
(f₂- ∙ ((cong f₁ g ∙ f₂) ∙ ((f₂- ∙ cong f₁ g') ∙ f₂)))
≡⟨ cong (λ z → (f₂- ∙ ((cong f₁ g ∙ f₂) ∙ z)))
(sym (assoc _ _ _)) ⟩
(f₂- ∙ ((cong f₁ g ∙ f₂) ∙ (f₂- ∙ cong f₁ g' ∙ f₂)))
≡⟨ assoc _ _ _ ⟩
(f₂- ∙ cong f₁ g ∙ f₂) ∙ (f₂- ∙ cong f₁ g' ∙ f₂)
≡⟨ cong (_∙ (f₂- ∙ cong f₁ g' ∙ f₂))
(sym (doubleCompPath-elim' f₂- (cong f₁ g) f₂)) ⟩
(f₂- ∙∙ cong f₁ g ∙∙ f₂) ∙ (f₂- ∙ cong f₁ g' ∙ f₂)
≡⟨ cong ((f₂- ∙∙ cong f₁ g ∙∙ f₂) ∙_)
(sym (doubleCompPath-elim' f₂- (cong f₁ g') f₂)) ⟩
(f₂- ∙∙ cong f₁ g ∙∙ f₂) ∙ (f₂- ∙∙ cong f₁ g' ∙∙ f₂) ∎
-- π₁ is a left inverse to EM₁
π₁EM₁≃inv : (G : Group {ℓ}) → GroupEquiv G (π₁-1BGroup (Group→1BGroup G))
GroupEquiv.eq (π₁EM₁≃inv G) = isoToEquiv (invIso (ΩEM₁Iso G))
GroupEquiv.isHom (π₁EM₁≃inv G) g g' = emloop-comp G g g'
π₁EM₁≃ : (G : Group {ℓ}) → GroupEquiv (π₁-1BGroup (Group→1BGroup G)) G
π₁EM₁≃ G = invGroupEquiv (π₁EM₁≃inv G)
-- the functorial action of EM₁ on groups
-- is a left inverse to the functorial action of π₁
-- on 1BGroups.
module _ (H : Group {ℓ}) (BG : 1BGroup ℓ') where
private
EM₁H = Group→1BGroup H
π₁EM₁H = π₁-1BGroup EM₁H
π₁BG = π₁-1BGroup BG
-- from the EM construction it follows
-- that there is a homomorphism H → π₁ (EM₁ H)
H→π₁EM₁H : GroupHom H π₁EM₁H
H→π₁EM₁H = GroupEquiv.hom (π₁EM₁≃inv H)
-- the promised functorial left inverse
-- split up into the three components:
-- function, is equivalence and pointedness.
-- pointedness component is trivial
-- on the object level
EM₁-functor-lInv-function : GroupHom π₁EM₁H π₁BG → basetype EM₁H → basetype BG
EM₁-functor-lInv-function f =
rec' H
(BGroup.isTrun BG)
(basepoint BG)
(GroupHom.fun (compGroupHom H→π₁EM₁H f))
λ g h → sym (GroupHom.isHom (compGroupHom H→π₁EM₁H f) g h)
EM₁-functor-lInv-pointed : (f : GroupHom π₁EM₁H π₁BG)
→ EM₁-functor-lInv-function f (basepoint EM₁H) ≡ basepoint BG
EM₁-functor-lInv-pointed f = refl
-- produces an equivalence proof when given a group iso
EM₁-functor-lInv-onIso-isEquiv : (f : GroupEquiv π₁EM₁H π₁BG)
→ isEquiv (EM₁-functor-lInv-function (GroupEquiv.hom f))
EM₁-functor-lInv-onIso-isEquiv f =
isEmbedding×isSurjection→isEquiv (isEmbedding-φ , isSurjection-φ)
where
φ₁ : basetype EM₁H → basetype BG
φ₁ = EM₁-functor-lInv-function (GroupEquiv.hom f)
abstract
isEmbedding-φ : isEmbedding φ₁
isEmbedding-φ = reduceToBp isEmbPt
where
isEmb : (x y : basetype EM₁H) → Type (ℓ-max ℓ ℓ')
isEmb x y = isEquiv (cong {x = x} {y = y} φ₁)
isPropIsEmb : (x y : basetype EM₁H) → isProp (isEmb x y)
isPropIsEmb x y = isPropIsEquiv (cong {x = x} {y = y} φ₁)
f-equiv : (basepoint EM₁H ≡ basepoint EM₁H) ≃ (basepoint BG ≡ basepoint BG)
f-equiv = GroupEquiv.eq f
f₁ = fst f-equiv
γ : ⟨ H ⟩ ≃ ⟨ π₁EM₁H ⟩
γ = GroupEquiv.eq (π₁EM₁≃inv H)
β : ⟨ π₁EM₁H ⟩ ≃ typ (carrier BG)
β = f-equiv
δ : ⟨ H ⟩ ≃ typ (carrier BG)
δ = compEquiv γ β
p : equivFun δ ≡ (λ h → cong φ₁ (equivFun γ h))
p = refl
η = (λ (h : ⟨ H ⟩) → cong φ₁ (equivFun γ h))
isEquiv-η : isEquiv η
isEquiv-η = equivFun≡→isEquiv δ η λ _ → refl
congφ∼f : (h : ⟨ H ⟩) → f₁ (GroupHom.fun H→π₁EM₁H h) ≡ cong φ₁ (GroupHom.fun H→π₁EM₁H h)
congφ∼f p = refl
isEmbPt : isEmb (basepoint EM₁H) (basepoint EM₁H)
isEmbPt = equivCompLCancel γ (cong φ₁) isEquiv-η
g : Unit → basetype EM₁H
g _ = basepoint EM₁H
isConn-g : isConnectedFun 1 g
isConn-g = isConnectedPoint 1 (BGroup.isConn EM₁H) (basepoint EM₁H)
reduceToBp1 : ((a : Unit) → isEmb (basepoint EM₁H) (g a))
→ (h' : basetype EM₁H) → isEmb (basepoint EM₁H) h'
reduceToBp1 =
Iso.inv (elim.isIsoPrecompose g
1
(λ h' → (isEmb (basepoint EM₁H) h') , isPropIsEmb (basepoint EM₁H) h')
isConn-g)
reduceToBp1' : isEmb (basepoint EM₁H) (basepoint EM₁H)
→ (h' : basetype EM₁H) → isEmb (basepoint EM₁H) h'
reduceToBp1' p = reduceToBp1 λ _ → p
reduceToBp2 : (h' : basetype EM₁H) → isEmb (basepoint EM₁H) h'
→ ((a : Unit) → isEmb (g a) h') → (h : basetype EM₁H) → isEmb h h'
reduceToBp2 h' p =
Iso.inv (elim.isIsoPrecompose g
1
(λ h → (isEmb h h') , (isPropIsEmb h h'))
isConn-g)
reduceToBp2' : ((h' : basetype EM₁H) → isEmb (basepoint EM₁H) h')
→ (h h' : basetype EM₁H) → isEmb h h'
reduceToBp2' Q h h' = reduceToBp2 h' (Q h') (λ _ → Q h') h
reduceToBp : isEmb (basepoint EM₁H) (basepoint EM₁H) → (h h' : basetype EM₁H) → isEmb h h'
reduceToBp p = reduceToBp2' (reduceToBp1' p)
isSurjection-φ : isSurjection φ₁
isSurjection-φ g = propTruncΣ← (λ x → φ₁ x ≡ g) ∣ basepoint EM₁H , fst r ∣
where
r : isContr ∥ φ₁ (basepoint EM₁H) ≡ g ∥
r = isContrRespectEquiv (invEquiv propTrunc≃Trunc1)
(isConnectedPath 1
(BGroup.isConn BG)
(φ₁ (basepoint EM₁H))
g)
|
{
"alphanum_fraction": 0.5333333333,
"avg_line_length": 39.0718562874,
"ext": "agda",
"hexsha": "146ba1dc72a88ff88b560099811c57866cd88426",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Schippmunk/cubical",
"max_forks_repo_path": "Cubical/Algebra/Group/Higher.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Schippmunk/cubical",
"max_issues_repo_path": "Cubical/Algebra/Group/Higher.agda",
"max_line_length": 123,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Schippmunk/cubical",
"max_stars_repo_path": "Cubical/Algebra/Group/Higher.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 4992,
"size": 13050
}
|
module Type.Properties.MereProposition {ℓ ℓₑ} where
import Lvl
open import Lang.Instance
open import Structure.Setoid
open import Type
-- A type is a mere proposition type when there is at most one inhabitant (there is at most one object with this type).
-- In other words: If there is an inhabitant of type T, it is unique (essentially only allowing empty or singleton types, but this is not provable (excluded middöe)).
-- Also called:
-- • "Irrelevance" / "Irrelevancy" / "Proof irrelevance" (in the context of proofs).
-- A proof of the proposition T is unique (using equality to determine uniqueness).
-- • "isProp" / "h-proposition" / "is of h-level 1" / "a mere proposition" (in homotopy type theory).
-- Classically, when MereProposition(T), T is either empty or a singleton (which in the context of proofs corresponds to types isomorphic to ⊥ or ⊤).
-- • "subsingleton" (in set theory)
-- When a type and its inhabitants is interpreted as a set and its elements.
-- • "subterminal object" (in category theory).
module _ (T : Type{ℓ}) ⦃ _ : Equiv{ℓₑ}(T) ⦄ where
record MereProposition : Type{ℓ Lvl.⊔ ℓₑ} where
constructor intro
field uniqueness : ∀{x y : T} → (x ≡ y)
uniqueness = inst-fn MereProposition.uniqueness
-- TODO: Consider using unicode ◐○●⧭⦵⦳
|
{
"alphanum_fraction": 0.7160589604,
"avg_line_length": 51.56,
"ext": "agda",
"hexsha": "ffd712aea25936fa3c7eaa10c865d1bd38485b52",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Type/Properties/MereProposition.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Type/Properties/MereProposition.agda",
"max_line_length": 166,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Type/Properties/MereProposition.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z",
"num_tokens": 377,
"size": 1289
}
|
{-# OPTIONS --sized-types #-}
open import Relation.Binary.Core
module SelectSort.Correctness.Permutation {A : Set}
(_≤_ : A → A → Set)
(tot≤ : Total _≤_ ) where
open import Data.List
open import Data.Product
open import Data.Sum
open import List.Permutation.Base A
open import List.Permutation.Base.Equivalence A
open import Size
open import SList
open import SList.Properties
open import SelectSort _≤_ tot≤
lemma-select∼ : {ι : Size}(x : A) → (xs : SList A {ι}) → unsize A (x ∙ xs) ∼ unsize A (proj₁ (select x xs) ∙ proj₂ (select x xs))
lemma-select∼ x snil = ∼x /head /head ∼[]
lemma-select∼ x (y ∙ ys)
with tot≤ x y
... | inj₁ x≤y = ∼x (/tail /head) (/tail /head) (lemma-select∼ x ys)
... | inj₂ y≤x = ∼x /head (/tail /head) (lemma-select∼ y ys)
lemma-selectSort∼ : {ι : Size}(xs : SList A {ι}) → unsize A xs ∼ unsize A (selectSort xs)
lemma-selectSort∼ snil = ∼[]
lemma-selectSort∼ (x ∙ xs) = trans∼ (lemma-select∼ x xs) (∼x /head /head (lemma-selectSort∼ (proj₂ (select x xs))))
theorem-selectSort∼ : (xs : List A) → xs ∼ unsize A (selectSort (size A xs))
theorem-selectSort∼ xs = trans∼ (lemma-unsize-size A xs) (lemma-selectSort∼ (size A xs))
|
{
"alphanum_fraction": 0.643572621,
"avg_line_length": 37.4375,
"ext": "agda",
"hexsha": "9e5ee691834dba882a4c688cbc80ffd96d7ab3b0",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bgbianchi/sorting",
"max_forks_repo_path": "agda/SelectSort/Correctness/Permutation.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "bgbianchi/sorting",
"max_issues_repo_path": "agda/SelectSort/Correctness/Permutation.agda",
"max_line_length": 129,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bgbianchi/sorting",
"max_stars_repo_path": "agda/SelectSort/Correctness/Permutation.agda",
"max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z",
"num_tokens": 412,
"size": 1198
}
|
import Structure.Logic.Classical.NaturalDeduction
-- TODO: Seems like Constructive does not work, but why?
module Structure.Logic.Constructive.Syntax.Algebra {ℓₗ} {Formula} {ℓₘₗ} {Proof} {ℓₒ} {Domain} ⦃ classicalLogic : _ ⦄ where
open Structure.Logic.Classical.NaturalDeduction.ClassicalLogic {ℓₗ} {Formula} {ℓₘₗ} {Proof} {ℓₒ} {Domain} (classicalLogic)
import Lvl
open import Syntax.Function
open import Type
-- Transitivitity through an operation on proofs
record Transitivable{ℓ}{T : Type{ℓ}}(_▫_ : T → T → Formula) : Type{ℓₘₗ Lvl.⊔ ℓₒ Lvl.⊔ ℓ} where
field
_🝖_ : ∀{a b c} → Proof(a ▫ b) → Proof(b ▫ c) → Proof(a ▫ c)
open Transitivable ⦃ ... ⦄ public
Transitivity-to-Transitivable : ∀{_▫_ : Domain → Domain → Formula} → Proof(∀ₗ(a ↦ ∀ₗ(b ↦ ∀ₗ(c ↦ (a ▫ b)∧(b ▫ c) ⟶ (a ▫ c))))) → Transitivable(_▫_)
_🝖_ ⦃ Transitivity-to-Transitivable proof ⦄ {a}{b}{c} ab bc =
([→].elim
([∀].elim ([∀].elim ([∀].elim proof {a}){b}){c})
([∧].intro ab bc)
)
instance
[⟶]-transitivable : Transitivable(_⟶_)
_🝖_ ⦃ [⟶]-transitivable ⦄ = [→].transitivity
instance
[⟷]-transitivable : Transitivable(_⟷_)
_🝖_ ⦃ [⟷]-transitivable ⦄ = [↔].transitivity
|
{
"alphanum_fraction": 0.6432848589,
"avg_line_length": 37.7096774194,
"ext": "agda",
"hexsha": "eef4401c8921f3a9552738b58f9a061a3f83c5ef",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "old/Structure/Logic/Constructive/Syntax/Algebra.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "old/Structure/Logic/Constructive/Syntax/Algebra.agda",
"max_line_length": 146,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "old/Structure/Logic/Constructive/Syntax/Algebra.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z",
"num_tokens": 483,
"size": 1169
}
|
{-# OPTIONS --without-K --safe #-}
module Categories.Functor.Hom where
-- The Hom Functor from C.op × C to Setoids,
-- the two 1-argument version fixing one object
-- and some notation for the version where the category must be made explicit
open import Data.Product
open import Function using () renaming (_∘_ to _∙_)
open import Categories.Category
open import Categories.Functor hiding (id)
open import Categories.Functor.Bifunctor
open import Categories.Category.Instance.Setoids
import Categories.Morphism.Reasoning as MR
open import Relation.Binary using (Setoid)
module Hom {o ℓ e} (C : Category o ℓ e) where
open Category C
open MR C
Hom[-,-] : Bifunctor (Category.op C) C (Setoids ℓ e)
Hom[-,-] = record
{ F₀ = F₀′
; F₁ = λ where
(f , g) → record
{ _⟨$⟩_ = λ h → g ∘ h ∘ f
; cong = ∘-resp-≈ʳ ∙ ∘-resp-≈ˡ
}
; identity = identity′
; homomorphism = homomorphism′
; F-resp-≈ = F-resp-≈′
}
where F₀′ : Obj × Obj → Setoid ℓ e
F₀′ (A , B) = hom-setoid {A} {B}
open HomReasoning
identity′ : {A : Obj × Obj} {x y : uncurry _⇒_ A} → x ≈ y → id ∘ x ∘ id ≈ y
identity′ {A} {x} {y} x≈y = begin
id ∘ x ∘ id ≈⟨ identityˡ ⟩
x ∘ id ≈⟨ identityʳ ⟩
x ≈⟨ x≈y ⟩
y ∎
homomorphism′ : ∀ {X Y Z : Σ Obj (λ x → Obj)}
{f : proj₁ Y ⇒ proj₁ X × proj₂ X ⇒ proj₂ Y}
{g : proj₁ Z ⇒ proj₁ Y × proj₂ Y ⇒ proj₂ Z}
{x y : proj₁ X ⇒ proj₂ X} →
x ≈ y →
(proj₂ g ∘ proj₂ f) ∘ x ∘ proj₁ f ∘ proj₁ g ≈
proj₂ g ∘ (proj₂ f ∘ y ∘ proj₁ f) ∘ proj₁ g
homomorphism′ {f = f₁ , f₂} {g₁ , g₂} {x} {y} x≈y = begin
(g₂ ∘ f₂) ∘ x ∘ f₁ ∘ g₁ ≈˘⟨ refl⟩∘⟨ assoc ⟩
(g₂ ∘ f₂) ∘ (x ∘ f₁) ∘ g₁ ≈⟨ pullʳ (pullˡ (∘-resp-≈ʳ (∘-resp-≈ˡ x≈y))) ⟩
g₂ ∘ (f₂ ∘ y ∘ f₁) ∘ g₁ ∎
F-resp-≈′ : ∀ {A B : Σ Obj (λ x → Obj)}
{f g : Σ (proj₁ B ⇒ proj₁ A) (λ x → proj₂ A ⇒ proj₂ B)} →
Σ (proj₁ f ≈ proj₁ g) (λ x → proj₂ f ≈ proj₂ g) →
{x y : proj₁ A ⇒ proj₂ A} →
x ≈ y → proj₂ f ∘ x ∘ proj₁ f ≈ proj₂ g ∘ y ∘ proj₁ g
F-resp-≈′ {f = f₁ , f₂} {g₁ , g₂} (f₁≈g₁ , f₂≈g₂) {x} {y} x≈y = begin
f₂ ∘ x ∘ f₁ ≈⟨ f₂≈g₂ ⟩∘⟨ x≈y ⟩∘⟨ f₁≈g₁ ⟩
g₂ ∘ y ∘ g₁ ∎
open Functor Hom[-,-]
open Equiv
open HomReasoning
Hom[_,-] : Obj → Functor C (Setoids ℓ e)
Hom[_,-] = appˡ Hom[-,-]
Hom[-,_] : Obj → Contravariant C (Setoids ℓ e)
Hom[-,_] = appʳ Hom[-,-]
-- Notation for when the ambient Category must be specified explicitly.
module _ {o ℓ e} (C : Category o ℓ e) where
open Category C
open Hom C
Hom[_][-,-] : Bifunctor (Category.op C) C (Setoids ℓ e)
Hom[_][-,-] = Hom[-,-]
Hom[_][_,-] : Obj → Functor C (Setoids ℓ e)
Hom[_][_,-] B = Hom[ B ,-]
Hom[_][-,_] : Obj → Contravariant C (Setoids ℓ e)
Hom[_][-,_] B = Hom[-, B ]
|
{
"alphanum_fraction": 0.4754202347,
"avg_line_length": 35.0333333333,
"ext": "agda",
"hexsha": "d7271b5b4fb8529e3073c8f1182c4c2966bd9421",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Taneb/agda-categories",
"max_forks_repo_path": "Categories/Functor/Hom.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Taneb/agda-categories",
"max_issues_repo_path": "Categories/Functor/Hom.agda",
"max_line_length": 85,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Taneb/agda-categories",
"max_stars_repo_path": "Categories/Functor/Hom.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1212,
"size": 3153
}
|
{-# OPTIONS --without-K --safe #-}
module Quasigroup where
open import Quasigroup.Bundles public
open import Quasigroup.Definitions public
open import Quasigroup.Structures public
|
{
"alphanum_fraction": 0.8021978022,
"avg_line_length": 22.75,
"ext": "agda",
"hexsha": "49df12417026ea72cfd6eb0e237c5951c999a30a",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "443e831e536b756acbd1afd0d6bae7bc0d288048",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Akshobhya1234/agda-NonAssociativeAlgebra",
"max_forks_repo_path": "src/Quasigroup.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "443e831e536b756acbd1afd0d6bae7bc0d288048",
"max_issues_repo_issues_event_max_datetime": "2021-10-09T08:24:56.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-10-04T05:30:30.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Akshobhya1234/agda-NonAssociativeAlgebra",
"max_issues_repo_path": "src/Quasigroup.agda",
"max_line_length": 41,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "443e831e536b756acbd1afd0d6bae7bc0d288048",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Akshobhya1234/agda-NonAssociativeAlgebra",
"max_stars_repo_path": "src/Quasigroup.agda",
"max_stars_repo_stars_event_max_datetime": "2021-08-17T09:14:03.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-08-15T06:16:13.000Z",
"num_tokens": 42,
"size": 182
}
|
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
open import LibraBFT.Base.Types
import LibraBFT.Impl.Consensus.ConsensusTypes.VoteData as VoteData
open import LibraBFT.Impl.OBM.Logging.Logging
import LibraBFT.Impl.Types.LedgerInfoWithSignatures as LedgerInfoWithSignatures
open import LibraBFT.ImplShared.Base.Types
open import LibraBFT.ImplShared.Consensus.Types
open import Optics.All
open import Util.Hash
import Util.KVMap as Map
open import Util.Prelude
------------------------------------------------------------------------------
open import Data.String using (String)
module LibraBFT.Impl.Consensus.ConsensusTypes.QuorumCert where
certificateForGenesisFromLedgerInfo : LedgerInfo → HashValue → QuorumCert
certificateForGenesisFromLedgerInfo ledgerInfo genesisId =
let ancestor = BlockInfo∙new
(ledgerInfo ^∙ liEpoch + 1)
0
genesisId
(ledgerInfo ^∙ liTransactionAccumulatorHash)
(ledgerInfo ^∙ liVersion)
--(ledgerInfo ^∙ liTimestamp)
nothing
voteData = VoteData.new ancestor ancestor
li = LedgerInfo∙new ancestor (hashVD voteData)
in QuorumCert∙new
voteData
(LedgerInfoWithSignatures∙new li Map.empty)
verify : QuorumCert → ValidatorVerifier → Either ErrLog Unit
verify self validator = do
let voteHash = hashVD (self ^∙ qcVoteData)
lcheck (self ^∙ qcSignedLedgerInfo ∙ liwsLedgerInfo ∙ liConsensusDataHash == voteHash)
(here' ("Quorum Cert's hash mismatch LedgerInfo" ∷ []))
if (self ^∙ qcCertifiedBlock ∙ biRound == 0)
-- TODO-?: It would be nice not to require the parens around the do block
then (do
lcheck (self ^∙ qcParentBlock == self ^∙ qcCertifiedBlock)
(here' ("Genesis QC has inconsistent parent block with certified block" ∷ []))
lcheck (self ^∙ qcCertifiedBlock == self ^∙ qcLedgerInfo ∙ liwsLedgerInfo ∙ liCommitInfo)
(here' ("Genesis QC has inconsistent commit block with certified block" ∷ []))
lcheck (Map.kvm-size (self ^∙ qcLedgerInfo ∙ liwsSignatures) == 0)
(here' ("Genesis QC should not carry signatures" ∷ []))
)
else do
withErrCtx'
("fail to verify QuorumCert" ∷ [])
(LedgerInfoWithSignatures.verifySignatures (self ^∙ qcLedgerInfo) validator)
VoteData.verify (self ^∙ qcVoteData)
where
here' : List String → List String
here' t = "QuorumCert" ∷ "verify" {- ∷ lsQC self-} ∷ t
|
{
"alphanum_fraction": 0.6523620627,
"avg_line_length": 45.4590163934,
"ext": "agda",
"hexsha": "19cb581494bdcb594c7b4d11afe0ad2ae69b6342",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_forks_repo_licenses": [
"UPL-1.0"
],
"max_forks_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_forks_repo_path": "src/LibraBFT/Impl/Consensus/ConsensusTypes/QuorumCert.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"UPL-1.0"
],
"max_issues_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_issues_repo_path": "src/LibraBFT/Impl/Consensus/ConsensusTypes/QuorumCert.agda",
"max_line_length": 111,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_stars_repo_licenses": [
"UPL-1.0"
],
"max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_stars_repo_path": "src/LibraBFT/Impl/Consensus/ConsensusTypes/QuorumCert.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 725,
"size": 2773
}
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
{-
This file defines
deltaIntSec : ∀ b → toInt (fromInt b) ≡ b
succPred : ∀ n → succ (pred n) ≡ n
predSucc : ∀ n → pred (succ n) ≡ n
and proved DeltaInt ≡ DeltaInt by the above functions
succPredEq : DeltaInt ≡ DeltaInt
along with some interval-relevant lemmas
cancelDiamond : ∀ a b i → cancel a b i ≡ cancel (suc a) (suc b) i
cancelTriangle : ∀ a b i → a ⊖ b ≡ cancel a b i
we also have DeltaInt ≡ Int proof
DeltaInt≡Int : DeltaInt ≡ Int
and we transported some proofs from Int to DeltaInt
discreteDeltaInt : Discrete DeltaInt
isSetDeltaInt : isSet DeltaInt
-}
module Cubical.HITs.Ints.DeltaInt.Properties where
open import Cubical.Foundations.Everything
open import Cubical.Data.Nat hiding (zero)
open import Cubical.Data.Int hiding (abs; sgn; _+_)
open import Cubical.HITs.Ints.DeltaInt.Base
open import Cubical.Relation.Nullary using (Discrete)
deltaIntSec : ∀ b → toInt (fromInt b) ≡ b
deltaIntSec (pos n) = refl
deltaIntSec (negsuc n) = refl
cancelDiamond : ∀ a b i → cancel a b i ≡ cancel (suc a) (suc b) i
cancelDiamond a b i j = hcomp (λ k → λ
{ (i = i0) → cancel a b j
; (i = i1) → cancel (suc a) (suc b) (j ∧ k)
; (j = i0) → cancel a b i
; (j = i1) → cancel (suc a) (suc b) (i ∧ k)
}) (cancel a b (i ∨ j))
cancelTriangle : ∀ a b i → a ⊖ b ≡ cancel a b i
cancelTriangle a b i j = hcomp (λ k → λ
{ (i = i0) → a ⊖ b
; (j = i0) → a ⊖ b
; (j = i1) → cancel a b (i ∧ k)
}) (a ⊖ b)
deltaIntRet : ∀ a → fromInt (toInt a) ≡ a
deltaIntRet (x ⊖ 0) = refl
deltaIntRet (0 ⊖ suc y) = refl
deltaIntRet (suc x ⊖ suc y) = deltaIntRet (x ⊖ y) ∙ cancel x y
deltaIntRet (cancel a 0 i) = cancelTriangle a 0 i
deltaIntRet (cancel 0 (suc b) i) = cancelTriangle 0 (suc b) i
deltaIntRet (cancel (suc a) (suc b) i) = deltaIntRet (cancel a b i) ∙ cancelDiamond a b i
DeltaInt≡Int : DeltaInt ≡ Int
DeltaInt≡Int = isoToPath (iso toInt fromInt deltaIntSec deltaIntRet)
discreteDeltaInt : Discrete DeltaInt
discreteDeltaInt = subst Discrete (sym DeltaInt≡Int) discreteInt
isSetDeltaInt : isSet DeltaInt
isSetDeltaInt = subst isSet (sym DeltaInt≡Int) isSetInt
succPred : ∀ n → succ (pred n) ≡ n
succPred (x ⊖ y) i = cancel x y (~ i)
-- cancel (suc a) (suc b) i ≡ cancel a b i
succPred (cancel a b i) = sym (cancelDiamond a b i)
predSucc : ∀ n → pred (succ n) ≡ n
predSucc (x ⊖ y) = succPred (x ⊖ y)
predSucc (cancel a b i) = succPred (cancel a b i)
succPredEq : DeltaInt ≡ DeltaInt
succPredEq = isoToPath (iso succ pred succPred predSucc)
|
{
"alphanum_fraction": 0.6669319538,
"avg_line_length": 28.8850574713,
"ext": "agda",
"hexsha": "d223ed2796a249beb01b4bb414ed02a15389979a",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dan-iel-lee/cubical",
"max_forks_repo_path": "Cubical/HITs/Ints/DeltaInt/Properties.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "dan-iel-lee/cubical",
"max_issues_repo_path": "Cubical/HITs/Ints/DeltaInt/Properties.agda",
"max_line_length": 89,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "dan-iel-lee/cubical",
"max_stars_repo_path": "Cubical/HITs/Ints/DeltaInt/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 933,
"size": 2513
}
|
-- Andreas, 2017-03-08
-- Impredicative data types are incompatible with structural recursion
-- (Coquand, Pattern Matching with Dependent Types, 1992)
{-# OPTIONS --type-in-type #-}
data ⊥ : Set where
-- An impredicative data type
data D : Set where
c : (f : (A : Set) → A → A) → D
-- Structural recursion with f args < c f is no longer valid.
-- We should not be able to demonstrated that D is empty.
empty : D → ⊥
empty (c f) = empty (f D (c f))
-- This gets us to absurdity quickly:
inhabited : D
inhabited = c λ A x → x
absurd : ⊥
absurd = empty inhabited
|
{
"alphanum_fraction": 0.6637630662,
"avg_line_length": 21.2592592593,
"ext": "agda",
"hexsha": "cd2a325fc66a4196f349b76e848700b66b961f5b",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Succeed/ImpredicativeData.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Succeed/ImpredicativeData.agda",
"max_line_length": 70,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/ImpredicativeData.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 177,
"size": 574
}
|
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2020 Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
{-# OPTIONS --allow-unsolved-metas #-}
open import Optics.All
open import LibraBFT.Lemmas
open import LibraBFT.Prelude
open import LibraBFT.Base.PKCS
open import LibraBFT.Impl.Consensus.Types
open import LibraBFT.Impl.NetworkMsg
open import LibraBFT.Impl.Util.Crypto
open import LibraBFT.Impl.Properties.Aux
open import LibraBFT.Concrete.System impl-sps-avp
open import LibraBFT.Concrete.System.Parameters
import LibraBFT.Concrete.Properties.VotesOnce as VO
open import LibraBFT.Yasm.AvailableEpochs
open import LibraBFT.Yasm.Base
open import LibraBFT.Yasm.System ConcSysParms
open import LibraBFT.Yasm.Properties ConcSysParms
open Structural impl-sps-avp
open import LibraBFT.Concrete.Obligations
-- In this module, we (will) prove the two implementation obligations for the VotesOnce rule. Note
-- that it is not yet 100% clear that the obligations are the best definitions to use. See comments
-- in Concrete.VotesOnce. We will want to prove these obligations for the fake/simple
-- implementation (or some variant on it) and streamline the proof before we proceed to tacke more
-- ambitious properties.
module LibraBFT.Impl.Properties.VotesOnce where
postulate -- TODO-3 : prove
vo₁ : VO.ImplObligation₁
vo₂ : VO.ImplObligation₂
|
{
"alphanum_fraction": 0.7915287889,
"avg_line_length": 37.775,
"ext": "agda",
"hexsha": "d7f6764c727333e70c95c403203f73e5dbfad945",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "b7dd98dd90d98fbb934ef8cb4f3314940986790d",
"max_forks_repo_licenses": [
"UPL-1.0"
],
"max_forks_repo_name": "lisandrasilva/bft-consensus-agda-1",
"max_forks_repo_path": "LibraBFT/Impl/Properties/VotesOnce.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b7dd98dd90d98fbb934ef8cb4f3314940986790d",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"UPL-1.0"
],
"max_issues_repo_name": "lisandrasilva/bft-consensus-agda-1",
"max_issues_repo_path": "LibraBFT/Impl/Properties/VotesOnce.agda",
"max_line_length": 111,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "b7dd98dd90d98fbb934ef8cb4f3314940986790d",
"max_stars_repo_licenses": [
"UPL-1.0"
],
"max_stars_repo_name": "lisandrasilva/bft-consensus-agda-1",
"max_stars_repo_path": "LibraBFT/Impl/Properties/VotesOnce.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 409,
"size": 1511
}
|
{-
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-θ⟩))
|
{
"alphanum_fraction": 0.533453726,
"avg_line_length": 57.218616567,
"ext": "agda",
"hexsha": "cb25daa96908fe0feac180d21db72a56391b45e8",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2020-04-15T20:02:49.000Z",
"max_forks_repo_forks_event_min_datetime": "2020-04-15T20:02:49.000Z",
"max_forks_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "florence/esterel-calculus",
"max_forks_repo_path": "agda/Esterel/Lang/CanFunction/CanThetaContinuation.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "florence/esterel-calculus",
"max_issues_repo_path": "agda/Esterel/Lang/CanFunction/CanThetaContinuation.agda",
"max_line_length": 251,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "florence/esterel-calculus",
"max_stars_repo_path": "agda/Esterel/Lang/CanFunction/CanThetaContinuation.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-01T03:59:31.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-16T10:58:53.000Z",
"num_tokens": 32042,
"size": 67003
}
|
module Structure.Relator.Apartness where
import Lvl
open import Logic
open import Logic.Propositional
open import Structure.Relator.Properties
hiding (irreflexivity ; symmetry ; cotransitivity)
open import Type
private variable ℓ₁ ℓ₂ : Lvl.Level
-- An apartness relation is a irreflexive, symmetric and cotransitive relation.
record Apartness {T : Type{ℓ₁}} (_#_ : T → T → Stmt{ℓ₂}) : Stmt{ℓ₁ Lvl.⊔ ℓ₂} where
instance constructor intro
field
instance ⦃ irreflexivity ⦄ : Irreflexivity (_#_)
instance ⦃ symmetry ⦄ : Symmetry (_#_)
instance ⦃ cotransitivity ⦄ : CoTransitivity (_#_)
|
{
"alphanum_fraction": 0.7214170692,
"avg_line_length": 32.6842105263,
"ext": "agda",
"hexsha": "4c0e14df27686c2422263276ee632222b7d8a3a5",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Structure/Relator/Apartness.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Structure/Relator/Apartness.agda",
"max_line_length": 82,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Structure/Relator/Apartness.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z",
"num_tokens": 191,
"size": 621
}
|
module Issue852 where
open import Common.Level
const : ∀ {a b} {A : Set a} {B : Set b} → A → B → A
const x = λ _ → x
ℓ : Level
ℓ = const lzero (Set ℓ)
ℓ′ : Level
ℓ′ = const lzero (Set ℓ′)
-- Error message using Agda 2.3.2 (the batch-mode command, not the
-- Emacs interface):
--
-- Termination checking failed for the following functions:
-- ℓ, ℓ′
-- Problematic calls:
-- ℓ
-- ℓ (at [...])
-- ℓ′
-- ℓ′
-- (at [...])
--
-- With the current development version of Agda:
--
-- Termination checking failed for the following functions:
-- ℓ, ℓ′
-- Problematic calls:
-- ℓ
-- ℓ (at [...])
-- ℓ′
-- (at [...])
|
{
"alphanum_fraction": 0.5428571429,
"avg_line_length": 19,
"ext": "agda",
"hexsha": "715ff74b94a5da700bf231bff52a773a488d6b20",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "test/fail/Issue852.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "test/fail/Issue852.agda",
"max_line_length": 66,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "redfish64/autonomic-agda",
"max_stars_repo_path": "test/Fail/Issue852.agda",
"max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z",
"num_tokens": 225,
"size": 665
}
|
open import IO using ( run ; putStrLn )
open import Data.String using ( _++_ )
open import Data.Natural using ( # ; _+_ ; toString )
module Data.Bindings.Examples.HelloFour where
main = run (putStrLn ("Hello, " ++ toString (#(2) + #(2)) ++ "."))
|
{
"alphanum_fraction": 0.6518218623,
"avg_line_length": 35.2857142857,
"ext": "agda",
"hexsha": "4f515aacb5164a7b9fd42c049d9520aa32c7aed8",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:14.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:40:14.000Z",
"max_forks_repo_head_hexsha": "84d51967e20bf248e9f73af37f52972922ffc77c",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "agda/agda-data-bindings",
"max_forks_repo_path": "src/Data/Bindings/Examples/HelloFour.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "84d51967e20bf248e9f73af37f52972922ffc77c",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "agda/agda-data-bindings",
"max_issues_repo_path": "src/Data/Bindings/Examples/HelloFour.agda",
"max_line_length": 66,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "84d51967e20bf248e9f73af37f52972922ffc77c",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "agda/agda-data-bindings",
"max_stars_repo_path": "src/Data/Bindings/Examples/HelloFour.agda",
"max_stars_repo_stars_event_max_datetime": "2019-10-24T13:51:16.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-08-02T23:17:59.000Z",
"num_tokens": 67,
"size": 247
}
|
-- Import all the material (useful to check that everything typechecks)
{-# OPTIONS --cubical #-}
module Everything where
import Warmup
import Part1
import Part2
import Part3
import Part4
import ExerciseSession1
import ExerciseSession2
import ExerciseSession3
|
{
"alphanum_fraction": 0.8199233716,
"avg_line_length": 20.0769230769,
"ext": "agda",
"hexsha": "60ffe71eebbf5870e0bc0cac4b4e206c44bbc939",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "9a510959fb0e6da9bcc6b0faa0dea76a2821bbdb",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "EgbertRijke/EPIT-2020",
"max_forks_repo_path": "04-cubical-type-theory/material/Everything.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9a510959fb0e6da9bcc6b0faa0dea76a2821bbdb",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "EgbertRijke/EPIT-2020",
"max_issues_repo_path": "04-cubical-type-theory/material/Everything.agda",
"max_line_length": 71,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "34742c0409818f8fe581ffc92992d1b5f29f6b47",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bafain/EPIT-2020",
"max_stars_repo_path": "04-cubical-type-theory/material/Everything.agda",
"max_stars_repo_stars_event_max_datetime": "2021-04-03T16:28:06.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-04-03T16:28:06.000Z",
"num_tokens": 61,
"size": 261
}
|
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import cw.CW
module cw.examples.Unit where
cw-unit-skel : Skeleton {lzero} 0
cw-unit-skel = Unit , Unit-is-set
CWUnit = ⟦ cw-unit-skel ⟧
CWUnit-equiv-Unit : CWUnit ≃ Unit
CWUnit-equiv-Unit = ide _
|
{
"alphanum_fraction": 0.6996197719,
"avg_line_length": 18.7857142857,
"ext": "agda",
"hexsha": "15cf4335f00955082b1e90d6ad79210f378b61bc",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z",
"max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mikeshulman/HoTT-Agda",
"max_forks_repo_path": "theorems/cw/examples/Unit.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "mikeshulman/HoTT-Agda",
"max_issues_repo_path": "theorems/cw/examples/Unit.agda",
"max_line_length": 39,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mikeshulman/HoTT-Agda",
"max_stars_repo_path": "theorems/cw/examples/Unit.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 82,
"size": 263
}
|
{-# 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)
|
{
"alphanum_fraction": 0.5354931903,
"avg_line_length": 32.7432432432,
"ext": "agda",
"hexsha": "0bd8d8bab6d69824c787510726b0ed9181ac50bc",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Schippmunk/cubical",
"max_forks_repo_path": "Cubical/DStructures/Structures/ReflGraph.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Schippmunk/cubical",
"max_issues_repo_path": "Cubical/DStructures/Structures/ReflGraph.agda",
"max_line_length": 95,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Schippmunk/cubical",
"max_stars_repo_path": "Cubical/DStructures/Structures/ReflGraph.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1729,
"size": 4846
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Floating point numbers
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Float where
------------------------------------------------------------------------
-- Re-export base definitions and decidability of equality
open import Data.Float.Base public
open import Data.Float.Properties using (_≈?_; _<?_; _≟_; _==_) public
|
{
"alphanum_fraction": 0.4079207921,
"avg_line_length": 31.5625,
"ext": "agda",
"hexsha": "dfd189623a5c0576f77442754a644a79e7b9e8bb",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DreamLinuxer/popl21-artifact",
"max_forks_repo_path": "agda-stdlib/src/Data/Float.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DreamLinuxer/popl21-artifact",
"max_issues_repo_path": "agda-stdlib/src/Data/Float.agda",
"max_line_length": 72,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DreamLinuxer/popl21-artifact",
"max_stars_repo_path": "agda-stdlib/src/Data/Float.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z",
"num_tokens": 73,
"size": 505
}
|
{-# 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
|
{
"alphanum_fraction": 0.5160532498,
"avg_line_length": 26.6041666667,
"ext": "agda",
"hexsha": "2348ff954ff9791a18a3e73feb7b8fd739c84b7b",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934",
"max_forks_repo_licenses": [
"CC-BY-4.0"
],
"max_forks_repo_name": "hemangandhi/HoTT-Intro",
"max_forks_repo_path": "Agda/univalent-hott/1-type-theory.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"CC-BY-4.0"
],
"max_issues_repo_name": "hemangandhi/HoTT-Intro",
"max_issues_repo_path": "Agda/univalent-hott/1-type-theory.agda",
"max_line_length": 84,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934",
"max_stars_repo_licenses": [
"CC-BY-4.0"
],
"max_stars_repo_name": "hemangandhi/HoTT-Intro",
"max_stars_repo_path": "Agda/univalent-hott/1-type-theory.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 579,
"size": 1277
}
|
{-# OPTIONS --universe-polymorphism #-}
module Categories.Lan where
open import Level
open import Categories.Category
open import Categories.Functor hiding (_≡_)
open import Categories.NaturalTransformation
record Lan {o₀ ℓ₀ e₀} {o₁ ℓ₁ e₁} {o₂ ℓ₂ e₂}
{A : Category o₀ ℓ₀ e₀} {B : Category o₁ ℓ₁ e₁} {C : Category o₂ ℓ₂ e₂}
(F : Functor A B) (X : Functor A C) : Set (o₀ ⊔ ℓ₀ ⊔ e₀ ⊔ o₁ ⊔ ℓ₁ ⊔ e₁ ⊔ o₂ ⊔ ℓ₂ ⊔ e₂) where
field
L : Functor B C
ε : NaturalTransformation X (L ∘ F)
σ : (M : Functor B C) → (α : NaturalTransformation X (M ∘ F)) → NaturalTransformation L M
.σ-unique : {M : Functor B C} → {α : NaturalTransformation X (M ∘ F)} →
(σ′ : NaturalTransformation L M) → α ≡ (σ′ ∘ʳ F) ∘₁ ε → σ′ ≡ σ M α
.commutes : (M : Functor B C) → (α : NaturalTransformation X (M ∘ F)) → α ≡ (σ M α ∘ʳ F) ∘₁ ε
|
{
"alphanum_fraction": 0.5955967555,
"avg_line_length": 41.0952380952,
"ext": "agda",
"hexsha": "59156249d15f2b8fefa2bfb9520215d6565520a1",
"lang": "Agda",
"max_forks_count": 23,
"max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z",
"max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "p-pavel/categories",
"max_forks_repo_path": "Categories/Lan.agda",
"max_issues_count": 19,
"max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2",
"max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "p-pavel/categories",
"max_issues_repo_path": "Categories/Lan.agda",
"max_line_length": 103,
"max_stars_count": 98,
"max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "copumpkin/categories",
"max_stars_repo_path": "Categories/Lan.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z",
"num_tokens": 326,
"size": 863
}
|
open import FRP.JS.Bool using ( Bool ; not )
open import FRP.JS.Event using ( Evt ; accumBy )
open import FRP.JS.RSet using ( RSet ; _⇒_ ; ⟦_⟧ ; ⟨_⟩ )
module FRP.JS.Behaviour where
postulate
Beh : RSet → RSet
map : ∀ {A B} → ⟦ A ⇒ B ⟧ → ⟦ Beh A ⇒ Beh B ⟧
map2 : ∀ {A B C} → ⟦ A ⇒ B ⇒ C ⟧ → ⟦ Beh A ⇒ Beh B ⇒ Beh C ⟧
[_] : ∀ {A} → A → ⟦ Beh ⟨ A ⟩ ⟧
join : ∀ {A} → ⟦ Beh (Beh A) ⇒ Beh A ⟧
hold : ∀ {A} → ⟦ ⟨ A ⟩ ⇒ Evt ⟨ A ⟩ ⇒ Beh ⟨ A ⟩ ⟧
{-# COMPILED_JS map function(A) { return function(B) {
return function(f) { return function(s) { return function(b) {
return b.map(function (t,v) { return f(t)(v); });
}; }; };
}; } #-}
{-# COMPILED_JS map2 function(A) { return function(B) { return function(C) {
return function(f) { return function(s) { return function(a) { return function(b) {
return a.map2(b, function (t,v1,v2) { return f(t)(v1)(v2); });
}; }; }; };
}; }; } #-}
{-# COMPILED_JS [_] function(A) { return function(a) { return function(s) {
return require("agda.frp").constant(a);
}; }; } #-}
{-# COMPILED_JS join function(A) { return function(s) { return function(b) {
return b.join();
}; }; } #-}
{-# COMPILED_JS hold function(A) { return function(s) { return function(a) { return function(e) {
return e.hold(a);
}; }; }; } #-}
accumHoldBy : ∀ {A B} → ⟦ (⟨ B ⟩ ⇒ A ⇒ ⟨ B ⟩) ⟧ → B → ⟦ Evt A ⇒ Beh ⟨ B ⟩ ⟧
accumHoldBy f b σ = hold b (accumBy f b σ)
not* : ⟦ Beh ⟨ Bool ⟩ ⇒ Beh ⟨ Bool ⟩ ⟧
not* = map not
|
{
"alphanum_fraction": 0.5398351648,
"avg_line_length": 33.0909090909,
"ext": "agda",
"hexsha": "538ff1bd41f5ae03c10f836413e5f1943322c3e5",
"lang": "Agda",
"max_forks_count": 7,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-11-07T21:50:58.000Z",
"max_forks_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72",
"max_forks_repo_licenses": [
"MIT",
"BSD-3-Clause"
],
"max_forks_repo_name": "agda/agda-frp-js",
"max_forks_repo_path": "src/agda/FRP/JS/Behaviour.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT",
"BSD-3-Clause"
],
"max_issues_repo_name": "agda/agda-frp-js",
"max_issues_repo_path": "src/agda/FRP/JS/Behaviour.agda",
"max_line_length": 97,
"max_stars_count": 63,
"max_stars_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72",
"max_stars_repo_licenses": [
"MIT",
"BSD-3-Clause"
],
"max_stars_repo_name": "agda/agda-frp-js",
"max_stars_repo_path": "src/agda/FRP/JS/Behaviour.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-28T09:46:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-20T21:47:00.000Z",
"num_tokens": 540,
"size": 1456
}
|
module Records where
open import Common.Nat
open import Common.IO
open import Common.Unit
record Test : Set where
constructor mkTest
field
a b c : Nat
f : Test -> Nat
f (mkTest a b c) = a + b + c
open Test
g : Nat
g = (f (mkTest 34 12 54)) + (f (record {a = 100; b = 120; c = 140})) + a m + b m + c m
where m = mkTest 200 300 400
main : IO Unit
main = printNat g
|
{
"alphanum_fraction": 0.6253298153,
"avg_line_length": 16.4782608696,
"ext": "agda",
"hexsha": "07bf7bb0186578ce8e71a679894f1ebaacd08f10",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Compiler/simple/Records.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Compiler/simple/Records.agda",
"max_line_length": 86,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Compiler/simple/Records.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 138,
"size": 379
}
|
------------------------------------------------------------------------
-- A depth-first backend
------------------------------------------------------------------------
-- Based on the parser combinators in Wadler's "How to Replace Failure
-- by a List of Successes".
module StructurallyRecursiveDescentParsing.DepthFirst where
open import Data.Bool
open import Data.Product as Prod
import Data.List as L; open L using (List)
import Data.List.Categorical
open import Data.Nat
open import Data.Nat.Properties
open import Data.Vec using ([]; _∷_)
open import Data.Vec.Bounded hiding ([]; _∷_)
open import Function
open import Category.Applicative.Indexed
open import Category.Monad.Indexed
open import Category.Monad.State
open import Codata.Musical.Notation
import Level
open import StructurallyRecursiveDescentParsing.Simplified
------------------------------------------------------------------------
-- Parser monad
private
P : Set → IFun ℕ Level.zero
P Tok = IStateT (Vec≤ Tok) List
open module M₁ {Tok : Set} =
RawIMonadPlus (StateTIMonadPlus (Vec≤ Tok)
Data.List.Categorical.monadPlus)
using ()
renaming ( return to return′
; _>>=_ to _>>=′_
; _>>_ to _>>′_
; ∅ to fail′
; _∣_ to _∣′_
)
open module M₂ {Tok : Set} =
RawIMonadState (StateTIMonadState (Vec≤ Tok)
Data.List.Categorical.monad)
using ()
renaming ( get to get′
; put to put′
; modify to modify′
)
------------------------------------------------------------------------
-- Run function for the parsers
-- For every successful parse the run function returns the remaining
-- string. (Since there can be several successful parses a list of
-- strings is returned.)
-- This function is structurally recursive with respect to the
-- following lexicographic measure:
--
-- 1) The upper bound of the length of the input string.
-- 2) The parser's proper left corner tree.
mutual
parse↓ : ∀ {Tok e R} n → Parser Tok e R →
P Tok n (if e then n else n ∸ 1) R
parse↓ n (return x) = return′ x
parse↓ n fail = fail′
parse↓ n (_∣_ {true} p₁ p₂) = parse↓ n p₁ ∣′ parse↑ n p₂
parse↓ n (_∣_ {false} {true} p₁ p₂) = parse↑ n p₁ ∣′ parse↓ n p₂
parse↓ n (_∣_ {false} {false} p₁ p₂) = parse↓ n p₁ ∣′ parse↓ n p₂
parse↓ n (p₁ ?>>= p₂) = parse↓ n p₁ >>=′ λ x → parse↓ n (p₂ x)
parse↓ zero (p₁ !>>= p₂) = fail′
parse↓ (suc n) (p₁ !>>= p₂) = parse↓ (suc n) p₁ >>=′ λ x → parse↑ n (♭ (p₂ x))
parse↓ n token = get′ >>=′ eat
where
eat : ∀ {Tok n} → Vec≤ Tok n → P Tok n (n ∸ 1) Tok
eat ([] , _) = fail′
eat s@(c ∷ _ , _) = put′ (drop 1 s) >>′ return′ c
parse↑ : ∀ {e Tok R} n → Parser Tok e R → P Tok n n R
parse↑ {true} n p = parse↓ n p
parse↑ {false} zero p = fail′
parse↑ {false} (suc n) p = parse↓ (suc n) p >>=′ λ r →
modify′ (≤-cast (n≤1+n _)) >>′
return′ r
-- Exported run function.
parse : ∀ {Tok i R} → Parser Tok i R → List Tok → List (R × List Tok)
parse p s = L.map (Prod.map id toList) (parse↓ _ p (fromList s))
-- A variant which only returns parses which leave no remaining input.
parseComplete : ∀ {Tok i R} → Parser Tok i R → List Tok → List R
parseComplete p s =
L.map proj₁ (L.boolFilter (L.null ∘ proj₂) (parse p s))
|
{
"alphanum_fraction": 0.5138091332,
"avg_line_length": 35.8529411765,
"ext": "agda",
"hexsha": "aa24259155412ec0a14dd2d9b9f847270d07c0b1",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/parser-combinators",
"max_forks_repo_path": "StructurallyRecursiveDescentParsing/DepthFirst.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/parser-combinators",
"max_issues_repo_path": "StructurallyRecursiveDescentParsing/DepthFirst.agda",
"max_line_length": 95,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/parser-combinators",
"max_stars_repo_path": "StructurallyRecursiveDescentParsing/DepthFirst.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:13.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-07-03T08:56:13.000Z",
"num_tokens": 1026,
"size": 3657
}
|
------------------------------------------------------------------------------
-- Arithmetic properties using instances of the induction principle
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOT.FOTC.Data.Nat.Induction.AdditionalHypothesis.Instances.PropertiesATP
where
open import FOTC.Base
open import FOTC.Data.Nat hiding ( N-ind )
------------------------------------------------------------------------------
-- Induction principle with the additional hypothesis.
N-ind₁ : (A : D → Set) →
A zero →
(∀ {n} → N n → A n → A (succ₁ n)) →
∀ {n} → N n → A n
N-ind₁ A A0 h nzero = A0
N-ind₁ A A0 h (nsucc Nn) = h Nn (N-ind₁ A A0 h Nn)
-- From now on we will use the N-ind₁ induction principle.
N-ind = N-ind₁
------------------------------------------------------------------------------
-- Totality properties
pred-N-ind-instance :
N (pred₁ zero) →
(∀ {n} → N n → N (pred₁ n) → N (pred₁ (succ₁ n))) →
∀ {n} → N n → N (pred₁ n)
pred-N-ind-instance = N-ind₁ (λ i → N (pred₁ i))
postulate pred-N : ∀ {n} → N n → N (pred₁ n)
{-# ATP prove pred-N pred-N-ind-instance #-}
+-N-ind-instance :
∀ {n} →
N (zero + n) →
(∀ {m} → N m → N (m + n) → N (succ₁ m + n)) →
∀ {m} → N m → N (m + n)
+-N-ind-instance {n} = N-ind (λ i → N (i + n))
postulate +-N : ∀ {m n} → N m → N n → N (m + n)
{-# ATP prove +-N +-N-ind-instance #-}
∸-N-ind-instance :
∀ {m} →
N (m ∸ zero) →
(∀ {n} → N n → N (m ∸ n) → N (m ∸ succ₁ n)) →
∀ {n} → N n → N (m ∸ n)
∸-N-ind-instance {n} = N-ind (λ i → N (n ∸ i))
postulate ∸-N : ∀ {m n} → N m → N n → N (m ∸ n)
{-# ATP prove ∸-N ∸-N-ind-instance pred-N #-}
*-N-ind-instance :
∀ {n} →
N (zero * n) →
(∀ {m} → N m → N (m * n) → N (succ₁ m * n)) →
∀ {m} → N m → N (m * n)
*-N-ind-instance {n} = N-ind (λ i → N (i * n))
postulate *-N : ∀ {m n} → N m → N n → N (m * n)
{-# ATP prove *-N *-N-ind-instance +-N #-}
+-rightIdentity-ind-instance :
zero + zero ≡ zero →
(∀ {n} → N n → n + zero ≡ n → succ₁ n + zero ≡ succ₁ n) →
∀ {n} → N n → n + zero ≡ n
+-rightIdentity-ind-instance = N-ind (λ i → i + zero ≡ i)
postulate +-rightIdentity : ∀ {n} → N n → n + zero ≡ n
{-# ATP prove +-rightIdentity +-rightIdentity-ind-instance #-}
+-assoc-ind-instance :
∀ {n} {o} →
zero + n + o ≡ zero + (n + o) →
(∀ {m} → N m →
m + n + o ≡ m + (n + o) → succ₁ m + n + o ≡ succ₁ m + (n + o)) →
∀ {m} → N m → m + n + o ≡ m + (n + o)
+-assoc-ind-instance {n} {o} = N-ind (λ i → i + n + o ≡ i + (n + o))
postulate +-assoc : ∀ {m} → N m → ∀ n o → m + n + o ≡ m + (n + o)
{-# ATP prove +-assoc +-assoc-ind-instance #-}
x+Sy≡S[x+y]-ind-instance :
∀ {n} →
zero + succ₁ n ≡ succ₁ (zero + n) →
(∀ {m} → N m →
m + succ₁ n ≡ succ₁ (m + n) → succ₁ m + succ₁ n ≡ succ₁ (succ₁ m + n)) →
∀ {m} → N m → m + succ₁ n ≡ succ₁ (m + n)
x+Sy≡S[x+y]-ind-instance {n} = N-ind (λ i → i + succ₁ n ≡ succ₁ (i + n))
postulate x+Sy≡S[x+y] : ∀ {m} → N m → ∀ n → m + succ₁ n ≡ succ₁ (m + n)
{-# ATP prove x+Sy≡S[x+y] x+Sy≡S[x+y]-ind-instance #-}
+-comm-ind-instance :
∀ {n} →
zero + n ≡ n + zero →
(∀ {m} → N m → m + n ≡ n + m → succ₁ m + n ≡ n + succ₁ m) →
∀ {m} → N m → m + n ≡ n + m
+-comm-ind-instance {n} = N-ind (λ i → i + n ≡ n + i)
postulate +-comm : ∀ {m n} → N m → N n → m + n ≡ n + m
{-# ATP prove +-comm +-comm-ind-instance +-rightIdentity x+Sy≡S[x+y] #-}
|
{
"alphanum_fraction": 0.4451631046,
"avg_line_length": 32.036036036,
"ext": "agda",
"hexsha": "993adf66f26973cfa4e8dfbc87995408c8ba7018",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z",
"max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/fotc",
"max_forks_repo_path": "notes/FOT/FOTC/Data/Nat/Induction/AdditionalHypothesis/Instances/PropertiesATP.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/fotc",
"max_issues_repo_path": "notes/FOT/FOTC/Data/Nat/Induction/AdditionalHypothesis/Instances/PropertiesATP.agda",
"max_line_length": 79,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "notes/FOT/FOTC/Data/Nat/Induction/AdditionalHypothesis/Instances/PropertiesATP.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z",
"num_tokens": 1334,
"size": 3556
}
|
postulate
A : Set
data B (a : A) : Set where
conB : B a → B a → B a
data C (a : A) : B a → Set where
conC : {bl br : B a} → C a bl → C a br → C a (conB bl br)
-- Second bug, likely same as first bug.
{-
An internal error has occurred. Please report this as a bug.
Location of the error: src/full/Agda/TypeChecking/Abstract.hs:133
-}
data F : Set where
conF : F
boo : (a : A) (b : B a) (c : C a _) → Set
boo a b (conC tl tr) with tr | conF
... | _ | _ = _
|
{
"alphanum_fraction": 0.5845824411,
"avg_line_length": 22.2380952381,
"ext": "agda",
"hexsha": "b2f84a080ea6f061d0ade4bdaf8a423fee815d7b",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/Issue2679b.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Fail/Issue2679b.agda",
"max_line_length": 65,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/Issue2679b.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 176,
"size": 467
}
|
------------------------------------------------------------------------
-- CCS
------------------------------------------------------------------------
{-# OPTIONS --sized-types #-}
open import Prelude
module Labelled-transition-system.CCS {ℓ} (Name : Type ℓ) where
open import Equality.Propositional
open import Prelude.Size
open import Bool equality-with-J
open import Function-universe equality-with-J hiding (id; _∘_)
open import Labelled-transition-system
------------------------------------------------------------------------
-- Fixity declarations
infix 12 _∙
infixr 12 _·_ _∙_
infix 10 !_
infix 8 _⊕_
infix 6 _∣_
infix 5 _[_] _[_]′
infix 4 _[_]⟶_ _∉_
------------------------------------------------------------------------
-- CCS, roughly as defined in "Enhancements of the bisimulation proof
-- method" by Pous and Sangiorgi, with support for corecursive
-- processes (instead of the named process constants presented in
-- "Coinduction All the Way Up" by Pous)
-- Names with kinds: (a , true) stands for "a", and (a , false) stands
-- for "a̅".
Name-with-kind : Type ℓ
Name-with-kind = Name × Bool
-- Turns names of one kind into names of the other kind.
co : Name-with-kind → Name-with-kind
co (a , kind) = a , not kind
-- Actions.
data Action : Type ℓ where
name : Name-with-kind → Action
τ : Action
-- The only silent action is τ.
is-silent : Action → Bool
is-silent (name _) = false
is-silent τ = true
-- Processes.
mutual
data Proc (i : Size) : Type ℓ where
∅ : Proc i
_∣_ _⊕_ : Proc i → Proc i → Proc i
_·_ : Action → Proc′ i → Proc i
⟨ν_⟩ : Name → Proc i → Proc i
!_ : Proc i → Proc i
record Proc′ (i : Size) : Type ℓ where
coinductive
field
force : {j : Size< i} → Proc j
open Proc′ public
-- An inductive variant of _·_.
_∙_ : ∀ {i} → Action → Proc i → Proc i
μ ∙ P = μ · λ { .force → P }
-- An abbreviation.
_∙ : Name-with-kind → Proc ∞
a ∙ = name a ∙ ∅
-- The predicate a ∉ μ holds if a is not the underlying name of μ (if
-- any).
_∉_ : Name → Action → Type ℓ
a ∉ name (b , _) = ¬ a ≡ b
a ∉ τ = ↑ ℓ ⊤
-- Transition relation.
data _[_]⟶_ : Proc ∞ → Action → Proc ∞ → Type ℓ where
par-left : ∀ {P Q P′ μ} → P [ μ ]⟶ P′ → P ∣ Q [ μ ]⟶ P′ ∣ Q
par-right : ∀ {P Q Q′ μ} → Q [ μ ]⟶ Q′ → P ∣ Q [ μ ]⟶ P ∣ Q′
par-τ : ∀ {P P′ Q Q′ a} →
P [ name a ]⟶ P′ → Q [ name (co a) ]⟶ Q′ →
P ∣ Q [ τ ]⟶ P′ ∣ Q′
sum-left : ∀ {P Q P′ μ} → P [ μ ]⟶ P′ → P ⊕ Q [ μ ]⟶ P′
sum-right : ∀ {P Q Q′ μ} → Q [ μ ]⟶ Q′ → P ⊕ Q [ μ ]⟶ Q′
action : ∀ {P μ} → μ · P [ μ ]⟶ force P
restriction : ∀ {P P′ a μ} →
a ∉ μ → P [ μ ]⟶ P′ → ⟨ν a ⟩ P [ μ ]⟶ ⟨ν a ⟩ P′
replication : ∀ {P P′ μ} → ! P ∣ P [ μ ]⟶ P′ → ! P [ μ ]⟶ P′
-- The CCS LTS.
CCS : LTS ℓ
CCS = record
{ Proc = Proc ∞
; Label = Action
; _[_]⟶_ = _[_]⟶_
; is-silent = is-silent
}
open LTS CCS public hiding (Proc; _[_]⟶_; is-silent)
------------------------------------------------------------------------
-- Contexts and some related definitions, roughly following
-- "Enhancements of the bisimulation proof method" by Pous and
-- Sangiorgi
mutual
-- Polyadic contexts.
data Context (i : Size) (n : ℕ) : Type ℓ where
hole : (x : Fin n) → Context i n
∅ : Context i n
_∣_ _⊕_ : Context i n → Context i n → Context i n
_·_ : (μ : Action) → Context′ i n → Context i n
⟨ν_⟩ : (a : Name) → Context i n → Context i n
!_ : Context i n → Context i n
record Context′ (i : Size) (n : ℕ) : Type ℓ where
coinductive
field
force : {j : Size< i} → Context j n
open Context′ public
mutual
-- Hole filling.
_[_] : ∀ {i n} → Context i n → (Fin n → Proc ∞) → Proc i
hole x [ Ps ] = Ps x
∅ [ Ps ] = ∅
C₁ ∣ C₂ [ Ps ] = (C₁ [ Ps ]) ∣ (C₂ [ Ps ])
C₁ ⊕ C₂ [ Ps ] = (C₁ [ Ps ]) ⊕ (C₂ [ Ps ])
μ · C [ Ps ] = μ · (C [ Ps ]′)
⟨ν a ⟩ C [ Ps ] = ⟨ν a ⟩ (C [ Ps ])
! C [ Ps ] = ! (C [ Ps ])
_[_]′ : ∀ {i n} → Context′ i n → (Fin n → Proc ∞) → Proc′ i
force (C [ Ps ]′) = force C [ Ps ]
-- A context is weakly guarded if every hole is under a prefix (μ ·_).
data Weakly-guarded {n : ℕ} : Context ∞ n → Type ℓ where
∅ : Weakly-guarded ∅
_∣_ : ∀ {C₁ C₂} →
Weakly-guarded C₁ → Weakly-guarded C₂ →
Weakly-guarded (C₁ ∣ C₂)
_⊕_ : ∀ {C₁ C₂} →
Weakly-guarded C₁ → Weakly-guarded C₂ →
Weakly-guarded (C₁ ⊕ C₂)
action : ∀ {μ C} → Weakly-guarded (μ · C)
⟨ν⟩ : ∀ {a C} → Weakly-guarded C → Weakly-guarded (⟨ν a ⟩ C)
!_ : ∀ {C} → Weakly-guarded C → Weakly-guarded (! C)
-- Turns processes into contexts without holes.
context : ∀ {i n} → Proc i → Context i n
context ∅ = ∅
context (P₁ ∣ P₂) = context P₁ ∣ context P₂
context (P₁ ⊕ P₂) = context P₁ ⊕ context P₂
context (μ · P) = μ · λ { .force → context (force P) }
context (⟨ν a ⟩ P) = ⟨ν a ⟩ (context P)
context (! P) = ! context P
-- Non-degenerate contexts.
mutual
data Non-degenerate (i : Size) {n : ℕ} : Context ∞ n → Type ℓ where
hole : ∀ {x} → Non-degenerate i (hole x)
∅ : Non-degenerate i ∅
_∣_ : ∀ {C₁ C₂} →
Non-degenerate i C₁ → Non-degenerate i C₂ →
Non-degenerate i (C₁ ∣ C₂)
_⊕_ : ∀ {C₁ C₂} →
Non-degenerate-summand i C₁ →
Non-degenerate-summand i C₂ →
Non-degenerate i (C₁ ⊕ C₂)
action : ∀ {μ C} →
Non-degenerate′ i (force C) → Non-degenerate i (μ · C)
⟨ν⟩ : ∀ {a C} → Non-degenerate i C → Non-degenerate i (⟨ν a ⟩ C)
!_ : ∀ {C} → Non-degenerate i C → Non-degenerate i (! C)
data Non-degenerate-summand (i : Size) {n : ℕ} :
Context ∞ n → Type ℓ where
process : ∀ P → Non-degenerate-summand i (context P)
action : ∀ {μ C} →
Non-degenerate′ i (force C) →
Non-degenerate-summand i (μ · C)
record Non-degenerate′ (i : Size) {n} (C : Context ∞ n) : Type ℓ where
coinductive
field
force : {j : Size< i} → Non-degenerate j C
open Non-degenerate′ public
------------------------------------------------------------------------
-- Very strong bisimilarity
-- "Very strong" bisimilarity for processes: Equal ∞ P Q means that P
-- and Q have the same structure.
mutual
data Equal (i : Size) : Proc ∞ → Proc ∞ → Type ℓ where
∅ : Equal i ∅ ∅
_∣_ : ∀ {P₁ P₂ Q₁ Q₂} →
Equal i P₁ P₂ → Equal i Q₁ Q₂ → Equal i (P₁ ∣ Q₁) (P₂ ∣ Q₂)
_⊕_ : ∀ {P₁ P₂ Q₁ Q₂} →
Equal i P₁ P₂ → Equal i Q₁ Q₂ → Equal i (P₁ ⊕ Q₁) (P₂ ⊕ Q₂)
_·_ : ∀ {μ₁ μ₂ P₁ P₂} →
μ₁ ≡ μ₂ → Equal′ i (force P₁) (force P₂) →
Equal i (μ₁ · P₁) (μ₂ · P₂)
⟨ν_⟩ : ∀ {a₁ a₂ P₁ P₂} →
a₁ ≡ a₂ → Equal i P₁ P₂ → Equal i (⟨ν a₁ ⟩ P₁) (⟨ν a₂ ⟩ P₂)
!_ : ∀ {P₁ P₂} → Equal i P₁ P₂ → Equal i (! P₁) (! P₂)
record Equal′ (i : Size) (P₁ P₂ : Proc ∞) : Type ℓ where
coinductive
field
force : {j : Size< i} → Equal j P₁ P₂
open Equal′ public
-- Extensionality for very strong bisimilarity.
Proc-extensionality : Type ℓ
Proc-extensionality = ∀ {P Q} → Equal ∞ P Q → P ≡ Q
------------------------------------------------------------------------
-- Some lemmas
-- The co function is involutive.
co-involutive : ∀ a → co (co a) ≡ a
co-involutive (a , kind) =
(a , not (not kind)) ≡⟨ cong (_ ,_) $ not-involutive kind ⟩∎
(a , kind) ∎
-- A name is not equal to the corresponding coname.
id≢co : ∀ {a} → a ≢ co a
id≢co {a} =
a ≡ co a ↝⟨ cong proj₂ ⟩
proj₂ a ≡ not (proj₂ a) ↝⟨ not≡⇒≢ _ _ ∘ sym ⟩
proj₂ a ≢ proj₂ a ↝⟨ _$ refl ⟩□
⊥ □
-- A cancellation law.
cancel-name : ∀ {a b} → name a ≡ name b → a ≡ b
cancel-name refl = refl
-- A disjointness law.
name≢τ : ∀ {a} → name a ≢ τ
name≢τ ()
-- The only silent label is τ.
silent≡τ : ∀ {μ} → Silent μ → μ ≡ τ
silent≡τ {τ} _ = refl
silent≡τ {name _} ()
-- Names do not match (the only silent label) τ.
∉τ : ∀ {μ a} → Silent μ → a ∉ μ
∉τ s rewrite silent≡τ s = _
-- A variant of par-τ.
par-τ′ : ∀ {P P′ Q Q′ a b} →
b ≡ co a → P [ name a ]⟶ P′ → Q [ name b ]⟶ Q′ →
P ∣ Q [ τ ]⟶ P′ ∣ Q′
par-τ′ refl = par-τ
-- The process μ · P can only make μ-transitions.
·-only : ∀ {μ₁ μ₂ P Q} → μ₁ · P [ μ₂ ]⟶ Q → μ₁ ≡ μ₂
·-only action = refl
-- The process μ · P can only transition to force P.
·-only⟶ : ∀ {μ₁ μ₂ P Q} → μ₁ · P [ μ₂ ]⟶ Q → Q ≡ force P
·-only⟶ action = refl
-- A simple corollary.
names-are-not-inverted :
∀ {a P Q} → ¬ (name a · P [ name (co a) ]⟶ Q)
names-are-not-inverted {a} {P} {Q} =
name a · P [ name (co a) ]⟶ Q ↝⟨ ·-only ⟩
name a ≡ name (co a) ↝⟨ id≢co ∘ cancel-name ⟩□
⊥ □
-- If P₁ and P₂ can only make μ-transitions, then P₁ ∣ P₂ can only
-- make μ-transitions.
∣-only : ∀ {μ₀ P₁ P₂} →
(∀ {P′ μ} → P₁ [ μ ]⟶ P′ → μ₀ ≡ μ) →
(∀ {P′ μ} → P₂ [ μ ]⟶ P′ → μ₀ ≡ μ) →
∀ {P′ μ} → P₁ ∣ P₂ [ μ ]⟶ P′ → μ₀ ≡ μ
∣-only only₁ only₂ (par-left tr) = only₁ tr
∣-only only₁ only₂ (par-right tr) = only₂ tr
∣-only {μ₀} only₁ only₂ (par-τ {a = a} tr₁ tr₂) = ⊥-elim (
$⟨ only₁ tr₁ , only₂ tr₂ ⟩
μ₀ ≡ name a × μ₀ ≡ name (co a) ↝⟨ uncurry trans ∘ Σ-map sym id ⟩
name a ≡ name (co a) ↝⟨ id≢co ∘ cancel-name ⟩□
⊥ □)
-- If P can only make μ-transitions, then ! P can only make
-- μ-transitions.
!-only : ∀ {μ₀ P} →
(∀ {P′ μ} → P [ μ ]⟶ P′ → μ₀ ≡ μ) →
∀ {P′ μ} → ! P [ μ ]⟶ P′ → μ₀ ≡ μ
!-only only (replication (par-left tr)) = !-only only tr
!-only only (replication (par-right tr)) = only tr
!-only {μ₀} only (replication (par-τ {a = a} tr₁ tr₂)) = ⊥-elim (
$⟨ !-only only tr₁ , only tr₂ ⟩
μ₀ ≡ name a × μ₀ ≡ name (co a) ↝⟨ uncurry trans ∘ Σ-map sym id ⟩
name a ≡ name (co a) ↝⟨ id≢co ∘ cancel-name ⟩□
⊥ □)
-- If P₁ and P₂ can only make μ-transitions, then P₁ ⊕ P₂ can only
-- make μ-transitions.
⊕-only : ∀ {μ₀ P₁ P₂} →
(∀ {P′ μ} → P₁ [ μ ]⟶ P′ → μ₀ ≡ μ) →
(∀ {P′ μ} → P₂ [ μ ]⟶ P′ → μ₀ ≡ μ) →
∀ {P′ μ} → P₁ ⊕ P₂ [ μ ]⟶ P′ → μ₀ ≡ μ
⊕-only only₁ only₂ (sum-left tr) = only₁ tr
⊕-only only₁ only₂ (sum-right tr) = only₂ tr
-- If P can only make μ-transitions, then ⟨ν a ⟩ P can only make
-- μ-transitions.
⟨ν⟩-only : ∀ {μ₀ a P} →
(∀ {P′ μ} → P [ μ ]⟶ P′ → μ₀ ≡ μ) →
∀ {P′ μ} → ⟨ν a ⟩ P [ μ ]⟶ P′ → μ₀ ≡ μ
⟨ν⟩-only only (restriction _ tr) = only tr
-- A simple lemma.
·⊕·-co :
∀ {a b c P Q R S} →
name a · P ⊕ name b · Q [ name c ]⟶ R →
name a · P ⊕ name b · Q [ name (co c) ]⟶ S →
b ≡ co a × (R ≡ force P × S ≡ force Q ⊎ R ≡ force Q × S ≡ force P)
·⊕·-co (sum-left action)
(sum-left tr) = ⊥-elim (names-are-not-inverted tr)
·⊕·-co (sum-left action)
(sum-right action) = refl , inj₁ (refl , refl)
·⊕·-co (sum-right action)
(sum-left action) = sym (co-involutive _)
, inj₂ (refl , refl)
·⊕·-co (sum-right action)
(sum-right tr) = ⊥-elim (names-are-not-inverted tr)
-- Very strong bisimilarity is reflexive.
Proc-refl : ∀ {i} P → Equal i P P
Proc-refl ∅ = ∅
Proc-refl (P₁ ∣ P₂) = Proc-refl P₁ ∣ Proc-refl P₂
Proc-refl (P₁ ⊕ P₂) = Proc-refl P₁ ⊕ Proc-refl P₂
Proc-refl (μ · P) = refl · λ { .force → Proc-refl (force P) }
Proc-refl (⟨ν a ⟩ P) = ⟨ν refl ⟩ (Proc-refl P)
Proc-refl (! P) = ! Proc-refl P
-- Very strong bisimilarity is symmetric.
Proc-sym : ∀ {i P Q} → Equal i P Q → Equal i Q P
Proc-sym ∅ = ∅
Proc-sym (P₁ ∣ P₂) = Proc-sym P₁ ∣ Proc-sym P₂
Proc-sym (P₁ ⊕ P₂) = Proc-sym P₁ ⊕ Proc-sym P₂
Proc-sym (p · P) = sym p · λ { .force → Proc-sym (force P) }
Proc-sym (⟨ν p ⟩ P) = ⟨ν sym p ⟩ (Proc-sym P)
Proc-sym (! P) = ! Proc-sym P
-- Very strong bisimilarity is transitive.
Proc-trans : ∀ {i P Q R} → Equal i P Q → Equal i Q R → Equal i P R
Proc-trans ∅ ∅ = ∅
Proc-trans (P₁ ∣ P₂) (Q₁ ∣ Q₂) = Proc-trans P₁ Q₁ ∣ Proc-trans P₂ Q₂
Proc-trans (P₁ ⊕ P₂) (Q₁ ⊕ Q₂) = Proc-trans P₁ Q₁ ⊕ Proc-trans P₂ Q₂
Proc-trans (p · P) (q · Q) = trans p q · λ { .force →
Proc-trans (force P) (force Q) }
Proc-trans (⟨ν p ⟩ P) (⟨ν q ⟩ Q) = ⟨ν trans p q ⟩ (Proc-trans P Q)
Proc-trans (! P) (! Q) = ! Proc-trans P Q
-- Weakening of contexts.
weaken : ∀ {i n} → Context i n → Context i (suc n)
weaken (hole x) = hole (fsuc x)
weaken ∅ = ∅
weaken (C₁ ∣ C₂) = weaken C₁ ∣ weaken C₂
weaken (C₁ ⊕ C₂) = weaken C₁ ⊕ weaken C₂
weaken (μ · C) = μ · λ { .force → weaken (force C) }
weaken (⟨ν a ⟩ C) = ⟨ν a ⟩ (weaken C)
weaken (! C) = ! weaken C
-- A lemma relating weakening and hole filling.
weaken-[] :
∀ {i n ps} (C : Context ∞ n) →
Equal i (weaken C [ ps ]) (C [ ps ∘ fsuc ])
weaken-[] (hole x) = Proc-refl _
weaken-[] ∅ = ∅
weaken-[] (C₁ ∣ C₂) = weaken-[] C₁ ∣ weaken-[] C₂
weaken-[] (C₁ ⊕ C₂) = weaken-[] C₁ ⊕ weaken-[] C₂
weaken-[] (μ · C) = refl · λ { .force → weaken-[] (force C) }
weaken-[] (⟨ν a ⟩ C) = ⟨ν refl ⟩ (weaken-[] C)
weaken-[] (! C) = ! weaken-[] C
-- The result of filling the holes in the context "context P" is P.
context-[] : ∀ {i n} {Ps : Fin n → Proc ∞} P →
Equal i P (context P [ Ps ])
context-[] ∅ = ∅
context-[] (P₁ ∣ P₂) = context-[] P₁ ∣ context-[] P₂
context-[] (P₁ ⊕ P₂) = context-[] P₁ ⊕ context-[] P₂
context-[] (μ · P) = refl · λ { .force → context-[] (force P) }
context-[] (⟨ν a ⟩ P) = ⟨ν refl ⟩ (context-[] P)
context-[] (! P) = ! (context-[] P)
-- The contexts constructed by the context function are always
-- non-degenerate.
context-non-degenerate :
∀ {i n} (P : Proc ∞) → Non-degenerate i (context {n = n} P)
context-non-degenerate ∅ = ∅
context-non-degenerate (P₁ ∣ P₂) = context-non-degenerate P₁ ∣
context-non-degenerate P₂
context-non-degenerate (P₁ ⊕ P₂) = process P₁ ⊕ process P₂
context-non-degenerate (μ · P) = action λ { .force →
context-non-degenerate (force P) }
context-non-degenerate (⟨ν a ⟩ P) = ⟨ν⟩ (context-non-degenerate P)
context-non-degenerate (! P) = ! context-non-degenerate P
mutual
-- A relation expressing that a certain process matches a certain
-- context.
data Matches (i : Size) {n} : Proc ∞ → Context ∞ n → Type ℓ where
hole : ∀ {P} (x : Fin n) → Matches i P (hole x)
∅ : Matches i ∅ ∅
_∣_ : ∀ {P₁ P₂ C₁ C₂} →
Matches i P₁ C₁ → Matches i P₂ C₂ →
Matches i (P₁ ∣ P₂) (C₁ ∣ C₂)
_⊕_ : ∀ {P₁ P₂ C₁ C₂} →
Matches i P₁ C₁ → Matches i P₂ C₂ →
Matches i (P₁ ⊕ P₂) (C₁ ⊕ C₂)
action : ∀ {μ P C} →
Matches′ i (force P) (force C) →
Matches i (μ · P) (μ · C)
⟨ν⟩ : ∀ {a P C} → Matches i P C → Matches i (⟨ν a ⟩ P) (⟨ν a ⟩ C)
!_ : ∀ {P C} → Matches i P C → Matches i (! P) (! C)
record Matches′
(i : Size) {n} (P : Proc ∞) (C : Context ∞ n) : Type ℓ where
coinductive
field
force : {j : Size< i} → Matches j P C
open Matches′ public
-- The process obtained by filling a context's holes matches the
-- context.
Matches-[] : ∀ {i n Ps} (C : Context ∞ n) → Matches i (C [ Ps ]) C
Matches-[] (hole x) = hole x
Matches-[] ∅ = ∅
Matches-[] (C₁ ∣ C₂) = Matches-[] C₁ ∣ Matches-[] C₂
Matches-[] (C₁ ⊕ C₂) = Matches-[] C₁ ⊕ Matches-[] C₂
Matches-[] (μ · C) = action λ { .force → Matches-[] (force C) }
Matches-[] (⟨ν a ⟩ C) = ⟨ν⟩ (Matches-[] C)
Matches-[] (! C) = ! Matches-[] C
-- Matches respects very strong bisimilarity.
Matches-cong : ∀ {i P Q n} {C : Context ∞ n} →
Equal i P Q → Matches i P C → Matches i Q C
Matches-cong _ (hole x) = hole x
Matches-cong ∅ ∅ = ∅
Matches-cong (p₁ ∣ p₂) (q₁ ∣ q₂) = Matches-cong p₁ q₁ ∣
Matches-cong p₂ q₂
Matches-cong (p₁ ⊕ p₂) (q₁ ⊕ q₂) = Matches-cong p₁ q₁ ⊕
Matches-cong p₂ q₂
Matches-cong (refl · p) (action q) = action λ { .force →
Matches-cong (force p)
(force q) }
Matches-cong (⟨ν refl ⟩ p) (⟨ν⟩ q) = ⟨ν⟩ (Matches-cong p q)
Matches-cong (! p) (! q) = ! Matches-cong p q
-- A predicate that identifies a process as being finite. Note that
-- this is an inductive definition.
data Finite : Proc ∞ → Type ℓ where
∅ : Finite ∅
_∣_ : ∀ {P Q} → Finite P → Finite Q → Finite (P ∣ Q)
_⊕_ : ∀ {P Q} → Finite P → Finite Q → Finite (P ⊕ Q)
action : ∀ {μ P} → Finite (force P) → Finite (μ · P)
⟨ν_⟩ : ∀ {a P} → Finite P → Finite (⟨ν a ⟩ P)
!_ : ∀ {P} → Finite P → Finite (! P)
-- The transition relation takes finite processes to finite processes.
finite→finite : ∀ {P μ Q} → P [ μ ]⟶ Q → Finite P → Finite Q
finite→finite (par-left tr) (f₁ ∣ f₂) = finite→finite tr f₁ ∣ f₂
finite→finite (par-right tr) (f₁ ∣ f₂) = f₁ ∣ finite→finite tr f₂
finite→finite (par-τ tr₁ tr₂) (f₁ ∣ f₂) = finite→finite tr₁ f₁ ∣
finite→finite tr₂ f₂
finite→finite (sum-left tr) (f₁ ⊕ f₂) = finite→finite tr f₁
finite→finite (sum-right tr) (f₁ ⊕ f₂) = finite→finite tr f₂
finite→finite action (action f) = f
finite→finite (restriction a∉ tr) ⟨ν f ⟩ = ⟨ν finite→finite tr f ⟩
finite→finite (replication tr) (! f) = finite→finite tr (! f ∣ f)
-- Subprocess P Q means that P is a syntactic subprocess of Q.
data Subprocess (P : Proc ∞) : Proc ∞ → Type ℓ where
refl : ∀ {Q} → Equal ∞ P Q → Subprocess P Q
par-left : ∀ {Q₁ Q₂} → Subprocess P Q₁ → Subprocess P (Q₁ ∣ Q₂)
par-right : ∀ {Q₁ Q₂} → Subprocess P Q₂ → Subprocess P (Q₁ ∣ Q₂)
sum-left : ∀ {Q₁ Q₂} → Subprocess P Q₁ → Subprocess P (Q₁ ⊕ Q₂)
sum-right : ∀ {Q₁ Q₂} → Subprocess P Q₂ → Subprocess P (Q₁ ⊕ Q₂)
action : ∀ {μ Q} → Subprocess P (force Q) → Subprocess P (μ · Q)
restriction : ∀ {a Q} → Subprocess P Q → Subprocess P (⟨ν a ⟩ Q)
replication : ∀ {Q} → Subprocess P Q → Subprocess P (! Q)
-- A process is regular if it has a finite number of distinct
-- subprocesses.
Regular : Proc ∞ → Type ℓ
Regular P =
∃ λ n → ∃ λ (Qs : Fin n → Proc ∞) →
∀ {Q} → Subprocess Q P →
∃ λ (i : Fin n) → Equal ∞ Q (Qs i)
-- Lemma 6.2.15 from "Enhancements of the bisimulation proof method".
-- That text claims that the lemma is proved by induction on the
-- structure of the context. Perhaps that is possible, but the proof
-- below uses induction on the structure of the transition relation,
-- and in the replication case's recursive call the context is not
-- structurally smaller.
6-2-15 :
∀ {n Ps μ P}
(C : Context ∞ n) → Weakly-guarded C →
C [ Ps ] [ μ ]⟶ P →
∃ λ (C′ : Context ∞ n) →
P ≡ C′ [ Ps ] × ∀ Qs → C [ Qs ] [ μ ]⟶ C′ [ Qs ]
6-2-15 ∅ ∅ ()
6-2-15 (C₁ ∣ C₂) (w₁ ∣ w₂) (par-left tr) = Σ-map (_∣ C₂) (Σ-map (cong (_∣ _)) (par-left ∘_)) (6-2-15 C₁ w₁ tr)
6-2-15 (C₁ ∣ C₂) (w₁ ∣ w₂) (par-right tr) = Σ-map (C₁ ∣_) (Σ-map (cong (_ ∣_)) (par-right ∘_)) (6-2-15 C₂ w₂ tr)
6-2-15 (C₁ ∣ C₂) (w₁ ∣ w₂) (par-τ tr₁ tr₂) = Σ-zip _∣_ (Σ-zip (cong₂ _)
(λ trs₁ trs₂ Qs → par-τ (trs₁ Qs) (trs₂ Qs)))
(6-2-15 C₁ w₁ tr₁) (6-2-15 C₂ w₂ tr₂)
6-2-15 (C₁ ⊕ C₂) (w₁ ⊕ w₂) (sum-left tr) = Σ-map id (Σ-map id (sum-left ∘_)) (6-2-15 C₁ w₁ tr)
6-2-15 (C₁ ⊕ C₂) (w₁ ⊕ w₂) (sum-right tr) = Σ-map id (Σ-map id (sum-right ∘_)) (6-2-15 C₂ w₂ tr)
6-2-15 (μ · C) action action = force C , refl , λ _ → action
6-2-15 (⟨ν a ⟩ C) (⟨ν⟩ w) (restriction a∉μ tr) = Σ-map ⟨ν a ⟩ (Σ-map (cong _) (restriction a∉μ ∘_)) (6-2-15 C w tr)
6-2-15 (! C) (! w) (replication tr) = Σ-map id (Σ-map id (replication ∘_)) (6-2-15 (! C ∣ C) (! w ∣ w) tr)
-- A variant of the previous lemma.
6-2-15-nd :
Proc-extensionality →
∀ {n Ps μ P}
(C : Context ∞ n) → Weakly-guarded C → Non-degenerate ∞ C →
C [ Ps ] [ μ ]⟶ P →
∃ λ (C′ : Context ∞ n) →
Non-degenerate ∞ C′ ×
P ≡ C′ [ Ps ] × ∀ Qs → C [ Qs ] [ μ ]⟶ C′ [ Qs ]
6-2-15-nd ext ∅ ∅ ∅ ()
6-2-15-nd ext (C₁ ∣ C₂) (w₁ ∣ w₂) (n₁ ∣ n₂) (par-left tr) = Σ-map (_∣ C₂) (Σ-map (_∣ n₂) (Σ-map (cong (_∣ _)) (par-left ∘_)))
(6-2-15-nd ext C₁ w₁ n₁ tr)
6-2-15-nd ext (C₁ ∣ C₂) (w₁ ∣ w₂) (n₁ ∣ n₂) (par-right tr) = Σ-map (C₁ ∣_) (Σ-map (n₁ ∣_) (Σ-map (cong (_ ∣_)) (par-right ∘_)))
(6-2-15-nd ext C₂ w₂ n₂ tr)
6-2-15-nd ext (C₁ ∣ C₂) (w₁ ∣ w₂) (n₁ ∣ n₂) (par-τ tr₁ tr₂) = Σ-zip _∣_ (Σ-zip _∣_ (Σ-zip (cong₂ _) (λ trs₁ trs₂ Qs →
par-τ (trs₁ Qs) (trs₂ Qs))))
(6-2-15-nd ext C₁ w₁ n₁ tr₁) (6-2-15-nd ext C₂ w₂ n₂ tr₂)
6-2-15-nd ext (μ · C) action (action n) action = force C , force n , refl , λ _ → action
6-2-15-nd ext (⟨ν a ⟩ C) (⟨ν⟩ w) (⟨ν⟩ n) (restriction a∉μ tr) = Σ-map ⟨ν a ⟩ (Σ-map ⟨ν⟩ (Σ-map (cong _) (restriction a∉μ ∘_)))
(6-2-15-nd ext C w n tr)
6-2-15-nd ext (! C) (! w) (! n) (replication tr) = Σ-map id (Σ-map id (Σ-map id (replication ∘_)))
(6-2-15-nd ext (! C ∣ C) (! w ∣ w) (! n ∣ n) tr)
6-2-15-nd ext (C₁ ⊕ C₂) (w₁ ⊕ w₂) (action n₁ ⊕ n₂) (sum-left tr) = Σ-map id (Σ-map id (Σ-map id (sum-left ∘_)))
(6-2-15-nd ext (_ · _) action (action n₁) tr)
6-2-15-nd ext {Ps = Ps} {P = P}
(C₁ ⊕ C₂) (w₁ ⊕ w₂) (process P₁ ⊕ n₂) (sum-left tr) = context P , context-non-degenerate P , ext (context-[] P) , λ Qs →
subst (_ [ _ ]⟶_) (ext $ context-[] P) $
subst (λ P → P ⊕ _ [ _ ]⟶ _)
(context P₁ [ Ps ] ≡⟨ sym $ ext $ context-[] P₁ ⟩
P₁ ≡⟨ ext $ context-[] P₁ ⟩∎
context P₁ [ Qs ] ∎) $
sum-left tr
6-2-15-nd ext (C₁ ⊕ C₂) (w₁ ⊕ w₂) (n₁ ⊕ action n₂) (sum-right tr) = Σ-map id (Σ-map id (Σ-map id (sum-right ∘_)))
(6-2-15-nd ext (_ · _) action (action n₂) tr)
6-2-15-nd ext {Ps = Ps} {P = P}
(C₁ ⊕ C₂) (w₁ ⊕ w₂) (n₁ ⊕ process P₂) (sum-right tr) = context P , context-non-degenerate P , ext (context-[] P) , λ Qs →
subst (_ [ _ ]⟶_) (ext $ context-[] P) $
subst (λ P → _ ⊕ P [ _ ]⟶ _)
(context P₂ [ Ps ] ≡⟨ sym $ ext $ context-[] P₂ ⟩
P₂ ≡⟨ ext $ context-[] P₂ ⟩∎
context P₂ [ Qs ] ∎) $
sum-right tr
|
{
"alphanum_fraction": 0.4622649257,
"avg_line_length": 38.6571428571,
"ext": "agda",
"hexsha": "8e718d4bb592630b00295c64709304d652276771",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/up-to",
"max_forks_repo_path": "src/Labelled-transition-system/CCS.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/up-to",
"max_issues_repo_path": "src/Labelled-transition-system/CCS.agda",
"max_line_length": 147,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/up-to",
"max_stars_repo_path": "src/Labelled-transition-system/CCS.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 8945,
"size": 24354
}
|
True : Prop
True = {P : Prop} → P → P
|
{
"alphanum_fraction": 0.4871794872,
"avg_line_length": 9.75,
"ext": "agda",
"hexsha": "a87e9164bb532439488fa9fe842954046f53f0b0",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "alhassy/agda",
"max_forks_repo_path": "test/Fail/Prop-NoImpredicativity.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "alhassy/agda",
"max_issues_repo_path": "test/Fail/Prop-NoImpredicativity.agda",
"max_line_length": 25,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "alhassy/agda",
"max_stars_repo_path": "test/Fail/Prop-NoImpredicativity.agda",
"max_stars_repo_stars_event_max_datetime": "2021-07-07T10:49:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-07-07T10:49:57.000Z",
"num_tokens": 17,
"size": 39
}
|
{-# OPTIONS --keep-pattern-variables #-}
open import Agda.Builtin.Nat
open import Agda.Builtin.Equality
test₁ : (m : Nat) → m ≡ 0 → Set
test₁ m eq = {!eq!}
test₂ : (A B : Set) → A ≡ B → Set
test₂ A B eq = {!eq!}
|
{
"alphanum_fraction": 0.6046511628,
"avg_line_length": 19.5454545455,
"ext": "agda",
"hexsha": "3f05e1e50f1cafb0b6a2ee978845f800e69587c2",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/interaction/KeepPatternVariables.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/interaction/KeepPatternVariables.agda",
"max_line_length": 40,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/interaction/KeepPatternVariables.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 79,
"size": 215
}
|
module Logic where
data Bool : Set where
true : Bool
false : Bool
_∧_ : Bool → Bool → Bool
false ∧ _ = false
true ∧ b = b
_∨_ : Bool → Bool → Bool
true ∨ _ = true
false ∨ b = b
|
{
"alphanum_fraction": 0.5945945946,
"avg_line_length": 14.2307692308,
"ext": "agda",
"hexsha": "9389874d479931e16b98b09fdabdb0210eb795d1",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "112a706f266941d6ec8cb107d18476f9d7ffbbc6",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "neosimsim/merkdas",
"max_forks_repo_path": "dependently-typed-programming-in-agda_norell-chapman/Logic.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "112a706f266941d6ec8cb107d18476f9d7ffbbc6",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "neosimsim/merkdas",
"max_issues_repo_path": "dependently-typed-programming-in-agda_norell-chapman/Logic.agda",
"max_line_length": 24,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "112a706f266941d6ec8cb107d18476f9d7ffbbc6",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "neosimsim/merkdas",
"max_stars_repo_path": "dependently-typed-programming-in-agda_norell-chapman/Logic.agda",
"max_stars_repo_stars_event_max_datetime": "2020-05-26T08:08:13.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-05-26T08:08:13.000Z",
"num_tokens": 68,
"size": 185
}
|
{-# OPTIONS --allow-unsolved-metas #-}
{-# OPTIONS --rewriting #-}
module CBVNTranslations where
open import Library
open import Polarized
-- Intuitionistic propositional logic
data IPL : Set where
Atom : (P : Atoms) → IPL
True False : IPL
_∨_ _∧_ _⇒_ : (A B : IPL) → IPL
module CallByName where
_⁻ : IPL → Form -
Atom P ⁻ = Atom- P
True ⁻ = True
False ⁻ = Comp False
(A ∨ B) ⁻ = Comp (Thunk (A ⁻) ∨ Thunk (B ⁻))
(A ∧ B) ⁻ = A ⁻ ∧ B ⁻
(A ⇒ B) ⁻ = Thunk (A ⁻) ⇒ B ⁻
module CallByValue where
_⁺ : IPL → Form +
Atom P ⁺ = Atom P
True ⁺ = True
False ⁺ = False
(A ∨ B) ⁺ = A ⁺ ∨ B ⁺
(A ∧ B) ⁺ = A ⁺ ∧ B ⁺
(A ⇒ B) ⁺ = Thunk (A ⁺ ⇒ Comp (B ⁺))
mutual
_⁺ : IPL → Form +
Atom P ⁺ = Atom P
True ⁺ = True
False ⁺ = False
(A ∨ B) ⁺ = A ⁺ ∨ B ⁺
(A ∧ B) ⁺ = A ⁺ ∧ B ⁺
(A ⇒ B) ⁺ = Thunk (A ⁺ ⇒ B ⁻)
_⁻ : IPL → Form -
Atom P ⁻ = Atom- P
True ⁻ = True
False ⁻ = Comp False
(A ∨ B) ⁻ = Comp (A ⁺ ∨ B ⁺)
(A ∧ B) ⁻ = A ⁻ ∧ B ⁻
(A ⇒ B) ⁻ = A ⁺ ⇒ B ⁻
-- Derivations
infix 2 _⊢_
data _⊢_ (Γ : Cxt' IPL) : (A : IPL) → Set where
hyp : ∀{A} (x : Hyp' IPL A Γ) → Γ ⊢ A
impI : ∀{A B} (t : Γ ∙ A ⊢ B) → Γ ⊢ A ⇒ B
impE : ∀{A B} (t : Γ ⊢ A ⇒ B) (u : Γ ⊢ A) → Γ ⊢ B
andI : ∀{A B} (t : Γ ⊢ A) (u : Γ ⊢ B) → Γ ⊢ A ∧ B
andE₁ : ∀{A B} (t : Γ ⊢ A ∧ B) → Γ ⊢ A
andE₂ : ∀{A B} (t : Γ ⊢ A ∧ B) → Γ ⊢ B
orI₁ : ∀{A B} (t : Γ ⊢ A) → Γ ⊢ A ∨ B
orI₂ : ∀{A B} (t : Γ ⊢ B) → Γ ⊢ A ∨ B
orE : ∀{A B C} (t : Γ ⊢ A ∨ B) (u : Γ ∙ A ⊢ C) (v : Γ ∙ B ⊢ C) → Γ ⊢ C
falseE : ∀{C} (t : Γ ⊢ False) → Γ ⊢ C
trueI : Γ ⊢ True
Tm = λ A Γ → Γ ⊢ A
-- Call-by value evaluation
module CBV where
V⟦_⟧ = λ A → ⟦ A ⁺ ⟧
C⟦_⟧ = λ A → ⟦ A ⁻ ⟧
return : ∀ A → V⟦ A ⟧ →̇ C⟦ A ⟧
return (Atom P) v = returnC v
return True v = v
return False v = returnC v
return (A ∨ B) v = returnC v
return (A ∧ B) (a , b) = return A a , return B b
return (A ⇒ B) v = v
run : ∀ A → C⟦ A ⟧ →̇ Cover ∞ ∞ V⟦ A ⟧
run (Atom P) c = c
run True c = returnC c
run False c = c
run (A ∨ B) c = c
run (A ∧ B) c = joinCover (mapCover' (λ τ a → mapCover' (λ τ' b → (mon⟦ A ⁺ ⟧ τ' a , b)) (run B (mon⟦ B ⁻ ⟧ τ (proj₂ c)))) (run A (proj₁ c)))
run (A ⇒ B) c = returnC c
-- Fundamental theorem
-- Extension of ⟦_⟧ to contexts
G⟦_⟧ : ∀ (Γ : Cxt' IPL) (Δ : Cxt) → Set
G⟦ ε ⟧ Δ = ⊤
G⟦ Γ ∙ A ⟧ Δ = G⟦ Γ ⟧ Δ × V⟦ A ⟧ Δ
-- monG : ∀{Γ Δ Φ} (τ : Φ ≤ Δ) → G⟦ Γ ⟧ Δ → G⟦ Γ ⟧ Φ
monG : ∀{Γ} → Mon G⟦ Γ ⟧
monG {ε} τ _ = _
monG {Γ ∙ A} τ (γ , a) = monG τ γ , mon⟦ A ⁺ ⟧ τ a
-- Variable case.
lookup : ∀{Γ A} (x : Hyp' IPL A Γ) → G⟦ Γ ⟧ →̇ V⟦ A ⟧
lookup top = proj₂
lookup (pop x) = lookup x ∘ proj₁
impIntro : ∀ {A B Γ} (f : KFun (Cover ∞ ∞ ⟦ A ⟧) ⟦ B ⟧ Γ) → ⟦ A ⇒ B ⟧ Γ
impIntro f τ a = f τ (returnC a)
-- impElim : ∀ A B {Γ} → (f : C⟦ A ⇒ B ⟧ Γ) (a : C⟦ A ⟧ Γ) → C⟦ B ⟧ Γ
-- impElim (Atom P) B f = paste (B ⁻) ∘ mapCover' f
-- impElim False B f = paste (B ⁻) ∘ mapCover' f
-- impElim True B f = f id≤
-- impElim (A ∨ A₁) B f = paste (B ⁻) ∘ mapCover' f
-- impElim (A ∧ A₁) B f = {!paste (B ⁻) ∘ mapCover' f!}
-- impElim (A ⇒ A₁) B f = f id≤
impElim : ∀ A B {Γ} → (f : C⟦ A ⇒ B ⟧ Γ) (a : C⟦ A ⟧ Γ) → C⟦ B ⟧ Γ
impElim A B f a = paste (B ⁻) (mapCover' f (run A a))
-- A lemma for the orE case.
orElim : ∀ A B C {Γ} → C⟦ A ∨ B ⟧ Γ → C⟦ A ⇒ C ⟧ Γ → C⟦ B ⇒ C ⟧ Γ → C⟦ C ⟧ Γ
orElim A B C c g h = paste (C ⁻) (mapCover' (λ τ → [ g τ , h τ ]) c)
-- A lemma for the falseE case.
-- Casts an empty cover into any semantic value (by contradiction).
falseElim : ∀ C → C⟦ False ⟧ →̇ C⟦ C ⟧
falseElim C = paste (C ⁻) ∘ mapCover ⊥-elim
-- The fundamental theorem
eval : ∀{A Γ} (t : Γ ⊢ A) → G⟦ Γ ⟧ →̇ C⟦ A ⟧
eval {A} (hyp x) = return A ∘ lookup x
eval (impI t) γ τ a = eval t (monG τ γ , a)
eval (impE {A} {B} t u) γ = impElim A B (eval t γ) (eval u γ)
eval (andI t u) γ = eval t γ , eval u γ
eval (andE₁ t) = proj₁ ∘ eval t
eval (andE₂ t) = proj₂ ∘ eval t
eval (orI₁ {A} {B} t) γ = mapCover inj₁ (run A (eval t γ))
eval (orI₂ {A} {B} t) γ = mapCover inj₂ (run B (eval t γ))
eval (orE {A} {B} {C} t u v) γ = orElim A B C (eval t γ)
(λ τ a → eval u (monG τ γ , a))
(λ τ b → eval v (monG τ γ , b))
eval {C} (falseE t) γ = falseElim C (eval t γ)
eval trueI γ = _
_⁺⁺ : (Γ : Cxt' IPL) → Cxt
ε ⁺⁺ = ε
(Γ ∙ A) ⁺⁺ = Γ ⁺⁺ ∙ A ⁻
-- Identity environment
ide : ∀ Γ → Cover ∞ ∞ G⟦ Γ ⟧ (Γ ⁺⁺)
ide ε = returnC _
ide (Γ ∙ A) = {!!}
-- monG (weak id≤) (ide Γ) , {! reflectHyp (A ⁺) (λ τ a → a) !}
{-
-- Normalization
norm : ∀{A : IPL} {Γ : Cxt' IPL} → Tm A Γ → RInv (Γ ⁺⁺) (A ⁻)
norm t = reify- _ (eval t (ide _))
-- -}
-- -}
|
{
"alphanum_fraction": 0.4461634957,
"avg_line_length": 27.1761363636,
"ext": "agda",
"hexsha": "ecdf502608b084fb559cd5a5b05f71c0dc0ce387",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2021-02-25T20:39:03.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-11-13T16:01:46.000Z",
"max_forks_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a",
"max_forks_repo_licenses": [
"Unlicense"
],
"max_forks_repo_name": "andreasabel/ipl",
"max_forks_repo_path": "src-focusing/CBVNTranslations.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Unlicense"
],
"max_issues_repo_name": "andreasabel/ipl",
"max_issues_repo_path": "src-focusing/CBVNTranslations.agda",
"max_line_length": 143,
"max_stars_count": 19,
"max_stars_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a",
"max_stars_repo_licenses": [
"Unlicense"
],
"max_stars_repo_name": "andreasabel/ipl",
"max_stars_repo_path": "src-focusing/CBVNTranslations.agda",
"max_stars_repo_stars_event_max_datetime": "2021-04-27T19:10:49.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-05-16T08:08:51.000Z",
"num_tokens": 2370,
"size": 4783
}
|
module UniDB.Morph.SubsPrime where
open import UniDB.Spec
open import Function
open import Data.Product
--------------------------------------------------------------------------------
mutual
data Subs* (T : STX) : MOR where
refl : {γ : Dom} → Subs* T γ γ
incl : {γ₁ γ₂ : Dom} (ξ : Subs+ T γ₁ γ₂) → Subs* T γ₁ γ₂
data Subs+ (T : STX) : MOR where
step : {γ₁ γ₂ : Dom} (ξ : Subs* T γ₁ γ₂) (t : T γ₂) → Subs+ T (suc γ₁) γ₂
skip : {γ₁ γ₂ : Dom} (ξ : Subs+ T γ₁ γ₂) → Subs+ T (suc γ₁) (suc γ₂)
{-
data Subs (T : STX) : MOR where
refl : {γ : Dom} → Subs T γ γ
step : {γ₁ γ₂ : Dom} (ξ : Subs T γ₁ γ₂) (t : T γ₂) → Subs T (suc γ₁) γ₂
skip : {γ₁ γ₂ : Dom} (ξ : Subs T γ₁ γ₂) → Subs T (suc γ₁) (suc γ₂)
instance
iUpSubs : {T : STX} → Up (Subs T)
_↑₁ {{iUpSubs}} = skip
_↑_ {{iUpSubs}} ξ 0 = ξ
_↑_ {{iUpSubs}} ξ (suc δ⁺) = ξ ↑ δ⁺ ↑₁
↑-zero {{iUpSubs}} ξ = refl
↑-suc {{iUpSubs}} ξ δ = refl
module _ {T : STX} {{vrT : Vr T}} {{wkT : Wk T}} where
instance
iLkSubs : Lk T (Subs T)
lk {{iLkSubs}} refl i = vr {T} i
lk {{iLkSubs}} (step ξ t) zero = t
lk {{iLkSubs}} (step ξ t) (suc i) = lk {T} {Subs T} ξ i
lk {{iLkSubs}} (skip ξ) zero = vr {T} zero
lk {{iLkSubs}} (skip ξ) (suc i) = wk₁ (lk {T} {Subs T} ξ i)
-}
--------------------------------------------------------------------------------
|
{
"alphanum_fraction": 0.4471086037,
"avg_line_length": 31.5111111111,
"ext": "agda",
"hexsha": "d78e0b7214b6ad6b69e9b651f3468c99781478c1",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "7ae52205db44ad4f463882ba7e5082120fb76349",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "skeuchel/unidb-agda",
"max_forks_repo_path": "UniDB/Morph/SubsPrime.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7ae52205db44ad4f463882ba7e5082120fb76349",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "skeuchel/unidb-agda",
"max_issues_repo_path": "UniDB/Morph/SubsPrime.agda",
"max_line_length": 80,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "7ae52205db44ad4f463882ba7e5082120fb76349",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "skeuchel/unidb-agda",
"max_stars_repo_path": "UniDB/Morph/SubsPrime.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 613,
"size": 1418
}
|
------------------------------------------------------------------------
-- Brzozowski-style derivatives of parsers
------------------------------------------------------------------------
module TotalParserCombinators.Derivative.Definition where
open import Category.Monad
open import Codata.Musical.Notation
open import Data.List using (List; map)
import Data.List.Categorical
import Data.Maybe; open Data.Maybe.Maybe
open import Level
open RawMonadPlus {f = zero} Data.List.Categorical.monadPlus
using ()
renaming ( return to return′
; ∅ to fail′
; _∣_ to _∣′_
; _⊛_ to _⊛′_
; _>>=_ to _>>=′_
)
open import TotalParserCombinators.Lib
open import TotalParserCombinators.Parser
-- A function which calculates the index of the derivative.
D-bag : ∀ {Tok R xs} → Tok → Parser Tok R xs → List R
D-bag t (return x) = fail′
D-bag t fail = fail′
D-bag t token = return′ t
D-bag t (p₁ ∣ p₂) = D-bag t p₁ ∣′ D-bag t p₂
D-bag t (nonempty p) = D-bag t p
D-bag t (cast eq p) = D-bag t p
D-bag t (f <$> p) = map f (D-bag t p)
D-bag t (p₁ ⊛ p₂) with forced? p₁ | forced? p₂
... | just xs | nothing = D-bag t p₁ ⊛′ xs
... | just xs | just fs = D-bag t p₁ ⊛′ xs ∣′ fs ⊛′ D-bag t p₂
... | nothing | nothing = fail′
... | nothing | just fs = fs ⊛′ D-bag t p₂
D-bag t (p₁ >>= p₂) with forced? p₁ | forced?′ p₂
... | just f | nothing = D-bag t p₁ >>=′ f
... | just f | just xs = (D-bag t p₁ >>=′ f) ∣′ (xs >>=′ λ x → D-bag t (p₂ x))
... | nothing | nothing = fail′
... | nothing | just xs = xs >>=′ λ x → D-bag t (p₂ x)
-- "Derivative": x ∈ D t p · s iff x ∈ p · t ∷ s.
D : ∀ {Tok R xs}
(t : Tok) (p : Parser Tok R xs) → Parser Tok R (D-bag t p)
D t (return x) = fail
D t fail = fail
D t token = return t
D t (p₁ ∣ p₂) = D t p₁ ∣ D t p₂
D t (nonempty p) = D t p
D t (cast eq p) = D t p
D t (f <$> p) = f <$> D t p
D t (p₁ ⊛ p₂) with forced? p₁ | forced? p₂
... | just xs | nothing = D t p₁ ⊛ ♭ p₂
... | just xs | just fs = D t p₁ ⊛ p₂ ∣ return⋆ fs ⊛ D t p₂
... | nothing | nothing = ♯ D t (♭ p₁) ⊛ ♭ p₂
... | nothing | just fs = ♯ D t (♭ p₁) ⊛ p₂ ∣ return⋆ fs ⊛ D t p₂
D t (p₁ >>= p₂) with forced? p₁ | forced?′ p₂
... | just f | nothing = D t p₁ >>= (λ x → ♭ (p₂ x))
... | just f | just xs = D t p₁ >>= (λ x → p₂ x)
∣ return⋆ xs >>= λ x → D t (p₂ x)
... | nothing | nothing = ♯ D t (♭ p₁) >>= (λ x → ♭ (p₂ x))
... | nothing | just xs = ♯ D t (♭ p₁) >>= (λ x → p₂ x)
∣ return⋆ xs >>= λ x → D t (p₂ x)
|
{
"alphanum_fraction": 0.4835414302,
"avg_line_length": 37.7571428571,
"ext": "agda",
"hexsha": "a5dd882f6be7b790150fe7022feb69b146eaf417",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/parser-combinators",
"max_forks_repo_path": "TotalParserCombinators/Derivative/Definition.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/parser-combinators",
"max_issues_repo_path": "TotalParserCombinators/Derivative/Definition.agda",
"max_line_length": 79,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/parser-combinators",
"max_stars_repo_path": "TotalParserCombinators/Derivative/Definition.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:13.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-07-03T08:56:13.000Z",
"num_tokens": 990,
"size": 2643
}
|
{-# OPTIONS --universe-polymorphism #-}
module Categories.Cone where
open import Level
open import Relation.Binary using (IsEquivalence; Setoid; module Setoid)
open import Categories.Support.PropositionalEquality
open import Categories.Category
open import Categories.Functor hiding (_≡_; _∘_)
module ConeOver {o ℓ e} {o′ ℓ′ e′} {C : Category o ℓ e} {J : Category o′ ℓ′ e′} (F : Functor J C) where
module J = Category J
open Category C
open Functor F
record Cone : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′) where
field
N : Obj
ψ : ∀ X → (N ⇒ F₀ X)
.commute : ∀ {X Y} (f : J [ X , Y ]) → F₁ f ∘ ψ X ≡ ψ Y
Cone′ = Cone
record _≜_ (X Y : Cone) : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′) where
module X = Cone X
module Y = Cone Y
field
N-≣ : X.N ≣ Y.N
ψ-≡ : ∀ j → C [ X.ψ j ∼ Y.ψ j ]
≜-is-equivalence : IsEquivalence _≜_
≜-is-equivalence = record
{ refl = record { N-≣ = ≣-refl; ψ-≡ = λ j → refl }
; sym = λ X≜Y → let module X≜Y = _≜_ X≜Y in record
{ N-≣ = ≣-sym X≜Y.N-≣
; ψ-≡ = λ j → sym (X≜Y.ψ-≡ j)
}
; trans = λ X≜Y Y≜Z →
let module X≜Y = _≜_ X≜Y in
let module Y≜Z = _≜_ Y≜Z in
record
{ N-≣ = ≣-trans X≜Y.N-≣ Y≜Z.N-≣
; ψ-≡ = λ j → trans (X≜Y.ψ-≡ j) (Y≜Z.ψ-≡ j)
}
}
where open Heterogeneous C
cone-setoid : Setoid _ _
cone-setoid = record
{ Carrier = Cone
; _≈_ = _≜_
; isEquivalence = ≜-is-equivalence
}
record ConeUnder (N : Obj) : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′) where
field
ψ′ : ∀ X → (N ⇒ F₀ X)
.commute : ∀ {X Y} (f : J [ X , Y ]) → F₁ f ∘ ψ′ X ≡ ψ′ Y
ConeUnder′ = ConeUnder
untether : ∀ {N} → ConeUnder N → Cone
untether {N} K = record { N = N; ψ = ψ′; commute = commute }
where open ConeUnder K
-- this Henry Ford bit is a little weird but it turns out to be handy
tether : ∀ {N} → (K : Cone) → (N ≣ Cone.N K) → ConeUnder N
tether K ≣-refl = record { ψ′ = Cone.ψ K; commute = Cone.commute K }
record _≜′_ {N} (X Y : ConeUnder N) : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′) where
module X = ConeUnder X
module Y = ConeUnder Y
field
.ψ′-≡ : ∀ j → C [ X.ψ′ j ≡ Y.ψ′ j ]
≜′-is-equivalence : (N : Obj) → IsEquivalence (_≜′_ {N})
≜′-is-equivalence N = record
{ refl = record { ψ′-≡ = λ j → Equiv.refl }
; sym = λ X≜′Y → let module X≜′Y = _≜′_ X≜′Y in record
{ ψ′-≡ = λ j → Equiv.sym (X≜′Y.ψ′-≡ j)
}
; trans = λ X≜′Y Y≜′Z →
let module X≜′Y = _≜′_ X≜′Y in
let module Y≜′Z = _≜′_ Y≜′Z in
record { ψ′-≡ = λ j → Equiv.trans (X≜′Y.ψ′-≡ j) (Y≜′Z.ψ′-≡ j) }
}
where open Heterogeneous C
cone-under-setoid : (N : Obj) → Setoid _ _
cone-under-setoid N = record
{ Carrier = ConeUnder N
; _≈_ = _≜′_
; isEquivalence = ≜′-is-equivalence N
}
private
.lemma₁ : ∀ {N j} {f : N ⇒ F₀ j} K → C [ f ∼ Cone.ψ K j ] → (pf : N ≣ Cone.N K) → f ≡ ConeUnder.ψ′ (tether K pf) j
lemma₁ K eq ≣-refl = ∼⇒≡ eq
where open Heterogeneous C
-- allow replacing the N-≣ because sometimes refl is available at the place
-- of use. in fact that's the main reason to even have ConeUnders.
-- coincidentally, it makes this easier to write!
homogenize : ∀ {K₁ K₂} → K₁ ≜ K₂ → (pf : Cone.N K₁ ≣ Cone.N K₂) → tether K₁ ≣-refl ≜′ tether K₂ pf
homogenize {K₂ = K₂} K₁≜K₂ pf = record { ψ′-≡ = λ j → lemma₁ K₂ (ψ-≡ j) pf }
where
open _≜_ K₁≜K₂
open Heterogeneous C
heterogenize : ∀ {N} {K₁ K₂ : ConeUnder N} → K₁ ≜′ K₂ → untether K₁ ≜ untether K₂
heterogenize {N} {K₁} {K₂} pf = record
{ N-≣ = ≣-refl
; ψ-≡ = λ j → Heterogeneous.≡⇒∼ (ψ′-≡ j)
}
where open _≜′_ pf
open Setoid cone-setoid public renaming (refl to ≜-refl; sym to ≜-sym; trans to ≜-trans; reflexive to ≜-reflexive)
module ≜′ {N : Obj} = Setoid (cone-under-setoid N)
open ConeOver public using (cone-setoid) renaming (_≜_ to _[_≜_]; Cone′ to Cone; _≜′_ to _[_≜′_]; ConeUnder′ to ConeUnder)
module Cone {o ℓ e} {o′ ℓ′ e′} {C : Category o ℓ e} {J : Category o′ ℓ′ e′} {F : Functor J C} (K : ConeOver.Cone F) = ConeOver.Cone K
|
{
"alphanum_fraction": 0.5425898572,
"avg_line_length": 33.0243902439,
"ext": "agda",
"hexsha": "ecd97f6f91c0f72422e59b8875f1afb41614b142",
"lang": "Agda",
"max_forks_count": 23,
"max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z",
"max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "p-pavel/categories",
"max_forks_repo_path": "Categories/Cone.agda",
"max_issues_count": 19,
"max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2",
"max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "p-pavel/categories",
"max_issues_repo_path": "Categories/Cone.agda",
"max_line_length": 133,
"max_stars_count": 98,
"max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "copumpkin/categories",
"max_stars_repo_path": "Categories/Cone.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z",
"num_tokens": 1770,
"size": 4062
}
|
{-# OPTIONS --without-K --rewriting #-}
open import lib.Basics
open import lib.types.Empty
open import lib.types.Group
open import lib.types.Word
open import lib.groups.GeneratedGroup
open import lib.groups.Homomorphism
module lib.groups.FreeGroup where
module FreeGroup {i} (A : Type i) where
private
module Gen = GeneratedGroup A empty-rel
open Gen hiding (GenGroup) public
FreeGroup : Group i
FreeGroup = Gen.GenGroup
module Freeness {j} (G : Group j) where
private
module G = Group G
module HE = HomomorphismEquiv G
extend-equiv : (A → G.El) ≃ (FreeGroup →ᴳ G)
extend-equiv =
HE.extend-equiv ∘e every-function-respects-empty-rel-equiv A G
extend : (A → G.El) → (FreeGroup →ᴳ G)
extend = –> extend-equiv
extend-is-equiv : is-equiv extend
extend-is-equiv = snd extend-equiv
|
{
"alphanum_fraction": 0.6891252955,
"avg_line_length": 23.5,
"ext": "agda",
"hexsha": "ceaa2d4f7f22b89f6925c873bbf2701d462a32c1",
"lang": "Agda",
"max_forks_count": 50,
"max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z",
"max_forks_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "AntoineAllioux/HoTT-Agda",
"max_forks_repo_path": "core/lib/groups/FreeGroup.agda",
"max_issues_count": 31,
"max_issues_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6",
"max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "AntoineAllioux/HoTT-Agda",
"max_issues_repo_path": "core/lib/groups/FreeGroup.agda",
"max_line_length": 68,
"max_stars_count": 294,
"max_stars_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "AntoineAllioux/HoTT-Agda",
"max_stars_repo_path": "core/lib/groups/FreeGroup.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z",
"num_tokens": 232,
"size": 846
}
|
{-# OPTIONS --without-K --rewriting #-}
open import lib.Basics
open import lib.NConnected
open import lib.NType2
open import lib.types.Span
open import lib.types.Pointed
open import lib.types.Pushout
open import lib.types.PushoutFlip
open import lib.types.PushoutFmap
open import lib.types.PushoutFlattening
open import lib.types.Unit
open import lib.types.Paths
open import lib.types.Truncation
open import lib.types.Lift
open import lib.cubical.Square
-- Suspension is defined as a particular case of pushout
module lib.types.Suspension where
module _ {i} (A : Type i) where
susp-span : Span
susp-span = span Unit Unit A (λ _ → tt) (λ _ → tt)
Susp : Type i
Susp = Pushout susp-span
-- [north'] and [south'] explictly ask for [A]
north' : Susp
north' = left tt
south' : Susp
south' = right tt
module _ {i} {A : Type i} where
north : Susp A
north = north' A
south : Susp A
south = south' A
merid : A → north == south
merid x = glue x
module SuspElim {j} {P : Susp A → Type j} (n : P north)
(s : P south) (p : (x : A) → n == s [ P ↓ merid x ]) where
open module P = PushoutElim (λ _ → n) (λ _ → s) p
public using (f) renaming (glue-β to merid-β)
open SuspElim public using () renaming (f to Susp-elim)
module SuspRec {j} {C : Type j} (n s : C) (p : A → n == s) where
open module P = PushoutRec {d = susp-span A} (λ _ → n) (λ _ → s) p
public using (f) renaming (glue-β to merid-β)
open SuspRec public using () renaming (f to Susp-rec)
module SuspRecType {j} (n s : Type j) (p : A → n ≃ s)
= PushoutRecType {d = susp-span A} (λ _ → n) (λ _ → s) p
susp-⊙span : ∀ {i} → Ptd i → ⊙Span
susp-⊙span X =
⊙span ⊙Unit ⊙Unit X (⊙cst {X = X}) (⊙cst {X = X})
⊙Susp : ∀ {i} → Ptd i → Ptd i
⊙Susp ⊙[ A , _ ] = ⊙[ Susp A , north ]
σloop : ∀ {i} (X : Ptd i) → de⊙ X → north' (de⊙ X) == north' (de⊙ X)
σloop ⊙[ _ , x₀ ] x = merid x ∙ ! (merid x₀)
σloop-pt : ∀ {i} {X : Ptd i} → σloop X (pt X) == idp
σloop-pt {X = ⊙[ _ , x₀ ]} = !-inv-r (merid x₀)
⊙σloop : ∀ {i} (X : Ptd i) → X ⊙→ ⊙[ north' (de⊙ X) == north' (de⊙ X) , idp ]
⊙σloop X = σloop X , σloop-pt
module SuspFlip {i} {A : Type i} = SuspRec
(south' A) north (! ∘ merid)
Susp-flip : ∀ {i} {A : Type i} → Susp A → Susp A
Susp-flip = SuspFlip.f
⊙Susp-flip : ∀ {i} (X : Ptd i) → ⊙Susp X ⊙→ ⊙Susp X
⊙Susp-flip X = (Susp-flip , ! (merid (pt X)))
Susp-flip-equiv : ∀ {i} {A : Type i} → Susp A ≃ Susp A
Susp-flip-equiv {A = A} = Pushout-flip-equiv (susp-span A)
module _ {i j} where
module SuspFmap {A : Type i} {B : Type j} (f : A → B) =
SuspRec north south (merid ∘ f)
Susp-fmap : {A : Type i} {B : Type j} (f : A → B)
→ (Susp A → Susp B)
Susp-fmap = SuspFmap.f
⊙Susp-fmap : {X : Ptd i} {Y : Ptd j} (f : X ⊙→ Y)
→ ⊙Susp X ⊙→ ⊙Susp Y
⊙Susp-fmap (f , fpt) = (Susp-fmap f , idp)
module _ {i} where
Susp-fmap-idf : (A : Type i) → ∀ a → Susp-fmap (idf A) a == a
Susp-fmap-idf A = Susp-elim idp idp $ λ a →
↓-='-in' (ap-idf (merid a) ∙ ! (SuspFmap.merid-β (idf A) a))
⊙Susp-fmap-idf : (X : Ptd i)
→ ⊙Susp-fmap (⊙idf X) == ⊙idf (⊙Susp X)
⊙Susp-fmap-idf X = ⊙λ=' (Susp-fmap-idf (de⊙ X)) idp
module _ {i j} where
Susp-fmap-cst : {A : Type i} {B : Type j} (b : B)
(a : Susp A) → Susp-fmap (cst b) a == north
Susp-fmap-cst b = Susp-elim idp (! (merid b)) $ (λ a →
↓-app=cst-from-square $ SuspFmap.merid-β (cst b) a ∙v⊡ tr-square _)
⊙Susp-fmap-cst : {X : Ptd i} {Y : Ptd j}
→ ⊙Susp-fmap (⊙cst {X = X} {Y = Y}) == ⊙cst
⊙Susp-fmap-cst = ⊙λ=' (Susp-fmap-cst _) idp
Susp-flip-fmap : {A : Type i} {B : Type j} (f : A → B)
→ ∀ σ → Susp-flip (Susp-fmap f σ) == Susp-fmap f (Susp-flip σ)
Susp-flip-fmap f = Susp-elim idp idp $ λ y → ↓-='-in' $
ap-∘ (Susp-fmap f) Susp-flip (merid y)
∙ ap (ap (Susp-fmap f)) (SuspFlip.merid-β y)
∙ ap-! (Susp-fmap f) (merid y)
∙ ap ! (SuspFmap.merid-β f y)
∙ ! (SuspFlip.merid-β (f y))
∙ ! (ap (ap Susp-flip) (SuspFmap.merid-β f y))
∙ ∘-ap Susp-flip (Susp-fmap f) (merid y)
module _ {i j k} where
Susp-fmap-∘ : {A : Type i} {B : Type j} {C : Type k} (g : B → C) (f : A → B)
(σ : Susp A) → Susp-fmap (g ∘ f) σ == Susp-fmap g (Susp-fmap f σ)
Susp-fmap-∘ g f = Susp-elim
idp
idp
(λ a → ↓-='-in' $
ap-∘ (Susp-fmap g) (Susp-fmap f) (merid a)
∙ ap (ap (Susp-fmap g)) (SuspFmap.merid-β f a)
∙ SuspFmap.merid-β g (f a)
∙ ! (SuspFmap.merid-β (g ∘ f) a))
⊙Susp-fmap-∘ : {X : Ptd i} {Y : Ptd j} {Z : Ptd k}
(g : Y ⊙→ Z) (f : X ⊙→ Y)
→ ⊙Susp-fmap (g ⊙∘ f) == ⊙Susp-fmap g ⊙∘ ⊙Susp-fmap f
⊙Susp-fmap-∘ g f = ⊙λ=' (Susp-fmap-∘ (fst g) (fst f)) idp
{- Extract the 'glue component' of a pushout -}
module _ {i j k} {s : Span {i} {j} {k}} where
module ExtractGlue = PushoutRec {d = s} {D = Susp (Span.C s)}
(λ _ → north) (λ _ → south) merid
extract-glue = ExtractGlue.f
module _ {x₀ : Span.A s} where
⊙extract-glue : ⊙[ Pushout s , left x₀ ] ⊙→ ⊙[ Susp (Span.C s) , north ]
⊙extract-glue = extract-glue , idp
module _ {i j} {A : Type i} {B : Type j} (eq : A ≃ B) where
susp-span-emap : SpanEquiv (susp-span A) (susp-span B)
susp-span-emap = ( span-map (idf _) (idf _) (fst eq) (comm-sqr λ _ → idp) (comm-sqr λ _ → idp)
, idf-is-equiv _ , idf-is-equiv _ , snd eq)
Susp-emap : Susp A ≃ Susp B
Susp-emap = Pushout-emap susp-span-emap
private
-- This is to make sure that we did not screw up [Susp-emap].
test₀ : fst Susp-emap == Susp-fmap (fst eq)
test₀ = idp
module _ {i j} {X : Ptd i} {Y : Ptd j} where
⊙Susp-emap : X ⊙≃ Y → ⊙Susp X ⊙≃ ⊙Susp Y
⊙Susp-emap ⊙eq = ≃-to-⊙≃ (Susp-emap (⊙≃-to-≃ ⊙eq)) idp
{- Interaction with [Lift] -}
module _ {i j} (X : Type i) where
Susp-Lift-econv : Susp (Lift {j = j} X) ≃ Lift {j = j} (Susp X)
Susp-Lift-econv = lift-equiv ∘e Susp-emap lower-equiv
Susp-Lift-conv : Susp (Lift {j = j} X) == Lift {j = j} (Susp X)
Susp-Lift-conv = ua Susp-Lift-econv
module _ {i j} (X : Ptd i) where
⊙Susp-Lift-econv : ⊙Susp (⊙Lift {j = j} X) ⊙≃ ⊙Lift {j = j} (⊙Susp X)
⊙Susp-Lift-econv = ⊙lift-equiv {j = j} ⊙∘e ⊙Susp-emap {X = ⊙Lift {j = j} X} {Y = X} ⊙lower-equiv
⊙Susp-Lift-conv : ⊙Susp (⊙Lift {j = j} X) == ⊙Lift {j = j} (⊙Susp X)
⊙Susp-Lift-conv = ⊙ua ⊙Susp-Lift-econv
{- Suspension of an n-connected space is n+1-connected -}
abstract
Susp-conn : ∀ {i} {A : Type i} {n : ℕ₋₂}
→ is-connected n A → is-connected (S n) (Susp A)
Susp-conn {A = A} {n = n} cA = has-level-in
([ north ] ,
Trunc-elim
(Susp-elim
idp
(Trunc-rec (λ a → ap [_] (merid a))
(contr-center cA))
(λ x → Trunc-elim
{P = λ y → idp ==
Trunc-rec (λ a → ap [_] (merid a)) y
[ (λ z → [ north ] == [ z ]) ↓ (merid x) ]}
{{λ _ → ↓-preserves-level ⟨⟩}}
(λ x' → ↓-cst=app-in (∙'-unit-l _ ∙ mers-eq n x x'))
(contr-center cA))))
where
instance _ = cA
mers-eq : ∀ {i} {A : Type i} (n : ℕ₋₂)
{{_ : is-connected n A}} → (x x' : A)
→ ap ([_] {n = S n}) (merid x)
== Trunc-rec {{has-level-apply (Trunc-level {n = S n}) _ _}} (λ a → ap [_] (merid a)) [ x' ]
mers-eq ⟨-2⟩ x x' = contr-has-all-paths _ _
mers-eq {A = A} (S n) x x' =
conn-extend (pointed-conn-out A x)
(λ y → ((ap [_] (merid x) == ap [_] (merid y)) ,
has-level-apply (has-level-apply (Trunc-level {n = S (S n)}) _ _) _ _))
(λ _ → idp) x'
|
{
"alphanum_fraction": 0.5379991986,
"avg_line_length": 31.3263598326,
"ext": "agda",
"hexsha": "5142ec469c87002723df912c6587f905be90a97b",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "timjb/HoTT-Agda",
"max_forks_repo_path": "core/lib/types/Suspension.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "timjb/HoTT-Agda",
"max_issues_repo_path": "core/lib/types/Suspension.agda",
"max_line_length": 100,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "timjb/HoTT-Agda",
"max_stars_repo_path": "core/lib/types/Suspension.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3136,
"size": 7487
}
|
-- {-# OPTIONS -v tc.meta:25 #-}
module Issue418 where
data _≡_ (A : Set₁) : Set₁ → Set₂ where
refl : A ≡ A
abstract
A : Set₁
A = Set
unfold-A : A ≡ _
unfold-A = refl
-- I don't think we should solve the meta-variable corresponding to
-- the underscore above. We have two obvious choices, A and Set, and
-- these choices are not equivalent.
-- Andreas, 2011-05-30
-- Meta-Variable should remain unsolved
|
{
"alphanum_fraction": 0.6674584323,
"avg_line_length": 19.1363636364,
"ext": "agda",
"hexsha": "be84ed9c249980d845f8f677b79e7ab712027f39",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "redfish64/autonomic-agda",
"max_forks_repo_path": "test/Fail/Issue418.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "redfish64/autonomic-agda",
"max_issues_repo_path": "test/Fail/Issue418.agda",
"max_line_length": 68,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "redfish64/autonomic-agda",
"max_stars_repo_path": "test/Fail/Issue418.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 128,
"size": 421
}
|
module _ where
id : (A B : Set₁) → (A → B) → A → B
id _ _ f = f
postulate
P : (A : Set₁) → A → Set₁
cong : (A B : Set₁) (f : A → B) (x : A) → P A x → P B (f x)
A : Set
record R₀ (B : Set) : Set₁ where
constructor mkR₀
no-eta-equality
field
proj₁ : Set
proj₂ : B
record R₁ (_ : Set) : Set₁ where
constructor mkR₁
eta-equality
field
p : R₀ A
X : Set
X = R₀.proj₁ p
record R₂ (r : R₁ A) : Set₁ where
constructor mkR₂
eta-equality
field
g : R₀ (R₁.X r)
should-succeed :
(r₁ : R₁ A) (r₂ : R₂ r₁) →
P (R₂ r₁) r₂ → P (R₀ (R₁.X r₁)) (R₂.g r₂)
should-succeed r₁ r₂ =
id (P _ _)
(P (R₀ (R₁.X r₁)) (R₂.g r₂))
(cong _ _ R₂.g _)
|
{
"alphanum_fraction": 0.5231884058,
"avg_line_length": 16.8292682927,
"ext": "agda",
"hexsha": "5e5a1b526cc2f95965bb3188f1cba506ec7d8c2f",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Succeed/Issue2553.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "hborum/agda",
"max_issues_repo_path": "test/Succeed/Issue2553.agda",
"max_line_length": 61,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "hborum/agda",
"max_stars_repo_path": "test/Succeed/Issue2553.agda",
"max_stars_repo_stars_event_max_datetime": "2020-09-20T00:28:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-10-29T09:40:30.000Z",
"num_tokens": 317,
"size": 690
}
|
-- Jesper, 2018-12-04, Issue #3431 reported by François Thiré on the
-- Agda mailing list
-- (https://lists.chalmers.se/pipermail/agda/2018/010686.html)
-- The instance of the Reduce typeclass for pairs did not have an
-- implementation for reduceB' (only reduce'), which made it default
-- to the standard implementation and forget the blocking tags.
{-# OPTIONS --rewriting #-}
open import Agda.Primitive
open import Agda.Builtin.Equality
{-# BUILTIN REWRITE _≡_ #-}
0ℓ : Level
0ℓ = lzero
1ℓ : Level
1ℓ = lsuc lzero
record Lift {a} ℓ (A : Set a) : Set (a ⊔ ℓ) where
constructor lift
field lower : A
postulate
prod : {ℓ ℓ′ : Level} → (A : Set ℓ) → (B : Set ℓ′) → Set (ℓ ⊔ ℓ′)
p : Set 1ℓ → Set 1ℓ
q : Set 1ℓ → Set 1ℓ
f : ∀ (c : Set 0ℓ) → p (Lift 1ℓ c) → q (Lift 1ℓ c)
g : ∀ (a : Set 1ℓ) → ∀ (b : Set 1ℓ) → p (prod a b)
a : Set 0ℓ
b : Set 0ℓ
canL : {ℓ ℓ′ ℓ″ : Level} → (A : Set ℓ) → (B : Set ℓ′) → (prod (Lift ℓ″ A) B) ≡ Lift (ℓ″ ⊔ ℓ′) (prod A B)
canR : {ℓ ℓ′ ℓ″ : Level} → (A : Set ℓ) → (B : Set ℓ′) → (prod A (Lift ℓ″ B)) ≡ Lift (ℓ ⊔ ℓ″) (prod A B)
canT : {ℓ ℓ′ ℓ″ : Level} → (A : Set ℓ) → Lift ℓ″ (Lift ℓ′ A) ≡ Lift (ℓ″ ⊔ ℓ′) A
{-# REWRITE canL #-}
{-# REWRITE canR #-}
{-# REWRITE canT #-}
ali : q (Lift 1ℓ (prod a b))
ali = f (prod a b) (g (Lift 1ℓ {!!}) (Lift 1ℓ b))
-- WAS: Set₁ != Set
-- SHOULD: succeed (with unsolved metas and constraints)
|
{
"alphanum_fraction": 0.5763688761,
"avg_line_length": 28.9166666667,
"ext": "agda",
"hexsha": "4ca84cbad7825149ec1cf8921b2447dd3f3f8a72",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "2fa8ede09451d43647f918dbfb24ff7b27c52edc",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "phadej/agda",
"max_forks_repo_path": "test/Fail/Issue3431.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "2fa8ede09451d43647f918dbfb24ff7b27c52edc",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "phadej/agda",
"max_issues_repo_path": "test/Fail/Issue3431.agda",
"max_line_length": 107,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "2fa8ede09451d43647f918dbfb24ff7b27c52edc",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "phadej/agda",
"max_stars_repo_path": "test/Fail/Issue3431.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 608,
"size": 1388
}
|
open import Agda.Builtin.Equality
open import Agda.Builtin.List
open import Agda.Builtin.Reflection renaming (bindTC to _>>=_)
open import Agda.Builtin.Unit
macro
pickWhatever : Term → TC ⊤
pickWhatever hole@(meta m _) = do
(cand ∷ _) ← getInstances m
where [] -> typeError (strErr "No candidates!" ∷ [])
unify hole cand
pickWhatever _ = typeError (strErr "Already solved!" ∷ [])
-- Testing basic functionality
data YesNo : Set where instance yes no : YesNo
test₁ : YesNo
test₁ = pickWhatever
test₁-ok : test₁ ≡ yes
test₁-ok = refl
-- Testing if candidates are correctly filtered
data IsYesNo : YesNo → Set where instance
isYes : IsYesNo yes
isNo : IsYesNo no
test₂ : IsYesNo no
test₂ = pickWhatever
-- Testing local candidates
test₃ : {{YesNo}} → YesNo
test₃ = pickWhatever
test₃-ok : ∀ {x} → test₃ {{x}} ≡ x
test₃-ok = refl
|
{
"alphanum_fraction": 0.700814901,
"avg_line_length": 22.6052631579,
"ext": "agda",
"hexsha": "29ad36c147b08777a364afdfda6bd8cdb3f1172b",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "cagix/agda",
"max_forks_repo_path": "test/Succeed/GetInstanceCandidates.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "cagix/agda",
"max_issues_repo_path": "test/Succeed/GetInstanceCandidates.agda",
"max_line_length": 62,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "cagix/agda",
"max_stars_repo_path": "test/Succeed/GetInstanceCandidates.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 264,
"size": 859
}
|
module Definitions where
data ℕ : Set where
zero : ℕ
suc : (n : ℕ) → ℕ
data _≡_ (x : ℕ) : ℕ → Set where
refl : x ≡ x
data _≢_ : ℕ → ℕ → Set where
z≢s : ∀ {n} → zero ≢ suc n
s≢z : ∀ {n} → suc n ≢ zero
s≢s : ∀ {m n} → m ≢ n → suc m ≢ suc n
data Equal? (m n : ℕ) : Set where
yes : m ≡ n → Equal? m n
no : m ≢ n → Equal? m n
data ⊥ : Set where
|
{
"alphanum_fraction": 0.4848484848,
"avg_line_length": 18.15,
"ext": "agda",
"hexsha": "dd49f1bd3528e36eb876e291eb75c01ec8e44207",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "ece25bed081a24f02e9f85056d05933eae2afabf",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "danr/agder",
"max_forks_repo_path": "problems/NatEquality/Definitions.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ece25bed081a24f02e9f85056d05933eae2afabf",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "danr/agder",
"max_issues_repo_path": "problems/NatEquality/Definitions.agda",
"max_line_length": 39,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "ece25bed081a24f02e9f85056d05933eae2afabf",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "danr/agder",
"max_stars_repo_path": "problems/NatEquality/Definitions.agda",
"max_stars_repo_stars_event_max_datetime": "2021-05-17T12:07:03.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-05-17T12:07:03.000Z",
"num_tokens": 169,
"size": 363
}
|
module STLC where
open import Data.Nat
open import Data.Empty
open import Relation.Binary.PropositionalEquality
-- infix 4 _⊢_
-- infix 4 _∋_∶_
-- infixl 5 _,_
infixr 7 _⟶_
infix 5 ƛ_
infixl 7 _∙_
-- infix 9 `_
infixl 10 _∶_
-- infix 5 μ_
-- infix 8 `suc_
-- infix 9 S_
-- infix 9 #_
data Type : Set where
_⟶_ : Type → Type → Type
⊤ : Type
data Context : Set
data Term : Set
infix 4 _∋_∶_
data _∋_∶_ : Context → Term → Type → Set
infixl 10 _,_∶_
data Context where
∅ : Context
_,_∶_ : Context → Term → Type → Context
data Term where
‵_ : ∀ {Γ x A} → Γ ∋ x ∶ A → Term
ƛ_ : Term → Term
_∙_ : Term → Term → Term
_∶_ : Term → Type → Term
tt : Term
data _∋_∶_ where
Z : ∀ {Γ x A}
---------
→ Γ , x ∶ A ∋ x ∶ A
S_ : ∀ {Γ x A y B}
→ Γ ∋ x ∶ A
---------
→ Γ , y ∶ B ∋ x ∶ A
-- lookup : Context → ℕ → Type
-- lookup (Γ , A) zero = A
-- lookup (Γ , _) (suc n) = lookup Γ n
-- lookup ∅ _ = ⊥-elim impossible
-- where postulate impossible : ⊥
-- count : ∀ {Γ} → (n : ℕ) → Γ ∋ lookup Γ n
-- count {Γ , _} zero = Z
-- count {Γ , _} (suc n) = S (count n)
-- count {∅} _ = ⊥-elim impossible
-- where postulate impossible : ⊥
-- -- #_ : ∀ {Γ} → (n : ℕ) → Γ ⊢ lookup Γ n
-- -- # n = ` count n
-- a = {! !}
infix 4 _⊢_⇐_
infix 4 _⊢_⇒_
data _⊢_⇐_ : Context → Term → Type → Set
data _⊢_⇒_ : Context → Term → Type → Set
variable
Γ : Context
x e f : Term
A B : Type
data _⊢_⇒_ where
Var :
Γ ∋ x ∶ A
----------------------------
→ Γ ⊢ x ⇒ A
Anno :
Γ ⊢ e ⇐ A
----------------------------
→ Γ ⊢ (e ∶ A) ⇒ A
⟶E :
Γ ⊢ f ⇒ (A ⟶ B)
→ Γ ⊢ e ⇐ A
----------------------------
→ Γ ⊢ f ∙ e ⇒ B
data _⊢_⇐_ where
Sub :
Γ ∋ e ∶ A
→ A ≡ B
----------------------------
→ Γ ⊢ e ⇐ B
⊤I : ∀ {Γ}
----------------------------
→ Γ ⊢ tt ⇐ ⊤
⟶I :
(Γ , x ∶ A) ⊢ e ⇐ B
----------------------------
→ Γ ⊢ ƛ e ⇐ A ⟶ B
4-4-Synth : ∅ , x ∶ A ⊢ x ⇒ A
4-4-Synth = Var Z
4-4-Check : ∅ , x ∶ A ⊢ x ⇐ A
4-4-Check = Sub Z refl
4-4-Sym→Elim : ∅ , f ∶ (A ⟶ B) , x ∶ A ⊢ (f ∙ x) ⇒ B
4-4-Sym→Elim = ⟶E (Var (S Z)) (Sub Z refl)
|
{
"alphanum_fraction": 0.4162936437,
"avg_line_length": 16.071942446,
"ext": "agda",
"hexsha": "dc3f7dcc30133c17d5f5bd3a44e5346d93748f04",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "0c9a6e79c23192b28ddb07315b200a94ee900ca6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "banacorn/bidirectional",
"max_forks_repo_path": "LC/stash/STLC.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0c9a6e79c23192b28ddb07315b200a94ee900ca6",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "banacorn/bidirectional",
"max_issues_repo_path": "LC/stash/STLC.agda",
"max_line_length": 52,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "0c9a6e79c23192b28ddb07315b200a94ee900ca6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "banacorn/bidirectional",
"max_stars_repo_path": "LC/stash/STLC.agda",
"max_stars_repo_stars_event_max_datetime": "2020-08-25T14:05:01.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-08-25T07:34:40.000Z",
"num_tokens": 986,
"size": 2234
}
|
{-# OPTIONS --safe --experimental-lossy-unification #-}
module Cubical.Categories.Instances.CommAlgebras where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Powerset
open import Cubical.Foundations.HLevels
open import Cubical.Data.Unit
open import Cubical.Data.Sigma
open import Cubical.Algebra.Ring
open import Cubical.Algebra.CommRing
open import Cubical.Algebra.Algebra
open import Cubical.Algebra.CommAlgebra
open import Cubical.Algebra.CommAlgebra.Instances.Unit
open import Cubical.Categories.Category
open import Cubical.Categories.Functor.Base
open import Cubical.Categories.Limits.Terminal
open import Cubical.Categories.Limits.Pullback
open import Cubical.Categories.Instances.CommRings
open import Cubical.HITs.PropositionalTruncation
open Category hiding (_∘_) renaming (_⋆_ to _⋆c_)
open CommAlgebraHoms
open Cospan
open Pullback
private
variable
ℓ ℓ' ℓ'' : Level
module _ (R : CommRing ℓ) where
CommAlgebrasCategory : Category (ℓ-suc (ℓ-max ℓ ℓ')) (ℓ-max ℓ ℓ')
ob CommAlgebrasCategory = CommAlgebra R _
Hom[_,_] CommAlgebrasCategory = CommAlgebraHom
id CommAlgebrasCategory {A} = idCommAlgebraHom A
_⋆c_ CommAlgebrasCategory {A} {B} {C} = compCommAlgebraHom A B C
⋆IdL CommAlgebrasCategory {A} {B} = compIdCommAlgebraHom {A = A} {B}
⋆IdR CommAlgebrasCategory {A} {B} = idCompCommAlgebraHom {A = A} {B}
⋆Assoc CommAlgebrasCategory {A} {B} {C} {D} = compAssocCommAlgebraHom {A = A} {B} {C} {D}
isSetHom CommAlgebrasCategory = isSetAlgebraHom _ _
TerminalCommAlgebra : Terminal (CommAlgebrasCategory {ℓ' = ℓ'})
fst TerminalCommAlgebra = UnitCommAlgebra R
fst (fst (snd TerminalCommAlgebra A)) = λ _ → tt*
snd (fst (snd TerminalCommAlgebra A)) = makeIsAlgebraHom
refl (λ _ _ → refl) (λ _ _ → refl) (λ _ _ → refl)
snd (snd TerminalCommAlgebra A) f = AlgebraHom≡ (funExt (λ _ → refl))
module PullbackFromCommRing (R : CommRing ℓ)
(commRingCospan : Cospan (CommRingsCategory {ℓ = ℓ}))
(commRingPB : Pullback _ commRingCospan)
(f₁ : CommRingHom R (commRingPB .pbOb))
(f₂ : CommRingHom R (commRingCospan .r))
(f₃ : CommRingHom R (commRingCospan .l))
(f₄ : CommRingHom R (commRingCospan .m))
where
open AlgebraHoms
open CommAlgChar R
open CommAlgebraStr ⦃...⦄
private
CommAlgCat = CommAlgebrasCategory {ℓ = ℓ} R {ℓ' = ℓ}
A = commRingPB .pbOb
B = commRingCospan .r
C = commRingCospan .l
D = commRingCospan .m
g₁ = commRingPB .pbPr₂
g₂ = commRingPB .pbPr₁
g₃ = commRingCospan .s₂
g₄ = commRingCospan .s₁
{-
g₁
A → B
⌟
g₂ ↓ ↓ g₃
C → D
g₄
-}
open RingHoms
univPropCommRingWithHomHom : (isRHom₁ : isCommRingWithHomHom (A , f₁) (B , f₂) g₁)
(isRHom₂ : isCommRingWithHomHom (A , f₁) (C , f₃) g₂)
(isRHom₃ : isCommRingWithHomHom (B , f₂) (D , f₄) g₃)
(isRHom₄ : isCommRingWithHomHom (C , f₃) (D , f₄) g₄)
(E,f₅ : CommRingWithHom)
(h₂ : CommRingWithHomHom E,f₅ (C , f₃))
(h₁ : CommRingWithHomHom E,f₅ (B , f₂))
→ g₄ ∘r fst h₂ ≡ g₃ ∘r fst h₁
→ ∃![ h₃ ∈ CommRingWithHomHom E,f₅ (A , f₁) ]
(fst h₂ ≡ g₂ ∘r fst h₃) × (fst h₁ ≡ g₁ ∘r fst h₃)
univPropCommRingWithHomHom isRHom₁ isRHom₂ isRHom₃ isRHom₄
(E , f₅) (h₂ , comm₂) (h₁ , comm₁) squareComm =
((h₃ , h₃∘f₅≡f₁) , h₂≡g₂∘h₃ , h₁≡g₁∘h₃)
, λ h₃' → Σ≡Prop (λ _ → isProp× (isSetRingHom _ _ _ _) (isSetRingHom _ _ _ _))
(Σ≡Prop (λ _ → isSetRingHom _ _ _ _)
(cong fst (commRingPB .univProp h₂ h₁ squareComm .snd
(h₃' .fst .fst , h₃' .snd .fst , h₃' .snd .snd))))
where
h₃ : CommRingHom E A
h₃ = commRingPB .univProp h₂ h₁ squareComm .fst .fst
h₂≡g₂∘h₃ : h₂ ≡ g₂ ∘r h₃
h₂≡g₂∘h₃ = commRingPB .univProp h₂ h₁ squareComm .fst .snd .fst
h₁≡g₁∘h₃ : h₁ ≡ g₁ ∘r h₃
h₁≡g₁∘h₃ = commRingPB .univProp h₂ h₁ squareComm .fst .snd .snd
-- the crucial obervation:
-- we can apply the universal property to maps R → A
fgSquare : g₄ ∘r f₃ ≡ g₃ ∘r f₂
fgSquare = isRHom₄ ∙ sym isRHom₃
h₃∘f₅≡f₁ : h₃ ∘r f₅ ≡ f₁
h₃∘f₅≡f₁ = cong fst (isContr→isProp (commRingPB .univProp f₃ f₂ fgSquare)
(h₃ ∘r f₅ , triangle1 , triangle2) (f₁ , (sym isRHom₂) , sym isRHom₁))
where
triangle1 : f₃ ≡ g₂ ∘r (h₃ ∘r f₅)
triangle1 = sym comm₂ ∙∙ cong (compRingHom f₅) h₂≡g₂∘h₃ ∙∙ sym (compAssocRingHom f₅ h₃ g₂)
triangle2 : f₂ ≡ g₁ ∘r (h₃ ∘r f₅)
triangle2 = sym comm₁ ∙∙ cong (compRingHom f₅) h₁≡g₁∘h₃ ∙∙ sym (compAssocRingHom f₅ h₃ g₁)
algCospan : (isRHom₁ : isCommRingWithHomHom (A , f₁) (B , f₂) g₁)
(isRHom₂ : isCommRingWithHomHom (A , f₁) (C , f₃) g₂)
(isRHom₃ : isCommRingWithHomHom (B , f₂) (D , f₄) g₃)
(isRHom₄ : isCommRingWithHomHom (C , f₃) (D , f₄) g₄)
→ Cospan CommAlgCat
l (algCospan isRHom₁ isRHom₂ isRHom₃ isRHom₄) = toCommAlg (C , f₃)
m (algCospan isRHom₁ isRHom₂ isRHom₃ isRHom₄) = toCommAlg (D , f₄)
r (algCospan isRHom₁ isRHom₂ isRHom₃ isRHom₄) = toCommAlg (B , f₂)
s₁ (algCospan isRHom₁ isRHom₂ isRHom₃ isRHom₄) = toCommAlgebraHom _ _ g₄ isRHom₄
s₂ (algCospan isRHom₁ isRHom₂ isRHom₃ isRHom₄) = toCommAlgebraHom _ _ g₃ isRHom₃
algPullback : (isRHom₁ : isCommRingWithHomHom (A , f₁) (B , f₂) g₁)
(isRHom₂ : isCommRingWithHomHom (A , f₁) (C , f₃) g₂)
(isRHom₃ : isCommRingWithHomHom (B , f₂) (D , f₄) g₃)
(isRHom₄ : isCommRingWithHomHom (C , f₃) (D , f₄) g₄)
→ Pullback CommAlgCat (algCospan isRHom₁ isRHom₂ isRHom₃ isRHom₄)
pbOb (algPullback isRHom₁ isRHom₂ isRHom₃ isRHom₄) = toCommAlg (A , f₁)
pbPr₁ (algPullback isRHom₁ isRHom₂ isRHom₃ isRHom₄) = toCommAlgebraHom _ _ g₂ isRHom₂
pbPr₂ (algPullback isRHom₁ isRHom₂ isRHom₃ isRHom₄) = toCommAlgebraHom _ _ g₁ isRHom₁
pbCommutes (algPullback isRHom₁ isRHom₂ isRHom₃ isRHom₄) =
AlgebraHom≡ (cong fst (pbCommutes commRingPB))
univProp (algPullback isRHom₁ isRHom₂ isRHom₃ isRHom₄) {d = F} h₂' h₁' g₄∘h₂'≡g₃∘h₁' =
(k , kComm₂ , kComm₁) , uniqueness
where
E = fromCommAlg F .fst
f₅ = fromCommAlg F .snd
h₁ : CommRingHom E B
fst h₁ = fst h₁'
IsRingHom.pres0 (snd h₁) = IsAlgebraHom.pres0 (snd h₁')
IsRingHom.pres1 (snd h₁) = IsAlgebraHom.pres1 (snd h₁')
IsRingHom.pres+ (snd h₁) = IsAlgebraHom.pres+ (snd h₁')
IsRingHom.pres· (snd h₁) = IsAlgebraHom.pres· (snd h₁')
IsRingHom.pres- (snd h₁) = IsAlgebraHom.pres- (snd h₁')
h₁comm : h₁ ∘r f₅ ≡ f₂
h₁comm = RingHom≡ (funExt (λ x → IsAlgebraHom.pres⋆ (snd h₁') x 1a
∙∙ cong (fst f₂ x ·_) (IsAlgebraHom.pres1 (snd h₁'))
∙∙ ·Rid _))
where
instance
_ = snd F
_ = snd (toCommAlg (B , f₂))
h₂ : CommRingHom E C
fst h₂ = fst h₂'
IsRingHom.pres0 (snd h₂) = IsAlgebraHom.pres0 (snd h₂')
IsRingHom.pres1 (snd h₂) = IsAlgebraHom.pres1 (snd h₂')
IsRingHom.pres+ (snd h₂) = IsAlgebraHom.pres+ (snd h₂')
IsRingHom.pres· (snd h₂) = IsAlgebraHom.pres· (snd h₂')
IsRingHom.pres- (snd h₂) = IsAlgebraHom.pres- (snd h₂')
h₂comm : h₂ ∘r f₅ ≡ f₃
h₂comm = RingHom≡ (funExt (λ x → IsAlgebraHom.pres⋆ (snd h₂') x 1a
∙∙ cong (fst f₃ x ·_) (IsAlgebraHom.pres1 (snd h₂'))
∙∙ ·Rid _))
where
instance
_ = snd F
_ = snd (toCommAlg (C , f₃))
commRingSquare : g₄ ∘r h₂ ≡ g₃ ∘r h₁
commRingSquare = RingHom≡ (funExt (λ x → funExt⁻ (cong fst g₄∘h₂'≡g₃∘h₁') x))
uniqueH₃ : ∃![ h₃ ∈ CommRingWithHomHom (E , f₅) (A , f₁) ] (h₂ ≡ g₂ ∘r fst h₃) × (h₁ ≡ g₁ ∘r fst h₃)
uniqueH₃ = univPropCommRingWithHomHom isRHom₁ isRHom₂ isRHom₃ isRHom₄
(E , f₅) (h₂ , h₂comm) (h₁ , h₁comm) commRingSquare
h₃ : CommRingHom E A
h₃ = uniqueH₃ .fst .fst .fst
h₃comm = uniqueH₃ .fst .fst .snd
k : CommAlgebraHom F (toCommAlg (A , f₁))
fst k = fst h₃
IsAlgebraHom.pres0 (snd k) = IsRingHom.pres0 (snd h₃)
IsAlgebraHom.pres1 (snd k) = IsRingHom.pres1 (snd h₃)
IsAlgebraHom.pres+ (snd k) = IsRingHom.pres+ (snd h₃)
IsAlgebraHom.pres· (snd k) = IsRingHom.pres· (snd h₃)
IsAlgebraHom.pres- (snd k) = IsRingHom.pres- (snd h₃)
IsAlgebraHom.pres⋆ (snd k) =
λ r y → sym (fst f₁ r · fst h₃ y ≡⟨ cong (_· fst h₃ y) (sym (funExt⁻ (cong fst h₃comm) r)) ⟩
fst h₃ (fst f₅ r) · fst h₃ y ≡⟨ sym (IsRingHom.pres· (snd h₃) _ _) ⟩
fst h₃ (fst f₅ r · y) ≡⟨ refl ⟩
fst h₃ ((r ⋆ 1a) · y) ≡⟨ cong (fst h₃) (⋆-lassoc _ _ _) ⟩
fst h₃ (r ⋆ (1a · y)) ≡⟨ cong (λ x → fst h₃ (r ⋆ x)) (·Lid y) ⟩
fst h₃ (r ⋆ y) ∎)
where
instance
_ = snd F
_ = (toCommAlg (A , f₁) .snd)
kComm₂ : h₂' ≡ toCommAlgebraHom _ _ g₂ isRHom₂ ∘a k
kComm₂ = AlgebraHom≡ (cong fst (uniqueH₃ .fst .snd .fst))
kComm₁ : h₁' ≡ toCommAlgebraHom _ _ g₁ isRHom₁ ∘a k
kComm₁ = AlgebraHom≡ (cong fst (uniqueH₃ .fst .snd .snd))
uniqueness : (y : Σ[ k' ∈ CommAlgebraHom F (toCommAlg (A , f₁)) ]
(h₂' ≡ toCommAlgebraHom _ _ g₂ isRHom₂ ∘a k')
× (h₁' ≡ toCommAlgebraHom _ _ g₁ isRHom₁ ∘a k'))
→ (k , kComm₂ , kComm₁) ≡ y
uniqueness (k' , k'Comm₂ , k'Comm₁) = Σ≡Prop (λ _ → isProp× (isSetAlgebraHom _ _ _ _)
(isSetAlgebraHom _ _ _ _))
(AlgebraHom≡ (cong (fst ∘ fst ∘ fst) uniqHelper))
where
h₃' : CommRingHom E A
fst h₃' = fst k'
IsRingHom.pres0 (snd h₃') = IsAlgebraHom.pres0 (snd k')
IsRingHom.pres1 (snd h₃') = IsAlgebraHom.pres1 (snd k')
IsRingHom.pres+ (snd h₃') = IsAlgebraHom.pres+ (snd k')
IsRingHom.pres· (snd h₃') = IsAlgebraHom.pres· (snd k')
IsRingHom.pres- (snd h₃') = IsAlgebraHom.pres- (snd k')
h₃'IsRHom : h₃' ∘r f₅ ≡ f₁
h₃'IsRHom = RingHom≡ (funExt (λ x → IsAlgebraHom.pres⋆ (snd k') x 1a
∙ cong (fst f₁ x ·_) (IsAlgebraHom.pres1 (snd k'))
∙ ·Rid (fst f₁ x)))
where
instance
_ = snd F
_ = (toCommAlg (A , f₁) .snd)
h₃'Comm₂ : h₂ ≡ g₂ ∘r h₃'
h₃'Comm₂ = RingHom≡ (cong fst k'Comm₂)
h₃'Comm₁ : h₁ ≡ g₁ ∘r h₃'
h₃'Comm₁ = RingHom≡ (cong fst k'Comm₁)
-- basically saying that h₃≡h₃' but we have to give all the commuting triangles
uniqHelper : uniqueH₃ .fst ≡ ((h₃' , h₃'IsRHom) , h₃'Comm₂ , h₃'Comm₁)
uniqHelper = uniqueH₃ .snd ((h₃' , h₃'IsRHom) , h₃'Comm₂ , h₃'Comm₁)
module PreSheafFromUniversalProp (C : Category ℓ ℓ') (P : ob C → Type ℓ)
{R : CommRing ℓ''} (𝓕 : Σ (ob C) P → CommAlgebra R ℓ'')
(uniqueHom : ∀ x y → C [ fst x , fst y ] → isContr (CommAlgebraHom (𝓕 y) (𝓕 x)))
where
private
∥P∥ : ℙ (ob C)
∥P∥ x = ∥ P x ∥ , isPropPropTrunc
ΣC∥P∥Cat = ΣPropCat C ∥P∥
CommAlgCat = CommAlgebrasCategory {ℓ = ℓ''} R {ℓ' = ℓ''}
𝓕UniqueEquiv : (x : ob C) (p q : P x) → isContr (CommAlgebraEquiv (𝓕 (x , p)) (𝓕 (x , q)))
𝓕UniqueEquiv x = contrCommAlgebraHom→contrCommAlgebraEquiv (curry 𝓕 x) λ p q → uniqueHom _ _ (id C)
theMap : (x : ob C) → ∥ P x ∥ → CommAlgebra R ℓ''
theMap x = recPT→CommAlgebra (curry 𝓕 x) (λ p q → 𝓕UniqueEquiv x p q .fst)
λ p q r → 𝓕UniqueEquiv x p r .snd _
theAction : (x y : ob C) → C [ x , y ]
→ (p : ∥ P x ∥) (q : ∥ P y ∥) → isContr (CommAlgebraHom (theMap y q) (theMap x p))
theAction _ _ f = elim2 (λ _ _ → isPropIsContr) λ _ _ → uniqueHom _ _ f
open Functor
universalPShf : Functor (ΣC∥P∥Cat ^op) CommAlgCat
F-ob universalPShf = uncurry theMap
F-hom universalPShf {x = x} {y = y} f = theAction _ _ f (y .snd) (x. snd) .fst
F-id universalPShf {x = x} = theAction (x .fst) (x .fst) (id C) (x .snd) (x .snd) .snd _
F-seq universalPShf {x = x} {z = z} f g = theAction _ _ (g ⋆⟨ C ⟩ f) (z .snd) (x .snd) .snd _
-- a big transport to help verifying the sheaf property
module toSheaf (x y u v : ob ΣC∥P∥Cat)
{f : C [ v .fst , y . fst ]} {g : C [ v .fst , u .fst ]}
{h : C [ u .fst , x . fst ]} {k : C [ y .fst , x .fst ]}
(Csquare : g ⋆⟨ C ⟩ h ≡ f ⋆⟨ C ⟩ k)
{-
v → y
↓ ↓
u → x
-}
(AlgCospan : Cospan CommAlgCat)
(AlgPB : Pullback _ AlgCospan)
(p₁ : AlgPB .pbOb ≡ F-ob universalPShf x) (p₂ : AlgCospan .l ≡ F-ob universalPShf u)
(p₃ : AlgCospan .r ≡ F-ob universalPShf y) (p₄ : AlgCospan .m ≡ F-ob universalPShf v)
where
private
-- just: 𝓕 k ⋆ 𝓕 f ≡ 𝓕 h ⋆ 𝓕 g
inducedSquare : seq' CommAlgCat {x = F-ob universalPShf x}
{y = F-ob universalPShf u}
{z = F-ob universalPShf v}
(F-hom universalPShf h) (F-hom universalPShf g)
≡ seq' CommAlgCat {x = F-ob universalPShf x}
{y = F-ob universalPShf y}
{z = F-ob universalPShf v}
(F-hom universalPShf k) (F-hom universalPShf f)
inducedSquare = F-square universalPShf Csquare
f' = F-hom universalPShf {x = y} {y = v} f
g' = F-hom universalPShf {x = u} {y = v} g
h' = F-hom universalPShf {x = x} {y = u} h
k' = F-hom universalPShf {x = x} {y = y} k
gPathP : PathP (λ i → CommAlgCat [ p₂ i , p₄ i ]) (AlgCospan .s₁) g'
gPathP = toPathP (sym (theAction _ _ g (v .snd) (u .snd) .snd _))
fPathP : PathP (λ i → CommAlgCat [ p₃ i , p₄ i ]) (AlgCospan .s₂) f'
fPathP = toPathP (sym (theAction _ _ f (v .snd) (y .snd) .snd _))
kPathP : PathP (λ i → CommAlgCat [ p₁ i , p₃ i ]) (AlgPB .pbPr₂) k'
kPathP = toPathP (sym (theAction _ _ k (y .snd) (x .snd) .snd _))
hPathP : PathP (λ i → CommAlgCat [ p₁ i , p₂ i ]) (AlgPB .pbPr₁) h'
hPathP = toPathP (sym (theAction _ _ h (u .snd) (x .snd) .snd _))
fgCospan : Cospan CommAlgCat
l fgCospan = F-ob universalPShf u
m fgCospan = F-ob universalPShf v
r fgCospan = F-ob universalPShf y
s₁ fgCospan = g'
s₂ fgCospan = f'
cospanPath : AlgCospan ≡ fgCospan
l (cospanPath i) = p₂ i
m (cospanPath i) = p₄ i
r (cospanPath i) = p₃ i
s₁ (cospanPath i) = gPathP i
s₂ (cospanPath i) = fPathP i
squarePathP : PathP (λ i → hPathP i ⋆⟨ CommAlgCat ⟩ gPathP i ≡ kPathP i ⋆⟨ CommAlgCat ⟩ fPathP i)
(AlgPB .pbCommutes) inducedSquare
squarePathP = toPathP (CommAlgCat .isSetHom _ _ _ _)
abstract
lemma : isPullback CommAlgCat fgCospan {c = F-ob universalPShf x} h' k' inducedSquare
lemma = transport (λ i → isPullback CommAlgCat (cospanPath i) {c = p₁ i}
(hPathP i) (kPathP i) (squarePathP i))
(AlgPB .univProp)
|
{
"alphanum_fraction": 0.5695891297,
"avg_line_length": 42.2267759563,
"ext": "agda",
"hexsha": "8bb81ec3ecebf8f700ef721dcfd188c669016e35",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "howsiyu/cubical",
"max_forks_repo_path": "Cubical/Categories/Instances/CommAlgebras.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "howsiyu/cubical",
"max_issues_repo_path": "Cubical/Categories/Instances/CommAlgebras.agda",
"max_line_length": 102,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "howsiyu/cubical",
"max_stars_repo_path": "Cubical/Categories/Instances/CommAlgebras.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 6148,
"size": 15455
}
|
module HT where
open import Prelude
open import T
open import SubstTheory
open import DynTheory
module HT where
---- Halting and Hereditary Termination
-- An old comment about lhs-halt
-- Mostly for fun, I didn't want to include "and it halts" as part
-- of the definition of HT for arrows, and I didn't want to define
-- it in terms of evaluating to a lambda and then substituting.
-- This seems to require being able to generate an inhabitant of an
-- arbitrary type as well as a proof that it is HT. The former is
-- easy in T and we accomplish the latter by appealing to all-HT,
-- although we could have also generated the proof along with the
-- inhabitant. This all seems to be handwaved away when doing it on
-- paper. Things get more unclear when in a system where not all
-- types are inhabited; if we know that either a type is inhabited or
-- it is not, then we are fine. But since we are constructive, we would
-- get tripped up by a language like System F in which type inhabitability
-- is undecidable. (Of course, the proof is easy to repair in a number of
-- ways by modifying the definition of HT.)
--
-- When I went to make the system deterministic, I found that I now depended
-- on HT-halts in all-HT, which broke the previous proof technique.
-- I decided that proving the inhabitant we construct is HT would be
-- annoying, so I decided to not bother and went back to hanging onto the
-- proof that arrows halt.
-- Extract that the lhs must halt if its application to something halts.
-- I think this isn't actually useful, though, since to use it we would
-- need to be able to produce an argument to the function.
{-
lhs-halt : {A B : TTp} {e : TCExp (A ⇒ B)} {e' : TCExp A} →
THalts (e $ e') → THalts e
lhs-halt (halts eval-refl ())
lhs-halt (halts (eval-cons (step-app-l S1) E) val) with lhs-halt (halts E val)
... | halts E' val' = halts (eval-cons S1 E') val'
lhs-halt (halts (eval-cons step-beta E) val) = halts eval-refl val-lam
-}
-- I think the induction principle for this datatype is the definition of
-- HTω from http://www.cs.cmu.edu/~rwh/courses/typesys/hw3/hw3-handout.pdf
data HTω : TNat → Set where
HT-z : {e : TNat} → (E : e ~>* zero) → HTω e
HT-s : {e e' : TNat} → (E : e ~>* suc e') → (HT : HTω e') → HTω e
-- definition of hereditary termination
HT : (A : TTp) → TCExp A → Set
HT nat e = THalts e
-- It is kind of ugly to have to hang on to the halting proof.
HT (A ⇒ B) e = THalts e × ((e' : TCExp A) → HT A e' → HT B (e $ e'))
-- proof that hereditary termination implies termination
HT-halts : ∀{A} → (e : TCExp A) → HT A e → THalts e
HT-halts {nat} e h = h
HT-halts {A ⇒ B} _ (h , _) = h
-- extend HT to substitutions
HTΓ : (Γ : Ctx) → TSubst Γ [] → Set
HTΓ Γ γ = ∀{A} (x : A ∈ Γ) -> HT A (γ x)
emptyHTΓ : ∀{γ : TSubst [] []} -> HTΓ [] γ
emptyHTΓ ()
extendHTΓ : ∀{Γ A} {e : TCExp A} {γ : TSubst Γ []} ->
HTΓ Γ γ -> HT A e -> HTΓ (A :: Γ) (extendγ γ e)
extendHTΓ η ht Z = ht
extendHTΓ {_} {_} {e} {γ} η ht {B} (S n) =
ID.coe1 (HT B) (extend-nofail-s γ e n) (η n)
-- head expansion lemma
head-expansion : ∀{A} {e e' : TCExp A} → (e ~>* e') → HT A e' → HT A e
head-expansion {nat} eval (halts eval₁ val) = halts (eval-trans eval eval₁) val
head-expansion {A ⇒ B} eval (halts eval' val , ht-logic) =
halts (eval-trans eval eval') val ,
(λ e' ht → head-expansion (eval-compat step-app-l eval) (ht-logic e' ht))
-- the main theorem
all-HT : ∀{Γ A} {γ : TSubst Γ []} → (e : TExp Γ A) → HTΓ Γ γ
→ HT A (ssubst γ e)
all-HT (var x) η = η x
all-HT (e₁ $ e₂) η with all-HT e₁ η
... | _ , HT₁ = HT₁ (ssubst _ e₂) (all-HT e₂ η)
all-HT zero η = halts eval-refl val-zero
all-HT (suc e) η with all-HT e η
... | halts eval val = halts (eval-compat step-suc eval) (val-suc val)
all-HT {Γ} {A ⇒ B} {γ} (Λ e) η =
(halts eval-refl val-lam) ,
lam-case
where lam-case : (e' : TCExp A) → HT A e' → HT B (Λ (ssubst (liftγ γ) e) $ e')
lam-case e' ht' with all-HT {γ = extendγ γ e'} e (extendHTΓ η ht')
... | ht with eval-step (step-beta {e = (ssubst (liftγ γ) e)})
... | steps-full with combine-subst-noob γ e e'
... | eq = head-expansion steps-full (ID.coe1 (HT B) eq ht)
all-HT {Γ} {A} {γ} (rec e e₀ es) η with all-HT e η
... | halts E val = head-expansion (eval-compat step-rec E) (inner val)
where inner : {n : TNat} → TVal n → HT A (rec n (ssubst γ e₀) (ssubst (liftγ γ) es))
inner val-zero = head-expansion (eval-step step-rec-z) (all-HT e₀ η)
inner (val-suc v) with all-HT es (extendHTΓ η (inner v))
... | ht with eval-step (step-rec-s v)
... | steps with combine-subst-noob γ es _
... | eq = head-expansion steps (ID.coe1 (HT A) eq ht)
-- Prove that all programs in Gödel's System T halt.
all-halt : ∀{A} → (e : TCExp A) → THalts e
all-halt {A} e = HT-halts e (ID.coe1 (HT A) (subid e) (all-HT e (emptyHTΓ {emptyγ})))
open HT public
|
{
"alphanum_fraction": 0.6106645756,
"avg_line_length": 43.2288135593,
"ext": "agda",
"hexsha": "1ef8de03687edac624c588746be8e8fe7858aa93",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2021-05-04T22:37:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-04-26T11:39:14.000Z",
"max_forks_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "msullivan/godels-t",
"max_forks_repo_path": "HT.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "msullivan/godels-t",
"max_issues_repo_path": "HT.agda",
"max_line_length": 88,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "msullivan/godels-t",
"max_stars_repo_path": "HT.agda",
"max_stars_repo_stars_event_max_datetime": "2021-03-22T00:28:03.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-12-25T01:52:57.000Z",
"num_tokens": 1756,
"size": 5101
}
|
{-# OPTIONS --copatterns --sized-types #-}
module Copatterns where
open import Size
record Stream {i : Size} (A : Set) : Set where
coinductive
constructor _::_
field
head : A
tail : {j : Size< i} -> Stream {j} A
open Stream
map : ∀ {i A B} (f : A -> B) -> (s : Stream {i} A) -> Stream {i} B
head (map {i} f s) = f (head s)
tail (map {i} f s) {j} = map {j} f (tail s {j})
iter : {A : Set} -> (A -> A) -> A -> Stream A
head (iter f a) = a
tail (iter f a) = iter f (f a)
repeat : {A : Set} -> A -> Stream A
head (repeat a) = a
tail (repeat a) = repeat a
data Nat : Set where
Z : Nat
S : Nat -> Nat
zipWith : ∀ {i : Size} {A B C : Set} -> (A -> B -> C) -> Stream {i} A -> Stream {i} B -> Stream {i} C
head (zipWith {i} f as bs) = f (head as) (head bs)
tail (zipWith {i} f as bs) {j} = zipWith {j} f (tail as {j}) (tail bs {j})
_+_ : Nat -> Nat -> Nat
_+_ Z m = m
_+_ (S n) m = S (n + m)
_*_ : Nat -> Nat -> Nat
_*_ Z m = Z
_*_ (S n) m = m + (n * m)
nats : Stream Nat
nats = iter S Z
nats' : ∀ {i : Size} -> Stream {i} Nat
head (nats' {i}) = Z
tail (nats' {i}) {j} = map {j} S (nats' {j})
fib : ∀ {i : Size} -> Stream {i} Nat
head (fib {i}) = Z
head (tail (fib {i}) {j}) = S Z
tail (tail (fib {i}) {j}) {k} = zipWith {k} _+_ (fib {k}) (tail (fib {j}) {k})
{-
pow2 : ∀ {i : Size} -> Stream {i} Nat
head pow2 = S Z
head (tail pow2) = S (S Z)
tail (tail pow2) = zipWith _+_ (tail pow2) (tail pow2)
-}
|
{
"alphanum_fraction": 0.5030885381,
"avg_line_length": 23.5,
"ext": "agda",
"hexsha": "afb0af0923dc7817f9eaa214858b68038c329cf0",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "7e12781ad0174a5f57bf57f6f1077e134b6de9dc",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "tdidriksen/copatterns",
"max_forks_repo_path": "src/agda/Copatterns.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7e12781ad0174a5f57bf57f6f1077e134b6de9dc",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "tdidriksen/copatterns",
"max_issues_repo_path": "src/agda/Copatterns.agda",
"max_line_length": 101,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "7e12781ad0174a5f57bf57f6f1077e134b6de9dc",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "tdidriksen/copatterns",
"max_stars_repo_path": "src/agda/Copatterns.agda",
"max_stars_repo_stars_event_max_datetime": "2020-11-27T15:37:01.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-11-27T15:37:01.000Z",
"num_tokens": 601,
"size": 1457
}
|
-- Kit instances and generic term traversals
module Syntax.Substitution.Instances where
open import Syntax.Types
open import Syntax.Context
open import Syntax.Terms
open import Syntax.Substitution.Kits
open import Data.Sum
open import Relation.Binary.PropositionalEquality as ≡
using (_≡_ ; refl ; sym ; cong ; subst)
open import Function using (id ; flip ; _∘_)
open ≡.≡-Reasoning
-- | Variable and term schemas
Var : Schema
Var = flip _∈_
Term : Schema
Term = _⊢_
-- | Variable kit
-- Variable kit
𝒱ar : Kit Var
𝒱ar = record
{ 𝓋 = id
; 𝓉 = var
; 𝓌 = pop
; 𝒶 = 𝒶-var
}
where
𝒶-var : ∀{A Γ} → Var Γ (A always) → Var (Γ ˢ) (A always)
𝒶-var top = top
𝒶-var (pop {B = B now} v) = 𝒶-var v
𝒶-var (pop {B = B always} v) = pop (𝒶-var v)
-- Generic substitution in a variable to any schema
subst-var : ∀ {𝒮 Γ Δ A} -> Subst 𝒮 Γ Δ → Var Γ A → 𝒮 Δ A
subst-var ● ()
subst-var (σ ▸ T) top = T
subst-var (σ ▸ T) (pop v) = subst-var σ v
-- Substitutable variable kit
𝒱arₛ : SubstKit Var
𝒱arₛ = record { 𝓀 = 𝒱ar ; 𝓈 = subst-var }
-- | Term traversal
module K {𝒮 : Schema} (k : Kit 𝒮) where
open Kit k
-- | Type-preserving term traversal
-- | Traverses the syntax tree of the term, applying
-- | the given substitution to the variables.
mutual
traverse : ∀{Γ Δ A} -> Subst 𝒮 Γ Δ -> Γ ⊢ A -> Δ ⊢ A
traverse σ (var x) = 𝓉 (subst-var σ x)
traverse σ (lam M) = lam (traverse (σ ↑ k) M)
traverse σ (M $ N) = traverse σ M $ traverse σ N
traverse σ unit = unit
traverse σ [ M ,, N ] = [ traverse σ M ,, traverse σ N ]
traverse σ (fst M) = fst (traverse σ M)
traverse σ (snd M) = snd (traverse σ M)
traverse σ (inl M) = inl (traverse σ M)
traverse σ (inr M) = inr (traverse σ M)
traverse σ (case M inl↦ N₁ ||inr↦ N₂)
= case traverse σ M
inl↦ traverse (σ ↑ k) N₁
||inr↦ traverse (σ ↑ k) N₂
traverse σ (sample M) = sample (traverse σ M)
traverse σ (stable M) = stable (traverse (σ ↓ˢ k) M)
traverse σ (sig M) = sig (traverse σ M)
traverse σ (letSig S In M) = letSig traverse σ S
In traverse (σ ↑ k) M
traverse σ (event E) = event (traverse′ σ E)
traverse′ : ∀{Γ Δ A} -> Subst 𝒮 Γ Δ -> Γ ⊨ A -> Δ ⊨ A
traverse′ σ (pure M) = pure (traverse σ M)
traverse′ σ (letSig S InC C) = letSig traverse σ S
InC traverse′ (σ ↑ k) C
traverse′ σ (letEvt E In C) = letEvt traverse σ E
In traverse′ (σ ↓ˢ k ↑ k) C
traverse′ σ (select E₁ ↦ C₁ || E₂ ↦ C₂ ||both↦ C₃) =
select traverse σ E₁ ↦ traverse′ (σ ↓ˢ k ↑ k ↑ k) C₁
|| traverse σ E₂ ↦ traverse′ (σ ↓ˢ k ↑ k ↑ k) C₂
||both↦ traverse′ (σ ↓ˢ k ↑ k ↑ k) C₃
open K
-- Renaming is a term traversal with variable substitutions
rename : ∀{A Γ Δ} -> Subst Var Γ Δ -> Γ ⊢ A -> Δ ⊢ A
rename = traverse 𝒱ar
-- Weakening is a renaming with a weakening substitution
weaken-top : ∀{B Γ A} -> Γ ⊢ A → Γ , B ⊢ A
weaken-top = rename (weak-topₛ 𝒱arₛ)
-- Weakening is a renaming with a weakening substitution
weaken′-top : ∀{B Γ A} -> Γ ⊨ A → Γ , B ⊨ A
weaken′-top = traverse′ 𝒱ar (weak-topₛ 𝒱arₛ)
-- | Term kit
-- Term kit
𝒯erm : Kit Term
𝒯erm = record
{ 𝓋 = var
; 𝓉 = id
; 𝓌 = weaken-top
; 𝒶 = 𝒶-term
}
where
𝒶-term : {Γ : Context} {A : Type} → Γ ⊢ A always → Γ ˢ ⊢ A always
𝒶-term {∙} M = M
𝒶-term {Γ , B now} (var (pop x)) = 𝒶-term (var x)
𝒶-term {Γ , B always} (var top) = var top
𝒶-term {Γ , B always} (var {A = A} (pop x)) = weaken-top (𝒶-term (var x))
𝒶-term {Γ , B now} (stable M) = 𝒶-term {Γ} (stable M)
𝒶-term {Γ , B always} (stable {A = A} M) =
stable (subst (λ x → x , B always ⊢ A now) (sym (ˢ-idemp Γ)) M)
-- Substitution is a traversal with term substitutions
substitute : ∀{Γ Δ A} -> Subst Term Γ Δ -> Γ ⊢ A -> Δ ⊢ A
substitute = traverse 𝒯erm
-- Computational substitution is a traversal with term substitutions
substitute′ : ∀{Γ Δ A} -> Subst Term Γ Δ -> Γ ⊨ A -> Δ ⊨ A
substitute′ = traverse′ 𝒯erm
-- Substitutable term kit
𝒯ermₛ : SubstKit Term
𝒯ermₛ = record { 𝓀 = 𝒯erm ; 𝓈 = substitute }
|
{
"alphanum_fraction": 0.5432822362,
"avg_line_length": 32.6176470588,
"ext": "agda",
"hexsha": "7a1995ae19a3817281e9eb11f325b7999481903d",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DimaSamoz/temporal-type-systems",
"max_forks_repo_path": "src/Syntax/Substitution/Instances.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DimaSamoz/temporal-type-systems",
"max_issues_repo_path": "src/Syntax/Substitution/Instances.agda",
"max_line_length": 77,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DimaSamoz/temporal-type-systems",
"max_stars_repo_path": "src/Syntax/Substitution/Instances.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-04T09:33:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-05-31T20:37:04.000Z",
"num_tokens": 1573,
"size": 4436
}
|
module Terminal where
open import Base
open import Category
open import Unique
open import Dual
import Iso
module Term (ℂ : Cat) where
private ℂ' = η-Cat ℂ
private open module C = Cat ℂ'
private open module U = Uniq ℂ'
private open module I = Iso ℂ'
Terminal : (A : Obj) -> Set1
Terminal A = (B : Obj) -> ∃! \(f : B ─→ A) -> True
toTerminal : {A B : Obj} -> Terminal A -> B ─→ A
toTerminal term = getWitness (term _)
terminalIso : {A B : Obj} -> Terminal A -> Terminal B -> A ≅ B
terminalIso tA tB = iso (toTerminal tB)
(toTerminal tA)
p q
where
p : toTerminal tB ∘ toTerminal tA == id
p = witnessEqual (tB _) tt tt
q : toTerminal tA ∘ toTerminal tB == id
q = witnessEqual (tA _) tt tt
module Init (ℂ : Cat) = Term (η-Cat ℂ op)
renaming
( Terminal to Initial
; toTerminal to fromInitial
; terminalIso to initialIso
)
|
{
"alphanum_fraction": 0.6039173014,
"avg_line_length": 22.4146341463,
"ext": "agda",
"hexsha": "146c5d20fc98bdb89ac19050f0616117556a73ef",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "examples/outdated-and-incorrect/cat/Terminal.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "examples/outdated-and-incorrect/cat/Terminal.agda",
"max_line_length": 64,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "examples/outdated-and-incorrect/cat/Terminal.agda",
"max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z",
"num_tokens": 301,
"size": 919
}
|
module Ual.Eq where
open import Agda.Primitive
open import Ual.Void
record Eq {a} (A : Set a) : Set (lsuc a) where
infix 30 _==_
infix 30 _≠_
field
_==_ : A → A → Set
self : {x : A} → x == x
sym : {x y : A} → x == y → y == x
trans : {x y z : A} → x == y → y == z → x == z
_≠_ : A → A → Set
x ≠ y = ¬ (x == y)
open Eq ⦃ ... ⦄ public
data Equality {a} {A : Set a} ⦃ eqA : Eq A ⦄ : A → A → Set where
equal : {x y : A} → x == y → Equality x y
notEqual : {x y : A} → x ≠ y → Equality x y
record Test {a} (A : Set a) : Set (lsuc a) where
field
⦃ eqA ⦄ : Eq A
test : (x : A) → (y : A) → Equality x y
|
{
"alphanum_fraction": 0.4698608964,
"avg_line_length": 23.962962963,
"ext": "agda",
"hexsha": "4a8264dcd0852a13c8c5775a80b9d1b898c57589",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "ea0260e1a0612ba581e4283dfb187f531a944dfd",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "brunoczim/ual",
"max_forks_repo_path": "Eq.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ea0260e1a0612ba581e4283dfb187f531a944dfd",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "brunoczim/ual",
"max_issues_repo_path": "Eq.agda",
"max_line_length": 64,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "ea0260e1a0612ba581e4283dfb187f531a944dfd",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "brunoczim/ual",
"max_stars_repo_path": "Eq.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 285,
"size": 647
}
|
{-# OPTIONS --safe --warning=error --without-K #-}
open import LogicalFormulae
open import Setoids.Setoids
open import Sets.EquivalenceRelations
open import Functions
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import Numbers.Naturals.Definition
open import Numbers.Integers.Integers
open import Numbers.Integers.Addition
open import Sets.FinSet.Definition
open import Groups.Homomorphisms.Definition
open import Groups.Groups
open import Groups.Subgroups.Definition
open import Groups.Lemmas
open import Groups.Subgroups.Definition
open import Groups.Abelian.Definition
open import Groups.Definition
open import Groups.Cyclic.Definition
open import Groups.Cyclic.DefinitionLemmas
open import Semirings.Definition
open import Rings.Definition
module Groups.Cyclic.Lemmas {m n : _} {A : Set m} {S : Setoid {m} {n} A} {_·_ : A → A → A} (G : Group S _·_) where
elementPowerHom : (x : A) → GroupHom ℤGroup G (λ i → elementPower G x i)
GroupHom.groupHom (elementPowerHom x) {a} {b} = symmetric (elementPowerCollapse G x a b)
where
open Equivalence (Setoid.eq S)
GroupHom.wellDefined (elementPowerHom x) {.y} {y} refl = reflexive
where
open Equivalence (Setoid.eq S)
subgroupOfCyclicIsCyclic : {c : _} {pred : A → Set c} → (sub : Subgroup G pred) → CyclicGroup G → CyclicGroup (subgroupIsGroup G sub)
CyclicGroup.generator (subgroupOfCyclicIsCyclic {pred = pred} sub record { generator = g ; cyclic = cyclic }) = {!!}
where
leastPowerInGroup : (bound : ℕ) → ℕ
leastPowerInGroup bound = {!!}
CyclicGroup.cyclic (subgroupOfCyclicIsCyclic sub cyc) = {!!}
-- Prefer to prove that subgroup of cyclic is cyclic, then deduce this like with abelian groups
{-
cyclicIsGroupProperty : {m n o p : _} {A : Set m} {B : Set o} {S : Setoid {m} {n} A} {T : Setoid {o} {p} B} {_+_ : A → A → A} {_*_ : B → B → B} {G : Group S _+_} {H : Group T _*_} → GroupsIsomorphic G H → CyclicGroup G → CyclicGroup H
CyclicGroup.generator (cyclicIsGroupProperty {H = H} iso G) = GroupsIsomorphic.isomorphism iso (CyclicGroup.generator G)
CyclicGroup.cyclic (cyclicIsGroupProperty {H = H} iso G) {a} with GroupIso.surj (GroupsIsomorphic.proof iso) {a}
CyclicGroup.cyclic (cyclicIsGroupProperty {H = H} iso G) {a} | a' , b with CyclicGroup.cyclic G {a'}
... | pow , prPow = pow , {!!}
-}
cyclicGroupIsAbelian : (cyclic : CyclicGroup G) → AbelianGroup G
AbelianGroup.commutative (cyclicGroupIsAbelian record { generator = generator ; cyclic = cyclic }) {a} {b} with cyclic {a}
... | bl with cyclic {b}
AbelianGroup.commutative (cyclicGroupIsAbelian record { generator = generator ; cyclic = cyclic }) {a} {b} | nA , prA | nB , prB = transitive (+WellDefined (symmetric prA) (symmetric prB)) (transitive (symmetric (GroupHom.groupHom (elementPowerHom generator) {nA} {nB})) (transitive (transitive (elementPowerWellDefinedZ' G (nA +Z nB) (nB +Z nA) (Ring.groupIsAbelian ℤRing {nA} {nB}) {generator}) (GroupHom.groupHom (elementPowerHom generator) {nB} {nA})) (+WellDefined prB prA)))
where
open Setoid S
open Equivalence eq
open Group G
|
{
"alphanum_fraction": 0.7259646828,
"avg_line_length": 52.724137931,
"ext": "agda",
"hexsha": "e3e6af609f3637d62b14ccfc845c1acb4feeb82e",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Smaug123/agdaproofs",
"max_forks_repo_path": "Groups/Cyclic/Lemmas.agda",
"max_issues_count": 14,
"max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Smaug123/agdaproofs",
"max_issues_repo_path": "Groups/Cyclic/Lemmas.agda",
"max_line_length": 480,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Smaug123/agdaproofs",
"max_stars_repo_path": "Groups/Cyclic/Lemmas.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z",
"num_tokens": 952,
"size": 3058
}
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Structures.Ring 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.Macro
open import Cubical.Structures.Semigroup hiding (⟨_⟩)
open import Cubical.Structures.Monoid hiding (⟨_⟩)
open import Cubical.Structures.AbGroup hiding (⟨_⟩)
open Iso
private
variable
ℓ : Level
record IsRing {R : Type ℓ}
(0r 1r : R) (_+_ _·_ : R → R → R) (-_ : R → R) : Type ℓ where
constructor isring
field
+-isAbGroup : IsAbGroup 0r _+_ -_
·-isMonoid : IsMonoid 1r _·_
dist : (x y z : R) → (x · (y + z) ≡ (x · y) + (x · z))
× ((x + y) · z ≡ (x · z) + (y · z))
-- This is in the Agda stdlib, but it's redundant
-- zero : (x : R) → (x · 0r ≡ 0r) × (0r · x ≡ 0r)
open IsAbGroup +-isAbGroup public
renaming
( assoc to +-assoc
; identity to +-identity
; lid to +-lid
; rid to +-rid
; inverse to +-inv
; invl to +-linv
; invr to +-rinv
; comm to +-comm
; isSemigroup to +-isSemigroup
; isMonoid to +-isMonoid
; isGroup to +-isGroup
)
open IsMonoid ·-isMonoid public
renaming
( assoc to ·-assoc
; identity to ·-identity
; lid to ·-lid
; rid to ·-rid
; isSemigroup to ·-isSemigroup
)
·-rdist-+ : (x y z : R) → x · (y + z) ≡ (x · y) + (x · z)
·-rdist-+ x y z = dist x y z .fst
·-ldist-+ : (x y z : R) → (x + y) · z ≡ (x · z) + (y · z)
·-ldist-+ x y z = dist x y z .snd
-- TODO: prove these somewhere
-- zero-lid : (x : R) → 0r · x ≡ 0r
-- zero-lid x = zero x .snd
-- zero-rid : (x : R) → x · 0r ≡ 0r
-- zero-rid x = zero x .fst
record Ring : Type (ℓ-suc ℓ) where
constructor ring
field
Carrier : Type ℓ
0r : Carrier
1r : Carrier
_+_ : Carrier → Carrier → Carrier
_·_ : Carrier → Carrier → Carrier
-_ : Carrier → Carrier
isRing : IsRing 0r 1r _+_ _·_ -_
infix 8 -_
infixl 7 _·_
infixl 6 _+_
open IsRing isRing public
-- Extractor for the carrier type
⟨_⟩ : Ring → Type ℓ
⟨_⟩ = Ring.Carrier
isSetRing : (R : Ring {ℓ}) → isSet ⟨ R ⟩
isSetRing R = R .Ring.isRing .IsRing.·-isMonoid .IsMonoid.isSemigroup .IsSemigroup.is-set
makeIsRing : {R : Type ℓ} {0r 1r : R} {_+_ _·_ : R → R → R} { -_ : R → R}
(is-setR : isSet R)
(+-assoc : (x y z : R) → x + (y + z) ≡ (x + y) + z)
(+-rid : (x : R) → x + 0r ≡ x)
(+-rinv : (x : R) → x + (- x) ≡ 0r)
(+-comm : (x y : R) → x + y ≡ y + x)
(+-assoc : (x y z : R) → x · (y · z) ≡ (x · y) · z)
(·-rid : (x : R) → x · 1r ≡ x)
(·-lid : (x : R) → 1r · x ≡ x)
(·-rdist-+ : (x y z : R) → x · (y + z) ≡ (x · y) + (x · z))
(·-ldist-+ : (x y z : R) → (x + y) · z ≡ (x · z) + (y · z))
→ IsRing 0r 1r _+_ _·_ -_
makeIsRing is-setR assoc +-rid +-rinv +-comm ·-assoc ·-rid ·-lid ·-rdist-+ ·-ldist-+ =
isring (makeIsAbGroup is-setR assoc +-rid +-rinv +-comm)
(makeIsMonoid is-setR ·-assoc ·-rid ·-lid)
λ x y z → ·-rdist-+ x y z , ·-ldist-+ x y z
makeRing : {R : Type ℓ} (0r 1r : R) (_+_ _·_ : R → R → R) (-_ : R → R)
(is-setR : isSet R)
(+-assoc : (x y z : R) → x + (y + z) ≡ (x + y) + z)
(+-rid : (x : R) → x + 0r ≡ x)
(+-rinv : (x : R) → x + (- x) ≡ 0r)
(+-comm : (x y : R) → x + y ≡ y + x)
(+-assoc : (x y z : R) → x · (y · z) ≡ (x · y) · z)
(·-rid : (x : R) → x · 1r ≡ x)
(·-lid : (x : R) → 1r · x ≡ x)
(·-rdist-+ : (x y z : R) → x · (y + z) ≡ (x · y) + (x · z))
(·-ldist-+ : (x y z : R) → (x + y) · z ≡ (x · z) + (y · z))
→ Ring
makeRing 0r 1r _+_ _·_ -_ is-setR assoc +-rid +-rinv +-comm ·-assoc ·-rid ·-lid ·-rdist-+ ·-ldist-+ =
ring _ 0r 1r _+_ _·_ -_
(makeIsRing is-setR assoc +-rid +-rinv +-comm
·-assoc ·-rid ·-lid ·-rdist-+ ·-ldist-+ )
record RingEquiv (R S : Ring {ℓ}) : Type ℓ where
constructor ringequiv
private
module R = Ring R
module S = Ring S
field
e : ⟨ R ⟩ ≃ ⟨ S ⟩
pres1 : equivFun e R.1r ≡ S.1r
isHom+ : (x y : ⟨ R ⟩) → equivFun e (x R.+ y) ≡ equivFun e x S.+ equivFun e y
isHom· : (x y : ⟨ R ⟩) → equivFun e (x R.· y) ≡ equivFun e x S.· equivFun e y
module RingΣTheory {ℓ} where
open Macro ℓ (recvar (recvar var) , var , recvar (recvar var)) public renaming
( structure to RawRingStructure
; equiv to RawRingEquivStr
; univalent to rawRingUnivalentStr )
RingAxioms : (R : Type ℓ) (s : RawRingStructure R) → Type ℓ
RingAxioms R (_+_ , 1r , _·_) =
AbGroupΣTheory.AbGroupAxioms R _+_
× IsMonoid 1r _·_
× ((x y z : R) → (x · (y + z) ≡ (x · y) + (x · z)) × ((x + y) · z ≡ (x · z) + (y · z)))
RingStructure : Type ℓ → Type ℓ
RingStructure = AxiomsStructure RawRingStructure RingAxioms
RingΣ : Type (ℓ-suc ℓ)
RingΣ = TypeWithStr ℓ RingStructure
RingEquivStr : StrEquiv RingStructure ℓ
RingEquivStr = AxiomsEquivStr RawRingEquivStr RingAxioms
isPropRingAxioms : (R : Type ℓ) (s : RawRingStructure R) → isProp (RingAxioms R s)
isPropRingAxioms R (_+_ , 1r , _·_) =
isProp× (AbGroupΣTheory.isPropAbGroupAxioms R _+_)
(isPropΣ (isPropIsMonoid 1r _·_)
λ R → isPropΠ3 λ _ _ _ →
isProp× (IsSemigroup.is-set (R .IsMonoid.isSemigroup) _ _)
(IsSemigroup.is-set (R .IsMonoid.isSemigroup) _ _))
Ring→RingΣ : Ring → RingΣ
Ring→RingΣ (ring R 0r 1r _+_ _·_ -_ (isring +-isAbelianGroup ·-isMonoid dist)) =
( R
, (_+_ , 1r , _·_)
, AbGroupΣTheory.AbGroup→AbGroupΣ (abgroup _ _ _ _ +-isAbelianGroup) .snd .snd
, ·-isMonoid , dist
)
RingΣ→Ring : RingΣ → Ring
RingΣ→Ring (_ , (y1 , y2 , y3) , z , w1 , w2) =
ring _ _ y2 y1 y3 _
(isring (AbGroupΣTheory.AbGroupΣ→AbGroup (_ , _ , z ) .AbGroup.isAbGroup)
w1 w2)
RingIsoRingΣ : Iso Ring RingΣ
RingIsoRingΣ = iso Ring→RingΣ RingΣ→Ring (λ _ → refl) (λ _ → refl)
ringUnivalentStr : UnivalentStr RingStructure RingEquivStr
ringUnivalentStr = axiomsUnivalentStr _ isPropRingAxioms rawRingUnivalentStr
RingΣPath : (R S : RingΣ) → (R ≃[ RingEquivStr ] S) ≃ (R ≡ S)
RingΣPath = SIP ringUnivalentStr
RingEquivΣ : (R S : Ring) → Type ℓ
RingEquivΣ R S = Ring→RingΣ R ≃[ RingEquivStr ] Ring→RingΣ S
RingIsoΣPath : {R S : Ring} → Iso (RingEquiv R S) (RingEquivΣ R S)
fun RingIsoΣPath (ringequiv e h1 h2 h3) = e , h2 , h1 , h3
inv RingIsoΣPath (e , h1 , h2 , h3) = ringequiv e h2 h1 h3
rightInv RingIsoΣPath _ = refl
leftInv RingIsoΣPath _ = refl
RingPath : (R S : Ring) → (RingEquiv R S) ≃ (R ≡ S)
RingPath R S =
RingEquiv R S ≃⟨ isoToEquiv RingIsoΣPath ⟩
RingEquivΣ R S ≃⟨ RingΣPath _ _ ⟩
Ring→RingΣ R ≡ Ring→RingΣ S ≃⟨ isoToEquiv (invIso (congIso RingIsoRingΣ)) ⟩
R ≡ S ■
RingPath : (R S : Ring {ℓ}) → (RingEquiv R S) ≃ (R ≡ S)
RingPath = RingΣTheory.RingPath
isPropIsRing : {R : Type ℓ} (0r 1r : R) (_+_ _·_ : R → R → R) (-_ : R → R)
→ isProp (IsRing 0r 1r _+_ _·_ -_)
isPropIsRing 0r 1r _+_ _·_ -_ (isring RG RM RD) (isring SG SM SD) =
λ i → isring (isPropIsAbGroup _ _ _ RG SG i)
(isPropIsMonoid _ _ RM SM i)
(isPropDistr RD SD i)
where
isSetR : isSet _
isSetR = RM .IsMonoid.isSemigroup .IsSemigroup.is-set
isPropDistr : isProp ((x y z : _) → ((x · (y + z)) ≡ ((x · y) + (x · z)))
× (((x + y) · z) ≡ ((x · z) + (y · z))))
isPropDistr = isPropΠ3 λ _ _ _ → isProp× (isSetR _ _) (isSetR _ _)
-- Rings have an abelian group and a monoid
Ring→AbGroup : Ring {ℓ} → AbGroup {ℓ}
Ring→AbGroup (ring _ _ _ _ _ _ R) = abgroup _ _ _ _ (IsRing.+-isAbGroup R)
Ring→Monoid : Ring {ℓ} → Monoid {ℓ}
Ring→Monoid (ring _ _ _ _ _ _ R) = monoid _ _ _ (IsRing.·-isMonoid R)
{-
some basic calculations (used for example in QuotientRing.agda),
that might 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
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)) ∎
|
{
"alphanum_fraction": 0.4563516896,
"avg_line_length": 36.9479768786,
"ext": "agda",
"hexsha": "4c63c2550159a24f70c7d20d5e2f6fb18b0c7ba3",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "RobertHarper/cubical",
"max_forks_repo_path": "Cubical/Structures/Ring.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "RobertHarper/cubical",
"max_issues_repo_path": "Cubical/Structures/Ring.agda",
"max_line_length": 101,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "RobertHarper/cubical",
"max_stars_repo_path": "Cubical/Structures/Ring.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 4996,
"size": 12784
}
|
{-# 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)
|
{
"alphanum_fraction": 0.7132216015,
"avg_line_length": 25.5714285714,
"ext": "agda",
"hexsha": "3826d52dde5dcbc4ac503df8db76163a6cd2d75e",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "2ad96390a9be5c238e73709a21533c7354cedd0c",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "logicshan/IAL",
"max_forks_repo_path": "neg-datatype-nonterm.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "2ad96390a9be5c238e73709a21533c7354cedd0c",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "logicshan/IAL",
"max_issues_repo_path": "neg-datatype-nonterm.agda",
"max_line_length": 67,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "2ad96390a9be5c238e73709a21533c7354cedd0c",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "logicshan/IAL",
"max_stars_repo_path": "neg-datatype-nonterm.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 141,
"size": 537
}
|
import PiCalculus.Utils
import PiCalculus.Syntax
import PiCalculus.Syntax.Properties
import PiCalculus.Semantics
import PiCalculus.Semantics.Properties
import PiCalculus.LinearTypeSystem
import PiCalculus.LinearTypeSystem.Algebras
import PiCalculus.LinearTypeSystem.Algebras.Graded
import PiCalculus.LinearTypeSystem.Algebras.Shared
import PiCalculus.LinearTypeSystem.Algebras.Linear
import PiCalculus.LinearTypeSystem.ContextLemmas
import PiCalculus.LinearTypeSystem.Framing
import PiCalculus.LinearTypeSystem.Weakening
import PiCalculus.LinearTypeSystem.Exchange
import PiCalculus.LinearTypeSystem.Strengthening
import PiCalculus.LinearTypeSystem.Substitution
import PiCalculus.LinearTypeSystem.SubjectCongruence
import PiCalculus.LinearTypeSystem.SubjectReduction
import PiCalculus.Examples
|
{
"alphanum_fraction": 0.9068010076,
"avg_line_length": 39.7,
"ext": "agda",
"hexsha": "c13be81203f3a44a528f8dc739fd3696b6697ffc",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2022-03-14T16:24:07.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-01-25T13:57:13.000Z",
"max_forks_repo_head_hexsha": "0fc3cf6bcc0cd07d4511dbe98149ac44e6a38b1a",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "guilhermehas/typing-linear-pi",
"max_forks_repo_path": "Everything.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "0fc3cf6bcc0cd07d4511dbe98149ac44e6a38b1a",
"max_issues_repo_issues_event_max_datetime": "2022-03-15T09:16:14.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-03-15T09:16:14.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "guilhermehas/typing-linear-pi",
"max_issues_repo_path": "Everything.agda",
"max_line_length": 52,
"max_stars_count": 26,
"max_stars_repo_head_hexsha": "0fc3cf6bcc0cd07d4511dbe98149ac44e6a38b1a",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "guilhermehas/typing-linear-pi",
"max_stars_repo_path": "Everything.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-14T15:18:23.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-05-02T23:32:11.000Z",
"num_tokens": 187,
"size": 794
}
|
module UnifyMgu where
open import UnifyTerm
open import Data.Product using (∃; _,_)
open import Data.Maybe using (Maybe; just; nothing)
open import Category.Monad using (RawMonad)
import Level
open RawMonad (Data.Maybe.monad {Level.zero})
amgu : ∀ {m} (s t : Term m) (acc : ∃ (AList m)) -> Maybe (∃ (AList m))
amgu leaf leaf acc = just acc
amgu leaf (s' fork t') acc = nothing
amgu (s' fork t') leaf acc = nothing
amgu (s1 fork s2) (t1 fork t2) acc =
amgu s2 t2 =<< amgu s1 t1 acc
amgu (i x) (i y) (m , anil) = just (flexFlex x y)
amgu (i x) t (m , anil) = flexRigid x t
amgu t (i x) (m , anil) = flexRigid x t
amgu s t (n , σ asnoc r / z) =
(λ σ -> σ ∃asnoc r / z) <$>
amgu ((r for z) ◃ s) ((r for z) ◃ t) (n , σ)
mgu : ∀ {m} -> (s t : Term m) -> Maybe (∃ (AList m))
mgu {m} s t = amgu s t (m , anil)
|
{
"alphanum_fraction": 0.5675990676,
"avg_line_length": 31.7777777778,
"ext": "agda",
"hexsha": "86f3b69bbec96eb4ac36c1192b1f644f1897ee0f",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_forks_repo_licenses": [
"RSA-MD"
],
"max_forks_repo_name": "m0davis/oscar",
"max_forks_repo_path": "archive/agda-1/UnifyMgu.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z",
"max_issues_repo_licenses": [
"RSA-MD"
],
"max_issues_repo_name": "m0davis/oscar",
"max_issues_repo_path": "archive/agda-1/UnifyMgu.agda",
"max_line_length": 70,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_stars_repo_licenses": [
"RSA-MD"
],
"max_stars_repo_name": "m0davis/oscar",
"max_stars_repo_path": "archive/agda-1/UnifyMgu.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 330,
"size": 858
}
|
module examplesPaperJFP.StatefulObject where
open import Data.Product
open import Data.String.Base as Str
open import Data.Nat.Base as N
open import Data.Vec as Vec using (Vec; []; _∷_; head; tail)
open import SizedIO.Console hiding (main)
open import Size
open import NativeIO
open import SizedIO.Base
StackStateˢ = ℕ
record Interfaceˢ : Set₁ where
field Stateˢ : Set
Methodˢ : (s : Stateˢ) → Set
Resultˢ : (s : Stateˢ) → (m : Methodˢ s) → Set
nextˢ : (s : Stateˢ) → (m : Methodˢ s) → (r : Resultˢ s m) → Stateˢ
open Interfaceˢ public
data StackMethodˢ (A : Set) : (n : StackStateˢ) → Set where
push : ∀ {n} → A → StackMethodˢ A n
pop : ∀ {n} → StackMethodˢ A (suc n)
StackResultˢ : (A : Set) → (s : StackStateˢ) → StackMethodˢ A s → Set
StackResultˢ A _ (push _) = Unit
StackResultˢ A _ pop = A
stackNextˢ : ∀ A n (m : StackMethodˢ A n) (r : StackResultˢ A n m) → StackStateˢ
stackNextˢ _ n (push _) _ = suc n
stackNextˢ _ (suc n) pop _ = n
StackInterfaceˢ : (A : Set) → Interfaceˢ
Stateˢ (StackInterfaceˢ A) = StackStateˢ
Methodˢ (StackInterfaceˢ A) = StackMethodˢ A
Resultˢ (StackInterfaceˢ A) = StackResultˢ A
nextˢ (StackInterfaceˢ A) = stackNextˢ A
record Objectˢ (I : Interfaceˢ) (s : Stateˢ I) : Set where
coinductive
field objectMethod : (m : Methodˢ I s) →
Σ[ r ∈ Resultˢ I s m ] Objectˢ I (nextˢ I s m r)
open Objectˢ public
record IOObjectˢ (Iᵢₒ : IOInterface) (I : Interfaceˢ) (s : Stateˢ I) : Set where
coinductive
field method : (m : Methodˢ I s) →
IO Iᵢₒ ∞ (Σ[ r ∈ Resultˢ I s m ] IOObjectˢ Iᵢₒ I (nextˢ I s m r))
open IOObjectˢ public
stack : ∀{A}{n : ℕ} (as : Vec A n) → Objectˢ (StackInterfaceˢ A) n
objectMethod (stack as) (push a) = unit , stack (a ∷ as)
objectMethod (stack (a ∷ as)) pop = a , stack as
|
{
"alphanum_fraction": 0.6078132927,
"avg_line_length": 32.85,
"ext": "agda",
"hexsha": "c15798218b907caa56370f53dfaffbcbbe78656a",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z",
"max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "agda/ooAgda",
"max_forks_repo_path": "examples/examplesPaperJFP/StatefulObject.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "agda/ooAgda",
"max_issues_repo_path": "examples/examplesPaperJFP/StatefulObject.agda",
"max_line_length": 91,
"max_stars_count": 23,
"max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "agda/ooAgda",
"max_stars_repo_path": "examples/examplesPaperJFP/StatefulObject.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z",
"num_tokens": 763,
"size": 1971
}
|
{-# OPTIONS --without-K --rewriting #-}
open import lib.Basics
open import lib.types.Coproduct
open import lib.types.Fin
open import lib.types.Pi
open import lib.types.Truncation
module lib.types.Choice where
unchoose : ∀ {i j} {n : ℕ₋₂} {A : Type i} {B : A → Type j}
→ Trunc n (Π A B) → Π A (Trunc n ∘ B)
unchoose = Trunc-rec (λ f → [_] ∘ f)
has-choice : ∀ {i} (n : ℕ₋₂) (A : Type i) j → Type (lmax i (lsucc j))
has-choice {i} n A j = (B : A → Type j) → is-equiv (unchoose {n = n} {A} {B})
Empty-has-choice : ∀ {n} {j} → has-choice n Empty j
Empty-has-choice {n} B = is-eq to from to-from from-to where
to = unchoose {n = n} {Empty} {B}
from : Π Empty (Trunc n ∘ B) → Trunc n (Π Empty B)
from _ = [ (λ{()}) ]
abstract
to-from : ∀ f → to (from f) == f
to-from _ = λ= λ{()}
from-to : ∀ f → from (to f) == f
from-to = Trunc-elim (λ _ → ap [_] (λ= λ{()}))
Unit-has-choice : ∀ {n} {j} → has-choice n Unit j
Unit-has-choice {n} B = is-eq to from to-from from-to where
to = unchoose {n = n} {Unit} {B}
Unit-elim' : B unit → Π Unit B
Unit-elim' u unit = u
from : Π Unit (Trunc n ∘ B) → Trunc n (Π Unit B)
from f = Trunc-fmap Unit-elim' (f unit)
abstract
to-from : ∀ f → to (from f) == f
to-from f = λ= λ{unit →
Trunc-elim
{P = λ f-unit → to (Trunc-fmap Unit-elim' f-unit) unit == f-unit}
(λ _ → idp)
(f unit)}
from-to : ∀ f → from (to f) == f
from-to = Trunc-elim (λ f → ap [_] (λ= λ{unit → idp}))
Coprod-has-choice : ∀ {i j} {n} {A : Type i} {B : Type j} {k}
→ has-choice n A k → has-choice n B k
→ has-choice n (A ⊔ B) k
Coprod-has-choice {n = n} {A} {B} A-hc B-hc C = is-eq to from to-from from-to where
A-unchoose = unchoose {n = n} {A} {C ∘ inl}
B-unchoose = unchoose {n = n} {B} {C ∘ inr}
module A-unchoose = is-equiv (A-hc (C ∘ inl))
module B-unchoose = is-equiv (B-hc (C ∘ inr))
to = unchoose {n = n} {A ⊔ B} {C}
from : Π (A ⊔ B) (Trunc n ∘ C) → Trunc n (Π (A ⊔ B) C)
from f = Trunc-fmap2 Coprod-elim (A-unchoose.g (f ∘ inl)) (B-unchoose.g (f ∘ inr))
abstract
to-from-inl' : ∀ f a → to (from f) (inl a) == A-unchoose (A-unchoose.g (f ∘ inl)) a
to-from-inl' f a = Trunc-elim
{P = λ f-inl → to (Trunc-fmap2 Coprod-elim f-inl (B-unchoose.g (f ∘ inr))) (inl a) == A-unchoose f-inl a}
(λ f-inl → Trunc-elim
{P = λ f-inr → to (Trunc-fmap2 Coprod-elim [ f-inl ] f-inr) (inl a) == [ f-inl a ]}
(λ f-inr → idp)
(B-unchoose.g (f ∘ inr)))
(A-unchoose.g (f ∘ inl))
to-from-inl : ∀ f a → to (from f) (inl a) == f (inl a)
to-from-inl f a = to-from-inl' f a ∙ app= (A-unchoose.f-g (f ∘ inl)) a
to-from-inr' : ∀ f b → to (from f) (inr b) == B-unchoose (B-unchoose.g (f ∘ inr)) b
to-from-inr' f b = Trunc-elim
{P = λ f-inr → to (Trunc-fmap2 Coprod-elim (A-unchoose.g (f ∘ inl)) f-inr) (inr b) == B-unchoose f-inr b}
(λ f-inr → Trunc-elim
{P = λ f-inl → to (Trunc-fmap2 Coprod-elim f-inl [ f-inr ]) (inr b) == [ f-inr b ]}
(λ f-inl → idp)
(A-unchoose.g (f ∘ inl)))
(B-unchoose.g (f ∘ inr))
to-from-inr : ∀ f b → to (from f) (inr b) == f (inr b)
to-from-inr f b = to-from-inr' f b ∙ app= (B-unchoose.f-g (f ∘ inr)) b
to-from : ∀ f → to (from f) == f
to-from f = λ= λ{(inl a) → to-from-inl f a; (inr b) → to-from-inr f b}
from-to : ∀ f → from (to f) == f
from-to = Trunc-elim
(λ f →
Trunc-fmap2 Coprod-elim (A-unchoose.g (λ a → [ f (inl a)])) (B-unchoose.g (λ b → [ f (inr b)]))
=⟨ ap2 (Trunc-fmap2 Coprod-elim) (A-unchoose.g-f [ f ∘ inl ]) (B-unchoose.g-f [ f ∘ inr ]) ⟩
[ Coprod-elim (f ∘ inl) (f ∘ inr) ]
=⟨ ap [_] $ λ= (λ{(inl _) → idp; (inr _) → idp}) ⟩
[ f ]
=∎)
equiv-preserves-choice : ∀ {i j} {n} {A : Type i} {B : Type j} (e : A ≃ B) {k}
→ has-choice n A k → has-choice n B k
equiv-preserves-choice {n = n} {A} {B} (f , f-ise) A-hc C = is-eq to from to-from from-to where
module f = is-equiv f-ise
A-unchoose = unchoose {n = n} {A} {C ∘ f}
module A-unchoose = is-equiv (A-hc (C ∘ f))
to = unchoose {n = n} {B} {C}
from' : Trunc n (Π A (C ∘ f)) → Trunc n (Π B C)
from' = Trunc-fmap (λ g' b → transport C (f.f-g b) (g' (f.g b)))
from : Π B (Trunc n ∘ C) → Trunc n (Π B C)
from g = from' (A-unchoose.g (g ∘ f))
abstract
to-from''' : ∀ (g-f' : Π A (C ∘ f)) {a a'} (path : f.g (f a) == a')
→ transport C (ap f path) (g-f' (f.g (f a))) == g-f' a'
to-from''' g-f' idp = idp
to-from'' : ∀ (g-f' : Π A (C ∘ f)) a
→ transport C (f.f-g (f a)) (g-f' (f.g (f a))) == g-f' a
to-from'' g-f' a =
transport C (f.f-g (f a)) (g-f' (f.g (f a)))
=⟨ ! $ ap (λ p → transport C p (g-f' (f.g (f a)))) (f.adj a) ⟩
transport C (ap f (f.g-f a)) (g-f' (f.g (f a)))
=⟨ to-from''' g-f' (f.g-f a) ⟩
g-f' a
=∎
to-from' : ∀ g a → to (from g) (f a) == A-unchoose (A-unchoose.g (g ∘ f)) a
to-from' g a =
Trunc-elim
{P = λ g-f → to (from' g-f) (f a) == A-unchoose g-f a}
(λ g-f' → ap [_] $ to-from'' g-f' a)
(A-unchoose.g (g ∘ f))
to-from : ∀ g → to (from g) == g
to-from g = λ= λ b → transport
(λ b → to (from g) b == g b)
(f.f-g b)
( to (from g) (f (f.g b))
=⟨ to-from' g (f.g b) ⟩
A-unchoose (A-unchoose.g (g ∘ f)) (f.g b)
=⟨ app= (A-unchoose.f-g (g ∘ f)) (f.g b) ⟩
g (f (f.g b))
=∎)
from-to' : ∀ g {b b'} (path : f (f.g b) == b')
→ transport C path (g (f (f.g b))) == g b'
from-to' g idp = idp
from-to : ∀ g → from (to g) == g
from-to = Trunc-elim
{P = λ g → from (to g) == g}
(λ g →
from' (A-unchoose.g (λ a → [ g (f a) ]))
=⟨ ap from' (A-unchoose.g-f [ (g ∘ f) ]) ⟩
from' [ (g ∘ f) ]
=⟨ ap [_] $ λ= (λ b → from-to' g (f.f-g b)) ⟩
[ g ]
=∎)
Fin-has-choice : ∀ (n : ℕ₋₂) {m} l → has-choice n (Fin m) l
Fin-has-choice _ {O} _ = equiv-preserves-choice
(Fin-equiv-Empty ⁻¹) Empty-has-choice
Fin-has-choice n {S m} l = equiv-preserves-choice
(Fin-equiv-Coprod ⁻¹) (Coprod-has-choice (Fin-has-choice n l) Unit-has-choice)
|
{
"alphanum_fraction": 0.49039858,
"avg_line_length": 35.6149425287,
"ext": "agda",
"hexsha": "062d0984c607752277fb5691986ede0c5e0a9de3",
"lang": "Agda",
"max_forks_count": 50,
"max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z",
"max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "timjb/HoTT-Agda",
"max_forks_repo_path": "core/lib/types/Choice.agda",
"max_issues_count": 31,
"max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "timjb/HoTT-Agda",
"max_issues_repo_path": "core/lib/types/Choice.agda",
"max_line_length": 111,
"max_stars_count": 294,
"max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "timjb/HoTT-Agda",
"max_stars_repo_path": "core/lib/types/Choice.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z",
"num_tokens": 2599,
"size": 6197
}
|
{- 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
-}
-- This module defines Outputs produced by handlers, as well as functions and properties relating
-- these to Yasm Actions.
open import LibraBFT.ImplShared.NetworkMsg
open import LibraBFT.ImplShared.Consensus.Types
open import Optics.All
open import Util.KVMap
open import Util.Prelude
open import Yasm.Types
module LibraBFT.ImplShared.Interface.Output where
data Output : Set where
--BroadcastEpochChangeProof : EpochChangeProof → List Author → Output -- TODO-1
BroadcastProposal : ProposalMsg → List Author → Output
BroadcastSyncInfo : SyncInfo → List Author → Output
LogErr : ErrLog → Output
LogInfo : InfoLog → Output
SendBRP : Author → BlockRetrievalResponse → Output
SendVote : VoteMsg → List Author → Output
open Output public
SendVote-inj-v : ∀ {x1 x2 y1 y2} → SendVote x1 y1 ≡ SendVote x2 y2 → x1 ≡ x2
SendVote-inj-v refl = refl
SendVote-inj-si : ∀ {x1 x2 y1 y2} → SendVote x1 y1 ≡ SendVote x2 y2 → y1 ≡ y2
SendVote-inj-si refl = refl
IsSendVote : Output → Set
IsSendVote (BroadcastProposal _ _) = ⊥
IsSendVote (BroadcastSyncInfo _ _) = ⊥
IsSendVote (LogErr _) = ⊥
IsSendVote (LogInfo _) = ⊥
IsSendVote (SendBRP _ _) = ⊥
IsSendVote (SendVote _ _) = ⊤
IsBroadcastProposal : Output → Set
IsBroadcastProposal (BroadcastProposal _ _) = ⊤
IsBroadcastProposal (BroadcastSyncInfo _ _) = ⊥
IsBroadcastProposal (LogErr _) = ⊥
IsBroadcastProposal (LogInfo _) = ⊥
IsBroadcastProposal (SendBRP _ _) = ⊥
IsBroadcastProposal (SendVote _ _) = ⊥
IsBroadcastSyncInfo : Output → Set
IsBroadcastSyncInfo (BroadcastProposal _ _) = ⊥
IsBroadcastSyncInfo (BroadcastSyncInfo _ _) = ⊤
IsBroadcastSyncInfo (LogErr _) = ⊥
IsBroadcastSyncInfo (LogInfo _) = ⊥
IsBroadcastSyncInfo (SendBRP _ _) = ⊥
IsBroadcastSyncInfo (SendVote _ _) = ⊥
IsLogErr : Output → Set
IsLogErr (BroadcastProposal _ _) = ⊥
IsLogErr (BroadcastSyncInfo _ _) = ⊥
IsLogErr (LogErr _) = ⊤
IsLogErr (LogInfo _) = ⊥
IsLogErr (SendBRP _ _) = ⊥
IsLogErr (SendVote _ _) = ⊥
logErrMB : Output → Maybe ErrLog
logErrMB (BroadcastProposal _ _) = nothing
logErrMB (BroadcastSyncInfo _ _) = nothing
logErrMB (LogErr e) = just e
logErrMB (LogInfo _) = nothing
logErrMB (SendBRP _ _) = nothing
logErrMB (SendVote _ _) = nothing
isSendVote? : (out : Output) → Dec (IsSendVote out)
isSendVote? (BroadcastProposal _ _) = no λ ()
isSendVote? (BroadcastSyncInfo _ _) = no λ ()
isSendVote? (LogErr _) = no λ ()
isSendVote? (LogInfo _) = no λ ()
isSendVote? (SendBRP _ _) = no λ ()
isSendVote? (SendVote mv pid) = yes tt
isBroadcastProposal? : (out : Output) → Dec (IsBroadcastProposal out)
isBroadcastProposal? (BroadcastProposal _ _) = yes tt
isBroadcastProposal? (BroadcastSyncInfo _ _) = no λ ()
isBroadcastProposal? (LogErr _) = no λ ()
isBroadcastProposal? (LogInfo _) = no λ ()
isBroadcastProposal? (SendBRP _ _) = no λ ()
isBroadcastProposal? (SendVote _ _) = no λ ()
isBroadcastSyncInfo? : (out : Output) → Dec (IsBroadcastSyncInfo out)
isBroadcastSyncInfo? (BroadcastProposal _ _) = no λ ()
isBroadcastSyncInfo? (BroadcastSyncInfo _ _) = yes tt
isBroadcastSyncInfo? (LogErr _) = no λ ()
isBroadcastSyncInfo? (LogInfo _) = no λ ()
isBroadcastSyncInfo? (SendBRP _ _) = no λ ()
isBroadcastSyncInfo? (SendVote _ _) = no λ ()
isLogErr? : (out : Output) → Dec (IsLogErr out)
isLogErr? (BroadcastProposal x _) = no λ ()
isLogErr? (BroadcastSyncInfo x _) = no λ ()
isLogErr? (LogErr x) = yes tt
isLogErr? (LogInfo x) = no λ ()
isLogErr? (SendBRP _ _) = no λ ()
isLogErr? (SendVote x x₁) = no λ ()
IsOutputMsg : Output → Set
IsOutputMsg = IsBroadcastProposal ∪ IsBroadcastSyncInfo ∪ IsSendVote
isOutputMsg? = isBroadcastProposal? ∪? (isBroadcastSyncInfo? ∪? isSendVote?)
data _Msg∈Out_ : NetworkMsg → Output → Set where
inBP : ∀ {pm pids} → P pm Msg∈Out BroadcastProposal pm pids
inSV : ∀ {vm pids} → V vm Msg∈Out SendVote vm pids
sendVote∉Output : ∀ {vm pid outs} → List-filter isSendVote? outs ≡ [] → ¬ (SendVote vm pid ∈ outs)
sendVote∉Output () (here refl)
sendVote∉Output{outs = x ∷ outs'} eq (there vm∈outs)
with isSendVote? x
... | no proof = sendVote∉Output eq vm∈outs
-- Note: the SystemModel allows anyone to receive any message sent, so intended recipient is ignored;
-- it is included in the model only to facilitate future work on liveness properties, when we will need
-- assumptions about message delivery between honest peers.
outputToActions : RoundManager → Output → List (Action NetworkMsg)
outputToActions rm (BroadcastProposal p rcvrs) = List-map (const (send (P p))) rcvrs
outputToActions _ (BroadcastSyncInfo _ _) = []
outputToActions _ (LogErr x) = []
outputToActions _ (LogInfo x) = []
outputToActions _ (SendVote vm rcvrs) = List-map (const (send (V vm))) rcvrs
outputToActions _ (SendBRP p brr) = [] -- TODO-1: Update `NetworkMsg`
outputsToActions : ∀ {State} → List Output → List (Action NetworkMsg)
outputsToActions {st} = concat ∘ List-map (outputToActions st)
-- Lemmas about `outputsToActions`
outputToActions-sendVote∉actions
: ∀ {out vm st} → ¬ (IsSendVote out) → ¬ (send (V vm) ∈ outputToActions st out)
outputToActions-sendVote∉actions {BroadcastProposal pm rcvrs}{vm}{st} ¬sv m∈acts =
help rcvrs m∈acts
where
help : ∀ xs → ¬ (send (V vm) ∈ List-map (const (send (P pm))) xs)
help (x ∷ xs) (there m∈acts) = help xs m∈acts
outputToActions-sendVote∉actions {SendVote _ _} ¬sv m∈acts = ¬sv tt
outputToActions-m∈sendVoteList
: ∀ {m vm rcvrs} → send m ∈ List-map (const $ send (V vm)) rcvrs
→ m Msg∈Out SendVote vm rcvrs
outputToActions-m∈sendVoteList {.(V vm)} {vm} {x ∷ rcvrs} (here refl) = inSV
outputToActions-m∈sendVoteList {m} {vm} {x ∷ rcvrs} (there m∈svl)
with outputToActions-m∈sendVoteList{rcvrs = rcvrs} m∈svl
... | inSV = inSV
outputToActions-m∈sendProposalList
: ∀ {m pm rcvrs} → send m ∈ List-map (const $ send (P pm)) rcvrs
→ m Msg∈Out BroadcastProposal pm rcvrs
outputToActions-m∈sendProposalList {.(P pm)} {pm} {x ∷ rcvrs} (here refl) = inBP
outputToActions-m∈sendProposalList {m} {pm} {x ∷ rcvrs} (there m∈spl)
with outputToActions-m∈sendProposalList {rcvrs = rcvrs} m∈spl
... | inBP = inBP
sendVote∉actions
: ∀ {outs vm st} → [] ≡ List-filter isSendVote? outs → ¬ (send (V vm) ∈ outputsToActions{st} outs)
sendVote∉actions {[]} {st = st} outs≡ ()
sendVote∉actions {x ∷ outs} {st = st} outs≡ m∈acts
with Any-++⁻ (outputToActions st x) m∈acts
... | Left m∈[]
with isSendVote? x
...| no proof = outputToActions-sendVote∉actions {st = st} proof m∈[]
sendVote∉actions {x ∷ outs} {st = st} outs≡ m∈acts | Right m∈acts'
with isSendVote? x
...| no proof = sendVote∉actions{outs = outs}{st = st} outs≡ m∈acts'
sendVote∈actions
: ∀ {vm vm' pids outs st} → SendVote vm pids ∷ [] ≡ List-filter isSendVote? outs
→ send (V vm') ∈ outputsToActions{st} outs
→ vm' ≡ vm
sendVote∈actions {outs = (BroadcastProposal x rcvrs) ∷ outs}{st = st} outs≡ m∈acts
with Any-++⁻ (outputToActions st (BroadcastProposal x rcvrs)) m∈acts
... | Left m∈[] = ⊥-elim (outputToActions-sendVote∉actions{out = BroadcastProposal x rcvrs}{st = st} id m∈[])
... | Right m∈acts' = sendVote∈actions{outs = outs}{st = st} outs≡ m∈acts'
sendVote∈actions {outs = (BroadcastSyncInfo x rcvrs) ∷ outs}{st = st} outs≡ m∈acts =
sendVote∈actions{outs = outs}{st = st} outs≡ m∈acts
sendVote∈actions {outs = LogErr x ∷ outs}{st = st} outs≡ m∈acts =
sendVote∈actions{outs = outs}{st = st} outs≡ m∈acts
sendVote∈actions {outs = LogInfo x ∷ outs}{st = st} outs≡ m∈acts =
sendVote∈actions{outs = outs}{st = st} outs≡ m∈acts
sendVote∈actions {vm}{vm'}{outs = SendBRP pid brr ∷ outs}{st = st} outs≡ m∈acts =
sendVote∈actions{outs = outs}{st = st} outs≡ m∈acts
sendVote∈actions {vm}{vm'}{outs = SendVote vm“ pids' ∷ outs}{st = st} outs≡ m∈acts
with ∷-injective outs≡
...| refl , tl≡
with Any-++⁻ (List-map (const (send (V vm“))) pids') m∈acts
... | Right m∈[] = ⊥-elim (sendVote∉actions{outs = outs}{st = st} tl≡ m∈[])
... | Left m∈acts' = help pids' m∈acts'
where
help : ∀ pids → send (V vm') ∈ List-map (const (send (V vm“))) pids → vm' ≡ vm“
help (_ ∷ pids) (here refl) = refl
help (_ ∷ pids) (there m∈acts) = help pids m∈acts
sendMsg∈actions
: ∀ {outs m st} → send m ∈ outputsToActions{st} outs
→ Σ[ out ∈ Output ] (out ∈ outs × m Msg∈Out out)
sendMsg∈actions {BroadcastProposal pm rcvrs ∷ outs} {m} {st} m∈acts
with Any-++⁻ (List-map (const $ send (P pm)) rcvrs) m∈acts
... | Left m∈bpl =
BroadcastProposal pm rcvrs , here refl , outputToActions-m∈sendProposalList m∈bpl
... | Right m∈acts'
with sendMsg∈actions{outs}{m}{st} m∈acts'
... | out , out∈outs , m∈out = out , there out∈outs , m∈out
-- NOTE: When we represent sending `BroadcastSyncInfo` as an action, this will require updating
sendMsg∈actions {BroadcastSyncInfo _ _ ∷ outs} {m} {st} m∈acts
with sendMsg∈actions{outs}{m}{st} m∈acts
...| out , out∈outs , m∈out = out , there out∈outs , m∈out
sendMsg∈actions {LogErr _ ∷ outs} {m} {st} m∈acts
with sendMsg∈actions{outs}{m}{st} m∈acts
...| out , out∈outs , m∈out = out , there out∈outs , m∈out
sendMsg∈actions {LogInfo _ ∷ outs} {m} {st} m∈acts
with sendMsg∈actions{outs}{m}{st} m∈acts
...| out , out∈outs , m∈out = out , there out∈outs , m∈out
sendMsg∈actions {SendBRP pid brr ∷ outs} {m} {st} m∈acts
with sendMsg∈actions{outs}{m}{st} m∈acts
...| out , out∈outs , m∈out = out , there out∈outs , m∈out
sendMsg∈actions {SendVote vm rcvrs ∷ outs} {m} {st} m∈acts
with Any-++⁻ (List-map (const (send (V vm))) rcvrs) m∈acts
... | Left m∈svl =
SendVote vm rcvrs , here refl , outputToActions-m∈sendVoteList m∈svl
... | Right m∈acts'
with sendMsg∈actions{outs}{m}{st} m∈acts'
... | out , out∈outs , m∈out = out , there out∈outs , m∈out
|
{
"alphanum_fraction": 0.6391810669,
"avg_line_length": 46.0952380952,
"ext": "agda",
"hexsha": "e153941886552aba726379a94a6c519a7d008d6a",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_forks_repo_licenses": [
"UPL-1.0"
],
"max_forks_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_forks_repo_path": "src/LibraBFT/ImplShared/Interface/Output.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"UPL-1.0"
],
"max_issues_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_issues_repo_path": "src/LibraBFT/ImplShared/Interface/Output.agda",
"max_line_length": 111,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_stars_repo_licenses": [
"UPL-1.0"
],
"max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_stars_repo_path": "src/LibraBFT/ImplShared/Interface/Output.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3678,
"size": 10648
}
|
----------------------------------------------------------------------
-- Copyright: 2013, Jan Stolarek, Lodz University of Technology --
-- --
-- License: See LICENSE file in root of the repo --
-- Repo address: https://github.com/jstolarek/dep-typed-wbl-heaps --
-- --
-- This module re-exports all Basics/* modules for convenience. --
-- Note that both Basics.Nat and Basics.Ordering define ≥ operator. --
-- Here we re-export the one from Basics.Ordering as it will be --
-- used most of the time. --
-- This module also defines two type synonyms that will be helpful --
-- when working on heaps: Rank and Priority. --
----------------------------------------------------------------------
module Basics where
open import Basics.Bool public
open import Basics.Nat public hiding (_≥_)
open import Basics.Ordering public
open import Basics.Reasoning public
-- Rank of a weight biased leftist heap is defined as number of nodes
-- in a heap. In other words it is size of a tree used to represent a
-- heap.
Rank : Set
Rank = Nat
-- Priority assigned to elements stored in a Heap.
--
-- CONVENTION: Lower number means higher Priority. Therefore the
-- highest Priority is zero. It will sometimes be more convenient not
-- to use this inversed terminology. We will then use terms "smaller"
-- and "greater" (in contrast to "lower" and "higher"). Example:
-- Priority 3 is higher than 5, but 3 is smaller than 5.
Priority : Set
Priority = Nat
-- Note that both Rank and Priority are Nat, which allows us to
-- operate on them with functions that work for Nat.
|
{
"alphanum_fraction": 0.5759423503,
"avg_line_length": 45.1,
"ext": "agda",
"hexsha": "315e509ac62ab88dbb411c87ff8a978479ac3aca",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "57db566cb840dc70331c29eb7bf3a0c849f8b27e",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "jstolarek/dep-typed-wbl-heaps",
"max_forks_repo_path": "src/Basics.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "57db566cb840dc70331c29eb7bf3a0c849f8b27e",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "jstolarek/dep-typed-wbl-heaps",
"max_issues_repo_path": "src/Basics.agda",
"max_line_length": 70,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "57db566cb840dc70331c29eb7bf3a0c849f8b27e",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "jstolarek/dep-typed-wbl-heaps",
"max_stars_repo_path": "src/Basics.agda",
"max_stars_repo_stars_event_max_datetime": "2018-05-02T21:48:43.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-05-02T21:48:43.000Z",
"num_tokens": 357,
"size": 1804
}
|
module Example where
open import Data.List
-- reverse
rev : ∀ {a} {A : Set a} → List A → List A
rev [] = []
rev (x ∷ xs) = rev xs ++ [ x ]
-- https://code.google.com/p/agda/issues/detail?id=1252 暫定対策
rev' = rev
{-# COMPILED_EXPORT rev' rev' #-}
private
open import Relation.Binary.PropositionalEquality
-- reverse2回で元に戻る証明
lemma : ∀ {a} {A : Set a} (x : A) (xs : List A) → rev (xs ∷ʳ x) ≡ x ∷ rev xs
lemma x [] = refl
lemma x (_ ∷ xs)
rewrite lemma x xs
= refl
revrev-is-id : ∀ {a} {A : Set a} (xs : List A) → rev (rev xs) ≡ xs
revrev-is-id [] = refl
revrev-is-id (x ∷ xs)
rewrite lemma x (rev xs)
| revrev-is-id xs
= refl
open import Data.Empty
head : ∀ {a} {A : Set a} (xs : List A) → {xs≢[] : xs ≢ []} → A
head [] {xs≠[]} = ⊥-elim (xs≠[] refl)
head (x ∷ xs) = x
{-
{-# COMPILED_EXPORT head safeHead' #-}
-- エラーになる
-- The type _≡_ cannot be translated to a Haskell type.
-- when checking the pragma COMPILED_EXPORT head' safeHead
--
-- つまり,証明オブジェクトを取るような関数は,
-- そのままではCOMPILED_EXPORTできないことが多い
-}
open import Data.Maybe
head' : ∀ {a} {A : Set a} (xs : List A) → Maybe A
head' = go where
go : ∀ {a} {A : Set a} (xs : List A) → Maybe A
go [] = nothing
go (x ∷ xs) = just (head (x ∷ xs) {λ ()})
{-# COMPILED_EXPORT head' safeHead' #-}
-- つまり,安全なheadを使うには,
-- 安全なものだけ渡せるようにしてjustで結果が得られ,
-- それ以外についてはnothingになるように,
-- 適切にラップしないとCOMPILED_EXPORTできない.
|
{
"alphanum_fraction": 0.5918079096,
"avg_line_length": 24.4137931034,
"ext": "agda",
"hexsha": "39944a3437468127a76da36bdc6b24df553b4319",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "9ad77d2aed8f950151e009135a9dfc02bc32ce65",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "notogawa/agda-haskell-example",
"max_forks_repo_path": "src/Example.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9ad77d2aed8f950151e009135a9dfc02bc32ce65",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "notogawa/agda-haskell-example",
"max_issues_repo_path": "src/Example.agda",
"max_line_length": 78,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "9ad77d2aed8f950151e009135a9dfc02bc32ce65",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "notogawa/agda-haskell-example",
"max_stars_repo_path": "src/Example.agda",
"max_stars_repo_stars_event_max_datetime": "2017-11-07T01:35:46.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-07-28T05:04:58.000Z",
"num_tokens": 600,
"size": 1416
}
|
module Issue4373.A where
postulate
T : Set
instance t : T
|
{
"alphanum_fraction": 0.6875,
"avg_line_length": 9.1428571429,
"ext": "agda",
"hexsha": "9a8ae940936d8b376be9601d733037f5633eca88",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "shlevy/agda",
"max_forks_repo_path": "test/Fail/Issue4373/A.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Fail/Issue4373/A.agda",
"max_line_length": 24,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/Issue4373/A.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 22,
"size": 64
}
|
module Languages.ILL.TypeSyntax where
open import bool
open import Utils.HaskellTypes
{-# IMPORT Languages.ILL.TypeSyntax #-}
data Type : Set where
TVar : String → Type
Top : Type
Imp : Type → Type → Type
Tensor : Type → Type → Type
Bang : Type → Type
{-# COMPILED_DATA Type Languages.ILL.TypeSyntax.Type
Languages.ILL.TypeSyntax.TVar
Languages.ILL.TypeSyntax.Top
Languages.ILL.TypeSyntax.Imp
Languages.ILL.TypeSyntax.Tensor
Languages.ILL.TypeSyntax.Bang #-}
_eq-type_ : Type → Type → 𝔹
(TVar _) eq-type (TVar _) = tt
Top eq-type Top = tt
(Imp A C) eq-type (Imp B D) = (A eq-type B) && (C eq-type D)
(Tensor A C) eq-type (Tensor B D) = (A eq-type B) && (C eq-type D)
(Bang A) eq-type (Bang B) = A eq-type B
_ eq-type _ = ff
|
{
"alphanum_fraction": 0.5937136205,
"avg_line_length": 28.6333333333,
"ext": "agda",
"hexsha": "cf5f830a2d5478a18e97e4b99484cbca779a6bdd",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "c83f5d8201362b26a749138f6dbff2dd509f85b1",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "heades/Agda-LLS",
"max_forks_repo_path": "Source/ALL/Languages/ILL/TypeSyntax.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "c83f5d8201362b26a749138f6dbff2dd509f85b1",
"max_issues_repo_issues_event_max_datetime": "2017-04-05T17:30:16.000Z",
"max_issues_repo_issues_event_min_datetime": "2017-03-27T14:52:46.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "heades/Agda-LLS",
"max_issues_repo_path": "Source/ALL/Languages/ILL/TypeSyntax.agda",
"max_line_length": 66,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "c83f5d8201362b26a749138f6dbff2dd509f85b1",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "heades/Agda-LLS",
"max_stars_repo_path": "Source/ALL/Languages/ILL/TypeSyntax.agda",
"max_stars_repo_stars_event_max_datetime": "2019-08-02T23:41:23.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-04-09T20:53:53.000Z",
"num_tokens": 232,
"size": 859
}
|
-- Andreas, 2017-01-21, issue #2422 overloading inherited projections
-- {-# OPTIONS -v tc.proj.amb:100 #-}
-- {-# OPTIONS -v tc.mod.apply:100 #-}
postulate
A : Set
record R : Set where
field f : A
record S : Set where
field r : R
open R r public
-- The inherited projection (in the eyes of the scope checker) S.f
-- is actually a composition of projections R.f ∘ S.r
-- s .S.f = s .S.r .R.f
open R -- works without this
open S
test : S → A
test s = f s
-- f is not really a projection, but a composition of projections
-- it would be nice if overloading is still allowed.
-- Error WAS:
-- Cannot resolve overloaded projection f because no matching candidate found
|
{
"alphanum_fraction": 0.6729377713,
"avg_line_length": 23.8275862069,
"ext": "agda",
"hexsha": "1acb6ac5c1a7d786d71be3b137491b01288e1fcc",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Succeed/Issue2422.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Succeed/Issue2422.agda",
"max_line_length": 77,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/Issue2422.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 197,
"size": 691
}
|
{- Type class for functors. -}
module CategoryTheory.Functor where
open import CategoryTheory.Categories
open import Relation.Binary
-- Functor between two categories
record Functor {n} (ℂ : Category n) (𝔻 : Category n) : Set (lsuc n) where
private module ℂ = Category ℂ
private module 𝔻 = Category 𝔻
field
-- || Definitions
-- Object map
omap : ℂ.obj -> 𝔻.obj
-- Arrow map
fmap : ∀{A B : ℂ.obj} -> (A ℂ.~> B) -> (omap A 𝔻.~> omap B)
-- || Laws
-- Functor preseres identities
fmap-id : ∀{A : ℂ.obj} -> fmap (ℂ.id {A}) 𝔻.≈ 𝔻.id
-- Functor preserves composition
fmap-∘ : ∀{A B C : ℂ.obj} {g : B ℂ.~> C} {f : A ℂ.~> B}
-> fmap (g ℂ.∘ f) 𝔻.≈ fmap g 𝔻.∘ fmap f
-- Congruence of equality and fmap
fmap-cong : ∀{A B : ℂ.obj} {f f′ : A ℂ.~> B}
-> f ℂ.≈ f′ -> fmap f 𝔻.≈ fmap f′
-- Type synonym for endofunctors
Endofunctor : ∀{n} -> Category n -> Set (lsuc n)
Endofunctor ℂ = Functor ℂ ℂ
-- Identity functor
I : ∀ {n} {ℂ : Category n} -> Endofunctor ℂ
I {n} {ℂ} = record { omap = λ a → a
; fmap = λ a → a
; fmap-id = IsEquivalence.refl (Category.≈-equiv ℂ)
; fmap-∘ = IsEquivalence.refl (Category.≈-equiv ℂ)
; fmap-cong = λ p → p }
-- Functors are closed under composition.
infixl 40 _◯_
_◯_ : ∀ {n} {𝔸 𝔹 ℂ : Category n} -> Functor 𝔹 ℂ -> Functor 𝔸 𝔹 -> Functor 𝔸 ℂ
_◯_ {n} {𝔸} {𝔹} {ℂ} G F =
record { omap = λ a → G.omap (F.omap a)
; fmap = λ f → G.fmap (F.fmap f)
; fmap-id = fmap-◯-id
; fmap-∘ = fmap-◯-∘
; fmap-cong = λ p → G.fmap-cong (F.fmap-cong p)}
where private module F = Functor F
private module G = Functor G
private module 𝔸 = Category 𝔸
private module 𝔹 = Category 𝔹
open Category ℂ
fmap-◯-id : ∀{A : 𝔸.obj} -> G.fmap (F.fmap (𝔸.id {A})) ≈ id
fmap-◯-id {A} =
begin
G.fmap (F.fmap (𝔸.id))
≈⟨ G.fmap-cong (F.fmap-id) ⟩
G.fmap (𝔹.id)
≈⟨ G.fmap-id ⟩
id
∎
fmap-◯-∘ : ∀{A B C : 𝔸.obj} {g : B 𝔸.~> C} {f : A 𝔸.~> B}
-> G.fmap (F.fmap (g 𝔸.∘ f)) ≈
G.fmap (F.fmap g) ∘ G.fmap (F.fmap f)
fmap-◯-∘ {A} {g = g} {f = f} =
begin
G.fmap (F.fmap (g 𝔸.∘ f))
≈⟨ G.fmap-cong (F.fmap-∘) ⟩
G.fmap ((F.fmap g) 𝔹.∘ (F.fmap f))
≈⟨ G.fmap-∘ ⟩
G.fmap (F.fmap g) ∘ G.fmap (F.fmap f)
∎
-- Endofunctor tensor product
infixl 40 _⨂_
_⨂_ : ∀ {n} {ℂ : Category n} -> Endofunctor ℂ -> Endofunctor ℂ -> Endofunctor ℂ
(T ⨂ S) = T ◯ S
-- Square and cube of an endofunctor
_² : ∀ {n} {ℂ : Category n} -> Endofunctor ℂ -> Endofunctor ℂ
F ² = F ⨂ F
_³ : ∀ {n} {ℂ : Category n} -> Endofunctor ℂ -> Endofunctor ℂ
F ³ = F ⨂ F ⨂ F
|
{
"alphanum_fraction": 0.4648862512,
"avg_line_length": 33.7,
"ext": "agda",
"hexsha": "3cf4df50b39e01d9cc283ff90d96af91180b1cff",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DimaSamoz/temporal-type-systems",
"max_forks_repo_path": "src/CategoryTheory/Functor.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DimaSamoz/temporal-type-systems",
"max_issues_repo_path": "src/CategoryTheory/Functor.agda",
"max_line_length": 79,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DimaSamoz/temporal-type-systems",
"max_stars_repo_path": "src/CategoryTheory/Functor.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-04T09:33:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-05-31T20:37:04.000Z",
"num_tokens": 1179,
"size": 3033
}
|
module Issue3579 where
open import Agda.Builtin.String
open import Agda.Builtin.Reflection
data _==_ {A : Set} (a : A) : A → Set where
refl : a == a
{-# BUILTIN EQUALITY _==_ #-}
|
{
"alphanum_fraction": 0.6630434783,
"avg_line_length": 18.4,
"ext": "agda",
"hexsha": "c847f35dcc3ed1114edc2725ff84bf8973fb5caf",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Succeed/Issue3579.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Succeed/Issue3579.agda",
"max_line_length": 43,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/Issue3579.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 58,
"size": 184
}
|
{-# OPTIONS --safe --without-K #-}
module Literals.Number where
open import Agda.Builtin.FromNat public
|
{
"alphanum_fraction": 0.7358490566,
"avg_line_length": 17.6666666667,
"ext": "agda",
"hexsha": "2c413a597a57032e59bde2af69488bf24186b668",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z",
"max_forks_repo_head_hexsha": "9c5e8b6f546bee952e92db0b73bfc12592bf3152",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/masters-thesis",
"max_forks_repo_path": "agda/Literals/Number.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9c5e8b6f546bee952e92db0b73bfc12592bf3152",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "oisdk/masters-thesis",
"max_issues_repo_path": "agda/Literals/Number.agda",
"max_line_length": 39,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/agda-playground",
"max_stars_repo_path": "Literals/Number.agda",
"max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z",
"num_tokens": 24,
"size": 106
}
|
module BTree.Complete.Alternative.Properties {A : Set} where
open import BTree {A}
open import BTree.Equality {A}
open import BTree.Equality.Properties {A}
open import BTree.Complete.Alternative {A}
open import Data.Sum renaming (_⊎_ to _∨_)
lemma-⋗-≃ : {t t' t'' : BTree} → t ⋗ t' → t' ≃ t'' → t ⋗ t''
lemma-⋗-≃ (⋗lf x) ≃lf = ⋗lf x
lemma-⋗-≃ (⋗nd x x' l≃r l'≃r' l⋗l') (≃nd .x' x'' _ l''≃r'' l'≃l'') = ⋗nd x x'' l≃r l'≃l'' (lemma-⋗-≃ l⋗l' l''≃r'')
lemma-≃-⋘ : {l r : BTree} → l ≃ r → l ⋘ r
lemma-≃-⋘ ≃lf = lf⋘
lemma-≃-⋘ (≃nd x x' l≃r l≃l' l'≃r') = ll⋘ x x' (lemma-≃-⋘ l≃r) l'≃r' (trans≃ (symm≃ l≃r) l≃l')
lemma-⋗-⋙ : {l r : BTree} → l ⋗ r → l ⋙ r
lemma-⋗-⋙ (⋗lf x) = ⋙lf x
lemma-⋗-⋙ (⋗nd x x' l≃r l'≃r' l⋗l') = ⋙rl x x' l≃r (lemma-≃-⋘ l'≃r') (lemma-⋗-≃ l⋗l' l'≃r')
|
{
"alphanum_fraction": 0.5071151358,
"avg_line_length": 36.8095238095,
"ext": "agda",
"hexsha": "0e952dc79b8e163f2c2ab3e79943edfe3f6c7c9e",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bgbianchi/sorting",
"max_forks_repo_path": "agda/BTree/Complete/Alternative/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "bgbianchi/sorting",
"max_issues_repo_path": "agda/BTree/Complete/Alternative/Properties.agda",
"max_line_length": 114,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bgbianchi/sorting",
"max_stars_repo_path": "agda/BTree/Complete/Alternative/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z",
"num_tokens": 486,
"size": 773
}
|
open import Relation.Binary.PropositionalEquality using ( refl )
open import Web.Semantic.DL.ABox.Interp using ( Interp ; ⌊_⌋ ; ind ; _*_ )
open import Web.Semantic.DL.ABox.Model using
( _⊨a_ ; ⊨a-resp-≡³ ; ⊨a-impl-⊨b ; ⊨b-impl-⊨a
; _,_ ; inb ; on-bnode ; bnodes )
open import Web.Semantic.DL.Category.Object using ( Object ; IN ; iface )
open import Web.Semantic.DL.Category.Morphism using
( _⇒_ ; _,_ ; BN ; impl ; _⊑_ ; _≣_ )
open import Web.Semantic.DL.KB using ( _,_ )
open import Web.Semantic.DL.KB.Model using ( _⊨_ )
open import Web.Semantic.DL.Signature using ( Signature )
open import Web.Semantic.DL.TBox using ( TBox ; _,_ )
open import Web.Semantic.DL.TBox.Interp using ( Δ )
open import Web.Semantic.Util using ( _⊕_⊕_ ; inode )
module Web.Semantic.DL.Category.Properties.Equivalence
{Σ : Signature} {S T : TBox Σ} where
⊑-refl : ∀ {A B : Object S T} (F : A ⇒ B) → (F ⊑ F)
⊑-refl F I I⊨STA I⊨F = ⊨a-impl-⊨b I (impl F) I⊨F
⊑-trans : ∀ {A B : Object S T} (F G H : A ⇒ B) → (F ⊑ G) → (G ⊑ H) → (F ⊑ H)
⊑-trans {A} {B} F G H F⊑G G⊑H I I⊨STA I⊨F = (g , I⊨H) where
f : BN G → Δ ⌊ I ⌋
f = inb (F⊑G I I⊨STA I⊨F)
J : Interp Σ (IN A ⊕ BN G ⊕ IN B)
J = bnodes I f
J⊨STA : inode * J ⊨ (S , T) , iface A
J⊨STA = I⊨STA
J⊨G : J ⊨a impl G
J⊨G = ⊨b-impl-⊨a (F⊑G I I⊨STA I⊨F)
g : BN H → Δ ⌊ I ⌋
g = inb (G⊑H J J⊨STA J⊨G)
K : Interp Σ (IN A ⊕ BN H ⊕ IN B)
K = bnodes J g
K⊨H : K ⊨a impl H
K⊨H = ⊨b-impl-⊨a (G⊑H J J⊨STA J⊨G)
I⊨H : bnodes I g ⊨a impl H
I⊨H = ⊨a-resp-≡³ K (on-bnode g (ind I)) refl (impl H) K⊨H
≣-refl : ∀ {A B : Object S T} (F : A ⇒ B) → (F ≣ F)
≣-refl F = (⊑-refl F , ⊑-refl F)
≣-sym : ∀ {A B : Object S T} {F G : A ⇒ B} → (F ≣ G) → (G ≣ F)
≣-sym (F⊑G , G⊑F) = (G⊑F , F⊑G)
≣-trans : ∀ {A B : Object S T} {F G H : A ⇒ B} → (F ≣ G) → (G ≣ H) → (F ≣ H)
≣-trans {A} {B} {F} {G} {H} (F⊑G , G⊑F) (G⊑H , H⊑G) =
(⊑-trans F G H F⊑G G⊑H , ⊑-trans H G F H⊑G G⊑F)
|
{
"alphanum_fraction": 0.5418181818,
"avg_line_length": 33.1896551724,
"ext": "agda",
"hexsha": "8aeb57b69bd2900a0cb0583210901254c227d839",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:03.000Z",
"max_forks_repo_forks_event_min_datetime": "2017-12-03T14:52:09.000Z",
"max_forks_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "agda/agda-web-semantic",
"max_forks_repo_path": "src/Web/Semantic/DL/Category/Properties/Equivalence.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab",
"max_issues_repo_issues_event_max_datetime": "2021-01-04T20:57:19.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T02:32:28.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "agda/agda-web-semantic",
"max_issues_repo_path": "src/Web/Semantic/DL/Category/Properties/Equivalence.agda",
"max_line_length": 77,
"max_stars_count": 9,
"max_stars_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "agda/agda-web-semantic",
"max_stars_repo_path": "src/Web/Semantic/DL/Category/Properties/Equivalence.agda",
"max_stars_repo_stars_event_max_datetime": "2020-03-14T14:21:08.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-13T17:46:41.000Z",
"num_tokens": 1032,
"size": 1925
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Some properties imply others
------------------------------------------------------------------------
-- This file contains some core definitions which are reexported by
-- Relation.Binary.Consequences.
module Relation.Binary.Consequences.Core where
open import Relation.Binary.Core
open import Data.Product
subst⟶resp₂ : ∀ {a ℓ p} {A : Set a} {∼ : Rel A ℓ}
(P : Rel A p) → Substitutive ∼ p → P Respects₂ ∼
subst⟶resp₂ {∼ = ∼} P subst =
(λ {x _ _} y'∼y Pxy' → subst (P x) y'∼y Pxy') ,
(λ {y _ _} x'∼x Px'y → subst (λ x → P x y) x'∼x Px'y)
|
{
"alphanum_fraction": 0.4889217134,
"avg_line_length": 33.85,
"ext": "agda",
"hexsha": "515c0dd91286d79042d2924f585171900ec09c63",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "qwe2/try-agda",
"max_forks_repo_path": "agda-stdlib-0.9/src/Relation/Binary/Consequences/Core.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "qwe2/try-agda",
"max_issues_repo_path": "agda-stdlib-0.9/src/Relation/Binary/Consequences/Core.agda",
"max_line_length": 72,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "qwe2/try-agda",
"max_stars_repo_path": "agda-stdlib-0.9/src/Relation/Binary/Consequences/Core.agda",
"max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z",
"num_tokens": 188,
"size": 677
}
|
{-# OPTIONS --without-K --safe #-}
module Data.Binary.Addition where
open import Data.Binary.Definition
open import Data.Binary.Increment
add₁ : 𝔹 → 𝔹 → 𝔹
add₂ : 𝔹 → 𝔹 → 𝔹
add₁ 0ᵇ ys = inc ys
add₁ (1ᵇ xs) 0ᵇ = 2ᵇ xs
add₁ (2ᵇ xs) 0ᵇ = 1ᵇ inc xs
add₁ (1ᵇ xs) (1ᵇ ys) = 1ᵇ add₁ xs ys
add₁ (1ᵇ xs) (2ᵇ ys) = 2ᵇ add₁ xs ys
add₁ (2ᵇ xs) (1ᵇ ys) = 2ᵇ add₁ xs ys
add₁ (2ᵇ xs) (2ᵇ ys) = 1ᵇ add₂ xs ys
add₂ 0ᵇ 0ᵇ = 2ᵇ 0ᵇ
add₂ 0ᵇ (1ᵇ ys) = 1ᵇ inc ys
add₂ 0ᵇ (2ᵇ ys) = 2ᵇ inc ys
add₂ (1ᵇ xs) 0ᵇ = 1ᵇ inc xs
add₂ (2ᵇ xs) 0ᵇ = 2ᵇ inc xs
add₂ (1ᵇ xs) (1ᵇ ys) = 2ᵇ add₁ xs ys
add₂ (1ᵇ xs) (2ᵇ ys) = 1ᵇ add₂ xs ys
add₂ (2ᵇ xs) (1ᵇ ys) = 1ᵇ add₂ xs ys
add₂ (2ᵇ xs) (2ᵇ ys) = 2ᵇ add₂ xs ys
infixl 6 _+_
_+_ : 𝔹 → 𝔹 → 𝔹
0ᵇ + ys = ys
1ᵇ xs + 0ᵇ = 1ᵇ xs
2ᵇ xs + 0ᵇ = 2ᵇ xs
1ᵇ xs + 1ᵇ ys = 2ᵇ (xs + ys)
1ᵇ xs + 2ᵇ ys = 1ᵇ add₁ xs ys
2ᵇ xs + 1ᵇ ys = 1ᵇ add₁ xs ys
2ᵇ xs + 2ᵇ ys = 2ᵇ add₁ xs ys
|
{
"alphanum_fraction": 0.5639658849,
"avg_line_length": 24.6842105263,
"ext": "agda",
"hexsha": "a40c889fdd58f89384bddb5afe94bab27b572f84",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z",
"max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/agda-playground",
"max_forks_repo_path": "Data/Binary/Addition.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "oisdk/agda-playground",
"max_issues_repo_path": "Data/Binary/Addition.agda",
"max_line_length": 36,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/agda-playground",
"max_stars_repo_path": "Data/Binary/Addition.agda",
"max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z",
"num_tokens": 624,
"size": 938
}
|
--
-- Created by Dependently-Typed Lambda Calculus on 2020-09-24
-- Equal
-- Author: dplaindoux
--
module Equal where
open import Data.Nat using (ℕ; zero; suc)
open import Data.Bool using (Bool; true; false)
infix 30 _=?_
data Type : Set where
nat : Type
▲_ : Type → Set
▲ nat = ℕ
_=?_ : { a : Type } → ▲ a → ▲ a → Bool
_=?_ {nat} zero zero = true
_=?_ {nat} (suc m) (suc n) = m =? n
_=?_ {nat} _ _ = false
Nat :
∀self(P : Nat → Set) →
∀(zero : P(λz. λs. z)) →
∀(succ : ∀(n : Nat) → P (λz. λs. s n)) →
P self
|
{
"alphanum_fraction": 0.5409836066,
"avg_line_length": 17.7096774194,
"ext": "agda",
"hexsha": "1c45bfc7ca5528c76a40b182c55d12aba50ea34b",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "a81447af3ab2ba898bb7d57be71369abbba12d81",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "d-plaindoux/colca",
"max_forks_repo_path": "src/exercices/Equal.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a81447af3ab2ba898bb7d57be71369abbba12d81",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "d-plaindoux/colca",
"max_issues_repo_path": "src/exercices/Equal.agda",
"max_line_length": 61,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "a81447af3ab2ba898bb7d57be71369abbba12d81",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "d-plaindoux/colca",
"max_stars_repo_path": "src/exercices/Equal.agda",
"max_stars_repo_stars_event_max_datetime": "2021-05-04T09:35:36.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-03-12T18:31:14.000Z",
"num_tokens": 221,
"size": 549
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Convenient syntax for "equational reasoning" in multiple Setoids
------------------------------------------------------------------------
-- Example use:
--
-- open import Data.Maybe
-- open import Relation.Binary.Reasoning.MultiSetoid
--
-- begin⟨ S ⟩
-- x ≈⟨ drop-just (begin⟨ setoid S ⟩
-- just x ≈⟨ justx≈mz ⟩
-- mz ≈⟨ mz≈justy ⟩
-- just y ∎)⟩
-- y ≈⟨ y≈z ⟩
-- z ∎
{-# OPTIONS --without-K --safe #-}
module Relation.Binary.Reasoning.MultiSetoid where
open import Relation.Binary
open import Relation.Binary.Reasoning.Setoid as EqR using (_IsRelatedTo_)
open import Relation.Binary.PropositionalEquality
open Setoid renaming (_≈_ to [_]_≈_)
infix 1 begin⟨_⟩_
infixr 2 _≈⟨_⟩_ _≡⟨_⟩_ _≡˘⟨_⟩_ _≡⟨⟩_
infix 3 _∎
begin⟨_⟩_ : ∀ {c l} (S : Setoid c l) {x y} → _IsRelatedTo_ S x y → [ S ] x ≈ y
begin⟨_⟩_ S p = EqR.begin_ S p
_≈⟨_⟩_ : ∀ {c l} {S : Setoid c l} x {y z} → [ S ] x ≈ y → _IsRelatedTo_ S y z → _IsRelatedTo_ S x z
_≈⟨_⟩_ {S = S} = EqR._≈⟨_⟩_ S
_≡⟨_⟩_ : ∀ {c l} {S : Setoid c l} x {y z} → x ≡ y → _IsRelatedTo_ S y z → _IsRelatedTo_ S x z
_≡⟨_⟩_ {S = S} = EqR._≡⟨_⟩_ S
_≡˘⟨_⟩_ : ∀ {c l} {S : Setoid c l} x {y z} → y ≡ x → _IsRelatedTo_ S y z → _IsRelatedTo_ S x z
_≡˘⟨_⟩_ {S = S} = EqR._≡˘⟨_⟩_ S
_≡⟨⟩_ : ∀ {c l} {S : Setoid c l} x {y} → _IsRelatedTo_ S x y → _IsRelatedTo_ S x y
_≡⟨⟩_ {S = S} = EqR._≡⟨⟩_ S
_∎ : ∀ {c l} {S : Setoid c l} x → _IsRelatedTo_ S x x
_∎ {S = S} = EqR._∎ S
|
{
"alphanum_fraction": 0.5189466924,
"avg_line_length": 30.5294117647,
"ext": "agda",
"hexsha": "99c17301370b8c96e2c1da6abe3f7993ff902ab5",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "omega12345/agda-mode",
"max_forks_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Reasoning/MultiSetoid.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "omega12345/agda-mode",
"max_issues_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Reasoning/MultiSetoid.agda",
"max_line_length": 99,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Reasoning/MultiSetoid.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 676,
"size": 1557
}
|
{-# OPTIONS --warning=error --safe --without-K #-}
open import LogicalFormulae
open import Lists.Lists
open import Numbers.Naturals.Semiring
open import Numbers.Naturals.Naturals
open import Numbers.Naturals.Order
open import Numbers.BinaryNaturals.Definition
open import Numbers.BinaryNaturals.Addition
open import Numbers.BinaryNaturals.SubtractionGo
open import Numbers.BinaryNaturals.SubtractionGoPreservesCanonicalRight
open import Orders.Total.Definition
open import Semirings.Definition
open import Maybe
module Numbers.BinaryNaturals.Subtraction where
private
aMinusAGo : (a : BinNat) → mapMaybe canonical (go zero a a) ≡ yes []
aMinusAGo [] = refl
aMinusAGo (zero :: a) with aMinusAGo a
... | bl with go zero a a
aMinusAGo (zero :: a) | bl | yes x rewrite yesInjective bl = refl
aMinusAGo (one :: a) with aMinusAGo a
... | bl with go zero a a
aMinusAGo (one :: a) | bl | yes x rewrite yesInjective bl = refl
aMinusALemma : (a : BinNat) → mapMaybe canonical (mapMaybe (_::_ zero) (go zero a a)) ≡ yes []
aMinusALemma a with inspect (go zero a a)
aMinusALemma a | no with≡ x with aMinusAGo a
... | r rewrite x = exFalso (noNotYes r)
aMinusALemma a | yes xs with≡ pr with inspect (canonical xs)
aMinusALemma a | yes xs with≡ pr | [] with≡ pr2 rewrite pr | pr2 = refl
aMinusALemma a | yes xs with≡ pr | (x :: t) with≡ pr2 with aMinusAGo a
... | b rewrite pr | pr2 = exFalso (nonEmptyNotEmpty (yesInjective b))
aMinusA : (a : BinNat) → mapMaybe canonical (a -B a) ≡ yes []
aMinusA [] = refl
aMinusA (zero :: a) = aMinusALemma a
aMinusA (one :: a) = aMinusALemma a
goOne : (a b : BinNat) → mapMaybe canonical (go one (incr a) b) ≡ mapMaybe canonical (go zero a b)
goOne [] [] = refl
goOne [] (zero :: b) with inspect (go zero [] b)
goOne [] (zero :: b) | no with≡ pr rewrite pr = refl
goOne [] (zero :: b) | yes x with≡ pr with goZeroEmpty b pr
... | t with inspect (canonical x)
goOne [] (zero :: b) | yes x with≡ pr | t | [] with≡ pr2 rewrite pr | pr2 = refl
goOne [] (zero :: b) | yes x with≡ pr | t | (x₁ :: y) with≡ pr2 with goZeroEmpty' b pr
... | bl = exFalso (nonEmptyNotEmpty (transitivity (equalityCommutative pr2) bl))
goOne [] (one :: b) with inspect (go one [] b)
goOne [] (one :: b) | no with≡ pr rewrite pr = refl
goOne [] (one :: b) | yes x with≡ pr = exFalso (goOneEmpty b pr)
goOne (zero :: a) [] = refl
goOne (zero :: a) (zero :: b) = refl
goOne (zero :: a) (one :: b) = refl
goOne (one :: a) [] with inspect (go one (incr a) [])
goOne (one :: a) [] | no with≡ pr with goOne a []
... | bl rewrite pr | goEmpty a = exFalso (noNotYes bl)
goOne (one :: a) [] | yes y with≡ pr with goOne a []
... | bl rewrite pr = applyEquality (λ i → yes (one :: i)) (yesInjective (transitivity bl (applyEquality (mapMaybe canonical) (goEmpty a))))
goOne (one :: a) (zero :: b) with inspect (go zero a b)
goOne (one :: a) (zero :: b) | no with≡ pr with inspect (go one (incr a) b)
goOne (one :: a) (zero :: b) | no with≡ pr | no with≡ x rewrite pr | x = refl
goOne (one :: a) (zero :: b) | no with≡ pr | yes y with≡ x with goOne a b
... | f rewrite pr | x = exFalso (noNotYes (equalityCommutative f))
goOne (one :: a) (zero :: b) | yes y with≡ pr with inspect (go one (incr a) b)
goOne (one :: a) (zero :: b) | yes y with≡ pr | no with≡ x with goOne a b
... | f rewrite pr | x = exFalso (noNotYes f)
goOne (one :: a) (zero :: b) | yes y with≡ pr | yes z with≡ x rewrite pr | x = applyEquality (λ i → yes (one :: i)) (yesInjective (transitivity (transitivity (applyEquality (mapMaybe canonical) (equalityCommutative x)) (goOne a b)) (applyEquality (mapMaybe canonical) pr)))
goOne (one :: a) (one :: b) with inspect (go zero a b)
goOne (one :: a) (one :: b) | no with≡ pr with inspect (go one (incr a) b)
goOne (one :: a) (one :: b) | no with≡ pr | no with≡ pr2 rewrite pr | pr2 = refl
goOne (one :: a) (one :: b) | no with≡ pr | yes x with≡ pr2 rewrite pr | pr2 = exFalso (noNotYes (transitivity (applyEquality (mapMaybe canonical) (equalityCommutative pr)) (transitivity (equalityCommutative (goOne a b)) (applyEquality (mapMaybe canonical) pr2))))
goOne (one :: a) (one :: b) | yes y with≡ pr with inspect (go one (incr a) b)
goOne (one :: a) (one :: b) | yes y with≡ pr | yes z with≡ pr2 rewrite pr | pr2 = applyEquality yes t
where
u : canonical z ≡ canonical y
u = yesInjective (transitivity (transitivity (equalityCommutative (applyEquality (mapMaybe canonical) pr2)) (goOne a b)) (applyEquality (mapMaybe canonical) pr))
t : canonical (zero :: z) ≡ canonical (zero :: y)
t with inspect (canonical z)
t | [] with≡ pr1 rewrite equalityCommutative u | pr1 = refl
t | (x :: bl) with≡ pr rewrite equalityCommutative u | pr = refl
goOne (one :: a) (one :: b) | yes y with≡ pr | no with≡ pr2 rewrite pr | pr2 = exFalso (noNotYes (transitivity (equalityCommutative (applyEquality (mapMaybe canonical) pr2)) (transitivity (goOne a b) (applyEquality (mapMaybe canonical) pr))))
plusThenMinus : (a b : BinNat) → mapMaybe canonical ((a +B b) -B b) ≡ yes (canonical a)
plusThenMinus [] b = aMinusA b
plusThenMinus (zero :: a) [] = refl
plusThenMinus (zero :: a) (zero :: b) = t
where
t : mapMaybe canonical (mapMaybe (zero ::_) (go zero (a +B b) b)) ≡ yes (canonical (zero :: a))
t with inspect (go zero (a +B b) b)
t | no with≡ x with plusThenMinus a b
... | bl rewrite x = exFalso (noNotYes bl)
t | yes y with≡ x with plusThenMinus a b
... | f rewrite x = applyEquality yes u
where
u : canonical (zero :: y) ≡ canonical (zero :: a)
u with inspect (canonical y)
u | [] with≡ pr rewrite pr | equalityCommutative (yesInjective f) = refl
u | (x :: bl) with≡ pr rewrite pr | equalityCommutative (yesInjective f) = refl
plusThenMinus (zero :: a) (one :: b) = t
where
t : mapMaybe canonical (mapMaybe (zero ::_) (go zero (a +B b) b)) ≡ yes (canonical (zero :: a))
t with inspect (go zero (a +B b) b)
t | no with≡ x with plusThenMinus a b
... | bl rewrite x = exFalso (noNotYes bl)
t | yes y with≡ x with plusThenMinus a b
... | f rewrite x = applyEquality yes u
where
u : canonical (zero :: y) ≡ canonical (zero :: a)
u with inspect (canonical y)
u | [] with≡ pr rewrite pr | equalityCommutative (yesInjective f) = refl
u | (x :: bl) with≡ pr rewrite pr | equalityCommutative (yesInjective f) = refl
plusThenMinus (one :: a) [] = refl
plusThenMinus (one :: a) (zero :: b) = t
where
t : mapMaybe canonical (mapMaybe (_::_ one) (go zero (a +B b) b)) ≡ yes (one :: canonical a)
t with inspect (go zero (a +B b) b)
t | no with≡ x with plusThenMinus a b
... | bl rewrite x = exFalso (noNotYes bl)
t | yes y with≡ x with plusThenMinus a b
... | bl rewrite x = applyEquality (λ i → yes (one :: i)) (yesInjective bl)
plusThenMinus (one :: a) (one :: b) = t
where
t : mapMaybe canonical (mapMaybe (_::_ one) (go one (incr (a +B b)) b)) ≡ yes (one :: canonical a)
t with inspect (go one (incr (a +B b)) b)
t | no with≡ x with goOne (a +B b) b
... | f rewrite x | plusThenMinus a b = exFalso (noNotYes f)
t | yes y with≡ x with goOne (a +B b) b
... | f rewrite x | plusThenMinus a b = applyEquality (λ i → yes (one :: i)) (yesInjective f)
subLemma : (a b : ℕ) → a <N b → succ (a +N a) <N b +N b
subLemma a b a<b with TotalOrder.totality ℕTotalOrder (succ (a +N a)) (b +N b)
subLemma a b a<b | inl (inl x) = x
subLemma a b a<b | inl (inr x) = exFalso (noIntegersBetweenXAndSuccX (a +N a) (addStrongInequalities a<b a<b) x)
subLemma a b a<b | inr x = exFalso (parity a b (transitivity (applyEquality (succ a +N_) (Semiring.sumZeroRight ℕSemiring a)) (transitivity x (applyEquality (b +N_) (equalityCommutative (Semiring.sumZeroRight ℕSemiring b))))))
subLemma2 : (a b : ℕ) → a <N b → 2 *N a <N succ (2 *N b)
subLemma2 a b a<b with TotalOrder.totality ℕTotalOrder (2 *N a) (succ (2 *N b))
subLemma2 a b a<b | inl (inl x) = x
subLemma2 a b a<b | inl (inr x) = exFalso (TotalOrder.irreflexive ℕTotalOrder (TotalOrder.<Transitive ℕTotalOrder x (TotalOrder.<Transitive ℕTotalOrder (lessRespectsMultiplicationLeft a b 2 a<b (le 1 refl)) (le 0 refl))))
subLemma2 a b a<b | inr x = exFalso (parity b a (equalityCommutative x))
subtraction : (a b : BinNat) → a -B b ≡ no → binNatToN a <N binNatToN b
subtraction' : (a b : BinNat) → go one a b ≡ no → (binNatToN a <N binNatToN b) || (binNatToN a ≡ binNatToN b)
subtraction' [] [] pr = inr refl
subtraction' [] (x :: b) pr with TotalOrder.totality ℕTotalOrder 0 (binNatToN (x :: b))
subtraction' [] (x :: b) pr | inl (inl x₁) = inl x₁
subtraction' [] (x :: b) pr | inr x₁ = inr x₁
subtraction' (zero :: a) [] pr with subtraction' a [] (mapMaybePreservesNo pr)
subtraction' (zero :: a) [] pr | inr x rewrite x = inr refl
subtraction' (zero :: a) (zero :: b) pr with subtraction' a b (mapMaybePreservesNo pr)
subtraction' (zero :: a) (zero :: b) pr | inl x = inl (lessRespectsMultiplicationLeft (binNatToN a) (binNatToN b) 2 x (le 1 refl))
subtraction' (zero :: a) (zero :: b) pr | inr x rewrite x = inr refl
subtraction' (zero :: a) (one :: b) pr with subtraction' a b (mapMaybePreservesNo pr)
subtraction' (zero :: a) (one :: b) pr | inl x = inl (subLemma2 (binNatToN a) (binNatToN b) x)
subtraction' (zero :: a) (one :: b) pr | inr x rewrite x = inl (le zero refl)
subtraction' (one :: a) (zero :: b) pr with subtraction a b (mapMaybePreservesNo pr)
... | t rewrite Semiring.sumZeroRight ℕSemiring (binNatToN a) | Semiring.sumZeroRight ℕSemiring (binNatToN b) = inl (subLemma (binNatToN a) (binNatToN b) t)
subtraction' (one :: a) (one :: b) pr with subtraction' a b (mapMaybePreservesNo pr)
subtraction' (one :: a) (one :: b) pr | inl x = inl (succPreservesInequality (lessRespectsMultiplicationLeft (binNatToN a) (binNatToN b) 2 x (le 1 refl)))
subtraction' (one :: a) (one :: b) pr | inr x rewrite x = inr refl
subtraction [] (zero :: b) pr with inspect (binNatToN b)
subtraction [] (zero :: b) pr | zero with≡ pr1 = exFalso (noNotYes (transitivity (applyEquality (mapMaybe canonical) (equalityCommutative pr)) (transitivity (goPreservesCanonicalRight zero [] b) (transitivity (applyEquality (λ i → mapMaybe canonical (go zero [] i)) (binNatToNZero b pr1)) refl))))
subtraction [] (zero :: b) pr | (succ bl) with≡ pr1 rewrite pr | pr1 = succIsPositive _
subtraction [] (one :: b) pr = succIsPositive _
subtraction (zero :: a) (zero :: b) pr = lessRespectsMultiplicationLeft (binNatToN a) (binNatToN b) 2 u (le 1 refl)
where
u : binNatToN a <N binNatToN b
u = subtraction a b (mapMaybePreservesNo pr)
subtraction (zero :: a) (one :: b) pr with subtraction' a b (mapMaybePreservesNo pr)
subtraction (zero :: a) (one :: b) pr | inl x = subLemma2 (binNatToN a) (binNatToN b) x
subtraction (zero :: a) (one :: b) pr | inr x rewrite x = le zero refl
subtraction (one :: a) (zero :: b) pr rewrite Semiring.sumZeroRight ℕSemiring (binNatToN a) | Semiring.sumZeroRight ℕSemiring (binNatToN b) = subLemma (binNatToN a) (binNatToN b) u
where
u : binNatToN a <N binNatToN b
u = subtraction a b (mapMaybePreservesNo pr)
subtraction (one :: a) (one :: b) pr = succPreservesInequality (lessRespectsMultiplicationLeft (binNatToN a) (binNatToN b) 2 u (le 1 refl))
where
u : binNatToN a <N binNatToN b
u = subtraction a b (mapMaybePreservesNo pr)
subLemma4 : (a b : BinNat) {t : BinNat} → go one a b ≡ no → go zero a b ≡ yes t → canonical t ≡ []
subLemma4 [] [] {t} pr1 pr2 rewrite yesInjective (equalityCommutative pr2) = refl
subLemma4 [] (x :: b) {t} pr1 pr2 = goZeroEmpty' (x :: b) pr2
subLemma4 (zero :: a) [] {t} pr1 pr2 with inspect (go one a [])
subLemma4 (zero :: a) [] {t} pr1 pr2 | no with≡ pr3 with subLemma4 a [] pr3 (goEmpty a)
... | bl with applyEquality canonical (yesInjective pr2)
... | th rewrite bl = equalityCommutative th
subLemma4 (zero :: a) [] {t} pr1 pr2 | yes x with≡ pr3 rewrite pr3 = exFalso (noNotYes (equalityCommutative pr1))
subLemma4 (zero :: a) (zero :: b) {t} pr1 pr2 with inspect (go one a b)
subLemma4 (zero :: a) (zero :: b) {t} pr1 pr2 | no with≡ pr3 with inspect (go zero a b)
subLemma4 (zero :: a) (zero :: b) {t} pr1 pr2 | no with≡ pr3 | no with≡ pr4 rewrite pr4 = exFalso (noNotYes pr2)
subLemma4 (zero :: a) (zero :: b) {t} pr1 pr2 | no with≡ pr3 | yes x with≡ pr4 with subLemma4 a b pr3 pr4
... | bl rewrite pr3 | pr4 = ans
where
ans : canonical t ≡ []
ans rewrite equalityCommutative (applyEquality canonical (yesInjective pr2)) | bl = refl
subLemma4 (zero :: a) (zero :: b) {t} pr1 pr2 | yes x with≡ pr3 rewrite pr3 = exFalso (noNotYes (equalityCommutative pr1))
subLemma4 (zero :: a) (one :: b) {t} pr1 pr2 with go one a b
... | no = exFalso (noNotYes pr2)
subLemma4 (zero :: a) (one :: b) {t} pr1 pr2 | yes x = exFalso (noNotYes (equalityCommutative pr1))
subLemma4 (one :: a) (zero :: b) {t} pr1 pr2 with go zero a b
subLemma4 (one :: a) (zero :: b) {t} pr1 pr2 | no = exFalso (noNotYes pr2)
subLemma4 (one :: a) (zero :: b) {t} pr1 pr2 | yes x = exFalso (noNotYes (equalityCommutative pr1))
subLemma4 (one :: a) (one :: b) {t} pr1 pr2 with inspect (go zero a b)
subLemma4 (one :: a) (one :: b) {t} pr1 pr2 | no with≡ pr3 rewrite pr3 = exFalso (noNotYes pr2)
subLemma4 (one :: a) (one :: b) {t} pr1 pr2 | yes x with≡ pr3 with inspect (go one a b)
subLemma4 (one :: a) (one :: b) {t} pr1 pr2 | yes x with≡ pr3 | no with≡ pr4 with subLemma4 a b pr4 pr3
... | bl rewrite pr3 | pr4 | bl = ans
where
ans : canonical t ≡ []
ans rewrite equalityCommutative (applyEquality canonical (yesInjective pr2)) | bl = refl
subLemma4 (one :: a) (one :: b) {t} pr1 pr2 | yes x with≡ pr3 | yes x₁ with≡ pr4 rewrite pr4 = exFalso (noNotYes (equalityCommutative pr1))
goOneFromZero : (a b : BinNat) → go zero a b ≡ no → go one a b ≡ no
goOneFromZero [] (zero :: b) pr = refl
goOneFromZero [] (one :: b) pr = refl
goOneFromZero (zero :: a) (zero :: b) pr rewrite goOneFromZero a b (mapMaybePreservesNo pr) = refl
goOneFromZero (zero :: a) (one :: b) pr rewrite (mapMaybePreservesNo pr) = refl
goOneFromZero (one :: a) (zero :: b) pr rewrite (mapMaybePreservesNo pr) = refl
goOneFromZero (one :: a) (one :: b) pr rewrite goOneFromZero a b (mapMaybePreservesNo pr) = refl
subLemma5 : (a b : BinNat) → mapMaybe canonical (go zero a b) ≡ yes [] → go one a b ≡ no
subLemma5 [] b pr = goOneEmpty' b
subLemma5 (zero :: a) [] pr with inspect (canonical a)
subLemma5 (zero :: a) [] pr | (z :: zs) with≡ pr2 rewrite pr2 = exFalso (nonEmptyNotEmpty (yesInjective pr))
subLemma5 (zero :: a) [] pr | [] with≡ pr2 rewrite pr2 = applyEquality (mapMaybe (one ::_)) (subLemma5 a [] (transitivity (applyEquality (mapMaybe canonical) (goEmpty a)) (applyEquality yes pr2)))
subLemma5 (zero :: a) (zero :: b) pr with inspect (go zero a b)
subLemma5 (zero :: a) (zero :: b) pr | no with≡ pr2 rewrite pr2 = exFalso (noNotYes pr)
subLemma5 (zero :: a) (zero :: b) pr | yes x with≡ pr2 with inspect (canonical x)
subLemma5 (zero :: a) (zero :: b) pr | yes x with≡ pr2 | [] with≡ pr3 rewrite pr | pr2 | pr3 = applyEquality (mapMaybe (one ::_)) (subLemma5 a b (transitivity (applyEquality (mapMaybe canonical) pr2) (applyEquality yes pr3)))
subLemma5 (zero :: a) (zero :: b) pr | yes x with≡ pr2 | (x₁ :: bl) with≡ pr3 rewrite pr | pr2 | pr3 = exFalso (nonEmptyNotEmpty (yesInjective pr))
subLemma5 (zero :: a) (one :: b) pr with (go one a b)
subLemma5 (zero :: a) (one :: b) pr | no = exFalso (noNotYes pr)
subLemma5 (zero :: a) (one :: b) pr | yes y = exFalso (nonEmptyNotEmpty (yesInjective pr))
subLemma5 (one :: a) (zero :: b) pr with go zero a b
subLemma5 (one :: a) (zero :: b) pr | no = exFalso (noNotYes pr)
subLemma5 (one :: a) (zero :: b) pr | yes x = exFalso (nonEmptyNotEmpty (yesInjective pr))
subLemma5 (one :: a) (one :: b) pr with inspect (go zero a b)
subLemma5 (one :: a) (one :: b) pr | yes x with≡ pr2 with inspect (canonical x)
subLemma5 (one :: a) (one :: b) pr | yes x with≡ pr2 | [] with≡ pr3 rewrite pr | pr2 | pr3 = applyEquality (mapMaybe (one ::_)) (subLemma5 a b (transitivity (applyEquality (mapMaybe canonical) pr2) (applyEquality yes pr3)))
subLemma5 (one :: a) (one :: b) pr | yes x with≡ pr2 | (x₁ :: y) with≡ pr3 rewrite pr | pr2 | pr3 = exFalso (nonEmptyNotEmpty (yesInjective pr))
subLemma5 (one :: a) (one :: b) pr | no with≡ pr2 rewrite pr2 = exFalso (noNotYes pr)
subLemma3 : (a b : BinNat) → go zero a b ≡ no → (go zero (incr a) b ≡ no) || (mapMaybe canonical (go zero (incr a) b) ≡ yes [])
subLemma3 a b pr with inspect (go zero (incr a) b)
subLemma3 a b pr | no with≡ x = inl x
subLemma3 [] (zero :: b) pr | yes y with≡ pr1 rewrite pr = exFalso (noNotYes pr1)
subLemma3 [] (one :: b) pr | yes y with≡ pr1 with inspect (go zero [] b)
subLemma3 [] (one :: b) pr | yes y with≡ pr1 | no with≡ pr2 rewrite pr1 | pr2 = exFalso (noNotYes pr1)
subLemma3 [] (one :: b) pr | yes y with≡ pr1 | yes x with≡ pr2 with goZeroEmpty' b pr2
... | f rewrite pr1 | pr2 | equalityCommutative (yesInjective pr1) | f = inr refl
subLemma3 (zero :: a) (zero :: b) pr | yes y with≡ pr1 rewrite mapMaybePreservesNo pr = exFalso (noNotYes pr1)
subLemma3 (zero :: a) (one :: b) pr | yes y with≡ pr1 with inspect (go zero a b)
subLemma3 (zero :: a) (one :: b) pr | yes y with≡ pr1 | no with≡ pr2 rewrite pr1 | pr2 = exFalso (noNotYes pr1)
subLemma3 (zero :: a) (one :: b) pr | yes y with≡ pr1 | yes x with≡ pr2 with inspect (canonical x)
... | [] with≡ pr3 rewrite pr1 | pr2 | equalityCommutative (yesInjective pr1) | pr3 = inr refl
... | (z :: zs) with≡ pr3 with inspect (go one a b)
subLemma3 (zero :: a) (one :: b) pr | yes y with≡ pr1 | yes x with≡ pr2 | (z :: zs) with≡ pr3 | no with≡ pr4 rewrite pr1 | pr2 | pr3 | pr4 = exFalso (nonEmptyNotEmpty (transitivity (equalityCommutative pr3) (subLemma4 a b pr4 pr2)))
subLemma3 (zero :: a) (one :: b) pr | yes y with≡ pr1 | yes x with≡ pr2 | (z :: zs) with≡ pr3 | yes x₁ with≡ pr4 rewrite pr1 | pr2 | pr3 | pr4 = exFalso (noNotYes (equalityCommutative pr))
subLemma3 (one :: a) (zero :: b) pr | yes y with≡ pr1 with subLemma3 a b (mapMaybePreservesNo pr)
subLemma3 (one :: a) (zero :: b) pr | yes y with≡ pr1 | inl x rewrite x = inl refl
subLemma3 (one :: a) (zero :: b) pr | yes y with≡ pr1 | inr x with inspect (go zero (incr a) b)
... | no with≡ pr2 rewrite pr1 | pr2 = exFalso (noNotYes x)
... | yes z with≡ pr2 rewrite pr1 | pr2 = inr (applyEquality yes (transitivity (transitivity (applyEquality canonical (yesInjective (equalityCommutative pr1))) r) (yesInjective x)))
where
r : canonical (zero :: z) ≡ canonical z
r rewrite yesInjective x = refl
subLemma3 (one :: a) (one :: b) pr | yes y with≡ pr1 with subLemma3 a b (mapMaybePreservesNo pr)
subLemma3 (one :: a) (one :: b) pr | yes y with≡ pr1 | inl x with inspect (go one (incr a) b)
subLemma3 (one :: a) (one :: b) pr | yes y with≡ pr1 | inl th | no with≡ pr2 rewrite pr2 = exFalso (noNotYes pr1)
subLemma3 (one :: a) (one :: b) pr | yes y with≡ pr1 | inl th | yes x with≡ pr2 with goOneFromZero (incr a) b th
... | bad rewrite pr2 = exFalso (noNotYes (equalityCommutative bad))
subLemma3 (one :: a) (one :: b) pr | yes y with≡ pr1 | inr x with inspect (go one (incr a) b)
subLemma3 (one :: a) (one :: b) pr | yes y with≡ pr1 | inr x | no with≡ pr2 rewrite pr2 = exFalso (noNotYes pr1)
subLemma3 (one :: a) (one :: b) pr | yes y with≡ pr1 | inr th | yes z with≡ pr2 with inspect (go zero (incr a) b)
subLemma3 (one :: a) (one :: b) pr | yes y with≡ pr1 | inr th | yes z with≡ pr2 | no with≡ pr3 rewrite pr3 = exFalso (noNotYes th)
subLemma3 (one :: a) (one :: b) pr | yes y with≡ pr1 | inr th | yes z with≡ pr2 | yes x with≡ pr3 with inspect (go zero a b)
subLemma3 (one :: a) (one :: b) pr | yes y with≡ pr1 | inr th | yes z with≡ pr2 | yes x with≡ pr3 | no with≡ pr4 rewrite pr1 | th | pr2 | pr3 | pr4 | equalityCommutative (yesInjective pr1) = exFalso false
where
false : False
false with applyEquality (mapMaybe canonical) pr3
... | f rewrite th | subLemma5 (incr a) b f = exFalso (noNotYes pr2)
subLemma3 (one :: a) (one :: b) pr | yes y with≡ pr1 | inr th | yes z with≡ pr2 | yes x with≡ pr3 | yes w with≡ pr4 rewrite pr4 = exFalso (noNotYes (equalityCommutative pr))
goIncrOne : (a b : BinNat) → mapMaybe canonical (go one a b) ≡ mapMaybe canonical (go zero a (incr b))
goIncrOne [] b rewrite goOneEmpty' b | goZeroIncr b = refl
goIncrOne (zero :: a) [] = refl
goIncrOne (zero :: a) (zero :: b) = refl
goIncrOne (zero :: a) (one :: b) with inspect (go one a b)
goIncrOne (zero :: a) (one :: b) | no with≡ pr1 with inspect (go zero a (incr b))
goIncrOne (zero :: a) (one :: b) | no with≡ pr1 | no with≡ pr2 rewrite pr1 | pr2 = refl
goIncrOne (zero :: a) (one :: b) | no with≡ pr1 | yes x with≡ pr2 with goIncrOne a b
... | f rewrite pr1 | pr2 = exFalso (noNotYes f)
goIncrOne (zero :: a) (one :: b) | yes x with≡ pr1 with inspect (go zero a (incr b))
goIncrOne (zero :: a) (one :: b) | yes x with≡ pr1 | no with≡ pr2 with goIncrOne a b
... | f rewrite pr1 | pr2 = exFalso (noNotYes (equalityCommutative f))
goIncrOne (zero :: a) (one :: b) | yes x with≡ pr1 | yes y with≡ pr2 with goIncrOne a b
... | f rewrite pr1 | pr2 | yesInjective f = refl
goIncrOne (one :: a) [] rewrite goEmpty a = refl
goIncrOne (one :: a) (zero :: b) = refl
goIncrOne (one :: a) (one :: b) with inspect (go one a b)
goIncrOne (one :: a) (one :: b) | no with≡ pr with inspect (go zero a (incr b))
goIncrOne (one :: a) (one :: b) | no with≡ pr | no with≡ pr2 with goIncrOne a b
... | f rewrite pr | pr2 = refl
goIncrOne (one :: a) (one :: b) | no with≡ pr | yes x with≡ pr2 with goIncrOne a b
... | f rewrite pr | pr2 = exFalso (noNotYes f)
goIncrOne (one :: a) (one :: b) | yes x with≡ pr with inspect (go zero a (incr b))
goIncrOne (one :: a) (one :: b) | yes x with≡ pr | no with≡ pr2 with goIncrOne a b
... | f rewrite pr | pr2 = exFalso (noNotYes (equalityCommutative f))
goIncrOne (one :: a) (one :: b) | yes x with≡ pr | yes y with≡ pr2 with goIncrOne a b
... | f rewrite pr | pr2 | yesInjective f = refl
goIncrIncr : (a b : BinNat) → mapMaybe canonical (go zero (incr a) (incr b)) ≡ mapMaybe canonical (go zero a b)
goIncrIncr [] [] = refl
goIncrIncr [] (zero :: b) with inspect (go zero [] b)
... | no with≡ pr rewrite goIncrIncr [] b | pr = refl
... | yes y with≡ pr rewrite goIncrIncr [] b | pr | goZeroEmpty' b {y} pr = refl
goIncrIncr [] (one :: b) rewrite goZeroIncr b = refl
goIncrIncr (zero :: a) [] rewrite goEmpty a = refl
goIncrIncr (zero :: a) (zero :: b) = refl
goIncrIncr (zero :: a) (one :: b) with inspect (go zero a (incr b))
goIncrIncr (zero :: a) (one :: b) | no with≡ pr with inspect (go one a b)
goIncrIncr (zero :: a) (one :: b) | no with≡ pr | no with≡ pr2 rewrite pr | pr2 = refl
goIncrIncr (zero :: a) (one :: b) | no with≡ pr | yes x with≡ pr2 with goIncrOne a b
... | f rewrite pr | pr2 = exFalso (noNotYes (equalityCommutative f))
goIncrIncr (zero :: a) (one :: b) | yes y with≡ pr with inspect (go one a b)
goIncrIncr (zero :: a) (one :: b) | yes y with≡ pr | yes z with≡ pr2 with goIncrOne a b
... | f rewrite pr | pr2 = applyEquality (λ i → yes (one :: i)) (equalityCommutative (yesInjective f))
goIncrIncr (zero :: a) (one :: b) | yes y with≡ pr | no with≡ pr2 with goIncrOne a b
... | f rewrite pr | pr2 = exFalso (noNotYes f)
goIncrIncr (one :: a) [] with goOne a []
... | f with go one (incr a) []
goIncrIncr (one :: a) [] | f | no rewrite goEmpty a = exFalso (noNotYes f)
goIncrIncr (one :: a) [] | f | yes x rewrite goEmpty a | yesInjective f = refl
goIncrIncr (one :: a) (zero :: b) with goOne a b
... | f with go one (incr a) b
goIncrIncr (one :: a) (zero :: b) | f | no with go zero a b
goIncrIncr (one :: a) (zero :: b) | f | no | no = refl
goIncrIncr (one :: a) (zero :: b) | f | yes x with go zero a b
goIncrIncr (one :: a) (zero :: b) | f | yes x | yes x₁ rewrite yesInjective f = refl
goIncrIncr (one :: a) (one :: b) with goIncrIncr a b
... | f with go zero a b
goIncrIncr (one :: a) (one :: b) | f | no with go zero (incr a) (incr b)
goIncrIncr (one :: a) (one :: b) | f | no | no = refl
goIncrIncr (one :: a) (one :: b) | f | yes x with go zero (incr a) (incr b)
goIncrIncr (one :: a) (one :: b) | f | yes x | yes x₁ rewrite yesInjective f = refl
subtractionConverse : (a b : ℕ) → a <N b → go zero (NToBinNat a) (NToBinNat b) ≡ no
subtractionConverse zero (succ b) a<b with NToBinNat b
subtractionConverse zero (succ b) a<b | [] = refl
subtractionConverse zero (succ b) a<b | zero :: bl = refl
subtractionConverse zero (succ b) a<b | one :: bl = goZeroIncr bl
subtractionConverse (succ a) (succ b) a<b with inspect (NToBinNat a)
subtractionConverse (succ a) (succ b) a<b | [] with≡ pr with inspect (NToBinNat b)
subtractionConverse (succ a) (succ b) a<b | [] with≡ pr | [] with≡ pr2 rewrite NToBinNatZero a pr | NToBinNatZero b pr2 = exFalso (TotalOrder.irreflexive ℕTotalOrder a<b)
subtractionConverse (succ a) (succ zero) a<b | [] with≡ pr | (zero :: y) with≡ pr2 rewrite NToBinNatZero a pr | pr2 = exFalso (TotalOrder.irreflexive ℕTotalOrder a<b)
subtractionConverse (succ a) (succ (succ b)) a<b | [] with≡ pr | (zero :: y) with≡ pr2 with inspect (go zero [] y)
... | no with≡ pr3 rewrite NToBinNatZero a pr | pr2 | pr3 = refl
... | yes t with≡ pr3 with applyEquality canonical pr2
... | g rewrite (goZeroEmpty y pr3) = exFalso (incrNonzero (NToBinNat b) g)
subtractionConverse (succ a) (succ b) a<b | [] with≡ pr | (one :: y) with≡ pr2 rewrite NToBinNatZero a pr | pr2 = applyEquality (mapMaybe (one ::_)) (goZeroIncr y)
subtractionConverse (succ a) (succ b) a<b | (zero :: y) with≡ pr with inspect (NToBinNat b)
subtractionConverse (succ a) (succ b) a<b | (zero :: y) with≡ pr | [] with≡ pr2 rewrite NToBinNatZero b pr2 = exFalso (bad a<b)
where
bad : {a : ℕ} → succ a <N 1 → False
bad {zero} (le zero ())
bad {zero} (le (succ x) ())
bad {succ a} (le zero ())
bad {succ a} (le (succ x) ())
subtractionConverse (succ a) (succ b) a<b | (zero :: y) with≡ pr | (zero :: z) with≡ pr2 rewrite pr | pr2 = applyEquality (mapMaybe (zero ::_)) (mapMaybePreservesNo u)
where
t : go zero (NToBinNat a) (NToBinNat b) ≡ no
t = subtractionConverse a b (canRemoveSuccFrom<N a<b)
u : go zero (zero :: y) (zero :: z) ≡ no
u = transitivity (transitivity {x = _} {go zero (NToBinNat a) (zero :: z)} (applyEquality (λ i → go zero i (zero :: z)) (equalityCommutative pr)) (applyEquality (go zero (NToBinNat a)) (equalityCommutative pr2))) t
subtractionConverse (succ a) (succ b) a<b | (zero :: y) with≡ pr | (one :: z) with≡ pr2 with subtractionConverse a (succ b) (le (succ (_<N_.x a<b)) (transitivity (applyEquality succ (transitivity (applyEquality succ (Semiring.commutative ℕSemiring (_<N_.x a<b) a)) (Semiring.commutative ℕSemiring (succ a) (_<N_.x a<b)))) (_<N_.proof a<b)))
subtractionConverse (succ a) (succ b) a<b | (zero :: y) with≡ pr | (one :: z) with≡ pr2 | thing=no with subLemma3 (NToBinNat a) (incr (NToBinNat b)) thing=no
subtractionConverse (succ a) (succ b) a<b | (zero :: y) with≡ pr | (one :: z) with≡ pr2 | thing=no | inl x = x
subtractionConverse (succ a) (succ b) a<b | (zero :: y) with≡ pr | (one :: z) with≡ pr2 | thing=no | inr x rewrite pr | pr2 | mapMaybePreservesNo thing=no = exFalso (noNotYes x)
subtractionConverse (succ a) (succ b) a<b | (one :: y) with≡ pr with goIncrIncr (NToBinNat a) (NToBinNat b)
... | f rewrite subtractionConverse a b (canRemoveSuccFrom<N a<b) = mapMaybePreservesNo f
bad : (b : ℕ) {t : BinNat} → incr (NToBinNat b) ≡ zero :: t → canonical t ≡ [] → False
bad b {c} t pr with applyEquality canonical t
... | bl with canonical c
bad b {c} t pr | bl | [] = exFalso (incrNonzero (NToBinNat b) bl)
lemma6 : (a : BinNat) (b : ℕ) → canonical a ≡ [] → NToBinNat b ≡ one :: a → a ≡ []
lemma6 [] b pr1 pr2 = refl
lemma6 (a :: as) b pr1 pr2 with applyEquality canonical pr2
lemma6 (a :: as) b pr1 pr2 | th rewrite pr1 | equalityCommutative (NToBinNatIsCanonical b) | pr2 = exFalso (bad' th)
where
bad' : one :: a :: as ≡ one :: [] → False
bad' ()
doublingLemma : (y : BinNat) → NToBinNat (2 *N binNatToN y) ≡ canonical (zero :: y)
doublingLemma y with inspect (canonical y)
doublingLemma y | [] with≡ pr rewrite binNatToNZero' y pr | pr = refl
doublingLemma y | (a :: as) with≡ pr with inspect (binNatToN y)
doublingLemma y | (a :: as) with≡ pr | zero with≡ pr2 rewrite binNatToNZero y pr2 = exFalso (nonEmptyNotEmpty (equalityCommutative pr))
doublingLemma y | (a :: as) with≡ pr | succ bl with≡ pr2 rewrite pr | pr2 | doubleIsBitShift' bl | equalityCommutative pr = applyEquality (zero ::_) (equalityCommutative (transitivity (equalityCommutative (binToBin y)) (applyEquality NToBinNat pr2)))
private
doubling : (a : ℕ) {y : BinNat} → (NToBinNat a ≡ zero :: y) → binNatToN y +N (binNatToN y +N 0) ≡ a
doubling a {y} pr = NToBinNatInj (binNatToN y +N (binNatToN y +N zero)) a (transitivity (transitivity (equalityCommutative (NToBinNatIsCanonical (binNatToN y +N (binNatToN y +N zero)))) (doublingLemma y)) (applyEquality canonical (equalityCommutative pr)))
subtraction2 : (a b : ℕ) {t : BinNat} → (NToBinNat a) -B (NToBinNat b) ≡ yes t → (binNatToN t) +N b ≡ a
subtraction2 zero zero {t} pr rewrite yesInjective (equalityCommutative pr) = refl
subtraction2 zero (succ b) pr with goZeroEmpty (NToBinNat (succ b)) pr
... | t = exFalso (incrNonzero (NToBinNat b) t)
subtraction2 (succ a) b {t} pr with inspect (NToBinNat a)
subtraction2 (succ a) b {t} pr | [] with≡ pr2 with inspect (NToBinNat b)
subtraction2 (succ a) b {t} pr | [] with≡ pr2 | [] with≡ pr3 rewrite pr2 | pr3 | equalityCommutative (yesInjective pr) | NToBinNatZero a pr2 | NToBinNatZero b pr3 = refl
subtraction2 (succ a) b {t} pr | [] with≡ pr2 | (zero :: bl) with≡ pr3 with inspect (go zero [] bl)
subtraction2 (succ a) b {t} pr | [] with≡ pr2 | (zero :: bl) with≡ pr3 | no with≡ pr4 rewrite pr2 | pr3 | pr4 = exFalso (noNotYes pr)
subtraction2 (succ a) b {t} pr | [] with≡ pr2 | (zero :: bl) with≡ pr3 | yes x with≡ pr4 with goZeroEmpty bl pr4
subtraction2 (succ a) (succ b) {t} pr | [] with≡ pr2 | (zero :: bl) with≡ pr3 | yes x with≡ pr4 | r with goZeroEmpty' bl pr4
... | s rewrite pr2 | pr3 | pr4 | r | equalityCommutative (yesInjective pr) | NToBinNatZero a pr2 = exFalso (bad b pr3 r)
subtraction2 (succ a) b {t} pr | [] with≡ pr2 | (one :: bl) with≡ pr3 with inspect (go zero [] bl)
subtraction2 (succ a) b {t} pr | [] with≡ pr2 | (one :: bl) with≡ pr3 | no with≡ pr4 rewrite pr2 | pr3 | pr4 = exFalso (noNotYes pr)
subtraction2 (succ a) b {t} pr | [] with≡ pr2 | (one :: bl) with≡ pr3 | yes x with≡ pr4 with goZeroEmpty bl pr4
... | u with goZeroEmpty' bl pr4
... | v rewrite pr2 | pr3 | pr4 | u | NToBinNatZero a pr2 | lemma6 bl b u pr3 | equalityCommutative (yesInjective pr4) | equalityCommutative (yesInjective pr) = ans pr3
where
z : bl ≡ []
z = lemma6 bl b u pr3
ans : (NToBinNat b ≡ one :: bl) → b ≡ 1
ans pr with applyEquality binNatToN pr
... | th rewrite z = transitivity (equalityCommutative (nToN b)) th
subtraction2 (succ a) b pr | (x :: y) with≡ pr2 with inspect (NToBinNat b)
subtraction2 (succ a) b pr | (zero :: y) with≡ pr2 | [] with≡ pr3 rewrite NToBinNatZero b pr3 | pr2 | pr3 | equalityCommutative (yesInjective pr) = applyEquality succ (transitivity (Semiring.sumZeroRight ℕSemiring _) (doubling a pr2))
subtraction2 (succ a) b pr | (one :: y) with≡ pr2 | [] with≡ pr3 rewrite NToBinNatZero b pr3 | pr2 | pr3 | equalityCommutative (yesInjective pr) = transitivity (Semiring.sumZeroRight ℕSemiring (binNatToN (incr y) +N (binNatToN (incr y) +N zero))) (equalityCommutative (transitivity (equalityCommutative (nToN (succ a))) (applyEquality binNatToN (transitivity (equalityCommutative (NToBinNatSucc a)) (applyEquality incr pr2)))))
subtraction2 (succ a) (succ b) {t} pr | (y :: ys) with≡ pr2 | (z :: zs) with≡ pr3 = transitivity (transitivity (Semiring.commutative ℕSemiring (binNatToN t) (succ b)) (applyEquality succ (transitivity (Semiring.commutative ℕSemiring b (binNatToN t)) (applyEquality (_+N b) (equalityCommutative (binNatToNIsCanonical t)))))) (applyEquality succ inter)
where
inter : binNatToN (canonical t) +N b ≡ a
inter with inspect (go zero (NToBinNat a) (NToBinNat b))
inter | no with≡ pr4 with goIncrIncr (NToBinNat a) (NToBinNat b)
... | f rewrite pr | pr4 = exFalso (noNotYes (equalityCommutative f))
inter | yes x with≡ pr4 with goIncrIncr (NToBinNat a) (NToBinNat b)
... | f with subtraction2 a b {x} pr4
... | g = transitivity (applyEquality (_+N b) (transitivity (applyEquality binNatToN h) (binNatToNIsCanonical x))) g
where
h : (canonical t) ≡ (canonical x)
h rewrite pr | pr4 = yesInjective f
subtraction2' : (a b : ℕ) {t : BinNat} → (NToBinNat a) -B (NToBinNat b) ≡ yes t → b ≤N a
subtraction2' a b {t} pr with subtraction2 a b pr
... | f with binNatToN t
subtraction2' a b {t} pr | f | zero = inr f
subtraction2' a b {t} pr | f | succ g = inl (le g f)
subtraction2'' : (a b : ℕ) → (pr : b ≤N a) → mapMaybe binNatToN ((NToBinNat a) -B (NToBinNat b)) ≡ yes (subtractionNResult.result (-N pr))
subtraction2'' a b pr with -N pr
subtraction2'' a b pr | record { result = result ; pr = subPr } with inspect (go zero (NToBinNat a) (NToBinNat b))
subtraction2'' a b (inl pr) | record { result = result ; pr = subPr } | no with≡ pr2 with subtraction (NToBinNat a) (NToBinNat b) pr2
... | bl rewrite nToN a | nToN b = exFalso (TotalOrder.irreflexive ℕTotalOrder (TotalOrder.<Transitive ℕTotalOrder pr bl))
subtraction2'' a b (inr pr) | record { result = result ; pr = subPr } | no with≡ pr2 with subtraction (NToBinNat a) (NToBinNat b) pr2
... | bl rewrite nToN a | nToN b | pr = exFalso (TotalOrder.irreflexive ℕTotalOrder bl)
subtraction2'' a b pr | record { result = result ; pr = subPr } | yes x with≡ pr2 with subtraction2 a b pr2
... | f rewrite pr2 | Semiring.commutative ℕSemiring (binNatToN x) b = applyEquality yes (canSubtractFromEqualityLeft {b} {binNatToN x} (transitivity f (equalityCommutative subPr)))
|
{
"alphanum_fraction": 0.6536237016,
"avg_line_length": 72.5653104925,
"ext": "agda",
"hexsha": "672b9f9e1fdac55773d15dc84ed7d784482ec4c7",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Smaug123/agdaproofs",
"max_forks_repo_path": "Numbers/BinaryNaturals/Subtraction.agda",
"max_issues_count": 14,
"max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Smaug123/agdaproofs",
"max_issues_repo_path": "Numbers/BinaryNaturals/Subtraction.agda",
"max_line_length": 427,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Smaug123/agdaproofs",
"max_stars_repo_path": "Numbers/BinaryNaturals/Subtraction.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z",
"num_tokens": 12261,
"size": 33888
}
|
import Lvl
open import Structure.Category
module Structure.Category.Functor.Equiv
{ℓₗₒ ℓᵣₒ ℓₗₘ ℓᵣₘ ℓₗₑ ℓᵣₑ : Lvl.Level}
{catₗ : CategoryObject{ℓₗₒ}{ℓₗₘ}{ℓₗₑ}}
{catᵣ : CategoryObject{ℓᵣₒ}{ℓᵣₘ}{ℓᵣₑ}}
where
open import Functional.Dependent as Fn using (_$_)
import Function.Equals
open Function.Equals.Dependent
open import Logic
open import Logic.Propositional
open import Logic.Predicate
open import Relator.Equals using ([≡]-intro) renaming (_≡_ to _≡ₑ_)
open import Relator.Equals.Proofs
open import Relator.Equals.Proofs.Equiv
open import Structure.Category.Functor
open import Structure.Category.Functor.Functors as Functors
open import Structure.Category.Morphism.IdTransport
import Structure.Categorical.Names as Names
open import Structure.Category.NaturalTransformation
open import Structure.Category.Proofs
open import Structure.Categorical.Properties
open import Structure.Function
open import Structure.Operator
open import Structure.Relator.Equivalence
open import Structure.Relator.Properties
open import Structure.Setoid
open import Syntax.Transitivity
open import Type
open Structure.Category
open Category ⦃ … ⦄
open CategoryObject
open Functor ⦃ … ⦄
private instance _ = category catₗ
private instance _ = category catᵣ
private open module MorphismEquivₗ {x}{y} = Equiv(morphism-equiv(catₗ){x}{y}) using () renaming (_≡_ to _≡ₗₘ_)
private open module MorphismEquivᵣ {x}{y} = Equiv(morphism-equiv(catᵣ){x}{y}) using () renaming (_≡_ to _≡ᵣₘ_)
module _
(f₁@([∃]-intro F₁) f₂@([∃]-intro F₂) : (catₗ →ᶠᵘⁿᶜᵗᵒʳ catᵣ))
where
record _≡ᶠᵘⁿᶜᵗᵒʳ_ : Type{Lvl.of(Type.of(catₗ)) Lvl.⊔ Lvl.of(Type.of(catᵣ))} where
constructor intro
field
functor-proof : (F₁ ⊜ F₂)
map-proof : NaturalTransformation(f₁)(f₂) (\x → transport(catᵣ) (_⊜_.proof functor-proof {x}))
instance
[≡ᶠᵘⁿᶜᵗᵒʳ]-reflexivity : Reflexivity(_≡ᶠᵘⁿᶜᵗᵒʳ_)
_≡ᶠᵘⁿᶜᵗᵒʳ_.functor-proof (Reflexivity.proof [≡ᶠᵘⁿᶜᵗᵒʳ]-reflexivity) = intro [≡]-intro
NaturalTransformation.natural (_≡ᶠᵘⁿᶜᵗᵒʳ_.map-proof (Reflexivity.proof [≡ᶠᵘⁿᶜᵗᵒʳ]-reflexivity {functor})) {f = f} =
trans-refl ∘ map(f) 🝖[ _≡ᵣₘ_ ]-[]
id ∘ map(f) 🝖[ _≡ᵣₘ_ ]-[ Morphism.identityₗ(_∘_)(id) ]
map(f) 🝖[ _≡ᵣₘ_ ]-[ Morphism.identityᵣ(_∘_)(id) ]-sym
map(f) ∘ id 🝖[ _≡ᵣₘ_ ]-[]
map(f) ∘ trans-refl 🝖-end
where
trans-refl = \{x} → transport(catᵣ) ([≡]-intro {x = x})
instance
[≡ᶠᵘⁿᶜᵗᵒʳ]-symmetry : Symmetry(_≡ᶠᵘⁿᶜᵗᵒʳ_)
_≡ᶠᵘⁿᶜᵗᵒʳ_.functor-proof (Symmetry.proof [≡ᶠᵘⁿᶜᵗᵒʳ]-symmetry xy) = symmetry(_⊜_) (_≡ᶠᵘⁿᶜᵗᵒʳ_.functor-proof xy)
NaturalTransformation.natural (_≡ᶠᵘⁿᶜᵗᵒʳ_.map-proof (Symmetry.proof [≡ᶠᵘⁿᶜᵗᵒʳ]-symmetry {[∃]-intro F₁} {[∃]-intro F₂} (intro (intro fe) (intro me)))) {x}{y} {f = f} =
trans-sym(y) ∘ map(f) 🝖[ _≡ᵣₘ_ ]-[ Morphism.identityᵣ(_∘_)(id) ]-sym
(trans-sym(y) ∘ map(f)) ∘ id 🝖[ _≡ᵣₘ_ ]-[ congruence₂ᵣ(_∘_)(_) ([∘]-on-transport-inverseᵣ catᵣ {ab = fe}) ]-sym
(trans-sym(y) ∘ map(f)) ∘ (trans(x) ∘ trans-sym(x)) 🝖[ _≡ᵣₘ_ ]-[ associate4-213-121 (category catᵣ) ]-sym
(trans-sym(y) ∘ (map(f) ∘ trans(x))) ∘ trans-sym(x) 🝖[ _≡ᵣₘ_ ]-[ congruence₂ₗ(_∘_)(_) (congruence₂ᵣ(_∘_)(_) me) ]-sym
(trans-sym(y) ∘ (trans(y) ∘ map(f))) ∘ trans-sym(x) 🝖[ _≡ᵣₘ_ ]-[ associate4-213-121 (category catᵣ) ]
(trans-sym(y) ∘ trans(y)) ∘ (map(f) ∘ trans-sym(x)) 🝖[ _≡ᵣₘ_ ]-[ congruence₂ₗ(_∘_)(_) ([∘]-on-transport-inverseₗ catᵣ {ab = fe}) ]
id ∘ (map(f) ∘ trans-sym(x)) 🝖[ _≡ᵣₘ_ ]-[ Morphism.identityₗ(_∘_)(id) ]
map(f) ∘ trans-sym(x) 🝖-end
where
trans = \(x : Object(catₗ)) → transport catᵣ (fe{x})
trans-sym = \(x : Object(catₗ)) → transport catᵣ (symmetry(_≡ₑ_) (fe{x}))
instance
[≡ᶠᵘⁿᶜᵗᵒʳ]-transitivity : Transitivity(_≡ᶠᵘⁿᶜᵗᵒʳ_)
_≡ᶠᵘⁿᶜᵗᵒʳ_.functor-proof (Transitivity.proof [≡ᶠᵘⁿᶜᵗᵒʳ]-transitivity (intro fe₁ _) (intro fe₂ _)) = transitivity(_⊜_) fe₁ fe₂
NaturalTransformation.natural (_≡ᶠᵘⁿᶜᵗᵒʳ_.map-proof (Transitivity.proof [≡ᶠᵘⁿᶜᵗᵒʳ]-transitivity {[∃]-intro F₁} {[∃]-intro F₂} {[∃]-intro F₃} (intro (intro fe₁) (intro me₁)) (intro (intro fe₂) (intro me₂)))) {x}{y} {f = f} =
transport catᵣ (transitivity(_≡ₑ_) (fe₁{y}) (fe₂{y})) ∘ map(f) 🝖[ _≡ᵣₘ_ ]-[ congruence₂ₗ(_∘_)(_) (transport-of-transitivity catᵣ {ab = fe₁}{bc = fe₂}) ]
(transport catᵣ (fe₂{y}) ∘ transport catᵣ (fe₁{y})) ∘ map(f) 🝖[ _≡ᵣₘ_ ]-[ Morphism.associativity(_∘_) ]
transport catᵣ (fe₂{y}) ∘ (transport catᵣ (fe₁{y}) ∘ map(f)) 🝖[ _≡ᵣₘ_ ]-[ congruence₂ᵣ(_∘_)(_) me₁ ]
transport catᵣ (fe₂{y}) ∘ (map(f) ∘ transport catᵣ (fe₁{x})) 🝖[ _≡ᵣₘ_ ]-[ Morphism.associativity(_∘_) ]-sym
(transport catᵣ (fe₂{y}) ∘ map(f)) ∘ transport catᵣ (fe₁{x}) 🝖[ _≡ᵣₘ_ ]-[ congruence₂ₗ(_∘_)(_) me₂ ]
(map(f) ∘ transport catᵣ (fe₂{x})) ∘ transport catᵣ (fe₁{x}) 🝖[ _≡ᵣₘ_ ]-[ Morphism.associativity(_∘_) ]
map(f) ∘ (transport catᵣ (fe₂{x}) ∘ transport catᵣ (fe₁{x})) 🝖[ _≡ᵣₘ_ ]-[ congruence₂ᵣ(_∘_)(_) (transport-of-transitivity catᵣ {ab = fe₁}{bc = fe₂}) ]-sym
map(f) ∘ transport catᵣ (transitivity(_≡ₑ_) (fe₁{x}) (fe₂{x})) 🝖-end
instance
[≡ᶠᵘⁿᶜᵗᵒʳ]-equivalence : Equivalence(_≡ᶠᵘⁿᶜᵗᵒʳ_)
[≡ᶠᵘⁿᶜᵗᵒʳ]-equivalence = intro
instance
[≡ᶠᵘⁿᶜᵗᵒʳ]-equiv : Equiv(catₗ →ᶠᵘⁿᶜᵗᵒʳ catᵣ)
[≡ᶠᵘⁿᶜᵗᵒʳ]-equiv = intro(_≡ᶠᵘⁿᶜᵗᵒʳ_) ⦃ [≡ᶠᵘⁿᶜᵗᵒʳ]-equivalence ⦄
|
{
"alphanum_fraction": 0.6441181936,
"avg_line_length": 52.7549019608,
"ext": "agda",
"hexsha": "d0e8a986189ef20a91c1f3f72ecf748e56cda47e",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Structure/Category/Functor/Equiv.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Structure/Category/Functor/Equiv.agda",
"max_line_length": 225,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Structure/Category/Functor/Equiv.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z",
"num_tokens": 2688,
"size": 5381
}
|
open import Agda.Builtin.Nat
open import Agda.Builtin.Unit
data ⊥ : Set where
data _⊎_ (A B : Set) : Set where
inj₁ : A → A ⊎ B
inj₂ : B → A ⊎ B
Fin : Nat → Set
Fin zero = ⊥
Fin (suc n) = ⊤ ⊎ Fin n
n = 49
postulate
P : Nat → Set
Q : Set → Set
f : (n : Nat) → Q (Fin n) → P n
q : Q (Fin n)
p : P n
p = f _ q
|
{
"alphanum_fraction": 0.5227963526,
"avg_line_length": 13.16,
"ext": "agda",
"hexsha": "64fbcc7741221dbf9e07352e04c00ddf8de2f592",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Succeed/Issue2945.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Succeed/Issue2945.agda",
"max_line_length": 33,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/Issue2945.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 149,
"size": 329
}
|
-- Andreas, 2018-10-17
--
-- Cannot branch on erased argument.
open import Agda.Builtin.Bool
T : @0 Bool → Set
T true = Bool
T false = Bool → Bool
-- Should fail with error like:
--
-- Cannot branch on erased argument of datatype Bool
-- when checking the definition of T
|
{
"alphanum_fraction": 0.6992753623,
"avg_line_length": 18.4,
"ext": "agda",
"hexsha": "272e5913afe40f5c93ecb2b997b8bb3b7277b402",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Fail/Erasure-Branch-On-Erased.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Fail/Erasure-Branch-On-Erased.agda",
"max_line_length": 52,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Fail/Erasure-Branch-On-Erased.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 74,
"size": 276
}
|
module MLib where
import MLib.Prelude
import MLib.Fin.Parts
import MLib.Fin.Parts.Simple
import MLib.Finite
import MLib.Finite.Properties
import MLib.Algebra.PropertyCode
import MLib.Matrix
|
{
"alphanum_fraction": 0.8256410256,
"avg_line_length": 13.9285714286,
"ext": "agda",
"hexsha": "bf49784e7295da1d0037daf99c52c477b048f3eb",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bch29/agda-matrices",
"max_forks_repo_path": "src/MLib.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "bch29/agda-matrices",
"max_issues_repo_path": "src/MLib.agda",
"max_line_length": 32,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bch29/agda-matrices",
"max_stars_repo_path": "src/MLib.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 54,
"size": 195
}
|
{-# OPTIONS --without-K #-}
module sets.nat where
open import sets.nat.core public
open import sets.nat.properties public
open import sets.nat.ordering public
open import sets.nat.solver public
open import sets.nat.struct public
|
{
"alphanum_fraction": 0.7844827586,
"avg_line_length": 23.2,
"ext": "agda",
"hexsha": "48b3be8f7707bd94041c03e8536750e63a7827c8",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z",
"max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "pcapriotti/agda-base",
"max_forks_repo_path": "src/sets/nat.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c",
"max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "pcapriotti/agda-base",
"max_issues_repo_path": "src/sets/nat.agda",
"max_line_length": 38,
"max_stars_count": 20,
"max_stars_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "pcapriotti/agda-base",
"max_stars_repo_path": "src/sets/nat.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-01T11:25:54.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-06-12T12:20:17.000Z",
"num_tokens": 55,
"size": 232
}
|
module _<?_ where
open import Data.Nat using (ℕ; zero; suc)
open import Relation.Nullary using (¬_)
open import decidable using (Dec; yes; no)
-- 厳密な不等式 (strict inequality)
infix 4 _<_
data _<_ : ℕ → ℕ → Set where
z<s : ∀ {n : ℕ}
------------
→ zero < suc n
s<s : ∀ {m n : ℕ}
→ m < n
-------------
→ suc m < suc n
-- 0未満の自然数は存在しない
¬m<z : ∀ {m : ℕ} → ¬ (m < zero)
¬m<z ()
-- m < n が成り立たなければ (m + 1) < (n + 1) も成り立たない
¬s<s : ∀ {m n : ℕ} → ¬ (m < n) → ¬ (suc m < suc n)
¬s<s ¬m<n (s<s m<n) = ¬m<n m<n
-- decidableを使った厳密な不等式
_<?_ : ∀ (m n : ℕ) → Dec (m < n)
m <? zero = no ¬m<z
zero <? suc n = yes z<s
suc m <? suc n with m <? n
... | yes m<n = yes (s<s m<n)
... | no ¬m<n = no (¬s<s ¬m<n)
|
{
"alphanum_fraction": 0.4323979592,
"avg_line_length": 23.0588235294,
"ext": "agda",
"hexsha": "a5cad5be969d29d74bad18bc80baa322baf02350",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "akiomik/plfa-solutions",
"max_forks_repo_path": "part1/decidable/_<?_.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "akiomik/plfa-solutions",
"max_issues_repo_path": "part1/decidable/_<?_.agda",
"max_line_length": 50,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "akiomik/plfa-solutions",
"max_stars_repo_path": "part1/decidable/_<?_.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z",
"num_tokens": 341,
"size": 784
}
|
-- Andrea & Andreas, 2014-11-12
-- Pruning projected vars during solving
open import Common.Product
open import Common.Equality
postulate
A : Set
works1 : {q1 : Set} {q2 : Set → Set} ->
let M : Set -> Set; M = _ in {z : Set} -> q1 ≡ M (q2 z)
works1 = refl
works2 : {q1 : Set} {q2 : Set → Set} ->
let M : Set -> Set; M = _ in q1 ≡ M (q2 A)
works2 = refl
works3 : {q : Set × Set} ->
let M : Set -> Set; M = _ in proj₁ q ≡ M (proj₂ q)
works3 = refl
test1 : {q : Set × (Set → Set)} ->
let M : Set -> Set; M = _ in {z : Set} -> proj₁ q ≡ M (proj₂ q z)
test1 = refl
test2 : {q : Set × (Set → Set)} ->
let M : Set -> Set; M = _ in proj₁ q ≡ M (proj₂ q A)
test2 = refl
-- these tests should succeed, as expanding q into a pair gets us back to
-- works1 and works2
|
{
"alphanum_fraction": 0.5555555556,
"avg_line_length": 25.03125,
"ext": "agda",
"hexsha": "14cdc1a49430ca17607904706e12f63a0e903375",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Succeed/Issue1357.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Succeed/Issue1357.agda",
"max_line_length": 73,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/Issue1357.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 291,
"size": 801
}
|
module Syntax where
open import Data.Fin
open import Data.List hiding (reverse)
open import Data.List.All
open import Data.Nat
open import Data.Product
open import Typing hiding (send ; recv)
-- expressions
data Expr Φ : Type → Set where
var : ∀ {t}
→ (x : t ∈ Φ)
→ Expr Φ t
nat : (unr-Φ : All Unr Φ)
→ (i : ℕ)
→ Expr Φ TInt
unit : (unr-Φ : All Unr Φ)
→ Expr Φ TUnit
letbind : ∀ {Φ₁ Φ₂ t₁ t₂}
→ (sp : Split Φ Φ₁ Φ₂)
→ (e₁ : Expr Φ₁ t₁)
→ (e₂ : Expr (t₁ ∷ Φ₂) t₂)
→ Expr Φ t₂
pair : ∀ {Φ₁ Φ₂ t₁ t₂}
→ (sp : Split Φ Φ₁ Φ₂)
→ (x₁ : t₁ ∈ Φ₁)
→ (x₂ : t₂ ∈ Φ₂)
→ Expr Φ (TPair t₁ t₂)
letpair : ∀ {Φ₁ Φ₂ t₁ t₂ t}
→ (sp : Split Φ Φ₁ Φ₂)
→ (p : TPair t₁ t₂ ∈ Φ₁)
→ (e : Expr (t₁ ∷ t₂ ∷ Φ₂) t)
→ Expr Φ t
fork : (e : Expr Φ TUnit)
→ Expr Φ TUnit
new : (unr-Φ : All Unr Φ)
→ (s : SType)
→ Expr Φ (TPair (TChan (SType.force s)) (TChan (SType.force (dual s))))
send : ∀ {Φ₁ Φ₂ s t}
→ (sp : Split Φ Φ₁ Φ₂)
→ (ch : (TChan (transmit SND t s)) ∈ Φ₁)
→ (vv : t ∈ Φ₂)
→ Expr Φ (TChan (SType.force s))
recv : ∀ {s t}
→ (ch : (TChan (transmit RCV t s)) ∈ Φ)
→ Expr Φ (TPair (TChan (SType.force s)) t)
close : (ch : TChan send! ∈ Φ)
→ Expr Φ TUnit
wait : (ch : TChan send? ∈ Φ)
→ Expr Φ TUnit
select : ∀ {s₁ s₂}
→ (lab : Selector)
→ (ch : TChan (sintern s₁ s₂) ∈ Φ)
→ Expr Φ (TChan (selection lab (SType.force s₁) (SType.force s₂)))
branch : ∀ {s₁ s₂ Φ₁ Φ₂ t}
→ (sp : Split Φ Φ₁ Φ₂)
→ (ch : TChan (sextern s₁ s₂) ∈ Φ₁)
→ (eleft : Expr (TChan (SType.force s₁) ∷ Φ₂) t)
→ (erght : Expr (TChan (SType.force s₂) ∷ Φ₂) t)
→ Expr Φ t
nselect : ∀ {m alt}
→ (lab : Fin m)
→ (ch : TChan (sintN m alt) ∈ Φ)
→ Expr Φ (TChan (SType.force (alt lab)))
nbranch : ∀ {m alt Φ₁ Φ₂ t}
→ (sp : Split Φ Φ₁ Φ₂)
→ (ch : TChan (sextN m alt) ∈ Φ₁)
→ (ealts : (i : Fin m) → Expr (TChan (SType.force (alt i)) ∷ Φ₂) t)
→ Expr Φ t
ulambda : ∀ {Φ₁ Φ₂ t₁ t₂}
→ (sp : Split Φ Φ₁ Φ₂)
→ (unr-Φ₁ : All Unr Φ₁)
→ (unr-Φ₂ : All Unr Φ₂)
→ (ebody : Expr (t₁ ∷ Φ₁) t₂)
→ Expr Φ (TFun UU t₁ t₂)
llambda : ∀ {Φ₁ Φ₂ t₁ t₂}
→ (sp : Split Φ Φ₁ Φ₂)
→ (unr-Φ₂ : All Unr Φ₂)
→ (ebody : Expr (t₁ ∷ Φ₁) t₂)
→ Expr Φ (TFun LL t₁ t₂)
app : ∀ {Φ₁ Φ₂ lu t₁ t₂}
→ (sp : Split Φ Φ₁ Φ₂)
→ (xfun : TFun lu t₁ t₂ ∈ Φ₁)
→ (xarg : t₁ ∈ Φ₂)
→ Expr Φ t₂
rec : ∀ {t₁ t₂}
→ (unr-Φ : All Unr Φ)
→ let t = TFun UU t₁ t₂ in
(ebody : Expr (t ∷ t₁ ∷ Φ) t₂)
→ Expr Φ t
subsume : ∀ {t₁ t₂}
→ (e : Expr Φ t₁)
→ (t≤t' : SubT t₁ t₂)
→ Expr Φ t₂
unr-weaken : ∀ {Φ Φ₁ Φ₂ t} → Split Φ Φ₁ Φ₂ → All Unr Φ₂ → Expr Φ₁ t → Expr Φ t
unr-weaken sp un-Φ₂ (var x) = var (unr-weaken-var sp un-Φ₂ x)
unr-weaken sp un-Φ₂ (nat unr-Φ i) = letbind sp (nat unr-Φ i) (var (here un-Φ₂))
unr-weaken sp un-Φ₂ (unit unr-Φ) = letbind sp (unit unr-Φ) (var (here un-Φ₂))
unr-weaken sp un-Φ₂ (letbind sp₁ e e₁) = letbind sp (letbind sp₁ e e₁) (var (here un-Φ₂))
unr-weaken sp un-Φ₂ (pair sp₁ x₁ x₂) = letbind sp (pair sp₁ x₁ x₂) (var (here un-Φ₂))
unr-weaken sp un-Φ₂ (letpair sp₁ p e) = letbind sp (letpair sp₁ p e) (var (here un-Φ₂))
unr-weaken sp un-Φ₂ (fork e) = unr-weaken sp un-Φ₂ e
unr-weaken sp un-Φ₂ (new unr-Φ s) = letbind sp (new unr-Φ s) (var (here un-Φ₂))
unr-weaken sp un-Φ₂ (send sp₁ ch vv) = letbind sp (send sp₁ ch vv) (var (here un-Φ₂))
unr-weaken sp un-Φ₂ (recv ch) = letbind sp (recv ch) (var (here un-Φ₂))
unr-weaken sp un-Φ₂ (close ch) = letbind sp (close ch) (var (here un-Φ₂))
unr-weaken sp un-Φ₂ (wait ch) = letbind sp (wait ch) (var (here un-Φ₂))
unr-weaken sp un-Φ₂ (nselect lab ch) = letbind sp (nselect lab ch) (var (here un-Φ₂))
unr-weaken sp un-Φ₂ (nbranch sp₁ ch ealts) = letbind sp (nbranch sp₁ ch ealts) (var (here un-Φ₂))
unr-weaken sp un-Φ₂ (select lab ch) = letbind sp (select lab ch) (var (here un-Φ₂))
unr-weaken sp un-Φ₂ (branch sp₁ ch e e₁) with split-rotate sp sp₁
... | Φ' , sp-ΦΦ₃Φ' , sp-Φ'Φ₄Φ₂ = branch sp-ΦΦ₃Φ' ch (unr-weaken (left sp-Φ'Φ₄Φ₂) un-Φ₂ e) (unr-weaken (left sp-Φ'Φ₄Φ₂) un-Φ₂ e₁)
unr-weaken sp un-Φ₂ (ulambda sp₁ unr-Φ₁ unr-Φ₂ e) = ulambda sp (split-unr sp₁ unr-Φ₁ unr-Φ₂) un-Φ₂ (unr-weaken (left sp₁) unr-Φ₂ e)
unr-weaken sp un-Φ₂ (llambda sp₁ unr-Φ₂ e) = llambda sp un-Φ₂ (unr-weaken (left sp₁) unr-Φ₂ e)
unr-weaken sp un-Φ₂ (app sp₁ xfun xarg) = letbind sp (app sp₁ xfun xarg) (var (here un-Φ₂))
unr-weaken sp un-Φ₂ (rec unr-Φ e) = rec (split-unr sp unr-Φ un-Φ₂) (unr-weaken (left (left sp)) un-Φ₂ e)
unr-weaken sp un-Φ₂ (subsume e t≤t') = subsume (unr-weaken sp un-Φ₂ e) t≤t'
lift-expr : ∀ {Φ t tᵤ} → Unr tᵤ → Expr Φ t → Expr (tᵤ ∷ Φ) t
lift-expr unrtu (var x) = var (there unrtu x)
lift-expr unrtu (nat unr-Φ i) = nat (unrtu ∷ unr-Φ) i
lift-expr unrtu (unit unr-Φ) = unit (unrtu ∷ unr-Φ)
lift-expr unrtu (letbind sp e e₁) = letbind (left sp) (lift-expr unrtu e) e₁
lift-expr unrtu (pair sp x₁ x₂) = pair (rght sp) x₁ (there unrtu x₂)
lift-expr unrtu (letpair sp p e) = letpair (left sp) (there unrtu p) e
lift-expr unrtu (fork e) = lift-expr unrtu e
lift-expr unrtu (new unr-Φ s) = new (unrtu ∷ unr-Φ) s
lift-expr unrtu (close ch) = close (there unrtu ch)
lift-expr unrtu (wait ch) = wait (there unrtu ch)
lift-expr unrtu (send sp ch vv) = send (rght sp) ch (there unrtu vv)
lift-expr unrtu (recv ch) = recv (there unrtu ch)
lift-expr unrtu (nselect lab ch) = nselect lab (there unrtu ch)
lift-expr unrtu (nbranch sp ch ealts) = nbranch (left sp) (there unrtu ch) ealts
lift-expr unrtu (select lab ch) = select lab (there unrtu ch)
lift-expr unrtu (branch sp ch x₁ x₂) = branch (left sp) (there unrtu ch) x₁ x₂
lift-expr unrtu (ulambda sp unr-Φ unr-Φ₂ ebody) = ulambda (rght sp) unr-Φ (unrtu ∷ unr-Φ₂) ebody
lift-expr unrtu (llambda sp unr-Φ₂ ebody) = llambda (rght sp) (unrtu ∷ unr-Φ₂) ebody
lift-expr unrtu (app sp xfun xarg) = app (rght sp) xfun (there unrtu xarg)
lift-expr{Φ} unrtu (rec unr-Φ ebody) = letbind (left (split-all-right Φ)) (var (here [])) (rec (unrtu ∷ unr-Φ) (unr-weaken (left (left (rght (split-all-left Φ)))) (unrtu ∷ []) ebody))
lift-expr unrtu (subsume e t≤t') = subsume (lift-expr unrtu e) t≤t'
unr-subst : ∀ {Φ Φ₁ Φ₂ tᵤ t} → Unr tᵤ → Split Φ Φ₁ Φ₂ → All Unr Φ₁ → Expr Φ₁ tᵤ → Expr (tᵤ ∷ Φ₂) t → Expr Φ t
unr-subst unrtu sp unr-Φ₁ etu (var (here x)) = unr-weaken sp x etu
unr-subst unrtu sp unr-Φ₁ etu (var (there x x₁)) = var (unr-weaken-var (split-sym sp) unr-Φ₁ x₁)
unr-subst unrtu sp unr-Φ₁ etu (nat (unr-tu ∷ unr-Φ) i) = nat (split-unr sp unr-Φ₁ unr-Φ) i
unr-subst unrtu sp unr-Φ₁ etu (unit (_ ∷ unr-Φ)) = unit (split-unr sp unr-Φ₁ unr-Φ)
unr-subst unrtu sp unr-Φ₁ etu (letbind sp₁ e e₁) = letbind sp etu (letbind sp₁ e e₁)
unr-subst unrtu sp unr-Φ₁ etu (pair sp₁ x₁ x₂) = letbind sp etu (pair sp₁ x₁ x₂)
unr-subst unrtu sp unr-Φ₁ etu (letpair sp₁ p e) = letbind sp etu (letpair sp₁ p e)
unr-subst unrtu sp unr-Φ₁ etu (fork e) = unr-subst unrtu sp unr-Φ₁ etu e
unr-subst unrtu sp unr-Φ₁ etu (new unr-Φ s) = letbind sp etu (new unr-Φ s)
unr-subst unrtu sp unr-Φ₁ etu (send sp₁ ch vv) = letbind sp etu (send sp₁ ch vv)
unr-subst unrtu sp unr-Φ₁ etu (recv ch) = letbind sp etu (recv ch)
unr-subst unrtu sp unr-Φ₁ etu (close ch) = letbind sp etu (close ch)
unr-subst unrtu sp unr-Φ₁ etu (wait ch) = letbind sp etu (wait ch)
unr-subst unrtu sp unr-Φ₁ etu (nselect lab ch) = letbind sp etu (nselect lab ch)
unr-subst unrtu sp unr-Φ₁ etu (nbranch sp₁ ch ealts) = letbind sp etu (nbranch sp₁ ch ealts)
unr-subst unrtu sp unr-Φ₁ etu (select lab ch) = letbind sp etu (select lab ch)
unr-subst unrtu sp unr-Φ₁ etu (branch sp₁ ch e e₁) = letbind sp etu (branch sp₁ ch e e₁)
unr-subst unrtu sp unr-Φ₁ etu (ulambda sp₁ unr-Φ₂ unr-Φ₃ e) = letbind sp etu (ulambda sp₁ unr-Φ₂ unr-Φ₃ e)
unr-subst unrtu sp unr-Φ₁ etu (llambda sp₁ unr-Φ₂ e) = letbind sp etu (llambda sp₁ unr-Φ₂ e)
unr-subst unrtu sp unr-Φ₁ etu (app sp₁ xfun xarg) = letbind sp etu (app sp₁ xfun xarg)
unr-subst unrtu sp unr-Φ₁ etu (rec unr-Φ e) = letbind sp etu (rec unr-Φ e)
unr-subst unrtu sp unr-Φ₁ etu (subsume e t≤t') = subsume (unr-subst unrtu sp unr-Φ₁ etu e) t≤t'
expr-coerce : ∀ {Φ t₁ t₂ t₁' t₂'} → Expr (t₁ ∷ Φ) t₂ → SubT t₂ t₂' → SubT t₁' t₁ → Expr (t₁' ∷ Φ) t₂'
expr-coerce e t2≤t2' t1'≤t1 = letbind (left (split-all-right _)) (subsume (var (here [])) t1'≤t1) (subsume e t2≤t2')
|
{
"alphanum_fraction": 0.6105113299,
"avg_line_length": 44.1308900524,
"ext": "agda",
"hexsha": "4820505e4db3dcde4390a52e2e6f462a9d2d5a98",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "c2213909c8a308fb1c1c1e4e789d65ba36f6042c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "peterthiemann/definitional-session",
"max_forks_repo_path": "src/Syntax.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c2213909c8a308fb1c1c1e4e789d65ba36f6042c",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "peterthiemann/definitional-session",
"max_issues_repo_path": "src/Syntax.agda",
"max_line_length": 183,
"max_stars_count": 9,
"max_stars_repo_head_hexsha": "c2213909c8a308fb1c1c1e4e789d65ba36f6042c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "peterthiemann/definitional-session",
"max_stars_repo_path": "src/Syntax.agda",
"max_stars_repo_stars_event_max_datetime": "2021-01-18T08:10:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-01-19T16:33:27.000Z",
"num_tokens": 3970,
"size": 8429
}
|
{-# OPTIONS --without-K --safe --no-universe-polymorphism --sized-types
--no-guardedness --no-subtyping #-}
module Agda.Builtin.Size where
{-# BUILTIN SIZEUNIV SizeUniv #-}
{-# BUILTIN SIZE Size #-}
{-# BUILTIN SIZELT Size<_ #-}
{-# BUILTIN SIZESUC ↑_ #-}
{-# BUILTIN SIZEINF ∞ #-}
{-# BUILTIN SIZEMAX _⊔ˢ_ #-}
{-# FOREIGN GHC
type SizeLT i = ()
#-}
{-# COMPILE GHC Size = type () #-}
{-# COMPILE GHC Size<_ = type SizeLT #-}
{-# COMPILE GHC ↑_ = \_ -> () #-}
{-# COMPILE GHC ∞ = () #-}
{-# COMPILE GHC _⊔ˢ_ = \_ _ -> () #-}
|
{
"alphanum_fraction": 0.5008237232,
"avg_line_length": 27.5909090909,
"ext": "agda",
"hexsha": "54ea1ace2ca7738e894e950f502b08f28ca62f1b",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "shlevy/agda",
"max_forks_repo_path": "src/data/lib/prim/Agda/Builtin/Size.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "src/data/lib/prim/Agda/Builtin/Size.agda",
"max_line_length": 71,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "src/data/lib/prim/Agda/Builtin/Size.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 186,
"size": 607
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.