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

« back to all changes in this revision

Viewing changes to benchmark/Syntacticosmos/Pr.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
 
module Pr where
2
 
 
3
 
data FF : Set where
4
 
 
5
 
magic : {X : Set} -> FF -> X
6
 
magic ()
7
 
 
8
 
record TT : Set where
9
 
 
10
 
data Id {S : Set}(s : S) : S -> Set where
11
 
  refl : Id s s
12
 
 
13
 
data Pr : Set1 where
14
 
  tt : Pr
15
 
  ff : Pr
16
 
  _/\_ : Pr -> Pr -> Pr
17
 
  all : (S : Set) -> (S -> Pr) -> Pr
18
 
  _eq_ : {S : Set} -> S -> S -> Pr
19
 
 
20
 
record Sig (S : Set)(T : S -> Set) : Set where
21
 
  field
22
 
    fst : S
23
 
    snd : T fst
24
 
 
25
 
open module Sig' {S : Set}{T : S -> Set} = Sig {S}{T} public
26
 
 
27
 
_,_ : {S : Set}{T : S -> Set}(s : S) -> T s -> Sig S T
28
 
s , t = record {fst = s ; snd = t}
29
 
 
30
 
[|_|] : Pr -> Set
31
 
[| tt |] = TT
32
 
[| ff |] = FF
33
 
[| P /\ Q |] = Sig [| P |] \_ -> [| Q |]
34
 
[| all S P |] = (x : S) -> [| P x |]
35
 
[| a eq b |] = Id a b
36
 
 
37
 
_=>_ : Pr -> Pr -> Pr
38
 
P => Q = all [| P |] \_ -> Q
39
 
 
40
 
∼ : Pr -> Pr
41
 
∼ P = P => ff
42
 
 
43
 
data Decision (P : Pr) : Set where
44
 
  yes  : [| P |]   -> Decision P
45
 
  no   : [| ∼ P |] -> Decision P
46
 
 
47
 
data Bool : Set where
48
 
  true : Bool
49
 
  false : Bool
50
 
 
51
 
So : Bool -> Pr
52
 
So true = tt
53
 
So false = ff
54
 
 
55
 
not : Bool -> Bool
56
 
not true = false
57
 
not false = true
58
 
 
59
 
so : (b : Bool) -> Decision (So b)
60
 
so true = yes _
61
 
so false = no magic
62
 
 
63
 
potahto : (b : Bool) -> [| So (not b) => ∼ (So b) |]
64
 
potahto true () _
65
 
potahto false _ ()
66
 
 
67
 
PEx : (P : Pr) -> ([| P |] -> Pr) -> Pr
68
 
PEx P Q = P /\ all [| P |] Q
69
 
 
70
 
Pow : Set -> Set1
71
 
Pow X = X -> Pr
72
 
 
73
 
_==>_ : {X : Set} -> Pow X -> Pow X -> Pr
74
 
_==>_ {X} P Q = all X \x -> P x => Q x
75
 
 
76
 
Decidable : {X : Set}(P : Pow X) -> Set
77
 
Decidable {X} P = (x : X) -> Decision (P x)
78
 
 
79
 
data _:-_ (S : Set)(P : Pow S) : Set where
80
 
  [_/_] : (s : S) -> [| P s |] -> S :- P
81
 
 
82
 
wit : {S : Set}{P : S -> Pr} -> S :- P -> S
83
 
wit [ s / p ] = s
84
 
 
85
 
cert : {S : Set}{P : S -> Pr}(sp : S :- P) -> [| P (wit sp) |]
86
 
cert [ s / p ] = p
87
 
 
88
 
_??_ : {S : Set}{P : S -> Pr}
89
 
      (sp : S :- P){M : Set} ->
90
 
      ((s : S)(p : [| P s |]) -> M) ->
91
 
      M
92
 
sp ?? m = m (wit sp) (cert sp)