Search is not available for this dataset
text
string | meta
dict |
---|---|
{-# OPTIONS --without-K --rewriting #-}
module Sharp where
open import Basics
open import Flat
open import lib.NType2
open import lib.Equivalence2
open import lib.types.Modality
-- --------------------------------------------------------------------------------------
-- Postulating the ♯ Modality
-- --------------------------------------------------------------------------------------
postulate
-- Here, I've tried to implement the rules for ♯ as in Shulman as closely as possible
-- to the sequents in Figure 3 of Section 3.
-- I'm pretty convinced now that this approach will work
-- However, as currently (02/18/19) rewrite rules do not see the ♭ modality,
-- it is not fully operational (and, clearly, has not been cleaned up).
-- The litmus is proving the lexness of ♯ along the lines of Shulman 3.7
{-
We implement the ♯ typing operations in two ways.
First, naively, as follows:
-}
-- Rule 1/5: Given a type A, we may form ♯ A
♯ : {i : ULevel} → Type i → Type i
-- Rule 2/5: Given an a : A, we may form a^♯ : ♯ A
_^♯ : {i : ULevel} {A : Type i} → A → ♯ A
-- Rule 3/5: Given a crisp a :: ♯ A, we may form a ↓♯ : A
_↓♯ : {@♭ i : ULevel} {@♭ A : Type i} → ♯ A ::→ A
{-
Rule 4/5
Given a :: A, we have that (a ^♯) ↓♯ ≡ a.
Δ | ∙ ⊢ a : A
-------------------------
Δ | Γ ⊢ (a ^♯) ↓♯ ≡ a : A
A and a are crisp, but we can have any other context Γ appear
which is fine, we just don't mention it.
-}
^↓♯ : {@♭ i : ULevel} {@♭ A : Type i} (@♭ a : A)
→ ((a ^♯) ↓♯) ↦ a
{-# REWRITE ^↓♯ #-}
{-
Rule 5/5
Given a : ♯ A in any context, we have (a ↓♯) ^♯ ≡ a
Δ | Γ ⊢ a : ♯ A
---------------
Δ | Γ ⊢ (a ↓♯) ^♯ ≡ a : ♯ A
Here we can do this in any context, but for agda that might mean
"factoring through" the ptwise operations first...
[WARNING] This implementation needs A to be crisp, and so doesn't
express the above sequent (I think...)
-}
↓^♯ : {@♭ i : ULevel} {@♭ A : Type i} (@♭ a : ♯ A)
→ ((a ↓♯) ^♯) ↦ a
{-# REWRITE ↓^♯ #-}
{-
Now, we will postulate "pointwise" versions of the above operations which
take in an additional crisp "context" Γ or Δ. The name Γ or Δ is chosen to match
the role of the explicit "context" with its analogy in Shulman.
In each of these, the context either becomes cohesive or not, according to the
rules from Shulman (which are reproduced here for comparison).
-}
{-
Rule 1/5, pointwise version
If one has a crisp context Γ and a type A which depends crisply on Γ,
Then one may form ♯ A which depends cohesively on Γ.
Or, read backwards, to construct ♯ A in the context Γ, it suffices to assume
That every variable x : Γ appearing in A is crisp.
Δ, Γ | ∙ ⊢ A : Type
-------------------
Δ | Γ ⊢ ♯ A : Type
-}
-- compare to ♯ : {i : ULevel} → Type i → Type i
♯-ptwise : {@♭ i : ULevel} {@♭ Γ : Type i} {j : ULevel}
(A : Γ ::→ Type j)
→ (Γ → Type j)
{-
We relate the pointwise # with the naive one in the obvious way.
That is, if we apply a pointwise operation to a crisp variable of the "context",
this is the same as applying the naive operation pointwise to that variable.
We take this sameness to be a judgemental equality, implemented as a rewrite rule.
-}
♯-law : {@♭ i : ULevel} {@♭ Γ : Type i} {j : ULevel}
(A : Γ ::→ Type j) (@♭ x : Γ)
→ (♯-ptwise A) x ↦ ♯ (A x)
{-# REWRITE ♯-law #-}
{-
Rule 2/5, pointwise version
If one has a : A in a crisp context Γ,
one may form a ^♯ : ♯ A in the cohesive context Γ.
Δ, Γ | ∙ ⊢ a : A
-------------------
Δ | Γ ⊢ a ^♯ : ♯ A
-}
^♯-ptwise : {@♭ i : ULevel} {@♭ Γ : Type i} {j : ULevel}
{A : Γ ::→ Type j} (a : (@♭ x : Γ) → A x)
→ (x : Γ) → (♯-ptwise A) x
{-
Relate the pointwise ^# with the naive one
-}
-- ^♯-law : {@♭ i : ULevel} {@♭ Γ : Type i} {j : ULevel}
-- {A : Γ ::→ Type j} (a : (@♭ x : Γ) → A x)
-- (@♭ x : Γ) → (^♯-ptwise a) x ↦ ((a x) ^♯)
-- {-# REWRITE ^♯-law #-}
{-
Rule 3/5, pointwise version
If one has a :: ♯ A in a crisp context Γ,
one may form a ↓♯ : A, also in a crisp context Γ
Δ | ∙ ⊢ a : ♯ A
---------------
Δ | Γ ⊢ a ↓♯ : A
It seems to me that to have a crisp variable of ♯ A requires A to be crisp...
But this pointwise definition one doesn't. It just requires that the context
is crisp.
-}
↓♯-ptwise : {@♭ i : ULevel} {@♭ Δ : Type i} {j : ULevel} {A : Δ ::→ Type j}
(a : (@♭ x : Δ) → (♯-ptwise A) x)
→ (@♭ x : Δ) → A x
{-
Rule 4/5, pointwise version
-}
^↓♯-ptwise : {@♭ i : ULevel} {@♭ Γ : Type i} {j : ULevel}
{A : Γ ::→ Type j} (a : (@♭ x : Γ) → A x) (@♭ x : Γ)
→ (((^♯-ptwise a) x) ↓♯) ↦ a x
{-
Rule 5/5, pointwise version
I'm having a difficulty implementing the ptwise version of ↓^♯ that will fire
whether or not A and a are crisp.
I think this is because if they are, it is a special case of the ↓^♯ rule,
But it is not strictly more general, since it keeps track of the "explicit context" Δ
Or, if I take everything in ↓♯-ptwise to be crisp, then it doesn't typecheck at this
generality.
-}
↓^♯-ptwise : {@♭ i : ULevel} {j : ULevel} {@♭ Δ : Type i} {A : Δ ::→ Type j}
(a : (@♭ x : Δ) → (♯-ptwise A) x) (@♭ x : Δ)
→ (((↓♯-ptwise a) x) ^♯) ↦ a x
-- ^^^ : (♯-ptwise A) x
-- ^^^^^^^^^^^ : (@♭ x : Δ) → A x
-- ^^^^^^^^^^^^^^^^ : A x
-- ^^^^^^^^^^^^^^^^^^^^^ : # (A x)
{-# REWRITE ↓^♯-ptwise #-}
-- [WARNING] When normalizing λ A x → (^♯-ptwise a) x, the rewrite ^♯-law will fire
-- turning it into ((a x) ^♯), which is ill typed on cohesive x : Γ (and the typechecker
-- complains)
↓♯-law : {@♭ i : ULevel} {@♭ Δ : Type i} {@♭ j : ULevel} {@♭ A : Δ ::→ Type j}
(@♭ a : (@♭ x : Δ) → (♯-ptwise A) x)
(@♭ x : Δ) → (↓♯-ptwise a) x ↦ ((a x) ↓♯)
{-# REWRITE ↓♯-law #-}
{-
Finally, we define some convenient notation for the ptwise operations.
To see how these work in practice, see below.
-}
syntax ♯-ptwise (λ γ → A) ctx = let♯ γ ::= ctx in♯-♯ A
syntax ^♯-ptwise (λ γ → a) ctx = let♯ γ ::= ctx in♯ a ^^♯
^♯-ptwise-explicit : {@♭ i : ULevel} {@♭ Γ : Type i} {j : ULevel}
(A : Γ ::→ Type j) (a : (@♭ x : Γ) → A x)
→ (x : Γ) → (♯-ptwise A) x
^♯-ptwise-explicit A = ^♯-ptwise {A = A}
syntax ^♯-ptwise-explicit A (λ γ → t) ctx = let♯ γ ::= ctx in♯ t ^^♯-in-family A
syntax ↓♯-ptwise (λ γ → a) ctx = let♯ γ ::= ctx in♯ a ↓↓♯
-- ----------------------------------------------------------------------------------------------
-- End of Postulates
-- ----------------------------------------------------------------------------------------------
-- We have to leave the universe levels out and assume they are crisp,
-- otherwise the "context record" becomes large.
-- It shouldn't matter tho, since ULevel is discrete.
module _ {@♭ i j : ULevel} where
private
record Γ : Type (lsucc (lmax i j)) where
constructor ctx
field
ᶜA : Type i
ᶜB : Type j
ᶜf : ᶜA → ᶜB
ᶜa : ♯ ᶜA
open Γ
-- Functoriality of ♯
♯→ : {A : Type i} {B : Type j}
(f : A → B) → (♯ A) → (♯ B)
♯→ {A} {B} f a =
let♯ γ ::= (ctx A B f a) in♯
(ᶜf γ (ᶜa γ ↓♯)) ^^♯ -- (f (a ↓♯)) ^♯
-- The naturality square of the unit (judgemental!)
♯→-nat : {A : Type i} {B : Type j} (f : A → B)
(a : A) → ((f a) ^♯) == ((♯→ f) (a ^♯))
♯→-nat {A} {B} f a = refl
-- ♯-elmination (Shulman Theorem 3.4)
{-
The general form of these definitions is:
Take the context (or the part of the context) you want to make crisp,
and make a private record Γ with fields ᶜx for every variable x in the context.
Then use the let♯ notation to crispify in the context.
-}
module _ {@♭ i j : ULevel} where
private
record Γ : Type (lsucc (lmax i j)) where
constructor ctx
field
ᶜA : Type i
ᶜB : (♯ ᶜA) → Type j
ᶜf : (a : ᶜA) → ♯ (ᶜB (a ^♯))
ᶜa : ♯ ᶜA
open Γ
♯-elim : {A : Type i} (B : ♯ A → Type j)
(f : (a : A) → ♯ (B (a ^♯)))
→ ((a : ♯ A) → ♯ (B a))
♯-elim {A} B f a =
let♯ γ ::= (ctx A B f a) in♯
(ᶜf γ (ᶜa γ ↓♯)) ↓♯ ^^♯
syntax ♯-elim B (λ x → t) a = let♯ x ^♯:= a in♯ t in-family B
-- Elimination with implicit family,
♯-elim' : {A : Type i} {B : ♯ A → Type j}
(f : (a : A) → ♯ (B (a ^♯)))
→ ((a : ♯ A) → ♯ (B a))
♯-elim' {A} {B} f a = ♯-elim {A} B f a
syntax ♯-elim' (λ x → t) a = let♯ x ^♯:= a in♯ t
-- Crisp eliminators
♯-elim-crisp : {@♭ A : Type i} (@♭ B : ♯ A → Type j)
(f : (@♭ a : A) → ♯ (B (a ^♯)))
→ (@♭ a : ♯ A) → ♯ (B a)
♯-elim-crisp B f a =
let♯ ᶜf ::= f in♯ ((ᶜf (a ↓♯)) ↓♯) ^^♯
syntax ♯-elim-crisp B (λ x → t) a = let♯ x ^♯::= a in♯ t in-family B
-- β holds judgementally :)
♯-elim-β : {A : Type i} {B : ♯ A → Type j}
(f : (a : A) → ♯ (B (a ^♯))) (a : A)
→ (♯-elim B f (a ^♯)) == (f a)
♯-elim-β f a = refl
-- ♯-elim is inverse to precomposition by _^♯
-- This proves that ♯ is a uniquely eliminating modality
♯-universal : {A : Type i} (B : ♯ A → Type j)
→ ((a : ♯ A) → ♯ (B a)) ≃ ((a : A) → ♯ (B (a ^♯)))
♯-universal {A} B = equiv to fro to-fro fro-to
where
to : (f : (a : ♯ A) → ♯ (B a))
→ (a : A) → ♯ (B (a ^♯))
to f = f ∘ _^♯
fro : ((a : A) → ♯ (B (a ^♯))) → ((a : ♯ A) → ♯ (B a))
fro = ♯-elim B
to-fro : (f : (a : A) → ♯ (B (a ^♯))) → to (fro f) == f
to-fro f = refl
fro-to : (f : (a : ♯ A) → ♯ (B a)) → fro (to f) == f
fro-to f = refl
-- A type is codiscrete if the inclusion a ↦ a ^♯ is an equivalence.
_is-codiscrete : {i : ULevel} (A : Type i) → Type i
A is-codiscrete = (_^♯ {A = A}) is-an-equiv
codisc-eq : {i : ULevel} {A : Type i} (p : A is-codiscrete) → A ≃ (♯ A)
codisc-eq = _^♯ ,_
un♯ : {i : ULevel} {A : Type i} (p : A is-codiscrete) → ♯ A → A
un♯ p = <– (codisc-eq p)
_is-codisc-is-a-prop : {i : ULevel} (A : Type i) → (A is-codiscrete) is-a-prop
A is-codisc-is-a-prop = is-equiv-is-prop
-- Shulman Theorem 3.5
-- ♯ A is codiscrete.
module _ {@♭ i : ULevel} where
private
record Γ : Type (lsucc i) where
constructor ctx
field
ᶜA : Type i
ᶜa : ♯ (♯ ᶜA)
open Γ
♯-is-codiscrete : (A : Type i) → (♯ A) is-codiscrete
♯-is-codiscrete = λ A →
(_^♯ {A = ♯ A}) is-an-equivalence-because fro is-inverse-by to-fro and fro-to
where
fro : {A : Type i} → ♯ (♯ A) → ♯ A
fro {A} a = let♯ γ ::= (ctx A a) in♯ ((ᶜa γ ↓♯) ↓♯) ^^♯
to-fro : {A : Type i} → (a : ♯ (♯ A)) → ((fro a) ^♯) == a
to-fro a = refl
fro-to : {A : Type i} → (a : ♯ A) → fro (a ^♯) == a
fro-to a = refl
{-
module _ {@♭ i j : ULevel} {@♭ i j : Type i} where
private
record Γ : Type (lsucc (lmax i j)) where
constructor ctx
field
ᶜA : Δ ::→ Type j
ᶜx : Δ
open Γ
♯-ptwise-is-codiscrete : (A : Δ ::→ Type j) (x : Δ)
→ ((♯-ptwise A) x) is-codiscrete
♯-ptwise-is-codiscrete = λ A x →
{!(_^\# {A = (♯-ptwise A) x}) is-an-equivalence-because fro is-inverse-by to-fro and fro-to!}
where
module _ {A : Δ ::→ Type j} {x : Δ} where
fro : ♯ ((♯-ptwise A) x) → (♯-ptwise A) x
fro = {!!}
-- to-fro : (a : ♯ ((♯-ptwise A) x)) → ((fro a) ^♯) == a
-- to-fro = {!!}
-- fro-to : ∀ a → fro (a ^♯) == a
-- fro-to = {!!}
-}
module _ {@♭ i j : ULevel} where
record CTX-uncrisp {@♭ A : Type i} : Type (lsucc (lmax i j)) where
constructor ctx
field
ᶜB : A → Type j
ᶜf : (@♭ a : A) → ♯ (ᶜB a)
ᶜa : A
uncrisp : {@♭ A : Type i} (B : A → Type j)
→ ((@♭ a : A) → ♯ (B a))
→ ((a : A) → ♯ (B a))
uncrisp B f a =
let♯ γ ::= (ctx B f a) in♯
(((ᶜf γ) (ᶜa γ)) ↓♯) ^^♯
where open CTX-uncrisp
Π-codisc : {@♭ i j : ULevel} {A : Type i} (B : A → Type j)
→ ((a : A) → ♯ (B a)) is-codiscrete
Π-codisc {A = A} B =
_^♯ is-an-equivalence-because
(λ f a → let♯ g ^♯:= f in♯ (g a)) is-inverse-by
(λ _ → refl) and (λ _ → refl)
-- The map ♯ (x == y) → (x == y) for x y : ♯ A, following RSS Lemma 1.25
module _ {@♭ i : ULevel} {A : Type i} {x y : ♯ A} where
private
constx : ♯ (x == y) → ♯ A
constx _ = x
consty : ♯ (x == y) → ♯ A
consty _ = y
lemma₀ : (constx ∘ _^♯) == (consty ∘ _^♯)
lemma₀ = λ= (λ p → p)
lemma₁ : constx == consty
lemma₁ = -- constx == consty because they are equalized by _^♯, via the universal prop of ♯
–>-is-inj (♯-universal (λ (_ : ♯ (x == y)) → A)) constx consty lemma₀
♯-=-retract : ♯ (x == y) → x == y
♯-=-retract p = app= lemma₁ p
-- To prove a type is an equivalence, it suffices to give a retract of _^♯
_is-codiscrete-because_is-retract-by_ : {@♭ i : ULevel} (A : Type i)
(r : ♯ A → A) (p : (a : A) → r (a ^♯) == a)
→ A is-codiscrete
A is-codiscrete-because r is-retract-by p =
(_^♯ {A = A}) is-an-equivalence-because r is-inverse-by
(λ a → -- Given an a : ♯ A, we will show ♯ ((r a)^♯ == a)
(let♯ b ^♯:= a in♯ -- We suppose a is b ^♯
((ap _^♯ (p b)) ^♯) -- apply p to b to get r (b ^♯) == b,
-- then apply _^♯ to get (r b^♯)^♯ == b^♯
-- then hit it with _^♯ to get ♯ ((r b^♯)^♯ == b^♯)
in-family (λ (a : ♯ A) → ((r a) ^♯) == a) -- which is ♯ ((r a)^♯ == a) by our hypothesis,
) -- and we can strip the ♯ becacuse equality types in ♯ are codiscrete.
|> (♯-=-retract {x = (r a) ^♯} {a})
)
and p
-- We follow RSS Lemma 1.25
=-is-codiscrete : {@♭ i : ULevel} {A : Type i} (x y : ♯ A)
→ (x == y) is-codiscrete
=-is-codiscrete {A = A} x y =
(x == y) is-codiscrete-because ♯-=-retract is-retract-by proof
where
abstract -- UNFINISHED
proof : (p : x == y) → (♯-=-retract (p ^♯)) == p
proof = trust-me
where postulate trust-me : (p : x == y) → (♯-=-retract (p ^♯)) == p
♯-modality : {@♭ i : ULevel} → Modality i
♯-modality {i} = record
{ is-local = _is-codiscrete
; is-local-is-prop = λ {A} → A is-codisc-is-a-prop
; ◯ = ♯
; ◯-is-local = λ {A} → ♯-is-codiscrete A
; η = _^♯
; ◯-elim = λ {A} {B} p f a → un♯ (p a) (♯-elim B (λ a → (f a) ^♯) a)
; ◯-elim-β = λ {A} {B} p f a → <–-inv-l (codisc-eq (p (a ^♯))) (f a)
; ◯-=-is-local = =-is-codiscrete
}
_is-infinitesimal : {@♭ i : ULevel} → Type i → Type i
_is-infinitesimal = Modality.is-◯-connected ♯-modality
♯→e : {@♭ i : ULevel} {A B : Type i} → A ≃ B → (♯ A) ≃ (♯ B)
♯→e = Modality.◯-emap ♯-modality
♯-Σ : ∀ {@♭ i} {A : Type i} (B : A → Type i)
→ A is-codiscrete → ((a : A) → (B a) is-codiscrete)
→ (Σ A B) is-codiscrete
♯-Σ {i} = (Modality.Σ-is-local {i}) ♯-modality
♯-Π : ∀ {@♭ i} {A : Type i} {B : A → Type i} (w : (a : A) → (B a) is-codiscrete)
→ (Π A B) is-codiscrete
♯-Π {i} = (Modality.Π-is-local {i}) ♯-modality
-- Theorem 6.22 of Shulman
-- Points of ♯ A are the points of A, and ♯ of the points of A is ♯ A.
♭♯-eq : {@♭ i : ULevel} {@♭ A : Type i} → ♭ (♯ A) ≃ ♭ A
♭♯-eq {A = A} = equiv to fro to-fro fro-to
where
to : ♭ (♯ A) → ♭ A
to (a ^♭) = (a ↓♯) ^♭
fro : ♭ A → ♭ (♯ A)
fro (a ^♭) = (a ^♯) ^♭
to-fro : (a : ♭ A) → to (fro a) == a
to-fro (a ^♭) = refl
fro-to : (a : ♭ (♯ A)) → fro (to a) == a
fro-to (a ^♭) = ♭-ap _^♭ refl
♯♭-eq : {@♭ i : ULevel} {@♭ A : Type i} → ♯ (♭ A) ≃ ♯ A
♯♭-eq {A = A} = equiv to fro to-fro fro-to
where
to : ♯ (♭ A) → ♯ A
to a =
let♯ u ^♯:= a in♯
let♭ v ^♭:= u in♭ (v ^♯)
fro : ♯ A → ♯ (♭ A)
fro a =
let♯ u ^♯:= a in♯
let♯ v ::= u in♯ (v ^♭) ^^♯
abstract
to-fro : (a : ♯ A) → to (fro a) == a
to-fro a = -- It suffices to show ♯ (to fro a == a),
(let♯ u ^♯:= a in♯ -- which lets us assume a = u^♯
refl ^♯ -- so that the equality follows judgementally.
in-family (λ a → to (fro a) == a))
|> ♯-=-retract
fro-to : (a : ♯ (♭ A)) → fro (to a) == a
fro-to a = -- It suffices to show ♯ (fro to a == a),
(let♯ u ^♯:= a in♯ -- which lets us assume a = u^♯ with u : ♭ A,
(let♭ v ^♭:= u in♭ -- so we can assume u = v^♭,
refl ^♯ -- so that the equality follows judgementally.
in-family (λ u → ♯ (fro (to (u ^♯)) == (u ^♯))))
in-family (λ a → fro (to a) == a))
|> ♯-=-retract
-- Theorem 6.27 of Shulman
-- The adjunction between ♭ and ♯
♭♯-adjoint : {@♭ i j : ULevel} {@♭ A : Type i} {@♭ B : A → Type j}
→ ♭ ((a : ♭ A) → B (a ↓♭)) ≃ ♭ ((a : A) → ♯ (B a))
♭♯-adjoint {A = A} {B = B} = equiv to fro to-fro fro-to
where
to : ♭ ((a : ♭ A) → B (a ↓♭)) → ♭ ((a : A) → ♯ (B a))
to (f ^♭) = (λ a → let♯ u ::= a in♯ f (u ^♭) ^^♯) ^♭
fro : ♭ ((a : A) → ♯ (B a)) → ♭ ((a : ♭ A) → B (a ↓♭))
fro (f ^♭) = (λ a → let♭ u ^♭:= a in♭ ((f u) ↓♯) in-family (λ a → B (a ↓♭))) ^♭
to-fro : ∀ f → to (fro f) == f
to-fro (f ^♭) = refl
fro-to : ∀ f → fro (to f) == f
fro-to (f ^♭) =
♭-ap _^♭ -- We can strip ^♭ from both sides,
( λ= (λ a → let♭ u ^♭:= a in♭ -- then, working at a crisp argument u,
refl -- we find both sides are judgementally the same.
in-family (λ a → ♭-elim (λ a₁ → B (a₁ ↓♭)) (λ (@♭ u : _) → f (u ^♭)) a == f a) )
) -- The "in family" gibberish just reminds agda what we are trying to prove.
-- Shulman Theorem 3.7
-- ♯ is left exact, in that x^♯ == y^♯ is ♯ (x == y)
module _ {@♭ i : ULevel} where
private
record CTX-code : Type (lsucc i) where
constructor ctx
field
ᶜA : Type i
ᶜx : ♯ ᶜA
ᶜy : ♯ ᶜA
code : {A : Type i} → ♯ A → ♯ A → Type i
code {A} x y =
let♯ γ ::= (ctx A x y) in♯-♯ (((ᶜx γ) ↓♯) == ((ᶜy γ) ↓♯))
where open CTX-code
private
record CTX-r : Type (lsucc i) where
constructor ctx
field
ᶜA : Type i
ᶜx : ♯ ᶜA
r : {A : Type i} (x : ♯ A) → code x x
r {A} x =
let♯ γ ::= (ctx A x) in♯ (idp {a = (ᶜx γ) ↓♯}) ^^♯
where open CTX-r
-- for some reason, I can't use refl here, I need idp???
encode : {A : Type i} {a b : ♯ A} → (a == b) → code a b
encode {A} {a} {b} p = transport (λ y → code a y) p (r a)
decode : {A : Type i} {a b : ♯ A} → code a b → (a == b)
decode {A} {a} {b} = -- It suffices to give ♯ (code a b → a == b) by lemma.
lemma a b (decode' a b)
where
lemma : {A : Type i} (a b : ♯ A)
→ ♯ (code a b → (a == b))
→ code a b → (a == b)
lemma a b p e =
♯-=-retract $ -- it suffices to show ♯ (a == b)
let♯ q ^♯:= p in♯ ((q e) ^♯) -- so we can assume p is of the form q ^♯.
decode' : {A : Type i} (a b : ♯ A) → ♯ (code a b → (a == b))
decode' {A} a b =
let♯ u ^♯:= a in♯ -- By ♯-elim, we can assume a and b are of the form
let♯ v ^♯:= b in♯ -- u ^♯ and v ^♯, and we'll give
-- code (u ^♯) (v ^♯) → (u ^♯) == (v ^♯).
(λ p → ♯-=-retract -- Assuming a code p, it suffices to give
-- ♯ (u ^♯ == v ^♯).
(let♯ q ^♯:= p in♯ ((ap _^♯ q)^♯)) )^♯ -- So, we let p be q^♯
-- with q : u == v, and then
-- push this through the unit.
in-family (λ b' → code (u ^♯) b' → (u ^♯) == b')
in-family (λ a' → code a' b → a' == b)
private -- context for encode-decode'
record CTX-encode-decode : Type (lsucc i) where
constructor ctx
field
ᶜA : Type i
ᶜa : ♯ ᶜA
ᶜb : ♯ ᶜA
-- ᶜp : code ᶜa ᶜb
open CTX-encode-decode
{-
encode-decode' : {A : Type i} {a b : ♯ A} → ♯ ((encode {a = a}{b = b})∘ decode == (idf (code a b)))
encode-decode' {A} {a} {b} =
let♯ γ ::= (ctx A a b) in♯
{!let♯ u ^♯:= (ᶜa γ) in♯
?
in-family (λ a' → (encode {a = a'}{b = ᶜb γ})∘ decode == (idf (code a' (ᶜb γ))))!}
^^♯-in-family (λ γ' → (encode {a = ᶜa γ'}{b = ᶜb γ'})∘ decode == (idf (code (ᶜa γ') (ᶜb γ'))))
-- [WARNING] I get an error here complaining about A in (a ↓♯) == (b ↓♯) if doing this at
-- p : code a b (I believe this to be because rewrite rules do not see the ♭ modality)
encode-decode : {A : Type i} {a b : ♯ A} → (encode {a = a}{b = b})∘ decode == (idf (code a b))
encode-decode {A} {a} {b} =
λ= (λ p → {!!})
-}
-- For now, we'll just postulate it
♯-=-compare : {@♭ i : ULevel} {A : Type i} {x y : A}
→ ♯ (x == y) → (x ^♯) == (y ^♯)
♯-=-compare {x = x} {y = y} p =
♯-=-retract $ -- it suffices to give ♯ (x ^♯ == y ^♯)
let♯ q ^♯:= p in♯ -- in which case we may assume p = q ^♯ with q : x == y
((ap _^♯ q) ^♯) -- and so we can push this through.
module _ {@♭ i : ULevel} where
private
record CTX-♯-lex : Type (lsucc i) where
constructor ctx
field
ᶜA : Type i
ᶜx : ᶜA
ᶜy : ᶜA
postulate
♯-lex : {A : Type i} {x y : A}
→ (♯-=-compare {x = x} {y = y}) is-an-equiv
♯-lex-eq : {A : Type i} {x y : A}
→ (♯ (x == y)) ≃ ((x ^♯) == (y ^♯))
♯-lex-eq {A}{x}{y} = ♯-=-compare , ♯-lex
test : {A : Type i} {x y : ♯ A}
→ ♯ ((x ^♯) == (y ^♯) → ♯ (x == y))
test {A} {x} {y} =
let♯ γ ::= (ctx (♯ A) x y) in♯
(λ p → let♯ q ::= p in♯
(♭-ap _↓♯ q)
^^♯-in-family (λ _ → (ᶜx γ == ᶜy γ)))
^^♯-in-family (λ γ → ((ᶜx γ) ^♯) == ((ᶜy γ) ^♯) → ♯ ((ᶜx γ) == (ᶜy γ)))
where open CTX-♯-lex
♯-has-level-is-codisc : {@♭ i : ULevel} {A : Type i}
{n : ℕ₋₂} → (has-level n (♯ A)) is-codiscrete
♯-has-level-is-codisc {i} {A} {n} = replete helper (has-level-def-eq ⁻¹)
where
replete = (Modality.local-is-replete {i}) ♯-modality
helper : {A : Type i}
{n : ℕ₋₂} → (has-level-aux n (♯ A)) is-codiscrete
helper {A} {⟨-2⟩} =
♯-Σ (λ x → (y : ♯ A) → x == y) (♯-is-codiscrete A) $
λ x → ♯-Π (λ y → =-is-codiscrete x y)
helper {A} {n = S n} =
♯-Π (λ x →
♯-Π (λ y →
replete (replete (helper {A = (x == y)} {n}) (has-level-def-eq ⁻¹))
(≃-preserves-level-eq ((codisc-eq $ =-is-codiscrete x y) ⁻¹))))
♯-preserves-level : {@♭ i : ULevel} {A : Type i}
{n : ℕ₋₂} (p : has-level n A)
→ has-level n (♯ A)
♯-preserves-level {i} {A} {⟨-2⟩} p =
has-level-in ( ((contr-center p)^♯) ,
(λ y → ♯-=-retract $ -- It suffices to prove ♯ (center == y)
let♯ u ^♯:= y in♯ -- so we can assume y is u ^♯
ap _^♯ (contr-path p u) ^♯ -- and then apply _^♯ to the contractibility of A.
in-family (λ y → ((contr-center p) ^♯) == y))
)
♯-preserves-level {i} {A} {S n} p =
has-level-in
(λ x y → -- Given x y : ♯ A, we need to show that x == y has level n.
≃-preserves-level ((codisc-eq (=-is-codiscrete x y))⁻¹) lemma
) -- since x == y is ♯ (x == y), it will suffice to show that has level n.
where
lemma : {x y : ♯ A} → has-level n (♯ (x == y))
lemma {x} {y} = -- Since has-level is codiscrete on codiscretes,
un♯ ♯-has-level-is-codisc $ -- we can let x and y be u^♯ and v^♯.
let♯ u ^♯:= x in♯ -- Then, we use the lex-ness of ♯ and a bit of jiggling
let♯ v ^♯:= y in♯ -- to show that we might as well prove the result of
(≃-preserves-level (e u v) -- ♯ (u == v), which we can do by recursing.
(♯-preserves-level (has-level-apply p u v)))^♯
in-family (λ y → has-level n (♯ ((u ^♯) == y)))
in-family (λ x → has-level n (♯ (x == y)))
where
e : (u v : A) → ♯ (u == v) ≃ ♯ ((u ^♯) == (v ^♯))
e u v = ♯ (u == v)
≃⟨ codisc-eq (♯-is-codiscrete (u == v)) ⟩
♯ (♯ (u == v))
≃⟨ ♯→e ♯-lex-eq ⟩
♯ ((u ^♯) == (v ^♯))
≃∎
♯ₙ : {@♭ i : ULevel} {n : ℕ₋₂}
→ (A : n -Type i) → (n -Type i)
♯ₙ A = (♯ (fst A)) , ♯-preserves-level (snd A)
|
{
"alphanum_fraction": 0.4205736666,
"avg_line_length": 36.9404255319,
"ext": "agda",
"hexsha": "fc83b3365b4cb67214ec806cf65cd6d06521bd6a",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a",
"max_forks_repo_licenses": [
"CC0-1.0"
],
"max_forks_repo_name": "glangmead/formalization",
"max_forks_repo_path": "cohesion/david_jaz_261/Sharp.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"CC0-1.0"
],
"max_issues_repo_name": "glangmead/formalization",
"max_issues_repo_path": "cohesion/david_jaz_261/Sharp.agda",
"max_line_length": 103,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a",
"max_stars_repo_licenses": [
"CC0-1.0"
],
"max_stars_repo_name": "glangmead/formalization",
"max_stars_repo_path": "cohesion/david_jaz_261/Sharp.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-13T05:51:12.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-10-06T17:39:22.000Z",
"num_tokens": 10149,
"size": 26043
}
|
------------------------------------------------------------------------------
-- Example of a nested recursive function using the Bove-Capretta
-- method
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
-- From: Bove, A. and Capretta, V. (2001). Nested General Recursion
-- and Partiality in Type Theory. In: Theorem Proving in Higher Order
-- Logics (TPHOLs 2001). Ed. by Boulton, R. J. and Jackson,
-- P. B. Vol. 2152. LNCS. Springer, pp. 121–135.
module FOT.FOTC.Program.Nest.NestBC-SL where
open import Data.Nat renaming ( suc to succ )
open import Data.Nat.Properties
open import Induction
open import Induction.Nat
open import Relation.Binary
------------------------------------------------------------------------------
-- The original non-terminating function.
{-# TERMINATING #-}
nestI : ℕ → ℕ
nestI 0 = 0
nestI (succ n) = nestI (nestI n)
-- ≤′-trans : Transitive _≤′_
-- ≤′-trans i≤′j j≤′k = ≤⇒≤′ (NDTO.trans (≤′⇒≤ i≤′j) (≤′⇒≤ j≤′k))
mutual
-- The domain predicate of the nest function.
data NestDom : ℕ → Set where
nestDom0 : NestDom 0
nestDomS : ∀ {n} → (h₁ : NestDom n) →
(h₂ : NestDom (nestD n h₁)) →
NestDom (succ n)
-- The nest function by structural recursion on the domain predicate.
nestD : ∀ n → NestDom n → ℕ
nestD .0 nestDom0 = 0
nestD .(succ n) (nestDomS {n} h₁ h₂) = nestD (nestD n h₁) h₂
nestD-≤′ : ∀ n → (h : NestDom n) → nestD n h ≤′ n
nestD-≤′ .0 nestDom0 = ≤′-refl
nestD-≤′ .(succ n) (nestDomS {n} h₁ h₂) =
≤′-trans (≤′-trans (nestD-≤′ (nestD n h₁) h₂) (nestD-≤′ n h₁))
(≤′-step ≤′-refl)
-- The nest function is total.
allNestDom : ∀ n → NestDom n
allNestDom = build <′-recBuilder P ih
where
P : ℕ → Set
P = NestDom
ih : ∀ y → <′-Rec P y → P y
ih zero rec = nestDom0
ih (succ y) rec = nestDomS nd-y (rec (nestD y nd-y) (s≤′s (nestD-≤′ y nd-y)))
where
helper : ∀ x → x <′ y → P x
helper x Sx≤′y = rec x (≤′-step Sx≤′y)
nd-y : NestDom y
nd-y = ih y helper
-- The nest function.
nest : ℕ → ℕ
nest n = nestD n (allNestDom n)
|
{
"alphanum_fraction": 0.5203111495,
"avg_line_length": 30.4473684211,
"ext": "agda",
"hexsha": "078e81c8a4f3d43d0de0f1ec6d5890277c747494",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z",
"max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/fotc",
"max_forks_repo_path": "notes/FOT/FOTC/Program/Nest/NestBC-SL.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/fotc",
"max_issues_repo_path": "notes/FOT/FOTC/Program/Nest/NestBC-SL.agda",
"max_line_length": 79,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "notes/FOT/FOTC/Program/Nest/NestBC-SL.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": 779,
"size": 2314
}
|
{-
Maybe structure: X ↦ Maybe (S X)
-}
{-# OPTIONS --cubical --no-import-sorts --no-exact-split --safe #-}
module Cubical.Structures.Relational.Maybe where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Structure
open import Cubical.Foundations.RelationalStructure
open import Cubical.Data.Unit
open import Cubical.Data.Empty
open import Cubical.Data.Maybe
open import Cubical.Data.Sigma
open import Cubical.HITs.PropositionalTruncation as Trunc
open import Cubical.HITs.SetQuotients
open import Cubical.Structures.Maybe
private
variable
ℓ ℓ₁ ℓ₁' ℓ₁'' : Level
-- Structured relations
MaybeRelStr : {S : Type ℓ → Type ℓ₁} {ℓ₁' : Level}
→ StrRel S ℓ₁' → StrRel (λ X → Maybe (S X)) ℓ₁'
MaybeRelStr ρ R = MaybeRel (ρ R)
maybeSuitableRel : {S : Type ℓ → Type ℓ₁} {ρ : StrRel S ℓ₁'}
→ SuitableStrRel S ρ
→ SuitableStrRel (MaybeStructure S) (MaybeRelStr ρ)
maybeSuitableRel θ .quo (X , nothing) R _ .fst = nothing , _
maybeSuitableRel θ .quo (X , nothing) R _ .snd (nothing , _) = refl
maybeSuitableRel θ .quo (X , just s) R c .fst =
just (θ .quo (X , s) R c .fst .fst) , θ .quo (X , s) R c .fst .snd
maybeSuitableRel θ .quo (X , just s) R c .snd (just s' , r) =
cong (λ {(t , r') → just t , r'}) (θ .quo (X , s) R c .snd (s' , r))
maybeSuitableRel θ .symmetric R {nothing} {nothing} r = _
maybeSuitableRel θ .symmetric R {just s} {just t} r = θ .symmetric R r
maybeSuitableRel θ .transitive R R' {nothing} {nothing} {nothing} r r' = _
maybeSuitableRel θ .transitive R R' {just s} {just t} {just u} r r' = θ .transitive R R' r r'
maybeSuitableRel θ .set setX = isOfHLevelMaybe 0 (θ .set setX)
maybeSuitableRel θ .prop propR nothing nothing = isOfHLevelLift 1 isPropUnit
maybeSuitableRel θ .prop propR nothing (just y) = isOfHLevelLift 1 isProp⊥
maybeSuitableRel θ .prop propR (just x) nothing = isOfHLevelLift 1 isProp⊥
maybeSuitableRel θ .prop propR (just x) (just y) = θ .prop propR x y
maybeRelMatchesEquiv : {S : Type ℓ → Type ℓ₁} (ρ : StrRel S ℓ₁') {ι : StrEquiv S ℓ₁''}
→ StrRelMatchesEquiv ρ ι
→ StrRelMatchesEquiv (MaybeRelStr ρ) (MaybeEquivStr ι)
maybeRelMatchesEquiv ρ μ (X , nothing) (Y , nothing) _ = Lift≃Lift (idEquiv _)
maybeRelMatchesEquiv ρ μ (X , nothing) (Y , just y) _ = Lift≃Lift (idEquiv _)
maybeRelMatchesEquiv ρ μ (X , just x) (Y , nothing) _ = Lift≃Lift (idEquiv _)
maybeRelMatchesEquiv ρ μ (X , just x) (Y , just y) = μ (X , x) (Y , y)
maybeRelAction :
{S : Type ℓ → Type ℓ₁} {ρ : StrRel S ℓ₁'}
→ StrRelAction ρ
→ StrRelAction (MaybeRelStr ρ)
maybeRelAction α .actStr f = map-Maybe (α .actStr f)
maybeRelAction α .actStrId s =
funExt⁻ (cong map-Maybe (funExt (α .actStrId))) s ∙ map-Maybe-id s
maybeRelAction α .actRel h nothing nothing = _
maybeRelAction α .actRel h (just s) (just t) r = α .actRel h s t r
maybePositiveRel :
{S : Type ℓ → Type ℓ₁} {ρ : StrRel S ℓ₁'} {θ : SuitableStrRel S ρ}
→ PositiveStrRel θ
→ PositiveStrRel (maybeSuitableRel θ)
maybePositiveRel σ .act = maybeRelAction (σ .act)
maybePositiveRel σ .reflexive nothing = _
maybePositiveRel σ .reflexive (just s) = σ .reflexive s
maybePositiveRel σ .detransitive R R' {nothing} {nothing} r = ∣ nothing , _ , _ ∣
maybePositiveRel σ .detransitive R R' {just s} {just u} rr' =
Trunc.map (λ {(t , r , r') → just t , r , r'}) (σ .detransitive R R' rr')
maybePositiveRel {S = S} {ρ = ρ} {θ = θ} σ .quo {X} R =
subst isEquiv
(funExt
(elimProp (λ _ → maybeSuitableRel θ .set squash/ _ _)
(λ {nothing → refl; (just _) → refl})))
(compEquiv (isoToEquiv isom) (congMaybeEquiv (_ , σ .quo R)) .snd)
where
fwd : Maybe (S X) / MaybeRel (ρ (R .fst .fst)) → Maybe (S X / ρ (R .fst .fst))
fwd [ nothing ] = nothing
fwd [ just s ] = just [ s ]
fwd (eq/ nothing nothing r i) = nothing
fwd (eq/ (just s) (just t) r i) = just (eq/ s t r i)
fwd (squash/ _ _ p q i j) =
isOfHLevelMaybe 0 squash/ _ _ (cong fwd p) (cong fwd q) i j
bwd : Maybe (S X / ρ (R .fst .fst)) → Maybe (S X) / MaybeRel (ρ (R .fst .fst))
bwd nothing = [ nothing ]
bwd (just [ s ]) = [ just s ]
bwd (just (eq/ s t r i)) = eq/ (just s) (just t) r i
bwd (just (squash/ _ _ p q i j)) =
squash/ _ _ (cong (bwd ∘ just) p) (cong (bwd ∘ just) q) i j
open Iso
isom : Iso (Maybe (S X) / MaybeRel (ρ (R .fst .fst))) (Maybe (S X / ρ (R .fst .fst)))
isom .fun = fwd
isom .inv = bwd
isom .rightInv nothing = refl
isom .rightInv (just x) =
elimProp {B = λ x → fwd (bwd (just x)) ≡ just x}
(λ _ → isOfHLevelMaybe 0 squash/ _ _)
(λ _ → refl)
x
isom .leftInv = elimProp (λ _ → squash/ _ _) (λ {nothing → refl; (just _) → refl})
maybeRelMatchesTransp : {S : Type ℓ → Type ℓ₁}
(ρ : StrRel S ℓ₁') (α : EquivAction S)
→ StrRelMatchesEquiv ρ (EquivAction→StrEquiv α)
→ StrRelMatchesEquiv (MaybeRelStr ρ) (EquivAction→StrEquiv (maybeEquivAction α))
maybeRelMatchesTransp _ _ μ (X , nothing) (Y , nothing) _ =
isContr→Equiv (isOfHLevelLift 0 isContrUnit) isContr-nothing≡nothing
maybeRelMatchesTransp _ _ μ (X , nothing) (Y , just y) _ =
uninhabEquiv lower ¬nothing≡just
maybeRelMatchesTransp _ _ μ (X , just x) (Y , nothing) _ =
uninhabEquiv lower ¬just≡nothing
maybeRelMatchesTransp _ _ μ (X , just x) (Y , just y) e =
compEquiv (μ (X , x) (Y , y) e) (_ , isEmbedding-just _ _)
|
{
"alphanum_fraction": 0.6645814167,
"avg_line_length": 42.4609375,
"ext": "agda",
"hexsha": "5e521278e5316e83e43e0d0db20e20db2f71bf77",
"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/Structures/Relational/Maybe.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "dan-iel-lee/cubical",
"max_issues_repo_path": "Cubical/Structures/Relational/Maybe.agda",
"max_line_length": 93,
"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/Structures/Relational/Maybe.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2049,
"size": 5435
}
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
{-
This file defines integers as equivalence classes of pairs of natural numbers
using a direct & untruncated HIT definition (cf. HITs.Ints.DiffInt)
and some basic operations, and the zero value:
succ : DeltaInt → DeltaInt
pred : DeltaInt → DeltaInt
zero : {a : ℕ} → DeltaInt
and conversion function for ℕ and Int:
fromℕ : ℕ → DeltaInt
fromInt : Int → DeltaInt
toInt : DeltaInt → Int
and a generalized version of cancel:
cancelN : ∀ a b n → a ⊖ b ≡ (n + a) ⊖ n + b
-}
module Cubical.HITs.Ints.DeltaInt.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Data.Nat hiding (zero)
open import Cubical.Data.Int hiding (abs; sgn; _+_)
infixl 5 _⊖_
data DeltaInt : Type₀ where
_⊖_ : ℕ → ℕ → DeltaInt
cancel : ∀ a b → a ⊖ b ≡ suc a ⊖ suc b
succ : DeltaInt → DeltaInt
succ (x ⊖ y) = suc x ⊖ y
succ (cancel a b i) = cancel (suc a) b i
pred : DeltaInt → DeltaInt
pred (x ⊖ y) = x ⊖ suc y
pred (cancel a b i) = cancel a (suc b) i
zero : {a : ℕ} → DeltaInt
zero {a} = a ⊖ a
fromℕ : ℕ → DeltaInt
fromℕ n = n ⊖ 0
fromInt : Int → DeltaInt
fromInt (pos n) = fromℕ n
fromInt (negsuc n) = 0 ⊖ suc n
toInt : DeltaInt → Int
toInt (x ⊖ y) = x ℕ- y
toInt (cancel a b i) = a ℕ- b
cancelN : ∀ a b n → a ⊖ b ≡ (n + a) ⊖ n + b
cancelN a b 0 = refl
cancelN a b (suc n) = cancelN a b n ∙ cancel (n + a) (n + b)
|
{
"alphanum_fraction": 0.6436865022,
"avg_line_length": 22.2258064516,
"ext": "agda",
"hexsha": "846dd201c708c5e10c86c4c937baa4bcda9963d4",
"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": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Edlyr/cubical",
"max_forks_repo_path": "Cubical/HITs/Ints/DeltaInt/Base.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e",
"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": "Edlyr/cubical",
"max_issues_repo_path": "Cubical/HITs/Ints/DeltaInt/Base.agda",
"max_line_length": 77,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Edlyr/cubical",
"max_stars_repo_path": "Cubical/HITs/Ints/DeltaInt/Base.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 505,
"size": 1378
}
|
-- Andreas, 2014-11-01, reported by Andrea Vezzosi
-- Non-printable characters in line comments
-- Soft hyphen in comment creates lexical error:
-- (SOFT HYPHEN \- 0xAD)
-- Or parse error:
-- A
|
{
"alphanum_fraction": 0.6915422886,
"avg_line_length": 20.1,
"ext": "agda",
"hexsha": "8be305ca0b36255f7e57d9ad7a689688614b00af",
"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/Issue1337.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/Issue1337.agda",
"max_line_length": 50,
"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/Issue1337.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": 61,
"size": 201
}
|
{-# OPTIONS --without-K --safe #-}
-- The category of Cats is Monoidal
module Categories.Category.Monoidal.Instance.Cats where
open import Level
open import Data.Product using (Σ; _×_; _,_; proj₁; proj₂; uncurry)
open import Categories.Category
open import Categories.Functor using (Functor; _∘F_) renaming (id to idF)
open import Categories.Category.Instance.Cats
open import Categories.Category.Monoidal
open import Categories.Functor.Bifunctor
open import Categories.Category.Instance.One
open import Categories.Category.Product
open import Categories.Category.Product.Properties
import Categories.Category.Cartesian as Cartesian
open import Categories.NaturalTransformation.NaturalIsomorphism using (NaturalIsomorphism)
-- Cats is a Monoidal Category with Product as Bifunctor
module Product {o ℓ e : Level} where
private
C = Cats o ℓ e
open Cartesian C
Cats-has-all : BinaryProducts
Cats-has-all = record { product = λ {A} {B} → record
{ A×B = Product A B
; π₁ = πˡ
; π₂ = πʳ
; ⟨_,_⟩ = _※_
; project₁ = λ {_} {h} {i} → project₁ {i = h} {j = i}
; project₂ = λ {_} {h} {i} → project₂ {i = h} {j = i}
; unique = unique
} }
Cats-is : Cartesian
Cats-is = record { terminal = One-⊤ ; products = Cats-has-all }
private
module Cart = Cartesian.Cartesian Cats-is
Cats-Monoidal : Monoidal C
Cats-Monoidal = Cart.monoidal
|
{
"alphanum_fraction": 0.7083032491,
"avg_line_length": 30.1086956522,
"ext": "agda",
"hexsha": "ba8988335ab600d24271d569552d4c81765e01b9",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bblfish/agda-categories",
"max_forks_repo_path": "src/Categories/Category/Monoidal/Instance/Cats.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "bblfish/agda-categories",
"max_issues_repo_path": "src/Categories/Category/Monoidal/Instance/Cats.agda",
"max_line_length": 90,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bblfish/agda-categories",
"max_stars_repo_path": "src/Categories/Category/Monoidal/Instance/Cats.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": 386,
"size": 1385
}
|
module VecReplicate where
open import Prelude
replicate : forall {A} -> (n : Nat) -> A -> Vec A n
replicate count x = {!!}
|
{
"alphanum_fraction": 0.648,
"avg_line_length": 17.8571428571,
"ext": "agda",
"hexsha": "c17c069be0f795e76e59c1f54b416ee720da8f33",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "baf979ef78b5ec0f4783240b03f9547490bc5d42",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "carlostome/martin",
"max_forks_repo_path": "data/test-files/VecReplicate.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "baf979ef78b5ec0f4783240b03f9547490bc5d42",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "carlostome/martin",
"max_issues_repo_path": "data/test-files/VecReplicate.agda",
"max_line_length": 51,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "baf979ef78b5ec0f4783240b03f9547490bc5d42",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "carlostome/martin",
"max_stars_repo_path": "data/test-files/VecReplicate.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 37,
"size": 125
}
|
module Function where
import Lvl
open import Type
-- The domain type of a function.
domain : ∀{ℓ₁ ℓ₂} {A : Type{ℓ₁}}{B : Type{ℓ₂}} → (A → B) → Type{ℓ₁}
domain{A = A} _ = A
-- The codomain type of a function.
codomain : ∀{ℓ₁ ℓ₂} {A : Type{ℓ₁}}{B : Type{ℓ₂}} → (A → B) → Type{ℓ₂}
codomain{B = B} _ = B
|
{
"alphanum_fraction": 0.5844155844,
"avg_line_length": 23.6923076923,
"ext": "agda",
"hexsha": "0de069db55154cbb7b8037390226be58b124a29f",
"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": "Function.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": "Function.agda",
"max_line_length": 69,
"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": "Function.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": 136,
"size": 308
}
|
{-# OPTIONS --without-K #-}
open import HoTT
module homotopy.HSpace where
-- This is just an approximation because
-- not all higher cells are killed.
record HSpaceStructure {i} (A : Type i) : Type i where
constructor hSpaceStructure
field
e : A
μ : A → A → A
μ-e-l : (a : A) → μ e a == a
μ-e-r : (a : A) → μ a e == a
μ-coh : μ-e-l e == μ-e-r e
module ConnectedHSpace {i} (A : Type i) (c : is-connected 0 A)
(hA : HSpaceStructure A) where
open HSpaceStructure hA
{-
Given that [A] is 0-connected, to prove that each [μ a] is an equivalence we
only need to prove that one of them is. But for [a] = [e], [μ a] is the
identity so we’re done.
-}
μ-e-l-is-equiv : (a : A) → is-equiv (λ a' → μ a' a)
μ-e-l-is-equiv = prop-over-connected {a = e} c
(λ a → (is-equiv (λ a' → μ a' a) , is-equiv-is-prop (λ a' → μ a' a)))
(transport! is-equiv (λ= μ-e-r) (idf-is-equiv A))
μ-e-r-is-equiv : (a : A) → is-equiv (μ a)
μ-e-r-is-equiv = prop-over-connected {a = e} c
(λ a → (is-equiv (μ a) , is-equiv-is-prop (μ a)))
(transport! is-equiv (λ= μ-e-l) (idf-is-equiv A))
μ-e-l-equiv : A → A ≃ A
μ-e-l-equiv a = _ , μ-e-l-is-equiv a
μ-e-r-equiv : A → A ≃ A
μ-e-r-equiv a = _ , μ-e-r-is-equiv a
|
{
"alphanum_fraction": 0.5674381484,
"avg_line_length": 28.4772727273,
"ext": "agda",
"hexsha": "c95ca5d07c9147265d5f7314be0a37ee91118236",
"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/HSpace.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/HSpace.agda",
"max_line_length": 78,
"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/HSpace.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 459,
"size": 1253
}
|
{-# OPTIONS --without-K --safe --no-sized-types --no-guardedness #-}
module Agda.Builtin.Float where
open import Agda.Builtin.Bool
open import Agda.Builtin.Nat
open import Agda.Builtin.Int
open import Agda.Builtin.String
postulate Float : Set
{-# BUILTIN FLOAT Float #-}
primitive
primFloatEquality : Float → Float → Bool
primFloatLess : Float → Float → Bool
primFloatNumericalEquality : Float → Float → Bool
primFloatNumericalLess : Float → Float → Bool
primNatToFloat : Nat → Float
primFloatPlus : Float → Float → Float
primFloatMinus : Float → Float → Float
primFloatTimes : Float → Float → Float
primFloatNegate : Float → Float
primFloatDiv : Float → Float → Float
primFloatSqrt : Float → Float
primRound : Float → Int
primFloor : Float → Int
primCeiling : Float → Int
primExp : Float → Float
primLog : Float → Float
primSin : Float → Float
primCos : Float → Float
primTan : Float → Float
primASin : Float → Float
primACos : Float → Float
primATan : Float → Float
primATan2 : Float → Float → Float
primShowFloat : Float → String
|
{
"alphanum_fraction": 0.6278501629,
"avg_line_length": 32.3157894737,
"ext": "agda",
"hexsha": "e96c3c748c57538e90426841db3dfa69c1a62f89",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "2fa8ede09451d43647f918dbfb24ff7b27c52edc",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "phadej/agda",
"max_forks_repo_path": "src/data/lib/prim/Agda/Builtin/Float.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "2fa8ede09451d43647f918dbfb24ff7b27c52edc",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "phadej/agda",
"max_issues_repo_path": "src/data/lib/prim/Agda/Builtin/Float.agda",
"max_line_length": 68,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "2fa8ede09451d43647f918dbfb24ff7b27c52edc",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "phadej/agda",
"max_stars_repo_path": "src/data/lib/prim/Agda/Builtin/Float.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 329,
"size": 1228
}
|
module Human.Unit where
-- Do I need a record and the built-in ⊤? Why?
data Unit : Set where
unit : Unit
|
{
"alphanum_fraction": 0.6851851852,
"avg_line_length": 18,
"ext": "agda",
"hexsha": "a88b1e0e98f39e668d70e1f9f146ca635020b85f",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "b509eb4c4014605facfb4ee5c807cd07753d4477",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "MaisaMilena/JuiceMaker",
"max_forks_repo_path": "src/Human/Unit.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b509eb4c4014605facfb4ee5c807cd07753d4477",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "MaisaMilena/JuiceMaker",
"max_issues_repo_path": "src/Human/Unit.agda",
"max_line_length": 46,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "b509eb4c4014605facfb4ee5c807cd07753d4477",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "MaisaMilena/JuiceMaker",
"max_stars_repo_path": "src/Human/Unit.agda",
"max_stars_repo_stars_event_max_datetime": "2020-11-28T05:46:27.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-03-29T17:35:20.000Z",
"num_tokens": 31,
"size": 108
}
|
module Data.Word.Primitive where
postulate
Word : Set
Word8 : Set
Word16 : Set
Word32 : Set
Word64 : Set
{-# IMPORT Data.Word #-}
{-# COMPILED_TYPE Word Data.Word.Word #-}
{-# COMPILED_TYPE Word8 Data.Word.Word8 #-}
{-# COMPILED_TYPE Word16 Data.Word.Word16 #-}
{-# COMPILED_TYPE Word32 Data.Word.Word32 #-}
{-# COMPILED_TYPE Word64 Data.Word.Word64 #-}
|
{
"alphanum_fraction": 0.6885245902,
"avg_line_length": 22.875,
"ext": "agda",
"hexsha": "6eb1fb879fb0ae5f2ae333129753b573173064eb",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:14.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:40:14.000Z",
"max_forks_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "ilya-fiveisky/agda-system-io",
"max_forks_repo_path": "src/Data/Word/Primitive.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "ilya-fiveisky/agda-system-io",
"max_issues_repo_path": "src/Data/Word/Primitive.agda",
"max_line_length": 45,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "ilya-fiveisky/agda-system-io",
"max_stars_repo_path": "src/Data/Word/Primitive.agda",
"max_stars_repo_stars_event_max_datetime": "2019-10-24T13:51:16.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-08-02T23:17:59.000Z",
"num_tokens": 102,
"size": 366
}
|
open import Mockingbird.Forest.Base using (Forest)
module Mockingbird.Forest.Birds {b ℓ} (forest : Forest {b} {ℓ}) where
open import Level using (_⊔_)
open import Data.Product using (_×_; ∃-syntax)
open import Relation.Unary using (Pred)
open import Relation.Binary using (Rel)
open Forest forest
-- TODO: consider using implicit arguments in the predicates, e.g.
-- IsMockingbird M = ∀ {x} → M ∙ x ≈ x ∙ x.
IsComposition : (A B C : Bird) → Set (b ⊔ ℓ)
IsComposition A B C = ∀ x → C ∙ x ≈ A ∙ (B ∙ x)
-- A forest ‘has composition’ if for every two birds A and B there exists a bird
-- C = A ∘ B such that C is the composition of A and B.
record HasComposition : Set (b ⊔ ℓ) where
infixr 6 _∘_
field
_∘_ : (A B : Bird) → Bird
isComposition : ∀ A B → IsComposition A B (A ∘ B)
open HasComposition ⦃ ... ⦄ public
IsMockingbird : Pred Bird (b ⊔ ℓ)
IsMockingbird M = ∀ x → M ∙ x ≈ x ∙ x
record HasMockingbird : Set (b ⊔ ℓ) where
field
M : Bird
isMockingbird : IsMockingbird M
open HasMockingbird ⦃ ... ⦄ public
infix 4 _IsFondOf_
_IsFondOf_ : Rel Bird ℓ
A IsFondOf B = A ∙ B ≈ B
IsEgocentric : Pred Bird ℓ
IsEgocentric A = A IsFondOf A
Agree : (A B x : Bird) → Set ℓ
Agree A B x = A ∙ x ≈ B ∙ x
IsAgreeable : Pred Bird (b ⊔ ℓ)
IsAgreeable A = ∀ B → ∃[ x ] Agree A B x
Compatible : Rel Bird (b ⊔ ℓ)
Compatible A B = ∃[ x ] ∃[ y ] (A ∙ x ≈ y) × (B ∙ y ≈ x)
IsHappy : Pred Bird (b ⊔ ℓ)
IsHappy A = Compatible A A
IsNormal : Pred Bird (b ⊔ ℓ)
IsNormal A = ∃[ x ] A IsFondOf x
infix 4 _IsFixatedOn_
_IsFixatedOn_ : Rel Bird (b ⊔ ℓ)
A IsFixatedOn B = ∀ x → A ∙ x ≈ B
IsHopelesslyEgocentric : Pred Bird (b ⊔ ℓ)
IsHopelesslyEgocentric A = A IsFixatedOn A
IsKestrel : Pred Bird (b ⊔ ℓ)
IsKestrel K = ∀ x y → (K ∙ x) ∙ y ≈ x
-- Alternative definition:
-- IsKestrel K = ∀ x → K ∙ x IsFixatedOn x
record HasKestrel : Set (b ⊔ ℓ) where
field
K : Bird
isKestrel : IsKestrel K
open HasKestrel ⦃ ... ⦄ public
IsIdentity : Pred Bird (b ⊔ ℓ)
IsIdentity I = ∀ x → I ∙ x ≈ x
record HasIdentity : Set (b ⊔ ℓ) where
field
I : Bird
isIdentity : IsIdentity I
open HasIdentity ⦃ ... ⦄ public
IsLark : Pred Bird (b ⊔ ℓ)
IsLark L = ∀ x y → (L ∙ x) ∙ y ≈ x ∙ (y ∙ y)
record HasLark : Set (b ⊔ ℓ) where
field
L : Bird
isLark : IsLark L
IsSageBird : Pred Bird (b ⊔ ℓ)
IsSageBird Θ = ∀ x → x IsFondOf (Θ ∙ x)
open HasLark ⦃ ... ⦄ public
record HasSageBird : Set (b ⊔ ℓ) where
field
Θ : Bird
isSageBird : IsSageBird Θ
IsBluebird : Pred Bird (b ⊔ ℓ)
IsBluebird B = ∀ x y z → B ∙ x ∙ y ∙ z ≈ x ∙ (y ∙ z)
open HasSageBird ⦃ ... ⦄ public
record HasBluebird : Set (b ⊔ ℓ) where
field
B : Bird
isBluebird : IsBluebird B
open HasBluebird ⦃ ... ⦄ public
IsDove : Pred Bird (b ⊔ ℓ)
IsDove D = ∀ x y z w → D ∙ x ∙ y ∙ z ∙ w ≈ x ∙ y ∙ (z ∙ w)
record HasDove : Set (b ⊔ ℓ) where
field
D : Bird
isDove : IsDove D
open HasDove ⦃ ... ⦄ public
IsBlackbird : Pred Bird (b ⊔ ℓ)
IsBlackbird B₁ = ∀ x y z w → B₁ ∙ x ∙ y ∙ z ∙ w ≈ x ∙ (y ∙ z ∙ w)
record HasBlackbird : Set (b ⊔ ℓ) where
field
B₁ : Bird
isBlackbird : IsBlackbird B₁
open HasBlackbird ⦃ ... ⦄ public
IsEagle : Pred Bird (b ⊔ ℓ)
IsEagle E = ∀ x y z w v → E ∙ x ∙ y ∙ z ∙ w ∙ v ≈ x ∙ y ∙ (z ∙ w ∙ v)
record HasEagle : Set (b ⊔ ℓ) where
field
E : Bird
isEagle : IsEagle E
open HasEagle ⦃ ... ⦄ public
IsBunting : Pred Bird (b ⊔ ℓ)
IsBunting B₂ = ∀ x y z w v → B₂ ∙ x ∙ y ∙ z ∙ w ∙ v ≈ x ∙ (y ∙ z ∙ w ∙ v)
record HasBunting : Set (b ⊔ ℓ) where
field
B₂ : Bird
isBunting : IsBunting B₂
open HasBunting ⦃ ... ⦄ public
IsDickcissel : Pred Bird (b ⊔ ℓ)
IsDickcissel D₁ = ∀ x y z w v → D₁ ∙ x ∙ y ∙ z ∙ w ∙ v ≈ x ∙ y ∙ z ∙ (w ∙ v)
record HasDickcissel : Set (b ⊔ ℓ) where
field
D₁ : Bird
isDickcissel : IsDickcissel D₁
open HasDickcissel ⦃ ... ⦄ public
IsBecard : Pred Bird (b ⊔ ℓ)
IsBecard B₃ = ∀ x y z w → B₃ ∙ x ∙ y ∙ z ∙ w ≈ x ∙ (y ∙ (z ∙ w))
record HasBecard : Set (b ⊔ ℓ) where
field
B₃ : Bird
isBecard : IsBecard B₃
open HasBecard ⦃ ... ⦄ public
IsDovekie : Pred Bird (b ⊔ ℓ)
IsDovekie D₂ = ∀ x y z w v → D₂ ∙ x ∙ y ∙ z ∙ w ∙ v ≈ x ∙ (y ∙ z) ∙ (w ∙ v)
record HasDovekie : Set (b ⊔ ℓ) where
field
D₂ : Bird
isDovekie : IsDovekie D₂
open HasDovekie ⦃ ... ⦄ public
IsBaldEagle : Pred Bird (b ⊔ ℓ)
IsBaldEagle Ê = ∀ x y₁ y₂ y₃ z₁ z₂ z₃ → Ê ∙ x ∙ y₁ ∙ y₂ ∙ y₃ ∙ z₁ ∙ z₂ ∙ z₃ ≈ x ∙ (y₁ ∙ y₂ ∙ y₃) ∙ (z₁ ∙ z₂ ∙ z₃)
record HasBaldEagle : Set (b ⊔ ℓ) where
field
Ê : Bird
isBaldEagle : IsBaldEagle Ê
open HasBaldEagle ⦃ ... ⦄ public
IsWarbler : Pred Bird (b ⊔ ℓ)
IsWarbler W = ∀ x y → W ∙ x ∙ y ≈ x ∙ y ∙ y
record HasWarbler : Set (b ⊔ ℓ) where
field
W : Bird
isWarbler : IsWarbler W
open HasWarbler ⦃ ... ⦄ public
IsCardinal : Pred Bird (b ⊔ ℓ)
IsCardinal C = ∀ x y z → C ∙ x ∙ y ∙ z ≈ x ∙ z ∙ y
record HasCardinal : Set (b ⊔ ℓ) where
field
C : Bird
isCardinal : IsCardinal C
open HasCardinal ⦃ ... ⦄ public
IsThrush : Pred Bird (b ⊔ ℓ)
IsThrush T = ∀ x y → T ∙ x ∙ y ≈ y ∙ x
record HasThrush : Set (b ⊔ ℓ) where
field
T : Bird
isThrush : IsThrush T
open HasThrush ⦃ ... ⦄ public
Commute : (x y : Bird) → Set ℓ
Commute x y = x ∙ y ≈ y ∙ x
IsRobin : Pred Bird (b ⊔ ℓ)
IsRobin R = ∀ x y z → R ∙ x ∙ y ∙ z ≈ y ∙ z ∙ x
record HasRobin : Set (b ⊔ ℓ) where
field
R : Bird
isRobin : IsRobin R
open HasRobin ⦃ ... ⦄ public
IsFinch : Pred Bird (b ⊔ ℓ)
IsFinch F = ∀ x y z → F ∙ x ∙ y ∙ z ≈ z ∙ y ∙ x
record HasFinch : Set (b ⊔ ℓ) where
field
F : Bird
isFinch : IsFinch F
open HasFinch ⦃ ... ⦄ public
IsVireo : Pred Bird (b ⊔ ℓ)
IsVireo V = ∀ x y z → V ∙ x ∙ y ∙ z ≈ z ∙ x ∙ y
record HasVireo : Set (b ⊔ ℓ) where
field
V : Bird
isVireo : IsVireo V
open HasVireo ⦃ ... ⦄ public
IsCardinalOnceRemoved : Pred Bird (b ⊔ ℓ)
IsCardinalOnceRemoved C* = ∀ x y z w → C* ∙ x ∙ y ∙ z ∙ w ≈ x ∙ y ∙ w ∙ z
record HasCardinalOnceRemoved : Set (b ⊔ ℓ) where
field
C* : Bird
isCardinalOnceRemoved : IsCardinalOnceRemoved C*
open HasCardinalOnceRemoved ⦃ ... ⦄ public
IsRobinOnceRemoved : Pred Bird (b ⊔ ℓ)
IsRobinOnceRemoved R* = ∀ x y z w → R* ∙ x ∙ y ∙ z ∙ w ≈ x ∙ z ∙ w ∙ y
record HasRobinOnceRemoved : Set (b ⊔ ℓ) where
field
R* : Bird
isRobinOnceRemoved : IsRobinOnceRemoved R*
open HasRobinOnceRemoved ⦃ ... ⦄ public
IsFinchOnceRemoved : Pred Bird (b ⊔ ℓ)
IsFinchOnceRemoved F* = ∀ x y z w → F* ∙ x ∙ y ∙ z ∙ w ≈ x ∙ w ∙ z ∙ y
record HasFinchOnceRemoved : Set (b ⊔ ℓ) where
field
F* : Bird
isFinchOnceRemoved : IsFinchOnceRemoved F*
open HasFinchOnceRemoved ⦃ ... ⦄ public
IsVireoOnceRemoved : Pred Bird (b ⊔ ℓ)
IsVireoOnceRemoved V* = ∀ x y z w → V* ∙ x ∙ y ∙ z ∙ w ≈ x ∙ w ∙ y ∙ z
record HasVireoOnceRemoved : Set (b ⊔ ℓ) where
field
V* : Bird
isVireoOnceRemoved : IsVireoOnceRemoved V*
open HasVireoOnceRemoved ⦃ ... ⦄ public
IsCardinalTwiceRemoved : Pred Bird (b ⊔ ℓ)
IsCardinalTwiceRemoved C** = ∀ x y z₁ z₂ z₃ → C** ∙ x ∙ y ∙ z₁ ∙ z₂ ∙ z₃ ≈ x ∙ y ∙ z₁ ∙ z₃ ∙ z₂
record HasCardinalTwiceRemoved : Set (b ⊔ ℓ) where
field
C** : Bird
isCardinalTwiceRemoved : IsCardinalTwiceRemoved C**
open HasCardinalTwiceRemoved ⦃ ... ⦄ public
IsRobinTwiceRemoved : Pred Bird (b ⊔ ℓ)
IsRobinTwiceRemoved R** = ∀ x y z₁ z₂ z₃ → R** ∙ x ∙ y ∙ z₁ ∙ z₂ ∙ z₃ ≈ x ∙ y ∙ z₂ ∙ z₃ ∙ z₁
record HasRobinTwiceRemoved : Set (b ⊔ ℓ) where
field
R** : Bird
isRobinTwiceRemoved : IsRobinTwiceRemoved R**
open HasRobinTwiceRemoved ⦃ ... ⦄ public
IsFinchTwiceRemoved : Pred Bird (b ⊔ ℓ)
IsFinchTwiceRemoved F** = ∀ x y z₁ z₂ z₃ → F** ∙ x ∙ y ∙ z₁ ∙ z₂ ∙ z₃ ≈ x ∙ y ∙ z₃ ∙ z₂ ∙ z₁
record HasFinchTwiceRemoved : Set (b ⊔ ℓ) where
field
F** : Bird
isFinchTwiceRemoved : IsFinchTwiceRemoved F**
open HasFinchTwiceRemoved ⦃ ... ⦄ public
IsVireoTwiceRemoved : Pred Bird (b ⊔ ℓ)
IsVireoTwiceRemoved V** = ∀ x y z₁ z₂ z₃ → V** ∙ x ∙ y ∙ z₁ ∙ z₂ ∙ z₃ ≈ x ∙ y ∙ z₃ ∙ z₁ ∙ z₂
record HasVireoTwiceRemoved : Set (b ⊔ ℓ) where
field
V** : Bird
isVireoTwiceRemoved : IsVireoTwiceRemoved V**
open HasVireoTwiceRemoved ⦃ ... ⦄ public
IsQueerBird : Pred Bird (b ⊔ ℓ)
IsQueerBird Q = ∀ x y z → Q ∙ x ∙ y ∙ z ≈ y ∙ (x ∙ z)
record HasQueerBird : Set (b ⊔ ℓ) where
field
Q : Bird
isQueerBird : IsQueerBird Q
open HasQueerBird ⦃ ... ⦄ public
IsQuixoticBird : Pred Bird (b ⊔ ℓ)
IsQuixoticBird Q₁ = ∀ x y z → Q₁ ∙ x ∙ y ∙ z ≈ x ∙ (z ∙ y)
record HasQuixoticBird : Set (b ⊔ ℓ) where
field
Q₁ : Bird
isQuixoticBird : IsQuixoticBird Q₁
open HasQuixoticBird ⦃ ... ⦄ public
IsQuizzicalBird : Pred Bird (b ⊔ ℓ)
IsQuizzicalBird Q₂ = ∀ x y z → Q₂ ∙ x ∙ y ∙ z ≈ y ∙ (z ∙ x)
record HasQuizzicalBird : Set (b ⊔ ℓ) where
field
Q₂ : Bird
isQuizzicalBird : IsQuizzicalBird Q₂
open HasQuizzicalBird ⦃ ... ⦄ public
IsQuirkyBird : Pred Bird (b ⊔ ℓ)
IsQuirkyBird Q₃ = ∀ x y z → Q₃ ∙ x ∙ y ∙ z ≈ z ∙ (x ∙ y)
record HasQuirkyBird : Set (b ⊔ ℓ) where
field
Q₃ : Bird
isQuirkyBird : IsQuirkyBird Q₃
open HasQuirkyBird ⦃ ... ⦄ public
IsQuackyBird : Pred Bird (b ⊔ ℓ)
IsQuackyBird Q₄ = ∀ x y z → Q₄ ∙ x ∙ y ∙ z ≈ z ∙ (y ∙ x)
record HasQuackyBird : Set (b ⊔ ℓ) where
field
Q₄ : Bird
isQuackyBird : IsQuackyBird Q₄
open HasQuackyBird ⦃ ... ⦄ public
IsGoldfinch : Pred Bird (b ⊔ ℓ)
IsGoldfinch G = ∀ x y z w → G ∙ x ∙ y ∙ z ∙ w ≈ x ∙ w ∙ (y ∙ z)
record HasGoldfinch : Set (b ⊔ ℓ) where
field
G : Bird
isGoldfinch : IsGoldfinch G
open HasGoldfinch ⦃ ... ⦄ public
IsDoubleMockingbird : Pred Bird (b ⊔ ℓ)
IsDoubleMockingbird M₂ = ∀ x y → M₂ ∙ x ∙ y ≈ x ∙ y ∙ (x ∙ y)
record HasDoubleMockingbird : Set (b ⊔ ℓ) where
field
M₂ : Bird
isDoubleMockingbird : IsDoubleMockingbird M₂
open HasDoubleMockingbird ⦃ ... ⦄ public
IsConverseWarbler : Pred Bird (b ⊔ ℓ)
IsConverseWarbler W′ = ∀ x y → W′ ∙ x ∙ y ≈ y ∙ x ∙ x
record HasConverseWarbler : Set (b ⊔ ℓ) where
field
W′ : Bird
isConverseWarbler : IsConverseWarbler W′
open HasConverseWarbler ⦃ ... ⦄ public
IsWarblerOnceRemoved : Pred Bird (b ⊔ ℓ)
IsWarblerOnceRemoved W* = ∀ x y z → W* ∙ x ∙ y ∙ z ≈ x ∙ y ∙ z ∙ z
record HasWarblerOnceRemoved : Set (b ⊔ ℓ) where
field
W* : Bird
isWarblerOnceRemoved : IsWarblerOnceRemoved W*
open HasWarblerOnceRemoved ⦃ ... ⦄ public
IsWarblerTwiceRemoved : Pred Bird (b ⊔ ℓ)
IsWarblerTwiceRemoved W** = ∀ x y z w → W** ∙ x ∙ y ∙ z ∙ w ≈ x ∙ y ∙ z ∙ w ∙ w
record HasWarblerTwiceRemoved : Set (b ⊔ ℓ) where
field
W** : Bird
isWarblerTwiceRemoved : IsWarblerTwiceRemoved W**
open HasWarblerTwiceRemoved ⦃ ... ⦄ public
IsHummingbird : Pred Bird (b ⊔ ℓ)
IsHummingbird H = ∀ x y z → H ∙ x ∙ y ∙ z ≈ x ∙ y ∙ z ∙ y
record HasHummingbird : Set (b ⊔ ℓ) where
field
H : Bird
isHummingbird : IsHummingbird H
open HasHummingbird ⦃ ... ⦄ public
IsStarling : Pred Bird (b ⊔ ℓ)
IsStarling S = ∀ x y z → S ∙ x ∙ y ∙ z ≈ x ∙ z ∙ (y ∙ z)
record HasStarling : Set (b ⊔ ℓ) where
field
S : Bird
isStarling : IsStarling S
open HasStarling ⦃ ... ⦄ public
IsPhoenix : Pred Bird (b ⊔ ℓ)
IsPhoenix Φ = ∀ x y z w → Φ ∙ x ∙ y ∙ z ∙ w ≈ x ∙ (y ∙ w) ∙ (z ∙ w)
record HasPhoenix : Set (b ⊔ ℓ) where
field
Φ : Bird
isPhoenix : IsPhoenix Φ
open HasPhoenix ⦃ ... ⦄ public
IsPsiBird : Pred Bird (b ⊔ ℓ)
IsPsiBird Ψ = ∀ x y z w → Ψ ∙ x ∙ y ∙ z ∙ w ≈ x ∙ (y ∙ z) ∙ (y ∙ w)
record HasPsiBird : Set (b ⊔ ℓ) where
field
Ψ : Bird
isPsiBird : IsPsiBird Ψ
open HasPsiBird ⦃ ... ⦄ public
IsTuringBird : Pred Bird (b ⊔ ℓ)
IsTuringBird U = ∀ x y → U ∙ x ∙ y ≈ y ∙ (x ∙ x ∙ y)
record HasTuringBird : Set (b ⊔ ℓ) where
field
U : Bird
isTuringBird : IsTuringBird U
open HasTuringBird ⦃ ... ⦄ public
IsOwl : Pred Bird (b ⊔ ℓ)
IsOwl O = ∀ x y → O ∙ x ∙ y ≈ y ∙ (x ∙ y)
record HasOwl : Set (b ⊔ ℓ) where
field
O : Bird
isOwl : IsOwl O
open HasOwl ⦃ ... ⦄ public
IsChoosy : Pred Bird (b ⊔ ℓ)
IsChoosy A = ∀ x → A IsFondOf x → IsSageBird x
IsJaybird : Pred Bird (b ⊔ ℓ)
IsJaybird J = ∀ x y z w → J ∙ x ∙ y ∙ z ∙ w ≈ x ∙ y ∙ (x ∙ w ∙ z)
record HasJaybird : Set (b ⊔ ℓ) where
field
J : Bird
isJaybird : IsJaybird J
open HasJaybird ⦃ ... ⦄ public
|
{
"alphanum_fraction": 0.601125921,
"avg_line_length": 23.454368932,
"ext": "agda",
"hexsha": "19db6bbf8b22364efec1253f6b68f8d2320e6a26",
"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": "df8bf877e60b3059532c54a247a36a3d83cd55b0",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "splintah/combinatory-logic",
"max_forks_repo_path": "Mockingbird/Forest/Birds.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0",
"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": "splintah/combinatory-logic",
"max_issues_repo_path": "Mockingbird/Forest/Birds.agda",
"max_line_length": 113,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "splintah/combinatory-logic",
"max_stars_repo_path": "Mockingbird/Forest/Birds.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-28T23:44:42.000Z",
"max_stars_repo_stars_event_min_datetime": "2022-02-28T23:44:42.000Z",
"num_tokens": 5327,
"size": 12079
}
|
-- WARNING: This file was generated automatically by Vehicle
-- and should not be modified manually!
-- Metadata
-- - Agda version: 2.6.2
-- - AISEC version: 0.1.0.1
-- - Time generated: ???
{-# OPTIONS --allow-exec #-}
open import Vehicle
open import Vehicle.Data.Tensor
open import Data.Nat as ℕ using (ℕ)
open import Data.Fin as Fin using (Fin; #_)
open import Data.List
module simple-tensor-temp-output where
zeroD : Tensor ℕ []
zeroD = 2
oneD : Tensor ℕ (2 ∷ [])
oneD = zeroD ∷ (1 ∷ [])
twoD : Tensor ℕ (2 ∷ (2 ∷ []))
twoD = oneD ∷ ((2 ∷ (3 ∷ [])) ∷ [])
lookup2D : ℕ
lookup2D = twoD (# 0) (# 1)
|
{
"alphanum_fraction": 0.6305418719,
"avg_line_length": 21.75,
"ext": "agda",
"hexsha": "640b9d65e4886db7a1c60a12bc1502788fde5665",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "vehicle-lang/vehicle",
"max_forks_repo_path": "test/Test/Compile/Golden/simple-tensor/simple-tensor-output.agda",
"max_issues_count": 19,
"max_issues_repo_head_hexsha": "25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T20:49:39.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-03-07T14:09:13.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "vehicle-lang/vehicle",
"max_issues_repo_path": "test/Test/Compile/Golden/simple-tensor/simple-tensor-output.agda",
"max_line_length": 60,
"max_stars_count": 9,
"max_stars_repo_head_hexsha": "25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "vehicle-lang/vehicle",
"max_stars_repo_path": "test/Test/Compile/Golden/simple-tensor/simple-tensor-output.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-17T18:51:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2022-02-10T12:56:42.000Z",
"num_tokens": 204,
"size": 609
}
|
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
-- The core of a category.
-- See https://ncatlab.org/nlab/show/core
module Categories.Category.Construction.Core {o ℓ e} (𝒞 : Category o ℓ e) where
open import Level using (_⊔_)
open import Function using (flip)
open import Categories.Category.Groupoid using (Groupoid; IsGroupoid)
open import Categories.Morphism 𝒞 as Morphism
open import Categories.Morphism.IsoEquiv 𝒞 as IsoEquiv
open Category 𝒞
open _≃_
Core : Category o (ℓ ⊔ e) e
Core = record
{ Obj = Obj
; _⇒_ = _≅_
; _≈_ = _≃_
; id = ≅.refl
; _∘_ = flip ≅.trans
; assoc = ⌞ assoc ⌟
; sym-assoc = ⌞ sym-assoc ⌟
; identityˡ = ⌞ identityˡ ⌟
; identityʳ = ⌞ identityʳ ⌟
; identity² = ⌞ identity² ⌟
; equiv = ≃-isEquivalence
; ∘-resp-≈ = λ where ⌞ eq₁ ⌟ ⌞ eq₂ ⌟ → ⌞ ∘-resp-≈ eq₁ eq₂ ⌟
}
Core-isGroupoid : IsGroupoid Core
Core-isGroupoid = record
{ _⁻¹ = ≅.sym
; iso = λ {_ _ f} → record { isoˡ = ⌞ isoˡ f ⌟ ; isoʳ = ⌞ isoʳ f ⌟ }
}
where open _≅_
CoreGroupoid : Groupoid o (ℓ ⊔ e) e
CoreGroupoid = record { category = Core; isGroupoid = Core-isGroupoid }
module CoreGroupoid = Groupoid CoreGroupoid
-- Useful shorthands for reasoning about isomorphisms and morphisms of
-- 𝒞 in the same module.
module Shorthands where
module Commutationᵢ where
open Commutation Core public using () renaming ([_⇒_]⟨_≈_⟩ to [_≅_]⟨_≈_⟩)
infixl 2 connectᵢ
connectᵢ : ∀ {A C : Obj} (B : Obj) → A ≅ B → B ≅ C → A ≅ C
connectᵢ B f g = ≅.trans f g
syntax connectᵢ B f g = f ≅⟨ B ⟩ g
open _≅_ public
open _≃_ public
open Morphism public using (module _≅_)
open IsoEquiv public using (⌞_⌟) renaming (module _≃_ to _≈ᵢ_)
open CoreGroupoid public using (_⁻¹) renaming
( _⇒_ to _≅_
; _≈_ to _≈ᵢ_
; id to idᵢ
; _∘_ to _∘ᵢ_
; iso to ⁻¹-iso
; module Equiv to Equivᵢ
; module HomReasoning to HomReasoningᵢ
; module iso to ⁻¹-iso
)
|
{
"alphanum_fraction": 0.5981713186,
"avg_line_length": 27.7066666667,
"ext": "agda",
"hexsha": "4dc229fa7babb31e2e0d2dc4473ae34100f8783c",
"lang": "Agda",
"max_forks_count": 64,
"max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z",
"max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Code-distancing/agda-categories",
"max_forks_repo_path": "src/Categories/Category/Construction/Core.agda",
"max_issues_count": 236,
"max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Code-distancing/agda-categories",
"max_issues_repo_path": "src/Categories/Category/Construction/Core.agda",
"max_line_length": 79,
"max_stars_count": 279,
"max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Trebor-Huang/agda-categories",
"max_stars_repo_path": "src/Categories/Category/Construction/Core.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": 801,
"size": 2078
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Some derivable properties
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Algebra
module Algebra.Properties.AbelianGroup
{a ℓ} (G : AbelianGroup a ℓ) where
open AbelianGroup G
open import Function
open import Relation.Binary.Reasoning.Setoid setoid
------------------------------------------------------------------------
-- Publicly re-export group properties
open import Algebra.Properties.Group group public
------------------------------------------------------------------------
-- Properties of abelian groups
xyx⁻¹≈y : ∀ x y → x ∙ y ∙ x ⁻¹ ≈ y
xyx⁻¹≈y x y = begin
x ∙ y ∙ x ⁻¹ ≈⟨ ∙-congʳ $ comm _ _ ⟩
y ∙ x ∙ x ⁻¹ ≈⟨ assoc _ _ _ ⟩
y ∙ (x ∙ x ⁻¹) ≈⟨ ∙-congˡ $ inverseʳ _ ⟩
y ∙ ε ≈⟨ identityʳ _ ⟩
y ∎
⁻¹-∙-comm : ∀ x y → x ⁻¹ ∙ y ⁻¹ ≈ (x ∙ y) ⁻¹
⁻¹-∙-comm x y = begin
x ⁻¹ ∙ y ⁻¹ ≈˘⟨ ⁻¹-anti-homo-∙ y x ⟩
(y ∙ x) ⁻¹ ≈⟨ ⁻¹-cong $ comm y x ⟩
(x ∙ y) ⁻¹ ∎
|
{
"alphanum_fraction": 0.4162112933,
"avg_line_length": 28.1538461538,
"ext": "agda",
"hexsha": "a5e2368447cdc2ad67f17d869e1504ac78858af0",
"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/Algebra/Properties/AbelianGroup.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/Algebra/Properties/AbelianGroup.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/Algebra/Properties/AbelianGroup.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": 375,
"size": 1098
}
|
------------------------------------------------------------------------
-- By indexing the program and WHNF types on a universe one can handle
-- several types at the same time
------------------------------------------------------------------------
module UniverseIndex where
open import Codata.Musical.Notation
open import Codata.Musical.Stream
open import Data.Product
infixr 5 _∷_
infixr 4 _,_
data U : Set₁ where
lift : Set → U
stream : U → U
product : U → U → U
El : U → Set
El (lift A) = A
El (stream a) = Stream (El a)
El (product a b) = El a × El b
data ElP : U → Set₁ where
interleave : ∀ {a} → ElP (stream a) → ElP (stream a) → ElP (stream a)
fst : ∀ {a b} → ElP (product a b) → ElP a
snd : ∀ {a b} → ElP (product a b) → ElP b
data ElW : U → Set₁ where
_∷_ : ∀ {a} → ElW a → ElP (stream a) → ElW (stream a)
_,_ : ∀ {a b} → ElW a → ElW b → ElW (product a b)
⌈_⌉ : ∀ {A} → A → ElW (lift A)
interleaveW : ∀ {a} → ElW (stream a) → ElP (stream a) → ElW (stream a)
interleaveW (x ∷ xs) ys = x ∷ interleave ys xs
fstW : ∀ {a b} → ElW (product a b) → ElW a
fstW (x , y) = x
sndW : ∀ {a b} → ElW (product a b) → ElW b
sndW (x , y) = y
whnf : ∀ {a} → ElP a → ElW a
whnf (interleave xs ys) = interleaveW (whnf xs) ys
whnf (fst p) = fstW (whnf p)
whnf (snd p) = sndW (whnf p)
mutual
⟦_⟧W : ∀ {a} → ElW a → El a
⟦ x ∷ xs ⟧W = ⟦ x ⟧W ∷ ♯ ⟦ xs ⟧P
⟦ x , y ⟧W = (⟦ x ⟧W , ⟦ y ⟧W)
⟦ ⌈ x ⌉ ⟧W = x
⟦_⟧P : ∀ {a} → ElP a → El a
⟦ p ⟧P = ⟦ whnf p ⟧W
|
{
"alphanum_fraction": 0.4811197917,
"avg_line_length": 26.4827586207,
"ext": "agda",
"hexsha": "2c6bf2a9257e071f2bc4969b2722766ef72e6e7d",
"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": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/codata",
"max_forks_repo_path": "UniverseIndex.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e",
"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/codata",
"max_issues_repo_path": "UniverseIndex.agda",
"max_line_length": 72,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/codata",
"max_stars_repo_path": "UniverseIndex.agda",
"max_stars_repo_stars_event_max_datetime": "2021-02-13T14:48:45.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-02-13T14:48:45.000Z",
"num_tokens": 622,
"size": 1536
}
|
{-# OPTIONS --without-K #-}
module hott where
open import hott.level public
open import hott.equivalence public
open import hott.loop public
open import hott.univalence public
open import hott.truncation public
|
{
"alphanum_fraction": 0.7981220657,
"avg_line_length": 21.3,
"ext": "agda",
"hexsha": "c09f67c61797e8056d2251af051315571dac1cb0",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z",
"max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "pcapriotti/agda-base",
"max_forks_repo_path": "src/hott.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c",
"max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "pcapriotti/agda-base",
"max_issues_repo_path": "src/hott.agda",
"max_line_length": 35,
"max_stars_count": 20,
"max_stars_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "pcapriotti/agda-base",
"max_stars_repo_path": "src/hott.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-01T11:25:54.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-06-12T12:20:17.000Z",
"num_tokens": 44,
"size": 213
}
|
module NamedImplicit where
postulate
T : Set -> Set
map' : (A B : Set) -> (A -> B) -> T A -> T B
map : {A B : Set} -> (A -> B) -> T A -> T B
map = map' _ _
data Nat : Set where
zero : Nat
suc : Nat -> Nat
data Bool : Set where
true : Bool
false : Bool
id : {A : Set} -> A -> A
id x = x
const : {A B : Set} -> A -> B -> A
const x y = x
postulate
unsafeCoerce : {A B : Set} -> A -> B
test1 = map {B = Nat} id
test2 = map {A = Nat} (const zero)
test3 = map {B = Bool} (unsafeCoerce {A = Nat})
test4 = map {B = Nat -> Nat} (const {B = Bool} id)
f : {A B C D : Set} -> D -> D
f {D = X} = \(x : X) -> x
|
{
"alphanum_fraction": 0.4904458599,
"avg_line_length": 16.972972973,
"ext": "agda",
"hexsha": "891fc59962542882f7b756aad76eb403d84b7cf9",
"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/NamedImplicit.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/NamedImplicit.agda",
"max_line_length": 50,
"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/NamedImplicit.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": 252,
"size": 628
}
|
{-# OPTIONS --safe --experimental-lossy-unification #-}
module Cubical.ZCohomology.CohomologyRings.Sn where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Transport
open import Cubical.Foundations.HLevels
open import Cubical.Data.Empty as ⊥
open import Cubical.Data.Unit
open import Cubical.Data.Nat renaming (_+_ to _+n_ ; +-comm to +n-comm ; _·_ to _·n_ ; snotz to nsnotz)
open import Cubical.Data.Nat.Order
open import Cubical.Data.Int hiding (_+'_)
open import Cubical.Data.Sigma
open import Cubical.Data.Vec
open import Cubical.Data.FinData
open import Cubical.Relation.Nullary
open import Cubical.Algebra.Group
open import Cubical.Algebra.Group.Instances.Int renaming (ℤGroup to ℤG)
open import Cubical.Algebra.Group.Morphisms
open import Cubical.Algebra.Group.MorphismProperties
open import Cubical.Algebra.DirectSum.Base
open import Cubical.Algebra.Ring
open import Cubical.Algebra.CommRing
open import Cubical.Algebra.CommRing.FGIdeal
open import Cubical.Algebra.CommRing.QuotientRing
open import Cubical.Algebra.Polynomials.Multivariate.Base renaming (base to baseP)
open import Cubical.Algebra.CommRing.Instances.Int renaming (ℤCommRing to ℤCR)
open import Cubical.Algebra.CommRing.Instances.MultivariatePoly
open import Cubical.Algebra.CommRing.Instances.MultivariatePoly-Quotient
open import Cubical.Algebra.CommRing.Instances.MultivariatePoly-notationZ
open import Cubical.HITs.SetQuotients as SQ renaming (_/_ to _/sq_)
open import Cubical.HITs.PropositionalTruncation as PT
open import Cubical.HITs.SetTruncation as ST
open import Cubical.HITs.Truncation
open import Cubical.HITs.Sn
open import Cubical.ZCohomology.Base
open import Cubical.ZCohomology.GroupStructure
open import Cubical.ZCohomology.RingStructure.CupProduct
open import Cubical.ZCohomology.RingStructure.RingLaws
open import Cubical.ZCohomology.RingStructure.CohomologyRing
open import Cubical.ZCohomology.Groups.Sn
open Iso
-----------------------------------------------------------------------------
-- Somme properties over H⁰-Sⁿ≅ℤ
module Properties-H⁰-Sⁿ≅ℤ where
open RingStr
T0m : (m : ℕ) → (z : ℤ) → coHom 0 (S₊ (suc m))
T0m m = inv (fst (H⁰-Sⁿ≅ℤ m))
T0mg : (m : ℕ) → IsGroupHom (snd ℤG) (T0m m) (coHomGr 0 (S₊ (suc m)) .snd)
T0mg m = snd (invGroupIso (H⁰-Sⁿ≅ℤ m))
T0m-pres1 : (m : ℕ) → base 0 ((T0m m) 1) ≡ 1r (snd (H*R (S₊ (suc m))))
T0m-pres1 zero = refl
T0m-pres1 (suc m) = refl
T0m-pos0 : (m : ℕ) → {l : ℕ} → (x : coHom l (S₊ (suc m))) → (T0m m) (pos zero) ⌣ x ≡ 0ₕ l
T0m-pos0 zero = ST.elim (λ x → isProp→isSet (squash₂ _ _)) λ x → refl
T0m-pos0 (suc m) = ST.elim (λ x → isProp→isSet (squash₂ _ _)) λ x → refl
T0m-posS : (m : ℕ) → {l : ℕ} → (k : ℕ) → (x : coHom l (S₊ (suc m)))
→ T0m m (pos (suc k)) ⌣ x ≡ x +ₕ (T0m m (pos k) ⌣ x)
T0m-posS zero k = ST.elim (λ x → isProp→isSet (squash₂ _ _)) (λ x → refl)
T0m-posS (suc m) k = ST.elim (λ x → isProp→isSet (squash₂ _ _)) (λ x → refl)
T0m-neg0 : (m : ℕ) → {l : ℕ} → (x : coHom l (S₊ (suc m))) → T0m m (negsuc zero) ⌣ x ≡ -ₕ x
T0m-neg0 zero = ST.elim (λ x → isProp→isSet (squash₂ _ _)) (λ x → refl)
T0m-neg0 (suc m) = ST.elim (λ x → isProp→isSet (squash₂ _ _)) (λ x → refl)
T0m-negS : (m : ℕ) → {l : ℕ} → (k : ℕ) → (x : coHom l (S₊ (suc m)))
→ T0m m (negsuc (suc k)) ⌣ x ≡ (T0m m (negsuc k) ⌣ x) +ₕ (-ₕ x)
T0m-negS zero k = ST.elim (λ x → isProp→isSet (squash₂ _ _)) (λ x → refl)
T0m-negS (suc m) k = ST.elim (λ x → isProp→isSet (squash₂ _ _)) (λ x → refl)
-----------------------------------------------------------------------------
-- Definitions
module Equiv-Sn-Properties (n : ℕ) where
open IsGroupHom
open Properties-H⁰-Sⁿ≅ℤ
open CommRingStr (snd ℤCR) using ()
renaming
( 0r to 0ℤ
; 1r to 1ℤ
; _+_ to _+ℤ_
; -_ to -ℤ_
; _·_ to _·ℤ_
; +Assoc to +ℤAssoc
; +Identity to +ℤIdentity
; +Lid to +ℤLid
; +Rid to +ℤRid
; +Inv to +ℤInv
; +Linv to +ℤLinv
; +Rinv to +ℤRinv
; +Comm to +ℤComm
; ·Assoc to ·ℤAssoc
; ·Identity to ·ℤIdentity
; ·Lid to ·ℤLid
; ·Rid to ·ℤRid
; ·Rdist+ to ·ℤRdist+
; ·Ldist+ to ·ℤLdist+
; is-set to isSetℤ )
open RingStr (snd (H*R (S₊ (suc n)))) using ()
renaming
( 0r to 0H*
; 1r to 1H*
; _+_ to _+H*_
; -_ to -H*_
; _·_ to _cup_
; +Assoc to +H*Assoc
; +Identity to +H*Identity
; +Lid to +H*Lid
; +Rid to +H*Rid
; +Inv to +H*Inv
; +Linv to +H*Linv
; +Rinv to +H*Rinv
; +Comm to +H*Comm
; ·Assoc to ·H*Assoc
; ·Identity to ·H*Identity
; ·Lid to ·H*Lid
; ·Rid to ·H*Rid
; ·Rdist+ to ·H*Rdist+
; ·Ldist+ to ·H*Ldist+
; is-set to isSetH* )
open CommRingStr (snd ℤ[X]) using ()
renaming
( 0r to 0Pℤ
; 1r to 1Pℤ
; _+_ to _+Pℤ_
; -_ to -Pℤ_
; _·_ to _·Pℤ_
; +Assoc to +PℤAssoc
; +Identity to +PℤIdentity
; +Lid to +PℤLid
; +Rid to +PℤRid
; +Inv to +PℤInv
; +Linv to +PℤLinv
; +Rinv to +PℤRinv
; +Comm to +PℤComm
; ·Assoc to ·PℤAssoc
; ·Identity to ·PℤIdentity
; ·Lid to ·PℤLid
; ·Rid to ·PℤRid
; ·Comm to ·PℤComm
; ·Rdist+ to ·PℤRdist+
; ·Ldist+ to ·PℤLdist+
; is-set to isSetPℤ )
open CommRingStr (snd ℤ[X]/X²) using ()
renaming
( 0r to 0PℤI
; 1r to 1PℤI
; _+_ to _+PℤI_
; -_ to -PℤI_
; _·_ to _·PℤI_
; +Assoc to +PℤIAssoc
; +Identity to +PℤIIdentity
; +Lid to +PℤILid
; +Rid to +PℤIRid
; +Inv to +PℤIInv
; +Linv to +PℤILinv
; +Rinv to +PℤIRinv
; +Comm to +PℤIComm
; ·Assoc to ·PℤIAssoc
; ·Identity to ·PℤIIdentity
; ·Lid to ·PℤILid
; ·Rid to ·PℤIRid
; ·Rdist+ to ·PℤIRdist+
; ·Ldist+ to ·PℤILdist+
; is-set to isSetPℤI )
-----------------------------------------------------------------------------
-- Partition of ℕ
data partℕ (k : ℕ) : Type ℓ-zero where
is0 : (k ≡ 0) → partℕ k
isSn : (k ≡ suc n) → partℕ k
else : (k ≡ 0 → ⊥) × (k ≡ suc n → ⊥) → partℕ k
part : (k : ℕ) → partℕ k
part k with (discreteℕ k 0)
... | yes p = is0 p
... | no ¬p with (discreteℕ k (suc n))
... | yes q = isSn q
... | no ¬q = else (¬p , ¬q)
part0 : part 0 ≡ is0 refl
part0 = refl
partSn : (x : partℕ (suc n)) → x ≡ isSn refl
partSn (is0 x) = ⊥.rec (nsnotz x)
partSn (isSn x) = cong isSn (isSetℕ _ _ _ _)
partSn (else x) = ⊥.rec (snd x refl)
-----------------------------------------------------------------------------
-- As we are in the general case, the definition are now up to a path and not definitional
-- Hence when need to add transport to go from coHom 0 X to coHom 0 X
-- This some notation and usefull lemma
substCoHom : {k l : ℕ} → (x : k ≡ l) → (a : coHom k (S₊ (suc n))) → coHom l (S₊ (suc n))
substCoHom x a = subst (λ X → coHom X (S₊ (suc n))) x a
-- solve a pbl of project with the notation
substReflCoHom : {k : ℕ} → (a : coHom k (S₊ (suc n))) → subst (λ X → coHom X (S₊ (suc n))) refl a ≡ a
substReflCoHom a = substRefl a
subst-0 : (k l : ℕ) → (x : k ≡ l) → substCoHom x (0ₕ k) ≡ 0ₕ l
subst-0 k l x = J (λ l x → substCoHom x (0ₕ k) ≡ 0ₕ l) (substReflCoHom (0ₕ k)) x
subst-+ : (k : ℕ) → (a b : coHom k (S₊ (suc n))) → (l : ℕ) → (x : k ≡ l)
→ substCoHom x (a +ₕ b) ≡ substCoHom x a +ₕ substCoHom x b
subst-+ k a b l x = J (λ l x → substCoHom x (a +ₕ b) ≡ substCoHom x a +ₕ substCoHom x b)
(substReflCoHom (a +ₕ b) ∙ sym (cong₂ _+ₕ_ (substReflCoHom a) (substReflCoHom b)))
x
subst-⌣ : (k : ℕ) → (a b : coHom k (S₊ (suc n))) → (l : ℕ) → (x : k ≡ l)
→ substCoHom (cong₂ _+'_ x x) (a ⌣ b) ≡ substCoHom x a ⌣ substCoHom x b
subst-⌣ k a b l x = J (λ l x → substCoHom (cong₂ _+'_ x x) (a ⌣ b) ≡ substCoHom x a ⌣ substCoHom x b)
(substReflCoHom (a ⌣ b) ∙ sym (cong₂ _⌣_ (substReflCoHom a) (substReflCoHom b)))
x
-----------------------------------------------------------------------------
-- Direct Sens on ℤ[x]
ℤ[x]→H*-Sⁿ : ℤ[x] → H* (S₊ (suc n))
ℤ[x]→H*-Sⁿ = Poly-Rec-Set.f _ _ _ isSetH*
0H*
base-trad
_+H*_
+H*Assoc
+H*Rid
+H*Comm
base-neutral-eq
base-add-eq
where
base-trad : _
base-trad (zero ∷ []) a = base 0 (inv (fst (H⁰-Sⁿ≅ℤ n)) a)
base-trad (one ∷ []) a = base (suc n) (inv (fst (Hⁿ-Sⁿ≅ℤ n)) a)
base-trad (suc (suc k) ∷ []) a = 0H*
base-neutral-eq : _
base-neutral-eq (zero ∷ []) = cong (base 0) (pres1 (snd (invGroupIso (H⁰-Sⁿ≅ℤ n)))) ∙ base-neutral _
base-neutral-eq (one ∷ []) = cong (base (suc n)) (pres1 (snd (invGroupIso (Hⁿ-Sⁿ≅ℤ n)))) ∙ base-neutral _
base-neutral-eq (suc (suc k) ∷ []) = refl
base-add-eq : _
base-add-eq (zero ∷ []) a b = base-add _ _ _ ∙ cong (base 0) (sym (pres· (snd (invGroupIso (H⁰-Sⁿ≅ℤ n))) a b))
base-add-eq (one ∷ []) a b = base-add _ _ _ ∙ cong (base (suc n)) (sym (pres· (snd (invGroupIso (Hⁿ-Sⁿ≅ℤ n))) a b))
base-add-eq (suc (suc k) ∷ []) a b = +H*Rid _
-----------------------------------------------------------------------------
-- Morphism on ℤ[x]
-- doesn't compute without an abstract value !
ℤ[x]→H*-Sⁿ-pres1 : ℤ[x]→H*-Sⁿ (1Pℤ) ≡ 1H*
ℤ[x]→H*-Sⁿ-pres1 = T0m-pres1 n
ℤ[x]→H*-Sⁿ-pres+ : (x y : ℤ[x]) → ℤ[x]→H*-Sⁿ (x +Pℤ y) ≡ ℤ[x]→H*-Sⁿ x +H* ℤ[x]→H*-Sⁿ y
ℤ[x]→H*-Sⁿ-pres+ x y = refl
T0 = T0m n
T0g = T0mg n
T0-pos0 = T0m-pos0 n
T0-posS = T0m-posS n
T0-neg0 = T0m-neg0 n
T0-negS = T0m-negS n
-- cup product on H⁰ → Hⁿ → Hⁿ
module _
(l : ℕ)
(Tl : (z : ℤ) → coHom l (S₊ (suc n)))
(Tlg : IsGroupHom (ℤG .snd) Tl (coHomGr l (S₊ (suc n)) .snd))
where
pres·-base-case-0l : (a : ℤ) → (b : ℤ) →
Tl (a ·ℤ b) ≡ (T0 a) ⌣ (Tl b)
pres·-base-case-0l (pos zero) b = pres1 Tlg
∙ sym (T0-pos0 (Tl b))
pres·-base-case-0l (pos (suc k)) b = pres· Tlg b (pos k ·ℤ b)
∙ cong (λ X → (Tl b) +ₕ X) (pres·-base-case-0l (pos k) b)
∙ sym (T0-posS k (Tl b))
pres·-base-case-0l (negsuc zero) b = presinv Tlg b
∙ sym (T0-neg0 (Tl b))
pres·-base-case-0l (negsuc (suc k)) b = cong Tl (+ℤComm (-ℤ b) (negsuc k ·ℤ b))
∙ pres· Tlg (negsuc k ·ℤ b) (-ℤ b)
∙ cong₂ _+ₕ_ (pres·-base-case-0l (negsuc k) b)
(presinv Tlg b)
∙ sym (T0-negS k (Tl b))
-- Nice packging of the proof
pres·-base-case-int : (k : ℕ) → (a : ℤ) → (l : ℕ) → (b : ℤ) →
ℤ[x]→H*-Sⁿ (baseP (k ∷ []) a ·Pℤ baseP (l ∷ []) b)
≡ ℤ[x]→H*-Sⁿ (baseP (k ∷ []) a) cup ℤ[x]→H*-Sⁿ (baseP (l ∷ []) b)
pres·-base-case-int zero a zero b = cong (base 0) (pres·-base-case-0l 0 (inv (fst (H⁰-Sⁿ≅ℤ n)))
(snd (invGroupIso (H⁰-Sⁿ≅ℤ n))) a b)
pres·-base-case-int zero a one b = cong (base (suc n)) (pres·-base-case-0l (suc n) (inv (fst (Hⁿ-Sⁿ≅ℤ n)))
(snd (invGroupIso (Hⁿ-Sⁿ≅ℤ n))) a b)
pres·-base-case-int zero a (suc (suc l)) b = refl
pres·-base-case-int one a zero b = cong ℤ[x]→H*-Sⁿ (·PℤComm (baseP (one ∷ []) a) (baseP (zero ∷ []) b))
∙ pres·-base-case-int zero b one a
∙ gradCommRing (S₊ (suc n)) 0 (suc n) (inv (fst (H⁰-Sⁿ≅ℤ n)) b) (inv (fst (Hⁿ-Sⁿ≅ℤ n)) a)
pres·-base-case-int one a one b = sym (base-neutral (suc n +' suc n))
∙ cong (base (suc n +' suc n))
(isOfHLevelRetractFromIso
1
(fst (Hⁿ-Sᵐ≅0 (suc (n +n n)) n (λ p → <→≢ (n , (+n-comm n (suc n))) (sym p))))
isPropUnit _ _)
pres·-base-case-int one a (suc (suc l)) b = refl
pres·-base-case-int (suc (suc k)) a l b = refl
pres·-base-case-vec : (v : Vec ℕ 1) → (a : ℤ) → (v' : Vec ℕ 1) → (b : ℤ) →
ℤ[x]→H*-Sⁿ (baseP v a ·Pℤ baseP v' b)
≡ ℤ[x]→H*-Sⁿ (baseP v a) cup ℤ[x]→H*-Sⁿ (baseP v' b)
pres·-base-case-vec (k ∷ []) a (l ∷ []) b = pres·-base-case-int k a l b
-- proof of the morphism
ℤ[x]→H*-Sⁿ-pres· : (x y : ℤ[x]) → ℤ[x]→H*-Sⁿ (x ·Pℤ y) ≡ ℤ[x]→H*-Sⁿ x cup ℤ[x]→H*-Sⁿ y
ℤ[x]→H*-Sⁿ-pres· = Poly-Ind-Prop.f _ _ _
(λ x p q i y j → isSetH* _ _ (p y) (q y) i j)
(λ y → refl)
base-case
λ {U V} ind-U ind-V y → cong₂ _+H*_ (ind-U y) (ind-V y)
where
base-case : _
base-case (k ∷ []) a = Poly-Ind-Prop.f _ _ _ (λ _ → isSetH* _ _)
(sym (RingTheory.0RightAnnihilates (H*R (S₊ (suc n))) _))
(λ v' b → pres·-base-case-vec (k ∷ []) a v' b)
λ {U V} ind-U ind-V → (cong₂ _+H*_ ind-U ind-V) ∙ sym (·H*Rdist+ _ _ _)
-----------------------------------------------------------------------------
-- Function on ℤ[x]/x + morphism
ℤ[x]→H*-Sⁿ-cancelX : (k : Fin 1) → ℤ[x]→H*-Sⁿ (<X²> k) ≡ 0H*
ℤ[x]→H*-Sⁿ-cancelX zero = refl
ℤ[X]→H*-Sⁿ : RingHom (CommRing→Ring ℤ[X]) (H*R (S₊ (suc n)))
fst ℤ[X]→H*-Sⁿ = ℤ[x]→H*-Sⁿ
snd ℤ[X]→H*-Sⁿ = makeIsRingHom ℤ[x]→H*-Sⁿ-pres1 ℤ[x]→H*-Sⁿ-pres+ ℤ[x]→H*-Sⁿ-pres·
ℤ[X]/X²→H*R-Sⁿ : RingHom (CommRing→Ring ℤ[X]/X²) (H*R (S₊ (suc n)))
ℤ[X]/X²→H*R-Sⁿ = Quotient-FGideal-CommRing-Ring.f ℤ[X] (H*R (S₊ (suc n))) ℤ[X]→H*-Sⁿ <X²> ℤ[x]→H*-Sⁿ-cancelX
ℤ[x]/x²→H*-Sⁿ : ℤ[x]/x² → H* (S₊ (suc n))
ℤ[x]/x²→H*-Sⁿ = fst ℤ[X]/X²→H*R-Sⁿ
-----------------------------------------------------------------------------
-- Converse Sens on ℤ[X] + ℤ[x]/x
base-trad-H* : (k : ℕ) → (a : coHom k (S₊ (suc n))) → (x : partℕ k) → ℤ[x]
base-trad-H* k a (is0 x) = baseP (0 ∷ []) (fun (fst (H⁰-Sⁿ≅ℤ n)) (substCoHom x a))
base-trad-H* k a (isSn x) = baseP (1 ∷ []) (fun (fst (Hⁿ-Sⁿ≅ℤ n)) (substCoHom x a))
base-trad-H* k a (else x) = 0Pℤ
H*-Sⁿ→ℤ[x] : H* (S₊ (suc n)) → ℤ[x]
H*-Sⁿ→ℤ[x] = DS-Rec-Set.f _ _ _ _ isSetPℤ
0Pℤ
(λ k a → base-trad-H* k a (part k))
_+Pℤ_
+PℤAssoc
+PℤRid
+PℤComm
(λ k → base-neutral-eq k (part k))
λ k a b → base-add-eq k a b (part k)
where
base-neutral-eq : (k : ℕ) → (x : partℕ k) → base-trad-H* k (0ₕ k) x ≡ 0Pℤ
base-neutral-eq k (is0 x) = cong (baseP (0 ∷ [])) (cong (fun (fst (H⁰-Sⁿ≅ℤ n))) (subst-0 k 0 x))
∙ cong (baseP (0 ∷ [])) (pres1 (snd (H⁰-Sⁿ≅ℤ n)))
∙ base-0P (0 ∷ [])
base-neutral-eq k (isSn x) = cong (baseP (1 ∷ [])) (cong (fun (fst (Hⁿ-Sⁿ≅ℤ n))) (subst-0 k (suc n) x))
∙ cong (baseP (1 ∷ [])) (pres1 (snd (Hⁿ-Sⁿ≅ℤ n)))
∙ base-0P (1 ∷ [])
base-neutral-eq k (else x) = refl
base-add-eq : (k : ℕ) → (a b : coHom k (S₊ (suc n))) → (x : partℕ k)
→ base-trad-H* k a x +Pℤ base-trad-H* k b x ≡ base-trad-H* k (a +ₕ b) x
base-add-eq k a b (is0 x) = base-poly+ _ _ _
∙ cong (baseP (0 ∷ [])) (sym (pres· (snd (H⁰-Sⁿ≅ℤ n)) _ _))
∙ cong (baseP (0 ∷ [])) (cong (fun (fst (H⁰-Sⁿ≅ℤ n))) (sym (subst-+ k a b 0 x)))
base-add-eq k a b (isSn x) = base-poly+ _ _ _
∙ cong (baseP (1 ∷ [])) (sym (pres· (snd (Hⁿ-Sⁿ≅ℤ n)) _ _))
∙ cong (baseP (1 ∷ [])) (cong (fun (fst (Hⁿ-Sⁿ≅ℤ n))) (sym (subst-+ k a b (suc n) x)))
base-add-eq k a b (else x) = +PℤRid _
H*-Sⁿ→ℤ[x]-pres+ : (x y : H* (S₊ (suc n))) → H*-Sⁿ→ℤ[x] ( x +H* y) ≡ H*-Sⁿ→ℤ[x] x +Pℤ H*-Sⁿ→ℤ[x] y
H*-Sⁿ→ℤ[x]-pres+ x y = refl
H*-Sⁿ→ℤ[x]/x² : H* (S₊ (suc n)) → ℤ[x]/x²
H*-Sⁿ→ℤ[x]/x² = [_] ∘ H*-Sⁿ→ℤ[x]
H*-Sⁿ→ℤ[x]/x²-pres+ : (x y : H* (S₊ (suc n))) → H*-Sⁿ→ℤ[x]/x² (x +H* y) ≡ (H*-Sⁿ→ℤ[x]/x² x) +PℤI (H*-Sⁿ→ℤ[x]/x² y)
H*-Sⁿ→ℤ[x]/x²-pres+ x y = refl
-----------------------------------------------------------------------------
-- Section
e-sect-base : (k : ℕ) → (a : coHom k (S₊ (suc n))) → (x : partℕ k) →
ℤ[x]/x²→H*-Sⁿ [ (base-trad-H* k a x) ] ≡ base k a
e-sect-base k a (is0 x) = cong (base 0) (leftInv (fst (H⁰-Sⁿ≅ℤ n)) (substCoHom x a))
∙ sym (constSubstCommSlice (λ x → coHom x (S₊ (suc n))) (H* (S₊ (suc n))) base x a)
e-sect-base k a (isSn x) = cong (base (suc n)) (leftInv (fst (Hⁿ-Sⁿ≅ℤ n)) (substCoHom x a))
∙ sym (constSubstCommSlice (λ x → coHom x (S₊ (suc n))) (H* (S₊ (suc n))) base x a)
e-sect-base k a (else x) = sym (base-neutral k)
∙ constSubstCommSlice ((λ x → coHom x (S₊ (suc n)))) ((H* (S₊ (suc n)))) base (suc-predℕ k (fst x)) (0ₕ k)
∙ cong (base (suc (predℕ k)))
((isOfHLevelRetractFromIso 1
(fst (Hⁿ-Sᵐ≅0 (predℕ k) n λ p → snd x (suc-predℕ k (fst x) ∙ cong suc p)))
isPropUnit _ _))
∙ sym (constSubstCommSlice ((λ x → coHom x (S₊ (suc n)))) ((H* (S₊ (suc n)))) base (suc-predℕ k (fst x)) a)
e-sect : (x : H* (S₊ (suc n))) → ℤ[x]/x²→H*-Sⁿ (H*-Sⁿ→ℤ[x]/x² x) ≡ x
e-sect = DS-Ind-Prop.f _ _ _ _ (λ _ → isSetH* _ _)
refl
(λ k a → e-sect-base k a (part k))
λ {U V} ind-U ind-V → cong₂ _+H*_ ind-U ind-V
-----------------------------------------------------------------------------
-- Retraction
e-retr : (x : ℤ[x]/x²) → H*-Sⁿ→ℤ[x]/x² (ℤ[x]/x²→H*-Sⁿ x) ≡ x
e-retr = SQ.elimProp (λ _ → isSetPℤI _ _)
(Poly-Ind-Prop.f _ _ _ (λ _ → isSetPℤI _ _)
refl
base-case
λ {U V} ind-U ind-V → cong₂ _+PℤI_ ind-U ind-V)
where
base-case : _
base-case (zero ∷ []) a = cong [_] (cong (base-trad-H* 0 (inv (fst (H⁰-Sⁿ≅ℤ n)) a)) part0)
∙ cong [_] (cong (baseP (0 ∷ [])) (cong (fun (fst (H⁰-Sⁿ≅ℤ n)))
(substReflCoHom (inv (fst (H⁰-Sⁿ≅ℤ n)) a))))
∙ cong [_] (cong (baseP (0 ∷ [])) (rightInv (fst (H⁰-Sⁿ≅ℤ n)) a))
base-case (one ∷ []) a = cong [_] (cong (base-trad-H* (suc n) (inv (fst (Hⁿ-Sⁿ≅ℤ n)) a)) (partSn (part (suc n))))
∙ cong [_] (cong (baseP (1 ∷ [])) (cong (fun (fst (Hⁿ-Sⁿ≅ℤ n)))
(substReflCoHom (inv (fst (Hⁿ-Sⁿ≅ℤ n)) a))))
∙ cong [_] (cong (baseP (1 ∷ [])) (rightInv (fst (Hⁿ-Sⁿ≅ℤ n)) a))
base-case (suc (suc k) ∷ []) a = eq/ 0Pℤ (baseP (suc (suc k) ∷ []) a) ∣ ((λ x → baseP (k ∷ []) (-ℤ a)) , helper) ∣₁
where
helper : _
helper = (+PℤLid _) ∙ cong₂ baseP (cong (λ X → X ∷ []) (sym (+n-comm k 2))) (sym (·ℤRid _)) ∙ (sym (+PℤRid _))
-----------------------------------------------------------------------------
-- Computation of the Cohomology Ring
module _ (n : ℕ) where
open Equiv-Sn-Properties n
Sⁿ-CohomologyRing : RingEquiv (CommRing→Ring ℤ[X]/X²) (H*R (S₊ (suc n)))
fst Sⁿ-CohomologyRing = isoToEquiv is
where
is : Iso ℤ[x]/x² (H* (S₊ (suc n)))
fun is = ℤ[x]/x²→H*-Sⁿ
inv is = H*-Sⁿ→ℤ[x]/x²
rightInv is = e-sect
leftInv is = e-retr
snd Sⁿ-CohomologyRing = snd ℤ[X]/X²→H*R-Sⁿ
CohomologyRing-Sⁿ : RingEquiv (H*R (S₊ (suc n))) (CommRing→Ring ℤ[X]/X²)
CohomologyRing-Sⁿ = RingEquivs.invEquivRing Sⁿ-CohomologyRing
|
{
"alphanum_fraction": 0.4610948239,
"avg_line_length": 41.6973947896,
"ext": "agda",
"hexsha": "827d202c9346b10b715f74a85e7ac5f9643230a0",
"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": "b6fbca9e83e553c5c2e4a16a2df7f9e9039034dc",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "xekoukou/cubical",
"max_forks_repo_path": "Cubical/ZCohomology/CohomologyRings/Sn.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b6fbca9e83e553c5c2e4a16a2df7f9e9039034dc",
"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": "xekoukou/cubical",
"max_issues_repo_path": "Cubical/ZCohomology/CohomologyRings/Sn.agda",
"max_line_length": 146,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "b6fbca9e83e553c5c2e4a16a2df7f9e9039034dc",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "xekoukou/cubical",
"max_stars_repo_path": "Cubical/ZCohomology/CohomologyRings/Sn.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 8349,
"size": 20807
}
|
{-# OPTIONS --type-in-type #-}
data ⊥ : Set where
℘ : ∀ {ℓ} → Set ℓ → Set _
℘ {ℓ} S = S → Set
U : Set
U = ∀ (X : Set) → (℘ (℘ X) → X) → ℘ (℘ X)
{- If using two impredicative universe layers instead of type-in-type:
U : Set₁
U = ∀ (X : Set₁) → (℘ (℘ X) → X) → ℘ (℘ X)
-}
τ : ℘ (℘ U) → U
τ t = λ X f p → t (λ x → p (f (x X f)))
σ : U → ℘ (℘ U)
σ s = s U τ
Δ : ℘ U
Δ y = (∀ p → σ y p → p (τ (σ y))) → ⊥
Ω : U
Ω = τ (λ p → (∀ x → σ x p → p x))
R : ∀ p → (∀ x → σ x p → p x) → p Ω
R _ 𝟙 = 𝟙 Ω (λ x → 𝟙 (τ (σ x)))
M : ∀ x → σ x Δ → Δ x
M _ 𝟚 𝟛 = 𝟛 Δ 𝟚 (λ p → 𝟛 (λ y → p (τ (σ y))))
L : (∀ p → (∀ x → σ x p → p x) → p Ω) → ⊥
L 𝟘 = 𝟘 Δ M (λ p → 𝟘 (λ y → p (τ (σ y))))
false : ⊥
false = L R
|
{
"alphanum_fraction": 0.3674351585,
"avg_line_length": 18.2631578947,
"ext": "agda",
"hexsha": "0bdb33a245e87c059b1d20d535bc900079280c90",
"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": "d54cdaf24391b2726e491a18cba2d2d8ae3ac20b",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "ionathanch/ionathanch.github.io",
"max_forks_repo_path": "_assets/agda/Girard.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "d54cdaf24391b2726e491a18cba2d2d8ae3ac20b",
"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": "ionathanch/ionathanch.github.io",
"max_issues_repo_path": "_assets/agda/Girard.agda",
"max_line_length": 70,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "d54cdaf24391b2726e491a18cba2d2d8ae3ac20b",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "ionathanch/ionathanch.github.io",
"max_stars_repo_path": "_assets/agda/Girard.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 395,
"size": 694
}
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Algebra.Group where
open import Cubical.Algebra.Group.Base public
open import Cubical.Algebra.Group.Properties public
open import Cubical.Algebra.Group.Morphism public
open import Cubical.Algebra.Group.MorphismProperties public
open import Cubical.Algebra.Group.Algebra public
|
{
"alphanum_fraction": 0.8226744186,
"avg_line_length": 38.2222222222,
"ext": "agda",
"hexsha": "3b3372086b2c851dcc0a411c5a26d634f48fa619",
"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/Group.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "dan-iel-lee/cubical",
"max_issues_repo_path": "Cubical/Algebra/Group.agda",
"max_line_length": 59,
"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/Group.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 76,
"size": 344
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Signs
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Sign where
open import Relation.Binary using (Decidable)
open import Relation.Binary.PropositionalEquality using (_≡_; refl)
open import Relation.Nullary using (yes; no)
-- Signs.
data Sign : Set where
- : Sign
+ : Sign
-- Decidable equality.
infix 4 _≟_
_≟_ : Decidable {A = Sign} _≡_
- ≟ - = yes refl
- ≟ + = no λ()
+ ≟ - = no λ()
+ ≟ + = yes refl
-- The opposite sign.
opposite : Sign → Sign
opposite - = +
opposite + = -
-- "Multiplication".
infixl 7 _*_
_*_ : Sign → Sign → Sign
+ * s₂ = s₂
- * s₂ = opposite s₂
|
{
"alphanum_fraction": 0.5026041667,
"avg_line_length": 17.4545454545,
"ext": "agda",
"hexsha": "9eeaaef4216291a1f3777167cc42d08d78478d99",
"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/Sign.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/Sign.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Sign.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 204,
"size": 768
}
|
module RAdjunctions.RAdj2RMon where
open import Function
open import Relation.Binary.HeterogeneousEquality
open import Categories
open import Functors
open import RMonads
open import RAdjunctions
open Cat
open Fun
open RAdj
Adj2Mon : ∀{a b c d e f}{C : Cat {a}{b}}{D : Cat {c}{d}}{E : Cat {e}{f}}
{J : Fun C D} → RAdj J E → RMonad J
Adj2Mon {C = C}{D}{E}{J} A = record{
T = OMap (R A) ∘ OMap (L A);
η = left A (iden E);
bind = HMap (R A) ∘ right A;
law1 = trans (cong (HMap (R A)) (lawa A (iden E))) (fid (R A));
law2 = λ {_ _ f} →
trans (cong (comp D (HMap (R A) (right A f)))
(trans (sym (idr D))
(cong (comp D (left A (iden E))) (sym (fid J)))))
(trans (natleft A (iden C) (right A f) (iden E))
(trans (cong (left A)
(trans (cong (comp E (right A f))
(trans (idl E) (fid (L A))))
(idr E)))
(lawb A f)));
law3 = λ{_ _ _ f g} →
trans (cong (HMap (R A))
(trans (trans (cong (right A)
(cong (comp D (HMap (R A) (right A g)))
(trans (sym (idr D))
(cong (comp D f)
(sym (fid J))))))
(trans (natright A (iden C) (right A g) f)
(trans (sym (ass E))
(cong (comp E (comp E (right A g)
(right A f)))
(fid (L A))))))
(idr E)))
(fcomp (R A))}
|
{
"alphanum_fraction": 0.3668831169,
"avg_line_length": 41.0666666667,
"ext": "agda",
"hexsha": "b9828cad4aa42f8f605dcb524249543143e68d4d",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-11-04T21:33:13.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-11-04T21:33:13.000Z",
"max_forks_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "jmchapman/Relative-Monads",
"max_forks_repo_path": "RAdjunctions/RAdj2RMon.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865",
"max_issues_repo_issues_event_max_datetime": "2019-05-29T09:50:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-13T13:12:33.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "jmchapman/Relative-Monads",
"max_issues_repo_path": "RAdjunctions/RAdj2RMon.agda",
"max_line_length": 79,
"max_stars_count": 21,
"max_stars_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "jmchapman/Relative-Monads",
"max_stars_repo_path": "RAdjunctions/RAdj2RMon.agda",
"max_stars_repo_stars_event_max_datetime": "2021-02-13T18:02:18.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-07-30T01:25:12.000Z",
"num_tokens": 504,
"size": 1848
}
|
{-# OPTIONS --safe --postfix-projections #-}
module Cubical.Algebra.OrderedCommMonoid.PropCompletion where
{-
The completion of an ordered monoid, viewed as monoidal prop-enriched category.
This is used in the construction of the upper naturals, which is an idea of David
Jaz Myers presented here
https://felix-cherubini.de/myers-slides-II.pdf
It should be straight forward, but tedious,
to generalize this to enriched monoidal categories.
-}
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Function
open import Cubical.Foundations.Structure
open import Cubical.Foundations.HLevels
open import Cubical.Functions.Logic
open import Cubical.Functions.Embedding
open import Cubical.Data.Sigma
open import Cubical.HITs.PropositionalTruncation renaming (rec to propTruncRec; rec2 to propTruncRec2)
open import Cubical.Algebra.CommMonoid.Base
open import Cubical.Algebra.OrderedCommMonoid
open import Cubical.Relation.Binary.Poset
private
variable
ℓ : Level
module PropCompletion (ℓ : Level) (M : OrderedCommMonoid ℓ ℓ) where
open OrderedCommMonoidStr (snd M)
_≤p_ : fst M → fst M → hProp ℓ
n ≤p m = (n ≤ m) , (is-prop-valued _ _)
isUpwardClosed : (s : fst M → hProp ℓ) → Type _
isUpwardClosed s = (n m : fst M) → n ≤ m → fst (s n) → fst (s m)
isPropUpwardClosed : (N : fst M → hProp ℓ) → isProp (isUpwardClosed N)
isPropUpwardClosed N =
isPropΠ4 (λ _ m _ _ → snd (N m))
isSetM→Prop : isSet (fst M → hProp ℓ)
isSetM→Prop = isOfHLevelΠ 2 λ _ → isSetHProp
M↑ : Type _
M↑ = Σ[ s ∈ (fst M → hProp ℓ)] isUpwardClosed s
isSetM↑ : isSet M↑
isSetM↑ = isOfHLevelΣ 2 isSetM→Prop λ s → isOfHLevelSuc 1 (isPropUpwardClosed s)
_isUpperBoundOf_ : fst M → M↑ → Type ℓ
n isUpperBoundOf s = fst (fst s n)
isBounded : (s : M↑) → Type _
isBounded s = ∃[ m ∈ (fst M) ] (m isUpperBoundOf s)
isPropIsBounded : (s : M↑) → isProp (isBounded s)
isPropIsBounded s = isPropPropTrunc
_^↑ : fst M → M↑
n ^↑ = n ≤p_ , isUpwardClosed≤
where
isUpwardClosed≤ : {m : fst M} → isUpwardClosed (m ≤p_)
isUpwardClosed≤ = λ {_ _ n≤k m≤n → is-trans _ _ _ m≤n n≤k}
isBounded^ : (m : fst M) → isBounded (m ^↑)
isBounded^ m = ∣ (m , (is-refl m)) ∣₁
1↑ : M↑
1↑ = ε ^↑
_·↑_ : M↑ → M↑ → M↑
s ·↑ l = seq , seqIsUpwardClosed
where
seq : fst M → hProp ℓ
seq n = (∃[ (a , b) ∈ (fst M) × (fst M) ] fst ((fst s a) ⊓ (fst l b) ⊓ ((a · b) ≤p n) )) ,
isPropPropTrunc
seqIsUpwardClosed : isUpwardClosed seq
seqIsUpwardClosed n m n≤m =
propTruncRec
isPropPropTrunc
λ {((a , b) , wa , (wb , a·b≤n)) → ∣ (a , b) , wa , (wb , is-trans _ _ _ a·b≤n n≤m) ∣₁}
·presBounded : (s l : M↑) (bs : isBounded s) (bl : isBounded l) → isBounded (s ·↑ l)
·presBounded s l =
propTruncRec2
isPropPropTrunc
λ {(m , s≤m) (k , l≤k)
→ ∣ (m · k) , ∣ (m , k) , (s≤m , (l≤k , (is-refl (m · k)))) ∣₁ ∣₁
}
{- convenience functions for the proof that ·↑ is the multiplication of a monoid -}
typeAt : fst M → M↑ → Type _
typeAt n s = fst (fst s n)
M↑Path : {s l : M↑} → ((n : fst M) → typeAt n s ≡ typeAt n l) → s ≡ l
M↑Path {s = s} {l = l} pwPath = path
where
seqPath : fst s ≡ fst l
seqPath i n = subtypePathReflection (λ A → isProp A , isPropIsProp)
(fst s n)
(fst l n)
(pwPath n) i
path : s ≡ l
path = subtypePathReflection (λ s → isUpwardClosed s , isPropUpwardClosed s) s l seqPath
pathFromImplications : (s l : M↑)
→ ((n : fst M) → typeAt n s → typeAt n l)
→ ((n : fst M) → typeAt n l → typeAt n s)
→ s ≡ l
pathFromImplications s l s→l l→s =
M↑Path λ n → cong fst (propPath n)
where propPath : (n : fst M) → fst s n ≡ fst l n
propPath n = ⇒∶ s→l n
⇐∶ l→s n
^↑Pres· : (x y : fst M) → (x · y) ^↑ ≡ (x ^↑) ·↑ (y ^↑)
^↑Pres· x y = pathFromImplications ((x · y) ^↑) ((x ^↑) ·↑ (y ^↑)) (⇐) ⇒
where
⇐ : (n : fst M) → typeAt n ((x · y) ^↑) → typeAt n ((x ^↑) ·↑ (y ^↑))
⇐ n x·y≤n = ∣ (x , y) , ((is-refl _) , ((is-refl _) , x·y≤n)) ∣₁
⇒ : (n : fst M) → typeAt n ((x ^↑) ·↑ (y ^↑)) → typeAt n ((x · y) ^↑)
⇒ n = propTruncRec
(snd (fst ((x · y) ^↑) n))
λ {((m , l) , x≤m , (y≤l , m·l≤n))
→ is-trans _ _ _
(is-trans _ _ _ (MonotoneR x≤m)
(MonotoneL y≤l))
m·l≤n
}
·↑Comm : (s l : M↑) → s ·↑ l ≡ l ·↑ s
·↑Comm s l = M↑Path λ n → cong fst (propPath n)
where implication : (s l : M↑) (n : fst M) → fst (fst (s ·↑ l) n) → fst (fst (l ·↑ s) n)
implication s l n = propTruncRec
isPropPropTrunc
(λ {((a , b) , wa , (wb , a·b≤n))
→ ∣ (b , a) , wb , (wa , subst (λ k → fst (k ≤p n)) (·Comm a b) a·b≤n) ∣₁ })
propPath : (n : fst M) → fst (s ·↑ l) n ≡ fst (l ·↑ s) n
propPath n = ⇒∶ implication s l n
⇐∶ implication l s n
·↑Rid : (s : M↑) → s ·↑ 1↑ ≡ s
·↑Rid s = pathFromImplications (s ·↑ 1↑) s (⇒) ⇐
where ⇒ : (n : fst M) → typeAt n (s ·↑ 1↑) → typeAt n s
⇒ n = propTruncRec
(snd (fst s n))
(λ {((a , b) , sa , (1b , a·b≤n))
→ (snd s) a n ( subst (_≤ n) (·IdR a) (is-trans _ _ _ (MonotoneL 1b) a·b≤n)) sa })
⇐ : (n : fst M) → typeAt n s → typeAt n (s ·↑ 1↑)
⇐ n = λ sn → ∣ (n , ε) , (sn , (is-refl _ , subst (_≤ n) (sym (·IdR n)) (is-refl _))) ∣₁
·↑Assoc : (s l k : M↑) → s ·↑ (l ·↑ k) ≡ (s ·↑ l) ·↑ k
·↑Assoc s l k = pathFromImplications (s ·↑ (l ·↑ k)) ((s ·↑ l) ·↑ k) (⇒) ⇐
where ⇒ : (n : fst M) → typeAt n (s ·↑ (l ·↑ k)) → typeAt n ((s ·↑ l) ·↑ k)
⇒ n = propTruncRec
isPropPropTrunc
λ {((a , b) , sa , (l·kb , a·b≤n))
→ propTruncRec
isPropPropTrunc
(λ {((a' , b') , la' , (kb' , a'·b'≤b))
→ ∣ ((a · a') , b') , ∣ (a , a') , (sa , (la' , is-refl _)) ∣₁ , kb' ,
(let a·⟨a'·b'⟩≤n = (is-trans _ _ _ (MonotoneL a'·b'≤b) a·b≤n)
in subst (_≤ n) (·Assoc a a' b') a·⟨a'·b'⟩≤n) ∣₁
}) l·kb
}
⇐ : _
⇐ n = propTruncRec
isPropPropTrunc
λ {((a , b) , s·l≤a , (k≤b , a·b≤n))
→ propTruncRec
isPropPropTrunc
(λ {((a' , b') , s≤a' , (l≤b' , a'·b'≤a))
→ ∣ (a' , b' · b) , s≤a' , ( ∣ (b' , b) , l≤b' , (k≤b , is-refl _) ∣₁ ,
(let ⟨a'·b'⟩·b≤n = (is-trans _ _ _ (MonotoneR a'·b'≤a) a·b≤n)
in subst (_≤ n) (sym (·Assoc a' b' b)) ⟨a'·b'⟩·b≤n) ) ∣₁
}) s·l≤a
}
asCommMonoid : CommMonoid (ℓ-suc ℓ)
asCommMonoid = makeCommMonoid 1↑ _·↑_ isSetM↑ ·↑Assoc ·↑Rid ·↑Comm
{-
Poset structure on M↑
-}
_≤↑_ : (s l : M↑) → Type _
s ≤↑ l = (m : fst M) → fst ((fst l) m) → fst ((fst s) m)
isBounded→≤↑ : (s : M↑) → isBounded s → ∃[ m ∈ fst M ] (s ≤↑ (m ^↑))
isBounded→≤↑ s =
propTruncRec
isPropPropTrunc
λ {(m , mIsBound)
→ ∣ m , (λ n m≤n → snd s m n m≤n mIsBound) ∣₁
}
≤↑IsProp : (s l : M↑) → isProp (s ≤↑ l)
≤↑IsProp s l = isPropΠ2 (λ x p → snd (fst s x))
≤↑IsRefl : (s : M↑) → s ≤↑ s
≤↑IsRefl s = λ m x → x
≤↑IsTrans : (s l t : M↑) → s ≤↑ l → l ≤↑ t → s ≤↑ t
≤↑IsTrans s l t p q x = (p x) ∘ (q x)
≤↑IsAntisym : (s l : M↑) → s ≤↑ l → l ≤↑ s → s ≡ l
≤↑IsAntisym s l p q = pathFromImplications _ _ q p
{-
Compatability with the monoid structure
-}
·↑IsRMonotone : (l t s : M↑) → l ≤↑ t → (l ·↑ s) ≤↑ (t ·↑ s)
·↑IsRMonotone l t s p x =
propTruncRec
isPropPropTrunc
λ { ((a , b) , l≤a , (s≤b , a·b≤x)) → ∣ (a , b) , p a l≤a , s≤b , a·b≤x ∣₁}
·↑IsLMonotone : (l t s : M↑) → l ≤↑ t → (s ·↑ l) ≤↑ (s ·↑ t)
·↑IsLMonotone l t s p x =
propTruncRec
isPropPropTrunc
λ {((a , b) , s≤a , (l≤b , a·b≤x)) → ∣ (a , b) , s≤a , p b l≤b , a·b≤x ∣₁}
asOrderedCommMonoid : OrderedCommMonoid (ℓ-suc ℓ) ℓ
asOrderedCommMonoid .fst = _
asOrderedCommMonoid .snd .OrderedCommMonoidStr._≤_ = _≤↑_
asOrderedCommMonoid .snd .OrderedCommMonoidStr._·_ = _·↑_
asOrderedCommMonoid .snd .OrderedCommMonoidStr.ε = 1↑
asOrderedCommMonoid .snd .OrderedCommMonoidStr.isOrderedCommMonoid =
IsOrderedCommMonoidFromIsCommMonoid
(CommMonoidStr.isCommMonoid (snd asCommMonoid))
≤↑IsProp ≤↑IsRefl ≤↑IsTrans ≤↑IsAntisym ·↑IsRMonotone ·↑IsLMonotone
boundedSubstructure : OrderedCommMonoid (ℓ-suc ℓ) ℓ
boundedSubstructure =
makeOrderedSubmonoid
asOrderedCommMonoid
(λ s → (isBounded s , isPropIsBounded s))
·presBounded
(isBounded^ ε)
PropCompletion :
OrderedCommMonoid ℓ ℓ
→ OrderedCommMonoid (ℓ-suc ℓ) ℓ
PropCompletion M = PropCompletion.asOrderedCommMonoid _ M
BoundedPropCompletion :
OrderedCommMonoid ℓ ℓ
→ OrderedCommMonoid (ℓ-suc ℓ) ℓ
BoundedPropCompletion M = PropCompletion.boundedSubstructure _ M
isSetBoundedPropCompletion :
(M : OrderedCommMonoid ℓ ℓ)
→ isSet (⟨ BoundedPropCompletion M ⟩)
isSetBoundedPropCompletion M =
isSetΣSndProp (isSetOrderedCommMonoid (PropCompletion M))
λ x → PropCompletion.isPropIsBounded _ M x
|
{
"alphanum_fraction": 0.4996459998,
"avg_line_length": 37.0299625468,
"ext": "agda",
"hexsha": "1f9c315f17d0a0c68f36c8f50ec6076e9282a02f",
"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/OrderedCommMonoid/PropCompletion.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/OrderedCommMonoid/PropCompletion.agda",
"max_line_length": 107,
"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/OrderedCommMonoid/PropCompletion.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3847,
"size": 9887
}
|
-- Andreas, 2018-10-18, re issue #2757
--
-- Extracted this snippet from the standard library
-- as it caused problems during work in #2757
-- (runtime erasue using 0-quantity).
-- {-# OPTIONS -v tc.lhs.unify:65 -v tc.irr:50 #-}
open import Agda.Builtin.Size
data ⊥ : Set where
mutual
data Conat (i : Size) : Set where
zero : Conat i
suc : ∞Conat i → Conat i
record ∞Conat (i : Size) : Set where
coinductive
field force : ∀{j : Size< i} → Conat j
open ∞Conat
infinity : ∀ {i} → Conat i
infinity = suc λ where .force → infinity
data Finite : Conat ∞ → Set where
zero : Finite zero
suc : ∀ {n} → Finite (n .force) → Finite (suc n)
¬Finite∞ : Finite infinity → ⊥
¬Finite∞ (suc p) = ¬Finite∞ p
-- The problem was that the usableMod check in the
-- unifier (LHS.Unify) refuted this pattern match
-- because a runtime-erased argument ∞ (via meta-variable)
-- the the extended lambda.
|
{
"alphanum_fraction": 0.6567982456,
"avg_line_length": 24.6486486486,
"ext": "agda",
"hexsha": "224874210130a2017bf0e63e3c52acb8e5ee89cd",
"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/Conat-Sized.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/Conat-Sized.agda",
"max_line_length": 58,
"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/Conat-Sized.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": 302,
"size": 912
}
|
open import MJ.Types
open import MJ.Classtable
import MJ.Syntax as Syntax
import MJ.Semantics.Values as Values
--
-- Substitution-free interpretation of welltyped MJ
--
module MJ.Semantics.Functional {c} (Σ : CT c) (ℂ : Syntax.Impl Σ) where
open import Prelude
open import Data.Vec hiding (init)
open import Data.Vec.All.Properties.Extra as Vec∀++
open import Data.Sum
open import Data.List as List
open import Data.List.All as List∀ hiding (lookup)
open import Data.List.All.Properties.Extra
open import Data.List.Any
open import Data.List.Prefix
open import Data.List.Properties.Extra as List+
open import Data.Maybe as Maybe using (Maybe; just; nothing)
open import Relation.Binary.PropositionalEquality
open import Data.Star.Indexed
import Data.Vec.All as Vec∀
open Membership-≡
open Values Σ
open CT Σ
open Syntax Σ
-- open import MJ.Semantics.Objects.Hierarchical Σ ℂ using (encoding)
open import MJ.Semantics.Objects.Flat Σ ℂ using (encoding)
open ObjEncoding encoding
open Heap encoding
⊒-res : ∀ {a}{I : World c → Set a}{W W'} → W' ⊒ W → Res I W' → Res I W
⊒-res {W = W} p (W' , ext' , μ' , v) = W' , ⊑-trans p ext' , μ' , v
mutual
--
-- object initialization
--
init : ∀ {W} cid → Cont (fromList (Class.constr (clookup cid))) (λ W → Obj W cid) W
init cid E μ with Impl.bodies ℂ cid
init cid E μ | impl super-args defs with evalₙ (defs FLD) E μ
... | W₁ , ext₁ , μ₁ , vs with clookup cid | inspect clookup cid
-- case *without* super initialization
init cid E μ | impl nothing defs | (W₁ , ext₁ , μ₁ , vs) | (class nothing constr decls) | [ eq ] =
W₁ , ext₁ , μ₁ , vs
-- case *with* super initialization
init cid E μ | impl (just sc) defs | (W₁ , ext₁ , μ₁ , vs) |
(class (just x) constr decls) | [ eq ] with evalₑ-all sc (Vec∀.map (coerce ext₁) E) μ₁
... | W₂ , ext₂ , μ₂ , svs with init x (all-fromList svs) μ₂
... | W₃ , ext₃ , μ₃ , inherited = W₃ , ⊑-trans (⊑-trans ext₁ ext₂) ext₃ , μ₃ ,
(List∀.map (coerce (⊑-trans ext₂ ext₃)) vs ++-all inherited)
{-}
init cid E μ with Impl.bodies ℂ cid
init cid E μ | impl super-args defs with evalₙ (defs FLD) E μ
... | W₁ , ext₁ , μ₁ , vs with clookup cid | inspect clookup cid
-- case *without* super initialization
init cid E μ | impl nothing defs | (W₁ , ext₁ , μ₁ , vs) |
(class nothing constr decls) | [ eq ] =
, ext₁
, μ₁
, record {
own = λ{
MTH → List∀.tabulate (λ _ → tt) ;
FLD → subst (λ C → All _ (Class.decls C FLD)) (sym eq) vs
};
inherited = subst (λ C → Maybe.All _ (Class.parent C)) (sym eq) nothing
}
-- case *with* super initialization
init cid E μ | impl (just sc) defs | (W₁ , ext₁ , μ₁ , vs) |
(class (just x) constr decls) | [ eq ] with evalₑ-all sc (Vec∀.map (coerce ext₁) E) μ₁
... | W₂ , ext₂ , μ₂ , svs with init x (all-fromList svs) μ₂
... | W₃ , ext₃ , μ₃ , sO =
, ⊑-trans (⊑-trans ext₁ ext₂) ext₃
, μ₃
, record {
own = λ{
MTH → List∀.tabulate (λ _ → tt) ;
FLD → subst
(λ C → All _ (Class.decls C FLD))
(sym eq)
(List∀.map (coerce (⊑-trans ext₂ ext₃)) vs)
};
inherited = subst (λ C → Maybe.All _ (Class.parent C)) (sym eq) (just sO)
}
-}
evalₑ-all : ∀ {n}{Γ : Ctx c n}{as} →
All (Expr Γ) as → ∀ {W} → Cont Γ (λ W' → All (Val W') as) W
evalₑ-all [] E μ = , ⊑-refl , μ , []
evalₑ-all (px ∷ exps) E μ with evalₑ px E μ
... | W' , ext' , μ' , v with evalₑ-all exps (Vec∀.map (coerce ext') E) μ'
... | W'' , ext'' , μ'' , vs = W'' , ⊑-trans ext' ext'' , μ'' , coerce ext'' v ∷ vs
--
-- evaluation of expressions
--
{-# TERMINATING #-}
evalₑ : ∀ {n}{Γ : Ctx c n}{a} → Expr Γ a → ∀ {W} → Cont Γ (flip Val a) W
evalₑ (upcast sub e) E μ with evalₑ e E μ
... | W' , ext' , μ' , (ref r s) = W' , ext' , μ' , ref r (<:-trans s sub)
-- primitive values
evalₑ unit = pure (const unit)
evalₑ (num n) = pure (const (num n))
-- variable lookup
evalₑ (var i) = pure (λ E → Vec∀.lookup i E)
-- object allocation
evalₑ (new C args) {W} E μ with evalₑ-all args E μ
-- create the object, typed under the current heap shape
... | W₁ , ext₁ , μ₁ , vs with init C (all-fromList vs) μ₁
... | W₂ , ext₂ , μ₂ , O =
let
-- extension fact for the heap extended with the new object allocation
ext = ∷ʳ-⊒ (obj C) W₂
in
, ⊑-trans (⊑-trans ext₁ ext₂) ext
, all-∷ʳ (List∀.map (coerce ext) μ₂) (coerce ext (obj C O))
, ref (∈-∷ʳ W₂ (obj C)) refl -- value typed under the extended heap
-- binary interger operations
evalₑ (iop f l r) E μ with evalₑ l E μ
... | W₁ , ext₁ , μ₁ , (num i) with evalₑ r (Vec∀.map (coerce ext₁) E) μ₁
... | W₂ , ext₂ , μ₂ , (num j) = W₂ , ⊑-trans ext₁ ext₂ , μ₂ , num (f i j)
-- method calls
evalₑ (call {C} e mtd args) E μ with evalₑ e E μ -- eval obj expression
... | W₁ , ext₁ , μ₁ , r@(ref o sub) with ∈-all o μ₁ -- lookup obj on the heap
... | val ()
... | obj cid O with evalₑ-all args (Vec∀.map (coerce ext₁) E) μ₁ -- eval arguments
... | W₂ , ext₂ , μ₂ , vs =
-- and finally eval the body of the method under the environment
-- generated from the call arguments and the object's "this"
⊒-res
(⊑-trans ext₁ ext₂)
(eval-body cmd (ref (∈-⊒ o ext₂) <:-fact Vec∀.∷ all-fromList vs) μ₂)
where
-- get the method definition
cmd = getDef C mtd ℂ
-- get a subtyping fact
<:-fact = <:-trans sub (proj₁ (proj₂ mtd))
-- field lookup in the heap
evalₑ (get e fld) E μ with evalₑ e E μ
... | W' , ext' , μ' , ref o C<:C₁ with ∈-all o μ'
... | (val ())
-- apply the runtime subtyping fact to weaken the member fact
... | obj cid O = W' , ext' , μ' , getter O (mem-inherit Σ C<:C₁ fld)
--
-- command evaluation
--
evalc : ∀ {n m}{I : Ctx c n}{O : Ctx c m}{W : World c}{a} →
-- we use a sum for abrupt returns
Cmd I a O → Cont I (λ W → (Val W a) ⊎ (Env O W)) W
-- new locals variable
evalc (loc x e) E μ with evalₑ e E μ
... | W₁ , ext₁ , μ₁ , v = W₁ , ext₁ , μ₁ , inj₂ (v Vec∀.∷ (Vec∀.map (coerce ext₁) E))
-- assigning to a local
evalc (asgn i x) E μ with evalₑ x E μ
... | W₁ , ext₁ , μ₁ , v = W₁ , ext₁ , μ₁ , inj₂ (Vec∀.map (coerce ext₁) E Vec∀++.[ i ]≔ v)
-- setting a field
-- start by lookuping up the referenced object on the heap & eval the expression to assign it
evalc (set rf fld e) E μ with evalₑ rf E μ
... | W₁ , ext₁ , μ₁ , ref p s with List∀.lookup μ₁ p | evalₑ e (Vec∀.map (coerce ext₁) E) μ₁
... | (val ()) | _
... | (obj cid O) | (W₂ , ext₂ , μ₂ , v) = let ext = ⊑-trans ext₁ ext₂ in
, ext
, (μ₂ All[ ∈-⊒ p ext₂ ]≔' -- update the store at the reference location
-- update the object at the member location
obj cid (
setter (coerce ext₂ O) (mem-inherit Σ s fld) v
)
)
, (inj₂ $ Vec∀.map (coerce ext) E)
-- side-effectful expressions
evalc (do x) E μ with evalₑ x E μ
... | W₁ , ext₁ , μ₁ , _ = W₁ , ext₁ , μ₁ , inj₂ (Vec∀.map (coerce ext₁) E)
-- early returns
evalc (ret x) E μ with evalₑ x E μ
... | W₁ , ext₁ , μ₁ , v = W₁ , ext₁ , μ₁ , inj₁ v
eval-body : ∀ {n}{I : Ctx c n}{W : World c}{a} → Body I a → Cont I (λ W → Val W a) W
eval-body (body ε re) E μ = evalₑ re E μ
eval-body (body (x ◅ xs) re) E μ with evalc x E μ
... | W₁ , ext₁ , μ₁ , inj₂ E₁ = ⊒-res ext₁ (eval-body (body xs re) E₁ μ₁)
... | W₁ , ext₁ , μ₁ , inj₁ v = _ , ext₁ , μ₁ , v
evalₙ : ∀ {n}{I : Ctx c n}{W : World c}{as} → All (Body I) as →
Cont I (λ W → All (Val W) as) W
evalₙ [] E μ = , ⊑-refl , μ , []
evalₙ (px ∷ bs) E μ with eval-body px E μ
... | W₁ , ext₁ , μ₁ , v with evalₙ bs (Vec∀.map (coerce ext₁) E) μ₁
... | W₂ , ext₂ , μ₂ , vs = W₂ , ⊑-trans ext₁ ext₂ , μ₂ , coerce ext₂ v ∷ vs
eval : ∀ {a} → Prog a → ∃ λ W → Store W × Val W a
eval (lib , main) with eval-body main Vec∀.[] []
... | W , ext , μ , v = W , μ , v
|
{
"alphanum_fraction": 0.5696170747,
"avg_line_length": 35.7174887892,
"ext": "agda",
"hexsha": "d498dd5e7ae81bd30a199a8d7cfcc6e110e2bb63",
"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/Semantics/Functional.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/Semantics/Functional.agda",
"max_line_length": 100,
"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/Semantics/Functional.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": 3009,
"size": 7965
}
|
{-# OPTIONS --allow-unsolved-metas #-}
module LiteralFormula where
open import OscarPrelude
open import IsLiteralFormula
open import HasNegation
open import Formula
record LiteralFormula : Set
where
constructor ⟨_⟩
field
{formula} : Formula
isLiteralFormula : IsLiteralFormula formula
open LiteralFormula public
instance EqLiteralFormula : Eq LiteralFormula
Eq._==_ EqLiteralFormula (⟨_⟩ {φ₁} lf₁) (⟨_⟩ {φ₂} lf₂)
with φ₁ ≟ φ₂
… | no φ₁≢φ₂ = no (λ {refl → φ₁≢φ₂ refl})
Eq._==_ EqLiteralFormula (⟨_⟩ {φ₁} lf₁) (⟨_⟩ {φ₂} lf₂) | yes refl = case (eqIsLiteralFormula lf₁ lf₂) of λ {refl → yes refl}
instance HasNegationLiteralFormula : HasNegation LiteralFormula
HasNegation.~ HasNegationLiteralFormula ⟨ atomic 𝑃 τs ⟩ = ⟨ logical 𝑃 τs ⟩
HasNegation.~ HasNegationLiteralFormula ⟨ logical 𝑃 τs ⟩ = ⟨ atomic 𝑃 τs ⟩
open import Interpretation
open import Vector
open import Term
open import Elements
open import TruthValue
module _ where
open import HasSatisfaction
instance HasSatisfactionLiteralFormula : HasSatisfaction LiteralFormula
HasSatisfaction._⊨_ HasSatisfactionLiteralFormula I ⟨ atomic 𝑃 τs ⟩ = 𝑃⟦ I ⟧ 𝑃 ⟨ ⟨ τ⟦ I ⟧ <$> vector (terms τs) ⟩ ⟩ ≡ ⟨ true ⟩
HasSatisfaction._⊨_ HasSatisfactionLiteralFormula I ⟨ logical 𝑃 τs ⟩ = 𝑃⟦ I ⟧ 𝑃 ⟨ ⟨ τ⟦ I ⟧ <$> vector (terms τs) ⟩ ⟩ ≡ ⟨ false ⟩
instance HasDecidableSatisfactionLiteralFormula : HasDecidableSatisfaction LiteralFormula
HasDecidableSatisfaction._⊨?_ HasDecidableSatisfactionLiteralFormula
I ⟨ atomic 𝑃 τs ⟩
with 𝑃⟦ I ⟧ 𝑃 ⟨ ⟨ τ⟦ I ⟧ <$> vector (terms τs) ⟩ ⟩
… | ⟨ true ⟩ = yes refl
… | ⟨ false ⟩ = no λ ()
HasDecidableSatisfaction._⊨?_ HasDecidableSatisfactionLiteralFormula
I ⟨ logical 𝑃 τs ⟩
with 𝑃⟦ I ⟧ 𝑃 ⟨ ⟨ τ⟦ I ⟧ <$> vector (terms τs) ⟩ ⟩
… | ⟨ true ⟩ = no λ ()
… | ⟨ false ⟩ = yes refl
instance HasDecidableValidationLiteralFormula : HasDecidableValidation LiteralFormula
HasDecidableValidation.⊨? HasDecidableValidationLiteralFormula = {!!}
module _ where
open import HasSubstantiveDischarge
postulate
instance cs' : CanonicalSubstitution LiteralFormula
instance hpu' : HasPairUnification LiteralFormula (CanonicalSubstitution.S cs')
instance HasSubstantiveDischargeLiteralFormula : HasSubstantiveDischarge LiteralFormula
--HasSubstantiveDischarge._o≽o_ HasSubstantiveDischargeLiteralFormula φ₁ φ₂ = φ₁ ≡ φ₂
HasSubstantiveDischarge.hasNegation HasSubstantiveDischargeLiteralFormula = it
HasSubstantiveDischarge.≽-reflexive HasSubstantiveDischargeLiteralFormula = {!!}
HasSubstantiveDischarge.≽-consistent HasSubstantiveDischargeLiteralFormula = {!!}
HasSubstantiveDischarge.≽-contrapositive HasSubstantiveDischargeLiteralFormula = {!!}
instance HasDecidableSubstantiveDischargeLiteralFormula : HasDecidableSubstantiveDischarge LiteralFormula
HasDecidableSubstantiveDischarge.hasSubstantiveDischarge HasDecidableSubstantiveDischargeLiteralFormula = it
HasDecidableSubstantiveDischarge._≽?_ HasDecidableSubstantiveDischargeLiteralFormula φ+ φ- = {!!} -- φ+ ≟ φ-
|
{
"alphanum_fraction": 0.7626446281,
"avg_line_length": 39.8026315789,
"ext": "agda",
"hexsha": "bf05023c154ed1b6778752f63b9cf166ec0fd933",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_forks_repo_licenses": [
"RSA-MD"
],
"max_forks_repo_name": "m0davis/oscar",
"max_forks_repo_path": "archive/agda-1/LiteralFormula.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z",
"max_issues_repo_licenses": [
"RSA-MD"
],
"max_issues_repo_name": "m0davis/oscar",
"max_issues_repo_path": "archive/agda-1/LiteralFormula.agda",
"max_line_length": 130,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_stars_repo_licenses": [
"RSA-MD"
],
"max_stars_repo_name": "m0davis/oscar",
"max_stars_repo_path": "archive/agda-1/LiteralFormula.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 961,
"size": 3025
}
|
{-# OPTIONS --cubical --safe #-}
module Cubical.Foundations.Bundle where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.Fibration
open import Cubical.Foundations.Structure
open import Cubical.Structures.TypeEqvTo
open import Cubical.Data.Sigma.Properties
open import Cubical.HITs.PropositionalTruncation
module _ {ℓb ℓf} {B : Type ℓb} {F : Type ℓf} {ℓ} where
{-
A fiber bundle with base space B and fibers F is a map `p⁻¹ : B → TypeEqvTo F`
taking points in the base space to their respective fibers.
e.g. a double cover is a map `B → TypeEqvTo Bool`
-}
Total : (p⁻¹ : B → TypeEqvTo ℓ F) → Type (ℓ-max ℓb ℓ)
Total p⁻¹ = Σ[ x ∈ B ] p⁻¹ x .fst
pr : (p⁻¹ : B → TypeEqvTo ℓ F) → Total p⁻¹ → B
pr p⁻¹ = fst
inc : (p⁻¹ : B → TypeEqvTo ℓ F) (x : B) → p⁻¹ x .fst → Total p⁻¹
inc p⁻¹ x = (x ,_)
fibPrEquiv : (p⁻¹ : B → TypeEqvTo ℓ F) (x : B) → fiber (pr p⁻¹) x ≃ p⁻¹ x .fst
fibPrEquiv p⁻¹ x = fiberEquiv (λ x → typ (p⁻¹ x)) x
module _ {ℓb ℓf} (B : Type ℓb) (ℓ : Level) (F : Type ℓf) where
private
ℓ' = ℓ-max ℓb ℓ
{-
Equivalently, a fiber bundle with base space B and fibers F is a type E and
a map `p : E → B` with fibers merely equivalent to F.
-}
bundleEquiv : (B → TypeEqvTo ℓ' F) ≃ (Σ[ E ∈ Type ℓ' ] Σ[ p ∈ (E → B) ] ∀ x → ∥ fiber p x ≃ F ∥)
bundleEquiv = compEquiv (compEquiv PiΣ (pathToEquiv p)) assocΣ
where e = fibrationEquiv B ℓ
p : (Σ[ p⁻¹ ∈ (B → Type ℓ') ] ∀ x → ∥ p⁻¹ x ≃ F ∥)
≡ (Σ[ p ∈ (Σ[ E ∈ Type ℓ' ] (E → B)) ] ∀ x → ∥ fiber (snd p) x ≃ F ∥ )
p i = Σ[ q ∈ ua e (~ i) ] ∀ x → ∥ ua-unglue e (~ i) q x ≃ F ∥
|
{
"alphanum_fraction": 0.5950317735,
"avg_line_length": 33.9411764706,
"ext": "agda",
"hexsha": "b9b15de0cf009161f3d00561c3aba4b6b801a405",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "borsiemir/cubical",
"max_forks_repo_path": "Cubical/Foundations/Bundle.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "borsiemir/cubical",
"max_issues_repo_path": "Cubical/Foundations/Bundle.agda",
"max_line_length": 98,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "borsiemir/cubical",
"max_stars_repo_path": "Cubical/Foundations/Bundle.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 718,
"size": 1731
}
|
module Generic.Property.Reify where
open import Generic.Core
data ExplView : Visibility -> Set where
yes-expl : ExplView expl
no-expl : ∀ {v} -> ExplView v
explView : ∀ v -> ExplView v
explView expl = yes-expl
explView v = no-expl
ExplMaybe : ∀ {α} -> Visibility -> Set α -> Set α
ExplMaybe v A with explView v
... | yes-expl = A
... | no-expl = ⊤
caseExplMaybe : ∀ {α π} {A : Set α} (P : Visibility -> Set π)
-> (A -> P expl) -> (∀ {v} -> P v) -> ∀ v -> ExplMaybe v A -> P v
caseExplMaybe P f y v x with explView v
... | yes-expl = f x
... | no-expl = y
Prod : ∀ {α} β -> Visibility -> Set α -> Set (α ⊔ β) -> Set (α ⊔ β)
Prod β v A B with explView v
... | yes-expl = A × B
... | no-expl = B
uncurryProd : ∀ {α β γ} {A : Set α} {B : Set (α ⊔ β)} {C : Set γ} v
-> Prod β v A B -> (ExplMaybe v A -> B -> C) -> C
uncurryProd v p g with explView v | p
... | yes-expl | (x , y) = g x y
... | no-expl | y = g tt y
SemReify : ∀ {i β} {I : Set i} -> Desc I β -> Set
SemReify (var i) = ⊤
SemReify (π i q C) = ⊥
SemReify (D ⊛ E) = SemReify D × SemReify E
mutual
ExtendReify : ∀ {i β} {I : Set i} -> Desc I β -> Set β
ExtendReify (var i) = ⊤
ExtendReify (π i q C) = ExtendReifyᵇ i C q
ExtendReify (D ⊛ E) = SemReify D × ExtendReify E
ExtendReifyᵇ : ∀ {ι α β γ q} {I : Set ι} i -> Binder α β γ i q I -> α ≤ℓ β -> Set β
ExtendReifyᵇ {β = β} i (coerce (A , D)) q = Coerce′ q $
Prod β (visibility i) (Reify A) (∀ {x} -> ExtendReify (D x))
-- Can't reify an irrelevant thing into its relevant representation.
postulate
reifyᵢ : ∀ {α} {A : Set α} {{aReify : Reify A}} -> .A -> Term
instance
{-# TERMINATING #-}
DataReify : ∀ {i β} {I : Set i} {D : Data (Desc I β)} {j}
{{reD : All ExtendReify (consTypes D)}} -> Reify (μ D j)
DataReify {ι} {β} {I} {D₀} = record { reify = reifyMu } where
mutual
reifySem : ∀ D {{reD : SemReify D}} -> ⟦ D ⟧ (μ D₀) -> Term
reifySem (var i) d = reifyMu d
reifySem (π i q C) {{()}}
reifySem (D ⊛ E) {{reD , reE}} (x , y) =
sate _,_ (reifySem D {{reD}} x) (reifySem E {{reE}} y)
reifyExtend : ∀ {j} D {{reD : ExtendReify D}} -> Extend D (μ D₀) j -> List Term
reifyExtend (var i) lrefl = []
reifyExtend (π i q C) p = reifyExtendᵇ i C q p
reifyExtend (D ⊛ E) {{reD , reE}} (x , e) =
reifySem D {{reD}} x ∷ reifyExtend E {{reE}} e
reifyExtendᵇ : ∀ {α γ q j} i (C : Binder α β γ i q I) q′ {{reC : ExtendReifyᵇ i C q′}}
-> Extendᵇ i C q′ (μ D₀) j -> List Term
reifyExtendᵇ i (coerce (A , D)) q {{reC}} p =
uncurryProd (visibility i) (uncoerce′ q reC) λ mreA reD -> split q p λ x e ->
let es = reifyExtend (D x) {{reD}} e in
caseExplMaybe _ (λ reA -> elimRelValue _ (reify {{reA}}) (reifyᵢ {{reA}}) x ∷ es)
es
(visibility i)
mreA
reifyDesc : ∀ {j} D {{reD : ExtendReify D}} -> Name -> Extend D (μ D₀) j -> Term
reifyDesc D n e = vis appCon n (reifyExtend D e)
reifyAny : ∀ {j} (Ds : List (Desc I β)) {{reD : All ExtendReify Ds}}
-> ∀ d a b ns -> Node D₀ (packData d a b Ds ns) j -> Term
reifyAny [] d a b tt ()
reifyAny (D ∷ []) {{reD , _}} d a b (n , ns) e = reifyDesc D {{reD}} n e
reifyAny (D ∷ E ∷ Ds) {{reD , reDs}} d a b (n , ns) (inj₁ e) = reifyDesc D {{reD}} n e
reifyAny (D ∷ E ∷ Ds) {{reD , reDs}} d a b (n , ns) (inj₂ r) =
reifyAny (E ∷ Ds) {{reDs}} d a b ns r
reifyMu : ∀ {j} -> μ D₀ j -> Term
reifyMu (node e) = reifyAny (consTypes D₀)
(dataName D₀)
(parsTele D₀)
(indsTele D₀)
(consNames D₀)
e
|
{
"alphanum_fraction": 0.4781304674,
"avg_line_length": 40.01,
"ext": "agda",
"hexsha": "a370ad0ff28f4b60678f3de32caf5fcce8edbd67",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2021-01-27T12:57:09.000Z",
"max_forks_repo_forks_event_min_datetime": "2017-07-17T07:23:39.000Z",
"max_forks_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "turion/Generic",
"max_forks_repo_path": "src/Generic/Property/Reify.agda",
"max_issues_count": 9,
"max_issues_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe",
"max_issues_repo_issues_event_max_datetime": "2022-01-04T15:43:14.000Z",
"max_issues_repo_issues_event_min_datetime": "2017-04-06T18:58:09.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "turion/Generic",
"max_issues_repo_path": "src/Generic/Property/Reify.agda",
"max_line_length": 93,
"max_stars_count": 30,
"max_stars_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "turion/Generic",
"max_stars_repo_path": "src/Generic/Property/Reify.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T10:19:38.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-07-19T21:10:54.000Z",
"num_tokens": 1489,
"size": 4001
}
|
module Issue1760g where
data ⊥ : Set where
{-# NO_POSITIVITY_CHECK #-}
{-# NON_TERMINATING #-}
mutual
record U : Set where
constructor roll
field ap : U → U
lemma : U → ⊥
lemma (roll u) = lemma (u (roll u))
bottom : ⊥
bottom = lemma (roll λ x → x)
|
{
"alphanum_fraction": 0.5948905109,
"avg_line_length": 16.1176470588,
"ext": "agda",
"hexsha": "ef04ee4da2b2cf472d7d6110e0b7e8bce9e3d754",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Succeed/Issue1760g.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "hborum/agda",
"max_issues_repo_path": "test/Succeed/Issue1760g.agda",
"max_line_length": 37,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "hborum/agda",
"max_stars_repo_path": "test/Succeed/Issue1760g.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": 88,
"size": 274
}
|
{-# OPTIONS --without-K --safe #-}
open import Algebra.Structures.Bundles.Field
module Algebra.Linear.Morphism.VectorSpace
{k ℓᵏ} (K : Field k ℓᵏ)
where
open import Level
open import Algebra.FunctionProperties as FP
import Algebra.Linear.Morphism.Definitions as LinearMorphismDefinitions
import Algebra.Morphism as Morphism
open import Relation.Binary using (Rel; Setoid)
open import Relation.Binary.Morphism.Structures
open import Algebra.Morphism
open import Algebra.Linear.Core
open import Algebra.Linear.Structures.VectorSpace K
open import Algebra.Linear.Structures.Bundles
module LinearDefinitions {a₁ a₂ ℓ₂} (A : Set a₁) (B : Set a₂) (_≈_ : Rel B ℓ₂) where
open Morphism.Definitions A B _≈_ public
open LinearMorphismDefinitions K A B _≈_ public
module _
{a₁ ℓ₁} (From : VectorSpace K a₁ ℓ₁)
{a₂ ℓ₂} (To : VectorSpace K a₂ ℓ₂)
where
private
module F = VectorSpace From
module T = VectorSpace To
K' : Set k
K' = Field.Carrier K
open F using () renaming (Carrier to A; _≈_ to _≈₁_; _+_ to _+₁_; _∙_ to _∙₁_)
open T using () renaming (Carrier to B; _≈_ to _≈₂_; _+_ to _+₂_; _∙_ to _∙₂_)
open import Function
open LinearDefinitions (VectorSpace.Carrier From) (VectorSpace.Carrier To) _≈₂_
record IsLinearMap (⟦_⟧ : Morphism) : Set (k ⊔ a₁ ⊔ a₂ ⊔ ℓ₁ ⊔ ℓ₂) where
field
isAbelianGroupMorphism : IsAbelianGroupMorphism F.abelianGroup T.abelianGroup ⟦_⟧
∙-homo : ScalarHomomorphism ⟦_⟧ _∙₁_ _∙₂_
open IsAbelianGroupMorphism isAbelianGroupMorphism public
renaming (∙-homo to +-homo; ε-homo to 0#-homo)
distrib-linear : ∀ (a b : K') (u v : A) -> ⟦ a ∙₁ u +₁ b ∙₁ v ⟧ ≈₂ a ∙₂ ⟦ u ⟧ +₂ b ∙₂ ⟦ v ⟧
distrib-linear a b u v = T.trans (+-homo (a ∙₁ u) (b ∙₁ v)) (T.+-cong (∙-homo a u) (∙-homo b v))
record IsLinearMonomorphism (⟦_⟧ : Morphism) : Set (k ⊔ a₁ ⊔ a₂ ⊔ ℓ₁ ⊔ ℓ₂) where
field
isLinearMap : IsLinearMap ⟦_⟧
injective : Injective _≈₁_ _≈₂_ ⟦_⟧
open IsLinearMap isLinearMap public
record IsLinearIsomorphism (⟦_⟧ : Morphism) : Set (k ⊔ a₁ ⊔ a₂ ⊔ ℓ₁ ⊔ ℓ₂) where
field
isLinearMonomorphism : IsLinearMonomorphism ⟦_⟧
surjective : Surjective _≈₁_ _≈₂_ ⟦_⟧
open IsLinearMonomorphism isLinearMonomorphism public
module _
{a ℓ} (V : VectorSpace K a ℓ)
where
open VectorSpace V
open LinearDefinitions Carrier Carrier _≈_
IsLinearEndomorphism : Morphism -> Set (k ⊔ a ⊔ ℓ)
IsLinearEndomorphism ⟦_⟧ = IsLinearMap V V ⟦_⟧
IsLinearAutomorphism : Morphism -> Set (k ⊔ a ⊔ ℓ)
IsLinearAutomorphism ⟦_⟧ = IsLinearIsomorphism V V ⟦_⟧
|
{
"alphanum_fraction": 0.6839258114,
"avg_line_length": 31.5609756098,
"ext": "agda",
"hexsha": "b45d42badcf6e0c9c0e82b96bdd5f641e7650820",
"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": "d87c5a1eb5dd0569238272e67bce1899616b789a",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "felko/linear-algebra",
"max_forks_repo_path": "src/Algebra/Linear/Morphism/VectorSpace.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a",
"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": "felko/linear-algebra",
"max_issues_repo_path": "src/Algebra/Linear/Morphism/VectorSpace.agda",
"max_line_length": 100,
"max_stars_count": 15,
"max_stars_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "felko/linear-algebra",
"max_stars_repo_path": "src/Algebra/Linear/Morphism/VectorSpace.agda",
"max_stars_repo_stars_event_max_datetime": "2020-12-30T06:18:08.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-11-02T14:11:00.000Z",
"num_tokens": 953,
"size": 2588
}
|
module helloworld where
open import IO
main = run (putStrLn "Hello World")
|
{
"alphanum_fraction": 0.7631578947,
"avg_line_length": 15.2,
"ext": "agda",
"hexsha": "888b18f62b4d08c865b1ad8c17ed67a645e5ec2f",
"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": "e410da7ee2b55e078aa53325a10f0f4ff0372566",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "P3trur0/vagrant-agda",
"max_forks_repo_path": "src/helloworld.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e410da7ee2b55e078aa53325a10f0f4ff0372566",
"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": "P3trur0/vagrant-agda",
"max_issues_repo_path": "src/helloworld.agda",
"max_line_length": 35,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "e410da7ee2b55e078aa53325a10f0f4ff0372566",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "P3trur0/vagrant-agda",
"max_stars_repo_path": "src/helloworld.agda",
"max_stars_repo_stars_event_max_datetime": "2018-04-09T19:56:39.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-04-09T19:56:39.000Z",
"num_tokens": 19,
"size": 76
}
|
{-# OPTIONS --without-K #-}
module hott.types where
open import hott.types.nat public
open import hott.types.coproduct public
|
{
"alphanum_fraction": 0.7578125,
"avg_line_length": 18.2857142857,
"ext": "agda",
"hexsha": "92967ca54ed23ee0ccd5082dc949a2049dbefcb5",
"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": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "piyush-kurur/hott",
"max_forks_repo_path": "agda/hott/types.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc",
"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": "piyush-kurur/hott",
"max_issues_repo_path": "agda/hott/types.agda",
"max_line_length": 39,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "piyush-kurur/hott",
"max_stars_repo_path": "agda/hott/types.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 28,
"size": 128
}
|
module README where
----------------------------------------------------------------------
-- The Agda smallib library, version 0.1
----------------------------------------------------------------------
--
-- This library implements a type theory which is described in the
-- Appendix of the HoTT book. It also contains some properties derived
-- from the rules of this theory.
----------------------------------------------------------------------
--
-- This project is meant to be a practice for the author but as a
-- secondary goal it would be nice to create a small library which is
-- less intimidating than the standard one.
--
-- This version was tested using Agda 2.6.1.
----------------------------------------------------------------------
----------------------------------------------------------------------
-- High-level overview of contents
----------------------------------------------------------------------
--
-- The top-level module L is not implemented (yet), it's sole purpose
-- is to prepend all of the module names with something to avoid
-- possible name clashes with the standard library.
--
-- The structure of the library is the following:
--
-- • Base
-- The derivation rules of the implemented type theory and some
-- useful properties which can be derived from these. To make a
-- clear distinction between these every type has a Core and a
-- Properties submodule. In some cases the latter might be empty.
--
-- • Data
-- ◦ Bool
-- A specialized form of the Coproduct type. It implements if as
-- an elimination rule. The following operations are defined on
-- them: not, ∧, ∨, xor.
----------------------------------------------------------------------
----------------------------------------------------------------------
-- Some useful modules
----------------------------------------------------------------------
--
-- • To use several things at once
import L.Base -- Type theory with it's properties.
import L.Base.Core -- Derivation rules.
--
-- • To use only one base type
import L.Base.Sigma -- Products (universe polymorphic).
import L.Base.Coproduct -- Disjoint sums (universe polymorphic).
import L.Base.Empty -- Empty type.
import L.Base.Unit -- Unit type.
import L.Base.Nat -- Natural numbers.
import L.Base.Id -- Propositional equality (universe poly.).
--
-- • To use the properties of the above
import L.Base.Sigma.Properties
import L.Base.Coproduct.Properties
import L.Base.Empty.Properties
import L.Base.Unit.Properties
import L.Base.Nat.Properties
import L.Base.Id.Properties
--
-- • Some datatypes
import L.Data.Bool -- Booleans.
----------------------------------------------------------------------
----------------------------------------------------------------------
-- Notes
----------------------------------------------------------------------
--
-- • L.Base exports L.Coproduct.Core._+_ as _⊎_ to avoid multiple
-- definitions of _+_, as L.Base.Nat declares it as well.
----------------------------------------------------------------------
|
{
"alphanum_fraction": 0.5001629195,
"avg_line_length": 39.8571428571,
"ext": "agda",
"hexsha": "0ce4cbd781e87043acb5b4a30ef03828845d232c",
"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": "83707537b182ba8906228ac0bcb9ccef972eaaa3",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "borszag/smallib",
"max_forks_repo_path": "README.agda",
"max_issues_count": 10,
"max_issues_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3",
"max_issues_repo_issues_event_max_datetime": "2020-11-09T16:40:39.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-10-19T10:13:16.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "borszag/smallib",
"max_issues_repo_path": "README.agda",
"max_line_length": 70,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "borszag/smallib",
"max_stars_repo_path": "README.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 529,
"size": 3069
}
|
{-# OPTIONS --without-K #-}
open import HoTT
open import cohomology.SuspAdjointLoopIso
open import cohomology.WithCoefficients
open import cohomology.Theory
open import cohomology.Exactness
open import cohomology.Choice
{- A spectrum (family (Eₙ | n : ℤ) such that ΩEₙ₊₁ = Eₙ)
- gives rise to a cohomology theory C with Cⁿ(S⁰) = π₁(Eₙ₊₁). -}
module cohomology.SpectrumModel
{i} (E : ℤ → Ptd i) (spectrum : (n : ℤ) → ⊙Ω (E (succ n)) == E n) where
module SpectrumModel where
{- Definition of cohomology group C -}
module _ (n : ℤ) (X : Ptd i) where
C : Group i
C = →Ω-group X (E (succ n))
{- convenient abbreviations -}
CEl = Group.El C
⊙CEl = Group.⊙El C
Cid = Group.ident C
{- before truncation -}
uCEl = fst (X ⊙→ ⊙Ω (E (succ n)))
{- Cⁿ(X) is an abelian group -}
C-abelian : (n : ℤ) (X : Ptd i) → is-abelian (C n X)
C-abelian n X =
transport (is-abelian ∘ →Ω-group X) (spectrum (succ n)) $
Trunc-group-abelian (→Ω-group-structure _ _) $ λ {(f , fpt) (g , gpt) →
⊙λ= (λ x → conc^2-comm (f x) (g x)) (pt-lemma fpt gpt)}
where
pt-lemma : ∀ {i} {A : Type i} {x : A} {p q : idp {a = x} == idp {a = x}}
(α : p == idp) (β : q == idp)
→ ap (uncurry _∙_) (ap2 _,_ α β) ∙ idp
== conc^2-comm p q ∙ ap (uncurry _∙_) (ap2 _,_ β α) ∙ idp
pt-lemma idp idp = idp
{- CF, the functorial action of C:
- contravariant functor from pointed spaces to abelian groups -}
module _ (n : ℤ) {X Y : Ptd i} where
CF-hom : fst (X ⊙→ Y) → (C n Y →ᴳ C n X)
CF-hom f = →Ω-group-dom-act f (E (succ n))
CF : fst (X ⊙→ Y) → fst (⊙CEl n Y ⊙→ ⊙CEl n X)
CF F = GroupHom.⊙f (CF-hom F)
{- CF-hom is a functor from pointed spaces to abelian groups -}
module _ (n : ℤ) {X : Ptd i} where
CF-ident : CF-hom n {X} {X} (⊙idf X) == idhom (C n X)
CF-ident = →Ω-group-dom-idf (E (succ n))
CF-comp : {Y Z : Ptd i} (g : fst (Y ⊙→ Z)) (f : fst (X ⊙→ Y))
→ CF-hom n (g ⊙∘ f) == CF-hom n f ∘ᴳ CF-hom n g
CF-comp g f = →Ω-group-dom-∘ g f (E (succ n))
-- Eilenberg-Steenrod Axioms
{- Suspension Axiom -}
private
C-Susp' : {E₁ E₀ : Ptd i} (p : ⊙Ω E₁ == E₀) (X : Ptd i)
→ →Ω-group (⊙Susp X) E₁ ≃ᴳ →Ω-group X E₀
C-Susp' {E₁ = E₁} idp X = SuspAdjointLoopIso.iso X E₁
C-SuspF' : {E₁ E₀ : Ptd i} (p : ⊙Ω E₁ == E₀)
{X Y : Ptd i} (f : fst (X ⊙→ Y))
→ fst (C-Susp' p X) ∘ᴳ →Ω-group-dom-act (⊙susp-fmap f) E₁
== →Ω-group-dom-act f E₀ ∘ᴳ fst (C-Susp' p Y)
C-SuspF' {E₁ = E₁} idp f = SuspAdjointLoopIso.nat-dom f E₁
C-Susp : (n : ℤ) (X : Ptd i) → C (succ n) (⊙Susp X) ≃ᴳ C n X
C-Susp n X = C-Susp' (spectrum (succ n)) X
C-SuspF : (n : ℤ) {X Y : Ptd i} (f : fst (X ⊙→ Y))
→ fst (C-Susp n X) ∘ᴳ CF-hom (succ n) (⊙susp-fmap f)
== CF-hom n f ∘ᴳ fst (C-Susp n Y)
C-SuspF n f = C-SuspF' (spectrum (succ n)) f
{- Non-truncated Exactness Axiom -}
module _ (n : ℤ) {X Y : Ptd i} where
{- precomposing [⊙cfcod' f] and then [f] gives [0] -}
exact-itok-lemma : (f : fst (X ⊙→ Y)) (g : uCEl n (⊙Cof f))
→ (g ⊙∘ ⊙cfcod' f) ⊙∘ f == ⊙cst
exact-itok-lemma (f , fpt) (g , gpt) = ⊙λ=
(λ x → ap g (! (cfglue' f x)) ∙ gpt)
(ap (g ∘ cfcod) fpt
∙ ap g (ap cfcod (! fpt) ∙ ! (cfglue (snd X))) ∙ gpt
=⟨ lemma cfcod g fpt (! (cfglue (snd X))) gpt ⟩
ap g (! (cfglue (snd X))) ∙ gpt
=⟨ ! (∙-unit-r _) ⟩
(ap g (! (cfglue (snd X))) ∙ gpt) ∙ idp ∎)
where
lemma : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k}
{a₁ a₂ : A} {b : B} {c : C} (f : A → B) (g : B → C)
(p : a₁ == a₂) (q : f a₁ == b) (r : g b == c)
→ ap (g ∘ f) p ∙ ap g (ap f (! p) ∙ q) ∙ r == ap g q ∙ r
lemma f g idp idp idp = idp
{- if g ⊙∘ f is constant then g factors as h ⊙∘ ⊙cfcod' f -}
exact-ktoi-lemma : (f : fst (X ⊙→ Y)) (g : uCEl n Y)
→ g ⊙∘ f == ⊙cst
→ Σ (uCEl n (⊙Cof f)) (λ h → h ⊙∘ ⊙cfcod' f == g)
exact-ktoi-lemma (f , fpt) (h , hpt) p =
((g , ! q ∙ hpt) ,
pair= idp (! (∙-assoc q (! q) hpt) ∙ ap (_∙ hpt) (!-inv-r q)))
where
g : Cofiber f → Ω (E (succ n))
g = CofiberRec.f idp h (! ∘ app= (ap fst p))
q : h (snd Y) == g (cfbase' f)
q = ap g (snd (⊙cfcod' (f , fpt)))
{- Truncated Exactness Axiom -}
module _ (n : ℤ) {X Y : Ptd i} where
{- in image of (CF n (⊙cfcod' f)) ⇒ in kernel of (CF n f) -}
abstract
C-exact-itok : (f : fst (X ⊙→ Y))
→ is-exact-itok (CF-hom n (⊙cfcod' f)) (CF-hom n f)
C-exact-itok f =
itok-alt-in (CF-hom n (⊙cfcod' f)) (CF-hom n f) $
Trunc-elim (λ _ → =-preserves-level _ (Trunc-level {n = 0}))
(ap [_] ∘ exact-itok-lemma n f)
{- in kernel of (CF n f) ⇒ in image of (CF n (⊙cfcod' f)) -}
abstract
C-exact-ktoi : (f : fst (X ⊙→ Y))
→ is-exact-ktoi (CF-hom n (⊙cfcod' f)) (CF-hom n f)
C-exact-ktoi f =
Trunc-elim
(λ _ → Π-level (λ _ → raise-level _ Trunc-level))
(λ h tp → Trunc-rec Trunc-level (lemma h) (–> (Trunc=-equiv _ _) tp))
where
lemma : (h : uCEl n Y) → h ⊙∘ f == ⊙cst
→ Trunc -1 (Σ (CEl n (⊙Cof f))
(λ tk → fst (CF n (⊙cfcod' f)) tk == [ h ]))
lemma h p = [ [ fst wit ] , ap [_] (snd wit) ]
where
wit : Σ (uCEl n (⊙Cof f)) (λ k → k ⊙∘ ⊙cfcod' f == h)
wit = exact-ktoi-lemma n f h p
C-exact : (f : fst (X ⊙→ Y)) → is-exact (CF-hom n (⊙cfcod' f)) (CF-hom n f)
C-exact f = record {itok = C-exact-itok f; ktoi = C-exact-ktoi f}
{- Additivity Axiom -}
module _ (n : ℤ) {A : Type i} (X : A → Ptd i)
(ac : (W : A → Type i) → has-choice 0 A W)
where
into : CEl n (⊙BigWedge X) → Trunc 0 (Π A (uCEl n ∘ X))
into = Trunc-rec Trunc-level (λ H → [ (λ a → H ⊙∘ ⊙bwin a) ])
module Out' (K : Π A (uCEl n ∘ X)) = BigWedgeRec
idp
(fst ∘ K)
(! ∘ snd ∘ K)
out : Trunc 0 (Π A (uCEl n ∘ X)) → CEl n (⊙BigWedge X)
out = Trunc-rec Trunc-level (λ K → [ Out'.f K , idp ])
into-out : ∀ y → into (out y) == y
into-out = Trunc-elim
(λ _ → =-preserves-level _ Trunc-level)
(λ K → ap [_] (λ= (λ a → pair= idp $
ap (Out'.f K) (! (bwglue a)) ∙ idp
=⟨ ∙-unit-r _ ⟩
ap (Out'.f K) (! (bwglue a))
=⟨ ap-! (Out'.f K) (bwglue a) ⟩
! (ap (Out'.f K) (bwglue a))
=⟨ ap ! (Out'.glue-β K a) ⟩
! (! (snd (K a)))
=⟨ !-! (snd (K a)) ⟩
snd (K a) ∎)))
out-into : ∀ x → out (into x) == x
out-into = Trunc-elim
{P = λ tH → out (into tH) == tH}
(λ _ → =-preserves-level _ Trunc-level)
(λ {(h , hpt) → ap [_] $ pair=
(λ= (out-into-fst (h , hpt)))
(↓-app=cst-in $ ! $
ap (λ w → w ∙ hpt) (app=-β (out-into-fst (h , hpt)) bwbase)
∙ !-inv-l hpt)})
where
lemma : ∀ {i j} {A : Type i} {B : Type j} (f : A → B)
{a₁ a₂ : A} {b : B} (p : a₁ == a₂) (q : f a₁ == b)
→ ! q ∙ ap f p == ! (ap f (! p) ∙ q)
lemma f idp idp = idp
out-into-fst : (H : fst (⊙BigWedge X ⊙→ ⊙Ω (E (succ n))))
→ ∀ w → Out'.f (λ a → H ⊙∘ ⊙bwin a) w == fst H w
out-into-fst (h , hpt) = BigWedge-elim
(! hpt)
(λ _ _ → idp)
(λ a → ↓-='-in $
! hpt ∙ ap h (bwglue a)
=⟨ lemma h (bwglue a) hpt ⟩
! (ap h (! (bwglue a)) ∙ hpt)
=⟨ ! (Out'.glue-β (λ a → (h , hpt) ⊙∘ ⊙bwin a) a) ⟩
ap (Out'.f (λ a → (h , hpt) ⊙∘ ⊙bwin a)) (bwglue a) ∎)
abstract
C-additive : is-equiv (GroupHom.f (Πᴳ-hom-in (CF-hom n ∘ ⊙bwin {X = X})))
C-additive = transport is-equiv
(λ= $ Trunc-elim
(λ _ → =-preserves-level _ $ Π-level $ λ _ → Trunc-level)
(λ _ → idp))
((ac (uCEl n ∘ X)) ∘ise (is-eq into out into-out out-into))
open SpectrumModel
spectrum-cohomology : CohomologyTheory i
spectrum-cohomology = record {
C = C;
CF-hom = CF-hom;
CF-ident = CF-ident;
CF-comp = CF-comp;
C-abelian = C-abelian;
C-Susp = C-Susp;
C-SuspF = C-SuspF;
C-exact = C-exact;
C-additive = C-additive}
spectrum-C-S⁰ : (n : ℤ) → C n (⊙Lift ⊙S⁰) == πS 0 (E (succ n))
spectrum-C-S⁰ n = Bool⊙→Ω-is-π₁ (E (succ n))
|
{
"alphanum_fraction": 0.4767329132,
"avg_line_length": 35.114893617,
"ext": "agda",
"hexsha": "274ad4b2acbe7737e00b3abe9058e7ad98d9a77a",
"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/cohomology/SpectrumModel.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/cohomology/SpectrumModel.agda",
"max_line_length": 79,
"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/cohomology/SpectrumModel.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3649,
"size": 8252
}
|
{-# 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
module Graphs.Definition where
record Graph {a b : _} (c : _) {V' : Set a} (V : Setoid {a} {b} V') : Set (a ⊔ b ⊔ lsuc c) where
field
_<->_ : Rel {a} {c} V'
noSelfRelation : (x : V') → x <-> x → False
symmetric : {x y : V'} → x <-> y → y <-> x
wellDefined : {x y r s : V'} → Setoid._∼_ V x y → Setoid._∼_ V r s → x <-> r → y <-> s
record GraphIso {a b c d e m : _} {V1' : Set a} {V2' : Set b} {V1 : Setoid {a} {c} V1'} {V2 : Setoid {b} {d} V2'} (G : Graph e V1) (H : Graph m V2) (f : V1' → V2') : Set (a ⊔ b ⊔ c ⊔ d ⊔ e ⊔ m) where
field
bij : SetoidBijection V1 V2 f
respects : (x y : V1') → Graph._<->_ G x y → Graph._<->_ H (f x) (f y)
respects' : (x y : V1') → Graph._<->_ H (f x) (f y) → Graph._<->_ G x y
record Subgraph {a b c d e : _} {V' : Set a} {V : Setoid {a} {b} V'} (G : Graph c V) {pred : V' → Set d} (sub : subset V pred) (_<->'_ : Rel {_} {e} (Sg V' pred)) : Set (a ⊔ b ⊔ c ⊔ d ⊔ e) where
field
inherits : {x y : Sg V' pred} → (x <->' y) → (Graph._<->_ G (underlying x) (underlying y))
symmetric : {x y : Sg V' pred} → (x <->' y) → (y <->' x)
wellDefined : {x y r s : Sg V' pred} → Setoid._∼_ (subsetSetoid V sub) x y → Setoid._∼_ (subsetSetoid V sub) r s → x <->' r → y <->' s
subgraphIsGraph : {a b c d e : _} {V' : Set a} {V : Setoid {a} {b} V'} {G : Graph c V} {pred : V' → Set d} {sub : subset V pred} {rel : Rel {_} {e} (Sg V' pred)} (H : Subgraph G sub rel) → Graph e (subsetSetoid V sub)
Graph._<->_ (subgraphIsGraph {rel = rel} H) = rel
Graph.noSelfRelation (subgraphIsGraph {G = G} H) (v , isSub) v=v = Graph.noSelfRelation G v (Subgraph.inherits H v=v)
Graph.symmetric (subgraphIsGraph H) v1=v2 = Subgraph.symmetric H v1=v2
Graph.wellDefined (subgraphIsGraph H) = Subgraph.wellDefined H
|
{
"alphanum_fraction": 0.5647590361,
"avg_line_length": 56.9142857143,
"ext": "agda",
"hexsha": "5c4dc2f00dc65d6589cdf27af58589bc738f5de9",
"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/Definition.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/Definition.agda",
"max_line_length": 217,
"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/Definition.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": 807,
"size": 1992
}
|
{-
A defintion of the real projective spaces following:
[BR17] U. Buchholtz, E. Rijke, The real projective spaces in homotopy type theory.
(2017) https://arxiv.org/abs/1704.05770
-}
{-# OPTIONS --cubical --safe #-}
module Cubical.HITs.RPn.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Equiv.Properties
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Bundle
open import Cubical.Foundations.SIP
open import Cubical.Structures.Pointed
open import Cubical.Structures.TypeEqvTo
open import Cubical.Data.Bool
open import Cubical.Data.Nat hiding (elim)
open import Cubical.Data.NatMinusOne
open import Cubical.Data.Sigma
open import Cubical.Data.Unit
open import Cubical.Data.Empty as ⊥ hiding (elim)
open import Cubical.Data.Sum as ⊎ hiding (elim)
open import Cubical.Data.Prod renaming (_×_ to _×'_; _×Σ_ to _×_; swapΣEquiv to swapEquiv)
hiding (swapEquiv)
open import Cubical.HITs.PropositionalTruncation as PropTrunc hiding (elim)
open import Cubical.HITs.Sn
open import Cubical.HITs.Susp
open import Cubical.HITs.Join
open import Cubical.HITs.Pushout
open import Cubical.HITs.Pushout.Flattening
private
variable
ℓ ℓ' ℓ'' : Level
-- Definition II.1 in [BR17], see also Cubical.Foundations.Bundle
2-EltType₀ = TypeEqvTo ℓ-zero Bool -- Σ[ X ∈ Type₀ ] ∥ X ≃ Bool ∥
2-EltPointed₀ = PointedEqvTo ℓ-zero Bool -- Σ[ X ∈ Type₀ ] X × ∥ X ≃ Bool ∥
Bool* : 2-EltType₀
Bool* = Bool , ∣ idEquiv _ ∣
-- Our first goal is to 'lift' `_⊕_ : Bool → Bool ≃ Bool` to a function `_⊕_ : A → A ≃ Bool`
-- for any 2-element type (A, ∣e∣).
-- `isContr-BoolPointedIso` and `isContr-2-EltPointed-iso` are contained in the proof
-- of Lemma II.2 in [BR17], though we prove `isContr-BoolPointedIso` more directly
-- with ⊕ -- [BR17] proves it for just the x = false case and uses notEquiv to get
-- the x = true case.
-- (λ y → x ⊕ y) is the unqiue pointed isomorphism (Bool , false) ≃ (Bool , x)
isContr-BoolPointedIso : ∀ x → isContr ((Bool , false) ≃[ pointed-iso ] (Bool , x))
fst (isContr-BoolPointedIso x) = ((λ y → x ⊕ y) , isEquiv-⊕ x) , ⊕-comm x false
snd (isContr-BoolPointedIso x) (e , p)
= ΣProp≡ (λ e → isSetBool (equivFun e false) x)
(ΣProp≡ isPropIsEquiv (funExt λ { false → ⊕-comm x false ∙ sym p
; true → ⊕-comm x true ∙ sym q }))
where q : e .fst true ≡ not x
q with dichotomyBool (invEq e (not x))
... | inl q = invEq≡→equivFun≡ e q
... | inr q = ⊥.rec (not≢const x (sym (invEq≡→equivFun≡ e q) ∙ p))
-- Since isContr is a mere proposition, we can eliminate a witness ∣e∣ : ∥ X ≃ Bool ∥ to get
-- that there is therefore a unique pointed isomorphism (Bool , false) ≃ (X , x) for any
-- 2-element pointed type (X , x, ∣e∣).
isContr-2-EltPointed-iso : (X∙ : 2-EltPointed₀)
→ isContr ((Bool , false , ∣ idEquiv Bool ∣) ≃[ PointedEqvTo-iso Bool ] X∙)
isContr-2-EltPointed-iso (X , x , ∣e∣)
= PropTrunc.rec isPropIsContr
(λ e → J (λ X∙ _ → isContr ((Bool , false) ≃[ pointed-iso ] X∙))
(isContr-BoolPointedIso (e .fst x))
(sym (pointed-sip _ _ (e , refl))))
∣e∣
-- This unique isomorphism must be _⊕_ 'lifted' to X. This idea is alluded to at the end of the
-- proof of Theorem III.4 in [BR17], where the authors reference needing ⊕-comm.
module ⊕* (X : 2-EltType₀) where
_⊕*_ : typ X → typ X → Bool
y ⊕* z = invEquiv (fst (fst (isContr-2-EltPointed-iso (fst X , y , snd X)))) .fst z
-- we've already shown that this map is an equivalence on the right
isEquivʳ : (y : typ X) → isEquiv (y ⊕*_)
isEquivʳ y = invEquiv (fst (fst (isContr-2-EltPointed-iso (fst X , y , snd X)))) .snd
Equivʳ : typ X → typ X ≃ Bool
Equivʳ y = (y ⊕*_) , isEquivʳ y
-- any mere proposition that holds for (Bool, _⊕_) holds for (typ X, _⊕*_)
-- this amounts to just carefully unfolding the PropTrunc.elim and J in isContr-2-EltPointed-iso
elim : ∀ {ℓ'} (P : (A : Type₀) (_⊕'_ : A → A → Bool) → Type ℓ') (propP : ∀ A _⊕'_ → isProp (P A _⊕'_))
→ P Bool _⊕_ → P (typ X) _⊕*_
elim {ℓ'} P propP r = PropTrunc.elim {P = λ ∣e∣ → P (typ X) (R₁ ∣e∣)} (λ _ → propP _ _)
(λ e → EquivJ (λ A e → P A (R₂ A e)) r e)
(snd X)
where R₁ : ∥ fst X ≃ Bool ∥ → typ X → typ X → Bool
R₁ ∣e∣ y = invEq (fst (fst (isContr-2-EltPointed-iso (fst X , y , ∣e∣))))
R₂ : (B : Type₀) → B ≃ Bool → B → B → Bool
R₂ A e y = invEq (fst (fst (J (λ A∙ _ → isContr ((Bool , false) ≃[ pointed-iso ] A∙))
(isContr-BoolPointedIso (e .fst y))
(sym (pointed-sip (A , y) (Bool , e .fst y) (e , refl))))))
-- as a consequence, we get that ⊕* is commutative, and is therefore also an equivalence on the left
comm : (y z : typ X) → y ⊕* z ≡ z ⊕* y
comm = elim (λ A _⊕'_ → (x y : A) → x ⊕' y ≡ y ⊕' x)
(λ _ _ → isPropPi (λ _ → isPropPi (λ _ → isSetBool _ _)))
⊕-comm
isEquivˡ : (y : typ X) → isEquiv (_⊕* y)
isEquivˡ y = subst isEquiv (funExt (λ z → comm y z)) (isEquivʳ y)
Equivˡ : typ X → typ X ≃ Bool
Equivˡ y = (_⊕* y) , isEquivˡ y
-- Lemma II.2 in [BR17], though we do not use it here
-- Note: Lemma II.3 is `pointed-sip`, used in `PointedEqvTo-sip`
isContr-2-EltPointed : isContr (2-EltPointed₀)
fst isContr-2-EltPointed = (Bool , false , ∣ idEquiv Bool ∣)
snd isContr-2-EltPointed A∙ = PointedEqvTo-sip Bool _ A∙ (fst (isContr-2-EltPointed-iso A∙))
--------------------------------------------------------------------------------
-- Now we mutually define RP n and its double cover (Definition III.1 in [BR17]),
-- and show that the total space of this double cover is S n (Theorem III.4).
RP : ℕ₋₁ → Type₀
cov⁻¹ : (n : ℕ₋₁) → RP n → 2-EltType₀ -- (see Cubical.Foundations.Bundle)
RP neg1 = ⊥
RP (ℕ→ℕ₋₁ n) = Pushout (pr (cov⁻¹ (-1+ n))) (λ _ → tt)
{-
tt
Total (cov⁻¹ (n-1)) — — — > Unit
| ∙
pr | ∙ inr
| ∙
V V
RP (n-1) ∙ ∙ ∙ ∙ ∙ ∙ > RP n := Pushout pr (const tt)
inl
-}
cov⁻¹ neg1 x = Bool*
cov⁻¹ (ℕ→ℕ₋₁ n) (inl x) = cov⁻¹ (-1+ n) x
cov⁻¹ (ℕ→ℕ₋₁ n) (inr _) = Bool*
cov⁻¹ (ℕ→ℕ₋₁ n) (push (x , y) i) = ua ((λ z → y ⊕* z) , ⊕*.isEquivʳ (cov⁻¹ (-1+ n) x) y) i , ∣p∣ i
where open ⊕* (cov⁻¹ (-1+ n) x)
∣p∣ = isProp→PathP (λ i → squash {A = ua (⊕*.Equivʳ (cov⁻¹ (-1+ n) x) y) i ≃ Bool})
(str (cov⁻¹ (-1+ n) x)) (∣ idEquiv _ ∣)
{-
tt
Total (cov⁻¹ (n-1)) — — — > Unit
| |
pr | // ua α // | Bool
| |
V V
RP (n-1) - - - - - - > Type
cov⁻¹ (n-1)
where α : ∀ (x : Total (cov⁻¹ (n-1))) → cov⁻¹ (n-1) (pr x) ≃ Bool
α (x , y) = (λ z → y ⊕* z) , ⊕*.isEquivʳ y
-}
TotalCov≃Sn : ∀ n → Total (cov⁻¹ n) ≃ S n
TotalCov≃Sn neg1 = isoToEquiv (iso (λ { () }) (λ { () }) (λ { () }) (λ { () }))
TotalCov≃Sn (ℕ→ℕ₋₁ n) =
Total (cov⁻¹ (ℕ→ℕ₋₁ n)) ≃⟨ i ⟩
Pushout Σf Σg ≃⟨ ii ⟩
join (Total (cov⁻¹ (-1+ n))) Bool ≃⟨ iii ⟩
S (ℕ→ℕ₋₁ n) ■
where
{-
(i) First we want to show that `Total (cov⁻¹ (ℕ→ℕ₋₁ n))` is equivalent to a pushout.
We do this using the flattening lemma, which states:
Given f,g,F,G,e such that the following square commutes:
g
A — — — — > C Define: E : Pushout f g → Type
| | E (inl b) = F b
f | ua e | G E (inr c) = G c
V V E (push a i) = ua (e a) i
B — — — — > Type
F
Then, the total space `Σ (Pushout f g) E` is the following pushout:
Σg := (g , e a)
Σ[ a ∈ A ] F (f a) — — — — — — — — > Σ[ c ∈ C ] G c
| ∙
Σf := (f , id) | ∙
V V
Σ[ b ∈ B ] F b ∙ ∙ ∙ ∙ ∙ ∙ ∙ ∙ ∙ ∙ > Σ (Pushout f g) E
In our case, setting `f = pr (cov⁻¹ (n-1))`, `g = λ _ → tt`, `F = cov⁻¹ (n-1)`, `G = λ _ → Bool`,
and `e = λ (x , y) → ⊕*.Equivʳ (cov⁻¹ (n-1) x) y` makes E equal (up to funExt) to `cov⁻¹ n`.
Thus the flattening lemma gives us that `Total (cov⁻¹ n) ≃ Pushout Σf Σg`.
-}
open FlatteningLemma {- f = -} (λ x → pr (cov⁻¹ (-1+ n)) x) {- g = -} (λ _ → tt)
{- F = -} (λ x → typ (cov⁻¹ (-1+ n) x)) {- G = -} (λ _ → Bool)
{- e = -} (λ { (x , y) → ⊕*.Equivʳ (cov⁻¹ (-1+ n) x) y })
hiding (Σf ; Σg)
cov⁻¹≃E : ∀ x → typ (cov⁻¹ (ℕ→ℕ₋₁ n) x) ≃ E x
cov⁻¹≃E (inl x) = idEquiv _
cov⁻¹≃E (inr x) = idEquiv _
cov⁻¹≃E (push a i) = idEquiv _
-- for easier reference, we copy these definitons here
Σf : Σ[ x ∈ Total (cov⁻¹ (-1+ n)) ] typ (cov⁻¹ (-1+ n) (fst x)) → Total (cov⁻¹ (-1+ n))
Σg : Σ[ x ∈ Total (cov⁻¹ (-1+ n)) ] typ (cov⁻¹ (-1+ n) (fst x)) → Unit × Bool
Σf ((x , y) , z) = (x , z) -- ≡ (f a , x)
Σg ((x , y) , z) = (tt , y ⊕* z) -- ≡ (g a , (e a) .fst x)
where open ⊕* (cov⁻¹ (-1+ n) x)
i : Total (cov⁻¹ (ℕ→ℕ₋₁ n)) ≃ Pushout Σf Σg
i = (Σ[ x ∈ RP (ℕ→ℕ₋₁ n) ] typ (cov⁻¹ (ℕ→ℕ₋₁ n) x)) ≃⟨ congΣEquiv cov⁻¹≃E ⟩
(Σ[ x ∈ RP (ℕ→ℕ₋₁ n) ] E x) ≃⟨ flatten ⟩
Pushout Σf Σg ■
{-
(ii) Next we want to show that `Pushout Σf Σg` is equivalent to `join (Total (cov⁻¹ (n-1))) Bool`.
Since both are pushouts, this can be done by defining a diagram equivalence:
Σf Σg
Total (cov⁻¹ (n-1)) < — — Σ[ x ∈ Total (cov⁻¹ (n-1)) ] cov⁻¹ (n-1) (pr x) — — > Unit × Bool
| ∙ |
id |≃ u ∙≃ snd |≃
V V V
Total (cov⁻¹ (n-1)) < — — — — — — — Total (cov⁻¹ (n-1)) × Bool — — — — — — — — — > Bool
proj₁ proj₂
where the equivalence u above must therefore satisfy: `u .fst x ≡ (Σf x , snd (Σg x))`
Unfolding this, we get: `u .fst ((x , y) , z) ≡ ((x , z) , (y ⊕* z))`
It suffices to show that the map y ↦ y ⊕* z is an equivalence, since we can then express u as
the following composition of equivalences:
((x , y) , z) ↦ (x , (y , z)) ↦ (x , (z , y)) ↦ (x , (z , y ⊕* z)) ↦ ((x , z) , y ⊕* z)
This was proved above by ⊕*.isEquivˡ.
-}
u : ∀ {n} → (Σ[ x ∈ Total (cov⁻¹ n) ] typ (cov⁻¹ n (fst x))) ≃ (Total (cov⁻¹ n) ×' Bool)
u {n} = Σ[ x ∈ Total (cov⁻¹ n) ] typ (cov⁻¹ n (fst x)) ≃⟨ assocΣ ⟩
Σ[ x ∈ RP n ] (typ (cov⁻¹ n x)) × (typ (cov⁻¹ n x)) ≃⟨ congΣEquiv (λ x → swapEquiv _ _) ⟩
Σ[ x ∈ RP n ] (typ (cov⁻¹ n x)) × (typ (cov⁻¹ n x)) ≃⟨ congΣEquiv (λ x → congΣEquiv (λ y →
⊕*.Equivˡ (cov⁻¹ n x) y)) ⟩
Σ[ x ∈ RP n ] (typ (cov⁻¹ n x)) × Bool ≃⟨ invEquiv assocΣ ⟩
Total (cov⁻¹ n) × Bool ≃⟨ invEquiv A×B≃A×ΣB ⟩
Total (cov⁻¹ n) ×' Bool ■
H : ∀ x → u .fst x ≡ (Σf x , snd (Σg x))
H x = refl
nat : 3-span-equiv (3span Σf Σg) (3span {A2 = Total (cov⁻¹ (-1+ n)) ×' Bool} proj₁ proj₂)
nat = record { e0 = idEquiv _ ; e2 = u ; e4 = ΣUnit _
; H1 = λ x → cong proj₁ (H x)
; H3 = λ x → cong proj₂ (H x) }
ii : Pushout Σf Σg ≃ join (Total (cov⁻¹ (-1+ n))) Bool
ii = compEquiv (pathToEquiv (spanEquivToPushoutPath nat)) (joinPushout≃join _ _)
{-
(iii) Finally, it's trivial to show that `join (Total (cov⁻¹ (n-1))) Bool` is equivalent to
`Susp (Total (cov⁻¹ (n-1)))`. Induction then gives us that `Susp (Total (cov⁻¹ (n-1)))`
is equivalent to `S n`, which completes the proof.
-}
iii : join (Total (cov⁻¹ (-1+ n))) Bool ≃ S (ℕ→ℕ₋₁ n)
iii = join (Total (cov⁻¹ (-1+ n))) Bool ≃⟨ invEquiv Susp≃joinBool ⟩
Susp (Total (cov⁻¹ (-1+ n))) ≃⟨ congSuspEquiv (TotalCov≃Sn (-1+ n)) ⟩
S (ℕ→ℕ₋₁ n) ■
-- the usual covering map S n → RP n, with fibers exactly cov⁻¹
cov : (n : ℕ₋₁) → S n → RP n
cov n = pr (cov⁻¹ n) ∘ invEq (TotalCov≃Sn n)
fibcov≡cov⁻¹ : ∀ n (x : RP n) → fiber (cov n) x ≡ cov⁻¹ n x .fst
fibcov≡cov⁻¹ n x =
fiber (cov n) x ≡[ i ]⟨ fiber {A = ua e i} (pr (cov⁻¹ n) ∘ ua-unglue e i) x ⟩
fiber (pr (cov⁻¹ n)) x ≡⟨ ua (fibPrEquiv (cov⁻¹ n) x) ⟩
cov⁻¹ n x .fst ∎
where e = invEquiv (TotalCov≃Sn n)
--------------------------------------------------------------------------------
-- Finally, we state the trivial equivalences for RP 0 and RP 1 (Example III.3 in [BR17])
RP0≃Unit : RP 0 ≃ Unit
RP0≃Unit = isoToEquiv (iso (λ _ → tt) (λ _ → inr tt) (λ _ → refl) (λ { (inr tt) → refl }))
RP1≡S1 : RP 1 ≡ S 1
RP1≡S1 = Pushout {A = Total (cov⁻¹ 0)} {B = RP 0} (pr (cov⁻¹ 0)) (λ _ → tt) ≡⟨ i ⟩
Pushout {A = Total (cov⁻¹ 0)} {B = Unit} (λ _ → tt) (λ _ → tt) ≡⟨ ii ⟩
Pushout {A = S 0} {B = Unit} (λ _ → tt) (λ _ → tt) ≡⟨ PushoutSusp≡Susp ⟩
S 1 ∎
where i = λ i → Pushout {A = Total (cov⁻¹ 0)}
{B = ua RP0≃Unit i}
(λ x → ua-gluePt RP0≃Unit i (pr (cov⁻¹ 0) x))
(λ _ → tt)
ii = λ j → Pushout {A = ua (TotalCov≃Sn 0) j} (λ _ → tt) (λ _ → tt)
|
{
"alphanum_fraction": 0.4765892122,
"avg_line_length": 45.0660377358,
"ext": "agda",
"hexsha": "45449153c301272a2071ef42dd6f73a926e03d27",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "borsiemir/cubical",
"max_forks_repo_path": "Cubical/HITs/RPn/Base.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "borsiemir/cubical",
"max_issues_repo_path": "Cubical/HITs/RPn/Base.agda",
"max_line_length": 104,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "borsiemir/cubical",
"max_stars_repo_path": "Cubical/HITs/RPn/Base.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 5449,
"size": 14331
}
|
{-# OPTIONS --allow-unsolved-metas #-}
open import Agda.Builtin.Bool
postulate
A : Set
F : Bool → Set
F true = A
F false = A
data D {b : Bool} (x : F b) : Set where
variable
b : Bool
x : F b
postulate
f : D x → (P : F b → Set) → P x
|
{
"alphanum_fraction": 0.5685483871,
"avg_line_length": 12.4,
"ext": "agda",
"hexsha": "cc19019014678b6e82f6984324b5589b2087e15c",
"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/Issue3655b.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/Issue3655b.agda",
"max_line_length": 39,
"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/Issue3655b.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": 94,
"size": 248
}
|
-- {-# OPTIONS -v scope.clash:20 #-}
-- Andreas, 2012-10-19 test case for Issue 719
module ShadowModule2 where
open import Common.Size as YesDuplicate
import Common.Size as NotDuplicate
private open module YesDuplicate = NotDuplicate
-- should report:
-- Duplicate definition of module YesDuplicate.
-- NOT: Duplicate definition of module NotDuplicate.
|
{
"alphanum_fraction": 0.7774647887,
"avg_line_length": 29.5833333333,
"ext": "agda",
"hexsha": "bf432051e72c1a6baeb78b50eaa821973f4085e7",
"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/Fail/ShadowModule2.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/Fail/ShadowModule2.agda",
"max_line_length": 52,
"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/Fail/ShadowModule2.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": 81,
"size": 355
}
|
------------------------------------------------------------------------
-- Various forms of induction for natural numbers
------------------------------------------------------------------------
module Induction.Nat where
open import Data.Function
open import Data.Nat
open import Data.Fin
open import Data.Fin.Props
open import Data.Product
open import Data.Unit
open import Induction
import Induction.WellFounded as WF
open import Relation.Binary.PropositionalEquality
------------------------------------------------------------------------
-- Ordinary induction
Rec : RecStruct ℕ
Rec P zero = ⊤
Rec P (suc n) = P n
rec-builder : RecursorBuilder Rec
rec-builder P f zero = tt
rec-builder P f (suc n) = f n (rec-builder P f n)
rec : Recursor Rec
rec = build rec-builder
------------------------------------------------------------------------
-- Complete induction
CRec : RecStruct ℕ
CRec P zero = ⊤
CRec P (suc n) = P n × CRec P n
cRec-builder : RecursorBuilder CRec
cRec-builder P f zero = tt
cRec-builder P f (suc n) = f n ih , ih
where ih = cRec-builder P f n
cRec : Recursor CRec
cRec = build cRec-builder
------------------------------------------------------------------------
-- Complete induction based on _<′_
open WF _<′_ using (acc) renaming (Acc to <-Acc)
<-allAcc : ∀ n → <-Acc n
<-allAcc n = acc (helper n)
where
helper : ∀ n m → m <′ n → <-Acc m
helper zero _ ()
helper (suc n) .n ≤′-refl = acc (helper n)
helper (suc n) m (≤′-step m<n) = helper n m m<n
open WF _<′_ public using () renaming (WfRec to <-Rec)
open WF.All _<′_ <-allAcc public
renaming ( wfRec-builder to <-rec-builder
; wfRec to <-rec
)
------------------------------------------------------------------------
-- Complete induction based on _≺_
open WF _≺_ renaming (Acc to ≺-Acc)
<-Acc⇒≺-Acc : ∀ {n} → <-Acc n → ≺-Acc n
<-Acc⇒≺-Acc (acc rs) =
acc (λ m m≺n → <-Acc⇒≺-Acc (rs m (≺⇒<′ m≺n)))
≺-allAcc : ∀ n → ≺-Acc n
≺-allAcc n = <-Acc⇒≺-Acc (<-allAcc n)
open WF _≺_ public using () renaming (WfRec to ≺-Rec)
open WF.All _≺_ ≺-allAcc public
renaming ( wfRec-builder to ≺-rec-builder
; wfRec to ≺-rec
)
------------------------------------------------------------------------
-- Examples
private
module Examples where
-- The half function.
HalfPred : ℕ → Set
HalfPred _ = ℕ
half₁ : ℕ → ℕ
half₁ = cRec HalfPred half₁'
where
half₁' : ∀ n → CRec HalfPred n → HalfPred n
half₁' zero _ = zero
half₁' (suc zero) _ = zero
half₁' (suc (suc n)) (_ , half₁n , _) = suc half₁n
half₂ : ℕ → ℕ
half₂ = <-rec HalfPred half₂'
where
half₂' : ∀ n → <-Rec HalfPred n → HalfPred n
half₂' zero _ = zero
half₂' (suc zero) _ = zero
half₂' (suc (suc n)) rec = suc (rec n (≤′-step ≤′-refl))
|
{
"alphanum_fraction": 0.4972144847,
"avg_line_length": 26.1090909091,
"ext": "agda",
"hexsha": "c3cdf5dde82ec6e6e33c5aa8a635d4b1a049c622",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z",
"max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "isabella232/Lemmachine",
"max_forks_repo_path": "vendor/stdlib/src/Induction/Nat.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "larrytheliquid/Lemmachine",
"max_issues_repo_path": "vendor/stdlib/src/Induction/Nat.agda",
"max_line_length": 72,
"max_stars_count": 56,
"max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "isabella232/Lemmachine",
"max_stars_repo_path": "vendor/stdlib/src/Induction/Nat.agda",
"max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z",
"num_tokens": 846,
"size": 2872
}
|
{-# OPTIONS --prop #-}
module Issue3526-2 where
open import Agda.Builtin.Equality
record Truth (P : Prop) : Set where
constructor [_]
field
truth : P
open Truth public
data ⊥' : Prop where
⊥ = Truth ⊥'
¬ : Set → Set
¬ A = A → ⊥
unique : {A : Set} (x y : ¬ A) → x ≡ y
unique x y = refl
⊥-elim : (A : Set) → ⊥ → A
⊥-elim A b = {!!}
open import Agda.Builtin.Bool
open import Agda.Builtin.Unit
set : Bool → Set
set false = ⊥
set true = ⊤
set-elim : ∀ b → set b → Set
set-elim b x = {!!}
|
{
"alphanum_fraction": 0.5753968254,
"avg_line_length": 14,
"ext": "agda",
"hexsha": "4a8ada2856f2a51ee2af65e338f658d07c2f46e9",
"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/Issue3526-2.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/Issue3526-2.agda",
"max_line_length": 38,
"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/Issue3526-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": 187,
"size": 504
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Notation for freely adding extrema to any set
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Relation.Nullary.Construct.Add.Extrema where
open import Relation.Binary.PropositionalEquality using (_≡_; refl)
open import Relation.Nullary.Construct.Add.Infimum as Infimum using (_₋)
open import Relation.Nullary.Construct.Add.Supremum as Supremum using (_⁺)
------------------------------------------------------------------------
-- Definition
_± : ∀ {a} → Set a → Set a
A ± = A ₋ ⁺
pattern ⊥± = Supremum.[ Infimum.⊥₋ ]
pattern [_] k = Supremum.[ Infimum.[ k ] ]
pattern ⊤± = Supremum.⊤⁺
------------------------------------------------------------------------
-- Properties
[_]-injective : ∀ {a} {A : Set a} {k l : A} → [ k ] ≡ [ l ] → k ≡ l
[_]-injective refl = refl
|
{
"alphanum_fraction": 0.4540709812,
"avg_line_length": 31.9333333333,
"ext": "agda",
"hexsha": "2f525621f0df691630df89448ecc7ed6793f53f7",
"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/Relation/Nullary/Construct/Add/Extrema.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "omega12345/agda-mode",
"max_issues_repo_path": "test/asset/agda-stdlib-1.0/Relation/Nullary/Construct/Add/Extrema.agda",
"max_line_length": 74,
"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/Relation/Nullary/Construct/Add/Extrema.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": 227,
"size": 958
}
|
{-# OPTIONS --universe-polymorphism #-}
module Categories.Groupoid.Product where
open import Data.Product
open import Categories.Category
open import Categories.Groupoid
open import Categories.Morphisms
import Categories.Product as ProductC
Product : ∀ {o₁ ℓ₁ e₁ o₂ ℓ₂ e₂} {C : Category o₁ ℓ₁ e₁} {D : Category o₂ ℓ₂ e₂}
→ Groupoid C → Groupoid D → Groupoid (ProductC.Product C D)
Product c₁ c₂ = record
{ _⁻¹ = λ {(x₁ , x₂) → Groupoid._⁻¹ c₁ x₁
, Groupoid._⁻¹ c₂ x₂}
; iso = record { isoˡ = Iso.isoˡ (Groupoid.iso c₁)
, Iso.isoˡ (Groupoid.iso c₂)
; isoʳ = Iso.isoʳ (Groupoid.iso c₁)
, Iso.isoʳ (Groupoid.iso c₂) } }
|
{
"alphanum_fraction": 0.5806028834,
"avg_line_length": 36.3333333333,
"ext": "agda",
"hexsha": "4fe0c77bc1ea2779227ae3c1212403ca8fde0126",
"lang": "Agda",
"max_forks_count": 23,
"max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z",
"max_forks_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "copumpkin/categories",
"max_forks_repo_path": "Categories/Groupoid/Product.agda",
"max_issues_count": 19,
"max_issues_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892",
"max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "copumpkin/categories",
"max_issues_repo_path": "Categories/Groupoid/Product.agda",
"max_line_length": 79,
"max_stars_count": 98,
"max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "copumpkin/categories",
"max_stars_repo_path": "Categories/Groupoid/Product.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z",
"num_tokens": 222,
"size": 763
}
|
------------------------------------------------------------------------------
-- Some properties of the function iter₀
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOTC.Program.Iter0.PropertiesATP where
open import FOTC.Program.Iter0.Iter0
open import FOTC.Base
open import FOTC.Base.List
------------------------------------------------------------------------------
postulate iter₀-0 : ∀ f → iter₀ f zero ≡ []
{-# ATP prove iter₀-0 #-}
|
{
"alphanum_fraction": 0.3996960486,
"avg_line_length": 31.3333333333,
"ext": "agda",
"hexsha": "fb25a0efc94f509358c6efd39405f2877f938d5c",
"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/Iter0/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/Iter0/PropertiesATP.agda",
"max_line_length": 78,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "src/fot/FOTC/Program/Iter0/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": 110,
"size": 658
}
|
{-# OPTIONS --safe #-}
module Cubical.HITs.Pushout.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Data.Unit
open import Cubical.Data.Sigma
open import Cubical.HITs.Susp.Base
data Pushout {ℓ ℓ' ℓ''} {A : Type ℓ} {B : Type ℓ'} {C : Type ℓ''}
(f : A → B) (g : A → C) : Type (ℓ-max ℓ (ℓ-max ℓ' ℓ'')) where
inl : B → Pushout f g
inr : C → Pushout f g
push : (a : A) → inl (f a) ≡ inr (g a)
-- cofiber (equivalent to Cone in Cubical.HITs.MappingCones.Base)
cofib : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} (f : A → B) → Type _
cofib f = Pushout (λ _ → tt) f
cfcod : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} (f : A → B) → B → cofib f
cfcod f = inr
-- Symmetry of pushout
symPushout : {ℓ ℓ' ℓ'' : Level} {A : Type ℓ} {B : Type ℓ'} {C : Type ℓ''}
→ (f : A → B) (g : A → C) → Pushout f g ≃ Pushout g f
symPushout f g = isoToEquiv
(iso (λ { (inl x) → inr x ; (inr x) → inl x ; (push x i) → push x (~ i)})
(λ { (inl x) → inr x ; (inr x) → inl x ; (push x i) → push x (~ i)})
(λ { (inl x) → refl ; (inr x) → refl ; (push x i) → refl})
(λ { (inl x) → refl ; (inr x) → refl ; (push x i) → refl}))
-- Suspension defined as a pushout
PushoutSusp : ∀ {ℓ} (A : Type ℓ) → Type ℓ
PushoutSusp A = Pushout {A = A} {B = Unit} {C = Unit} (λ _ → tt) (λ _ → tt)
PushoutSusp→Susp : ∀ {ℓ} {A : Type ℓ} → PushoutSusp A → Susp A
PushoutSusp→Susp (inl _) = north
PushoutSusp→Susp (inr _) = south
PushoutSusp→Susp (push a i) = merid a i
Susp→PushoutSusp : ∀ {ℓ} {A : Type ℓ} → Susp A → PushoutSusp A
Susp→PushoutSusp north = inl tt
Susp→PushoutSusp south = inr tt
Susp→PushoutSusp (merid a i) = push a i
Susp→PushoutSusp→Susp : ∀ {ℓ} {A : Type ℓ} (x : Susp A) →
PushoutSusp→Susp (Susp→PushoutSusp x) ≡ x
Susp→PushoutSusp→Susp north = refl
Susp→PushoutSusp→Susp south = refl
Susp→PushoutSusp→Susp (merid _ _) = refl
PushoutSusp→Susp→PushoutSusp : ∀ {ℓ} {A : Type ℓ} (x : PushoutSusp A) →
Susp→PushoutSusp (PushoutSusp→Susp x) ≡ x
PushoutSusp→Susp→PushoutSusp (inl _) = refl
PushoutSusp→Susp→PushoutSusp (inr _) = refl
PushoutSusp→Susp→PushoutSusp (push _ _) = refl
PushoutSuspIsoSusp : ∀ {ℓ} {A : Type ℓ} → Iso (PushoutSusp A) (Susp A)
Iso.fun PushoutSuspIsoSusp = PushoutSusp→Susp
Iso.inv PushoutSuspIsoSusp = Susp→PushoutSusp
Iso.rightInv PushoutSuspIsoSusp = Susp→PushoutSusp→Susp
Iso.leftInv PushoutSuspIsoSusp = PushoutSusp→Susp→PushoutSusp
PushoutSusp≃Susp : ∀ {ℓ} {A : Type ℓ} → PushoutSusp A ≃ Susp A
PushoutSusp≃Susp = isoToEquiv PushoutSuspIsoSusp
PushoutSusp≡Susp : ∀ {ℓ} {A : Type ℓ} → PushoutSusp A ≡ Susp A
PushoutSusp≡Susp = isoToPath PushoutSuspIsoSusp
-- Generalised pushout, used in e.g. BlakersMassey
data PushoutGen {ℓ₁ ℓ₂ ℓ₃ : Level} {X : Type ℓ₁} {Y : Type ℓ₂}
(Q : X → Y → Type ℓ₃) : Type (ℓ-max (ℓ-max ℓ₁ ℓ₂) ℓ₃)
where
inl : X → PushoutGen Q
inr : Y → PushoutGen Q
push : {x : X} {y : Y} → Q x y → inl x ≡ inr y
-- The usual pushout is a special case of the above
module _ {ℓ₁ ℓ₂ ℓ₃ : Level} {A : Type ℓ₁} {B : Type ℓ₂} {C : Type ℓ₃}
(f : A → B) (g : A → C) where
open Iso
doubleFib : B → C → Type _
doubleFib b c = Σ[ a ∈ A ] (f a ≡ b) × (g a ≡ c)
PushoutGenFib = PushoutGen doubleFib
Pushout→PushoutGen : Pushout f g → PushoutGenFib
Pushout→PushoutGen (inl x) = inl x
Pushout→PushoutGen (inr x) = inr x
Pushout→PushoutGen (push a i) = push (a , refl , refl) i
PushoutGen→Pushout : PushoutGenFib → Pushout f g
PushoutGen→Pushout (inl x) = inl x
PushoutGen→Pushout (inr x) = inr x
PushoutGen→Pushout (push (x , p , q) i) =
((λ i → inl (p (~ i))) ∙∙ push x ∙∙ (λ i → inr (q i))) i
IsoPushoutPushoutGen : Iso (Pushout f g) (PushoutGenFib)
fun IsoPushoutPushoutGen = Pushout→PushoutGen
inv IsoPushoutPushoutGen = PushoutGen→Pushout
rightInv IsoPushoutPushoutGen (inl x) = refl
rightInv IsoPushoutPushoutGen (inr x) = refl
rightInv IsoPushoutPushoutGen (push (x , p , q) i) j = lem x p q j i
where
lem : {b : B} {c : C} (x : A) (p : f x ≡ b) (q : g x ≡ c)
→ cong Pushout→PushoutGen (cong PushoutGen→Pushout (push (x , p , q)))
≡ push (x , p , q)
lem {c = c} x =
J (λ b p → (q : g x ≡ c)
→ cong Pushout→PushoutGen
(cong PushoutGen→Pushout (push (x , p , q)))
≡ push (x , p , q))
(J (λ c q → cong Pushout→PushoutGen
(cong PushoutGen→Pushout (push (x , refl , q)))
≡ push (x , refl , q))
(cong (cong Pushout→PushoutGen) (sym (rUnit (push x)))))
leftInv IsoPushoutPushoutGen (inl x) = refl
leftInv IsoPushoutPushoutGen (inr x) = refl
leftInv IsoPushoutPushoutGen (push a i) j = rUnit (push a) (~ j) i
|
{
"alphanum_fraction": 0.6091977727,
"avg_line_length": 37.8828125,
"ext": "agda",
"hexsha": "35630a5a3defef3330795dc551a8283de61cc38b",
"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/Pushout/Base.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "thomas-lamiaux/cubical",
"max_issues_repo_path": "Cubical/HITs/Pushout/Base.agda",
"max_line_length": 76,
"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/Pushout/Base.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": 1930,
"size": 4849
}
|
{-# OPTIONS --without-K --safe --erased-cubical --no-import-sorts #-}
module SUtil where
open import Prelude
_∈_ : Name → List Name → Bool
n ∈ [] = false
n ∈ (x ∷ ns) = if n == x then true else n ∈ ns
-- treat list as set
insert : Name → List Name → List Name
insert n ns = if n ∈ ns then ns else n ∷ ns
lookup : {A : Type} → List (Name × List A) → Name → List A
lookup [] n = []
lookup ((m , x) ∷ xs) n = if n == m then x else lookup xs n
nameSet : List Name → List Name
nameSet = foldr insert []
iterate : {A : Type} → ℕ → (A → A) → A → A
iterate zero f x = x
iterate (suc k) f x = iterate k f (f x)
2ⁿSpeed : ℕ → List Note → List Note
2ⁿSpeed n = map (iterate n doubleSpeed)
zipFull : {A : Type} → List (List A) → List (List A) → List (List A)
zipFull [] yss = yss
zipFull xss@(_ ∷ _) [] = xss
zipFull (xs ∷ xss) (ys ∷ yss) = (xs ++ ys) ∷ zipFull xss yss
_+1 : {n : ℕ} → Fin n → Fin n
_+1 {suc n} k = (suc (toℕ k)) mod (suc n)
emptyVec : {n : ℕ}{A : Type} → Vec (List A) n
emptyVec {zero} = []
emptyVec {suc n} = [] ∷ emptyVec {n}
foldIntoVector : {n : ℕ} {A : Type} → List (List A) → Vec (List A) (suc n)
foldIntoVector {n} {A} xss = fiv fz emptyVec xss
where fiv : Fin (suc n) → Vec (List A) (suc n) → List (List A) → Vec (List A) (suc n)
fiv k xss [] = xss
fiv k xss (ys ∷ yss) = fiv (k +1) (updateAt k (_++ ys) xss) yss
|
{
"alphanum_fraction": 0.5495750708,
"avg_line_length": 30.6956521739,
"ext": "agda",
"hexsha": "f3774b7b089565c0bc381ad767bbe290da1a3f66",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2020-11-10T04:05:31.000Z",
"max_forks_repo_forks_event_min_datetime": "2020-11-10T04:05:31.000Z",
"max_forks_repo_head_hexsha": "5d9a1bbfbe52f55acf33d960763dce0872689c2b",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "halfaya/Music",
"max_forks_repo_path": "Soundness/agda/SUtil.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "5d9a1bbfbe52f55acf33d960763dce0872689c2b",
"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": "halfaya/Music",
"max_issues_repo_path": "Soundness/agda/SUtil.agda",
"max_line_length": 87,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "5d9a1bbfbe52f55acf33d960763dce0872689c2b",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "halfaya/Music",
"max_stars_repo_path": "Soundness/agda/SUtil.agda",
"max_stars_repo_stars_event_max_datetime": "2020-11-10T04:05:28.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-11-10T04:05:28.000Z",
"num_tokens": 541,
"size": 1412
}
|
------------------------------------------------------------------------
-- Various parser combinator laws
------------------------------------------------------------------------
-- Note that terms like "monad" and "Kleene algebra" are interpreted
-- liberally in the modules listed below.
module TotalParserCombinators.Laws where
open import Algebra
open import Category.Monad
open import Codata.Musical.Notation
open import Data.List as List
import Data.List.Categorical
open import Data.List.Properties
open import Data.List.Relation.Binary.BagAndSetEquality as Eq
using (bag) renaming (_∼[_]_ to _List-∼[_]_)
open import Data.Maybe hiding (_>>=_)
open import Function
import Level
open import Relation.Binary.PropositionalEquality as P using (_≡_)
private
module BagMonoid {k} {A : Set} =
CommutativeMonoid (Eq.commutativeMonoid k A)
open module ListMonad =
RawMonad {f = Level.zero} Data.List.Categorical.monad
using () renaming (_⊛_ to _⊛′_)
open import TotalParserCombinators.Derivative using (D)
open import TotalParserCombinators.Congruence
hiding (return; fail; token)
open import TotalParserCombinators.Lib hiding (module Return⋆)
open import TotalParserCombinators.Parser
------------------------------------------------------------------------
-- Reexported modules
-- Laws related to _∣_.
import TotalParserCombinators.Laws.AdditiveMonoid
module AdditiveMonoid = TotalParserCombinators.Laws.AdditiveMonoid
-- Laws related to D.
import TotalParserCombinators.Laws.Derivative
module D = TotalParserCombinators.Laws.Derivative
hiding (left-zero-⊛; right-zero-⊛;
left-zero->>=; right-zero->>=)
-- Laws related to return⋆.
import TotalParserCombinators.Laws.ReturnStar
module Return⋆ = TotalParserCombinators.Laws.ReturnStar
-- Laws related to _⊛_.
import TotalParserCombinators.Laws.ApplicativeFunctor
module ApplicativeFunctor =
TotalParserCombinators.Laws.ApplicativeFunctor
-- Laws related to _>>=_.
import TotalParserCombinators.Laws.Monad
module Monad = TotalParserCombinators.Laws.Monad
-- Do the parser combinators form a Kleene algebra?
import TotalParserCombinators.Laws.KleeneAlgebra
module KleeneAlgebra = TotalParserCombinators.Laws.KleeneAlgebra
------------------------------------------------------------------------
-- Some laws for _<$>_
module <$> where
open D
-- _<$>_ could have been defined using return and _⊛_.
return-⊛ : ∀ {Tok R₁ R₂ xs} {f : R₁ → R₂} (p : Parser Tok R₁ xs) →
f <$> p ≅P return f ⊛ p
return-⊛ {xs = xs} {f} p =
BagMonoid.reflexive (lemma xs) ∷ λ t → ♯ (
f <$> D t p ≅⟨ return-⊛ (D t p) ⟩
return f ⊛ D t p ≅⟨ sym $ D-return-⊛ f p ⟩
D t (return f ⊛ p) ∎)
where
lemma : ∀ xs → List.map f xs ≡ ([ f ] ⊛′ xs)
lemma [] = P.refl
lemma (x ∷ xs) = P.cong (_∷_ (f x)) $ lemma xs
-- fail is a zero for _<$>_.
zero : ∀ {Tok R₁ R₂} {f : R₁ → R₂} →
f <$> fail {Tok = Tok} ≅P fail
zero {f = f} =
f <$> fail ≅⟨ return-⊛ fail ⟩
return f ⊛ fail ≅⟨ ApplicativeFunctor.right-zero (return f) ⟩
fail ∎
-- A variant of ApplicativeFunctor.homomorphism.
homomorphism : ∀ {Tok R₁ R₂} (f : R₁ → R₂) {x} →
f <$> return {Tok = Tok} x ≅P return (f x)
homomorphism f {x} =
f <$> return x ≅⟨ return-⊛ {f = f} (return x) ⟩
return f ⊛ return x ≅⟨ ApplicativeFunctor.homomorphism f x ⟩
return (f x) ∎
-- Adjacent uses of _<$>_ can be fused.
<$>-<$> : ∀ {Tok R₁ R₂ R₃ xs}
{f : R₂ → R₃} {g : R₁ → R₂} {p : Parser Tok R₁ xs} →
f <$> (g <$> p) ≅P (f ∘ g) <$> p
<$>-<$> = BagMonoid.reflexive (P.sym (map-compose _)) ∷ λ _ → ♯ <$>-<$>
------------------------------------------------------------------------
-- A law for nonempty
module Nonempty where
-- fail is a zero for nonempty.
zero : ∀ {Tok R} → nonempty {Tok = Tok} {R = R} fail ≅P fail
zero = BagMonoid.refl ∷ λ t → ♯ (fail ∎)
-- nonempty (return x) is parser equivalent to fail.
nonempty-return :
∀ {Tok R} {x : R} → nonempty {Tok = Tok} (return x) ≅P fail
nonempty-return = BagMonoid.refl ∷ λ t → ♯ (fail ∎)
-- nonempty can be defined in terms of token, _>>=_ and D.
private
nonempty′ : ∀ {Tok R xs} (p : Parser Tok R xs) → Parser Tok R []
nonempty′ p = token >>= λ t → D t p
nonempty-definable : ∀ {Tok R xs} (p : Parser Tok R xs) →
nonempty p ≅P nonempty′ p
nonempty-definable p = BagMonoid.refl ∷ λ t → ♯ (
D t p ≅⟨ sym $ Monad.left-identity t (λ t′ → D t′ p) ⟩
ret-D t ≅⟨ sym $ AdditiveMonoid.right-identity (ret-D t) ⟩
ret-D t ∣ fail ≅⟨ (ret-D t ∎) ∣ sym (Monad.left-zero _) ⟩
D t (nonempty′ p) ∎)
where ret-D = λ (t : _) → return t >>= (λ t′ → D t′ p)
------------------------------------------------------------------------
-- A law for cast
module Cast where
-- Casts can be erased.
correct : ∀ {Tok R xs₁ xs₂}
{xs₁≈xs₂ : xs₁ List-∼[ bag ] xs₂}
{p : Parser Tok R xs₁} →
cast xs₁≈xs₂ p ≅P p
correct {xs₁≈xs₂ = xs₁≈xs₂} {p} =
BagMonoid.sym xs₁≈xs₂ ∷ λ t → ♯ (D t p ∎)
------------------------------------------------------------------------
-- A law for subst
module Subst where
-- Uses of subst can be erased.
correct : ∀ {Tok R xs₁ xs₂}
(xs₁≡xs₂ : xs₁ ≡ xs₂)
{p : Parser Tok R xs₁} →
P.subst (Parser Tok R) xs₁≡xs₂ p ≅P p
correct P.refl {p} = p ∎
correct∞ : ∀ {Tok R xs₁ xs₂ A} {m : Maybe A}
(xs₁≡xs₂ : xs₁ ≡ xs₂)
(p : ∞⟨ m ⟩Parser Tok R xs₁) →
♭? (P.subst (∞⟨ m ⟩Parser Tok R) xs₁≡xs₂ p) ≅P ♭? p
correct∞ P.refl p = ♭? p ∎
|
{
"alphanum_fraction": 0.5533472803,
"avg_line_length": 31.5164835165,
"ext": "agda",
"hexsha": "bd9161fdb292e9738728527d3c7736cdb8240692",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/parser-combinators",
"max_forks_repo_path": "TotalParserCombinators/Laws.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/parser-combinators",
"max_issues_repo_path": "TotalParserCombinators/Laws.agda",
"max_line_length": 73,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/parser-combinators",
"max_stars_repo_path": "TotalParserCombinators/Laws.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:13.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-07-03T08:56:13.000Z",
"num_tokens": 1838,
"size": 5736
}
|
{-# OPTIONS --without-K #-}
module Util.HoTT.Univalence.Beta where
open import Util.HoTT.Equiv
open import Util.HoTT.Equiv.Induction
open import Util.HoTT.Univalence.Axiom
open import Util.Prelude
open import Util.Relation.Binary.PropositionalEquality using
( Σ-≡⁻ ; cast )
private
variable
α β γ : Level
A B C : Set α
≃→≡-β : ≃→≡ (≃-refl {A = A}) ≡ refl
≃→≡-β = ≃→≡∘≡→≃ refl
cast-≃→≡ : ∀ (A≃B : A ≃ B) {x}
→ cast (≃→≡ A≃B) x ≡ A≃B .forth x
cast-≃→≡ A≃B {x}
= J-≃ (λ A B A≃B → ∀ x → cast (≃→≡ A≃B) x ≡ A≃B .forth x)
(λ A x → subst (λ p → cast p x ≡ x) (sym ≃→≡-β) refl) A≃B x
cast-≅→≡ : ∀ (A≅B : A ≅ B) {x}
→ cast (≅→≡ A≅B) x ≡ A≅B .forth x
cast-≅→≡ = cast-≃→≡ ∘ ≅→≃
|
{
"alphanum_fraction": 0.5357142857,
"avg_line_length": 21.875,
"ext": "agda",
"hexsha": "7df8386167630ade13f4002d427bdb441fd4b1fa",
"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/Beta.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/Beta.agda",
"max_line_length": 65,
"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/Beta.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": 360,
"size": 700
}
|
------------------------------------------------------------------------------
-- Testing records
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module Record where
postulate
D : Set
P₁ : D → Set
P₂ : D → D → Set
record P (a b : D) : Set where
constructor is
field
property₁ : P₁ a
property₂ : P₂ a b
{-# ATP axiom is #-}
postulate
p₁ : ∀ a → P₁ a
p₂ : ∀ a b → P₂ a b
{-# ATP axiom p₁ #-}
{-# ATP axiom p₂ #-}
thm₁ : ∀ a b → P a b
thm₁ a b = is (p₁ a) (p₂ a b)
postulate thm₂ : ∀ a b → P a b
{-# ATP prove thm₂ #-}
|
{
"alphanum_fraction": 0.4072096128,
"avg_line_length": 21.4,
"ext": "agda",
"hexsha": "c951c3f57dc612d444beb223f33046e62a4c21be",
"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/Succeed/fol-theorems/Record.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/Succeed/fol-theorems/Record.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/Succeed/fol-theorems/Record.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": 202,
"size": 749
}
|
module Structure.Container.SetLike.Proofs where
{-
open import Data.Boolean
open import Data.Boolean.Stmt
open import Functional
open import Lang.Instance
import Lvl
open import Logic
open import Logic.Propositional
open import Logic.Predicate
open import Structure.Container.SetLike
open import Structure.Function.Domain
open import Structure.Function
open import Structure.Operator
open import Structure.Relator.Equivalence
open import Structure.Relator.Properties
open import Structure.Relator hiding (module Names)
open import Structure.Setoid renaming (_≡_ to _≡ₛ_ ; _≢_ to _≢ₛ_)
open import Type.Properties.Inhabited
open import Type
private variable ℓ ℓ₁ ℓ₂ ℓ₃ ℓ₄ ℓ₅ ℓ₆ ℓ₇ ℓ₈ ℓ₉ ℓ₁₀ ℓₗ ℓₗ₁ ℓₗ₂ ℓₗ₃ : Lvl.Level
private variable A B C C₁ C₂ Cₒ Cᵢ E E₁ E₂ : Type{ℓ}
private variable _∈_ _∈ₒ_ _∈ᵢ_ : E → C
import Data
import Data.Either as Either
import Data.Tuple as Tuple
open import Logic.Predicate.Theorems
open import Logic.Propositional.Theorems
open import Structure.Relator.Ordering
open import Structure.Relator.Proofs
open import Syntax.Transitivity
module _ ⦃ setLike : SetLike{ℓ₁}{ℓ₁}{ℓ₂}{C}{C} (_∈_) {ℓ₄}{ℓ₅} ⦄ where
open SetLike(setLike)
module _ ⦃ _ : Equiv{ℓₗ}(C) ⦄ where
private
instance
big-intersection-filter-unary-relator : ⦃ _ : Equiv{ℓₗ}(E) ⦄ ⦃ _ : BinaryRelator{B = C}(_∈_) ⦄ → ∀{As} → UnaryRelator(\a → ∀{A} → (A ∈ As) → (a ∈ A))
big-intersection-filter-unary-relator ⦃ [∈]-binaryRelator ⦄ = [∀]-unaryRelator ⦃ rel-P = \{A} → [→]-unaryRelator ⦃ rel-P = const-unaryRelator ⦄ ⦃ rel-Q = BinaryRelator.left (binaryRelator(_∈_)) {A} ⦄ ⦄
filter-big-union-to-big-intersection : ⦃ _ : BinaryRelator(_∈_) ⦄ ⦃ _ : FilterFunction(_∈_){ℓ = ℓ₁ Lvl.⊔ ℓ₂} ⦄ ⦃ _ : BigUnionOperator(_∈_)(_∈_) ⦄ → BigIntersectionOperator(_∈_)(_∈_)
BigIntersectionOperator.⋂ filter-big-union-to-big-intersection As = filter(\a → ∀{A} → (A ∈ As) → (a ∈ A))(⋃ As)
Tuple.left (BigIntersectionOperator.membership filter-big-union-to-big-intersection {As} eAs {a}) p = [↔]-to-[←] Filter.membership ([∧]-intro ([↔]-to-[←] BigUnion.membership ([∃]-map-proof (aAs ↦ [∧]-intro aAs (p aAs)) eAs)) (\{x} → p{x}))
Tuple.right (BigIntersectionOperator.membership filter-big-union-to-big-intersection {As} eAs {a}) xfilter {A} AAs = [∧]-elimᵣ([↔]-to-[→] Filter.membership xfilter) AAs
module _
⦃ _ : Equiv{ℓₗ}(C) ⦄
⦃ _ : BinaryRelator(_∈_) ⦄
where
-- Also called: Russell's paradox.
filter-universal-contradiction : ⦃ _ : FilterFunction(_∈_){ℓ = ℓ₂} ⦄ ⦃ _ : UniversalSet(_∈_) ⦄ → ⊥
filter-universal-contradiction = proof-not-in proof-in where
instance
filter-unary-relator : UnaryRelator(x ↦ (x ∉ x))
filter-unary-relator = [¬]-unaryRelator ⦃ rel-P = binary-unaryRelator ⦄
notInSelf : C
notInSelf = filter (x ↦ (x ∉ x))(𝐔)
proof-not-in : (notInSelf ∉ notInSelf)
proof-not-in pin = [∧]-elimᵣ([↔]-to-[→] Filter.membership pin) pin
proof-in : (notInSelf ∈ notInSelf)
proof-in = [↔]-to-[←] Filter.membership ([∧]-intro Universal.membership proof-not-in)
module _ ⦃ setLike : SetLike{ℓ₁}{ℓ₂}{ℓ₃}{C}{E} (_∈_) {ℓ₄}{ℓ₅} ⦄ where
open SetLike(setLike)
private variable a b c : C
private variable x y z : E
[⊇]-membership : ∀{a b} → (a ⊇ b) ↔ (∀{x} → (x ∈ a) ← (x ∈ b))
[⊇]-membership = [⊆]-membership
module _ ⦃ _ : Equiv{ℓₗ}(E) ⦄ where
pair-to-singleton : ⦃ _ : PairSet(_∈_) ⦄ → SingletonSet(_∈_)
SingletonSet.singleton pair-to-singleton e = pair e e
SingletonSet.membership pair-to-singleton = [↔]-transitivity Pair.membership ([↔]-intro [∨]-introₗ ([∨]-elim id id))
filter-to-empty : let _ = c in ⦃ _ : FilterFunction(_∈_){ℓ = Lvl.𝟎} ⦄ → EmptySet(_∈_)
EmptySet.∅ (filter-to-empty {c = c}) = filter (const ⊥) c
EmptySet.membership filter-to-empty p = [∧]-elimᵣ ([↔]-to-[→] Filter.membership p)
module _
⦃ _ : Equiv{ℓₗ}(C) ⦄
⦃ _ : BinaryRelator(_∈_) ⦄
where
filter-to-intersection : ⦃ _ : FilterFunction(_∈_){ℓ = ℓ₃} ⦄ → IntersectionOperator(_∈_)
IntersectionOperator._∩_ filter-to-intersection a b = filter (_∈ b) ⦃ unaryRelator = BinaryRelator.left infer ⦄ a
IntersectionOperator.membership filter-to-intersection = Filter.membership ⦃ unaryRelator = BinaryRelator.left infer ⦄
module _ ⦃ equivalence : Equivalence(_≡_) ⦄ where
private
instance
[≡]-equiv : Equiv{ℓ₅}(C)
Equiv._≡_ [≡]-equiv = _≡_
Equiv.equivalence [≡]-equiv = equivalence
[∈]-unaryOperatorᵣ : UnaryRelator(x ∈_)
UnaryRelator.substitution [∈]-unaryOperatorᵣ xy = [↔]-to-[→] ([↔]-to-[→] [≡]-membership xy)
module _
⦃ _ : Equiv{ℓₗ₂}(E) ⦄
⦃ _ : Weak.PartialOrder(_⊆_)(_≡_) ⦄
⦃ _ : BinaryRelator(_∈_) ⦄
⦃ _ : (_≡_) ⊆₂ (_⊆_) ⦄
⦃ _ : (_≡_) ⊆₂ (_⊇_) ⦄
where
[⊆]-binaryRelator : BinaryRelator(_⊆_)
BinaryRelator.substitution [⊆]-binaryRelator p1 p2 ps = sub₂(_≡_)(_⊇_) p1 🝖 ps 🝖 sub₂(_≡_)(_⊆_) p2
[⊇]-binaryRelator : BinaryRelator(_⊇_)
BinaryRelator.substitution [⊇]-binaryRelator = swap(substitute₂(_⊆_) ⦃ [⊆]-binaryRelator ⦄)
[≡]-to-[⊆] : (_≡_) ⊆₂ (_⊆_)
_⊆₂_.proof [≡]-to-[⊆] =
[↔]-to-[←] [⊆]-membership
∘ [∀][→]-distributivity [↔]-to-[→]
∘ [↔]-to-[→] [≡]-membership
[≡]-to-[⊇] : (_≡_) ⊆₂ (_⊇_)
_⊆₂_.proof [≡]-to-[⊇] =
[↔]-to-[←] [⊆]-membership
∘ [∀][→]-distributivity [↔]-to-[←]
∘ [↔]-to-[→] [≡]-membership
[⊆]-reflexivity : Reflexivity(_⊆_)
Reflexivity.proof [⊆]-reflexivity = [↔]-to-[←] [⊆]-membership [→]-reflexivity
[⊆]-antisymmetry : Antisymmetry(_⊆_)(_≡_)
Antisymmetry.proof [⊆]-antisymmetry ab ba =
[↔]-to-[←] [≡]-membership ([↔]-intro ([↔]-to-[→] [⊇]-membership ba) ([↔]-to-[→] [⊆]-membership ab))
[⊆]-transitivity : Transitivity(_⊆_)
Transitivity.proof [⊆]-transitivity xy yz =
[↔]-to-[←] [⊆]-membership ([→]-transitivity ([↔]-to-[→] [⊆]-membership xy) ([↔]-to-[→] [⊆]-membership yz))
[⊆]-partialOrder : Weak.PartialOrder(_⊆_)(_≡_)
[⊆]-partialOrder = Weak.intro ⦃ [⊆]-antisymmetry ⦄ ⦃ [⊆]-transitivity ⦄ ⦃ [⊆]-reflexivity ⦄
[≡]-reflexivity : Reflexivity(_≡_)
Reflexivity.proof [≡]-reflexivity = [↔]-to-[←] [≡]-membership [↔]-reflexivity
[≡]-symmetry : Symmetry(_≡_)
Symmetry.proof [≡]-symmetry =
[↔]-to-[←] [≡]-membership
∘ [∀][→]-distributivity [↔]-symmetry
∘ [↔]-to-[→] [≡]-membership
[≡]-transitivity : Transitivity(_≡_)
Transitivity.proof [≡]-transitivity xy yz = [↔]-to-[←] [≡]-membership ([↔]-transitivity ([↔]-to-[→] [≡]-membership xy) ([↔]-to-[→] [≡]-membership yz))
[≡]-equivalence : Equivalence(_≡_)
[≡]-equivalence = intro ⦃ [≡]-reflexivity ⦄ ⦃ [≡]-symmetry ⦄ ⦃ [≡]-transitivity ⦄
-- TODO: These are unneccessary if one uses Structure.Operator.SetAlgebra or lattices
module _ ⦃ _ : EmptySet(_∈_) ⦄ ⦃ _ : UniversalSet(_∈_) ⦄ ⦃ _ : ComplementOperator(_∈_) ⦄ where
∁-of-∅ : (∁(∅) ≡ 𝐔)
∁-of-∅ = [↔]-to-[←] [≡]-membership ([↔]-intro ([↔]-to-[←] Complement.membership ∘ const Empty.membership) (const Universal.membership))
∁-of-𝐔 : (∁(𝐔) ≡ ∅)
∁-of-𝐔 = [↔]-to-[←] [≡]-membership ([↔]-intro ([⊥]-elim ∘ Empty.membership) ([⊥]-elim ∘ apply Universal.membership ∘ [↔]-to-[→] Complement.membership))
module _ ⦃ setLike : SetLike{ℓ₁}{ℓ₂}{ℓ₃}{C}{E} (_∈_) {ℓ₄}{ℓ₅} ⦄ where
open SetLike(setLike)
open import Logic.Classical
open import Structure.Operator.Lattice
open import Structure.Operator.Properties
module _ where
private
instance
equiv-C : Equiv{ℓ₅}(C)
equiv-C = intro(_≡_) ⦃ [≡]-equivalence ⦄
module _ ⦃ _ : ComplementOperator(_∈_) ⦄ where
instance
[∁]-function : Function(∁)
Function.congruence [∁]-function xy =
[↔]-to-[←] [≡]-membership (
Complement.membership ⦗ [↔]-transitivity ⦘ᵣ
[¬]-unaryOperator ([↔]-to-[→] [≡]-membership xy) ⦗ [↔]-transitivity ⦘ᵣ
[↔]-symmetry Complement.membership
)
instance
[∁]-involution : ⦃ _ : ∀{x y} → Classical(x ∈ y) ⦄ → Involution(∁)
Involution.proof [∁]-involution =
[↔]-to-[←] [≡]-membership (
Complement.membership ⦗ [↔]-transitivity ⦘ᵣ
[¬]-unaryOperator Complement.membership ⦗ [↔]-transitivity ⦘ᵣ
[↔]-intro [¬¬]-intro [¬¬]-elim
)
module _ ⦃ _ : UnionOperator(_∈_) ⦄ where
instance
[∪]-binaryOperator : BinaryOperator(_∪_)
BinaryOperator.congruence [∪]-binaryOperator xy₁ xy₂ =
[↔]-to-[←] [≡]-membership (
Union.membership ⦗ [↔]-transitivity ⦘ᵣ
[↔]-intro (Either.map ([↔]-to-[←] ([↔]-to-[→] [≡]-membership xy₁)) ([↔]-to-[←] ([↔]-to-[→] [≡]-membership xy₂))) (Either.map ([↔]-to-[→] ([↔]-to-[→] [≡]-membership xy₁)) ([↔]-to-[→] ([↔]-to-[→] [≡]-membership xy₂))) ⦗ [↔]-transitivity ⦘ᵣ
[↔]-symmetry Union.membership
)
instance
[∪]-commutativity : Commutativity(_∪_)
Commutativity.proof [∪]-commutativity {x} {y} =
[↔]-to-[←] [≡]-membership (
Union.membership ⦗ [↔]-transitivity ⦘ᵣ
[↔]-intro [∨]-symmetry [∨]-symmetry ⦗ [↔]-transitivity ⦘ᵣ
[↔]-symmetry Union.membership
)
instance
[∪]-associativity : Associativity(_∪_)
Associativity.proof [∪]-associativity {x} {y} =
[↔]-to-[←] [≡]-membership (
Union.membership ⦗ [↔]-transitivity ⦘ᵣ
[↔]-intro (Either.mapLeft ([↔]-to-[←] Union.membership)) (Either.mapLeft ([↔]-to-[→] Union.membership)) ⦗ [↔]-transitivity ⦘ᵣ
[∨]-associativity ⦗ [↔]-transitivity ⦘ᵣ
[↔]-symmetry([↔]-intro (Either.mapRight ([↔]-to-[←] Union.membership)) (Either.mapRight ([↔]-to-[→] Union.membership))) ⦗ [↔]-transitivity ⦘ᵣ
[↔]-symmetry Union.membership
)
module _ ⦃ _ : EmptySet(_∈_) ⦄ where
instance
[∪]-identityₗ : Identityₗ(_∪_)(∅)
Identityₗ.proof [∪]-identityₗ {x} =
[↔]-to-[←] [≡]-membership (
Union.membership ⦗ [↔]-transitivity ⦘ᵣ
[↔]-intro (Either.mapLeft [⊥]-elim) (Either.mapLeft Empty.membership) ⦗ [↔]-transitivity ⦘ᵣ
[↔]-intro [∨]-introᵣ [∨]-identityₗ
)
module _ ⦃ _ : IntersectionOperator(_∈_) ⦄ where
instance
[∩]-binaryOperator : BinaryOperator(_∩_)
BinaryOperator.congruence [∩]-binaryOperator xy₁ xy₂ =
[↔]-to-[←] [≡]-membership (
Intersection.membership ⦗ [↔]-transitivity ⦘ᵣ
[↔]-intro (Tuple.map ([↔]-to-[←] ([↔]-to-[→] [≡]-membership xy₁)) ([↔]-to-[←] ([↔]-to-[→] [≡]-membership xy₂))) (Tuple.map ([↔]-to-[→] ([↔]-to-[→] [≡]-membership xy₁)) ([↔]-to-[→] ([↔]-to-[→] [≡]-membership xy₂))) ⦗ [↔]-transitivity ⦘ᵣ
[↔]-symmetry Intersection.membership
)
instance
[∩]-commutativity : Commutativity(_∩_)
Commutativity.proof [∩]-commutativity {x} {y} =
[↔]-to-[←] [≡]-membership (
Intersection.membership ⦗ [↔]-transitivity ⦘ᵣ
[↔]-intro [∧]-symmetry [∧]-symmetry ⦗ [↔]-transitivity ⦘ᵣ
[↔]-symmetry Intersection.membership
)
instance
[∩]-associativity : Associativity(_∩_)
Associativity.proof [∩]-associativity {x} {y} =
[↔]-to-[←] [≡]-membership (
Intersection.membership ⦗ [↔]-transitivity ⦘ᵣ
[↔]-intro (Tuple.mapLeft ([↔]-to-[←] Intersection.membership)) (Tuple.mapLeft ([↔]-to-[→] Intersection.membership)) ⦗ [↔]-transitivity ⦘ᵣ
[∧]-associativity ⦗ [↔]-transitivity ⦘ᵣ
[↔]-symmetry([↔]-intro (Tuple.mapRight ([↔]-to-[←] Intersection.membership)) (Tuple.mapRight ([↔]-to-[→] Intersection.membership))) ⦗ [↔]-transitivity ⦘ᵣ
[↔]-symmetry Intersection.membership
)
module _ ⦃ _ : UniversalSet(_∈_) ⦄ where
instance
[∩]-identityₗ : Identityₗ(_∩_)(𝐔)
Identityₗ.proof [∩]-identityₗ {x} =
[↔]-to-[←] [≡]-membership (
Intersection.membership ⦗ [↔]-transitivity ⦘ᵣ
[↔]-intro (Tuple.mapLeft {ℓ₁} (const Universal.membership)) (Tuple.mapLeft (const [⊤]-intro)) ⦗ [↔]-transitivity ⦘ᵣ
[↔]-intro ([∧]-intro [⊤]-intro) [∧]-elimᵣ
)
module _ ⦃ _ : UnionOperator(_∈_) ⦄ ⦃ _ : IntersectionOperator(_∈_) ⦄ where
instance
[∩][∪]-distributivityₗ : Distributivityₗ(_∩_)(_∪_)
Distributivityₗ.proof [∩][∪]-distributivityₗ {x} {y} {z} =
[↔]-to-[←] [≡]-membership (
Intersection.membership ⦗ [↔]-transitivity ⦘ᵣ
[↔]-intro (Tuple.mapRight ([↔]-to-[←] Union.membership)) (Tuple.mapRight ([↔]-to-[→] Union.membership)) ⦗ [↔]-transitivity ⦘ᵣ
[∧][∨]-distributivityₗ ⦗ [↔]-transitivity ⦘ᵣ
[↔]-intro (Either.map ([↔]-to-[→] Intersection.membership) ([↔]-to-[→] Intersection.membership)) (Either.map ([↔]-to-[←] Intersection.membership) ([↔]-to-[←] Intersection.membership)) ⦗ [↔]-transitivity ⦘ᵣ
[↔]-symmetry Union.membership
)
instance
[∪][∩]-distributivityₗ : Distributivityₗ(_∪_)(_∩_)
Distributivityₗ.proof [∪][∩]-distributivityₗ {x} {y} {z} =
[↔]-to-[←] [≡]-membership (
Union.membership ⦗ [↔]-transitivity ⦘ᵣ
[↔]-intro (Either.mapRight ([↔]-to-[←] Intersection.membership)) (Either.mapRight ([↔]-to-[→] Intersection.membership)) ⦗ [↔]-transitivity ⦘ᵣ
[∨][∧]-distributivityₗ ⦗ [↔]-transitivity ⦘ᵣ
[↔]-intro (Tuple.map ([↔]-to-[→] Union.membership) ([↔]-to-[→] Union.membership)) (Tuple.map ([↔]-to-[←] Union.membership) ([↔]-to-[←] Union.membership)) ⦗ [↔]-transitivity ⦘ᵣ
[↔]-symmetry Intersection.membership
)
instance
[∩][∪]-absorptionₗ : Absorptionₗ(_∩_)(_∪_)
Absorptionₗ.proof [∩][∪]-absorptionₗ {x} {y} =
[↔]-to-[←] [≡]-membership (
Intersection.membership ⦗ [↔]-transitivity ⦘
[↔]-intro (ax ↦ [∧]-intro ax ([↔]-to-[←] Union.membership ([∨]-introₗ ax))) [∧]-elimₗ
)
instance
[∪][∩]-absorptionₗ : Absorptionₗ(_∪_)(_∩_)
Absorptionₗ.proof [∪][∩]-absorptionₗ {x} {y} =
[↔]-to-[←] [≡]-membership (
Union.membership ⦗ [↔]-transitivity ⦘
[↔]-intro [∨]-introₗ ([∨]-elim id ([∧]-elimₗ ∘ [↔]-to-[→] Intersection.membership))
)
instance
[∪][∩]-lattice : Lattice(C) (_∪_)(_∩_)
Lattice.[∨]-operator [∪][∩]-lattice = [∪]-binaryOperator
Lattice.[∧]-operator [∪][∩]-lattice = [∩]-binaryOperator
Lattice.[∨]-commutativity [∪][∩]-lattice = [∪]-commutativity
Lattice.[∧]-commutativity [∪][∩]-lattice = [∩]-commutativity
Lattice.[∨]-associativity [∪][∩]-lattice = [∪]-associativity
Lattice.[∧]-associativity [∪][∩]-lattice = [∩]-associativity
Lattice.[∨][∧]-absorptionₗ [∪][∩]-lattice = [∪][∩]-absorptionₗ
Lattice.[∧][∨]-absorptionₗ [∪][∩]-lattice = [∩][∪]-absorptionₗ
instance
[∪][∩]-distributiveLattice : Lattice.Distributive([∪][∩]-lattice)
[∪][∩]-distributiveLattice = intro
module _ ⦃ _ : EmptySet(_∈_) ⦄ ⦃ _ : UniversalSet(_∈_) ⦄ where
instance
[∪][∩]-boundedLattice : Lattice.Bounded([∪][∩]-lattice)(∅)(𝐔)
Lattice.Bounded.[∨]-identityₗ [∪][∩]-boundedLattice = [∪]-identityₗ
Lattice.Bounded.[∧]-identityₗ [∪][∩]-boundedLattice = [∩]-identityₗ
module _ ⦃ _ : ComplementOperator(_∈_) ⦄ where
-}
|
{
"alphanum_fraction": 0.5646756583,
"avg_line_length": 45.1304347826,
"ext": "agda",
"hexsha": "62460984e51531d7d05d3425d44a1599fd9868ae",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Structure/Container/SetLike/Proofs.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Structure/Container/SetLike/Proofs.agda",
"max_line_length": 249,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Structure/Container/SetLike/Proofs.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": 6125,
"size": 15570
}
|
module Issue835 where
data _≡_ {A : Set} (x : A) : A → Set where
refl : x ≡ x
postulate
A : Set
x y : A
F : x ≡ y → Set
F ()
|
{
"alphanum_fraction": 0.5073529412,
"avg_line_length": 9.7142857143,
"ext": "agda",
"hexsha": "294de7e13ce27566c48cc7868a767ed948726ad4",
"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/Issue835.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/Issue835.agda",
"max_line_length": 42,
"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/Issue835.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": 60,
"size": 136
}
|
-- 2014-05-02
-- This looped in the epic backend after Andreas' big projection refactoring (Oct 2013)
data ℕ : Set where
zero : ℕ
suc : (n : ℕ) → ℕ
{-# BUILTIN NATURAL ℕ #-} -- Essential
f : ℕ → ℕ
f zero = zero
f (suc m) = m
postulate
IO : Set → Set
{-# COMPILED_TYPE IO IO #-}
postulate
return : ∀ {A} → A → IO A
{-# COMPILED_EPIC return (u1 : Unit, a : Any) -> Any = ioreturn(a) #-}
main : IO ℕ
main = return zero
|
{
"alphanum_fraction": 0.5886363636,
"avg_line_length": 16.2962962963,
"ext": "agda",
"hexsha": "67caa7a87b66125ff812e65c37f4fc5141dc8611",
"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/Succeed/Issue1119.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/Succeed/Issue1119.agda",
"max_line_length": 87,
"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/Succeed/Issue1119.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 157,
"size": 440
}
|
module Issue4924 where
record R (T : Set) : Set where
field
f : T → T
module _ {A B : Set} (ra : R A) (rb : R B) (pri : {T : Set} → {{r : R T}} → T) where
open R ra
open R rb
instance
_ = ra
_ : A
_ = f pri
|
{
"alphanum_fraction": 0.4978354978,
"avg_line_length": 14.4375,
"ext": "agda",
"hexsha": "f2f95f00f06058b5efdbdf50459e6c69617aa556",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "shlevy/agda",
"max_forks_repo_path": "test/Fail/Issue4924.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/Issue4924.agda",
"max_line_length": 84,
"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/Issue4924.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": 96,
"size": 231
}
|
{-# OPTIONS --without-K --safe #-}
-- https://www.cs.bham.ac.uk/~mhe/papers/omniscient-journal-revised.pdf
module Constructive.Omniscience where
open import Level renaming (zero to lzero; suc to lsuc)
import Data.Bool as 𝔹 using (_≤_)
open import Data.Bool as 𝔹 using (Bool; true; false; T; f≤t; b≤b; _∧_; not; _∨_)
import Data.Bool.Properties as 𝔹ₚ
open import Data.Empty
open import Data.Unit using (tt)
open import Data.Nat
open import Data.Nat.Properties
open import Data.Product as Prod
open import Data.Sum as Sum
open import Function.Base
open import Relation.Binary as B
open import Relation.Binary.PropositionalEquality
open import Relation.Nullary
open import Relation.Nullary.Decidable
import Relation.Unary as U
-- agda-misc
open import Constructive.Axiom
open import Constructive.Axiom.Properties
open import Constructive.Axiom.Properties.Base.Lemma
open import Constructive.Common
open import Constructive.Combinators
ℕ∞ : Set
ℕ∞ = Σ (ℕ → Bool) λ x → ∀ i → T (x (suc i)) → T (x i)
⟦_⟧C : ℕ → ℕ → Bool
⟦ n ⟧C = λ m → isYes (m <? n)
⟦_⟧C-con : ∀ n i → T (⟦ n ⟧C (suc i)) → T (⟦ n ⟧C i)
⟦ n ⟧C-con i True[si<n] = fromWitness (m+n≤o⇒n≤o 1 $ toWitness True[si<n])
⟦_⟧ : ℕ → ℕ∞
⟦ n ⟧ = ⟦ n ⟧C , ⟦ n ⟧C-con
∞ : ℕ∞
∞ = (λ _ → true) , (λ i _ → tt)
_≈_ : Rel (ℕ → Bool) lzero
α ≈ β = ∀ i → α i ≡ β i
_≉_ : Rel (ℕ → Bool) lzero
α ≉ β = ¬ (α ≈ β)
_#_ : Rel (ℕ → Bool) lzero
α # β = ∃ λ i → α i ≢ β i
#⇒≉ : {α β : ℕ → Bool} → α # β → α ≉ β
#⇒≉ {α} {β} (i , αi≢βi) α≈β = αi≢βi (α≈β i)
≈-refl : {α : ℕ → Bool} → α ≈ α
≈-refl _ = refl
≈-sym : {α β : ℕ → Bool} → α ≈ β → β ≈ α
≈-sym α≈β i = sym (α≈β i)
≈-trans : {α β γ : ℕ → Bool} → α ≈ β → β ≈ γ → α ≈ γ
≈-trans α≈β β≈γ i = trans (α≈β i) (β≈γ i)
_≈∞_ : Rel ℕ∞ lzero
x ≈∞ y = proj₁ x ≈ proj₁ y
_≉∞_ : Rel ℕ∞ lzero
x ≉∞ y = proj₁ x ≉ proj₁ y
_#∞_ : Rel ℕ∞ lzero
x #∞ y = proj₁ x # proj₁ y
⟦⟧-cong : ∀ {m n} → m ≡ n → ⟦ m ⟧ ≈∞ ⟦ n ⟧
⟦⟧-cong {m} {n} m≡n i = cong (λ x → ⟦ x ⟧C i) m≡n
-- Proposition 3.1
-- r = ≤-all
≤-all : (ℕ → Bool) → (ℕ → Bool)
≤-all α zero = α 0
≤-all α (suc n) = α (suc n) ∧ ≤-all α n
≤-all-idem : ∀ α → ≤-all (≤-all α) ≈ ≤-all α
≤-all-idem α zero = refl
≤-all-idem α (suc n) = begin
(α (suc n) ∧ ≤-all α n) ∧ ≤-all (≤-all α) n
≡⟨ cong ((α (suc n) ∧ ≤-all α n) ∧_) $ ≤-all-idem α n ⟩
(α (suc n) ∧ ≤-all α n) ∧ ≤-all α n
≡⟨ 𝔹ₚ.∧-assoc (α (suc n)) (≤-all α n) (≤-all α n) ⟩
α (suc n) ∧ (≤-all α n ∧ ≤-all α n)
≡⟨ cong (α (suc n) ∧_) $ 𝔹ₚ.∧-idem (≤-all α n) ⟩
α (suc n) ∧ ≤-all α n
∎
where open ≡-Reasoning
private
T-∧-× : ∀ {x y} → T (x ∧ y) → (T x × T y)
T-∧-× {true} {true} t = tt , tt
T-×-∧ : ∀ {x y} → (T x × T y) → T (x ∧ y)
T-×-∧ {true} {true} (tt , tt) = tt
≤⇒≡∨< : ∀ {m n} → m ≤ n → (m ≡ n) ⊎ (m < n)
≤⇒≡∨< {m} {n} m≤n with m ≟ n
... | yes m≡n = inj₁ m≡n
... | no m≢n = inj₂ (≤∧≢⇒< m≤n m≢n)
≤-all-convergent : ∀ α i → T (≤-all α (suc i)) → T (≤-all α i)
≤-all-convergent α n t = proj₂ (T-∧-× t)
≤-all-ℕ∞ : (ℕ → Bool) → ℕ∞
≤-all-ℕ∞ α = ≤-all α , ≤-all-convergent α
≤-all-extract-by-≤ : ∀ α {n k} → k ≤ n → T (≤-all α n) → T (α k)
≤-all-extract-by-≤ α {zero} {.0} z≤n t = t
≤-all-extract-by-≤ α {suc n} {zero} z≤n t =
≤-all-extract-by-≤ α {n} {0} z≤n (proj₂ (T-∧-× t))
≤-all-extract-by-≤ α {suc n} {suc k} (s≤s k≤n) t with ≤⇒≡∨< k≤n
... | inj₁ k≡n = subst (T ∘′ α ∘′ suc) (sym k≡n) (proj₁ (T-∧-× t))
... | inj₂ suck≤n = ≤-all-extract-by-≤ α suck≤n (proj₂ (T-∧-× t))
≤-all-extract : ∀ α n → T (≤-all α n) → T (α n)
≤-all-extract α n = ≤-all-extract-by-≤ α ≤-refl
≤-all-construct : ∀ α n → (∀ k → k ≤ n → T (α k)) → T (≤-all α n)
≤-all-construct α zero f = f zero ≤-refl
≤-all-construct α (suc n) f =
T-×-∧ ((f (suc n) ≤-refl) , ≤-all-construct α n λ k k≤n → f k (≤-step k≤n))
private
not-injective : ∀ {x y} → not x ≡ not y → x ≡ y
not-injective {false} {false} refl = refl
not-injective {true} {true} refl = refl
x≢y⇒not[x]≡y : ∀ {x y} → x ≢ y → not x ≡ y
x≢y⇒not[x]≡y {false} {false} x≢y = contradiction refl x≢y
x≢y⇒not[x]≡y {false} {true} x≢y = refl
x≢y⇒not[x]≡y {true} {false} x≢y = refl
x≢y⇒not[x]≡y {true} {true} x≢y = contradiction refl x≢y
x≡y⇒not[x]≢y : ∀ {x y} → x ≡ y → not x ≢ y
x≡y⇒not[x]≢y {false} {false} p ()
x≡y⇒not[x]≢y {false} {true} () q
x≡y⇒not[x]≢y {true} {false} () q
x≡y⇒not[x]≢y {true} {true} p ()
not[x]≢y⇒x≡y : ∀ {x y} → not x ≢ y → x ≡ y
not[x]≢y⇒x≡y {x} {y} not[x]≢y =
subst (_≡ y) (𝔹ₚ.not-involutive x) $ x≢y⇒not[x]≡y not[x]≢y
not[x]≡y⇒x≢y : ∀ {x y} → not x ≡ y → x ≢ y
not[x]≡y⇒x≢y not[x]≡y x≡y = x≡y⇒not[x]≢y x≡y not[x]≡y
-- LPO-Bool <=> ∀ x → (x #∞ ∞) ⊎ (x ≈∞ ∞)
lpo-Bool⇒∀x→x#∞⊎x≈∞ : LPO-Bool ℕ → ∀ x → (x #∞ ∞) ⊎ (x ≈∞ ∞)
lpo-Bool⇒∀x→x#∞⊎x≈∞ lpo-Bool (α , con) with lpo-Bool λ n → not (α n)
... | inj₁ (x , not[αx]≡true) = inj₁ (x , not[x]≡y⇒x≢y not[αx]≡true)
... | inj₂ ¬∃x→not[αx]≡true =
inj₂ λ i → not[x]≢y⇒x≡y $′ ¬∃P→∀¬P ¬∃x→not[αx]≡true i
private
T-to-≡ : ∀ {x} → T x → x ≡ true
T-to-≡ {true} tx = refl
≡-to-T : ∀ {x} → x ≡ true → T x
≡-to-T {true} x≡true = tt
T-¬-not : ∀ {x} → ¬ (T x) → T (not x)
T-¬-not {false} n = tt
T-¬-not {true} n = n tt
T-not-¬ : ∀ {x} → T (not x) → ¬ (T x)
T-not-¬ {false} tt ()
T-not-¬ {true} () y
¬-T-not-to-T : ∀ {x} → ¬ T (not x) → T x
¬-T-not-to-T {x} ¬Tnotx = subst T (𝔹ₚ.not-involutive x) $ T-¬-not ¬Tnotx
≤-to-→ : ∀ {x y} → x 𝔹.≤ y → T x → T y
≤-to-→ {true} {true} x≤y _ = tt
→-to-≤ : ∀ {x y} → (T x → T y) → x 𝔹.≤ y
→-to-≤ {false} {false} Tx→Ty = b≤b
→-to-≤ {false} {true} Tx→Ty = f≤t
→-to-≤ {true} {false} Tx→Ty = ⊥-elim (Tx→Ty tt)
→-to-≤ {true} {true} Tx→Ty = b≤b
T-≡ : ∀ {x y} → (T x → T y) → (T y → T x) → x ≡ y
T-≡ Tx→Ty Ty→Tx = 𝔹ₚ.≤-antisym (→-to-≤ Tx→Ty) (→-to-≤ Ty→Tx)
¬T-≤-all-to-≤ : ∀ α n → ¬ T (≤-all α n) → ∃ λ k → k ≤ n × ¬ T (α k)
¬T-≤-all-to-≤ α zero ¬T with 𝔹ₚ.T? (α 0)
... | yes Tα0 = contradiction Tα0 ¬T
... | no ¬Tα0 = 0 , (z≤n , ¬Tα0)
¬T-≤-all-to-≤ α (suc n) ¬T with 𝔹ₚ.T? (α (suc n))
... | yes Tαsn =
Prod.map₂ (Prod.map₁ ≤-step) $
¬T-≤-all-to-≤ α n (contraposition (λ T≤-allαn → T-×-∧ (Tαsn , T≤-allαn)) ¬T)
... | no ¬Tαsn = suc n , ≤-refl , ¬Tαsn
¬T-≤-all-to-≤′ : ∀ α n → ¬ T (≤-all (not ∘′ α) n) → ∃ λ k → k ≤ n × T (α k)
¬T-≤-all-to-≤′ α n ¬T with ¬T-≤-all-to-≤ (not ∘ α) n ¬T
... | (k , k≤n , ¬Tnotαn) = k , (k≤n , ¬-T-not-to-T ¬Tnotαn)
¬T-≤-all-to-∃ : ∀ α n → ¬ T (≤-all α n) → ∃ λ k → ¬ T (α k)
¬T-≤-all-to-∃ α n ¬T = Prod.map₂ proj₂ (¬T-≤-all-to-≤ α n ¬T)
¬T-≤-all-to-∃′ : ∀ α n → ¬ T (≤-all (not ∘′ α) n) → ∃ λ k → T (α k)
¬T-≤-all-to-∃′ α n ¬T = Prod.map₂ proj₂ (¬T-≤-all-to-≤′ α n ¬T)
≤-to-¬T-≤-all : ∀ α n → ∃ (λ k → k ≤ n × ¬ T (α k)) → ¬ T (≤-all α n)
≤-to-¬T-≤-all α n (k , k≤n , ¬Tαk) ttt = ¬Tαk (≤-all-extract-by-≤ α k≤n ttt)
∀x→x#∞⊎x≈∞⇒lpo-Bool : (∀ x → (x #∞ ∞) ⊎ (x ≈∞ ∞)) → LPO-Bool ℕ
∀x→x#∞⊎x≈∞⇒lpo-Bool ≈∞? P with ≈∞? (≤-all-ℕ∞ (λ n → not (P n)))
... | inj₁ (x , ≤-all[not∘P,x]≢true) =
inj₁ (Prod.map₂ T-to-≡ (¬T-≤-all-to-∃′ P x
(contraposition T-to-≡ ≤-all[not∘P,x]≢true)))
... | inj₂ ∀i→≤-all[not∘P,i]≡true =
inj₂ (∀¬P→¬∃P λ i → not[x]≡y⇒x≢y (T-to-≡ $ ≤-all-extract (not ∘ P) i $
≡-to-T (∀i→≤-all[not∘P,i]≡true i)))
-- Theorem 3.5
ε : (ℕ∞ → Bool) → ℕ∞
ε p = ≤-all-ℕ∞ λ n → p ⟦ n ⟧
T-⟦⟧C-to-< : ∀ {n i} → T (⟦ n ⟧C i) → i < n
T-⟦⟧C-to-< t = toWitness t
<-to-T-⟦⟧C : ∀ {n i} → i < n → T (⟦ n ⟧C i)
<-to-T-⟦⟧C i<n = fromWitness i<n
lemma-1-forward : ∀ (p : ℕ∞ → Bool) n →
ε p ≈∞ ⟦ n ⟧ → ¬ T (p ⟦ n ⟧) × (∀ k → k < n → T (p ⟦ k ⟧))
lemma-1-forward p n εp≈∞⟦n⟧ = ¬T[p⟦n⟧] , i<n⇒Tp⟦i⟧
where
∀i→≤-all[p∘⟦⟧,i]≡⟦n⟧Ci : ∀ i → ≤-all (λ m → p ⟦ m ⟧) i ≡ ⟦ n ⟧C i
∀i→≤-all[p∘⟦⟧,i]≡⟦n⟧Ci = εp≈∞⟦n⟧
i<n⇒Tp⟦i⟧ : ∀ i → i < n → T (p ⟦ i ⟧)
i<n⇒Tp⟦i⟧ i i<n = ≤-all-extract (p ∘′ ⟦_⟧) i T[≤-all[p∘⟦⟧,i]]
where
⟦n⟧Ci≡true : ⟦ n ⟧C i ≡ true
⟦n⟧Ci≡true = T-to-≡ (<-to-T-⟦⟧C i<n)
≤-all[p∘⟦⟧,i]≡true : ≤-all (λ m → p ⟦ m ⟧) i ≡ true
≤-all[p∘⟦⟧,i]≡true = trans (∀i→≤-all[p∘⟦⟧,i]≡⟦n⟧Ci i) ⟦n⟧Ci≡true
T[≤-all[p∘⟦⟧,i]] : T (≤-all (λ m → p ⟦ m ⟧) i)
T[≤-all[p∘⟦⟧,i]] = ≡-to-T ≤-all[p∘⟦⟧,i]≡true
¬T[p⟦n⟧] : ¬ T (p ⟦ n ⟧)
¬T[p⟦n⟧] = contraposition (subst (T ∘′ p ∘′ ⟦_⟧) (sym m≡n)) ¬T[p⟦m⟧]
where
⟦n⟧Cn≡false : ⟦ n ⟧C n ≡ false
⟦n⟧Cn≡false = not-injective (T-to-≡ (T-¬-not (contraposition T-⟦⟧C-to-< (n≮n n))))
≤-all[p∘⟦⟧,n]≡false : ≤-all (λ m → p ⟦ m ⟧) n ≡ false
≤-all[p∘⟦⟧,n]≡false = trans (∀i→≤-all[p∘⟦⟧,i]≡⟦n⟧Ci n) ⟦n⟧Cn≡false
¬T-≤-all[p∘⟦⟧,n] : ¬ T (≤-all (λ m → p ⟦ m ⟧) n)
¬T-≤-all[p∘⟦⟧,n] = T-not-¬ (≡-to-T (cong not ≤-all[p∘⟦⟧,n]≡false))
∃m→m≤n׬T[p⟦m⟧] : ∃ λ m → m ≤ n × ¬ T (p ⟦ m ⟧)
∃m→m≤n׬T[p⟦m⟧] = ¬T-≤-all-to-≤ (p ∘′ ⟦_⟧) n ¬T-≤-all[p∘⟦⟧,n]
m : ℕ
m = proj₁ ∃m→m≤n׬T[p⟦m⟧]
m≤n : m ≤ n
m≤n = proj₁ (proj₂ ∃m→m≤n׬T[p⟦m⟧])
¬T[p⟦m⟧] : ¬ T (p ⟦ m ⟧)
¬T[p⟦m⟧] = proj₂ (proj₂ ∃m→m≤n׬T[p⟦m⟧])
m≮n : m ≮ n
m≮n m<n = ¬T[p⟦m⟧] (i<n⇒Tp⟦i⟧ m m<n)
m≡n : m ≡ n
m≡n = ≤-antisym m≤n (≮⇒≥ m≮n)
lemma-1-backwards : ∀ (p : ℕ∞ → Bool) n →
¬ T (p ⟦ n ⟧) × (∀ k → k < n → T (p ⟦ k ⟧)) →
ε p ≈∞ ⟦ n ⟧
lemma-1-backwards p n (¬Tp⟦n⟧ , ∀k→k<n→Tp⟦k⟧) = ∀i→≤-all[p∘⟦⟧,i]≡⟦n⟧Ci
where
open ≡-Reasoning
∀i→≤-all[p∘⟦⟧,i]≡⟦n⟧Ci : ∀ i → ≤-all (λ m → p ⟦ m ⟧) i ≡ ⟦ n ⟧C i
∀i→≤-all[p∘⟦⟧,i]≡⟦n⟧Ci i with n ≤? i
... | yes n≤i = trans (not-injective (T-to-≡ (T-¬-not ¬T≤-all[p∘⟦⟧,i])))
(sym ⟦n⟧Ci≡false)
where
⟦n⟧Ci≡false : ⟦ n ⟧C i ≡ false
⟦n⟧Ci≡false = not-injective (T-to-≡ (T-¬-not (contraposition T-⟦⟧C-to-< (≤⇒≯ n≤i))))
¬T≤-all[p∘⟦⟧,i] : ¬ T (≤-all (λ m → p ⟦ m ⟧) i)
¬T≤-all[p∘⟦⟧,i] t = ¬Tp⟦n⟧ (≤-all-extract-by-≤ (p ∘′ ⟦_⟧) n≤i t)
... | no n≰i = begin
≤-all (λ m → p ⟦ m ⟧) i
≡⟨ T-to-≡ (≤-all-construct (p ∘ ⟦_⟧) i
λ k k≤i → ∀k→k<n→Tp⟦k⟧ k (<-transʳ k≤i i<n)) ⟩
true
≡⟨ sym $ T-to-≡ (<-to-T-⟦⟧C i<n) ⟩
⟦ n ⟧C i
∎
where i<n = ≰⇒> n≰i
{-
pp : ℕ∞ → Bool
pp (x , _) = not (x 0) ∨ (x 0 ∧ not (x 1))
-}
ε-correct : (P : ℕ∞ → Bool) → P (ε P) ≡ true → ∀ x → P x ≡ true
ε-correct P P[εP]≡true x = {! !}
searchable-Bool : Searchable-Bool ℕ∞
searchable-Bool = ε , ε-correct
|
{
"alphanum_fraction": 0.4531234629,
"avg_line_length": 31.6666666667,
"ext": "agda",
"hexsha": "17dde8c91097ccf92aff0334d81ed403c9ec42cd",
"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": "Constructive/Omniscience.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": "Constructive/Omniscience.agda",
"max_line_length": 88,
"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": "Constructive/Omniscience.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": 6039,
"size": 10165
}
|
-- Some very simple problems just to test that things work properly.
-- If everything has been installed properly following
--
-- https://github.com/HoTT/EPIT-2020/tree/main/04-cubical-type-theory#installation-of-cubical-agda-and-agdacubical
--
-- then this file should load fine and one should get 4 holes which
-- one can fill with appropriate terms. Everything should work with
-- both Agda 2.6.1.3 and agda/cubical v0.2 as well as with the
-- development version of both Agda and agda/cubical.
--
-- Solution how to fill the holes is written at the bottom of the file.
--
{-# OPTIONS --cubical #-}
module Warmup where
open import Part1
variable
A B C : Type ℓ
-- Cong/ap satisfies a lot of nice equations:
congRefl : (f : A → B) {x : A} → cong f (refl {x = x}) ≡ refl
congRefl f = {!!}
congId : {x y : A} (p : x ≡ y) → cong id p ≡ p
congId p = {!!}
_∘_ : (g : B → C) (f : A → B) → A → C
(g ∘ f) x = g (f x)
congComp : (f : A → B) (g : B → C) {x y : A} (p : x ≡ y) →
cong (g ∘ f) p ≡ cong g (cong f p)
congComp f g x = {!!}
-- Sym is an involution:
symInv : {x y : A} (p : x ≡ y) → sym (sym p) ≡ p
symInv p = {!!}
-- Solution: replace all holes by refl
|
{
"alphanum_fraction": 0.6044407895,
"avg_line_length": 15.3924050633,
"ext": "agda",
"hexsha": "07536f56aa3bdd58aa7ea74200ad7315342fff9a",
"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": "54b18e4adf890b3533bbefda373912423be7f490",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "tomdjong/EPIT-2020",
"max_forks_repo_path": "04-cubical-type-theory/material/Warmup.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "54b18e4adf890b3533bbefda373912423be7f490",
"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": "tomdjong/EPIT-2020",
"max_issues_repo_path": "04-cubical-type-theory/material/Warmup.agda",
"max_line_length": 114,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "54b18e4adf890b3533bbefda373912423be7f490",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "tomdjong/EPIT-2020",
"max_stars_repo_path": "04-cubical-type-theory/material/Warmup.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 411,
"size": 1216
}
|
------------------------------------------------------------------------
-- INCREMENTAL λ-CALCULUS
--
-- Values for standard evaluation (Def. 3.1 and 3.2, Fig. 4c and 4f).
------------------------------------------------------------------------
import Parametric.Syntax.Type as Type
module Parametric.Denotation.Value
(Base : Type.Structure)
where
open import Base.Denotation.Notation
open Type.Structure Base
-- Extension point: Values for base types.
Structure : Set₁
Structure = Base → Set
module Structure (⟦_⟧Base : Structure) where
-- We provide: Values for arbitrary types.
⟦_⟧Type : Type → Set
⟦ base ι ⟧Type = ⟦ ι ⟧Base
⟦ σ ⇒ τ ⟧Type = ⟦ σ ⟧Type → ⟦ τ ⟧Type
instance
-- This means: Overload ⟦_⟧ to mean ⟦_⟧Type.
meaningOfType : Meaning Type
meaningOfType = meaning ⟦_⟧Type
-- We also provide: Environments of such values.
open import Base.Denotation.Environment Type ⟦_⟧Type public
|
{
"alphanum_fraction": 0.5875402793,
"avg_line_length": 27.3823529412,
"ext": "agda",
"hexsha": "af7048406be099612797bbd9b2ab9adb3569342d",
"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": "Parametric/Denotation/Value.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": "Parametric/Denotation/Value.agda",
"max_line_length": 72,
"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": "Parametric/Denotation/Value.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": 256,
"size": 931
}
|
{-# OPTIONS --safe #-}
module Cubical.Data.FinSet.Properties where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Function
open import Cubical.Foundations.Structure
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.Equiv renaming (_∙ₑ_ to _⋆_)
open import Cubical.HITs.PropositionalTruncation as Prop
open import Cubical.Data.Nat
open import Cubical.Data.Unit
open import Cubical.Data.Bool
open import Cubical.Data.Empty as Empty
open import Cubical.Data.Sigma
open import Cubical.Data.Fin.Base renaming (Fin to Finℕ)
open import Cubical.Data.SumFin
open import Cubical.Data.FinSet.Base
open import Cubical.Relation.Nullary
open import Cubical.Relation.Nullary.DecidableEq
open import Cubical.Relation.Nullary.HLevels
private
variable
ℓ ℓ' ℓ'' : Level
A : Type ℓ
B : Type ℓ'
-- operators to more conveniently compose equivalences
module _
{A : Type ℓ}{B : Type ℓ'}{C : Type ℓ''} where
infixr 30 _⋆̂_
_⋆̂_ : ∥ A ≃ B ∥ → ∥ B ≃ C ∥ → ∥ A ≃ C ∥
_⋆̂_ = Prop.map2 (_⋆_)
module _
{A : Type ℓ}{B : Type ℓ'} where
∣invEquiv∣ : ∥ A ≃ B ∥ → ∥ B ≃ A ∥
∣invEquiv∣ = Prop.map invEquiv
-- useful implications
EquivPresIsFinSet : A ≃ B → isFinSet A → isFinSet B
EquivPresIsFinSet e (_ , p) = _ , ∣ invEquiv e ∣ ⋆̂ p
isFinSetFin : {n : ℕ} → isFinSet (Fin n)
isFinSetFin = _ , ∣ idEquiv _ ∣
isFinSetUnit : isFinSet Unit
isFinSetUnit = 1 , ∣ invEquiv Fin1≃Unit ∣
isFinSetBool : isFinSet Bool
isFinSetBool = 2 , ∣ invEquiv SumFin2≃Bool ∣
isFinSet→Discrete : isFinSet A → Discrete A
isFinSet→Discrete h = Prop.rec isPropDiscrete (λ p → EquivPresDiscrete (invEquiv p) discreteFin) (h .snd)
isContr→isFinSet : isContr A → isFinSet A
isContr→isFinSet h = 1 , ∣ isContr→≃Unit* h ⋆ invEquiv Unit≃Unit* ⋆ invEquiv Fin1≃Unit ∣
isDecProp→isFinSet : isProp A → Dec A → isFinSet A
isDecProp→isFinSet h (yes p) = isContr→isFinSet (inhProp→isContr p h)
isDecProp→isFinSet h (no ¬p) = 0 , ∣ uninhabEquiv ¬p (idfun _) ∣
isDec→isFinSet∥∥ : Dec A → isFinSet ∥ A ∥
isDec→isFinSet∥∥ dec = isDecProp→isFinSet isPropPropTrunc (Dec∥∥ dec)
isFinSet→Dec∥∥ : isFinSet A → Dec ∥ A ∥
isFinSet→Dec∥∥ h =
Prop.rec (isPropDec isPropPropTrunc)
(λ p → EquivPresDec (propTrunc≃ (invEquiv p)) (Dec∥Fin∥ _)) (h .snd)
isFinProp→Dec : isFinSet A → isProp A → Dec A
isFinProp→Dec p h = subst Dec (propTruncIdempotent h) (isFinSet→Dec∥∥ p)
PeirceLaw∥∥ : isFinSet A → NonEmpty ∥ A ∥ → ∥ A ∥
PeirceLaw∥∥ p = Dec→Stable (isFinSet→Dec∥∥ p)
PeirceLaw : isFinSet A → NonEmpty A → ∥ A ∥
PeirceLaw p q = PeirceLaw∥∥ p (λ f → q (λ x → f ∣ x ∣))
-- transprot family towards Fin
transpFamily :
{A : Type ℓ}{B : A → Type ℓ'}
→ ((n , e) : isFinOrd A) → (x : A) → B x ≃ B (invEq e (e .fst x))
transpFamily {B = B} (n , e) x = pathToEquiv (λ i → B (retEq e x (~ i)))
|
{
"alphanum_fraction": 0.6914049016,
"avg_line_length": 29.5612244898,
"ext": "agda",
"hexsha": "873870480f9ad81bb49035a96c7a0f7be0175871",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "howsiyu/cubical",
"max_forks_repo_path": "Cubical/Data/FinSet/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "howsiyu/cubical",
"max_issues_repo_path": "Cubical/Data/FinSet/Properties.agda",
"max_line_length": 105,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "howsiyu/cubical",
"max_stars_repo_path": "Cubical/Data/FinSet/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1143,
"size": 2897
}
|
{-# OPTIONS --safe --warning=error --without-K --guardedness #-}
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import LogicalFormulae
open import Groups.Lemmas
open import Groups.Definition
open import Setoids.Orders.Partial.Definition
open import Setoids.Orders.Total.Definition
open import Setoids.Setoids
open import Functions.Definition
open import Sets.EquivalenceRelations
open import Rings.Definition
open import Rings.Orders.Total.Definition
open import Rings.Orders.Partial.Definition
open import Numbers.Naturals.Semiring
open import Numbers.Naturals.Order
open import Numbers.Modulo.Definition
open import Semirings.Definition
open import Orders.Total.Definition
open import Sequences
-- Note: totality is necessary here. The construction of a base-n expansion fundamentally relies on being able to take floors.
module Rings.Orders.Total.BaseExpansion {a m p : _} {A : Set a} {S : Setoid {a} {m} A} {_+_ : A → A → A} {_*_ : A → A → A} {R : Ring S _+_ _*_} {_<_ : Rel {_} {p} A} {pOrder : SetoidPartialOrder S _<_} {pOrderRing : PartiallyOrderedRing R pOrder} (order : TotallyOrderedRing pOrderRing) {n : ℕ} (1<n : 1 <N n) where
open Ring R
open Group additiveGroup
open Setoid S
open Equivalence eq
open SetoidPartialOrder pOrder
open TotallyOrderedRing order
open SetoidTotalOrder total
open PartiallyOrderedRing pOrderRing
open import Rings.Lemmas R
open import Rings.Orders.Partial.Lemmas pOrderRing
open import Rings.Orders.Total.Lemmas order
open import Rings.InitialRing R
open import Rings.IntegralDomains.Lemmas
record FloorIs (a : A) (n : ℕ) : Set (m ⊔ p) where
field
prBelow : fromN n <= a
prAbove : a < fromN (succ n)
addOneToFloor : {a : A} {n : ℕ} → FloorIs a n → FloorIs (a + 1R) (succ n)
FloorIs.prBelow (addOneToFloor record { prBelow = (inl x) ; prAbove = prAbove }) = inl (<WellDefined groupIsAbelian reflexive (orderRespectsAddition x 1R))
FloorIs.prBelow (addOneToFloor record { prBelow = (inr x) ; prAbove = prAbove }) = inr (transitive groupIsAbelian (+WellDefined x reflexive))
FloorIs.prAbove (addOneToFloor record { prBelow = x ; prAbove = prAbove }) = <WellDefined reflexive groupIsAbelian (orderRespectsAddition prAbove 1R)
private
0<n : {x y : A} → (x < y) → 0R < fromN n
0<n x<y = fromNPreservesOrder (0<1 (anyComparisonImpliesNontrivial x<y)) (lessTransitive (succIsPositive 0) 1<n)
0<aFromN : {a : A} → (0<a : 0R < a) → 0R < (a * fromN n)
0<aFromN 0<a = orderRespectsMultiplication 0<a (0<n 0<a)
floorWellDefinedLemma : {a : A} {n1 n2 : ℕ} → FloorIs a n1 → FloorIs a n2 → n1 <N n2 → False
floorWellDefinedLemma {a} {n1} {n2} record { prAbove = prAbove1 } record { prBelow = inl prBelow } n1<n2 with TotalOrder.totality ℕTotalOrder (succ n1) n2
... | inl (inl n1+1<n2) = irreflexive (<Transitive prAbove1 (<Transitive (fromNPreservesOrder (0<1 (anyComparisonImpliesNontrivial prBelow)) n1+1<n2) prBelow))
... | inl (inr n2<n1+1) = noIntegersBetweenXAndSuccX n1 n1<n2 n2<n1+1
... | inr refl = irreflexive (<Transitive prAbove1 prBelow)
floorWellDefinedLemma {a} {n1} {n2} record { prBelow = (inl x) ; prAbove = prAbove1 } record { prBelow = (inr eq) ; prAbove = _ } n1<n2 with TotalOrder.totality ℕTotalOrder (succ n1) n2
... | inl (inl n1+1<n2) = irreflexive (<Transitive prAbove1 (<WellDefined reflexive eq (fromNPreservesOrder (0<1 (anyComparisonImpliesNontrivial prAbove1)) n1+1<n2)))
... | inl (inr n2<n1+1) = noIntegersBetweenXAndSuccX n1 n1<n2 n2<n1+1
... | inr refl = irreflexive (<WellDefined reflexive eq prAbove1)
floorWellDefinedLemma {a} {n1} {n2} record { prBelow = (inr x) ; prAbove = prAbove1 } record { prBelow = (inr eq) ; prAbove = _ } n1<n2 = lessIrreflexive {n1} (fromNPreservesOrder' (anyComparisonImpliesNontrivial prAbove1) (<WellDefined reflexive (transitive eq (symmetric x)) (fromNPreservesOrder (0<1 (anyComparisonImpliesNontrivial prAbove1)) n1<n2)))
floorWellDefined : {a : A} {n1 n2 : ℕ} → FloorIs a n1 → FloorIs a n2 → n1 ≡ n2
floorWellDefined {a} {n1} {n2} record { prBelow = prBelow1 ; prAbove = prAbove1 } record { prBelow = prBelow ; prAbove = prAbove } with TotalOrder.totality ℕTotalOrder n1 n2
... | inr x = x
floorWellDefined {a} {n1} {n2} f1 f2 | inl (inl x) = exFalso (floorWellDefinedLemma f1 f2 x)
floorWellDefined {a} {n1} {n2} f1 f2 | inl (inr x) = exFalso (floorWellDefinedLemma f2 f1 x)
floorWellDefined' : {a b : A} {n : ℕ} → (a ∼ b) → FloorIs a n → FloorIs b n
FloorIs.prBelow (floorWellDefined' {a} {b} {n} a=b record { prBelow = (inl x) ; prAbove = s }) = inl (<WellDefined reflexive a=b x)
FloorIs.prBelow (floorWellDefined' {a} {b} {n} a=b record { prBelow = (inr x) ; prAbove = s }) = inr (transitive x a=b)
FloorIs.prAbove (floorWellDefined' {a} {b} {n} a=b record { prBelow = t ; prAbove = s }) = <WellDefined a=b reflexive s
computeFloor' : {k : ℕ} → (fuel : ℕ) → .(k +N fuel ≡ n) → (a : A) → (0R < a) → .(a < fromN k) → Sg ℕ (FloorIs a)
computeFloor' {zero} zero pr a 0<a a<f = exFalso (lessIrreflexive (lessTransitive 1<n (le 0 (applyEquality succ (equalityCommutative pr)))))
computeFloor' {zero} (succ k) pr a 0<a a<f = exFalso (irreflexive (<Transitive 0<a a<f))
computeFloor' {succ k} n pr a 0<a a<f with totality 1R a
... | inl (inr a<1) = 0 , (record { prAbove = <WellDefined reflexive (symmetric identRight) a<1 ; prBelow = inl 0<a })
... | inr 1=a = 1 , (record { prAbove = <WellDefined (transitive identRight 1=a) reflexive (fromNPreservesOrder (0<1 (anyComparisonImpliesNontrivial 0<a)) {1} (le 0 refl)) ; prBelow = inr (transitive identRight 1=a) })
... | inl (inl 1<a) with computeFloor' {k} (succ n) (transitivity (transitivity (Semiring.commutative ℕSemiring k (succ n)) (applyEquality succ (Semiring.commutative ℕSemiring n k))) pr) (a + inverse 1R) (moveInequality 1<a) (<WellDefined reflexive (transitive groupIsAbelian (transitive +Associative (transitive (+WellDefined invLeft reflexive) identLeft))) (orderRespectsAddition a<f (inverse 1R)))
... | N , snd = succ N , floorWellDefined' (transitive (symmetric +Associative) (transitive (+WellDefined reflexive invLeft) identRight)) (addOneToFloor snd)
computeFloor : (a : A) → (0R < a) → .(a < fromN n) → Sg (ℤn n (lessTransitive (succIsPositive 0) 1<n)) (λ z → FloorIs a (ℤn.x z))
computeFloor a 0<a a<n with computeFloor' {n} 0 (Semiring.sumZeroRight ℕSemiring n) a 0<a a<n
... | floor , record { prBelow = inl p ; prAbove = prAbove } = record { x = floor ; xLess = fromNPreservesOrder' (anyComparisonImpliesNontrivial 0<a) (<Transitive p a<n) } , record { prBelow = inl p ; prAbove = prAbove }
... | floor , record { prBelow = inr p ; prAbove = prAbove } = record { x = floor ; xLess = fromNPreservesOrder' (anyComparisonImpliesNontrivial 0<a) (<WellDefined (symmetric p) reflexive a<n) } , record { prBelow = inr p ; prAbove = prAbove }
firstDigit : (a : A) → 0R < a → .(a < 1R) → ℤn n (lessTransitive (succIsPositive 0) 1<n)
firstDigit a 0<a a<1 = underlying (computeFloor (a * fromN n) (orderRespectsMultiplication 0<a (0<n 0<a)) (<WellDefined reflexive identIsIdent (ringCanMultiplyByPositive (0<n 0<a) a<1)))
baseNExpansion : (a : A) → 0R < a → .(a < 1R) → Sequence (ℤn n (lessTransitive (succIsPositive 0) 1<n))
Sequence.head (baseNExpansion a 0<a a<1) = firstDigit a 0<a a<1
Sequence.tail (baseNExpansion a 0<a a<1) with computeFloor (a * fromN n) (0<aFromN 0<a) (<WellDefined reflexive identIsIdent (ringCanMultiplyByPositive (0<n 0<a) a<1))
... | record { x = x ; xLess = xLess } , record { prBelow = inl prB ; prAbove = prA } = baseNExpansion ((a * fromN n) + inverse (fromN x)) (moveInequality prB) (<WellDefined reflexive (transitive (symmetric +Associative) (transitive (+WellDefined reflexive invRight) identRight)) (orderRespectsAddition prA (inverse (fromN x))))
... | record { x = x ; xLess = xLess } , record { prBelow = inr prB ; prAbove = prA } = constSequence (record { x = 0 ; xLess = lessTransitive (succIsPositive 0) 1<n })
private
powerSeq : (i : A) → (start : A) → Sequence A
Sequence.head (powerSeq i start) = start
Sequence.tail (powerSeq i start) = powerSeq i (start * i)
powerSeqInduction : (i : A) (start : A) → (m : ℕ) → (index (powerSeq i start) (succ m)) ∼ i * (index (powerSeq i start) m)
powerSeqInduction i start zero = *Commutative
powerSeqInduction i start (succ m) = powerSeqInduction i (start * i) m
powerSeq' : (i : A) → Sequence A
powerSeq' i = powerSeq i i
dot : A → ℤn n (lessTransitive (succIsPositive 0) 1<n) → A
dot 1/n^i x = fromN (ℤn.x {n} {lessTransitive (succIsPositive 0) 1<n} x) * 1/n^i
dotWellDefined : {x y : A} {b : ℤn n (lessTransitive (succIsPositive 0) 1<n)} → (x ∼ y) → dot x b ∼ dot y b
dotWellDefined eq = *WellDefined reflexive eq
sequenceEntries : (b : A) → (b * fromN n ∼ 1R) → Sequence (ℤn n (lessTransitive (succIsPositive 0) 1<n)) → Sequence A
sequenceEntries 1/n pr1/n s = apply dot (powerSeq' 1/n) s
private
partialSums' : A → Sequence A → Sequence A
Sequence.head (partialSums' a seq) = a + Sequence.head seq
Sequence.tail (partialSums' a seq) = partialSums' (a + Sequence.head seq) (Sequence.tail seq)
partialSums'WellDefined : (a b : A) → (a ∼ b) → (s : Sequence A) → (m : ℕ) → (index (partialSums' a s) m) ∼ (index (partialSums' b s) m)
partialSums'WellDefined a b a=b s zero = +WellDefined a=b reflexive
partialSums'WellDefined a b a=b s (succ m) = partialSums'WellDefined (a + Sequence.head s) (b + Sequence.head s) (+WellDefined a=b reflexive) (Sequence.tail s) m
partialSums'WellDefined' : (a : A) → (s1 s2 : Sequence A) → (equal : (m : ℕ) → index s1 m ∼ index s2 m) → (m : ℕ) → (index (partialSums' a s1) m) ∼ (index (partialSums' a s2) m)
partialSums'WellDefined' a s1 s2 equal zero = +WellDefined reflexive (equal 0)
partialSums'WellDefined' a s1 s2 equal (succ m) = transitive (partialSums'WellDefined (a + Sequence.head s1) (a + Sequence.head s2) (+WellDefined reflexive (equal 0)) _ m) (partialSums'WellDefined' (a + Sequence.head s2) (Sequence.tail s1) (Sequence.tail s2) (λ m → equal (succ m)) m)
partialSums'Translate : (a b : A) → (s : Sequence A) → (m : ℕ) → (index (partialSums' (a + b) s) m) ∼ (b + index (partialSums' a s) m)
partialSums'Translate a b s zero = transitive (+WellDefined groupIsAbelian reflexive) (symmetric +Associative)
partialSums'Translate a b s (succ m) = transitive (partialSums'WellDefined _ _ (transitive (symmetric +Associative) (transitive (+WellDefined reflexive groupIsAbelian) +Associative)) (Sequence.tail s) m) (partialSums'Translate (a + Sequence.head s) b (Sequence.tail s) m)
powerSeqWellDefined : {a b start1 start2 : A} → (a ∼ b) → (start1 ∼ start2) → (m : ℕ) → (index (powerSeq a start1) m) ∼ (index (powerSeq b start2) m)
powerSeqWellDefined {a} {b} {s1} {s2} a=b s1=s2 zero = s1=s2
powerSeqWellDefined {a} {b} {s1} {s2} a=b s1=s2 (succ m) = powerSeqWellDefined a=b (*WellDefined s1=s2 a=b) m
powerSeqMove : (a start : A) (m : ℕ) → index (powerSeq a (a * start)) m ∼ a * index (powerSeq a start) m
powerSeqMove a start zero = reflexive
powerSeqMove a start (succ m) = transitive (powerSeqWellDefined reflexive (transitive *Commutative (*WellDefined reflexive *Commutative)) m) (powerSeqMove _ _ m)
partialSumsConst : (r s : A) → (m : ℕ) → index (partialSums' r (constSequence s)) m ∼ (r + (s * fromN (succ m)))
partialSumsConst r s zero = +WellDefined reflexive (transitive (symmetric identIsIdent) (transitive *Commutative (*WellDefined reflexive (symmetric identRight))))
partialSumsConst r s (succ m) = transitive (partialSumsConst (r + s) s m) (transitive (symmetric +Associative) (+WellDefined reflexive (transitive (+WellDefined (symmetric (transitive *Commutative identIsIdent)) reflexive) (symmetric *DistributesOver+))))
applyWellDefined : {b : _} {B : Set b} (r1 r2 : Sequence A) (s : Sequence B) → (f : A → B → A) → ({x y : A} {b : B} → (x ∼ y) → f x b ∼ f y b) → ((m : ℕ) → index r1 m ∼ index r2 m) → (m : ℕ) → index (apply f r1 s) m ∼ index (apply f r2 s) m
applyWellDefined r1 r2 s f wd eq zero = wd (eq 0)
applyWellDefined r1 r2 s f wd eq (succ m) = applyWellDefined _ _ (Sequence.tail s) f wd (λ n → eq (succ n)) m
partialSums : Sequence A → Sequence A
partialSums = partialSums' 0R
approximations : (b : A) → (b * (fromN n) ∼ 1R) → Sequence (ℤn n (lessTransitive (succIsPositive 0) 1<n)) → Sequence A
approximations 1/n pr1/n s = partialSums (sequenceEntries 1/n pr1/n s)
private
multiplyZeroSequence : (s : Sequence A) (m : ℕ) → index (apply dot s (constSequence (record { x = 0 ; xLess = lessTransitive (succIsPositive 0) 1<n }))) m ∼ 0R
multiplyZeroSequence s zero = timesZero'
multiplyZeroSequence s (succ m) = multiplyZeroSequence _ m
lemma1 : (x y : A) (s : Sequence (ℤn n (lessTransitive (succIsPositive 0) 1<n))) → (m : ℕ) → index (apply dot (powerSeq x (y * x)) s) m ∼ x * (index (apply dot (powerSeq x y) s) m)
lemma1 x y s zero = transitive *Associative *Commutative
lemma1 x y s (succ m) = lemma1 x (y * x) (Sequence.tail s) m
lemma2 : (w x y z : A) (s : Sequence (ℤn n (lessTransitive (succIsPositive 0) 1<n))) → (m : ℕ) → (w * index (partialSums' x (apply dot (powerSeq y z) s)) m) ∼ index (partialSums' (w * x) (apply dot (powerSeq y (z * w)) s)) m
lemma2 x y z w s zero = transitive *DistributesOver+ (+WellDefined reflexive (transitive (transitive (*WellDefined reflexive *Commutative) (transitive *Associative (*WellDefined *Commutative reflexive))) *Commutative))
lemma2 x y z w s (succ m) = transitive (lemma2 x (y + dot w (Sequence.head s)) z (w * z) (Sequence.tail s) m) (transitive (partialSums'WellDefined _ (_ + dot (w * x) (Sequence.head s)) (transitive *DistributesOver+ (+WellDefined reflexive (transitive *Commutative (symmetric *Associative)))) _ m) (partialSums'WellDefined' _ _ _ (λ n → applyWellDefined (powerSeq z ((w * z) * x)) (powerSeq z ((w * x) * z)) (Sequence.tail s) dot (λ {m} {n} {s} m=n → dotWellDefined {m} {n} {s} m=n) (λ n → powerSeqWellDefined reflexive (transitive (transitive (symmetric *Associative) (*WellDefined reflexive *Commutative)) *Associative) n) n) m))
approximationComesFromBelow : (1/n : A) → (1/nPr : 1/n * (fromN n) ∼ 1R) → (a : A) → (0<a : 0R < a) → (a<1 : a < 1R) → (m : ℕ) → index (approximations 1/n 1/nPr (baseNExpansion a 0<a a<1)) m <= a
approximationComesFromBelow 1/n 1/nPr a 0<a a<1 zero with computeFloor' 0 (Semiring.sumZeroRight ℕSemiring n) (a * fromN n) (0<aFromN 0<a) ((<WellDefined reflexive identIsIdent (ringCanMultiplyByPositive (0<n 0<a) a<1)))
... | x , record { prBelow = inl prBelow ; prAbove = prAbove } = inl (<WellDefined (symmetric identLeft) reflexive (ringCanCancelPositive (0<n prBelow) (<WellDefined (transitive (symmetric identIsIdent) (transitive *Commutative (transitive (*WellDefined reflexive (symmetric 1/nPr)) *Associative))) reflexive prBelow)))
... | x , record { prBelow = inr prBelow ; prAbove = prAbove } = inr (transitive identLeft (transitive (transitive (transitive (transitive (*WellDefined prBelow reflexive) (transitive (symmetric *Associative) (*WellDefined reflexive *Commutative))) (*WellDefined reflexive 1/nPr)) (*Commutative)) identIsIdent))
approximationComesFromBelow 1/n 1/nPr a 0<a a<1 (succ m) with computeFloor' 0 (Semiring.sumZeroRight ℕSemiring n) (a * fromN n) (0<aFromN 0<a) ((<WellDefined reflexive identIsIdent (ringCanMultiplyByPositive (0<n 0<a) a<1)))
... | x , record { prBelow = inr x=an ; prAbove = an<x+1 } = inr (transitive (partialSums'Translate 0G _ _ m) (transitive (+WellDefined (transitive (*WellDefined x=an reflexive) (transitive (symmetric *Associative) (*WellDefined reflexive (transitive *Commutative 1/nPr)))) reflexive) (transitive (+WellDefined (transitive *Commutative identIsIdent) (transitive (partialSums'WellDefined' 0G _ (constSequence 0G) (λ m → transitive (multiplyZeroSequence (powerSeq 1/n (1/n * 1/n)) m) (identityOfIndiscernablesRight _∼_ reflexive (equalityCommutative (indexAndConst 0G m)))) m) (transitive (partialSumsConst _ _ m) (transitive identLeft timesZero')))) identRight)))
... | x , record { prBelow = inl x<an ; prAbove = an<x+1 } with approximationComesFromBelow 1/n 1/nPr ((a * fromN n) + inverse (fromN x)) (moveInequality x<an) (<WellDefined reflexive (transitive (symmetric +Associative) (transitive (+WellDefined reflexive invRight) identRight)) (orderRespectsAddition an<x+1 (inverse (fromN x)))) m
... | inl inter<an = inl (<WellDefined (symmetric (partialSums'Translate 0G (fromN x * 1/n) _ m)) reflexive (<WellDefined (+WellDefined reflexive (symmetric (partialSums'WellDefined 0G (fromN n * 0G) (symmetric timesZero) _ m))) reflexive (ringCanCancelPositive (0<n an<x+1) (<WellDefined (symmetric (transitive *DistributesOver+' (+WellDefined (transitive (symmetric *Associative) (transitive (*WellDefined reflexive 1/nPr) (transitive *Commutative identIsIdent))) (transitive *Commutative (transitive (lemma2 (fromN n) (fromN n * 0G) 1/n (1/n * 1/n) _ m) (transitive (partialSums'WellDefined _ 0G (transitive (*WellDefined reflexive timesZero) timesZero) _ m) (partialSums'WellDefined' 0G _ _ (λ m → applyWellDefined _ _ _ dot (λ {x} {y} {s} → dotWellDefined {x} {y} {s}) (λ m → powerSeqWellDefined {_} {1/n} {_} {1/n} reflexive (transitive (symmetric *Associative) (transitive (transitive *Commutative (*WellDefined 1/nPr reflexive)) identIsIdent)) m) m) m))))))) reflexive (<WellDefined groupIsAbelian (transitive (symmetric +Associative) (transitive (+WellDefined reflexive invLeft) identRight)) (orderRespectsAddition inter<an (fromN x)))))))
... | inr inter=an = inr (transitive (partialSums'Translate 0G (fromN x * 1/n) _ m) (cancelIntDom' (isIntDom λ t → anyComparisonImpliesNontrivial a<1 (symmetric t)) ans λ t → irreflexive (<WellDefined reflexive t (fromNPreservesOrder (0<1 (anyComparisonImpliesNontrivial a<1)) (lessTransitive (succIsPositive 0) 1<n)))))
where
ans : (((fromN x * 1/n) + index (partialSums' 0G (apply dot (powerSeq 1/n (1/n * 1/n)) (baseNExpansion ((a * fromN n) + inverse (fromN x)) (moveInequality x<an) (<WellDefined reflexive (transitive (symmetric +Associative) (transitive (+WellDefined reflexive invRight) identRight)) (orderRespectsAddition an<x+1 (inverse (fromN x))))))) m) * fromN n) ∼ a * fromN n
ans = transitive (transitive *DistributesOver+' (+WellDefined (transitive (symmetric *Associative) (transitive (*WellDefined reflexive 1/nPr) (transitive *Commutative identIsIdent))) *Commutative)) (transitive (+WellDefined reflexive (transitive (lemma2 (fromN n) 0G 1/n (1/n * 1/n) _ m) (transitive (partialSums'WellDefined _ _ timesZero _ m) (partialSums'WellDefined' _ _ _ (λ m → applyWellDefined _ _ _ dot (λ {x} {y} {s} → dotWellDefined {x} {y} {s}) (λ m → powerSeqWellDefined reflexive (transitive (symmetric *Associative) (transitive (*WellDefined reflexive 1/nPr) (transitive *Commutative identIsIdent))) m) m) m)))) (transitive (+WellDefined reflexive inter=an) (transitive groupIsAbelian (transitive (symmetric +Associative) (transitive (+WellDefined reflexive invLeft) identRight)))))
pow : ℕ → A → A
pow zero x = 1R
pow (succ n) x = x * pow n x
powPos : (m : ℕ) {a : A} → (0R < a) → 0R < pow m a
powPos zero 0<a = 0<1 (anyComparisonImpliesNontrivial 0<a)
powPos (succ m) 0<a = orderRespectsMultiplication 0<a (powPos m 0<a)
approximationIsNear : (1/n : A) → (1/nPr : 1/n * (fromN n) ∼ 1R) → (a : A) → (0<a : 0R < a) → (a<1 : a < 1R) → (m : ℕ) → a < ((index (approximations 1/n 1/nPr (baseNExpansion a 0<a a<1)) m) + pow m 1/n)
approximationIsNear 1/n 1/npr a 0<a a<1 zero with computeFloor' 0 (Semiring.sumZeroRight ℕSemiring n) (a * fromN n) (0<aFromN 0<a) (<WellDefined reflexive identIsIdent (ringCanMultiplyByPositive (0<n 0<a) a<1))
... | x , record { prBelow = inl prBelow ; prAbove = prAbove } = <WellDefined reflexive (transitive (symmetric identLeft) +Associative) (ringCanCancelPositive (0<n prAbove) (<Transitive prAbove (<WellDefined reflexive (transitive (+WellDefined (transitive (*WellDefined reflexive (symmetric 1/npr)) *Associative) (symmetric identIsIdent)) (symmetric *DistributesOver+')) (<WellDefined reflexive (transitive groupIsAbelian (+WellDefined (transitive (symmetric identIsIdent) *Commutative) reflexive)) (orderRespectsAddition (<WellDefined identRight reflexive (fromNPreservesOrder (0<1 (anyComparisonImpliesNontrivial prAbove)) 1<n)) (fromN x))))))
... | x , record { prBelow = inr prBelow ; prAbove = prAbove } = <WellDefined reflexive (symmetric (transitive (symmetric +Associative) identLeft)) (ringCanCancelPositive (0<n prAbove) (<WellDefined prBelow (symmetric (transitive *DistributesOver+' (+WellDefined (transitive (symmetric *Associative) (transitive *Commutative (transitive (*WellDefined 1/npr reflexive) identIsIdent))) identIsIdent))) (<WellDefined identLeft groupIsAbelian (orderRespectsAddition (0<n prAbove) (fromN x)))))
approximationIsNear 1/n 1/npr a 0<a a<1 (succ m) with computeFloor' 0 (Semiring.sumZeroRight ℕSemiring n) (a * fromN n) (0<aFromN 0<a) (<WellDefined reflexive identIsIdent (ringCanMultiplyByPositive (0<n 0<a) a<1))
... | x , record { prBelow = inl prBelow ; prAbove = prAbove } = <WellDefined reflexive (+WellDefined (symmetric (partialSums'Translate 0G (fromN x * 1/n) _ m)) reflexive) (ringCanCancelPositive (0<n prAbove) (<WellDefined reflexive (transitive (+WellDefined (transitive (+WellDefined (transitive (transitive (symmetric identIsIdent) (transitive *Commutative (*WellDefined reflexive (symmetric 1/npr))) ) *Associative) *Commutative) (symmetric *DistributesOver+')) (transitive (transitive (transitive (symmetric identIsIdent) (*WellDefined (transitive (symmetric 1/npr) *Commutative) reflexive)) (symmetric *Associative)) *Commutative)) (symmetric *DistributesOver+')) (<WellDefined reflexive (+WellDefined (+WellDefined reflexive (transitive (partialSums'WellDefined' _ _ _ (λ m → applyWellDefined _ _ _ dot (λ {_} {_} {s} → dotWellDefined {_} {_} {s}) (λ m → powerSeqWellDefined reflexive (transitive (transitive (transitive (symmetric identIsIdent) *Commutative) (*WellDefined reflexive (symmetric 1/npr))) *Associative) m) m) m) (symmetric (lemma2 (fromN n) 0G 1/n (1/n * 1/n) _ m)))) reflexive) (<WellDefined reflexive (+WellDefined (+WellDefined reflexive (partialSums'WellDefined _ _ (symmetric timesZero) _ m)) reflexive) (<WellDefined reflexive +Associative u)))))
where
t : ((a * fromN n) + inverse (fromN x)) < ((index (partialSums' 0R (apply dot (powerSeq 1/n 1/n) (baseNExpansion ((a * fromN n) + inverse (fromN x)) (moveInequality prBelow) _))) m) + pow m 1/n)
t = approximationIsNear 1/n 1/npr ((a * fromN n) + inverse (fromN x)) (moveInequality prBelow) (<WellDefined reflexive (transitive (transitive (symmetric +Associative) (+WellDefined reflexive invRight)) identRight) (orderRespectsAddition prAbove (inverse (fromN x)))) m
u : (a * fromN n) < (fromN x + ((index (partialSums' 0R (apply dot (powerSeq 1/n 1/n) (baseNExpansion ((a * fromN n) + inverse (fromN x)) (moveInequality prBelow) _))) m) + pow m 1/n))
u = <WellDefined (transitive (transitive (symmetric +Associative) (+WellDefined reflexive invLeft)) identRight) groupIsAbelian (orderRespectsAddition t (fromN x))
... | x , record { prBelow = inr prBelow ; prAbove = prAbove } = <WellDefined reflexive (+WellDefined (symmetric (partialSums'Translate 0G (fromN x * 1/n) _ m)) reflexive) (ringCanCancelPositive (0<n prAbove) (<WellDefined reflexive (transitive (+WellDefined (transitive (+WellDefined (transitive (transitive (symmetric identIsIdent) (transitive *Commutative (*WellDefined reflexive (symmetric 1/npr))) ) *Associative) *Commutative) (symmetric *DistributesOver+')) (transitive (transitive (transitive (symmetric identIsIdent) (*WellDefined (transitive (symmetric 1/npr) *Commutative) reflexive)) (symmetric *Associative)) *Commutative)) (symmetric *DistributesOver+')) (<WellDefined reflexive (+WellDefined (+WellDefined reflexive (transitive (partialSums'WellDefined' _ _ _ (λ m → applyWellDefined _ _ _ dot (λ {_} {_} {s} → dotWellDefined {_} {_} {s}) (λ m → powerSeqWellDefined reflexive (transitive (transitive (transitive (symmetric identIsIdent) *Commutative) (*WellDefined reflexive (symmetric 1/npr))) *Associative) m) m) m) (symmetric (lemma2 (fromN n) 0G 1/n (1/n * 1/n) _ m)))) reflexive) (<WellDefined reflexive (+WellDefined (+WellDefined reflexive (partialSums'WellDefined _ _ (symmetric timesZero) _ m)) reflexive) (<WellDefined reflexive +Associative (<WellDefined (transitive identLeft prBelow) groupIsAbelian (orderRespectsAddition (<WellDefined reflexive (transitive (symmetric identLeft) (+WellDefined (symmetric (transitive (partialSums'WellDefined' 0R _ (constSequence 0R) (λ m → transitive (multiplyZeroSequence _ m) (identityOfIndiscernablesLeft _∼_ reflexive (indexAndConst 0G m))) m ) (transitive (partialSumsConst _ _ m) (transitive identLeft timesZero')))) reflexive)) (powPos m {1/n} (reciprocalPositive _ _ (0<n 0<a) (transitive *Commutative 1/npr)))) (fromN x))))))))
|
{
"alphanum_fraction": 0.7097163064,
"avg_line_length": 119.6442307692,
"ext": "agda",
"hexsha": "02c449f6708c73c37588586b2826bb04e3fb88a0",
"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": "Rings/Orders/Total/BaseExpansion.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": "Rings/Orders/Total/BaseExpansion.agda",
"max_line_length": 1798,
"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": "Rings/Orders/Total/BaseExpansion.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": 8457,
"size": 24886
}
|
-- Limits.
-- Heavily inspired by https://github.com/UniMath/UniMath/blob/master/UniMath/CategoryTheory/limits/graphs/limits.v
-- (except we're using categories instead of graphs to index limits)
{-# OPTIONS --safe #-}
module Cubical.Categories.Limits.Limits where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Data.Sigma.Base
open import Cubical.Categories.Category
open import Cubical.Categories.Functor
open import Cubical.HITs.PropositionalTruncation.Base
module _ {ℓJ ℓJ' ℓC ℓC' : Level} {J : Category ℓJ ℓJ'} {C : Category ℓC ℓC'} where
open Category
open Functor
private
ℓ = ℓ-max (ℓ-max (ℓ-max ℓJ ℓJ') ℓC) ℓC'
record Cone (D : Functor J C) (c : ob C) : Type (ℓ-max (ℓ-max ℓJ ℓJ') ℓC') where
constructor cone
field
coneOut : (v : ob J) → C [ c , F-ob D v ]
coneOutCommutes : {u v : ob J} (e : J [ u , v ]) →
coneOut u ⋆⟨ C ⟩ D .F-hom e ≡ coneOut v
open Cone
cone≡ : {D : Functor J C} {c : ob C} → {c1 c2 : Cone D c}
→ ((v : ob J) → coneOut c1 v ≡ coneOut c2 v) → c1 ≡ c2
coneOut (cone≡ h i) v = h v i
coneOutCommutes (cone≡ {D} {_} {c1} {c2} h i) {u} {v} e =
isProp→PathP (λ j → isSetHom C (h u j ⋆⟨ C ⟩ D .F-hom e) (h v j))
(coneOutCommutes c1 e) (coneOutCommutes c2 e) i
-- TODO: can we automate this a bit?
isSetCone : (D : Functor J C) (c : ob C) → isSet (Cone D c)
isSetCone D c = isSetRetract toConeΣ fromConeΣ (λ _ → refl)
(isSetΣSndProp (isSetΠ (λ _ → isSetHom C))
(λ _ → isPropImplicitΠ2 (λ _ _ → isPropΠ (λ _ → isSetHom C _ _))))
where
ConeΣ = Σ[ f ∈ ((v : ob J) → C [ c , F-ob D v ]) ]
({u v : ob J} (e : J [ u , v ]) → f u ⋆⟨ C ⟩ D .F-hom e ≡ f v)
toConeΣ : Cone D c → ConeΣ
fst (toConeΣ x) = coneOut x
snd (toConeΣ x) = coneOutCommutes x
fromConeΣ : ConeΣ → Cone D c
coneOut (fromConeΣ x) = fst x
coneOutCommutes (fromConeΣ x) = snd x
isConeMor : {c1 c2 : ob C} {D : Functor J C}
(cc1 : Cone D c1) (cc2 : Cone D c2)
→ C [ c1 , c2 ] → Type (ℓ-max ℓJ ℓC')
isConeMor cc1 cc2 f = (v : ob J) → f ⋆⟨ C ⟩ coneOut cc2 v ≡ coneOut cc1 v
isPropIsConeMor : {c1 c2 : ob C} {D : Functor J C}
(cc1 : Cone D c1) (cc2 : Cone D c2) (f : C [ c1 , c2 ])
→ isProp (isConeMor cc1 cc2 f)
isPropIsConeMor cc1 cc2 f = isPropΠ (λ _ → isSetHom C _ _)
isLimCone : (D : Functor J C) (c0 : ob C) → Cone D c0 → Type ℓ
isLimCone D c0 cc0 = (c : ob C) → (cc : Cone D c)
→ ∃![ f ∈ C [ c , c0 ] ] isConeMor cc cc0 f
isPropIsLimCone : (D : Functor J C) (c0 : ob C) (cc0 : Cone D c0)
→ isProp (isLimCone D c0 cc0)
isPropIsLimCone D c0 cc0 = isPropΠ2 λ _ _ → isProp∃!
record LimCone (D : Functor J C) : Type ℓ where
constructor climCone
field
lim : ob C
limCone : Cone D lim
univProp : isLimCone D lim limCone
limOut : (v : ob J) → C [ lim , D .F-ob v ]
limOut = coneOut limCone
limOutCommutes : {u v : ob J} (e : J [ u , v ])
→ limOut u ⋆⟨ C ⟩ D .F-hom e ≡ limOut v
limOutCommutes = coneOutCommutes limCone
limArrow : (c : ob C) → (cc : Cone D c) → C [ c , lim ]
limArrow c cc = univProp c cc .fst .fst
limArrowCommutes : (c : ob C) → (cc : Cone D c) (u : ob J)
→ limArrow c cc ⋆⟨ C ⟩ limOut u ≡ coneOut cc u
limArrowCommutes c cc = univProp c cc .fst .snd
limArrowUnique : (c : ob C) → (cc : Cone D c) (k : C [ c , lim ])
→ isConeMor cc limCone k → limArrow c cc ≡ k
limArrowUnique c cc k hk = cong fst (univProp c cc .snd (k , hk))
open LimCone
limOfArrows : (D₁ D₂ : Functor J C)
(CC₁ : LimCone D₁) (CC₂ : LimCone D₂)
(f : (u : ob J) → C [ D₁ .F-ob u , D₂ .F-ob u ])
(fNat : {u v : ob J} (e : J [ u , v ])
→ f u ⋆⟨ C ⟩ D₂ .F-hom e ≡ D₁ .F-hom e ⋆⟨ C ⟩ f v)
→ C [ CC₁ .lim , CC₂ .lim ]
limOfArrows D₁ D₂ CC₁ CC₂ f fNat = limArrow CC₂ (CC₁ .lim) coneD₂Lim₁
where
coneD₂Lim₁ : Cone D₂ (CC₁ .lim)
coneOut coneD₂Lim₁ v = limOut CC₁ v ⋆⟨ C ⟩ f v
coneOutCommutes coneD₂Lim₁ {u = u} {v = v} e =
limOut CC₁ u ⋆⟨ C ⟩ f u ⋆⟨ C ⟩ D₂ .F-hom e ≡⟨ ⋆Assoc C _ _ _ ⟩
limOut CC₁ u ⋆⟨ C ⟩ (f u ⋆⟨ C ⟩ D₂ .F-hom e) ≡⟨ cong (λ x → seq' C (limOut CC₁ u) x) (fNat e) ⟩
limOut CC₁ u ⋆⟨ C ⟩ (D₁ .F-hom e ⋆⟨ C ⟩ f v) ≡⟨ sym (⋆Assoc C _ _ _) ⟩
limOut CC₁ u ⋆⟨ C ⟩ D₁ .F-hom e ⋆⟨ C ⟩ f v ≡⟨ cong (λ x → x ⋆⟨ C ⟩ f v) (limOutCommutes CC₁ e) ⟩
limOut CC₁ v ⋆⟨ C ⟩ f v ∎
-- A category is complete if it has all limits
Limits : {ℓJ ℓJ' ℓC ℓC' : Level} → Category ℓC ℓC' → Type _
Limits {ℓJ} {ℓJ'} C = (J : Category ℓJ ℓJ') → (D : Functor J C) → LimCone D
hasLimits : {ℓJ ℓJ' ℓC ℓC' : Level} → Category ℓC ℓC' → Type _
hasLimits {ℓJ} {ℓJ'} C = (J : Category ℓJ ℓJ') → (D : Functor J C) → ∥ LimCone D ∥
-- Limits of a specific shape J in a category C
LimitsOfShape : {ℓJ ℓJ' ℓC ℓC' : Level} → Category ℓJ ℓJ' → Category ℓC ℓC' → Type _
LimitsOfShape J C = (D : Functor J C) → LimCone D
-- Preservation of limits
module _ {ℓJ ℓJ' ℓC1 ℓC1' ℓC2 ℓC2' : Level}
{C1 : Category ℓC1 ℓC1'} {C2 : Category ℓC2 ℓC2'}
(F : Functor C1 C2) where
open Category
open Functor
open Cone
private
ℓ = ℓ-max (ℓ-max (ℓ-max (ℓ-max (ℓ-max ℓJ ℓJ') ℓC1) ℓC1') ℓC2) ℓC2'
mapCone : {J : Category ℓJ ℓJ'} (D : Functor J C1) {x : ob C1} (ccx : Cone D x) → Cone (funcComp F D) (F .F-ob x)
coneOut (mapCone D ccx) v = F .F-hom (coneOut ccx v)
coneOutCommutes (mapCone D ccx) e =
sym (F-seq F (coneOut ccx _) (D ⟪ e ⟫)) ∙ cong (F .F-hom) (coneOutCommutes ccx e)
preservesLimit : {J : Category ℓJ ℓJ'} (D : Functor J C1)
→ (L : ob C1) → Cone D L → Type ℓ
preservesLimit D L ccL =
isLimCone D L ccL → isLimCone (funcComp F D) (F .F-ob L) (mapCone D ccL)
-- TODO: prove that right adjoints preserve limits
|
{
"alphanum_fraction": 0.5507317875,
"avg_line_length": 38.9807692308,
"ext": "agda",
"hexsha": "8ba2e7db0befe6a6a7caa1cc3811a409013f178e",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "howsiyu/cubical",
"max_forks_repo_path": "Cubical/Categories/Limits/Limits.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "howsiyu/cubical",
"max_issues_repo_path": "Cubical/Categories/Limits/Limits.agda",
"max_line_length": 115,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "howsiyu/cubical",
"max_stars_repo_path": "Cubical/Categories/Limits/Limits.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2553,
"size": 6081
}
|
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
open import Categories.Object.Zero
-- Cokernels of morphisms.
-- https://ncatlab.org/nlab/show/cokernel
module Categories.Object.Cokernel {o ℓ e} {𝒞 : Category o ℓ e} (𝟎 : Zero 𝒞) where
open import Level
open import Categories.Morphism 𝒞
open import Categories.Morphism.Reasoning 𝒞
hiding (glue)
open Category 𝒞
open Zero 𝟎
open HomReasoning
private
variable
A B X : Obj
f h i j k : A ⇒ B
record IsCokernel {A B K} (f : A ⇒ B) (k : B ⇒ K) : Set (o ⊔ ℓ ⊔ e) where
field
commute : k ∘ f ≈ zero⇒
universal : ∀ {X} {h : B ⇒ X} → h ∘ f ≈ zero⇒ → K ⇒ X
factors : ∀ {eq : h ∘ f ≈ zero⇒} → h ≈ universal eq ∘ k
unique : ∀ {eq : h ∘ f ≈ zero⇒} → h ≈ i ∘ k → i ≈ universal eq
universal-resp-≈ : ∀ {eq : h ∘ f ≈ zero⇒} {eq′ : i ∘ f ≈ zero⇒} →
h ≈ i → universal eq ≈ universal eq′
universal-resp-≈ h≈i = unique (⟺ h≈i ○ factors)
universal-∘ : h ∘ k ∘ f ≈ zero⇒
universal-∘ {h = h} = begin
h ∘ k ∘ f ≈⟨ refl⟩∘⟨ commute ⟩
h ∘ zero⇒ ≈⟨ zero-∘ˡ h ⟩
zero⇒ ∎
record Cokernel {A B} (f : A ⇒ B) : Set (o ⊔ ℓ ⊔ e) where
field
{cokernel} : Obj
cokernel⇒ : B ⇒ cokernel
isCokernel : IsCokernel f cokernel⇒
open IsCokernel isCokernel public
IsCokernel⇒Cokernel : IsCokernel f k → Cokernel f
IsCokernel⇒Cokernel {k = k} isCokernel = record
{ cokernel⇒ = k
; isCokernel = isCokernel
}
|
{
"alphanum_fraction": 0.5914505957,
"avg_line_length": 25.4821428571,
"ext": "agda",
"hexsha": "267f256b72327f95cbc72cc279095d627b19a65c",
"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/Object/Cokernel.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/Object/Cokernel.agda",
"max_line_length": 81,
"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/Object/Cokernel.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": 617,
"size": 1427
}
|
{-# OPTIONS --type-in-type #-}
module DescTT where
--********************************************
-- Prelude
--********************************************
-- Some preliminary stuffs, to avoid relying on the stdlib
--****************
-- Sigma and friends
--****************
data Sigma (A : Set) (B : A -> Set) : Set where
_,_ : (x : A) (y : B x) -> Sigma A B
_*_ : (A : Set)(B : Set) -> Set
A * B = Sigma A \_ -> B
fst : {A : Set}{B : A -> Set} -> Sigma A B -> A
fst (a , _) = a
snd : {A : Set}{B : A -> Set} (p : Sigma A B) -> B (fst p)
snd (a , b) = b
data Zero : Set where
data Unit : Set where
Void : Unit
--****************
-- Sum and friends
--****************
data _+_ (A : Set)(B : Set) : Set where
l : A -> A + B
r : B -> A + B
--****************
-- Equality
--****************
data _==_ {A : Set}(x : A) : A -> Set where
refl : x == x
cong : {A B : Set}(f : A -> B){x y : A} -> x == y -> f x == f y
cong f refl = refl
cong2 : {A B C : Set}(f : A -> B -> C){x y : A}{z t : B} ->
x == y -> z == t -> f x z == f y t
cong2 f refl refl = refl
postulate
reflFun : {A : Set}{B : A -> Set}(f : (a : A) -> B a)(g : (a : A) -> B a)-> ((a : A) -> f a == g a) -> f == g
--********************************************
-- Desc code
--********************************************
data Desc : Set where
id : Desc
const : Set -> Desc
prod : Desc -> Desc -> Desc
sigma : (S : Set) -> (S -> Desc) -> Desc
pi : (S : Set) -> (S -> Desc) -> Desc
--********************************************
-- Desc interpretation
--********************************************
[|_|]_ : Desc -> Set -> Set
[| id |] Z = Z
[| const X |] Z = X
[| prod D D' |] Z = [| D |] Z * [| D' |] Z
[| sigma S T |] Z = Sigma S (\s -> [| T s |] Z)
[| pi S T |] Z = (s : S) -> [| T s |] Z
--********************************************
-- Fixpoint construction
--********************************************
data Mu (D : Desc) : Set where
con : [| D |] (Mu D) -> Mu D
--********************************************
-- Predicate: All
--********************************************
All : (D : Desc)(X : Set)(P : X -> Set) -> [| D |] X -> Set
All id X P x = P x
All (const Z) X P x = Unit
All (prod D D') X P (d , d') = (All D X P d) * (All D' X P d')
All (sigma S T) X P (a , b) = All (T a) X P b
All (pi S T) X P f = (s : S) -> All (T s) X P (f s)
all : (D : Desc)(X : Set)(P : X -> Set)(R : (x : X) -> P x)(x : [| D |] X) -> All D X P x
all id X P R x = R x
all (const Z) X P R z = Void
all (prod D D') X P R (d , d') = all D X P R d , all D' X P R d'
all (sigma S T) X P R (a , b) = all (T a) X P R b
all (pi S T) X P R f = \ s -> all (T s) X P R (f s)
--********************************************
-- Map
--********************************************
map : (D : Desc)(X Y : Set)(f : X -> Y)(v : [| D |] X) -> [| D |] Y
map id X Y sig x = sig x
map (const Z) X Y sig z = z
map (prod D D') X Y sig (d , d') = map D X Y sig d , map D' X Y sig d'
map (sigma S T) X Y sig (a , b) = (a , map (T a) X Y sig b)
map (pi S T) X Y sig f = \x -> map (T x) X Y sig (f x)
proof-map-id : (D : Desc)(X : Set)(v : [| D |] X) -> map D X X (\x -> x) v == v
proof-map-id id X v = refl
proof-map-id (const Z) X v = refl
proof-map-id (prod D D') X (v , v') = cong2 (\x y -> (x , y)) (proof-map-id D X v) (proof-map-id D' X v')
proof-map-id (sigma S T) X (a , b) = cong (\x -> (a , x)) (proof-map-id (T a) X b)
proof-map-id (pi S T) X f = reflFun (\a -> map (T a) X X (\x -> x) (f a)) f (\a -> proof-map-id (T a) X (f a))
proof-map-compos : (D : Desc)(X Y Z : Set)
(f : X -> Y)(g : Y -> Z)
(v : [| D |] X) ->
map D X Z (\x -> g (f x)) v == map D Y Z g (map D X Y f v)
proof-map-compos id X Y Z f g v = refl
proof-map-compos (const K) X Y Z f g v = refl
proof-map-compos (prod D D') X Y Z f g (v , v') = cong2 (\x y -> (x , y))
(proof-map-compos D X Y Z f g v)
(proof-map-compos D' X Y Z f g v')
proof-map-compos (sigma S T) X Y Z f g (a , b) = cong (\x -> (a , x)) (proof-map-compos (T a) X Y Z f g b)
proof-map-compos (pi S T) X Y Z f g fc = reflFun (\a -> map (T a) X Z (\x -> g (f x)) (fc a))
(\a -> map (T a) Y Z g (map (T a) X Y f (fc a)))
(\a -> proof-map-compos (T a) X Y Z f g (fc a))
--********************************************
-- Elimination principle: induction
--********************************************
{-
induction : (D : Desc)
(P : Mu D -> Set) ->
( (x : [| D |] (Mu D)) ->
All D (Mu D) P x -> P (con x)) ->
(v : Mu D) ->
P v
induction D P ms (con xs) = ms xs (all D (Mu D) P (\x -> induction D P ms x) xs)
-}
module Elim (D : Desc)
(P : Mu D -> Set)
(ms : (x : [| D |] (Mu D)) ->
All D (Mu D) P x -> P (con x))
where
mutual
induction : (x : Mu D) -> P x
induction (con xs) = ms xs (hyps D xs)
hyps : (D' : Desc)
(xs : [| D' |] (Mu D)) ->
All D' (Mu D) P xs
hyps id x = induction x
hyps (const Z) z = Void
hyps (prod D D') (d , d') = hyps D d , hyps D' d'
hyps (sigma S T) (a , b) = hyps (T a) b
hyps (pi S T) f = \s -> hyps (T s) (f s)
induction : (D : Desc)
(P : Mu D -> Set) ->
( (x : [| D |] (Mu D)) ->
All D (Mu D) P x -> P (con x)) ->
(v : Mu D) ->
P v
induction D P ms x = Elim.induction D P ms x
--********************************************
-- Examples
--********************************************
--****************
-- Nat
--****************
data NatConst : Set where
Ze : NatConst
Suc : NatConst
natCases : NatConst -> Desc
natCases Ze = const Unit
natCases Suc = id
NatD : Desc
NatD = sigma NatConst natCases
Nat : Set
Nat = Mu NatD
ze : Nat
ze = con (Ze , Void)
suc : Nat -> Nat
suc n = con (Suc , n)
--****************
-- List
--****************
data ListConst : Set where
Nil : ListConst
Cons : ListConst
listCases : Set -> ListConst -> Desc
listCases X Nil = const Unit
listCases X Cons = sigma X (\_ -> id)
ListD : Set -> Desc
ListD X = sigma ListConst (listCases X)
List : Set -> Set
List X = Mu (ListD X)
nil : {X : Set} -> List X
nil = con ( Nil , Void )
cons : {X : Set} -> X -> List X -> List X
cons x t = con ( Cons , ( x , t ))
--****************
-- Tree
--****************
data TreeConst : Set where
Leaf : TreeConst
Node : TreeConst
treeCases : Set -> TreeConst -> Desc
treeCases X Leaf = const Unit
treeCases X Node = sigma X (\_ -> prod id id)
TreeD : Set -> Desc
TreeD X = sigma TreeConst (treeCases X)
Tree : Set -> Set
Tree X = Mu (TreeD X)
leaf : {X : Set} -> Tree X
leaf = con (Leaf , Void)
node : {X : Set} -> X -> Tree X -> Tree X -> Tree X
node x le ri = con (Node , (x , (le , ri)))
--********************************************
-- Finite sets
--********************************************
EnumU : Set
EnumU = Nat
nilE : EnumU
nilE = ze
consE : EnumU -> EnumU
consE e = suc e
{-
data EnumU : Set where
nilE : EnumU
consE : EnumU -> EnumU
-}
data EnumT : (e : EnumU) -> Set where
EZe : {e : EnumU} -> EnumT (consE e)
ESu : {e : EnumU} -> EnumT e -> EnumT (consE e)
casesSpi : (xs : [| NatD |] Nat) ->
All NatD Nat (\e -> (P' : EnumT e -> Set) -> Set) xs ->
(P' : EnumT (con xs) -> Set) -> Set
casesSpi (Ze , Void) hs P' = Unit
casesSpi (Suc , n) hs P' = P' EZe * hs (\e -> P' (ESu e))
spi : (e : EnumU)(P : EnumT e -> Set) -> Set
spi e P = induction NatD (\e -> (P : EnumT e -> Set) -> Set) casesSpi e P
{-
spi : (e : EnumU)(P : EnumT e -> Set) -> Set
spi nilE P = Unit
spi (consE e) P = P EZe * spi e (\e -> P (ESu e))
-}
casesSwitch : (xs : [| NatD |] Nat) ->
All NatD Nat (\e -> (P' : EnumT e -> Set)(b' : spi e P')(x' : EnumT e) -> P' x') xs ->
(P' : EnumT (con xs) -> Set)(b' : spi (con xs) P')(x' : EnumT (con xs)) -> P' x'
casesSwitch (Ze , Void) hs P' b' ()
casesSwitch (Suc , n) hs P' b' EZe = fst b'
casesSwitch (Suc , n) hs P' b' (ESu e') = hs (\e -> P' (ESu e)) (snd b') e'
switch : (e : EnumU)(P : EnumT e -> Set)(b : spi e P)(x : EnumT e) -> P x
switch e P b x = induction NatD (\e -> (P : EnumT e -> Set)(b : spi e P)(x : EnumT e) -> P x) casesSwitch e P b x
{-
switch : (e : EnumU)(P : EnumT e -> Set)(b : spi e P)(x : EnumT e) -> P x
switch nilE P b ()
switch (consE e) P b EZe = fst b
switch (consE e) P b (ESu n) = switch e (\e -> P (ESu e)) (snd b) n
-}
--********************************************
-- Tagged description
--********************************************
TagDesc : Set
TagDesc = Sigma EnumU (\e -> spi e (\_ -> Desc))
toDesc : TagDesc -> Desc
toDesc (B , F) = sigma (EnumT B) (\e -> switch B (\_ -> Desc) F e)
--********************************************
-- Catamorphism
--********************************************
cata : (D : Desc)
(T : Set) ->
([| D |] T -> T) ->
(Mu D) -> T
cata D T phi x = induction D (\_ -> T) (\x ms -> phi (replace D T x ms)) x
where replace : (D' : Desc)(T : Set)(xs : [| D' |] (Mu D))(ms : All D' (Mu D) (\_ -> T) xs) -> [| D' |] T
replace id T x y = y
replace (const Z) T z z' = z
replace (prod D D') T (x , x') (y , y') = replace D T x y , replace D' T x' y'
replace (sigma A B) T (a , b) t = a , replace (B a) T b t
replace (pi A B) T f t = \s -> replace (B s) T (f s) (t s)
--********************************************
-- Free monad construction
--********************************************
_**_ : TagDesc -> (X : Set) -> TagDesc
(e , D) ** X = consE e , (const X , D)
--********************************************
-- Substitution
--********************************************
apply : (D : TagDesc)(X Y : Set) ->
(X -> Mu (toDesc (D ** Y))) ->
[| toDesc (D ** X) |] (Mu (toDesc (D ** Y))) ->
Mu (toDesc (D ** Y))
apply (E , B) X Y sig (EZe , x) = sig x
apply (E , B) X Y sig (ESu n , t) = con (ESu n , t)
subst : (D : TagDesc)(X Y : Set) ->
Mu (toDesc (D ** X)) ->
(X -> Mu (toDesc (D ** Y))) ->
Mu (toDesc (D ** Y))
subst D X Y x sig = cata (toDesc (D ** X)) (Mu (toDesc (D ** Y))) (apply D X Y sig) x
|
{
"alphanum_fraction": 0.398075824,
"avg_line_length": 28.9201101928,
"ext": "agda",
"hexsha": "7da4bb5084c7885efd6cc6cdfebb5fdca4fc2a86",
"lang": "Agda",
"max_forks_count": 12,
"max_forks_repo_forks_event_max_datetime": "2022-02-11T01:57:40.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-08-14T21:36:35.000Z",
"max_forks_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mietek/epigram",
"max_forks_repo_path": "models/DescTT.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2",
"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": "mietek/epigram",
"max_issues_repo_path": "models/DescTT.agda",
"max_line_length": 113,
"max_stars_count": 48,
"max_stars_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mietek/epigram",
"max_stars_repo_path": "models/DescTT.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-11T01:55:28.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-01-09T17:36:19.000Z",
"num_tokens": 3553,
"size": 10498
}
|
------------------------------------------------------------------------------
-- Testing the translation of definitions
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module Definition12 where
infixl 9 _·_
infix 7 _≡_
postulate
D : Set
_≡_ : D → D → Set
true if : D
_·_ : D → D → D
postulate if-true : ∀ d₁ {d₂} → if · true · d₁ · d₂ ≡ d₁
{-# ATP axiom if-true #-}
if_then_else_ : D → D → D → D
if b then d₁ else d₂ = if · b · d₁ · d₂
{-# ATP definition if_then_else_ #-}
-- We test the translation of a definition with holes.
postulate foo : ∀ d₁ d₂ → (if true then d₁ else d₂) ≡ d₁
{-# ATP prove foo #-}
|
{
"alphanum_fraction": 0.4577883472,
"avg_line_length": 27.1290322581,
"ext": "agda",
"hexsha": "6be72c470175742dbd0bf2934e007ab422baa7f2",
"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/Succeed/fol-theorems/Definition12.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/Succeed/fol-theorems/Definition12.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/Succeed/fol-theorems/Definition12.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": 221,
"size": 841
}
|
{-# OPTIONS --cubical --safe #-}
module Cubical.HITs.ListedFiniteSet.Base where
open import Cubical.Core.Everything
open import Cubical.Foundations.Logic
open import Cubical.Foundations.Everything
private
variable
A : Type₀
infixr 20 _∷_
infix 30 _∈_
data LFSet (A : Type₀) : Type₀ where
[] : LFSet A
_∷_ : (x : A) → (xs : LFSet A) → LFSet A
dup : ∀ x xs → x ∷ x ∷ xs ≡ x ∷ xs
comm : ∀ x y xs → x ∷ y ∷ xs ≡ y ∷ x ∷ xs
trunc : isSet (LFSet A)
-- Membership.
--
-- Doing some proofs with equational reasoning adds an extra "_∙ refl"
-- at the end.
-- We might want to avoid it, or come up with a more clever equational reasoning.
_∈_ : A → LFSet A → hProp _
z ∈ [] = ⊥
z ∈ (y ∷ xs) = (z ≡ₚ y) ⊔ (z ∈ xs)
z ∈ dup x xs i = proof i
where
-- proof : z ∈ (x ∷ x ∷ xs) ≡ z ∈ (x ∷ xs)
proof = z ≡ₚ x ⊔ (z ≡ₚ x ⊔ z ∈ xs) ≡⟨ ⊔-assoc (z ≡ₚ x) (z ≡ₚ x) (z ∈ xs) ⟩
(z ≡ₚ x ⊔ z ≡ₚ x) ⊔ z ∈ xs ≡⟨ cong (_⊔ (z ∈ xs)) (⊔-idem (z ≡ₚ x)) ⟩
z ≡ₚ x ⊔ z ∈ xs ∎
z ∈ comm x y xs i = proof i
where
-- proof : z ∈ (x ∷ y ∷ xs) ≡ z ∈ (y ∷ x ∷ xs)
proof = z ≡ₚ x ⊔ (z ≡ₚ y ⊔ z ∈ xs) ≡⟨ ⊔-assoc (z ≡ₚ x) (z ≡ₚ y) (z ∈ xs) ⟩
(z ≡ₚ x ⊔ z ≡ₚ y) ⊔ z ∈ xs ≡⟨ cong (_⊔ (z ∈ xs)) (⊔-comm (z ≡ₚ x) (z ≡ₚ y)) ⟩
(z ≡ₚ y ⊔ z ≡ₚ x) ⊔ z ∈ xs ≡⟨ sym (⊔-assoc (z ≡ₚ y) (z ≡ₚ x) (z ∈ xs)) ⟩
z ≡ₚ y ⊔ (z ≡ₚ x ⊔ z ∈ xs) ∎
x ∈ trunc xs ys p q i j = isSetHProp (x ∈ xs) (x ∈ ys) (cong (x ∈_) p) (cong (x ∈_) q) i j
module LFSetElim {ℓ}
(B : LFSet A → Type ℓ)
([]* : B [])
(_∷*_ : (x : A) {xs : LFSet A} → B xs → B (x ∷ xs))
(comm* : (x y : A) {xs : LFSet A} (b : B xs)
→ PathP (λ i → B (comm x y xs i)) (x ∷* (y ∷* b)) (y ∷* (x ∷* b)))
(dup* : (x : A) {xs : LFSet A} (b : B xs)
→ PathP (λ i → B (dup x xs i)) (x ∷* (x ∷* b)) (x ∷* b))
(trunc* : (xs : LFSet A) → isSet (B xs)) where
f : ∀ x → B x
f [] = []*
f (x ∷ xs) = x ∷* f xs
f (dup x xs i) = dup* x (f xs) i
f (comm x y xs i) = comm* x y (f xs) i
f (trunc x y p q i j) =
isOfHLevel→isOfHLevelDep 2 trunc*
(f x) (f y)
(λ i → f (p i)) (λ i → f (q i))
(trunc x y p q) i j
module LFSetRec {ℓ} {B : Type ℓ}
([]* : B)
(_∷*_ : (x : A) → B → B)
(comm* : (x y : A) (xs : B) → (x ∷* (y ∷* xs)) ≡ (y ∷* (x ∷* xs)))
(dup* : (x : A) (b : B) → (x ∷* (x ∷* b)) ≡ (x ∷* b))
(trunc* : isSet B) where
f : LFSet A → B
f = LFSetElim.f _
[]* (λ x xs → x ∷* xs)
(λ x y b → comm* x y b) (λ x b → dup* x b)
λ _ → trunc*
module LFPropElim {ℓ}
(B : LFSet A → Type ℓ)
([]* : B []) (_∷*_ : (x : A) {xs : LFSet A} → B xs → B (x ∷ xs))
(trunc* : (xs : LFSet A) → isProp (B xs)) where
f : ∀ x → B x
f = LFSetElim.f _
[]* _∷*_
(λ _ _ _ → isOfHLevel→isOfHLevelDep 1 trunc* _ _ _)
(λ _ _ → isOfHLevel→isOfHLevelDep 1 trunc* _ _ _)
λ xs → isProp→isSet (trunc* xs)
|
{
"alphanum_fraction": 0.4445585216,
"avg_line_length": 31.4193548387,
"ext": "agda",
"hexsha": "ab100b8f472117f2847a72f4f65e7e2dfcdcbdb7",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "limemloh/cubical",
"max_forks_repo_path": "Cubical/HITs/ListedFiniteSet/Base.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "limemloh/cubical",
"max_issues_repo_path": "Cubical/HITs/ListedFiniteSet/Base.agda",
"max_line_length": 90,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "limemloh/cubical",
"max_stars_repo_path": "Cubical/HITs/ListedFiniteSet/Base.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1423,
"size": 2922
}
|
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
open import LibraBFT.ImplShared.Util.Dijkstra.RWS
open import LibraBFT.ImplShared.Util.Dijkstra.Syntax
open import LibraBFT.Prelude
open import Optics.All
-- This module contains definitions allowing RWS programs to be written using
-- Agda's do-notation, as well as convenient short names for operations
-- (including lens operations).
module LibraBFT.ImplShared.Util.Dijkstra.RWS.Syntax where
private
variable
Ev Wr St : Set
A B C : Set
-- From this instance declaration, we get _<$>_, pure, and _<*>_ also.
instance
RWS-Monad : Monad (RWS Ev Wr St)
Monad.return RWS-Monad = RWS-return
Monad._>>=_ RWS-Monad = RWS-bind
-- These instance declarations give us variant conditional operations that we
-- can define to play nice with `RWS-weakestPre`
instance
RWS-MonadIfD : MonadIfD{ℓ₃ = ℓ0} (RWS Ev Wr St)
MonadIfD.monad RWS-MonadIfD = RWS-Monad
MonadIfD.ifD‖ RWS-MonadIfD = RWS-if
RWS-MonadMaybeD : MonadMaybeD (RWS Ev Wr St)
MonadMaybeD.monad RWS-MonadMaybeD = RWS-Monad
MonadMaybeD.maybeSD RWS-MonadMaybeD = RWS-maybe
RWS-MonadEitherD : MonadEitherD (RWS Ev Wr St)
MonadEitherD.monad RWS-MonadEitherD = RWS-Monad
MonadEitherD.eitherSD RWS-MonadEitherD = RWS-either
gets : (St → A) → RWS Ev Wr St A
gets = RWS-gets
get : RWS Ev Wr St St
get = gets id
put : St → RWS Ev Wr St Unit
put = RWS-put
modify : (St → St) → RWS Ev Wr St Unit
modify f = do
st ← get
put (f st)
ask : RWS Ev Wr St Ev
ask = RWS-ask
tell : List Wr → RWS Ev Wr St Unit
tell = RWS-tell
tell1 : Wr → RWS Ev Wr St Unit
tell1 x = tell (x ∷ [])
act = tell1
void : RWS Ev Wr St A → RWS Ev Wr St Unit
void m = do
_ ← m
pure unit
-- -- Composition with error monad
ok : A → RWS Ev Wr St (B ⊎ A)
ok = pure ∘ Right
bail : B → RWS Ev Wr St (B ⊎ A)
bail = pure ∘ Left
infixl 4 _∙?∙_
_∙?∙_ : RWS Ev Wr St (Either C A) → (A → RWS Ev Wr St (Either C B)) → RWS Ev Wr St (Either C B)
_∙?∙_ = RWS-ebind
maybeSM : RWS Ev Wr St (Maybe A) → RWS Ev Wr St B → (A → RWS Ev Wr St B) → RWS Ev Wr St B
maybeSM mma mb f = do
x ← mma
caseMD x of λ where
nothing → mb
(just j) → f j
maybeSMP-RWS : RWS Ev Wr St (Maybe A) → B → (A → RWS Ev Wr St B)
→ RWS Ev Wr St B
maybeSMP-RWS ma b f = do
x ← ma
caseMD x of λ where
nothing → pure b
(just j) → f j
infixl 4 _∙^∙_
_∙^∙_ : RWS Ev Wr St (Either B A) → (B → B) → RWS Ev Wr St (Either B A)
m ∙^∙ f = do
x ← m
either (bail ∘ f) ok x
RWS-weakestPre-∙^∙Post : (ev : Ev) (e : C → C) → RWS-Post Wr St (C ⊎ A) → RWS-Post Wr St (C ⊎ A)
RWS-weakestPre-∙^∙Post ev e Post =
RWS-weakestPre-bindPost ev (either (bail ∘ e) ok) Post
-- Lens functionality
--
-- If we make RWS work for different level State types, we will break use and
-- modify because Lens does not support different levels, we define use and
-- modify' here for RoundManager. We are ok as long as we can keep
-- RoundManager in Set. If we ever need to make RoundManager at some higher
-- Level, we will have to consider making Lens level-agnostic. Preliminary
-- exploration by @cwjnkins showed this to be somewhat painful in particular
-- around composition, so we are not pursuing it for now.
use : Lens St A → RWS Ev Wr St A
use f = gets (_^∙ f)
modifyL : Lens St A → (A → A) → RWS Ev Wr St Unit
modifyL l f = modify (over l f)
syntax modifyL l f = l %= f
setL : Lens St A → A → RWS Ev Wr St Unit
setL l x = l %= const x
syntax setL l x = l ∙= x
setL? : Lens St (Maybe A) → A → RWS Ev Wr St Unit
setL? l x = l ∙= just x
syntax setL? l x = l ?= x
|
{
"alphanum_fraction": 0.6679968077,
"avg_line_length": 28.2631578947,
"ext": "agda",
"hexsha": "c579f2a0c67a659156e911e932117081396ec709",
"lang": "Agda",
"max_forks_count": 6,
"max_forks_repo_forks_event_max_datetime": "2022-02-18T01:04:32.000Z",
"max_forks_repo_forks_event_min_datetime": "2020-12-16T19:43:52.000Z",
"max_forks_repo_head_hexsha": "49f8b1b70823be805d84ffc3157c3b880edb1e92",
"max_forks_repo_licenses": [
"UPL-1.0"
],
"max_forks_repo_name": "oracle/bft-consensus-agda",
"max_forks_repo_path": "LibraBFT/ImplShared/Util/Dijkstra/RWS/Syntax.agda",
"max_issues_count": 72,
"max_issues_repo_head_hexsha": "49f8b1b70823be805d84ffc3157c3b880edb1e92",
"max_issues_repo_issues_event_max_datetime": "2022-03-25T05:36:11.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-02-04T05:04:33.000Z",
"max_issues_repo_licenses": [
"UPL-1.0"
],
"max_issues_repo_name": "oracle/bft-consensus-agda",
"max_issues_repo_path": "LibraBFT/ImplShared/Util/Dijkstra/RWS/Syntax.agda",
"max_line_length": 111,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "49f8b1b70823be805d84ffc3157c3b880edb1e92",
"max_stars_repo_licenses": [
"UPL-1.0"
],
"max_stars_repo_name": "oracle/bft-consensus-agda",
"max_stars_repo_path": "LibraBFT/ImplShared/Util/Dijkstra/RWS/Syntax.agda",
"max_stars_repo_stars_event_max_datetime": "2021-12-18T19:24:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-12-16T19:43:41.000Z",
"num_tokens": 1348,
"size": 3759
}
|
{-# OPTIONS --without-K #-}
module combination where
open import Type
open import Data.Nat.NP
open import Data.Nat.DivMod
open import Data.Fin using (Fin; Fin′; zero; suc) renaming (toℕ to Fin▹ℕ)
open import Data.Zero
open import Data.One
open import Data.Two
open import Data.Sum
open import Data.Product
open import Data.Vec
open import Function.NP
open import Function.Related.TypeIsomorphisms.NP
import Function.Inverse.NP as Inv
open Inv using (_↔_; sym; inverses; module Inverse) renaming (_$₁_ to to; _$₂_ to from; id to idI; _∘_ to _∘I_)
open import Relation.Binary.Product.Pointwise
open import Relation.Binary.Sum
import Relation.Binary.PropositionalEquality as ≡
open import factorial
_/_ : ℕ → ℕ → ℕ
x / y = _div_ x y {{!!}}
module v0 where
C : ℕ → ℕ → ℕ
C n zero = 1
C zero (suc k) = 0
C (suc n) (suc k) = C n k + C n (suc k)
D : ℕ → ℕ → ★
D n zero = 𝟙
D zero (suc k) = 𝟘
D (suc n) (suc k) = D n k ⊎ D n (suc k)
FinC≅D : ∀ n k → Fin (C n k) ↔ D n k
FinC≅D n zero = Fin1↔𝟙
FinC≅D zero (suc k) = Fin0↔𝟘
FinC≅D (suc n) (suc k) = FinC≅D n k ⊎-cong FinC≅D n (suc k)
∘I sym (Fin-⊎-+ (C n k) (C n (suc k)))
module v! where
C : ℕ → ℕ → ℕ
C n k = n ! / (k ! * (n ∸ k)!)
module v1 where
C : ℕ → ℕ → ℕ
C n 0 = 1
C n (suc k) = (C n k * (n ∸ k)) / suc k
module v2 where
C : ℕ → ℕ → ℕ
C n zero = 1
C zero (suc k) = 0
C (suc n) (suc k) = (C n k * suc n) / suc k
{- Σ_{0≤k<n} (C n k) ≡ 2ⁿ -}
Σ𝟙F↔F : ∀ (F : 𝟙 → ★) → Σ 𝟙 F ↔ F _
Σ𝟙F↔F F = inverses proj₂ ,_ (λ _ → ≡.refl) (λ _ → ≡.refl)
Bits = Vec 𝟚
Bits1↔𝟚 : Bits 1 ↔ 𝟚
Bits1↔𝟚 = {!!}
open v0
foo : ∀ n → Σ (Fin (suc n)) (D (suc n) ∘ Fin▹ℕ) ↔ Bits (suc n)
foo zero = ((sym Bits1↔𝟚 ∘I {!!}) ∘I Σ𝟙F↔F _) ∘I first-iso Fin1↔𝟙
foo (suc n) = {!!}
|
{
"alphanum_fraction": 0.5603732162,
"avg_line_length": 23.6623376623,
"ext": "agda",
"hexsha": "dac01db1c808cab1a18f5c25bcc647b8f577b39f",
"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": "16bc8333503ff9c00d47d56f4ec6113b9269a43e",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "crypto-agda/explore",
"max_forks_repo_path": "experimental-examples/combination.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e",
"max_issues_repo_issues_event_max_datetime": "2019-03-16T14:24:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-03-16T14:24:04.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "crypto-agda/explore",
"max_issues_repo_path": "experimental-examples/combination.agda",
"max_line_length": 111,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "crypto-agda/explore",
"max_stars_repo_path": "experimental-examples/combination.agda",
"max_stars_repo_stars_event_max_datetime": "2017-06-28T19:19:29.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-06-05T09:25:32.000Z",
"num_tokens": 827,
"size": 1822
}
|
module eq-reasoning {A : Set} where
open import eq
infix 1 begin_
infixr 2 _≡⟨⟩_ _≡⟨_⟩_
infix 3 _∎
begin_ : ∀ {x y : A}
→ x ≡ y
-----
→ x ≡ y
begin x≡y = x≡y
_≡⟨⟩_ : ∀ (x : A) {y : A}
→ x ≡ y
-----
→ x ≡ y
x ≡⟨⟩ x≡y = x≡y
_≡⟨_⟩_ : ∀ (x : A) {y z : A}
→ x ≡ y
→ y ≡ z
-----
→ x ≡ z
x ≡⟨ x≡y ⟩ y≡z = trans x≡y y≡z
_∎ : ∀ (x : A)
-----
→ x ≡ x
x ∎ = refl
|
{
"alphanum_fraction": 0.32,
"avg_line_length": 14.0625,
"ext": "agda",
"hexsha": "127768b0636bcc437c4e61629c478ea663e7d53e",
"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": "eq-reasoning.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": "eq-reasoning.agda",
"max_line_length": 35,
"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": "eq-reasoning.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 252,
"size": 450
}
|
{-# OPTIONS --without-K #-}
module Util.HoTT.Univalence.Statement where
open import Util.HoTT.Equiv
open import Util.Prelude
Univalence : ∀ α → Set (lsuc α)
Univalence α = {A B : Set α} → IsEquiv (≡→≃ {A = A} {B = B})
|
{
"alphanum_fraction": 0.6515837104,
"avg_line_length": 22.1,
"ext": "agda",
"hexsha": "9c9429b0f4292ead6bc49df6ae32c7a52e0ba6d8",
"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/Statement.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/Statement.agda",
"max_line_length": 60,
"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/Statement.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": 74,
"size": 221
}
|
module Luau.Heap where
open import Agda.Builtin.Equality using (_≡_)
open import FFI.Data.Maybe using (Maybe; just)
open import FFI.Data.Vector using (Vector; length; snoc; empty)
open import Luau.Addr using (Addr)
open import Luau.Var using (Var)
open import Luau.Syntax using (Block; Expr; nil; addr; function⟨_⟩_end)
data HeapValue : Set where
function_⟨_⟩_end : Var → Var → Block → HeapValue
Heap = Vector HeapValue
data _≡_⊕_↦_ : Heap → Heap → Addr → HeapValue → Set where
defn : ∀ {H val} →
-----------------------------------
(snoc H val) ≡ H ⊕ (length H) ↦ val
lookup : Heap → Addr → Maybe HeapValue
lookup = FFI.Data.Vector.lookup
emp : Heap
emp = empty
data AllocResult (H : Heap) (V : HeapValue) : Set where
ok : ∀ a H′ → (H′ ≡ H ⊕ a ↦ V) → AllocResult H V
alloc : ∀ H V → AllocResult H V
alloc H V = ok (length H) (snoc H V) defn
next : Heap → Addr
next = length
allocated : Heap → HeapValue → Heap
allocated = snoc
-- next-emp : (length empty ≡ 0)
next-emp = FFI.Data.Vector.length-empty
-- lookup-next : ∀ V H → (lookup (allocated H V) (next H) ≡ just V)
lookup-next = FFI.Data.Vector.lookup-snoc
-- lookup-next-emp : ∀ V → (lookup (allocated emp V) 0 ≡ just V)
lookup-next-emp = FFI.Data.Vector.lookup-snoc-empty
|
{
"alphanum_fraction": 0.6518282989,
"avg_line_length": 25.6734693878,
"ext": "agda",
"hexsha": "1a0416e472bdad83a9ded3dca03908b866b48a6c",
"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": "5187e64f88953f34785ffe58acd0610ee5041f5f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "FreakingBarbarians/luau",
"max_forks_repo_path": "prototyping/Luau/Heap.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "5187e64f88953f34785ffe58acd0610ee5041f5f",
"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": "FreakingBarbarians/luau",
"max_issues_repo_path": "prototyping/Luau/Heap.agda",
"max_line_length": 71,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "5187e64f88953f34785ffe58acd0610ee5041f5f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "FreakingBarbarians/luau",
"max_stars_repo_path": "prototyping/Luau/Heap.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-11T21:30:17.000Z",
"max_stars_repo_stars_event_min_datetime": "2022-02-11T21:30:17.000Z",
"num_tokens": 400,
"size": 1258
}
|
open import Oscar.Prelude
open import Oscar.Data.𝟘
module Oscar.Data.ProperlyExtensionNothing where
module _
{𝔵} {𝔛 : Ø 𝔵}
{𝔬} {𝔒 : 𝔛 → Ø 𝔬}
{ℓ}
{ℓ̇} {_↦_ : ∀ {x} → 𝔒 x → 𝔒 x → Ø ℓ̇}
where
record ProperlyExtensionNothing (P : ExtensionṖroperty ℓ 𝔒 _↦_) : Ø 𝔵 ∙̂ 𝔬 ∙̂ ℓ where
constructor ∁
field
π₀ : ∀ {n} {f : 𝔒 n} → π₀ (π₀ P) f → 𝟘
open ProperlyExtensionNothing public
|
{
"alphanum_fraction": 0.6004962779,
"avg_line_length": 20.15,
"ext": "agda",
"hexsha": "06079f7a5fde6eb86489bde8b4d0ff0ed72de167",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_forks_repo_licenses": [
"RSA-MD"
],
"max_forks_repo_name": "m0davis/oscar",
"max_forks_repo_path": "archive/agda-3/src/Oscar/Data/ProperlyExtensionNothing.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z",
"max_issues_repo_licenses": [
"RSA-MD"
],
"max_issues_repo_name": "m0davis/oscar",
"max_issues_repo_path": "archive/agda-3/src/Oscar/Data/ProperlyExtensionNothing.agda",
"max_line_length": 88,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_stars_repo_licenses": [
"RSA-MD"
],
"max_stars_repo_name": "m0davis/oscar",
"max_stars_repo_path": "archive/agda-3/src/Oscar/Data/ProperlyExtensionNothing.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 194,
"size": 403
}
|
------------------------------------------------------------------------------
-- Totality properties respect to OrdTree
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOTC.Program.SortList.Properties.Totality.OrdTreeI where
open import Common.FOL.Relation.Binary.EqReasoning
open import FOTC.Base
open import FOTC.Data.Bool
open import FOTC.Data.Bool.PropertiesI
open import FOTC.Data.Nat.Inequalities
open import FOTC.Data.Nat.Inequalities.PropertiesI
open import FOTC.Data.Nat.List.Type
open import FOTC.Data.Nat.Type
open import FOTC.Program.SortList.SortList
open import FOTC.Program.SortList.Properties.Totality.BoolI
open import FOTC.Program.SortList.Properties.Totality.TreeI
------------------------------------------------------------------------------
-- Subtrees
-- If (node t₁ i t₂) is ordered then t₁ is ordered.
leftSubTree-OrdTree : ∀ {t₁ i t₂} → Tree t₁ → N i → Tree t₂ →
OrdTree (node t₁ i t₂) → OrdTree t₁
leftSubTree-OrdTree {t₁} {i} {t₂} Tt₁ Ni Tt₂ TOnode =
ordTree t₁
≡⟨ &&-list₂-t₁ (ordTree-Bool Tt₁)
(&&-Bool (ordTree-Bool Tt₂)
(&&-Bool (le-TreeItem-Bool Tt₁ Ni)
(le-ItemTree-Bool Ni Tt₂)))
(trans (sym (ordTree-node t₁ i t₂)) TOnode)
⟩
true ∎
-- If (node t₁ i t₂) is ordered then t₂ is ordered.
rightSubTree-OrdTree : ∀ {t₁ i t₂} → Tree t₁ → N i → Tree t₂ →
OrdTree (node t₁ i t₂) → OrdTree t₂
rightSubTree-OrdTree {t₁} {i} {t₂} Tt₁ Ni Tt₂ TOnode =
ordTree t₂
≡⟨ &&-list₂-t₁
(ordTree-Bool Tt₂)
(&&-Bool (le-TreeItem-Bool Tt₁ Ni)
(le-ItemTree-Bool Ni Tt₂))
(&&-list₂-t₂ (ordTree-Bool Tt₁)
(&&-Bool (ordTree-Bool Tt₂)
(&&-Bool (le-TreeItem-Bool Tt₁ Ni)
(le-ItemTree-Bool Ni Tt₂)))
(trans (sym (ordTree-node t₁ i t₂)) TOnode))
⟩
true ∎
------------------------------------------------------------------------------
-- Helper functions
toTree-OrdTree-helper₁ : ∀ {i₁ i₂ t} → N i₁ → N i₂ → i₁ > i₂ →
Tree t →
≤-TreeItem t i₁ →
≤-TreeItem (toTree · i₂ · t) i₁
toTree-OrdTree-helper₁ {i₁} {i₂} .{nil} Ni₁ Ni₂ i₁>i₂ tnil _ =
le-TreeItem (toTree · i₂ · nil) i₁
≡⟨ subst (λ t → le-TreeItem (toTree · i₂ · nil) i₁ ≡ le-TreeItem t i₁)
(toTree-nil i₂)
refl
⟩
le-TreeItem (tip i₂) i₁
≡⟨ le-TreeItem-tip i₂ i₁ ⟩
le i₂ i₁
≡⟨ x<y→x≤y Ni₂ Ni₁ i₁>i₂ ⟩
true ∎
toTree-OrdTree-helper₁ {i₁} {i₂} Ni₁ Ni₂ i₁>i₂ (ttip {j} Nj) t≤i₁ =
case prf₁ prf₂ (x>y∨x≤y Nj Ni₂)
where
prf₁ : j > i₂ → ≤-TreeItem (toTree · i₂ · tip j) i₁
prf₁ j>i₂ =
le-TreeItem (toTree · i₂ · tip j) i₁
≡⟨ subst (λ t → le-TreeItem (toTree · i₂ · tip j) i₁ ≡
le-TreeItem t i₁)
(toTree-tip i₂ j)
refl
⟩
le-TreeItem (if (le j i₂)
then (node (tip j) i₂ (tip i₂))
else (node (tip i₂) j (tip j))) i₁
≡⟨ subst (λ t → le-TreeItem
(if (le j i₂)
then (node (tip j) i₂ (tip i₂))
else (node (tip i₂) j (tip j))) i₁ ≡
le-TreeItem (if t
then (node (tip j) i₂ (tip i₂))
else (node (tip i₂) j (tip j))) i₁)
(x>y→x≰y Nj Ni₂ j>i₂)
refl
⟩
le-TreeItem (if false
then (node (tip j) i₂ (tip i₂))
else (node (tip i₂) j (tip j))) i₁
≡⟨ subst (λ t → le-TreeItem (if false
then (node (tip j) i₂ (tip i₂))
else (node (tip i₂) j (tip j))) i₁ ≡
le-TreeItem t i₁)
(if-false (node (tip i₂) j (tip j)))
refl
⟩
le-TreeItem (node (tip i₂) j (tip j)) i₁
≡⟨ le-TreeItem-node (tip i₂) j (tip j) i₁ ⟩
le-TreeItem (tip i₂) i₁ && le-TreeItem (tip j) i₁
≡⟨ subst (λ t → le-TreeItem (tip i₂) i₁ && le-TreeItem (tip j) i₁ ≡
t && le-TreeItem (tip j) i₁)
(le-TreeItem-tip i₂ i₁)
refl
⟩
le i₂ i₁ && le-TreeItem (tip j) i₁
≡⟨ subst (λ t → le i₂ i₁ && le-TreeItem (tip j) i₁ ≡
t && le-TreeItem (tip j) i₁)
(x<y→x≤y Ni₂ Ni₁ i₁>i₂)
refl
⟩
true && le-TreeItem (tip j) i₁
≡⟨ subst (λ t → true && le-TreeItem (tip j) i₁ ≡ true && t)
(le-TreeItem-tip j i₁)
refl
⟩
true && le j i₁
≡⟨ subst (λ t → true && le j i₁ ≡ true && t)
-- j ≤ i₁ because by hypothesis we have (tip j) ≤ i₁.
(trans (sym (le-TreeItem-tip j i₁)) t≤i₁)
refl
⟩
true && true
≡⟨ t&&x≡x true ⟩
true ∎
prf₂ : j ≤ i₂ → ≤-TreeItem (toTree · i₂ · tip j) i₁
prf₂ j≤i₂ =
le-TreeItem (toTree · i₂ · tip j) i₁
≡⟨ subst (λ t → le-TreeItem (toTree · i₂ · tip j) i₁ ≡
le-TreeItem t i₁)
(toTree-tip i₂ j)
refl
⟩
le-TreeItem (if (le j i₂)
then (node (tip j) i₂ (tip i₂))
else (node (tip i₂) j (tip j))) i₁
≡⟨ subst (λ t → le-TreeItem
(if (le j i₂)
then (node (tip j) i₂ (tip i₂))
else (node (tip i₂) j (tip j))) i₁ ≡
le-TreeItem (if t
then (node (tip j) i₂ (tip i₂))
else (node (tip i₂) j (tip j))) i₁)
j≤i₂
refl
⟩
le-TreeItem (if true
then (node (tip j) i₂ (tip i₂))
else (node (tip i₂) j (tip j))) i₁
≡⟨ subst (λ t → le-TreeItem (if true
then (node (tip j) i₂ (tip i₂))
else (node (tip i₂) j (tip j))) i₁ ≡
le-TreeItem t i₁)
(if-true (node (tip j) i₂ (tip i₂)))
refl
⟩
le-TreeItem (node (tip j) i₂ (tip i₂)) i₁
≡⟨ le-TreeItem-node (tip j) i₂ (tip i₂) i₁ ⟩
le-TreeItem (tip j) i₁ && le-TreeItem (tip i₂) i₁
≡⟨ subst (λ t → le-TreeItem (tip j) i₁ && le-TreeItem (tip i₂) i₁ ≡
t && le-TreeItem (tip i₂) i₁)
(le-TreeItem-tip j i₁)
refl
⟩
le j i₁ && le-TreeItem (tip i₂) i₁
≡⟨ subst (λ t → le j i₁ && le-TreeItem (tip i₂) i₁ ≡
t && le-TreeItem (tip i₂) i₁)
-- j ≤ i₁ because by hypothesis we have (tip j) ≤ i₁.
(trans (sym (le-TreeItem-tip j i₁)) t≤i₁)
refl
⟩
true && le-TreeItem (tip i₂) i₁
≡⟨ subst (λ t → true && le-TreeItem (tip i₂) i₁ ≡ true && t)
(le-TreeItem-tip i₂ i₁)
refl
⟩
true && le i₂ i₁
≡⟨ subst (λ t → true && le i₂ i₁ ≡ true && t)
(x<y→x≤y Ni₂ Ni₁ i₁>i₂)
refl
⟩
true && true
≡⟨ t&&x≡x true ⟩
true ∎
toTree-OrdTree-helper₁ {i₁} {i₂} Ni₁ Ni₂ i₁>i₂
(tnode {t₁} {j} {t₂} Tt₁ Nj Tt₂) t≤i₁ =
case prf₁ prf₂ (x>y∨x≤y Nj Ni₂)
where
prf₁ : j > i₂ → ≤-TreeItem (toTree · i₂ · node t₁ j t₂) i₁
prf₁ j>i₂ =
le-TreeItem (toTree · i₂ · node t₁ j t₂) i₁
≡⟨ subst (λ t → le-TreeItem (toTree · i₂ · node t₁ j t₂) i₁ ≡
le-TreeItem t i₁)
(toTree-node i₂ t₁ j t₂)
refl
⟩
le-TreeItem (if (le j i₂)
then (node t₁ j (toTree · i₂ · t₂))
else (node (toTree · i₂ · t₁) j t₂)) i₁
≡⟨ subst (λ t → le-TreeItem
(if (le j i₂)
then (node t₁ j (toTree · i₂ · t₂))
else (node (toTree · i₂ · t₁) j t₂)) i₁ ≡
le-TreeItem
(if t
then (node t₁ j (toTree · i₂ · t₂))
else (node (toTree · i₂ · t₁) j t₂)) i₁)
(x>y→x≰y Nj Ni₂ j>i₂)
refl
⟩
le-TreeItem (if false
then (node t₁ j (toTree · i₂ · t₂))
else (node (toTree · i₂ · t₁) j t₂)) i₁
≡⟨ subst (λ t → le-TreeItem (if false
then (node t₁ j (toTree · i₂ · t₂))
else (node (toTree · i₂ · t₁) j t₂)) i₁ ≡
le-TreeItem t i₁)
(if-false (node (toTree · i₂ · t₁) j t₂))
refl
⟩
le-TreeItem (node (toTree · i₂ · t₁) j t₂) i₁
≡⟨ le-TreeItem-node (toTree · i₂ · t₁) j t₂ i₁ ⟩
le-TreeItem (toTree · i₂ · t₁) i₁ && le-TreeItem t₂ i₁
≡⟨ subst (λ t → le-TreeItem (toTree · i₂ · t₁) i₁ &&
le-TreeItem t₂ i₁ ≡
t &&
le-TreeItem t₂ i₁)
-- Inductive hypothesis.
(toTree-OrdTree-helper₁ Ni₁ Ni₂ i₁>i₂ Tt₁
(&&-list₂-t₁ (le-TreeItem-Bool Tt₁ Ni₁)
(le-TreeItem-Bool Tt₂ Ni₁)
(trans (sym (le-TreeItem-node t₁ j t₂ i₁)) t≤i₁)))
refl
⟩
true && le-TreeItem t₂ i₁
≡⟨ subst (λ t → true && le-TreeItem t₂ i₁ ≡ true && t)
-- t₂ ≤ i₁ because by hypothesis we have (node t₁ j t₂) ≤ i₁.
(&&-list₂-t₂ (le-TreeItem-Bool Tt₁ Ni₁)
(le-TreeItem-Bool Tt₂ Ni₁)
(trans (sym (le-TreeItem-node t₁ j t₂ i₁)) t≤i₁))
refl
⟩
true && true
≡⟨ t&&x≡x true ⟩
true ∎
prf₂ : j ≤ i₂ → ≤-TreeItem (toTree · i₂ · node t₁ j t₂) i₁
prf₂ j≤i₂ =
le-TreeItem (toTree · i₂ · node t₁ j t₂) i₁
≡⟨ subst (λ t → le-TreeItem (toTree · i₂ · node t₁ j t₂) i₁ ≡
le-TreeItem t i₁)
(toTree-node i₂ t₁ j t₂)
refl
⟩
le-TreeItem (if (le j i₂)
then (node t₁ j (toTree · i₂ · t₂))
else (node (toTree · i₂ · t₁) j t₂)) i₁
≡⟨ subst (λ t → le-TreeItem
(if (le j i₂)
then (node t₁ j (toTree · i₂ · t₂))
else (node (toTree · i₂ · t₁) j t₂)) i₁ ≡
le-TreeItem
(if t
then (node t₁ j (toTree · i₂ · t₂))
else (node (toTree · i₂ · t₁) j t₂)) i₁)
(j≤i₂)
refl
⟩
le-TreeItem (if true
then (node t₁ j (toTree · i₂ · t₂))
else (node (toTree · i₂ · t₁) j t₂)) i₁
≡⟨ subst (λ t → le-TreeItem (if true
then (node t₁ j (toTree · i₂ · t₂))
else (node (toTree · i₂ · t₁) j t₂)) i₁ ≡
le-TreeItem t i₁)
(if-true (node t₁ j (toTree · i₂ · t₂)))
refl
⟩
le-TreeItem (node t₁ j (toTree · i₂ · t₂)) i₁
≡⟨ le-TreeItem-node t₁ j (toTree · i₂ · t₂) i₁ ⟩
le-TreeItem t₁ i₁ && le-TreeItem (toTree · i₂ · t₂) i₁
≡⟨ subst (λ t → le-TreeItem t₁ i₁ && le-TreeItem (toTree · i₂ · t₂) i₁ ≡
t && le-TreeItem (toTree · i₂ · t₂) i₁)
-- t₁ ≤ i₁ because by hypothesis we have (node t₁ j t₂) ≤ i₁.
(&&-list₂-t₁ (le-TreeItem-Bool Tt₁ Ni₁)
(le-TreeItem-Bool Tt₂ Ni₁)
(trans (sym (le-TreeItem-node t₁ j t₂ i₁)) t≤i₁))
refl
⟩
true && le-TreeItem (toTree · i₂ · t₂) i₁
≡⟨ subst (λ t → true && le-TreeItem (toTree · i₂ · t₂) i₁ ≡
true && t)
-- Inductive hypothesis.
(toTree-OrdTree-helper₁ Ni₁ Ni₂ i₁>i₂ Tt₂
(&&-list₂-t₂ (le-TreeItem-Bool Tt₁ Ni₁)
(le-TreeItem-Bool Tt₂ Ni₁)
(trans (sym (le-TreeItem-node t₁ j t₂ i₁)) t≤i₁)))
refl
⟩
true && true
≡⟨ t&&x≡x true ⟩
true ∎
------------------------------------------------------------------------------
toTree-OrdTree-helper₂ : ∀ {i₁ i₂ t} → N i₁ → N i₂ → i₁ ≤ i₂ →
Tree t →
≤-ItemTree i₁ t →
≤-ItemTree i₁ (toTree · i₂ · t)
toTree-OrdTree-helper₂ {i₁} {i₂} .{nil} _ _ i₁≤i₂ tnil _ =
le-ItemTree i₁ (toTree · i₂ · nil)
≡⟨ subst (λ t → le-ItemTree i₁ (toTree · i₂ · nil) ≡ le-ItemTree i₁ t)
(toTree-nil i₂)
refl
⟩
le-ItemTree i₁ (tip i₂)
≡⟨ le-ItemTree-tip i₁ i₂ ⟩
le i₁ i₂
≡⟨ i₁≤i₂ ⟩
true ∎
toTree-OrdTree-helper₂ {i₁} {i₂} Ni₁ Ni₂ i₁≤i₂ (ttip {j} Nj) i₁≤t =
case prf₁ prf₂ (x>y∨x≤y Nj Ni₂)
where
prf₁ : j > i₂ → ≤-ItemTree i₁ (toTree · i₂ · tip j)
prf₁ j>i₂ =
le-ItemTree i₁ (toTree · i₂ · tip j)
≡⟨ subst (λ t → le-ItemTree i₁ (toTree · i₂ · tip j) ≡
le-ItemTree i₁ t)
(toTree-tip i₂ j)
refl
⟩
le-ItemTree i₁ (if (le j i₂)
then (node (tip j) i₂ (tip i₂))
else (node (tip i₂) j (tip j)))
≡⟨ subst (λ t → le-ItemTree i₁ (if (le j i₂)
then (node (tip j) i₂ (tip i₂))
else (node (tip i₂) j (tip j))) ≡
le-ItemTree i₁ (if t
then (node (tip j) i₂ (tip i₂))
else (node (tip i₂) j (tip j))))
(x>y→x≰y Nj Ni₂ j>i₂)
refl
⟩
le-ItemTree i₁ (if false
then (node (tip j) i₂ (tip i₂))
else (node (tip i₂) j (tip j)))
≡⟨ subst (λ t → le-ItemTree i₁ (if false
then (node (tip j) i₂ (tip i₂))
else (node (tip i₂) j (tip j))) ≡
le-ItemTree i₁ t)
(if-false (node (tip i₂) j (tip j)))
refl
⟩
le-ItemTree i₁ (node (tip i₂) j (tip j))
≡⟨ le-ItemTree-node i₁ (tip i₂) j (tip j) ⟩
le-ItemTree i₁ (tip i₂) && le-ItemTree i₁ (tip j)
≡⟨ subst (λ t → le-ItemTree i₁ (tip i₂) && le-ItemTree i₁ (tip j) ≡
t && le-ItemTree i₁ (tip j))
(le-ItemTree-tip i₁ i₂)
refl
⟩
le i₁ i₂ && le-ItemTree i₁ (tip j)
≡⟨ subst (λ t → le i₁ i₂ && le-ItemTree i₁ (tip j) ≡
t && le-ItemTree i₁ (tip j))
i₁≤i₂
refl
⟩
true && le-ItemTree i₁ (tip j)
≡⟨ subst (λ t → true && le-ItemTree i₁ (tip j) ≡ true && t)
(le-ItemTree-tip i₁ j)
refl
⟩
true && le i₁ j
≡⟨ subst (λ t → true && le i₁ j ≡ true && t)
-- i₁ ≤ j because by hypothesis we have i₁ ≤ (tip j).
(trans (sym (le-ItemTree-tip i₁ j)) i₁≤t)
refl
⟩
true && true
≡⟨ t&&x≡x true ⟩
true ∎
prf₂ : j ≤ i₂ → ≤-ItemTree i₁ (toTree · i₂ · tip j)
prf₂ j≤i₂ =
le-ItemTree i₁ (toTree · i₂ · tip j)
≡⟨ subst (λ t → le-ItemTree i₁ (toTree · i₂ · tip j) ≡
le-ItemTree i₁ t)
(toTree-tip i₂ j)
refl
⟩
le-ItemTree i₁ (if (le j i₂)
then (node (tip j) i₂ (tip i₂))
else (node (tip i₂) j (tip j)))
≡⟨ subst (λ t → le-ItemTree i₁ (if (le j i₂)
then (node (tip j) i₂ (tip i₂))
else (node (tip i₂) j (tip j))) ≡
le-ItemTree i₁ (if t
then (node (tip j) i₂ (tip i₂))
else (node (tip i₂) j (tip j))))
j≤i₂
refl
⟩
le-ItemTree i₁ (if true
then (node (tip j) i₂ (tip i₂))
else (node (tip i₂) j (tip j)))
≡⟨ subst (λ t → le-ItemTree i₁ (if true
then (node (tip j) i₂ (tip i₂))
else (node (tip i₂) j (tip j))) ≡
le-ItemTree i₁ t)
(if-true (node (tip j) i₂ (tip i₂)))
refl
⟩
le-ItemTree i₁ (node (tip j) i₂ (tip i₂))
≡⟨ le-ItemTree-node i₁ (tip j) i₂ (tip i₂) ⟩
le-ItemTree i₁ (tip j) && le-ItemTree i₁ (tip i₂)
≡⟨ subst (λ t → le-ItemTree i₁ (tip j) && le-ItemTree i₁ (tip i₂) ≡
t && le-ItemTree i₁ (tip i₂))
(le-ItemTree-tip i₁ j)
refl
⟩
le i₁ j && le-ItemTree i₁ (tip i₂)
≡⟨ subst (λ t → le i₁ j && le-ItemTree i₁ (tip i₂) ≡
t && le-ItemTree i₁ (tip i₂))
-- i₁ ≤ j because by hypothesis we have i₁ ≤ (tip j).
(trans (sym (le-ItemTree-tip i₁ j)) i₁≤t)
refl
⟩
true && le-ItemTree i₁ (tip i₂)
≡⟨ subst (λ t → true && le-ItemTree i₁ (tip i₂) ≡ true && t)
(le-ItemTree-tip i₁ i₂)
refl
⟩
true && le i₁ i₂
≡⟨ subst (λ t → true && le i₁ i₂ ≡ true && t)
i₁≤i₂
refl
⟩
true && true
≡⟨ t&&x≡x true ⟩
true ∎
toTree-OrdTree-helper₂ {i₁} {i₂} Ni₁ Ni₂ i₁≤i₂
(tnode {t₁} {j} {t₂} Tt₁ Nj Tt₂) i₁≤t =
case prf₁ prf₂ (x>y∨x≤y Nj Ni₂)
where
prf₁ : j > i₂ → ≤-ItemTree i₁ (toTree · i₂ · node t₁ j t₂)
prf₁ j>i₂ =
le-ItemTree i₁ (toTree · i₂ · node t₁ j t₂)
≡⟨ subst (λ t → le-ItemTree i₁ (toTree · i₂ · node t₁ j t₂) ≡
le-ItemTree i₁ t)
(toTree-node i₂ t₁ j t₂)
refl
⟩
le-ItemTree i₁ (if (le j i₂)
then (node t₁ j (toTree · i₂ · t₂))
else (node (toTree · i₂ · t₁) j t₂))
≡⟨ subst (λ t → le-ItemTree i₁ (if (le j i₂)
then (node t₁ j (toTree · i₂ · t₂))
else (node (toTree · i₂ · t₁) j t₂)) ≡
le-ItemTree i₁ (if t
then (node t₁ j (toTree · i₂ · t₂))
else (node (toTree · i₂ · t₁) j t₂)))
(x>y→x≰y Nj Ni₂ j>i₂)
refl
⟩
le-ItemTree i₁ (if false
then (node t₁ j (toTree · i₂ · t₂))
else (node (toTree · i₂ · t₁) j t₂))
≡⟨ subst (λ t → le-ItemTree i₁ (if false
then (node t₁ j (toTree · i₂ · t₂))
else (node (toTree · i₂ · t₁) j t₂)) ≡
le-ItemTree i₁ t)
(if-false (node (toTree · i₂ · t₁) j t₂))
refl
⟩
le-ItemTree i₁ (node (toTree · i₂ · t₁) j t₂)
≡⟨ le-ItemTree-node i₁ (toTree · i₂ · t₁) j t₂ ⟩
le-ItemTree i₁ (toTree · i₂ · t₁) && le-ItemTree i₁ t₂
≡⟨ subst (λ t → le-ItemTree i₁ (toTree · i₂ · t₁) && le-ItemTree i₁ t₂ ≡
t && le-ItemTree i₁ t₂)
-- Inductive hypothesis.
(toTree-OrdTree-helper₂ Ni₁ Ni₂ i₁≤i₂ Tt₁
(&&-list₂-t₁ (le-ItemTree-Bool Ni₁ Tt₁)
(le-ItemTree-Bool Ni₁ Tt₂)
(trans (sym (le-ItemTree-node i₁ t₁ j t₂)) i₁≤t)))
refl
⟩
true && le-ItemTree i₁ t₂
≡⟨ subst (λ t → true && le-ItemTree i₁ t₂ ≡ true && t)
-- i₁ ≤ t₂ because by hypothesis we have i₁ ≤ (node t₁ j t₂).
(&&-list₂-t₂ (le-ItemTree-Bool Ni₁ Tt₁)
(le-ItemTree-Bool Ni₁ Tt₂)
(trans (sym (le-ItemTree-node i₁ t₁ j t₂)) i₁≤t))
refl
⟩
true && true
≡⟨ t&&x≡x true ⟩
true ∎
prf₂ : j ≤ i₂ → ≤-ItemTree i₁ (toTree · i₂ · node t₁ j t₂)
prf₂ j≤i₂ =
le-ItemTree i₁ (toTree · i₂ · node t₁ j t₂)
≡⟨ subst (λ t → le-ItemTree i₁ (toTree · i₂ · node t₁ j t₂) ≡
le-ItemTree i₁ t)
(toTree-node i₂ t₁ j t₂)
refl
⟩
le-ItemTree i₁ (if (le j i₂)
then (node t₁ j (toTree · i₂ · t₂))
else (node (toTree · i₂ · t₁) j t₂))
≡⟨ subst (λ t → le-ItemTree i₁ (if (le j i₂)
then (node t₁ j (toTree · i₂ · t₂))
else (node (toTree · i₂ · t₁) j t₂)) ≡
le-ItemTree i₁ (if t
then (node t₁ j (toTree · i₂ · t₂))
else (node (toTree · i₂ · t₁) j t₂)))
j≤i₂
refl
⟩
le-ItemTree i₁ (if true
then (node t₁ j (toTree · i₂ · t₂))
else (node (toTree · i₂ · t₁) j t₂))
≡⟨ subst (λ t → le-ItemTree i₁ (if true
then (node t₁ j (toTree · i₂ · t₂))
else (node (toTree · i₂ · t₁) j t₂)) ≡
le-ItemTree i₁ t)
(if-true (node t₁ j (toTree · i₂ · t₂)))
refl
⟩
le-ItemTree i₁ (node t₁ j (toTree · i₂ · t₂))
≡⟨ le-ItemTree-node i₁ t₁ j (toTree · i₂ · t₂) ⟩
le-ItemTree i₁ t₁ && le-ItemTree i₁ (toTree · i₂ · t₂)
≡⟨ subst (λ t → le-ItemTree i₁ t₁ && le-ItemTree i₁ (toTree · i₂ · t₂) ≡
t && le-ItemTree i₁ (toTree · i₂ · t₂))
-- i₁ ≤ t₁ because by hypothesis we have i₁ ≤ (node t₁ j t₂).
(&&-list₂-t₁ (le-ItemTree-Bool Ni₁ Tt₁)
(le-ItemTree-Bool Ni₁ Tt₂)
(trans (sym (le-ItemTree-node i₁ t₁ j t₂)) i₁≤t))
refl
⟩
true && le-ItemTree i₁ (toTree · i₂ · t₂)
≡⟨ subst (λ t → true && le-ItemTree i₁ (toTree · i₂ · t₂) ≡ true && t)
-- Inductive hypothesis.
(toTree-OrdTree-helper₂ Ni₁ Ni₂ i₁≤i₂ Tt₂
(&&-list₂-t₂ (le-ItemTree-Bool Ni₁ Tt₁)
(le-ItemTree-Bool Ni₁ Tt₂)
(trans (sym (le-ItemTree-node i₁ t₁ j t₂)) i₁≤t)))
refl
⟩
true && true
≡⟨ t&&x≡x true ⟩
true ∎
|
{
"alphanum_fraction": 0.4140740741,
"avg_line_length": 40.3339191564,
"ext": "agda",
"hexsha": "1363685b97bfa7ead3003e729980e3dbd8c38919",
"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/SortList/Properties/Totality/OrdTreeI.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/SortList/Properties/Totality/OrdTreeI.agda",
"max_line_length": 80,
"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/SortList/Properties/Totality/OrdTreeI.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": 7789,
"size": 22950
}
|
module UniverseCollapse
(down : Set₁ -> Set)
(up : Set → Set₁)
(iso : ∀ {A} → down (up A) → A)
(osi : ∀ {A} → up (down A) → A) where
anything : (A : Set) → A
anything = {!!}
|
{
"alphanum_fraction": 0.4816753927,
"avg_line_length": 21.2222222222,
"ext": "agda",
"hexsha": "0b6e1d84d9f6757298f1259195d3b4cc9b2884ee",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "ece25bed081a24f02e9f85056d05933eae2afabf",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "danr/agder",
"max_forks_repo_path": "problems/UniverseCollapse/UniverseCollapse.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ece25bed081a24f02e9f85056d05933eae2afabf",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "danr/agder",
"max_issues_repo_path": "problems/UniverseCollapse/UniverseCollapse.agda",
"max_line_length": 41,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "ece25bed081a24f02e9f85056d05933eae2afabf",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "danr/agder",
"max_stars_repo_path": "problems/UniverseCollapse/UniverseCollapse.agda",
"max_stars_repo_stars_event_max_datetime": "2021-05-17T12:07:03.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-05-17T12:07:03.000Z",
"num_tokens": 72,
"size": 191
}
|
module ctxt where
open import lib
open import cedille-types
open import ctxt-types public
open import subst
open import general-util
open import syntax-util
new-sym-info-trie : trie sym-info
new-sym-info-trie = trie-insert empty-trie compileFail-qual ((term-decl compileFailType) , "missing" , "missing")
new-qualif : qualif
new-qualif = trie-insert empty-trie compileFail (compileFail-qual , ArgsNil)
qualif-nonempty : qualif → 𝔹
qualif-nonempty q = trie-nonempty (trie-remove q compileFail)
new-ctxt : (filename modname : string) → ctxt
new-ctxt fn mn = mk-ctxt (fn , mn , ParamsNil , new-qualif) (empty-trie , empty-trie , empty-trie , empty-trie , 0 , []) new-sym-info-trie empty-trie empty-trie
empty-ctxt : ctxt
empty-ctxt = new-ctxt "" ""
ctxt-get-info : var → ctxt → maybe sym-info
ctxt-get-info v (mk-ctxt _ _ i _ _) = trie-lookup i v
ctxt-set-qualif : ctxt → qualif → ctxt
ctxt-set-qualif (mk-ctxt (f , m , p , q') syms i sym-occurrences d) q
= mk-ctxt (f , m , p , q) syms i sym-occurrences d
ctxt-get-qualif : ctxt → qualif
ctxt-get-qualif (mk-ctxt (_ , _ , _ , q) _ _ _ _) = q
ctxt-get-qi : ctxt → var → maybe qualif-info
ctxt-get-qi Γ = trie-lookup (ctxt-get-qualif Γ)
ctxt-qualif-args-length : ctxt → maybeErased → var → maybe ℕ
ctxt-qualif-args-length Γ me v =
ctxt-get-qi Γ v ≫=maybe λ qv →
just (me-args-length me (snd qv))
qi-var-if : maybe qualif-info → var → var
qi-var-if (just (v , _)) _ = v
qi-var-if nothing v = v
ctxt-restore-info : ctxt → var → maybe qualif-info → maybe sym-info → ctxt
ctxt-restore-info (mk-ctxt (fn , mn , ps , q) syms i symb-occs d) v qi si =
mk-ctxt (fn , mn , ps , f qi v q) syms (f si (qi-var-if qi v) (trie-remove i (qi-var-if (trie-lookup q v) v))) symb-occs d
where
f : ∀{A : Set} → maybe A → string → trie A → trie A
f (just a) s t = trie-insert t s a
f nothing s t = trie-remove t s
ctxt-restore-info* : ctxt → 𝕃 (string × maybe qualif-info × maybe sym-info) → ctxt
ctxt-restore-info* Γ [] = Γ
ctxt-restore-info* Γ ((v , qi , m) :: ms) = ctxt-restore-info* (ctxt-restore-info Γ v qi m) ms
def-params : defScope → params → defParams
def-params tt ps = nothing
def-params ff ps = just ps
-- TODO add renamectxt to avoid capture bugs?
inst-type : ctxt → params → args → type → type
inst-type Γ ps as T with mk-inst ps as
...| σ , ps' = abs-expand-type (substs-params Γ σ ps') (substs Γ σ T)
inst-kind : ctxt → params → args → kind → kind
inst-kind Γ ps as k with mk-inst ps as
...| σ , ps' = abs-expand-kind (substs-params Γ σ ps') (substs Γ σ k)
qualif-x : ∀ {ℓ} {X : Set ℓ} → (ctxt → qualif → X) → ctxt → X
qualif-x f Γ = f Γ (ctxt-get-qualif Γ)
qualif-term = qualif-x $ substs {TERM}
qualif-type = qualif-x $ substs {TYPE}
qualif-kind = qualif-x $ substs {KIND}
qualif-liftingType = qualif-x $ substs {LIFTINGTYPE}
qualif-tk = qualif-x $ substs {TK}
qualif-params = qualif-x substs-params
qualif-args = qualif-x substs-args
erased-margs : ctxt → stringset
erased-margs = stringset-insert* empty-stringset ∘ (erased-params ∘ ctxt-get-current-params)
ctxt-term-decl : posinfo → var → type → ctxt → ctxt
ctxt-term-decl p v t Γ@(mk-ctxt (fn , mn , ps , q) syms i symb-occs d) =
mk-ctxt (fn , mn , ps , (qualif-insert-params q v' v ParamsNil))
syms
(trie-insert i v' ((term-decl (qualif-type Γ t)) , fn , p))
symb-occs
d
where v' = p % v
ctxt-type-decl : posinfo → var → kind → ctxt → ctxt
ctxt-type-decl p v k Γ@(mk-ctxt (fn , mn , ps , q) syms i symb-occs d) =
mk-ctxt (fn , mn , ps , (qualif-insert-params q v' v ParamsNil))
syms
(trie-insert i v' (type-decl (qualif-kind Γ k) , fn , p))
symb-occs
d
where v' = p % v
ctxt-tk-decl : posinfo → var → tk → ctxt → ctxt
ctxt-tk-decl p x (Tkt t) Γ = ctxt-term-decl p x t Γ
ctxt-tk-decl p x (Tkk k) Γ = ctxt-type-decl p x k Γ
-- TODO not sure how this and renaming interacts with module scope
ctxt-var-decl-if : var → ctxt → ctxt
ctxt-var-decl-if v Γ with Γ
... | mk-ctxt (fn , mn , ps , q) syms i symb-occs d with trie-lookup i v
... | just (rename-def _ , _) = Γ
... | just (var-decl , _) = Γ
... | _ = mk-ctxt (fn , mn , ps , (trie-insert q v (v , ArgsNil))) syms
(trie-insert i v (var-decl , "missing" , "missing"))
symb-occs
d
ctxt-rename-rep : ctxt → var → var
ctxt-rename-rep (mk-ctxt m syms i _ _) v with trie-lookup i v
... | just (rename-def v' , _) = v'
... | _ = v
-- we assume that only the left variable might have been renamed
ctxt-eq-rep : ctxt → var → var → 𝔹
ctxt-eq-rep Γ x y = (ctxt-rename-rep Γ x) =string y
{- add a renaming mapping the first variable to the second, unless they are equal.
Notice that adding a renaming for v will overwrite any other declarations for v. -}
ctxt-rename : var → var → ctxt → ctxt
ctxt-rename v v' Γ @ (mk-ctxt (fn , mn , ps , q) syms i symb-occs d) =
(mk-ctxt (fn , mn , ps , qualif-insert-params q v' v ps) syms
(trie-insert i v (rename-def v' , "missing" , "missing"))
symb-occs
d)
----------------------------------------------------------------------
-- lookup functions
----------------------------------------------------------------------
-- lookup mod params from filename
lookup-mod-params : ctxt → var → maybe params
lookup-mod-params (mk-ctxt _ (syms , _ , mn-ps , id) _ _ _) fn =
trie-lookup syms fn ≫=maybe λ { (mn , _) →
trie-lookup mn-ps mn }
-- look for a defined kind for the given var, which is assumed to be a type,
-- then instantiate its parameters
qual-lookup : ctxt → var → maybe (args × sym-info)
qual-lookup Γ@(mk-ctxt (_ , _ , _ , q) _ i _ _) v =
trie-lookup q v ≫=maybe λ qv →
trie-lookup i (fst qv) ≫=maybe λ si →
just (snd qv , si)
env-lookup : ctxt → var → maybe sym-info
env-lookup Γ@(mk-ctxt (_ , _ , _ , _) _ i _ _) v =
trie-lookup i v
-- look for a declared kind for the given var, which is assumed to be a type,
-- otherwise look for a qualified defined kind
ctxt-lookup-type-var : ctxt → var → maybe kind
ctxt-lookup-type-var Γ v with qual-lookup Γ v
... | just (as , type-decl k , _) = just k
... | just (as , type-def (just ps) _ T k , _) = just (inst-kind Γ ps as k)
... | just (as , type-def nothing _ T k , _) = just k
... | just (as , datatype-def _ k , _) = just k
... | _ = nothing
-- remove ?
-- add-param-type : params → type → type
-- add-param-type (ParamsCons (Decl pi pix e x tk _) ps) ty = Abs pi e pix x tk (add-param-type ps ty)
-- add-param-type ParamsNil ty = ty
ctxt-lookup-term-var : ctxt → var → maybe type
ctxt-lookup-term-var Γ v with qual-lookup Γ v
... | just (as , term-decl T , _) = just T
... | just (as , term-def (just ps) _ t T , _) = just $ inst-type Γ ps as T
... | just (as , term-def nothing _ t T , _) = just T
... | just (as , const-def T , _) = just T
... | _ = nothing
ctxt-lookup-tk-var : ctxt → var → maybe tk
ctxt-lookup-tk-var Γ v with qual-lookup Γ v
... | just (as , term-decl T , _) = just $ Tkt T
... | just (as , type-decl k , _) = just $ Tkk k
... | just (as , term-def (just ps) _ t T , _) = just $ Tkt $ inst-type Γ ps as T
... | just (as , type-def (just ps) _ T k , _) = just $ Tkk $ inst-kind Γ ps as k
... | just (as , term-def nothing _ t T , _) = just $ Tkt T
... | just (as , type-def nothing _ T k , _) = just $ Tkk k
... | just (as , datatype-def _ k , _) = just $ Tkk k
... | _ = nothing
ctxt-lookup-term-var-def : ctxt → var → maybe term
ctxt-lookup-term-var-def Γ v with env-lookup Γ v
... | just (term-def nothing OpacTrans t _ , _) = just t
... | just (term-udef nothing OpacTrans t , _) = just t
... | just (term-def (just ps) OpacTrans t _ , _) = just $ lam-expand-term ps t
... | just (term-udef (just ps) OpacTrans t , _) = just $ lam-expand-term ps t
... | _ = nothing
ctxt-lookup-type-var-def : ctxt → var → maybe type
ctxt-lookup-type-var-def Γ v with env-lookup Γ v
... | just (type-def nothing OpacTrans T _ , _) = just T
... | just (type-def (just ps) OpacTrans T _ , _) = just $ lam-expand-type ps T
... | _ = nothing
ctxt-lookup-kind-var-def : ctxt → var → maybe (params × kind)
ctxt-lookup-kind-var-def Γ x with env-lookup Γ x
... | just (kind-def ps k , _) = just (ps , k)
... | _ = nothing
ctxt-lookup-kind-var-def-args : ctxt → var → maybe (params × args)
ctxt-lookup-kind-var-def-args Γ@(mk-ctxt (_ , _ , _ , q) _ i _ _) v with trie-lookup q v
... | just (v' , as) = ctxt-lookup-kind-var-def Γ v' ≫=maybe λ { (ps , k) → just (ps , as) }
... | _ = nothing
ctxt-lookup-occurrences : ctxt → var → 𝕃 (var × posinfo × string)
ctxt-lookup-occurrences (mk-ctxt _ _ _ symb-occs _) symbol with trie-lookup symb-occs symbol
... | just l = l
... | nothing = []
----------------------------------------------------------------------
ctxt-var-location : ctxt → var → location
ctxt-var-location (mk-ctxt _ _ i _ _) x with trie-lookup i x
... | just (_ , l) = l
... | nothing = "missing" , "missing"
ctxt-clarify-def : ctxt → var → maybe (sym-info × ctxt)
ctxt-clarify-def Γ@(mk-ctxt mod@(_ , _ , _ , q) syms i sym-occurrences d) x
= trie-lookup i x ≫=maybe λ { (ci , l) →
clarified x ci l }
where
ctxt' : var → ctxt-info → location → ctxt
ctxt' v ci l = mk-ctxt mod syms (trie-insert i v (ci , l)) sym-occurrences d
clarified : var → ctxt-info → location → maybe (sym-info × ctxt)
clarified v ci@(term-def ps _ t T) l = just ((ci , l) , (ctxt' v (term-def ps OpacTrans t T) l))
clarified v ci@(term-udef ps _ t) l = just ((ci , l) , (ctxt' v (term-udef ps OpacTrans t) l))
clarified v ci@(type-def ps _ T k) l = just ((ci , l) , (ctxt' v (type-def ps OpacTrans T k) l))
clarified _ _ _ = nothing
ctxt-set-sym-info : ctxt → var → sym-info → ctxt
ctxt-set-sym-info (mk-ctxt mod syms i sym-occurrences d) x si =
mk-ctxt mod syms (trie-insert i x si) sym-occurrences d
ctxt-restore-clarified-def : ctxt → var → sym-info → ctxt
ctxt-restore-clarified-def = ctxt-set-sym-info
ctxt-set-current-file : ctxt → string → string → ctxt
ctxt-set-current-file (mk-ctxt _ syms i symb-occs d) fn mn = mk-ctxt (fn , mn , ParamsNil , new-qualif) syms i symb-occs d
ctxt-set-current-mod : ctxt → mod-info → ctxt
ctxt-set-current-mod (mk-ctxt _ syms i symb-occs d) m = mk-ctxt m syms i symb-occs d
ctxt-add-current-params : ctxt → ctxt
ctxt-add-current-params Γ@(mk-ctxt m@(fn , mn , ps , _) (syms , mn-fn , mn-ps , ids) i symb-occs d) =
mk-ctxt m (trie-insert syms fn (mn , []) , mn-fn , trie-insert mn-ps mn ps , ids) i symb-occs d
ctxt-clear-symbol : ctxt → string → ctxt
ctxt-clear-symbol Γ @ (mk-ctxt (fn , mn , pms , q) (syms , mn-fn) i symb-occs d) x =
mk-ctxt (fn , mn , pms , (trie-remove q x)) (trie-map (λ ss → fst ss , remove _=string_ x (snd ss)) syms , mn-fn) (trie-remove i (qualif-var Γ x)) symb-occs d
ctxt-clear-symbols : ctxt → 𝕃 string → ctxt
ctxt-clear-symbols Γ [] = Γ
ctxt-clear-symbols Γ (v :: vs) = ctxt-clear-symbols (ctxt-clear-symbol Γ v) vs
ctxt-clear-symbols-of-file : ctxt → (filename : string) → ctxt
ctxt-clear-symbols-of-file (mk-ctxt f (syms , mn-fn , mn-ps) i symb-occs d) fn =
mk-ctxt f (trie-insert syms fn (fst p , []) , trie-insert mn-fn (fst p) fn , mn-ps)
(hremove i (fst p) (snd p))
symb-occs
d
where
p = trie-lookup𝕃2 syms fn
hremove : ∀ {A : Set} → trie A → var → 𝕃 string → trie A
hremove i mn [] = i
hremove i mn (x :: xs) = hremove (trie-remove i (mn # x)) mn xs
ctxt-add-current-id : ctxt → ctxt
ctxt-add-current-id (mk-ctxt mod (syms , mn-fn , mn-ps , fn-ids , id , id-fns) is os d) =
mk-ctxt mod (syms , mn-fn , mn-ps , trie-insert fn-ids (fst mod) (suc id) , suc id , (fst mod) :: id-fns) is os d
ctxt-initiate-file : ctxt → (filename modname : string) → ctxt
ctxt-initiate-file Γ fn mn = ctxt-add-current-id (ctxt-set-current-file (ctxt-clear-symbols-of-file Γ fn) fn mn)
unqual : ctxt → var → string
unqual (mk-ctxt (_ , _ , _ , q) _ _ _ _) v =
if qualif-nonempty q
then unqual-local (unqual-all q v)
else v
|
{
"alphanum_fraction": 0.6158934852,
"avg_line_length": 40.3445945946,
"ext": "agda",
"hexsha": "edbfdef78b2f249e4638c747f8a2a2890d825877",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "acf691e37210607d028f4b19f98ec26c4353bfb5",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "xoltar/cedille",
"max_forks_repo_path": "src/ctxt.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "acf691e37210607d028f4b19f98ec26c4353bfb5",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "xoltar/cedille",
"max_issues_repo_path": "src/ctxt.agda",
"max_line_length": 160,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "acf691e37210607d028f4b19f98ec26c4353bfb5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "xoltar/cedille",
"max_stars_repo_path": "src/ctxt.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3947,
"size": 11942
}
|
{-# OPTIONS --copatterns #-}
-- Andreas, 2013-11-05 Coverage checker needs clauses to reduce type!
-- {-# OPTIONS -v tc.cover:20 #-}
module Issue937a where
open import Common.Prelude
open import Common.Equality
open import Common.Product
T : (b : Bool) → Set
T true = Nat
T false = Bool → Nat
test : Σ Bool T
proj₁ test = false
proj₂ test true = zero
proj₂ test false = suc zero -- Error: unreachable clause
module _ {_ : Set} where
bla : Σ Bool T
proj₁ bla = false
proj₂ bla true = zero
proj₂ bla false = suc zero -- Error: unreachable clause
-- should coverage check
|
{
"alphanum_fraction": 0.6933560477,
"avg_line_length": 20.9642857143,
"ext": "agda",
"hexsha": "ecaff836625bcc9ef8da44ddbe0cbd8a69f4ccfd",
"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/Issue937a.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/Issue937a.agda",
"max_line_length": 70,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/Issue937a.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": 167,
"size": 587
}
|
module Sized.StatefulCell where
open import Data.Product
open import Data.String.Base
open import SizedIO.Object
open import SizedIO.IOObject
open import SizedIO.ConsoleObject
open import SizedIO.Console hiding (main)
open import NativeIO
open import Size
--open import StateSizedIO.Base
data CellState# : Set where
empty full : CellState#
data CellMethodEmpty A : Set where
put : A → CellMethodEmpty A
data CellMethodFull A : Set where
get : CellMethodFull A
put : A → CellMethodFull A
CellMethod# : ∀{A} → CellState# → Set
CellMethod#{A} empty = CellMethodEmpty A
CellMethod#{A} full = CellMethodFull A
CellResultFull : ∀{A} → CellMethodFull A → Set
CellResultFull {A} get = A
CellResultFull (put _) = Unit
CellResultEmpty : ∀{A} → CellMethodEmpty A → Set
CellResultEmpty (put _) = Unit
CellResult# : ∀{A} → (s : CellState#) → CellMethod#{A} s → Set
CellResult#{A} empty = CellResultEmpty{A}
CellResult#{A} full = CellResultFull{A}
n# : ∀{A} → (s : CellState#) → (c : CellMethod#{A} s) → (CellResult# s c) → CellState#
n# empty (put x) unit = full
n# full get z = full
n# full (put x) unit = full
|
{
"alphanum_fraction": 0.7093639576,
"avg_line_length": 22.64,
"ext": "agda",
"hexsha": "fe0baf42cf87224828647311bc2c1996b6223fb6",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z",
"max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "agda/ooAgda",
"max_forks_repo_path": "examples/Sized/StatefulCell.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "agda/ooAgda",
"max_issues_repo_path": "examples/Sized/StatefulCell.agda",
"max_line_length": 86,
"max_stars_count": 23,
"max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "agda/ooAgda",
"max_stars_repo_path": "examples/Sized/StatefulCell.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z",
"num_tokens": 347,
"size": 1132
}
|
{-# OPTIONS --safe #-}
module Cubical.Data.SumFin.Properties where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv renaming (_∙ₑ_ to _⋆_)
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Function
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.Data.Empty as ⊥
open import Cubical.Data.Unit
open import Cubical.Data.Bool
open import Cubical.Data.Nat
open import Cubical.Data.Nat.Order
import Cubical.Data.Fin as Fin
import Cubical.Data.Fin.LehmerCode as LehmerCode
open import Cubical.Data.SumFin.Base as SumFin
open import Cubical.Data.Sum
open import Cubical.Data.Sigma
open import Cubical.HITs.PropositionalTruncation as Prop
open import Cubical.Relation.Nullary
private
variable
ℓ : Level
k : ℕ
SumFin→Fin : Fin k → Fin.Fin k
SumFin→Fin = SumFin.elim (λ {k} _ → Fin.Fin k) Fin.fzero Fin.fsuc
Fin→SumFin : Fin.Fin k → Fin k
Fin→SumFin = Fin.elim (λ {k} _ → Fin k) fzero fsuc
Fin→SumFin-fsuc : (fk : Fin.Fin k) → Fin→SumFin (Fin.fsuc fk) ≡ fsuc (Fin→SumFin fk)
Fin→SumFin-fsuc = Fin.elim-fsuc (λ {k} _ → Fin k) fzero fsuc
SumFin→Fin→SumFin : (fk : Fin k) → Fin→SumFin (SumFin→Fin fk) ≡ fk
SumFin→Fin→SumFin = SumFin.elim (λ fk → Fin→SumFin (SumFin→Fin fk) ≡ fk)
refl λ {k} {fk} eq →
Fin→SumFin (Fin.fsuc (SumFin→Fin fk)) ≡⟨ Fin→SumFin-fsuc (SumFin→Fin fk) ⟩
fsuc (Fin→SumFin (SumFin→Fin fk)) ≡⟨ cong fsuc eq ⟩
fsuc fk ∎
Fin→SumFin→Fin : (fk : Fin.Fin k) → SumFin→Fin (Fin→SumFin fk) ≡ fk
Fin→SumFin→Fin = Fin.elim (λ fk → SumFin→Fin (Fin→SumFin fk) ≡ fk)
refl λ {k} {fk} eq →
SumFin→Fin (Fin→SumFin (Fin.fsuc fk)) ≡⟨ cong SumFin→Fin (Fin→SumFin-fsuc fk) ⟩
Fin.fsuc (SumFin→Fin (Fin→SumFin fk)) ≡⟨ cong Fin.fsuc eq ⟩
Fin.fsuc fk ∎
SumFin≃Fin : ∀ k → Fin k ≃ Fin.Fin k
SumFin≃Fin _ =
isoToEquiv (iso SumFin→Fin Fin→SumFin Fin→SumFin→Fin SumFin→Fin→SumFin)
SumFin≡Fin : ∀ k → Fin k ≡ Fin.Fin k
SumFin≡Fin k = ua (SumFin≃Fin k)
enum : (n : ℕ)(p : n < k) → Fin k
enum n p = Fin→SumFin (n , p)
enumElim : (P : Fin k → Type ℓ) → ((n : ℕ)(p : n < k) → P (enum _ p)) → (i : Fin k) → P i
enumElim P f i = subst P (SumFin→Fin→SumFin i) (f (SumFin→Fin i .fst) (SumFin→Fin i .snd))
-- Closure properties of SumFin under type constructors
SumFin⊎≃ : (m n : ℕ) → (Fin m ⊎ Fin n) ≃ (Fin (m + n))
SumFin⊎≃ 0 n = ⊎-swap-≃ ⋆ ⊎-⊥-≃
SumFin⊎≃ (suc m) n = ⊎-assoc-≃ ⋆ ⊎-equiv (idEquiv ⊤) (SumFin⊎≃ m n)
SumFinΣ≃ : (n : ℕ)(f : Fin n → ℕ) → (Σ (Fin n) (λ x → Fin (f x))) ≃ (Fin (totalSum f))
SumFinΣ≃ 0 f = ΣEmpty _
SumFinΣ≃ (suc n) f =
Σ⊎≃
⋆ ⊎-equiv (ΣUnit (λ tt → Fin (f (inl tt)))) (SumFinΣ≃ n (λ x → f (inr x)))
⋆ SumFin⊎≃ (f (inl tt)) (totalSum (λ x → f (inr x)))
SumFin×≃ : (m n : ℕ) → (Fin m × Fin n) ≃ (Fin (m · n))
SumFin×≃ m n = SumFinΣ≃ m (λ _ → n) ⋆ pathToEquiv (λ i → Fin (totalSumConst {m = m} n i))
SumFinΠ≃ : (n : ℕ)(f : Fin n → ℕ) → ((x : Fin n) → Fin (f x)) ≃ (Fin (totalProd f))
SumFinΠ≃ 0 _ = isContr→≃Unit (isContrΠ⊥) ⋆ invEquiv (⊎-⊥-≃)
SumFinΠ≃ (suc n) f =
Π⊎≃
⋆ Σ-cong-equiv (ΠUnit (λ tt → Fin (f (inl tt)))) (λ _ → SumFinΠ≃ n (λ x → f (inr x)))
⋆ SumFin×≃ (f (inl tt)) (totalProd (λ x → f (inr x)))
isNotZero : ℕ → ℕ
isNotZero 0 = 0
isNotZero (suc n) = 1
SumFin∥∥≃ : (n : ℕ) → ∥ Fin n ∥ ≃ Fin (isNotZero n)
SumFin∥∥≃ 0 = propTruncIdempotent≃ (isProp⊥)
SumFin∥∥≃ (suc n) =
isContr→≃Unit (inhProp→isContr ∣ inl tt ∣ isPropPropTrunc)
⋆ isContr→≃Unit (isContrUnit) ⋆ invEquiv (⊎-⊥-≃)
ℕ→Bool : ℕ → Bool
ℕ→Bool 0 = false
ℕ→Bool (suc n) = true
SumFin∥∥DecProp : (n : ℕ) → ∥ Fin n ∥ ≃ Bool→Type (ℕ→Bool n)
SumFin∥∥DecProp 0 = uninhabEquiv (Prop.rec isProp⊥ ⊥.rec) ⊥.rec
SumFin∥∥DecProp (suc n) = isContr→≃Unit (inhProp→isContr ∣ inl tt ∣ isPropPropTrunc)
-- negation of SumFin
SumFin¬ : (n : ℕ) → (¬ Fin n) ≃ Bool→Type (isZero n)
SumFin¬ 0 = isContr→≃Unit isContr⊥→A
SumFin¬ (suc n) = uninhabEquiv (λ f → f fzero) ⊥.rec
-- SumFin 1 is equivalent to unit
Fin1≃Unit : Fin 1 ≃ Unit
Fin1≃Unit = ⊎-⊥-≃
isContrSumFin1 : isContr (Fin 1)
isContrSumFin1 = isOfHLevelRespectEquiv 0 (invEquiv Fin1≃Unit) isContrUnit
-- SumFin 2 is equivalent to Bool
SumFin2≃Bool : Fin 2 ≃ Bool
SumFin2≃Bool = ⊎-equiv (idEquiv _) ⊎-⊥-≃ ⋆ isoToEquiv Iso-⊤⊎⊤-Bool
-- decidable predicate over SumFin
SumFinℙ≃ : (n : ℕ) → (Fin n → Bool) ≃ Fin (2 ^ n)
SumFinℙ≃ 0 = isContr→≃Unit (isContrΠ⊥) ⋆ invEquiv (⊎-⊥-≃)
SumFinℙ≃ (suc n) =
Π⊎≃
⋆ Σ-cong-equiv (UnitToType≃ Bool ⋆ invEquiv SumFin2≃Bool) (λ _ → SumFinℙ≃ n)
⋆ SumFin×≃ 2 (2 ^ n)
-- decidable subsets of SumFin
Bool→ℕ : Bool → ℕ
Bool→ℕ true = 1
Bool→ℕ false = 0
trueCount : {n : ℕ}(f : Fin n → Bool) → ℕ
trueCount {n = 0} _ = 0
trueCount {n = suc n} f = Bool→ℕ (f (inl tt)) + (trueCount (f ∘ inr))
SumFinDec⊎≃ : (n : ℕ)(t : Bool) → (Bool→Type t ⊎ Fin n) ≃ (Fin (Bool→ℕ t + n))
SumFinDec⊎≃ _ true = idEquiv _
SumFinDec⊎≃ _ false = ⊎-swap-≃ ⋆ ⊎-⊥-≃
SumFinSub≃ : (n : ℕ)(f : Fin n → Bool) → Σ _ (Bool→Type ∘ f) ≃ Fin (trueCount f)
SumFinSub≃ 0 _ = ΣEmpty _
SumFinSub≃ (suc n) f =
Σ⊎≃
⋆ ⊎-equiv (ΣUnit (Bool→Type ∘ f ∘ inl)) (SumFinSub≃ n (f ∘ inr))
⋆ SumFinDec⊎≃ _ (f (inl tt))
-- decidable quantifier
trueForSome : (n : ℕ)(f : Fin n → Bool) → Bool
trueForSome 0 _ = false
trueForSome (suc n) f = f (inl tt) or trueForSome n (f ∘ inr)
trueForAll : (n : ℕ)(f : Fin n → Bool) → Bool
trueForAll 0 _ = true
trueForAll (suc n) f = f (inl tt) and trueForAll n (f ∘ inr)
SumFin∃→ : (n : ℕ)(f : Fin n → Bool) → Σ _ (Bool→Type ∘ f) → Bool→Type (trueForSome n f)
SumFin∃→ 0 _ = ΣEmpty _ .fst
SumFin∃→ (suc n) f =
Bool→Type⊎' _ _
∘ map-⊎ (ΣUnit (Bool→Type ∘ f ∘ inl) .fst) (SumFin∃→ n (f ∘ inr))
∘ Σ⊎≃ .fst
SumFin∃← : (n : ℕ)(f : Fin n → Bool) → Bool→Type (trueForSome n f) → Σ _ (Bool→Type ∘ f)
SumFin∃← 0 _ = ⊥.rec
SumFin∃← (suc n) f =
invEq Σ⊎≃
∘ map-⊎ (invEq (ΣUnit (Bool→Type ∘ f ∘ inl))) (SumFin∃← n (f ∘ inr))
∘ Bool→Type⊎ _ _
SumFin∃≃ : (n : ℕ)(f : Fin n → Bool) → ∥ Σ (Fin n) (Bool→Type ∘ f) ∥ ≃ Bool→Type (trueForSome n f)
SumFin∃≃ n f =
propBiimpl→Equiv isPropPropTrunc isPropBool→Type
(Prop.rec isPropBool→Type (SumFin∃→ n f))
(∣_∣ ∘ SumFin∃← n f)
SumFin∀≃ : (n : ℕ)(f : Fin n → Bool) → ((x : Fin n) → Bool→Type (f x)) ≃ Bool→Type (trueForAll n f)
SumFin∀≃ 0 _ = isContr→≃Unit (isContrΠ⊥)
SumFin∀≃ (suc n) f =
Π⊎≃
⋆ Σ-cong-equiv (ΠUnit (Bool→Type ∘ f ∘ inl)) (λ _ → SumFin∀≃ n (f ∘ inr))
⋆ Bool→Type×≃ _ _
-- internal equality
SumFin≡ : (n : ℕ) → (a b : Fin n) → Bool
SumFin≡ 0 _ _ = true
SumFin≡ (suc n) (inl tt) (inl tt) = true
SumFin≡ (suc n) (inl tt) (inr y) = false
SumFin≡ (suc n) (inr x) (inl tt) = false
SumFin≡ (suc n) (inr x) (inr y) = SumFin≡ n x y
isSetSumFin : (n : ℕ)→ isSet (Fin n)
isSetSumFin 0 = isProp→isSet isProp⊥
isSetSumFin (suc n) = isSet⊎ (isProp→isSet isPropUnit) (isSetSumFin n)
SumFin≡≃ : (n : ℕ) → (a b : Fin n) → (a ≡ b) ≃ Bool→Type (SumFin≡ n a b)
SumFin≡≃ 0 _ _ = isContr→≃Unit (isProp→isContrPath isProp⊥ _ _)
SumFin≡≃ (suc n) (inl tt) (inl tt) = isContr→≃Unit (inhProp→isContr refl (isSetSumFin _ _ _))
SumFin≡≃ (suc n) (inl tt) (inr y) = invEquiv (⊎Path.Cover≃Path _ _) ⋆ uninhabEquiv ⊥.rec* ⊥.rec
SumFin≡≃ (suc n) (inr x) (inl tt) = invEquiv (⊎Path.Cover≃Path _ _) ⋆ uninhabEquiv ⊥.rec* ⊥.rec
SumFin≡≃ (suc n) (inr x) (inr y) = invEquiv (_ , isEmbedding-inr x y) ⋆ SumFin≡≃ n x y
-- propositional truncation of Fin
-- decidability of Fin
DecFin : (n : ℕ) → Dec (Fin n)
DecFin 0 = no (idfun _)
DecFin (suc n) = yes fzero
-- propositional truncation of Fin
Dec∥Fin∥ : (n : ℕ) → Dec ∥ Fin n ∥
Dec∥Fin∥ n = Dec∥∥ (DecFin n)
-- some properties about cardinality
fzero≠fone : {n : ℕ} → ¬ (fzero ≡ fsuc fzero)
fzero≠fone {n = n} = SumFin≡≃ (suc (suc n)) fzero (fsuc fzero) .fst
Fin>0→isInhab : (n : ℕ) → 0 < n → Fin n
Fin>0→isInhab 0 p = ⊥.rec (¬-<-zero p)
Fin>0→isInhab (suc n) p = fzero
Fin>1→hasNonEqualTerm : (n : ℕ) → 1 < n → Σ[ i ∈ Fin n ] Σ[ j ∈ Fin n ] ¬ i ≡ j
Fin>1→hasNonEqualTerm 0 p = ⊥.rec (snotz (≤0→≡0 p))
Fin>1→hasNonEqualTerm 1 p = ⊥.rec (snotz (≤0→≡0 (pred-≤-pred p)))
Fin>1→hasNonEqualTerm (suc (suc n)) _ = fzero , fsuc fzero , fzero≠fone
isEmpty→Fin≡0 : (n : ℕ) → ¬ Fin n → 0 ≡ n
isEmpty→Fin≡0 0 _ = refl
isEmpty→Fin≡0 (suc n) p = ⊥.rec (p fzero)
isInhab→Fin>0 : (n : ℕ) → Fin n → 0 < n
isInhab→Fin>0 0 i = ⊥.rec i
isInhab→Fin>0 (suc n) _ = suc-≤-suc zero-≤
hasNonEqualTerm→Fin>1 : (n : ℕ) → (i j : Fin n) → ¬ i ≡ j → 1 < n
hasNonEqualTerm→Fin>1 0 i _ _ = ⊥.rec i
hasNonEqualTerm→Fin>1 1 i j p = ⊥.rec (p (isContr→isProp isContrSumFin1 i j))
hasNonEqualTerm→Fin>1 (suc (suc n)) _ _ _ = suc-≤-suc (suc-≤-suc zero-≤)
Fin≤1→isProp : (n : ℕ) → n ≤ 1 → isProp (Fin n)
Fin≤1→isProp 0 _ = isProp⊥
Fin≤1→isProp 1 _ = isContr→isProp isContrSumFin1
Fin≤1→isProp (suc (suc n)) p = ⊥.rec (¬-<-zero (pred-≤-pred p))
isProp→Fin≤1 : (n : ℕ) → isProp (Fin n) → n ≤ 1
isProp→Fin≤1 0 _ = ≤-solver 0 1
isProp→Fin≤1 1 _ = ≤-solver 1 1
isProp→Fin≤1 (suc (suc n)) p = ⊥.rec (fzero≠fone (p fzero (fsuc fzero)))
-- automorphisms of SumFin
SumFin≃≃ : (n : ℕ) → (Fin n ≃ Fin n) ≃ Fin (LehmerCode.factorial n)
SumFin≃≃ _ =
equivComp (SumFin≃Fin _) (SumFin≃Fin _)
⋆ LehmerCode.lehmerEquiv
⋆ LehmerCode.lehmerFinEquiv
⋆ invEquiv (SumFin≃Fin _)
|
{
"alphanum_fraction": 0.6042273266,
"avg_line_length": 33.967032967,
"ext": "agda",
"hexsha": "896a6e3c565f3c81d9f7cd1673cfd01478ae7d34",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "howsiyu/cubical",
"max_forks_repo_path": "Cubical/Data/SumFin/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "howsiyu/cubical",
"max_issues_repo_path": "Cubical/Data/SumFin/Properties.agda",
"max_line_length": 99,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "howsiyu/cubical",
"max_stars_repo_path": "Cubical/Data/SumFin/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 4413,
"size": 9273
}
|
{-# OPTIONS --safe --warning=error --without-K #-}
open import LogicalFormulae
open import Functions.Definition
open import Lists.Definition
open import Lists.Fold.Fold
open import Lists.Length
module Lists.Map.Map where
map : {a b : _} {A : Set a} {B : Set b} (f : A → B) → List A → List B
map f [] = []
map f (x :: list) = (f x) :: (map f list)
map' : {a b : _} {A : Set a} {B : Set b} (f : A → B) → List A → List B
map' f = fold (λ a → (f a) ::_ ) []
map=map' : {a b : _} {A : Set a} {B : Set b} (f : A → B) → (l : List A) → (map f l ≡ map' f l)
map=map' f [] = refl
map=map' f (x :: l) with map=map' f l
... | bl = applyEquality (f x ::_) bl
mapId : {a : _} {A : Set a} (l : List A) → map id l ≡ l
mapId [] = refl
mapId (x :: l) rewrite mapId l = refl
mapMap : {a b c : _} {A : Set a} {B : Set b} {C : Set c} → (l : List A) → {f : A → B} {g : B → C} → map g (map f l) ≡ map (g ∘ f) l
mapMap [] = refl
mapMap (x :: l) {f = f} {g} rewrite mapMap l {f} {g} = refl
mapExtension : {a b : _} {A : Set a} {B : Set b} (l : List A) (f g : A → B) → ({x : A} → (f x ≡ g x)) → map f l ≡ map g l
mapExtension [] f g pr = refl
mapExtension (x :: l) f g pr rewrite mapExtension l f g pr | pr {x} = refl
mapConcat : {a b : _} {A : Set a} {B : Set b} (l1 l2 : List A) (f : A → B) → map f (l1 ++ l2) ≡ (map f l1) ++ (map f l2)
mapConcat [] l2 f = refl
mapConcat (x :: l1) l2 f rewrite mapConcat l1 l2 f = refl
lengthMap : {a b : _} {A : Set a} {B : Set b} → (l : List A) → {f : A → B} → length l ≡ length (map f l)
lengthMap [] {f} = refl
lengthMap (x :: l) {f} rewrite lengthMap l {f} = refl
|
{
"alphanum_fraction": 0.527375708,
"avg_line_length": 37.8333333333,
"ext": "agda",
"hexsha": "faf757235ff89f89955b52b021a174b30d442e5b",
"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": "Lists/Map/Map.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": "Lists/Map/Map.agda",
"max_line_length": 131,
"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": "Lists/Map/Map.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": 661,
"size": 1589
}
|
module Structure.Container.SetLike where
{-
open import Data.Boolean
open import Data.Boolean.Stmt
open import Functional
open import Lang.Instance
import Lvl
open import Logic
open import Logic.Propositional
open import Logic.Predicate
open import Structure.Setoid renaming (_≡_ to _≡ₛ_ ; _≢_ to _≢ₛ_)
open import Structure.Function.Domain
open import Structure.Function
open import Structure.Operator
open import Structure.Relator.Equivalence
open import Structure.Relator.Properties
open import Structure.Relator hiding (module Names)
open import Type.Properties.Inhabited
open import Type
private variable ℓ ℓ₁ ℓ₂ ℓ₃ ℓ₄ ℓ₅ ℓ₆ ℓ₇ ℓ₈ ℓ₉ ℓ₁₀ ℓₗ ℓₗ₁ ℓₗ₂ ℓₗ₃ : Lvl.Level
private variable A B C C₁ C₂ Cₒ Cᵢ E E₁ E₂ : Type{ℓ}
private variable _∈_ _∈ₒ_ _∈ᵢ_ : E → C
module _ {C : Type{ℓ₁}} {E : Type{ℓ₂}} (_∈_ : E → C → Stmt{ℓ₃}) where -- TODO: Maybe generalize C so that it becomes "indexed": `(C : (i : I) → Type{ℓ₁(i)})`? Is it neccessary? Which set-like structures does not fit with the definitions below?
record SetLike {ℓ₄} : Type{ℓ₁ Lvl.⊔ ℓ₂ Lvl.⊔ ℓ₃ Lvl.⊔ Lvl.𝐒(ℓ₄)} where
field
_≡_ : C → C → Stmt{ℓ₄}
field
[≡]-membership : ∀{a b} → (a ≡ b) ↔ (∀{x} → (x ∈ a) ↔ (x ∈ b))
_∋_ : C → E → Stmt
_∋_ = swap(_∈_)
_∉_ : E → C → Stmt
_∉_ = (¬_) ∘₂ (_∈_)
_≢_ : C → C → Stmt
_≢_ = (¬_) ∘₂ (_≡_)
-- A type such that its inhabitants is the elements of the set `S`.
SetElement : C → Stmt
SetElement(S) = ∃(_∈ S)
record SubsetRelation {ℓ₄} : Type{ℓ₁ Lvl.⊔ ℓ₂ Lvl.⊔ ℓ₃ Lvl.⊔ Lvl.𝐒(ℓ₄)} where
field _⊆_ : C → C → Stmt{ℓ₄}
Membership = ∀{a b} → (a ⊆ b) ↔ (∀{x} → (x ∈ a) → (x ∈ b))
field [⊆]-membership : Membership
_⊇_ : C → C → Stmt
_⊇_ = swap(_⊆_)
_⊈_ : C → C → Stmt
_⊈_ = (¬_) ∘₂ (_⊆_)
_⊉_ : C → C → Stmt
_⊉_ = (¬_) ∘₂ (_⊇_)
open SubsetRelation ⦃ ... ⦄ hiding (Membership ; membership) public
module Subset ⦃ inst ⦄ = SubsetRelation(inst)
module FunctionProperties where
module Names where
_closed-under₁_ : C → (E → E) → Stmt -- TODO: Maybe possible to generalize over n
S closed-under₁ f = (∀{x} → (x ∈ S) → (f(x) ∈ S))
_closed-under₂_ : C → (E → E → E) → Stmt
S closed-under₂ (_▫_) = (∀{x y} → (x ∈ S) → (y ∈ S) → ((x ▫ y) ∈ S))
open import Lang.Instance
module _ (S : C) (f : E → E) where
record _closed-under₁_ : Stmt{Lvl.of(S Names.closed-under₁ f)} where
constructor intro
field proof : S Names.closed-under₁ f
_closureUnder₁_ = inst-fn _closed-under₁_.proof
module _ (S : C) (_▫_ : E → E → E) where
record _closed-under₂_ : Stmt{Lvl.of(S Names.closed-under₂ (_▫_))} where
constructor intro
field proof : S Names.closed-under₂ (_▫_)
_closureUnder₂_ = inst-fn _closed-under₂_.proof
module _ (_∈_ : _) ⦃ setLike : SetLike{ℓ₁}{ℓ₂}{ℓ₃}{C}{E} (_∈_) {ℓ₄} ⦄ where
open SetLike(setLike)
module Names where
record EmptySet : Type{ℓ₁ Lvl.⊔ ℓ₂ Lvl.⊔ ℓ₃} where
field ∅ : C
Membership = ∀{x} → (x ∉ ∅)
field membership : Membership
open EmptySet ⦃ ... ⦄ hiding (Membership ; membership) public
module Empty ⦃ inst ⦄ = EmptySet(inst)
{-# DISPLAY EmptySet.∅ = ∅ #-}
record UniversalSet : Type{ℓ₁ Lvl.⊔ ℓ₂ Lvl.⊔ ℓ₃} where
field 𝐔 : C
Membership = ∀{x} → (x ∈ 𝐔)
field membership : Membership
open UniversalSet ⦃ ... ⦄ hiding (Membership ; membership) public
module Universal ⦃ inst ⦄ = UniversalSet(inst)
record UnionOperator : Type{ℓ₁ Lvl.⊔ ℓ₂ Lvl.⊔ ℓ₃} where
field _∪_ : C → C → C
Membership = ∀{a b}{x} → (x ∈ (a ∪ b)) ↔ ((x ∈ a) ∨ (x ∈ b))
field membership : Membership
open UnionOperator ⦃ ... ⦄ hiding (Membership ; membership) public
module Union ⦃ inst ⦄ = UnionOperator(inst)
record IntersectionOperator : Type{ℓ₁ Lvl.⊔ ℓ₂ Lvl.⊔ ℓ₃} where
field _∩_ : C → C → C
Membership = ∀{a b}{x} → (x ∈ (a ∩ b)) ↔ ((x ∈ a) ∧ (x ∈ b))
field membership : Membership
open IntersectionOperator ⦃ ... ⦄ hiding (Membership ; membership) public
module Intersection ⦃ inst ⦄ = IntersectionOperator(inst)
{-# DISPLAY IntersectionOperator._∩_ = _∩_ #-}
record WithoutOperator : Type{ℓ₁ Lvl.⊔ ℓ₂ Lvl.⊔ ℓ₃} where
field _∖_ : C → C → C
Membership = ∀{a b}{x} → (x ∈ (a ∖ b)) ↔ ((x ∈ a) ∧ (x ∉ b))
field membership : Membership
open WithoutOperator ⦃ ... ⦄ hiding (Membership ; membership) public
module Without ⦃ inst ⦄ = WithoutOperator(inst)
record ComplementOperator : Type{ℓ₁ Lvl.⊔ ℓ₂ Lvl.⊔ ℓ₃} where
field ∁ : C → C
Membership = ∀{a}{x} → (x ∈ (∁ a)) ↔ (x ∉ a)
field membership : Membership
open ComplementOperator ⦃ ... ⦄ hiding (Membership ; membership) public
module Complement ⦃ inst ⦄ = ComplementOperator(inst)
module _ {I : Type{ℓ}} ⦃ equiv-I : Equiv{ℓₗ₁}(I) ⦄ ⦃ equiv-E : Equiv{ℓₗ₂}(E) ⦄ where
record ImageOperator : Type{ℓ₁ Lvl.⊔ ℓ₂ Lvl.⊔ ℓ₃ Lvl.⊔ ℓ Lvl.⊔ ℓₗ₁ Lvl.⊔ ℓₗ₂} where
field ⊶ : (f : I → E) → ⦃ func : Function(f) ⦄ → C
Membership = ∀{f} ⦃ func : Function(f) ⦄ → ∀{y} → (y ∈ (⊶ f)) ↔ ∃(x ↦ f(x) ≡ₛ y)
field membership : Membership
open ImageOperator ⦃ ... ⦄ hiding (Membership ; membership) public
module Image ⦃ inst ⦄ = ImageOperator(inst)
module _ ⦃ _ : Equiv{ℓₗ}(E) ⦄ where
record SingletonSet : Type{ℓ₁ Lvl.⊔ ℓ₂ Lvl.⊔ ℓ₃ Lvl.⊔ ℓₗ} where
field singleton : E → C
Membership = ∀{y}{x} → (x ∈ singleton(y)) ↔ (x ≡ₛ y)
field membership : Membership
open SingletonSet ⦃ ... ⦄ hiding (Membership ; membership) public
module Singleton ⦃ inst ⦄ = SingletonSet(inst)
record PairSet : Type{ℓ₁ Lvl.⊔ ℓ₂ Lvl.⊔ ℓ₃ Lvl.⊔ ℓₗ} where
field pair : E → E → C
Membership = ∀{y₁ y₂}{x} → (x ∈ pair y₁ y₂) ↔ (x ≡ₛ y₁)∨(x ≡ₛ y₂)
field membership : Membership
open PairSet ⦃ ... ⦄ hiding (Membership ; membership) public
module Pair ⦃ inst ⦄ = PairSet(inst)
record AddFunction : Type{ℓ₁ Lvl.⊔ ℓ₂ Lvl.⊔ ℓ₃ Lvl.⊔ ℓₗ} where
field add : E → C → C
Membership = ∀{y}{a}{x} → (x ∈ add y a) ↔ ((x ∈ a) ∨ (x ≡ₛ y))
field membership : Membership
open AddFunction ⦃ ... ⦄ hiding (Membership ; membership) public
module Add ⦃ inst ⦄ = AddFunction(inst)
record RemoveFunction : Type{ℓ₁ Lvl.⊔ ℓ₂ Lvl.⊔ ℓ₃ Lvl.⊔ ℓₗ} where
field remove : E → C → C
Membership = ∀{y}{a}{x} → (x ∈ remove y a) ↔ ((x ∈ a) ∧ (x ≢ₛ y))
field membership : Membership
open RemoveFunction ⦃ ... ⦄ hiding (Membership ; membership) public
module Remove ⦃ inst ⦄ = RemoveFunction(inst)
module _ {ℓ} where
record FilterFunction : Type{ℓ₁ Lvl.⊔ ℓ₂ Lvl.⊔ ℓ₃ Lvl.⊔ Lvl.𝐒(ℓ) Lvl.⊔ ℓₗ} where
field filter : (P : E → Stmt{ℓ}) ⦃ unaryRelator : UnaryRelator(P) ⦄ → (C → C)
Membership = ∀{A}{P} ⦃ unaryRelator : UnaryRelator(P) ⦄ {x} → (x ∈ filter P(A)) ↔ ((x ∈ A) ∧ P(x))
field membership : Membership
open FilterFunction ⦃ ... ⦄ hiding (Membership ; membership) public
module Filter ⦃ inst ⦄ = FilterFunction(inst)
record BooleanFilterFunction : Type{ℓ₁ Lvl.⊔ ℓ₂ Lvl.⊔ ℓ₃} where
field boolFilter : (E → Bool) → (C → C)
Membership = ∀{A}{P}{x} → (x ∈ boolFilter P(A)) ↔ ((x ∈ A) ∧ IsTrue(P(x)))
field membership : Membership
open BooleanFilterFunction ⦃ ... ⦄ hiding (Membership ; membership) public
module BooleanFilter ⦃ inst ⦄ = BooleanFilterFunction(inst)
module _ (_∈_ : _) ⦃ setLike : SetLike{ℓ₁}{ℓ₂}{ℓ₃}{C}{E} (_∈_) {ℓ₄} ⦄ ⦃ equiv-E : Equiv{ℓₗ₁}(E) ⦄ {O : Type{ℓ₆}} ⦃ equiv-O : Equiv{ℓₗ₂}(O) ⦄ where
record UnapplyFunction : Type{ℓ₁ Lvl.⊔ ℓ₂ Lvl.⊔ ℓ₃ Lvl.⊔ ℓ₆ Lvl.⊔ ℓₗ₁ Lvl.⊔ ℓₗ₂} where
field unapply : (f : E → O) ⦃ func : Function(f) ⦄ → O → C
Membership = ∀{f} ⦃ func : Function(f) ⦄ {y}{x} → (x ∈ unapply f(y)) ↔ (f(x) ≡ₛ y)
field membership : Membership
open UnapplyFunction ⦃ ... ⦄ hiding (Membership ; membership) public
module Unapply ⦃ inst ⦄ = UnapplyFunction(inst)
module _
⦃ equiv-E₁ : Equiv{ℓₗ₁}(E₁) ⦄
(_∈₁_ : _) ⦃ setLike₁ : SetLike{ℓ₁}{ℓ₂}{ℓ₃}{C₁}{E₁} (_∈₁_) {ℓ₄} ⦄
⦃ equiv-E₂ : Equiv{ℓₗ₂}(E₂) ⦄
(_∈₂_ : _) ⦃ setLike₂ : SetLike{ℓ₆}{ℓ₇}{ℓ₈}{C₂}{E₂} (_∈₂_) {ℓ₉} ⦄
where
open SetLike ⦃ … ⦄
record MapFunction : Type{ℓₗ₁ Lvl.⊔ ℓₗ₂ Lvl.⊔ ℓ₁ Lvl.⊔ ℓ₂ Lvl.⊔ ℓ₃ Lvl.⊔ ℓ₆ Lvl.⊔ ℓ₇ Lvl.⊔ ℓ₈} where
field map : (f : E₁ → E₂) ⦃ func : Function(f) ⦄ → (C₁ → C₂)
Membership = ∀{f} ⦃ func : Function(f) ⦄ {A}{y} → (y ∈₂ map f(A)) ↔ ∃(x ↦ (x ∈₁ A) ∧ (f(x) ≡ₛ y))
field membership : Membership
open MapFunction ⦃ ... ⦄ hiding (Membership ; membership) public
module Map ⦃ inst ⦄ = MapFunction(inst)
record UnmapFunction : Type{ℓₗ₁ Lvl.⊔ ℓₗ₂ Lvl.⊔ ℓ₁ Lvl.⊔ ℓ₂ Lvl.⊔ ℓ₃ Lvl.⊔ ℓ₆ Lvl.⊔ ℓ₇ Lvl.⊔ ℓ₈} where
field unmap : (f : E₁ → E₂) ⦃ func : Function(f) ⦄ → (C₂ → C₁)
Membership = ∀{f} ⦃ func : Function(f) ⦄ {A}{x} → (x ∈₁ unmap f(A)) ↔ (f(x) ∈₂ A)
field membership : Membership
open UnmapFunction ⦃ ... ⦄ hiding (Membership ; membership) public
module Unmap ⦃ inst ⦄ = UnmapFunction(inst)
module _ (_∈ₒ_ : _) ⦃ outer-setLike : SetLike{ℓ₁}{ℓ₂}{ℓ₃}{Cₒ}{Cᵢ} (_∈ₒ_) {ℓ₄} ⦄ (_∈ᵢ_ : _) ⦃ inner-setLike : SetLike{ℓ₂}{ℓ₆}{ℓ₇}{Cᵢ}{E} (_∈ᵢ_) {ℓ₈} ⦄ where
open SetLike ⦃ … ⦄
record PowerFunction ⦃ subset : SubsetRelation(_∈ᵢ_){ℓ₄ = ℓ₉} ⦄ : Type{ℓ₁ Lvl.⊔ ℓ₂ Lvl.⊔ ℓ₃ Lvl.⊔ ℓ₈} where
field ℘ : Cᵢ → Cₒ
Membership = ∀{A x} → (x ∈ₒ ℘(A)) ↔ (x ⊆ A)
field membership : Membership
open PowerFunction ⦃ ... ⦄ hiding (Membership ; membership) public
module Power ⦃ inst ⦄ = PowerFunction(inst)
record BigUnionOperator : Type{ℓ₁ Lvl.⊔ ℓ₂ Lvl.⊔ ℓ₃ Lvl.⊔ ℓ₆ Lvl.⊔ ℓ₇} where
field ⋃ : Cₒ → Cᵢ
Membership = ∀{A}{x} → (x ∈ᵢ (⋃ A)) ↔ ∃(a ↦ (a ∈ₒ A) ∧ (x ∈ᵢ a))
field membership : Membership
open BigUnionOperator ⦃ ... ⦄ hiding (Membership ; membership) public
module BigUnion ⦃ inst ⦄ = BigUnionOperator(inst)
record BigIntersectionOperator : Type{ℓ₁ Lvl.⊔ ℓ₂ Lvl.⊔ ℓ₃ Lvl.⊔ ℓ₆ Lvl.⊔ ℓ₇} where
field ⋂ : Cₒ → Cᵢ
Membership = ∀{A} → ∃(_∈ₒ A) → ∀{x} → (x ∈ᵢ (⋂ A)) ↔ (∀{a} → (a ∈ₒ A) → (x ∈ᵢ a))
field membership : Membership
open BigIntersectionOperator ⦃ ... ⦄ hiding (Membership ; membership) public
module BigIntersection ⦃ inst ⦄ = BigIntersectionOperator(inst)
module _ {I : Type{ℓ}} ⦃ equiv-I : Equiv{ℓₗ₁}(I) ⦄ ⦃ equiv-E : Equiv{ℓₗ₂}(E) ⦄ (_∈_ : _) ⦃ setLike : SetLike{ℓ₁}{ℓ₂}{ℓ₃}{C}{E} (_∈_) {ℓ₄}{ℓ₅} ⦄ where
record IndexedBigUnionOperator : Type{ℓ Lvl.⊔ ℓ₁ Lvl.⊔ ℓ₂ Lvl.⊔ ℓ₃} where
field ⋃ᵢ : (I → C) → C
Membership = ∀{Ai}{x} → (x ∈ (⋃ᵢ Ai)) ↔ ∃(i ↦ (x ∈ Ai(i)))
field membership : Membership
open IndexedBigUnionOperator ⦃ ... ⦄ hiding (Membership ; membership) public
module IndexedBigUnion ⦃ inst ⦄ = IndexedBigUnionOperator(inst)
record IndexedBigIntersectionOperator : Type{ℓ Lvl.⊔ ℓ₁ Lvl.⊔ ℓ₂ Lvl.⊔ ℓ₃} where
field ⋂ᵢ : (I → C) → C
Membership = ∀{Ai} → ◊(I) → ∀{x} → (x ∈ (⋂ᵢ Ai)) ↔ (∀{i} → (x ∈ Ai(i)))
field membership : Membership
open IndexedBigIntersectionOperator ⦃ ... ⦄ hiding (Membership ; membership) public
module IndexedBigIntersection ⦃ inst ⦄ = IndexedBigIntersectionOperator(inst)
{-
open SetLike ⦃ … ⦄
using (
_∈_ ; _⊆_ ; _≡_ ;
_∋_ ; _⊇_ ;
_∉_ ; _⊈_ ; _⊉_ ; _≢_ ;
∅ ; _∪_ ; _∩_ ; _∖_ ;
singleton ; add ; remove
)
-}
-}
|
{
"alphanum_fraction": 0.5990532333,
"avg_line_length": 42.4090909091,
"ext": "agda",
"hexsha": "9d15816a69dfbdb3686f27fea0128a3145becbc4",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Structure/Container/SetLike.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Structure/Container/SetLike.agda",
"max_line_length": 243,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Structure/Container/SetLike.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": 4858,
"size": 11196
}
|
{-# OPTIONS --cubical-compatible --show-implicit #-}
-- {-# OPTIONS -v tc.data.sort:20 -v tc.lhs.split.well-formed:100 #-}
module WithoutK5 where
-- Equality defined with one index.
data _≡_ {A : Set} (x : A) : A → Set where
refl : x ≡ x
weak-K : {A : Set} {a b : A} (p q : a ≡ b) (α β : p ≡ q) → α ≡ β
weak-K refl .refl refl refl = refl
|
{
"alphanum_fraction": 0.5843023256,
"avg_line_length": 26.4615384615,
"ext": "agda",
"hexsha": "4e54ab93f02e0e0a87e6c36371551de910b74fd4",
"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/Fail/WithoutK5.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/Fail/WithoutK5.agda",
"max_line_length": 69,
"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/Fail/WithoutK5.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 126,
"size": 344
}
|
-- Andreas, 2016-02-21 issue 1862 reported by nad
-- {-# OPTIONS -v tc.decl:10 -v tc.def.where:10 -v tc.meta:10 -v tc.size.solve:100 #-}
open import Common.Size
data Nat (i : Size) : Set where
zero : Nat i
suc : (j : Size< i) (n : Nat j) → Nat i
id : ∀ i → Nat i → Nat i
id _ zero = zero
id _ (suc j n) = s
where
mutual
s = suc _ r -- should not be instantiated to ∞x
r = id _ n
|
{
"alphanum_fraction": 0.5717761557,
"avg_line_length": 24.1764705882,
"ext": "agda",
"hexsha": "469e14f0cf826adecbe78b9400a89d0f2239992e",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Succeed/SizeInfinity.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/SizeInfinity.agda",
"max_line_length": 86,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/SizeInfinity.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": 152,
"size": 411
}
|
{-# OPTIONS --without-K #-}
open import lib.Basics
open import lib.types.Span
open import lib.types.Pointed
open import lib.types.Pushout
open import lib.types.PushoutFlattening
open import lib.types.Unit
open import lib.types.Paths
open import lib.types.Lift
open import lib.cubical.Square
-- Suspension is defined as a particular case of pushout
module lib.types.Suspension where
module _ {i} (A : Type i) where
suspension-span : Span
suspension-span = span Unit Unit A (λ _ → tt) (λ _ → tt)
Suspension : Type i
Suspension = Pushout suspension-span
-- [north'] and [south'] explictly ask for [A]
north' : Suspension
north' = left tt
south' : Suspension
south' = right tt
module _ {i} {A : Type i} where
north : Suspension A
north = north' A
south : Suspension A
south = south' A
merid : A → north == south
merid x = glue x
module SuspensionElim {j} {P : Suspension A → Type j} (n : P north)
(s : P south) (p : (x : A) → n == s [ P ↓ merid x ]) where
open module P = PushoutElim (λ _ → n) (λ _ → s) p
public using (f) renaming (glue-β to merid-β)
open SuspensionElim public using () renaming (f to Suspension-elim)
module SuspensionRec {j} {C : Type j} (n s : C) (p : A → n == s) where
open module P = PushoutRec {d = suspension-span A} (λ _ → n) (λ _ → s) p
public using (f) renaming (glue-β to merid-β)
open SuspensionRec public using () renaming (f to Suspension-rec)
module SuspensionRecType {j} (n s : Type j) (p : A → n ≃ s)
= PushoutRecType {d = suspension-span A} (λ _ → n) (λ _ → s) p
suspension-⊙span : ∀ {i} → Ptd i → ⊙Span
suspension-⊙span X =
⊙span ⊙Unit ⊙Unit X (⊙cst {X = X}) (⊙cst {X = X})
⊙Susp : ∀ {i} → Ptd i → Ptd i
⊙Susp (A , _) = ⊙[ Suspension A , north ]
σloop : ∀ {i} (X : Ptd i) → fst X → north' (fst X) == north' (fst X)
σloop (_ , x₀) x = merid x ∙ ! (merid x₀)
σloop-pt : ∀ {i} {X : Ptd i} → σloop X (snd X) == idp
σloop-pt {X = (_ , x₀)} = !-inv-r (merid x₀)
module FlipSusp {i} {A : Type i} = SuspensionRec
(south' A) north (! ∘ merid)
flip-susp : ∀ {i} {A : Type i} → Suspension A → Suspension A
flip-susp = FlipSusp.f
⊙flip-susp : ∀ {i} (X : Ptd i) → fst (⊙Susp X ⊙→ ⊙Susp X)
⊙flip-susp X = (flip-susp , ! (merid (snd X)))
module _ {i j} where
module SuspFmap {A : Type i} {B : Type j} (f : A → B) =
SuspensionRec north south (merid ∘ f)
susp-fmap : {A : Type i} {B : Type j} (f : A → B)
→ (Suspension A → Suspension B)
susp-fmap = SuspFmap.f
⊙susp-fmap : {X : Ptd i} {Y : Ptd j} (f : fst (X ⊙→ Y))
→ fst (⊙Susp X ⊙→ ⊙Susp Y)
⊙susp-fmap (f , fpt) = (susp-fmap f , idp)
module _ {i} where
susp-fmap-idf : (A : Type i) → ∀ a → susp-fmap (idf A) a == a
susp-fmap-idf A = Suspension-elim idp idp $ λ a →
↓-='-in (ap-idf (merid a) ∙ ! (SuspFmap.merid-β (idf A) a))
⊙susp-fmap-idf : (X : Ptd i)
→ ⊙susp-fmap (⊙idf X) == ⊙idf (⊙Susp X)
⊙susp-fmap-idf X = ⊙λ= (susp-fmap-idf (fst X)) idp
module _ {i j} where
susp-fmap-cst : {A : Type i} {B : Type j} (b : B)
(a : Suspension A) → susp-fmap (cst b) a == north
susp-fmap-cst b = Suspension-elim idp (! (merid b)) $ (λ a →
↓-app=cst-from-square $ SuspFmap.merid-β (cst b) a ∙v⊡ tr-square _)
⊙susp-fmap-cst : {X : Ptd i} {Y : Ptd j}
→ ⊙susp-fmap (⊙cst {X = X} {Y = Y}) == ⊙cst
⊙susp-fmap-cst = ⊙λ= (susp-fmap-cst _) idp
module _ {i j k} where
susp-fmap-∘ : {A : Type i} {B : Type j} {C : Type k} (g : B → C) (f : A → B)
(σ : Suspension A) → susp-fmap (g ∘ f) σ == susp-fmap g (susp-fmap f σ)
susp-fmap-∘ g f = Suspension-elim
idp
idp
(λ a → ↓-='-in $
ap-∘ (susp-fmap g) (susp-fmap f) (merid a)
∙ ap (ap (susp-fmap g)) (SuspFmap.merid-β f a)
∙ SuspFmap.merid-β g (f a)
∙ ! (SuspFmap.merid-β (g ∘ f) a))
⊙susp-fmap-∘ : {X : Ptd i} {Y : Ptd j} {Z : Ptd k}
(g : fst (Y ⊙→ Z)) (f : fst (X ⊙→ Y))
→ ⊙susp-fmap (g ⊙∘ f) == ⊙susp-fmap g ⊙∘ ⊙susp-fmap f
⊙susp-fmap-∘ g f = ⊙λ= (susp-fmap-∘ (fst g) (fst f)) idp
{- Extract the 'glue component' of a pushout -}
module _ {i j k} {s : Span {i} {j} {k}} where
module ExtGlue = PushoutRec {d = s} {D = Suspension (Span.C s)}
(λ _ → north) (λ _ → south) merid
ext-glue = ExtGlue.f
module _ {x₀ : Span.A s} where
⊙ext-glue :
fst ((Pushout s , left x₀) ⊙→ (Suspension (Span.C s) , north))
⊙ext-glue = (ext-glue , idp)
module _ {i j} {A : Type i} {B : Type j} where
equiv-Suspension : A ≃ B → Suspension A ≃ Suspension B
equiv-Suspension eq = equiv to from to-from from-to where
module To = SuspensionRec north south (λ a → merid (–> eq a))
module From = SuspensionRec north south (λ b → merid (<– eq b))
to : Suspension A → Suspension B
to = To.f
from : Suspension B → Suspension A
from = From.f
to-from : ∀ b → to (from b) == b
to-from = Suspension-elim idp idp to-from-merid where
to-from-merid : ∀ b → idp == idp [ (λ b → to (from b) == b) ↓ merid b ]
to-from-merid b = ↓-app=idf-in $
idp ∙' merid b
=⟨ ∙'-unit-l (merid b) ⟩
merid b
=⟨ ! $ <–-inv-r eq b |in-ctx merid ⟩
merid (–> eq (<– eq b))
=⟨ ! $ To.merid-β (<– eq b) ⟩
ap to (merid (<– eq b))
=⟨ ! $ From.merid-β b |in-ctx ap To.f ⟩
ap to (ap from (merid b))
=⟨ ! $ ap-∘ to from (merid b) ⟩
ap (to ∘ from) (merid b)
=⟨ ! $ ∙-unit-r (ap (to ∘ from) (merid b)) ⟩
ap (to ∘ from) (merid b) ∙ idp
∎
from-to : ∀ a → from (to a) == a
from-to = Suspension-elim idp idp from-to-merid where
from-to-merid : ∀ a → idp == idp [ (λ a → from (to a) == a) ↓ merid a ]
from-to-merid a = ↓-app=idf-in $
idp ∙' merid a
=⟨ ∙'-unit-l (merid a) ⟩
merid a
=⟨ ! $ <–-inv-l eq a |in-ctx merid ⟩
merid (<– eq (–> eq a))
=⟨ ! $ From.merid-β (–> eq a) ⟩
ap from (merid (–> eq a))
=⟨ ! $ To.merid-β a |in-ctx ap From.f ⟩
ap from (ap to (merid a))
=⟨ ! $ ap-∘ from to (merid a) ⟩
ap (from ∘ to) (merid a)
=⟨ ! $ ∙-unit-r (ap (from ∘ to) (merid a)) ⟩
ap (from ∘ to) (merid a) ∙ idp
∎
module _ {i j} {X : Ptd i} {Y : Ptd j} where
⊙equiv-⊙Susp : X ⊙≃ Y → ⊙Susp X ⊙≃ ⊙Susp Y
⊙equiv-⊙Susp ⊙eq = ⊙≃-in (equiv-Suspension (fst (⊙≃-out ⊙eq))) idp
{- Interaction with [Lift] -}
module _ {i j} (X : Type i) where
Suspension-Lift-equiv-Lift-Suspension : Suspension (Lift {j = j} X) ≃ Lift {j = j} (Suspension X)
Suspension-Lift-equiv-Lift-Suspension = lift-equiv ∘e equiv-Suspension lower-equiv
Suspension-Lift : Suspension (Lift {j = j} X) == Lift {j = j} (Suspension X)
Suspension-Lift = ua Suspension-Lift-equiv-Lift-Suspension
module _ {i j} (X : Ptd i) where
⊙Susp-⊙Lift-⊙equiv-⊙Lift-⊙Susp : ⊙Susp (⊙Lift {j = j} X) ⊙≃ ⊙Lift {j = j} (⊙Susp X)
⊙Susp-⊙Lift-⊙equiv-⊙Lift-⊙Susp = ⊙lift-equiv {j = j} ⊙∘e ⊙equiv-⊙Susp {X = ⊙Lift {j = j} X} {Y = X} ⊙lower-equiv
⊙Susp-⊙Lift : ⊙Susp (⊙Lift {j = j} X) == ⊙Lift {j = j} (⊙Susp X)
⊙Susp-⊙Lift = ⊙ua ⊙Susp-⊙Lift-⊙equiv-⊙Lift-⊙Susp
|
{
"alphanum_fraction": 0.54539057,
"avg_line_length": 31.8609865471,
"ext": "agda",
"hexsha": "a4f31aaadeb18845302a40d8f6e723d2c6d8befd",
"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/Suspension.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/Suspension.agda",
"max_line_length": 114,
"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/Suspension.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2952,
"size": 7105
}
|
module MLib.Algebra.PropertyCode.Core where
open import MLib.Prelude
open import MLib.Finite
import MLib.Finite.Properties as FiniteProps
open import MLib.Algebra.PropertyCode.RawStruct
import Relation.Unary as U using (Decidable)
open import Relation.Binary as B using (Setoid)
open List.All using (All; _∷_; [])
open import Data.List.Any using (Any; here; there)
open import Data.List.Membership.Propositional using (_∈_)
open import Data.Vec.N-ary
open import Data.Product.Relation.SigmaPropositional as OverΣ using (OverΣ)
open import Data.Bool using (T)
open import Category.Applicative
open LeftInverse using () renaming (_∘_ to _∘ⁱ_)
open FE using (_⇨_; cong)
open import Function.Equivalence using (Equivalence)
open Table using (Table)
open Algebra using (IdempotentCommutativeMonoid)
--------------------------------------------------------------------------------
-- Extra theorems about bools
--------------------------------------------------------------------------------
open Bool
module BoolExtra where
_⇒_ : Bool → Bool → Bool
false ⇒ false = true
false ⇒ true = true
true ⇒ false = false
true ⇒ true = true
true⇒ : ∀ {x} → true ⇒ x ≡ x
true⇒ {false} = ≡.refl
true⇒ {true} = ≡.refl
MP : ∀ {x y} → T (x ⇒ y) → T x → T y
MP {false} {false} _ ()
MP {false} {true} _ _ = tt
MP {true} {false} ()
MP {true} {true} _ _ = tt
abs : ∀ {x y} → (T x → T y) → T (x ⇒ y)
abs {false} {false} f = tt
abs {false} {true} f = tt
abs {true} {false} f = f tt
abs {true} {true} f = tt
∧-elim : ∀ {x y} → T (x ∧ y) → T x × T y
∧-elim {false} {false} ()
∧-elim {false} {true} ()
∧-elim {true} {false} ()
∧-elim {true} {true} p = tt , tt
--------------------------------------------------------------------------------
-- Universe of properties
--------------------------------------------------------------------------------
data PropKind : Set where
associative commutative idempotent selective cancellative
leftIdentity rightIdentity
leftZero rightZero
distributesOverˡ distributesOverʳ
: PropKind
opArities : PropKind → List ℕ
opArities associative = 2 ∷ []
opArities commutative = 2 ∷ []
opArities idempotent = 2 ∷ []
opArities selective = 2 ∷ []
opArities cancellative = 2 ∷ []
opArities leftIdentity = 0 ∷ 2 ∷ []
opArities rightIdentity = 0 ∷ 2 ∷ []
opArities leftZero = 0 ∷ 2 ∷ []
opArities rightZero = 0 ∷ 2 ∷ []
opArities distributesOverˡ = 2 ∷ 2 ∷ []
opArities distributesOverʳ = 2 ∷ 2 ∷ []
module _ {c ℓ k} {K : ℕ → Set k} (rawStruct : RawStruct K c ℓ) where
open RawStruct rawStruct
open Algebra.FunctionProperties _≈_
interpret : (π : PropKind) → All K (opArities π) → Set (c ⊔ˡ ℓ)
interpret associative (∙ ∷ []) = Associative ⟦ ∙ ⟧
interpret commutative (∙ ∷ []) = Commutative ⟦ ∙ ⟧
interpret idempotent (∙ ∷ []) = Idempotent ⟦ ∙ ⟧
interpret selective (∙ ∷ []) = Selective ⟦ ∙ ⟧
interpret cancellative (∙ ∷ []) = Cancellative ⟦ ∙ ⟧
interpret leftIdentity (ε ∷ ∙ ∷ []) = LeftIdentity ⟦ ε ⟧ ⟦ ∙ ⟧
interpret rightIdentity (ε ∷ ∙ ∷ []) = RightIdentity ⟦ ε ⟧ ⟦ ∙ ⟧
interpret leftZero (ω ∷ ∙ ∷ []) = LeftZero ⟦ ω ⟧ ⟦ ∙ ⟧
interpret rightZero (ω ∷ ∙ ∷ []) = RightZero ⟦ ω ⟧ ⟦ ∙ ⟧
interpret distributesOverˡ (* ∷ + ∷ []) = ⟦ * ⟧ DistributesOverˡ ⟦ + ⟧
interpret distributesOverʳ (* ∷ + ∷ []) = ⟦ * ⟧ DistributesOverʳ ⟦ + ⟧
Property : ∀ {k} (K : ℕ → Set k) → Set k
Property K = ∃ (All K ∘ opArities)
module PropertyC where
natsEqual : ℕ → ℕ → Bool
natsEqual Nat.zero Nat.zero = true
natsEqual Nat.zero (Nat.suc y) = false
natsEqual (Nat.suc x) Nat.zero = false
natsEqual (Nat.suc x) (Nat.suc y) = natsEqual x y
aritiesMatch : List ℕ → List ℕ → Bool
aritiesMatch [] [] = true
aritiesMatch [] (x ∷ ys) = false
aritiesMatch (x ∷ xs) [] = false
aritiesMatch (x ∷ xs) (y ∷ ys) = natsEqual x y ∧ aritiesMatch xs ys
natsEqual-correct : ∀ {m n} → T (natsEqual m n) → m ≡ n
natsEqual-correct {Nat.zero} {Nat.zero} p = ≡.refl
natsEqual-correct {Nat.zero} {Nat.suc n} ()
natsEqual-correct {Nat.suc m} {Nat.zero} ()
natsEqual-correct {Nat.suc m} {Nat.suc n} p = ≡.cong Nat.suc (natsEqual-correct p)
aritiesMatch-correct : ∀ {xs ys} → T (aritiesMatch xs ys) → xs ≡ ys
aritiesMatch-correct {[]} {[]} p = ≡.refl
aritiesMatch-correct {[]} {x ∷ ys} ()
aritiesMatch-correct {x ∷ xs} {[]} ()
aritiesMatch-correct {x ∷ xs} {y ∷ ys} p =
let q , r = BoolExtra.∧-elim {natsEqual x y} p
in ≡.cong₂ _∷_ (natsEqual-correct q) (aritiesMatch-correct r)
_on_ : ∀ {k} {K : ℕ → Set k} {n : ℕ} (π : PropKind) {_ : T (aritiesMatch (opArities π) (n ∷ []))} → K n → Property K
_on_ {K = K} π {match} κ = π , ≡.subst (All K) (≡.sym (aritiesMatch-correct {opArities π} match)) (κ ∷ [])
_is_for_ : ∀ {k} {K : ℕ → Set k} {m n : ℕ} → K m → (π : PropKind) {_ : T (aritiesMatch (opArities π) (m ∷ n ∷ []))} → K n → Property K
_is_for_ {K = K} α π {match} ∙ = π , ≡.subst (All K) (≡.sym (aritiesMatch-correct {opArities π} match)) (α ∷ ∙ ∷ [])
_⟨_⟩ₚ_ = _is_for_
⟦_⟧P : ∀ {c ℓ k} {K : ℕ → Set k} → Property K → RawStruct K c ℓ → Set (c ⊔ˡ ℓ)
⟦ π , ops ⟧P rawStruct = interpret rawStruct π ops
PropKind-IsFiniteSet : IsFiniteSet PropKind _
PropKind-IsFiniteSet = record
{ ontoFin = record
{ to = ≡.→-to-⟶ to
; from = ≡.→-to-⟶ from
; left-inverse-of = left-inverse-of
}
}
where
open Fin using (#_) renaming (zero to z; suc to s_)
N = 11
to : PropKind → Fin N
to associative = # 0
to commutative = # 1
to idempotent = # 2
to selective = # 3
to cancellative = # 4
to leftIdentity = # 5
to rightIdentity = # 6
to leftZero = # 7
to rightZero = # 8
to distributesOverˡ = # 9
to distributesOverʳ = # 10
from : Fin N → PropKind
from z = associative
from (s z) = commutative
from (s s z) = idempotent
from (s s s z) = selective
from (s s s s z) = cancellative
from (s s s s s z) = leftIdentity
from (s s s s s s z) = rightIdentity
from (s s s s s s s z) = leftZero
from (s s s s s s s s z) = rightZero
from (s s s s s s s s s z) = distributesOverˡ
from (s s s s s s s s s s z) = distributesOverʳ
from (s s s s s s s s s s s ())
left-inverse-of : ∀ x → from (to x) ≡ x
left-inverse-of associative = ≡.refl
left-inverse-of commutative = ≡.refl
left-inverse-of idempotent = ≡.refl
left-inverse-of selective = ≡.refl
left-inverse-of cancellative = ≡.refl
left-inverse-of leftIdentity = ≡.refl
left-inverse-of rightIdentity = ≡.refl
left-inverse-of leftZero = ≡.refl
left-inverse-of rightZero = ≡.refl
left-inverse-of distributesOverˡ = ≡.refl
left-inverse-of distributesOverʳ = ≡.refl
finitePropKind : FiniteSet _ _
finitePropKind = record { isFiniteSetoid = PropKind-IsFiniteSet }
--------------------------------------------------------------------------------
-- Subsets of properties over a particular operator code type
--------------------------------------------------------------------------------
record Code k : Set (sucˡ k) where
field
K : ℕ → Set k
boundAt : ℕ → ℕ
isFiniteAt : ∀ n → IsFiniteSet (K n) (boundAt n)
finiteSetAt : ℕ → FiniteSet _ _
finiteSetAt n = record { isFiniteSetoid = isFiniteAt n }
module K n = FiniteSet (finiteSetAt n)
module Property where
finiteSet : FiniteSet _ _
finiteSet = record
{ isFiniteSetoid =
Σ-isFiniteSetoid PropKind-IsFiniteSet (All-finiteSet finiteSetAt ∘ opArities)
}
open FiniteSet finiteSet public
open FiniteProps finiteSet public
≈⇒≡ : ∀ {π π′} → π ≈ π′ → π ≡ π′
≈⇒≡ {π , κ} {.π , κ′} (≡.refl , snd) with All′.PW-≡ _ snd
≈⇒≡ {π , κ} {.π , .κ} (≡.refl , snd) | ≡.refl = ≡.refl
record IsSubcode {k k′} (sub : Code k) (sup : Code k′) : Set (k ⊔ˡ k′) where
constructor subcode
private
module Sub = Code sub
module Sup = Code sup
field
subK→supK : ∀ {n} → Sub.K n → Sup.K n
supK→subK : ∀ {n} → Sup.K n → Maybe (Sub.K n)
acrossSub : ∀ {n} (κ : Sub.K n) → supK→subK (subK→supK κ) ≡ just κ
mapProperty :
∀ {k k′} {K : ℕ → Set k} {K′ : ℕ → Set k′}
→ (∀ {n} → K′ n → K n)
→ Property K′
→ Property K
mapProperty f (π , κs) = π , List.All.map f κs
record Properties {k} (code : Code k) : Set k where
constructor properties
open Code code using (K; module Property)
field
hasProperty : Property K → Bool
hasPropertyF : Property.setoid ⟶ ≡.setoid Bool
_⟨$⟩_ hasPropertyF = hasProperty
cong hasPropertyF (≡.refl , q) rewrite All′.PW-≡ K q = ≡.refl
open Properties public
module _ {k} {code : Code k} where
open Code code using (K; module Property)
Property-Func : Setoid _ _
Property-Func = Property.setoid ⇨ ≡.setoid Bool
Properties-setoid : Setoid _ _
Properties-setoid = record
{ Carrier = Properties code
; _≈_ = λ Π Π′ → hasPropertyF Π ≈ hasPropertyF Π′
; isEquivalence = record
{ refl = λ {Π} → refl {hasPropertyF Π}
; sym = λ {Π} {Π′} → sym {hasPropertyF Π} {hasPropertyF Π′}
; trans = λ {Π} {Π′} {Π′′} → trans {hasPropertyF Π} {hasPropertyF Π′} {hasPropertyF Π′′}
}
}
where
open Setoid Property-Func
Properties↞Func : LeftInverse Properties-setoid Property-Func
Properties↞Func = record
{ to = record { _⟨$⟩_ = hasPropertyF ; cong = id }
; from = record { _⟨$⟩_ = properties ∘ _⟨$⟩_ ; cong = id }
; left-inverse-of = left-inverse-of
}
where
open Setoid Property.setoid using (_≈_)
left-inverse-of : ∀ (Π : Properties code) {π π′} → π ≈ π′ → hasProperty Π π ≡ hasProperty Π π′
left-inverse-of Π (≡.refl , p) rewrite All′.PW-≡ K p = ≡.refl
-- Properties↞ℕ : LeftInverse Properties-setoid (≡.setoid ℕ)
-- Properties↞ℕ = asNat Property.finiteSet ∘ⁱ Properties↞Func
-- Evaluates to 'true' only when every property is present.
hasAll : Properties code → Bool
hasAll Π = Property.foldMap Bool.∧-idempotentCommutativeMonoid (hasProperty Π)
implies : Properties code → Properties code → Bool
implies Π₁ Π₂ = Property.foldMap Bool.∧-idempotentCommutativeMonoid (λ π → hasProperty Π₁ π BoolExtra.⇒ hasProperty Π₂ π)
-- The full set of properties
True : Properties code
hasProperty True _ = true
-- The empty set of properties
False : Properties code
hasProperty False _ = false
-- Inhabited if the given property is present. Suitable for use as an instance
-- argument.
record _∈ₚ_ (π : Property K) (Π : Properties code) : Set where
instance constructor fromTruth
field
truth : T (hasProperty Π π)
open _∈ₚ_
-- Inhabited if the first set of properties implies the second. Suitable for
-- use as an instance argument but difficult to work with.
record _⇒ₚ_ (Π₁ Π₂ : Properties code) : Set where
instance constructor fromTruth
field
truth : T (implies Π₁ Π₂)
⊨ : Properties code → Set
⊨ Π = True ⇒ₚ Π
-- Inhabited if the first set of properties implies the second. Unsuitable for
-- use as an instance argument, but easy to work with.
_→ₚ_ : Properties code → Properties code → Set k
Π₁ →ₚ Π₂ = ∀ π → π ∈ₚ Π₁ → π ∈ₚ Π₂
⊢ : Properties code → Set k
⊢ Π = True →ₚ Π
-- The two forms of implication are equivalent to each other, as we would hope
→ₚ-⇒ₚ : {Π₁ Π₂ : Properties code} → Π₁ →ₚ Π₂ → Π₁ ⇒ₚ Π₂
→ₚ-⇒ₚ {Π₁} {Π₂} p = _⇒ₚ_.fromTruth (Equivalence.from T-≡ ⟨$⟩ impl-true)
where
open ≡.Reasoning
icm = Bool.∧-idempotentCommutativeMonoid
impl-pointwise : ∀ π → hasProperty Π₁ π BoolExtra.⇒ hasProperty Π₂ π ≡ true
impl-pointwise π = Equivalence.to T-≡ ⟨$⟩ BoolExtra.abs (truth ∘ p π ∘ fromTruth)
impl-true : implies Π₁ Π₂ ≡ true
impl-true = begin
implies Π₁ Π₂ ≡⟨⟩
Property.foldMap icm (λ π → hasProperty Π₁ π BoolExtra.⇒ hasProperty Π₂ π) ≡⟨ Property.foldMap-cong icm impl-pointwise ⟩
Property.foldMap icm (λ _ → true) ≡⟨ proj₁ (IdempotentCommutativeMonoid.identity icm) _ ⟩
true ∧ Property.foldMap icm (λ _ → true) ≡⟨ Property.foldMap-const icm ⟩
true ∎
⇒ₚ-→ₚ : {Π₁ Π₂ : Properties code} → Π₁ ⇒ₚ Π₂ → Π₁ →ₚ Π₂
⇒ₚ-→ₚ {Π₁} {Π₂} (fromTruth p) π (fromTruth q) = fromTruth (BoolExtra.MP (Equivalence.from T-≡ ⟨$⟩ impl-π) q)
where
i = Property.toIx π
open ≡.Reasoning
icm = Bool.∧-idempotentCommutativeMonoid
module ∧ = IdempotentCommutativeMonoid icm
implies-true : implies Π₁ Π₂ ≡ true
implies-true = Equivalence.to T-≡ ⟨$⟩ p
implies-F : Property.setoid ⟶ ≡.setoid Bool
implies-F = record
{ _⟨$⟩_ = λ π → hasProperty Π₁ π BoolExtra.⇒ hasProperty Π₂ π
; cong = λ { {π} {π′} p → ≡.cong₂ BoolExtra._⇒_ (cong (hasPropertyF Π₁) p) (cong (hasPropertyF Π₂) p)}
}
impl-π : hasProperty Π₁ π BoolExtra.⇒ hasProperty Π₂ π ≡ true
impl-π = begin
hasProperty Π₁ π BoolExtra.⇒ hasProperty Π₂ π ≡⟨ ≡.sym (proj₂ ∧.identity _) ⟩
(hasProperty Π₁ π BoolExtra.⇒ hasProperty Π₂ π) ∧ true ≡⟨ ∧.∙-cong (≡.refl {x = hasProperty Π₁ π BoolExtra.⇒ hasProperty Π₂ π}) (≡.sym implies-true) ⟩
(hasProperty Π₁ π BoolExtra.⇒ hasProperty Π₂ π) ∧ implies Π₁ Π₂ ≡⟨ Property.enumₜ-complete icm implies-F π ⟩
implies Π₁ Π₂ ≡⟨ implies-true ⟩
true ∎
-- Form a set of properties from a single property
singleton : Property K → Properties code
hasProperty (singleton π) π′ = ⌊ π Property.≟ π′ ⌋
-- Union of two sets of properties
_∪ₚ_ : Properties code → Properties code → Properties code
hasProperty (Π₁ ∪ₚ Π₂) π = hasProperty Π₁ π ∨ hasProperty Π₂ π
-- Form a set of properties from a list of properties
fromList : List (Property K) → Properties code
fromList = List.foldr (_∪ₚ_ ∘ singleton) False
π-∈ₚ-singleton : ∀ {π} → π ∈ₚ singleton π
truth (π-∈ₚ-singleton {π}) with π Property.≟ π
truth (π-∈ₚ-singleton {π}) | yes p = _
truth (π-∈ₚ-singleton {π}) | no ¬p = ¬p Property.refl
_⊆_ : Properties code → Properties code → Properties code
hasProperty (Π₁ ⊆ Π₂) π = not (hasProperty Π₁ π) ∨ hasProperty Π₂ π
→ₚ-trans : ∀ {Π₁ Π₂ Π₃} → Π₁ →ₚ Π₂ → Π₂ →ₚ Π₃ → Π₁ →ₚ Π₃
→ₚ-trans {Π₁} p q π = q π ∘ p π
⇒ₚ-trans : ∀ {Π₁ Π₂ Π₃} → Π₁ ⇒ₚ Π₂ → Π₂ ⇒ₚ Π₃ → Π₁ ⇒ₚ Π₃
⇒ₚ-trans {Π₁} p q = →ₚ-⇒ₚ (→ₚ-trans (⇒ₚ-→ₚ p) (⇒ₚ-→ₚ q))
⇒ₚ-MP : ∀ {Π Π′ π} → π ∈ₚ Π′ → Π′ ⇒ₚ Π → π ∈ₚ Π
⇒ₚ-MP {Π = Π} {Π′} {π} hasπ has⇒ = ⇒ₚ-→ₚ has⇒ π hasπ
⇒ₚ-weaken : ∀ {Π Π′ Π′′ : Properties code} (hasΠ′ : Π′ ⇒ₚ Π) ⦃ hasΠ′′ : Π′′ ⇒ₚ Π′ ⦄ → Π′′ ⇒ₚ Π
⇒ₚ-weaken hasΠ′ ⦃ hasΠ′′ ⦄ = ⇒ₚ-trans hasΠ′′ hasΠ′
module _ {k k′} {sub : Code k} {sup : Code k′} (isSub : IsSubcode sub sup) where
private
module Sub = Code sub
module Sup = Code sup
open IsSubcode isSub public
subcodeProperties : Properties sup → Properties sub
hasProperty (subcodeProperties Π) = hasProperty Π ∘ mapProperty subK→supK
supcodeProperties : Properties sub → Properties sup
hasProperty (supcodeProperties Π) (π , κs) with List.All.traverse supK→subK κs
hasProperty (supcodeProperties Π) (π , κs) | just κs′ = hasProperty Π (π , κs′)
hasProperty (supcodeProperties Π) (π , κs) | nothing = false
fromSubcode :
∀ {π} {Π : Properties sup}
→ π ∈ₚ subcodeProperties Π
→ mapProperty subK→supK π ∈ₚ Π
fromSubcode (fromTruth truth) = fromTruth truth
fromSupcode :
∀ {π} {Π : Properties sup}
→ mapProperty subK→supK π ∈ₚ Π
→ π ∈ₚ subcodeProperties Π
fromSupcode (fromTruth truth) = fromTruth truth
fromSupcode′ : ∀ {π} {Π : Properties sub} →
π ∈ₚ Π → mapProperty subK→supK π ∈ₚ supcodeProperties Π
fromSupcode′ {π , κs} π∈Π ._∈ₚ_.truth with lem
where
open ≡.Reasoning
lem : List.All.traverse supK→subK (List.All.map subK→supK κs) ≡ just κs
lem = begin
List.All.traverse supK→subK (List.All.map subK→supK κs) ≡⟨ List-All.traverse-map supK→subK subK→supK κs ⟩
List.All.traverse (supK→subK ∘ subK→supK) κs ≡⟨ List-All.traverse-cong (supK→subK ∘ subK→supK) just acrossSub κs ⟩
List.All.traverse just κs ≡⟨ List-All.traverse-just κs ⟩
just κs ∎
fromSupcode′ {π , κs} π∈Π ._∈ₚ_.truth | p rewrite p = π∈Π ._∈ₚ_.truth
module _
{c ℓ}
(sup-rawStruct : RawStruct Sup.K c ℓ)
(sub-isRawStruct : IsRawStruct (RawStruct._≈_ sup-rawStruct) (RawStruct.appOp sup-rawStruct ∘ subK→supK)) where
sub-rawStruct : RawStruct Sub.K c ℓ
sub-rawStruct = record { isRawStruct = sub-isRawStruct }
reinterpret :
∀ (π : Property Sub.K)
→ ⟦ mapProperty subK→supK π ⟧P sup-rawStruct → ⟦ π ⟧P sub-rawStruct
reinterpret (associative , ∙ ∷ []) = id
reinterpret (commutative , ∙ ∷ []) = id
reinterpret (idempotent , ∙ ∷ []) = id
reinterpret (selective , ∙ ∷ []) = id
reinterpret (cancellative , ∙ ∷ []) = id
reinterpret (leftIdentity , α ∷ ∙ ∷ []) = id
reinterpret (rightIdentity , α ∷ ∙ ∷ []) = id
reinterpret (leftZero , α ∷ ∙ ∷ []) = id
reinterpret (rightZero , α ∷ ∙ ∷ []) = id
reinterpret (distributesOverˡ , * ∷ + ∷ []) = id
reinterpret (distributesOverʳ , * ∷ + ∷ []) = id
|
{
"alphanum_fraction": 0.5890238313,
"avg_line_length": 35.0522088353,
"ext": "agda",
"hexsha": "5137757817e75b58b4b87d769f52fc9cc0e411f4",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bch29/agda-matrices",
"max_forks_repo_path": "src/MLib/Algebra/PropertyCode/Core.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "bch29/agda-matrices",
"max_issues_repo_path": "src/MLib/Algebra/PropertyCode/Core.agda",
"max_line_length": 169,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bch29/agda-matrices",
"max_stars_repo_path": "src/MLib/Algebra/PropertyCode/Core.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 6406,
"size": 17456
}
|
open import FRP.JS.Bool using ( Bool ; not )
open import FRP.JS.Maybe using ( Maybe ; just ; nothing ; _≟[_]_ )
open import FRP.JS.Nat using ( ℕ ; _≟_ ; _+_ ; _*_ ; _∸_ ; _/_ ; _/?_ ; _≤_ ; _<_ ; show ; float )
open import FRP.JS.Float using ( ℝ ) renaming ( _≟_ to _≟r_ )
open import FRP.JS.String using () renaming ( _≟_ to _≟s_ )
open import FRP.JS.QUnit using ( TestSuite ; ok ; ok! ; test ; _,_ )
module FRP.JS.Test.Nat where
infixr 2 _≟?r_
_≟?r_ : Maybe ℝ → Maybe ℝ → Bool
x ≟?r y = x ≟[ _≟r_ ] y
tests : TestSuite
tests =
( test "≟"
( ok "0 ≟ 0" (0 ≟ 0)
, ok "1 ≟ 1" (1 ≟ 1)
, ok "2 ≟ 2" (2 ≟ 2)
, ok "0 != 1" (not (0 ≟ 1))
, ok "0 != 2" (not (0 ≟ 2))
, ok "1 != 2" (not (1 ≟ 2))
, ok "1 != 0" (not (1 ≟ 0)) )
, test "+"
( ok "0 + 0" (0 + 0 ≟ 0)
, ok "1 + 1" (1 + 1 ≟ 2)
, ok "37 + 0" (37 + 0 ≟ 37)
, ok "37 + 1" (37 + 1 ≟ 38)
, ok "37 + 5" (37 + 5 ≟ 42) )
, test "*"
( ok "0 * 0" (0 * 0 ≟ 0)
, ok "1 * 1" (1 * 1 ≟ 1)
, ok "37 * 0" (37 * 0 ≟ 0)
, ok "37 * 1" (37 * 1 ≟ 37)
, ok "37 * 5" (37 * 5 ≟ 185) )
, test "∸"
( ok "0 ∸ 0" (0 ∸ 0 ≟ 0)
, ok "1 ∸ 1" (1 ∸ 1 ≟ 0)
, ok "37 ∸ 0" (37 ∸ 0 ≟ 37)
, ok "37 ∸ 1" (37 ∸ 1 ≟ 36)
, ok "37 ∸ 5" (37 ∸ 5 ≟ 32)
, ok "5 ∸ 37" (5 ∸ 37 ≟ 0) )
, test "/"
( ok "1 / 1" (1 / 1 ≟r 1.0)
, ok "37 / 1" (37 / 1 ≟r 37.0)
, ok "37 / 5" (37 / 5 ≟r 7.4)
, ok "0 /? 0" (0 /? 0 ≟?r nothing)
, ok "1 /? 1" (1 /? 1 ≟?r just 1.0)
, ok "37 /? 0" (37 /? 0 ≟?r nothing)
, ok "37 /? 1" (37 /? 1 ≟?r just 37.0)
, ok "37 /? 5" (37 /? 5 ≟?r just 7.4) )
, test "≤"
( ok "0 ≤ 0" (0 ≤ 0)
, ok "0 ≤ 1" (0 ≤ 1)
, ok "1 ≤ 0" (not (1 ≤ 0))
, ok "1 ≤ 1" (1 ≤ 1)
, ok "37 ≤ 0" (not (37 ≤ 0))
, ok "37 ≤ 1" (not (37 ≤ 1))
, ok "37 ≤ 5" (not (37 ≤ 5))
, ok "5 ≤ 37" (5 ≤ 37) )
, test "<"
( ok "0 < 0" (not (0 < 0))
, ok "0 < 1" (0 < 1)
, ok "1 < 0" (not (1 < 0))
, ok "1 < 1" (not (1 < 1))
, ok "37 < 0" (not (37 < 0))
, ok "37 < 1" (not (37 < 1))
, ok "37 < 5" (not (37 < 5))
, ok "5 < 37" (5 < 37) )
, test "show"
( ok "show 0" (show 0 ≟s "0")
, ok "show 1" (show 1 ≟s "1")
, ok "show 5" (show 5 ≟s "5")
, ok "show 37" (show 37 ≟s "37") )
, test "float"
( ok "float 0" (float 0 ≟r 0.0)
, ok "float 1" (float 1 ≟r 1.0)
, ok "float 5" (float 5 ≟r 5.0)
, ok "float 37" (float 37 ≟r 37.0) )
)
|
{
"alphanum_fraction": 0.3865306122,
"avg_line_length": 30.2469135802,
"ext": "agda",
"hexsha": "235bceb046a8a8646e92fdd04e32ed41299ce8f5",
"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/Nat.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/Nat.agda",
"max_line_length": 98,
"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/Nat.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": 1321,
"size": 2450
}
|
{-# OPTIONS --cubical --safe --no-import-sorts #-}
module Cubical.Algebra.CommAlgebra.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv.HalfAdjoint
open import Cubical.Foundations.SIP
open import Cubical.Data.Sigma
open import Cubical.Reflection.StrictEquiv
open import Cubical.Structures.Axioms
open import Cubical.Algebra.Semigroup
open import Cubical.Algebra.Monoid
open import Cubical.Algebra.CommRing
open import Cubical.Algebra.Ring
open import Cubical.Algebra.Algebra hiding (⟨_⟩a)
private
variable
ℓ ℓ′ : Level
record IsCommAlgebra (R : CommRing {ℓ}) {A : Type ℓ}
(0a : A) (1a : A)
(_+_ : A → A → A) (_·_ : A → A → A) (-_ : A → A)
(_⋆_ : ⟨ R ⟩ → A → A) : Type ℓ where
constructor iscommalgebra
field
isAlgebra : IsAlgebra (CommRing→Ring R) 0a 1a _+_ _·_ -_ _⋆_
·-comm : (x y : A) → x · y ≡ y · x
open IsAlgebra isAlgebra public
record CommAlgebra (R : CommRing {ℓ}) : Type (ℓ-suc ℓ) where
constructor commalgebra
field
Carrier : Type ℓ
0a : Carrier
1a : Carrier
_+_ : Carrier → Carrier → Carrier
_·_ : Carrier → Carrier → Carrier
-_ : Carrier → Carrier
_⋆_ : ⟨ R ⟩ → Carrier → Carrier
isCommAlgebra : IsCommAlgebra R 0a 1a _+_ _·_ -_ _⋆_
open IsCommAlgebra isCommAlgebra public
module _ {R : CommRing {ℓ}} where
open CommRingStr (snd R) using (1r) renaming (_+_ to _+r_; _·_ to _·s_)
⟨_⟩a : CommAlgebra R → Type ℓ
⟨_⟩a = CommAlgebra.Carrier
CommAlgebra→Algebra : (A : CommAlgebra R) → Algebra (CommRing→Ring R)
CommAlgebra→Algebra (commalgebra Carrier _ _ _ _ _ _ (iscommalgebra isAlgebra ·-comm)) =
algebra Carrier _ _ _ _ _ _ isAlgebra
CommAlgebra→CommRing : (A : CommAlgebra R) → CommRing {ℓ}
CommAlgebra→CommRing (commalgebra Carrier _ _ _ _ _ _
(iscommalgebra isAlgebra ·-comm)) =
_ , commringstr _ _ _ _ _ (iscommring (IsAlgebra.isRing isAlgebra) ·-comm)
CommAlgebraEquiv : (R S : CommAlgebra R) → Type ℓ
CommAlgebraEquiv R S = AlgebraEquiv (CommAlgebra→Algebra R) (CommAlgebra→Algebra S)
makeIsCommAlgebra : {A : Type ℓ} {0a 1a : A}
{_+_ _·_ : A → A → A} { -_ : A → A} {_⋆_ : ⟨ R ⟩ → A → A}
(isSet-A : isSet A)
(+-assoc : (x y z : A) → x + (y + z) ≡ (x + y) + z)
(+-rid : (x : A) → x + 0a ≡ x)
(+-rinv : (x : A) → x + (- x) ≡ 0a)
(+-comm : (x y : A) → x + y ≡ y + x)
(·-assoc : (x y z : A) → x · (y · z) ≡ (x · y) · z)
(·-lid : (x : A) → 1a · x ≡ x)
(·-ldist-+ : (x y z : A) → (x + y) · z ≡ (x · z) + (y · z))
(·-comm : (x y : A) → x · y ≡ y · x)
(⋆-assoc : (r s : ⟨ R ⟩) (x : A) → (r ·s s) ⋆ x ≡ r ⋆ (s ⋆ x))
(⋆-ldist : (r s : ⟨ R ⟩) (x : A) → (r +r s) ⋆ x ≡ (r ⋆ x) + (s ⋆ x))
(⋆-rdist : (r : ⟨ R ⟩) (x y : A) → r ⋆ (x + y) ≡ (r ⋆ x) + (r ⋆ y))
(⋆-lid : (x : A) → 1r ⋆ x ≡ x)
(⋆-lassoc : (r : ⟨ R ⟩) (x y : A) → (r ⋆ x) · y ≡ r ⋆ (x · y))
→ IsCommAlgebra R 0a 1a _+_ _·_ -_ _⋆_
makeIsCommAlgebra {A} {0a} {1a} {_+_} {_·_} { -_} {_⋆_} isSet-A
+-assoc +-rid +-rinv +-comm
·-assoc ·-lid ·-ldist-+ ·-comm
⋆-assoc ⋆-ldist ⋆-rdist ⋆-lid ⋆-lassoc
= iscommalgebra
(makeIsAlgebra
isSet-A
+-assoc +-rid +-rinv +-comm
·-assoc
(λ x → x · 1a ≡⟨ ·-comm _ _ ⟩ 1a · x ≡⟨ ·-lid _ ⟩ x ∎)
·-lid
(λ x y z → x · (y + z) ≡⟨ ·-comm _ _ ⟩
(y + z) · x ≡⟨ ·-ldist-+ _ _ _ ⟩
(y · x) + (z · x) ≡⟨ cong (λ u → (y · x) + u) (·-comm _ _) ⟩
(y · x) + (x · z) ≡⟨ cong (λ u → u + (x · z)) (·-comm _ _) ⟩
(x · y) + (x · z) ∎)
·-ldist-+
⋆-assoc
⋆-ldist
⋆-rdist
⋆-lid
⋆-lassoc
λ r x y → r ⋆ (x · y) ≡⟨ cong (λ u → r ⋆ u) (·-comm _ _) ⟩
r ⋆ (y · x) ≡⟨ sym (⋆-lassoc _ _ _) ⟩
(r ⋆ y) · x ≡⟨ ·-comm _ _ ⟩
x · (r ⋆ y) ∎)
·-comm
module CommAlgebraΣTheory (R : CommRing {ℓ}) where
open AlgebraΣTheory (CommRing→Ring R)
CommAlgebraAxioms : (A : Type ℓ) (s : RawAlgebraStructure A) → Type ℓ
CommAlgebraAxioms A (_+_ , _·_ , 1a , _⋆_) = AlgebraAxioms A (_+_ , _·_ , 1a , _⋆_)
× ((x y : A) → x · y ≡ y · x)
CommAlgebraStructure : Type ℓ → Type ℓ
CommAlgebraStructure = AxiomsStructure RawAlgebraStructure CommAlgebraAxioms
CommAlgebraΣ : Type (ℓ-suc ℓ)
CommAlgebraΣ = TypeWithStr ℓ CommAlgebraStructure
CommAlgebraEquivStr : StrEquiv CommAlgebraStructure ℓ
CommAlgebraEquivStr = AxiomsEquivStr RawAlgebraEquivStr CommAlgebraAxioms
isPropCommAlgebraAxioms : (A : Type ℓ) (s : RawAlgebraStructure A)
→ isProp (CommAlgebraAxioms A s)
isPropCommAlgebraAxioms A (_+_ , _·_ , 1a , _⋆_) =
isPropΣ (isPropAlgebraAxioms A (_+_ , _·_ , 1a , _⋆_))
λ isAlgebra → isPropΠ2 λ _ _ → (isSetAlgebraΣ (A , _ , isAlgebra)) _ _
CommAlgebra→CommAlgebraΣ : CommAlgebra R → CommAlgebraΣ
CommAlgebra→CommAlgebraΣ (commalgebra _ _ _ _ _ _ _ (iscommalgebra G C)) =
_ , _ , Algebra→AlgebraΣ (algebra _ _ _ _ _ _ _ G) .snd .snd , C
CommAlgebraΣ→CommAlgebra : CommAlgebraΣ → CommAlgebra R
CommAlgebraΣ→CommAlgebra (_ , _ , G , C) =
commalgebra _ _ _ _ _ _ _ (iscommalgebra (AlgebraΣ→Algebra (_ , _ , G) .Algebra.isAlgebra) C)
CommAlgebraIsoCommAlgebraΣ : Iso (CommAlgebra R) CommAlgebraΣ
CommAlgebraIsoCommAlgebraΣ =
iso CommAlgebra→CommAlgebraΣ CommAlgebraΣ→CommAlgebra (λ _ → refl) (λ _ → refl)
commAlgebraUnivalentStr : UnivalentStr CommAlgebraStructure CommAlgebraEquivStr
commAlgebraUnivalentStr = axiomsUnivalentStr _ isPropCommAlgebraAxioms rawAlgebraUnivalentStr
CommAlgebraΣPath : (A B : CommAlgebraΣ) → (A ≃[ CommAlgebraEquivStr ] B) ≃ (A ≡ B)
CommAlgebraΣPath = SIP commAlgebraUnivalentStr
CommAlgebraEquivΣ : (A B : CommAlgebra R) → Type ℓ
CommAlgebraEquivΣ A B = CommAlgebra→CommAlgebraΣ A ≃[ CommAlgebraEquivStr ] CommAlgebra→CommAlgebraΣ B
CommAlgebraPath : (A B : CommAlgebra R) → (CommAlgebraEquiv A B) ≃ (A ≡ B)
CommAlgebraPath A B =
CommAlgebraEquiv A B ≃⟨ strictIsoToEquiv AlgebraEquivΣPath ⟩
CommAlgebraEquivΣ A B ≃⟨ CommAlgebraΣPath _ _ ⟩
CommAlgebra→CommAlgebraΣ A ≡ CommAlgebra→CommAlgebraΣ B
≃⟨ isoToEquiv (invIso (congIso CommAlgebraIsoCommAlgebraΣ)) ⟩
A ≡ B ■
CommAlgebraPath : (R : CommRing {ℓ}) → (A B : CommAlgebra R) → (CommAlgebraEquiv A B) ≃ (A ≡ B)
CommAlgebraPath = CommAlgebraΣTheory.CommAlgebraPath
|
{
"alphanum_fraction": 0.5505157553,
"avg_line_length": 41.1453488372,
"ext": "agda",
"hexsha": "6d4e8ea1675666115fc2c7b2157cb053c5849e9d",
"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": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Edlyr/cubical",
"max_forks_repo_path": "Cubical/Algebra/CommAlgebra/Base.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e",
"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": "Edlyr/cubical",
"max_issues_repo_path": "Cubical/Algebra/CommAlgebra/Base.agda",
"max_line_length": 104,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Edlyr/cubical",
"max_stars_repo_path": "Cubical/Algebra/CommAlgebra/Base.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2736,
"size": 7077
}
|
{-# OPTIONS --without-K --safe #-}
module Data.Binary.Relations where
open import Data.Binary.Relations.Raw
open import Data.Binary.Definitions
open import Data.Binary.Operations.Addition
open import Relation.Binary
open import Relation.Nullary
import Data.Empty.Irrelevant as Irrel
infix 4 _≤_ _<_
record _≤_ (x y : 𝔹) : Set where
constructor ≤!
field
.proof : ⟅ I ⟆ x ≺ y
record _<_ (x y : 𝔹) : Set where
constructor <!
field
.proof : ⟅ O ⟆ x ≺ y
_≤?_ : Decidable _≤_
x ≤? y with I ! x ≺? y
(x ≤? y) | yes x₁ = yes (≤! x₁)
(x ≤? y) | no x₁ = no λ p → Irrel.⊥-elim (x₁ (_≤_.proof p))
_<?_ : Decidable _<_
x <? y with O ! x ≺? y
(x <? y) | yes x₁ = yes (<! x₁)
(x <? y) | no x₁ = no λ p → Irrel.⊥-elim (x₁ (_<_.proof p))
<⇒≤ : ∀ {x y} → x < y → x ≤ y
<⇒≤ {x} {y} x<y = ≤! (weaken x y (_<_.proof x<y))
≤-trans : Transitive _≤_
≤-trans {i} {j} {k} i≤j j≤k = ≤! (≺-trans I I i j k (_≤_.proof i≤j) (_≤_.proof j≤k))
<-trans : Transitive _<_
<-trans {i} {j} {k} i<j j<k = <! (≺-trans O O i j k (_<_.proof i<j) (_<_.proof j<k))
n≤m+n : ∀ x y → x ≤ y + x
n≤m+n x y = ≤! (≺-add y x)
|
{
"alphanum_fraction": 0.5563636364,
"avg_line_length": 25,
"ext": "agda",
"hexsha": "375d93b72f50896e3fa0c28f3b54a6a6dddea18f",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "92af4d620febd47a9791d466d747278dc4a417aa",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/agda-binary",
"max_forks_repo_path": "Data/Binary/Relations.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "92af4d620febd47a9791d466d747278dc4a417aa",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "oisdk/agda-binary",
"max_issues_repo_path": "Data/Binary/Relations.agda",
"max_line_length": 84,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "92af4d620febd47a9791d466d747278dc4a417aa",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/agda-binary",
"max_stars_repo_path": "Data/Binary/Relations.agda",
"max_stars_repo_stars_event_max_datetime": "2019-03-21T21:30:10.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-03-21T21:30:10.000Z",
"num_tokens": 484,
"size": 1100
}
|
module Test where
open import Agda.Builtin.Bool
using (Bool; false; true)
open import Agda.Builtin.Unit
_∧_
: Bool
→ Bool
→ Bool
false ∧ x
= false
_ ∧ y
= y
|
{
"alphanum_fraction": 0.649122807,
"avg_line_length": 11.4,
"ext": "agda",
"hexsha": "61c59a9bb4bd1cce9d1a66976ed7aa15215741d9",
"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/example/Test.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/example/Test.agda",
"max_line_length": 29,
"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/example/Test.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": 61,
"size": 171
}
|
------------------------------------------------------------------------------
-- The gcd program is correct
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
-- This module proves the correctness of the gcd program using
-- the Euclid's algorithm.
-- N.B This module does not contain combined proofs, but it imports
-- modules which contain combined proofs.
module FOTC.Program.GCD.Total.CorrectnessProofATP where
open import FOTC.Base
open import FOTC.Data.Nat.Type
open import FOTC.Program.GCD.Total.CommonDivisorATP using ( gcdCD )
open import FOTC.Program.GCD.Total.Definitions using ( gcdSpec )
open import FOTC.Program.GCD.Total.DivisibleATP using ( gcdDivisible )
open import FOTC.Program.GCD.Total.GCD using ( gcd )
------------------------------------------------------------------------------
-- The gcd is correct.
postulate gcdCorrect : ∀ {m n} → N m → N n → gcdSpec m n (gcd m n)
{-# ATP prove gcdCorrect gcdCD gcdDivisible #-}
|
{
"alphanum_fraction": 0.5587467363,
"avg_line_length": 39.6206896552,
"ext": "agda",
"hexsha": "dc88f5de968228f73873c8ac47c2d53052f680b2",
"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/GCD/Total/CorrectnessProofATP.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/GCD/Total/CorrectnessProofATP.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/GCD/Total/CorrectnessProofATP.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": 232,
"size": 1149
}
|
{-# OPTIONS --without-K #-}
open import Base
module Spaces.Circle where
{-
Idea :
data S¹ : Set where
base : S¹
loop : base ≡ base
I’m using Dan Licata’s trick to have a higher inductive type with definitional
reduction rule for [base]
-}
private
data #S¹ : Set where
#base : #S¹
S¹ : Set
S¹ = #S¹
base : S¹
base = #base
postulate -- HIT
loop : base ≡ base
S¹-rec : ∀ {i} (P : S¹ → Set i) (x : P base) (p : transport P loop x ≡ x)
→ ((t : S¹) → P t)
S¹-rec P x p #base = x
postulate -- HIT
S¹-β-loop : ∀ {i} (P : S¹ → Set i) (x : P base) (p : transport P loop x ≡ x)
→ apd (S¹-rec P x p) loop ≡ p
S¹-rec-nondep : ∀ {i} (A : Set i) (x : A) (p : x ≡ x) → (S¹ → A)
S¹-rec-nondep A x p #base = x
postulate -- HIT
S¹-β-loop-nondep : ∀ {i} (A : Set i) (x : A) (p : x ≡ x)
→ ap (S¹-rec-nondep A x p) loop ≡ p
-- S¹-rec-nondep : ∀ {i} (A : Set i) (x : A) (p : x ≡ x) → (S¹ → A)
-- S¹-rec-nondep A x p = S¹-rec (λ _ → A) x (trans-cst loop x ∘ p)
-- β-nondep : ∀ {i} (A : Set i) (x : A) (p : x ≡ x)
-- → ap (S¹-rec-nondep A x p) loop ≡ p
-- β-nondep A x p =
-- apd-trivial (S¹-rec-nondep A x p) loop ∘
-- (whisker-left (! (trans-cst loop _)) (β (λ _ → A) x (trans-cst loop _ ∘ p))
-- ∘ (! (concat-assoc (! (trans-cst loop _)) (trans-cst loop _) p)
-- ∘ whisker-right p (opposite-left-inverse (trans-cst loop _))))
|
{
"alphanum_fraction": 0.5378398237,
"avg_line_length": 23.8771929825,
"ext": "agda",
"hexsha": "e9b9f19661a92508b41c433b1d8f70ec2168cd09",
"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/Spaces/Circle.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/Spaces/Circle.agda",
"max_line_length": 80,
"max_stars_count": 294,
"max_stars_repo_head_hexsha": "f8fa68bf753d64d7f45556ca09d0da7976709afa",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "UlrikBuchholtz/HoTT-Agda",
"max_stars_repo_path": "old/Spaces/Circle.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": 567,
"size": 1361
}
|
{-# OPTIONS --cubical #-}
module _ where
open import Agda.Builtin.Equality
uip : ∀ {a} {A : Set a} {x y : A} (p q : x ≡ y) → p ≡ q
uip refl refl = refl
|
{
"alphanum_fraction": 0.5714285714,
"avg_line_length": 19.25,
"ext": "agda",
"hexsha": "92c64b5eb39d8b5afeefc6971d7827fa02a0e888",
"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/Issue2790.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/Issue2790.agda",
"max_line_length": 55,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/Issue2790.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": 61,
"size": 154
}
|
{-# OPTIONS --rewriting #-}
-- 2015-02-17 Jesper and Andreas
postulate
A : Set
R : A → A → Set
f : A → A
g : A → A
r : R (f _) (g _)
{-# BUILTIN REWRITE R #-}
{-# REWRITE r #-}
|
{
"alphanum_fraction": 0.4947368421,
"avg_line_length": 13.5714285714,
"ext": "agda",
"hexsha": "f8ac975fa85057d79c95f8c4fdac9f15dc4668e3",
"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/RewriteRuleOpenMeta.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/RewriteRuleOpenMeta.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/Fail/RewriteRuleOpenMeta.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": 73,
"size": 190
}
|
{-# OPTIONS --cubical #-}
module Type.Cubical.Univalence where
open import Function.Axioms
open import Functional
open import Logic.Predicate
open import Logic.Propositional
import Lvl
open import Structure.Function.Domain using (intro ; Inverseₗ ; Inverseᵣ)
open import Structure.Relator.Properties
open import Structure.Type.Identity
open import Type.Cubical.Path.Equality
open import Type.Cubical.Equiv
open import Type.Cubical
open import Type.Properties.MereProposition
open import Type
private variable ℓ ℓ₁ ℓ₂ : Lvl.Level
private variable T A B P Q : Type{ℓ}
-- TODO: Move
primitive primGlue : (A : Type{ℓ₁}) → ∀{i : Interval} → (T : Interval.Partial i (Type{ℓ₂})) → (e : Interval.PartialP i (\o → T(o) ≍ A)) → Type{ℓ₂}
type-extensionalityₗ : (A ≡ B) ← (A ≍ B)
type-extensionalityₗ {A = A}{B = B} ab i = primGlue(B)
(\{(i = Interval.𝟎) → A ; (i = Interval.𝟏) → B})
(\{(i = Interval.𝟎) → ab ; (i = Interval.𝟏) → reflexivity(_≍_)})
module _ ⦃ prop-P : MereProposition{ℓ}(P) ⦄ ⦃ prop-Q : MereProposition{ℓ}(Q) ⦄ where
propositional-extensionalityₗ : (P ≡ Q) ← (P ↔ Q)
propositional-extensionalityₗ pq = type-extensionalityₗ([∃]-intro pq ⦃ intro ⦄) where
instance
l : Inverseₗ([↔]-to-[←] pq)([↔]-to-[→] pq)
Inverseᵣ.proof l = uniqueness(Q)
instance
r : Inverseᵣ([↔]-to-[←] pq)([↔]-to-[→] pq)
Inverseᵣ.proof r = uniqueness(P)
module _ {P Q : T → Type} ⦃ prop-P : ∀{x} → MereProposition{ℓ}(P(x)) ⦄ ⦃ prop-Q : ∀{x} → MereProposition{ℓ}(Q(x)) ⦄ where
prop-set-extensionalityₗ : (P ≡ Q) ← (∀{x} → P(x) ↔ Q(x))
prop-set-extensionalityₗ pq = functionExtensionalityOn P Q (propositional-extensionalityₗ pq)
-- module _ ⦃ uip-P : UniqueIdentityProofs{ℓ}(P) ⦄ ⦃ uip-Q : UniqueIdentityProofs{ℓ}(Q) ⦄ where
-- TODO: Actual proof of univalence
|
{
"alphanum_fraction": 0.6638795987,
"avg_line_length": 37.375,
"ext": "agda",
"hexsha": "ca57d5f222836b680079ce4383e7b08feef47da5",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Type/Cubical/Univalence.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Type/Cubical/Univalence.agda",
"max_line_length": 146,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Type/Cubical/Univalence.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": 657,
"size": 1794
}
|
{-# OPTIONS --without-K #-}
module container.m.from-nat where
open import container.m.from-nat.core public
open import container.m.from-nat.cone public
open import container.m.from-nat.coalgebra public
open import container.m.from-nat.bisimulation public
|
{
"alphanum_fraction": 0.796875,
"avg_line_length": 32,
"ext": "agda",
"hexsha": "3ba0a9db824042f4f9976f6427c74daa0a808860",
"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/m/from-nat.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/m/from-nat.agda",
"max_line_length": 52,
"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/m/from-nat.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": 59,
"size": 256
}
|
------------------------------------------------------------------------------
-- Testing the translation of the logical constants
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module LogicalConstants where
infix 5 ¬_
infixr 4 _∧_
infixr 3 _∨_
infixr 2 _⇒_
infixr 1 _↔_ _⇔_
------------------------------------------------------------------------------
-- Propositional logic
-- The logical constants
-- The logical constants are hard-coded in our implementation,
-- i.e. the following symbols must be used (it is possible to use Agda
-- non-dependent function space → instead of ⇒).
postulate
⊥ ⊤ : Set -- N.B. the name of the tautology symbol is "\top" not T.
¬_ : Set → Set -- N.B. the right hole.
_∧_ _∨_ : Set → Set → Set
_⇒_ _↔_ _⇔_ : Set → Set → Set
-- We postulate some formulae (which are translated as 0-ary
-- predicates).
postulate A B C : Set
-- Testing the conditional using the non-dependent function type.
postulate A→A : A → A
{-# ATP prove A→A #-}
-- Testing the conditional using the hard-coded function type.
postulate A⇒A : A ⇒ A
{-# ATP prove A⇒A #-}
-- The introduction and elimination rules for the propositional
-- connectives are theorems.
postulate
→I : (A → B) → A ⇒ B
→E : (A ⇒ B) → A → B
∧I : A → B → A ∧ B
∧E₁ : A ∧ B → A
∧E₂ : A ∧ B → B
∨I₁ : A → A ∨ B
∨I₂ : B → A ∨ B
∨E : (A ⇒ C) → (B ⇒ C) → A ∨ B → C
⊥E : ⊥ → A
¬E : (¬ A → ⊥) → A
{-# ATP prove →I #-}
{-# ATP prove →E #-}
{-# ATP prove ∧I #-}
{-# ATP prove ∧E₁ #-}
{-# ATP prove ∧E₂ #-}
{-# ATP prove ∨I₁ #-}
{-# ATP prove ∨I₂ #-}
{-# ATP prove ∨E #-}
{-# ATP prove ⊥E #-}
{-# ATP prove ¬E #-}
-- Testing other logical constants.
postulate
thm₁ : A ∧ ⊤ → A
thm₂ : A ∨ ⊥ → A
thm₃ : A ↔ A
thm₄ : A ⇔ A
{-# ATP prove thm₁ #-}
{-# ATP prove thm₂ #-}
{-# ATP prove thm₃ #-}
{-# ATP prove thm₄ #-}
------------------------------------------------------------------------------
-- Predicate logic
--- The universe of discourse.
postulate D : Set
-- The propositional equality is hard-coded in our implementation, i.e. the
-- following symbol must be used.
postulate _≡_ : D → D → Set
-- Testing propositional equality.
postulate refl : ∀ {x} → x ≡ x
{-# ATP prove refl #-}
-- The quantifiers are hard-coded in our implementation, i.e. the
-- following symbols must be used (it is possible to use Agda
-- dependent function space ∀ x → A instead of ⋀).
postulate
∃ : (A : D → Set) → Set
⋀ : (A : D → Set) → Set
-- We postulate some formulae and propositional functions.
postulate
A¹ B¹ : D → Set
A² : D → D → Set
-- The introduction and elimination rules for the quantifiers are
-- theorems.
postulate
∀I₁ : ((x : D) → A¹ x) → ⋀ A¹
∀I₂ : ((x : D) → A¹ x) → ∀ x → A¹ x
∀E₁ : (t : D) → ⋀ A¹ → A¹ t
∀E₂ : (t : D) → (∀ x → A¹ x) → A¹ t
{-# ATP prove ∀I₁ #-}
{-# ATP prove ∀I₂ #-}
{-# ATP prove ∀E₁ #-}
{-# ATP prove ∀E₂ #-}
postulate ∃I : (t : D) → A¹ t → ∃ A¹
{-# ATP prove ∃I #-}
postulate ∃E : ∃ A¹ → ((x : D) → A¹ x → A) → A
{-# ATP prove ∃E #-}
|
{
"alphanum_fraction": 0.513463324,
"avg_line_length": 26.4836065574,
"ext": "agda",
"hexsha": "9e0ddda3d912656679c8eb2cdbc4268765e6e109",
"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/Succeed/fol-theorems/LogicalConstants.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/Succeed/fol-theorems/LogicalConstants.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/Succeed/fol-theorems/LogicalConstants.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": 1032,
"size": 3231
}
|
-- Basic intuitionistic modal logic S4, without ∨, ⊥, or ◇.
-- Tarski-style semantics with contexts as concrete worlds, and glueing for α, ▻, and □.
-- Implicit syntax.
module BasicIS4.Semantics.TarskiOvergluedImplicit where
open import BasicIS4.Syntax.Common public
open import Common.Semantics public
-- Intuitionistic Tarski models.
record Model : Set₁ where
infix 3 _⊩ᵅ_
field
-- Forcing for atomic propositions; monotonic.
_⊩ᵅ_ : Cx Ty → Atom → Set
mono⊩ᵅ : ∀ {P Γ Γ′} → Γ ⊆ Γ′ → Γ ⊩ᵅ P → Γ′ ⊩ᵅ P
open Model {{…}} public
module ImplicitSyntax
(_[⊢]_ : Cx Ty → Ty → Set)
(mono[⊢] : ∀ {A Γ Γ′} → Γ ⊆ Γ′ → Γ [⊢] A → Γ′ [⊢] A)
where
-- Forcing in a particular model.
module _ {{_ : Model}} where
infix 3 _⊩_
_⊩_ : Cx Ty → Ty → Set
Γ ⊩ α P = Glue (Γ [⊢] (α P)) (Γ ⊩ᵅ P)
Γ ⊩ A ▻ B = ∀ {Γ′} → Γ ⊆ Γ′ → Glue (Γ′ [⊢] (A ▻ B)) (Γ′ ⊩ A → Γ′ ⊩ B)
Γ ⊩ □ A = ∀ {Γ′} → Γ ⊆ Γ′ → Glue (Γ′ [⊢] (□ A)) (Γ′ ⊩ A)
Γ ⊩ A ∧ B = Γ ⊩ A × Γ ⊩ B
Γ ⊩ ⊤ = 𝟙
infix 3 _⊩⋆_
_⊩⋆_ : Cx Ty → Cx Ty → Set
Γ ⊩⋆ ∅ = 𝟙
Γ ⊩⋆ Ξ , A = Γ ⊩⋆ Ξ × Γ ⊩ A
-- Monotonicity with respect to context inclusion.
module _ {{_ : Model}} where
mono⊩ : ∀ {A Γ Γ′} → Γ ⊆ Γ′ → Γ ⊩ A → Γ′ ⊩ A
mono⊩ {α P} η s = mono[⊢] η (syn s) ⅋ mono⊩ᵅ η (sem s)
mono⊩ {A ▻ B} η s = λ η′ → s (trans⊆ η η′)
mono⊩ {□ A} η s = λ η′ → s (trans⊆ η η′)
mono⊩ {A ∧ B} η s = mono⊩ {A} η (π₁ s) , mono⊩ {B} η (π₂ s)
mono⊩ {⊤} η s = ∙
mono⊩⋆ : ∀ {Ξ Γ Γ′} → Γ ⊆ Γ′ → Γ ⊩⋆ Ξ → Γ′ ⊩⋆ Ξ
mono⊩⋆ {∅} η ∙ = ∙
mono⊩⋆ {Ξ , A} η (ts , t) = mono⊩⋆ {Ξ} η ts , mono⊩ {A} η t
-- Additional useful equipment.
module _ {{_ : Model}} where
_⟪$⟫_ : ∀ {A B Γ} → Γ ⊩ A ▻ B → Γ ⊩ A → Γ ⊩ B
s ⟪$⟫ a = sem (s refl⊆) a
⟪S⟫ : ∀ {A B C Γ} → Γ ⊩ A ▻ B ▻ C → Γ ⊩ A ▻ B → Γ ⊩ A → Γ ⊩ C
⟪S⟫ s₁ s₂ a = (s₁ ⟪$⟫ a) ⟪$⟫ (s₂ ⟪$⟫ a)
⟪↓⟫ : ∀ {A Γ} → Γ ⊩ □ A → Γ ⊩ A
⟪↓⟫ s = sem (s refl⊆)
-- Forcing in a particular world of a particular model, for sequents.
module _ {{_ : Model}} where
infix 3 _⊩_⇒_
_⊩_⇒_ : Cx Ty → Cx Ty → Ty → Set
w ⊩ Γ ⇒ A = w ⊩⋆ Γ → w ⊩ A
infix 3 _⊩_⇒⋆_
_⊩_⇒⋆_ : Cx Ty → Cx Ty → Cx Ty → Set
w ⊩ Γ ⇒⋆ Ξ = w ⊩⋆ Γ → w ⊩⋆ Ξ
-- Entailment, or forcing in all worlds of all models, for sequents.
infix 3 _⊨_
_⊨_ : Cx Ty → Ty → Set₁
Γ ⊨ A = ∀ {{_ : Model}} {w : Cx Ty} → w ⊩ Γ ⇒ A
infix 3 _⊨⋆_
_⊨⋆_ : Cx Ty → Cx Ty → Set₁
Γ ⊨⋆ Ξ = ∀ {{_ : Model}} {w : Cx Ty} → w ⊩ Γ ⇒⋆ Ξ
-- Additional useful equipment, for sequents.
module _ {{_ : Model}} where
lookup : ∀ {A Γ w} → A ∈ Γ → w ⊩ Γ ⇒ A
lookup top (γ , a) = a
lookup (pop i) (γ , b) = lookup i γ
_⟦$⟧_ : ∀ {A B Γ w} → w ⊩ Γ ⇒ A ▻ B → w ⊩ Γ ⇒ A → w ⊩ Γ ⇒ B
(s₁ ⟦$⟧ s₂) γ = s₁ γ ⟪$⟫ s₂ γ
⟦S⟧ : ∀ {A B C Γ w} → w ⊩ Γ ⇒ A ▻ B ▻ C → w ⊩ Γ ⇒ A ▻ B → w ⊩ Γ ⇒ A → w ⊩ Γ ⇒ C
⟦S⟧ s₁ s₂ a γ = ⟪S⟫ (s₁ γ) (s₂ γ) (a γ)
⟦↓⟧ : ∀ {A Γ w} → w ⊩ Γ ⇒ □ A → w ⊩ Γ ⇒ A
⟦↓⟧ s γ = ⟪↓⟫ (s γ)
_⟦,⟧_ : ∀ {A B Γ w} → w ⊩ Γ ⇒ A → w ⊩ Γ ⇒ B → w ⊩ Γ ⇒ A ∧ B
(a ⟦,⟧ b) γ = a γ , b γ
⟦π₁⟧ : ∀ {A B Γ w} → w ⊩ Γ ⇒ A ∧ B → w ⊩ Γ ⇒ A
⟦π₁⟧ s γ = π₁ (s γ)
⟦π₂⟧ : ∀ {A B Γ w} → w ⊩ Γ ⇒ A ∧ B → w ⊩ Γ ⇒ B
⟦π₂⟧ s γ = π₂ (s γ)
|
{
"alphanum_fraction": 0.4287469287,
"avg_line_length": 26.4715447154,
"ext": "agda",
"hexsha": "e929c40c0376d11c1902cef3f9c761a1038b2bbb",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_forks_repo_licenses": [
"X11"
],
"max_forks_repo_name": "mietek/hilbert-gentzen",
"max_forks_repo_path": "BasicIS4/Semantics/TarskiOvergluedImplicit.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_issues_repo_issues_event_max_datetime": "2018-06-10T09:11:22.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-06-10T09:11:22.000Z",
"max_issues_repo_licenses": [
"X11"
],
"max_issues_repo_name": "mietek/hilbert-gentzen",
"max_issues_repo_path": "BasicIS4/Semantics/TarskiOvergluedImplicit.agda",
"max_line_length": 88,
"max_stars_count": 29,
"max_stars_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_stars_repo_licenses": [
"X11"
],
"max_stars_repo_name": "mietek/hilbert-gentzen",
"max_stars_repo_path": "BasicIS4/Semantics/TarskiOvergluedImplicit.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-01T10:29:18.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-07-03T18:51:56.000Z",
"num_tokens": 1777,
"size": 3256
}
|
module lib-safe where
open import datatypes-safe public
open import logic public
open import thms public
open import termination public
open import error public
|
{
"alphanum_fraction": 0.8343558282,
"avg_line_length": 18.1111111111,
"ext": "agda",
"hexsha": "cbf14dd6a5fdd5c42b09974423fe85c9fc8027b6",
"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": "lib-safe.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": "lib-safe.agda",
"max_line_length": 33,
"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": "lib-safe.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": 33,
"size": 163
}
|
------------------------------------------------------------------------------
-- Conversion rules for the Collatz function
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOT.FOTC.Program.Collatz.ConversionRulesI where
open import Common.FOL.Relation.Binary.EqReasoning
open import FOT.FOTC.Program.Collatz.CollatzConditionals
open import FOTC.Base
open import FOTC.Data.Nat
open import FOTC.Data.Nat.UnaryNumbers
open import FOTC.Program.Collatz.Data.Nat
------------------------------------------------------------------------------
private
-- The steps
-- Initially, the equation collatz-eq is used.
collatz-s₁ : D → D
collatz-s₁ n = if (iszero₁ n)
then 1'
else (if (iszero₁ (pred₁ n))
then 1'
else (if (even n)
then collatz (div n 2')
else collatz (3' * n + 1')))
-- First if_then_else_ iszero₁ n = b.
collatz-s₂ : D → D → D
collatz-s₂ n b = if b
then 1'
else (if (iszero₁ (pred₁ n))
then 1'
else (if (even n)
then collatz (div n 2')
else collatz (3' * n + 1')))
-- First if_then_else_ when if true ....
collatz-s₃ : D → D
collatz-s₃ n = 1'
-- First if_then_else_ when if false ....
collatz-s₄ : D → D
collatz-s₄ n = if (iszero₁ (pred₁ n))
then 1'
else (if (even n)
then collatz (div n 2')
else collatz (3' * n + 1'))
-- Second if_then_else_ iszero₁ (pred₁ n) = b.
collatz-s₅ : D → D → D
collatz-s₅ n b = if b
then 1'
else (if (even n)
then collatz (div n 2')
else collatz (3' * n + 1'))
-- Second if_then_else_ when if true ....
collatz-s₆ : D → D
collatz-s₆ n = 1'
-- Second if_then_else_ when if false ....
collatz-s₇ : D → D
collatz-s₇ n = if (even n) then collatz (div n 2') else collatz (3' * n + 1')
-- Third if_then_else_ even n b.
collatz-s₈ : D → D → D
collatz-s₈ n b = if b then collatz (div n 2') else collatz (3' * n + 1')
-- Third if_then_else_ when if true ....
collatz-s₉ : D → D
collatz-s₉ n = collatz (div n 2')
-- Third if_then_else_ when if false ....
collatz-s₁₀ : D → D
collatz-s₁₀ n = collatz (3' * n + 1')
----------------------------------------------------------------------------
-- The execution steps
proof₀₋₁ : ∀ n → collatz n ≡ collatz-s₁ n
proof₀₋₁ n = collatz-eq n
proof₁₋₂ : ∀ {n b} → iszero₁ n ≡ b → collatz-s₁ n ≡ collatz-s₂ n b
proof₁₋₂ {n} {b} h = subst (λ x → collatz-s₂ n x ≡ collatz-s₂ n b)
(sym h)
refl
proof₂₋₃ : ∀ n → collatz-s₂ n true ≡ collatz-s₃ n
proof₂₋₃ n = if-true (collatz-s₃ n)
proof₂₋₄ : ∀ n → collatz-s₂ n false ≡ collatz-s₄ n
proof₂₋₄ n = if-false (collatz-s₄ n)
proof₄₋₅ : ∀ {n b} → iszero₁ (pred₁ n) ≡ b → collatz-s₄ n ≡ collatz-s₅ n b
proof₄₋₅ {n} {b} h = subst (λ x → collatz-s₅ n x ≡ collatz-s₅ n b)
(sym h)
refl
proof₅₋₆ : ∀ n → collatz-s₅ n true ≡ collatz-s₆ n
proof₅₋₆ n = if-true (collatz-s₆ n)
proof₅₋₇ : ∀ n → collatz-s₅ n false ≡ collatz-s₇ n
proof₅₋₇ n = if-false (collatz-s₇ n)
proof₇₋₈ : ∀ {n b} → even n ≡ b → collatz-s₇ n ≡ collatz-s₈ n b
proof₇₋₈ {n} {b} h = subst (λ x → collatz-s₈ n x ≡ collatz-s₈ n b)
(sym h)
refl
proof₈₋₉ : ∀ n → collatz-s₈ n true ≡ collatz-s₉ n
proof₈₋₉ n = if-true (collatz-s₉ n)
proof₈₋₁₀ : ∀ n → collatz-s₈ n false ≡ collatz-s₁₀ n
proof₈₋₁₀ n = if-false (collatz-s₁₀ n)
------------------------------------------------------------------------------
-- Conversion rules for the Collatz function
collatz-0 : collatz zero ≡ 1'
collatz-0 =
collatz zero ≡⟨ proof₀₋₁ zero ⟩
collatz-s₁ zero ≡⟨ proof₁₋₂ iszero-0 ⟩
collatz-s₂ zero true ≡⟨ proof₂₋₃ zero ⟩
1' ∎
collatz-1 : collatz 1' ≡ 1'
collatz-1 =
collatz 1'
≡⟨ proof₀₋₁ 1' ⟩
collatz-s₁ 1'
≡⟨ proof₁₋₂ (iszero-S zero) ⟩
collatz-s₂ 1' false
≡⟨ proof₂₋₄ 1' ⟩
collatz-s₄ 1'
≡⟨ proof₄₋₅ (subst (λ x → iszero₁ x ≡ true) (sym (pred-S zero)) iszero-0) ⟩
collatz-s₅ 1' true
≡⟨ proof₅₋₆ 1' ⟩
1' ∎
collatz-even : ∀ {n} → Even (succ₁ (succ₁ n)) →
collatz (succ₁ (succ₁ n)) ≡ collatz (div (succ₁ (succ₁ n)) 2')
collatz-even {n} h =
collatz (succ₁ (succ₁ n))
≡⟨ proof₀₋₁ (succ₁ (succ₁ n)) ⟩
collatz-s₁ (succ₁ (succ₁ n))
≡⟨ proof₁₋₂ (iszero-S (succ₁ n)) ⟩
collatz-s₂ (succ₁ (succ₁ n)) false
≡⟨ proof₂₋₄ (succ₁ (succ₁ n)) ⟩
collatz-s₄ (succ₁ (succ₁ n))
≡⟨ proof₄₋₅ (subst (λ x → iszero₁ x ≡ false)
(sym (pred-S (succ₁ n)))
(iszero-S n))
⟩
collatz-s₅ (succ₁ (succ₁ n)) false
≡⟨ proof₅₋₇ (succ₁ (succ₁ n)) ⟩
collatz-s₇ (succ₁ (succ₁ n))
≡⟨ proof₇₋₈ h ⟩
collatz-s₈ (succ₁ (succ₁ n)) true
≡⟨ proof₈₋₉ (succ₁ (succ₁ n)) ⟩
collatz (div (succ₁ (succ₁ n)) 2') ∎
collatz-noteven : ∀ {n} → NotEven (succ₁ (succ₁ n)) →
collatz (succ₁ (succ₁ n)) ≡
collatz (3' * (succ₁ (succ₁ n)) + 1')
collatz-noteven {n} h =
collatz (succ₁ (succ₁ n))
≡⟨ proof₀₋₁ (succ₁ (succ₁ n)) ⟩
collatz-s₁ (succ₁ (succ₁ n))
≡⟨ proof₁₋₂ (iszero-S (succ₁ n)) ⟩
collatz-s₂ (succ₁ (succ₁ n)) false
≡⟨ proof₂₋₄ (succ₁ (succ₁ n)) ⟩
collatz-s₄ (succ₁ (succ₁ n))
≡⟨ proof₄₋₅ (subst (λ x → iszero₁ x ≡ false)
(sym (pred-S (succ₁ n)))
(iszero-S n))
⟩
collatz-s₅ (succ₁ (succ₁ n)) false
≡⟨ proof₅₋₇ (succ₁ (succ₁ n)) ⟩
collatz-s₇ (succ₁ (succ₁ n))
≡⟨ proof₇₋₈ h ⟩
collatz-s₈ (succ₁ (succ₁ n)) false
≡⟨ proof₈₋₁₀ (succ₁ (succ₁ n)) ⟩
collatz (3' * (succ₁ (succ₁ n)) + 1') ∎
|
{
"alphanum_fraction": 0.4810066477,
"avg_line_length": 32.5670103093,
"ext": "agda",
"hexsha": "6223cca23d2277e7a9d2272d2a8f300e5117ff60",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z",
"max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/fotc",
"max_forks_repo_path": "notes/FOT/FOTC/Program/Collatz/ConversionRulesI.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/fotc",
"max_issues_repo_path": "notes/FOT/FOTC/Program/Collatz/ConversionRulesI.agda",
"max_line_length": 79,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "notes/FOT/FOTC/Program/Collatz/ConversionRulesI.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": 2315,
"size": 6318
}
|
-- An ATP-pragma must appear in the same module where its argument is
-- defined.
-- This error is detected by TypeChecking.Monad.Signature.
module ATPImports where
open import Imports.ATP-A
{-# ATP axiom p #-}
postulate foo : a ≡ b
{-# ATP prove foo #-}
|
{
"alphanum_fraction": 0.7076923077,
"avg_line_length": 18.5714285714,
"ext": "agda",
"hexsha": "b224cb1882ae5d92b57ef291cbf068f5bdeeeb66",
"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": "7220bebfe9f64297880ecec40314c0090018fdd0",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "asr/eagda",
"max_forks_repo_path": "test/fail/ATPImports.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0",
"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": "asr/eagda",
"max_issues_repo_path": "test/fail/ATPImports.agda",
"max_line_length": 69,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "asr/eagda",
"max_stars_repo_path": "test/fail/ATPImports.agda",
"max_stars_repo_stars_event_max_datetime": "2016-03-17T01:45:59.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-03-17T01:45:59.000Z",
"num_tokens": 63,
"size": 260
}
|
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
import homotopy.ConstantToSetExtendsToProp as ConstExt
open import homotopy.Pigeonhole
module homotopy.FinSet where
-- the explicit type of finite sets, carrying the cardinality on its sleeve
FinSet-exp : Type₁
FinSet-exp = Σ ℕ λ n → BAut (Fin n)
FinSet-prop : SubtypeProp Type₀ (lsucc lzero)
FinSet-prop = (λ A → Trunc -1 (Σ ℕ λ n → Fin n == A)) , λ A → Trunc-level
-- the implicit type of finite sets, hiding the cardinality in prop. trunc.
FinSet : Type₁
FinSet = Subtype FinSet-prop
FinSet= : {A B : FinSet} → fst A == fst B → A == B
FinSet= = Subtype=-out FinSet-prop
FinFS : ℕ → FinSet
FinFS n = Fin n , [ n , idp ]
UnitFS : FinSet
UnitFS = ⊤ , [ S O , ua Fin-equiv-Coprod ∙ ap (λ C → C ⊔ ⊤) (ua Fin-equiv-Empty)
∙ ua (Coprod-unit-l ⊤) ]
Fin-inj-lemma : {n m : ℕ} → n < m → Fin m == Fin n → ⊥
Fin-inj-lemma {n} {m} n<m p = i≠j (<– (ap-equiv (coe-equiv p) i j) q)
where
i : Fin m
i = fst (pigeonhole n<m (coe p))
j : Fin m
j = fst (snd (pigeonhole n<m (coe p)))
i≠j : i ≠ j
i≠j = fst (snd (snd (pigeonhole n<m (coe p))))
q : coe p i == coe p j
q = snd (snd (snd (pigeonhole n<m (coe p))))
Fin-inj : (n m : ℕ) → Fin n == Fin m → n == m
Fin-inj n m p with ℕ-trichotomy n m
Fin-inj n m p | inl q = q
Fin-inj n m p | inr (inl q) = ⊥-rec (Fin-inj-lemma q (! p))
Fin-inj n m p | inr (inr q) = ⊥-rec (Fin-inj-lemma q p)
FinSet-aux-prop : (A : Type₀) → SubtypeProp ℕ (lsucc lzero)
FinSet-aux-prop A = (λ n → Trunc -1 (Fin n == A)) , (λ n → Trunc-level)
FinSet-aux : (A : FinSet) → Subtype (FinSet-aux-prop (fst A))
FinSet-aux (A , tz) = CE.ext tz
where
to : (Σ ℕ λ n → Fin n == A) → Subtype (FinSet-aux-prop A)
to (n , p) = n , [ p ]
to-const : (z₁ z₂ : Σ ℕ λ n → Fin n == A) → to z₁ == to z₂
to-const (n₁ , p₁) (n₂ , p₂) = Subtype=-out (FinSet-aux-prop A) (Fin-inj n₁ n₂ (p₁ ∙ ! p₂))
module CE =
ConstExt ⦃ Subtype-level (FinSet-aux-prop A) ⦄ to to-const
card : FinSet → ℕ
card A = fst (FinSet-aux A)
card-conv : (A : FinSet) (n : ℕ) → Trunc -1 (Fin n == fst A) → card A == n
card-conv (A , tz) n = Trunc-rec λ p → ap card (FinSet= {A , tz} {FinFS n} (! p))
FinSet-econv : FinSet-exp ≃ FinSet
FinSet-econv = equiv to from to-from from-to
where
to : FinSet-exp → FinSet
to (n , A , tp) = A , Trunc-rec (λ p → [ n , p ]) tp
from : FinSet → FinSet-exp
from A = card A , fst A , snd (FinSet-aux A)
to-from : (A : FinSet) → to (from A) == A
to-from A = pair= idp (prop-has-all-paths (snd (to (from A))) (snd A))
from-to : (A : FinSet-exp) → from (to A) == A
from-to A = pair= (card-conv (to A) (fst A) (snd (snd A)))
(↓-Subtype-in (λ n → BAut-prop (Fin n)) (↓-cst-in idp))
FinSet-elim-prop : ∀ {j} {P : FinSet → Type j} (p : (A : FinSet) → has-level -1 (P A))
(d : (n : ℕ) → P (FinFS n)) → (A : FinSet) → P A
FinSet-elim-prop {j} {P} p d (A , tz) = Trunc-elim ⦃ λ tw → p (A , tw) ⦄
(λ {(n , p) → transport P (FinSet= p) (d n)}) tz
finset-has-dec-eq : (A : FinSet) → has-dec-eq (fst A)
finset-has-dec-eq = FinSet-elim-prop (λ A → has-dec-eq-is-prop) λ n → Fin-has-dec-eq
-- todo: closure of FinSet under product, coproduct, exponential, etc.
|
{
"alphanum_fraction": 0.5671870217,
"avg_line_length": 33.6804123711,
"ext": "agda",
"hexsha": "a6f8537070ca262226d45984add1084ad24ee99f",
"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/FinSet.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/FinSet.agda",
"max_line_length": 95,
"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/FinSet.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": 1295,
"size": 3267
}
|
{-# OPTIONS --sized-types #-}
module SList (A : Set) where
open import Data.List
open import Data.Product
open import Size
data SList : {ι : Size} → Set where
snil : {ι : Size}
→ SList {↑ ι}
_∙_ : {ι : Size}(x : A)
→ SList {ι}
→ SList {↑ ι}
size : List A → SList
size [] = snil
size (x ∷ xs) = x ∙ (size xs)
unsize : {ι : Size} → SList {ι} → List A
unsize snil = []
unsize (x ∙ xs) = x ∷ unsize xs
unsize× : {ι : Size} → SList {ι} × SList {ι} → List A × List A
unsize× (xs , ys) = unsize xs , unsize ys
_⊕_ : SList → SList → SList
snil ⊕ ys = ys
(x ∙ xs) ⊕ ys = x ∙ (xs ⊕ ys)
|
{
"alphanum_fraction": 0.5030674847,
"avg_line_length": 19.1764705882,
"ext": "agda",
"hexsha": "41588a5bffde149ad0542e727c9d969d97746c5c",
"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/SList.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/SList.agda",
"max_line_length": 62,
"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/SList.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": 252,
"size": 652
}
|
{-# OPTIONS --safe #-}
module Cubical.Algebra.AbGroup.Instances.NProd where
open import Cubical.Foundations.Prelude
open import Cubical.Data.Nat using (ℕ)
open import Cubical.Algebra.Group
open import Cubical.Algebra.Group.Instances.NProd
open import Cubical.Algebra.AbGroup
private variable
ℓ : Level
open AbGroupStr
NProd-AbGroup : (G : (n : ℕ) → Type ℓ) → (Gstr : (n : ℕ) → AbGroupStr (G n)) → AbGroup ℓ
NProd-AbGroup G Gstr = Group→AbGroup (NProd-Group G (λ n → AbGroupStr→GroupStr (Gstr n)))
λ f g → funExt λ n → +Comm (Gstr n) _ _
|
{
"alphanum_fraction": 0.6740994854,
"avg_line_length": 29.15,
"ext": "agda",
"hexsha": "02c0cdf924c993303c99e982846557b3b2451b55",
"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/NProd.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/NProd.agda",
"max_line_length": 89,
"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/NProd.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 179,
"size": 583
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.