Debian Codegraph @

apps/cs/README.md

raw symbols SCIP
1 # Canonical solution
2
3 The `canonical_solution` app enables to program Coq canonical structure solutions in Elpi.
4
5 This app is experimental.
6
7 ## The cs predicate
8
9 The `cs` predicate lives in the database `cs.db`
10
11 ```elpi
12 % predicate [cs Ctx Lhs Rhs] used to unify Lhs with Rhs, with
13 % - [Ctx] is the context
14 % - [Lhs] and [Rhs] are the terms to unify
15 :index (0 6 6)
16 pred cs i:goal-ctx, o:term, o:term.
17 ```
18
19 By addings rules for this predicate one can recover from a CS instance search failure
20 error, that is when `Lhs` and `Rhs` are not unifiable using a canonical structure registered
21 by Coq.
22
23 ## Simple example of canonical solution
24
25 This example declares a structure `S` with a projection `sort` and declares
26 a canonical solution for `nat` in `S`.
27
28 ```coq
29 From elpi.apps Require Import cs.
30 From Coq Require Import Bool.
31
32 Structure S : Type := mkS { sort :> Type }.
33
34 Elpi Accumulate cs.db lp:{{
35
36 cs _ {{ sort }} {{ nat }} {{ mkS nat }}.
37
38 }}.
39
40 Check eq_refl _ : (sort _) = nat.
41 ```