~ubuntu-branches/ubuntu/wily/agda/wily-proposed

« back to all changes in this revision

Viewing changes to examples/outdated-and-incorrect/clowns/Equality.agda

  • Committer: Package Import Robot
  • Author(s): Iain Lane
  • Date: 2014-08-05 06:38:12 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20140805063812-io8e77niomivhd49
Tags: 2.4.0.2-1
* [6e140ac] Imported Upstream version 2.4.0.2
* [2049fc8] Update Build-Depends to match control
* [93dc4d4] Install the new primitives
* [e48f40f] Fix typo dev→doc

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
module Equality where
3
 
 
4
 
  postulate _==_ : {A : Set} -> A -> A -> Set
5
 
            refl : {A : Set}{x : A} -> x == x
6
 
 
7
 
  {-# BUILTIN EQUAL _==_ #-}
8
 
  {-# BUILTIN REFL  refl #-}
9
 
 
10
 
  private
11
 
   primitive
12
 
    primEqElim : {A : Set}(x : A)(C : (y : A) -> x == y -> Set) ->
13
 
                 C x refl -> (y : A) -> (p : x == y) -> C y p
14
 
 
15
 
  elim-== = \{A : Set} -> primEqElim {A}
16
 
 
17
 
  subst : {A : Set}(C : A -> Set){x y : A} -> x == y -> C y -> C x
18
 
  subst C {x}{y} p Cy = elim-== x (\z _ -> C z -> C x) (\Cx -> Cx) y p Cy
19
 
 
20
 
  sym : {A : Set}{x y : A} -> x == y -> y == x
21
 
  sym {x = x}{y = y} p = subst (\z -> y == z) p refl
22
 
 
23
 
  trans : {A : Set}{x y z : A} -> x == y -> y == z -> x == z
24
 
  trans {x = x}{y = y}{z = z} xy yz = subst (\w -> w == z) xy yz
25
 
 
26
 
  cong : {A B : Set}{x y : A}(f : A -> B) -> x == y -> f x == f y
27
 
  cong {y = y} f xy = subst (\ ∙ -> f ∙ == f y) xy refl
28