std:Certificate

lib/Certificate.omg

lib/Certificate.omg47 lines
1-- Proof-producing computation. A candidate supplies an equality obligation
2-- and a kernel-checked function turning its evidence into the desired fact.
3-- No Boolean assertion or trusted validator is promoted to a proof.
4let E = std:Equal
5let Certificate =
6      \{la lp : Level} (P : Type lp) ->
7        exists (A : Type la) (left : A) (right : A) * left === right -> P
8let make =
9      \{la lp : Level} {A : Type la} {P : Type lp} (left right : A) (build : left === right -> P) ->
10        ((A, (left, (right, build))) : Certificate @la P)
11let Valid =
12      \{la lp : Level} {P : Type lp} (candidate : Certificate @la P) ->
13        candidate.2.1 === candidate.2.2.1
14let prove =
15      \{la lp : Level} {P : Type lp} (candidate : Certificate @la P) {valid : Valid candidate} ->
16        candidate.2.2.2 valid
17let known = \{l : Level} {P : Type l} (proof : P) -> make {=} {=} (\_ -> proof)
18let map =
19      \{la lp lq : Level}
20       {P : Type lp}
21       {Q : Type lq}
22       (f : P -> Q)
23       (candidate : Certificate @la P) ->
24        make candidate.2.1 candidate.2.2.1 (\proof -> f (candidate.2.2.2 proof))
25let both =
26      \{la lb lp lq : Level}
27       {P : Type lp}
28       {Q : Type lq}
29       (left : Certificate @la P)
30       (right : Certificate @lb Q) ->
31        make
32          (left.2.1, right.2.1)
33          (left.2.2.1, right.2.2.1)
34          (\proof ->
35             (left.2.2.2 (E.cong (\(pair : left.1 * right.1) -> pair.1) proof),
36             right.2.2.2 (E.cong (\(pair : left.1 * right.1) -> pair.2) proof)))
37let label =
38      \{la lp : Level} {P : Type lp} (message : Text) (candidate : Certificate @la P) ->
39        make
40          { message, obligation = candidate.2.1 }
41          { message, obligation = candidate.2.2.1 }
42          (\proof ->
43             candidate.2.2.2
44               (E.cong
45                  (\(value : { message : Text, obligation : candidate.1 }) -> value.obligation)
46                  proof))
47in  { Certificate, make, Valid, prove, known, map, both, label }
Your result
Complete file: lib/Certificate.omg · with imports