Guest User

Untitled

a guest
Nov 22nd, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. data ℕ : Set where
  2. zero : ℕ
  3. suc : ℕ → ℕ
  4.  
  5. _+_ : ℕ → ℕ → ℕ
  6. zero + n = n
  7. (suc n) + m = suc (n + m)
  8.  
  9. data _≡_ {A : Set}(x : A) : A → Set where
  10. refl : x ≡ x
  11.  
  12. data _≢_ : ℕ → ℕ → Set where
  13. _<_ : (n m : ℕ) → n ≢ (n + (suc m))
  14. _>_ : (m n : ℕ) → (n + (suc m)) ≢ n
  15.  
  16. ----------------------------------------
  17.  
  18. data List (A : Set) : Set where
  19. [] : List A
  20. _::_ : A → List A → List A
  21.  
  22. [_] : {A : Set} → A → List A
  23. [ x ] = x :: []
  24.  
  25.  
  26. data Project (a : ℕ) : List ℕ → List ℕ → Set where
  27. empty : Project a [] []
  28.  
  29. distinct : ∀{xs ys}
  30. → (n : ℕ)
  31. → Project a xs ys
  32. → a ≢ n
  33. → Project a (n :: xs) (n :: ys)
  34.  
  35. same : ∀{xs ys}
  36. → (n : ℕ)
  37. → Project a xs ys
  38. → a ≡ n
  39. → Project a (n :: xs) ys
  40.  
  41. ----------------------------------------
  42.  
  43. data _⊎_ (A B : Set) : Set where
  44. left : A → A ⊎ B
  45. right : B → A ⊎ B
  46.  
  47. extend : (n m : ℕ)
  48. → (n ≡ m) ⊎ (n ≢ m)
  49. → ((suc n) ≡ (suc m)) ⊎ ((suc n) ≢ (suc m))
  50. extend n .n (left refl) = left refl
  51. extend n .(n + suc m) (right (.n < m)) = right (suc n < m)
  52. extend .(m + suc m₁) m (right (m₁ > .m)) = right (m₁ > suc m)
  53.  
  54. total : (n m : ℕ) → (n ≡ m) ⊎ (n ≢ m)
  55. total zero zero = left refl
  56. total zero (suc m) = right (zero < m)
  57. total (suc n) zero = right (n > zero)
  58. total (suc n) (suc m) = extend n m (total n m)
  59.  
  60. ----------------------------------------
  61.  
  62.  
  63. _∖_==_ : List ℕ → ℕ → List ℕ → Set
  64. xs ∖ x == ys = Project x xs ys
  65.  
  66.  
  67. noop : (x : ℕ) → [ x ] ∖ x == []
  68. noop = λ x → same x empty refl
  69.  
  70.  
  71. data Foo : List ℕ → Set where
  72. empty : Foo []
  73. add : ∀{xs} → (x : ℕ) → Foo xs → Foo (x :: xs)
  74. delete : ∀{xs ys}
  75. → (x : ℕ)
  76. → Foo xs
  77. → {_ : xs ∖ x == ys}
  78. → Foo ys
  79.  
  80. -- Agda can fill the holes with Auto(), but can't compute the proofs implicitly?
  81.  
  82. single : (n : ℕ) → Foo []
  83. single n = delete n (add n empty) {noop n}
  84.  
  85. double : (n m : ℕ) → Foo []
  86. double n m with (total m n)
  87. ... | left x = delete n (add n empty) {?}
  88. ... | right x = delete n (delete m (add n (add m empty)) {?}) {?}
Add Comment
Please, Sign In to add comment