{"text": "import 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{- Addition -}\n\n_+_ : ℕ → ℕ → ℕ\nzero + n = n\n(suc m) + n = suc (m + n)\n\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\n_ : 1 + 1 ≡ 2\n_ = refl\n\n{- Multiplication -}\n\n_*_ : ℕ → ℕ → ℕ\nzero * n = zero\n(suc m) * n = n + (m * n)\n\n_ : 2 * 2 ≡ 4\n_ =\n begin\n 2 * 2\n ≡⟨⟩\n 2 + (1 * 2)\n ≡⟨⟩\n 2 + (2 + (0 * 2))\n ≡⟨⟩\n 2 + 2\n ≡⟨⟩\n 4\n ∎\n\n_ : 1 * 1 ≡ 1\n_ = refl\n\n{- Exponentiation -}\n\n_^_ : ℕ → ℕ → ℕ\nn ^ 0 = 1\nn ^ (suc m) = n * (n ^ m)\n\n_ : 2 ^ 3 ≡ 8\n_ =\n begin\n 2 ^ 3\n ≡⟨⟩\n 2 * (2 ^ 2)\n ≡⟨⟩\n 2 * (2 * (2 ^ 1))\n ≡⟨⟩\n 2 * (2 * (2 * (2 ^ 0)))\n ≡⟨⟩\n 2 * (2 * (2 * 1))\n ≡⟨⟩\n 8\n ∎\n\n_ : 42 ^ 0 ≡ 1\n_ = refl\n\n{- Monus -}\n\n_∸_ : ℕ → ℕ → ℕ\nm ∸ zero = m\nzero ∸ (suc n) = zero\n(suc m) ∸ (suc n) = m ∸ n\n\n_ : 2 ∸ 1 ≡ 1\n_ =\n begin\n 2 ∸ 1\n ≡⟨⟩\n 1 ∸ 0\n ≡⟨⟩\n 1\n ∎\n\n_ : 7 ∸ 4 ≡ 3\n_ = refl\n\n_ : 4 ∸ 7 ≡ 0\n_ = refl\n", "meta": {"hexsha": "0e5c5c77e66b3e256aa745eb27d76e9c4057952e", "size": 1180, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/proof-nat.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/proof-nat.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/proof-nat.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": 11.1320754717, "max_line_length": 50, "alphanum_fraction": 0.356779661, "num_tokens": 689, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9546474155747541, "lm_q2_score": 0.8887587868629346, "lm_q1q2_score": 0.8484512789480543}} {"text": "{-# OPTIONS --without-K #-}\n\n-- Some basic theorms about natural numbers.\nmodule hott.types.nat.theorems where\n\nopen import hott.core\nopen import hott.functions\nopen import hott.types.nat\n\n-- 0 is the right identity of addition.\nx+0≡x : ∀(x : ℕ) → x + 0 ≡ x\nx+0≡x 0 = begin 0 + 0 ≡ 0 by definition ∎\nx+0≡x (succ n)\n = begin succ n + 0 ≡ succ (n + 0) by definition\n ≡ succ n by ap succ (x+0≡x (n))\n ∎\n\n-- Alternate from of 0 being right identity.\nx≡x+0 : ∀(x : ℕ) → x ≡ x + 0\nx≡x+0 n = x+0≡x n ⁻¹\n\n-- This is really refl but it is better to use these when proving\n-- properties about ℕ. One does not have to remember which is\n-- definitional equality and which is not.\n0+x≡x : ∀ (x : ℕ) → 0 + x ≡ x\n0+x≡x n = begin 0 + n ≡ n by definition ∎\n\n-- This is really refl but it is better to use these when proving\n-- properties about ℕ. One does not have to remember which is\n-- definitional equality and which is not.\nx≡0+x : ∀ (x : ℕ) → x ≡ 0 + x\nx≡0+x n = begin n ≡ 0 + n by definition ∎\n\n-- Commutativity of addition.\nx+y≡y+x : ∀ (x y : ℕ) → x + y ≡ y + x\nx+y≡y+x 0 n\n = begin 0 + n ≡ n by definition\n ≡ n + 0 by x≡x+0 (n)\n ∎\nx+y≡y+x n 0\n = begin n + 0 ≡ n by x+0≡x (n)\n ≡ 0 + n by definition\n ∎\nx+y≡y+x (succ m) (succ n)\n = begin succ m + succ n\n ≡ succ (m + succ n) by definition\n ≡ succ (succ n + m) by applying succ on x+y≡y+x m (succ n)\n ≡ succ (succ (n + m)) by definition\n ≡ succ (succ (m + n)) by applying succ ∘ succ on (x+y≡y+x n m)\n ≡ succ (succ m + n) by applying succ on definition\n ≡ succ (n + succ m) by applying succ on x+y≡y+x (succ m) n\n ≡ succ n + succ m by definition\n ∎\n-- Associativity of +\nx+[y+z]≡[x+y]+z : ∀ (x y z : ℕ) → x + (y + z) ≡ (x + y) + z\nx+[y+z]≡[x+y]+z zero y z\n = begin 0 + (y + z)\n ≡ y + z by definition\n ≡ (0 + y) + z by definition\n ∎\nx+[y+z]≡[x+y]+z (succ x) y z\n = begin succ x + (y + z)\n ≡ succ (x + (y + z)) by definition\n ≡ succ ((x + y) + z) by applying succ on x+[y+z]≡[x+y]+z x y z\n ≡ succ (x + y) + z by definition\n ≡ (succ x + y) + z by definition\n ∎\n", "meta": {"hexsha": "0ca782ed9a1f13c569bc58075551a95a7e8d60e4", "size": 2337, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/hott/types/nat/theorems.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/theorems.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/theorems.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": 34.3676470588, "max_line_length": 72, "alphanum_fraction": 0.5002139495, "num_tokens": 867, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.965899575269305, "lm_q2_score": 0.8705972549785201, "lm_q1q2_score": 0.8409095188143755}} {"text": "\nmodule Nat where\n\nimport Bool\nopen Bool\n\ndata Nat : Set where\n zero : Nat\n suc : Nat -> Nat\n\ninfixr 25 _+_\n\n_+_ : Nat -> Nat -> Nat\nzero + m = m\nsuc n + m = suc (n + m)\n\ninfix 10 _==_ _<_\n\n_==_ : Nat -> Nat -> Bool\nzero == zero = true\nsuc n == zero = false\nzero == suc m = 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{-# BUILTIN NATURAL Nat #-}\n{-# BUILTIN ZERO zero #-}\n{-# BUILTIN SUC suc #-}\n-- {-# BUILTIN NATPLUS _+_ #-}\n-- {-# BUILTIN NATEQUALS _==_ #-}\n-- {-# BUILTIN NATLESS _<_ #-}\n\n", "meta": {"hexsha": "88aa22dac0138be998c44c544769852b631cbf36", "size": 579, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "benchmark/ac/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": "benchmark/ac/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": "benchmark/ac/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": 15.6486486486, "max_line_length": 33, "alphanum_fraction": 0.5354058722, "num_tokens": 211, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9664104924150547, "lm_q2_score": 0.8688267779364222, "lm_q1q2_score": 0.8396433142889231}} {"text": "module plfa-code.Naturals where\n\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\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\nsuc m + n = suc (m + n)\n\n_ : 2 + 3 ≡ 5\n_ = refl\n\n_*_ : ℕ → ℕ → ℕ\nzero * n = zero\nsuc m * n = n + (m * n)\n\n_^_ : ℕ → ℕ → ℕ\nn ^ zero = suc zero\nn ^ (suc m) = n * (n ^ m)\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_ =\n begin\n 3 ∸ 2\n ≡⟨⟩\n 2 ∸ 1\n ≡⟨⟩\n 1 ∸ 0\n ≡⟨⟩\n 1\n ∎\n\n_ =\n begin\n 2 ∸ 3\n ≡⟨⟩\n 1 ∸ 2\n ≡⟨⟩\n 0 ∸ 1\n ≡⟨⟩\n 0\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 = x1 nil\ninc (x0 t) = x1 t\ninc (x1 t) = x0 (inc t)\n\n_ : inc (x1 x1 x0 x1 nil) ≡ x0 x0 x1 x1 nil\n_ = refl\n\n_ : inc (x0 nil) ≡ x1 nil\n_ = refl\n\n_ : inc (x1 nil) ≡ x0 x1 nil\n_ = refl\n\n_ : inc (x0 x1 nil) ≡ x1 x1 nil\n_ = refl\n\n_ : inc (x1 x1 nil) ≡ x0 x0 x1 nil\n_ = refl\n\nto : ℕ → Bin\nto 0 = x0 nil\nto (suc n) = inc (to n)\n\nfrom : Bin → ℕ\nfrom nil = 0\nfrom (x0 t) = (from t) * 2\nfrom (x1 t) = (from t) * 2 + 1\n\n_ : to 0 ≡ x0 nil\n_ = refl\n\n_ : to 1 ≡ x1 nil\n_ = refl\n\n_ : to 2 ≡ x0 x1 nil\n_ = refl\n\n_ : to 3 ≡ x1 x1 nil\n_ = refl\n\n_ : to 4 ≡ x0 x0 x1 nil\n_ = refl\n\n_ : 0 ≡ from (x0 nil)\n_ = refl\n\n_ : 1 ≡ from (x1 nil)\n_ = refl\n\n_ : 2 ≡ from (x0 x1 nil)\n_ = refl\n\n_ : 3 ≡ from (x1 x1 nil)\n_ = refl\n\n_ : 4 ≡ from (x0 x0 x1 nil)\n_ = refl\n\n", "meta": {"hexsha": "4dba82f3a117ac414a87d2107e2dea0061489b47", "size": 1752, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/plfa-code/Naturals.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/Naturals.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/Naturals.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": 12.5142857143, "max_line_length": 50, "alphanum_fraction": 0.4474885845, "num_tokens": 942, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9532750400464604, "lm_q2_score": 0.8774767986961401, "lm_q1q2_score": 0.8364767304169028}} {"text": "open import Relation.Binary.Core\n\nmodule InsertSort.Impl1.Correctness.Order {A : Set}\n (_≤_ : A → A → Set)\n (tot≤ : Total _≤_) where\n\nopen import Data.List\nopen import Data.Sum\nopen import InsertSort.Impl1 _≤_ tot≤\nopen import List.Sorted _≤_\n\nlemma-insert-sorted : {xs : List A}(x : A) → Sorted xs → Sorted (insert x xs)\nlemma-insert-sorted {xs = .[]} x nils = singls x \nlemma-insert-sorted {xs = .([ y ])} x (singls y) \n with tot≤ x y\n... | inj₁ x≤y = conss x≤y (singls y)\n... | inj₂ y≤x = conss y≤x (singls x) \nlemma-insert-sorted x (conss {y} {z} {ys} y≤z szys)\n with tot≤ x y \n... | inj₁ x≤y = conss x≤y (conss y≤z szys)\n... | inj₂ y≤x \n with tot≤ x z | lemma-insert-sorted x szys\n... | inj₁ x≤z | _ = conss y≤x (conss x≤z szys)\n... | inj₂ z≤x | h = conss y≤z h \n\ntheorem-insertSort-sorted : (xs : List A) → Sorted (insertSort xs)\ntheorem-insertSort-sorted [] = nils\ntheorem-insertSort-sorted (x ∷ xs) = lemma-insert-sorted x (theorem-insertSort-sorted xs) \n\n\n", "meta": {"hexsha": "3068da93d10bacba9fe4bcf79b488018e4f890ae", "size": 1013, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/InsertSort/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/InsertSort/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/InsertSort/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": 32.6774193548, "max_line_length": 90, "alphanum_fraction": 0.614017769, "num_tokens": 377, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9481545392102522, "lm_q2_score": 0.8807970873650401, "lm_q1q2_score": 0.8351317565083318}} {"text": "{-\n\nhttps://serokell.io/blog/playing-with-negation\n\nConstructive and Non-Constructive Proofs in Agda (Part 3): Playing with Negation\n\nDanya Rogozin Friday, November 30th, 2018\n\n\nPresent an empty type to work with constructive negation.\nDiscuss Markov’s principle and apply this principle for one use case.\nDeclare the double negation elimination as a postulate.\nSome examples of non-constructive proofs in Agda.\n\n------------------------------------------------------------------------------\nEmpty type\n\n-}\n-- Type with no constructors (so-called bottom).\n-- Type that corresponds to an absurd statement or contradiction.\ndata ⊥ : Set where\n\n-- ¬ defines negation. ¬A denotes that any proof of A yields a proof of a contradiction:\n\n¬_ : Set → Set\n¬ A = A → ⊥\n\n-- elimination of ⊥ : derives an arbitrary statement from bottom\nexFalso : {A : Set} → ⊥ → A\nexFalso ()\n\n-- examples of propositions with negation that are provable constructively.\n\n-- Derives an arbitrary formula from a contradiction.\n-- The first argument f has a type ¬ A (or A → ⊥).\n-- The second argument x has a type A.\n-- Thus f x is an object of type ⊥.\n-- Hence exContr (f x) has a type B.\nexContr : {A B : Set} → ¬ A → A → B\nexContr f x = exFalso (f x)\n\nexContr2 : {A B : Set} → (A → ⊥) → A → B\nexContr2 f x = exFalso (f x)\n\n-- g proves B → ⊥\n-- f proves A → B\n-- g ∘ f proves A → ⊥, i.e. ¬ A.\ncontraposition : {A B : Set} → (A → B) → (¬ B → ¬ A)\ncontraposition f g = g ∘ f\n\n-- negation on formula A.\n-- If possible to derive contradictionary consequences B and ¬ B from the statement A,\n-- then any proof of A yields ⊥.\n¬-intro : {A B : Set} → (A → B) → (A → ¬ B) → ¬ A\n¬-intro f g x = g x (f x)\n\n{-\ndisjImpl establishes a connection between disjunction and implication.\nIf prove ¬ A ∨ B and have a proof of A.\nIf have a proof of ¬ A, then we have proved B by ex-falso.\nIf have a proof of B, then we have already proved B trivially.\nSo, we have obtained a proof of B by case analysis (i.e., pattern-matching).\n-}\ndisjImpl : {A B : Set} → ¬ A ⊎ B → A → B\ndisjImpl (inj₁ x) a = exContr x a\ndisjImpl (inj₂ y) a = y\n\n\n\n\n\n\n", "meta": {"hexsha": "aebce9b9798bcec41bf26eae3703be86cc9ea018", "size": 2089, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/paper/2018-11-danya-rogozin-serokell-constructive-and-non-cons-proofs-in-agda/src/Part3_Playing_with_Negation.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/2018-11-danya-rogozin-serokell-constructive-and-non-cons-proofs-in-agda/src/Part3_Playing_with_Negation.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/2018-11-danya-rogozin-serokell-constructive-and-non-cons-proofs-in-agda/src/Part3_Playing_with_Negation.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.6164383562, "max_line_length": 88, "alphanum_fraction": 0.6467209191, "num_tokens": 620, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9511422220702924, "lm_q2_score": 0.8757870029950159, "lm_q1q2_score": 0.8329979960889613}} {"text": "module simpleAgda where\n\n-- main : IO ()\n-- main = putStrLn \"Testing simple Idris\"\n\n--\n-- Some simple equivalent Idris and Agda code.\n--\n\n-- data N = Z | Suc N\ndata N : Set where\n Z : N\n suc : N -> N\n \n-- one : N\n-- one = Suc Z\none : N\none = suc Z\n\n-- addOne : N -> N\n-- addOne Z = Suc Z\n-- addOne (Suc n) = Suc (Suc n)\n\naddOne : N -> N\naddOne Z = suc Z\naddOne (suc a) = suc (suc a)\n\n-- add : N -> N -> N\n-- add Z s = s\n-- add (Suc a) b = add a (Suc b)\nadd : N -> N -> N\nadd Z s = s\nadd (suc a) b = add a (suc b)\n\n-- data Vec : Type -> N -> Type where\n-- Nil : Vec a Z\n-- (::) : a -> Vec a n -> Vec a (Suc n)\ndata Vec (A : Set) : N -> Set where\n Nil : Vec A Z \n cons : {n : N} -> A -> Vec A n -> Vec A (suc n)\n \n-- empt : Vec N Z\n-- empt = Nil\nempt : Vec N Z\nempt = Nil\n\nopen import Agda.Builtin.Nat\n-- test : Vec Nat (Suc Main.one)\n-- test = 1 :: 2 :: Nil\ntest : Vec Nat (suc (suc Z))\ntest = cons 1 (cons 2 Nil)\n\n-- test2 : Vec Nat (Suc (Suc Main.one))\n-- test2 = 3 :: 4 :: 5 :: Nil\ntest2 : Vec Nat (suc (suc (suc Z)))\ntest2 = cons 3 (cons 4 (cons 5 Nil))\n\n-- concat : Vec g a -> Vec g b -> Vec g (add a b)\n-- concat Nil rest = rest\n-- concat (a :: rest) b = concat rest (a :: b)\nconcat : {a b : N} {g : Set} -> (Vec g a) -> (Vec g b) -> (Vec g (add a b))\nconcat Nil rest = rest\nconcat (cons a rest) b = concat rest (cons a b)\n\n-- t3 : Vec (addOne $ addOne $ addOne $ addOne Main.one) Nat\n-- t3 = concat test test2\nt3 : Vec Nat (addOne (addOne (addOne (addOne one))))\nt3 = concat test test2\n", "meta": {"hexsha": "4ae8c4c37f722608110d621384f8130f94efb44e", "size": 1502, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "simpleAgda.agda", "max_stars_repo_name": "hjorthjort/IdrisToAgda", "max_stars_repo_head_hexsha": "a5f65e28cc9fdfefde49e7d8cf84486601b9e7b1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-02-16T23:22:50.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-29T20:42:43.000Z", "max_issues_repo_path": "simpleAgda.agda", "max_issues_repo_name": "hjorthjort/IdrisToAgda", "max_issues_repo_head_hexsha": "a5f65e28cc9fdfefde49e7d8cf84486601b9e7b1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-11-28T17:52:42.000Z", "max_issues_repo_issues_event_max_datetime": "2019-11-28T17:52:42.000Z", "max_forks_repo_path": "simpleAgda.agda", "max_forks_repo_name": "hjorthjort/IdrisToAgda", "max_forks_repo_head_hexsha": "a5f65e28cc9fdfefde49e7d8cf84486601b9e7b1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-11-27T16:25:18.000Z", "max_forks_repo_forks_event_max_datetime": "2019-11-27T16:25:18.000Z", "avg_line_length": 21.768115942, "max_line_length": 75, "alphanum_fraction": 0.5439414115, "num_tokens": 567, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9669140216112959, "lm_q2_score": 0.8596637559030338, "lm_q1q2_score": 0.8312209394536738}} {"text": "module Relation.Unary.Membership {a} (A : Set a) where\n\nopen import Level\nopen import Data.Product using (_×_; _,_; proj₁; proj₂)\nopen import Relation.Unary\nopen import Relation.Binary\n\ninfixl 4 _≋_\n_≋_ : Rel (Pred A a) _\nP ≋ Q = P ⊆′ Q × Q ⊆′ P\n\n⊆-refl : Reflexive (_⊆′_ {a} {A} {a})\n⊆-refl {pred} x P = P\n\n≋-refl : Reflexive _≋_\n≋-refl {pred} = (⊆-refl {pred}) , (⊆-refl {pred})\n\n≋-sym : Symmetric _≋_\n≋-sym x = (proj₂ x) , (proj₁ x)\n\n≋-trans : Transitive _≋_\n≋-trans f≋g g≋h =\n (λ x z → proj₁ g≋h x (proj₁ f≋g x z)) , (λ x z → proj₂ f≋g x (proj₂ g≋h x z))\n\n≋-isEquivalence : IsEquivalence _≋_\n≋-isEquivalence = record\n { refl = ≋-refl\n ; sym = ≋-sym\n ; trans = ≋-trans\n }\n\n⊆-trans : Transitive (_⊆′_ {a} {A} {a})\n⊆-trans A⊆B B⊆C x x∈A = B⊆C x (A⊆B x x∈A)\n\n⊆-preorder : IsPreorder _≋_ _⊆′_\n⊆-preorder = record\n { isEquivalence = ≋-isEquivalence\n ; reflexive = proj₁\n ; trans = ⊆-trans\n }\n\n⊆-partialOrder : IsPartialOrder _≋_ _⊆′_\n⊆-partialOrder = record\n { isPreorder = ⊆-preorder\n ; antisym = λ A⊆B B⊆A → A⊆B , B⊆A\n }\n\n⊆-poset : Poset (suc a) a a\n⊆-poset = record\n { Carrier = Pred A a\n ; _≈_ = _≋_\n ; _≤_ = _⊆′_\n ; isPartialOrder = ⊆-partialOrder\n }\n\nmodule ⊆-Reasoning where\n import Relation.Binary.PartialOrderReasoning as PosetR\n open PosetR ⊆-poset public\n renaming (_≤⟨_⟩_ to _⊆⟨_⟩_)\n\n infix 1 _∈⟨_⟩_\n infixr 2 _→⟨_⟩_\n\n _∈⟨_⟩_ : ∀ x {xs ys} → x ∈ xs → xs IsRelatedTo ys → x ∈ ys\n x ∈⟨ x∈xs ⟩ xs⊆ys = begin_ xs⊆ys x x∈xs\n\n _→⟨_⟩_ : ∀ A {B C} → (A ⊆ B) → B IsRelatedTo C → A IsRelatedTo C\n A →⟨ f ⟩ B∼C = A ⊆⟨ (λ x x∈A → f x∈A) ⟩ B∼C\n -- A ⊆[ f ] relTo B∼C = A ⊆⟨ f ⟩ relTo B∼C\n --\n\n --(begin xs⊆ys) x∈xs\n", "meta": {"hexsha": "46f863ac7f1129cb961fd30cf7fce6d11b3de91e", "size": 1707, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Relation/Unary/Membership.agda", "max_stars_repo_name": "banacorn/formal-language", "max_stars_repo_head_hexsha": "063ae0ce03955b332c3edebae6b55a42209813d0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2015-06-01T11:24:15.000Z", "max_stars_repo_stars_event_max_datetime": "2020-11-22T12:48:25.000Z", "max_issues_repo_path": "src/Relation/Unary/Membership.agda", "max_issues_repo_name": "banacorn/formal-language", "max_issues_repo_head_hexsha": "063ae0ce03955b332c3edebae6b55a42209813d0", "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/Relation/Unary/Membership.agda", "max_forks_repo_name": "banacorn/formal-language", "max_forks_repo_head_hexsha": "063ae0ce03955b332c3edebae6b55a42209813d0", "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.3835616438, "max_line_length": 81, "alphanum_fraction": 0.5506736965, "num_tokens": 845, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9465966702001757, "lm_q2_score": 0.8774767858797979, "lm_q1q2_score": 0.8306166036917693}} {"text": "\n---------------------------------------------------------------------------------\n-- Equality\n\ndata _≡_ {A : Set} (x : A) : A → Set where\n refl : x ≡ x\n{-# BUILTIN EQUALITY _≡_ #-}\ninfix 4 _≡_\n\n------------------------------------------------------------------------------\n-- Equality is an equivalence relation : reflexive, symmetric, and transitive.\n-- Reflexivity is built-in to the definition of equality.\n\nsym : ∀ {A : Set} {x y : A}\n → x ≡ y\n -----\n → y ≡ x\nsym refl = refl\n\ntrans : ∀ {A : Set} {x y z : A}\n → x ≡ y\n → y ≡ z\n -----\n → x ≡ z\ntrans refl refl = refl\n\n-- Equality satisfies congruence.\n-- If two terms are equal, they are eual after the 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-- Congruence of 2 arg functions\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-- Equality is a congruence in the function position of an application.\n-- If two functions are equal, then applying them to the 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-- If two values are equal and a predicate holds of the first then it also holds of the second:\nsubst : ∀ {A : Set} {x y : A} (P : A → Set)\n → x ≡ y\n ---------\n → P x → P y\nsubst P refl px = px\n\n-- Chains of equations : support equational reasoning\nmodule ≡-Reasoning {A : Set} where\n\n infix 1 begin_\n infixr 2 _≡⟨⟩_ _≡⟨_⟩_\n infix 3 _∎\n\n begin_ : ∀ {x y : A}\n → x ≡ y\n -----\n → x ≡ y\n begin x≡y = x≡y\n\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\n-- equational proof of transitivity\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\n x\n ≡⟨ x≡y ⟩\n y\n ≡⟨ y≡z ⟩\n z\n ∎\n\n{-\nExercise trans and ≡-Reasoning (practice): TODO\nCannot use the definition of trans’ using ≡-Reasoning as the definition for trans.\nWHY?\nHint: look at the definition of _≡⟨_⟩_\n-}\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\n+-comm : ∀ (m n : ℕ) → m + n ≡ n + m\n+-comm m zero =\n begin\n m + zero\n ≡⟨ +-identity m ⟩\n m\n ≡⟨⟩\n zero + m\n ∎\n+-comm m (suc n) =\n begin\n m + suc n\n ≡⟨ +-suc m n ⟩\n suc (m + n)\n ≡⟨ cong suc (+-comm m n) ⟩\n suc (n + m)\n ≡⟨⟩\n suc n + m\n ∎\n\n{-\nExercise ≤-Reasoning (stretch) TODO\nThe proof of monotonicity from Chapter Relations can be written in a more readable form\nby using an analogue of our notation for ≡-Reasoning.\nDefine ≤-Reasoning analogously, and use it to write out an alternative proof\nthat addition is monotonic with regard to inequality.\nRewrite all of +-monoˡ-≤, +-monoʳ-≤, and +-mono-≤.\n-}\n\n------------------------------------------------------------------------------\n-- Rewriting\n-- keyword rewrite : followed by evidence of an EQUALITY\n-- that equality is used to rewrite\n-- - the type of the goal\n-- - and of any variable in scope\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\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 -- even (m + n) ; ev : even (m + n)\n = ev\n\n\n--------------------------------------------------\n-- Multiple rewrites each separated by a vertical bar.\n+-comm′ : ∀ (m n : ℕ) → m + n ≡ n + m\n+-comm′ zero n rewrite +-identity n = refl\n+-comm′ (suc m) n rewrite +-suc n m | +-comm′ m n = refl\n\n\n--------------------------------------------------\n-- rewrite is shorthand for an use of WITH\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{-\n--------------------------------------------------\nDOT pattern, .(n + m).\ndot followed by an expression.\nUsed when other info forces value matched to be equal to value of expr in dot pattern.\n-}\n\n------------------------------------------------------------------------------\n-- subst (instead of rewrite)\n\neven-comm″ : ∀ (m n : ℕ)\n → even (m + n)\n ------------\n → even (n + m)\neven-comm″ m n = subst even (+-comm m n)\n\n{-\n------------------------------------------------------------------------------\nLeibniz equality\n\n≡ def is due to Martin Löf (1975).\n\nOlder form is due to Leibniz (1686).\n\nIDENTITY OF INDISCERNIBLES:\n- two objects are equal IFF they satisfy the same properties\n\nBelow: define Leibniz equality, and show that two terms satisfy Leibniz equality IFF\nthey satisfy Martin Löf equality.\n\nx ≐ y holds if every property P that holds of x also holds of y\n\nthis def is sufficient to ensure the converse\n- that every 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\n_≐_ : ∀ {A : Set} (x y : A) → Set₁\n_≐_ {A} x y = ∀ (P : A → Set) → P x → P y\n\n{-\nNOTE: write _≐_ {A} x y (instead of x ≐ y) to provide access to implicit parameter.\n\n--------------------------------------------------\nFIRST USE OF LEVELS.\n\nCannot assign Set the type Set (Russell’s Paradox and Girard’s Paradox).\n\nSet is an abbreviation for Set₀\n\nSince _≐_ def mentions Set on right-hand side, the corresponding signature must use Set₁.\n\nLeibniz equality is reflexive (follows by a variant of the identity function)\nand transitive (by a variant of function composition)\n-}\nrefl-≐ : ∀ {A : Set} {x : A}\n → x ≐ x\nrefl-≐ P Px = Px\n\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-- Symmetry : show that if P x implies P y for all predicates P,\n-- then the implication holds the other way round as well:\nsym-≐ : ∀ {A : Set} {x y : A}\n → x ≐ y\n -----\n → y ≐ x\nsym-≐ {A} {x} {y} x≐y P = Qy\n where\n Q : A → Set\n Q z = P z → P x\n Qx : Q x\n Qx = refl-≐ P\n Qy : Q y\n Qy = x≐y Q Qx\n{-\nGiven x ≐ y, a specific P, construct a proof that P y implies P x.\nInstantiate the equality with a predicate Q such that Q z holds if P z implies P x.\nThe property Q x is trivial by reflexivity, and hence Q y follows from x ≐ y.\nBut Q y is exactly a proof of what we require, that P y implies P x.\n\nshow Martin Löf equality implies Leibniz equality, and vice versa.\n\nif x ≡ y then need for any P to take evidence of P x to evidence of P y\nwhich can be done since equality of x and y implies that any proof of P x is also a proof of P y:\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-- given that for any P we can take a proof of P x to a proof of P y then show x ≡ y:\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\n Q z = x ≡ z\n Qx : Q x\n Qx = refl\n Qy : Q y\n Qy = x≐y Q Qx\n{-\nproof similar to that for symmetry of Leibniz equality.\nWe take Q to be the predicate that holds of z if x ≡ z.\nThen Q x is trivial by reflexivity of Martin Löf equality, and hence Q y follows from x ≐ y.\nBut Q y is exactly a proof of what we require, that x ≡ y.\n\n(Parts adapted from\n≐≃≡: Leibniz Equality is Isomorphic to Martin-Löf Identity, Parametrically,\nby Andreas Abel, Jesper Cockx, Dominique Devries, Andreas Nuyts, and Philip Wadler, draft, 2017.)\n\n------------------------------------------------------------------------------\nUniverse polymorphism\n\nNot every type belongs to Set.\nSet₀ : Set₁, Set₁ : Set₂, ...\n\n≡ def at beginning is ok for comparing values of a type that belongs to Set.\n\nHow to compare two values of a type that belongs to Set ℓ for some arbitrary level ℓ?\n\nVia universe polymorphism : definition made with respect to arbitrary level ℓ.\nTo use levels:\n-}\nopen import Level using (Level; _⊔_) renaming (zero to lzero; suc to lsuc)\n{-\n\nLevels : isomorphic to natural numbers\n\nlzero : Level\nlsuc : Level → Level\n\nSet₀, Set₁, Set₂, and so on, are abbreviations for\n\nSet lzero\nSet (lsuc lzero)\nSet (lsuc (lsuc lzero))\n\n_⊔_ : Level → Level → Level -- given two levels returns the largest\n\nequality, symetry, generalised to an arbitrary level:\n-}\n\ndata _≡′_ {ℓ : Level} {A : Set ℓ} (x : A) : A → Set ℓ where\n refl′ : x ≡′ x\n\nsym′ : ∀ {ℓ : Level} {A : Set ℓ} {x y : A}\n → x ≡′ y\n ------\n → y ≡′ x\nsym′ refl′ = refl′\n\n{-\nmost defs in standard library are generalised to arbitrary levels\n\ngeneralised Leibniz equality:\n-}\n\n_≐′_ : ∀ {ℓ : Level} {A : Set ℓ} (x y : A) → Set (lsuc ℓ)\n_≐′_ {ℓ} {A} x y = ∀ (P : A → Set ℓ) → P x → P y\n\n-- generalized 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{-\nStandard library\n\ndefines _≡⟨_⟩_ as step-≡, which reverses the order of the arguments.\n\ndefines a syntax macro ((automatically imported with step-≡) i, which recovers original arg order:\n-}\n", "meta": {"hexsha": "32a89307bbf8abfb7e107ea72eccb21fdbb6b547", "size": 9548, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x04equality-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/x04equality-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/x04equality-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": 24.2335025381, "max_line_length": 98, "alphanum_fraction": 0.5364474235, "num_tokens": 3285, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9546474200908501, "lm_q2_score": 0.868826771143471, "lm_q1q2_score": 0.829423235577978}} {"text": "module Numeral.Natural.Combinatorics where\n\nopen import Numeral.Natural\nopen import Numeral.Natural.Oper\n\n-- Counting combinations.\n-- `𝑐𝐶 n k` is the number of ways one can pick `k` number of distinct objects from a set of `n` number of distinct objects.\n-- Equivalently, it is the number of `k`-sized subsets of an `n`-sized set.\n-- Also called: Binomial coefficients\n-- Formulated using sets:\n-- 𝐶: Set → ℕ → Set\n-- 𝐶 S k = {(K∊℘(S)). #K = k}\n-- 𝑐𝐶(n) = #𝐶(𝕟(n))\n𝑐𝐶 : ℕ → ℕ → ℕ\n𝑐𝐶 _ 𝟎 = 𝐒 𝟎\n𝑐𝐶 𝟎 (𝐒 k) = 𝟎\n𝑐𝐶 (𝐒 n) (𝐒 k) = 𝑐𝐶 n k + 𝑐𝐶 n (𝐒 k)\n\n-- Counting partial permutations.\n-- `𝑐𝑃 n k` is the number of arrangements for a list of `n` number of distinct objects into `k` number of objects.\n-- Equivalently, it is the number of injective functions (function equality by the standard function extensionality) of type `𝕟(k) → 𝕟(n)`.\n-- Also called: Falling factorial\n-- Formulated using sets:\n-- 𝑃: Set → ℕ → Set\n-- 𝑃 S k = {(π: 𝕟(k) → S). Injective(π)}\n-- 𝑐𝑃(n) = #𝑃(𝕟(n))\n𝑐𝑃 : ℕ → ℕ → ℕ\n𝑐𝑃 _ 𝟎 = 𝐒 𝟎\n𝑐𝑃 𝟎 (𝐒 k) = 𝟎\n𝑐𝑃 (𝐒 n) (𝐒 k) = 𝑐𝑃 n k ⋅ (𝐒 n)\n\n-- Counting derangements.\n-- `𝑐𝐷(n)` is the number of permutations of a list of `n` number of distinct objects such that in every permutation, no object is permuted with itself.\n-- Formulated using sets:\n-- 𝐷: Set → Set\n-- 𝐷(S) = {(π∊𝑃(S)). ∀(s∊S). π(s) ≠ s}\n-- 𝑐𝐷(n) = #𝐷(𝕟(n))\n𝑐𝐷 : ℕ → ℕ\n𝑐𝐷(𝟎) = 𝐒 𝟎\n𝑐𝐷(𝐒 𝟎) = 𝟎\n𝑐𝐷(𝐒(𝐒 n)) = 𝐒(n) ⋅ (𝑐𝐷 (𝐒 n) + 𝑐𝐷 n)\n\n-- Stirling numbers of the first kind.\nstir₁ : ℕ → ℕ → ℕ\nstir₁ 𝟎 𝟎 = 𝐒(𝟎)\nstir₁ (𝐒(n)) 𝟎 = 𝟎\nstir₁ 𝟎 (𝐒(k)) = 𝟎\nstir₁ (𝐒(n)) (𝐒(k)) = (n ⋅ stir₁ n (𝐒(k))) + stir₁ n k\n\n-- Stirling numbers of the second kind.\nstir₂ : ℕ → ℕ → ℕ\nstir₂ 𝟎 𝟎 = 𝐒(𝟎)\nstir₂ (𝐒(n)) 𝟎 = 𝟎\nstir₂ 𝟎 (𝐒(k)) = 𝟎\nstir₂ (𝐒(n)) (𝐒(k)) = (𝐒(k) ⋅ stir₂ n (𝐒(k))) + stir₂ n k\n\n-- Counting injective functions.\n𝑐𝐼𝑛𝑗 : ℕ → ℕ → ℕ\n𝑐𝐼𝑛𝑗 = 𝑐𝑃\n\n-- Counting surjective functions.\n𝑐𝑆𝑢𝑟𝑗 : ℕ → ℕ → ℕ\n𝑐𝑆𝑢𝑟𝑗 a b = stir₂ a b ⋅ (b !)\n", "meta": {"hexsha": "52b33ebf1469336fa71f9d562cac132658ad6985", "size": 1979, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Natural/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": "Numeral/Natural/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": "Numeral/Natural/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": 30.921875, "max_line_length": 151, "alphanum_fraction": 0.5805962607, "num_tokens": 1037, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9780517494838938, "lm_q2_score": 0.8479677545357569, "lm_q1q2_score": 0.8293563458296261}} {"text": "module logic where\n\nopen import Level\nopen import Relation.Nullary\nopen import Relation.Binary hiding (_⇔_ )\nopen import Data.Empty\n\ndata One {n : Level } : Set n where\n OneObj : One\n\ndata Two : Set where\n i0 : Two\n i1 : Two\n\ndata Bool : Set where\n true : Bool\n false : Bool\n\nrecord _∧_ {n m : Level} (A : Set n) ( B : Set m ) : Set (n ⊔ m) where\n constructor ⟪_,_⟫\n field\n proj1 : A\n proj2 : B\n\ndata _∨_ {n m : Level} (A : Set n) ( B : Set m ) : Set (n ⊔ m) where\n case1 : A → A ∨ B\n case2 : B → A ∨ B\n\n_⇔_ : {n m : Level } → ( A : Set n ) ( B : Set m ) → Set (n ⊔ m)\n_⇔_ A B = ( A → B ) ∧ ( B → A )\n\ncontra-position : {n m : Level } {A : Set n} {B : Set m} → (A → B) → ¬ B → ¬ A\ncontra-position {n} {m} {A} {B} f ¬b a = ¬b ( f a )\n\ndouble-neg : {n : Level } {A : Set n} → A → ¬ ¬ A\ndouble-neg A notnot = notnot A\n\ndouble-neg2 : {n : Level } {A : Set n} → ¬ ¬ ¬ A → ¬ A\ndouble-neg2 notnot A = notnot ( double-neg A )\n\nde-morgan : {n : Level } {A B : Set n} → A ∧ B → ¬ ( (¬ A ) ∨ (¬ B ) )\nde-morgan {n} {A} {B} and (case1 ¬A) = ⊥-elim ( ¬A ( _∧_.proj1 and ))\nde-morgan {n} {A} {B} and (case2 ¬B) = ⊥-elim ( ¬B ( _∧_.proj2 and ))\n\ndont-or : {n m : Level} {A : Set n} { B : Set m } → A ∨ B → ¬ A → B\ndont-or {A} {B} (case1 a) ¬A = ⊥-elim ( ¬A a )\ndont-or {A} {B} (case2 b) ¬A = b\n\ndont-orb : {n m : Level} {A : Set n} { B : Set m } → A ∨ B → ¬ B → A\ndont-orb {A} {B} (case2 b) ¬B = ⊥-elim ( ¬B b )\ndont-orb {A} {B} (case1 a) ¬B = a\n\n\ninfixr 130 _∧_\ninfixr 140 _∨_\ninfixr 150 _⇔_\n\n", "meta": {"hexsha": "e9ec323257c93bf764d953b2d5db6678e54e1362", "size": 1527, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/logic.agda", "max_stars_repo_name": "shinji-kono/zf-in-agda", "max_stars_repo_head_hexsha": "031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2019-10-02T13:46:23.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-10T13:27:48.000Z", "max_issues_repo_path": "src/logic.agda", "max_issues_repo_name": "shinji-kono/zf-in-agda", "max_issues_repo_head_hexsha": "031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0", "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/logic.agda", "max_forks_repo_name": "shinji-kono/zf-in-agda", "max_forks_repo_head_hexsha": "031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0", "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.3275862069, "max_line_length": 78, "alphanum_fraction": 0.497707924, "num_tokens": 687, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9399133498259924, "lm_q2_score": 0.8807970889295664, "lm_q1q2_score": 0.8278729423727713}} {"text": "module x02-842Induction where\n\n-- Library\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; _+_; _*_; _∸_)\n\n-- PLFA coverage of identity, associativity, commutativity, distributivity.\n\n-- An example of the associative law for addition.\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-- A theorem easy to prove.\n\n+-identityᴸ : ∀ (m : ℕ) → zero + m ≡ m\n+-identityᴸ m = {!!}\n\n-- A first nontrivial theorem.\n-- An equational proof is shown in PLFA.\n-- It uses helpers cong and sym imported from the standard library,\n-- and a form of equational reasoning that allows more elaborate justification.\n-- Instead we will use 'rewrite'.\n\n+-identityʳ : ∀ (m : ℕ) → m + zero ≡ m\n+-identityʳ m = {!!}\n\n-- Associativity of addition.\n-- (Done first in PLFA.)\n\n+-assoc : ∀ (m n p : ℕ) → (m + n) + p ≡ m + (n + p)\n+-assoc m n p = {!!}\n\n-- A useful lemma about addition.\n-- Equational proof shown in PLFA.\n\n+-suc : ∀ (m n : ℕ) → m + suc n ≡ suc (m + n)\n+-suc m n = {!!}\n\n-- Commutativity of addition.\n-- Equational proof shown in PLFA.\n\n+-comm : ∀ (m n : ℕ) → m + n ≡ n + m\n+-comm m n = {!!}\n\n-- 842 exercise: AddSwap (1 point)\n-- Please do this without using induction/recursion.\n\n+-swap : ∀ (m n p : ℕ) → (m + n) + p ≡ n + (m + p)\n+-swap m n p = {!!}\n\n-- 842 exercise: AddDistMult (2 points)\n-- Show that addition distributes over multiplication.\n\n*-+-rdistrib : ∀ (m n p : ℕ) → (m + n) * p ≡ m * p + n * p\n*-+-rdistrib m n p = {!!}\n\n-- 842 exercise: MultAssoc (2 points)\n-- Show that multiplication is associative.\n\n*-assoc : ∀ (m n p : ℕ) → (m * n) * p ≡ m * (n * p)\n*-assoc m n p = {!!}\n\n-- 842 exercise: MultComm (3 points)\n-- Show that multiplication is commutative.\n-- As with the addition proof above, helper lemmas will be needed.\n\n*-comm : ∀ (m n : ℕ) → m * n ≡ n * m\n*-comm m n = {!!}\n\n-- 842 exercise: LeftMonusZero (1 point)\n-- PLFA asks \"Did your proof require induction?\"\n-- (which should give you an indication of the expected answer).\n\n0∸n≡0 : ∀ (m : ℕ) → zero ∸ m ≡ zero\n0∸n≡0 m = {!!}\n\n-- 842 exercise: MonusAssocish (2 points)\n-- Show a form of associativity for monus.\n\n∸-+-assoc : ∀ (m n p : ℕ) → m ∸ n ∸ p ≡ m ∸ (n + p)\n∸-+-assoc m n p = {!!}\n\n-- 842 extended exercise: properties of binary representation.\n-- This is based on the PLFA Bin-laws exercise.\n\n-- Copied from 842Naturals.\n\ndata Bin-ℕ : Set where\n bits : Bin-ℕ\n _x0 : Bin-ℕ → Bin-ℕ\n _x1 : Bin-ℕ → Bin-ℕ\n\ndbl : ℕ → ℕ\ndbl zero = zero\ndbl (suc n) = suc (suc (dbl n))\n\n-- Copy your versions of 'inc', 'to', 'from', 'bin-+' over from 842Naturals.\n-- You may choose to change them here to make proofs easier.\n-- But make sure to test them if you do!\n\ninc : Bin-ℕ → Bin-ℕ\ninc m = {!!}\n\ntob : ℕ → Bin-ℕ\ntob m = {!!}\n\nfromb : Bin-ℕ → ℕ\nfromb m = {!!}\n\n_bin-+_ : Bin-ℕ → Bin-ℕ → Bin-ℕ\nm bin-+ n = {!!}\n\n-- 842 exercise: DoubleB (1 point)\n-- Write the Bin-ℕ version of dbl, here called dblb.\n-- As with the other Bin-ℕ operations, don't use tob/fromb.\n\ndblb : Bin-ℕ → Bin-ℕ\ndblb m = {!!}\n\n-- Here are some properties of tob/fromb/inc suggested by PLFA Induction.\n-- Please complete the proofs.\n\n-- 842 exercise: FromInc (1 point)\n\nfrom∘inc : ∀ (m : Bin-ℕ) → fromb (inc m) ≡ suc (fromb m)\nfrom∘inc m = {!!}\n\n-- 842 exercise: FromToB (1 point)\n\nfrom∘tob : ∀ (m : ℕ) → fromb (tob m) ≡ m\nfrom∘tob m = {!!}\n\n-- 842 exercise: ToFromB (2 points)\n-- The property ∀ (m : Bin-ℕ) → tob (fromb m) ≡ m cannot be proved.\n-- Can you see why?\n-- However, this restriction of it can be proved.\n\nto/from-corr : ∀ (m : Bin-ℕ) (n : ℕ) → m ≡ tob n → fromb m ≡ n\nto/from-corr m n m≡tn = {!!}\n\n-- Here are a few more properties for you to prove.\n\n-- 842 exercise: DblBInc (1 point)\n\ndblb∘inc : ∀ (m : Bin-ℕ) → dblb (inc m) ≡ inc (inc (dblb m))\ndblb∘inc m = {!!}\n\n-- 842 exercise: ToDbl (1 point)\n\nto∘dbl : ∀ (m : ℕ) → tob (dbl m) ≡ dblb (tob m)\nto∘dbl m = {!!}\n\n-- 842 exercise: FromDblB (1 point)\n\nfrom∘dblb : ∀ (m : Bin-ℕ) → fromb (dblb m) ≡ dbl (fromb m)\nfrom∘dblb m = {!!}\n\n-- 842 exercise: BinPlusLInc (2 points)\n-- This helper function translates the second case for unary addition\n-- suc m + n = suc (m + n)\n-- into the binary setting. It's useful in the next proof.\n-- Hint: induction on both m and n is needed.\n\nbin-+-linc : ∀ (m n : Bin-ℕ) → (inc m) bin-+ n ≡ inc (m bin-+ n)\nbin-+-linc m n = {!!}\n\n-- 842 exercise: PlusUnaryBinary (2 points)\n-- This theorem relates unary and binary addition.\n\nto∘+ : ∀ (m n : ℕ) → tob (m + n) ≡ tob m bin-+ tob n\nto∘+ m n = {!!}\n\n-- This ends the extended exercise.\n\n\n-- The following theorems proved in PLFA can be found in the standard library.\n\n-- import Data.Nat.Properties using (+-assoc; +-identityʳ; +-suc; +-comm)\n\n-- Unicode used in this chapter:\n\n{-\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\n-}\n", "meta": {"hexsha": "a0fd7a74499065d427271b8dc4591c0d9d012b3e", "size": 5078, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x02-842Induction.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/x02-842Induction.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/x02-842Induction.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.5314009662, "max_line_length": 79, "alphanum_fraction": 0.596297755, "num_tokens": 1849, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9353465152482724, "lm_q2_score": 0.8840392832736083, "lm_q1q2_score": 0.8268830629525499}} {"text": "{-# OPTIONS --allow-unsolved-metas #-}\n\ndata _≡_ {a} {A : Set a} (x : A) : A → Set a where\n refl : x ≡ x\ninfix 0 _≡_\n\n{-# BUILTIN EQUALITY _≡_ #-}\n\ndata Sigma {l} (A : Set l) (B : A -> Set l) : Set l where\n _**_ : (a : A) -> B a -> Sigma A B\n\nsym : ∀ {a} {A : Set a} {x y : A} → x ≡ y → y ≡ x\nsym refl = refl\n\ntrans : ∀ {a} {A : Set a} {x y z : A} → x ≡ y → y ≡ z → x ≡ z\ntrans refl eq = eq\n\nsubst : ∀ {a b} {x y : Set a} → (P : Set a → Set b) → x ≡ y → P x ≡ P y\nsubst P refl = refl\n\ncong : ∀ {a b} {A : Set a} {B : Set b} (f : A → B) {x y : A} → x ≡ y → f x ≡ f y\ncong f refl = refl\nfst : ∀ {l} -> {A : Set l}{B : A -> Set l} -> Sigma A B -> A\nfst (x ** _) = x\n\nsnd : ∀ {l} -> {A : Set l}{B : A -> Set l} -> (sum : Sigma A B) -> B (fst sum)\nsnd (x ** y) = y\n\nrecord Group {l} (G : Set l) (_op_ : G -> G -> G) : Set l where\n field\n assoc : {a b c : G} -> ((a op b) op c) ≡ (a op (b op c))\n id : {a : G} -> Sigma G (\\e -> e op a ≡ a)\n inv : {a : G} -> Sigma G (\\a^-1 -> (a^-1 op a) ≡ (fst (id {a})))\n e : {a : G} -> G\n e {a} = fst (id {a})\n\n _^-1 : G -> G\n x ^-1 = fst (inv {x})\n\n a^-1-op-a==e : {a : G} -> ((a ^-1) op a) ≡ e {a}\n a^-1-op-a==e {a} with inv {a}\n ... | (_ ** p) = p\n\n id-lem-right : {a : G} -> (e {a} op a) ≡ a\n id-lem-right {a} = snd (id {a})\n\n id-lem-left : {a : G} -> (a op e {a}) ≡ a\n id-lem-left {a} rewrite id-lem-right {a} = {!!}\n\n-- In Agda 2.4.2.5 the error was:\n\n-- Function does not accept argument {r = _}\n-- when checking that {r = a} is a valid argument to a function of\n-- type {a : G} → G\n", "meta": {"hexsha": "830142a7e7dea96b9b32d9926b7c0dfc8c5268b0", "size": 1561, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue1934.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/Issue1934.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/Issue1934.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": 28.3818181818, "max_line_length": 80, "alphanum_fraction": 0.4349775785, "num_tokens": 702, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9399133498259924, "lm_q2_score": 0.8791467627598857, "lm_q1q2_score": 0.8263217787743212}} {"text": "module Propositional where\n\nopen import Data.Nat\nopen import Relation.Binary.PropositionalEquality\n\nopen import Holes.Term using (⌞_⌟)\nopen import Holes.Cong.Propositional\n\nopen ≡-Reasoning\n\n--------------------------------------------------------------------------------\n-- Some easy lemmas\n--------------------------------------------------------------------------------\n\n+-zero : ∀ a → a + zero ≡ a\n+-zero zero = refl\n+-zero (suc a) rewrite +-zero a = 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+-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--------------------------------------------------------------------------------\n-- Proofs by equational reasoning\n--------------------------------------------------------------------------------\n\n-- commutativity of addition proved traditionally\n\n+-comm₁ : ∀ a b → a + b ≡ b + a\n+-comm₁ zero b = sym (+-zero b)\n+-comm₁ (suc a) b =\n suc ⌞ a + b ⌟ ≡⟨ cong suc (+-comm₁ a b) ⟩\n suc (b + a) ≡⟨ sym (+-suc b a) ⟩\n b + suc a ∎\n\n-- commutativity of addition proved with holes\n\n+-comm : ∀ a b → a + b ≡ b + a\n+-comm zero b = sym (+-zero b)\n+-comm (suc a) b =\n suc ⌞ a + b ⌟ ≡⟨ cong! (+-comm a b) ⟩\n suc (b + a) ≡⟨ cong! (+-suc b a) ⟩\n b + suc a ∎\n\n-- distributivity of multiplication over addition proved traditionally\n\n*-distrib-+₁ : ∀ a b c → a * (b + c) ≡ a * b + a * c\n*-distrib-+₁ zero b c = refl\n*-distrib-+₁ (suc a) b c =\n b + c + a * (b + c) ≡⟨ cong (λ h → b + c + h) (*-distrib-+₁ a b c) ⟩\n (b + c) + (a * b + a * c) ≡⟨ sym (+-assoc (b + c) (a * b) (a * c)) ⟩\n ((b + c) + a * b) + a * c ≡⟨ cong (λ h → h + a * c) (+-assoc b c (a * b)) ⟩\n (b + (c + a * b)) + a * c ≡⟨ cong (λ h → (b + h) + a * c) (+-comm c (a * b)) ⟩\n (b + (a * b + c)) + a * c ≡⟨ cong (λ h → h + a * c) (sym (+-assoc b (a * b) c)) ⟩\n ((b + a * b) + c) + a * c ≡⟨ +-assoc (b + a * b) c (a * c) ⟩\n (b + a * b) + (c + a * c)\n ∎\n\n-- distributivity of multiplication over addition proved with holes\n\n*-distrib-+ : ∀ a b c → a * (b + c) ≡ a * b + a * c\n*-distrib-+ zero b c = refl\n*-distrib-+ (suc a) b c =\n b + c + ⌞ a * (b + c) ⌟ ≡⟨ cong! (*-distrib-+ a b c) ⟩\n ⌞ (b + c) + (a * b + a * c) ⌟ ≡⟨ cong! (+-assoc (b + c) (a * b) (a * c)) ⟩\n ⌞ (b + c) + a * b ⌟ + a * c ≡⟨ cong! (+-assoc b c (a * b)) ⟩\n (b + ⌞ c + a * b ⌟) + a * c ≡⟨ cong! (+-comm c (a * b)) ⟩\n ⌞ b + (a * b + c) ⌟ + a * c ≡⟨ cong! (+-assoc b (a * b) c) ⟩\n ⌞ ((b + a * b) + c) + a * c ⌟ ≡⟨ cong! (+-assoc (b + a * b) c (a * c)) ⟩\n (b + a * b) + (c + a * c)\n ∎\n", "meta": {"hexsha": "7a55279f54c33240e607a76205f40cc61845bf9f", "size": 2680, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/Propositional.agda", "max_stars_repo_name": "bch29/agda-holes", "max_stars_repo_head_hexsha": "b5537c29e69febd7e89580398fac38d619aab3b4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 24, "max_stars_repo_stars_event_min_datetime": "2017-01-28T10:56:46.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-03T15:02:41.000Z", "max_issues_repo_path": "examples/Propositional.agda", "max_issues_repo_name": "bch29/agda-holes", "max_issues_repo_head_hexsha": "b5537c29e69febd7e89580398fac38d619aab3b4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2019-01-16T10:47:58.000Z", "max_issues_repo_issues_event_max_datetime": "2020-08-31T20:58:33.000Z", "max_forks_repo_path": "examples/Propositional.agda", "max_forks_repo_name": "bch29/agda-holes", "max_forks_repo_head_hexsha": "b5537c29e69febd7e89580398fac38d619aab3b4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2017-01-27T14:57:39.000Z", "max_forks_repo_forks_event_max_datetime": "2021-02-02T18:57:17.000Z", "avg_line_length": 35.2631578947, "max_line_length": 88, "alphanum_fraction": 0.3951492537, "num_tokens": 1103, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9609517083920618, "lm_q2_score": 0.8596637451167997, "lm_q1q2_score": 0.8260953445127066}} {"text": "{-# OPTIONS --without-K #-}\n\n-- Some basic theorems on paths and path compositions.\nmodule hott.core.equality.theorems where\n\nopen import hott.core\n\n-- The path refl is the left identity under path concatnation.\nrefl∙p≡p : ∀ {ℓ} {A : Type ℓ} {x y : A}\n → ∀ (p : x ≡ y)\n → refl ∙ p ≡ p\nrefl∙p≡p refl = refl\n\n-- Alternate form of refl being left identity.\np≡refl∙p : ∀ {ℓ} {A : Type ℓ} {x y : A}\n → ∀ (p : x ≡ y)\n → p ≡ refl ∙ p\np≡refl∙p p = refl∙p≡p p ⁻¹\n\n-- The path refl is the right identity under path concatnation.\np∙refl≡p : ∀ {ℓ} {A : Type ℓ} {x y : A}\n → ∀ (p : x ≡ y)\n → p ∙ refl ≡ p\n\np∙refl≡p refl = refl\n\n-- Alternate form of refl being the right identity.\np≡p∙refl : ∀ {ℓ} {A : Type ℓ} {x y : A}\n → ∀ (p : x ≡ y)\n → p ≡ p ∙ refl\n\np≡p∙refl p = p∙refl≡p p ⁻¹\n\n-- The inverse of inverse is identity\np⁻¹⁻¹≡p : ∀ {ℓ} {A : Type ℓ} {x y : A}\n → ∀ (p : x ≡ y)\n → (p ⁻¹)⁻¹ ≡ p\np⁻¹⁻¹≡p refl = refl\n\n-- Alternate form of the theorem inverse of inverse is identity.\np≡p⁻¹⁻¹ : ∀ {ℓ} {A : Type ℓ} {x y : A}\n → ∀ (p : x ≡ y)\n → p ≡ (p ⁻¹)⁻¹\np≡p⁻¹⁻¹ p = p⁻¹⁻¹≡p p ⁻¹\n\n\n-- Inverse is actually right inverse.\np∙p⁻¹≡refl : ∀ {ℓ} {A : Type ℓ} {x y : A}\n → ∀ (p : x ≡ y)\n → p ∙ p ⁻¹ ≡ refl\np∙p⁻¹≡refl refl = refl\n\n-- Inverse is actually left inverse.\np⁻¹∙p≡refl : ∀ {ℓ} {A : Type ℓ} {x y : A}\n → ∀ (p : x ≡ y)\n → p ⁻¹ ∙ p ≡ refl\np⁻¹∙p≡refl refl = refl\n\n\n-- The associativity of path composition.\nassoc : ∀ {ℓ} {A : Type ℓ} {u v w x : A}\n → (p : u ≡ v)\n → (q : v ≡ w)\n → (r : w ≡ x)\n → (p ∙ q) ∙ r ≡ p ∙ (q ∙ r)\nassoc refl refl refl = refl\n", "meta": {"hexsha": "7a344dbf4100d13bd6c123057b33945d4cd1e0a4", "size": 1719, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/hott/core/equality/theorems.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/equality/theorems.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/equality/theorems.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": 25.6567164179, "max_line_length": 64, "alphanum_fraction": 0.4746945899, "num_tokens": 765, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9263037323284109, "lm_q2_score": 0.8918110346549901, "lm_q1q2_score": 0.8260878899325792}} {"text": "{-# OPTIONS --sized-types #-}\nmodule SNat.Order.Properties where\n\nopen import Data.Sum renaming (_⊎_ to _∨_)\nopen import Relation.Binary.PropositionalEquality\nopen import Size\nopen import SNat\nopen import SNat.Order\n\ntot≤ : {ι ι' : Size} → (m : SNat {ι}) → (n : SNat {ι'}) → m ≤ n ∨ n ≤ m\ntot≤ zero n = inj₁ (z≤n n)\ntot≤ m zero = inj₂ (z≤n m)\ntot≤ (succ m) (succ n) \n with tot≤ m n\n...| inj₁ m≤n = inj₁ (s≤s m≤n)\n...| inj₂ n≤m = inj₂ (s≤s n≤m)\n\nrefl≤ : {n : SNat} → n ≤ n\nrefl≤ {n} \n with tot≤ n n\n... | inj₁ n≤n = n≤n\n... | inj₂ n≤n = n≤n\n\ntrans≤ : {ι ι' ι'' : Size}{n : SNat {ι}}{n' : SNat {ι'}}{n'' : SNat {ι''}} → n ≤ n' → n' ≤ n'' → n ≤ n''\ntrans≤ {n'' = n''} (z≤n n') _ = z≤n n''\ntrans≤ (s≤s n≤n') (s≤s n'≤n'') = s≤s (trans≤ n≤n' n'≤n'')\n\nrefl≅ : {n : SNat} → n ≅ n\nrefl≅ {zero} = z≅z\nrefl≅ {succ _} = s≅s refl≅\n\ntrans≅ : {ι ι' ι'' : Size}{n : SNat {ι}}{n' : SNat {ι'}}{n'' : SNat {ι''}} → n ≅ n' → n' ≅ n'' → n ≅ n''\ntrans≅ z≅z z≅z = z≅z\ntrans≅ (s≅s n≅n') (s≅s n'≅n'') = s≅s (trans≅ n≅n' n'≅n'')\n\nlemma-z≤′n : {ι ι' : Size}(n : SNat {ι}) → zero {ι'} ≤′ n\nlemma-z≤′n zero = ≤′-eq z≅z\nlemma-z≤′n (succ n) = ≤′-step (lemma-z≤′n n)\n\nlemma-s≤′s : {ι ι' : Size}{m : SNat {ι}}{n : SNat {ι'}} → m ≤′ n → succ m ≤′ succ n\nlemma-s≤′s (≤′-eq m≅n) = ≤′-eq (s≅s m≅n)\nlemma-s≤′s (≤′-step m≤′n) = ≤′-step (lemma-s≤′s m≤′n)\n\nlemma-≤-≤′ : {ι ι' : Size}{m : SNat {ι}}{n : SNat {ι'}} → m ≤ n → m ≤′ n\nlemma-≤-≤′ (z≤n n) = lemma-z≤′n n\nlemma-≤-≤′ (s≤s m≤n) = lemma-s≤′s (lemma-≤-≤′ m≤n)\n\nlemma-≅-≤ : {ι ι' : Size}{m : SNat {ι}}{n : SNat {ι'}} → m ≅ n → m ≤ n\nlemma-≅-≤ z≅z = z≤n zero\nlemma-≅-≤ (s≅s m≅n) = s≤s (lemma-≅-≤ m≅n)\n \nlemma-≡-≤′ : {a b c : SNat} → b ≡ a → a ≤′ c → b ≤′ c\nlemma-≡-≤′ b≡a a≤′c rewrite b≡a = a≤′c\n\nlemma-n≤sn : {ι : Size}(n : SNat {ι}) → n ≤ succ n\nlemma-n≤sn zero = z≤n (succ zero)\nlemma-n≤sn (succ n) = s≤s (lemma-n≤sn n)\n\nlemma-≤′-≤ : {ι ι' : Size}{m : SNat {ι}}{n : SNat {ι'}} → m ≤′ n → m ≤ n\nlemma-≤′-≤ (≤′-eq m≅n) = lemma-≅-≤ m≅n\nlemma-≤′-≤ (≤′-step {n = n} m≤′n) = trans≤ (lemma-≤′-≤ m≤′n) (lemma-n≤sn n)\n\nrefl≤′ : {n : SNat} → n ≤′ n\nrefl≤′ = lemma-≤-≤′ refl≤\n\ntrans≤′ : {ι ι' ι'' : Size}{n : SNat {ι}}{n' : SNat {ι'}}{n'' : SNat {ι''}} → n ≤′ n' → n' ≤′ n'' → n ≤′ n''\ntrans≤′ n≤′n' n'≤′n'' = lemma-≤-≤′ (trans≤ (lemma-≤′-≤ n≤′n') (lemma-≤′-≤ n'≤′n''))\n", "meta": {"hexsha": "185ff58fbf22fac284855fa63fd4c78bb1676ae6", "size": 2292, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/SNat/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/SNat/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/SNat/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": 33.7058823529, "max_line_length": 109, "alphanum_fraction": 0.4554973822, "num_tokens": 1337, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9481545289551957, "lm_q2_score": 0.8705972549785201, "lm_q1q2_score": 0.8254607302038451}} {"text": "module x01-842Naturals where\n\n-- This is a comment.\n\n{-\n This is a multi-line comment\n-}\n\n-- Definition of datatype representing natural numbers. ♭ \n\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\n-- A couple of definitions using this datatype.\n\none : ℕ\none = suc zero\n\ntwo : ℕ\ntwo = suc (suc zero)\n\n-- I could have also said two = suc one.\n\n-- PLFA exercise: write out seven.\n\n-- Pragma to use decimal notation as shorthand.\n\n{-# BUILTIN NATURAL ℕ #-}\n\n-- Some useful imports from the standard library:\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl)\nopen Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _∎)\n\n-- Addition on naturals.\n\n_+_ : ℕ → ℕ → ℕ\nzero + n = n\nsuc m + n = suc {!m + n!}\n\n-- Agda normalization; proof of equality.\n\n_ : 2 + 3 ≡ 5\n_ = refl\n\n-- Equational reasoning.\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-- PLFA shows longhand and shorthand are interchangeable.\n\n-- PLFA exercise: write out the reduction for 3+4 equationally.\n\n\n-- Multiplication.\n\n_*_ : ℕ → ℕ → ℕ\nm * n = {!!}\n\n_ =\n begin\n 2 * 3\n ≡⟨⟩ -- many steps condensed\n 6\n ∎\n\n-- PLFA exercise: write out 3*4.\n\n-- 842 exercise: Exponentiation (1 point)\n-- Define exponentiation (m raised to the power n).\n\n_^_ : ℕ → ℕ → ℕ\nm ^ n = {!!}\n\n-- One test for exponentiation (you should write others).\n\n_ : 2 ^ 3 ≡ 8\n_ = refl\n\n-- Monus (subtraction for naturals, bottoms out at zero).\n\n_∸_ : ℕ → ℕ → ℕ\nm ∸ n = {!!}\n\n_ =\n begin\n 3 ∸ 2\n ≡⟨⟩ -- many steps condensed\n 1\n ∎\n\n_ =\n begin\n 2 ∸ 3\n ≡⟨⟩ -- many steps condensed\n 0\n ∎\n\n-- PLFA exercise: write out 5 ∸ 3 and 3 ∸ 5.\n\ninfixl 6 _+_ _∸_\ninfixl 7 _*_\n\n-- These pragmas will register our operations, if we want,\n-- so that they work with decimal notation.\n\n-- {-# BUILTIN NATPLUS _+_ #-}\n-- {-# BUILTIN NATTIMES _*_ #-}\n-- {-# BUILTIN NATMINUS _∸_ #-}\n\n-- Binary representation.\n-- Modified from PLFA exercise (thanks to David Darais).\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 m = {!!}\n\n-- An example/test of increment (you should create others).\n\n_ : inc (bits x1 x0 x1 x1) ≡ bits x1 x1 x0 x0\n_ = refl\n\n-- 842 exercise: To/From (2 points)\n-- Define 'tob' and 'fromb' operations\n-- to convert between unary (ℕ) and binary (Bin-ℕ) notation.\n-- Hint: avoid addition and multiplication,\n-- and instead use the provided dbl (double) function.\n-- This will make later proofs easier.\n-- I've put 'b' on the end of the operations to\n-- avoid a name clash in a later file.\n-- It also makes the direction clear when using them.\n\ndbl : ℕ → ℕ\ndbl zero = zero\ndbl (suc m) = suc (suc (dbl m))\n\ntob : ℕ → Bin-ℕ\ntob m = {!!}\n\nfromb : Bin-ℕ → ℕ\nfromb n = {!!}\n\n-- A couple of examples/tests (you should create others).\n\n_ : tob 6 ≡ bits x1 x1 x0\n_ = refl\n\n_ : fromb (bits x1 x1 x0) ≡ 6\n_ = refl\n\n-- 842 exercise: BinAdd (2 points)\n-- Write the addition function for binary notation.\n-- Do NOT use 'to' and 'from'. Work with Bin-ℕ as if ℕ did not exist.\n-- Hint: use recursion on both m and n.\n\n_bin-+_ : Bin-ℕ → Bin-ℕ → Bin-ℕ\nm bin-+ n = {!!}\n\n-- Tests can use to/from, or write out binary constants as below.\n-- Again: write more tests!\n\n_ : (bits x1 x0) bin-+ (bits x1 x1) ≡ (bits x1 x0 x1)\n_ = refl\n\n-- That's it for now, but we will return to binary notation later.\n\n-- Many definitions from above are also in the standard library.\n\n-- open import Data.Nat using (ℕ; zero; suc; _+_; _*_; _^_; _∸_)\n\n-- Unicode used in this chapter:\n\n{-\n ℕ U+2115 DOUBLE-STRUCK CAPITAL N (\\bN)\n → U+2192 RIGHTWARDS ARROW (\\to, \\r, \\->)\n ∸ U+2238 DOT MINUS (\\.-)\n ≡ U+2261 IDENTICAL TO (\\==)\n ⟨ U+27E8 MATHEMATICAL LEFT ANGLE BRACKET (\\<)\n ⟩ U+27E9 MATHEMATICAL RIGHT ANGLE BRACKET (\\>)\n ∎ U+220E END OF PROOF (\\qed)\n-}\n", "meta": {"hexsha": "56e2faf5012a0310a8a214a0b3932203ce1abe85", "size": 4202, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x01-842Naturals.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.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.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": 19.9146919431, "max_line_length": 69, "alphanum_fraction": 0.6249405045, "num_tokens": 1442, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9441768588653856, "lm_q2_score": 0.8740772466456689, "lm_q1q2_score": 0.8252835091436126}} {"text": "-- For the first task, we are asked to prove that max is idempotent and\n-- associative. The proves presented in this file are as succint as they\n-- possibly can. The proves come with added comments to aid understanding as\n-- the proves are meant to be short and simple but not very legible. The\n-- solution to task 1 starts in lines 44 and 51.\n\nmodule sv20.assign2.First where\n\nopen import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; trans; cong)\nopen import Data.Nat using (ℕ; zero; suc; _+_)\nopen import Data.Nat using (_≤_; z≤n; s≤s; _<_)\nopen import Relation.Nullary using (¬_)\nopen import Data.Empty using (⊥-elim)\nopen import Function using (_∘_)\n\n-- First, we define the max function. Notice, how the function differs from the\n-- definition offered for the assignment\nmax : ℕ → ℕ → ℕ\nmax zero n = n\nmax (suc m) zero = suc m\nmax (suc m) (suc n) = suc (max m n)\n\n-- Nonetheless, we can prove that the definition of max presented in the\n-- assignment follows from ours.\n-- In athena, the first part of the definition corresponds to the sentence\n-- \"y < x ==> x max y = x\", which translated into Agda corresponds to:\nless : ∀ {x y} → y < x → max x y ≡ x\n-- and it is easily proven by:\nless {zero} () -- Nonesense case\nless {suc m} {zero} (s≤s z≤n) = refl -- Simplest case, y ≡ 0\nless {suc m} {suc n} (s≤s n x max y = y\"\nnot-less : ∀ {x y} → ¬ (y < x) → max x y ≡ y\n-- which is easily proven by induction with:\nnot-less {zero} {n} ¬y n holds\n- where m > n hold when n < m\n\nMONOTONIC with regards to ADDITION and MULTIPLICATION\n\nnegation required to prove (so deferred to Chapter Negation)\n- irreflexivity\n- trichotomy case are mutually exclusive\n\n------------------------------------------------------------------------------\nshow suc m ≤ n implies m < n (and conversely)\n-}\n\nm≤n→m n\n\nDefine m > n to be the same as n < m.\n\nNeed a data declaration, similar to that used for totality.\n(Later will show that the three cases are exclusive after negation is introduced.)\n-}\n\n-- from 842\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-- hc\n<-trichotomy : ∀ (m n : ℕ) → Trichotomy m n\n<-trichotomy zero zero = is-≡ refl\n<-trichotomy zero (suc n) = is-< z z Trichotomy (suc m) (suc n)\n helper (is-< x) = is-< (s x) = is-> (s ℕ\ndo-dbls zero = suc zero\ndo-dbls (suc n) = dbl (do-dbls n)\n{-\nxxx : {b : Bin} {n : ℕ}\n → (p : One b)\n → n ≡ num-trailing-zeros b {p}\n → do-dbls n ≤ from b\nxxx {⟨⟩ I} {zero} one ntz = s≤s z≤n\nxxx {b I} {zero} (ob withI) ntz = s≤s z≤n\nxxx {b O} {zero} (ob withO) ntz = ≤-trans (oneb→1≤fromb ob) (dbl-mono (from b))\nxxx {b O} {suc n} (ob withO) ntz = {!!}\n-}\n-- bitstring is canonical if\ndata Can : Bin → Set where\n czero : Can (⟨⟩ O) -- it consists of a single zero (representing zero)\n\n cone : ∀ {b : Bin}\n → One b -- it has a leading one (representing a positive number)\n -----\n → Can b\n\n{-\n--------------------------------------------------\nshow that increment preserves canonical bitstrings\n-}\n\noneb→one-incb : ∀ {b : Bin} → One b → One (inc b)\noneb→one-incb one = one withO\noneb→one-incb (p withO) = p withI\noneb→one-incb (p withI) = oneb→one-incb p withO\n\ncanb→canincb : ∀ {b : Bin}\n → Can b\n ----------\n → Can (inc b)\ncanb→canincb {.(⟨⟩ O)} czero = cone one\ncanb→canincb {b} (cone p) = cone (oneb→one-incb p)\n\n{-\n--------------------------------------------------\nshow that converting a natural to a bitstring always yields a canonical bitstring\n-}\n\ncan-to-n : ∀ {n : ℕ} → Can (to n)\ncan-to-n {zero} = czero\ncan-to-n {suc n} = canb→canincb (can-to-n {n})\n\n{-\n--------------------------------------------------\nshow that converting a canonical bitstring to a natural and back is the identity TODO\n-}\n\nob→obO : ∀ {b : Bin} → One b → One (b O)\nob→obI : ∀ {b : Bin} → One b → One (b I)\n\nob→obI {.(⟨⟩ I)} one = one withI\nob→obI {.(_ O)} (p withO) = ob→obO p withI\nob→obI {(b I)} (p withI) = ob→obI {b} p withI\n\nob→obO {.(⟨⟩ I)} one = one withO\nob→obO {.(_ O)} (p withO) = (ob→obO p) withO\nob→obO {(b I)} (p withI) = ob→obI {b} p withO\n\ndblb : Bin → Bin\ndblb ⟨⟩ = ⟨⟩\ndblb (⟨⟩ O) = ⟨⟩ O\ndblb b = b O\n\ndblbo : ∀ {b} → One b → Bin → Bin\ndblbo _ b = b O\n\ndblbc : ∀ {b} → Can b → Bin → Bin\ndblbc czero _ = ⟨⟩ O\ndblbc (cone _) b = b O\n\nxxxx : ∀ {b : Bin} {n : ℕ}\n → b ≡ (⟨⟩ I)\n → b ≡ to n\n → n ≡ 1\n → (⟨⟩ I O) ≡ to (dbl n)\nxxxx p1 p2 p3 rewrite p3 = refl\n\nxx : ∀ {b : Bin} → One b -> to (dbl (from b)) ≡ b O\nxx one = refl\nxx {b O} (p withO) -- to (dbl (from (b O))) ≡ ((b O) O)\n -- to (dbl (dbl (from b))) ≡ ((b O) O)\n rewrite\n sym (xx p) -- to (dbl (dbl (from b))) ≡ (to (dbl (from b)) O)\n = {!!}\nxx {b I} (p withI) -- to (dbl (from (b I)) ≡ ((b I) O)\n -- inc (inc (to (dbl (dbl (from b))))) ≡ ((b I) O)\n = {!!}\n\ncan-b→to-from-b≡b : ∀ {b : Bin}\n → Can b\n ---------------\n → to (from b) ≡ b\ncan-b→to-from-b≡b czero = refl\ncan-b→to-from-b≡b {.⟨⟩ I} (cone one) = refl\ncan-b→to-from-b≡b {b O} (cone (p withO)) -- to (dbl (from b)) ≡ (b O)\n = xx p\n\ncan-b→to-from-b≡b {b I} (cone (p withI)) -- inc (to (dbl (from b))) ≡ (b I)\n rewrite xx p -- (b I) ≡ (b I)\n = refl\n\n{-\n------------------------------------------------------------------------------\nStandard library\n\ndefs in this chapter in standard library:\n\nimport Data.Nat using (_≤_; z≤n; s≤s)\nimport Data.Nat.Properties using (≤-refl; ≤-trans; ≤-antisym; ≤-total;\n +-monoʳ-≤; +-monoˡ-≤; +-mono-≤)\n\n------------------------------------------------------------------------------\nUnicode\n\n≤ U+2264 LESS-THAN OR EQUAL TO (\\<=, \\le)\n≥ U+2265 GREATER-THAN OR EQUAL TO (\\>=, \\ge)\nˡ U+02E1 MODIFIER LETTER SMALL L (\\^l)\nʳ U+02B3 MODIFIER LETTER SMALL R (\\^r)\n-}\n", "meta": {"hexsha": "b6177650f804f01739877b08b170b691e02c64f5", "size": 26567, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x03relations.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/x03relations.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/x03relations.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.4875373878, "max_line_length": 99, "alphanum_fraction": 0.4840215305, "num_tokens": 9606, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9294403959948494, "lm_q2_score": 0.8824278664544911, "lm_q1q2_score": 0.8201641056343523}} {"text": "module AuxDefs where\n\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\n_+_ : ℕ → ℕ → ℕ\nzero + n = n\n(suc m) + n = suc (m + n)\n\ndata Bool : Set where\n true : Bool\n false : Bool\n\ndata Comparison : Set where\n less : Comparison\n equal : Comparison\n greater : Comparison\n\n_<_ : ℕ → ℕ → Bool\nzero < y = true\nsuc x < zero = false\nsuc x < suc y = x < y\n\n", "meta": {"hexsha": "6ad9299a4bf0576e7439cbcb515b61cf0e2ca4e0", "size": 367, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/plfa/part1/AuxDefs.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/AuxDefs.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/AuxDefs.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.68, "max_line_length": 27, "alphanum_fraction": 0.553133515, "num_tokens": 133, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9597620585273154, "lm_q2_score": 0.8539127585282745, "lm_q1q2_score": 0.8195530669278352}} {"text": "module Hello where\n\n-- Oh, you made it! Well done! This line is a comment.\n\n-- In the beginning, Agda knows nothing, but we can teach it about numbers.\n\ndata Nat : Set where\n zero : Nat\n suc : Nat -> Nat\n\n-- data Nat = Zero | Suc Nat -- in Haskell\n\n-- Now we can say how to add numbers.\n\n_+N_ : Nat -> Nat -> Nat\nm +N zero = m\nm +N suc n = suc (m +N n)\n\n-- Now we can try adding some numbers.\n\nfour : Nat\nfour = (suc (suc zero)) +N (suc (suc zero))\n\n-- To make it go, select \"Evaluate term to normal form\" from the\n-- Agda menu, then type \"four\", without the quotes, and press return.\n\n-- Hopefully, you should get a response\n-- suc (suc (suc (suc zero)))\n\n-- Done?\n\n-- Now you can start Ex1.agda\n\n-- WARNING Ex1.agda requires you to give a definition of addition.\n-- There are lots of ways to define addition, and by the end of the\n-- exercise, it will matter which you choose. If you start just by\n-- copying the above definition, you will reach a point where you\n-- may wish to reconsider it, and hopefully learn something useful\n-- about the way Agda works.\n", "meta": {"hexsha": "cf0e98cb1e5b6149e01bc2bb4332032e8282c71e", "size": 1071, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Hello.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": "Hello.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": "Hello.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": 26.775, "max_line_length": 75, "alphanum_fraction": 0.6797385621, "num_tokens": 300, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9678992951349231, "lm_q2_score": 0.8459424353665381, "lm_q1q2_score": 0.8187870869159926}} {"text": "{-# OPTIONS --sized-types #-}\nopen import Relation.Binary.Core\n\nmodule BubbleSort.Correctness.Order {A : Set}\n (_≤_ : A → A → Set)\n (tot≤ : Total _≤_) \n (trans≤ : Transitive _≤_) where\n\nopen import BubbleSort _≤_ tot≤\nopen import Data.Product\nopen import Data.List\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 _≤_\n\nlemma-swap*-≤*-≤ : {ι : Size}{x t : A}{xs : SList A {ι}} → x ≤ t → xs ≤* t → proj₁ (swap* x xs) ≤* t × proj₂ (swap* x xs) ≤ t\nlemma-swap*-≤*-≤ x≤t lenx = lenx , x≤t\nlemma-swap*-≤*-≤ {x = x} x≤t (lecx {x = y} y≤t ys≤*t) \n with tot≤ x y\n... | inj₁ x≤y = lecx x≤t (proj₁ (lemma-swap*-≤*-≤ y≤t ys≤*t)), proj₂ (lemma-swap*-≤*-≤ y≤t ys≤*t)\n... | inj₂ y≤x = lecx y≤t (proj₁ (lemma-swap*-≤*-≤ x≤t ys≤*t)), proj₂ (lemma-swap*-≤*-≤ x≤t ys≤*t)\n\nlemma-bubbleSort-≤* : {ι : Size}{t : A}{xs : SList A {ι}} → xs ≤* t → bubbleSort xs ≤* t\nlemma-bubbleSort-≤* lenx = lenx\nlemma-bubbleSort-≤* (lecx x≤t xs≤*t) \n with lemma-swap*-≤*-≤ x≤t xs≤*t\n... | (zs≤*t , z≤t) = lemma-⊕≤* z≤t (lemma-bubbleSort-≤* zs≤*t)\n\nlemma-swap*-≤ : {ι : Size}(x : A) → (xs : SList A {ι}) → x ≤ proj₂ (swap* x xs)\nlemma-swap*-≤ x snil = refl≤\nlemma-swap*-≤ x (y ∙ ys) \n with tot≤ x y\n... | inj₁ x≤y = trans≤ x≤y (lemma-swap*-≤ y ys)\n... | inj₂ y≤x = lemma-swap*-≤ x ys \n\nlemma-swap*-≤* : {ι : Size}(x : A) → (xs : SList A {ι}) → proj₁ (swap* x xs) ≤* proj₂ (swap* x xs)\nlemma-swap*-≤* x snil = lenx\nlemma-swap*-≤* x (y ∙ ys) \n with tot≤ x y\n... | inj₁ x≤y = lecx (trans≤ x≤y (lemma-swap*-≤ y ys)) (lemma-swap*-≤* y ys)\n... | inj₂ y≤x = lecx (trans≤ y≤x (lemma-swap*-≤ x ys)) (lemma-swap*-≤* x ys)\n\nlemma-bubbleSort-sorted : {ι : Size}(xs : SList A {ι}) → Sorted (unsize A (bubbleSort xs))\nlemma-bubbleSort-sorted snil = nils\nlemma-bubbleSort-sorted (x ∙ xs) = lemma-sorted⊕ (lemma-bubbleSort-≤* (lemma-swap*-≤* x xs)) (lemma-bubbleSort-sorted (proj₁ (swap* x xs)))\n\ntheorem-bubbleSort-sorted : (xs : List A) → Sorted (unsize A (bubbleSort (size A xs)))\ntheorem-bubbleSort-sorted = lemma-bubbleSort-sorted ∘ (size A)\n\n\n\n", "meta": {"hexsha": "ff0a098a0e4b95ef952e8bcd93cea6fa3c4d4181", "size": 2223, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/BubbleSort/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/BubbleSort/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/BubbleSort/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": 39.0, "max_line_length": 139, "alphanum_fraction": 0.5820962663, "num_tokens": 960, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9539660949832346, "lm_q2_score": 0.8577681104440172, "lm_q1q2_score": 0.818281694721427}} {"text": "module Numeral.Natural.Relation.Divisibility where\n\nimport Lvl\nopen import Functional\nopen import Logic\nopen import Logic.Propositional\nopen import Numeral.Natural\nopen import Numeral.Natural.Oper\nopen import Type\n\n-- Divisibility relation of natural numbers.\n-- `(y ∣ x)` means that `y` is divisible by `x`.\n-- In other words: `x/y` is an integer.\n-- Or: `∃(c: ℕ). x = c⋅y`.\n-- Note on the definition of Div𝐒:\n-- The order (y + x) works and depends on rewriting rules of ℕ at the moment (Specifically on the commuted identity and successor rules, I think).\n-- Without rewriting rules, deconstruction of Div𝐒 seems not working.\n-- Example:\n-- div23 : ¬(2 ∣ 3)\n-- div23(Div𝐒())\n-- This is a \"valid\" proof, but would not type-check because deconstruction from (2 ∣ 3) to (2 ∣ 1) is impossible.\n-- Seems like the compiler would see (3 = 2+x), but because of definition of (_+_), only (3 = x+2) can be found.\n-- Defining Div𝐒 with (x + y) inside would work, but then the definition of DivN becomes more complicated because (_⋅_) is defined in this order.\n-- Note on zero divisors:\n-- (0 ∣ 0) is true, and it is the only number divisible by 0.\n-- Example definitions of special cases of the divisibility relation and the divisibility with remainder relation:\n-- data Even : ℕ → Stmt{Lvl.𝟎} where\n-- Even0 : Even(𝟎)\n-- Even𝐒 : ∀{x : ℕ} → Even(x) → Even(𝐒(𝐒(x)))\n-- data Odd : ℕ → Stmt{Lvl.𝟎} where\n-- Odd0 : Odd(𝐒(𝟎))\n-- Odd𝐒 : ∀{x : ℕ} → Odd(x) → Odd(𝐒(𝐒(x)))\ndata _∣_ : ℕ → ℕ → Stmt{Lvl.𝟎} where\n Div𝟎 : ∀{y} → (y ∣ 𝟎)\n Div𝐒 : ∀{y x} → (y ∣ x) → (y ∣ (y + x))\n\n_∤_ : ℕ → ℕ → Stmt\ny ∤ x = ¬(y ∣ x)\n\n-- `Divisor(n)(d)` means that `d` is a divisor of `n`.\nDivisor = swap(_∣_)\n\n-- `Multiple(n)(m)` means that `m` is a multiple of `n`.\nMultiple = _∣_\n\n-- Elimination rule for (_∣_).\ndivides-elim : ∀{ℓ}{P : ∀{y x} → (y ∣ x) → Type{ℓ}} → (∀{y} → P(Div𝟎{y})) → (∀{y x}{p : y ∣ x} → P(p) → P(Div𝐒 p)) → (∀{y x} → (p : y ∣ x) → P(p))\ndivides-elim z s Div𝟎 = z\ndivides-elim{P = P} z s (Div𝐒 p) = s(divides-elim{P = P} z s p)\n", "meta": {"hexsha": "b819a653bc6981dc3d9d6fdb243ddedfcb158cfa", "size": 2077, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Natural/Relation/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/Relation/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/Relation/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": 41.54, "max_line_length": 148, "alphanum_fraction": 0.6119402985, "num_tokens": 780, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.92522995296862, "lm_q2_score": 0.8840392756357327, "lm_q1q2_score": 0.8179396174188619}} {"text": "module Numeral.Natural.Function where\n\nopen import Numeral.Natural\nopen import Numeral.Natural.Oper\n\n-- Maximum function\n-- Returns the greatest number\nmax : ℕ → ℕ → ℕ\nmax 𝟎 𝟎 = 𝟎\nmax (𝐒(a)) 𝟎 = 𝐒(a)\nmax 𝟎 (𝐒(b)) = 𝐒(b)\nmax (𝐒(a)) (𝐒(b)) = 𝐒(max a b)\n\n-- Minimum function\n-- Returns the smallest number\nmin : ℕ → ℕ → ℕ\nmin 𝟎 𝟎 = 𝟎\nmin (𝐒(_)) 𝟎 = 𝟎\nmin 𝟎 (𝐒(_)) = 𝟎\nmin (𝐒(a)) (𝐒(b)) = 𝐒(min a b)\n-- min a b = (a + b) −₀ max(a)(b)\n\n-- min and max as binary operators\ninfixl 100 _[max]_ _[min]_\n_[max]_ = max\n_[min]_ = min\n\n-- Fibonacci numbers\nfib : ℕ → ℕ\nfib(𝟎) = 𝟎\nfib(𝐒(𝟎)) = 𝐒(𝟎)\nfib(𝐒(𝐒(n))) = fib(n) + fib(𝐒(n))\n\narithmetic-sequence : ℕ → ℕ → (ℕ → ℕ)\narithmetic-sequence init diff 𝟎 = init\narithmetic-sequence init diff (𝐒(n)) = diff + arithmetic-sequence init diff n\n\ngeometric-sequence : ℕ → ℕ → (ℕ → ℕ)\ngeometric-sequence init diff 𝟎 = init\ngeometric-sequence init diff (𝐒(n)) = diff ⋅ arithmetic-sequence init diff n\n", "meta": {"hexsha": "ea4ecb15ee24d7d9a619ac46f18eee8e5063139c", "size": 985, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Natural/Function.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/Function.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/Function.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.0243902439, "max_line_length": 77, "alphanum_fraction": 0.5949238579, "num_tokens": 432, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9688561730622296, "lm_q2_score": 0.8438951025545426, "lm_q1q2_score": 0.8176129795269519}} {"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-- This is where the fun begins.\n-- Unleashing datatypes, pattern matching and recursion.\n\nmodule Datatypes where\n\n{-\n\n Simple datatypes.\n\n-}\n\n-- Now which datatype should we start with...?\n\ndata Nat : Set where\n zero : Nat\n suc : Nat -> Nat\n\n-- Let's start simple.\npred : Nat -> Nat\npred zero = zero\npred (suc n) = n\n\n-- Now let's do recursion.\n_+_ : Nat -> Nat -> Nat\nzero + m = m\nsuc n + m = suc (n + m)\n\n-- An aside on infix operators:\n-- Any name containing _ can be used as a mixfix operator.\n-- The arguments simply go in place of the _. For instance:\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\n-- To declare the associativity and precedence of an operator\n-- we write. In this case we need parenthesis around the else branch\n-- if its precedence is lower than 10. For the condition and the then\n-- branch we only need parenthesis for things like λs.\ninfix 10 if_then_else_\n\n\n{-\n\n Parameterised datatypes\n\n-}\n\ndata List (A : Set) : Set where\n [] : List A\n _::_ : A -> List A -> List A\n\ninfixr 50 _::_\n\n-- The parameters are implicit arguments to the constructors.\nnil : (A : Set) -> List A\nnil A = [] {A}\n\nmap : {A B : Set} -> (A -> B) -> List A -> List B\nmap f [] = []\nmap f (x :: xs) = f x :: map f xs\n\n{-\n\n Empty datatypes\n\n-}\n\n-- A very useful guy is the empty datatype.\ndata False : Set where\n\n-- When pattern matching on an element of an empty type, something\n-- interesting happens:\n\nelim-False : {A : Set} -> False -> A\nelim-False () -- Look Ma, no right hand side!\n\n-- The pattern () is called an absurd pattern and matches elements\n-- of an empty type.\n\n{-\n\n What's next?\n\n-}\n\n-- Fun as they are, eventually you'll get bored with\n-- inductive datatypes.\n\n-- Move on to: Families.agda", "meta": {"hexsha": "4dba1b778b155dca3d1ffb370adc9d4780dc60c2", "size": 2002, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/AIM6/HelloAgda/Datatypes.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/Datatypes.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/HelloAgda/Datatypes.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": 18.537037037, "max_line_length": 69, "alphanum_fraction": 0.6243756244, "num_tokens": 564, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9465966732132747, "lm_q2_score": 0.8633916099737806, "lm_q1q2_score": 0.8172836256814339}} {"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-- This is where the fun begins.\n-- Unleashing datatypes, pattern matching and recursion.\n\nmodule Datatypes where\n\n{-\n\n Simple datatypes.\n\n-}\n\n-- Let's define natural numbers.\n\ndata Nat : Set where\n zero : Nat\n suc : Nat -> Nat\n\n-- A simple function.\npred : Nat -> Nat\npred zero = zero\npred (suc n) = n\n\n-- Now let's do recursion.\n_+_ : Nat -> Nat -> Nat\nzero + m = m\nsuc n + m = suc (n + m)\n\ninfixl 60 _+_\n\n-- An aside on infix operators:\n-- Any name containing _ can be used as a mixfix operator.\n-- The arguments simply go in place of the _. For instance:\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\n-- if false then x else y = y\nif_then_else_ false x y = y\n\n{-\n\n Parameterised datatypes\n\n-}\n\ndata List (A : Set) : Set where\n [] : List A\n _::_ : A -> List A -> List A\n\n-- The parameters are implicit arguments to the constructors.\nnil : (A : Set) -> List A\nnil A = [] {A}\n\nmap : {A B : Set} -> (A -> B) -> List A -> List B\nmap f [] = []\nmap f (x :: xs) = f x :: map f xs\n\n{-\n\n Empty datatypes\n\n-}\n\n-- A very useful guy is the empty datatype.\ndata False : Set where\n\n-- When pattern matching on an element of an empty type, something\n-- interesting happens:\n\nelim-False : {A : Set} -> False -> A\nelim-False () -- Look Ma, no right hand side!\n\n-- The pattern () is called an absurd pattern and matches elements\n-- of an empty type.\n\n{-\n\n What's next?\n\n-}\n\n-- The Curry-Howard isomorphism.\n-- CurryHoward.agda\n", "meta": {"hexsha": "25035f930ae8e4f67e0afb63a1bce787dced2448", "size": 1678, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/SummerSchool07/Lecture/Datatypes.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/Datatypes.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/Datatypes.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": 16.6138613861, "max_line_length": 66, "alphanum_fraction": 0.5953516091, "num_tokens": 494, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9591542805873231, "lm_q2_score": 0.8519528019683105, "lm_q1q2_score": 0.817154176866269}} {"text": "module x01-842Naturals-hc where\n\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\none : ℕ\none = suc zero\n\ntwo : ℕ\ntwo = suc (suc zero)\n\nseven : ℕ\nseven = 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\nsuc m + n = suc (m + n)\n\n_ : 2 + 3 ≡ 5\n_ = refl\n\n_ : 2 + 3 ≡ 5\n_ =\n begin\n 2 + 3 ≡⟨⟩ -- is shorthand for\n (suc (suc zero)) + (suc (suc (suc zero))) ≡⟨⟩ -- many steps condensed\n 5\n ∎\n\n_*_ : ℕ → ℕ → ℕ\nzero * n = 0\nsuc m * n = n + (m * n)\n\n_ =\n begin\n 2 * 3 ≡⟨⟩ -- many steps condensed\n 6\n ∎\n\n_^_ : ℕ → ℕ → ℕ\nm ^ zero = 1\nm ^ suc n = m * (m ^ n)\n\n_ : 2 ^ 3 ≡ 8\n_ = refl\n_ : 2 ^ 4 ≡ 16\n_ = refl\n_ : 3 ^ 3 ≡ 27\n_ = refl\n_ : 3 ^ 10 ≡ 59049\n_ = refl\n\n-- Monus (subtraction for naturals, bottoms out at zero).\n\n_∸_ : ℕ → ℕ → ℕ\nzero ∸ n = zero\nm ∸ zero = m\nsuc m ∸ suc n = m ∸ n\n\n_ =\n begin\n 3 ∸ 2\n ≡⟨⟩ -- many steps condensed\n 1\n ∎\n\n_ =\n begin\n 2 ∸ 3\n ≡⟨⟩ -- many steps condensed\n 0\n ∎\n\n_ = begin 5 ∸ 3 ≡⟨⟩ 2 ∎\n_ = begin 3 ∸ 5 ≡⟨⟩ 0 ∎\n\ninfixl 6 _+_ _∸_\ninfixl 7 _*_\n\n-- {-# BUILTIN NATPLUS _+_ #-}\n-- {-# BUILTIN NATTIMES _*_ #-}\n-- {-# BUILTIN NATMINUS _∸_ #-}\n\n-- Binary representation.\n-- Modified from PLFA exercise (thanks to David Darais).\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\ninc : Bin-ℕ → Bin-ℕ\ninc bits = bits x1\ninc (m x0) = m x1\ninc (m x1) = inc m x0\n\n_ : inc (bits x1 x0 x1 x0) ≡ bits x1 x0 x1 x1\n_ = refl\n_ : inc (bits x1 x0 x1 x1) ≡ bits x1 x1 x0 x0\n_ = refl\n_ : inc (bits x1 x1 x1 x1) ≡ bits x1 x0 x0 x0 x0\n_ = refl\n\n-- 842 exercise: To/From (2 points)\n-- Hint: avoid addition and multiplication. Use the provided dbl.\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 = 0\nfromb (n x0) = dbl (fromb n)\nfromb (n x1) = suc (dbl (fromb n))\n\n_ : tob 6 ≡ bits x1 x1 x0\n_ = refl\n_ : tob 7 ≡ bits x1 x1 x1\n_ = refl\n_ : tob 8 ≡ bits x1 x0 x0 x0\n_ = refl\n\n_ : fromb (bits x1 x1 x0) ≡ 6\n_ = refl\n_ : fromb (bits x1 x1 x1) ≡ 7\n_ = refl\n_ : fromb (bits x1 x0 x0 x0) ≡ 8\n_ = refl\n\n-- 842 exercise: BinAdd (2 points)\n-- Write the addition function for binary notation.\n-- Do NOT use 'to' and 'from'. Work with Bin-ℕ as if ℕ did not exist.\n-- Hint: use recursion on both m and n.\n\n_bin-+_ : Bin-ℕ → Bin-ℕ → Bin-ℕ\nm bin-+ bits = m\nbits bin-+ n = n\n(m x0) bin-+ (n x0) = (m bin-+ n) x0\n(m x0) bin-+ (n x1) = (m bin-+ n) x1\n(m x1) bin-+ (n x0) = (m bin-+ n) x1\n(m x1) bin-+ (n x1) = inc ((m bin-+ n) x1)\n\n-- Tests can use to/from, or write out binary constants as below.\n-- Again: write more tests!\n\n_ : (bits x1 x0) bin-+ (bits x1 x1) ≡ (bits x1 x0 x1)\n_ = refl\n\n_ : tob 0 bin-+ tob 0 ≡ tob 0\n_ = refl\n\n_ : tob 7 bin-+ tob 7 ≡ tob 14\n_ = refl\n\n_ : tob 3 bin-+ tob 4 ≡ tob 7\n_ = refl\n\n{-\n-- Many definitions from above are also in the standard library.\n-- open import Data.Nat using (ℕ; zero; suc; _+_; _*_; _^_; _∸_)\n\n-- Unicode used in this chapter:\n\n ℕ U+2115 DOUBLE-STRUCK CAPITAL N (\\bN)\n → U+2192 RIGHTWARDS ARROW (\\to, \\r, \\->)\n ∸ U+2238 DOT MINUS (\\.-)\n ≡ U+2261 IDENTICAL TO (\\==)\n ⟨ U+27E8 MATHEMATICAL LEFT ANGLE BRACKET (\\<)\n ⟩ U+27E9 MATHEMATICAL RIGHT ANGLE BRACKET (\\>)\n ∎ U+220E END OF PROOF (\\qed)\n-}\n", "meta": {"hexsha": "8a6199f41ab99b17e04f4076249896699f5eead2", "size": 3858, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x01-842Naturals-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/x01-842Naturals-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/x01-842Naturals-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": 19.5837563452, "max_line_length": 76, "alphanum_fraction": 0.5461378953, "num_tokens": 1668, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9219218327098193, "lm_q2_score": 0.8856314723088732, "lm_q1q2_score": 0.8164829900564919}} {"text": "{- \n Mathematical Foundations of Programming (G54FOP)\n Nicolai Kraus\n Lecture 3, 7 Feb 2018\n\n ====================\n INTRODUCTION TO AGDA\n ====================\n\n Your G54FPP project could involve Agda. If you want.\n\n Btw, text in {- -} is a comment. So is text after --.\n\n links to help you install and learn Agda:\n http://wiki.portal.chalmers.se/agda/pmwiki.php\n http://agda.readthedocs.io/en/latest/getting-started/index.html\n https://github.com/agda/agda\n\n Agda standard library:\n https://github.com/agda/agda-stdlib\n \n Some key combinations, where C is ctrl,\n i.e. C-c C-l means:\n press control and keep it pressed,\n press and release c,\n press and release l,\n release control.\n C-c C-l load file, replace ? by hole\n C-c C-, show goal\n C-c C-. show goal and input type\n C-c C-n normalise expression\n C-c C-space give current hole input to Agda\n see links above for more\n\n I recommend using a monospace font.\n-}\n\nmodule lec3FOP where\n\n data ℕ : Set where -- type: \\bN\n zero : ℕ\n suc : ℕ → ℕ -- type: \\to or \\->\n -- (or just use ->) \n\n infix 6 _+_\n _+_ : ℕ → ℕ → ℕ -- the arguments go where _ is\n zero + n = n\n (suc m) + n = suc (m + n) \n\n {- type of equalities on natural numbers *which\n we need to prove*. Some equalities can be hard\n to prove, so we cannot assume that Agda would\n find them automatically! -}\n infix 3 _==_\n data _==_ : (m n : ℕ) → Set where\n refl : {m : ℕ} → m == m\n\n suc-lem : {m n : ℕ} → m == n → suc m == suc n\n suc-lem refl = refl\n\n +-is-associative : (k m n : ℕ)\n → k + (m + n) == (k + m) + n\n +-is-associative zero m n = refl\n +-is-associative (suc k) m n =\n suc-lem (+-is-associative k m n)\n\n {- Next: implement the language of expressions\n from the lecture\n This language was given by a BNF:\n E:= t | f | z | s E | p E | iz E | if E then E else E\n -}\n\n data Expr : Set where\n t : Expr\n f : Expr\n z : Expr\n s : Expr → Expr\n p : Expr → Expr\n iz : Expr → Expr\n if_then_else_ : Expr → Expr → Expr → Expr\n\n -- denotational semantics from last week:\n -- ⟦_⟧ : Expr → S type: \\[[_\\]]\n -- S was {True, False, 0, 1, 2, ..., ⊥}\n\n data Bool : Set where\n True : Bool\n False : Bool\n\n data S : Set where\n bool : Bool → S\n number : ℕ → S\n ⊥ : S\n\n -- Here we go:\n ⟦_⟧ : Expr → S\n ⟦ t ⟧ = bool True\n ⟦ f ⟧ = bool False\n ⟦ z ⟧ = number zero\n ⟦ s e ⟧ with ⟦ e ⟧\n ⟦ s e ⟧ | number n = number (suc n)\n ⟦ s e ⟧ | _ = ⊥\n ⟦ _ ⟧ = ⊥ -- not what we want, but\n -- at least Agda accepts it.\n -- Exercise: complete this definition.\n\n\n\n\n\n\n\n\n\n\n\n", "meta": {"hexsha": "d45f472054c1a807febf77b7ffd2a473b9e08ead", "size": 2674, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/lec3FOP.agda", "max_stars_repo_name": "nicolaikraus/FOP2018", "max_stars_repo_head_hexsha": "b65516ce0fdc5fc98604cbcff3ef8ae704d59049", "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/lec3FOP.agda", "max_issues_repo_name": "nicolaikraus/FOP2018", "max_issues_repo_head_hexsha": "b65516ce0fdc5fc98604cbcff3ef8ae704d59049", "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/lec3FOP.agda", "max_forks_repo_name": "nicolaikraus/FOP2018", "max_forks_repo_head_hexsha": "b65516ce0fdc5fc98604cbcff3ef8ae704d59049", "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.8547008547, "max_line_length": 65, "alphanum_fraction": 0.5553477936, "num_tokens": 886, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.947381042195331, "lm_q2_score": 0.8615382129861583, "lm_q1q2_score": 0.8162049701099298}} {"text": "{- --- 3. Natural numbers --- -}\n\n{- 3.1 Definition -}\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\n{- 3.2 Addition -}\n_+_ : ℕ → ℕ → ℕ\nzero + n = n\nsuc m + n = suc (m + n)\n\n{- 3.3 Multiplication -}\n_*_ : ℕ → ℕ → ℕ\nzero * b = zero\nsuc a * b = b + (a * b)\n\n{- 3.4 Equality is a congruence for successor -}\ndata _≡_ {A : Set} (x : A) : A → Set where\n refl : x ≡ x\n\ninfix 4 _≡_\n \nsuc-≡ : {m n : ℕ} → (m ≡ n) → (suc m ≡ suc n)\nsuc-≡ refl = refl\n\n{- 3.5 Some properties -}\nzeroL : (n : ℕ) → zero + n ≡ n\nzeroL n = refl\n\nzeroR : (n : ℕ) → n + zero ≡ n\nzeroR zero = refl\nzeroR (suc n) = suc-≡ (zeroR 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 = suc-≡ (+-assoc m n p)\n\none : ℕ\none = suc zero\n\n+-assoc1 : (m n : ℕ) → ((m + n) + one) ≡ (m + (n + one))\n+-assoc1 m n = +-assoc m n one\n\n{- Falsity type, needed for the next property -}\ndata ⊥ : Set where\n\n{- ¬ : Set → Set\n¬ A = A → ⊥ -}\n\nopen import Relation.Nullary\n\nsuc-notzero : (n : ℕ) → ¬ (zero ≡ suc n)\nsuc-notzero n ()\n\n{- 3.6 The recurrence principle -}\nrec : (P : ℕ → Set) → (P zero) → ((n : ℕ) → (P n) → (P (suc n))) → ((n : ℕ) → P n)\nrec p z h zero = z\nrec p z h (suc n) = h n (rec p z h n)\n\n{- 3.7 Properties of equality -}\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} {x y : A} (f : A → B) → x ≡ y → f x ≡ f y\ncong f refl = refl\n\np : {m n : ℕ} → (e : m ≡ n) → suc-≡ e ≡ cong suc e\np refl = refl\n\nsubst : {A : Set} (P : A → Set) → {x y : A} → x ≡ y → P x → P y\nsubst P refl p = p\n\n{- 3.8 Commutativity of addition -}\n+-suc : (m n : ℕ) → m + suc n ≡ suc (m + n)\n+-suc zero n = refl\n+-suc (suc m) n = suc-≡ (+-suc m n)\n\n+-commut : (m n : ℕ) → m + n ≡ n + m\n+-commut m zero = zeroR m\n+-commut m (suc n) = trans (+-suc m n) (suc-≡ (+-commut m n))\n\n{- 3.9 Injectivity of successor -}\nsuc-inj : {m n : ℕ} → suc m ≡ suc n → m ≡ n\nsuc-inj refl = refl\n\n{- 3.10 Decidability of equality -}\nopen import Data.Sum renaming (_⊎_ to _∨_ ; inj₁ to left ; inj₂ to right)\n\nℕ-≡-dec : (m n : ℕ) → (m ≡ n) ∨ ¬ (m ≡ n)\nℕ-≡-dec zero zero = left refl\nℕ-≡-dec zero (suc n) = right (suc-notzero n)\nℕ-≡-dec (suc m) zero = right λ ()\nℕ-≡-dec (suc m) (suc n) with ℕ-≡-dec m n\nℕ-≡-dec (suc m) (suc n) | left e = left (suc-≡ e)\nℕ-≡-dec (suc m) (suc n) | right e' = right λ x → e' (suc-inj x)\n\n{- 3.11 Recurrence for equality -}\nJ : (A : Set) → (P : (x : A) → (y : A) → (p : x ≡ y) → Set) → (r : (x : A) → P x x refl) → (x : A) → (y : A) → (p : x ≡ y) → P x y p\nJ A P r x .x refl = r x\n\n\n", "meta": {"hexsha": "2c99c243deac47fe056feaf393eece417915a64b", "size": 2578, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "TD6/Nat.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/Nat.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/Nat.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.320754717, "max_line_length": 132, "alphanum_fraction": 0.4918541505, "num_tokens": 1194, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9390248225478306, "lm_q2_score": 0.8688267643505193, "lm_q1q2_score": 0.8158498982190522}} {"text": "module Naturals where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl)\nopen Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _∎)\n\n-- type definition\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\n-- bind builtin (aka Haskell integers) to my natural type\n{-# BUILTIN NATURAL ℕ #-}\n\n-- define addition proof\n-- base case for identity rule\n-- inductive case for associative rule\n_+_ : ℕ → ℕ → ℕ\nzero + n = n\nsuc m + n = suc (m + n)\n\n-- 2 + 3 proposition is reflexive\n-- that means addition is a binary\n-- relation that relates to itself\n_ : 2 + 3 ≡ 5\n_ = refl\n\n-- same for 3 + 4 propositon\n-- i manually proved it\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 0)) + suc 3\n ≡⟨⟩\n suc (suc (suc 0)) + suc (suc 2)\n ≡⟨⟩\n suc (suc (suc 0)) + suc (suc (suc 1))\n ≡⟨⟩\n suc (suc (suc 0)) + suc (suc (suc (suc 0)))\n ≡⟨⟩\n 7\n ∎\n-- after addition we can efine\n-- multiplication in terms of it\n-- note the base case and the inductive case\n_*_ : ℕ → ℕ → ℕ\nzero * n = zero\nsuc m * n = n + (m * n)\n\n_ =\n begin\n 2 * 3\n ≡⟨⟩\n 3 + (1 * 3)\n ≡⟨⟩\n 3 + (3 + (0 * 3))\n ≡⟨⟩\n 3 + (3 + 0)\n ≡⟨⟩\n 6\n ∎\n\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 12\n ∎\n\n-- with multiplication we then can\n-- define exponentiation\n-- note that `m ^ zero` ‌/= `zero ^ m`\n_^_ : ℕ → ℕ → ℕ\nn ^ 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 81\n ∎\n\n_∸_ : ℕ → ℕ → ℕ\nm ∸ zero = m\nzero ∸ suc n = zero\nsuc m ∸ suc n = m ∸ n\n\n_ : 3 ∸ 2 ≡ 1\n_ =\n begin\n 3 ∸ 2\n ≡⟨⟩\n 2 ∸ 1\n ≡⟨⟩\n 1 ∸ 0\n ≡⟨⟩\n 1\n ∎\n\n_ : 2 ∸ 3 ≡ 0\n_ =\n begin\n 2 ∸ 3\n ≡⟨⟩\n 1 ∸ 2\n ≡⟨⟩\n 0 ∸ 1\n ≡⟨⟩\n 0\n ∎\n\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\n-- here we define the precedence\n-- of operators. all they are left associative\n-- and addiction and monus have precedence less\n-- than multiplication\ninfixl 6 _+_ _∸_\ninfixl 7 _*_\ninfixl 8 _^_\n\n-- binding aforementioned operators\n-- to the relevant Haskell integer operators\n{-# BUILTIN NATPLUS _+_ #-}\n{-# BUILTIN NATTIMES _*_ #-}\n{-# BUILTIN NATMINUS _∸_ #-}\n", "meta": {"hexsha": "c1e72f49fbea01fc07f658061a7ed621eb309ed2", "size": 2491, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "funcional/agda/plfa/parte1/Naturals.agda", "max_stars_repo_name": "matdsoupe/paradigmas", "max_stars_repo_head_hexsha": "0bedfbd7156e631a2ea563cbe812588c9fdb8b37", "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": "funcional/agda/plfa/parte1/Naturals.agda", "max_issues_repo_name": "matdsoupe/paradigmas", "max_issues_repo_head_hexsha": "0bedfbd7156e631a2ea563cbe812588c9fdb8b37", "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": "funcional/agda/plfa/parte1/Naturals.agda", "max_forks_repo_name": "matdsoupe/paradigmas", "max_forks_repo_head_hexsha": "0bedfbd7156e631a2ea563cbe812588c9fdb8b37", "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": 14.0734463277, "max_line_length": 57, "alphanum_fraction": 0.4664793256, "num_tokens": 1260, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9390248242542284, "lm_q2_score": 0.8670357580842941, "lm_q1q2_score": 0.814168100357236}} {"text": "\nmodule OverloadedConstructors where\n\ndata Nat : Set where\n zero : Nat\n suc : Nat -> Nat\n\ndata Fin : Nat -> Set where\n zero : {n : Nat} -> Fin (suc n)\n suc : {n : Nat} -> Fin n -> Fin (suc n)\n\nthree : Nat\nthree = suc (suc (suc zero))\n\nftwo : Fin three\nftwo = suc (suc zero)\n\ninc : Nat -> Nat\ninc = suc\n\n{-\n{-# BUILTIN NATURAL Nat #-}\n{-# BUILTIN ZERO zero #-}\n{-# BUILTIN SUC suc #-}\n-}\n", "meta": {"hexsha": "cdb132893a5715b43acd1d854ac6df5c91bae5b3", "size": 392, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/succeed/OverloadedConstructors.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/OverloadedConstructors.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/OverloadedConstructors.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": 15.0769230769, "max_line_length": 42, "alphanum_fraction": 0.5790816327, "num_tokens": 132, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.959762052772658, "lm_q2_score": 0.8479677526147223, "lm_q1q2_score": 0.8138472709345234}} {"text": "-- notes-05-friday.agda\n\nopen import mylib\n\n-- Π-types = dependent function types\nΠ : (A : Set)(B : A → Set) → Set\nΠ A B = (x : A) → B x\n\nsyntax Π A (λ x → P) = Π[ x ∈ A ] P\n\n-- Σ-types = dependent pair type\n\nrecord Σ(A : Set)(B : A → Set) : Set where\n constructor _,_\n field\n proj₁ : A\n proj₂ : B proj₁\n\nopen Σ\n\nsyntax Σ A (λ x → P) = Σ[ x ∈ A ] P\n\nList' : Set → Set\nList' A = Σ[ n ∈ ℕ ] Vec A n\n\nList'' : Set → Set -- ex: show that this is isomorphic to lists\nList'' A = Σ[ n ∈ ℕ ] Fin n → A\n\n{-\n Container representation of lists.\n Set of shapes S = ℕ.\n Family of positions P : ℕ → Set, P = Fin.\n All strictly positive types can be represented as containers ( ~ polynomial\n functors) !\n-}\n\n{-\nA → B = Π[ _ ∈ A ] B\nA × B = Σ[ _ ∈ A ] B\n-}\n\n_⊎'_ : Set → Set → Set\nA ⊎' B = Σ[ b ∈ Bool ] F b\n where F : Bool → Set\n F true = A\n F false = B\n\n_×'_ : Set → Set → Set -- exercise: show that this equivalent to ⊎\nA ×' B = Π[ b ∈ Bool ] F b\n where F : Bool → Set\n F true = A\n F false = B\n\n{-\n \"Propositions as types\": for predicate logic\n P : A → prop = dependent type\n-}\n\nAll : (A : Set)(P : A → prop) → prop\nAll A P = Π[ x ∈ A ] P x\n\nEx : (A : Set)(P : A → prop) → prop\nEx A P = Σ[ x ∈ A ] P x\n\nsyntax All A (λ x → P) = ∀[ x ∈ A ] P \ninfix 0 All\nsyntax Ex A (λ x → P) = ∃[ x ∈ A ] P\ninfix 0 Ex\n\nvariable PP QQ : A → prop\n\ntaut : (∀[ x ∈ A ] PP x ⇒ Q) ⇔ (∃[ x ∈ A ] PP x) ⇒ Q\nproj₁ taut f (a , pa) = f a pa\nproj₂ taut g a pa = g (a , pa)\n\ndata _≡_ : A → A → prop where\n refl : {a : A} → a ≡ a\n\ninfix 4 _≡_\n\n-- inductive definition of equality: _≡_ is an equivalence relation\n\nsym : (a b : A) → a ≡ b → b ≡ a\nsym a .a refl = refl\n\ntrans : {a b c : A} → a ≡ b → b ≡ c → a ≡ c\ntrans refl q = q\n\ncong : {a b : A}(f : A → B) → a ≡ b → f a ≡ f b\ncong f refl = refl\n\n{-\n Proving that + is associative\n\n_+_ : ℕ → ℕ → ℕ\nzero + n = n\nsuc m + n = suc (m + n) \n-}\n\nassoc : (i j k : ℕ) → (i + j) + k ≡ i + (j + k)\nassoc zero j k = refl\nassoc (suc i) j k = cong suc (assoc i j k)\n\n-- proof by induction = pattern matching + recursion\n\nind : (P : ℕ → Set)\n → P 0\n → ((n : ℕ) → P n → P (suc n))\n → (n : ℕ) → P n\nind P z s zero = z\nind P z s (suc n) = s n (ind P z s n)\n\n-- eliminator for ℕ = induction/dependent recursion\n\n{-\ndata _≡_ : A → A → prop where\n refl : {a : A} → a ≡ a\n\n What is ind for equality?\n-}\n\nind≡ : (P : (a b : A) → a ≡ b → prop)\n (r : (a : A) → P a a refl)\n → (a b : A)(p : a ≡ b) → P a b p\nind≡ P r a .a refl = r a\n\n-- Ex. derive sym, trans, cong from ind≡ (= J)\n\nuip : (a b : A)(p q : a ≡ b) → p ≡ q\nuip = ind≡ (λ a b p → (q : a ≡ b) → p ≡ q) λ a q →\n {!!}\n--uip refl refl = refl\n\n{-\n Is uip derivable from J ? Hofmann & Streicher: groupoid model of type theory.\n Restricted version of HoTT (infinity groupoid model of TT); observed: version\n of univalence in this theory. Voevodsky formulated HoTT, which supports full\n univalence.\n-}\n", "meta": {"hexsha": "7b2f10ba22f0263ea55d21b13b7230bb0f77867d", "size": 2967, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Type Theory/notes-05-friday.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-05-friday.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-05-friday.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": 21.1928571429, "max_line_length": 79, "alphanum_fraction": 0.5176946411, "num_tokens": 1172, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.938124016006303, "lm_q2_score": 0.8670357666736772, "lm_q1q2_score": 0.8133870754530139}} {"text": "module sortedLists where\r\n\r\nopen import lib\r\n\r\n{- we use internal verification to define a datatype of sorted lists\r\n of natural numbers, where typing ensures that the lists are truly\r\n sorted in non-decreasing order.\r\n\r\n A list of type (sortedList n) is sorted and guaranteed to have \r\n all its data greater than or equal to n; so n is a lower bound\r\n on the data in the list. Keeping this lower bound explicit in\r\n the type enables us to require a proof of a constant-time check,\r\n namely d ≤ n, when insert d into a list with lower-bound n. For\r\n cons nodes, we allow the lower-bound to be less than the head of\r\n the list. This is needed for merge below.\r\n\r\n There are three constructors:\r\n\r\n -- nil, as usual (empty list)\r\n -- cons, as usual (build a new list from head and tail)\r\n -- weaken, decrease the lower bound (this was missing in my first\r\n attempt, which led to nasty problems in the case of merge below)\r\n\r\n -}\r\n\r\ndata sortedList : ℕ → Set where\r\n nil : ∀ (n : ℕ) → sortedList n -- empty lists can have any lower bound you like\r\n cons : ∀ (d : ℕ) → -- the head of the list\r\n {n : ℕ} → -- the lower-bound for the tail\r\n sortedList n → -- the tail of the list, with lower bound n on its data\r\n d ≤ n ≡ tt → {- proof that d is less than or equal to that lower bound, and\r\n hence less than or equal to all data in the tail -}\r\n sortedList d -- d is the lower bound for the new list created by the cons\r\n weaken : ∀ (n : ℕ) {n' : ℕ} → sortedList n' → n ≤ n' ≡ tt → sortedList n\r\n\r\n-- fill in the holes below, just to help you get a feel for how the sortedList datatype works\r\n-- [5 points]\r\nsimple : sortedList 1\r\nsimple = weaken 1 (cons 2 (nil 3) refl)refl\r\n\r\n{- glb stands for greatest lower bound. min d n is the greatest \r\n lower bound of d and n, in the sense that if any other d' is a lower bound \r\n of both d and n, then it is also a lower bound of min d n. (Ideas from \r\n basic lattice theory.) \r\n\r\n To prove this, you will run into a mess if you case split on d', d, or n.\r\n Instead, you should consider cases for whether or not d < n. You can use\r\n \"with\" for this, as discussed in Section 4.3.3 (page 86) of the book. \r\n -}\r\n-- [10 points]\r\nglb : ∀ d' d n → d' ≤ d ≡ tt → d' ≤ n ≡ tt → d' ≤ min d n ≡ tt\r\nglb d' d n x y with keep (d < n)\r\n... | tt , p rewrite p = x\r\n... | ff , p rewrite p = y\r\n{- insert d xs should insert d into xs as the right position to keep the list\r\n sorted. \r\n\r\n So you will case split on xs (the sortedList), and in the cons case, \r\n consider whether the data you are inserting is ≤ the data at the head of the\r\n list.\r\n\r\n I found I needed to use the \"with keep\" idiom; see Section 4.3.3 (page 90).\r\n\r\n Another hint: I also needed a few theorems from nat-thms.agda in the IAL: \r\n\r\n <≤, min-mono2, bin\n | |\n bin_to_nat | | bin_to_nat\n | |\n v v\n nat ----------------------> nat\n S\n\nincrementing a binary number and then converting it to a (unary) natural number\nyields the same result as\nfirst converting it to a natural number and then incrementing\n-}\n\n\nbin-to-nat' : bin → nat\nbin-to-nat' Z = 0\nbin-to-nat' (B₀ x) = double (bin-to-nat' x)\nbin-to-nat' (B₁ x) = 1 + (double (bin-to-nat' x))\n\n_ : bin-to-nat' (B₀ (B₁ Z)) ≡ 2\n_ = refl\n_ : bin-to-nat' (incr (B₁ Z)) ≡ 1 + bin-to-nat' (B₁ Z)\n_ = refl\n_ : bin-to-nat' (incr (incr (B₁ Z))) ≡ 2 + bin-to-nat' (B₁ Z)\n_ = refl\n\n-- PREServes\nbin-to-nat-pres-incr : (b : bin) (n : nat)\n → bin-to-nat' b ≡ n\n → bin-to-nat' (incr b) ≡ S n\nbin-to-nat-pres-incr Z n b≡n -- bin-to-nat (incr Z) ≡ S n\n -- 1 ≡ S n ; b≡n : 0 ≡ n\n rewrite sym b≡n -- 1 ≡ 1\n = refl\nbin-to-nat-pres-incr (B₀ b) n b≡n -- bin-to-nat' (incr (B₀ b)) ≡ S n\n -- 1 + double (bin-to-nat' b) ≡ S n\n rewrite b≡n -- S n ≡ S n\n = refl\nbin-to-nat-pres-incr (B₁ b) n b≡n -- bin-to-nat' (incr (B₁ b)) ≡ S n\n -- double (bin-to-nat' (incr b)) ≡ S n\n -- b≡n : 1 + double (bin-to-nat' b) ≡ n\n rewrite\n sym b≡n -- double (bin-to-nat' (incr b)) ≡ S (S (double (bin-to-nat' b)))\n-- | bin-to-nat-pres-incr b n b≡n\n = {!!}\n\nnat-to-bin : (n : nat) → bin\nnat-to-bin n = {!!}\n\n{-\n\nProve for any nat, convert it to binary; convert it back, get same nat\nHINT If def of nat_to_bin uses other functions,\nmight need to prove lemma showing how functions relate to nat_to_bin.)\n\nTheorem nat_bin_nat : ∀ n, bin_to_nat (nat_to_bin n) = n.\nProof.\n (* FILL IN HERE *) Admitted.\n\n(b) One might naturally expect that we should also prove the opposite direction -- that starting with a binary number, converting to a natural, and then back to binary should yield the same number we started with. However, this is not the case! Explain (in a comment) what the problem is.\n\n(* FILL IN HERE *)\n\n(c) Define a normalization function -- i.e., a function normalize going directly from bin to bin (i.e., not by converting to nat and back) such that, for any binary number b, converting b to a natural and then back to binary yields (normalize b). Prove it. (Warning: This part is a bit tricky -- you may end up defining several auxiliary lemmas. One good way to find out what you need is to start by trying to prove the main statement, see where you get stuck, and see if you can find a lemma -- perhaps requiring its own inductive proof -- that will allow the main proof to make progress.) Don't define this using nat_to_bin and bin_to_nat!\n\n(* FILL IN HERE *)\n-}\n", "meta": {"hexsha": "de2a383728d1740efb56e71e03fc6bff19fcf818", "size": 9418, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/book/SFHC/v01-02-induction.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/SFHC/v01-02-induction.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/SFHC/v01-02-induction.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.0842911877, "max_line_length": 641, "alphanum_fraction": 0.4877893396, "num_tokens": 3299, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.925229961215457, "lm_q2_score": 0.8757869965109765, "lm_q1q2_score": 0.8103043688148523}} {"text": "open import Data.Nat using (ℕ; zero; suc; _+_)\nopen import Relation.Binary.PropositionalEquality \nopen ≡-Reasoning\nopen import Data.Nat.Properties using (+-assoc; +-comm)\n\nmodule Exercises.One where\n\n_*_ : ℕ → ℕ → ℕ\nzero * y = zero\nsuc x * y = y + (x * y)\n\n-- Prove that multiplication is commutative\n*-idʳ : ∀ x → x * 0 ≡ 0\n*-idʳ zero = refl\n*-idʳ (suc x) = *-idʳ x\n\n*-suc : ∀ x y → x + (x * y) ≡ (x * suc y)\n*-suc zero y = refl\n*-suc (suc x) y\n rewrite sym (+-assoc x y (x * y)) | +-comm x y |\n +-assoc y x (x * y) | *-suc x y = refl\n\n*-comm : ∀ x y → x * y ≡ y * x\n*-comm zero y rewrite *-idʳ y = refl\n*-comm (suc x) y rewrite *-comm x y | *-suc y x = refl\n\n-- Prove that if x + x ≡ y + y then x ≡ y (taken from CodeWars)\nsuc-injective : ∀ x y → suc x ≡ suc y → x ≡ y\nsuc-injective zero zero p = refl\nsuc-injective (suc x) (suc .x) refl = refl\n\nxxyy : ∀ x y → x + x ≡ y + y → x ≡ y\nxxyy zero zero refl = refl\nxxyy (suc x) (suc y) p rewrite +-comm x (suc x) | +-comm y (suc y) =\n cong suc (xxyy x y (suc-injective _ _ (suc-injective _ _ p)))\n", "meta": {"hexsha": "66ae97b0751728a78b1792092b2e3d296b12c3a3", "size": 1055, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Exercises/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": "Exercises/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": "Exercises/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": 29.3055555556, "max_line_length": 68, "alphanum_fraction": 0.5772511848, "num_tokens": 429, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9496693702514737, "lm_q2_score": 0.8519527963298947, "lm_q1q2_score": 0.8090734755745932}} {"text": "-- ----------------------------------------------------------------------\n-- The Agda σ-library\n-- \n-- Substitutions\n-- ----------------------------------------------------------------------\n\n-- A substitution on T is defined as a mapping from\n-- indices to T (w/ explicit bounds).\n-- \n-- Since the domain is bounded, we may think\n-- of substitutions as vectors. \n\nmodule Sigma.Subst.Base where\n\nopen import Data.Nat using (ℕ; suc; zero; _+_)\nopen import Data.Fin using (Fin; zero; suc)\n\nopen import Function using (_∘_)\n\nopen import Data.Product using (_×_) renaming ( _,_ to ⟨_,_⟩ )\n\n-- ----------------------------------------------------------------------\n\n-- A subsitution σ : 𝕀ⁿ → T is denoted { i ↦ x : i ∈ 𝕀ⁿ, x ∈ T }\nSub : Set → ℕ → Set \nSub T m = Fin m → T\n\n\n-- The empty subsitution. \n-- Note that 𝕀⁰ ≡ ⊥. We note σ : 𝕀⁰ → T by []\n-- Intuitively, this mimics an empty vector. \n[] : ∀ { T } → Sub T 0\n[] = λ ()\n\ninfixr 5 _∷_ \n\n-- The σ-cons operator ∷ ∶ T → (𝕀ⁿ → T) → (𝕀¹⁺ⁿ → T)\n-- \n-- Intuitively, the σ-cons operator mimics the \n-- semantics of cons operator on vectors. \n-- \n-- x ∷ σ = { 0 ↦ x } ∪ { 1 + i ↦ σ i : i ∈ 𝕀ⁿ }\n_∷_ : ∀ { n } { T } → T → Sub T n → Sub T (1 + n)\n(x ∷ σ) zero = x\n(x ∷ σ) (suc n) = σ n\n\n[_] : ∀ { T } → T → Sub T 1\n[ x ] = x ∷ []\n\nhead : ∀ { n } { T } → Sub T (1 + n) → T\nhead σ = σ zero\n\ntail : ∀ { n } { T } → Sub T (1 + n) → Sub T n\ntail σ = σ ∘ suc\n\nmap : ∀ { n } { T U } → (T → U) → Sub T n → Sub U n\nmap f σ = f ∘ σ\n\nuncons : ∀ { n } { T } → Sub T (1 + n) → T × Sub T n \nuncons σ = ⟨ head σ , tail σ ⟩\n\n\ninfixr 5 _++_\n\n-- The σ-append operator ++ : (𝕀ᵐ → T) → (𝕀ⁿ → T) → (𝕀ᵐ⁺ⁿ → T)\n-- \n-- σ₁ ++ σ₂ = { i ↦ σ₁ i : i ∈ 𝕀ᵐ⁺ⁿ, i < m } ∪ { i ↦ σ₂ i : i ∈ 𝕀ᵐ⁺ⁿ, i ≥ m }\n_++_ : ∀ { m n } { T } → Sub T m → Sub T n → Sub T (m + n)\n_++_ {zero} σ₁ σ₂ = σ₂\n_++_ {suc m} σ₁ σ₂ = σ₁ zero ∷ (σ₁ ∘ suc) ++ σ₂\n\n\n", "meta": {"hexsha": "ae1d17a6b7e6c6824d2e50be2d9d1fe51c992d63", "size": 1842, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Sigma/Subst/Base.agda", "max_stars_repo_name": "johnyob/agda-sigma", "max_stars_repo_head_hexsha": "bb895fa8a3ccbefbd2c4a135c79744ba06895be7", "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/Sigma/Subst/Base.agda", "max_issues_repo_name": "johnyob/agda-sigma", "max_issues_repo_head_hexsha": "bb895fa8a3ccbefbd2c4a135c79744ba06895be7", "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/Sigma/Subst/Base.agda", "max_forks_repo_name": "johnyob/agda-sigma", "max_forks_repo_head_hexsha": "bb895fa8a3ccbefbd2c4a135c79744ba06895be7", "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.2328767123, "max_line_length": 77, "alphanum_fraction": 0.4451682953, "num_tokens": 724, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9241418241572634, "lm_q2_score": 0.8740772368049822, "lm_q1q2_score": 0.8077713320752965}} {"text": "module plfa.Relations where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl; cong; sym)\nopen import Data.Nat using (ℕ ; zero; suc; _+_)\nopen import Data.Nat.Properties using (+-comm)\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\ninfix 4 _≤_\n\n_ : 2 ≤ 4\n_ = s≤s (s≤s z≤n)\n\n_ : 2 ≤ 4\n_ = s≤s {1} {3} (s≤s {0} {2} (z≤n {2}))\n\n_ : 2 ≤ 4\n_ = s≤s {m = 1} {n = 3} (s≤s {m = 0} {n = 2} (z≤n {n = 2}))\n\n_ : 2 ≤ 4\n_ = s≤s {n = 3} (s≤s {n = 2} z≤n)\n\ninv-s≤s : ∀ { m n : ℕ }\n → suc m ≤ suc n\n -------------\n → m ≤ n\ninv-s≤s (s≤s m≤n) = m≤n\n\ninv-z≤n : ∀ { m : ℕ }\n → m ≤ zero\n --------\n → m ≡ zero\ninv-z≤n z≤n = refl\n\n-- @practice: exercise `orderings` start\n\n-- _⊆_ relations has partial order property but not total order\n-- adjacency relation has preorder property but not partial order\n\n-- @practice: exercise `orderings` end\n\n-- 自反: reflexive - refl\n-- 传递: transitive - trans\n-- 反对称: anti-symmetric - antisym\n-- 完全: total - total\n\n≤-refl : ∀ { n : ℕ }\n -----\n → n ≤ n\n≤-refl {zero} = z≤n\n≤-refl {suc n} = s≤s ≤-refl\n\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\n", "meta": {"hexsha": "b5968ad4c5f834a37712c538e5b5d9a410f59255", "size": 1312, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "fp/agda/plfa/Relations.agda", "max_stars_repo_name": "lonelyhentai/workspace", "max_stars_repo_head_hexsha": "2a996af58d6b9be5d608ed040267398bcf72403b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-04-26T16:37:38.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-15T01:26:19.000Z", "max_issues_repo_path": "fp/agda/plfa/Relations.agda", "max_issues_repo_name": "lonelyhentai/workspace", "max_issues_repo_head_hexsha": "2a996af58d6b9be5d608ed040267398bcf72403b", "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": "fp/agda/plfa/Relations.agda", "max_forks_repo_name": "lonelyhentai/workspace", "max_forks_repo_head_hexsha": "2a996af58d6b9be5d608ed040267398bcf72403b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-15T01:26:23.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-15T01:26:23.000Z", "avg_line_length": 18.2222222222, "max_line_length": 65, "alphanum_fraction": 0.4839939024, "num_tokens": 610, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9136765140114859, "lm_q2_score": 0.8840392909114836, "lm_q1q2_score": 0.8077259375691902}} {"text": "open import Relation.Binary.Core\n\nmodule Mergesort.Impl2.Correctness.Order {A : Set}\n (_≤_ : A → A → Set)\n (tot≤ : Total _≤_) where\n\nopen import Data.List\nopen import Function using (_∘_)\nopen import List.Sorted _≤_\nopen import Mergesort.Impl2 _≤_ tot≤\nopen import OList _≤_\nopen import OList.Properties _≤_\n\ntheorem-mergesort-sorted : (xs : List A) → Sorted (forget (mergesort xs))\ntheorem-mergesort-sorted = lemma-olist-sorted ∘ mergesort\n", "meta": {"hexsha": "3b4c63dc6a55cdbcdba75f82b296a4a0586389f4", "size": 477, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Mergesort/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/Mergesort/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/Mergesort/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": 29.8125, "max_line_length": 73, "alphanum_fraction": 0.6855345912, "num_tokens": 148, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.954647415574754, "lm_q2_score": 0.8459424411924673, "lm_q1q2_score": 0.8075767652093873}} {"text": "{- \n Computer Aided Formal Reasoning (G53CFR, G54CFR)\n Thorsten Altenkirch\n\n Lecture 2: A first taste of Agda\n\n In this lecture we start to explore the Agda system, a functional\n programming language based on Type Theory. We start with some\n ordinary examples which we could have developed in Haskell as well. \n-}\n\nmodule l02 where\n\n-- module myNat where\n\n {- Agda has no automatically loaded prelude. Hence we can start from\n scratch and define the natural numbers. Later we will use the\n standard libray. -}\n \n data ℕ : Set where -- to type ℕ we type \\bn \n zero : ℕ\n suc : (m : ℕ) → ℕ -- \\-> or \\to\n\n {- To process an Agda file we use C-c C-c from emacs. Once Agda has\n checked the file the type checker also colours the different\n symbols. -}\n\n {- We define addition. Note Agda's syntax for mixfix operations. The\n arguments are represented by _s -}\n\n _+_ : ℕ → ℕ → ℕ\n zero + n = n\n suc m + n = suc (m + n)\n\n {- Try to evaluate: (suc (suc zero)) + (suc (suc zero))\n by typing in C-c C-n -}\n\n{- Better we import the library definition of ℕ\n This way we can type 2 instead of (suc (suc zero))\n-}\n \n-- open import Data.Nat\n\n{- We define Lists : -}\n\ndata List (A : Set) : Set where\n [] : List A\n _∷_ : (a : A) → (as : List A) → List A\n\n{- In future we'll use \n open import Data.List -}\n\n{- declare the fixity of ∷ (type \\::) -}\n\ninfixr 5 _∷_\n\n{- Two example lists -}\n\n{-\nl1 : List ℕ\nl1 = 1 ∷ 2 ∷ 3 ∷ []\n\nl2 : List ℕ\nl2 = 4 ∷ 5 ∷ []\n-}\n\n{- implementing append (++) -}\n\n_++_ : {A : Set} → List A → List A → List A\n[] ++ bs = bs\n(a ∷ as) ++ bs = a ∷ (as ++ bs)\n\n{- Note that Agda checks wether a function is terminating.\n If we type\n (a ∷ as) ++ bs = (a ∷ as) ++ bs\n in the 2nd line Agda will complain by coloring the offending \n function calls in red.\n-}\n\n{- What does the following variant of ++ do ? -}\n\n_++'_ : {A : Set} → List A → List A → List A\nas ++' [] = as\nas ++' (b ∷ bs) = (b ∷ as) ++' bs\n\n{- Indeed it can be used to define reverse. This way to implement\n reverse is often called fast reverse because it is \"tail recursive\"\n which leads to a more efficient execution than the naive\n implementation. -}\n\nrev : {A : Set} → List A → List A\nrev as = [] ++' as\n\n{- We tried to define a function which accesses the nth element of a list:\n\n_!!_ : {A : Set} → List A → ℕ → A\n[] !! n = {!!}\n(a ∷ as) !! zero = a\n(a ∷ as) !! suc n = as !! n\n\n but there is no way to complete the first line (consider what happens\n if A is the empty type! \n-}\n\n{- To fix this we handle errors explicitely, using Maybe -}\n\n-- open import Data.Maybe\n\ndata Maybe (A : Set) : Set where\n just : (x : A) → Maybe A\n nothing : Maybe A\n\n{- This version of the function can either return an element of the list \n (just a) or an error (nothing).\n-}\n_!!_ : {A : Set} → List A → ℕ → Maybe A\n[] !! n = nothing\n(a ∷ as) !! zero = just a\n(a ∷ as) !! suc n = as !! n\n", "meta": {"hexsha": "cb61f43baa8e6c9169b9a890009372a7cc2bad7c", "size": 2912, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "tests/covered/l02.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/l02.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/l02.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": 24.2666666667, "max_line_length": 74, "alphanum_fraction": 0.6085164835, "num_tokens": 924, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9149009503523291, "lm_q2_score": 0.8824278571786139, "lm_q1q2_score": 0.8073340851500832}} {"text": "module Arithmetic where\n\n data ℕ : Set where\n zero : ℕ\n succ : ℕ → ℕ\n\n _+_ : ℕ → ℕ → ℕ\n zero + b = b\n (succ a) + b = succ (a + b)\n \n -- ℕ + ℕ = succ (succ ℕ))\n\n _*_ : ℕ → ℕ → ℕ\n zero * b = zero\n (succ a) * b = a + b * a\n", "meta": {"hexsha": "66edb106b94b242fd862048d46a5e50abf479e1c", "size": 244, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Arithmetic.agda", "max_stars_repo_name": "haskellcamargo/agda-arithmetic-operations", "max_stars_repo_head_hexsha": "cf10911d8f8c4dcc0ced16f39f7f8d4588bd84ff", "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": "Arithmetic.agda", "max_issues_repo_name": "haskellcamargo/agda-arithmetic-operations", "max_issues_repo_head_hexsha": "cf10911d8f8c4dcc0ced16f39f7f8d4588bd84ff", "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": "Arithmetic.agda", "max_forks_repo_name": "haskellcamargo/agda-arithmetic-operations", "max_forks_repo_head_hexsha": "cf10911d8f8c4dcc0ced16f39f7f8d4588bd84ff", "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.25, "max_line_length": 29, "alphanum_fraction": 0.4180327869, "num_tokens": 100, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9732407129338139, "lm_q2_score": 0.82893881677331, "lm_q1q2_score": 0.8067570050149684}} {"text": "module *-distrib-+ where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; cong; sym)\nopen Eq.≡-Reasoning using (begin_; _≡⟨⟩_; step-≡; _∎)\nopen import Data.Nat using (ℕ; zero; suc; _+_; _*_)\n\nopen import Induction′ using (+-assoc; +-comm; +-suc)\n\n-- 積が和に対して分配的であることの証明\n*-distrib-+ : ∀ (m n p : ℕ) → (m + n) * p ≡ m * p + n * p\n*-distrib-+ zero n p =\n begin\n (zero + n) * p\n ≡⟨⟩\n n * p\n ≡⟨⟩\n zero * p + n * p\n ∎\n*-distrib-+ (suc m) n p =\n begin\n ((suc m) + n) * p\n ≡⟨ cong (_* p) (+-comm (suc m) n) ⟩\n (n + (suc m)) * p\n ≡⟨ cong (_* p) (+-suc n m) ⟩\n (suc (n + m)) * p\n ≡⟨⟩\n p + ((n + m) * p)\n ≡⟨ cong (p +_) (*-distrib-+ n m p) ⟩\n p + (n * p + m * p)\n ≡⟨ cong (p +_) (+-comm (n * p) (m * p)) ⟩\n p + (m * p + n * p)\n ≡⟨ sym (+-assoc p (m * p) (n * p)) ⟩\n (p + (m * p)) + n * p\n ≡⟨⟩\n (suc m) * p + n * p\n ∎\n", "meta": {"hexsha": "09924533ac50219ac9d913f42c78ca7fea0f5358", "size": 874, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "part1/induction/*-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/induction/*-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/induction/*-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": 23.0, "max_line_length": 57, "alphanum_fraction": 0.4416475973, "num_tokens": 450, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9489172673767973, "lm_q2_score": 0.8499711699569787, "lm_q1q2_score": 0.8065523199446356}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Setoids.Setoids\nopen import Sets.EquivalenceRelations\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_)\nopen import Numbers.Naturals.Semiring\nopen import Numbers.Integers.Integers\nopen import Groups.Definition\n\nmodule Groups.Cyclic.Definition {m n : _} {A : Set m} {S : Setoid {m} {n} A} {_·_ : A → A → A} (G : Group S _·_) where\n\nopen Setoid S\nopen Group G\nopen Equivalence eq\nopen import Groups.Lemmas G\n\npositiveEltPower : (x : A) (i : ℕ) → A\npositiveEltPower x 0 = Group.0G G\npositiveEltPower x (succ i) = x · (positiveEltPower x i)\n\npositiveEltPowerWellDefinedG : (x y : A) → (x ∼ y) → (i : ℕ) → (positiveEltPower x i) ∼ (positiveEltPower y i)\npositiveEltPowerWellDefinedG x y x=y 0 = reflexive\npositiveEltPowerWellDefinedG x y x=y (succ i) = +WellDefined x=y (positiveEltPowerWellDefinedG x y x=y i)\n\npositiveEltPowerCollapse : (x : A) (i j : ℕ) → Setoid._∼_ S ((positiveEltPower x i) · (positiveEltPower x j)) (positiveEltPower x (i +N j))\npositiveEltPowerCollapse x zero j = Group.identLeft G\npositiveEltPowerCollapse x (succ i) j = transitive (symmetric +Associative) (+WellDefined reflexive (positiveEltPowerCollapse x i j))\n\nelementPower : (x : A) (i : ℤ) → A\nelementPower x (nonneg i) = positiveEltPower x i\nelementPower x (negSucc i) = Group.inverse G (positiveEltPower x (succ i))\n\n-- TODO: move this to lemmas\nelementPowerWellDefinedZ : (i j : ℤ) → (i ≡ j) → {g : A} → elementPower g i ≡ elementPower g j\nelementPowerWellDefinedZ i j i=j {g} = applyEquality (elementPower g) i=j\n\nelementPowerWellDefinedZ' : (i j : ℤ) → (i ≡ j) → {g : A} → (elementPower g i) ∼ (elementPower g j)\nelementPowerWellDefinedZ' i j i=j {g} = identityOfIndiscernablesRight _∼_ reflexive (elementPowerWellDefinedZ i j i=j)\n\nelementPowerWellDefinedG : (g h : A) → (g ∼ h) → {n : ℤ} → (elementPower g n) ∼ (elementPower h n)\nelementPowerWellDefinedG g h g=h {nonneg n} = positiveEltPowerWellDefinedG g h g=h n\nelementPowerWellDefinedG g h g=h {negSucc x} = inverseWellDefined (+WellDefined g=h (positiveEltPowerWellDefinedG g h g=h x))\n\nrecord CyclicGroup : Set (m ⊔ n) where\n field\n generator : A\n cyclic : {a : A} → (Sg ℤ (λ i → Setoid._∼_ S (elementPower generator i) a))\n\n", "meta": {"hexsha": "acae944ef1d437f3e3f7549753d91285f3398729", "size": 2273, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Groups/Cyclic/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/Cyclic/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/Cyclic/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": 45.46, "max_line_length": 139, "alphanum_fraction": 0.7144742631, "num_tokens": 773, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9458012655937034, "lm_q2_score": 0.8519527963298947, "lm_q1q2_score": 0.805778032994909}} {"text": "open import Relation.Binary.Core\n\nmodule InsertSort.Impl2 {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 OList _≤_\n\ninsert : {b : Bound}{x : A} → LeB b (val x) → OList b → OList b\ninsert {b} {x} b≤x onil = :< b≤x onil\ninsert {b} {x} b≤x (:< {x = y} b≤y ys) \n with tot≤ x y\n... | inj₁ x≤y = :< b≤x (:< (lexy x≤y) ys)\n... | inj₂ y≤x = :< b≤y (insert (lexy y≤x) ys)\n\ninsertSort : List A → OList bot\ninsertSort [] = onil\ninsertSort (x ∷ xs) = insert {bot} {x} lebx (insertSort xs)\n", "meta": {"hexsha": "218583dd349588f691098b71949f699565c82688", "size": 639, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/InsertSort/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/InsertSort/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/InsertSort/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.7826086957, "max_line_length": 63, "alphanum_fraction": 0.5758998435, "num_tokens": 256, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.971563964485063, "lm_q2_score": 0.8289388019824946, "lm_q1q2_score": 0.8053670687696111}} {"text": "open import Relation.Binary.Core\n\nmodule InsertSort.Impl2.Correctness.Permutation.Alternative {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 Function\nopen import InsertSort.Impl2 _≤_ tot≤\nopen import List.Permutation.Alternative A renaming (_∼_ to _∼′_)\nopen import List.Permutation.Alternative.Correctness A \nopen import List.Permutation.Base A\nopen import OList _≤_\n\nlemma-insert∼′ : {b : Bound}{x : A}(b≤x : LeB b (val x))(xs : OList b) → (x ∷ forget xs) ∼′ forget (insert b≤x xs)\nlemma-insert∼′ b≤x onil = ∼refl\nlemma-insert∼′ {x = x} b≤x (:< {x = y} b≤y ys) \n with tot≤ x y\n... | inj₁ x≤y = ∼refl\n... | inj₂ y≤x = ∼trans (∼swap ∼refl) (∼head y (lemma-insert∼′ (lexy y≤x) ys)) \n\nlemma-insertSort∼′ : (xs : List A) → xs ∼′ forget (insertSort xs)\nlemma-insertSort∼′ [] = ∼refl\nlemma-insertSort∼′ (x ∷ xs) = ∼trans (∼head x (lemma-insertSort∼′ xs)) (lemma-insert∼′ lebx (insertSort xs))\n\ntheorem-insertSort∼ : (xs : List A) → xs ∼ forget (insertSort xs)\ntheorem-insertSort∼ = lemma-∼′-∼ ∘ lemma-insertSort∼′\n", "meta": {"hexsha": "b7ddb34533fd3b3175bfcd8c45b6463a5f86b2b5", "size": 1172, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/InsertSort/Impl2/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/Impl2/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/Impl2/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": 37.8064516129, "max_line_length": 114, "alphanum_fraction": 0.6527303754, "num_tokens": 434, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9559813513911655, "lm_q2_score": 0.8418256432832333, "lm_q1q2_score": 0.8047696161016425}} {"text": "module 015-logic where\n\n-- Simple propositional logic.\n\nopen import 010-false-true\n\n-- Logical and. We represent a proof of A and B as a pair of proofs,\n-- namely, a proof of A and a proof of B.\n\ndata Pair (A B : Set) : Set where\n _,_ : A -> B -> Pair A B\n\n_∧_ : (A B : Set) -> Set\nA ∧ B = Pair A B\n\n-- Get back proof of any of the components.\n\na∧b->a : {A B : Set} -> A ∧ B -> A\na∧b->a (a , b) = a \n\na∧b->b : {A B : Set} -> A ∧ B -> B\na∧b->b (a , b) = b\n\n-- Logical or. We represent a proof of A or B as a proof of A or a\n-- proof of B.\n\ndata Either (A B : Set) : Set where\n left : A -> Either A B\n right : B -> Either A B\n\n_∨_ : (A B : Set) -> Set\nA ∨ B = Either A B\n\n-- Negation.\n\n¬_ : (A : Set) -> Set\n¬ A = A -> False\n\n-- Now some properties.\n\n-- Commutativity.\n\na∧b->b∧a : ∀ {A B} -> A ∧ B -> B ∧ A\na∧b->b∧a ( a , b ) = ( b , a )\n\na∨b->b∨a : ∀ {A B} -> A ∨ B -> B ∨ A\na∨b->b∨a (left a) = right a\na∨b->b∨a (right b) = left b\n\n-- Distributivity.\n\na∧[b∨c]->[a∧b]∨[a∧c] : ∀ {A B C} -> A ∧ (B ∨ C) -> (A ∧ B) ∨ (A ∧ C)\na∧[b∨c]->[a∧b]∨[a∧c] (a , left b) = left (a , b)\na∧[b∨c]->[a∧b]∨[a∧c] (a , right c) = right (a , c)\n\n[a∧b]∨[a∧c]->a∧[b∨c] : ∀ {A B C} -> (A ∧ B) ∨ (A ∧ C) -> A ∧ (B ∨ C)\n[a∧b]∨[a∧c]->a∧[b∨c] (left (a , b)) = (a , left b)\n[a∧b]∨[a∧c]->a∧[b∨c] (right (a , c)) = (a , right c)\n\na∨[b∧c]->[a∨b]∧[a∨c] : ∀ {A B C} -> A ∨ (B ∧ C) -> (A ∨ B) ∧ (A ∨ C)\na∨[b∧c]->[a∨b]∧[a∨c] (left a) = (left a , left a)\na∨[b∧c]->[a∨b]∧[a∨c] (right (b , c)) = (right b , right c)\n\n[a∨b]∧[a∨c]->a∨[b∧c] : ∀ {A B C} -> (A ∨ B) ∧ (A ∨ C) -> A ∨ (B ∧ C)\n[a∨b]∧[a∨c]->a∨[b∧c] ( left a , _ ) = left a\n[a∨b]∧[a∨c]->a∨[b∧c] ( _ , left a ) = left a\n[a∨b]∧[a∨c]->a∨[b∧c] ( right b , right c ) = right (b , c)\n\n-- Contraposition.\n\n[a->b]->[¬b->¬a] : ∀ {A B} -> (A -> B) -> (¬ B -> ¬ A)\n[a->b]->[¬b->¬a] a->b ¬b a = ¬b (a->b a)\n\n-- Contradiction.\n\n¬[a∧¬a] : ∀ {A} -> ¬ (A ∧ (¬ A))\n¬[a∧¬a] ( a , ¬a ) = ¬a a\n\n-- De Morgan.\n\n¬[a∨b]->¬a∧¬b : ∀ {A B} -> ¬ (A ∨ B) -> (¬ A) ∧ (¬ B)\n¬[a∨b]->¬a∧¬b ¬[a∨b] = (\\a -> ¬[a∨b] (left a)) , (\\b -> ¬[a∨b] (right b))\n\n¬a∧¬b->¬[a∨b] : ∀ {A B} -> (¬ A) ∧ (¬ B) -> ¬ (A ∨ B)\n¬a∧¬b->¬[a∨b] ( ¬a , ¬b ) (left a) = ¬a a\n¬a∧¬b->¬[a∨b] ( ¬a , ¬b ) (right b) = ¬b b\n\n¬a∨¬b->¬[a∧b] : ∀ {A B} -> (¬ A) ∨ (¬ B) -> ¬ (A ∧ B)\n¬a∨¬b->¬[a∧b] (left ¬a) ( a , b ) = ¬a a\n¬a∨¬b->¬[a∧b] (right ¬b) ( a , b ) = ¬b b\n\n-- not provable, see https://math.stackexchange.com/questions/120187/does-de-morgans-laws-hold-in-propositional-intuitionistic-logic\n-- ¬[a∧b]->¬a∨¬b : ∀ {A B} -> ¬ (A ∧ B) -> (¬ A) ∨ (¬ B)\n-- ¬[a∧b]->¬a∨¬b ¬[a∧b] = {!!}\n", "meta": {"hexsha": "6c00d29d2980530c8408acf80daf3be6af83e34c", "size": 2537, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "015-logic.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": "015-logic.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": "015-logic.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.7052631579, "max_line_length": 132, "alphanum_fraction": 0.4189988175, "num_tokens": 1414, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9632305307578323, "lm_q2_score": 0.8354835371034368, "lm_q1q2_score": 0.8047632508835745}} {"text": "{-# OPTIONS --sized-types #-}\nopen import Relation.Binary.Core\n\nmodule SelectSort.Correctness.Permutation {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 List.Permutation.Base A\nopen import List.Permutation.Base.Equivalence A\nopen import Size\nopen import SList\nopen import SList.Properties\nopen import SelectSort _≤_ tot≤\n\nlemma-select∼ : {ι : Size}(x : A) → (xs : SList A {ι}) → unsize A (x ∙ xs) ∼ unsize A (proj₁ (select x xs) ∙ proj₂ (select x xs))\nlemma-select∼ x snil = ∼x /head /head ∼[]\nlemma-select∼ x (y ∙ ys) \n with tot≤ x y\n... | inj₁ x≤y = ∼x (/tail /head) (/tail /head) (lemma-select∼ x ys)\n... | inj₂ y≤x = ∼x /head (/tail /head) (lemma-select∼ y ys)\n\nlemma-selectSort∼ : {ι : Size}(xs : SList A {ι}) → unsize A xs ∼ unsize A (selectSort xs)\nlemma-selectSort∼ snil = ∼[]\nlemma-selectSort∼ (x ∙ xs) = trans∼ (lemma-select∼ x xs) (∼x /head /head (lemma-selectSort∼ (proj₂ (select x xs))))\n\ntheorem-selectSort∼ : (xs : List A) → xs ∼ unsize A (selectSort (size A xs))\ntheorem-selectSort∼ xs = trans∼ (lemma-unsize-size A xs) (lemma-selectSort∼ (size A xs))\n\n", "meta": {"hexsha": "9e5ee691834dba882a4c688cbc80ffd96d7ab3b0", "size": 1198, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/SelectSort/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/SelectSort/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/SelectSort/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.4375, "max_line_length": 129, "alphanum_fraction": 0.643572621, "num_tokens": 412, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9481545377452443, "lm_q2_score": 0.847967764140929, "lm_q1q2_score": 0.8040044834319109}} {"text": "{-# OPTIONS --without-K #-}\nmodule hott.core.equality where\n\nopen import hott.core.universe\n\n-- | The equality type. In hott we think of the equality type as paths\n-- between two points in the space A. To simplify the types we first\n-- fix the common parameters.\n\nmodule common {a : Level}{A : Type a} where\n\n\n data _≡_ (x : A) : (y : A) → Type a where\n refl : x ≡ x\n\n -- Induction principle for ≡ type.\n induction≡ : {ℓ : Level}\n → (D : {x y : A} (p : x ≡ y) → Type ℓ)\n → (d : {x : A} → D {x} {x} refl)\n → {x y : A} → (p : x ≡ y) → D p\n induction≡ D d refl = d\n\n -- In hott view point, this function takes the inverse of the path\n -- from x to y. As a relation you are proving that ≡ is symmetric.\n _⁻¹ : ∀{x y}\n → x ≡ y → y ≡ x\n refl ⁻¹ = refl\n\n -- The path composition. This means transitivity of the ≡ relation.\n _∙_ : ∀ {x y z}\n → x ≡ y → y ≡ z → x ≡ z\n refl ∙ refl = refl\n\n\n infixr 1 _≡_\n\n -- Precedence of multiplication\n infixl 70 _∙_\n\n -- Precedence of exponentiation.\n infixl 90 _⁻¹\n -- Equational reasoning\n -- To prove x_0 = x_n by a sequence of proofs\n -- x_0 = x_1\n -- x_1 = x_2\n -- ... you can use the following syntax\n --\n -- begin x_0 ≅ x_1 by p1\n -- ≅ x_2 by p2\n -- ....\n -- ≅ x_n by pn\n -- ∎\n --\n\n -- In equational proofs, it is more readable to use by definition\n -- than by refl\n definition : ∀{x} → x ≡ x\n definition = refl\n\n begin_ : (x : A)\n → x ≡ x\n begin_ x = refl\n\n _≡_by_ : ∀ {x y : A}\n → x ≡ y\n → (z : A)\n → y ≡ z\n → x ≡ z\n p ≡ z by q = p ∙ q\n\n _∎ : ∀{x y : A}\n → (x ≡ y)\n → (x ≡ y)\n proof ∎ = proof\n\n infixl 2 begin_\n infixl 1 _≡_by_\n infixl 0 _∎\n\n\n -- We now capture path transportation in the following submodule.\n module Transport {ℓ : Level} where\n -- Path transportation.\n transport : ∀ {x y : A}\n → x ≡ y\n → {P : A → Type ℓ}\n → P x → P y\n transport refl = λ z → z\n\n -- Another symbol for transport. Use it when you do not want to\n -- specify P.\n _⋆ : {P : A → Type ℓ}\n → {x y : A}\n → x ≡ y\n → P x → P y\n p ⋆ = transport p\n\n open Transport public\n\nopen common public\n\n\n{-# BUILTIN EQUALITY _≡_ #-}\n{-# BUILTIN REFL refl #-}\n\n\n-- The functional congruence, i.e. likes gives likes on application of\n-- a function. In the HoTT perspective this says that functions are\n-- functors.\nap : ∀ {a b : Level} {A : Type a}{B : Type b} {x y : A}\n → (f : A → B)\n → x ≡ y → (f x) ≡ (f y)\nap f refl = refl\n\n-- The dependent version of ap. This requires transport for its\n-- definition.\napd : ∀{a b : Level }{A : Type a}{B : A → Type b}\n → (f : (a : A) → B a)\n → {x y : A}\n → (p : x ≡ y)\n → (p ⋆) (f x) ≡ f y\napd f refl = refl\n\n-- Better syntax fro ap in equational reasoning.\napplying_on_ : ∀{ℓ₀ ℓ₁}{A : Type ℓ₀}{B : Type ℓ₁}\n → (f : A → B)\n → {x y : A}\n → (p : x ≡ y)\n → f x ≡ f y\napplying_on_ f a = ap f a\n\n-- Better syntax for dependent version of applying on both sides.\ntransporting_over_ : ∀{ℓ₀ ℓ₁}{A : Type ℓ₀}{B : A → Type ℓ₁}\n → (f : (a : A) → B(a)){x y : A}\n → (p : x ≡ y)\n → (p ⋆) (f x) ≡ f y\ntransporting f over p = apd f p\n\ninfixr 2 applying_on_\ninfixr 2 transporting_over_\n", "meta": {"hexsha": "7dea982a49fdd794a714b131416a6423396c5b21", "size": 3379, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/hott/core/equality.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/equality.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/equality.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.9645390071, "max_line_length": 70, "alphanum_fraction": 0.5146493045, "num_tokens": 1207, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9496693659780477, "lm_q2_score": 0.8459424295406088, "lm_q1q2_score": 0.8033656107157593}} {"text": "-- {-# OPTIONS --sized-types --show-implicit #-}\n\nmodule _ where\n\nopen import Common.Size\n\ndata Either (A B : Set) : Set where\n left : A → Either A B\n right : B → Either A B\n\ncaseEither : ∀{A B C : Set} → Either A B → (A → C) → (B → C) → C\ncaseEither (left a) l r = l a\ncaseEither (right b) l r = r b\n\ndata Nat {i : Size} : Set where\n zero : Nat\n suc : {i' : Size< i} → Nat {i'} → Nat\n\n-- subtraction is non size increasing\nsub : {size : Size} → Nat {size} → Nat {∞} → Nat {size}\nsub zero n = zero\nsub (suc m) zero = suc m\nsub (suc m) (suc n) = sub m n\n\n-- div' m n computes ceiling(m/(n+1))\ndiv' : {size : Size} → Nat {size} → Nat → Nat {size}\ndiv' zero n = zero\ndiv' (suc m) n = suc (div' (sub m n) n)\n\n-- one can use sized types as if they were not sized\n-- sizes default to ∞\n\nadd : Nat → Nat → Nat\nadd (zero ) n = n\nadd (suc m) n = suc (add m n)\n\nnisse : {i : Size} → Nat {i} → Nat {i}\nnisse zero = zero\nnisse (suc zero) = suc zero\nnisse (suc (suc n)) = suc zero\n\n-- symmetric difference\n-- @diff n m@ returns @left (n - m)@ if @n@ is bigger, otherwise @right (m - n)@\ndiff : ∀{i j} → Nat {i} → Nat {j} → Either (Nat {i}) (Nat {j})\ndiff zero m = right m\ndiff (suc n) zero = left (suc n)\ndiff (suc n) (suc m) = diff n m\n\nmodule Case where\n gcd : ∀{i j} → Nat {i} → Nat {j} → Nat\n gcd zero m = m\n gcd (suc n) zero = suc n\n gcd (suc n) (suc m) = caseEither (diff n m)\n (λ n' → gcd n' (suc m))\n (λ m' → gcd (suc n) m')\n\nmodule With where\n gcd : ∀{i j} → Nat {i} → Nat {j} → Nat\n gcd zero m = m\n gcd (suc n) zero = suc n\n gcd (suc n) (suc m) with diff n m\n ... | left n' = gcd n' (suc m)\n ... | right m' = gcd (suc n) m'\n\n\n\n\n\n\nNatInfty = Nat {∞}\n\n{-# BUILTIN NATURAL NatInfty #-}\n-- {-# BUILTIN NATPLUS add #-} -- not accepted\n\n", "meta": {"hexsha": "fdc21dd616b081ad1e600072502c2076620baa98", "size": 1830, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/SizedNatNew.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "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/SizedNatNew.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_forks_repo_path": "test/Succeed/SizedNatNew.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "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": 24.4, "max_line_length": 80, "alphanum_fraction": 0.5338797814, "num_tokens": 706, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9207896802383028, "lm_q2_score": 0.8723473663814338, "lm_q1q2_score": 0.803248452547086}} {"text": "{-# OPTIONS --no-termination-check #-}\n\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\ndivSucAux : Nat -> Nat -> Nat -> Nat -> Nat\ndivSucAux k m zero j = k\ndivSucAux k m (suc n) zero = divSucAux (suc k) m n m\ndivSucAux k m (suc n) (suc j) = divSucAux k m n j\n\nmodSucAux : Nat -> Nat -> Nat -> Nat -> Nat\nmodSucAux k m zero j = k\nmodSucAux k m (suc n) zero = modSucAux zero m n m\nmodSucAux k m (suc n) (suc j) = modSucAux (suc k) m n j\n\n{-# BUILTIN NATDIVSUCAUX divSucAux #-}\n{-# BUILTIN NATMODSUCAUX modSucAux #-}\n\ndiv : Nat -> Nat -> Nat\ndiv n zero = zero\ndiv n (suc m) = divSucAux zero m n m\n\nmod : Nat -> Nat -> Nat\nmod n zero = zero\nmod n (suc m) = modSucAux zero m 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": "e289f8e720a38125e310343964f35c430fe76e8b", "size": 1936, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/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/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/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": 18.6153846154, "max_line_length": 55, "alphanum_fraction": 0.5511363636, "num_tokens": 753, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9184802395624257, "lm_q2_score": 0.8740772417253256, "lm_q1q2_score": 0.8028226743759415}} {"text": "\nmodule Example where\n\nopen import Agda.Builtin.Nat\nopen import Agda.Builtin.List\nopen import Agda.Builtin.Equality\n\ndownFrom : Nat → List Nat\ndownFrom zero = []\ndownFrom (suc n) = n ∷ downFrom n\n\nsum-rec : List Nat → Nat\nsum-rec [] = 0\nsum-rec (x ∷ xs) = x + sum-rec xs\n\nsum-acc : Nat → List Nat → Nat\nsum-acc z [] = z\nsum-acc z (x ∷ xs) = sum-acc (z + x) xs\n\nsum-acc! : Nat → List Nat → Nat\nsum-acc! z [] = z\nsum-acc! 0 (x ∷ xs) = sum-acc! x xs\nsum-acc! z (x ∷ xs) = sum-acc! (z + x) xs\n\nn = 10000\nbench-rec = sum-rec (downFrom n)\nbench-acc = sum-acc 0 (downFrom n)\nbench-acc! = sum-acc! 0 (downFrom n)\n", "meta": {"hexsha": "bc77c726792e2f99c61f38da9f5fc19b2852c338", "size": 620, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/Example.agda", "max_stars_repo_name": "L-TChen/agda-bench", "max_stars_repo_head_hexsha": "cf0043a64d2913ad19a58f2b4bcc075138bb911f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 13, "max_stars_repo_stars_event_min_datetime": "2018-10-18T10:31:12.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-22T10:57:58.000Z", "max_issues_repo_path": "examples/Example.agda", "max_issues_repo_name": "L-TChen/agda-bench", "max_issues_repo_head_hexsha": "cf0043a64d2913ad19a58f2b4bcc075138bb911f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2021-02-05T18:44:25.000Z", "max_issues_repo_issues_event_max_datetime": "2021-02-09T05:59:42.000Z", "max_forks_repo_path": "examples/Example.agda", "max_forks_repo_name": "L-TChen/agda-bench", "max_forks_repo_head_hexsha": "cf0043a64d2913ad19a58f2b4bcc075138bb911f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-02-05T18:49:17.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-25T06:10:26.000Z", "avg_line_length": 21.3793103448, "max_line_length": 41, "alphanum_fraction": 0.6112903226, "num_tokens": 245, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9111797148356994, "lm_q2_score": 0.8807970764133561, "lm_q1q2_score": 0.8025644289144396}} {"text": "------------------------------------------------------------------------------\n-- Example of a nested recursive function using the Bove-Capretta\n-- method\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\n-- From: Bove, A. and Capretta, V. (2001). Nested General Recursion\n-- and Partiality in Type Theory. In: Theorem Proving in Higher Order\n-- Logics (TPHOLs 2001). Ed. by Boulton, R. J. and Jackson,\n-- P. B. Vol. 2152. LNCS. Springer, pp. 121–135.\n\nmodule FOT.FOTC.Program.Nest.NestBC-SL where\n\nopen import Data.Nat renaming ( suc to succ )\nopen import Data.Nat.Properties\n\nopen import Induction\nopen import Induction.Nat\n\nopen import Relation.Binary\n\n------------------------------------------------------------------------------\n-- The original non-terminating function.\n\n{-# TERMINATING #-}\nnestI : ℕ → ℕ\nnestI 0 = 0\nnestI (succ n) = nestI (nestI n)\n\n-- ≤′-trans : Transitive _≤′_\n-- ≤′-trans i≤′j j≤′k = ≤⇒≤′ (NDTO.trans (≤′⇒≤ i≤′j) (≤′⇒≤ j≤′k))\n\nmutual\n -- The domain predicate of the nest function.\n data NestDom : ℕ → Set where\n nestDom0 : NestDom 0\n nestDomS : ∀ {n} → (h₁ : NestDom n) →\n (h₂ : NestDom (nestD n h₁)) →\n NestDom (succ n)\n\n -- The nest function by structural recursion on the domain predicate.\n nestD : ∀ n → NestDom n → ℕ\n nestD .0 nestDom0 = 0\n nestD .(succ n) (nestDomS {n} h₁ h₂) = nestD (nestD n h₁) h₂\n\nnestD-≤′ : ∀ n → (h : NestDom n) → nestD n h ≤′ n\nnestD-≤′ .0 nestDom0 = ≤′-refl\nnestD-≤′ .(succ n) (nestDomS {n} h₁ h₂) =\n ≤′-trans (≤′-trans (nestD-≤′ (nestD n h₁) h₂) (nestD-≤′ n h₁))\n (≤′-step ≤′-refl)\n\n-- The nest function is total.\nallNestDom : ∀ n → NestDom n\nallNestDom = build <′-recBuilder P ih\n where\n P : ℕ → Set\n P = NestDom\n\n ih : ∀ y → <′-Rec P y → P y\n ih zero rec = nestDom0\n ih (succ y) rec = nestDomS nd-y (rec (nestD y nd-y) (s≤′s (nestD-≤′ y nd-y)))\n where\n helper : ∀ x → x <′ y → P x\n helper x Sx≤′y = rec x (≤′-step Sx≤′y)\n\n nd-y : NestDom y\n nd-y = ih y helper\n\n-- The nest function.\nnest : ℕ → ℕ\nnest n = nestD n (allNestDom n)\n", "meta": {"hexsha": "078e81c8a4f3d43d0de0f1ec6d5890277c747494", "size": 2314, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/FOT/FOTC/Program/Nest/NestBC-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/FOT/FOTC/Program/Nest/NestBC-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/FOT/FOTC/Program/Nest/NestBC-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": 30.4473684211, "max_line_length": 79, "alphanum_fraction": 0.5203111495, "num_tokens": 779, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9314625088705931, "lm_q2_score": 0.8615382147637196, "lm_q1q2_score": 0.8024905470117062}} {"text": "\nmodule Logic.Base where\n\ninfix 60 ¬_\ninfix 30 _/\\_\ninfix 20 _\\/_\n\ndata True : Set where\n tt : True\n\ndata False : Set where\n\nelim-False : {A : Set} -> False -> A\nelim-False ()\n\ndata _/\\_ (P Q : Set) : Set where\n /\\-I : P -> Q -> P /\\ Q\n\ndata _\\/_ (P Q : Set) : Set where\n \\/-IL : P -> P \\/ Q\n \\/-IR : Q -> P \\/ Q\n\nelimD-\\/ : {P Q : Set}(C : P \\/ Q -> Set) ->\n\t ((p : P) -> C (\\/-IL p)) ->\n\t ((q : Q) -> C (\\/-IR q)) ->\n\t (pq : P \\/ Q) -> C pq\nelimD-\\/ C left right (\\/-IL p) = left p\nelimD-\\/ C left right (\\/-IR q) = right q\n\nelim-\\/ : {P Q R : Set} -> (P -> R) -> (Q -> R) -> P \\/ Q -> R\nelim-\\/ = elimD-\\/ (\\_ -> _)\n\n¬_ : Set -> Set\n¬ P = P -> False\n\ndata ∃ {A : Set}(P : A -> Set) : Set where\n ∃-I : (w : A) -> P w -> ∃ P\n\n∏ : {A : Set}(P : A -> Set) -> Set\n∏ {A} P = (x : A) -> P x\n\n", "meta": {"hexsha": "a99b8574e4136d624833deeba61dfb610c547e43", "size": 799, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Logic/Base.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/Logic/Base.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/Base.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.0238095238, "max_line_length": 62, "alphanum_fraction": 0.4192740926, "num_tokens": 347, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9597620562254526, "lm_q2_score": 0.8354835452961425, "lm_q1q2_score": 0.8018654053759569}} {"text": "module HC-Lec2 where\n\nopen import HC-Lec1\n\n-- ==============================================================================\n-- Lecture 4 : Sigma, Difference, Vector Take\n-- https://www.youtube.com/watch?v=OZeDRtRmgkw\n\n-- 43:14\n\ndata Vec (X : Set) : Nat -> Set where\n [] : Vec X zero\n _::_ : {n : Nat} -> X -> Vec X n -> Vec X (suc n)\ninfixr 4 _::_\n\nvTake : (m n : Nat) -> m >= n -> {X : Set} -> Vec X m -> Vec X n\nvTake m zero m>=n xs = []\nvTake (suc m) (suc n) m>=n (x :: xs) = x :: vTake m n m>=n xs\n\nvTake32 : Set\nvTake32 = vTake 3 2 <> (1 :: 2 :: 3 :: []) == (1 :: 2 :: [])\n\n-- 47:35 : taking ALL elements is an identity\nvTakeIdFact : (n : Nat) {X : Set} (xs : Vec X n)\n -> vTake n n (refl->= n) xs == xs\nvTakeIdFact .0 [] = refl []\nvTakeIdFact (suc n) (x :: xs) rewrite vTakeIdFact n xs = refl (x :: xs)\n\n-- 48:17 : taking p elements from Vm is same as taking n elements from Vm, forming Vn\n-- then taking p elments from Vn\nvTakeCpFact : (m n p : Nat) (m>=n : m >= n) (n>=p : n >= p) {X : Set} (xs : Vec X m)\n -> vTake m p (trans->= m n p m>=n n>=p) xs\n == vTake n p n>=p (vTake m n m>=n xs)\nvTakeCpFact m n zero m>=n n>=p _ = refl []\nvTakeCpFact (suc m) (suc n) (suc p) m>=n n>=p (x :: xs)\n rewrite vTakeCpFact m n p m>=n n>=p xs\n = refl (x :: (vTake n p n>=p (vTake m n m>=n xs)))\n\n-- 48:54\n-- vTakeIdFact : reflexivity turns into identity\n-- vTakeCpFact : transitivity turns into composition\n\n-- ==============================================================================\n-- Lecture 5 : How Rewrite Works\n-- https://www.youtube.com/watch?v=b5salYMZoyM\n\n-- 3:34\nvTake53 : Vec Nat 3\nvTake53 = vTake 5 3 <> (1 :: 2 :: 3 :: 4 :: 5 :: [])\n\n-- 5:30\nvTake' : ∀ {m : Nat} {X : Set}\n -> (n : Nat) -> m >= n -> Vec X m\n -> Vec X n\nvTake' {m} zero m>=n xs = []\nvTake' {suc m} (suc n) m>=n (x :: xs) = x :: vTake' {m} n m>=n xs\n\n{-\n-- 7:45\nrigid symbols : constructors (value and type)\n- if you are trying to tell if two usages of constructors match each other,\n you can compare them component-wise\n- no defined computational meaning - they are what they are\n- e.g., Vec Nat 3\nnon-rigid\n- e.g., >=\n- can compute\n\n\n-- 15:48\nvTake : think of as turning a '>=' proof into a vector operation.\n- In comes a proof on numbers, out comes an operation on vectors.\nvTakeIdFact : identity proof on numbers turns into identity operation on vectors\nvTakeCpFact : proof of transitivity on numbers turns into composition operation on vectors\n\n-- 24:08 : best practice : use record (instead of data) when possible : agda is more aggressive\n\n-- 24:28 : HOW REWRITE WORKS\nRewrite is shorthand for\n- abstract the LHS of the equation using 'with'\n- abstract the proof of the equation using 'with'\n- then pattern matching on the proof\n-}\n\n------------------------------------------------------------------------------\n-- Splittings (which bear some relationship to <= from ex1)\n-- 39:00\n\ndata _<[_]>_ : Nat -> Nat -> Nat -> Set where\n zzz : zero <[ zero ]> zero\n\n lll : {l m r : Nat} -> l <[ m ]> r\n -> suc l <[ suc m ]> r\n\n rrr : {l m r : Nat} -> l <[ m ]> r\n -> l <[ suc m ]> suc r\n\n-- xzzz : Set\n-- xzzz = zero <[ zero ]> zero\n\n-- x1z1 : Set\n-- x1z1 = 1 <[ zero ]> 1\n\n-- x159 : Set\n-- x159 = 1 <[ 5 ]> 9\n\n-- x951 : Set\n-- x951 = 9 <[ 5 ]> 1\n\n-- 41:08\n-- combine two vectors into one according to given instructions\n\n-- this is kind of a \"double-sided\" '<='\n{- collection\n * <--- *\n * ---> *\n * ---> *\n * <--- *\n * ---> *\n 3 from left 2 from right\n-}\n_>[_]<_ : {X : Set} {l m r : Nat}\n -> Vec X l\n -> l <[ m ]> r -- instructions\n -> Vec X r\n -> Vec X m\n-- why is rrr the first line?\n-- 29:49 https://www.youtube.com/watch?v=RW4aC_6n0yQ\n-- do NOT pattern match on vector first (LHS of first clause)\n-- pattern match on instructions first\n-- i.e., no pattern match on xl, so goes to try to match instruction : >[ rrr mmm ]<\nxl >[ rrr mmm ]< (x :: xr) = x :: (xl >[ mmm ]< xr)\n(x :: xl) >[ lll mmm ]< xr = x :: (xl >[ mmm ]< xr)\n[] >[ zzz ]< [] = []\n\nv6rl : Vec Nat 6\nv6rl = (0 :: 2 :: 3 :: []) >[ rrr (rrr (rrr (lll (lll (lll zzz))))) ]< (7 :: 8 :: 9 :: [])\n\n_ : v6rl == (7 :: 8 :: 9 :: 0 :: 2 :: 3 :: [])\n_ = refl (7 :: 8 :: 9 :: 0 :: 2 :: 3 :: [])\n\nv6 : Vec Nat 6\nv6 = (0 :: 2 :: 3 :: []) >[ lll (rrr (lll (rrr (lll (rrr zzz))))) ]< (7 :: 8 :: 9 :: [])\n\n_ : v6 == (0 :: 7 :: 2 :: 8 :: 3 :: 9 :: [])\n_ = refl (0 :: 7 :: 2 :: 8 :: 3 :: 9 :: [])\n\n-- 44:27\n\n-- split a vector into two vectors according to given instructions\n-- reverses '<[ m ]>' - instructions for taking things apart\ndata FindSplit {X : Set} {l m r : Nat}\n (nnn : l <[ m ]> r) : (xs : Vec X m) -> Set where\n splitBits : (xl : Vec X l) (xr : Vec X r) -> FindSplit nnn (xl >[ nnn ]< xr)\n\n-- proves FindSplit\nfindSplit : {X : Set} {l m r : Nat} (nnn : l <[ m ]> r) (xs : Vec X m) -> FindSplit nnn xs\n\nfindSplit zzz [] = splitBits [] []\n\nfindSplit (lll nnn) (x :: xs) with findSplit nnn xs\n -- FindSplit (lll nnn) (x :: (xl >[ nnn ]< xr))\nfindSplit (lll nnn) (x :: .(xl >[ nnn ]< xr)) | splitBits xl xr = splitBits (x :: xl) xr\n\nfindSplit (rrr nnn) (x :: xs) with findSplit nnn xs\n -- FindSplit (rrr nnn) (x :: (xl >[ nnn ]< xr))\nfindSplit (rrr nnn) (x :: .(xl >[ nnn ]< xr)) | splitBits xl xr = splitBits xl (x :: xr)\n\n-- ==============================================================================\n-- https://www.youtube.com/watch?v=RW4aC_6n0yQ\n\n-- 5:08\n{-\nThe o' <= constructor : you can keep increasing the RHS\n\n oz -- stop\n os -- take this one and keep going\n o' -- skip this one and keep going\n\nTabulating the ways of choosing N things from M things\nA path is a way to get a specific embedding.\nThe numbers in parenthesis shows the number of paths to a specific embedding (Pascal's triangle).\n\n oz\n 0<=0\n (1)\n / \\\n / \\\n / \\\n o' os\n 0<=1 1<=1\n (1) (1)\n / \\ / \\\n / \\ / \\\n / \\ / \\\n o' os o' os\n 0<=2 1<=2 2<=2\n (1) (2) (2)\n / \\ / \\ / \\\n / \\ / \\ / \\\n / \\ / \\ / \\\n o' os o' os o' os\n 0<=3 1<=3 2<=3 3<=3\n (1) (3) (3) (1)\n\nwitnesses to M choose N\nread a value in a set of this type as instructions for choosing\n-}\n\n-- 14:58\n-- 'findSplit' (above)\n-- 23:20\n-- last clause of 'findSplit'\n-- 29:49 : the same ERROR I had before changing order of clauses in _>[_]<_\n-- 34:22 : rule of thumb\n-- if there is one column of args, where on every line is a constructor then no change\n-- otherwise, choose ordering carefully\n-- 35:52 : final order of clauses of of _>[_]<_ -- tidy to have nil case at top or bottom\n-- 40:15 shows how agda/haskell does case splitting on _>[_]<_\n\n\n\n\n", "meta": {"hexsha": "ccc52f366eb056b8d74befc718c4443b2951da93", "size": 7845, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/course/2017-conor_mcbride_cs410/HC-Lec2.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-Lec2.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-Lec2.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": 35.0223214286, "max_line_length": 97, "alphanum_fraction": 0.4467813894, "num_tokens": 2440, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9449947062846397, "lm_q2_score": 0.8479677660619633, "lm_q1q2_score": 0.8013250500285671}} {"text": "\nmodule Fin where\n\nimport Nat\nimport Bool\n\nopen Nat hiding (_==_; _<_)\nopen Bool\n\ndata FZero : Set where\n\ndata FSuc (A : Set) : Set where\n fz : FSuc A\n fs : A -> FSuc A\n\nmutual\n\n Fin' : Nat -> Set\n Fin' zero = FZero\n Fin' (suc n) = FSuc (Fin n)\n\n data Fin (n : Nat) : Set where\n fin : Fin' n -> Fin n\n\nfzero : {n : Nat} -> Fin (suc n)\nfzero = fin fz\n\nfsuc : {n : Nat} -> Fin n -> Fin (suc n)\nfsuc n = fin (fs n)\n\n_==_ : {n : Nat} -> Fin n -> Fin n -> Bool\n_==_ {zero} (fin ()) (fin ())\n_==_ {suc n} (fin fz) (fin fz) = true\n_==_ {suc n} (fin (fs i)) (fin (fs j)) = i == j\n_==_ {suc n} (fin fz) (fin (fs j)) = false\n_==_ {suc n} (fin (fs i)) (fin fz) = false\n\nsubst : {n : Nat}{i j : Fin n} -> (P : Fin n -> Set) -> IsTrue (i == j) -> P i -> P j\nsubst {zero} {fin ()} {fin ()} P _ _\nsubst {suc n} {fin fz} {fin fz} P eq pi = pi\nsubst {suc n} {fin (fs i)} {fin (fs j)} P eq pi = subst (\\z -> P (fsuc z)) eq pi\nsubst {suc n} {fin fz} {fin (fs j)} P () _\nsubst {suc n} {fin (fs i)} {fin fz} P () _\n\n_<_ : {n : Nat} -> Fin n -> Fin n -> Bool\n_<_ {zero} (fin ()) (fin ())\n_<_ {suc n} _ (fin fz) = false\n_<_ {suc n} (fin fz) (fin (fs j)) = true\n_<_ {suc n} (fin (fs i)) (fin (fs j)) = i < j\n\nfromNat : (n : Nat) -> Fin (suc n)\nfromNat zero = fzero\nfromNat (suc n) = fsuc (fromNat n)\n\nliftSuc : {n : Nat} -> Fin n -> Fin (suc n)\nliftSuc {zero} (fin ())\nliftSuc {suc n} (fin fz) = fin fz\nliftSuc {suc n} (fin (fs 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\n", "meta": {"hexsha": "9b3543414a036d325c1e3d62ad9a644e9c514568", "size": 1629, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "benchmark/ac/Fin.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": "benchmark/ac/Fin.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": "benchmark/ac/Fin.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": 25.453125, "max_line_length": 85, "alphanum_fraction": 0.4917127072, "num_tokens": 681, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9241418262465169, "lm_q2_score": 0.867035763237924, "lm_q1q2_score": 0.8012640136597377}} {"text": "open import Relation.Binary.Core\n\nmodule Heapsort.Impl1.Correctness.Order {A : Set}\n (_≤_ : A → A → Set) \n (tot≤ : Total _≤_) \n (trans≤ : Transitive _≤_) where\n\nopen import Data.List\nopen import Function using (_∘_)\nopen import Heapsort.Impl1 _≤_ tot≤ trans≤\nopen import List.Sorted _≤_\nopen import OList _≤_\nopen import OList.Properties _≤_\n\ntheorem-heapsort-sorted : (xs : List A) → Sorted (forget (heapsort xs))\ntheorem-heapsort-sorted = lemma-olist-sorted ∘ heapsort\n", "meta": {"hexsha": "29a1fb9b8ebfef25a537f091efa812a24ab33728", "size": 522, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Heapsort/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/Heapsort/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/Heapsort/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": 30.7058823529, "max_line_length": 71, "alphanum_fraction": 0.6570881226, "num_tokens": 159, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9539660923657093, "lm_q2_score": 0.8397339676722393, "lm_q1q2_score": 0.801077731767039}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- An explanation about the `Axiom` modules.\n------------------------------------------------------------------------\n\nmodule README.Axiom where\n\nopen import Level using (Level)\n\nprivate variable ℓ : Level\n\n------------------------------------------------------------------------\n-- Introduction\n\n-- Several rules that are used without thought in written mathematics\n-- cannot be proved in Agda. The modules in the `Axiom` folder\n-- provide types expressing some of these rules that users may want to\n-- use even when they're not provable in Agda.\n\n------------------------------------------------------------------------\n-- Example: law of excluded middle\n\n-- In classical logic the law of excluded middle states that for any\n-- proposition `P` either `P` or `¬P` must hold. This is impossible\n-- to prove in Agda because Agda is a constructive system and so any\n-- proof of the excluded middle would have to build a term of either\n-- type `P` or `¬P`. This is clearly impossible without any knowledge\n-- of what proposition `P` is.\n\n-- The types for which `P` or `¬P` holds is called `Dec P` in the\n-- standard library (short for `Decidable`).\n\nopen import Relation.Nullary using (Dec)\n\n-- The type of the proof of saying that excluded middle holds for\n-- all types at universe level ℓ is therefore:\n--\n-- ExcludedMiddle ℓ = ∀ {P : Set ℓ} → Dec P\n--\n-- and this type is exactly the one found in `Axiom.ExcludedMiddle`:\n\nopen import Axiom.ExcludedMiddle\n\n-- There are two different ways that the axiom can be introduced into\n-- your Agda development. The first option is to postulate it:\n\npostulate excludedMiddle : ExcludedMiddle ℓ\n\n-- This has the advantage that it only needs to be postulated once\n-- and it can then be imported into many different modules as with any\n-- other proof. The downside is that the resulting Agda code will no\n-- longer type check under the --safe flag.\n\n-- The second approach is to pass it as a module parameter:\n\nmodule Proof (excludedMiddle : ExcludedMiddle ℓ) where\n\n-- The advantage of this approach is that the resulting Agda\n-- development can still be type checked under the --safe flag.\n-- Intuitively the reason for this is that when postulating it\n-- you are telling Agda that excluded middle does hold (which is clearly\n-- untrue as discussed above). In contrast when passing it as a module\n-- parameter you are telling Agda that **if** excluded middle was true\n-- then the following proofs would hold, which is logically valid.\n\n-- The disadvantage of this approach is that it is now necessary to\n-- include the excluded middle assumption as a parameter in every module\n-- that you want to use it in. Additionally the modules can never\n-- be fully instantiated (without postulating excluded middle).\n\n------------------------------------------------------------------------\n-- Other axioms\n\n-- Double negation elimination\n-- (∀ P → ¬ ¬ P → P)\n\nimport Axiom.DoubleNegationElimination\n\n-- Function extensionality\n-- (∀ f g → (∀ x → f x ≡ g x) → f ≡ g)\n\nimport Axiom.Extensionality.Propositional\nimport Axiom.Extensionality.Heterogeneous\n\n-- Uniqueness of identity proofs (UIP)\n-- (∀ x y (p q : x ≡ y) → p ≡ q)\n\nimport Axiom.UniquenessOfIdentityProofs\n", "meta": {"hexsha": "d22dfc0ca9003ff718aa6d86260b983a5cd5f7b6", "size": 3307, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/README/Axiom.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/Axiom.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/Axiom.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": 36.7444444444, "max_line_length": 72, "alphanum_fraction": 0.65951013, "num_tokens": 736, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9111797148356995, "lm_q2_score": 0.8791467690927439, "lm_q1q2_score": 0.801060702360653}} {"text": "open import Relation.Binary.Core\n\nmodule TreeSort.Impl1 {A : Set}\n (_≤_ : A → A → Set)\n (tot≤ : Total _≤_) where\n\nopen import BTree {A}\nopen import Data.List\nopen import Data.Sum\n\ninsert : A → BTree → BTree\ninsert x leaf = node x leaf leaf\ninsert x (node y l r) \n with tot≤ x y\n... | inj₁ x≤y = node y (insert x l) r\n... | inj₂ y≤x = node y l (insert x r)\n\ntreeSort : List A → BTree\ntreeSort [] = leaf\ntreeSort (x ∷ xs) = insert x (treeSort xs)\n\n\n\n\n", "meta": {"hexsha": "230581f6984d3aa2d3b109a078ec9fa2d7b8bb0f", "size": 488, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/TreeSort/Impl1.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.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.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.52, "max_line_length": 43, "alphanum_fraction": 0.5860655738, "num_tokens": 163, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9715639669551474, "lm_q2_score": 0.8244619199068831, "lm_q1q2_score": 0.8010174935081883}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Least Common Multiple for integers\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Integer.LCM where\n\nopen import Data.Integer.Base\nopen import Data.Integer.Divisibility\nopen import Data.Integer.GCD\nopen import Data.Nat.Base using (ℕ)\nimport Data.Nat.LCM as ℕ\nopen import Relation.Binary.PropositionalEquality\n\n------------------------------------------------------------------------\n-- Definition\n------------------------------------------------------------------------\n\nlcm : ℤ → ℤ → ℤ\nlcm i j = + ℕ.lcm ∣ i ∣ ∣ j ∣\n\n------------------------------------------------------------------------\n-- Properties\n------------------------------------------------------------------------\n\ni∣lcm[i,j] : ∀ i j → i ∣ lcm i j\ni∣lcm[i,j] i j = ℕ.m∣lcm[m,n] ∣ i ∣ ∣ j ∣\n\nj∣lcm[i,j] : ∀ i j → j ∣ lcm i j\nj∣lcm[i,j] i j = ℕ.n∣lcm[m,n] ∣ i ∣ ∣ j ∣\n\nlcm-least : ∀ {i j c} → i ∣ c → j ∣ c → lcm i j ∣ c\nlcm-least c∣i c∣j = ℕ.lcm-least c∣i c∣j\n\nlcm[0,i]≡0 : ∀ i → lcm 0ℤ i ≡ 0ℤ\nlcm[0,i]≡0 i = cong (+_) (ℕ.lcm[0,n]≡0 ∣ i ∣)\n\nlcm[i,0]≡0 : ∀ i → lcm i 0ℤ ≡ 0ℤ\nlcm[i,0]≡0 i = cong (+_) (ℕ.lcm[n,0]≡0 ∣ i ∣)\n\nlcm-comm : ∀ i j → lcm i j ≡ lcm j i\nlcm-comm i j = cong (+_) (ℕ.lcm-comm ∣ i ∣ ∣ j ∣)\n", "meta": {"hexsha": "8e8101132aeeccb2a0a9a03f82c7a5e6eb372cd5", "size": 1354, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Data/Integer/LCM.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/src/Data/Integer/LCM.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/src/Data/Integer/LCM.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.4347826087, "max_line_length": 72, "alphanum_fraction": 0.3892171344, "num_tokens": 447, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.948917260153714, "lm_q2_score": 0.8438951045175643, "lm_q1q2_score": 0.8007866304359392}} {"text": "{-# OPTIONS --sized-types #-}\nopen import Relation.Binary.Core\n\nmodule Mergesort.Impl1 {A : Set}\n (_≤_ : A → A → Set)\n (tot≤ : Total _≤_) where\n\nopen import Bound.Lower A\nopen import Bound.Lower.Order _≤_\nopen import Data.Product\nopen import Data.Sum\nopen import Size\nopen import SList\nopen import SOList.Lower _≤_\n\ndeal : {ι : Size} → SList A {ι} → SList A {ι} × SList A {ι}\ndeal snil = (snil , snil) \ndeal (x ∙ snil) = (x ∙ snil , snil) \ndeal (x ∙ (y ∙ xs)) \n with deal xs\n... | (ys , zs) = (x ∙ ys , y ∙ zs)\n\nmerge : {ι ι' : Size}{b : Bound} → SOList {ι} b → SOList {ι'} b → SOList b\nmerge onil ys = ys \nmerge xs onil = xs \nmerge (:< {x = x} b≤x xs) (:< {x = y} b≤y ys) \n with tot≤ x y\n... | inj₁ x≤y = :< b≤x (merge xs (:< (lexy x≤y) ys))\n... | inj₂ y≤x = :< b≤y (merge (:< (lexy y≤x) xs) ys)\n\nmergesort : {ι : Size} → SList A {↑ ι} → SOList bot\nmergesort snil = onil\nmergesort (x ∙ snil) = :< {x = x} lebx onil\nmergesort (x ∙ (y ∙ xs)) \n with deal xs\n... | (ys , zs) = merge (mergesort (x ∙ ys)) (mergesort (y ∙ zs))\n", "meta": {"hexsha": "bf5619ee91afa276edd084c120ef7bcc36b5682f", "size": 1069, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Mergesort/Impl1.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.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.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.8918918919, "max_line_length": 75, "alphanum_fraction": 0.5481758653, "num_tokens": 444, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9465966717067253, "lm_q2_score": 0.8459424411924673, "lm_q1q2_score": 0.8007662992882518}} {"text": "\nmodule Parity where\n\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ -> ℕ\n\ninfixl 60 _+_\ninfixl 70 _*_\n\n_+_ : ℕ -> ℕ -> ℕ\nn + zero = n\nn + suc m = suc (n + m)\n\n_*_ : ℕ -> ℕ -> ℕ\nn * zero = zero\nn * suc m = n * m + n\n\n{-# BUILTIN NATURAL ℕ #-}\n{-# BUILTIN ZERO zero #-}\n{-# BUILTIN SUC suc #-}\n{-# BUILTIN NATPLUS _+_ #-}\n{-# BUILTIN NATTIMES _*_ #-}\n\ndata Parity : ℕ -> Set where\n itsEven : (k : ℕ) -> Parity (2 * k)\n itsOdd : (k : ℕ) -> Parity (2 * k + 1)\n\nparity : (n : ℕ) -> Parity n\nparity zero = itsEven zero\nparity (suc n) with parity n\nparity (suc .(2 * k)) | itsEven k = itsOdd k\nparity (suc .(2 * k + 1)) | itsOdd k = itsEven (k + 1)\n\nhalf : ℕ -> ℕ\nhalf n with parity n\nhalf .(2 * k) | itsEven k = k\nhalf .(2 * k + 1) | itsOdd k = k\n\n", "meta": {"hexsha": "a7dd752e73fd8046408e3eaac494913ee475d5c5", "size": 782, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/succeed/Parity.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/Parity.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/Parity.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": 19.55, "max_line_length": 55, "alphanum_fraction": 0.5051150895, "num_tokens": 304, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9559813513911655, "lm_q2_score": 0.8376199673867852, "lm_q1q2_score": 0.8007490683746429}} {"text": "{-# OPTIONS --sized-types #-}\nmodule SNat.Sum where\n\nopen import Relation.Binary.PropositionalEquality\nopen import Size\nopen import SNat\n\n+-assoc-succ : (m n : SNat) → m + succ n ≡ succ (m + n)\n+-assoc-succ zero n = refl\n+-assoc-succ (succ m) n rewrite +-assoc-succ m n = refl\n\n+-assoc-right : (a b c : SNat) → (a + b) + c ≡ a + (b + c)\n+-assoc-right zero b c = refl \n+-assoc-right (succ n) b c rewrite +-assoc-right n b c = refl\n\n+-assoc-left : (a b c : SNat) → a + (b + c) ≡ (a + b) + c\n+-assoc-left zero b c = refl \n+-assoc-left (succ n) b c rewrite +-assoc-left n b c = refl\n\n+-id : (n : SNat) → n + zero ≡ n\n+-id zero = refl\n+-id (succ n) rewrite +-id n = refl\n\n+-comm : (m n : SNat) → m + n ≡ n + m\n+-comm zero n rewrite +-id n = refl\n+-comm (succ m) n rewrite +-assoc-succ n m | +-comm m n = refl\n", "meta": {"hexsha": "5dbde2af4dfee7dd7d33ff317d35aa333c7ff4bf", "size": 805, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/SNat/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/SNat/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/SNat/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": 29.8148148148, "max_line_length": 62, "alphanum_fraction": 0.5875776398, "num_tokens": 289, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9532750466836961, "lm_q2_score": 0.8397339736884712, "lm_q1q2_score": 0.8004974429697631}} {"text": "module Nat.Class where\n\nopen import Relation.Binary.PropositionalEquality\nopen ≡-Reasoning\n\nrecord Nat (ℕ : Set) : Set₁ where\n field\n zero : ℕ\n succ : ℕ → ℕ\n\n ind : (P : ℕ → Set) → P zero → (∀ {k} → P k → P (succ k)) → ∀ n → P n\n\n _+_ : ℕ → ℕ → ℕ\n +-zero : ∀ {n} → zero + n ≡ n\n +-succ : ∀ {m n} → succ m + n ≡ m + succ n\n\nmodule _ {ℕ : Set} {{nn : Nat ℕ}} where\n open Nat nn\n\n +-succˡ : {m n : ℕ} → succ m + n ≡ succ (m + n)\n +-succˡ {m} {n} = ind Succˡ Succˡ-zero Succˡ-succ m n\n where\n Succˡ : ℕ → Set\n Succˡ m′ = ∀ n′ → succ m′ + n′ ≡ succ (m′ + n′)\n\n Succˡ-zero : Succˡ zero\n Succˡ-zero n′ =\n begin\n succ zero + n′\n ≡⟨ +-succ ⟩\n zero + succ n′\n ≡⟨ +-zero ⟩\n succ n′\n ≡⟨ cong succ (sym +-zero) ⟩\n succ (zero + n′)\n ∎\n\n Succˡ-succ : ∀ {m′} → Succˡ m′ → Succˡ (succ m′)\n Succˡ-succ {m′} ih n′ =\n begin\n succ (succ m′) + n′\n ≡⟨ +-succ ⟩\n succ m′ + succ n′\n ≡⟨ ih (succ n′) ⟩\n succ (m′ + succ n′)\n ≡⟨ cong succ (sym +-succ) ⟩\n succ (succ m′ + n′)\n ∎\n\n +-succʳ : {m n : ℕ} → m + succ n ≡ succ (m + n)\n +-succʳ = trans (sym +-succ) +-succˡ\n\n +-assoc : {m n p : ℕ} → (m + n) + p ≡ m + (n + p)\n +-assoc {m} {n} {p} = ind Assoc Assoc-zero Assoc-succ m\n where\n Assoc : ℕ → Set\n Assoc k = (k + n) + p ≡ k + (n + p)\n\n Assoc-zero : Assoc zero\n Assoc-zero =\n begin\n (zero + n) + p\n ≡⟨ cong (_+ p) +-zero ⟩\n n + p\n ≡⟨ sym +-zero ⟩\n zero + (n + p)\n ∎\n\n Assoc-succ : ∀ {k} → Assoc k → Assoc (succ k)\n Assoc-succ {k} ih =\n begin\n (succ k + n) + p\n ≡⟨ cong (_+ p) +-succˡ ⟩\n succ (k + n) + p\n ≡⟨ +-succˡ ⟩\n succ ((k + n) + p)\n ≡⟨ cong succ ih ⟩\n succ (k + (n + p))\n ≡⟨ sym +-succˡ ⟩\n succ k + (n + p)\n ∎\n", "meta": {"hexsha": "3de5919dcb02720d3ef7d172e70d92b665f47b95", "size": 1965, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Nat/Class.agda", "max_stars_repo_name": "iblech/agda-quotients", "max_stars_repo_head_hexsha": "1b51e83acf193a556a61d44a4585a6467a383fa3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-04-29T13:10:27.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-29T13:10:27.000Z", "max_issues_repo_path": "src/Nat/Class.agda", "max_issues_repo_name": "iblech/agda-quotients", "max_issues_repo_head_hexsha": "1b51e83acf193a556a61d44a4585a6467a383fa3", "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/Nat/Class.agda", "max_forks_repo_name": "iblech/agda-quotients", "max_forks_repo_head_hexsha": "1b51e83acf193a556a61d44a4585a6467a383fa3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-04-28T12:49:47.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-28T12:49:47.000Z", "avg_line_length": 23.9634146341, "max_line_length": 73, "alphanum_fraction": 0.3989821883, "num_tokens": 783, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9458012671214071, "lm_q2_score": 0.8459424334245618, "lm_q1q2_score": 0.8000934254447171}}