Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exporting refined signatures #1031

Open
gabrielhdt opened this issue Jan 24, 2024 · 1 comment
Open

Exporting refined signatures #1031

gabrielhdt opened this issue Jan 24, 2024 · 1 comment

Comments

@gabrielhdt
Copy link
Member

Since we have coercions available, I'd like to see what the theory looks like after the coercions have been inserted. Here follows a practical use case.

Use case: inserting explicit introduction of implication

Assume one has an encoding of (a fragment of) first order logic with the elimination of the implication to the product, like this

constant symbol I: TYPE;
constant symbol Prop: TYPE;
symbol Prf (_: Prop): TYPE;

symbol imp (_: Prop) (_: Prop): Prop;

rule Prf (imp $x $y) ↪ Prf $x → Prf $y;

symbol p-imp-p (p: Prop): Prf (imp p p) ≔ λ x : (Prf p), x;

There are various reasons one would like to avoid that rewrite rule and use the explicit elimination of implication with the constant
constant symbol imp-i (p: Prop) (q: Prop): (Prf p → Prf q) → Prf (imp p q);. Therefore one may replace the previous theory with

constant symbol I: TYPE;
constant symbol Prop: TYPE;
symbol Prf (_: Prop): TYPE;

symbol imp (_: Prop) (_: Prop): Prop;

symbol imp-i (p: Prop) (q: Prop): (Prf p → Prf q) → Prf (imp p q);

but in that case the proof of p-imp-p doesn't type check anymore.

With coercions, we can recover well-typedness of p-imp-p without modifying the proof. For that, it's enough to change the theory to

constant symbol I: TYPE;
constant symbol Prop: TYPE;
symbol Prf (_: Prop): TYPE;

symbol imp (_: Prop) (_: Prop): Prop;

coerce_rule coerce (Π(a:$A),$B.[a]) (Π(a:$A),$C.[a]) (λ(a:$A),$e.[a])
          ↪ λ(a:$A), (coerce $B.[a] $C.[a] $e.[a]);
constant symbol imp-i (p: Prop) (q: Prop): (Prf p → Prf q) → Prf (imp p q);
coerce_rule coerce (Prf $p → Prf $p) (Prf (imp $p $p)) (λ x: Prf $p, x)
          ↪ imp-i $p $p (λ x: Prf $p, x);

Following that, one may be interested to see the new proof. It can be seen calling lambdapi with option --debug i where one can spot the line

Coerced [λ p x, x : Π p: Prop, Prf p → Prf p <: λ a, imp-i a a (λ x, x) : Π p: Prop, Prf (imp p p)]

but lambdapi export -o lp only exports the initial theory.

@fblanqui
Copy link
Member

fblanqui commented Mar 1, 2024

-o lp calls Pretty, which works on p_terms. We should rename this mode raw_lp, and a add a new mode lp working on terms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants