Skip to content

Commit

Permalink
Merge pull request #82 from proux01/lra_cast
Browse files Browse the repository at this point in the history
Handle casts in lra parser
  • Loading branch information
pi8027 authored Apr 12, 2023
2 parents edc8e5e + ec0fc7e commit a2f292b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions examples/lra_examples.v
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ Variable F : realFieldType.

Implicit Types x y : F.

Lemma test_cast : 0 <= 2 :> F.
Proof.
lra.
Qed.

Example test_div x y : x / 2 + y <= 3 -> x + y / 2 <= 3 -> x + y <= 4.
Proof.
lra.
Qed.

Lemma test_lt x y :
x + 2%:R * y < 3%:R -> 2%:R * x + y <= 3%:R -> x + y < 2%:R.
Proof.
Expand Down Expand Up @@ -289,3 +299,11 @@ lra.
Qed.

End TestsCoq.

Example test_abstract_rmorphism (R : realDomainType) (f : {rmorphism R -> R})
(x y : R) : f y >= 0 -> f x + 2 * f (y + 1) <= f (3 * y + x) + 2.
Proof. lra. Qed.

Example test_concrete_rmorphism (R : realFieldType) (x y : rat) :
ratr y >= 0 :> R -> ratr x + 2 * ratr (y + 1) <= ratr (3 * y + x) + 2 :> R.
Proof. lra. Qed.
3 changes: 3 additions & 0 deletions theories/lra.elpi
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ quote.int {{ Negz lp:N }} {{ large_int_Z (Zneg lp:P) }} (coqZneg P) :-
% - [VM] is a variable map, that is a list of terms of type [R].
pred quote.expr i:bool, i:term, i:option term, i:term, i:option term,
i:(term -> term), i:term, o:term, o:term, o:list term.
% _ : _
quote.expr ff R F TR TUR Morph {{ lp:E : _ }} OutM Out VM :- !,
quote.expr ff R F TR TUR Morph E OutM Out VM.
% 0%R
quote.expr _ R _ _ _ _ {{ @GRing.zero lp:U }}
{{ @R0 lp:R }} {{ PEc (Qmake 0 1) }} _ :-
Expand Down

0 comments on commit a2f292b

Please sign in to comment.