{"text": "module L where\n\nopen import Data.Nat using (ℕ; suc) -- ; _*_)\nopen import Relation.Binary.PropositionalEquality using (_≡_; refl; cong; sym; trans)\nopen import Data.Product\nopen import Data.Empty\n\n-- Recursion principle\n\nrecℕ : (C : Set) → C → (ℕ → C → C) → ℕ → C\nrecℕ C c f 0 = c\nrecℕ C c f (suc n) = f n (recℕ C c f n)\n\ndouble : ℕ → ℕ\ndouble = recℕ ℕ 0 (λ n r → suc (suc r))\n\nadd : ℕ → ℕ → ℕ\nadd = recℕ (ℕ → ℕ) (λ n → n) (λ m r → λ n → suc (r n))\n\n-- fact : ℕ → ℕ\n-- fact = recℕ ℕ 1 (λ n r → suc n * r)\n\n-- Induction principle\n\nindℕ : (C : ℕ → Set) → C 0 → ((n : ℕ) → C n → C (suc n)) → (n : ℕ) → C n\nindℕ C c f 0 = c\nindℕ C c f (suc n) = f n (indℕ C c f n)\n\nadd-assoc : (i j k : ℕ) → add i (add j k) ≡ add (add i j) k\nadd-assoc = indℕ\n (λ i → (j k : ℕ) → add i (add j k) ≡ add (add i j) k)\n (λ j k → refl)\n (λ i i+[j+k]≡[i+j]+k j k → cong suc (i+[j+k]≡[i+j]+k j k))\n\nadd-right-unit : (i : ℕ) → add i 0 ≡ i\nadd-right-unit = indℕ (λ i → add i 0 ≡ i) refl (λ i i+0≡i → cong suc i+0≡i) \n\nadd-suc : (i j : ℕ) → suc (add i j) ≡ add i (suc j)\nadd-suc = indℕ (λ i → (j : ℕ) → suc (add i j) ≡ add i (suc j))\n (λ j → refl)\n (λ i s[i+j]≡i+s[j] j → cong suc (s[i+j]≡i+s[j] j))\n\nadd-comm : (i j : ℕ) → add i j ≡ add j i\nadd-comm = indℕ\n (λ i → (j : ℕ) → add i j ≡ add j i)\n (λ j → sym (add-right-unit j))\n (λ i i+j≡j+i j → trans (cong suc (i+j≡j+i j)) (add-suc j i))\n\n-- Some type definitions\n\n_≤_ : (i j : ℕ) → Set\ni ≤ j = Σ[ k ∈ ℕ ] (add i k ≡ j)\n\ni≤i+j : (i j : ℕ) → i ≤ add i j\ni≤i+j = indℕ\n (λ i → (j : ℕ) → i ≤ add i j)\n (λ j → (j , refl))\n (λ i i≤i+j j → (j , refl))\n\n¬ : Set → Set\n¬ A = A → ⊥\n\n_<_ : (i j : ℕ) → Set\ni < j = (i ≤ j) × ¬ (i ≡ j)\n\n0≠si : (i : ℕ) → ¬ (0 ≡ suc i)\n0≠si i = λ ()\n\n0< : (i : ℕ) → (0 < suc i)\n0< = indℕ (λ i → 0 < suc i)\n {!!}\n {!!}\n \n", "meta": {"hexsha": "765fbf2afa4edf6d542731ec0082d2f1b1c68024", "size": 1919, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "L.agda", "max_stars_repo_name": "andmkent/misc-HoTT", "max_stars_repo_head_hexsha": "b05c58ffdaed99932ca2acc632deca8d14742b04", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-01-26T18:17:16.000Z", "max_stars_repo_stars_event_max_datetime": "2016-01-26T18:17:16.000Z", "max_issues_repo_path": "L.agda", "max_issues_repo_name": "andmkent/misc-HoTT", "max_issues_repo_head_hexsha": "b05c58ffdaed99932ca2acc632deca8d14742b04", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "L.agda", "max_forks_repo_name": "andmkent/misc-HoTT", "max_forks_repo_head_hexsha": "b05c58ffdaed99932ca2acc632deca8d14742b04", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.9324324324, "max_line_length": 85, "alphanum_fraction": 0.440333507, "num_tokens": 860, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9343951570602081, "lm_q2_score": 0.8558511506439707, "lm_q1q2_score": 0.7997031703261328}} {"text": "module Nat where\n\ndata ℕ : Set where\n zero : ℕ\n succ : ℕ → ℕ\n\n{-# BUILTIN NATURAL ℕ #-}\n\n_+_ : ℕ → ℕ → ℕ\nzero + b = b\nsucc a + b = succ (a + b)\n\n_×_ : ℕ → ℕ → ℕ\nzero × b = zero\nsucc a × b = (a × b) + b\n\n\nopen import Relation.Binary.PropositionalEquality\n\n0-is-right-identity-of-+ : ∀ (n : ℕ) → n + zero ≡ n\n0-is-right-identity-of-+ zero = refl\n0-is-right-identity-of-+ (succ n) = cong succ (0-is-right-identity-of-+ n)\n\n\n+-is-associative : ∀ (a b c : ℕ) → a + (b + c) ≡ (a + b) + c\n+-is-associative zero b c = refl\n+-is-associative (succ a) b c = cong succ (+-is-associative a b c)\n\n\nlemma : ∀ (a b : ℕ) → a + succ b ≡ succ (a + b)\nlemma zero b = refl\nlemma (succ a) b = cong succ (lemma a b)\n\nimport Relation.Binary.EqReasoning as EqR\nopen module EqNat = EqR (setoid ℕ)\n\n+-is-commutative : ∀ (a b : ℕ) → a + b ≡ b + a\n+-is-commutative a zero = 0-is-right-identity-of-+ a\n+-is-commutative a (succ b) =\n begin\n a + succ b\n ≈⟨ lemma a b ⟩\n succ (a + b)\n ≈⟨ cong succ (+-is-commutative a b) ⟩\n succ (b + a)\n ≈⟨ refl ⟩\n succ b + a\n ∎\n", "meta": {"hexsha": "ab6f04098af1d31543d938d560e00e478f519fe8", "size": 1081, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Nat.agda", "max_stars_repo_name": "piyush-kurur/sample-code", "max_stars_repo_head_hexsha": "1062c0b81f8dbb664fcc9376ba13695f0ee7ebc8", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2017-06-19T12:34:08.000Z", "max_stars_repo_stars_event_max_datetime": "2017-06-20T02:19:33.000Z", "max_issues_repo_path": "agda/Nat.agda", "max_issues_repo_name": "piyush-kurur/sample-code", "max_issues_repo_head_hexsha": "1062c0b81f8dbb664fcc9376ba13695f0ee7ebc8", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2017-11-01T05:48:28.000Z", "max_issues_repo_issues_event_max_datetime": "2017-11-01T05:48:28.000Z", "max_forks_repo_path": "agda/Nat.agda", "max_forks_repo_name": "piyush-kurur/sample-code", "max_forks_repo_head_hexsha": "1062c0b81f8dbb664fcc9376ba13695f0ee7ebc8", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.0612244898, "max_line_length": 74, "alphanum_fraction": 0.5513413506, "num_tokens": 417, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9643214511730025, "lm_q2_score": 0.8289388040954683, "lm_q1q2_score": 0.7993634704989552}} {"text": "\nmodule Logic.Identity where\n\nopen import Logic.Equivalence\nopen import Logic.Base\n\ninfix 20 _≡_ _≢_\n\ndata _≡_ {A : Set}(x : A) : A -> Set where\n refl : x ≡ x\n\nsubst : {A : Set}(P : A -> Set){x y : A} -> x ≡ y -> P y -> P x\nsubst P {x} .{x} refl px = px\n\nsym : {A : Set}{x y : A} -> x ≡ y -> y ≡ x\nsym {A} refl = refl\n\ntrans : {A : Set}{x y z : A} -> x ≡ y -> y ≡ z -> x ≡ z\ntrans {A} refl xz = xz\n\ncong : {A B : Set}(f : A -> B){x y : A} -> x ≡ y -> f x ≡ f y\ncong {A} f refl = refl\n\ncong2 : {A B C : Set}(f : A -> B -> C){x z : A}{y w : B} -> x ≡ z -> y ≡ w -> f x y ≡ f z w\ncong2 {A}{B} f refl refl = refl\n\nEquiv : {A : Set} -> Equivalence A\nEquiv = record\n\t{ _==_ = _≡_\n\t; refl = \\x -> refl\n\t; sym = \\x y -> sym\n\t; trans = \\x y z -> trans\n\t}\n\n_≢_ : {A : Set} -> A -> A -> Set\nx ≢ y = ¬ (x ≡ y)\n\nsym≢ : {A : Set}{x y : A} -> x ≢ y -> y ≢ x\nsym≢ np p = np (sym p)\n\n", "meta": {"hexsha": "e45cfbbb1083623944c0ce9814651ddd029c2ca4", "size": 872, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Logic/Identity.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z", "max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z", "max_issues_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Logic/Identity.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Logic/Identity.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 21.2682926829, "max_line_length": 91, "alphanum_fraction": 0.4564220183, "num_tokens": 407, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.944176852582231, "lm_q2_score": 0.845942439250491, "lm_q1q2_score": 0.7987192697572637}} {"text": "open import Relation.Binary.Core\n\nmodule PLRTree.Order {A : Set} where\n\nopen import Data.Nat\nopen import Data.Sum\nopen import PLRTree {A}\nopen import Relation.Binary\n\nopen DecTotalOrder decTotalOrder hiding (refl)\n\nheight : PLRTree → ℕ\nheight leaf = zero\nheight (node t x l r) \n with total (height l) (height r)\n... | inj₁ hl≤hr = suc (height r)\n... | inj₂ hr≤hl = suc (height l)\n\n_≺_ : PLRTree → PLRTree → Set \nt ≺ t' = height t <′ height t'\n", "meta": {"hexsha": "0fdc139867139aace9d2dcfed7b4a26a2acc9287", "size": 446, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/PLRTree/Order.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/PLRTree/Order.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/PLRTree/Order.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.2380952381, "max_line_length": 46, "alphanum_fraction": 0.6883408072, "num_tokens": 143, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9683812354689083, "lm_q2_score": 0.8244619263765707, "lm_q1q2_score": 0.7983934588616196}} {"text": "open import Relation.Binary.Core\n\nmodule InsertSort.Impl1.Correctness.Permutation.Alternative {A : Set}\n (_≤_ : A → A → Set)\n (tot≤ : Total _≤_) where\n\nopen import Data.List\nopen import Data.Sum\nopen import Function\nopen import InsertSort.Impl1 _≤_ tot≤\nopen import List.Permutation.Alternative A renaming (_∼_ to _∼′_)\nopen import List.Permutation.Alternative.Correctness A \nopen import List.Permutation.Base A\n\nlemma-insert∼′ : (x : A)(xs : List A) → (x ∷ xs) ∼′ insert x xs\nlemma-insert∼′ x [] = ∼refl\nlemma-insert∼′ x (y ∷ ys) \n with tot≤ x y\n... | inj₁ x≤y = ∼refl\n... | inj₂ y≤x = ∼trans (∼swap ∼refl) (∼head y (lemma-insert∼′ x ys)) \n\nlemma-insertSort∼′ : (xs : List A) → xs ∼′ insertSort xs\nlemma-insertSort∼′ [] = ∼refl\nlemma-insertSort∼′ (x ∷ xs) = ∼trans (∼head x (lemma-insertSort∼′ xs)) (lemma-insert∼′ x (insertSort xs))\n\ntheorem-insertSort∼ : (xs : List A) → xs ∼ insertSort xs\ntheorem-insertSort∼ = lemma-∼′-∼ ∘ lemma-insertSort∼′\n", "meta": {"hexsha": "32316d4e54fa16148b68b7d64ec1db86a983e217", "size": 984, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/InsertSort/Impl1/Correctness/Permutation/Alternative.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/InsertSort/Impl1/Correctness/Permutation/Alternative.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/InsertSort/Impl1/Correctness/Permutation/Alternative.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.1428571429, "max_line_length": 105, "alphanum_fraction": 0.6493902439, "num_tokens": 355, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9683812318188366, "lm_q2_score": 0.824461928533133, "lm_q1q2_score": 0.798393457940649}} {"text": "{-# OPTIONS --sized-types #-}\nopen import Relation.Binary.Core\n\nmodule SOList.Total.Properties {A : Set} \n (_≤_ : A → A → Set) \n (trans≤ : Transitive _≤_) where\n\nopen import Bound.Total A\nopen import Bound.Total.Order _≤_ \nopen import Bound.Total.Order.Properties _≤_ trans≤\nopen import List.Order.Bounded _≤_\nopen import List.Order.Bounded.Properties _≤_ trans≤\nopen import List.Sorted _≤_\nopen import Size\nopen import SOList.Total _≤_\n\nlemma-solist≤ : {ι : Size}{b t : Bound} → SOList {ι} b t → LeB b t\nlemma-solist≤ (onil b≤t) = b≤t\nlemma-solist≤ (ocons x xs ys) = transLeB (lemma-solist≤ xs) (lemma-solist≤ ys)\n\nlemma-solist≤* : {ι : Size}{b : Bound}{x : A} → (xs : SOList {ι} b (val x)) → forget xs ≤* (val x)\nlemma-solist≤* (onil _) = lenx\nlemma-solist≤* (ocons x xs ys) = lemma-++≤* (lemma-solist≤ ys) (lemma-solist≤* xs) (lemma-solist≤* ys)\n\nlemma-solist*≤ : {ι : Size}{b t : Bound} → (xs : SOList {ι} b t) → b *≤ forget xs\nlemma-solist*≤ (onil _) = genx\nlemma-solist*≤ (ocons x xs ys) = lemma-++*≤ (lemma-solist≤ xs) (lemma-solist*≤ xs) (lemma-solist*≤ ys)\n\nlemma-solist-sorted : {ι : Size}{b t : Bound}(xs : SOList {ι} b t) → Sorted (forget xs)\nlemma-solist-sorted (onil _) = nils\nlemma-solist-sorted (ocons x xs ys) = lemma-sorted++ (lemma-solist≤* xs) (lemma-solist*≤ ys) (lemma-solist-sorted xs) (lemma-solist-sorted ys)\n\n\n\n\n", "meta": {"hexsha": "f94618406025c1ea958cfa475757dc26d354579f", "size": 1367, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/SOList/Total/Properties.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/SOList/Total/Properties.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/SOList/Total/Properties.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.9722222222, "max_line_length": 142, "alphanum_fraction": 0.6444769568, "num_tokens": 506, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9481545304202039, "lm_q2_score": 0.8418256532040708, "lm_q1q2_score": 0.7981808069093872}} {"text": "module index where\n\n-- natural numbers\n--- additions\nimport Nats.Add.Assoc\n using (nat-add-assoc) -- associative law\nimport Nats.Add.Comm\n using (nat-add-comm) -- commutative law\nimport Nats.Add.Invert\n using (nat-add-invert) -- a + a == b + b implies a == b\n using (nat-add-invert-1) -- a + 1 == b + 1 implies a == b\n\n--- multiplications\nimport Nats.Multiply.Comm\n using (nat-multiply-comm) -- commutative law\nimport Nats.Multiply.Distrib\n using (nat-multiply-distrib) -- distributive law\nimport Nats.Multiply.Assoc\n using (nat-multiply-assoc) -- associative law\n\n-- integers\n--- some properties\nimport Ints.Properties\n using (eq-int-to-nat) -- for natrual number a, + a == + a implis a == a\n using (eq-neg-int-to-nat) -- for natrual number a, - a == - a implis a == a\n using (eq-nat-to-int) -- for natrual number a, a == a implis + a == + a\n using (eq-neg-nat-to-int) -- for natrual number a, a == a implis - a == - a\n\n--- additions\nimport Ints.Add.Comm\n using (int-add-comm) -- commutative law\nimport Ints.Add.Assoc\n using (int-add-assoc) -- associative law\nimport Ints.Add.Invert\n using (int-add-invert) -- a + a == b + b implis a == b\n\n-- non-negative rationals\n--- some properties\nimport Rationals.Properties\n -- if b is not zero, n times b div b is the original number\n using (times-div-id)\n\n-- additions\nimport Rationals.Add.Comm\n using (rational-add-comm) -- commutative law\nimport Rationals.Add.Assoc\n using (rational-add-assoc) -- associative law\n\n-- multiplications\nimport Rationals.Multiply.Comm\n using (rational-multiply-comm) -- commutative law\n\n-- logics\n--- the \"and\" relations\nimport Logics.And\n using (and-comm) -- commutative law\n using (and-assoc) -- associative law\n\n--- the \"or\" relations\nimport Logics.Or\n using (or-comm) -- commutative law\n using (or-assoc) -- associative law\n using (or-elim) -- elimination rule\n\n--- negations\nimport Logics.Not\n -- law that negative twice will make a positive\n using (not-not)\n using (contrapositive) -- contrapositive\n\n-- vectors\n--- reverse twice gives the original vector\nimport Vecs.Reverse\n using (vec-rev-rev-id)\n\n-- lists\n--- reverse twice gives the original vector\nimport Lists.Reverse\n using (list-rev-rev-id)\n\n-- isomorphisms\n--- natrual numbers and others\nimport Isos.NatLike\n using (iso-nat-vec) -- with vector\n using (iso-nat-list) -- with list\n\n--- trees\nimport Isos.TreeLike\n using (iso-seven-tree-in-one) -- seven trees in one\n\n-- groups\n--- s3 group, xxx=e, yy=e, yx=xxy\nimport Groups.Symm.S3\n using (s3-property-1) -- given s3, prove xyx≡y\n", "meta": {"hexsha": "2060ef76fba93a2703a258e394967a8f4db09f6d", "size": 2552, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/index.agda", "max_stars_repo_name": "ice1k/Theorems", "max_stars_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-04-15T15:28:03.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-15T15:28:03.000Z", "max_issues_repo_path": "src/index.agda", "max_issues_repo_name": "ice1k/Theorems", "max_issues_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/index.agda", "max_forks_repo_name": "ice1k/Theorems", "max_forks_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.8631578947, "max_line_length": 77, "alphanum_fraction": 0.6947492163, "num_tokens": 772, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9481545304202039, "lm_q2_score": 0.8418256452674009, "lm_q1q2_score": 0.7981807993841976}} {"text": "open import Relation.Binary.Core\n\nmodule TreeSort.Impl2.Correctness.Order {A : Set}\n (_≤_ : A → A → Set)\n (tot≤ : Total _≤_) \n (trans≤ : Transitive _≤_) where\n\nopen import BBSTree _≤_ \nopen import BBSTree.Properties _≤_ trans≤\nopen import Data.List\nopen import Function using (_∘_)\nopen import List.Sorted _≤_\nopen import TreeSort.Impl2 _≤_ tot≤\n\ntheorem-treeSort-sorted : (xs : List A) → Sorted (flatten (treeSort xs))\ntheorem-treeSort-sorted = lemma-bbst-sorted ∘ treeSort\n\n\n\n\n", "meta": {"hexsha": "67c5b79db29e0d6c4d57252f58cbc7ab0b3ed26e", "size": 532, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/TreeSort/Impl2/Correctness/Order.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/TreeSort/Impl2/Correctness/Order.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/TreeSort/Impl2/Correctness/Order.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.3333333333, "max_line_length": 72, "alphanum_fraction": 0.6522556391, "num_tokens": 159, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9626731094431571, "lm_q2_score": 0.8289388083214156, "lm_q1q2_score": 0.7979971001448823}} {"text": "{-# OPTIONS --copatterns #-}\nmodule Copatterns where\n\nopen import Common.Equality\n\nrecord _×_ (A B : Set) : Set where\n constructor _,_\n field\n fst : A\n snd : B\nopen _×_\n\npair : {A B : Set} → A → B → A × B\nfst (pair a b) = a\nsnd (pair a b) = b\n\nswap : {A B : Set} → A × B → B × A\nfst (swap p) = snd p\nsnd (swap p) = fst p\n\nswap3 : {A B C : Set} → A × (B × C) → C × (B × A)\nfst (swap3 t) = snd (snd t)\nfst (snd (swap3 t)) = fst (snd t)\nsnd (snd (swap3 t)) = fst t\n\n-- should also work if we shuffle the clauses\nswap4 : {A B C D : Set} → A × (B × (C × D)) → D × (C × (B × A))\nfst (snd (swap4 t)) = fst (snd (snd t))\nsnd (snd (snd (swap4 t))) = fst t\nfst (swap4 t) = snd (snd (snd t))\nfst (snd (snd (swap4 t))) = fst (snd t)\n\n-- State monad example\n\nrecord State (S A : Set) : Set where\n constructor state\n field\n runState : S → A × S\nopen State\n\nrecord Monad (M : Set → Set) : Set1 where\n constructor monad\n field\n return : {A : Set} → A → M A\n _>>=_ : {A B : Set} → M A → (A → M B) → M B\nopen Monad {{...}}\n\nstateMonad : {S : Set} → Monad (State S)\nrunState (return {{stateMonad}} a ) s = a , s\nrunState (_>>=_ {{stateMonad}} m k) s₀ =\n let a , s₁ = runState m s₀\n in runState (k a) s₁\n\nleftId : {A B S : Set}(a : A)(k : A → State S B) → (return a >>= k) ≡ k a\nleftId a k = refl\n\nrightId : {A B S : Set}(m : State S A) → (m >>= return) ≡ m\nrightId m = refl\n\nassoc : {A B C S : Set}(m : State S A)(k : A → State S B)(l : B → State S C) →\n ((m >>= k) >>= l) ≡ (m >>= λ a → k a >>= l)\nassoc m k l = refl\n\n-- multiple clauses with abstractions\n\nfswap3 : {A B C X : Set} → (X → A) × ((X → B) × C) → (X → C) × (X → (B × A))\nfst (fswap3 t) x = snd (snd t)\nfst (snd (fswap3 t) y) = fst (snd t) y\nsnd (snd (fswap3 t) z) = fst t z\n\n", "meta": {"hexsha": "e135b64a1e96f81583b7e8db60939ce646ce19e1", "size": 1782, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/succeed/Copatterns.agda", "max_stars_repo_name": "np/agda-git-experiment", "max_stars_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "test/succeed/Copatterns.agda", "max_issues_repo_name": "np/agda-git-experiment", "max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/succeed/Copatterns.agda", "max_forks_repo_name": "np/agda-git-experiment", "max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.0985915493, "max_line_length": 78, "alphanum_fraction": 0.5173961841, "num_tokens": 708, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9161096204605946, "lm_q2_score": 0.8705972600147106, "lm_q1q2_score": 0.7975625254461102}} {"text": "module Spire.Examples.Standard where\n\n----------------------------------------------------------------------\n\ndata ℕ : Set where\n zero : ℕ\n suc : (n : ℕ) → ℕ\n\ndata Vec (A : Set) : ℕ → Set where\n nil : Vec A zero\n cons : (n : ℕ) (a : A) (xs : Vec A n) → Vec A (suc n)\n\n----------------------------------------------------------------------\n\nelimℕ : (P : ℕ → Set)\n (pzero : P zero)\n (psuc : (m : ℕ) → P m → P (suc m))\n (n : ℕ)\n → P n\nelimℕ P pzero psuc zero = pzero\nelimℕ P pzero psuc (suc n) = psuc n (elimℕ P pzero psuc n)\n\nelimVec : (A : Set) (P : (n : ℕ) → Vec A n → Set)\n (pnil : P zero nil)\n (pcons : (n : ℕ) (a : A) (xs : Vec A n) → P n xs → P (suc n) (cons n a xs))\n (n : ℕ)\n (xs : Vec A n)\n → P n xs\nelimVec A P pnil pcons .zero nil = pnil\nelimVec A P pnil pcons .(suc n) (cons n a xs) = pcons n a xs (elimVec A P pnil pcons n xs)\n\n----------------------------------------------------------------------\n\nmodule PatternMatching where\n\n add : ℕ → ℕ → ℕ\n add zero n = n\n add (suc m) n = suc (add m n)\n \n mult : ℕ → ℕ → ℕ\n mult zero n = zero\n mult (suc m) n = add n (mult m n)\n\n append : (A : Set) (m : ℕ) (xs : Vec A m) (n : ℕ) (ys : Vec A n) → Vec A (add m n)\n append A .zero nil n ys = ys\n append A .(suc m) (cons m x xs) n ys = cons (add m n) x (append A m xs n ys) \n \n concat : (A : Set) (m n : ℕ) (xss : Vec (Vec A m) n) → Vec A (mult n m)\n concat A m .zero nil = nil\n concat A m .(suc n) (cons n xs xss) = append A m xs (mult n m) (concat A m n xss)\n\n----------------------------------------------------------------------\n\nmodule Eliminator where\n\n add : ℕ → ℕ → ℕ\n add = elimℕ (λ _ → ℕ → ℕ)\n (λ n → n)\n (λ m ih n → suc (ih n))\n\n mult : ℕ → ℕ → ℕ\n mult = elimℕ (λ _ → ℕ → ℕ)\n (λ n → zero)\n (λ m ih n → add n (ih n))\n\n append : (A : Set) (m : ℕ) (xs : Vec A m) (n : ℕ) (ys : Vec A n) → Vec A (add m n)\n append A = elimVec A (λ m xs → (n : ℕ) (ys : Vec A n) → Vec A (add m n))\n (λ n ys → ys)\n (λ m x xs ih n ys → cons (add m n) x (ih n ys))\n\n concat : (A : Set) (m n : ℕ) (xss : Vec (Vec A m) n) → Vec A (mult n m)\n concat A m = elimVec (Vec A m) (λ n xss → Vec A (mult n m))\n nil\n (λ n xs xss ih → append A m xs (mult n m) ih)\n\n----------------------------------------------------------------------\n", "meta": {"hexsha": "fb3bea7423703f96d7fd38011214d0a43598fa13", "size": 2267, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "formalization/agda/Spire/Examples/Standard.agda", "max_stars_repo_name": "spire/spire", "max_stars_repo_head_hexsha": "3d67f137ee9423b7e6f8593634583998cd692353", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 43, "max_stars_repo_stars_event_min_datetime": "2015-05-28T23:25:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-08T17:10:59.000Z", "max_issues_repo_path": "formalization/agda/Spire/Examples/Standard.agda", "max_issues_repo_name": "spire/spire", "max_issues_repo_head_hexsha": "3d67f137ee9423b7e6f8593634583998cd692353", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "formalization/agda/Spire/Examples/Standard.agda", "max_forks_repo_name": "spire/spire", "max_forks_repo_head_hexsha": "3d67f137ee9423b7e6f8593634583998cd692353", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2015-08-17T21:00:07.000Z", "max_forks_repo_forks_event_max_datetime": "2015-08-17T21:00:07.000Z", "avg_line_length": 29.4415584416, "max_line_length": 90, "alphanum_fraction": 0.4305249228, "num_tokens": 829, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9399133531922388, "lm_q2_score": 0.8479677526147223, "lm_q1q2_score": 0.7970162137589905}} {"text": "module Ag01 where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl)\nopen Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _∎)\n\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\n{-# BUILTIN NATURAL ℕ #-}\n\n_+_ : ℕ → ℕ → ℕ\nzero + n = n\nsuc m + n = suc (m + n)\n\n_*_ : ℕ → ℕ → ℕ\nzero * n = zero\nsuc m * n = n + (m * n)\n\n_ : 3 * 4 ≡ 12\n_ = refl\n\n_^_ : ℕ → ℕ → ℕ\nm ^ 0 = 1\nm ^ (suc n) = m * (m ^ n)\n\n_ : 3 ^ 4 ≡ 81\n_ = refl\n\n_∸_ : ℕ → ℕ → ℕ\nm ∸ zero = m\nzero ∸ suc n = zero\nsuc m ∸ suc n = m ∸ n\n\ninfixl 6 _+_ _∸_\ninfixl 7 _*_\n\ndata Bin : Set where\n nil : Bin\n x0_ : Bin → Bin\n x1_ : Bin → Bin\n\ninc : Bin → Bin\ninc nil = nil\ninc (x1 b) = x0 (inc b)\ninc (x0 b) = x1 b\n\n_ : inc (x0 nil) ≡ (x1 nil)\n_ = refl\n\n_ : inc (x1 x1 x0 x1 nil) ≡ x0 x0 x1 x1 nil\n_ = refl\n\nto : ℕ → Bin\nto zero = x0 nil\nto (suc m) = inc (to m)\n\nfrom : Bin → ℕ\nfrom nil = zero\nfrom (x1 b) = suc (2 * (from b))\nfrom (x0 b) = 2 * (from b)\n\n", "meta": {"hexsha": "5e40f7f6d4e6031abd3795ed3ffc5e6fa2095d7c", "size": 934, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Agda/Ag01.agda", "max_stars_repo_name": "Brethland/LEARNING-STUFF", "max_stars_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-02-03T05:05:52.000Z", "max_stars_repo_stars_event_max_datetime": "2020-03-11T10:35:42.000Z", "max_issues_repo_path": "Agda/Ag01.agda", "max_issues_repo_name": "Brethland/LEARNING-STUFF", "max_issues_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Agda/Ag01.agda", "max_forks_repo_name": "Brethland/LEARNING-STUFF", "max_forks_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-12-13T04:50:46.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-13T04:50:46.000Z", "avg_line_length": 14.59375, "max_line_length": 50, "alphanum_fraction": 0.5149892934, "num_tokens": 434, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9441768588653856, "lm_q2_score": 0.8438950986284991, "lm_q1q2_score": 0.7967862234349511}} {"text": "{- --- 4. Lists --- -}\n\ndata List (A : Set) : Set where\n [] : List A\n _∷_ : A → List A → List A\n\ninfixr 5 _∷_\n\nopen import Data.Nat\nopen import Relation.Binary.PropositionalEquality\n\n{- 4.1 Length -}\n\nlength : {A : Set} → List A → ℕ\nlength [] = 0\nlength (x ∷ l) = 1 + (length l)\n\n\n{- 4.2 List reversal -}\n\nconcat : {A : Set} → List A → List A → List A\nconcat [] l = l\nconcat (x ∷ k) l = x ∷ (concat k l)\n\nconcat-length : {A : Set} → (k l : List A) → length (concat k l) ≡ (length k) + (length l)\nconcat-length [] l = refl\nconcat-length (x ∷ k) l rewrite concat-length k l = refl\n\nconcat-assoc : {A : Set} → (j k l : List A) → concat (concat j k) l ≡ concat j (concat k l)\nconcat-assoc [] k l = refl\nconcat-assoc (x ∷ j) k l rewrite concat-assoc j k l = refl\n\n\n{- 4.3 List reversal -}\n\nsnoc : {A : Set} → A -> List A → List A\nsnoc a [] = a ∷ []\nsnoc a (x ∷ l) = x ∷ (snoc a l)\n\nrev : {A : Set} → List A → List A\nrev [] = []\nrev (x ∷ l) = snoc x (rev l)\n\nsnoc-length : {A : Set} → (a : A) → (l : List A) → length (snoc a l) ≡ suc (length l)\nsnoc-length a [] = refl\nsnoc-length a (x ∷ l) rewrite snoc-length a l = refl \n\nrev-length : {A : Set} → (l : List A) → (length (rev l)) ≡ (length l)\nrev-length [] = refl\nrev-length (x ∷ l) rewrite snoc-length x (rev l) | rev-length l = refl\n\nsnoc-rev : {A : Set} → (a : A) → (l : List A) → rev (snoc a l) ≡ a ∷ (rev l)\nsnoc-rev a [] = refl\nsnoc-rev a (x ∷ l) rewrite snoc-rev a l = refl\n\ndouble-rev : {A : Set} → (l : List A) → rev (rev l) ≡ l\ndouble-rev [] = refl\ndouble-rev (x ∷ l) rewrite snoc-rev x (rev l) | double-rev l = refl\n\n\n{- 4.4 Filtering -}\nopen import Data.Bool\n\nfilter : {A : Set} → (p : A → Bool) → (l : List A) → List A\nfilter p [] = []\nfilter p (x ∷ l) with p x\nfilter p (x ∷ l) | false = filter p l\nfilter p (x ∷ l) | true = x ∷ (filter p l)\n\nempty-list : {A : Set} → (l : List A) → filter (λ _ → false) l ≡ []\nempty-list [] = refl\nempty-list (x ∷ l) = empty-list l\n\nidentity-list : {A : Set} → (l : List A) → filter (λ _ → true) l ≡ l\nidentity-list [] = refl\nidentity-list (x ∷ l) rewrite identity-list l = refl\n", "meta": {"hexsha": "0ed03b0e3c0b242114cdef79a211fa8589861966", "size": 2074, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "TD6/List.agda", "max_stars_repo_name": "erwinkn/program-eq-proof", "max_stars_repo_head_hexsha": "9a0d4a3f97103550a67e5e9ecbc8322bf0a8be23", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "TD6/List.agda", "max_issues_repo_name": "erwinkn/program-eq-proof", "max_issues_repo_head_hexsha": "9a0d4a3f97103550a67e5e9ecbc8322bf0a8be23", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "TD6/List.agda", "max_forks_repo_name": "erwinkn/program-eq-proof", "max_forks_repo_head_hexsha": "9a0d4a3f97103550a67e5e9ecbc8322bf0a8be23", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.9350649351, "max_line_length": 91, "alphanum_fraction": 0.5597878496, "num_tokens": 802, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9111797148356994, "lm_q2_score": 0.874077222043951, "lm_q1q2_score": 0.7964414339263876}} {"text": "module z05-00-internal-verification where\n\nopen import bool\nopen import eq\nopen import nat\nopen import nat-thms\nopen import product\nopen import sum\n\n{-\n------------------------------------------------------------------------------\nso far: EXTERNAL VERIFICATION\n- written programs (e.g., 'length')\n- proved properties (e.g., 'length-reverse')\n\nThis style of verification in type theory is called external verification\n- proofs are external to programs\n- proofs are distinct artifacts about some pre-existing programs\n\nINTERNAL VERIFICATION\n\nwrite functions with semantically expressive types\nwrite datatypes that put restrictions on data\nmay require embedding proofs in code\n\n------------------------------------------------------------------------------\n-- p 99 VECTORS - length of vector included in type : vector is INDEXED by its length\n\n-- vector.agda\n-}\ndata 𝕍 {ℓ} (A : Set ℓ) : ℕ → Set ℓ where\n [] : 𝕍 A 0\n _::_ : {n : ℕ} (x : A) (xs : 𝕍 A n) → 𝕍 A (suc n)\n\n-- compare to list (overloaded constructors OK)\ndata L {ℓ} (A : Set ℓ) : Set ℓ where\n [] : L A\n _::_ : (x : A) (xs : L A) → L A\n\ninfixr 6 _::_ _++𝕍_\n\n-- p 101\n\n[_]𝕍 : ∀ {ℓ} {A : Set ℓ} → A → 𝕍 A 1\n[ x ]𝕍 = x :: []\n\n-- type level addition on length\n_++𝕍_ : ∀ {ℓ} {A : Set ℓ}{n m : ℕ} → 𝕍 A n → 𝕍 A m → 𝕍 A (n + m)\n[] ++𝕍 ys = ys\n(x :: xs) ++𝕍 ys = x :: xs ++𝕍 ys\n\n-- p 102\n\n-- no 'nil' list corner case\nhead𝕍 : ∀ {ℓ} {A : Set ℓ} {n : ℕ} → 𝕍 A (suc n) → A\nhead𝕍 (x :: _) = x\n\n-- type level subtraction\ntail𝕍 : ∀ {ℓ} {A : Set ℓ} {n : ℕ} → 𝕍 A n → 𝕍 A (pred n)\ntail𝕍 [] = []\ntail𝕍 (_ :: xs) = xs\n\n-- p 103\n\n-- length preserving (for lists, length preservation is separate proof)\nmap𝕍 : ∀ {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} {n : ℕ} → (A → B) → 𝕍 A n → 𝕍 B n\nmap𝕍 f [] = []\nmap𝕍 f (x :: xs) = f x :: map𝕍 f xs\n\n-- p 104\n\n-- takes a vector of length m\n-- each element is vector of length n\n-- concats into single vector of length m * n\nconcat𝕍 : ∀{ℓ} {A : Set ℓ} {n m : ℕ} → 𝕍 (𝕍 A n) m → 𝕍 A (m * n)\nconcat𝕍 [] = []\nconcat𝕍 (x :: xs) = x ++𝕍 (concat𝕍 xs)\n\n-- p 104\n\n-- no need for maybe result as in lists by requiring n < m\nnth𝕍 : ∀ {ℓ} {A : Set ℓ} {m : ℕ}\n → (n : ℕ)\n → n < m ≡ tt\n → 𝕍 A m\n → A\nnth𝕍 0 _ (x :: _) = x\n-- Proof p (that index is less than length of vector) reused in recursive call.\n-- index is suc n\n-- length of list is suc m, for implicit m\n-- Agda implicitly introduces .m with suc .m\n-- p proves suc n < suc m ≡ tt\n-- def/eq to n < m ≡ tt\n-- so p has correct type to make the recursive call\nnth𝕍 (suc n) p (_ :: xs) = nth𝕍 n p xs\n-- us absurd pattern for the proof in last two cases\n-- length of list is zero, so no index can be smaller than that length\n-- must case-split on the index so Agda can the absurdity\n-- because the definition of _<_ splits on both inputs\n-- - returns ff separately for when the first input is is 0 and the second is 0\n-- - and for the first input being suc n and second is 0\nnth𝕍 (suc n) () []\nnth𝕍 0 () []\n\n-- p 105\n\nrepeat𝕍 : ∀ {ℓ} {A : Set ℓ} → (a : A) (n : ℕ) → 𝕍 A n\nrepeat𝕍 a 0 = []\nrepeat𝕍 a (suc n) = a :: (repeat𝕍 a n)\n\n{-\n------------------------------------------------------------------------------\n-- p 106 BRAUN TREES : balanced binary heaps\n\neither empty or\nnode consisting of some data x and a left and a right subtree\n\ndata may be stored so that x is smaller than all data in left and right subtrees\nif such an ordering property is desired\n\nBRAUN TREE PROPERTY (BTP) : crucial property : sizes of left and right trees:\n\nfor each node in the tree\n- either size (left) = size ( right ) or\n size (left) = size ( right ) + 1\n\nensures depth of the trees is ≤ log₂(N), where N is the number of nodes\n\nproperty maintained (via types) during insert\n\nmake the type A and ordering on that type be parameters of the module\n\nbraun-tree.adga\n-}\n\nmodule braun-tree {ℓ} (A : Set ℓ) (_ value at node ℕ\n\nsee z05-01-bst-test.agda\n z05-01-bst.agda\n\n-- p 117-120\nTODO : read/understand discussion of\n bool-relations.agda\n relations.agda\n\n------------------------------------------------------------------------------\n-- p 123 Internal vs. External Verification\n\ninternal verification : datatypes defined with invariants; functions take proofs of preconditions\n- Datatypes with essential invariants : enforce via internal\n- Complex programs\n - doing external of complex will cause reasoning about complexity\n not relevant to property being proved\n - internal weaves proofs thru code and datatype\n\nexternal verification : theorems about functions proved separately\n- Algebraic Properties e.g., proving associativity\n- Functions used in an internal verification's specification\n -- e.g., min/max used in bst - need to externally prove properties about min/max\n\n------------------------------------------------------------------------------\n-- p 126 Exercises\n\n1. Nested vector type.\n Fill in the hole to define a type for matrices of nats\n where the type lists the dimensions of the matrix:\n-}\n\n-- inner vector is a row\n_by_matrix : ℕ → ℕ → Set\nrows by cols matrix = 𝕍 (𝕍 ℕ cols) rows\n\nmatrix-to-vec-vec : ∀ {rows cols : ℕ} → rows by cols matrix → 𝕍 (𝕍 ℕ cols) rows\nmatrix-to-vec-vec 𝕞 = 𝕞\n\n-- 2a\nzero-matrix : (rows cols : ℕ) → rows by cols matrix\nzero-matrix rows cols = repeat𝕍 (repeat𝕍 0 cols) rows\n\n_ : zero-matrix 2 3 ≡ (0 :: 0 :: 0 :: []) ::\n (0 :: 0 :: 0 :: []) :: []\n_ = refl\n\n_ : zero-matrix 0 0 ≡ []\n_ = refl\n_ : zero-matrix 0 1 ≡ []\n_ = refl\n_ : zero-matrix 1 0 ≡ [] :: []\n_ = refl\n_ : zero-matrix 1 1 ≡ (0 :: []) :: []\n_ = refl\n\n-- 2b\nmatrix-elt : ∀ {rows cols : ℕ}\n → rows by cols matrix\n → (r : ℕ)\n → (c : ℕ)\n → r < rows ≡ tt\n → c < cols ≡ tt\n → ℕ\nmatrix-elt 𝕞 r c r arith-formula n ≡ arith-sum n\narith-eq zero = refl\narith-eq (suc n) rewrite lemma n = cong (_+_ (suc n)) (arith-eq n)\n", "meta": {"hexsha": "401c682e94c65daf36f954dafcf585483ad3bb85", "size": 923, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Agda/TEST.agda", "max_stars_repo_name": "Brethland/LEARNING-STUFF", "max_stars_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-02-03T05:05:52.000Z", "max_stars_repo_stars_event_max_datetime": "2020-03-11T10:35:42.000Z", "max_issues_repo_path": "Agda/TEST.agda", "max_issues_repo_name": "Brethland/LEARNING-STUFF", "max_issues_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Agda/TEST.agda", "max_forks_repo_name": "Brethland/LEARNING-STUFF", "max_forks_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-12-13T04:50:46.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-13T04:50:46.000Z", "avg_line_length": 35.5, "max_line_length": 142, "alphanum_fraction": 0.5135427952, "num_tokens": 397, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9504109798251321, "lm_q2_score": 0.8376199633332891, "lm_q1q2_score": 0.7960832100726826}} {"text": "-- Length-indexed lists as a recursive family\n-- From \"Dependent Types at Work\", section 3.1\n\nmodule xx where\n\nopen import Level renaming (suc to lsuc)\nopen import Data.Nat hiding (_^_)\nopen import Data.Empty.Polymorphic\nopen import Data.Unit.Polymorphic\nopen import Data.Maybe hiding (map ; zip)\nopen import Data.Product hiding (map ; zip)\n\nprivate\n variable\n m n : ℕ\n ℓ ℓ′ : Level\n A : Set ℓ\n B : Set ℓ′\n\n-- Vec : Set ℓ → ℕ → Set ℓ\n-- Vec A zero = ⊤\n-- Vec A (suc n) = A × Vec A n\n\n-- Generalize Vec\n\nopen import Function\n\niter : A → (A → A) → ℕ → A\niter z f zero = z\niter z f (suc n) = f (iter z f n)\n\n-- Is iter defined somewhere standard?\n\nVec : Set ℓ → ℕ → Set ℓ\nVec A = iter ⊤ (A ×_)\n\nhead : Vec A (suc n) → A\nhead (a , _) = a\n\ntail : Vec A (suc n) → Vec A n\ntail (_ , as) = as\n\nmap : (A → B) → Vec A n → Vec B n\nmap {n = zero } _ _ = tt\nmap {n = suc n} f (a , as) = f a , map {n = n} f as\n\nzip : Vec A n → Vec B n → Vec (A × B) n\nzip {n = zero } _ _ = tt\nzip {n = suc n} (a , as) (b , bs) = (a , b) , zip {n = n} as bs\n\nFin : ℕ → Set\nFin zero = ⊥\nFin (suc n) = Maybe (Fin n)\n\nf5 : Fin 5\nf5 = nothing\nf4 : Fin 4\nf4 = nothing\nf3 : Fin 3\nf3 = nothing\nf2 : Fin 2\nf2 = just nothing -- an element of the type\nf1 : Fin 1\nf1 = nothing\n-- f0 : Fin 0\n-- f0 = {!!} -- no solution found\n\n_!_ : Vec A n → Fin n → A\n_!_ {n = suc m} (a , _ ) nothing = a\n_!_ {n = suc m} (_ , as) (just i) = as ! i\n\n_!'_ : Vec A n → Fin n → A\n_!'_ {n = suc m} (a , _) nothing = a\n_!'_ {n = suc m} (_ , as) (just finm) = as !' finm\n\n{-\n(0 , 1 , 2 , tt) ! nothing\n(0 , 1 , 2 , tt) ! just nothing\n(0 , 1 , 2 , tt) ! just (just nothing)\n(0 , 1 , 2 , tt) ! just (just (just nothing))\n-}\n\n-- Perfect binary leaf tree\nBTree : Set ℓ → ℕ → Set ℓ\nBTree A = iter A (λ τ → τ × τ)\n", "meta": {"hexsha": "45ff6949b18ea45025374a642c66854be4e19279", "size": 1802, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/paper/2009-Dependent_Types_at_Work-Bove_and_Dybjer/xx.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/paper/2009-Dependent_Types_at_Work-Bove_and_Dybjer/xx.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/paper/2009-Dependent_Types_at_Work-Bove_and_Dybjer/xx.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 20.9534883721, "max_line_length": 63, "alphanum_fraction": 0.5410654828, "num_tokens": 718, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.931462503162843, "lm_q2_score": 0.8539127510928476, "lm_q1q2_score": 0.7953877086156135}} {"text": "module List.Sorted {A : Set}(_≤_ : A → A → Set) where\n\nopen import Data.List\n\ndata Sorted : List A → Set where\n nils : Sorted []\n singls : (x : A) \n → Sorted [ x ]\n conss : {x y : A}{xs : List A} \n → x ≤ y \n → Sorted (y ∷ xs) \n → Sorted (x ∷ y ∷ xs)\n\n\n\n\n", "meta": {"hexsha": "b68d745bb730bf741c6a26f9bbe238a387173d9b", "size": 331, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/List/Sorted.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/List/Sorted.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/List/Sorted.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.4705882353, "max_line_length": 54, "alphanum_fraction": 0.4048338369, "num_tokens": 104, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9621075777163567, "lm_q2_score": 0.8267117940706734, "lm_q1q2_score": 0.795385681662879}} {"text": "------------------------------------------------------------------------------\n-- Common (interactive and automatic) properties using the induction principle\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule PA.Inductive.PropertiesByInduction where\n\nopen import PA.Inductive.Base\n\n------------------------------------------------------------------------------\n-- Congruence properties\n\nsuccCong : ∀ {m n} → m ≡ n → succ m ≡ succ n\nsuccCong refl = refl\n\n------------------------------------------------------------------------------\n\n+-leftIdentity : ∀ n → zero + n ≡ n\n+-leftIdentity n = refl\n\n+-rightIdentity : ∀ n → n + zero ≡ n\n+-rightIdentity n = ℕ-ind A A0 is n\n where\n A : ℕ → Set\n A i = i + zero ≡ i\n\n A0 : A zero\n A0 = refl\n\n is : ∀ i → A i → A (succ i)\n is i ih = succCong ih\n\n+-assoc : ∀ m n o → m + n + o ≡ m + (n + o)\n+-assoc m n o = ℕ-ind A A0 is m\n where\n A : ℕ → Set\n A i = i + n + o ≡ i + (n + o)\n\n A0 : A zero\n A0 = refl\n\n is : ∀ i → A i → A (succ i)\n is i ih = succCong ih\n\nx+Sy≡S[x+y] : ∀ m n → m + succ n ≡ succ (m + n)\nx+Sy≡S[x+y] m n = ℕ-ind A A0 is m\n where\n A : ℕ → Set\n A i = i + succ n ≡ succ (i + n)\n\n A0 : A zero\n A0 = refl\n\n is : ∀ i → A i → A (succ i)\n is i ih = succCong ih\n", "meta": {"hexsha": "831f456210057310780fcf2d3dcbadf2cc35783a", "size": 1436, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/PA/Inductive/PropertiesByInduction.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/PA/Inductive/PropertiesByInduction.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/PA/Inductive/PropertiesByInduction.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 23.9333333333, "max_line_length": 78, "alphanum_fraction": 0.4164345404, "num_tokens": 418, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9399133481428692, "lm_q2_score": 0.8459424334245618, "lm_q1q2_score": 0.7951125849362061}} {"text": "data ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\n{-# BUILTIN NATURAL ℕ #-}\n\n_+_ : ℕ → ℕ → ℕ\nzero + b = b\nsuc a + b = suc (a + b)\ninfix 100 _+_\n\ndata _≡_ : ℕ → ℕ → Set where\n refl : {n : ℕ} → n ≡ n\n\nsym : {n m : ℕ} → n ≡ m → m ≡ n\nsym refl = refl\n\ntrans : {m n o : ℕ} → m ≡ n → n ≡ o → m ≡ o\ntrans refl p₂ = p₂\n\nsuc-inj : {m n : ℕ} → suc m ≡ suc n → m ≡ n\nsuc-inj refl = refl\n\ndata ⊥ : Set where\n\n¬ : Set → Set\n¬ A = A → ⊥\n\n_≢_ : ℕ → ℕ → Set\nm ≢ n = ¬(m ≡ n)\n\nzero-img : ∀ {m} → suc m ≢ 0\nzero-img ()\n\ninduction : (P : ℕ → Set) → P 0 → (∀ {n} → P n → P (suc n)) → (∀ m → P m)\ninduction pred base hypo zero = base\ninduction pred base hypo (suc m) = hypo (induction pred base hypo m)\n\ncong : ∀ {m n} → (f : ℕ → ℕ) → m ≡ n → f m ≡ f n\ncong f refl = refl\n\nassoc : ∀ m n o → m + (n + o) ≡ (m + n) + o\nassoc zero n o = refl\nassoc (suc m) n o = cong suc (assoc m n o)\n\nn+zero : ∀ n → n ≡ n + 0\nn+zero zero = refl\nn+zero (suc n) = cong suc (n+zero n)\n\nsuc+ : ∀ m n → suc (n + m) ≡ (n + suc m)\nsuc+ m zero = refl\nsuc+ m (suc n) = cong suc (suc+ m n)\n\ncomm : ∀ m n → m + n ≡ n + m\ncomm zero n = n+zero n\ncomm (suc m) n = trans (cong suc (comm m n)) (suc+ m n)\n\n\n-- Where to go from here?\n-- Agda:\n-- • Aaron Stump - Verified Functional Programming in Agda, https://svn.divms.uiowa.edu/repos/clc/projects/agda/book/book.pdf\n-- • Conor McBride - Dependently Typed Metaprogramming (in Agda), http://cs.ioc.ee/ewscs/2014/mcbride/mcbride-deptypedmetaprog.pdf\n-- Type theory:\n-- • So you want to learn type theory, http://purelytheoretical.com/sywtltt.html\n", "meta": {"hexsha": "ef1ab753322df632942d29a24a836915c97932da", "size": 1543, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "fpb-6/talk.agda", "max_stars_repo_name": "FPBrno/FPBrno.github.io", "max_stars_repo_head_hexsha": "970b31f80fc24481a088b099f32a8c8e4b120618", "max_stars_repo_licenses": ["Artistic-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-12-06T14:30:32.000Z", "max_stars_repo_stars_event_max_datetime": "2018-12-06T14:30:32.000Z", "max_issues_repo_path": "fpb-6/talk.agda", "max_issues_repo_name": "FPBrno/FPBrno.github.io", "max_issues_repo_head_hexsha": "970b31f80fc24481a088b099f32a8c8e4b120618", "max_issues_repo_licenses": ["Artistic-2.0"], "max_issues_count": 21, "max_issues_repo_issues_event_min_datetime": "2015-03-05T11:01:13.000Z", "max_issues_repo_issues_event_max_datetime": "2019-01-14T18:45:37.000Z", "max_forks_repo_path": "fpb-6/talk.agda", "max_forks_repo_name": "FPBrno/FPBrno.github.io", "max_forks_repo_head_hexsha": "970b31f80fc24481a088b099f32a8c8e4b120618", "max_forks_repo_licenses": ["Artistic-2.0"], "max_forks_count": 9, "max_forks_repo_forks_event_min_datetime": "2015-03-04T22:12:51.000Z", "max_forks_repo_forks_event_max_datetime": "2018-09-14T07:57:40.000Z", "avg_line_length": 23.7384615385, "max_line_length": 132, "alphanum_fraction": 0.5541153597, "num_tokens": 646, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.953966098909522, "lm_q2_score": 0.8333245953120233, "lm_q1q2_score": 0.794963413315167}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Level\nopen import Categories.Category\nopen import Categories.Monad\n\nmodule Categories.Monad.Morphism {o ℓ e} {C D : Category o ℓ e} where\n\nopen import Categories.NaturalTransformation\nopen import Categories.Functor\n\nopen NaturalTransformation\n\n-- monad morphism in the sense of the nLab\n-- https://ncatlab.org/nlab/show/monad#the_bicategory_of_monads\n-- between generic monads t : a -> a & s : b -> b\nrecord Monad⇒ (M : Monad C) (N : Monad D) : Set (o ⊔ ℓ ⊔ e) where\n\n private\n module M = Monad M\n module N = Monad N\n\n open module D = Category D using (_∘_; _≈_)\n\n field\n X : Functor C D\n α : NaturalTransformation (N.F ∘F X) (X ∘F M.F)\n\n module X = Functor X\n module α = NaturalTransformation α\n\n field\n unit-comp : ∀ {U} → α.η U ∘ (N.η.η (X.₀ U)) ≈ X.₁ (M.η.η U)\n mult-comp : ∀ {U} → α.η U ∘ (N.μ.η (X.₀ U)) ≈ X.₁ (M.μ.η U) ∘ α.η (M.F.₀ U) ∘ N.F.₁ (α.η U)\n\n-- monad morphism in a different sense:\n-- monads are on the same category, X is the identity\nrecord Monad⇒-id (M N : Monad C) : Set (o ⊔ ℓ ⊔ e) where\n\n private\n module M = Monad M\n module N = Monad N\n\n field\n α : NaturalTransformation N.F M.F\n\n module α = NaturalTransformation α\n\n open module C = Category C using (_∘_; _≈_)\n\n field\n unit-comp : ∀ {U} → α.η U ∘ N.η.η U ≈ M.η.η U\n mult-comp : ∀ {U} → α.η U ∘ (N.μ.η U) ≈ M.μ.η U ∘ α.η (M.F.₀ U) ∘ N.F.₁ (α.η U)\n\n-- monad 2-cell in the sense of https://ncatlab.org/nlab/show/monad#the_bicategory_of_monads\nrecord Monad²⇒ {M : Monad C} {N : Monad D} (Γ Δ : Monad⇒ M N) : Set (o ⊔ ℓ ⊔ e) where\n\n private\n module M = Monad M\n module N = Monad N\n module Γ = Monad⇒ Γ\n module Δ = Monad⇒ Δ\n\n field\n m : NaturalTransformation Γ.X Δ.X\n\n module m = NaturalTransformation m\n\n open module D = Category D using (_∘_; _≈_)\n\n field\n comm : ∀ {U} → Δ.α.η U ∘ N.F.₁ (m.η U) ≈ m.η (M.F.₀ U) ∘ Γ.α.η U", "meta": {"hexsha": "72bb06a9c6d30a0383dcfa8636db2d4717238724", "size": 1908, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Monad/Morphism.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2019-05-21T17:07:19.000Z", "max_stars_repo_stars_event_max_datetime": "2019-05-22T03:54:24.000Z", "max_issues_repo_path": "src/Categories/Monad/Morphism.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Monad/Morphism.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.5, "max_line_length": 95, "alphanum_fraction": 0.6137316562, "num_tokens": 727, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9441768572945969, "lm_q2_score": 0.8418256412990657, "lm_q1q2_score": 0.7948322883917605}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Some examples showing where the natural numbers and some related\n-- operations and properties are defined, and how they can be used\n------------------------------------------------------------------------\n\nmodule README.Nat where\n\n-- The natural numbers and various arithmetic operations are defined\n-- in Data.Nat.\n\nopen import Data.Nat\n\nex₁ : ℕ\nex₁ = 1 + 3\n\n-- Propositional equality and some related properties can be found\n-- in Relation.Binary.PropositionalEquality.\n\nopen import Relation.Binary.PropositionalEquality\n\nex₂ : 3 + 5 ≡ 2 * 4\nex₂ = refl\n\n-- Data.Nat.Properties contains a number of properties about natural\n-- numbers. Algebra defines what a commutative semiring is, among\n-- other things.\n\nopen import Algebra\nimport Data.Nat.Properties as Nat\nprivate\n module CS = CommutativeSemiring Nat.commutativeSemiring\n\nex₃ : ∀ m n → m * n ≡ n * m\nex₃ m n = CS.*-comm m n\n\n-- The module ≡-Reasoning in Relation.Binary.PropositionalEquality\n-- provides some combinators for equational reasoning.\n\nopen ≡-Reasoning\nopen import Data.Product\n\nex₄ : ∀ m n → m * (n + 0) ≡ n * m\nex₄ m n = begin\n m * (n + 0) ≡⟨ cong (_*_ m) (proj₂ CS.+-identity n) ⟩\n m * n ≡⟨ CS.*-comm m n ⟩\n n * m ∎\n\n-- The module SemiringSolver in Data.Nat.Properties contains a solver\n-- for natural number equalities involving variables, constants, _+_\n-- and _*_.\n\nopen Nat.SemiringSolver\n\nex₅ : ∀ m n → m * (n + 0) ≡ n * m\nex₅ = solve 2 (λ m n → m :* (n :+ con 0) := n :* m) refl\n", "meta": {"hexsha": "4a2e9785b8f0222171d8e00c5fdcaad00dfbf05a", "size": 1586, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib-0.9/README/Nat.agda", "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_issues_repo_path": "agda-stdlib-0.9/README/Nat.agda", "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib-0.9/README/Nat.agda", "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.3448275862, "max_line_length": 72, "alphanum_fraction": 0.6292559899, "num_tokens": 446, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9489172615983308, "lm_q2_score": 0.8376199552262967, "lm_q1q2_score": 0.7948320341734539}} {"text": "module x02induction where\n\n-- prove properties of inductive naturals and operations on them via induction\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl; cong; sym)\nopen Eq.≡-Reasoning using (begin_; _≡⟨⟩_; step-≡; _∎)\nopen import Data.Nat using (ℕ; zero; suc; _+_; _*_; _∸_; _^_)\n\n{-\n------------------------------------------------------------------------------\n## Properties of operators : identity, associativity, commutativity, distributivity\n\n* _Identity_. left/right/both; sometimes called _unit_\n\n* _Associativity_. e.g., `(m + n) + p ≡ m + (n + p)`\n\n* _Commutativity_. e.g., `m + n ≡ n + m`\n\n* _Distributivity_. e.g., from the left `(m + n) * p ≡ (m * p) + (n * p)`\n from the right `m * (p + q) ≡ (m * p) + (m * q)`\n\n#### Exercise `operators` (practice) {name=operators} TODO : ops with different properties - no proofs\n\npair of operators\n- have an identity\n- are associative, commutative, and distribute over one another\n(do not prove)\n\noperator\n- has identity\n- is associative\n- not commutative\n(do not prove)\n-}\n\n{-\nHC not associative; right identity\n-}\n_ =\n begin\n (3 ∸ 1) ∸ 1 ∸ 0 ≡⟨⟩\n 2 ∸ 1 ∸ 0 ≡⟨⟩\n 1 ∸ 0 ≡⟨⟩\n 1 ∸ 0\n ∎\n{-\n------------------------------------------------------------------------------\n## ASSOCIATIVITY of ADDITION : (m + n) + p ≡ m + (n + p)\n-}\n\n_ : (3 + 4) + 5 ≡ 3 + (4 + 5)\n_ =\n begin\n (3 + 4) + 5 ≡⟨⟩\n 7 + 5 ≡⟨⟩\n 12 ≡⟨⟩\n 3 + 9 ≡⟨⟩\n 3 + (4 + 5)\n ∎\n\n{-\nuseful to read chains like above\n- from top down until reaching simplest term (i.e., `12`)\n- from bottom up until reaching the same term\n\nWhy should `7 + 5` be the same as `3 + 9`?\nPerhaps gather more evidence, testing the proposition by choosing other numbers.\nBut infinite naturals so testing can never be complete.\n\n## PROOF BY INDUCTION\n\nnatural definition has\n- base case\n- inductive case\n\ninductive proof follows structure of definition: prove two cases\n- _base case_ : show property holds for `zero`\n- _inductive case_ :\n - assume property holds for an arbitrary natural `m` (the _inductive hypothesis_)\n - then show that the property holds for `suc m`\n\n ------\n P zero\n\n P m\n ---------\n P (suc m)\n\n- initially, no properties are known.\n- base case : `P zero` holds : add it to set of known properties\n -- On the first day, one property is known.\n P zero\n- inductive case tells us that if `P m` holds\n -- On the second day, two properties are known.\n P zero\n P (suc zero)\n then `P (suc m)` also holds\n\n -- On the third day, three properties are known.\n P zero\n P (suc zero)\n P (suc (suc zero))\n\n -- On the fourth day, four properties are known.\n P zero\n P (suc zero)\n P (suc (suc zero))\n P (suc (suc (suc zero)))\n\nthe process continues: property `P n` first appears on day _n+1_\n\n------------------------------------------------------------------------------\n## PROVE ASSOCIATIVITY of ADDITION\n\ntake `P m` to be the property:\n\n (m + n) + p ≡ m + (n + p)\n\n`n` and `p` are arbitrary natural numbers\n\nshow the equation holds for all `m` it will also hold for all `n` and `p`\n\n\n -------------------------------\n (zero + n) + p ≡ zero + (n + p)\n\n\n (m + n) + p ≡ m + (n + p)\n ---------------------------------\n (suc m + n) + p ≡ suc m + (n + p)\n\ndemonstrate both of above, then associativity of addition follows by induction\n-}\n\n-- signature says providing evidence for proposition\n+-assoc : ∀ (m n p : ℕ)\n → (m + n) + p\n ≡ m + (n + p)\n\n-- Evidence is a function that\n-- - takes three natural numbers, binds them to `m`, `n`, and `p`\n-- - returns evidence for the corresponding instance of the equation\n\n-- base case : show: (zero + n) + p\n-- ≡ zero + (n + p)\n+-assoc zero n p =\n begin\n (zero + n) + p ≡⟨⟩ -- _+_ base case\n n + p ≡⟨⟩\n zero + (n + p)\n ∎\n\n-- inductive case : show: (suc m + n) + p\n-- ≡ suc m + (n + p)\n+-assoc (suc m) n p =\n begin\n (suc m + n) + p ≡⟨⟩ -- _+_ inductive case (left to right)\n suc (m + n) + p ≡⟨⟩\n suc ((m + n) + p) ≡⟨ cong suc (+-assoc m n p) ⟩\n -- simplifying both sides : suc ((m + n) + p) ≡ suc (m + (n + p))\n -- follows by prefacing `suc` to both sides of the induction hypothesis:\n -- (m + n) + p ≡ m + (n + p)\n suc (m + (n + p)) ≡⟨⟩ -- _+_ inductive case (right to left)\n suc m + (n + p)\n ∎\n\n-- HC minimal version\n\n+-assoc' : ∀ (m n p : ℕ)\n → (m + n) + p\n ≡ m + (n + p)\n+-assoc' zero n p = refl\n+-assoc' (suc m) n p = cong suc (+-assoc m n p)\n\n{-\nidentifiers can have any characters NOT including spaces or the characters @.(){};_\n\nthe \"middle\" equation, does not follow from applying _+_ (i.e., \"simplification\") alone\n- `_≡⟨_⟩_` : called \"chain reasoning\"\n- justification for equation given in angle brackets:\n - empty means \"simplification\", or\n - something more, e.g.,:\n\n ⟨ cong suc (+-assoc m n p) ⟩\n\nrecursive invocation `+-assoc m n p`\n- has type of the induction hypothesis\n- `cong suc` prefaces `suc` to each side of inductive hypothesis\n\nA relation is a CONGRUENCE for a given function\nif the relation is preserved by applying the function.\n\nif `e` is evidence that `x ≡ y`, then `cong f e` is evidence `f x ≡ f y`, for any `f`\n\nhere the inductive hypothesis is not assumed\n\ninstead, proved by recursive invocation of the function being defined, `+-assoc m n p`\n\nWELL FOUNDED : associativity of larger numbers is proved in of associativity of smaller numbers.\n\ne.g., `assoc (suc m) n p` is proved using `assoc m n p`.\n\n------------------------------------------------------------------------------\n## Induction as recursion\n\nConcrete example of how induction corresponds to recursion : instantiate `m` to `2`\n-}\n\n+-assoc-2 : ∀ (n p : ℕ)\n → (2 + n) + p\n ≡ 2 + (n + p)\n+-assoc-2 n p =\n begin\n (2 + n) + p ≡⟨⟩\n suc (1 + n) + p ≡⟨⟩\n suc ((1 + n) + p) ≡⟨ cong suc (+-assoc-1 n p) ⟩\n suc (1 + (n + p)) ≡⟨⟩\n 2 + (n + p)\n ∎\n where\n +-assoc-1 : ∀ (n p : ℕ) → (1 + n) + p ≡ 1 + (n + p)\n +-assoc-1 n p =\n begin\n (1 + n) + p ≡⟨⟩\n suc (0 + n) + p ≡⟨⟩\n suc ((0 + n) + p) ≡⟨ cong suc (+-assoc-0 n p) ⟩\n suc (0 + (n + p)) ≡⟨⟩\n 1 + (n + p)\n ∎\n where\n +-assoc-0 : ∀ (n p : ℕ) → (0 + n) + p ≡ 0 + (n + p)\n +-assoc-0 n p =\n begin\n (0 + n) + p ≡⟨⟩\n n + p ≡⟨⟩\n 0 + (n + p)\n ∎\n{-\n------------------------------------------------------------------------------\n## Terminology and notation\n\nEvidence for a universal quantifier is a function. The notations\n\n +-assoc : ∀ (m n p : ℕ)\n → (m + n) + p\n ≡ m + (n + p)\n\nand\n\n +-assoc : ∀ (m : ℕ)\n → ∀ (n : ℕ)\n → ∀ (p : ℕ)\n → (m + n) + p\n ≡ m + (n + p)\n\nare equivalent.\n\ndiffer from function type such as `ℕ → ℕ → ℕ`\n- variables are associated with each argument type\n- the result type may mention (or depend upon) these variables\n- hence called _DEPENDENT functions_\n\n------------------------------------------------------------------------------\n## COMMUTATIVITY of ADDITION : m + n ≡ n + m\n\ntwo lemmas used in proof\n\n### first lemma\n\nThe base case of the definition of addition states that zero is a left-identity:\n\n zero + n ≡ n\n\nFirst lemma states that zero is also a right-identity:\n-}\n\n-- proof by induction on `m`\n+-identityʳ : ∀ (m : ℕ)\n → m + zero\n ≡ m\n\n-- base case : show:\n-- zero + zero\n-- ≡ zero\n+-identityʳ zero =\n begin\n zero + zero ≡⟨⟩ -- _+_ base\n zero\n ∎\n\n-- inductive case : show:\n-- (suc m) + zero\n-- = suc m\n+-identityʳ (suc m) =\n begin\n suc m + zero ≡⟨⟩ -- _+_ inductive\n suc (m + zero) ≡⟨ cong suc (+-identityʳ m) ⟩\n -- recursive invocation `+-identityʳ m`\n -- has type of induction hypothesis\n -- m + zero ≡ m\n -- `cong suc` prefaces `suc` to each side of that type, yielding\n -- suc (m + zero) ≡ suc m\n suc m\n ∎\n{-\n### second lemma\n\ninductive case of _+_ pushes `suc` on 1st arg to the outside:\n\n suc m + n ≡ suc (m + n)\n\nsecond lemma does same for `suc` on 2nd arg:\n\n m + suc n ≡ suc (m + n)\n-}\n\n-- signature states defining `+-suc` which provides evidence for the proposition/type\n+-suc : ∀ (m n : ℕ)\n → m + suc n\n ≡ suc (m + n)\n\n-- evidence is fun that takes two nats, binds to `m` and `n`\n-- returns evidence for the corresponding instance of the equation\n-- proof is by induction on `m`\n\n-- base case\n+-suc zero n =\n begin\n zero + suc n ≡⟨⟩ -- _+_ base\n suc n ≡⟨⟩ -- _+_ base\n suc (zero + n)\n ∎\n-- inductive case : show: suc m + suc n\n-- ≡ suc (suc m + n)\n+-suc (suc m) n =\n begin\n suc m + suc n ≡⟨⟩ -- _+_ inductive\n suc (m + suc n) ≡⟨ cong suc (+-suc m n) ⟩ -- induction\n suc (suc (m + n)) ≡⟨⟩ -- _+_ inductive\n suc (suc m + n)\n ∎\n\n-------------------------\n\n+-comm : ∀ (m n : ℕ)\n → m + n\n ≡ n + m\n+-comm m zero =\n begin\n m + zero ≡⟨ +-identityʳ m ⟩\n m ≡⟨⟩\n zero + m\n ∎\n+-comm m (suc n) =\n begin\n m + suc n ≡⟨ +-suc m n ⟩\n suc (m + n) ≡⟨ cong suc (+-comm m n) ⟩ -- congruence and induction hypothesis\n suc (n + m) ≡⟨⟩ -- _+_ inductive\n suc n + m\n ∎\n\n{-\ndefinition required BEFORE using them\n\n------------------------------------------------------------------------------\n## COROLLARY: REARRANGING : apply associativity to rearrange parentheses (SYM; sections)\n-}\n\n+-rearrange : ∀ (m n p q : ℕ)\n → (m + n) + (p + q)\n ≡ m + (n + p) + q\n+-rearrange m n p q =\n begin\n (m + n) + (p + q) ≡⟨ +-assoc m n (p + q) ⟩\n m + (n + (p + q)) ≡⟨ cong (m +_) (sym (+-assoc n p q)) ⟩\n m + ((n + p) + q) ≡⟨ sym (+-assoc m (n + p) q) ⟩\n (m + (n + p)) + q ≡⟨⟩\n m + (n + p) + q\n ∎\n\n{-\nno induction is required\n\nNOTE:\n\naddition is left associative : m + (n + p) + q\n = (m + (n + p)) + q\n\nSYM : interchange sides of an equation, e.g.,\n- `+-assoc n p q` shifts parens right to left:\n\n (n + p) + q ≡ n + (p + q)\n\n`sym (+-assoc n p q)`: to shift them left-to-right\n\n n + (p + q) ≡ (n + p) + q\n\ngeneral\n- if `e` provides evidence for `x ≡ y`\n- then `sym e` provides evidence for `y ≡ x`\n\nSECTION NOTATION (introduced by Richard Bird) : `(x +_)` `(_+ x)`\n\n------------------------------------------------------------------------------\n## Creation, one last time\n\nbase case : `(zero + n) + p ≡ zero + (n + p)`\n\ninductive case :\n- if `(m + n) + p ≡ m + (n + p)` then\n `(suc m + n) + p ≡ suc m + (n + p)`\n\nusing base case, associativity of zero on left:\n (0 + 0) + 0 ≡ 0 + (0 + 0) ... (0 + 4) + 5 ≡ 0 + (4 + 5) ...\nusing inductive case\n (1 + 0) + 0 ≡ 1 + (0 + 0) ... (1 + 4) + 5 ≡ 1 + (4 + 5) ...\n (2 + 0) + 0 ≡ 2 + (0 + 0) ... (2 + 4) + 5 ≡ 2 + (4 + 5) ...\n (3 + 0) + 0 ≡ 3 + (0 + 0) ... (3 + 4) + 5 ≡ 3 + (4 + 5) ...\n ...\n\nthere is a finite approach to generating the same equations (following exercise)\n\n------------------------------------------------------------------------------\n#### Exercise `finite-|-assoc` (stretch) {name=finite-plus-assoc} TODO - first four days of creation - description, not proof\n\nWrite out what is known about associativity of addition on each of the\nfirst four days using a finite story of creation, as\n[earlier](/Naturals/#finite-creation).\n\n------------------------------------------------------------------------------\n## proof of ASSOCIATIVITY using `rewrite` (rather than chains of equations)\n\navoids chains of equations and the need to invoke `cong`\n-}\n\n+-assoc′ : ∀ (m n p : ℕ)\n → (m + n) + p\n ≡ m + (n + p)\n\n-- base\n-- show: (zero + n) + p ≡ zero + (n + p)\n-- _+_ base applied \"invisibly\", then terms equal/refl\n+-assoc′ zero n p = refl\n\n-- inductive\n-- show: (suc m + n) + p ≡ suc m + (n + p)\n-- _+_ inductive applied \"invisibly\" giving: suc ((m + n) + p) ≡ suc (m + (n + p))\n-- rewrite with the inductive hypothesis\n-- then terms are equal/refl\n+-assoc′ (suc m) n p rewrite +-assoc′ m n p = refl\n\n{-\nrewriting by a given equation\n- indicated by keyword `rewrite`\n- followed by a proof of that equation\n\n------------------------------------------------------------------------------\n## COMMUTATIVITY with rewrite\n-}\n\n+-suc′ : ∀ (m n : ℕ) → m + suc n ≡ suc (m + n)\n+-suc′ zero n = refl\n+-suc′ (suc m) n rewrite +-suc′ m n = refl\n\n+-comm′ : ∀ (m n : ℕ) → m + n ≡ n + m\n+-comm′ m zero rewrite +-identityʳ m = refl\n-- rewriting with two equations indicated by separating the two proofs\n-- of the relevant equations by a vertical bar\n-- left rewrite performed before right\n+-comm′ m (suc n) -- m + suc n ≡ suc n + m\n -- m + suc n ≡ suc (n + m) -- def/eq\n rewrite\n +-suc′ m n -- suc (m + n) ≡ suc (n + m)\n | +-comm′ m n -- suc (n + m) ≡ suc (n + m)\n = refl\n\n+-comm′′ : ∀ (m n : ℕ) → m + n ≡ n + m\n+-comm′′ m zero rewrite +-identityʳ m = refl\n+-comm′′ m (suc n) =\n begin\n m + suc n ≡⟨ +-suc′ m n ⟩\n suc (m + n) ≡⟨ cong suc (+-comm′′ m n) ⟩\n suc (n + m) ≡⟨⟩ -- def/eq\n suc n + m\n ∎\n\n{-\n------------------------------------------------------------------------------\nHC\n-}\n\n*0 : ∀ (m : ℕ) → m * 0 ≡ 0\n*0 zero = refl\n*0 (suc m) = *0 m\n\n0* : ∀ (m : ℕ) → 0 * m ≡ 0\n0* m = refl\n\n*1 : ∀ (n : ℕ) → n * 1 ≡ n\n*1 zero = refl\n*1 (suc n) rewrite *1 n = refl\n\n1* : ∀ (n : ℕ) → 1 * n ≡ n\n1* zero = refl\n1* (suc n) rewrite 1* n = refl\n\n{-\n------------------------------------------------------------------------------\n## Building proofs interactively\n\n +-assoc′ : ∀ (m n p : ℕ) → (m + n) + p ≡ m + (n + p)\n +-assoc′ m n p = ?\n\nC-c C-l\n\n +-assoc′ : ∀ (m n p : ℕ) → (m + n) + p ≡ m + (n + p)\n +-assoc′ m n p = { }0\n\nnew window at the bottom:\n\n ?0 : ((m + n) + p) ≡ (m + (n + p))\n\nindicates hole 0 needs to be filled with a proof of the stated judgment\n\nto prove the proposition by induction on `m`\nmove cursor into hole\nC-c C-c\nprompt: pattern variables to case (empty for split on result):\n\ntype `m` to case split on that variable\n\n +-assoc′ : ∀ (m n p : ℕ) → (m + n) + p ≡ m + (n + p)\n +-assoc′ zero n p = { }0\n +-assoc′ (suc m) n p = { }1\n\nThere are now two holes, and the window at the bottom tells you what\neach is required to prove:\n\n ?0 : ((zero + n) + p) ≡ (zero + (n + p))\n ?1 : ((suc m + n) + p) ≡ (suc m + (n + p))\n\ngoto hole 0\nC-c C-,\n\n Goal: (n + p) ≡ (n + p)\n ————————————————————————————————————————————————————————————\n p : ℕ\n n : ℕ\n\nindicates that after simplification the goal for hole 0 is as stated,\n and that variables `p` and `n` of the stated types are available to use in the proof.\n\nthe proof of the given goal is simple\ngoto goal\nC-c C-r\nfills in with refl\nC-c C-l renumbers remaining hole to 0:\n\n +-assoc′ : ∀ (m n p : ℕ) → (m + n) + p ≡ m + (n + p)\n +-assoc′ zero n p = refl\n +-assoc′ (suc m) n p = { }0\n\ngoto hole 0\nC-c C-,\n\n Goal: suc ((m + n) + p) ≡ suc (m + (n + p))\n ————————————————————————————————————————————————————————————\n p : ℕ\n n : ℕ\n m : ℕ\n\ngives simplified goal and available variables\n\nneed to rewrite by the induction hypothesis\n\n +-assoc′ : ∀ (m n p : ℕ) → (m + n) + p ≡ m + (n + p)\n +-assoc′ zero n p = refl\n +-assoc′ (suc m) n p rewrite +-assoc′ m n p = { }0\n\ngoto hole\nC-c C-,\n\n Goal: suc (m + (n + p)) ≡ suc (m + (n + p))\n ————————————————————————————————————————————————————————————\n p : ℕ\n n : ℕ\n m : ℕ\n\ngoto goal\nC-c C-r\nfills in, completing proof\n\n +-assoc′ : ∀ (m n p : ℕ) → (m + n) + p ≡ m + (n + p)\n +-assoc′ zero n p = refl\n +-assoc′ (suc m) n p rewrite +-assoc′ m n p = refl\n\n------------------------------------------------------------------------------\n#### Exercise `+-swap` (recommended) {name=plus-swap}\n\nShow\n\n m + (n + p) ≡ n + (m + p)\n\nfor all naturals `m`, `n`, and `p`\n- no induction\n- use associativity and commutativity of addtion\n-}\n\n+-swap : ∀ (m n p : ℕ)\n → m + (n + p)\n ≡ n + (m + p)\n+-swap m n p =\n begin\n m + (n + p) ≡⟨ sym (+-assoc m n p) ⟩\n (m + n) + p ≡⟨ cong (_+ p) (sym (+-comm n m)) ⟩\n (n + m) + p ≡⟨ +-assoc n m p ⟩\n n + (m + p)\n ∎\n\n{-\n------------------------------------------------------------------------------\n#### Exercise `*-distrib-+` (recommended) {name=times-distrib-plus} (m + n) * p ≡ m * p + n * p\n-}\n\n*-distrib-+r : ∀ (m n p : ℕ)\n → (m + n) * p\n ≡ m * p + n * p\n*-distrib-+r zero y z = refl\n*-distrib-+r (suc x) y z -- (suc x + y) * z ≡ suc x * z + y * z\n -- z + (x + y) * z ≡ z + x * z + y * z\n rewrite\n *-distrib-+r x y z -- z + (x * z + y * z) ≡ z + x * z + y * z\n | sym (+-assoc z (x * z) (y * z)) -- z + x * z + y * z ≡ z + x * z + y * z\n = refl\n\n{- TODO: agda loops on this : *-distrib-+r done with chain reasoning\n*-distrib-+r' : ∀ (m n p : ℕ)\n → (m + n) * p\n ≡ m * p + n * p\n*-distrib-+r' zero y z = refl\n*-distrib-+r' (suc x) y z\n begin\n (suc x + y) * z ≡⟨⟩\n z + (x + y) * z ≡⟨ *-distrib-+r' x y z ⟩\n z + (x * z + y * z) ≡⟨ sym (+-assoc z (x * z) (y * z)) ⟩\n z + x * z + y * z ≡⟨⟩\n suc x * z + y * z\n ∎\n-}\n{-\n------------------------------------------------------------------------------\n#### Exercise `*-assoc` (recommended) {name=times-assoc} (m * n) * p ≡ m * (n * p)\n-}\n\n*-assoc : ∀ (m n p : ℕ)\n → (m * n) * p\n ≡ m * (n * p)\n-- base case : show: (zero * n) * p\n-- ≡ zero * (n * p)\n*-assoc zero n p = refl -- zero * n * p ≡ zero * (n * p)\n -- zero ≡ zero -- def/eq\n-- inductive case : show: (suc m * n) * p\n-- ≡ suc m * (n * p)\n*-assoc (suc m) n p -- suc m * n * p ≡ suc m * (n * p)\n -- (n + m * n) * p ≡ n * p + m * (n * p)\n rewrite\n *-distrib-+r n (m * n) p -- n * p + m * n * p ≡ n * p + m * (n * p)\n | *-assoc m n p -- n * p + m * (n * p) ≡ n * p + m * (n * p)\n = refl\n\n{-\n------------------------------------------------------------------------------\n#### Exercise `*-comm` (practice) {name=times-comm} MULTIPLICATION is COMMUTATIVE : m * n ≡ n * m\n-}\n\n*-suc : ∀ (x y : ℕ) → x * (suc y) ≡ x + (x * y)\n*-suc zero y = refl\n*-suc (suc x) y -- suc x * suc y ≡ suc x + suc x * y\n -- suc (y + x * suc y) ≡ suc (x + (y + x * y))\n rewrite\n +-comm y (x * suc y) -- suc (x * suc y + y) ≡ suc (x + (y + x * y))\n | *-suc x y -- suc (x + x * y + y) ≡ suc (x + (y + x * y))\n | +-comm y (x * y) -- suc (x + x * y + y) ≡ suc (x + (x * y + y))\n | sym (+-assoc x (x * y) y) -- suc (x + x * y + y) ≡ suc (x + x * y + y)\n = refl\n\n*-comm : ∀ (m n : ℕ) → m * n ≡ n * m\n*-comm m zero rewrite *0 m = refl\n*-comm m (suc n) -- m * suc n ≡ suc n * m\n -- m * suc n ≡ m + n * m\n rewrite\n *-suc m n -- m + m * n ≡ m + n * m\n | *-comm m n -- m + n * m ≡ m + n * m\n = refl\n\n{-\n------------------------------------------------------------------------------\n#### Exercise `0∸n≡0` (practice) {name=zero-monus} : Show zero ∸ n ≡ zero\n\nfor all naturals `n`. Did your proof require induction?\n-}\n\n0∸n≡0 : ∀ (n : ℕ) → 0 ∸ n ≡ 0\n0∸n≡0 zero = refl\n0∸n≡0 (suc n) = refl\n\n{-\n------------------------------------------------------------------------------\n#### Exercise `∸-|-assoc` (practice) {name=monus-plus-assoc} : m ∸ n ∸ p ≡ m ∸ (n + p)\n\nshow that monus associates with addition\n-}\n\n∸-|-assoc : ∀ (m n p : ℕ) → m ∸ n ∸ p ≡ m ∸ (n + p)\n∸-|-assoc m n zero -- m ∸ n ∸ zero ≡ m ∸ (n + zero)\n -- m ∸ n ≡ m ∸ (n + zero)\n rewrite +-identityʳ n = refl -- m ∸ n ≡ m ∸ n\n∸-|-assoc m zero (suc p) -- m ∸ zero ∸ suc p ≡ m ∸ (zero + suc p)\n = refl -- m ∸ suc p ≡ m ∸ suc p\n∸-|-assoc zero (suc n) (suc p) -- zero ∸ suc n ∸ suc p ≡ zero ∸ (suc n + suc p)\n = refl -- zero ≡ zero\n∸-|-assoc (suc m) (suc n) (suc p) -- suc m ∸ suc n ∸ suc p ≡ suc m ∸ (suc n + suc p)\n -- m ∸ n ∸ suc p ≡ m ∸ (n + suc p)\n rewrite\n ∸-|-assoc m n (suc p) -- m ∸ (n + suc p) ≡ m ∸ (n + suc p)\n = refl\n\n{-\n------------------------------------------------------------------------------\n#### Exercise `+*^` (stretch)\n\n m ^ (n + p) ≡ (m ^ n) * (m ^ p) (^-distribˡ-|-*)\n (m * n) ^ p ≡ (m ^ p) * (n ^ p) (^-distribʳ-*)\n (m ^ n) ^ p ≡ m ^ (n * p) (^-*-assoc)\n-}\n\n-------------------------\n-- this can be shortened\n^-distribˡ-|-* : ∀ (m n p : ℕ)\n → m ^ (n + p)\n ≡ (m ^ n) * (m ^ p)\n^-distribˡ-|-* m n zero -- (m ^ (n + zero)) ≡ (m ^ n) * (m ^ zero)\n -- (m ^ (n + zero)) ≡ (m ^ n) * 1\n rewrite\n +-identityʳ n -- (m ^ n) ≡ (m ^ n) * 1\n | *1 (m ^ n) -- (m ^ n) ≡ (m ^ n)\n = refl\n^-distribˡ-|-* m n (suc p) -- (m ^ (n + suc p)) ≡ (m ^ n) * (m ^ suc p)\n -- (m ^ (n + suc p)) ≡ (m ^ n) * (m * (m ^ p))\n rewrite\n *-comm m (m ^ p) -- (m ^ (n + suc p)) ≡ (m ^ n) * ((m ^ p) * m)\n | sym (*-assoc (m ^ n) (m ^ p) m) -- (m ^ (n + suc p)) ≡ (m ^ n) * (m ^ p) * m\n | +-comm n (suc p) -- (m ^ suc (p + n)) ≡ (m ^ n) * (m ^ p) * m\n -- m * (m ^ (p + n)) ≡ (m ^ n) * (m ^ p) * m\n | *-comm ((m ^ n) * (m ^ p)) m -- m * (m ^ (p + n)) ≡ m * ((m ^ n) * (m ^ p))\n | sym (*-assoc m (m ^ n) (m ^ p)) -- m * (m ^ (p + n)) ≡ m * (m ^ n) * (m ^ p)\n | ^-distribˡ-|-* m p n -- m * ((m ^ p) * (m ^ n)) ≡ m * (m ^ n) * (m ^ p)\n | sym (*-comm (m ^ n) (m ^ p)) -- m * ((m ^ n) * (m ^ p)) ≡ m * (m ^ n) * (m ^ p)\n | *-assoc m (m ^ n) (m ^ p) -- m * ((m ^ n) * (m ^ p)) ≡ m * ((m ^ n) * (m ^ p))\n = refl\n\n-------------------------\n^-distribʳ-* : ∀ (m n p : ℕ)\n → (m * n) ^ p\n ≡ (m ^ p) * (n ^ p)\n^-distribʳ-* m n zero = refl\n^-distribʳ-* m n (suc p) -- ((m * n) ^ suc p) ≡(m ^ suc p) * (n ^ suc p)\n -- m * n * ((m * n) ^ p) ≡ m * (m ^ p) * (n * (n ^ p))\n rewrite\n ^-distribʳ-* m n p -- m * n * ((m ^ p) * (n ^ p)) ≡ m * (m ^ p) * (n * (n ^ p))\n | *-comm (m * (m ^ p)) (n * (n ^ p))\n -- m * n * ((m ^ p) * (n ^ p)) ≡ n * (n ^ p) * (m * (m ^ p))\n | *-assoc m n ((m ^ p) * (n ^ p)) -- m *(n * ((m ^ p) * (n ^ p)))≡ n * (n ^ p) * (m * (m ^ p))\n | *-comm m (n * ((m ^ p) * (n ^ p)))\n -- n *((m ^ p) * (n ^ p))* m ≡ n * (n ^ p) * (m * (m ^ p))\n | *-comm (m ^ p) (n ^ p) -- n *((n ^ p) * (m ^ p))* m ≡ n * (n ^ p) * (m * (m ^ p))\n | sym (*-assoc n (n ^ p) (m ^ p)) -- n * (n ^ p) * (m ^ p) * m ≡ n * (n ^ p) * (m * (m ^ p))\n | *-assoc n (n ^ p) (m * (m ^ p)) -- n * (n ^ p) * (m ^ p) * m ≡ n *((n ^ p) * (m * (m ^ p)))\n | *-comm m (m ^ p) -- n * (n ^ p) * (m ^ p) * m ≡ n *((n ^ p) * ((m ^ p) * m))\n | *-assoc n (n ^ p) (m ^ p) -- n *((n ^ p) * (m ^ p))* m ≡ n *((n ^ p) * ((m ^ p) * m))\n | *-assoc n ((n ^ p) * (m ^ p)) m -- n *((n ^ p) * (m ^ p) * m) ≡ n *((n ^ p) * ((m ^ p) * m))\n | *-assoc (n ^ p) (m ^ p) m -- n *((n ^ p) *((m ^ p) * m))≡ n *((n ^ p) * ((m ^ p) * m))\n = refl\n\n-------------------------\n^-*-assoc : ∀ (m n p : ℕ)\n → (m ^ n) ^ p\n ≡ m ^ (n * p)\n^-*-assoc m n zero -- ((m ^ n) ^ zero) ≡ (m ^ (n * zero))\n -- 1 ≡ (m ^ (n * zero))\n rewrite *0 n -- 1 ≡ (m ^ 0)\n -- 1 ≡ 1\n = refl\n^-*-assoc m n (suc p) -- ((m ^ n) ^ suc p) ≡ (m ^ (n * suc p))\n -- (m ^ n) * ((m ^ n) ^ p) ≡ (m ^ (n * suc p))\n rewrite\n *-suc n p -- (m ^ n) * ((m ^ n) ^ p) ≡ (m ^ (n + n * p))\n | ^-distribˡ-|-* m n (n * p) -- (m ^ n) * ((m ^ n) ^ p) ≡ (m ^ n) * (m ^ (n * p))\n | sym (^-*-assoc m n p) -- (m ^ n) * ((m ^ n) ^ p) ≡ (m ^ n) * ((m ^ n) ^ p)\n = refl\n\n{-\n------------------------------------------------------------------------------\n#### Exercise `Bin-laws` (stretch) {name=Bin-laws}\n\nRecall that\nExercise [Bin](/Naturals/#Bin)\ndefines a datatype `Bin` of bitstrings representing natural numbers,\nand asks you to define functions\n-}\n\n-- begin duplicated from x01 (can't import because of \"duplicate\" pragma)\n\ndata Bin : Set where\n ⟨⟩ : Bin\n _O : Bin → Bin\n _I : Bin → Bin\n\ninc : Bin → Bin\ninc ⟨⟩ = ⟨⟩ I\ninc (b O) = b I\ninc (b I) = (inc b) O\n\n_ : inc (⟨⟩ I O I I) ≡ ⟨⟩ I I O O\n_ = refl\n\n-- end duplicated\n\ndbl : ℕ → ℕ\ndbl zero = zero\ndbl (suc m) = suc (suc (dbl m))\n\nto : ℕ → Bin\nto zero = ⟨⟩ O\nto (suc m) = inc (to m)\n\n-- THIS IS THE CRITICAL STEP : defining in terms of 'dbl'\n-- Got hint from : https://cs.uwaterloo.ca/~plragde/842/\nfrom : Bin → ℕ\nfrom ⟨⟩ = 0\nfrom (b O) = dbl (from b)\nfrom (b I) = suc (dbl (from b))\n\n_ : to 6 ≡ ⟨⟩ I I O\n_ = refl\n\n_ : from (⟨⟩ I I O) ≡ 6\n_ = refl\n\n{-\nConsider the following laws, where `n` ranges over naturals and `b`\nover bitstrings:\n\n from (inc b) ≡ suc (from b)\n to (from b) ≡ b\n from (to n) ≡ n\n\nFor each law: if it holds, prove; if not, give a counterexample.\n-}\n\n-------------------------\n-- fromInc≡sucFrom\n\n+1 : ∀ (x : ℕ) → x + 1 ≡ suc x\n+1 zero = refl\n+1 (suc n) rewrite +1 n = refl\n\nfromInc≡sucFrom : ∀ (b : Bin)\n → from (inc b) ≡ suc (from b)\nfromInc≡sucFrom ⟨⟩ -- from (inc ⟨⟩) ≡ suc (from ⟨⟩)\n -- 1 ≡ 1\n = refl\nfromInc≡sucFrom (⟨⟩ I) -- from (inc (⟨⟩ I)) ≡ suc (from (⟨⟩ I))\n -- 2 ≡ 2\n = refl\nfromInc≡sucFrom (b O) -- from (inc (b O)) ≡ suc (from (b O))\n -- dbl (from b) + 1 ≡ suc (dbl (from b))\n rewrite\n +1 (dbl (from b)) -- suc (dbl (from b)) ≡ suc (dbl (from b))\n = refl\nfromInc≡sucFrom (b I) -- from (inc (b I)) ≡ suc (from (b I))\n -- dbl (from (inc b)) ≡ suc (dbl (from b) + 1)\n rewrite\n +1 (dbl (from b)) -- dbl (from (inc b)) ≡ suc (suc (dbl (from b)))\n | fromInc≡sucFrom b -- dbl (suc (from b)) ≡ suc (suc (dbl (from b)))\n -- suc (suc (dbl (from b))) ≡ suc (suc (dbl (from b)))\n = refl\n\n-------------------------\n-- to-from≡b -- cannot be proved because there are TWO representations of ZERO\n\n-- NOT USED\nxx : ∀ (b : Bin)\n → (dbl (from b)) ≡ from (b O)\nxx ⟨⟩ -- dbl (from ⟨⟩) ≡ from (⟨⟩ O)\n -- zero ≡ zero\n = refl\nxx (b O) -- dbl (from (b O)) ≡ from ((b O) O)\n -- dbl (dbl (from b)) ≡ dbl (dbl (from b))\n = refl\nxx (b I) -- dbl (from (b I)) ≡ from ((b I) O)\n -- suc (suc (dbl (dbl (from b)))) ≡ suc (suc (dbl (dbl (from b))))\n = refl\n\n-- CANNOT BE PROVED BECAUSE TWO REPRESENTATIONS OF ZERO : (⟨⟩) and (⟨⟩ O)\nyy : ∀ (b : Bin)\n → to (dbl (from b)) ≡ (b O)\nyy ⟨⟩ -- to (dbl (from ⟨⟩)) ≡ (⟨⟩ O)\n -- (⟨⟩ O) ≡ (⟨⟩ O)\n = refl\nyy (b O) -- to (dbl (from (b O))) ≡ ((b O) O)\n -- to (dbl (dbl (from b))) ≡ ((b O) O)\n rewrite\n yy b\n = {!!}\nyy (b I) -- to (dbl (from (b I))) ≡ ((b I) O)\n -- inc (inc (to (dbl (dbl (from b))))) ≡ ((b I) O)\n = {!!}\n\nto-from : ∀ (b : Bin)\n → to (from b) ≡ b\nto-from ⟨⟩ -- to (from ⟨⟩) ≡ ⟨⟩\n -- (⟨⟩ O) ≡ ⟨⟩ -- *****\n = {!!}\nto-from (⟨⟩ I) -- to (from (⟨⟩ I)) ≡ (⟨⟩ I)\n -- (⟨⟩ I) ≡ (⟨⟩ I)\n = refl\nto-from (b O) -- to (from (b O)) ≡ (b O)\n -- to (dbl (from b)) ≡ (b O)\n rewrite\n yy b -- (b O) ≡ (b O)\n = refl\nto-from (b I) -- to (from (b I)) ≡ (b I)\n -- inc (to (dbl (from b))) ≡ (b I)\n rewrite\n yy b -- (b I) ≡ (b I)\n = refl\n\n-------------------------\n\n-- https://github.com/billyang98/plfa/blob/master/plfa/Induction.agda\n\nfrom-inc≡suc-from : ∀ x → from (inc x) ≡ suc (from x)\nfrom-inc≡suc-from ⟨⟩ = refl\nfrom-inc≡suc-from (x O) = refl\nfrom-inc≡suc-from (x I) -- from (inc (x I)) ≡ suc (from (x I))\n -- dbl (from (inc x)) ≡ suc (suc (dbl (from x)))\n rewrite\n from-inc≡suc-from x -- suc (suc (dbl (from x))) ≡ suc (suc (dbl (from x)))\n = refl\n\nfrom-to : ∀ n → from (to n) ≡ n\nfrom-to zero = refl\nfrom-to (suc n) -- from (to (suc n)) ≡ suc n\n -- from (inc (to n)) ≡ suc n\n rewrite\n from-inc≡suc-from (to n) -- suc (from (to n)) ≡ suc n\n | cong suc (from-to n) -- suc n ≡ suc n\n = refl\n\n{-\n------------------------------------------------------------------------------\n## Standard library\n\nDefinitions similar to those in this chapter can be found in the standard library:\n```\nimport Data.Nat.Properties using (+-assoc; +-identityʳ; +-suc; +-comm)\n```\n\n------------------------------------------------------------------------------\n## Unicode\n\nThis chapter uses the following unicode:\n\n ∀ U+2200 FOR ALL (\\forall, \\all)\n ʳ U+02B3 MODIFIER LETTER SMALL R (\\^r)\n ′ U+2032 PRIME (\\')\n ″ U+2033 DOUBLE PRIME (\\')\n ‴ U+2034 TRIPLE PRIME (\\')\n ⁗ U+2057 QUADRUPLE PRIME (\\')\n\nSimilar to `\\r`, the command `\\^r` gives access to a variety of\nsuperscript rightward arrows, and also a superscript letter `r`.\nThe command `\\'` gives access to a range of primes (`′ ″ ‴ ⁗`).\n-}\n\n-- ============================================================================\n\n-- this is here to ensure the Bin/in/from/to does not get broken if changed above\n\n_ : inc (⟨⟩ I O I I) ≡ ⟨⟩ I I O O\n_ = refl\n\n_ : inc (⟨⟩ O) ≡ ⟨⟩ I\n_ = refl\n_ : inc (⟨⟩ I) ≡ ⟨⟩ I O\n_ = refl\n_ : inc (⟨⟩ I O) ≡ ⟨⟩ I I\n_ = refl\n_ : inc (⟨⟩ I I) ≡ ⟨⟩ I O O\n_ = refl\n_ : inc (⟨⟩ I O O) ≡ ⟨⟩ I O I\n_ = refl\n\n_ : from (⟨⟩ O) ≡ 0\n_ = refl\n_ : from (⟨⟩ I) ≡ 1\n_ = refl\n_ : from (⟨⟩ I O) ≡ 2\n_ = refl\n_ : from (⟨⟩ I I) ≡ 3\n_ = refl\n_ : from (⟨⟩ I O O) ≡ 4\n_ = refl\n\n_ : to 0 ≡ (⟨⟩ O)\n_ = refl\n_ : to 1 ≡ (⟨⟩ I)\n_ = refl\n_ : to 2 ≡ (⟨⟩ I O)\n_ = refl\n_ : to 3 ≡ (⟨⟩ I I)\n_ = refl\n_ : to 4 ≡ (⟨⟩ I O O)\n_ = refl\n\n_ : from (to 12) ≡ 12\n_ = refl\n\n_ : to (from (⟨⟩ I I O O)) ≡ ⟨⟩ I I O O\n_ = refl\n", "meta": {"hexsha": "41e8c42d615dfce97b5718c02f9d84dd18c20261", "size": 31652, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x02induction.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x02induction.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x02induction.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 30.6408518877, "max_line_length": 125, "alphanum_fraction": 0.4053140402, "num_tokens": 11345, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9073122288794594, "lm_q2_score": 0.8757869803008764, "lm_q1q2_score": 0.7946122371203994}} {"text": "module InequalityReasoningExercise where\n\nopen import EqualityAux\n\ninfix 4 _≤_\n\ndata _≤_ : ℕ → ℕ → Set where\n\n z≤n : ∀ {n : ℕ}\n --------\n → zero ≤ n\n\n s≤s : ∀ {m n : ℕ}\n → m ≤ n\n -------------\n → suc m ≤ suc n\n\n≤-refl : ∀ {n : ℕ}\n -----\n → n ≤ n\n≤-refl {zero} = z≤n\n≤-refl {suc n} = s≤s ≤-refl\n\n≤-trans : ∀ {m n p : ℕ}\n → m ≤ n\n → n ≤ p\n -----\n → m ≤ p\n≤-trans z≤n _ = z≤n\n≤-trans (s≤s m≤n) (s≤s n≤p) = s≤s (≤-trans m≤n n≤p)\n\nmodule ≤-Reasoning where\n\n infix 1 ≤-begin_\n infixr 2 _≤⟨⟩_ _≤⟨_⟩_ _≤-≡⟨_⟩_\n infix 3 _≤-∎\n\n ≤-begin_ : ∀ {x y : ℕ}\n → x ≤ y\n -----\n → x ≤ y\n ≤-begin x≤y = x≤y\n\n _≤⟨⟩_ : ∀ (x : ℕ) {y : ℕ}\n → x ≤ y\n -----\n → x ≤ y\n x ≤⟨⟩ x≤y = x≤y\n\n _≤⟨_⟩_ : ∀ (x : ℕ) {y z : ℕ}\n → x ≤ y\n → y ≤ z\n -----\n → x ≤ z\n x ≤⟨ x≤y ⟩ y≤z = ≤-trans x≤y y≤z\n\n _≤-≡⟨_⟩_ : ∀ (x : ℕ) {y z : ℕ}\n → x ≡ y\n → y ≤ z\n -----\n → x ≤ z\n x ≤-≡⟨ refl ⟩ y≤z = ≤-trans ≤-refl y≤z\n\n _≤-∎ : ∀ (x : ℕ)\n -----\n → x ≤ x\n x ≤-∎ = ≤-refl\n\nopen ≤-Reasoning\n\n+-monoʳ-≤ : ∀ (n p q : ℕ)\n → p ≤ q\n -------------\n → n + p ≤ n + q\n+-monoʳ-≤ zero p q p≤q =\n ≤-begin\n zero + p\n ≤⟨⟩\n p\n ≤⟨ p≤q ⟩\n q\n ≤⟨⟩\n zero + q\n ≤-∎\n\n+-monoʳ-≤ (suc n) p q p≤q =\n ≤-begin\n (suc n) + p\n ≤⟨⟩\n suc (n + p)\n ≤⟨ s≤s (+-monoʳ-≤ n p q p≤q) ⟩\n suc (n + q)\n ≤⟨⟩\n (suc n) + q\n ≤-∎\n\n+-monoˡ-≤ : ∀ (m n p : ℕ)\n → m ≤ n\n -------------\n → m + p ≤ n + p\n+-monoˡ-≤ m n p m≤n =\n ≤-begin\n m + p\n ≤-≡⟨ +-comm m p ⟩\n p + m\n ≤⟨ +-monoʳ-≤ p m n m≤n ⟩\n p + n\n ≤-≡⟨ +-comm p n ⟩\n n + p\n ≤-∎\n\n+-mono-≤ : ∀ (m n p q : ℕ)\n → m ≤ n\n → p ≤ q\n -------------\n → m + p ≤ n + q\n+-mono-≤ m n p q m≤n p≤q =\n ≤-begin\n m + p\n ≤⟨ +-monoˡ-≤ m n p m≤n ⟩\n n + p\n ≤⟨ +-monoʳ-≤ n p q p≤q ⟩\n n + q\n ≤-∎\n\n\n", "meta": {"hexsha": "f11e62291cbeb2f22c0272e648fa915f263de5c6", "size": 1809, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/plfa/part1/InequalityReasoningExercise.agda", "max_stars_repo_name": "abolotina/plfa.github.io", "max_stars_repo_head_hexsha": "75bef9bb35643160e2d2ab4221a3057f22eb3324", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/plfa/part1/InequalityReasoningExercise.agda", "max_issues_repo_name": "abolotina/plfa.github.io", "max_issues_repo_head_hexsha": "75bef9bb35643160e2d2ab4221a3057f22eb3324", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/plfa/part1/InequalityReasoningExercise.agda", "max_forks_repo_name": "abolotina/plfa.github.io", "max_forks_repo_head_hexsha": "75bef9bb35643160e2d2ab4221a3057f22eb3324", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 14.2440944882, "max_line_length": 51, "alphanum_fraction": 0.320066335, "num_tokens": 1023, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9390248157222395, "lm_q2_score": 0.8459424373085146, "lm_q1q2_score": 0.79436094130525}} {"text": "-- A DSL example in the language Agda: \"polynomial types\"\nmodule TypeDSL where\nopen import Data.Nat using (ℕ;_+_;_*_)\n\ndata E : Set where\n Zero : E\n One : E\n Add : (x : E) -> (y : E) -> E\n Mul : (x : E) -> (y : E) -> E\n\ntwo : E\ntwo = Add One One\n\nfour : E\nfour = Mul two two\n\n-- First semantics: compute the natural number \"value\" of the expression\ncard : E -> ℕ\ncard Zero = 0\ncard One = 1\ncard (Add x y) = card x + card y\ncard (Mul x y) = card x * card y\n\ndata Empty : Set where\ndata Unit : Set where unit : Unit\ndata Either (a : Set) (b : Set) : Set where\n Left : a -> Either a b\n Right : b -> Either a b\ndata Both (a : Set) (b : Set) : Set where\n _,_ : a -> b -> Both a b\n\n-- Second semantics: compute the corresponding finite type\ntyp : E -> Set\ntyp Zero = Empty\ntyp One = Unit\ntyp (Add x y) = Either (typ x) (typ y) -- disjoint union type = sum type\ntyp (Mul x y) = Both (typ x) (typ y) -- cartesian product type = pair type\n\nBool : Set\nBool = typ two\n\nfalse : Bool\nfalse = Left unit\ntrue : Bool\ntrue = Right unit\n\nBothBoolBool : Set\nBothBoolBool = typ four\n\nex1 : BothBoolBool\nex1 = ( false , true )\n\nopen import Data.Vec as V\n\nvariable\n a b : Set\n m n : ℕ\n\nenumAdd : Vec a m -> Vec b n -> Vec (Either a b) (m + n)\nenumAdd as bs = V.map Left as ++ V.map Right bs\n\nenumMul : Vec a m -> Vec b n -> Vec (Both a b) (m * n)\nenumMul as bs = concat (V.map (\\ a -> V.map (\\ b -> (a , b)) bs) as)\n\n-- Third semantics: enumerate all the values in a vector\nenumerate : (t : E) -> Vec (typ t) (card t)\nenumerate Zero = []\nenumerate One = [ unit ]\nenumerate (Add x y) = enumAdd (enumerate x) (enumerate y)\nenumerate (Mul x y) = enumMul (enumerate x) (enumerate y)\n\ntest2 : Vec (typ two) (card two) -- Vec Bool 2\ntest2 = enumerate two\n -- false ∷ true ∷ []\n\ntest4 : Vec (typ four) (card four) -- Vec BothBoolBool 4\ntest4 = enumerate four\n{-\n(false , false) ∷\n(false , true) ∷\n(true , false) ∷\n(true , true) ∷ []\n-}\n\n-- Exercise: add a constructor for function types\n", "meta": {"hexsha": "4787ff189c69f1dced0db0a5d9886a52813a2a04", "size": 1987, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "L/01/agda/TypeDSL.agda", "max_stars_repo_name": "nicolabotta/DSLsofMath", "max_stars_repo_head_hexsha": "ce764c9bbff5a726d5cf1699a433d9921a1d6a60", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-02-24T21:27:31.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-24T21:27:31.000Z", "max_issues_repo_path": "L/01/agda/TypeDSL.agda", "max_issues_repo_name": "nicolabotta/DSLsofMath", "max_issues_repo_head_hexsha": "ce764c9bbff5a726d5cf1699a433d9921a1d6a60", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "L/01/agda/TypeDSL.agda", "max_forks_repo_name": "nicolabotta/DSLsofMath", "max_forks_repo_head_hexsha": "ce764c9bbff5a726d5cf1699a433d9921a1d6a60", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.1046511628, "max_line_length": 78, "alphanum_fraction": 0.6149974836, "num_tokens": 662, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9481545318852121, "lm_q2_score": 0.8376199694135332, "lm_q1q2_score": 0.7941931699969943}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Setoids.Setoids\nopen import Functions.Definition\nopen import Sets.EquivalenceRelations\nopen import Rings.Definition\n\nmodule Rings.Divisible.Lemmas {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} (R : Ring S _+_ _*_) where\n\nopen Setoid S\nopen Equivalence eq\nopen Ring R\nopen import Rings.Divisible.Definition R\nopen import Rings.Units.Definition R\n\ndivisionTransitive : (x y z : A) → x ∣ y → y ∣ z → x ∣ z\ndivisionTransitive x y z (a , pr) (b , pr2) = (a * b) , transitive (transitive *Associative (*WellDefined pr reflexive)) pr2\n\ndivisionReflexive : (x : A) → x ∣ x\ndivisionReflexive x = 1R , transitive *Commutative identIsIdent\n\neverythingDividesZero : (r : A) → r ∣ 0R\neverythingDividesZero r = 0R , timesZero\n\nnonzeroInherits : {x y : A} (nz : (x ∼ 0R) → False) → y ∣ x → (y ∼ 0R) → False\nnonzeroInherits {x} {y} nz (c , pr) y=0 = nz (transitive (symmetric pr) (transitive (*WellDefined y=0 reflexive) (transitive *Commutative timesZero)))\n\nnonunitInherits : {x y : A} (nonunit : Unit x → False) → x ∣ y → Unit y → False\nnonunitInherits nu (s , pr) (a , b) = nu ((s * a) , transitive (transitive *Associative (*WellDefined pr reflexive)) b)\n", "meta": {"hexsha": "70623075906105b8808b7011e1efe30267009678", "size": 1257, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Rings/Divisible/Lemmas.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Rings/Divisible/Lemmas.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Rings/Divisible/Lemmas.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 40.5483870968, "max_line_length": 150, "alphanum_fraction": 0.6825775656, "num_tokens": 432, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9381240177362488, "lm_q2_score": 0.8459424334245617, "lm_q1q2_score": 0.7935989144178289}} {"text": "data Bool : Set where\n true : Bool\n false : Bool\n\n\nnot : Bool → Bool\nnot true = false\nnot false = true\n\n\ndata ℕ : Set where\n O : ℕ\n S : ℕ → ℕ\n\n\n_+_ : ℕ → ℕ → ℕ\nO + a = a\nS a + b = S (a + b)\n\n_*_ : ℕ → ℕ → ℕ\nO * a = O\nS a * b = a + (a * b)\n\n_or_ : Bool → Bool → Bool\ntrue or _ = true\nfalse or b = b\n\n\nif_then_else_ : {A : Set} → Bool → A → A → A\nif true then x else y = x\nif false then x else y = y\n\n\ninfixl 60 _*_\ninfixl 40 _+_\ninfixr 20 _or_\ninfix 5 if_then_else_\n\n\ninfixr 40 _::_\ndata List (A : Set) : Set where\n [] : List A\n _::_ : A -> List A -> List A\n\n\n_∘_ : {A : Set} -> {B : A -> Set} -> {C : (x : A) -> B x -> Set} ->\n (f : {x : A} -> (y : B x) -> C x y) -> (g : (x : A) -> B x) ->\n (x : A) -> C x (g x)\n_∘_ f g a = f (g a)\n\n\nplus-two = S ∘ S\n\nmap : {A B : Set} -> (A -> B) -> List A -> List B\nmap f [] = []\nmap f (x :: xs) = f x :: map f xs\n\n_++_ : {A : Set} -> List A -> List A -> List A\n[] ++ ys = ys\nx :: xs ++ ys = x :: (xs ++ ys)\n\n\ndata Vec (A : Set) : ℕ -> Set where\n nil : Vec A O\n cons : (n : ℕ) -> A -> Vec A n -> Vec A (S n)\n\nhead : {A : Set} {n : ℕ} -> Vec A (S n) -> A\nhead (cons n v vs) = v\n\n\nvmap : {A B : Set} (n : ℕ) -> (A -> B) -> Vec A n -> Vec B n\nvmap .O f nil = nil\nvmap .(S n) f (cons n x xs) = cons n (f x) (vmap n f xs)\n\n\nvmap′ : {A B : Set} (n : ℕ) -> (A -> B) -> Vec A n -> Vec B n\nvmap′ O f nil = nil\nvmap′ (S n) f (cons .n x xs) = cons n (f x) (vmap n f xs)\n\n\ndata Fin : ℕ -> Set where\n fzero : {n : ℕ} -> Fin (S n)\n fsuc : {n : ℕ} -> Fin n -> Fin (S n)\n\n_!_ : {n : ℕ}{A : Set} -> Vec A n -> Fin n -> A\nnil ! ()\ncons n x a ! fzero = x\ncons n x a ! fsuc b = a ! b\n\n\n\ntabulate : {n : ℕ}{A : Set} -> (Fin n -> A) -> Vec A n\ntabulate {O} f = nil\ntabulate {S n} f = cons n (f fzero) (tabulate (f ∘ fsuc))\n\n\ndata False : Set where\nrecord True : Set where\n\n\ntrivial : True\ntrivial = _\n\n\nisTrue : Bool -> Set\nisTrue true = True\nisTrue false = False\n\n\n_<_ : ℕ -> ℕ -> Bool\n_ < O = false\nO < S n = true\nS m < S n = m < n\n\nlength : {A : Set} -> List A -> ℕ\nlength [] = O\nlength (x :: xs) = S (length xs)\n\nlookup : {A : Set}(xs : List A)(n : ℕ) -> isTrue (n < length xs) -> A\nlookup (x :: xs) O b = x\nlookup (x :: xs) (S n) b = lookup xs n b\nlookup [] a ()\n\n\ndata _==_ {A : Set}(x : A) : A -> Set where\n refl : x == x\n\n\ndata _≤_ : ℕ -> ℕ -> Set where\n ≤O : {m n : ℕ} -> m == n -> m ≤ n\n ≤I : {m n : ℕ} -> m ≤ n -> m ≤ S n\n\n\nleq-trans : {l m n : ℕ} -> l ≤ m -> m ≤ n -> l ≤ n\nleq-trans a (≤O refl) = a\nleq-trans a (≤I b) = ≤I (leq-trans a b)\n\n\nmin : ℕ -> ℕ -> ℕ\nmin a b with a < b\nmin a b | true = a\nmin a b | false = b\n\n\nfilter : {A : Set} -> (A -> Bool) -> List A -> List A\nfilter f [] = []\nfilter f (x :: xs) with f x\n... | true = x :: filter f xs\n... | false = filter f xs\n\n\ndata _≠_ : ℕ -> ℕ -> Set where\n z≠s : {n : ℕ} -> O ≠ S n\n s≠z : {n : ℕ} -> S n ≠ O\n s≠s : {m n : ℕ} -> n ≠ m → S n ≠ S m\n\n\ndata Equal? (n m : ℕ) : Set where\n eq : n == m -> Equal? n m\n neq : n ≠ m -> Equal? n m\n", "meta": {"hexsha": "08277dcd5fa4a72d9f6428edda57223223eaa22e", "size": 2998, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-tutorial/basics.agda", "max_stars_repo_name": "shouya/thinking-dumps", "max_stars_repo_head_hexsha": "a6fc111e02dc631f56302bb059d855446792bebc", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 24, "max_stars_repo_stars_event_min_datetime": "2015-02-14T17:18:34.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-09T01:02:15.000Z", "max_issues_repo_path": "agda-tutorial/basics.agda", "max_issues_repo_name": "shouya/thinking-dumps", "max_issues_repo_head_hexsha": "a6fc111e02dc631f56302bb059d855446792bebc", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2015-06-14T06:07:33.000Z", "max_issues_repo_issues_event_max_datetime": "2015-08-04T22:05:11.000Z", "max_forks_repo_path": "agda-tutorial/basics.agda", "max_forks_repo_name": "shouya/thinking-dumps", "max_forks_repo_head_hexsha": "a6fc111e02dc631f56302bb059d855446792bebc", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2015-12-02T02:10:26.000Z", "max_forks_repo_forks_event_max_datetime": "2017-06-03T06:32:26.000Z", "avg_line_length": 18.6211180124, "max_line_length": 69, "alphanum_fraction": 0.4543028686, "num_tokens": 1289, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9314625012602593, "lm_q2_score": 0.8519527944504227, "lm_q1q2_score": 0.7935620808744583}} {"text": "{-# OPTIONS --cubical #-}\nmodule ExerciseSession1 where\n\nopen import Part1 hiding (B)\n\n-- We redefine B to be a family of types in this file\nvariable\n B : A → Type ℓ\n\n-- Exercise 1: state and prove funExt for dependent functions f g : (x : A) → B x\n\n\n-- Exercise 2: generalize the type of cong to dependent function f : (x : A) → B x\n-- (hint: the result should be a PathP)\n\n\n-- Exercise 3 (easy) state and prove that inhabited propositions are contractible\n\n\n-- We could have stated isProp as follows:\nisProp' : Type ℓ → Type ℓ\nisProp' A = (x y : A) → isContr (x ≡ y)\n\n-- Exercise 4 (easy): prove that isProp' A implies isProp A\n\n-- For the converse we need path composition, see ExerciseSession2\n\n\n-- Exercise 5: prove isPropΠ\nisPropΠ : (h : (x : A) → isProp (B x)) → isProp ((x : A) → B x)\nisPropΠ h = {!!}\n\n\n-- Exercise 6: prove the inverse of funExt (sometimes called happly)\nfunExt⁻ : {f g : (x : A) → B x} → f ≡ g → ((x : A) → f x ≡ g x)\nfunExt⁻ p = {!!}\n\n\n-- Exercise 7: use funExt⁻ to prove isSetΠ\nisSetΠ : (h : (x : A) → isSet (B x)) → isSet ((x : A) → B x)\nisSetΠ h = {!!}\n\n\n-- We could have defined the type of singletons as follows\nsingl' : {A : Type ℓ} (a : A) → Type ℓ\nsingl' {A = A} a = Σ[ x ∈ A ] x ≡ a\n\n-- Exercise 8 (harder): prove the corresponding version of contractibility of singetons for singl'\n-- (hint: use a suitable combinations of connections and _~)\nisContrSingl' : (x : A) → isContr (singl' x)\nisContrSingl' x = {!!}\n", "meta": {"hexsha": "8862d2666ef1e603fca50c2d4c840b041d4b1869", "size": 1450, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "04-cubical-type-theory/material/ExerciseSession1.agda", "max_stars_repo_name": "tomdjong/EPIT-2020", "max_stars_repo_head_hexsha": "54b18e4adf890b3533bbefda373912423be7f490", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "04-cubical-type-theory/material/ExerciseSession1.agda", "max_issues_repo_name": "tomdjong/EPIT-2020", "max_issues_repo_head_hexsha": "54b18e4adf890b3533bbefda373912423be7f490", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "04-cubical-type-theory/material/ExerciseSession1.agda", "max_forks_repo_name": "tomdjong/EPIT-2020", "max_forks_repo_head_hexsha": "54b18e4adf890b3533bbefda373912423be7f490", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.8846153846, "max_line_length": 98, "alphanum_fraction": 0.6386206897, "num_tokens": 490, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9207896780646392, "lm_q2_score": 0.8615382076534742, "lm_q1q2_score": 0.7932954888656288}} {"text": "{-# OPTIONS --safe --warning=error #-}\n\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_)\nopen import LogicalFormulae\nopen import Logic.PropositionalLogic\nopen import Functions.Definition\nopen import Numbers.Naturals.Naturals\nopen import Vectors\nopen import Boolean.Definition\n\nmodule Logic.PropositionalAxiomsTautology where\n\naxiomKTaut : {a : _} {A : Set a} (P Q : Propositions A) → Tautology (implies P (implies Q P))\naxiomKTaut P Q v with inspect (Valuation.v v P)\naxiomKTaut P Q v | BoolTrue with≡ pT with inspect (Valuation.v v Q)\naxiomKTaut P Q v | BoolTrue with≡ pT | BoolTrue with≡ qT = Valuation.vImplicationT v (Valuation.vImplicationT v pT)\naxiomKTaut P Q v | BoolTrue with≡ pT | BoolFalse with≡ qF = Valuation.vImplicationT v (Valuation.vImplicationVacuous v qF)\naxiomKTaut P Q v | BoolFalse with≡ pF = Valuation.vImplicationVacuous v pF\n\naxiomSTaut : {a : _} {A : Set a} (P Q R : Propositions A) → Tautology (implies (implies P (implies Q R)) (implies (implies P Q) (implies P R)))\naxiomSTaut P Q R v with inspect (Valuation.v v P)\naxiomSTaut P Q R v | BoolTrue with≡ pT with inspect (Valuation.v v Q)\naxiomSTaut P Q R v | BoolTrue with≡ pT | BoolTrue with≡ qT with inspect (Valuation.v v R)\naxiomSTaut P Q R v | BoolTrue with≡ pT | BoolTrue with≡ qT | BoolTrue with≡ rT = Valuation.vImplicationT v (Valuation.vImplicationT v (Valuation.vImplicationT v rT))\naxiomSTaut P Q R v | BoolTrue with≡ pT | BoolTrue with≡ qT | BoolFalse with≡ rF = Valuation.vImplicationVacuous v (Valuation.vImplicationF v pT (Valuation.vImplicationF v qT rF))\naxiomSTaut P Q R v | BoolTrue with≡ pT | BoolFalse with≡ qF = Valuation.vImplicationT v (Valuation.vImplicationVacuous v (Valuation.vImplicationF v pT qF))\naxiomSTaut P Q R v | BoolFalse with≡ pF = Valuation.vImplicationT v (Valuation.vImplicationT v (Valuation.vImplicationVacuous v pF))\n\nexcludedMiddleTaut : {a : _} {A : Set a} (P : Propositions A) → Tautology (implies (prNot (prNot P)) P)\nexcludedMiddleTaut P v with inspect (Valuation.v v P)\nexcludedMiddleTaut P v | BoolTrue with≡ pT = Valuation.vImplicationT v pT\nexcludedMiddleTaut P v | BoolFalse with≡ pF = Valuation.vImplicationVacuous v (Valuation.vImplicationF v (Valuation.vImplicationVacuous v pF) (Valuation.vFalse v))\n\npropositionalAxiomsTautology : {a : _} {A : Set a} (x : Sg ThreeElements (indexAxiom A)) → Tautology (IsSubset.ofElt propositionalAxioms x)\npropositionalAxiomsTautology (One , (fst ,, snd)) = axiomKTaut fst snd\npropositionalAxiomsTautology (Two , record { one = one ; two = two ; three = three }) = axiomSTaut one two three\npropositionalAxiomsTautology (Three , b) = excludedMiddleTaut b\n", "meta": {"hexsha": "90c30892206eef26e678d1e7838542b569f76414", "size": 2635, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Logic/PropositionalAxiomsTautology.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Logic/PropositionalAxiomsTautology.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Logic/PropositionalAxiomsTautology.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 69.3421052632, "max_line_length": 178, "alphanum_fraction": 0.7563567362, "num_tokens": 892, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9372107984180245, "lm_q2_score": 0.8459424411924673, "lm_q1q2_score": 0.792826390725685}} {"text": "{-\n\n Agda Implementors' Meeting VI\n\n Göteborg\n May 24 - 30, 2007\n\n\n Hello Agda!\n\n Ulf Norell\n\n-}\n\n-- Now we're getting somewhere! Inductive families of datatypes.\n\nmodule Families where\n\n-- You can import modules defined in other files.\n-- More details later...\n--open import Naturals\n\ndata Nat : Set where\n zero : Nat\n suc : Nat -> Nat\n\ninfixl 60 _+_\ninfixl 80 _*_\n\n_+_ : Nat -> Nat -> Nat\nzero + m = m\nsuc n + m = suc (n + m)\n\n_*_ : Nat -> Nat -> Nat\nzero * m = zero\nsuc n * m = m + n * m\n\n-- Think of an inductive family...\nmodule Vec where\n\n data Vec (A : Set) : Nat -> Set where\n [] : Vec A zero\n _::_ : {n : Nat} -> A -> Vec A n -> Vec A (suc n)\n\n infixr 40 _::_\n\n -- Some simple functions\n head : {A : Set}{n : Nat} -> Vec A (suc n) -> A\n head (x :: _) = x -- no need for a [] case\n\n -- Does the definition look familiar?\n map : {A B : Set}{n : Nat} -> (A -> B) -> Vec A n -> Vec B n\n map f [] = []\n map f (x :: xs) = f x :: map f xs\n\n t1 : Vec Nat (suc (suc zero))\n t1 = map (_+_ three) (zero :: suc three :: [])\n where three = suc (suc (suc zero))\n\n infixr 40 _++_\n\n _++_ : {A : Set}{n m : Nat} -> Vec A n -> Vec A m -> Vec A (n + m)\n [] ++ ys = ys\n (x :: xs) ++ ys = x :: (xs ++ ys)\n\n{-\n\n Wait a second.. what's really going on here?\n\n All the indices were conveniently implicit!\n\n-}\n\n-- Ok. Let's make the implicit stuff explicit.\n{-\nmodule WhatsGoingOnHere? where\n\n open Vec using (Vec; []; _::_)\n-}\n\n -- Now what's this funny dot thing?\n map' : {A B : Set}(n : Nat) -> (A -> B) -> Vec A n -> Vec B n\n map' .zero f [] = []\n map' .(suc _) f (x :: xs) = f x :: map' _ f xs\n\n -- Basically the dot means: inside is not a pattern at all but a\n -- term whose value is uniquely determined by type checking\n -- the actual pattern.\n\n -- In the cases above the types of the patterns\n -- [] and (_::_ {n} x xs)\n -- forces the first argument to be zero and suc n respectively.\n -- So, that's what we write.\n\n -- We could spend hours talking about this, but let's move on...\n\n-- Let's do some other interesting families.\n\n-- The identity type.\ndata _==_ {A : Set}(x : A) : A -> Set where\n refl : x == x\n\ninfix 30 _==_\ninfix 20 ¬_\n\n-- In the presence of families we get a lot more empty types.\n\ndata Bool : Set where\n true : Bool\n false : Bool\n\ndata False : Set where\n\n¬_ : Set -> Set\n¬ A = A -> False\n\n_≠_ : {A : Set} -> A -> A -> Set\nx ≠ y = ¬ x == y\n\ntrue≠false : true == false -> False -- true ≠ false\ntrue≠false ()\n\n-- [The following example might have worked at AIM6, but it does not\n-- work now, so I commented it out. /NAD]\n\n-- lem : (n : Nat) -> n == suc n -> False\n-- lem n ()\n\n-- Why does this work: true == false is an empty type.\n\n{-\n\n What's next?\n\n-}\n\n-- Actually, inductive families are sufficiently fun that\n-- you'll never get bored, but there's even more fun to be had.\n\n-- Move on to: With.agda\n", "meta": {"hexsha": "90f5424bc47cf9440cc3e75075010a1cdc0fc0e3", "size": 2964, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "tests/covered/Families.agda", "max_stars_repo_name": "andrejtokarcik/agda-semantics", "max_stars_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-08-10T15:33:56.000Z", "max_stars_repo_stars_event_max_datetime": "2018-12-06T17:24:25.000Z", "max_issues_repo_path": "tests/covered/Families.agda", "max_issues_repo_name": "andrejtokarcik/agda-semantics", "max_issues_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tests/covered/Families.agda", "max_forks_repo_name": "andrejtokarcik/agda-semantics", "max_forks_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.0212765957, "max_line_length": 68, "alphanum_fraction": 0.5617408907, "num_tokens": 940, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9284087946129328, "lm_q2_score": 0.8539127548105611, "lm_q1q2_score": 0.7927801113982819}} {"text": "-- notes-01-monday.agda\n\nopen import Data.Nat\nopen import Data.Bool\n\nf : ℕ → ℕ\nf x = x + 2\n\n{-\n f 3 =\n = (x + 2)[x:=3] =\n = 3 + 2 =\n = 5\n-}\n\nn : ℕ\nn = 3\n\nf' : ℕ → ℕ\nf' = λ x → x + 2 -- λ function (nameless function)\n\n{-\n f' 3 =\n = (λ x → x + 2) 3 =\n = (x + 2)[x := 3] = -- β-reduction\n = 3 + 2 =\n = 5\n-}\n\ng : ℕ → ℕ → ℕ -- currying\ng = λ x → (λ y → x + y)\n\nk : (ℕ → ℕ) → ℕ\nk h = h 2 + h 3\n\n{-\n k f =\n = f 2 + f 3 = \n = (2 + 2) + (3 + 2) =\n = 4 + 5 =\n = 9\n-}\n\nvariable\n A B C : Set -- polymorphic: Set actually means \"type\"\n\nid : A → A\nid x = x\n\n_∘_ : (B → C) → (A → B) → (A → C)\nf ∘ g = λ x → f (g x)\n\n{-\n A combinator is a high-order function that uses only function application and\n other combinators.\n-}\nK : A → B → A\nK x y = x\n\nS : (A → B → C) → (A → B) → A → C\nS f g x = f x (g x)\n\n-- in combinatory logic, every pure λ-term can be translated into S,K\n-- λ x → f x = f -- η-equality\n", "meta": {"hexsha": "c67c336023212bb4794fb6565d935393e3915b29", "size": 910, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Type Theory/notes-01-monday.agda", "max_stars_repo_name": "FoxySeta/mgs-2021", "max_stars_repo_head_hexsha": "f328e596d98a7d052b34144447dd14de0f57e534", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Type Theory/notes-01-monday.agda", "max_issues_repo_name": "FoxySeta/mgs-2021", "max_issues_repo_head_hexsha": "f328e596d98a7d052b34144447dd14de0f57e534", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2021-07-14T20:34:53.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-14T20:35:48.000Z", "max_forks_repo_path": "Type Theory/notes-01-monday.agda", "max_forks_repo_name": "FoxySeta/mgs-2021", "max_forks_repo_head_hexsha": "f328e596d98a7d052b34144447dd14de0f57e534", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 14.0, "max_line_length": 79, "alphanum_fraction": 0.4516483516, "num_tokens": 418, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9241418283357702, "lm_q2_score": 0.8577681013541611, "lm_q1q2_score": 0.7926993814735367}} {"text": "{-# OPTIONS --without-K --safe #-}\nmodule Categories.Category.CMonoidEnriched where\n\n-- A category where the Homs are not sets, but commutative monoids\n-- There are weak kind of Ab-enriched.\n-- The reason to do these \"by hand\" is that the\n-- \"free commutative monoid monad\", i.e. Bag, is very hard to work\n-- with in type theory, so it is easier to work axiomatically.\n\nopen import Level\nopen import Algebra.Bundles using (CommutativeMonoid)\nopen import Function.Base using (flip)\nopen import Relation.Binary using (Rel; IsEquivalence)\n\nopen import Categories.Category.Core using (Category)\n\nrecord CM-Category (o ℓ e : Level) : Set (suc (o ⊔ ℓ ⊔ e)) where\n infix 4 _≈_ _⇒_\n infixr 9 _∘_\n infixl 7 _+_\n\n open CommutativeMonoid using (_∙_; ε) renaming (Carrier to ∣_∣)\n field\n Obj : Set o\n Hom : (A B : Obj) → CommutativeMonoid ℓ e\n\n _⇒_ : (A B : Obj) → Set ℓ\n A ⇒ B = ∣ Hom A B ∣\n\n _+_ : {A B : Obj} → A ⇒ B → A ⇒ B → A ⇒ B\n _+_ {A} {B} f g = _∙_ (Hom A B) f g\n\n 0M : {A B : Obj} → A ⇒ B\n 0M {A} {B} = ε (Hom A B)\n\n field\n _≈_ : ∀ {A B : Obj} → Rel (A ⇒ B) e\n\n id : ∀ {A} → A ⇒ A\n _∘_ : ∀ {A B C} → B ⇒ C → A ⇒ B → A ⇒ C\n\n -- The usual categorical structure\n field\n assoc : ∀ {A B C D} {f : A ⇒ B} {g : B ⇒ C} {h : C ⇒ D} → (h ∘ g) ∘ f ≈ h ∘ (g ∘ f)\n -- We add a symmetric proof of associativity so that the opposite category of the\n -- opposite category is definitionally equal to the original category. See how\n -- `op` is implemented.\n sym-assoc : ∀ {A B C D} {f : A ⇒ B} {g : B ⇒ C} {h : C ⇒ D} → h ∘ (g ∘ f) ≈ (h ∘ g) ∘ f\n identityˡ : ∀ {A B} {f : A ⇒ B} → id ∘ f ≈ f\n identityʳ : ∀ {A B} {f : A ⇒ B} → f ∘ id ≈ f\n -- We add a proof of \"neutral\" identity proof, in order to ensure the opposite of\n -- constant functor is definitionally equal to itself.\n identity² : ∀ {A} → id ∘ id {A} ≈ id {A}\n equiv : ∀ {A B} → IsEquivalence (_≈_ {A} {B})\n ∘-resp-≈ : ∀ {A B C} {f h : B ⇒ C} {g i : A ⇒ B} → f ≈ h → g ≈ i → f ∘ g ≈ h ∘ i\n\n -- preservation of additive structure\n +-resp-∘ : ∀ {A B C D} {f g : B ⇒ C} {h : A ⇒ B} {k : C ⇒ D} →\n k ∘ (f + g) ∘ h ≈ k ∘ f ∘ h + k ∘ g ∘ h\n\n 0-resp-∘ : ∀ {A C D} {h : A ⇒ C} {k : C ⇒ D} → k ∘ 0M ∘ h ≈ 0M\n\nUnderlying : {o ℓ e : Level} → CM-Category o ℓ e → Category o ℓ e\nUnderlying C = record { CM-Category C }\n", "meta": {"hexsha": "b7898c2b879b0d1675a13a8052584fec13759437", "size": 2336, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/CMonoidEnriched.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Category/CMonoidEnriched.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Category/CMonoidEnriched.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 35.9384615385, "max_line_length": 91, "alphanum_fraction": 0.5505136986, "num_tokens": 931, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9433475794701961, "lm_q2_score": 0.8397339716830606, "lm_q1q2_score": 0.7921610095861095}} {"text": "module Lec6Done where\n\nopen import Lec1Done\n\ndata List (X : Set) : Set where\n [] : List X\n _,-_ : X -> List X -> List X\ninfixr 4 _,-_\n\n-- ListF : Set -> Set -> Set\n-- ListF X T = One + (X * T)\n\nmkList : {X : Set} -> One + (X * List X) -> List X\nmkList (inl <>) = []\nmkList (inr (x , xs)) = x ,- xs\n\nfoldr : {X T : Set} -> ((One + (X * T)) -> T) -> List X -> T\nfoldr alg [] = alg (inl <>)\nfoldr alg (x ,- xs) = alg (inr (x , foldr alg xs))\n\nex1 = foldr mkList (1 ,- 2 ,- 3 ,- [])\n\nlength : {X : Set} -> List X -> Nat\nlength = foldr \\ { (inl <>) -> zero ; (inr (x , n)) -> suc n }\n\nrecord CoList (X : Set) : Set where\n coinductive\n field\n force : One + (X * CoList X)\nopen CoList\n\n[]~ : {X : Set} -> CoList X\nforce []~ = inl <>\n\n_,~_ : {X : Set} -> X -> CoList X -> CoList X\nforce (x ,~ xs) = inr (x , xs)\ninfixr 4 _,~_\n\nunfoldr : {X S : Set} -> (S -> (One + (X * S))) -> S -> CoList X\nforce (unfoldr coalg s) with coalg s\nforce (unfoldr coalg s) | inl <> = inl <>\nforce (unfoldr coalg s) | inr (x , s') = inr (x , unfoldr coalg s')\n\nex2 = unfoldr force (1 ,~ 2 ,~ 3 ,~ []~)\n\nrepeat : {X : Set} -> X -> CoList X\nrepeat = unfoldr \\ x -> inr (x , x)\n\nprefix : {X : Set} -> Nat -> CoList X -> List X\nprefix zero xs = []\nprefix (suc n) xs with force xs\nprefix (suc n) xs | inl <> = []\nprefix (suc n) xs | inr (x , xs') = x ,- prefix n xs'\n\nex2' = prefix 3 ex2\n\nrecord Stream (X : Set) : Set where\n coinductive\n field\n hdTl : X * Stream X\nopen Stream\n\nforever : {X : Set} -> X -> Stream X\nfst (hdTl (forever x)) = x\nsnd (hdTl (forever x)) = forever x\n\nunfold : {X S : Set} -> (S -> X * S) -> S -> Stream X\nfst (hdTl (unfold coalg s)) = fst (coalg s)\nsnd (hdTl (unfold coalg s)) = unfold coalg (snd (coalg s))\n", "meta": {"hexsha": "a81e60c33379366fb66e4dd5a4e41c979c4e889a", "size": 1739, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "data/github.com/pigworker/CS410-17/ecf7c3bbe9b468eb72578d05c7dd4dfa913dce44/lectures/Lec6Done.agda", "max_stars_repo_name": "ajnavarro/language-dataset", "max_stars_repo_head_hexsha": "34e2980af98ff2ded500619edce3e0907a6e9050", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "data/github.com/pigworker/CS410-17/ecf7c3bbe9b468eb72578d05c7dd4dfa913dce44/lectures/Lec6Done.agda", "max_issues_repo_name": "ajnavarro/language-dataset", "max_issues_repo_head_hexsha": "34e2980af98ff2ded500619edce3e0907a6e9050", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 91, "max_issues_repo_issues_event_min_datetime": "2019-11-11T15:41:26.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-21T04:17:18.000Z", "max_forks_repo_path": "data/github.com/pigworker/CS410-17/ecf7c3bbe9b468eb72578d05c7dd4dfa913dce44/lectures/Lec6Done.agda", "max_forks_repo_name": "ajnavarro/language-dataset", "max_forks_repo_head_hexsha": "34e2980af98ff2ded500619edce3e0907a6e9050", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 24.8428571429, "max_line_length": 67, "alphanum_fraction": 0.5238642898, "num_tokens": 688, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9184802440252812, "lm_q2_score": 0.8615382058759129, "lm_q1q2_score": 0.7913058215700114}} {"text": "open import Tutorials.Monday-Complete\nmodule Tutorials.Tuesday-Complete where\n\n-----------\n-- Pi and Sigma types\n-----------\n\nmodule Product where\n -- The open keyword opens a given module in the current namespace\n -- By default all of the public names of the module are opened\n -- The using keyword limits the imported definitions to those explicitly listed\n open Fin\n open Vec using (Vec; []; _∷_)\n open Simple using (¬_)\n\n variable\n P Q : A → Set\n\n -- Pi types: dependent function types\n -- For every x of type A, the predicate P x holds\n Π : (A : Set) → (Pred A) → Set\n Π A P = (x : A) → P x\n\n infix 5 _,_\n -- Sigma types: dependent product types, existential types\n -- For this x of type A, the predicate P x holds\n record Σ (A : Set) (P : Pred A) : Set where\n -- In the type P fst, fst refers to a previously introduced field\n constructor _,_\n field\n fst : A\n snd : P fst\n\n open Σ public\n\n -- By depending on a boolean we can use pi types to represent product types\n Π-× : Set → Set → Set\n Π-× A B = Π Bool λ where\n true → A\n false → B\n\n -- By depending on a boolean we can use sigma types to represent sum types\n Σ-⊎ : Set → Set → Set\n Σ-⊎ A B = Σ Bool λ where\n true → A\n false → B\n\n -- Use pi types to recover function types\n Π-→ : Set → Set → Set\n Π-→ A B = Π A λ where\n _ → B\n\n -- Use sigma types to recover product types\n Σ-× : Set → Set → Set\n Σ-× A B = Σ A λ where\n _ → B\n\n infix 5 _×_\n _×_ : Set → Set → Set\n _×_ = Σ-×\n\n -- 1) If we can transform the witness and\n -- 2) transform the predicate as per the transformation on the witness\n -- ⇒) then we can transform a sigma type\n map : (f : A → B) → (∀ {x} → P x → Q (f x)) → (Σ A P → Σ B Q)\n map f g (x , y) = (f x , g y)\n\n -- The syntax keyword introduces notation that can include binders\n infix 4 Σ-syntax\n Σ-syntax : (A : Set) → (A → Set) → Set\n Σ-syntax = Σ\n syntax Σ-syntax A (λ x → B) = Σ[ x ∈ A ] B\n\n example₁ : Σ ℕ EvenData\n example₁ = 0 , zero\n\n one-is-not-even : ¬ EvenData 1\n one-is-not-even ()\n\n example₂ : ¬ Π ℕ EvenData\n example₂ f = one-is-not-even (f 1)\n\n\n ¬∘ : Pred A → Pred A\n ¬∘ P = ¬_ ∘ P\n\n -- These can be proven regardless of A\n\n ¬∃⇒∀¬ : ¬ (Σ A P) → Π A (¬∘ P)\n ¬∃⇒∀¬ f x px = f (x , px)\n\n ∃¬⇒¬∀ : Σ A (¬∘ P) → ¬ Π A P\n ∃¬⇒¬∀ (a , ¬pa) f = ¬pa (f a)\n\n ∀¬⇒¬∃ : Π A (¬∘ P) → ¬ Σ A P\n ∀¬⇒¬∃ f (a , pa) = f a pa\n\n -- Works in classical, not in constructive mathematics\n postulate ¬∀⇒∃¬ : ¬ Π A P → Σ A (¬∘ P)\n\n -- Show that ≤ is antisymmetric\n ≤-≡ : n ≤ m → m ≤ n → n ≡ m\n ≤-≡ z≤n z≤n = refl\n ≤-≡ (s≤s x) (s≤s y) = cong suc (≤-≡ x y)\n\n -- By using n ≤ m instead of Fin m we can mention n in the output\n take : Vec A m → n ≤ m → Vec A n\n take xs z≤n = []\n take (x ∷ xs) (s≤s lte) = x ∷ take xs lte\n\n Fin-to-≤ : (i : Fin m) → to-ℕ i < m\n Fin-to-≤ zero = s≤s z≤n\n Fin-to-≤ (suc i) = s≤s (Fin-to-≤ i)\n\n -- Proof combining sigma types and equality\n ≤-to-Fin : n < m → Fin m\n ≤-to-Fin (s≤s z≤n) = zero\n ≤-to-Fin (s≤s (s≤s i)) = suc (≤-to-Fin (s≤s i))\n\n Fin-≤-inv : (i : Fin m) → ≤-to-Fin (Fin-to-≤ i) ≡ i\n Fin-≤-inv zero = refl\n Fin-≤-inv (suc zero) = refl\n Fin-≤-inv (suc (suc i)) = cong suc (Fin-≤-inv (suc i))\n\n ≤-Fin-inv : (lt : Σ[ n ∈ ℕ ] n < m)\n → (to-ℕ (≤-to-Fin (snd lt)) , Fin-to-≤ (≤-to-Fin (snd lt))) ≡ lt\n ≤-Fin-inv (.zero , s≤s z≤n) = refl\n ≤-Fin-inv (.(suc _) , s≤s (s≤s i)) =\n cong (map suc s≤s) (≤-Fin-inv (_ , s≤s i))\n", "meta": {"hexsha": "b40ee744f2aa1c26f6ee9a6a6943b29dde109ecc", "size": 3455, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Tutorials/Tuesday-Complete.agda", "max_stars_repo_name": "poncev/agda-bcam", "max_stars_repo_head_hexsha": "ccd2a78642e93754011deffbe85e9ef5071e4cb7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 27, "max_stars_repo_stars_event_min_datetime": "2021-09-23T17:59:21.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-03T22:53:51.000Z", "max_issues_repo_path": "Tutorials/Tuesday-Complete.agda", "max_issues_repo_name": "poncev/agda-bcam", "max_issues_repo_head_hexsha": "ccd2a78642e93754011deffbe85e9ef5071e4cb7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Tutorials/Tuesday-Complete.agda", "max_forks_repo_name": "poncev/agda-bcam", "max_forks_repo_head_hexsha": "ccd2a78642e93754011deffbe85e9ef5071e4cb7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-11-23T08:50:13.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-24T10:50:55.000Z", "avg_line_length": 26.5769230769, "max_line_length": 81, "alphanum_fraction": 0.5461649783, "num_tokens": 1419, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9372107931567176, "lm_q2_score": 0.843895106480586, "lm_q1q2_score": 0.7909076020857426}} {"text": "{-# OPTIONS --without-K #-}\n\nmodule Lecture2 where\n\nimport Basics\nopen Basics public\n\n-- Definition 2.2.3 define the identity function, and show lambda-abstraction in so doing\nid : {i : Level} {A : UU i} → A → A\nid = λ a → a -- can also use plain backslash \\ instead of lambda (as it resembles lambda?)\n\n-- Definition 2.2.4\ncomp : {i j k : Level} {A : UU i} {B : UU j} {C : UU k} → (B → C) → ((A → B) → (A → C))\ncomp = λ g f a → g(f(a)) -- the lambda extends to cover g, f and a\n_∘_ : {i j k : Level} {A : UU i} {B : UU j} {C : UU k} → (B → C) → ((A → B) → (A → C))\ng ∘ f = comp g f\n\ndata ℕ : U where\n Nzero : ℕ\n Nsucc : ℕ → ℕ\n\nadd : ℕ → ℕ → ℕ\nadd Nzero = id\nadd (Nsucc n) = Nsucc ∘ (add n)\n\n-- try some examples, hit C-c C-n (or whatever \"compute normal form\" is bound to)\n-- and try entering \"add (Nsucc Nzero) (Nsucc (Nsucc Nzero))\"\n-- you should get \"Nsucc (Nsucc (Nsucc Nzero))\"\n\n_+_ : ℕ → ℕ → ℕ\nn + m = add n m\n\n-- Exercise 2.3\nconst : {i j : Level} (A : UU i) (B : UU j) (b : B) → A → B\nconst A B b x = b\n\n-- Exercise 2.4\nPi-swap : {i j k : Level} {A : UU i} {B : UU j} {C : A → (B → UU k)} →\n ((x : A) (y : B) → C x y) → ((y : B) (x : A) → C x y)\nPi-swap f y x = f x y\n\n-- Exercise 2.5(a)\n_**_ : ℕ → (ℕ → ℕ)\nNzero ** n = Nzero\n(Nsucc m) ** n = (m ** n) + n\n\n-- Exercise 2.5(b)\n_^_ : ℕ → (ℕ → ℕ)\nm ^ Nzero = Nsucc Nzero\nm ^ (Nsucc n) = m ** (m ^ n)\n\n-- Exercise 2.5(c)\nfactorial : ℕ → ℕ\nfactorial Nzero = Nsucc Nzero\nfactorial (Nsucc m) = (Nsucc m) ** (factorial m)\n\n-- Exercise 2.6(a)\nNmax : ℕ → (ℕ → ℕ)\nNmax Nzero n = n\nNmax (Nsucc m) Nzero = Nsucc m\nNmax (Nsucc m) (Nsucc n) = Nsucc (Nmax m n)\n\n-- Exercise 2.6(b)\nNmin : ℕ → (ℕ → ℕ)\nNmin Nzero n = Nzero\nNmin (Nsucc m) Nzero = Nzero\nNmin (Nsucc m) (Nsucc n) = Nsucc (Nmin m n)\n\n-- Exercise 2.7\n-- induction: for any dependent type P over ℕ, define a section of P\n-- built out of a term in P 0 and a section of P n → P(Nsucc n)\nind-N : {i : Level} {P : ℕ → UU i} → P Nzero → ((n : ℕ) → P n → P(Nsucc n)) → ((n : ℕ) → P n)\nind-N p0 pS Nzero = p0\nind-N p0 pS (Nsucc n) = pS n (ind-N p0 pS n)\n", "meta": {"hexsha": "cd19968c3bbaea8505a2ed77d482f5390ad1bfd3", "size": 2052, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Lecture2.agda", "max_stars_repo_name": "glangmead/hott_cmu80818", "max_stars_repo_head_hexsha": "af64d808630f4f1498a75201b6ca4d74d662516b", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2018-05-03T20:32:19.000Z", "max_stars_repo_stars_event_max_datetime": "2018-09-04T02:52:25.000Z", "max_issues_repo_path": "Lecture2.agda", "max_issues_repo_name": "glangmead/hott_cmu80818", "max_issues_repo_head_hexsha": "af64d808630f4f1498a75201b6ca4d74d662516b", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2018-02-22T21:01:16.000Z", "max_issues_repo_issues_event_max_datetime": "2018-03-25T14:44:31.000Z", "max_forks_repo_path": "Lecture2.agda", "max_forks_repo_name": "glangmead/hott_cmu80818", "max_forks_repo_head_hexsha": "af64d808630f4f1498a75201b6ca4d74d662516b", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2018-02-22T19:58:46.000Z", "max_forks_repo_forks_event_max_datetime": "2018-06-25T15:05:21.000Z", "avg_line_length": 27.36, "max_line_length": 93, "alphanum_fraction": 0.5511695906, "num_tokens": 867, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9099070035949656, "lm_q2_score": 0.8688267745399465, "lm_q1q2_score": 0.7905515670647214}} {"text": "module Bin where\n\nopen import Relation.Binary.PropositionalEquality using (_≡_; refl)\n\nopen import Naturals using (ℕ; zero; suc; _+_; _*_)\n\n-- 2進数の表現\ndata Bin : Set where\n ⟨⟩ : Bin\n _O : Bin → Bin\n _I : Bin → Bin\n\n-- 2進数のインクリメント\ninc : Bin → Bin\ninc ⟨⟩ = ⟨⟩ I\ninc (b O) = b I\ninc (b I) = inc b O\n\n_ : inc (⟨⟩ I O I I) ≡ ⟨⟩ I I O O\n_ = refl\n\n_ : inc (⟨⟩ O O O O) ≡ ⟨⟩ O O O I\n_ = refl\n\n_ : inc (⟨⟩ O O O I) ≡ ⟨⟩ O O I O\n_ = refl\n\n_ : inc (⟨⟩ O O I O) ≡ ⟨⟩ O O I I\n_ = refl\n\n_ : inc (⟨⟩ O O I I) ≡ ⟨⟩ O I O O\n_ = refl\n\n_ : inc (⟨⟩ O I O O) ≡ ⟨⟩ O I O I\n_ = refl\n\n-- 自然数から2進数への変換\nto : ℕ → Bin\nto zero = ⟨⟩ O\nto (suc n) = inc (to n)\n\n_ : to 0 ≡ ⟨⟩ O\n_ = refl\n\n_ : to 1 ≡ ⟨⟩ I\n_ = refl\n\n_ : to 2 ≡ ⟨⟩ I O\n_ = refl\n\n_ : to 3 ≡ ⟨⟩ I I\n_ = refl\n\n_ : to 4 ≡ ⟨⟩ I O O\n_ = refl\n\n-- 2進数から自然数への変換\nfrom : Bin → ℕ\nfrom ⟨⟩ = zero\nfrom (b O) = 2 * (from b)\nfrom (b I) = 2 * (from b) + 1\n\n_ : from (⟨⟩ O) ≡ 0\n_ = refl\n\n_ : from (⟨⟩ I) ≡ 1\n_ = refl\n\n_ : from (⟨⟩ I O) ≡ 2\n_ = refl\n\n_ : from (⟨⟩ I I) ≡ 3\n_ = refl\n\n_ : from (⟨⟩ I O O) ≡ 4\n_ = refl\n", "meta": {"hexsha": "606ee96b5e3ea2f462c40c80253f2769611efb15", "size": 1039, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "part1/naturals/Bin.agda", "max_stars_repo_name": "akiomik/plfa-solutions", "max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z", "max_issues_repo_path": "part1/naturals/Bin.agda", "max_issues_repo_name": "akiomik/plfa-solutions", "max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "part1/naturals/Bin.agda", "max_forks_repo_name": "akiomik/plfa-solutions", "max_forks_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 13.4935064935, "max_line_length": 67, "alphanum_fraction": 0.4773820982, "num_tokens": 550, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9294404018582427, "lm_q2_score": 0.8499711699569787, "lm_q1q2_score": 0.7899975457727351}} {"text": "module Two where\n\nopen import Relation.Binary.PropositionalEquality\nopen ≡-Reasoning\n\nimport Data.Nat as ℕ\nimport Data.Nat.Properties as ℕₚ\n\nopen ℕ using (ℕ; zero; suc; _+_)\n\n-- Our language consists of constants and addition\ndata Expr : Set where\n const : ℕ → Expr\n plus : Expr → Expr → Expr\n\n-- Straightforward semantics\neval-expr : Expr → ℕ\neval-expr (const n) = n\neval-expr (plus e1 e2) = eval-expr e1 + eval-expr e2\n\n-- Tail recursive semantics\neval-expr-tail' : Expr → ℕ → ℕ\neval-expr-tail' (const n) acc = n + acc\neval-expr-tail' (plus e1 e2) acc = eval-expr-tail' e2 (eval-expr-tail' e1 acc)\n\neval-expr-tail : Expr → ℕ\neval-expr-tail e = eval-expr-tail' e 0\n\n--\n-- Task: prove that eval-expr-tail is equivalent to eval-expr.\n--\n\n-- The tail recursive evaluation does not depend on its accumulator\neval-expr-tail-correct-lemma : ∀ e acc → eval-expr-tail' e acc ≡ eval-expr-tail' e 0 + acc\neval-expr-tail-correct-lemma e acc = ?\n\n-- The tail recursive evaluation agrees with the straightforward evaluation\neval-expr-tail-correct : ∀ e → eval-expr-tail e ≡ eval-expr e\neval-expr-tail-correct e = ?\n", "meta": {"hexsha": "b51a2c434d74358d16362b57835a2b9d2f2e0774", "size": 1105, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Exercises/Two.agda", "max_stars_repo_name": "UoG-Agda/Agda101", "max_stars_repo_head_hexsha": "d9359c5bfd0eaf69efe1113945d7f3145f6b2dff", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Exercises/Two.agda", "max_issues_repo_name": "UoG-Agda/Agda101", "max_issues_repo_head_hexsha": "d9359c5bfd0eaf69efe1113945d7f3145f6b2dff", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Exercises/Two.agda", "max_forks_repo_name": "UoG-Agda/Agda101", "max_forks_repo_head_hexsha": "d9359c5bfd0eaf69efe1113945d7f3145f6b2dff", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.625, "max_line_length": 90, "alphanum_fraction": 0.7113122172, "num_tokens": 348, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9399133515091156, "lm_q2_score": 0.8397339756938819, "lm_q1q2_score": 0.7892771754705107}} {"text": "{-\n\nPart 3: Univalence and the SIP\n\n- Univalence from ua and uaβ\n- Transporting with ua (examples: ua not : Bool = Bool, ua suc : Z = Z, ...)\n- Subst using ua\n- The SIP as a consequence of ua\n- Examples of using the SIP for math and programming (algebra, data\n structures, etc.)\n\n-}\n\n{-# OPTIONS --cubical #-}\nmodule Part3 where\n\nopen import Cubical.Foundations.Prelude hiding (refl ; transport ; subst ; sym)\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Foundations.Univalence\n\nopen import Cubical.Data.Int\n\nopen import Part2 public\n\n\n-- Another key concept in HoTT/UF is the Univalence Axiom. In Cubical\n-- Agda this is provable, we hence refer to it as the Univalence\n-- Theorem.\n\n-- The univalence theorem: equivalences of types give paths of types\nua' : {A B : Type ℓ} → A ≃ B → A ≡ B\nua' = ua\n\n-- Any isomorphism of types gives rise to an equivalence\nisoToEquiv' : {A B : Type ℓ} → Iso A B → A ≃ B\nisoToEquiv' = isoToEquiv\n\n-- And hence to a path\nisoToPath' : {A B : Type ℓ} → Iso A B → A ≡ B\nisoToPath' e = ua' (isoToEquiv' e)\n\n-- ua satisfies the following computation rule\n-- This suffices to be able to prove the standard formulation of univalence.\nuaβ' : {A B : Type ℓ} (e : A ≃ B) (x : A)\n → transport (ua' e) x ≡ fst e x\nuaβ' e x = transportRefl (equivFun e x)\n\n\n\n-- Time for an example!\n\n-- Booleans\ndata Bool : Type₀ where\n false true : Bool\n\nnot : Bool → Bool\nnot false = true\nnot true = false\n\nnotPath : Bool ≡ Bool\nnotPath = isoToPath' (iso not not rem rem)\n where\n rem : (b : Bool) → not (not b) ≡ b\n rem false = refl\n rem true = refl\n\n_ : transport notPath true ≡ false\n_ = refl\n\n\n-- Another example, integers:\n\nsucPath : Int ≡ Int\nsucPath = isoToPath' (iso sucInt predInt sucPred predSuc)\n\n_ : transport sucPath (pos 0) ≡ pos 1\n_ = refl\n\n_ : transport (sucPath ∙ sucPath) (pos 0) ≡ pos 2\n_ = refl\n\n_ : transport (sym sucPath) (pos 0) ≡ negsuc 0\n_ = refl\n\n\n\n-------------------------------------------------------------------------\n-- The structure identity principle\n\n-- A more efficient version of finite multisets based on association lists\nopen import Cubical.HITs.AssocList.Base\n\n-- data AssocList (A : Type) : Type where\n-- ⟨⟩ : AssocList A\n-- ⟨_,_⟩∷_ : (a : A) (n : ℕ) (xs : AssocList A) → AssocList A\n-- per : (a b : A) (m n : ℕ) (xs : AssocList A)\n-- → ⟨ a , m ⟩∷ ⟨ b , n ⟩∷ xs ≡ ⟨ b , n ⟩∷ ⟨ a , m ⟩∷ xs\n-- agg : (a : A) (m n : ℕ) (xs : AssocList A)\n-- → ⟨ a , m ⟩∷ ⟨ a , n ⟩∷ xs ≡ ⟨ a , m + n ⟩∷ xs\n-- del : (a : A) (xs : AssocList A) → ⟨ a , 0 ⟩∷ xs ≡ xs\n-- trunc : (xs ys : AssocList A) (p q : xs ≡ ys) → p ≡ q\n\n\n-- Programming and proving is more complicated with AssocList compared\n-- to FMSet. This kind of example occurs everywhere in programming and\n-- mathematics: one representation is easier to work with, but not\n-- efficient, while another is efficient but difficult to work with.\n\n-- Solution: substitute using univalence\nsubstIso : {A B : Type ℓ} (P : Type ℓ → Type ℓ') (e : Iso A B) → P A → P B\nsubstIso P e = subst P (isoToPath e)\n\n-- Can transport for example Monoid structure from FMSet to AssocList\n-- this way, but the achieved Monoid structure is not very efficient\n-- to work with. A better solution is to prove that FMSet and\n-- AssocList are equal *as monoids*, but how to do this?\n\n-- Solution: structure identity principle (SIP)\n-- This is a very useful consequence of univalence\nopen import Cubical.Foundations.SIP\n\n{-\nsip' : {ℓ : Level} {S : Type ℓ → Type ℓ} {ι : StrEquiv S ℓ}\n (θ : UnivalentStr S ι) (A B : TypeWithStr ℓ S) → A ≃[ ι ] B → A ≡ B\nsip' = sip\n-}\n-- The tricky thing is to prove that (S,ι) is a univalent structure.\n-- Luckily we provide automation for this in the library, see for example:\n-- open import Cubical.Algebra.Monoid.Base\n\n-- Another cool application of the SIP: matrices represented as\n-- functions out of pairs of Fin's and vectors are equal as abelian\n-- groups:\nopen import Cubical.Algebra.Matrix\n", "meta": {"hexsha": "3a4671b2636af99a7a6c69d76969358acf18d42c", "size": 3977, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "04-cubical-type-theory/material/Part3.agda", "max_stars_repo_name": "tomdjong/EPIT-2020", "max_stars_repo_head_hexsha": "54b18e4adf890b3533bbefda373912423be7f490", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "04-cubical-type-theory/material/Part3.agda", "max_issues_repo_name": "tomdjong/EPIT-2020", "max_issues_repo_head_hexsha": "54b18e4adf890b3533bbefda373912423be7f490", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "04-cubical-type-theory/material/Part3.agda", "max_forks_repo_name": "tomdjong/EPIT-2020", "max_forks_repo_head_hexsha": "54b18e4adf890b3533bbefda373912423be7f490", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.2426470588, "max_line_length": 79, "alphanum_fraction": 0.6552677898, "num_tokens": 1261, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.926303724190573, "lm_q2_score": 0.8519527963298947, "lm_q1q2_score": 0.7891670480749543}} {"text": "-- Properties involving susbets and membership\n-- between sets.\n\nmodule sv20.assign2.SetTheory.Subset where\n\nopen import sv20.assign2.SetTheory.Logic\nopen import sv20.assign2.SetTheory.ZAxioms\n\nmemberEq : (x y z : 𝓢) → x ∈ y ∧ y ≡ z → x ∈ z\nmemberEq x y z (x₁ , x₂) = subs _ x₂ x₁\n\n-- Theorem 1, p. 21 (Suppes 1960)\nnotInEmpty : ∀ x → x ∉ ∅\nnotInEmpty x h = (proj₂ _ empt) x h\n\nprop-∅ : (x A : 𝓢) → x ∈ A → A ≢ ∅\nprop-∅ x A x∈A h = notInEmpty x (subs _ h x∈A)\n\nprop₂-∅ : (x : 𝓢) → ∃ (λ y → y ∈ x) → x ≢ ∅\nprop₂-∅ x h₁ h₂ = cont _ (h₂ , prop-∅ _ _ aux-p)\n where\n aux : 𝓢\n aux = proj₁ h₁\n\n aux-p : aux ∈ x\n aux-p = proj₂ _ h₁\n\n-- Theorem 3, p. 22 (Suppes 1960)\nsubsetOfItself : ∀ {x} → x ⊆ x\nsubsetOfItself _ t∈x = t∈x\n\n-- Theorem 4, p. 22 (Suppes 1960)\nequalitySubset : (x y : 𝓢) → x ⊆ y ∧ y ⊆ x → x ≡ y\nequalitySubset x y (x⊆y , y⊆x) = ext x y ((x⊆y x) , (y⊆x x))\n\n-- Theorem 6, p. 23 (Suppes 1960)\ntrans-⊆ : (x y z : 𝓢) → x ⊆ y ∧ y ⊆ z → x ⊆ z\ntrans-⊆ x y z (x⊆y , y⊆z) t t∈x = y⊆z t (x⊆y t t∈x)\n\n-- Theorem 7, p. 23 (Suppes 1960)\nnotContainedInItself : ∀ {x} → ¬ (x ⊂ x)\nnotContainedInItself (_ , x≢x) = x≢x refl\n\n-- Theorem 8, p. 23 (Suppes 1960)\nnonSymmetry-⊂ : (x y : 𝓢) (p : x ⊂ y) → ¬ (y ⊂ x)\nnonSymmetry-⊂ x y (x⊆y , x≢y) (y⊆x , _) = x≢y (equalitySubset x y (x⊆y , y⊆x))\n\n-- Theorem 10, p. 23 (Suppes 1960)\n⊂→⊆ : ∀ {x y} → x ⊂ y → x ⊆ y\n⊂→⊆ (x⊆y , _) z z∈x = x⊆y z z∈x\n\nprop-⊆ : (x A B : 𝓢) → x ∈ A → A ⊆ B → x ∈ B\nprop-⊆ x A B x₁ x₂ = i x₁\n where\n i : x ∈ A → x ∈ B\n i = x₂ _\n\n-- References\n--\n-- Suppes, Patrick (1960). Axiomatic Set Theory.\n-- The University Series in Undergraduate Mathematics.\n-- D. Van Nostrand Company, inc.\n--\n-- Enderton, Herbert B. (1977). Elements of Set Theory.\n-- Academic Press Inc.\n\n", "meta": {"hexsha": "9f558b292a09ce04aea3eff87a9268c11125288b", "size": 1733, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "proglangs-learning/Agda/sv20/assign2/SetTheory/Subset.agda", "max_stars_repo_name": "helq/old_code", "max_stars_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "proglangs-learning/Agda/sv20/assign2/SetTheory/Subset.agda", "max_issues_repo_name": "helq/old_code", "max_issues_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2020-03-10T19:20:21.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-07T15:39:48.000Z", "max_forks_repo_path": "proglangs-learning/Agda/sv20/assign2/SetTheory/Subset.agda", "max_forks_repo_name": "helq/old_code", "max_forks_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.8656716418, "max_line_length": 78, "alphanum_fraction": 0.5585689556, "num_tokens": 858, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9005297834483234, "lm_q2_score": 0.8757869900269366, "lm_q1q2_score": 0.7886722684758162}} {"text": "------------------------------------------------------------------------------\n-- Group theory properties\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule GroupTheory.PropertiesATP where\n\nopen import GroupTheory.Base\n\n------------------------------------------------------------------------------\n\npostulate leftCancellation : ∀ {a b c} → a · b ≡ a · c → b ≡ c\n{-# ATP prove leftCancellation #-}\n\npostulate rightIdentity : ∀ a → a · ε ≡ a\n{-# ATP prove rightIdentity #-}\n\npostulate rightInverse : ∀ a → a · a ⁻¹ ≡ ε\n{-# ATP prove rightInverse #-}\n\npostulate rightCancellation : ∀ {a b c} → b · a ≡ c · a → b ≡ c\n{-# ATP prove rightCancellation #-}\n\npostulate y≡x⁻¹[xy] : ∀ a b → b ≡ a ⁻¹ · (a · b)\n{-# ATP prove y≡x⁻¹[xy] #-}\n\npostulate x≡[xy]y⁻¹ : ∀ a b → a ≡ (a · b) · b ⁻¹\n{-# ATP prove x≡[xy]y⁻¹ #-}\n\npostulate rightIdentityUnique : ∀ r → (∀ a → a · r ≡ a) → r ≡ ε\n{-# ATP prove rightIdentityUnique #-}\n\n-- A more appropiate version to be used in the proofs.\npostulate rightIdentityUnique' : ∀ a r → a · r ≡ a → r ≡ ε\n{-# ATP prove rightIdentityUnique' #-}\n\npostulate leftIdentityUnique : ∀ l → (∀ a → l · a ≡ a) → l ≡ ε\n{-# ATP prove leftIdentityUnique #-}\n\n-- A more appropiate version to be used in the proofs.\npostulate leftIdentityUnique' : ∀ a l → l · a ≡ a → l ≡ ε\n{-# ATP prove leftIdentityUnique' #-}\n\npostulate\n rightInverseUnique : ∀ {a} → ∃[ r ] (a · r ≡ ε) ∧ (∀ r' → a · r' ≡ ε → r ≡ r')\n{-# ATP prove rightInverseUnique #-}\n\n-- A more appropiate version to be used in the proofs.\npostulate rightInverseUnique' : ∀ {a r} → a · r ≡ ε → a ⁻¹ ≡ r\n{-# ATP prove rightInverseUnique' #-}\n\npostulate\n leftInverseUnique : ∀ {a} → ∃[ l ] (l · a ≡ ε) ∧ (∀ l' → l' · a ≡ ε → l ≡ l')\n{-# ATP prove leftInverseUnique #-}\n\n-- A more appropiate version to be used in the proofs.\npostulate leftInverseUnique' : ∀ {a l} → l · a ≡ ε → a ⁻¹ ≡ l\n{-# ATP prove leftInverseUnique' #-}\n\npostulate ⁻¹-involutive : ∀ a → a ⁻¹ ⁻¹ ≡ a\n{-# ATP prove ⁻¹-involutive #-}\n\npostulate identityInverse : ε ⁻¹ ≡ ε\n{-# ATP prove identityInverse #-}\n\npostulate inverseDistributive : ∀ a b → (a · b) ⁻¹ ≡ b ⁻¹ · a ⁻¹\n{-# ATP prove inverseDistributive #-}\n\n-- The equation xa = b has an unique solution.\npostulate\n xa≡b-uniqueSolution : ∀ a b → ∃[ x ] (x · a ≡ b) ∧ (∀ x' → x' · a ≡ b → x ≡ x')\n{-# ATP prove xa≡b-uniqueSolution #-}\n\n-- The equation ax = b has an unique solution.\npostulate\n ax≡b-uniqueSolution : ∀ a b → ∃[ x ] (a · x ≡ b) ∧ (∀ x' → a · x' ≡ b → x ≡ x')\n{-# ATP prove ax≡b-uniqueSolution #-}\n\n-- If the square of every element is the identity, the system is\n-- commutative. From: TPTP 6.4.0 problem GRP/GRP001-2.p.\npostulate x²≡ε→comm : (∀ a → a · a ≡ ε) → ∀ {b c d} → b · c ≡ d → c · b ≡ d\n{-# ATP prove x²≡ε→comm #-}\n", "meta": {"hexsha": "a1b0b94f2c188784bd9bea34c7e109c38f49d218", "size": 2929, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/GroupTheory/PropertiesATP.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/GroupTheory/PropertiesATP.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/GroupTheory/PropertiesATP.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 33.6666666667, "max_line_length": 81, "alphanum_fraction": 0.5384090133, "num_tokens": 941, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9390248191350352, "lm_q2_score": 0.83973396967765, "lm_q1q2_score": 0.7885310389981004}} {"text": "{-# OPTIONS --warning=error --safe --without-K #-}\n\nopen import LogicalFormulae\nopen import Numbers.Naturals.Definition\n\nmodule Numbers.Naturals.Addition where\n\ninfix 15 _+N_\n_+N_ : ℕ → ℕ → ℕ\nzero +N y = y\nsucc x +N y = succ (x +N y)\n{-# BUILTIN NATPLUS _+N_ #-}\n\naddZeroRight : (x : ℕ) → (x +N zero) ≡ x\naddZeroRight zero = refl\naddZeroRight (succ x) rewrite addZeroRight x = refl\n\nprivate\n succExtracts : (x y : ℕ) → (x +N succ y) ≡ (succ (x +N y))\n succExtracts zero y = refl\n succExtracts (succ x) y = applyEquality succ (succExtracts x y)\n\nsuccCanMove : (x y : ℕ) → (x +N succ y) ≡ (succ x +N y)\nsuccCanMove x y = transitivity (succExtracts x y) refl\n\nadditionNIsCommutative : (x y : ℕ) → (x +N y) ≡ (y +N x)\nadditionNIsCommutative zero y = equalityCommutative (addZeroRight y)\nadditionNIsCommutative (succ x) zero = transitivity (addZeroRight (succ x)) refl\nadditionNIsCommutative (succ x) (succ y) = transitivity refl (applyEquality succ (transitivity (succCanMove x y) (additionNIsCommutative (succ x) y)))\n\naddingPreservesEqualityRight : {a b : ℕ} (c : ℕ) → (a ≡ b) → (a +N c ≡ b +N c)\naddingPreservesEqualityRight {a} {b} c pr = applyEquality (λ n -> n +N c) pr\naddingPreservesEqualityLeft : {a b : ℕ} (c : ℕ) → (a ≡ b) → (c +N a ≡ c +N b)\naddingPreservesEqualityLeft {a} {b} c pr = applyEquality (λ n -> c +N n) pr\n\nadditionNIsAssociative : (a b c : ℕ) → ((a +N b) +N c) ≡ (a +N (b +N c))\nadditionNIsAssociative zero b c = refl\nadditionNIsAssociative (succ a) zero c = transitivity (transitivity (applyEquality (λ n → n +N c) (applyEquality succ (addZeroRight a))) refl) (transitivity refl refl)\nadditionNIsAssociative (succ a) (succ b) c = transitivity refl (transitivity refl (transitivity (applyEquality succ (additionNIsAssociative a (succ b) c)) refl))\n\nsuccIsAddOne : (a : ℕ) → succ a ≡ a +N succ zero\nsuccIsAddOne a = equalityCommutative (transitivity (additionNIsCommutative a (succ zero)) refl)\n\ncanSubtractFromEqualityRight : {a b c : ℕ} → (a +N b ≡ c +N b) → a ≡ c\ncanSubtractFromEqualityRight {a} {zero} {c} pr = transitivity (equalityCommutative (addZeroRight a)) (transitivity pr (addZeroRight c))\ncanSubtractFromEqualityRight {a} {succ b} {c} pr rewrite additionNIsCommutative a (succ b) | additionNIsCommutative c (succ b) | additionNIsCommutative b a | additionNIsCommutative b c = canSubtractFromEqualityRight {a} {b} {c} (succInjective pr)\n\ncanSubtractFromEqualityLeft : {a b c : ℕ} → (a +N b ≡ a +N c) → b ≡ c\ncanSubtractFromEqualityLeft {a} {b} {c} pr rewrite additionNIsCommutative a b | additionNIsCommutative a c = canSubtractFromEqualityRight {b} {a} {c} pr\n", "meta": {"hexsha": "f892dbcfab15c9dc18dcc760328dc51d4dd72ce0", "size": 2597, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numbers/Naturals/Addition.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Numbers/Naturals/Addition.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Numbers/Naturals/Addition.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 51.94, "max_line_length": 246, "alphanum_fraction": 0.7035040431, "num_tokens": 911, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9532750400464604, "lm_q2_score": 0.8267118004748677, "lm_q1q2_score": 0.7880837247045609}} {"text": "module examplesPaperJFP.finn where\n\nopen import Data.Nat\n\ndata Fin : ℕ → Set where\n zero : {n : ℕ} → Fin (suc n)\n suc : {n : ℕ} (i : Fin n) → Fin (suc n)\n\nmutual\n data Even : ℕ → Set where\n 0p : Even 0\n sucp : {n : ℕ} → Odd n → Even (suc n)\n\n data Odd : ℕ → Set where\n sucp : {n : ℕ} → Even n → Odd (suc n)\n", "meta": {"hexsha": "5e0a4e41e59fa5d3c777f979ec98aa3c1a310a4f", "size": 340, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/examplesPaperJFP/finn.agda", "max_stars_repo_name": "agda/ooAgda", "max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 23, "max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z", "max_issues_repo_path": "examples/examplesPaperJFP/finn.agda", "max_issues_repo_name": "agda/ooAgda", "max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/examplesPaperJFP/finn.agda", "max_forks_repo_name": "agda/ooAgda", "max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z", "avg_line_length": 21.25, "max_line_length": 49, "alphanum_fraction": 0.5176470588, "num_tokens": 143, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9664104924150546, "lm_q2_score": 0.8152324938410784, "lm_q1q2_score": 0.7878492358057095}} {"text": "module Naturals where\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_ ; refl ; cong )\nopen Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _∎ )\n\ndata ℕ : Set where\n zero : ℕ \n suc : ℕ → ℕ\n{-# BUILTIN NATURAL ℕ #-}\n\ninfixl 6 _+_\n_+_ : ℕ → ℕ → ℕ\nzero + x = x\n(suc a) + x = suc (a + x)\n\n-- Exercise: Write the reasoning chain of 3 + 4\n_ : 3 + 4 ≡ 7\n_ = \n begin\n 3 + 4\n ≡⟨⟩\n suc (2 + 4)\n ≡⟨⟩\n suc (suc (1 + 4))\n ≡⟨⟩\n suc (suc (suc (0 + 4)))\n ≡⟨⟩\n suc (suc (suc 4))\n ≡⟨⟩\n 7\n ∎\n\ninfixl 7 _*_\n_*_ : ℕ → ℕ → ℕ\nzero * y = zero\nsuc x * y = y + (x * y)\n\n_ : 3 * 4 ≡ 12\n_ =\n begin\n 3 * 4\n ≡⟨⟩\n 4 + (2 * 4)\n ≡⟨⟩\n 4 + (4 + (1 * 4))\n ≡⟨⟩\n 4 + (4 + (4 + (0 * 4)))\n ≡⟨⟩\n 4 + (4 + (4 + (0 * 4)))\n ≡⟨⟩\n 4 + (4 + (4 + 0))\n ≡⟨⟩\n 12\n ∎\n\n_^_ : ℕ → ℕ → ℕ\nx ^ zero = 1\nx ^ suc y = x * (x ^ y)\n\n-- Kinda like minus, but not exactly\ninfixl 6 _monus_\n_monus_ : ℕ → ℕ → ℕ\nzero monus y = zero\nsuc x monus zero = suc x\nsuc x monus suc y = x monus y\n\n_ : 5 monus 3 ≡ 2\n_ =\n begin\n 5 monus 3\n ≡⟨⟩\n 4 monus 2\n ≡⟨⟩\n 3 monus 1\n ≡⟨⟩\n 2 monus 0\n ≡⟨⟩\n 2\n ∎\n\n_ : 3 monus 5 ≡ 0\n_ =\n begin\n 2 monus 4\n ≡⟨⟩\n 1 monus 3\n ≡⟨⟩\n 0 monus 2\n ≡⟨⟩\n 0 \n ∎\n\n{-# BUILTIN NATPLUS _+_ #-}\n{-# BUILTIN NATTIMES _*_ #-}\n{-# BUILTIN NATMINUS _monus_ #-}\n\ndata Bin : Set where\n -- Empty bitstring\n ⟨⟩ : Bin\n -- Append a zero\n _O : Bin → Bin\n -- Append a one\n _I : Bin → Bin\n\ninc : Bin → Bin\ninc ⟨⟩ = ⟨⟩ I\ninc (b O) = b I\ninc (b I) = (inc b) O\n\nto : ℕ → Bin\nto zero = ⟨⟩ O\nto (suc n) = inc (to n)\n\nfrom : Bin → ℕ\nfrom ⟨⟩ = zero\nfrom (b O) = from b * 2\nfrom (b I) = from b * 2 + 1\n\n-- I tried to prove these things doing some basic stuff but sadly got nowhere\n-- I probably should just read the next chapter! (lol)\n--multCommutes : (a : ℕ) → (b : ℕ) → a * b ≡ b * a\n--multCommutes zero zero = refl\n--multCommutes zero (suc b) = multCommutes zero b\n--multCommutes (suc a) zero = multCommutes a zero\n--multCommutes (suc a) (suc b) = {! cong (multCommutes a b) !}\n\n--multIsAssociative : (a : ℕ) → (b : ℕ) → (c : ℕ) → (a * b) * c ≡ a * (b * c)\n--multIsAssociative zero b c = refl\n--multIsAssociative (suc a) zero c = refl\n--multIsAssociative (suc a) (suc b) zero = refl\n--multIsAssociative (suc a) (suc b) (suc c) = {! multIsAssociative a b c !}\n\n", "meta": {"hexsha": "3a38d0b8aee32e452ebdce7ddc3a38b821096d38", "size": 2295, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Naturals.agda", "max_stars_repo_name": "GustavoMF31/upgraded-happiness", "max_stars_repo_head_hexsha": "9f81052c4c872f0e19677bf6e9710350d3acf0e5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Naturals.agda", "max_issues_repo_name": "GustavoMF31/upgraded-happiness", "max_issues_repo_head_hexsha": "9f81052c4c872f0e19677bf6e9710350d3acf0e5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Naturals.agda", "max_forks_repo_name": "GustavoMF31/upgraded-happiness", "max_forks_repo_head_hexsha": "9f81052c4c872f0e19677bf6e9710350d3acf0e5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 17.2556390977, "max_line_length": 77, "alphanum_fraction": 0.5128540305, "num_tokens": 1073, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9553191335436404, "lm_q2_score": 0.824461932846258, "lm_q1q2_score": 0.7876242593264022}} {"text": "module _ M -> Set)\n (_*_ : M -> M -> M)\n (id : M)\n (invert : M -> M)\n : Set1 where\n field\n monoid : Monoid _==_ _*_ id\n icong : ∀ {r s} -> (r == s) -> (invert r) == (invert s)\n r*ir==id : ∀ {r} -> (r * (invert r)) == id\n ir*r==id : ∀ {r} -> ((invert r) * r) == id\n\n open Monoid monoid public\n\n -- Trivial but useful equalities.\n id==r*ir : ∀ {r} -> id == (r * (invert r))\n id==r*ir = symm r*ir==id\n id==ir*r : ∀ {r} -> id == ((invert r) * r)\n id==ir*r = symm ir*r==id\n\n -- Double inverse gets back original.\n iir==r : ∀ {r} -> (invert (invert r)) == r\n iir==r {r} = trans3 iir==r*ir*iir r*ir*iir==r*id r*id==r\n where iir==r*ir*iir :\n (invert (invert r)) == (r * ((invert r) * (invert (invert r))))\n iir==r*ir*iir = trans3 r==id*r (cong id==r*ir refl) assoc\n -- assoc {r} {ir} {iir} : (r * ir) * iir == r * (ir * iir)\n -- id==r*ir : id == r * ir\n -- cong % (refl {iir}) : id * iir == (r * ir) * iir \n -- id*r==r {iir} : iir == id * iir \n -- trans3 % %% %%%% : iir == r * (ir * iir)\n r*ir*iir==r*id : (r * ((invert r) * (invert (invert r)))) == (r * id)\n r*ir*iir==r*id = cong refl r*ir==id\n\n -- Uniqueness of (left and right) inverse.\n irleftunique : ∀ {r} -> ∀ {s} -> (s * r) == id -> s == (invert r)\n irleftunique {r} {s} s*r==id = trans (symm s*r*ir==s) (s*r*ir==ir)\n where s*r*ir==ir : ((s * r) * (invert r)) == (invert r)\n s*r*ir==ir = trans (cong s*r==id refl) id*r==r\n s*r*ir==s : ((s * r) * (invert r)) == s\n s*r*ir==s = trans3 assoc (cong refl r*ir==id) r*id==r\n irrightunique : ∀ {r} -> ∀ {s} -> (r * s) == id -> s == (invert r)\n irrightunique {r} {s} r*s==id = trans (symm ir*r*s==s) (ir*r*s==ir)\n where ir*r*s==ir : ((invert r) * (r * s)) == (invert r)\n ir*r*s==ir = trans (cong refl r*s==id) r*id==r\n ir*r*s==s : ((invert r) * (r * s)) == s\n ir*r*s==s = trans3 (symm assoc) (cong ir*r==id refl) id*r==r\n", "meta": {"hexsha": "0a3a413faca02b54677ec1754d3fed592e98a988", "size": 2331, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "050-group.agda", "max_stars_repo_name": "mcmtroffaes/agda-proofs", "max_stars_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2015-08-09T22:51:55.000Z", "max_stars_repo_stars_event_max_datetime": "2016-08-17T16:15:42.000Z", "max_issues_repo_path": "050-group.agda", "max_issues_repo_name": "mcmtroffaes/agda-proofs", "max_issues_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "050-group.agda", "max_forks_repo_name": "mcmtroffaes/agda-proofs", "max_forks_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.85, "max_line_length": 79, "alphanum_fraction": 0.4804804805, "num_tokens": 900, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9449947086083138, "lm_q2_score": 0.8333245911726382, "lm_q1q2_score": 0.7874873292113295}} {"text": "-- {-# OPTIONS -v tc.size:100 #-}\n\nmodule SizedTypesMergeSort where\n\nopen import Common.Size\nopen import Common.Prelude using (Bool; true; false; if_then_else_)\nopen import Common.Product\n\nmodule Old where\n\n -- sized lists\n\n data List (A : Set) : {_ : Size} -> Set where\n [] : {size : Size} -> List A {↑ size}\n _::_ : {size : Size} -> A -> List A {size} -> List A {↑ size}\n\n -- CPS split (non-size increasing)\n\n split : {A : Set}{i : Size} -> List A {i} ->\n {C : Set} -> (List A {i} -> List A {i} -> C) -> C\n split [] k = k [] []\n split (x :: xs) k = split xs (\\ l r -> k (x :: r) l)\n\n\n module Sort (A : Set) (compare : A -> A -> {B : Set} -> B -> B -> B) where\n\n -- Andreas, 4 Sep 2008\n -- the size indices i and j should not be necessary here\n -- but without them, the termination checker does not recognise that\n -- the pattern x :: xs is equal to the term x :: xs\n -- I suspect that _::_ {∞} x xs is not equal to itself since ∞ is a term\n -- not a constructor or variable\n merge : {i j : Size} -> List A {i} -> List A {j} -> List A\n merge [] ys = ys\n merge xs [] = xs\n merge (x :: xs) (y :: ys) =\n compare x y (x :: merge xs (y :: ys))\n (y :: merge (x :: xs) ys)\n\n sort : {i : Size} -> List A {i} -> List A\n sort [] = []\n sort (x :: []) = x :: []\n sort (x :: (y :: xs)) = split xs (\\ l r -> merge (sort (x :: l))\n (sort (y :: r)))\n\nmodule New where\n\n -- sized lists\n\n data List A {i} : Set where\n [] : List A\n _::_ : {i' : Size< i} → A → List A {i'} → List A\n\n module CPS where\n\n -- CPS split (non-size increasing)\n\n split : ∀ {A i} → List A {i} →\n {C : Set} → (List A {i} → List A {i} → C) → C\n split [] k = k [] []\n split (x :: xs) k = split xs (\\ l r → k (x :: r) l)\n\n\n module Sort (A : Set) (compare : A → A → {B : Set} → B → B → B) where\n\n merge : List A → List A → List A\n merge [] ys = ys\n merge xs [] = xs\n merge (x :: xs) (y :: ys) =\n compare x y (x :: merge xs (y :: ys))\n (y :: merge (x :: xs) ys)\n\n sort : {i : Size} → List A {i} → List A\n sort [] = []\n sort (x :: []) = x :: []\n sort (x :: (y :: xs)) = split xs (\\ l r → merge (sort (x :: l))\n (sort (y :: r)))\n\n module Direct where\n\n split : ∀ {A i} → List A {i} → List A {i} × List A {i}\n split [] = [] , []\n split (x :: xs) = let l , r = split xs in (x :: r) , l\n\n\n module Sort (A : Set) (_≤_ : A → A → Bool) where\n\n merge : List A → List A → List A\n merge [] ys = ys\n merge xs [] = xs\n merge (x :: xs) (y :: ys) =\n if x ≤ y then (x :: merge xs (y :: ys))\n else (y :: merge (x :: xs) ys)\n\n sort : {i : Size} → List A {i} → List A\n sort [] = []\n sort (x :: []) = x :: []\n sort (x :: (y :: xs)) = let l , r = split xs in merge (sort (x :: l))\n (sort (y :: r))\n", "meta": {"hexsha": "1f9a904db5df2a1d8b6c5f0c63cb912de1e089f4", "size": 3122, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/SizedTypesMergeSort.agda", "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_issues_repo_path": "test/Succeed/SizedTypesMergeSort.agda", "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/Succeed/SizedTypesMergeSort.agda", "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "avg_line_length": 31.22, "max_line_length": 76, "alphanum_fraction": 0.4263292761, "num_tokens": 979, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8991213664574069, "lm_q2_score": 0.8757869851639066, "lm_q1q2_score": 0.7874387908261845}} {"text": "open import Relation.Binary.Core\n\nmodule InsertSort.Impl2.Correctness.Permutation.Base {A : Set}\n (_≤_ : A → A → Set)\n (tot≤ : Total _≤_) where\n\nopen import Bound.Lower A\nopen import Bound.Lower.Order _≤_\nopen import Data.List\nopen import Data.Sum\nopen import InsertSort.Impl2 _≤_ tot≤\nopen import List.Permutation.Base A\nopen import OList _≤_\n\nlemma-forget-insert : {b : Bound} → (x : A) → (b≤x : LeB b (val x)) → (xs : OList b) → forget (insert b≤x xs) / x ⟶ forget xs\nlemma-forget-insert x b≤x onil = /head\nlemma-forget-insert x b≤x (:< {x = y} b≤y ys) \n with tot≤ x y\n... | inj₁ x≤y = /head\n... | inj₂ y≤x = /tail (lemma-forget-insert x (lexy y≤x) ys)\n\ntheorem-insertSort∼ : (xs : List A) → xs ∼ forget (insertSort xs)\ntheorem-insertSort∼ [] = ∼[]\ntheorem-insertSort∼ (x ∷ xs) = ∼x /head (lemma-forget-insert x lebx (insertSort xs)) (theorem-insertSort∼ xs)\n", "meta": {"hexsha": "1e6220ecb2344163c905f2b03863fddd78699e5e", "size": 899, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/InsertSort/Impl2/Correctness/Permutation/Base.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/InsertSort/Impl2/Correctness/Permutation/Base.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/InsertSort/Impl2/Correctness/Permutation/Base.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.96, "max_line_length": 125, "alphanum_fraction": 0.6418242492, "num_tokens": 318, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9496693702514737, "lm_q2_score": 0.8289388040954683, "lm_q1q2_score": 0.7872177920623531}} {"text": "{-# OPTIONS --cubical #-}\nmodule SolutionsSession1 where\n\nopen import Part1 hiding (B)\n\nvariable\n B : A → Type ℓ\n\n-- Solutions to ExerciseSession1\n\n-- Exercise 1:\nfunExtDep : {f g : (x : A) → B x}\n → ((x : A) → f x ≡ g x)\n → f ≡ g\nfunExtDep p i x = p x i\n\n-- Exercise 2:\ncongP : {x y : A} {B : A → Type ℓ'}\n (f : (a : A) → B a) (p : x ≡ y) →\n PathP (λ i → B (p i)) (f x) (f y)\ncongP f p i = f (p i)\n\n-- Exercise 3:\nisContrInhProp : isProp A → A → isContr A\nisContrInhProp p x = x , p x\n\n\n-- We could have stated isProp as follows:\nisProp' : Type ℓ → Type ℓ\nisProp' A = (x y : A) → isContr (x ≡ y)\n\n-- Exercise 4:\nisProp'→isProp : isProp' A → isProp A\nisProp'→isProp h = λ x y → h x y .fst\n\n-- Exercise 5:\nisPropΠ : (h : (x : A) → isProp (B x)) → isProp ((x : A) → B x)\nisPropΠ h p q i x = h x (p x) (q x) i\n\n-- Exercise 6:\nfunExt⁻ : {f g : (x : A) → B x} → f ≡ g → ((x : A) → f x ≡ g x)\nfunExt⁻ eq x i = eq i x\n\n-- Exercise 7:\nisSetΠ : (h : (x : A) → isSet (B x)) → isSet ((x : A) → B x)\nisSetΠ h f g p q i j x = h x (f x) (g x) (funExt⁻ p x) (funExt⁻ q x) i j\n\n\n-- We could have defined the type of singletons as follows\nsingl' : {A : Type ℓ} (a : A) → Type ℓ\nsingl' {A = A} a = Σ[ x ∈ A ] x ≡ a\n\n-- Exercise 8:\nisContrSingl' : (x : A) → isContr (singl' x)\nisContrSingl' x = ctr , prf\n where\n ctr : singl' x\n ctr = x , refl\n\n prf : (s : singl' x) → ctr ≡ s\n prf (y , pax) i = (pax (~ i)) , λ j → pax (~ i ∨ j)\n", "meta": {"hexsha": "964c6e4e0b22728db2f86ea5d9621872df96fb8b", "size": 1449, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "04-cubical-type-theory/material/SolutionsSession1.agda", "max_stars_repo_name": "williamdemeo/EPIT-2020", "max_stars_repo_head_hexsha": "19d72759e18e05d2c509f62d23a998573270140c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 97, "max_stars_repo_stars_event_min_datetime": "2021-03-19T14:13:37.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-15T13:58:25.000Z", "max_issues_repo_path": "04-cubical-type-theory/material/SolutionsSession1.agda", "max_issues_repo_name": "williamdemeo/EPIT-2020", "max_issues_repo_head_hexsha": "19d72759e18e05d2c509f62d23a998573270140c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2021-03-31T18:27:23.000Z", "max_issues_repo_issues_event_max_datetime": "2021-04-13T09:03:56.000Z", "max_forks_repo_path": "04-cubical-type-theory/material/SolutionsSession1.agda", "max_forks_repo_name": "williamdemeo/EPIT-2020", "max_forks_repo_head_hexsha": "19d72759e18e05d2c509f62d23a998573270140c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 14, "max_forks_repo_forks_event_min_datetime": "2021-03-19T12:36:53.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-22T19:37:21.000Z", "avg_line_length": 23.3709677419, "max_line_length": 72, "alphanum_fraction": 0.5175983437, "num_tokens": 638, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9136765257642905, "lm_q2_score": 0.8615382058759129, "lm_q1q2_score": 0.7871672347579042}} {"text": "module z04-lists where\n\nopen import bool\nopen import eq\nopen import nat\nopen import nat-thms\nopen import product-thms using (keep)\nopen import logic -- needed for filter-idem\n\n{-\n-- p 75\n\n'data' : datatype declaration\n'𝕃' : name of type being declared\n{ℓ} : level\nA : element type (polymorphic)\n\n𝕃 is a type level function\n- takes a type (bound to 'A') - at level ℓ\n- returns a type - at level same level ℓ\n-}\n\ndata 𝕃 {ℓ} (A : Set ℓ) : Set ℓ where\n [] : 𝕃 A\n _::_ : (x : A) (xs : 𝕃 A) → 𝕃 A\n\n-- from lists.agda\n\n[_] : ∀ {ℓ} {A : Set ℓ} → A → 𝕃 A\n[ x ] = x :: []\n\n-- p 77\n\nlength : ∀ {ℓ} {A : Set ℓ } → 𝕃 A → ℕ\nlength [] = 0\nlength (x :: xs) = suc (length xs)\n\n-- 78\n\n_++_ : ∀ {ℓ} {A : Set ℓ} → 𝕃 A → 𝕃 A → 𝕃 A\n[] ++ ys = ys\n(x :: xs) ++ ys = x :: (xs ++ ys)\n\n-- 79\n\nmap : ∀ {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} → (A → B) → 𝕃 A → 𝕃 B\nmap f [] = []\nmap f (x :: xs) = f x :: map f xs\n\n-- 80\n\nfilter : ∀ {ℓ} {A : Set ℓ} → (A → 𝔹) → 𝕃 A → 𝕃 A\nfilter p [] = []\nfilter p (x :: xs) = if p x then x :: r else r\n where\n r = filter p xs\n\n-- p 81\n\nremove : ∀ {ℓ} {A : Set ℓ} (eq : A → A → 𝔹) (a : A) (l : 𝕃 A) → 𝕃 A\nremove eq a l = filter (λ x → ~ (eq a x)) l\n\n-- p 82\n\ndata maybe {ℓ} (A : Set ℓ) : Set ℓ where\n just : A → maybe A\n nothing : maybe A\n\nnth : ∀ {ℓ} {A : Set ℓ} → ℕ → 𝕃 A → maybe A\nnth _ [] = nothing\nnth 0 (x :: xs) = just x\nnth (suc n) (x :: xs) = nth n xs\n\n-- p 83\n\n-- inefficient\nsreverse : ∀ {ℓ} {A : Set ℓ} → 𝕃 A → 𝕃 A\nsreverse [] = []\nsreverse (h :: t) = sreverse t ++ [ h ]\n\nreverse-helper : ∀ {ℓ}{A : Set ℓ} → 𝕃 A → 𝕃 A → 𝕃 A\nreverse-helper h [] = h\nreverse-helper h (x :: xs) = reverse-helper (x :: h) xs\n\nreverse : ∀ {ℓ} {A : Set ℓ} → 𝕃 A → 𝕃 A\nreverse l = reverse-helper [] l\n\n------------------------------------------------------------------------------\n-- p 84 Reasong about List Operations\n\nlength-++ : ∀ {ℓ}{A : Set ℓ} (l1 l2 : 𝕃 A)\n → length (l1 ++ l2) ≡ length l1 + length l2\nlength-++ [] l2 -- length ([] ++ l2) ≡ length [] + length l2\n -- length l2 ≡ length l2\n = refl\nlength-++ (x :: xs) l2 -- length ((x :: xs) ++ l2) ≡ length (x :: xs) + length l2\n -- suc (length (xs ++ l2)) ≡ suc (length xs + length l2)\n -- |\n rewrite -- IH ≡\n -- v\n length-++ xs l2 -- suc (length xs + length l2) ≡ suc (length xs + length l2)\n = refl\n\n-- p 86\n\n++-assoc : ∀ {ℓ} {A : Set ℓ} (l1 l2 l3 : 𝕃 A)\n → (l1 ++ l2) ++ l3\n ≡ l1 ++ (l2 ++ l3)\n++-assoc [] l2 l3 -- (([] ++ l2) ++ l3) ≡ ([] ++ (l2 ++ l3))\n -- (l2 ++ l3) ≡ (l2 ++ l3)\n = refl\n++-assoc (x :: xs) l2 l3 -- (((x :: xs) ++ l2) ++ l3) ≡ ((x :: xs) ++ (l2 ++ l3))\n -- (x :: ((xs ++ l2) ++ l3)) ≡ (x :: (xs ++ (l2 ++ l3)))\n rewrite -- IH v\n ++-assoc xs l2 l3 -- (x :: (xs ++ (l2 ++ l3))) ≡ (x :: (xs ++ (l2 ++ l3)))\n = refl\n\n{-\n------------------------------------------------------------------------------\n-- p 87 - WITH\n\nfor\n- any type A (of any level),\n- any predicate p on A\n- any list of A\nthe length of the list after filtering l with p\n<=\nlength of l\n-}\n\nlength-filter : ∀ {ℓ} {A : Set ℓ} (p : A → 𝔹) (l : 𝕃 A)\n → length (filter p l) ≤ length l ≡ tt\n\n-- proof case-splits input list\n\nlength-filter p [] -- length (filter p []) ≤ length [] ≡ tt\n -- 0 ≤ 0 ≡ tt\n = refl\n\n-- Consider cases where predicate returns tt or ff.\n-- The predicate return value is NOT an input to length-filter.\n-- WITH : extend pattern on left side with an additional pattern, here : | tt and | ff\n\nlength-filter p (x :: l) with p x\nlength-filter p (x :: l) | tt -- length (filter p l) < length l\n -- || length (filter p l) =ℕ length l ≡ tt\n = length-filter p l -- IH\nlength-filter p (x :: l) | ff -- length (filter p l) < suc (length l)\n = -- || length (filter p l) =ℕ suc (length l) ≡ tt\n ≤-trans {length (filter p l)}\n (length-filter p l) -- IH\n (≤-suc (length l)) -- ≤-suc proves length l ≤ suc (length l)\n\n{- this is to see the goal for the non-nil case\nlf : ∀ {ℓ} {A : Set ℓ} (p : A → 𝔹) (l : 𝕃 A)\n → length (filter p l) ≤ length l ≡ tt\nlf p [] = refl\nlf p (x :: l) -- length (filter p (x :: l)) ≤ length (x :: l) ≡ tt\n -- length (if p x then x :: filter p l else filter p l) ≤ suc (length l) ≡ tt\n = {!!}\n\n------------------------------------------------------------------------------\n-- p 90 KEEP (called INSPECT in Agda standard library)\n\nfiltering a list twice using same predicate gives the same result as filtering it once\n\ncannot use WITH because Agda only applies the p ≡ tt to the goal once, not the next iteration\n(see page 92 for more details)\n\n'with keep (p x)' : make additional variable (here p') available\n-}\n\nfilter-idem : ∀ {ℓ} {A : Set ℓ} (p : A → 𝔹) (l : 𝕃 A)\n → (filter p (filter p l)) ≡ (filter p l)\nfilter-idem p [] -- filter p (filter p []) ≡ filter p []\n -- [] ≡ []\n = refl\n{-\nfilter-idem p (x :: l) -- filter p (filter p (x :: l)) ≡ filter p (x :: l)\n --\n -- filter p (if p x then x :: filter p l else filter p l)\n -- ≡ if p x then x :: filter p l else filter p l\n = {!!}\n-}\nfilter-idem p (x :: l) with keep (p x)\n\nfilter-idem p (x :: l) | tt , p' -- filter p (if p x then x :: filter p l else filter p l)\n -- ≡ if p x then x :: filter p l else filter p l\n\n rewrite\n -- agda does not instantiate 'p x' in goal\n -- must explicit use it below to change 'p x' to 'tt' (or 'ff' further below)\n\n p' -- filter p (if tt then x :: filter p l else filter p l)\n -- ≡ if tt then x :: filter p l else filter p l\n --\n -- if p x then x :: filter p (filter p l) else filter p (filter p l)\n -- ≡ (x :: filter p l)\n\n -- use it again to eliminate the if\n\n | p' -- if tt then x :: filter p (filter p l) else filter p (filter p l)\n -- ≡ (x :: filter p l)\n --\n -- (x :: filter p (filter p l)) ≡ (x :: filter p l)\n\n\n | filter-idem p l -- (x :: filter p l) ≡ (x :: filter p l)\n = refl\n\nfilter-idem p (x :: l) | ff , p' -- filter p (if p x then x :: filter p l else filter p l)\n -- ≡ if p x then x :: filter p l else filter p l\n\n rewrite p' -- filter p (if ff then x :: filter p l else filter p l)\n -- ≡ if ff then x :: filter p l else filter p l\n --\n -- filter p (filter p l) ≡ filter p l\n = filter-idem p l\n\n{-\n------------------------------------------------------------------------------\n-- p 93\n\nreverse-helper args\n- reverse of the list processed so far\n- rest of list to be reversed\n\ntricky to figure out what general property of reverse-helper to prove\n-length of reverse-helper h l is sum of lengths of h and l\n-}\n\nlength-reverse-helper\n : ∀ {ℓ} {A : Set ℓ} (h l : 𝕃 A)\n → length (reverse-helper h l) ≡ length h + length l\n\nlength-reverse-helper h [] -- length (reverse-helper h []) ≡ length h + length []\n -- length h ≡ length h + 0\n rewrite\n +comm (length h) 0 -- length h ≡ length h\n -- also can do via\n -- rewrite +0 (length h) = refl\n = refl\nlength-reverse-helper h (x :: xs)\n -- length (reverse-helper h (x :: xs)) ≡ length h + length (x :: xs)\n -- length (reverse-helper (x :: h) xs) ≡ length h + suc (length xs)\n rewrite\n length-reverse-helper (x :: h) xs -- IH -- suc (length h + length xs) ≡ length h + suc (length xs)\n | +suc (length h) (length xs) -- suc (length h + length xs) ≡ suc (length h + length xs)\n = refl\n\nlength-reverse : ∀ {ℓ} {A : Set ℓ} (l : 𝕃 A)\n → length (reverse l) ≡ length l\nlength-reverse l = length-reverse-helper [] l\n\n{-\n------------------------------------------------------------------------------\n-- p 95 conclusion : WITH and KEEP (aka INSPECT)\n\n-- p 96 EXERCISES\n\n-- 1\n-}\n\n-------------------------\n-- NOT TRUE\n-- 1a : ∀ {ℓ} {A : Set ℓ} (l1 l2 : 𝕃 A) → l1 ++ l2 ≡ l2 ++ l1\n\n-------------------------\n-- NOT TRUE\n-- 1b : ∀ {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} (f : A → B) (l : 𝕃 A) → length (map f l) ≡ suc (length l)\n\n-------------------------\n-- 1c: TRUE\n\nrepeat : ∀ {ℓ} {A : Set ℓ} → ℕ → A → 𝕃 A\nrepeat 0 a = []\nrepeat (suc n) a = a :: (repeat n a)\n\n1c : ∀ {ℓ} {A : Set ℓ} {p : A → 𝔹} {a : A} (n : ℕ)\n → p a ≡ ff\n → filter p (repeat n a) ≡ []\n1c 0 prop -- filter p (repeat zero a) ≡ []\n -- [] ≡ []\n = refl\n1c (suc n) prop -- filter p (repeat (suc n) a) ≡ []\n -- if p a then a :: filter p (repeat n a) else filter p (repeat n a) ≡ []\n rewrite\n prop -- if ff then a :: filter p (repeat n a) else filter p (repeat n a) ≡ []\n -- filter p (repeat n a) ≡ []\n = 1c n prop -- IH\n\n-------------------------\n-- NOT TRUE\n-- 1d : ∀ {ℓ} {A : Set ℓ} (l : 𝕃 A) → is-empty l ≡ tt → is-empty (reverse l) ≡ ff\n\n-------------------------\n-- TRUE\n1e : ∀ {ℓ} {A : Set ℓ} (p : A -> 𝔹) (l1 l2 : 𝕃 A)\n → filter p (l1 ++ l2)\n ≡ filter p l1 ++ filter p l2\n1e p [] l2 -- filter p ([] ++ l2) ≡ (filter p [] ++ filter p l2)\n -- filter p l2 ≡ filter p l2\n = refl\n1e p (x :: xs) l2 with keep (p x)\n1e p (x :: xs) l2 | tt , p' -- if p x then x :: filter p (xs ++ l2) else filter p (xs ++ l2)\n -- ≡ ((if p x then x :: filter p xs else filter p xs) ++ filter p l2)\n rewrite\n p' -- if tt then x :: filter p (xs ++ l2) else filter p (xs ++ l2)\n -- ≡ ((if tt then x :: filter p xs else filter p xs) ++ filter p l2)\n --\n -- (x :: filter p (xs ++ l2))\n -- ≡ (x :: (filter p xs ++ filter p l2))\n\n | 1e p xs l2 -- (x :: (filter p xs ++ filter p l2))\n -- ≡ (x :: (filter p xs ++ filter p l2))\n = refl\n1e p (x :: xs) l2 | ff , p' -- if p x then x :: filter p (xs ++ l2) else filter p (xs ++ l2)\n -- ≡ ((if p x then x :: filter p xs else filter p xs) ++ filter p l2)\n rewrite\n p' -- if ff then x :: filter p (xs ++ l2) else filter p (xs ++ l2)\n -- ≡ ((if ff then x :: filter p xs else filter p xs) ++ filter p l2)\n --\n -- filter p (xs ++ l2) ≡ (filter p xs ++ filter p l2)\n = 1e p xs l2 -- IH\n\n--------------------------------------------------\n-- 2\n\n-------------------------\n-- 2a [] : 𝕃 Set (𝕃 _A_277)\n\n-------------------------\n2b : ∀ {ℓ} {A : Set ℓ} → 𝕃 A → ℕ\n2b [] = 0\n2b (x :: xs) = suc (2b xs)\n\n-------------------------\n-- Note: 2ci does not explicitly give ℓ\n-- Note: some other answers are probably OK - did not check\n2c : ∀ {ℓ} {A : Set ℓ} {B : Set ℓ} {C : Set ℓ}\n → (A → B)\n → (B → C)\n → 𝕃 A\n → 𝕃 C\n2c f g x = map g (map f x)\n\n--------------------------------------------------\n-- 3\n\ntakeWhile : ∀ {ℓ} {A : Set ℓ} → (A → 𝔹) -> 𝕃 A → 𝕃 A\ntakeWhile p [] = []\ntakeWhile p (x :: xs) = if p x then x :: takeWhile p xs else takeWhile p xs\n\n--------------------------------------------------\n-- 4\n\n4twr : ∀ {ℓ} {A : Set ℓ} {p : A → 𝔹} {a : A} (n : ℕ)\n → p a ≡ tt\n → takeWhile p (repeat n a) ≡ repeat n a\n4twr zero p -- takeWhile p₁ (repeat zero a) ≡ repeat zero a\n -- [] ≡ []\n = refl\n4twr {l} {A} {pred} {a} (suc n) p -- takeWhile p₁ (repeat (suc n) a) ≡ repeat (suc n) a\n -- if p₁ a then a :: takeWhile p₁ (repeat n a) else takeWhile p₁ (repeat n a)\n -- ≡ (a :: repeat n a)\n rewrite\n p -- if tt then a :: takeWhile p₁ (repeat n a) else takeWhile p₁ (repeat n a)\n -- ≡ (a :: repeat n a)\n -- (a :: takeWhile p₁ (repeat n a))\n -- ≡ (a :: repeat n a)\n | 4twr {l} {A} {pred} {a} n p -- (a :: repeat n a) ≡ (a :: repeat n a)\n = refl\n\n--------------------------------------------------\n-- 5\n\ntake : ∀ {ℓ} {A : Set ℓ} → ℕ → 𝕃 A → 𝕃 A\ntake 0 _ = []\ntake _ [] = []\ntake (suc n) (x :: xs) = x :: take n xs\n\n--------------------------------------------------\n-- 6\n\nnthTail : ∀ {ℓ} {A : Set ℓ} → ℕ → 𝕃 A → 𝕃 A\nnthTail 0 xs = xs\nnthTail _ [] = []\nnthTail (suc n) (x :: xs) = nthTail n xs\n{-\n6tn : ∀ {ℓ} {A : Set ℓ} {a : A} (n : ℕ) (l : 𝕃 A)\n → take n l ++ nthTail n l ≡ l\n6tn zero l -- (take zero l ++ nthTail zero l) ≡ l\n -- l ≡ l\n = refl\n6tn {ℓ} {A} {a} (suc n) l -- (take (suc n) l ++ nthTail (suc n) l) ≡ l\n rewrite\n 6tn {ℓ} {A} {a} n l\n = {!!}\n-}\n\n6tn : ∀ {ℓ} {A : Set ℓ} {a : A} (n : ℕ) (l : 𝕃 A)\n → take n l ++ nthTail n l ≡ l\n6tn zero [] -- (take zero [] ++ nthTail zero []) ≡ []\n -- [] ≡ []\n = refl\n6tn (suc n) [] -- (take (suc n) [] ++ nthTail (suc n) []) ≡ []\n -- [] ≡ []\n = refl\n6tn zero (x :: xs) -- (take zero (x :: xs) ++ nthTail zero (x :: xs)) ≡ (x :: xs)\n -- (x :: xs) ≡ (x :: xs)\n = refl\n6tn {ℓ} {A} {a} (suc n) (x :: xs) -- (take (suc n) (x :: xs) ++ nthTail (suc n) (x :: xs)) ≡ (x :: xs)\n -- (x :: (take n xs ++ nthTail n xs)) ≡ (x :: xs)\n rewrite\n 6tn {ℓ} {A} {a} n xs -- (x :: xs) ≡ (x :: xs)\n = refl\n", "meta": {"hexsha": "ff6fb52052a86db45f26d510887608f0182e603c", "size": 15284, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z04-lists.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z04-lists.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z04-lists.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 36.6522781775, "max_line_length": 115, "alphanum_fraction": 0.3800706621, "num_tokens": 4834, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9173026595857203, "lm_q2_score": 0.8577680977182186, "lm_q1q2_score": 0.7868329573447059}} {"text": "{-\n Copyright 2019 Lisandra Silva\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n-}\n\nopen import Prelude\nopen import Data.Nat.Divisibility\n\nopen import StateMachineModel\n\n\n{-\n This State Machine begins in a state equal to 0 or 1 and if :\n - The current state s is Even then jump to state (s + 2)\n - The current state is Odd jump to state (s + 1)\n\n We want to prove that a state s always leads-to a state Even\n-}\n\nmodule Examples.SMCounterEven where\n\n -- DEFINITIONS and proofs about Even and Odd\n Even : ℕ → Set\n Even n = 2 ∣ n\n\n Odd : ℕ → Set\n Odd = ¬_ ∘ Even\n\n even? : (n : ℕ) → Dec (Even n)\n even? n = 2 ∣? n\n\n evenK⇒even2+K : ∀ {k} → Even k → Even (2 + k)\n evenK⇒even2+K (divides q₁ refl) = divides (1 + q₁) refl\n\n\n -- The following are mutually recursive properties.\n oddK⇒even1+K : ∀ {k} → Odd k → Even (suc k)\n oddK⇒evenK-1 : ∀ {k} → Odd k → Even (pred k)\n\n oddK⇒even1+K {zero} x = ⊥-elim (x (divides 0 refl))\n oddK⇒even1+K {suc k} x = evenK⇒even2+K (oddK⇒evenK-1 x)\n\n oddK⇒evenK-1 {zero} x = ⊥-elim (x (divides 0 refl))\n oddK⇒evenK-1 {suc k} x with even? k\n ...| no imp = ⊥-elim (x (oddK⇒even1+K imp))\n ...| yes prf = prf\n\n\n odd1 : Odd 1\n odd1 (divides zero ())\n odd1 (divides (suc q₁) ())\n\n\n -----------------------------------------------------------------------------\n -- SPECIFICATION\n -----------------------------------------------------------------------------\n\n data MyEvent : Set where\n inc : MyEvent\n inc2 : MyEvent\n -- TODO : Try with an event iddle that doesn't do anything and is in another\n -- EventSet in the weakFairness relation (just to try)\n\n -- If we are in a state that is odd then the enabled event is inc\n -- otherwise the enabled event is inc2\n data MyEnabled : MyEvent → ℕ → Set where\n odd : ∀ {n} → Odd n → MyEnabled inc n\n even : ∀ {n} → Even n → MyEnabled inc2 n\n\n MyStateMachine : StateMachine ℕ MyEvent\n MyStateMachine = record\n { initial = (0 ≡_) ∪ (1 ≡_)\n ; enabled = MyEnabled\n ; action = λ { {pre} {inc} cond → 1 + pre\n ; {pre} {inc2} cond → 2 + pre }\n }\n\n MyEventSet : EventSet {Event = MyEvent}\n MyEventSet inc = ⊤\n MyEventSet inc2 = ⊤\n\n data MyWeakFairness : EventSet → Set where\n wf : MyWeakFairness MyEventSet\n\n MySystem : System ℕ MyEvent\n MySystem = record\n { stateMachine = MyStateMachine\n ; weakFairness = MyWeakFairness\n }\n\n\n\n -----------------------------------------------------------------------------\n -- PROOFS\n -----------------------------------------------------------------------------\n\n open LeadsTo ℕ MyEvent MySystem\n\n -- In every state there is always an enabled transition\n alwaysEnabled : ∀ (s : ℕ) → enabledSet MyStateMachine MyEventSet s\n alwaysEnabled s with even? s\n ... | yes p = inc2 , tt , even p\n ... | no ¬p = inc , tt , odd ¬p\n\n\n -- Any state n leads to an Even state\n progressEven : ∀ {n : ℕ} → (n ≡_) l-t Even\n progressEven = viaEvSet\n MyEventSet wf\n (λ { inc ⊤ → hoare λ { refl (odd x) → oddK⇒even1+K x }\n ; inc2 ⊤ → hoare λ { refl (even x) → evenK⇒even2+K x } })\n (λ { inc ⊥ → ⊥-elim (⊥ tt)\n ; inc2 ⊥ → ⊥-elim (⊥ tt) })\n λ {s} rs n≡s → alwaysEnabled s\n\n\n -- QUESTION : Although we don't have weakfairness (WF) on event inc it was\n -- possible to prove this.\n -- ANSWER : This is because of the 2nd constraint in the viaEvSet constructor:\n -- - ∀ event e ∉ WF (in this case only inc) → [P] e [P ∪ Q], in this case\n -- we achieve Q (Even), because the event inc is enabled only in Odd states.\n\n\n -- REFACTOR: Maybe m is the one that should be explicit\n myWFR : ∀ {m} → ℕ → Z → Set\n myWFR {m} d s = m ≡ d + s\n\n\n -- For every m and even state s, or s is greater than m or there is a distance\n -- x between s and m\n [Q∪Fx] : ∀ {m} → (s : Z) → Even s\n → (m ≤ s × Even s) ⊎ ∃[ x ] myWFR {m} x s\n [Q∪Fx] {m} s sEven with m ≤? s\n ... | yes m≤s = inj₁ (m≤s , sEven)\n ... | no s s m ∩ Even s₁, because or we increment 1 if s is odd or we\n -- increment 2 if s is even.\n d≡0⇒Q : ∀ {m}\n → myWFR {m} 0\n l-t\n ( (m ≤_) ∩ Even )\n d≡0⇒Q {m} = viaEvSet\n MyEventSet wf\n (λ { inc ⊤\n → hoare λ { refl (odd x)\n → m≤n+m m 1 , oddK⇒even1+K x }\n ; inc2 ⊤\n → hoare λ { refl (even x)\n → m≤n+m m 2 , evenK⇒even2+K x }})\n (λ { inc ⊥ → ⊥-elim (⊥ tt)\n ; inc2 ⊥ → ⊥-elim (⊥ tt) })\n λ {s} rs F0 → alwaysEnabled s\n\n\n -- If we are at distance 1 from m, which means m ≡ s + 1.\n -- If s is odd then s is incremented by 1 (because of the enabling\n -- condition) then we go to an even state s₁ ≡ s + 1 ≡ m.\n -- If if s is even then s is incremented by 2, which leads to a state\n -- s₁ ≡ s + 2 > s + 1 ≡ m. As so, m ≤ s₁ ∩ Even s₁ will always hold.\n d≡1⇒Q∪d≡0 : ∀ {m}\n → myWFR {m} 1\n l-t\n ( ((m ≤_) ∩ Even) ∪ [∃ x ⇒ _< 1 ∶ myWFR {m} x ] )\n d≡1⇒Q∪d≡0 {m} = viaEvSet\n MyEventSet wf\n (λ { inc ⊤\n → hoare λ { {ps} refl (odd x)\n → inj₁ (≤-refl , oddK⇒even1+K x) }\n ; inc2 ⊤\n → hoare λ { {ps} refl (even x)\n → inj₁ (m≤n+m (suc ps) 1 , evenK⇒even2+K x) }})\n (λ { inc ⊥ → ⊥-elim (⊥ tt)\n ; inc2 ⊥ → ⊥-elim (⊥ tt) })\n λ {s} rs F1 → alwaysEnabled s\n\n\n -- Auxiliary properties\n assoc∘comm : ∀ {w s : ℕ} n → n + w + s ≡ w + (n + s)\n assoc∘comm {w} {s} n = trans (cong (_+ s) (+-comm n w)) (+-assoc w n s)\n\n assoc∘assoc : ∀ {w s : ℕ} n p → (n + p) + w + s ≡ n + w + (p + s)\n assoc∘assoc {w} {s} n p\n rewrite +-assoc n p w\n | +-comm p w\n | +-assoc n (w + p) s\n | +-assoc w p s\n | +-assoc n w (p + s) = refl\n\n\n -- If we are at a distance greater o equal to 2 then with we decrease the\n -- distance in 1 or 2, because we can jump 1 or 2 states (inc or onc2)\n -- This property together with d≡0⇒Q and d≡1⇒Q∪d≡0 allows to prove the\n -- second constraint for the WFR rule (see below)\n [d≡2+w]⇒[d≡1+w]∪[d≡w] : ∀ {m w}\n → myWFR {m} (2 + w)\n l-t\n ( myWFR {m} (1 + w) ∪ myWFR {m} w )\n [d≡2+w]⇒[d≡1+w]∪[d≡w] {m} {w} =\n viaEvSet\n MyEventSet wf\n (λ { inc ⊤\n → hoare λ { {ps} refl (odd x) → inj₁ (assoc∘assoc 1 1) }\n ; inc2 ⊤\n → hoare λ { {ps} refl enEv → inj₂ (assoc∘comm 2) }})\n (λ { inc ⊥ → ⊥-elim (⊥ tt)\n ; inc2 ⊥ → ⊥-elim (⊥ tt) })\n λ {s} rs F2+d → alwaysEnabled s\n\n\n -- Second constraint for WFR rule\n [Fw]l-t[Q∪Fx] : ∀ {m w}\n → myWFR {m} w\n l-t\n ( ((m ≤_) ∩ Even) ∪ [∃ x ⇒ _< w ∶ myWFR {m} x ] )\n [Fw]l-t[Q∪Fx] {m} {zero} = viaTrans d≡0⇒Q (viaInv (λ rs x → inj₁ x))\n [Fw]l-t[Q∪Fx] {m} {suc zero} = d≡1⇒Q∪d≡0\n [Fw]l-t[Q∪Fx] {m} {suc (suc w)} =\n viaTrans\n [d≡2+w]⇒[d≡1+w]∪[d≡w]\n (viaInv (λ { rs (inj₁ mfr[1+w]) → inj₂ ( 1 + w , s≤s ≤-refl , mfr[1+w] )\n ; rs (inj₂ mfr[w]) → inj₂ ( w , s≤s (m≤n+m w 1) , mfr[w]) }))\n\n\n\n\n ------------------------------------------------------------------------------\n -- MAIN PROPERTY\n ------------------------------------------------------------------------------\n -- From any n, we can reach any state m such that m is Even\n progressAlwaysEven : ∀ {n m : ℕ} → (n ≡_) l-t ((m ≤_) ∩ Even)\n progressAlwaysEven {n} {m} = viaWFR\n (myWFR {m})\n [P]l-t[Q∪Fx]\n λ w → [Fw]l-t[Q∪Fx]\n\n", "meta": {"hexsha": "8a62537dffb4e9edb9422364ad45dff4c3099a6c", "size": 9379, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Examples/SMCounterEven.agda", "max_stars_repo_name": "lisandrasilva/agda-liveness", "max_stars_repo_head_hexsha": "391e148f391dc2d246249193788a0d203285b38e", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Examples/SMCounterEven.agda", "max_issues_repo_name": "lisandrasilva/agda-liveness", "max_issues_repo_head_hexsha": "391e148f391dc2d246249193788a0d203285b38e", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Examples/SMCounterEven.agda", "max_forks_repo_name": "lisandrasilva/agda-liveness", "max_forks_repo_head_hexsha": "391e148f391dc2d246249193788a0d203285b38e", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.9962686567, "max_line_length": 80, "alphanum_fraction": 0.4575114618, "num_tokens": 3215, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9465966747198243, "lm_q2_score": 0.8311430436757312, "lm_q1q2_score": 0.786757241359961}} {"text": "module RandomAccessList.Standard.Numeral where\n\nopen import Data.List\nopen import Data.Nat\nopen import Data.Nat.Properties.Simple\nopen import Data.Unit using (⊤)\nopen import Data.Empty using (⊥; ⊥-elim)\nopen import Relation.Nullary.Negation using (contraposition)\nopen import Relation.Binary.PropositionalEquality as PropEq\n using (_≡_; _≢_; refl; cong; trans; sym; inspect)\nopen PropEq.≡-Reasoning\n\ndata Digit : Set where\n zero : Digit\n one : Digit\n\nBinary : Set\nBinary = List Digit\n\nincr : Binary → Binary\nincr [] = one ∷ []\nincr (zero ∷ xs) = one ∷ xs\nincr (one ∷ xs) = zero ∷ incr xs\n\n⟦_⟧ : Binary → ℕ\n⟦ [] ⟧ = 0\n⟦ zero ∷ xs ⟧ = 2 * ⟦ xs ⟧\n⟦ one ∷ xs ⟧ = 1 + 2 * ⟦ xs ⟧\n\n*-0-absorb : (n m : ℕ) → n ≡ 0 → m * n ≡ 0\n*-0-absorb n m p =\n begin\n m * n\n ≡⟨ cong (_*_ m) p ⟩\n m * 0\n ≡⟨ *-right-zero m ⟩\n 0\n ∎\n\ndecr : (xs : Binary) → ⟦ xs ⟧ ≢ 0 → Binary\ndecr [] p = ⊥-elim (p refl)\ndecr (zero ∷ xs) p = one ∷ decr xs (contraposition (*-0-absorb ⟦ xs ⟧ 2) p)\ndecr (one ∷ xs) p = zero ∷ xs\n", "meta": {"hexsha": "afd17efcddbda6679b52dc67f6c5f984ab4e1db8", "size": 1062, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "legacy/RandomAccessList/Standard/Numeral.agda", "max_stars_repo_name": "banacorn/numeral", "max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z", "max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z", "max_issues_repo_path": "legacy/RandomAccessList/Standard/Numeral.agda", "max_issues_repo_name": "banacorn/numeral", "max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "legacy/RandomAccessList/Standard/Numeral.agda", "max_forks_repo_name": "banacorn/numeral", "max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z", "avg_line_length": 24.1363636364, "max_line_length": 76, "alphanum_fraction": 0.5725047081, "num_tokens": 410, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9362850075259039, "lm_q2_score": 0.839733963661418, "lm_q1q2_score": 0.7862303204864879}} {"text": "module Peano where\n data ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\n _+_ : ℕ → ℕ → ℕ\n zero + zero = zero\n zero + n = n\n (suc n) + m = suc (n + m)\n\n data _even : ℕ → Set where\n ZERO : zero even\n STEP : ∀ x → x even → suc (suc x) even\n\n proof₁ : suc (suc (suc (suc zero))) even\n proof₁ = STEP (suc (suc zero)) (STEP zero ZERO)\n", "meta": {"hexsha": "9900b507e8bd083e40755157fb331753baa922f0", "size": 343, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Peano.agda", "max_stars_repo_name": "prt2121/tdd-playground", "max_stars_repo_head_hexsha": "6178c6ff150b11a462d40f0f3a0fd3ccc8d5ffb0", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "agda/Peano.agda", "max_issues_repo_name": "prt2121/tdd-playground", "max_issues_repo_head_hexsha": "6178c6ff150b11a462d40f0f3a0fd3ccc8d5ffb0", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/Peano.agda", "max_forks_repo_name": "prt2121/tdd-playground", "max_forks_repo_head_hexsha": "6178c6ff150b11a462d40f0f3a0fd3ccc8d5ffb0", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.1764705882, "max_line_length": 49, "alphanum_fraction": 0.527696793, "num_tokens": 133, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9664104933824753, "lm_q2_score": 0.8128673155708975, "lm_q1q2_score": 0.7855635034953593}} {"text": "-- Long version, the final version is Nat.agda\nmodule NatTry where\n\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\none two three four : ℕ\none = suc zero\ntwo = suc one\nthree = suc two\nfour = suc three\n\n_+_ : ℕ → ℕ → ℕ\nzero + b = b\nsuc a + b = suc (a + b)\n\ndata Bool : Set where\n true : Bool\n false : Bool\n\n_≟_ : ℕ → ℕ → Bool\nzero ≟ zero = true\nsuc a ≟ suc b = a ≟ b\n_ ≟ _ = false\n\ninfix 4 _≟_\n\nassocProp : ℕ → ℕ → ℕ → Bool\nassocProp a b c = (a + b) + c ≟ a + (b + c)\n\nreflProp : ℕ → Bool\nreflProp n = n ≟ n\n\nmodule isTrue-direct where\n\n data isTrue : Bool → Set where\n ok : isTrue true\n\n unitTest : isTrue (assocProp one one two)\n unitTest = ok\n\n refl-True : (n : ℕ) → isTrue (reflProp n)\n refl-True zero = ok\n refl-True (suc n) = refl-True n\n\n assocProp-zero-True : (n m : ℕ) → isTrue (assocProp zero n m)\n assocProp-zero-True n m = refl-True (n + m)\n\n assocProp-True : (n m k : ℕ) → isTrue (assocProp n m k)\n assocProp-True zero m k = assocProp-zero-True m k\n assocProp-True (suc n) m k = assocProp-True n m k\n\n-------- switch to _≡_\n\nmodule ≡-Bool where\n\n -- propositional equalitiy on Bool\n data _≡_ : Bool → Bool → Set where\n refl : {a : Bool} → a ≡ a -- the Bool paramter is hidden\n\n infix 4 _≡_\n\n isTrue : Bool → Set\n isTrue x = x ≡ true\n\n-- generic propositional equality\ndata _≡_ {A : Set} : A → A → Set where\n refl : {a : A} → a ≡ a\n\ninfix 4 _≡_\n\n-- This is the type of the refl constructor\n-- The parameters are hidden\nrefl′ : {A : Set} {a : A} → a ≡ a\nrefl′ = refl\n\nisTrue : Bool → Set\nisTrue x = x ≡ true\n\nrefl-True : (n : ℕ) → isTrue (reflProp n)\nrefl-True zero = refl\nrefl-True (suc n) = refl-True n\n\nunitTest : isTrue (assocProp one one two)\nunitTest = refl\n\nassocProp-zero-True : (n m : ℕ) → isTrue (assocProp zero n m)\nassocProp-zero-True n m = refl-True (n + m)\n\nassocProp-True : (n m k : ℕ) → isTrue (assocProp n m k)\nassocProp-True zero m k = assocProp-zero-True m k\nassocProp-True (suc n) m k = assocProp-True n m k\n\n\n---- switch from _≟_\n\ncong : {A B : Set} {a b : A} (f : A → B) → a ≡ b → f a ≡ f b\ncong f refl = refl\n\ncong-suc : {a b : ℕ} → a ≡ b → suc a ≡ suc b\ncong-suc = cong suc\n\n≡-to-≟ : {a b : ℕ} → a ≡ b → isTrue (a ≟ b)\n≡-to-≟ {a} refl = refl-True a\n\n≟-to-≡ : (a b : ℕ) → isTrue (a ≟ b) → a ≡ b\n≟-to-≡ zero zero i = refl\n≟-to-≡ zero (suc b) ()\n≟-to-≡ (suc a) zero ()\n≟-to-≡ (suc a) (suc b) i = cong-suc (≟-to-≡ a b i)\n\n\n-- the rest is in Nat.agda\n", "meta": {"hexsha": "e0a8f0faf74055e8e02b03784c2555bd7bb2f5a8", "size": 2429, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "NatTry.agda", "max_stars_repo_name": "divipp/agda-intro-prezi", "max_stars_repo_head_hexsha": "a8902e36ed2037de9008e061d54517d4d7d99f0f", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2018-11-27T02:50:48.000Z", "max_stars_repo_stars_event_max_datetime": "2020-01-21T14:53:25.000Z", "max_issues_repo_path": "NatTry.agda", "max_issues_repo_name": "divipp/agda-intro-prezi", "max_issues_repo_head_hexsha": "a8902e36ed2037de9008e061d54517d4d7d99f0f", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "NatTry.agda", "max_forks_repo_name": "divipp/agda-intro-prezi", "max_forks_repo_head_hexsha": "a8902e36ed2037de9008e061d54517d4d7d99f0f", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.1217391304, "max_line_length": 63, "alphanum_fraction": 0.5841910251, "num_tokens": 985, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9059898153067649, "lm_q2_score": 0.8670357735451835, "lm_q1q2_score": 0.7855255803385588}} {"text": "module Numeral.Natural.Relation.Properties where\n\nimport Lvl\nopen import Data.Tuple as Tuple using (_⨯_ ; _,_)\nopen import Functional\nopen import Logic.Propositional\nopen import Logic.Propositional.Theorems\nopen import Logic.Predicate\nopen import Numeral.Natural\nopen import Numeral.Natural.Oper\nopen import Numeral.Natural.Oper.Proofs\nopen import Numeral.Natural.Induction\nopen import Numeral.Natural.Relation\nopen import Relator.Equals\nopen import Relator.Equals.Proofs\nopen import Structure.Function.Domain\nopen import Structure.Operator.Properties\nopen import Structure.Relator.Ordering\nopen import Structure.Relator.Properties\nopen import Type\n\n[ℕ]-zero-or-nonzero : ∀{n : ℕ} → (n ≡ 𝟎)∨(n ≢ 𝟎)\n[ℕ]-zero-or-nonzero {𝟎} = [∨]-introₗ [≡]-intro\n[ℕ]-zero-or-nonzero {𝐒(_)} = [∨]-introᵣ \\()\n\n[≡][ℕ]-excluded-middle : ∀{a b : ℕ} → (a ≡ b)∨(a ≢ b)\n[≡][ℕ]-excluded-middle {𝟎} {𝟎} = [∨]-introₗ [≡]-intro\n[≡][ℕ]-excluded-middle {𝟎} {𝐒(_)} = [∨]-introᵣ \\()\n[≡][ℕ]-excluded-middle {𝐒(_)}{𝟎} = [∨]-introᵣ \\()\n[≡][ℕ]-excluded-middle {𝐒(a)}{𝐒(b)} = [∨]-elim ([∨]-introₗ ∘ [≡]-with(𝐒)) ([∨]-introᵣ ∘ (contrapositiveᵣ(injective(𝐒)))) ([≡][ℕ]-excluded-middle {a}{b})\n", "meta": {"hexsha": "13d719c2fd63f6dd877570b0befc04b9663b5ce7", "size": 1166, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Natural/Relation/Properties.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Numeral/Natural/Relation/Properties.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Numeral/Natural/Relation/Properties.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.6129032258, "max_line_length": 152, "alphanum_fraction": 0.6861063465, "num_tokens": 457, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.926303728259492, "lm_q2_score": 0.8479677583778258, "lm_q1q2_score": 0.7854756960292242}} {"text": "module Nats.Multiply.Comm where\n\nopen import Nats\nopen import Equality\nopen import Function\n\nopen import Nats.Add.Comm\nopen import Nats.Add.Assoc\n\n------------------------------------------------------------------------\n-- internal stuffs\n\nprivate\n\n a*0=0*a : ∀ a → a * 0 ≡ 0\n a*0=0*a zero = refl\n a*0=0*a (suc a) = a*0=0*a a\n\n a+a*b=a*++b : ∀ a b → a + a * b ≡ a * suc b\n a+a*b=a*++b zero _ = refl\n a+a*b=a*++b (suc a) b\n rewrite nat-add-comm b $ a * suc b\n | nat-add-comm b $ a * b\n | sym $ nat-add-assoc a (a * b) b\n | a+a*b=a*++b a b\n = refl\n\n a*b=b*a : ∀ a b → a * b ≡ b * a\n a*b=b*a zero b\n rewrite a*0=0*a b = refl\n a*b=b*a (suc a) b\n rewrite a*b=b*a a b\n | a+a*b=a*++b b a\n = refl\n\n------------------------------------------------------------------------\n-- public aliases\n\nnat-multiply-comm : ∀ a b → a * b ≡ b * a\nnat-multiply-comm = a*b=b*a\n", "meta": {"hexsha": "1ffd22b0948c2d4b391f0d333c8dd5b8454aab63", "size": 937, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Nats/Multiply/Comm.agda", "max_stars_repo_name": "ice1k/Theorems", "max_stars_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-04-15T15:28:03.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-15T15:28:03.000Z", "max_issues_repo_path": "src/Nats/Multiply/Comm.agda", "max_issues_repo_name": "ice1k/Theorems", "max_issues_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Nats/Multiply/Comm.agda", "max_forks_repo_name": "ice1k/Theorems", "max_forks_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.8536585366, "max_line_length": 72, "alphanum_fraction": 0.4258271078, "num_tokens": 321, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9473810511092411, "lm_q2_score": 0.8289388146603364, "lm_q1q2_score": 0.7853209255381578}} {"text": "module plfa.part1.Equality where\n\ndata _≡_ {A : Set} (x : A) : A → Set where\n refl : x ≡ x\n\ninfix 4 _≡_\n\nsym : ∀ {A : Set} {x y : A} → x ≡ y → y ≡ x\nsym refl = refl\n\ntrans : ∀ {A : Set} {x y z : A} → x ≡ y → y ≡ z → x ≡ z\ntrans refl refl = refl\n\ncong : ∀ {A B : Set} (f : A → B) {x y : A} → x ≡ y → f x ≡ f y\ncong f refl = refl\n\ncong₂ : ∀ {A B C : Set} (f : A → B → C) {u x : A} {v y : B} → u ≡ x → v ≡ y → f u v ≡ f x y\ncong₂ f refl refl = refl\n\ncong-app : ∀ {A B : Set} {f g : A → B} → f ≡ g → ∀ (x : A) → f x ≡ g x\ncong-app refl x = refl\n\nsubst : ∀ {A : Set} {x y : A} (P : A → Set) → x ≡ y → P x → P y\nsubst P refl px = px\n\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\n_+_ : ℕ → ℕ → ℕ\nzero + n = n\n(suc m) + n = suc (m + n)\n\npostulate\n +-identity : ∀ (m : ℕ) → m + zero ≡ m\n +-suc : ∀ (m n : ℕ) → m + suc n ≡ suc (m + n)\n", "meta": {"hexsha": "7140ac8940f22cfbab8bd1a16cfffb570c2f1d03", "size": 836, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "proglangs-learning/Agda/plfa-exercises/part1/Equality.agda", "max_stars_repo_name": "helq/old_code", "max_stars_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "proglangs-learning/Agda/plfa-exercises/part1/Equality.agda", "max_issues_repo_name": "helq/old_code", "max_issues_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2020-03-10T19:20:21.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-07T15:39:48.000Z", "max_forks_repo_path": "proglangs-learning/Agda/plfa-exercises/part1/Equality.agda", "max_forks_repo_name": "helq/old_code", "max_forks_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.5945945946, "max_line_length": 91, "alphanum_fraction": 0.4413875598, "num_tokens": 403, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9399133447766225, "lm_q2_score": 0.8354835289107307, "lm_q1q2_score": 0.7852821181642609}} {"text": "------------------------------------------------------------------------------\n-- Well-founded induction on natural numbers\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\n-- Adapted from\n-- http://www.iis.sinica.edu.tw/~scm/2008/well-founded-recursion-and-accessibility/\n-- and the Agda standard library 0.8.1.\n\nmodule FOTC.Induction.WF where\n\nopen import Common.Relation.Unary\n\nopen import FOTC.Base\n\n------------------------------------------------------------------------------\n-- The accessibility predicate: x is accessible if everything which is\n-- smaller than x is also accessible (inductively).\ndata Acc (P : D → Set)(_<_ : D → D → Set)(x : D) : Set where\n acc : (∀ {y} → P y → y < x → Acc P _<_ y) → Acc P _<_ x\n\naccFold : {P Q : D → Set}(_<_ : D → D → Set) →\n (∀ {x} → Q x → (∀ {y} → Q y → y < x → P y) → P x) →\n ∀ {x} → Q x → Acc Q _<_ x → P x\naccFold _<_ f Qx (acc h) = f Qx (λ Qy y(1::nat)) [2,6,4] = True\n todos (λx. x>(2::nat)) [2,6,4] = False\n Nota: La conjunción se representa por ∧\n --------------------------------------------------------------- -}\n \nfun todos :: \"('a ⇒ bool) ⇒ 'a list ⇒ bool\" where\n \"todos p xs = undefined\"\n \n{- --------------------------------------------------------------- \n Ejercicio 3.3. Demostrar que todos los elementos de (copia n x) son\n iguales a x. \n ----------------------------------------------------------------- -}\n \nlemma \"todos (λy. y=x) (copia n x)\"\n oops\n \n{- --------------------------------------------------------------- \n Ejercicio 4.1. Definir, recursivamente y sin usar (@), la función\n amplia :: 'a list ⇒ 'a ⇒ 'a list\n tal que (amplia xs y) es la lista obtenida añadiendo el elemento y al\n final de la lista xs. Por ejemplo,\n amplia [d,a] t = [d,a,t]\n ---------------------------------------------------------------- -}\n \nfun amplia :: \"'a list ⇒ 'a ⇒ 'a list\" where\n \"amplia xs y = undefined\"\n \n{- --------------------------------------------------------------- \n Ejercicio 4.2. Demostrar que \n amplia xs y = xs @ [y]\n ----------------------------------------------------------------- -}\n \nlemma \"amplia xs y = xs @ [y]\"\n oops\n-}\n", "meta": {"hexsha": "5acd9e505de31ab89114175458b6ef1104de696e", "size": 3867, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Ejercicios/Agda/R2.agda", "max_stars_repo_name": "Zegeri/TFG-TeoriaCategorias", "max_stars_repo_head_hexsha": "cc2e64e1a42ac225c3d1a6a998721f916065418b", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Ejercicios/Agda/R2.agda", "max_issues_repo_name": "Zegeri/TFG-TeoriaCategorias", "max_issues_repo_head_hexsha": "cc2e64e1a42ac225c3d1a6a998721f916065418b", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Ejercicios/Agda/R2.agda", "max_forks_repo_name": "Zegeri/TFG-TeoriaCategorias", "max_forks_repo_head_hexsha": "cc2e64e1a42ac225c3d1a6a998721f916065418b", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.225, "max_line_length": 75, "alphanum_fraction": 0.4290147401, "num_tokens": 1035, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9032942041005328, "lm_q2_score": 0.8688267864276107, "lm_q1q2_score": 0.7848062005473523}} {"text": "\nmodule Agda.Builtin.Nat where\n\nopen import Agda.Builtin.Bool\n\ndata Nat : Set where\n zero : Nat\n suc : (n : Nat) → Nat\n\n{-# BUILTIN NATURAL Nat #-}\n\ninfix 4 _==_ _<_\ninfixl 6 _+_ _-_\ninfixl 7 _*_\n\n_+_ : Nat → Nat → Nat\nzero + m = m\nsuc n + m = suc (n + m)\n\n{-# BUILTIN NATPLUS _+_ #-}\n\n_-_ : Nat → Nat → Nat\nn - zero = n\nzero - suc m = zero\nsuc n - suc m = n - m\n\n{-# BUILTIN NATMINUS _-_ #-}\n\n_*_ : Nat → Nat → Nat\nzero * m = zero\nsuc n * m = m + n * m\n\n{-# BUILTIN NATTIMES _*_ #-}\n\n_==_ : Nat → Nat → Bool\nzero == zero = true\nsuc n == suc m = n == m\n_ == _ = false\n\n{-# BUILTIN NATEQUALS _==_ #-}\n\n_<_ : Nat → Nat → Bool\n_ < zero = false\nzero < suc _ = true\nsuc n < suc m = n < m\n\n{-# BUILTIN NATLESS _<_ #-}\n\ndiv-helper : Nat → Nat → Nat → Nat → Nat\ndiv-helper k m zero j = k\ndiv-helper k m (suc n) zero = div-helper (suc k) m n m\ndiv-helper k m (suc n) (suc j) = div-helper k m n j\n\n{-# BUILTIN NATDIVSUCAUX div-helper #-}\n\nmod-helper : Nat → Nat → Nat → Nat → Nat\nmod-helper k m zero j = k\nmod-helper k m (suc n) zero = mod-helper 0 m n m\nmod-helper k m (suc n) (suc j) = mod-helper (suc k) m n j\n\n{-# BUILTIN NATMODSUCAUX mod-helper #-}\n", "meta": {"hexsha": "0e7c880b2195c173b2dd94e89882c8a0904aaa73", "size": 1195, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/data/lib/prim/Agda/Builtin/Nat.agda", "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/data/lib/prim/Agda/Builtin/Nat.agda", "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/data/lib/prim/Agda/Builtin/Nat.agda", "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.2741935484, "max_line_length": 57, "alphanum_fraction": 0.5556485356, "num_tokens": 450, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9518632302488963, "lm_q2_score": 0.8244619242200081, "lm_q1q2_score": 0.7847749904052777}} {"text": "module *-assoc where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; cong)\nopen Eq.≡-Reasoning using (begin_; _≡⟨⟩_; step-≡; _∎)\nopen import Data.Nat using (ℕ; zero; suc; _+_; _*_)\n\nopen import *-distrib-+ using (*-distrib-+)\n\n-- 積の結合律 (associativity)\n*-assoc : ∀ (m n p : ℕ) → (m * n) * p ≡ m * (n * p)\n*-assoc zero n p =\n begin\n (zero * n) * p\n ≡⟨⟩\n zero * p\n ≡⟨⟩\n zero\n ≡⟨⟩\n zero * (n * p)\n ∎\n*-assoc (suc m) n p =\n begin\n ((suc m) * n) * p\n ≡⟨⟩\n (n + m * n) * p\n ≡⟨ *-distrib-+ n (m * n) p ⟩\n (n * p) + m * n * p\n ≡⟨ cong ((n * p) +_) (*-assoc m n p) ⟩\n (n * p) + m * (n * p)\n ≡⟨⟩\n (suc m) * (n * p)\n ∎\n", "meta": {"hexsha": "5600163ee3442b375da8314157fef2093ded19ee", "size": 669, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "part1/induction/*-assoc.agda", "max_stars_repo_name": "akiomik/plfa-solutions", "max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z", "max_issues_repo_path": "part1/induction/*-assoc.agda", "max_issues_repo_name": "akiomik/plfa-solutions", "max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "part1/induction/*-assoc.agda", "max_forks_repo_name": "akiomik/plfa-solutions", "max_forks_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.6764705882, "max_line_length": 53, "alphanum_fraction": 0.466367713, "num_tokens": 327, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9597620562254525, "lm_q2_score": 0.8175744695262775, "lm_q1q2_score": 0.7846769539899737}} {"text": "module nat where\n\nopen import product\nopen import bool\nopen import maybe\nopen import eq\n\n----------------------------------------------------------------------\n-- datatypes\n----------------------------------------------------------------------\n\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\nnat = ℕ\n\n----------------------------------------------------------------------\n-- syntax\n----------------------------------------------------------------------\n\ninfixl 10 _*_\ninfixl 9 _+_ _∸_\ninfixl 8 _<_ _=ℕ_ _≤_ _>_ _≥_\n\n-- pragmas to get decimal notation:\n\n{-# BUILTIN NATURAL ℕ #-}\n\n----------------------------------------------------------------------\n-- operations\n----------------------------------------------------------------------\n\n---------------------------------------\n-- basic arithmetic operations\n---------------------------------------\n\n_+_ : ℕ → ℕ → ℕ\nzero + n = n\nsuc m + n = suc (m + n)\n\n{-# BUILTIN NATPLUS _+_ #-}\n\n_*_ : ℕ → ℕ → ℕ\nzero * n = zero\nsuc m * n = n + (m * n)\n\n{-# BUILTIN NATTIMES _*_ #-}\n\npred : ℕ → ℕ\npred 0 = 0\npred (suc n) = n\n\n_∸_ : ℕ → ℕ → ℕ\nm ∸ zero = m\nzero ∸ suc n = zero\nsuc m ∸ suc n = m ∸ n\n\n-- see nat-division.agda for division function\n\n{-# BUILTIN NATMINUS _∸_ #-}\n\nsquare : ℕ → ℕ\nsquare x = x * x\n\n--------------------------------------------------\n-- comparisons\n--------------------------------------------------\n\n_<_ : ℕ → ℕ → 𝔹\n0 < 0 = ff\n0 < (suc y) = tt\n(suc x) < (suc y) = x < y\n(suc x) < 0 = ff\n\n_=ℕ_ : ℕ → ℕ → 𝔹\n0 =ℕ 0 = tt\nsuc x =ℕ suc y = x =ℕ y\n_ =ℕ _ = ff\n\n_≤_ : ℕ → ℕ → 𝔹\nx ≤ y = (x < y) || x =ℕ y\n\n_>_ : ℕ → ℕ → 𝔹\na > b = b < a\n\n_≥_ : ℕ → ℕ → 𝔹\na ≥ b = b ≤ a\n\nmin : ℕ → ℕ → ℕ\nmin x y = if x < y then x else y\n\nmax : ℕ → ℕ → ℕ\nmax x y = if x < y then y else x\n\ndata compare-t : Set where\n compare-lt : compare-t\n compare-eq : compare-t\n compare-gt : compare-t\n\ncompare : ℕ → ℕ → compare-t\ncompare 0 0 = compare-eq\ncompare 0 (suc y) = compare-lt\ncompare (suc x) 0 = compare-gt\ncompare (suc x) (suc y) = compare x y \n\niszero : ℕ → 𝔹\niszero 0 = tt\niszero _ = ff\n\nparity : ℕ → 𝔹\nparity 0 = ff\nparity (suc x) = ~ (parity x)\n\n_pow_ : ℕ → ℕ → ℕ\nx pow 0 = 1\nx pow (suc y) = x * (x pow y)\n\nfactorial : ℕ → ℕ\nfactorial 0 = 1\nfactorial (suc x) = (suc x) * (factorial x)\n\nis-even : ℕ → 𝔹\nis-odd : ℕ → 𝔹\nis-even 0 = tt\nis-even (suc x) = is-odd x\nis-odd 0 = ff\nis-odd (suc x) = is-even x\n", "meta": {"hexsha": "cae4676847dd3fdbfdfdeccc66bc03166e8803e6", "size": 2343, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "nat.agda", "max_stars_repo_name": "heades/AUGL", "max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "nat.agda", "max_issues_repo_name": "heades/AUGL", "max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "nat.agda", "max_forks_repo_name": "heades/AUGL", "max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.1627906977, "max_line_length": 70, "alphanum_fraction": 0.408023901, "num_tokens": 781, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9433475762847495, "lm_q2_score": 0.8311430457670241, "lm_q1q2_score": 0.7840567777702468}} {"text": "module Sandbox.PrimitiveRecursion where\n\nopen import Data.Nat\nopen import Data.Fin using (Fin)\nopen import Data.Vec\n\ndata PR : ℕ → Set where\n -- Constant function: The 0-ary constant function 0 is primitive recursive.\n K : PR 0\n\n -- Successor function: The 1-ary successor function S, which returns the\n -- successor of its argument (see Peano postulates), is primitive recursive.\n -- That is, S(k) = k + 1.\n S : PR 1\n\n -- Projection function: For every n≥1 and each i with 1≤i≤n, the n-ary\n -- projection function Pᵢⁿ, which returns its i-th argument, is primitive\n -- recursive.\n Proj : ∀ {n} → (i : Fin n) → PR n\n\n -- Composition: Given f, a m-ary primitive recursive function, and m n-ary\n -- primitive recursive functions g1,...,gm, the composition of f with\n -- g1,...,gk, is primitive recursive\n -- f(\n -- g₁(x₁, x₂, ..., xₙ)\n -- g₂(x₁, x₂, ..., xₙ)\n -- ...\n -- gₘ(x₁, x₂, ..., xₙ)\n -- )\n Comp : ∀ {m n} → (f : PR m) → Vec (PR n) m → PR n\n -- Primitive recursion: Given f, a m-ary primitive recursive function,\n -- and g, a (m+2)-ary primitive recursive function, the (m+1)-ary function\n -- h is defined as the primitive recursion of f and g, i.e. the function h\n -- is primitive recursive when\n -- h(0 , x₁, x₂, .. xₘ) = f(x₁, x₂, .. xₘ)\n -- h(S(n), x₁, x₂, .. xₘ) = g(n, h(n, x₁, x₂, .. xₘ), x₁, x₂, .. xₘ)\n Rec : ∀ {n} → (f : PR {! !}) (g : PR (suc (suc n))) → PR (suc n)\n\n\nmutual\n ⟦_⟧_ : ∀ {a} → PR a → Vec ℕ a → ℕ\n ⟦ K ⟧ args = zero\n ⟦ S ⟧ args = suc zero\n ⟦ Proj i ⟧ args = lookup i args\n ⟦ Comp f gs ⟧ args = ⟦ f ⟧ (⟦ gs ⟧* args)\n ⟦ Rec f g ⟧ (zero ∷ args) = ⟦ f ⟧ args\n ⟦ Rec f g ⟧ (suc x ∷ args) = ⟦ g ⟧ (x ∷ (⟦ f ⟧ args) ∷ args)\n\n ⟦_⟧* : {m n : ℕ} (gs : Vec (PR n) m) → Vec ℕ n → Vec ℕ m\n ⟦ [] ⟧* args = []\n ⟦ g ∷ gs ⟧* args = (⟦ g ⟧ args) ∷ ⟦ gs ⟧* args\n", "meta": {"hexsha": "a3419422170d358a7b2c5e640e5ccbb0cde24942", "size": 1979, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Sandbox/PrimitiveRecursion.agda", "max_stars_repo_name": "banacorn/numeral", "max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z", "max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z", "max_issues_repo_path": "Sandbox/PrimitiveRecursion.agda", "max_issues_repo_name": "banacorn/numeral", "max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Sandbox/PrimitiveRecursion.agda", "max_forks_repo_name": "banacorn/numeral", "max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z", "avg_line_length": 38.0576923077, "max_line_length": 80, "alphanum_fraction": 0.517433047, "num_tokens": 742, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9433475778774728, "lm_q2_score": 0.8311430436757313, "lm_q1q2_score": 0.7840567771212117}} {"text": "module naturals where\n\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\n-- 1)\nseven : ℕ\nseven = suc (suc (suc (suc (suc (suc (suc zero))))))\n\n{-# BUILTIN NATURAL ℕ #-}\n\nopen import Relation.Binary.PropositionalEquality\nopen ≡-Reasoning\n\n_+_ : ℕ → ℕ → ℕ\nzero + n = n\n(suc m) + n = suc (m + n)\n\n-- 2)\n_ : 3 + 4 ≡ 7\n_ =\n begin\n 3 + 4\n ≡⟨⟩\n suc (2 + 4)\n ≡⟨⟩\n suc (suc (1 + 4))\n ≡⟨⟩\n suc (suc (suc (0 + 4)))\n ≡⟨⟩\n suc (suc (suc 4))\n ≡⟨⟩\n suc (suc 5)\n ≡⟨⟩\n suc 6\n ≡⟨⟩\n 7\n ∎\n\n_*_ : ℕ → ℕ → ℕ\nzero * n = zero\n(suc m) * n = n + (m * n)\n\n-- 3)\n_ : 3 * 4 ≡ 12\n_ =\n begin\n 3 * 4\n ≡⟨⟩\n 4 + (2 * 4)\n ≡⟨⟩\n 4 + (4 + (1 * 4))\n ≡⟨⟩\n 4 + (4 + (4 + (0 * 4)))\n ≡⟨⟩\n 4 + (4 + (4 + 0))\n ≡⟨⟩\n 4 + (4 + (4))\n ≡⟨⟩\n 12\n ∎\n\n-- 4)\n_^_ : ℕ → ℕ → ℕ\nm ^ zero = suc zero\nm ^ suc n = m * (m ^ n)\n\n\n_ : 3 ^ 4 ≡ 81\n_ =\n begin\n 3 ^ 4\n ≡⟨⟩\n 3 * (3 ^ 3)\n ≡⟨⟩\n 3 * (3 * (3 ^ 2))\n ≡⟨⟩\n 3 * (3 * (3 * (3 ^ 1)))\n ≡⟨⟩\n 3 * (3 * (3 * (3 * (3 ^ 0))))\n ≡⟨⟩\n 3 * (3 * (3 * (3 * 1)))\n ≡⟨⟩\n 81\n ∎\n\n_∸_ : ℕ → ℕ → ℕ\nm ∸ zero = m\nzero ∸ suc n = zero\nsuc m ∸ suc n = m ∸ n\n\n-- 5)\n_ : 5 ∸ 3 ≡ 2\n_ =\n begin\n 5 ∸ 3\n ≡⟨⟩\n 4 ∸ 2\n ≡⟨⟩\n 3 ∸ 1\n ≡⟨⟩\n 2 ∸ 0\n ≡⟨⟩\n 2\n ∎\n\n_ : 3 ∸ 5 ≡ 0\n_ =\n begin\n 3 ∸ 5\n ≡⟨⟩\n 2 ∸ 4\n ≡⟨⟩\n 1 ∸ 3\n ≡⟨⟩\n 0 ∸ 2\n ≡⟨⟩\n 0\n ∎\n\ninfixl 6 _+_ _∸_\ninfixl 7 _*_\n\n{-# BUILTIN NATPLUS _+_ #-}\n{-# BUILTIN NATTIMES _*_ #-}\n{-# BUILTIN NATMINUS _∸_ #-}\n\n-- 6)\ndata Bin : Set where\n - : Bin\n _O : Bin → Bin\n _I : Bin → Bin\n\ninc : Bin → Bin\ninc - = - I\ninc (rest O) = rest I\ninc (rest I) = (inc rest) O\n\nto : ℕ → Bin\nto zero = - O\nto (suc n) = inc (to n)\n\nfrom : Bin → ℕ\nfrom - = 0\nfrom (rest O) = 2 * from rest\nfrom (rest I) = 2 * from rest + 1\n", "meta": {"hexsha": "45e17078a875639c2eb555a43042125cc4892e97", "size": 1741, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "plfa/naturals.agda", "max_stars_repo_name": "aronerben/agda-playground", "max_stars_repo_head_hexsha": "64a00f1f97f053d246d5b9deab090e75d923fe8f", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "plfa/naturals.agda", "max_issues_repo_name": "aronerben/agda-playground", "max_issues_repo_head_hexsha": "64a00f1f97f053d246d5b9deab090e75d923fe8f", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "plfa/naturals.agda", "max_forks_repo_name": "aronerben/agda-playground", "max_forks_repo_head_hexsha": "64a00f1f97f053d246d5b9deab090e75d923fe8f", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 11.7635135135, "max_line_length": 52, "alphanum_fraction": 0.3716255026, "num_tokens": 1000, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9458012762876287, "lm_q2_score": 0.8289388125473629, "lm_q1q2_score": 0.7840113868716472}} {"text": "module even where\n\nopen import Data.Nat \nopen import Data.Nat.Properties\nopen import Data.Empty\nopen import Data.Unit using (⊤ ; tt)\nopen import Relation.Nullary\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Binary.Definitions\nopen import nat\nopen import logic\n\neven : (n : ℕ ) → Set\neven zero = ⊤\neven (suc zero) = ⊥\neven (suc (suc n)) = even n\n\neven? : (n : ℕ ) → Dec ( even n )\neven? zero = yes tt\neven? (suc zero) = no (λ ())\neven? (suc (suc n)) = even? n\n\nn+even : {n m : ℕ } → even n → even m → even ( n + m )\nn+even {zero} {zero} tt tt = tt\nn+even {zero} {suc m} tt em = em\nn+even {suc (suc n)} {m} en em = n+even {n} {m} en em\n\nn*even : {m n : ℕ } → even n → even ( m * n )\nn*even {zero} {n} en = tt\nn*even {suc m} {n} en = n+even {n} {m * n} en (n*even {m} {n} en) \n\neven*n : {n m : ℕ } → even n → even ( n * m )\neven*n {n} {m} en = subst even (*-comm m n) (n*even {m} {n} en)\n\n\nrecord Even (i : ℕ) : Set where\n field\n j : ℕ\n is-twice : i ≡ 2 * j\n\ne2 : (i : ℕ) → even i → Even i\ne2 zero en = record { j = 0 ; is-twice = refl }\ne2 (suc (suc i)) en = record { j = suc (Even.j (e2 i en )) ; is-twice = e21 } where\n e21 : suc (suc i) ≡ 2 * suc (Even.j (e2 i en))\n e21 = begin\n suc (suc i) ≡⟨ cong (λ k → suc (suc k)) (Even.is-twice (e2 i en)) ⟩\n suc (suc (2 * Even.j (e2 i en))) ≡⟨ sym (*-distribˡ-+ 2 1 _) ⟩\n 2 * suc (Even.j (e2 i en)) ∎ where open ≡-Reasoning\n\nrecord Odd (i : ℕ) : Set where\n field\n j : ℕ\n is-twice : i ≡ suc (2 * j )\n\nodd2 : (i : ℕ) → ¬ even i → even (suc i) \nodd2 zero ne = ⊥-elim ( ne tt )\nodd2 (suc zero) ne = tt\nodd2 (suc (suc i)) ne = odd2 i ne \n\nodd3 : (i : ℕ) → ¬ even i → Odd i\nodd3 zero ne = ⊥-elim ( ne tt )\nodd3 (suc zero) ne = record { j = 0 ; is-twice = refl }\nodd3 (suc (suc i)) ne = record { j = Even.j (e2 (suc i) (odd2 i ne)) ; is-twice = odd31 } where\n odd31 : suc (suc i) ≡ suc (2 * Even.j (e2 (suc i) (odd2 i ne)))\n odd31 = begin\n suc (suc i) ≡⟨ cong suc (Even.is-twice (e2 (suc i) (odd2 i ne))) ⟩\n suc (2 * (Even.j (e2 (suc i) (odd2 i ne)))) ∎ where open ≡-Reasoning\n\nodd4 : (i : ℕ) → even i → ¬ even ( suc i )\nodd4 (suc (suc i)) en en1 = odd4 i en en1 \n\n", "meta": {"hexsha": "a1dc82bed38362aa973f43a5acc0ac4f71f44dab", "size": 2183, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/even.agda", "max_stars_repo_name": "shinji-kono/automaton-in-agda", "max_stars_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/even.agda", "max_issues_repo_name": "shinji-kono/automaton-in-agda", "max_issues_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/even.agda", "max_forks_repo_name": "shinji-kono/automaton-in-agda", "max_forks_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.3194444444, "max_line_length": 96, "alphanum_fraction": 0.5478699038, "num_tokens": 924, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9481545333502202, "lm_q2_score": 0.8267118004748677, "lm_q1q2_score": 0.7838505413943685}} {"text": "module Nat.Sum where\n\nopen import Data.Nat \nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality \n\nopen DecTotalOrder decTotalOrder hiding (refl)\n\n+id : (n : ℕ) → n + zero ≡ n\n+id zero = refl\n+id (suc n) = cong suc (+id n)\n\n+assoc : (m n : ℕ) → m + suc n ≡ suc (m + n)\n+assoc zero n = refl\n+assoc (suc m) n = cong suc (+assoc m n)\n\n", "meta": {"hexsha": "be82a3f09ef970423398bc55dd8eb9a05a83edb1", "size": 358, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Nat/Sum.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/Nat/Sum.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/Nat/Sum.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.0588235294, "max_line_length": 50, "alphanum_fraction": 0.656424581, "num_tokens": 119, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9697854111860906, "lm_q2_score": 0.8080672066194946, "lm_q1q2_score": 0.7836517882374823}} {"text": "{-# OPTIONS --sized-types #-}\nopen import Relation.Binary.Core\n\nmodule Mergesort.Impl1.Correctness.Permutation {A : Set}\n (_≤_ : A → A → Set)\n (tot≤ : Total _≤_) where\n\nopen import Bound.Lower A\nopen import Bound.Lower.Order _≤_\nopen import Data.List\nopen import Data.Product\nopen import Data.Sum\nopen import List.Permutation.Base A\nopen import List.Permutation.Base.Equivalence A\nopen import List.Permutation.Pair A\nopen import List.Permutation.Pair.Properties A\nopen import Mergesort.Impl1 _≤_ tot≤\nopen import Size\nopen import SList\nopen import SList.Properties\nopen import SOList.Lower _≤_\n\nlemma-deal : {ι : Size} → (xs : SList A {ι}) → unsize A xs ≈ unsize× A (deal xs)\nlemma-deal snil = ≈[]l []\nlemma-deal (x ∙ snil) = ≈[]r (x ∷ [])\nlemma-deal (x ∙ (y ∙ xs)) \n with lemma-deal xs\n... | xs≈ys,zs = ≈xl (≈xr xs≈ys,zs)\n\nlemma-merge : {ι ι' : Size}{b : Bound}(xs : SOList {ι} b)(ys : SOList {ι'} b) → forget (merge xs ys) ≈ (forget xs , forget ys) \nlemma-merge onil ys = ≈[]l (forget ys)\nlemma-merge xs onil \n with xs\n... | onil = ≈[]r []\n... | (:< {x = z} b≤z zs) = ≈[]r (z ∷ forget zs)\nlemma-merge (:< {x = x} b≤x xs) (:< {x = y} b≤y ys) \n with tot≤ x y\n... | inj₁ x≤y = ≈xl (lemma-merge xs (:< (lexy x≤y) ys))\n... | inj₂ y≤x = ≈xr (lemma-merge (:< (lexy y≤x) xs) ys)\n\nlemma-mergesort : {ι : Size}(xs : SList A {↑ ι}) → unsize A xs ∼ forget (mergesort xs)\nlemma-mergesort snil = ∼[]\nlemma-mergesort (x ∙ snil) = ∼x /head /head ∼[]\nlemma-mergesort (x ∙ (y ∙ xs)) = lemma≈ (≈xl (≈xr (lemma-deal xs))) (lemma-mergesort (x ∙ ys)) (lemma-mergesort (y ∙ zs)) (lemma-merge (mergesort (x ∙ ys)) (mergesort (y ∙ zs)))\n where d = deal xs\n ys = proj₁ d\n zs = proj₂ d\n\ntheorem-mergesort-∼ : (xs : List A) → xs ∼ (forget (mergesort (size A xs)))\ntheorem-mergesort-∼ xs = trans∼ (lemma-unsize-size A xs) (lemma-mergesort (size A xs))\n", "meta": {"hexsha": "8d7003eadcd98cb819e64331d80e6432605a96ca", "size": 1927, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Mergesort/Impl1/Correctness/Permutation.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/Mergesort/Impl1/Correctness/Permutation.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/Mergesort/Impl1/Correctness/Permutation.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.7843137255, "max_line_length": 177, "alphanum_fraction": 0.598858329, "num_tokens": 728, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.92414182206801, "lm_q2_score": 0.847967764140929, "lm_q1q2_score": 0.7836424746081346}} {"text": "module Nat where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl)\nopen Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _∎)\n\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\n{-# BUILTIN NATURAL ℕ #-}\n\n_+_ : ℕ → ℕ → ℕ\nzero + n = n\n(suc m) + n = suc (m + n)\n\n_ : 2 + 3 ≡ 5\n_ =\n begin\n 2 + 3\n ≡⟨⟩\n suc (1 + 3)\n ≡⟨⟩\n suc (suc (0 + 3))\n ≡⟨⟩\n suc (suc 3)\n ≡⟨⟩\n 5\n ∎\n\n\n", "meta": {"hexsha": "c48f04dc0d15c691a635bd307464d6d7268063b3", "size": 404, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "extra/extra/Nat.agda", "max_stars_repo_name": "manikdv/plfa.github.io", "max_stars_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1003, "max_stars_repo_stars_event_min_datetime": "2018-07-05T18:15:14.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-27T07:03:28.000Z", "max_issues_repo_path": "extra/extra/Nat.agda", "max_issues_repo_name": "manikdv/plfa.github.io", "max_issues_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 323, "max_issues_repo_issues_event_min_datetime": "2018-07-05T22:34:34.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-30T07:42:57.000Z", "max_forks_repo_path": "extra/extra/Nat.agda", "max_forks_repo_name": "manikdv/plfa.github.io", "max_forks_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 304, "max_forks_repo_forks_event_min_datetime": "2018-07-16T18:24:59.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-28T11:35:02.000Z", "avg_line_length": 12.625, "max_line_length": 50, "alphanum_fraction": 0.4876237624, "num_tokens": 192, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9449947163538936, "lm_q2_score": 0.8289388125473628, "lm_q1q2_score": 0.7833427980379285}} {"text": "module treeThms where\r\n\r\nopen import lib\r\n\r\n-- simple Tree type storing natural numbers\r\ndata Tree : Set where\r\n Node : ℕ → Tree → Tree → Tree\r\n Leaf : Tree\r\n\r\nmirror : Tree → Tree\r\nmirror (Node x t1 t2) = Node x (mirror t2) (mirror t1)\r\nmirror Leaf = Leaf\r\n\r\nmirror-mirror : ∀ (t : Tree) → mirror (mirror t) ≡ t\r\nmirror-mirror Leaf = refl\r\nmirror-mirror (Node x t1 t2) rewrite mirror-mirror t2 | mirror-mirror t1 = refl\r\n\r\n\r\nsize : Tree → ℕ\r\nsize (Node x t t₁) = 1 + size t + size t₁\r\nsize Leaf = 1\r\n\r\nheight : Tree → ℕ\r\nheight (Node x t t₁) = 1 + (max (height t) (height t₁))\r\nheight Leaf = 0\r\n\r\nnumLeaves : Tree → ℕ\r\nnumLeaves (Node x t t₁) = numLeaves t + numLeaves t₁\r\nnumLeaves Leaf = 1\r\n\r\nperfect : ℕ → Tree\r\nperfect zero = Leaf\r\nperfect (suc n) = Node 1 (perfect n) (perfect n)\r\n\r\n-- I found I needed the +0 theorem from nat-thms.agda in the IAL\r\nperfect-numLeaves : ∀(n : ℕ) → numLeaves (perfect n) ≡ 2 pow n\r\nperfect-numLeaves zero = refl\r\nperfect-numLeaves (suc n) rewrite +0 (2 pow n) | perfect-numLeaves n = refl\r\n\r\nperfect-size : ∀(n : ℕ) → suc (size (perfect n)) ≡ 2 pow (suc n)\r\nperfect-size zero = refl\r\nperfect-size (suc n) rewrite sym (perfect-size n) | +0 (size(perfect n)) | sym (+suc(size(perfect n))(size(perfect n)))= refl\r\n\r\n-- helper lemma I found I needed below\r\nmax-same : ∀ (n : ℕ) → max n n ≡ n\r\nmax-same n rewrite <-irrefl n = refl\r\n\r\nperfect-height : ∀(n : ℕ) → height (perfect n) ≡ n\r\nperfect-height zero = refl\r\nperfect-height (suc n) rewrite max-same (height(perfect n)) | perfect-height n = refl\r\n\r\nnumNodes : Tree → ℕ\r\nnumNodes (Node x t1 t2) = 1 + numNodes t1 + numNodes t2 \r\nnumNodes Leaf = 0\r\n\r\n-- flatten a tree into a list of all the values stored at the nodes\r\nprefixFlatten : Tree → 𝕃 ℕ\r\nprefixFlatten (Node x t1 t2) = x :: prefixFlatten t1 ++ prefixFlatten t2\r\nprefixFlatten Leaf = []\r\n\r\n-- I found I needed a theorem from list-thms.agda in the IAL\r\nlength-flatten : ∀(t : Tree) → numNodes t ≡ length (prefixFlatten t)\r\nlength-flatten (Node x t1 t2) rewrite length-++(prefixFlatten t1) (prefixFlatten t2) | length-flatten t1 | length-flatten t2 = refl\r\nlength-flatten Leaf = refl\r\n", "meta": {"hexsha": "fa78d604d84f53c4712c4dcc8b9c3ad057fc784b", "size": 2131, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "treeThms.agda", "max_stars_repo_name": "DTMcNamara/CS3820-ProgrammingLanguageConcepts-Workout7", "max_stars_repo_head_hexsha": "0117aa66ff3cbc8d75be3c9705bada96bdcf8d5a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "treeThms.agda", "max_issues_repo_name": "DTMcNamara/CS3820-ProgrammingLanguageConcepts-Workout7", "max_issues_repo_head_hexsha": "0117aa66ff3cbc8d75be3c9705bada96bdcf8d5a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "treeThms.agda", "max_forks_repo_name": "DTMcNamara/CS3820-ProgrammingLanguageConcepts-Workout7", "max_forks_repo_head_hexsha": "0117aa66ff3cbc8d75be3c9705bada96bdcf8d5a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.7846153846, "max_line_length": 132, "alphanum_fraction": 0.6611919287, "num_tokens": 694, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8976952811593496, "lm_q2_score": 0.8723473846343393, "lm_q1q2_score": 0.7831021307179464}} {"text": "{-# OPTIONS --safe #-}\nmodule Squaring where\n\nopen import Relation.Binary.PropositionalEquality\nopen import Data.Nat\nopen import Data.Product\nopen import Data.Bool hiding (_≤_;_<_)\nopen import Data.Nat.Properties\n\nopen ≡-Reasoning\n\ndiv-mod2 : ℕ → ℕ × Bool\ndiv-mod2 0 = 0 , false\ndiv-mod2 (suc 0) = 0 , true\ndiv-mod2 (suc (suc n)) = let q , r = div-mod2 n in suc q , r\n\n-- The first argument (k) helps Agda to prove\n-- that the function terminates\npow-sqr-aux : ℕ → ℕ → ℕ → ℕ\npow-sqr-aux 0 _ _ = 1\npow-sqr-aux _ _ 0 = 1\npow-sqr-aux (suc k) b e with div-mod2 e\n... | e' , false = pow-sqr-aux k (b * b) e'\n... | e' , true = b * pow-sqr-aux k (b * b) e'\n\npow-sqr : ℕ → ℕ → ℕ\npow-sqr b e = pow-sqr-aux e b e\n\ndiv-mod2-spec : ∀ n → let q , r = div-mod2 n in 2 * q + (if r then 1 else 0) ≡ n\ndiv-mod2-spec 0 = refl\ndiv-mod2-spec 1 = refl\ndiv-mod2-spec (suc (suc n)) with div-mod2 n | div-mod2-spec n\n... | q , r | eq rewrite +-suc q (q + 0) | eq = refl\n\ndiv-mod2-lt : ∀ n → 0 < n → proj₁ (div-mod2 n) < n\ndiv-mod2-lt 0 lt = lt\ndiv-mod2-lt 1 lt = lt\ndiv-mod2-lt 2 lt = s≤s (s≤s z≤n)\ndiv-mod2-lt (suc (suc (suc n))) lt with\n div-mod2 (suc n) | div-mod2-lt (suc n) (s≤s z≤n)\n... | q , r | ih = ≤-step (s≤s ih)\n\npow-lemma : ∀ b e → (b * b) ^ e ≡ b ^ (2 * e)\npow-lemma b e = begin\n (b * b) ^ e ≡⟨ cong (λ t → (b * t) ^ e) (sym (*-identityʳ b)) ⟩\n (b ^ 2) ^ e ≡⟨ ^-*-assoc b 2 e ⟩\n b ^ (2 * e) ∎\n\npow-sqr-lemma : ∀ k b e → e ≤ k → pow-sqr-aux k b e ≡ b ^ e\npow-sqr-lemma 0 _ 0 _ = refl\npow-sqr-lemma (suc k) _ 0 _ = refl\npow-sqr-lemma (suc k) b (suc e) (s≤s le) with\n div-mod2 (suc e) | div-mod2-spec (suc e) | div-mod2-lt (suc e) (s≤s z≤n)\n... | e' , false | eq | lt = begin\n pow-sqr-aux k (b * b) e' ≡⟨ pow-sqr-lemma k (b * b) e' (≤-trans (≤-pred lt) le) ⟩\n (b * b) ^ e' ≡⟨ pow-lemma b e' ⟩\n b ^ (2 * e') ≡⟨ cong (b ^_) (trans (sym (+-identityʳ (e' + (e' + 0)))) eq) ⟩\n b ^ suc e ∎\n... | e' , true | eq | lt = cong (b *_) (begin\n pow-sqr-aux k (b * b) e' ≡⟨ pow-sqr-lemma k (b * b) e' (≤-trans (≤-pred lt) le) ⟩\n (b * b) ^ e' ≡⟨ pow-lemma b e' ⟩\n b ^ (2 * e') ≡⟨ cong (b ^_) (suc-injective (trans (+-comm 1 _) eq)) ⟩\n b ^ e ∎)\n\n", "meta": {"hexsha": "0e79fa7c05b86b73e4be6e69d150ee04912055a0", "size": 2130, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Agda/Squaring.agda", "max_stars_repo_name": "Brethland/LEARNING-STUFF", "max_stars_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-02-03T05:05:52.000Z", "max_stars_repo_stars_event_max_datetime": "2020-03-11T10:35:42.000Z", "max_issues_repo_path": "Agda/Squaring.agda", "max_issues_repo_name": "Brethland/LEARNING-STUFF", "max_issues_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Agda/Squaring.agda", "max_forks_repo_name": "Brethland/LEARNING-STUFF", "max_forks_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-12-13T04:50:46.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-13T04:50:46.000Z", "avg_line_length": 32.7692307692, "max_line_length": 83, "alphanum_fraction": 0.541314554, "num_tokens": 993, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9149009457116781, "lm_q2_score": 0.855851143290548, "lm_q1q2_score": 0.7830190203849433}} {"text": "open import Relation.Binary.Core\n\nmodule BBSTree.Properties {A : Set} \n (_≤_ : A → A → Set)\n (trans≤ : Transitive _≤_) where\n\nopen import BBSTree _≤_\nopen import Bound.Total A\nopen import Bound.Total.Order.Properties _≤_ trans≤\nopen import List.Order.Simple _≤_\nopen import List.Order.Simple.Properties _≤_ trans≤\nopen import List.Sorted _≤_\n\nlemma-bbst-*≤ : {b : Bound}(x : A) → (t : BBSTree b (val x)) → flatten t *≤ x\nlemma-bbst-*≤ x (bslf _) = lenx\nlemma-bbst-*≤ x (bsnd {x = y} b≤y y≤x l r) = lemma-++-*≤ (lemma-LeB≤ y≤x) (lemma-bbst-*≤ y l) (lemma-bbst-*≤ x r)\n\nlemma-bbst-≤* : {b : Bound}(x : A) → (t : BBSTree (val x) b) → x ≤* flatten t\nlemma-bbst-≤* x (bslf _) = genx\nlemma-bbst-≤* x (bsnd {x = y} x≤y y≤t l r) = lemma-≤*-++ (lemma-LeB≤ x≤y) (lemma-bbst-≤* x l) (lemma-bbst-≤* y r)\n\nlemma-bbst-sorted : {b t : Bound}(t : BBSTree b t) → Sorted (flatten t)\nlemma-bbst-sorted (bslf _) = nils\nlemma-bbst-sorted (bsnd {x = x} b≤x x≤t l r) = lemma-sorted++ (lemma-bbst-*≤ x l) (lemma-bbst-≤* x r) (lemma-bbst-sorted l) (lemma-bbst-sorted r)\n", "meta": {"hexsha": "4ad3c06cc886e1fccd72b9d044ff3379d6110948", "size": 1086, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/BBSTree/Properties.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/BBSTree/Properties.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/BBSTree/Properties.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.44, "max_line_length": 145, "alphanum_fraction": 0.6012891344, "num_tokens": 445, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9496693702514737, "lm_q2_score": 0.824461932846258, "lm_q1q2_score": 0.7829662445624186}} {"text": "module x01-842Naturals-hc-2 where\n\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n{-# BUILTIN NATURAL ℕ #-}\n\none : ℕ\none = suc zero\n\ntwo : ℕ\ntwo = suc (suc zero)\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl)\nopen Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _∎)\n\nseven : ℕ\nseven = suc (suc (suc (suc (suc (suc (suc zero))))))\n\n_ : seven ≡ 7\n_ = refl\n\n_+_ : ℕ → ℕ → ℕ\nzero + n = n\nsuc m + n = suc (m + n)\n\n_ : 2 + 3 ≡ 5\n_ = refl\n\n_ : 2 + 3 ≡ 5\n_ =\n begin\n 2 + 3\n ≡⟨⟩ -- is shorthand for\n (suc (suc zero)) + (suc (suc (suc zero)))\n ≡⟨⟩ -- many steps condensed\n 5\n ∎\n\n_*_ : ℕ → ℕ → ℕ\nzero * n = zero\nsuc m * n = n + (m * n)\n\n_ =\n begin\n 2 * 3\n ≡⟨⟩ -- many steps condensed\n 6\n ∎\n\n_ : 3 * 4 ≡ 12\n_ = refl\n\n_^_ : ℕ → ℕ → ℕ\nm ^ zero = suc zero\nm ^ suc n = m * (m ^ n)\n\n_ : 2 ^ 0 ≡ 1\n_ = refl\n\n_ : 2 ^ 1 ≡ 2\n_ = refl\n\n_ : 2 ^ 2 ≡ 4\n_ = refl\n\n_ : 2 ^ 3 ≡ 8\n_ = refl\n\n_ : 3 ^ 3 ≡ 27\n_ = refl\n\n_∸_ : ℕ → ℕ → ℕ\nzero ∸ n = zero\nm ∸ zero = m\nsuc m ∸ suc n = m ∸ n\n\n_ : 3 ∸ 2 ≡ 1\n_ = refl\n\n_ : 2 ∸ 3 ≡ 0\n_ = refl\n\ninfixl 6 _+_ _∸_\ninfixl 7 _*_\n\n{-# BUILTIN NATPLUS _+_ #-}\n{-# BUILTIN NATTIMES _*_ #-}\n{-# BUILTIN NATMINUS _∸_ #-}\n\n-- Binary representation.\n\ndata Bin-ℕ : Set where\n bits : Bin-ℕ\n _x0 : Bin-ℕ → Bin-ℕ\n _x1 : Bin-ℕ → Bin-ℕ\n\n-- Our representation of zero is different from PLFA.\n-- We use the empty sequence of bits (more consistent).\n\nbin-zero : Bin-ℕ\nbin-zero = bits\n\nbin-one : Bin-ℕ\nbin-one = bits x1 -- 1 in binary\n\nbin-two : Bin-ℕ\nbin-two = bits x1 x0 -- 10 in binary\n\n-- 842 exercise: Increment (1 point)\n-- Define increment (add one).\n\ninc : Bin-ℕ → Bin-ℕ\ninc bits = bits x1\ninc (m x0) = m x1\ninc (m x1) = (inc m) x0\n\n_ : inc (bits) ≡ bits x1\n_ = refl\n_ : inc (bits x1) ≡ bits x1 x0\n_ = refl\n_ : inc (bits x1 x0) ≡ bits x1 x1\n_ = refl\n_ : inc (bits x1 x1) ≡ bits x1 x0 x0\n_ = refl\n_ : inc (bits x1 x0 x0) ≡ bits x1 x0 x1\n_ = refl\n_ : inc (bits x1 x0 x1) ≡ bits x1 x1 x0\n_ = refl\n_ : inc (bits x1 x1 x0) ≡ bits x1 x1 x1\n_ = refl\n_ : inc (bits x1 x1 x1) ≡ bits x1 x0 x0 x0\n_ = refl\n_ : inc (bits x1 x0 x1 x1) ≡ bits x1 x1 x0 x0\n_ = refl\n\ndbl : ℕ → ℕ\ndbl zero = zero\ndbl (suc m) = suc (suc (dbl m))\n\ntob : ℕ → Bin-ℕ\ntob zero = bits\ntob (suc m) = inc (tob m)\n\nfromb : Bin-ℕ → ℕ\nfromb bits = zero\nfromb (n x0) = dbl (fromb n)\nfromb (n x1) = suc (dbl (fromb n))\n\n_ : tob 6 ≡ bits x1 x1 x0\n_ = refl\n\n_ : fromb bits ≡ 0\n_ = refl\n_ : fromb (bits x0) ≡ 0\n_ = refl\n_ : fromb (bits x1) ≡ 1\n_ = refl\n_ : fromb (bits x1 x0) ≡ 2\n_ = refl\n_ : fromb (bits x1 x1) ≡ 3\n_ = refl\n_ : fromb (bits x1 x1 x0) ≡ 6\n_ = refl\n_ : fromb (bits x1 x1 x0) ≡ 6\n_ = refl\n\n-- Do NOT use 'to' and 'from'. Work with Bin-ℕ as if ℕ did not exist.\n_bin-+_ : Bin-ℕ → Bin-ℕ → Bin-ℕ\nbits bin-+ n = n\nm bin-+ bits = m\n(m x0) bin-+ (n x0) = (m bin-+ n) x0\n(m x0) bin-+ (n x1) = inc ((m bin-+ n) x0)\n(m x1) bin-+ (n x0) = inc ((m bin-+ n) x0)\n(m x1) bin-+ (n x1) = inc (inc ((m bin-+ n) x0))\n\n_ : (bits x1 x0 x0 x0) bin-+ (bits x1) ≡ (bits x1 x0 x0 x1)\n_ = refl\n_ : (bits x1 x0 x0 x1) bin-+ (bits x1) ≡ (bits x1 x0 x1 x0)\n_ = refl\n_ : (bits x1 x0 x0 x0) bin-+ (bits x1 x1 x1) ≡ (bits x1 x1 x1 x1)\n_ = refl\n_ : (tob 6) bin-+ (tob 2) ≡ (tob 8)\n_ = refl\n_ : (bits x1 x0) bin-+ (bits x1 x1) ≡ (bits x1 x0 x1)\n_ = refl\n", "meta": {"hexsha": "a929e643a2ec6107eaa30e1d1711192b9a590874", "size": 3416, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x01-842Naturals-hc-2.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x01-842Naturals-hc-2.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x01-842Naturals-hc-2.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 18.170212766, "max_line_length": 69, "alphanum_fraction": 0.5181498829, "num_tokens": 1616, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9124361604769413, "lm_q2_score": 0.8577681013541611, "lm_q1q2_score": 0.7826586329791867}} {"text": "\nmodule Logic.Relations where\n\nimport Logic.Base\nimport Data.Bool\n\nRel : Set -> Set1\nRel A = A -> A -> Set\n\nReflexive : {A : Set} -> Rel A -> Set\nReflexive {A} _R_ = (x : A) -> x R x\n\nSymmetric : {A : Set} -> Rel A -> Set\nSymmetric {A} _R_ = (x y : A) -> x R y -> y R x\n\nTransitive : {A : Set} -> Rel A -> Set\nTransitive {A} _R_ = (x y z : A) -> x R y -> y R z -> x R z\n\nCongruent : {A : Set} -> Rel A -> Set\nCongruent {A} _R_ = (f : A -> A)(x y : A) -> x R y -> f x R f y\n\nSubstitutive : {A : Set} -> Rel A -> Set1\nSubstitutive {A} _R_ = (P : A -> Set)(x y : A) -> x R y -> P x -> P y\n\nmodule PolyEq (_≡_ : {A : Set} -> Rel A) where\n\n Antisymmetric : {A : Set} -> Rel A -> Set\n Antisymmetric {A} _R_ = (x y : A) -> x R y -> y R x -> x ≡ y\n\nmodule MonoEq {A : Set}(_≡_ : Rel A) where\n\n Antisymmetric : Rel A -> Set\n Antisymmetric _R_ = (x y : A) -> x R y -> y R x -> x ≡ y\n\nopen Logic.Base\n\nTotal : {A : Set} -> Rel A -> Set\nTotal {A} _R_ = (x y : A) -> (x R y) \\/ (y R x)\n\nDecidable : (P : Set) -> Set\nDecidable P = P \\/ ¬ P\n\n", "meta": {"hexsha": "a87a668b665b1195588a7885b36f559129963008", "size": 1032, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/lib/Logic/Relations.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/lib/Logic/Relations.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/lib/Logic/Relations.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 24.0, "max_line_length": 69, "alphanum_fraction": 0.5145348837, "num_tokens": 430, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9465966717067253, "lm_q2_score": 0.8267117898012105, "lm_q1q2_score": 0.7825626286865358}} {"text": "module Peano where\n open import IPL\n\n data ℕ : Set where\n zero : ℕ -- Axiom 2.1. 0 is a natural number\n _++ : ℕ → ℕ -- Axiom 2.2. If n is a natural number, then n++ is also a natural number\n\n data _≡_ : ℕ → ℕ → Set where\n refl : {a : ℕ} → a ≡ a\n\n axiom23 : {n : ℕ} → ¬ (zero ≡ (n ++))\n axiom23 = λ ()\n\n axiom24 : {n m : ℕ} → (n ++) ≡ (m ++) → n ≡ m\n axiom24 refl = refl\n\n _+_ : ℕ → ℕ → ℕ -- Definition 2.2.1\n zero + m = m\n (n ++) + m = (n + m) ++\n\n ≡-sec : {n m : ℕ} → n ≡ m → (n ++) ≡ (m ++)\n ≡-sec refl = refl \n\n ≡-comm : {n m : ℕ} → n ≡ m → m ≡ n\n ≡-comm refl = refl\n\n ≡-trans : {n m p : ℕ} → n ≡ m → m ≡ p → n ≡ p\n ≡-trans refl refl = refl\n\n lemma222 : (n : ℕ) → (n + zero) ≡ n\n lemma222 zero = refl\n lemma222 (n ++) = ≡-sec (lemma222 n) \n\n lemma223 : (n m : ℕ) → (n + (m ++)) ≡ ((n + m) ++)\n lemma223 zero m = refl\n lemma223 (n ++) m = ≡-sec (lemma223 n m)\n\n -- Addition is commutative\n prop224 : (n m : ℕ) → (n + m) ≡ (m + n)\n prop224 zero m = ≡-comm (lemma222 m)\n prop224 (n ++) m = ≡-trans (≡-sec (prop224 n m)) (≡-comm (lemma223 m n))\n\n -- Addition is associative\n prop225 : (a b c : ℕ) → ((a + b) + c) ≡ (a + (b + c))\n prop225 zero b c = refl\n prop225 (a ++) b c = ≡-sec (prop225 a b c)\n\n -- Cancellation law\n prop226 : (a b c : ℕ) → (a + b) ≡ (a + c) → b ≡ c\n prop226 zero b c = λ z → z\n prop226 (a ++) b c = λ z → (prop226 a b c) (axiom24 z)\n", "meta": {"hexsha": "72bcadde4ad88ae3b39628483044f6b015332d48", "size": 1397, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "peano.agda", "max_stars_repo_name": "alf239/tao", "max_stars_repo_head_hexsha": "11f8071e325d07d19a53157cb065d88244b20cb4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "peano.agda", "max_issues_repo_name": "alf239/tao", "max_issues_repo_head_hexsha": "11f8071e325d07d19a53157cb065d88244b20cb4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "peano.agda", "max_forks_repo_name": "alf239/tao", "max_forks_repo_head_hexsha": "11f8071e325d07d19a53157cb065d88244b20cb4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.8653846154, "max_line_length": 89, "alphanum_fraction": 0.4781675018, "num_tokens": 612, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9511422186079558, "lm_q2_score": 0.822189121808099, "lm_q1q2_score": 0.7820187854318821}} {"text": "module x04equality where\n\n------------------------------------------------------------------------------\n-- EQUALITY\n\n-- for any type A\n-- for any x of type A\n-- refl constructor provides evidence that x ≡ x\n-- i.e., every value is equal to itself\ndata _≡_ {A : Set} (x : A) : A → Set where\n refl : x ≡ x\n\ninfix 4 _≡_\n\n-- tell Agda which type corresponds to equality\n{-# BUILTIN EQUALITY _≡_ #-}\n\n{-\nNote:\n- 1st arg to _≡_ is PARAMETER (x : A)\n - BEST PRACTICE: use parameters when possible\n - can be a parameter because it does not vary\n- 2nd arg is an INDEX in A → Set\n - must be an index, so it can be required to be equal to the first\n\n------------------------------------------------------------------------------\n-- EQUALITY is an EQUIVALENCE RELATION (reflexive, symmetric, transitive)\n\nreflexivity in the def of equality, via refl constructor\n-}\n\n-- symmetry\nsym : ∀ {A : Set} {x y : A}\n → x ≡ y -- arg has type x ≡ y\n -----\n → y ≡ x\nsym refl -- LHS :instantiates arg to refl CONSTRUCTOR (only one possible)\n -- refl requires x y to be the same\n = refl -- RHS : need a term of type x ≡ x, so refl\n\n-- transitive\ntrans : ∀ {A : Set} {x y z : A}\n → x ≡ y\n → y ≡ z\n -----\n → x ≡ z\ntrans refl refl = refl\n\n------------------------------------------------------------------------------\n-- EQUALITY SATISFIES CONGRUENCE\n\n-- if two terms are equal, they remain so after same function is applied to both\ncong : ∀ {A B : Set} (f : A → B) {x y : A}\n → x ≡ y\n ---------\n → f x ≡ f y\ncong f refl = refl\n\n-- where f takes two args\ncong₂ : ∀ {A B C : Set} (f : A → B → C) {u x : A} {v y : B}\n → u ≡ x\n → v ≡ y\n -------------\n → f u v ≡ f x y\ncong₂ f refl refl = refl\n\n-- if two functions are equal, then applying them to same term yields equal terms\ncong-app : ∀ {A B : Set} {f g : A → B}\n → f ≡ g\n ---------------------\n → ∀ (x : A) → f x ≡ g x\ncong-app refl x = refl\n\n------------------------------------------------------------------------------\n-- EQUALITY SATISFIES SUBSTITUTION\n\n-- if two values are equal and a predicate holds of first then it also holds of second\nsubst : ∀ {A : Set} {x y : A} (P : A → Set)\n → x ≡ y\n ---------\n → P x\n → P y\nsubst P refl px = px\n\n------------------------------------------------------------------------------\n-- CHAINS OF EQUATIONS (aka EQUATIONAL REASONING)\n\nmodule ≡-Reasoning {A : Set} where\n\n infix 1 begin_\n infixr 2 _≡⟨⟩_ _≡⟨_⟩_\n infix 3 _∎\n\n -- identity : this is just used to make proof look nice\n begin_ : ∀ {x y : A}\n → x ≡ y\n -----\n → x ≡ y\n begin x≡y = x≡y\n\n -- think of _≡⟨⟩_ as equivalent to _≡⟨ refl ⟩_\n _≡⟨⟩_ : ∀ (x : A) {y : A}\n → x ≡ y\n -----\n → x ≡ y\n x ≡⟨⟩ x≡y = x≡y\n\n _≡⟨_⟩_ : ∀ (x : A) {y z : A}\n → x ≡ y\n → y ≡ z\n -----\n → x ≡ z\n x ≡⟨ x≡y ⟩ y≡z = trans x≡y y≡z\n\n _∎ : ∀ (x : A)\n -----\n → x ≡ x\n x ∎ = refl\n\nopen ≡-Reasoning\n\ntrans′ : ∀ {A : Set} {x y z : A}\n → x ≡ y\n → y ≡ z\n -----\n → x ≡ z\ntrans′ {A} {x} {y} {z} x≡y y≡z =\n begin -- Goal: x ≡ z ; y≡z : y ≡ z; x≡y : x ≡ y\n x ≡⟨ x≡y ⟩ -- Goal: y ≡ z\n y ≡⟨ y≡z ⟩ -- Goal: z ≡ z\n z\n ∎\n\n{-\nEXERCISE trans and ≡-Reasoning (practice) TODO\nCannot use definition of trans’ using ≡-Reasoning as the definition for trans.\nWhy?\nHint: look at the definition of _≡⟨_⟩_\n\n-- Your code goes here\n\n------------------------------------------------------------------------------\nChains of equations, another example : addition is commutative\n-}\n\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\n{-# BUILTIN NATURAL ℕ #-}\n\n_+_ : ℕ → ℕ → ℕ\nzero + n = n\n(suc m) + n = suc (m + n)\n\ninfixl 6 _+_\n\n-- to save space, postulate (rather than prove) two lemmas:\n-- POSTULATE : specifies a signature but no def. Use with care. DON'T postulate something false!\npostulate\n +-identity : ∀ (m : ℕ) → m + zero ≡ m\n +-suc : ∀ (m n : ℕ) → m + suc n ≡ suc (m + n)\n\n+-comm : ∀ (m n : ℕ) → m + n ≡ n + m\n+-comm m zero =\n begin\n m + zero ≡⟨ +-identity m ⟩\n m ≡⟨⟩\n zero + m\n ∎\n+-comm m (suc n) =\n begin\n m + suc n ≡⟨ +-suc m n ⟩\n suc (m + n) ≡⟨ cong suc (+-comm m n) ⟩\n suc (n + m) ≡⟨⟩ -- terms are equivalent to simplified term\n suc n + m\n ∎\n\n{-\n------------------------------------------------------------------------------\nExercise ≤-Reasoning (stretch)\n\nredo proof of +-monoʳ-≤ (from Chapter Relations) using an analogue of ≡-Reasoning\n\ndefine ≤-Reasoning\n\nuse it to write out proof that addition is monotonic with regard to inequality\nby redoing all of +-monoˡ-≤, +-monoʳ-≤, and +-mono-≤\n-}\n\nmodule ≤-Reasoning {A : Set} where\n\n data _≤_ : ℕ → ℕ → Set where\n z≤n : ∀ {n : ℕ}\n --------\n → zero ≤ n\n\n s≤s : ∀ {m n : ℕ}\n → m ≤ n\n -------------\n → suc m ≤ suc n\n\n infix 4 _≤_\n\n ≤-trans : ∀ {m n p : ℕ} → m ≤ n → n ≤ p → m ≤ p\n ≤-trans z≤n _ = z≤n\n ≤-trans (s≤s m≤n) (s≤s n≤p) = s≤s (≤-trans m≤n n≤p)\n\n infix 1 begin≤_\n infixr 2 _≤⟨⟩_ _≤⟨_⟩_\n infix 3 _∎≤\n\n --------------------------------------------------\n\n begin≤_ : ∀ {x y : ℕ}\n → x ≤ y\n -----\n → x ≤ y\n begin≤ x≤y = x≤y\n\n -- can think of _≤⟨⟩_ as equivalent to _≤⟨ refl ⟩_\n _≤⟨⟩_ : ∀ (x : ℕ) {y : ℕ}\n → x ≤ y\n -----\n → x ≤ y\n x ≤⟨⟩ x≤y = x≤y\n\n _≤⟨_⟩_ : ∀ (x : ℕ) {y z : ℕ}\n → x ≤ y\n → y ≤ z\n -----\n → x ≤ z\n x ≤⟨ x≤y ⟩ y≤z = ≤-trans x≤y y≤z\n\n _∎≤ : ∀ (x : ℕ)\n -----\n → x ≤ x\n zero ∎≤ = z≤n\n suc x ∎≤ = s≤s (x ∎≤)\n\n --------------------------------------------------\n\n +-monoʳ-≤ : ∀ (n p q : ℕ)\n → p ≤ q\n -------------\n → (n + p) ≤ (n + q)\n\n +-monoʳ-≤ zero p q p≤q =\n begin≤\n zero + p ≤⟨⟩\n p ≤⟨ p≤q ⟩\n q ≤⟨⟩\n zero + q\n ∎≤\n\n +-monoʳ-≤ (suc n) p q p≤q =\n begin≤\n suc n + p ≤⟨ s≤s (+-monoʳ-≤ n p q p≤q) ⟩\n suc n + q\n ∎≤\n\n -------------------------\n\n postulate\n +-comm-≤ : ∀ (m n : ℕ) → m + n ≤ n + m\n\n +-monoˡ-≤ : ∀ (m n p : ℕ)\n → m ≤ n\n -------------\n → m + p ≤ n + p\n\n +-monoˡ-≤ m n p m≤n =\n begin≤\n m + p ≤⟨ +-comm-≤ m p ⟩\n p + m ≤⟨ +-monoʳ-≤ p m n m≤n ⟩\n p + n ≤⟨ +-comm-≤ p n ⟩\n n + p\n ∎≤\n\n -------------------------\n\n +-mono-≤ : ∀ (m n p q : ℕ)\n → m ≤ n\n → p ≤ q\n -------------\n → m + p ≤ n + q\n +-mono-≤ m n p q m≤n p≤q =\n begin≤\n m + p ≤⟨ +-monoˡ-≤ m n p m≤n ⟩\n n + p ≤⟨ +-monoʳ-≤ n p q p≤q ⟩\n n + q\n ∎≤\n\n{-\n------------------------------------------------------------------------------\n-- Rewriting\n-}\n\ndata even : ℕ → Set\ndata odd : ℕ → Set\n\ndata even where\n\n even-zero : even zero\n\n even-suc : ∀ {n : ℕ}\n → odd n\n ------------\n → even (suc n)\n\ndata odd where\n odd-suc : ∀ {n : ℕ}\n → even n\n -----------\n → odd (suc n)\n\n{-\ngiven even (m + n) holds\nprove even (n + m) holds\n\nREWRITE: notation to support this kind of reasoning\n-}\n\n-- then use rewrite\neven-comm : ∀ (m n : ℕ)\n → even (m + n)\n ------------\n → even (n + m)\neven-comm m n ev -- even (n + m)\n rewrite +-comm n m -- Goal: even (m + n); ev : even (m + n)\n = ev\n\n{-\nkeyword REWRITE : followed by evidence of an equality\nThat equality is used to rewrite the type of the goal and of any variable in scope.\n-}\n\neven-comm' : ∀ (m n : ℕ)\n → even (m + n)\n ------------\n → even (n + m)\neven-comm' m n ev -- Goal: even (n + m) ; ev : even (m + n)\n rewrite\n +-comm m n -- Goal: even (n + m) ; ev : even (n + m) <-- rewrites evidence\n = ev -- ^\n-- note: arg order diff than 'even-comm' above\n\n------------------------------------------------------------------------------\n-- Multiple rewrites : each separated by a vertical bar\n\n+-comm′ : ∀ (m n : ℕ) → m + n ≡ n + m\n+-comm′ zero n -- zero + n ≡ n + zero\n -- n ≡ n + zero\n rewrite\n +-identity n -- n ≡ n\n = refl\n+-comm′ (suc m) n -- suc m + n ≡ n + suc m\n -- suc (m + n) ≡ n + suc m\n rewrite\n +-suc n m -- suc (m + n) ≡ suc (n + m) <-- rewrites LHS\n | +-comm′ m n -- suc (n + m) ≡ suc (n + m) <-- rewrites RHS\n = refl\n\n{-\nPrevious +-comm proof required cong suc (+-comm m n) (invoking inductive hypothesis).\nRewriting automatically takes congruence into account.\nProofs with rewriting are shorter.\nProofs as chains of equalities are easier to follow.\n-}\n\n+-comm′' : ∀ (m n : ℕ) → m + n ≡ n + m\n+-comm′' zero n =\n begin\n zero + n ≡⟨⟩\n n ≡⟨ +-comm′ zero n ⟩\n n + zero\n ∎\n+-comm′' (suc m) n =\n begin\n suc m + n ≡⟨ +-comm′ (suc m) n ⟩\n n + suc m\n ∎\n\n{-\n------------------------------------------------------------------------------\n--rewrite is shorthand for 'WITH'\n-}\n\neven-comm′ : ∀ (m n : ℕ)\n → even (m + n)\n ------------\n → even (n + m)\neven-comm′ m n ev with m + n | +-comm m n\n... | .(n + m) | refl = ev\n\n{-\nWITH : can be followed by one or more expressions, separated by bars\n- where each equation has the same number of patterns\n\n1st COLUMN asserts m + n and n + m are identical\n2nd COLUMN justifies assertion with evidence of the appropriate equality\n\nDOT PATTERN : .(n + m)\n- dot followed by an expression\n- used when other info forces value matched to be equal to value of expression in dot pattern\n\nHere: m + n ≡ n + m justified by matching +-comm m n with refl\n\n------------------------------------------------------------------------------\n-- using SUBSTITUTION instead of REWRITE\n-}\n\neven-comm″ : ∀ (m n : ℕ)\n → even (m + n)\n ------------\n → even (n + m)\neven-comm″ m n\n -- m + n ≡ n + m\n -- v\n--= subst even {!!}\n--= subst {!!} (+-comm m n)\n-- ^\n-- Constraints\n-- ?0 (n + m) =< even (n + m)\n-- even (m + n) =< ?0 (m + n)\n = subst even (+-comm m n)\n\n{-\n------------------------------------------------------------------------------\n-- Leibniz equality : TWO OBJECTS EQUAL IFF THEY SATISFY THE SAME PROPERTIES.\n\nThe form of asserting equality so far is due to Martin Löf (1975).\n\nAnother form is due to Leibniz (1686).\n\n\nDefine Leibniz equality and show that two terms satisfy Leibniz equality\nIFF they satisfy Martin Löf equality.\n\nx ≐ y\nholds if\nevery property P that holds of x also holds of y\nalso ensures converse\nevery property P that holds of y also holds of x\n\nLet x and y be objects of type A.\nx ≐ y holds if for every predicate P over type A we have that P x implies P y:\n-}\n\n_≐_ : ∀ {A : Set} (x y : A) → Set₁\n_≐_ {A} x y = ∀ (P : A → Set) → P x → P y\n\n{-\nwrite _≐_ {A} x y (instead of infix) to provide access to the implicit parameter A\n\nFIRST USE OF LEVELS\n\nCannot assign Set the type Set\n- would lead to contradictions such as Russell’s Paradox and Girard’s Paradox\n\nhierarchy of types, where Set : Set₁, Set₁ : Set₂, ...\n\n'Set' is an abbreviation for 'Set₀'\n\nSince the equation defining _≐_ mentions Set on the right-hand side,\nthe corresponding signature must use Set₁.\n\n------------------------------------------------------------------------------\nLeibniz equality is reflexive, transitive, symmetric\n-}\n\n-- reflexiviity follows by a variant of the identity function\nrefl-≐ : ∀ {A : Set} {x : A}\n → x ≐ x\nrefl-≐ P Px = Px\n\n-- transitivity follows by a variant of function composition\ntrans-≐ : ∀ {A : Set} {x y z : A}\n → x ≐ y\n → y ≐ z\n -----\n → x ≐ z\ntrans-≐ x≐y y≐z P Px = y≐z P (x≐y P Px)\n\n-- show that if P x implies P y for all predicates P\n-- then P y implies P x\nsym-≐ : ∀ {A : Set} {x y : A}\n → x ≐ y -- given x ≐ y\n -----\n → y ≐ x\nsym-≐ {A} {x} {y} x≐y P = Qy -- TODO : where is 'P' in the signature?\n where\n Q : A → Set -- instantiate the equality with a predicate Q such that Q z holds\n Q z = P z → P x -- if P z implies P x\n\n Qx : Q x -- The property Q x is by reflexivity, and hence Q y follows from x ≐ y.\n Qx = refl-≐ P\n\n Qy : Q y -- Q y is the required proof : P y implies P x\n Qy = x≐y Q Qx\n\n{-\n------------------------------------------------------------------------------\nMartin Löf equality implies Leibniz equality\n\ngiven x ≡ y\nneed for any P to take evidence of P x to evidence of P y\n\nthe equality of x and y implies that any proof of P x is also a proof of P y\nfollows from substitution\n-}\n\n≡-implies-≐ : ∀ {A : Set} {x y : A}\n → x ≡ y\n -----\n → x ≐ y\n≡-implies-≐ x≡y P = subst P x≡y\n\n{-\n------------------------------------------------------------------------------\nLeibniz equality implies Martin Löf equality\n\ngiven for any P we can take a proof of P x to a proof of P y\nshow x ≡ y\n\nproof is similar to that for symmetry of Leibniz equality\n-}\n\n≐-implies-≡ : ∀ {A : Set} {x y : A}\n → x ≐ y\n -----\n → x ≡ y\n≐-implies-≡ {A} {x} {y} x≐y = Qy\n where\n Q : A → Set -- Q is predicate that holds of z if x ≡ z\n Q z = x ≡ z\n\n Qx : Q x -- Q x by reflexivity of Martin Löf equality\n Qx = refl\n\n Qy : Q y -- Q y follows from x ≐ y\n Qy = x≐y Q Qx -- Q y is required proof : x ≡ y\n\n{-\nThis section adapted from\n≐≃≡: Leibniz Equality is Isomorphic to Martin-Löf Identity, Parametrically\ndraft/2017\nby Andreas Abel, Jesper Cockx, Dominique Devries, Andreas Nuyts, and Philip Wadler\n\n------------------------------------------------------------------------------\nUNIVERSE POLYMORPHISM (aka LEVELs)\n\nevery type belongs somewhere in the hierarchy Set₀, Set₁, Set₂, ...\n\nSet abbreviates Set₀\n\nSet₀ : Set₁\nSet₁ : Set₂\n...\n\nto compare values of a type that belongs to Set ℓ for some arbitrary level ℓ?\n\nvia UNIVERSE POLYMORPHISM\n\ndefinition is made with respect to an arbitrary level ℓ\n\nto use levels:\n-}\n\nopen import Level using (Level; _⊔_) renaming (zero to lzero; suc to lsuc)\n\n{-\nrename constructors zero and suc to avoid confusion between levels and naturals\n\nLevels are isomorphic to natural numbers, and have similar constructors:\n\nlzero : Level\nlsuc : Level → Level\n\nSet₀, Set₁, Set₂, ... abbreviations for\n\nSet lzero\nSet (lsuc lzero)\nSet (lsuc (lsuc lzero))\n\n_⊔_ : Level → Level → Level\n\nthat given two levels returns the larger of the two.\n-}\n\n-- equality, generalised to an arbitrary level:\ndata _≡′_ {ℓ : Level} {A : Set ℓ} (x : A) : A → Set ℓ where\n refl′ : x ≡′ x\n\n-- generalised definition of symmetry:\nsym′ : ∀ {ℓ : Level} {A : Set ℓ} {x y : A}\n → x ≡′ y\n ------\n → y ≡′ x\nsym′ refl′ = refl′\n\n{-\nFor simplicity, this book avoids universe polymorphism.\nMost definitions in the standard library are generalised to arbitrary levels as above.\n-}\n\n-- generalised definition of Leibniz equality:\n_≐′_ : ∀ {ℓ : Level} {A : Set ℓ} (x y : A) → Set (lsuc ℓ)\n_≐′_ {ℓ} {A} x y = ∀ (P : A → Set ℓ) → P x → P y\n\n{-\nBefore the signature used Set₁ as the type of a term that includes Set,\nwhereas here the signature uses Set (lsuc ℓ) as the type of a term that includes Set ℓ.\n\nMost other functions in the standard library are also generalised to arbitrary levels.\n-}\n\n-- definition of composition.\n_∘_ : ∀ {ℓ₁ ℓ₂ ℓ₃ : Level} {A : Set ℓ₁} {B : Set ℓ₂} {C : Set ℓ₃}\n → (B → C) → (A → B) → A → C\n(g ∘ f) x = g (f x)\n\n{-\n------------------------------------------------------------------------------\nStandard library\n\nstandard library defines _≡⟨_⟩_ as step-≡,\nwhich reverses the order of the arguments\n\nstandard library defines a macro,imported when import step-≡\nwhich recovers the original argument order:\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl; trans; sym; cong; cong-app; subst)\nopen Eq.≡-Reasoning using (begin_; _≡⟨⟩_; step-≡; _∎)\n\n------------------------------------------------------------------------------\nUnicode\n\n≡ U+2261 IDENTICAL TO (\\==, \\equiv)\n⟨ U+27E8 MATHEMATICAL LEFT ANGLE BRACKET (\\<)\n⟩ U+27E9 MATHEMATICAL RIGHT ANGLE BRACKET (\\>)\n∎ U+220E END OF PROOF (\\qed)\n≐ U+2250 APPROACHES THE LIMIT (\\.=)\nℓ U+2113 SCRIPT SMALL L (\\ell)\n⊔ U+2294 SQUARE CUP (\\lub)\n₀ U+2080 SUBSCRIPT ZERO (\\_0)\n₁ U+2081 SUBSCRIPT ONE (\\_1)\n₂ U+2082 SUBSCRIPT TWO (\\_2)\n-}\n", "meta": {"hexsha": "9578edfd598bf78818bab8922dfcb6fe2488fa12", "size": 16140, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x04equality.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x04equality.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x04equality.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 24.7926267281, "max_line_length": 96, "alphanum_fraction": 0.4861833953, "num_tokens": 5461, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.901920681802153, "lm_q2_score": 0.8670357598021707, "lm_q1q2_score": 0.7819974836276216}} {"text": "{-# OPTIONS --safe #-}\n\nmodule Invert where\n\nopen import Relation.Binary.PropositionalEquality\nopen import Data.Nat\n\nopen import Data.Nat.Properties\n\n_∘_ : ∀ {A B C : Set} → (B → C) → (A → B) → (A → C)\n(g ∘ f) x = g (f x)\n\npred₂ : ℕ → ℕ\npred₂ = pred ∘ pred\n\nlemma : (a b : ℕ) → pred₂ (suc a + suc a) ≡ pred₂ (suc b + suc b)\n → a + a ≡ b + b\nlemma a b p =\n begin\n a + a ≡⟨⟩\n pred₂ (suc (suc (a + a))) ≡⟨⟩\n pred₂ (suc (suc a + a)) ≡⟨ cong (pred₂ ∘ suc) (+-comm (suc a) a) ⟩\n pred₂ (suc (a + suc a)) ≡⟨⟩\n pred₂ (suc a + suc a) ≡⟨ p ⟩\n pred₂ (suc b + suc b) ≡⟨⟩\n pred₂ (suc (b + suc b)) ≡⟨ cong (pred₂ ∘ suc) (+-comm b (suc b)) ⟩\n pred₂ (suc (suc b + b)) ≡⟨⟩\n b + b\n ∎ where open ≡-Reasoning\n\ninvert : (a b : ℕ) → a + a ≡ b + b → a ≡ b\ninvert zero zero p = refl\ninvert (suc m) (suc n) p = cong suc (invert m n (lemma m n (cong pred₂ p)))\n", "meta": {"hexsha": "74049821bde48b8b288184acf2e4c6ca9ee734b2", "size": 853, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Invert.agda", "max_stars_repo_name": "anqurvanillapy/fpl", "max_stars_repo_head_hexsha": "9576d5b76e6a868992dbe52930712ac67697bed2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-08-24T22:47:47.000Z", "max_stars_repo_stars_event_max_datetime": "2019-08-24T22:47:47.000Z", "max_issues_repo_path": "agda/Invert.agda", "max_issues_repo_name": "anqurvanillapy/fpl", "max_issues_repo_head_hexsha": "9576d5b76e6a868992dbe52930712ac67697bed2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/Invert.agda", "max_forks_repo_name": "anqurvanillapy/fpl", "max_forks_repo_head_hexsha": "9576d5b76e6a868992dbe52930712ac67697bed2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.0882352941, "max_line_length": 75, "alphanum_fraction": 0.5216881594, "num_tokens": 394, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9381240194661945, "lm_q2_score": 0.8333245994514084, "lm_q1q2_score": 0.7817618227574118}} {"text": "module Bin-laws where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; sym; cong)\nopen Eq.≡-Reasoning using (begin_; _≡⟨⟩_; step-≡; _∎)\nopen import Data.Nat using (ℕ; zero; suc; _+_; _*_)\n\nopen import Induction′ using (+-suc; +-identityʳ; +-comm; +-assoc)\n\n-- 2進数の表現\ndata Bin : Set where\n ⟨⟩ : Bin\n _O : Bin → Bin\n _I : Bin → Bin\n\n-- 2進数のインクリメント\ninc : Bin → Bin\ninc ⟨⟩ = ⟨⟩ I\ninc (b O) = b I\ninc (b I) = inc b O\n\n-- 自然数から2進数への変換\nto : ℕ → Bin\nto zero = ⟨⟩ O\nto (suc n) = inc (to n)\n\n-- 2進数から自然数への変換\nfrom : Bin → ℕ\nfrom ⟨⟩ = zero\nfrom (b O) = 2 * (from b)\nfrom (b I) = 2 * (from b) + 1\n\n2*n≡n+n : ∀ (n : ℕ) → 2 * n ≡ n + n\n2*n≡n+n n =\n begin\n 2 * n\n ≡⟨⟩\n n + (1 * n)\n ≡⟨⟩\n n + (n + (0 * n))\n ≡⟨⟩\n n + (n + 0)\n ≡⟨ cong (n +_) (+-identityʳ n) ⟩\n n + n\n ∎\n\n+-suc-suc : ∀ (m n : ℕ) → (suc m) + (suc n) ≡ suc (suc (m + n))\n+-suc-suc m n =\n begin\n (suc m) + (suc n)\n ≡⟨ +-suc (suc m) n ⟩\n suc ((suc m) + n)\n ≡⟨ cong suc (sym (+-assoc 1 m n)) ⟩\n suc (suc (m + n))\n ∎\n\n-- 変換の前後どちらでインクリメントしても結果は等しい\nfrom∘inc≡suc∘from : ∀ (b : Bin) → from (inc b) ≡ suc (from b)\nfrom∘inc≡suc∘from ⟨⟩ =\n begin\n from (inc ⟨⟩)\n ≡⟨⟩\n from (⟨⟩ I)\n ≡⟨⟩\n suc zero\n ≡⟨⟩\n suc (from ⟨⟩)\n ∎\nfrom∘inc≡suc∘from (b O) =\n begin\n from (inc (b O))\n ≡⟨⟩\n from (b I)\n ≡⟨⟩\n 2 * (from b) + 1\n ≡⟨⟩\n from (b O) + 1\n ≡⟨ +-suc (from (b O)) zero ⟩\n suc (from (b O) + zero)\n ≡⟨ cong suc (+-identityʳ (from (b O))) ⟩\n suc (from (b O))\n ∎\nfrom∘inc≡suc∘from (b I) =\n begin\n from (inc (b I))\n ≡⟨⟩\n from ((inc b) O)\n ≡⟨⟩\n 2 * (from (inc b))\n ≡⟨ cong (2 *_) (from∘inc≡suc∘from b) ⟩\n 2 * (suc (from b))\n ≡⟨ 2*n≡n+n (suc (from b)) ⟩\n (suc (from b)) + (suc (from b))\n ≡⟨ +-suc-suc (from b) (from b) ⟩\n suc (suc ((from b) + (from b)))\n ≡⟨ cong (λ 2*fromb → suc (suc 2*fromb)) (sym (2*n≡n+n (from b))) ⟩\n suc (suc (2 * (from b)))\n ≡⟨ cong suc (+-comm 1 (2 * (from b))) ⟩\n suc (2 * (from b) + 1)\n ≡⟨⟩\n suc (from (b I))\n ∎\n\n-- to∘from : ∀ (b : Bin) → to (from b) ≡ b\n-- to∘from ⟨⟩ = {!!} -- (to zero) が (⟨⟩ O) にエンコードされるため成り立たない\n-- to∘from (b O) = {!!}\n-- to∘from (b I) = {!!}\n\nfrom∘to : ∀ (n : ℕ) → from (to n) ≡ n\nfrom∘to zero =\n begin\n from (to zero)\n ≡⟨⟩\n from (⟨⟩ O)\n ≡⟨⟩\n 2 * (from ⟨⟩)\n ≡⟨⟩\n 2 * zero\n ≡⟨⟩\n zero\n ∎\nfrom∘to (suc n) =\n begin\n from (to (suc n))\n ≡⟨⟩\n from (inc (to n))\n ≡⟨ from∘inc≡suc∘from (to n) ⟩\n suc (from (to n))\n ≡⟨ cong suc (from∘to n) ⟩\n suc n\n ∎\n", "meta": {"hexsha": "8dff0bd2bbde90268be9abcd037d73fe04a1dd20", "size": 2492, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "part1/induction/Bin-laws.agda", "max_stars_repo_name": "akiomik/plfa-solutions", "max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z", "max_issues_repo_path": "part1/induction/Bin-laws.agda", "max_issues_repo_name": "akiomik/plfa-solutions", "max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "part1/induction/Bin-laws.agda", "max_forks_repo_name": "akiomik/plfa-solutions", "max_forks_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.8787878788, "max_line_length": 68, "alphanum_fraction": 0.4582664526, "num_tokens": 1337, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9263037302939515, "lm_q2_score": 0.8438951045175643, "lm_q1q2_score": 0.781703183291424}} {"text": "\nmodule Data.Permutation where\n\nopen import Prelude\nopen import Data.Fin as Fin hiding (_==_; _<_)\nopen import Data.Nat\nopen import Data.Vec\nopen import Logic.Identity\nopen import Logic.Base\nimport Logic.ChainReasoning\n\n-- What is a permutation?\n-- Answer 1: A bijection between Fin n and itself\n\ndata Permutation (n : Nat) : Set where\n permutation :\n (π π⁻¹ : Fin n -> Fin n) ->\n (forall {i} -> π (π⁻¹ i) ≡ i) ->\n Permutation n\n\nmodule Permutation {n : Nat}(P : Permutation n) where\n\n private\n π' : Permutation n -> Fin n -> Fin n\n π' (permutation x _ _) = x\n\n π⁻¹' : Permutation n -> Fin n -> Fin n\n π⁻¹' (permutation _ x _) = x\n\n proof : (P : Permutation n) -> forall {i} -> π' P (π⁻¹' P i) ≡ i\n proof (permutation _ _ x) = x\n\n π : Fin n -> Fin n\n π\t = π' P\n\n π⁻¹ : Fin n -> Fin n\n π⁻¹\t = π⁻¹' P\n\n module Proofs where\n\n ππ⁻¹-id : {i : Fin n} -> π (π⁻¹ i) ≡ i\n ππ⁻¹-id = proof P\n\n open module Chain = Logic.ChainReasoning.Poly.Homogenous _≡_ (\\x -> refl) (\\x y z -> trans)\n\n π⁻¹-inj : (i j : Fin n) -> π⁻¹ i ≡ π⁻¹ j -> i ≡ j\n π⁻¹-inj i j h =\n chain> i\n\t === π (π⁻¹ i)\tby sym ππ⁻¹-id\n\t === π (π⁻¹ j)\tby cong π h\n\t === j\t\tby ππ⁻¹-id\n\n -- Generalise\n lem : {n : Nat}(f g : Fin n -> Fin n)\n\t -> (forall i -> f (g i) ≡ i)\n\t -> (forall i -> g (f i) ≡ i)\n lem {zero} f g inv ()\n lem {suc n} f g inv i = ?\n where\n\tgz≠gs : {i : Fin n} -> g fzero ≢ g (fsuc i)\n\tgz≠gs {i} gz=gs = fzero≠fsuc $\n\t chain> fzero\n\t === f (g fzero)\t by sym (inv fzero)\n\t === f (g (fsuc i)) by cong f gz=gs\n\t === fsuc i\t\t by inv (fsuc i)\n\n\tz≠f-thin-gz : {i : Fin n} -> fzero ≢ f (thin (g fzero) i)\n\tz≠f-thin-gz {i} z=f-thin-gz = ?\n-- \t f (g fzero)\n-- \t = fzero\n-- \t = f (thin (g fzero) i)\n\n\tg' : Fin n -> Fin n\n\tg' j = thick (g fzero) (g (fsuc j)) gz≠gs\n\n\tf' : Fin n -> Fin n\n\tf' j = thick fzero (f (thin (g fzero) j)) ?\n\n\tg'f' : forall j -> g' (f' j) ≡ j\n\tg'f' = lem {n} f' g' ?\n\n π⁻¹π-id : forall {i} -> π⁻¹ (π i) ≡ i\n π⁻¹π-id = ?\n\n-- Answer 2: A Vec (Fin n) n with no duplicates\n\n{-\ninfixr 40 _◅_ _↦_,_\ninfixr 20 _○_\n\ndata Permutation : Nat -> Set where\n ε : Permutation zero\n _◅_ : {n : Nat} -> Fin (suc n) -> Permutation n -> Permutation (suc n)\n\n_↦_,_ : {n : Nat}(i j : Fin (suc n)) -> Permutation n -> Permutation (suc n)\nfzero ↦ j , π\t = j ◅ π\nfsuc i ↦ j , j' ◅ π = thin j j' ◅ i ↦ ? , π\n\nindices : {n : Nat} -> Permutation n -> Vec (Fin n) n\nindices ε\t= []\nindices (i ◅ π) = i :: map (thin i) (indices π)\n\n-- permute (i ◅ π) xs with xs [!] i where\n-- permute₁ (i ◅ π) .(insert i x xs) (ixV x xs) = x :: permute π xs\n\npermute : {n : Nat}{A : Set} -> Permutation n -> Vec A n -> Vec A n\npermute (i ◅ π) xs = permute' π i xs (xs [!] i)\n where\n permute' : {n : Nat}{A : Set} -> Permutation n -> (i : Fin (suc n))(xs : Vec A (suc n)) ->\n\t IndexView i xs -> Vec A (suc n)\n permute' π i .(insert i x xs') (ixV x xs') = x :: permute π xs'\n\ndelete : {n : Nat} -> Fin (suc n) -> Permutation (suc n) -> Permutation n\ndelete\t\tfzero (j ◅ π) = π\ndelete {zero} (fsuc ()) _\ndelete {suc _} (fsuc i) (j ◅ π) = ? ◅ delete i π\n\nidentity : {n : Nat} -> Permutation n\nidentity {zero } = ε\nidentity {suc n} = fzero ◅ identity\n\n_⁻¹ : {n : Nat} -> Permutation n -> Permutation n\nε\t⁻¹ = ε\n(i ◅ π) ⁻¹ = ?\n\n_○_ : {n : Nat} -> Permutation n -> Permutation n -> Permutation n\nε ○ π₂ = ε\ni ◅ π₁ ○ π₂ = (indices π₂ ! i) ◅ (π₁ ○ delete i π₂)\n-}\n\n", "meta": {"hexsha": "9db4549f15adf1152a36f5d04d6bba22e04d7264", "size": 3424, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Permutation.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Permutation.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Permutation.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 26.1374045802, "max_line_length": 95, "alphanum_fraction": 0.5268691589, "num_tokens": 1435, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9173026618464795, "lm_q2_score": 0.8519528038477824, "lm_q1q2_score": 0.7814985747371423}} {"text": "module List.Permutation.Pair.Properties (A : Set) where\n\nopen import List.Permutation.Base A\nopen import List.Permutation.Base.Concatenation A\nopen import List.Permutation.Base.Equivalence A\nopen import List.Permutation.Base.Preorder A\nopen import List.Permutation.Pair A\nopen import Data.List\nopen import Data.Product\nopen import Relation.Binary.PreorderReasoning ∼-preorder\nopen import Algebra\nopen import Algebra.Structures\n\nlemma≈∼ : {xs ys zs : List A} → xs ≈ (ys , zs) → xs ∼ (ys ++ zs)\nlemma≈∼ (≈[]l zs) = refl∼ \nlemma≈∼ (≈[]r ys) rewrite ((proj₂ (IsMonoid.identity (Monoid.isMonoid (monoid A)))) ys) = refl∼\nlemma≈∼ (≈xr {ys = ys} xs∼ys,zs') = ∼x /head (lemma++/l {xs = ys} /head) (lemma≈∼ xs∼ys,zs')\nlemma≈∼ (≈xl xs∼ys',zs) = ∼x /head /head (lemma≈∼ xs∼ys',zs)\n\nlemma≈ : {xs ys zs ws ys' zs' : List A} → xs ≈ (ys , zs) → ys ∼ ys' → zs ∼ zs' → ws ≈ (ys' , zs') → xs ∼ ws\nlemma≈ {xs} {ys} {zs} {ws} {ys'} {zs'} xs∼ys,zs ys∼ys' zs∼zs' ws∼ys',zs' \n = begin\n xs\n ∼⟨ lemma≈∼ xs∼ys,zs ⟩\n ys ++ zs\n ∼⟨ lemma++∼ ys∼ys' zs∼zs' ⟩\n ys' ++ zs'\n ∼⟨ sym∼ (lemma≈∼ ws∼ys',zs') ⟩\n ws\n ∎\n", "meta": {"hexsha": "c40129b35cfef720c353ca69f92f5deb8c02a0ec", "size": 1138, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/List/Permutation/Pair/Properties.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/List/Permutation/Pair/Properties.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/List/Permutation/Pair/Properties.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.7096774194, "max_line_length": 107, "alphanum_fraction": 0.5966608084, "num_tokens": 474, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9473810451666346, "lm_q2_score": 0.824461932846258, "lm_q1q2_score": 0.7810796076399916}} {"text": "module _^_ where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_)\nopen Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _∎)\n\nopen import Naturals using (ℕ; zero; suc; _*_)\n\n_^_ : ℕ → ℕ → ℕ\n_ ^ zero = 1\nm ^ (suc n) = m * (m ^ n)\n\n_ : 3 ^ 4 ≡ 81\n_ =\n begin\n 3 ^ 4\n ≡⟨⟩\n 3 * (3 ^ 3)\n ≡⟨⟩\n 3 * (3 * (3 ^ 2))\n ≡⟨⟩\n 3 * (3 * (3 * (3 ^ 1)))\n ≡⟨⟩\n 3 * (3 * (3 * (3 * (3 ^ 0))))\n ≡⟨⟩\n 3 * (3 * (3 * (3 * 1)))\n ≡⟨⟩\n 81\n ∎\n", "meta": {"hexsha": "8a3749acc9e4e37289716e07a136b72a7bb365af", "size": 455, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "part1/naturals/_^_.agda", "max_stars_repo_name": "akiomik/plfa-solutions", "max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z", "max_issues_repo_path": "part1/naturals/_^_.agda", "max_issues_repo_name": "akiomik/plfa-solutions", "max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "part1/naturals/_^_.agda", "max_forks_repo_name": "akiomik/plfa-solutions", "max_forks_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 15.1666666667, "max_line_length": 50, "alphanum_fraction": 0.4175824176, "num_tokens": 242, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9473810421953309, "lm_q2_score": 0.8244619350028204, "lm_q1q2_score": 0.7810796072333511}} {"text": "module Data.List.Combinatorics where\n\nimport Lvl\nopen import Data\nopen import Data.List\nopen import Data.List.Functions\nopen Data.List.Functions.LongOper\nopen import Data.Tuple as Tuple using (_⨯_ ; _,_)\nopen import Data.Tuple.Raiseᵣ as Tuple₊ using (_^_)\nimport Data.Tuple.Raiseᵣ.Functions as Tuple₊\nopen import Functional\nopen import Numeral.Natural\nopen import Type\n\nprivate variable ℓ : Lvl.Level\nprivate variable T : Type{ℓ}\n\n-- A list of all non-empty sublists of the specified list.\n-- The corresponding counting function is `(2 ^ n) − 1` where `n` is the length of the list.\n-- Note:\n-- In the inductive case, all of these are permutations of each other:\n-- • `foldᵣ (prev ↦ rest ↦ (prev ⊰ (x ⊰ prev) ⊰ rest)) ∅ (sublists₊ l)` (This is used because of its \"natural\" order)\n-- • `foldᵣ (prev ↦ rest ↦ ((x ⊰ prev) ⊰ prev ⊰ rest)) ∅ (sublists₊ l)`\n-- • `(map (x ⊰_) (sublists₊ l)) ++ (sublists₊ l)`\n-- • `(sublists₊ l) ++ (map (x ⊰_) (sublists₊ l))`\n-- Examples:\n-- sublists₊ [] = []\n-- sublists₊ [1] = [[1]]\n-- sublists₊ [1,2] = [[1],[2],[1,2]]\n-- sublists₊ [1,2,3] = [[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]]\n-- sublists₊ [1,2,3,4] = [[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3],[4],[1,4],[2,4],[1,2,4],[3,4],[1,3,4],[2,3,4],[1,2,3,4]]\nsublists₊ : List(T) → List(List(T))\nsublists₊ ∅ = ∅\nsublists₊ (x ⊰ l) = singleton(x) ⊰ concatMap(y ↦ (y ⊰ (x ⊰ y) ⊰ ∅)) (sublists₊ l)\n\n-- A list of all sublists of the specified list.\n-- This is also the list of all subsets when the given list is a set (distinct elements).\n-- The corresponding counting function is `2 ^ n` where `n` is the length of the list.\n-- Examples:\n-- sublists [] = [[]]\n-- sublists [1] = [[],[1]]\n-- sublists [1,2] = [[],[1],[2],[1,2]]\n-- sublists [1,2,3] = [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]]\n-- sublists [1,2,3,4] = [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3],[4],[1,4],[2,4],[1,2,4],[3,4],[1,3,4],[2,3,4],[1,2,3,4]]\nsublists : List(T) → List(List(T))\nsublists(l) = ∅ ⊰ sublists₊(l)\n\n-- A list of all combinations of the specified size of the specified list.\n-- The corresponding counting function is `𝑐𝐶(n,k)` where `n` is the length of the specified \"multiset\".\n-- All subsets of size `n` from the set `l`.\n-- Every unique subset of size n up to set equality.\n-- This is also a list of all sublists of the specified size of the specified list.\n-- Alternative definition that does not pass the termination checker:\n-- combinations : ℕ → List(T) → List(List(T))\n-- combinations 0 _ = ∅\n-- combinations _ ∅ = ∅\n-- combinations 1 l = map singleton l\n-- combinations (𝐒(𝐒(n))) l = concat(map f(tails l)) where\n-- f : List(T) → List(List(T))\n-- f ∅ = ∅\n-- f(x ⊰ l) = map (x ⊰_) (combinations (𝐒(n)) l)\n-- Examples:\n-- combinations _ [] = []\n-- combinations 0 [a,b,c,...] = [[]] when the list is non-empty\n-- combinations 1 [a,b,c,...] = [[a],[b],[c],...] when the list is non-empty\n-- combinations n l = [] when (n ≥ length(l))\n-- combinations n l = [l] when (n = length(l))\n-- combinations 2 [a,b,c] = [[a,b],[a,c],[b,c]]\n-- combinations 2 [a,b,c,d] = [[a,b],[a,c],[a,d],[b,c],[b,d],[c,d]]\n-- combinations 2 [a,b,c,d,e] = [[a,b],[a,c],[a,d],[a,e],[b,c],[b,d],[b,e],[c,d],[c,e],[d,e]]\n-- combinations 3 [a,b,c,d] = [[a,b,c],[a,b,d],[a,c,d],[b,c,d]]\n-- combinations 3 [a,b,c,d,e] = [[a,b,c],[a,b,d],[a,b,e],[a,c,d],[a,c,e],[a,d,e],[b,c,d],[b,c,e],[b,d,e],[c,d,e]]\n-- combinations 4 [a,b,c,d,e] = [[a,b,c,d],[a,b,c,e],[a,b,d,e],[a,c,d,e],[b,c,d,e]]\ncombinations : (k : ℕ) → List(T) → List(T ^ k)\ncombinations 0 _ = singleton(<>)\ncombinations (𝐒(_)) ∅ = ∅\ncombinations 1 l@(_ ⊰ _) = l\ncombinations (𝐒(𝐒(k))) (x ⊰ l) = (map(x ,_) (combinations (𝐒(k)) l)) ++ (combinations(𝐒(𝐒(k))) l)\n\n-- The corresponding counting function is `𝑐𝐶(n + k − 1 , k)` where `n` is the length of the specified \"multiset\".\n-- Examples:\n-- repeatableCombinations _ [] = []\n-- repeatableCombinations 0 [a,b,c,...] = [[]] when the list is non-empty\n-- repeatableCombinations 1 [a,b,c,...] = [[a],[b],[c],...] when the list is non-empty\n-- repeatableCombinations n [a] = [repeat n a]\n-- repeatableCombinations 2 [a,b] = [[a,a],[a,b],[b,b]]\n-- repeatableCombinations 2 [a,b,c] = [[a,a],[a,b],[a,c],[b,b],[b,c],[c,c]]\n-- repeatableCombinations 3 [a,b] = [[a,a,a],[a,a,b],[a,b,b],[b,b,b]]\n-- repeatableCombinations 3 [a,b,c] = [[a,a,a],[a,a,b],[a,a,c],[a,b,b],[a,b,c],[a,c,c],[b,b,b],[b,b,c],[b,c,c],[c,c,c]]\n-- repeatableCombinations 4 [a,b] = [[a,a,a,a],[a,a,a,b],[a,a,b,b],[a,b,b,b],[b,b,b,b]]\n-- repeatableCombinations 4 [a,b,c] = [[a,a,a,a],[a,a,a,b],[a,a,a,c],[a,a,b,b],[a,a,b,c],[a,a,c,c],[a,b,b,b],[a,b,b,c],[a,b,c,c],[a,c,c,c],[b,b,b,b],[b,b,b,c],[b,b,c,c],[b,c,c,c],[c,c,c,c]]\nrepeatableCombinations : (k : ℕ) → List(T) → List(T ^ k)\nrepeatableCombinations 0 _ = singleton(<>)\nrepeatableCombinations (𝐒(_)) ∅ = ∅\nrepeatableCombinations 1 l@(_ ⊰ _) = l\nrepeatableCombinations (𝐒(𝐒(k))) (x ⊰ l) = (map (x ,_) (repeatableCombinations (𝐒(k)) (x ⊰ l))) ++ (repeatableCombinations (𝐒(𝐒(k))) l)\n\n-- A list of all tuples of length `n` from the \"multiset\" `l`.\n-- Every tuple combination of length `n`.\n-- The corresponding counting function is `k ^ n` where `k` is the length of the list.\n-- Examples:\n-- tuples 0 [a] = [()]\n-- tuples 1 [a] = [a]\n-- tuples 2 [a] = [(a,a)]\n-- tuples 0 [a,b] = [()]\n-- tuples 1 [a,b] = [a,b]\n-- tuples 2 [a,b] = [(a,a) , (a,b) , (b,a) , (b,b)]\n-- tuples 0 [a,b,c] = [()]\n-- tuples 1 [a,b,c] = [a,b,c]\n-- tuples 2 [a,b,c] = [(a,a) , (a,b) , (a,c) , (b,a) , (b,b) , (b,c) , (c,a) , (c,b), (c,c)]\ntuples : (n : ℕ) → List(T) → List(T ^ n)\ntuples 0 = const(singleton(<>))\ntuples 1 = id\ntuples (𝐒(𝐒(n))) l = concatMap(x ↦ map (Tuple₊.prepend x) (tuples (𝐒(n)) l)) l\n\n-- A list of all rotations of a list.\n-- Examples:\n-- rotations [] = []\n-- rotations [a] = [[a]]\n-- rotations [a,b] = [[a,b] , [b,a]]\n-- rotations [a,b,c] = [[a,b,c] , [b,c,a] , [c,a,b]]\n-- rotations [a,b,c,d] = [[a,b,c,d] , [b,c,d,a] , [c,d,a,b] , [d,a,b,c]]\nrotations : List(T) → List(List(T))\nrotations l = accumulateIterate₀(length l) (rotateₗ(1)) l\n\n-- Accumulated `insertAt` for every position of the given list.\n-- Examples:\n-- insertedEverywhere i [] = [[i]]\n-- insertedEverywhere i [a] = [[i,a],[a,i]]\n-- insertedEverywhere i [a,b] = [[i,a,b],[a,i,b],[a,b,i]]\n-- insertedEverywhere i [a,b,c] = [[i,a,b,c],[a,i,b,c],[a,b,i,c],[a,b,c,i]]\n-- insertedEverywhere i [a,b,c,d] = [[i,a,b,c,d],[a,i,b,c,d],[a,b,i,c,d],[a,b,c,i,d],[a,b,c,d,i]\ninsertedEverywhere : T → List(T) → List(List(T))\ninsertedEverywhere i ∅ = singleton(singleton i)\ninsertedEverywhere i (x ⊰ l) = (i ⊰ x ⊰ l) ⊰ (map (prepend x) (insertedEverywhere i l))\n\n-- Every reordering of the list's elements.\n-- Examples:\n-- permutations [] = [[]]\n-- permutations [a] = [[a]]\n-- permutations [a,b] = [[a,b],[b,a]]\n-- permutations [a,b,c] = [[a,b,c],[b,a,c],[b,c,a],[a,c,b],[c,a,b],[c,b,a]]\n-- permutations [a,b,c,d] = [[a,b,c,d],[b,a,c,d],[b,c,a,d],[b,c,d,a],[a,c,b,d],[c,a,b,d],[c,b,a,d],[c,b,d,a],[a,c,d,b],[c,a,d,b],[c,d,a,b],[c,d,b,a],[a,b,d,c],[b,a,d,c],[b,d,a,c],[b,d,c,a],[a,d,b,c],[d,a,b,c],[d,b,a,c],[d,b,c,a],[a,d,c,b],[d,a,c,b],[d,c,a,b],[d,c,b,a]]\npermutations : List(T) → List(List(T))\npermutations ∅ = singleton(∅)\npermutations (x ⊰ ∅) = singleton(singleton x)\npermutations (x ⊰ l@(_ ⊰ _)) = concatMap (insertedEverywhere x) (permutations l)\n", "meta": {"hexsha": "9477d58d0657829d43fb0218570075f54eb2b980", "size": 7784, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/List/Combinatorics.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Data/List/Combinatorics.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/List/Combinatorics.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 52.5945945946, "max_line_length": 271, "alphanum_fraction": 0.526336074, "num_tokens": 2930, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9046505325302034, "lm_q2_score": 0.8633916152464016, "lm_q1q2_score": 0.7810676845147697}} {"text": "module Nat1 where\n\ndata ℕ : Set where\n zero : ℕ\n succ : ℕ → ℕ\n\n_+_ : ℕ → ℕ → ℕ\nzero + b = b\nsucc a + b = succ (a + b)\n\nopen import Equality\none = succ zero\ntwo = succ one\nthree = succ two\n\n0-is-id : ∀ (n : ℕ) → (n + zero) ≡ n\n0-is-id zero =\n begin\n (zero + zero) ≈ zero by definition\n ∎\n0-is-id (succ y) =\n begin\n (succ y + zero) ≈ succ (y + zero) by definition\n ≈ succ y by cong succ (0-is-id y)\n ∎\n\n+-assoc : ∀ (a b c : ℕ) → (a + b) + c ≡ a + (b + c)\n+-assoc zero b c = definition\n+-assoc (succ a) b c =\n begin ((succ a + b) + c)\n ≈ succ (a + b) + c by definition\n ≈ succ ((a + b) + c) by definition\n ≈ succ (a + (b + c)) by cong succ (+-assoc a b c)\n ≈ succ a + (b + c) by definition\n ∎\n{-\n+-assoc zero b c = definition\n+-assoc (succ a) b c =\n begin ((succ a + b) + c)\n ≈ succ (a + b) + c by definition\n ≈ succ ((a + b) + c) by definition\n ≈ succ (a + (b + c)) by cong succ (+-assoc a b c)\n ≈ succ a + (b + c) by definition\n ∎\n-}\n", "meta": {"hexsha": "dd661c3134861008f0887630e9bc130d379b1f8f", "size": 1123, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Nat1.agda", "max_stars_repo_name": "piyush-kurur/sample-code", "max_stars_repo_head_hexsha": "1062c0b81f8dbb664fcc9376ba13695f0ee7ebc8", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2017-06-19T12:34:08.000Z", "max_stars_repo_stars_event_max_datetime": "2017-06-20T02:19:33.000Z", "max_issues_repo_path": "agda/Nat1.agda", "max_issues_repo_name": "piyush-kurur/sample-code", "max_issues_repo_head_hexsha": "1062c0b81f8dbb664fcc9376ba13695f0ee7ebc8", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2017-11-01T05:48:28.000Z", "max_issues_repo_issues_event_max_datetime": "2017-11-01T05:48:28.000Z", "max_forks_repo_path": "agda/Nat1.agda", "max_forks_repo_name": "piyush-kurur/sample-code", "max_forks_repo_head_hexsha": "1062c0b81f8dbb664fcc9376ba13695f0ee7ebc8", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.4130434783, "max_line_length": 65, "alphanum_fraction": 0.4443455031, "num_tokens": 400, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.966410494349896, "lm_q2_score": 0.8080672158638527, "lm_q1q2_score": 0.78092463755093}} {"text": "open import Data.Nat using (_+_; _*_; zero; suc; ℕ)\nopen import Relation.Binary.PropositionalEquality as PropEq\n using (_≡_; _≢_; refl; cong)\nimport Data.Nat.Properties\nopen Data.Nat.Properties.SemiringSolver\n using (solve; _:=_; con; var; _:+_; _:*_; :-_; _:-_)\nopen PropEq.≡-Reasoning\n\nlem1 : (4 + 6 ≡ 10)\nlem1 = refl\n\nlem3 : (x : ℕ) → (2 * (x + 4) ≡ 8 + 2 * x)\nlem3 = solve 1 (λ x' → con 2 :* (x' :+ con 4) := con 8 :+ con 2 :* x') refl\n\nsum : ℕ → ℕ\nsum zero = 0\nsum (suc n) = 1 + 2 * n + sum n\n\ntheorem : (n : ℕ) → (sum n ≡ n * n)\ntheorem 0 = refl\ntheorem (suc p) =\n begin\n sum (suc p)\n ≡⟨ refl ⟩\n 1 + 2 * p + sum p\n ≡⟨ cong (λ x → 1 + 2 * p + x) (theorem p)⟩\n 1 + 2 * p + p * p\n ≡⟨ solve 1 (λ p → con 1 :+ con 2 :* p :+ p :* p := (con 1 :+ p) :* (con 1 :+ p)) refl p ⟩\n (1 + p) * (1 + p)\n ≡⟨ refl ⟩\n (suc p) * (suc p)\n ∎\n", "meta": {"hexsha": "e85dd84ef58f8150694b82e8d876356adf84a123", "size": 859, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "tests/comparison/sumodd.agda", "max_stars_repo_name": "jota191/pml", "max_stars_repo_head_hexsha": "9319c5c1e7d6eec0dc22bc8ae690dc362e9113b9", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 15, "max_stars_repo_stars_event_min_datetime": "2017-12-22T12:10:16.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-17T18:31:08.000Z", "max_issues_repo_path": "tests/comparison/sumodd.agda", "max_issues_repo_name": "jota191/pml", "max_issues_repo_head_hexsha": "9319c5c1e7d6eec0dc22bc8ae690dc362e9113b9", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 36, "max_issues_repo_issues_event_min_datetime": "2017-11-01T16:27:45.000Z", "max_issues_repo_issues_event_max_datetime": "2020-02-08T09:43:31.000Z", "max_forks_repo_path": "tests/comparison/sumodd.agda", "max_forks_repo_name": "jota191/pml", "max_forks_repo_head_hexsha": "9319c5c1e7d6eec0dc22bc8ae690dc362e9113b9", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-07-18T22:03:24.000Z", "max_forks_repo_forks_event_max_datetime": "2019-07-18T22:03:24.000Z", "avg_line_length": 26.0303030303, "max_line_length": 91, "alphanum_fraction": 0.4994179278, "num_tokens": 402, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.960361162033533, "lm_q2_score": 0.8128673155708975, "lm_q1q2_score": 0.7806461997607457}} {"text": "module Type.Properties.MereProposition {ℓ ℓₑ} where\n\nimport Lvl\nopen import Lang.Instance\nopen import Structure.Setoid\nopen import Type\n\n-- A type is a mere proposition type when there is at most one inhabitant (there is at most one object with this type).\n-- In other words: If there is an inhabitant of type T, it is unique (essentially only allowing empty or singleton types, but this is not provable (excluded middöe)).\n-- Also called:\n-- • \"Irrelevance\" / \"Irrelevancy\" / \"Proof irrelevance\" (in the context of proofs).\n-- A proof of the proposition T is unique (using equality to determine uniqueness).\n-- • \"isProp\" / \"h-proposition\" / \"is of h-level 1\" / \"a mere proposition\" (in homotopy type theory).\n-- Classically, when MereProposition(T), T is either empty or a singleton (which in the context of proofs corresponds to types isomorphic to ⊥ or ⊤).\n-- • \"subsingleton\" (in set theory)\n-- When a type and its inhabitants is interpreted as a set and its elements.\n-- • \"subterminal object\" (in category theory).\nmodule _ (T : Type{ℓ}) ⦃ _ : Equiv{ℓₑ}(T) ⦄ where\n record MereProposition : Type{ℓ Lvl.⊔ ℓₑ} where\n constructor intro\n field uniqueness : ∀{x y : T} → (x ≡ y)\n uniqueness = inst-fn MereProposition.uniqueness\n\n-- TODO: Consider using unicode ◐○●⧭⦵⦳\n", "meta": {"hexsha": "ffd712aea25936fa3c7eaa10c865d1bd38485b52", "size": 1289, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Type/Properties/MereProposition.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Type/Properties/MereProposition.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Type/Properties/MereProposition.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 51.56, "max_line_length": 166, "alphanum_fraction": 0.7160589604, "num_tokens": 377, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9518632288833652, "lm_q2_score": 0.8198933359135361, "lm_q1q2_score": 0.780426318062612}} {"text": "module x00-playpen where\n\n-- prove properties of inductive naturals and operations on them via induction\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl; cong; sym)\nopen Eq.≡-Reasoning using (begin_; _≡⟨⟩_; step-≡; _∎)\nopen import Data.Nat using (ℕ; zero; suc; _+_; _*_; _∸_; _^_)\n\n*-assoc : ∀ (m n p : ℕ)\n → (m * n) * p\n ≡ m * (n * p)\n*-assoc m n p = {!!}\n\n+-xx : ∀ (n : ℕ)\n → (n ^ 3) ∸ ((n * n) * n)\n ≡ zero\n+-xx zero = refl\n+-xx (suc n) = {!!}\n{-\n begin\n (n * (n ^ 2)) ∸ ((n * n) * n)\n ≡⟨⟩\n (n * (n * (n ^ 1))) ∸ ((n * n) * n)\n ≡⟨⟩\n (n * (n * (n * (n ^ 0)))) ∸ ((n * n) * n)\n ≡⟨⟩\n (n * (n * (n * 1 ))) ∸ ((n * n) * n)\n ≡⟨⟩\n (n * (n * n )) ∸ ((n * n) * n)\n ≡⟨ cong ( ((n * (n * n))) ∸_) (*-assoc n n n) ⟩\n (n * (n * n )) ∸ ( n * (n * n))\n ∎\n-}\n", "meta": {"hexsha": "995d37bbba0f82cc8955d762cd9938e0d21bd349", "size": 913, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x00-playpen.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x00-playpen.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x00-playpen.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 26.0857142857, "max_line_length": 78, "alphanum_fraction": 0.3713033954, "num_tokens": 405, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9362850039701655, "lm_q2_score": 0.8333246015211009, "lm_q1q2_score": 0.7802293278436205}} {"text": "{-# OPTIONS --without-K #-}\n\nmodule hott.core.univalence where\n\nopen import hott.core.universe\nopen import hott.functions\nopen import hott.core.equality\nopen import hott.core.sigma\n\n\n-- The core idea of univalence is to \"identify\" isomorphic types as\n-- equal. Of course the normal definition of isomorphism is that there\n-- should be a map from A to B that is witnesses the equivalence of the\n-- two type. This is captured by the following record.\nrecord _≃_ {a b : Level}(A : Type a)(B : Type b) : Type (a ⊔ b) where\n\n constructor IdentifyTypesVia\n field\n equiv : (A → B) -- The equivalence\n left-inv : (B → A) -- its left inverse\n right-inv : (B → A) -- and its right inverse\n\n -- The proofs of the fact that the left and right inverses are actually\n -- left and right inverses.\n left-inv∘equiv~idA : left-inv ∘ equiv ~ id\n iso∘right-equiv~idB : equiv ∘ right-inv ~ id\n\n-- Of course a type should be equivalent to itself via identity.\nA≃A : {ℓ : Level}{A : Type ℓ} → A ≃ A\nA≃A {ℓ} {A} = IdentifyTypesVia id id id (λ _ → refl) (λ _ → refl)\n\n-- Equal types are equivalent.\n≡→≃ : {ℓ : Level}{A B : Type ℓ} → A ≡ B → A ≃ B\n≡→≃ refl = A≃A\n\n\n-- For the converse we need the univalence. However Univalence says\n-- something. Not only can we infer A ≡ B from A ≃ B via the postulate\n-- ua, this map together with ≡→≃ gives an equivalence of types.\nmodule Univalence {ℓ : Level}{A B : Type ℓ} where\n\n -- The main axiom is to identify A ≃ B with A ≡ B\n postulate ua : A ≃ B → A ≡ B\n\n -- Now we are ready for the univalence axiom.\n UnivalenceAxiom : (A ≃ B) ≃ (A ≡ B)\n UnivalenceAxiom = IdentifyTypesVia ua ≡→≃ ≡→≃ linv-prf rinv-prf\n where postulate rinv-prf : ua ∘ ≡→≃ ~ id\n postulate linv-prf : ≡→≃ ∘ ua ~ id\n\n -- The next function helps in clean use of the univalence\n -- axioms in equational reasoning.\n --\n --\n -- begin ...\n -- ≡ B by univalence\n -- ...\n --\n -- provided an appropriate instance of A ≃ B is available in the\n -- vicinity.\n --\n univalence : ⦃ a≃b : A ≃ B ⦄ → A ≡ B\n univalence ⦃ a≃b ⦄ = ua a≃b\n\nopen Univalence public\n", "meta": {"hexsha": "5ec7c02e47dc7dc040ab8ab4430fb9e4f77c4924", "size": 2115, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/hott/core/univalence.agda", "max_stars_repo_name": "piyush-kurur/hott", "max_stars_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "agda/hott/core/univalence.agda", "max_issues_repo_name": "piyush-kurur/hott", "max_issues_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/hott/core/univalence.agda", "max_forks_repo_name": "piyush-kurur/hott", "max_forks_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.0454545455, "max_line_length": 75, "alphanum_fraction": 0.6368794326, "num_tokens": 696, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9136765187126079, "lm_q2_score": 0.8539127473751341, "lm_q1q2_score": 0.7802000263060311}} {"text": "-- Solutions to ExerciseSession2\n{-# OPTIONS --cubical #-}\nmodule SolutionsSession2 where\n\nopen import Part1\nopen import Part2\nopen import ExerciseSession1\n\n-- Exercise 1\nJEq : {x : A} (P : (z : A) → x ≡ z → Type ℓ'')\n (d : P x refl) → J P d refl ≡ d\nJEq P p d = transportRefl p d\n\n\n-- Exercise 2\nisContr→isProp : isContr A → isProp A\nisContr→isProp (x , p) a b = sym (p a) ∙ p b\n\n\n-- Exercise 3\nisProp→isProp' : isProp A → isProp' A\nisProp→isProp' p x y = p x y , isProp→isSet p _ _ (p x y)\n\n\n-- Exercise 4\nisContr→isContr≡ : isContr A → (x y : A) → isContr (x ≡ y)\nisContr→isContr≡ h = isProp→isProp' (isContr→isProp h)\n\n\n-- Exercise 5\nfromPathP : {A : I → Type ℓ} {x : A i0} {y : A i1}\n → PathP A x y\n → transport (λ i → A i) x ≡ y\nfromPathP {A = A} p i = transp (λ j → A (i ∨ j)) i (p i)\n\n\n-- The converse is harder to prove so we give it:\ntoPathP : {A : I → Type ℓ} {x : A i0} {y : A i1}\n → transport (λ i → A i) x ≡ y\n → PathP A x y\ntoPathP {A = A} {x = x} p i =\n hcomp (λ j → λ { (i = i0) → x\n ; (i = i1) → p j })\n (transp (λ j → A (i ∧ j)) (~ i) x)\n\n\n-- Exercise 6\nΣ≡Prop : {B : A → Type ℓ'} {u v : Σ A B} (h : (x : A) → isProp (B x))\n → (p : fst u ≡ fst v) → u ≡ v\nΣ≡Prop {B = B} {u = u} {v = v} h p =\n ΣPathP (p , toPathP (h _ (transport (λ i → B (p i)) (snd u)) (snd v)))\n\n\n-- Exercice 7 (thanks Loïc for the slick proof!)\nisPropIsContr : isProp (isContr A)\nisPropIsContr (c0 , h0) (c1 , h1) j =\n h0 c1 j , λ y i → hcomp (λ k → λ { (i = i0) → h0 (h0 c1 j) k;\n (i = i1) → h0 y k;\n (j = i0) → h0 (h0 y i) k;\n (j = i1) → h0 (h1 y i) k}) c0\n\n\n-- Exercises about Part 3:\n\n-- Exercise 8 (a bit longer, but very good):\n\nopen import Cubical.Data.Nat\nopen import Cubical.Data.Int hiding (addEq ; subEq)\n\n-- Compose sucPathInt with itself n times. Transporting along this\n-- will be addition, transporting with it backwards will be subtraction.\n\n-- a) Define a path \"addEq n\" by composing sucPathInt with itself n\n-- times.\naddEq : ℕ → Int ≡ Int\naddEq zero = refl\naddEq (suc n) = (addEq n) ∙ sucPathInt\n\n-- b) Define another path \"subEq n\" by composing \"sym sucPathInt\" with\n-- itself n times.\nsubEq : ℕ → Int ≡ Int\nsubEq zero = refl\nsubEq (suc n) = (subEq n) ∙ sym sucPathInt\n\n\n-- c) Define addition on integers by pattern-matching and transporting\n-- along addEq/subEq appropriately.\n_+Int_ : Int → Int → Int\nm +Int pos n = transport (addEq n) m\nm +Int negsuc n = transport (subEq (suc n)) m\n\n-- d) Do some concrete computations using _+Int_ (this would not work\n-- in HoTT as the transport would be stuck!)\n\n\n-- Exercise 9: prove that hSet is not an hSet\n\nopen import Cubical.Data.Bool renaming (notEq to notPath)\nopen import Cubical.Data.Empty\n\n-- Just define hSets of level 0 for simplicity\nhSet : Type₁\nhSet = Σ[ A ∈ Type₀ ] isSet A\n\n-- Bool is an hSet\nBoolSet : hSet\nBoolSet = Bool , isSetBool\n\nnotPath≢refl : (notPath ≡ refl) → ⊥\nnotPath≢refl e = true≢false (transport (λ i → transport (e i) true ≡ false) refl)\n\n¬isSet-hSet : isSet hSet → ⊥\n¬isSet-hSet h = notPath≢refl (cong (cong fst) (h BoolSet BoolSet p refl))\n where\n p : BoolSet ≡ BoolSet\n p = Σ≡Prop (λ A → isPropIsSet {A = A}) notPath\n\n\n-- Exercise 10: squivalence between FinData and Fin\n\n-- Thanks to Elies for the PR with the code. On the development\n-- version of the library there is now:\n--\n-- open import Cubical.Data.Fin using (FinData≡Fin)\n\n", "meta": {"hexsha": "df867fde78127db5d16213cab2089c4430147030", "size": 3498, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "04-cubical-type-theory/material/SolutionsSession2.agda", "max_stars_repo_name": "williamdemeo/EPIT-2020", "max_stars_repo_head_hexsha": "19d72759e18e05d2c509f62d23a998573270140c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "04-cubical-type-theory/material/SolutionsSession2.agda", "max_issues_repo_name": "williamdemeo/EPIT-2020", "max_issues_repo_head_hexsha": "19d72759e18e05d2c509f62d23a998573270140c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "04-cubical-type-theory/material/SolutionsSession2.agda", "max_forks_repo_name": "williamdemeo/EPIT-2020", "max_forks_repo_head_hexsha": "19d72759e18e05d2c509f62d23a998573270140c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-08-02T16:16:34.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-02T16:16:34.000Z", "avg_line_length": 27.7619047619, "max_line_length": 81, "alphanum_fraction": 0.598913665, "num_tokens": 1268, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8976953003183443, "lm_q2_score": 0.8688267796346599, "lm_q1q2_score": 0.779941716868756}} {"text": "module plfa-exercises.Practice where\n\n--------------------------------------- Naturals ---------------------------------------\n\n-- Inductive definition of Numbers (new datatype)\ndata ℕ : Set where\n-- Judgements (two in total for this case)\n zero : ℕ -- No hypothesis and one conclusion\n suc : ℕ → ℕ -- One hypothesis and one conclusion\n\nseven : ℕ\nseven = suc (suc (suc (suc (suc (suc (suc zero))))))\n--seven′ = --7\n\npred : ℕ → ℕ\npred zero = zero\npred (suc n) = n\n\n---\n\n-- Gives us the power of writing 3 to signify suc (suc (suc zero)) :)\n{-# BUILTIN NATURAL ℕ #-}\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; _≢_; refl; cong; sym; trans)\nopen Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _≡⟨_⟩_; _∎)\nopen import Function.Base using (flip)\nopen import Relation.Nullary using (¬_)\nopen import Data.Empty using (⊥; ⊥-elim)\nopen import Data.Product using (_×_; ∃-syntax) renaming (_,_ to ⟨_,_⟩)\nopen import Data.Sum using (_⊎_; inj₁; inj₂)\n\n_+_ : ℕ → ℕ → ℕ\nzero + n = n -- +-def₀\n(suc m) + n = suc (m + n) -- +-def₁\n\n--_ : (suc (suc zero)) + (suc (suc (suc zero))) ≡ (suc (suc (suc (suc (suc zero)))))\n--_ =\n-- begin\n-- (suc (suc zero)) + (suc (suc (suc zero)))\n-- ≡⟨⟩ -- inductive case\n-- suc ((suc zero) + (suc (suc (suc zero))))\n-- ≡⟨⟩ -- inductive case\n-- suc (suc (zero + (suc (suc (suc zero)))))\n-- ≡⟨⟩ -- base case\n-- suc (suc (suc (suc (suc zero))))\n-- ∎\n--\n--_ : 2 + 3 ≡ 5\n--_ =\n-- begin\n-- 2 + 3\n-- (suc 1) + 3\n-- ≡⟨⟩\n-- suc (1 + 3)\n-- ≡⟨⟩\n-- suc (suc 0 + 3)\n-- ≡⟨⟩\n-- suc (suc (0 + 3))\n-- ≡⟨⟩\n-- suc (suc 3)\n-- ≡⟨⟩\n-- suc 4\n-- ≡⟨⟩\n-- 5\n-- ∎\n--\n--\n--_ : (suc (suc zero)) + (suc (suc (suc zero))) ≡ (suc (suc (suc (suc (suc zero)))))\n--_ = refl\n\n_*_ : ℕ → ℕ → ℕ\nzero * n = zero\n(suc m) * n = n + (m * n)\n\n_^_ : ℕ → ℕ → ℕ\nn ^ zero = suc zero\nn ^ (suc m) = n * (n ^ m)\n\n-- Monus\n_∸_ : ℕ → ℕ → ℕ\nm ∸ zero = m\nzero ∸ suc n = zero\nsuc m ∸ suc n = m ∸ n\n\ninfixl 6 _+_ _∸_\ninfixl 7 _*_\ninfixr 8 _^_\n\n\n-- Superfun binary numbers :D\ndata Bin : Set where\n ⟨⟩ : Bin\n _O : Bin → Bin\n _I : Bin → Bin\n\ninc : Bin → Bin\ninc ⟨⟩ = ⟨⟩ I\ninc (b O) = b I\ninc (b I) = (inc b) O\n\n_ : inc (⟨⟩ I O I I) ≡ ⟨⟩ I I O O\n_ = refl\n\ntoᵇ : ℕ → Bin\ntoᵇ zero = ⟨⟩ O\ntoᵇ (suc n) = inc (toᵇ n)\n\nfromᵇ : Bin → ℕ\nfromᵇ ⟨⟩ = zero\nfromᵇ (b O) = let n = fromᵇ b in n + n\nfromᵇ (b I) = let n = fromᵇ b in suc (n + n)\n\n_ : toᵇ 11 ≡ (⟨⟩ I O I I)\n_ = refl\n\n_ : fromᵇ (inc (⟨⟩ I O I I)) ≡ 12\n_ = refl\n--_ = begin\n-- (fromᵇ (⟨⟩ I I O O))\n-- ≡⟨ 12 ≡⟨⟩ 12 ∎ ⟩ \n-- 12\n-- ∎\n\n--_ : Set₉₁₁₁₁₁₁₁₁₁₁₁₁₁₁₁₁₁₁₁₁\n--_ : Set₀\n_ : Set\n_ = suc 11 ≡ 12\n\n_+ᵇ_ : Bin → Bin → Bin\n⟨⟩ +ᵇ b = b\nb +ᵇ ⟨⟩ = b\n--(b O) +ᵇ ⟨⟩ = b O\n(b O) +ᵇ (d O) = (b +ᵇ d) O\n(b O) +ᵇ (d I) = (b +ᵇ d) I\n--(b I) +ᵇ ⟨⟩ = b I\n(b I) +ᵇ (d O) = (b +ᵇ d) I\n(b I) +ᵇ (d I) = (inc (b +ᵇ d)) O\n\n-- Proving the following is trivial\nmod-left : ∀ {b : Bin} → ⟨⟩ +ᵇ b ≡ b\nmod-left = refl\n-- But not its complement. This is due to \"case trees\" (or how Agda implements\n-- functions under the hood)\n-- https://agda.readthedocs.io/en/v2.6.0.1/language/function-definitions.html#case-trees\nmod-right : ∀ {b : Bin} → b +ᵇ ⟨⟩ ≡ b\nmod-right {⟨⟩} = refl\nmod-right {b O} = refl\nmod-right {b I} = refl\n-- Also, I'm confused on the implications of improper \"case trees\". If the\n-- second rule wasn't reachable, the following code would run even\n-- if the rule was nonesense (eg, changing `b +ᵇ ⟨⟩ = b O O`) but it doesn't\n-- work! The rule must make sense. So, Agda is applying the rule after all and\n-- not ignoring it even thought it can't be reached directly in proofs\n_ : (⟨⟩ I O I I I) +ᵇ (⟨⟩ O O I) ≡ ⟨⟩ I I O O O\n_ = refl\n\n\n---proppre : ∀ (n : ℕ) → zero + suc n ≡ suc (zero + n)\n---proppre zero = refl\n---proppre (suc n) =\n--- begin\n--- zero + suc (suc n)\n--- ≡⟨⟩\n--- zero + suc (zero + suc n)\n--- ≡⟨⟩\n--- suc (zero + suc n)\n--- ∎\n --≡⟨ cong suc (proppre n) ⟩\n\n-- Taken it from book\nassoc-+ : ∀ (m n p : ℕ) → (m + n) + p ≡ m + (n + p)\nassoc-+ zero n p = refl\nassoc-+ (suc m) n p rewrite assoc-+ m n p = refl\n\ncomm-+₀ : ∀ (m : ℕ) → m + zero ≡ m\ncomm-+₀ zero = refl\ncomm-+₀ (suc n) rewrite comm-+₀ n = refl\n--comm-+₀ (suc n) =\n-- begin\n-- zero + suc n\n-- ≡⟨⟩\n-- zero + suc (zero + n)\n-- ≡⟨⟩\n-- suc (zero + n)\n-- ≡⟨ cong suc (comm-+₀ n) ⟩\n-- suc (n + zero)\n-- ≡⟨⟩\n-- suc n + zero\n-- ∎\n\nsucc_right : ∀ (n m : ℕ) → suc (n + m) ≡ n + suc m\nsucc_right zero m = refl\nsucc_right (suc n) m rewrite succ_right n m = refl\n--succ_right (suc n) m = cong suc (succ_right n m)\n--succ_right (suc n) m =\n-- begin\n-- suc (suc n + m)\n-- ≡⟨⟩\n-- suc (suc (n + m))\n-- ≡⟨ cong suc (succ_right n m) ⟩\n-- suc (n + suc m)\n-- ≡⟨⟩\n-- suc n + suc m\n-- ∎\n\ncomm-+ : ∀ (n m : ℕ) → n + m ≡ m + n\ncomm-+ zero n = sym (comm-+₀ n)\ncomm-+ (suc n) m rewrite comm-+ n m | succ_right m n = refl\n--comm-+ (suc n) m = trans (cong suc (comm-+ n m)) (succ_right m n)\n--comm-+ (suc n) m =\n-- begin\n-- suc n + m\n-- ≡⟨⟩ -- +-def₁\n-- suc (n + m)\n-- ≡⟨ cong suc (comm-+ n m) ⟩\n-- suc (m + n)\n-- ≡⟨ succ_right m n ⟩\n-- m + suc n\n-- ∎\n\n-- Try evaluating and type-checking the following expressions:\n-- comm-+ zero\n-- (flip comm-+) zero\n-- λ n m → cong suc (comm-+ n m)\n-- λ m n → succ_right m n\n-- λ m n → sym (succ_right m n)\n-- λ n m → trans (cong suc (comm-+ n m)) (succ_right m n)\n\nmonus : ∀ (n : ℕ) → zero ∸ n ≡ zero\nmonus zero = refl\nmonus (suc n) = refl\n--monus : ∀ {n : ℕ} → zero ∸ n ≡ zero\n--monus {zero} = refl\n--monus {suc n} = refl\n\ninc≡suc : ∀ (b : Bin) → fromᵇ (inc b) ≡ suc (fromᵇ b)\ninc≡suc ⟨⟩ = refl\ninc≡suc (b O) rewrite sym (comm-+₀ (fromᵇ b)) = refl\ninc≡suc (b I)\n rewrite\n comm-+₀ (fromᵇ (inc b))\n | inc≡suc b\n | succ_right (fromᵇ b) (fromᵇ b)\n | comm-+₀ (fromᵇ b)\n | succ_right (fromᵇ b) (fromᵇ b) = refl\n\n-- `toᵇ (fromᵇ b) ≡ b` doesn't hold for all values, just for some.\n-- So the following is false\n--tofromb≢b : ∀ (b : Bin) → ¬ (toᵇ (fromᵇ b) ≡ b)\n--tofromb≢b ⟨⟩ = λ()\n--tofromb≢b = ? -- impossible to prove\n\n_ : ¬ (toᵇ (fromᵇ ⟨⟩) ≡ ⟨⟩)\n_ = λ()\n\n--from∘toᵇ₀ : ∀ (n : ℕ) → fromᵇ ((toᵇ n) O) ≡ fromᵇ (toᵇ n) + fromᵇ (toᵇ n)\n--from∘toᵇ₀ zero = refl\n--from∘toᵇ₀ (suc n) = refl\n--\n--from∘toᵇ₁ : ∀ (n : ℕ) → fromᵇ ((toᵇ n) I) ≡ suc (fromᵇ (toᵇ n) + fromᵇ (toᵇ n))\n--from∘toᵇ₁ zero = refl\n--from∘toᵇ₁ (suc n) = refl\n\nmonobin₀ : ∀ (b : Bin) → inc (inc (b +ᵇ b)) ≡ (inc b +ᵇ inc b)\nmonobin₀ ⟨⟩ = refl\nmonobin₀ (b O) = refl\nmonobin₀ (b I) rewrite monobin₀ b = refl\n\nmonobin : ∀ (n : ℕ) → toᵇ (n + n) ≡ (toᵇ n) +ᵇ (toᵇ n)\nmonobin zero = refl\nmonobin (suc n) rewrite\n sym (succ_right n n)\n | monobin n\n | monobin₀ (toᵇ n) = refl\n\n--mononat₀ : ∀ (a : Bin) → a +ᵇ ⟨⟩ ≡ a\n--mononat₀ ⟨⟩ = refl\n--mononat₀ (b O) = refl\n--mononat₀ (b I) = refl\n--\n--mononat₁ : ∀ (a b : Bin) → fromᵇ (inc (a +ᵇ b)) ≡ suc (fromᵇ a + fromᵇ b)\n--mononat₁ ⟨⟩ b rewrite inc≡suc b = refl\n--mononat₁ a ⟨⟩ rewrite mononat₀ a | comm-+₀ (fromᵇ a) | inc≡suc a = refl\n--mononat₁ = ?\n---- λ a → fromᵇ (inc (a +ᵇ ⟨⟩)) ≡ suc (fromᵇ a + fromᵇ ⟨⟩)\n---- fromᵇ (inc b) ≡ suc (fromᵇ b)\n--\n--mononat : ∀ (a b : Bin) → fromᵇ (a +ᵇ b) ≡ fromᵇ a + fromᵇ b\n--mononat ⟨⟩ _ = refl\n--mononat a ⟨⟩ rewrite mononat₀ a | comm-+₀ (fromᵇ a) = refl\n----mononat a ⟨⟩ = \n---- begin\n---- fromᵇ (a +ᵇ ⟨⟩)\n---- ≡⟨ cong fromᵇ (mononat₀ a) ⟩\n---- fromᵇ (a)\n---- ≡⟨ sym (comm-+₀ (fromᵇ a)) ⟩\n---- fromᵇ a + zero\n---- ≡⟨⟩\n---- fromᵇ a + fromᵇ ⟨⟩\n---- ∎\n--mononat (a O) (b O) rewrite\n-- mononat a b\n-- | assoc-+ (fromᵇ a) (fromᵇ b) (fromᵇ a + fromᵇ b)\n-- | comm-+ (fromᵇ b) (fromᵇ a + fromᵇ b)\n-- | assoc-+ (fromᵇ a) (fromᵇ a) (fromᵇ b + fromᵇ b)\n-- | assoc-+ (fromᵇ a) (fromᵇ b) (fromᵇ b)\n-- = refl\n--mononat (a I) (b O) rewrite\n-- mononat a b\n-- | assoc-+ (fromᵇ a) (fromᵇ b) (fromᵇ a + fromᵇ b)\n-- | comm-+ (fromᵇ b) (fromᵇ a + fromᵇ b)\n-- | assoc-+ (fromᵇ a) (fromᵇ a) (fromᵇ b + fromᵇ b)\n-- | assoc-+ (fromᵇ a) (fromᵇ b) (fromᵇ b)\n-- = refl\n--mononat (a O) (b I) rewrite\n-- mononat a b\n-- | sym (succ_right (fromᵇ a + fromᵇ a) (fromᵇ b + fromᵇ b))\n-- | assoc-+ (fromᵇ a) (fromᵇ b) (fromᵇ a + fromᵇ b)\n-- | comm-+ (fromᵇ b) (fromᵇ a + fromᵇ b)\n-- | assoc-+ (fromᵇ a) (fromᵇ a) (fromᵇ b + fromᵇ b)\n-- | assoc-+ (fromᵇ a) (fromᵇ b) (fromᵇ b)\n-- = refl\n--mononat (a I) (b I) rewrite\n-- mononat₁ a b\n-- | sym (succ_right (fromᵇ a + fromᵇ a) (fromᵇ b + fromᵇ b))\n-- | sym (succ_right (fromᵇ a + fromᵇ b) (fromᵇ a + fromᵇ b))\n-- | assoc-+ (fromᵇ a) (fromᵇ b) (fromᵇ a + fromᵇ b)\n-- | comm-+ (fromᵇ b) (fromᵇ a + fromᵇ b)\n-- | assoc-+ (fromᵇ a) (fromᵇ a) (fromᵇ b + fromᵇ b)\n-- | assoc-+ (fromᵇ a) (fromᵇ b) (fromᵇ b)\n-- = refl\n\n-- Really hard!! Keep working on it!\n-- IT WASN'T HARD!!! I JUST COULDN'T SEE THE RIGHT REWRITE!!\nfrom∘toᵇ : ∀ (n : ℕ) → fromᵇ (toᵇ n) ≡ n\nfrom∘toᵇ zero = refl\nfrom∘toᵇ (suc n) rewrite inc≡suc (toᵇ n) | from∘toᵇ n = refl\n--from∘toᵇ (suc n) =\n-- begin\n-- fromᵇ (toᵇ (suc n))\n-- ≡⟨⟩\n-- fromᵇ (inc (toᵇ n))\n-- ≡⟨ inc≡suc (toᵇ n) ⟩\n-- suc (fromᵇ (toᵇ n))\n-- ≡⟨ cong suc (from∘toᵇ n) ⟩\n-- suc n\n-- ∎\n\nswap-m-n-+ : ∀ (m n p) → m + (n + p) ≡ n + (m + p)\nswap-m-n-+ m n p rewrite\n sym (assoc-+ m n p)\n | sym (assoc-+ n m p)\n | comm-+ m n\n = refl\n\nright-zero-* : ∀ (n : ℕ) → n * 0 ≡ 0\nright-zero-* zero = refl\nright-zero-* (suc n) rewrite right-zero-* n = refl\n\nsuc-right-* : ∀ (m n) → m * suc n ≡ m + m * n\nsuc-right-* zero n = refl\nsuc-right-* (suc m) n\n rewrite\n suc-right-* m n\n | sym (assoc-+ n m (m * n))\n | comm-+ n m\n | assoc-+ m n (m * n)\n = refl\n\ncomm-* : ∀ (m n : ℕ) → m * n ≡ n * m\ncomm-* zero n rewrite right-zero-* n = refl\ncomm-* (suc m) n\n rewrite\n comm-* m n\n | suc-right-* n m\n = refl\n\ndistr-*-+ : ∀ (m n p) → (m + n) * p ≡ m * p + n * p\ndistr-*-+ zero _ _ = refl\ndistr-*-+ (suc m) n p rewrite distr-*-+ m n p | assoc-+ p (m * p) (n * p) = refl\n\ndistl-*-+ : ∀ (p m n) → p * (m + n) ≡ p * m + p * n\ndistl-*-+ zero _ _ = refl\ndistl-*-+ (suc p) m n\n rewrite\n distl-*-+ p m n\n | sym (assoc-+ (m + n) (p * m) (p * n))\n | sym (assoc-+ (m + p * m) n (p * n))\n | assoc-+ m n (p * m)\n | comm-+ n (p * m)\n | assoc-+ m (p * m) n\n = refl\n\nassoc-* : ∀ (m n p : ℕ) → (m * n) * p ≡ m * (n * p)\nassoc-* zero n p = refl\nassoc-* (suc m) n p\n rewrite\n assoc-* m n p\n | distr-*-+ n (m * n) p\n | assoc-* m n p\n = refl\n\nswap-m-n-* : ∀ (m n p) → m * (n * p) ≡ n * (m * p)\nswap-m-n-* m n p rewrite\n sym (assoc-* m n p)\n | sym (assoc-* n m p)\n | comm-* m n\n = refl\n\ndistr-^-* : ∀ (m n p) → (m * n) ^ p ≡ (m ^ p) * (n ^ p)\n--distr-^-* m n zero =\n-- begin\n-- (m * n) ^ zero\n-- ≡⟨⟩\n-- (m * n) ^ 0\n-- ≡⟨⟩\n-- suc 0\n-- ≡⟨⟩\n-- 1\n-- ≡⟨⟩\n-- 1 + 0\n-- ≡⟨⟩\n-- 1 + 0 * 1\n-- ≡⟨⟩\n-- (suc 0) * 1\n-- ≡⟨⟩\n-- (suc 0) * 1\n-- ≡⟨⟩\n-- 1 * 1\n-- ≡⟨⟩\n-- 1 * (n ^ 0)\n-- ≡⟨⟩\n-- (m ^ zero) * (n ^ zero)\n-- ≡⟨⟩\n-- (m ^ 0) * (n ^ 0)\n-- ∎\ndistr-^-* _ _ zero = refl\ndistr-^-* zero zero (suc p) = refl\ndistr-^-* zero (suc n) (suc p) = refl\ndistr-^-* (suc m) zero (suc p)\n rewrite\n right-zero-* (suc m ^ suc p)\n | right-zero-* m\n = refl\ndistr-^-* (suc m) (suc n) (suc p)\n rewrite\n-- (suc m * suc n) ^ suc p ≡ suc m ^ suc p * suc n ^ suc p\n--\n-- suc (n + m * suc n) ^ p + (n + m * suc n) * suc (n + m * suc n) ^ p\n-- ≡ (suc m ^ p + m * suc m ^ p) * (suc n ^ p + n * suc n ^ p)\n distr-*-+ (suc m ^ p) (m * suc m ^ p) (suc n ^ p + n * suc n ^ p)\n-- suc (n + m * suc n) ^ p + (n + m * suc n) * suc (n + m * suc n) ^ p\n-- ≡\n-- suc m ^ p * (suc n ^ p + n * suc n ^ p)\n-- + m * suc m ^ p * (suc n ^ p + n * suc n ^ p)\n | assoc-* m (suc m ^ p) (suc n ^ p + n * suc n ^ p)\n-- suc (n + m * suc n) ^ p + (n + m * suc n) * suc (n + m * suc n) ^ p\n-- ≡\n-- suc m ^ p * (suc n ^ p + n * suc n ^ p)\n-- + m * (suc m ^ p * (suc n ^ p + n * suc n ^ p))\n | distl-*-+ (suc m ^ p) (suc n ^ p) (n * suc n ^ p)\n-- suc (n + m * suc n) ^ p + (n + m * suc n) * suc (n + m * suc n) ^ p\n-- ≡\n-- suc m ^ p * suc n ^ p + suc m ^ p * (n * suc n ^ p)\n-- + m * (suc m ^ p * suc n ^ p + suc m ^ p * (n * suc n ^ p))\n | comm-* m (suc n)\n-- suc (n + (m + n * m)) ^ p\n-- + (n + (m + n * m)) * suc (n + (m + n * m)) ^ p\n-- ≡\n-- suc m ^ p * suc n ^ p + suc m ^ p * (n * suc n ^ p)\n-- + m * (suc m ^ p * suc n ^ p + suc m ^ p * (n * suc n ^ p))\n | comm-* n m\n-- suc (n + (m + m * n)) ^ p\n-- + (n + (m + m * n)) * suc (n + (m + m * n)) ^ p\n-- ≡\n-- suc m ^ p * suc n ^ p + suc m ^ p * (n * suc n ^ p)\n-- + m * (suc m ^ p * suc n ^ p + suc m ^ p * (n * suc n ^ p))\n | sym (suc-right-* m n)\n-- suc (n + m * suc n) ^ p\n-- + (n + m * suc n) * suc (n + m * suc n) ^ p\n-- ≡\n-- suc m ^ p * suc n ^ p + suc m ^ p * (n * suc n ^ p)\n-- + m * (suc m ^ p * suc n ^ p + suc m ^ p * (n * suc n ^ p))\n | distr-^-* (suc m) (suc n) p\n-- suc m ^ p * suc n ^ p + (n + m * suc n) * (suc m ^ p * suc n ^ p)\n-- ≡\n-- suc m ^ p * suc n ^ p + suc m ^ p * (n * suc n ^ p)\n-- + m * (suc m ^ p * suc n ^ p + suc m ^ p * (n * suc n ^ p))\n | distr-*-+ n (m * suc n) (suc m ^ p * suc n ^ p)\n-- suc m ^ p * suc n ^ p + (n * (suc m ^ p * suc n ^ p)\n-- + m * suc n * (suc m ^ p * suc n ^ p))\n-- ≡\n-- suc m ^ p * suc n ^ p + suc m ^ p * (n * suc n ^ p)\n-- + m * (suc m ^ p * suc n ^ p + suc m ^ p * (n * suc n ^ p))\n | distl-*-+ m (suc m ^ p * suc n ^ p) (suc m ^ p * (n * suc n ^ p))\n-- suc m ^ p * suc n ^ p + (n * (suc m ^ p * suc n ^ p)\n-- + m * suc n * (suc m ^ p * suc n ^ p))\n-- ≡\n-- suc m ^ p * suc n ^ p + suc m ^ p * (n * suc n ^ p)\n-- + (m * (suc m ^ p * suc n ^ p) + m * (suc m ^ p * (n * suc n ^ p)))\n | comm-* m (suc n)\n-- suc m ^ p * suc n ^ p + (n * (suc m ^ p * suc n ^ p)\n-- + (m + n * m) * (suc m ^ p * suc n ^ p))\n-- ≡\n-- suc m ^ p * suc n ^ p + suc m ^ p * (n * suc n ^ p)\n-- + (m * (suc m ^ p * suc n ^ p) + m * (suc m ^ p * (n * suc n ^ p)))\n | distr-*-+ m (n * m) (suc m ^ p * suc n ^ p)\n-- suc m ^ p * suc n ^ p +\n-- (n * (suc m ^ p * suc n ^ p) +\n-- (m * (suc m ^ p * suc n ^ p) + n * m * (suc m ^ p * suc n ^ p)))\n-- ≡\n-- suc m ^ p * suc n ^ p + suc m ^ p * (n * suc n ^ p) +\n-- (m * (suc m ^ p * suc n ^ p) + m * (suc m ^ p * (n * suc n ^ p)))\n | swap-m-n-* n (suc m ^ p) (suc n ^ p)\n-- suc m ^ p * suc n ^ p +\n-- (suc m ^ p * (n * suc n ^ p) +\n-- (m * (suc m ^ p * suc n ^ p) + n * m * (suc m ^ p * suc n ^ p)))\n-- ≡\n-- suc m ^ p * suc n ^ p + suc m ^ p * (n * suc n ^ p) +\n-- (m * (suc m ^ p * suc n ^ p) + m * (suc m ^ p * (n * suc n ^ p)))\n | swap-m-n-* (suc m ^ p) n (suc n ^ p)\n-- suc m ^ p * suc n ^ p +\n-- (n * (suc m ^ p * suc n ^ p) +\n-- (m * (suc m ^ p * suc n ^ p) + n * m * (suc m ^ p * suc n ^ p)))\n-- ≡\n-- suc m ^ p * suc n ^ p + n * (suc m ^ p * suc n ^ p) +\n-- (m * (suc m ^ p * suc n ^ p) + m * (n * (suc m ^ p * suc n ^ p)))\n | sym (assoc-* m n (suc m ^ p * suc n ^ p))\n-- suc m ^ p * suc n ^ p +\n-- (n * (suc m ^ p * suc n ^ p) +\n-- (m * (suc m ^ p * suc n ^ p) + n * m * (suc m ^ p * suc n ^ p)))\n-- ≡\n-- suc m ^ p * suc n ^ p + n * (suc m ^ p * suc n ^ p) +\n-- (m * (suc m ^ p * suc n ^ p) + m * n * (suc m ^ p * suc n ^ p))\n | comm-* m n\n-- suc m ^ p * suc n ^ p +\n-- (n * (suc m ^ p * suc n ^ p) +\n-- (m * (suc m ^ p * suc n ^ p) + n * m * (suc m ^ p * suc n ^ p)))\n-- ≡\n-- suc m ^ p * suc n ^ p + n * (suc m ^ p * suc n ^ p) +\n-- (m * (suc m ^ p * suc n ^ p) + n * m * (suc m ^ p * suc n ^ p))\n | assoc-+ (suc m ^ p * suc n ^ p) (n * (suc m ^ p * suc n ^ p))\n (m * (suc m ^ p * suc n ^ p) + n * m * (suc m ^ p * suc n ^ p))\n-- suc m ^ p * suc n ^ p +\n-- (n * (suc m ^ p * suc n ^ p) +\n-- (m * (suc m ^ p * suc n ^ p) + n * m * (suc m ^ p * suc n ^ p)))\n-- ≡\n-- suc m ^ p * suc n ^ p +\n-- (n * (suc m ^ p * suc n ^ p) +\n-- (m * (suc m ^ p * suc n ^ p) + n * m * (suc m ^ p * suc n ^ p)))\n-- QED\n = refl\n\n--distr-^-* (suc m) (suc n) (suc p)\n-- rewrite\n-- distr-*-+ (suc m ^ p) (m * suc m ^ p) (suc n ^ p + n * suc n ^ p)\n-- | assoc-* m (suc m ^ p) (suc n ^ p + n * suc n ^ p)\n-- | distl-*-+ (suc m ^ p) (suc n ^ p) (n * suc n ^ p)\n-- | comm-* m (suc n)\n-- | comm-* n m\n-- | sym (suc-right-* m n)\n-- | distr-^-* (suc m) (suc n) p\n-- | distr-*-+ n (m * suc n) (suc m ^ p * suc n ^ p)\n-- | distl-*-+ m (suc m ^ p * suc n ^ p) (suc m ^ p * (n * suc n ^ p))\n-- | comm-* m (suc n)\n-- | distr-*-+ m (n * m) (suc m ^ p * suc n ^ p)\n-- | swap-m-n-* n (suc m ^ p) (suc n ^ p)\n-- | swap-m-n-* (suc m ^ p) n (suc n ^ p)\n-- | sym (assoc-* m n (suc m ^ p * suc n ^ p))\n-- | comm-* m n\n-- | assoc-+ (suc m ^ p * suc n ^ p) (n * (suc m ^ p * suc n ^ p))\n-- (m * (suc m ^ p * suc n ^ p) + n * m * (suc m ^ p * suc n ^ p))\n-- = refl\n\n--------------------------------------- Relations ---------------------------------------\n\ndata _≤_ : ℕ → ℕ → Set where\n z≤n : ∀ {n : ℕ} → zero ≤ n\n s≤s : ∀ {m n : ℕ} → m ≤ n → suc m ≤ suc n\n\n_ : 2 ≤ 4\n_ = s≤s (s≤s z≤n)\n--_ = s≤s {1} {3} (s≤s {0} {2} (z≤n {2}))\n\ninv-s≤s : ∀ {m n : ℕ} → suc m ≤ suc n → m ≤ n\ninv-s≤s (s≤s m≤n) = m≤n\n\ninv-z≤n : ∀ {m : ℕ} → m ≤ zero → m ≡ zero\ninv-z≤n z≤n = refl\n\nrefl-≤ : ∀ {n : ℕ} → n ≤ n\nrefl-≤ {zero} = z≤n\nrefl-≤ {suc o} = s≤s refl-≤\n\ntrans-≤ : ∀ {m n p : ℕ} → m ≤ n → n ≤ p → m ≤ p\ntrans-≤ z≤n _ = z≤n\ntrans-≤ (s≤s m≤n) (s≤s n≤p) = s≤s (trans-≤ m≤n n≤p)\n\nantisym-≤ : ∀ {m n : ℕ} → m ≤ n → n ≤ m → m ≡ n\nantisym-≤ z≤n n≤m = sym (inv-z≤n n≤m)\nantisym-≤ (s≤s m≤n) (s≤s n≤m) = cong suc (antisym-≤ m≤n n≤m)\n\nopen import Data.Sum using (_⊎_; inj₁; inj₂) renaming ([_,_] to case-⊎)\n\n--data Total (m n : ℕ) : Set where\n-- forward : m ≤ n → Total m n\n-- flipped : n ≤ m → Total m n\n--\n--total-≤ : ∀ (m n : ℕ) → Total m n\n--total-≤ zero _ = forward z≤n\n--total-≤ (suc m) zero = flipped z≤n\n--total-≤ (suc m) (suc n) with total-≤ m n\n--... | forward m≤n = forward (s≤s m≤n)\n--... | flipped n≤m = flipped (s≤s n≤m)\n\ntotal-≤` : ∀ (m n : ℕ) → m ≤ n ⊎ n ≤ m\ntotal-≤` zero _ = inj₁ z≤n\ntotal-≤` _ zero = inj₂ z≤n\ntotal-≤` (suc m) (suc n) with total-≤` m n\n... | inj₁ m≤n = inj₁ (s≤s m≤n)\n... | inj₂ n≤m = inj₂ (s≤s n≤m)\n\n--+-monoʳ-≤ : ∀ (n p q : ℕ) → p ≤ q → (n + p) ≤ (n + q)\n--+-monoʳ-≤ zero _ _ p≤q = p≤q\n--+-monoʳ-≤ (suc n) p q p≤q = s≤s (+-monoʳ-≤ n p q p≤q)\n\n+-monoʳ-≤ : ∀ {n p q : ℕ} → p ≤ q → (n + p) ≤ (n + q)\n+-monoʳ-≤ {zero} p≤q = p≤q\n+-monoʳ-≤ {suc n} p≤q = s≤s (+-monoʳ-≤ {n} p≤q)\n\n+-monoˡ-≤ : ∀ {m n p : ℕ} → m ≤ n → (m + p) ≤ (n + p)\n+-monoˡ-≤ {m} {n} {p} m≤n rewrite comm-+ m p | comm-+ n p = +-monoʳ-≤ m≤n\n\n-- From book\n≤-trans : ∀ {m n p : ℕ} → m ≤ n → n ≤ p → m ≤ p\n≤-trans z≤n _ = z≤n\n≤-trans (s≤s m≤n) (s≤s n≤p) = s≤s (≤-trans m≤n n≤p)\n\n+-mono-≤ : ∀ {m n p q : ℕ} → m ≤ n → p ≤ q → (m + p) ≤ (n + q)\n+-mono-≤ m≤n p≤q = ≤-trans (+-monoˡ-≤ m≤n) (+-monoʳ-≤ p≤q)\n\n-- Exercises\n*-monoʳ-≤ : ∀ {n p q : ℕ} → p ≤ q → (n * p) ≤ (n * q)\n*-monoʳ-≤ {zero} p≤q = z≤n\n*-monoʳ-≤ {suc n} p≤q = +-mono-≤ p≤q (*-monoʳ-≤ {n} p≤q)\n\n*-monoˡ-≤ : ∀ {m n p : ℕ} → m ≤ n → (m * p) ≤ (n * p)\n*-monoˡ-≤ {m} {n} {p} m≤n rewrite comm-* m p | comm-* n p = *-monoʳ-≤ {p} {m} {n} m≤n\n\n*-mono-≤ : ∀ {m n p q : ℕ} → m ≤ n → p ≤ q → (m * p) ≤ (n * q)\n*-mono-≤ {_} {n} m≤n p≤q = ≤-trans (*-monoˡ-≤ m≤n) (*-monoʳ-≤ {n} p≤q)\n\ninfix 4 _<_\n\ndata _<_ : ℕ → ℕ → Set where\n z A -> Set\n _≤_ : A -> A -> Set\n ==-def : forall {x y} -> (x == y) ⇐⇒ (x ≤ y) ∧ (y ≤ x)\n ≤-refl : forall {x} -> x ≤ x\n ≤-trans : forall {x y z} -> x ≤ y -> y ≤ z -> x ≤ z\n\nmodule POrder {A : Set}(ord : PartialOrder A) where\n\n private module POrd = PartialOrder ord\n open POrd public\n\n infix 60 _≤_ _==_\n\n Monotone : (A -> A) -> Set\n Monotone f = forall {x y} -> x ≤ y -> f x ≤ f y\n \n Antitone : (A -> A) -> Set\n Antitone f = forall {x y} -> x ≤ y -> f y ≤ f x\n\n ≤-antisym : forall {x y} -> x ≤ y -> y ≤ x -> x == y\n ≤-antisym p q = snd ==-def (p , q)\n\n ==≤-L : forall {x y} -> x == y -> x ≤ y\n ==≤-L x=y = fst (fst ==-def x=y)\n\n ==≤-R : forall {x y} -> x == y -> y ≤ x\n ==≤-R x=y = snd (fst ==-def x=y)\n\n ==-refl : forall {x} -> x == x\n ==-refl = ≤-antisym ≤-refl ≤-refl\n\n ==-sym : forall {x y} -> x == y -> y == x\n ==-sym xy = snd ==-def (swap (fst ==-def xy))\n\n ==-trans : forall {x y z} -> x == y -> y == z -> x == z\n ==-trans xy yz = ≤-antisym\n (≤-trans x≤y y≤z)\n (≤-trans z≤y y≤x)\n where\n x≤y = ==≤-L xy\n y≤z = ==≤-L yz\n y≤x = ==≤-R xy\n z≤y = ==≤-R yz\n\n Dual : PartialOrder A\n Dual = record\n { _==_ = _==_\n ; _≤_ = \\x y -> y ≤ x\n ; ==-def = (swap ∘ fst ==-def , snd ==-def ∘ swap)\n ; ≤-refl = ≤-refl\n ; ≤-trans = \\yx zy -> ≤-trans zy yx\n }\n", "meta": {"hexsha": "50f3c8c37e924e2c4b0e373478c3d99e84a1a60d", "size": 1504, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/lattice/PartialOrder.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/outdated-and-incorrect/lattice/PartialOrder.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/outdated-and-incorrect/lattice/PartialOrder.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.0666666667, "max_line_length": 59, "alphanum_fraction": 0.4208776596, "num_tokens": 646, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9458012701768144, "lm_q2_score": 0.824461919906883, "lm_q1q2_score": 0.779777131060345}} {"text": "\nmodule Lib.Vec where\n\nopen import Lib.Prelude\nopen import Lib.Nat\nopen import Lib.Fin\n\ninfixr 40 _::_ _++_\n\ndata Vec (A : Set) : Nat -> Set where\n [] : Vec A 0\n _::_ : forall {n} -> A -> Vec A n -> Vec A (suc n)\n\n_++_ : {A : Set}{n m : Nat} -> Vec A n -> Vec A m -> Vec A (n + m)\n[] ++ ys = ys\n(x :: xs) ++ ys = x :: xs ++ ys\n\n_!_ : forall {A n} -> Vec A n -> Fin n -> A\n[] ! ()\nx :: xs ! zero = x\nx :: xs ! suc i = xs ! i\n\ntabulate : forall {A n} -> (Fin n -> A) -> Vec A n\ntabulate {n = zero} f = []\ntabulate {n = suc n} f = f zero :: tabulate (f ∘ suc)\n\nvec : forall {A n} -> A -> Vec A n\nvec x = tabulate (\\_ -> x)\n\ninfixl 30 _<*>_\n\n_<*>_ : forall {A B n} -> Vec (A -> B) n -> Vec A n -> Vec B n\n[] <*> [] = []\nf :: fs <*> x :: xs = f x :: (fs <*> xs)\n\nmap : forall {A B n} -> (A -> B) -> Vec A n -> Vec B n\nmap f xs = vec f <*> xs\n\nzip : forall {A B C n} -> (A -> B -> C) -> Vec A n -> Vec B n -> Vec C n\nzip f xs ys = vec f <*> xs <*> ys\n", "meta": {"hexsha": "6394315f305aacf874d571d51830f603f1209c13", "size": 973, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/simple-lib/Lib/Vec.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/simple-lib/Lib/Vec.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/simple-lib/Lib/Vec.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 23.7317073171, "max_line_length": 72, "alphanum_fraction": 0.4563206578, "num_tokens": 381, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9481545362802364, "lm_q2_score": 0.8221891305219504, "lm_q1q2_score": 0.7795623537846906}} {"text": "module Issue246 where\n\nmodule James where\n\n data Nat : Set where\n zero : Nat\n suc : Nat -> Nat\n\n data Zero : Set where\n\n data One : Set where\n void : One\n\n propLEQ : Nat -> Nat -> Set\n propLEQ zero _ = One\n propLEQ (suc n) (suc m) = propLEQ n m\n propLEQ (suc n) zero = Zero\n\n data Fin : Nat -> Set where\n fzero : {n : Nat} -> Fin (suc n)\n fsuc : {n : Nat} -> Fin n -> Fin (suc n)\n\n toFin : {n : Nat} -> (i : Nat) -> (propLEQ (suc i) n) -> Fin n\n toFin {zero} zero ()\n toFin {zero} (suc _) ()\n toFin {suc n} zero k = fzero\n toFin {suc n} (suc i) k = fsuc (toFin i k)\n\n one : Nat\n one = suc zero\n\n two : Nat\n two = suc one\n\n three : Nat\n three = suc two\n\n null : Fin three\n null = toFin zero void\n\nmodule Conor where\n\n data Nat : Set where\n ze : Nat\n su : Nat -> Nat\n\n data Bool : Set where\n tt ff : Bool\n\n record One : Set where\n data Zero : Set where\n\n So : Bool -> Set\n So tt = One\n So ff = Zero\n\n _<_ : Nat -> Nat -> Bool\n _ < ze = ff\n ze < su n = tt\n su m < su n = m < n\n\n data Lt (m n : Nat) : Set where\n lt : So (m < n) -> Lt m n\n\n boo : {m n : Nat} -> So (m < n) -> Lt (su m) (su n)\n boo p = lt p\n\nmodule Alan where\n\n data ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\n {-# BUILTIN NATURAL ℕ #-}\n {-# BUILTIN ZERO zero #-}\n {-# BUILTIN SUC suc #-}\n\n data Bool : Set where\n true false : Bool\n\n infixr 5 _∷_\n\n _lt_ : ℕ → ℕ → Bool\n _ lt zero = false\n zero lt suc _ = true\n suc x lt suc y = x lt y\n\n data List>=_ : {A B : Set} → M A → (A → M B) → M B\n\n mapM : {A B : Set} → (A → M B) → List A → M (List B)\n mapM f [] = return []\n mapM f (x :: xs) = f x >>= \\y →\n mapM f xs >>= \\ys →\n return (y :: ys)\n\nmapM’ : {M : Set → Set}\n → Monad M\n → {A B : Set}\n → (A → M B)\n → List A\n → M (List B)\nmapM’ Mon f xs = Monad.mapM Mon f xs\n\n--------------------------------------------------\n-- 2.9 Exercises\n\n-------------------------\n-- Exercise 2.1. Matrix transposition\n-- inner vectors are rows\nMatrix : Set → Nat → Nat → Set\nMatrix A n m = Vec (Vec A n) m\n\n-- (a) function to compute vector containing n copies of element x\n\nvec : {n : Nat} {A : Set} → A → Vec A n\nvec {zero} x = []\nvec {suc n} x = x :: vec {n} x\n\nvecTest : Vec Nat 3\nvecTest = vec zero\n\n-- (b) point-wise application of vector of functions to vector of arguments\n\ninfixl 90 _$_\n_$_ : {n : Nat} {A B : Set} → Vec (A → B) n → Vec A n → Vec B n\n_$_ [] [] = []\n_$_ (f :: fs) (x :: xs) = f x :: fs $ xs\n\n$TestInputFs : Vec (Nat → Nat) 2\n$TestInputFs = (_+ 1) :: (_* 2) :: []\n\n$TestInputXs : Vec Nat 2\n$TestInputXs = 0 :: 2 :: []\n\n$TestOutput : Vec Nat 2\n$TestOutput = 1 :: 4 :: []\n\n$Test : $TestInputFs $ $TestInputXs ≡ $TestOutput\n$Test = refl\n\n-- (c) matrix transposition in terms of 'vec' and _$_\n\ntranspose : forall {A n m} → Matrix A n m → Matrix A m n\ntranspose [] = vec []\ntranspose (xs :: xss) = (vmap _::_ xs) $ (transpose xss)\n\ntransposeTestInput : Matrix Nat 2 3\ntransposeTestInput = r1 :: r2 :: r3 :: []\n where\n r1 = 1 :: 2 :: []\n r2 = 3 :: 4 :: []\n r3 = 5 :: 6 :: []\n\ntransposeTestOuput : Matrix Nat 3 2\ntransposeTestOuput = r1 :: r2 :: []\n where\n r1 = 1 :: 3 :: 5 :: []\n r2 = 2 :: 4 :: 6 :: []\n\ntransposeTest : transpose transposeTestInput ≡ transposeTestOuput\ntransposeTest = refl\n\n-------------------------\n-- Exercise 2.2. Vector lookup\n\n-- function composition\n_∘_ : ∀ {A B C : Set} → (B → C) → (A → B) → (A → C)\n(g ∘ f) x = g (f x)\n\n-- prove 'tabulate' and '!' are each other’s inverses\n\n-- (a) relatively easy\nlem-!-tab : ∀ {A n}\n → (f : Fin n → A) → (i : Fin n)\n → ((tabulate f) ! i) ≡ f i\nlem-!-tab f fzero = refl -- (tabulate f ! fzero) ≡ f fzero\nlem-!-tab f (fsuc i) = lem-!-tab (f ∘ fsuc) i -- (tabulate f ! fsuc i) ≡ f (fsuc i)\n\n-- (b) trickier\nlem-tab-! : forall {A n}\n → (xs : Vec A n)\n → tabulate (xs !_) ≡ xs\nlem-tab-! [] = refl\nlem-tab-! (x :: xs) -- tabulate (_!_ (x :: xs)) ≡ (x :: xs)\n with tabulate (xs !_) | lem-tab-! xs\n... | _y | refl = refl -- (x :: _y) ≡ (x :: xs)\n-- ^ ^\n-- Vec A n _y ≡ xs\n\n-------------------------\n-- Exercise 2.3. Sublists (see def above)\n\n-- (a) prove reflexivity and transitivity of ⊆\n\n-- need to name implicits since the interesting one does not come first\n⊆-refl : {A : Set} {xs : List A}\n → xs ⊆ xs\n⊆-refl {xs = []} = stop\n⊆-refl {xs = x :: xss} = keep (⊆-refl { xs = xss })\n\n{-\n [] [] []\n [] [] [z]\n [] [z] [z]\n [z] [z] [z]\n [z] [z] [z,z]\n [z] [z,z] [z,z]\n[z,z] [z,z] [z,z]\n-}\n\n⊆-trans : {A : Set} {xs ys zs : List A}\n → xs ⊆ ys\n → ys ⊆ zs\n → xs ⊆ zs\n-- [] [] []\n⊆-trans stop stop = stop\n\n-- [] [] [z]\n-- [z] [z] [z,z]\n⊆-trans xy (drop yz) = drop (⊆-trans xy yz)\n\n-- [] [z] [z]\n-- [z] [z,z] [z,z]\n⊆-trans (drop xy) (keep yz) = drop (⊆-trans xy yz)\n\n-- [z] [z] [z]\n⊆-trans (keep xy) (keep yz) = keep (⊆-trans xy yz)\n\n⊆-trans' : {A : Set} {xs ys zs : List A}\n → xs ⊆ ys\n → ys ⊆ zs\n → xs ⊆ zs\n⊆-trans' stop stop = stop\n⊆-trans' stop (drop yz) = drop (⊆-trans' stop yz)\n⊆-trans' (drop xy) (drop yz) = drop (⊆-trans' (drop xy) yz)\n⊆-trans' (drop xy) (keep yz) = drop (⊆-trans' xy yz)\n⊆-trans' (keep xy) (drop yz) = drop (⊆-trans' (keep xy) yz)\n⊆-trans' (keep xy) (keep yz) = keep (⊆-trans' xy yz)\n\n-- sublist TYPE of a specific list (compare to existing sublist RELATION above)\ninfixr 30 _:::_\ndata SubList {A : Set} : List A → Set where\n [] : SubList []\n _:::_ : forall x {xs} → SubList xs → SubList (x :: xs)\n skip : forall {x xs} → SubList xs → SubList (x :: xs)\n\n-- (b) extract list corresponding to a sublist\nforget : {A : Set} {xs : List A}\n → SubList xs\n → List A\nforget [] = []\nforget (x ::: s) = x :: forget s\nforget (skip s) = forget s\n\n-- (c) prove SubList is a sublist in the sense of ⊆\nlem-forget : {A : Set} {xs : List A}\n → (zs : SubList xs)\n → forget zs ⊆ xs\nlem-forget [] = stop\nlem-forget (x ::: zs) = keep (lem-forget zs)\nlem-forget (skip zs) = drop (lem-forget zs)\n\n-- (d) alternative def of filter : satisfies sublist property by construction\nfilter' : {A : Set}\n → (A → Bool) → (xs : List A)\n → SubList xs\nfilter' p [] = []\nfilter' p (x :: xs) with p x\n... | true = x ::: filter' p xs\n... | false = skip (filter' p xs)\n\n-- (e) complement of a sublist\ncomplement : {A : Set} {xs : List A}\n → SubList xs\n → SubList xs\ncomplement [] = []\ncomplement (x ::: xs) = skip (complement xs)\ncomplement (skip {x} xs) = x ::: complement xs\n\nmodule ComplementTest where\n ll : List Nat\n ll = 1 :: 2 :: 3 :: 4 :: []\n\n p1 : Nat → Bool\n p1 2 = true\n p1 3 = true\n p1 4 = true\n p1 _ = false\n\n p2 : Nat → Bool\n p2 2 = true\n p2 4 = true\n p2 _ = false\n\n sl1 : SubList ll\n sl1 = filter' p1 ll\n\n sl2 : SubList ll\n sl2 = filter' p2 ll\n\n sl1Test : sl1 ≡ skip (2 ::: 3 ::: 4 ::: [])\n sl1Test = refl\n\n sl2Test : sl2 ≡ skip (2 ::: skip (4 ::: []))\n sl2Test = refl\n\n c1 : SubList ll\n c1 = complement sl1\n\n c2 : SubList ll\n c2 = complement sl2\n\n cTest1 : c1 ≡ 1 ::: skip (skip (skip []))\n cTest1 = refl\n\n cTest2 : c2 ≡ 1 ::: skip (3 ::: skip [])\n cTest2 = refl\n\n-- https://medium.com/@angerman/powersets-in-haskell-1df9684db52a\n-- (f) compute all sublists of a given list\nsublists : {A : Set}\n → (xs : List A)\n → List (SubList xs)\nsublists [] = [] :: []\nsublists (x :: xs) = map (x :::_) (sublists xs) ++ (map skip (sublists xs))\n\n-- 2^3 elements - expected output MUST be in same element ORDER as function result\nsublistsTest : sublists (1 :: 2 :: 3 :: []) ≡\n (1 ::: 2 ::: 3 ::: []) ::\n (1 ::: 2 ::: skip []) ::\n (1 ::: skip (3 ::: [])) ::\n (1 ::: skip (skip [])) ::\n skip (2 ::: 3 ::: []) ::\n skip (2 ::: skip []) ::\n skip (skip (3 ::: [])) ::\n skip (skip (skip [])) ::\n []\nsublistsTest = refl\n\n{-\n------------------------------------------------------------------------------\n3 Programming Techniques : VIEWS and UNIVERSE constructions\n\n--------------------------------------------------\n3.1 VIEWS\n\nmatching can reveal info about term being matched AND terms INSIDE the type matched term\n\nVIEW[5]: datatypes whose purpose is to reveal info about its indices\n\nto use a view, define a view function\n- computes an element of the view for arbitrary indices\n-}\n\n-- view datatype expressing\n-- any Nat can be expressed as 2k or 2k + 1 for some k\n-- element of Parity n says if n is even or odd and what k is\ndata Parity : Nat → Set where\n even : (k : Nat) → Parity (k * 2)\n odd : (k : Nat) → Parity (1 + k * 2)\n\nparity : (n : Nat) → Parity n\nparity zero = even zero\nparity (suc n) with parity n\n... | even k = odd k\n... | odd k = even (suc k)\n{-\nparity (suc .(k * 2)) | even k = odd k\nparity (suc .(1 + k * 2)) | odd k = even (suc k)\n-}\n\nhalf : Nat → Nat\nhalf n with parity n\n... | even k = k\n... | odd k = k\n{-\n-- Note that k is bound in the pattern for the view,\n-- not in the dotted pattern for the natural number.\nhalf .(k * 2) | even k = k\nhalf .(1 + k * 2) | odd k = k\n-}\n\n-------------------------\n-- FINDING AN ELEMENT IN A LIST\n\n-- given predicate and list\n-- returns if P holds for all elements\n-- A proof of All P xs is a list of proofs of P x for each element x of xs.\n-- P does not have to be a decidable predicate.\ninfixr 30 _:all:_\ndata All {A : Set} (P : A → Set) : List A → Set where\n all[] : All P []\n _:all:_ : forall {x xs} → P x → All P xs → All P (x :: xs)\n\n-- to turn a decidable predicate into a general predicate, define:\nsatisfies : {A : Set} → (A → Bool) → A → Set\nsatisfies p x = isTrue (p x)\n\n-------------------------\n-- exercise : use All to prove 2nd part of correctness of filter\n-- - all elements of result satisfies the predicate\n-- All (satisfies p) (filter p xs)\n\n-- https://www.javaer101.com/en/article/18631037.html\n{-\nopen import Relation.Binary.PropositionalEquality\n\nfilter-lem-b : {A : Set} → (p : A → Bool) → (xs : List A) → All (satisfies p) (filter p xs)\nfilter-lem-b p [] = vacuo\nfilter-lem-b p (x :: xs) with p x | inspect p x\n... | true | [ eq ] = holds _ _ (subst isTrue (sym eq) _) (filter-lem-b p xs)\n... | false | [ eq ] = filter-lem-b p xs\n-}\n\n-- https://stackoverflow.com/questions/38572464/agda-type-isnt-simplified-in-with-block\nlem-all-filter : {A : Set}\n → (p : A → Bool) → (xs : List A)\n → All (satisfies p) (filter p xs)\nlem-all-filter p [] = all[]\n-- isTrue (p x)\nlem-all-filter p (x :: xs) with p x | λ (y : satisfies p x) → y :all: lem-all-filter p xs\n-- onTrue : (y : True) → All (λ x₁ → isTrue (p x₁)) (x :: filter p xs)\n... | true | onTrue = onTrue _\n... | false | _ = lem-all-filter p xs\n\n-------------------------\n-- VIEWS ON LISTS\n\n-- given : decidable predicate on elements of list\n-- find element in list that satisfies predicate,\n-- or else all elements satifies negation of the predicate\n\ndata Find {A : Set} (p : A → Bool) : List A → Set where\n -- does NOT specify which element to use as a witness in the found case.\n -- (If the view was always to return first (or last) matching element,\n -- force elements of xs (or ys) to satisfy the negation of p.)\n found : (xs : List A) → (y : A) → satisfies p y → (ys : List A)\n → Find p (xs ++ y :: ys)\n not-found : forall {xs} → All (satisfies (not ◦ p)) xs\n → Find p xs\n\n-- view function computing an element of Find p xs for any p and xs\n\n-- 1st attempt\n{-\nfind1 : {A : Set} (p : A → Bool) (xs : List A) → Find p xs\nfind1 p [] = not-found all[]\nfind1 p (x :: xs) with p x\n-- Need to return found on first match.\n-- ({ }) is isTrue (p x), even though already matched on p x and found out that it was true.\n-- Problem : when abstracting over p x did not know that needed to use the found constructor,\n-- so there were no p x to abstract over.\n-- WITH does not remember connection between the with-term and the pattern.\n... | true = found [] x {! !} xs\n... | false = {! !}\n-}\n\n{-\nA solution : make this connection explicit with a proof object.\nDo NOT abstract over the term itself\n- instead rather over arbitrary term of same type\n AND a proof that it is equal to the original term\n-}\n\n-- type of elements of type A AND proofs they are equal to some given x in A\ndata Inspect {A : Set} (x : A) : Set where\n it : (y : A) → x ≡ y → Inspect x\n\n-- construct an element of Inspect x by picking x as thing which is equal to x.\ninspect : {A : Set} → (x : A) → Inspect x\ninspect x = it x refl\n\n-- lemmas\ntrueIsTrue : {x : Bool} → x ≡ true → isTrue x\nfalseIsFalse : {x : Bool} → x ≡ false → isFalse x\ntrueIsTrue refl = _\nfalseIsFalse refl = _\n\n{-\nnow define find by abstracting over inspect (p x) rather than p x\nprovide either a proof of p x == true or a proof of p x == false\n- can be use in args to 'found' and 'not-found\n-}\n\nfind : {A : Set}\n → (p : A → Bool) → (xs : List A)\n → Find p xs\nfind p [] = not-found all[]\nfind p (x :: xs) with inspect (p x)\n-- When p x is true, inspect (p x) matches 'it true prf' where prf : p x == true.\n-- Use lemma to turn into proof of isTrue (p x) needed by 3rd arg of 'found'\n... | it true prf = found [] x (trueIsTrue prf) xs\n... | it false prf with find p xs\nfind p (x :: ._) | it false _ | found xs y py ys = found (x :: xs) y py ys\n-- p x is false : use lemma\nfind p (x :: xs) | it false prf | not-found npxs = not-found (falseIsFalse prf :all: npxs)\n\n-------------------------\n-- INDEXING INTO A LIST\n\n{-\nPreviously showed two ways of safely indexing into a list.\nBoth cases used type system to guarantee the index didn’t point outside the list.\n\nIn situations where there is no control over value of index (i.e., it might be outside)\na solution is to wrap result of lookup in MAYBE, but MAYBE provides no info.\n-}\n\n-- type of proofs that an element x is in a list xs.\ndata _∈_ {A : Set} (x : A) : List A → Set where\n hd : forall {xs} → x ∈ x :: xs -- 1st el is a member\n tl : forall {y xs} → x ∈ xs → x ∈ y :: xs -- any el in tail is member\n\n\n-- Given proof of x ∈ xs, compute index where x occurs.\n-- Count number of tls in proof.\nindex : forall {A} {x : A} {xs} → x ∈ xs → Nat\nindex hd = zero\nindex (tl p) = suc (index p)\n\n-- view on Nat with respect to list\ndata Lookup {A : Set} (xs : List A) : Nat → Set where\n inside : (x : A) → (p : x ∈ xs) → Lookup xs (index p)\n outside : (m : Nat) → Lookup xs (length xs + m)\n\n{-\nWhen n is valid, get element at that position and guarantee that element is returned.\nNo way for 'lookup' to cheat.\n\nWhen n is outside, get out-of-bounds proof showing by how much.\n-}\n\n-- now, guaranteed 'lookup' function\n_!'_ : {A : Set}\n → (xs : List A) → (n : Nat)\n → Lookup xs n\n[] !' n = outside n\n(x :: xs) !' zero = inside x hd\n(x :: xs) !' suc n with xs !' n\n... | inside y p = inside y (tl p)\n(x :: xs) !' suc .(length xs + n) | outside n = outside n\n{-\n(x :: xs) !' suc .(index p) | inside y p = inside y (tl p)\n(x :: xs) !' suc .(length xs + n) | outside n = outside n\n-}\n\n--------------------------------------------------\n-- TYPE CHECKER FOR λ-CALCULUS\n\n", "meta": {"hexsha": "222e4655c4d6a46f92aa762b4649477c2cdc122b", "size": 32168, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/paper/2008-Ulf_Norell_and_Chapman-Dependently_Typed_Programming_in_Agda/z.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/paper/2008-Ulf_Norell_and_Chapman-Dependently_Typed_Programming_in_Agda/z.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/paper/2008-Ulf_Norell_and_Chapman-Dependently_Typed_Programming_in_Agda/z.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 28.568383659, "max_line_length": 98, "alphanum_fraction": 0.5756652574, "num_tokens": 9827, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9273632976542184, "lm_q2_score": 0.83973396967765, "lm_q1q2_score": 0.7787384632725329}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import Setoids.Setoids\nopen import Groups.Definition\nopen import Groups.Subgroups.Definition\nopen import Groups.Actions.Definition\nopen import Sets.EquivalenceRelations\nopen import Groups.Actions.Definition\n\nmodule Groups.Actions.Stabiliser {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} {_+_ : A → A → A} {G : Group S _+_} (act : GroupAction G T) where\n\nopen GroupAction act\nopen Setoid T\n\nstabiliserPred : (x : B) → (g : A) → Set d\nstabiliserPred x g = (action g x) ∼ x\n\nstabiliserWellDefined : (x : B) → {g h : A} → Setoid._∼_ S g h → (stabiliserPred x g) → stabiliserPred x h\nstabiliserWellDefined x {g} {h} g=h gx=x = transitive (actionWellDefined1 (Equivalence.symmetric (Setoid.eq S) g=h)) gx=x\n where\n open Equivalence eq\n\nopen Setoid T\nopen Equivalence (Setoid.eq T)\n\nstabiliserSubgroup : (x : B) → Subgroup G (stabiliserPred x)\nSubgroup.isSubset (stabiliserSubgroup x) = stabiliserWellDefined x\nSubgroup.closedUnderPlus (stabiliserSubgroup x) gx=x hx=x = transitive associativeAction (transitive (actionWellDefined2 hx=x) gx=x)\nSubgroup.containsIdentity (stabiliserSubgroup x) = identityAction\nSubgroup.closedUnderInverse (stabiliserSubgroup x) {g} gx=x = transitive (transitive (transitive (actionWellDefined2 (symmetric gx=x)) (symmetric associativeAction)) (actionWellDefined1 (invLeft {g}))) identityAction\n where\n open Group G\n", "meta": {"hexsha": "50fa96831a26b26807355f2caa8c6a95644fc654", "size": 1444, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Groups/Actions/Stabiliser.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Groups/Actions/Stabiliser.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Groups/Actions/Stabiliser.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 43.7575757576, "max_line_length": 216, "alphanum_fraction": 0.737534626, "num_tokens": 447, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9416541610257063, "lm_q2_score": 0.8267117983401363, "lm_q1q2_score": 0.778476604876034}} {"text": "\nmodule plfa.part1.Midterm where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl; cong; sym)\n-- you can add any import definitions that you need\nopen import Data.Nat using (ℕ; zero; suc; _+_; _*_; _≤_; _>_; z≤n; s≤s; _≤?_)\nopen import Data.Nat.Properties using (+-assoc; +-suc; *-suc; +-comm; *-distribˡ-+; *-identityʳ)\nopen import Relation.Nullary using (yes; no)\nopen import plfa.part1.Induction using (*-distrib-+; *-zero)\n-- used for rewrite\nsimplify : ∀ {A : Set} (x : A) → x ≡ x\nsimplify x = refl\n\nsum : ℕ → ℕ\nsum 0 = 0\nsum n@(suc sn) = sum sn + n\n\n-- Problem 1\n-- remove the \"postulate\" and prove this theorem, which is a version of\n-- sum n ≡ n * (n + 1) / 2\n---postulate\nsimple : ∀ (n : ℕ) → (sum n) * 2 ≡ (suc n) * n\nsimple zero = refl\nsimple (suc n) rewrite *-distrib-+ (sum n) (suc n) 2 \n | simple n \n | simplify n \n | *-suc n n \n | +-comm n (n * n)\n | sym (+-assoc n (n * n) n) \n | +-comm n (n * n) | +-assoc (n * n) n n \n | sym (+-suc (n * n) (n + n)) | sym (+-assoc n (n * n) (suc (n + n))) \n | +-comm n (n * n) \n | sym (+-suc (n * n) n) \n | +-assoc (n * n) n (suc (n + n)) \n | sym (+-suc (n * n) (n + suc (n + n))) \n | sym (+-suc n (suc (n + n))) \n | sym (+-assoc (n * n) n (suc (suc (n + n)))) \n | *-suc n 1 \n | *-identityʳ n = refl \n\n\n-- Problem 2\n-- remove the postulate and implement this function, which gives an Natural\n-- number approximation of square root\npostulate \n sqrt : ℕ → ℕ\n\n-- you can run these test cases\n-- _ : sqrt 0 ≡ 0\n-- _ = refl\n-- _ : sqrt 1 ≡ 1\n-- _ = refl\n-- _ : sqrt 2 ≡ 1\n-- _ = refl\n-- _ : sqrt 3 ≡ 1\n-- _ = refl\n-- _ : sqrt 4 ≡ 2\n-- _ = refl\n-- _ : sqrt 5 ≡ 2\n-- _ = refl\n-- _ : sqrt 6 ≡ 2\n-- _ = refl\n-- _ : sqrt 7 ≡ 2\n-- _ = refl\n-- _ : sqrt 8 ≡ 2\n-- _ = refl\n-- _ : sqrt 9 ≡ 3\n-- _ = refl\n-- _ : sqrt 10 ≡ 3\n-- _ = refl\n-- _ : sqrt 11 ≡ 3\n-- _ = refl\n-- _ : sqrt 12 ≡ 3\n-- _ = refl\n-- _ : sqrt 13 ≡ 3\n-- _ = refl\n-- _ : sqrt 14 ≡ 3\n-- _ = refl\n-- _ : sqrt 15 ≡ 3\n-- _ = refl\n-- _ : sqrt 16 ≡ 4\n-- _ = refl\n-- _ : sqrt 17 ≡ 4\n-- _ = refl\n-- _ : sqrt 18 ≡ 4\n-- _ = refl\n-- _ : sqrt 19 ≡ 4\n-- _ = refl\n-- _ : sqrt 20 ≡ 4\n-- _ = refl\n-- _ : sqrt 21 ≡ 4\n-- _ = refl\n-- _ : sqrt 22 ≡ 4\n-- _ = refl\n-- _ : sqrt 23 ≡ 4\n-- _ = refl\n-- _ : sqrt 24 ≡ 4\n-- _ = refl\n-- _ : sqrt 24 ≡ 4\n-- _ = refl\n-- _ : sqrt 24 ≡ 4\n-- _ = refl\n-- _ : sqrt 25 ≡ 5\n-- _ = refl\n-- _ : sqrt 26 ≡ 5\n-- _ = refl\n-- _ : sqrt 27 ≡ 5\n-- _ = refl\n\n", "meta": {"hexsha": "609407830588d0fba1168a13dec1826f4125322c", "size": 2619, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/plfa/part1/Midterm.agda", "max_stars_repo_name": "zrz1996/plfa.github.io", "max_stars_repo_head_hexsha": "a30af28dc669502ec79d36379afd6925ad8f74da", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/plfa/part1/Midterm.agda", "max_issues_repo_name": "zrz1996/plfa.github.io", "max_issues_repo_head_hexsha": "a30af28dc669502ec79d36379afd6925ad8f74da", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/plfa/part1/Midterm.agda", "max_forks_repo_name": "zrz1996/plfa.github.io", "max_forks_repo_head_hexsha": "a30af28dc669502ec79d36379afd6925ad8f74da", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.5945945946, "max_line_length": 96, "alphanum_fraction": 0.4688812524, "num_tokens": 1073, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9390248242542283, "lm_q2_score": 0.8289388125473628, "lm_q1q2_score": 0.778394122769796}} {"text": "module map-is-fold-Tree where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl; sym; trans; cong)\nopen Eq.≡-Reasoning\n\nopen import map-Tree using (Tree; leaf; node; map-Tree)\nopen import fold-Tree using (fold-Tree)\n\npostulate\n -- 外延性の公理\n extensionality : ∀ {A B : Set} {f g : A → B}\n → (∀ (x : A) → f x ≡ g x)\n -----------------------\n → f ≡ g\n\n-- 外延性の公理を利用した証明のための補題\nlemma : ∀ {A B C D : Set} → (f : A → C) → (g : B → D) → (tree : Tree A B)\n → map-Tree f g tree ≡ fold-Tree (λ a → leaf (f a)) (λ treeˡ b treeʳ → node treeˡ (g b) treeʳ) tree\nlemma f g (leaf a) =\n begin\n map-Tree f g (leaf a)\n ≡⟨⟩\n leaf (f a)\n ≡⟨⟩\n fold-Tree (λ a → leaf (f a)) (λ treeˡ b treeʳ → node treeˡ (g b) treeʳ) (leaf a)\n ∎\nlemma f g (node treeˡ b treeʳ) =\n begin\n map-Tree f g (node treeˡ b treeʳ)\n ≡⟨⟩\n node (map-Tree f g treeˡ) (g b) (map-Tree f g treeʳ)\n ≡⟨ cong (λ treeʳ′ → node (map-Tree f g treeˡ) (g b) treeʳ′) (lemma f g treeʳ) ⟩\n node (map-Tree f g treeˡ)\n (g b)\n (fold-Tree (λ a → leaf (f a)) (λ treeˡ b treeʳ → node treeˡ (g b) treeʳ) treeʳ)\n ≡⟨ cong (λ treeˡ′ → node treeˡ′\n (g b)\n (fold-Tree (λ a → leaf (f a)) (λ treeˡ b treeʳ → node treeˡ (g b) treeʳ) treeʳ))\n (lemma f g treeˡ) ⟩\n node (fold-Tree (λ a → leaf (f a)) (λ treeˡ b treeʳ → node treeˡ (g b) treeʳ) treeˡ)\n (g b)\n (fold-Tree (λ a → leaf (f a)) (λ treeˡ b treeʳ → node treeˡ (g b) treeʳ) treeʳ)\n ≡⟨⟩\n fold-Tree (λ a → leaf (f a)) (λ treeˡ b treeʳ → node treeˡ (g b) treeʳ) (node treeˡ b treeʳ)\n ∎\n\n-- Treeのmapが畳み込みで表現できることの証明\nmap-is-fold-Tree : ∀ {A B C D : Set} → (f : A → C) → (g : B → D)\n → map-Tree f g ≡ fold-Tree (λ a → leaf (f a)) (λ treeˡ b treeʳ → node treeˡ (g b) treeʳ)\nmap-is-fold-Tree f g = extensionality (lemma f g)\n", "meta": {"hexsha": "15647b4007f56f78d297c7005e3e04e581cbabdc", "size": 1853, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "part1/lists/map-is-fold-Tree.agda", "max_stars_repo_name": "akiomik/plfa-solutions", "max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z", "max_issues_repo_path": "part1/lists/map-is-fold-Tree.agda", "max_issues_repo_name": "akiomik/plfa-solutions", "max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "part1/lists/map-is-fold-Tree.agda", "max_forks_repo_name": "akiomik/plfa-solutions", "max_forks_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.6346153846, "max_line_length": 107, "alphanum_fraction": 0.5450620615, "num_tokens": 819, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8991213772699435, "lm_q2_score": 0.8652240964782011, "lm_q1q2_score": 0.7779414812726226}} {"text": "open import Peano using (ℕ; zero; succ; _+_; Rel)\n\nmodule Semigroup where\n\n infix 4 _≡_\n\n data _≡_ {a} {A : Set a} (x : A) : A → Set a where\n refl : x ≡ x\n\n record Semigroup {A : Set} (_◇_ : A → A → A) : Set where\n field\n associativity : ∀ x y z → (x ◇ y) ◇ z ≡ x ◇ (y ◇ z)\n\n record ℕ+-isSemigroup : Semigroup _+_ where\n field\n associativity : ∀ x y z → (x + y) + z ≡ x + (y + z)\n", "meta": {"hexsha": "c343313de40eb46c2bc1bdb3f989926a8f4ec5ed", "size": 403, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Semigroup.agda", "max_stars_repo_name": "cantsin/agda-experiments", "max_stars_repo_head_hexsha": "382fcfae193079783621fc5cf54b6588e22ef759", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Semigroup.agda", "max_issues_repo_name": "cantsin/agda-experiments", "max_issues_repo_head_hexsha": "382fcfae193079783621fc5cf54b6588e22ef759", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Semigroup.agda", "max_forks_repo_name": "cantsin/agda-experiments", "max_forks_repo_head_hexsha": "382fcfae193079783621fc5cf54b6588e22ef759", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.7058823529, "max_line_length": 58, "alphanum_fraction": 0.5260545906, "num_tokens": 164, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9626731158685838, "lm_q2_score": 0.8080672181749422, "lm_q1q2_score": 0.7779045867517304}} {"text": "{- Name: Bowornmet (Ben) Hudson and Theodore (Ted) Kim\n\n -- COMP360 Final Project: Group Theory in Agda --\n\nIn this project, we define some fundamental ideas of group theory and\nprove a few basic theorems about the topic using Agda. For example, we\ndefine what a group is, and give several elementary examples of groups.\nWe utilize the notion of propositional equality in Agda to prove our\ntheorems using equation chains.\n\n-}\n\nopen import Preliminaries\n\nmodule finalproject where\n\n -- addition of nats\n plusNat : Nat → Nat → Nat\n plusNat Z m = m\n plusNat (S n) m = S (plusNat n m)\n\n -- integers\n data Int : Set where\n _-_ : (n : Nat) → (m : Nat) → Int\n\n -- negation\n -_ : Int → Int\n - (n - m) = m - n\n \n -- addition of ints\n plusInt : Int → Int → Int\n plusInt (n1 - m1) (n2 - m2) = plusNat n1 n2 - plusNat m1 m2\n\n -- operation\n Op : Set → Set\n Op el = el → el → el\n\n -- record of Group\n {- Definition: a Group is a set G with a binary operation, *, with three properties:\n 1.) G has an identity element, e ∈ G, such that ∀ x ∈ G, e*x = x = x*e.\n 2.) ∀ x ∈ G, ∃ x' ∈ G such that x*x' = e = x'*x, where e is the identity element of G.\n 3.) G is associative. That is, ∀ x y z ∈ G, (x*y)*z = x*(y*z).\n -}\n record Group : Set1 where\n field\n el : Set\n _*_ : Op el\n e : el\n inv : el → el\n assoc : ∀ x y z → ((x * y) * z) == (x * (y * z))\n ident-l : ∀ x → (e * x) == x\n ident-r : ∀ x → (x * e) == x\n inv-l : ∀ x → ((inv x) * x) == e\n inv-r : ∀ x → (x * (inv x)) == e\n\n -- first example, Bools with \"multiplication\" operation. Comparable to Z mod 2\n -- with addition\n\n -- multiplication of bools\n multB : Bool → Bool → Bool\n multB True True = True\n multB True False = False\n multB False True = False\n multB False False = True\n\n -- associativity of bools\n assocB : ∀ (x y z : Bool) → multB (multB x y) z == multB x (multB y z)\n assocB True True True = Refl\n assocB True True False = Refl\n assocB True False True = Refl\n assocB True False False = Refl\n assocB False True True = Refl\n assocB False True False = Refl\n assocB False False True = Refl\n assocB False False False = Refl\n\n -- proof of identity\n multTruel : ∀ (x : Bool) → (multB True x == x)\n multTruel True = Refl\n multTruel False = Refl\n\n multTruer : ∀ (x : Bool) → (multB x True == x)\n multTruer True = Refl\n multTruer False = Refl\n\n -- inverses of bools\n invB : Bool → Bool\n invB True = True\n invB False = False\n\n -- proof of inverses with identity\n invBMultl : ∀ (x : Bool) → (multB (invB x) x == True)\n invBMultl True = Refl\n invBMultl False = Refl\n\n invBMultr : ∀ (x : Bool) → (multB x (invB x) == True)\n invBMultr True = Refl\n invBMultr False = Refl\n\n -- proof that the Booleans are a group on multiplication\n Bool*-isgroup : Group\n Bool*-isgroup = record {\n el = Bool;\n _*_ = multB;\n e = True;\n inv = invB;\n assoc = assocB;\n ident-l = multTruel;\n ident-r = multTruer;\n inv-l = invBMultl;\n inv-r = invBMultr }\n\n -- second example of a group, ints with the addition operation\n\n -- congruence\n congruenceNatInt : ∀ (a b c d : Nat) → a == c → b == d → a - b == c - d\n congruenceNatInt .c .d c d Refl Refl = Refl \n\n congruenceNat : ∀ (x y : Nat) → x == y → (S x) == (S y)\n congruenceNat .y y Refl = Refl\n\n congruenceNat' : ∀ (n m : Nat) → n == m → S n == S m\n congruenceNat' .m m Refl = Refl\n\n -- lemma\n addZNat : ∀ (x : Nat) → plusNat x Z == x\n addZNat Z = Refl\n addZNat (S x) = congruenceNat (plusNat x Z) x (addZNat x)\n\n -- proof of associativity\n assocNat+ : (x y z : Nat) → plusNat (plusNat x y) z == plusNat x (plusNat y z)\n assocNat+ Z y z = Refl\n assocNat+ (S x) y z = congruenceNat (plusNat (plusNat x y) z) (plusNat x (plusNat y z)) (assocNat+ x y z)\n\n assocInt+ : ∀ (a b c : Int) → plusInt (plusInt a b) c == plusInt a (plusInt b c)\n assocInt+ (n1 - m1) (n2 - m2) (n3 - m3) = congruenceNatInt (plusNat (plusNat n1 n2) n3)\n (plusNat (plusNat m1 m2) m3) (plusNat n1 (plusNat n2 n3))\n (plusNat m1 (plusNat m2 m3)) (assocNat+ n1 n2 n3) (assocNat+ m1 m2 m3) \n\n -- proof of identity\n addIntZl : ∀ (n : Int) → (plusInt (Z - Z) n == n)\n addIntZl (n - m) = Refl\n\n addIntZr : ∀ (n : Int) → (plusInt n (Z - Z) == n)\n addIntZr (n - m) = congruenceNatInt (plusNat n 0) (plusNat m 0) n m (addZNat n) (addZNat m)\n\n -- proof of inverses\n -- issue with quotient type: impossible to prove that (S n) - (S n) = 0 - 0 without equality constructor\n -- had problems in including the equality constructor, only thing we could not work out\n invIntl : ∀ (n : Int) → plusInt (- n) n == (Z - Z)\n invIntl (n - m) = {!!}\n\n invIntr : ∀ (n : Int) → plusInt n (- n) == (Z - Z)\n invIntr (n - m) = {!!}\n\n -- proof that the integers on addition are a group\n Int+-isgroup : Group\n Int+-isgroup = record {\n el = Int;\n _*_ = plusInt;\n e = Z - Z;\n inv = -_;\n assoc = assocInt+;\n ident-l = addIntZl;\n ident-r = addIntZr;\n inv-l = invIntl;\n inv-r = invIntr }\n\n {- Definition: an group is called abelian if it is commutative.\n That is, ∀ x y ∈ G, x*y = y*x. Our record of an abelian group\n requires a group and a proof that the group operation\n is commutative.\n -}\n record AbelianGroup (G : Group) : Set where\n open Group G\n field\n comm : ∀ (x y : el) → x * y == y * x\n\n -- proof of commutativity for multiplication on bools\n commB : ∀ (x y : Bool) → multB x y == multB y x\n commB True True = Refl\n commB True False = Refl\n commB False True = Refl\n commB False False = Refl\n\n Bool*-isAbelian : AbelianGroup Bool*-isgroup\n Bool*-isAbelian = record {\n comm = commB }\n\n -- some theorems\n module Theorems (G : Group) where\n open Group G\n congruenceOP : {a b c : el} → a == b → a * c == b * c\n congruenceOP Refl = Refl\n\n congruenceOP' : {a b c : el} → b == c → a * b == a * c\n congruenceOP' Refl = Refl\n\n sym : {a b : el} → a == b → b == a\n sym Refl = Refl\n\n -- extremely simple theorem\n babytheorem : (a b : el) → ((a * e) * b) == (a * b)\n babytheorem a b = congruenceOP (ident-r a)\n\n -- theorem 1: Let G be a group, and let a and b ∈ G. Then (a * b)^-1 = b^-1 * a^-1.\n theorem1 : ∀ (a b : el) → inv (a * b) == (inv b * inv a)\n theorem1 a b = inv (a * b) =⟨ sym (ident-r (inv (a * b))) ⟩\n (inv (a * b) * e) =⟨ sym (congruenceOP' (inv-r a)) ⟩ \n (inv (a * b) * (a * inv a)) =⟨ congruenceOP' (congruenceOP (sym (ident-r a))) ⟩\n (inv (a * b) * ((a * e) * inv a)) =⟨ congruenceOP' (congruenceOP (congruenceOP' (sym (inv-r b)))) ⟩\n (inv (a * b) * ((a * (b * inv b)) * inv a)) =⟨ congruenceOP' (congruenceOP (sym (assoc a b (inv b)))) ⟩\n (inv (a * b) * (((a * b) * inv b) * inv a)) =⟨ congruenceOP' (assoc (a * b) (inv b) (inv a)) ⟩\n (inv (a * b) * ((a * b) * (inv b * inv a))) =⟨ sym (assoc (inv (a * b)) (a * b) (inv b * inv a)) ⟩\n ((inv (a * b) * (a * b)) * (inv b * inv a)) =⟨ congruenceOP (inv-l (a * b)) ⟩\n (e * (inv b * inv a)) =⟨ ident-l (inv b * inv a) ⟩\n (inv b * inv a) ∎\n\n -- theorem 2: Let G be a group, and let a, b, and c ∈ G. If a * c = b * c, then a = b.\n theorem2 : ∀ (a b c : el) → (a * c) == (b * c) → a == b\n theorem2 a b c p = a =⟨ sym (ident-r a) ⟩\n a * e =⟨ congruenceOP' (sym (inv-r c)) ⟩\n (a * (c * inv c)) =⟨ sym (assoc a c (inv c)) ⟩\n (a * c) * inv c =⟨ congruenceOP p ⟩\n (b * c) * inv c =⟨ assoc b c (inv c) ⟩\n (b * (c * inv c)) =⟨ congruenceOP' (inv-r c) ⟩\n (b * e) =⟨ ident-r b ⟩\n b ∎\n\n -- theorem 3: Let G be a group, and let g ∈ G. If g * g = g, then g = e.\n theorem3 : ∀ (g : el) → (g * g) == g → g == e\n theorem3 g p = g =⟨ sym (ident-r g) ⟩\n (g * e) =⟨ congruenceOP' (sym (inv-r g)) ⟩\n (g * (g * inv g)) =⟨ sym (assoc g g (inv g)) ⟩\n (g * g) * inv g =⟨ congruenceOP p ⟩\n g * inv g =⟨ inv-r g ⟩\n e ∎\n\n -- lemma 1: for all x ∈ G, if x * x = e, x^-1 = x. That is, x is its own inverse.\n lemma1 : ∀ (x : el) → (p : x * x == e) → inv x == x\n lemma1 x p = (inv x) =⟨ sym (ident-r (inv x)) ⟩\n (inv x * e) =⟨ congruenceOP' (sym p) ⟩\n inv x * (x * x) =⟨ sym (assoc (inv x) x x) ⟩\n (inv x * x) * x =⟨ congruenceOP (inv-l x) ⟩\n (e * x) =⟨ ident-l x ⟩\n x ∎ \n\n -- theorem 4: let G be a group. If ∀ x ∈ G, x * x = e, then G is abelian.\n theorem4 : (p : ∀ x → (x * x) == e) → AbelianGroup G\n theorem4 p = record {\n comm = λ a b → a * b =⟨ congruenceOP (sym (ident-r a)) ⟩\n (a * e) * b =⟨ congruenceOP (congruenceOP' (sym (inv-r a))) ⟩\n (a * (a * inv a)) * b =⟨ congruenceOP (sym (assoc a a (inv a))) ⟩\n ((a * a) * inv a) * b =⟨ congruenceOP (congruenceOP (p a)) ⟩\n (e * inv a) * b =⟨ congruenceOP (ident-l (inv a)) ⟩\n inv a * b =⟨ congruenceOP' (sym (ident-r b)) ⟩\n inv a * (b * e) =⟨ congruenceOP' (congruenceOP' (sym (inv-r b))) ⟩\n inv a * (b * (b * inv b)) =⟨ congruenceOP' (sym (assoc b b (inv b))) ⟩ \n inv a * ((b * b) * inv b) =⟨ congruenceOP' (congruenceOP (p b)) ⟩\n inv a * (e * inv b) =⟨ congruenceOP' (ident-l (inv b)) ⟩\n (inv a * inv b) =⟨ sym (theorem1 b a) ⟩\n (inv (b * a)) =⟨ lemma1 (b * a) (p (b * a)) ⟩\n (b * a) ∎ }\n\n -- theorem 5: Let G be a group, and a, b, and c ∈ G. If (a * b) * c = e, then (b * c) * a = e as well.\n theorem5 : ∀ (a b c : el) → ((a * b) * c) == e → ((b * c) * a) == e \n theorem5 a b c p = ((b * c) * a) =⟨ sym (ident-l ((b * c) * a)) ⟩\n e * ((b * c) * a) =⟨ congruenceOP (sym (inv-l a)) ⟩\n (inv a * a) * ((b * c) * a) =⟨ assoc (inv a) a ((b * c) * a) ⟩\n inv a * (a * ((b * c) * a)) =⟨ sym (congruenceOP' (assoc a (b * c) a)) ⟩\n inv a * ((a * (b * c)) * a) =⟨ congruenceOP' (congruenceOP (sym (assoc a b c))) ⟩\n inv a * (((a * b) * c) * a) =⟨ congruenceOP' (congruenceOP p) ⟩\n inv a * (e * a) =⟨ congruenceOP' (ident-l a) ⟩\n (inv a * a) =⟨ inv-l a ⟩\n e ∎\n\n {- Definition: a homomorphism is a function f from a group (G , *) to another group (H , ∘)\n such that (∀ a,b ∈ G), f(a*b) = f(a)∘f(b). Our definition of a homomorphism also includes a\n proof that homomorphisms preserve identity elements between groups. That is, f(e_G) = e_H,\n where e_G and e_H are the identity elements in G and H, respectively.\n -}\n -- record of homomorphisms\n record Homomorphism (G : Group) (H : Group) : Set where\n open Group renaming (_*_ to *)\n field\n f : el G → el H\n preserve-id : f (e G) == e H\n preserve-op : ∀ (a b : el G) → (f (* G a b)) == * H (f a) (f b)\n\n -- third example of a group, Z mod 2 under addition.\n -- Z mod 2\n data Zmod2 : Set where\n Zero : Zmod2\n One : Zmod2\n\n -- addition mod 2\n plusmod2 : Zmod2 → Zmod2 → Zmod2\n plusmod2 Zero Zero = Zero\n plusmod2 Zero One = One\n plusmod2 One Zero = One\n plusmod2 One One = Zero\n\n -- identity of Z mod 2\n idenZmod2-l : (x : Zmod2) → plusmod2 Zero x == x\n idenZmod2-l Zero = Refl\n idenZmod2-l One = Refl\n\n idenZmod2-r : (x : Zmod2) → plusmod2 x Zero == x\n idenZmod2-r Zero = Refl\n idenZmod2-r One = Refl\n\n -- inverses of Z mod 2 (the inverse of anything in Z mod 2 is itself)\n invZmod2 : Zmod2 → Zmod2\n invZmod2 x = x\n\n -- left and right inverses of Z mod 2\n invZmod2-lr : (x : Zmod2) → plusmod2 x x == Zero\n invZmod2-lr Zero = Refl\n invZmod2-lr One = Refl\n\n -- associativity of addition in Z mod 2\n assocZmod2 : (x y z : Zmod2) → plusmod2 (plusmod2 x y) z == plusmod2 x (plusmod2 y z)\n assocZmod2 Zero Zero Zero = Refl\n assocZmod2 Zero Zero One = Refl\n assocZmod2 Zero One Zero = Refl\n assocZmod2 Zero One One = Refl\n assocZmod2 One Zero Zero = Refl\n assocZmod2 One Zero One = Refl\n assocZmod2 One One Zero = Refl\n assocZmod2 One One One = Refl\n\n -- commutativity of addition in Z mod 2\n commZmod2 : (x y : Zmod2) → plusmod2 x y == plusmod2 y x\n commZmod2 Zero Zero = Refl\n commZmod2 Zero One = Refl\n commZmod2 One Zero = Refl\n commZmod2 One One = Refl\n\n -- Zmod2 is a group on addition.\n Zmod2+-isgroup : Group\n Zmod2+-isgroup = record {\n el = Zmod2;\n _*_ = plusmod2;\n e = Zero;\n inv = invZmod2;\n assoc = assocZmod2;\n ident-l = idenZmod2-l;\n ident-r = idenZmod2-r;\n inv-l = λ x → invZmod2-lr x;\n inv-r = λ x → invZmod2-lr x }\n\n -- proof that Z mod 2 on addition is an abelian group.\n Zmod2+-isAbelian : AbelianGroup (Zmod2+-isgroup)\n Zmod2+-isAbelian = record {\n comm = commZmod2 }\n\n -- example of a homomorphism: mapBool-to-Zmod2 is a homomorphism from Bools on multiplication to Zmod2 with addition.\n -- map from Bools to the elements of Zmod2.\n mapBool-to-Zmod2 : Bool → Zmod2\n mapBool-to-Zmod2 True = Zero\n mapBool-to-Zmod2 False = One\n\n -- proof that the map from Bools to Zmod2 preserves composition.\n mapBool-to-Zmod2-preserve-op : (a b : Bool) → mapBool-to-Zmod2 (multB a b) == plusmod2 (mapBool-to-Zmod2 a) (mapBool-to-Zmod2 b)\n mapBool-to-Zmod2-preserve-op True True = Refl\n mapBool-to-Zmod2-preserve-op True False = Refl\n mapBool-to-Zmod2-preserve-op False True = Refl\n mapBool-to-Zmod2-preserve-op False False = Refl\n\n homomorphism-example : Homomorphism (Bool*-isgroup) (Zmod2+-isgroup)\n homomorphism-example = record {\n f = mapBool-to-Zmod2;\n preserve-id = Refl;\n preserve-op = mapBool-to-Zmod2-preserve-op }\n\n -- record of isomorphisms.\n {- Definition: a homomorphism between two groups is called an isomorphism\n if it is bijective (both one-to-one and onto). The isomorphism record\n requires a homomorphism along with proofs that it is both one-to-one\n (injective) and onto (surjective).\n -}\n record Isomorphism (G : Group) (H : Group) : Set where\n open Group\n open Homomorphism\n field\n homomorphism : Homomorphism G H\n injective : ∀ (a b : el G) → f homomorphism a == f homomorphism b → a == b\n surjective : ∀ (b : el H) → Σ (λ g → f homomorphism g == b)\n\n -- example of an isomorphism\n -- proof that this map from Bools to Zmod2 is injective (that is, ∀ a b : Bool, f(a) = f(b) implies a = b).\n mapB-Zmod2-inj : (a b : Bool) → mapBool-to-Zmod2 a == mapBool-to-Zmod2 b → a == b \n mapB-Zmod2-inj True True p = Refl\n mapB-Zmod2-inj True False ()\n mapB-Zmod2-inj False True ()\n mapB-Zmod2-inj False False p = Refl\n\n -- proof that this map from Bools to Zmod2 is surjective (that is, ∀ b : Zmod2, ∃ a ∈ Bool such that f(a) = b).\n mapB-Zmod2-sur : (n : Zmod2) → Σ (λ bool → mapBool-to-Zmod2 bool == n)\n mapB-Zmod2-sur Zero = True , Refl\n mapB-Zmod2-sur One = False , Refl\n\n -- the homomorphism between Bools on multiplication to Zmod2 with addition is isomorphic\n isomorphism-example : Isomorphism Bool*-isgroup Zmod2+-isgroup\n isomorphism-example = record { \n homomorphism = homomorphism-example;\n injective = mapB-Zmod2-inj;\n surjective = mapB-Zmod2-sur }\n", "meta": {"hexsha": "54b184bb6cc1ee372f89b936a8698a69d67072f4", "size": 17044, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "ug/finalproject.agda", "max_stars_repo_name": "benhuds/Agda", "max_stars_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2016-04-26T20:22:22.000Z", "max_stars_repo_stars_event_max_datetime": "2019-08-08T12:27:18.000Z", "max_issues_repo_path": "ug/finalproject.agda", "max_issues_repo_name": "benhuds/Agda", "max_issues_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-03-23T08:39:04.000Z", "max_issues_repo_issues_event_max_datetime": "2020-05-12T00:32:45.000Z", "max_forks_repo_path": "ug/finalproject.agda", "max_forks_repo_name": "benhuds/Agda", "max_forks_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.6723716381, "max_line_length": 133, "alphanum_fraction": 0.4983571931, "num_tokens": 5672, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9263037221561135, "lm_q2_score": 0.8397339616560073, "lm_q1q2_score": 0.7778486943028586}} {"text": "{-# OPTIONS --without-K #-}\n\nmodule hott.types.nat where\n\nopen import hott.core.universe\nopen import hott.core.equality\nopen import hott.functions\n\ndata ℕ : Type₀ where\n zero : ℕ\n succ : ℕ → ℕ\n\n{-# BUILTIN NATURAL ℕ #-}\n\n-- Addition.\n_+_ : ℕ → ℕ → ℕ\n0 + y = y\nsucc x + y = succ (x + y)\n\n-- Multiplication\n_*_ : ℕ → ℕ → ℕ\nzero * y = zero\nsucc x * y = y + (x * y)\n\n-- The interated fucntion\niterate : ∀{ℓ} {A : Type ℓ} → (A → A) → ℕ → A → A\niterate _ zero = id\niterate f (succ n) = f ∘ iterate f n\n", "meta": {"hexsha": "b671dcb00184b0846b9078718d8000a1da9b4bd4", "size": 515, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/hott/types/nat.agda", "max_stars_repo_name": "piyush-kurur/hott", "max_stars_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "agda/hott/types/nat.agda", "max_issues_repo_name": "piyush-kurur/hott", "max_issues_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/hott/types/nat.agda", "max_forks_repo_name": "piyush-kurur/hott", "max_forks_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 17.7586206897, "max_line_length": 49, "alphanum_fraction": 0.572815534, "num_tokens": 180, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9648551495568569, "lm_q2_score": 0.8056321889812553, "lm_q1q2_score": 0.7773183661873271}} {"text": "open import Functional using (id)\nimport Structure.Logic.Constructive.NaturalDeduction\n\nmodule Structure.Logic.Constructive.Functions.Properties {ℓₗ} {Formula} {ℓₘₗ} {Proof} {ℓₒ} {Domain} ⦃ constructiveLogicSign : _ ⦄ where\nopen Structure.Logic.Constructive.NaturalDeduction.ConstructiveLogicSignature {ℓₗ} {Formula} {ℓₘₗ} {Proof} {ℓₒ} {Domain} (constructiveLogicSign)\n\nopen import Structure.Logic.Constructive.Functions(Domain)\nopen import Syntax.Function\n\n-- States whether the function f is defined on the element x.\n-- Whether f(x) yields/returns an element in the domain.\n-- In other words: Whether the logic can interpret f(x) as anything meaningful.\nDefined : Function → Domain → Formula\nDefined f(x) = ∃ₗ(y ↦ f(x) ≡ y)\n\n-- States whether the function f can yield/return the element y.\nValue : Function → Domain → Formula\nValue f(y) = ∃ₗ(x ↦ f(x) ≡ y)\n\nInjective : Function → Formula\nInjective(f) = ∀ₗ(x ↦ ∀ₗ(y ↦ (f(x) ≡ f(y)) ⟶ (x ≡ y)))\n\nSurjective : Function → Formula\nSurjective(f) = ∀ₗ(y ↦ ∃ₗ(x ↦ f(x) ≡ y))\n\nBijective : Function → Formula\nBijective(f) =\n Injective(f)\n ∧ Surjective(f)\n\nPreserving₁ : Function → Function → Function → Formula\nPreserving₁(f)(g₁)(g₂) = ∀ₗ(x ↦ f(g₁(x)) ≡ g₂(f(x)))\n\nPreserving₂ : Function → BinaryOperator → BinaryOperator → Formula\nPreserving₂(f)(_▫₁_)(_▫₂_) = ∀ₗ(x ↦ ∀ₗ(y ↦ f(x ▫₁ y) ≡ (f(x) ▫₂ f(y))))\n\nFixpoint : Function → Domain → Formula\nFixpoint f(x) = (f(x) ≡ x)\n", "meta": {"hexsha": "723453903abf619871362a5f4c4cc7e30307f62a", "size": 1421, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "old/Structure/Logic/Constructive/Functions/Properties.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "old/Structure/Logic/Constructive/Functions/Properties.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "old/Structure/Logic/Constructive/Functions/Properties.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.4358974359, "max_line_length": 144, "alphanum_fraction": 0.6952850106, "num_tokens": 472, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.953275045356249, "lm_q2_score": 0.815232489352, "lm_q1q2_score": 0.7771407882629155}} {"text": "module Rev {A : Set} where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl; sym; trans; cong; cong₂; _≢_)\nopen Eq.≡-Reasoning\nopen import Data.Empty using (⊥; ⊥-elim)\nopen import Data.List\n using (List; []; _∷_; _++_; map; foldr; replicate; length; _∷ʳ_)\n -- renaming (reverse to rev)\nopen import Data.List.Properties\n using (++-assoc; ++-identityʳ)\n -- renaming (unfold-reverse to revʳ;\n -- reverse-++-commute to rev-++;\n -- reverse-involutive to rev-inv)\nopen import Data.List.All using (All; []; _∷_)\nopen import Data.List.All.Properties\n renaming (++⁺ to _++All_)\n\npattern [_] x = x ∷ []\npattern [_,_] x y = x ∷ y ∷ []\npattern [_,_,_] x y z = x ∷ y ∷ z ∷ []\npattern [_,_,_,_] x y z w = x ∷ y ∷ z ∷ w ∷ []\n\nrev : List A → List A\nrev [] = []\nrev (x ∷ xs) = rev xs ++ [ x ]\n\nrev-++ : ∀ xs ys → rev (xs ++ ys) ≡ rev ys ++ rev xs\nrev-++ [] ys =\n begin\n rev ([] ++ ys)\n ≡⟨ sym (++-identityʳ (rev ys)) ⟩\n rev ys ++ rev []\n ∎\nrev-++ (x ∷ xs) ys =\n begin\n rev (x ∷ xs ++ ys)\n ≡⟨⟩\n rev (xs ++ ys) ++ [ x ]\n ≡⟨ cong (_++ [ x ]) (rev-++ xs ys) ⟩\n (rev ys ++ rev xs) ++ [ x ]\n ≡⟨ ++-assoc (rev ys) (rev xs) [ x ] ⟩\n rev ys ++ (rev xs ++ [ x ])\n ≡⟨⟩\n rev ys ++ (rev (x ∷ xs))\n ∎\n\nrev-inv : ∀ xs → rev (rev xs) ≡ xs\nrev-inv [] =\n begin\n rev (rev [])\n ≡⟨⟩\n []\n ∎\nrev-inv (x ∷ xs) =\n begin\n rev (rev (x ∷ xs))\n ≡⟨⟩\n rev (rev xs ++ [ x ])\n ≡⟨ rev-++ (rev xs) [ x ] ⟩\n rev [ x ] ++ rev (rev xs)\n ≡⟨ cong (rev [ x ] ++_) (rev-inv xs) ⟩\n rev [ x ] ++ xs\n ≡⟨⟩\n x ∷ xs\n ∎\n\nrevAll : ∀ (P : A → Set) → ∀ {xs} → All P xs → All P (rev xs)\nrevAll P [] = []\nrevAll P (Px ∷ Pxs) = revAll P Pxs ++All [ Px ]\n\n", "meta": {"hexsha": "88889804fd26968edf5fceff5868ce9007391d8f", "size": 1733, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "extra/extra/Rev.agda", "max_stars_repo_name": "manikdv/plfa.github.io", "max_stars_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1003, "max_stars_repo_stars_event_min_datetime": "2018-07-05T18:15:14.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-27T07:03:28.000Z", "max_issues_repo_path": "extra/extra/Rev.agda", "max_issues_repo_name": "manikdv/plfa.github.io", "max_issues_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 323, "max_issues_repo_issues_event_min_datetime": "2018-07-05T22:34:34.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-30T07:42:57.000Z", "max_forks_repo_path": "extra/extra/Rev.agda", "max_forks_repo_name": "manikdv/plfa.github.io", "max_forks_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 304, "max_forks_repo_forks_event_min_datetime": "2018-07-16T18:24:59.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-28T11:35:02.000Z", "avg_line_length": 24.0694444444, "max_line_length": 66, "alphanum_fraction": 0.4795152914, "num_tokens": 701, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8774767874818408, "lm_q2_score": 0.8856314723088733, "lm_q1q2_score": 0.777121059214403}} {"text": "module plfa-code.Induction where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl; cong; sym)\nopen Eq.≡-Reasoning using (begin_; _≡⟨⟩_)\nopen import Data.Nat using (ℕ; zero; suc; _+_; _*_; _∸_)\nopen import Function\n\nopen import plfa-code.Reasoning-legacy \n\n_ : (3 + 4) + 5 ≡ 3 + (4 + 5)\n_ =\n begin\n (3 + 4) + 5\n ≡⟨⟩\n 7 + 5\n ≡⟨⟩\n 12\n ≡⟨⟩\n 3 + 9\n ≡⟨⟩\n 3 + (4 + 5)\n ∎\n\n+-assoc : ∀ (m n p : ℕ) → (m + n) + p ≡ m + (n + p)\n+-assoc zero n p =\n begin\n (zero + n) + p\n ≡⟨⟩\n n + p\n ≡⟨⟩\n zero + (n + p)\n ∎\n+-assoc (suc m) n p =\n begin\n (suc m + n) + p\n ≡⟨⟩\n suc (m + n) + p\n ≡⟨⟩\n suc ((m + n) + p)\n ≡⟨ cong suc (+-assoc m n p) ⟩\n suc (m + (n + p))\n ≡⟨⟩\n suc m + (n + p)\n ∎\n\n+-identityʳ : ∀ (m : ℕ) → m + zero ≡ m\n+-identityʳ zero =\n begin\n zero + zero\n ≡⟨⟩\n zero\n ∎\n+-identityʳ (suc m) =\n begin\n suc m + zero\n ≡⟨⟩\n suc (m + zero)\n ≡⟨ cong suc (+-identityʳ m)⟩\n suc m\n ∎\n\n+-suc : ∀ (m n : ℕ) → m + suc n ≡ suc (m + n)\n+-suc zero n =\n begin\n zero + suc n\n ≡⟨⟩\n suc n\n ≡⟨⟩\n suc (zero + n)\n ∎\n+-suc (suc m) n =\n begin\n suc m + suc n\n ≡⟨⟩\n suc (m + suc n)\n ≡⟨ cong suc (+-suc m n) ⟩\n suc (suc (m + n))\n ≡⟨⟩\n suc (suc m + n)\n ∎\n\n+-comm : ∀ (m n : ℕ) → m + n ≡ n + m\n+-comm zero n =\n begin\n zero + n\n ≡⟨⟩\n n\n ≡⟨ sym (+-identityʳ n) ⟩\n n + zero\n ∎\n+-comm (suc m) n =\n begin\n suc m + n\n ≡⟨⟩\n suc (m + n)\n ≡⟨ cong suc (+-comm m n) ⟩\n suc (n + m)\n ≡⟨ sym (+-suc n m) ⟩\n n + suc m\n ∎\n\n+-rearrange : ∀ (m n p q : ℕ) → (m + n) + (p + q) ≡ m + (n + p) + q\n+-rearrange m n p q =\n begin\n (m + n) + (p + q)\n ≡⟨ +-assoc m n (p + q) ⟩\n m + (n + (p + q))\n ≡⟨ cong (m +_) (sym (+-assoc n p q)) ⟩\n m + ((n + p) + q)\n ≡⟨ sym (+-assoc m (n + p) q) ⟩\n (m + (n + p)) + q\n ∎\n\n+-assoc′ : ∀ (m n p : ℕ) → (m + n) + p ≡ m + (n + p) \n+-assoc′ zero n p = refl\n+-assoc′ (suc m) n p rewrite +-assoc′ m n p = refl\n\n\n-- practice\n\n+-swap : ∀ (m n p : ℕ) → m + (n + p) ≡ n + (m + p)\n+-swap m zero p = refl\n+-swap m (suc n) p\n rewrite +-suc m (n + p)\n | sym (+-assoc m n p)\n | +-comm m n\n | +-assoc n m p = refl\n\n*-distrib-+ : ∀ (m n p : ℕ) → (m + n) * p ≡ m * p + n * p\n*-distrib-+ zero n p = refl\n*-distrib-+ (suc m) n p rewrite *-distrib-+ m n p\n | sym (+-assoc p (m * p) (n * p)) = refl\n\n*-assoc : ∀ (m n p : ℕ) → (m * n) * p ≡ m * (n * p)\n*-assoc zero n p = refl\n*-assoc (suc m) n p rewrite *-distrib-+ n (m * n) p | *-assoc m n p = refl\n\n*-zeroʳ : ∀ (n : ℕ) → n * zero ≡ zero\n*-zeroʳ zero = refl\n*-zeroʳ (suc n) rewrite *-zeroʳ n = refl\n\n*-suc : ∀ (m n : ℕ) → m * suc n ≡ m * n + m\n*-suc zero n = refl\n*-suc (suc m) n =\n begin\n (suc m) * (suc n)\n ≡⟨⟩\n (suc n) + m * (suc n)\n ≡⟨ cong ((suc n) +_) (*-suc m n) ⟩\n suc n + (m * n + m)\n ≡⟨ +-swap (suc n) (m * n) m ⟩\n m * n + (suc n + m)\n ≡⟨ cong ((m * n) +_) (sym (+-suc n m)) ⟩\n m * n + (n + suc m)\n ≡⟨ sym (+-assoc (m * n) n (suc m)) ⟩\n m * n + n + suc m\n ≡⟨ cong (_+ (suc m)) (+-comm (m * n) n) ⟩\n (suc m) * n + (suc m)\n ∎\n\n*-comm : ∀ (m n : ℕ) → m * n ≡ n * m\n*-comm zero n rewrite *-zeroʳ n = refl\n*-comm (suc m) n =\n begin\n suc m * n\n ≡⟨⟩\n n + m * n\n ≡⟨ +-comm n (m * n) ⟩\n m * n + n\n ≡⟨ cong (_+ n) (*-comm m n) ⟩\n n * m + n\n ≡⟨ sym (*-suc n m) ⟩\n n * suc m\n ∎\n\nz∸n≡z : ∀ (n : ℕ) → zero ∸ n ≡ zero\nz∸n≡z zero = refl\nz∸n≡z (suc n) = refl\n\n∸-+-assoc : ∀ (m n p : ℕ) → m ∸ n ∸ p ≡ m ∸ (n + p)\n∸-+-assoc zero n p rewrite z∸n≡z n | z∸n≡z p | z∸n≡z (n + p) = refl\n∸-+-assoc (suc m) zero p = refl\n∸-+-assoc (suc m) (suc n) p rewrite ∸-+-assoc m n p = refl\n\n---------- Bin ----------\ndata Bin : Set where\n nil : Bin\n x0_ : Bin → Bin\n x1_ : Bin → Bin\n\ninc : Bin → Bin\ninc nil = x1 nil\ninc (x0 t) = x1 t\ninc (x1 t) = x0 (inc t)\n\nto : ℕ → Bin\nto zero = x0 nil\nto (suc n) = inc (to n)\n\nfrom : Bin → ℕ\nfrom nil = 0\nfrom (x0 t) = 2 * (from t)\nfrom (x1 t) = suc (2 * (from t))\n--------------------------------------\n\n+1≡suc : ∀ {n : ℕ} → n + 1 ≡ suc n\n+1≡suc {zero} = refl\n+1≡suc {suc n} = cong suc +1≡suc\n\nsuc-from-inc : ∀ (x : Bin) → from (inc x) ≡ suc (from x)\nsuc-from-inc nil = refl\nsuc-from-inc (x0 x) rewrite +1≡suc {from x * 2} = refl\nsuc-from-inc (x1 x) rewrite suc-from-inc x | +-suc (from x) (from x + 0) = refl\n\n-- t4 is ⊥ , because `to (from nil) ≡ x0 nil ≢ nil`\n-- t4 : ∀ (x : Bin) → to (from x) ≡ x\n\nfrom-to-const : ∀ (n : ℕ) → from (to n) ≡ n\nfrom-to-const zero = refl\nfrom-to-const (suc n) rewrite suc-from-inc (to n) | from-to-const n = refl\n", "meta": {"hexsha": "65e24d368b6d4c2688b807a97795e7974621f5e7", "size": 4670, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/plfa-code/Induction.agda", "max_stars_repo_name": "chirsz-ever/plfa-code", "max_stars_repo_head_hexsha": "ec5b359a8c22bf5268cae3c36a97e6737c75d5f3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/plfa-code/Induction.agda", "max_issues_repo_name": "chirsz-ever/plfa-code", "max_issues_repo_head_hexsha": "ec5b359a8c22bf5268cae3c36a97e6737c75d5f3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/plfa-code/Induction.agda", "max_forks_repo_name": "chirsz-ever/plfa-code", "max_forks_repo_head_hexsha": "ec5b359a8c22bf5268cae3c36a97e6737c75d5f3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.036036036, "max_line_length": 79, "alphanum_fraction": 0.4209850107, "num_tokens": 2235, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.918480237330998, "lm_q2_score": 0.8459424353665382, "lm_q1q2_score": 0.7769814088038205}} {"text": "\nmodule Data.Nat where\n\nimport Prelude\nimport Data.Bool as Bool\n\nopen Prelude\nopen Bool\n\ndata Nat : Set where\n zero : Nat\n suc : Nat -> Nat\n\n{-# BUILTIN NATURAL Nat #-}\n{-# BUILTIN SUC suc #-}\n{-# BUILTIN ZERO zero #-}\n\ninfix 40 _==_ _<_ _≤_ _>_ _≥_\ninfixl 60 _+_ _-_\ninfixl 70 _*_\ninfixr 80 _^_\ninfix 100 _!\n\n_+_ : Nat -> Nat -> Nat\nzero + m = m\nsuc n + m = suc (n + m)\n\n_-_ : Nat -> Nat -> Nat\nzero - m = zero\nsuc n - zero = suc n\nsuc n - suc m = n - m\n\n_*_ : Nat -> Nat -> Nat\nzero * m = zero\nsuc n * m = m + n * m\n\n_^_ : Nat -> Nat -> Nat\nn ^ zero = 1\nn ^ suc m = n * n ^ m\n\n_! : Nat -> Nat\nzero ! = 1\nsuc n ! = suc n * n !\n\n{-# BUILTIN NATPLUS _+_ #-}\n{-# BUILTIN NATMINUS _-_ #-}\n{-# BUILTIN NATTIMES _*_ #-}\n\n_==_ : Nat -> Nat -> Bool\nzero == zero = true\nzero == suc _ = false\nsuc _ == zero = false\nsuc n == suc m = n == m\n\n_<_ : Nat -> Nat -> Bool\nn < zero = false\nzero < suc m = true\nsuc n < suc m = n < m\n\n_≤_ : Nat -> Nat -> Bool\nn ≤ m = n < suc m\n\n_>_ = flip _<_\n_≥_ = flip _≤_\n\n{-# BUILTIN NATEQUALS _==_ #-}\n{-# BUILTIN NATLESS _<_ #-}\n\ndivSuc : Nat -> Nat -> Nat\ndivSuc zero _ = zero\ndivSuc (suc n) m = 1 + divSuc (n - m) m\n\nmodSuc : Nat -> Nat -> Nat\nmodSuc zero _ = zero\nmodSuc (suc n) m =\n ! n ≤ m => suc n\n ! otherwise modSuc (n - m) m\n\n{-# BUILTIN NATDIVSUC divSuc #-}\n-- {-# BUILTIN NATMODSUC modSuc #-}\n\ndiv : Nat -> Nat -> Nat\ndiv n zero = zero\ndiv n (suc m) = divSuc n m\n\nmod : Nat -> Nat -> Nat\nmod n zero = zero\nmod n (suc m) = modSuc n m\n\ngcd : Nat -> Nat -> Nat\ngcd a 0 = a\ngcd a b = gcd b (mod a b)\n\nlcm : Nat -> Nat -> Nat\nlcm a b = div (a * b) (gcd a b)\n\neven : Nat -> Bool\neven n = mod n 2 == 0\n\nodd : Nat -> Bool\nodd n = mod n 2 == 1\n\n", "meta": {"hexsha": "4e920f84871f3e8832a094fb38fd3045fb1ce2bc", "size": 1709, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Nat.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Nat.agda", "max_issues_repo_name": "np/agda-git-experiment", "max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Nat.agda", "max_forks_repo_name": "np/agda-git-experiment", "max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 16.5922330097, "max_line_length": 39, "alphanum_fraction": 0.5330602692, "num_tokens": 676, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9252299570920387, "lm_q2_score": 0.8397339716830606, "lm_q1q2_score": 0.7769470265890455}} {"text": "module PlfaInduction where\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_ ; refl ; cong ; sym)\nopen Eq.≡-Reasoning using (begin_ ; _≡⟨⟩_ ; _≡⟨_⟩_ ; _∎ )\nopen import Data.Nat using (ℕ ; zero ; suc ; _+_ ; _*_ ; _^_ )\n\n+-assoc : ∀ (a b c : ℕ) → (a + b) + c ≡ a + (b + c)\n+-assoc zero b c =\n begin\n (zero + b) + c\n ≡⟨⟩\n b + c\n ≡⟨⟩\n zero + (b + c)\n ∎\n\n+-assoc (suc a) b c =\n begin\n (suc a + b) + c \n ≡⟨⟩\n suc (a + b) + c \n ≡⟨⟩\n suc ((a + b) + c) \n ≡⟨ cong suc (+-assoc a b c) ⟩ \n suc (a + (b + c)) \n ≡⟨⟩\n suc a + (b + c)\n ∎\n\n+-identityʳ : ∀ (a : ℕ) → a + zero ≡ a\n+-identityʳ zero =\n begin\n zero + zero\n ≡⟨⟩\n zero\n ∎\n\n+-identityʳ (suc a) =\n begin\n suc a + zero\n ≡⟨⟩\n suc (a + zero)\n ≡⟨ cong suc (+-identityʳ a) ⟩\n suc a\n ∎\n\n+-suc : ∀ (a b : ℕ) → a + suc b ≡ suc (a + b)\n+-suc zero b =\n begin\n zero + suc b\n ≡⟨⟩\n suc b\n ≡⟨⟩\n suc (zero + b) \n ∎\n\n+-suc (suc a) b =\n begin\n suc a + suc b\n ≡⟨⟩\n suc (a + suc b) \n ≡⟨ cong suc (+-suc a b) ⟩\n suc (suc a + b)\n ∎\n\n+-comm : ∀ (a b : ℕ) → a + b ≡ b + a\n+-comm zero b =\n begin\n zero + b\n ≡⟨⟩\n b\n ≡⟨ sym (+-identityʳ b) ⟩\n b + zero\n ∎\n \n+-comm (suc a) b =\n begin\n suc a + b\n ≡⟨⟩\n suc (a + b)\n ≡⟨ cong suc (+-comm a b) ⟩\n suc (b + a)\n ≡⟨ sym (+-suc b a) ⟩\n b + suc a\n ∎\n\n+-rearrange : ∀ (a b c d : ℕ) → (a + b) + (c + d) ≡ (a + (b + c)) + d\n+-rearrange a b c d =\n begin\n -- Because addition associates to the left\n -- a + b + (c + d)\n -- is the same as\n (a + b) + (c + d)\n ≡⟨ +-assoc a b (c + d) ⟩\n a + (b + (c + d))\n -- Lesson: The + and the _ in in (a +_) MUST be next to each other (no spaces allowed)\n ≡⟨ cong (a +_) (sym (+-assoc b c d)) ⟩\n a + ((b + c) + d)\n ≡⟨ sym (+-assoc a (b + c) d) ⟩\n (a + (b + c)) + d\n ∎ \n\n-- Let's do it again, now using the rewrite magic\n--+-assoc' : ∀ (a b c : ℕ) → a + b + c ≡ a + (b + c)\n--+-assoc' zero b c = refl\n--+-assoc' (suc a) b c rewrite +-assoc' a b c = refl\n\n--+-suc' : ∀ (a b : ℕ) → a + suc b ≡ suc (a + b)\n--+-suc' zero b = refl\n--+-suc' (suc a) b rewrite +-suc' a b = refl\n\n+-swap : ∀ (a b c : ℕ) → a + (b + c) ≡ b + (a + c)\n+-swap a b c rewrite sym (+-assoc a b c) | +-comm a b | +-assoc b a c = refl \n\n*-zero : ∀ (a : ℕ) → a * zero ≡ zero \n*-zero zero = refl\n*-zero (suc a) rewrite *-zero a = refl\n\n*-rsucdist : ∀ (n m : ℕ) → n * suc m ≡ n + n * m\n*-rsucdist zero m = refl\n*-rsucdist (suc n) m rewrite *-rsucdist n m | +-swap m n (n * m) = refl\n\n*-distrib : ∀ (x b c : ℕ) → (b + c) * x ≡ b * x + c * x \n*-distrib zero b c rewrite *-zero (b + c) | *-zero b | *-zero c = refl\n*-distrib (suc x) b c rewrite *-rsucdist (b + c) x\n | *-distrib x b c\n | +-rearrange b c (b * x) (c * x)\n | +-comm c (b * x)\n | sym (+-rearrange b (b * x) c (c * x) )\n | sym (*-rsucdist b x)\n | sym (*-rsucdist c x) = refl\n\n*-assoc : ∀ (a b c : ℕ) → (a * b) * c ≡ a * (b * c) \n*-assoc zero b c = refl\n*-assoc (suc a) b c =\n begin\n (suc a * b) * c\n ≡⟨⟩\n (b + a * b) * c\n ≡⟨ *-distrib c b (a * b) ⟩\n b * c + (a * b) * c\n ≡⟨ cong (λ { x → b * c + x }) (*-assoc a b c) ⟩\n suc a * (b * c)\n ∎\n\n*-comm : ∀ (a b : ℕ) → a * b ≡ b * a\n*-comm zero b rewrite *-zero b = refl\n*-comm (suc a) b rewrite *-comm a b | sym (*-rsucdist b a) = refl\n\ninfixl 6 _∸_\n_∸_ : ℕ → ℕ → ℕ\nm ∸ zero = m\nzero ∸ (suc n) = zero\n(suc m) ∸ (suc n) = m ∸ n\n\n∸-zero : ∀ (a : ℕ) → zero ∸ a ≡ zero\n∸-zero zero = refl\n∸-zero (suc a) = refl\n\n∸-suc : ∀ (a b : ℕ) → a ∸ suc b ≡ a ∸ 1 ∸ b\n∸-suc zero b rewrite ∸-zero b = refl\n∸-suc (suc a) b = refl\n\n-- ∸-+-assoc : ∀ (a b c : ℕ) → a ∸ b ∸ c ≡ a ∸ (b + c)\n-- ∸-+-assoc a zero c = refl\n-- ∸-+-assoc a (suc b) c =\n-- begin\n-- a ∸ suc b ∸ c \n-- ≡⟨ cong (λ x → x ∸ c) (∸-suc a b) ⟩\n-- a ∸ 1 ∸ b ∸ c -- Remember this is equal to ((a ∸ 1) ∸ b) ∸ c \n-- ≡⟨ ∸-+-assoc ⟩\n-- ≡⟨ ∸-suc a (b + c) ⟩\n-- a ∸ (b + c) \n-- ∎\n", "meta": {"hexsha": "48629a8b183f20bd62ffef34842eeaeaa10bb4b2", "size": 4031, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "PlfaInduction.agda", "max_stars_repo_name": "GustavoMF31/upgraded-happiness", "max_stars_repo_head_hexsha": "9f81052c4c872f0e19677bf6e9710350d3acf0e5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "PlfaInduction.agda", "max_issues_repo_name": "GustavoMF31/upgraded-happiness", "max_issues_repo_head_hexsha": "9f81052c4c872f0e19677bf6e9710350d3acf0e5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "PlfaInduction.agda", "max_forks_repo_name": "GustavoMF31/upgraded-happiness", "max_forks_repo_head_hexsha": "9f81052c4c872f0e19677bf6e9710350d3acf0e5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.0342857143, "max_line_length": 88, "alphanum_fraction": 0.4177623419, "num_tokens": 1881, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9252299509069105, "lm_q2_score": 0.8397339736884712, "lm_q1q2_score": 0.7769470232506491}} {"text": "{-\n\nBased on Nicolai Kraus' blog post:\n The Truncation Map |_| : ℕ -> ‖ℕ‖ is nearly Invertible\n https://homotopytypetheory.org/2013/10/28/the-truncation-map-_-ℕ-‖ℕ‖-is-nearly-invertible/\n\nDefines [recover], which definitionally satisfies `recover ∣ x ∣ ≡ x` ([recover∣∣]) for homogeneous types\n\nAlso see the follow-up post by Jason Gross:\n Composition is not what you think it is! Why “nearly invertible” isn’t.\n https://homotopytypetheory.org/2014/02/24/composition-is-not-what-you-think-it-is-why-nearly-invertible-isnt/\n\n-}\n{-# OPTIONS --cubical --safe #-}\n\nmodule Cubical.HITs.PropositionalTruncation.MagicTrick where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Function\nopen import Cubical.Foundations.Path\nopen import Cubical.Foundations.Pointed\nopen import Cubical.Foundations.Pointed.Homogeneous\n\nopen import Cubical.HITs.PropositionalTruncation.Base\nopen import Cubical.HITs.PropositionalTruncation.Properties\n\nmodule Recover {ℓ} (A∙ : Pointed ℓ) (h : isHomogeneous A∙) where\n private\n A = typ A∙\n a = pt A∙\n\n toEquivPtd : ∥ A ∥ → Σ[ B∙ ∈ Pointed ℓ ] (A , a) ≡ B∙\n toEquivPtd = recPropTrunc (isContr→isProp (_ , λ p → contrSingl (snd p)))\n (λ x → (A , x) , h x)\n private\n B∙ : ∥ A ∥ → Pointed ℓ\n B∙ tx = fst (toEquivPtd tx)\n\n -- the key observation is that B∙ ∣ x ∣ is definitionally equal to (A , x)\n private\n obvs : ∀ x → B∙ ∣ x ∣ ≡ (A , x)\n obvs x = refl -- try it: `C-c C-n B∙ ∣ x ∣` gives `(A , x)`\n\n -- thus any truncated element (of a homogeneous type) can be recovered by agda's normalizer!\n\n recover : ∀ (tx : ∥ A ∥) → typ (B∙ tx)\n recover tx = pt (B∙ tx)\n\n recover∣∣ : ∀ (x : A) → recover ∣ x ∣ ≡ x\n recover∣∣ x = refl -- try it: `C-c C-n recover ∣ x ∣` gives `x`\n\n private\n -- notice that the following typechecks because typ (B∙ ∣ x ∣) is definitionally equal to to A, but\n -- `recover : ∥ A ∥ → A` does not because typ (B∙ tx) is not definitionally equal to A (though it is\n -- judegmentally equal to A by cong typ (snd (toEquivPtd tx)) : A ≡ typ (B∙ tx))\n obvs2 : A → A\n obvs2 = recover ∘ ∣_∣\n\n -- one might wonder if (cong recover (squash ∣ x ∣ ∣ y ∣)) therefore has type x ≡ y, but thankfully\n -- typ (B∙ (squash ∣ x ∣ ∣ y ∣ i)) is *not* A (it's a messy hcomp involving h x and h y)\n recover-squash : ∀ x y → -- x ≡ y -- this raises an error\n PathP (λ i → typ (B∙ (squash ∣ x ∣ ∣ y ∣ i))) x y\n recover-squash x y = cong recover (squash ∣ x ∣ ∣ y ∣)\n\n\n-- Demo, adapted from:\n-- https://bitbucket.org/nicolaikraus/agda/src/e30d70c72c6af8e62b72eefabcc57623dd921f04/trunc-inverse.lagda\n\nprivate\n open import Cubical.Data.Nat\n open Recover (ℕ , zero) (isHomogeneousDiscrete discreteℕ)\n\n -- only `∣hidden∣` is exported, `hidden` is no longer in scope\n module _ where\n private\n hidden : ℕ\n hidden = 17\n\n ∣hidden∣ : ∥ ℕ ∥\n ∣hidden∣ = ∣ hidden ∣\n\n -- we can still recover the value, even though agda can no longer see `hidden`!\n test : recover ∣hidden∣ ≡ 17\n test = refl -- try it: `C-c C-n recover ∣hidden∣` gives `17`\n -- `C-c C-n hidden` gives an error\n\n -- Finally, note that the definition of recover is independent of the proof that A is homogeneous. Thus we\n -- still can definitionally recover information hidden by ∣_∣ as long as we permit holes. Try replacing\n -- `isHomogeneousDiscrete discreteℕ` above with a hole (`?`) and notice that everything still works\n", "meta": {"hexsha": "00be68b228efcd0621cf689ccc82bb2f2b18c3d3", "size": 3487, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/HITs/PropositionalTruncation/MagicTrick.agda", "max_stars_repo_name": "oisdk/cubical", "max_stars_repo_head_hexsha": "a01973ef7264f9454a40697313a2073c51a6b77a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/HITs/PropositionalTruncation/MagicTrick.agda", "max_issues_repo_name": "oisdk/cubical", "max_issues_repo_head_hexsha": "a01973ef7264f9454a40697313a2073c51a6b77a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/HITs/PropositionalTruncation/MagicTrick.agda", "max_forks_repo_name": "oisdk/cubical", "max_forks_repo_head_hexsha": "a01973ef7264f9454a40697313a2073c51a6b77a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.7444444444, "max_line_length": 111, "alphanum_fraction": 0.6472612561, "num_tokens": 1206, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8976952893703476, "lm_q2_score": 0.8652240686758841, "lm_q1q2_score": 0.7767075707001873}} {"text": "module nat-to-string where\n\nopen import bool\nopen import char\nopen import eq\nopen import list\nopen import maybe\nopen import nat\nopen import nat-division\nopen import nat-thms\nopen import product\nopen import string\nopen import termination\n\nℕ-to-digitsh : (base : ℕ) → 1 < base ≡ tt → (x : ℕ) → ↓𝔹 _>_ x → 𝕃 ℕ\nℕ-to-digitsh _ _ 0 _ = []\nℕ-to-digitsh base bp (suc x) (pf↓ fx) with (suc x) ÷ base ! (<=ℕff2 base bp)\n... | q , r , p , _ = r :: (ℕ-to-digitsh base bp q (fx (÷<{base}{q}{r}{x} bp p)))\n\nℕ-to-digits : ℕ → 𝕃 ℕ\nℕ-to-digits x = reverse (ℕ-to-digitsh 10 refl x (↓-> x))\n\ndigit-to-string : ℕ → string\ndigit-to-string 0 = \"0\"\ndigit-to-string 1 = \"1\"\ndigit-to-string 2 = \"2\"\ndigit-to-string 3 = \"3\"\ndigit-to-string 4 = \"4\"\ndigit-to-string 5 = \"5\"\ndigit-to-string 6 = \"6\"\ndigit-to-string 7 = \"7\"\ndigit-to-string 8 = \"8\"\ndigit-to-string 9 = \"9\"\ndigit-to-string _ = \"unexpected-digit\"\n\ndigits-to-string : 𝕃 ℕ → string\ndigits-to-string [] = \"\"\ndigits-to-string (d :: ds) = (digit-to-string d) ^ (digits-to-string ds)\n\nℕ-to-string : ℕ → string\nℕ-to-string 0 = \"0\"\nℕ-to-string (suc x) = digits-to-string (ℕ-to-digits (suc x))\n\nstring-to-digit : char → maybe ℕ \nstring-to-digit '0' = just 0\nstring-to-digit '1' = just 1\nstring-to-digit '2' = just 2\nstring-to-digit '3' = just 3\nstring-to-digit '4' = just 4\nstring-to-digit '5' = just 5\nstring-to-digit '6' = just 6\nstring-to-digit '7' = just 7\nstring-to-digit '8' = just 8\nstring-to-digit '9' = just 9\nstring-to-digit _ = nothing\n\n-- the digits are in order from least to most significant\ndigits-to-ℕh : ℕ → ℕ → 𝕃 ℕ → ℕ\ndigits-to-ℕh multiplier sum [] = sum\ndigits-to-ℕh multiplier sum (x :: xs) = digits-to-ℕh (10 * multiplier) (x * multiplier + sum) xs\n\ndigits-to-ℕ : 𝕃 ℕ → ℕ\ndigits-to-ℕ digits = digits-to-ℕh 1 0 digits\n\nstring-to-ℕ : string → maybe ℕ\nstring-to-ℕ s with 𝕃maybe-map string-to-digit (reverse (string-to-𝕃char s)) \n... | nothing = nothing\n... | just ds = just (digits-to-ℕ ds)\n", "meta": {"hexsha": "db05bf422ebdaf27a13686a7d65a1762322ef5cc", "size": 1935, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "nat-to-string.agda", "max_stars_repo_name": "heades/AUGL", "max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "nat-to-string.agda", "max_issues_repo_name": "heades/AUGL", "max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "nat-to-string.agda", "max_forks_repo_name": "heades/AUGL", "max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.0434782609, "max_line_length": 96, "alphanum_fraction": 0.650129199, "num_tokens": 697, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.934395157060208, "lm_q2_score": 0.8311430478583168, "lm_q1q2_score": 0.776616038743072}} {"text": "-- Exercises for session 2\n--\n-- If unsure which exercises to do start with those marked with *\n--\n{-# OPTIONS --cubical --allow-unsolved-metas #-}\nmodule ExerciseSession2 where\n\nopen import Part1\nopen import Part2\nopen import ExerciseSession1\n\nopen import Cubical.Foundations.Equiv\n\n-- Exercises about Part 2:\n\n-- Exercise* 1: prove that the computation rule for J on refl\n-- holds up to a path.\n-- (hint: normalize the goal using C-u C-u C-c C-,)\nJEq : {x : A} (P : (z : A) → x ≡ z → Type ℓ'')\n (d : P x refl) → J P d refl ≡ d\nJEq P p d = {!!}\n\n\n-- Exercise* 2: prove that isContr implies isProp\nisContr→isProp : isContr A → isProp A\nisContr→isProp = {!!}\n\n\n-- Exercise 3: prove that isProp implies isProp'\n-- (hint: use isProp→isSet from the Part2)\nisProp→isProp' : isProp A → isProp' A\nisProp→isProp' = {!!}\n\n\n-- Exercise 4: prove the following lemma\n-- (hint: use the solutions to exercises 2 and 3)\nisContr→isContr≡ : isContr A → (x y : A) → isContr (x ≡ y)\nisContr→isContr≡ = {!!}\n\n\n-- Exercise 5: use transp to turn a PathP into a transport\nfromPathP : {A : I → Type ℓ} {x : A i0} {y : A i1}\n → PathP A x y\n → transport (λ i → A i) x ≡ y\nfromPathP {A = A} p i = {!!}\n\n\n-- The converse is harder to prove so we give it:\ntoPathP : {A : I → Type ℓ} {x : A i0} {y : A i1}\n → transport (λ i → A i) x ≡ y\n → PathP A x y\ntoPathP {A = A} {x = x} p i =\n hcomp (λ j → λ { (i = i0) → x\n ; (i = i1) → p j })\n (transp (λ j → A (i ∧ j)) (~ i) x)\n\n\n-- Exercise* 6: prove that two Σ-types where the second component is a\n-- proposition is equal if the first projections are equal.\n-- (hint: use ΣPathP and toPathP)\nΣ≡Prop : {B : A → Type ℓ'} {u v : Σ A B} (h : (x : A) → isProp (B x))\n → (p : fst u ≡ fst v) → u ≡ v\nΣ≡Prop {B = B} {u = u} {v = v} h p = {!!}\n\n-- Exercice 7 (harder): prove that being contractible is a proposition.\n-- (hint: the second component can be given by a suitable higher\n-- dimensional hcomp)\nisPropIsContr : isProp (isContr A)\nisPropIsContr = {!!}\n\n\n\n\n-- Exercises about Part 3:\n\n-- Exercise* 8: compose sucPathInt with itself n times. Transporting\n-- along this will be addition, transporting with it backwards will be\n-- subtraction.\n\nopen import Cubical.Data.Nat\nopen import Cubical.Data.Int hiding (addEq ; subEq)\n\n-- a) Define a path \"addEq n\" by composing sucPathInt with itself n times.\naddEq : ℕ → Int ≡ Int\naddEq n = {!!}\n\n-- b) Define another path \"subEq n\" by composing \"sym sucPathInt\" with\n-- itself n times.\nsubEq : ℕ → Int ≡ Int\nsubEq n = {!!}\n\n-- c) Define addition on integers by pattern-matching and transporting\n-- along addEq/subEq appropriately.\n_+Int_ : Int → Int → Int\nm +Int n = {!!}\n\n-- d) Do some concrete computations using _+Int_ (this would not work\n-- in HoTT as the transport would be stuck!)\n\n-- e) Use isEquivTransport from\n\nopen import Cubical.Foundations.Transport\n\n-- to prove that +Int with a fixed number is an equivalence.\n--\n-- Note that proving this for the usual _+_ function would be a lot\n-- longer, but now we get it for free as addition is defined using\n-- transport which we already know is an equivalence.\n\n-- Exercise* 9 (harder): prove that hSet is not a set\n\n-- Let's import Bool instead so that we get it from the library\nopen import Cubical.Data.Bool renaming (notEq to notPath)\n\n-- The empty type ⊥ (written \\bot)\nopen import Cubical.Data.Empty\n\n-- Just define hSets of level 0 for simplicity\nhSet : Type₁\nhSet = Σ[ A ∈ Type₀ ] isSet A\n\n-- Bool is an hSet\nBoolSet : hSet\nBoolSet = Bool , isSetBool\n\n-- (hint: use a suitable nested transport)\nnotPath≢refl : (notPath ≡ refl) → ⊥\nnotPath≢refl e = true≢false {!!}\n\n-- (hint: use notPath≢refl and define two elements of BoolSet ≡\n-- BoolSet, one based on notPath and one based on refl. Σ≡Prop and\n-- isPropIsSet is probably handy)\n¬isSet-hSet : isSet hSet → ⊥\n¬isSet-hSet h = {!!}\n\n\n\n-- Exercise 10 (more work): prove that FinData and Fin are equivalent\n-- and hence equal. Transport some functions and proofs between the\n-- two.\n\n-- Orderings on ℕ\nopen import Cubical.Data.Nat.Order\n\ndata FinData : ℕ → Type₀ where\n zero : {n : ℕ} → FinData (suc n)\n suc : {n : ℕ} (i : FinData n) → FinData (suc n)\n\nFin : ℕ → Type₀\nFin n = Σ[ k ∈ ℕ ] k < n\n", "meta": {"hexsha": "7a02ab01149e022f5d6a4b9ac1029928d357bae1", "size": 4229, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "04-cubical-type-theory/material/ExerciseSession2.agda", "max_stars_repo_name": "williamdemeo/EPIT-2020", "max_stars_repo_head_hexsha": "19d72759e18e05d2c509f62d23a998573270140c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-04-03T16:28:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-03T16:28:06.000Z", "max_issues_repo_path": "04-cubical-type-theory/material/ExerciseSession2.agda", "max_issues_repo_name": "EgbertRijke/EPIT-2020", "max_issues_repo_head_hexsha": "9a510959fb0e6da9bcc6b0faa0dea76a2821bbdb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "04-cubical-type-theory/material/ExerciseSession2.agda", "max_forks_repo_name": "EgbertRijke/EPIT-2020", "max_forks_repo_head_hexsha": "9a510959fb0e6da9bcc6b0faa0dea76a2821bbdb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-08-02T16:16:34.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-02T16:16:34.000Z", "avg_line_length": 28.0066225166, "max_line_length": 74, "alphanum_fraction": 0.6538188697, "num_tokens": 1353, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.903294214513915, "lm_q2_score": 0.8596637505099167, "lm_q1q2_score": 0.7765292922629414}} {"text": "module relations where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl; cong)\nopen import Data.Nat using (ℕ; zero; suc; _+_)\nopen import Data.Nat.Properties using (+-comm; +-identityʳ)\n\ndata _≤_ : ℕ → ℕ → Set where\n z≤n : ∀ {n : ℕ} → zero ≤ n\n s≤s : ∀ {m n : ℕ} → m ≤ n → suc m ≤ suc n\n\ninfix 4 _≤_\n\nfoo : 2 ≤ 4\nfoo = s≤s (s≤s z≤n)\n\ninv-s≤s : ∀ {m n : ℕ} → suc m ≤ suc n → m ≤ n\ninv-s≤s (s≤s m≤n) = m≤n\n\nbar : 1 ≤ 3\nbar = inv-s≤s foo\n", "meta": {"hexsha": "99c017d4ec32c8b881ed28606522a50595fc16df", "size": 465, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "plfa/relations.agda", "max_stars_repo_name": "aronerben/agda-playground", "max_stars_repo_head_hexsha": "64a00f1f97f053d246d5b9deab090e75d923fe8f", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "plfa/relations.agda", "max_issues_repo_name": "aronerben/agda-playground", "max_issues_repo_head_hexsha": "64a00f1f97f053d246d5b9deab090e75d923fe8f", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "plfa/relations.agda", "max_forks_repo_name": "aronerben/agda-playground", "max_forks_repo_head_hexsha": "64a00f1f97f053d246d5b9deab090e75d923fe8f", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.1363636364, "max_line_length": 59, "alphanum_fraction": 0.5806451613, "num_tokens": 206, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9609517106286378, "lm_q2_score": 0.8080672158638527, "lm_q1q2_score": 0.77651357338729}} {"text": "module z03-natural-numbers where\n\nopen import bool\nopen import bool-thms using (𝔹-contra)\nopen import eq\nopen import level\n\n-- p 50\n\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\n-- p 51\n\n{-# BUILTIN NATURAL ℕ #-}\n\n-------------------------\n_+_ : ℕ → ℕ → ℕ\nzero + n = n\nsuc m + n = suc (m + n) -- recursive call on structurally smaller left side 'm' -- termination\n\n-- p 53\n\n-------------------------\n0+ : ∀ (x : ℕ)\n → 0 + x ≡ x\n0+ _ = refl -- via definitional equality\n\n{- fails because _+_ defined in terms of pattern matching on left arg\n+0 : ∀ (x : ℕ)\n → x + 0 ≡ x\n+0 _ = refl\n\n-- p 55\n\nsolution is for proof to call itself recursively:\n-------------------------\n-}\n+0 : ∀ (x : ℕ)\n → x + 0 ≡ x\n\n-- BASE\n+0 zero = refl -- via definitional equality\n\n-- INDUCTIVE\n-- note: name of 'y' variable, if renamed to 'x', is not same as 'x' in signature\n+0 (suc y) rewrite +0 y = refl\n{- ^\n |\n'x' in sig instantiated to 'suc y'\n\nso trying to prove (the goal) : suc y + 0 ≡ suc y\n\ngoal can be simplified by inductive case of def of _+_\n\nso goal definitionally equal to : suc (y + 0) ≡ suc y\n\n rewrite recursive call proves y + 0 ≡ y\n\n type of proof is x + 0 ≡ x\n so Agda with replace occurrences of x + 0 with x\n\n leaving : suc y ≡ suc y\n\n-- p 57\n\nPROOF BY INDUCTION: recursive proofs\n\n------------------------------------------------------------------------------\n+ ASSOCIATIVITY\n\nWhen theorem has multiple variables, must decide which one to use for induction.\nGenerally: var used where a recursive fun will patten match on it.\nIf several vars are pattern matched, prefer the one that is matched the most.\n\nSince _+_ matches on 1st arg, then do induction here on 1st arg.\nHere 'x' is matched twice but 'y' only once -- so use 'x'.\n-}\n\n-------------------------\n+assoc : ∀ (x y z : ℕ)\n → x + (y + z)\n ≡ (x + y) + z\n{-\nBASE case\n goal: zero + (y + z) ≡ (zero + y) + z\n via def/eq\n-}\n+assoc zero y z = refl\n\n{-\nINDUCTIVE case\n goal : suc (x + (y + z)) ≡ suc ((x + y) + z)\n need proof of : (x + (y + z)) ≡ ((x + y) + z)\n that is exactly the inductive hypotheses\n so use rewrite to recursively apply the proof\n-}\n+assoc (suc x) y z rewrite +assoc x y z = refl\n\n------------------------------------------------------------------------------\n-- p 60 + COMMUTATIVITY (rewrite with multiple equations)\n\n-------------------------\n+suc : ∀ (x y : ℕ) → x + (suc y) ≡ suc (x + y)\n+suc zero y = refl\n+suc (suc x) y rewrite +suc x y = refl\n\n-------------------------\n+comm : ∀ (x y : ℕ) → x + y ≡ y + x\n{-\nBASE\n Goal: : y ≡ (y + zero)\n so rewrite right hand side using +0 proof\n simplifies to : y ≡ y\n-}\n+comm zero y rewrite +0 y = refl\n{-\nINDUCTIVE\n Goal : suc (x + y) ≡ (y + suc x)\n-}\n+comm (suc x) y rewrite +suc y x | +comm x y = refl\n\n------------------------------------------------------------------------------\n-- p 62 MULTIPLICATION\n\n-------------------------\n_*_ : ℕ → ℕ → ℕ\nzero * n = zero\nsuc m * n = n + (m * n)\n\n-------------------------\n-- p 63 - right distributivity of * over +\n\n-- variable counts x : 2; y : 1; z : 0 : so use x\n\n*distribr : ∀ (x y z : ℕ)\n → (x + y) * z ≡ (x * z) + (y * z)\n\n-- BASE\n*distribr zero y z = refl\n\n{-\nINDUCTIVE\nGoal: ((suc x + y) * z) ≡ ((suc x * z) + (y * z))\nGoal: (z + ((x + y) * z)) ≡ ((z + (x * z)) + (y * z))\n\n*distribr (suc x) y z rewrite *distribr x y z = {!!}\nGoal: (z + ((x * z) + (y * z))) ≡ ((z + (x * z)) + (y * z))\n right-associated left-associated\nso reassociate: to prove\nA + (B + C) ≡ (A + B) + C\n^ ^ ^\n| | |\nz | |\n x * z |\n y * z\n-}\n*distribr (suc x) y z\n rewrite\n *distribr x y z\n = +assoc z (x * z) (y * z)\n\n------------------------------------------------------------------------------\n-- p 65 * COMMUTATIVITY\n\n-------------------------\n*0 : ∀ (x : ℕ)\n → x * 0 ≡ 0\n\n-- BASE\n*0 zero = refl -- def/eq : (zero * 0) ≡ 0\n{-\nINDUCTIVE\n(suc x * 0) ≡ 0\n (x * 0) ≡ 0 -- IH\nrewrite\n 0 ≡ 0\n-}\n*0 (suc y) rewrite *0 y = refl\n\n-------------------------\n\n*suc : ∀ (x y : ℕ) → x * (suc y) ≡ x + (x * y)\n{-\nBASE\n (zero * suc y) ≡ (zero + (zero * y))\ndef/eq zero ≡ zero\n-}\n*suc zero y = refl\n{-\nINDUCTIVE\n (suc x * suc y) ≡ (suc x + (suc x * y))\ndef/eq suc (y + (x * suc y)) ≡ suc (x + (y + (x * y)))\nrw *suc suc (y + (x + (x * y))) ≡ suc (x + (y + (x * y)))\nrw +assoc suc ((y + x) + (x * y)) ≡ suc (x + (y + (x * y)))\nrw +assoc suc ((y + x) + (x * y)) ≡ suc ((x + y) + (x * y))\nrw +comm suc ((x + y) + (x * y)) ≡ suc ((x + y) + (x * y))\n-}\n*suc (suc x) y\n rewrite\n *suc x y\n | +assoc y x (x * y)\n | +assoc x y (x * y)\n | +comm y x = refl\n\n-------------------------\n\n*comm : ∀ (x y : ℕ) → x * y ≡ y * x\n{-\nBASE\n (zero * y) ≡ (y * zero)\ndef/eq zero ≡ (y * zero)\nrs *0 zero ≡ zero\n-}\n*comm zero y rewrite *0 y = refl\n{-\nINDUCTIVE\n (suc x * y) ≡ (y * suc x)\ndef/eq (y + (x * y)) ≡ (y * suc x)\nrw *suc (y + (x * y)) ≡ (y + (y * x))\nrw *comm (y + (y * x)) ≡ (y + (y * x))\n-}\n*comm (suc x) y\n rewrite\n *suc y x\n | *comm x y = refl\n\n------------------------------------------------------------------------------\n-- p 66 * ASSOCIATIVITY\n\n*assoc : ∀ (x y z : ℕ) → x * (y * z) ≡ (x * y) * z\n{-\nBASE\n (zero * (y * z)) ≡ ((zero * y) * z)\ndef/eq zero ≡ zero\n-}\n*assoc zero y z = refl\n{-\nINDUCTIVE\n\n (suc x * (y * z)) ≡ ((suc x * y) * z)\ndef/eq ((y * z) + (x * (y * z))) ≡ ((y + (x * y)) * z)\nrw *distribr ((y * z) + (x * (y * z))) ≡ ((y * z) + ((x * y) * z))\nrw *assoc ((y * z) + ((x * y) * z)) ≡ ((y * z) + ((x * y) * z))\n-}\n*assoc (suc x) y z\n rewrite\n *distribr y (x * y) z\n | *assoc x y z = refl\n\n------------------------------------------------------------------------------\n-- p 67 LESS-THEN <\n\n_<_ : ℕ → ℕ → 𝔹\n0 < 0 = ff\n0 < (suc y) = tt\n(suc x) < (suc y) = x < y\n(suc x) < 0 = ff\n\n-------------------------\n-- < is TRANSITIVE\n\n{-\nxx : ∀ {x y z : ℕ}\n → x < y\n → y < z\n → x < z\n\nAbove will not type check because _<_ returns 𝔹 VALUE, not a type\nTypes have type Set in Agda -- 𝔹 is not the same as Set.\nCould define _<_ as a relation: ℕ → ℕ → Set.\nBut then _<_ could not be used computationally.\nExpressions with type Set describe code -- they are NOT code themselves\n- e.g., cannot pattern-match on expressions of type Set\n cannot compute with them\nTransitivity theorem is statement about behavior of the PROGRAM _<_.\n-}\n\n-- p 69\n\n-------------------------\n<-0 : ∀ (x : ℕ) → x < 0 ≡ ff\n<-0 0 = refl -- (zero < 0) ≡ ff; ff ≡ ff\n<-0 (suc y) = refl -- (suc y < 0) ≡ ff; ff ≡ ff\n\n-------------------------\n<-trans : ∀ {x y z : ℕ}\n → x < y ≡ tt\n → y < z ≡ tt\n → x < z ≡ tt\n{-\n p1 : (x < zero) ≡ tt ; p2 : (zero < z) ≡ tt = Goal: (x < z) ≡ tt\nrw <-0 p1 : ff ≡ tt ; p2 : (0 < z) ≡ tt = Goal: (x < z) ≡ tt\n-}\n<-trans {x} {0} p1 p2 rewrite <-0 x = 𝔹-contra p1\n\n-- can't be called like this so no proof needed\n<-trans {0} {suc y} {0} p1 ()\n\n-- p1 : (zero < suc y) ≡ tt ; p2 : (suc y < suc z) ≡ tt = Goal: (zero < suc z) ≡ tt\n<-trans {0} {suc y} {suc z} p1 p2 = refl\n\n-- can't be called like this so no proof needed\n<-trans {suc x} {suc y} {0} p1 ()\n\n-- p1 : (suc x < suc y) ≡ tt; p2 : (suc y < suc z) ≡ tt = Goal: (suc x < suc z) ≡ tt\n<-trans {suc x} {suc y} {suc z} p1 p2 = <-trans {x} {y} {z} p1 p2 -- uses IH via recursive call\n\n------------------------------------------------------------------------------\n-- p 71 EQUALITY TEST for ℕ\n{-\nso far, rely on\n- def/eq : done automatically during type checking\n- ≡ : express, as a TYPE, a proposition that two VALUES are equal\n\nthere are other kinds of equality, e,g.,\n\nCOMPUTATIONAL EQUALITY : tests VALUE equality\n-}\n\n_=ℕ_ : ℕ → ℕ → 𝔹\n0 =ℕ 0 = tt\nsuc x =ℕ suc y = x =ℕ y\n_ =ℕ _ = ff\n\n_≤_ : ℕ → ℕ → 𝔹\nx ≤ y = (x < y) || x =ℕ y\n\n-------------------------\n\n=ℕ-refl : ∀ (x : ℕ) → (x =ℕ x) ≡ tt\n=ℕ-refl 0 = refl\n=ℕ-refl (suc x) = (=ℕ-refl x)\n\n-------------------------\n\n-- SOUNDNESS property: things indicated to be true really are true\n=ℕ-to-≡ : ∀ {x y : ℕ} → x =ℕ y ≡ tt → x ≡ y\n=ℕ-to-≡ {0} {0} _ = refl\n=ℕ-to-≡ {suc x} {0} ()\n=ℕ-to-≡ {0} {suc y} ()\n=ℕ-to-≡ {suc x} {suc y} p\n rewrite\n =ℕ-to-≡ {x} {y} p = refl\n\n-------------------------\n\n=ℕ-from-≡ : ∀ {x y : ℕ}\n → x ≡ y\n → x =ℕ y ≡ tt\n=ℕ-from-≡ {x} refl = =ℕ-refl x\n\n------------------------------------------------------------------------------\n-- p 73 EXERCISES\n\n-- 1 nat-thms\n\n--------------------------------------------------\n-- properties of addition\n--------------------------------------------------\n\n+1 : ∀ (x : ℕ) → x + 1 ≡ suc x\n+1 zero = refl\n+1 (suc n) rewrite +1 n = refl\n\n+perm : ∀ (x y z : ℕ) → x + (y + z) ≡ y + (x + z)\n+perm zero y z = refl\n+perm (suc x) y z -- (suc x + (y + z)) ≡ (y + (suc x + z))\n -- suc (x + (y + z)) ≡ (y + suc (x + z))\n rewrite\n +suc y (x + z) -- suc (x + (y + z)) ≡ suc (y + (x + z))\n | +assoc x y z -- suc ((x + y) + z) ≡ suc (y + (x + z))\n | +comm x y -- suc ((y + x) + z) ≡ suc (y + (x + z))\n | +assoc y x z -- suc ((y + x) + z) ≡ suc ((y + x) + z)\n = refl\n\n--------------------------------------------------\n-- properties of multiplication\n--------------------------------------------------\n\n*1 : ∀ {n : ℕ} → n * 1 ≡ n\n*1 {zero} = refl\n*1 {suc n} -- (suc n * 1) ≡ suc n\n -- suc (n * 1) ≡ suc n\n rewrite\n *comm n 1 -- suc (n + 0) ≡ suc n\n | +0 n -- suc n ≡ suc n\n = refl\n\n--------------------------------------------------\n-- properties of <, ≤, and =ℕ, iszero\n--------------------------------------------------\n\n0-≤ : ∀ (x : ℕ) → 0 ≤ x ≡ tt\n0-≤ zero = refl\n0-≤ (suc n) -- (0 ≤ suc n) ≡ tt\n rewrite 0-≤ n -- tt ≡ tt\n = refl\n\n=ℕ-sym : ∀ (x y : ℕ) → (x =ℕ y) ≡ (y =ℕ x)\n=ℕ-sym zero zero = refl\n=ℕ-sym (suc x) zero = refl -- (suc x =ℕ zero) ≡ (zero =ℕ suc x); ff ≡ ff\n=ℕ-sym zero (suc y) = refl -- (zero =ℕ suc y) ≡ (suc y =ℕ zero); ff ≡ ff\n=ℕ-sym (suc x) (suc y) rewrite =ℕ-sym x y = refl\n\n=ℕ-suc : ∀ (x : ℕ) → suc x =ℕ x ≡ ff\n=ℕ-suc zero = refl\n=ℕ-suc (suc n) rewrite =ℕ-suc n = refl\n\n<-suc : ∀ (n : ℕ) → n < suc n ≡ tt\n<-suc zero = refl\n<-suc (suc n) rewrite <-suc n = refl\n\n-- TODO: understand\nsuc-inj : ∀ {n m : ℕ} → suc n ≡ suc m → n ≡ m\nsuc-inj {0} {0} _ = refl\nsuc-inj {m = suc m} refl = refl\n\n<=ℕff : ∀ (x : ℕ) → 0 < x ≡ tt → x =ℕ 0 ≡ ff\n<=ℕff (suc x) _ = refl\n\n<≤ : ∀ {n m : ℕ} → n < m ≡ tt → n ≤ m ≡ tt\n<≤ {0} {0} _ = refl\n<≤ {suc _} {0} ()\n<≤ {0} {suc _} _ = refl\n<≤ {suc n} {suc m} p rewrite <≤ {n} {m} p = refl\n\n--------------------------------------------------\n-- ordering properties of < and ≤ℕ\n--------------------------------------------------\n\n<-irrefl : ∀ (n : ℕ) → n < n ≡ ff\n<-irrefl zero = refl\n<-irrefl (suc n) rewrite <-irrefl n = refl\n\n<-asym : ∀ {x y : ℕ}\n → x < y ≡ tt\n → y < x ≡ ff\n<-asym {0} {0} _ = refl\n<-asym {0} {suc _} _ = refl\n<-asym {suc _} {0} ()\n<-asym {suc x} {suc y} p = <-asym {x} {y} p\n\nℕ-trichotomy𝔹 : ∀ (n m : ℕ) → n < m || n =ℕ m || m < n ≡ tt\nℕ-trichotomy𝔹 0 0 = refl\nℕ-trichotomy𝔹 0 (suc m) = refl\nℕ-trichotomy𝔹 (suc n) 0 = refl\nℕ-trichotomy𝔹 (suc n) (suc m) = ℕ-trichotomy𝔹 n m\n\n<≤-trans : ∀ {x y z : ℕ}\n → x < y ≡ tt\n → y ≤ z ≡ tt\n → x < z ≡ tt\n<≤-trans {x} {0} p1 _ rewrite <-0 x = 𝔹-contra p1\n<≤-trans {0} {suc y} {0} _ ()\n<≤-trans {0} {suc y} {suc z} _ _ = refl\n<≤-trans {suc x} {suc y} {0} _ ()\n<≤-trans {suc x} {suc y} {suc z} p1 p2 = <≤-trans {x} {y} {z} p1 p2\n\n≤-refl : ∀ (x : ℕ) → x ≤ x ≡ tt\n≤-refl zero = refl\n≤-refl (suc x) rewrite ≤-refl x = refl\n\n--------------------------------------------------\n-- injectivity properties of addition\n--------------------------------------------------\n\n+inj1 : ∀ {x y z : ℕ}\n → x + y ≡ x + z\n → y ≡ z\n+inj1 {0} {y} {z} p = p\n+inj1 {suc x} {y} {z} p = +inj1 {x} {y} {z} (suc-inj p)\n\n+inj2 : ∀ {x y z : ℕ}\n → x + z ≡ y + z\n → x ≡ y\n+inj2 {x} {y} {z} p -- p : (x + z) ≡ (y + z); Goal: x ≡ y\n rewrite\n +comm x z -- p : (z + x) ≡ (y + z); Goal: x ≡ y\n | +comm y z -- p : (z + x) ≡ (z + y); Goal: x ≡ y\n = +inj1 {z} {x} {y} p -- NOTE: '+inj1'\n\n------------------------------------------------------------------------------\n\n-- 2\n\n{- TODO\nnat.agda\n\n>, >= : defined in terms of < and <=\n\nProve versions of theorems like <-trans and <+\n- modified to use _>_ instead of _<_\n\nfor practice writing out formulas in Agda\nsince the proofs can be written just to invoke the theorems dealing with _<_\n-}\n\n_>_ : ℕ → ℕ → 𝔹\na > b = b < a\n\n_≥_ : ℕ → ℕ → 𝔹\na ≥ b = b ≤ a\n\n<-trans2 : ∀ {x y z : ℕ}\n → y > x ≡ tt\n → z > y ≡ tt\n → z > x ≡ tt\n<-trans2 {x} {y} {z} = <-trans {x} {y} {z}\n\n------------------------------------------------------------------------------\n\n-- 3a\n\nf : (n : ℕ) → ℕ\nf 0 = 1\nf (suc x) = (suc x) * (f x)\n\nf-is-factorial : f 5 ≡ 120\nf-is-factorial = refl\n\n-- 3b\n\nf' : ℕ → 𝔹\nfb : ℕ → 𝔹\n\n-- is-odd\nf' 0 = ff\nf' (suc x) = fb x\n\n-- is-even\nfb 0 = tt\nfb (suc x) = f' x\n\nf'-is-odd : f' (suc 0) ≡ tt\nf'-is-odd = refl\n\nfb-is-even : fb (suc (suc 0)) ≡ tt\nfb-is-even = refl\n", "meta": {"hexsha": "b8ecc2f982821bf43142fcea0d2d821fe50a33ad", "size": 13568, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z03-natural-numbers.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z03-natural-numbers.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z03-natural-numbers.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 25.0794824399, "max_line_length": 95, "alphanum_fraction": 0.4037441038, "num_tokens": 5260, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9111797124237605, "lm_q2_score": 0.8519528019683106, "lm_q1q2_score": 0.7762821090961022}} {"text": "module Misc.PosBinary where -- Positive Binary Numbers\n\nopen import Data.Nat\nopen import Data.List\nopen import Relation.Binary.PropositionalEquality\n using (_≡_; refl; sym)\n\nopen import Induction.WellFounded\nopen import Induction.Nat using (<-well-founded)\n\ndata Bin+ : Set where\n [] : Bin+\n 1∷_ : Bin+ → Bin+\n 2∷_ : Bin+ → Bin+\n\ndecimal : Bin+ → ℕ\ndecimal [] = 0\ndecimal (1∷ xs) = 1 + 2 * decimal xs\ndecimal (2∷ xs) = 2 + 2 * decimal xs\n\n-- A even/odd view. Surprised that we don't have it in StdLib\n\ndata Div2 : ℕ → Set where\n even : ∀ n → Div2 (2 * n)\n odd : ∀ n → Div2 (1 + 2 * n)\n\nopen import Data.Nat.Properties.Simple using (+-suc)\n -- +-suc : ∀ m n → m + suc n ≡ suc (m + n)\nopen import Data.Nat.Properties using (m≤′m+n)\n -- m≤′m+n : ∀ m n → m ≤′ m + n\n\n_div2 : ∀ n → Div2 n\nzero div2 = even 0\nsuc n div2 with n div2\nsuc .(n + (n + 0)) div2 | even n = odd n\nsuc .(suc (n + (n + 0))) div2 | odd n\n rewrite sym (+-suc n (n + zero)) = even (1 + n)\n\nbin+' : (n : ℕ) → Acc _<′_ n → Bin+\nbin+' n _ with n div2\nbin+' .0 _ | even zero = []\nbin+' .(suc (m + suc (m + 0))) (acc rs) | even (suc m) =\n 2∷ bin+' m (rs m (m≤′m+n (suc m) _))\nbin+' .(suc (m + (m + 0))) (acc rs) | odd m =\n 1∷ bin+' m (rs m (m≤′m+n (suc m) _))\n\nbin+ : ℕ → Bin+\nbin+ n = bin+' n (<-well-founded n)\n\n{- For reference.\n\nbin' : (n : ℕ) → Acc _<′_ n → List ℕ\nbin' n _ with n div2\nbin' .0 (acc rs) | even 0 = []\nbin' .(suc m + (suc m + 0)) (acc rs) | even (suc m) =\n 0 ∷ bin' m (rs m (m≤′m+n (suc m) _))\nbin' .(suc (m + (m + 0))) (acc rs) | odd m =\n 1 ∷ bin' m (rs m (m≤′m+n (suc m) _))\n\nbin : ℕ → List ℕ\nbin n = bin' n (<-well-founded n)\n-}\n\nlInv' : ∀ n → (ac : Acc _<′_ n) → decimal (bin+' n ac) ≡ n\nlInv' n ac with n div2\nlInv' .0 ac | even zero = refl\nlInv' .(suc (m + suc (m + 0))) (acc rs) | even (suc m)\n rewrite lInv' m (rs m (m≤′m+n (suc m) (suc (m + zero))))\n | +-suc m (m + 0) = refl\nlInv' .(suc (m + (m + 0))) (acc rs) | odd m\n rewrite lInv' m (rs m (m≤′m+n (suc m) (m + zero))) = refl\n\nlInv : ∀ n → decimal (bin+ n) ≡ n\nlInv n = lInv' n (<-well-founded n)\n", "meta": {"hexsha": "ce3ece786399470079de66c00a77ccfc61e0ba85", "size": 2118, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "legacy/Misc/PosBinary.agda", "max_stars_repo_name": "banacorn/numeral", "max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z", "max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z", "max_issues_repo_path": "legacy/Misc/PosBinary.agda", "max_issues_repo_name": "banacorn/numeral", "max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "legacy/Misc/PosBinary.agda", "max_forks_repo_name": "banacorn/numeral", "max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z", "avg_line_length": 28.24, "max_line_length": 61, "alphanum_fraction": 0.5226628895, "num_tokens": 901, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9219218370002787, "lm_q2_score": 0.8418256532040708, "lm_q1q2_score": 0.7760974526358565}} {"text": "module Nats.Add.Comm where\n\nopen import Equality\nopen import Nats\nopen import Function\n\n------------------------------------------------------------------------\n-- internal stuffs\n\nprivate\n\n a+0=0+a : ∀ a → a + 0 ≡ a\n a+0=0+a zero = refl\n a+0=0+a (suc a) = cong suc $ a+0=0+a a\n\n ++a+b=a+b++ : ∀ a b → suc (a + b) ≡ a + suc b\n ++a+b=a+b++ zero b = refl\n ++a+b=a+b++ (suc a) b = cong suc $ ++a+b=a+b++ a b\n\n a+b=b+a : ∀ a b → a + b ≡ b + a\n a+b=b+a zero b = sym (a+0=0+a b)\n a+b=b+a (suc a) b = suc (a + b) ≡⟨ cong suc (a+b=b+a a b) ⟩ ++a+b=a+b++ b a\n\n------------------------------------------------------------------------\n-- public aliases\n\nnat-add-comm : ∀ a b → a + b ≡ b + a\nnat-add-comm = a+b=b+a\n", "meta": {"hexsha": "7b6f1464f23ebfe28254b968d1919ba464ff58a6", "size": 718, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Nats/Add/Comm.agda", "max_stars_repo_name": "ice1k/Theorems", "max_stars_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-04-15T15:28:03.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-15T15:28:03.000Z", "max_issues_repo_path": "src/Nats/Add/Comm.agda", "max_issues_repo_name": "ice1k/Theorems", "max_issues_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Nats/Add/Comm.agda", "max_forks_repo_name": "ice1k/Theorems", "max_forks_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.7586206897, "max_line_length": 77, "alphanum_fraction": 0.3997214485, "num_tokens": 262, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9518632343454896, "lm_q2_score": 0.8152324960856175, "lm_q1q2_score": 0.7759898404676026}} {"text": "-- agad-modeの使い方\n-- https://agda.readthedocs.io/en/latest/tools/emacs-mode.html\n{-# OPTIONS --without-K --safe #-}\nmodule Learn.Interactive where\n\n-- ロード\n-- タイプチェックする\n-- C-c C-l\n-- Ctrlを押しながら、cを押して次にlを押す\n-- このとき、ソース内に\"?\"が存在すればそれをゴールにする\n-- ゴールには番号が振られる\n\n-- 型推論する\n-- C-c C-d\n\n-- 評価する\n-- C-c C-n\n\n-- 終了させる\n-- C-c C-x C-q\n-- Ctrlを押しながら、c、x、qと押す\n\n-- 再スタートさせる\n-- C-c C-x C-r\n\n----------------------------------------------------------------------------\n-- ゴールへの操作\n-- ゴール内に値を書いてからゴールにカーソルを合わせ実行する。\n\n-- 与える\n-- C-c C-SPC\n-- Ctrlを押しながら、cを押して次にスペースを押す\n-- 型が合っていればゴールは消える\n\n-- リファイン\n-- C-c C-r\n-- 何もない状態で行うと関数ならラムダ、レコード型ならコンストラクタを挿入する\n-- ゴールに関数がある場合、関数の引数をゴールにする\n\n-- ケーススプリット\n-- C-c C-c\n-- ゴール内に変数を書く、またはC-c C-cして出てきた入力枠に変数を入力すると\n-- その変数でパターンマッチングを行う\n\n-- ゴールの型を確認する\n-- C-c C-t\n\n-- 環境を確認する\n-- C-c C-e\n\n----------------------------------------------------------------------------\n-- 自然数\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\n-- 等価性\ninfix 3 _≡_\ndata _≡_ {A : Set} (x : A) : A → Set where\n refl : x ≡ x\n\ncong : ∀ {A B : Set} (f : A → B) {x y} → x ≡ y → f x ≡ f y\ncong f refl = refl\n\n-- 足し算\n-- 右辺に?と書いてC-c C-l(ロード)する\n-- モジュールは無視で\nmodule Step1 where\n _+_ : ℕ → ℕ → ℕ\n m + n = {! !}\n\n-- ゴールに\"m\"と入力する\nmodule Step2 where\n _+_ : ℕ → ℕ → ℕ\n m + n = {! m !}\n\n-- ゴールにカーソルを合わせ C-c C-c (ケーススプリット)する\nmodule Step3 where\n _+_ : ℕ → ℕ → ℕ\n zero + n = {! !}\n suc m + n = {! !}\n\n-- インデントを整える\nmodule Step4 where\n _+_ : ℕ → ℕ → ℕ\n zero + n = {! !}\n suc m + n = {! !}\n\n-- ゴール内に右辺値を書く\nmodule Step5 where\n _+_ : ℕ → ℕ → ℕ\n zero + n = {! zero !}\n suc m + n = {! !}\n\n-- ゴールにカーソルを合わせ C-c C-SPC (Give)する\nmodule Step6 where\n _+_ : ℕ → ℕ → ℕ\n zero + n = zero\n suc m + n = {! !}\n\n-- もう一方のゴールも同様にする\n-- このときmは再帰的な呼び出しをするときに小さくなっている\n_+_ : ℕ → ℕ → ℕ\nzero + n = zero\nsuc m + n = suc (m + n)\n\n-- +の結合性\n-- 証明したい型を書く。右辺を?にしてゴールにする\nmodule Assoc1 where\n +-assoc : ∀ m n o → (m + n) + o ≡ m + (n + o)\n +-assoc m n o = {! !}\n\n-- このとき+の定義から+の左の変数で帰納するとよいとわかる\n-- 単一の変数であるならばパターンマッチングできるのでmを選びゴールに書く\nmodule Assoc2 where\n +-assoc : ∀ m n o → (m + n) + o ≡ m + (n + o)\n +-assoc m n o = {! m !}\n\n-- C-c C-cする\n-- ここで +-assoc zero n o の右辺のゴールでC-c C-tすると zero ≡ zero とわかる\n-- 同じ形ならreflが使えるのでreflをC-c C-SPCする\nmodule Assoc3 where\n +-assoc : ∀ m n o → (m + n) + o ≡ m + (n + o)\n +-assoc zero n o = refl\n +-assoc (suc m) n o = {! !}\n\n-- 次に +-assoc (suc m) n o の右辺でC-c C-tすると\n-- suc ((m + n) + o) ≡ suc (m + (n + o)) とわかる\n-- 両辺に同じ関数(suc)が掛かっているのでcongが使える\n-- congとゴール内に書く\nmodule Assoc4 where\n +-assoc : ∀ m n o → (m + n) + o ≡ m + (n + o)\n +-assoc zero n o = refl\n +-assoc (suc m) n o = {!cong !}\n\n-- C-c C-rするとゴールが分かれる\n-- 前はsucを与える\nmodule Assoc5 where\n +-assoc : ∀ m n o → (m + n) + o ≡ m + (n + o)\n +-assoc zero n o = refl\n +-assoc (suc m) n o = cong suc {! !}\n\n-- 後ろは+-assoc m n oの型と同じなのでそれを与える\n-- これで証明終了\nmodule Assoc6 where\n +-assoc : ∀ m n o → (m + n) + o ≡ m + (n + o)\n +-assoc zero n o = refl\n +-assoc (suc m) n o = cong suc (+-assoc m n o)\n", "meta": {"hexsha": "ebe13bcc8c0492b1a2da3128e5c14745c0a7ba29", "size": 2957, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Learn/Interactive.agda", "max_stars_repo_name": "rei1024/agda-misc", "max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z", "max_issues_repo_path": "Learn/Interactive.agda", "max_issues_repo_name": "rei1024/agda-misc", "max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Learn/Interactive.agda", "max_forks_repo_name": "rei1024/agda-misc", "max_forks_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.8456375839, "max_line_length": 76, "alphanum_fraction": 0.5262089956, "num_tokens": 1652, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9005297941266014, "lm_q2_score": 0.8615382094310357, "lm_q1q2_score": 0.7758408263711313}} {"text": "module plfa.working.Naturals where\n\n data ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\n seven : ℕ\n seven = suc(suc(suc(suc(suc(suc(suc(zero)))))))\n\n {-# BUILTIN NATURAL ℕ #-}\n\n import Relation.Binary.PropositionalEquality as Eq\n open Eq using (_≡_; refl)\n open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _∎)\n\n\n _+_ : ℕ → ℕ → ℕ\n zero + n = n\n (suc m) + n = suc(m + n)\n\n\n _ : 2 + 3 ≡ 5\n _ =\n begin\n 2 + 3\n ≡⟨⟩\n (suc (suc zero)) + (suc (suc (suc zero)))\n ≡⟨⟩\n suc( (suc zero) + (suc (suc (suc zero))))\n ≡⟨⟩\n (suc(suc (zero + (suc (suc (suc zero))))))\n ≡⟨⟩\n (suc (suc (suc (suc (suc zero)))))\n ≡⟨⟩\n 5\n ∎\n\n _ : 2 + 3 ≡ 5\n _ =\n begin\n 2 + 3\n ≡⟨⟩\n suc (1 + 3)\n ≡⟨⟩\n suc (suc (0 + 3))\n ≡⟨⟩\n suc (suc 3)\n ≡⟨⟩\n 5\n ∎\n\n _ : 3 + 4 ≡ 7\n _ =\n begin\n 3 + 4\n ≡⟨⟩\n suc (2 + 4)\n ≡⟨⟩\n suc (2 + (suc 3))\n ≡⟨⟩\n suc (suc (2 + 3))\n ≡⟨⟩\n suc (suc 5)\n ≡⟨⟩\n 7\n ∎\n\n _*_ : ℕ → ℕ → ℕ\n zero * n = zero\n (suc m) * n = n + (n * m)\n\n\n _ : 3 * 4 ≡ 12\n _ =\n begin\n 3 * 4\n ≡⟨⟩\n (suc 2) * 4\n ≡⟨⟩\n 4 + (4 * 2)\n ≡⟨⟩\n 4 + ((suc 3) * 2)\n ≡⟨⟩\n 4 + (2 + (2 * 3))\n ≡⟨⟩\n 4 + (2 + (suc 1 * 3))\n ≡⟨⟩\n 4 + (2 + (3 + (3 * 1)))\n ≡⟨⟩\n 4 + (2 + (3 + (suc 2 * 1)))\n ≡⟨⟩\n 4 + (2 + (3 + (1 + (1 * 2))))\n ≡⟨⟩\n 12\n ∎\n\n _^_ : ℕ → ℕ → ℕ\n n ^ zero = suc zero\n n ^ (suc m) = n * (n ^ m)\n\n _ : 3 ^ 4 ≡ 81\n _ =\n begin\n 3 ^ 4\n ≡⟨⟩\n 3 ^ (1 + 3)\n ≡⟨⟩\n 3 * (3 ^ 3)\n ≡⟨⟩\n 3 * (3 * (3 ^ 2))\n ≡⟨⟩\n 3 * (3 * (3 * (3 ^ 1)))\n ≡⟨⟩\n 3 * (3 * (3 * 3))\n ≡⟨⟩\n 81\n ∎\n\n _∸_ : ℕ → ℕ → ℕ\n m ∸ zero = m\n zero ∸ suc n = zero\n suc m ∸ suc n = m ∸ n\n\n _ : 5 ∸ 3 ≡ 2\n _ =\n begin\n 5 ∸ 3\n ≡⟨⟩\n (1 + 4) ∸ (1 + 2)\n ≡⟨⟩\n 4 ∸ 2\n ≡⟨⟩\n 3 ∸ 1\n ≡⟨⟩\n 2 ∸ 0\n ≡⟨⟩\n 2\n ∎\n\n _ : 2 ∸ 5 ≡ 0\n _ =\n begin\n 2 ∸ 5\n ≡⟨⟩\n 1 ∸ 4\n ≡⟨⟩\n 0 ∸ 3\n ≡⟨⟩\n 0\n ∎\n\n data Bin : Set where\n ⟨⟩ : Bin\n _O : Bin → Bin\n _I : Bin → Bin\n\n inc : Bin → Bin\n inc ⟨⟩ = ⟨⟩ I\n inc (p O) = p I\n inc (p I) = (inc p) O\n\n _ : inc (⟨⟩ O O O O) ≡ ⟨⟩ O O O I\n _ = refl\n\n _ : inc (⟨⟩ O O O I) ≡ ⟨⟩ O O I O\n _ = refl\n\n _ : inc (⟨⟩ O O I O) ≡ ⟨⟩ O O I I\n _ = refl\n\n _ : inc (⟨⟩ O O I I) ≡ ⟨⟩ O I O O\n _ = refl\n\n _ : inc (⟨⟩ I O I I) ≡ ⟨⟩ I I O O\n _ = refl\n\n to : ℕ → Bin\n to zero = ⟨⟩ O\n to (suc n) = inc (to n)\n\n from : Bin → ℕ\n from ⟨⟩ = zero\n from (p O) = from p * 2\n from (p I) = suc ((from p) * 2)\n\n _ : to 3 ≡ ⟨⟩ I I\n _ = refl\n\n _ : from (⟨⟩ I I) ≡ 3\n _ = refl\n", "meta": {"hexsha": "35077b0bf60002b445a1c6cc16fd55efa3d8140d", "size": 2974, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/plfa/working/Naturals.agda", "max_stars_repo_name": "kaychaks/plfa.github.io", "max_stars_repo_head_hexsha": "5365a4ba8ba0dc80cb77ab73aee92c645d0787d9", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/plfa/working/Naturals.agda", "max_issues_repo_name": "kaychaks/plfa.github.io", "max_issues_repo_head_hexsha": "5365a4ba8ba0dc80cb77ab73aee92c645d0787d9", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/plfa/working/Naturals.agda", "max_forks_repo_name": "kaychaks/plfa.github.io", "max_forks_repo_head_hexsha": "5365a4ba8ba0dc80cb77ab73aee92c645d0787d9", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 15.5706806283, "max_line_length": 54, "alphanum_fraction": 0.284129119, "num_tokens": 1444, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9149009480320036, "lm_q2_score": 0.847967764140929, "lm_q1q2_score": 0.7758065113131144}} {"text": "module Nat where\n\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\n_+_ : ℕ → ℕ → ℕ\nzero + a = a\nsuc a + b = suc (a + b)\n\ndata _≡_ {A : Set} : A → A → Set where\n refl : {a : A} → a ≡ a\n\ninfix 4 _≡_\n\ncong : {A B : Set} {a b : A} (f : A → B) → a ≡ b → f a ≡ f b\ncong f refl = refl\n\n+-assoc : (a b c : ℕ) → (a + b) + c ≡ a + (b + c)\n+-assoc zero b c = refl\n+-assoc (suc a) b c = cong suc (+-assoc a b c)\n", "meta": {"hexsha": "cba1fa9dbd68d565381e97c46eed596ce5ac9d38", "size": 398, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Nat.agda", "max_stars_repo_name": "divipp/agda-intro-prezi", "max_stars_repo_head_hexsha": "a8902e36ed2037de9008e061d54517d4d7d99f0f", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2018-11-27T02:50:48.000Z", "max_stars_repo_stars_event_max_datetime": "2020-01-21T14:53:25.000Z", "max_issues_repo_path": "Nat.agda", "max_issues_repo_name": "divipp/agda-intro-prezi", "max_issues_repo_head_hexsha": "a8902e36ed2037de9008e061d54517d4d7d99f0f", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Nat.agda", "max_forks_repo_name": "divipp/agda-intro-prezi", "max_forks_repo_head_hexsha": "a8902e36ed2037de9008e061d54517d4d7d99f0f", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.0909090909, "max_line_length": 60, "alphanum_fraction": 0.4623115578, "num_tokens": 185, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.965899575269305, "lm_q2_score": 0.803173801068221, "lm_q1q2_score": 0.775785233319228}} {"text": "------------------------------------------------------------------------------\n-- Axiomatic PA properties\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule PA.Axiomatic.Standard.PropertiesI where\n\nopen import Common.FOL.Relation.Binary.EqReasoning\n\nopen import PA.Axiomatic.Standard.Base\n\n------------------------------------------------------------------------------\n-- Congruence properties\n\nsuccCong : ∀ {m n} → m ≡ n → succ m ≡ succ n\nsuccCong refl = refl\n\n+-leftCong : ∀ {m n o} → m ≡ n → m + o ≡ n + o\n+-leftCong refl = refl\n\n+-rightCong : ∀ {m n o} → n ≡ o → m + n ≡ m + o\n+-rightCong refl = refl\n\n------------------------------------------------------------------------------\n\n+-leftIdentity : ∀ n → zero + n ≡ n\n+-leftIdentity = PA₃\n\n+-rightIdentity : ∀ n → n + zero ≡ n\n+-rightIdentity = ℕ-ind A A0 is\n where\n A : ℕ → Set\n A i = i + zero ≡ i\n\n A0 : A zero\n A0 = +-leftIdentity zero\n\n is : ∀ i → A i → A (succ i)\n is i ih = succ i + zero ≡⟨ PA₄ i zero ⟩\n succ (i + zero) ≡⟨ succCong ih ⟩\n succ i ∎\n\n+-asocc : ∀ m n o → m + n + o ≡ m + (n + o)\n+-asocc m n o = ℕ-ind A A0 is m\n where\n A : ℕ → Set\n A i = i + n + o ≡ i + (n + o)\n\n A0 : A zero\n A0 = zero + n + o ≡⟨ +-leftCong (+-leftIdentity n) ⟩\n n + o ≡⟨ sym (+-leftIdentity (n + o)) ⟩\n zero + (n + o) ∎\n\n is : ∀ i → A i → A (succ i)\n is i ih = succ i + n + o ≡⟨ +-leftCong (PA₄ i n) ⟩\n succ (i + n) + o ≡⟨ PA₄ (i + n) o ⟩\n succ (i + n + o) ≡⟨ succCong ih ⟩\n succ (i + (n + o)) ≡⟨ sym (PA₄ i (n + o)) ⟩\n succ i + (n + o) ∎\n\nx+Sy≡S[x+y] : ∀ m n → m + succ n ≡ succ (m + n)\nx+Sy≡S[x+y] m n = ℕ-ind A A0 is m\n where\n A : ℕ → Set\n A i = i + succ n ≡ succ (i + n)\n\n A0 : A zero\n A0 = zero + succ n ≡⟨ +-leftIdentity (succ n) ⟩\n succ n ≡⟨ succCong (sym (+-leftIdentity n)) ⟩\n succ (zero + n) ∎\n\n is : ∀ i → A i → A (succ i)\n is i ih = succ i + succ n ≡⟨ PA₄ i (succ n) ⟩\n succ (i + succ n) ≡⟨ succCong ih ⟩\n succ (succ (i + n)) ≡⟨ succCong (sym (PA₄ i n)) ⟩\n succ (succ i + n) ∎\n\n+-comm : ∀ m n → m + n ≡ n + m\n+-comm m n = ℕ-ind A A0 is m\n where\n A : ℕ → Set\n A i = i + n ≡ n + i\n\n A0 : A zero\n A0 = zero + n ≡⟨ +-leftIdentity n ⟩\n n ≡⟨ sym (+-rightIdentity n) ⟩\n n + zero ∎\n\n is : ∀ i → A i → A (succ i)\n is i ih = succ i + n ≡⟨ PA₄ i n ⟩\n succ (i + n) ≡⟨ succCong ih ⟩\n succ (n + i) ≡⟨ sym (x+Sy≡S[x+y] n i) ⟩\n n + succ i ∎\n", "meta": {"hexsha": "f884f7fa85c7226fc6b40bcbb94bcac94459118a", "size": 2747, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/PA/Axiomatic/Standard/PropertiesI.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/PA/Axiomatic/Standard/PropertiesI.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/PA/Axiomatic/Standard/PropertiesI.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 28.0306122449, "max_line_length": 78, "alphanum_fraction": 0.4022570076, "num_tokens": 1004, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9407897442783526, "lm_q2_score": 0.824461928533133, "lm_q1q2_score": 0.7756453269119237}} {"text": "module List.Order.Bounded {A : Set}(_≤_ : A → A → Set) where\n\nopen import Bound.Total A\nopen import Bound.Total.Order _≤_\nopen import Data.List\n\ndata _≤*_ : List A → Bound → Set where\n lenx : {t : Bound} → [] ≤* t\n lecx : {t : Bound}{x : A}{xs : List A} → LeB (val x) t → xs ≤* t → (x ∷ xs) ≤* t\n\ndata _*≤_ : Bound → List A → Set where\n genx : {b : Bound} → b *≤ []\n gecx : {b : Bound}{x : A}{xs : List A} → LeB b (val x) → b *≤ xs → b *≤ (x ∷ xs)\n", "meta": {"hexsha": "05b689d82ee781ee9b1f03d25629876fb9d5a3d4", "size": 453, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/List/Order/Bounded.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/List/Order/Bounded.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/List/Order/Bounded.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.3571428571, "max_line_length": 82, "alphanum_fraction": 0.5342163355, "num_tokens": 188, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9626731169394881, "lm_q2_score": 0.8056321959813275, "lm_q1q2_score": 0.7755604572121491}} {"text": "module Id1 where\n\nimport Level\nopen import Data.Empty using (⊥)\nopen import Data.Unit using (⊤)\nopen import Data.Bool using (Bool)\nopen import Data.Sum using (_⊎_)\nopen import Data.Nat \nopen import Data.Product\nopen import Data.Vec \nopen import Function using (id)\n\n-- Study identity types from first principles\n\n-- As we have seen for the previous types, we need to define the type,\n-- its constructors, and then focus on the recursion and induction\n-- principles. All computations and all properties of the identity\n-- type should be derivable from these (recursion and induction)\n-- principles.\n\n------------------------------------------------------------------------------\n\ndata _≡_ {A : Set} : (x y : A) → Set where\n refl : (x : A) → x ≡ x\n\n-- We have to write (refl x) for some x. This is different from the\n-- Agda library which leaves the 'x' implicit\n\ninfix 4 _≡_\n\n{-- \nConvention:\nmultiplicative precedence 7\nadditive precedence 6\nequality and comparison precedence 4 \n--}\n\n-- Simple examples\n\nprivate\n p₁ : 3 ≡ 3\n p₁ = refl 3\n\n p₂ : 3 * 1 ≡ 1 + 2\n p₂ = refl (4 ∸ 1)\n \n-- Let's try to derive the recursion principle for identity\n-- types... This type has one constructor just like ⊤ in some sense.\n-- Recall the recursion principle for ⊤:\n-- rec⊤ : (C : Set) → C → (v : ⊤) → C\n\n-- So at first approximation, the recursion principle for ≡ looks like:\n\n-- \n-- rec≡ : (C : Set) → C → ({A : Set} {x y : A} (p : x ≡ y) → C)\n-- \n\n-- In the case of ⊤, we wanted to map the element of ⊤ to an element\n-- of C. For ≡, we also want to map the element of (x ≡ y) to an\n-- element of C. Note that the element of (x ≡ y) is some kind of\n-- relation between x and y so it makes sense to insist that the\n-- target C is also a relation between x and y, i.e., we map relations\n-- to relations.\n\n-- So as a second approximation, the recursion principle for ≡ looks like:\n\n--\n-- rec≡ : {A : Set} {x y : A} → \n-- (R : A → A → Set) → R x y → (p : x ≡ y) → R x y\n-- \n\n-- In the case of ⊤, the second argument to the recursion operation\n-- specified an element of C which would serve as the target for\n-- tt. Now in the case of ≡, we want to specify an element of R x y\n-- which would be the target of refl. This requires two adjustments:\n-- first the second argument of type (R x y) makes no sense in general\n-- as we don't want to insist that the relation R is universal (i.e.,\n-- holds between arbitrary x and y). Second we must insist that the\n-- relation R is reflexive. \n\nrec≡ : {A : Set} →\n (R : A → A → Set) {reflexiveR : {a : A} → R a a} →\n ({x y : A} (p : x ≡ y) → R x y)\nrec≡ R {reflR} (refl y) = reflR {y}\n\n-- A special case of reflexive relations on A is the class of\n-- functions from C a -> C a for some predicate C. Let's specialize\n-- the above recursion principle to this special case.\n\nrec≡S : {A : Set} {C : A → Set} →\n ({x y : A} (p : x ≡ y) → C x → C y)\nrec≡S {C = C} p = rec≡ (λ a b → C a → C b) {id} p\n \n-- Or we can prove the specialized version directly (rename to subst)\n\nsubst : {A : Set} {C : A → Set} →\n ({x y : A} (p : x ≡ y) → C x → C y)\nsubst {x = x} {y = .x} (refl .x) = id\n\n-- So the recursion principle for the identity type says\n-- equals may be substituted for equals OR \n-- indiscernability of identicals OR \n-- every type family respects equality\n\n-- Examples:\n\nprivate\n\n ex₁ : ∀ {n} → (p : n + 0 ≡ n) → (n + 0 > 0) → (n > 0) \n ex₁ {n} p = subst {C = λ m → m > 0} {n + 0} {n} p\n\n ex₂ : ∀ {A n} → (p : n + 0 ≡ n) → (Vec A (n + 0)) → (Vec A n)\n ex₂ {A} {n} p = subst {C = λ m → Vec A m} {n + 0} {n} p\n\n {-- \n\n From Data.Nat library:\n\n data _≤_ : Rel ℕ Level.zero where\n z≤n : ∀ {n} → zero ≤ n\n s≤s : ∀ {m n} (m≤n : m ≤ n) → suc m ≤ suc n\n\n --}\n\n ≤-reflexive : {a : ℕ} → a ≤ a\n ≤-reflexive {zero} = z≤n \n ≤-reflexive {suc a} = s≤s (≤-reflexive {a}) \n\n ex₃ : ∀ {n} → (p : n + 0 ≡ n) → (n + 0 ≤ n)\n ex₃ {n} = rec≡ {ℕ} (_≤_) {≤-reflexive} {n + 0} {n}\n\n------------------------------------------------------------------------------\n-- Now let's look at the induction principle for identity types\n\n-- Our usual idiom is to use the same code for the recursion principle\n-- and just make the eliminator a dependent function\n\n-- Let's look at rec≡ again\n\n-- rec≡ : {A : Set} →\n-- (R : A → A → Set) {reflexiveR : {a : A} → R a a} →\n-- ({x y : A} (p : x ≡ y) → R x y)\n-- rec≡ R {reflR} (refl y) = reflR {y}\n\n-- The relation R is already dependent on x and y; we just need to\n-- make it dependent on p too\n\nind≡ : {A : Set} → \n (R : (x : A) → (y : A) → (p : x ≡ y) → Set)\n {reflexiveR : {a : A} → R a a (refl a)} →\n ({x y : A} (p : x ≡ y) → R x y p)\nind≡ R {reflR} (refl y) = reflR {y}\n\n-- Changing some implicit argument to being explicit and vice-versa,\n-- and changing names of bound variables we get:\n\nJ : {A : Set} →\n (R : {x y : A} → (p : x ≡ y) → Set)\n (r : (a : A) → R (refl a)) →\n ({a b : A} (p : a ≡ b) → R p)\nJ R r (refl y) = r y\n\n-- Examples\n\nsym : {A : Set} {x y : A} → (x ≡ y) → (y ≡ x)\nsym = J (λ {x} {y} p → y ≡ x) (λ a → refl a)\n\n-- Next we want to prove:\n-- trans : {A : Set} {x y z : A} → (x ≡ y) → (y ≡ z) → (x ≡ z)\n-- if we try to directly use J we discover that the definition of R \n-- (λ {x} {y} p → y ≡ z → x ≡ z)\n-- refers to an unbound z\n\ntrans' : {A : Set} {x y : A} → (x ≡ y) → ((z : A) → (q : y ≡ z) → (x ≡ z))\ntrans' {A} = \n J (λ {x} {y} p → ((z : A) → (q : y ≡ z) → (x ≡ z)))\n (λ a z → id)\n\n-- then\n\ntrans : {A : Set} {x y z : A} → (x ≡ y) → (y ≡ z) → (x ≡ z)\ntrans {A} {x} {y} {z} p q = trans' {A} {x} {y} p z q\n\n-- trans' refl q will simplify to q because we did induction on the first argument\n\nidR : {A : Set} {x y : A} (q : x ≡ y) → trans (refl x) q ≡ q\nidR q = refl q\n\n-- but trans' p refl will NOT simplify\n\n-- idL : {A : Set} {x y : A} (p : x ≡ y) → trans p (refl y) ≡ p\n-- idL p = refl p -- does not work\n\n-- We can do induction on the right and get the reverse situation\n-- OR we can do induction twice and lose BOTH and ONLY get\n-- trans refl refl = refl\n-- Even though this seems \"worse\", it is symmetric at least and easy to work is.\n\ntrans2' : {A : Set} {x y : A} → (x ≡ y) → ((z : A) → (q : y ≡ z) → (x ≡ z))\ntrans2' {A} =\n J (λ {x} {y} p → ((z : A) → (q : y ≡ z) → (x ≡ z)))\n (λ a z → J (λ {x'} {y'} q → x' ≡ y') (λ b → refl b))\n\ntrans2 : {A : Set} {x y z : A} → (x ≡ y) → (y ≡ z) → (x ≡ z)\ntrans2 {A} {x} {y} {z} p q = trans2' {A} {x} {y} p z q\n\nidLR : {A : Set} {a : A} → trans2 (refl a) (refl a) ≡ refl a\nidLR {A} {a} = refl (refl a)\n\n------------------------------------------------------------------------------\n\n-- If we restrict ourselves to proofs about \"points\" like numbers,\n-- booleans, etc. all we are saying is that if we normalize the\n-- calculation for each point they each reduce to same identical\n-- result. Things get much more interesting if we start thinking about\n-- identity in higher universes... So for example, say we want to\n-- prove that groups are the same, in that case we might have to prove\n-- that two types are the same etc. Unfortunately J by itself is\n-- helpless here... This motivates the univalence axiom to be discussed next...\n\n------------------------------------------------------------------------------\n", "meta": {"hexsha": "9ef58ff62d135584dbc2c014adcc7955085ff25e", "size": 7261, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Id1.agda", "max_stars_repo_name": "andmkent/misc-HoTT", "max_stars_repo_head_hexsha": "b05c58ffdaed99932ca2acc632deca8d14742b04", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-01-26T18:17:16.000Z", "max_stars_repo_stars_event_max_datetime": "2016-01-26T18:17:16.000Z", "max_issues_repo_path": "Id1.agda", "max_issues_repo_name": "andmkent/misc-HoTT", "max_issues_repo_head_hexsha": "b05c58ffdaed99932ca2acc632deca8d14742b04", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Id1.agda", "max_forks_repo_name": "andmkent/misc-HoTT", "max_forks_repo_head_hexsha": "b05c58ffdaed99932ca2acc632deca8d14742b04", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.7072072072, "max_line_length": 82, "alphanum_fraction": 0.5464812009, "num_tokens": 2543, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.938124016006303, "lm_q2_score": 0.8267117876664789, "lm_q1q2_score": 0.7755581823254273}} {"text": "{- \n\nThis is the Agda formalization of\n\n NOTIONS OF ANONYMOUS EXISTENCE IN MARTIN-LOF TYPE THEORY\n\n by\n\nNicolai Kraus, Martin Escardo, Thierry Coquand, Thorsten Altenkirch\n\nThis file stays very close to the article. Because of this, not all \nproofs are given in the way that is most elegant for a formalization. \nIn fact, often re-ordering statements would lead to a shorter \npresentation. The order that we have chosen in the article makes our \nresults, as we hope, understandable and gives sufficient motivation.\n\nThis file type check with Agda 2.4.2.5.\n-}\n\nmodule INDEX_NotionsOfAnonymousExistence where\n\n-- We use the following library files:\n\nopen import library.Basics hiding (Type ; Σ)\nopen import library.types.Sigma\nopen import library.types.Pi\nopen import library.types.Bool\nopen import library.NType2\nopen import library.types.Paths\n\n-- OUR FORMALIZATION\n\n-- Section 1: Introduction\n-- (no formalization)\n\n-- Section 2: Preliminaries\nopen import Sec2preliminaries\n\n-- Section 3: Hedberg's Theorem\nopen import Sec3hedberg\n\n-- Section 4: Collapsibility implies H-Stability\nopen import Sec4hasConstToSplit\n\n-- Section 5: Factorizing Weakly Constant Functions\nopen import Sec5factorConst\n\n-- Section 6: Populatedness\nopen import Sec6populatedness\n\n-- Section 7: Taboos and Counter-Models\nopen import Sec7taboos\n\n-- Section 8: Propositional Truncation with Judgmental Computation Rule\nopen import Sec8judgmentalBeta\n\n-- Section 9: Conclusion and Open Problems\n-- (no formalization)\n", "meta": {"hexsha": "6dfeaca766b9135ad6928ef22f401ee03681341c", "size": 1522, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "nicolai/anonymousExistence/INDEX_NotionsOfAnonymousExistence.agda", "max_stars_repo_name": "nicolaikraus/HoTT-Agda", "max_stars_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-06-30T00:17:55.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-30T00:17:55.000Z", "max_issues_repo_path": "nicolai/anonymousExistence/INDEX_NotionsOfAnonymousExistence.agda", "max_issues_repo_name": "nicolaikraus/HoTT-Agda", "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "nicolai/anonymousExistence/INDEX_NotionsOfAnonymousExistence.agda", "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.7966101695, "max_line_length": 71, "alphanum_fraction": 0.776609724, "num_tokens": 387, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9353465098415279, "lm_q2_score": 0.8289388083214156, "lm_q1q2_score": 0.7753450212356314}} {"text": "{-# OPTIONS --allow-unsolved-metas #-}\n------------------------------------------------------------------------------\n------------------------------------------------------------------------------\n-- CS410 2017/18 Exercise 1 VECTORS AND FRIENDS (worth 25%)\n------------------------------------------------------------------------------\n------------------------------------------------------------------------------\n\n-- NOTE (19/9/17) This file is currently incomplete: more will arrive on\n-- GitHub.\n\n-- MARK SCHEME (transcribed from paper): the (m) numbers add up to slightly\n-- more than 25, so should be taken as the maximum number of marks losable on\n-- the exercise. In fact, I did mark it negatively, but mostly because it was\n-- done so well (with Agda's help) that it was easier to find the errors.\n\n\n------------------------------------------------------------------------------\n-- Dependencies\n------------------------------------------------------------------------------\n\nopen import CS410-Prelude\n\n\n------------------------------------------------------------------------------\n-- Vectors\n------------------------------------------------------------------------------\n\ndata Vec (X : Set) : Nat -> Set where -- like lists, but length-indexed\n [] : Vec X zero\n _,-_ : {n : Nat} -> X -> Vec X n -> Vec X (suc n)\ninfixr 4 _,-_ -- the \"cons\" operator associates to the right\n\n-- I like to use the asymmetric ,- to remind myself that the element is to\n-- the left and the rest of the list is to the right.\n\n-- Vectors are useful when there are important length-related safety\n-- properties.\n\n\n------------------------------------------------------------------------------\n-- Heads and Tails\n------------------------------------------------------------------------------\n\n-- We can rule out nasty head and tail errors by insisting on nonemptiness!\n\n--??--1.1-(2)-----------------------------------------------------------------\n\nvHead : {X : Set}{n : Nat} -> Vec X (suc n) -> X\nvHead xs = {!!}\n\nvTail : {X : Set}{n : Nat} -> Vec X (suc n) -> Vec X n\nvTail xs = {!!}\n\nvHeadTailFact : {X : Set}{n : Nat}(xs : Vec X (suc n)) ->\n (vHead xs ,- vTail xs) == xs\nvHeadTailFact xs = {!!} \n\n--??--------------------------------------------------------------------------\n\n\n------------------------------------------------------------------------------\n-- Concatenation and its Inverse\n------------------------------------------------------------------------------\n\n--??--1.2-(2)-----------------------------------------------------------------\n\n_+V_ : {X : Set}{m n : Nat} -> Vec X m -> Vec X n -> Vec X (m +N n)\nxs +V ys = {!!}\ninfixr 4 _+V_\n\nvChop : {X : Set}(m : Nat){n : Nat} -> Vec X (m +N n) -> Vec X m * Vec X n\nvChop m xs = {!!}\n\nvChopAppendFact : {X : Set}{m n : Nat}(xs : Vec X m)(ys : Vec X n) ->\n vChop m (xs +V ys) == (xs , ys)\nvChopAppendFact xs ys = {!!}\n\n--??--------------------------------------------------------------------------\n\n\n------------------------------------------------------------------------------\n-- Map, take I\n------------------------------------------------------------------------------\n\n-- Implement the higher-order function that takes an operation on\n-- elements and does it to each element of a vector. Use recursion\n-- on the vector.\n-- Note that the type tells you the size remains the same.\n\n-- Show that if the elementwise function \"does nothing\", neither does\n-- its vMap. \"map of identity is identity\"\n\n-- Show that two vMaps in a row can be collapsed to just one, or\n-- \"composition of maps is map of compositions\"\n\n--??--1.3-(2)-----------------------------------------------------------------\n\nvMap : {X Y : Set} -> (X -> Y) -> {n : Nat} -> Vec X n -> Vec Y n\nvMap f xs = {!!}\n\nvMapIdFact : {X : Set}{f : X -> X}(feq : (x : X) -> f x == x) ->\n {n : Nat}(xs : Vec X n) -> vMap f xs == xs\nvMapIdFact feq xs = {!!}\n\nvMapCpFact : {X Y Z : Set}{f : Y -> Z}{g : X -> Y}{h : X -> Z}\n (heq : (x : X) -> f (g x) == h x) ->\n {n : Nat}(xs : Vec X n) ->\n vMap f (vMap g xs) == vMap h xs\nvMapCpFact heq xs = {!!}\n\n--??--------------------------------------------------------------------------\n\n\n------------------------------------------------------------------------------\n-- vMap and +V\n------------------------------------------------------------------------------\n\n-- Show that if you've got two vectors of Xs and a function from X to Y,\n-- and you want to concatenate and map, it doesn't matter which you do\n-- first.\n\n--??--1.4-(1)-----------------------------------------------------------------\n\nvMap+VFact : {X Y : Set}(f : X -> Y) ->\n {m n : Nat}(xs : Vec X m)(xs' : Vec X n) ->\n vMap f (xs +V xs') == (vMap f xs +V vMap f xs')\nvMap+VFact f xs xs' = {!!}\n\n--??--------------------------------------------------------------------------\n\n-- Think about what you could prove, relating vMap with vHead, vTail, vChop...\n-- Now google \"Philip Wadler\" \"Theorems for Free\"\n\n\n------------------------------------------------------------------------------\n-- Applicative Structure (giving mapping and zipping cheaply)\n------------------------------------------------------------------------------\n\n--??--1.5-(2)-----------------------------------------------------------------\n\n-- HINT: you will need to override the default invisibility of n to do this.\nvPure : {X : Set} -> X -> {n : Nat} -> Vec X n\nvPure x {n} = {!!}\n\n_$V_ : {X Y : Set}{n : Nat} -> Vec (X -> Y) n -> Vec X n -> Vec Y n\nfs $V xs = {!!}\ninfixl 3 _$V_ -- \"Application associates to the left,\n -- rather as we all did in the sixties.\" (Roger Hindley)\n\n-- Pattern matching and recursion are forbidden for the next two tasks.\n\n-- implement vMap again, but as a one-liner\nvec : {X Y : Set} -> (X -> Y) -> {n : Nat} -> Vec X n -> Vec Y n\nvec f xs = {!!}\n\n-- implement the operation which pairs up corresponding elements\nvZip : {X Y : Set}{n : Nat} -> Vec X n -> Vec Y n -> Vec (X * Y) n\nvZip xs ys = {!!}\n\n--??--------------------------------------------------------------------------\n\n\n------------------------------------------------------------------------------\n-- Applicative Laws\n------------------------------------------------------------------------------\n\n-- According to \"Applicative programming with effects\" by\n-- Conor McBride and Ross Paterson\n-- some laws should hold for applicative functors.\n-- Check that this is the case.\n\n--??--1.6-(2)-----------------------------------------------------------------\n\nvIdentity : {X : Set}{f : X -> X}(feq : (x : X) -> f x == x) ->\n {n : Nat}(xs : Vec X n) -> (vPure f $V xs) == xs\nvIdentity feq xs = {!!}\n\nvHomomorphism : {X Y : Set}(f : X -> Y)(x : X) ->\n {n : Nat} -> (vPure f $V vPure x) == vPure (f x) {n}\nvHomomorphism f x {n} = {!!}\n\nvInterchange : {X Y : Set}{n : Nat}(fs : Vec (X -> Y) n)(x : X) ->\n (fs $V vPure x) == (vPure (_$ x) $V fs)\nvInterchange fs x = {!!}\n\nvComposition : {X Y Z : Set}{n : Nat}\n (fs : Vec (Y -> Z) n)(gs : Vec (X -> Y) n)(xs : Vec X n) ->\n (vPure _<<_ $V fs $V gs $V xs) == (fs $V (gs $V xs))\nvComposition fs gs xs = {!!}\n\n--??--------------------------------------------------------------------------\n\n\n------------------------------------------------------------------------------\n-- Order-Preserving Embeddings (also known in the business as \"thinnings\")\n------------------------------------------------------------------------------\n\n-- What have these to do with Pascal's Triangle?\n\ndata _<=_ : Nat -> Nat -> Set where\n oz : zero <= zero\n os : {n m : Nat} -> n <= m -> suc n <= suc m\n o' : {n m : Nat} -> n <= m -> n <= suc m\n\n-- Find all the values in each of the following <= types.\n-- This is a good opportunity to learn to use C-c C-a with the -l option\n-- (a.k.a. \"google the type\" without \"I feel lucky\")\n-- The -s n option also helps.\n\n--??--1.7-(1)-----------------------------------------------------------------\n\nall0<=4 : Vec (0 <= 4) {!!}\nall0<=4 = {!!}\n\nall1<=4 : Vec (1 <= 4) {!!}\nall1<=4 = {!!}\n\nall2<=4 : Vec (2 <= 4) {!!}\nall2<=4 = {!!}\n \nall3<=4 : Vec (3 <= 4) {!!}\nall3<=4 = {!!}\n\nall4<=4 : Vec (4 <= 4) {!!}\nall4<=4 = {!!}\n\n-- Prove the following. A massive case analysis \"rant\" is fine.\n\nno5<=4 : 5 <= 4 -> Zero\nno5<=4 th = {!!}\n\n--??--------------------------------------------------------------------------\n\n\n------------------------------------------------------------------------------\n-- Order-Preserving Embeddings Select From Vectors\n------------------------------------------------------------------------------\n\n-- Use n <= m to encode the choice of n elements from an m-Vector.\n-- The os constructor tells you to take the next element of the vector;\n-- the o' constructor tells you to omit the next element of the vector.\n\n--??--1.8-(2)-----------------------------------------------------------------\n\n_ n <= m -> Vec X m\n -> Vec X n\nth Y)\n {n m : Nat}(th : n <= m)(xs : Vec X m) ->\n vMap f (th n <= n\noi {n} = {!!}\n\noe : {n : Nat} -> 0 <= n\noe {n} = {!!}\n\n--??--------------------------------------------------------------------------\n\n\n-- Show that all empty thinnings are equal to yours.\n\n--??--1.10-(1)----------------------------------------------------------------\n\noeUnique : {n : Nat}(th : 0 <= n) -> th == oe\noeUnique i = {!!}\n\n--??--------------------------------------------------------------------------\n\n\n-- Show that there are no thinnings of form big <= small (TRICKY)\n-- Then show that all the identity thinnings are equal to yours.\n-- Note that you can try the second even if you haven't finished the first.\n-- HINT: you WILL need to expose the invisible numbers.\n-- HINT: check CS410-Prelude for a reminder of >=\n\n--??--1.11-(3)----------------------------------------------------------------\n\noTooBig : {n m : Nat} -> n >= m -> suc n <= m -> Zero\noTooBig {n} {m} n>=m th = {!!}\n\noiUnique : {n : Nat}(th : n <= n) -> th == oi\noiUnique th = {!!}\n\n--??--------------------------------------------------------------------------\n\n\n-- Show that the identity thinning selects the whole vector\n\n--??--1.12-(1)----------------------------------------------------------------\n\nid- (oi >_ : {p n m : Nat} -> p <= n -> n <= m -> p <= m\nth o>> th' = {!!}\n\ncp-\n {X : Set}(xs : Vec X m) ->\n ((th o>> th') > : {n m : Nat}(th : n <= m) -> (oi o>> th) == th\nidThen-o>> th = {!!}\n\nidAfter-o>> : {n m : Nat}(th : n <= m) -> (th o>> oi) == th\nidAfter-o>> th = {!!}\n\nassoc-o>> : {q p n m : Nat}(th0 : q <= p)(th1 : p <= n)(th2 : n <= m) ->\n ((th0 o>> th1) o>> th2) == (th0 o>> (th1 o>> th2))\nassoc-o>> th0 th1 th2 = {!!}\n\n--??--------------------------------------------------------------------------\n\n\n------------------------------------------------------------------------------\n-- Vectors as Arrays\n------------------------------------------------------------------------------\n\n-- We can use 1 <= n as the type of bounded indices into a vector and do\n-- a kind of \"array projection\". First we select a 1-element vector from\n-- the n-element vector, then we take its head to get the element out.\n\nvProject : {n : Nat}{X : Set} -> Vec X n -> 1 <= n -> X\nvProject xs i = vHead (i (1 <= n -> X) -> Vec X n\nvTabulate {n} f = {!!}\n\n-- This should be easy if vTabulate is correct.\nvTabulateProjections : {n : Nat}{X : Set}(xs : Vec X n) ->\n vTabulate (vProject xs) == xs\nvTabulateProjections xs = {!!}\n\n-- HINT: oeUnique\nvProjectFromTable : {n : Nat}{X : Set}(f : 1 <= n -> X)(i : 1 <= n) ->\n vProject (vTabulate f) i == f i\nvProjectFromTable f i = {!!}\n\n--??--------------------------------------------------------------------------\n", "meta": {"hexsha": "75c052b25e1ac227bc906c3434739d59a9849bd2", "size": 13994, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/course/2017-conor_mcbride_cs410/CS410-17-master/exercises/Ex1.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/course/2017-conor_mcbride_cs410/CS410-17-master/exercises/Ex1.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/course/2017-conor_mcbride_cs410/CS410-17-master/exercises/Ex1.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 36.2538860104, "max_line_length": 78, "alphanum_fraction": 0.3686579963, "num_tokens": 3240, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473779969194, "lm_q2_score": 0.888758801595206, "lm_q1q2_score": 0.7753064102432623}} {"text": "-- Simple test to check if constraint solving for injective\n-- functions is working.\nmodule Injectivity where\n\ndata Nat : Set where\n zero : Nat\n suc : Nat -> Nat\n\n_+_ : Nat -> Nat -> Nat\nzero + m = m\nsuc n + m = suc (n + m)\n\n{-# BUILTIN NATURAL Nat #-}\n{-# BUILTIN ZERO zero #-}\n{-# BUILTIN SUC suc #-}\n{-# BUILTIN NATPLUS _+_ #-}\n\ninfixr 40 _::_\ndata List (A : Set) : Set where\n [] : List A\n _::_ : A -> List A -> List A\n\nfoldr : {A B : Set} -> (A -> B -> B) -> B -> List A -> B\nfoldr f z [] = z\nfoldr f z (x :: xs) = f x (foldr f z xs)\n\ndata U : Set where\n nat : U\n list : U -> U\n\nEl : U -> Set\nEl nat = Nat\nEl (list a) = List (El a)\n\nsum : {a : U} -> El a -> Nat\nsum {nat} n = n\nsum {list a} xs = foldr (\\a b -> sum a + b) zero xs\n\ndata _==_ {A : Set}(x : A) : A -> Set where\n refl : x == x\n\ntest₁ = sum (1 :: 2 :: 3 :: [])\n\nok₁ : test₁ == 6\nok₁ = refl\n\ntest₂ = sum ((1 :: []) :: (3 :: 5 :: []) :: [])\n\nok₂ : test₂ == 9\nok₂ = refl\n\n", "meta": {"hexsha": "c9aafa6d9ee1effab2cdc4dc7e0777f3a1172ce1", "size": 973, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/succeed/Injectivity.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T07:26:06.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T07:26:06.000Z", "max_issues_repo_path": "test/succeed/Injectivity.agda", "max_issues_repo_name": "np/agda-git-experiment", "max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/succeed/Injectivity.agda", "max_forks_repo_name": "np/agda-git-experiment", "max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.7115384615, "max_line_length": 59, "alphanum_fraction": 0.4964028777, "num_tokens": 365, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9230391579526934, "lm_q2_score": 0.839733963661418, "lm_q1q2_score": 0.7751073307223129}} {"text": "\nopen import Common.Prelude\nopen import Common.Equality\n\ninfixr 5 _∷_\n\ndata Vec (A : Set) : Nat → Set where\n [] : Vec A zero\n _∷_ : ∀ {n} → A → Vec A n → Vec A (suc n)\n\nrecord Eq (A : Set) : Set where\n field\n _==_ : (x y : A) → Maybe (x ≡ y)\n\nopen Eq {{...}}\n\ndata Σ (A : Set) (B : A → Set) : Set where\n _,_ : (x : A) → B x → Σ A B\n\neqNat : ∀ n m → Maybe (n ≡ m)\neqNat zero zero = just refl\neqNat zero (suc m) = nothing\neqNat (suc n) zero = nothing\neqNat (suc n) (suc m) with eqNat n m\neqNat (suc n) (suc m) | nothing = nothing\neqNat (suc n) (suc .n) | just refl = just refl\n\neqVec : ∀ {A n} {{EqA : Eq A}} (xs ys : Vec A n) → Maybe (xs ≡ ys)\neqVec [] [] = just refl\neqVec (x ∷ xs) ( y ∷ ys) with x == y | eqVec xs ys\neqVec (x ∷ xs) ( y ∷ ys) | nothing | _ = nothing\neqVec (x ∷ xs) ( y ∷ ys) | _ | nothing = nothing\neqVec (x ∷ xs) (.x ∷ .xs) | just refl | just refl = just refl\n\neqSigma : ∀ {A B} {{EqA : Eq A}} {{EqB : ∀ {x} → Eq (B x)}} (x y : Σ A B) → Maybe (x ≡ y)\neqSigma (x , y) (x₁ , y₁) with x == x₁\neqSigma (x , y) (x₁ , y₁) | nothing = nothing\neqSigma (x , y) (.x , y₁) | just refl with y == y₁\neqSigma (x , y) (.x , y₁) | just refl | nothing = nothing\neqSigma (x , y) (.x , .y) | just refl | just refl = just refl\n\ninstance\n EqNat : Eq Nat\n EqNat = record { _==_ = eqNat }\n\n EqVec : ∀ {A n} {{_ : Eq A}} → Eq (Vec A n)\n EqVec = record { _==_ = eqVec }\n\n EqSigma : ∀ {A B} {{_ : Eq A}} {{_ : ∀ {x} → Eq (B x)}} → Eq (Σ A B)\n EqSigma = record { _==_ = eqSigma }\n\ncmpSigma : (xs ys : Σ Nat (Vec Nat)) → Maybe (xs ≡ ys)\ncmpSigma xs ys = xs == ys\n", "meta": {"hexsha": "e099c6ebd303784b5c639810b8160d4b6e570e14", "size": 1601, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/DependentInstanceSearch.agda", "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_issues_repo_path": "test/Succeed/DependentInstanceSearch.agda", "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/Succeed/DependentInstanceSearch.agda", "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.6481481481, "max_line_length": 89, "alphanum_fraction": 0.519675203, "num_tokens": 669, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9324533051062237, "lm_q2_score": 0.8311430520409023, "lm_q1q2_score": 0.7750020858916135}} {"text": "{-# OPTIONS --without-K --safe #-}\nmodule Categories.Category.Dagger where\n\nopen import Level using (_⊔_; suc)\nopen import Relation.Unary using (Pred)\n\nopen import Categories.Category.Core using (Category)\nopen import Categories.Functor.Core using (Functor)\nopen import Categories.Morphism using (Iso)\n\nrecord HasDagger {o ℓ e} (C : Category o ℓ e) : Set (o ⊔ ℓ ⊔ e) where\n open Category C\n infix 10 _†\n\n field\n _† : ∀ {A B} → A ⇒ B → B ⇒ A\n †-identity : ∀ {A} → id {A} † ≈ id\n †-homomorphism : ∀ {A B C} {f : A ⇒ B} {g : B ⇒ C} → (g ∘ f) † ≈ f † ∘ g †\n †-resp-≈ : ∀ {A B} {f g : A ⇒ B} → f ≈ g → f † ≈ g †\n †-involutive : ∀ {A B} (f : A ⇒ B) → f † † ≈ f\n\n †-Functor : Functor op C\n †-Functor = record\n { F₀ = λ A → A\n ; F₁ = _†\n ; identity = †-identity\n ; homomorphism = †-homomorphism\n ; F-resp-≈ = †-resp-≈\n }\n\n isUnitary : ∀ {A B} → Pred (A ⇒ B) e\n isUnitary f = Iso C f (f †)\n\n isSelfAdjoint : ∀ {A} → Pred (A ⇒ A) e\n isSelfAdjoint f = f † ≈ f\n\nrecord DaggerCategory o ℓ e : Set (suc (o ⊔ ℓ ⊔ e)) where\n field\n C : Category o ℓ e\n hasDagger : HasDagger C\n\n open Category C public\n open HasDagger hasDagger public\n", "meta": {"hexsha": "bdd8ef843121e6674ad0c43a76b92ab3832a2b5d", "size": 1169, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Dagger.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Category/Dagger.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Category/Dagger.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 26.5681818182, "max_line_length": 78, "alphanum_fraction": 0.5620188195, "num_tokens": 474, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9343951552333004, "lm_q2_score": 0.8289388146603365, "lm_q1q2_score": 0.7745564124034532}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- A bunch of properties about natural number operations\n------------------------------------------------------------------------\n\nmodule Data.Nat.Properties.Simple where\n\nopen import Data.Nat as Nat\nopen import Function\nopen import Relation.Binary.PropositionalEquality as PropEq\n using (_≡_; _≢_; refl; sym; cong; cong₂)\nopen PropEq.≡-Reasoning\nopen import Data.Product\nopen import Data.Sum\n\n------------------------------------------------------------------------\n\n+-assoc : ∀ m n o → (m + n) + o ≡ m + (n + o)\n+-assoc zero _ _ = refl\n+-assoc (suc m) n o = cong suc $ +-assoc m n o\n\n+-right-identity : ∀ n → n + 0 ≡ n\n+-right-identity zero = refl\n+-right-identity (suc n) = cong suc $ +-right-identity n\n\n+-suc : ∀ m n → m + suc n ≡ suc (m + n)\n+-suc zero n = refl\n+-suc (suc m) n = cong suc (+-suc m n)\n\n+-comm : ∀ m n → m + n ≡ n + m\n+-comm zero n = sym $ +-right-identity n\n+-comm (suc m) n =\n begin\n suc m + n\n ≡⟨ refl ⟩\n suc (m + n)\n ≡⟨ cong suc (+-comm m n) ⟩\n suc (n + m)\n ≡⟨ sym (+-suc n m) ⟩\n n + suc m\n ∎\n\n+-*-suc : ∀ m n → m * suc n ≡ m + m * n\n+-*-suc zero n = refl\n+-*-suc (suc m) n =\n begin\n suc m * suc n\n ≡⟨ refl ⟩\n suc n + m * suc n\n ≡⟨ cong (λ x → suc n + x) (+-*-suc m n) ⟩\n suc n + (m + m * n)\n ≡⟨ refl ⟩\n suc (n + (m + m * n))\n ≡⟨ cong suc (sym $ +-assoc n m (m * n)) ⟩\n suc (n + m + m * n)\n ≡⟨ cong (λ x → suc (x + m * n)) (+-comm n m) ⟩\n suc (m + n + m * n)\n ≡⟨ cong suc (+-assoc m n (m * n)) ⟩\n suc (m + (n + m * n))\n ≡⟨ refl ⟩\n suc m + suc m * n\n ∎\n\n*-right-zero : ∀ n → n * 0 ≡ 0\n*-right-zero zero = refl\n*-right-zero (suc n) = *-right-zero n\n\n*-comm : ∀ m n → m * n ≡ n * m\n*-comm zero n = sym $ *-right-zero n\n*-comm (suc m) n =\n begin\n suc m * n\n ≡⟨ refl ⟩\n n + m * n\n ≡⟨ cong (λ x → n + x) (*-comm m n) ⟩\n n + n * m\n ≡⟨ sym (+-*-suc n m) ⟩\n n * suc m\n ∎\n\ndistribʳ-*-+ : ∀ m n o → (n + o) * m ≡ n * m + o * m\ndistribʳ-*-+ m zero o = refl\ndistribʳ-*-+ m (suc n) o =\n begin\n (suc n + o) * m\n ≡⟨ refl ⟩\n m + (n + o) * m\n ≡⟨ cong (_+_ m) $ distribʳ-*-+ m n o ⟩\n m + (n * m + o * m)\n ≡⟨ sym $ +-assoc m (n * m) (o * m) ⟩\n m + n * m + o * m\n ≡⟨ refl ⟩\n suc n * m + o * m\n ∎\n\n*-assoc : ∀ m n o → (m * n) * o ≡ m * (n * o)\n*-assoc zero n o = refl\n*-assoc (suc m) n o =\n begin\n (suc m * n) * o\n ≡⟨ refl ⟩\n (n + m * n) * o\n ≡⟨ distribʳ-*-+ o n (m * n) ⟩\n n * o + (m * n) * o\n ≡⟨ cong (λ x → n * o + x) $ *-assoc m n o ⟩\n n * o + m * (n * o)\n ≡⟨ refl ⟩\n suc m * (n * o)\n ∎\n", "meta": {"hexsha": "6c5cb93c5abd78775059fbbb22d5917b66fe6ce7", "size": 2630, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Data/Nat/Properties/Simple.agda", "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_issues_repo_path": "agda-stdlib-0.9/src/Data/Nat/Properties/Simple.agda", "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib-0.9/src/Data/Nat/Properties/Simple.agda", "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.6936936937, "max_line_length": 72, "alphanum_fraction": 0.4182509506, "num_tokens": 1112, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9362850093037731, "lm_q2_score": 0.8267117962054048, "lm_q1q2_score": 0.7740378618017164}} {"text": "\n-- statically checked sorted lists\n-- see http://www2.tcs.ifi.lmu.de/~abel/DepTypes.pdf\n\nmodule SortedList where\n\nopen import Data.Nat using (ℕ; zero; suc; _+_; _*_)\nopen import Data.Bool using (Bool; true; false)\n\n----------------------------------------------------------------------\n-- Curry-Howard stuff\n\nProposition = Set\n\n-- intentionally blank. signifies the empty set in the type system.\ndata Absurd : Proposition where\n\n-- tt = trivially true\ndata Truth : Proposition where\n tt : Truth\n\n-- ∧ = conjunction\ndata _∧_ (A B : Proposition) : Proposition where\n _,_ : A → B → A ∧ B\n\nfst : {A B : Proposition} → A ∧ B → A\nfst (a , b) = a\n\nsnd : {A B : Proposition} → A ∧ B → B\nsnd (a , b) = b\n\n-- Cartesian product = conjunction\n_×_ = _∧_\n\n-- ∨ = disjunction\ndata _∨_ (A B : Proposition) : Proposition where\n inl : A → A ∨ B\n inr : B → A ∨ B\n\n-- given: A or B is true, A implies C, B implies C. then C is true.\ncase : {A B C : Proposition} → A ∨ B → (A → C) → (B → C) → C\ncase (inl a) f g = f a\ncase (inr b) f g = g b\n\n-- map booleans to propositions by mapping true to Truth and false to Absurd\nTrue : Bool → Proposition\nTrue true = Truth\nTrue false = Absurd\n\n----------------------------------------------------------------------\n\n_≤_ : ℕ → ℕ → Bool\nzero ≤ n = true\nsuc m ≤ zero = false\nsuc m ≤ suc n = m ≤ n\n\n-- proposition: ≤ is reflexive. proof: induction.\nrefl≤ : (n : ℕ) → True (n ≤ n)\nrefl≤ zero = tt\nrefl≤ (suc n) = refl≤ n\n\n----------------------------------------------------------------------\n\ndata SortedList : ℕ → Set where\n ∅ : SortedList zero\n ⋉ : {n : ℕ} (m : ℕ) → True (n ≤ m) → SortedList n → SortedList m\n\n-- the arguments to ⋉ are\n-- m : a natural number to prepend to the given sorted list xs\n-- p : a proof that m (the new head) is ≥ head xs\n-- xs : a list such that head xs = n\n\n-- for constant natural numbers, proofs that n ≤ m are trivial since\n-- ≤ is decidable; this is why we pass in `tt` in the examples below\n\n-- examples:\none : ℕ\none = suc zero\n\ns1 = ⋉ one tt (⋉ zero tt ∅)\n-- s2 = ⋉ zero tt (⋉ one tt ∅) -- fails statically, as desired\ns3 = ⋉ one tt s1 -- normal form: ⋉ 1 tt (⋉ 1 tt (⋉ 0 tt ∅))\ns4 = ⋉ (suc one) tt s1 -- normal form: ⋉ 2 tt (⋉ 1 tt (⋉ 0 tt ∅))\n\n", "meta": {"hexsha": "815d3a9f967f4ac1f6d3bd8f1ebc2b6a4cb6a3cf", "size": 2214, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "SortedList.agda", "max_stars_repo_name": "sshastry/agda-examples", "max_stars_repo_head_hexsha": "e70ef1ea1891cff6157fba682a61c6f227a26fd8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "SortedList.agda", "max_issues_repo_name": "sshastry/agda-examples", "max_issues_repo_head_hexsha": "e70ef1ea1891cff6157fba682a61c6f227a26fd8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "SortedList.agda", "max_forks_repo_name": "sshastry/agda-examples", "max_forks_repo_head_hexsha": "e70ef1ea1891cff6157fba682a61c6f227a26fd8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.0470588235, "max_line_length": 76, "alphanum_fraction": 0.5555555556, "num_tokens": 722, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9465966702001757, "lm_q2_score": 0.8175744761936437, "lm_q1q2_score": 0.7739132768055559}} {"text": "\nmodule Haskell.Prim.Tuple where\n\nopen import Agda.Builtin.List\n\nopen import Haskell.Prim\n\nprivate\n variable\n as : List Set\n\n--------------------------------------------------\n-- Tuples\n\ninfixr 5 _∷_\ndata Tuple : List Set → Set where\n [] : Tuple []\n _∷_ : a → Tuple as → Tuple (a ∷ as)\n\ninfix 3 _×_ _×_×_\n\n_×_ : (a b : Set) → Set\na × b = Tuple (a ∷ b ∷ [])\n\n_×_×_ : (a b c : Set) → Set\na × b × c = Tuple (a ∷ b ∷ c ∷ [])\n\ninfix -1 _,_ _,_,_\n\npattern _,_ x y = x Tuple.∷ y Tuple.∷ []\npattern _,_,_ x y z = x Tuple.∷ y Tuple.∷ z Tuple.∷ []\n\nuncurry : (a → b → c) → a × b → c\nuncurry f (x , y) = f x y\n\ncurry : (a × b → c) → a → b → c\ncurry f x y = f (x , y)\n\nfst : a × b → a\nfst (x , _) = x\n\nsnd : a × b → b\nsnd (_ , y) = y\n\nfirst : (a → b) → a × c → b × c\nfirst f (x , y) = f x , y\n\nsecond : (a → b) → c × a → c × b\nsecond f (x , y) = x , f y\n\n_***_ : (a → b) → (c → d) → a × c → b × d\n(f *** g) (x , y) = f x , g y\n", "meta": {"hexsha": "e20333953639cd19be7f8312059d51b1b17a1b7d", "size": 934, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "lib/Haskell/Prim/Tuple.agda", "max_stars_repo_name": "dxts/agda2hs", "max_stars_repo_head_hexsha": "8c8f24a079ed9677dbe6893cf786e7ed52dfe8b6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 55, "max_stars_repo_stars_event_min_datetime": "2020-10-20T13:36:25.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-26T21:57:56.000Z", "max_issues_repo_path": "lib/Haskell/Prim/Tuple.agda", "max_issues_repo_name": "seanpm2001/agda2hs", "max_issues_repo_head_hexsha": "160478a51bc78b0fdab07b968464420439f9fed6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 63, "max_issues_repo_issues_event_min_datetime": "2020-10-22T05:19:27.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-25T15:47:30.000Z", "max_forks_repo_path": "lib/Haskell/Prim/Tuple.agda", "max_forks_repo_name": "seanpm2001/agda2hs", "max_forks_repo_head_hexsha": "160478a51bc78b0fdab07b968464420439f9fed6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 18, "max_forks_repo_forks_event_min_datetime": "2020-10-21T22:19:09.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:42:52.000Z", "avg_line_length": 17.6226415094, "max_line_length": 58, "alphanum_fraction": 0.4421841542, "num_tokens": 397, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9334308165850442, "lm_q2_score": 0.8289388104343893, "lm_q1q2_score": 0.7737570307228072}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Functions.Definition\nopen import Lists.Definition\nopen import Lists.Monad\nopen import Boolean.Definition\n\nmodule Lists.Filter.AllTrue where\n\nallTrue : {a b : _} {A : Set a} (f : A → Set b) (l : List A) → Set b\nallTrue f [] = True'\nallTrue f (x :: l) = f x && allTrue f l\n\nallTrueConcat : {a b : _} {A : Set a} (f : A → Set b) (l m : List A) → allTrue f l → allTrue f m → allTrue f (l ++ m)\nallTrueConcat f [] m fl fm = fm\nallTrueConcat f (x :: l) m (fst ,, snd) fm = fst ,, allTrueConcat f l m snd fm\n\nallTrueFlatten : {a b : _} {A : Set a} (f : A → Set b) (l : List (List A)) → allTrue (λ i → allTrue f i) l → allTrue f (flatten l)\nallTrueFlatten f [] pr = record {}\nallTrueFlatten f ([] :: ls) pr = allTrueFlatten f ls (_&&_.snd pr)\nallTrueFlatten f ((x :: l) :: ls) ((fx ,, fl) ,, snd) = fx ,, allTrueConcat f l (flatten ls) fl (allTrueFlatten f ls snd)\n\nallTrueMap : {a b c : _} {A : Set a} {B : Set b} (pred : B → Set c) (f : A → B) (l : List A) → allTrue (pred ∘ f) l → allTrue pred (map f l)\nallTrueMap pred f [] pr = record {}\nallTrueMap pred f (x :: l) pr = _&&_.fst pr ,, allTrueMap pred f l (_&&_.snd pr)\n\nallTrueExtension : {a b : _} {A : Set a} (f g : A → Set b) (l : List A) → ({x : A} → f x → g x) → allTrue f l → allTrue g l\nallTrueExtension f g [] pred t = record {}\nallTrueExtension f g (x :: l) pred (fg ,, snd) = pred {x} fg ,, allTrueExtension f g l pred snd\n\nallTrueTail : {a b : _} {A : Set a} (pred : A → Set b) (x : A) (l : List A) → allTrue pred (x :: l) → allTrue pred l\nallTrueTail pred x l (fst ,, snd) = snd\n\nfilter : {a : _} {A : Set a} (l : List A) (f : A → Bool) → List A\nfilter [] f = []\nfilter (x :: l) f with f x\nfilter (x :: l) f | BoolTrue = x :: filter l f\nfilter (x :: l) f | BoolFalse = filter l f\n", "meta": {"hexsha": "51d971e8ac39277a6c422d60a05af032d8095ba7", "size": 1831, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Lists/Filter/AllTrue.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Lists/Filter/AllTrue.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Lists/Filter/AllTrue.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 45.775, "max_line_length": 140, "alphanum_fraction": 0.5903877662, "num_tokens": 667, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.888758793492457, "lm_q2_score": 0.8705972700870909, "lm_q1q2_score": 0.7737509793804296}} {"text": "{-\n\n Types Summer School 2007\n\n Bertinoro\n Aug 19 - 31, 2007\n\n\n Agda\n\n Ulf Norell\n\n-}\n\n-- Now we're getting somewhere! Inductive families of datatypes.\n\nmodule Families where\n\n-- You can import modules defined in other files.\n-- More details later...\n-- open import Nat\n\ndata Nat : Set where\n zero : Nat\n suc : Nat -> Nat\n\n_+_ : Nat -> Nat -> Nat\nzero + m = m\nsuc n + m = suc (n + m)\n\n-- Think of an inductive family...\n\ndata Vec (A : Set) : Nat -> Set where\n [] : Vec A zero\n _::_ : {n : Nat} -> A -> Vec A n -> Vec A (suc n)\n\ninfixr 40 _::_\n\n-- Some simple functions\nhead : {A : Set}{n : Nat} -> Vec A (suc n) -> A\nhead (x :: _) = x -- no need for a [] case\n\n-- Does the definition look familiar?\nmap : {A B : Set}{n : Nat} -> (A -> B) -> Vec A n -> Vec B n\nmap f [] = []\nmap f (x :: xs) = f x :: map f xs\n\ninfixr 40 _++_\n\n_++_ : {A : Set}{n m : Nat} -> Vec A n -> Vec A m -> Vec A (n + m)\n[] ++ ys = ys\n(x :: xs) ++ ys = x :: (xs ++ ys)\n\n-- Why does this type check? Let's walk through it slowly.\n-- When pattern matching on the first vector, n is instantiated.\n\n-- What happens if we make the lengths explicit?\n\ncat : {A : Set}(n m : Nat) -> Vec A n -> Vec A m -> Vec A (n + m)\ncat .zero m [] ys = ys\ncat .(suc n) m (_::_ {n} x xs) ys = x :: (cat n m xs ys)\n\n-- Patterns which get instantiated by pattern matching on other stuff\n-- get tagged by a dot. If you erase all the dotted things you get a\n-- well-formed linear first-order pattern.\n\n-- Inside the dot we could have arbitrary terms. For instance,\n\ndata Image_∋_ {A B : Set}(f : A -> B) : B -> Set where\n im : (x : A) -> Image f ∋ f x\n\ninv : {A B : Set}(f : A -> B)(y : B) -> Image f ∋ y -> A\ninv f .(f x) (im x) = x\n\n-- Let's do some other interesting families.\n\n-- The identity type.\ndata _==_ {A : Set} : A -> A -> Set where\n refl : (x : A) -> x == x\n\nsubst : {A : Set}(C : A -> Set)(x y : A) -> x == y -> C x -> C y\nsubst C .x .x (refl x) cx = cx\n\n-- Finite sets\n\n{-\n\nFin zero -\nFin (suc zero) fzero\nFin 2 fzero, fsuc fzero\n\n-}\n\ndata Fin : Nat -> Set where\n fzero : {n : Nat} -> Fin (suc n)\n fsuc : {n : Nat} -> Fin n -> Fin (suc n)\n\n_!_ : {A : Set}{n : Nat} -> Vec A n -> Fin n -> A\n[] ! ()\n(x :: xs) ! fzero = x\n(x :: xs) ! fsuc i = xs ! i\n\n{-\n\n What's next?\n\n-}\n\n-- Actually, inductive families are sufficiently fun that\n-- you'll never get bored, but there's even more fun to be had.\n\n-- Move on to: Filter.agda\n", "meta": {"hexsha": "7f9e86f494d167ec284841c3dd98a80781194c00", "size": 2521, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/SummerSchool07/Lecture/Families.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/SummerSchool07/Lecture/Families.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/SummerSchool07/Lecture/Families.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 22.3097345133, "max_line_length": 69, "alphanum_fraction": 0.535898453, "num_tokens": 839, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9546474168650673, "lm_q2_score": 0.8104789178257654, "lm_q1q2_score": 0.7737216053259621}} {"text": "------------------------------------------------------------------------------\n-- Inductive PA properties\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule PA.Inductive.PropertiesI where\n\nopen import PA.Inductive.Base\nopen import PA.Inductive.Relation.Binary.EqReasoning\n\n------------------------------------------------------------------------------\n-- Congruence properties\n\nsuccCong : ∀ {m n} → m ≡ n → succ m ≡ succ n\nsuccCong refl = refl\n\n+-leftCong : ∀ {m n o} → m ≡ n → m + o ≡ n + o\n+-leftCong refl = refl\n\n+-rightCong : ∀ {m n o} → n ≡ o → m + n ≡ m + o\n+-rightCong refl = refl\n\n------------------------------------------------------------------------------\n-- Peano's third axiom.\nP₃ : ∀ {m n} → succ m ≡ succ n → m ≡ n\nP₃ refl = refl\n\n-- Peano's fourth axiom.\nP₄ : ∀ {n} → zero ≢ succ n\nP₄ ()\n\nx≢Sx : ∀ {n} → n ≢ succ n\nx≢Sx {zero} ()\nx≢Sx {succ n} h = x≢Sx (P₃ h)\n\n+-leftIdentity : ∀ n → zero + n ≡ n\n+-leftIdentity n = refl\n\n-- Adapted from the Agda standard library 0.8.1 (see\n-- Data.Nat.Properties.Simple.+-rightIdentity).\n+-rightIdentity : ∀ n → n + zero ≡ n\n+-rightIdentity zero = refl\n+-rightIdentity (succ n) = succCong (+-rightIdentity n)\n\n-- Adapted from the Agda standard library_0.8.1 (see\n-- Data.Nat.Properties.Simple.+-assoc).\n+-assoc : ∀ m n o → m + n + o ≡ m + (n + o)\n+-assoc zero _ _ = refl\n+-assoc (succ m) n o = succCong (+-assoc m n o)\n\n-- Adapted from the Agda standard library 0.8.1 (see\n-- Data.Nat.Properties.Simple.+-suc).\nx+Sy≡S[x+y] : ∀ m n → m + succ n ≡ succ (m + n)\nx+Sy≡S[x+y] zero _ = refl\nx+Sy≡S[x+y] (succ m) n = succCong (x+Sy≡S[x+y] m n)\n\n-- Adapted from the Agda standard library 0.8.1 (see\n-- Data.Nat.Properties.Simple.+-comm).\n+-comm : ∀ m n → m + n ≡ n + m\n+-comm zero n = sym (+-rightIdentity n)\n+-comm (succ m) n = succ (m + n) ≡⟨ succCong (+-comm m n) ⟩\n succ (n + m) ≡⟨ sym (x+Sy≡S[x+y] n m) ⟩\n n + succ m ∎\n", "meta": {"hexsha": "e3e49b172bfc2261fefff8dca461596804f0b4e7", "size": 2133, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/PA/Inductive/PropertiesI.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/PA/Inductive/PropertiesI.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/PA/Inductive/PropertiesI.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 31.3676470588, "max_line_length": 78, "alphanum_fraction": 0.4857008908, "num_tokens": 672, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9284087965937711, "lm_q2_score": 0.8333245994514084, "lm_q1q2_score": 0.7736658885486684}} {"text": "\nmodule Unique where\n\nopen import Category\n\nmodule Uniq (ℂ : Cat) where\n\n private open module C = Cat ℂ\n\n -- We say that f ∈! P iff f is the unique arrow satisfying P.\n data _∈!_ {A B : Obj}(f : A ─→ B)(P : A ─→ B -> Set) : Set where\n unique : (forall g -> P g -> f == g) -> f ∈! P\n\n itsUnique : {A B : Obj}{f : A ─→ B}{P : A ─→ B -> Set} ->\n\t f ∈! P -> (g : A ─→ B) -> P g -> f == g\n itsUnique (unique h) = h\n\n data ∃! {A B : Obj}(P : A ─→ B -> Set) : Set where\n witness : (f : A ─→ B) -> f ∈! P -> ∃! P\n\n getWitness : {A B : Obj}{P : A ─→ B -> Set} -> ∃! P -> A ─→ B\n getWitness (witness w _) = w\n\n uniqueWitness : {A B : Obj}{P : A ─→ B -> Set}(u : ∃! P) ->\n\t\t getWitness u ∈! P\n uniqueWitness (witness _ u) = u\n\n witnessEqual : {A B : Obj}{P : A ─→ B -> Set} -> ∃! P ->\n\t\t {f g : A ─→ B} -> P f -> P g -> f == g\n witnessEqual u {f} {g} pf pg = trans (sym hf) hg\n where\n h = getWitness u\n\n hf : h == f\n hf = itsUnique (uniqueWitness u) f pf\n\n hg : h == g\n hg = itsUnique (uniqueWitness u) g pg\n", "meta": {"hexsha": "eadeb8244134885ab00e0f2545506b009d97431a", "size": 1049, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/cat/Unique.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/outdated-and-incorrect/cat/Unique.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/outdated-and-incorrect/cat/Unique.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 26.8974358974, "max_line_length": 66, "alphanum_fraction": 0.4775977121, "num_tokens": 422, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9433475746920261, "lm_q2_score": 0.8198933403143929, "lm_q1q2_score": 0.7734443940917265}} {"text": "{-# OPTIONS --rewriting #-}\n\nmodule RewritingNat where\n\nopen import Common.Equality\n\n{-# BUILTIN REWRITE _≡_ #-}\n\ndata Nat : Set where\n zero : Nat\n suc : Nat → Nat\n\n_+_ : Nat → Nat → Nat\nzero + n = n\n(suc m) + n = suc (m + n)\n\nplusAssoc : ∀ x {y z : Nat} → ((x + y) + z) ≡ (x + (y + z))\nplusAssoc zero = refl\nplusAssoc (suc x) {y} {z} rewrite plusAssoc x {y} {z} = refl\n\nplus0T : Set\nplus0T = ∀{x} → (x + zero) ≡ x\n\nplusSucT : Set\nplusSucT = ∀{x y} → (x + (suc y)) ≡ suc (x + y)\n\npostulate\n plus0p : plus0T\n {-# REWRITE plus0p #-}\n\n plusSucp : plusSucT\n\n{-# REWRITE plusSucp plusAssoc #-}\n\nplus0 : plus0T\nplus0 = refl\n\ndata Vec (A : Set) : Nat → Set where\n [] : Vec A zero\n _∷_ : ∀ {n} (x : A) (xs : Vec A n) → Vec A (suc n)\n\n-- Needs REWRITE plus0p plusSucp\nreverseAcc : ∀{A n m} → Vec A n → Vec A m → Vec A (n + m)\nreverseAcc [] acc = acc\nreverseAcc (x ∷ xs) acc = reverseAcc xs (x ∷ acc)\n\nappend : ∀{A n m} → Vec A n → Vec A m → Vec A (n + m)\nappend [] ys = ys\nappend (x ∷ xs) ys = x ∷ append xs ys\n\n-- Note: appendAssoc needs REWRITE plusAssoc to be well-typed.\nappendAssoc : ∀{A n m l} (u : Vec A n) {v : Vec A m}{w : Vec A l} →\n append (append u v) w ≡ append u (append v w)\nappendAssoc [] = refl\nappendAssoc (x ∷ xs) {v} {w} rewrite appendAssoc xs {v} {w} = refl\n", "meta": {"hexsha": "8d79d148d068a5e866b5ca4a4d3d91c0c291fb16", "size": 1285, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/RewritingNat.agda", "max_stars_repo_name": "alhassy/agda", "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_issues_repo_path": "test/Succeed/RewritingNat.agda", "max_issues_repo_name": "alhassy/agda", "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/Succeed/RewritingNat.agda", "max_forks_repo_name": "alhassy/agda", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "avg_line_length": 22.9464285714, "max_line_length": 67, "alphanum_fraction": 0.5750972763, "num_tokens": 501, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9304582574225517, "lm_q2_score": 0.8311430457670241, "lm_q1q2_score": 0.7733439100332574}} {"text": "{-# OPTIONS --type-in-type #-}\nmodule Record where\n\ninfixr 2 _,_\nrecord Σ (A : Set)(B : A → Set) : Set where\n constructor _,_\n field fst : A\n snd : B fst\n\nopen Σ\n\ndata ⊤ : Set where\n tt : ⊤\n\n∃ : {A : Set}(B : A → Set) → Set\n∃ B = Σ _ B\n\ninfix 10 _≡_\n\ndata _≡_ {A : Set}(a : A) : {B : Set} → B → Set where\n refl : a ≡ a\n\ntrans : ∀ {A B C}{a : A}{b : B}{c : C} → a ≡ b → b ≡ c → a ≡ c\ntrans refl p = p\n\nsym : ∀ {A B}{a : A}{b : B} → a ≡ b → b ≡ a\nsym refl = refl\n\nresp : ∀ {A}{B : A → Set}{a a' : A} →\n (f : (a : A) → B a) → a ≡ a' → f a ≡ f a'\nresp f refl = refl\n\nCat : Set\nCat =\n ∃ λ (Obj : Set) →\n ∃ λ (Hom : Obj → Obj → Set) →\n ∃ λ (id : ∀ X → Hom X X) →\n ∃ λ (_○_ : ∀ {X Y Z} → Hom Y Z → Hom X Y → Hom X Z) →\n ∃ λ (idl : ∀ {X Y}{f : Hom X Y} → id Y ○ f ≡ f) →\n ∃ λ (idr : ∀ {X Y}{f : Hom X Y} → f ○ id X ≡ f) →\n ∃ λ (assoc : ∀ {W X Y Z}{f : Hom W X}{g : Hom X Y}{h : Hom Y Z} →\n (h ○ g) ○ f ≡ h ○ (g ○ f)) →\n ⊤\n\nObj : (C : Cat) → Set\nObj C = fst C\n\nHom : (C : Cat) → Obj C → Obj C → Set\nHom C = fst (snd C)\n\nid : (C : Cat) → ∀ X → Hom C X X\nid C = fst (snd (snd C))\n\ncomp : (C : Cat) → ∀ {X Y Z} → Hom C Y Z → Hom C X Y → Hom C X Z\ncomp C = fst (snd (snd (snd C)))\n\nidl : (C : Cat) → ∀ {X Y}{f : Hom C X Y} → comp C (id C Y) f ≡ f\nidl C = fst (snd (snd (snd (snd C))))\n\nidr : (C : Cat) → ∀ {X Y}{f : Hom C X Y} → comp C f (id C X) ≡ f\nidr C = fst (snd (snd (snd (snd (snd C)))))\n\nassoc : (C : Cat) → ∀ {W X Y Z}{f : Hom C W X}{g : Hom C X Y}{h : Hom C Y Z} →\n comp C (comp C h g) f ≡ comp C h (comp C g f)\nassoc C = fst (snd (snd (snd (snd (snd (snd C))))))\n", "meta": {"hexsha": "84a1b075c7942e5b2c8d205309391741af76db6c", "size": 1608, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "benchmark/proj/Record.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "benchmark/proj/Record.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "benchmark/proj/Record.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 24.3636363636, "max_line_length": 78, "alphanum_fraction": 0.4322139303, "num_tokens": 748, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9353465152482724, "lm_q2_score": 0.8267118004748677, "lm_q1q2_score": 0.7732620016887926}} {"text": "module 747Negation where\n\n-- Library\n\nopen import Relation.Binary.PropositionalEquality using (_≡_; refl) -- added last\nopen import Data.Nat using (ℕ; zero; suc) \nopen import Data.Empty using (⊥; ⊥-elim)\nopen import Data.Sum using (_⊎_; inj₁; inj₂)\nopen import Data.Product using (_×_; proj₁; proj₂)\n\n-- Negation is defined as implying false.\n\n¬_ : Set → Set\n¬ A = A → ⊥\n\n-- if both ¬ A and A hold, then ⊥ holds (not surprisingly).\n\n¬-elim : ∀ {A : Set}\n → ¬ A\n → A\n ---\n → ⊥\n\n¬-elim = {!!}\n\ninfix 3 ¬_\n\n-- Double negation introduction.\n\n¬¬-intro : ∀ {A : Set}\n → A\n -----\n → ¬ ¬ A\n\n¬¬-intro = {!!}\n\n-- Double negation cannot be eliminated in intuitionistic logic.\n\n-- Triple negation elimination.\n\n¬¬¬-elim : ∀ {A : Set}\n → ¬ ¬ ¬ A\n -------\n → ¬ A\n\n¬¬¬-elim = {!!}\n\n-- One direction of the contrapositive.\n\ncontraposition : ∀ {A B : Set}\n → (A → B)\n -----------\n → (¬ B → ¬ A)\n\ncontraposition = {!!}\n\n-- The other direction cannot be proved in intuitionistic logic.\n\n-- not-equal-to.\n\n_≢_ : ∀ {A : Set} → A → A → Set\nx ≢ y = ¬ (x ≡ y)\n\n_ : 1 ≢ 2\n_ = {!!}\n\n-- One of the first-order Peano axioms.\n\npeano : ∀ {m : ℕ} → zero ≢ suc m\npeano = {!!}\n\n-- Copied from 747Isomorphism.\n\npostulate\n extensionality : ∀ {A B : Set} {f g : A → B}\n → (∀ (x : A) → f x ≡ g x)\n -----------------------\n → f ≡ g\n\n-- Two proofs of ⊥ → ⊥ which look different but are the same\n-- (assuming extensionality).\n \nid : ⊥ → ⊥\nid x = x\n\nid′ : ⊥ → ⊥\nid′ ()\n\nid≡id′ : id ≡ id′\nid≡id′ = extensionality (λ())\n\n-- Assuming extensionality, any two proofs of a negation are the same\n\nassimilation : ∀ {A : Set} (¬x ¬x′ : ¬ A) → ¬x ≡ ¬x′\nassimilation ¬x ¬x′ = extensionality λ x → ⊥-elim (¬x x)\n\n-- Strict inequality (copied from 747Relations).\n\ninfix 4 _<_\n\ndata _<_ : ℕ → ℕ → Set where\n\n z : n < m → ¬ m ≡ n → ¬ m < n → Trichotomy m n\n\n<-trichotomy : ∀ (m n : ℕ) → Trichotomy m n\n<-trichotomy m n = {!!}\n\n-- PLFA exercise: one of DeMorgan's Laws as isomorphism\n-- ⊎-dual-× : ∀ {A B : Set} → ¬ (A ⊎ B) ≃ (¬ A) × (¬ B)\n-- Expand negation as implies-false, then look in 747Relations\n-- for a law of which this is a special case.\n\n-- What about ¬ (A × B) ≃ (¬ A) ⊎ (¬ B)?\n-- Answer: RHS implies LHS but converse cannot be proved in intuitionistic logic.\n\n-- Intuitionistic vs classical logic.\n\n-- The law of the excluded middle (LEM, or just em) cannot be\n-- proved in intuitionistic logic.\n-- But we can add it, and get classical logic.\n\n-- postulate\n-- em : ∀ {A : Set} → A ⊎ ¬ A\n\n-- How do we know this does not give a contradiction?\n-- The following theorem of intuitionistic logic demonstrates this.\n-- (The proof is compact, but takes some thought.)\n\nem-irrefutable : ∀ {A : Set} → ¬ ¬ (A ⊎ ¬ A)\nem-irrefutable = {!!}\n\n-- PLFA exercise: classical equivalences\n-- Excluded middle cannot be proved in intuitionistic logic,\n-- but adding it is consistent and gives classical logic.\n-- Here are four other classical theorems with the same property.\n-- You can show that each of them is logically equivalent to all the others.\n-- You do not need to prove twenty implications, since implication is transitive.\n-- But there is a lot of choice as to how to proceed!\n\n-- Excluded Middle\nem = ∀ {A : Set} → A ⊎ ¬ A\n\n-- Double Negation Elimination\ndne = ∀ {A : Set} → ¬ ¬ A → A\n\n-- Peirce’s Law\npeirce = ∀ {A B : Set} → ((A → B) → A) → A\n\n-- Implication as disjunction\niad = ∀ {A B : Set} → (A → B) → ¬ A ⊎ B\n\n-- De Morgan:\ndem = ∀ {A B : Set} → ¬ (¬ A × ¬ B) → A ⊎ B\n\n-- End of classical five exercise.\n\n-- Definition: a formula is stable if double negation holds for it.\n\nStable : Set → Set\nStable A = ¬ ¬ A → A\n\n-- PLFA exercise: every negated formula is stable.\n-- This is triple negation elimination.\n\n-- PLFA exercise: the conjunction of two stable formulas is stable.\n-- This is the version of DeMorgan's Law that is a special case, above.\n\n-- Where negation sits in the standard library.\n\nimport Relation.Nullary using (¬_)\nimport Relation.Nullary.Negation using (contraposition)\n\n-- Unicode used in this chapter:\n\n{-\n\n ¬ U+00AC NOT SIGN (\\neg)\n ≢ U+2262 NOT IDENTICAL TO (\\==n)\n\n-}\n", "meta": {"hexsha": "c7bc080f842876b7a6f9640cc85da89d6065a6a6", "size": 4804, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x07-747Negation.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x07-747Negation.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x07-747Negation.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 22.8761904762, "max_line_length": 81, "alphanum_fraction": 0.5980432973, "num_tokens": 1574, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9207896693699845, "lm_q2_score": 0.8397339696776499, "lm_q1q2_score": 0.7732183642982279}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Level using (Level)\n\nopen import Relation.Binary.PropositionalEquality\nopen ≡-Reasoning\n\nopen import Data.Nat using (ℕ)\nopen import Data.Vec using (Vec; foldr; zipWith; map)\n\nopen import FLA.Algebra.Structures\nopen import FLA.Algebra.Properties.Field\n\nmodule FLA.Algebra.LinearAlgebra where\n\nprivate\n variable\n ℓ : Level\n A : Set ℓ\n m n p q : ℕ\n\nmodule _ {ℓ : Level} {A : Set ℓ} ⦃ F : Field A ⦄ where\n open Field F\n\n -- Vector addition\n _+ⱽ_ : Vec A n → Vec A n → Vec A n\n _+ⱽ_ = zipWith _+_\n\n -- Vector substraction\n _-ⱽ_ : Vec A n → Vec A n → Vec A n\n a -ⱽ b = a +ⱽ (map (-_) b)\n\n -- Vector Hadamard product\n _*ⱽ_ : Vec A n → Vec A n → Vec A n\n _*ⱽ_ = zipWith _*_\n\n -- Multiply vector by a constant\n _∘ⱽ_ : A → Vec A n → Vec A n\n c ∘ⱽ v = map (c *_) v\n\n -- Match the fixity of Haskell\n infixl 6 _+ⱽ_\n infixl 6 _-ⱽ_\n infixl 7 _*ⱽ_\n infixl 10 _∘ⱽ_\n\n sum : Vec A n → A\n sum = foldr _ _+_ 0ᶠ\n\n -- Inner product\n ⟨_,_⟩ : Vec A n → Vec A n → A\n ⟨ v₁ , v₂ ⟩ = sum (v₁ *ⱽ v₂)\n", "meta": {"hexsha": "a25ad16d2b8f61cad3ee0900c1c3513fa79e3900", "size": 1054, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/FLA/Algebra/LinearAlgebra.agda", "max_stars_repo_name": "turion/functional-linear-algebra", "max_stars_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 21, "max_stars_repo_stars_event_min_datetime": "2020-09-22T20:49:34.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-07T05:28:00.000Z", "max_issues_repo_path": "src/FLA/Algebra/LinearAlgebra.agda", "max_issues_repo_name": "turion/functional-linear-algebra", "max_issues_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2020-09-01T01:42:12.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-07T05:27:53.000Z", "max_forks_repo_path": "src/FLA/Algebra/LinearAlgebra.agda", "max_forks_repo_name": "turion/functional-linear-algebra", "max_forks_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2021-04-12T20:34:17.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-07T19:55:59.000Z", "avg_line_length": 19.8867924528, "max_line_length": 54, "alphanum_fraction": 0.6138519924, "num_tokens": 433, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.918480248488136, "lm_q2_score": 0.8418256412990658, "lm_q1q2_score": 0.7732002242040504}} {"text": "module x05isomorphism where\n\n{-\n------------------------------------------------------------------------------\nIsomorphism: Isomorphism and Embedding\n\nisomorphism\n- way of asserting two types are equal\n\nembedding\n- way of asserting that one type is smaller than another\n\napply isomorphisms in next chapter to show 'product' and 'sum' satisfy properties\nsimilar to associativity, commutativity, and distributivity\n-}\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl; cong; cong-app)\nopen Eq.≡-Reasoning\nopen import Data.Nat using (ℕ; zero; suc; _+_)\nopen import Data.Nat.Properties using (+-comm)\n\n{-\n------------------------------------------------------------------------------\nLAMBDA EXPRESSIONS : ANONYMOUS FUNS\n\nλ{ P₁ → N₁; ⋯ ; Ppₙ → Np }\n\nequivalent def by equations\n\nf P₁ = N₁\n⋯\nf Pp = Npₙ\n\nwhere\n- P are patterns (left-hand sides of an equation)\n- N are expressions (right-hand side of an equation)\n\nfor case of one equation and pattern is a variable:\n\nλ x → N\n\nor\n\nλ (x : A) → N\n\nequivalent to\n\nλ{x → N}\n\n------------------------------------------------------------------------------\nFunction composition\n-}\n\n-- first apply f, then apply g to result\n_∘_ : ∀ {A B C : Set} → (B → C) → (A → B) → (A → C)\n(g ∘ f) x = g (f x)\n\n\n-- equivalent\n_∘′_ : ∀ {A B C : Set} → (B → C) → (A → B) → (A → C)\ng ∘′ f = λ x → g (f x)\n\n{-\n------------------------------------------------------------------------------\nEXTENSIONALITY : only way to distinguish functions is by applying them\n\nIf two functions applied to same arg always give same result, then they are same.\n\nconverse of cong-app\n\nAgda does not presume extensionality, so\n-}\n\npostulate\n extensionality : ∀ {A B : Set} {f g : A → B}\n → (∀ (x : A) → f x ≡ g x)\n -----------------------\n → f ≡ g\n\n{-\nPostulating extensionality does not lead to difficulties.\nIt is known to be consistent with the theory that underlies Agda.\n\nexample\n-}\n\n-- version that matches on right\n_+′_ : ℕ → ℕ → ℕ\nm +′ zero = m\nm +′ suc n = suc (m +′ n)\n\n-- using commutativity, show + and +′ always return same result for same arg\nsame-app : ∀ (m n : ℕ) → m +′ n ≡ m + n\nsame-app m n -- (m +′ n) ≡ m + n\n rewrite +-comm m n -- (m +′ n) ≡ n + m\n = helper m n\n where\n helper : ∀ (m n : ℕ) → m +′ n ≡ n + m\n helper m zero = refl\n helper m (suc n) -- suc (m +′ n) ≡ suc (n + m)\n = cong suc (helper m n)\n\n-- now assert + and +′ to be indistinguishable (via two applications of extensionality)\nsame : _+′_ ≡ _+_\nsame = extensionality (λ m → extensionality (λ n → same-app m n))\n\n{-\nto postulate extensionality in what follows\n(and to postulate extensionality for dependent functions):\n-}\n\n-- type of f and g has changed from A → B to ∀ (x : A) → B x\npostulate\n ∀-extensionality : ∀ {A : Set} {B : A → Set} {f g : ∀(x : A) → B x}\n → (∀ (x : A) → f x ≡ g x)\n -----------------------\n → f ≡ g\n\n{-\n------------------------------------------------------------------------------\nISOMORPHISM : sets are isomorphic if they are in one-to-one correspondence\n\nformal definition:\n-}\n\ninfix 0 _≃_\n\n-- RECORD\n-- isomorphism between sets A and B consists of four things\nrecord _≃_ (A B : Set) : Set where\n field\n to : A → B -- function from A to B\n from : B → A -- function from B to A\n from∘to : ∀ (x : A) → from (to x) ≡ x -- evidence asserting 'from' is a left-inverse for 'to'\n to∘from : ∀ (y : B) → to (from y) ≡ y -- evidence asserting 'from' is a right-inverse for 'to'\nopen _≃_ -- makes field names 'to', etc., available without needing to write '_≃_.to'\n\n{-\nfrom ∘ to AND to ∘ from are identities\n\nrecord declaration behaves similar to single-constructor data declaration\n(there are minor differences - see Connectives):\n-}\ndata _≃′_ (A B : Set): Set where\n mk-≃′ : ∀ (to : A → B)\n → ∀ (from : B → A)\n → ∀ (from∘to : (∀ (x : A) → from (to x) ≡ x))\n → ∀ (to∘from : (∀ (y : B) → to (from y) ≡ y))\n → A ≃′ B\n\nto′ : ∀ {A B : Set} → (A ≃′ B) → (A → B)\nto′ (mk-≃′ f g g∘f f∘g) = f\n\nfrom′ : ∀ {A B : Set} → (A ≃′ B) → (B → A)\nfrom′ (mk-≃′ f g g∘f f∘g) = g\n\nfrom∘to′ : ∀ {A B : Set} → (A≃B : A ≃′ B) → (∀ (x : A) → from′ A≃B (to′ A≃B x) ≡ x)\nfrom∘to′ (mk-≃′ f g g∘f f∘g) = g∘f\n\nto∘from′ : ∀ {A B : Set} → (A≃B : A ≃′ B) → (∀ (y : B) → to′ A≃B (from′ A≃B y) ≡ y)\nto∘from′ (mk-≃′ f g g∘f f∘g) = f∘g\n\n{-\nconstruct record values via\n\nrecord\n { to = f\n ; from = g\n ; from∘to = g∘f\n ; to∘from = f∘g\n }\n\ncorresponds to using the constructor of the corresponding inductive type\n\nmk-≃′ f g g∘f f∘g\n\n------------------------------------------------------------------------------\nISOMORPHISM is an EQUIVALENCE : REFLEXIVE, SYMMETRIC, and TRANSITIVE\n-}\n\n-- REFLEXIVE\n≃-refl : ∀ {A : Set}\n -----\n → A ≃ A\n≃-refl =\n record\n { to = λ{x → x} -- bind to identity function\n ; from = λ{y → y} -- ditto\n -- refl next is proof since for left inverse, from (to x) simplifies to x, and vice versa\n ; from∘to = λ{x → refl} -- bound to fun that discards arg; returns refl\n ; to∘from = λ{y → refl} -- ditto\n }\n\n-- SYMMETRIC : swap roles of to/from and from∘to/to∘from\n≃-sym : ∀ {A B : Set}\n → A ≃ B\n -----\n → B ≃ A\n≃-sym A≃B =\n record\n { to = from A≃B\n ; from = to A≃B\n ; from∘to = to∘from A≃B\n ; to∘from = from∘to A≃B\n }\n\n-- TRANSITIVE : compose to/from and use equational reasoning to combine inverses\n≃-trans : ∀ {A B C : Set}\n → A ≃ B\n → B ≃ C\n -----\n → A ≃ C\n≃-trans A≃B B≃C =\n record\n { to = to B≃C ∘ to A≃B\n ; from = from A≃B ∘ from B≃C\n ; from∘to = λ{x →\n begin\n (from A≃B ∘ from B≃C) ((to B≃C ∘ to A≃B) x) ≡⟨⟩\n from A≃B (from B≃C (to B≃C (to A≃B x))) ≡⟨ cong (from A≃B) (from∘to B≃C (to A≃B x)) ⟩\n from A≃B (to A≃B x) ≡⟨ from∘to A≃B x ⟩\n x\n ∎}\n ; to∘from = λ{y →\n begin\n (to B≃C ∘ to A≃B) ((from A≃B ∘ from B≃C) y) ≡⟨⟩\n to B≃C (to A≃B (from A≃B (from B≃C y))) ≡⟨ cong (to B≃C) (to∘from A≃B (from B≃C y)) ⟩\n to B≃C (from B≃C y) ≡⟨ to∘from B≃C y ⟩\n y\n ∎}\n }\n{-\n------------------------------------------------------------------------------\nEQUATIONAL REASONING FOR ISOMORPHISM\n\nEssentially copy previous definition of equality for isomorphism.\nOmit the form that corresponds to _≡⟨⟩_,\nsince simple isomorphisms arise less often than simple equalities\n-}\n\nmodule ≃-Reasoning where\n\n infix 1 ≃-begin_\n infixr 2 _≃⟨_⟩_\n infix 3 _≃-∎\n\n ≃-begin_ : ∀ {A B : Set}\n → A ≃ B\n -----\n → A ≃ B\n ≃-begin A≃B = A≃B\n\n _≃⟨_⟩_ : ∀ (A : Set) {B C : Set}\n → A ≃ B\n → B ≃ C\n -----\n → A ≃ C\n A ≃⟨ A≃B ⟩ B≃C = ≃-trans A≃B B≃C\n\n _≃-∎ : ∀ (A : Set)\n -----\n → A ≃ A\n A ≃-∎ = ≃-refl\n\nopen ≃-Reasoning\n\n{-\n------------------------------------------------------------------------------\nEMBEDDING : WEAKENING of ISOMORPHISM : EMBEDDING SHOWS 1ST TYPE INCLUDED IN SECOND\ni.e., there is many-to-one correspondence between second type and first\n-}\n\ninfix 0 _≲_\nrecord _≲_ (A B : Set) : Set where\n field\n to : A → B\n from : B → A\n from∘to : ∀ (x : A) → from (to x) ≡ x\nopen _≲_\n\n{-\nsame as isomorphism, except it omits 'to∘from' field\n- says 'from' is left-inverse for 'to', but not a right-inverse\n\nEMBEDDING IS NOT SYMMETRIC\n\nproofs of REFLEXIVE and TRANSITIVE same as ISOMORPHISM except omitting one unneeded case\n-}\n\n-- REFLEXIVE\n≲-refl : ∀ {A : Set} → A ≲ A\n≲-refl =\n record\n { to = λ{x → x}\n ; from = λ{y → y}\n ; from∘to = λ{x → refl}\n }\n\n-- TRANSITIVE\n≲-trans : ∀ {A B C : Set} → A ≲ B → B ≲ C → A ≲ C\n≲-trans A≲B B≲C =\n record\n { to = λ{x → to B≲C (to A≲B x)}\n ; from = λ{y → from A≲B (from B≲C y)}\n ; from∘to = λ{x →\n begin\n from A≲B (from B≲C (to B≲C (to A≲B x))) ≡⟨ cong (from A≲B) (from∘to B≲C (to A≲B x)) ⟩\n from A≲B (to A≲B x) ≡⟨ from∘to A≲B x ⟩\n x\n ∎}\n }\n{-\nweak form of ANTI-SYMMETRY\nif two types embed in each other, and embedding functions correspond, they are isomorphic\n-}\n\n≲-antisym : ∀ {A B : Set}\n → (A≲B : A ≲ B)\n → (B≲A : B ≲ A)\n → (to A≲B ≡ from B≲A)\n → (from A≲B ≡ to B≲A)\n -------------------\n → A ≃ B\n≲-antisym A≲B B≲A to≡from from≡to =\n record\n { to = to A≲B\n ; from = from A≲B\n ; from∘to = from∘to A≲B\n ; to∘from = λ{y →\n begin\n to A≲B (from A≲B y) ≡⟨ cong (to A≲B) (cong-app from≡to y) ⟩\n to A≲B (to B≲A y) ≡⟨ cong-app to≡from (to B≲A y) ⟩\n from B≲A (to B≲A y) ≡⟨ from∘to B≲A y ⟩\n y\n ∎}\n }\n\n{-\nFirst three components are copied from the embedding.\nThe last combines left inverse of B ≲ A with the equivalences of the 'to' and 'from' components\nfrom the two embeddings to obtain the right inverse of the isomorphism.\n\n------------------------------------------------------------------------------\nEquational reasoning for embedding\n-}\n\nmodule ≲-Reasoning where\n\n infix 1 ≲-begin_\n infixr 2 _≲⟨_⟩_\n infix 3 _≲-∎\n\n ≲-begin_ : ∀ {A B : Set}\n → A ≲ B\n -----\n → A ≲ B\n ≲-begin A≲B = A≲B\n\n _≲⟨_⟩_ : ∀ (A : Set) {B C : Set}\n → A ≲ B\n → B ≲ C\n -----\n → A ≲ C\n A ≲⟨ A≲B ⟩ B≲C = ≲-trans A≲B B≲C\n\n _≲-∎ : ∀ (A : Set)\n -----\n → A ≲ A\n A ≲-∎ = ≲-refl\n\nopen ≲-Reasoning\n\n{-\n------------------------------------------------------------------------------\nExercise ≃-implies-≲ (practice) Show that every isomorphism implies an embedding. TODO\n\npostulate\n ≃-implies-≲ : ∀ {A B : Set}\n → A ≃ B\n -----\n → A ≲ B\n-- Your code goes here\n\n------------------------------------------------------------------------------\nExercise _⇔_ (practice) Define equivalence of propositions TODO\n(also known as “if and only if”) as follows:\n\nrecord _⇔_ (A B : Set) : Set where\n field\n to : A → B\n from : B → A\nShow that equivalence is reflexive, symmetric, and transitive.\n\n-- Your code goes here\n\n------------------------------------------------------------------------------\nExercise Bin-embedding (stretch) TODO\n\nBin and Bin-laws define a datatype Bin of bitstrings representing natural numbers\nwith functions\n\nto : ℕ → Bin\nfrom : Bin → ℕ\n\nthat satisfy\n\nfrom (to n) ≡ n\n\nUsing the above, establish that there is an embedding of ℕ into Bin.\n\n-- Your code goes here\n\nWhy do to and from not form an isomorphism?\n\n------------------------------------------------------------------------------\nStandard library\n\nimport Function using (_∘_)\nimport Function.Inverse using (_↔_)\nimport Function.LeftInverse using (_↞_)\n\nThe standard library _↔︎_ and _↞_ correspond to our _≃_ and _≲_, respectively,\nbut those in the standard library are less convenient,\nsince they depend on a nested record structure\nand are parameterised with regard to an arbitrary notion of equivalence.\n\n------------------------------------------------------------------------------\nUnicode\nThis chapter uses the following unicode:\n\n∘ U+2218 RING OPERATOR (\\o, \\circ, \\comp)\nλ U+03BB GREEK SMALL LETTER LAMBDA (\\lambda, \\Gl)\n≃ U+2243 ASYMPTOTICALLY EQUAL TO (\\~-)\n≲ U+2272 LESS-THAN OR EQUIVALENT TO (\\<~)\n⇔ U+21D4 LEFT RIGHT DOUBLE ARROW (\\<=>)\n-}\n", "meta": {"hexsha": "2c2be464e1364b8ca3a116cf4e796be4674138ca", "size": 11547, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x05isomorphism.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x05isomorphism.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x05isomorphism.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 26.3630136986, "max_line_length": 99, "alphanum_fraction": 0.489564389, "num_tokens": 4030, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.907312213841788, "lm_q2_score": 0.8519528038477824, "lm_q1q2_score": 0.77298718454785}} {"text": "module hott.types.int where\n\n\nopen import hott.functions\nopen import hott.core\nimport hott.types.nat as nat\n\nopen nat using (ℕ)\n\ndata ℤ : Type₀ where\n zero : ℤ\n +ve : ℕ → ℤ\n -ve : ℕ → ℤ\n\nfromNat : ℕ → ℤ\nfromNat nat.zero = zero\nfromNat (nat.succ n) = +ve n\n\nneg : ℤ → ℤ\nneg zero = zero\nneg (+ve n) = -ve n\nneg (-ve n) = +ve n\n\n\nsuc : ℤ → ℤ\nsuc zero = +ve 0\nsuc (+ve x) = +ve (nat.succ x)\nsuc (-ve 0) = zero\nsuc (-ve (nat.succ x)) = -ve x\n\n\npred : ℤ → ℤ\npred zero = -ve 0\npred (-ve x) = -ve (nat.succ x)\npred (+ve 0) = zero\npred (+ve (nat.succ x)) = +ve x\n\n\nsuc∘pred~id : suc ∘ pred ~ id\nsuc∘pred~id zero = refl\nsuc∘pred~id (+ve 0) = refl\nsuc∘pred~id (+ve (nat.succ x)) = refl\nsuc∘pred~id (-ve x) = refl\n\n\npred∘suc~id : pred ∘ suc ~ id\npred∘suc~id zero = refl\npred∘suc~id (+ve x) = refl\npred∘suc~id (-ve 0) = refl\npred∘suc~id (-ve (nat.succ x)) = refl\n", "meta": {"hexsha": "4d5ec9a2b93a6697edf34ee3d1d023236100c2f3", "size": 1015, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/hott/types/int.agda", "max_stars_repo_name": "piyush-kurur/hott", "max_stars_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "agda/hott/types/int.agda", "max_issues_repo_name": "piyush-kurur/hott", "max_issues_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/hott/types/int.agda", "max_forks_repo_name": "piyush-kurur/hott", "max_forks_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.9019607843, "max_line_length": 44, "alphanum_fraction": 0.4985221675, "num_tokens": 397, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9653811651448431, "lm_q2_score": 0.8006920116079208, "lm_q1q2_score": 0.7729729870882228}} {"text": "module #8 where\n\n{-\n Define multiplication and exponentiation using recN. Verify that (N, +, 0, ×, 1) is\n a semiring using only indN. You will probably also need to use symmetry and transitivity of\n equality, Lemmas 2.1.1 and 2.1.2.\n-}\n\nopen import Data.Nat\n\nrecₙ : ∀{c}{C : Set c} → C → (ℕ → C → C) → ℕ → C\nrecₙ c₀ cₛ zero = c₀\nrecₙ c₀ cₛ (suc n) = cₛ n (recₙ c₀ cₛ n)\n\nmul-recₙ : ℕ → ℕ → ℕ\nmul-recₙ n = recₙ 0 (λ _ z → z + n)\n\nexp-recₙ : ℕ → ℕ → ℕ\nexp-recₙ n = recₙ 1 (λ _ z → z * n)\n\nind-ℕ : ∀{k}{C : ℕ → Set k} → C zero → ((n : ℕ) → C n → C (suc n)) → (n : ℕ) → C n\nind-ℕ c0 cs zero = c0\nind-ℕ c0 cs (suc n) = cs n (ind-ℕ c0 cs n)\n\nrecord Semiring (X : Set) : Set where\n field\n ε : X\n _⊕_ : X → X → X\n _⊛_ : X → X → X\nopen Semiring {{...}} public\n\nnatIsSemiring : Semiring ℕ\nnatIsSemiring = record { ε = zero\n ; _⊕_ = _+_\n ; _⊛_ = _*_\n }\n\n{- Semiring Laws Follow -}\n\n\n", "meta": {"hexsha": "1fada7ccbf1f7dba8746424964a31642f2cdb124", "size": 951, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Chapter1/#8.agda", "max_stars_repo_name": "CodaFi/HoTT-Exercises", "max_stars_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapter1/#8.agda", "max_issues_repo_name": "CodaFi/HoTT-Exercises", "max_issues_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter1/#8.agda", "max_forks_repo_name": "CodaFi/HoTT-Exercises", "max_forks_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.1951219512, "max_line_length": 93, "alphanum_fraction": 0.523659306, "num_tokens": 403, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9324533163686646, "lm_q2_score": 0.8289388125473629, "lm_q1q2_score": 0.7729467448264913}} {"text": "------------------------------------------------------------------------------\n-- Properties related with the group commutator\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule GroupTheory.Commutator.PropertiesI where\n\nopen import Common.FOL.Relation.Binary.EqReasoning\n\nopen import GroupTheory.Base\nopen import GroupTheory.Commutator\nopen import GroupTheory.PropertiesI\n\n------------------------------------------------------------------------------\n-- Kurosh (1960), p. 99.\ncommutatorInverse : ∀ a b → [ a , b ] · [ b , a ] ≡ ε\ncommutatorInverse a b =\n a ⁻¹ · b ⁻¹ · a · b · (b ⁻¹ · a ⁻¹ · b · a)\n ≡⟨ assoc (a ⁻¹ · b ⁻¹ · a) b (b ⁻¹ · a ⁻¹ · b · a) ⟩\n a ⁻¹ · b ⁻¹ · a · (b · (b ⁻¹ · a ⁻¹ · b · a))\n ≡⟨ ·-rightCong (·-rightCong (assoc (b ⁻¹ · a ⁻¹) b a)) ⟩\n a ⁻¹ · b ⁻¹ · a · (b · (b ⁻¹ · a ⁻¹ · (b · a)))\n ≡⟨ ·-rightCong (·-rightCong (assoc (b ⁻¹) (a ⁻¹) (b · a))) ⟩\n a ⁻¹ · b ⁻¹ · a · (b · (b ⁻¹ · (a ⁻¹ · (b · a))))\n ≡⟨ ·-rightCong (sym (assoc b (b ⁻¹) (a ⁻¹ · (b · a)))) ⟩\n a ⁻¹ · b ⁻¹ · a · (b · b ⁻¹ · (a ⁻¹ · (b · a)))\n ≡⟨ ·-rightCong (·-leftCong (rightInverse b)) ⟩\n a ⁻¹ · b ⁻¹ · a · (ε · (a ⁻¹ · (b · a)))\n ≡⟨ ·-rightCong (leftIdentity (a ⁻¹ · (b · a))) ⟩\n a ⁻¹ · b ⁻¹ · a · (a ⁻¹ · (b · a))\n ≡⟨ assoc (a ⁻¹ · b ⁻¹) a (a ⁻¹ · (b · a)) ⟩\n a ⁻¹ · b ⁻¹ · (a · (a ⁻¹ · (b · a)))\n ≡⟨ ·-rightCong (sym (assoc a (a ⁻¹) (b · a))) ⟩\n a ⁻¹ · b ⁻¹ · (a · a ⁻¹ · (b · a))\n ≡⟨ ·-rightCong (·-leftCong (rightInverse a)) ⟩\n a ⁻¹ · b ⁻¹ · (ε · (b · a))\n ≡⟨ ·-rightCong (leftIdentity (b · a)) ⟩\n a ⁻¹ · b ⁻¹ · (b · a)\n ≡⟨ assoc (a ⁻¹) (b ⁻¹) (b · a) ⟩\n a ⁻¹ · (b ⁻¹ · (b · a))\n ≡⟨ ·-rightCong (sym (assoc (b ⁻¹) b a)) ⟩\n a ⁻¹ · ((b ⁻¹ · b) · a)\n ≡⟨ ·-rightCong (·-leftCong (leftInverse b)) ⟩\n a ⁻¹ · (ε · a)\n ≡⟨ ·-rightCong (leftIdentity a) ⟩\n a ⁻¹ · a\n ≡⟨ leftInverse a ⟩\n ε ∎\n\n------------------------------------------------------------------------------\n-- References\n--\n-- Kurosh, A. G. (1960). The Theory of Groups. 2nd\n-- ed. Vol. 1. Translated and edited by K. A. Hirsch. Chelsea\n-- Publising Company.\n", "meta": {"hexsha": "1eed7cc852e1713825e7f435059dc43890f2547c", "size": 2279, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/GroupTheory/Commutator/PropertiesI.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/GroupTheory/Commutator/PropertiesI.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/GroupTheory/Commutator/PropertiesI.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 37.9833333333, "max_line_length": 78, "alphanum_fraction": 0.4028082492, "num_tokens": 935, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8807970873650401, "lm_q2_score": 0.8774767938900121, "lm_q1q2_score": 0.7728790042887363}} {"text": "------------------------------------------------------------------------------\n-- Even predicate\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule FOTC.Even where\n\nopen import FOTC.Base\nopen import FOTC.Data.Nat.Type\n\n------------------------------------------------------------------------------\n\ndata Even : D → Set where\n ezero : Even zero\n enext : ∀ {n} → Even n → Even (succ₁ (succ₁ n))\n\nEven-ind : (A : D → Set) →\n A zero →\n (∀ {n} → A n → A (succ₁ (succ₁ n))) →\n ∀ {n} → Even n → A n\nEven-ind A A0 h ezero = A0\nEven-ind A A0 h (enext En) = h (Even-ind A A0 h En)\n\nEven→N : ∀ {n} → Even n → N n\nEven→N ezero = nzero\nEven→N (enext En) = nsucc (nsucc (Even→N En))\n", "meta": {"hexsha": "1c10510d44e0775ad2a859ad05a6d61731b10add", "size": 937, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/thesis/report/FOTC/Even.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "notes/thesis/report/FOTC/Even.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "notes/thesis/report/FOTC/Even.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 30.2258064516, "max_line_length": 78, "alphanum_fraction": 0.3820704376, "num_tokens": 234, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9449947179030095, "lm_q2_score": 0.8175744695262775, "lm_q1q2_score": 0.7726035551946873}} {"text": "open import x1-Base\n\nmodule x4-Nat where\n\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n{-# BUILTIN NATURAL ℕ #-}\n\ndata _≤_ : Rel ℕ where\n z≤n : ∀ {x} → zero ≤ x\n s≤s : ∀ {x y} → x ≤ y\n → suc x ≤ suc y\n\n≤-suc : ∀ {x y} → suc x ≤ suc y\n → x ≤ y\n≤-suc (s≤s x≤y) = x≤y\n\n_≤?_ : Decidable _≤_\nzero ≤? _ = left z≤n\nsuc _ ≤? zero = right λ()\nsuc x ≤? suc y with x ≤? y\n... | left x≤y = left (s≤s x≤y)\n... | right x>y = right (λ sx≤sy → x>y (≤-suc sx≤sy))\n\nopen import x3-PropositionalEquality using (_≡_; refl; cong; equivalence)\n\nantisym : ∀ {x y} → x ≤ y → y ≤ x → x ≡ y\nantisym z≤n z≤n = refl\nantisym (s≤s x≤y) (s≤s y≤x) = cong suc (antisym x≤y y≤x)\n\ntrans : ∀ {x y z} → x ≤ y → y ≤ z → x ≤ z\ntrans z≤n _ = z≤n\ntrans (s≤s x≤y) (s≤s y≤z) = s≤s (trans x≤y y≤z)\n\ntotal : ∀ x y → Either (x ≤ y) (y ≤ x)\ntotal zero _ = left z≤n\ntotal (suc x) zero = right z≤n\ntotal (suc x) (suc y) with total x y\n... | left x≤y = left (s≤s x≤y)\n... | right y≤x = right (s≤s y≤x)\n\nreflexive : ∀ {x y} → x ≡ y → x ≤ y\nreflexive {zero} refl = z≤n\nreflexive {suc _} refl = s≤s (reflexive refl)\n\ntotalOrder : TotalOrder _≡_ _≤_\ntotalOrder = record\n { antisym = antisym\n ; trans = trans\n ; total = total\n ; reflexive = reflexive\n ; equivalence = equivalence\n }\n\n", "meta": {"hexsha": "6cbd099bd646bad9274e6d75322d1b26e2cb3880", "size": 1368, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/topic/order/2013-04-01-sorting-francesco-mazzo/x4-Nat.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/topic/order/2013-04-01-sorting-francesco-mazzo/x4-Nat.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/topic/order/2013-04-01-sorting-francesco-mazzo/x4-Nat.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 24.4285714286, "max_line_length": 73, "alphanum_fraction": 0.4970760234, "num_tokens": 620, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9504109770159682, "lm_q2_score": 0.8128673178375735, "lm_q1q2_score": 0.7725580217303578}} {"text": "-- exercises-01-monday.agda\n\nopen import Data.Nat\n\nvariable\n A B C : Set\n\n-- Exercise 1\n\nadd3 : ℕ → ℕ\nadd3 x = x + 3\n\ntw : (A → A) → A → A\ntw f n = f (f n) -- tw = λ f n → f (f n)\n\n-- evaluate: \"tw tw add3 1\"; derive the result (in a comment) step by step\n{-\n tw tw add3 1 =\n = tw (tw add3) 1 =\n = (tw add3) (tw add3 1) =\n = (tw add3) (add3 (add3 1))\n = tw add3 7 =\n = add3 (add3 7) =\n = 13\n-}\n\n-- Exercise 2\n\n-- derive lambda terms with the following types\n\nf₀ : (A → B) → (B → C) → (A → C)\nf₀ f g a = g (f a)\n\nf₁ : (A → B) → ((A → C) → C) → ((B → C) → C)\nf₁ f g h = g λ a -> h (f a)\n\nf₂ : (A → B → C) → B → A → C\nf₂ f b a = f a b\n\n-- Exercise 3\n\n-- derive a function tw-c which behaves the same as tw using only S, K (and I\n-- which is defined using S and K below).\n\nK : A → B → A\nK = λ a b → a\n\nS : (A → B → C) → (A → B) → A → C\nS = λ f g x → f x (g x)\n\n-- I = λ x → x\nI : A → A\nI {A} = S K (K {B = A})\n\n{-\n λ f n → f (f n) =\n = λ f → λ n → f (f n) =\n = λ f → S (λ n → f) (λ n → f n) =\n = λ f → S (K f) f =\n = S (λ f → S (K f) (λ f → f) =\n = S (S (λ f → S) (λ f → (K f)) I =\n = S (S (K S) K) I =\n-}\n\ntw-c : (A → A) → A → A\ntw-c = S (S (K S) K) I\n", "meta": {"hexsha": "3b8af5ba63501576f184f8c91471b6c2573831c7", "size": 1168, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Type Theory/exercises-01-monday.agda", "max_stars_repo_name": "FoxySeta/mgs-2021", "max_stars_repo_head_hexsha": "f328e596d98a7d052b34144447dd14de0f57e534", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Type Theory/exercises-01-monday.agda", "max_issues_repo_name": "FoxySeta/mgs-2021", "max_issues_repo_head_hexsha": "f328e596d98a7d052b34144447dd14de0f57e534", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2021-07-14T20:34:53.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-14T20:35:48.000Z", "max_forks_repo_path": "Type Theory/exercises-01-monday.agda", "max_forks_repo_name": "FoxySeta/mgs-2021", "max_forks_repo_head_hexsha": "f328e596d98a7d052b34144447dd14de0f57e534", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 17.4328358209, "max_line_length": 77, "alphanum_fraction": 0.4409246575, "num_tokens": 546, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9086178870347122, "lm_q2_score": 0.8499711775577735, "lm_q1q2_score": 0.7722990153929504}} {"text": "{-# OPTIONS --sized-types #-}\nmodule SNat.Order where\n\nopen import Size\nopen import SNat\n\ndata _≤_ : {ι ι' : Size} → SNat {ι} → SNat {ι'} → Set where\n z≤n : {ι ι' : Size} \n → (n : SNat {ι'}) \n → _≤_ (zero {ι}) n\n s≤s : {ι ι' : Size}{m : SNat {ι}}{n : SNat {ι'}} \n → m ≤ n \n → (succ m) ≤ (succ n)\n\ndata _≅_ : {ι ι' : Size} → SNat {ι} → SNat {ι'} → Set where\n z≅z : {ι ι' : Size} \n → zero {ι} ≅ zero {ι'}\n s≅s : {ι ι' : Size}{m : SNat {ι}}{n : SNat {ι'}} \n → m ≅ n \n → succ m ≅ succ n\n\ndata _≤′_ : {ι ι' : Size} → SNat {ι} → SNat {ι'} → Set where\n ≤′-eq : {ι ι' : Size}{m : SNat {ι}}{n : SNat {ι'}} \n → m ≅ n \n → m ≤′ n\n ≤′-step : {ι ι' : Size}{m : SNat {ι}}{n : SNat {ι'}} \n → m ≤′ n \n → m ≤′ succ n\n", "meta": {"hexsha": "653609f43a358946ac44370a671ba888eb9cb663", "size": 904, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/SNat/Order.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/SNat/Order.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/SNat/Order.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.1724137931, "max_line_length": 60, "alphanum_fraction": 0.3462389381, "num_tokens": 362, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9585377261041521, "lm_q2_score": 0.8056321913146127, "lm_q1q2_score": 0.7722288487390141}} {"text": "\nmodule Prelude.Fin where\n\nopen import Prelude.Nat\nopen import Prelude.Equality\nopen import Prelude.Decidable\nopen import Prelude.Ord\nopen import Prelude.Bool\nopen import Prelude.Function\nopen import Prelude.Number\nopen import Prelude.Nat.Properties using (suc-inj)\n\ndata Fin : Nat → Set where\n zero : ∀ {n} → Fin (suc n)\n suc : ∀ {n} (i : Fin n) → Fin (suc n)\n\nfinToNat : ∀ {@erased n} → Fin n → Nat\nfinToNat zero = zero\nfinToNat (suc i) = suc (finToNat i)\n\nfinToNat-inj : ∀ {@erased n} {i j : Fin n} → finToNat i ≡ finToNat j → i ≡ j\nfinToNat-inj {i = zero } {zero } p = refl\nfinToNat-inj {i = zero } {suc j} ()\nfinToNat-inj {i = suc i} {zero } ()\nfinToNat-inj {i = suc i} {suc j} p rewrite finToNat-inj (suc-inj p) = refl\n\nnatToFin : ∀ {n} (m : Nat) {{m -- added in video Lecture 2 4:50\n -- This record has no fields.\n -- This record has exactly one inhabitant.\n\n-- 18:42 -- like Haskell Either\ndata _+_ (S : Set) (T : Set) : Set where\n inl : S -> S + T -- left constructor\n inr : T -> S + T -- right constructor\n\n-- 24:50 -- like Haskell pair ( , )\nrecord _*_ (S : Set) (T : Set) : Set where\n constructor _,_ -- added in video Lecture 2 4:58\n field\n fst : S\n snd : T\n\n------------------------------------------------------------------------------\n-- examples\n\n-- 28:36\ncomm-* : {A : Set} {B : Set} -> A * B -> B * A\ncomm-* record { fst = a ; snd = b } = record { fst = b ; snd = a }\n\n-- 43:00\nassocLR-+ : {A B C : Set} -> (A + B) + C -> A + (B + C)\nassocLR-+ (inl (inl a)) = inl a\nassocLR-+ (inl (inr b)) = inr (inl b)\nassocLR-+ (inr c) = inr (inr c)\n\n-- 47:34\n-- If you can arrive at a contradiction, then you can derive any conclusion.\n-- Given a Zero, must produce an X for ANY X.\n-- But there are no inhabitants of Zero.\n-- So use 'absurd' pattern that indicates something that is IMPOSSIBLE.\nnaughtE : {X : Set} -> Zero -> X\nnaughtE ()\n\n-- standard composition: f << g is \"f after g\"\n_<<_ : {X Y Z : Set} -> (Y -> Z) -> (X -> Y) -> (X -> Z)\n(f << g) x = f (g x)\n\n-- diagrammatic composition: f >> g is \"f then g\"\n_>>_ : {X Y Z : Set} -> (X -> Y) -> (Y -> Z) -> (X -> Z)\n -- ^^^^^^^^ dominoes!\n(f >> g) x = g (f x)\n\n-- infix application\n_$_ : {S : Set}{T : S -> Set}(f : (x : S) -> T x)(s : S) -> T s\nf $ s = f s\ninfixl 2 _$_\n\n-- ==============================================================================\n-- Lecture 2 : more Programs and Proof, Introducing \"with\"\n-- https://www.youtube.com/watch?v=qcVZxQTouDk\n\n-- 2:25\n_$*_ : {A A' B B' : Set} -> (A -> A') -> (B -> B') -> A * B -> A' * B'\n(a→a' $* b→b') (a , b) = (a→a' a) , (b→b' b)\n\n-- 6:53\n_$+_ : {A A' B B' : Set} -> (A -> A') -> (B -> B') -> A + B -> A' + B'\n(a→a' $+ b→b') (inl a) = inl (a→a' a)\n(a→a' $+ b→b') (inr b) = inr (b→b' b)\n\n-- 8:52 -- like Haskell const ; this is pure for applicative functor needing an E\ncombinatorK : {A E : Set} -> A -> E -> A\ncombinatorK a _ = a\n\n-- 11:25 -- this is application\ncombinatorS : {S T E : Set} -> (E -> S -> T) -> (E -> S) -> E -> T\ncombinatorS e→s→t e→s e = e→s→t e (e→s e)\n\n-- 14:50\nidK : {X : Set} -> X -> X\nidK x = combinatorK x x\n\n-- 19:00\nidSKK : {X : Set} -> X -> X\nidSKK {X} = combinatorS combinatorK (combinatorK {E = X}) -- 'Zero' and 'One' also work\n\nid : {X : Set} -> X -> X\n-- id x = x -- is the easy way; let's do it a funny way to make a point\nid = combinatorS combinatorK (combinatorK {_} {Zero})\n-- no choice for -^ ^^^^- could be anything\n\n-- 30:25\n-- naughtE\n\n------------------------------------------------------------------------------\n-- from logic to data\n\n-- 32:05\n\ndata Nat : Set where\n zero : Nat\n suc : Nat -> Nat -- recursive data type\n{-# BUILTIN NATURAL Nat #-} -- enables decimal notation\n\n-- 32:58\n_+N_ : Nat -> Nat -> Nat\nzero +N y = y\nsuc x +N y = suc (x +N y)\n\nfour : Nat\nfour = 2 +N 2\n\n------------------------------------------------------------------------------\n-- and back to logic\n\n-- 36:46\ndata _==_ {X : Set} : X -> X -> Set where\n refl : (x : X) -> x == x -- the relation that is \"only reflexive\"\n{-# BUILTIN EQUALITY _==_ #-}\n\nsee4 : (2 +N 2) == 4\nsee4 = refl 4\n\n-- 42:35\n-- application of equalities\n_=$=_ : {X Y : Set} {f f' : X -> Y} {x x' : X}\n -> f == f'\n -> x == x'\n -> f x == f' x\nrefl f =$= refl x = refl (f x)\n\n------------------------------------------------------------------------------\n-- computing types\n\n-- 45:00\n_>=_ : Nat -> Nat -> Set\nx >= zero = One -- i.e., true\nzero >= suc y = Zero -- i.e., false\nsuc x >= suc y = x >= y\n\n--a0 : 2 >= 4\n--a0 = {!!}\n\na1 : 4 >= 2\na1 = <>\n\nrefl->= : (n : Nat) -> n >= n\nrefl->= zero = <>\nrefl->= (suc n) = refl->= n\n\ntrans->= : (x y z : Nat) -> x >= y -> y >= z -> x >= z\ntrans->= zero zero z x>=y y>=z = y>=z\ntrans->= (suc x) zero zero x>=y y>=z = <>\ntrans->= (suc x) (suc y) zero x>=y y>=z = <>\ntrans->= (suc x) (suc y) (suc z) x>=y y>=z = trans->= x y z x>=y y>=z\n\n------------------------------------------------------------------------------\n-- construction by proof\n\n-- 47:38\n\nrecord Sg (S : Set) (T : S -> Set) : Set where -- Sg is short for \"Sigma\"\n constructor _,_\n field\n fst : S -- a value\n snd : T fst -- some evidence about that value\n\ndifference : (m n : Nat) -> m >= n -> Sg Nat λ d -> m == (n +N d)\ndifference m zero m>=n = m , refl m\ndifference zero (suc n) ()\ndifference (suc m) (suc n) m>=n\n with difference m n m>=n\n...| d , e\n = d , xxx m n d e\n where\n xxx : ∀ (m n d : Nat) -> m == (n +N d) -> suc m == suc (n +N d)\n xxx m n d p rewrite p = refl (suc (n +N d))\n\n-- ==============================================================================\n-- Lecture 3 : Proof by induction\n-- https://www.youtube.com/watch?v=8xFT9FPlm18\n\n-- 6:20\n-- Nat with zero, +N and assocLR-+ form a monoid.\n\n-- 8:48\nzero-+N : (n : Nat) -> (zero +N n) == n\nzero-+N n = refl n -- by definition\n\n-- 9:36\n-- version in video\n-- +N-zero' : (n : Nat) -> (n +N zero) == n\n-- +N-zero' zero = refl zero -- by definition\n-- +N-zero' (suc n) = refl suc =$= +N-zero' n -- TODO : does not compile\n\n-- HC alternate version\n+N-zero : (n : Nat) -> (n +N zero) == n\n+N-zero zero = refl zero -- by definition\n+N-zero (suc n)\n with +N-zero n\n...| n+N0==n\n rewrite n+N0==n\n = refl (suc n)\n\n-- 26:00\n-- version in video\n-- assocLR-+N' : (x y z : Nat) -> ((x +N y) +N z) == (x +N (y +N z))\n-- assocLR-+N' zero y z = refl (y +N z)\n-- assocLR-+N' (suc x) y z = refl suc =$= assocLR-+N' x y z -- TODO : does not compile\n\n-- 30:21\nassocLR-+N : (x y z : Nat) -> ((x +N y) +N z) == (x +N (y +N z))\nassocLR-+N zero y z = refl (y +N z)\nassocLR-+N (suc x) y z\n rewrite assocLR-+N x y z\n = refl (suc (x +N (y +N z)))\n\n------------------------------------------------------------------------------\n-- computing types\n\n-- 34:46\nrefl->=' : (n : Nat) -> n >= n\nrefl->=' zero = <>\nrefl->=' (suc n) = refl->=' n\n\n-- 41:00\ntrans->=' : (x y z : Nat) -> x >= y -> y >= z -> x >= z\n-- start with 'z'\ntrans->=' x y zero x>=y y>=z = <>\ntrans->=' (suc x) (suc y) (suc z) x>=y y>=z = trans->=' x y z x>=y y>=z\n\n-- ==============================================================================\n-- Lecture 4 : Sigma, Difference, Vector Take\n-- https://www.youtube.com/watch?v=OZeDRtRmgkw\n\n-- 0:46 Sigma type (see above)\n\n-- 5:10 -- make _*_ from Sg\n_*'_ : (S : Set) -> (T : Set) -> Set\ns *' t = Sg s λ _ -> t\n\n-- 10:55 difference (see above)\ndifference' : (m n : Nat) -> m >= n -> Sg Nat λ d -> m == (n +N d)\n-- 1st clause of >= matches on right, so start with 'n'\ndifference' m zero m>=n = m , refl m\ndifference' (suc m) (suc n) m>=n\n with difference' m n m>=n\n...| d , m==n+Nd\n rewrite m==n+Nd\n = d , refl (suc (n +N d)) -- video also uses refl suc =$= m==n+Nd\n\n-- 27:24 -- pattern match on proof of equation ; here 'm==n+Nd'\ndifference'' : (m n : Nat) -> m >= n -> Sg Nat λ d -> m == (n +N d)\n-- 1st clause of >= matches on right, so start with 'n'\ndifference'' m zero m>=n = m , refl m\ndifference'' (suc m) (suc n) m>=n\n with difference'' m n m>=n\n...| d , m==n+Nd\n with m==n+Nd\n... | refl .(n +N d) = d , (refl (suc (n +N d)))\n\ntryMe = difference 42 37\n-- dontTryMe = difference 37 42 {!!}\n\n------------------------------------------------------------------------------\n-- things to remember to say\n\n{-\n-- 34:22 : = VIZ ==\n= : makes a definition (part of Agda programming language)\n== : makes a type (by user built definition)\n\nfunction type is both IMPLICATION and UNIVERSAL QUANTIFICATION : why call Pi?\n\nwhy is Sigma called Sigma?\n\n-- 38:50 : B or not B\nmust be able to return a\n- inl B for any B : not possible because nothing known about B\n- inR B→Zero for any B : not possible because Zero has no elements\nexMiddle : {B : Set} -> B + (B -> Zero)\nexMiddle = ?\n\n-- 40:45\n-- not possible to \"look inside\" 'notAandB' to determine 'inl' or 'inr'\ndeMorgan : {A B : Set} -> ((A * B) -> Zero) -> (A -> Zero) + (B -> Zero)\ndeMorgan notAandB = {!!}\n-}\n\n\n\n\n\n", "meta": {"hexsha": "745c976e72a62b33388de67f988026eb069f69dd", "size": 8719, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/course/2017-conor_mcbride_cs410/HC-Lec1.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/course/2017-conor_mcbride_cs410/HC-Lec1.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/course/2017-conor_mcbride_cs410/HC-Lec1.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 28.6809210526, "max_line_length": 87, "alphanum_fraction": 0.4688611079, "num_tokens": 3049, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9241418262465169, "lm_q2_score": 0.8354835391516133, "lm_q1q2_score": 0.7721052836704753}} {"text": "-- A DSL example in the language Agda: \"polynomial types\"\nmodule TypeDSL where\nopen import Data.Empty\nopen import Data.Unit\nopen import Data.Sum\nopen import Data.Product\nopen import Data.Nat\n\ndata E : Set1 where\n Add : E -> E -> E\n Mul : E -> E -> E\n Zero : E\n One : E\n\neval : E -> Set\neval (Add x y) = (eval x) ⊎ (eval y)\neval (Mul x y) = (eval x) × (eval y)\neval Zero = ⊥\neval One = ⊤\n\ntwo = Add One One\nthree = Add One two\n\ntest1 : eval One\ntest1 = tt\n\nfalse : eval two\nfalse = inj₁ tt\ntrue : eval two\ntrue = inj₂ tt\n\ntest3 : eval three\ntest3 = inj₁ tt\n\ncard : E -> ℕ\ncard (Add x y) = card x + card y\ncard (Mul x y) = card x * card y\ncard Zero = 0\ncard One = 1\n\nopen import Data.Vec as V\n\nvariable\n m n : ℕ\n A B : Set\n\nenumAdd : Vec A m -> Vec B n -> Vec (A ⊎ B) (m + n)\nenumAdd xs ys = V.map inj₁ xs ++ V.map inj₂ ys\n\n-- cartesianProduct\nenumMul : Vec A m → Vec B n → Vec (A × B) (m * n)\nenumMul xs ys = concat (V.map (\\a -> V.map ((a ,_)) ys) xs)\n\nenumerate : (t : E) -> Vec (eval t) (card t)\nenumerate (Add x y) = enumAdd (enumerate x) (enumerate y)\nenumerate (Mul x y) = enumMul (enumerate x) (enumerate y) \nenumerate Zero = []\nenumerate One = [ tt ]\n\ntest : Vec (eval three) 3\ntest = enumerate three\n-- inj₁ tt ∷ inj₂ (inj₁ tt) ∷ inj₂ (inj₂ tt) ∷ []\n\n-- Exercise: add a constructor for function types to the syntax E \n", "meta": {"hexsha": "56de41055c9400ccb85a2ae356673800639a6544", "size": 1399, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "L/01/TypeDSL.agda", "max_stars_repo_name": "felixwellen/DSLsofMath", "max_stars_repo_head_hexsha": "22c9e02aaeb505baad7a001f179e0d1e1f6e511c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "L/01/TypeDSL.agda", "max_issues_repo_name": "felixwellen/DSLsofMath", "max_issues_repo_head_hexsha": "22c9e02aaeb505baad7a001f179e0d1e1f6e511c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "L/01/TypeDSL.agda", "max_forks_repo_name": "felixwellen/DSLsofMath", "max_forks_repo_head_hexsha": "22c9e02aaeb505baad7a001f179e0d1e1f6e511c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.5230769231, "max_line_length": 66, "alphanum_fraction": 0.5947105075, "num_tokens": 489, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9496693645535724, "lm_q2_score": 0.8128673223709251, "lm_q1q2_score": 0.7719551935023603}} {"text": "-- Problem 4: ``50 shades of continuity''\n\n{-\nC(f) = ∀ c : X. Cat(f,c)\nCat(f,c) = ∀ ε > 0. ∃ δ > 0. Q(f,c,ε,δ)\nQ(f,c,ε,δ) = ∀ x : X. abs(x - c) < δ ⇒ abs(f x - f c) < ε\n\nC'(f) = ∃ getδ : X -> RPos -> RPos. ∀ c : X. ∀ ε > 0. Q(f,c,ε,getδ c ε)\n\n4a: Define UC(f):\n\nUC(f) = ∀ ε > 0. ∃ δ > 0. ∀ y : X. Q(f,y,ε,δ)\n\n4b: Define UC'(f):\n\nUC'(f) = ∃ newδ : RPos -> RPos. ∀ ε > 0. ∀ y : X. Q(f,y,ε,newδ ε)\n\nThe function |newδ| computes a suitable \"global\" |δ| from any |ε|,\nwhich shows |Q| for any |y|.\n\n4c: Prove |∀ f : X -> ℝ. UC'(f) => C'(f)|.\n\nThe proof is a function from a pair (newδ, puc) to a pair (getδ, pc).\n\nproof f (newδ, puc) = (getδ, pc)\n where getδ c ε = newδ ε\n pc c ε = puc ε c -- (1)\n\nThe type of (1) is\n\n Q(f,c,ε,newδ ε)\n=\n Q(f,c,ε,getδ c ε)\n\nwhich is the type of |pc c ε|.\n\n----------------\n\nBelow is a self-contained proof in Agda just to check the above. It is\nnot part of the exam question.\n\n-}\n\npostulate\n R RPos : Set\n abs : R -> RPos\n _-_ : R -> R -> R\n _<_ : RPos -> RPos -> Set\n\nX = R -- to avoid trouble with lack of subtyping\n\nrecord Sigma (A : Set) (B : A -> Set) : Set where\n constructor _,_\n field\n fst : A\n snd : B fst\n\nQ : (X -> R) -> X -> RPos -> RPos -> Set\nQ f c ε δ = (x : X) -> (abs( x - c) < δ) ->\n (abs(f x - f c) < ε)\n\nCat : (X -> R) -> X -> Set\nCat f c = (ε : RPos) -> Sigma RPos (\\δ ->\n Q f c ε δ)\n\nC : (X -> R) -> Set\nC f = (c : X) -> Cat f c\n\nC' : (X -> R) -> Set\nC' f = Sigma (X -> RPos -> RPos) (\\getδ ->\n (c : X) -> (ε : RPos) -> Q f c ε (getδ c ε))\n\nUC : (X -> R) -> Set\nUC f = (ε : RPos) -> Sigma RPos (\\δ ->\n (y : X) -> Q f y ε δ)\n\nUC' : (X -> R) -> Set\nUC' f = Sigma (RPos -> RPos) (\\newδ ->\n (ε : RPos) -> (y : X) -> Q f y ε (newδ ε))\n\nproof : (f : X -> R) -> UC' f -> C' f\nproof f (newδ , puc) = (getδ , pc)\n where getδ = \\c -> newδ\n pc = \\c ε -> puc ε c\n", "meta": {"hexsha": "eb9e02811a509eff1f63211a6324a194a8087110", "size": 1993, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Exam/2017-08/P4.agda", "max_stars_repo_name": "nicolabotta/DSLsofMath", "max_stars_repo_head_hexsha": "ce764c9bbff5a726d5cf1699a433d9921a1d6a60", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 248, "max_stars_repo_stars_event_min_datetime": "2015-04-27T21:04:02.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-29T11:12:24.000Z", "max_issues_repo_path": "Exam/2017-08/P4.agda", "max_issues_repo_name": "nicolabotta/DSLsofMath", "max_issues_repo_head_hexsha": "ce764c9bbff5a726d5cf1699a433d9921a1d6a60", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 51, "max_issues_repo_issues_event_min_datetime": "2016-01-30T15:59:39.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-03T20:06:39.000Z", "max_forks_repo_path": "Exam/2017-08/P4.agda", "max_forks_repo_name": "nicolabotta/DSLsofMath", "max_forks_repo_head_hexsha": "ce764c9bbff5a726d5cf1699a433d9921a1d6a60", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 47, "max_forks_repo_forks_event_min_datetime": "2015-11-16T08:41:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-03T23:57:42.000Z", "avg_line_length": 23.4470588235, "max_line_length": 78, "alphanum_fraction": 0.4320120421, "num_tokens": 821, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9230391727723469, "lm_q2_score": 0.8354835371034368, "lm_q1q2_score": 0.7711840329528707}} {"text": "module BSTree {A : Set}(_≤_ : A → A → Set) where\n\nopen import BTree {A}\n\ndata _⊴*_ : A → BTree → Set where\n gelf : {x : A} \n → x ⊴* leaf\n gend : {x y : A}{l r : BTree} \n → x ≤ y \n → x ⊴* l \n → x ⊴* (node y l r)\n\ndata _*⊴_ : BTree → A → Set where\n lelf : {x : A} \n → leaf *⊴ x\n lend : {x y : A}{l r : BTree} \n → y ≤ x \n → r *⊴ x \n → (node y l r) *⊴ x\n\ndata BSTree : BTree → Set where\n slf : BSTree leaf\n snd : {x : A}{l r : BTree} \n → BSTree l \n → BSTree r \n → l *⊴ x \n → x ⊴* r \n → BSTree (node x l r) \n\n\n\n", "meta": {"hexsha": "adfe6d5f21762f6d5f167f86afc7fbcc08f6f754", "size": 747, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/BSTree.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/BSTree.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/BSTree.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.34375, "max_line_length": 49, "alphanum_fraction": 0.3172690763, "num_tokens": 258, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9688561703644736, "lm_q2_score": 0.7956581073313275, "lm_q1q2_score": 0.7708782667884753}} {"text": "----------------------------------------------------------------------\n-- Copyright: 2013, Jan Stolarek, Lodz University of Technology --\n-- --\n-- License: See LICENSE file in root of the repo --\n-- Repo address: https://github.com/jstolarek/dep-typed-wbl-heaps --\n-- --\n-- Definition of natural numbers and operations on them. --\n----------------------------------------------------------------------\n\nmodule Basics.Nat where\n\nopen import Basics.Bool\n\n-- Nat represents natural numbers (starting with 0)\ndata Nat : Set where\n zero : Nat\n suc : Nat → Nat\n\n-- We define a constant 1 as it will be useful later on\none : Nat\none = suc zero\n\n-- Addition\n_+_ : Nat → Nat → Nat\nzero + m = m\nsuc n + m = suc (n + m)\n\ninfixl 6 _+_\n\n-- Comparisons needed in our code\n_<_ : Nat → Nat → Bool\nn < zero = false\nzero < suc n = true\nsuc n < suc m = n < m\n\n_≥_ : Nat → Nat → Bool\nm ≥ zero = true\nzero ≥ suc n = false\nsuc m ≥ suc n = m ≥ n\n\ninfixl 4 _<_ _≥_\n", "meta": {"hexsha": "271fdbf0fe30a1fac74c048a355a223725111fa1", "size": 1123, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Basics/Nat.agda", "max_stars_repo_name": "jstolarek/dep-typed-wbl-heaps", "max_stars_repo_head_hexsha": "57db566cb840dc70331c29eb7bf3a0c849f8b27e", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-05-02T21:48:43.000Z", "max_stars_repo_stars_event_max_datetime": "2018-05-02T21:48:43.000Z", "max_issues_repo_path": "src/Basics/Nat.agda", "max_issues_repo_name": "jstolarek/dep-typed-wbl-heaps", "max_issues_repo_head_hexsha": "57db566cb840dc70331c29eb7bf3a0c849f8b27e", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Basics/Nat.agda", "max_forks_repo_name": "jstolarek/dep-typed-wbl-heaps", "max_forks_repo_head_hexsha": "57db566cb840dc70331c29eb7bf3a0c849f8b27e", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.7380952381, "max_line_length": 70, "alphanum_fraction": 0.4612644702, "num_tokens": 272, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9591542817548989, "lm_q2_score": 0.8031737940012418, "lm_q1q2_score": 0.7703675835096182}} {"text": "import Lvl\nopen import Structure.Operator.Vector\nopen import Structure.Setoid\nopen import Type\n\nmodule Structure.Operator.Vector.LinearCombination\n {ℓᵥ ℓₛ ℓᵥₑ ℓₛₑ}\n {V : Type{ℓᵥ}} ⦃ equiv-V : Equiv{ℓᵥₑ}(V) ⦄\n {S : Type{ℓₛ}} ⦃ equiv-S : Equiv{ℓₛₑ}(S) ⦄\n {_+ᵥ_ : V → V → V}\n {_⋅ₛᵥ_ : S → V → V}\n {_+ₛ_ _⋅ₛ_ : S → S → S}\n ⦃ vectorSpace : VectorSpace(_+ᵥ_)(_⋅ₛᵥ_)(_+ₛ_)(_⋅ₛ_) ⦄\n where\n\nopen VectorSpace(vectorSpace)\n\nopen import Data.Tuple using (_⨯_ ; _,_)\nopen import Functional using (id ; _∘_ ; _∘₂_ ; _$_ ; swap ; _on₂_)\nopen import Function.Equals\nopen import Logic\nopen import Logic.Predicate\nopen import Numeral.CoordinateVector as Vec using () renaming (Vector to Vec)\nopen import Numeral.Finite\nopen import Numeral.Natural\nopen import Sets.ExtensionalPredicateSet as PredSet using (PredSet ; _∈_ ; [∋]-binaryRelator)\nopen import Structure.Function.Domain\nopen import Syntax.Function\n\nprivate variable ℓ ℓₗ : Lvl.Level\nprivate variable n : ℕ\n\n-- A linear combination constructed from a sequence of vectors and a sequence of scalars.\n-- Linear combination of 0 scalars and vectors are the zero vector.\n-- Linear combination of 1 scalar and vector is just scalar on vector multiplication.\n-- Example: LinearCombination {4} sf vf = (sf[0] ⋅ₛᵥ vf[0]) +ᵥ (sf[1] ⋅ₛᵥ vf[1]) +ᵥ (sf[2] ⋅ₛᵥ vf[2]) +ᵥ (sf[3] ⋅ₛᵥ vf[3])\n-- Inlined definition:\n-- LinearCombination {0} _ _ = 𝟎ᵥ\n-- LinearCombination {1} vf sf = Vec.proj(sf)(0) ⋅ₛᵥ Vec.proj(vf)(0)\n-- LinearCombination {𝐒(𝐒(n))} vf sf = (Vec.proj(sf)(0) ⋅ₛᵥ Vec.proj(vf)(0)) +ᵥ (LinearCombination {𝐒(n)} (Vec.tail vf) (Vec.tail sf))\nlinearCombination : Vec(n)(V) → Vec(n)(S) → V\nlinearCombination = Vec.reduceOrᵣ(_+ᵥ_) 𝟎ᵥ ∘₂ Vec.map₂(_⋅ᵥₛ_)\n\n-- Whether the two specified vectors are linearly dependent or not.\n-- TODO: Is this definition neccessary?\nLinearlyDependentPair : V → V → Stmt\nLinearlyDependentPair v₁ v₂ = ∃{Obj = S ⨯ S}(\\{(s₁ , s₂) → s₁ ⋅ₛᵥ v₁ ≡ s₂ ⋅ₛᵥ v₂})\n", "meta": {"hexsha": "c21de1c4bdee976daa6bca866302c971b593831e", "size": 1946, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Structure/Operator/Vector/LinearCombination.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Structure/Operator/Vector/LinearCombination.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Structure/Operator/Vector/LinearCombination.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.5416666667, "max_line_length": 136, "alphanum_fraction": 0.6891058582, "num_tokens": 783, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9149009549929797, "lm_q2_score": 0.8418256452674008, "lm_q1q2_score": 0.7701870867927264}} {"text": "{-# BUILTIN NATURAL ℕ #-}\n\nmodule the-naturals where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl)\nopen Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _∎)\n\ninfixl 6 _+_ _∸_\ninfixl 7 _*_\n\n-- the naturals\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\n-- addition\n_+_ : ℕ → ℕ → ℕ\nzero + n = n\n(suc m) + n = suc (m + n)\n\n-- multiplication\n_*_ : ℕ → ℕ → ℕ\nzero * n = zero\n(suc m) * n = n + (m * n)\n\n-- monus ( subtraction for the naturals )\n_∸_ : ℕ → ℕ → ℕ\nm ∸ zero = m\nzero ∸ suc n = zero\nsuc m ∸ suc n = m ∸ n\n\n", "meta": {"hexsha": "a2ffecbed0a3b576537d1af7c6705da337243dee", "size": 552, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/the-naturals.agda", "max_stars_repo_name": "seanwestfall/agda_explorations", "max_stars_repo_head_hexsha": "9fd9fbf9f265bf526a2ec83e9442dedc7106b80c", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/the-naturals.agda", "max_issues_repo_name": "seanwestfall/agda_explorations", "max_issues_repo_head_hexsha": "9fd9fbf9f265bf526a2ec83e9442dedc7106b80c", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/the-naturals.agda", "max_forks_repo_name": "seanwestfall/agda_explorations", "max_forks_repo_head_hexsha": "9fd9fbf9f265bf526a2ec83e9442dedc7106b80c", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 16.7272727273, "max_line_length": 50, "alphanum_fraction": 0.5615942029, "num_tokens": 227, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9648551546097942, "lm_q2_score": 0.7981867705385763, "lm_q1q2_score": 0.7701346198954904}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Sets.EquivalenceRelations\nopen import Setoids.Setoids\n\nmodule Setoids.Product {m n o p : _} {A : Set m} {B : Set n} (R : Setoid {m} {o} A) (S : Setoid {n} {p} B) where\n\nopen Setoid\n\nproductSetoid : Setoid (A && B)\n_∼_ (productSetoid) (a ,, b) (c ,, d) = (Setoid._∼_ R a c) && (Setoid._∼_ S b d)\nEquivalence.reflexive (eq (productSetoid)) {(a ,, b)} = Equivalence.reflexive (Setoid.eq R) ,, Equivalence.reflexive (Setoid.eq S)\nEquivalence.symmetric (eq (productSetoid)) {(a ,, b)} {(c ,, d)} (fst ,, snd) = Equivalence.symmetric (Setoid.eq R) fst ,, Equivalence.symmetric (Setoid.eq S) snd\nEquivalence.transitive (eq (productSetoid)) {a ,, b} {c ,, d} {e ,, f} (fst1 ,, snd1) (fst2 ,, snd2) = Equivalence.transitive (Setoid.eq R) fst1 fst2 ,, Equivalence.transitive (Setoid.eq S) snd1 snd2\n\nproductLift : {r s : A} {t u : B} → (Setoid._∼_ R r s) → (Setoid._∼_ S t u) → Setoid._∼_ productSetoid (r ,, t) (s ,, u)\n_&&_.fst (productLift r=s t=u) = r=s\n_&&_.snd (productLift r=s t=u) = t=u\n", "meta": {"hexsha": "09a9e50f324e54848e837605534f2aa7e86ddd5a", "size": 1077, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Setoids/Product.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Setoids/Product.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Setoids/Product.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 53.85, "max_line_length": 199, "alphanum_fraction": 0.6425255339, "num_tokens": 397, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9314625069680098, "lm_q2_score": 0.8267117962054048, "lm_q1q2_score": 0.7700510422335127}} {"text": "\nmodule Data.Fin where\n\nopen import Data.Nat hiding (_==_; _<_)\nopen import Data.Bool\nopen import Logic.Identity\nopen import Logic.Base\n\ndata Fin : Nat -> Set where\n fzero : {n : Nat} -> Fin (suc n)\n fsuc : {n : Nat} -> Fin n -> Fin (suc n)\n\npred : {n : Nat} -> Fin (suc (suc n)) -> Fin (suc n)\npred fzero = fzero\npred (fsuc i) = i\n\nfzero≠fsuc : {n : Nat}{i : Fin n} -> fzero ≢ fsuc i\nfzero≠fsuc ()\n\nfsuc-inj : {n : Nat}{i j : Fin n} -> fsuc i ≡ fsuc j -> i ≡ j\nfsuc-inj refl = refl\n\n_==_ : {n : Nat}(i j : Fin n) -> i ≡ j \\/ i ≢ j\nfzero == fzero = \\/-IL refl\nfzero == fsuc j = \\/-IR fzero≠fsuc\nfsuc i == fzero = \\/-IR (sym≢ fzero≠fsuc)\nfsuc i == fsuc j = aux i j (i == j)\n where\n aux : {n : Nat}(i j : Fin n) -> i ≡ j \\/ i ≢ j -> fsuc i ≡ fsuc j \\/ fsuc i ≢ fsuc j\n aux i .i (\\/-IL refl) = \\/-IL refl\n aux i j (\\/-IR i≠j) = \\/-IR \\si=sj -> i≠j (fsuc-inj si=sj)\n\n_<_ : {n : Nat} -> Fin n -> Fin n -> Bool\n_ < fzero = false\nfzero < fsuc j = true\nfsuc i < fsuc j = i < j\n\nfromNat : (n : Nat) -> Fin (suc n)\nfromNat zero\t= fzero\nfromNat (suc n) = fsuc (fromNat n)\n\nliftSuc : {n : Nat} -> Fin n -> Fin (suc n)\nliftSuc fzero\t = fzero\nliftSuc (fsuc i) = fsuc (liftSuc i)\n\nlift+ : {n : Nat}(m : Nat) -> Fin n -> Fin (m + n)\nlift+ zero i = i\nlift+ (suc m) i = liftSuc (lift+ m i)\n\nthin : {n : Nat} -> Fin (suc n) -> Fin n -> Fin (suc n)\nthin fzero i\t = fsuc i\nthin (fsuc j) fzero = fzero\nthin (fsuc j) (fsuc i) = fsuc (thin j i)\n\n-- Two elements of Fin n are either the same or one is the thinning of\n-- something with respect to the other.\ndata ThinView : {n : Nat}(i j : Fin n) -> Set where\n same : {n : Nat}{i : Fin n}\t\t -> ThinView i i\n diff : {n : Nat}{i : Fin (suc n)}(j : Fin n) -> ThinView i (thin i j)\n\nthinView : {n : Nat}(i j : Fin n) -> ThinView i j\nthinView fzero fzero\t\t = same\nthinView fzero (fsuc j) = diff j\nthinView {suc zero} (fsuc ()) fzero\nthinView {suc (suc n)} (fsuc i) fzero\t = diff fzero\nthinView (fsuc i) (fsuc j) = aux i j (thinView i j)\n where\n aux : {n : Nat}(i j : Fin n) -> ThinView i j -> ThinView (fsuc i) (fsuc j)\n aux i .i\t same = same\n aux i .(thin i j) (diff j) = diff (fsuc j)\n\nthin-ij≠i : {n : Nat}(i : Fin (suc n))(j : Fin n) -> thin i j ≢ i\nthin-ij≠i fzero j\t ()\nthin-ij≠i (fsuc i) fzero ()\nthin-ij≠i (fsuc i) (fsuc j) eq = thin-ij≠i i j (fsuc-inj eq)\n\n-- Thickening.\n-- thin i (thick i j) ≡ j ?\n-- thick i (thin i j) ≡ j\nthick : {n : Nat}(i j : Fin (suc n)) -> i ≢ j -> Fin n\nthick i j i≠j = thick' i j i≠j (thinView i j) where\n thick' : {n : Nat}(i j : Fin (suc n)) -> i ≢ j -> ThinView i j -> Fin n\n thick' i .i\t i≠i same\t = elim-False (i≠i refl)\n thick' i .(thin i j) _ (diff j) = j\n\n-- thin∘thick=id : {n : Nat}(i j : Fin (suc n))(p : i ≢ j) ->\n-- \t\tthin i (thick i j p) ≡ j\n-- thin∘thick=id i j p = ?\n--\n-- thick∘thin=id : {n : Nat}(i : Fin (suc n))(j : Fin n) ->\n-- \t\tthick i (thin i j) (sym≢ (thin-ij≠i i j)) ≡ j\n-- thick∘thin=id i j = ?\n--\n", "meta": {"hexsha": "eeb59d8ef2b32ce5eb51660468715368e5024696", "size": 2988, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Fin.agda", "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Fin.agda", "max_issues_repo_name": "larrytheliquid/agda", "max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Fin.agda", "max_forks_repo_name": "larrytheliquid/agda", "max_forks_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 31.7872340426, "max_line_length": 88, "alphanum_fraction": 0.5331325301, "num_tokens": 1273, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9263037323284109, "lm_q2_score": 0.8311430499496095, "lm_q1q2_score": 0.7698909092671421}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Experiment.Zero where\n\nopen import Level using (_⊔_)\n\n-- Empty type\ndata ⊥ : Set where\n\n-- Unit type\nrecord ⊤ : Set where\n constructor tt\n\n-- Boolean\ndata Bool : Set where\n true false : Bool\n\n-- Natural number\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\n-- Propositional Equality\ndata _≡_ {a} {A : Set a} (x : A) : A → Set a where\n refl : x ≡ x\n\n-- Sum type\ndata _⊎_ {a} {b} (A : Set a) (B : Set b) : Set (a ⊔ b) where\n inj₁ : A → A ⊎ B\n inj₂ : B → A ⊎ B\n\n-- Dependent Product type\nrecord Σ {a} {b} (A : Set a) (B : A → Set b) : Set (a ⊔ b) where\n constructor _,_\n field\n fst : A\n snd : B fst\n\n-- Induction\n⊤-ind : ∀ {p} {P : ⊤ → Set p} → P tt → ∀ x → P x\n⊤-ind P⊤ tt = P⊤\n\n⊥-ind : ∀ {p} {P : ⊥ → Set p} → ∀ x → P x\n⊥-ind ()\n\nBool-ind : ∀ {p} {P : Bool → Set p} → P true → P false → ∀ x → P x\nBool-ind t e true = t\nBool-ind t e false = e\n\nℕ-ind : ∀ {p} {P : ℕ → Set p} → P zero → (∀ m → P m → P (suc m)) → ∀ n → P n\nℕ-ind P0 Ps zero = P0\nℕ-ind P0 Ps (suc n) = Ps n (ℕ-ind P0 Ps n)\n\n≡-ind : ∀ {a p} {A : Set a}\n (P : (x y : A) → x ≡ y → Set p) →\n (∀ x → P x x refl) →\n ∀ x y (eq : x ≡ y) → P x y eq\n≡-ind P Pr x .x refl = Pr x\n\n⊎-ind : ∀ {a b p} {A : Set a} {B : Set b} {P : A ⊎ B → Set p} →\n (∀ x → P (inj₁ x)) → (∀ y → P (inj₂ y)) → ∀ s → P s\n⊎-ind i1 i2 (inj₁ x) = i1 x\n⊎-ind i1 i2 (inj₂ y) = i2 y\n\nΣ-ind : ∀ {a b p} {A : Set a} {B : A → Set b} {P : Σ A B → Set p} →\n (∀ x y → P (x , y)) → ∀ p → P p\nΣ-ind f (x , y) = f x y\n", "meta": {"hexsha": "15211498c51d3fdb09bda4ed4d919c6c6228a802", "size": 1523, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Experiment/Zero.agda", "max_stars_repo_name": "rei1024/agda-misc", "max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z", "max_issues_repo_path": "Experiment/Zero.agda", "max_issues_repo_name": "rei1024/agda-misc", "max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Experiment/Zero.agda", "max_forks_repo_name": "rei1024/agda-misc", "max_forks_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.3970588235, "max_line_length": 76, "alphanum_fraction": 0.4674983585, "num_tokens": 703, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8933093975331751, "lm_q2_score": 0.8615382076534742, "lm_q1q2_score": 0.7696201772307365}} {"text": "\nmodule Problem3 where\n\nopen import Problem1\nopen import Problem2\n\ndata Fin : Nat -> Set where\n fzero : {n : Nat} -> Fin (suc n)\n fsuc : {n : Nat} -> Fin n -> Fin (suc n)\n\ndata False : Set where\n\n-- 3.1\n\nempty : Fin zero -> False\nempty ()\n\n-- 3.2\n\n_!_ : {A : Set}{n : Nat} -> Vec A n -> Fin n -> A\nε ! ()\n(x ► xs) ! fzero = x\n(x ► xs) ! fsuc i = xs ! i\n\n-- 3.3\n\n-- The simply typed composition would do here, but the more\n-- dependent version is more interesting.\n-- _∘_ : {A B C : Set} -> (B -> C) -> (A -> B) -> A -> C\n\n_∘_ : {A B : Set}{C : B -> Set}(f : (x : B) -> C x)\n (g : A -> B)(x : A) -> C (g x)\n(f ∘ g) x = f (g x)\n\ntabulate : {A : Set}{n : Nat} -> (Fin n -> A) -> Vec A n\ntabulate {n = zero } f = ε\ntabulate {n = suc n} f = f fzero ► tabulate (f ∘ fsuc)\n", "meta": {"hexsha": "9fc78185cc7e29371f7a84eeef404b2c68692444", "size": 782, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/SummerSchool07/Solutions/Problem3.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/SummerSchool07/Solutions/Problem3.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/SummerSchool07/Solutions/Problem3.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 20.5789473684, "max_line_length": 59, "alphanum_fraction": 0.5012787724, "num_tokens": 310, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9334308147331957, "lm_q2_score": 0.8244619285331332, "lm_q1q2_score": 0.7695781696671842}} {"text": "module Nat where\n\ndata Nat : Set\n\ndata Nat where\n zero : Nat\n suc : Nat -> Nat\n\nplus : Nat -> Nat -> Nat\nplus zero n = n\nplus (suc m) n = suc (plus m n)\n\nelim : (P : (n : Nat) -> Set) ->\n (z : P (plus zero zero)) ->\n (s : (n : Nat) -> P (plus zero n) -> P (plus (suc zero) n)) ->\n (n : Nat) -> P n\nelim P z s zero = z\nelim P z s (suc n) = s n (elim P z s n)\n", "meta": {"hexsha": "4ab64de6a2384eaa3940d66fe10269bd07df7b96", "size": 385, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/prototyping/term/examples/Nat.agda", "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z", "max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z", "max_issues_repo_path": "src/prototyping/term/examples/Nat.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/prototyping/term/examples/Nat.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 20.2631578947, "max_line_length": 69, "alphanum_fraction": 0.4831168831, "num_tokens": 146, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9579122720843812, "lm_q2_score": 0.803173791645582, "lm_q1q2_score": 0.7693700316338469}} {"text": "module Ag13 where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl)\nopen Eq.≡-Reasoning\nopen import Data.Nat using (ℕ; zero; suc)\nopen import Data.Product using (_×_) renaming (_,_ to ⟨_,_⟩)\nopen import Data.Sum using (_⊎_; inj₁; inj₂)\nopen import Relation.Nullary using (¬_)\nopen import Relation.Nullary.Negation using ()\n renaming (contradiction to ¬¬-intro)\nopen import Data.Unit using (⊤; tt)\nopen import Data.Empty using (⊥; ⊥-elim)\nopen import Ag09 using (_⇔_)\n\ndata Bool : Set where\n true : Bool\n false : Bool\n\nT : Bool → Set\nT true = ⊤\nT false = ⊥\n\nT→≡ : ∀ (b : Bool) → T b → b ≡ true\nT→≡ true tt = refl\nT→≡ false ()\n\n≡→T : ∀ {b : Bool} → b ≡ true → T b\n≡→T refl = tt\n\ndata Dec (A : Set) : Set where\n yes : A → Dec A\n no : ¬ A → Dec A\n\ninfix 4 _≤_\n\ndata _≤_ : ℕ → ℕ → Set where\n\n z≤n : ∀ {n : ℕ}\n --------\n → zero ≤ n\n\n s≤s : ∀ {m n : ℕ}\n → m ≤ n\n -------------\n → suc m ≤ suc n\n\n¬s≤z : ∀ {m : ℕ} → ¬ (suc m ≤ zero)\n¬s≤z ()\n\n¬s≤s : ∀ {m n : ℕ} → ¬ (m ≤ n) → ¬ (suc m ≤ suc n)\n¬s≤s ¬m≤n (s≤s m≤n) = ¬m≤n m≤n\n\n_≤?_ : ∀ (m n : ℕ) → Dec (m ≤ n)\nzero ≤? n = yes z≤n\nsuc m ≤? zero = no ¬s≤z\nsuc m ≤? suc n with m ≤? n\n... | yes m≤n = yes (s≤s m≤n)\n... | no ¬m≤n = no (¬s≤s ¬m≤n)\n\n\n", "meta": {"hexsha": "a34c317f1a8815c1d76005a6bade258219473616", "size": 1319, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Agda/Ag13.agda", "max_stars_repo_name": "Brethland/LEARNING-STUFF", "max_stars_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-02-03T05:05:52.000Z", "max_stars_repo_stars_event_max_datetime": "2020-03-11T10:35:42.000Z", "max_issues_repo_path": "Agda/Ag13.agda", "max_issues_repo_name": "Brethland/LEARNING-STUFF", "max_issues_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Agda/Ag13.agda", "max_forks_repo_name": "Brethland/LEARNING-STUFF", "max_forks_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-12-13T04:50:46.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-13T04:50:46.000Z", "avg_line_length": 21.2741935484, "max_line_length": 60, "alphanum_fraction": 0.5003790751, "num_tokens": 554, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9161096112990283, "lm_q2_score": 0.8397339736884712, "lm_q1q2_score": 0.7692883642303339}} {"text": "module Algebra.Dioid where\n\nrecord Dioid A (_≡_ : A -> A -> Set) : Set where\n field\n zero : A\n one : A\n _+_ : A -> A -> A\n _*_ : A -> A -> A\n\n reflexivity : ∀ {r : A} -> r ≡ r\n symmetry : ∀ {r s : A} -> r ≡ s -> s ≡ r\n transitivity : ∀ {r s t : A} -> r ≡ s -> s ≡ t -> r ≡ t\n\n +left-congruence : ∀ {r s t : A} -> r ≡ s -> (r + t) ≡ (s + t)\n -- +right-congruence holds but as a theorem, please see below\n *left-congruence : ∀ {r s t : A} -> r ≡ s -> (r * t) ≡ (s * t)\n *right-congruence : ∀ {r s t : A} -> r ≡ s -> (t * r) ≡ (t * s)\n\n +idempotence : ∀ {r : A} -> (r + r) ≡ r\n +commutativity : ∀ {r s : A} -> (r + s) ≡ (s + r)\n +associativity : ∀ {r s t : A} -> (r + (s + t)) ≡ ((r + s) + t)\n +zero-identity : ∀ {r : A} -> (r + zero) ≡ r\n\n *associativity : ∀ {r s t : A} -> (r * (s * t)) ≡ ((r * s) * t)\n *left-zero : ∀ {r : A} -> (zero * r) ≡ zero\n *right-zero : ∀ {r : A} -> (r * zero) ≡ zero\n *left-identity : ∀ {r : A} -> (one * r) ≡ r\n *right-identity : ∀ {r : A} -> (r * one) ≡ r\n\n left-distributivity : ∀ {r s t : A} -> (r * (s + t)) ≡ ((r * s) + (r * t))\n right-distributivity : ∀ {r s t : A} -> ((r + s) * t) ≡ ((r * t) + (s * t))\n\n -- For convenience to avoid `Dioid._+_ d r s`\n plus : A -> A -> A\n plus x y = x + y\n\n times : A -> A -> A\n times x y = x * y\n\n+right-congruence : ∀ {D eq} {d : Dioid D eq} {r s t : D} -> eq r s -> eq (Dioid.plus d t r) (Dioid.plus d t s)\n+right-congruence {_} {_} {d} {r} {s} {t} e = trans commut (trans (Dioid.+left-congruence d e) commut)\n where\n trans = Dioid.transitivity d\n commut = Dioid.+commutativity d\n", "meta": {"hexsha": "fdb959123b24fa66fbb299406cebe83e7a0ecdb7", "size": 1746, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Algebra/Dioid.agda", "max_stars_repo_name": "snowleopard/alga-proofs", "max_stars_repo_head_hexsha": "0fdb96c0233d9be83eba637f0434d0fd22aefb1d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 60, "max_stars_repo_stars_event_min_datetime": "2017-12-27T14:57:04.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T23:05:29.000Z", "max_issues_repo_path": "src/Algebra/Dioid.agda", "max_issues_repo_name": "snowleopard/alga-proofs", "max_issues_repo_head_hexsha": "0fdb96c0233d9be83eba637f0434d0fd22aefb1d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2018-04-12T16:25:13.000Z", "max_issues_repo_issues_event_max_datetime": "2018-06-23T13:54:02.000Z", "max_forks_repo_path": "src/Algebra/Dioid.agda", "max_forks_repo_name": "snowleopard/alga-proofs", "max_forks_repo_head_hexsha": "0fdb96c0233d9be83eba637f0434d0fd22aefb1d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 6, "max_forks_repo_forks_event_min_datetime": "2017-12-17T20:48:20.000Z", "max_forks_repo_forks_event_max_datetime": "2019-05-09T23:53:28.000Z", "avg_line_length": 38.8, "max_line_length": 111, "alphanum_fraction": 0.4163802978, "num_tokens": 736, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9304582516374121, "lm_q2_score": 0.8267117919359419, "lm_q1q2_score": 0.7692208085327485}} {"text": "module Acc where\n\ndata Acc ( A : Set ) ( Lt : A -> A -> Set) : A -> Set where\n acc : ( b : A ) \n -> ( ( a : A ) -> Lt a b -> Acc A Lt a )\n -> ( Acc A Lt b )\n\ndata Nat : Set where\n zero : Nat\n succ : Nat -> Nat\n\ndata Lt : Nat -> Nat -> Set where\n ltzero : ( x : Nat ) -> Lt zero (succ x)\n ltsucc : ( x : Nat ) -> (y : Nat) -> Lt x y -> Lt (succ x) (succ y)\n\nltstep : (x : Nat) -> Lt x (succ x)\nltstep zero = ltzero _\nltstep (succ x) = ltsucc _ _ (ltstep x)\n\nnotLt0 : ( x : Nat ) -> Lt x zero -> (C : Set) -> C\nnotLt0 x ()\n\nwkLt : ( x y : Nat ) -> Lt (succ x) (succ y) -> Lt x y\nwkLt zero (succ y) _ = ltzero y\nwkLt x zero (ltsucc .x .zero ())\nwkLt x y (ltsucc .x .y p) = p \n\n{-\nwkLt1 : ( x y : Nat ) -> Lt (succ x) y -> Lt x y\nwkLt1 x zero ()\nwkLt1 zero (succ y) _ = ltzero y \nwkLt1 (succ x) (succ y) (ltsucc .(succ x) .y p) = ltsucc x y (wkLt1 x y p) \n-}\n\nwkLt2 : (x y : Nat ) -> Lt x y -> Lt x (succ y)\nwkLt2 x zero () \nwkLt2 zero y p = ltzero y \nwkLt2 (succ x) (succ y) (ltsucc .x .y p) = ltsucc x (succ y) (wkLt2 x y p) \n\nltcase : ( x : Nat ) -> ( y : Nat ) -> Lt x (succ y) -> \n ( P : Nat -> Set ) -> ( (x' : Nat ) -> Lt x' y -> P x') -> P y -> P x\nltcase zero zero _ P hx' hy = hy\nltcase zero (succ y') _ P hx' hy = hx' zero (ltzero y')\nltcase (succ x') zero (ltsucc .x' .zero ()) _ _ _\nltcase (succ x') (succ y') (ltsucc .x' .(succ y') p) P hx' hy = \n ltcase x' y' p (\\ n -> P (succ n))\n (\\ x'' p' -> hx' (succ x'') (ltsucc x'' y' p')) hy\n\naccSucc : (x : Nat) -> Acc Nat Lt x -> Acc Nat Lt (succ x)\naccSucc x (acc .x h) = acc (succ x) (\\ y p -> ltcase y x p (Acc Nat Lt) h (acc x h))\n\n\naccLt : ( x : Nat ) -> Acc Nat Lt x\naccLt zero = acc zero (\\a -> \\p -> notLt0 a p (Acc Nat Lt a) )\naccLt (succ x) = accSucc x (accLt x)\n\n\n-- subtraction x - y\n\nsub : Nat -> Nat -> Nat\nsub zero y = zero\nsub (succ x) zero = succ x\nsub (succ x) (succ y) = sub x y\n\nsubLt : (x y : Nat) -> Lt (sub (succ x) (succ y)) (succ x)\nsubLt zero y = ltzero _\nsubLt (succ x') zero = ltstep (succ x')\nsubLt (succ x') (succ y') = wkLt2 _ _ (subLt x' y')\n\n-- division x / (y + 1)\n\ndiv' : (x y : Nat) -> Acc Nat Lt x -> Nat\ndiv' zero _ _ = zero\ndiv' (succ x') y' (acc ._ h) = succ (div' z y' (h _ p)) \n where z = sub (succ x') (succ y')\n p = subLt x' y'\n\n\n----\n\ndata WO ( A : Set ) ( Lt : A -> A -> Set ) : Set where\n wo : ((x : A) -> Acc A Lt x) -> WO A Lt \n\nwoLt : WO Nat Lt\nwoLt = wo accLt\n\n\n", "meta": {"hexsha": "e3ec5b648993552555e8d0e7316088178e4bb95a", "size": 2426, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/AccP.agda", "max_stars_repo_name": "andreasabel/miniagda", "max_stars_repo_head_hexsha": "4a674eddcc8950f37fcc723b26f81d5164b05f08", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 85, "max_stars_repo_stars_event_min_datetime": "2016-12-16T15:53:24.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-12T16:54:56.000Z", "max_issues_repo_path": "examples/AccP.agda", "max_issues_repo_name": "andreasabel/miniagda", "max_issues_repo_head_hexsha": "4a674eddcc8950f37fcc723b26f81d5164b05f08", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 7, "max_issues_repo_issues_event_min_datetime": "2016-12-16T15:48:25.000Z", "max_issues_repo_issues_event_max_datetime": "2020-03-17T08:09:01.000Z", "max_forks_repo_path": "examples/AccP.agda", "max_forks_repo_name": "andreasabel/miniagda", "max_forks_repo_head_hexsha": "4a674eddcc8950f37fcc723b26f81d5164b05f08", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 5, "max_forks_repo_forks_event_min_datetime": "2019-03-30T00:17:04.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-16T07:47:36.000Z", "avg_line_length": 27.5681818182, "max_line_length": 84, "alphanum_fraction": 0.5028854081, "num_tokens": 986, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9407897492587141, "lm_q2_score": 0.817574471748733, "lm_q1q2_score": 0.7691656822768161}} {"text": "module Issue637 where\n\ndata Nat : Set where\n zero : Nat\n suc : Nat → Nat\n\ninfixl 60 _+_\n_+_ : Nat → Nat → Nat\nzero + n = n\nsuc m + n = suc (n + m)\n\ndata _≡_ {A : Set}(x : A) : A → Set where\n refl : x ≡ x\n\n`1 = suc zero\n`2 = suc `1\n`3 = suc `2\n`4 = `2 + `2\n`8 = `4 + `4\n`16 = `8 + `8\n`32 = `16 + `16\n`50 = `32 + `16 + `2\n`64 = `32 + `32\n`100 = `64 + `32 + `4\n`200 = `100 + `100\n`400 = `200 + `200\n`800 = `400 + `400\n`1000 = `800 + `200\n`2000 = `1000 + `1000\n`4000 = `2000 + `2000\n\nprf : `16 ≡ (`4 + (`4 + `8))\nprf = refl\n\ninfixr 40 _∷_\ndata Vec : Nat → Set where\n [] : Vec zero\n _∷_ : ∀ {n} → Nat → Vec n → Vec (suc n)\n\nfromN : ∀ {n} → Nat → Vec n\nfromN {zero} _ = []\nfromN {suc n} x = x ∷ fromN (suc x)\n\nsum : ∀ {n} → Vec n → Nat\nsum [] = zero\nsum (n ∷ ns) = n + sum ns\n\nprf₁ : sum (fromN {`100} `1) ≡ (`4000 + `1000 + `50)\nprf₁ = refl\n", "meta": {"hexsha": "d9c552f3bf1f8f808372d35ebb1e5dc38226ff71", "size": 842, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/interaction/Issue637.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/interaction/Issue637.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/interaction/Issue637.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 16.84, "max_line_length": 52, "alphanum_fraction": 0.4798099762, "num_tokens": 407, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9372107984180245, "lm_q2_score": 0.8198933425148213, "lm_q1q2_score": 0.7684128941559384}} {"text": "open import Agda.Builtin.Nat\nopen import Agda.Builtin.Equality\n\ncong : {A B : Set} (f : A → B)\n → {x y : A} → x ≡ y → f x ≡ f y\ncong f refl = refl\n\n+-identityʳ : (x : Nat) → x + 0 ≡ x\n+-identityʳ zero = refl\n+-identityʳ (suc n) = cong suc (+-identityʳ n)\n\n+-assoc : (x y z : Nat) → (x + y) + z ≡ x + (y + z)\n+-assoc zero _ _ = refl\n+-assoc (suc m) n o = cong suc (+-assoc m n o)\n\ndata Bin : Set where\n nil : Bin\n x0_ : Bin → Bin\n x1_ : Bin → Bin\n\ninc : Bin → Bin\ninc nil = x1 nil\ninc (x0 x) = x1 x\ninc (x1 x) = x0 (inc x)\n\nto : Nat → Bin\nto zero = (x0 nil)\nto (suc x) = inc (to x)\n\npostulate\n from : Bin → Nat\n\ndata Can : Bin → Set where\n Can- : ∀ {n} → from (to n) ≡ n → Can (to n)\n\ndata Σ (A : Set) (B : A → Set) : Set where\n ⟨_,_⟩ : (x : A) → B x → Σ A B\n\npostulate\n to'' : (x : Nat) → Σ Bin Can\n\nto∘from' : (a : Bin) → (b : Can a) → to'' (from a) ≡ ⟨ a , b ⟩\nto∘from' .(to _) (Can- x) = {!!}\n", "meta": {"hexsha": "7e99d65d5190319f03df495f902b320107f963c0", "size": 913, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Fail/Issue3813.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Fail/Issue3813.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Fail/Issue3813.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 20.75, "max_line_length": 62, "alphanum_fraction": 0.5082146769, "num_tokens": 405, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9425067163548471, "lm_q2_score": 0.8152324871074608, "lm_q1q2_score": 0.768362094489448}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Numbers.Naturals.Semiring -- for length\nopen import Lists.Definition\nopen import Lists.Fold.Fold\n\nmodule Lists.Length where\n\nlength : {a : _} {A : Set a} (l : List A) → ℕ\nlength [] = zero\nlength (x :: l) = succ (length l)\n\nlength' : {a : _} {A : Set a} → (l : List A) → ℕ\nlength' = fold (λ _ → succ) 0\n\nlength=length' : {a : _} {A : Set a} (l : List A) → length l ≡ length' l\nlength=length' [] = refl\nlength=length' (x :: l) = applyEquality succ (length=length' l)\n", "meta": {"hexsha": "d770c9aad3d0d663795f4b6470ea26687c4a6bb5", "size": 557, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Lists/Length.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Lists/Length.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Lists/Length.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 27.85, "max_line_length": 72, "alphanum_fraction": 0.6337522442, "num_tokens": 181, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9173026618464795, "lm_q2_score": 0.8376199673867852, "lm_q1q2_score": 0.7683510256996594}} {"text": "\nmodule Prelude where\n\nid : {A : Set} -> A -> A\nid x = x\n\n_·_ : {A B C : Set} -> (B -> C) -> (A -> B) -> (A -> C)\nf · g = \\ x -> f (g x)\n\nflip : {A B C : Set} -> (A -> B -> C) -> B -> A -> C\nflip f x y = f y x\n\nRel : Set -> Set1\nRel X = X -> X -> Set\n\ndata False : Set where\nrecord True : Set where\n\ntt : True\ntt = _\n\n! : {A : Set} -> A -> True\n! = _\n\ndata _==_ {A : Set}(x : A) : A -> Set where\n refl : x == x\n\nsubst : {A : Set}(P : A -> Set){x y : A} -> x == y -> P y -> P x\nsubst P refl p = p\n\ncong : {A B : Set}(f : A -> B){x y : A} -> x == y -> f x == f y\ncong f refl = refl\n\nsym : {A : Set}{x y : A} -> x == y -> y == x\nsym refl = refl\n\ntrans : {A : Set}{x y z : A} -> x == y -> y == z -> x == z\ntrans refl yz = yz\n\ndata _×_ (A B : Set) : Set where\n _,_ : A -> B -> A × B\n\ninfixr 10 _,_\n\nrecord Σ (A : Set)(B : A -> Set) : Set where\n field\n fst : A\n snd : B fst\n\n_,,_ : {A : Set}{B : A -> Set}(x : A) -> B x -> Σ A B\nx ,, y = record { fst = x; snd = y }\n\nprivate module Σp {A : Set}{B : A -> Set} = Σ {A}{B}\nopen Σp public\n\ndata _∨_ (A B : Set) : Set where\n inl : A -> A ∨ B\n inr : B -> A ∨ B\n\ndata Bool : Set where\n false : Bool\n true : Bool\n\nIsTrue : Bool -> Set\nIsTrue false = False\nIsTrue true = True\n\nIsFalse : Bool -> Set\nIsFalse true = False\nIsFalse false = True\n\ndata Inspect (b : Bool) : Set where\n itsTrue : IsTrue b -> Inspect b\n itsFalse : IsFalse b -> Inspect b\n\ninspect : (b : Bool) -> Inspect b \ninspect true = itsTrue _\ninspect false = itsFalse _\n\ndata LeqBool : Rel Bool where\n ref : {b : Bool} -> LeqBool b b\n up : LeqBool false true\n\nOne : Rel True\nOne _ _ = True\n\n_[×]_ : {A B : Set} -> Rel A -> Rel B -> Rel (A × B)\n(R [×] S) (a₁ , b₁) (a₂ , b₂) = R a₁ a₂ × S b₁ b₂\n", "meta": {"hexsha": "95c9defc30a18b5b09df754ae9fc41378aa7b079", "size": 1717, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/AIM6/Path/Prelude.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/AIM6/Path/Prelude.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/AIM6/Path/Prelude.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.2921348315, "max_line_length": 64, "alphanum_fraction": 0.495049505, "num_tokens": 701, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9173026595857204, "lm_q2_score": 0.8376199552262967, "lm_q1q2_score": 0.768351012651154}} {"text": "\nmodule Numeric.Nat.GCD where\n\nopen import Prelude\nopen import Control.WellFounded\nopen import Numeric.Nat.Properties\nopen import Numeric.Nat.DivMod\nopen import Numeric.Nat.Divide\nopen import Numeric.Nat.Divide.Properties\nopen import Tactic.Nat\n\n--- GCD ---\n\nrecord IsGCD (d a b : Nat) : Set where\n no-eta-equality\n constructor is-gcd\n field d|a : d Divides a\n d|b : d Divides b\n g : ∀ k → k Divides a → k Divides b → k Divides d\n\nrecord GCD (a b : Nat) : Set where\n no-eta-equality\n constructor gcd-res\n field d : Nat\n isGCD : IsGCD d a b\n\nopen GCD public using () renaming (d to get-gcd)\n\n-- Projections --\n\nis-gcd-factor₁ : ∀ {a b d} → IsGCD d a b → Nat\nis-gcd-factor₁ g = get-factor (IsGCD.d|a g)\n\nis-gcd-factor₂ : ∀ {a b d} → IsGCD d a b → Nat\nis-gcd-factor₂ g = get-factor (IsGCD.d|b g)\n\ngcd-factor₁ : ∀ {a b} → GCD a b → Nat\ngcd-factor₁ g = is-gcd-factor₁ (GCD.isGCD g)\n\ngcd-factor₂ : ∀ {a b} → GCD a b → Nat\ngcd-factor₂ g = is-gcd-factor₂ (GCD.isGCD g)\n\n-- Euclid's algorithm --\n\nisGCD-step : ∀ {d r₀ r₁ r₂} q → q * r₁ + r₂ ≡ r₀ → IsGCD d r₁ r₂ → IsGCD d r₀ r₁\nisGCD-step q refl (is-gcd d|r₁ d|r₂ g) =\n is-gcd (divides-add (divides-mul-r q d|r₁) d|r₂)\n d|r₁ (λ k k|r₀ k|r₁ → g k k|r₁ (divides-sub-l k|r₀ (divides-mul-r q k|r₁)))\n\nprivate\n gcd-step : ∀ {a b} q {r} → q * suc b + r ≡ a → GCD (suc b) r → GCD a (suc b)\n gcd-step q eq (gcd-res d p) = gcd-res d (isGCD-step q eq p)\n\n gcd-cert-acc : ∀ a b → Acc _<_ b → GCD a b\n gcd-cert-acc a zero _ = gcd-res a (is-gcd (factor 1 auto) (factor! 0) (λ k k|a _ → k|a))\n gcd-cert-acc a (suc b) (acc wf) =\n case a divmod suc b of λ\n { (qr q r lt eq) → gcd-step q eq (gcd-cert-acc (suc b) r (wf r lt)) }\n\neraseIsGCD : ∀ {d a b} → IsGCD d a b → IsGCD d a b\neraseIsGCD (is-gcd d|a d|b g) =\n is-gcd (fast-divides d|a) (fast-divides d|b)\n λ k k|a k|b → fast-divides (g k k|a k|b)\n\neraseGCD : ∀ {a b} → GCD a b → GCD a b\neraseGCD (gcd-res d p) = gcd-res d (eraseIsGCD p)\n\ngcd : ∀ a b → GCD a b\ngcd 0 b = gcd-res b (is-gcd (factor! 0) divides-refl (λ _ _ k|b → k|b))\ngcd 1 b = gcd-res 1 (is-gcd divides-refl (factor b auto) (λ _ k|1 _ → k|1))\ngcd a b = eraseGCD (gcd-cert-acc a b (wfNat b))\n\ngcd! : Nat → Nat → Nat\ngcd! a b = get-gcd (gcd a b)\n\nCoprime : Nat → Nat → Set\nCoprime a b = gcd! a b ≡ 1\n", "meta": {"hexsha": "d749bab4ef2352be2baa9575419135d09ef61461", "size": 2302, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Numeric/Nat/GCD.agda", "max_stars_repo_name": "lclem/agda-prelude", "max_stars_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Numeric/Nat/GCD.agda", "max_issues_repo_name": "lclem/agda-prelude", "max_issues_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Numeric/Nat/GCD.agda", "max_forks_repo_name": "lclem/agda-prelude", "max_forks_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.5128205128, "max_line_length": 90, "alphanum_fraction": 0.6059947871, "num_tokens": 933, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.921921841290738, "lm_q2_score": 0.833324587033253, "lm_q1q2_score": 0.7682601376705404}} {"text": "module Fin where\n\ndata Nat : Set where\n zero : Nat\n succ : Nat -> Nat\n\ndata Fin : Nat -> Set where\n fzero : {n : Nat} -> Fin (succ n)\n fsucc : {n : Nat} -> Fin n -> Fin (succ n)\n", "meta": {"hexsha": "2476f46c256bd8855039d89a21454c0d67805cd6", "size": 186, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "tests/covered/Fin.agda", "max_stars_repo_name": "andrejtokarcik/agda-semantics", "max_stars_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-08-10T15:33:56.000Z", "max_stars_repo_stars_event_max_datetime": "2018-12-06T17:24:25.000Z", "max_issues_repo_path": "tests/covered/Fin.agda", "max_issues_repo_name": "andrejtokarcik/agda-semantics", "max_issues_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tests/covered/Fin.agda", "max_forks_repo_name": "andrejtokarcik/agda-semantics", "max_forks_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.6, "max_line_length": 46, "alphanum_fraction": 0.5483870968, "num_tokens": 63, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9653811621568289, "lm_q2_score": 0.7956580927949807, "lm_q1q2_score": 0.7681133343019044}} {"text": "\nmodule Problem2 where\n\nopen import Problem1\n\ninfixr 40 _►_\n\ndata Vec (A : Set) : Nat -> Set where\n ε : Vec A zero\n _►_ : {n : Nat} -> A -> Vec A n -> Vec A (suc n)\n\n-- 2.1\n\nvec : {A : Set}{n : Nat} -> A -> Vec A n\nvec {n = zero } x = ε\nvec {n = suc n} x = x ► vec x\n\n-- 2.2\n\ninfixl 80 _<*>_\n\n_<*>_ : {A B : Set}{n : Nat} -> Vec (A -> B) n -> Vec A n -> Vec B n\nε <*> ε = ε\n(f ► fs) <*> (x ► xs) = f x ► fs <*> xs\n\n-- 2.3\n\nmap : {A B : Set}{n : Nat} -> (A -> B) -> Vec A n -> Vec B n\nmap f xs = vec f <*> xs\n\n-- 2.4\n\nzip : {A B C : Set}{n : Nat} -> (A -> B -> C) ->\n Vec A n -> Vec B n -> Vec C n\nzip f xs ys = vec f <*> xs <*> ys\n", "meta": {"hexsha": "3be2ea86ad9aae2e4ff43a70597c3c0ce8c47e8e", "size": 654, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/SummerSchool07/Solutions/Problem2.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/SummerSchool07/Solutions/Problem2.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/SummerSchool07/Solutions/Problem2.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 18.1666666667, "max_line_length": 68, "alphanum_fraction": 0.4311926606, "num_tokens": 279, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9362850093037731, "lm_q2_score": 0.8198933381139646, "lm_q1q2_score": 0.767653841704135}} {"text": "module Prelude.Fin where\n\nopen import Prelude.Eq\nopen import Prelude.Nat\n\ndata Fin : Nat -> Set where\n fz : ∀{n} -> Fin (S n)\n fs : ∀{n} -> Fin n -> Fin (S n)\n\nforget : {n : Nat} -> Fin n -> Nat\nforget fz = Z\nforget (fs n) = S (forget n)\n\ninject : (n : Nat) -> Fin (S n)\ninject Z = fz\ninject (S n) = fs (inject n)\n\ninc : {n : Nat} -> Fin n -> Fin (S n)\ninc fz = fz\ninc (fs n) = fs (inc n)\n", "meta": {"hexsha": "bcd8ec4ffd940f44530bf16b6f04a0abd0600dd2", "size": 399, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/epic/Prelude/Fin.agda", "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/epic/Prelude/Fin.agda", "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/epic/Prelude/Fin.agda", "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 19.0, "max_line_length": 37, "alphanum_fraction": 0.5438596491, "num_tokens": 147, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9362850039701653, "lm_q2_score": 0.8198933315126792, "lm_q1q2_score": 0.7676538311504609}} {"text": "module plfa-exercises.part1.Decidable where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl; sym; cong)\nopen Eq.≡-Reasoning\nopen import Data.Nat using (ℕ; zero; suc; pred)\nopen import Data.Product using (_×_) renaming (_,_ to ⟨_,_⟩)\nopen import Data.Sum using (_⊎_; inj₁; inj₂)\nopen import Relation.Nullary using (¬_)\nopen import Relation.Nullary.Negation using ()\n renaming (contradiction to ¬¬-intro)\nopen import Data.Unit using (⊤; tt)\nopen import Data.Empty using (⊥; ⊥-elim)\nopen import plfa.part1.Relations using (_<_; z reduces to: λ m n → T (m ≤ᵇ n)\n-- Ohh! Ok. It is because the third rule of `≤ᵇ` reduces `suc m ≤ᵇ suc n` to `m ≤ᵇ n`\n≤ᵇ→≤ {suc m} {suc n} t = s≤s (≤ᵇ→≤ {m} {n} t)\n-- λ m → T (suc m ≤ᵇ zero) => reduces to: λ m → ⊥\n-- which means that there are no rules for `fromᵇ {suc m} {zero}`\n≤ᵇ→≤ {suc m} {zero} ()\n\nproof≡computation : ∀ {m n} → (m ≤ n) ⇔ T (m ≤ᵇ n)\nproof≡computation {m} {n} =\n record\n { from = ≤ᵇ→≤\n ; to = ≤→≤ᵇ\n }\n\nT→≡ : ∀ (b : Bool) → T b → b ≡ true\nT→≡ true tt = refl\nT→≡ false ()\n\n--postulate\n-- lie : false ≡ true\n\n≡→T : ∀ {b : Bool} → b ≡ true → T b\n--≡→T {false} refl = ? -- This is impossible because of refl's definition. Unification forces `b` to be `true`\n--≡→T {false} rewrite lie = λ refl → ? -- Even postulating a lie, it is impossible to create a bottom value\n≡→T refl = tt\n\n_ : 2 ≤ 4\n_ = ≤ᵇ→≤ tt\n\n¬4≤2₂ : ¬ (4 ≤ 2)\n--¬4≤2₂ 4≤2 = ≤→≤ᵇ 4≤2\n--¬4≤2₂ = ≤→≤ᵇ {4} {2}\n-- The type of `T (4 ≤ᵇ 2)` which reduces to `T false` and then `⊥`\n¬4≤2₂ = ≤→≤ᵇ\n-- Notice how defining ≤ᵇ lifts from us the demand of computing the correct\n-- `evidence` (implementation) for the `proof` (function type)\n\n\ndata Dec (A : Set) : Set where\n yes : A → Dec A\n no : ¬ A → Dec A\n\n¬s≤z : {m : ℕ} → ¬ (suc m) ≤ zero\n--¬s≤z = ≤→≤ᵇ\n¬s≤z ()\n\n¬s≤s : {m n : ℕ} → ¬ m ≤ n → ¬ suc m ≤ suc n\n¬s≤s ¬m≤n = λ { (s≤s m≤n) → ¬m≤n m≤n }\n\n_≤?_ : (m n : ℕ) → Dec (m ≤ n)\nzero ≤? n = yes z≤n\n(suc m) ≤? zero = no ¬s≤z\n(suc m) ≤? (suc n) with m ≤? n\n... | yes m≤n = yes (s≤s m≤n)\n... | no ¬m≤n = no (¬s≤s ¬m≤n)\n\n-- `2 ≤? 4` reduces to `yes (s≤s (s≤s z≤n))`\n_ : Dec (2 ≤ 4)\n_ = 2 ≤? 4\n_ = yes (s≤s (s≤s (z≤n {2})))\n\n⌊_⌋ : ∀ {A : Set} → Dec A → Bool\n⌊ yes x ⌋ = true\n⌊ no ¬x ⌋ = false\n\n_ : Bool\n_ = true\n_ = ⌊ 3 ≤? 4 ⌋\n\n_ : ⌊ 3 ≤? 4 ⌋ ≡ true\n_ = refl\n\n_ : ⌊ 3 ≤? 2 ⌋ ≡ false\n_ = refl\n\ntoWitness : ∀ {A : Set} {D : Dec A} → T ⌊ D ⌋ → A\ntoWitness {_} {yes v} tt = v\n--toWitness {_} {no _} = ? -- `T ⌊ no x ⌋ → A` reduces to `⊥ → A`\ntoWitness {_} {no _} () -- Empty because there is no value for `⊥`\n\nfromWitness : ∀ {A : Set} {D : Dec A} → A → T ⌊ D ⌋\nfromWitness {_} {yes _} _ = tt\nfromWitness {_} {no ¬a} a = ¬a a -- with type ⊥\n\n_ : 2 ≤ 4\n--_ = toWitness {D = 2 ≤? 4} tt\n_ = toWitness {_} {2 ≤? 4} tt\n\n¬4≤2₃ : ¬ (4 ≤ 2)\n--¬4≤2₃ = fromWitness {D = 4 ≤? 2}\n¬4≤2₃ = fromWitness {_} {4 ≤? 2}\n\n¬z Set (a ⊔ ℓ)\nMultiplicativeInverse 0# = NonZero 0# → NonZero 0#\n\nrecord IsField (_+_ _*_ : Op₂ A) (0# 1# : A) (-_ : Op₁ A) (_⁻¹ : MultiplicativeInverse 0#) : Set (a ⊔ ℓ) where\n field\n isCommutativeRing : IsCommutativeRing _+_ _*_ -_ 0# 1#\n _⁻¹-involutive : ∀ (x : NonZero 0#) → NonZero.value ((x ⁻¹) ⁻¹) ≈ NonZero.value x\n _⁻¹-inverse : ∀ (x : NonZero 0#) → ((NonZero.value x) * (NonZero.value (x ⁻¹))) ≈ 1#\n 0#-not-1# : ¬ (0# ≈ 1#)\n\n open IsCommutativeRing isCommutativeRing public\n\n open import Algebra.Properties.Ring (record { isRing = isRing }) public\n", "meta": {"hexsha": "9de497b077e85ca77fd2819d7a9a975d7002ab1d", "size": 1053, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Algebra/Structures/Field.agda", "max_stars_repo_name": "felko/linear-algebra", "max_stars_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 15, "max_stars_repo_stars_event_min_datetime": "2019-11-02T14:11:00.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-30T06:18:08.000Z", "max_issues_repo_path": "src/Algebra/Structures/Field.agda", "max_issues_repo_name": "felko/linear-algebra", "max_issues_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Algebra/Structures/Field.agda", "max_forks_repo_name": "felko/linear-algebra", "max_forks_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.4594594595, "max_line_length": 110, "alphanum_fraction": 0.6353276353, "num_tokens": 386, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9441768620069627, "lm_q2_score": 0.8128673087708699, "lm_q1q2_score": 0.7674905048233248}} {"text": "module Data.List.First {ℓ}{A : Set ℓ} where\n\nopen import Data.Product\nopen import Data.List\nopen import Relation.Nullary\nopen import Relation.Binary.PropositionalEquality\nopen import Level\nopen import Function\nopen import Data.Empty\n\n-- proof that an element is the first in a vector to satisfy the predicate B\ndata First {b}(B : A → Set b) : (x : A) → List A → Set (ℓ ⊔ b) where\n\n here : ∀ {x : A} → (p : B x) → {v : List A} → First B x (x ∷ v)\n there : ∀ {x} {v : List A} (x' : A) → ¬ (B x') → First B x v → First B x (x' ∷ v)\n\n-- get the witness of B x from the element ∈ First\nfirst⟶witness : ∀ {B : A → Set} {x l} → First B x l → B x\nfirst⟶witness (here p) = p\nfirst⟶witness (there x ¬px f) = first⟶witness f\n\n-- more likable syntax for the above structure\nfirst_∈_⇒_ : ∀ {p} → A → List A → (B : A → Set p) → Set (p ⊔ ℓ)\nfirst_∈_⇒_ x v p = First p x v\n\n-- a decision procedure to find the first element in a vector that satisfies a predicate\nfind : ∀ (P : A → Set) → ((a : A) → Dec (P a)) → (v : List A) →\n Dec (∃ λ e → first e ∈ v ⇒ P)\nfind P dec [] = no (λ{ (e , ()) })\nfind P dec (x ∷ v) with dec x\nfind P dec (x ∷ v) | yes px = yes (x , here px)\nfind P dec (x ∷ v) | no ¬px with find P dec v\nfind P dec (x ∷ v) | no ¬px | yes firstv = yes (-, there x ¬px (proj₂ firstv))\nfind P dec (x ∷ v) | no ¬px | no ¬firstv = no $ helper ¬px ¬firstv\n where\n helper : ¬ (P x) → ¬ (∃ λ e → First P e v) → ¬ (∃ λ e → First P e (x ∷ v))\n helper ¬px ¬firstv (.x , here p) = ¬px p\n helper ¬px ¬firstv (u , there ._ _ firstv) = ¬firstv (u , firstv)\n", "meta": {"hexsha": "b350a774d08b9f919ccd6fc0e341ca5dafcbaf72", "size": 1559, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/List/First.agda", "max_stars_repo_name": "metaborg/mj.agda", "max_stars_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z", "max_issues_repo_path": "src/Data/List/First.agda", "max_issues_repo_name": "metaborg/mj.agda", "max_issues_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z", "max_forks_repo_path": "src/Data/List/First.agda", "max_forks_repo_name": "metaborg/mj.agda", "max_forks_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z", "avg_line_length": 39.9743589744, "max_line_length": 88, "alphanum_fraction": 0.5824246312, "num_tokens": 586, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9334308184368928, "lm_q2_score": 0.8221891305219504, "lm_q1q2_score": 0.7674566730130215}} {"text": "\n-- This module introduces the basic structure of an Agda program.\n\n{- Every Agda file contains a single top-level module. To make it possible to\n find the file corresponding to a particular module, the name of the file\n should correspond to the name of the module. In this case the module\n 'Introduction.Basics' is defined in the file 'Introduction/Basics.agda'.\n-}\nmodule Basics where\n\n{- The top-level module contains a sequence of declarations, such as datatype\n declarations and function definitions. The most common forms of declarations\n are introduced below.\n\n A module can also contain sub-modules, see 'Introduction.Modules.SubModules'\n for more information.\n-}\n\n-- Agda can be used as a pure logical framework. The 'postulate' declaration\n-- introduces new constants :\npostulate\n N : Set -- Set is the first universe\n z : N\n s : N -> N -- The independent function space is written A -> B\n\n-- Using 'postulate' it is not possible to introduce new computation rules. A\n-- better way is to introduce a datatype and define functions by pattern\n-- matching on elements of the datatype.\n\n-- A datatype is introduced with the 'data' keyword. All constructors of the\n-- datatype are given with their types after the 'where'. Datatypes can be\n-- parameterised (see 'Introduction.Data.Parameterised').\n\ndata Bool : Set where\n false : Bool\n true : Bool\n\ndata Nat : Set where\n zero : Nat\n suc : Nat -> Nat\n\n-- Functions over datatypes can be defined by pattern matching.\n\nplus : Nat -> Nat -> Nat\nplus zero m = m\nplus (suc n) m = suc (plus n m)\n\n-- With this definition plus (suc zero) (suc zero) will reduce to suc (suc\n-- zero).\n\n-- When defining mutually recursive functions you have to declare functions\n-- before they can be called.\n\nodd : Nat -> Bool\n\neven : Nat -> Bool\neven (suc n) = odd n\neven zero = true\n\nodd zero = false\nodd (suc n) = even n\n\n-- Agda is a monomorphic, but dependently typed, language. This means that\n-- polymorphism is simulated by having functions take type arguments. For\n-- instance, the polymorphic identity function can be represented as follows :\n\nid : (A : Set) -> A -> A -- the dependent function space is written (x : A) -> B\nid A x = x\n\none : Nat\none = id Nat (suc zero) -- a silly use of the identity function\n\n-- To faithfully simulate a polymorphic function we would like to omit the type\n-- argument when using the function. See 'Introduction.Implicit' for\n-- information on how to do this.\n\n-- Agda is both a programming language and a formal proof language, so we\n-- expect to be able to prove theorems about our programs. As an example we\n-- prove the very simple theorem n + 0 == n.\n\n-- First we introduce datatypes for truth (a singleton type) and falsity (an\n-- empty type).\n\ndata True : Set where -- Here it would make sense to declare True to be a\n tt : True -- Prop (the universe of propositions) rather than a\n -- Set. See 'Introduction.Universes' for more\n -- information.\n\ndata False : Set where -- see 'Introduction.Data.Empty' for more information\n -- on empty types.\n\n-- Second, we define what it means for two natural numbers to be equal. Infix\n-- operators are declared by enclosing the operator in _. See\n-- 'Introduction.Operators' for more information.\n\n_==_ : Nat -> Nat -> Set\nzero == zero = True\nzero == suc m = False\nsuc n == zero = False\nsuc n == suc m = n == m\n\n-- Now we are ready to state and prove our theorem. The proof is by induction\n-- (i.e. recursion) on 'n'.\n\nthmPlusZero : (n : Nat) -> plus n zero == n -- A function from a number n to\n -- P n can be seen as the\n -- proposition ∀ n. P n.\nthmPlusZero zero = tt\nthmPlusZero (suc n) = thmPlusZero n\n\nthmPlusZero' : (n : Nat) -> plus zero n == n\nthmPlusZero' zero = tt\nthmPlusZero' (suc n) = thmPlusZero' n\n\n\n{- In both branches the reduction makes the proof very simple. In the first\n case the goal is\n\n plus zero zero == zero which reduces to\n zero == zero and\n True\n\n In the second case we have\n\n plus (suc n) zero == suc n\n suc (plus n zero) == suc n\n plus n zero == n\n\n so the induction hypothesis (the recursive call) is directly applicable.\n-}\n", "meta": {"hexsha": "75f5723f471d5967d094d40abed113f62ff0b9c8", "size": 4342, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "tests/covered/Basics.agda", "max_stars_repo_name": "andrejtokarcik/agda-semantics", "max_stars_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-08-10T15:33:56.000Z", "max_stars_repo_stars_event_max_datetime": "2018-12-06T17:24:25.000Z", "max_issues_repo_path": "tests/covered/Basics.agda", "max_issues_repo_name": "andrejtokarcik/agda-semantics", "max_issues_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tests/covered/Basics.agda", "max_forks_repo_name": "andrejtokarcik/agda-semantics", "max_forks_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.1450381679, "max_line_length": 87, "alphanum_fraction": 0.6731920774, "num_tokens": 1080, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9184802417938535, "lm_q2_score": 0.8354835432479661, "lm_q1q2_score": 0.7673751268171773}} {"text": "{-\n\nThis file introduces the \"powerset\" of a type in the style of\nEscardó's lecture notes:\n\nhttps://www.cs.bham.ac.uk/~mhe/HoTT-UF-in-Agda-Lecture-Notes/HoTT-UF-Agda.html#propositionalextensionality\n\n-}\n{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Foundations.Powerset where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Foundations.Structure\nopen import Cubical.Foundations.Function\nopen import Cubical.Foundations.Univalence using (hPropExt)\n\nopen import Cubical.Data.Sigma\n\nprivate\n variable\n ℓ : Level\n X : Type ℓ\n\nℙ : Type ℓ → Type (ℓ-suc ℓ)\nℙ X = X → hProp _\n\ninfix 5 _∈_\n\n_∈_ : {X : Type ℓ} → X → ℙ X → Type ℓ\nx ∈ A = ⟨ A x ⟩\n\n_⊆_ : {X : Type ℓ} → ℙ X → ℙ X → Type ℓ\nA ⊆ B = ∀ x → x ∈ A → x ∈ B\n\n∈-isProp : (A : ℙ X) (x : X) → isProp (x ∈ A)\n∈-isProp A = snd ∘ A\n\n⊆-isProp : (A B : ℙ X) → isProp (A ⊆ B)\n⊆-isProp A B = isPropΠ2 (λ x _ → ∈-isProp B x)\n\n⊆-refl : (A : ℙ X) → A ⊆ A\n⊆-refl A x = idfun (x ∈ A)\n\n⊆-refl-consequence : (A B : ℙ X) → A ≡ B → (A ⊆ B) × (B ⊆ A)\n⊆-refl-consequence A B p = subst (A ⊆_) p (⊆-refl A)\n , subst (B ⊆_) (sym p) (⊆-refl B)\n\n⊆-extensionality : (A B : ℙ X) → (A ⊆ B) × (B ⊆ A) → A ≡ B\n⊆-extensionality A B (φ , ψ) =\n funExt (λ x → TypeOfHLevel≡ 1 (hPropExt (A x .snd) (B x .snd) (φ x) (ψ x)))\n\npowersets-are-sets : isSet (ℙ X)\npowersets-are-sets = isSetΠ (λ _ → isSetHProp)\n\n⊆-extensionalityEquiv : (A B : ℙ X) → (A ⊆ B) × (B ⊆ A) ≃ (A ≡ B)\n⊆-extensionalityEquiv A B = isoToEquiv (iso (⊆-extensionality A B)\n (⊆-refl-consequence A B)\n (λ _ → powersets-are-sets A B _ _)\n (λ _ → isPropΣ (⊆-isProp A B) (λ _ → ⊆-isProp B A) _ _))\n", "meta": {"hexsha": "6ce7c884b5c612cb05330f991ffd423d43b1261b", "size": 1886, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Foundations/Powerset.agda", "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Foundations/Powerset.agda", "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_forks_repo_path": "Cubical/Foundations/Powerset.agda", "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.9365079365, "max_line_length": 106, "alphanum_fraction": 0.5699893955, "num_tokens": 764, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8887587964389113, "lm_q2_score": 0.8633916117313211, "lm_q1q2_score": 0.7673468896977808}} {"text": "{- 1. Booleans -}\n\ndata Bool : Set where\n true : Bool\n false : Bool\n\nnot : Bool → Bool\nnot true = false\nnot false = true\n\n_∧_ : Bool → Bool → Bool\ntrue ∧ true = true\ntrue ∧ false = false\nfalse ∧ true = false\nfalse ∧ false = false\n\n_∨_ : Bool → Bool → Bool\ntrue ∨ true = true\ntrue ∨ false = true\nfalse ∨ true = true\nfalse ∨ false = false\n\n{- 2. Equality -}\ndata _≡_ {A : Set} (x : A) : (y : A) → Set where\n refl : x ≡ x\n\ninfix 4 _≡_\n\nnot-inv : (b : Bool) → not (not b) ≡ b\nnot-inv true = refl\nnot-inv false = refl\n\nf : (b : Bool) → (not b) ∧ b ≡ false\nf true = refl\nf false = refl\n\n\n", "meta": {"hexsha": "b6f61cc449028916401ed577c8f3181101912d89", "size": 585, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "TD6/Bool.agda", "max_stars_repo_name": "erwinkn/program-eq-proof", "max_stars_repo_head_hexsha": "9a0d4a3f97103550a67e5e9ecbc8322bf0a8be23", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "TD6/Bool.agda", "max_issues_repo_name": "erwinkn/program-eq-proof", "max_issues_repo_head_hexsha": "9a0d4a3f97103550a67e5e9ecbc8322bf0a8be23", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "TD6/Bool.agda", "max_forks_repo_name": "erwinkn/program-eq-proof", "max_forks_repo_head_hexsha": "9a0d4a3f97103550a67e5e9ecbc8322bf0a8be23", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 15.3947368421, "max_line_length": 48, "alphanum_fraction": 0.5829059829, "num_tokens": 220, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9770226287518853, "lm_q2_score": 0.7853085758631159, "lm_q1q2_score": 0.7672642491711807}} {"text": "{-# OPTIONS --warning=error --safe --without-K #-}\n\nopen import LogicalFormulae\nopen import Numbers.Naturals.Definition\nopen import Numbers.Naturals.Addition\nopen import Numbers.Naturals.Multiplication\nopen import Semirings.Definition\nopen import Monoids.Definition\n\nmodule Numbers.Naturals.Semiring where\n\nopen Numbers.Naturals.Definition using (ℕ ; zero ; succ ; succInjective ; naughtE) public\nopen Numbers.Naturals.Addition using (_+N_ ; canSubtractFromEqualityRight ; canSubtractFromEqualityLeft) public\nopen Numbers.Naturals.Multiplication using (_*N_ ; multiplicationNIsCommutative) public\n\nℕSemiring : Semiring 0 1 _+N_ _*N_\nMonoid.associative (Semiring.monoid ℕSemiring) a b c = equalityCommutative (additionNIsAssociative a b c)\nMonoid.idLeft (Semiring.monoid ℕSemiring) _ = refl\nMonoid.idRight (Semiring.monoid ℕSemiring) a = additionNIsCommutative a 0\nSemiring.commutative ℕSemiring = additionNIsCommutative\nMonoid.associative (Semiring.multMonoid ℕSemiring) = multiplicationNIsAssociative\nMonoid.idLeft (Semiring.multMonoid ℕSemiring) a = additionNIsCommutative a 0\nMonoid.idRight (Semiring.multMonoid ℕSemiring) a = transitivity (multiplicationNIsCommutative a 1) (additionNIsCommutative a 0)\nSemiring.productZeroLeft ℕSemiring _ = refl\nSemiring.productZeroRight ℕSemiring a = multiplicationNIsCommutative a 0\nSemiring.+DistributesOver* ℕSemiring = productDistributes\nSemiring.+DistributesOver*' ℕSemiring a b c rewrite multiplicationNIsCommutative (a +N b) c | multiplicationNIsCommutative a c | multiplicationNIsCommutative b c = productDistributes c a b\n\nsuccExtracts : (x y : ℕ) → (x +N succ y) ≡ (succ (x +N y))\nsuccExtracts x y = transitivity (Semiring.commutative ℕSemiring x (succ y)) (applyEquality succ (Semiring.commutative ℕSemiring y x))\n\nproductZeroImpliesOperandZero : {a b : ℕ} → a *N b ≡ 0 → (a ≡ 0) || (b ≡ 0)\nproductZeroImpliesOperandZero {zero} {b} pr = inl refl\nproductZeroImpliesOperandZero {succ a} {zero} pr = inr refl\nproductZeroImpliesOperandZero {succ a} {succ b} ()\n\n*NWellDefined : {a b c d : ℕ} → (a ≡ c) → (b ≡ d) → a *N b ≡ c *N d\n*NWellDefined refl refl = refl\n\n+NWellDefined : {a b c d : ℕ} → (a ≡ c) → (b ≡ d) → a +N b ≡ c +N d\n+NWellDefined refl refl = refl\n", "meta": {"hexsha": "40c7b910a65edc9eaf468909da427d6e415b434a", "size": 2208, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numbers/Naturals/Semiring.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Numbers/Naturals/Semiring.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Numbers/Naturals/Semiring.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 52.5714285714, "max_line_length": 188, "alphanum_fraction": 0.7753623188, "num_tokens": 701, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9136765257642906, "lm_q2_score": 0.8397339676722393, "lm_q1q2_score": 0.7672452141490347}} {"text": "open import Relation.Binary.Core\n\nmodule TreeSort.Impl1.Correctness.Permutation {A : Set}\n (_≤_ : A → A → Set)\n (tot≤ : Total _≤_) where\n\nopen import BTree {A}\nopen import Data.List\nopen import Data.Sum\nopen import List.Permutation.Base A\nopen import List.Permutation.Base.Concatenation A\nopen import List.Permutation.Base.Equivalence A\nopen import TreeSort.Impl1 _≤_ tot≤\n\nlemma-++∼ : {x : A}{xs ys : List A} → (x ∷ (xs ++ ys)) ∼ (xs ++ (x ∷ ys))\nlemma-++∼ {xs = xs} = ∼x /head (lemma++/l {xs = xs} /head) refl∼\n\nlemma-flatten∼ : (x : A) → (t : BTree) → (x ∷ flatten t) ∼ flatten (insert x t)\nlemma-flatten∼ x leaf = ∼x /head /head ∼[]\nlemma-flatten∼ x (node y l r) \n with tot≤ x y\n... | inj₁ x≤y = lemma++∼r (lemma-flatten∼ x l)\n... | inj₂ y≤x = trans∼ (lemma-++∼ {xs = flatten l}) (lemma++∼l {xs = flatten l} (∼x (/tail /head) /head (lemma-flatten∼ x r)))\n\ntheorem-treeSort∼ : (xs : List A) → xs ∼ (flatten (treeSort xs))\ntheorem-treeSort∼ [] = ∼[]\ntheorem-treeSort∼ (x ∷ xs) = trans∼ (∼x /head /head (theorem-treeSort∼ xs)) (lemma-flatten∼ x (treeSort xs)) \n\n\n\n\n", "meta": {"hexsha": "f37837655194338e96ced6a0c43fecb1011e1333", "size": 1105, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/TreeSort/Impl1/Correctness/Permutation.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/TreeSort/Impl1/Correctness/Permutation.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/TreeSort/Impl1/Correctness/Permutation.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.53125, "max_line_length": 127, "alphanum_fraction": 0.6045248869, "num_tokens": 413, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9465966671870767, "lm_q2_score": 0.8104789155369048, "lm_q1q2_score": 0.7671966402726302}} {"text": "module Graph where\n\nimport Lvl\nopen import Data.Tuple as Tuple using (_⨯_ ; _,_)\nopen import Functional\nopen import Data.List\nopen import Logic.Propositional{Lvl.𝟎}\nopen import Logic.Predicate{Lvl.𝟎}{Lvl.𝟎}\nopen import Relator.Equals{Lvl.𝟎}\nopen import Data.List.Relation.Membership{Lvl.𝟎} using (_∈_)\n\n-- EdgeClass(V)(E) means that E is a type which can represent an edge between vertices of type V.\nrecord EdgeClass (V : Set) (Self : Set) : Set where\n constructor edgeInstance\n field\n from : Self → V\n to : Self → V\n _withVertices_ : Self → (V ⨯ V) → Self\n\nmodule Edge where\n open EdgeClass ⦃ ... ⦄ public\n\ninstance\n EdgeInstance-Tuple : ∀{V} → EdgeClass(V)(V ⨯ V)\n Edge.from ⦃ EdgeInstance-Tuple ⦄ (v₁ , v₂) = v₁\n Edge.to ⦃ EdgeInstance-Tuple ⦄ (v₁ , v₂) = v₂\n Edge._withVertices_ ⦃ EdgeInstance-Tuple ⦄ (v₁ , v₂) (w₁ , w₂) = (w₁ , w₂)\n\nrecord Graph (V : Set) (E : Set) ⦃ _ : EdgeClass(V)(E) ⦄ : Set where\n constructor graph\n\n field\n edges : List(E)\n\n -- Propositions\n HasEdge[_⟶_] : V → V → Set\n HasEdge[_⟶_](v₁)(v₂) = ∃(edge ↦ (edge ∈ edges)∧(Edge.from(edge) ≡ v₁)∧(Edge.to(edge) ≡ v₂))\n\n HasEdge[_⟵_] : V → V → Set\n HasEdge[_⟵_](v₁)(v₂) = HasEdge[_⟶_](v₂)(v₁)\n\n HasEdge[_⟷_] : V → V → Set\n HasEdge[_⟷_](v₁)(v₂) = HasEdge[_⟵_](v₁)(v₂) ∧ HasEdge[_⟶_](v₁)(v₂)\n\n data Path : V → V → Set where\n PathIntro : ∀{v₁ v₂ : V} → HasEdge[ v₁ ⟶ v₂ ] → Path(v₁)(v₂)\n PathTransitivity : ∀{v₁ v₂ v₃ : V} → Path(v₁)(v₂) → Path(v₂)(v₃) → Path(v₁)(v₃)\n\n Connected : V → V → Set\n Connected(v₁)(v₂) = Path(v₁)(v₂)\n\n Disconnected : V → V → Set\n Disconnected(v₁)(v₂) = ¬(Connected(v₁)(v₂))\n\n -- Constructions\n mapVertices : ∀{V₂} → ⦃ _ : EdgeClass(V₂)(E) ⦄ → (V → V₂) → Graph(V₂)(E)\n mapVertices(f) = record{edges = map(edge ↦ (edge Edge.withVertices(f(Edge.from(edge)) , f(Edge.to(edge))))) (edges)}\n\n -- Boolean testing\n -- with-edge\n -- without-edge\n -- has-edge\n -- is-connected\n -- is-disconnected\n", "meta": {"hexsha": "f3ef25f4368f0104341d40d7eadad0f4b09097c7", "size": 1987, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "old/Graph.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "old/Graph.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "old/Graph.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.5692307692, "max_line_length": 118, "alphanum_fraction": 0.6059386009, "num_tokens": 775, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.92522995296862, "lm_q2_score": 0.8289388104343892, "lm_q1q2_score": 0.7669590165920738}} {"text": "module fib1 where\n\ndata ℕ : Set where\n Z : ℕ \n S : ℕ -> ℕ \n\n\n_+_ : ℕ -> ℕ -> ℕ\nn + Z = n\nn + S m = S (n + m)\n\none : ℕ \none = S Z\n\nfib : ℕ -> ℕ\nfib Z = one\nfib (S Z) = one\nfib (S (S n)) = fib n + fib (S n)\n", "meta": {"hexsha": "b86b813c518a2bf0b9c9d0de5cfdbf57fe957f61", "size": 222, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "tests/covered/fib1.agda", "max_stars_repo_name": "andrejtokarcik/agda-semantics", "max_stars_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-08-10T15:33:56.000Z", "max_stars_repo_stars_event_max_datetime": "2018-12-06T17:24:25.000Z", "max_issues_repo_path": "tests/covered/fib1.agda", "max_issues_repo_name": "andrejtokarcik/agda-semantics", "max_issues_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tests/covered/fib1.agda", "max_forks_repo_name": "andrejtokarcik/agda-semantics", "max_forks_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 11.6842105263, "max_line_length": 33, "alphanum_fraction": 0.4099099099, "num_tokens": 97, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9693242018339896, "lm_q2_score": 0.79053032607222, "lm_q1q2_score": 0.7662801773455181}} {"text": "module start where\n\nopen import Relation.Binary.PropositionalEquality\nopen import Data.Product\nopen import Function hiding (id)\n\n\ninjective : {A B : Set} → (f : A → B) → Set\ninjective f = ∀ a₁ a₂ → f a₁ ≡ f a₂ → a₁ ≡ a₂\n\nsurjective : {A B : Set} → (f : A → B) → Set\nsurjective f = ∀ b → ∃ (λ a → f a ≡ b)\n\nbijective : {A B : Set} → (f : A → B) → Set\nbijective f = injective f × surjective f\n\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\n\nlemma-suc-inj : ∀ {a₁ a₂} → suc a₁ ≡ suc a₂ → a₁ ≡ a₂\nlemma-suc-inj refl = refl\n\nsuc-injective : injective suc\nsuc-injective a₁ a₂ = lemma-suc-inj\n\nid : {A : Set} → A → A\nid x = x\n\nlemma-id-inj : ∀ {A} {a₁ a₂ : A} → id a₁ ≡ id a₂ → a₁ ≡ a₂\nlemma-id-inj refl = refl\n\nid-injective : ∀ {A} → injective (id {A})\nid-injective a₁ a₂ = lemma-id-inj\n\nlemma-id-surj : ∀ {A} (b : A) → ∃ (λ a → id a ≡ b)\nlemma-id-surj b = b , refl\n\nid-surjective : ∀ {A} → surjective (id {A})\nid-surjective = lemma-id-surj\n\nbijective→injective : ∀ {A B} {f : A → B} → bijective f → injective f\nbijective→injective b = proj₁ b\n\nbijective→surjective : ∀ {A B} {f : A → B} → bijective f → surjective f\nbijective→surjective b = proj₂ b\n\nleft-inverse : ∀ {A B} → (f : A → B) → Set\nleft-inverse f = ∃ (λ g → g ∘ f ≡ id)\n\nright-inverse : ∀ {A B} → (f : A → B) → Set\nright-inverse f = ∃ (λ g → f ∘ g ≡ id)\n\ninfix 5 _s~_\n_s~_ : {A : Set} {a b c : A} → a ≡ b → a ≡ c → c ≡ b\n_s~_ refl refl = refl\n\ninfix 5 _~_\n_~_ : {A : Set} {a b c : A} → a ≡ b → b ≡ c → a ≡ c\n_~_ = trans\n\n\nlemma-left-id₁ : ∀ {A B : Set} (g : B → A) (f : A → B) → g ∘ f ≡ id → (∀ a → g (f a) ≡ a)\nlemma-left-id₁ g f idcomp a = cong (λ f₁ → f₁ a) idcomp\n\n\nlemma-left-id : ∀ {A B : Set} (a₁ a₂ : A) (g : B → A) (f : A → B) → g ∘ f ≡ id → g (f a₁) ≡ g (f a₂) → a₁ ≡ a₂\nlemma-left-id a₁ a₂ g f idcomp comp = (comp ~ lemma-left-id₁ g f idcomp a₂) s~ lemma-left-id₁ g f idcomp a₁\n\n\nlemma-left-inj : ∀ {A B : Set} (a₁ a₂ : A) → (f : A → B) → ∃ (λ g → g ∘ f ≡ id) → f a₁ ≡ f a₂ → a₁ ≡ a₂\nlemma-left-inj a₁ a₂ f (g , idcomp) eq = lemma-left-id a₁ a₂ g f idcomp (cong (λ x → g x) eq)\n\nleft-inverse→injective : ∀ {A B} (f : A → B) → left-inverse f → injective f\nleft-inverse→injective f left-inv a₁ a₂ fas = lemma-left-inj a₁ a₂ f left-inv fas\n\nright-inverse→surjective : ∀ {A B} (f : A → B) → right-inverse f → surjective f\nright-inverse→surjective f (g , right) b = g b , cong (λ f₁ → f₁ b) right\n\n\n\npostulate extensionality : {A : Set} {B : Set} {f g : A → B} → (∀ x → f x ≡ g x) → f ≡ g\n\nid-unique : ∀ {A : Set} → (f : A → A) → (∀ a → f a ≡ a) → f ≡ id\nid-unique f fa-prop = extensionality {f = f} {g = id} fa-prop\n\nsurjective→right-inverse : ∀ {A B} (f : A → B) → surjective f → right-inverse f\nsurjective→right-inverse f right = g , id-unique (f ∘ g) (λ b → proj₂ (right b))\n where g = λ b → proj₁ (right b)\n\n", "meta": {"hexsha": "c271b13ce3f16eb560ab939047f32cd8ab78ed67", "size": 2775, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "start.agda", "max_stars_repo_name": "Chobbes/AbstractAgdabra", "max_stars_repo_head_hexsha": "a5f046cd37c7c2abb5d287c7d7572f3e84dceb96", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "start.agda", "max_issues_repo_name": "Chobbes/AbstractAgdabra", "max_issues_repo_head_hexsha": "a5f046cd37c7c2abb5d287c7d7572f3e84dceb96", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "start.agda", "max_forks_repo_name": "Chobbes/AbstractAgdabra", "max_forks_repo_head_hexsha": "a5f046cd37c7c2abb5d287c7d7572f3e84dceb96", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.1630434783, "max_line_length": 110, "alphanum_fraction": 0.5636036036, "num_tokens": 1167, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.92414182206801, "lm_q2_score": 0.8289388146603364, "lm_q1q2_score": 0.7660570265630997}} {"text": "module nat-division where\n\nopen import bool\nopen import bool-thms\nopen import eq\nopen import neq\nopen import nat\nopen import nat-thms\nopen import product\nopen import product-thms\nopen import sum\n\n{- a div-result for dividend x and divisor d consists of the quotient q, remainder r, and a proof that q * d + r = x -}\ndiv-result : ℕ → ℕ → Set \ndiv-result x d = Σ ℕ (λ q → Σ ℕ (λ r → q * d + r ≡ x ∧ r < d ≡ tt))\n\n-- we use an upper bound n on the dividend x. For an alternative approach, see nat-division-wf.agda.\ndivh : (n : ℕ) → (x : ℕ) → (y : ℕ) → x ≤ n ≡ tt → y =ℕ 0 ≡ ff → div-result x y\ndivh 0 0 0 p1 ()\ndivh 0 0 (suc y) p1 p2 = 0 , 0 , refl , refl\ndivh 0 (suc x) y () p2 \ndivh (suc n) x y p1 p2 with keep (x < y)\ndivh (suc n) x y p1 p2 | tt , pl = 0 , x , refl , pl\ndivh (suc n) x y p1 p2 | ff , pl with divh n (x ∸ y) y (∸≤2 n x y p1 p2) p2\ndivh (suc n) x y p1 p2 | ff , pl | q , r , pa , pb = suc q , r , lem{q}{r} pa , pb\n where lem : ∀{q r} → q * y + r ≡ x ∸ y → y + q * y + r ≡ x\n lem{q}{r} p rewrite sym (+assoc y (q * y) r) | p | +comm y (x ∸ y) = ∸+2{x}{y} ( Nat -> Maybe A\nlookup-List' (_ , []) _ = nothing\nlookup-List' (_ , (x :: _)) zero = just x\nlookup-List' (_ , (_ :: xs)) (suc n) = lookup-List' ((list-to-list' (vec-to-list xs))) n\n\nex-l'xs : List' Nat\nex-l'xs = (4 , 0 :: 1 :: 2 :: 3 :: [])\n\nlookup-List'[]0 : IsTrue (lookup-List' (0 , []) 0 =Maybe-Nat nothing)\nlookup-List'[]0 = is-true\nlookup-List'ex-l'xs0 : IsTrue (lookup-List' ex-l'xs 0 =Maybe-Nat (just 0))\nlookup-List'ex-l'xs0 = is-true\nlookup-List'ex-l'xs1 : IsTrue (lookup-List' ex-l'xs 1 =Maybe-Nat (just 1))\nlookup-List'ex-l'xs1 = is-true\nlookup-List'ex-l'xs9 : IsTrue (lookup-List' ex-l'xs 9 =Maybe-Nat nothing)\nlookup-List'ex-l'xs9 = is-true\n\n------------------------------------------------------------------------------\n-- 3 The Curry-Howard correspondence\n-- can interpret logical propositions — such as “P and Q”, “not P”, “P implies Q”, ...\n-- as types whose inhabitants are valid proofs of that proposition.\n\n--------------------------------------------------\n-- PROPOSITIONAL LOGIC\n\n-- ex 3.1\ndata Either (A B : Set) : Set where\n left : A → Either A B\n right : B → Either A B\n\ncases : {A B C : Set} → Either A B → (A → C) → (B → C) → C\ncases (left a) fac _ = fac a\ncases (right b) _ fbc = fbc b\n\ncases-left : IsTrue (cases (left 3) (2 +_) (2 *_) =Nat 5)\ncases-left = is-true\ncases-right : IsTrue (cases (right 3) (2 +_) (2 *_) =Nat 6)\ncases-right = is-true\n\n{-\n-------------------------\nTRUTH : true : the proposition that always holds no matter what.\nProving it is straightforward: do not need to provide any assumptions.\nAssuming true in a proof does not provide any new information.\n'true' corresponds to the unit type\n-}\n\ndata ⊤ : Set where\n tt : ⊤\n\n{-\n-------------------------\nFALSITY. the proposition that is never true.\nThere are no ways to prove it.\nRepresented by empty type : datatype with no constructors\n-}\n\ndata ⊥ : Set where\n\n{-\ngiven a proof p of “false” (which can't happen because no constructors)\n- “ex falso quodlibet” : “from falsity follows anything”)\n- can can get a proof of any proposition\n-}\nabsurd : {A : Set} → ⊥ → A\nabsurd ()\n\n{-\n-------------------------\nNEGATION : the type P → ⊥\nEQUIVALENCE. “P is equivalent to Q” as (P → Q) × (Q → P)\n\nPropositional logic versus boolean logic.\n\ntypes ⊤ and ⊥ seem similar to booleans true and false\n- true and false are VALUES : can manipulate and return\n- ⊤ and and ⊥ are TYPES\n - not possible to check whether a given type ⊤ or ⊥\n-}\n\ncurryCompose : {P Q R : Set} → (P → Q) × (Q → R) -> (P → R)\ncurryCompose (f , g) = λ x → g (f x)\n\n-- ex 3.2\nif-A-then-B-implies-A : {A B : Set} → A → (B → A)\nif-A-then-B-implies-A a = λ _ → a\n\nif-A-and-true-then-A-or-false : {A : Set} → (A × ⊤) → Either A ⊥\nif-A-and-true-then-A-or-false (a , ⊤) = left a\n\nuncurry : {A B C : Set} → (A → (B → C)) → (A × B) → C\nuncurry f = λ a×b → f (fst a×b) (snd a×b)\n\nex32x : {A B C : Set} → (A × Either B C) → Either (A × B) (A × C)\nex32x (a , left b) = left (a , b)\nex32x (a , right c) = right (a , c)\n\nex32y : {A B C D : Set} → ((A → C) × (B → D)) → (A × B) → (C × D)\nex32y (ac , bd) (a , b) = ac a , bd b\n\n{-\n--------------------------------------------------\n-- PREDICATE LOGIC\n\nto prove propositions that say something about a given VALUE or FUNCTION\n\ne.g., 6 is even\n length (map f xs) is equal to length xs for all xs\n there exists a number n such that n + n = 12\n\nCurry-Howard : propositions are types\n\ncan define new propositions by defining new data types\n\ne.g.,\n-}\n\n-- index\n-- v\ndata IsEven : Nat → Set where\n even-zero : IsEven zero\n even-suc2 : {n : Nat} → IsEven n → IsEven (suc (suc n))\n\n6-is-even : IsEven 6\n6-is-even = even-suc2 (even-suc2 (even-suc2 even-zero))\n\n7-is-not-even : IsEven 7 → ⊥\n7-is-not-even (even-suc2 (even-suc2 (even-suc2 ())))\n-- ^ -- absurb pattern as arg\n\n{-\n-- useful predicate\n-- states that a given Bool is true\ndata IsTrue : Bool → Set where\n is-true : IsTrue true\n\n_=Nat_ : Nat → Nat → Bool\nzero =Nat zero = true\n(suc x) =Nat (suc y) = x =Nat y\n_ =Nat _ = false\n-}\n\nlength-is-3 : IsTrue (length (1 :: 2 :: 3 :: []) =Nat 3)\nlength-is-3 = is-true\n\n{-\nDefining properties as functions.\n\nCan define properties as\n- data types, or\n- functions that return a value of type Set\ne..g.,\n-}\n\nIsTrue’ : Bool → Set\nIsTrue’ true = ⊤\nIsTrue’ false = ⊥\n\n{-\nFunction approach often results in proofs that are shorter, but less readable.\n\nAlso less general, as some types (e.g., identity type in next section)\ncan only be defined as a data type.\n\nBEST PRACTICE: use data types (not functions)\n\n--------------------------------------------------\nUNIVERSAL QUANTIFICATION : “∀ x of type A, P(x)”\n\nto prove : provide proof of P(v) for EVERY concrete value v : A.\n\ni.e., a function λv → P v\n\nin opposite direction\nassume a f of “∀ x of type A, P(x)”\nand given a concrete v : A\nthen can the proof to the case of v to get a proof f v of P(v)\n\nunder Curry-Howard, universal quantification corresponds to dependent function\n (x : A) → P x\n-}\n\ndouble : Nat → Nat\ndouble zero = zero\ndouble (suc n) = suc (suc (double n))\n\n-- ∀ n : Nat, double n is an even number\n-- 'double-is-even' is a dependent function : return TYPE depends on input VALUE\n-- pattern matching here is \"proof by cases\"\n-- recursion here is \"induction on n\"\ndouble-is-even : (n : Nat) → IsEven (double n)\ndouble-is-even zero = even-zero\ndouble-is-even (suc m) = even-suc2 (double-is-even m)\n\nn-equals-n : (n : Nat) → IsTrue (n =Nat n)\nn-equals-n zero = is-true\nn-equals-n (suc m) = n-equals-n m\n\n{-\n--------------------------------------------------\nEXISTENTIAL QUANTIFICATION : “∃ a x : A such that P( x )”\n\nto prove : provide a concrete v : A, and a proof that P(v) holds\n\ni.e. a pair (v : A, P v)\n\nin opposite direction\ngiven proof z of “∃ a x : A such that P( x )”\nthen extract the witness fst z : A\nand the proof snd z : P (fst z)\n\nunder Curry-Howard, existential quantification corresponds to the dependent pair type\n Σ A ( λ x → P x ).\n-}\n\n-- ∃ an n such that n + n = 12\nhalf-a-dozen : Σ Nat (λ n → IsTrue ((n + n) =Nat 12))\nhalf-a-dozen = 6 , is-true\n\n-- any number n is either 0 or the successor of another number m\n-- ∀ n, n is 0\n-- or ∃ m such that n is suc m\nzero-or-suc : (n : Nat) → Either (IsTrue (n =Nat 0))\n (Σ Nat (λ m → IsTrue (n =Nat (suc m))))\nzero-or-suc zero = left is-true\nzero-or-suc (suc m) = right (m , n-equals-n m)\n\n{-\n--------------------------------------------------\n\nPropositional logic Type System\n------------------------------------------------------------\nproposition P type\nproof of a proposition p : P program of a type\nconjunction P × Q pair type\ndisjunction Either P Q either type\nimplication P → Q function type\ntruth ⊤ unit type\nfalsity ⊥ empty type\nnegation P → ⊥ function to ⊥\nequivalence (P → Q) × (Q → P) pair of two functions\n------------------------------------------------------------\nPredicate log\nuniversal quantification (x : A) → P x dependent function type\nexistential quantification Σ A (λ x → P x ) dependent pair type\n\n\n--------------------------------------------------\n-- IDENTITY TYPE : EQUALITY at any type (to avoid =Nat, =Vec-Nat, ...)\n\nMartin-Löf introduced a new type x ≡ y, called the IDENTITY TYPE (NOT FUNCTION)\n\nif x and y are equal, then x ≡ y has a single inhabitant refl\n- behaves like the unit type ⊤\n\nif x and y are distinct, then x ≡ y has no constructors\n- behaves like the empty type ⊥\n-}\n\ndata _≡_ {A : Set} : A → A → Set where\n -- ‘reflexivity’\n refl : {x : A} → x ≡ x\ninfix 4 _≡_\n{-# BUILTIN EQUALITY _≡_ #-}\n\none-plus-one-IsTrue : IsTrue ((1 + 1) =Nat 2)\none-plus-one-IsTrue = is-true\n\none-plus-one : 1 + 1 ≡ 2\none-plus-one = refl\n\n{-\nzero-not-one-not-IsTrue : IsTrue (0 =Nat 1)\nzero-not-one-not-IsTrue = {!!}\n-}\n\nzero-not-one : 0 ≡ 1 → ⊥\nzero-not-one ()\n\n-- prove facts about polymorphic types\nid-returns-input : {A : Set}\n → (x : A)\n → id x ≡ x\nid-returns-input _ = refl\n\n-- unit tests using identity type\nlength-test1 : length (1 :: 2 :: []) ≡ 2\nlength-test1 = refl\n\n-- symmetry of equality\nsym : {A : Set} {x y : A} → x ≡ y → y ≡ x\nsym refl = refl\n\n-- transitivity of equality\ntrans : {A : Set} {x y z : A} → x ≡ y → y ≡ z → x ≡ z\ntrans refl refl = refl\n\n-- congruence of equality\ncong : {A B : Set} {x y : A} → (f : A → B) → x ≡ y → f x ≡ f y\ncong f refl = refl\n\n{-\nIf a and b can be unified by instantiating some of the variables, then can match on refl.\nIf a and b are different (e.g. different constructors), then match on absurb pattern ().\nAgda canNOT always tell if they are different.\n-}\n\n------------------------------------------------------------------------------\n-- 4 EQUATIONAL REASONING\n\nbegin_ : {A : Set} → {x y : A} → x ≡ y → x ≡ y\nbegin p = p\n\n_end : {A : Set} → (x : A) → x ≡ x\nx end = refl\n\n_=⟨_⟩_ : {A : Set} → (x : A) → {y z : A} → x ≡ y → y ≡ z → x ≡ z\nx =⟨ p ⟩ q = trans p q\n\n_=⟨⟩_ : {A : Set} → (x : A) → {y : A} → x ≡ y → x ≡ y\nx =⟨⟩ q = x =⟨ refl ⟩ q\n\ninfix 1 begin_\ninfix 3 _end\ninfixr 2 _=⟨_⟩_\ninfixr 2 _=⟨⟩_\n\n-- create singleton list\n[_] : {A : Set} → A → List A\n[ x ] = x :: []\n\nreverse : {A : Set} → List A → List A\nreverse [] = []\nreverse (x :: xs) = reverse xs ++ [ x ]\n\n-- reverse has no effect on singleton lists\nreverse-singleton : {A : Set}\n → (x : A)\n → reverse [ x ] ≡ [ x ]\nreverse-singleton x =\n begin\n reverse [ x ] =⟨⟩ -- definition of [_]\n reverse (x :: []) =⟨⟩ -- applying reverse (second clause)\n reverse [] ++ [ x ] =⟨⟩ -- applying reverse (first clause)\n [] ++ [ x ] =⟨⟩ -- applying _++_\n [ x ]\n end\n\n-- proof by cases and induction\nnot-not : (b : Bool)\n → not (not b) ≡ b\n\nnot-not true =\n begin\n not (not true) =⟨⟩\n not false =⟨⟩ -- apply inner not\n true -- apply not\n end\n\nnot-not false =\n begin\n not (not false) =⟨⟩\n not true =⟨⟩\n false\n end\n\n-- prove fact about Nat by induction (i.e., recursion)\nadd-n-zero : (n : Nat)\n → n + zero ≡ n\nadd-n-zero zero =\n begin\n zero + zero =⟨⟩\n zero =⟨⟩\n zero\n end\n\nadd-n-zero (suc n) =\n begin\n (suc n) + zero =⟨⟩ -- applying +\n suc (n + zero) =⟨ cong suc (add-n-zero n) ⟩ -- using induction hypothesis\n suc n\n end\n\nadd-n-zero' : (n : Nat)\n → n + zero ≡ n\nadd-n-zero' zero = refl\nadd-n-zero' (suc n) = cong suc (add-n-zero' n)\n\nadd-assoc : (x y z : Nat)\n → x + (y + z) ≡ (x + y) + z\nadd-assoc zero y z =\n begin\n zero + (y + z) =⟨⟩ -- def of +\n y + z =⟨⟩ -- unapply +\n (zero + y) + z\n end\nadd-assoc (suc x) y z =\n begin\n (suc x) + (y + z) =⟨⟩ -- def of +\n suc (x + (y + z)) =⟨ cong suc (add-assoc x y z) ⟩ -- inductive hypo\n suc ((x + y) + z) =⟨⟩ -- unapply outer add\n (suc (x + y)) + z =⟨⟩ -- unapply inner add\n ((suc x) + y) + z\n end\n\n-- ex 4.1\nadd-suc : (m n : Nat)\n → m + suc n ≡ suc (m + n)\nadd-suc zero n =\n begin\n zero + suc n =⟨⟩ -- def of +\n suc n =⟨⟩\n suc (zero + n)\n end\nadd-suc (suc m) n = -- cong suc (add-suc m n)\n begin\n suc m + suc n =⟨⟩ -- def of +\n suc (m + suc n) =⟨ cong suc (add-suc m n) ⟩\n suc (suc m + n)\n end\n\n--use add-suc and add-n-zero\n+-comm : (m n : Nat)\n → m + n ≡ n + m\n+-comm zero n = sym (add-n-zero n)\n+-comm (suc m) n\n rewrite -- suc m + n ≡ n + suc m\n -- suc (m + n) ≡ n + suc m\n +-comm m n -- suc (n + m) ≡ n + suc m\n | sym (add-suc n m) -- n + suc m ≡ n + suc m\n = refl\n\n+-comm' : (m n : Nat)\n → m + n ≡ n + m\n+-comm' zero n =\n begin\n zero + n =⟨⟩ -- def of +\n n =⟨ sym (add-n-zero n) ⟩ -- add zero to right\n n + zero\n end\n+-comm' (suc m) n =\n begin\n suc m + n =⟨⟩ -- def of +\n suc (m + n) =⟨ cong suc (+-comm m n) ⟩\n suc (n + m) =⟨ sym (add-suc n m) ⟩\n n + suc m\n end\n\n--------------------------------------------------\n-- induction on lists\n\n-- ex 4.2\nreplicate : {A : Set} → Nat → A → List A\nreplicate zero x = []\nreplicate (suc n) x = x :: replicate n x\n\nlength-replicate : {A : Set} {a : A}\n → (n : Nat)\n → length (replicate n a) ≡ n\nlength-replicate zero = refl\nlength-replicate (suc n) = cong suc (length-replicate n)\n\n-- ex 4.3\nappend-[] : {A : Set}\n → (xs : List A)\n → xs ++ [] ≡ xs\nappend-[] [] = refl\nappend-[] (x :: xs) = cong (x ::_) (append-[] xs)\n\nappend-assoc : {A : Set}\n → (xs ys zs : List A)\n → (xs ++ ys) ++ zs ≡ xs ++ (ys ++ zs)\nappend-assoc [] ys zs = refl\nappend-assoc (x :: xs) ys zs -- (((x :: xs) ++ ys) ++ zs) ≡ ((x :: xs) ++ (ys ++ zs))\n -- x :: ((xs ++ ys) ++ zs) ≡ x :: (xs ++ (ys ++ zs))\n = cong (x ::_) (append-assoc xs ys zs)\n\nreverse-distributivity : {A : Set}\n → (xs ys : List A)\n → reverse (xs ++ ys) ≡ reverse ys ++ reverse xs\nreverse-distributivity [] ys = sym (append-[] (reverse ys))\nreverse-distributivity (x :: xs) ys\n -- reverse ((x :: xs) ++ ys) ≡ (reverse ys ++ reverse (x :: xs))\n -- (reverse (xs ++ ys) ++ (x :: [])) ≡ (reverse ys ++ (reverse xs ++ (x :: [])))\n rewrite\n reverse-distributivity xs ys\n -- ((reverse ys ++ reverse xs) ++ (x :: []))\n -- ≡ (reverse ys ++ (reverse xs ++ (x :: [])))\n | sym (append-assoc (reverse ys) (reverse xs) (x :: []))\n = refl\n\nreverse-reverse : {A : Set}\n → (xs : List A)\n → reverse (reverse xs) ≡ xs\nreverse-reverse [] = refl\nreverse-reverse (x :: xs) -- reverse (reverse (x :: xs)) ≡ x :: xs\n -- reverse (reverse xs ++ (x :: [])) ≡ x :: xs\n rewrite\n -- NOTE\n -- v\n reverse-distributivity (reverse xs) [ x ]\n -- x :: reverse (reverse xs) ≡ x :: xs\n-- can rewrite here then refl\n--| reverse-reverse xs -- x :: xs ≡ x :: xs\n--= refl\n-- or use 'cong' on rightof '='\n = cong (x ::_) (reverse-reverse xs)\n\n{-\nmap satisfies functor laws:\n- identity : map id = id\n- composition : map (g . h) = map g . h\n-}\n\nmap-id : {A : Set}\n → (xs : List A)\n → map id xs ≡ xs\nmap-id [] = refl\nmap-id (x :: xs) -- map id (x :: xs) ≡ x :: xs\n -- id x :: map id xs ≡ x :: xs\n = cong (x ::_) (map-id xs)\n\n_◦_ : {A B C : Set} → (B → C) → (A → B) → (A → C)\ng ◦ h = λ x → g (h x)\n\nmap-compose : {A B C : Set}\n → (f : B → C) → (g : A → B) → (xs : List A)\n → map (f ◦ g) xs ≡ map f (map g xs)\nmap-compose f g [] = refl\nmap-compose f g (x :: xs)\n -- map (f ◦ g) (x :: xs) ≡ map f (map g (x :: xs))\n -- (f ◦ g) x :: map (f ◦ g) xs ≡ f (g x) :: map f (map g xs)\n{- this\n rewrite\n sym (map-compose f g xs)\n -- f (g x) :: map (λ x₁ → f (g x₁)) xs ≡\n f (g x) :: map (λ x₁ → f (g x₁)) xs\n = refl\n-}\n -- or this\n = cong (f (g x) ::_) (map-compose f g xs)\n\n-- ex 4.4\nlength-map : {A B : Set} {f : A → B}\n → (xs : List A)\n → length (map f xs) ≡ length xs\nlength-map [] = refl\nlength-map (x :: xs) -- length (map f (x :: xs)) ≡ length (x :: xs)\n -- suc (length (map f xs)) ≡ suc (length xs)\n = cong suc (length-map xs)\n\n-- ex 4.5\ntake : {A : Set} → List A → Nat → List A\ntake _ zero = []\ntake [] (suc n) = []\ntake (x :: xs) (suc n) = x :: take xs n\n\ntake-0 : take ex-xs 0 ≡ []\ntake-0 = refl\ntake-1 : take ex-xs 1 ≡ 0 :: []\ntake-1 = refl\ntake-2 : take ex-xs 2 ≡ 0 :: 1 :: []\ntake-2 = refl\ntake-3 : take ex-xs 3 ≡ 0 :: 1 :: 2 :: []\ntake-3 = refl\ntake-4 : take ex-xs 4 ≡ ex-xs\ntake-4 = refl\ntake-5 : take ex-xs 5 ≡ ex-xs\ntake-5 = refl\n\ndrop : {A : Set} → List A → Nat → List A\ndrop xs zero = xs\ndrop [] (suc x) = []\ndrop (_ :: xs) (suc n) = drop xs n\n\ndrop-0 : drop ex-xs 0 ≡ ex-xs\ndrop-0 = refl\ndrop-1 : drop ex-xs 1 ≡ 1 :: 2 :: 3 :: []\ndrop-1 = refl\ndrop-2 : drop ex-xs 2 ≡ 2 :: 3 :: []\ndrop-2 = refl\ndrop-3 : drop ex-xs 3 ≡ 3 :: []\ndrop-3 = refl\ndrop-4 : drop ex-xs 4 ≡ []\ndrop-4 = refl\ndrop-5 : drop ex-xs 5 ≡ []\ndrop-5 = refl\n\ntake-drop : {A : Set} → (xs : List A) → (n : Nat) → take xs n ++ drop xs n ≡ xs\ntake-drop [] zero = refl\ntake-drop [] (suc n) = refl\ntake-drop (x :: xs) zero = refl\ntake-drop (x :: xs) (suc n) -- (take (x :: xs) (suc n) ++ drop (x :: xs) (suc n)) ≡ x :: xs\n -- x :: (take xs n ++ drop xs n) ≡ x :: xs\n = cong (x ::_) (take-drop xs n)\n\n--------------------------------------------------\n-- verifying optimizations\n\n-- list optimization\n\nreverse-acc : {A : Set} → List A → List A → List A\nreverse-acc [] ys = ys\nreverse-acc (x :: xs) ys = reverse-acc xs (x :: ys)\n\nreverse' : {A : Set} → List A → List A\nreverse' xs = reverse-acc xs []\n\nreverse-acc-lemma : {A : Set}\n → (xs ys : List A)\n → reverse-acc xs ys ≡ reverse xs ++ ys\nreverse-acc-lemma [] _ = refl\nreverse-acc-lemma (x :: xs) ys -- reverse-acc (x :: xs) ys ≡ (reverse (x :: xs) ++ ys)\n -- reverse-acc xs (x :: ys) ≡ ((reverse xs ++ (x :: [])) ++ ys)\n rewrite\n append-assoc (reverse xs) [ x ] ys\n -- reverse-acc xs (x :: ys) ≡ (reverse xs ++ (x :: ys))\n | reverse-acc-lemma xs (x :: ys)\n -- (reverse xs ++ (x :: ys)) ≡ (reverse xs ++ (x :: ys))\n = refl\n\nreverse'-reverse : {A : Set}\n → (xs : List A)\n → reverse' xs ≡ reverse xs\nreverse'-reverse [] = refl\nreverse'-reverse (x :: xs) -- reverse' (x :: xs) ≡ reverse (x :: xs)\n -- reverse' (x :: xs) ≡ (reverse xs ++ (x :: []))\n rewrite\n reverse-acc-lemma xs [ x ] -- (reverse xs ++ (x :: [])) ≡ (reverse xs ++ (x :: []))\n = refl\n\n-- tree optimization\n\ndata Tree (A : Set) : Set where\n leaf : A → Tree A\n node : Tree A → Tree A → Tree A\n\nflatten : {A : Set} → Tree A → List A\nflatten (leaf a) = [ a ]\nflatten (node t1 t2) = flatten t1 ++ flatten t2\n\nflatten-acc : {A : Set} → Tree A → List A → List A\nflatten-acc (leaf x) xs = x :: xs\nflatten-acc (node t1 t2) xs = flatten-acc t1 (flatten-acc t2 xs)\n\nflatten' : {A : Set} → Tree A → List A\nflatten' t = flatten-acc t []\n\nflatten-acc-lemma : {A : Set}\n → (t : Tree A) → (ys : List A)\n → flatten-acc t ys ≡ flatten t ++ ys\nflatten-acc-lemma (leaf x) _ = refl\nflatten-acc-lemma (node t1 t2) ys\n -- flatten-acc (node t1 t2) ys ≡ (flatten (node t1 t2) ++ ys)\n -- flatten-acc t1 (flatten-acc t2 ys) ≡ ((flatten t1 ++ flatten t2) ++ ys)\n rewrite\n flatten-acc-lemma t1 (flatten-acc t2 ys)\n -- (flatten t1 ++ flatten-acc t2 ys) ≡ ((flatten t1 ++ flatten t2) ++ ys)\n | flatten-acc-lemma t2 ys\n -- (flatten t1 ++ (flatten t2 ++ ys)) ≡ ((flatten t1 ++ flatten t2) ++ ys)\n | append-assoc (flatten t1) (flatten t2) ys\n -- (flatten t1 ++ (flatten t2 ++ ys)) ≡ (flatten t1 ++ (flatten t2 ++ ys))\n = refl\n\nflatten-acc-flatten : {A : Set}\n → (t : Tree A) → (ys : List A)\n → flatten-acc t ys ≡ flatten t ++ ys\nflatten-acc-flatten (leaf x) ys = refl\n -- flatten-acc (leaf x) ys ≡ (flatten (leaf x) ++ ys)\nflatten-acc-flatten (node t1 t2) ys\n -- flatten-acc (node t1 t2) ys ≡ (flatten (node t1 t2) ++ ys)\n -- flatten-acc t1 (flatten-acc t2 ys) ≡ ((flatten t1 ++ flatten t2) ++ ys)\n rewrite\n flatten-acc-lemma t2 ys\n -- flatten-acc t1 (flatten t2 ++ ys) ≡ ((flatten t1 ++ flatten t2) ++ ys)\n | flatten-acc-lemma t1 (flatten t2 ++ ys)\n -- (flatten t1 ++ (flatten t2 ++ ys)) ≡ ((flatten t1 ++ flatten t2) ++ ys)\n\n | append-assoc (flatten t1) (flatten t2) ys\n -- (flatten t1 ++ (flatten t2 ++ ys)) ≡ (flatten t1 ++ (flatten t2 ++ ys))\n = refl\n\n-- ex 4.6\nflatten'-flatten : {A : Set}\n → (t : Tree A)\n → flatten' t ≡ flatten t\nflatten'-flatten (leaf x) = refl\nflatten'-flatten (node t1 t2)\n -- flatten' (node t1 t2) ≡ flatten (node t1 t2)\n -- flatten' (node t1 t2) ≡ (flatten t1 ++ flatten t2)\n rewrite\n sym (flatten-acc-flatten t1 (flatten t2))\n -- flatten-acc t1 (flatten-acc t2 []) ≡ flatten-acc t1 (flatten t2)\n | flatten-acc-flatten t2 []\n -- flatten-acc t1 (flatten t2 ++ []) ≡ flatten-acc t1 (flatten t2)\n | append-[] (flatten t2)\n -- flatten-acc t1 (flatten t2) ≡ flatten-acc t1 (flatten t2)\n = refl\n\n--------------------------------------------------\n-- compiler correctness\n\ndata Expr : Set where\n valE : Nat → Expr\n addE : Expr → Expr → Expr\n\neval : Expr → Nat\neval (valE x) = x\neval (addE e1 e2) = eval e1 + eval e2\n\ndata Op : Set where\n PUSH : Nat → Op\n ADD : Op\n\nStack = List Nat\nCode = List Op\n\nexec : Code → Stack → Stack\nexec [] s = s\nexec (PUSH x :: c) s = exec c (x :: s)\nexec (ADD :: c) (m :: n :: s) = exec c (n + m :: s)\nexec (ADD :: c) _ = []\n\ncompile' : Expr → Code → Code\ncompile' (valE x) c = PUSH x :: c\ncompile' (addE e1 e2) c = compile' e1 (compile' e2 (ADD :: c))\n\ncompile : Expr → Code\ncompile e = compile' e []\n\ncompile'-exec-eval : (e : Expr) → (s : Stack) → (c : Code)\n → exec (compile' e c) s ≡ exec c (eval e :: s)\ncompile'-exec-eval (valE _) _ _ = refl\ncompile'-exec-eval (addE e1 e2) s c\n -- exec (compile' (addE e1 e2) c) s ≡ exec c (eval (addE e1 e2) :: s)\n -- exec (compile' e1 (compile' e2 (ADD :: c))) s ≡ exec c (eval e1 + eval e2 :: s)\n rewrite\n compile'-exec-eval e1 s (compile' e2 (ADD :: c))\n -- exec (compile' e2 (ADD :: c)) (eval e1 :: s) ≡ exec c (eval e1 + eval e2 :: s)\n | compile'-exec-eval e2 (eval e1 :: s) (ADD :: c)\n -- exec c (eval e1 + eval e2 :: s) ≡ exec c (eval e1 + eval e2 :: s)\n = refl\n\ncompile-exec-eval : (e : Expr) → exec (compile e) [] ≡ [ eval e ]\ncompile-exec-eval e = compile'-exec-eval e [] []\n", "meta": {"hexsha": "43858fda06af1dbd85accae6afff72b146d88105", "size": 31349, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/paper/2021-03-Jesper_Cockx-Programming_and_Proving_in_Agda/z.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/paper/2021-03-Jesper_Cockx-Programming_and_Proving_in_Agda/z.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/paper/2021-03-Jesper_Cockx-Programming_and_Proving_in_Agda/z.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 29.7146919431, "max_line_length": 99, "alphanum_fraction": 0.4924240008, "num_tokens": 10670, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8887588052782737, "lm_q2_score": 0.86153820232079, "lm_q1q2_score": 0.765699663396217}} {"text": "module my-nat where\n\nopen import product\nopen import bool\nopen import eq\n\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\n{-# BUILTIN NATURAL ℕ #-}\n\ninfixl 10 _*_\ninfixl 9 _+_\n--infixl 8 _<_ _=ℕ_ _≤_ _>_ _≥_\n\n_+_ : ℕ → ℕ → ℕ\nzero + n = n\nsuc m + n = suc (m + n)\n\n0+ : ∀ (x : ℕ) → 0 + x ≡ x\n0+ x = refl\n\n+0 : ∀ (x : ℕ) → x + 0 ≡ x\n+0 zero = refl\n+0 (suc x) rewrite +0 x = refl\n\n+assoc : ∀ (x y z : ℕ) → x + (y + z) ≡ (x + y) + z\n+assoc zero y z = refl\n+assoc (suc x) y z rewrite +assoc x y z = refl\n\n+suc : ∀ (x y : ℕ) → x + (suc y) ≡ suc(x + y)\n+suc zero y = refl\n+suc (suc x) y rewrite +suc x y = refl\n\n+comm : ∀ (x y : ℕ) → x + y ≡ y + x\n+comm zero y rewrite +0 y = refl\n+comm (suc x) y rewrite +suc y x | +comm x y = refl\n\n_*_ : ℕ → ℕ → ℕ\nzero * n = zero\nsuc m * n = n + (m * n)\n\n*distribr : ∀ (x y z : ℕ) → (x + y) * z ≡ x * z + y * z\n--*distribr : ∀ (x y z : ℕ) → (x + y) * z ≡ x * z + y * z\n*distribr zero y z = refl\n*distribr (suc x) y z rewrite *distribr x y z = +assoc z (x * z) (y * z)\n\n*0 : ∀ (x : ℕ) → x * 0 ≡ 0\n*0 zero = refl\n*0 (suc x) = *0 x\n\n*suc : ∀ (x y : ℕ) → x * (suc y) ≡ x + x * y\n*suc zero y = refl\n*suc (suc x) y rewrite *suc x y\n | +assoc y x (x * y)\n | +assoc x y (x * y)\n | +comm x y = refl\n\n*comm : ∀ (x y : ℕ) → x * y ≡ y * x\n*comm zero y rewrite *0 y = refl\n*comm (suc x) y rewrite *suc y x | *comm x y = refl\n\n*assoc : ∀ (x y z : ℕ) → x * (y * z) ≡ (x * y) * z\n*assoc zero y z = refl\n*assoc (suc x) y z rewrite *distribr y (x * y) z\n | *assoc x y z = refl\n\n_<_ : ℕ → ℕ → 𝔹\n0 < 0 = ff\n0 < (suc y) = tt\n(suc x) < (suc y) = x < y\n(suc x) < 0 = ff\n\n_=ℕ_ : ℕ → ℕ → 𝔹\n0 =ℕ 0 = tt\nsuc x =ℕ suc y = x =ℕ y\n_ =ℕ _ = ff\n\n=ℕ-refl : ∀ (x : ℕ) → (x =ℕ x) ≡ tt\n=ℕ-refl zero = refl\n=ℕ-refl (suc x) = =ℕ-refl x\n\n=ℕ-to-≡ : ∀ {x y : ℕ} → x =ℕ y ≡ tt → x ≡ y\n=ℕ-to-≡ {zero} {zero} u = refl\n=ℕ-to-≡ {zero} {suc y} ()\n=ℕ-to-≡ {suc x} {zero} ()\n=ℕ-to-≡ {suc x} {suc y} u rewrite =ℕ-to-≡ {x} {y} u = refl\n\n=ℕ-from-≡ : ∀ {x y : ℕ} → x ≡ y → x =ℕ y ≡ tt\n=ℕ-from-≡ {x} {.x} refl = =ℕ-refl x\n\nis-even : ℕ → 𝔹\nis-odd : ℕ → 𝔹\nis-even 0 = tt\nis-even (suc x) = is-odd x\nis-odd 0 = ff\nis-odd (suc x) = is-even x\n\neven~odd : ∀ (x : ℕ) → is-even x ≡ ~ is-odd x\nodd~even : ∀ (x : ℕ) → is-odd x ≡ ~ is-even x\neven~odd zero = refl\neven~odd (suc x) = odd~even x\nodd~even zero = refl\nodd~even (suc x) = even~odd x\n", "meta": {"hexsha": "5681e4ad1dd05269c07f98c3481d356ff00cb7c2", "size": 2396, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "my-nat.agda", "max_stars_repo_name": "logicshan/IAL", "max_stars_repo_head_hexsha": "2ad96390a9be5c238e73709a21533c7354cedd0c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "my-nat.agda", "max_issues_repo_name": "logicshan/IAL", "max_issues_repo_head_hexsha": "2ad96390a9be5c238e73709a21533c7354cedd0c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "my-nat.agda", "max_forks_repo_name": "logicshan/IAL", "max_forks_repo_head_hexsha": "2ad96390a9be5c238e73709a21533c7354cedd0c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.6037735849, "max_line_length": 72, "alphanum_fraction": 0.4661936561, "num_tokens": 1163, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9473810451666345, "lm_q2_score": 0.8080672227971211, "lm_q1q2_score": 0.7655475700984362}} {"text": "module Numeral.Natural.Oper.Divisibility where\n\nimport Lvl\nopen import Data\nopen import Data.Boolean\nopen import Numeral.Natural\nopen import Numeral.Natural.Oper.Comparisons\nopen import Numeral.Natural.Oper.Modulo\n\n-- Divisibility check\n_∣?_ : ℕ → ℕ → Bool\n𝟎 ∣? _ = 𝐹\n𝐒(y) ∣? x = zero?(x mod 𝐒(y))\n\n-- Divisibility check\n_∣₀?_ : ℕ → ℕ → Bool\n𝟎 ∣₀? 𝟎 = 𝑇\n𝟎 ∣₀? 𝐒(_) = 𝐹\n𝐒(y) ∣₀? x = zero?(x mod 𝐒(y))\n\n{-\nopen import Numeral.Natural.Oper\nopen import Numeral.Natural.UnclosedOper\nopen import Data.Option as Option using (Option)\n\n{-# TERMINATING #-}\n_∣?_ : ℕ → ℕ → Bool\n_ ∣? 𝟎 = 𝑇\n𝟎 ∣? 𝐒(_) = 𝐹\n𝐒(x) ∣? 𝐒(y) with (x −? y)\n... | Option.Some(xy) = xy ∣? 𝐒(y)\n... | Option.None = 𝐹\n-}\n", "meta": {"hexsha": "5455e184559b589382a73c2ec75af51a1b8438cf", "size": 704, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Natural/Oper/Divisibility.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Numeral/Natural/Oper/Divisibility.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Numeral/Natural/Oper/Divisibility.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.7058823529, "max_line_length": 48, "alphanum_fraction": 0.6221590909, "num_tokens": 305, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9473810451666346, "lm_q2_score": 0.8080672089305841, "lm_q1q2_score": 0.7655475569615421}} {"text": "module Data.List.First.Properties {ℓ}{A : Set ℓ} where\n\nopen import Data.Product\nopen import Data.List\nopen import Data.List.Any\nopen import Relation.Binary.PropositionalEquality\nopen import Function\nopen import Data.Empty\nopen import Data.List.First\nopen import Data.List.Membership.Propositional\n\nfirst⟶∈ : ∀ {B : A → Set} {x l} → First B x l → (x ∈ l × B x)\nfirst⟶∈ (here {x = x} p) = here refl , p\nfirst⟶∈ (there x' ¬px f) with (first⟶∈ f)\nfirst⟶∈ (there x' ¬px f) | x∈l , p = there x∈l , p\n\nfirst-unique : ∀ {P : A → Set}{x y v} → First P x v → First P y v → x ≡ y\nfirst-unique (here x) (here y) = refl\nfirst-unique (here {x = x} px) (there .x ¬px r) = ⊥-elim (¬px px)\nfirst-unique (there x ¬px l) (here {x = .x} px) = ⊥-elim (¬px px)\nfirst-unique (there x' _ l) (there .x' _ r) = first-unique l r\n", "meta": {"hexsha": "cf04cce1e0d6821b487b102225c4fb2320e8e8c8", "size": 803, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/List/First/Properties.agda", "max_stars_repo_name": "metaborg/mj.agda", "max_stars_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z", "max_issues_repo_path": "src/Data/List/First/Properties.agda", "max_issues_repo_name": "metaborg/mj.agda", "max_issues_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z", "max_forks_repo_path": "src/Data/List/First/Properties.agda", "max_forks_repo_name": "metaborg/mj.agda", "max_forks_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z", "avg_line_length": 36.5, "max_line_length": 73, "alphanum_fraction": 0.6400996264, "num_tokens": 301, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9284088064979619, "lm_q2_score": 0.8244619263765707, "lm_q1q2_score": 0.7654377130702825}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category.Core\nopen import Categories.Object.Terminal hiding (up-to-iso)\n\nmodule Categories.Object.NaturalNumber {o ℓ e} (𝒞 : Category o ℓ e) (𝒞-Terminal : Terminal 𝒞) where\n\nopen import Level\n\nopen import Categories.Morphism 𝒞\nopen import Categories.Morphism.Reasoning 𝒞\n\nopen Category 𝒞\nopen HomReasoning\nopen Equiv\n\nopen Terminal 𝒞-Terminal\n\nprivate\n variable\n A B C D X Y Z : Obj\n h i j : A ⇒ B\n\nrecord IsNaturalNumber (N : Obj) : Set (o ⊔ ℓ ⊔ e) where\n field\n z : ⊤ ⇒ N\n s : N ⇒ N\n universal : ∀ {A} → ⊤ ⇒ A → A ⇒ A → N ⇒ A\n z-commute : ∀ {A} {q : ⊤ ⇒ A} {f : A ⇒ A} → q ≈ universal q f ∘ z\n s-commute : ∀ {A} {q : ⊤ ⇒ A} {f : A ⇒ A} → f ∘ universal q f ≈ universal q f ∘ s\n unique : ∀ {A} {q : ⊤ ⇒ A} {f : A ⇒ A} {u : N ⇒ A} → q ≈ u ∘ z → f ∘ u ≈ u ∘ s → u ≈ universal q f\n\n η : universal z s ≈ id\n η = ⟺ (unique (⟺ identityˡ) id-comm)\n\n universal-cong : ∀ {A} → {f f′ : ⊤ ⇒ A} → {g g′ : A ⇒ A} → f ≈ f′ → g ≈ g′ → universal f g ≈ universal f′ g′\n universal-cong f≈f′ g≈g′ = unique (⟺ f≈f′ ○ z-commute) (∘-resp-≈ˡ (⟺ g≈g′) ○ s-commute)\n\nrecord NaturalNumber : Set (o ⊔ ℓ ⊔ e) where\n field\n N : Obj\n isNaturalNumber : IsNaturalNumber N\n\n open IsNaturalNumber isNaturalNumber public\n\nopen NaturalNumber\n\nmodule _ (N : NaturalNumber) (N′ : NaturalNumber) where\n private\n module N = NaturalNumber N\n module N′ = NaturalNumber N′\n\n up-to-iso : N.N ≅ N′.N\n up-to-iso = record\n { from = N.universal N′.z N′.s\n ; to = N′.universal N.z N.s\n ; iso = record\n { isoˡ = universal-∘ N N′\n ; isoʳ = universal-∘ N′ N\n }\n }\n where\n universal-∘ : ∀ (N N′ : NaturalNumber) → universal N′ (z N) (s N) ∘ universal N (z N′) (s N′) ≈ id \n universal-∘ N N′ = unique N (z-commute N′ ○ pushʳ (z-commute N)) (pullˡ (s-commute N′) ○ assoc ○ ∘-resp-≈ʳ (s-commute N) ○ ⟺ assoc) ○ (η N)\n \n", "meta": {"hexsha": "6362992022cb42a5761147dff881505258d17675", "size": 1919, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Object/NaturalNumber.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Object/NaturalNumber.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Object/NaturalNumber.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 29.0757575758, "max_line_length": 145, "alphanum_fraction": 0.5659197499, "num_tokens": 769, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9284087946129328, "lm_q2_score": 0.8244619263765707, "lm_q1q2_score": 0.7654377032715285}} {"text": "{-# OPTIONS --without-K #-}\n\nmodule Ch2-1 where\n\nopen import Level\n\ninfixl 4 _≡_\ndata _≡_ {a} {A : Set a} (x : A) : A → Set a where\n refl : x ≡ x\n\n\nJ : {a b : Level} (A : Set a) (C : (x y : A) → x ≡ y → Set b)\n → ((x : A) → C x x refl)\n → (x y : A) (P : x ≡ y)\n → C x y P\nJ A C b x .x refl = b x\n\n-- K : (A : Set) (x : A) (C : x ≡ x → Set)\n-- → C refl\n-- → (loop : x ≡ x)\n-- → C loop\n-- K A x C b p = {! p !}\n\n-- Lemma 2.1.1 (inversion of paths)\ninfix 6 ¬_\n¬_ : {a : Level} {A : Set a} {x y : A} → x ≡ y → y ≡ x\n¬_ {a} {A} {x} {y} p = J A D d x y p\n\n where\n D : (x y : A) (p : x ≡ y) → Set a\n D x y p = y ≡ x\n\n d : (x : A) → D x x refl\n d x = refl\n\n\n-- Lemma 2.1.2 (concatenation of paths)\ninfixl 5 _∙_\n_∙_ : {a : Level} {A : Set a} {x y z : A} → x ≡ y → y ≡ z → x ≡ z\n_∙_ {a} {A} {x} {y} {z} p q = J {a} {a} A D d x y p z q\n\n where\n -- the predicate\n D : (x y : A) (p : x ≡ y) → Set a\n D x y p = (z : A) (q : y ≡ z) → x ≡ z\n\n -- base case\n d : (x : A) → D x x refl\n d x z q = J A E e x z q\n where\n -- the predicate\n E : (x z : A) (q : x ≡ z) → Set a\n E x z q = x ≡ z\n\n -- base case\n e : (x : A) → E x x refl\n e x = refl\n\n\n-- Lemma 2.1.4.i (identity of path concatenation)\n∙-identityʳ : {a : Level} {A : Set a} {x y : A} (p : x ≡ y) → p ≡ p ∙ refl\n∙-identityʳ {a} {A} {x} {y} p = J A D d x y p\n\n where\n -- the predicate\n D : (x y : A) (p : x ≡ y) → Set a\n D x y p = p ≡ p ∙ refl\n\n -- base case\n d : (x : A) → D x x refl\n d x = refl\n\n∙-identityˡ : {a : Level} {A : Set a} {x y : A} (p : x ≡ y) → p ≡ refl ∙ p\n∙-identityˡ {a} {A} {x} {y} p = J A D d x y p\n where\n -- the predicate\n D : (x y : A) (p : x ≡ y) → Set a\n D x y p = p ≡ refl ∙ p\n\n -- base case\n d : (x : A) → D x x refl\n d x = refl\n\n-- Lemma 2.1.4.ii (identity of path inversion)\n¬-identityʳ : {a : Level} {A : Set a} {x y : A} (p : x ≡ y) → ¬ p ∙ p ≡ refl\n¬-identityʳ {a} {A} {x} {y} p = J A D d x y p\n where\n -- the predicate\n D : (x y : A) (p : x ≡ y) → Set a\n D x y p = ¬ p ∙ p ≡ refl\n\n -- base case\n d : (x : A) → D x x refl\n d x = refl\n\n¬-identityˡ : {a : Level} {A : Set a} {x y : A} (p : x ≡ y) → p ∙ ¬ p ≡ refl\n¬-identityˡ {a} {A} {x} {y} p = J A D d x y p\n where\n -- the predicate\n D : (x y : A) (p : x ≡ y) → Set a\n D x y p = p ∙ ¬ p ≡ refl\n\n -- base case\n d : (x : A) → D x x refl\n d x = refl\n\n-- Lemma 2.1.4.iii (involution of path inversion)\ninvolution : {A : Set} {x y : A} (p : x ≡ y) → ¬ ¬ p ≡ p\ninvolution {A} {x} {y} p = J A D d x y p\n where\n -- the predicate\n D : (x y : A) (p : x ≡ y) → Set\n D x y p = ¬ ¬ p ≡ p\n\n -- base case\n d : (x : A) → D x x refl\n d x = refl\n\n-- Lemma 2.1.4.iv (associativity of path concatenation)\n∙-assoc : {a : Level} {A : Set a} {w x y z : A}\n → (p : w ≡ x) (q : x ≡ y) (r : y ≡ z)\n → p ∙ (q ∙ r) ≡ (p ∙ q) ∙ r\n∙-assoc {a} {A} {w} {x} {y} {z} p q r = J A D d w x p y q z r\n where\n -- the predicate\n D : (w x : A) (p : w ≡ x) → Set a\n D w x p = (y : A) (q : x ≡ y)\n → (z : A) (r : y ≡ z)\n → p ∙ (q ∙ r) ≡ (p ∙ q) ∙ r\n\n -- base case\n d : (x : A) → D x x refl\n d x y q z r = J A E e x y q z r\n where\n -- the predicate\n E : (x y : A) (q : x ≡ y) → Set a\n E x y q = (z : A) (r : y ≡ z)\n → refl ∙ (q ∙ r) ≡ refl ∙ q ∙ r\n\n -- base case\n e : (x : A) → E x x refl\n e x z r = J A F f x z r\n where\n -- the predicate\n F : (y z : A) (r : y ≡ z) → Set a\n F y z r = refl ∙ (refl ∙ r) ≡ refl ∙ refl ∙ r\n\n -- base case\n f : (x : A) → F x x refl\n f x = refl\n\n\nopen import Relation.Binary\n\nisEquivalence : ∀ {a} {A : Set a} → IsEquivalence (_≡_ {a} {A})\nisEquivalence = record\n { refl = refl\n ; sym = ¬_\n ; trans = _∙_\n }\n\nsetoid : ∀ {a} → Set a → Setoid _ _\nsetoid {a} A = record\n { Carrier = A\n ; _≈_ = _≡_\n ; isEquivalence = isEquivalence {a} {A}\n }\n-- module EckmannHilton where\n--\n-- -- begin\n-- -- p ∙ refl\n-- -- ≈⟨ ¬ ∙-identityʳ p ⟩\n-- -- p\n-- -- ≈⟨ α ⟩\n-- -- q\n-- -- ≈⟨ ∙-identityʳ q ⟩\n-- -- q ∙ refl\n-- -- ∎\n-- -- where\n-- -- open import Relation.Binary.Reasoning.Setoid (setoid (a ≡ x))\n--\n-- -- whisker right\n-- infixl 6 _∙r_\n-- _∙r_ : {A : Set} {a b c : A} {p q : a ≡ b}\n-- → (α : p ≡ q) (r : b ≡ c)\n-- → p ∙ r ≡ q ∙ r\n-- _∙r_ {A} {a} {b} {c} {p} {q} α r = J A D d b c r a p q α\n-- where\n-- -- the predicate\n-- D : (b c : A) (r : b ≡ c) → Set\n-- D b c r = (a : A) (p q : a ≡ b) (α : p ≡ q)\n-- → p ∙ r ≡ q ∙ r\n--\n-- -- base case\n-- d : (x : A) → D x x refl\n-- d x a p q α = J A E e a x p q\n-- where\n-- -- the predicate\n-- E : (a x : A) (p : a ≡ x) → Set\n-- E a x p = (q : a ≡ x) → p ∙ refl ≡ q ∙ refl\n--\n-- -- base case\n-- e : (x : A) → E x x refl\n-- e x q = {! !}\n-- where\n-- -- the predicate\n-- F : (a x : A) (q : a ≡ x) → Set\n-- F a x q = {! !}\n-- -- refl ∙ refl ≡ q ∙ refl\n-- -- refl ∙ refl ≡ q ∙ refl\n--\n-- -- base case\n-- f : (x : A) → F x x refl\n-- f x = {! !}\n-- --\n-- -- ¬ ∙-identityʳ p ∙ α ∙ ∙-identityʳ q\n-- --\n-- --\n-- -- -- whisker left\n-- -- infixl 6 _∙l_\n-- -- _∙l_ : {A : Set} {a b c : A} {r s : b ≡ c}\n-- -- → (q : a ≡ b) (β : r ≡ s)\n-- -- → q ∙ r ≡ q ∙ s\n-- -- _∙l_ {A} {a} {b} {c} {r} {s} q β = J A D d a b q c r s β\n-- -- where\n-- -- -- the predicate\n-- -- D : (a b : A) (q : a ≡ b) → Set\n-- -- D a b q = (c : A) (r s : b ≡ c) (β : r ≡ s)\n-- -- → q ∙ r ≡ q ∙ s\n-- --\n-- -- -- base case\n-- -- d : (x : A) → D x x refl\n-- -- d x c r s β = ¬ ∙-identityˡ r ∙ β ∙ ∙-identityˡ s\n-- --\n-- -- -- horizontal composition\n-- -- _⋆_ : {A : Set} {a b c : A} {p q : a ≡ b} {r s : b ≡ c}\n-- -- → (α : p ≡ q) (β : r ≡ s)\n-- -- → p ∙ r ≡ q ∙ s\n-- -- _⋆_ {A} {a} {b} {c} {p} {q} {r} {s} α β = (α ∙r r) ∙ (q ∙l β)\n-- --\n-- -- where\n-- -- whisker-right-lemma : ∀ {A : Set} {a b : A}\n-- -- → {p q : a ≡ b} {α : p ≡ q}\n-- -- → α ∙r refl ≡ ¬ ∙-identityʳ p ∙ α ∙ ∙-identityʳ q\n-- -- whisker-right-lemma {A} {a} {b} {p} {q} {α} = refl\n-- --\n-- -- whisker-left-lemma : ∀ {A : Set} {b c : A}\n-- -- → {r s : b ≡ c} {β : r ≡ s}\n-- -- → refl ∙l β ≡ ¬ ∙-identityˡ r ∙ β ∙ ∙-identityˡ s\n-- -- whisker-left-lemma {A} {b} {c} {r} {s} {α} = refl\n-- --\n-- -- cong : {A B : Set} {x y : A}\n-- -- → (f : A → B) (p : x ≡ y)\n-- -- → f x ≡ f y\n-- -- cong {A} {B} {x} {y} f p = J A D d x y p f\n-- -- where\n-- -- -- the predicate\n-- -- D : (x y : A) (p : x ≡ y) → Set\n-- -- D x y p = (f : A → B) → f x ≡ f y\n-- --\n-- -- -- base case\n-- -- d : (x : A) → D x x refl\n-- -- d x f = refl\n-- --\n-- -- cong2 : {A B C : Set} {x y : A} {a b : B}\n-- -- → (f : A → B → C) (p : x ≡ y) (q : a ≡ b)\n-- -- → f x a ≡ f y b\n-- -- cong2 {A} {B} {C} {x} {y} {a} {b} f p q = J A D d x y p a b q f\n-- -- -- J A D d x y p f\n-- -- where\n-- -- -- the predicate\n-- -- D : (x y : A) (p : x ≡ y) → Set\n-- -- D x y p = (a b : B) (q : a ≡ b) (f : A → B → C) → f x a ≡ f y b\n-- --\n-- -- -- base case\n-- -- d : (x : A) → D x x refl\n-- -- d x a b q f = cong (f x) q\n-- --\n-- --\n-- -- -- theorem : {A : Set} {a b c : A}\n-- -- -- → {p q : a ≡ b} {r s : b ≡ c}\n-- -- -- → (α : p ≡ q) (β : r ≡ s)\n-- -- -- → α ⋆ β ≡ cong2 _∙_ α β\n-- -- -- theorem {A} {a} {b} {c} {p} {q} {r} {s} α β = J A D d a b p q c r s α β\n-- -- --\n-- -- -- where\n-- -- -- -- the predicate\n-- -- -- D : (a b : A) (p : a ≡ b) → Set\n-- -- -- D a b p = (q : a ≡ b) (c : A) (r s : b ≡ c) (α : p ≡ q) (β : r ≡ s)\n-- -- -- → α ⋆ β ≡ cong2 _∙_ α β\n-- -- --\n-- -- -- -- base case ʳˡ\n-- -- -- d : (x : A) → D x x refl\n-- -- -- d x q c r s α β = J A E e x c r s q α β\n-- -- --\n-- -- -- where\n-- -- -- -- the predicate\n-- -- -- E : (b c : A) (r : b ≡ c) → Set\n-- -- -- E b c r = (s : b ≡ c) (q : b ≡ b) (α : refl ≡ q) (β : r ≡ s)\n-- -- -- → α ⋆ β ≡ cong2 _∙_ α β\n-- -- --\n-- -- -- -- base case\n-- -- -- e : (x : A) → E x x refl\n-- -- -- e x s q α β = {! !}\n", "meta": {"hexsha": "90f8a2a29cdd48a1a9481e6c6eb133450176fb2f", "size": 8611, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Ch2-1.agda", "max_stars_repo_name": "banacorn/hott", "max_stars_repo_head_hexsha": "75eea99a879e100304bd48c538c9d2db0b4a4ff3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Ch2-1.agda", "max_issues_repo_name": "banacorn/hott", "max_issues_repo_head_hexsha": "75eea99a879e100304bd48c538c9d2db0b4a4ff3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Ch2-1.agda", "max_forks_repo_name": "banacorn/hott", "max_forks_repo_head_hexsha": "75eea99a879e100304bd48c538c9d2db0b4a4ff3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.2327868852, "max_line_length": 82, "alphanum_fraction": 0.3445592846, "num_tokens": 3968, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8962513703624557, "lm_q2_score": 0.853912747375134, "lm_q1q2_score": 0.7653204700049333}} {"text": "module Lectures.One where\n\n-- Check background color\n-- Check fontsize\n-- Ask questions at *any* time\n\ndata ⊤ : Set where\n tt : ⊤\n\ndata ⊥ : Set where\n\nabsurd : ⊥ → {P : Set} → P\nabsurd ()\n\n-- Introduce most common key bindings\n-- C-c C-l load\n-- C-c C-, show context\n-- C-c C-. show context + type\n-- C-c C-SPACE input\n-- C-c C-A auto\n-- C-c C-r refine\n-- C-c C-d type inference\n-- C-c C-c pattern match\n\n-- Briefly introduce syntax\n-- Introduce Set 0\n\nmodus-ponens : {P Q : Set} → P → (P → Q) → Q\nmodus-ponens p f = f p\n\n-- Introduce misfix operators\n\n¬_ : Set → Set\n¬ P = P → ⊥\n\ncontra-elim : {P : Set} → P → ¬ P → ⊥\ncontra-elim = modus-ponens\n\n-- no-dne : {P : Set} → ¬ ¬ P → P\n-- no-dne ¬¬P = {!!}\n\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\n{-# BUILTIN NATURAL ℕ #-}\n\n_+_ : ℕ → ℕ → ℕ\nzero + n = n\nsuc m + n = suc (m + n)\n\n_isEven : ℕ → Set\nzero isEven = ⊤\nsuc zero isEven = ⊥\nsuc (suc n) isEven = n isEven\n\nhalf : (n : ℕ) → n isEven → ℕ\nhalf zero tt = zero\nhalf (suc (suc n)) p = suc (half n p)\n\n_ : ℕ\n_ = half 8 tt\n\n-- Comment on termination checking\n\n-- brexit : ⊥\n-- brexit = brexit\n", "meta": {"hexsha": "6e928a760818091fa9fc63baab1d3b6465d509a3", "size": 1123, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Lectures/One.agda", "max_stars_repo_name": "UoG-Agda/Agda101", "max_stars_repo_head_hexsha": "d9359c5bfd0eaf69efe1113945d7f3145f6b2dff", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Lectures/One.agda", "max_issues_repo_name": "UoG-Agda/Agda101", "max_issues_repo_head_hexsha": "d9359c5bfd0eaf69efe1113945d7f3145f6b2dff", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Lectures/One.agda", "max_forks_repo_name": "UoG-Agda/Agda101", "max_forks_repo_head_hexsha": "d9359c5bfd0eaf69efe1113945d7f3145f6b2dff", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 16.5147058824, "max_line_length": 44, "alphanum_fraction": 0.5592163847, "num_tokens": 421, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9046505376715775, "lm_q2_score": 0.8459424334245617, "lm_q1q2_score": 0.7652822772367324}} {"text": "------------------------------------------------------------------------\n-- One form of induction for natural numbers\n------------------------------------------------------------------------\n\n-- I want universe polymorphism.\n\nmodule Induction1.Nat where\n\nopen import Data.Nat\nimport Induction1.WellFounded as WF\n\n------------------------------------------------------------------------\n-- Complete induction based on <′\n\nopen WF _<′_ using (Acc; acc)\n\nallAcc : ∀ n → Acc n\nallAcc n = acc (helper n)\n where\n helper : ∀ n m → m <′ n → Acc m\n helper zero _ ()\n helper (suc n) .n ≤′-refl = acc (helper n)\n helper (suc n) m (≤′-step m<′n) = helper n m m<′n\n\nopen WF _<′_ public using () renaming (WfRec to <-Rec)\nopen WF.All _<′_ allAcc public\n renaming ( wfRec-builder to <-rec-builder\n ; wfRec to <-rec\n )\n", "meta": {"hexsha": "15846f13010cfe1136a4bd9b364b55f60e34010a", "size": 841, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "vendor/stdlib/src/Induction1/Nat.agda", "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 56, "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_issues_repo_path": "vendor/stdlib/src/Induction1/Nat.agda", "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_forks_repo_path": "vendor/stdlib/src/Induction1/Nat.agda", "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "avg_line_length": 28.0333333333, "max_line_length": 72, "alphanum_fraction": 0.4601664685, "num_tokens": 208, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9441768557238083, "lm_q2_score": 0.8104789040926008, "lm_q1q2_score": 0.7652354232966299}} {"text": "module Logic where\n\n-- The true proposition.\ndata ⊤ : Set where\n obvious : ⊤ -- The proof of truth.\n\n-- The false proposition.\ndata ⊥ : Set where\n -- There is nothing here so one can never prove false.\n\n-- The AND of two statments.\ndata _∧_ (A B : Set) : Set where\n -- The only way to construct a proof of A ∧ B is by pairing a a\n -- proof of A with a proof of and B.\n ⟨_,_⟩ : (a : A) -- Proof of A\n → (b : B) -- Proof of B\n → A ∧ B -- Proof of A ∧ B\n\n-- The OR of two statements.\ndata _∨_ (A B : Set) : Set where\n -- There are two ways of constructing a proof of A ∨ B.\n inl : (a : A) → A ∨ B -- From a proof of A by left introduction\n inr : (b : B) → A ∨ B -- From a proof of B by right introduction\n\n-- The not of statement A\n¬_ : (A : Set) → Set\n¬ A = A → ⊥ -- Given a proof of A one should be able to get a proof\n -- of ⊥.\n\n-- The statement A ↔ B are equivalent.\n_↔_ : (A B : Set) → Set\nA ↔ B = (A → B) -- If\n ∧ -- and\n (B → A) -- only if\n\n\ninfixr 1 _∧_\ninfixr 1 _∨_\ninfixr 0 _↔_\ninfix 2 ¬_\n\n-- Function composition\n_∘_ : {A B C : Set} → (B → C) → (A → B) → A → C\n(f ∘ g) x = f (g x)\n\n-- Double negation\ndoubleNegation : ∀ {A : Set} → A → ¬ (¬ A)\ndoubleNegation a negNegA = negNegA a\n\n{-\n\ndoubleNegation' : ∀ {A : Set} → ¬ ( ¬ (¬ A)) → ¬ A\n\n-}\n\n\ndeMorgan1 : ∀ (A B : Set) → ¬ (A ∨ B) → ¬ A ∧ ¬ B\ndeMorgan1 A B notAorB = ⟨ notAorB ∘ inl , notAorB ∘ inr ⟩\n\ndeMorgan2 : ∀ (A B : Set) → ¬ A ∧ ¬ B → ¬ (A ∨ B)\ndeMorgan2 A B ⟨ notA , notB ⟩ (inl a) = notA a\ndeMorgan2 A B ⟨ notA , notB ⟩ (inr b) = notB b\n\n\ndeMorgan : ∀ (A B : Set) → ¬ (A ∨ B) ↔ ¬ A ∧ ¬ B\ndeMorgan A B = ⟨ deMorgan1 A B , deMorgan2 A B ⟩\n", "meta": {"hexsha": "a5c7ead3416ce38aa342d6260aeca46faff6a050", "size": 1674, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Logic.agda", "max_stars_repo_name": "piyush-kurur/sample-code", "max_stars_repo_head_hexsha": "1062c0b81f8dbb664fcc9376ba13695f0ee7ebc8", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2017-06-19T12:34:08.000Z", "max_stars_repo_stars_event_max_datetime": "2017-06-20T02:19:33.000Z", "max_issues_repo_path": "agda/Logic.agda", "max_issues_repo_name": "piyush-kurur/sample-code", "max_issues_repo_head_hexsha": "1062c0b81f8dbb664fcc9376ba13695f0ee7ebc8", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2017-11-01T05:48:28.000Z", "max_issues_repo_issues_event_max_datetime": "2017-11-01T05:48:28.000Z", "max_forks_repo_path": "agda/Logic.agda", "max_forks_repo_name": "piyush-kurur/sample-code", "max_forks_repo_head_hexsha": "1062c0b81f8dbb664fcc9376ba13695f0ee7ebc8", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.9850746269, "max_line_length": 69, "alphanum_fraction": 0.5346475508, "num_tokens": 663, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9496693659780477, "lm_q2_score": 0.8056321913146127, "lm_q1q2_score": 0.7650842123372535}} {"text": "module W where\n\nopen import Function using (_∘_)\nopen import Data.Bool using (Bool; true; false)\nopen import Data.Product\nopen import Data.Unit using (⊤; tt)\nopen import Data.Empty using (⊥; ⊥-elim)\n\ndata W (S : Set) (P : S → Set) : Set where\n max : (s : S) → (f : P s → W S P) → W S P\n\n-- data ℕ : Set where\n-- zero : ℕ _^0\n-- succ : ℕ → ℕ ∣ℕ∣\n\nℕ : Set\nℕ = W Bool f\n where f : Bool → Set\n f true = ⊤ -- 1\n f false = ⊥ -- 0\n\nzero : ℕ\nzero = max false ⊥-elim\n\nsucc : ℕ → ℕ\nsucc n = max true (λ _ → n)\n\n_+_ : ℕ → ℕ → ℕ\n(max true f) + y = max true (λ _ → f tt + y)\n(max false f) + y = y\n\n-- data Tree : Set where\n-- leaf : Tree _^0\n-- node : Tree → Tree → Tree |ℕ| x |ℕ|\n\nTree : Set\nTree = W Bool λ { true → Bool ; false → ⊥ }\n\nleaf : Tree\nleaf = max false ⊥-elim -- _^0\n\nnode : Tree → Tree → Tree\nnode l r = max true λ { true → l -- ∣Tree∣^2\n ; false → r }\n\n\n\ndata LW (S : Set) (LP : S → Set × Set) : Set where\n lmax : (s : Σ S (proj₁ ∘ LP)) → (proj₂ (LP (proj₁ s)) → LW S LP) → LW S LP\n\nList : (X : Set) → Set\nList X = LW Bool (λ { true → X , ⊤ -- cons\n ; false → ⊤ , ⊥ }) -- nil\n\nnil : {X : Set} → List X\nnil = lmax (false , tt) ⊥-elim\n\ncons : {X : Set} → (x : X) → List X → List X\ncons {X} x xs = lmax (true , x) λ _ → xs\n\n\n\n-- induction principle on W-types\nindW : (S : Set)\n → (P : S → Set)\n → (C : W S P → Set) -- property\n → (c : (s : S) -- given a shape\n → (f : P s → W S P) -- and a bunch of kids\n → (h : (p : P s) → C (f p)) -- if C holds for all kids\n → C (max s f)) -- C holds for (max s f)\n → (x : W S P)\n → C x\nindW S P C step (max s f) = step s f (λ p → {! !} S P C step (f p))\n\nindℕ : (C : ℕ → Set) → C zero → ((n : ℕ) → C n → C (succ n)) → (x : ℕ) → C x\nindℕ C base step (max true f) = step (f tt) (indℕ C base step (f tt))\nindℕ C base step (max false f) = {! base !}\n", "meta": {"hexsha": "c8f125ea9ae5ee3dd974b47f36237a1e2f37ee42", "size": 2030, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Sandbox/W.agda", "max_stars_repo_name": "banacorn/numeral", "max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z", "max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z", "max_issues_repo_path": "Sandbox/W.agda", "max_issues_repo_name": "banacorn/numeral", "max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Sandbox/W.agda", "max_forks_repo_name": "banacorn/numeral", "max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z", "avg_line_length": 26.0256410256, "max_line_length": 79, "alphanum_fraction": 0.4532019704, "num_tokens": 758, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9304582593509315, "lm_q2_score": 0.8221891327004133, "lm_q1q2_score": 0.7650126692696786}} {"text": "import Lvl\nopen import Data.Boolean\nopen import Type\n\nmodule Data.List.Sorting {ℓ} {T : Type{ℓ}} (_≤?_ : T → T → Bool) where\n\nopen import Functional using (_∘₂_)\nopen import Data.Boolean.Stmt\nopen import Data.List\nimport Data.List.Relation.Pairwise\nopen import Data.List.Relation.Permutation\nopen import Logic\n\nopen Data.List.Relation.Pairwise using (empty ; single ; step) public\nSorted = Data.List.Relation.Pairwise.AdjacentlyPairwise(IsTrue ∘₂ (_≤?_))\n\n-- A sorting algorithm is a function that given a list, always return a sorted list which is a permutation of the original one.\nrecord SortingAlgorithm (f : List(T) → List(T)) : Stmt{Lvl.𝐒(ℓ)} where\n constructor intro\n field\n ⦃ sorts ⦄ : ∀{l} → Sorted(f(l))\n ⦃ permutes ⦄ : ∀{l} → (f(l) permutes l)\n", "meta": {"hexsha": "1b42f2ffc35b424d03f6fa9dcba1385aec228af6", "size": 776, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/List/Sorting.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Data/List/Sorting.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/List/Sorting.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.7391304348, "max_line_length": 127, "alphanum_fraction": 0.7100515464, "num_tokens": 236, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9674102571131692, "lm_q2_score": 0.7905303137346446, "lm_q1q2_score": 0.7647671340657868}} {"text": "module examplesPaperJFP.Collatz where\n\nopen import Data.Nat.Base\nopen import Data.Nat.DivMod\nopen import Data.Fin using (Fin; zero; suc)\n\nopen import examplesPaperJFP.Colists\n\ncollatzStep : ℕ → ListF ℕ ℕ\ncollatzStep 1 = nil\ncollatzStep n with n divMod 2\n... | result q zero _ = cons n q\n... | _ = cons n (1 + 3 * n)\n\ncollatzSequence : ℕ → Colist ℕ\ncollatzSequence = unfold collatzStep\n\nopen Colist\nopen import Data.List\n\ndisplayList : Colist ℕ → ℕ → List ℕ\ndisplayList s 0 = []\ndisplayList s (suc m) with force s\n... | nil = []\n... | (cons k s′) = k ∷ displayList s′ m\n\n\ndisplayCollatz : ℕ → ℕ → List ℕ\ndisplayCollatz n m = displayList (collatzSequence n) m\n", "meta": {"hexsha": "6da90d2653fa6b7e8e9b103ea3be79826f242a21", "size": 713, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/examplesPaperJFP/Collatz.agda", "max_stars_repo_name": "agda/ooAgda", "max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 23, "max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z", "max_issues_repo_path": "examples/examplesPaperJFP/Collatz.agda", "max_issues_repo_name": "agda/ooAgda", "max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/examplesPaperJFP/Collatz.agda", "max_forks_repo_name": "agda/ooAgda", "max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z", "avg_line_length": 23.7666666667, "max_line_length": 54, "alphanum_fraction": 0.6479663394, "num_tokens": 226, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9579122756889438, "lm_q2_score": 0.7981867729389246, "lm_q1q2_score": 0.7645929080907395}} {"text": "\nmodule Lib.Fin where\n\nopen import Lib.Nat\nopen import Lib.Bool\nopen import Lib.Id\n\ndata Fin : Nat -> Set where\n zero : {n : Nat} -> Fin (suc n)\n suc : {n : Nat} -> Fin n -> Fin (suc n)\n\nfromNat : (n : Nat) -> Fin (suc n)\nfromNat zero = zero\nfromNat (suc n) = suc (fromNat n)\n\ntoNat : {n : Nat} -> Fin n -> Nat\ntoNat zero = zero\ntoNat (suc n) = suc (toNat n)\n\nweaken : {n : Nat} -> Fin n -> Fin (suc n)\nweaken zero = zero\nweaken (suc n) = suc (weaken n)\n\nlem-toNat-weaken : forall {n} (i : Fin n) -> toNat i ≡ toNat (weaken i)\nlem-toNat-weaken zero = refl\nlem-toNat-weaken (suc i) with toNat i | lem-toNat-weaken i\n... | .(toNat (weaken i)) | refl = refl\n\nlem-toNat-fromNat : (n : Nat) -> toNat (fromNat n) ≡ n\nlem-toNat-fromNat zero = refl\nlem-toNat-fromNat (suc n) with toNat (fromNat n) | lem-toNat-fromNat n\n... | .n | refl = refl\n\nfinEq : {n : Nat} -> Fin n -> Fin n -> Bool\nfinEq zero zero = true\nfinEq zero (suc _) = false\nfinEq (suc _) zero = false\nfinEq (suc i) (suc j) = finEq i j\n\n-- A view telling you if a given element is the maximal one.\ndata MaxView {n : Nat} : Fin (suc n) -> Set where\n theMax : MaxView (fromNat n)\n notMax : (i : Fin n) -> MaxView (weaken i)\n\nmaxView : {n : Nat}(i : Fin (suc n)) -> MaxView i\nmaxView {zero} zero = theMax\nmaxView {zero} (suc ())\nmaxView {suc n} zero = notMax zero\nmaxView {suc n} (suc i) with maxView i\nmaxView {suc n} (suc .(fromNat n)) | theMax = theMax\nmaxView {suc n} (suc .(weaken i)) | notMax i = notMax (suc i)\n\n-- The non zero view\n\ndata NonEmptyView : {n : Nat} -> Fin n -> Set where\n ne : {n : Nat}{i : Fin (suc n)} -> NonEmptyView i\n\nnonEmpty : {n : Nat}(i : Fin n) -> NonEmptyView i\nnonEmpty zero = ne\nnonEmpty (suc _) = ne\n\n-- The thinning view\n\nthin : {n : Nat} -> Fin (suc n) -> Fin n -> Fin (suc n)\nthin zero j = suc j\nthin (suc i) zero = zero\nthin (suc i) (suc j) = suc (thin i j)\n\ndata EqView : {n : Nat} -> Fin n -> Fin n -> Set where\n equal : {n : Nat}{i : Fin n} -> EqView i i\n notequal : {n : Nat}{i : Fin (suc n)}(j : Fin n) -> EqView i (thin i j)\n\ncompare : {n : Nat}(i j : Fin n) -> EqView i j\ncompare zero zero = equal\ncompare zero (suc j) = notequal j\ncompare (suc i) zero with nonEmpty i\n... | ne = notequal zero\ncompare (suc i) (suc j) with compare i j\ncompare (suc i) (suc .i) | equal = equal\ncompare (suc i) (suc .(thin i j)) | notequal j = notequal (suc j)", "meta": {"hexsha": "f83c36e385fd814f198e8aa1b4fdac6f15255b7e", "size": 2434, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/simple-lib/Lib/Fin.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/simple-lib/Lib/Fin.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/simple-lib/Lib/Fin.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.425, "max_line_length": 73, "alphanum_fraction": 0.5903861956, "num_tokens": 916, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9173026618464796, "lm_q2_score": 0.8333246015211008, "lm_q1q2_score": 0.7644108751574626}} {"text": "module Bin-embedding where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl; sym; cong)\nopen Eq.≡-Reasoning\nopen import Data.Nat using (ℕ; zero; suc; _+_; _*_)\nopen import Data.Nat.Properties using (+-identityʳ; +-suc; +-comm; +-assoc)\n\nopen import Isomorphism using (_≲_)\n\n-- 2進数の表現\ndata Bin : Set where\n ⟨⟩ : Bin\n _O : Bin → Bin\n _I : Bin → Bin\n\n-- 2進数のインクリメント\ninc : Bin → Bin\ninc ⟨⟩ = ⟨⟩ I\ninc (b O) = b I\ninc (b I) = inc b O\n\n-- 自然数から2進数への変換\nto : ℕ → Bin\nto zero = ⟨⟩ O\nto (suc n) = inc (to n)\n\n-- 2進数から自然数への変換\nfrom : Bin → ℕ\nfrom ⟨⟩ = zero\nfrom (b O) = 2 * (from b)\nfrom (b I) = 2 * (from b) + 1\n\n2*n≡n+n : ∀ (n : ℕ) → 2 * n ≡ n + n\n2*n≡n+n n rewrite +-identityʳ n = refl\n\n+-suc-suc : ∀ (m n : ℕ) → (suc m) + (suc n) ≡ suc (suc (m + n))\n+-suc-suc m n rewrite +-suc (suc m) n | +-assoc 1 m n = refl\n\nfrom∘inc≡suc∘from : ∀ (b : Bin) → from (inc b) ≡ suc (from b)\nfrom∘inc≡suc∘from ⟨⟩ = refl\nfrom∘inc≡suc∘from (b O) rewrite +-suc (from (b O)) zero = cong suc (+-identityʳ (from (b O)))\nfrom∘inc≡suc∘from (b I) rewrite from∘inc≡suc∘from b | 2*n≡n+n (suc (from b)) | +-suc-suc (from b) (from b) | sym (2*n≡n+n (from b)) | +-comm 1 (2 * (from b)) = refl\n\nfrom∘to : ∀ (n : ℕ) → from (to n) ≡ n\nfrom∘to zero = refl\nfrom∘to (suc n) rewrite from∘inc≡suc∘from (to n) = cong suc (from∘to n)\n\nBin-embedding : ℕ ≲ Bin\nBin-embedding =\n record\n { to = to\n ; from = from\n ; from∘to = from∘to\n }\n", "meta": {"hexsha": "e5195f878bbe794f7eb5c069f95b0ddc63684adf", "size": 1444, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "part1/isomorphism/Bin-embedding.agda", "max_stars_repo_name": "akiomik/plfa-solutions", "max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z", "max_issues_repo_path": "part1/isomorphism/Bin-embedding.agda", "max_issues_repo_name": "akiomik/plfa-solutions", "max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "part1/isomorphism/Bin-embedding.agda", "max_forks_repo_name": "akiomik/plfa-solutions", "max_forks_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.7857142857, "max_line_length": 164, "alphanum_fraction": 0.5734072022, "num_tokens": 664, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9149009549929797, "lm_q2_score": 0.8354835411997897, "lm_q1q2_score": 0.7643846897246042}} {"text": "module Data.Boolean.Operators where\n\nopen import Data.Boolean\n\n-- Definition of boolean operators with conventions from logic\nmodule Logic where\n infixl 1005 _∧_\n infixl 1004 _∨_ _⊕_\n infixl 1003 _⟵_ _⟷_ _⟶_\n\n _∧_ : Bool → Bool → Bool\n _∧_ 𝑇 𝑇 = 𝑇\n _∧_ 𝐹 𝑇 = 𝐹\n _∧_ 𝑇 𝐹 = 𝐹\n _∧_ 𝐹 𝐹 = 𝐹\n\n _∨_ : Bool → Bool → Bool\n _∨_ 𝑇 𝑇 = 𝑇\n _∨_ 𝐹 𝑇 = 𝑇\n _∨_ 𝑇 𝐹 = 𝑇\n _∨_ 𝐹 𝐹 = 𝐹\n\n open Data.Boolean using () renaming (not to ¬) public\n\n _⊕_ : Bool → Bool → Bool\n _⊕_ 𝑇 𝑇 = 𝐹\n _⊕_ 𝐹 𝑇 = 𝑇\n _⊕_ 𝑇 𝐹 = 𝑇\n _⊕_ 𝐹 𝐹 = 𝐹\n\n _⟶_ : Bool → Bool → Bool\n _⟶_ 𝑇 𝑇 = 𝑇\n _⟶_ 𝐹 𝑇 = 𝑇\n _⟶_ 𝑇 𝐹 = 𝐹\n _⟶_ 𝐹 𝐹 = 𝑇\n\n _⟵_ : Bool → Bool → Bool\n _⟵_ 𝑇 𝑇 = 𝑇\n _⟵_ 𝐹 𝑇 = 𝐹\n _⟵_ 𝑇 𝐹 = 𝑇\n _⟵_ 𝐹 𝐹 = 𝑇\n\n _⟷_ : Bool → Bool → Bool\n _⟷_ 𝑇 𝑇 = 𝑇\n _⟷_ 𝐹 𝑇 = 𝐹\n _⟷_ 𝑇 𝐹 = 𝐹\n _⟷_ 𝐹 𝐹 = 𝑇\n\n _⊼_ : Bool → Bool → Bool\n _⊼_ 𝑇 𝑇 = 𝐹\n _⊼_ 𝐹 𝑇 = 𝑇\n _⊼_ 𝑇 𝐹 = 𝑇\n _⊼_ 𝐹 𝐹 = 𝑇\n\n _⊽_ : Bool → Bool → Bool\n _⊽_ 𝑇 𝑇 = 𝐹\n _⊽_ 𝐹 𝑇 = 𝐹\n _⊽_ 𝑇 𝐹 = 𝐹\n _⊽_ 𝐹 𝐹 = 𝑇\n\n ⊤ : Bool\n ⊤ = 𝑇\n\n ⊥ : Bool\n ⊥ = 𝐹\n\n-- Definition of boolean operators with conventions from typical programming languages\nmodule Programming where\n open Logic using () renaming\n (_∧_ to _&&_\n ; _∨_ to _||_\n ; ¬ to !\n ; _⟷_ to _==_\n ; _⊕_ to _!=_\n ; _⟶_ to _→?_\n ; _⟵_ to _←?_\n ) public\n", "meta": {"hexsha": "62c22c1d2c85604ba4e8a14b2ff5367e192da084", "size": 1260, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/Boolean/Operators.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Data/Boolean/Operators.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/Boolean/Operators.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 16.1538461538, "max_line_length": 86, "alphanum_fraction": 0.5119047619, "num_tokens": 830, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9458012701768145, "lm_q2_score": 0.8080672112416737, "lm_q1q2_score": 0.7642709947806112}} {"text": "{-# OPTIONS --without-K #-}\n\nmodule hott.topology.loopspace where\n\nopen import hott.core\nopen import hott.types\nopen import hott.functions\n\n\n-- The pointed loop space\n\nΩ∙ : ∀{ℓ} → Type● ℓ → Type● ℓ\nΩ∙ (A , a) = (a ≡ a , refl)\n\n-- The loops space. It is obtained by suppressing the base point of\n-- the corresponding pointed loop space.\nΩ : ∀{ℓ} → Type● ℓ → Type ℓ\nΩ = space ∘ Ω∙\n\n--\n\n-- The iterated pointed loop space\n\nΩ̂∙ : ∀{ℓ} → ℕ → Type● ℓ → Type● ℓ\nΩ̂∙ = iterate Ω∙\n\n\n-- The iterated loop space. It is obtained by suppressing the base\n-- point of the iterated pointed loop space.\n\nΩ̂ : ∀{ℓ} → ℕ → Type● ℓ → Type ℓ\nΩ̂ n = space ∘ Ω̂∙ n\n\n-- Some short hands\n\n\nΩ²∙ : ∀{ℓ} → Type● ℓ → Type● ℓ; Ω²∙ = Ω̂∙ 2\nΩ³∙ : ∀{ℓ} → Type● ℓ → Type● ℓ; Ω³∙ = Ω̂∙ 3\nΩ⁴∙ : ∀{ℓ} → Type● ℓ → Type● ℓ; Ω⁴∙ = Ω̂∙ 4\nΩ⁵∙ : ∀{ℓ} → Type● ℓ → Type● ℓ; Ω⁵∙ = Ω̂∙ 5\nΩ⁶∙ : ∀{ℓ} → Type● ℓ → Type● ℓ; Ω⁶∙ = Ω̂∙ 6\nΩ⁷∙ : ∀{ℓ} → Type● ℓ → Type● ℓ; Ω⁷∙ = Ω̂∙ 7\nΩ⁸∙ : ∀{ℓ} → Type● ℓ → Type● ℓ; Ω⁸∙ = Ω̂∙ 8\nΩ⁹∙ : ∀{ℓ} → Type● ℓ → Type● ℓ; Ω⁹∙ = Ω̂∙ 9\n\n\nΩ² : ∀{ℓ} → Type● ℓ → Type ℓ; Ω² = Ω̂ 2\nΩ³ : ∀{ℓ} → Type● ℓ → Type ℓ; Ω³ = Ω̂ 3\nΩ⁴ : ∀{ℓ} → Type● ℓ → Type ℓ; Ω⁴ = Ω̂ 4\nΩ⁵ : ∀{ℓ} → Type● ℓ → Type ℓ; Ω⁵ = Ω̂ 5\nΩ⁶ : ∀{ℓ} → Type● ℓ → Type ℓ; Ω⁶ = Ω̂ 6\nΩ⁷ : ∀{ℓ} → Type● ℓ → Type ℓ; Ω⁷ = Ω̂ 7\nΩ⁸ : ∀{ℓ} → Type● ℓ → Type ℓ; Ω⁸ = Ω̂ 8\nΩ⁹ : ∀{ℓ} → Type● ℓ → Type ℓ; Ω⁹ = Ω̂ 9\n", "meta": {"hexsha": "a91421817c975e3091319a1cf787a1158afd98f4", "size": 1340, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/hott/topology/loopspace.agda", "max_stars_repo_name": "piyush-kurur/hott", "max_stars_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "agda/hott/topology/loopspace.agda", "max_issues_repo_name": "piyush-kurur/hott", "max_issues_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/hott/topology/loopspace.agda", "max_forks_repo_name": "piyush-kurur/hott", "max_forks_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.3636363636, "max_line_length": 67, "alphanum_fraction": 0.5171641791, "num_tokens": 804, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9294404096760996, "lm_q2_score": 0.8221891348788759, "lm_q1q2_score": 0.7641758063530604}} {"text": "module CS410-Prelude where\n\nopen import Agda.Primitive\n\n\n----------------------------------------------------------------------------\n-- Zero -- the empty type (logically, a false proposition)\n----------------------------------------------------------------------------\n\ndata Zero : Set where\n\nmagic : forall {l}{A : Set l} -> Zero -> A\nmagic ()\n\n\n----------------------------------------------------------------------------\n-- One -- the type with one value (logically, a true proposition)\n----------------------------------------------------------------------------\n\nrecord One : Set where\n constructor <>\nopen One public\n{-# COMPILED_DATA One () () #-}\n\n----------------------------------------------------------------------------\n-- Two -- the type of Boolean values\n----------------------------------------------------------------------------\n\ndata Two : Set where tt ff : Two\n{-# BUILTIN BOOL Two #-}\n{-# BUILTIN TRUE tt #-}\n{-# BUILTIN FALSE ff #-}\n{-# COMPILED_DATA Two Bool True False #-}\n\n-- nondependent conditional with traditional syntax\nif_then_else_ : {l : Level}{X : Set l} -> Two -> X -> X -> X\nif tt then t else e = t\nif ff then t else e = e\n\n-- dependent conditional cooked for partial application\ncaseTwo : forall {l}{P : Two -> Set l} -> P tt -> P ff -> (b : Two) -> P b\ncaseTwo t f tt = t\ncaseTwo t f ff = f\n\n\n----------------------------------------------------------------------------\n-- \"Sigma\" -- the type of dependent pairs, giving binary products and sums\n----------------------------------------------------------------------------\n\nrecord Sg {l : Level}(S : Set l)(T : S -> Set l) : Set l where\n constructor _,_\n field\n fst : S\n snd : T fst\nopen Sg public\n_*_ : {l : Level} -> Set l -> Set l -> Set l\nS * T = Sg S \\ _ -> T\ninfixr 4 _,_ _*_\n\n_+_ : Set -> Set -> Set\nS + T = Sg Two (caseTwo S T)\n\npattern inl s = tt , s\npattern inr t = ff , t\n\n\n----------------------------------------------------------------------------\n-- \"Equality\" -- the type of evidence that things are the same\n----------------------------------------------------------------------------\n\ndata _==_ {l}{X : Set l}(x : X) : X -> Set l where\n refl : x == x\ninfix 1 _==_\n{-# BUILTIN EQUALITY _==_ #-}\n{-# BUILTIN REFL refl #-}\n\nsym : forall {l}{X : Set l}{x y : X} -> x == y -> y == x\nsym refl = refl\n\n-- this proof principle is useful for proving laws, don't use it for\n-- fixing type problems in your programs\n\npostulate ext : forall {l m}{A : Set l}{B : Set m}{f g : A -> B} ->\n (forall a -> f a == g a) -> f == g\n\n----------------------------------------------------------------------------\n-- functional plumbing\n----------------------------------------------------------------------------\n\nid : forall {l}{X : Set l} -> X -> X\nid x = x\n\n-- the type of composition can be generalized further\n_o_ : forall {l}{X Y Z : Set l} -> (Y -> Z) -> (X -> Y) -> X -> Z\n(f o g) x = f (g x)\n\n_$_ : forall{l}{X Y : Set l} -> (X -> Y) -> X -> Y\nf $ x = f x\n\n\n----------------------------------------------------------------------------\n-- lists\n----------------------------------------------------------------------------\n\ndata List (X : Set) : Set where -- X scopes over the whole declaration...\n [] : List X -- ...so you can use it here...\n _::_ : X -> List X -> List X -- ...and here.\ninfixr 3 _::_\n{-# COMPILED_DATA List [] [] (:) #-}\n{-# BUILTIN LIST List #-}\n{-# BUILTIN NIL [] #-}\n{-# BUILTIN CONS _::_ #-}\n\n----------------------------------------------------------------------------\n-- chars and strings\n----------------------------------------------------------------------------\n\npostulate -- this means that we just suppose the following things exist...\n Char : Set\n String : Set\n{-# BUILTIN CHAR Char #-}\n{-# COMPILED_TYPE Char Char #-} -- ...and by the time we reach Haskell...\n{-# BUILTIN STRING String #-}\n{-# COMPILED_TYPE String String #-} -- ...they *do* exist!\n\nprimitive -- these are baked in; they even work!\n primCharEquality : Char -> Char -> Two\n primStringAppend : String -> String -> String\n primStringToList : String -> List Char\n primStringFromList : List Char -> String\n\n\n---------------------------------------------------------------------------\n-- COLOURS\n---------------------------------------------------------------------------\n\n-- We're going to be making displays from coloured text.\n\ndata Colour : Set where\n black red green yellow blue magenta cyan white : Colour\n{-# COMPILED_DATA Colour HaskellSetup.Colour\n HaskellSetup.Black HaskellSetup.Red HaskellSetup.Green\n HaskellSetup.Yellow HaskellSetup.Blue HaskellSetup.Magenta\n HaskellSetup.Cyan HaskellSetup.White #-}\n\n", "meta": {"hexsha": "5bcbb52a32d28e4dde3a1e4470b1509c008ae967", "size": 4693, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/CS410-Prelude.agda", "max_stars_repo_name": "clarkdm/CS410", "max_stars_repo_head_hexsha": "523a8749f49c914bcd28402116dcbe79a78dbbf4", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "notes/CS410-Prelude.agda", "max_issues_repo_name": "clarkdm/CS410", "max_issues_repo_head_hexsha": "523a8749f49c914bcd28402116dcbe79a78dbbf4", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "notes/CS410-Prelude.agda", "max_forks_repo_name": "clarkdm/CS410", "max_forks_repo_head_hexsha": "523a8749f49c914bcd28402116dcbe79a78dbbf4", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.1438356164, "max_line_length": 80, "alphanum_fraction": 0.4278712977, "num_tokens": 1005, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9343951643678381, "lm_q2_score": 0.817574478416099, "lm_q1q2_score": 0.7639376391425603}} {"text": "module Data.Nat.Literal where\n\nopen import Data.Nat using (ℕ; suc; zero)\nopen import Data.Fin using (Fin; suc; zero)\nopen import Data.Unit using (⊤)\nopen import Data.Empty using (⊥)\nopen import Agda.Builtin.FromNat using (Number; fromNat) public\n\n_≤_ : ℕ → ℕ → Set\nzero ≤ n = ⊤\nsuc m ≤ zero = ⊥\nsuc m ≤ suc n = m ≤ n\n\ninstance\n ℕ-num : Number ℕ\n ℕ-num .Number.Constraint _ = ⊤\n ℕ-num .Number.fromNat n = n\n\ninstance\n Fin-num : {n : ℕ} → Number (Fin (suc n))\n Fin-num {n} .Number.Constraint m = m ≤ n\n Fin-num {n} .Number.fromNat m ⦃ p ⦄ = from m n p where\n from : (m n : ℕ) → m ≤ n → Fin (suc n)\n from zero _ _ = zero\n from (suc _) zero ()\n from (suc m) (suc n) p = suc (from m n p)\n", "meta": {"hexsha": "df010b3202fe630f912cd06312b3416397d508af", "size": 707, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "formalization/Data/Nat/Literal.agda", "max_stars_repo_name": "brunoczim/Celeste", "max_stars_repo_head_hexsha": "9f5129d97ee7b89fb8e43136779a78806b7506ab", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-09-16T17:31:57.000Z", "max_stars_repo_stars_event_max_datetime": "2020-09-16T17:31:57.000Z", "max_issues_repo_path": "formalization/Data/Nat/Literal.agda", "max_issues_repo_name": "brunoczim/Celeste", "max_issues_repo_head_hexsha": "9f5129d97ee7b89fb8e43136779a78806b7506ab", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "formalization/Data/Nat/Literal.agda", "max_forks_repo_name": "brunoczim/Celeste", "max_forks_repo_head_hexsha": "9f5129d97ee7b89fb8e43136779a78806b7506ab", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.1851851852, "max_line_length": 63, "alphanum_fraction": 0.6067892504, "num_tokens": 261, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9343951661947456, "lm_q2_score": 0.8175744695262775, "lm_q1q2_score": 0.7639376323295871}} {"text": "{-# OPTIONS --sized-types #-}\nopen import Relation.Binary.Core\n\nmodule SelectSort.Correctness.Order {A : Set}\n (_≤_ : A → A → Set)\n (tot≤ : Total _≤_)\n (trans≤ : Transitive _≤_) where\n\nopen import Data.List\nopen import Data.Product\nopen import Data.Sum\nopen import Function using (_∘_)\nopen import List.Sorted _≤_\nopen import Order.Total _≤_ tot≤\nopen import Size\nopen import SList\nopen import SList.Order _≤_\nopen import SList.Order.Properties _≤_\nopen import SelectSort _≤_ tot≤\n\nlemma-select-≤ : {ι : Size}(x : A) → (xs : SList A {ι}) → proj₁ (select x xs) ≤ x\nlemma-select-≤ x snil = refl≤\nlemma-select-≤ x (y ∙ ys) \n with tot≤ x y\n... | inj₁ x≤y = lemma-select-≤ x ys\n... | inj₂ y≤x = trans≤ (lemma-select-≤ y ys) y≤x\n\nlemma-select-*≤ : {ι : Size}(x : A) → (xs : SList A {ι}) → proj₁ (select x xs) *≤ proj₂ (select x xs)\nlemma-select-*≤ x snil = genx\nlemma-select-*≤ x (y ∙ ys) \n with tot≤ x y\n... | inj₁ x≤y = gecx (trans≤ (lemma-select-≤ x ys) x≤y) (lemma-select-*≤ x ys)\n... | inj₂ y≤x = gecx (trans≤ (lemma-select-≤ y ys) y≤x) (lemma-select-*≤ y ys)\n\nlemma-select-≤-*≤ : {ι : Size}{b x : A}{xs : SList A {ι}} → b ≤ x → b *≤ xs → b ≤ proj₁ (select x xs) × b *≤ proj₂ (select x xs) \nlemma-select-≤-*≤ b≤x genx = b≤x , genx\nlemma-select-≤-*≤ {x = x} b≤x (gecx {x = y} b≤y b*≤ys) \n with tot≤ x y\n... | inj₁ x≤y = proj₁ (lemma-select-≤-*≤ b≤x b*≤ys) , gecx (trans≤ b≤x x≤y) (proj₂ (lemma-select-≤-*≤ b≤x b*≤ys))\n... | inj₂ y≤x = proj₁ (lemma-select-≤-*≤ b≤y b*≤ys) , gecx (trans≤ b≤y y≤x) (proj₂ (lemma-select-≤-*≤ b≤y b*≤ys))\n\nlemma-selectSort-*≤ : {ι : Size}{x : A}{xs : SList A {ι}} → x *≤ xs → x *≤ selectSort xs\nlemma-selectSort-*≤ genx = genx\nlemma-selectSort-*≤ (gecx x≤y x*≤ys) \n with lemma-select-≤-*≤ x≤y x*≤ys\n... | (x≤z , x*≤zs) = gecx x≤z (lemma-selectSort-*≤ x*≤zs)\n\nlemma-selectSort-sorted : {ι : Size}(xs : SList A {ι}) → Sorted (unsize A (selectSort xs))\nlemma-selectSort-sorted snil = nils\nlemma-selectSort-sorted (x ∙ xs) = lemma-slist-sorted (lemma-selectSort-*≤ (lemma-select-*≤ x xs)) (lemma-selectSort-sorted (proj₂ (select x xs)))\n\ntheorem-selectSort-sorted : (xs : List A) → Sorted (unsize A (selectSort (size A xs)))\ntheorem-selectSort-sorted = lemma-selectSort-sorted ∘ (size A)\n\n", "meta": {"hexsha": "897f934286bcc1798b6dcad213ab108d62a7cc0f", "size": 2276, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/SelectSort/Correctness/Order.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/SelectSort/Correctness/Order.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/SelectSort/Correctness/Order.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.3818181818, "max_line_length": 146, "alphanum_fraction": 0.6001757469, "num_tokens": 932, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9511422172230208, "lm_q2_score": 0.8031737892899222, "lm_q1q2_score": 0.763932498760632}} {"text": "module Numeral.Natural.Oper.Comparisons where\n\nimport Lvl\nopen import Data.Boolean\nimport Data.Boolean.Operators\nopen Data.Boolean.Operators.Programming\nopen import Numeral.Natural\nopen import Numeral.Sign\n\nℕbool : Bool → ℕ\nℕbool = if_then 1 else 0\n\n-- Compare\n_⋚?_ : ℕ → ℕ → (−|0|+)\n𝟎 ⋚? 𝟎 = 𝟎\n𝟎 ⋚? 𝐒(b) = ➖\n𝐒(a) ⋚? 𝟎 = ➕\n𝐒(a) ⋚? 𝐒(b) = a ⋚? b\n\n-- Equality check\n_≡?_ : ℕ → ℕ → Bool\na ≡? b = elim₃ 𝐹 𝑇 𝐹 (a ⋚? b)\n{-# BUILTIN NATEQUALS _≡?_ #-}\n\n-- Non-equality check\n_≢?_ : ℕ → ℕ → Bool\nx ≢? y = !(x ≡? y)\n\n-- Positivity check\npositive? : ℕ → Bool\npositive? (𝟎) = 𝐹\npositive? (𝐒(_)) = 𝑇\n\n-- Zero check\nzero? : ℕ → Bool\nzero? n = !(positive? n)\n\n-- Lesser-than check\n_?_ : ℕ → ℕ → Bool\nx >? y = y Nat\n\n one : Nat\n one = suc zero\n", "meta": {"hexsha": "d6fd5231615618318dddfb684c8f146647b1e99a", "size": 109, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "tests/covered/Nat.agda", "max_stars_repo_name": "andrejtokarcik/agda-semantics", "max_stars_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-08-10T15:33:56.000Z", "max_stars_repo_stars_event_max_datetime": "2018-12-06T17:24:25.000Z", "max_issues_repo_path": "tests/covered/Nat.agda", "max_issues_repo_name": "andrejtokarcik/agda-semantics", "max_issues_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tests/covered/Nat.agda", "max_forks_repo_name": "andrejtokarcik/agda-semantics", "max_forks_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 10.9, "max_line_length": 22, "alphanum_fraction": 0.5596330275, "num_tokens": 36, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.953966101527047, "lm_q2_score": 0.800691997339971, "lm_q1q2_score": 0.7638330232263167}} {"text": "{-# OPTIONS --without-K #-}\n\nmodule hott.types.coproduct where\n\nopen import hott.core.universe\n\ndata _∐_ {ℓ₀ ℓ₁ : Level}\n (A : Type ℓ₀)\n (B : Type ℓ₁) : Type (ℓ₀ ⊔ ℓ₁) where\n\n inl : (a : A) → A ∐ B -- left introduction\n inr : (b : B) → A ∐ B -- right introduction\n\n-- A more suggestive way of building elements of nested co-product\n-- types. For example if we have a : A, b : B and c : C then the\n-- expressions, a ∣∙, ∙∣ b ∣∙ and ∙∣ ∙∣ c are elements inl a, inr (inl\n-- b) and inr (inr c) of A ∐ B ∐ C respectively.\n\n_∣∙ : {ℓ₀ ℓ₁ : Level}{A : Type ℓ₀}{B : Type ℓ₁}\n → A → A ∐ B\n_∣∙ = inl\n\n∙∣_ : {ℓ₀ ℓ₁ : Level}{A : Type ℓ₀}{B : Type ℓ₁}\n → B → A ∐ B\n∙∣_ = inr\n\ninfixr 0 ∙∣_\ninfixr 0 _∣∙\n\n-- A more suggestive way of building a case by case analysis.\n-- For example, one can just write f1 ∣ f2 ∣ f3\n_∣_ : {a b c : Level}\n {A : Type a}\n {B : Type b}\n {C : Type c}\n → (A → C)\n → (B → C)\n → (A ∐ B → C)\n\n(f ∣ g) (inl a) = f a\n(f ∣ g) (inr b) = g b\n\ninfixr 0 _∐_\ninfixr 0 _∣_\n\n\n-- Case by case analysis.\neither : {ℓ₀ ℓ₁ ℓ₃ : Level}\n {A : Type ℓ₀}{B : Type ℓ₁}{C : Type ℓ₃}\n → (A → C) → (B → C) → (A ∐ B → C)\neither f g (inl a) = f a\neither f g (inr b) = g b\n", "meta": {"hexsha": "392ccdff6016bc66ec0028558d639ef55de62c9d", "size": 1223, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/hott/types/coproduct.agda", "max_stars_repo_name": "piyush-kurur/hott", "max_stars_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "agda/hott/types/coproduct.agda", "max_issues_repo_name": "piyush-kurur/hott", "max_issues_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/hott/types/coproduct.agda", "max_forks_repo_name": "piyush-kurur/hott", "max_forks_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.0754716981, "max_line_length": 70, "alphanum_fraction": 0.517579722, "num_tokens": 547, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9005297887874625, "lm_q2_score": 0.8479677564567913, "lm_q1q2_score": 0.7636202246206127}} {"text": "module BHeap {A : Set}(_≤_ : A → A → Set) where\n\nopen import Bound.Lower A\nopen import Bound.Lower.Order _≤_\nopen import BTree {A} hiding (flatten)\nopen import Data.Nat hiding (_≤_)\nopen import Data.List\nopen import Data.Sum renaming (_⊎_ to _∨_)\nopen import Relation.Binary\nopen import Relation.Binary.Core\nopen import Relation.Binary.PropositionalEquality hiding (trans)\n\nopen DecTotalOrder decTotalOrder hiding (refl ; _≤_)\n\ndata BHeap : Bound → Set where\n lf : {b : Bound} \n → BHeap b\n nd : {b : Bound}{x : A} \n → LeB b (val x) \n → (l r : BHeap (val x)) \n → BHeap b\n\nforget : {b : Bound} → BHeap b → BTree\nforget lf = leaf\nforget (nd {x = x} _ l r) = node x (forget l) (forget r)\n\n# : {b : Bound} → BHeap b → ℕ\n# lf = zero\n# (nd _ l r) = suc (# l + # r)\n\nheight : {b : Bound} → BHeap b → ℕ\nheight lf = zero\nheight (nd _ l r) \n with total (height l) (height r) \n... | inj₁ hl≤hr = suc (height r)\n... | inj₂ hr≤hl = suc (height l)\n\nmerge : {b : Bound} → Total _≤_ → (l r : BHeap b) → BHeap b\nmerge _ lf r = r\nmerge _ l lf = l\nmerge tot≤ (nd {x = x} b≤x l r) (nd {x = x'} b≤x' l' r') \n with tot≤ x x'\n... | inj₁ x≤x' = nd b≤x (merge tot≤ l r) (nd (lexy x≤x') l' r') \n... | inj₂ x'≤x = nd b≤x' (nd (lexy x'≤x) l r) (merge tot≤ l' r')\n\nflatten : {b : Bound}(h : BHeap b) → List A\nflatten lf = []\nflatten (nd {x = x} b≤x l r) = x ∷ (flatten l ++ flatten r)\n\n", "meta": {"hexsha": "e66d700fbe4517caacb7a6a7f9180375cd0f0fa9", "size": 1436, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/BHeap.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/BHeap.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/BHeap.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.72, "max_line_length": 65, "alphanum_fraction": 0.5619777159, "num_tokens": 537, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9449947148047777, "lm_q2_score": 0.8080672158638528, "lm_q1q2_score": 0.7636192481983523}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Some examples showing where the natural numbers and some related\n-- operations and properties are defined, and how they can be used\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K #-}\n\nmodule README.Data.Nat where\n\n-- The natural numbers and various arithmetic operations are defined\n-- in Data.Nat.\n\nopen import Data.Nat using (ℕ; _+_; _*_)\n\n-- _*_ has precedence 7 over precedence 6 of _+_\n-- precedence of both defined in module Agda.Builtin.Nat\nex₁ : ℕ\nex₁ = 1 + 3 * 4\n\n-- Propositional equality and some related properties can be found\n-- in Relation.Binary.PropositionalEquality.\n\nopen import Relation.Binary.PropositionalEquality using (_≡_; refl)\n\nex₂ : 3 + 5 ≡ 2 * 4\nex₂ = refl\n\n-- Data.Nat.Properties contains a number of properties about natural\n-- numbers.\n\nopen import Data.Nat.Properties using (*-comm; +-identityʳ)\n\nex₃ : ∀ m n → m * n ≡ n * m\nex₃ m n = *-comm m n\n\n-- The module ≡-Reasoning in Relation.Binary.PropositionalEquality\n-- provides some combinators for equational reasoning.\n\nopen Relation.Binary.PropositionalEquality using (cong; module ≡-Reasoning)\n\nex₄ : ∀ m n → m * (n + 0) ≡ n * m\nex₄ m n = begin\n m * (n + 0) ≡⟨ cong (_*_ m) (+-identityʳ n) ⟩\n m * n ≡⟨ *-comm m n ⟩\n n * m ∎\n where open ≡-Reasoning\n\n-- The module SemiringSolver in Data.Nat.Solver contains a solver\n-- for natural number equalities involving variables, constants, _+_\n-- and _*_.\n\nopen import Data.Nat.Solver using (module +-*-Solver)\nopen +-*-Solver using (solve; _:*_; _:+_; con; _:=_)\n\nex₅ : ∀ m n → m * (n + 0) ≡ n * m\nex₅ = solve 2 (λ m n → m :* (n :+ con 0) := n :* m) refl\n", "meta": {"hexsha": "60dbf266bfb4312a9d67dd67d76d1055ab9239cc", "size": 1761, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/README/Data/Nat.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/README/Data/Nat.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/README/Data/Nat.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 29.8474576271, "max_line_length": 75, "alphanum_fraction": 0.617830778, "num_tokens": 510, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.918480248488136, "lm_q2_score": 0.8311430520409023, "lm_q1q2_score": 0.7633884769677157}} {"text": "module StalinSort where\n\n import Relation.Binary.PropositionalEquality as Eq\n open Eq using (_≡_; refl)\n open import Data.Nat using (ℕ; _≤_; _≤?_)\n open import Data.List using (List; _∷_; [])\n open import Relation.Nullary using (Dec; yes; no)\n\n -- Implementation of Stalin Sort\n stalinSort : List ℕ → List ℕ\n stalinSort [] = []\n stalinSort (x ∷ []) = x ∷ []\n stalinSort (x ∷ y ∷ zs) with x ≤? y\n ...| yes m≤n = x ∷ stalinSort (y ∷ zs)\n ...| no m≰n = stalinSort (x ∷ zs)\n\n -- Example Test\n _ : stalinSort (2 ∷ 3 ∷ 5 ∷ 4 ∷ 6 ∷ []) ≡ (2 ∷ 3 ∷ 5 ∷ 6 ∷ [])\n _ = refl\n\n -------------------- Correctness of Stalin Sort -------------------------\n {-\n This section is only interesting for Logic and Formal Verification\n enthusiasts. Although I tried to sketch the formal proof that\n Stalin Sort always returns a Sorted List, there is a point in the proof\n that I couldn't solve yet. I declared it as a postulate, so somebody can\n try improving it by giving an lemma that remove the postulate and\n finish the proof =D\n -}\n\n -- A proof that x is less than all values in xs (thanks to Twan van Laarhoven)\n data _≤*_ (x : ℕ) : List ℕ → Set where\n [] : x ≤* []\n _∷_ : ∀ {y ys} → (x ≤ y) → y ≤* ys → x ≤* (y ∷ ys)\n\n -- Proof that a list is sorted (thanks to Twan van Laarhoven)\n data SortedList : List ℕ → Set where\n [] : SortedList []\n _∷_ : ∀ {x xs} → x ≤* xs → SortedList xs → SortedList (x ∷ xs)\n\n -- This is necessary to prove the correctness, I can't find a way yet ...\n postulate\n less-stalin : ∀ (x y : ℕ) (zs : List ℕ) → x ≤ y → x ≤* stalinSort (y ∷ zs)\n\n -- Proof that Stalin Sort returns a sorted list\n stalinSort-correctness : ∀ (xs : List ℕ) → SortedList (stalinSort xs)\n stalinSort-correctness [] = []\n stalinSort-correctness (x ∷ []) = [] ∷ []\n stalinSort-correctness (x ∷ y ∷ zs) with x ≤? y\n ...| yes m≤n = less-stalin x y zs m≤n ∷ (stalinSort-correctness (y ∷ zs))\n ...| no m≰n = stalinSort-correctness (x ∷ zs)\n", "meta": {"hexsha": "f094536808f0584a228af71a650d5ee661372fcc", "size": 1989, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/StalinSort.agda", "max_stars_repo_name": "bluoxy/stalin-sort", "max_stars_repo_head_hexsha": "6098af3dbebdcbb8d23491a0be51775bddaee4a4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "agda/StalinSort.agda", "max_issues_repo_name": "bluoxy/stalin-sort", "max_issues_repo_head_hexsha": "6098af3dbebdcbb8d23491a0be51775bddaee4a4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/StalinSort.agda", "max_forks_repo_name": "bluoxy/stalin-sort", "max_forks_repo_head_hexsha": "6098af3dbebdcbb8d23491a0be51775bddaee4a4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.25, "max_line_length": 80, "alphanum_fraction": 0.5987933635, "num_tokens": 672, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9184802440252811, "lm_q2_score": 0.8311430541321951, "lm_q1q2_score": 0.763388475179256}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Setoids.Setoids\nopen import Functions.Definition\nopen import Functions.Lemmas\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_)\nopen import Numbers.Naturals.Semiring\nopen import Numbers.Naturals.Order\nopen import Numbers.Integers.Integers\nopen import Numbers.Rationals.Definition\nopen import Sets.FinSet.Definition\nopen import Sets.FinSet.Lemmas\nopen import Sets.Cardinality.Finite.Definition\nopen import Groups.Definition\nopen import Groups.Groups\nopen import Groups.Abelian.Definition\nopen import Groups.FiniteGroups.Definition\nopen import Rings.Definition\nopen import Numbers.Modulo.Group\nopen import Numbers.Modulo.Definition\nopen import Semirings.Definition\n\nmodule Groups.LectureNotes.Lecture1 where\n\nℤIsGroup : _\nℤIsGroup = ℤGroup\n\nℚIsGroup : _\nℚIsGroup = Ring.additiveGroup ℚRing\n\n-- TODO: R is a group with +\n\nintegersMinusNotGroup : Group (reflSetoid ℤ) (_-Z_) → False\nintegersMinusNotGroup record { +WellDefined = wellDefined ; 0G = identity ; inverse = inverse ; +Associative = multAssoc ; identRight = multIdentRight ; identLeft = multIdentLeft ; invLeft = invLeft ; invRight = invRight } with multAssoc {nonneg 3} {nonneg 2} {nonneg 1}\nintegersMinusNotGroup record { +WellDefined = wellDefined ; 0G = identity ; inverse = inverse ; +Associative = multAssoc ; identRight = multIdentRight ; identLeft = multIdentLeft ; invLeft = invLeft ; invRight = invRight } | ()\n\nnegSuccInjective : {a b : ℕ} → (negSucc a ≡ negSucc b) → a ≡ b\nnegSuccInjective {a} {.a} refl = refl\n\nnonnegInjective : {a b : ℕ} → (nonneg a ≡ nonneg b) → a ≡ b\nnonnegInjective {a} {.a} refl = refl\n\nintegersTimesNotGroup : Group (reflSetoid ℤ) (_*Z_) → False\nintegersTimesNotGroup record { +WellDefined = wellDefined ; 0G = (nonneg zero) ; inverse = inverse ; +Associative = multAssoc ; identRight = multIdentRight ; identLeft = multIdentLeft ; invLeft = invLeft ; invRight = invRight } with multIdentLeft {negSucc 1}\n... | ()\nintegersTimesNotGroup record { +WellDefined = wellDefined ; 0G = (nonneg (succ zero)) ; inverse = inverse ; +Associative = multAssoc ; identRight = multIdentRight ; identLeft = multIdentLeft ; invLeft = invLeft ; invRight = invRight } with invLeft {nonneg zero}\n... | bl with inverse (nonneg zero)\nintegersTimesNotGroup record { +WellDefined = wellDefined ; 0G = (nonneg (succ zero)) ; inverse = inverse ; +Associative = multAssoc ; identRight = multIdentRight ; identLeft = multIdentLeft ; invLeft = invLeft ; invRight = invRight } | () | nonneg zero\nintegersTimesNotGroup record { +WellDefined = wellDefined ; 0G = (nonneg (succ zero)) ; inverse = inverse ; +Associative = multAssoc ; identRight = multIdentRight ; identLeft = multIdentLeft ; invLeft = invLeft ; invRight = invRight } | p | nonneg (succ x) = naughtE (nonnegInjective (transitivity (applyEquality nonneg (equalityCommutative (Semiring.productZeroRight ℕSemiring x))) p))\nintegersTimesNotGroup record { +WellDefined = wellDefined ; 0G = (nonneg (succ zero)) ; inverse = inverse ; +Associative = multAssoc ; identRight = multIdentRight ; identLeft = multIdentLeft ; invLeft = invLeft ; invRight = invRight } | () | negSucc x\nintegersTimesNotGroup record { +WellDefined = wellDefined ; 0G = (nonneg (succ (succ x))) ; inverse = inverse ; +Associative = multAssoc ; identRight = multIdentRight ; identLeft = multIdentLeft ; invLeft = invLeft ; invRight = invRight } with succInjective (negSuccInjective (multIdentLeft {negSucc 1}))\n... | ()\nintegersTimesNotGroup record { +WellDefined = wellDefined ; 0G = (negSucc x) ; inverse = inverse ; +Associative = multAssoc ; identRight = multIdentRight ; identLeft = multIdentLeft ; invLeft = invLeft ; invRight = invRight } with multIdentLeft {nonneg 2}\nintegersTimesNotGroup record { +WellDefined = wellDefined ; 0G = (negSucc x) ; inverse = inverse ; +Associative = multAssoc ; identRight = multIdentRight ; identLeft = multIdentLeft ; invLeft = invLeft ; invRight = invRight } | ()\n\n-- TODO: Q is not a group with *Q\n-- TODO: Q without 0 is a group with *Q\n-- TODO: {1, -1} is a group with *\n\nℤnIsGroup : (n : ℕ) → (0 (a + b) + c ≡ a + (b + c)\n-- Goal: (b + c) ≡ (b + c)\n-- Follows from reflexivity\nplusAssociative zero b c = refl\n-- Goal: suc ((a + b) + c) ≡ suc (a + (b + c))\n-- Inductive step\n-- Follows from induction assumption and congruence\nplusAssociative (suc a) b c =\n begin\n suc ((a + b) + c)\n ≡⟨ cong suc (plusAssociative a b c) ⟩\n suc (a + (b + c))\n ∎\n\nplusCommutativeLemma : ∀ a b -> a + suc b ≡ suc (a + b)\n-- Goal: suc b ≡ suc b\n-- Follows from reflexivity\nplusCommutativeLemma zero b = refl\n-- Goal: suc (a + suc b) ≡ suc (suc (a + b))\n-- Inductive step\n-- Follows from induction assumption and congruence\nplusCommutativeLemma (suc a) b =\n begin\n suc (a + suc b)\n ≡⟨ cong suc (plusCommutativeLemma a b) ⟩\n suc (suc (a + b))\n ∎\n\nplusCommutative : ∀ a b -> a + b ≡ b + a\n-- Goal: zero ≡ zero\n-- Follows from reflexivity\nplusCommutative zero zero = refl\n-- Goal: suc (a + zero) ≡ suc a\n-- One-sided inductive step\n-- Follows from induction assumption and congruence\nplusCommutative (suc a) zero =\n begin\n suc (a + zero)\n ≡⟨ cong suc (plusCommutative a zero) ⟩\n suc a\n ∎\n-- Goal: suc b ≡ suc (b + zero)\n-- One-sided inductive step\n-- Follows from induction assumption and congruence\nplusCommutative zero (suc b) =\n begin\n suc b\n ≡⟨ cong suc (plusCommutative zero b) ⟩\n suc (b + zero)\n ∎\n-- plusCommutative (suc a) (suc b) rewrite plusCommutativeAux a b | plusCommutativeAux b a = cong suc (cong suc (plusCommutative a b))\n-- Goal: suc (a + suc b) ≡ suc (b + suc a)\nplusCommutative (suc a) (suc b) =\n begin\n suc (a + suc b)\n ≡⟨ cong suc (plusCommutativeLemma a b) ⟩\n suc (suc (a + b))\n ≡⟨ cong suc (cong suc (plusCommutative a b)) ⟩\n suc (suc (b + a))\n -- Need to invoke symmetry since definitional equivalence does not guarantee it\n ≡⟨ cong suc (sym (plusCommutativeLemma b a)) ⟩\n suc (b + suc a)\n ∎\n\nplusSemigroup : CommutativeSemigroup ℕ\nplusSemigroup = record\n { _⊛_ = _+_\n ; associative = plusAssociative\n ; commutative = plusCommutative\n }\n", "meta": {"hexsha": "9133b1ecb3050de975ed0fa480f450b0e9a63191", "size": 3111, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "experiments/algebra.agda", "max_stars_repo_name": "aronerben/agda-playground", "max_stars_repo_head_hexsha": "64a00f1f97f053d246d5b9deab090e75d923fe8f", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "experiments/algebra.agda", "max_issues_repo_name": "aronerben/agda-playground", "max_issues_repo_head_hexsha": "64a00f1f97f053d246d5b9deab090e75d923fe8f", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "experiments/algebra.agda", "max_forks_repo_name": "aronerben/agda-playground", "max_forks_repo_head_hexsha": "64a00f1f97f053d246d5b9deab090e75d923fe8f", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.888, "max_line_length": 134, "alphanum_fraction": 0.6097717776, "num_tokens": 1164, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9441768620069626, "lm_q2_score": 0.8080672112416737, "lm_q1q2_score": 0.7629583638008809}} {"text": "module bool where\n\n------------------------\n-- Datatypes\n------------------------\ndata 𝔹 : Set where\n true : 𝔹\n false : 𝔹\n\n----------------------\n-- AND\n----------------------\ninfixr 6 _∧_\n_∧_ : 𝔹 → 𝔹 → 𝔹\ntrue ∧ b = b\nfalse ∧ b = false\n\n---------------------\n-- OR\n---------------------\ninfixr 5 _∨_\n_∨_ : 𝔹 → 𝔹 → 𝔹\ntrue ∨ b = true\nfalse ∨ b = b\n\n--------------------\n-- NEFATION\n--------------------\ninfixr 7 ¬_\n¬_ : 𝔹 → 𝔹\n¬ true = false\n¬ false = true\n", "meta": {"hexsha": "5ed0c3335476cde35966ce46f6535bc2419b636f", "size": 461, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "bool.agda", "max_stars_repo_name": "mrLSD/agda-emacs", "max_stars_repo_head_hexsha": "2c92eb9520dc83f0258e43b4227ce281dfadaffe", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "bool.agda", "max_issues_repo_name": "mrLSD/agda-emacs", "max_issues_repo_head_hexsha": "2c92eb9520dc83f0258e43b4227ce281dfadaffe", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "bool.agda", "max_forks_repo_name": "mrLSD/agda-emacs", "max_forks_repo_head_hexsha": "2c92eb9520dc83f0258e43b4227ce281dfadaffe", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 13.9696969697, "max_line_length": 24, "alphanum_fraction": 0.3275488069, "num_tokens": 168, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9441768651485396, "lm_q2_score": 0.8080672043084051, "lm_q1q2_score": 0.7629583597932543}} {"text": "module Data.Vec.Any.Membership.Propositional where\n open import Relation.Binary.PropositionalEquality \n open import Data.Vec\n open import Data.Vec.Any hiding (map) \n open import Function.Inverse using (_↔_)\n open import Function using (_∘_)\n open import Data.Nat \n open import Data.Product hiding (map)\n import Data.Vec.Any.Membership as Mem\n open import Function.Related using (↔⇒)\n module _ {a} {A : Set a} where\n private module M = Mem (setoid A)\n open M public hiding (lose′)\n\n ∈′→∈ : ∀ {n x}{xs : Vec A n} → x ∈′ xs → x ∈ xs\n ∈′→∈ {xs = .(_ ∷ _)} (here refl) = here\n ∈′→∈ {xs = .(_ ∷ _)} (there p) = there (∈′→∈ p)\n\n ∈→∈′ : ∀ {n x}{xs : Vec A n} → x ∈ xs → x ∈′ xs\n ∈→∈′ {xs = .(_ ∷ _)} here = here refl\n ∈→∈′ {xs = .(_ ∷ _)} (there p) = there (∈→∈′ p)\n \n ∈↔∈′ : ∀ {n x}{xs : Vec A n} → x ∈ xs ↔ x ∈′ xs\n ∈↔∈′ = record {\n to = →-to-⟶ ∈→∈′\n ; from = →-to-⟶ ∈′→∈\n ; inverse-of = record {\n left-inverse-of = left-inverse\n ; right-inverse-of = right-inverse\n }\n }\n where\n left-inverse : ∀ {n x}{xs : Vec A n}(p : x ∈ xs) → ∈′→∈ (∈→∈′ p) ≡ p \n left-inverse {xs = .(_ ∷ _)} here = refl\n left-inverse {xs = .(_ ∷ _)} (there p) = cong there (left-inverse p)\n\n right-inverse : ∀ {n x}{xs : Vec A n}(p : x ∈′ xs) → ∈→∈′ (∈′→∈ p) ≡ p\n right-inverse {xs = .(_ ∷ _)} (here refl) = refl\n right-inverse {xs = .(_ ∷ _)} (there p) = cong there (right-inverse p)\n\n ∈′→∈-there : ∀ {n x}{xs : Vec A n}(x∈′xs : x ∈′ xs) → ∈′→∈ (there {x = x} x∈′xs) ≡ there (∈′→∈ x∈′xs)\n ∈′→∈-there (here refl) = refl\n ∈′→∈-there (there p) rewrite ∈′→∈-there p = refl\n \n lose′ : ∀ {p}{P : A → Set p} {n x} {xs : Vec A n} →\n x ∈′ xs → P x → Any P xs\n lose′ {P = P} = M.lose′ (subst P) \n\n open import Function.Related as Related public using (Kind; Symmetric-kind)\n renaming (implication to subset\n ; reverse-implication to superset\n ; equivalence to set\n ; injection to subbag\n ; reverse-injection to superbag\n ; bijection to bag)\n infix 4 _∼[_]_\n _∼[_]_ : ∀ {a m n}{A : Set a} → Vec A m → Kind → Vec A n → Set _\n xs ∼[ k ] ys = ∀ {x} → (x ∈′ xs) Related.∼[ k ] (x ∈′ ys)\n \n bag-=⇒ : ∀ {k a m n} {A : Set a} {xs : Vec A m} {ys : Vec A n} →\n xs ∼[ bag ] ys → xs ∼[ k ] ys\n bag-=⇒ xs≈ys = ↔⇒ xs≈ys\n", "meta": {"hexsha": "da4281e3da7c850bb96c570782d7cab88f1cb8ff", "size": 2498, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/Vec/Any/Membership/Propositional.agda", "max_stars_repo_name": "tizmd/agda-vector-any", "max_stars_repo_head_hexsha": "1a60f72b9ea1dd61845311ee97dc380aa542b874", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Data/Vec/Any/Membership/Propositional.agda", "max_issues_repo_name": "tizmd/agda-vector-any", "max_issues_repo_head_hexsha": "1a60f72b9ea1dd61845311ee97dc380aa542b874", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Data/Vec/Any/Membership/Propositional.agda", "max_forks_repo_name": "tizmd/agda-vector-any", "max_forks_repo_head_hexsha": "1a60f72b9ea1dd61845311ee97dc380aa542b874", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.6507936508, "max_line_length": 105, "alphanum_fraction": 0.4707766213, "num_tokens": 939, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9059898178450964, "lm_q2_score": 0.8418256492357359, "lm_q1q2_score": 0.7626854666084143}} {"text": "\nmodule Examples where\n\ndata Nat : Set where\n zero : Nat\n suc : Nat -> Nat\n\ndata Bool : Set where\n true : Bool\n false : Bool\n\nif_then_else_ : {A : Set} -> Bool -> A -> A -> A\nif true then x else y = x\nif false then x else y = y\n\nnot : Bool -> Bool\nnot x = if x then false else true\n\nisZero : Nat -> Bool\nisZero zero = true\nisZero (suc _) = false\n\nF : Bool -> Set\nF true = Nat\nF false = Bool\n\nf : (x : Bool) -> F x -> F (not x)\nf true n = isZero n\nf false b = if b then zero else suc zero\n\ntest : Bool\ntest = f ? zero\n\n", "meta": {"hexsha": "d92b2c050073aacf92ac66b52992ccbc160405e1", "size": 530, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/talks/MetaVars/Examples.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "notes/talks/MetaVars/Examples.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "notes/talks/MetaVars/Examples.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 15.5882352941, "max_line_length": 48, "alphanum_fraction": 0.5981132075, "num_tokens": 182, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9553191297273498, "lm_q2_score": 0.7981867777396212, "lm_q1q2_score": 0.7625230978700925}} {"text": "{-# OPTIONS --sized-types #-}\nmodule SList.Order.Properties {A : Set}(_≤_ : A → A → Set) where\n\nopen import List.Sorted _≤_\nopen import Size\nopen import SList\nopen import SList.Order _≤_\n\nlemma-slist-sorted : {ι : Size}{x : A}{xs : SList A {ι}} → x *≤ xs → Sorted (unsize A xs) → Sorted (unsize A (x ∙ xs))\nlemma-slist-sorted {x = x} genx nils = singls x\nlemma-slist-sorted (gecx x≤y genx) (singls y) = conss x≤y (singls y)\nlemma-slist-sorted (gecx x≤y x*≤zys ) syzys = conss x≤y syzys\n\nlemma-sorted⊕ : {ι : Size}{x : A}{xs : SList A {ι}} → xs ≤* x → Sorted (unsize A xs) → Sorted (unsize A (_⊕_ A xs (x ∙ snil)))\nlemma-sorted⊕ {x = x} {xs = snil} _ nils = singls x\nlemma-sorted⊕ {x = x} {xs = y ∙ snil} (lecx y≤x _) (singls .y) = conss y≤x (singls x)\nlemma-sorted⊕ {xs = y ∙ (z ∙ ys)} (lecx y≤x zys≤*x) (conss y≤z szys) = conss y≤z (lemma-sorted⊕ zys≤*x szys)\n\nlemma-⊕≤* : {ι : Size}{x t : A}{xs : SList A {ι}} → x ≤ t → xs ≤* t → (_⊕_ A xs (x ∙ snil)) ≤* t\nlemma-⊕≤* x≤t lenx = lecx x≤t lenx\nlemma-⊕≤* x≤t (lecx y≤t ys≤*t) = lecx y≤t (lemma-⊕≤* x≤t ys≤*t)\n", "meta": {"hexsha": "1df392bffeeea716d5f3343cbeb06f3fc8b7da65", "size": 1060, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/SList/Order/Properties.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/SList/Order/Properties.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/SList/Order/Properties.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.1818181818, "max_line_length": 126, "alphanum_fraction": 0.5877358491, "num_tokens": 515, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9273632916317102, "lm_q2_score": 0.8221891283434876, "lm_q1q2_score": 0.7624680164044232}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category\n\nmodule Categories.Category.Instance.Simplex where\n\nopen import Level\nopen import Data.Product\nopen import Data.Fin.Base using (Fin; _≤_)\nopen import Data.Nat.Base using (ℕ; z≤n; s≤s)\nopen import Function renaming (id to idF; _∘_ to _∙_)\n\nopen import Relation.Binary using (_=[_]⇒_)\nopen import Relation.Binary.PropositionalEquality\n\nΔ : Category 0ℓ 0ℓ 0ℓ\nΔ = record\n { Obj = ℕ\n ; _⇒_ = λ m n → Σ (Fin m → Fin n) (λ f → _≤_ =[ f ]⇒ _≤_)\n ; _≈_ = λ { (f , mf) (g , mg) → ∀ x → f x ≡ g x }\n ; id = idF , idF\n ; _∘_ = λ { (f , mf) (g , mg) → f ∙ g , mf ∙ mg }\n ; assoc = λ _ → refl\n ; sym-assoc = λ _ → refl\n ; identityˡ = λ _ → refl\n ; identityʳ = λ _ → refl\n ; identity² = λ _ → refl\n ; equiv = record\n { refl = λ _ → refl\n ; sym = λ eq x → sym (eq x)\n ; trans = λ eq₁ eq₂ x → trans (eq₁ x) (eq₂ x)\n }\n ; ∘-resp-≈ = λ {_ _ _ f g h i} eq₁ eq₂ x → trans (cong (λ t → proj₁ f t) (eq₂ x)) (eq₁ (proj₁ i x))\n }\n\nopen Category Δ\n\n--------------------------------------------------------------------------------\n-- Face + Degeneracy Maps\n\nface-map : ∀ {n} → Fin (ℕ.suc n) → Fin n → Fin (ℕ.suc n)\nface-map Fin.zero k = Fin.suc k\nface-map (Fin.suc i) Fin.zero = Fin.zero\nface-map (Fin.suc i) (Fin.suc k) = Fin.suc (face-map i k)\n\nface-mono : ∀ {n} → (i : Fin (ℕ.suc n)) → _≤_ =[ face-map i ]⇒ _≤_\nface-mono Fin.zero {_} {_} le = s≤s le\nface-mono (Fin.suc i) {Fin.zero} {_} _ = z≤n\nface-mono (Fin.suc i) {Fin.suc _} {Fin.suc _} (s≤s le) = s≤s (face-mono i le)\n\nface : ∀ {n} → Fin (ℕ.suc n) → n ⇒ ℕ.suc n\nface i = face-map i , face-mono i\n\ndegeneracy-map : ∀ {n} → Fin n → Fin (ℕ.suc n) → Fin n\ndegeneracy-map Fin.zero Fin.zero = Fin.zero\ndegeneracy-map Fin.zero (Fin.suc k) = k\ndegeneracy-map (Fin.suc i) Fin.zero = Fin.zero\ndegeneracy-map (Fin.suc i) (Fin.suc k) = Fin.suc (degeneracy-map i k)\n\ndegeneracy-mono : ∀ {n} → (i : Fin n) → _≤_ =[ degeneracy-map i ]⇒ _≤_\ndegeneracy-mono Fin.zero {Fin.zero} {_} _ = z≤n\ndegeneracy-mono Fin.zero {Fin.suc _} {Fin.suc _} (s≤s le) = le\ndegeneracy-mono (Fin.suc i) {Fin.zero} {_} _ = z≤n\ndegeneracy-mono (Fin.suc i) {Fin.suc _} {Fin.suc _} (s≤s le) = s≤s (degeneracy-mono i le)\n\ndegeneracy : ∀ {n} → Fin n → ℕ.suc n ⇒ n\ndegeneracy i = degeneracy-map i , degeneracy-mono i\n", "meta": {"hexsha": "7894b0f3bf41a0bb6d916e7d8f740b27224e1a91", "size": 2445, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Instance/Simplex.agda", "max_stars_repo_name": "jaykru/agda-categories", "max_stars_repo_head_hexsha": "a4053cf700bcefdf73b857c3352f1eae29382a60", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Categories/Category/Instance/Simplex.agda", "max_issues_repo_name": "jaykru/agda-categories", "max_issues_repo_head_hexsha": "a4053cf700bcefdf73b857c3352f1eae29382a60", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Category/Instance/Simplex.agda", "max_forks_repo_name": "jaykru/agda-categories", "max_forks_repo_head_hexsha": "a4053cf700bcefdf73b857c3352f1eae29382a60", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.9558823529, "max_line_length": 102, "alphanum_fraction": 0.5386503067, "num_tokens": 961, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9219218348550491, "lm_q2_score": 0.8267117962054049, "lm_q1q2_score": 0.7621636560540003}} {"text": "module List.Permutation.Base.Concatenation (A : Set) where\n\nopen import List.Permutation.Base A\nopen import List.Permutation.Base.Equivalence A\nopen import List.Permutation.Base.Preorder A\nopen import Data.List\nopen import Data.Product\nopen import Relation.Binary.PreorderReasoning ∼-preorder\nopen import Algebra\nopen import Algebra.Structures\n\nlemma++/r : {x : A}{xs ys xs' : List A} → (xs / x ⟶ xs') → (xs ++ ys) / x ⟶ (xs' ++ ys)\nlemma++/r /head = /head\nlemma++/r (/tail xs/x⟶xs') = /tail (lemma++/r xs/x⟶xs')\n\nlemma++/l : {y : A}{xs ys ys' : List A} → (ys / y ⟶ ys') → (xs ++ ys) / y ⟶ (xs ++ ys')\nlemma++/l {xs = []} ys/y⟶ys' = ys/y⟶ys'\nlemma++/l {xs = x ∷ xs} ys/y⟶ys' = /tail (lemma++/l {xs = xs} ys/y⟶ys')\n\nlemma++/ : {y : A}{xs ys : List A} → (xs ++ y ∷ ys) / y ⟶ (xs ++ ys)\nlemma++/ {xs = xs} = lemma++/l {xs = xs} /head\n\nlemma++∼r : {xs xs' ys : List A} → xs ∼ xs' → (xs ++ ys) ∼ (xs' ++ ys)\nlemma++∼r {xs} {xs'} {[]} xs∼xs' \n rewrite ((proj₂ (IsMonoid.identity (Monoid.isMonoid (monoid A)))) xs) \n | ((proj₂ (IsMonoid.identity (Monoid.isMonoid (monoid A)))) xs') = xs∼xs'\nlemma++∼r {xs} {xs'} {y ∷ ys} xs∼xs' = ∼x (lemma++/ {y} {xs} {ys}) (lemma++/ {y} {xs'} {ys}) (lemma++∼r xs∼xs') \n\nlemma++∼l : {xs ys ys' : List A} → ys ∼ ys' → (xs ++ ys) ∼ (xs ++ ys')\nlemma++∼l {xs = []} ys∼ys' = ys∼ys'\nlemma++∼l {xs = x ∷ xs} ys∼ys' = ∼x /head /head (lemma++∼l {xs = xs} ys∼ys')\n\nlemma++∼ : {xs ys xs' ys' : List A} → xs ∼ xs' → ys ∼ ys' → (xs ++ ys) ∼ (xs' ++ ys')\nlemma++∼ {xs} {ys} {xs'} {ys'} xs∼xs' ys∼ys' \n = begin\n xs ++ ys\n ∼⟨ lemma++∼r xs∼xs' ⟩\n xs' ++ ys\n ∼⟨ lemma++∼l {xs = xs'} ys∼ys' ⟩\n xs' ++ ys'\n ∎\n", "meta": {"hexsha": "6f315efa0e390b75313cfac41a19e56cc51de14f", "size": 1695, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/List/Permutation/Base/Concatenation.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/List/Permutation/Base/Concatenation.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/List/Permutation/Base/Concatenation.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.3571428571, "max_line_length": 113, "alphanum_fraction": 0.5126843658, "num_tokens": 728, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9219218370002787, "lm_q2_score": 0.8267117855317474, "lm_q1q2_score": 0.762163647987209}} {"text": "module AnyBoolean where\nopen import Data.Bool\nopen import Data.Nat\nopen import Data.List hiding (any)\nopen import Relation.Binary.PropositionalEquality\n\neven : ℕ → Bool\neven zero = true\neven (suc zero) = false\neven (suc (suc n)) = even n\n\ntest-6-even : even 6 ≡ true\ntest-6-even = refl\n\nodd : ℕ → Bool\nodd zero = false\nodd (suc zero) = true\nodd (suc (suc n)) = odd n\n\ntest-5-odd : odd 5 ≡ true\ntest-5-odd = refl\n\nany : {A : Set} → (A → Bool) → List A → Bool\nany _ [] = false\nany p (x ∷ xs) with p x\n... | true = true\n... | false = any p xs\n\ntest-any-even-true : \n any even (3 ∷ 6 ∷ 9 ∷ []) ≡ true\ntest-any-even-true = refl\n\ntest-any-even-false : \n any even (3 ∷ 7 ∷ 9 ∷ []) ≡ false\ntest-any-even-false = refl\n\ntest-any-odd-true : \n any odd (4 ∷ 7 ∷ 10 ∷ []) ≡ true\ntest-any-odd-true = refl\n\ntest-any-odd-false : \n any odd (4 ∷ 8 ∷ 10 ∷ []) ≡ false\ntest-any-odd-false = refl\n", "meta": {"hexsha": "d08ca99a2258f57dc222ad2fa643095efa5a90e8", "size": 878, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "AnyBoolean.agda", "max_stars_repo_name": "larrytheliquid/bahug-april2010", "max_stars_repo_head_hexsha": "60f71d369015b83b9ef5fabc75a70f367d20ac97", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "AnyBoolean.agda", "max_issues_repo_name": "larrytheliquid/bahug-april2010", "max_issues_repo_head_hexsha": "60f71d369015b83b9ef5fabc75a70f367d20ac97", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "AnyBoolean.agda", "max_forks_repo_name": "larrytheliquid/bahug-april2010", "max_forks_repo_head_hexsha": "60f71d369015b83b9ef5fabc75a70f367d20ac97", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T12:03:09.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T12:03:09.000Z", "avg_line_length": 19.9545454545, "max_line_length": 49, "alphanum_fraction": 0.6195899772, "num_tokens": 334, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9399133548753619, "lm_q2_score": 0.8104789018037399, "lm_q1q2_score": 0.7617799436500522}} {"text": "\nmodule Prelude.Nat.Properties where\n\nopen import Prelude.Bool\nopen import Prelude.Nat.Core\nopen import Prelude.Equality\nopen import Prelude.Semiring\n\nsuc-inj : ∀ {n m} → suc n ≡ suc m → n ≡ m\nsuc-inj refl = refl\n\n--- Addition ---\n\nadd-zero-r : (n : Nat) → n + 0 ≡ n\nadd-zero-r zero = refl\nadd-zero-r (suc n) = suc $≡ add-zero-r n\n\nadd-suc-r : (n m : Nat) → n + suc m ≡ suc (n + m)\nadd-suc-r zero m = refl\nadd-suc-r (suc n) m = suc $≡ add-suc-r n m\n\nadd-commute : (a b : Nat) → a + b ≡ b + a\nadd-commute zero b = sym (add-zero-r _)\nadd-commute (suc a) b = suc $≡ add-commute a b ⟨≡⟩ʳ add-suc-r b _\n\nadd-assoc : (a b c : Nat) → a + (b + c) ≡ a + b + c\nadd-assoc zero b c = refl\nadd-assoc (suc a) b c = suc $≡ add-assoc a b c\n\nadd-inj₂ : (a b c : Nat) → a + b ≡ a + c → b ≡ c\nadd-inj₂ zero b c eq = eq\nadd-inj₂ (suc a) b c eq = add-inj₂ a b c (suc-inj eq)\n\nadd-inj₁ : (a b c : Nat) → a + c ≡ b + c → a ≡ b\nadd-inj₁ a b c eq = add-inj₂ c a b (add-commute c a ⟨≡⟩ eq ⟨≡⟩ add-commute b c)\n\n--- Subtraction ---\n\n--- Multiplication ---\n\nmul-one-r : (x : Nat) → x * 1 ≡ x\nmul-one-r zero = refl\nmul-one-r (suc x) = suc $≡ mul-one-r x\n\nmul-zero-r : (x : Nat) → x * 0 ≡ 0\nmul-zero-r zero = refl\nmul-zero-r (suc x) = mul-zero-r x\n\nmul-distr-r : (x y z : Nat) → (x + y) * z ≡ x * z + y * z\nmul-distr-r zero y z = refl\nmul-distr-r (suc x) y z = z +_ $≡ mul-distr-r x y z ⟨≡⟩ add-assoc z _ _\n\nprivate\n shuffle : (a b c d : Nat) → a + b + (c + d) ≡ a + c + (b + d)\n shuffle a b c d = add-assoc a _ _ ʳ⟨≡⟩\n a +_ $≡ (add-assoc b c d ⟨≡⟩ _+ d $≡ add-commute b c ⟨≡⟩ʳ add-assoc c b d) ⟨≡⟩\n add-assoc a _ _\n\nmul-distr-l : (x y z : Nat) → x * (y + z) ≡ x * y + x * z\nmul-distr-l zero y z = refl\nmul-distr-l (suc x) y z = y + z +_ $≡ mul-distr-l x y z ⟨≡⟩ shuffle y z (x * y) (x * z)\n\nmul-assoc : (x y z : Nat) → x * (y * z) ≡ x * y * z\nmul-assoc zero y z = refl\nmul-assoc (suc x) y z = y * z +_ $≡ mul-assoc x y z ⟨≡⟩ʳ mul-distr-r y (x * y) z\n\nmul-commute : (x y : Nat) → x * y ≡ y * x\nmul-commute x zero = mul-zero-r x\nmul-commute x (suc y) = mul-distr-l x 1 y ⟨≡⟩ _+ x * y $≡ mul-one-r x ⟨≡⟩ x +_ $≡ mul-commute x y\n\nmul-inj₁ : (x y z : Nat) {{_ : NonZero z}} → x * z ≡ y * z → x ≡ y\nmul-inj₁ x y zero {{}}\nmul-inj₁ zero zero (suc z) eq = refl\nmul-inj₁ zero (suc y) (suc z) ()\nmul-inj₁ (suc x) zero (suc z) ()\nmul-inj₁ (suc x) (suc y) (suc z) eq = suc $≡ mul-inj₁ x y (suc z) (add-inj₂ z _ _ (suc-inj eq))\n\nmul-inj₂ : (x y z : Nat) {{_ : NonZero x}} → x * y ≡ x * z → y ≡ z\nmul-inj₂ x y z eq = mul-inj₁ y z x (mul-commute y x ⟨≡⟩ eq ⟨≡⟩ mul-commute x z)\n", "meta": {"hexsha": "356c41f6c253821e2c4a36025ff75e85db08f15e", "size": 2631, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Prelude/Nat/Properties.agda", "max_stars_repo_name": "L-TChen/agda-prelude", "max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 111, "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_issues_repo_path": "src/Prelude/Nat/Properties.agda", "max_issues_repo_name": "L-TChen/agda-prelude", "max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 59, "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_forks_repo_path": "src/Prelude/Nat/Properties.agda", "max_forks_repo_name": "L-TChen/agda-prelude", "max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 24, "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "avg_line_length": 32.8875, "max_line_length": 98, "alphanum_fraction": 0.5229950589, "num_tokens": 1168, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9343951588871157, "lm_q2_score": 0.8152324938410784, "lm_q1q2_score": 0.761749295612574}} {"text": "open import Relation.Binary.Core\n\nmodule PLRTree.Insert {A : Set} \n (_≤_ : A → A → Set)\n (tot≤ : Total _≤_) where\n\nopen import Data.Sum\nopen import PLRTree {A}\n\ninsert : A → PLRTree → PLRTree\ninsert x leaf = node perfect x leaf leaf \ninsert x (node perfect y l r) \n with tot≤ x y | l | r\n... | inj₁ x≤y | leaf | leaf = node right x (node perfect y leaf leaf) leaf\n... | inj₁ x≤y | _ | _ = node left x (insert y l) r \n... | inj₂ y≤x | leaf | leaf = node right y (node perfect x leaf leaf) leaf\n... | inj₂ y≤x | _ | _ = node left y (insert x l) r \ninsert x (node left y l r)\n with tot≤ x y\n... | inj₁ x≤y \n with insert y l \n... | node perfect y' l' r' = node right x (node perfect y' l' r') r \n... | t = node left x t r \ninsert x (node left y l r) | inj₂ y≤x \n with insert x l\n... | node perfect y' l' r' = node right y (node perfect y' l' r') r \n... | t = node left y t r \ninsert x (node right y l r)\n with tot≤ x y \n... | inj₁ x≤y \n with insert y r\n... | node perfect y' l' r' = node perfect x l (node perfect y' l' r') \n... | t = node right x l t \ninsert x (node right y l r) | inj₂ y≤x \n with insert x r\n... | node perfect y' l' r' = node perfect y l (node perfect y' l' r') \n... | t = node right y l t \n", "meta": {"hexsha": "816020d8f10d47441a705fa093c5a9a9e530c624", "size": 1269, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/PLRTree/Insert.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/PLRTree/Insert.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/PLRTree/Insert.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.3947368421, "max_line_length": 75, "alphanum_fraction": 0.5626477541, "num_tokens": 445, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9603611643025387, "lm_q2_score": 0.7931059536292271, "lm_q1q2_score": 0.7616681570426398}} {"text": "module plfa.part1.Bin where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl; cong)\nopen import Data.Nat using (ℕ; zero; suc; _*_; _+_)\nopen import Data.Nat.Properties using (+-suc)\n\ndata Bin : Set where\n ⟨⟩ : Bin\n _O : Bin → Bin\n _I : Bin → Bin\n\ninc : Bin → Bin\ninc ⟨⟩ = ⟨⟩ I\ninc (b O) = b I\ninc (b I) = (inc b) O\n\nto : ℕ → Bin\nto zero = ⟨⟩ O\nto (suc n) = inc (to n)\n\nfrom : Bin → ℕ\nfrom ⟨⟩ = 0\nfrom (b O) = 2 * from b\nfrom (b I) = suc (2 * from b)\n\ninc-suc-law : ∀ b → from (inc b) ≡ suc (from b)\ninc-suc-law ⟨⟩ = refl\ninc-suc-law (b O) = refl\ninc-suc-law (b I) rewrite\n inc-suc-law b\n | +-suc (suc (from b)) ((from b) + 0) = refl\n\nfrom-to-identity : ∀ n → from (to n) ≡ n\nfrom-to-identity zero = refl\nfrom-to-identity (suc n) rewrite\n inc-suc-law (to n)\n | from-to-identity n = refl\n\n", "meta": {"hexsha": "4c1eae40d2fb2a16d8370a07ec18878b67746772", "size": 835, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/plfa/part1/Bin.agda", "max_stars_repo_name": "abolotina/plfa.github.io", "max_stars_repo_head_hexsha": "75bef9bb35643160e2d2ab4221a3057f22eb3324", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/plfa/part1/Bin.agda", "max_issues_repo_name": "abolotina/plfa.github.io", "max_issues_repo_head_hexsha": "75bef9bb35643160e2d2ab4221a3057f22eb3324", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/plfa/part1/Bin.agda", "max_forks_repo_name": "abolotina/plfa.github.io", "max_forks_repo_head_hexsha": "75bef9bb35643160e2d2ab4221a3057f22eb3324", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.875, "max_line_length": 51, "alphanum_fraction": 0.5880239521, "num_tokens": 326, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9184802507195636, "lm_q2_score": 0.8289388146603364, "lm_q1q2_score": 0.7613639303204036}} {"text": "module z where\n\n------------------------------------------------------------------------------\n-- inductive data types and function that are defined by pattern matching\n\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\n_+_ : ℕ → ℕ → ℕ\nzero + n = n\nsuc m + n = suc (m + n)\n\ndata List {ℓ} (A : Set ℓ) : Set ℓ where\n [] : List A\n _::_ : (x : A) (xs : List A) → List A\n\n_#_ : {A : Set} → List A → List A → List A\n[] # ys = ys\n(x :: xs) # ys = x :: (xs # ys)\n\nsum : List ℕ → List ℕ → List ℕ\nsum [] ys = ys\nsum (x :: xs) [] = x :: xs\nsum (x :: xs) (y :: ys) = (x + y) :: sum xs ys\n\n-- inductively defined predicates\n-- P over S is a data type S -> Set\n\ndata _reverseOf_ {A : Set} : List A → List A → Set where\n rev-Λ : [] reverseOf []\n rev-t : {x : A} {xs ys : List A}\n → xs reverseOf ys\n → (x :: xs) reverseOf (ys # (x :: []))\n\ndata _⊆_ {A : Set} : List A → List A → Set where\n sub-Λ : [] ⊆ []\n sub-right : {n : A} {ys xs : List A}\n → ys ⊆ xs → ys ⊆ (n :: xs)\n sub-ind : {n : A} {ys xs : List A}\n → ys ⊆ xs → (n :: ys) ⊆ (n :: xs)\n\n------------------------------------------------------------------------------\n-- coinductive records and copattern matching\n\n-- inductive pair\nrecord Pair (A B : Set) : Set where\n constructor _,_\n field\n fst : A\n snd : B\n\n-- coinductive infinite list (e.g., \"stream\")\nrecord Stream (A : Set) : Set where\n coinductive\n field\n hd : A\n tl : Stream A\nopen Stream\n\n-- functions cannot be defined inductively (by pattern matching).\n-- use copattern matching [APTS13]\n-- - specify how the result of the function will be observed\n\nzeros : Stream ℕ\nhd zeros = zero\ntl zeros = zeros\n\nnatsFrom : ℕ → Stream ℕ\nhd (natsFrom n) = n\ntl (natsFrom n) = natsFrom (suc n)\n\nsumS : Stream ℕ → Stream ℕ → Stream ℕ\nhd (sumS a b) = hd a + hd b\ntl (sumS a b) = sumS (tl a) (tl b)\n\n------------------------------------------------------------------------------\n-- possibly infinite streams\n\n--open import Codata.Thunk\nopen import Size\nopen import Relation.Unary\n\n{-\nA thunk is a coinductive record with only one field, the suspended computation.\nTakes a function from Size to Set (e.g., Colist A).\nAccessing forces the computation and implicitly decreases the size.\n'Size < i' represents all the sizes smaller than i.\n-}\nrecord Thunk {ℓ} (F : Size → Set ℓ) (i : Size) : Set ℓ where\n coinductive\n field force : {j : Size< i} → F j\nopen Thunk public\n\n-- 'Size' represents an approximation level.\n-- - Can be ∞.\n-- - Can help termination checker by tracking depth of data structures.\n-- 'Thunk' simulates laziness\ndata Colist {a} (A : Set a) (i : Size) : Set a where\n [] : Colist A i\n _::_ : A → Thunk (Colist A) i → Colist A i\n\n{-\nAlternative Colist impl: follows pattern used for coinductive types.\nTo represent a structure which can be either finite or infinite, use a coinductive record\nwith a field representing the whole observation which can be made on the structure.\nThis field is typically a variant type, since the observation can take different shapes,\ne.g., if colist is non-empty then observe the pair consisting of head and tail, otherwise nothing.\n-}\nopen import Data.Maybe\nopen import Data.Product\n\nrecord MyColist (A : Set) : Set where\n constructor CoL_\n coinductive\n field\n list : Maybe (A × MyColist A)\n\n-- Either of these two approaches can be used for possibly infinite structures.\n\ndata StreamT {ℓ} (A : Set ℓ) (i : Size) : Set ℓ where\n _::_ : A → Thunk (StreamT A) i → StreamT A i\n\nrecord MyStream_bis (A : Set) : Set where\n coinductive\n field\n stream : A × (MyStream_bis A)\n\n------------------------------------------------------------------------------\n-- equality properties\n\n-- stdlib equality and properties\n\ndata _≡_ {a} {A : Set a} (x : A) : A → Set a where\n instance refl : x ≡ x\n\n-- Each property is a function that takes proofs as input and returns a new proof.\n\nsym : ∀ {A : Set} {x y : A} → x ≡ y → y ≡ x\nsym refl = refl\n\ntrans : ∀ {A : Set} {x y z : A} → x ≡ y → y ≡ z → x ≡ z\ntrans refl refl = refl\n\ncong : ∀ {A B : Set} (f : A → B) {x y : A} → x ≡ y → f x ≡ f y\ncong f refl = refl\n\nsubst : ∀ {A : Set} {x y : A} (P : A → Set) → x ≡ y → P x → P y\nsubst P refl px = px\n\n------------------------------------------------------------------------------\n-- Chapter 2 - Inductive reasoning\n\ndata _memberOf_ {A : Set} : A → List A → Set where\n mem-h : {x : A} → {xs : List A} → x memberOf (x :: xs)\n mem-t : {x y : A} → {xs : List A} → x memberOf xs → x memberOf(y :: xs)\n", "meta": {"hexsha": "02856f45b85997380ba005bb928eda87a62a27a6", "size": 4639, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/paper/2020-02-luca-ciccone-flexible-coinduction-in-agda/z.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/paper/2020-02-luca-ciccone-flexible-coinduction-in-agda/z.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/paper/2020-02-luca-ciccone-flexible-coinduction-in-agda/z.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 29.5477707006, "max_line_length": 98, "alphanum_fraction": 0.5442983402, "num_tokens": 1395, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8856314647623016, "lm_q2_score": 0.8596637487122111, "lm_q1q2_score": 0.7613452649750466}} {"text": "module Numeral.PositiveInteger.Oper where\n\nopen import Numeral.PositiveInteger\n\ninfixl 10010 _+_\ninfixl 10020 _⋅_\ninfixl 10030 _^_\n\n-- Addition\n_+_ : ℕ₊ → ℕ₊ → ℕ₊\nx + 𝟏 = 𝐒(x)\nx + 𝐒(y) = 𝐒(x + y)\n\n-- Multiplication\n_⋅_ : ℕ₊ → ℕ₊ → ℕ₊\nx ⋅ 𝟏 = x\nx ⋅ 𝐒(y) = x + (x ⋅ y)\n\n-- Exponentiation\n_^_ : ℕ₊ → ℕ₊ → ℕ₊\nx ^ 𝟏 = x\nx ^ 𝐒(y) = x ⋅ (x ^ y)\n\n-- Factorial\n_! : ℕ₊ → ℕ₊\n𝟏 ! = 𝟏\n𝐒(x) ! = 𝐒(x) ⋅ (x !)\n\nopen import Data.Option\nopen import Data.Option.Functions\n-- Truncated subtraction\n_−₀_ : ℕ₊ → ℕ₊ → Option(ℕ₊)\n𝟏 −₀ _ = None\n𝐒(x) −₀ 𝟏 = Some x\n𝐒(x) −₀ 𝐒(y) = x −₀ y\n\nopen import Data.Boolean\nopen import Type\n_≤?_ : ℕ₊ → ℕ₊ → Bool\n𝟏 ≤? _ = 𝑇\n𝐒(x) ≤? 𝟏 = 𝐹\n𝐒(x) ≤? 𝐒(y) = x ≤? y\n", "meta": {"hexsha": "d4c6172b98513180cb52dce565ed2ecbedb3e61e", "size": 704, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/PositiveInteger/Oper.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Numeral/PositiveInteger/Oper.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Numeral/PositiveInteger/Oper.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 16.3720930233, "max_line_length": 41, "alphanum_fraction": 0.5213068182, "num_tokens": 391, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9693242000616579, "lm_q2_score": 0.7853085859124002, "lm_q1q2_score": 0.761218616841089}} {"text": "module Numeral.Natural.Induction{ℓ} where\n\nopen import Logic\nopen import Logic.Propositional\nopen import Functional\nopen import Numeral.Natural\n\n-- The induction proof method on natural numbers\n-- TODO: There seems to be a problem making i implicit with unsolved metas.\n-- TODO: Maybe rename to elim because this is the elimination rule for ℕ\nℕ-elim : ∀{T : ℕ → Stmt{ℓ}} → T(𝟎) → ((i : ℕ) → T(i) → T(𝐒(i))) → ((n : ℕ) → T(n))\nℕ-elim {T} base step 𝟎 = base\nℕ-elim {T} base step (𝐒(n)) = step n (ℕ-elim {T} base step n)\n\n[ℕ]-induction : ∀{φ : ℕ → Stmt{ℓ}} → φ(𝟎) → (∀(i : ℕ) → φ(i) → φ(𝐒(i))) → (∀{n} → φ(n))\n[ℕ]-induction {φ} base step {n} = ℕ-elim {φ} base step n\n\n[ℕ]-inductionᵢ : ∀{φ : ℕ → Stmt{ℓ}} → φ(𝟎) → (∀{i : ℕ} → φ(i) → φ(𝐒(i))) → (∀{n} → φ(n))\n[ℕ]-inductionᵢ {φ} base step = [ℕ]-induction {φ} base (i ↦ step{i})\n", "meta": {"hexsha": "b5cabb5dcdd4326ab715819f924180132e6ad3e5", "size": 827, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Natural/Induction.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Numeral/Natural/Induction.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Numeral/Natural/Induction.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.35, "max_line_length": 88, "alphanum_fraction": 0.592503023, "num_tokens": 347, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9390248157222396, "lm_q2_score": 0.8104789063814616, "lm_q1q2_score": 0.7610598057116142}} {"text": "module Dave.Algebra.Naturals.Addition where \n open import Dave.Algebra.Naturals.Definition public\n open import Dave.Extensionality\n\n _+_ : ℕ → ℕ → ℕ\n zero + b = b\n suc a + b = suc (a + b)\n\n infixl 6 _+_\n\n {- Semigroup -}\n +-assoc : associative _+_\n +-assoc zero n p = refl\n +-assoc (suc m) n p = cong suc (+-assoc m n p)\n\n +-assoc' : associative _+_\n +-assoc' zero n p = begin\n (zero + n) + p ≡⟨⟩\n n + p ≡⟨⟩\n zero + (n + p) ∎\n +-assoc' (suc m) n p = begin\n (suc m + n) + p ≡⟨⟩\n suc (m + n) + p ≡⟨⟩\n suc ((m + n) + p) ≡⟨ cong suc (+-assoc' m n p) ⟩\n suc (m + (n + p)) ∎\n \n ℕ-+-IsSemigroup : IsSemigroup _+_\n IsSemigroup.assoc ℕ-+-IsSemigroup = +-assoc\n\n ℕ-+-Semigroup : Semigroup\n Semigroup.Carrier ℕ-+-Semigroup = ℕ\n Semigroup._·_ ℕ-+-Semigroup = _+_\n Semigroup.isSemigroup ℕ-+-Semigroup = ℕ-+-IsSemigroup\n\n {- Identity -}\n +-right-identity : right-identity _+_ 0\n +-right-identity zero = refl\n +-right-identity (suc n) = cong suc (+-right-identity n)\n\n +-left-identity : left-identity _+_ 0\n +-left-identity m = refl\n\n ℕ-+-HasIdentity : Identity _+_ 0\n Identity.left ℕ-+-HasIdentity = +-left-identity\n Identity.right ℕ-+-HasIdentity = +-right-identity\n\n {- Monoid -}\n ℕ-+-IsMonoid : IsMonoid _+_ 0\n IsMonoid.semigroup ℕ-+-IsMonoid = ℕ-+-IsSemigroup\n IsMonoid.identity ℕ-+-IsMonoid = ℕ-+-HasIdentity\n\n ℕ-+-Monoid : Monoid\n Monoid.Carrier ℕ-+-Monoid = ℕ\n Monoid._·_ ℕ-+-Monoid = _+_\n Monoid.e ℕ-+-Monoid = 0\n Monoid.isMonoid ℕ-+-Monoid = ℕ-+-IsMonoid\n\n {- Commutative Monoid -}\n +-suc : ∀ (m n : ℕ) → m + suc n ≡ suc (m + n)\n +-suc zero n = refl\n +-suc (suc m) n = cong suc (+-suc m n)\n\n +-comm : commutative _+_\n +-comm m zero = +-right-identity m\n +-comm m (suc n) = trans (+-suc m n) (cong suc (+-comm m n))\n\n +-comm' : commutative _+_\n +-comm' m zero = +-right-identity m\n +-comm' m (suc n) = begin\n (m + suc n) ≡⟨ +-suc m n ⟩\n suc (m + n) ≡⟨ cong suc (+-comm' m n) ⟩\n suc (n + m) ∎\n\n ℕ-+-IsCommutativeMonoid : IsCommutativeMonoid _+_ 0\n IsCommutativeMonoid.isSemigroup ℕ-+-IsCommutativeMonoid = ℕ-+-IsSemigroup\n IsCommutativeMonoid.leftIdentity ℕ-+-IsCommutativeMonoid = +-left-identity\n IsCommutativeMonoid.comm ℕ-+-IsCommutativeMonoid = +-comm\n\n {- Additional Theorems -}\n +-add1ᵣ : ∀ (m : ℕ) → m + 1 ≡ suc m\n +-add1ᵣ zero = refl\n +-add1ᵣ (suc m) = cong suc (+-add1ᵣ m)\n\n +-add1ₗ : ∀ (m : ℕ) → 1 + m ≡ suc m\n +-add1ₗ m = refl\n\n {- Another equal Addition Definition -}\n _+´_ : ℕ → ℕ → ℕ\n m +´ zero = m\n m +´ suc n = suc (m +´ n)\n\n app-+≡+´ : ∀ (m n : ℕ) → m + n ≡ m +´ n\n app-+≡+´ zero zero = refl\n app-+≡+´ zero (suc n) = cong suc (app-+≡+´ zero n)\n app-+≡+´ (suc m) zero = cong suc (app-+≡+´ m zero)\n app-+≡+´ (suc m) (suc n) = cong suc ( \n begin\n m + suc n ≡⟨ +-suc m n ⟩\n suc m + n ≡⟨ app-+≡+´ (suc m) n ⟩\n suc m +´ n ∎ )\n\n +≡+´ : _+_ ≡ _+´_\n +≡+´ = extensionality (λ m → extensionality (λ n → app-+≡+´ m n))\n ", "meta": {"hexsha": "afbe5a867ed49fc87df673b4079d78536acd51b9", "size": 2945, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Dave/Algebra/Naturals/Addition.agda", "max_stars_repo_name": "DavidStahl97/formal-proofs", "max_stars_repo_head_hexsha": "05213fb6ab1f51f770f9858b61526ba950e06232", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Dave/Algebra/Naturals/Addition.agda", "max_issues_repo_name": "DavidStahl97/formal-proofs", "max_issues_repo_head_hexsha": "05213fb6ab1f51f770f9858b61526ba950e06232", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Dave/Algebra/Naturals/Addition.agda", "max_forks_repo_name": "DavidStahl97/formal-proofs", "max_forks_repo_head_hexsha": "05213fb6ab1f51f770f9858b61526ba950e06232", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.3173076923, "max_line_length": 76, "alphanum_fraction": 0.5643463497, "num_tokens": 1236, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9532750440288019, "lm_q2_score": 0.7981867801399695, "lm_q1q2_score": 0.7608915379811371}} {"text": "{-# OPTIONS --without-K --exact-split --safe #-}\n\nmodule Basic_Types where\n\n-- Already in the builtin's of agda, there are Π types, which is ∀, and lambda\n-- abstraction, which is λ{ } and function types, which is →.\n\n\n-- ------------------------------------\n-- Some operations for function types\n-- The curly brackts ∀{} should be viewed as contexts.\n\n-- identity function\nid : ∀ {A : Set} → A → A\nid = λ{ x → x }\n\n-- function composition\ncomp : ∀ {A B C : Set} → (B → C) → (A → B) → A → C\ncomp {A} {B} {C} = λ (f : B → C) (g : A → B) (x : A) → f (g x)\n-- The judgemental equality of association of functions is builtin in agda,\n-- i.e., all the rules of derivation in the basic language of type theory,\n-- e.g., the β-, η- reduction is automatic in agda.\n\n-- swapping the argument\nswap : ∀ {A B : Set} {C : A → B → Set} →\n (∀ (a : A) (b : B) → C a b) → (∀ (b : B) (a : A) → C a b)\nswap {A} {B} {C} = λ { p → λ (b : B) (a : A) → p a b }\n\n\n-- ------------------------------------\n-- the unit type\ndata 𝟙 : Set where\n ⋆ : 𝟙\n\n𝟙-ind : ∀ {A : 𝟙 → Set} → ∀ (a : A ⋆) → ∀ (x : 𝟙) → A x\n𝟙-ind {A} a = 𝟙-indhelper\n where 𝟙-indhelper : ∀ (x : 𝟙) → A x\n 𝟙-indhelper ⋆ = a\n\n-- ------------------------------------\n-- the empty type\ndata 𝟘 : Set where\n\n𝟘-ind : ∀ {A : 𝟘 → Set} → ∀ (x : 𝟘) → A x\n𝟘-ind {A} ()\n\n-- define negation\n¬_ : ∀ (A : Set) → Set\n¬ A = A → 𝟘\n\n-- ------------------------------------\n-- the boolean type\ndata 𝟚 : Set where\n tt ff : 𝟚\n\n𝟚-ind : ∀ {A : 𝟚 → Set} → A ff → A tt → ∀ (x : 𝟚) → A x\n𝟚-ind Aff _ ff = Aff\n𝟚-ind _ Att tt = Att\n\n-- ------------------------------------\n-- natural numbers\ndata ℕ : Set where\n zero : ℕ\n succ : ℕ → ℕ\n\n{-# BUILTIN NATURAL ℕ #-}\n\n-- ℕ induction\nℕ-ind : ∀ {A : ℕ → Set} →\n ∀ (a : A 0) → (∀ (n : ℕ) → A n → A (succ n)) → ∀ (m : ℕ) → A m\nℕ-ind {A} a p = ℕ-indhelper\n where ℕ-indhelper : ∀ (m : ℕ) → A m\n ℕ-indhelper 0 = a\n ℕ-indhelper (succ n) = p n (ℕ-indhelper n)\n-- From this exercise, we can actually see that the idea of induction is\n-- builtin in agda, since we essentially use the induction builtin in agda\n-- to prove ℕ-ind.\n\n-- ℕ recursion, which is a special case for ℕ induction, where the type is not\n-- dependent on ℕ\nℕ-rec : ∀ {A : Set} →\n ∀ (a : A) → (∀ (n : ℕ) → A → A) → ∀ (m : ℕ) → A\nℕ-rec {A} = ℕ-ind {λ { n → A }}\n\n-- for example, we can use ℕ-rec to define addition\nadd : ℕ → ℕ → ℕ\nadd = ℕ-rec {ℕ → ℕ} (id {ℕ}) (λ (n : ℕ) (p : ℕ → ℕ) → comp succ p)\n\n-- ------------------------------------\n-- the sum type\nrecord Σ (A : Set) (B : A → Set) : Set where\n constructor\n _,_\n field\n a : A\n b : B a\n\n-- the two projections\nπ₁ : ∀ {A : Set} {B : A → Set} → Σ A B → A\nπ₁ (x , y) = x\n\nπ₂ : ∀ {A : Set} {B : A → Set} → ∀ (z : Σ A B) → B (π₁ z)\nπ₂ (x , y) = y\n\nsyntax Σ A (λ a → b) = Σ a ∶ A , b\n\n-- Σ induction\nΣ-ind : ∀ {A : Set} {B : A → Set} {P : Σ A B → Set} →\n (∀ (a : A) (b : B a) → P (a , b)) → ∀ (z : Σ A B) → P z\nΣ-ind {A} {B} {P} = λ (f : ∀ (a : A) (b : B a) → P (a , b)) →\n λ (z : Σ A B) → f (π₁ z) (π₂ z)\n\n-- cartesion product type\n_×_ : Set → Set → Set\nA × B = Σ a ∶ A , B\n\n×-ind : ∀ {A : Set} {B : Set} {P : A × B → Set} →\n (∀ (a : A) (b : B) → P (a , b)) → ∀ (z : A × B) → P z\n×-ind {A} {B} {P} = Σ-ind {A} {λ (a : A) → B} {P}\n\n-- ------------------------------------\n-- the coproduct type\n\ndata _⊎_ (A : Set) (B : Set) : Set where\n inl : A → A ⊎ B\n inr : B → A ⊎ B\n\n⊎-ind : ∀ {A : Set} {B : Set} {P : A ⊎ B → Set} →\n (∀ (a : A) → P (inl a)) → (∀ (b : B) → P (inr b)) →\n ∀ (u : A ⊎ B) → P u\n⊎-ind f _ (inl x) = f x\n⊎-ind _ g (inr y) = g y\n", "meta": {"hexsha": "3915693ceb51f001de8ce12b4ac883debedc76a5", "size": 3613, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "HoTT/Basic_Types.agda", "max_stars_repo_name": "andyfreeyy/agda_and_math", "max_stars_repo_head_hexsha": "76b9ef64626b6d3bbb7ace4f1a16aeb447c54328", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-03-23T09:01:42.000Z", "max_stars_repo_stars_event_max_datetime": "2020-05-24T10:56:36.000Z", "max_issues_repo_path": "HoTT/Basic_Types.agda", "max_issues_repo_name": "andyfreeyy/agda_and_math", "max_issues_repo_head_hexsha": "76b9ef64626b6d3bbb7ace4f1a16aeb447c54328", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "HoTT/Basic_Types.agda", "max_forks_repo_name": "andyfreeyy/agda_and_math", "max_forks_repo_head_hexsha": "76b9ef64626b6d3bbb7ace4f1a16aeb447c54328", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.1654135338, "max_line_length": 78, "alphanum_fraction": 0.4439523941, "num_tokens": 1474, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8991213853793453, "lm_q2_score": 0.8459424431344437, "lm_q1q2_score": 0.760604941422229}} {"text": "module Structure.Setoid.Uniqueness where\n\nimport Lvl\nopen import Functional\nopen import Logic\nopen import Logic.Propositional\nopen import Logic.Predicate\nopen import Structure.Setoid\nopen import Type\n\nprivate variable ℓₗ ℓₗ₁ ℓₗ₂ : Lvl.Level\n\nmodule _ {ℓ₁}{ℓ₂} where\n -- Definition of uniqueness of a property.\n -- This means that there is at most one element that satisfies this property.\n -- This is similiar to \"Injective\" for functions.\n Unique : ∀{Obj : Type{ℓ₁}}{ℓₗ} → ⦃ equiv : Equiv{ℓₗ}(Obj) ⦄ → (Pred : Obj → Stmt{ℓ₂}) → Stmt\n Unique {Obj = Obj} Pred = ∀{x y : Obj} → Pred(x) → Pred(y) → (x ≡ y)\n\n -- Definition of existence of an unique element satisfying a property.\n -- This means that there is one and only one element that satisfies this property.\n ∃! : ∀{Obj : Type{ℓ₁}}{ℓₗ} → ⦃ equiv : Equiv{ℓₗ}(Obj) ⦄ → (Pred : Obj → Stmt{ℓ₂}) → Stmt\n ∃! {Obj} Pred = ∃(Pred) ∧ Unique(Pred)\n\n [∃!]-intro : ∀{T} → ⦃ _ : Equiv{ℓₗ}(T) ⦄ → ∀{property} → ∃(property) → Unique{T}(property) → ∃!(property)\n [∃!]-intro = [∧]-intro\n\n [∃!]-existence : ∀{Obj} → ⦃ _ : Equiv{ℓₗ}(Obj) ⦄ → ∀{Pred} → ∃!{Obj}(Pred) → ∃(Pred)\n [∃!]-existence = [∧]-elimₗ\n\n [∃!]-uniqueness : ∀{Obj} → ⦃ _ : Equiv{ℓₗ}(Obj) ⦄ → ∀{Pred} → ∃!{Obj}(Pred) → Unique(Pred)\n [∃!]-uniqueness = [∧]-elimᵣ\n\n [∃!]-witness : ∀{Obj} → ⦃ _ : Equiv{ℓₗ}(Obj) ⦄ → ∀{Pred} → ∃!{Obj}(Pred) → Obj\n [∃!]-witness e = [∃]-witness ([∃!]-existence e)\n\n [∃!]-proof : ∀{Obj} → ⦃ _ : Equiv{ℓₗ}(Obj) ⦄ → ∀{Pred} → (e : ∃!{Obj}(Pred)) → Pred([∃!]-witness(e))\n [∃!]-proof e = [∃]-proof ([∃!]-existence e)\n\n [∃!]-existence-eq : ∀{T} → ⦃ _ : Equiv{ℓₗ}(T) ⦄ → ∀{P} → (e : ∃!(P)) → ∀{x} → P(x) → (x ≡ [∃!]-witness e)\n [∃!]-existence-eq e {x} px = [∃!]-uniqueness e {x} {[∃!]-witness e} px ([∃!]-proof e)\n\n [∃!]-existence-eq-any : ∀{T} → ⦃ _ : Equiv{ℓₗ}(T) ⦄ → ∀{P} → (e : ∃!(P)) → ∀{x} → P(x) → ([∃!]-witness e ≡ x)\n [∃!]-existence-eq-any e {x} px = [∃!]-uniqueness e {[∃!]-witness e} {x} ([∃!]-proof e) px\n\n -- TODO: [∃!]-equivalence {T} property = ∃(a ↦ ∃{property(a)}(pa ↦ pa ∧ Uniqueness{T}(property){a}(pa)))\n", "meta": {"hexsha": "6adb16b7a2b6614c7d0abdd30760a22736a25f01", "size": 2073, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Structure/Setoid/Uniqueness.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Structure/Setoid/Uniqueness.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Structure/Setoid/Uniqueness.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.1063829787, "max_line_length": 111, "alphanum_fraction": 0.5504100338, "num_tokens": 943, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8947894661025424, "lm_q2_score": 0.849971181358171, "lm_q1q2_score": 0.7605452595700251}} {"text": "--------------------------------------------------------------------------------\n-- This is part of Agda Inference Systems\n\nopen import Data.Nat\nopen import Relation.Binary.PropositionalEquality\nopen import Data.Sum\n\nmodule Examples.Colists.Auxiliary.MaxOf where\n\n max : ℕ → ℕ → ℕ\n max zero zero = zero\n max zero (suc y) = suc y\n max (suc x) zero = suc x\n max (suc x) (suc y) = suc (max x y)\n\n max-refl : (x y : ℕ) → (x ≡ max x y) ⊎ (y ≡ max x y)\n max-refl zero zero = inj₂ refl\n max-refl zero (suc y) = inj₂ refl\n max-refl (suc x) zero = inj₁ refl\n max-refl (suc x) (suc y) with max-refl x y\n max-refl (suc x) (suc y) | inj₁ eq = inj₁ (cong (λ x₁ → suc x₁) eq)\n max-refl (suc x) (suc y) | inj₂ eq = inj₂ (cong (λ x₁ → suc x₁) eq)\n\n max-refl-eq : ∀{x y z} → z ≡ max x y → z ≡ x ⊎ z ≡ y\n max-refl-eq {x} {y} {z} refl with max-refl x y\n max-refl-eq {x} {y} {.(max x y)} refl | inj₁ x₁ = inj₁ (sym x₁)\n max-refl-eq {x} {y} {.(max x y)} refl | inj₂ y₁ = inj₂ (sym y₁)\n\n max-self : ∀ {n} → n ≡ max n n\n max-self {zero} = refl\n max-self {suc n} = cong (λ x → suc x) max-self\n\n max-trans : ∀{x y z} → y ≡ max y z → x ≡ max x y → x ≡ max x z\n max-trans {zero} {zero} {zero} _ _ = refl\n max-trans {suc x} {zero} {zero} refl refl = refl\n max-trans {suc x} {suc y} {zero} refl _ = refl\n max-trans {suc x} {suc y} {suc z} eq eq1 =\n let eq-pred = cong pred eq in\n let eq1-pred = cong pred eq1 in\n cong suc (max-trans eq-pred eq1-pred)\n\n max-comm : ∀{x y z} → x ≡ max y z → x ≡ max z y\n max-comm {x} {zero} {zero} eq = eq\n max-comm {x} {suc y} {zero} eq = eq\n max-comm {x} {zero} {suc z} eq = eq\n max-comm {suc x} {suc y} {suc z} eq = cong suc (max-comm (cong pred eq))", "meta": {"hexsha": "fe01bdc8693c343ab9fdccfbf4b2fe33c4f69b75", "size": 1693, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Examples/Colists/Auxiliary/MaxOf.agda", "max_stars_repo_name": "LcicC/inference-systems-agda", "max_stars_repo_head_hexsha": "b9043f99e4bf7211db4066a7a943401d127f0c8f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2022-03-10T15:53:47.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-25T15:48:52.000Z", "max_issues_repo_path": "Examples/Colists/Auxiliary/MaxOf.agda", "max_issues_repo_name": "LcicC/inference-systems-agda", "max_issues_repo_head_hexsha": "b9043f99e4bf7211db4066a7a943401d127f0c8f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Examples/Colists/Auxiliary/MaxOf.agda", "max_forks_repo_name": "LcicC/inference-systems-agda", "max_forks_repo_head_hexsha": "b9043f99e4bf7211db4066a7a943401d127f0c8f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.8043478261, "max_line_length": 80, "alphanum_fraction": 0.5528647372, "num_tokens": 686, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9149009480320036, "lm_q2_score": 0.8311430499496095, "lm_q1q2_score": 0.7604135643491087}} {"text": "{-# OPTIONS --sized-types #-}\nopen import Relation.Binary.Core\n\nmodule BubbleSort.Correctness.Permutation {A : Set}\n (_≤_ : A → A → Set)\n (tot≤ : Total _≤_) where\n\nopen import BubbleSort _≤_ tot≤\nopen import Data.Product\nopen import Data.List\nopen import Data.Sum\nopen import List.Permutation.Base A\nopen import List.Permutation.Base.Equivalence A\nopen import Size\nopen import SList\nopen import SList.Properties A\nopen import SList.Concatenation A\n\nlemma-swap*∼ : {ι : Size}(x : A) → (xs : SList A {ι}) → unsize A (x ∙ xs) ∼ unsize A (proj₂ (swap* x xs) ∙ proj₁ (swap* x xs))\nlemma-swap*∼ x snil = ∼x /head /head ∼[]\nlemma-swap*∼ x (y ∙ ys) \n with tot≤ x y\n... | inj₁ x≤y = ∼x /head (/tail /head) (lemma-swap*∼ y ys)\n... | inj₂ y≤x = ∼x (/tail /head) (/tail /head) (lemma-swap*∼ x ys)\n\nlemma-bubbleSort∼ : {ι : Size}(xs : SList A {ι}) → unsize A xs ∼ unsize A (bubbleSort xs)\nlemma-bubbleSort∼ snil = ∼[]\nlemma-bubbleSort∼ (x ∙ xs) = trans∼ (lemma-swap*∼ x xs) (trans∼ (lemma-⊕∼ y (lemma-bubbleSort∼ ys)) (lemma-size-unsize y (bubbleSort ys)))\n where sxxs = swap* x xs\n ys = proj₁ sxxs\n y = proj₂ sxxs\n\ntheorem-bubbleSort∼ : (xs : List A) → xs ∼ unsize A (bubbleSort (size A xs))\ntheorem-bubbleSort∼ xs = trans∼ (lemma-unsize-size xs) (lemma-bubbleSort∼ (size A xs))\n\n\n", "meta": {"hexsha": "72d99f16ad8a6a0335dcfc32cd725eb4c1a0618b", "size": 1369, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/BubbleSort/Correctness/Permutation.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/BubbleSort/Correctness/Permutation.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/BubbleSort/Correctness/Permutation.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.0, "max_line_length": 138, "alphanum_fraction": 0.6128560993, "num_tokens": 481, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9273632896242073, "lm_q2_score": 0.8198933337131076, "lm_q1q2_score": 0.7603389790931454}} {"text": "{-# OPTIONS --prop --without-K #-}\n\nmodule Data.Nat.Square where\n\nopen import Data.Nat\nopen import Data.Nat.Properties\n\nopen import Relation.Nullary\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality as Eq using (_≡_; refl)\n\n_² : ℕ → ℕ\nn ² = n * n\n\nn^2≡n² : ∀ n → n ^ 2 ≡ n ²\nn^2≡n² n = Eq.cong (n *_) (*-identityʳ n)\n\n²-mono : _² Preserves _≤_ ⟶ _≤_\n²-mono m≤n = *-mono-≤ m≤n m≤n\n", "meta": {"hexsha": "f0e82fca790ed677fafb7fdb7a7fd439e09d2aed", "size": 408, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/Nat/Square.agda", "max_stars_repo_name": "jonsterling/agda-calf", "max_stars_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 29, "max_stars_repo_stars_event_min_datetime": "2021-07-14T03:18:28.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T20:35:11.000Z", "max_issues_repo_path": "src/Data/Nat/Square.agda", "max_issues_repo_name": "jonsterling/agda-calf", "max_issues_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Data/Nat/Square.agda", "max_forks_repo_name": "jonsterling/agda-calf", "max_forks_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-10-06T10:28:24.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-29T08:12:01.000Z", "avg_line_length": 20.4, "max_line_length": 73, "alphanum_fraction": 0.6642156863, "num_tokens": 157, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9353465116437761, "lm_q2_score": 0.8128673110375458, "lm_q1q2_score": 0.7603126038082249}} {"text": "module Numeral.Natural.Relation where\n\nopen import Data.Boolean.Stmt\nopen import Numeral.Natural\nopen import Numeral.Natural.Oper.Comparisons\nopen import Logic.Propositional\nopen import Logic\nimport Lvl\nopen import Relator.Equals\nopen import Type\n\nPositive : ℕ → Stmt\nPositive(n) = IsTrue(positive? n)\n\nzero-not-positive : ¬ Positive(𝟎)\nzero-not-positive ()\n\npositive-not-zero : ∀{n} → ⦃ _ : Positive(n) ⦄ → (n ≢ 𝟎)\npositive-not-zero {𝟎} ⦃ pos ⦄ _ = pos\n\nnon-zero-positive : ∀{n} → (n ≢ 𝟎) → Positive(n)\nnon-zero-positive {𝟎} p = p [≡]-intro\nnon-zero-positive {𝐒 n} p = [⊤]-intro\n", "meta": {"hexsha": "921027508c716cd596f94e5d4bc869e53889cbe5", "size": 587, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Natural/Relation.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Numeral/Natural/Relation.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Numeral/Natural/Relation.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.4583333333, "max_line_length": 56, "alphanum_fraction": 0.6984667802, "num_tokens": 200, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9465966671870766, "lm_q2_score": 0.8031737963569016, "lm_q1q2_score": 0.7602816388034348}} {"text": "open import Data.List\n\n{- --- 6. Vectors --- -}\n\n{- 6.1 Warmup -}\n\n{- Problem: what do we return for the empty list ? -}\nhead2 : {A : Set} → List A → A\nhead2 [] = {!!}\nhead2 (x ∷ l) = x\n\n{- 6.2 Definition -}\nopen import Data.Nat\n\ndata Vec (A : Set) : ℕ → Set where\n [] : Vec A zero\n _::_ : {n : ℕ} → A → Vec A n → Vec A (suc n)\n\n{- 6.3 Head and tail -}\nhead-vec : {A : Set} → {n : ℕ} → Vec A (suc n) → A\nhead-vec (x :: v) = x\n\ntail-vec : {A : Set} → {n : ℕ} → Vec A (suc n) → Vec A n\ntail-vec (x :: v) = v\n\n{- 6.4 Concatenation -}\nconcat-vec : {A : Set} → {m n : ℕ} → Vec A m → Vec A n → Vec A (m + n)\nconcat-vec [] v2 = v2\nconcat-vec (x :: v1) v2 = x :: (concat-vec v1 v2)\n\n{- 6.5 Reversal -}\nsnoc-vec : {A : Set} → {n : ℕ} → A → Vec A n → Vec A (suc n)\nsnoc-vec a [] = a :: []\nsnoc-vec a (x :: v) = x :: (snoc-vec a v)\n\nrev-vec : {A : Set} → {n : ℕ} → Vec A n → Vec A n\nrev-vec [] = []\nrev-vec (x :: v) = snoc-vec x (rev-vec v)\n\n{- 6.6 Accessing an element -}\ndata Fin : ℕ → Set where\n zero : {n : ℕ} → Fin (suc n)\n suc : {n : ℕ} (i : Fin n) → Fin (suc n)\n\n{- 6.7 Zipping -}\nopen import Data.Product hiding (zip)\n\nzip-vec : {A : Set} → {n : ℕ} → Vec A n → Vec A n → Vec (A × A) n\nzip-vec [] [] = []\nzip-vec (x₁ :: y₁) (x₂ :: y₂) = (x₁ , x₂) :: (zip-vec y₁ y₂)\n", "meta": {"hexsha": "7dbfa743e4eb6b8515652373ad997f9146618130", "size": 1266, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "TD6/Vector.agda", "max_stars_repo_name": "erwinkn/program-eq-proof", "max_stars_repo_head_hexsha": "9a0d4a3f97103550a67e5e9ecbc8322bf0a8be23", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "TD6/Vector.agda", "max_issues_repo_name": "erwinkn/program-eq-proof", "max_issues_repo_head_hexsha": "9a0d4a3f97103550a67e5e9ecbc8322bf0a8be23", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "TD6/Vector.agda", "max_forks_repo_name": "erwinkn/program-eq-proof", "max_forks_repo_head_hexsha": "9a0d4a3f97103550a67e5e9ecbc8322bf0a8be23", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.8235294118, "max_line_length": 70, "alphanum_fraction": 0.4944707741, "num_tokens": 554, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.907312221360624, "lm_q2_score": 0.8376199653600372, "lm_q1q2_score": 0.7599828314268243}} {"text": "module Data.Nat.Etc where\n\nopen import Data.Nat\nopen import Data.Nat.Properties.Simple\nopen import Function\nopen import Relation.Nullary.Negation using (contradiction; contraposition)\nopen import Relation.Binary\n\nopen import Relation.Binary.PropositionalEquality as PropEq\n using (_≡_; _≢_; refl; cong; trans; sym)\nopen PropEq.≡-Reasoning\n\n-- exponention\n_^_ : ℕ → ℕ → ℕ\na ^ zero = 1\na ^ suc b = a * (a ^ b)\n\n--------------------------------------------------------------------------------\n-- Properties\n--------------------------------------------------------------------------------\n\ndistrib-left-*-+ : ∀ m n o → m * (n + o) ≡ m * n + m * o\ndistrib-left-*-+ m n o =\n begin\n m * (n + o)\n ≡⟨ *-comm m (n + o) ⟩\n (n + o) * m\n ≡⟨ distribʳ-*-+ m n o ⟩\n n * m + o * m\n ≡⟨ cong (flip _+_ (o * m)) (*-comm n m) ⟩\n m * n + o * m\n ≡⟨ cong (_+_ (m * n)) (*-comm o m) ⟩\n m * n + m * o\n ∎\n{-\nno-zero-divisor : ∀ m n → m ≢ 0 → m * n ≡ 0 → n ≡ 0\nno-zero-divisor zero n p q = contradiction q p\nno-zero-divisor (suc m) zero p q = refl\nno-zero-divisor (suc m) (suc n) p ()\n\nm^n≢0 : ∀ m n → {m≢0 : m ≢ 0} → m ^ n ≢ 0\nm^n≢0 m zero {p} = λ ()\nm^n≢0 m (suc n) {p} = contraposition (no-zero-divisor m (m ^ n) p) (m^n≢0 m n {p})\n\nm≰n⇒n n\nm≰n⇒n⇒≰ : _>_ ⇒ _≰_\n>⇒≰ {zero} ()\n>⇒≰ {suc m} {zero} rel ()\n>⇒≰ {suc m} {suc n} (s≤s rel) (s≤s x) = contradiction x (>⇒≰ rel)\n\n>⇒≢ : _>_ ⇒ _≢_\n>⇒≢ {zero} () m≡n\n>⇒≢ {suc m} {zero} m>n ()\n>⇒≢ {suc m} {suc n} (s≤s m>n) m≡n = >⇒≢ m>n (cong pred m≡n)\n\n{-\n≰⇒> : _≰_ ⇒ _>_\n≰⇒> {zero} z≰n with z≰n z≤n\n... | ()\n≰⇒> {suc m} {zero} _ = s≤s z≤n\n≰⇒> {suc m} {suc n} m≰n = s≤s (≰⇒> (m≰n ∘ s≤s))\n-}\n{-\n begin\n {! !}\n ≡⟨ {! !} ⟩\n {! !}\n ≡⟨ {! !} ⟩\n {! !}\n ≡⟨ {! !} ⟩\n {! !}\n ≡⟨ {! !} ⟩\n {! !}\n ∎\n-}\n", "meta": {"hexsha": "b622648bcfa3f87460f5eb7cefe295815c4bffb7", "size": 2082, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "legacy/Data/Nat/Etc.agda", "max_stars_repo_name": "banacorn/numeral", "max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z", "max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z", "max_issues_repo_path": "legacy/Data/Nat/Etc.agda", "max_issues_repo_name": "banacorn/numeral", "max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "legacy/Data/Nat/Etc.agda", "max_forks_repo_name": "banacorn/numeral", "max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z", "avg_line_length": 25.7037037037, "max_line_length": 82, "alphanum_fraction": 0.3991354467, "num_tokens": 966, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9046505273888291, "lm_q2_score": 0.8397339656668286, "lm_q1q2_score": 0.7596657749068094}} {"text": "{-# OPTIONS --copatterns #-}\n\nopen import Common.Size\nopen import Common.Prelude\nopen import Common.Product renaming (proj₁ to fst; proj₂ to snd)\n\nrecord Stream (i : Size) (A : Set) : Set where\n coinductive\n field force : ∀{j : Size< i} → A × Stream j A\nopen Stream\n\nhead : ∀{i A} → Stream (↑ i) A → A\nhead s = fst (force s)\n\ntail : ∀{i A} → Stream (↑ i) A → Stream i A\ntail s = snd (force s)\n\nsmap : ∀{i A B} (f : A → B) → Stream i A → Stream i B\nforce (smap f s) with force s\n... | a , as = f a , smap f as\n\nscanl : ∀{i A B} (f : B → A → B) (b : B) (s : Stream i A) → Stream i B\nforce (scanl f b s) with force s\n... | a , as = b , scanl f (f b a) as\n\n_!_ : ∀{A} (s : Stream _ A) (n : Nat) → A\ns ! zero = head s\ns ! suc n = tail s ! n\n\n_!!_ : ∀{A} (s : Stream _ A) (n : Nat) → A\ns !! n with force s\n_ !! zero | a , as = a\n_ !! suc n | a , as = as !! n\n\nnats : ∀{i} → Stream i Nat\nforce nats = 0 , smap suc nats\n\nsums : Stream _ Nat\nsums = scanl (_+_) 0 (tail nats)\n\nmain : IO Unit\nmain = printNat (sums ! 100)\n-- Expected output, due to Gauss: 5050\n", "meta": {"hexsha": "0252795029122598c91b930a01b8f8e45df6f7fb", "size": 1055, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Compiler/simple/CopatternStreamSized.agda", "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/Compiler/simple/CopatternStreamSized.agda", "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/Compiler/simple/CopatternStreamSized.agda", "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.9772727273, "max_line_length": 70, "alphanum_fraction": 0.5620853081, "num_tokens": 415, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9372107949104866, "lm_q2_score": 0.8104789086703225, "lm_q1q2_score": 0.7595895822530966}} {"text": "{-\nThis second-order signature was created from the following second-order syntax description:\n\nsyntax Prod | P\n\ntype\n _⊗_ : 2-ary | l40\n\nterm\n pair : α β -> α ⊗ β | ⟨_,_⟩ \n fst : α ⊗ β -> α\n snd : α ⊗ β -> β\n\ntheory\n (fβ) a : α b : β |> fst (pair(a, b)) = a\n (sβ) a : α b : β |> snd (pair(a, b)) = b\n (pη) p : α ⊗ β |> pair (fst(p), snd(p)) = p\n-}\n\nmodule Prod.Signature where\n\nopen import SOAS.Context\n\n-- Type declaration\ndata PT : Set where\n _⊗_ : PT → PT → PT\ninfixl 40 _⊗_\n\n\nopen import SOAS.Syntax.Signature PT public\nopen import SOAS.Syntax.Build PT public\n\n-- Operator symbols\ndata Pₒ : Set where\n pairₒ fstₒ sndₒ : {α β : PT} → Pₒ\n\n-- Term signature\nP:Sig : Signature Pₒ\nP:Sig = sig λ\n { (pairₒ {α}{β}) → (⊢₀ α) , (⊢₀ β) ⟼₂ α ⊗ β\n ; (fstₒ {α}{β}) → (⊢₀ α ⊗ β) ⟼₁ α\n ; (sndₒ {α}{β}) → (⊢₀ α ⊗ β) ⟼₁ β\n }\n\nopen Signature P:Sig public\n", "meta": {"hexsha": "7552e7d313d57a4e47c4e72c0092a3de6cff060d", "size": 881, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "out/Prod/Signature.agda", "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 39, "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_issues_repo_path": "out/Prod/Signature.agda", "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_forks_repo_path": "out/Prod/Signature.agda", "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "avg_line_length": 19.152173913, "max_line_length": 91, "alphanum_fraction": 0.5550510783, "num_tokens": 380, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9372107949104866, "lm_q2_score": 0.8104789063814616, "lm_q1q2_score": 0.7595895801079515}} {"text": "------------------------------------------------------------------------------\n-- Distributive laws on a binary operation (Stanovský example)\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule DistributiveLaws.README where\n\n------------------------------------------------------------------------------\n-- Description\n\n-- Let _·_ be a left-associative binary operation which satifies the\n-- left and right distributive axioms:\n--\n-- ∀ x y z → x ∙ (y ∙ z) ≡ (x ∙ y) ∙ (x ∙ z)\n-- ∀ x y z → (x ∙ y) ∙ z ≡ (x ∙ z) ∙ (y ∙ z).\n\n-- We prove some properties of Stanovský (2008): Task B, Lemma 3,\n-- Lemma 4, Lemma 5 (Task A) and Lemma 6.\n\n------------------------------------------------------------------------------\n-- The axioms\nopen import DistributiveLaws.Base\n\n-- The interactive and combined proofs\nopen import DistributiveLaws.Lemma3-ATP\nopen import DistributiveLaws.Lemma4-ATP\nopen import DistributiveLaws.Lemma5-ATP\nopen import DistributiveLaws.Lemma6-ATP\nopen import DistributiveLaws.TaskB-AllStepsATP\nopen import DistributiveLaws.TaskB-HalvedStepsATP\nopen import DistributiveLaws.TaskB-I\nopen import DistributiveLaws.TaskB-TopDownATP\n\n-- Unproven theorem by the ATPs\nopen import DistributiveLaws.TaskB.UnprovedATP\n\n------------------------------------------------------------------------------\n-- References:\n--\n-- Stanovský, David (2008). Distributive Groupoids are\n-- Symmetrical-by-Medial: An Elementary Proof. Commentations\n-- Mathematicae Universitatis Carolinae 49.4, pp. 541–546.\n", "meta": {"hexsha": "d66c03388c488dfe49c780a7e2985d934253ae67", "size": 1700, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/DistributiveLaws/README.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/DistributiveLaws/README.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/DistributiveLaws/README.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 36.170212766, "max_line_length": 78, "alphanum_fraction": 0.5488235294, "num_tokens": 403, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.926303728259492, "lm_q2_score": 0.8198933447152497, "lm_q1q2_score": 0.7594702619848807}} {"text": "{-# OPTIONS --without-K #-}\n\nmodule Lecture3 where\n\nimport Lecture2\nopen Lecture2 public\n\ndata unit : U where\n star : unit\n\n𝟙 = unit\n\nind-unit : {i : Level} {P : unit → UU i} → P star → ((x : unit) → P x)\nind-unit p star = p\n\ndata empty : U where\n\n𝟘 = empty\n\nind-empty : {i : Level} {P : empty → UU i} → ((x : empty) → P x)\nind-empty ()\n\n¬ : {i : Level} → UU i → UU i\n¬ A = A → empty\n\ndata bool : U where\n true false : bool\n\nnot : bool → bool\nnot true = false\nnot false = true\n\nind-bool : {i : Level} {P : bool → UU i} → P true → P false → (x : bool) → P x\nind-bool Pt Pf true = Pt\nind-bool Pt Pf false = Pf\n\ndata coprod {i j : Level} (A : UU i) (B : UU j) : UU (i ⊔ j) where\n inl : A → coprod A B\n inr : B → coprod A B\n\ndata Sigma {i j : Level} (A : UU i) (B : A → UU j) : UU (i ⊔ j) where\n dpair : (x : A) → (B x → Sigma A B)\n\nΣ = Sigma\n\nind-Σ : {i j k : Level} {A : UU i} {B : A → UU j} {C : Σ A B → UU k} →\n ((x : A) (y : B x) → C (dpair x y)) → ((t : Σ A B) → C t)\nind-Σ f (dpair x y) = f x y\n\npr1 : {i j : Level} {A : UU i} {B : A → UU j} → Sigma A B → A\npr1 (dpair a b) = a\n\npr2 : {i j : Level} {A : UU i} {B : A → UU j} → (t : Sigma A B) → B (pr1 t)\npr2 (dpair a b) = b\n\nweaken : {i j : Level} (A : UU i) (B : UU j) → (A → UU j)\nweaken A B = λ a → B\n\nprod : {i j : Level} (A : UU i) (B : UU j) → UU (i ⊔ j)\nprod A B = Sigma A (λ a → B)\n\n_×_ : {i j : Level} (A : UU i) (B : UU j) → UU (i ⊔ j)\nA × B = prod A B\n\n-- WARNING, can't use pair in pattern matching as it's not recognized as a ctor\npair : {i j : Level} {A : UU i} {B : UU j} → A → (B → prod A B)\npair a b = dpair a b\n\n-- Pointed types\nU-pt : Type\nU-pt = Sigma U (λ X → X)\n\n-- Graphs\nGph : Type\nGph = Sigma U (λ X → (X → X → U))\n\n-- Reflexive graphs\nrGph : Type\nrGph = Sigma U (λ X → Sigma (X → X → U) (λ R → (x : X) → R x x))\n\n-- Finite sets\nFin : ℕ → U\nFin Nzero = empty\nFin (Nsucc n) = coprod (Fin n) unit\n\n-- Observational equality on the natural numbers\nEqN : ℕ → (ℕ → U)\nEqN Nzero Nzero = 𝟙\nEqN Nzero (Nsucc n) = 𝟘\nEqN (Nsucc m) Nzero = 𝟘\nEqN (Nsucc m) (Nsucc n) = EqN m n\n\n-- The integers\nℤ : U\nℤ = coprod ℕ (coprod unit ℕ)\n-- ^ ^^^^ ^\n-- (-∞, -1] 0 [1, ∞)\n-- -(n+1) n+1\n\n-- Inclusion of the negative integers\nin-neg : ℕ → ℤ\nin-neg n = inl n\n\n-- Negative one\nZneg-one : ℤ\nZneg-one = in-neg Nzero\n\n-- Zero\nZzero : ℤ\nZzero = inr (inl star)\n\n-- One\nZone : ℤ\nZone = inr (inr Nzero)\n\n-- Inclusion of the positive integers\nin-pos : ℕ → ℤ\nin-pos n = inr (inr n)\n\n-- Since Agda is already strong with nested induction, I dont think we need this definition.\nind-ℤ : {i : Level} (P : ℤ → UU i) → P Zneg-one → ((n : ℕ) → P (inl n) → P (inl (Nsucc n))) → P Zzero → P Zone → ((n : ℕ) → P (inr (inr (n))) → P (inr (inr (Nsucc n)))) → (k : ℤ) → P k\nind-ℤ P p-1 p-S p0 p1 pS (inl Nzero) = p-1\nind-ℤ P p-1 p-S p0 p1 pS (inl (Nsucc x)) = p-S x (ind-ℤ P p-1 p-S p0 p1 pS (inl x))\nind-ℤ P p-1 p-S p0 p1 pS (inr (inl star)) = p0\nind-ℤ P p-1 p-S p0 p1 pS (inr (inr Nzero)) = p1\nind-ℤ P p-1 p-S p0 p1 pS (inr (inr (Nsucc x))) = pS x (ind-ℤ P p-1 p-S p0 p1 pS (inr (inr (x))))\n\nZsucc : ℤ → ℤ\nZsucc (inl Nzero) = Zzero\nZsucc (inl (Nsucc x)) = inl x\nZsucc (inr (inl star)) = Zone\nZsucc (inr (inr x)) = inr (inr (Nsucc x))\n\n-- Exercise 3.1\n-- In this exercise we were asked to show that (A + ¬A) implies (¬¬A → A).\n-- In other words, we get double negation elimination for the types that are decidable\ndne-dec : {i : Level} (A : UU i) → (coprod A (¬ A)) → (¬ (¬ A) → A)\ndne-dec A (inl x) = λ f → x\ndne-dec A (inr x) = λ f → ind-empty (f x)\n\n-- Exercise 3.3\n-- In this exercise we were asked to show that the observational equality on ℕ is an equivalence relation.\nreflexive-EqN : (n : ℕ) → EqN n n\nreflexive-EqN Nzero = star\nreflexive-EqN (Nsucc n) = reflexive-EqN n\n\nsymmetric-EqN : (m n : ℕ) → EqN m n → EqN n m\nsymmetric-EqN Nzero Nzero t = t\nsymmetric-EqN Nzero (Nsucc n) t = t\nsymmetric-EqN (Nsucc n) Nzero t = t\nsymmetric-EqN (Nsucc m) (Nsucc n) t = symmetric-EqN m n t\n\ntransitive-EqN : (l m n : ℕ) → EqN l m → EqN m n → EqN l n\ntransitive-EqN Nzero Nzero Nzero s t = star\ntransitive-EqN (Nsucc n) Nzero Nzero s t = ind-empty s\ntransitive-EqN Nzero (Nsucc n) Nzero s t = ind-empty s\ntransitive-EqN Nzero Nzero (Nsucc n) s t = ind-empty t\ntransitive-EqN (Nsucc l) (Nsucc m) Nzero s t = ind-empty t\ntransitive-EqN (Nsucc l) Nzero (Nsucc n) s t = ind-empty s\ntransitive-EqN Nzero (Nsucc m) (Nsucc n) s t = ind-empty s\ntransitive-EqN (Nsucc l) (Nsucc m) (Nsucc n) s t = transitive-EqN l m n s t\n\n-- Exercise 3.4\n-- In this exercise we were asked to show that observational equality on the natural numbers is the least reflexive relation, in the sense that it implies all other reflexive relation. As we will see once we introduce the identity type, it follows that observationally equal natural numbers can be identified.\n\n-- We first make an auxilary construction, where the relation is quantified over inside the scope of the variables n and m. This is to ensure that the inductive hypothesis is strong enough to make the induction go through.\nleast-reflexive-EqN' : {i : Level} (n m : ℕ)\n (R : ℕ → ℕ → UU i) (ρ : (n : ℕ) → R n n) → EqN n m → R n m\nleast-reflexive-EqN' Nzero Nzero R ρ p = ρ Nzero\nleast-reflexive-EqN' Nzero (Nsucc m) R ρ = ind-empty\nleast-reflexive-EqN' (Nsucc n) Nzero R ρ = ind-empty\nleast-reflexive-EqN' (Nsucc n) (Nsucc m) R ρ =\n least-reflexive-EqN' n m (λ x y → R (Nsucc x) (Nsucc y)) (λ x → ρ (Nsucc x))\n\n-- Now we solve the actual exercise by rearranging the order of the variables.\nleast-reflexive-EqN : {i : Level} {R : ℕ → ℕ → UU i}\n (ρ : (n : ℕ) → R n n) → (n m : ℕ) → EqN n m → R n m\nleast-reflexive-EqN ρ n m p = least-reflexive-EqN' n m _ ρ p\n\n-- Exercise 3.5\n-- In this exercise we were asked to show that any function on the natural numbers preserves observational equality. The quick solution uses the fact that observational equality is the least reflexive relation.\npreserve_EqN : (f : ℕ → ℕ) (n m : ℕ) → (EqN n m) → (EqN (f n) (f m))\npreserve_EqN f =\n least-reflexive-EqN {_} {λ x y → EqN (f x) (f y)}\n (λ x → reflexive-EqN (f x))\n\n-- Exercise 3.6\n-- In this exercise we were asked to construct the relations ≤ and < on the natural numbers, and show basic properties about them.\n\n-- Definition of ≤\nleqN : ℕ → ℕ → U\nleqN Nzero Nzero = unit\nleqN Nzero (Nsucc m) = unit\nleqN (Nsucc n) Nzero = empty\nleqN (Nsucc n) (Nsucc m) = leqN n m\n\n_≤_ = leqN\n\n-- Definition of <\nleN : ℕ → ℕ → U\nleN Nzero Nzero = empty\nleN Nzero (Nsucc m) = unit\nleN (Nsucc n) Nzero = empty\nleN (Nsucc n) (Nsucc m) = leN n m\n\n_<_ = leN\n\nreflexive-leqN : (n : ℕ) → n ≤ n\nreflexive-leqN Nzero = star\nreflexive-leqN (Nsucc n) = reflexive-leqN n\n\nanti-reflexive-leN : (n : ℕ) → ¬ (n < n)\nanti-reflexive-leN Nzero = ind-empty\nanti-reflexive-leN (Nsucc n) = anti-reflexive-leN n\n\ntransitive-leqN : (n m l : ℕ) → (n ≤ m) → (m ≤ l) → (n ≤ l)\ntransitive-leqN Nzero Nzero Nzero p q = reflexive-leqN Nzero\ntransitive-leqN Nzero Nzero (Nsucc l) p q = q\ntransitive-leqN Nzero (Nsucc m) Nzero p q = star\ntransitive-leqN Nzero (Nsucc m) (Nsucc l) p q = star\ntransitive-leqN (Nsucc n) Nzero l p q = ind-empty p\ntransitive-leqN (Nsucc n) (Nsucc m) Nzero p q = ind-empty q\ntransitive-leqN (Nsucc n) (Nsucc m) (Nsucc l) p q = transitive-leqN n m l p q\n\ntransitive-leN : (n m l : ℕ) → (leN n m) → (leN m l) → (leN n l)\ntransitive-leN Nzero Nzero Nzero p q = p\ntransitive-leN Nzero Nzero (Nsucc l) p q = q\ntransitive-leN Nzero (Nsucc m) Nzero p q = ind-empty q\ntransitive-leN Nzero (Nsucc m) (Nsucc l) p q = star\ntransitive-leN (Nsucc n) Nzero l p q = ind-empty p\ntransitive-leN (Nsucc n) (Nsucc m) Nzero p q = ind-empty q\ntransitive-leN (Nsucc n) (Nsucc m) (Nsucc l) p q = transitive-leN n m l p q\n\nsucc-leN : (n : ℕ) → leN n (Nsucc n)\nsucc-leN Nzero = star\nsucc-leN (Nsucc n) = succ-leN n\n\n-- Exercise 3.7\n-- With the construction of the divisibility relation we open the door to basic number theory.\ndivides : (d n : ℕ) → U\ndivides d n = Σ ℕ (λ m → EqN (d ** m) n)\n\n-- Exercise 3.8\n-- In this exercise we were asked to construct observational equality on the booleans. This construction is analogous to, but simpler than, the construction of observational equality on the natural numbers.\nEq2 : bool → bool → U\nEq2 true true = unit\nEq2 true false = empty\nEq2 false true = empty\nEq2 false false = unit\n\nreflexive-Eq2 : (x : bool) → Eq2 x x\nreflexive-Eq2 true = star\nreflexive-Eq2 false = star\n\nleast-reflexive-Eq2 : {i : Level}\n (R : bool → bool → UU i) (ρ : (x : bool) → R x x)\n (x y : bool) → Eq2 x y → R x y\nleast-reflexive-Eq2 R ρ true true p = ρ true\nleast-reflexive-Eq2 R ρ true false p = ind-empty p\nleast-reflexive-Eq2 R ρ false true p = ind-empty p\nleast-reflexive-Eq2 R ρ false false p = ρ false\n\n-- Exercise 3.9\n-- In this exercise we were asked to show that 1 + 1 satisfies the induction principle of the booleans. In other words, type theory cannot distinguish the booleans from the type 1 + 1. We will see later that they are indeed equivalent types.\nt0 : coprod unit unit\nt0 = inl star\n\nt1 : coprod unit unit\nt1 = inr star\n\nind-coprod-unit-unit : {i : Level} {P : coprod unit unit → UU i} →\n P t0 → P t1 → (x : coprod unit unit) → P x\nind-coprod-unit-unit p0 p1 (inl star) = p0\nind-coprod-unit-unit p0 p1 (inr star) = p1\n\n-- Exercise 3.10\n-- In this exercise we were asked to define the relations ≤ and < on the integers. As a criterion of correctness, we were then also asked to show that the type of all integers l satisfying k ≤ l satisfy the induction principle of the natural numbers.\n-- It turns out that this is a long exercise that requires to develop intermediate properties of the relation ≤, involving long proofs. None of them is really hard, but they are probably unintelligible because induction on the integers splits into so many cases.\n\nleqZ : ℤ → ℤ → U\nleqZ (inl Nzero) (inl Nzero) = unit\nleqZ (inl Nzero) (inl (Nsucc x)) = empty\nleqZ (inl Nzero) (inr l) = unit\nleqZ (inl (Nsucc x)) (inl Nzero) = unit\nleqZ (inl (Nsucc x)) (inl (Nsucc y)) = leqZ (inl x) (inl y)\nleqZ (inl (Nsucc x)) (inr l) = unit\nleqZ (inr k) (inl x) = empty\nleqZ (inr (inl star)) (inr l) = unit\nleqZ (inr (inr x)) (inr (inl star)) = empty\nleqZ (inr (inr Nzero)) (inr (inr y)) = unit\nleqZ (inr (inr (Nsucc x))) (inr (inr Nzero)) = empty\nleqZ (inr (inr (Nsucc x))) (inr (inr (Nsucc y))) =\n leqZ (inr (inr (x))) (inr (inr (y)))\n\nreflexive-leqZ : (k : ℤ) → leqZ k k\nreflexive-leqZ (inl Nzero) = star\nreflexive-leqZ (inl (Nsucc x)) = reflexive-leqZ (inl x)\nreflexive-leqZ (inr (inl star)) = star\nreflexive-leqZ (inr (inr Nzero)) = star\nreflexive-leqZ (inr (inr (Nsucc x))) = reflexive-leqZ (inr (inr x))\n\ntransitive-leqZ : (k l m : ℤ) → leqZ k l → leqZ l m → leqZ k m\ntransitive-leqZ (inl Nzero) (inl Nzero) m p q = q\ntransitive-leqZ (inl Nzero) (inl (Nsucc x)) m p q = ind-empty p\ntransitive-leqZ (inl Nzero) (inr (inl star)) (inl Nzero) star q =\n reflexive-leqZ (inl Nzero)\ntransitive-leqZ (inl Nzero) (inr (inl star)) (inl (Nsucc x)) star q =\n ind-empty q\ntransitive-leqZ (inl Nzero) (inr (inl star)) (inr (inl star)) star q = star\ntransitive-leqZ (inl Nzero) (inr (inl star)) (inr (inr x)) star q = star\ntransitive-leqZ (inl Nzero) (inr (inr x)) (inl y) star q = ind-empty q\ntransitive-leqZ (inl Nzero) (inr (inr x)) (inr (inl star)) star q =\n ind-empty q\ntransitive-leqZ (inl Nzero) (inr (inr x)) (inr (inr y)) star q = star\ntransitive-leqZ (inl (Nsucc x)) (inl Nzero) (inl Nzero) star q = star\ntransitive-leqZ (inl (Nsucc x)) (inl Nzero) (inl (Nsucc y)) star q =\n ind-empty q\ntransitive-leqZ (inl (Nsucc x)) (inl Nzero) (inr m) star q = star\ntransitive-leqZ (inl (Nsucc x)) (inl (Nsucc y)) (inl Nzero) p q = star\ntransitive-leqZ (inl (Nsucc x)) (inl (Nsucc y)) (inl (Nsucc z)) p q =\n transitive-leqZ (inl x) (inl y) (inl z) p q\ntransitive-leqZ (inl (Nsucc x)) (inl (Nsucc y)) (inr m) p q = star\ntransitive-leqZ (inl (Nsucc x)) (inr y) (inl z) star q = ind-empty q\ntransitive-leqZ (inl (Nsucc x)) (inr y) (inr z) star q = star\ntransitive-leqZ (inr k) (inl x) m p q = ind-empty p\ntransitive-leqZ (inr (inl star)) (inr l) (inl x) star q = ind-empty q\ntransitive-leqZ (inr (inl star)) (inr l) (inr m) star q = star\ntransitive-leqZ (inr (inr x)) (inr (inl star)) m p q = ind-empty p\ntransitive-leqZ (inr (inr Nzero)) (inr (inr Nzero)) m p q = q\ntransitive-leqZ (inr (inr Nzero)) (inr (inr (Nsucc y))) (inl x) star q =\n ind-empty q\ntransitive-leqZ (inr (inr Nzero)) (inr (inr (Nsucc y))) (inr (inl star))\n star q =\n ind-empty q\ntransitive-leqZ (inr (inr Nzero)) (inr (inr (Nsucc y))) (inr (inr z))\n star q = star\ntransitive-leqZ (inr (inr (Nsucc x))) (inr (inr Nzero)) m p q = ind-empty p\ntransitive-leqZ (inr (inr (Nsucc x))) (inr (inr (Nsucc y))) (inl z) p q =\n ind-empty q\ntransitive-leqZ (inr (inr (Nsucc x))) (inr (inr (Nsucc y)))\n (inr (inl star)) p q = ind-empty q\ntransitive-leqZ (inr (inr (Nsucc x))) (inr (inr (Nsucc y)))\n (inr (inr Nzero)) p q = ind-empty q\ntransitive-leqZ (inr (inr (Nsucc x))) (inr (inr (Nsucc y)))\n (inr (inr (Nsucc z))) p q =\n transitive-leqZ (inr (inr x)) (inr (inr y)) (inr (inr z)) p q\n\nsucc-leqZ : (k : ℤ) → leqZ k (Zsucc k)\nsucc-leqZ (inl Nzero) = star\nsucc-leqZ (inl (Nsucc Nzero)) = star\nsucc-leqZ (inl (Nsucc (Nsucc x))) = succ-leqZ (inl (Nsucc x))\nsucc-leqZ (inr (inl star)) = star\nsucc-leqZ (inr (inr Nzero)) = star\nsucc-leqZ (inr (inr (Nsucc x))) = succ-leqZ (inr (inr x))\n\nleqZ-succ-leqZ : (k l : ℤ) → leqZ k l → leqZ k (Zsucc l)\nleqZ-succ-leqZ k l p = transitive-leqZ k l (Zsucc l) p (succ-leqZ l)\n\nleZ : ℤ → ℤ → U\nleZ (inl Nzero) (inl x) = empty\nleZ (inl Nzero) (inr y) = unit\nleZ (inl (Nsucc x)) (inl Nzero) = unit\nleZ (inl (Nsucc x)) (inl (Nsucc y)) = leZ (inl x) (inl y)\nleZ (inl (Nsucc x)) (inr y) = unit\nleZ (inr x) (inl y) = empty\nleZ (inr (inl star)) (inr (inl star)) = empty\nleZ (inr (inl star)) (inr (inr x)) = unit\nleZ (inr (inr x)) (inr (inl star)) = empty\nleZ (inr (inr Nzero)) (inr (inr Nzero)) = empty\nleZ (inr (inr Nzero)) (inr (inr (Nsucc y))) = unit\nleZ (inr (inr (Nsucc x))) (inr (inr Nzero)) = empty\nleZ (inr (inr (Nsucc x))) (inr (inr (Nsucc y))) =\n leZ (inr (inr x)) (inr (inr y))\n\nfam-shift-leqZ : (k : ℤ) {i : Level} (P : (l : ℤ) → leqZ k l → UU i) → (l : ℤ) → (leqZ (Zsucc k) l) → UU i\nfam-shift-leqZ k P l p = P l (transitive-leqZ k (Zsucc k) l (succ-leqZ k) p)\n\n-- ind-Z-leqZ : (k : ℤ) {i : Level} (P : (l : ℤ) → (leqZ k l) → UU i) →\n-- P k (reflexive-leqZ k) →\n-- ((l : ℤ) (p : leqZ k l) → P l p → P (Zsucc l) (leqZ-succ-leqZ k l p)) →\n-- (l : ℤ) (p : leqZ k l) → P l p\n-- ind-Z-leqZ (inl Nzero) P pk pS (inl Nzero) star = pk\n-- ind-Z-leqZ (inl Nzero) P pk pS (inl (Nsucc x)) ()\n-- ind-Z-leqZ (inl Nzero) P pk pS (inr (inl star)) star = pS (inl Nzero) star pk\n-- ind-Z-leqZ (inl Nzero) P pk pS (inr (inr Nzero)) star = pS (inr (inl star)) star (pS (inl Nzero) star pk)\n-- ind-Z-leqZ (inl Nzero) P pk pS (inr (inr (Nsucc x))) star = pS (inr (inr x)) star (ind-Z-leqZ (inl Nzero) P pk pS (inr (inr x)) star)\n-- ind-Z-leqZ (inl (Nsucc Nzero)) {i} P pk pS (inl Nzero) star = pS {!!} {!!} {!!}\n-- ind-Z-leqZ (inl (Nsucc (Nsucc x))) {i} P pk pS (inl Nzero) star = {!!}\n-- ind-Z-leqZ (inl (Nsucc x)) P pk pS (inl (Nsucc y)) p = {!!}\n-- ind-Z-leqZ (inl (Nsucc x)) P pk pS (inr y) p = {!!}\n-- ind-Z-leqZ (inr k) P pk pS l p = {!!}\n\n-- Exercise 3.11\nZpred : ℤ → ℤ\nZpred (inl x) = inl (Nsucc x)\nZpred (inr (inl star)) = inl Nzero\nZpred (inr (inr Nzero)) = inr (inl star)\nZpred (inr (inr (Nsucc x))) = inr (inr x)\n\n-- Exercise 3.12\nZadd : ℤ → ℤ → ℤ\nZadd (inl Nzero) l = Zpred l\nZadd (inl (Nsucc x)) l = Zpred (Zadd (inl x) l)\nZadd (inr (inl star)) l = l\nZadd (inr (inr Nzero)) l = Zsucc l\nZadd (inr (inr (Nsucc x))) l = Zsucc (Zadd (inr (inr x)) l)\n\nZneg : ℤ → ℤ\nZneg (inl x) = inr (inr x)\nZneg (inr (inl star)) = inr (inl star)\nZneg (inr (inr x)) = inl x\n", "meta": {"hexsha": "a16826f44c06bdf7148fe15178743ab2af5034eb", "size": 15789, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Lecture3.agda", "max_stars_repo_name": "glangmead/hott_cmu80818", "max_stars_repo_head_hexsha": "af64d808630f4f1498a75201b6ca4d74d662516b", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2018-05-03T20:32:19.000Z", "max_stars_repo_stars_event_max_datetime": "2018-09-04T02:52:25.000Z", "max_issues_repo_path": "Lecture3.agda", "max_issues_repo_name": "glangmead/hott_cmu80818", "max_issues_repo_head_hexsha": "af64d808630f4f1498a75201b6ca4d74d662516b", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2018-02-22T21:01:16.000Z", "max_issues_repo_issues_event_max_datetime": "2018-03-25T14:44:31.000Z", "max_forks_repo_path": "Lecture3.agda", "max_forks_repo_name": "glangmead/hott_cmu80818", "max_forks_repo_head_hexsha": "af64d808630f4f1498a75201b6ca4d74d662516b", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2018-02-22T19:58:46.000Z", "max_forks_repo_forks_event_max_datetime": "2018-06-25T15:05:21.000Z", "avg_line_length": 38.322815534, "max_line_length": 309, "alphanum_fraction": 0.6227120147, "num_tokens": 6597, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8976952948443462, "lm_q2_score": 0.8459424411924673, "lm_q1q2_score": 0.759398549167618}} {"text": "module L.Base.Nat.Properties where\n\nopen import L.Base.Nat\nopen import L.Base.Id.Core\nopen import L.Base.Id.Properties using (ap;sym;transport)\n\n-- Properties of +\n+-idl : ∀{x} → zero + x ≡ x\n+-idl = refl\n\n+-idr : ∀{x} → x + zero ≡ x\n+-idr {x} = ind (λ n → n + zero ≡ n) refl (λ _ p → ap succ p) x\n\n+-assoc : {x y z : Nat} → (x + y) + z ≡ x + (y + z)\n+-assoc {x}{y}{z} = ind (λ n → (n + y) + z ≡ n + (y + z))\n refl (λ _ p → ap succ p) x\n\n+-succ : {x y : Nat} → x + succ y ≡ succ (x + y)\n+-succ {x}{y} = ind (λ n → n + succ y ≡ succ (n + y)) refl (λ _ p → ap succ p) x\n\n+-comm : {x y : Nat} → x + y ≡ y + x\n+-comm {x}{y} = ind (λ n → n + y ≡ y + n) (sym +-idr) (λ n p → sym\n (transport (λ q → y + succ n ≡ succ q) (sym p) +-succ)) x\n\n-- Properties of *\n*-zl : ∀{x} → zero * x ≡ zero\n*-zl = refl\n\n*-zr : ∀{x} → x * zero ≡ zero\n*-zr {x} = ind (λ n → n * zero ≡ zero) refl (λ _ p → p) x\n\n*-idl : ∀{x} → 1 * x ≡ x\n*-idl = +-idr\n\n*-idr : ∀{x} → x * 1 ≡ x\n*-idr {x} = ind (λ n → n * 1 ≡ n) refl (λ _ p → ap succ p) x\n\n*-distrib-+ : {x y z : Nat} → (x + y) * z ≡ x * z + y * z\n*-distrib-+ {x}{y}{z} = ind (λ n → (n + y) * z ≡ n * z + y * z) refl\n (λ m p → transport (λ s → z + (m + y) * z ≡ s)\n (sym (+-assoc {z} {m * z} {y * z}))\n (ap (λ k → z + k) p)) x\n\n*-assoc : {x y z : Nat} → (x * y) * z ≡ x * (y * z)\n*-assoc {x}{y}{z} = ind (λ n → (n * y) * z ≡ n * (y * z)) refl (λ n p\n → transport (λ q → (y + n * y) * z ≡ y * z + q) p\n (*-distrib-+ {y}{n * y})) x\n", "meta": {"hexsha": "f63c90931e2caaead9c9381f9393af09cd01f4ea", "size": 1582, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/L/Base/Nat/Properties.agda", "max_stars_repo_name": "borszag/smallib", "max_stars_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/L/Base/Nat/Properties.agda", "max_issues_repo_name": "borszag/smallib", "max_issues_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 10, "max_issues_repo_issues_event_min_datetime": "2020-10-19T10:13:16.000Z", "max_issues_repo_issues_event_max_datetime": "2020-11-09T16:40:39.000Z", "max_forks_repo_path": "src/L/Base/Nat/Properties.agda", "max_forks_repo_name": "borszag/smallib", "max_forks_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.9583333333, "max_line_length": 80, "alphanum_fraction": 0.4032869785, "num_tokens": 689, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9136765234137297, "lm_q2_score": 0.831143054132195, "lm_q1q2_score": 0.7593958961589733}} {"text": "module plfa.part1.Negation where\n\nopen import Relation.Binary.PropositionalEquality using (_≡_; refl)\nopen import Data.Nat using (ℕ; zero; suc; _<_)\nopen import Data.Empty using (⊥; ⊥-elim)\nopen import Data.Sum using (_⊎_; inj₁; inj₂)\nopen import Data.Product using (_×_; _,_)\nopen import plfa.part1.Isomorphism using (_≃_; extensionality)\n\n¬_ : Set → Set\n¬ A = A → ⊥\n\n¬-elim : ∀ {A : Set}\n → ¬ A\n → A\n ---\n → ⊥\n¬-elim ¬x x = ¬x x\n\ninfix 3 ¬_\n\n¬¬-intro : ∀ {A : Set}\n → A\n -----\n → ¬ ¬ A\n¬¬-intro x = λ{¬x → ¬x x}\n\n¬¬¬-elim : ∀ {A : Set}\n → ¬ ¬ ¬ A\n -------\n → ¬ A\n¬¬¬-elim ¬¬¬x = λ x → ¬¬¬x (¬¬-intro x)\n\ncontraposition : ∀ {A B : Set}\n → (A → B)\n -----------\n → (¬ B → ¬ A)\ncontraposition f ¬y x = ¬y (f x)\n\n_≢_ : ∀ {A : Set} → A → A → Set\nx ≢ y = ¬ (x ≡ y)\n\n_ : 1 ≢ 2\n_ = λ()\n\npeano : ∀ {m : ℕ} → zero ≢ suc m\npeano = λ()\n\nid : ⊥ → ⊥\nid x = x\n\nid′ : ⊥ → ⊥\nid′ ()\n\nassimilation : ∀ {A : Set} (¬x ¬x′ : ¬ A) → ¬x ≡ ¬x′\nassimilation ¬x ¬x′ = extensionality (λ x → ⊥-elim (¬x x))\n\nassimilation' : ∀ {A : Set} {¬x ¬x′ : ¬ A} → ¬x ≡ ¬x′\nassimilation' {A} {¬x} {¬x′} = assimilation ¬x ¬x′\n\n<-irreflexive : ∀ {n : ℕ} → ¬ (n < n)\n<-irreflexive (Data.Nat.s≤s x) = <-irreflexive x\n\n⊎-dual-× : ∀ {A B : Set} → ¬ (A ⊎ B) ≃ (¬ A) × (¬ B)\n⊎-dual-× = record {\n to = λ {x → (λ z → x (inj₁ z)) , λ x₁ → x (inj₂ x₁) };\n from = λ { (fst , snd) (inj₁ x) → fst x ;\n (fst , snd) (inj₂ y) → snd y} ;\n from∘to = λ {¬x → assimilation'} ;\n to∘from = λ { (fst , snd) → refl} }\n", "meta": {"hexsha": "11f5d783179f1fd080a93d90e86bfec476ead14c", "size": 1575, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "plfa/part1/Negation.agda", "max_stars_repo_name": "UnsoundWitch/proofs", "max_stars_repo_head_hexsha": "275ecc582b3a6a1da1af387251c6b4d74d9a5203", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2021-01-03T03:29:40.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-18T10:58:03.000Z", "max_issues_repo_path": "plfa/part1/Negation.agda", "max_issues_repo_name": "sym-cereal/proofs", "max_issues_repo_head_hexsha": "275ecc582b3a6a1da1af387251c6b4d74d9a5203", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "plfa/part1/Negation.agda", "max_forks_repo_name": "sym-cereal/proofs", "max_forks_repo_head_hexsha": "275ecc582b3a6a1da1af387251c6b4d74d9a5203", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.1830985915, "max_line_length": 72, "alphanum_fraction": 0.4457142857, "num_tokens": 682, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9111797100118214, "lm_q2_score": 0.8333245891029456, "lm_q1q2_score": 0.7593084574445422}} {"text": "module 110-natural-model where\n\nopen import 010-false-true\nopen import 020-equivalence\nopen import 100-natural\n\n-- We prove that there is a model of the naturals within Agda's lambda\n-- calculus. This also shows that the Peano axioms are consistent.\n\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ -> ℕ\n\nthm-ℕ-is-natural : Natural zero suc _≡_\nthm-ℕ-is-natural = record {\n equiv = thm-≡-is-equivalence;\n sucn!=zero = sucn!=zero;\n sucinjective = sucinjective;\n cong = cong;\n induction = induction\n }\n where\n sucn!=zero : ∀ {r} -> suc r ≡ zero -> False\n sucn!=zero ()\n sucinjective : ∀ {r s} -> suc r ≡ suc s -> r ≡ s\n sucinjective refl = refl\n cong : ∀ {r s} -> r ≡ s -> suc r ≡ suc s\n cong refl = refl\n\n -- This is the only tricky bit: proving the principle of induction.\n induction : (p : ℕ -> Set) -> p zero -> (∀ n -> p n -> p (suc n)) -> ∀ n -> p n\n -- We first prove that p n holds for n equal to zero. This is just\n -- the base case.\n induction p base hypothesis zero = base\n -- Then we prove that p (suc n) holds, using induction on n, that is,\n -- we may assume that p n is proven, or more precisely, that\n -- \"induction p base hypothesis n\" is a proof of p n.\n induction p base hypothesis (suc n) =\n hypothesis n (induction p base hypothesis n)\n", "meta": {"hexsha": "e524375942c9c7a1700dfd574c911c429137b6e3", "size": 1304, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "110-natural-model.agda", "max_stars_repo_name": "mcmtroffaes/agda-proofs", "max_stars_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2015-08-09T22:51:55.000Z", "max_stars_repo_stars_event_max_datetime": "2016-08-17T16:15:42.000Z", "max_issues_repo_path": "110-natural-model.agda", "max_issues_repo_name": "mcmtroffaes/agda-proofs", "max_issues_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "110-natural-model.agda", "max_forks_repo_name": "mcmtroffaes/agda-proofs", "max_forks_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.6, "max_line_length": 83, "alphanum_fraction": 0.6357361963, "num_tokens": 401, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9416541544761566, "lm_q2_score": 0.8056321889812553, "lm_q1q2_score": 0.7586268977339192}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import Sets.EquivalenceRelations\nopen import Setoids.Setoids\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_)\nopen import Groups.Definition\n\nmodule Groups.Homomorphisms.Definition where\n\nrecord GroupHom {m n o p : _} {A : Set m} {S : Setoid {m} {o} A} {_·A_ : A → A → A} {B : Set n} {T : Setoid {n} {p} B} {_·B_ : B → B → B} (G : Group S _·A_) (H : Group T _·B_) (f : A → B) : Set (m ⊔ n ⊔ o ⊔ p) where\n open Group H\n open Setoid T\n field\n groupHom : {x y : A} → f (x ·A y) ∼ (f x) ·B (f y)\n wellDefined : {x y : A} → Setoid._∼_ S x y → f x ∼ f y\n groupHom' : {x y : A} → (f x) ·B (f y) ∼ f (x ·A y)\n groupHom' = Equivalence.symmetric eq groupHom\n\nrecord InjectiveGroupHom {m n o p : _} {A : Set m} {S : Setoid {m} {o} A} {_·A_ : A → A → A} {B : Set n} {T : Setoid {n} {p} B} {_·B_ : B → B → B} {G : Group S _·A_} {H : Group T _·B_} {underf : A → B} (f : GroupHom G H underf) : Set (m ⊔ n ⊔ o ⊔ p) where\n open Setoid S renaming (_∼_ to _∼A_)\n open Setoid T renaming (_∼_ to _∼B_)\n field\n injective : SetoidInjection S T underf\n", "meta": {"hexsha": "f9080768704877a2f3278a1a94be862e04d2e952", "size": 1111, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Groups/Homomorphisms/Definition.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Groups/Homomorphisms/Definition.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Groups/Homomorphisms/Definition.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 46.2916666667, "max_line_length": 255, "alphanum_fraction": 0.5796579658, "num_tokens": 466, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9304582554941718, "lm_q2_score": 0.8152324915965392, "lm_q1q2_score": 0.758539801953083}} {"text": "{-\n\n Types Summer School 2007\n\n Bertinoro\n Aug 19 - 31, 2007\n\n\n Agda\n\n Ulf Norell\n\n-}\n\n-- Records are labeled sigma types.\n\nmodule Records where\n\nopen import Nat\nopen import Bool\n\n{-\n\n A very simple record.\n\n-}\n\nrecord Point : Set where\n field\n x : Nat\n y : Nat\n\n-- A record can be seen as a one constructor datatype. In this case:\ndata Point' : Set where\n mkPoint : (x : Nat)(y : Nat) -> Point'\n\n-- There are a few differences, though:\n\n-- To construct a record you use the syntax record { ..; x = e; .. }\norigin : Point\norigin = record { x = 0; y = 0 }\n\n-- instead of\norigin' : Point'\norigin' = mkPoint 0 0\n\n-- What's more interesting is that you get projection functions\n-- for free when you declare a record. More precisely, you get a module\n-- parameterised over a record, containing functions corresponding to the\n-- fields. In the Point example you get:\n{-\n module Point (p : Point) where\n x : Nat\n y : Nat\n-}\n\n-- So Point.x : Point -> Nat is the projection function for the field x.\ngetX : Point -> Nat\ngetX = Point.x\n\n-- A nifty thing with having the projection functions in a module is that\n-- you can apply the module to a record value, in effect opening the record.\nsum : Point -> Nat\nsum p = x + y\n where\n open module Pp = Point p\n\n-- The final difference between records and datatypes is that we have\n-- η-equality on records.\n\ndata _==_ {A : Set}(x : A) : A -> Set where\n refl : x == x\n\nη-Point : (p : Point) -> p == record { x = Point.x p; y = Point.y p }\nη-Point p = refl\n\n{-\n\n The empty record\n\n-}\n\n-- One interesting benefit of this is that we get a unit type with\n-- η-equality.\nrecord True : Set where\n\ntt : True\ntt = record{}\n\n-- Now, since any element of True is equal to tt, metavariables of\n-- type True will simply disappear. The following cute example exploits\n-- this:\n\ndata False : Set where\n\nNonZero : Nat -> Set\nNonZero zero = False\nNonZero (suc _) = True\n\n-- We make the proof that m is non-zero implicit.\n\n_/_ : (n m : Nat){p : NonZero m} -> Nat\n(n / zero) {}\nzero / suc m = zero\nsuc n / suc m = div (suc n) (suc m) m\n where\n div : Nat -> Nat -> Nat -> Nat\n div zero zero c = suc zero\n div zero (suc y) c = zero\n div (suc x) zero c = suc (div x c c)\n div (suc x) (suc y) c = div x y c\n\n-- Now, as long as we're dividing by things which are obviously\n-- NonZero we can completely ignore the proof.\n\nfive = 17 / 3\n\n{-\n\n A dependent record\n\n-}\n\n-- Of course, records can be dependent, and have parameters.\nrecord ∃ {A : Set}(P : A -> Set) : Set where\n field\n witness : A\n proof : P witness\n", "meta": {"hexsha": "1dda8aab2e493903d2c933061c4328d63f7f9156", "size": 2653, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/SummerSchool07/Lecture/Records.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/SummerSchool07/Lecture/Records.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/SummerSchool07/Lecture/Records.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 20.5658914729, "max_line_length": 76, "alphanum_fraction": 0.6268375424, "num_tokens": 771, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9173026595857203, "lm_q2_score": 0.8267117940706734, "lm_q1q2_score": 0.7583449274119111}} {"text": "open import Relation.Binary.Core\n\nmodule TreeSort.Impl1.Correctness.Order {A : Set}\n (_≤_ : A → A → Set)\n (tot≤ : Total _≤_) \n (trans≤ : Transitive _≤_) where\n\nopen import BSTree _≤_\nopen import BSTree.Properties _≤_ trans≤\nopen import BTree {A}\nopen import Data.List\nopen import Data.Sum\nopen import Function using (_∘_)\nopen import List.Sorted _≤_\nopen import TreeSort.Impl1 _≤_ tot≤\n\nlemma-insert-*⊴ : {x y : A}{t : BTree} → x ≤ y → t *⊴ y → insert x t *⊴ y\nlemma-insert-*⊴ x≤y lelf = lend x≤y lelf\nlemma-insert-*⊴ {x = x}{t = node z l r} x≤y (lend z≤y r≤y) \n with tot≤ x z\n... | inj₁ x≤z = lend z≤y r≤y\n... | inj₂ z≤x = lend z≤y (lemma-insert-*⊴ x≤y r≤y) \n\nlemma-insert-⊴* : {x y : A}{t : BTree} → y ≤ x → y ⊴* t → y ⊴* insert x t\nlemma-insert-⊴* y≤x gelf = gend y≤x gelf\nlemma-insert-⊴* {x = x} {t = node z l r} y≤x (gend y≤z y≤l) \n with tot≤ x z\n... | inj₁ x≤z = gend y≤z (lemma-insert-⊴* y≤x y≤l)\n... | inj₂ z≤x = gend y≤z y≤l\n\nlemma-insert-bst : {t : BTree}(x : A) → BSTree t → BSTree (insert x t)\nlemma-insert-bst x slf = snd slf slf lelf gelf\nlemma-insert-bst x (snd {x = y} sl sr l≤y y≤r) \n with tot≤ x y\n... | inj₁ x≤y = snd (lemma-insert-bst x sl) sr (lemma-insert-*⊴ x≤y l≤y) y≤r\n... | inj₂ y≤x = snd sl (lemma-insert-bst x sr) l≤y (lemma-insert-⊴* y≤x y≤r)\n\nlemma-treeSort-bst : (xs : List A) → BSTree (treeSort xs)\nlemma-treeSort-bst [] = slf\nlemma-treeSort-bst (x ∷ xs) = lemma-insert-bst x (lemma-treeSort-bst xs)\n\ntheorem-treeSort-sorted : (xs : List A) → Sorted (flatten (treeSort xs))\ntheorem-treeSort-sorted = lemma-bst-sorted ∘ lemma-treeSort-bst \n\n\n\n\n", "meta": {"hexsha": "fa5ac1f31386d9ea159bf9f8a52e86e71f9f4895", "size": 1637, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/TreeSort/Impl1/Correctness/Order.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/TreeSort/Impl1/Correctness/Order.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/TreeSort/Impl1/Correctness/Order.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.1041666667, "max_line_length": 77, "alphanum_fraction": 0.5998778253, "num_tokens": 693, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9441768557238084, "lm_q2_score": 0.8031737963569014, "lm_q1q2_score": 0.7583381096440136}} {"text": "\nmodule Isomorphism where\n\n import Sets\n open Sets\n\n infix 20 _≅_\n\n data _≅_ (A B : Set) : Set where\n iso : (i : A -> B)(j : B -> A) ->\n\t (forall x -> j (i x) == x) ->\n\t (forall y -> i (j y) == y) ->\n\t A ≅ B\n\n refl-≅ : (A : Set) -> A ≅ A\n refl-≅ A = iso id id (\\x -> refl) (\\x -> refl)\n\n iso[×] : {A₁ A₂ B₁ B₂ : Set} -> A₁ ≅ A₂ -> B₁ ≅ B₂ -> A₁ [×] B₁ ≅ A₂ [×] B₂\n iso[×] (iso a₁₂ a₂₁ p₁₁ p₂₂) (iso b₁₂ b₂₁ q₁₁ q₂₂) =\n iso ab₁₂ ab₂₁ pq₁₁ pq₂₂ where\n\n ab₁₂ = a₁₂ <×> b₁₂\n ab₂₁ = a₂₁ <×> b₂₁\n\n pq₂₂ : (z : _ [×] _) -> ab₁₂ (ab₂₁ z) == z\n pq₂₂ < x , y > =\n subst (\\ ∙ -> < ∙ , b₁₂ (b₂₁ y) > == < x , y >) (p₂₂ x)\n $ cong < x ,∙> (q₂₂ y)\n\n pq₁₁ : (z : _ [×] _) -> ab₂₁ (ab₁₂ z) == z\n pq₁₁ < x , y > =\n subst (\\ ∙ -> < ∙ , b₂₁ (b₁₂ y) > == < x , y >) (p₁₁ x)\n $ cong < x ,∙> (q₁₁ y)\n\n iso[+] : {A₁ A₂ B₁ B₂ : Set} -> A₁ ≅ A₂ -> B₁ ≅ B₂ -> A₁ [+] B₁ ≅ A₂ [+] B₂\n iso[+] (iso a₁₂ a₂₁ p₁₁ p₂₂) (iso b₁₂ b₂₁ q₁₁ q₂₂) =\n iso ab₁₂ ab₂₁ pq₁₁ pq₂₂ where\n\n ab₁₂ = a₁₂ <+> b₁₂\n ab₂₁ = a₂₁ <+> b₂₁\n\n pq₂₂ : (z : _ [+] _) -> ab₁₂ (ab₂₁ z) == z\n pq₂₂ (inl x) = cong inl (p₂₂ x)\n pq₂₂ (inr y) = cong inr (q₂₂ y)\n\n pq₁₁ : (z : _ [+] _) -> ab₂₁ (ab₁₂ z) == z\n pq₁₁ (inl x) = cong inl (p₁₁ x)\n pq₁₁ (inr y) = cong inr (q₁₁ y)\n\n", "meta": {"hexsha": "91f9fecdf1f6af52dba068e8d287c9e0f622381c", "size": 1289, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/clowns/Isomorphism.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/outdated-and-incorrect/clowns/Isomorphism.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/outdated-and-incorrect/clowns/Isomorphism.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 25.78, "max_line_length": 77, "alphanum_fraction": 0.4321179209, "num_tokens": 679, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9441768620069627, "lm_q2_score": 0.8031737892899222, "lm_q1q2_score": 0.7583381080180003}} {"text": "open import Nat\nopen import Prelude\nopen import core\nopen import contexts\n\nmodule htype-decidable where\n lemma-l : ∀{t1 t2 t4} → t1 ==> t2 == t1 ==> t4 → t2 == t4\n lemma-l refl = refl\n\n lemma-r : ∀{t1 t2 t3} → t1 ==> t2 == t3 ==> t2 → t1 == t3\n lemma-r refl = refl\n\n lemma-b : ∀{t1 t2 t3 t4} → t1 ==> t2 == t3 ==> t4 → t1 == t3\n lemma-b refl = refl\n\n htype-dec : (t1 t2 : htyp) → t1 == t2 + (t1 == t2 → ⊥)\n htype-dec b b = Inl refl\n htype-dec b ⦇-⦈ = Inr (λ ())\n htype-dec b (t2 ==> t3) = Inr (λ ())\n htype-dec ⦇-⦈ b = Inr (λ ())\n htype-dec ⦇-⦈ ⦇-⦈ = Inl refl\n htype-dec ⦇-⦈ (t2 ==> t3) = Inr (λ ())\n htype-dec (t1 ==> t2) b = Inr (λ ())\n htype-dec (t1 ==> t2) ⦇-⦈ = Inr (λ ())\n htype-dec (t1 ==> t2) (t3 ==> t4) with htype-dec t1 t3 | htype-dec t2 t4\n htype-dec (t1 ==> t2) (.t1 ==> .t2) | Inl refl | Inl refl = Inl refl\n htype-dec (t1 ==> t2) (.t1 ==> t4) | Inl refl | Inr x₁ = Inr (λ x → x₁ (lemma-l x))\n htype-dec (t1 ==> t2) (t3 ==> .t2) | Inr x | Inl refl = Inr (λ x₁ → x (lemma-r x₁))\n htype-dec (t1 ==> t2) (t3 ==> t4) | Inr x | Inr x₁ = Inr (λ x₂ → x (lemma-b x₂))\n\n -- if an arrow is disequal, it disagrees in the first or second argument\n ne-factor : ∀{τ1 τ2 τ3 τ4} → (τ1 ==> τ2) ≠ (τ3 ==> τ4) → (τ1 ≠ τ3) + (τ2 ≠ τ4)\n ne-factor {τ1} {τ2} {τ3} {τ4} ne with htype-dec τ1 τ3 | htype-dec τ2 τ4\n ne-factor ne | Inl refl | Inl refl = Inl (λ x → ne refl)\n ne-factor ne | Inl x | Inr x₁ = Inr x₁\n ne-factor ne | Inr x | Inl x₁ = Inl x\n ne-factor ne | Inr x | Inr x₁ = Inl x\n", "meta": {"hexsha": "374ea88a99c03ac8ec0e809a3bf10ea11051f33a", "size": 1519, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "htype-decidable.agda", "max_stars_repo_name": "hazelgrove/hazelnut-dynamics-agda", "max_stars_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 16, "max_stars_repo_stars_event_min_datetime": "2018-03-12T14:32:03.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-19T02:50:23.000Z", "max_issues_repo_path": "htype-decidable.agda", "max_issues_repo_name": "hazelgrove/hazelnut-dynamics-agda", "max_issues_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 54, "max_issues_repo_issues_event_min_datetime": "2017-06-29T20:53:34.000Z", "max_issues_repo_issues_event_max_datetime": "2018-11-29T16:32:40.000Z", "max_forks_repo_path": "htype-decidable.agda", "max_forks_repo_name": "hazelgrove/hazelnut-dynamics-agda", "max_forks_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-09-13T18:20:02.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-13T18:20:02.000Z", "avg_line_length": 39.9736842105, "max_line_length": 89, "alphanum_fraction": 0.5233706386, "num_tokens": 724, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9353465098415279, "lm_q2_score": 0.8104789178257654, "lm_q1q2_score": 0.7580786270884682}} {"text": "module fizzbuzz where\n\nimport Data.Nat as N\nimport Data.Nat.DivMod as N\nimport Data.Nat.Show as N\nimport Data.Bool as B\nimport Data.Fin as F\nimport Data.Unit as U\nimport Data.String as S\nopen import Data.Product using (_,_ ; _×_)\nopen import IO\nopen import Agda.Builtin.Coinduction\nopen import Relation.Nullary\nopen import Function\n\ncongruent : N.ℕ → N.ℕ → B.Bool\ncongruent n N.zero = B.false\ncongruent n (N.suc m) with N._≟_ 0 $ F.toℕ (N._mod_ n (N.suc m) {U.tt})\n... | yes _ = B.true\n... | no _ = B.false\n\n_and_ : {A B : Set} → A → B → A × B\n_and_ = _,_\n\nfizzbuzz : N.ℕ → S.String\nfizzbuzz N.zero = \"fizzbuzz\"\nfizzbuzz n with congruent n 3 and congruent n 5\n... | B.true , B.true = \"fizzbuzz\"\n... | B.true , B.false = \"fizz\"\n... | B.false , B.true = \"buzz\"\n... | B.false , B.false = N.show n\n\nworker : N.ℕ → IO U.⊤\nworker N.zero = putStrLn $ fizzbuzz N.zero\nworker (N.suc n) = ♯ worker n >> ♯ putStrLn (fizzbuzz $ N.suc n)\n\nmain = run $ worker 100\n", "meta": {"hexsha": "d9a2ef9b0ec1a4ac525875d3af47aef3d038b69e", "size": 1000, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/examples-that-run/fizzbuzz/src-agda/fizzbuzz.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/examples-that-run/fizzbuzz/src-agda/fizzbuzz.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/examples-that-run/fizzbuzz/src-agda/fizzbuzz.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 26.3157894737, "max_line_length": 71, "alphanum_fraction": 0.623, "num_tokens": 357, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9585377261041521, "lm_q2_score": 0.7905303260722198, "lm_q1q2_score": 0.7577531411696395}} {"text": "{-# OPTIONS --copatterns #-}\n\nmodule LecStr where\n\nopen import CS410-Prelude\nopen import CS410-Nat\nopen import CS410-Functor\n\nrecord Stream (X : Set) : Set where\n coinductive\n field\n head : X\n tail : Stream X\nopen Stream\n\ncount : Nat -> Stream Nat\nhead (count n) = n\ntail (count n) = count (suc n)\n\nnats : Stream Nat\nnats = count zero\n\npoke : Nat\npoke = head (tail (tail (tail nats)))\n\nrepeat : {X : Set} -> X -> Stream X\nhead (repeat x) = x\ntail (repeat x) = repeat x\n\nstrApp : {S T : Set} -> Stream (S -> T) -> Stream S -> Stream T\nhead (strApp fs ss) = (head fs) (head ss)\ntail (strApp fs ss) = strApp (tail fs) (tail ss)\n\nstrMap : {S T : Set} -> (S -> T) -> Stream S -> Stream T\nstrMap f ss = strApp (repeat f) ss\n\ndiagonal : {X : Set} -> Stream (Stream X) -> Stream X\nhead (diagonal xss) = head (head xss)\ntail (diagonal xss) = diagonal (strMap tail (tail xss))\n\n{- productivity checker rejects\nfibo : Stream Nat\nhead fibo = 1\nhead (tail fibo) = 1\ntail (tail fibo) = strApp (strApp (repeat _+N_) (tail fibo)) fibo\n-}\n\ndata CoList' (X : Set) : Set\nrecord CoList (X : Set) : Set where\n coinductive\n constructor thunk\n field\n force : CoList' X\ndata CoList' X where\n [] : CoList' X\n _::_ : X -> CoList X -> CoList' X\n\nmodule CoListExamples where\n open CoList\n\n short : CoList Nat\n short = thunk (0 :: thunk (1 :: thunk (2 :: thunk [])))\n\n long : forall {X} -> Stream X -> CoList X\n force (long s) = head s :: long (tail s)\n\n _++_ : forall {X} -> CoList X -> CoList X -> CoList X\n force (xs ++ ys) with force xs\n force (xs ++ ys) | [] = force ys\n force (xs ++ ys) | x :: xs' = x :: (xs' ++ ys)\n\n{-\n concat : forall {X} -> CoList (CoList X) -> CoList X\n force (concat xss) with force xss\n force (concat xss) | [] = []\n force (concat xss) | xs :: xss' with force xs\n force (concat xss) | xs :: xss' | [] = ? -- oops force (concat xss')\n force (concat xss) | xs :: xss' | x :: xs' = x :: concat (thunk (xs' :: xss'))\n-}\n\n-- nonempty CoLists\n-- tails for Streams\n-- \" n.e. CoLists\n", "meta": {"hexsha": "ce3a7d1a3832d31d167c2b72cf5584437ecec8ee", "size": 2008, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "LecStr.agda", "max_stars_repo_name": "clarkdm/CS410", "max_stars_repo_head_hexsha": "523a8749f49c914bcd28402116dcbe79a78dbbf4", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "LecStr.agda", "max_issues_repo_name": "clarkdm/CS410", "max_issues_repo_head_hexsha": "523a8749f49c914bcd28402116dcbe79a78dbbf4", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "LecStr.agda", "max_forks_repo_name": "clarkdm/CS410", "max_forks_repo_head_hexsha": "523a8749f49c914bcd28402116dcbe79a78dbbf4", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.9047619048, "max_line_length": 80, "alphanum_fraction": 0.6035856574, "num_tokens": 699, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8872045937171068, "lm_q2_score": 0.8539127529517043, "lm_q1q2_score": 0.757595317052373}} {"text": "------------------------------------------------------------------------------\n-- Proving that two group theory formalisations are equivalents\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\n-- We prove that group theory axioms based on the signature (G, ·, ε,)\n-- (see for example [p. 39, 1]), i.e.\n\n-- ∀ a b c. abc = a(bc)\n\n-- ∀ a. εa = aε = a\n\n-- ∀ a. ∃ a'. a'a = aa' = ε\n\n-- are equivalents to the axioms based on the signature (G, ·, _⁻¹, ε,)\n-- (see for example [2,3]), i.e.\n\n-- ∀ a b c. abc = a(bc)\n\n-- ∀ a. εa = aε = a\n\n-- ∀ a. a⁻¹a = aa⁻¹ = ε\n\n-- [1] C. C. Chang and H. J. Keisler. Model Theory, volume 73 of Studies\n-- in Logic and the Foundations of Mathematics. North-Holland, 3rd\n-- edition, 3rd impression 1992.\n\n-- [2] Agda standard library_0.8.1 (see Algebra/Structures.agda)\n\n-- [3] Coq implementation\n-- (http://coq.inria.fr/pylons/contribs/files/GroupTheory/v8.3/GroupTheory.g1.html)\n\nmodule FOT.GroupTheory.FormalisationsSL where\n\nopen import Data.Product\nopen import Relation.Binary.PropositionalEquality\n\n------------------------------------------------------------------------------\n\n-- NB. We only write the proof for the left-inverse property.\n\ninfixl 10 _·_ -- The symbol is '\\cdot'.\n\npostulate\n G : Set -- The universe\n ε : G -- The identity element.\n _·_ : G → G → G -- The binary operation.\n\n-- Left-inverse property based on the signature (G, ·, ε,).\nleftInverse₁ : Set\nleftInverse₁ = ∀ a → Σ G (λ a' → a' · a ≡ ε)\n\n-- Left-inverse property based on the signature (G, ·, _⁻¹, ε,).\ninfix 11 _⁻¹\n\npostulate _⁻¹ : G → G -- The inverse function.\n\nleftInverse₂ : Set\nleftInverse₂ = ∀ a → a ⁻¹ · a ≡ ε\n\n-- From the left-inverse property based on the signature (G, ·, _⁻¹, ε,)\n-- to the one based on the signature (G, ·, ε,).\nleftInverse₂₋₁ : leftInverse₂ → leftInverse₁\nleftInverse₂₋₁ h a = (a ⁻¹) , (h a)\n\n-- From the left-inverse property based on the signature (G, ·, ε,) to\n-- the one based on the signature (G, ·, _⁻¹, ε,).\n--\n-- In this case we prove the existence of the inverse function.\nleftInverse₁₋₂ : leftInverse₁ → Σ (G → G) (λ f → ∀ a → f a · a ≡ ε)\nleftInverse₁₋₂ h = f , prf\n where\n f : G → G -- The inverse function.\n f a = proj₁ (h a)\n\n prf : ∀ a → f a · a ≡ ε\n prf a = proj₂ (h a)\n", "meta": {"hexsha": "dc7766198371bc669abd46421c4534dd983e1836", "size": 2469, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/FOT/GroupTheory/FormalisationsSL.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "notes/FOT/GroupTheory/FormalisationsSL.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "notes/FOT/GroupTheory/FormalisationsSL.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 30.1097560976, "max_line_length": 87, "alphanum_fraction": 0.5536654516, "num_tokens": 754, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8976952866333484, "lm_q2_score": 0.8438951045175643, "lm_q1q2_score": 0.7575606577383744}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Setoids.Setoids\nopen import Functions.Definition\nopen import Sets.EquivalenceRelations\nopen import Rings.Definition\n\nmodule Rings.Divisible.Definition {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} (R : Ring S _+_ _*_) where\n\nopen Setoid S\nopen Equivalence eq\nopen Ring R\n\n_∣_ : Rel A\na ∣ b = Sg A (λ c → (a * c) ∼ b)\n\ndivisibleWellDefined : {x y a b : A} → (x ∼ y) → (a ∼ b) → x ∣ a → y ∣ b\ndivisibleWellDefined x=y a=b (c , xc=a) = c , transitive (*WellDefined (symmetric x=y) reflexive) (transitive xc=a a=b)\n", "meta": {"hexsha": "3447436857ce4dbfc13a814955593c1da6b90190", "size": 624, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Rings/Divisible/Definition.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Rings/Divisible/Definition.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Rings/Divisible/Definition.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 31.2, "max_line_length": 127, "alphanum_fraction": 0.6554487179, "num_tokens": 219, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9489172644875642, "lm_q2_score": 0.7981867801399695, "lm_q1q2_score": 0.7574132159605567}} {"text": "module Issue790 where\n\nopen import Common.Level renaming (lzero to zero; lsuc to suc)\nopen import Common.Prelude using (Bool; true; false; zero; suc) renaming (Nat to ℕ)\n\neven? : ℕ -> Bool\neven? 0 = true\neven? (suc (suc n)) = even? n\neven? _ = false\n\n-- Name overlap between Level's suc and Nat's suc should not matter,\n-- since only one is a constructor.\n", "meta": {"hexsha": "f57df7375fd4e63ae8fd4ecbf6a1a7723db0ae32", "size": 382, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue790.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue790.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue790.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 29.3846153846, "max_line_length": 83, "alphanum_fraction": 0.6596858639, "num_tokens": 105, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9111796979521252, "lm_q2_score": 0.8311430394931456, "lm_q1q2_score": 0.7573206636803756}} {"text": "module Naturals where\n\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\n-- suc (suc (suc (suc (suc (suc (suc zero))))))\n\n{-# BUILTIN NATURAL ℕ #-}\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl)\nopen Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _∎)\n\n_+_ : ℕ → ℕ → ℕ\nzero + n = n -- 0 + n ≡ n\nsuc m + n = suc (m + n) -- (1 + m) + n ≡ 1 + (m + n)\n\n_ : 1 + 1 ≡ 2\n_ = refl\n\n\n_ : 3 + 4 ≡ 7\n_ =\n begin\n 3 + 4\n ≡⟨⟩\n suc 1 + 4\n ∎", "meta": {"hexsha": "af5b1436ff5734b6f4b2874aa8341530ea7b74b1", "size": 466, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "plfa/src/Naturals.agda", "max_stars_repo_name": "xiongxin/playground", "max_stars_repo_head_hexsha": "9f23862b35c00b810e20f2e1e661142c024baa33", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "plfa/src/Naturals.agda", "max_issues_repo_name": "xiongxin/playground", "max_issues_repo_head_hexsha": "9f23862b35c00b810e20f2e1e661142c024baa33", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "plfa/src/Naturals.agda", "max_forks_repo_name": "xiongxin/playground", "max_forks_repo_head_hexsha": "9f23862b35c00b810e20f2e1e661142c024baa33", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 16.0689655172, "max_line_length": 52, "alphanum_fraction": 0.491416309, "num_tokens": 210, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9343951607140233, "lm_q2_score": 0.8104789109591832, "lm_q1q2_score": 0.7573075722610326}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Setoids.Setoids\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_)\nopen import Groups.Definition\n\nmodule Groups.Subgroups.Definition {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ : A → A → A} (G : Group S _+_) where\n\nopen import Setoids.Subset S\nopen Group G\n\nrecord Subgroup {c : _} (pred : A → Set c) : Set (a ⊔ b ⊔ c) where\n field\n isSubset : subset pred\n closedUnderPlus : {g h : A} → (pred g) → (pred h) → pred (g + h)\n containsIdentity : pred 0G\n closedUnderInverse : ({g : A} → (pred g) → (pred (inverse g)))\n\nsubgroupOp : {c : _} {pred : A → Set c} → (s : Subgroup pred) → Sg A pred → Sg A pred → Sg A pred\nsubgroupOp {pred = pred} record { closedUnderPlus = one } (a , prA) (b , prB) = (a + b) , one prA prB\n\nsubgroupIsGroup : {c : _} {pred : A → Set c} → (s : Subgroup pred) → Group (subsetSetoid (Subgroup.isSubset s)) (subgroupOp s)\nGroup.+WellDefined (subgroupIsGroup s) {m , prM} {n , prN} {x , prX} {y , prY} m=x n=y = +WellDefined m=x n=y\nGroup.0G (subgroupIsGroup record { containsIdentity = two }) = 0G , two\nGroup.inverse (subgroupIsGroup record { closedUnderInverse = three }) (a , prA) = (inverse a) , three prA\nGroup.+Associative (subgroupIsGroup s) {a , prA} {b , prB} {c , prC} = +Associative\nGroup.identRight (subgroupIsGroup s) {a , prA} = identRight\nGroup.identLeft (subgroupIsGroup s) {a , prA} = identLeft\nGroup.invLeft (subgroupIsGroup s) {a , prA} = invLeft\nGroup.invRight (subgroupIsGroup s) {a , prA} = invRight\n", "meta": {"hexsha": "2e078dec351bd97200040608159b04cec1faa6c9", "size": 1562, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Groups/Subgroups/Definition.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Groups/Subgroups/Definition.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Groups/Subgroups/Definition.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 48.8125, "max_line_length": 126, "alphanum_fraction": 0.6542893726, "num_tokens": 555, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9184802462567085, "lm_q2_score": 0.8244619263765707, "lm_q1q2_score": 0.7572519931676329}} {"text": "module 030-semigroup where\n\n-- We need equivalence.\n\nopen import 020-equivalence\n\n-- Semigroups are basically a set with equality and some binary\n-- operator which is associative and respects equality.\n\nrecord SemiGroup\n {M : Set}\n (_==_ : M -> M -> Set)\n (_*_ : M -> M -> M)\n : Set1 where\n\n field\n equiv : Equivalence _==_\n assoc : ∀ {r s t} -> ((r * s) * t) == (r * (s * t))\n cong : ∀ {r s u v} -> (r == s) -> (u == v) -> (r * u) == (s * v)\n\n -- The next line brings all fields and declarations of Equivalence\n -- into this record's namespace so we can refer to them in an\n -- unqualified way in proofs (for example, we can write \"refl\" for\n -- \"Equivalence.symm equiv\" and so on).\n\n open Equivalence equiv public\n\n -- No theorems here yet.\n", "meta": {"hexsha": "38e65ddf8b5cfa869a5dc916239b944440ec16ac", "size": 763, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "030-semigroup.agda", "max_stars_repo_name": "mcmtroffaes/agda-proofs", "max_stars_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2015-08-09T22:51:55.000Z", "max_stars_repo_stars_event_max_datetime": "2016-08-17T16:15:42.000Z", "max_issues_repo_path": "030-semigroup.agda", "max_issues_repo_name": "mcmtroffaes/agda-proofs", "max_issues_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "030-semigroup.agda", "max_forks_repo_name": "mcmtroffaes/agda-proofs", "max_forks_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.3103448276, "max_line_length": 68, "alphanum_fraction": 0.6186107471, "num_tokens": 230, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9609517072737735, "lm_q2_score": 0.7879311981328135, "lm_q1q2_score": 0.7571638300599971}} {"text": "-- Proof of: ∀ (x : ND ℕ) → always (even (double (eo x))) ≡ tt\n\nmodule even-double-eo where\n\nopen import bool\nopen import nat\nopen import eq\nopen import nat-thms\nopen import nondet\nopen import nondet-thms\nopen import functions\n\n----------------------------------------------------------------------\n\n-- A definition of double with addition.\ndouble : ℕ → ℕ\ndouble x = x + x\n\n-- even is a deterministic predicate:\neven : ℕ → 𝔹\neven zero = tt\neven (suc 0) = ff\neven (suc (suc x)) = even x\n\n-- eo yields an even and odd number close to the input value:\neo : ℕ → ND ℕ\neo n = Val n ?? Val (suc n)\n\n-- auxiliary property for x+x instead of double:\neven-x+x : (x : ℕ) → even (x + x) ≡ tt\neven-x+x zero = refl\neven-x+x (suc x) rewrite +suc x x | even-x+x x = refl\n\n-- (even (double x)) is always true:\neven-double-is-true : ∀ (x : ℕ) → even (double x) ≡ tt\neven-double-is-true x rewrite even-x+x x = refl\n\n-- Proof of main result:\neven-double-eo-true : (n : ℕ) → always ((even ∘ double) $* (eo n)) ≡ tt\neven-double-eo-true n = always-$* (even ∘ double) (eo n) even-double-is-true\n\n-- Alternative statement and proof:\ndouble-eo-satisfy-even : ∀ (n : ℕ) → (double $* (eo n)) satisfy even ≡ tt\ndouble-eo-satisfy-even n\n rewrite even-double-is-true n | +suc n n | even-double-is-true n = refl\n\n\n----------------------------------------------------------------------\n", "meta": {"hexsha": "c6929b0908a0beb9ce9d1b3248bf3416c93cc671", "size": 1354, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "nondet/even-double-eo.agda", "max_stars_repo_name": "mihanus/curry-agda", "max_stars_repo_head_hexsha": "b7cfdda11cdadeba882b6b72d75448acd8b0a294", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "nondet/even-double-eo.agda", "max_issues_repo_name": "mihanus/curry-agda", "max_issues_repo_head_hexsha": "b7cfdda11cdadeba882b6b72d75448acd8b0a294", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "nondet/even-double-eo.agda", "max_forks_repo_name": "mihanus/curry-agda", "max_forks_repo_head_hexsha": "b7cfdda11cdadeba882b6b72d75448acd8b0a294", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.6326530612, "max_line_length": 76, "alphanum_fraction": 0.582717873, "num_tokens": 403, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9314625126757597, "lm_q2_score": 0.8128673201042492, "lm_q1q2_score": 0.7571554364563151}} {"text": "module Lib where\n\n\n-- Natural numbers\n\ndata Nat : Set where\n zero : Nat\n suc : Nat -> Nat\n\n{-# BUILTIN NATURAL Nat #-}\n\n_+_ : Nat -> Nat -> Nat\nzero + n = n\nsuc k + n = suc (k + n)\n\n\n-- Finite sets\n\ndata Fin : Nat -> Set where\n fzero : forall {n} -> Fin (suc n)\n fsuc : forall {n} -> Fin n -> Fin (suc n)\n\nfin : forall {n} (k : Nat) -> Fin (suc (k + n))\nfin zero = fzero\nfin (suc i) = fsuc (fin i)\n\n\n-- Lists\n\ninfixl 0 _,_\n\ndata List (X : Set) : Set where\n [] : List X\n _,_ : List X -> X -> List X\n\n\n-- List membership\n\ndata LMem {X : Set} (a : X) : List X -> Set where\n lzero : forall {l} -> LMem a (l , a)\n lsuc : forall {l b} -> LMem a l -> LMem a (l , b)\n\n\n-- Vectors\n\ndata Vec (X : Set) : Nat -> Set where\n [] : Vec X zero\n _,_ : forall {n} -> Vec X n -> X -> Vec X (suc n)\n\nproj : forall {X n} -> Vec X n -> Fin n -> X\nproj [] ()\nproj (_ , a) fzero = a\nproj (v , _) (fsuc i) = proj v i\n\n\n-- Vector membership\n\ndata VMem {X : Set} (a : X) : forall {n} -> Fin n -> Vec X n -> Set where\n mzero : forall {n} {v : Vec X n} -> VMem a fzero (v , a)\n msuc : forall {n i b} {v : Vec X n} -> VMem a i v -> VMem a (fsuc i) (v , b)\n\nfmem : forall {X n} -> (i : Fin n) -> {v : Vec X n} -> VMem (proj v i) i v\nfmem {_} {zero} ()\nfmem {_} {suc n} fzero {_ , a} = mzero\nfmem {_} {suc n} (fsuc i) {v , _} = msuc (fmem i)\n\nmem : forall {X n} -> (k : Nat) -> {v : Vec X (suc (k + n))} -> VMem (proj v (fin k)) (fin k) v\nmem i = fmem (fin i)\n", "meta": {"hexsha": "1ea71170036f6dc08f1cfb317a695c1805f97225", "size": 1559, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Lib.agda", "max_stars_repo_name": "mietek/formal-logic", "max_stars_repo_head_hexsha": "2dd761bfa96ccda089888e8defa6814776fa2922", "max_stars_repo_licenses": ["X11"], "max_stars_count": 26, "max_stars_repo_stars_event_min_datetime": "2015-08-31T09:49:52.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-13T12:37:44.000Z", "max_issues_repo_path": "src/Lib.agda", "max_issues_repo_name": "mietek/formal-logic", "max_issues_repo_head_hexsha": "2dd761bfa96ccda089888e8defa6814776fa2922", "max_issues_repo_licenses": ["X11"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Lib.agda", "max_forks_repo_name": "mietek/formal-logic", "max_forks_repo_head_hexsha": "2dd761bfa96ccda089888e8defa6814776fa2922", "max_forks_repo_licenses": ["X11"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.5942028986, "max_line_length": 95, "alphanum_fraction": 0.4746632457, "num_tokens": 597, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9314625107731765, "lm_q2_score": 0.8128673155708976, "lm_q1q2_score": 0.7571554306871203}} {"text": "-- Functions used in googology\n\n{-# OPTIONS --without-K --safe --exact-split #-}\n\nmodule Math.Googology.Function where\n\n-- agda-stdlib\nopen import Data.Nat\nopen import Data.Nat.GeneralisedArithmetic\nopen import Function\n\n-- Ackermann function.\n-- ack m n = Ack(m, n)\nack : ℕ → ℕ → ℕ\nack 0 n = 1 + n\nack (suc m) zero = ack m 1\nack (suc m) (suc n) = ack m (ack (suc m) n)\n\n-- Hyperoperation.\n-- H n a b ≡ Hₙ(a, b)\nH : ℕ → ℕ → ℕ → ℕ\nH 0 a b = 1 + b\nH 1 a 0 = a\nH 1 a (suc b) = H 0 a (H 1 a b)\nH 2 a 0 = 0\nH 2 a (suc b) = H 1 a (H 2 a b)\nH (suc (suc (suc _))) a 0 = 1\nH (suc n@(suc (suc _))) a (suc b) = H n a (H (suc n) a b)\n\n-- Knuth's up-arrow notation.\n-- a ↑[ n ] b =`a ↑ⁿ b`\n_↑[_]_ : ℕ → ℕ → ℕ → ℕ\na ↑[ n ] b = H (2 + n) a b\n\ninfixr 8 _↑_ _↑↑_ _↑↑↑_ _↑↑↑↑_\n\n-- Exponentiation.\n_↑_ : ℕ → ℕ → ℕ\n_↑_ a b = a ↑[ 1 ] b\n\n-- Tetration.\n_↑↑_ : ℕ → ℕ → ℕ\n_↑↑_ a b = a ↑[ 2 ] b\n\n-- Pentation.\n_↑↑↑_ : ℕ → ℕ → ℕ\n_↑↑↑_ a b = a ↑[ 3 ] b\n\n-- Hexation.\n_↑↑↑↑_ : ℕ → ℕ → ℕ\n_↑↑↑↑_ a b = a ↑[ 4 ] b\n\n-- Heptation.\n_↑↑↑↑↑_ : ℕ → ℕ → ℕ\n_↑↑↑↑↑_ a b = a ↑[ 5 ] b\n\n-- Graham's number.\ngraham's-number : ℕ\ngraham's-number = go 64 where\n go : ℕ → ℕ\n go 0 = 4\n go (suc n) = 3 ↑[ go n ] 3\n\n-- Fast-growing hierarchy\nFGHℕ[_][_] : ℕ → ℕ → ℕ\nFGHℕ[ zero ][ x ] = suc x\nFGHℕ[ suc n ][ x ] = fold x FGHℕ[ n ][_] x\n\nFGHω : ℕ → ℕ\nFGHω n = FGHℕ[ n ][ n ]\n", "meta": {"hexsha": "51c2b0c42f6d91684b1e58535a5cb6bd366a3a16", "size": 1472, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Math/Googology/Function.agda", "max_stars_repo_name": "rei1024/agda-misc", "max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z", "max_issues_repo_path": "Math/Googology/Function.agda", "max_issues_repo_name": "rei1024/agda-misc", "max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Math/Googology/Function.agda", "max_forks_repo_name": "rei1024/agda-misc", "max_forks_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.7323943662, "max_line_length": 57, "alphanum_fraction": 0.457201087, "num_tokens": 660, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9546474168650673, "lm_q2_score": 0.7931059438487663, "lm_q1q2_score": 0.7571365405955558}} {"text": "------------------------------------------------------------------------------\n-- Group theory properties\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule GroupTheory.PropertiesI where\n\nopen import GroupTheory.Base\n\nopen import Common.FOL.Relation.Binary.EqReasoning\n\n------------------------------------------------------------------------------\n-- Congruence properties\n\n-- The propositional equality is compatible with the binary operation.\n\n·-leftCong : ∀ {a b c} → a ≡ b → a · c ≡ b · c\n·-leftCong refl = refl\n\n·-rightCong : ∀ {a b c} → b ≡ c → a · b ≡ a · c\n·-rightCong refl = refl\n\n-- The propositional equality is compatible with the inverse function.\n⁻¹-cong : ∀ {a b} → a ≡ b → a ⁻¹ ≡ b ⁻¹\n⁻¹-cong refl = refl\n\n------------------------------------------------------------------------------\n\nleftCancellation : ∀ {a b c} → a · b ≡ a · c → b ≡ c\nleftCancellation {a} {b} {c} h =\n b ≡⟨ sym (leftIdentity b) ⟩\n ε · b ≡⟨ ·-leftCong (sym (leftInverse a)) ⟩\n a ⁻¹ · a · b ≡⟨ assoc (a ⁻¹) a b ⟩\n a ⁻¹ · (a · b) ≡⟨ ·-rightCong h ⟩\n a ⁻¹ · (a · c) ≡⟨ sym (assoc (a ⁻¹) a c) ⟩\n a ⁻¹ · a · c ≡⟨ ·-leftCong (leftInverse a) ⟩\n ε · c ≡⟨ leftIdentity c ⟩\n c ∎\n\n-- A different proof without using congruence.\nleftCancellation' : ∀ {a b c} → a · b ≡ a · c → b ≡ c\n-- Paper proof (Mac Lane and Garret Birkhoff 1999. p. 48):\n--\n-- 1. a⁻¹(ab) = a⁻¹(ac) (hypothesis ab = ac)\n-- 2. a⁻¹a(b) = a⁻¹a(c) (associative axiom)\n-- 3. εb = εc (left-inverse axiom for a⁻¹)\n-- 4. b = c (left-identity axiom)\nleftCancellation' {a} {b} {c} h =\n b ≡⟨ sym (leftIdentity b) ⟩\n ε · b ≡⟨ subst (λ t → ε · b ≡ t · b) (sym (leftInverse a)) refl ⟩\n a ⁻¹ · a · b ≡⟨ assoc (a ⁻¹) a b ⟩\n a ⁻¹ · (a · b) ≡⟨ subst (λ t → a ⁻¹ · (a · b) ≡ a ⁻¹ · t) h refl ⟩\n a ⁻¹ · (a · c) ≡⟨ sym (assoc (a ⁻¹) a c) ⟩\n a ⁻¹ · a · c ≡⟨ subst (λ t → a ⁻¹ · a · c ≡ t · c) (leftInverse a) refl ⟩\n ε · c ≡⟨ leftIdentity c ⟩\n c ∎\n\n-- Mac Lane and Garret Birkhoff (1999) p. 50, exercise 6.\nrightIdentity : ∀ a → a · ε ≡ a\nrightIdentity a = leftCancellation prf\n where\n prf : a ⁻¹ · (a · ε) ≡ a ⁻¹ · a\n prf = a ⁻¹ · (a · ε) ≡⟨ sym (assoc (a ⁻¹) a ε) ⟩\n a ⁻¹ · a · ε ≡⟨ ·-leftCong (leftInverse a) ⟩\n ε · ε ≡⟨ leftIdentity ε ⟩\n ε ≡⟨ sym (leftInverse a) ⟩\n a ⁻¹ · a ∎\n\n-- Mac Lane and Garret Birkhoff (1999) p. 50, exercise 6.\nrightInverse : ∀ a → a · a ⁻¹ ≡ ε\nrightInverse a = leftCancellation prf\n where\n prf : a ⁻¹ · (a · a ⁻¹) ≡ a ⁻¹ · ε\n prf = a ⁻¹ · (a · a ⁻¹) ≡⟨ sym (assoc (a ⁻¹) a (a ⁻¹)) ⟩\n a ⁻¹ · a · a ⁻¹ ≡⟨ ·-leftCong (leftInverse a) ⟩\n ε · a ⁻¹ ≡⟨ leftIdentity (a ⁻¹) ⟩\n a ⁻¹ ≡⟨ sym (rightIdentity (a ⁻¹)) ⟩\n a ⁻¹ · ε ∎\n\nrightCancellation : ∀ {a b c} → b · a ≡ c · a → b ≡ c\nrightCancellation {a} {b} {c} h =\n-- Paper proof:\n--\n-- 1. (ba)a⁻¹ = (ca)a⁻¹ (hypothesis ab = ac)\n-- 2. (b)aa⁻¹ = (c)aa⁻¹ (associative axiom)\n-- 3. bε = cε (right-inverse axiom for a⁻¹)\n-- 4. b = c (right-identity axiom)\n b ≡⟨ sym (rightIdentity b) ⟩\n b · ε ≡⟨ ·-rightCong (sym (rightInverse a)) ⟩\n b · (a · a ⁻¹) ≡⟨ sym (assoc b a (a ⁻¹)) ⟩\n b · a · a ⁻¹ ≡⟨ ·-leftCong h ⟩\n c · a · a ⁻¹ ≡⟨ assoc c a (a ⁻¹) ⟩\n c · (a · a ⁻¹) ≡⟨ ·-rightCong (rightInverse a) ⟩\n c · ε ≡⟨ rightIdentity c ⟩\n c ∎\n\n-- Adapted from the Agda standard library 0.8.1 (see\n-- Algebra.Properties.Group.right-helper).\ny≡x⁻¹[xy] : ∀ a b → b ≡ a ⁻¹ · (a · b)\ny≡x⁻¹[xy] a b = b ≡⟨ sym (leftIdentity b) ⟩\n ε · b ≡⟨ ·-leftCong (sym (leftInverse a)) ⟩\n a ⁻¹ · a · b ≡⟨ assoc (a ⁻¹) a b ⟩\n a ⁻¹ · (a · b) ∎\n\n-- Adapted from the Agda standard library 0.8.1 (see\n-- Algebra.Properties.Group.left-helper).\nx≡[xy]y⁻¹ : ∀ a b → a ≡ (a · b) · b ⁻¹\nx≡[xy]y⁻¹ a b = a ≡⟨ sym (rightIdentity a) ⟩\n a · ε ≡⟨ ·-rightCong (sym (rightInverse b)) ⟩\n a · (b · b ⁻¹) ≡⟨ sym (assoc a b (b ⁻¹)) ⟩\n a · b · b ⁻¹ ∎\n\nrightIdentityUnique : ∀ r → (∀ a → a · r ≡ a) → r ≡ ε\n-- Paper proof (Mac Lane and Garret 1999. p. 48):\n--\n-- 1. r = εr (ε is an identity)\n-- 2. εr = r (hypothesis)\n-- 3. r = ε (transitivity)\nrightIdentityUnique r h = trans (sym (leftIdentity r)) (h ε)\n\n-- A more appropiate version to be used in the proofs. Adapted from\n-- the Agda standard library 0.8.1 (see\n-- Algebra.Properties.Group.right-identity-unique).\nrightIdentityUnique' : ∀ a r → a · r ≡ a → r ≡ ε\nrightIdentityUnique' a r h = r ≡⟨ y≡x⁻¹[xy] a r ⟩\n a ⁻¹ · (a · r) ≡⟨ ·-rightCong h ⟩\n a ⁻¹ · a ≡⟨ leftInverse a ⟩\n ε ∎\n\nleftIdentityUnique : ∀ l → (∀ a → l · a ≡ a) → l ≡ ε\n-- Paper proof:\n-- 1. l = le (ε is an identity)\n-- 2. le = e (hypothesis)\n-- 3. l = e (transitivity)\nleftIdentityUnique l h = trans (sym (rightIdentity l)) (h ε)\n\n-- A more appropiate version to be used in the proofs. Adapted from\n-- the Agda standard library 0.8.1 (see\n-- Algebra.Properties.Group.left-identity-unique).\nleftIdentityUnique' : ∀ a l → l · a ≡ a → l ≡ ε\nleftIdentityUnique' a l h = l ≡⟨ x≡[xy]y⁻¹ l a ⟩\n l · a · a ⁻¹ ≡⟨ ·-leftCong h ⟩\n a · a ⁻¹ ≡⟨ rightInverse a ⟩\n ε ∎\n\nrightInverseUnique : ∀ {a} → ∃[ r ] (a · r ≡ ε) ∧\n (∀ r' → a · r' ≡ ε → r ≡ r')\nrightInverseUnique {a} =\n-- Paper proof:\n--\n-- 1. We know that (a⁻¹) is a right inverse for a.\n-- 2. Let's suppose there is other right inverse r for a, i.e. ar ≡ ε, then\n-- 2.1. aa⁻¹ = ε (right-inverse axiom)\n-- 2.2. ar = ε (hypothesis)\n-- 2.3. aa⁻¹ = ar (transitivity)\n-- 2.4 a⁻¹ = a (left-cancellation)\n _ , rightInverse a , prf\n where\n prf : ∀ r' → a · r' ≡ ε → a ⁻¹ ≡ r'\n prf r' ar'≡ε = leftCancellation aa⁻¹≡ar'\n where\n aa⁻¹≡ar' : a · a ⁻¹ ≡ a · r'\n aa⁻¹≡ar' = a · a ⁻¹ ≡⟨ rightInverse a ⟩\n ε ≡⟨ sym ar'≡ε ⟩\n a · r' ∎\n\n-- A more appropiate version to be used in the proofs.\nrightInverseUnique' : ∀ {a r} → a · r ≡ ε → a ⁻¹ ≡ r\nrightInverseUnique' {a} {r} ar≡ε = leftCancellation aa⁻¹≡ar\n where\n aa⁻¹≡ar : a · a ⁻¹ ≡ a · r\n aa⁻¹≡ar = a · a ⁻¹ ≡⟨ rightInverse a ⟩\n ε ≡⟨ sym ar≡ε ⟩\n a · r ∎\n\nleftInverseUnique : ∀ {a} → ∃[ l ] (l · a ≡ ε) ∧\n (∀ l' → l' · a ≡ ε → l ≡ l')\nleftInverseUnique {a} =\n-- Paper proof:\n--\n-- 1. We know that (a⁻¹) is a left inverse for a.\n-- 2. Let's suppose there is other right inverse l for a, i.e. la ≡ ε, then\n-- 2.1. a⁻¹a = ε (left-inverse axiom)\n-- 2.2. la = ε (hypothesis)\n-- 2.3. a⁻¹a = la (transitivity)\n-- 2.4 a⁻¹ = l (right-cancellation)\n _ , leftInverse a , prf\n where\n prf : ∀ l' → l' · a ≡ ε → a ⁻¹ ≡ l'\n prf l' l'a≡ε = rightCancellation a⁻¹a≡l'a\n where\n a⁻¹a≡l'a : a ⁻¹ · a ≡ l' · a\n a⁻¹a≡l'a = a ⁻¹ · a ≡⟨ leftInverse a ⟩\n ε ≡⟨ sym l'a≡ε ⟩\n l' · a ∎\n\n-- A more appropiate version to be used in the proofs.\nleftInverseUnique' : ∀ {a l} → l · a ≡ ε → a ⁻¹ ≡ l\nleftInverseUnique' {a} {l} la≡ε = rightCancellation a⁻¹a≡la\n where\n a⁻¹a≡la : a ⁻¹ · a ≡ l · a\n a⁻¹a≡la = a ⁻¹ · a ≡⟨ leftInverse a ⟩\n ε ≡⟨ sym la≡ε ⟩\n l · a ∎\n\n⁻¹-involutive : ∀ a → a ⁻¹ ⁻¹ ≡ a\n-- Paper proof:\n--\n-- 1. a⁻¹a = ε (left-inverse axiom)\n-- 2. The previous equation states that a is the unique right\n-- inverse (a⁻¹)⁻¹ of a⁻¹.\n⁻¹-involutive a = rightInverseUnique' (leftInverse a)\n\nidentityInverse : ε ⁻¹ ≡ ε\n-- Paper proof:\n--\n-- 1. εε = ε (left/right-identity axiom)\n-- 2. The previous equation states that ε is the unique left/right\n-- inverse ε⁻¹ of ε.\nidentityInverse = rightInverseUnique' (leftIdentity ε)\n\ninverseDistribution : ∀ a b → (a · b) ⁻¹ ≡ b ⁻¹ · a ⁻¹\n-- Paper proof:\n--\n-- (b⁻¹a⁻¹)(ab) = b⁻¹(a⁻¹(ab)) (associative axiom)\n-- = b⁻¹(a⁻¹a)b (associative axiom)\n-- = b⁻¹(εb) (left-inverse axiom)\n-- = b⁻¹b (left-identity axiom)\n-- = ε (left-inverse axiom)\n-- Therefore, b⁻¹a⁻¹ is the unique left inverse of ab.\ninverseDistribution a b = leftInverseUnique' b⁻¹a⁻¹[ab]≡ε\n where\n b⁻¹a⁻¹[ab]≡ε : b ⁻¹ · a ⁻¹ · (a · b) ≡ ε\n b⁻¹a⁻¹[ab]≡ε =\n b ⁻¹ · a ⁻¹ · (a · b)\n ≡⟨ assoc (b ⁻¹) (a ⁻¹) (a · b) ⟩\n b ⁻¹ · (a ⁻¹ · (a · b))\n ≡⟨ ·-rightCong (sym (assoc (a ⁻¹) a b)) ⟩\n b ⁻¹ · (a ⁻¹ · a · b)\n ≡⟨ ·-rightCong (·-leftCong (leftInverse a)) ⟩\n b ⁻¹ · (ε · b)\n ≡⟨ ·-rightCong (leftIdentity b) ⟩\n b ⁻¹ · b\n ≡⟨ leftInverse b ⟩\n ε ∎\n\n-- If the square of every element is the identity, the system is\n-- commutative. From: TPTP 6.4.0 problem GRP/GRP001-2.p.\nx²≡ε→comm : (∀ a → a · a ≡ ε) → ∀ {b c d} → b · c ≡ d → c · b ≡ d\n-- Paper proof:\n--\n-- 1. d(bc) = dd (hypothesis bc = d)\n-- 2. d(bc) = ε (hypothesis dd = ε)\n-- 3. d(bc)c = c (by 2)\n-- 4. db(cc) = c (associativity axiom)\n-- 5. db = c (hypothesis cc = ε)\n-- 6. (db)b = cb (by 5)\n-- 7. d(bb) = cb (associativity axiom)\n-- 6. d = cb (hypothesis bb = ε)\nx²≡ε→comm h {b} {c} {d} bc≡d = sym d≡cb\n where\n db≡c : d · b ≡ c\n db≡c =\n d · b\n ≡⟨ sym (rightIdentity (d · b)) ⟩\n d · b · ε\n ≡⟨ ·-rightCong (sym (h c)) ⟩\n d · b · (c · c)\n ≡⟨ assoc d b (c · c) ⟩\n d · (b · (c · c))\n ≡⟨ ·-rightCong (sym (assoc b c c)) ⟩\n d · ((b · c) · c)\n ≡⟨ ·-rightCong (·-leftCong bc≡d) ⟩\n d · (d · c)\n ≡⟨ sym (assoc d d c) ⟩\n d · d · c\n ≡⟨ ·-leftCong (h d) ⟩\n ε · c\n ≡⟨ leftIdentity c ⟩\n c ∎\n\n d≡cb : d ≡ c · b\n d≡cb = d ≡⟨ sym (rightIdentity d) ⟩\n d · ε ≡⟨ ·-rightCong (sym (h b)) ⟩\n d · (b · b) ≡⟨ sym (assoc d b b) ⟩\n d · b · b ≡⟨ ·-leftCong db≡c ⟩\n c · b ∎\n\n------------------------------------------------------------------------------\n-- References\n--\n-- Mac Lane, S. and Birkhof, G. (1999). Algebra. 3rd ed. AMS Chelsea\n-- Publishing.\n", "meta": {"hexsha": "59a71e166027325073c19b09cd78b186c43978de", "size": 10461, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/GroupTheory/PropertiesI.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/GroupTheory/PropertiesI.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/GroupTheory/PropertiesI.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 35.1040268456, "max_line_length": 78, "alphanum_fraction": 0.4613325686, "num_tokens": 4273, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8947894604912848, "lm_q2_score": 0.8459424411924673, "lm_q1q2_score": 0.7569403805612883}} {"text": "module Data.List.Relation.Permutation where\n\nimport Data\nopen import Data.Boolean\nopen import Data.List\nopen import Data.List.Functions renaming (module LongOper to List)\nopen import Data.List.Relation\nopen import Functional using (id ; _∘_ ; const)\nopen import Logic.Propositional\nopen import Logic\nimport Lvl\nopen import Numeral.Finite\nopen import Syntax.Function\nopen import Type\n\nprivate variable ℓ : Lvl.Level\nprivate variable T A B : Type{ℓ}\nprivate variable l l₁ l₂ l₃ l₄ : List(T)\nprivate variable x y z : T\nprivate variable f : A → B\nprivate variable P : T → Bool\n\n-- The relation for two lists that are permutations of each other.\n-- This means that they contain the same elements and the same number of them but possibly in a different order.\n-- Or in other words, the first list is a reordered list of the second.\ndata _permutes_ {ℓ} : List{ℓ}(T) → List{ℓ}(T) → Stmt{Lvl.𝐒(ℓ)} where\n empty : ∅ permutes (∅ {T = T})\n prepend : (l₁ permutes l₂) → ((x ⊰ l₁) permutes (x ⊰ l₂))\n swap : (x ⊰ y ⊰ l) permutes (y ⊰ x ⊰ l)\n trans : (l₁ permutes l₂) → (l₂ permutes l₃) → (l₁ permutes l₃)\n\ntrans-swap : (l₁ permutes l₂) → ((x ⊰ y ⊰ l₁) permutes (y ⊰ x ⊰ l₂))\ntrans-swap p = trans swap (prepend (prepend p))\n\n-- TODO\n-- _partition-of_ : List(List(T)) → List(T) → Stmt\n-- p partition-of l = (foldᵣ (x ↦ ¬ Empty(x) ∧_) Data.Unit p) ∧ (concat(p) permutes l)\n\n-- The permutation as a function between the permutated elements' indices.\n-- Example:\n-- p : [a,b,c,d,e,f] permutes [a,f,e,d,b,c]\n-- map(permutation-mapping(p)) [0,1,2,3,4,5] = [0,4,5,3,2,1]\npermutation-mapping : (l₁ permutes l₂) → (𝕟(length(l₁)) → 𝕟(length(l₂)))\npermutation-mapping empty = id\npermutation-mapping (prepend p) 𝟎 = 𝟎\npermutation-mapping (prepend p) (𝐒 n) = 𝐒(permutation-mapping p n)\npermutation-mapping swap 𝟎 = 𝐒(𝟎)\npermutation-mapping swap (𝐒 𝟎) = 𝟎\npermutation-mapping swap (𝐒(𝐒 n)) = 𝐒 (𝐒 n)\npermutation-mapping (trans p q) = permutation-mapping q ∘ permutation-mapping p\n\n-- TODO: It should be possible to make (_permutes_) the morphism of a category with some correct notion of equivalence (maybe trans swap swap ≡ refl for example?). Then permutation-mapping would be an instance of Functor(length) for the ((_→_) on₂ 𝕟) category?\n\nmodule Proofs where\n open import Data.List.Proofs\n open import Data.List.Equiv.Id\n open import Lang.Inspect\n open import Logic.Predicate\n open import Numeral.Natural\n open import Numeral.Finite.Proofs\n open import Relator.Equals\n open import Relator.Equals.Proofs\n open import Structure.Function.Domain\n open import Structure.Function.Domain.Proofs\n import Structure.Function.Names as Names\n open import Structure.Function.Proofs\n open import Structure.Function\n import Structure.Operator.Names as Names\n open import Structure.Operator.Properties\n open import Structure.Operator\n import Structure.Relator.Names as Names\n open import Structure.Relator.Equivalence\n open import Structure.Relator.Properties\n open import Structure.Setoid using (Equiv)\n open import Syntax.Function\n open import Syntax.Transitivity\n\n instance\n permutes-reflexivity : Reflexivity(_permutes_ {T = T})\n permutes-reflexivity = intro proof where\n proof : Names.Reflexivity(_permutes_)\n proof {∅} = empty\n proof {_ ⊰ _} = prepend proof\n\n instance\n permutes-symmetry : Symmetry(_permutes_ {T = T})\n permutes-symmetry = intro proof where\n proof : Names.Symmetry(_permutes_)\n proof empty = empty\n proof (prepend p) = prepend (proof p)\n proof swap = swap\n proof (trans p q) = trans (proof q) (proof p)\n\n instance\n permutes-transitivity : Transitivity(_permutes_ {T = T})\n permutes-transitivity = intro trans\n\n instance\n permutes-equivalence : Equivalence(_permutes_ {T = T})\n permutes-equivalence = intro\n\n permutes-equiv : Equiv(List(T))\n Equiv._≡_ permutes-equiv = _permutes_\n Equiv.equivalence permutes-equiv = permutes-equivalence\n\n -- If permutation relation had empty, prepend and trans-swap\n module _ where\n swap-from-trans-swap : (x ⊰ y ⊰ l) permutes (y ⊰ x ⊰ l)\n swap-from-trans-swap = trans-swap(reflexivity(_permutes_))\n\n PermutationMappingCorrectness : (l₁ l₂ : List(T)) → (𝕟(length(l₁)) → 𝕟(length(l₂))) → Stmt\n PermutationMappingCorrectness l₁ l₂ mapping = ∀{i} → (index l₁(i) ≡ index l₂(mapping i))\n\n permutation-mapping-correctness : (p : (l₁ permutes l₂)) → PermutationMappingCorrectness l₁ l₂ (permutation-mapping p)\n permutation-mapping-correctness empty = reflexivity(_≡_)\n permutation-mapping-correctness (prepend p) {𝟎} = reflexivity(_≡_)\n permutation-mapping-correctness (prepend p) {𝐒 i} = permutation-mapping-correctness p {i}\n permutation-mapping-correctness swap {𝟎} = reflexivity(_≡_)\n permutation-mapping-correctness swap {𝐒 𝟎} = reflexivity(_≡_)\n permutation-mapping-correctness swap {𝐒 (𝐒 i)} = reflexivity(_≡_)\n permutation-mapping-correctness (trans p q) = permutation-mapping-correctness p 🝖 permutation-mapping-correctness q\n\n instance\n permutation-mapping-injective : ∀{p : (l₁ permutes l₂)} → Injective(permutation-mapping p)\n permutation-mapping-injective {p = p} = intro(proof p) where\n proof : (p : (l₁ permutes l₂)) → Names.Injective(permutation-mapping p)\n proof (prepend p) {𝟎} {𝟎} eq = [≡]-intro\n proof (prepend p) {𝐒 x} {𝐒 y} eq = congruence₁(𝐒) (proof p (injective(𝐒) ⦃ [𝐒]-injective ⦄ eq))\n proof swap {𝟎} {𝟎} eq = [≡]-intro\n proof swap {𝟎} {𝐒 (𝐒 y)} ()\n proof swap {𝐒 (𝐒 x)} {𝟎} ()\n proof swap {𝐒 𝟎} {𝐒 𝟎} eq = [≡]-intro\n proof swap {𝐒 (𝐒 x)} {𝐒 (𝐒 y)} eq = eq\n proof (trans p q) = proof p ∘ proof q\n\n instance\n permutation-mapping-surjective : ∀{p : (l₁ permutes l₂)} → Surjective(permutation-mapping p)\n permutation-mapping-surjective {p = p} = intro(proof p) where\n proof : (p : (l₁ permutes l₂)) → Names.Surjective(permutation-mapping p)\n ∃.witness (proof p {y}) = permutation-mapping(symmetry(_permutes_) p) y\n ∃.proof (proof (prepend p) {𝟎}) = [≡]-intro\n ∃.proof (proof (prepend p) {𝐒 y}) = congruence₁(𝐒) (∃.proof (proof p {y}))\n ∃.proof (proof swap {𝟎}) = [≡]-intro\n ∃.proof (proof swap {𝐒 𝟎}) = [≡]-intro\n ∃.proof (proof swap {𝐒 (𝐒 y)}) = [≡]-intro\n ∃.proof (proof (trans p q) {y}) =\n permutation-mapping (trans p q) (∃.witness (proof (trans p q))) 🝖[ _≡_ ]-[]\n (permutation-mapping (trans p q) ∘ permutation-mapping(symmetry(_permutes_) p) ∘ permutation-mapping (symmetry(_permutes_) q)) y 🝖[ _≡_ ]-[]\n (permutation-mapping q ∘ permutation-mapping p ∘ permutation-mapping(symmetry(_permutes_) p) ∘ permutation-mapping (symmetry(_permutes_) q)) y 🝖[ _≡_ ]-[ congruence₁(permutation-mapping q) (∃.proof (proof p {_})) ]\n (permutation-mapping q ∘ permutation-mapping (symmetry(_permutes_) q)) y 🝖[ _≡_ ]-[ ∃.proof (proof q {y}) ]\n y 🝖[ _≡_ ]-end\n\n permutation-mapping-bijective : ∀{p : (l₁ permutes l₂)} → Bijective(permutation-mapping p)\n permutation-mapping-bijective {p = p} = injective-surjective-to-bijective(permutation-mapping p) ⦃ permutation-mapping-injective {p = p} ⦄ ⦃ permutation-mapping-surjective {p = p} ⦄\n\n {-\n permutation-from-mapping : (p : 𝕟(length(l₁)) → 𝕟(length(l₂))) ⦃ bij : Bijective(p) ⦄ (correctness : PermutationMappingCorrectness l₁ l₂ p) → (l₁ permutes l₂)\n permutation-from-mapping {l₁ = ∅} {l₂ = ∅} p _ = empty\n permutation-from-mapping {l₁ = ∅} {l₂ = x₂ ⊰ l₂} p _ = {!!}\n permutation-from-mapping {l₁ = x₁ ⊰ l₁} {l₂ = ∅} p _ = {!!}\n permutation-from-mapping {l₁ = x₁ ⊰ l₁} {l₂ = x₂ ⊰ l₂} p correctness with p(𝟎) | correctness{𝟎}\n ... | 𝟎 | [≡]-intro = prepend (permutation-from-mapping (forgetFirstCutoffOfBij p) ⦃ forgetFirstCutoffOfBij-bijective ⦄ {!!}) where\n bijective-equinumerous : ∀{a b}{f : 𝕟(a) → 𝕟(b)} → Bijective(f) → (a ≡ b)\n forgetFirstCutoff : ∀{a} → (𝕟(𝐒(a)) → 𝕟(𝐒(a))) → (𝕟(a) → 𝕟(a))\n forgetFirstCutoff {𝐒(a)} f(x) with f(𝐒(x))\n ... | 𝟎 = 𝟎\n ... | 𝐒(y) = y\n\n forgetFirstCutoffOfBij : ∀{a b} → (f : 𝕟(𝐒(a)) → 𝕟(𝐒(b))) ⦃ bij : Bijective(f) ⦄ → (𝕟(a) → 𝕟(b))\n forgetFirstCutoffOfBij {𝐒 a} f ⦃ bij ⦄ with [≡]-intro ← bijective-equinumerous bij = forgetFirstCutoff f\n forgetFirstCutoffOfBij-bijective : ∀{a b}{f : 𝕟(𝐒(a)) → 𝕟(𝐒(b))} ⦃ bij : Bijective(f) ⦄ → Bijective(forgetFirstCutoffOfBij f)\n\n -- proof : ∀{l₁ l₂ : List(T)}{p : 𝕟(length(l₁)) → 𝕟(length(l₂))} → PermutationMappingCorrectness l₁ l₂ (forgetFirstCutoffOfBij p)\n proof : PermutationMappingCorrectness l₁ l₂ (forgetFirstCutoffOfBij p)\n proof {i} =\n index l₁ i 🝖[ _≡_ ]-[ {!correctness!} ]\n index l₂ (forgetFirstCutoffOfBij p i) 🝖-end \n ... | 𝐒 w | _ = {!!}\n -}\n\n permutes-prepend-function : Function ⦃ permutes-equiv ⦄ ⦃ permutes-equiv ⦄ (List.prepend x)\n permutes-prepend-function = intro prepend\n\n permutes-postpend-function : Function ⦃ permutes-equiv ⦄ ⦃ permutes-equiv ⦄ (postpend x)\n permutes-postpend-function = intro proof where\n proof : (l₁ permutes l₂) → (postpend x l₁) permutes (postpend x l₂)\n proof empty = prepend empty\n proof (prepend x) = prepend (proof x)\n proof swap = swap\n proof (trans x y) = trans (proof x) (proof y)\n\n postpend-prepend-permutes : (postpend x l) permutes (List.prepend x l)\n postpend-prepend-permutes {l = ∅} = prepend empty\n postpend-prepend-permutes {l = x ⊰ l} = trans (prepend postpend-prepend-permutes) swap\n\n permutes-reverse : (reverse l) permutes l\n permutes-reverse {l = ∅} = empty\n permutes-reverse {l = x ⊰ l} = trans (Function.congruence ⦃ _ ⦄ ⦃ _ ⦄ permutes-postpend-function(permutes-reverse {l = l})) postpend-prepend-permutes\n\n permutes-length-function : Function ⦃ permutes-equiv {T = T} ⦄ (length)\n permutes-length-function = intro proof where\n proof : (l₁ permutes l₂) → (length l₁ ≡ length l₂)\n proof empty = [≡]-intro\n proof (prepend p) = congruence₁(𝐒) (proof p)\n proof swap = [≡]-intro\n proof (trans p q) = transitivity(_≡_) (proof p) (proof q)\n\n permutes-countᵣ-function : Function ⦃ permutes-equiv ⦄ (count P)\n permutes-countᵣ-function = intro proof where\n proof : (l₁ permutes l₂) → (count P l₁ ≡ count P l₂)\n proof empty = [≡]-intro\n proof {l₁ = x₁ ⊰ l₁} {P = P} (prepend {x = x} p) with P(x)\n ... | 𝑇 = [≡]-with 𝐒(proof {l₁ = l₁} {P = P} p)\n ... | 𝐹 = proof {l₁ = l₁} {P = P} p\n proof {P = P} (swap {x = x} {y = y}) with P(x) | P(y)\n ... | 𝑇 | 𝑇 = [≡]-intro\n ... | 𝑇 | 𝐹 = [≡]-intro\n ... | 𝐹 | 𝑇 = [≡]-intro\n ... | 𝐹 | 𝐹 = [≡]-intro\n proof (trans p q) = proof p 🝖 proof q\n\n permutes-satisfiesAny-functionᵣ : Function ⦃ permutes-equiv ⦄ (satisfiesAny f)\n permutes-satisfiesAny-functionᵣ = intro proof where\n proof : (l₁ permutes l₂) → (satisfiesAny f l₁ ≡ satisfiesAny f l₂)\n proof empty = [≡]-intro\n proof {f = f} (prepend{x = x} p) with f(x)\n ... | 𝑇 = [≡]-intro\n ... | 𝐹 = proof p\n proof {l₁ = x ⊰ y ⊰ l₁}{y ⊰ x ⊰ l₂}{f = f} (swap{x = x}{y = y}) with f(x) | f(y) | inspect f(x) | inspect f(y)\n ... | 𝑇 | 𝑇 | intro _ | intro _ = [≡]-intro\n ... | 𝑇 | 𝐹 | intro _ | intro _ with 𝑇 ← f(x) = [≡]-intro\n ... | 𝐹 | 𝑇 | intro _ | intro _ with 𝑇 ← f(y) = [≡]-intro\n ... | 𝐹 | 𝐹 | intro _ | intro _ with 𝐹 ← f(x) | 𝐹 ← f(y)= reflexivity(_≡_)\n proof (trans p q) = proof p 🝖 proof q\n\n {- TODO\n permutes-countₗ : (∀{P} → count P l₁ ≡ count P l₂) → (l₁ permutes l₂)\n permutes-countₗ {l₁ = ∅} {l₂ = ∅} p = empty\n permutes-countₗ {l₁ = ∅} {l₂ = x ⊰ l₂} p with () ← p{const 𝑇}\n permutes-countₗ {l₁ = x ⊰ l₁} {l₂ = ∅} p with () ← p{const 𝑇}\n permutes-countₗ {l₁ = x ⊰ l₁} {l₂ = x₁ ⊰ l₂} p = {!!} -- TODO: The rest of the cases from _permutes_. Maybe decidable equality on the items are required?\n -}\n\n permutes-[++]-function : BinaryOperator ⦃ permutes-equiv ⦄ ⦃ permutes-equiv ⦄ ⦃ permutes-equiv ⦄ (_++_ {T = T})\n permutes-[++]-function = binaryOperator-from-function ⦃ _ ⦄ ⦃ _ ⦄ ⦃ _ ⦄ ⦃ \\{l} → intro(R{l = l}) ⦄ ⦃ intro L ⦄ where\n L : Names.Congruence₁ ⦃ permutes-equiv ⦄ ⦃ permutes-equiv ⦄ (_++ l)\n L {l = l} empty = reflexivity(_permutes_)\n L {l = l} (prepend l12) = prepend (L {l = l} l12)\n L {l = l} swap = swap\n L {l = l} (trans l13 l32) = transitivity(_permutes_) (L {l = l} l13) (L {l = l} l32)\n\n R : Names.Congruence₁ ⦃ permutes-equiv ⦄ ⦃ permutes-equiv ⦄ (l ++_)\n R {l = ∅} l12 = l12\n R {l = x ⊰ l} l12 = prepend (R {l = l} l12)\n\n permutes-[++]-commutativity : Commutativity ⦃ permutes-equiv {T = T} ⦄ (_++_)\n permutes-[++]-commutativity = intro(\\{l₁}{l₂} → proof{l₁}{l₂}) where\n proof : Names.Commutativity ⦃ permutes-equiv ⦄ (_++_)\n proof {∅} {l₂} rewrite identityᵣ(_++_)(∅) {l₂} = reflexivity(_permutes_)\n proof {x ⊰ l₁} {l₂} =\n (x ⊰ l₁) ++ l₂ 🝖[ _permutes_ ]-[]\n x ⊰ (l₁ ++ l₂) 🝖[ _permutes_ ]-[ prepend (proof {l₁} {l₂}) ]\n x ⊰ (l₂ ++ l₁) 🝖[ _permutes_ ]-[]\n (x ⊰ l₂) ++ l₁ 🝖[ _permutes_ ]-[ BinaryOperator.congruence ⦃ _ ⦄ ⦃ _ ⦄ ⦃ _ ⦄ permutes-[++]-function (postpend-prepend-permutes {l = l₂}) (reflexivity(_permutes_)) ]-sym\n (postpend x l₂) ++ l₁ 🝖[ _permutes_ ]-[ sub₂(_≡_)(_permutes_) ([++]-middle-prepend-postpend {l₁ = l₂}{l₂ = l₁}) ]\n l₂ ++ (x ⊰ l₁) 🝖[ _permutes_ ]-end\n\n permutes-empty-not-empty : ¬(∅ permutes (x ⊰ l))\n permutes-empty-not-empty (trans {l₂ = ∅} p q) = permutes-empty-not-empty q\n permutes-empty-not-empty (trans {l₂ = _ ⊰ _} p q) = permutes-empty-not-empty p\n\n permutes-map : ∀{f : A → B} → Function ⦃ permutes-equiv ⦄ ⦃ permutes-equiv ⦄ (map f)\n permutes-map {f = f} = intro proof where\n proof : Names.Congruence₁ ⦃ permutes-equiv ⦄ ⦃ permutes-equiv ⦄ (map f)\n proof empty = empty\n proof (prepend p) = prepend (proof p)\n proof swap = swap\n proof (trans p q) = trans(proof p) (proof q)\n\n permutes-on-empty : (l permutes ∅) → (l ≡ ∅)\n permutes-on-empty empty = [≡]-intro\n permutes-on-empty (trans p q)\n rewrite permutes-on-empty q\n rewrite permutes-on-empty p\n = [≡]-intro\n\n permutes-on-singleton : (l permutes (singleton x)) → (l ≡ singleton x)\n permutes-on-singleton (prepend empty) = [≡]-intro\n permutes-on-singleton (prepend (trans p q))\n rewrite permutes-on-empty q\n rewrite permutes-on-empty p\n = [≡]-intro\n permutes-on-singleton (trans p q)\n rewrite permutes-on-singleton q\n rewrite permutes-on-singleton p\n = [≡]-intro\n\n permutes-insertIn : ∀{n} → ((insertIn x l n) permutes (x ⊰ l))\n permutes-insertIn {n = 𝟎} = reflexivity(_permutes_)\n permutes-insertIn {l = x ⊰ l} {n = 𝐒 n} = trans (prepend (permutes-insertIn {n = n})) swap\n\nmodule InsertionPermutation where\n data _insertion-permutes_ {ℓ} : List{ℓ}(T) → List{ℓ}(T) → Stmt{Lvl.𝐒(ℓ)} where\n empty : ∅ insertion-permutes (∅ {T = T})\n ins : (n : 𝕟₌(length l₁)) → (l₁ insertion-permutes l₂) → ((insertIn x l₁ n) insertion-permutes (x ⊰ l₂))\n\n open import Data.List.Proofs.Length\n open import Relator.Equals.Proofs\n open import Structure.Relator\n\n insertion-permutation-mapping : (l₁ insertion-permutes l₂) → (𝕟(length(l₁)) → 𝕟(length(l₂)))\n insertion-permutation-mapping empty ()\n insertion-permutation-mapping (ins 𝟎 p) 𝟎 = 𝟎\n insertion-permutation-mapping (ins 𝟎 p) (𝐒 i) = 𝐒(insertion-permutation-mapping p i)\n insertion-permutation-mapping (ins {l₁ = x ⊰ l₁} (𝐒 n) p) 𝟎 = 𝟎\n insertion-permutation-mapping (ins {l₁ = x ⊰ l₁} (𝐒 n) p) (𝐒 i) = 𝐒(insertion-permutation-mapping p (substitute₁(𝕟) (length-insertIn {l = l₁} {n = n}) i))\n\n open import Data using ()\n open import Numeral.Natural\n open import Relator.Equals\n open import Syntax.Number\n\n insertion-permutes-prepend : (l₁ insertion-permutes l₂) → ((x ⊰ l₁) insertion-permutes (x ⊰ l₂))\n insertion-permutes-prepend p = ins 𝟎 p\n\n insertion-permutes-refl : l insertion-permutes l\n insertion-permutes-refl {l = ∅} = empty\n insertion-permutes-refl {l = x ⊰ l} = insertion-permutes-prepend insertion-permutes-refl\n\n insertion-permutes-swap : (x ⊰ y ⊰ l) insertion-permutes (y ⊰ x ⊰ l)\n insertion-permutes-swap = ins 1 (insertion-permutes-prepend insertion-permutes-refl)\n\n insertion-permutes-to-permutes : (l₁ insertion-permutes l₂) → (l₁ permutes l₂)\n insertion-permutes-to-permutes empty = empty\n insertion-permutes-to-permutes (ins n p) = trans Proofs.permutes-insertIn (prepend (insertion-permutes-to-permutes p))\n\n insertion-permutes-flipped-ins : ∀{n} → (l₁ insertion-permutes l₂) → ((x ⊰ l₁) insertion-permutes (insertIn x l₂ n))\n insertion-permutes-flipped-ins {n = 𝟎} empty = insertion-permutes-refl\n insertion-permutes-flipped-ins {n = 𝟎} (ins k p) = insertion-permutes-prepend (ins k p)\n insertion-permutes-flipped-ins {n = 𝐒 n} (ins k p) = ins (𝐒 k) (insertion-permutes-flipped-ins {n = n} p)\n\n insertion-permutes-sym : (l₁ insertion-permutes l₂) → (l₂ insertion-permutes l₁)\n insertion-permutes-sym empty = empty\n insertion-permutes-sym (ins n p) = insertion-permutes-flipped-ins(insertion-permutes-sym p)\n\n {-\n insertion-permutes-trans : (l₁ insertion-permutes l₂) → (l₃ insertion-permutes l₂) → (l₁ insertion-permutes l₃)\n ins2 : ∀{n₁ n₂} → (l₁ insertion-permutes l₂) → ((insertIn x l₁ n₁) insertion-permutes (insertIn x l₂ n₂))\n\n ins2 {l₁ = l₁} {l₂} {n₁ = n₁} {𝟎} p = ins n₁ p\n ins2 {l₁ = .(insertIn x _ n)} {x ⊰ l₂} {n₁ = 𝟎} {𝐒 n₂} (ins n p) = insertion-permutes-trans (insertion-permutes-prepend (ins n p)) (ins(𝐒 n₂) insertion-permutes-refl)\n ins2 {l₁ = .(insertIn x _ n)} {x ⊰ l₂} {n₁ = 𝐒 n₁} {𝐒 n₂} (ins n p) = {!!}\n\n insertion-permutes-trans empty empty = empty\n insertion-permutes-trans (ins m p) (ins n q) = {!!}\n -- ins2(insertion-permutes-trans p q)\n -}\n\n {-\n insertion-permutation-mapping-correctness : (p : (l₁ insertion-permutes l₂)) → Proofs.PermutationMappingCorrectness l₁ l₂ (insertion-permutation-mapping p)\n insertion-permutation-mapping-correctness (ins {l₁ = ∅} 𝟎 p) {𝟎} = [≡]-intro\n insertion-permutation-mapping-correctness (ins {l₁ = x ⊰ l₁} 𝟎 p) {𝟎} = [≡]-intro\n insertion-permutation-mapping-correctness (ins {l₁ = x ⊰ l₁} 𝟎 p) {𝐒 i} = insertion-permutation-mapping-correctness p\n insertion-permutation-mapping-correctness (ins {l₁ = x ⊰ l₁} (𝐒 n) p) {𝟎} = {!!}\n insertion-permutation-mapping-correctness (ins {l₁ = x ⊰ l₁} (𝐒 n) p) {𝐒 i} = {!!}\n -}\n\n -- test : (p : (l₁ insertion-permutes l₂)) → (∀{i} → (index l₁(insertion-permutation-mapping p i) ≡ index l₂(i)))\n -- test p = ?\n\n {-\n open import Data.Boolean.Stmt\n open import Numeral.Finite.Oper.Comparisons\n test : ∀{l : List(T)}{n₁ : 𝕟(𝐒(length l))}{n₂ : 𝕟(𝐒(length (insertIn y l n₁)))} → IsTrue(n₁ >? n₂) → (insertIn y (insertIn x l n₁) n₂ ≡ insertIn x (insertIn y l n₁) n₂)\n test p = {!!}\n -}\n\n {-\n ins2 : ∀{n₁ n₂} → (l₁ insertion-permutes l₂) → ((insertIn x l₁ n₁) insertion-permutes (insertIn x l₂ n₂))\n ins2 {n₁ = 𝟎} {𝟎} empty = insertion-permutes-refl\n ins2 {n₁ = n₁} {𝟎} (ins n p) = ins n₁ (ins n p)\n ins2 {x = x} {n₁ = n₁} {𝐒 n₂} (ins {x = y} n p) = {!(ins2 {x = x}{n₁ = n}{n₂ = n₂} p)!}\n\n insertion-permutes-trans : (l₁ insertion-permutes l₂) → (l₃ insertion-permutes l₂) → (l₁ insertion-permutes l₃)\n insertion-permutes-trans empty empty = empty\n insertion-permutes-trans (ins m p) (ins n q) = {!!}\n -}\n\n {-\n test : ∀{n} → (l₁ insertion-permutes (y ⊰ insertIn x l₂ n)) → (l₁ insertion-permutes (x ⊰ insertIn y l₂ n))\n test {l₂ = l₂} (ins {l₁ = l₁} n p) = {!!}\n\n ins2 : ∀{n₁ n₂} → (l₁ insertion-permutes l₂) → ((insertIn x l₁ n₁) insertion-permutes (insertIn x l₂ n₂))\n ins2 {n₁ = n₁} {𝟎} p = ins n₁ p\n ins2 {n₁ = n₁} {𝐒 n₂} (ins {x = x} n p) = test(ins n₁ (ins2{x = x}{n}{n₂} p))\n\n -- insertIn x₁ (insertIn x l₁ n) n₁\n -- x ⊰ insertIn x₁ l₂ n₂\n\n tr : (l₁ insertion-permutes l₂) → (l₃ insertion-permutes l₂) → (l₁ insertion-permutes l₃)\n tr {l₂ = ∅} empty empty = empty\n tr {l₂ = x₂ ⊰ l₂} (ins n₁ p) (ins n₂ q) = ins2(tr p q)\n\n sym : (l₁ insertion-permutes l₂) → (l₂ insertion-permutes l₁)\n sym = tr insertion-permutes-refl\n -}\n", "meta": {"hexsha": "6569ef05376ccf6560bf6021296f98f7acf8160c", "size": 20188, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/List/Relation/Permutation.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Data/List/Relation/Permutation.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/List/Relation/Permutation.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.601965602, "max_line_length": 260, "alphanum_fraction": 0.6315137706, "num_tokens": 7474, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9059898203834277, "lm_q2_score": 0.8354835350552603, "lm_q1q2_score": 0.7569395778580265}} {"text": "{-# OPTIONS --warning=error --safe --without-K #-}\n\nopen import LogicalFormulae\nopen import Numbers.Naturals.Semiring\nopen import Numbers.Naturals.Naturals\nopen import Numbers.Naturals.Order\nopen import Numbers.Naturals.Order.Lemmas\nopen import Numbers.Naturals.Order.WellFounded\nopen import Orders.WellFounded.Induction\nopen import Orders.Total.Definition\nopen import Semirings.Definition\n\nmodule Numbers.Naturals.Division where\n\nopen import Numbers.Naturals.EuclideanAlgorithm public using (_∣_ ; zeroDividesNothing ; divisionAlgResult ; divides ; biggerThanCantDivide ; aDivA ; aDivZero ; divEquality ; oneDivN ; dividesBothImpliesDividesSum ; dividesBothImpliesDividesDifference)\n\ndivOneImpliesOne : {a : ℕ} → a ∣ 1 → a ≡ 1\ndivOneImpliesOne {zero} a|1 = exFalso (zeroDividesNothing _ a|1)\ndivOneImpliesOne {succ zero} a|1 = refl\ndivOneImpliesOne {succ (succ a)} (divides record { quot = zero ; rem = .0 ; pr = pr ; remIsSmall = remIsSmall ; quotSmall = quotSmall } refl) rewrite Semiring.sumZeroRight ℕSemiring (a *N zero) | multiplicationNIsCommutative a 0 = exFalso (naughtE pr)\ndivOneImpliesOne {succ (succ a)} (divides record { quot = (succ quot) ; rem = .0 ; pr = pr ; remIsSmall = remIsSmall ; quotSmall = quotSmall } refl) rewrite Semiring.commutative ℕSemiring quot (succ (quot +N a *N succ quot)) = exFalso (naughtE (equalityCommutative (succInjective pr)))\n", "meta": {"hexsha": "5f33221c8b35cc9889cab7e43b0ad050553076f7", "size": 1371, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numbers/Naturals/Division.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Numbers/Naturals/Division.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Numbers/Naturals/Division.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 62.3181818182, "max_line_length": 285, "alphanum_fraction": 0.7753464624, "num_tokens": 401, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9284088045171238, "lm_q2_score": 0.8152324960856175, "lm_q1q2_score": 0.756869027094359}} {"text": "open import Relation.Binary.Core\n\nmodule TreeSort.Impl2 {A : Set}\n (_≤_ : A → A → Set)\n (tot≤ : Total _≤_) where\n\nopen import BBSTree _≤_\nopen import Bound.Total A \nopen import Bound.Total.Order _≤_\nopen import Data.List\nopen import Data.Sum\n\ninsert : {x : A}{b t : Bound} → LeB b (val x) → LeB (val x) t → BBSTree b t → BBSTree b t\ninsert b≤x x≤t (bslf _) = bsnd b≤x x≤t (bslf b≤x) (bslf x≤t)\ninsert {x = x} b≤x x≤t (bsnd {x = y} b≤y y≤t l r) \n with tot≤ x y\n... | inj₁ x≤y = bsnd b≤y y≤t (insert b≤x (lexy x≤y) l) r\n... | inj₂ y≤x = bsnd b≤y y≤t l (insert (lexy y≤x) x≤t r)\n\ntreeSort : List A → BBSTree bot top\ntreeSort [] = bslf lebx\ntreeSort (x ∷ xs) = insert {x = x} lebx lext (treeSort xs)\n\n\n\n\n", "meta": {"hexsha": "669efe0c46ccb7fb374adfe09c5f4f3a25e44d93", "size": 739, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/TreeSort/Impl2.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/TreeSort/Impl2.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/TreeSort/Impl2.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.3703703704, "max_line_length": 89, "alphanum_fraction": 0.5832205683, "num_tokens": 320, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.970239908635611, "lm_q2_score": 0.7799929053683038, "lm_q1q2_score": 0.7567802452409679}} {"text": "module +-mono-< where\n\nopen import Data.Nat using (ℕ; zero; suc; _+_)\nopen import Data.Nat.Properties using (+-comm)\n\nopen import Relations using (_<_; z Set where\n even : (k : Nat) -> Parity (2 * k)\n odd : (k : Nat) -> Parity (2 * k + 1)\n\n-- Every number is either even or odd.\n\nparity : (n : Nat) -> Parity n\nparity zero = even zero\nparity (suc n) with parity n\nparity (suc .(2 * k)) | even k = {! !}\nparity (suc .(2 * k + 1)) | odd k = {! !}\n\nhalf : Nat -> Nat\nhalf n with parity n\nhalf .(2 * k) | even k = k\nhalf .(2 * k + 1) | odd k = k\n\n", "meta": {"hexsha": "6390ff69f1f0a3db573f3e3b2e5037fc6ed760df", "size": 683, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/SummerSchool07/Lecture/Parity.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/SummerSchool07/Lecture/Parity.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/SummerSchool07/Lecture/Parity.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 17.9736842105, "max_line_length": 46, "alphanum_fraction": 0.4919472914, "num_tokens": 229, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.966410494349896, "lm_q2_score": 0.7826624840223698, "lm_q1q2_score": 0.756373238093176}} {"text": "module Auto.Prelude where\n\nopen import Agda.Primitive public\n using (Level)\n\n\ndata ⊥ : Set where\n\n¬ : Set → Set\n¬ A = A → ⊥\n\n⊥-e : (A : Set) → ⊥ → A\n⊥-e A ()\n\n\nrecord ⊤ : Set where\n\n\n\nrecord _∧_ (A B : Set) : Set where\n constructor ∧-i\n field fst : A\n snd : B\n\ndata _∨_ (A B : Set) : Set where\n ∨-i₁ : A → A ∨ B\n ∨-i₂ : B → A ∨ B\n\n∨-e : (A B C : Set) → A ∨ B → (A → C) → (B → C) → C\n∨-e A B C (∨-i₁ x) h₁ h₂ = h₁ x\n∨-e A B C (∨-i₂ x) h₁ h₂ = h₂ x\n\n\ndata Π (A : Set) (F : A → Set) : Set where\n fun : ((a : A) → F a) → Π A F\n\nrecord Σ (X : Set) (P : X → Set) : Set where\n constructor Σ-i\n field wit : X\n prf : P wit\n\n\ndata ℕ : Set where\n zero : ℕ\n succ : ℕ → ℕ\n\n_+_ : ℕ → ℕ → ℕ\nzero + n = n\nsucc m + n = succ (m + n)\n\n\ndata Fin : ℕ → Set where\n zero : ∀ {n} → Fin (succ n)\n suc : ∀ {n} → Fin n → Fin (succ n)\n\n\ndata List (X : Set) : Set where\n [] : List X\n _∷_ : X → List X → List X\n\n_++_ : {X : Set} → List X → List X → List X\n[] ++ ys = ys\n(x ∷ xs) ++ ys = x ∷ (xs ++ ys)\n\n\ndata Vec (X : Set) : ℕ → Set where\n [] : Vec X zero\n _∷_ : ∀ {n} → X → Vec X n → Vec X (succ n)\n\n-- -----------------------------------\n\ndata _≡_ {a} {A : Set a} (x : A) : A → Set where\n refl : x ≡ x\n\nsubst : {i j : Level} {X : Set i} → (P : X → Set j) → (x y : X) → y ≡ x → P x → P y\nsubst P x .x refl h = h\n\ntrans : ∀ {a} {A : Set a} → {x y z : A} → x ≡ y → y ≡ z → x ≡ z\ntrans refl refl = refl\n\nsym : ∀ {a} {A : Set a} → {x y : A} → x ≡ y → y ≡ x\nsym refl = refl\n\ncong : ∀ {a b} {A : Set a} {B : Set b}\n (f : A → B) {x y} → x ≡ y → f x ≡ f y\ncong f refl = refl\n\ndata _IsRelatedTo_ {a : Level} {Carrier : Set a} (x y : Carrier) : Set a where\n relTo : (x∼y : x ≡ y) → x IsRelatedTo y\n\nbegin_ : {a : Level} {Carrier : Set a} → {x y : Carrier} → x IsRelatedTo y → x ≡ y\nbegin relTo x∼y = x∼y\n\n_∎ : {a : Level} {Carrier : Set a} → (x : Carrier) → x IsRelatedTo x\n_∎ _ = relTo refl\n\n_≡⟨_⟩_ : {a : Level} {Carrier : Set a} → (x : Carrier) {y z : Carrier} → x ≡ y → y IsRelatedTo z → x IsRelatedTo z\n_ ≡⟨ x∼y ⟩ relTo y∼z = relTo (trans x∼y y∼z)\n\n-- -----------------------------------\n", "meta": {"hexsha": "adf68ce6285d47bd5b8424f3ee8b9b965263be4c", "size": 2090, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/interaction/Auto/Prelude.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/interaction/Auto/Prelude.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/interaction/Auto/Prelude.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 20.6930693069, "max_line_length": 114, "alphanum_fraction": 0.4641148325, "num_tokens": 927, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9173026618464796, "lm_q2_score": 0.8244619350028204, "lm_q1q2_score": 0.7562811275691864}} {"text": "{-# OPTIONS --exact-split #-}\n\n-- The --exact-split flag causes Agda to raise an error whenever\n-- a clause in a definition by pattern matching cannot be made to\n-- hold definitionally (i.e. as a reduction rule). Specific clauses\n-- can be excluded from this check by means of the {-# CATCHALL #-}\n-- pragma.\n\nmodule ExactSplit where\n\ndata Bool : Set where\n true false : Bool\n\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\n_+_ : ℕ → ℕ → ℕ\nzero + n = zero\n(suc m) + n = suc (m + n)\n\neq : ℕ → ℕ → Bool\neq zero zero = true\neq (suc m) (suc n) = eq m n\n{-# CATCHALL #-}\neq _ _ = false\n\n-- See also fail/ExactSplitMin.agda\nmin : ℕ → ℕ → ℕ\nmin zero y = zero\n{-# CATCHALL #-}\nmin x zero = zero\nmin (suc x) (suc y) = suc (min x y)\n\n-- See also fail/ExactSplitBerry.agda\nmaj : Bool → Bool → Bool → Bool\nmaj true true true = true\n{-# CATCHALL #-}\nmaj x true false = x\n{-# CATCHALL #-}\nmaj false y true = y\nmaj true false z = z\nmaj false false false = false\n\n-- See also fail/ExactSplitParity.agda\nparity : ℕ → ℕ → Bool\nparity zero zero = true\nparity zero (suc zero) = false\nparity zero (suc (suc n)) = parity zero n\nparity (suc zero) zero = false\nparity (suc (suc m)) zero = parity m zero\n{-# CATCHALL #-}\nparity (suc m) (suc n) = parity m n\n", "meta": {"hexsha": "00a87798c9fdcd2e068a2c5d797066d6cf1f6f97", "size": 1367, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/ExactSplit.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/ExactSplit.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/ExactSplit.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 25.3148148148, "max_line_length": 67, "alphanum_fraction": 0.5815654718, "num_tokens": 423, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9099070011518829, "lm_q2_score": 0.8311430478583168, "lm_q1q2_score": 0.756262878204997}} {"text": "module foldr-++ where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; cong)\nopen Eq.≡-Reasoning\nopen import lists using (List; _∷_; []; _++_; foldr)\n \n-- 結合したリストの重畳は、重畳した結果を初期値とした重畳と等しいことの証明\nfoldr-++ : ∀ {A B : Set} → (_⊗_ : A → B → B) → (e : B) → (xs ys : List A)\n → foldr _⊗_ e (xs ++ ys) ≡ foldr _⊗_ (foldr _⊗_ e ys) xs\nfoldr-++ _⊗_ e [] ys =\n begin\n foldr _⊗_ e ([] ++ ys)\n ≡⟨⟩\n foldr _⊗_ e ys\n ≡⟨⟩\n foldr _⊗_ (foldr _⊗_ e ys) []\n ∎\nfoldr-++ _⊗_ e (x ∷ xs) ys =\n begin\n foldr _⊗_ e ((x ∷ xs) ++ ys)\n ≡⟨⟩\n x ⊗ (foldr _⊗_ e (xs ++ ys))\n ≡⟨ cong (x ⊗_) (foldr-++ _⊗_ e xs ys) ⟩\n x ⊗ (foldr _⊗_ (foldr _⊗_ e ys) xs)\n ≡⟨⟩\n foldr _⊗_ (foldr _⊗_ e ys) (x ∷ xs)\n ∎\n", "meta": {"hexsha": "28335f0d8944a3f0abdcbc4a25260a8ffdb033d9", "size": 716, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "part1/lists/foldr-++.agda", "max_stars_repo_name": "akiomik/plfa-solutions", "max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z", "max_issues_repo_path": "part1/lists/foldr-++.agda", "max_issues_repo_name": "akiomik/plfa-solutions", "max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "part1/lists/foldr-++.agda", "max_forks_repo_name": "akiomik/plfa-solutions", "max_forks_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.6896551724, "max_line_length": 73, "alphanum_fraction": 0.5195530726, "num_tokens": 403, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9219218370002787, "lm_q2_score": 0.8198933337131076, "lm_q1q2_score": 0.7558775683610707}} {"text": "{-# OPTIONS --without-K #-}\n\nopen import library.Basics hiding (Type ; Σ)\nopen import library.types.Sigma\nopen import library.types.Bool\n\nopen import Sec2preliminaries \nopen import Sec4hasConstToSplit\n\nmodule Sec6hasConstToDecEq where\n\n-- Lemma 6.1\nhasConst-family-dec : {X : Type} → (x₁ x₂ : X) → ((x : X) → hasConst ((x₁ == x) + (x₂ == x))) → (x₁ == x₂) + ¬(x₁ == x₂)\nhasConst-family-dec {X} x₁ x₂ hasConst-fam = solution where\n f₋ : (x : X) → (x₁ == x) + (x₂ == x) → (x₁ == x) + (x₂ == x)\n f₋ x = fst (hasConst-fam x)\n\n E₋ : X → Type\n E₋ x = fix (f₋ x)\n\n E : Type\n E = Σ X λ x → (E₋ x)\n\n E-fst-determines-eq : (e₁ e₂ : E) → (fst e₁ == fst e₂) → e₁ == e₂\n E-fst-determines-eq e₁ e₂ p = second-comp-triv (λ x → fixed-point (f₋ x) (snd (hasConst-fam x))) _ _ p\n\n r : Bool → E\n r true = x₁ , to-fix (f₋ x₁) (snd (hasConst-fam x₁)) (inl idp) \n r false = x₂ , to-fix (f₋ x₂) (snd (hasConst-fam x₂)) (inr idp)\n\n about-r : (r true == r false) ↔ (x₁ == x₂)\n about-r = (λ p → ap fst p) , (λ p → E-fst-determines-eq _ _ p)\n\n s : E → Bool\n s (_ , inl _ , _) = true\n s (_ , inr _ , _) = false\n\n s-section-of-r : (e : E) → r(s e) == e\n s-section-of-r (x , inl p , q) = E-fst-determines-eq _ _ p\n s-section-of-r (x , inr p , q) = E-fst-determines-eq _ _ p\n\n about-s : (e₁ e₂ : E) → (s e₁ == s e₂) ↔ (e₁ == e₂)\n about-s e₁ e₂ = one , two where\n one : (s e₁ == s e₂) → (e₁ == e₂)\n one p = \n e₁ =⟨ ! (s-section-of-r e₁) ⟩\n r(s(e₁)) =⟨ ap r p ⟩\n r(s(e₂)) =⟨ s-section-of-r e₂ ⟩\n e₂ ∎\n two : (e₁ == e₂) → (s e₁ == s e₂)\n two p = ap s p\n\n combine : (s (r true) == s (r false)) ↔ (x₁ == x₂)\n combine = (about-s _ _) ◎ about-r\n\n check-bool : (s (r true) == s (r false)) + ¬(s (r true) == s (r false))\n check-bool = Bool-has-dec-eq _ _\n\n solution : (x₁ == x₂) + ¬(x₁ == x₂)\n solution with check-bool \n solution | inl p = inl (fst combine p)\n solution | inr np = inr (λ p → np (snd combine p))\n\n\n-- Theorem 6.2\nall-hasConst→dec-eq : ((X : Type) → hasConst X) → (X : Type) → has-dec-eq X\nall-hasConst→dec-eq all-hasConst X x₁ x₂ = hasConst-family-dec x₁ x₂ (λ x → all-hasConst _)\n", "meta": {"hexsha": "52bfdc76e510bce52b4b9de76a2ace6664fe90f7", "size": 2130, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "nicolai/anonymousExistence/Sec6hasConstToDecEq.agda", "max_stars_repo_name": "nicolaikraus/HoTT-Agda", "max_stars_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-06-30T00:17:55.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-30T00:17:55.000Z", "max_issues_repo_path": "nicolai/anonymousExistence/Sec6hasConstToDecEq.agda", "max_issues_repo_name": "nicolaikraus/HoTT-Agda", "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "nicolai/anonymousExistence/Sec6hasConstToDecEq.agda", "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.3235294118, "max_line_length": 120, "alphanum_fraction": 0.5375586854, "num_tokens": 910, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9219218348550491, "lm_q2_score": 0.8198933337131076, "lm_q1q2_score": 0.7558775666022112}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Properties of functions, such as associativity and commutativity\n------------------------------------------------------------------------\n\n-- These properties can (for instance) be used to define algebraic\n-- structures.\n\nopen import Level\nopen import Relation.Binary\n\n-- The properties are specified using the following relation as\n-- \"equality\".\n\nmodule Algebra.FunctionProperties\n {a ℓ} {A : Set a} (_≈_ : Rel A ℓ) where\n\nopen import Data.Product\n\n------------------------------------------------------------------------\n-- Unary and binary operations\n\nopen import Algebra.FunctionProperties.Core public\n\n------------------------------------------------------------------------\n-- Properties of operations\n\nAssociative : Op₂ A → Set _\nAssociative _∙_ = ∀ x y z → ((x ∙ y) ∙ z) ≈ (x ∙ (y ∙ z))\n\nCommutative : Op₂ A → Set _\nCommutative _∙_ = ∀ x y → (x ∙ y) ≈ (y ∙ x)\n\nLeftIdentity : A → Op₂ A → Set _\nLeftIdentity e _∙_ = ∀ x → (e ∙ x) ≈ x\n\nRightIdentity : A → Op₂ A → Set _\nRightIdentity e _∙_ = ∀ x → (x ∙ e) ≈ x\n\nIdentity : A → Op₂ A → Set _\nIdentity e ∙ = LeftIdentity e ∙ × RightIdentity e ∙\n\nLeftZero : A → Op₂ A → Set _\nLeftZero z _∙_ = ∀ x → (z ∙ x) ≈ z\n\nRightZero : A → Op₂ A → Set _\nRightZero z _∙_ = ∀ x → (x ∙ z) ≈ z\n\nZero : A → Op₂ A → Set _\nZero z ∙ = LeftZero z ∙ × RightZero z ∙\n\nLeftInverse : A → Op₁ A → Op₂ A → Set _\nLeftInverse e _⁻¹ _∙_ = ∀ x → (x ⁻¹ ∙ x) ≈ e\n\nRightInverse : A → Op₁ A → Op₂ A → Set _\nRightInverse e _⁻¹ _∙_ = ∀ x → (x ∙ (x ⁻¹)) ≈ e\n\nInverse : A → Op₁ A → Op₂ A → Set _\nInverse e ⁻¹ ∙ = LeftInverse e ⁻¹ ∙ × RightInverse e ⁻¹ ∙\n\n_DistributesOverˡ_ : Op₂ A → Op₂ A → Set _\n_*_ DistributesOverˡ _+_ =\n ∀ x y z → (x * (y + z)) ≈ ((x * y) + (x * z))\n\n_DistributesOverʳ_ : Op₂ A → Op₂ A → Set _\n_*_ DistributesOverʳ _+_ =\n ∀ x y z → ((y + z) * x) ≈ ((y * x) + (z * x))\n\n_DistributesOver_ : Op₂ A → Op₂ A → Set _\n* DistributesOver + = (* DistributesOverˡ +) × (* DistributesOverʳ +)\n\n_IdempotentOn_ : Op₂ A → A → Set _\n_∙_ IdempotentOn x = (x ∙ x) ≈ x\n\nIdempotent : Op₂ A → Set _\nIdempotent ∙ = ∀ x → ∙ IdempotentOn x\n\nIdempotentFun : Op₁ A → Set _\nIdempotentFun f = ∀ x → f (f x) ≈ f x\n\n_Absorbs_ : Op₂ A → Op₂ A → Set _\n_∙_ Absorbs _∘_ = ∀ x y → (x ∙ (x ∘ y)) ≈ x\n\nAbsorptive : Op₂ A → Op₂ A → Set _\nAbsorptive ∙ ∘ = (∙ Absorbs ∘) × (∘ Absorbs ∙)\n\nInvolutive : Op₁ A → Set _\nInvolutive f = ∀ x → f (f x) ≈ x\n", "meta": {"hexsha": "1d49422474c1181033fb9d7678a311a3ff552f56", "size": 2462, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Algebra/FunctionProperties.agda", "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_issues_repo_path": "agda-stdlib-0.9/src/Algebra/FunctionProperties.agda", "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib-0.9/src/Algebra/FunctionProperties.agda", "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.3555555556, "max_line_length": 72, "alphanum_fraction": 0.5296506905, "num_tokens": 866, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9381240090865197, "lm_q2_score": 0.8056321843145404, "lm_q1q2_score": 0.7557828945982866}} {"text": "module EqTest where\n\nimport Common.Level\n\ndata _≡_ {a : Set} (x : a) : a -> Set where\n refl : x ≡ x\n\ndata Maybe (a : Set) : Set where\n just : a -> Maybe a\n nothing : Maybe a\n\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ -> ℕ\n\n_≟_ : (x y : ℕ) -> Maybe (x ≡ y)\nsuc m ≟ suc n with m ≟ n\nsuc .n ≟ suc n | just refl = just refl\nsuc m ≟ suc n | nothing = nothing\nzero ≟ suc _ = nothing\nsuc m ≟ zero = nothing\nzero ≟ zero = just refl\n", "meta": {"hexsha": "e22fe438ed9c66f9a8e98ca4fe14a2b19a8109f1", "size": 446, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/succeed/EqTest.agda", "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z", "max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z", "max_issues_repo_path": "test/succeed/EqTest.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/succeed/EqTest.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 19.3913043478, "max_line_length": 43, "alphanum_fraction": 0.5538116592, "num_tokens": 177, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9407897558991952, "lm_q2_score": 0.8031737987125613, "lm_q1q2_score": 0.7556176820354199}} {"text": "module nat where\n\ndata N : Set where\n zero : N\n suc : N -> N\n\n_+_ : N -> N -> N\nn + zero = n\nn + (suc m) = suc (n + m)\n\n_*_ : N -> N -> N\nn * zero = zero\nn * (suc m) = (m * n) + m\n", "meta": {"hexsha": "034e4c86817c034e57fbeaab49991c282c3212b9", "size": 183, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "nat.agda", "max_stars_repo_name": "uedatakumi/nat", "max_stars_repo_head_hexsha": "2f064f660d6f3ce5fc3e5b05e8f096fa4b26c717", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-06-02T15:31:17.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-02T15:31:17.000Z", "max_issues_repo_path": "nat.agda", "max_issues_repo_name": "uedatakumi/nat", "max_issues_repo_head_hexsha": "2f064f660d6f3ce5fc3e5b05e8f096fa4b26c717", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "nat.agda", "max_forks_repo_name": "uedatakumi/nat", "max_forks_repo_head_hexsha": "2f064f660d6f3ce5fc3e5b05e8f096fa4b26c717", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 13.0714285714, "max_line_length": 25, "alphanum_fraction": 0.4371584699, "num_tokens": 83, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9783846691281406, "lm_q2_score": 0.7718434978390746, "lm_q1q2_score": 0.7551598452519896}} {"text": "{-# OPTIONS --allow-unsolved-metas #-}\n\nopen import Tutorials.Monday-Complete\nmodule Tutorials.Tuesday where\n\n-----------\n-- Pi and Sigma types\n-----------\n\nmodule Product where\n -- The open keyword opens a given module in the current namespace\n -- By default all of the public names of the module are opened\n -- The using keyword limits the imported definitions to those explicitly listed\n open Fin\n open Vec using (Vec; []; _∷_)\n open Simple using (¬_)\n\n variable\n P Q : A → Set\n\n -- Pi types: dependent function types\n -- For every x of type A, the predicate P x holds\n Π : (A : Set) → (Pred A) → Set\n Π A P = (x : A) → P x\n\n infix 5 _,_\n -- Sigma types: dependent product types, existential types\n -- For this x of type A, the predicate P x holds\n record Σ (A : Set) (P : Pred A) : Set where\n -- In the type P fst, fst refers to a previously introduced field\n constructor _,_\n field\n fst : A\n snd : P fst\n\n open Σ public\n\n -- By depending on a boolean we can use pi types to represent product types\n Π-× : Set → Set → Set\n Π-× A B = Π Bool λ where\n true → A\n false → B\n\n -- By depending on a boolean we can use sigma types to represent sum types\n Σ-⊎ : Set → Set → Set\n Σ-⊎ A B = Σ Bool λ where\n true → A\n false → B\n\n -- Use pi types to recover function types\n Π-→ : Set → Set → Set\n Π-→ A B = Π A λ where\n _ → B\n\n -- Use sigma types to recover product types\n Σ-× : Set → Set → Set\n Σ-× A B = Σ A λ where\n _ → B\n\n infix 5 _×_\n _×_ : Set → Set → Set\n _×_ = Σ-×\n\n -- 1) If we can transform the witness and\n -- 2) transform the predicate as per the transformation on the witness\n -- ⇒) then we can transform a sigma type\n map : (f : A → B) → (∀ {x} → P x → Q (f x)) → (Σ A P → Σ B Q)\n map f g (x , y) = (f x , g y)\n\n -- The syntax keyword introduces notation that can include binders\n infix 4 Σ-syntax\n Σ-syntax : (A : Set) → (A → Set) → Set\n Σ-syntax = Σ\n syntax Σ-syntax A (λ x → B) = Σ[ x ∈ A ] B\n\n ¬∘ : Pred A → Pred A\n ¬∘ P = ¬_ ∘ P\n\n -- These can be proven regardless of A\n\n ¬∃⇒∀¬ : ¬ (Σ A P) → Π A (¬∘ P)\n ¬∃⇒∀¬ = {!!}\n\n ∃¬⇒¬∀ : Σ A (¬∘ P) → ¬ Π A P\n ∃¬⇒¬∀ = {!!}\n\n ∀¬⇒¬∃ : Π A (¬∘ P) → ¬ Σ A P\n ∀¬⇒¬∃ = {!!}\n\n -- Works in classical, not in constructive mathematics\n postulate ¬∀⇒∃¬ : ¬ Π A P → Σ A (¬∘ P)\n\n -- Show that ≤ is antisymmetric\n ≤-≡ : n ≤ m → m ≤ n → n ≡ m\n ≤-≡ x y = {!!}\n\n -- By using n ≤ m instead of Fin m we can mention n in the output\n take : Vec A m → n ≤ m → Vec A n\n take xs lte = {!!}\n\n Fin-to-≤ : (i : Fin m) → to-ℕ i < m\n Fin-to-≤ i = {!!}\n\n -- Proof combining sigma types and equality\n ≤-to-Fin : n < m → Fin m\n ≤-to-Fin lt = {!!}\n\n Fin-≤-inv : (i : Fin m) → ≤-to-Fin (Fin-to-≤ i) ≡ i\n Fin-≤-inv i = {!!}\n\n ≤-Fin-inv : (lt : Σ[ n ∈ ℕ ] n < m)\n → (to-ℕ (≤-to-Fin (snd lt)) , Fin-to-≤ (≤-to-Fin (snd lt))) ≡ lt\n ≤-Fin-inv lt = {!!}\n", "meta": {"hexsha": "564f8167f1258e2ffa46bf5fbfb33ad66725075c", "size": 2891, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Tutorials/Tuesday.agda", "max_stars_repo_name": "poncev/agda-bcam", "max_stars_repo_head_hexsha": "ccd2a78642e93754011deffbe85e9ef5071e4cb7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 27, "max_stars_repo_stars_event_min_datetime": "2021-09-23T17:59:21.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-03T22:53:51.000Z", "max_issues_repo_path": "Tutorials/Tuesday.agda", "max_issues_repo_name": "poncev/agda-bcam", "max_issues_repo_head_hexsha": "ccd2a78642e93754011deffbe85e9ef5071e4cb7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Tutorials/Tuesday.agda", "max_forks_repo_name": "poncev/agda-bcam", "max_forks_repo_head_hexsha": "ccd2a78642e93754011deffbe85e9ef5071e4cb7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-11-23T08:50:13.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-24T10:50:55.000Z", "avg_line_length": 25.3596491228, "max_line_length": 81, "alphanum_fraction": 0.5468695953, "num_tokens": 1099, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9343951680216529, "lm_q2_score": 0.8080672135527632, "lm_q1q2_score": 0.755054099780423}} {"text": "module reverse-++-distrib where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl; sym; cong)\nopen Eq.≡-Reasoning\nopen import lists using (List; []; _∷_; [_]; _++_; ++-assoc; ++-identityʳ; reverse)\n\n-- 結合したリストの逆順は、逆順にしたリストの逆順の結合と等しいことの証明\nreverse-++-distrib : ∀ {A : Set} → (xs ys : List A)\n → reverse (xs ++ ys) ≡ reverse ys ++ reverse xs\nreverse-++-distrib [] ys =\n begin\n reverse ([] ++ ys)\n ≡⟨⟩\n reverse ys\n ≡⟨ sym (++-identityʳ (reverse ys)) ⟩\n reverse ys ++ []\n ≡⟨⟩\n reverse ys ++ reverse []\n ∎\nreverse-++-distrib (x ∷ xs) ys =\n begin\n reverse (x ∷ xs ++ ys)\n ≡⟨⟩\n reverse (xs ++ ys) ++ [ x ]\n ≡⟨ cong (_++ [ x ]) (reverse-++-distrib xs ys) ⟩\n (reverse ys ++ reverse xs) ++ [ x ]\n ≡⟨ ++-assoc (reverse ys) (reverse xs) [ x ] ⟩\n reverse ys ++ (reverse xs ++ [ x ])\n ≡⟨⟩\n reverse ys ++ reverse (x ∷ xs)\n ∎\n", "meta": {"hexsha": "443635d03c57db39e921481c794cd9f0f6f40d92", "size": 875, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "part1/lists/reverse-++-distrib.agda", "max_stars_repo_name": "akiomik/plfa-solutions", "max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z", "max_issues_repo_path": "part1/lists/reverse-++-distrib.agda", "max_issues_repo_name": "akiomik/plfa-solutions", "max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "part1/lists/reverse-++-distrib.agda", "max_forks_repo_name": "akiomik/plfa-solutions", "max_forks_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.5151515152, "max_line_length": 83, "alphanum_fraction": 0.5565714286, "num_tokens": 355, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9489172601537141, "lm_q2_score": 0.7956581024858785, "lm_q1q2_score": 0.755013706630003}} {"text": "{-# OPTIONS --safe #-}\nmodule Cubical.Algebra.Monoid.Instances.NatVec where\n\nopen import Cubical.Foundations.Prelude\n\nopen import Cubical.Data.Nat using (ℕ ; isSetℕ)\nopen import Cubical.Data.Vec\nopen import Cubical.Data.Vec.OperationsNat\n\nopen import Cubical.Algebra.Monoid\n\n\nNatVecMonoid : (n : ℕ) → Monoid ℓ-zero\nfst (NatVecMonoid n) = Vec ℕ n\nMonoidStr.ε (snd (NatVecMonoid n)) = replicate 0\nMonoidStr._·_ (snd (NatVecMonoid n)) = _+n-vec_\nMonoidStr.isMonoid (snd (NatVecMonoid n)) = makeIsMonoid (VecPath.isOfHLevelVec 0 n isSetℕ)\n +n-vec-assoc +n-vec-rid +n-vec-lid\n", "meta": {"hexsha": "ff2a19041e3af9025ac1b31295ae66a8304a1639", "size": 625, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/Monoid/Instances/NatVec.agda", "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/Monoid/Instances/NatVec.agda", "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/Monoid/Instances/NatVec.agda", "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.8947368421, "max_line_length": 91, "alphanum_fraction": 0.688, "num_tokens": 201, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9489172615983308, "lm_q2_score": 0.7956580903722561, "lm_q1q2_score": 0.7550136962845985}} {"text": "{-# OPTIONS --type-in-type #-} -- yes, I will let you cheat in this exercise\n{-# OPTIONS --allow-unsolved-metas #-} -- allows import, unfinished\n\n------------------------------------------------------------------------------\n------------------------------------------------------------------------------\n-- CS410 2017/18 Exercise 3 WINDOWS AND OTHER STORIES (worth 25%)\n------------------------------------------------------------------------------\n------------------------------------------------------------------------------\n\n------------------------------------------------------------------------------\n-- Dependencies\n------------------------------------------------------------------------------\n\nopen import CS410-Prelude\nopen import CS410-Categories\nopen import Ex2\n\n\n------------------------------------------------------------------------------\n-- PART I: Splittings\n------------------------------------------------------------------------------\n\n-- The type ls <[ ms ]> rs\n-- is similar to that found in Lec2.agda, but it works on lists, not numbers.\n-- It provides the evidence that a list ms can be split into a left sublist ls\n-- and a right sublist rs. In effect, it's a vector of bits that say which\n-- elements of ms go left and which go right.\n\ndata _<[_]>_ {X : Set} : List X -> List X -> List X -> Set where\n sz : [] <[ [] ]> []\n sl : forall {l ls ms rs} -> ls <[ ms ]> rs -> (l ,- ls) <[ l ,- ms ]> rs\n sr : forall {r ls ms rs} -> ls <[ ms ]> rs -> ls <[ r ,- ms ]> (r ,- rs)\n\n\n--??--3.1---------------------------------------------------------------------\n\n-- Adapt _>[_]<_ from Lec2 to work for All. Given a P for each element of\n-- ls and rs, riffle them together to get Ps for all the ms.\n\n_>[_]<_ : {X : Set}{ls ms rs : List X} -> {P : X -> Set} ->\n All P ls -> ls <[ ms ]> rs -> All P rs ->\n All P ms\npl >[ s ]< pr = {!!}\n\n-- Now, buikd the view that shows riffling can be inverted, using a splitting\n-- as the instructions to discover how to split an All in two.\n\ndata IsRiffle {X : Set}{ls ms rs : List X}(s : ls <[ ms ]> rs){P : X -> Set}\n : All P ms -> Set where\n mkRiffle : (pl : All P ls)(pr : All P rs) -> IsRiffle s (pl >[ s ]< pr)\n \nisRiffle : {X : Set}{ls ms rs : List X}(s : ls <[ ms ]> rs)\n {P : X -> Set}(pm : All P ms) -> IsRiffle s pm\nisRiffle s pm = {!!}\n\n--??--------------------------------------------------------------------------\n\n\n--??--3.2---------------------------------------------------------------------\n\n-- Construct the \"all on the right\" splitting.\n\nsrs : forall {X : Set}{xs : List X} -> [] <[ xs ]> xs\nsrs = {!!}\n\n-- Construct a view to show that any \"none on the left\" splitting is\n-- \"all on the right\". Come up with the type yourself.\n\n\n-- Construct the splitting that corresponds to concatenation.\n\nslrs : forall {X : Set}(xs ys : List X) -> xs <[ xs +L ys ]> ys\nslrs xs ys = {!!}\n\n--??--------------------------------------------------------------------------\n\n--??--3.3---------------------------------------------------------------------\n\n-- Invent other useful operations which transform splittings.\n-- You will need some to do later parts of the exercise, so maybe\n-- wait until you see what you need.\n\n-- I expect you will need at least something that takes a pair of splittings\n-- that make a tree, like\n--\n-- ms\n-- <[ ]>\n-- ls rs\n-- <[ ]>\n-- lrs rrs\n--\n-- and compute a \"rotated\" pair of splittings like\n--\n-- ms\n-- <[ ]>\n-- ?? rrs\n-- <[ ]>\n-- ls lrs\n\n-- HINT: Sg is your friend\n\n-- You'll probably need some other stuff, too.\n\n--??--------------------------------------------------------------------------\n\n\n------------------------------------------------------------------------------\n-- PART II: Permutations\n------------------------------------------------------------------------------\n\n-- When is one list a permutation of another?\n\ndata _~_ {X : Set} : List X -> List X -> Set where\n\n -- [] is a permutation of []\n [] : [] ~ []\n\n -- if xs ~ ys, then (x ,- xs) is a permutation of any list made by\n -- shoving x somewhere into ys\n _,-_ : forall {x xs ys' ys} ->\n (x ,- []) <[ ys' ]> ys ->\n xs ~ ys ->\n (x ,- xs) ~ ys'\n\n\n--??--3.4---------------------------------------------------------------------\n\n-- Show that every list is a permutation of itself.\n\nreflP : {X : Set}{xs : List X} -> xs ~ xs\nreflP = {!!}\n\n--??--------------------------------------------------------------------------\n\n\n--??--3.5---------------------------------------------------------------------\n\n-- Construct an \"unbiased\" insertion operator which lets you grow a\n-- permutation by inserting a new element anywhere, left and right\n\ninsP : forall {X : Set}{z : X}{xs xs' ys ys'} ->\n (z ,- []) <[ xs' ]> xs ->\n (z ,- []) <[ ys' ]> ys ->\n xs ~ ys -> xs' ~ ys'\ninsP l r p = {!!}\n\n-- Now show that, given a permutation, and any element on the left,\n-- you can find out where it ended up on the right, and why the\n-- remaining elements form a permutation.\n\nfindLonR : forall {X : Set}{z : X}{xs xs' ys'} ->\n (z ,- []) <[ xs' ]> xs ->\n xs' ~ ys' ->\n {!!}\nfindLonR l p = {!!}\n\n-- HINT: again, you may need Sg to give a sensible return type.\n\n--??--------------------------------------------------------------------------\n\n\n--??--3.6---------------------------------------------------------------------\n\n-- Show that permutation is transitive.\n\ntransP : {X : Set}{xs ys zs : List X} -> xs ~ ys -> ys ~ zs -> xs ~ zs\ntransP p q = {!!}\n\n-- HINT: you will need to define some useful operations on splittings to\n-- get this to work.\n\n-- HINT: this may help you figure out what you need for findLonR\n\n-- For a small bonus, show that permutations are the morphisms of a\n-- Category.\n\n-- Show that permutation is symmetric.\n\nsymP : {X : Set}{xs ys : List X} -> xs ~ ys -> ys ~ xs\nsymP p = {!!}\n\n-- A category where all morphisms are invertible is called a \"groupoid\".\n\n--??--------------------------------------------------------------------------\n\n\n--??--3.7---------------------------------------------------------------------\n\n-- Make permutations act on All.\n\npermute : {X : Set}{xs ys : List X} -> xs ~ ys ->\n {Q : X -> Set} -> All Q xs -> All Q ys\n\npermute p qs = {!!}\n\n--??--------------------------------------------------------------------------\n\n\n\n-- MORE TO FOLLOW\n", "meta": {"hexsha": "3534de0eff1bef19987253152ef623b54cec9593", "size": 6560, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Ex3.agda", "max_stars_repo_name": "m-schmidt/CS410-17-Exercises", "max_stars_repo_head_hexsha": "5db8e95bbcbe8dc0eec810f3e73130ecd78d207c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Ex3.agda", "max_issues_repo_name": "m-schmidt/CS410-17-Exercises", "max_issues_repo_head_hexsha": "5db8e95bbcbe8dc0eec810f3e73130ecd78d207c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Ex3.agda", "max_forks_repo_name": "m-schmidt/CS410-17-Exercises", "max_forks_repo_head_hexsha": "5db8e95bbcbe8dc0eec810f3e73130ecd78d207c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.6368159204, "max_line_length": 78, "alphanum_fraction": 0.3972560976, "num_tokens": 1503, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8902942290328344, "lm_q2_score": 0.8479677602988602, "lm_q1q2_score": 0.754940803399973}} {"text": "module map-++-distribute where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl; cong)\nopen Eq.≡-Reasoning\nopen import lists using (List; []; _∷_; _++_; map)\n\n-- リストの結合に関するmapの分配法則の証明\nmap-++-distribute : {A B : Set} → (f : A → B) → (xs ys : List A)\n → map f (xs ++ ys) ≡ map f xs ++ map f ys\nmap-++-distribute f [] ys =\n begin\n map f ([] ++ ys)\n ≡⟨⟩\n map f ys\n ≡⟨⟩\n map f [] ++ map f ys\n ∎\nmap-++-distribute f (x ∷ xs) ys =\n begin\n map f ((x ∷ xs) ++ ys)\n ≡⟨⟩\n f x ∷ map f (xs ++ ys)\n ≡⟨ cong (f x ∷_) (map-++-distribute f xs ys) ⟩\n f x ∷ map f xs ++ map f ys\n ≡⟨⟩\n map f (x ∷ xs) ++ map f ys\n ∎\n", "meta": {"hexsha": "fe56b00ced79c4a2a5fe6271f61e97095f15a3c6", "size": 655, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "part1/lists/map-++-distribute.agda", "max_stars_repo_name": "akiomik/plfa-solutions", "max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z", "max_issues_repo_path": "part1/lists/map-++-distribute.agda", "max_issues_repo_name": "akiomik/plfa-solutions", "max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "part1/lists/map-++-distribute.agda", "max_forks_repo_name": "akiomik/plfa-solutions", "max_forks_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.5862068966, "max_line_length": 64, "alphanum_fraction": 0.5267175573, "num_tokens": 292, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9314625145783428, "lm_q2_score": 0.8104789155369047, "lm_q1q2_score": 0.7549307286787336}} {"text": "{-# OPTIONS --sized-types #-}\nmodule BBHeap.Height {A : Set}(_≤_ : A → A → Set) where\n\nopen import BBHeap _≤_ hiding (#)\nopen import Bound.Lower A \nopen import Bound.Lower.Order _≤_\nopen import SNat\n\n# : {b : Bound} → BBHeap b → SNat\n# leaf = zero\n# (left {l = l} {r = r} _ _) = succ (# l + # r)\n# (right {l = l} {r = r} _ _) = succ (# l + # r)\n\nheight : {b : Bound} → BBHeap b → SNat\nheight leaf = zero\nheight (left {l = l} _ _) = succ (height l)\nheight (right {l = l} _ _) = succ (height l)\n\n#' : {b : Bound} → BBHeap b → SNat\n#' leaf = zero\n#' (left {r = r} _ _) = succ (#' r + #' r)\n#' (right {r = r} _ _) = succ (#' r + #' r)\n\nheight' : {b : Bound} → BBHeap b → SNat\nheight' leaf = zero\nheight' (left {r = r} _ _) = succ (height' r)\nheight' (right {r = r} _ _) = succ (height' r)\n\n\n", "meta": {"hexsha": "8b43eba04cbad30261357ffd41b04d83bf5cf7cc", "size": 788, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/BBHeap/Height.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/BBHeap/Height.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/BBHeap/Height.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.2666666667, "max_line_length": 55, "alphanum_fraction": 0.5393401015, "num_tokens": 297, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9546474168650673, "lm_q2_score": 0.7905303236047049, "lm_q1q2_score": 0.7546777313827372}} {"text": "module List.Order.Bounded.Properties {A : Set} \n (_≤_ : A → A → Set) \n (trans≤ : {x y z : A} → x ≤ y → y ≤ z → x ≤ z) where\n\nopen import Bound.Total A\nopen import Bound.Total.Order _≤_\nopen import Bound.Total.Order.Properties _≤_ trans≤\nopen import Data.List\nopen import List.Order.Bounded _≤_\nopen import List.Sorted _≤_\n\nlemma-sorted++ : {x : A}{xs ys : List A} → xs ≤* (val x) → (val x) *≤ ys → Sorted xs → Sorted ys → Sorted (xs ++ (x ∷ ys))\nlemma-sorted++ {x = x} lenx genx _ _ = singls x\nlemma-sorted++ lenx (gecx u≤y _) _ sys = conss (lemma-LeB≤ u≤y) sys\nlemma-sorted++ (lecx x≤u xs≤*u) u*≤ys (singls x) sys = conss (lemma-LeB≤ x≤u) (lemma-sorted++ xs≤*u u*≤ys nils sys)\nlemma-sorted++ (lecx x≤u xs≤*u) u*≤ys (conss x≤z sxs) sys = conss x≤z (lemma-sorted++ xs≤*u u*≤ys sxs sys)\n\nlemma-++≤* : {t : Bound}{x : A}{xs ys : List A} → LeB (val x) t → xs ≤* (val x) → ys ≤* t → (xs ++ (x ∷ ys)) ≤* t\nlemma-++≤* u≤t lenx ys≤*t = lecx u≤t ys≤*t\nlemma-++≤* u≤t (lecx x≤u xs≤*u) ys≤*u = lecx (transLeB x≤u u≤t) (lemma-++≤* u≤t xs≤*u ys≤*u)\n\nlemma-*≤ : {b : Bound}{x : A}{xs : List A} → LeB b (val x) → (val x) *≤ xs → b *≤ xs\nlemma-*≤ _ genx = genx\nlemma-*≤ b≤u (gecx u≤x u*≤xs) = gecx (transLeB b≤u u≤x) (lemma-*≤ b≤u u*≤xs)\n\nlemma-++*≤ : {b : Bound}{x : A}{xs ys : List A} → LeB b (val x) → b *≤ xs → (val x) *≤ ys → b *≤ (xs ++ (x ∷ ys))\nlemma-++*≤ b≤u genx u*≤ys = gecx b≤u (lemma-*≤ b≤u u*≤ys)\nlemma-++*≤ b≤u (gecx b≤x b*≤xs) u*≤ys = gecx b≤x (lemma-++*≤ b≤u b*≤xs u*≤ys)\n", "meta": {"hexsha": "5aacdd88f68bdd9ae07d1da0a3d3d1944e17c4a9", "size": 1510, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/List/Order/Bounded/Properties.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/List/Order/Bounded/Properties.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/List/Order/Bounded/Properties.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 52.0689655172, "max_line_length": 122, "alphanum_fraction": 0.540397351, "num_tokens": 743, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9284087985746092, "lm_q2_score": 0.8128673246376009, "lm_q1q2_score": 0.754673176267352}} {"text": "module trichotomy where\n\nopen import Relation.Binary.PropositionalEquality using (_≡_; refl)\nopen import Data.Nat using (ℕ; zero; suc)\nopen import Data.Sum using (_⊎_; inj₁; inj₂)\nopen import Data.Product using (_×_) renaming (_,_ to ⟨_,_⟩)\n\nopen import Negation using (¬_; _≢_)\n\ninfix 4 _<_\ndata _<_ : ℕ → ℕ → Set where\n z List A -> List A\n\ninfixr 50 _::_\n\n-- non-deterministic choice\npostulate\n _⊕_ : {A : Set} -> A -> A -> A \ninfixl 10 _⊕_\n\n-- a funny formulation of insert\n-- insert (a :: l) inserts a into l \n--\n-- this example cannot be handled with subpatterns\n-- it is done with structured orders\n-- could also be done with sized types\n\ninsert : {A : Set} -> List A -> List A\ninsert [] = []\ninsert (a :: []) = a :: []\ninsert (a :: b :: bs) = a :: b :: bs ⊕ -- case a <= b \n b :: insert (a :: bs) -- case a > b\n\n\n-- list flattening\n-- termination using structured orders\nflat : {A : Set} -> List (List A) -> List A\nflat [] = []\nflat ([] :: ll) = flat ll\nflat ((x :: l) :: ll) = x :: flat (l :: ll)\n\n{- generates two recursive calls with the following call matrices\n\n \n [] :: ll (x :: l) ll \n \n ll < l < . \n ll . =\n\nduring composition, the second is collapsed to =, so the call graph is\nalready complete. Both matrices are idempotent and contain a strictly\ndecreasing argument. \n\nIt could also be done with sized types; lexicographic in (i,j)\nwith type\n\n flat : {A : Set} -> (1 + Listʲ A × List^i (List^∞ A)) -> List^∞ A\n\n\n-}\n", "meta": {"hexsha": "2e258e4904583087ad01650a12c3bdc30b499544", "size": 1374, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/succeed/TerminationListInsertionNaive.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "test/succeed/TerminationListInsertionNaive.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/succeed/TerminationListInsertionNaive.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.4444444444, "max_line_length": 70, "alphanum_fraction": 0.5349344978, "num_tokens": 394, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9173026550642019, "lm_q2_score": 0.822189121808099, "lm_q1q2_score": 0.7541962643994737}} {"text": "\nmodule Naturals where\n\ndata Nat : Set where\n zero : Nat\n suc : Nat -> Nat\n\ninfixl 60 _+_\ninfixl 80 _*_\n\n_+_ : Nat -> Nat -> Nat\nzero + m = m\nsuc n + m = suc (n + m)\n\n_*_ : Nat -> Nat -> Nat\nzero * m = zero\nsuc n * m = m + n * m\n\n{-# BUILTIN NATURAL Nat #-}\n{-# BUILTIN ZERO zero #-}\n{-# BUILTIN SUC suc #-}\n{-# BUILTIN NATPLUS _+_ #-}\n{-# BUILTIN NATTIMES _*_ #-}\n", "meta": {"hexsha": "8f4174eb590c0e79741d3b7a20625a278e88d9e5", "size": 385, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/AIM6/HelloAgda/Naturals.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/AIM6/HelloAgda/Naturals.agda", "max_issues_repo_name": "np/agda-git-experiment", "max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/AIM6/HelloAgda/Naturals.agda", "max_forks_repo_name": "np/agda-git-experiment", "max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 16.0416666667, "max_line_length": 29, "alphanum_fraction": 0.5272727273, "num_tokens": 142, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9539660923657094, "lm_q2_score": 0.79053032607222, "lm_q1q2_score": 0.7541391260597058}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Quiver where\n\n-- A Quiver, also known as a multidigraph, is the \"underlying graph\" of\n-- a category. Note how a Quiver has a *setoid* of edges.\n\nopen import Level\nopen import Relation.Binary using (Rel; IsEquivalence; Setoid)\nimport Relation.Binary.Reasoning.Setoid as EqR\n\n-- a Quiver has vertices Obj and edges _⇒_, where edges form a setoid over _≈_.\nrecord Quiver o ℓ e : Set (suc (o ⊔ ℓ ⊔ e)) where\n infix 4 _≈_ _⇒_\n\n field\n Obj : Set o\n _⇒_ : Rel Obj ℓ\n _≈_ : ∀ {A B} → Rel (A ⇒ B) e\n equiv : ∀ {A B} → IsEquivalence (_≈_ {A} {B})\n\n setoid : {A B : Obj} → Setoid _ _\n setoid {A} {B} = record\n { Carrier = A ⇒ B\n ; _≈_ = _≈_\n ; isEquivalence = equiv\n }\n\n module Equiv {A B : Obj} = IsEquivalence (equiv {A} {B})\n module EdgeReasoning {A B : Obj} = EqR (setoid {A} {B})\n", "meta": {"hexsha": "3d262a18d164c441c2b1be348ecbf528128f7a4b", "size": 874, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/Quiver.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Data/Quiver.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Data/Quiver.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 28.1935483871, "max_line_length": 79, "alphanum_fraction": 0.6018306636, "num_tokens": 316, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9304582554941718, "lm_q2_score": 0.8104789018037399, "lm_q1q2_score": 0.7541167850871401}} {"text": "{-# OPTIONS --sized-types #-}\nopen import Relation.Binary.Core\n\nmodule SelectSort {A : Set}\n (_≤_ : A → A → Set)\n (tot≤ : Total _≤_) where\n\nopen import Data.List\nopen import Data.Product\nopen import Data.Sum\nopen import Size\nopen import SList\nopen import SList.Order _≤_\n\nselect : {ι : Size} → A → SList A {ι} → A × SList A {ι}\nselect x snil = (x , snil)\nselect x (y ∙ ys) \n with tot≤ x y\n... | inj₁ x≤y \n with select x ys \nselect x (y ∙ ys) | inj₁ x≤y | (z , zs) = (z , y ∙ zs)\nselect x (y ∙ ys) | inj₂ y≤x \n with select y ys\nselect x (y ∙ ys) | inj₂ y≤x | (z , zs) = (z , x ∙ zs) \n\nselectSort : {ι : Size} → SList A {ι} → SList A {ι}\nselectSort snil = snil\nselectSort (x ∙ xs) \n with select x xs\n... | (y , ys) = y ∙ (selectSort ys)\n", "meta": {"hexsha": "ce2bfa5f1dd162215019bea1130537f74663d5d0", "size": 784, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/SelectSort.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/SelectSort.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/SelectSort.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.2903225806, "max_line_length": 56, "alphanum_fraction": 0.5599489796, "num_tokens": 294, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9504109770159683, "lm_q2_score": 0.7931059585194573, "lm_q1q2_score": 0.7537766089136635}} {"text": "\nmodule Vec where\n\nopen import Star\nopen import Nat\n\ndata Step (A : Set) : Nat -> Nat -> Set where\n step : (x : A){n : Nat} -> Step A (suc n) n\n\nVec : (A : Set) -> Nat -> Set\nVec A n = Star (Step A) n zero\n\n[] : {A : Set} -> Vec A zero\n[] = ε\n\n_::_ : {A : Set}{n : Nat} -> A -> Vec A n -> Vec A (suc n)\nx :: xs = step x • xs\n\n_+++_ : {A : Set}{n m : Nat} -> Vec A n -> Vec A m -> Vec A (n + m)\n_+++_ {A}{m = m} xs ys = map +m step+m xs ++ ys\n where\n +m = \\z -> z + m\n step+m : Step A =[ +m ]=> Step A\n step+m (step x) = step x\n\nvec : {A : Set}{n : Nat} -> A -> Vec A n\nvec {n = ε} x = []\nvec {n = _ • n} x = x :: vec x\n\n_⊗_ : {A B : Set}{n : Nat} -> Vec (A -> B) n -> Vec A n -> Vec B n\nε ⊗ ε = []\n(step f • fs) ⊗ (step x • xs) = f x :: (fs ⊗ xs)\nε ⊗ (() • _)\n\n{- Some proof about _-_ needed...\n\nvreverse : {A : Set}{n : Nat} -> Vec A n -> Vec A n\nvreverse {A}{n} xs = {! !} -- map i f (reverse xs)\n where\n i : Nat -> Nat\n i m = n - m\n\n f : Step A op =[ i ]=> Step A\n f (step x) = {! !} -- step x\n-}", "meta": {"hexsha": "2585f460b73926fc88d2a8519873e79b08b54ddc", "size": 1063, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/AIM6/Path/Vec.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/AIM6/Path/Vec.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/AIM6/Path/Vec.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.6222222222, "max_line_length": 67, "alphanum_fraction": 0.4289746002, "num_tokens": 427, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9353465170505204, "lm_q2_score": 0.8056321913146128, "lm_q1q2_score": 0.7535452641699016}} {"text": "module Relation.Relation where\n\nopen import Level renaming (suc to lsuc)\nopen import Data.Product\n\n-- Partial equivalence relations.\nrecord ParRel {l l' : Level}{A : Set l}(R : A → A → Set l') : Set (l ⊔ l') where\n field\n symPf : ∀{x y} → R x y → R y x\n transPf : ∀{x y z} → R x y → R y z → R x z\n\n-- (Total) equivalence relation. \nrecord EqRel {l l' : Level}{A : Set l}(R : A → A → Set l') : Set (l ⊔ l') where\n field\n parEqPf : ParRel R\n refPf : ∀{x} → R x x\n\nopen ParRel public\nopen EqRel public\n\n-- The product of two relations.\nProductRel : {l l' : Level}{A : Set l}{B : Set l'} \n → (R : A → A → Set l) \n → (R' : B → B → Set l') \n → (A × B → A × B → Set (l ⊔ l'))\nProductRel R R' a b = (R (proj₁ a) (proj₁ b)) × (R' (proj₂ a) (proj₂ b))\n\n-- The product of two partial equivalence relations is also a partial\n-- equivalence relation.\nProductRelIsParRel : {l l' : Level}{A : Set l}{B : Set l'} \n → (R : A → A → Set l) \n → (R' : B → B → Set l') \n → ParRel R\n → ParRel R'\n → ParRel (ProductRel R R')\nProductRelIsParRel R R' erPF₁ erPF₂ = \n record { symPf = λ x₁ → symPf erPF₁ (proj₁ x₁) , symPf erPF₂ (proj₂ x₁); \n transPf = λ x₁ x₂ → (transPf erPF₁ (proj₁ x₁) (proj₁ x₂)) , (transPf erPF₂ (proj₂ x₁) (proj₂ x₂)) }\n\n-- The product of two (total) equivalence relations is also a (total)\n-- equivalence relation.\nProductRelIsEqRel : {l l' : Level}{A : Set l}{B : Set l'} \n → (R : A → A → Set l) \n → (R' : B → B → Set l') \n → EqRel R\n → EqRel R'\n → EqRel (ProductRel R R')\nProductRelIsEqRel R R' erPF₁ erPF₂ = \n record { parEqPf = ProductRelIsParRel R R' (parEqPf erPF₁) (parEqPf erPF₂); \n refPf = λ {x} → (refPf erPF₁ {proj₁ x}) , (refPf erPF₂ {proj₂ x}) }\n\n-- The restriction of a relation by a predicate.\n_↓_ : {l l' : Level}\n {A : Set l} \n → (R : A → A → Set l) \n → (P : A → Set l') \n → Set (l ⊔ l')\n_↓_ {A = A} R P = Σ[ f ∈ A ] (P f)\n\n-- The restriction of a paritial equivalence is also a partial\n-- equivalence.\n↓ParRel : {l l' : Level}\n {A : Set l} \n → (R : A → A → Set l) \n → (P : A → Set l') \n → ParRel R\n → ParRel (λ (f g : R ↓ P) → R (proj₁ f) (proj₁ g))\n↓ParRel R P prPF = record { symPf = λ x₁ → symPf prPF x₁; transPf = λ x₁ x₂ → transPf prPF x₁ x₂ }\n\n-- The restriction of an equivalence relation is also an equivalence\n-- relation.\n↓EqRel : {l l' : Level}\n {A : Set l} \n → (R : A → A → Set l) \n → (P : A → Set l') \n → EqRel R\n → EqRel (λ (f g : R ↓ P) → R (proj₁ f) (proj₁ g))\n↓EqRel R P eqrPF = record { parEqPf = ↓ParRel R P (parEqPf eqrPF); refPf = refPf eqrPF }\n", "meta": {"hexsha": "78fbd97ac608303b619e98dbaf6660cf030c7ac1", "size": 2621, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "setoid-cats/Relation/Relation.agda", "max_stars_repo_name": "heades/AUGL", "max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "setoid-cats/Relation/Relation.agda", "max_issues_repo_name": "heades/AUGL", "max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "setoid-cats/Relation/Relation.agda", "max_forks_repo_name": "heades/AUGL", "max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.1772151899, "max_line_length": 110, "alphanum_fraction": 0.550553224, "num_tokens": 1023, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9111797148356995, "lm_q2_score": 0.8267117940706734, "lm_q1q2_score": 0.7532830167726258}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category\n\nmodule Categories.Diagram.Equalizer.Properties {o ℓ e} (C : Category o ℓ e) where\n\nopen import Categories.Diagram.Equalizer C\nopen import Categories.Morphism C\nopen import Categories.Morphism.Reasoning C\n\nprivate\n module C = Category C\n open C\n\n variable\n X Y Z : Obj\n f g : X ⇒ Y\n\nmodule _ (equalizer : Equalizer f g) where\n open Equalizer equalizer\n open HomReasoning\n\n equalizer-≈⇒≈ : ∀ {h} → arr ∘ h ≈ id → f ≈ g\n equalizer-≈⇒≈ {h} eq = begin\n f ≈⟨ introʳ eq ⟩\n f ∘ arr ∘ h ≈⟨ pullˡ equality ⟩\n (g ∘ arr) ∘ h ≈⟨ cancelʳ eq ⟩\n g ∎\n\nsection-equalizer : ∀ {X Y} {f : Y ⇒ X} {g : X ⇒ Y} → f SectionOf g → IsEqualizer f (f ∘ g) id\nsection-equalizer {X = X} {Y = Y} {f = f} {g = g} g∘f≈id = record\n { equality = equality\n ; equalize = equalize\n ; universal = λ {_} {_} {eq} → universal {eq = eq}\n ; unique = unique\n }\n where\n open HomReasoning\n\n equality : (f ∘ g) ∘ f ≈ id ∘ f\n equality = begin\n (f ∘ g) ∘ f ≈⟨ pullʳ g∘f≈id ⟩\n f ∘ id ≈⟨ id-comm ⟩\n id ∘ f ∎\n\n equalize : ∀ {Z} {h : Z ⇒ X} → (f ∘ g) ∘ h ≈ id ∘ h → Z ⇒ Y \n equalize {h = h} _ = g ∘ h\n\n universal : ∀ {Z} {h : Z ⇒ X} {eq : (f ∘ g) ∘ h ≈ id ∘ h} → h ≈ f ∘ g ∘ h\n universal {h = h} {eq = eq} = begin\n h ≈˘⟨ identityˡ ⟩\n id ∘ h ≈˘⟨ eq ⟩\n (f ∘ g) ∘ h ≈⟨ assoc ⟩\n f ∘ g ∘ h ∎\n\n unique : ∀ {Z} {h : Z ⇒ X} {i : Z ⇒ Y} → h ≈ f ∘ i → i ≈ g ∘ h\n unique {h = h} {i = i} h≈g∘i = begin\n i ≈⟨ introˡ g∘f≈id ⟩\n (g ∘ f) ∘ i ≈⟨ pullʳ (⟺ h≈g∘i) ⟩\n g ∘ h ∎\n", "meta": {"hexsha": "301c2131654ace3b2c9bb83fea497455df3fbb01", "size": 1647, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Diagram/Equalizer/Properties.agda", "max_stars_repo_name": "maxsnew/agda-categories", "max_stars_repo_head_hexsha": "8f3c844d929508040dfa21f681fa260056214b73", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Categories/Diagram/Equalizer/Properties.agda", "max_issues_repo_name": "maxsnew/agda-categories", "max_issues_repo_head_hexsha": "8f3c844d929508040dfa21f681fa260056214b73", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Diagram/Equalizer/Properties.agda", "max_forks_repo_name": "maxsnew/agda-categories", "max_forks_repo_head_hexsha": "8f3c844d929508040dfa21f681fa260056214b73", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.0, "max_line_length": 94, "alphanum_fraction": 0.4851244687, "num_tokens": 722, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9111797027760039, "lm_q2_score": 0.8267117876664789, "lm_q1q2_score": 0.7532830009673611}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Coinductive \"natural\" numbers\n------------------------------------------------------------------------\n\nmodule Data.Conat where\n\nopen import Coinduction\nopen import Data.Nat using (ℕ; zero; suc)\nopen import Relation.Binary\n\n------------------------------------------------------------------------\n-- The type\n\ndata Coℕ : Set where\n zero : Coℕ\n suc : (n : ∞ Coℕ) → Coℕ\n\n------------------------------------------------------------------------\n-- Some operations\n\nfromℕ : ℕ → Coℕ\nfromℕ zero = zero\nfromℕ (suc n) = suc (♯ fromℕ n)\n\n∞ℕ : Coℕ\n∞ℕ = suc (♯ ∞ℕ)\n\ninfixl 6 _+_\n\n_+_ : Coℕ → Coℕ → Coℕ\nzero + n = n\nsuc m + n = suc (♯ (♭ m + n))\n\n------------------------------------------------------------------------\n-- Equality\n\ndata _≈_ : Coℕ → Coℕ → Set where\n zero : zero ≈ zero\n suc : ∀ {m n} (m≈n : ∞ (♭ m ≈ ♭ n)) → suc m ≈ suc n\n\nsetoid : Setoid _ _\nsetoid = record\n { Carrier = Coℕ\n ; _≈_ = _≈_\n ; isEquivalence = record\n { refl = refl\n ; sym = sym\n ; trans = trans\n }\n }\n where\n refl : Reflexive _≈_\n refl {zero} = zero\n refl {suc n} = suc (♯ refl)\n\n sym : Symmetric _≈_\n sym zero = zero\n sym (suc m≈n) = suc (♯ sym (♭ m≈n))\n\n trans : Transitive _≈_\n trans zero zero = zero\n trans (suc m≈n) (suc n≈k) = suc (♯ trans (♭ m≈n) (♭ n≈k))\n", "meta": {"hexsha": "185e892390ce8b46d5a343286bffdfc5cc843fdf", "size": 1445, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Data/Conat.agda", "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_issues_repo_path": "agda-stdlib-0.9/src/Data/Conat.agda", "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib-0.9/src/Data/Conat.agda", "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.2307692308, "max_line_length": 72, "alphanum_fraction": 0.3937716263, "num_tokens": 468, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9407897525789547, "lm_q2_score": 0.8006919949619792, "lm_q1q2_score": 0.75328282383223}} {"text": "module 010-false-true where\n\n-- In Agda, types are theorems, and instances of types are proofs. The\n-- simplest theorem is the theorem which has no proof, and is useful\n-- to represent any contradictory situation. We declare False as an\n-- algebraic data type without constructors. If \"False\" has no\n-- constructors, then it also has no instances, and thereby perfectly\n-- serves our purpose. Note that what we call here \"False\" is also\n-- sometimes also called bottom and is denoted by ⊥.\n\ndata False : Set where\n\n-- The next simplest theorem is the trivial theorem which is always\n-- true. We declare it as an algebraic data type \"True\", with one\n-- constructor named \"trivial\".\n\ndata True : Set where\n trivial : True\n", "meta": {"hexsha": "16614eee8cbdc71d71e5accfe0a94b010beb8d36", "size": 722, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "010-false-true.agda", "max_stars_repo_name": "mcmtroffaes/agda-proofs", "max_stars_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2015-08-09T22:51:55.000Z", "max_stars_repo_stars_event_max_datetime": "2016-08-17T16:15:42.000Z", "max_issues_repo_path": "010-false-true.agda", "max_issues_repo_name": "mcmtroffaes/agda-proofs", "max_issues_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "010-false-true.agda", "max_forks_repo_name": "mcmtroffaes/agda-proofs", "max_forks_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.0, "max_line_length": 70, "alphanum_fraction": 0.7506925208, "num_tokens": 172, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9591542887603537, "lm_q2_score": 0.785308578375437, "lm_q1q2_score": 0.7532320909490967}} {"text": "module Numeral.Natural.Oper.FlooredDivision where\n\nimport Lvl\nopen import Data\nopen import Data.Boolean.Stmt\nopen import Logic.Propositional.Theorems\nopen import Numeral.Natural\nopen import Numeral.Natural.Oper.Comparisons\nopen import Numeral.Natural.Oper.Comparisons.Proofs\nopen import Numeral.Natural.Relation.Order\nopen import Relator.Equals\n\ninfixl 10100 _⌊/⌋_\n\n-- Inductive definition of an algorithm for division.\n-- `[ d , b ] a' div b'` should be interpreted as following:\n-- `d` is the result of the algorithm that is being incremented as it runs.\n-- `b` is the predecessor of the original denominator. This is constant throughout the whole process.\n-- `a'` is the numerator. This is decremented as it runs.\n-- `b'` is the predecessor of the temporary denominator. This is decremented as it runs.\n-- By decrementing both `a'` and `b'`, and incrementing `d` when 'b`' reaches 0, it counts how many times `b` \"fits into\" `a`. \n-- Note: See Numeral.Natural.Oper.Modulo for a similiar algorithm used to determine the modulo.\n[_,_]_div_ : ℕ → ℕ → ℕ → ℕ → ℕ\n[ d , _ ] 𝟎 div _ = d\n[ d , b ] 𝐒(a') div 𝟎 = [ 𝐒(d) , b ] a' div b\n[ d , b ] 𝐒(a') div 𝐒(b') = [ d , b ] a' div b'\n{-# BUILTIN NATDIVSUCAUX [_,_]_div_ #-}\n\n-- Floored division operation.\n_⌊/⌋_ : ℕ → (m : ℕ) → .⦃ _ : IsTrue(positive?(m)) ⦄ → ℕ\na ⌊/⌋ 𝐒(m) = [ 𝟎 , m ] a div m\n\n_⌊/⌋₀_ : ℕ → ℕ → ℕ\n_ ⌊/⌋₀ 𝟎 = 𝟎\na ⌊/⌋₀ 𝐒(m) = a ⌊/⌋ 𝐒(m)\n{-# INLINE _⌊/⌋₀_ #-}\n", "meta": {"hexsha": "520841b7d5d06549b07ff7c2f5b25b4be908a75d", "size": 1441, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Natural/Oper/FlooredDivision.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Numeral/Natural/Oper/FlooredDivision.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Numeral/Natural/Oper/FlooredDivision.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.9459459459, "max_line_length": 127, "alphanum_fraction": 0.6592643997, "num_tokens": 532, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9184802350995702, "lm_q2_score": 0.8198933293122507, "lm_q1q2_score": 0.7530558178632853}} {"text": "\nopen import Oscar.Prelude\nopen import Oscar.Class.Symmetry\nopen import Oscar.Class.Symmetrical\nimport Oscar.Data.Proposequality\n\nmodule Oscar.Class.Symmetrical.Symmetry where\n\nmodule _\n {𝔬} {𝔒 : Ø 𝔬}\n {ℓ} {_∼_ : 𝔒 → 𝔒 → Ø ℓ}\n ⦃ _ : Symmetry.class _∼_ ⦄\n where\n\n instance\n\n Symmetrical𝓢ymmetry : Symmetrical _∼_ (λ x∼y y∼x → x∼y → y∼x)\n Symmetrical𝓢ymmetry .𝓢ymmetrical.symmetrical _ _ = symmetry\n", "meta": {"hexsha": "018866b9818becc3dc626aa9a9f476b01d04e9dc", "size": 414, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-3/src/Oscar/Class/Symmetrical/Symmetry.agda", "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "archive/agda-3/src/Oscar/Class/Symmetrical/Symmetry.agda", "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_forks_repo_path": "archive/agda-3/src/Oscar/Class/Symmetrical/Symmetry.agda", "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.7894736842, "max_line_length": 65, "alphanum_fraction": 0.6980676329, "num_tokens": 161, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.934395157060208, "lm_q2_score": 0.805632181981183, "lm_q1q2_score": 0.7527788092150656}} {"text": "Extensionality of a function of two arguments\n\n\\begin{code}\nextensionality2 : ∀ {A B C : Set} → {f g : A → B → C} → (∀ (x : A) (y : B) → f x y ≡ g x y) → f ≡ g\nextensionality2 fxy≡gxy = extensionality (λ x → extensionality (λ y → fxy≡gxy x y))\n\\end{code}\n\nIsomorphism of all and exists.\n\\begin{code}\n¬∃∀ : ∀ {A : Set} {B : A → Set} → (¬ ∃ (λ (x : A) → B x)) ≃ ∀ (x : A) → ¬ B x\n¬∃∀ =\n record\n { to = λ { ¬∃bx x bx → ¬∃bx (x , bx) }\n ; fro = λ { ∀¬bx (x , bx) → ∀¬bx x bx }\n ; invˡ = λ { ¬∃bx → extensionality (λ { (x , bx) → refl }) } \n ; invʳ = λ { ∀¬bx → refl } \n }\n\\end{code}\n", "meta": {"hexsha": "c19bfe4ee0d44fbd5f928515486eddccedd81070", "size": 602, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "extra/extra/Isomorphisms.agda", "max_stars_repo_name": "manikdv/plfa.github.io", "max_stars_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1003, "max_stars_repo_stars_event_min_datetime": "2018-07-05T18:15:14.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-27T07:03:28.000Z", "max_issues_repo_path": "extra/extra/Isomorphisms.agda", "max_issues_repo_name": "manikdv/plfa.github.io", "max_issues_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 323, "max_issues_repo_issues_event_min_datetime": "2018-07-05T22:34:34.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-30T07:42:57.000Z", "max_forks_repo_path": "extra/extra/Isomorphisms.agda", "max_forks_repo_name": "manikdv/plfa.github.io", "max_forks_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 304, "max_forks_repo_forks_event_min_datetime": "2018-07-16T18:24:59.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-28T11:35:02.000Z", "avg_line_length": 31.6842105263, "max_line_length": 99, "alphanum_fraction": 0.4750830565, "num_tokens": 272, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.945801267121407, "lm_q2_score": 0.7956581073313275, "lm_q1q2_score": 0.75253444610939}} {"text": "------------------------------------------------------------------------------\n-- Inductive PA arithmetic properties using Agsy\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\n-- Tested with the development version of the Agda standard library on\n-- 02 February 2012.\n\nmodule Agsy.PA.Inductive.Properties where\n\nopen import Data.Nat renaming ( suc to succ )\n\nopen import Relation.Binary.PropositionalEquality\nopen ≡-Reasoning\n\n------------------------------------------------------------------------------\n\n+-rightIdentity : ∀ n → n + zero ≡ n -- via Agsy {-c}\n+-rightIdentity zero = refl\n+-rightIdentity (succ n) = cong succ (+-rightIdentity n)\n\n+-assoc : ∀ m n o → m + n + o ≡ m + (n + o) -- via Agsy {-c}\n+-assoc zero n o = refl\n+-assoc (succ m) n o = cong succ (+-assoc m n o)\n\nx+Sy≡S[x+y] : ∀ m n → m + succ n ≡ succ (m + n) -- via Agsy {-c}\nx+Sy≡S[x+y] zero n = refl\nx+Sy≡S[x+y] (succ m) n = cong succ (x+Sy≡S[x+y] m n)\n\n+-comm : ∀ m n → m + n ≡ n + m -- via Agsy {-c -m}\n+-comm zero n = sym (+-rightIdentity n)\n+-comm (succ m) n =\n begin\n succ (m + n) ≡⟨ cong succ (+-comm m n) ⟩\n succ (n + m) ≡⟨ sym (x+Sy≡S[x+y] n m) ⟩\n n + succ m\n ∎\n", "meta": {"hexsha": "31eb389fd2228102386c8345f88a758f1c696bbc", "size": 1378, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/Agsy/PA/Inductive/Properties.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/Agsy/PA/Inductive/Properties.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/Agsy/PA/Inductive/Properties.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 32.8095238095, "max_line_length": 78, "alphanum_fraction": 0.469521045, "num_tokens": 398, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9284087946129328, "lm_q2_score": 0.8104789109591832, "lm_q1q2_score": 0.7524557487828178}} {"text": "{-# OPTIONS --safe --without-K #-}\nopen import Relation.Binary\n\nmodule Data.List.Membership.Setoid.Disjoint {a p} (S : Setoid a p) where\nopen Setoid S renaming (Carrier to A)\nopen import Data.List using (List ; [])\nopen import Data.List.Membership.Setoid (S)\nopen import Data.List.Membership.Setoid.Trans (S)\nopen import Data.Empty\n\nopen import Function\n\n\nDisjoint : Rel (List A) _\nDisjoint xs ys = ∀ {x} → x ∈ xs → x ∈ ys → ⊥ \n\ndisjoint-sym : Symmetric Disjoint\ndisjoint-sym dis = flip dis\n\ndisjoint-[]ˡ : ∀ {xs} → Disjoint xs []\ndisjoint-[]ˡ _ ()\n\ndisjoint-[]ʳ : ∀ {xs} → Disjoint [] xs\ndisjoint-[]ʳ ()\n\ndisjointness : ∀ {xs ys} → Disjoint xs ys → ∀ {x} → x ∈ xs → ∀ {y} → y ∈ ys → x ≈ y → ⊥\ndisjointness xs⋈ys x∈xs y∈ys x≈y = xs⋈ys x∈xs (≈-trans-∈ x≈y y∈ys)\n\n", "meta": {"hexsha": "0ab83deeeb5ed638f202aa5b66b205b50250fdf4", "size": 764, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/List/Membership/Setoid/Disjoint.agda", "max_stars_repo_name": "tizmd/agda-distinct-disjoint", "max_stars_repo_head_hexsha": "d4cd2a3442a9b58e6139499d16a2b31268f27f80", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Data/List/Membership/Setoid/Disjoint.agda", "max_issues_repo_name": "tizmd/agda-distinct-disjoint", "max_issues_repo_head_hexsha": "d4cd2a3442a9b58e6139499d16a2b31268f27f80", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Data/List/Membership/Setoid/Disjoint.agda", "max_forks_repo_name": "tizmd/agda-distinct-disjoint", "max_forks_repo_head_hexsha": "d4cd2a3442a9b58e6139499d16a2b31268f27f80", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.3448275862, "max_line_length": 87, "alphanum_fraction": 0.6413612565, "num_tokens": 273, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9425067211996142, "lm_q2_score": 0.7981867753392728, "lm_q1q2_score": 0.7522964005299111}} {"text": "\nmodule Nat where\n\ndata Nat : Set where\n zero : Nat\n suc : Nat -> Nat\n\ninfixl 60 _+_\ninfixl 70 _*_\n\n_+_ : Nat -> Nat -> Nat\nn + zero = n\nn + suc m = suc (n + m)\n\n_*_ : Nat -> Nat -> Nat\nn * zero = zero\nn * suc m = n * m + n\n\n{-# BUILTIN NATURAL Nat #-}\n{-# BUILTIN ZERO zero #-}\n{-# BUILTIN SUC suc #-}\n{-# BUILTIN NATPLUS _+_ #-}\n{-# BUILTIN NATTIMES _*_ #-}\n\n", "meta": {"hexsha": "394e2db5441f0949210c19f84c81268cdb42dfc1", "size": 366, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/SummerSchool07/Lecture/Nat.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/SummerSchool07/Lecture/Nat.agda", "max_issues_repo_name": "np/agda-git-experiment", "max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/SummerSchool07/Lecture/Nat.agda", "max_forks_repo_name": "np/agda-git-experiment", "max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 14.64, "max_line_length": 28, "alphanum_fraction": 0.5409836066, "num_tokens": 131, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9579122696813394, "lm_q2_score": 0.7853085758631159, "lm_q1q2_score": 0.7522567203052576}} {"text": "open import Preliminaries\nopen import Preorder\n\nmodule PreorderExamples where\n\n-- there is a preorder on Unit\n\n unit-p : Preorder Unit\n unit-p = preorder (preorder-structure (λ x x₁ → Unit) (λ x → <>) (λ x y z _ _ → <>))\n\n-- there is a preorder on Nat\n\n _≤n_ : Nat → Nat → Set\n _≤n_ Z Z = Unit\n _≤n_ Z (S n) = Unit\n _≤n_ (S m) Z = Void\n _≤n_ (S m) (S n) = m ≤n n\n\n nat-refl : ∀ (n : Nat) → n ≤n n\n nat-refl Z = <>\n nat-refl (S n) = nat-refl n\n\n nat-trans : ∀ (m n p : Nat) → m ≤n n → n ≤n p → m ≤n p\n nat-trans Z Z Z x x₁ = <>\n nat-trans Z Z (S p) x x₁ = <>\n nat-trans Z (S n) Z x x₁ = <>\n nat-trans Z (S n) (S p) x x₁ = <>\n nat-trans (S m) Z Z () x₁\n nat-trans (S m) Z (S p) () x₁\n nat-trans (S m) (S n) Z x ()\n nat-trans (S m) (S n) (S p) x x₁ = nat-trans m n p x x₁\n\n nat-p : Preorder Nat\n nat-p = preorder (preorder-structure (λ m n → m ≤n n) nat-refl nat-trans)\n", "meta": {"hexsha": "9c4eba6653e981781a3f0c829b3e52e226ca36e9", "size": 888, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "complexity-drafts/PreorderExamples.agda", "max_stars_repo_name": "benhuds/Agda", "max_stars_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2016-04-26T20:22:22.000Z", "max_stars_repo_stars_event_max_datetime": "2019-08-08T12:27:18.000Z", "max_issues_repo_path": "complexity-drafts/PreorderExamples.agda", "max_issues_repo_name": "benhuds/Agda", "max_issues_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-03-23T08:39:04.000Z", "max_issues_repo_issues_event_max_datetime": "2020-05-12T00:32:45.000Z", "max_forks_repo_path": "complexity-drafts/PreorderExamples.agda", "max_forks_repo_name": "benhuds/Agda", "max_forks_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.3714285714, "max_line_length": 86, "alphanum_fraction": 0.5472972973, "num_tokens": 374, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.951142221377825, "lm_q2_score": 0.7905303186696748, "lm_q1q2_score": 0.7519067633659944}} {"text": "module Extensions.VecFirst where\n\nopen import Data.Vec\nopen import Data.Product\nopen import Level\nopen import Relation.Nullary\nopen import Function using (_∘_; _$_)\n\n-- proof that an element is the first in a vector to satisfy the predicate B\ndata First {a b} {A : Set a} (B : A → Set b) : ∀ {n} (x : A) → Vec A n → Set (a ⊔ b) where\n\n here : ∀ {n} {x : A} → (p : B x) → (v : Vec A n) → First B x (x ∷ v)\n there : ∀ {n x} {v : Vec A n} (x' : A) → ¬ (B x') → First B x v → First B x (x' ∷ v)\n\n-- more likable syntax for the above structure\nfirst_∈_⇔_ : ∀ {n} {A : Set} → A → Vec A n → (B : A → Set) → Set \nfirst_∈_⇔_ x v p = First p x v\n\n-- a decision procedure to find the first element in a vector that satisfies a predicate\nfind : ∀ {n} {A : Set} (P : A → Set) → ((a : A) → Dec (P a)) → (v : Vec A n) → \n Dec (∃ λ e → first e ∈ v ⇔ P)\nfind P dec [] = no (λ{ (e , ()) })\nfind P dec (x ∷ v) with dec x\nfind P dec (x ∷ v) | yes px = yes (x , here px v)\nfind P dec (x ∷ v) | no ¬px with find P dec v\nfind P dec (x ∷ v) | no ¬px | yes firstv = yes (, there x ¬px (proj₂ firstv))\nfind P dec (x ∷ v) | no ¬px | no ¬firstv = no $ helper ¬px ¬firstv\n where\n helper : ¬ (P x) → ¬ (∃ λ e → First P e v) → ¬ (∃ λ e → First P e (x ∷ v))\n helper ¬px ¬firstv (.x , here p .v) = ¬px p\n helper ¬px ¬firstv (u , there ._ _ firstv) = ¬firstv (u , firstv)\n", "meta": {"hexsha": "36b25545000f38577fb2afaccd7fcb988b4be313", "size": 1358, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Extensions/VecFirst.agda", "max_stars_repo_name": "metaborg/ts.agda", "max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z", "max_issues_repo_path": "src/Extensions/VecFirst.agda", "max_issues_repo_name": "metaborg/ts.agda", "max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z", "max_forks_repo_path": "src/Extensions/VecFirst.agda", "max_forks_repo_name": "metaborg/ts.agda", "max_forks_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z", "avg_line_length": 42.4375, "max_line_length": 90, "alphanum_fraction": 0.5530191458, "num_tokens": 529, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9304582574225517, "lm_q2_score": 0.8080672066194945, "lm_q1q2_score": 0.7518728049514839}} {"text": "module x03-842Relations-hc where\n\n-- Library\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl; cong; sym) -- added sym\nopen import Data.Nat using (ℕ; zero; suc; _+_)\nopen import Data.Nat.Properties using (+-comm)\n\n-- The less-than-or-equal-to relation.\n\ndata _≤_ : ℕ → ℕ → Set where\n\n z≤n : ∀ {n : ℕ}\n --------\n → zero ≤ n\n\n s≤s : ∀ {m n : ℕ}\n → m ≤ n\n -------------\n → suc m ≤ suc n\n\n-- Some examples.\n\n_ : 2 ≤ 4 -- can do just by refine\n_ = s≤s (s≤s z≤n)\n\n_ : 2 ≤ 4 -- with implicit args\n_ = s≤s {1} {3} (s≤s {0} {2} z≤n)\n\n_ : 2 ≤ 4 -- with named implicit args\n_ = s≤s {m = 1} {n = 3} (s≤s {m = 0} {n = 2} z≤n)\n\n_ : 2 ≤ 4 -- with some implicit named args\n_ = s≤s {n = 3} (s≤s {m = 0} z≤n)\n\ninfix 4 _≤_\n\n-- Inversion.\n\ninv-s≤s : ∀ {m n : ℕ}\n → suc m ≤ suc n\n -------------\n → m ≤ n\n\ninv-s≤s (s≤s x) = x\n\ninv-z≤n : ∀ {m : ℕ}\n → m ≤ zero\n --------\n → m ≡ zero\n\ninv-z≤n z≤n = refl\n\n-- Properties.\n\n-- Reflexivity.\n\n≤-refl : ∀ {n : ℕ}\n -----\n → n ≤ n\n\n≤-refl {zero} = z≤n\n≤-refl {suc n} = s≤s (≤-refl {n})\n\n-- Transitivity.\n\n≤-trans : ∀ {m n p : ℕ} -- note implicit arguments\n → m ≤ n\n → n ≤ p\n -----\n → m ≤ p\n\n≤-trans z≤n n≤p = z≤n\n≤-trans (s≤s m≤n) (s≤s n≤p) = s≤s (≤-trans m≤n n≤p)\n\n≤-trans′ : ∀ (m n p : ℕ) -- without implicit arguments\n → m ≤ n\n → n ≤ p\n -----\n → m ≤ p\n\n≤-trans′ .0 _ _ z≤n n≤p = z≤n\n≤-trans′ (suc m) (suc n) (suc p) (s≤s m≤n) (s≤s n≤p) = s≤s (≤-trans′ m n p m≤n n≤p)\n\n-- Antisymmetry.\n\n≤-antisym : ∀ {m n : ℕ}\n → m ≤ n\n → n ≤ m\n -----\n → m ≡ n\n\n≤-antisym z≤n z≤n = refl\n≤-antisym (s≤s m≤n) (s≤s n≤m) rewrite ≤-antisym m≤n n≤m = refl\n\n-- Total ordering.\n\n-- A definition with parameters.\n\ndata Total (m n : ℕ) : Set where\n\n forward :\n m ≤ n\n ---------\n → Total m n\n\n flipped :\n n ≤ m\n ---------\n → Total m n\n\n-- An equivalent definition without parameters.\n\ndata Total′ : ℕ → ℕ → Set where\n\n forward′ : ∀ {m n : ℕ}\n → m ≤ n\n ----------\n → Total′ m n\n\n flipped′ : ∀ {m n : ℕ}\n → n ≤ m\n ----------\n → Total′ m n\n\n-- Showing that ≤ is a total order.\n\n≤-total : ∀ (m n : ℕ) → Total m n -- introducing with clause\n≤-total zero n = forward z≤n\n≤-total (suc m) zero = flipped z≤n\n≤-total (suc m) (suc n) with ≤-total m n\n... | forward x = forward (s≤s x)\n... | flipped x = flipped (s≤s x)\n\n≤-total′ : ∀ (m n : ℕ) → Total m n -- with helper function and where\n≤-total′ zero n = forward z≤n\n≤-total′ (suc m) zero = flipped z≤n\n≤-total′ (suc m) (suc n) = helper (≤-total m n)\n where\n helper : Total m n → Total (suc m) (suc n)\n helper (forward x) = forward (s≤s x)\n helper (flipped x) = flipped (s≤s x)\n\n-- Splitting on n first gives different code (see PLFA or try it yourself).\n\n-- Monotonicity.\n\n+-monoʳ-≤ : ∀ (m p q : ℕ)\n → p ≤ q\n -------------\n → m + p ≤ m + q\n\n+-monoʳ-≤ zero p q p≤q = p≤q -- split on m\n+-monoʳ-≤ (suc m) p q p≤q = s≤s (+-monoʳ-≤ m p q p≤q) -- refine, recurse\n\n+-monoˡ-≤ : ∀ (m n p : ℕ)\n → m ≤ n\n -------------\n → m + p ≤ n + p\n\n+-monoˡ-≤ m n p m≤n rewrite +-comm m p | +-comm n p = +-monoʳ-≤ p m n m≤n -- use commutativity\n\n+-mono-≤ : ∀ (m n p q : ℕ) -- combine above\n → m ≤ n\n → p ≤ q\n -------------\n → m + p ≤ n + q\n\n+-mono-≤ m n p q m≤n p≤q = ≤-trans (+-monoʳ-≤ m p q p≤q ) (+-monoˡ-≤ m n q m≤n)\n\n-- PLFA exercise: show *-mono-≤.\n\n-- Strict inequality.\n\ninfix 4 _<_\n\ndata _<_ : ℕ → ℕ → Set where\n\n z n for all m and n.\n\ndata Trichotomy (m n : ℕ) : Set where\n is-< : m < n → Trichotomy m n\n is-≡ : m ≡ n → Trichotomy m n\n is-> : n < m → Trichotomy m n\n\n<-trichotomy : ∀ (m n : ℕ) → Trichotomy m n -- TODO\n<-trichotomy m n = {!!}\n\n-- PLFA exercise: show +-mono-<.\n\n-- Prove that suc m ≤ n implies m < n, and conversely,\n-- and do the same for (m ≤ n) and (m < suc n).\n-- Hint: if you do the proofs in the order below, you can avoid induction\n-- for two of the four proofs.\n\n-- 842 exercise: LEtoLTS (1 point)\n\n≤-<-to : ∀ {m n : ℕ} → m ≤ n → m < suc n -- TODO\n≤-<-to m≤n = {!!}\n\n-- 842 exercise: LEStoLT (1 point)\n\n≤-<--to′ : ∀ {m n : ℕ} → suc m ≤ n → m < n -- TODO\n≤-<--to′ sm≤n = {!!}\n\n-- 842 exercise: LTtoSLE (1 point)\n\n≤-<-from : ∀ {m n : ℕ} → m < n → suc m ≤ n -- TODO\n≤-<-from m=, \\ge)\nˡ U+02E1 MODIFIER LETTER SMALL L (\\^l)\nʳ U+02B3 MODIFIER LETTER SMALL R (\\^r)\n\n-}\n", "meta": {"hexsha": "a31d4d9a19ccd032e707c92b769a353b16ed4d31", "size": 6119, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x03-842Relations-hc.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x03-842Relations-hc.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x03-842Relations-hc.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 20.3289036545, "max_line_length": 94, "alphanum_fraction": 0.5066187286, "num_tokens": 2510, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8887587993853654, "lm_q2_score": 0.8459424411924673, "lm_q1q2_score": 0.7518387883833423}} {"text": "open import Data.Nat\nopen import Data.Nat.Show\nopen import IO\n\nmodule Ackermann where\n\nack : ℕ -> ℕ -> ℕ\nack zero n = n + 1\nack (suc m) zero = ack m 1\nack (suc m) (suc n) = ack m (ack (suc m) n)\n\nmain = run (putStrLn (show (ack 3 9)))\n", "meta": {"hexsha": "1528a75ff43c67a44eaae7745ecdc7d4a6865ec2", "size": 235, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Task/Ackermann-function/Agda/ackermann-function-1.agda", "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Ackermann-function/Agda/ackermann-function-1.agda", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Ackermann-function/Agda/ackermann-function-1.agda", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 18.0769230769, "max_line_length": 43, "alphanum_fraction": 0.6340425532, "num_tokens": 90, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9603611620335328, "lm_q2_score": 0.7826624738835051, "lm_q1q2_score": 0.7516386428988024}} {"text": "module natThms where\r\n\r\nopen import lib\r\n\r\n-- this function divides a natural number by 2, dropping any remainder\r\ndiv2 : ℕ → ℕ\r\ndiv2 0 = 0\r\ndiv2 1 = 0\r\ndiv2 (suc (suc x)) = suc (div2 x)\r\n\r\ndiv2-double : ∀(x : ℕ) → (div2 (x * 2)) ≡ x\r\ndiv2-double zero = refl\r\ndiv2-double (suc x) rewrite div2-double (x) = refl\r\n\r\n{- Hint: consider the same cases as in the definition of div2: 0, 1, (suc (suc x)).\r\n The case for 1 is impossible, so you can just drop that case or use the \r\n absurd pattern for the proof of is-even 1 ≡ tt. -}\r\ndiv2-even : ∀(x : ℕ) → is-even x ≡ tt → div2 x ≡ div2 (suc x)\r\ndiv2-even zero x = refl\r\ndiv2-even (suc (suc x))y rewrite div2-even x y = refl\r\n\r\n-- same hint as for div2-even, except now the 0 case is impossible\r\ndiv2-odd : ∀(x : ℕ) → is-odd x ≡ tt → div2 (suc x) ≡ suc (div2 x)\r\ndiv2-odd (suc(suc x))y rewrite div2-odd x y = refl\r\ndiv2-odd (suc zero) y = refl\r\n\r\n{- hint: do *not* do induction on x. Look at the definitions of square and pow. \r\n There are lemmas about multiplication in the IAL that will help you (nat-thms.agda). -}\r\nsquare-square : ∀(x : ℕ) → square (square x) ≡ x pow 4\r\nsquare-square x rewrite *1{x} | *assoc x x ( x * x ) = refl\r\n", "meta": {"hexsha": "b20cc2db270bf8c39040895da8d67a33b3a3c6df", "size": 1190, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "natThms.agda", "max_stars_repo_name": "DTMcNamara/CS3820-ProgrammingLanguageConcepts-Workout7", "max_stars_repo_head_hexsha": "0117aa66ff3cbc8d75be3c9705bada96bdcf8d5a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "natThms.agda", "max_issues_repo_name": "DTMcNamara/CS3820-ProgrammingLanguageConcepts-Workout7", "max_issues_repo_head_hexsha": "0117aa66ff3cbc8d75be3c9705bada96bdcf8d5a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "natThms.agda", "max_forks_repo_name": "DTMcNamara/CS3820-ProgrammingLanguageConcepts-Workout7", "max_forks_repo_head_hexsha": "0117aa66ff3cbc8d75be3c9705bada96bdcf8d5a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.3870967742, "max_line_length": 91, "alphanum_fraction": 0.6361344538, "num_tokens": 421, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9219218262741297, "lm_q2_score": 0.8152324826183822, "lm_q1q2_score": 0.7515806192135316}} {"text": "module Numeral.Natural.Sequence where\n\nimport Lvl\nopen import Data\nopen import Data.Either as Either using (_‖_)\nopen import Data.Tuple as Tuple using (_⨯_ ; _,_)\nimport Data.Tuple.Raise as Tuple\nopen import Functional\nopen import Numeral.Natural\nopen import Numeral.Natural.Oper\nopen import Numeral.Natural.Oper.FlooredDivision\nopen import Type\n\nprivate variable ℓ ℓ₁ ℓ₂ : Lvl.Level\nprivate variable n : ℕ\nprivate variable A : Type{ℓ}\nprivate variable B : Type{ℓ}\n\n-- Alternates between the two sides, starting with the left.\n-- A countable bijection for the Either type.\n-- Examples:\n-- alternate₂(0) = Left(0)\n-- alternate₂(2) = Left(1)\n-- alternate₂(4) = Left(2)\n-- alternate₂(6) = Left(3)\n\n-- alternate₂(1) = Right(0)\n-- alternate₂(3) = Right(1)\n-- alternate₂(5) = Right(2)\n-- alternate₂(7) = Right(3)\nalternate₂ : ℕ → (ℕ ‖ ℕ)\nalternate₂(0) = Either.Left 0\nalternate₂(1) = Either.Right 0\nalternate₂(𝐒(𝐒(n))) = Either.map 𝐒 𝐒 (alternate₂ n)\n\n-- The inverse of `alternate₂`.\nunalternate₂ : (ℕ ‖ ℕ) → ℕ\nunalternate₂(Either.Left n) = n ⋅ 2\nunalternate₂(Either.Right n) = 𝐒(n ⋅ 2)\n\n-- Maps two natural numbers to a single one without overlaps by following the inverse diagonals downwards.\n-- A countable bijection for the tuple pairing type.\n-- Alternative forms:\n-- pairIndexing a b = a + (∑(𝕟(a + b)) (i ↦ 𝕟-to-ℕ(i)))\n-- pairIndexing a b = a + ((a + b) * (a + b + 1) / 2)\n-- Example:\n-- Horizontal axis is `a` starting from 0.\n-- Vertical axis is `b` starting from 0.\n-- Cells are `pairIndexing a b`.\n-- 0, 1, 3, 6,10,15\n-- 2, 4, 7,11,16,..\n-- 5, 8,12,17, ..\n-- 9,13,18, ..\n-- 14,19, ..\n-- 20,.. .. .. .. ..\n-- Termination:\n-- Decreases `a` until 0 while at the same time increases `b` (So `b` is at most `a`).\n-- Then the arguments is swapped, but using the predecessor of `b`.\n-- This means that `b` will eventually reach 0.\n{-# TERMINATING #-}\npairIndexing : ℕ → ℕ → ℕ\npairIndexing 𝟎 𝟎 = 𝟎\npairIndexing (𝐒 a) 𝟎 = 𝐒(pairIndexing 𝟎 a)\n{-# CATCHALL #-}\npairIndexing a (𝐒 b) = 𝐒(pairIndexing (𝐒 a) b)\n\n-- A sequence which fills a discrete two dimensional grid (a space bounded in two directions and infinite in the other two).\n-- It is the inverse of an uncurried `pairIndexing`.\n-- Example:\n-- •-→-• ↗→• ↗→•\n-- ↙ ↗ ↙ ↗ ↙\n-- •→↗ • ↗ • •\n-- ↙ ↗ ↙\n-- •→↗ • • •\ndiagonalFilling : ℕ → (ℕ ⨯ ℕ)\ndiagonalFilling 𝟎 = (𝟎 , 𝟎)\ndiagonalFilling (𝐒(n)) with diagonalFilling n\n... | (𝟎 , b) = (𝐒(b) , 0)\n... | (𝐒(a) , b) = (a , 𝐒(b))\n\ntupleIndexing : (ℕ Tuple.^ n) → ℕ\ntupleIndexing {𝟎} <> = 𝟎\ntupleIndexing {𝐒(𝟎)} x = x\ntupleIndexing {𝐒(𝐒(n))} (x , y) = pairIndexing x (tupleIndexing {𝐒(n)} y)\n\nspaceFilling : ℕ → (ℕ Tuple.^ n)\nspaceFilling {𝟎} _ = <>\nspaceFilling {𝐒(𝟎)} i = i\nspaceFilling {𝐒(𝐒(n))} i = Tuple.mapRight (spaceFilling {𝐒(n)}) (diagonalFilling i)\n\n\n-- Interleaves two sequences into one, alternating between the elements from each sequence.\ninterleave : (ℕ → A) → (ℕ → B) → (ℕ → (A ‖ B))\ninterleave af bf = Either.map af bf ∘ alternate₂\n\npair : (ℕ → A) → (ℕ → B) → (ℕ → (A ⨯ B))\npair af bf = Tuple.map af bf ∘ diagonalFilling\n", "meta": {"hexsha": "0d80a72c3e331c3d1ecefcfb36b263056abfbb00", "size": 3197, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Natural/Sequence.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Numeral/Natural/Sequence.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Numeral/Natural/Sequence.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.6224489796, "max_line_length": 124, "alphanum_fraction": 0.6111979981, "num_tokens": 1206, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9111797027760038, "lm_q2_score": 0.8244619242200082, "lm_q1q2_score": 0.7512329710609192}} {"text": "{-# OPTIONS --safe --without-K #-}\n------------------------------------------------------------------------\n-- Group objects in a cartesian category.\n------------------------------------------------------------------------\n\nopen import Categories.Category\nopen import Categories.Category.Cartesian\n\nmodule Categories.Object.Group {o ℓ e} {𝒞 : Category o ℓ e} (C : Cartesian 𝒞) where\n\nopen import Level\n\nopen import Categories.Category.BinaryProducts 𝒞 using (BinaryProducts)\nopen import Categories.Category.Cartesian.Monoidal\nopen import Categories.Object.Monoid (CartesianMonoidal.monoidal C)\nopen import Categories.Object.Terminal 𝒞\n\nopen Category 𝒞\nopen Cartesian C\nmodule Π = BinaryProducts products\nopen BinaryProducts products using (_×_; _⁂_; ⟨_,_⟩)\nopen Terminal terminal\n\nrecord IsGroup (G : Obj) : Set (ℓ ⊔ e) where\n -- any group object is also a monoid object\n field\n isMonoid : IsMonoid G\n\n open IsMonoid isMonoid public\n \n field\n -- inverse operation\n ι : G ⇒ G\n -- ι is in fact an inverse\n inverseˡ : η ∘ ! ≈ μ ∘ ⟨ ι , id ⟩\n inverseʳ : η ∘ ! ≈ μ ∘ ⟨ id , ι ⟩\n\nrecord Group : Set (o ⊔ ℓ ⊔ e) where\n field\n Carrier : Obj\n isGroup : IsGroup Carrier\n\n open IsGroup isGroup public\n\n monoid : Monoid\n monoid = record { isMonoid = isMonoid }\n\nopen Group\n\nrecord Group⇒ (G H : Group) : Set (ℓ ⊔ e) where\n field\n arr : Carrier G ⇒ Carrier H\n preserves-μ : arr ∘ μ G ≈ μ H ∘ (arr ⁂ arr)\n preserves-η : arr ∘ η G ≈ η H\n preserves-ι : arr ∘ ι G ≈ ι H ∘ arr\n", "meta": {"hexsha": "b575714821a88ff4a856f51c632e6b83972e0539", "size": 1510, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Object/Group.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2019-05-21T17:07:19.000Z", "max_stars_repo_stars_event_max_datetime": "2019-05-22T03:54:24.000Z", "max_issues_repo_path": "src/Categories/Object/Group.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Object/Group.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.9642857143, "max_line_length": 83, "alphanum_fraction": 0.6099337748, "num_tokens": 438, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9324533069832973, "lm_q2_score": 0.8056321866478979, "lm_q1q2_score": 0.7512143966520175}} {"text": "{-# OPTIONS --without-K --exact-split --safe #-}\n\nmodule Fragment.Extensions.CSemigroup.Nat where\n\nopen import Relation.Binary.PropositionalEquality as PE using (_≡_)\n\ndata ℕ⁺ : Set where\n one : ℕ⁺\n suc : ℕ⁺ → ℕ⁺\n\ninfixl 6 _+_\n\n_+_ : ℕ⁺ → ℕ⁺ → ℕ⁺\none + x = suc x\nsuc x + y = suc (x + y)\n\n+-suc : ∀ x y → x + suc y ≡ suc (x + y)\n+-suc one y = PE.refl\n+-suc (suc x) y = PE.cong suc (+-suc x y)\n\n+-one : ∀ x → x + one ≡ suc x\n+-one one = PE.refl\n+-one (suc x) = PE.cong suc (+-one x)\n\n+-assoc : ∀ x y z → (x + y) + z ≡ x + (y + z)\n+-assoc one _ _ = PE.refl\n+-assoc (suc x) y z = PE.cong suc (+-assoc x y z)\n\nopen PE.≡-Reasoning\n\n+-comm : ∀ x y → x + y ≡ y + x\n+-comm one one = PE.refl\n+-comm one (suc y) = begin\n one + (suc y) ≡⟨⟩\n suc (suc y) ≡⟨ PE.sym (PE.cong suc (+-one y)) ⟩\n suc (y + one) ≡⟨ PE.sym PE.refl ⟩\n suc y + one ∎\n+-comm (suc x) y = begin\n suc x + y ≡⟨⟩\n suc (x + y) ≡⟨ PE.cong suc (+-comm x y) ⟩\n suc (y + x) ≡⟨ PE.sym (+-suc y x) ⟩\n y + suc x ∎\n", "meta": {"hexsha": "3cd6e613007cc05b2011f3e033aafb3d259b6eef", "size": 1020, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Fragment/Extensions/CSemigroup/Nat.agda", "max_stars_repo_name": "yallop/agda-fragment", "max_stars_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 18, "max_stars_repo_stars_event_min_datetime": "2021-06-15T15:45:39.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-17T17:26:09.000Z", "max_issues_repo_path": "src/Fragment/Extensions/CSemigroup/Nat.agda", "max_issues_repo_name": "yallop/agda-fragment", "max_issues_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-06-16T09:44:31.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-16T10:24:15.000Z", "max_forks_repo_path": "src/Fragment/Extensions/CSemigroup/Nat.agda", "max_forks_repo_name": "yallop/agda-fragment", "max_forks_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2021-06-15T15:34:50.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-16T08:04:31.000Z", "avg_line_length": 23.7209302326, "max_line_length": 67, "alphanum_fraction": 0.4960784314, "num_tokens": 450, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9324533088603708, "lm_q2_score": 0.8056321796478255, "lm_q1q2_score": 0.7512143916370075}} {"text": "{-# OPTIONS --safe #-}\nmodule Mod where\n\nopen import Data.Fin\nopen import Data.Nat as ℕ\n using (ℕ; zero; suc; z≤n; s≤s)\nopen import Relation.Binary.PropositionalEquality\nopen import Function\n\nprivate variable k : ℕ\n\nlast : Fin (suc k)\nlast {k = zero} = zero\nlast {k = suc _} = suc last\n\nnegate : Fin k -> Fin k\nnegate zero = zero\nnegate (suc zero) = last\nnegate (suc (suc n)) = inject₁ (negate (suc n))\n\nsubt : Fin k -> Fin k -> Fin k\nsubt n zero = n\nsubt zero (suc m) = negate (suc m)\nsubt (suc n) (suc m) with (compare n m)\n...| less _ _ = suc (subt n m)\n...| _ = inject₁ (subt n m)\n\nadd : Fin k -> Fin k -> Fin k\nadd n m = subt n (negate m)\n\nmultAux : ∀{n} → ℕ → (Fin n → Fin n) → Fin n → Fin n\nmultAux zero _ x = x\nmultAux (suc n) f x = multAux n f (f x)\n\nmult : Fin k -> Fin k -> Fin k\nmult zero m = zero\nmult (suc n) m = multAux (toℕ n) (add m) zero\n\nzer : Fin 5\nzer = zero\none : Fin 5\none = suc zero\ntwo : Fin 5\ntwo = suc (suc zero)\nthree : Fin 5\nthree = suc (suc (suc zero))\nfour : Fin 5\nfour = suc (suc (suc (suc zero)))\n", "meta": {"hexsha": "6ec124d5df04db871970d00ac8c8f2f46aeb620f", "size": 1031, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Agda/Mod.agda", "max_stars_repo_name": "Brethland/LEARNING-STUFF", "max_stars_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-02-03T05:05:52.000Z", "max_stars_repo_stars_event_max_datetime": "2020-03-11T10:35:42.000Z", "max_issues_repo_path": "Agda/Mod.agda", "max_issues_repo_name": "Brethland/LEARNING-STUFF", "max_issues_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Agda/Mod.agda", "max_forks_repo_name": "Brethland/LEARNING-STUFF", "max_forks_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-12-13T04:50:46.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-13T04:50:46.000Z", "avg_line_length": 21.0408163265, "max_line_length": 52, "alphanum_fraction": 0.6149369544, "num_tokens": 396, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9407897442783527, "lm_q2_score": 0.7981867705385763, "lm_q1q2_score": 0.7509259277413515}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Categories.Category.Finite where\n\nopen import Level\nopen import Data.Nat using (ℕ)\nopen import Data.Fin\n\nopen import Categories.Adjoint.Equivalence\nopen import Categories.Category\nopen import Categories.Functor\nopen import Categories.Category.Finite.Fin\n\n-- definition of a finite category\n-- \n-- the idea is to require a functor from C to a category generated from a finite shape\n-- is the right adjoint.\n--\n-- Question: it seems to me right adjoint is enough, though the original plan is to\n-- use adjoint equivalence. intuitively, the shape category is an \"overapproximation\"\n-- of C, which is a very strong constraint. so requiring adjoint equivalence sounds an\n-- unnecessarily stronger constraint. is adjoint equivalence necessary?\n--\n-- Answer: probably yes. adjoint equivalence seems necessary as the notion needs to\n-- show that shapes are preserved.\n--\n-- c.f. Categories.Adjoint.Equivalence.Properties.⊣equiv-preserves-diagram\nrecord Finite {o ℓ e} (C : Category o ℓ e) : Set (o ⊔ ℓ ⊔ e) where\n field\n shape : FinCatShape\n\n open FinCatShape public renaming (size to ∣Obj∣)\n\n shapeCat : Category _ _ _\n shapeCat = FinCategory shape\n\n --\n -- /------------\\\n -- < - \\\n -- C | S\n -- \\ - ^\n -- \\------------/\n --\n field\n ⊣equiv : ⊣Equivalence shapeCat C\n\n module ⊣equiv = ⊣Equivalence ⊣equiv\n open ⊣equiv public\n", "meta": {"hexsha": "6c9900f47a9f1b17a5414ffd4bf56a06b9cd9378", "size": 1422, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Finite.agda", "max_stars_repo_name": "MirceaS/agda-categories", "max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Categories/Category/Finite.agda", "max_issues_repo_name": "MirceaS/agda-categories", "max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Category/Finite.agda", "max_forks_repo_name": "MirceaS/agda-categories", "max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.0204081633, "max_line_length": 86, "alphanum_fraction": 0.688466948, "num_tokens": 367, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9263037221561136, "lm_q2_score": 0.8104789155369047, "lm_q1q2_score": 0.7507496361908852}} {"text": "module 020-equivalence where\n\n-- We need False to represent logical contradiction.\n\nopen import 010-false-true\n\n-- Next, we need to be able to work with equalities. Equalities are\n-- defined between objects of the same type. Two objects are equal if\n-- we have a proof of their equality. In Agda, we can represent this\n-- by means of a function which takes two instances of some type M,\n-- and maps this to a proof of equality.\n\n-- To be a reasonable model for equality, we demand that this function\n-- has the properties of an equivalence relation: (i) we must have a\n-- proof that every object r in M equals itself, (ii) given a proof\n-- that r == s, we must be able to prove that s == r, and (iii) given\n-- proofs of r == s and s == t, we must be able to prove that r == t.\n\n-- A convenient way to store all these properties, goes by means of a\n-- record, which is in essence a local parametrised module, where the\n-- parameters and fields correspond to postulates (theorems that can\n-- be stated without proof), and declarations are theorems derived\n-- from parameters and fields. A good question is, what should be a\n-- parameter, and what should be a field? Fields can be considered as\n-- named parameters, so probably anything that would otherwise not be\n-- obvious without name should go into a field.\n\n-- Here we declare the type and equality function (which maps pairs of\n-- elements to proofs) as parameters, and the equivalence axioms as\n-- fields. The parameter M is optional because it can be derived\n-- unambiguously from the type signature of the equality function.\n\nrecord Equivalence\n {M : Set}\n (_==_ : M -> M -> Set)\n : Set1 where\n\n {- axioms -}\n field\n refl : ∀ {r} -> (r == r)\n symm : ∀ {r s} -> (r == s) -> (s == r)\n trans : ∀ {r s t} -> (r == s) -> (s == t) -> (r == t)\n\n -- We have a proof of inequality if we can prove contradiction from\n -- equality, and this is precisely how we define the inequality\n -- relation.\n\n _!=_ : M -> M -> Set\n m != n = (m == n) -> False\n\n -- Prove transitivity chains.\n -- (TODO: Use a type dependent function for these chains.)\n trans3 : ∀ {r s t u}\n -> (r == s) -> (s == t) -> (t == u) -> (r == u)\n trans3 p1 p2 p3 = trans (trans p1 p2) p3\n trans4 : ∀ {r s t u v}\n -> (r == s) -> (s == t) -> (t == u) -> (u == v) -> (r == v)\n trans4 p1 p2 p3 p4 = trans (trans3 p1 p2 p3) p4\n trans5 : ∀ {r s t u v w}\n -> (r == s) -> (s == t) -> (t == u) -> (u == v) -> (v == w)\n -> (r == w)\n trans5 p1 p2 p3 p4 p5 = trans (trans4 p1 p2 p3 p4) p5\n trans6 : ∀ {r s t u v w x}\n -> (r == s) -> (s == t) -> (t == u) -> (u == v) -> (v == w)\n -> (w == x) -> (r == x)\n trans6 p1 p2 p3 p4 p5 p6 = trans (trans5 p1 p2 p3 p4 p5) p6\n\n-- Now we construct a trivial model of equivalence: two instances of a\n-- type are equivalent if they reduce to the same normal form. (Note\n-- that Agda reduces expressions to normal form for us.)\n\ndata _≡_ {A : Set} : A -> A -> Set where\n refl : ∀ {r} -> r ≡ r\n\nthm-≡-is-equivalence : {A : Set} -> Equivalence {A} _≡_\nthm-≡-is-equivalence = record {\n refl = refl;\n symm = symm;\n trans = trans\n }\n where\n symm : ∀ {r s} -> r ≡ s -> s ≡ r\n symm refl = refl\n trans : ∀ {r s t} -> r ≡ s -> s ≡ t -> r ≡ t\n trans refl refl = refl\n", "meta": {"hexsha": "599546155a068df99375d53ad7ae899c6d4f697f", "size": 3297, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "020-equivalence.agda", "max_stars_repo_name": "mcmtroffaes/agda-proofs", "max_stars_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2015-08-09T22:51:55.000Z", "max_stars_repo_stars_event_max_datetime": "2016-08-17T16:15:42.000Z", "max_issues_repo_path": "020-equivalence.agda", "max_issues_repo_name": "mcmtroffaes/agda-proofs", "max_issues_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "020-equivalence.agda", "max_forks_repo_name": "mcmtroffaes/agda-proofs", "max_forks_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.3372093023, "max_line_length": 70, "alphanum_fraction": 0.6078252957, "num_tokens": 1038, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9263037241905732, "lm_q2_score": 0.8104789063814616, "lm_q1q2_score": 0.7507496293590508}} {"text": "-- Agda program using the Iowa Agda library\n\nopen import bool\n\nmodule PROOF-evendoublecoin\n (Choice : Set)\n (choose : Choice → 𝔹)\n (lchoice : Choice → Choice)\n (rchoice : Choice → Choice)\n where\n\nopen import eq\nopen import nat\nopen import list\nopen import maybe\n\n---------------------------------------------------------------------------\n-- Translated Curry operations:\n\nadd : ℕ → ℕ → ℕ\nadd zero x = x\nadd (suc y) z = suc (add y z)\n\ncoin : Choice → ℕ → ℕ\ncoin c1 x = if choose c1 then x else suc x\n\ndouble : ℕ → ℕ\ndouble x = add x x\n\neven : ℕ → 𝔹\neven zero = tt\neven (suc zero) = ff\neven (suc (suc x)) = even x\n\n---------------------------------------------------------------------------\n\nadd-suc : ∀ (x y : ℕ) → add x (suc y) ≡ suc (add x y)\nadd-suc zero y = refl\nadd-suc (suc x) y rewrite add-suc x y = refl\n\n-- auxiliary property for x+x instead of double:\neven-add-x-x : ∀ (x : ℕ) → even (add x x) ≡ tt\neven-add-x-x zero = refl\neven-add-x-x (suc x) rewrite add-suc x x | even-add-x-x x = refl\n\nevendoublecoin : (c1 : Choice) → (x : ℕ) → (even (double (coin c1 x))) ≡ tt\nevendoublecoin c1 x rewrite even-add-x-x (coin c1 x) = refl\n\n---------------------------------------------------------------------------\n", "meta": {"hexsha": "ac4ee4d205a1dd99f5004efe35792271019b4114", "size": 1217, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "docs/src/tooldocs/verify/PROOF-evendoublecoin.agda", "max_stars_repo_name": "DouglasRMiles/pakcs_lib", "max_stars_repo_head_hexsha": "c34d76595b23e5152e6a5883ad3b0ec1d840f6d9", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-01-06T18:32:48.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-21T22:25:28.000Z", "max_issues_repo_path": "docs/src/tooldocs/verify/PROOF-evendoublecoin.agda", "max_issues_repo_name": "DouglasRMiles/pakcs_lib", "max_issues_repo_head_hexsha": "c34d76595b23e5152e6a5883ad3b0ec1d840f6d9", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-02-21T22:25:13.000Z", "max_issues_repo_issues_event_max_datetime": "2021-02-24T12:41:30.000Z", "max_forks_repo_path": "docs/src/tooldocs/verify/PROOF-evendoublecoin.agda", "max_forks_repo_name": "DouglasRMiles/pakcs_lib", "max_forks_repo_head_hexsha": "c34d76595b23e5152e6a5883ad3b0ec1d840f6d9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-10-09T16:02:18.000Z", "max_forks_repo_forks_event_max_datetime": "2021-10-09T16:02:18.000Z", "avg_line_length": 24.34, "max_line_length": 75, "alphanum_fraction": 0.5176663928, "num_tokens": 357, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9496693688269984, "lm_q2_score": 0.7905303186696747, "lm_q1q2_score": 0.7507424287696359}} {"text": "open import Data.List\nopen import Data.Nat using (ℕ; zero; suc)\nopen import Data.Product\nopen import Data.Bool\nopen import Function using (id; _∘_)\nopen import Algebra\nopen import Level using (Level; _⊔_)\n\n\nmodule test where\n\n variable\n a b c ℓ c₂ ℓ₂ : Level\n A : Set a\n B : Set b\n C : Set c\n m n o p : ℕ\n\n-- Vector representation\n \n module Vector where\n -- Inductive definition of a vector\n data Vector (A : Set a) : (n : ℕ) → Set a where\n [] : Vector A zero\n _::_ : A → Vector A n → Vector A (suc n)\n\n infixr 5 _::_\n\n vecLength : Vector A n → ℕ\n vecLength {n = n} v = n\n\n headV : Vector A (suc n) → A\n headV (x :: _) = x\n\n tailV : Vector A (suc n) → Vector A n\n tailV (_ :: xs) = xs\n\n -- Matrices are defined as vector of vectors\n Matrix : (A : Set a) → (m n : ℕ) → Set a\n Matrix A m n = Vector (Vector A m) n\n\n matLength : Matrix A m n → ℕ × ℕ\n matLength {m = m} {n = n} mat = m , n\n\n -- Some examples\n v1 : Vector ℕ 4\n v1 = 1 :: 3 :: 4 :: 5 :: []\n\n m1 : Matrix ℕ 2 2\n m1 = (1 :: 2 :: []) :: (3 :: 4 :: []) :: []\n\n -- Some standard functions for working with vectors\n zipV : (A → B → C) → (Vector A n → Vector B n → Vector C n)\n zipV f [] [] = []\n zipV f (x :: xs) (y :: ys) = f x y :: zipV f xs ys\n\n mapV : (A → B) → Vector A n → Vector B n\n mapV f [] = []\n mapV f (x :: v) = f x :: mapV f v\n\n replicateV : A → Vector A n\n replicateV {n = zero} x = []\n replicateV {n = suc n} x = x :: replicateV x\n\n transpose : Matrix A m n → Matrix A n m\n transpose [] = replicateV []\n transpose (x :: xs) = ((zipV _::_) x) (transpose xs)\n\n -- Pointwise equality on vectors (lifting _∼_ from elements to vectors)\n data EqV {A : Set a} (_∼_ : A → A → Set c) :\n ∀ {m n} (xs : Vector A m) (ys : Vector A n) → Set (a ⊔ c)\n where\n eq-[] : EqV _∼_ [] []\n eq-:: : ∀ {m n x y} {xs : Vector A m} {ys : Vector A n}\n (x∼y : x ∼ y) (xs∼ys : EqV _∼_ xs ys) →\n EqV _∼_ (x :: xs) (y :: ys)\n \n-- Operations\n\n module Operations (R : Ring c ℓ) where\n open Ring R\n open Vector\n\n infixr 6 _+v_\n infixr 7 _◁_ _◁ₘ_ _x_ _⊗_ _*m_ \n\n sumV : Vector Carrier n → Carrier\n sumV {n = zero} v = 0#\n sumV {n = suc n} (x :: xs) = x + sumV {n} xs\n\n 0v : Vector Carrier n\n 0v = replicateV 0#\n\n 0m : Matrix Carrier m n\n 0m = replicateV 0v\n\n -- Vector addition\n _+v_ : Vector Carrier n → Vector Carrier n → Vector Carrier n\n _+v_ = zipV _+_\n\n -- Scale vector\n _◁_ : Carrier → Vector Carrier n → Vector Carrier n\n c ◁ v = mapV (c *_) v\n\n -- Dot product\n _•_ : Vector Carrier n → Vector Carrier n → Carrier\n u • v = sumV (zipV _*_ u v)\n\n -- Cross\n _x_ : Vector Carrier 3 → Vector Carrier 3 → Vector Carrier 3\n (v1 :: v2 :: v3 :: []) x (u1 :: u2 :: u3 :: []) = (v2 * u3 + -(v3 * u2) ::\n v3 * u1 + -(v1 * u3) ::\n v1 * u2 + -(v2 * u1) :: [])\n\n -- Outer product\n _⊗_ : Vector Carrier m → Vector Carrier n → Matrix Carrier n m\n _⊗_ [] ys = []\n _⊗_ (x :: xs) ys = mapV (x *_) ys :: xs ⊗ ys\n\n -- Scale matrix\n _◁ₘ_ : Carrier → Matrix Carrier m n → Matrix Carrier m n\n c ◁ₘ m = mapV (c ◁_) m\n\n -- Add matrix/matrix\n _+m_ : Matrix Carrier m n → Matrix Carrier m n → Matrix Carrier m n\n _+m_ = zipV _+v_\n\n -- Mul matrix/vector\n _*mv_ : Matrix Carrier n m → Vector Carrier n → Vector Carrier m\n [] *mv m = 0v\n m *mv v = mapV (_• v) m\n\n -- Mul matrix/matrix\n _*m_ : {m n o : ℕ} → Matrix Carrier m n → Matrix Carrier m o → Matrix Carrier n o \n _ *m [] = 0m\n m1 *m m2 = mapV (m1 *mv_) m2 \n \n Sign = Carrier\n altSumVHelp : Sign → Vector Carrier n → Carrier\n altSumVHelp s [] = 0#\n altSumVHelp s (x :: xs) = s * x + altSumVHelp (- s) xs\n\n altSumV : Vector Carrier n → Carrier\n altSumV = altSumVHelp 1# -- alternating sum: multiply every second term by minus one\n\n -- submatricesStep : Matrix Carrier m (suc (suc n)) → Vector (Matrix Carrier m (suc n)) (suc (suc n))\n submatricesStep : Matrix Carrier (suc (suc m)) n → Vector (Matrix Carrier (suc m) n) (suc (suc m)) \n\n -- submatrices : Matrix Carrier m (suc n) → Vector (Matrix Carrier m n) (suc n)\n submatrices : Matrix Carrier (suc m) n → Vector (Matrix Carrier m n) (suc m)\n submatrices {ℕ.zero} {n} ma = replicateV [] :: []\n submatrices {suc m} {n} ma = submatricesStep ma\n\n submatricesStep ma with mapV headV ma | mapV tailV ma \n submatricesStep ma | heads | tails with submatrices tails\n submatricesStep ma | heads | tails | rec = tails :: mapV (zipV _::_ heads) rec\n\n -- Determinant\n det : Matrix Carrier m m → Carrier\n det [] = 1#\n det (v :: m) = altSumV (zipV _*_ v (mapV det (submatrices m)))\n\n module Property (a11 a12 a21 a22 : Carrier) where\n\n m22 : Matrix Carrier 2 2\n m22 = (a11 :: a12 :: []) :: (a21 :: a22 :: []) :: []\n test : Carrier\n test = det m22\n \n \n -- Equality on our vectors is a lifted version of the\n -- underlying equality of the ring of components.\n _=v_ : Vector Carrier n → Vector Carrier m → Set (c ⊔ ℓ)\n _=v_ = EqV _≈_\n -- The equality type is basically just a vector of equality\n -- proofs between pairs of corresponding elements.\n\n -- Left and right proof of identity with vector addition\n vectorAddIdentityˡ : ∀ {n} (v1 : Vector Carrier n) → (0v +v v1) =v v1\n vectorAddIdentityˡ [] = eq-[]\n vectorAddIdentityˡ (x1 :: v1) = eq-::(+-identityˡ x1) (vectorAddIdentityˡ v1)\n\n vectorAddIdentityʳ : ∀ {n} (v1 : Vector Carrier n) → (v1 +v 0v) =v v1\n vectorAddIdentityʳ [] = eq-[]\n vectorAddIdentityʳ (x1 :: v1) = eq-::(+-identityʳ x1) (vectorAddIdentityʳ v1)\n \n -- Vector addition is commutative (statement, and inductive proof)\n vectorAddComm : ∀ {n} (v1 v2 : Vector Carrier n) →\n (v1 +v v2) =v (v2 +v v1)\n vectorAddComm [] [] = eq-[]\n vectorAddComm (x1 :: v1) (x2 :: v2) =\n eq-:: (+-comm x1 x2) (vectorAddComm v1 v2)\n\n -- Vector addition is associative (statement, and inductive proof)\n vectorAddAssoc : ∀ {n} (v1 v2 v3 : Vector Carrier n) →\n ((v1 +v v2) +v v3) =v (v1 +v (v2 +v v3))\n vectorAddAssoc [] [] [] = eq-[]\n vectorAddAssoc (x1 :: v1) (x2 :: v2) (x3 :: v3) =\n eq-:: (+-assoc x1 x2 x3) (vectorAddAssoc v1 v2 v3)\n\n dotComm : ∀ {n} (v1 v2 : Vector Carrier n) → (v1 • v2) ≈ (v2 • v1)\n dotComm [] v2 = refl\n dotComm (v1 :: vs) v2 = {!!} --hmmm\n\n module Morphism (G : Group c ℓ) (H : Group c₂ ℓ₂) where\n open Group G renaming (_∙_ to _*m_; ε to 0m)\n open Group H renaming (_∙_ to _*_; ε to 0#)\n\n \n -- show the determinant is a homomorphism\n\n", "meta": {"hexsha": "9e5553c7d11bbd18d2aa102a38d855480bc44c6b", "size": 7454, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/test.agda", "max_stars_repo_name": "DSLsofMath/BScProj2021", "max_stars_repo_head_hexsha": "87c0340515b0965454d9ba240ecc6de84b74ee0a", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2022-02-27T11:56:35.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-10T22:46:54.000Z", "max_issues_repo_path": "agda/test.agda", "max_issues_repo_name": "DSLsofMath/BScProj2021", "max_issues_repo_head_hexsha": "87c0340515b0965454d9ba240ecc6de84b74ee0a", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/test.agda", "max_forks_repo_name": "DSLsofMath/BScProj2021", "max_forks_repo_head_hexsha": "87c0340515b0965454d9ba240ecc6de84b74ee0a", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-02-02T18:02:43.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-02T18:02:43.000Z", "avg_line_length": 35.1603773585, "max_line_length": 109, "alphanum_fraction": 0.5005366246, "num_tokens": 2397, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9207896802383028, "lm_q2_score": 0.8152324915965392, "lm_q1q2_score": 0.7506576652570521}} {"text": "module BHeap.Properties {A : Set}(_≤_ : A → A → Set) where\n\nopen import Bound.Lower A\nopen import Bound.Lower.Order _≤_ \nopen import BHeap _≤_ \nopen import Data.List\nopen import Data.Nat \nopen import Data.Sum \nopen import Nat.Sum\nopen import List.Permutation.Base A\nopen import List.Permutation.Base.Concatenation A\nopen import List.Permutation.Base.Equivalence A\nopen import List.Properties A\nopen import Relation.Binary.Core\nopen import Relation.Binary.PropositionalEquality\n\nlemma-merge-lf : {b : Bound}(tot≤ : Total _≤_)(h : BHeap b) → merge tot≤ h lf ≡ h\nlemma-merge-lf _ lf = refl\nlemma-merge-lf _ (nd b≤x l r) = refl\n\nlemma-merge# : {b : Bound}(tot≤ : Total _≤_)(l r : BHeap b) → # (merge tot≤ l r) ≡ # l + # r\nlemma-merge# _ lf r = refl\nlemma-merge# tot≤ l lf rewrite lemma-merge-lf tot≤ l | +id (# l) = refl\nlemma-merge# tot≤ (nd {x = y} x≤y l r) (nd {x = y'} x≤y' l' r') \n with tot≤ y y'\n... | inj₁ y≤y' rewrite lemma-merge# tot≤ l r = refl\n... | inj₂ y'≤y rewrite lemma-merge# tot≤ l' r' | +assoc (# l + # r) (# l' + # r') = refl\n\nlemma-merge≤′ : {b : Bound}{x : A}(tot≤ : Total _≤_)(b≤x : LeB b (val x))(l r : BHeap (val x)) → suc (# (merge tot≤ l r)) ≤′ # (nd b≤x l r)\nlemma-merge≤′ tot≤ b≤x l r rewrite lemma-merge# tot≤ l r = ≤′-refl\n\nlemma-merge∼ : {b : Bound}(tot≤ : Total _≤_)(l r : BHeap b) → flatten (merge tot≤ l r) ∼ (flatten l ++ flatten r)\nlemma-merge∼ _ lf r = refl∼\nlemma-merge∼ tot≤ l lf rewrite lemma-merge-lf tot≤ l | ++id (flatten l) = refl∼\nlemma-merge∼ tot≤ (nd {x = y} b≤x l r) (nd {x = y'} b≤y' l' r') \n with tot≤ y y'\n... | inj₁ y≤y' = lemma++∼r (∼x /head /head (lemma-merge∼ tot≤ l r))\n... | inj₂ y'≤y = trans∼ (lemma++∼l {xs = y' ∷ (y ∷ flatten l ++ flatten r)} (lemma-merge∼ tot≤ l' r')) (∼x /head (lemma++/ {xs = y ∷ flatten l ++ flatten r}) refl∼)\n", "meta": {"hexsha": "33f3a49df229bde81e36210219064c5eb40fa071", "size": 1795, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/BHeap/Properties.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/BHeap/Properties.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/BHeap/Properties.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.0256410256, "max_line_length": 165, "alphanum_fraction": 0.6128133705, "num_tokens": 731, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9005297834483234, "lm_q2_score": 0.8333246015211009, "lm_q1q2_score": 0.7504336229499573}} {"text": "{-\n My first Proof in Agda\n-}\n\n-- define Natural numbers\n\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\n-- Simply defining 1\none : ℕ\none = suc(zero)\n\ntwo : ℕ\ntwo = suc(suc(zero))\n\n-- define addition of natural numbers\n\n_+_ : ℕ → ℕ → ℕ\nzero + n = n\n(suc m) + n = suc (m + n)\n\n\n-- Define equality\n\ndata _≡_ {A : Set} (a : A) : A → Set where\n refl : a ≡ a\n\n-- small test for equality\n\n-- oneplusoneistwo : one + one ≡ two\n-- oneplusoneistwo = refl\n\n-- Prove n+0 = n\n", "meta": {"hexsha": "d7ca397f86765e0071cdde3c5b09d23c99e75ab9", "size": 464, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Hello-Agda.agda", "max_stars_repo_name": "adithyaselv/Learn-Agda", "max_stars_repo_head_hexsha": "c506d7e317366443d6d17be943b95e46409c1570", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Hello-Agda.agda", "max_issues_repo_name": "adithyaselv/Learn-Agda", "max_issues_repo_head_hexsha": "c506d7e317366443d6d17be943b95e46409c1570", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Hello-Agda.agda", "max_forks_repo_name": "adithyaselv/Learn-Agda", "max_forks_repo_head_hexsha": "c506d7e317366443d6d17be943b95e46409c1570", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 12.8888888889, "max_line_length": 42, "alphanum_fraction": 0.5818965517, "num_tokens": 169, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9399133464597458, "lm_q2_score": 0.7981867681382279, "lm_q1q2_score": 0.750226396340691}} {"text": "------------------------------------------------------------------------------\n-- Propositional equality on inductive PA\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\n-- This file contains some definitions which are reexported by\n-- PA.Inductive.Base.\n\nmodule PA.Inductive.Relation.Binary.PropositionalEquality where\n\nopen import Common.FOL.FOL using ( ¬_ )\nopen import PA.Inductive.Base.Core\n\ninfix 4 _≡_ _≢_\n\n------------------------------------------------------------------------------\n-- The identity type on PA.\ndata _≡_ (x : ℕ) : ℕ → Set where\n refl : x ≡ x\n\n-- Inequality.\n_≢_ : ℕ → ℕ → Set\nx ≢ y = ¬ x ≡ y\n{-# ATP definition _≢_ #-}\n\n-- Identity properties\n\nsym : ∀ {x y} → x ≡ y → y ≡ x\nsym refl = refl\n\ntrans : ∀ {x y z} → x ≡ y → y ≡ z → x ≡ z\ntrans refl h = h\n\nsubst : (A : ℕ → Set) → ∀ {x y} → x ≡ y → A x → A y\nsubst A refl Ax = Ax\n\ncong : (f : ℕ → ℕ) → ∀ {x y} → x ≡ y → f x ≡ f y\ncong f refl = refl\n\ncong₂ : (f : ℕ → ℕ → ℕ) → ∀ {x x' y y'} → x ≡ y → x' ≡ y' → f x x' ≡ f y y'\ncong₂ f refl refl = refl\n", "meta": {"hexsha": "39529018339db884ed4bb6615840b16f8a3642a8", "size": 1226, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/PA/Inductive/Relation/Binary/PropositionalEquality.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/PA/Inductive/Relation/Binary/PropositionalEquality.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/PA/Inductive/Relation/Binary/PropositionalEquality.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 26.652173913, "max_line_length": 78, "alphanum_fraction": 0.4453507341, "num_tokens": 360, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9284087985746092, "lm_q2_score": 0.8080672135527632, "lm_q1q2_score": 0.7502167109020531}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Groups.Definition\nopen import Rings.Definition\nopen import Rings.IntegralDomains.Definition\nopen import Setoids.Setoids\nopen import Sets.EquivalenceRelations\n\n\nmodule Fields.FieldOfFractions.Addition {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ : A → A → A} {_*_ : A → A → A} {R : Ring S _+_ _*_} (I : IntegralDomain R) where\n\nopen import Fields.FieldOfFractions.Setoid I\n\nfieldOfFractionsPlus : fieldOfFractionsSet → fieldOfFractionsSet → fieldOfFractionsSet\nfieldOfFractionsSet.num (fieldOfFractionsPlus (record { num = a ; denom = b ; denomNonzero = b!=0 }) (record { num = c ; denom = d ; denomNonzero = d!=0 })) = (a * d) + (b * c)\nfieldOfFractionsSet.denom (fieldOfFractionsPlus (record { num = a ; denom = b ; denomNonzero = b!=0 }) (record { num = c ; denom = d ; denomNonzero = d!=0 })) = b * d\nfieldOfFractionsSet.denomNonzero (fieldOfFractionsPlus (record { num = a ; denom = b ; denomNonzero = b!=0 }) (record { num = c ; denom = d ; denomNonzero = d!=0 })) = λ pr → exFalso (d!=0 (IntegralDomain.intDom I pr b!=0))\n\n--record { num = ((a * d) + (b * c)) ; denom = b * d ; denomNonzero = λ pr → exFalso (d!=0 (IntegralDomain.intDom I pr b!=0)) }\n\nplusWellDefined : {a b c d : fieldOfFractionsSet} → (Setoid._∼_ fieldOfFractionsSetoid a c) → (Setoid._∼_ fieldOfFractionsSetoid b d) → Setoid._∼_ fieldOfFractionsSetoid (fieldOfFractionsPlus a b) (fieldOfFractionsPlus c d)\nplusWellDefined {record { num = a ; denom = b ; denomNonzero = b!=0 }} {record { num = c ; denom = d ; denomNonzero = d!=0 }} {record { num = e ; denom = f ; denomNonzero = f!=0 }} {record { num = g ; denom = h ; denomNonzero = h!=0 }} af=be ch=dg = need\n where\n open Setoid S\n open Ring R\n open Equivalence eq\n have1 : (c * h) ∼ (d * g)\n have1 = ch=dg\n have2 : (a * f) ∼ (b * e)\n have2 = af=be\n need : (((a * d) + (b * c)) * (f * h)) ∼ ((b * d) * (((e * h) + (f * g))))\n need = transitive (transitive (Ring.*Commutative R) (transitive (Ring.*DistributesOver+ R) (Group.+WellDefined (Ring.additiveGroup R) (transitive *Associative (transitive (*WellDefined (*Commutative) reflexive) (transitive (*WellDefined *Associative reflexive) (transitive (*WellDefined (*WellDefined have2 reflexive) reflexive) (transitive (symmetric *Associative) (transitive (*WellDefined reflexive *Commutative) (transitive *Associative (transitive (*WellDefined (transitive (transitive (symmetric *Associative) (*WellDefined reflexive *Commutative)) *Associative) reflexive) (symmetric *Associative))))))))) (transitive *Commutative (transitive (transitive (symmetric *Associative) (*WellDefined reflexive (transitive (*WellDefined reflexive *Commutative) (transitive *Associative (transitive (*WellDefined have1 reflexive) (transitive (symmetric *Associative) (*WellDefined reflexive *Commutative))))))) *Associative))))) (symmetric (Ring.*DistributesOver+ R))\n", "meta": {"hexsha": "50b9d3de1d020995ceaf5e4f297b309dbb7be4f6", "size": 2946, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Fields/FieldOfFractions/Addition.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Fields/FieldOfFractions/Addition.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Fields/FieldOfFractions/Addition.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 86.6470588235, "max_line_length": 970, "alphanum_fraction": 0.6880515954, "num_tokens": 936, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9284087946129328, "lm_q2_score": 0.8080672089305841, "lm_q1q2_score": 0.7502167034094805}} {"text": "module FRP.JS.Bool where\n\nopen import FRP.JS.Primitive public using ( Bool ; true ; false )\n\nnot : Bool → Bool\nnot true = false\nnot false = true\n\n{-# COMPILED_JS not function(x) { return !x; } #-}\n\n_≟_ : Bool → Bool → Bool\ntrue ≟ b = b\nfalse ≟ b = not b\n\n{-# COMPILED_JS _≟_ function(x) { return function(y) { return x === y; }; } #-}\n\nif_then_else_ : ∀ {α} {A : Set α} → Bool → A → A → A\nif true then t else f = t\nif false then t else f = f\n\n{-# COMPILED_JS if_then_else_ function(a) { return function(A) { return function(x) {\n if (x) { return function(t) { return function(f) { return t; }; }; }\n else { return function(t) { return function(f) { return f; }; }; }\n}; }; } #-}\n\n_∧_ : Bool → Bool → Bool\ntrue ∧ b = b\nfalse ∧ b = false\n\n{-# COMPILED_JS _∧_ function(x) { return function(y) { return x && y; }; } #-}\n\n_∨_ : Bool → Bool → Bool\ntrue ∨ b = true\nfalse ∨ b = b\n\n{-# COMPILED_JS _∨_ function(x) { return function(y) { return x || y; }; } #-}\n\n_xor_ : Bool → Bool → Bool\ntrue xor b = not b\nfalse xor b = b\n\n_≠_ = _xor_\n\n{-# COMPILED_JS _xor_ function(x) { return function(y) { return x !== y; }; } #-}\n{-# COMPILED_JS _≠_ function(x) { return function(y) { return x !== y; }; } #-}\n", "meta": {"hexsha": "10cd888130166c22318e7abe37e44f4f68601f1e", "size": 1199, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/agda/FRP/JS/Bool.agda", "max_stars_repo_name": "agda/agda-frp-js", "max_stars_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_stars_repo_licenses": ["MIT", "BSD-3-Clause"], "max_stars_count": 63, "max_stars_repo_stars_event_min_datetime": "2015-04-20T21:47:00.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-28T09:46:14.000Z", "max_issues_repo_path": "src/agda/FRP/JS/Bool.agda", "max_issues_repo_name": "agda/agda-frp-js", "max_issues_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_issues_repo_licenses": ["MIT", "BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/agda/FRP/JS/Bool.agda", "max_forks_repo_name": "agda/agda-frp-js", "max_forks_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_forks_repo_licenses": ["MIT", "BSD-3-Clause"], "max_forks_count": 7, "max_forks_repo_forks_event_min_datetime": "2016-11-07T21:50:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:38.000Z", "avg_line_length": 26.0652173913, "max_line_length": 85, "alphanum_fraction": 0.5863219349, "num_tokens": 406, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9099070060380482, "lm_q2_score": 0.8244619242200082, "lm_q1q2_score": 0.7501836810593958}} {"text": "module Self where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl; cong; sym)\n\ndata B : Set where\n T : B\n F : B\n\n_&&_ : B -> B -> B\ninfixl 20 _&&_\nT && T = T\nT && F = F\nF && _ = F\n\n_||_ : B -> B -> B\ninfixl 15 _||_\nT || _ = T\nF || T = T\nF || F = F\n\np||p≡p : ∀ (p : B) -> p || p ≡ p\np||p≡p T = refl\np||p≡p F = refl\n\np&&p≡p : ∀ (p : B) -> p && p ≡ p\np&&p≡p T = refl\np&&p≡p F = refl\n\n-- 交换律\n\na&&b≡b&&a : ∀ (a b : B) -> a && b ≡ b && a\na&&b≡b&&a T T = refl\na&&b≡b&&a T F = refl\na&&b≡b&&a F T = refl\na&&b≡b&&a F F = refl\n\na||b≡b||a : ∀ (a b : B) -> a || b ≡ b || a\na||b≡b||a T T = refl\na||b≡b||a T F = refl\na||b≡b||a F T = refl\na||b≡b||a F F = refl\n\nabc||abc : ∀ (a b c : B) -> (a || b) || c ≡ a || (b || c)\nabc||abc T b c = refl\nabc||abc F T c = refl\nabc||abc F F T = refl\nabc||abc F F F = refl\n\nabc&&abc : ∀ (a b c : B) -> a && b && c ≡ a && (b && c)\nabc&&abc T T T = refl\nabc&&abc T T F = refl\nabc&&abc T F c = refl\nabc&&abc F b c = refl\n\n-- 分配律\n\na&&b||c≡a&&b||a&&c : ∀ (a b c : B) -> a && (b || c) ≡ a && b || a && c\na&&b||c≡a&&b||a&&c T T c = refl\na&&b||c≡a&&b||a&&c T F T = refl\na&&b||c≡a&&b||a&&c T F F = refl\na&&b||c≡a&&b||a&&c F T c = refl\na&&b||c≡a&&b||a&&c F F c = refl\n\na||b&&c≡a||b&&a||c : ∀ (a b c : B) -> a || b && c ≡ (a || b) && (a || c)\na||b&&c≡a||b&&a||c T b c = refl\na||b&&c≡a||b&&a||c F T T = refl\na||b&&c≡a||b&&a||c F T F = refl\na||b&&c≡a||b&&a||c F F c = refl\n\nT&&p≡p : ∀ (p : B) -> T && p ≡ p\nT&&p≡p T = refl\nT&&p≡p F = refl\n\nF||p≡p : ∀ (p : B) -> F || p ≡ p\nF||p≡p T = refl\nF||p≡p F = refl\n\n¬_ : B -> B\ninfix 25 ¬_\n¬ F = T\n¬ T = F\n\n-- 负负得正\n¬¬p≡p : ∀ (p : B) -> ¬ (¬ p) ≡ p\n¬¬p≡p T = refl\n¬¬p≡p F = refl\n\n-- 德·摩根律\n\n¬a&&b≡¬a||¬b : ∀ (a b : B) -> ¬ (a && b) ≡ ¬ a || ¬ b\n¬a&&b≡¬a||¬b T T = refl\n¬a&&b≡¬a||¬b T F = refl\n¬a&&b≡¬a||¬b F T = refl\n¬a&&b≡¬a||¬b F F = refl\n\n¬a||b≡¬a&&¬b : ∀ (a b : B) -> ¬ (a || b) ≡ ¬ a && ¬ b\n¬a||b≡¬a&&¬b T T = refl\n¬a||b≡¬a&&¬b T F = refl\n¬a||b≡¬a&&¬b F T = refl\n¬a||b≡¬a&&¬b F F = refl\n\n-- 自反律\n\np&&¬p≡F : ∀ (p : B) -> p && ¬ p ≡ F\np&&¬p≡F T = refl\np&&¬p≡F F = refl\n\n-- 排中律\n\n¬p||p≡T : ∀ (p : B) -> ¬ p || p ≡ T\n¬p||p≡T T = refl\n¬p||p≡T F = refl\n\n-- 蕴含 如果 .. 就\n\n_to_ : B -> B -> B\ninfixl 10 _to_\nT to F = F\nT to T = T\nF to _ = T\n\n-- 蕴含等值推演\nptoq≡¬p||q : ∀ (p q : B) -> p to q ≡ ¬ p || q\nptoq≡¬p||q T T = refl\nptoq≡¬p||q T F = refl\nptoq≡¬p||q F q = refl\n\nTtop≡p : ∀ (p : B) -> T to p ≡ p\nTtop≡p T = refl\nTtop≡p F = refl\n\nFtop≡T : ∀ (p : B) -> F to p ≡ T\nFtop≡T p = refl\n\n-- 等价\n\n_<>_ : B -> B -> B\ninfixl 10 _eq_\nT <> T = T\nF <> T = F\nT <> F = F\nF <> F = T\n\n-- 等价等值式\np<>q≡ptoq&&qtop : ∀ (p q : B) -> p <> q ≡ (p to q) && (q to p)\np<>q≡ptoq&&qtop T T = refl\np<>q≡ptoq&&qtop T F = refl\np<>q≡ptoq&&qtop F T = refl\np<>q≡ptoq&&qtop F F = refl\n\n-- lemma 01\n\np||q&&¬q≡p : ∀ (p q : B) -> p || q && ¬ q ≡ p\np||q&&¬q≡p T T = refl\np||q&&¬q≡p T F = refl\np||q&&¬q≡p F q rewrite p&&¬p≡F q = refl\n\n-- proof 01\n\np&&q||p&&¬q≡p : ∀ (p q : B) -> p && q || p && ¬ q ≡ p \np&&q||p&&¬q≡p T T = refl\np&&q||p&&¬q≡p T F = refl\np&&q||p&&¬q≡p F q = refl\n\n-- proof 02\n\natob≡¬bto¬a : ∀ (a b : B) -> a to b ≡ ¬ b to ¬ a\natob≡¬bto¬a a b\n rewrite ptoq≡¬p||q a b\n | ptoq≡¬p||q (¬ b) (¬ a)\n | a||b≡b||a (¬ a) b\n | ¬¬p≡p b = refl\n\nimplies₁ : ∀ (p q r s : B) -> ((p to (q to r)) && (¬ s || p) && q) to (s to r) ≡ T\nimplies₁ T T T T = refl\nimplies₁ T T T F = refl\nimplies₁ T T F s = refl\nimplies₁ T F T T = refl\nimplies₁ T F T F = refl\nimplies₁ T F F T = refl\nimplies₁ T F F F = refl\nimplies₁ F T T T = refl\nimplies₁ F T T F = refl\nimplies₁ F T F T = refl\nimplies₁ F T F F = refl\nimplies₁ F F r T = refl\nimplies₁ F F r F = refl\n", "meta": {"hexsha": "2852390130abeeb86119492fb2ee970ed59edf64", "size": 3575, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Self.agda", "max_stars_repo_name": "kands-code/agda-exercise", "max_stars_repo_head_hexsha": "b3c9c4f678feac75af6f30d0dd941ab58b9f40dd", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Self.agda", "max_issues_repo_name": "kands-code/agda-exercise", "max_issues_repo_head_hexsha": "b3c9c4f678feac75af6f30d0dd941ab58b9f40dd", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Self.agda", "max_forks_repo_name": "kands-code/agda-exercise", "max_forks_repo_head_hexsha": "b3c9c4f678feac75af6f30d0dd941ab58b9f40dd", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.9153439153, "max_line_length": 82, "alphanum_fraction": 0.4321678322, "num_tokens": 2013, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8933094003735663, "lm_q2_score": 0.8397339656668287, "lm_q1q2_score": 0.7501422453431517}} {"text": "{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule SL where\n\nopen import Data.Nat\nopen import Data.Product\nopen import Data.Sum\nopen import Relation.Binary.PropositionalEquality\n\n-- Example from: Hofmann and Streicher. The groupoid model refutes\n-- uniqueness of identity proofs.\nthm₁ : ∀ n → n ≡ 0 ⊎ Σ ℕ (λ n' → n ≡ suc n')\nthm₁ zero = inj₁ refl\nthm₁ (suc n) = inj₂ (n , refl)\n\npostulate indℕ : (P : ℕ → Set) → P 0 → (∀ n → P n → P (suc n)) → ∀ n → P n\n\nthm₂ : ∀ n → n ≡ 0 ⊎ Σ ℕ λ n' → n ≡ suc n'\nthm₂ = indℕ P P0 is\n where\n P : ℕ → Set\n P m = m ≡ 0 ⊎ Σ ℕ λ m' → m ≡ suc m'\n\n P0 : P 0\n P0 = inj₁ refl\n\n is : ∀ m → P m → P (suc m)\n is m _ = inj₂ (m , refl)\n", "meta": {"hexsha": "a46d9efb64def5bcb16f802904a485a6a2536168", "size": 808, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/k-axiom/SL.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "notes/k-axiom/SL.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "notes/k-axiom/SL.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 25.25, "max_line_length": 74, "alphanum_fraction": 0.5457920792, "num_tokens": 292, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9149009596336302, "lm_q2_score": 0.8198933403143929, "lm_q1q2_score": 0.7501212038508606}}