Search is not available for this dataset
text
string | meta
dict |
---|---|
module Data.Maybe where
data Maybe (a : Set) : Set where
nothing : Maybe a
just : a -> Maybe a
|
{
"alphanum_fraction": 0.625,
"avg_line_length": 13,
"ext": "agda",
"hexsha": "ae9670febdfe4765f0eb92a488f08e59a3c4dd00",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "larrytheliquid/agda",
"max_forks_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Maybe.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "larrytheliquid/agda",
"max_issues_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Maybe.agda",
"max_line_length": 32,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "larrytheliquid/agda",
"max_stars_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Maybe.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 32,
"size": 104
}
|
{-# OPTIONS --cubical-compatible --rewriting --confluence-check #-}
module Issue1719.Common where
ofType : ∀ {i} (A : Set i) → A → A
ofType A x = x
syntax ofType A x = x :> A
infixr 3 ofType
postulate
_↦_ : ∀ {i} {A : Set i} → A → A → Set i
idr : ∀ {i} {A : Set i} {a : A} → a ↦ a
{-# BUILTIN REWRITE _↦_ #-}
infixr 3 _==_
data _==_ {i} {A : Set i} (a : A) : A → Set i where
idp : a == a
HetEq : ∀ {i} {A B : Set i} (e : A == B) (a : A) (b : B) → Set i
HetEq idp a b = (a == b)
PathOver : ∀ {i j} {A : Set i} (B : A → Set j)
{x y : A} (p : x == y) (u : B x) (v : B y) → Set j
PathOver B idp u v = (u == v)
syntax PathOver B p u v =
u == v [ B ↓ p ]
postulate
PathOver-rewr : ∀ {i j} {A : Set i} {B : Set j} {x y : A} (p : x == y) (u v : B) →
(PathOver (λ _ → B) p u v) ↦ (u == v)
{-# REWRITE PathOver-rewr #-}
-- Note that this is both [ap] and [apd], as a [PathOver] in a constant family
-- reduces to the usual identity type.
ap : ∀ {i j} {A : Set i} {B : A → Set j} (f : (a : A) → B a) {x y : A}
→ (p : x == y) → PathOver B p (f x) (f y)
ap f idp = idp
postulate
ap-cst : ∀ {i j} {A : Set i} {B : Set j} (b : B) {x y : A} (p : x == y) →
ap (λ _ → b) p ↦ idp
{-# REWRITE ap-cst #-}
|
{
"alphanum_fraction": 0.4816326531,
"avg_line_length": 26.0638297872,
"ext": "agda",
"hexsha": "9f51acee20a1a062bb806a36c211d8091456fd40",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "KDr2/agda",
"max_forks_repo_path": "test/Succeed/Issue1719/Common.agda",
"max_issues_count": 6,
"max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "KDr2/agda",
"max_issues_repo_path": "test/Succeed/Issue1719/Common.agda",
"max_line_length": 84,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "KDr2/agda",
"max_stars_repo_path": "test/Succeed/Issue1719/Common.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 546,
"size": 1225
}
|
module A where
import B
import C
|
{
"alphanum_fraction": 0.7647058824,
"avg_line_length": 6.8,
"ext": "agda",
"hexsha": "452b85a4f7fed7eab7825d909ccc8fc8aaf534ab",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "examples/uptodate/A.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "examples/uptodate/A.agda",
"max_line_length": 14,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "examples/uptodate/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": 10,
"size": 34
}
|
{-# OPTIONS --without-K #-}
module Util.HoTT.Univalence where
open import Util.HoTT.Univalence.Axiom public
open import Util.HoTT.Univalence.Beta public
open import Util.HoTT.Univalence.ContrFormulation public using
( UnivalenceContr ; UnivalenceProp ; univalenceContr ; univalenceProp )
open import Util.HoTT.Univalence.Statement public
|
{
"alphanum_fraction": 0.8123167155,
"avg_line_length": 37.8888888889,
"ext": "agda",
"hexsha": "0071d1609415996ecf2a89c08950c1a21039ea3f",
"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": "104cddc6b65386c7e121c13db417aebfd4b7a863",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "JLimperg/msc-thesis-code",
"max_forks_repo_path": "src/Util/HoTT/Univalence.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "JLimperg/msc-thesis-code",
"max_issues_repo_path": "src/Util/HoTT/Univalence.agda",
"max_line_length": 73,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "JLimperg/msc-thesis-code",
"max_stars_repo_path": "src/Util/HoTT/Univalence.agda",
"max_stars_repo_stars_event_max_datetime": "2021-06-26T06:37:31.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-04-13T21:31:17.000Z",
"num_tokens": 84,
"size": 341
}
|
module plfa.part1.Induction where
import Relation.Binary.PropositionalEquality as Eq
open Eq using (_≡_; refl; cong; sym)
open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; step-≡; _∎)
open import Data.Nat using (ℕ; zero; suc; _+_; _*_; _∸_)
_ : (3 + 4) + 5 ≡ 3 + (4 + 5)
_ =
begin
(3 + 4) + 5
≡⟨⟩
7 + 5
≡⟨⟩
12
≡⟨⟩
3 + 9
≡⟨⟩
3 + (4 + 5)
∎
+-assoc : ∀ (m n p : ℕ) → (m + n) + p ≡ m + (n + p)
+-assoc zero n p = refl
+-assoc (suc m) n p = cong suc (+-assoc m n p)
+-suc : ∀ (m n : ℕ) → m + suc n ≡ suc (m + n)
+-suc zero n = refl
+-suc (suc m) n = cong suc (+-suc m n)
+-commu : ∀ (m n : ℕ) → m + n ≡ n + m
+-commu zero zero = refl
+-commu zero (suc n) = cong suc (+-commu zero n)
+-commu (suc m) zero = cong suc (+-commu m zero)
+-commu (suc m) (suc n)
rewrite +-suc m n
rewrite +-suc n m = cong suc (cong suc (+-commu m n))
+-identityʳ : ∀ (m : ℕ) → m + zero ≡ m
+-identityʳ m rewrite +-commu m zero = refl
+-swap : ∀ (m n p : ℕ) → m + (n + p) ≡ n + (m + p)
+-swap m n p rewrite +-commu m (n + p)
rewrite +-assoc n p m
rewrite +-commu p m = refl
*-assoc : ∀ (m n p : ℕ) → (m + n) * p ≡ m * p + n * p
*-assoc zero n p = refl
*-assoc (suc m) n p
rewrite +-commu (suc m) n
rewrite +-assoc p (m * p) (n * p) = cong (λ n → p + n) (*-assoc m n p)
|
{
"alphanum_fraction": 0.4980901451,
"avg_line_length": 25.1730769231,
"ext": "agda",
"hexsha": "c01d1d026e4cb0b68268b15579777dca5c4a10cf",
"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": "275ecc582b3a6a1da1af387251c6b4d74d9a5203",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "sym-cereal/proofs",
"max_forks_repo_path": "plfa/part1/Induction.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "275ecc582b3a6a1da1af387251c6b4d74d9a5203",
"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": "sym-cereal/proofs",
"max_issues_repo_path": "plfa/part1/Induction.agda",
"max_line_length": 72,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "275ecc582b3a6a1da1af387251c6b4d74d9a5203",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "UnsoundWitch/proofs",
"max_stars_repo_path": "plfa/part1/Induction.agda",
"max_stars_repo_stars_event_max_datetime": "2021-01-18T10:58:03.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-01-03T03:29:40.000Z",
"num_tokens": 584,
"size": 1309
}
|
------------------------------------------------------------------------
-- Specifications of output-restricted deques (single-ended queues
-- with cons)
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Equality
module Queue {c⁺} (eq : ∀ {a p} → Equality-with-J a p c⁺) where
open Derived-definitions-and-properties eq
open import Prelude
open import Bijection eq as Bijection using (_↔_)
import Equivalence eq as Eq
open import Function-universe eq as F hiding (id; _∘_)
open import List eq as L hiding (map)
open import Maybe eq
open import Surjection eq using (_↠_)
private
variable
a ℓ ℓ₁ ℓ₂ : Level
A B : Type a
P Q : ∀ {ℓ} → Type ℓ → Type ℓ
p q x : A
f : A → B
xs : List A
-- A specification of when (and how) a type constructor implements
-- output-restricted deques.
record Is-queue
-- A family of queue types.
(Q : ∀ {ℓ} → Type ℓ → Type ℓ)
-- Some operations are only available for carrier types
-- satisfying this predicate.
(P : ∀ {ℓ} → Type ℓ → Type ℓ)
ℓ :
Type (lsuc ℓ) where
field
-- Conversion functions.
to-List : {A : Type ℓ} → P A → Q A → List A
from-List : {A : Type ℓ} → List A → Q A
to-List-from-List : to-List p (from-List xs) ≡ xs
-- Enqueues an element.
enqueue : {A : Type ℓ} → A → Q A → Q A
to-List-enqueue : to-List p (enqueue x q) ≡ to-List p q ++ x ∷ []
-- Dequeues an element, if possible.
dequeue : {A : Type ℓ} → P A → Q A → Maybe (A × Q A)
to-List-dequeue : ⊎-map id (Σ-map id (to-List p)) (dequeue p q) ≡
_↔_.to List↔Maybe[×List] (to-List p q)
-- The "inverse" of the dequeue operation.
dequeue⁻¹ : {A : Type ℓ} → Maybe (A × Q A) → Q A
to-List-dequeue⁻¹ :
to-List p (dequeue⁻¹ x) ≡
_↔_.from List↔Maybe[×List] (⊎-map id (Σ-map id (to-List p)) x)
-- This module exports universe-polymorphic queue
-- operations/properties.
module Is-queue⁺ ⦃ is-queue : ∀ {ℓ} → Is-queue Q P ℓ ⦄ where
private
module Q {ℓ} = Is-queue (is-queue {ℓ = ℓ})
open Q public
-- A split surjection from queues to lists.
Queue↠List : P A → Q A ↠ List A
Queue↠List p = record
{ logical-equivalence = record
{ to = to-List p
; from = from-List
}
; right-inverse-of = λ _ → to-List-from-List
}
-- An empty queue.
empty : Q A
empty = dequeue⁻¹ nothing
to-List-empty : to-List p empty ≡ ([] ⦂ List A)
to-List-empty {p = p} =
to-List p empty ≡⟨⟩
to-List p (dequeue⁻¹ nothing) ≡⟨ to-List-dequeue⁻¹ ⟩
_↔_.from List↔Maybe[×List] (⊎-map id (Σ-map id (to-List p)) nothing) ≡⟨⟩
[] ∎
-- Adds an element to the front of a queue.
cons : A → Q A → Q A
cons x q = dequeue⁻¹ (just (x , q))
to-List-cons : to-List p (cons x q) ≡ x ∷ to-List p q
to-List-cons {p = p} {x = x} {q = q} =
to-List p (cons x q) ≡⟨⟩
to-List p (dequeue⁻¹ (just (x , q))) ≡⟨ to-List-dequeue⁻¹ ⟩
_↔_.from List↔Maybe[×List]
(⊎-map id (Σ-map id (to-List p)) (just (x , q))) ≡⟨⟩
x ∷ to-List p q ∎
open Is-queue⁺ public
-- A specification of when (and how) a type constructor implements
-- output-restricted deques with a map function.
record Is-queue-with-map
(Q : ∀ {ℓ} → Type ℓ → Type ℓ)
⦃ is-queue : ∀ {ℓ} → Is-queue Q P ℓ ⦄
ℓ₁ ℓ₂ :
Type (lsuc (ℓ₁ ⊔ ℓ₂)) where
field
-- A map function.
map : {A : Type ℓ₁} {B : Type ℓ₂} →
(A → B) → Q A → Q B
to-List-map : {p₁ : P B} {p₂ : P A} →
to-List p₁ (map f q) ≡ L.map f (to-List p₂ q)
-- This module exports universe-polymorphic queue
-- operations/properties.
module Is-queue-with-map⁺
⦃ is-queue : ∀ {ℓ} → Is-queue Q P ℓ ⦄
⦃ is-queue-with-map : ∀ {ℓ₁ ℓ₂} → Is-queue-with-map Q ℓ₁ ℓ₂ ⦄
where
private
module Q {ℓ₁ ℓ₂} =
Is-queue-with-map (is-queue-with-map {ℓ₁ = ℓ₁} {ℓ₂ = ℓ₂})
open Q public
open Is-queue-with-map⁺ public
-- A specification of when (and how) a type constructor implements
-- output-restricted deques with unique representations.
record Is-queue-with-unique-representations
(Q : ∀ {ℓ} → Type ℓ → Type ℓ)
⦃ is-queue : ∀ {ℓ} → Is-queue Q P ℓ ⦄
ℓ :
Type (lsuc ℓ) where
field
-- The from-List function is a left inverse of to-List.
from-List-to-List :
{A : Type ℓ} {p : P A} {q : Q A} →
from-List (to-List p q) ≡ q
-- This module exports universe-polymorphic queue
-- operations/properties.
module Is-queue-with-unique-representations⁺
⦃ is-queue : ∀ {ℓ} → Is-queue Q P ℓ ⦄
⦃ is-queue-with-unique-representations :
∀ {ℓ} → Is-queue-with-unique-representations Q ℓ ⦄
where
private
module Q {ℓ} =
Is-queue-with-unique-representations
(is-queue-with-unique-representations {ℓ = ℓ})
open Q public
-- A bijection between queues and lists.
Queue↔List : P A → Q A ↔ List A
Queue↔List p = record
{ surjection = Queue↠List p
; left-inverse-of = λ _ → from-List-to-List
}
-- There is a bijection between equality of two queues and equality
-- of the corresponding lists.
≡-for-lists↔≡ :
{A : Type a} {p : P A} {q₁ q₂ : Q A} →
to-List p q₁ ≡ to-List p q₂ ↔ q₁ ≡ q₂
≡-for-lists↔≡ {p = p} {q₁ = q₁} {q₂ = q₂} =
to-List p q₁ ≡ to-List p q₂ ↔⟨ Eq.≃-≡ $ Eq.↔⇒≃ $ Queue↔List _ ⟩□
q₁ ≡ q₂ □
-- A variant of Queue↔List.
Maybe[×Queue]↔List : P A → Maybe (A × Q A) ↔ List A
Maybe[×Queue]↔List {A = A} p =
Maybe (A × Q A) ↝⟨ F.id ⊎-cong F.id ×-cong Queue↔List p ⟩
Maybe (A × List A) ↝⟨ inverse List↔Maybe[×List] ⟩□
List A □
-- The function dequeue p is an inverse of dequeue⁻¹.
Queue↔Maybe[×Queue] : P A → Q A ↔ Maybe (A × Q A)
Queue↔Maybe[×Queue] {A = A} p =
Bijection.with-other-function
(Bijection.with-other-inverse
(Q A ↝⟨ Queue↔List p ⟩
List A ↝⟨ inverse (Maybe[×Queue]↔List p) ⟩□
Maybe (A × Q A) □)
dequeue⁻¹
(λ x →
_↔_.from-to (inverse $ Queue↔List p) (
to-List p (dequeue⁻¹ x) ≡⟨ to-List-dequeue⁻¹ ⟩∎
_↔_.to (Maybe[×Queue]↔List p) x ∎)))
(dequeue p)
(λ q → _↔_.to-from (Maybe[×Queue]↔List p) (
_↔_.to (Maybe[×Queue]↔List p) (dequeue p q) ≡⟨⟩
_↔_.from List↔Maybe[×List]
(⊎-map id (Σ-map id (to-List p)) (dequeue p q)) ≡⟨ cong (_↔_.from List↔Maybe[×List]) to-List-dequeue ⟩
_↔_.from List↔Maybe[×List]
(_↔_.to List↔Maybe[×List] (to-List p q)) ≡⟨ _↔_.left-inverse-of List↔Maybe[×List] _ ⟩∎
to-List p q ∎))
_ : {A : Type a} {p : P A} →
_↔_.to (Queue↔Maybe[×Queue] p) ≡ dequeue p
_ = refl _
_ : {A : Type a} {p : P A} →
_↔_.from (Queue↔Maybe[×Queue] p) ≡ dequeue⁻¹
_ = refl _
-- The function from-List can be expressed using enqueue and empty.
from-List≡foldl-enqueue-empty :
{A : Type a} {xs : List A} →
P A → from-List xs ≡ foldl (flip enqueue) empty xs
from-List≡foldl-enqueue-empty {A = A} {xs = xs} p =
_↔_.to ≡-for-lists↔≡ (
to-List p (from-List xs) ≡⟨ to-List-from-List ⟩
xs ≡⟨⟩
[] ++ xs ≡⟨ cong (_++ _) $ sym to-List-empty ⟩
to-List p empty ++ xs ≡⟨ lemma _ _ ⟩∎
to-List p (foldl (flip enqueue) empty xs) ∎)
where
lemma :
∀ xs (q : Q A) →
to-List p q ++ xs ≡ to-List p (foldl (flip enqueue) q xs)
lemma [] q =
to-List p q ++ [] ≡⟨ ++-right-identity _ ⟩∎
to-List p q ∎
lemma (x ∷ xs) q =
to-List p q ++ x ∷ xs ≡⟨ ++-associative (to-List _ _) _ _ ⟩
(to-List p q ++ x ∷ []) ++ xs ≡⟨ cong (_++ _) $ sym to-List-enqueue ⟩
to-List p (enqueue x q) ++ xs ≡⟨ lemma _ _ ⟩
to-List p (foldl (flip enqueue) (enqueue x q) xs) ≡⟨⟩
to-List p (foldl (flip enqueue) q (x ∷ xs)) ∎
-- A corollary.
to-List-foldl-enqueue-empty :
{A : Type a} {p : P A} (xs : List A) →
to-List p (foldl (flip enqueue) empty xs) ≡ xs
to-List-foldl-enqueue-empty {p = p} xs =
to-List p (foldl (flip enqueue) empty xs) ≡⟨ cong (to-List p) $ sym $ from-List≡foldl-enqueue-empty p ⟩
to-List p (from-List xs) ≡⟨ to-List-from-List ⟩∎
xs ∎
open Is-queue-with-unique-representations⁺ public
instance
-- Lists can be seen as queues.
List-is-queue : Is-queue List (λ _ → ↑ _ ⊤) ℓ
List-is-queue .Is-queue.to-List = λ _ → id
List-is-queue .Is-queue.from-List = id
List-is-queue .Is-queue.enqueue = λ x xs → xs ++ x ∷ []
List-is-queue .Is-queue.dequeue = λ _ → _↔_.to List↔Maybe[×List]
List-is-queue .Is-queue.dequeue⁻¹ = _↔_.from List↔Maybe[×List]
List-is-queue .Is-queue.to-List-from-List = refl _
List-is-queue .Is-queue.to-List-enqueue = refl _
List-is-queue .Is-queue.to-List-dequeue {q = []} = refl _
List-is-queue .Is-queue.to-List-dequeue {q = _ ∷ _} = refl _
List-is-queue .Is-queue.to-List-dequeue⁻¹ {x = nothing} = refl _
List-is-queue .Is-queue.to-List-dequeue⁻¹ {x = just _} = refl _
List-is-queue-with-map : Is-queue-with-map List ℓ₁ ℓ₂
List-is-queue-with-map .Is-queue-with-map.map = L.map
List-is-queue-with-map .Is-queue-with-map.to-List-map = refl _
List-is-queue-with-unique-representations :
Is-queue-with-unique-representations List ℓ
List-is-queue-with-unique-representations
.Is-queue-with-unique-representations.from-List-to-List = refl _
|
{
"alphanum_fraction": 0.5216277466,
"avg_line_length": 33.1666666667,
"ext": "agda",
"hexsha": "d3e7d3941316bdb9dbb5554386728064677583d7",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/equality",
"max_forks_repo_path": "src/Queue.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/equality",
"max_issues_repo_path": "src/Queue.agda",
"max_line_length": 114,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/equality",
"max_stars_repo_path": "src/Queue.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z",
"num_tokens": 3583,
"size": 10149
}
|
-- Andreas, 2017-12-04, issue #2862, reported by m0davis
-- Regression in development version 2.5.4
-- Scope checker allowed definition in different module than signature
-- {-# OPTIONS -v scope.data.def:30 #-}
open import Agda.Builtin.Equality
data N : Set
module Z where
data N where -- should be rejected since signature lives in different module
zero : N
unitary-N : (x y : N) → x ≡ y
unitary-N zero zero = refl
data N where
zero : N
suc : N → N
data ⊥ : Set where
one : N
one = suc zero
¬zero≡one : zero ≡ one → ⊥
¬zero≡one ()
zero≡one : zero ≡ one
zero≡one = Z.unitary-N zero one
boom : ⊥
boom = ¬zero≡one zero≡one
|
{
"alphanum_fraction": 0.6646058733,
"avg_line_length": 18.4857142857,
"ext": "agda",
"hexsha": "cdb86ee27a99060cbb2d01eba691204ad783b7b7",
"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/Issue2862.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/Issue2862.agda",
"max_line_length": 79,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/Issue2862.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": 214,
"size": 647
}
|
module Acc where
data Acc ( A : Set ) ( Lt : A -> A -> Set) : A -> Set where
acc : ( b : A )
-> ( ( a : A ) -> Lt a b -> Acc A Lt a )
-> ( Acc A Lt b )
data Nat : Set where
zero : Nat
succ : Nat -> Nat
data Lt : Nat -> Nat -> Set where
ltzero : ( x : Nat ) -> Lt zero (succ x)
ltsucc : ( x : Nat ) -> (y : Nat) -> Lt x y -> Lt (succ x) (succ y)
ltstep : (x : Nat) -> Lt x (succ x)
ltstep zero = ltzero _
ltstep (succ x) = ltsucc _ _ (ltstep x)
notLt0 : ( x : Nat ) -> Lt x zero -> (C : Set) -> C
notLt0 x ()
wkLt : ( x y : Nat ) -> Lt (succ x) (succ y) -> Lt x y
wkLt zero (succ y) _ = ltzero y
wkLt x zero (ltsucc .x .zero ())
wkLt x y (ltsucc .x .y p) = p
{-
wkLt1 : ( x y : Nat ) -> Lt (succ x) y -> Lt x y
wkLt1 x zero ()
wkLt1 zero (succ y) _ = ltzero y
wkLt1 (succ x) (succ y) (ltsucc .(succ x) .y p) = ltsucc x y (wkLt1 x y p)
-}
wkLt2 : (x y : Nat ) -> Lt x y -> Lt x (succ y)
wkLt2 x zero ()
wkLt2 zero y p = ltzero y
wkLt2 (succ x) (succ y) (ltsucc .x .y p) = ltsucc x (succ y) (wkLt2 x y p)
ltcase : ( x : Nat ) -> ( y : Nat ) -> Lt x (succ y) ->
( P : Nat -> Set ) -> ( (x' : Nat ) -> Lt x' y -> P x') -> P y -> P x
ltcase zero zero _ P hx' hy = hy
ltcase zero (succ y') _ P hx' hy = hx' zero (ltzero y')
ltcase (succ x') zero (ltsucc .x' .zero ()) _ _ _
ltcase (succ x') (succ y') (ltsucc .x' .(succ y') p) P hx' hy =
ltcase x' y' p (\ n -> P (succ n))
(\ x'' p' -> hx' (succ x'') (ltsucc x'' y' p')) hy
accSucc : (x : Nat) -> Acc Nat Lt x -> Acc Nat Lt (succ x)
accSucc x (acc .x h) = acc (succ x) (\ y p -> ltcase y x p (Acc Nat Lt) h (acc x h))
accLt : ( x : Nat ) -> Acc Nat Lt x
accLt zero = acc zero (\a -> \p -> notLt0 a p (Acc Nat Lt a) )
accLt (succ x) = accSucc x (accLt x)
-- subtraction x - y
sub : Nat -> Nat -> Nat
sub zero y = zero
sub (succ x) zero = succ x
sub (succ x) (succ y) = sub x y
subLt : (x y : Nat) -> Lt (sub (succ x) (succ y)) (succ x)
subLt zero y = ltzero _
subLt (succ x') zero = ltstep (succ x')
subLt (succ x') (succ y') = wkLt2 _ _ (subLt x' y')
-- division x / (y + 1)
div' : (x y : Nat) -> Acc Nat Lt x -> Nat
div' zero _ _ = zero
div' (succ x') y' (acc ._ h) = succ (div' z y' (h _ p))
where z = sub (succ x') (succ y')
p = subLt x' y'
----
data WO ( A : Set ) ( Lt : A -> A -> Set ) : Set where
wo : ((x : A) -> Acc A Lt x) -> WO A Lt
woLt : WO Nat Lt
woLt = wo accLt
|
{
"alphanum_fraction": 0.5028854081,
"avg_line_length": 27.5681818182,
"ext": "agda",
"hexsha": "e3ec5b648993552555e8d0e7316088178e4bb95a",
"lang": "Agda",
"max_forks_count": 5,
"max_forks_repo_forks_event_max_datetime": "2021-08-16T07:47:36.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-30T00:17:04.000Z",
"max_forks_repo_head_hexsha": "4a674eddcc8950f37fcc723b26f81d5164b05f08",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "andreasabel/miniagda",
"max_forks_repo_path": "examples/AccP.agda",
"max_issues_count": 7,
"max_issues_repo_head_hexsha": "4a674eddcc8950f37fcc723b26f81d5164b05f08",
"max_issues_repo_issues_event_max_datetime": "2020-03-17T08:09:01.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-12-16T15:48:25.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "andreasabel/miniagda",
"max_issues_repo_path": "examples/AccP.agda",
"max_line_length": 84,
"max_stars_count": 85,
"max_stars_repo_head_hexsha": "4a674eddcc8950f37fcc723b26f81d5164b05f08",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "andreasabel/miniagda",
"max_stars_repo_path": "examples/AccP.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-12T16:54:56.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-12-16T15:53:24.000Z",
"num_tokens": 986,
"size": 2426
}
|
module Binders.Var where
data Var (a b : Set) : Set where
Free : a -> Var a b
Bound : b -> Var a b
|
{
"alphanum_fraction": 0.5391304348,
"avg_line_length": 16.4285714286,
"ext": "agda",
"hexsha": "6abf4bd3dce3ed6c64c2ed4818eecc98bf71a035",
"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": "e0de23b3c78313a7f6856c3d48c3d6a2ce3962dd",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "hopper-lang/hopper-v0",
"max_forks_repo_path": "models/agda/Binders/Var.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "e0de23b3c78313a7f6856c3d48c3d6a2ce3962dd",
"max_issues_repo_issues_event_max_datetime": "2020-02-19T01:08:47.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-02-19T01:08:47.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "hopper-lang/hopper-v0",
"max_issues_repo_path": "models/agda/Binders/Var.agda",
"max_line_length": 35,
"max_stars_count": 17,
"max_stars_repo_head_hexsha": "e0de23b3c78313a7f6856c3d48c3d6a2ce3962dd",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "hopper-lang/hopper-v0",
"max_stars_repo_path": "models/agda/Binders/Var.agda",
"max_stars_repo_stars_event_max_datetime": "2019-03-18T03:02:06.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-09-23T16:03:03.000Z",
"num_tokens": 39,
"size": 115
}
|
module LearnYouAgda where
data ℕ : Set where
zero : ℕ
-- one : ℕ
suc : ℕ -> ℕ
-- define arithmetic operations
_+_ : ℕ → ℕ → ℕ
zero + zero = zero
zero + n = n
(suc n) + n′ = suc (n + n′)
|
{
"alphanum_fraction": 0.5117370892,
"avg_line_length": 17.75,
"ext": "agda",
"hexsha": "282bced96335fab548efc5ff71fed830e2b8e221",
"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": "c134875eae37d265936199fda278416e2a3c1224",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "supeterlau/bedev",
"max_forks_repo_path": "agda/LearnYouAgda.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c134875eae37d265936199fda278416e2a3c1224",
"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": "supeterlau/bedev",
"max_issues_repo_path": "agda/LearnYouAgda.agda",
"max_line_length": 31,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "c134875eae37d265936199fda278416e2a3c1224",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "supeterlau/bedev",
"max_stars_repo_path": "agda/LearnYouAgda.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 81,
"size": 213
}
|
{-# OPTIONS --without-K #-}
open import Base
open import Homotopy.TruncatedHIT
open import Integers
module Algebra.FreeGroupProps {i} (A : Set i) ⦃ p : is-set A ⦄ where
import Algebra.FreeGroup
open Algebra.FreeGroup A
abstract
freegroup-is-set : is-set freegroup
freegroup-is-set =
spheres-filled-is-truncated _ freegroup (λ ()) (λ f → (top f , rays f))
x·-is-equiv : (x : A) → is-equiv (λ u → x · u)
x·-is-equiv x = iso-is-eq (λ u → x · u)
(λ u → x ⁻¹· u)
(right-inverse-· x)
(left-inverse-· x)
|
{
"alphanum_fraction": 0.6434108527,
"avg_line_length": 23.4545454545,
"ext": "agda",
"hexsha": "8d7b2a3c4a27128cb552f79b31cfdf6543adac53",
"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": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nicolaikraus/HoTT-Agda",
"max_forks_repo_path": "old/Algebra/FreeGroupProps.agda",
"max_issues_count": 31,
"max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633",
"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": "nicolaikraus/HoTT-Agda",
"max_issues_repo_path": "old/Algebra/FreeGroupProps.agda",
"max_line_length": 75,
"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": "old/Algebra/FreeGroupProps.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": 174,
"size": 516
}
|
{-# OPTIONS --without-K --rewriting #-}
open import lib.Basics
open import lib.NType2
open import lib.types.Modality
open import lib.types.Truncation
module lib.modalities.Truncation where
Trunc-modality : ∀ {i} n → Modality i
Trunc-modality n = record {
is-local = has-level n;
is-local-is-prop = has-level-is-prop;
◯ = Trunc n;
◯-is-local = Trunc-level;
η = [_];
◯-elim = λ f → Trunc-elim {{f}};
◯-elim-β = λ _ _ _ → idp;
◯-=-is-local = λ _ _ → =-preserves-level Trunc-level}
|
{
"alphanum_fraction": 0.6519114688,
"avg_line_length": 24.85,
"ext": "agda",
"hexsha": "fc7bb6db4c4630dfe5071c7a0d132d587e9ec13c",
"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/modalities/Truncation.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/modalities/Truncation.agda",
"max_line_length": 55,
"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/modalities/Truncation.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": 166,
"size": 497
}
|
{-# OPTIONS --without-K --safe #-}
open import Categories.Bicategory using (Bicategory)
-- A Pseudofunctor is a homomorphism of Bicategories
-- Follow Bénabou's definition, which is basically that of a Functor
-- Note that what is in nLab is an "exploded" version of the simpler version below
module Categories.Pseudofunctor {o ℓ e t o′ ℓ′ e′ t′}
(C : Bicategory o ℓ e t)
(D : Bicategory o′ ℓ′ e′ t′)
where
open import Level
open import Data.Product using (_,_)
import Categories.Bicategory.Extras as BicategoryExtras
open import Categories.Category using (Category; _[_,_]; module Commutation)
open import Categories.Category.Instance.One using (shift)
open import Categories.Category.Product using (_⁂_)
open import Categories.Functor using (Functor; _∘F_) renaming (id to idF)
open import Categories.NaturalTransformation using (NaturalTransformation)
open import Categories.NaturalTransformation.NaturalIsomorphism
using (NaturalIsomorphism; _≃_)
open BicategoryExtras using (module ComHom)
open Category using (Obj)
open NaturalIsomorphism using (F⇒G; F⇐G)
private
module C = BicategoryExtras C
module D = BicategoryExtras D
record Pseudofunctor : Set (o ⊔ ℓ ⊔ e ⊔ t ⊔ o′ ⊔ ℓ′ ⊔ e′ ⊔ t′) where
field
P₀ : C.Obj → D.Obj
P₁ : {x y : C.Obj} → Functor (C.hom x y) (D.hom (P₀ x) (P₀ y))
-- For maximal generality, shift the levels of One. P preserves id
P-identity : {A : C.Obj} → D.id {P₀ A} ∘F shift o′ ℓ′ e′ ≃ P₁ ∘F (C.id {A})
-- P preserves composition
P-homomorphism : {x y z : C.Obj} → D.⊚ ∘F (P₁ ⁂ P₁) ≃ P₁ ∘F C.⊚ {x} {y} {z}
-- P preserves ≃
module P₁ {x} {y} = Functor (P₁ {x} {y})
module unitˡ {A} = NaturalTransformation (F⇒G (P-identity {A}))
module unitʳ {A} = NaturalTransformation (F⇐G (P-identity {A}))
module Hom {x} {y} {z} = NaturalTransformation (F⇒G (P-homomorphism {x} {y} {z}))
-- For notational convenience, shorten some functor applications
private
F₀ = λ {x y} f → Functor.F₀ (P₁ {x} {y}) f
F₁ = λ {x y f g} α → Functor.F₁ (P₁ {x} {y}) {f} {g} α
Pid = λ {A} → NaturalTransformation.η (F⇒G (P-identity {A})) _
Phom = λ {x} {y} {z} f,g →
NaturalTransformation.η (F⇒G (P-homomorphism {x} {y} {z})) f,g
field
unitaryˡ : {x y : C.Obj} →
let open ComHom D in
{f : Obj (C.hom x y)} →
[ D.id₁ D.⊚₀ F₀ f ⇒ F₀ f ]⟨
Pid D.⊚₁ D.id₂ ⇒⟨ F₀ C.id₁ D.⊚₀ F₀ f ⟩
Phom (C.id₁ , f) ⇒⟨ F₀ (C.id₁ C.⊚₀ f) ⟩
F₁ C.unitorˡ.from
≈ D.unitorˡ.from
⟩
unitaryʳ : {x y : C.Obj} →
let open ComHom D in
{f : Obj (C.hom x y)} →
[ F₀ f D.⊚₀ D.id₁ ⇒ F₀ f ]⟨
D.id₂ D.⊚₁ Pid ⇒⟨ F₀ f D.⊚₀ F₀ C.id₁ ⟩
Phom (f , C.id₁) ⇒⟨ F₀ (f C.⊚₀ C.id₁) ⟩
F₁ C.unitorʳ.from
≈ D.unitorʳ.from
⟩
assoc : {x y z w : C.Obj} →
let open ComHom D in
{f : Obj (C.hom x y)} {g : Obj (C.hom y z)} {h : Obj (C.hom z w)} →
[ (F₀ h D.⊚₀ F₀ g) D.⊚₀ F₀ f ⇒ F₀ (h C.⊚₀ (g C.⊚₀ f)) ]⟨
Phom (h , g) D.⊚₁ D.id₂ ⇒⟨ F₀ (h C.⊚₀ g) D.⊚₀ F₀ f ⟩
Phom (_ , f) ⇒⟨ F₀ ((h C.⊚₀ g) C.⊚₀ f) ⟩
F₁ C.associator.from
≈ D.associator.from ⇒⟨ F₀ h D.⊚₀ (F₀ g D.⊚₀ F₀ f) ⟩
D.id₂ D.⊚₁ Phom (g , f) ⇒⟨ F₀ h D.⊚₀ F₀ (g C.⊚₀ f) ⟩
Phom (h , _)
⟩
-- Useful shorthands
₀ = P₀
module ₁ = P₁
|
{
"alphanum_fraction": 0.5268729642,
"avg_line_length": 38.7789473684,
"ext": "agda",
"hexsha": "6e2a03be04a583bf19d9bda81256b818a5a76b2b",
"lang": "Agda",
"max_forks_count": 64,
"max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z",
"max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Code-distancing/agda-categories",
"max_forks_repo_path": "src/Categories/Pseudofunctor.agda",
"max_issues_count": 236,
"max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Code-distancing/agda-categories",
"max_issues_repo_path": "src/Categories/Pseudofunctor.agda",
"max_line_length": 83,
"max_stars_count": 279,
"max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Trebor-Huang/agda-categories",
"max_stars_repo_path": "src/Categories/Pseudofunctor.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z",
"num_tokens": 1386,
"size": 3684
}
|
{-# OPTIONS --allow-unsolved-metas --universe-polymorphism #-}
module Issue203 where
postulate
Level : Set
zero : Level
suc : Level → Level
max : Level → Level → Level
{-# BUILTIN LEVEL Level #-}
{-# BUILTIN LEVELZERO zero #-}
{-# BUILTIN LEVELSUC suc #-}
{-# BUILTIN LEVELMAX max #-}
-- Should work but give unsolved metas (type of b)
data ↓ {a b} (A : Set a) : Set a where
[_] : (x : A) → ↓ A
mutual -- avoid freezing
-- Shouldn't instantiate the level of Σ to a
data Σ {a b} (A : Set a) (B : A → Set b) : Set _ where
_,_ : (x : A) (y : B x) → Σ A B
instantiateToMax : ∀ {a b}(A : Set a)(B : A → Set b) → Set (max a b)
instantiateToMax = Σ
|
{
"alphanum_fraction": 0.5861561119,
"avg_line_length": 23.4137931034,
"ext": "agda",
"hexsha": "e7885e099f85d97e0e7367b9a7dc09415b3b7378",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "np/agda-git-experiment",
"max_forks_repo_path": "test/succeed/Issue203.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "np/agda-git-experiment",
"max_issues_repo_path": "test/succeed/Issue203.agda",
"max_line_length": 70,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "test/succeed/Issue203.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": 228,
"size": 679
}
|
module Test where
-- To compile code: stack exec -- agda Test.agda -c
-- or: agda Test.agda -c --ghc-flag=-dynamic
open import IO
-- All of these are not necessary but they help to reduce clutter when looking
-- at the types of the different things in the code
import Agda.Builtin.List as List
open import Agda.Builtin.Unit using (⊤)
open List using (_∷_)
import Agda.Builtin.String as String
main = run (putStrLn "Hello, World!")
data Bool : Set where
true : Bool
false : Bool
if_then_else_ : { A : Set } → Bool → A → A → A
if true then t else e = t
if false then t else e = e
|
{
"alphanum_fraction": 0.7006802721,
"avg_line_length": 25.5652173913,
"ext": "agda",
"hexsha": "0b836b9f5ffa6396b0efdf0c2864d4989a2d6d4e",
"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": "a432faf1b340cb379190a2f2b11b997b02d1cd8d",
"max_forks_repo_licenses": [
"CC0-1.0"
],
"max_forks_repo_name": "helq/old_code",
"max_forks_repo_path": "proglangs-learning/Agda/Test.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d",
"max_issues_repo_issues_event_max_datetime": "2021-06-07T15:39:48.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-03-10T19:20:21.000Z",
"max_issues_repo_licenses": [
"CC0-1.0"
],
"max_issues_repo_name": "helq/old_code",
"max_issues_repo_path": "proglangs-learning/Agda/Test.agda",
"max_line_length": 78,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d",
"max_stars_repo_licenses": [
"CC0-1.0"
],
"max_stars_repo_name": "helq/old_code",
"max_stars_repo_path": "proglangs-learning/Agda/Test.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 172,
"size": 588
}
|
{-# OPTIONS --without-K --safe #-}
module TypeTheory.HoTT.Function.Properties where
-- agda-stdlib
open import Axiom.Extensionality.Propositional
open import Level
-- agda-misc
open import TypeTheory.HoTT.Base
private
variable
a b : Level
A : Set a
B : Set b
module _ {a b} {A : Set a} {B : Set b} where
isProp-→ : Extensionality a b → isProp B → isProp (A → B)
isProp-→ ext B-isProp f g = ext λ x → B-isProp (f x) (g x)
|
{
"alphanum_fraction": 0.6576576577,
"avg_line_length": 21.1428571429,
"ext": "agda",
"hexsha": "3c4a8f0d6c9df2e0ae88a7a7651263d9cdd17088",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "rei1024/agda-misc",
"max_forks_repo_path": "TypeTheory/HoTT/Function/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "rei1024/agda-misc",
"max_issues_repo_path": "TypeTheory/HoTT/Function/Properties.agda",
"max_line_length": 60,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "rei1024/agda-misc",
"max_stars_repo_path": "TypeTheory/HoTT/Function/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z",
"num_tokens": 146,
"size": 444
}
|
{-# OPTIONS --rewriting --without-K #-}
open import Agda.Primitive
open import Prelude
open import GSeTT.Syntax
open import GSeTT.Rules
{- Type theory for globular sets -}
module GSeTT.Uniqueness-Derivations where
has-all-paths-∈ : ∀ {Γ x A} → Γ ⊢C → has-all-paths (x # A ∈ Γ)
has-all-paths-∈ {Γ :: (y , B)} {x} {A} (cc Γ⊢ γ⊢A idp) (inl x∈Γ) (inl x∈'Γ) = ap inl (has-all-paths-∈ Γ⊢ x∈Γ x∈'Γ)
has-all-paths-∈ {Γ :: (y , B)} {x} {A} (cc Γ⊢ γ⊢A idp) (inl x∈Γ) (inr (idp , idp)) = ⊥-elim (lΓ∉Γ Γ⊢ x∈Γ)
has-all-paths-∈ {Γ :: (y , B)} {x} {A} (cc Γ⊢ γ⊢A idp) (inr (idp , idp)) (inl x∈Γ) = ⊥-elim (lΓ∉Γ Γ⊢ x∈Γ)
has-all-paths-∈ {Γ :: (y , B)} {x} {A} (cc Γ⊢ γ⊢A idp) (inr (idp , idp)) (inr (p' , q')) =
ap inr (,= (is-prop-has-all-paths (is-setℕ x (length Γ)) idp p') (is-prop-has-all-paths ((eqdec-is-set eqdec-PreTy) A B) idp q'))
has-all-paths-⊢C : ∀ {Γ} → has-all-paths (Γ ⊢C)
has-all-paths-⊢T : ∀ {Γ A} → has-all-paths (Γ ⊢T A)
has-all-paths-⊢t : ∀ {Γ A t} → has-all-paths (Γ ⊢t t # A)
has-all-paths-⊢S : ∀ {Δ Γ γ} → has-all-paths (Δ ⊢S γ > Γ)
has-all-paths-⊢C {nil} ec ec = idp
has-all-paths-⊢C {Γ :: (x , A)} (cc Γ⊢ Γ⊢A p) (cc Γ⊢' Γ⊢'A q) = ap³ cc ((has-all-paths-⊢C Γ⊢ Γ⊢')) ((has-all-paths-⊢T Γ⊢A Γ⊢'A)) (is-prop-has-all-paths (is-setℕ x (length Γ)) p q)
has-all-paths-⊢T {Γ} {∗} (ob Γ⊢) (ob Γ⊢') = ap ob (has-all-paths-⊢C Γ⊢ Γ⊢')
has-all-paths-⊢T {Γ} {⇒ A t u} (ar Γ⊢t:A Γ⊢u:A) (ar Γ⊢'t:A Γ⊢'u:A) = ap² ar (has-all-paths-⊢t Γ⊢t:A Γ⊢'t:A) (has-all-paths-⊢t Γ⊢u:A Γ⊢'u:A)
has-all-paths-⊢t {Γ} {A} {Var x} (var Γ⊢ x∈Γ) (var Γ⊢' x∈'Γ) = ap² var (has-all-paths-⊢C Γ⊢ Γ⊢') (has-all-paths-∈ Γ⊢ x∈Γ x∈'Γ)
has-all-paths-⊢S {Δ} {Γ} {<>} (es Δ⊢) (es Δ⊢')= ap es (has-all-paths-⊢C Δ⊢ Δ⊢')
has-all-paths-⊢S {Δ} {Γ :: (y , A)} {γ :: (x , t)} (sc Δ⊢γ Γ+⊢ Δ⊢t p) (sc Δ⊢'γ Γ+⊢' Δ⊢'t q) =
ap⁴ sc (has-all-paths-⊢S Δ⊢γ Δ⊢'γ) (has-all-paths-⊢C Γ+⊢ Γ+⊢') (has-all-paths-⊢t Δ⊢t Δ⊢'t) (is-prop-has-all-paths (is-setℕ y x) p q)
is-prop-⊢C : ∀ Γ → is-prop (Γ ⊢C)
is-prop-⊢T : ∀ Γ A → is-prop (Γ ⊢T A)
is-prop-⊢t : ∀ Γ A t → is-prop (Γ ⊢t t # A)
is-prop-⊢S : ∀ Δ Γ γ → is-prop (Δ ⊢S γ > Γ)
is-prop-⊢C Γ = has-all-paths-is-prop has-all-paths-⊢C
is-prop-⊢T Γ A = has-all-paths-is-prop has-all-paths-⊢T
is-prop-⊢t Γ A t = has-all-paths-is-prop has-all-paths-⊢t
is-prop-⊢S Γ Δ γ = has-all-paths-is-prop has-all-paths-⊢S
Γ⊢→length∉ : ∀ {Γ A n} → length Γ ≤ n → Γ ⊢C → ¬ (n # A ∈ Γ)
Γ⊢→length∉ {.(_ :: (length _ , _))} Sl≤n (cc Γ⊢ x₁ idp) (inl n∈Γ) = Γ⊢→length∉ (Sn≤m→n≤m Sl≤n) Γ⊢ n∈Γ
Γ⊢→length∉ {.(_ :: (length _ , _))} Sl≤l (cc Γ⊢ x₁ idp) (inr (idp , idp)) = Sn≰n _ Sl≤l
unique-type : ∀ {Γ t u A B} → (Γ ⊢t t # A) → (Γ ⊢t u # B) → t == u → A == B
unique-type {Γ :: a} (var _ (inr (idp , idp))) (var _ (inr (idp , idp))) _ = idp
unique-type {Γ :: .(_ , _)} (var x (inl x∈Γ)) (var (cc Γ⊢ _ p) (inl x'∈Γ)) idp = unique-type (var Γ⊢ x∈Γ) (var Γ⊢ x'∈Γ ) idp
unique-type {Γ :: .(_ , _)} (var _ (inl x∈Γ)) (var (cc Γ⊢ _ idp) (inr (idp , idp))) idp = ⊥-elim (Γ⊢→length∉ (n≤n _) Γ⊢ x∈Γ)
unique-type {Γ :: .(_ , _)} (var (cc Γ⊢ _ idp) (inr (idp , idp))) (var _ (inl x∈Γ)) idp = ⊥-elim (Γ⊢→length∉ (n≤n _) Γ⊢ x∈Γ)
|
{
"alphanum_fraction": 0.5139240506,
"avg_line_length": 58.5185185185,
"ext": "agda",
"hexsha": "a3898402382a824d0465e20723cdfeb82f0e843c",
"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": "3a02010a869697f4833c9bc6047d66ca27b87cf2",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "thibautbenjamin/catt-formalization",
"max_forks_repo_path": "GSeTT/Uniqueness-Derivations.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "3a02010a869697f4833c9bc6047d66ca27b87cf2",
"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": "thibautbenjamin/catt-formalization",
"max_issues_repo_path": "GSeTT/Uniqueness-Derivations.agda",
"max_line_length": 181,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "3a02010a869697f4833c9bc6047d66ca27b87cf2",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "thibautbenjamin/catt-formalization",
"max_stars_repo_path": "GSeTT/Uniqueness-Derivations.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1863,
"size": 3160
}
|
import SOAS.Families.Core
-- Combinators for context maps
module SOAS.ContextMaps.Combinators {T : Set}
(open SOAS.Families.Core {T})
(𝒳 : Familyₛ) where
open import SOAS.Common
open import SOAS.Context {T}
open import SOAS.Sorting
open import SOAS.Variable
open import SOAS.Families.Isomorphism
open import SOAS.Families.BCCC
private
variable
Γ Γ′ Δ Δ′ Θ : Ctx
α β τ : T
-- Sub from the empty context
empty : ∅ ~[ 𝒳 ]↝ Δ
empty ()
-- Combine two maps into the same context by concatenating the domain
copair : Γ ~[ 𝒳 ]↝ Θ → Δ ~[ 𝒳 ]↝ Θ → (Γ ∔ Δ) ~[ 𝒳 ]↝ Θ
copair {∅} σ ς v = ς v
copair {α ∙ Γ} σ ς new = σ new
copair {α ∙ Γ} σ ς (old v) = copair {Γ} (σ ∘ old) ς v
copair≈₁ : {σ₁ σ₂ : Γ ~[ 𝒳 ]↝ Θ}(ς : Δ ~[ 𝒳 ]↝ Θ){v : ℐ α (Γ ∔ Δ)}
→ ({τ : T}(v : ℐ τ Γ) → σ₁ v ≡ σ₂ v)
→ copair σ₁ ς v ≡ copair σ₂ ς v
copair≈₁ ς {v} p = cong (λ - → copair (λ {τ} → - {τ}) ς v) (dext (λ y → p y))
copair≈₂ : (σ : Γ ~[ 𝒳 ]↝ Θ){ς₁ ς₂ : Δ ~[ 𝒳 ]↝ Θ}{v : ℐ α (Γ ∔ Δ)}
→ ({τ : T}(v : ℐ τ Δ) → ς₁ v ≡ ς₂ v)
→ copair σ ς₁ v ≡ copair σ ς₂ v
copair≈₂ σ {v = v} p = cong (λ - → copair σ (λ {τ} → - {τ}) v) (dext (λ y → p y))
-- Split a map from a combined context into two maps
split : (Γ ∔ Δ) ~[ 𝒳 ]↝ Θ → Γ ~[ 𝒳 ]↝ Θ × Δ ~[ 𝒳 ]↝ Θ
split {∅} σ = (λ ()) , σ
split {α ∙ Γ} σ with split {Γ} (σ ∘ old)
... | ς₁ , ς₂ = (λ{ new → σ new ; (old v) → ς₁ v}) , ς₂
-- Expand the codomain of a renaming
expandʳ : ({Γ} Δ : Ctx) → Γ ↝ Γ ∔ Δ
expandʳ {α ∙ Γ} Δ new = new
expandʳ {α ∙ Γ} Δ (old v) = old (expandʳ Δ v)
expandˡ : (Γ {Δ} : Ctx) → Δ ↝ Γ ∔ Δ
expandˡ ∅ v = v
expandˡ (α ∙ Γ) v = old (expandˡ Γ v)
-- Special cases of the above, when one of the contexts is a singleton
-- and the map from the singleton context is isomorphic to a term
-- Add a term to a context map
add : 𝒳 α Δ → Γ ~[ 𝒳 ]↝ Δ → (α ∙ Γ) ~[ 𝒳 ]↝ Δ
add t σ new = t
add t σ (old v) = σ v
-- Consider a term as a context map from the singleton context
asMap : 𝒳 α Γ → ⌊ α ⌋ ~[ 𝒳 ]↝ Γ
asMap t new = t
-- Separate a compound context map into a term and a residual map
detach : (τ ∙ Γ) ~[ 𝒳 ]↝ Δ → 𝒳 τ Δ × (Γ ~[ 𝒳 ]↝ Δ)
detach {_}{∅} σ = σ new , (λ ())
detach {_}{(α ∙ Γ)} σ = σ new , σ ∘ old
add[new][old] : (σ : τ ∙ Γ ~[ 𝒳 ]↝ Δ)(v : ℐ α (τ ∙ Γ))
→ add (σ new) (σ ∘ old) v ≡ σ v
add[new][old] σ new = refl
add[new][old] σ (old v) = refl
-- Remove a term from a compound context map
remove : (τ ∙ Γ) ~[ 𝒳 ]↝ Δ → Γ ~[ 𝒳 ]↝ Δ
remove {_} {∅} σ = λ ()
remove {_} {α ∙ Γ} σ = σ ∘ old
-- Add and remove are inverses
add∘remove : (σ : (τ ∙ Γ) ~[ 𝒳 ]↝ Δ) (v : ℐ α (τ ∙ Γ))
→ add (σ new) (remove σ) v
≡ σ v
add∘remove σ new = refl
add∘remove σ (old new) = refl
add∘remove σ (old (old v)) = refl
remove∘add : (σ : Γ ~[ 𝒳 ]↝ Δ) (t : 𝒳 τ Δ)(v : ℐ α Γ)
→ remove (add t σ) v
≡ σ v
remove∘add σ t new = refl
remove∘add σ t (old v) = refl
|
{
"alphanum_fraction": 0.5287156283,
"avg_line_length": 29.3163265306,
"ext": "agda",
"hexsha": "1c73be8d1ba82f4e72a434a5948dbe817fb98452",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z",
"max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "JoeyEremondi/agda-soas",
"max_forks_repo_path": "SOAS/ContextMaps/Combinators.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8",
"max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "JoeyEremondi/agda-soas",
"max_issues_repo_path": "SOAS/ContextMaps/Combinators.agda",
"max_line_length": 81,
"max_stars_count": 39,
"max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "JoeyEremondi/agda-soas",
"max_stars_repo_path": "SOAS/ContextMaps/Combinators.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z",
"num_tokens": 1323,
"size": 2873
}
|
{-
Constant structure: _ ↦ A
-}
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Structures.Constant where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.SIP
private
variable
ℓ ℓ' : Level
-- Structured isomorphisms
module _ (A : Type ℓ') where
ConstantStructure : Type ℓ → Type ℓ'
ConstantStructure _ = A
ConstantEquivStr : StrEquiv {ℓ} ConstantStructure ℓ'
ConstantEquivStr (_ , a) (_ , a') _ = a ≡ a'
constantUnivalentStr : UnivalentStr {ℓ} ConstantStructure ConstantEquivStr
constantUnivalentStr e = idEquiv _
|
{
"alphanum_fraction": 0.731078905,
"avg_line_length": 20.7,
"ext": "agda",
"hexsha": "332170ac916a871ab6197708f5969ebf88e3fb3d",
"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/Constant.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/Constant.agda",
"max_line_length": 76,
"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/Constant.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 185,
"size": 621
}
|
record R : Set₁ where
field
_! : Set → Set
open R
F : Set → Set
F ! = !
|
{
"alphanum_fraction": 0.5125,
"avg_line_length": 8.8888888889,
"ext": "agda",
"hexsha": "2662e26ea5f9f8aaa3b8f090c8f88a5751e10c76",
"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/OpBind.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/OpBind.agda",
"max_line_length": 21,
"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/OpBind.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": 31,
"size": 80
}
|
open import MJ.Types
open import MJ.Classtable
module MJ.Syntax {c}(Σ : Classtable c) where
open import MJ.Syntax.Typed Σ public
|
{
"alphanum_fraction": 0.7709923664,
"avg_line_length": 18.7142857143,
"ext": "agda",
"hexsha": "3bb010a5e264202f23071208bc8b4808f3beee15",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z",
"max_forks_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "metaborg/mj.agda",
"max_forks_repo_path": "src/MJ/Syntax.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z",
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "metaborg/mj.agda",
"max_issues_repo_path": "src/MJ/Syntax.agda",
"max_line_length": 44,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "metaborg/mj.agda",
"max_stars_repo_path": "src/MJ/Syntax.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z",
"num_tokens": 37,
"size": 131
}
|
{-# OPTIONS --without-K --safe #-}
module Data.Sigma.Base where
open import Agda.Builtin.Sigma
using (Σ; _,_; fst; snd)
public
open import Level
infixr 4.5 ∃-syntax
∃-syntax : ∀ {a b} {A : Type a} (B : A → Type b) → Type (a ℓ⊔ b)
∃-syntax {A = A} = Σ A
syntax ∃-syntax (λ x → e) = ∃ x × e
infixr 4.5 Σ⦂-syntax
Σ⦂-syntax : (A : Type a) (B : A → Type b) → Type (a ℓ⊔ b)
Σ⦂-syntax = Σ
syntax Σ⦂-syntax t (λ x → e) = Σ[ x ⦂ t ] × e
infixr 4.5 _×_
_×_ : (A : Type a) → (B : Type b) → Type (a ℓ⊔ b)
A × B = Σ A λ _ → B
curry : ∀ {A : Type a} {B : A → Type b} {C : Σ A B → Type c} →
((p : Σ A B) → C p) →
((x : A) → (y : B x) → C (x , y))
curry f x y = f (x , y)
{-# INLINE curry #-}
uncurry : ∀ {A : Type a} {B : A → Type b} {C : Σ A B → Type c} →
((x : A) → (y : B x) → C (x , y)) →
((p : Σ A B) → C p)
uncurry f (x , y) = f x y
{-# INLINE uncurry #-}
map-Σ : ∀ {p q} {P : A → Set p} {Q : B → Set q} →
(f : A → B) → (∀ {x} → P x → Q (f x)) →
Σ A P → Σ B Q
map-Σ f g (x , y) = f x , g y
{-# INLINE map-Σ #-}
map₁ : (A → B) → A × C → B × C
map₁ f = map-Σ f (λ x → x)
{-# INLINE map₁ #-}
map₁-Σ : ∀ {A : Set a} {B : Set b} {C : B → Set b}
→ (f : A → B) → Σ A (λ x → C (f x)) → Σ B C
map₁-Σ f (x , y) = f x , y
{-# INLINE map₁-Σ #-}
map₂ : ∀ {A : Set a} {B : A → Set b} {C : A → Set c} →
(∀ {x} → B x → C x) → Σ A B → Σ A C
map₂ f = map-Σ (λ x → x) f
{-# INLINE map₂ #-}
|
{
"alphanum_fraction": 0.4215955983,
"avg_line_length": 25.5087719298,
"ext": "agda",
"hexsha": "0fcc92c6e0dfb871ddb11e6abccce7a4661bf93a",
"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/Sigma/Base.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/Sigma/Base.agda",
"max_line_length": 64,
"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/Sigma/Base.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": 700,
"size": 1454
}
|
module Open1 where
module M where
data ⊤
: Set
where
tt
: ⊤
module N where
open M
v
: ⊤
v
= tt
open M
open N
module O where
w
: ⊤
w
= tt
x
: ⊤
x
= tt
module P where
open O
using (w)
renaming (x to x')
y
: ⊤
y
= w
open P
module Q where
open O
hiding (w)
renaming (x to x'')
z
: ⊤
z
= x''
|
{
"alphanum_fraction": 0.42997543,
"avg_line_length": 6.7833333333,
"ext": "agda",
"hexsha": "94cda66c0607c1ebdbd1383999a0acfbed03f75a",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-01T16:38:14.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-01T16:38:14.000Z",
"max_forks_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "msuperdock/agda-unused",
"max_forks_repo_path": "data/declaration/Open1.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9",
"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": "msuperdock/agda-unused",
"max_issues_repo_path": "data/declaration/Open1.agda",
"max_line_length": 23,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "msuperdock/agda-unused",
"max_stars_repo_path": "data/declaration/Open1.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-01T16:38:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-29T09:38:43.000Z",
"num_tokens": 167,
"size": 407
}
|
module Issue561 where
open import Common.Prelude
open import Common.MAlonzo using ()
-- if I do not include this, I get compilation errors
-- MAlonzo/Code/Common/Prelude.hs:8:7:
-- Not in scope: type constructor or class `Common.FFI.Nat'
primitive
primIsDigit : Char → Bool
postulate
return : ∀ {A} → A → IO A
main : IO Bool
main = return true
|
{
"alphanum_fraction": 0.6978021978,
"avg_line_length": 17.3333333333,
"ext": "agda",
"hexsha": "3e151ef4cc6e3c7c11a02f8360e2a1c8e23a2192",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "test/succeed/Issue561.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "test/succeed/Issue561.agda",
"max_line_length": 63,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "larrytheliquid/agda",
"max_stars_repo_path": "test/succeed/Issue561.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": 107,
"size": 364
}
|
------------------------------------------------------------------------------
-- Testing the --schematic-functions option
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
-- Fails because requires the above option.
module RequiredOption.SchematicFunctions where
postulate
D : Set
fix : (D → D) → D
_≡_ : D → D → Set
postulate fix-f : (f : D → D) → fix f ≡ f (fix f)
{-# ATP axiom fix-f #-}
-- We need to have at least one conjecture to generate a TPTP file.
postulate refl : ∀ d → d ≡ d
{-# ATP prove refl #-}
|
{
"alphanum_fraction": 0.4574175824,
"avg_line_length": 29.12,
"ext": "agda",
"hexsha": "e9dbb23a93b7b43389adc27666ee8973b107498f",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2016-08-03T03:54:55.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-05-10T23:06:19.000Z",
"max_forks_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/apia",
"max_forks_repo_path": "test/Fail/Errors/RequiredOption/SchematicFunctions.agda",
"max_issues_count": 121,
"max_issues_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682",
"max_issues_repo_issues_event_max_datetime": "2018-04-22T06:01:44.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-25T13:22:12.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/apia",
"max_issues_repo_path": "test/Fail/Errors/RequiredOption/SchematicFunctions.agda",
"max_line_length": 78,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/apia",
"max_stars_repo_path": "test/Fail/Errors/RequiredOption/SchematicFunctions.agda",
"max_stars_repo_stars_event_max_datetime": "2019-12-03T13:44:25.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-03T20:54:16.000Z",
"num_tokens": 158,
"size": 728
}
|
module Problem2 where
open import Problem1
infixr 40 _►_
data Vec (A : Set) : Nat -> Set where
ε : Vec A zero
_►_ : {n : Nat} -> A -> Vec A n -> Vec A (suc n)
-- 2.1
vec : {A : Set}{n : Nat} -> A -> Vec A n
vec {n = zero } x = ε
vec {n = suc n} x = x ► vec x
-- 2.2
infixl 80 _<*>_
_<*>_ : {A B : Set}{n : Nat} -> Vec (A -> B) n -> Vec A n -> Vec B n
ε <*> ε = ε
(f ► fs) <*> (x ► xs) = f x ► fs <*> xs
-- 2.3
map : {A B : Set}{n : Nat} -> (A -> B) -> Vec A n -> Vec B n
map f xs = vec f <*> xs
-- 2.4
zip : {A B C : Set}{n : Nat} -> (A -> B -> C) ->
Vec A n -> Vec B n -> Vec C n
zip f xs ys = vec f <*> xs <*> ys
|
{
"alphanum_fraction": 0.4311926606,
"avg_line_length": 18.1666666667,
"ext": "agda",
"hexsha": "3be2ea86ad9aae2e4ff43a70597c3c0ce8c47e8e",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "examples/SummerSchool07/Solutions/Problem2.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "examples/SummerSchool07/Solutions/Problem2.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": "examples/SummerSchool07/Solutions/Problem2.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": 279,
"size": 654
}
|
module Issue790 where
open import Common.Level renaming (lzero to zero; lsuc to suc)
open import Common.Prelude using (Bool; true; false; zero; suc) renaming (Nat to ℕ)
even? : ℕ -> Bool
even? 0 = true
even? (suc (suc n)) = even? n
even? _ = false
-- Name overlap between Level's suc and Nat's suc should not matter,
-- since only one is a constructor.
|
{
"alphanum_fraction": 0.6596858639,
"avg_line_length": 29.3846153846,
"ext": "agda",
"hexsha": "f57df7375fd4e63ae8fd4ecbf6a1a7723db0ae32",
"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/Issue790.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/Issue790.agda",
"max_line_length": 83,
"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/Issue790.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 105,
"size": 382
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Natural number division
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Nat.DivMod where
open import Agda.Builtin.Nat using (div-helper; mod-helper)
open import Data.Fin using (Fin; toℕ; fromℕ≤)
open import Data.Fin.Properties using (toℕ-fromℕ≤)
open import Data.Nat as Nat
open import Data.Nat.DivMod.Core
open import Data.Nat.Properties using (≤⇒≤″; +-assoc; +-comm; +-identityʳ)
open import Function using (_$_)
open import Relation.Nullary.Decidable using (False)
open import Relation.Binary.PropositionalEquality
open ≡-Reasoning
------------------------------------------------------------------------
-- Basic operations
infixl 7 _div_ _%_
-- Integer division
_div_ : (dividend divisor : ℕ) {≢0 : False (divisor ≟ 0)} → ℕ
(a div 0) {}
(a div suc n) = div-helper 0 n a n
-- Integer remainder (mod)
_%_ : (dividend divisor : ℕ) {≢0 : False (divisor ≟ 0)} → ℕ
(a % 0) {}
(a % suc n) = mod-helper 0 n a n
------------------------------------------------------------------------
-- Properties
a≡a%n+[a/n]*n : ∀ a n → a ≡ a % suc n + (a div (suc n)) * suc n
a≡a%n+[a/n]*n a n = division-lemma 0 0 a n
a%1≡0 : ∀ a → a % 1 ≡ 0
a%1≡0 = a[modₕ]1≡0
a%n<n : ∀ a n → a % suc n < suc n
a%n<n a n = s≤s (a[modₕ]n<n 0 a n)
n%n≡0 : ∀ n → suc n % suc n ≡ 0
n%n≡0 n = n[modₕ]n≡0 0 n
a%n%n≡a%n : ∀ a n → a % suc n % suc n ≡ a % suc n
a%n%n≡a%n a n = modₕ-idem 0 a n
[a+n]%n≡a%n : ∀ a n → (a + suc n) % suc n ≡ a % suc n
[a+n]%n≡a%n a n = a+n[modₕ]n≡a[modₕ]n 0 a n
[a+kn]%n≡a%n : ∀ a k n → (a + k * (suc n)) % suc n ≡ a % suc n
[a+kn]%n≡a%n a zero n = cong (_% suc n) (+-identityʳ a)
[a+kn]%n≡a%n a (suc k) n = begin
(a + (m + k * m)) % m ≡⟨ cong (_% m) (sym (+-assoc a m (k * m))) ⟩
(a + m + k * m) % m ≡⟨ [a+kn]%n≡a%n (a + m) k n ⟩
(a + m) % m ≡⟨ [a+n]%n≡a%n a n ⟩
a % m ∎
where m = suc n
kn%n≡0 : ∀ k n → k * (suc n) % suc n ≡ 0
kn%n≡0 = [a+kn]%n≡a%n 0
%-distribˡ-+ : ∀ a b n → (a + b) % suc n ≡ (a % suc n + b % suc n) % suc n
%-distribˡ-+ a b n = begin
(a + b) % m ≡⟨ cong (λ v → (v + b) % m) (a≡a%n+[a/n]*n a n) ⟩
(a % m + a div m * m + b) % m ≡⟨ cong (_% m) (+-assoc (a % m) _ b) ⟩
(a % m + (a div m * m + b)) % m ≡⟨ cong (λ v → (a % m + v) % m) (+-comm _ b) ⟩
(a % m + (b + a div m * m)) % m ≡⟨ cong (_% m) (sym (+-assoc (a % m) b _)) ⟩
(a % m + b + a div m * m) % m ≡⟨ [a+kn]%n≡a%n (a % m + b) (a div m) n ⟩
(a % m + b) % m ≡⟨ cong (λ v → (a % m + v) % m) (a≡a%n+[a/n]*n b n) ⟩
(a % m + (b % m + (b div m) * m)) % m ≡⟨ sym (cong (_% m) (+-assoc (a % m) (b % m) _)) ⟩
(a % m + b % m + (b div m) * m) % m ≡⟨ [a+kn]%n≡a%n (a % m + b % m) (b div m) n ⟩
(a % m + b % m) % m ∎
where m = suc n
------------------------------------------------------------------------
-- A specification of integer division.
record DivMod (dividend divisor : ℕ) : Set where
constructor result
field
quotient : ℕ
remainder : Fin divisor
property : dividend ≡ toℕ remainder + quotient * divisor
_mod_ : (dividend divisor : ℕ) {≢0 : False (divisor ≟ 0)} → Fin divisor
(a mod 0) {}
(a mod suc n) = fromℕ≤ (a%n<n a n)
_divMod_ : (dividend divisor : ℕ) {≢0 : False (divisor ≟ 0)} →
DivMod dividend divisor
(a divMod 0) {}
(a divMod suc n) = result (a div suc n) (a mod suc n) $ begin
a ≡⟨ a≡a%n+[a/n]*n a n ⟩
a % suc n + [a/n]*n ≡⟨ cong (_+ [a/n]*n) (sym (toℕ-fromℕ≤ (a%n<n a n))) ⟩
toℕ (fromℕ≤ (a%n<n a n)) + [a/n]*n ∎
where
[a/n]*n = a div suc n * suc n
|
{
"alphanum_fraction": 0.4404982772,
"avg_line_length": 34.3,
"ext": "agda",
"hexsha": "d22fd88ec51cc8e00dd5ab73a4cf8d979b880078",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "omega12345/agda-mode",
"max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Nat/DivMod.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "omega12345/agda-mode",
"max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Nat/DivMod.agda",
"max_line_length": 93,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Nat/DivMod.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1551,
"size": 3773
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Pointwise equality over lists using propositional equality
------------------------------------------------------------------------
-- Note think carefully about using this module as pointwise
-- propositional equality can usually be replaced with propositional
-- equality.
{-# OPTIONS --without-K --safe #-}
open import Relation.Binary
module Data.List.Relation.Binary.Equality.Propositional {a} {A : Set a} where
open import Data.List.Base
import Data.List.Relation.Binary.Equality.Setoid as SetoidEquality
open import Relation.Binary.PropositionalEquality as P using (_≡_)
------------------------------------------------------------------------
-- Re-export everything from setoid equality
open SetoidEquality (P.setoid A) public
------------------------------------------------------------------------
-- ≋ is propositional
≋⇒≡ : _≋_ ⇒ _≡_
≋⇒≡ [] = P.refl
≋⇒≡ (P.refl ∷ xs≈ys) = P.cong (_ ∷_) (≋⇒≡ xs≈ys)
≡⇒≋ : _≡_ ⇒ _≋_
≡⇒≋ P.refl = ≋-refl
|
{
"alphanum_fraction": 0.5115848007,
"avg_line_length": 30.8285714286,
"ext": "agda",
"hexsha": "1a9c993fbbfd08efbead8128d7623f6ab381ba06",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DreamLinuxer/popl21-artifact",
"max_forks_repo_path": "agda-stdlib/src/Data/List/Relation/Binary/Equality/Propositional.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DreamLinuxer/popl21-artifact",
"max_issues_repo_path": "agda-stdlib/src/Data/List/Relation/Binary/Equality/Propositional.agda",
"max_line_length": 77,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DreamLinuxer/popl21-artifact",
"max_stars_repo_path": "agda-stdlib/src/Data/List/Relation/Binary/Equality/Propositional.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z",
"num_tokens": 258,
"size": 1079
}
|
module Data.Union where
open import Data.List using (List; _∷_; [_]; [])
open import Data.List.Relation.Unary.Any using (here; there; _─_)
open import Data.List.Membership.Propositional using (_∈_)
open import Data.Maybe using (Maybe; just; nothing; _>>=_)
open import Level using (Level; _⊔_)
open import Function using (_∘_)
-- ----------------------------------------------------------------------
-- Definition
--
-- A union of the family B defined by the list of tags ts
-- of type A
data Union {a b} (A : Set a) (B : A → Set b) : List A → Set (a ⊔ b) where
here : ∀ {t ts} → B t → Union A B (t ∷ ts)
there : ∀ {t ts} → Union A B ts → Union A B (t ∷ ts)
-- ----------------------------------------------------------------------
-- Injection and projections to (and from) unions
private
variable
a b : Level
A : Set a
B : A → Set b
t : A
ts ts′ : List A
inj : t ∈ ts → B t → Union A B ts
inj (here t≡t′) x rewrite t≡t′ = here x
inj (there t∈ts) x = there (inj t∈ts x)
`_ : ⦃ t ∈ ts ⦄ → B t → Union A B ts
`_ ⦃ t∈ts ⦄ x = inj t∈ts x
proj : t ∈ ts → Union A B ts → Maybe (B t)
proj (here t≡t′) (here x) rewrite t≡t′ = just x
proj (there t∈ts) (here x) = nothing
proj (here t≡t′) (there x) = nothing
proj (there t∈ts) (there x) = proj t∈ts x
`proj : ⦃ t ∈ ts ⦄ → Union A B ts → Maybe (B t)
`proj ⦃ t∈ts ⦄ x = proj t∈ts x
proj₀ : Union A B [ t ] → B t
proj₀ (here x) = x
remove : Union A B ts → (i : t ∈ ts) → Maybe (Union A B (ts ─ i))
remove (here x) (here _) = nothing
remove (here x) (there _) = just (here x)
remove (there x) (here _) = just x
remove (there x) (there t∈ts) = remove x t∈ts >>= just ∘ there
|
{
"alphanum_fraction": 0.5379975875,
"avg_line_length": 27.1803278689,
"ext": "agda",
"hexsha": "8ed7c869907f3add746b85fc9290a2a511292a1c",
"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": "921a0dc44a69a74391031ca61568c624ab7f9c94",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "johnyob/agda-union",
"max_forks_repo_path": "src/Data/Union.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "921a0dc44a69a74391031ca61568c624ab7f9c94",
"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": "johnyob/agda-union",
"max_issues_repo_path": "src/Data/Union.agda",
"max_line_length": 73,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "921a0dc44a69a74391031ca61568c624ab7f9c94",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "johnyob/agda-union",
"max_stars_repo_path": "src/Data/Union.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 591,
"size": 1658
}
|
open import FRP.JS.Bool using ( Bool ; not )
open import FRP.JS.Maybe using ( Maybe ; just ; nothing ) renaming ( _≟[_]_ to _≟?[_]_ )
open import FRP.JS.Nat using ( ℕ ; zero ; suc ; _≟_ ; _<_ )
open import FRP.JS.Object using ( Object ; IObject ; [] ; _↦_∷_ ; object ; ⟪⟫ ; ⟪_ ; _↦_,_ ; _↦_⟫ ; _≟[_]_ ; _⊆[_]_ ; lookup ; lookup? ; map ; filter )
open import FRP.JS.QUnit using ( TestSuite ; ok ; test ; _,_ )
module FRP.JS.Test.Object where
_≟*_ : Object ℕ → Object ℕ → Bool
xs ≟* ys = xs ≟[ _≟_ ] ys
_⊆*_ : Object ℕ → Object ℕ → Bool
xs ⊆* ys = xs ⊆[ _≟_ ] ys
_≟?_ : Maybe ℕ → Maybe ℕ → Bool
xs ≟? ys = xs ≟?[ _≟_ ] ys
_≟??_ : Maybe (Maybe ℕ) → Maybe (Maybe ℕ) → Bool
xs ≟?? ys = xs ≟?[ _≟?_ ] ys
iincr : ∀ {ks ks✓} → IObject ℕ ks ks✓ → IObject ℕ ks ks✓
iincr [] = []
iincr (k ↦ n ∷ ns) = k ↦ suc n ∷ iincr ns
incr : Object ℕ → Object ℕ
incr (object ns) = object (iincr ns)
⟪a↦0⟫ = ⟪ "a" ↦ 0 ⟫
⟪a↦1⟫ = ⟪ "a" ↦ 1 ⟫
⟪a↦0,b↦1⟫ = ⟪ "a" ↦ 0 , "b" ↦ 1 ⟫
⟪a↦1,b↦2⟫ = ⟪ "a" ↦ 1 , "b" ↦ 2 ⟫
⟪b↦0⟫ = ⟪ "b" ↦ 0 ⟫
⟪b↦2⟫ = ⟪ "b" ↦ 2 ⟫
⟪a↦n⟫ = ⟪ "a" ↦ nothing {A = ℕ} ⟫
⟪a↦j0⟫ = ⟪ "a" ↦ just 0 ⟫
tests : TestSuite
tests =
( test "≟"
( ok "⟪⟫ ≟ ⟪⟫" (⟪⟫ ≟* ⟪⟫)
, ok "⟪a↦0⟫ ≟ ⟪⟫" (not (⟪a↦0⟫ ≟* ⟪⟫))
, ok "⟪⟫ ≟ ⟪a↦0⟫" (not (⟪⟫ ≟* ⟪a↦0⟫))
, ok "⟪a↦0⟫ ≟ ⟪a↦0⟫" (⟪a↦0⟫ ≟* ⟪a↦0⟫)
, ok "⟪a↦0⟫ ≟ ⟪a↦1⟫" (not (⟪a↦0⟫ ≟* ⟪a↦1⟫))
, ok "⟪a↦0⟫ ≟ ⟪a↦0,b↦1⟫" (not (⟪a↦0⟫ ≟* ⟪a↦0,b↦1⟫))
, ok "⟪a↦0,b↦1⟫ ≟ ⟪a↦0⟫" (not (⟪a↦0,b↦1⟫ ≟* ⟪a↦0⟫))
, ok "⟪a↦0,b↦1⟫ ≟ ⟪a↦0,b↦1⟫" (⟪a↦0,b↦1⟫ ≟* ⟪a↦0,b↦1⟫) )
, test "⊆"
( ok "⟪⟫ ⊆ ⟪⟫" (⟪⟫ ⊆* ⟪⟫)
, ok "⟪a↦0⟫ ⊆ ⟪⟫" (not (⟪a↦0⟫ ⊆* ⟪⟫))
, ok "⟪⟫ ⊆ ⟪a↦0⟫" (⟪⟫ ⊆* ⟪a↦0⟫)
, ok "⟪a↦0⟫ ⊆ ⟪a↦0⟫" (⟪a↦0⟫ ⊆* ⟪a↦0⟫)
, ok "⟪a↦0⟫ ⊆ ⟪a↦1⟫" (not (⟪a↦0⟫ ⊆* ⟪a↦1⟫))
, ok "⟪a↦0⟫ ⊆ ⟪a↦0,b↦1⟫" (⟪a↦0⟫ ⊆* ⟪a↦0,b↦1⟫)
, ok "⟪a↦0,b↦1⟫ ⊆ ⟪a↦0⟫" (not (⟪a↦0,b↦1⟫ ⊆* ⟪a↦0⟫))
, ok "⟪a↦0,b↦1⟫ ⊆ ⟪a↦0,b↦1⟫" (⟪a↦0,b↦1⟫ ⊆* ⟪a↦0,b↦1⟫) )
, test "lookup"
( ok "lookup ⟪a↦0⟫ a" (lookup ⟪a↦0⟫ "a" ≟ 0)
, ok "lookup ⟪a↦0,b↦1⟫ a" (lookup ⟪a↦0,b↦1⟫ "b" ≟ 1)
, ok "lookup ⟪a↦0,b↦1⟫ a" (lookup ⟪a↦0,b↦1⟫ "a" ≟ 0)
, ok "lookup ⟪a↦0,b↦1⟫ b" (lookup ⟪a↦0,b↦1⟫ "b" ≟ 1)
, ok "lookup ⟪a↦j0⟫ a" (lookup ⟪a↦j0⟫ "a" ≟? just 0)
, ok "lookup ⟪a↦n⟫ a" (lookup ⟪a↦n⟫ "a" ≟? nothing)
, ok "lookup? ⟪⟫ a" (lookup? ⟪⟫ "a" ≟? nothing)
, ok "lookup? ⟪a↦0⟫ a" (lookup? ⟪a↦0⟫ "a" ≟? just 0)
, ok "lookup? ⟪a↦0⟫ b" (lookup? ⟪a↦0⟫ "b" ≟? nothing)
, ok "lookup? ⟪a↦0,b↦1⟫ a" (lookup? ⟪a↦0,b↦1⟫ "a" ≟? just 0)
, ok "lookup? ⟪a↦0,b↦1⟫ b" (lookup? ⟪a↦0,b↦1⟫ "b" ≟? just 1)
, ok "lookup? ⟪a↦0,b↦1⟫ c" (lookup? ⟪a↦0,b↦1⟫ "c" ≟? nothing)
, ok "lookup? ⟪a↦j0⟫ a" (lookup? ⟪a↦j0⟫ "a" ≟?? just (just 0))
, ok "lookup? ⟪a↦n⟫ a" (lookup? ⟪a↦n⟫ "a" ≟?? just nothing) )
, test "map"
( ok "map suc ⟪⟫" (map suc ⟪⟫ ≟* ⟪⟫)
, ok "map suc ⟪a↦0⟫" (map suc ⟪a↦0⟫ ≟* ⟪a↦1⟫)
, ok "map suc ⟪a↦0,b↦1⟫" (map suc ⟪a↦0,b↦1⟫ ≟* ⟪a↦1,b↦2⟫)
, ok "incr ⟪⟫" (map suc ⟪⟫ ≟* incr ⟪⟫)
, ok "incr ⟪a↦0⟫" (map suc ⟪a↦0⟫ ≟* incr ⟪a↦0⟫)
, ok "incr ⟪a↦0,b↦1⟫" (map suc ⟪a↦0,b↦1⟫ ≟* incr ⟪a↦0,b↦1⟫) )
, test "filter"
( ok "filter 0< ⟪a↦1,b↦2⟫" (filter (_<_ 0) ⟪a↦1,b↦2⟫ ≟* ⟪a↦1,b↦2⟫)
, ok "filter 1< ⟪a↦1,b↦2⟫" (filter (_<_ 1) ⟪a↦1,b↦2⟫ ≟* ⟪b↦2⟫)
, ok "filter 2< ⟪a↦1,b↦2⟫" (filter (_<_ 2) ⟪a↦1,b↦2⟫ ≟* ⟪⟫) ) )
|
{
"alphanum_fraction": 0.4138863841,
"avg_line_length": 40.0843373494,
"ext": "agda",
"hexsha": "3b85b31c25e7b2ff8641b1133e9b6485774a27ca",
"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": "test/agda/FRP/JS/Test/Object.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": "test/agda/FRP/JS/Test/Object.agda",
"max_line_length": 151,
"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": "test/agda/FRP/JS/Test/Object.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": 2273,
"size": 3327
}
|
module container.w.core where
open import level
open import sum
open import equality
open import function.extensionality
open import function.isomorphism
open import function.isomorphism.properties
open import function.overloading
open import sets.empty
open import sets.nat.core using (suc)
open import sets.unit
open import hott.level
open import container.core
open import container.fixpoint
open import container.equality
private
module Definition {li la lb} (c : Container li la lb) where
open Container c
-- definition of indexed W-types using a type family
data W (i : I) : Set (la ⊔ lb) where
sup : (a : A i) → ((b : B a) → W (r b)) → W i
-- initial F-algebra
inW : F W →ⁱ W
inW i (a , f) = sup a f
module Elim {lx} {X : I → Set lx}
(α : F X →ⁱ X) where
-- catamorphisms
fold : W →ⁱ X
fold i (sup a f) = α i (a , λ b → fold _ (f b))
-- computational rule for catamorphisms
-- this holds definitionally
fold-β : ∀ {i} (x : F W i) → fold i (inW i x) ≡ α i (imap fold i x)
fold-β x = refl
-- η-rule, this is only propositional
fold-η : (h : W →ⁱ X)
→ (∀ {i} (x : F W i) → h i (inW i x) ≡ α i (imap h i x))
→ ∀ {i} (x : W i) → h i x ≡ fold i x
fold-η h p {i} (sup a f) = p (a , λ b → f b) · lem
where
lem : α i (a , (λ b → h _ (f b)))
≡ α i (a , (λ b → fold _ (f b)))
lem = ap (λ z → α i (a , z))
(funext λ b → fold-η h p (f b))
open Elim public
head : ∀ {i} → W i → A i
head (sup a f) = a
tail : ∀ {i} (x : W i)(b : B (head x)) → W (r b)
tail (sup a f) = f
fixpoint : (i : I) → W i ≅ F W i
fixpoint _ = iso f g H K
where
f : {i : I} → W i → F W i
f (sup a f) = a , f
g : {i : I} → F W i → W i
g (a , f) = sup a f
H : {i : I}(w : W i) → g (f w) ≡ w
H (sup a f) = refl
K : {i : I}(w : F W i) → f (g w) ≡ w
K (a , f) = refl
private
module Properties {li la lb}{c : Container li la lb} where
open Container c
open Definition c
open Equality c (fix W fixpoint)
open Container equality
using ()
renaming (F to F-≡')
open Definition equality
using ()
renaming ( W to W-≡
; fixpoint to fixpoint-≡ )
F-≡ : ∀ {lx}
→ (∀ {i} → W i → W i → Set lx)
→ (∀ {i} → W i → W i → Set _)
F-≡ X u v = F-≡' (λ {(i , u , v) → X {i} u v}) (_ , u , v)
_≡W_ : ∀ {i} → W i → W i → Set _
_≡W_ {i} u v = W-≡ (i , u , v)
fixpoint-W : ∀ {i}{u v : W i} → (u ≡ v) ≅ F-≡ _≡_ u v
fixpoint-W {i}{sup a f}{sup a' f'} = begin
(sup a f ≡ sup a' f')
≅⟨ iso≡ (fixpoint i) ⟩
(apply (fixpoint i) (sup a f) ≡ apply (fixpoint i) (sup a' f'))
≅⟨ sym≅ Σ-split-iso ⟩
(Σ (a ≡ a') λ p → subst (λ a → (b : B a) → W (r b)) p f ≡ f')
≅⟨ Σ-ap-iso refl≅ (substX-β f f') ⟩
(Σ (a ≡ a') λ p → ∀ b → f b ≡ substX p b (f' (subst B p b)))
∎
where open ≅-Reasoning
str-iso : ∀ {i}{u v : W i} → (u ≡ v) ≅ (u ≡W v)
str-iso {i}{sup a f}{sup a' f'} = begin
(sup a f ≡ sup a' f')
≅⟨ fixpoint-W ⟩
(Σ (a ≡ a') λ p → ∀ b → f b ≡ substX p b (f' (subst B p b)))
≅⟨ Σ-ap-iso refl≅ (λ a → Π-ap-iso refl≅ λ b → str-iso) ⟩
(Σ (a ≡ a') λ p → ∀ b → f b ≡W substX p b (f' (subst B p b)))
≅⟨ sym≅ (fixpoint-≡ _) ⟩
(sup a f ≡W sup a' f')
∎
where open ≅-Reasoning
-- w-level : ∀ {n} → ((i : I) → h (suc n) (A i)) → (i : I) → h (suc n) (W i)
-- w-level hA i (sup a f) (sup a' f') = iso-level (sym≅ lem)
-- (Σ-level (hA i a a') (λ p → Π-level λ b → w-level hA _ _ _))
-- where
-- lem : ∀ {i}{a a' : A i}
-- {f : (b : B a) → W (r b)}
-- {f' : (b : B a') → W (r b)}
-- → (sup a f ≡ sup a' f')
-- ≅ Σ (a ≡ a') λ p → ∀ b → f b ≡ substX p b (f' (subst B p b))
-- lem = fixpoint-W
open Definition public
-- open Properties public using (w-level)
|
{
"alphanum_fraction": 0.4579462103,
"avg_line_length": 30.7518796992,
"ext": "agda",
"hexsha": "c096598a4e806a4c028edf5148001dd84c30dbe7",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2019-02-26T06:17:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-04-11T17:19:12.000Z",
"max_forks_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "HoTT/M-types",
"max_forks_repo_path": "container/w/core.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4",
"max_issues_repo_issues_event_max_datetime": "2015-02-11T15:20:34.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-02-11T11:14:59.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "HoTT/M-types",
"max_issues_repo_path": "container/w/core.agda",
"max_line_length": 79,
"max_stars_count": 27,
"max_stars_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "HoTT/M-types",
"max_stars_repo_path": "container/w/core.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-09T07:26:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-14T15:47:03.000Z",
"num_tokens": 1612,
"size": 4090
}
|
{-# OPTIONS --without-K --safe #-}
-- This module defines D<: normal form, proves its transitivity and shows its
-- equivalence to the original D<:. It turns out that D<: normal form can be used to
-- prove undecidability.
module DsubEquivSimpler where
open import Data.List as List
open import Data.List.All as All
open import Data.Nat as ℕ
open import Data.Maybe as Maybe
open import Data.Product
open import Data.Sum
open import Data.Empty renaming (⊥ to False)
open import Data.Vec as Vec renaming (_∷_ to _‼_ ; [] to nil) hiding (_++_)
open import Function
open import Data.Maybe.Properties as Maybeₚ
open import Data.Nat.Properties as ℕₚ
open import Relation.Nullary
open import Relation.Binary.PropositionalEquality as ≡
open import Induction.Nat
open import DsubDef
open import Dsub
open import Utils
-- D<: Normal Form
--
-- The following judgment defines D<: normal form as in Figure 4.
infix 4 _⊢″_<:_
data _⊢″_<:_ : Env → Typ → Typ → Set where
<:⊤ : ∀ {Γ T} → Γ ⊢″ T <: ⊤
⊥<: : ∀ {Γ T} → Γ ⊢″ ⊥ <: T
refl : ∀ {Γ T} → Γ ⊢″ T <: T
bnd : ∀ {Γ S U S′ U′} →
Γ ⊢″ S′ <: S →
Γ ⊢″ U <: U′ →
Γ ⊢″ ⟨A: S ⋯ U ⟩ <: ⟨A: S′ ⋯ U′ ⟩
Π<: : ∀ {Γ S U S′ U′} →
Γ ⊢″ S′ <: S →
Γ ‣ S′ ! ⊢″ U <: U′ →
Γ ⊢″ Π S ∙ U <: Π S′ ∙ U′
sel₁ : ∀ {Γ n T S} →
env-lookup Γ n ≡ just T →
Γ ⊢″ T <: ⟨A: S ⋯ ⊤ ⟩ →
Γ ⊢″ S <: n ∙A
sel₂ : ∀ {Γ n T U} →
env-lookup Γ n ≡ just T →
Γ ⊢″ T <: ⟨A: ⊥ ⋯ U ⟩ →
Γ ⊢″ n ∙A <: U
<:> : ∀ {Γ n T S U} →
env-lookup Γ n ≡ just T →
Γ ⊢″ T <: ⟨A: S ⋯ ⊤ ⟩ →
Γ ⊢″ T <: ⟨A: ⊥ ⋯ U ⟩ →
Γ ⊢″ S <: U
-- First we show that D<: normal form admits weakening.
<:″-weakening-gen : ∀ {Γ S U} →
Γ ⊢″ S <: U →
∀ Γ₁ Γ₂ T →
Γ ≡ Γ₁ ‣ Γ₂ →
Γ₁ ‣ T ! ‣ Γ₂ ⇑ ⊢″ S ↑ length Γ₂ <: U ↑ length Γ₂
<:″-weakening-gen <:⊤ Γ₁ Γ₂ T eqΓ = <:⊤
<:″-weakening-gen ⊥<: Γ₁ Γ₂ T eqΓ = ⊥<:
<:″-weakening-gen refl Γ₁ Γ₂ T eqΓ = refl
<:″-weakening-gen (bnd S′<:S U<:U′) Γ₁ Γ₂ T eqΓ = bnd (<:″-weakening-gen S′<:S Γ₁ Γ₂ T eqΓ)
(<:″-weakening-gen U<:U′ Γ₁ Γ₂ T eqΓ)
<:″-weakening-gen (Π<: S′<:S U<:U′) Γ₁ Γ₂ T eqΓ = Π<: (<:″-weakening-gen S′<:S Γ₁ Γ₂ T eqΓ)
(<:″-weakening-gen U<:U′ Γ₁ (_ ∷ Γ₂) T (cong (_ ∷_) eqΓ))
<:″-weakening-gen (sel₁ {_} {n} T∈Γ T<:B) Γ₁ Γ₂ T eqΓ
rewrite ↑-var n (length Γ₂) = sel₁ (↦∈-weaken′ T∈Γ Γ₁ Γ₂ T eqΓ)
(<:″-weakening-gen T<:B Γ₁ Γ₂ T eqΓ)
<:″-weakening-gen (sel₂ {_} {n} T∈Γ T<:B) Γ₁ Γ₂ T eqΓ
rewrite ↑-var n (length Γ₂) = sel₂ (↦∈-weaken′ T∈Γ Γ₁ Γ₂ T eqΓ)
(<:″-weakening-gen T<:B Γ₁ Γ₂ T eqΓ)
<:″-weakening-gen (<:> {_} {n} T∈Γ T<:B T<:B′) Γ₁ Γ₂ T eqΓ
rewrite ↑-var n (length Γ₂) = <:> (↦∈-weaken′ T∈Γ Γ₁ Γ₂ T eqΓ)
(<:″-weakening-gen T<:B Γ₁ Γ₂ T eqΓ)
(<:″-weakening-gen T<:B′ Γ₁ Γ₂ T eqΓ)
<:″-weakening : ∀ {Γ₁ Γ₂ S U} T →
Γ₁ ‣ Γ₂ ⊢″ S <: U →
Γ₁ ‣ T ! ‣ Γ₂ ⇑ ⊢″ S ↑ length Γ₂ <: U ↑ length Γ₂
<:″-weakening T S<:U = <:″-weakening-gen S<:U _ _ T refl
<:″-weakening-hd : ∀ {Γ S U} T →
Γ ⊢″ S <: U →
Γ ‣ T ! ⊢″ S ↑ 0 <: U ↑ 0
<:″-weakening-hd T = <:″-weakening {Γ₂ = []} T
-- Then we work on transitivity.
module SimplerTransitivity where
-- This predicate asserts that the first context replaces _one_ type in the second
-- context with its subtype. That is, the first context is more "precise" than the
-- second context.
infix 4 _≺:[_]_
data _≺:[_]_ : Env → ℕ → Env → Set where
≺[_,_] : ∀ {Γ U} S → Γ ⊢″ S <: U → Γ ‣ S ! ≺:[ 0 ] Γ ‣ U !
_∷_ : ∀ {Γ₁ n Γ₂} T → Γ₁ ≺:[ n ] Γ₂ → Γ₁ ‣ T ! ≺:[ suc n ] Γ₂ ‣ T !
<:∈-find : ∀ {x T Γ Γ′ n} →
x ↦ T ∈ Γ →
Γ′ ≺:[ n ] Γ →
x ≡ n × (∃ λ T′ → n ↦ T′ ∈ Γ′ × Γ′ ⊢″ T′ <: T) ⊎ x ≢ n × x ↦ T ∈ Γ′
<:∈-find hd ≺[ T′ , T′<:T ] = inj₁ (refl , T′ ↑ 0 , hd , <:″-weakening-hd T′ T′<:T)
<:∈-find hd (T ∷ Γ′≺:Γ) = inj₂ ((λ ()) , hd)
<:∈-find (tl T∈Γ) ≺[ T′ , T′<:T ] = inj₂ ((λ ()) , tl T∈Γ)
<:∈-find (tl T∈Γ) (S ∷ Γ′≺:Γ) with <:∈-find T∈Γ Γ′≺:Γ
... | inj₁ (x≡n , T′ , T′∈Γ′ , T′<:T) = inj₁ (cong suc x≡n , T′ ↑ 0 , tl T′∈Γ′ , <:″-weakening-hd S T′<:T)
... | inj₂ (x≢n , T∈Γ′) = inj₂ (x≢n ∘ suc-injective , tl T∈Γ′)
<:∈-find′ : ∀ {x T Γ Γ′ n} →
env-lookup Γ x ≡ just T →
Γ′ ≺:[ n ] Γ →
x ≡ n × (∃ λ T′ → env-lookup Γ′ n ≡ just T′ × Γ′ ⊢″ T′ <: T) ⊎ x ≢ n × env-lookup Γ′ x ≡ just T
<:∈-find′ T∈Γ Γ′≺Γ with <:∈-find (lookup⇒↦∈ T∈Γ) Γ′≺Γ
... | inj₁ (x≡n , T′ , T′∈Γ′ , T′<:T) = inj₁ (x≡n , T′ , ↦∈⇒lookup T′∈Γ′ , T′<:T)
... | inj₂ (x≢n , T∈Γ′) = inj₂ (x≢n , ↦∈⇒lookup T∈Γ′)
private
trans-on : Typ → Set
trans-on T = ∀ {Γ S U} → Γ ⊢″ S <: T → Γ ⊢″ T <: U → Γ ⊢″ S <: U
narrow-on : Typ → Set
narrow-on T = ∀ {Γ Γ′ n S U} →
Γ ⊢″ S <: U →
Γ′ ≺:[ n ] Γ →
env-lookup Γ n ≡ just T →
Γ′ ⊢″ S <: U
-- Per Definition 11, this defines type declaration hierarchy.
⟨A:⟩-layer : Typ → List Typ → Typ
⟨A:⟩-layer T [] = T
⟨A:⟩-layer T (S ∷ l) = ⟨A: S ⋯ ⟨A:⟩-layer T l ⟩
-- Now we start proving transitivity and narrowing via a mutual induction. This
-- mutual induction begins exactly as presented in the paper: an induction of
-- lexicographical order of the triple (T, 𝒟₁, 𝒟₂). Notice that this is
-- automatically handled by Agda's termination checker, which makes the problem very
-- nice to work with.
--
-- If one loads this file from Emacs, one shall see that some cases below are
-- highlighted. The reason is that those cases are not defined
-- _definitionally_. More details can be found in:
-- https://agda.readthedocs.io/en/v2.5.4.2/language/function-definitions.html#case-trees.
--
-- In fact, those non-definitional cases hides many cases away, as they expand to
-- numerous definitional cases, which is necessarily the case in Coq. The fact that
-- Agda's termination checking is permissive and Agda allows non-definitional cases
-- has significantly improved productivity of showing transitivity. In Coq, this
-- would have required significant amount of technical setup which can easily wipe
-- away the main idea of the proof and might not be finished within a reasonable
-- time interval.
mutual
<:′-trans-rec : ∀ T → (∀ T′ → Typ-measure T′ < Typ-measure T → trans-on T′ × narrow-on T′) → trans-on T
<:′-trans-rec (n ∙A) rec (sel₁ T∈Γ T<:B) (sel₂ T′∈Γ T<:B′)
with ≡.trans (≡.sym T∈Γ) T′∈Γ
... | refl = <:> T′∈Γ T<:B T<:B′
<:′-trans-rec ⟨A: S′ ⋯ U′ ⟩ rec (bnd S′<:S U<:U′) (bnd S″<:S U′<:U″) = bnd (<:′-trans-rec S′ (λ T′ T′<S′ → rec T′ (≤-step (≤-stepsʳ _ T′<S′))) S″<:S S′<:S)
(<:′-trans-rec U′ (λ T′ T′<U′ → rec T′ (≤-step (≤-stepsˡ _ T′<U′))) U<:U′ U′<:U″)
<:′-trans-rec (Π S′ ∙ U′) rec (Π<: S′<:S″ U″<:U′) (Π<: S‴<:S′ U′<:U‴)
= Π<: (<:′-trans-rec S′ (λ T′ T′<S′ → rec T′ (≤-step (≤-stepsʳ _ T′<S′))) S‴<:S′ S′<:S″)
(<:′-trans-rec U′ (λ T′ T′<U′ → rec T′ (≤-step (≤-stepsˡ _ T′<U′)))
(proj₂ (rec (S′ ↑ 0) (s≤s $ ≤-stepsʳ _ $ ≤-reflexive (Typ-measure-↑ S′ 0)))
U″<:U′
≺[ _ , S‴<:S′ ]
refl)
U′<:U‴)
<:′-trans-rec T rec ⊥<: T<:U = ⊥<:
<:′-trans-rec T rec refl T<:U = T<:U
<:′-trans-rec T rec S<:T <:⊤ = <:⊤
<:′-trans-rec T rec S<:T refl = S<:T
<:′-trans-rec T rec (sel₂ T′∈Γ T′<:B) T<:U = sel₂ T′∈Γ (⟨A<:⟩-traverseʳ T rec T<:U T′<:B _ refl)
<:′-trans-rec T rec (<:> T′∈Γ T′<:B T′<:B′) T<:U = <:> T′∈Γ T′<:B (⟨A<:⟩-traverseʳ T rec T<:U T′<:B′ _ refl)
<:′-trans-rec T rec S<:T (sel₁ T′∈Γ T′<:B) = sel₁ T′∈Γ (⟨A<:⟩-traverseˡ T rec S<:T T′<:B [] refl)
<:′-trans-rec T rec S<:T (<:> T′∈Γ T′<:B T′<:B′) = <:> T′∈Γ (⟨A<:⟩-traverseˡ T rec S<:T T′<:B [] refl) T′<:B′
⟨A<:⟩-traverseʳ : ∀ T →
(∀ T′ → Typ-measure T′ < Typ-measure T → trans-on T′ × narrow-on T′) →
∀ {Γ U} →
Γ ⊢″ T <: U →
∀ {S S′ T′} →
Γ ⊢″ S <: ⟨A: S′ ⋯ T′ ⟩ →
∀ l →
T′ ≡ ⟨A:⟩-layer T l →
Γ ⊢″ S <: ⟨A: S′ ⋯ ⟨A:⟩-layer U l ⟩
⟨A<:⟩-traverseʳ T rec T<:U ⊥<: l eqT′ = ⊥<:
⟨A<:⟩-traverseʳ T rec T<:U refl [] refl = bnd refl T<:U
⟨A<:⟩-traverseʳ T rec T<:U refl (S′ ∷ l) refl = bnd refl (⟨A<:⟩-traverseʳ T rec T<:U refl l refl)
⟨A<:⟩-traverseʳ T rec T<:U (bnd S₂<:S₁ U₁<:T) [] refl = bnd S₂<:S₁ (<:′-trans-rec T rec U₁<:T T<:U)
⟨A<:⟩-traverseʳ T rec T<:U (bnd S₂<:S₁ U₁<:U₂) (S′ ∷ l) refl = bnd S₂<:S₁ (⟨A<:⟩-traverseʳ T rec T<:U U₁<:U₂ l refl)
⟨A<:⟩-traverseʳ T rec T<:U (sel₂ T′∈Γ T′<:B) l refl = sel₂ T′∈Γ (⟨A<:⟩-traverseʳ T rec T<:U T′<:B (_ ∷ l) refl)
⟨A<:⟩-traverseʳ T rec T<:U (<:> T′∈Γ T′<:B T′<:B′) l refl = <:> T′∈Γ T′<:B (⟨A<:⟩-traverseʳ T rec T<:U T′<:B′ (_ ∷ l) refl)
⟨A<:⟩-traverseˡ : ∀ T →
(∀ T′ → Typ-measure T′ < Typ-measure T → trans-on T′ × narrow-on T′) →
∀ {Γ S} →
Γ ⊢″ S <: T →
∀ {S′ T′} →
Γ ⊢″ S′ <: T′ →
∀ {U} l →
T′ ≡ ⟨A:⟩-layer ⟨A: T ⋯ U ⟩ l →
Γ ⊢″ S′ <: ⟨A:⟩-layer ⟨A: S ⋯ U ⟩ l
⟨A<:⟩-traverseˡ T rec S<:T <:⊤ [] ()
⟨A<:⟩-traverseˡ T rec S<:T <:⊤ (_ ∷ l) ()
⟨A<:⟩-traverseˡ T rec S<:T ⊥<: l eqT′ = ⊥<:
⟨A<:⟩-traverseˡ T rec S<:T refl [] refl = bnd S<:T refl
⟨A<:⟩-traverseˡ T rec S<:T refl (S′ ∷ l) refl = bnd refl (⟨A<:⟩-traverseˡ T rec S<:T refl l refl)
⟨A<:⟩-traverseˡ T rec S<:T (bnd T<:S₁ U₁<:U₂) [] refl = bnd (<:′-trans-rec T rec S<:T T<:S₁) U₁<:U₂
⟨A<:⟩-traverseˡ T rec S<:T (bnd S₂<:S₁ U₁<:U₂) (S′ ∷ l) refl = bnd S₂<:S₁ (⟨A<:⟩-traverseˡ T rec S<:T U₁<:U₂ l refl)
⟨A<:⟩-traverseˡ T rec S<:T (Π<: S₂<:S₁ U₁<:U₂) [] ()
⟨A<:⟩-traverseˡ T rec S<:T (Π<: S₂<:S₁ U₁<:U₂) (_ ∷ l) ()
⟨A<:⟩-traverseˡ T rec S<:T (sel₁ T′∈Γ T′<:B) [] ()
⟨A<:⟩-traverseˡ T rec S<:T (sel₁ T′∈Γ T′<:B) (_ ∷ l) ()
⟨A<:⟩-traverseˡ T rec S<:T (sel₂ T′∈Γ T′<:B) {U} l refl = sel₂ T′∈Γ (⟨A<:⟩-traverseˡ T rec S<:T T′<:B {U} (_ ∷ l) refl)
⟨A<:⟩-traverseˡ T rec S<:T (<:> T′∈Γ T′<:B T′<:B′) l refl = <:> T′∈Γ T′<:B (⟨A<:⟩-traverseˡ T rec S<:T T′<:B′ (_ ∷ l) refl)
<:″-narrow-on : ∀ T → (∀ T′ → Typ-measure T′ ≡ Typ-measure T → trans-on T′) → narrow-on T
<:″-narrow-on T trans <:⊤ Γ′≺Γ T∈Γ = <:⊤
<:″-narrow-on T trans ⊥<: Γ′≺Γ T∈Γ = ⊥<:
<:″-narrow-on T trans refl Γ′≺Γ T∈Γ = refl
<:″-narrow-on T trans (bnd S′<:S U<:U′) Γ′≺Γ T∈Γ = bnd (<:″-narrow-on T trans S′<:S Γ′≺Γ T∈Γ)
(<:″-narrow-on T trans U<:U′ Γ′≺Γ T∈Γ)
<:″-narrow-on T trans {Γ} {Γ′} {n} (Π<: {S′ = S′} S′<:S U<:U′) Γ′≺Γ T∈Γ
= Π<: (<:″-narrow-on T trans S′<:S Γ′≺Γ T∈Γ)
(<:″-narrow-on (T ↑ 0)
(λ T′ eq → trans T′ (≡.trans eq (Typ-measure-↑ T 0)))
U<:U′ (_ ∷ Γ′≺Γ)
(↦∈⇒lookup (tl {n} {T′ = S′} {Γ} (lookup⇒↦∈ T∈Γ))))
<:″-narrow-on T trans (sel₁ T′∈Γ T′<:B) Γ′≺Γ T∈Γ
with <:∈-find′ T′∈Γ Γ′≺Γ
... | inj₁ (refl , T″ , T″∈Γ′ , T″<:T)
rewrite just-injective (≡.trans (≡.sym T′∈Γ) T∈Γ) = sel₁ T″∈Γ′ (trans T refl T″<:T (<:″-narrow-on T trans T′<:B Γ′≺Γ T∈Γ))
... | inj₂ (x≢n , T′∈Γ′) = sel₁ T′∈Γ′ (<:″-narrow-on T trans T′<:B Γ′≺Γ T∈Γ)
<:″-narrow-on T trans (sel₂ T′∈Γ T′<:B) Γ′≺Γ T∈Γ
with <:∈-find′ T′∈Γ Γ′≺Γ
... | inj₁ (refl , T″ , T″∈Γ′ , T″<:T)
rewrite just-injective (≡.trans (≡.sym T′∈Γ) T∈Γ) = sel₂ T″∈Γ′ (trans T refl T″<:T (<:″-narrow-on T trans T′<:B Γ′≺Γ T∈Γ))
... | inj₂ (x≢n , T′∈Γ′) = sel₂ T′∈Γ′ (<:″-narrow-on T trans T′<:B Γ′≺Γ T∈Γ)
<:″-narrow-on T trans (<:> T′∈Γ T′<:B T′<:B′) Γ′≺Γ T∈Γ
with <:∈-find′ T′∈Γ Γ′≺Γ
... | inj₁ (refl , T″ , T″∈Γ′ , T″<:T)
rewrite just-injective (≡.trans (≡.sym T′∈Γ) T∈Γ) = <:> T″∈Γ′
(trans T refl T″<:T (<:″-narrow-on T trans T′<:B Γ′≺Γ T∈Γ))
(trans T refl T″<:T (<:″-narrow-on T trans T′<:B′ Γ′≺Γ T∈Γ))
... | inj₂ (x≢n , T′∈Γ′) = <:> T′∈Γ′
(<:″-narrow-on T trans T′<:B Γ′≺Γ T∈Γ)
(<:″-narrow-on T trans T′<:B′ Γ′≺Γ T∈Γ)
-- The previous functions achieve the inductive hypotheses of the well-founded
-- induction on the size of the type T, and the following function combines those
-- inductive hypotheses and conclude transitivity and narrowing.
<:″-trans-narrow : ∀ T → trans-on T × narrow-on T
<:″-trans-narrow = wfRec _ aux
where open Measure <-wellFounded Typ-measure
aux : ∀ T → (∀ T′ → Typ-measure T′ < Typ-measure T → trans-on T′ × narrow-on T′) → trans-on T × narrow-on T
aux T rec = <:′-trans-rec T rec
, <:″-narrow-on T (λ T′ T′≡T →
<:′-trans-rec T′ λ T″ T″<T′ → rec T″ (≤-trans T″<T′ (≤-reflexive T′≡T)))
<:″-trans : ∀ {T} → trans-on T
<:″-trans {T} = proj₁ (<:″-trans-narrow T)
<:″-narrow : ∀ {T} → narrow-on T
<:″-narrow {T} = proj₂ (<:″-trans-narrow T)
open SimplerTransitivity using (<:″-trans ; <:″-narrow) public
-- the following two functions show that the original D<: and D<: normal form are
-- equivalent.
<:⇒<:″ : ∀ {Γ S U} → Γ ⊢ S <: U → Γ ⊢″ S <: U
<:⇒<:″ dtop = <:⊤
<:⇒<:″ dbot = ⊥<:
<:⇒<:″ drefl = refl
<:⇒<:″ (dtrans T S<:T T<:U) = <:″-trans (<:⇒<:″ S<:T) (<:⇒<:″ T<:U)
<:⇒<:″ (dbnd S′<:S U<:U′) = bnd (<:⇒<:″ S′<:S) (<:⇒<:″ U<:U′)
<:⇒<:″ (dall S′<:S U<:U′) = Π<: (<:⇒<:″ S′<:S) (<:⇒<:″ U<:U′)
<:⇒<:″ (dsel₁ T∈Γ T<:B) = sel₁ T∈Γ (<:⇒<:″ T<:B)
<:⇒<:″ (dsel₂ T∈Γ T<:B) = sel₂ T∈Γ (<:⇒<:″ T<:B)
<:″⇒<: : ∀ {Γ S U} → Γ ⊢″ S <: U → Γ ⊢ S <: U
<:″⇒<: <:⊤ = dtop
<:″⇒<: ⊥<: = dbot
<:″⇒<: refl = drefl
<:″⇒<: (bnd S′<:S U<:U′) = dbnd (<:″⇒<: S′<:S) (<:″⇒<: U<:U′)
<:″⇒<: (Π<: S′<:S U<:U′) = dall (<:″⇒<: S′<:S) (<:″⇒<: U<:U′)
<:″⇒<: (sel₁ T∈Γ T<:B) = dsel₁ T∈Γ (<:″⇒<: T<:B)
<:″⇒<: (sel₂ T∈Γ T<:B) = dsel₂ T∈Γ (<:″⇒<: T<:B)
<:″⇒<: (<:> T∈Γ T<:B S<:B′) = dtrans _ (dsel₁ T∈Γ (dtrans _ (<:″⇒<: T<:B) (dbnd drefl dtop)))
(dsel₂ T∈Γ (dtrans _ (<:″⇒<: S<:B′) (dbnd dbot drefl)))
-- D<: subtyping is undecidable.
module Undecidability′ where
open import DsubReduced
open FsubMinusToDsubR using (⟦_⟧ ; ⟪_⟫ ; D<:ᵣ⇒F<: ; F<:⇒D<:ᵣ ; ⟪⟫-contraEnv ; ⟦⟧-covar)
open DsubInvProperties contraInvertible
open import FsubMinus
<:″⇒<:ᵣ : ∀ {Γ S U} →
Γ ⊢″ S <: U →
ContraEnv Γ → Covar S → Covar U →
Γ ⊢ᵣ S <: U
<:″⇒<:ᵣ <:⊤ cΓ cS cU = drtop cS
<:″⇒<:ᵣ ⊥<: cΓ () cU
<:″⇒<:ᵣ refl cΓ cS cU = drrefl cU
<:″⇒<:ᵣ (bnd S′<:S U<:U′) cΓ cS ()
<:″⇒<:ᵣ (Π<: <:⊤ U<:U′) cΓ () cU
<:″⇒<:ᵣ (Π<: ⊥<: U<:U′) cΓ cS ()
<:″⇒<:ᵣ (Π<: refl U<:U′) cΓ (cvΠ cS cU) (cvΠ cS′ cU′) = drall cS′ cU cS′ cU′
(drrefl cS′)
(<:″⇒<:ᵣ U<:U′ (ctt cS′ ∷ cΓ) cU cU′)
<:″⇒<:ᵣ (Π<: (bnd _ S′<:S) U<:U′) cΓ (cvΠ cS cU) (cvΠ cS′ cU′) = drall cS cU cS′ cU′
(<:″⇒<:ᵣ S′<:S cΓ cS′ cS)
(<:″⇒<:ᵣ U<:U′ (ctt cS′ ∷ cΓ) cU cU′)
<:″⇒<:ᵣ (Π<: (Π<: S′<:S S′<:S₁) U<:U′) cΓ () cU
<:″⇒<:ᵣ (Π<: (sel₁ x S′<:S) U<:U′) cΓ () cU
<:″⇒<:ᵣ (Π<: (sel₂ x S′<:S) U<:U′) cΓ cS ()
<:″⇒<:ᵣ (Π<: (<:> T∈Γ T<:B T<:B′) U<:U′) cΓ (cvΠ _ _) (cvΠ _ _)
with lookupContraEnv T∈Γ cΓ
... | ctt _ = case ⟨A:⟩<:⟨A:⟩′ (<:″⇒<: T<:B) cΓ of λ ()
<:″⇒<:ᵣ (sel₁ T∈Γ T<:B) cΓ cS cU
with lookupContraEnv T∈Γ cΓ
... | ctt _ rewrite ⟨A:⟩<:⟨A:⟩′ (<:″⇒<: T<:B) cΓ = case cS of λ ()
<:″⇒<:ᵣ (sel₂ T∈Γ T<:B) cΓ cS cU
with lookupContraEnv T∈Γ cΓ
... | ctt cT = drsel T∈Γ cT (aux T<:B cΓ cT cU)
where aux : ∀ {Γ T S U} → Γ ⊢″ ⟨A: ⊥ ⋯ T ⟩ <: ⟨A: S ⋯ U ⟩ → ContraEnv Γ → Covar T → Covar U → Γ ⊢ᵣ T <: U
aux refl cΓ cT cU = drrefl cU
aux (bnd _ T<:U) cΓ cT cU = <:″⇒<:ᵣ T<:U cΓ cT cU
aux (<:> T′∈Γ T′<:B _) cΓ cT cU
with lookupContraEnv T′∈Γ cΓ
... | ctt _ = case ⟨A:⟩<:⟨A:⟩′ (<:″⇒<: T′<:B) cΓ of λ ()
<:″⇒<:ᵣ (<:> T∈Γ T<:B T<:B′) cΓ cS cU
with lookupContraEnv T∈Γ cΓ
... | ctt _ rewrite ⟨A:⟩<:⟨A:⟩′ (<:″⇒<: T<:B) cΓ = case cS of λ ()
<:ᵣ⇒<: : ∀ {Γ S U} → Γ ⊢ᵣ S <: U → Γ ⊢ S <: U
<:ᵣ⇒<: (drtop _) = dtop
<:ᵣ⇒<: (drrefl _) = drefl
<:ᵣ⇒<: (drall _ _ _ _ S′<:S U<:U′) = dall (dbnd dbot (<:ᵣ⇒<: S′<:S)) (<:ᵣ⇒<: U<:U′)
<:ᵣ⇒<: (drsel T∈Γ _ T<:B) = dtrans _ (dsel₂ T∈Γ drefl) (<:ᵣ⇒<: T<:B)
open FsubMinus.FsubMinus
F<:⇒D<: : ∀ {Γ S U} → Γ ⊢F S <: U → ⟪ Γ ⟫ ⊢ ⟦ S ⟧ <: ⟦ U ⟧
F<:⇒D<: = <:ᵣ⇒<: ∘ F<:⇒D<:ᵣ
D<:⇒F<: : ∀ {Γ S U} → ⟪ Γ ⟫ ⊢ ⟦ S ⟧ <: ⟦ U ⟧ → Γ ⊢F S <: U
D<:⇒F<: S<:U = D<:ᵣ⇒F<: (<:″⇒<:ᵣ (<:⇒<:″ S<:U) (⟪⟫-contraEnv _) (⟦⟧-covar _) (⟦⟧-covar _))
refl refl refl
|
{
"alphanum_fraction": 0.4035993824,
"avg_line_length": 52.9042253521,
"ext": "agda",
"hexsha": "6f92880ee2b7d0f5d584e5a9a40be1640f5653b6",
"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": "48214a55ebb484fd06307df4320813d4a002535b",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "HuStmpHrrr/popl20-artifact",
"max_forks_repo_path": "agda/DsubEquivSimpler.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "48214a55ebb484fd06307df4320813d4a002535b",
"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": "HuStmpHrrr/popl20-artifact",
"max_issues_repo_path": "agda/DsubEquivSimpler.agda",
"max_line_length": 160,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "48214a55ebb484fd06307df4320813d4a002535b",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "HuStmpHrrr/popl20-artifact",
"max_stars_repo_path": "agda/DsubEquivSimpler.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-23T08:40:28.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-09-23T08:40:28.000Z",
"num_tokens": 8737,
"size": 18781
}
|
module imper-nouni where
--
-- TO-DOs
--
-- * change use of =string
-- * prove that =string can't be both tt and ff
-- * prove reverse theorems for passes/fails/chck
-- * prove semantic equivalence for execs and execsTo
-- + this would be s-thm and s-det
open import lib
open import eq-reas-nouni
_=nat_ = _=ℕ_
_-nat_ = _∸_
cross = _×_
equiv = _≡_
bottom = ⊥
bottom-elim = ⊥-elim
--
-- inspect/with-eq idiom
--
data Singleton {a} {A : Set a} (x : A) : Set a where
_with-eq_ : (y : A) → equiv x y → Singleton x
inspect : forall {a} {A : Set a} (x : A) -> Singleton x
inspect x = x with-eq refl
--
-- variable identifiers
--
Id : Set
Id = string
_=Id_ : Id -> Id -> bool
_=Id_ = _=string_
--
-- values (just natural numbers here)
--
Val : Set
Val = nat
--
-- value and variable expressions
--
data Expn : Set where
val : Val -> Expn
var : Id -> Expn
plus : Expn -> Expn -> Expn
minus : Expn -> Expn -> Expn
scaleBy : Expn -> Val -> Expn
--
-- conditions on values and variables
--
data Cond : Set where
true : Cond
false : Cond
and : Cond -> Cond -> Cond
or : Cond -> Cond -> Cond
not : Cond -> Cond
less : Expn -> Expn -> Cond
equal : Expn -> Expn -> Cond
--
-- stack frames containing variable bindings
--
Frm : Set
Frm = list (cross Id Val)
--
-- program statements that transform a frame
--
data Stmt : Set where
skip : Stmt
assign : Id -> Expn -> Stmt
seq : Stmt -> Stmt -> Stmt
ifThenElse : Cond -> Stmt -> Stmt -> Stmt
repeatBy : Id -> Stmt -> Stmt
returns : Expn -> Stmt
--
-- functional SEMANTICS of frames
--
lkup : Id -> Frm -> Val
lkup x [] = 0
lkup x ((y , w) :: F) = if (x =Id y) then w else (lkup x F)
update : Id -> Val -> Frm -> Frm
update x v [] = (x , v) :: []
update x v ((y , w) :: F)
= if (x =Id y)
then (y , v) :: F
else (y , w) :: (update x v F)
--
-- functional SEMANTICS of expressions
--
eval : Expn -> Frm -> Val
eval (val v) F = v
eval (var x) F = lkup x F
eval (plus e1 e2) F = (eval e1 F) + (eval e2 F)
eval (minus e1 e2) F = (eval e1 F) -nat (eval e2 F)
eval (scaleBy e1 v2) F = (eval e1 F) * v2
--
-- functional SEMANTICS of conditions
--
chck : Cond -> Frm -> bool
chck true F = tt
chck false F = ff
chck (and c1 c2) F = (chck c1 F) && (chck c2 F)
chck (or c1 c2) F = (chck c1 F) || (chck c2 F)
chck (not c) F = ~ (chck c F)
chck (less e1 e2) F = (eval e1 F) < (eval e2 F)
chck (equal e1 e2) F = (eval e1 F) =nat (eval e2 F)
--
-- functional SEMANTICS of program execution
--
exec : Stmt -> Frm -> Frm
repeatedly : Stmt -> Id -> nat -> Frm -> Frm
repeatedly s x 0 F = F
repeatedly s x (suc n) F = repeatedly s x n (update x n (exec s F))
exec skip F = F
exec (seq s1 s2) F = (exec s2 (exec s1 F))
exec (assign x e) F = (update x (eval e F) F)
exec (ifThenElse c s1 s2) F = if (chck c F) then (exec s1 F) else (exec s2 F)
exec (repeatBy x s) F = repeatedly s x (lkup x F) F
exec (returns e) F = (update "retval" (eval e F) F)
--
-- SEMANTICS of stack bindings as a relation
--
data mapsTo : Frm -> Id -> Val -> Set where
var-undef : forall {x : Id}
----------------
-> (mapsTo [] x 0)
var-match : forall {x y : Id} {F : Frm} {v : Val}
-> (equiv (x =string y) tt)
---------------------------
-> (mapsTo ((y , v) :: F) x v)
var-mismatch : forall {x y : Id} {F : Frm} {v w : Val}
-> (equiv (x =string y) ff)
-> (mapsTo F x v)
----------------------------
-> (mapsTo ((y , w) :: F) x v)
--
-- THEOREM: mapsTo agrees with lookup
--
var-thm : forall (x : Id) (F : Frm) -> mapsTo F x (lkup x F)
var-thm x [] = var-undef
var-thm x ((y , w) :: F)
with (inspect (x =string y))
... | tt with-eq match =
let lkup-is-w : (equiv (lkup x ((y , w) :: F)) w)
lkup-is-w = cong3 if_then_else_ match refl refl
in cong-pred (mapsTo ((y , w) :: F) x) (sym lkup-is-w) (var-match match)
... | ff with-eq mismatch =
let lkup-is-lkup : (equiv (lkup x ((y , w) :: F)) (lkup x F))
lkup-is-lkup = cong3 if_then_else_ mismatch refl refl
in cong-pred (mapsTo ((y , w) :: F) x) (sym lkup-is-lkup) (var-mismatch mismatch (var-thm x F))
postulate
=Id-det : ∀ {x y : Id} -> (equiv (x =string y) tt) -> (equiv (x =string y) ff) -> bottom
var-det : forall{x : Id}{F : Frm}{u1 u2 : Val}
-> mapsTo F x u1 -> mapsTo F x u2 -> equiv u1 u2
var-det{x}{[]}{u1}{u2} var-undef var-undef =
refl
var-det{x}{(y , w) :: F}{u1}{u2} (var-match _) (var-match _) =
refl
var-det{x}{(y , w) :: F}{u1}{u2} (var-mismatch _ lkup-is-u1) (var-mismatch _ lkup-is-u2) =
var-det lkup-is-u1 lkup-is-u2
var-det{x}{(y , w) :: F}{u1}{u2} (var-match{.x}{.y}{.F}{.u1} same) (var-mismatch{.x}{.y}{.F}{.u2} diff _) =
bottom-elim (=Id-det{x}{y} same diff)
var-det{x}{(y , w) :: F}{u1}{u2} (var-mismatch{.x}{.y}{.F}{.u1} diff _) (var-match{.x}{.y}{.F}{.u2} same) =
bottom-elim (=Id-det{x}{y} same diff)
--
-- SEMANTICS of expression evaluation as a relation
--
data evalsTo : Frm -> Expn -> Val -> Set where
e-val : forall {v : Val} {F : Frm}
------------------------
-> (evalsTo F (val v) v)
e-var : forall {x : Id} {F : Frm} {v : Val}
-> (mapsTo F x v)
------------------------
-> (evalsTo F (var x) v)
e-add : forall {e1 e2 : Expn} {F : Frm} {v1 v2 : Val}
-> (evalsTo F e1 v1)
-> (evalsTo F e2 v2)
-------------------------------------
-> (evalsTo F (plus e1 e2) (v1 + v2))
e-sub : forall {e1 e2 : Expn} {F : Frm} {v1 v2 : Val}
-> (evalsTo F e1 v1)
-> (evalsTo F e2 v2)
-----------------------------------------
-> (evalsTo F (minus e1 e2) (v1 -nat v2))
e-scale : forall {e1 : Expn} {F : Frm} {v1 v2 : Val}
-> (evalsTo F e1 v1)
----------------------------------------
-> (evalsTo F (scaleBy e1 v2) (v1 * v2))
e-thm : forall (e : Expn) -> (F : Frm) -> (evalsTo F e (eval e F))
e-thm (val e) F = e-val
e-thm (var x) F = e-var (var-thm x F)
e-thm (plus e1 e2) F = (e-add (e-thm e1 F) (e-thm e2 F))
e-thm (minus e1 e2) F = (e-sub (e-thm e1 F) (e-thm e2 F))
e-thm (scaleBy e1 v2) F = (e-scale (e-thm e1 F))
e-det : forall {e : Expn}{F : Frm}{u w : Val}
-> (evalsTo F e u) -> (evalsTo F e w) -> (equiv u w)
e-det{val v}{F}{u}{w} e-val e-val = refl
e-det{var x}{F}{u}{w} (e-var var-lkup-u) (e-var var-lkup-v) =
var-det var-lkup-u var-lkup-v
e-det{plus e1 e2}{F}{u}{w} (e-add e-u1 e-u2) (e-add e-w1 e-w2) =
cong2 _+_ (e-det e-u1 e-w1) (e-det e-u2 e-w2)
e-det{minus e1 e2}{F}{u}{w} (e-sub e-u1 e-u2) (e-sub e-w1 e-w2) =
cong2 _-nat_ (e-det e-u1 e-w1) (e-det e-u2 e-w2)
e-det{scaleBy e1 v2}{F}{u}{w} (e-scale e-u1) (e-scale e-w1) =
cong2 _*_ (e-det e-u1 e-w1) refl
e-thm-fwd : forall {e : Expn}{F : Frm}{v : Val}
-> (evalsTo F e v) -> (equiv v (eval e F))
e-thm-fwd{e}{F}{v} ev =
let
p1 : evalsTo F e (eval e F)
p1 = e-thm e F
in e-det ev p1
e-thm-rev : forall {e : Expn}{F : Frm}{v : Val}
-> (equiv v (eval e F)) -> (evalsTo F e v)
e-thm-rev{e}{F}{v} v-is = cong-pred (evalsTo F e) (sym v-is) (e-thm e F)
--
-- SEMANTICS of conditions as a decidable relation
--
data passes : Frm -> Cond -> Set
data fails : Frm -> Cond -> Set
data passes where
c-tt : forall {F : Frm}
----------------
-> passes F true
c-and : forall {c1 c2 : Cond} {F : Frm}
-> passes F c1
-> passes F c2
-----------------------
-> passes F (and c1 c2)
c-or1 : forall {c1 c2 : Cond} {F : Frm}
-> passes F c1
----------------------
-> passes F (or c1 c2)
c-or2 : forall {c1 c2 : Cond} {F : Frm}
-> passes F c2
----------------------
-> passes F (or c1 c2)
c-less : forall {e1 e2 : Expn} {F : Frm} {v1 v2 : Val}
-> equiv (v1 < v2) tt
-> evalsTo F e1 v1
-> evalsTo F e2 v2
-------------------------
-> passes F (less e1 e2)
c-eq : forall {e1 e2 : Expn} {F : Frm} {v1 v2 : Val}
-> equiv (v1 =nat v2) tt
-> evalsTo F e1 v1
-> evalsTo F e2 v2
--------------------------
-> passes F (equal e1 e2)
c-not : forall {c : Cond} {F : Frm}
-> fails F c
-------------------
-> passes F (not c)
data fails where
~c-ff : forall {F : Frm}
----------------
-> fails F false
~c-or : forall {c1 c2 : Cond} {F : Frm}
-> fails F c1
-> fails F c2
-----------------------
-> fails F (or c1 c2)
~c-and1 : forall {c1 c2 : Cond} {F : Frm}
-> fails F c1
----------------------
-> fails F (and c1 c2)
~c-and2 : forall {c1 c2 : Cond} {F : Frm}
-> fails F c2
----------------------
-> fails F (and c1 c2)
~c-less : forall {e1 e2 : Expn} {F : Frm} {v1 v2 : Val}
-> equiv (v1 < v2) ff
-> evalsTo F e1 v1
-> evalsTo F e2 v2
-------------------------
-> fails F (less e1 e2)
~c-eq : forall {e1 e2 : Expn} {F : Frm} {v1 v2 : Val}
-> equiv (v1 =nat v2) ff
-> evalsTo F e1 v1
-> evalsTo F e2 v2
--------------------------
-> fails F (equal e1 e2)
~c-not : forall {c : Cond} {F : Frm}
-> passes F c
-------------------
-> fails F (not c)
c-thm-fwd : forall {c : Cond}{F : Frm} -> (passes F c) -> (equiv (chck c F) tt)
~c-thm-fwd : forall {c : Cond}{F : Frm} -> (fails F c) -> (equiv (chck c F) ff)
c-thm-fwd (c-tt{F}) = refl
c-thm-fwd (c-and{c1}{c2}{F} passes-c1 passes-c2) =
cong2 _&&_ (c-thm-fwd passes-c1) (c-thm-fwd passes-c2)
c-thm-fwd (c-or1{c1}{c2}{F} passes-c1) =
cong2 _||_ (c-thm-fwd passes-c1) refl
c-thm-fwd (c-or2{c1}{c2}{F} passes-c2) =
trans (cong2 _||_ refl (c-thm-fwd passes-c2)) (||-tt (chck c1 F))
c-thm-fwd (c-less{e1}{e2}{F}{v1}{v2} v1-less-v2 evalsTo-e1-v1 evalsTo-e2-v2) =
let
eval-e1-is-v1 : (equiv (eval e1 F) v1)
eval-e1-is-v1 = sym (e-thm-fwd evalsTo-e1-v1)
eval-e2-is-v2 : (equiv (eval e2 F) v2)
eval-e2-is-v2 = sym (e-thm-fwd evalsTo-e2-v2)
in
begin
chck (less e1 e2) F
equiv[ refl ]
(eval e1 F) < (eval e2 F)
equiv[ cong2 _<_ eval-e1-is-v1 eval-e2-is-v2 ]
v1 < v2
equiv[ v1-less-v2 ]
tt
qed
c-thm-fwd (c-eq{e1}{e2}{F}{v1}{v2} v1-equals-v2 evalsTo-e1-v1 evalsTo-e2-v2) =
let
eval-e1-is-v1 : (equiv (eval e1 F) v1)
eval-e1-is-v1 = sym (e-thm-fwd evalsTo-e1-v1)
eval-e2-is-v2 : (equiv (eval e2 F) v2)
eval-e2-is-v2 = sym (e-thm-fwd evalsTo-e2-v2)
in
begin
chck (equal e1 e2) F
equiv[ refl ]
(eval e1 F) =nat (eval e2 F)
equiv[ cong2 _=nat_ eval-e1-is-v1 eval-e2-is-v2 ]
v1 =nat v2
equiv[ v1-equals-v2 ]
tt
qed
c-thm-fwd (c-not{c}{F} c-fails) = cong ~_ (~c-thm-fwd c-fails)
~c-thm-fwd (~c-ff{F}) =
refl
~c-thm-fwd (~c-or{c1}{c2}{F} fails-c1 fails-c2) =
cong2 _||_ (~c-thm-fwd fails-c1) (~c-thm-fwd fails-c2)
~c-thm-fwd (~c-and1{c1}{c2}{F} fails-c1) =
cong2 _&&_ (~c-thm-fwd fails-c1) refl
~c-thm-fwd (~c-and2{c1}{c2}{F} fails-c2) =
trans (cong2 _&&_ refl (~c-thm-fwd fails-c2)) (&&-ff (chck c1 F))
~c-thm-fwd (~c-less{e1}{e2}{F}{v1}{v2} v1-not-less-v2 evalsTo-e1-v1 evalsTo-e2-v2) =
let
eval-e1-is-v1 : (equiv (eval e1 F) v1)
eval-e1-is-v1 = sym (e-thm-fwd evalsTo-e1-v1)
eval-e2-is-v2 : (equiv (eval e2 F) v2)
eval-e2-is-v2 = sym (e-thm-fwd evalsTo-e2-v2)
in begin
chck (less e1 e2) F
equiv[ refl ]
(eval e1 F) < (eval e2 F)
equiv[ cong2 _<_ eval-e1-is-v1 eval-e2-is-v2 ]
v1 < v2
equiv[ v1-not-less-v2 ]
ff
qed
~c-thm-fwd (~c-eq{e1}{e2}{F}{v1}{v2} v1-not-equals-v2 evalsTo-e1-v1 evalsTo-e2-v2) =
let
eval-e1-is-v1 : (equiv (eval e1 F) v1)
eval-e1-is-v1 = sym (e-thm-fwd evalsTo-e1-v1)
eval-e2-is-v2 : (equiv (eval e2 F) v2)
eval-e2-is-v2 = sym (e-thm-fwd evalsTo-e2-v2)
in
begin
chck (equal e1 e2) F
equiv[ refl ]
(eval e1 F) =nat (eval e2 F)
equiv[ cong2 _=nat_ eval-e1-is-v1 eval-e2-is-v2 ]
v1 =nat v2
equiv[ v1-not-equals-v2 ]
ff
qed
~c-thm-fwd (~c-not{c}{F} c-passes) =
cong ~_ (c-thm-fwd c-passes)
-- These can probably be shown just by using
-- the contrapositives of ~c-thm-fwd and ~~c-thm-fwd
postulate
c-thm-rev : forall {c : Cond}{F : Frm} -> (equiv (chck c F) tt) -> (passes F c)
~c-thm-rev : forall {c : Cond}{F : Frm} -> (equiv (chck c F) ff) -> (fails F c)
--
-- SEMANTICS of program statements
-- as a state transformation relation
--
data execsTo : Frm -> Stmt -> Frm -> Set where
s-skip : forall {F : Frm}
-------------------
-> execsTo F skip F
s-assign : forall {x : Id} {e : Expn} {F : Frm} {v : Val}
-> evalsTo F e v
----------------------------------------
-> execsTo F (assign x e) (update x v F)
s-seq : forall {s1 s2 : Stmt} {F0 F1 F2 : Frm}
-> (execsTo F0 s1 F1)
-> (execsTo F1 s2 F2)
------------------------------
-> (execsTo F0 (seq s1 s2) F2)
s-if-then : forall {c : Cond} {s1 s2 : Stmt} {F F' : Frm}
-> (passes F c)
-> (execsTo F s1 F')
--------------------------------------
-> (execsTo F (ifThenElse c s1 s2) F')
s-if-else : forall {c : Cond} {s1 s2 : Stmt} {F F' : Frm}
-> (fails F c)
-> (execsTo F s2 F')
--------------------------------------
-> (execsTo F (ifThenElse c s1 s2) F')
s-repeat-0 : forall {s : Stmt} {x : Id} {F : Frm}
-> (mapsTo F x 0)
-------------------------------
-> (execsTo F (repeatBy x s) F)
s-repeat-suc : forall {n : nat} {s : Stmt} {x : Id} {F F' : Frm}
-> (mapsTo F x (suc n))
-> (execsTo F (seq (seq s (assign x (val n))) (repeatBy x s)) F')
-----------------------------------------------------------------
-> (execsTo F (repeatBy x s) F')
--
-- A lil cheat: "returns" is just assign; doesn't exit
s-return : forall {e : Expn} {F : Frm} {rv : Val}
-> (evalsTo F e rv)
-------------------------------------------------
-> (execsTo F (returns e) (update "retval" rv F))
postulate
frm-compare : Frm -> Frm -> bool
frm-iso : Frm -> Frm -> Set
frm-not-iso : Frm -> Frm -> Set
postulate
s-thm : forall {s : Stmt}{F Ff Fr : Frm}
-> execsTo F s Fr
-> equiv (exec s F) Ff
----------------------
-> frm-iso Ff Fr
|
{
"alphanum_fraction": 0.4914568037,
"avg_line_length": 28.9146825397,
"ext": "agda",
"hexsha": "2b1095b86b3765d8a2004a442beddfff01262c8b",
"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": "80d9411b2869614cae488cd4a6272894146c9f3c",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "JimFixGroupResearch/imper-ial",
"max_forks_repo_path": "imper-nouni.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "80d9411b2869614cae488cd4a6272894146c9f3c",
"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": "JimFixGroupResearch/imper-ial",
"max_issues_repo_path": "imper-nouni.agda",
"max_line_length": 108,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "80d9411b2869614cae488cd4a6272894146c9f3c",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "JimFixGroupResearch/imper-ial",
"max_stars_repo_path": "imper-nouni.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 5466,
"size": 14573
}
|
{-# OPTIONS --exact-split #-}
postulate
I : Set
P : I → Set
record ∃ (P : I → Set) : Set where
constructor _,_
field
fst : I
snd : P fst
open ∃
data S : ∃ P → Set where
s : (i : I) (x : P i) → S (i , x)
Foo : (p : ∃ P) → S p → Set
Foo p (s .(fst p) .(snd p)) = I
|
{
"alphanum_fraction": 0.4802867384,
"avg_line_length": 13.95,
"ext": "agda",
"hexsha": "c20cec77a525f306c9b44fbd3d0eef3a38a16252",
"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/Issue1380b.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/Issue1380b.agda",
"max_line_length": 34,
"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/Issue1380b.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": 115,
"size": 279
}
|
module hello-world where
open import IO
open import Level
main = run {0ℓ} (putStrLn "Hello, World!")
|
{
"alphanum_fraction": 0.7281553398,
"avg_line_length": 14.7142857143,
"ext": "agda",
"hexsha": "f72a9f414d57f820d2c060ed26d66c6cf8bae547",
"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": "c134875eae37d265936199fda278416e2a3c1224",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "supeterlau/bedev",
"max_forks_repo_path": "agda/hello-world.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c134875eae37d265936199fda278416e2a3c1224",
"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": "supeterlau/bedev",
"max_issues_repo_path": "agda/hello-world.agda",
"max_line_length": 42,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "c134875eae37d265936199fda278416e2a3c1224",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "supeterlau/bedev",
"max_stars_repo_path": "agda/hello-world.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 29,
"size": 103
}
|
-- Andreas, 2011-05-10
-- {-# OPTIONS -v tc.term.con:20 -v tc.meta:20 #-}
module Issue380 where
data _==_ {A : Set}(a : A) : A -> Set where
refl : a == a
record Sigma (A : Set)(B : A -> Set) : Set where
constructor _,_
field
fst : A
snd : B fst
open Sigma public
testProj : {A : Set}{B : A -> Set}(y z : Sigma A B) ->
let X : Sigma A B
X = _
in fst X == fst y -> snd X == snd z
testProj y z = refl , refl
{- OLD BEHAVIOR: Error message about telescope comparison unreadable
This ill-typed term produces a weird error message:
(z' : fst (fst z , _283 y z) == fst y) !=<
when checking that the expression refl , refl has type
fst (fst z , _283 y z) == fst y → snd (fst z , _283 y z) == snd z
-}
{- FIXED. Now it should complain that
Sigma (_47 y z == _47 y z) (_45 y z) !=<
fst (fst z , _43 y z) == fst y → snd (fst z , _43 y z) == snd z
when checking that the expression refl , refl has type
fst (fst z , _43 y z) == fst y → snd (fst z , _43 y z) == snd z
-}
|
{
"alphanum_fraction": 0.5947315096,
"avg_line_length": 30.84375,
"ext": "agda",
"hexsha": "0f3a60fea9f60461f2978889acc5f044d6bcbb23",
"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/Issue380.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/Issue380.agda",
"max_line_length": 69,
"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/Issue380.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 339,
"size": 987
}
|
module _ where
open import Common.Bool
private
unused = true
used = true
private
module Private where
not-in-scope = true
in-scope = used
|
{
"alphanum_fraction": 0.7133333333,
"avg_line_length": 10,
"ext": "agda",
"hexsha": "b0218dba220a5273c24cf1476efb9a68b5818a7e",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/interaction/TopScope.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/interaction/TopScope.agda",
"max_line_length": 23,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/interaction/TopScope.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": 42,
"size": 150
}
|
record R : Set₁ where
field
⟨_+_⟩ : Set
open R
-- Name parts coming from projections can not be used as part of the
-- defined name.
+ : Set → Set
+ A = A
|
{
"alphanum_fraction": 0.6280487805,
"avg_line_length": 13.6666666667,
"ext": "agda",
"hexsha": "d6e08e2ecfc2c63e9868323502f53e97bc622bbf",
"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/Issue3400-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/Fail/Issue3400-2.agda",
"max_line_length": 68,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/Issue3400-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": 51,
"size": 164
}
|
{-# OPTIONS --without-K #-}
open import HoTT
open import homotopy.elims.Lemmas
open import homotopy.elims.CofPushoutSection
module homotopy.elims.SuspSmash {i j k} {X : Ptd i} {Y : Ptd j}
{P : Suspension (X ∧ Y) → Type k}
(north* : P north) (south* : P south)
(cod* : (s : fst X × fst Y) → north* == south* [ P ↓ merid (cfcod s) ])
where
private
base* = transport (λ κ → north* == south* [ P ↓ merid κ ])
(! (cfglue (winl (snd X))))
(cod* (snd X , snd Y))
coh* : (s : X ∧ Y) → north* == south* [ P ↓ merid s ]
coh* = CofPushoutSection.elim (λ _ → tt) (λ _ → idp)
base*
(λ {(x , y) →
(fst (fillX x) ∙ fst (fillY y)) ◃ fst fill0 ◃ cod* (x , y)})
(↓↓-from-squareover ∘ λ x →
snd (fillX x) ↓⊡h∙
ap (λ p → p ◃ fst fill0 ◃ cod* (x , snd Y))
(! (ap (λ q → fst (fillX x) ∙ q) fillY-lemma ∙ ∙-unit-r _)))
(↓↓-from-squareover ∘ λ y →
snd (fillY y) ↓⊡h∙
ap (λ p → p ◃ fst fill0 ◃ cod* (snd X , y))
(! (ap (λ q → q ∙ fst (fillY y)) fillX-lemma)))
where
fill-lemma : (w : X ∨ Y)
(α : north* == south* [ P ↓ merid (cfcod (∨-in-× X Y w)) ])
→ Σ (north* == north*)
(λ p → SquareOver P (natural-square merid (cfglue w))
base*
(↓-ap-in _ _ (apd (λ _ → north*) (cfglue w)))
(↓-ap-in _ _ (apd (λ _ → south*) (cfglue w)))
(p ◃ α))
fill-lemma w α = fill-upper-right _ _ _ _ _
fill0 = fill-lemma (winl (snd X)) (cod* (snd X , snd Y))
fillX = λ x → fill-lemma (winl x) (fst fill0 ◃ cod* (x , snd Y))
fillY = λ y → fill-lemma (winr y) (fst fill0 ◃ cod* (snd X , y))
fillX-lemma : fst (fillX (snd X)) == idp
fillX-lemma = ! $
fill-upper-right-unique _ _ _ _ _ idp (snd fill0 ↓⊡h∙ ! (idp◃ _))
fillY-lemma : fst (fillY (snd Y)) == idp
fillY-lemma = ! $
fill-upper-right-unique _ _ _ _ _ idp (snd fill0 ↓⊡h∙ ! (idp◃ _))
∙ ap (λ w → fst (fill-lemma w (fst fill0 ◃ cod* (∨-in-× X Y w))))
wglue
susp-smash-elim : Π (Suspension (X ∧ Y)) P
susp-smash-elim = Suspension-elim north* south* coh*
|
{
"alphanum_fraction": 0.5014150943,
"avg_line_length": 36.5517241379,
"ext": "agda",
"hexsha": "d7ef8fccba58384166121778db0eeb3f1539936d",
"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/homotopy/elims/SuspSmash.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/homotopy/elims/SuspSmash.agda",
"max_line_length": 73,
"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/homotopy/elims/SuspSmash.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 836,
"size": 2120
}
|
-- {-# OPTIONS -v term:20 #-}
module Issue787 where
data ⊥ : Set where
data List (A : Set) : Set where
[] : List A
_∷_ : A → List A → List A
data Rat' {X : Set} : List (List X) → List X → Set where
cons : ∀{ss x xs} → Rat' ((x ∷ xs) ∷ ss) xs → Rat' ss (x ∷ xs)
bad : {X : Set} (xs : List X) (acc : List (List X)) (p : Rat' acc xs) → ⊥
bad .(x ∷ xs) acc (cons {ss = .acc} {x = x} {xs = xs} p) =
bad (x ∷ xs) acc (cons {ss = acc} {x = x} {xs = xs} p)
-- Andreas, 2013-02-18
-- This should give a termination error.
-- It did pass up to today because of the idempotency check
-- excluded bad calls with embedded sub-matrices.
-- Disabling matrix-shaped orders, which do not have a formal semantics
-- anyway, bring the termination problem to Agda's attention.
|
{
"alphanum_fraction": 0.6025974026,
"avg_line_length": 33.4782608696,
"ext": "agda",
"hexsha": "ed8548ce7a980c4b70043522515e08d490e7afe3",
"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/Issue787.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/Issue787.agda",
"max_line_length": 73,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/Issue787.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": 272,
"size": 770
}
|
module Warshall
(X : Set)
((≤) : X -> X -> Prop)
-- and axioms...
where
id : {A:Set} -> A -> A
id x = x
(∘) : {A B C:Set} -> (B -> C) -> (A -> B) -> A -> C
f ∘ g = \x -> f (g x)
-- Natural numbers --------------------------------------------------------
data Nat : Set where
zero : Nat
suc : Nat -> Nat
(+) : Nat -> Nat -> Nat
zero + m = m
suc n + m = suc (n + m)
-- Finite sets ------------------------------------------------------------
data Zero : Set where
data Suc (A:Set) : Set where
fzero_ : Suc A
fsuc_ : A -> Suc A
mutual
data Fin (n:Nat) : Set where
finI : Fin_ n -> Fin n
Fin_ : Nat -> Set
Fin_ zero = Zero
Fin_ (suc n) = Suc (Fin n)
fzero : {n:Nat} -> Fin (suc n)
fzero = finI fzero_
fsuc : {n:Nat} -> Fin n -> Fin (suc n)
fsuc i = finI (fsuc_ i)
finE : {n:Nat} -> Fin n -> Fin_ n
finE (finI i) = i
infixr 15 ::
-- Vectors ----------------------------------------------------------------
data Nil : Set where
nil_ : Nil
data Cons (Xs:Set) : Set where
cons_ : X -> Xs -> Cons Xs
mutual
data Vec (n:Nat) : Set where
vecI : Vec_ n -> Vec n
Vec_ : Nat -> Set
Vec_ zero = Nil
Vec_ (suc n) = Cons (Vec n)
nil : Vec zero
nil = vecI nil_
(::) : {n:Nat} -> X -> Vec n -> Vec (suc n)
x :: xs = vecI (cons_ x xs)
vecE : {n:Nat} -> Vec n -> Vec_ n
vecE (vecI xs) = xs
vec : (n:Nat) -> X -> Vec n
vec zero _ = nil
vec (suc n) x = x :: vec n x
map : {n:Nat} -> (X -> X) -> Vec n -> Vec n
map {zero} f (vecI nil_) = nil
map {suc n} f (vecI (cons_ x xs)) = f x :: map f xs
(!) : {n:Nat} -> Vec n -> Fin n -> X
(!) {suc n} (vecI (cons_ x _ )) (finI fzero_) = x
(!) {suc n} (vecI (cons_ _ xs)) (finI (fsuc_ i)) = xs ! i
upd : {n:Nat} -> Fin n -> X -> Vec n -> Vec n
upd {suc n} (finI fzero_) x (vecI (cons_ _ xs)) = x :: xs
upd {suc n} (finI (fsuc_ i)) x (vecI (cons_ y xs)) = y :: upd i x xs
tabulate : {n:Nat} -> (Fin n -> X) -> Vec n
tabulate {zero} f = nil
tabulate {suc n} f = f fzero :: tabulate (\x -> f (fsuc x))
postulate
(===) : {n:Nat} -> Vec n -> Vec n -> Prop
module Proof
(F : {n:Nat} -> Vec n -> Vec n)
-- and axioms...
where
stepF : {n:Nat} -> Fin n -> Vec n -> Vec n
stepF i xs = upd i (F xs ! i) xs
unsafeF' : {n:Nat} -> Nat -> Vec (suc n) -> Vec (suc n)
unsafeF' zero = id
unsafeF' (suc m) = unsafeF' m ∘ stepF fzero
unsafeF : {n:Nat} -> Vec n -> Vec n
unsafeF {zero} = id
unsafeF {suc n} = unsafeF' (suc n)
thm : {n:Nat} -> (xs:Vec n) -> F xs === unsafeF xs
thm = ?
|
{
"alphanum_fraction": 0.4685148515,
"avg_line_length": 20.867768595,
"ext": "agda",
"hexsha": "33c957a2be3b8af2daa74d2526b2a26014bb60ac",
"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/Warshall.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/Warshall.agda",
"max_line_length": 75,
"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/Warshall.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": 1005,
"size": 2525
}
|
module BTA4 where
-- specialize two-level typed terms to untyped lambda calculus
open import Data.Nat hiding (_<_)
open import Data.Bool
open import Data.Fin hiding (_≤_ ; pred; _+_)
open import Data.List
open import Data.Product
open import Function
open import Algebra.FunctionProperties using (Commutative; Identity; RightIdentity)
open import Relation.Binary.PropositionalEquality as PropEq
using (_≡_; _≢_; refl; sym; cong; cong₂)
open PropEq.≡-Reasoning
open import Data.Nat.Properties
open import Relation.Nullary
-- Binding times
data BT : Set where
S : BT
D : BT
-- defining a data type [BT],where two members are
-- [S] standing for "static" and [D] standing for dynamic.
-- ``subsumption'' binding times; static can be treated as dynamic,
-- but not vice versa
_≼_ : BT → BT → Bool
_≼_ D S = false
_≼_ _ _ = true
record True : Set where
data False : Set where
isTrue : Bool → Set
isTrue true = True
isTrue false = False
-- an inductive type describing bt subsumption
data _⊑_ : BT → BT → Set where
bt-leq-refl : ∀ {bt} → bt ⊑ bt
bt-leq-dyn : ∀ {bt} → bt ⊑ D
bt-reify : ∀ bt1 bt2 → isTrue (bt1 ≼ bt2) → bt1 ⊑ bt2
bt-reify S S p = bt-leq-refl
bt-reify S D p = bt-leq-dyn
bt-reify D S ()
bt-reify D D p = bt-leq-refl
bt-reflect : ∀ bt1 bt2 → bt1 ⊑ bt2 → isTrue (bt1 ≼ bt2)
bt-reflect S S p = _
bt-reflect S D p = _
bt-reflect D S ()
bt-reflect D D p = _
-- More general purpose definitions (should also be in standard library)
-- list membership
infix 4 _∈_
data _∈_ {A : Set} : A → List A → Set where
hd : ∀ {x xs} → x ∈ (x ∷ xs)
tl : ∀ {x y xs} → x ∈ xs → x ∈ (y ∷ xs)
-- Types of the calculus
mutual
-- s ^ BT
data AType : Set where
Ann : BT → SType → AType
-- int | t -> t
data SType : Set where
SInt : SType
SFun : AType → AType → SType
-- aux definitions
ATInt : BT → AType
ATInt bt = Ann bt SInt
ATFun : BT → AType → AType → AType
ATFun bt at1 at2 = Ann bt (SFun at1 at2)
-- projection: get the BT from a type
btof : AType → BT
btof (Ann bt _) = bt
-- an alternative: have only wf types from the start
data AType' : BT → Set where
AInt : (bt : BT) → AType' bt
AFun : (bt : BT) → ∀ {bt1 bt2} → AType' bt1 → AType' bt2 → bt ⊑ bt1 → bt ⊑ bt2 → AType' bt
forget-wft : ∀ {bt} → AType' bt → AType
forget-wft {bt} (AInt .bt) = ATInt bt
forget-wft {bt} (AFun .bt at at₁ x x₁) = ATFun bt (forget-wft at) (forget-wft at₁)
data LEQ-Problem : Set where
LEQ-not-D⊑S : LEQ-Problem
data WF-Problem : Set where
WF-LEQ-right : LEQ-Problem → WF-Problem
WF-LEQ-left : LEQ-Problem → WF-Problem
WF-WF-left : WF-Problem → WF-Problem
WF-WF-right : WF-Problem → WF-Problem
data Inferred (E A : Set) : Set where
Ok : A → Inferred E A
Error : E → Inferred E A
infer-bt-leq : ∀ bt1 bt2 → Inferred LEQ-Problem (bt1 ⊑ bt2)
infer-bt-leq S S = Ok bt-leq-refl
infer-bt-leq S D = Ok bt-leq-dyn
infer-bt-leq D S = Error LEQ-not-D⊑S
infer-bt-leq D D = Ok bt-leq-refl
-- insufficiently constrained ...
infer-wft' : (α : AType) → Inferred WF-Problem (AType' (btof α))
infer-wft' (Ann x SInt) = Ok (AInt x)
infer-wft' (Ann x (SFun x₁ x₂)) with infer-wft' x₁ | infer-wft' x₂ | infer-bt-leq x (btof x₁) | infer-bt-leq x (btof x₂)
infer-wft' (Ann x₄ (SFun x₁ x₂)) | Ok x | Ok x₃ | Ok x₅ | Ok x₆ = Ok (AFun x₄ x x₃ x₅ x₆)
infer-wft' (Ann x₄ (SFun x₁ x₂)) | Ok x | Ok x₃ | Ok x₅ | Error x₆ = Error (WF-LEQ-right x₆)
infer-wft' (Ann x₄ (SFun x₁ x₂)) | Ok x | Ok x₃ | Error x₅ | okbt2 = Error (WF-LEQ-left x₅)
infer-wft' (Ann x₄ (SFun x₁ x₂)) | Ok x | Error x₃ | _ | _ = Error (WF-WF-right x₃)
infer-wft' (Ann x₃ (SFun x₁ x₂)) | Error x | r2 | _ | _ = Error (WF-WF-left x)
-- might be easier to infer a Σ type
check-wft : (α : AType) → Inferred WF-Problem (∃ λ α' → α ≡ forget-wft {btof α} α')
check-wft (Ann x SInt) = Ok (AInt x , refl)
check-wft (Ann x (SFun x₁ x₂)) with check-wft x₁ | check-wft x₂ | infer-bt-leq x (btof x₁) | infer-bt-leq x (btof x₂)
... | Ok (α₁ , pr₁) | Ok (α₂ , pr₂) | Ok leq₁ | Ok leq₂ = Ok (AFun x α₁ α₂ leq₁ leq₂ , cong₂ (λ x₃ x₄ → Ann x (SFun x₃ x₄)) pr₁ pr₂)
... | Ok p₁ | Ok p₂ | Ok leq₁ | Error e₄ = Error (WF-LEQ-right e₄)
... | Ok p₁ | Ok p₂ | Error e₃ | _ = Error (WF-LEQ-left e₃)
... | Ok p₁ | Error e₂ | _ | _ = Error (WF-WF-right e₂)
... | Error e₁ | _ | _ | _ = Error (WF-WF-left e₁)
unfold-forget : ∀ bt {bt₁} {bt₂} at₁ at₂ x₅ x₆ →
forget-wft (AFun bt {bt₁} {bt₂} at₁ at₂ x₅ x₆) ≡ ATFun bt (forget-wft at₁) (forget-wft at₂)
unfold-forget bt at₁ at₂ x₅ x₆ = refl
-- well-formedness
data wft : AType → Set where
wf-int : ∀ {bt} → wft (Ann bt SInt)
wf-fun : ∀ {bt at1 at2} → wft at1 → wft at2
→ isTrue (bt ≼ btof at1) → isTrue (bt ≼ btof at2) → wft (Ann bt (SFun at1 at2))
infer-lemma-fun-left : ∀ σ₁ α₂ → ¬ wft (Ann D (SFun (Ann S σ₁) α₂))
infer-lemma-fun-left σ₁ α₂ (wf-fun v v₁ () x₁)
infer-lemma-fun-right : ∀ α σ → ¬ wft (Ann D (SFun α (Ann S σ)))
infer-lemma-fun-right α σ (wf-fun v v₁ x ())
infer-yes-yes : ∀ bt α₁ α₂ → (wf1 : wft α₁) (wf2 : wft α₂) → Dec (wft (Ann bt (SFun α₁ α₂)))
infer-yes-yes S (Ann bt1 σ₁) (Ann bt2 σ₂) wf1 wf2 = yes (wf-fun wf1 wf2 _ _)
infer-yes-yes D (Ann D σ₁) (Ann D σ₂) wf1 wf2 = yes (wf-fun wf1 wf2 _ _)
infer-yes-yes D (Ann S σ₁) (Ann bt2 σ₂) wf1 wf2 = no (infer-lemma-fun-left σ₁ (Ann bt2 σ₂))
infer-yes-yes D (Ann bt1 σ₁) (Ann S σ₂) wf1 wf2 = no (infer-lemma-fun-right (Ann bt1 σ₁) σ₂)
infer-lemma-arg-left : ∀ bt α₁ α₂ → ¬ wft α₁ → ¬ wft (Ann bt (SFun α₁ α₂))
infer-lemma-arg-left bt α₁ α₂ ¬wft1 (wf-fun v v₁ x x₁) = ¬wft1 v
infer-lemma-arg-right : ∀ bt α₁ α₂ → ¬ wft α₂ → ¬ wft (Ann bt (SFun α₁ α₂))
infer-lemma-arg-right bt α₁ α₂ ¬wft2 (wf-fun v v₁ x x₁) = ¬wft2 v₁
infer-wft : (α : AType) → Dec (wft α)
infer-wft (Ann bt SInt) = yes wf-int
infer-wft (Ann bt (SFun α₁ α₂))
with infer-wft α₁ | infer-wft α₂
... | yes wf1 | yes wf2 = infer-yes-yes bt α₁ α₂ wf1 wf2
... | yes wf1 | no ¬wf2 = no (infer-lemma-arg-right bt α₁ α₂ ¬wf2)
... | no ¬wf1 | yes wf2 = no (infer-lemma-arg-left bt α₁ α₂ ¬wf1)
... | no ¬wf1 | no ¬wf2 = no (infer-lemma-arg-left bt α₁ α₂ ¬wf1)
----------------------------------------------------------------------
-- step 0
-- Untyped expressions, incorrect results
data Exp : Set where
EVar : ℕ → Exp
EInt : ℕ → Exp
EAdd : Exp → Exp → Exp
ELam : Exp → Exp
EApp : Exp → Exp → Exp
-- mapping from annotated type to implementation type
ImpTA : AType → Set
ImpTA (Ann S SInt) = ℕ
ImpTA (Ann S (SFun α β)) = ImpTA α → ImpTA β
ImpTA (Ann D σ) = Exp
-- test for dynamic by wellformedness
data IsDynamic : AType → Set where
is-dyn : ∀ σ → IsDynamic (Ann D σ)
lem-IsDynamic-by-wf : ∀ α → isTrue (D ≼ btof α) → IsDynamic α
lem-IsDynamic-by-wf (Ann S σ) ()
lem-IsDynamic-by-wf (Ann D σ) _ = is-dyn σ
-- typed annotated expressions
ACtx = List AType
data AExp (Δ : ACtx) : AType → Set where
AVar : ∀ {α} → α ∈ Δ → AExp Δ α
AInt : (bt : BT) → ℕ → AExp Δ (ATInt bt)
AAdd : (bt : BT) → AExp Δ (ATInt bt) → AExp Δ (ATInt bt) → AExp Δ (ATInt bt)
ALam : ∀ {α₁ α₂} (bt : BT) → wft (ATFun bt α₂ α₁) → AExp (α₂ ∷ Δ) α₁ → AExp Δ (ATFun bt α₂ α₁)
AApp : ∀ {α₁ α₂} (bt : BT) → wft (ATFun bt α₂ α₁) → AExp Δ (ATFun bt α₂ α₁) → AExp Δ α₂ → AExp Δ α₁
-- TODO: replace wellformedness of types in AApp with lemma
-- the lemma does not require wft in AApp
data wft-context : ACtx → Set where
wft-[] : wft-context []
wft-:: : ∀ {α Δ} → wft α → wft-context Δ → wft-context (α ∷ Δ)
lemma-wft-var : ∀ {α Δ} → wft-context Δ → α ∈ Δ → wft α
lemma-wft-var (wft-:: x wc) hd = x
lemma-wft-var (wft-:: x wc) (tl pf) = lemma-wft-var wc pf
lemma-wft : ∀ {α Δ} → wft-context Δ → AExp Δ α → wft α
lemma-wft wc (AVar x) = lemma-wft-var wc x
lemma-wft wc (AInt bt x) = wf-int
lemma-wft wc (AAdd bt ae₁ ae₂) = wf-int
lemma-wft wc (ALam bt x ae) = x
lemma-wft wc (AApp bt _ ae ae₁)
with lemma-wft wc ae
... | (wf-fun w₁ w₂ d≤bt₁ d≤bt₂) = w₂
data AEnv0 (F : AType → Set) : ACtx -> Set where
AE[] : AEnv0 F []
AE∷ : ∀ {Δ} α → F α → AEnv0 F Δ → AEnv0 F (α ∷ Δ)
AEnv = AEnv0 ImpTA
aelength : ∀ {F Δ} → AEnv0 F Δ → ℕ
aelength AE[] = 0
aelength (AE∷ α x ae) = suc( aelength ae)
lookup : ∀ {F Δ α} → AEnv0 F Δ → (o : α ∈ Δ ) → F α
lookup (AE∷ α x env) hd = x
lookup (AE∷ α x env) (tl o) = lookup env o
-- partial evaluation
peval : ∀ {α Δ } → AExp Δ α → AEnv Δ → ImpTA α
peval (AVar x) env = lookup env x
peval (AInt S x) env = x
peval (AInt D x) env = EInt x
peval (AAdd S e₁ e₂) env = peval e₁ env + peval e₂ env
peval (AAdd D e₁ e₂) env = EAdd (peval e₁ env) (peval e₂ env)
peval (ALam {α₂} {α₁} S w e) env = λ y → peval e (AE∷ α₁ y env)
peval (ALam {α₂} {α₁} D (wf-fun w₁ w₂ d≤bt₁ d≤bt₂) e) env
with lem-IsDynamic-by-wf α₁ d≤bt₁ | lem-IsDynamic-by-wf α₂ d≤bt₂
peval (ALam {.(Ann D σ₂)} {.(Ann D σ₁)} D (wf-fun _ _ d≤bt₁ d≤bt₂) e) env
| is-dyn σ₁ | is-dyn σ₂ = ELam (peval e (AE∷ (Ann D σ₁) (EVar (aelength env)) env))
peval (AApp S w e e₁) env = peval e env (peval e₁ env)
peval (AApp {α₂} {α₁} D (wf-fun w₁ w₂ d≤bt₁ d≤bt₂) e e₁) env
with lem-IsDynamic-by-wf α₁ d≤bt₁ | lem-IsDynamic-by-wf α₂ d≤bt₂
peval (AApp {.(Ann D σ₂)} {.(Ann D σ₁)} D (wf-fun _ _ d≤bt₁ d≤bt₂) e e₁) env
| is-dyn σ₁ | is-dyn σ₂ = EApp (peval e env) (peval e₁ env)
----------------------------------------------------------------------
-- step 1
-- Untyped expression, but correctly scoped
data Exp' : ℕ → Set where
EVar : ∀ {n} → Fin n → Exp' n
EInt : ∀ {n} → ℕ → Exp' n
EAdd : ∀ {n} → Exp' n → Exp' n → Exp' n
ELam : ∀ {n} → Exp' (suc n) → Exp' n
EApp : ∀ {n} → Exp' n → Exp' n → Exp' n
---
m+1+n≡1+m+n : ∀ m n → m + suc n ≡ suc (m + n)
m+1+n≡1+m+n zero n = refl
m+1+n≡1+m+n (suc m) n = cong suc (m+1+n≡1+m+n m n)
n+0≡n : ∀ n → n + 0 ≡ n
n+0≡n zero = refl
n+0≡n (suc n) = cong suc $ n+0≡n n
+-comm : ∀ m n → m + n ≡ n + m
+-comm zero n = sym (n+0≡n n)
+-comm (suc m) n =
begin
suc m + n
≡⟨ refl ⟩
suc (m + n)
≡⟨ cong suc (+-comm m n) ⟩
suc (n + m)
≡⟨ sym (m+1+n≡1+m+n n m) ⟩
n + suc m
∎
≤-refl : ∀ {n} → n ≤ n
≤-refl {zero} = z≤n
≤-refl {suc n} = s≤s ≤-refl
≤-trans : ∀ {a b c} → a ≤ b → b ≤ c → a ≤ c
≤-trans z≤n q = z≤n
≤-trans (s≤s p) (s≤s q) = s≤s (≤-trans p q)
≤-suc-right : ∀ {m n} → m ≤ n → m ≤ suc n
≤-suc-right z≤n = z≤n
≤-suc-right (s≤s p) = s≤s (≤-suc-right p)
≤-suc-left : ∀ {m n} → suc m ≤ n → m ≤ n
≤-suc-left (s≤s p) = ≤-suc-right p
xlate : ∀ {m} {n} → Exp' (m + suc n) → Exp' (suc (n + m))
xlate {m} {n} e rewrite m+1+n≡1+m+n m n | +-comm m n = e
shifter1 : ∀ {n} m → Exp' (suc n) → Exp' (suc (n + m))
shifter1 {n} m (EVar x) = xlate {m} (EVar (raise m x))
shifter1 m (EInt x) = EInt x
shifter1 m (EAdd e₁ e₂) = EAdd (shifter1 m e₁) (shifter1 m e₂)
shifter1 m (ELam e) = ELam (shifter1 m e)
shifter1 m (EApp e e₁) = EApp (shifter1 m e) (shifter1 m e₁)
shifter0 : ∀ m → Exp' zero → Exp' m
shifter0 m (EVar ())
shifter0 m (EInt x) = EInt x
shifter0 m (EAdd e₁ e₂) = EAdd (shifter0 m e₁) (shifter0 m e₂)
shifter0 m (ELam e) = ELam (shifter1 m e)
shifter0 m (EApp e e₁) = EApp (shifter0 m e) (shifter0 m e₁)
shifter : ∀ m d → Exp' m → Exp' (m + d)
shifter zero d e = shifter0 d e
shifter (suc m) d e = shifter1 d e
-- m+n∸m≡n : ∀ {m n} → m ≤ n → m + (n ∸ m) ≡ n
-- m+n∸m≡n p
helper : ∀ {m n} → n ≤ m → Exp' (n + (m ∸ n)) → Exp' m
helper p e rewrite m+n∸m≡n p = e
-- index m = nesting level of dynamic definitions
Imp : (m : ℕ) → AType → Set
Imp m (Ann S SInt) = ℕ
Imp m (Ann S (SFun α₁ α₂)) = ∀ n → m ≤ n → (Imp n α₁ → Imp n α₂)
Imp m (Ann D σ) = Exp' m
-- index = nesting level of dynamic definitions
data AEnv1 : ℕ → ACtx → Set where
[] : AEnv1 0 []
consS : ∀ {m Δ o} → m ≤ o → (α : AType) → Imp o α → AEnv1 m Δ → AEnv1 o (α ∷ Δ)
consD : ∀ {m Δ} → (α : AType) → isTrue (D ≼ btof α) → Imp (suc m) α → AEnv1 m Δ → AEnv1 (suc m) (α ∷ Δ)
lift1 : ∀ {m n} α → m ≤ n → Imp m α → Imp n α
lift1 (Ann S SInt) p v = v
lift1 (Ann S (SFun x x₁)) p v = λ k n≤k → v k (≤-trans p n≤k)
lift1 {m} {n} (Ann D σ) p v = helper p (shifter m (n ∸ m) v)
lookup1 : ∀ {α Δ m n} → m ≤ n → AEnv1 m Δ → α ∈ Δ → Imp n α
lookup1 {α} p (consS _ .α x env) hd = lift1 α p x
lookup1 {α} p (consD .α x x₁ env) hd = lift1 α p x₁
lookup1 p (consS p' .y x env) (tl {_} {y} x₁) = lookup1 (≤-trans p' p) env x₁
lookup1 p (consD .y x x₁ env) (tl {_} {y} x₂) = lookup1 (≤-suc-left p) env x₂
pe1 : ∀ {α Δ} m → AExp Δ α → AEnv1 m Δ → Imp m α
pe1 m (AVar x) env = lookup1 ≤-refl env x
pe1 m (AInt S x) env = x
pe1 m (AInt D x) env = EInt x
pe1 m (AAdd S e₁ e₂) env = pe1 m e₁ env + pe1 m e₂ env
pe1 m (AAdd D e₁ e₂) env = EAdd (pe1 m e₁ env) (pe1 m e₂ env)
pe1 m (ALam S x e) env = λ o p → λ v → pe1 o e (consS p _ v env)
pe1 m (ALam {α₂} {α₁} D (wf-fun w₁ w₂ d≤bt₁ d≤bt₂) e) env
with lem-IsDynamic-by-wf α₁ d≤bt₁ | lem-IsDynamic-by-wf α₂ d≤bt₂
pe1 m (ALam {.(Ann D σ₂)} {.(Ann D σ₁)} D (wf-fun _ _ d≤bt₁ d≤bt₂) e) env
| is-dyn σ₁ | is-dyn σ₂ = ELam (pe1 (suc m) e (consD (Ann D σ₁) d≤bt₁ (EVar zero) env))
pe1 m (AApp S x e e₁) env = (pe1 m e env) m ≤-refl (pe1 m e₁ env)
pe1 m (AApp {α₂} {α₁} D (wf-fun w₁ w₂ d≤bt₁ d≤bt₂) e e₁) env
with lem-IsDynamic-by-wf α₁ d≤bt₁ | lem-IsDynamic-by-wf α₂ d≤bt₂
pe1 m (AApp {.(Ann D σ₂)} {.(Ann D σ₁)} D (wf-fun w₁ w₂ d≤bt₁ d≤bt₂) e e₁) env
| is-dyn σ₁ | is-dyn σ₂ = EApp (pe1 m e env) (pe1 m e₁ env)
term1 : AExp [] (ATInt D)
term1 = AInt D 42
term2 : AExp [] (ATFun D (ATInt D) (ATInt D))
term2 = ALam D (wf-fun wf-int wf-int _ _) (AVar hd)
-- Dλ y → let f = λ x → x D+ y in Dλ z → f z
-- Dλ y → let f = λ x → (Dλ w → x D+ y) in Dλ z → f z
-- Dλ y → (λ f → Dλ z → f z) (λ x → (Dλ w → x D+ y))
-- :: DInt D→ (DT D→ DInt)
-- y : DInt, f : DInt → (DT D→ DInt)
term3-0 : AExp (Ann D SInt ∷ Ann D SInt ∷ Ann D SInt ∷ []) (Ann D SInt)
term3-0 = AAdd D (AVar (tl (tl hd))) (AVar (tl hd))
term3-1 : AExp (Ann D SInt ∷ Ann D SInt ∷ []) (Ann D (SFun (Ann D SInt) (Ann D SInt)))
term3-1 = ALam D (wf-fun wf-int wf-int _ _) term3-0
term3-2 : AExp (Ann D SInt ∷ []) (Ann S (SFun (Ann D SInt) (Ann D (SFun (Ann D SInt) (Ann D SInt)))))
term3-2 = ALam S (wf-fun wf-int (wf-fun wf-int wf-int _ _) _ _) term3-1
term3-3 : AExp (Ann D SInt ∷ Ann S (SFun (Ann D SInt) (Ann D (SFun (Ann D SInt) (Ann D SInt)))) ∷ Ann D SInt ∷ [])
(Ann D (SFun (Ann D SInt) (Ann D SInt)))
term3-3 = AApp S (wf-fun wf-int (wf-fun wf-int wf-int _ _) _ _) (AVar (tl hd)) (AVar hd)
term3-4 : AExp (Ann S (SFun (Ann D SInt) (Ann D (SFun (Ann D SInt) (Ann D SInt)))) ∷ Ann D SInt ∷ [])
(Ann D (SFun (Ann D SInt) (Ann D (SFun (Ann D SInt) (Ann D SInt)))))
term3-4 = ALam D (wf-fun wf-int (wf-fun wf-int wf-int _ _) _ _) term3-3
term3-5 : AExp (Ann D SInt ∷ [])
(Ann S (SFun (Ann S (SFun (Ann D SInt) (Ann D (SFun (Ann D SInt) (Ann D SInt)))))
(Ann D (SFun (Ann D SInt) (Ann D (SFun (Ann D SInt) (Ann D SInt)))))))
term3-5 = ALam S (wf-fun (wf-fun wf-int (wf-fun wf-int wf-int _ _) _ _) (wf-fun wf-int (wf-fun wf-int wf-int _ _) _ _) _ _) term3-4
term3-6 : AExp (Ann D SInt ∷ [])
(Ann D (SFun (Ann D SInt) (Ann D (SFun (Ann D SInt) (Ann D SInt)))))
term3-6 = AApp S (wf-fun (wf-fun wf-int (wf-fun wf-int wf-int _ _) _ _) (wf-fun wf-int (wf-fun wf-int wf-int _ _) _ _) _ _) term3-5 term3-2
term3 : AExp [] (Ann D (SFun (Ann D SInt) (Ann D (SFun (Ann D SInt) (Ann D (SFun (Ann D SInt) (Ann D SInt)))))))
term3 = ALam D (wf-fun wf-int (wf-fun wf-int (wf-fun wf-int wf-int _ _) _ _) _ _) term3-6
-- conclusion: you want type inference ...
-------------------------------------------------------------------------------
-- step 2
-- now let's do everything typed
data Type : Set where
Int : Type
Fun : Type → Type → Type
Ctx = List Type
data _↝_ : Ctx → Ctx → Set where
↝-refl : ∀ {Γ} → Γ ↝ Γ
↝-extend : ∀ {Γ Γ' τ} → Γ ↝ Γ' → Γ ↝ (τ ∷ Γ')
↝-≤ : ∀ Γ Γ' → Γ ↝ Γ' → length Γ ≤ length Γ'
↝-≤ .Γ' Γ' ↝-refl = ≤-refl
↝-≤ Γ .(τ ∷ Γ') (↝-extend {.Γ} {Γ'} {τ} Γ↝Γ') = ≤-suc-right (↝-≤ Γ Γ' Γ↝Γ')
↝-no-left : ∀ Γ τ → ¬ (τ ∷ Γ) ↝ Γ
↝-no-left Γ τ p = 1+n≰n (↝-≤ (τ ∷ Γ) Γ p)
↝-trans : ∀ {Γ Γ' Γ''} → Γ ↝ Γ' → Γ' ↝ Γ'' → Γ ↝ Γ''
↝-trans Γ↝Γ' ↝-refl = Γ↝Γ'
↝-trans Γ↝Γ' (↝-extend Γ'↝Γ'') = ↝-extend (↝-trans Γ↝Γ' Γ'↝Γ'')
lem : ∀ x y xs xs' → (x ∷ xs) ↝ xs' → xs ↝ (y ∷ xs')
lem x y xs .(x ∷ xs) ↝-refl = ↝-extend (↝-extend ↝-refl)
lem x y xs .(x' ∷ xs') (↝-extend {.(x ∷ xs)} {xs'} {x'} p) = ↝-extend (lem x x' xs xs' p)
data _↝_↝_ : Ctx → Ctx → Ctx → Set where
↝↝-base : ∀ {Γ Γ''} → Γ ↝ Γ'' → Γ ↝ [] ↝ Γ''
↝↝-extend : ∀ {Γ Γ' Γ'' τ} → Γ ↝ Γ' ↝ Γ'' → (τ ∷ Γ) ↝ (τ ∷ Γ') ↝ (τ ∷ Γ'')
-- Typed residula expressions
data Exp'' (Γ : Ctx) : Type → Set where
EVar : ∀ {τ} → τ ∈ Γ → Exp'' Γ τ
EInt : ℕ → Exp'' Γ Int
EAdd : Exp'' Γ Int → Exp'' Γ Int -> Exp'' Γ Int
ELam : ∀ {τ τ'} → Exp'' (τ ∷ Γ) τ' → Exp'' Γ (Fun τ τ')
EApp : ∀ {τ τ'} → Exp'' Γ (Fun τ τ') → Exp'' Γ τ → Exp'' Γ τ'
-- erase annotations
erase : AType → Type
erase (Ann x SInt) = Int
erase (Ann x (SFun x₁ x₂)) = Fun (erase x₁) (erase x₂)
-- index Γ = nesting level of dynamic definitions / dynamic environment
Imp'' : Ctx → AType → Set
Imp'' Γ (Ann S SInt) = ℕ
Imp'' Γ (Ann S (SFun α₁ α₂)) = ∀ Γ' → Γ ↝ Γ' → (Imp'' Γ' α₁ → Imp'' Γ' α₂)
Imp'' Γ (Ann D σ) = Exp'' Γ (erase (Ann D σ))
-- index = nesting level of dynamic definitions
data AEnv2 : Ctx → ACtx → Set where
[] : AEnv2 [] []
consS : ∀ {Γ Δ Γ'} → Γ ↝ Γ' → (α : AType) → Imp'' Γ' α → AEnv2 Γ Δ → AEnv2 Γ' (α ∷ Δ)
consD : ∀ {Γ Δ} → (α : AType) → isTrue (D ≼ btof α) → Imp'' (erase α ∷ Γ) α → AEnv2 Γ Δ → AEnv2 (erase α ∷ Γ) (α ∷ Δ)
elevate-var : ∀ {Γ Γ' τ} → Γ ↝ Γ' → τ ∈ Γ → τ ∈ Γ'
elevate-var ↝-refl x = x
elevate-var (↝-extend Γ↝Γ') x = tl (elevate-var Γ↝Γ' x)
elevate-var2 : ∀ {Γ Γ' Γ'' τ} → Γ ↝ Γ' ↝ Γ'' → τ ∈ Γ → τ ∈ Γ''
elevate-var2 (↝↝-base x) x₁ = elevate-var x x₁
elevate-var2 (↝↝-extend Γ↝Γ'↝Γ'') hd = hd
elevate-var2 (↝↝-extend Γ↝Γ'↝Γ'') (tl x) = tl (elevate-var2 Γ↝Γ'↝Γ'' x)
elevate : ∀ {Γ Γ' Γ'' τ} → Γ ↝ Γ' ↝ Γ'' → Exp'' Γ τ → Exp'' Γ'' τ
elevate Γ↝Γ'↝Γ'' (EVar x) = EVar (elevate-var2 Γ↝Γ'↝Γ'' x)
elevate Γ↝Γ'↝Γ'' (EInt x) = EInt x
elevate Γ↝Γ'↝Γ'' (EAdd e e₁) = EAdd (elevate Γ↝Γ'↝Γ'' e) (elevate Γ↝Γ'↝Γ'' e₁)
elevate Γ↝Γ'↝Γ'' (ELam e) = ELam (elevate (↝↝-extend Γ↝Γ'↝Γ'') e)
elevate Γ↝Γ'↝Γ'' (EApp e e₁) = EApp (elevate Γ↝Γ'↝Γ'' e) (elevate Γ↝Γ'↝Γ'' e₁)
lift2 : ∀ {Γ Γ'} α → Γ ↝ Γ' → Imp'' Γ α → Imp'' Γ' α
lift2 (Ann S SInt) p v = v
lift2 (Ann S (SFun x x₁)) Γ↝Γ' v = λ Γ'' Γ'↝Γ'' → v Γ'' (↝-trans Γ↝Γ' Γ'↝Γ'')
lift2 (Ann D x₁) Γ↝Γ' v = elevate (↝↝-base Γ↝Γ') v
lookup2 : ∀ {α Δ Γ Γ'} → Γ ↝ Γ' → AEnv2 Γ Δ → α ∈ Δ → Imp'' Γ' α
lookup2 Γ↝Γ' (consS p α v env) hd = lift2 α Γ↝Γ' v
lookup2 Γ↝Γ' (consS p α₁ v env) (tl x) = lookup2 (↝-trans p Γ↝Γ') env x
lookup2 Γ↝Γ' (consD α D≼α v env) hd = lift2 α Γ↝Γ' v
lookup2 ↝-refl (consD α₁ D≼α v env) (tl x) = lookup2 (↝-extend ↝-refl) env x
lookup2 (↝-extend Γ↝Γ') (consD α₁ D≼α v env) (tl x) = lookup2 (lem (erase α₁) _ _ _ Γ↝Γ') env x
pe2 : ∀ {α Δ} Γ → AExp Δ α → AEnv2 Γ Δ → Imp'' Γ α
pe2 Γ (AVar x) env = lookup2 ↝-refl env x
pe2 Γ (AInt S x) env = x
pe2 Γ (AInt D x) env = EInt x
pe2 Γ (AAdd S e₁ e₂) env = pe2 Γ e₁ env + pe2 Γ e₂ env
pe2 Γ (AAdd D e₁ e₂) env = EAdd (pe2 Γ e₁ env) (pe2 Γ e₂ env)
pe2 {Ann S (SFun α₂ α₁)} Γ (ALam .S w e) env = λ Γ' Γ↝Γ' → λ y → pe2 {α₁} Γ' e (consS Γ↝Γ' α₂ y env)
pe2 Γ (ALam {α₂} {α₁} D (wf-fun w₁ w₂ d≤bt₁ d≤bt₂) e) env
with lem-IsDynamic-by-wf α₁ d≤bt₁ | lem-IsDynamic-by-wf α₂ d≤bt₂
pe2 Γ (ALam {.(Ann D σ₂)} {.(Ann D σ₁)} D (wf-fun _ _ d≤bt₁ d≤bt₂) e) env
| is-dyn σ₁ | is-dyn σ₂ = ELam (pe2 (erase (Ann D σ₁) ∷ Γ) e (consD (Ann D σ₁) d≤bt₁ (EVar hd) env))
pe2 Γ (AApp S w e₁ e₂) env = pe2 Γ e₁ env Γ ↝-refl (pe2 Γ e₂ env)
pe2 Γ (AApp {α₂} {α₁} D (wf-fun w₁ w₂ d≤bt₁ d≤bt₂) e e₁) env
with lem-IsDynamic-by-wf α₁ d≤bt₁ | lem-IsDynamic-by-wf α₂ d≤bt₂
pe2 Γ (AApp {.(Ann D σ₂)} {.(Ann D σ₁)} D (wf-fun w₁ w₂ d≤bt₁ d≤bt₂) e e₁) env
| is-dyn σ₁ | is-dyn σ₂ = EApp (pe2 Γ e env) (pe2 Γ e₁ env)
pe2-term1 = pe2 [] term1 []
pe2-term2 = pe2 [] term2 []
pe2-term3 = pe2 [] term3 []
|
{
"alphanum_fraction": 0.5639839034,
"avg_line_length": 37.2983114447,
"ext": "agda",
"hexsha": "a5ba0a430d87cf4944f4af3fdcfc53109e506688",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-10-15T09:01:37.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-10-15T09:01:37.000Z",
"max_forks_repo_head_hexsha": "ef878f7fa5afa51fb7a14cd8f7f75da0af1b9deb",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "luminousfennell/polybta",
"max_forks_repo_path": "BTA4.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ef878f7fa5afa51fb7a14cd8f7f75da0af1b9deb",
"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": "luminousfennell/polybta",
"max_issues_repo_path": "BTA4.agda",
"max_line_length": 139,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "ef878f7fa5afa51fb7a14cd8f7f75da0af1b9deb",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "luminousfennell/polybta",
"max_stars_repo_path": "BTA4.agda",
"max_stars_repo_stars_event_max_datetime": "2019-10-15T04:35:29.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-10-15T04:35:29.000Z",
"num_tokens": 9150,
"size": 19880
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Some defined operations (multiplication by natural number and
-- exponentiation)
------------------------------------------------------------------------
open import Algebra
module Algebra.Operations {s₁ s₂} (S : Semiring s₁ s₂) where
open Semiring S renaming (zero to *-zero)
open import Data.Nat
using (zero; suc; ℕ) renaming (_+_ to _ℕ+_; _*_ to _ℕ*_)
open import Data.Product using (module Σ)
open import Function
open import Relation.Binary
open import Relation.Binary.PropositionalEquality as PropEq using (_≡_)
import Relation.Binary.EqReasoning as EqR
open EqR setoid
------------------------------------------------------------------------
-- Operations
-- Multiplication by natural number.
infixr 7 _×_
_×_ : ℕ → Carrier → Carrier
0 × x = 0#
suc n × x = x + n × x
-- A variant that includes a "redundant" case which ensures that 1 × y
-- is definitionally equal to y.
_×′_ : ℕ → Carrier → Carrier
0 ×′ x = 0#
1 ×′ x = x
suc n ×′ x = x + n ×′ x
-- Exponentiation.
infixr 8 _^_
_^_ : Carrier → ℕ → Carrier
x ^ zero = 1#
x ^ suc n = x * x ^ n
------------------------------------------------------------------------
-- Some properties
-- Unfolding lemma for _×′_.
1+×′ : ∀ n x → suc n ×′ x ≈ x + n ×′ x
1+×′ 0 x = begin
x ≈⟨ sym $ Σ.proj₂ +-identity x ⟩
x + 0# ∎
1+×′ (suc n) x = begin
x + suc n ×′ x ≡⟨⟩
x + suc n ×′ x ∎
-- _×_ and _×′_ are extensionally equal (up to the setoid
-- equivalence).
×≈×′ : ∀ n x → n × x ≈ n ×′ x
×≈×′ 0 x = begin 0# ∎
×≈×′ (suc n) x = begin
x + n × x ≈⟨ +-cong refl (×≈×′ n x) ⟩
x + n ×′ x ≈⟨ sym $ 1+×′ n x ⟩
suc n ×′ x ∎
-- _×_ is homomorphic with respect to _ℕ+_/_+_.
×-homo-+ : ∀ c m n → (m ℕ+ n) × c ≈ m × c + n × c
×-homo-+ c 0 n = begin
n × c ≈⟨ sym $ Σ.proj₁ +-identity (n × c) ⟩
0# + n × c ∎
×-homo-+ c (suc m) n = begin
c + (m ℕ+ n) × c ≈⟨ +-cong refl (×-homo-+ c m n) ⟩
c + (m × c + n × c) ≈⟨ sym $ +-assoc c (m × c) (n × c) ⟩
c + m × c + n × c ∎
-- _×′_ is homomorphic with respect to _ℕ+_/_+_.
×′-homo-+ : ∀ c m n → (m ℕ+ n) ×′ c ≈ m ×′ c + n ×′ c
×′-homo-+ c m n = begin
(m ℕ+ n) ×′ c ≈⟨ sym $ ×≈×′ (m ℕ+ n) c ⟩
(m ℕ+ n) × c ≈⟨ ×-homo-+ c m n ⟩
m × c + n × c ≈⟨ +-cong (×≈×′ m c) (×≈×′ n c) ⟩
m ×′ c + n ×′ c ∎
-- _× 1# is homomorphic with respect to _ℕ*_/_*_.
×1-homo-* : ∀ m n → (m ℕ* n) × 1# ≈ (m × 1#) * (n × 1#)
×1-homo-* 0 n = begin
0# ≈⟨ sym $ Σ.proj₁ *-zero (n × 1#) ⟩
0# * (n × 1#) ∎
×1-homo-* (suc m) n = begin
(n ℕ+ m ℕ* n) × 1# ≈⟨ ×-homo-+ 1# n (m ℕ* n) ⟩
n × 1# + (m ℕ* n) × 1# ≈⟨ +-cong refl (×1-homo-* m n) ⟩
n × 1# + (m × 1#) * (n × 1#) ≈⟨ sym $ +-cong (Σ.proj₁ *-identity (n × 1#)) refl ⟩
1# * (n × 1#) + (m × 1#) * (n × 1#) ≈⟨ sym $ Σ.proj₂ distrib (n × 1#) 1# (m × 1#) ⟩
(1# + m × 1#) * (n × 1#) ∎
-- _×′ 1# is homomorphic with respect to _ℕ*_/_*_.
×′1-homo-* : ∀ m n → (m ℕ* n) ×′ 1# ≈ (m ×′ 1#) * (n ×′ 1#)
×′1-homo-* m n = begin
(m ℕ* n) ×′ 1# ≈⟨ sym $ ×≈×′ (m ℕ* n) 1# ⟩
(m ℕ* n) × 1# ≈⟨ ×1-homo-* m n ⟩
(m × 1#) * (n × 1#) ≈⟨ *-cong (×≈×′ m 1#) (×≈×′ n 1#) ⟩
(m ×′ 1#) * (n ×′ 1#) ∎
-- _×_ preserves equality.
×-cong : _×_ Preserves₂ _≡_ ⟶ _≈_ ⟶ _≈_
×-cong {n} {n′} {x} {x′} n≡n′ x≈x′ = begin
n × x ≈⟨ reflexive $ PropEq.cong (λ n → n × x) n≡n′ ⟩
n′ × x ≈⟨ ×-congʳ n′ x≈x′ ⟩
n′ × x′ ∎
where
×-congʳ : ∀ n → (_×_ n) Preserves _≈_ ⟶ _≈_
×-congʳ 0 x≈x′ = refl
×-congʳ (suc n) x≈x′ = x≈x′ ⟨ +-cong ⟩ ×-congʳ n x≈x′
-- _×′_ preserves equality.
×′-cong : _×′_ Preserves₂ _≡_ ⟶ _≈_ ⟶ _≈_
×′-cong {n} {n′} {x} {x′} n≡n′ x≈x′ = begin
n ×′ x ≈⟨ sym $ ×≈×′ n x ⟩
n × x ≈⟨ ×-cong n≡n′ x≈x′ ⟩
n′ × x′ ≈⟨ ×≈×′ n′ x′ ⟩
n′ ×′ x′ ∎
-- _^_ preserves equality.
^-cong : _^_ Preserves₂ _≈_ ⟶ _≡_ ⟶ _≈_
^-cong {x} {x'} {n} {n'} x≈x' n≡n' = begin
x ^ n ≈⟨ reflexive $ PropEq.cong (_^_ x) n≡n' ⟩
x ^ n' ≈⟨ ^-congˡ n' x≈x' ⟩
x' ^ n' ∎
where
^-congˡ : ∀ n → (λ x → x ^ n) Preserves _≈_ ⟶ _≈_
^-congˡ zero x≈x' = refl
^-congˡ (suc n) x≈x' = x≈x' ⟨ *-cong ⟩ ^-congˡ n x≈x'
|
{
"alphanum_fraction": 0.4242137621,
"avg_line_length": 28.9657534247,
"ext": "agda",
"hexsha": "4534d8a2650e7b48f8396ad93da0ffb28bb0af00",
"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/Algebra/Operations.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/Algebra/Operations.agda",
"max_line_length": 91,
"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/Algebra/Operations.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": 2086,
"size": 4229
}
|
module New.Types where
open import Data.Integer public
open import Data.Product public hiding (map)
open import Data.Sum public hiding (map)
infixr 5 _⇒_
data Type : Set where
_⇒_ : (σ τ : Type) → Type
int : Type
pair : (σ τ : Type) → Type
sum : (σ τ : Type) → Type
⟦_⟧Type : Type → Set
⟦ σ ⇒ τ ⟧Type = ⟦ σ ⟧Type → ⟦ τ ⟧Type
⟦ int ⟧Type = ℤ
⟦ pair σ τ ⟧Type = ⟦ σ ⟧Type × ⟦ τ ⟧Type
⟦ sum σ τ ⟧Type = ⟦ σ ⟧Type ⊎ ⟦ τ ⟧Type
Δt : Type → Type
Δt (σ ⇒ τ) = σ ⇒ Δt σ ⇒ Δt τ
Δt int = int
Δt (pair σ τ) = pair (Δt σ) (Δt τ)
Δt (sum σ τ) = sum (sum (Δt σ) (Δt τ)) (sum σ τ)
|
{
"alphanum_fraction": 0.5736568458,
"avg_line_length": 23.08,
"ext": "agda",
"hexsha": "f57c7d3561ecd60935fdae1e178ef208fc5e0424",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z",
"max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "inc-lc/ilc-agda",
"max_forks_repo_path": "New/Types.agda",
"max_issues_count": 6,
"max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "inc-lc/ilc-agda",
"max_issues_repo_path": "New/Types.agda",
"max_line_length": 48,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "inc-lc/ilc-agda",
"max_stars_repo_path": "New/Types.agda",
"max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z",
"num_tokens": 266,
"size": 577
}
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Algebra.RingSolver.CommRingAsAlmostRing where
open import Cubical.Foundations.Prelude
open import Cubical.Algebra.CommRing.Base
open import Cubical.Algebra.RingSolver.AlmostRing
open import Cubical.Algebra.Semigroup
open import Cubical.Algebra.Monoid
open import Cubical.Algebra.Group
open import Cubical.Algebra.AbGroup
open import Cubical.Algebra.Ring.Base
open import Cubical.Algebra.Ring.Properties
private
variable
ℓ : Level
open Cubical.Algebra.Ring.Properties.Theory
CommRingAsAlmostRing : CommRing {ℓ} → AlmostRing {ℓ}
CommRingAsAlmostRing {ℓ}
(R , commringstr _ _ _ _ _
(iscommring (isring
(isabgroup (isgroup +-isMonoid inverse) +-comm)
·-isMonoid dist)
·-comm)) =
let
R' : CommRing {ℓ}
R' = (R , commringstr _ _ _ _ _
(iscommring (isring
(isabgroup (isgroup +-isMonoid inverse) +-comm) ·-isMonoid dist)
·-comm))
R″ = CommRing→Ring R'
in almostring R _ _ _ _ _
(isalmostring
+-isMonoid
·-isMonoid
+-comm
·-comm
(λ x y z → fst (dist x y z))
(λ x y z → snd (dist x y z))
(λ x y → sym (-DistL· R″ x y))
(λ x y → sym (-Dist R″ x y))
(λ x → 0LeftAnnihilates R″ x)
λ x → 0RightAnnihilates R″ x)
|
{
"alphanum_fraction": 0.6156048676,
"avg_line_length": 30.3695652174,
"ext": "agda",
"hexsha": "c52b84974801e4eae67c81248c6d9796c6b28e5d",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dan-iel-lee/cubical",
"max_forks_repo_path": "Cubical/Algebra/RingSolver/CommRingAsAlmostRing.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "dan-iel-lee/cubical",
"max_issues_repo_path": "Cubical/Algebra/RingSolver/CommRingAsAlmostRing.agda",
"max_line_length": 87,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "dan-iel-lee/cubical",
"max_stars_repo_path": "Cubical/Algebra/RingSolver/CommRingAsAlmostRing.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 423,
"size": 1397
}
|
{-# OPTIONS --cubical --safe #-}
module Yamanote where
open import Data.Fin
open import Data.List using (List; map) renaming (_∷_ to _L∷_; _++_ to _L++_; [] to L[])
open import Data.Maybe using (fromMaybe)
open import Data.Nat
open import Data.Product using (_×_; _,_; proj₁; proj₂)
open import Function using (_∘_)
open import Data.Vec using (Vec; []; _∷_; zip; toList) renaming (map to vmap)
open import Relation.Binary.PropositionalEquality using (refl)
open import Counterpoint
open import Note
open import Music
open import MidiEvent
open import Pitch
open import Interval
-- open import ScaleDegree
open import Util
-- Yamanoto melody transposed down an octave and with an additional d6 at the end.
cantusFirmus : Vec Pitch 40
cantusFirmus =
g 4 ∷ a 4 ∷ g 4 ∷ c 5 ∷ g 4 ∷ e 5 ∷ g 4 ∷
g 5 ∷ g 4 ∷ a 4 ∷ g 4 ∷ c 5 ∷ g 4 ∷ e 5 ∷ g 4 ∷
g 5 ∷ g 4 ∷ a 4 ∷ g 4 ∷ b 4 ∷ g 4 ∷ d 5 ∷ g 4 ∷
g 5 ∷ g 4 ∷ a 4 ∷ g 4 ∷ b 4 ∷ g 4 ∷ d 5 ∷ g 4 ∷
g 4 ∷ e 4 ∷ g 4 ∷ c 5 ∷ c 5 ∷ c 5 ∷ e 5 ∷ g 5 ∷
d 6 ∷ []
-- Counterpoint (composed on Aug 2, 2019)
counterpoint : Vec Upi 40
counterpoint =
maj6 ∷ min6 ∷ per8 ∷ maj3 ∷ per8 ∷ min3 ∷ maj6 ∷
maj6 ∷ maj6 ∷ min3 ∷ per5 ∷ maj3 ∷ maj6 ∷ min3 ∷ per8 ∷
maj3 ∷ maj10 ∷ per8 ∷ maj10 ∷ min6 ∷ per8 ∷ maj6 ∷ maj10 ∷
maj3 ∷ maj3 ∷ min3 ∷ per5 ∷ min6 ∷ maj6 ∷ min3 ∷ per8 ∷
maj6 ∷ min10 ∷ per8 ∷ maj10 ∷ per8 ∷ maj10 ∷ min10 ∷ per8 ∷
maj6 ∷ []
-- Counterpoint (composed on March 18, 2019)
counterpoint0 : Vec Upi 40
counterpoint0 =
maj6 ∷ min6 ∷ per8 ∷ maj3 ∷ per8 ∷ min3 ∷ maj6 ∷
maj6 ∷ maj6 ∷ min3 ∷ per5 ∷ maj3 ∷ maj6 ∷ min3 ∷ per8 ∷
maj3 ∷ maj10 ∷ per8 ∷ maj10 ∷ min6 ∷ per8 ∷ maj6 ∷ maj10 ∷
maj3 ∷ maj10 ∷ min6 ∷ per8 ∷ min3 ∷ per8 ∷ min3 ∷ per8 ∷
maj6 ∷ min10 ∷ per8 ∷ maj10 ∷ per8 ∷ maj10 ∷ min10 ∷ per8 ∷
maj6 ∷ []
yamanote-cfcp : Vec PitchInterval 40
yamanote-cfcp = zip cantusFirmus counterpoint
fs : FirstSpecies
fs = firstSpecies (g 5 , per8) (toList yamanote-cfcp) (c 6 , per8) refl refl refl refl
yamanote counterp : List Note
yamanote =
tone 8th (g 5) L∷
map (tone 8th ∘ proj₁ ∘ pitchIntervalToPitchPair) (FirstSpecies.middleBars fs) L++
tone 8th (g 5) L∷
L[]
counterp =
tone 8th (g 6) L∷
map (tone 8th ∘ proj₂ ∘ pitchIntervalToPitchPair) (FirstSpecies.middleBars fs) L++
tone 8th (c 7) L∷
L[]
----
piano marimba : InstrumentNumber-1
piano = # 0
marimba = # 12
channel1 channel2 : Channel-1
channel1 = # 0
channel2 = # 1
tempo : ℕ
tempo = 120
yVelocity cVelocity : Velocity
yVelocity = # 60
cVelocity = # 30
yamanoteTrack : MidiTrack
yamanoteTrack = track "Cantus Firmus" piano channel1 tempo (notes→events yVelocity yamanote)
cpTrack : MidiTrack
cpTrack = track "Counterpoint" marimba channel2 tempo (notes→events cVelocity counterp)
ycpTracks : List MidiTrack
ycpTracks = cpTrack L∷ yamanoteTrack L∷ L[]
|
{
"alphanum_fraction": 0.6520056298,
"avg_line_length": 28.7070707071,
"ext": "agda",
"hexsha": "fc013d1c67b2987cf91ff322999f619ccb1617a4",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2020-11-10T04:04:40.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-01-12T17:02:36.000Z",
"max_forks_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "halfaya/MusicTools",
"max_forks_repo_path": "agda/Yamanote.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021",
"max_issues_repo_issues_event_max_datetime": "2020-11-17T00:58:55.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-11-13T01:26:20.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "halfaya/MusicTools",
"max_issues_repo_path": "agda/Yamanote.agda",
"max_line_length": 92,
"max_stars_count": 28,
"max_stars_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "halfaya/MusicTools",
"max_stars_repo_path": "agda/Yamanote.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-04T18:04:07.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-04-21T09:08:52.000Z",
"num_tokens": 1198,
"size": 2842
}
|
module Examples.InfiniteBind where
open import ActorMonad
open import Prelude
Box : InboxShape
Box = []
binder : ∀ {i} → ∞ActorM i Box ⊤₁ [] (λ _ → [])
binder .force = binder ∞>> binder
|
{
"alphanum_fraction": 0.6684210526,
"avg_line_length": 15.8333333333,
"ext": "agda",
"hexsha": "53b32b23a1dc2bd56d50a91be0ba414b4d30fd51",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "ae541df13d069df4eb1464f29fbaa9804aad439f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Zalastax/singly-typed-actors",
"max_forks_repo_path": "src/Examples/InfiniteBind.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ae541df13d069df4eb1464f29fbaa9804aad439f",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Zalastax/singly-typed-actors",
"max_issues_repo_path": "src/Examples/InfiniteBind.agda",
"max_line_length": 47,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "ae541df13d069df4eb1464f29fbaa9804aad439f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Zalastax/thesis",
"max_stars_repo_path": "src/Examples/InfiniteBind.agda",
"max_stars_repo_stars_event_max_datetime": "2018-02-02T16:44:43.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-02-02T16:44:43.000Z",
"num_tokens": 58,
"size": 190
}
|
{-# OPTIONS --cubical #-}
module Miscellaneous.LimNatural where
import Lvl
open import Numeral.Natural as ℕ using (ℕ)
open import Numeral.Sign as Sign using (−|+ ; −|0|+ ; ➖ ; ➕)
open import Type.Cubical
open import Type.Cubical.Path.Equality
open import Type
data ℕ∞ : Type{Lvl.𝟎} where
𝟎 : ℕ∞
𝐒 : ℕ∞ → ℕ∞
∞ : ℕ∞
𝐒-fixpoint : (𝐒(∞) ≡ ∞)
𝐏₀ : ℕ∞ → ℕ∞
𝐏₀(𝟎) = 𝟎
𝐏₀(𝐒(n)) = n
𝐏₀(∞) = ∞
𝐏₀(𝐒-fixpoint i) = ∞
_+_ : ℕ∞ → ℕ∞ → ℕ∞
x + 𝟎 = x
x + 𝐒(y) = 𝐒(x + y)
_ + ∞ = ∞
x + 𝐒-fixpoint i = 𝐒-fixpoint i
_⋅_ : ℕ∞ → ℕ∞ → ℕ∞
x ⋅ 𝟎 = 𝟎
x ⋅ 𝐒(y) = x + (x ⋅ y)
x ⋅ ∞ = ∞
x ⋅ 𝐒-fixpoint i = ∞
infixl 10010 _+_
infixl 10020 _⋅_
open import Structure.Function.Domain
open import Structure.Function
open import Structure.Relator.Properties
open import Syntax.Transitivity
open import Type.Cubical.Path.Proofs
private variable x y z : ℕ∞
𝐒-∞-involutive : (𝐒(𝐒(∞)) ≡ ∞)
𝐒-∞-involutive = congruence₁(𝐒) 𝐒-fixpoint 🝖 𝐒-fixpoint
instance
𝐒-injectivity : Injective(𝐒)
Injective.proof 𝐒-injectivity = congruence₁(𝐏₀)
[+]-baseₗ : (𝟎 + x ≡ x)
[+]-baseₗ {𝟎} = reflexivity(_≡_)
[+]-baseₗ {𝐒 x} = congruence₁(𝐒) ([+]-baseₗ {x})
[+]-baseₗ {∞} = reflexivity(_≡_)
[+]-baseₗ {𝐒-fixpoint i} = reflexivity(_≡_) {𝐒-fixpoint i}
[+]-stepₗ : (𝐒(x) + y ≡ 𝐒(x + y))
[+]-stepₗ {x} {𝟎} = reflexivity(_≡_)
[+]-stepₗ {x} {𝐒 y} = congruence₁(𝐒) ([+]-stepₗ {x}{y})
[+]-stepₗ {x} {∞} = symmetry(_≡_) 𝐒-fixpoint
[+]-stepₗ {x} {𝐒-fixpoint i} = symmetry(_≡_) (Interval.hComp diagram {!!}) where
diagram : Interval → Interval.Partial(Interval.farBound i) _
diagram _ (i = Interval.𝟎) = congruence₁(𝐒) 𝐒-fixpoint
diagram _ (i = Interval.𝟏) = 𝐒-fixpoint
{-
i0 j0 𝐒∞
i0 j1 𝐒𝐒∞
i1 j0 ∞
i1 j1 𝐒∞
-}
-- test : ∀{i} → (𝐒(𝐒-fixpoint i) ≡ 𝐒-fixpoint i)
-- test {i} j = {!!}
{-
i0 j0 𝐒𝐒∞
i0 j1 𝐒∞
i1 j0 𝐒∞
i1 j1 ∞
-}
|
{
"alphanum_fraction": 0.5772357724,
"avg_line_length": 22.5,
"ext": "agda",
"hexsha": "befb7040b2e19936786506ddf302670737d0af99",
"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": "Miscellaneous/LimNatural.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": "Miscellaneous/LimNatural.agda",
"max_line_length": 80,
"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": "Miscellaneous/LimNatural.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": 976,
"size": 1845
}
|
{-# OPTIONS --cubical #-}
open import Agda.Primitive.Cubical
open import Agda.Builtin.Cubical.Path
open import Agda.Builtin.Cubical.Id
reflPath : ∀ {ℓ} {A : Set ℓ} {x : A} → x ≡ x
reflPath {x = x} = λ i → x
reflId : ∀ {ℓ} {A : Set ℓ} {x : A} → Id x x
reflId {x = x} = conid i1 reflPath
Id-comp-Id : ∀ {ℓ ℓ'} {A : Set ℓ} {x : A} (P : ∀ y → Id x y → Set ℓ')
→ (b : P x reflId) → Id (primIdJ P b reflId) b
Id-comp-Id P b = reflId
Id-comp-Path : ∀ {ℓ ℓ'} {A : Set ℓ} {x : A} (P : ∀ y → Id x y → Set ℓ')
→ (b : P x reflId) → (primIdJ P b reflId) ≡ b
Id-comp-Path P b = λ i → b
|
{
"alphanum_fraction": 0.5274542429,
"avg_line_length": 30.05,
"ext": "agda",
"hexsha": "536d5371788803ef142ce61158ea4f5f2e82f106",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-04-01T18:30:09.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-04-01T18:30:09.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/Issue2846.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Succeed/Issue2846.agda",
"max_line_length": 71,
"max_stars_count": 2,
"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/Issue2846.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": 267,
"size": 601
}
|
module Issue246 where
module James where
data Nat : Set where
zero : Nat
suc : Nat -> Nat
data Zero : Set where
data One : Set where
void : One
propLEQ : Nat -> Nat -> Set
propLEQ zero _ = One
propLEQ (suc n) (suc m) = propLEQ n m
propLEQ (suc n) zero = Zero
data Fin : Nat -> Set where
fzero : {n : Nat} -> Fin (suc n)
fsuc : {n : Nat} -> Fin n -> Fin (suc n)
toFin : {n : Nat} -> (i : Nat) -> (propLEQ (suc i) n) -> Fin n
toFin {zero} zero ()
toFin {zero} (suc _) ()
toFin {suc n} zero k = fzero
toFin {suc n} (suc i) k = fsuc (toFin i k)
one : Nat
one = suc zero
two : Nat
two = suc one
three : Nat
three = suc two
null : Fin three
null = toFin zero void
module Conor where
data Nat : Set where
ze : Nat
su : Nat -> Nat
data Bool : Set where
tt ff : Bool
record One : Set where
data Zero : Set where
So : Bool -> Set
So tt = One
So ff = Zero
_<_ : Nat -> Nat -> Bool
_ < ze = ff
ze < su n = tt
su m < su n = m < n
data Lt (m n : Nat) : Set where
lt : So (m < n) -> Lt m n
boo : {m n : Nat} -> So (m < n) -> Lt (su m) (su n)
boo p = lt p
module Alan where
data ℕ : Set where
zero : ℕ
suc : ℕ → ℕ
{-# BUILTIN NATURAL ℕ #-}
{-# BUILTIN ZERO zero #-}
{-# BUILTIN SUC suc #-}
data Bool : Set where
true false : Bool
infixr 5 _∷_
_lt_ : ℕ → ℕ → Bool
_ lt zero = false
zero lt suc _ = true
suc x lt suc y = x lt y
data List<? (X : ℕ → Set) (n : ℕ) : Bool → Set where
[] : List<? X n true
_∷_ : {m : ℕ} → (x : X m) → (List<? X m true) → (List<? X n (m lt n))
List< : (ℕ → Set) → ℕ → Set
List< X n = List<? X n true
data A : ℕ → Set where
a1 : A 1
a2 : A 2
as : List< A 3
as = a2 ∷ a1 ∷ ([] {A})
as' : List< A 3
as' = a2 ∷ a1 ∷ []
|
{
"alphanum_fraction": 0.5026910657,
"avg_line_length": 17.8653846154,
"ext": "agda",
"hexsha": "a2b82f4e36a1bf31cbedcd99b1527e6a31a69ba6",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "np/agda-git-experiment",
"max_forks_repo_path": "test/succeed/Issue246.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "np/agda-git-experiment",
"max_issues_repo_path": "test/succeed/Issue246.agda",
"max_line_length": 73,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "test/succeed/Issue246.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": 736,
"size": 1858
}
|
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOT.FOTC.Data.Conat.PropertiesI where
open import FOTC.Base
open import FOTC.Data.Conat
open import FOTC.Data.Conat.PropertiesI
open import FOTC.Data.Nat
------------------------------------------------------------------------------
-- 25 April 2014, Failed with --without-K.
--
{-# TERMINATING #-}
Conat→N : ∀ {n} → Conat n → N n
Conat→N Cn with Conat-out Cn
... | inj₁ prf = subst N (sym prf) nzero
... | inj₂ (n' , refl , Cn') = nsucc (Conat→N Cn')
|
{
"alphanum_fraction": 0.5231481481,
"avg_line_length": 30.8571428571,
"ext": "agda",
"hexsha": "7569dc376ba03d7d446ffb8a8812cfa9ec5ecb50",
"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/Conat/PropertiesI.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/Conat/PropertiesI.agda",
"max_line_length": 78,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "notes/FOT/FOTC/Data/Conat/PropertiesI.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": 174,
"size": 648
}
|
{-# OPTIONS --warning=ignore #-}
module Issue2596 where
{-# REWRITE #-}
|
{
"alphanum_fraction": 0.6438356164,
"avg_line_length": 14.6,
"ext": "agda",
"hexsha": "d250d137430b4e25f22839499d192cdfe74076c2",
"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/Issue2596.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/Issue2596.agda",
"max_line_length": 32,
"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/Issue2596.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": 73
}
|
module Pi-.NoRepeat where
open import Data.Empty
open import Data.Unit
open import Data.Sum
open import Data.Product
open import Relation.Binary.Core
open import Relation.Binary
open import Relation.Nullary
open import Relation.Binary.PropositionalEquality
open import Data.Nat
open import Data.Nat.Properties
open import Data.List as L
open import Function using (_∘_)
open import Pi-.Syntax
open import Pi-.Opsem
open import Pi-.AuxLemmas
import RevNoRepeat
-- Forward deterministic
deterministic : ∀ {st st₁ st₂} → st ↦ st₁ → st ↦ st₂ → st₁ ≡ st₂
deterministic (↦⃗₁ {b = b₁}) (↦⃗₁ {b = b₂}) with base-is-prop _ b₁ b₂
... | refl = refl
deterministic ↦⃗₂ ↦⃗₂ = refl
deterministic ↦⃗₃ ↦⃗₃ = refl
deterministic ↦⃗₄ ↦⃗₄ = refl
deterministic ↦⃗₅ ↦⃗₅ = refl
deterministic ↦⃗₆ ↦⃗₆ = refl
deterministic ↦⃗₇ ↦⃗₇ = refl
deterministic ↦⃗₈ ↦⃗₈ = refl
deterministic ↦⃗₉ ↦⃗₉ = refl
deterministic ↦⃗₁₀ ↦⃗₁₀ = refl
deterministic ↦⃗₁₁ ↦⃗₁₁ = refl
deterministic ↦⃗₁₂ ↦⃗₁₂ = refl
deterministic {[ c ∣ _ ∣ κ ]◁} {⟨ _ ∣ v ∣ _ ⟩◁} {[ _ ∣ _ ∣ _ ]▷} ↦⃖₁ r with Lemma₅ r
... | refl , refl with Lemma₆ r
... | refl , refl with Lemma₇ r
... | refl with v
... | ()
deterministic {[ c ∣ _ ∣ _ ]◁} {⟨ _ ∣ v ∣ _ ⟩◁} {⟨ _ ∣ v' ∣ _ ⟩◁} ↦⃖₁ r with Lemma₁ r
... | refl , refl with Lemma₂ r
deterministic {[ unite₊l ∣ _ ∣ κ ]◁} {⟨ _ ∣ inj₂ y ∣ κ ⟩◁} {⟨ _ ∣ inj₂ y ∣ κ ⟩◁} ↦⃖₁ ↦⃖₁ | refl , refl | refl , refl = refl
deterministic {[ uniti₊l ∣ _ ∣ κ ]◁} {⟨ _ ∣ v ∣ κ ⟩◁} {⟨ _ ∣ v ∣ κ ⟩◁} ↦⃖₁ ↦⃖₁ | refl , refl | refl , refl = refl
deterministic {[ swap₊ ∣ _ ∣ κ ]◁} {⟨ _ ∣ inj₁ x ∣ κ ⟩◁} {⟨ _ ∣ inj₁ x ∣ κ ⟩◁} ↦⃖₁ ↦⃖₁ | refl , refl | refl , refl = refl
deterministic {[ swap₊ ∣ _ ∣ κ ]◁} {⟨ _ ∣ inj₂ y ∣ κ ⟩◁} {⟨ _ ∣ inj₂ y ∣ κ ⟩◁} ↦⃖₁ ↦⃖₁ | refl , refl | refl , refl = refl
deterministic {[ assocl₊ ∣ _ ∣ κ ]◁} {⟨ _ ∣ inj₁ x ∣ κ ⟩◁} {⟨ _ ∣ inj₁ x ∣ κ ⟩◁} ↦⃖₁ ↦⃖₁ | refl , refl | refl , refl = refl
deterministic {[ assocl₊ ∣ _ ∣ κ ]◁} {⟨ _ ∣ inj₁ x ∣ κ ⟩◁} {⟨ _ ∣ inj₂ (inj₁ y) ∣ κ ⟩◁} ↦⃖₁ (() ) | refl , refl | refl , refl
deterministic {[ assocl₊ ∣ _ ∣ κ ]◁} {⟨ _ ∣ inj₁ x ∣ κ ⟩◁} {⟨ _ ∣ inj₂ (inj₂ z) ∣ κ ⟩◁} ↦⃖₁ (() ) | refl , refl | refl , refl
deterministic {[ assocl₊ ∣ _ ∣ κ ]◁} {⟨ _ ∣ inj₂ (inj₁ y) ∣ κ ⟩◁} {⟨ _ ∣ inj₂ (inj₁ y) ∣ κ ⟩◁} ↦⃖₁ ↦⃖₁ | refl , refl | refl , refl = refl
deterministic {[ assocl₊ ∣ _ ∣ κ ]◁} {⟨ _ ∣ inj₂ (inj₂ z) ∣ κ ⟩◁} {⟨ _ ∣ inj₂ (inj₂ z) ∣ κ ⟩◁} ↦⃖₁ ↦⃖₁ | refl , refl | refl , refl = refl
deterministic {[ assocr₊ ∣ _ ∣ κ ]◁} {⟨ _ ∣ inj₁ (inj₁ x) ∣ κ ⟩◁} {⟨ _ ∣ inj₁ (inj₁ x) ∣ κ ⟩◁} ↦⃖₁ ↦⃖₁ | refl , refl | refl , refl = refl
deterministic {[ assocr₊ ∣ _ ∣ κ ]◁} {⟨ _ ∣ inj₁ (inj₂ y) ∣ κ ⟩◁} {⟨ _ ∣ inj₁ (inj₂ y) ∣ κ ⟩◁} ↦⃖₁ ↦⃖₁ | refl , refl | refl , refl = refl
deterministic {[ assocr₊ ∣ _ ∣ κ ]◁} {⟨ _ ∣ inj₂ z ∣ κ ⟩◁} {⟨ _ ∣ inj₁ (inj₁ x) ∣ κ ⟩◁} ↦⃖₁ (() ) | refl , refl | refl , refl
deterministic {[ assocr₊ ∣ _ ∣ κ ]◁} {⟨ _ ∣ inj₂ z ∣ κ ⟩◁} {⟨ _ ∣ inj₁ (inj₂ y) ∣ κ ⟩◁} ↦⃖₁ (() ) | refl , refl | refl , refl
deterministic {[ assocr₊ ∣ _ ∣ κ ]◁} {⟨ _ ∣ inj₂ z ∣ κ ⟩◁} {⟨ _ ∣ inj₂ z ∣ κ ⟩◁} ↦⃖₁ ↦⃖₁ | refl , refl | refl , refl = refl
deterministic {[ unite⋆l ∣ _ ∣ κ ]◁} {⟨ _ ∣ (tt , v) ∣ κ ⟩◁} {⟨ _ ∣ (tt , v) ∣ κ ⟩◁} ↦⃖₁ ↦⃖₁ | refl , refl | refl , refl = refl
deterministic {[ uniti⋆l ∣ _ ∣ κ ]◁} {⟨ _ ∣ v ∣ κ ⟩◁} {⟨ _ ∣ v ∣ κ ⟩◁} ↦⃖₁ ↦⃖₁ | refl , refl | refl , refl = refl
deterministic {[ swap⋆ ∣ _ ∣ κ ]◁} {⟨ _ ∣ (x , y) ∣ κ ⟩◁} {⟨ _ ∣ (x , y) ∣ κ ⟩◁} ↦⃖₁ ↦⃖₁ | refl , refl | refl , refl = refl
deterministic {[ assocl⋆ ∣ _ ∣ κ ]◁} {⟨ _ ∣ (x , (y , z)) ∣ κ ⟩◁} {⟨ _ ∣ (x , (y , z)) ∣ κ ⟩◁} ↦⃖₁ ↦⃖₁ | refl , refl | refl , refl = refl
deterministic {[ assocr⋆ ∣ _ ∣ κ ]◁} {⟨ _ ∣ ((x , y) , z) ∣ κ ⟩◁} {⟨ _ ∣ ((x , y) , z) ∣ κ ⟩◁} ↦⃖₁ ↦⃖₁ | refl , refl | refl , refl = refl
deterministic {[ dist ∣ _ ∣ κ ]◁} {⟨ _ ∣ (inj₁ x , z) ∣ κ ⟩◁} {⟨ _ ∣ (inj₁ x , z) ∣ κ ⟩◁} ↦⃖₁ ↦⃖₁ | refl , refl | refl , refl = refl
deterministic {[ dist ∣ _ ∣ κ ]◁} {⟨ _ ∣ (inj₂ y , z) ∣ κ ⟩◁} {⟨ _ ∣ (inj₂ y , z) ∣ κ ⟩◁} ↦⃖₁ ↦⃖₁ | refl , refl | refl , refl = refl
deterministic {[ factor ∣ _ ∣ κ ]◁} {⟨ _ ∣ inj₁ (x , z) ∣ κ ⟩◁} {⟨ _ ∣ inj₁ (x , z) ∣ κ ⟩◁} ↦⃖₁ ↦⃖₁ | refl , refl | refl , refl = refl
deterministic {[ factor ∣ _ ∣ κ ]◁} {⟨ _ ∣ inj₂ (y , z) ∣ κ ⟩◁} {⟨ _ ∣ inj₂ (y , z) ∣ κ ⟩◁} ↦⃖₁ ↦⃖₁ | refl , refl | refl , refl = refl
deterministic {[ unite₊l ∣ _ ∣ _ ]◁} {⟨ _ ∣ _ ∣ _ ⟩◁} {[ _ ∣ _ ∣ _ ]◁} ↦⃖₁ ()
deterministic {[ uniti₊l ∣ _ ∣ _ ]◁} {⟨ _ ∣ _ ∣ _ ⟩◁} {[ _ ∣ _ ∣ _ ]◁} ↦⃖₁ ()
deterministic {[ swap₊ ∣ _ ∣ _ ]◁} {⟨ _ ∣ _ ∣ _ ⟩◁} {[ _ ∣ _ ∣ _ ]◁} ↦⃖₁ ()
deterministic {[ assocl₊ ∣ _ ∣ _ ]◁} {⟨ _ ∣ _ ∣ _ ⟩◁} {[ _ ∣ _ ∣ _ ]◁} ↦⃖₁ ()
deterministic {[ assocr₊ ∣ _ ∣ _ ]◁} {⟨ _ ∣ _ ∣ _ ⟩◁} {[ _ ∣ _ ∣ _ ]◁} ↦⃖₁ ()
deterministic {[ unite⋆l ∣ _ ∣ _ ]◁} {⟨ _ ∣ _ ∣ _ ⟩◁} {[ _ ∣ _ ∣ _ ]◁} ↦⃖₁ ()
deterministic {[ uniti⋆l ∣ _ ∣ _ ]◁} {⟨ _ ∣ _ ∣ _ ⟩◁} {[ _ ∣ _ ∣ _ ]◁} ↦⃖₁ ()
deterministic {[ swap⋆ ∣ _ ∣ _ ]◁} {⟨ _ ∣ _ ∣ _ ⟩◁} {[ _ ∣ _ ∣ _ ]◁} ↦⃖₁ ()
deterministic {[ assocl⋆ ∣ _ ∣ _ ]◁} {⟨ _ ∣ _ ∣ _ ⟩◁} {[ _ ∣ _ ∣ _ ]◁} ↦⃖₁ ()
deterministic {[ assocr⋆ ∣ _ ∣ _ ]◁} {⟨ _ ∣ _ ∣ _ ⟩◁} {[ _ ∣ _ ∣ _ ]◁} ↦⃖₁ ()
deterministic {[ dist ∣ _ ∣ _ ]◁} {⟨ _ ∣ _ ∣ _ ⟩◁} {[ _ ∣ _ ∣ _ ]◁} ↦⃖₁ ()
deterministic {[ factor ∣ _ ∣ _ ]◁} {⟨ _ ∣ _ ∣ _ ⟩◁} {[ _ ∣ _ ∣ _ ]◁} ↦⃖₁ ()
deterministic {[ id↔ ∣ _ ∣ _ ]◁} {⟨ _ ∣ _ ∣ _ ⟩◁} {[ _ ∣ _ ∣ _ ]◁} (↦⃖₁ {b = ()})
deterministic {[ _ ⨾ _ ∣ _ ∣ _ ]◁} {⟨ _ ∣ _ ∣ _ ⟩◁} {[ _ ∣ _ ∣ _ ]◁} (↦⃖₁ {b = ()})
deterministic {[ _ ⊕ _ ∣ _ ∣ _ ]◁} {⟨ _ ∣ _ ∣ _ ⟩◁} {[ _ ∣ _ ∣ _ ]◁} (↦⃖₁ {b = ()})
deterministic {[ _ ⊗ _ ∣ _ ∣ _ ]◁} {⟨ _ ∣ _ ∣ _ ⟩◁} {[ _ ∣ _ ∣ _ ]◁} (↦⃖₁ {b = ()})
deterministic {[ η₊ ∣ _ ∣ _ ]◁} {⟨ _ ∣ _ ∣ _ ⟩◁} {[ _ ∣ _ ∣ _ ]◁} (↦⃖₁ {b = ()})
deterministic {[ ε₊ ∣ _ ∣ _ ]◁} {⟨ _ ∣ _ ∣ _ ⟩◁} {[ _ ∣ _ ∣ _ ]◁} (↦⃖₁ {b = ()})
deterministic ↦⃖₂ ↦⃖₂ = refl
deterministic ↦⃖₃ ↦⃖₃ = refl
deterministic ↦⃖₄ ↦⃖₄ = refl
deterministic ↦⃖₅ ↦⃖₅ = refl
deterministic ↦⃖₆ ↦⃖₆ = refl
deterministic ↦⃖₇ ↦⃖₇ = refl
deterministic ↦⃖₈ ↦⃖₈ = refl
deterministic ↦⃖₉ ↦⃖₉ = refl
deterministic ↦⃖₁₀ ↦⃖₁₀ = refl
deterministic {[ c₁ ⊕ c₂ ∣ inj₁ v ∣ κ ]◁} {[ c₁ ∣ v ∣ ☐⊕ c₂ • κ ]◁} {⟨ _ ∣ x ∣ _ ⟩◁} ↦⃖₁₁ r with Lemma₁ r
... | refl , refl with Lemma₂ r
... | refl , refl with Lemma₃ r
... | inj₂ refl with Lemma₄ r
... | inj₁ ()
... | inj₂ ()
deterministic {[ c₁ ⊕ c₂ ∣ _ ∣ _ ]◁} {[ _ ∣ _ ∣ _ ]◁} {[ _ ∣ _ ∣ _ ]◁} ↦⃖₁₁ ↦⃖₁₁ = refl
deterministic {[ c₁ ⊕ c₂ ∣ inj₂ v ∣ _ ]◁} {[ _ ∣ _ ∣ _ ]◁} {⟨ _ ∣ x ∣ _ ⟩◁} ↦⃖₁₂ r with Lemma₁ r
... | refl , refl with Lemma₂ r
... | refl , refl with Lemma₃ r
... | inj₂ refl with Lemma₄ r
... | inj₁ ()
... | inj₂ ()
deterministic {[ c₁ ⊕ c₂ ∣ _ ∣ _ ]◁} {[ _ ∣ _ ∣ _ ]◁} {[ _ ∣ _ ∣ _ ]◁} ↦⃖₁₂ ↦⃖₁₂ = refl
deterministic {[ η₊ ∣ inj₁ v ∣ _ ]◁} {[ η₊ ∣ _ ∣ _ ]▷} {[ _ ∣ _ ∣ _ ]▷} ↦η₁ ↦η₁ = refl
deterministic {[ η₊ ∣ inj₁ v ∣ _ ]◁} {[ η₊ ∣ _ ∣ _ ]▷} {⟨ η₊ ∣ v' ∣ _ ⟩◁} ↦η₁ r with Lemma₁ r
... | refl , refl with Lemma₂ r
... | refl , refl with v'
... | ()
deterministic {[ η₊ ∣ inj₂ (- v) ∣ _ ]◁} {[ η₊ ∣ _ ∣ _ ]▷} {[ _ ∣ _ ∣ _ ]▷} ↦η₂ ↦η₂ = refl
deterministic {[ η₊ ∣ inj₂ (- v) ∣ _ ]◁} {[ η₊ ∣ _ ∣ _ ]▷} {⟨ η₊ ∣ v' ∣ _ ⟩◁} ↦η₂ r with Lemma₁ r
... | refl , refl with Lemma₂ r
... | refl , refl with v'
... | ()
deterministic ↦ε₁ ↦ε₁ = refl
deterministic ↦ε₂ ↦ε₂ = refl
-- Backward deterministic
deterministicᵣₑᵥ : ∀ {st st₁ st₂} → st₁ ↦ st → st₂ ↦ st → st₁ ≡ st₂
deterministicᵣₑᵥ {[ c ∣ _ ∣ κ ]▷} {⟨ c ∣ v ∣ κ ⟩▷} {⟨ c' ∣ v' ∣ κ' ⟩▷} ↦⃗₁ r with Lemma₈ r
... | refl , refl with Lemma₉ r
deterministicᵣₑᵥ {[ unite₊l ∣ _ ∣ κ ]▷} {⟨ _ ∣ inj₂ y ∣ κ ⟩▷} {⟨ _ ∣ inj₂ y ∣ κ ⟩▷} ↦⃗₁ ↦⃗₁ | refl , refl | refl , refl = refl
deterministicᵣₑᵥ {[ uniti₊l ∣ _ ∣ κ ]▷} {⟨ _ ∣ v ∣ κ ⟩▷} {⟨ _ ∣ v ∣ κ ⟩▷} ↦⃗₁ ↦⃗₁ | refl , refl | refl , refl = refl
deterministicᵣₑᵥ {[ swap₊ ∣ _ ∣ κ ]▷} {⟨ _ ∣ inj₁ x ∣ κ ⟩▷} {⟨ _ ∣ inj₁ x ∣ κ ⟩▷} ↦⃗₁ ↦⃗₁ | refl , refl | refl , refl = refl
deterministicᵣₑᵥ {[ swap₊ ∣ _ ∣ κ ]▷} {⟨ _ ∣ inj₂ y ∣ κ ⟩▷} {⟨ _ ∣ inj₂ y ∣ κ ⟩▷} ↦⃗₁ ↦⃗₁ | refl , refl | refl , refl = refl
deterministicᵣₑᵥ {[ assocl₊ ∣ _ ∣ κ ]▷} {⟨ _ ∣ inj₁ x ∣ κ ⟩▷} {⟨ _ ∣ inj₁ x ∣ κ ⟩▷} ↦⃗₁ ↦⃗₁ | refl , refl | refl , refl = refl
deterministicᵣₑᵥ {[ assocl₊ ∣ _ ∣ κ ]▷} {⟨ _ ∣ inj₁ x ∣ κ ⟩▷} {⟨ _ ∣ inj₂ (inj₁ y) ∣ κ ⟩▷} ↦⃗₁ () | refl , refl | refl , refl
deterministicᵣₑᵥ {[ assocl₊ ∣ _ ∣ κ ]▷} {⟨ _ ∣ inj₁ x ∣ κ ⟩▷} {⟨ _ ∣ inj₂ (inj₂ z) ∣ κ ⟩▷} ↦⃗₁ () | refl , refl | refl , refl
deterministicᵣₑᵥ {[ assocl₊ ∣ _ ∣ κ ]▷} {⟨ _ ∣ inj₂ (inj₁ y) ∣ κ ⟩▷} {⟨ _ ∣ inj₂ (inj₁ y) ∣ κ ⟩▷} ↦⃗₁ ↦⃗₁ | refl , refl | refl , refl = refl
deterministicᵣₑᵥ {[ assocl₊ ∣ _ ∣ κ ]▷} {⟨ _ ∣ inj₂ (inj₂ z) ∣ κ ⟩▷} {⟨ _ ∣ inj₂ (inj₂ z) ∣ κ ⟩▷} ↦⃗₁ ↦⃗₁ | refl , refl | refl , refl = refl
deterministicᵣₑᵥ {[ assocr₊ ∣ _ ∣ κ ]▷} {⟨ _ ∣ inj₁ (inj₁ x) ∣ κ ⟩▷} {⟨ _ ∣ inj₁ (inj₁ x) ∣ κ ⟩▷} ↦⃗₁ ↦⃗₁ | refl , refl | refl , refl = refl
deterministicᵣₑᵥ {[ assocr₊ ∣ _ ∣ κ ]▷} {⟨ _ ∣ inj₁ (inj₂ y) ∣ κ ⟩▷} {⟨ _ ∣ inj₁ (inj₂ y) ∣ κ ⟩▷} ↦⃗₁ ↦⃗₁ | refl , refl | refl , refl = refl
deterministicᵣₑᵥ {[ assocr₊ ∣ _ ∣ κ ]▷} {⟨ _ ∣ inj₂ z ∣ κ ⟩▷} {⟨ _ ∣ inj₁ (inj₁ x) ∣ κ ⟩▷} ↦⃗₁ () | refl , refl | refl , refl
deterministicᵣₑᵥ {[ assocr₊ ∣ _ ∣ κ ]▷} {⟨ _ ∣ inj₂ z ∣ κ ⟩▷} {⟨ _ ∣ inj₁ (inj₂ y) ∣ κ ⟩▷} ↦⃗₁ () | refl , refl | refl , refl
deterministicᵣₑᵥ {[ assocr₊ ∣ _ ∣ κ ]▷} {⟨ _ ∣ inj₂ z ∣ κ ⟩▷} {⟨ _ ∣ inj₂ z ∣ κ ⟩▷} ↦⃗₁ ↦⃗₁ | refl , refl | refl , refl = refl
deterministicᵣₑᵥ {[ unite⋆l ∣ _ ∣ κ ]▷} {⟨ _ ∣ (tt , v) ∣ κ ⟩▷} {⟨ _ ∣ (tt , v) ∣ κ ⟩▷} ↦⃗₁ ↦⃗₁ | refl , refl | refl , refl = refl
deterministicᵣₑᵥ {[ uniti⋆l ∣ _ ∣ κ ]▷} {⟨ _ ∣ v ∣ κ ⟩▷} {⟨ _ ∣ v ∣ κ ⟩▷} ↦⃗₁ ↦⃗₁ | refl , refl | refl , refl = refl
deterministicᵣₑᵥ {[ swap⋆ ∣ _ ∣ κ ]▷} {⟨ _ ∣ (x , y) ∣ κ ⟩▷} {⟨ _ ∣ (x , y) ∣ κ ⟩▷} ↦⃗₁ ↦⃗₁ | refl , refl | refl , refl = refl
deterministicᵣₑᵥ {[ assocl⋆ ∣ _ ∣ κ ]▷} {⟨ _ ∣ (x , (y , z)) ∣ κ ⟩▷} {⟨ _ ∣ (x , (y , z)) ∣ κ ⟩▷} ↦⃗₁ ↦⃗₁ | refl , refl | refl , refl = refl
deterministicᵣₑᵥ {[ assocr⋆ ∣ _ ∣ κ ]▷} {⟨ _ ∣ ((x , y) , z) ∣ κ ⟩▷} {⟨ _ ∣ ((x , y) , z) ∣ κ ⟩▷} ↦⃗₁ ↦⃗₁ | refl , refl | refl , refl = refl
deterministicᵣₑᵥ {[ dist ∣ _ ∣ κ ]▷} {⟨ _ ∣ (inj₁ x , z) ∣ κ ⟩▷} {⟨ _ ∣ (inj₁ x , z) ∣ κ ⟩▷} ↦⃗₁ ↦⃗₁ | refl , refl | refl , refl = refl
deterministicᵣₑᵥ {[ dist ∣ _ ∣ κ ]▷} {⟨ _ ∣ (inj₂ y , z) ∣ κ ⟩▷} {⟨ _ ∣ (inj₂ y , z) ∣ κ ⟩▷} ↦⃗₁ ↦⃗₁ | refl , refl | refl , refl = refl
deterministicᵣₑᵥ {[ factor ∣ _ ∣ κ ]▷} {⟨ _ ∣ inj₁ (x , z) ∣ κ ⟩▷} {⟨ _ ∣ inj₁ (x , z) ∣ κ ⟩▷} ↦⃗₁ ↦⃗₁ | refl , refl | refl , refl = refl
deterministicᵣₑᵥ {[ factor ∣ _ ∣ κ ]▷} {⟨ _ ∣ inj₂ (y , z) ∣ κ ⟩▷} {⟨ _ ∣ inj₂ (y , z) ∣ κ ⟩▷} ↦⃗₁ ↦⃗₁ | refl , refl | refl , refl = refl
deterministicᵣₑᵥ {[ unite₊l ∣ _ ∣ κ ]▷} {⟨ _ ∣ v ∣ κ ⟩▷} {[ c' ∣ v' ∣ κ' ]▷} ↦⃗₁ ()
deterministicᵣₑᵥ {[ uniti₊l ∣ _ ∣ κ ]▷} {⟨ _ ∣ v ∣ κ ⟩▷} {[ c' ∣ v' ∣ κ' ]▷} ↦⃗₁ ()
deterministicᵣₑᵥ {[ swap₊ ∣ _ ∣ κ ]▷} {⟨ _ ∣ v ∣ κ ⟩▷} {[ c' ∣ v' ∣ κ' ]▷} ↦⃗₁ ()
deterministicᵣₑᵥ {[ assocl₊ ∣ _ ∣ κ ]▷} {⟨ _ ∣ v ∣ κ ⟩▷} {[ c' ∣ v' ∣ κ' ]▷} ↦⃗₁ ()
deterministicᵣₑᵥ {[ assocr₊ ∣ _ ∣ κ ]▷} {⟨ _ ∣ v ∣ κ ⟩▷} {[ c' ∣ v' ∣ κ' ]▷} ↦⃗₁ ()
deterministicᵣₑᵥ {[ unite⋆l ∣ _ ∣ κ ]▷} {⟨ _ ∣ v ∣ κ ⟩▷} {[ c' ∣ v' ∣ κ' ]▷} ↦⃗₁ ()
deterministicᵣₑᵥ {[ uniti⋆l ∣ _ ∣ κ ]▷} {⟨ _ ∣ v ∣ κ ⟩▷} {[ c' ∣ v' ∣ κ' ]▷} ↦⃗₁ ()
deterministicᵣₑᵥ {[ swap⋆ ∣ _ ∣ κ ]▷} {⟨ _ ∣ v ∣ κ ⟩▷} {[ c' ∣ v' ∣ κ' ]▷} ↦⃗₁ ()
deterministicᵣₑᵥ {[ assocl⋆ ∣ _ ∣ κ ]▷} {⟨ _ ∣ v ∣ κ ⟩▷} {[ c' ∣ v' ∣ κ' ]▷} ↦⃗₁ ()
deterministicᵣₑᵥ {[ assocr⋆ ∣ _ ∣ κ ]▷} {⟨ _ ∣ v ∣ κ ⟩▷} {[ c' ∣ v' ∣ κ' ]▷} ↦⃗₁ ()
deterministicᵣₑᵥ {[ dist ∣ _ ∣ κ ]▷} {⟨ _ ∣ v ∣ κ ⟩▷} {[ c' ∣ v' ∣ κ' ]▷} ↦⃗₁ ()
deterministicᵣₑᵥ {[ factor ∣ _ ∣ κ ]▷} {⟨ _ ∣ v ∣ κ ⟩▷} {[ c' ∣ v' ∣ κ' ]▷} ↦⃗₁ ()
deterministicᵣₑᵥ {[ id↔ ∣ _ ∣ κ ]▷} {⟨ _ ∣ v ∣ κ ⟩▷} {[ c' ∣ v' ∣ κ' ]▷} (↦⃗₁ {b = ()})
deterministicᵣₑᵥ {[ c₁ ⨾ c₂ ∣ _ ∣ κ ]▷} {⟨ _ ∣ v ∣ κ ⟩▷} {[ c' ∣ v' ∣ κ' ]▷} (↦⃗₁ {b = ()})
deterministicᵣₑᵥ {[ c₁ ⊕ c₂ ∣ _ ∣ κ ]▷} {⟨ _ ∣ v ∣ κ ⟩▷} {[ c' ∣ v' ∣ κ' ]▷} (↦⃗₁ {b = ()})
deterministicᵣₑᵥ {[ c₁ ⊗ c₂ ∣ _ ∣ κ ]▷} {⟨ _ ∣ v ∣ κ ⟩▷} {[ c' ∣ v' ∣ κ' ]▷} (↦⃗₁ {b = ()})
deterministicᵣₑᵥ {[ c ∣ _ ∣ κ ]▷} {⟨ c ∣ v ∣ κ ⟩▷} {[ _ ∣ _ ∣ _ ]◁} ↦⃗₁ r with Lemma₅ r
... | refl , refl with Lemma₆ r
... | refl , refl with Lemma₇ r
... | refl with v
... | ()
deterministicᵣₑᵥ ↦⃗₂ ↦⃗₂ = refl
deterministicᵣₑᵥ ↦⃗₃ ↦⃗₃ = refl
deterministicᵣₑᵥ ↦⃗₄ ↦⃗₄ = refl
deterministicᵣₑᵥ ↦⃗₅ ↦⃗₅ = refl
deterministicᵣₑᵥ ↦⃗₆ ↦⃗₆ = refl
deterministicᵣₑᵥ ↦⃗₇ ↦⃗₇ = refl
deterministicᵣₑᵥ ↦⃗₈ ↦⃗₈ = refl
deterministicᵣₑᵥ ↦⃗₉ ↦⃗₉ = refl
deterministicᵣₑᵥ ↦⃗₁₀ ↦⃗₁₀ = refl
deterministicᵣₑᵥ {[ c₁ ⊕ c₂ ∣ inj₁ v ∣ κ ]▷} {_} {⟨ _ ∣ _ ∣ _ ⟩▷} ↦⃗₁₁ r with Lemma₈ r
... | refl , refl with Lemma₉ r
... | refl , refl with Lemma₁₀ r
... | inj₂ refl with Lemma₁₁ r
... | inj₁ ()
... | inj₂ ()
deterministicᵣₑᵥ {[ c₁ ⊕ c₂ ∣ inj₁ v ∣ κ ]▷} {_} {[ _ ∣ _ ∣ _ ]▷} ↦⃗₁₁ ↦⃗₁₁ = refl
deterministicᵣₑᵥ {[ c₁ ⊕ c₂ ∣ inj₂ v ∣ κ ]▷} {_} {⟨ _ ∣ _ ∣ _ ⟩▷} ↦⃗₁₂ r with Lemma₈ r
... | refl , refl with Lemma₉ r
... | refl , refl with Lemma₁₀ r
... | inj₂ refl with Lemma₁₁ r
... | inj₁ ()
... | inj₂ ()
deterministicᵣₑᵥ {[ c₁ ⊕ c₂ ∣ inj₂ v ∣ κ ]▷} {_} {[ _ ∣ _ ∣ _ ]▷} ↦⃗₁₂ ↦⃗₁₂ = refl
deterministicᵣₑᵥ (↦⃖₁ {b = b₁}) (↦⃖₁ {b = b₂}) with base-is-prop _ b₁ b₂
... | refl = refl
deterministicᵣₑᵥ ↦⃖₂ ↦⃖₂ = refl
deterministicᵣₑᵥ ↦⃖₃ ↦⃖₃ = refl
deterministicᵣₑᵥ ↦⃖₄ ↦⃖₄ = refl
deterministicᵣₑᵥ ↦⃖₅ ↦⃖₅ = refl
deterministicᵣₑᵥ ↦⃖₆ ↦⃖₆ = refl
deterministicᵣₑᵥ ↦⃖₇ ↦⃖₇ = refl
deterministicᵣₑᵥ ↦⃖₈ ↦⃖₈ = refl
deterministicᵣₑᵥ ↦⃖₉ ↦⃖₉ = refl
deterministicᵣₑᵥ ↦⃖₁₀ ↦⃖₁₀ = refl
deterministicᵣₑᵥ ↦⃖₁₁ ↦⃖₁₁ = refl
deterministicᵣₑᵥ ↦⃖₁₂ ↦⃖₁₂ = refl
deterministicᵣₑᵥ {_} {[ η₊ ∣ inj₁ _ ∣ _ ]◁} {⟨ _ ∣ v ∣ _ ⟩▷} ↦η₁ r with Lemma₈ r
... | refl , refl with Lemma₉ r
... | refl , refl with Lemma₁₀ r
... | inj₁ ()
... | inj₂ ()
deterministicᵣₑᵥ {_} {[ η₊ ∣ inj₁ v ∣ _ ]◁} {[ _ ∣ _ ∣ _ ]◁} ↦η₁ ↦η₁ = refl
deterministicᵣₑᵥ {_} {[ η₊ ∣ inj₂ (- v) ∣ _ ]◁} {⟨ c ∣ x ∣ x₁ ⟩▷} ↦η₂ r with Lemma₈ r
... | refl , refl with Lemma₉ r
... | refl , refl with Lemma₁₀ r
... | inj₁ ()
... | inj₂ ()
deterministicᵣₑᵥ {_} {[ η₊ ∣ inj₂ (- v) ∣ _ ]◁} {[ _ ∣ _ ∣ _ ]◁} ↦η₂ ↦η₂ = refl
deterministicᵣₑᵥ ↦ε₁ ↦ε₁ = refl
deterministicᵣₑᵥ ↦ε₂ ↦ε₂ = refl
-- Non-repeating Lemma
open RevNoRepeat (record { State = State
; _↦_ = _↦_
; deterministic = deterministic
; deterministicᵣₑᵥ = deterministicᵣₑᵥ }) public
NoRepeatPi- : ∀ {A B stₙ stₘ n m} (c : A ↔ B) (v : ⟦ A ⟧)
→ n < m
→ ⟨ c ∣ v ∣ ☐ ⟩▷ ↦[ n ] stₙ
→ ⟨ c ∣ v ∣ ☐ ⟩▷ ↦[ m ] stₘ
→ stₙ ≢ stₘ
NoRepeatPi- c v n<m st₀↦stₙ st₀↦stₘ = NoRepeat (λ ()) n<m st₀↦stₙ st₀↦stₘ
|
{
"alphanum_fraction": 0.4531662716,
"avg_line_length": 64.1956521739,
"ext": "agda",
"hexsha": "bd855ab0b0ba769477ac0230dcfa3a3c977ea44c",
"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": "Pi-/NoRepeat.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": "Pi-/NoRepeat.agda",
"max_line_length": 141,
"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": "Pi-/NoRepeat.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": 9487,
"size": 14765
}
|
{-# OPTIONS --cubical --no-import-sorts #-}
open import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc)
open import Function.Base using (_∋_; _$_)
open import Cubical.Data.Sigma renaming (_×_ to infixr 4 _×_)
open import Cubical.Data.Empty renaming (elim to ⊥-elim; ⊥ to ⊥⊥) -- `⊥` and `elim`
open import Cubical.HITs.PropositionalTruncation.Base -- ∣_∣
import Cubical.HITs.PropositionalTruncation.Properties as PTrunc
open import Cubical.Foundations.Logic renaming
( inl to inlᵖ
; inr to inrᵖ
; _⇒_ to infixr 0 _⇒_ -- shifting by -6
; _⇔_ to infixr -2 _⇔_ --
; ∃[]-syntax to infix -4 ∃[]-syntax --
; ∃[∶]-syntax to infix -4 ∃[∶]-syntax --
; ∀[∶]-syntax to infix -4 ∀[∶]-syntax --
; ∀[]-syntax to infix -4 ∀[]-syntax --
)
open import Utils
open import MoreLogic.Reasoning
open import MoreLogic.Definitions renaming
( _ᵗ⇒_ to infixr 0 _ᵗ⇒_
; ∀ᵖ[∶]-syntax to infix -4 ∀ᵖ[∶]-syntax
; ∀ᵖ〚∶〛-syntax to infix -4 ∀ᵖ〚∶〛-syntax
; ∀ᵖ!〚∶〛-syntax to infix -4 ∀ᵖ!〚∶〛-syntax
; ∀〚∶〛-syntax to infix -4 ∀〚∶〛-syntax
; Σᵖ[]-syntax to infix -4 Σᵖ[]-syntax
; Σᵖ[∶]-syntax to infix -4 Σᵖ[∶]-syntax
) hiding (≡ˢ-syntax)
open import MoreLogic.Properties
open import MorePropAlgebra.Definitions hiding (_≤''_)
open import MorePropAlgebra.Consequences
open import MorePropAlgebra.Bundles
module MorePropAlgebra.Properties.AlmostPartiallyOrderedField {ℓ} {ℓ'} (assumptions : AlmostPartiallyOrderedField {ℓ} {ℓ'})
(let F = AlmostPartiallyOrderedField.Carrier assumptions
_≡ˢ_ = λ(x y : F) → MoreLogic.Definitions.≡ˢ-syntax x y {AlmostPartiallyOrderedField.is-set assumptions}
infixl 4 _≡ˢ_
) where
import MorePropAlgebra.Properties.Group
module Group'Properties = MorePropAlgebra.Properties.Group record { AlmostPartiallyOrderedField assumptions ; is-Group = AlmostPartiallyOrderedField.+-Group assumptions }
module Group' = Group record { AlmostPartiallyOrderedField assumptions ; is-Group = AlmostPartiallyOrderedField.+-Group assumptions }
( Group') = Group ∋ record { AlmostPartiallyOrderedField assumptions ; is-Group = AlmostPartiallyOrderedField.+-Group assumptions }
module GroupLemmas' = Group'Properties.GroupLemmas'
import MorePropAlgebra.Properties.Ring
module Ring'Properties = MorePropAlgebra.Properties.Ring record { AlmostPartiallyOrderedField assumptions }
module Ring' = Ring record { AlmostPartiallyOrderedField assumptions }
( Ring') = Ring ∋ record { AlmostPartiallyOrderedField assumptions }
module RingTheory' = Ring'Properties.RingTheory'
open AlmostPartiallyOrderedField assumptions -- renaming (Carrier to F; _-_ to _-_)
-- Bridges' definition of _≤__
_≤''_ : hPropRel F F (ℓ-max ℓ ℓ')
x ≤'' y = ∀[ ε ] (y < ε) ⇒ (x < ε)
infixl 4 _≤''_
private
-- infixl 4 _≡ˢ_
-- _≡ˢ_ = λ(x y : F) → MoreLogic.Definitions.≡ˢ-syntax x y {is-set} -- [ is-set ] x ≡ˢ y
≡ˢ-sym : ∀ a b → [ (a ≡ˢ b) ⇔ (b ≡ˢ a) ]
≡ˢ-sym a b .fst a≡b = sym a≡b
≡ˢ-sym a b .snd b≡a = sym b≡a
≡ˢ-symᵗ : ∀ a b → (a ≡ˢ b) ≡ (b ≡ˢ a)
≡ˢ-symᵗ a b = let (p , q) = ≡ˢ-sym a b in ⇔toPath p q
abstract
-dist' : ∀ a b → -(a + b) ≡ (- b) + (- a)
-dist : ∀ a b → -(a + b) ≡ (- a) + (- b)
·-inv#0 : ∀ x y → x · y ≡ 1f → [ (x # 0f) ⊓ (y # 0f) ]
·-reflects-≡ : (a b c : F) → [ c # 0f ⇒ (a · c ≡ˢ b · c) ⇒ (a ≡ˢ b) ]; _ : [ operation _·_ reflects _≡ˢ_ when (λ c → c # 0f) ]; _ = ·-reflects-≡
·-rinv-unique'' : (x y z : F) → [ x · y ≡ˢ 1f ] → [ x · z ≡ˢ 1f ] → [ y ≡ˢ z ]
_⁻¹'' : ∀ x → {{[ x # 0f ]}} → Σ[ y ∈ F ] x · y ≡ 1f
_⁻¹ : ∀ x → {{[ x # 0f ]}} → F
infix 9 _⁻¹
·-rinv : ∀ x → (p : [ x # 0f ]) → [ x · (x ⁻¹) {{p}} ≡ˢ 1f ]
·-linv : ∀ x → (p : [ x # 0f ]) → [ (x ⁻¹) {{p}} · x ≡ˢ 1f ]
·-linv-unique : (x y : F) → x · y ≡ 1f → (p : [ y # 0f ]) → x ≡ (y ⁻¹) {{p}}
<-≤-trans : ∀ x y z → [ x < y ⇒ y ≤ z ⇒ x < z ]
≤-<-trans : ∀ x y z → [ x ≤ y ⇒ y < z ⇒ x < z ]
≤-⇔-≤'' : ∀ x y → [ (x ≤ y) ⇔ (x ≤'' y) ]
≤-reflects-≡ : ∀ x y → [ (∀[ z ] z ≤ x ⇔ z ≤ y) ⇔ x ≡ˢ y ]
-dist' a b = GroupLemmas'.invDistr a b
-dist a b = -dist' a b ∙ +-comm _ _
·-inv#0 x y x·y≡1 .fst = ·-inv'' x .fst ∣ (y , x·y≡1) ∣
·-inv#0 x y x·y≡1 .snd = ·-inv'' y .fst ∣ (x , ·-comm y x ∙ x·y≡1) ∣
·-reflects-≡ a b c p = PTrunc.rec (isProp[] ((a · c ≡ˢ b · c) ⇒ (a ≡ˢ b) )) γ (·-inv'' c .snd p) where
γ : Σ[ c⁻¹ ∈ F ] [ c · c⁻¹ ≡ˢ 1f ] → [ (a · c ≡ˢ b · c) ⇒ a ≡ˢ b ]
γ (c⁻¹ , c·c⁻¹≡1) a·c≡b·c =
a ≡⟨ sym (fst (·-identity a)) ∙ cong (a ·_) (sym c·c⁻¹≡1) ∙ ·-assoc _ _ _ ⟩
(a · c) · (c⁻¹) ≡⟨ cong (_· c⁻¹) a·c≡b·c ⟩
(b · c) · (c⁻¹) ≡⟨ sym (·-assoc _ _ _) ∙ cong (b ·_) c·c⁻¹≡1 ∙ fst (·-identity b) ⟩
b ∎
-- uniqueness of inverses from `·-assoc` + `·-comm` + `·-lid` + `·-rid`
·-rinv-unique'' x y z x·y≡1 x·z≡1 =
( x · y ≡ˢ 1f ⇒ᵖ⟨ (λ x·y≡1 i → z · x·y≡1 i) ⟩
z · (x · y) ≡ˢ z · 1f ⇒ᵖ⟨ pathTo⇒ (λ i → ·-assoc z x y i ≡ˢ ·-rid z i) ⟩
(z · x) · y ≡ˢ z ⇒ᵖ⟨ pathTo⇒ (λ i → (·-comm z x i) · y ≡ˢ z) ⟩
(x · z) · y ≡ˢ z ⇒ᵖ⟨ pathTo⇒ (λ i → x·z≡1 i · y ≡ˢ z) ⟩
1f · y ≡ˢ z ⇒ᵖ⟨ pathTo⇒ (λ i → ·-lid y i ≡ˢ z) ⟩
y ≡ˢ z ◼ᵖ) .snd x·y≡1
-- inverse function from `·-rinv-unique''` and `∀[ x ] (∃[ y ] x · y ≡ˢ 1f) ⇔ x # 0f`
(x ⁻¹'') {{x#0f}} = PTrunc.rec γ (λ p → p) (·-inv'' x .snd x#0f) where
γ : isProp (Σ[ y ∈ F ] x · y ≡ 1f)
γ (a , x·a≡1) (b , x·b≡1) = let a≡b = ·-rinv-unique'' x a b x·a≡1 x·b≡1
in Σ≡Prop (λ c → isProp[] (x · c ≡ˢ 1f)) a≡b
(x ⁻¹) {{p}} = (x ⁻¹'') .fst
·-rinv x p = (x ⁻¹'') {{p}} .snd
·-linv x p = ·-comm _ _ ∙ ·-rinv x p
·-linv-unique x y x·y≡1 p = sym $ ·-rinv-unique'' y ((y ⁻¹) {{p}}) x (·-rinv y p) (·-comm _ _ ∙ x·y≡1)
<-≤-trans x y z x<y y≤z = ⊔-elim (x < z) (z < y) (λ _ → x < z) (λ x<z → x<z) (λ z<y → ⊥-elim (y≤z z<y)) (<-cotrans _ _ x<y z)
≤-<-trans x y z x≤y y<z = ⊔-elim (y < x) (x < z) (λ _ → x < z) (λ y<x → ⊥-elim (x≤y y<x)) (λ x<z → x<z) (<-cotrans y z y<z x)
-- Booij's _≤_ ⇔ Brigdes' _≤''_
≤-⇔-≤'' x y .fst x≤y ε y<ε = ≤-<-trans x y ε x≤y y<ε
≤-⇔-≤'' x y .snd x≤''y y<x = <-irrefl x (x≤''y x y<x)
≤-reflects-≡ x y .fst z≤x⇔z≤y = ≤-antisym x y (z≤x⇔z≤y x .fst (≤-refl x)) (z≤x⇔z≤y y .snd (≤-refl y))
≤-reflects-≡ x y .snd x≡y z .fst = subst (λ p → [ z ≤ p ]) x≡y
≤-reflects-≡ x y .snd x≡y z .snd = subst (λ p → [ z ≤ p ]) (sym x≡y)
|
{
"alphanum_fraction": 0.5041359603,
"avg_line_length": 46.4965034965,
"ext": "agda",
"hexsha": "b42acc5a575ae0433971c7d24ba3c52f75d48707",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mchristianl/synthetic-reals",
"max_forks_repo_path": "agda/MorePropAlgebra/Properties/AlmostPartiallyOrderedField.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "mchristianl/synthetic-reals",
"max_issues_repo_path": "agda/MorePropAlgebra/Properties/AlmostPartiallyOrderedField.agda",
"max_line_length": 173,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mchristianl/synthetic-reals",
"max_stars_repo_path": "agda/MorePropAlgebra/Properties/AlmostPartiallyOrderedField.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-19T12:15:21.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-07-31T18:15:26.000Z",
"num_tokens": 3124,
"size": 6649
}
|
data ⊤ : Set where tt : ⊤
postulate
A : Set
B : A → Set
a : A
b : B a
G : ∀ x → B x → Set
postulate tt' : ⊤
poo : G a b
poo with tt | a
... | _ | _ = {!!}
|
{
"alphanum_fraction": 0.4319526627,
"avg_line_length": 10.5625,
"ext": "agda",
"hexsha": "b70c1bde60795d38774846a5be22582acb9ff836",
"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/Issue2763.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/Issue2763.agda",
"max_line_length": 25,
"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/Issue2763.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": 169
}
|
{-# OPTIONS --universe-polymorphism #-}
-- {-# OPTIONS --verbose tc.rec:15 #-}
-- {-# OPTIONS --verbose tc.records.ifs:15 #-}
-- {-# OPTIONS --verbose tc.constr.findInScope:15 #-}
-- {-# OPTIONS --verbose tc.term.args.ifs:15 #-}
module 05-equality-std2 where
open import Relation.Binary
open import Data.Bool hiding (_≟_)
open DecSetoid {{...}}
test = isDecEquivalence
test2 = false ≟ false
|
{
"alphanum_fraction": 0.6658227848,
"avg_line_length": 24.6875,
"ext": "agda",
"hexsha": "277234e8c2af29e95bfb3fecf3cda7277db185a3",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "larrytheliquid/agda",
"max_forks_repo_path": "examples/instance-arguments/05-equality-std2.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "larrytheliquid/agda",
"max_issues_repo_path": "examples/instance-arguments/05-equality-std2.agda",
"max_line_length": 53,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "larrytheliquid/agda",
"max_stars_repo_path": "examples/instance-arguments/05-equality-std2.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 109,
"size": 395
}
|
{-
This file contains:
- Natural functions from FreeGroupoid into FreeGroupoid
- Proofs that they induce equivalences
- Natural paths in Universe from FreeGroupoid to FreeGroupoid
- Proofs that these functions and paths respect the groupoid structure of FreeGroupoid
-}
{-# OPTIONS --safe #-}
module Cubical.HITs.FreeGroupoid.GroupoidActions where
open import Cubical.HITs.FreeGroupoid.Base
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Equiv.BiInvertible
open import Cubical.Foundations.Function
private
variable
ℓ : Level
A : Type ℓ
-- A function for every element of FreeGroupoid A
action : ∀ (a : FreeGroupoid A) → FreeGroupoid A → FreeGroupoid A
action a g = g · a
invAction : FreeGroupoid A → FreeGroupoid A → FreeGroupoid A
invAction a = action (inv a)
-- Naturality properties of the FreeGroupoid operations
multNaturality : (g1 g2 : FreeGroupoid A) → action (g1 · g2) ≡ (action g2 ∘ action g1)
multNaturality g1 g2 = funExt (pointwise g1 g2) where
pointwise : (g1 g2 g3 : FreeGroupoid A) → action (g1 · g2) g3 ≡ (action g2 ∘ action g1) g3
pointwise g1 g2 g3 =
action (g1 · g2) g3
≡⟨ assoc g3 g1 g2 ⟩
(action g2 ∘ action g1) g3 ∎
idNaturality : action ε ≡ idfun (FreeGroupoid A)
idNaturality = funExt pointwise where
pointwise : (g : FreeGroupoid A) → action ε g ≡ idfun (FreeGroupoid A) g
pointwise g =
action ε g
≡⟨ sym (idr g) ⟩
idfun _ g ∎
rCancelAction : ∀ (a : FreeGroupoid A) → action a ∘ invAction a ≡ idfun (FreeGroupoid A)
rCancelAction a =
action a ∘ invAction a
≡⟨ sym (multNaturality (inv a) a) ⟩
action ((inv a) · a)
≡⟨ cong action (invl a) ⟩
action ε
≡⟨ idNaturality ⟩
idfun _ ∎
lCancelAction : ∀ (a : FreeGroupoid A) → invAction a ∘ action a ≡ idfun (FreeGroupoid A)
lCancelAction a =
invAction a ∘ action a
≡⟨ sym (multNaturality a (inv a)) ⟩
action (a · (inv a))
≡⟨ cong action (invr a) ⟩
action ε
≡⟨ idNaturality ⟩
idfun _ ∎
-- Characterization of the action functions
actionCharacterization : ∀ (f : FreeGroupoid A → FreeGroupoid A)
→ (∀ g1 g2 → f (g1 · g2) ≡ g1 · (f g2))
→ Σ[ a ∈ FreeGroupoid A ] (f ≡ action a)
actionCharacterization f property = f ε , (funExt pointwise) where
pointwise : ∀ g → f g ≡ action (f ε) g
pointwise g =
f g
≡⟨ cong f (idr g) ⟩
f (g · ε)
≡⟨ property g ε ⟩
action (f ε) g ∎
-- Actions induce equivalences
biInvAction : FreeGroupoid A → BiInvEquiv (FreeGroupoid A) (FreeGroupoid A)
biInvAction a = biInvEquiv (action a) (invAction a) (rhomotopy a) (invAction a) (lhomotopy a) where
rhomotopy : ∀ a g → (action a ∘ invAction a) g ≡ g
rhomotopy a g = cong (λ f → f g) (rCancelAction a)
lhomotopy : ∀ a g → (invAction a ∘ action a) g ≡ g
lhomotopy a g = cong (λ f → f g) (lCancelAction a)
equivs : FreeGroupoid A → (FreeGroupoid A) ≃ (FreeGroupoid A)
equivs a = biInvEquiv→Equiv-right (biInvAction a)
-- Naturality properties of the equivs group
multEquivsNaturality : ∀ (k1 k2 : FreeGroupoid A) → equivs (k1 · k2) ≡ compEquiv (equivs k1) (equivs k2)
multEquivsNaturality k1 k2 = equivEq h where
h : (equivs (k1 · k2)) .fst ≡ (compEquiv (equivs k1) (equivs k2)) .fst
h =
equivs (k1 · k2) .fst
≡⟨ multNaturality k1 k2 ⟩
compEquiv (equivs k1) (equivs k2) .fst ∎
idEquivsNaturality : equivs ε ≡ idEquiv (FreeGroupoid A)
idEquivsNaturality = equivEq h where
h : (equivs ε) .fst ≡ idEquiv (FreeGroupoid A) .fst
h =
(equivs ε) .fst
≡⟨ idNaturality ⟩
idEquiv _ .fst ∎
invEquivsNaturality : ∀ (g : FreeGroupoid A) → equivs (inv g) ≡ invEquiv (equivs g)
invEquivsNaturality g = equivEq refl
-- Actions induce paths in Universe
pathsInU : {A : Type ℓ} → FreeGroupoid A → (FreeGroupoid A) ≡ (FreeGroupoid A)
pathsInU a = ua (equivs a)
-- Naturality properties of the paths group
multPathsInUNaturality : ∀ (g1 g2 : FreeGroupoid A) → pathsInU (g1 · g2) ≡ (pathsInU g1) ∙ (pathsInU g2)
multPathsInUNaturality g1 g2 =
pathsInU (g1 · g2)
≡⟨ cong ua (multEquivsNaturality g1 g2) ⟩
ua (compEquiv (equivs g1) (equivs g2))
≡⟨ uaCompEquiv (equivs g1) (equivs g2) ⟩
(pathsInU g1) ∙ (pathsInU g2) ∎
idPathsInUNaturality : pathsInU {A = A} ε ≡ refl
idPathsInUNaturality =
pathsInU ε
≡⟨ cong ua idEquivsNaturality ⟩
ua (idEquiv _)
≡⟨ uaIdEquiv ⟩
refl ∎
invPathsInUNaturality : ∀ (g : FreeGroupoid A) → pathsInU (inv g) ≡ sym (pathsInU g)
invPathsInUNaturality g =
pathsInU (inv g)
≡⟨ cong ua (invEquivsNaturality g) ⟩
ua (invEquiv (equivs g))
≡⟨ uaInvEquiv (equivs g) ⟩
sym (pathsInU g) ∎
|
{
"alphanum_fraction": 0.679835924,
"avg_line_length": 30.6754966887,
"ext": "agda",
"hexsha": "7f906dc309850e8fc765b2520c6cf2f88972287d",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "thomas-lamiaux/cubical",
"max_forks_repo_path": "Cubical/HITs/FreeGroupoid/GroupoidActions.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "thomas-lamiaux/cubical",
"max_issues_repo_path": "Cubical/HITs/FreeGroupoid/GroupoidActions.agda",
"max_line_length": 104,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "thomas-lamiaux/cubical",
"max_stars_repo_path": "Cubical/HITs/FreeGroupoid/GroupoidActions.agda",
"max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z",
"num_tokens": 1770,
"size": 4632
}
|
------------------------------------------------------------------------------
-- ABP terms
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOTC.Program.ABP.Terms where
open import FOTC.Base
open import FOTC.Base.Loop
open import FOTC.Data.Bool
------------------------------------------------------------------------------
-- N.B. We did not define @Bit = Bool@ due to the issue #11.
Bit : D → Set
Bit b = Bool b
{-# ATP definition Bit #-}
F T : D
F = false
T = true
{-# ATP definition F T #-}
postulate
<_,_> : D → D → D
ok : D → D
|
{
"alphanum_fraction": 0.392338177,
"avg_line_length": 25.2333333333,
"ext": "agda",
"hexsha": "bc9984d4accf5b224a022b25719a0cd55b96c4c6",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z",
"max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/fotc",
"max_forks_repo_path": "src/fot/FOTC/Program/ABP/Terms.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/fotc",
"max_issues_repo_path": "src/fot/FOTC/Program/ABP/Terms.agda",
"max_line_length": 78,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "src/fot/FOTC/Program/ABP/Terms.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": 157,
"size": 757
}
|
-- An implementation of Olivier Danvy's Type-Directed Partial Evaluation (POPL 1996)
-- for STLC with sum types using continuations in form of shift and reset.
--
-- The algorithm was originally for a two-level lambda-calculus.
-- Our use of Kripke semantics makes the effect of fresh variable generation explicit and formal.
open import Library
module DanvyShiftReset where
data Base : Set where
α β : Base
-- import Formulas ; open module Form = Formulas Base
-- import Derivations; open module Der = Derivations Base
open import Formulas Base
open import Derivations Base
-- -- Shift-reset continutation monad
-- record M (A B C : Set) : Set where
-- field run : (C → B) → A
-- open M
-- return : ∀{X A} → A → M X X A
-- return x .run k = k x
-- _>>=_ : ∀{X Y Z A B} (m : M X Y A) (f : A → M Y Z B) → M X Z B
-- (m >>= f) .run k = m .run λ a → f a .run k
-- _<$>_ : ∀{X Y A B} (f : A → B) (m : M X Y A) → M X Y B
-- (f <$> m) .run k = m .run (k ∘ f)
-- shift : ∀{X Y A} (f : (A → Y) → M X Y Y) → M X Y A
-- shift f .run k = f k .run id
-- shift' : ∀{X Y A} (f : (A → Y) → X) → M X Y A
-- shift' f .run k = f k
-- reset : ∀{X Y A} (m : M A Y Y) → M X X A
-- reset m .run k = k (m .run id)
-- Shift-reset continutation monad
record M (A B C : Cxt → Set) (Γ : Cxt) : Set where
field run : KFun (KFun C B) A Γ
open M
return : ∀{X A} → □ A →̇ M X X A
return x .run τ k = k id≤ (x τ)
return' : ∀{X A} → □ A →̇ M X X (□ A)
return' x .run τ k = k id≤ λ τ₁ → x (τ₁ • τ)
_>>=_ : ∀{X Y Z A B Γ} (m : M X Y A Γ) (f : KFun A (M Y Z B) Γ) → M X Z B Γ
(m >>= f) .run σ k = m .run σ λ τ a → f (τ • σ) a .run id≤ λ τ′ → k (τ′ • τ)
_<$>_ : ∀{X Y A B} (f : A →̇ B) → M X Y A →̇ M X Y B
(f <$> m) .run σ k = m .run σ λ τ → k τ ∘ f
-- liftA2 : ∀{X Y A B C} (f : ∀{Γ} → A Γ → B Γ → C Γ) → ∀{Γ} → M X Y A Γ → M X Y B Γ → M X Y C Γ
-- liftA2 f ma mb .run σ k = ma .run σ λ τ a → {!mb .run!}
K$ : ∀{X Y A B} → KFun A B →̇ KFun (M X Y A) (M X Y B)
K$ f τ m .run σ k = m .run σ λ τ′ a → k τ′ (f (τ′ • (σ • τ)) a)
shift' : ∀{X Y A Γ} (f : KFun (KFun A Y) X Γ) → M X Y A Γ
shift' f .run σ k = f σ k
shift : ∀{X Y A Γ} (f : KFun (KFun A Y) (M X Y Y) Γ) → M X Y A Γ
shift f .run σ k = f σ k .run id≤ λ τ → id
reset' : ∀{Y A} → M A Y Y →̇ A
reset' m = m .run id≤ λ τ → id
reset : ∀{X Y A} → M A Y Y →̇ M X X A
reset m .run σ k = k id≤ (m .run σ λ τ → id)
-- We use a continuation monad with answer type Nf.
M' : (X : Cxt → Set) (Γ : Cxt) → Set
M' X Γ = ∀ {C} → M (Nf' C) (Nf' C) X Γ
T⟦_⟧ : (A : Form) (Γ : Cxt) → Set
T⟦ Atom P ⟧ = Nf' (Atom P)
T⟦ True ⟧ Γ = ⊤
T⟦ False ⟧ Γ = ⊥
T⟦ A ∨ B ⟧ Γ = T⟦ A ⟧ Γ ⊎ T⟦ B ⟧ Γ
T⟦ A ∧ B ⟧ Γ = T⟦ A ⟧ Γ × T⟦ B ⟧ Γ
T⟦ A ⇒ B ⟧ Γ = ∀{Δ} (τ : Δ ≤ Γ) → T⟦ A ⟧ Δ → M' T⟦ B ⟧ Δ
-- Monotonicity of the model is proven by induction on the proposition.
-- monT : ∀ A {Γ Δ} (τ : Δ ≤ Γ) → T⟦ A ⟧ Γ → T⟦ A ⟧ Δ
monT : ∀ A → Mon T⟦ A ⟧
monT (Atom P) = monNf
monT True = _
monT False τ ()
monT (A ∨ B) τ = map-⊎ (monT A τ) (monT B τ)
monT (A ∧ B) τ (a , b) = monT A τ a , monT B τ b
monT (A ⇒ B) τ f σ = f (σ • τ)
-- Reflection / reification, proven simultaneously by induction on the proposition.
-- Reflection is η-expansion (and recursively reflection);
mutual
reflect : ∀{Γ} A (t : Ne Γ A) → M' T⟦ A ⟧ Γ
reflect (Atom P) t = return λ τ → ne (monNe τ t)
reflect True t = return _
reflect False t = shift' λ τ k → falseE (monNe τ t)
reflect (A ∨ B) t = shift' λ τ k → orE (monNe τ t)
(reset' (K$ k (weak id≤) (inj₁ <$> reflect A (hyp top))))
(reset' (K$ k (weak id≤) (inj₂ <$> reflect B (hyp top))))
-- ((inj₂ <$> reflect B (hyp top)) .run λ τ → k (τ • weak id≤))
-- Wrong:
-- (reset' (k (weak id≤) <$> (inj₁ <$> reflect A (hyp top))))
-- reflect (A ∧ B) t = do
-- a ← reflect A (andE₁ t)
-- b ← reflect B (andE₂ t)
-- return (a , b)
reflect (A ∧ B) t =
reflect A (andE₁ t ) >>= λ τ a →
reflect B (andE₂ (monNe τ t)) >>= λ τ′ b →
return λ τ₁ → monT A (τ₁ • τ′) a , monT B τ₁ b
reflect (A ⇒ B) t = return' λ τ a → reflect B (impE (monNe τ t) (reify A a))
reify : ∀{Γ} A (⟦f⟧ : T⟦ A ⟧ Γ) → Nf Γ A
reify (Atom P) t = t
reify True _ = trueI
reify False ()
reify (A ∨ B) (inj₁ a) = orI₁ (reify A a)
reify (A ∨ B) (inj₂ b) = orI₂ (reify B b)
reify (A ∧ B) (a , b) = andI (reify A a) (reify B b)
reify (A ⇒ B) f = impI $ reset' $
reflect A (hyp top) >>= λ τ a →
reify B <$> f (τ • weak id≤) a
-- Fundamental theorem
-- Extension of T⟦_⟧ to contexts
G⟦_⟧ : ∀ (Γ Δ : Cxt) → Set
G⟦ ε ⟧ Δ = ⊤
G⟦ Γ ∙ A ⟧ Δ = G⟦ Γ ⟧ Δ × T⟦ A ⟧ Δ
-- monG : ∀{Γ Δ Φ} (τ : Φ ≤ Δ) → G⟦ Γ ⟧ Δ → G⟦ Γ ⟧ Φ
monG : ∀{Γ} → Mon G⟦ Γ ⟧
monG {ε} τ _ = _
monG {Γ ∙ A} τ (γ , a) = monG τ γ , monT A τ a
-- Variable case.
fundH : ∀{Γ Δ A} (x : Hyp A Γ) (γ : G⟦ Γ ⟧ Δ) → T⟦ A ⟧ Δ
fundH top = proj₂
fundH (pop x) = fundH x ∘ proj₁
-- The fundamental theorem:
-- A call-by-value interpreter.
fund : ∀{Γ A} (t : Γ ⊢ A) {Δ} (γ : G⟦ Γ ⟧ Δ) → M' T⟦ A ⟧ Δ
fund (hyp {A} x) γ = return λ τ → monT A τ (fundH x γ)
fund (impI t) γ = return' λ τ a → fund t (monG τ γ , a)
fund (impE t u) γ =
fund t γ >>= λ τ f →
fund u (monG τ γ) >>= λ τ′ a →
f τ′ a
fund (andI {A} {B} t u) γ =
fund t γ >>= λ τ a →
fund u (monG τ γ) >>= λ τ′ b →
return λ τ₁ → monT A (τ₁ • τ′) a , monT B τ₁ b
fund (andE₁ t) γ = proj₁ <$> fund t γ
fund (andE₂ t) γ = proj₂ <$> fund t γ
fund (orI₁ t) γ = inj₁ <$> fund t γ
fund (orI₂ t) γ = inj₂ <$> fund t γ
fund (orE t u v) γ = fund t γ >>= λ τ →
[ (λ a → fund u (monG τ γ , a))
, (λ b → fund v (monG τ γ , b))
]
fund (falseE t) γ = fund t γ >>= λ τ ()
fund trueI γ = return _
-- Identity environment
ide : ∀ Γ → □ (M' G⟦ Γ ⟧) Γ
ide ε τ = return _
ide (Γ ∙ A) τ =
ide Γ (τ • weak id≤) >>= λ τ₁ γ →
reflect A (monNe (τ₁ • τ) (hyp top)) >>= λ τ₂ a →
return λ τ₃ → monG (τ₃ • τ₂) γ , monT A τ₃ a
-- Normalization
norm : ∀{A Γ} (t : Γ ⊢ A) → Nf Γ A
norm {A} {Γ} t = reset' $
ide Γ id≤ >>= λ _ γ →
reify A <$> fund t γ
idD : (A : Form) → ε ⊢ (A ⇒ A)
idD A = impI (hyp top)
test : let A = Atom α; B = Atom β in Nf ε (A ∨ B ⇒ A ∨ B)
test = norm (idD (Atom α ∨ Atom β))
test2 = norm (idD (Atom α ∨ Atom β ∨ Atom α))
-- Q.E.D. -}
-- -}
-- -}
-- -}
-- -}
-- -}
-- -}
|
{
"alphanum_fraction": 0.4922517394,
"avg_line_length": 27.0256410256,
"ext": "agda",
"hexsha": "ea73b62a4b527ca533319e2c578da780fc560e15",
"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/DanvyShiftReset.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/DanvyShiftReset.agda",
"max_line_length": 97,
"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/DanvyShiftReset.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": 2835,
"size": 6324
}
|
data C : Set₁ where
c : Set → C
data D : Set where
d : D
F : C → {y : D} → C → Set₁
F z (c _) = G d
module M where
G : D → Set₁
G _ = Set
fail : Set
fail = M.G
|
{
"alphanum_fraction": 0.4885057471,
"avg_line_length": 10.875,
"ext": "agda",
"hexsha": "713099f3038ad79763780d844dd5201c445d8d5b",
"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/Issue2776.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/Issue2776.agda",
"max_line_length": 26,
"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/Issue2776.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": 78,
"size": 174
}
|
{-# OPTIONS --without-K --rewriting #-}
open import HoTT renaming (pt to ⊙pt)
open import homotopy.Bouquet
open import homotopy.FinWedge
open import homotopy.LoopSpaceCircle
open import homotopy.SphereEndomorphism
open import groups.SphereEndomorphism
open import cw.CW
open import cw.FinCW
open import cw.WedgeOfCells
open import cw.DegreeByProjection {lzero}
open import homotopy.DisjointlyPointedSet
open import cohomology.Theory
module cw.cohomology.cochainequiv.FirstCoboundaryAbstractDefs (OT : OrdinaryTheory lzero)
(⊙fin-skel : ⊙FinSkeleton 1) where
open OrdinaryTheory OT
open import cohomology.Bouquet OT
private
⊙skel = ⊙FinSkeleton-realize ⊙fin-skel
fin-skel = ⊙FinSkeleton.skel ⊙fin-skel
I = AttachedFinSkeleton.numCells fin-skel
skel = ⊙Skeleton.skel ⊙skel
dec = FinSkeleton-has-cells-with-dec-eq fin-skel
endpoint = attaching-last skel
I₋₁ = AttachedFinSkeleton.skel fin-skel
⊙head = ⊙cw-head ⊙skel
pt = ⊙pt ⊙head
open import cw.cohomology.reconstructed.TipCoboundary OT ⊙skel
⊙head-is-separable : is-separable ⊙head
⊙head-is-separable = Fin-has-dec-eq pt
⊙head-separate = separate-pt ⊙head-is-separable
⊙head-separate-equiv = (unite-pt ⊙head , separable-has-disjoint-pt ⊙head-is-separable)⁻¹
MinusPoint-⊙head-has-choice : has-choice 0 (MinusPoint ⊙head) lzero
MinusPoint-⊙head-has-choice = MinusPoint-has-choice ⊙head-is-separable (Fin-has-choice 0 lzero)
MinusPoint-⊙head-has-dec-eq : has-dec-eq (MinusPoint ⊙head)
MinusPoint-⊙head-has-dec-eq = MinusPoint-has-dec-eq Fin-has-dec-eq
⊙function₀ : ⊙FinBouquet I 1 ⊙→ ⊙Susp (⊙Bouquet (MinusPoint ⊙head) 0)
⊙function₀ = ⊙Susp-fmap (⊙<– (Bouquet-⊙equiv-X ⊙head-is-separable))
⊙∘ ⊙cw-∂-head'-before-Susp
⊙∘ ⊙–> (Bouquet-⊙equiv-Xₙ/Xₙ₋₁ skel)
function₁ : Fin I → MinusPoint ⊙head → Sphere-endo 0
function₁ <I b x with Fin-has-dec-eq (fst b) (endpoint <I x)
function₁ <I b x | inl _ = false
function₁ <I b x | inr _ = true
abstract
⊙function₀' : ⊙FinBouquet I 1 ⊙→ ⊙Susp (⊙Bouquet (MinusPoint ⊙head) 0)
⊙function₀' = ⊙function₀
⊙function₀'-β : ⊙function₀' == ⊙function₀
⊙function₀'-β = idp
function₁' : Fin I → MinusPoint ⊙head → Sphere-endo 0
function₁' = function₁
function₁'-β : ∀ <I b → function₁' <I b == function₁ <I b
function₁'-β _ _ = idp
private
mega-reduction-cases : ∀ <I b x
→ bwproj MinusPoint-⊙head-has-dec-eq b (<– (Bouquet-equiv-X ⊙head-is-separable) (endpoint <I x))
== function₁ <I b x
mega-reduction-cases <I b x with Fin-has-dec-eq pt (endpoint <I x)
mega-reduction-cases <I b x | inl _ with Fin-has-dec-eq (fst b) (endpoint <I x)
mega-reduction-cases <I b x | inl pt=end | inl b=end = ⊥-rec (snd b (pt=end ∙ ! b=end))
mega-reduction-cases <I b x | inl _ | inr _ = idp
mega-reduction-cases <I b x | inr _ with Fin-has-dec-eq (fst b) (endpoint <I x)
mega-reduction-cases <I b x | inr _ | inl b=end =
bwproj MinusPoint-⊙head-has-dec-eq b (bwin (endpoint <I x , _) false)
=⟨ ap (λ b' → bwproj MinusPoint-⊙head-has-dec-eq b (bwin b' false)) $ ! $
Subtype=-out (MinusPoint-prop ⊙head) b=end ⟩
bwproj MinusPoint-⊙head-has-dec-eq b (bwin b false)
=⟨ bwproj-bwin-diag MinusPoint-⊙head-has-dec-eq b false ⟩
false
=∎
mega-reduction-cases <I b x | inr _ | inr b≠end =
bwproj-bwin-≠ MinusPoint-⊙head-has-dec-eq (b≠end ∘ ap fst) false
mega-reduction : ∀ <I b →
Susp-fmap (bwproj MinusPoint-⊙head-has-dec-eq b) ∘ fst ⊙function₀' ∘ fwin <I
∼ Susp-fmap (function₁' <I b)
mega-reduction <I b = Susp-elim idp idp λ x → ↓-='-in' $ ! $
ap (Susp-fmap (bwproj MinusPoint-⊙head-has-dec-eq b) ∘ fst ⊙function₀ ∘ fwin <I) (merid x)
=⟨ ap-∘
( Susp-fmap (bwproj MinusPoint-⊙head-has-dec-eq b)
∘ Susp-fmap (<– (Bouquet-equiv-X ⊙head-is-separable))
∘ cw-∂-head'-before-Susp)
(Bouquet-to-Xₙ/Xₙ₋₁ skel ∘ fwin <I)
(merid x) ⟩
ap ( Susp-fmap (bwproj MinusPoint-⊙head-has-dec-eq b)
∘ Susp-fmap (<– (Bouquet-equiv-X ⊙head-is-separable))
∘ cw-∂-head'-before-Susp)
(ap (Bouquet-to-Xₙ/Xₙ₋₁ skel ∘ fwin <I) (merid x))
=⟨ ap (ap ( Susp-fmap (bwproj MinusPoint-⊙head-has-dec-eq b)
∘ Susp-fmap (<– (Bouquet-equiv-X ⊙head-is-separable))
∘ cw-∂-head'-before-Susp))
(Bouquet-to-Xₙ/Xₙ₋₁-in-merid-β skel <I x) ⟩
ap ( Susp-fmap (bwproj MinusPoint-⊙head-has-dec-eq b)
∘ Susp-fmap (<– (Bouquet-equiv-X ⊙head-is-separable))
∘ cw-∂-head'-before-Susp)
(cfglue (endpoint <I x) ∙' ap cfcod (spoke <I x))
=⟨ ap-∘
( Susp-fmap (bwproj MinusPoint-⊙head-has-dec-eq b)
∘ Susp-fmap (<– (Bouquet-equiv-X ⊙head-is-separable)))
cw-∂-head'-before-Susp
(cfglue (endpoint <I x) ∙' ap cfcod (spoke <I x)) ⟩
ap ( Susp-fmap (bwproj MinusPoint-⊙head-has-dec-eq b)
∘ Susp-fmap (<– (Bouquet-equiv-X ⊙head-is-separable)))
(ap cw-∂-head'-before-Susp
(cfglue (endpoint <I x) ∙' ap cfcod (spoke <I x)))
=⟨ ap (ap ( Susp-fmap (bwproj MinusPoint-⊙head-has-dec-eq b)
∘ Susp-fmap (<– (Bouquet-equiv-X ⊙head-is-separable))))
( ap-∙' cw-∂-head'-before-Susp (cfglue (endpoint <I x)) (ap cfcod (spoke <I x))
∙ ap2 _∙'_
(cw-∂-head'-before-Susp-glue-β (endpoint <I x))
( ∘-ap cw-∂-head'-before-Susp cfcod (spoke <I x)
∙ ap-cst south (spoke <I x))) ⟩
ap ( Susp-fmap (bwproj MinusPoint-⊙head-has-dec-eq b)
∘ Susp-fmap (<– (Bouquet-equiv-X ⊙head-is-separable)))
(merid (endpoint <I x))
=⟨ ap-∘
(Susp-fmap (bwproj MinusPoint-⊙head-has-dec-eq b))
(Susp-fmap (<– (Bouquet-equiv-X ⊙head-is-separable)))
(merid (endpoint <I x)) ⟩
ap (Susp-fmap (bwproj MinusPoint-⊙head-has-dec-eq b))
(ap (Susp-fmap (<– (Bouquet-equiv-X ⊙head-is-separable)))
(merid (endpoint <I x)))
=⟨ ap
(ap (Susp-fmap (bwproj MinusPoint-⊙head-has-dec-eq b)))
(SuspFmap.merid-β
(<– (Bouquet-equiv-X ⊙head-is-separable))
(endpoint <I x)) ⟩
ap (Susp-fmap (bwproj MinusPoint-⊙head-has-dec-eq b))
(merid (<– (Bouquet-equiv-X ⊙head-is-separable) (endpoint <I x)))
=⟨ SuspFmap.merid-β (bwproj MinusPoint-⊙head-has-dec-eq b)
(<– (Bouquet-equiv-X ⊙head-is-separable) (endpoint <I x)) ⟩
merid (bwproj MinusPoint-⊙head-has-dec-eq b (<– (Bouquet-equiv-X ⊙head-is-separable) (endpoint <I x)))
=⟨ ap merid (mega-reduction-cases <I b x) ⟩
merid (function₁ <I b x)
=⟨ ! $ SuspFmap.merid-β (function₁ <I b) x ⟩
ap (Susp-fmap (function₁ <I b)) (merid x)
=∎
open DegreeAtOne skel dec
degree-matches' : ∀ <I b
→ merid (function₁' <I b false) ∙ ! (merid (function₁' <I b true))
== loop^ (degree <I (fst b))
degree-matches' <I b with Fin-has-dec-eq (fst b) (endpoint <I false)
degree-matches' <I b | inl _ with Fin-has-dec-eq (fst b) (endpoint <I true)
degree-matches' <I b | inl _ | inl _ = !-inv-r (merid false)
degree-matches' <I b | inl _ | inr _ = idp
degree-matches' <I b | inr _ with Fin-has-dec-eq (fst b) (endpoint <I true)
degree-matches' <I b | inr _ | inl _ = ap (_∙ ! (merid false)) (! (!-! (merid true))) ∙ ∙-! (! (merid true)) (merid false)
degree-matches' <I b | inr _ | inr _ = !-inv-r (merid true)
degree-matches : ∀ <I b
→ ⊙SphereS-endo-degree 0 (Susp-fmap (function₁' <I b) , idp)
== degree <I (fst b)
degree-matches <I b = equiv-adj' ΩS¹-equiv-ℤ $
ap (Susp-fmap (function₁ <I b)) loop
=⟨ ap-∙ (Susp-fmap (function₁ <I b)) (merid false) (! (merid true)) ⟩
ap (Susp-fmap (function₁ <I b)) (merid false)
∙ ap (Susp-fmap (function₁ <I b)) (! (merid true))
=⟨ ap2 _∙_
(SuspFmap.merid-β (function₁ <I b) false)
( ap-! (Susp-fmap (function₁ <I b)) (merid true)
∙ ap ! (SuspFmap.merid-β (function₁ <I b) true)) ⟩
merid (function₁ <I b false) ∙ ! (merid (function₁ <I b true))
=⟨ degree-matches' <I b ⟩
loop^ (degree <I (fst b))
=∎
|
{
"alphanum_fraction": 0.6086849247,
"avg_line_length": 43.3475935829,
"ext": "agda",
"hexsha": "d79af26bcb93f51670021a79fe2079610866babb",
"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": "theorems/cw/cohomology/cochainequiv/FirstCoboundaryAbstractDefs.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": "theorems/cw/cohomology/cochainequiv/FirstCoboundaryAbstractDefs.agda",
"max_line_length": 124,
"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": "theorems/cw/cohomology/cochainequiv/FirstCoboundaryAbstractDefs.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3142,
"size": 8106
}
|
-- The ATP pragma with the role <axiom> can be used with data constructors.
module ATPAxiomDataConstructors where
postulate
D : Set
zero : D
succ : D → D
data N : D → Set where
zN : N zero
sN : ∀ {n} → N n → N (succ n)
{-# ATP axiom zN #-}
|
{
"alphanum_fraction": 0.5851851852,
"avg_line_length": 19.2857142857,
"ext": "agda",
"hexsha": "3f32c39e2fece07481930f94d806fa692b21bd41",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2016-08-03T03:54:55.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-05-10T23:06:19.000Z",
"max_forks_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/apia",
"max_forks_repo_path": "examples/ATPAxiomDataConstructors.agda",
"max_issues_count": 121,
"max_issues_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682",
"max_issues_repo_issues_event_max_datetime": "2018-04-22T06:01:44.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-25T13:22:12.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/apia",
"max_issues_repo_path": "examples/ATPAxiomDataConstructors.agda",
"max_line_length": 75,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/apia",
"max_stars_repo_path": "examples/ATPAxiomDataConstructors.agda",
"max_stars_repo_stars_event_max_datetime": "2019-12-03T13:44:25.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-03T20:54:16.000Z",
"num_tokens": 88,
"size": 270
}
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Relation.Binary.Construct.Never where
open import Cubical.Core.Everything
open import Cubical.Relation.Binary
open import Cubical.Relation.Binary.Construct.Constant
open import Cubical.Data.Empty.Polymorphic
------------------------------------------------------------------------
-- Definition
Never : ∀ {a b ℓ} {A : Type a} {B : Type b} → REL A B ℓ
Never = Const (⊥ , isProp⊥)
|
{
"alphanum_fraction": 0.6146993318,
"avg_line_length": 29.9333333333,
"ext": "agda",
"hexsha": "1be4ba3a2bf5cb0df3c229aa0ad41770a9fc7051",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bijan2005/univalent-foundations",
"max_forks_repo_path": "Cubical/Relation/Binary/Construct/Never.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "bijan2005/univalent-foundations",
"max_issues_repo_path": "Cubical/Relation/Binary/Construct/Never.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bijan2005/univalent-foundations",
"max_stars_repo_path": "Cubical/Relation/Binary/Construct/Never.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 111,
"size": 449
}
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Algebra.Matrix where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Transport
open import Cubical.Functions.FunExtEquiv
import Cubical.Data.Empty as ⊥
open import Cubical.Data.Bool
open import Cubical.Data.Nat hiding (_+_ ; +-comm ; +-assoc)
open import Cubical.Data.Vec
open import Cubical.Data.Sigma.Base
open import Cubical.Data.FinData
open import Cubical.Relation.Nullary
open import Cubical.Algebra.Group hiding (⟨_⟩)
open import Cubical.Algebra.AbGroup hiding (⟨_⟩)
open import Cubical.Algebra.Monoid hiding (⟨_⟩)
open import Cubical.Algebra.Ring
open Iso
private
variable
ℓ : Level
A : Type ℓ
-- Equivalence between Vec matrix and Fin function matrix
FinMatrix : (A : Type ℓ) (m n : ℕ) → Type ℓ
FinMatrix A m n = FinVec (FinVec A n) m
VecMatrix : (A : Type ℓ) (m n : ℕ) → Type ℓ
VecMatrix A m n = Vec (Vec A n) m
FinMatrix→VecMatrix : {m n : ℕ} → FinMatrix A m n → VecMatrix A m n
FinMatrix→VecMatrix M = FinVec→Vec (λ fm → FinVec→Vec (M fm))
VecMatrix→FinMatrix : {m n : ℕ} → VecMatrix A m n → FinMatrix A m n
VecMatrix→FinMatrix M fn fm = lookup fm (lookup fn M)
FinMatrix→VecMatrix→FinMatrix : {m n : ℕ} (M : FinMatrix A m n)
→ VecMatrix→FinMatrix (FinMatrix→VecMatrix M) ≡ M
FinMatrix→VecMatrix→FinMatrix {m = zero} M = funExt (⊥.rec ∘ ¬Fin0)
FinMatrix→VecMatrix→FinMatrix {n = zero} M = funExt₂ (λ _ → ⊥.rec ∘ ¬Fin0)
FinMatrix→VecMatrix→FinMatrix {m = suc m} {n = suc n} M = funExt₂ goal
where
goal : (fm : Fin (suc m)) (fn : Fin (suc n))
→ VecMatrix→FinMatrix (_ ∷ FinMatrix→VecMatrix (M ∘ suc)) fm fn ≡ M fm fn
goal zero zero = refl
goal zero (suc fn) i = FinVec→Vec→FinVec (M zero ∘ suc) i fn
goal (suc fm) fn i = FinMatrix→VecMatrix→FinMatrix (M ∘ suc) i fm fn
VecMatrix→FinMatrix→VecMatrix : {m n : ℕ} (M : VecMatrix A m n)
→ FinMatrix→VecMatrix (VecMatrix→FinMatrix M) ≡ M
VecMatrix→FinMatrix→VecMatrix {m = zero} [] = refl
VecMatrix→FinMatrix→VecMatrix {m = suc m} (M ∷ MS) i =
Vec→FinVec→Vec M i ∷ VecMatrix→FinMatrix→VecMatrix MS i
FinMatrixIsoVecMatrix : (A : Type ℓ) (m n : ℕ) → Iso (FinMatrix A m n) (VecMatrix A m n)
fun (FinMatrixIsoVecMatrix A m n) = FinMatrix→VecMatrix
inv (FinMatrixIsoVecMatrix A m n) = VecMatrix→FinMatrix
rightInv (FinMatrixIsoVecMatrix A m n) = VecMatrix→FinMatrix→VecMatrix
leftInv (FinMatrixIsoVecMatrix A m n) = FinMatrix→VecMatrix→FinMatrix
FinMatrix≃VecMatrix : {m n : ℕ} → FinMatrix A m n ≃ VecMatrix A m n
FinMatrix≃VecMatrix {_} {A} {m} {n} = isoToEquiv (FinMatrixIsoVecMatrix A m n)
FinMatrix≡VecMatrix : (A : Type ℓ) (m n : ℕ) → FinMatrix A m n ≡ VecMatrix A m n
FinMatrix≡VecMatrix _ _ _ = ua FinMatrix≃VecMatrix
-- Define abelian group structure on matrices
module FinMatrixAbGroup (G' : AbGroup {ℓ}) where
open AbGroup G' renaming ( Carrier to G ; is-set to isSetG )
zeroFinMatrix : ∀ {m n} → FinMatrix G m n
zeroFinMatrix _ _ = 0g
negFinMatrix : ∀ {m n} → FinMatrix G m n → FinMatrix G m n
negFinMatrix M i j = - M i j
addFinMatrix : ∀ {m n} → FinMatrix G m n → FinMatrix G m n → FinMatrix G m n
addFinMatrix M N i j = M i j + N i j
isSetFinMatrix : ∀ {m n} → isSet (FinMatrix G m n)
isSetFinMatrix = isSetΠ2 λ _ _ → isSetG
addFinMatrixAssoc : ∀ {m n} → (M N K : FinMatrix G m n)
→ addFinMatrix M (addFinMatrix N K) ≡ addFinMatrix (addFinMatrix M N) K
addFinMatrixAssoc M N K i j k = assoc (M j k) (N j k) (K j k) i
addFinMatrix0r : ∀ {m n} → (M : FinMatrix G m n)
→ addFinMatrix M zeroFinMatrix ≡ M
addFinMatrix0r M i j k = rid (M j k) i
addFinMatrix0l : ∀ {m n} → (M : FinMatrix G m n)
→ addFinMatrix zeroFinMatrix M ≡ M
addFinMatrix0l M i j k = lid (M j k) i
addFinMatrixNegMatrixr : ∀ {m n} → (M : FinMatrix G m n)
→ addFinMatrix M (negFinMatrix M) ≡ zeroFinMatrix
addFinMatrixNegMatrixr M i j k = invr (M j k) i
addFinMatrixNegMatrixl : ∀ {m n} → (M : FinMatrix G m n)
→ addFinMatrix (negFinMatrix M) M ≡ zeroFinMatrix
addFinMatrixNegMatrixl M i j k = invl (M j k) i
addFinMatrixComm : ∀ {m n} → (M N : FinMatrix G m n)
→ addFinMatrix M N ≡ addFinMatrix N M
addFinMatrixComm M N i k l = comm (M k l) (N k l) i
FinMatrixAbGroup : (m n : ℕ) → AbGroup {ℓ}
FinMatrixAbGroup m n =
makeAbGroup {G = FinMatrix G m n} zeroFinMatrix addFinMatrix negFinMatrix
isSetFinMatrix addFinMatrixAssoc addFinMatrix0r
addFinMatrixNegMatrixr addFinMatrixComm
-- Define a abelian group structure on vector matrices and prove that
-- it is equal to FinMatrixAbGroup using the SIP
module _ (G' : AbGroup {ℓ}) where
open AbGroup G' renaming ( Carrier to G )
zeroVecMatrix : ∀ {m n} → VecMatrix G m n
zeroVecMatrix = replicate (replicate 0g)
negVecMatrix : ∀ {m n} → VecMatrix G m n → VecMatrix G m n
negVecMatrix = map (map (λ x → - x))
addVec : ∀ {m} → Vec G m → Vec G m → Vec G m
addVec [] [] = []
addVec (x ∷ xs) (y ∷ ys) = x + y ∷ addVec xs ys
addVecMatrix : ∀ {m n} → VecMatrix G m n → VecMatrix G m n → VecMatrix G m n
addVecMatrix [] [] = []
addVecMatrix (M ∷ MS) (N ∷ NS) = addVec M N ∷ addVecMatrix MS NS
open FinMatrixAbGroup
-- Proof that FinMatrix→VecMatrix is a group homorphism
FinMatrix→VecMatrixHomAdd : (m n : ℕ) (M N : FinMatrix G m n)
→ FinMatrix→VecMatrix (addFinMatrix G' M N) ≡
addVecMatrix (FinMatrix→VecMatrix M) (FinMatrix→VecMatrix N)
FinMatrix→VecMatrixHomAdd zero n M N = refl
FinMatrix→VecMatrixHomAdd (suc m) n M N =
λ i → lem n (M zero) (N zero) i
∷ FinMatrix→VecMatrixHomAdd m n (λ i j → M (suc i) j) (λ i j → N (suc i) j) i
where
lem : (n : ℕ) (V W : FinVec G n)
→ FinVec→Vec (λ j → V j + W j) ≡ addVec (FinVec→Vec V) (FinVec→Vec W)
lem zero V W = refl
lem (suc n) V W = λ i → V zero + W zero ∷ lem n (V ∘ suc) (W ∘ suc) i
-- Combine everything to get an induced abelian group structure of
-- VecMatrix that is equal to the one on FinMatrix
VecMatrixAbGroup : (m n : ℕ) → AbGroup
VecMatrixAbGroup m n =
InducedAbGroup (FinMatrixAbGroup G' m n) (_ , addVecMatrix)
FinMatrix≃VecMatrix (FinMatrix→VecMatrixHomAdd m n)
FinMatrixAbGroup≡VecMatrixAbGroup : (m n : ℕ) → FinMatrixAbGroup G' m n ≡ VecMatrixAbGroup m n
FinMatrixAbGroup≡VecMatrixAbGroup m n =
InducedAbGroupPath (FinMatrixAbGroup G' m n) (_ , addVecMatrix)
FinMatrix≃VecMatrix (FinMatrix→VecMatrixHomAdd m n)
-- Define identity matrix and matrix multiplication for FinMatrix and
-- prove that square matrices form a ring
module _ (R' : Ring {ℓ}) where
open Ring R' renaming ( Carrier to R ; is-set to isSetR )
open Theory R'
open FinMatrixAbGroup (abgroup R _ _ _ (R' .Ring.+-isAbGroup))
oneFinMatrix : ∀ {n} → FinMatrix R n n
oneFinMatrix i j = if i == j then 1r else 0r
-- TODO: upstream and state for monoids
∑ : ∀ {n} → FinVec R n → R
∑ = foldrFin _+_ 0r
mulFinMatrix : ∀ {m1 m2 m3} → FinMatrix R m1 m2 → FinMatrix R m2 m3 → FinMatrix R m1 m3
mulFinMatrix M N i k = ∑ λ j → M i j · N j k
-- Properties
sumVecExt : ∀ {n} → {V W : FinVec R n} → ((i : Fin n) → V i ≡ W i) → ∑ V ≡ ∑ W
sumVecExt {n = zero} _ = refl
sumVecExt {n = suc n} h i = h zero i + sumVecExt (h ∘ suc) i
sumVecSplit : ∀ {n} → (V W : FinVec R n) → ∑ (λ i → V i + W i) ≡ ∑ V + ∑ W
sumVecSplit {n = zero} V W = sym (+-rid 0r)
sumVecSplit {n = suc n} V W =
V zero + W zero + ∑ (λ i → V (suc i) + W (suc i)) ≡⟨ (λ i → V zero + W zero + sumVecSplit (V ∘ suc) (W ∘ suc) i) ⟩
V zero + W zero + (∑ (V ∘ suc) + ∑ (W ∘ suc)) ≡⟨ sym (+-assoc _ _ _) ⟩
V zero + (W zero + (∑ (V ∘ suc) + ∑ (W ∘ suc))) ≡⟨ cong (λ x → V zero + x) (+-assoc-comm1 _ _ _) ⟩
V zero + (∑ (V ∘ suc) + (W zero + (∑ (W ∘ suc)))) ≡⟨ +-assoc _ _ _ ⟩
V zero + ∑ (V ∘ suc) + (W zero + ∑ (W ∘ suc)) ∎
sumVec0r : (n : ℕ) → ∑ (λ (i : Fin n) → 0r) ≡ 0r
sumVec0r zero = refl
sumVec0r (suc n) = cong (λ x → 0r + x) (sumVec0r n) ∙ +-rid 0r
sumVecExchange : ∀ {m n} → (M : FinMatrix R m n) → ∑ (λ i → ∑ (λ j → M i j)) ≡ ∑ (λ j → ∑ (λ i → M i j))
sumVecExchange {m = zero} {n = n} M = sym (sumVec0r n)
sumVecExchange {m = suc m} {n = zero} M = cong (λ x → 0r + x) (sumVec0r m) ∙ +-rid 0r
sumVecExchange {m = suc m} {n = suc n} M =
let a = M zero zero
L = ∑ λ j → M zero (suc j)
C = ∑ λ i → M (suc i) zero
N = ∑ λ i → ∑ λ j → M (suc i) (suc j)
-- N reindexed
N' = ∑ λ j → ∑ λ i → M (suc i) (suc j)
in a + L + ∑ (λ i → ∑ (λ j → M (suc i) j)) ≡⟨ (λ k → a + L + sumVecSplit (λ i → M (suc i) zero) (λ i → ∑ (λ j → M (suc i) (suc j))) k) ⟩
a + L + (C + N) ≡⟨ (λ k → a + L + (C + sumVecExchange (λ i j → M (suc i) (suc j)) k)) ⟩
a + L + (C + N') ≡⟨ sym (+-assoc _ _ _) ⟩
a + (L + (C + N')) ≡⟨ (λ k → a + +-assoc-comm1 L C N' k) ⟩
a + (C + (L + N')) ≡⟨ +-assoc _ _ _ ⟩
a + C + (L + N') ≡⟨ (λ k → a + C + sumVecSplit (λ j → M zero (suc j)) (λ j → ∑ (λ i → M (suc i) (suc j))) (~ k)) ⟩
a + C + ∑ (λ j → ∑ (λ i → M i (suc j))) ∎
sumVecMulrdist : ∀ {n} → (x : R) → (V : FinVec R n)
→ x · ∑ V ≡ ∑ λ i → x · V i
sumVecMulrdist {n = zero} x _ = 0-rightNullifies x
sumVecMulrdist {n = suc n} x V =
x · (V zero + ∑ (V ∘ suc)) ≡⟨ ·-rdist-+ _ _ _ ⟩
x · V zero + x · ∑ (V ∘ suc) ≡⟨ (λ i → x · V zero + sumVecMulrdist x (V ∘ suc) i) ⟩
x · V zero + ∑ (λ i → x · V (suc i)) ∎
sumVecMulldist : ∀ {n} → (x : R) → (V : FinVec R n)
→ (∑ V) · x ≡ ∑ λ i → V i · x
sumVecMulldist {n = zero} x _ = 0-leftNullifies x
sumVecMulldist {n = suc n} x V =
(V zero + ∑ (V ∘ suc)) · x ≡⟨ ·-ldist-+ _ _ _ ⟩
V zero · x + (∑ (V ∘ suc)) · x ≡⟨ (λ i → V zero · x + sumVecMulldist x (V ∘ suc) i) ⟩
V zero · x + ∑ (λ i → V (suc i) · x) ∎
sumVecMulr0 : ∀ {n} → (V : FinVec R n) → ∑ (λ i → V i · 0r) ≡ 0r
sumVecMulr0 V = sym (sumVecMulldist 0r V) ∙ 0-rightNullifies _
sumVecMul0r : ∀ {n} → (V : FinVec R n) → ∑ (λ i → 0r · V i) ≡ 0r
sumVecMul0r V = sym (sumVecMulrdist 0r V) ∙ 0-leftNullifies _
sumVecMulr1 : (n : ℕ) (V : FinVec R n) → (j : Fin n) → ∑ (λ i → V i · (if i == j then 1r else 0r)) ≡ V j
sumVecMulr1 (suc n) V zero = (λ k → ·-rid (V zero) k + sumVecMulr0 (V ∘ suc) k) ∙ +-rid (V zero)
sumVecMulr1 (suc n) V (suc j) =
(λ i → 0-rightNullifies (V zero) i + ∑ (λ x → V (suc x) · (if x == j then 1r else 0r)))
∙∙ +-lid _ ∙∙ sumVecMulr1 n (V ∘ suc) j
sumVecMul1r : (n : ℕ) (V : FinVec R n) → (j : Fin n) → ∑ (λ i → (if j == i then 1r else 0r) · V i) ≡ V j
sumVecMul1r (suc n) V zero = (λ k → ·-lid (V zero) k + sumVecMul0r (V ∘ suc) k) ∙ +-rid (V zero)
sumVecMul1r (suc n) V (suc j) =
(λ i → 0-leftNullifies (V zero) i + ∑ (λ i → (if j == i then 1r else 0r) · V (suc i)))
∙∙ +-lid _ ∙∙ sumVecMul1r n (V ∘ suc) j
mulFinMatrixAssoc : ∀ {m n k l} → (M : FinMatrix R m n) → (N : FinMatrix R n k) → (K : FinMatrix R k l)
→ mulFinMatrix M (mulFinMatrix N K) ≡ mulFinMatrix (mulFinMatrix M N) K
mulFinMatrixAssoc M N K = funExt₂ λ i j →
∑ (λ k → M i k · ∑ (λ l → N k l · K l j)) ≡⟨ sumVecExt (λ k → sumVecMulrdist (M i k) (λ l → N k l · K l j)) ⟩
∑ (λ k → ∑ (λ l → M i k · (N k l · K l j))) ≡⟨ sumVecExt (λ k → sumVecExt (λ l → ·-assoc (M i k) (N k l) (K l j))) ⟩
∑ (λ k → ∑ (λ l → M i k · N k l · K l j)) ≡⟨ sumVecExchange (λ k l → M i k · N k l · K l j) ⟩
∑ (λ l → ∑ (λ k → M i k · N k l · K l j)) ≡⟨ sumVecExt (λ l → sym (sumVecMulldist (K l j) (λ k → M i k · N k l))) ⟩
∑ (λ l → ∑ (λ k → M i k · N k l) · K l j) ∎
mulFinMatrixr1 : ∀ {m n} → (M : FinMatrix R m n) → mulFinMatrix M oneFinMatrix ≡ M
mulFinMatrixr1 M = funExt₂ λ i j → sumVecMulr1 _ (M i) j
mulFinMatrix1r : ∀ {m n} → (M : FinMatrix R m n) → mulFinMatrix oneFinMatrix M ≡ M
mulFinMatrix1r M = funExt₂ λ i j → sumVecMul1r _ (λ x → M x j) i
mulFinMatrixrDistrAddFinMatrix : ∀ {n} (M N K : FinMatrix R n n)
→ mulFinMatrix M (addFinMatrix N K) ≡ addFinMatrix (mulFinMatrix M N) (mulFinMatrix M K)
mulFinMatrixrDistrAddFinMatrix M N K = funExt₂ λ i j →
∑ (λ k → M i k · (N k j + K k j)) ≡⟨ sumVecExt (λ k → ·-rdist-+ (M i k) (N k j) (K k j)) ⟩
∑ (λ k → M i k · N k j + M i k · K k j) ≡⟨ sumVecSplit (λ k → M i k · N k j) (λ k → M i k · K k j) ⟩
∑ (λ k → M i k · N k j) + ∑ (λ k → M i k · K k j) ∎
mulFinMatrixlDistrAddFinMatrix : ∀ {n} (M N K : FinMatrix R n n)
→ mulFinMatrix (addFinMatrix M N) K ≡ addFinMatrix (mulFinMatrix M K) (mulFinMatrix N K)
mulFinMatrixlDistrAddFinMatrix M N K = funExt₂ λ i j →
∑ (λ k → (M i k + N i k) · K k j) ≡⟨ sumVecExt (λ k → ·-ldist-+ (M i k) (N i k) (K k j)) ⟩
∑ (λ k → M i k · K k j + N i k · K k j) ≡⟨ sumVecSplit (λ k → M i k · K k j) (λ k → N i k · K k j) ⟩
∑ (λ k → M i k · K k j) + ∑ (λ k → N i k · K k j) ∎
FinMatrixRing : (n : ℕ) → Ring {ℓ}
FinMatrixRing n =
makeRing {R = FinMatrix R n n} zeroFinMatrix oneFinMatrix addFinMatrix
mulFinMatrix negFinMatrix isSetFinMatrix addFinMatrixAssoc
addFinMatrix0r addFinMatrixNegMatrixr addFinMatrixComm
mulFinMatrixAssoc mulFinMatrixr1 mulFinMatrix1r
mulFinMatrixrDistrAddFinMatrix mulFinMatrixlDistrAddFinMatrix
|
{
"alphanum_fraction": 0.5709559088,
"avg_line_length": 46.4983277592,
"ext": "agda",
"hexsha": "cd982ad5929d92b3eb16ec0e7be79f930c9ff297",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "knrafto/cubical",
"max_forks_repo_path": "Cubical/Algebra/Matrix.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "knrafto/cubical",
"max_issues_repo_path": "Cubical/Algebra/Matrix.agda",
"max_line_length": 145,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "knrafto/cubical",
"max_stars_repo_path": "Cubical/Algebra/Matrix.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 5506,
"size": 13903
}
|
module _ {A : Set} (P : A → Set) where
instance
postulate
forbidden : {x : A} → P x
|
{
"alphanum_fraction": 0.5425531915,
"avg_line_length": 15.6666666667,
"ext": "agda",
"hexsha": "f9b44eff6d0998cc1d58b32379cc6284534f40ec",
"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/Issue1452-warn.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/Issue1452-warn.agda",
"max_line_length": 38,
"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/Issue1452-warn.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": 35,
"size": 94
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- This module is DEPRECATED. Please use
-- Data.Vec.Relation.Binary.Equality.Propositional directly.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Vec.Relation.Equality.Propositional where
open import Data.Vec.Relation.Binary.Equality.Propositional public
{-# WARNING_ON_IMPORT
"Data.Vec.Relation.Equality.Propositional was deprecated in v1.0.
Use Data.Vec.Relation.Binary.Equality.Propositional instead."
#-}
|
{
"alphanum_fraction": 0.5892255892,
"avg_line_length": 33,
"ext": "agda",
"hexsha": "aa79ec472e1a4683e7f1e3bb31bc71b262dd46df",
"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/Vec/Relation/Equality/Propositional.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DreamLinuxer/popl21-artifact",
"max_issues_repo_path": "agda-stdlib/src/Data/Vec/Relation/Equality/Propositional.agda",
"max_line_length": 72,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DreamLinuxer/popl21-artifact",
"max_stars_repo_path": "agda-stdlib/src/Data/Vec/Relation/Equality/Propositional.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z",
"num_tokens": 113,
"size": 594
}
|
{-# OPTIONS --without-K --safe #-}
-- Singleton type and its 'inverse'
module Singleton where
open import Data.Unit using (⊤; tt)
open import Data.Sum
open import Data.Product
open import Relation.Binary.PropositionalEquality
using (_≡_; refl; sym; trans; subst; cong ; cong₂ ; inspect ; [_])
-- open import Level
-- using (zero)
-- open import Axiom.Extensionality.Propositional
-- using (Extensionality)
is-contr : Set → Set
is-contr A = Σ A (λ a → (x : A) → a ≡ x)
is-prop : Set → Set
is-prop A = (x y : A) → x ≡ y
is-set : Set → Set
is-set A = (x y : A) → is-prop (x ≡ y)
contr-prop : {A : Set} → is-contr A → is-prop A
contr-prop (a , ϕ) x y = trans (sym (ϕ x)) (ϕ y)
apd : ∀ {a b} {A : Set a} {B : A → Set b} (f : (x : A) → B x) {x y} → (p : x ≡ y) → subst B p (f x) ≡ f y
apd f refl = refl
prop-set : {A : Set} → is-prop A → is-set A
prop-set {A} ϕ x y p q = trans (l p) (sym (l q))
where g : (z : A) → x ≡ z
g z = ϕ x z
unitr : {y z : A} (p : y ≡ z) → refl ≡ trans (sym p) p
unitr refl = refl
l : {y z : A} (p : y ≡ z) → p ≡ trans (sym (g y)) (g z)
l refl = unitr (g _)
prop-contr : {A : Set} → is-prop A → A → is-contr A
prop-contr ϕ a = a , ϕ a
------------------------------------------------------------------------------
-- Singleton type: A type with a distinguished point
-- The 'interesting' part is that the point is both a parameter
-- and a field.
{--
record Singleton (A : Set) (v : A) : Set where
constructor ⇑
field
● : A
v≡● : v ≡ ●
open Singleton public
--}
Singleton : (A : Set) → (v : A) → Set
Singleton A v = ∃ (λ ● → v ≡ ●)
-- Singleton types are contractible:
pointed-contr : {A : Set} {v : A} → is-contr (Singleton A v)
--pointed-contr {A} {v} = ⇑ v refl , λ { (⇑ ● refl) → refl }
pointed-contr {A} {v} = (v , refl) , λ { ( ● , refl) → refl }
-- and thus have all paths between them:
pointed-all-paths : {A : Set} {v : A} {p q : Singleton A v} → p ≡ q
pointed-all-paths = contr-prop pointed-contr _ _
-- What does Singleton of Singleton do?
-- Values of type Singleton A v are of the form (w , p) where p : v ≡ w
-- Values of type Singleton (Singleton A v) x
ssv : (A : Set) (v : A) (x : Singleton A v) → Singleton (Singleton A v) x
ssv A v (.v , refl) = (v , refl) , refl
{--
ss=s : (A : Set) (v : A) (x : Singleton A v) → Singleton (Singleton A v) x ≡ Singleton A v
ss=s A v (.v , refl) with pointed-contr {A} {v}
... | (.v , refl) , f = let p = f (v , refl) in {!!} -- ??
--}
------------------------------------------------------------------------------
-- The 'reciprocal' of a Singleton type is a function that accepts exactly
-- that point, and returns no information. It acts as a 'witness' that
-- the right point has been fed to it.
{--
Recip : (A : Set) → (v : A) → Set
Recip A v = (w : A) → (v ≡ w) → ⊤
--}
Recip : (A : Set) → (v : A) → Set
Recip A v = Singleton A v → ⊤
-- Recip A v = Singleton A v → ⊤
-- Recip is also contractible, if we're thinking of homotopy types.
-- We need funext to prove it which is not --safe
-- posulate
-- funext : Extensionality zero zero
-- recip-contr : {A : Set} {v : A} → is-contr (Recip A v)
-- recip-contr = (λ _ _ → tt) , λ r → funext λ _ → funext λ _ → refl
------------------------------------------------------------------------------
-- Recip' : {A : Set} {v : A} → Singleton A v → Set
-- Recip' {A} {v} (⇑ w v≡w) = v ≡ w
-- Recip'-ptd : {A : Set} {v : A} → (p : Singleton A v) → Singleton (Recip' p) (v≡● p)
-- Recip'-ptd (⇑ w v≡w) = ⇑ v≡w refl
-- family of path types from arbitrary w to a fixed v
Recip' : (A : Set) → (v : A) → Set
Recip' A v = (w : A) → v ≡ w
-- If A is a n-type, Recip' is a (n-1)-type
-- recip'-contr : {A : Set} {v : A} → is-prop A → is-contr (Recip' A v)
-- recip'-contr {A} {v} ϕ = (λ w → ϕ v w) , λ r → funext λ x → prop-set ϕ v x (ϕ v x) (r x)
-- recip'-prop : {A : Set} {v : A} → is-set A → is-prop (Recip' A v)
-- recip'-prop ϕ r s = funext (λ x → ϕ _ x (r x) (s x))
------------------------------------------------------------------------------
-- Singleton is an idempotent bimonad on pointed sets
-- (need to check some coherences)
∙Set = Σ Set (λ X → X)
∙Set[_,_] : ∙Set → ∙Set → Set
∙Set[ (A , a) , (B , b) ] = Σ (A → B) λ f → f a ≡ b
_∙×_ : ∙Set → ∙Set → ∙Set
(A , a) ∙× (B , b) = (A × B) , (a , b)
-- left version, there's also a right version
-- note that this isn't a coproduct
-- wedge sum is the coproduct
_∙+_ : ∙Set → ∙Set → ∙Set
(A , a) ∙+ (B , b) = (A ⊎ B) , inj₁ a
∙id : ∀{∙A} → ∙Set[ ∙A , ∙A ]
∙id = (λ a → a) , refl
_∘_ : ∀ {∙A ∙B ∙C} → ∙Set[ ∙A , ∙B ] → ∙Set[ ∙B , ∙C ] → ∙Set[ ∙A , ∙C ]
(f , p) ∘ (g , q) = (λ x → g (f x)) , trans (cong g p) q
-- terminal and initial
∙1 : ∙Set
∙1 = ⊤ , tt
∙![_] : ∀ ∙A → ∙Set[ ∙A , ∙1 ]
∙![ (A , a) ] = (λ _ → tt) , refl
∙!-uniq : ∀ {∙A} {x : ∙A .proj₁} → (∙f : ∙Set[ ∙A , ∙1 ]) → (∙f .proj₁) x ≡ (∙![ ∙A ] .proj₁) x
∙!-uniq {A , a} {x} (f , p) = refl
∙¡[_] : ∀ ∙A → ∙Set[ ∙1 , ∙A ]
∙¡[ A , a ] = (λ _ → a) , refl
∙¡-uniq : ∀ {∙A} → (∙f : ∙Set[ ∙1 , ∙A ]) → (∙f .proj₁) tt ≡ (∙¡[ ∙A ] .proj₁) tt
∙¡-uniq (f , p) = p
record ∙Iso[_,_] (∙A ∙B : ∙Set) : Set where
constructor iso
field
∙f : ∙Set[ ∙A , ∙B ]
∙g : ∙Set[ ∙B , ∙A ]
f = ∙f .proj₁
g = ∙g .proj₁
field
f-g : ∀ b → f (g b) ≡ b
g-f : ∀ a → g (f a) ≡ a
open ∙Iso[_,_]
∙Iso⁻¹ : ∀ {∙A ∙B} → ∙Iso[ ∙A , ∙B ] → ∙Iso[ ∙B , ∙A ]
∙Iso⁻¹ (iso ∙f ∙g f-g g-f) = iso ∙g ∙f g-f f-g
Sing : ∙Set → ∙Set
Sing (A , a) = Singleton A a , a , refl
Sing[_,_] : ∀ ∙A ∙B → ∙Set[ ∙A , ∙B ] → ∙Set[ Sing ∙A , Sing ∙B ]
Sing[ (A , a) , (B , .(f a)) ] (f , refl) = (λ { (x , refl) → f x , refl }) , refl
-- monad
η[_] : ∀ ∙A → ∙Set[ ∙A , Sing ∙A ]
η[ (A , a) ] = (λ x → a , refl) , refl
-- Sing(A) is terminal
η-uniq : ∀ {∙A} {x : ∙A .proj₁} → (∙f : ∙Set[ ∙A , Sing ∙A ]) → (∙f .proj₁) x ≡ (η[ ∙A ] .proj₁) x
η-uniq {A , a} (f , p) = pointed-all-paths
Sing≃1 : ∀ {∙A} → ∙Iso[ Sing ∙A , ∙1 ]
Sing≃1 {∙A@(A , a)} = iso ∙![ Sing ∙A ] ( ((λ _ → a) , refl) ∘ η[ ∙A ]) (λ _ → refl) (λ _ → pointed-all-paths)
μ[_] : ∀ ∙A → ∙Iso[ Sing (Sing ∙A) , Sing ∙A ]
μ[ (A , a) ] = iso ((λ { (.(a , refl) , refl) → a , refl }) , refl)
((λ { (a , refl) → (a , refl) , refl }) , refl)
(λ { (a , refl) → refl})
(λ { ((a , refl) , refl) → refl })
-- check
Sη-μ : ∀ {∙A} → ((Sing[ ∙A , Sing ∙A ] η[ ∙A ] ∘ (μ[ ∙A ] .∙f)) .proj₁) (∙A .proj₂ , refl) ≡ (∙A .proj₂ , refl)
Sη-μ = refl
ηS-μ : ∀ {∙A} → ((Sing[ Sing ∙A , Sing (Sing ∙A) ] η[ Sing ∙A ] ∘ (μ[ Sing ∙A ] .∙f)) .proj₁) ((∙A .proj₂ , refl) , refl) ≡ ((∙A .proj₂ , refl) , refl)
ηS-μ = refl
-- strength
σ×[_,_] : ∀ ∙A ∙B → ∙Set[ Sing ∙A ∙× ∙B , Sing (∙A ∙× ∙B) ]
σ×[ (A , a) , (B , b) ] = (λ { ((a , refl) , _) → (a , b) , refl }) , refl
τ×[_,_] : ∀ ∙A ∙B → ∙Set[ ∙A ∙× Sing ∙B , Sing (∙A ∙× ∙B) ]
τ×[ (A , a) , (B , b) ] = (λ { (_ , (b , refl)) → (a , b) , refl }) , refl
σ+[_,_] : ∀ ∙A ∙B → ∙Set[ Sing ∙A ∙+ ∙B , Sing (∙A ∙+ ∙B) ]
σ+[ (A , a) , (B , b) ] = (λ _ → inj₁ a , refl) , refl
τ+[_,_] : ∀ ∙A ∙B → ∙Set[ ∙A ∙+ Sing ∙B , Sing (∙A ∙+ ∙B) ]
τ+[ (A , a) , (B , b) ] = (λ _ → inj₁ a , refl) , refl
-- comonad
ε[_] : ∀ ∙A → ∙Set[ Sing ∙A , ∙A ]
ε[ (A , a) ] = (λ { (x , refl) → x }) , refl
δ[_] : ∀ ∙A → ∙Iso[ Sing ∙A , Sing (Sing ∙A) ]
δ[ ∙A ] = ∙Iso⁻¹ μ[ ∙A ]
-- check
δ-Sε : ∀ {∙A} → ((δ[ ∙A ] .∙f ∘ Sing[ Sing ∙A , ∙A ] ε[ ∙A ]) .proj₁) (∙A .proj₂ , refl) ≡ (∙A .proj₂ , refl)
δ-Sε = refl
δ-εS : ∀ {∙A} → ((δ[ Sing ∙A ] .∙f ∘ Sing[ Sing (Sing ∙A) , Sing ∙A ] ε[ Sing ∙A ]) .proj₁) ((∙A .proj₂ , refl) , refl) ≡ ((∙A .proj₂ , refl) , refl)
δ-εS = refl
-- costrength
σ'×[_,_] : ∀ ∙A ∙B → ∙Set[ Sing (∙A ∙× ∙B) , Sing ∙A ∙× ∙B ]
σ'×[ (A , a) , (B , b) ] = (λ { (.(a , b) , refl) → (a , refl) , b }) , refl
τ'×[_,_] : ∀ ∙A ∙B → ∙Set[ Sing (∙A ∙× ∙B) , ∙A ∙× Sing ∙B ]
τ'×[ (A , a) , (B , b) ] = (λ { (.(a , b) , refl) → a , (b , refl) }) , refl
σ'+[_,_] : ∀ ∙A ∙B → ∙Set[ Sing (∙A ∙+ ∙B) , Sing ∙A ∙+ ∙B ]
σ'+[ (A , a) , (B , b) ] = (λ _ → inj₁ (a , refl)) , refl
τ'+[_,_] : ∀ ∙A ∙B → ∙Set[ Sing (∙A ∙+ ∙B) , ∙A ∙+ Sing ∙B ]
τ'+[ (A , a) , (B , b) ] = (λ _ → inj₁ a) , refl
-- even better, strong monoidal functor
ν×[_,_] : ∀ ∙A ∙B → ∙Iso[ Sing ∙A ∙× Sing ∙B , Sing (∙A ∙× ∙B) ]
ν×[ (A , a) , (B , b) ] = iso ((λ _ → (a , b) , refl) , refl)
((λ _ → (a , refl) , b , refl) , refl)
(λ { (.(a , b) , refl) → refl })
(λ { ((a , refl) , (b , refl)) → refl })
-- this one is only lax
ν+[_,_] : ∀ ∙A ∙B → ∙Set[ Sing ∙A ∙+ Sing ∙B , Sing (∙A ∙+ ∙B) ]
ν+[ (A , a) , (B , b) ] = (λ _ → inj₁ a , refl) , refl
-- free pointed set
U : ∙Set → Set
U = proj₁
U[_,_] : ∀ ∙A ∙B → ∙Set[ ∙A , ∙B ] → (U ∙A → U ∙B)
U[ _ , _ ] = proj₁
F : Set → ∙Set
F A = (A ⊎ ⊤) , inj₂ tt
F[_,_] : ∀ A B → (A → B) → ∙Set[ F A , F B ]
F[ A , B ] f = (λ { (inj₁ a) → inj₁ (f a) ; (inj₂ tt) → inj₂ tt }) , refl
->adj : ∀ {A ∙B} → (A → U ∙B) → ∙Set[ F A , ∙B ]
->adj f = (λ { (inj₁ a) → f a ; (inj₂ tt) → _ }) , refl
<-adj : ∀ {A ∙B} → ∙Set[ F A , ∙B ] → (A → U ∙B)
<-adj (f , refl) a = f (inj₁ a)
η-adj : ∀ {A} → (A → U (F A))
η-adj = <-adj ∙id
ε-adj : ∀ {∙A} → ∙Set[ F (U ∙A), ∙A ]
ε-adj = ->adj λ x → x
-- maybe monad
T : Set → Set
T A = U (F A)
T-η[_] : ∀ A → (A → T A)
T-η[ A ] = η-adj
T-μ[_] : ∀ A → (T (T A) → T A)
T-μ[ A ] = U[ F (T A) , F A ] ε-adj
-- comaybe comonad
D : ∙Set → ∙Set
D ∙A = F (U ∙A)
D-ε[_] : ∀ ∙A → ∙Set[ D ∙A , ∙A ]
D-ε[ ∙A ] = ε-adj
D-δ[_] : ∀ ∙A → ∙Set[ D ∙A , D (D ∙A) ]
D-δ[ ∙A ] = F[ U ∙A , U (D ∙A) ] η-adj
-- but also
D-η[_] : ∀ ∙A → ∙Set[ ∙A , D ∙A ]
D-η[ ∙A ] = (λ _ → inj₂ tt) , refl
-- D ∙A is not contractible
-- distributive laws?
-- same as ∙Set[ ∙1 , D ∙1 ] so follows D-η
Λ : ∀ {∙A} → ∙Set[ Sing (D ∙A) , D (Sing ∙A) ]
Λ = (λ { (.(inj₂ tt) , refl) → inj₂ tt }) , refl
|
{
"alphanum_fraction": 0.4375572519,
"avg_line_length": 30.7993730408,
"ext": "agda",
"hexsha": "0ec54904ef9ae3e6f8039e3004035d13472975ae",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z",
"max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "JacquesCarette/pi-dual",
"max_forks_repo_path": "fracGC/Singleton.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "JacquesCarette/pi-dual",
"max_issues_repo_path": "fracGC/Singleton.agda",
"max_line_length": 151,
"max_stars_count": 14,
"max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "JacquesCarette/pi-dual",
"max_stars_repo_path": "fracGC/Singleton.agda",
"max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z",
"num_tokens": 4565,
"size": 9825
}
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Categories.Equivalence.Properties where
open import Cubical.Foundations.Prelude
open import Cubical.Data.Sigma
open import Cubical.Categories.Category
open import Cubical.Categories.Functor
open import Cubical.Categories.NaturalTransformation
open import Cubical.Categories.Morphism
open import Cubical.Categories.Equivalence.Base
open import Cubical.HITs.PropositionalTruncation.Base
open Precategory
open Functor
open NatIso
open CatIso
open NatTrans
open isEquivalence
private
variable
ℓC ℓC' ℓD ℓD' : Level
-- Equivalence implies Full, Faithul, and Essentially Surjective
module _ {C : Precategory ℓC ℓC'} {D : Precategory ℓD ℓD'} where
symEquiv : ∀ {F : Functor C D} → (e : isEquivalence F) → isEquivalence (e .invFunc)
symEquiv {F} record { invFunc = G ; η = η ; ε = ε } = record { invFunc = F ; η = symNatIso ε ; ε = symNatIso η }
isEquiv→Faithful : ∀ {F : Functor C D} → isEquivalence F → isFaithful F
isEquiv→Faithful {F} record { invFunc = G
; η = η
; ε = _ }
c c' f g p = f
≡⟨ sqRL η ⟩
cIso .mor ⋆⟨ C ⟩ G ⟪ F ⟪ f ⟫ ⟫ ⋆⟨ C ⟩ c'Iso .inv
≡⟨ cong (λ v → cIso .mor ⋆⟨ C ⟩ (G ⟪ v ⟫) ⋆⟨ C ⟩ c'Iso .inv) p ⟩
cIso .mor ⋆⟨ C ⟩ G ⟪ F ⟪ g ⟫ ⟫ ⋆⟨ C ⟩ c'Iso .inv
≡⟨ sym (sqRL η) ⟩
g
∎
where
-- isomorphism between c and GFc
cIso = isIso→CatIso (η .nIso c)
-- isomorphism between c' and GFc'
c'Iso = isIso→CatIso (η .nIso c')
module _ {C : Precategory ℓC ℓC'} {D : Precategory ℓD ℓD'} where
isEquiv→Full : ∀ {F : Functor C D} → isEquivalence F → isFull F
isEquiv→Full {F} eq@record { invFunc = G
; η = η
; ε = _ }
c c' g = ∣ h , isEquiv→Faithful (symEquiv eq) _ _ _ _ GFh≡Gg ∣ -- apply faithfulness of G
where
-- isomorphism between c and GFc
cIso = isIso→CatIso (η .nIso c)
-- isomorphism between c' and GFc'
c'Iso = isIso→CatIso (η .nIso c')
-- reverses
cIso⁻ = symCatIso cIso
c'Iso⁻ = symCatIso c'Iso
h = cIso .mor ⋆⟨ C ⟩ G ⟪ g ⟫ ⋆⟨ C ⟩ c'Iso .inv
-- we show that both `G ⟪ g ⟫` and `G ⟪ F ⟪ h ⟫ ⟫`
-- are equal to the same thing
-- namely : cIso .inv ⋆⟨ C ⟩ h ⋆⟨ C ⟩ c'Iso .mor
Gg≡ηhη : G ⟪ g ⟫ ≡ cIso .inv ⋆⟨ C ⟩ h ⋆⟨ C ⟩ c'Iso .mor
Gg≡ηhη = invMoveL cAreInv move-c' ∙ sym (C .⋆Assoc _ _ _)
where
cAreInv : areInv (cIso .mor) (cIso .inv)
cAreInv = CatIso→areInv cIso
c'AreInv : areInv (c'Iso .mor) (c'Iso .inv)
c'AreInv = CatIso→areInv c'Iso
move-c' : cIso .mor ⋆⟨ C ⟩ G ⟪ g ⟫ ≡ h ⋆⟨ C ⟩ c'Iso .mor
move-c' = invMoveR (symAreInv c'AreInv) refl
GFh≡Gg : G ⟪ F ⟪ h ⟫ ⟫ ≡ G ⟪ g ⟫
GFh≡Gg = G ⟪ F ⟪ h ⟫ ⟫
≡⟨ sqLR η ⟩
cIso .inv ⋆⟨ C ⟩ h ⋆⟨ C ⟩ c'Iso .mor
≡⟨ sym Gg≡ηhη ⟩
G ⟪ g ⟫
∎
isEquiv→Surj : ∀ {F : Functor C D} → isEquivalence F → isEssentiallySurj F
isEquiv→Surj isE d = (isE .invFunc ⟅ d ⟆) , isIso→CatIso ((isE .ε .nIso) d)
|
{
"alphanum_fraction": 0.5172721858,
"avg_line_length": 36.1075268817,
"ext": "agda",
"hexsha": "462072d528d32532d386e10779b62fa97dfa48c3",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dan-iel-lee/cubical",
"max_forks_repo_path": "Cubical/Categories/Equivalence/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "dan-iel-lee/cubical",
"max_issues_repo_path": "Cubical/Categories/Equivalence/Properties.agda",
"max_line_length": 114,
"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/Categories/Equivalence/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1269,
"size": 3358
}
|
------------------------------------------------------------------------------
-- Properties of the Collatz function
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOTC.Program.Collatz.PropertiesATP where
open import FOTC.Base
open import FOTC.Data.Nat
open import FOTC.Data.Nat.PropertiesATP using ( ∸-N )
open import FOTC.Data.Nat.UnaryNumbers
open import FOTC.Data.Nat.UnaryNumbers.TotalityATP using ( 2-N )
open import FOTC.Program.Collatz.Collatz
open import FOTC.Program.Collatz.Data.Nat
open import FOTC.Program.Collatz.Data.Nat.PropertiesATP
------------------------------------------------------------------------------
helper : ∀ {n} → N n → collatz (2' ^ succ₁ n) ≡ collatz (2' ^ n)
helper nzero = prf
where postulate prf : collatz (2' ^ succ₁ zero) ≡ collatz (2' ^ zero)
{-# ATP prove prf #-}
helper (nsucc {n} Nn) = prf
where postulate prf : collatz (2' ^ succ₁ (succ₁ n)) ≡ collatz (2' ^ succ₁ n)
{-# ATP prove prf +∸2 ^-N 2-N 2^x≢0 2^[x+1]≢1 div-2^[x+1]-2≡2^x
x-Even→SSx-Even ∸-N ∸-Even 2^[x+1]-Even 2-Even
#-}
collatz-2^x : ∀ {n} → N n → collatz (2' ^ n) ≡ 1'
collatz-2^x nzero = prf
where postulate prf : collatz (2' ^ 0') ≡ 1'
{-# ATP prove prf #-}
collatz-2^x (nsucc {n} Nn) = prf (collatz-2^x Nn)
where postulate prf : collatz (2' ^ n) ≡ 1' → collatz (2' ^ succ₁ n) ≡ 1'
{-# ATP prove prf helper #-}
|
{
"alphanum_fraction": 0.5161691542,
"avg_line_length": 39.2195121951,
"ext": "agda",
"hexsha": "e864b352e6809fb9934687c5a58c5f5f1f95f5ae",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z",
"max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/fotc",
"max_forks_repo_path": "src/fot/FOTC/Program/Collatz/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": "src/fot/FOTC/Program/Collatz/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": "src/fot/FOTC/Program/Collatz/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": 509,
"size": 1608
}
|
{-# OPTIONS --sized-types #-}
module SNat where
open import Data.Nat hiding (_+_)
open import Size
data SNat : {ι : Size} → Set where
zero : {ι : Size}
→ SNat {↑ ι}
succ : {ι : Size}
→ SNat {ι}
→ SNat {↑ ι}
subtyping : {ι : Size} → SNat {ι} → SNat {↑ ι}
subtyping zero = zero
subtyping (succ n) = succ (subtyping n)
_/2 : {ι : Size} → SNat { ι} → SNat {ι}
zero /2 = zero
(succ zero) /2 = zero
(succ (succ n)) /2 = subtyping (succ (n /2))
log₂ : {ι : Size} → SNat {ι} → SNat {ι}
log₂ zero = zero
log₂ (succ zero) = zero
log₂ (succ (succ n)) = succ (log₂ (succ (n /2)))
_+_ : SNat → SNat → SNat
zero + n = n
(succ m) + n = succ (m + n)
toNat : SNat → ℕ
toNat zero = zero
toNat (succ n) = suc (toNat n)
|
{
"alphanum_fraction": 0.5259067358,
"avg_line_length": 22.0571428571,
"ext": "agda",
"hexsha": "701dd3da97934720031f5458f53dd6a9c15a98d9",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bgbianchi/sorting",
"max_forks_repo_path": "agda/SNat.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "bgbianchi/sorting",
"max_issues_repo_path": "agda/SNat.agda",
"max_line_length": 48,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bgbianchi/sorting",
"max_stars_repo_path": "agda/SNat.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": 291,
"size": 772
}
|
module nat-log-test where
open import eq
open import nat
open import nat-log
test : log-result 11 3
test = log 11 3 refl refl
exp-from-test : ℕ
exp-from-test with test
exp-from-test | pos-power e s p = e
exp-from-test | no-power p = 0
|
{
"alphanum_fraction": 0.7142857143,
"avg_line_length": 17,
"ext": "agda",
"hexsha": "25d96ec5109803b715265f8f5f95e1ae1513c862",
"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": "nat-log-test.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": "nat-log-test.agda",
"max_line_length": 35,
"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": "nat-log-test.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": 73,
"size": 238
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- The Thunk wrappers for sized codata, copredicates and corelations
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe --sized-types #-}
module Codata.Thunk where
open import Size
open import Relation.Unary
------------------------------------------------------------------------
-- Basic types.
record Thunk {ℓ} (F : Size → Set ℓ) (i : Size) : Set ℓ where
coinductive
field force : {j : Size< i} → F j
open Thunk public
Thunk^P : ∀ {f p} {F : Size → Set f} (P : Size → F ∞ → Set p)
(i : Size) (tf : Thunk F ∞) → Set p
Thunk^P P i tf = Thunk (λ i → P i (tf .force)) i
Thunk^R : ∀ {f g r} {F : Size → Set f} {G : Size → Set g}
(R : Size → F ∞ → G ∞ → Set r)
(i : Size) (tf : Thunk F ∞) (tg : Thunk G ∞) → Set r
Thunk^R R i tf tg = Thunk (λ i → R i (tf .force) (tg .force)) i
------------------------------------------------------------------------
-- Syntax
Thunk-syntax : ∀ {ℓ} → (Size → Set ℓ) → Size → Set ℓ
Thunk-syntax = Thunk
syntax Thunk-syntax (λ j → e) i = Thunk[ j < i ] e
------------------------------------------------------------------------
-- Basic functions.
-- Thunk is a functor
module _ {p q} {P : Size → Set p} {Q : Size → Set q} where
map : ∀[ P ⇒ Q ] → ∀[ Thunk P ⇒ Thunk Q ]
map f p .force = f (p .force)
-- Thunk is a comonad
module _ {p} {P : Size → Set p} where
extract : ∀[ Thunk P ] → P ∞
extract p = p .force
duplicate : ∀[ Thunk P ⇒ Thunk (Thunk P) ]
duplicate p .force .force = p .force
module _ {p q} {P : Size → Set p} {Q : Size → Set q} where
infixl 1 _<*>_
_<*>_ : ∀[ Thunk (P ⇒ Q) ⇒ Thunk P ⇒ Thunk Q ]
(f <*> p) .force = f .force (p .force)
-- We can take cofixpoints of functions only making Thunk'd recursive calls
module _ {p} (P : Size → Set p) where
cofix : ∀[ Thunk P ⇒ P ] → ∀[ P ]
cofix f = f λ where .force → cofix f
|
{
"alphanum_fraction": 0.458958959,
"avg_line_length": 29.3823529412,
"ext": "agda",
"hexsha": "4da100a2c1cb52c8182746aaee47bf68df89ff72",
"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": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "omega12345/agda-mode",
"max_forks_repo_path": "test/asset/agda-stdlib-1.0/Codata/Thunk.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/Codata/Thunk.agda",
"max_line_length": 75,
"max_stars_count": 5,
"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/Codata/Thunk.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": 622,
"size": 1998
}
|
{-# OPTIONS --cubical #-}
module TranspComputing where
open import Agda.Builtin.Cubical.Path
open import Agda.Primitive.Cubical
open import Agda.Builtin.List
transpList : ∀ (φ : I) (A : Set) x xs → primTransp (λ _ → List A) φ (x ∷ xs) ≡ (primTransp (λ i → A) φ x ∷ primTransp (λ i → List A) φ xs)
transpList φ A x xs = \ _ → primTransp (λ _ → List A) φ (x ∷ xs)
data S¹ : Set where
base : S¹
loop : base ≡ base
-- This should be refl.
transpS¹ : ∀ (φ : I) (u0 : S¹) → primTransp (λ _ → S¹) φ u0 ≡ u0
transpS¹ φ u0 = \ _ → u0
|
{
"alphanum_fraction": 0.6231343284,
"avg_line_length": 26.8,
"ext": "agda",
"hexsha": "333eaa32ea99528886e89632b80ab275e22a8310",
"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/TranspComputing.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/TranspComputing.agda",
"max_line_length": 138,
"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/TranspComputing.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": 214,
"size": 536
}
|
-- {-# OPTIONS -v interaction:50 #-}
module Issue841 where
postulate
D : Set
c : (A : Set) (B : Set1) → D
e : (A : Set) (B : Set1) (C : Set2) (X : Set3) → D
-- When the following is refined the goals end up being the wrong way
-- around.
bad : D
bad = {!c ?!}
-- I.e. bad ?3 ?2 instead of bad ?2 ?3.
-- Andreas, 2013-05-01 should now be correct.
bad' : D
bad' = {!e ? ?!}
-- This works:
good : D
good = {!c!}
also-good : D
also-good = {!c ? ?!}
|
{
"alphanum_fraction": 0.5502183406,
"avg_line_length": 16.962962963,
"ext": "agda",
"hexsha": "2b673a733c970a3ec4ac6362e6e751454d17f1b0",
"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/Issue841.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/Issue841.agda",
"max_line_length": 69,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/interaction/Issue841.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": 172,
"size": 458
}
|
{-# OPTIONS --cubical-compatible #-}
module Common.Maybe where
data Maybe {a} (A : Set a) : Set a where
nothing : Maybe A
just : A → Maybe A
|
{
"alphanum_fraction": 0.6308724832,
"avg_line_length": 21.2857142857,
"ext": "agda",
"hexsha": "d8630b1bc305e10fb7f264d938c7716e2b541464",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "KDr2/agda",
"max_forks_repo_path": "test/Common/Maybe.agda",
"max_issues_count": 6,
"max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "KDr2/agda",
"max_issues_repo_path": "test/Common/Maybe.agda",
"max_line_length": 40,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "KDr2/agda",
"max_stars_repo_path": "test/Common/Maybe.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 44,
"size": 149
}
|
module Reduction where
open import Data.Sum
open import Library
open import Terms
open import Substitution
open import TermShape
open import SN
data βECxt (Γ : Cxt) : (Δ : Cxt) (a b : Ty) → Set where
appl : ∀ {a b} (u : Tm Γ a) → βECxt Γ Γ (a →̂ b) b
appr : ∀ {a b} (t : Tm Γ (a →̂ b)) → βECxt Γ Γ a b
abs : ∀ {a b} → βECxt Γ (a ∷ Γ) b (a →̂ b)
data βEhole {Γ : Cxt} : {Δ : Cxt} {b a : Ty} → Tm Γ b → βECxt Γ Δ a b → Tm Δ a → Set where
appl : ∀ {a b} {t : Tm Γ (a →̂ b)} (u : Tm Γ a) → βEhole (app t u) (appl u) t
appr : ∀ {a b u} (t : Tm Γ (a →̂ b)) → βEhole (app t u) (appr t) u
abs : ∀ {a b} {t : Tm (a ∷ Γ) b} → βEhole (abs t) abs t
-- Plugging a hole
mkHole : ∀ {Γ Δ} {a b} (E : βECxt Γ Δ a b) {t} → ∃ λ E[t] → βEhole E[t] E t
mkHole (appl u) = _ , appl u
mkHole (appr t) = _ , appr t
mkHole abs = _ , abs
data _⇒β_ {Γ} : ∀ {a} → Tm Γ a → Tm Γ a → Set where
β : ∀ {a b}{t : Tm (a ∷ Γ) b}{u}
→ (app (abs t) u) ⇒β subst0 u t
cong : ∀ {Δ a b t t' Et Et'}{E : βECxt Γ Δ a b}
→ (𝑬𝒕 : βEhole Et E t)
→ (𝑬𝒕' : βEhole Et' E t')
→ (t⇒β : t ⇒β t')
→ Et ⇒β Et'
subst⇒β : ∀ {m vt a Γ} {t t' : Tm Γ a} {Δ}
(σ : RenSub {m} vt Γ Δ) → t ⇒β t' → subst σ t ⇒β subst σ t'
subst⇒β σ (β {t = t} {u = u}) = ≡.subst (λ t' → app (abs (subst (lifts σ) t)) (subst σ u) ⇒β t')
(sgs-lifts-term {σ = σ} {u} {t})
β
subst⇒β σ (cong (appl u) (appl .u) t⇒) = cong (appl _) (appl _) (subst⇒β σ t⇒)
subst⇒β σ (cong (appr t) (appr .t) t⇒) = cong (appr _) (appr _) (subst⇒β σ t⇒)
subst⇒β σ (cong abs abs t⇒) = cong abs abs (subst⇒β (lifts σ) t⇒)
-- Multi-step β-reduction (β-reduction sequences).
-- Reflexive-transitive closure of single-step β-reduction.
infix 7 _⇒β_ _⇒β*_
data _⇒β*_ {Γ} {a} : Tm Γ a → Tm Γ a → Set where
[] : ∀ {t} → t ⇒β* t
_∷_ : ∀ {ti tm to} → ti ⇒β tm → tm ⇒β* to → ti ⇒β* to
-- Concatenating β-reduction sequences
_++β_ : ∀ {Γ} {a} {t₀ t₁ t₂ : Tm Γ a} → t₀ ⇒β* t₁ → t₁ ⇒β* t₂ → t₀ ⇒β* t₂
[] ++β ys = ys
(x ∷ xs) ++β ys = x ∷ (xs ++β ys)
-- Multi-step β-reduction is compatible with term constructors.
cong* : ∀ {a Γ Δ} {b} {t tβ* : Tm Γ a} {E : βECxt Δ Γ a b} {E[t] E[tβ*]}
→ βEhole E[t] E t
→ βEhole E[tβ*] E tβ*
→ t ⇒β* tβ*
→ E[t] ⇒β* E[tβ*]
cong* E1 E2 (x ∷ t⇒) = cong E1 (proj₂ (mkHole _)) x ∷ cong* (proj₂ (mkHole _)) E2 t⇒
cong* (appl u) (appl .u) [] = []
cong* (appr t₁) (appr .t₁) [] = []
cong* abs abs [] = []
EC→βEC : ∀ {Γ} {a b} (E : ECxt Γ a b) → βECxt Γ Γ a b
EC→βEC (appl u) = appl u
mkHole4 : ∀ {Γ} {a b} (E : ECxt Γ a b) {t : Tm Γ a} → βEhole (E [ t ]) (EC→βEC E) t
mkHole4 (appl u) = appl u
cong*3 : ∀ {Γ a b t t'}(E : ECxt* Γ a b)
→ (t⇒ : t ⇒β t')
→ E [ t ]* ⇒β E [ t' ]*
cong*3 [] t⇒ = t⇒
cong*3 (x ∷ E) t⇒ = cong*3 E (cong (mkHole4 x) (mkHole4 x) t⇒)
cong*4 : ∀ {Γ a b t t'}(E : ECxt* Γ a b)
→ (t⇒ : t ⇒β* t')
→ E [ t ]* ⇒β* E [ t' ]*
cong*4 E [] = []
cong*4 E (x ∷ xs) = cong*3 E x ∷ cong*4 E xs
subst⇒β*₀ : ∀ {m vt a Γ} {t t' : Tm Γ a} {Δ} (σ : RenSub {m} vt Γ Δ) → t ⇒β* t' → subst σ t ⇒β* subst σ t'
subst⇒β*₀ σ [] = []
subst⇒β*₀ σ (x ∷ xs) = (subst⇒β σ x) ∷ (subst⇒β*₀ σ xs)
mutual
subst⇒β* : ∀ {m vt a Γ} {Δ} {σ ρ : RenSub {m} vt Γ Δ}
→ (∀ {b} (x : Var Γ b) → vt2tm _ (σ x) ⇒β* vt2tm _ (ρ x))
→ (t : Tm Γ a)
→ subst σ t ⇒β* subst ρ t
subst⇒β* σ₁ (var x) = σ₁ x
subst⇒β* {vt = vt} σ₁ (abs t) = cong* abs abs (subst⇒β* (lifts⇒β* {vt = vt} σ₁) t)
subst⇒β* σ₁ (app t t₁) = cong* (appl _) (appl _) (subst⇒β* σ₁ t) ++β cong* (appr _) (appr _) (subst⇒β* σ₁ t₁)
lifts⇒β* : ∀ {m vt a Γ} {Δ} {σ ρ : RenSub {m} vt Γ Δ}
→ (∀ {b} (x : Var Γ b) → vt2tm _ (σ x) ⇒β* vt2tm _ (ρ x))
→ ∀ {b} (x : Var (a ∷ Γ) b)
→ vt2tm _ (lifts {a = a} σ x) ⇒β* vt2tm _ (lifts {a = a} ρ x)
lifts⇒β* {vt = `Var} σ (zero) = []
lifts⇒β* {vt = `Tm} σ (zero) = []
lifts⇒β* {vt = `Var} σ (suc x) = subst⇒β*₀ {vt = `Var} suc (σ x)
lifts⇒β* {vt = `Tm} σ (suc x) = subst⇒β*₀ {vt = `Var} suc (σ x)
-- Altenkirch's weak standardization lemma.
mutual
beta-shr : ∀ {i a Γ} {t tβ th : Tm Γ a}
→ t ⇒β tβ
→ t ⟨ i ⟩⇒ th
→ (tβ ≡ th) ⊎ ∃ λ t' → tβ ⟨ i ⟩⇒ t' × th ⇒β* t'
beta-shr β (β 𝒖) = inj₁ ≡.refl
beta-shr (cong (appl u) (appl .u) (cong abs abs tβ⇒)) (β 𝒖) = inj₂ (_ , β 𝒖 , (subst⇒β (sgs u) tβ⇒ ∷ []))
beta-shr (cong (appr ._) (appr ._) tβ⇒) (β {t = t} 𝒖)
= inj₂ (_ , β (mapβSN tβ⇒ 𝒖) , subst⇒β* {vt = `Tm} (λ { {._} (zero) → tβ⇒ ∷ [] ; (suc x) → [] }) t)
beta-shr β (cong (appl u) (appl .u) (cong () 𝑬𝒕' th⇒))
beta-shr (cong E1 E2 t⇒) (cong E0 E3 th⇒) = helper E1 E2 t⇒ E0 E3 th⇒
where
helper : ∀ {i}{a Γ} {t tβ th : Tm Γ a} {Δ a₁} {t₁ ta : Tm Δ a₁}
{E : βECxt Γ Δ a₁ a} {a₂} {t₂ tb : Tm Γ a₂} {E₁ : ECxt Γ a₂ a}
→ βEhole t E t₁
→ βEhole tβ E ta
→ t₁ ⇒β ta
→ Ehole t E₁ t₂
→ Ehole th E₁ tb
→ t₂ ⟨ i ⟩⇒ tb
→ tβ ≡ th ⊎ ∃ λ t' → tβ ⟨ i ⟩⇒ t' × th ⇒β* t'
helper (appl u) (appl .u) t⇒₁ (appl .u) (appl .u) th⇒₁ with beta-shr t⇒₁ th⇒₁
helper (appl u) (appl .u) t⇒₁ (appl .u) (appl .u) th⇒₁ | inj₁ ≡.refl = inj₁ ≡.refl
helper (appl u) (appl .u) t⇒₁ (appl .u) (appl .u) th⇒₁ | inj₂ (tm , h⇒tm , tm⇒β)
= inj₂ (_ , cong (appl _) (appl _) h⇒tm , cong* (appl _) (appl _) tm⇒β)
helper (appr t₂) (appr .t₂) t⇒₁ (appl t₁) (appl .t₁) th⇒₁ = inj₂ (_ , cong (appl _) (appl _) th⇒₁ , (cong (appr _) (appr _) t⇒₁ ∷ []))
-- SNe is preserved under reduction.
mapβSNe : ∀ {i a Γ} {t t' : Tm Γ a}
→ t ⇒β t'
→ SNe {i} t
→ SNe {i} t'
mapβSNe (cong (appl u) (appl .u) t⇒) (elim 𝒏 (appl 𝒖)) = elim (mapβSNe t⇒ 𝒏) (appl 𝒖)
mapβSNe (cong (appr u) (appr .u) t⇒) (elim 𝒏 (appl 𝒖)) = elim 𝒏 (appl (mapβSN t⇒ 𝒖))
-- The other cases are impossible
mapβSNe (cong abs abs t⇒) (elim 𝒏 ())
mapβSNe β (elim (elim 𝒏 ()) (appl 𝒖))
-- SN is preserved under reduction.
mapβSN : ∀ {i a Γ} {t t' : Tm Γ a}
→ t ⇒β t'
→ SN {i} t
→ SN {i} t'
mapβSN t⇒ (ne 𝒏) = ne (mapβSNe t⇒ 𝒏)
mapβSN (cong abs abs t⇒) (abs 𝒕) = abs (mapβSN t⇒ 𝒕)
mapβSN t⇒ (exp t⇒₁ 𝒕) with beta-shr t⇒ t⇒₁
mapβSN t⇒ (exp t⇒₁ 𝒕) | inj₁ ≡.refl = 𝒕
mapβSN t⇒ (exp t⇒₁ 𝒕) | inj₂ (_ , t⇒h , t⇒β*) = exp t⇒h (mapβ*SN t⇒β* 𝒕)
-- SN is preserved under multi-step reduction.
mapβ*SN : ∀ {i a Γ} {t t' : Tm Γ a}
→ t ⇒β* t'
→ SN {i} t
→ SN {i} t'
mapβ*SN [] 𝒕 = 𝒕
mapβ*SN (t⇒ ∷ t⇒β*) 𝒕 = mapβ*SN t⇒β* (mapβSN t⇒ 𝒕)
|
{
"alphanum_fraction": 0.4495786109,
"avg_line_length": 39.1022727273,
"ext": "agda",
"hexsha": "86e2a84bacd45720d9a95383fd714ee9daa6a604",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2018-02-23T18:22:17.000Z",
"max_forks_repo_forks_event_min_datetime": "2017-11-10T16:44:52.000Z",
"max_forks_repo_head_hexsha": "79d97481f3312c2d30a823c3b1bcb8ae871c2fe2",
"max_forks_repo_licenses": [
"Unlicense"
],
"max_forks_repo_name": "ryanakca/strong-normalization",
"max_forks_repo_path": "agda-aplas14/Reduction.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "79d97481f3312c2d30a823c3b1bcb8ae871c2fe2",
"max_issues_repo_issues_event_max_datetime": "2018-02-20T14:54:18.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-02-14T16:42:36.000Z",
"max_issues_repo_licenses": [
"Unlicense"
],
"max_issues_repo_name": "ryanakca/strong-normalization",
"max_issues_repo_path": "agda-aplas14/Reduction.agda",
"max_line_length": 140,
"max_stars_count": 32,
"max_stars_repo_head_hexsha": "79d97481f3312c2d30a823c3b1bcb8ae871c2fe2",
"max_stars_repo_licenses": [
"Unlicense"
],
"max_stars_repo_name": "ryanakca/strong-normalization",
"max_stars_repo_path": "agda-aplas14/Reduction.agda",
"max_stars_repo_stars_event_max_datetime": "2021-03-05T12:12:03.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-05-22T14:33:27.000Z",
"num_tokens": 3456,
"size": 6882
}
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
open import Cubical.Relation.Binary.Base
open import Cubical.Core.Everything
module Cubical.Relation.Binary.Raw.Structures
{a ℓ} {A : Type a} -- The underlying type
(_<>_ : RawRel A ℓ) -- The relation
where
open import Cubical.Foundations.Prelude using (refl; sym)
open import Cubical.Foundations.Function using (_∘_)
open import Cubical.Data.Prod.Base using (proj₁; proj₂; _,_)
open import Cubical.Relation.Nullary.Decidable
open import Cubical.Relation.Binary.Raw.Definitions
open import Cubical.Relation.Binary.Raw.Properties
private
variable
ℓ₂ : Level
------------------------------------------------------------------------
-- Preorders
------------------------------------------------------------------------
record IsPreorder : Type (ℓ-max a ℓ) where
constructor ispreorder
field
reflexive : Reflexive _<>_
transitive : Transitive _<>_
fromEq : FromEq _<>_
fromEq = reflx→fromeq _<>_ reflexive
------------------------------------------------------------------------
-- Equivalences
------------------------------------------------------------------------
record IsPartialEquivalence : Type (ℓ-max a ℓ) where
constructor ispartialeq
field
symmetric : Symmetric _<>_
transitive : Transitive _<>_
record IsEquivalence : Type (ℓ-max a ℓ) where
constructor isequivalence
field
reflexive : Reflexive _<>_
isPartialEquivalence : IsPartialEquivalence
open IsPartialEquivalence isPartialEquivalence public
from-≡ : FromEq _<>_
from-≡ = reflx→fromeq _<>_ reflexive
isPreorder : IsPreorder
isPreorder = record
{ reflexive = reflexive
; transitive = transitive
}
record IsDecEquivalence : Type (ℓ-max a ℓ) where
constructor isdeceq
infix 4 _≟_
field
isEquivalence : IsEquivalence
_≟_ : Decidable _<>_
open IsEquivalence isEquivalence public
------------------------------------------------------------------------
-- Partial orders
------------------------------------------------------------------------
record IsPartialOrder : Type (ℓ-max a ℓ) where
constructor ispartialorder
field
isPreorder : IsPreorder
antisym : Antisymmetric _<>_
open IsPreorder isPreorder public
record IsDecPartialOrder : Type (ℓ-max a ℓ) where
constructor isdecpartialorder
infix 4 _≤?_
field
isPartialOrder : IsPartialOrder
_≤?_ : Decidable _<>_
open IsPartialOrder isPartialOrder public
private
lemma : ∀ {x y} → ¬ x <> y → ¬ x ≡ y
lemma x≰y x≡y = x≰y (fromEq x≡y)
_≟_ : Discrete A
_≟_ x y with x ≤? y
... | no ¬p = no (lemma ¬p)
... | yes p with y ≤? x
... | no ¬q = no (lemma ¬q ∘ sym)
... | yes q = yes (antisym p q)
record IsStrictPartialOrder : Type (ℓ-max a ℓ) where
constructor isstrictpartialorder
field
irrefl : Irreflexive _<>_
transitive : Transitive _<>_
asym : Asymmetric _<>_
asym {x} {y} = trans∧irr→asym _<>_ transitive irrefl
record IsDecStrictPartialOrder : Type (ℓ-max a ℓ) where
constructor isdecstrictpartialorder
infix 4 _<?_
field
isStrictPartialOrder : IsStrictPartialOrder
_<?_ : Decidable _<>_
open IsStrictPartialOrder isStrictPartialOrder public
------------------------------------------------------------------------
-- Total orders
------------------------------------------------------------------------
record IsTotalOrder : Type (ℓ-max a ℓ) where
constructor istotalorder
field
isPartialOrder : IsPartialOrder
total : PropTotal _<>_
open IsPartialOrder isPartialOrder public
record IsDecTotalOrder : Type (ℓ-max a ℓ) where
constructor isdectotalorder
infix 4 _≤?_
field
isTotalOrder : IsTotalOrder
_≤?_ : Decidable _<>_
open IsTotalOrder isTotalOrder public
isDecPartialOrder : IsDecPartialOrder
isDecPartialOrder = record
{ isPartialOrder = isPartialOrder
; _≤?_ = _≤?_
}
open IsDecPartialOrder isDecPartialOrder public using (_≟_)
-- Note that these orders are decidable. The current implementation
-- of `Trichotomous` subsumes irreflexivity and asymmetry. Any reasonable
-- definition capturing these three properties implies decidability
-- as `Trichotomous` necessarily separates out the equality case.
record IsStrictTotalOrder : Type (ℓ-max a ℓ) where
constructor isstricttotalorder
field
transitive : Transitive _<>_
compare : Trichotomous _<>_
infix 4 _<?_
_<?_ : Decidable _<>_
_<?_ = tri→dec< _<>_ compare
_≟_ : Discrete A
_≟_ = tri→dec≡ _<>_ compare
isStrictPartialOrder : IsStrictPartialOrder
isStrictPartialOrder = record
{ irrefl = tri→irr _<>_ compare
; transitive = transitive
}
isDecStrictPartialOrder : IsDecStrictPartialOrder
isDecStrictPartialOrder = record
{ isStrictPartialOrder = isStrictPartialOrder
; _<?_ = _<?_
}
open IsStrictPartialOrder isStrictPartialOrder public hiding (transitive)
|
{
"alphanum_fraction": 0.616978876,
"avg_line_length": 26.4105263158,
"ext": "agda",
"hexsha": "ae4bdf93762835d7fe4fa00b5560ba75fc26cde8",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bijan2005/univalent-foundations",
"max_forks_repo_path": "Cubical/Relation/Binary/Raw/Structures.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "bijan2005/univalent-foundations",
"max_issues_repo_path": "Cubical/Relation/Binary/Raw/Structures.agda",
"max_line_length": 75,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bijan2005/univalent-foundations",
"max_stars_repo_path": "Cubical/Relation/Binary/Raw/Structures.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1367,
"size": 5018
}
|
module Algebra where
-- Core graph construction primitives
data Graph (A : Set) : Set where
ε : Graph A -- Empty graph
v : A -> Graph A -- Graph comprising a single vertex
_+_ : Graph A -> Graph A -> Graph A -- Overlay two graphs
_*_ : Graph A -> Graph A -> Graph A -- Connect two graphs
infixl 4 _≡_
infixl 8 _+_
infixl 9 _*_
infix 10 _⊆_
-- Equational theory of graphs
data _≡_ {A} : (x y : Graph A) -> Set where
-- Equivalence relation
reflexivity : ∀ {x : Graph A} -> x ≡ x
symmetry : ∀ {x y : Graph A} -> x ≡ y -> y ≡ x
transitivity : ∀ {x y z : Graph A} -> x ≡ y -> y ≡ z -> x ≡ z
-- Congruence
+left-congruence : ∀ {x y z : Graph A} -> x ≡ y -> x + z ≡ y + z
+right-congruence : ∀ {x y z : Graph A} -> x ≡ y -> z + x ≡ z + y
*left-congruence : ∀ {x y z : Graph A} -> x ≡ y -> x * z ≡ y * z
*right-congruence : ∀ {x y z : Graph A} -> x ≡ y -> z * x ≡ z * y
-- Axioms of +
+commutativity : ∀ {x y : Graph A} -> x + y ≡ y + x
+associativity : ∀ {x y z : Graph A} -> x + (y + z) ≡ (x + y) + z
-- Axioms of *
*left-identity : ∀ {x : Graph A} -> ε * x ≡ x
*right-identity : ∀ {x : Graph A} -> x * ε ≡ x
*associativity : ∀ {x y z : Graph A} -> x * (y * z) ≡ (x * y) * z
-- Other axioms
left-distributivity : ∀ {x y z : Graph A} -> x * (y + z) ≡ x * y + x * z
right-distributivity : ∀ {x y z : Graph A} -> (x + y) * z ≡ x * z + y * z
decomposition : ∀ {x y z : Graph A} -> x * y * z ≡ x * y + x * z + y * z
-- Subgraph relation
_⊆_ : ∀ {A} -> Graph A -> Graph A -> Set
x ⊆ y = x + y ≡ y
|
{
"alphanum_fraction": 0.4566103669,
"avg_line_length": 38.1555555556,
"ext": "agda",
"hexsha": "231a43654a6cd07684fac0cbc45573f79f9f058d",
"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": "01f5f9f53ea81f692215300744aa77e26d8bf332",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/alga",
"max_forks_repo_path": "src/Algebra.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "01f5f9f53ea81f692215300744aa77e26d8bf332",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/alga",
"max_issues_repo_path": "src/Algebra.agda",
"max_line_length": 85,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "01f5f9f53ea81f692215300744aa77e26d8bf332",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/alga",
"max_stars_repo_path": "src/Algebra.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 659,
"size": 1717
}
|
-- Andreas, 2014-01-10, reported by fredrik.forsberg
record ⊤ : Set where
record Σ (A : Set) (B : A → Set) : Set where
syntax Σ A (λ x → B) = Σ[ x ∈ A ] B
test : Set
test = {! Σ[ x ∈ ⊤ ] ?!}
-- Fredrik's report:
-- Using the darcs version of Agda from today 10 January,
-- if I load the file and give (or refine) in the hole, I end up with
--
-- test = Σ ⊤ (λ x → {!!})
--
-- i.e. Agda has translated away the syntax Σ[ x ∈ ⊤ ] {!!} for me.
-- I would of course expect
--
-- test = Σ[ x ∈ ⊤ ] {!!}
--
-- instead, and I think this used to be the behaviour? (Using the Σ from
-- the standard library, this is more annoying, as one gets
--
-- test = Σ-syntax ⊤ (λ x → {!!})
--
-- as a result.)
--
-- This might be related to issue 994?
-- Expected test case behavior:
--
-- Bad (at the time of report:
--
-- (agda2-give-action 0 "Σ ⊤ (λ x → ?)")
--
-- Good:
--
-- (agda2-give-action 0 'no-paren)
|
{
"alphanum_fraction": 0.5723684211,
"avg_line_length": 21.2093023256,
"ext": "agda",
"hexsha": "d10a607f6a1a5a6a5f61bbac364d464e5a689d71",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/interaction/Issue1020.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/Issue1020.agda",
"max_line_length": 72,
"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/Issue1020.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": 316,
"size": 912
}
|
module heap.libraryNat where
open import Data.Nat renaming (_⊔_ to _⊔n_; _≟_ to _≟ℕ_) hiding ( _<_ )
open import Data.Bool
open import Data.Fin hiding (pred)
open import Data.Unit
open import Data.Empty
open import Function
open import Relation.Nullary
open import Relation.Binary.PropositionalEquality
{-
--- WARNING USES TODO
postulate TODO : {A : Set} → A
-}
_==b_ : ℕ → ℕ → Bool
zero ==b zero = true
zero ==b suc a' = false
suc a ==b zero = false
suc a ==b suc a' = a ==b a'
transferℕ : (P : ℕ → Set)
→ (a a' : ℕ) → T (a ==b a')
→ P a → P a'
transferℕ P zero zero aa' q = q
transferℕ P zero (suc a') () q
transferℕ P (suc a) zero () q
transferℕ P (suc a) (suc a') aa' q = transferℕ (P ∘ suc) a a' aa' q
_<ℕb_ : ℕ → ℕ → Bool
_ <ℕb zero = false
zero <ℕb suc a' = true
suc a <ℕb suc a' = a <ℕb a'
_<ℕ_ : ℕ → ℕ → Set
n <ℕ m = T (n <ℕb m)
_≦ℕb_ : ℕ → ℕ → Bool
zero ≦ℕb _ = true
suc a ≦ℕb zero = false
suc a ≦ℕb suc a' = a ≦ℕb a'
_≧ℕb_ : ℕ → ℕ → Bool
n ≧ℕb m = m ≦ℕb n
<ℕb-suc : {a b : ℕ} → T (a <ℕb b) → T (a <ℕb suc b)
<ℕb-suc{zero} = λ _ → tt
<ℕb-suc{_}{zero} ()
<ℕb-suc{suc a}{suc b} = <ℕb-suc{a}{b}
<ℕb-suc' : {a b : ℕ} → T (a ≦ℕb b) → T (a <ℕb suc b)
<ℕb-suc' {zero} {zero} ab = ab
<ℕb-suc' {zero} {suc b} ab = ab
<ℕb-suc' {suc a} {zero} ab = ab
<ℕb-suc' {suc a} {suc b} ab = <ℕb-suc'{a}{b} ab
n<sucnLem : {n m : ℕ} → T (n ==b m) → T (n <ℕb suc m)
n<sucnLem {zero} {zero} nm = tt
n<sucnLem {zero} {suc m} ()
n<sucnLem {suc n} {zero} ()
n<sucnLem {suc n} {suc m} nm = n<sucnLem {n} {m} nm
n<mImpliesn/=m : (n m : ℕ) → T (m <ℕb n) → ¬ T (n ==b m)
n<mImpliesn/=m zero m ()
n<mImpliesn/=m (suc n) zero p ()
n<mImpliesn/=m (suc n) (suc m) p q = n<mImpliesn/=m n m p q
le : {n m : ℕ} → ¬ (n ==b m) ≡ false → T (n ==b m)
le{zero}{zero} p = tt
le {zero} {suc n} p = p refl
le {suc n} {zero} p = p refl
le {suc n} {suc m} p = le{n}{m} p
refl==b : {n : ℕ} → T (n ==b n)
refl==b {zero} = tt
refl==b {suc n} = refl==b {n}
symb : (n m : ℕ) → T (n ==b m) → T (m ==b n)
symb zero zero p = tt
symb zero (suc m) ()
symb (suc n) zero ()
symb (suc n) (suc m) p = symb n m p
neqsymb : (n m : ℕ) → ¬ T (n ==b m) → ¬ T (m ==b n)
neqsymb n m p q = p (symb m n q)
n<ℕbsucn : {n : ℕ} → T (n <ℕb suc n)
n<ℕbsucn {zero} = tt
n<ℕbsucn {suc n} = n<ℕbsucn{n}
n≦ℕbsucn : {n : ℕ} → T (n ≦ℕb suc n)
n≦ℕbsucn {zero} = tt
n≦ℕbsucn {suc n} = n≦ℕbsucn {n}
¬n<ℕbn : {n : ℕ} → ¬ (T (n <ℕb n))
¬n<ℕbn {zero} ()
¬n<ℕbn {suc n} p = ¬n<ℕbn {n} p
refl≦ℕb : (n : ℕ) → T (n ≦ℕb n)
refl≦ℕb zero = tt
refl≦ℕb (suc n) = refl≦ℕb n
trans≦ℕb : (n m k : ℕ) → T (n ≦ℕb m) → T (m ≦ℕb k) → T (n ≦ℕb k)
trans≦ℕb zero m k nm mk = tt
trans≦ℕb (suc n) zero k () mk
trans≦ℕb (suc n) (suc m) zero nm ()
trans≦ℕb (suc n) (suc m) (suc k) nm mk = trans≦ℕb n m k nm mk
⊔isMaxl : {n m : ℕ} → T (n ≦ℕb (n ⊔n m ))
⊔isMaxl {zero} {m} = tt
⊔isMaxl {suc n} {zero} = refl≦ℕb (suc n)
⊔isMaxl {suc n} {suc m} = ⊔isMaxl {n} {m}
⊔isMaxr : {n m : ℕ} → T (m ≦ℕb (n ⊔n m ))
⊔isMaxr {n} {zero} = tt
⊔isMaxr {zero} {suc m} = refl≦ℕb (suc m)
⊔isMaxr {suc n} {suc m} = ⊔isMaxr {n} {m}
⊔zero : {n : ℕ} → (n ⊔n zero) ≡ n
⊔zero {zero} = refl
⊔zero {suc n} = refl
⊔isMaxl' : {n m k : ℕ} → T (n ≦ℕb m ) → T (n ≦ℕb (m ⊔n k ))
⊔isMaxl' {zero} {m} {k} = λ _ → tt
⊔isMaxl' {suc n} {zero} {k} = λ ()
⊔isMaxl' {suc n} {suc m} {zero} = λ z → z
⊔isMaxl' {suc n} {suc m} {suc k} = ⊔isMaxl'{n}{m}
⊔isMax<l : {n m k : ℕ} → T ((n ⊔n m) <ℕb k) → T (n <ℕb k)
⊔isMax<l {n} {m} {zero} p = p
⊔isMax<l {zero} {m} {suc k} p = tt
⊔isMax<l {suc n} {zero} {suc k} p = p
⊔isMax<l {suc n} {suc m} {suc k} p = ⊔isMax<l {n} {m} {k} p
⊔isMax<r : {n m k : ℕ} → T ((n ⊔n m) <ℕb k) → T (m <ℕb k)
⊔isMax<r {n} {zero} {zero} p = p
⊔isMax<r {n} {zero} {suc k} p = tt
⊔isMax<r {zero} {suc m} {k} p = p
⊔isMax<r {suc n} {suc m} {zero} p = p
⊔isMax<r {suc n} {suc m} {suc k} p = ⊔isMax<r{n}{m}{k} p
sucinvertible : {n m : ℕ} → suc n ≡ suc m → n ≡ m
sucinvertible {n} {m} = cong pred
¬n≡m→¬sucn≡sucm : {n m : ℕ} → ¬ (n ≡ m) → ¬ (suc n ≡ suc m)
¬n≡m→¬sucn≡sucm {n} {m} p q = p (sucinvertible q)
<impliesnoteq : {n m : ℕ} → T (n <ℕb m) → ¬ (n ≡ m)
<impliesnoteq {n} {zero} p = λ _ → p
<impliesnoteq {zero} {suc m} p = λ ()
<impliesnoteq {suc n} {suc m} p = ¬n≡m→¬sucn≡sucm {n}{m} (<impliesnoteq{n}{m} p)
<impliesNot= = <impliesnoteq
-- {- Fin n related lemmata -}
-- fromℕ< : ∀ {n m} → n <ℕ m → Fin m
-- fromℕ< {_} {zero} ()
-- fromℕ< {zero} {suc m} p = zero
-- fromℕ< {suc n} {suc m} p = suc (fromℕ< {n} {m} p)
update : {A : Set} (f : ℕ → A) (n : ℕ) (a : A) → ℕ → A
update {A} f n a m = aux (n ≟ℕ m)
module updateaux where
aux : Dec (n ≡ m)
→ A
aux (yes _) = a
aux (no _) = f m
updateLem : {A : Set}(Q : A → Set)(f : ℕ → A)(n : ℕ)(a : A)
→ (m : ℕ)
→ ¬ (n ≡ m)
→ Q (f m)
→ Q (update f n a m)
updateLem {A} Q f n a m nm Qfm = aux (n ≟ℕ m)
module updateLemaux where
aux : (x : Dec (n ≡ m)) → Q(updateaux.aux f n a m x)
aux (yes p) = ⊥-elim (nm p)
aux (no ¬p) = Qfm
updateLem2 : {A : Set}(f : ℕ → A)(n : ℕ)(a : A)(m : ℕ)
→ (n ≡ m)
→ update f n a m ≡ a
updateLem2 {A} f n a m nm = aux (n ≟ℕ m)
module updateLem2aux where
aux : (x : Dec (n ≡ m)) → updateaux.aux f n a m x ≡ a
aux (yes p) = refl
aux (no ¬p) = ⊥-elim (¬p nm)
updateLem3 : {A : Set}(f : ℕ → A)(n : ℕ)(a : A)(m : ℕ)
→ ¬ (n ≡ m)
→ update f n a m ≡ f m
updateLem3 f n a m nm = updateLem (λ a' → a' ≡ f m) f n a m nm refl
leqEmbedLem : (P : ℕ → Set) → (l : (n : ℕ) → P n → P (suc n))
→ (n m : ℕ) → T (n ≦ℕb m) → P n → P m
leqEmbedLem P l zero zero nm p = p
leqEmbedLem P l zero (suc m) nm p = l m (leqEmbedLem P l zero m tt p)
leqEmbedLem P l (suc n) zero () p
leqEmbedLem P l (suc n) (suc m) nm p = leqEmbedLem (P ∘ suc) (l ∘ suc) n m nm p
|
{
"alphanum_fraction": 0.4955947137,
"avg_line_length": 25.8859649123,
"ext": "agda",
"hexsha": "ff938d7ecd7af8e9716e532eb2e2fc337bf5ec04",
"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": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "stephanadls/state-dependent-gui",
"max_forks_repo_path": "src/heap/libraryNat.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/heap/libraryNat.agda",
"max_line_length": 80,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "stephanadls/state-dependent-gui",
"max_stars_repo_path": "src/heap/libraryNat.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-31T17:20:59.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-07-31T15:37:39.000Z",
"num_tokens": 3068,
"size": 5902
}
|
{-# OPTIONS --cubical --no-import-sorts #-}
module Number.Instances.QuoIntFromInt where
open import Agda.Primitive renaming (_⊔_ to ℓ-max; lsuc to ℓ-suc; lzero to ℓ-zero)
open import Cubical.Foundations.Everything hiding (⋆) renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc)
open import Cubical.Foundations.Logic renaming (inl to inlᵖ; inr to inrᵖ)
open import Cubical.Relation.Nullary.Base renaming (¬_ to ¬ᵗ_)
open import Cubical.Relation.Binary.Base
open import Cubical.Data.Sum.Base renaming (_⊎_ to infixr 4 _⊎_)
open import Cubical.Data.Sigma.Base renaming (_×_ to infixr 4 _×_)
open import Cubical.Data.Sigma
open import Cubical.Data.Bool as Bool using (Bool; not; true; false)
open import Cubical.Data.Empty renaming (elim to ⊥-elim; ⊥ to ⊥⊥) -- `⊥` and `elim`
open import Cubical.Foundations.Logic renaming (¬_ to ¬ᵖ_; inl to inlᵖ; inr to inrᵖ)
open import Function.Base using (it; _∋_; _$_)
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.HITs.PropositionalTruncation --.Properties
open import Utils using (!_; !!_)
open import MoreLogic.Reasoning
open import MoreLogic.Definitions
open import MoreLogic.Properties
open import MorePropAlgebra.Definitions hiding (_≤''_)
open import MorePropAlgebra.Structures
open import MorePropAlgebra.Bundles
open import MorePropAlgebra.Consequences
open import Number.Structures2
open import Number.Bundles2
import Agda.Builtin.Int as Builtin
import Data.Integer.Base as BuiltinBase
import Data.Integer.Properties as BuiltinProps
open import Cubical.Data.Nat.Literals
open import Number.Prelude.Nat
open import Number.Prelude.Int
import Cubical.Data.Int as Int
import Number.Instances.Int
open import Cubical.HITs.Ints.QuoInt as QuoInt using
( ℤ
; _+_
; -_
; Int≡ℤ
; signed
; posneg
; ℤ→Int
; sucℤ
; predℤ
; sign
; abs
; pos
; neg
; +-comm
; +-assoc
; sucℤ-+ʳ
) renaming
( _*_ to _·_ )
ℤ≡Int = sym Int≡ℤ
private
_·ᵗʳ_ : Int → Int → Int
_·ᵗʳ_ = transport (λ i → (ℤ≡Int i → ℤ≡Int i → ℤ≡Int i)) _·_
·≡·ᵗʳ : PathP (λ i → (ℤ≡Int i → ℤ≡Int i → ℤ≡Int i)) _·_ _·ᵗʳ_
·≡·ᵗʳ i = transp (λ j → ℤ≡Int (i ∧ j) → ℤ≡Int (i ∧ j) → ℤ≡Int (i ∧ j)) (~ i) _·_
lemma1 : ∀ a b → b +ⁿ a ·ⁿ suc b ≡ a ·ⁿ b +ⁿ (a +ⁿ b)
lemma1 a b =
b +ⁿ a ·ⁿ suc b ≡⟨ (λ i → b +ⁿ ·ⁿ-suc a b i) ⟩
b +ⁿ (a +ⁿ a ·ⁿ b) ≡⟨ +ⁿ-assoc b a (a ·ⁿ b) ⟩
(b +ⁿ a) +ⁿ a ·ⁿ b ≡⟨ (λ i → +ⁿ-comm b a i +ⁿ a ·ⁿ b) ⟩
(a +ⁿ b) +ⁿ a ·ⁿ b ≡⟨ +ⁿ-comm (a +ⁿ b) (a ·ⁿ b) ⟩
a ·ⁿ b +ⁿ (a +ⁿ b) ∎
·ᵗʳ≡'·ᶻ : ∀ a b → a ·ᵗʳ b ≡ a ·ᶻ b
·ᵗʳ≡'·ᶻ (posᶻ 0 ) (posᶻ 0 ) = refl
·ᵗʳ≡'·ᶻ (posᶻ 0 ) (posᶻ (suc b)) = refl
·ᵗʳ≡'·ᶻ (posᶻ (suc a)) (posᶻ 0 ) = refl
·ᵗʳ≡'·ᶻ (posᶻ (suc a)) (posᶻ (suc b)) = refl
·ᵗʳ≡'·ᶻ (posᶻ 0 ) (negsucᶻ b ) = refl
·ᵗʳ≡'·ᶻ (posᶻ (suc a)) (negsucᶻ b ) i = negsucᶻ (lemma1 a b i)
·ᵗʳ≡'·ᶻ (negsucᶻ a ) (posᶻ 0 ) i = ℤ→Int (signed sneg (·ⁿ-nullifiesʳ a i))
·ᵗʳ≡'·ᶻ (negsucᶻ a ) (posᶻ (suc b)) i = negsucᶻ (lemma1 a b i)
·ᵗʳ≡'·ᶻ (negsucᶻ a ) (negsucᶻ b ) = refl
·ᵗʳ≡·ᶻ : _·ᵗʳ_ ≡ _·ᶻ_
·ᵗʳ≡·ᶻ i a b = ·ᵗʳ≡'·ᶻ a b i
·≡·ᶻ : PathP (λ i → (ℤ≡Int i → ℤ≡Int i → ℤ≡Int i)) _·_ _·ᶻ_
·≡·ᶻ = J (λ _⋆_ _ → PathP (λ i → (ℤ≡Int i → ℤ≡Int i → ℤ≡Int i)) _·_ _⋆_) ·≡·ᵗʳ ·ᵗʳ≡·ᶻ
-- ·-assoc''''' : ∀ a b c → a · (b · c) ≡ (a · b) · c
-- ·-assoc''''' = transport γ ·-assoc where
-- γ : ((m n o : Z) → m · (n · o) ≡ (m · n) · o)
-- ≡ ((a b c : ℤ) → a · (b · c) ≡ (a · b) · c)
-- γ i = let _⋆_ = QuoInt·≡· i in (x y z : ℤ≡Int i) → x ⋆ (y ⋆ z) ≡ (x ⋆ y) ⋆ z
sucInt-preserves-ℤ→Int : ∀ a → sucInt (ℤ→Int a) ≡ ℤ→Int (sucℤ a)
sucInt-preserves-ℤ→Int (signed spos n) = refl
sucInt-preserves-ℤ→Int (signed sneg zero) = refl
sucInt-preserves-ℤ→Int (signed sneg (suc zero)) = refl
sucInt-preserves-ℤ→Int (signed sneg (suc (suc n))) = refl
sucInt-preserves-ℤ→Int (posneg i) = refl
predInt-preserves-ℤ→Int : ∀ a → predInt (ℤ→Int a) ≡ ℤ→Int (predℤ a)
predInt-preserves-ℤ→Int (signed spos zero) = refl
predInt-preserves-ℤ→Int (signed spos (suc n)) = refl
predInt-preserves-ℤ→Int (signed sneg zero) = refl
predInt-preserves-ℤ→Int (signed sneg (suc n)) = refl
predInt-preserves-ℤ→Int (posneg i) = refl
-sucℤ-sucℤ≡id : ∀ a → - sucℤ (- sucℤ a) ≡ a
-sucℤ-sucℤ≡id (signed spos n) = refl
-sucℤ-sucℤ≡id (signed sneg zero) = posneg
-sucℤ-sucℤ≡id (signed sneg (suc n)) = refl
-sucℤ-sucℤ≡id (posneg i) j = posneg (i ∧ j)
sucℤ-sucℤ-≡id : ∀ a → sucℤ (- sucℤ (- a)) ≡ a
sucℤ-sucℤ-≡id (signed spos zero) i = posneg (~ i)
sucℤ-sucℤ-≡id (signed spos (suc n)) = refl
sucℤ-sucℤ-≡id (signed sneg n) = refl
sucℤ-sucℤ-≡id (posneg i) j = posneg (i ∨ (~ j))
-sucℤ-sucℤ≡sucℤ-sucℤ- : ∀ a → - sucℤ (- sucℤ a) ≡ sucℤ (- sucℤ (- a))
-sucℤ-sucℤ≡sucℤ-sucℤ- a = -sucℤ-sucℤ≡id a ∙ sym (sucℤ-sucℤ-≡id a)
private
_+ᵗʳ_ : Int → Int → Int
_+ᵗʳ_ = transport (λ i → (ℤ≡Int i → ℤ≡Int i → ℤ≡Int i)) _+_
+≡+ᵗʳ : PathP (λ i → (ℤ≡Int i → ℤ≡Int i → ℤ≡Int i)) _+_ _+ᵗʳ_
+≡+ᵗʳ i = transp (λ j → ℤ≡Int (i ∧ j) → ℤ≡Int (i ∧ j) → ℤ≡Int (i ∧ j)) (~ i) _+_
+ᵗʳ≡'+ᶻ : ∀ a b → a +ᵗʳ b ≡ a +ᶻ b
+ᵗʳ≡'+ᶻ (posᶻ 0 ) (posᶻ 0 ) = refl
+ᵗʳ≡'+ᶻ (posᶻ 0 ) (posᶻ (suc b)) i = sucInt (Int.+-comm (posᶻ b) 0 i)
+ᵗʳ≡'+ᶻ (posᶻ (suc a)) (posᶻ 0 ) i = ℤ→Int (sucℤ (+-comm (pos a) 0 i))
+ᵗʳ≡'+ᶻ (posᶻ (suc a)) (posᶻ (suc b)) =
(posᶻ (suc a) +ᵗʳ posᶻ (suc b)) ≡⟨ sym (sucInt-preserves-ℤ→Int (signed spos a + signed spos (suc b))) ⟩
sucInt (posᶻ a +ᵗʳ posᶻ (suc b)) ≡⟨ (λ i → sucInt $ (+ᵗʳ≡'+ᶻ (posᶻ a) (posᶻ (suc b)) ∙ sucInt+ (posᶻ a) (posᶻ b)) i) ⟩
sucInt (posᶻ (suc a) +pos b) ∎
+ᵗʳ≡'+ᶻ (posᶻ 0 ) (negsucᶻ b ) = sym (+negsuc-identityˡ b)
+ᵗʳ≡'+ᶻ (posᶻ (suc a)) (negsucᶻ b ) =
(posᶻ (suc a) +ᵗʳ negsucᶻ b) ≡⟨ sym $ sucInt-preserves-ℤ→Int (signed spos a + signed sneg (suc b)) ⟩
sucInt (posᶻ a +ᵗʳ negsucᶻ b) ≡⟨ (λ i → sucInt $ +ᵗʳ≡'+ᶻ (posᶻ a) (negsucᶻ b) i) ⟩
sucInt (posᶻ a +ᶻ negsucᶻ b) ≡⟨ sucInt+ (posᶻ a) (negsucᶻ b) ⟩
(posᶻ (suc a) +negsuc b) ∎
+ᵗʳ≡'+ᶻ (negsucᶻ a ) (posᶻ 0 ) i = ℤ→Int $ -_ $ sucℤ $ -_ $ +-comm (signed sneg a) (pos 0) i
+ᵗʳ≡'+ᶻ (negsucᶻ a ) (posᶻ (suc b)) =
(negsucᶻ a +ᵗʳ posᶻ (suc b)) ≡⟨ (λ i → ℤ→Int $ - sucℤ (- sucℤ-+ʳ (signed sneg a) (signed spos b) (~ i))) ⟩
ℤ→Int (- sucℤ (- sucℤ (signed sneg a + signed spos b))) ≡⟨ (λ i → ℤ→Int $ -sucℤ-sucℤ≡sucℤ-sucℤ- (signed sneg a + signed spos b) i) ⟩
ℤ→Int (sucℤ (- sucℤ (- (signed sneg a + signed spos b)))) ≡⟨ sym $ sucInt-preserves-ℤ→Int (- sucℤ (- (signed sneg a + signed spos b))) ⟩
sucInt (negsucᶻ a +ᵗʳ posᶻ b) ≡⟨ (λ i → sucInt $ +ᵗʳ≡'+ᶻ (negsucᶻ a) (posᶻ b) i) ⟩
sucInt (negsucᶻ a +pos b) ∎
+ᵗʳ≡'+ᶻ (negsucᶻ zero) (negsucᶻ b) = sym $ negsuc+negsuc≡+ⁿ 0 b
+ᵗʳ≡'+ᶻ (negsucᶻ (suc a)) (negsucᶻ b) =
(negsucᶻ (suc a) +ᵗʳ negsucᶻ b) ≡⟨ sym $ predInt-preserves-ℤ→Int (- sucℤ (- (signed sneg a + signed sneg (suc b)))) ⟩
predInt (negsucᶻ a +ᵗʳ negsucᶻ b) ≡⟨ (λ i → predInt $ +ᵗʳ≡'+ᶻ (negsucᶻ a) (negsucᶻ b) i) ⟩
predInt (negsucᶻ a +ᶻ negsucᶻ b) ≡⟨ predInt+ (negsucᶻ a) (negsucᶻ b) ⟩
(negsucᶻ (suc a) +negsuc b) ∎
+ᵗʳ≡+ᶻ : _+ᵗʳ_ ≡ _+ᶻ_
+ᵗʳ≡+ᶻ i a b = +ᵗʳ≡'+ᶻ a b i
+≡+ᶻ : PathP (λ i → (ℤ≡Int i → ℤ≡Int i → ℤ≡Int i)) _+_ _+ᶻ_
+≡+ᶻ = J (λ _+ᵗʳ_ _ → PathP (λ i → (ℤ≡Int i → ℤ≡Int i → ℤ≡Int i)) _+_ _+ᵗʳ_) +≡+ᵗʳ +ᵗʳ≡+ᶻ
private
-ᵗʳ_ : Int → Int
-ᵗʳ_ = transport (λ i → (ℤ≡Int i → ℤ≡Int i)) -_
-≡-ᵗʳ : PathP (λ i → (ℤ≡Int i → ℤ≡Int i)) -_ -ᵗʳ_
-≡-ᵗʳ i = transp (λ j → ℤ≡Int (i ∧ j) → ℤ≡Int (i ∧ j)) (~ i) -_
-ᵗʳ≡'-ᶻ : ∀ a → -ᵗʳ a ≡ -ᶻ a
-ᵗʳ≡'-ᶻ (posᶻ zero) = refl
-ᵗʳ≡'-ᶻ (posᶻ (suc n)) = refl
-ᵗʳ≡'-ᶻ (negsucᶻ n) = refl
-ᵗʳ≡-ᶻ : (-ᵗʳ_) ≡ (-ᶻ_)
-ᵗʳ≡-ᶻ i a = -ᵗʳ≡'-ᶻ a i
-≡-ᶻ : PathP (λ i → (ℤ≡Int i → ℤ≡Int i)) (-_) (-ᶻ_)
-≡-ᶻ = J (λ -ᵗʳ_ _ → PathP (λ i → (ℤ≡Int i → ℤ≡Int i)) -_ -ᵗʳ_) -≡-ᵗʳ -ᵗʳ≡-ᶻ
min : ℤ → ℤ → ℤ
min x y with sign x | sign y
... | spos | spos = pos (minⁿ (abs x) (abs y))
... | spos | sneg = y
... | sneg | spos = x
... | sneg | sneg = neg (maxⁿ (abs x) (abs y))
max : ℤ → ℤ → ℤ
max x y with sign x | sign y
... | spos | spos = pos (maxⁿ (abs x) (abs y))
... | spos | sneg = x
... | sneg | spos = y
... | sneg | sneg = neg (minⁿ (abs x) (abs y))
private
minᵗʳ : Int → Int → Int
minᵗʳ = transport (λ i → (ℤ≡Int i → ℤ≡Int i → ℤ≡Int i)) min
maxᵗʳ : Int → Int → Int
maxᵗʳ = transport (λ i → (ℤ≡Int i → ℤ≡Int i → ℤ≡Int i)) max
min≡minᵗʳ : PathP (λ i → (ℤ≡Int i → ℤ≡Int i → ℤ≡Int i)) min minᵗʳ
min≡minᵗʳ i = transp (λ j → ℤ≡Int (i ∧ j) → ℤ≡Int (i ∧ j) → ℤ≡Int (i ∧ j)) (~ i) min
max≡maxᵗʳ : PathP (λ i → (ℤ≡Int i → ℤ≡Int i → ℤ≡Int i)) max maxᵗʳ
max≡maxᵗʳ i = transp (λ j → ℤ≡Int (i ∧ j) → ℤ≡Int (i ∧ j) → ℤ≡Int (i ∧ j)) (~ i) max
minᵗʳ≡'minᶻ : ∀ a b → minᵗʳ a b ≡ minᶻ a b
minᵗʳ≡'minᶻ (posᶻ 0 ) (posᶻ 0 ) = refl
minᵗʳ≡'minᶻ (posᶻ 0 ) (posᶻ (suc b)) = refl
minᵗʳ≡'minᶻ (posᶻ (suc a)) (posᶻ 0 ) = refl
minᵗʳ≡'minᶻ (posᶻ (suc a)) (posᶻ (suc b)) = refl
minᵗʳ≡'minᶻ (posᶻ 0 ) (negsucᶻ b ) = refl
minᵗʳ≡'minᶻ (posᶻ (suc a)) (negsucᶻ b ) = refl
minᵗʳ≡'minᶻ (negsucᶻ a ) (posᶻ 0 ) = refl
minᵗʳ≡'minᶻ (negsucᶻ a ) (posᶻ (suc b)) = refl
minᵗʳ≡'minᶻ (negsucᶻ a ) (negsucᶻ b ) = refl
maxᵗʳ≡'maxᶻ : ∀ a b → maxᵗʳ a b ≡ maxᶻ a b
maxᵗʳ≡'maxᶻ (posᶻ 0 ) (posᶻ 0 ) = refl
maxᵗʳ≡'maxᶻ (posᶻ 0 ) (posᶻ (suc b)) = refl
maxᵗʳ≡'maxᶻ (posᶻ (suc a)) (posᶻ 0 ) = refl
maxᵗʳ≡'maxᶻ (posᶻ (suc a)) (posᶻ (suc b)) = refl
maxᵗʳ≡'maxᶻ (posᶻ 0 ) (negsucᶻ b ) = refl
maxᵗʳ≡'maxᶻ (posᶻ (suc a)) (negsucᶻ b ) = refl
maxᵗʳ≡'maxᶻ (negsucᶻ a ) (posᶻ 0 ) = refl
maxᵗʳ≡'maxᶻ (negsucᶻ a ) (posᶻ (suc b)) = refl
maxᵗʳ≡'maxᶻ (negsucᶻ a ) (negsucᶻ b ) = refl
minᵗʳ≡minᶻ : minᵗʳ ≡ minᶻ
minᵗʳ≡minᶻ i a b = minᵗʳ≡'minᶻ a b i
maxᵗʳ≡maxᶻ : maxᵗʳ ≡ maxᶻ
maxᵗʳ≡maxᶻ i a b = maxᵗʳ≡'maxᶻ a b i
min≡min : PathP (λ i → (ℤ≡Int i → ℤ≡Int i → ℤ≡Int i)) min minᶻ
min≡min = J (λ minᵗʳ _ → PathP (λ i → (ℤ≡Int i → ℤ≡Int i → ℤ≡Int i)) min minᵗʳ) min≡minᵗʳ minᵗʳ≡minᶻ
max≡max : PathP (λ i → (ℤ≡Int i → ℤ≡Int i → ℤ≡Int i)) max maxᶻ
max≡max = J (λ maxᵗʳ _ → PathP (λ i → (ℤ≡Int i → ℤ≡Int i → ℤ≡Int i)) max maxᵗʳ) max≡maxᵗʳ maxᵗʳ≡maxᶻ
infixl 4 _<_
_<_ : ∀(x y : ℤ) → hProp ℓ-zero
x < y with sign x | sign y
... | spos | spos = abs x <ⁿ abs y
... | spos | sneg = ⊥
... | sneg | spos = ⊤
... | sneg | sneg = abs y <ⁿ abs x
private
_<ᵗʳ_ : Int → Int → hProp ℓ-zero
_<ᵗʳ_ = transport (λ i → (ℤ≡Int i → ℤ≡Int i → hProp ℓ-zero)) _<_
<≡<ᵗʳ : PathP (λ i → (ℤ≡Int i → ℤ≡Int i → hProp ℓ-zero)) _<_ _<ᵗʳ_
<≡<ᵗʳ i = transp (λ j → ℤ≡Int (i ∧ j) → ℤ≡Int (i ∧ j) → hProp ℓ-zero) (~ i) _<_
<ᵗʳ⇔<ᶻ : ∀ a b → [ (a <ᵗʳ b) ⇔ (a <ᶻ b) ]
<ᵗʳ⇔<ᶻ (posᶻ 0 ) (posᶻ 0 ) .fst pᵗʳ = pᵗʳ
<ᵗʳ⇔<ᶻ (posᶻ 0 ) (posᶻ (suc b)) .fst pᵗʳ = pᵗʳ
<ᵗʳ⇔<ᶻ (posᶻ (suc a)) (posᶻ 0 ) .fst pᵗʳ = pᵗʳ
<ᵗʳ⇔<ᶻ (posᶻ (suc a)) (posᶻ (suc b)) .fst pᵗʳ = pᵗʳ
<ᵗʳ⇔<ᶻ (posᶻ 0 ) (negsucᶻ b ) .fst pᵗʳ = pᵗʳ
<ᵗʳ⇔<ᶻ (posᶻ (suc a)) (negsucᶻ b ) .fst pᵗʳ = pᵗʳ
<ᵗʳ⇔<ᶻ (negsucᶻ a ) (posᶻ 0 ) .fst pᵗʳ = pᵗʳ
<ᵗʳ⇔<ᶻ (negsucᶻ a ) (posᶻ (suc b)) .fst pᵗʳ = pᵗʳ
<ᵗʳ⇔<ᶻ (negsucᶻ a ) (negsucᶻ b ) .fst pᵗʳ = sucⁿ-creates-<ⁿ b a .snd pᵗʳ
<ᵗʳ⇔<ᶻ (posᶻ 0 ) (posᶻ 0 ) .snd p = p
<ᵗʳ⇔<ᶻ (posᶻ 0 ) (posᶻ (suc b)) .snd p = p
<ᵗʳ⇔<ᶻ (posᶻ (suc a)) (posᶻ 0 ) .snd p = p
<ᵗʳ⇔<ᶻ (posᶻ (suc a)) (posᶻ (suc b)) .snd p = p
<ᵗʳ⇔<ᶻ (negsucᶻ a ) (posᶻ 0 ) .snd p = p
<ᵗʳ⇔<ᶻ (negsucᶻ a ) (posᶻ (suc b)) .snd p = p
<ᵗʳ⇔<ᶻ (negsucᶻ a ) (negsucᶻ b ) .snd p = sucⁿ-creates-<ⁿ b a .fst p
<ᵗʳ≡<ᶻ : _<ᵗʳ_ ≡ _<ᶻ_
<ᵗʳ≡<ᶻ i a b = ⇔toPath {P = a <ᵗʳ b} {Q = a <ᶻ b} (<ᵗʳ⇔<ᶻ a b .fst) (<ᵗʳ⇔<ᶻ a b .snd) i
<≡<ᶻ : PathP (λ i → (ℤ≡Int i → ℤ≡Int i → hProp ℓ-zero)) _<_ _<ᶻ_
<≡<ᶻ = J (λ _<ᵗʳ_ _ → PathP (λ i → (ℤ≡Int i → ℤ≡Int i → hProp ℓ-zero)) _<_ _<ᵗʳ_) <≡<ᵗʳ <ᵗʳ≡<ᶻ
is-LinearlyOrderedCommRing : [ isLinearlyOrderedCommRing 0 1 _+_ _·_ -_ _<_ min max ]
is-LinearlyOrderedCommRing = transport γ is-LinearlyOrderedCommRingᶻ where
γ : ([ isLinearlyOrderedCommRing 0 1 _+ᶻ_ _·ᶻ_ (-ᶻ_) _<ᶻ_ minᶻ maxᶻ ])
≡ [ isLinearlyOrderedCommRing 0 1 _+_ _·_ -_ _<_ min max ]
γ i = [ isLinearlyOrderedCommRing 0ⁱ 1ⁱ _+ⁱ_ _·ⁱ_ -ⁱ_ _<ⁱ_ minⁱ maxⁱ ] where
0ⁱ = transport (λ j → ℤ≡Int (~ i ∧ j)) 0
1ⁱ = transport (λ j → ℤ≡Int (~ i ∧ j)) 1
_+ⁱ_ = +≡+ᶻ (~ i)
_·ⁱ_ = ·≡·ᶻ (~ i)
-ⁱ_ = -≡-ᶻ (~ i)
_<ⁱ_ = <≡<ᶻ (~ i)
minⁱ = min≡min (~ i)
maxⁱ = max≡max (~ i)
bundle : LinearlyOrderedCommRing {ℓ-zero} {ℓ-zero}
bundle .LinearlyOrderedCommRing.Carrier = ℤ
bundle .LinearlyOrderedCommRing.0f = 0
bundle .LinearlyOrderedCommRing.1f = 1
bundle .LinearlyOrderedCommRing._+_ = _+_
bundle .LinearlyOrderedCommRing._·_ = _·_
bundle .LinearlyOrderedCommRing.-_ = -_
bundle .LinearlyOrderedCommRing.min = min
bundle .LinearlyOrderedCommRing.max = max
bundle .LinearlyOrderedCommRing._<_ = _<_
bundle .LinearlyOrderedCommRing.is-LinearlyOrderedCommRing = is-LinearlyOrderedCommRing
·-reflects-< : (x y z : ℤ) → [ 0 < z ] → [ (x · z) < (y · z) ] → [ x < y ]
·-reflects-< = transport γ ·ᶻ-reflects-<ᶻ where
γ : ((x y z : Int) → [ 0 <ᶻ z ] → [ x ·ᶻ z <ᶻ y ·ᶻ z ] → [ x <ᶻ y ])
≡ ((x y z : ℤ) → [ 0 < z ] → [ (x · z) < (y · z) ] → [ x < y ])
γ i = let _·'_ = ·≡·ᶻ (~ i); _<'_ = <≡<ᶻ (~ i); 0ⁱ = transport (λ j → ℤ≡Int (~ i ∧ j)) 0 in
((x y z : ℤ≡Int (~ i)) → [ 0ⁱ <' z ] → [ (x ·' z) <' (y ·' z) ] → [ x <' y ])
|
{
"alphanum_fraction": 0.5434477667,
"avg_line_length": 41.6769230769,
"ext": "agda",
"hexsha": "251d848472e642b9ae61b640ed04694a3e9f721b",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mchristianl/synthetic-reals",
"max_forks_repo_path": "agda/Number/Instances/QuoIntFromInt.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "mchristianl/synthetic-reals",
"max_issues_repo_path": "agda/Number/Instances/QuoIntFromInt.agda",
"max_line_length": 140,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mchristianl/synthetic-reals",
"max_stars_repo_path": "agda/Number/Instances/QuoIntFromInt.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-19T12:15:21.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-07-31T18:15:26.000Z",
"num_tokens": 8005,
"size": 13545
}
|
{-# OPTIONS --without-K #-}
open import lib.Basics
open import lib.types.Nat
open import lib.types.Group
open import lib.types.TLevel
module lib.types.Int where
data ℤ : Type₀ where
pos : (n : ℕ) → ℤ
negsucc : (n : ℕ) → ℤ
Int = ℤ
{-# BUILTIN INTEGER Int #-}
{-# BUILTIN INTEGERPOS pos #-}
{-# BUILTIN INTEGERNEGSUC negsucc #-}
{- literal overloading -}
instance
ℤ-reader : FromNat ℤ
FromNat.in-range ℤ-reader _ = ⊤
FromNat.read ℤ-reader n = pos n
ℤ-neg-reader : FromNeg ℤ
FromNeg.in-range ℤ-neg-reader _ = ⊤
FromNeg.read ℤ-neg-reader O = pos O
FromNeg.read ℤ-neg-reader (S n) = negsucc n
{- succ and pred -}
succ : ℤ → ℤ
succ (pos n) = pos (S n)
succ (negsucc O) = pos O
succ (negsucc (S n)) = negsucc n
pred : ℤ → ℤ
pred (pos O) = negsucc O
pred (pos (S n)) = pos n
pred (negsucc n) = negsucc (S n)
abstract
succ-pred : (n : ℤ) → succ (pred n) == n
succ-pred (pos O) = idp
succ-pred (pos (S n)) = idp
succ-pred (negsucc n) = idp
pred-succ : (n : ℤ) → pred (succ n) == n
pred-succ (pos n) = idp
pred-succ (negsucc O) = idp
pred-succ (negsucc (S n)) = idp
succ-equiv : ℤ ≃ ℤ
succ-equiv = equiv succ pred succ-pred pred-succ
pred-injective : (z₁ z₂ : ℤ) → pred z₁ == pred z₂ → z₁ == z₂
pred-injective z₁ z₂ p = ! (succ-pred z₁) ∙ ap succ p ∙ succ-pred z₂
succ-injective : (z₁ z₂ : ℤ) → succ z₁ == succ z₂ → z₁ == z₂
succ-injective z₁ z₂ p = ! (pred-succ z₁) ∙ ap pred p ∙ pred-succ z₂
{- Converting between ℤ, ℕ, and ℕ₋₂ -}
ℤ-to-ℕ₋₂ : ℤ → ℕ₋₂
ℤ-to-ℕ₋₂ (pos m) = ⟨ m ⟩
ℤ-to-ℕ₋₂ (negsucc O) = -1
ℤ-to-ℕ₋₂ (negsucc _) = -2
ℕ-to-ℤ : ℕ → ℤ
ℕ-to-ℤ n = pos n
{- Proof that [ℤ] has decidable equality and hence is a set -}
private
ℤ-get-pos : ℤ → ℕ
ℤ-get-pos (pos n) = n
ℤ-get-pos (negsucc n) = O
ℤ-get-negsucc : ℤ → ℕ
ℤ-get-negsucc (pos n) = O
ℤ-get-negsucc (negsucc n) = n
ℤ-negsucc≠pos-type : ℤ → Type₀
ℤ-negsucc≠pos-type (pos n) = Empty
ℤ-negsucc≠pos-type (negsucc n) = Unit
abstract
pos-injective : (n m : ℕ) (p : pos n == pos m) → n == m
pos-injective n m p = ap ℤ-get-pos p
pos-≠ : {n m : ℕ} (p : n ≠ m) → pos n ≠ pos m
pos-≠ p = p ∘ pos-injective _ _
negsucc-injective : (n m : ℕ) (p : negsucc n == negsucc m) → n == m
negsucc-injective n m p = ap ℤ-get-negsucc p
ℤ-negsucc≠pos : (n m : ℕ) → negsucc n ≠ pos m
ℤ-negsucc≠pos n m p = transport ℤ-negsucc≠pos-type p unit
ℤ-pos≠negsucc : (n m : ℕ) → pos n ≠ negsucc m
ℤ-pos≠negsucc n m p = transport ℤ-negsucc≠pos-type (! p) unit
ℤ-has-dec-eq : has-dec-eq ℤ
ℤ-has-dec-eq (pos n) (pos m) with ℕ-has-dec-eq n m
ℤ-has-dec-eq (pos n) (pos m) | inl p = inl (ap pos p)
ℤ-has-dec-eq (pos n) (pos m) | inr p⊥ = inr (pos-≠ p⊥)
ℤ-has-dec-eq (pos n) (negsucc m) = inr (ℤ-pos≠negsucc n m)
ℤ-has-dec-eq (negsucc n) (pos m) = inr (ℤ-negsucc≠pos n m)
ℤ-has-dec-eq (negsucc n) (negsucc m) with ℕ-has-dec-eq n m
ℤ-has-dec-eq (negsucc n) (negsucc m) | inl p = inl (ap negsucc p)
ℤ-has-dec-eq (negsucc n) (negsucc m) | inr p⊥ = inr (λ p → p⊥ (negsucc-injective n m p))
ℤ-is-set : is-set ℤ
ℤ-is-set = dec-eq-is-set ℤ-has-dec-eq
ℤ-level = ℤ-is-set
{-
ℤ is also a group!
-}
-- inv
ℤ~ : ℤ → ℤ
ℤ~ (pos (S n)) = negsucc n
ℤ~ (pos O) = pos O
ℤ~ (negsucc n) = pos (S n)
-- comp
infixl 80 _ℤ+_
_ℤ+_ : ℤ → ℤ → ℤ
pos O ℤ+ z = z
pos (S n) ℤ+ z = succ (pos n ℤ+ z)
negsucc O ℤ+ z = pred z
negsucc (S n) ℤ+ z = pred (negsucc n ℤ+ z)
-- unit-l
ℤ+-unit-l : ∀ z → pos O ℤ+ z == z
ℤ+-unit-l _ = idp
-- unit-r
private
ℤ+-unit-r-pos : ∀ n → pos n ℤ+ pos O == pos n
ℤ+-unit-r-pos O = idp
ℤ+-unit-r-pos (S n) = ap succ $ ℤ+-unit-r-pos n
ℤ+-unit-r-negsucc : ∀ n → negsucc n ℤ+ pos O == negsucc n
ℤ+-unit-r-negsucc O = idp
ℤ+-unit-r-negsucc (S n) = ap pred $ ℤ+-unit-r-negsucc n
ℤ+-unit-r : ∀ z → z ℤ+ pos O == z
ℤ+-unit-r (pos n) = ℤ+-unit-r-pos n
ℤ+-unit-r (negsucc n) = ℤ+-unit-r-negsucc n
-- assoc
succ-ℤ+ : ∀ z₁ z₂ → succ z₁ ℤ+ z₂ == succ (z₁ ℤ+ z₂)
succ-ℤ+ (pos n) _ = idp
succ-ℤ+ (negsucc O) _ = ! $ succ-pred _
succ-ℤ+ (negsucc (S _)) _ = ! $ succ-pred _
pred-ℤ+ : ∀ z₁ z₂ → pred z₁ ℤ+ z₂ == pred (z₁ ℤ+ z₂)
pred-ℤ+ (negsucc _) _ = idp
pred-ℤ+ (pos O) _ = idp
pred-ℤ+ (pos (S n)) _ = ! $ pred-succ _
ℤ+-assoc : ∀ z₁ z₂ z₃ → (z₁ ℤ+ z₂) ℤ+ z₃ == z₁ ℤ+ (z₂ ℤ+ z₃)
ℤ+-assoc (pos O) z₂ z₃ = idp
ℤ+-assoc (pos (S n₁)) z₂ z₃ =
succ (pos n₁ ℤ+ z₂) ℤ+ z₃ =⟨ succ-ℤ+ (pos n₁ ℤ+ z₂) z₃ ⟩
succ ((pos n₁ ℤ+ z₂) ℤ+ z₃) =⟨ ap succ $ ℤ+-assoc (pos n₁) z₂ z₃ ⟩
succ (pos n₁ ℤ+ (z₂ ℤ+ z₃)) ∎
ℤ+-assoc (negsucc O) z₂ z₃ = pred-ℤ+ z₂ z₃
ℤ+-assoc (negsucc (S n₁)) z₂ z₃ =
pred (negsucc n₁ ℤ+ z₂) ℤ+ z₃ =⟨ pred-ℤ+ (negsucc n₁ ℤ+ z₂) z₃ ⟩
pred ((negsucc n₁ ℤ+ z₂) ℤ+ z₃) =⟨ ap pred $ ℤ+-assoc (negsucc n₁) z₂ z₃ ⟩
pred (negsucc n₁ ℤ+ (z₂ ℤ+ z₃)) ∎
--comm
ℤ+-succ : ∀ z₁ z₂ → z₁ ℤ+ succ z₂ == succ (z₁ ℤ+ z₂)
ℤ+-succ (pos O) z₂ = idp
ℤ+-succ (pos (S n)) z₂ = ap succ (ℤ+-succ (pos n) z₂)
ℤ+-succ (negsucc O) z₂ = pred-succ z₂ ∙ ! (succ-pred z₂)
ℤ+-succ (negsucc (S n)) z₂ =
pred (negsucc n ℤ+ succ z₂)
=⟨ ap pred (ℤ+-succ (negsucc n) z₂) ⟩
pred (succ (negsucc n ℤ+ z₂))
=⟨ pred-succ (negsucc n ℤ+ z₂) ⟩
negsucc n ℤ+ z₂
=⟨ ! $ succ-pred (negsucc n ℤ+ z₂) ⟩
succ (pred (negsucc n ℤ+ z₂))
∎
ℤ+-pred : ∀ z₁ z₂ → z₁ ℤ+ pred z₂ == pred (z₁ ℤ+ z₂)
ℤ+-pred (pos O) z₂ = idp
ℤ+-pred (pos (S n)) z₂ =
succ (pos n ℤ+ pred z₂)
=⟨ ap succ (ℤ+-pred (pos n) z₂) ⟩
succ (pred (pos n ℤ+ z₂))
=⟨ succ-pred (pos n ℤ+ z₂) ⟩
pos n ℤ+ z₂
=⟨ ! $ pred-succ (pos n ℤ+ z₂) ⟩
pred (succ (pos n ℤ+ z₂))
∎
ℤ+-pred (negsucc O) z₂ = idp
ℤ+-pred (negsucc (S n)) z₂ = ap pred (ℤ+-pred (negsucc n) z₂)
ℤ+-comm : ∀ z₁ z₂ → z₁ ℤ+ z₂ == z₂ ℤ+ z₁
ℤ+-comm (pos O) z₂ = ! $ ℤ+-unit-r z₂
ℤ+-comm (pos (S n₁)) z₂ =
succ (pos n₁ ℤ+ z₂)
=⟨ ℤ+-comm (pos n₁) z₂ |in-ctx succ ⟩
succ (z₂ ℤ+ pos n₁)
=⟨ ! $ ℤ+-succ z₂ (pos n₁) ⟩
z₂ ℤ+ pos (S n₁)
∎
ℤ+-comm (negsucc O) z₂ =
pred z₂
=⟨ ! $ ℤ+-unit-r z₂ |in-ctx pred ⟩
pred (z₂ ℤ+ pos O)
=⟨ ! $ ℤ+-pred z₂ (pos O) ⟩
z₂ ℤ+ negsucc O
∎
ℤ+-comm (negsucc (S n)) z₂ =
pred (negsucc n ℤ+ z₂)
=⟨ ℤ+-comm (negsucc n) z₂ |in-ctx pred ⟩
pred (z₂ ℤ+ negsucc n)
=⟨ ! $ ℤ+-pred z₂ (negsucc n) ⟩
z₂ ℤ+ negsucc (S n)
∎
private
pos-S-ℤ+-negsucc-S : ∀ n₁ n₂ → pos (S n₁) ℤ+ negsucc (S n₂) == pos n₁ ℤ+ negsucc n₂
pos-S-ℤ+-negsucc-S O n₂ = idp
pos-S-ℤ+-negsucc-S (S n₁) n₂ = ap succ $ pos-S-ℤ+-negsucc-S n₁ n₂
negsucc-S-ℤ+-pos-S : ∀ n₁ n₂ → negsucc (S n₁) ℤ+ pos (S n₂) == negsucc n₁ ℤ+ pos n₂
negsucc-S-ℤ+-pos-S O n₂ = idp
negsucc-S-ℤ+-pos-S (S n₁) n₂ = ap pred $ negsucc-S-ℤ+-pos-S n₁ n₂
ℤ~-inv-r : ∀ z → z ℤ+ ℤ~ z == 0
ℤ~-inv-r (pos O) = idp
ℤ~-inv-r (pos (S O)) = idp
ℤ~-inv-r (pos (S (S n))) =
pos (S (S n)) ℤ+ negsucc (S n) =⟨ pos-S-ℤ+-negsucc-S (S n) n ⟩
pos (S n) ℤ+ negsucc n =⟨ ℤ~-inv-r (pos (S n)) ⟩
0 ∎
ℤ~-inv-r (negsucc O) = idp
ℤ~-inv-r (negsucc (S n)) =
negsucc (S n) ℤ+ pos (S (S n)) =⟨ negsucc-S-ℤ+-pos-S n (S n) ⟩
negsucc n ℤ+ pos (S n) =⟨ ℤ~-inv-r (negsucc n) ⟩
0 ∎
ℤ~-inv-l : ∀ z → ℤ~ z ℤ+ z == 0
ℤ~-inv-l (pos O) = idp
ℤ~-inv-l (pos (S n)) = ℤ~-inv-r (negsucc n)
ℤ~-inv-l (negsucc n) = ℤ~-inv-r (pos (S n))
ℤ-group-structure : GroupStructure ℤ
ℤ-group-structure = record
{ ident = 0
; inv = ℤ~
; comp = _ℤ+_
; unitl = ℤ+-unit-l
; unitr = ℤ+-unit-r
; assoc = ℤ+-assoc
; invr = ℤ~-inv-r
; invl = ℤ~-inv-l
}
ℤ-group : Group₀
ℤ-group = group _ ℤ-is-set ℤ-group-structure
-- More properties about [ℤ~]
ℤ~-succ : ∀ z → ℤ~ (succ z) == pred (ℤ~ z)
ℤ~-succ (pos 0) = idp
ℤ~-succ (pos (S n)) = idp
ℤ~-succ (negsucc 0) = idp
ℤ~-succ (negsucc (S n)) = idp
ℤ~-pred : ∀ z → ℤ~ (pred z) == succ (ℤ~ z)
ℤ~-pred (pos 0) = idp
ℤ~-pred (pos 1) = idp
ℤ~-pred (pos (S (S n))) = idp
ℤ~-pred (negsucc 0) = idp
ℤ~-pred (negsucc (S n)) = idp
ℤ~-ℤ+ : ∀ z₁ z₂ → ℤ~ (z₁ ℤ+ z₂) == ℤ~ z₁ ℤ+ ℤ~ z₂
ℤ~-ℤ+ (pos 0) z₂ = idp
ℤ~-ℤ+ (pos 1) z₂ = ℤ~-succ z₂
ℤ~-ℤ+ (pos (S (S n))) z₂ =
ℤ~-succ (pos (S n) ℤ+ z₂) ∙ ap pred (ℤ~-ℤ+ (pos (S n)) z₂)
ℤ~-ℤ+ (negsucc O) z₂ = ℤ~-pred z₂
ℤ~-ℤ+ (negsucc (S n)) z₂ =
ℤ~-pred (negsucc n ℤ+ z₂) ∙ ap succ (ℤ~-ℤ+ (negsucc n) z₂)
|
{
"alphanum_fraction": 0.5414735301,
"avg_line_length": 27.6026936027,
"ext": "agda",
"hexsha": "4499739cc10b48e0ee629b81bf4f4fec7dd18338",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cmknapp/HoTT-Agda",
"max_forks_repo_path": "core/lib/types/Int.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cmknapp/HoTT-Agda",
"max_issues_repo_path": "core/lib/types/Int.agda",
"max_line_length": 90,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cmknapp/HoTT-Agda",
"max_stars_repo_path": "core/lib/types/Int.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 4036,
"size": 8198
}
|
-- Andreas, 2016-11-03, issue #2291 reported by Aerate
test = let {{_}} = _ in _
-- WAS: Internal error
-- NOW: Could not parse the left-hand side {{_}}
|
{
"alphanum_fraction": 0.6451612903,
"avg_line_length": 22.1428571429,
"ext": "agda",
"hexsha": "b783fb1975e49a2f51d7e6570d50fb50b8a8ed95",
"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/Issue2291-instance.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/Issue2291-instance.agda",
"max_line_length": 54,
"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/Issue2291-instance.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": 49,
"size": 155
}
|
module Issue4130 where
module Foo where
data D : Set where
con : D
module Bar (S : Set) where
open Foo public using (con)
open Bar using (con)
open Foo using (D; con)
data B : Set where
tt : B
ff : B
module _ (S : Set) where
open Bar S
f : D -> B
-- 'con' is not ambiguous, because although 'con' may refer to
-- 'Foo.D.con' or 'Bar.con', they are two different names of the
-- same constructor.
f con = tt
|
{
"alphanum_fraction": 0.6353211009,
"avg_line_length": 18.1666666667,
"ext": "agda",
"hexsha": "fe8d07eeedb8c18915790dbcd52633fd35ca19fb",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "shlevy/agda",
"max_forks_repo_path": "test/Succeed/Issue4130.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/Issue4130.agda",
"max_line_length": 66,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/Issue4130.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": 139,
"size": 436
}
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Algebra.Group.Morphism where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Algebra
open import Cubical.Algebra.Monoid.Morphism
open import Cubical.Algebra.Properties
open import Cubical.Relation.Binary.Reasoning.Equality
private
variable
g h : Level
-- The following definitions of GroupHom and GroupEquiv are level-wise heterogeneous.
-- This allows for example to deduce that G ≡ F from a chain of isomorphisms
-- G ≃ H ≃ F, even if H does not lie in the same level as G and F.
record IsGroupHom (G : Group g) (H : Group h) (f : ⟨ G ⟩ → ⟨ H ⟩) : Type (ℓ-max g h) where
constructor isgrouphom
private
module G = Group G
module H = Group H
field
preservesOp : Homomorphic₂ f G._•_ H._•_
preservesId : Homomorphic₀ f G.ε H.ε
preservesId = H.cancelʳ _ (
f G.ε H.• f G.ε ≡˘⟨ preservesOp G.ε G.ε ⟩
f (G.ε G.• G.ε) ≡⟨ cong f (G.identityˡ G.ε) ⟩
f G.ε ≡˘⟨ H.identityˡ (f G.ε) ⟩
H.ε H.• f G.ε ∎)
preservesInv : Homomorphic₁ f G._⁻¹ H._⁻¹
preservesInv x = H.inv-uniqueʳ _ _ (
f (x G.⁻¹) H.• f x ≡˘⟨ preservesOp (x G.⁻¹) x ⟩
f (x G.⁻¹ G.• x) ≡⟨ cong f (G.inverseˡ x) ⟩
f G.ε ≡⟨ preservesId ⟩
H.ε ∎)
record GroupHom (G : Group g) (H : Group h) : Type (ℓ-max g h) where
constructor grouphom
field
fun : ⟨ G ⟩ → ⟨ H ⟩
isHom : IsGroupHom G H fun
open IsGroupHom isHom public
record GroupEquiv (G : Group g) (H : Group h) : Type (ℓ-max g h) where
constructor groupequiv
field
eq : ⟨ G ⟩ ≃ ⟨ H ⟩
isHom : IsGroupHom G H (equivFun eq)
open IsGroupHom isHom public
hom : GroupHom G H
hom = grouphom (equivFun eq) isHom
instance
GroupHomOperators : HomOperators (Group g) (Group h) (ℓ-max g h)
GroupHomOperators = record { _⟶ᴴ_ = GroupHom; _≃ᴴ_ = GroupEquiv }
private
variable
G : Group g
H : Group h
isPropIsMonoidHom : {f : ⟨ G ⟩ → ⟨ H ⟩}
→ isProp (IsMonoidHom (Group.monoid G) (Group.monoid H) f)
isPropIsMonoidHom {G = G} {H = H} {f = f} (ismonoidhom aOp aId) (ismonoidhom bOp bId) =
cong₂ ismonoidhom
(isPropHomomorphic₂ (Group.is-set H) f (Group._•_ G) (Group._•_ H) aOp bOp)
(isPropHomomorphic₀ (Group.is-set H) f (Group.ε G) (Group.ε H) aId bId)
isPropIsGroupHom : {f : ⟨ G ⟩ → ⟨ H ⟩} → isProp (IsGroupHom G H f)
isPropIsGroupHom {G = G} {H = H} {f = f} (isgrouphom aHom) (isgrouphom bHom) =
cong isgrouphom
(isPropHomomorphic₂ (Group.is-set H) f (Group._•_ G) (Group._•_ H) aHom bHom)
IsGroupHom→IsMonoidHom : {f : ⟨ G ⟩ → ⟨ H ⟩}
→ IsGroupHom G H f → IsMonoidHom (Group.monoid G) (Group.monoid H) f
IsGroupHom→IsMonoidHom hom .IsMonoidHom.preservesOp = hom .IsGroupHom.preservesOp
IsGroupHom→IsMonoidHom hom .IsMonoidHom.preservesId = IsGroupHom.preservesId hom
IsMonoidHom→IsGroupHom : {f : ⟨ G ⟩ → ⟨ H ⟩}
→ IsMonoidHom (Group.monoid G) (Group.monoid H) f → IsGroupHom G H f
IsMonoidHom→IsGroupHom hom .IsGroupHom.preservesOp = hom .IsMonoidHom.preservesOp
IsGroupHom≃IsMonoidHom : {f : ⟨ G ⟩ → ⟨ H ⟩}
→ IsGroupHom G H f ≃ IsMonoidHom (Group.monoid G) (Group.monoid H) f
IsGroupHom≃IsMonoidHom {G = G} {H = H} = isoToEquiv
(iso IsGroupHom→IsMonoidHom
IsMonoidHom→IsGroupHom
(λ _ → isPropIsMonoidHom {G = G} {H = H} _ _)
(λ _ → isPropIsGroupHom _ _))
GroupHom→MonoidHom : (G ⟶ᴴ H) → (Group.monoid G ⟶ᴴ Group.monoid H)
GroupHom→MonoidHom hom .MonoidHom.fun = hom .GroupHom.fun
GroupHom→MonoidHom hom .MonoidHom.isHom = IsGroupHom→IsMonoidHom (hom .GroupHom.isHom)
MonoidHom→GroupHom : (Group.monoid G ⟶ᴴ Group.monoid H) → (G ⟶ᴴ H)
MonoidHom→GroupHom hom .GroupHom.fun = hom .MonoidHom.fun
MonoidHom→GroupHom hom .GroupHom.isHom = IsMonoidHom→IsGroupHom (hom .MonoidHom.isHom)
GroupHom≃MonoidHom : (G ⟶ᴴ H) ≃ (Group.monoid G ⟶ᴴ Group.monoid H)
GroupHom≃MonoidHom {G = G} {H = H} =
isoToEquiv (iso GroupHom→MonoidHom
MonoidHom→GroupHom
MonoidHom→GroupHom→MonoidHom
GroupHom→MonoidHom→GroupHom)
where
MonoidHom→GroupHom→MonoidHom :
section (GroupHom→MonoidHom {G = G} {H = H}) (MonoidHom→GroupHom {G = G} {H = H})
MonoidHom→GroupHom→MonoidHom (monoidhom fun prf) =
cong₂ monoidhom refl (isPropIsMonoidHom {G = G} {H = H} _ _)
GroupHom→MonoidHom→GroupHom :
retract (GroupHom→MonoidHom {G = G} {H = H}) (MonoidHom→GroupHom {G = G} {H = H})
GroupHom→MonoidHom→GroupHom (grouphom fun prf) =
cong₂ grouphom refl (isPropIsGroupHom _ _)
GroupEquiv→MonoidEquiv : G ≃ᴴ H → Group.monoid G ≃ᴴ Group.monoid H
GroupEquiv→MonoidEquiv eq .MonoidEquiv.eq = eq .GroupEquiv.eq
GroupEquiv→MonoidEquiv eq .MonoidEquiv.isHom = IsGroupHom→IsMonoidHom (eq .GroupEquiv.isHom)
MonoidEquiv→GroupEquiv : Group.monoid G ≃ᴴ Group.monoid H → G ≃ᴴ H
MonoidEquiv→GroupEquiv eq .GroupEquiv.eq = eq .MonoidEquiv.eq
MonoidEquiv→GroupEquiv eq .GroupEquiv.isHom = IsMonoidHom→IsGroupHom (eq .MonoidEquiv.isHom)
GroupEquiv≃MonoidEquiv : G ≃ᴴ H ≃ Group.monoid G ≃ᴴ Group.monoid H
GroupEquiv≃MonoidEquiv {G = G} {H = H} =
isoToEquiv (iso GroupEquiv→MonoidEquiv
MonoidEquiv→GroupEquiv
MonoidEquiv→GroupEquiv→MonoidEquiv
GroupEquiv→MonoidEquiv→GroupEquiv)
where
MonoidEquiv→GroupEquiv→MonoidEquiv :
section (GroupEquiv→MonoidEquiv {G = G} {H = H}) (MonoidEquiv→GroupEquiv {G = G} {H = H})
MonoidEquiv→GroupEquiv→MonoidEquiv (monoidequiv eq prf) =
cong₂ monoidequiv refl (isPropIsMonoidHom {G = G} {H = H} _ _)
GroupEquiv→MonoidEquiv→GroupEquiv :
retract (GroupEquiv→MonoidEquiv {G = G} {H = H}) (MonoidEquiv→GroupEquiv {G = G} {H = H})
GroupEquiv→MonoidEquiv→GroupEquiv (groupequiv eq prf) =
cong₂ groupequiv refl (isPropIsGroupHom _ _)
|
{
"alphanum_fraction": 0.6593572146,
"avg_line_length": 38.2948717949,
"ext": "agda",
"hexsha": "1f6c5c89a15480ff5b1267b11475e8f61363cd7d",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bijan2005/univalent-foundations",
"max_forks_repo_path": "Cubical/Algebra/Group/Morphism.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "bijan2005/univalent-foundations",
"max_issues_repo_path": "Cubical/Algebra/Group/Morphism.agda",
"max_line_length": 95,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bijan2005/univalent-foundations",
"max_stars_repo_path": "Cubical/Algebra/Group/Morphism.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2238,
"size": 5974
}
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Algebra.RingSolver.CommRingExamples where
open import Cubical.Foundations.Prelude
open import Cubical.Data.FinData
open import Cubical.Data.Nat using (ℕ)
open import Cubical.Data.Vec.Base
open import Cubical.Algebra.CommRing
open import Cubical.Algebra.RingSolver.NatAsAlmostRing
open import Cubical.Algebra.RingSolver.RawAlgebra renaming (⟨_⟩ to ⟨_⟩ᵣ)
open import Cubical.Algebra.RingSolver.CommRingSolver
-- In scope for debugging:
open import Cubical.Algebra.RingSolver.CommRingHornerForms
private
variable
ℓ : Level
module MultivariateSolving (R : CommRing {ℓ}) where
-- In scope for debuggin:
-- In scope for solver use:
open CommRingStr (snd R)
AsAlgebra = CommRing→RawℤAlgebra R
X : ℤExpr R 3
X = ∣ Fin.zero
Y : ℤExpr R 3
Y = ∣ (suc Fin.zero)
Z : ℤExpr R 3
Z = ∣ (suc (suc Fin.zero))
_ : (x y z : (fst R)) → x · y · z ≡ z · y · x
_ = λ x y z →
let
lhs = X ·' Y ·' Z
rhs = Z ·' Y ·' X
in solve R lhs rhs (x ∷ y ∷ z ∷ []) refl
_ : (x y z : (fst R)) → x · (y + z) ≡ z · x + y · x
_ = λ x y z →
let
lhs = X ·' (Y +' Z)
rhs = Z ·' X +' Y ·' X
in solve R lhs rhs (x ∷ y ∷ z ∷ []) refl
_ : (x y z : (fst R)) → x · (y - z) ≡ (- z) · x + y · x
_ = λ x y z →
let
lhs = X ·' (Y +' (-' Z))
rhs = (-' Z) ·' X +' (Y ·' X)
in solve R lhs rhs (x ∷ y ∷ z ∷ []) refl
{-
A bigger example, copied from 'Example.agda'
-}
_ : (x y z : (fst R)) → (x + y) · (x + y) · (x + y) · (x + y)
≡ x · x · x · x + (scalar R 4) · x · x · x · y + (scalar R 6) · x · x · y · y
+ (scalar R 4) · x · y · y · y + y · y · y · y
_ = λ x y z → let
lhs = (X +' Y) ·' (X +' Y) ·' (X +' Y) ·' (X +' Y)
rhs = X ·' X ·' X ·' X
+' (K 4) ·' X ·' X ·' X ·' Y
+' (K 6) ·' X ·' X ·' Y ·' Y
+' (K 4) ·' X ·' Y ·' Y ·' Y
+' Y ·' Y ·' Y ·' Y
in solve R lhs rhs (x ∷ y ∷ z ∷ []) refl
_ : (x y z : (fst R)) → (x + y) · (x - y) ≡ (x · x - y · y)
_ = λ x y z →
let
lhs = (X +' Y) ·' (X +' (-' Y))
rhs = (X ·' X) +' (-' (Y ·' Y))
in solve R lhs rhs (x ∷ y ∷ z ∷ []) refl
|
{
"alphanum_fraction": 0.4322554237,
"avg_line_length": 29.4337349398,
"ext": "agda",
"hexsha": "2be2b91bae41acbb36911833e4877e08b9712619",
"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": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "apabepa10/cubical",
"max_forks_repo_path": "Cubical/Algebra/RingSolver/CommRingExamples.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05",
"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": "apabepa10/cubical",
"max_issues_repo_path": "Cubical/Algebra/RingSolver/CommRingExamples.agda",
"max_line_length": 93,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "apabepa10/cubical",
"max_stars_repo_path": "Cubical/Algebra/RingSolver/CommRingExamples.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 905,
"size": 2443
}
|
{-# OPTIONS --safe #-}
module Cubical.Algebra.AbGroup.Instances.DirectSumFun where
open import Cubical.Foundations.Prelude
open import Cubical.Data.Nat
open import Cubical.Algebra.AbGroup
open import Cubical.Algebra.DirectSum.DirectSumFun.Base
open import Cubical.Algebra.DirectSum.DirectSumFun.Properties
private variable
ℓ : Level
module _ (G : (n : ℕ) → Type ℓ) (Gstr : (n : ℕ) → AbGroupStr (G n)) where
open AbGroupStr
open DSF-properties G Gstr
⊕Fun-AbGr : AbGroup ℓ
fst ⊕Fun-AbGr = ⊕Fun G Gstr
0g (snd ⊕Fun-AbGr) = 0⊕Fun
AbGroupStr._+_ (snd ⊕Fun-AbGr) = _+⊕Fun_
- snd ⊕Fun-AbGr = Inv⊕Fun
isAbGroup (snd ⊕Fun-AbGr) = makeIsAbGroup isSet⊕Fun +⊕FunAssoc +⊕FunRid +⊕FunInvR +⊕FunComm
|
{
"alphanum_fraction": 0.7215189873,
"avg_line_length": 27.3461538462,
"ext": "agda",
"hexsha": "64c1bb4ff21e6d09a88e158bd68867cd8d232c29",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "thomas-lamiaux/cubical",
"max_forks_repo_path": "Cubical/Algebra/AbGroup/Instances/DirectSumFun.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "thomas-lamiaux/cubical",
"max_issues_repo_path": "Cubical/Algebra/AbGroup/Instances/DirectSumFun.agda",
"max_line_length": 93,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "thomas-lamiaux/cubical",
"max_stars_repo_path": "Cubical/Algebra/AbGroup/Instances/DirectSumFun.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 270,
"size": 711
}
|
{-# OPTIONS --cubical --safe #-}
module Data.Tree.Rose where
open import Prelude
open import Data.List
mutual
Forest : Type a → Type a
Forest A = List (Tree A)
infixr 5 _&_
record Tree {a} (A : Type a) : Type a where
inductive
constructor _&_
field
root : A
children : Forest A
open Tree public
module WikiTree where
open import Data.List.Syntax
wikiTree : Tree ℕ
wikiTree =
1 &
[ 2 &
[ 5 &
[ 9 & []
, 10 & [] ]
, 6 & [] ]
, 3 & []
, 4 &
[ 7 &
[ 11 & []
, 12 & [] ]
, 8 & [] ] ]
|
{
"alphanum_fraction": 0.4347826087,
"avg_line_length": 17.1025641026,
"ext": "agda",
"hexsha": "d92ffc7367e200a685c571d27aab7fd53b1f1a27",
"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/Tree/Rose.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/Tree/Rose.agda",
"max_line_length": 45,
"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/Tree/Rose.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": 193,
"size": 667
}
|
{-# OPTIONS --cubical #-}
module Demos.Printf where
open import Data.List
open import Data.String
open import Prelude
open import Data.Nat.Show
data Fstr : Type where
[] : Fstr
%s_ : Fstr → Fstr
%i_ : Fstr → Fstr
_∷_ : Char → Fstr → Fstr
parse : String → Fstr
parse = go ∘ unpack
where
go : List Char → Fstr
go ('%' ∷ 's' ∷ xs) = %s go xs
go ('%' ∷ 'i' ∷ xs) = %i go xs
go [] = []
go (x ∷ xs) = x ∷ go xs
Format : Fstr → Type
Format [] = String
Format (%s xs) = String → Format xs
Format (%i xs) = ℕ → Format xs
Format (x ∷ xs) = Format xs
format : (xs : Fstr) → Format xs
format = go pack
where
go : (List Char → String) → (xs : Fstr) → Format xs
go k [] = k []
go k (%s xs) s = go (k ∘ (unpack s ++_)) xs
go k (%i xs) i = go (k ∘ (unpack (showℕ i) ++_)) xs
go k (x ∷ xs) = go (k ∘ (x ∷_)) xs
printf : (fstr : String) → Format (parse fstr)
printf fstr = format (parse fstr)
-- Example:
--
-- >>> printf "%s, %i: %s" "hello" 2 "you"
-- "hello, 2: you"
|
{
"alphanum_fraction": 0.5528700906,
"avg_line_length": 21.1276595745,
"ext": "agda",
"hexsha": "f32188d7480ef06b6fed417a561d464abf124268",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z",
"max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/agda-playground",
"max_forks_repo_path": "Demos/Printf.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "oisdk/agda-playground",
"max_issues_repo_path": "Demos/Printf.agda",
"max_line_length": 53,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/agda-playground",
"max_stars_repo_path": "Demos/Printf.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": 390,
"size": 993
}
|
{-# OPTIONS --cubical-compatible #-}
-- Andreas, 2020-02-07, instances of #906 needing --cubical-compatible to throw
-- off the termination checker.
module Issue906WithoutK where
module Issue3081 where
postulate
X : Set
P : (x : X) → Set
any : {X : Set} → X
record W : Set where
field
x : X
p : P x
record Category : Set₁ where
field
z : W
s : W → W
{- Termination checking failed for the following functions:
functor
Problematic calls:
W.x (functor .Category.s u)
W.x (functor .Category.z)
-}
functor : Category
functor .Category.z .W.x = any
functor .Category.z .W.p = any
functor .Category.s u .W.x = any
functor .Category.s u .W.p = any
module Issue3081Ulf where
open import Agda.Builtin.Nat
record R : Set where
field
a : Nat
b : Nat
record S : Set where
field
r : R -- works if we give r and h the same number of arguments
h : Nat → R
open R
open S
f : S
f .r .a = 0
f .r .b = f .r .a
f .h n .a = n
f .h n .b = f .h n .a
-- Should all pass the termination checker.
|
{
"alphanum_fraction": 0.5841409692,
"avg_line_length": 18.3064516129,
"ext": "agda",
"hexsha": "25831de4a2c6d4d155f8b6c5459b741123635378",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "KDr2/agda",
"max_forks_repo_path": "test/Succeed/Issue906WithoutK.agda",
"max_issues_count": 6,
"max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "KDr2/agda",
"max_issues_repo_path": "test/Succeed/Issue906WithoutK.agda",
"max_line_length": 79,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "KDr2/agda",
"max_stars_repo_path": "test/Succeed/Issue906WithoutK.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 366,
"size": 1135
}
|
{-# OPTIONS --warning=error --safe --without-K #-}
open import LogicalFormulae
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import Functions.Definition
open import Setoids.Setoids
open import Setoids.Subset
open import Graphs.Definition
module Graphs.Bipartite where
Bipartite : {a b : _} {c : _} {V' : Set a} {V : Setoid {a} {b} V'} (G : Graph c V) → Set _
Bipartite {V' = V'} {V = V} G = Sg (V' → Set) (λ partition → ((x y : V') → (Setoid._∼_ V x y) → partition x → partition y) & ((x : V') → (partition x) || ((partition x) → False)) & ((x y : V') → (Graph._<->_ G x y) → (partition x) → ((partition y) → False)))
|
{
"alphanum_fraction": 0.6228482003,
"avg_line_length": 45.6428571429,
"ext": "agda",
"hexsha": "48214f7e5ffaee47f442620769c3349eb156a3ef",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Smaug123/agdaproofs",
"max_forks_repo_path": "Graphs/Bipartite.agda",
"max_issues_count": 14,
"max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Smaug123/agdaproofs",
"max_issues_repo_path": "Graphs/Bipartite.agda",
"max_line_length": 258,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Smaug123/agdaproofs",
"max_stars_repo_path": "Graphs/Bipartite.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": 224,
"size": 639
}
|
module Typing where
import IO.Primitive as Prim
--open import Data.Unit
open import ParseTree
open import Data.Nat
open import Data.List
open import Data.String
open import Data.Unit
{-# FOREIGN GHC
import InteractWithAgda
#-}
postulate getTypes : List ParseTree -> ℕ -> List Expr -> String -> Prim.IO (List Expr)
{-# COMPILE GHC getTypes = getTypes #-}
postulate getEnvironment : List ParseTree -> ℕ -> String -> Prim.IO (List TypeSignature)
{-# COMPILE GHC getEnvironment = getEnvironment #-}
postulate output : String -> Prim.IO ⊤
{-# COMPILE GHC output = output #-}
|
{
"alphanum_fraction": 0.7291666667,
"avg_line_length": 27.4285714286,
"ext": "agda",
"hexsha": "971d71512b0cd377d74123d32556213851141bbf",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-01-31T08:40:41.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-01-31T08:40:41.000Z",
"max_forks_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "omega12345/RefactorAgda",
"max_forks_repo_path": "RefactorAgdaEngine/Typing.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b",
"max_issues_repo_issues_event_max_datetime": "2019-02-05T12:53:36.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-31T08:03:07.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "omega12345/RefactorAgda",
"max_issues_repo_path": "RefactorAgdaEngine/Typing.agda",
"max_line_length": 89,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "omega12345/RefactorAgda",
"max_stars_repo_path": "RefactorAgdaEngine/Typing.agda",
"max_stars_repo_stars_event_max_datetime": "2019-05-03T10:03:36.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-01-31T14:10:18.000Z",
"num_tokens": 141,
"size": 576
}
|
{-# OPTIONS --without-K --rewriting #-}
open import lib.Basics
open import lib.types.TLevel
open import lib.types.Pi
open import lib.types.Sigma
open import lib.NType2
module lib.types.Truncation where
module _ {i} where
postulate -- HIT
Trunc : (n : ℕ₋₂) (A : Type i) → Type i
[_] : {n : ℕ₋₂} {A : Type i} → A → Trunc n A
instance Trunc-level : {n : ℕ₋₂} {A : Type i} → has-level n (Trunc n A)
module TruncElim {n : ℕ₋₂} {A : Type i} {j} {P : Trunc n A → Type j}
{{p : (x : Trunc n A) → has-level n (P x)}} (d : (a : A) → P [ a ]) where
postulate -- HIT
f : Π (Trunc n A) P
[_]-β : ∀ a → f [ a ] ↦ d a
{-# REWRITE [_]-β #-}
open TruncElim public renaming (f to Trunc-elim)
module TruncRec {i j} {n : ℕ₋₂} {A : Type i} {B : Type j} {{p : has-level n B}}
(d : A → B) where
private
module M = TruncElim {{λ x → p}} d
f : Trunc n A → B
f = M.f
open TruncRec public renaming (f to Trunc-rec)
module TruncRecType {i j} {n : ℕ₋₂} {A : Type i} (d : A → n -Type j) where
open TruncRec {{n -Type-level j}} d public
flattening-Trunc : Σ (Trunc (S n) A) (fst ∘ f) ≃ Trunc (S n) (Σ A (fst ∘ d))
flattening-Trunc = equiv to from to-from from-to where
to-aux : (x : Trunc (S n) A) → (fst (f x) → Trunc (S n) (Σ A (fst ∘ d)))
to-aux = Trunc-elim (λ a b → [ (a , b) ])
to : Σ (Trunc (S n) A) (fst ∘ f) → Trunc (S n) (Σ A (fst ∘ d))
to (x , y) = to-aux x y
from-aux : Σ A (fst ∘ d) → Σ (Trunc (S n) A) (fst ∘ f)
from-aux (a , b) = ([ a ] , b)
from : Trunc (S n) (Σ A (fst ∘ d)) → Σ (Trunc (S n) A) (fst ∘ f)
from = Trunc-rec {{Σ-level ⟨⟩ (λ x → raise-level _ (snd (f x)))}}
from-aux where
to-from : (x : Trunc (S n) (Σ A (fst ∘ d))) → to (from x) == x
to-from = Trunc-elim (λ _ → idp)
from-to-aux : (a : Trunc (S n) A) (b : fst (f a)) → from (to-aux a b) == (a , b)
from-to-aux = Trunc-elim {{λ _ → Π-level (λ _ → =-preserves-level (Σ-level ⟨⟩ (λ x → raise-level _ (snd (f x)))))}}
(λ a b → idp)
from-to : (x : Σ (Trunc (S n) A) (fst ∘ f)) → from (to x) == x
from-to (a , b) = from-to-aux a b
⊙Trunc : ∀ {i} → ℕ₋₂ → Ptd i → Ptd i
⊙Trunc n ⊙[ A , a ] = ⊙[ Trunc n A , [ a ] ]
module _ {i} {n : ℕ₋₂} {A : Type i} where
Trunc= : (a b : Trunc (S n) A) → n -Type i
Trunc= = Trunc-elim (λ a → Trunc-elim ((λ b → (Trunc n (a == b) , Trunc-level))))
Trunc=-equiv : (a b : Trunc (S n) A) → (a == b) ≃ fst (Trunc= a b)
Trunc=-equiv a b = equiv (to a b) (from a b) (to-from a b) (from-to a b) where
to-aux : (a : Trunc (S n) A) → fst (Trunc= a a)
to-aux = Trunc-elim {{λ x → raise-level _ (snd (Trunc= x x))}}
(λ a → [ idp ])
to : (a b : Trunc (S n) A) → (a == b → fst (Trunc= a b))
to a .a idp = to-aux a
from-aux : (a b : A) → a == b → [ a ] == [ b ] :> Trunc (S n) A
from-aux a .a idp = idp
from : (a b : Trunc (S n) A) → (fst (Trunc= a b) → a == b)
from = Trunc-elim (λ a → Trunc-elim (λ b → Trunc-rec (from-aux a b)))
to-from-aux : (a b : A) → (p : a == b) → to _ _ (from-aux a b p) == [ p ]
to-from-aux a .a idp = idp
to-from : (a b : Trunc (S n) A) (x : fst (Trunc= a b)) → to a b (from a b x) == x
to-from = Trunc-elim {{λ x → Π-level (λ y → Π-level (λ _ → =-preserves-level (raise-level _ (snd (Trunc= x y)))))}}
(λ a → Trunc-elim {{λ x → Π-level (λ _ → =-preserves-level (raise-level _ (snd (Trunc= [ a ] x))))}}
(λ b → Trunc-elim
(to-from-aux a b)))
from-to-aux : (a : Trunc (S n) A) → from a a (to-aux a) == idp
from-to-aux = Trunc-elim (λ _ → idp)
from-to : (a b : Trunc (S n) A) (p : a == b) → from a b (to a b p) == p
from-to a .a idp = from-to-aux a
Trunc=-path : (a b : Trunc (S n) A) → (a == b) == fst (Trunc= a b)
Trunc=-path a b = ua (Trunc=-equiv a b)
{- Universal property -}
abstract
Trunc-rec-is-equiv : ∀ {i j} (n : ℕ₋₂) (A : Type i) (B : Type j)
{{p : has-level n B}} → is-equiv (Trunc-rec {{p}} :> ((A → B) → (Trunc n A → B)))
Trunc-rec-is-equiv n A B {{p}} = is-eq _ (λ f → f ∘ [_])
(λ f → λ= (Trunc-elim (λ a → idp))) (λ f → idp)
Trunc-preserves-level : ∀ {i} {A : Type i} {n : ℕ₋₂} (m : ℕ₋₂)
→ has-level n A → has-level n (Trunc m A)
Trunc-preserves-level {n = ⟨-2⟩} _ p = has-level-in
([ contr-center p ] , Trunc-elim (λ a → ap [_] (contr-path p a)))
Trunc-preserves-level ⟨-2⟩ _ = contr-has-level Trunc-level
Trunc-preserves-level {n = (S n)} (S m) c = has-level-in (λ t₁ t₂ →
Trunc-elim
{{λ s₁ → prop-has-level-S {A = has-level n (s₁ == t₂)} has-level-is-prop}}
(λ a₁ → Trunc-elim
{{λ s₂ → prop-has-level-S {A = has-level n ([ a₁ ] == s₂)} has-level-is-prop}}
(λ a₂ → equiv-preserves-level
((Trunc=-equiv [ a₁ ] [ a₂ ])⁻¹)
{{Trunc-preserves-level {n = n} m (has-level-apply c a₁ a₂)}})
t₂)
t₁)
{- an n-type is equivalent to its n-truncation -}
unTrunc-equiv : ∀ {i} {n : ℕ₋₂} (A : Type i)
{{_ : has-level n A}} → Trunc n A ≃ A
unTrunc-equiv A = equiv f [_] (λ _ → idp) g-f where
f = Trunc-rec (idf _)
g-f = Trunc-elim (λ _ → idp)
⊙unTrunc-equiv : ∀ {i} {n : ℕ₋₂} (X : Ptd i)
{{_ : has-level n (de⊙ X)}} → ⊙Trunc n X ⊙≃ X
⊙unTrunc-equiv {n = n} X = ≃-to-⊙≃ (unTrunc-equiv (de⊙ X)) idp
-- Equivalence associated to the universal property
Trunc-extend-equiv : ∀ {i j} (n : ℕ₋₂) (A : Type i) (B : Type j)
{{p : has-level n B}} → (A → B) ≃ (Trunc n A → B)
Trunc-extend-equiv n A B = (Trunc-rec , Trunc-rec-is-equiv n A B)
Trunc-fmap : ∀ {i j} {n : ℕ₋₂} {A : Type i} {B : Type j} → ((A → B) → (Trunc n A → Trunc n B))
Trunc-fmap f = Trunc-rec ([_] ∘ f)
⊙Trunc-fmap : ∀ {i j} {n : ℕ₋₂} {X : Ptd i} {Y : Ptd j} → ((X ⊙→ Y) → (⊙Trunc n X ⊙→ ⊙Trunc n Y))
⊙Trunc-fmap F = Trunc-fmap (fst F) , ap [_] (snd F)
Trunc-fmap2 : ∀ {i j k} {n : ℕ₋₂} {A : Type i} {B : Type j} {C : Type k}
→ ((A → B → C) → (Trunc n A → Trunc n B → Trunc n C))
Trunc-fmap2 f = Trunc-rec (λ a → Trunc-fmap (f a))
-- XXX What is the naming convention?
Trunc-fpmap : ∀ {i j} {n : ℕ₋₂} {A : Type i} {B : Type j} {f g : A → B}
→ f ∼ g → Trunc-fmap {n = n} f ∼ Trunc-fmap g
Trunc-fpmap h = Trunc-elim (ap [_] ∘ h)
Trunc-fmap-idf : ∀ {i} {n : ℕ₋₂} {A : Type i}
→ ∀ x → Trunc-fmap {n = n} (idf A) x == x
Trunc-fmap-idf =
Trunc-elim (λ _ → idp)
Trunc-fmap-∘ : ∀ {i j k} {n : ℕ₋₂} {A : Type i} {B : Type j} {C : Type k}
→ (g : B → C) → (f : A → B)
→ ∀ x → Trunc-fmap {n = n} g (Trunc-fmap f x) == Trunc-fmap (g ∘ f) x
Trunc-fmap-∘ g f =
Trunc-elim (λ _ → idp)
Trunc-csmap : ∀ {i₀ i₁ j₀ j₁} {n : ℕ₋₂}
{A₀ : Type i₀} {A₁ : Type i₁} {B₀ : Type j₀} {B₁ : Type j₁}
{f : A₀ → B₀} {g : A₁ → B₁} {hA : A₀ → A₁} {hB : B₀ → B₁}
→ CommSquare f g hA hB
→ CommSquare (Trunc-fmap {n = n} f) (Trunc-fmap g) (Trunc-fmap hA) (Trunc-fmap hB)
Trunc-csmap (comm-sqr cs) = comm-sqr $ Trunc-elim (ap [_] ∘ cs)
{- Pushing concatentation through Trunc= -}
module _ {i} {n : ℕ₋₂} {A : Type i} where
{- concatenation in Trunc= -}
Trunc=-∙ : {ta tb tc : Trunc (S n) A}
→ fst (Trunc= ta tb) → fst (Trunc= tb tc) → fst (Trunc= ta tc)
Trunc=-∙ {ta = ta} {tb = tb} {tc = tc} =
Trunc-elim {P = λ ta → C ta tb tc}
{{λ ta → level ta tb tc}}
(λ a → Trunc-elim {P = λ tb → C [ a ] tb tc}
{{λ tb → level [ a ] tb tc}}
(λ b → Trunc-elim {P = λ tc → C [ a ] [ b ] tc}
{{λ tc → level [ a ] [ b ] tc}}
(λ c → Trunc-fmap2 _∙_)
tc)
tb)
ta
where
C : (ta tb tc : Trunc (S n) A) → Type i
C ta tb tc = fst (Trunc= ta tb) → fst (Trunc= tb tc) → fst (Trunc= ta tc)
level : (ta tb tc : Trunc (S n) A) → has-level (S n) (C ta tb tc)
level ta tb tc = raise-level _ $
Π-level (λ _ → Π-level (λ _ → snd (Trunc= ta tc)))
{- XXX naming convention -}
Trunc=-∙-comm : {x y z : Trunc (S n) A }
(p : x == y) (q : y == z)
→ –> (Trunc=-equiv x z) (p ∙ q)
== Trunc=-∙ {ta = x} (–> (Trunc=-equiv x y) p) (–> (Trunc=-equiv y z) q)
Trunc=-∙-comm {x = x} idp idp =
Trunc-elim
{P = λ x → –> (Trunc=-equiv x x) idp
== Trunc=-∙ {ta = x} (–> (Trunc=-equiv x x) idp)
(–> (Trunc=-equiv x x) idp)}
{{λ x → raise-level _ $ =-preserves-level (snd (Trunc= x x))}}
(λ a → idp)
x
{- naturality of Trunc=-equiv -}
module _ {i j} {n : ℕ₋₂} {A : Type i} {B : Type j} (f : A → B) where
Trunc=-fmap : ∀ (a₀ a₁ : Trunc (S n) A)
→ (fst (Trunc= {n = n} a₀ a₁) → fst (Trunc= {n = n} (Trunc-fmap f a₀) (Trunc-fmap f a₁)))
Trunc=-fmap = Trunc-elim
{P = λ a₀ → ∀ a₁ → (fst (Trunc= a₀ a₁) → fst (Trunc= (Trunc-fmap f a₀) (Trunc-fmap f a₁)))}
{{λ a₀ → Π-level λ a₁ → Π-level λ _ → raise-level _ $ snd (Trunc= (Trunc-fmap f a₀) (Trunc-fmap f a₁))}}
(λ a₀ → Trunc-elim
{P = λ a₁ → (fst (Trunc= [ a₀ ] a₁) → fst (Trunc= [ f a₀ ] (Trunc-fmap f a₁)))}
{{λ a₁ → Π-level λ _ → raise-level _ $ snd (Trunc= [ f a₀ ] (Trunc-fmap f a₁))}}
(λ a₁ → Trunc-fmap (ap f)))
module _ {i j} {n : ℕ₋₂} {A : Type i} {B : Type j} (f : A → B) where
Trunc=-equiv-nat : ∀ (a₀ a₁ : Trunc (S n) A) (p : a₀ == a₁)
→ –> (Trunc=-equiv (Trunc-fmap f a₀) (Trunc-fmap f a₁)) (ap (Trunc-fmap f) p)
== Trunc=-fmap f a₀ a₁ (–> (Trunc=-equiv a₀ a₁) p)
Trunc=-equiv-nat a₀ .a₀ idp =
Trunc-elim
{P = λ a
→ –> (Trunc=-equiv (Trunc-fmap f a) (Trunc-fmap f a)) idp
== Trunc=-fmap f a a (–> (Trunc=-equiv a a) idp)}
{{λ a → raise-level _ $ =-preserves-level $ snd ((Trunc= (Trunc-fmap f a) (Trunc-fmap f a)))}}
(λ _ → idp)
a₀
{- Truncation preserves equivalences - more convenient than univalence+ap
- when we need to know the forward or backward function explicitly -}
module _ {i j} {n : ℕ₋₂} {A : Type i} {B : Type j} where
Trunc-isemap : {f : A → B} → is-equiv f → is-equiv (Trunc-fmap {n = n} f)
Trunc-isemap {f-orig} ie = is-eq f g f-g g-f where
f = Trunc-fmap f-orig
g = Trunc-fmap (is-equiv.g ie)
f-g : ∀ tb → f (g tb) == tb
f-g = Trunc-elim (ap [_] ∘ is-equiv.f-g ie)
g-f : ∀ ta → g (f ta) == ta
g-f = Trunc-elim (ap [_] ∘ is-equiv.g-f ie)
Trunc-emap : A ≃ B → Trunc n A ≃ Trunc n B
Trunc-emap (f , f-ie) = Trunc-fmap f , Trunc-isemap f-ie
Trunc-csemap : ∀ {i₀ i₁ j₀ j₁} {n : ℕ₋₂}
{A₀ : Type i₀} {A₁ : Type i₁} {B₀ : Type j₀} {B₁ : Type j₁}
{f : A₀ → B₀} {g : A₁ → B₁} {hA : A₀ → A₁} {hB : B₀ → B₁}
→ CommSquareEquiv f g hA hB
→ CommSquareEquiv (Trunc-fmap {n = n} f) (Trunc-fmap g) (Trunc-fmap hA) (Trunc-fmap hB)
Trunc-csemap (cs , hA-ise , hB-ise) = Trunc-csmap cs , Trunc-isemap hA-ise , Trunc-isemap hB-ise
transport-Trunc : ∀ {i j} {A : Type i} {n : ℕ₋₂} (P : A → Type j)
{x y : A} (p : x == y) (b : P x)
→ transport (Trunc n ∘ P) p [ b ] == [ transport P p b ]
transport-Trunc _ idp _ = idp
Trunc-fuse : ∀ {i} (A : Type i) (m n : ℕ₋₂)
→ Trunc m (Trunc n A) ≃ Trunc (minT m n) A
Trunc-fuse A m n = equiv
(Trunc-rec {{raise-level-≤T (minT≤l m n) Trunc-level}}
(Trunc-rec {{raise-level-≤T (minT≤r m n) Trunc-level}}
[_]))
(Trunc-rec ([_] ∘ [_]))
(Trunc-elim (λ _ → idp))
(Trunc-elim (Trunc-elim
{{λ _ → =-preserves-level (Trunc-preserves-level _ Trunc-level)}}
(λ _ → idp)))
where
instance
l : has-level (minT m n) (Trunc m (Trunc n A))
l with (minT-out m n)
l | inl p = transport (λ k → has-level k (Trunc m (Trunc n A)))
(! p) Trunc-level
l | inr q = Trunc-preserves-level _
(transport (λ k → has-level k (Trunc n A))
(! q) Trunc-level)
Trunc-fuse-≤ : ∀ {i} (A : Type i) {m n : ℕ₋₂} (m≤n : m ≤T n)
→ Trunc m (Trunc n A) ≃ Trunc m A
Trunc-fuse-≤ A m≤n = equiv
(Trunc-rec (Trunc-rec {{raise-level-≤T m≤n Trunc-level}}
[_]))
(Trunc-rec ([_] ∘ [_]))
(Trunc-elim (λ _ → idp))
(Trunc-elim (Trunc-elim
{{λ _ → =-preserves-level (Trunc-preserves-level _ Trunc-level)}}
(λ _ → idp)))
{- Truncating a binary product is equivalent to truncating its components -}
Trunc-×-econv : ∀ {i} {j} (n : ℕ₋₂) (A : Type i) (B : Type j)
→ Trunc n (A × B) ≃ Trunc n A × Trunc n B
Trunc-×-econv n A B = equiv f g f-g g-f
where
f : Trunc n (A × B) → Trunc n A × Trunc n B
f = Trunc-rec (λ {(a , b) → [ a ] , [ b ]})
g : Trunc n A × Trunc n B → Trunc n (A × B)
g (ta , tb) = Trunc-rec (λ a → Trunc-rec (λ b → [ a , b ]) tb) ta
f-g : ∀ p → f (g p) == p
f-g (ta , tb) = Trunc-elim
{P = λ ta → f (g (ta , tb)) == (ta , tb)}
(λ a → Trunc-elim
{P = λ tb → f (g ([ a ] , tb)) == ([ a ] , tb)}
(λ b → idp)
tb)
ta
g-f : ∀ tab → g (f tab) == tab
g-f = Trunc-elim
{P = λ tab → g (f tab) == tab}
(λ ab → idp)
Trunc-×-conv : ∀ {i} {j} (n : ℕ₋₂) (A : Type i) (B : Type j)
→ Trunc n (A × B) == Trunc n A × Trunc n B
Trunc-×-conv n A B = ua (Trunc-×-econv n A B)
|
{
"alphanum_fraction": 0.5,
"avg_line_length": 38.082111437,
"ext": "agda",
"hexsha": "06b8f632a53575ac293a5b5ec2c202f53c9fddbf",
"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/Truncation.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/Truncation.agda",
"max_line_length": 119,
"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/Truncation.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 5557,
"size": 12986
}
|
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import homotopy.HSpace renaming (HSpaceStructure to HSS)
open import homotopy.Pi2HSusp
open import homotopy.WedgeExtension
open import lib.types.TwoSemiCategory
open import lib.two-semi-categories.FundamentalCategory
module homotopy.Pi2HSuspCompose {i} {X : Ptd i} {{_ : has-level 1 (de⊙ X)}}
{{is-0-connected : is-connected 0 (de⊙ X)}} (H-X : HSS X)
(H-X-assoc : associator H-X)
(coh-assoc-unit-l-r-pentagon : coh-unit-l-r-pentagon H-X H-X-assoc)
where
private
A = de⊙ X
e = pt X
open Pi2HSusp H-X public
infixr 80 _∙₁_
_∙₁_ : {x y z : Susp A} → Trunc 1 (x == y) → Trunc 1 (y == z) → Trunc 1 (x == z)
_∙₁_ {x} {y} {z} p q = _∙ₜ_ {A = Susp A} {ta = [ x ]} {tb = [ y ]} {tc = [ z ]} p q
module _ {k} {B : Type k} where
add-path-inverse-l : {x y z : B}
→ (p : x == y) (q : x == z)
→ p == (q ∙ ! q) ∙ p
add-path-inverse-l p q = ap (_∙ p) (! (!-inv-r q))
add-path-inverse-r : {x y z : B}
→ (p : x == y) (r : y == z)
→ p == p ∙ (r ∙ ! r)
add-path-inverse-r p r =
! (∙-unit-r p) ∙ ap (p ∙_) (! (!-inv-r r))
abstract
add-path-inverse-coh : {x y : B} (p : x == x) (q : x == y)
→ add-path-inverse-r p q ◃∙
ap (_∙ (q ∙ ! q)) (add-path-inverse-l p q) ◃∙
∙-assoc (q ∙ ! q) p (q ∙ ! q) ◃∎
=ₛ
add-path-inverse-l p q ◃∙
ap ((q ∙ ! q) ∙_) (add-path-inverse-r p q) ◃∎
add-path-inverse-coh p idp =
add-path-inverse-r p idp ◃∙
idp ◃∙
idp ◃∎
=ₛ⟨ 1 & 1 & expand [] ⟩
add-path-inverse-r p idp ◃∙
idp ◃∎
=ₛ⟨ 1 & 1 & expand [] ⟩
add-path-inverse-r p idp ◃∎
=ₛ₁⟨ ! (ap-idf (add-path-inverse-r p idp)) ⟩
ap (λ q → q) (add-path-inverse-r p idp) ◃∎
=ₛ⟨ 0 & 0 & contract ⟩
add-path-inverse-l p idp ◃∙
ap (λ q → q) (add-path-inverse-r p idp) ◃∎ ∎ₛ
comp-l-seq : (a' : A) → η (μ e a') =-= η e ∙ η a'
comp-l-seq a' =
η (μ e a')
=⟪ ap η (μ.unit-l a') ⟫
η a'
=⟪ add-path-inverse-l (η a') (merid e) ⟫
η e ∙ η a' ∎∎
comp-l : (a' : A) → η (μ e a') == η e ∙ η a'
comp-l a' = ↯ (comp-l-seq a')
comp-r-seq : (a : A) → η (μ a e) =-= η a ∙ η e
comp-r-seq a =
η (μ a e)
=⟪ ap η (μ.unit-r a) ⟫
η a
=⟪ add-path-inverse-r (η a) (merid e) ⟫
η a ∙ η e ∎∎
comp-r : (a : A) → η (μ a e) == η a ∙ η e
comp-r a = ↯ (comp-r-seq a)
comp-lr-coh : comp-l e == comp-r e
comp-lr-coh =
ap2 (λ p₁ p₂ → ap η p₁ ∙ p₂)
μ.coh
(add-path-inverse-lr-coh (merid e))
where
add-path-inverse-lr-coh : {B : Type i} {b b' : B} (p : b == b')
→ add-path-inverse-l (p ∙ ! p) p == add-path-inverse-r (p ∙ ! p) p
add-path-inverse-lr-coh idp = idp
comp-l₁ : (a' : A) → [ η (μ e a') ]₁ == [ η e ∙ η a' ]₁
comp-l₁ = ap [_]₁ ∘ comp-l
comp-r₁ : (a : A) → [ η (μ a e) ]₁ == [ η a ∙ η e ]₁
comp-r₁ = ap [_]₁ ∘ comp-r
comp-args : args {i} {i} {A} {e} {A} {e}
comp-args =
record {
m = -1; n = -1;
P = λ a a' → (Q a a' , ⟨⟩);
f = comp-r₁;
g = comp-l₁;
p = ap (ap [_]₁) (! comp-lr-coh)
}
where
Q : A → A → Type i
Q a a' = [ η (μ a a' ) ]₁ == [ η a ∙ η a' ]₁
module Comp = WedgeExt {i} {i} {A} {e} {A} {e} comp-args
comp : (a a' : A) → [ η (μ a a') ]₁ == [ η a ]₁ ∙₁ [ η a' ]₁
comp = Comp.ext
comp-unit-l : (a' : A) → comp e a' == comp-l₁ a'
comp-unit-l a' = Comp.β-r a'
comp-unit-r : (a : A) → comp a e == comp-r₁ a
comp-unit-r a = Comp.β-l a
module CoherenceProof (a' : A) where
P : A → A → Type i
P a a'' =
comp (μ a a') a'' ◃∙
ap (_∙₁ [ η a'' ]₁) (comp a a') ◃∙
ap [_]₁ (∙-assoc (η a) (η a') (η a'')) ◃∎
=ₛ
ap ([_]₁ ∘ η) (H-X-assoc a a' a'') ◃∙
comp a (μ a' a'') ◃∙
ap ([ η a ]₁ ∙₁_) (comp a' a'') ◃∎
P-is-prop : ∀ a a'' → is-prop (P a a'')
P-is-prop a a'' = =ₛ-level (Trunc-level {n = 1})
Q : A → A → hProp i
Q a a'' = P a a'' , P-is-prop a a''
inner-coh :
comp-r (μ e a') ◃∙
ap (_∙ η e) (comp-l a') ◃∙
∙-assoc (η e) (η a') (η e) ◃∎
=ₛ
ap η (H-X-assoc e a' e) ◃∙
comp-l (μ a' e) ◃∙
ap (η e ∙_) (comp-r a') ◃∎
inner-coh =
comp-r (μ e a') ◃∙
ap (_∙ η e) (comp-l a') ◃∙
∙-assoc (η e) (η a') (η e) ◃∎
=ₛ⟨ 0 & 1 & expand (comp-r-seq (μ e a')) ⟩
ap η (μ.unit-r (μ e a')) ◃∙
add-path-inverse-r (η (μ e a')) (merid e) ◃∙
ap (_∙ η e) (comp-l a') ◃∙
∙-assoc (η e) (η a') (η e) ◃∎
=ₛ⟨ 2 & 1 & ap-seq-∙ (_∙ η e) (comp-l-seq a') ⟩
ap η (μ.unit-r (μ e a')) ◃∙
add-path-inverse-r (η (μ e a')) (merid e) ◃∙
ap (_∙ η e) (ap η (μ.unit-l a')) ◃∙
ap (_∙ η e) (add-path-inverse-l (η a') (merid e)) ◃∙
∙-assoc (η e) (η a') (η e) ◃∎
=ₛ⟨ 1 & 2 & !ₛ $
homotopy-naturality-from-idf (_∙ η e)
(λ r → add-path-inverse-r r (merid e))
(ap η (μ.unit-l a')) ⟩
ap η (μ.unit-r (μ e a')) ◃∙
ap η (μ.unit-l a') ◃∙
add-path-inverse-r (η a') (merid e) ◃∙
ap (_∙ η e) (add-path-inverse-l (η a') (merid e)) ◃∙
∙-assoc (η e) (η a') (η e) ◃∎
=ₛ⟨ 2 & 3 & add-path-inverse-coh (η a') (merid e) ⟩
ap η (μ.unit-r (μ e a')) ◃∙
ap η (μ.unit-l a') ◃∙
add-path-inverse-l (η a') (merid e) ◃∙
ap (η e ∙_) (add-path-inverse-r (η a') (merid e)) ◃∎
=ₛ⟨ 0 & 2 & ap-seq-=ₛ η (coh-assoc-unit-l-r-pentagon a') ⟩
ap η (H-X-assoc e a' e) ◃∙
ap η (μ.unit-l (μ a' e)) ◃∙
ap η (μ.unit-r a') ◃∙
add-path-inverse-l (η a') (merid e) ◃∙
ap (η e ∙_) (add-path-inverse-r (η a') (merid e)) ◃∎
=ₛ⟨ 2 & 2 &
homotopy-naturality-from-idf (η e ∙_)
(λ v → add-path-inverse-l v (merid e))
(ap η (μ.unit-r a')) ⟩
ap η (H-X-assoc e a' e) ◃∙
ap η (μ.unit-l (μ a' e)) ◃∙
add-path-inverse-l (η (μ a' e)) (merid e) ◃∙
ap (η e ∙_) (ap η (μ.unit-r a')) ◃∙
ap (η e ∙_) (add-path-inverse-r (η a') (merid e)) ◃∎
=ₛ⟨ 3 & 2 & ∙-ap-seq (η e ∙_) (comp-r-seq a')⟩
ap η (H-X-assoc e a' e) ◃∙
ap η (μ.unit-l (μ a' e)) ◃∙
add-path-inverse-l (η (μ a' e)) (merid e) ◃∙
ap (η e ∙_) (comp-r a') ◃∎
=ₛ⟨ 1 & 2 & contract ⟩
ap η (H-X-assoc e a' e) ◃∙
comp-l (μ a' e) ◃∙
ap (η e ∙_) (comp-r a') ◃∎ ∎ₛ
coh : P e e
coh =
comp (μ e a') e ◃∙
ap (_∙₁ [ η e ]₁) (comp e a') ◃∙
ap [_]₁ (∙-assoc (η e) (η a') (η e)) ◃∎
=ₛ₁⟨ 0 & 1 & comp-unit-r (μ e a') ⟩
comp-r₁ (μ e a') ◃∙
ap (_∙₁ [ η e ]₁) (comp e a') ◃∙
ap [_]₁ (∙-assoc (η e) (η a') (η e)) ◃∎
=ₛ₁⟨ 1 & 1 & step₂ ⟩
comp-r₁ (μ e a') ◃∙
ap [_]₁ (ap (_∙ η e) (comp-l a')) ◃∙
ap [_]₁ (∙-assoc (η e) (η a') (η e)) ◃∎
=ₛ⟨ 0 & 3 & ap-seq-=ₛ [_]₁ inner-coh ⟩
ap [_]₁ (ap η (H-X-assoc e a' e)) ◃∙
comp-l₁ (μ a' e) ◃∙
ap [_]₁ (ap (η e ∙_) (comp-r a')) ◃∎
=ₛ₁⟨ 0 & 1 & ∘-ap [_]₁ η (H-X-assoc e a' e) ⟩
ap ([_]₁ ∘ η) (H-X-assoc e a' e) ◃∙
comp-l₁ (μ a' e) ◃∙
ap [_]₁ (ap (η e ∙_) (comp-r a')) ◃∎
=ₛ₁⟨ 1 & 1 & ! (comp-unit-l (μ a' e)) ⟩
ap ([_]₁ ∘ η) (H-X-assoc e a' e) ◃∙
comp e (μ a' e) ◃∙
ap [_]₁ (ap (η e ∙_) (comp-r a')) ◃∎
=ₛ₁⟨ 2 & 1 & step₈ ⟩
ap ([_]₁ ∘ η) (H-X-assoc e a' e) ◃∙
comp e (μ a' e) ◃∙
ap ([ η e ]₁ ∙₁_) (comp a' e) ◃∎ ∎ₛ
where
step₂ : ap (_∙₁ [ η e ]₁) (comp e a') == ap [_]₁ (ap (_∙ η e) (comp-l a'))
step₂ =
ap (_∙₁ [ η e ]₁) (comp e a')
=⟨ ap (ap (_∙₁ [ η e ]₁)) (comp-unit-l a') ⟩
ap (_∙₁ [ η e ]₁) (comp-l₁ a')
=⟨ ∘-ap (_∙₁ [ η e ]₁) [_]₁ (comp-l a') ⟩
ap ([_]₁ ∘ (_∙ η e)) (comp-l a')
=⟨ ap-∘ [_]₁ (_∙ η e) (comp-l a') ⟩
ap [_]₁ (ap (_∙ η e) (comp-l a')) =∎
step₈ : ap [_]₁ (ap (η e ∙_) (comp-r a')) == ap ([ η e ]₁ ∙₁_) (comp a' e)
step₈ =
ap [_]₁ (ap (η e ∙_) (comp-r a'))
=⟨ ∘-ap [_]₁ (η e ∙_) (comp-r a') ⟩
ap (λ v → [ η e ∙ v ]₁) (comp-r a')
=⟨ ap-∘ ([ η e ]₁ ∙₁_) [_]₁ (comp-r a') ⟩
ap ([ η e ]₁ ∙₁_) (comp-r₁ a')
=⟨ ! (ap (ap ([ η e ]₁ ∙₁_)) (comp-unit-r a')) ⟩
ap ([ η e ]₁ ∙₁_) (comp a' e) =∎
abstract
comp-coh : (a a' a'' : A)
→ comp (μ a a') a'' ◃∙
ap (λ v → v ∙₁ [ η a'' ]₁) (comp a a') ◃∙
ap [_]₁ (∙-assoc (η a) (η a') (η a'')) ◃∎
=ₛ
ap ([_]₁ ∘ η) (H-X-assoc a a' a'') ◃∙
comp a (μ a' a'') ◃∙
ap (λ v → [ η a ] ∙₁ v) (comp a' a'') ◃∎
comp-coh a a' a'' =
prop-over-connected {A = A} {a = e} {{is-0-connected}}
(λ a → CoherenceProof.Q a' a a'')
(prop-over-connected {A = A} {a = e} {{is-0-connected}}
(λ a'' → CoherenceProof.Q a' e a'')
(CoherenceProof.coh a')
a'')
a
comp-functor : (pentagon : coh-assoc-pentagon H-X H-X-assoc)
→ TwoSemiFunctor
(HSpace-2-semi-category H-X {{⟨⟩}} H-X-assoc pentagon)
(=ₜ-fundamental-cat (Susp (de⊙ X)))
comp-functor _ =
record
{ F₀ = λ _ → [ north ]
; F₁ = λ x → [ η x ]
; pres-comp = comp
; pres-comp-coh = comp-coh
}
|
{
"alphanum_fraction": 0.4020142677,
"avg_line_length": 33.8014184397,
"ext": "agda",
"hexsha": "a0a80d4c38e4c530002c79fecb49a38f6be09432",
"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": "theorems/homotopy/Pi2HSuspCompose.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": "theorems/homotopy/Pi2HSuspCompose.agda",
"max_line_length": 85,
"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": "theorems/homotopy/Pi2HSuspCompose.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": 4429,
"size": 9532
}
|
module Basics where
_%_ : {A B : Set}{C : B -> Set}
(f : (x : B) -> C x)(g : A -> B)(x : A) -> C (g x)
f % g = \x -> f (g x)
-- Logic
data False : Set where
record True : Set where
tt : True
tt = _
¬_ : Set -> Set
¬ A = A -> False
record ∃ {A : Set}(P : A -> Set) : Set where
field
witness : A
proof : P witness
∃-intro : {A : Set}{P : A -> Set}(x : A) -> P x -> ∃ P
∃-intro x p = record { witness = x; proof = p }
infixr 15 _/\_ _×_
data _×_ (A B : Set) : Set where
_,_ : A -> B -> A × B
_/\_ = _×_
-- Maybe
data Lift (A : Set) : Set where
bot : Lift A
lift : A -> Lift A
_=<<_ : {A B : Set} -> (A -> Lift B) -> Lift A -> Lift B
f =<< bot = bot
f =<< lift v = f v
-- Nat
data Nat : Set where
zero : Nat
suc : Nat -> Nat
-- Identity
infix 10 _==_
data _==_ {A : Set}(x : A) : A -> Set where
refl : x == x
data Id {A : Set}(x : A) : Set where
it : (y : A) -> x == y -> Id x
-- Booleans
data Bool : Set where
true : Bool
false : Bool
data LR : Set where
left : LR
right : LR
if_then_else_ : {A : Set} -> Bool -> A -> A -> A
if true then x else y = x
if false then x else y = y
-- Lists
infixr 50 _::_
data List (A : Set) : Set where
[] : List A
_::_ : A -> List A -> List A
data Elem {A : Set}(x : A) : List A -> Set where
hd : forall {xs} -> Elem x (x :: xs)
tl : forall {y xs} -> Elem x xs -> Elem x (y :: xs)
|
{
"alphanum_fraction": 0.4903502502,
"avg_line_length": 16.4588235294,
"ext": "agda",
"hexsha": "ace6a18a6b536261c0d1cff2ce2f19fc6047e7d9",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "examples/outdated-and-incorrect/cbs/Basics.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "examples/outdated-and-incorrect/cbs/Basics.agda",
"max_line_length": 56,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "examples/outdated-and-incorrect/cbs/Basics.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": 550,
"size": 1399
}
|
module Cryptol where
open import Bool
open import Nat
open import Eq
postulate
Int : Set
Float : Set
Char : Set
String : Set
{-# BUILTIN INTEGER Int #-}
{-# BUILTIN FLOAT Float #-}
{-# BUILTIN CHAR Char #-}
{-# BUILTIN STRING String #-}
data List (A : Set) : Set where
Nil : List A
Cons : A → List A → List A
{-# BUILTIN LIST List #-}
{-# BUILTIN NIL Nil #-}
{-# BUILTIN CONS Cons #-}
append : {A : Set} → List A → List A → List A
append Nil ys = ys
append (Cons x xs) ys = Cons x (append xs ys)
infixr 5 _::_
data Vec (A : Set) : ℕ → Set where
Nil : Vec A Z
_::_ : {n : ℕ} → A → Vec A n → Vec A (S n)
_++_ : ∀ {A m n} → Vec A m → Vec A n → Vec A (m + n)
Nil ++ ys = ys
(x :: xs) ++ ys = x :: (xs ++ ys)
data Bit : Set where
O : Bit
I : Bit
Word : ℕ → Set
Word n = Vec Bit n
data SnocView {A : Set} : List A → Set where
Nil : SnocView Nil
Snoc : (xs : List A) → (x : A) → SnocView (append xs (Cons x Nil))
view : {A : Set} → (xs : List A) → SnocView xs
view Nil = Nil
view (Cons x xs) with view xs
view (Cons x _) | Nil = Snoc Nil x
view (Cons x _) | Snoc ys y = Snoc (Cons x ys) y
rotateRight : {A : Set} → List A → List A
rotateRight xs with view xs
rotateRight _ | Nil = Nil
rotateRight _ | Snoc ys y = Cons y ys
take : ∀ {A m} → (n : ℕ) → Vec A (n + m) → Vec A n
take Z l = Nil
take (S k) (x :: xs) = x :: take k xs
drop : ∀ {A m} → (n : ℕ) → Vec A (n + m) → Vec A m
drop Z xs = xs
drop (S k) (x :: xs) = drop k xs
split : ∀ {A} → (n : ℕ) → (m : ℕ) → Vec A (m × n) → Vec (Vec A n) m
split n Z Nil = Nil
split n (S k) xs = (take n xs) :: (split n k (drop n xs))
concat : ∀ {A n m} → Vec (Vec A n) m → Vec A (m × n)
concat Nil = Nil
concat (xs :: xss) = xs ++ concat xss
postulate
splitConcatLemma : ∀ {A : Set} → (m : ℕ) → (n : ℕ) → (xs : Vec A (m × n)) → concat (split n m xs) ≡ xs
takeDropLemma : ∀ {A : Set} → (n : ℕ) → (m : ℕ) → (xs : Vec A (n + m)) → ((take n xs) ++ (drop n xs)) ≡ xs
takeDropLemma Z m _ = Refl
takeDropLemma (S k) m (x :: xs) with ((take k xs) ++ (drop k xs)) | takeDropLemma k _ xs
takeDropLemma (S k) m (x :: xs) | ._ | Refl = Refl
data SplitView {A : Set} : {n : ℕ} → (m : ℕ) → Vec A (m × n) → Set where
[_] : ∀ {m n} → (xss : Vec (Vec A n) m) → SplitView m (concat xss)
splitView : {A : Set} → (n : ℕ) → (m : ℕ) → (xs : Vec A (m × n)) → SplitView m xs
splitView n m xs with concat (split n m xs) | [ split n m xs ] | splitConcatLemma m n xs
splitView n m xs | _ | v | Refl = v
data TakeView (A : Set) (m : ℕ) (n : ℕ) : Vec A (m + n) → Set where
Take : (xs : Vec A m) → (ys : Vec A n) → TakeView A m n (xs ++ ys)
--sv : {A : Set} → (n : ℕ) → (m : ℕ) → Vec a
swab : Word 32 → Word 32
swab xs with splitView 8 4 xs
swab _ | [ a :: b :: c :: d :: Nil ] = concat (b :: a :: c :: d :: Nil)
|
{
"alphanum_fraction": 0.520168362,
"avg_line_length": 27.1523809524,
"ext": "agda",
"hexsha": "6fb2b038093e7a9b32921520e6836b06e43f06f7",
"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": "76743baacba0f07992bac5234ba8045d18706893",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "mjhopkins/PowerOfPi",
"max_forks_repo_path": "Cryptol.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "76743baacba0f07992bac5234ba8045d18706893",
"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": "mjhopkins/PowerOfPi",
"max_issues_repo_path": "Cryptol.agda",
"max_line_length": 106,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "76743baacba0f07992bac5234ba8045d18706893",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "mjhopkins/PowerOfPi",
"max_stars_repo_path": "Cryptol.agda",
"max_stars_repo_stars_event_max_datetime": "2018-07-25T13:12:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-07-25T13:12:15.000Z",
"num_tokens": 1101,
"size": 2851
}
|
{-# OPTIONS --safe --warning=error --without-K #-}
open import Setoids.Setoids
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import Groups.Definition
open import Groups.Actions.Definition
open import Sets.EquivalenceRelations
module Groups.Actions.Orbit where
data Orbit {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} {_+_ : A → A → A} {G : Group S _+_} (action : GroupAction G T) (x : B) : Set (a ⊔ b ⊔ c ⊔ d) where
orbitElt : (g : A) → Orbit action x
orbitSetoid : {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} {_+_ : A → A → A} {G : Group S _+_} (action : GroupAction G T) (x : B) → Setoid (Orbit action x)
Setoid._∼_ (orbitSetoid {T = T} action x) (orbitElt a) (orbitElt b) = Setoid._∼_ T (GroupAction.action action a x) (GroupAction.action action b x)
Equivalence.reflexive (Setoid.eq (orbitSetoid {T = T} action x)) {orbitElt g} = Equivalence.reflexive (Setoid.eq T)
Equivalence.symmetric (Setoid.eq (orbitSetoid {T = T} action x)) {orbitElt g} {orbitElt h} = Equivalence.symmetric (Setoid.eq T)
Equivalence.transitive (Setoid.eq (orbitSetoid {T = T} action x)) {orbitElt g} {orbitElt h} {orbitElt i} = Equivalence.transitive (Setoid.eq T)
|
{
"alphanum_fraction": 0.6626506024,
"avg_line_length": 65.5263157895,
"ext": "agda",
"hexsha": "4c8f41fcb999a18869489bcca171a2efdfcf4d8e",
"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/Actions/Orbit.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/Actions/Orbit.agda",
"max_line_length": 194,
"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/Actions/Orbit.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": 449,
"size": 1245
}
|
{-# OPTIONS --safe --experimental-lossy-unification #-}
module Cubical.Algebra.Polynomials.Multivariate.Properties where
open import Cubical.Foundations.Prelude
open import Cubical.Data.Nat renaming(_+_ to _+n_; _·_ to _·n_)
open import Cubical.Data.Vec
open import Cubical.Data.Vec.OperationsNat
open import Cubical.Algebra.Ring
open import Cubical.Algebra.CommRing
open import Cubical.Algebra.Polynomials.Multivariate.Base
private variable
ℓ ℓ' : Level
module Nth-Poly-structure (A' : CommRing ℓ) (n : ℕ) where
private
A = fst A'
Ar = CommRing→Ring A'
open CommRingStr (snd A')
open RingTheory Ar
-----------------------------------------------------------------------------
poly-com-adv : (P Q R S : Poly A' n) → ((P poly+ Q) poly+ (R poly+ S) ≡ (P poly+ R) poly+ (Q poly+ S))
poly-com-adv P Q R S = ((P poly+ Q) poly+ (R poly+ S) ≡⟨ poly+Assoc (P poly+ Q) R S ⟩
(((P poly+ Q) poly+ R) poly+ S) ≡⟨ cong (λ X → X poly+ S) (sym (poly+Assoc P Q R)) ⟩
((P poly+ (Q poly+ R)) poly+ S) ≡⟨ cong (λ X → (P poly+ X) poly+ S) (poly+Comm Q R) ⟩
((P poly+ (R poly+ Q)) poly+ S) ≡⟨ cong (λ X → X poly+ S) (poly+Assoc P R Q) ⟩
(((P poly+ R) poly+ Q) poly+ S) ≡⟨ sym (poly+Assoc (P poly+ R) Q S) ⟩
((P poly+ R) poly+ (Q poly+ S)) ∎)
poly+IdL : (P : Poly A' n) → 0P poly+ P ≡ P
poly+IdL P = (poly+Comm 0P P) ∙ (poly+IdR P)
polyInv : Poly A' n → Poly A' n
polyInv = Poly-Rec-Set.f A' n (Poly A' n) trunc
0P
(λ v a → base v (- a))
(λ PS RS → PS poly+ RS)
poly+Assoc
poly+IdR
poly+Comm
(λ v → base v (- 0r) ≡⟨ cong (base v) 0Selfinverse ⟩ base v 0r ≡⟨ base-0P v ⟩ 0P ∎)
λ v a b → (base-poly+ v (- a) (- b)) ∙ (cong (base v) (-Dist a b))
polyInvol : (P : Poly A' n) → polyInv (polyInv P) ≡ P
polyInvol = Poly-Ind-Prop.f A' n (λ P → polyInv (polyInv P) ≡ P) (λ _ → trunc _ _)
refl
(λ v a → cong (base v) (-Idempotent a))
λ {P Q} ind-P ind-Q → cong₂ _poly+_ ind-P ind-Q
poly+InvR : (P : Poly A' n ) → P poly+ (polyInv P) ≡ 0P
poly+InvR = Poly-Ind-Prop.f A' n (λ P → (P poly+ polyInv P) ≡ 0P) (λ _ → trunc _ _)
(poly+IdR 0P)
(λ v a → (base-poly+ v a (- a)) ∙ cong (base v) (+Rinv a) ∙ base-0P v)
λ {P Q} ind-P ind-Q → ((P poly+ Q) poly+ ((polyInv P) poly+ (polyInv Q)))
≡⟨ poly-com-adv P Q (polyInv P) (polyInv Q) ⟩
((P poly+ polyInv P) poly+ (Q poly+ polyInv Q))
≡⟨ cong₂ _poly+_ ind-P ind-Q ⟩
(0P poly+ 0P)
≡⟨ poly+IdR 0P ⟩
0P ∎
poly+InvL : (P : Poly A' n) → (polyInv P) poly+ P ≡ 0P
poly+InvL = Poly-Ind-Prop.f A' n _ (λ _ → trunc _ _)
(poly+IdR 0P)
(λ v a → (base-poly+ v (- a) a) ∙ cong (base v) (snd (+Inv a)) ∙ base-0P v)
λ {U V} ind-U ind-V → poly-com-adv (polyInv U) (polyInv V) U V
∙ cong₂ _poly+_ ind-U ind-V
∙ poly+IdR 0P
-----------------------------------------------------------------------------
_poly*_ : Poly A' n → Poly A' n → Poly A' n
_poly*_ = -- Induction Left Argument
Poly-Rec-Set.f A' n (Poly A' n → Poly A' n)
(λ f g p q i j Q → trunc (f Q) (g Q) (λ X → p X Q) (λ X → q X Q) i j )
(λ Q → 0P)
(λ v a → -- Induction Right Argument
Poly-Rec-Set.f A' n (Poly A' n) trunc
0P
(λ v' a' → base (v +n-vec v') (a · a'))
_poly+_
poly+Assoc
poly+IdR
poly+Comm
(λ v' → (cong (base (v +n-vec v')) (0RightAnnihilates a)) ∙ (base-0P (v +n-vec v')))
λ v' b c → (base-poly+ (v +n-vec v') (a · b) (a · c))
∙ (cong (base (v +n-vec v')) (sym (·Rdist+ a b c))))
-- End Right induction
(λ PS QS Q → (PS Q) poly+ (QS Q) )
(λ PS QS RS i Q → poly+Assoc (PS Q) (QS Q) (RS Q) i)
(λ PS i Q → poly+IdR (PS Q) i)
(λ PS QS i Q → poly+Comm (PS Q) (QS Q) i)
(λ v → funExt (
-- Induction Right Argument
Poly-Ind-Prop.f A' n _ (λ _ → trunc _ _)
refl
(λ v' a' → (cong (base (v +n-vec v')) (0LeftAnnihilates a')) ∙ (base-0P (v +n-vec v')))
λ {P Q} ind-P ind-Q → (cong₂ _poly+_ ind-P ind-Q) ∙ (poly+IdR 0P) ))
-- End Right Induction
λ v a b → funExt (
-- Induction Right Argument
Poly-Ind-Prop.f A' n _ (λ _ → trunc _ _)
(poly+IdR 0P)
(λ v' c → (base-poly+ (v +n-vec v') (a · c) (b · c))
∙ (cong (base (v +n-vec v')) (sym (·Ldist+ a b c))))
λ {P Q} ind-P ind-Q → (poly-com-adv _ _ _ _) ∙ (cong₂ _poly+_ ind-P ind-Q))
-- End Right Induction
-- End Left Induction
poly*Assoc : (P Q R : Poly A' n) → P poly* (Q poly* R) ≡ (P poly* Q) poly* R
poly*Assoc = Poly-Ind-Prop.f A' n _
(λ P p q i Q R j → trunc (P poly* (Q poly* R)) ((P poly* Q) poly* R) (p Q R) (q Q R) i j)
(λ _ _ → refl)
(λ v a → Poly-Ind-Prop.f A' n _
(λ Q p q i R j → trunc (base v a poly* (Q poly* R)) ((base v a poly* Q) poly* R) (p R) (q R) i j)
(λ _ → refl)
(λ v' a' → Poly-Ind-Prop.f A' n _ (λ _ → trunc _ _)
refl
(λ v'' a'' → cong₂ base (+n-vec-assoc v v' v'') (·Assoc a a' a''))
(λ {U V} ind-U ind-V → cong₂ _poly+_ ind-U ind-V))
(λ {U V} ind-U ind-V R → cong₂ _poly+_ (ind-U R) (ind-V R)))
λ {U V} ind-U ind-V Q R → cong₂ _poly+_ (ind-U Q R) (ind-V Q R)
poly*AnnihilL : (P : Poly A' n) → 0P poly* P ≡ 0P
poly*AnnihilL P = refl
poly*AnnihilR : (P : Poly A' n) → P poly* 0P ≡ 0P
poly*AnnihilR = Poly-Ind-Prop.f A' n (λ P → (P poly* 0P) ≡ 0P) (λ _ → trunc _ _)
refl
(λ _ _ → refl)
λ {P Q} ind-P ind-Q → (cong₂ _poly+_ ind-P ind-Q) ∙ (poly+IdR 0P)
1P : Poly A' n
1P = base (replicate zero) 1r
poly*IdR : (P : Poly A' n) → P poly* 1P ≡ P
poly*IdR = Poly-Ind-Prop.f A' n (λ P → (P poly* 1P) ≡ P) (λ _ → trunc _ _)
refl
(λ v a → cong₂ base (+n-vec-rid v) (·Rid a))
(λ {P Q} ind-P ind-Q → cong₂ _poly+_ ind-P ind-Q)
poly*IdL : (P : Poly A' n) → 1P poly* P ≡ P
poly*IdL = Poly-Ind-Prop.f A' n (λ P → (1P poly* P) ≡ P) (λ _ → trunc _ _)
refl
(λ v a → cong₂ base (+n-vec-lid v) (·Lid a))
λ {P Q} ind-P ind-Q → cong₂ _poly+_ ind-P ind-Q
poly*DistR : (P Q R : Poly A' n) → P poly* (Q poly+ R) ≡ (P poly* Q) poly+ (P poly* R)
poly*DistR = Poly-Ind-Prop.f A' n _
(λ P p q i Q R j → trunc (P poly* (Q poly+ R)) ((P poly* Q) poly+ (P poly* R)) (p Q R) (q Q R) i j)
(λ _ _ → sym (poly+IdR 0P))
(λ v a → λ Q R → refl)
λ {U V} ind-U ind-V Q R → (cong₂ _poly+_ (ind-U Q R) (ind-V Q R)) ∙ poly-com-adv (U poly* Q) (U poly* R) (V poly* Q) (V poly* R)
poly*DistL : (P Q R : Poly A' n) → (P poly+ Q) poly* R ≡ (P poly* R) poly+ (Q poly* R)
poly*DistL P Q R = refl
poly*Comm : (P Q : Poly A' n) → P poly* Q ≡ Q poly* P
poly*Comm = Poly-Ind-Prop.f A' n _
(λ P p q i Q j → trunc (P poly* Q) (Q poly* P) (p Q) (q Q) i j)
(λ Q → sym (poly*AnnihilR Q))
(λ v a → Poly-Ind-Prop.f A' n _ (λ _ → trunc _ _)
refl
(λ v' a' → cong₂ base (+n-vec-comm v v') (·Comm a a'))
(λ {U V} ind-U ind-V → cong₂ _poly+_ ind-U ind-V))
λ {U V} ind-U ind-V Q → ((cong₂ _poly+_ (ind-U Q) (ind-V Q)) ∙ sym (poly*DistR Q U V))
|
{
"alphanum_fraction": 0.4154220215,
"avg_line_length": 45.6984126984,
"ext": "agda",
"hexsha": "c115bd3c51e9962a4bb8af3c73f07b32cdcadba9",
"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": "ce3120d3f8d692847b2744162bcd7a01f0b687eb",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "guilhermehas/cubical",
"max_forks_repo_path": "Cubical/Algebra/Polynomials/Multivariate/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ce3120d3f8d692847b2744162bcd7a01f0b687eb",
"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": "guilhermehas/cubical",
"max_issues_repo_path": "Cubical/Algebra/Polynomials/Multivariate/Properties.agda",
"max_line_length": 143,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "ce3120d3f8d692847b2744162bcd7a01f0b687eb",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "guilhermehas/cubical",
"max_stars_repo_path": "Cubical/Algebra/Polynomials/Multivariate/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z",
"num_tokens": 2968,
"size": 8637
}
|
module AKS.Binary where
open import AKS.Binary.Base public
|
{
"alphanum_fraction": 0.8166666667,
"avg_line_length": 15,
"ext": "agda",
"hexsha": "a9b4cd94696564f4034d35bf344e4bbc3c3b3e09",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mckeankylej/thesis",
"max_forks_repo_path": "proofs/AKS/Binary.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "mckeankylej/thesis",
"max_issues_repo_path": "proofs/AKS/Binary.agda",
"max_line_length": 34,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mckeankylej/thesis",
"max_stars_repo_path": "proofs/AKS/Binary.agda",
"max_stars_repo_stars_event_max_datetime": "2020-12-01T22:38:27.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-12-01T22:38:27.000Z",
"num_tokens": 14,
"size": 60
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.