Skip to content

Commit dca10a8

Browse files
authored
Merge pull request #367 from LPCIC/fix-implcut
fix =!=> in presence of pi
2 parents c03b9d1 + ea8796d commit dca10a8

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

CHANGES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Unreleased
2+
3+
- Compiler:
4+
- Fix `=!=>` that was adding a head cut, rather than a tail cut, in some
5+
cases
6+
17
# v3.3.1 (September 2025)
28

39
Requires Menhir 20211230 and OCaml 4.13 or above.

src/compiler/compiler.ml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1597,7 +1597,6 @@ end = struct
15971597
match it with
15981598
| Impl(R2L,lb,hd,hyp) -> Some (mk @@ Impl(R2L,lb,hd,mk @@ append_list_or_conj hyp))
15991599
| App({ scope = Scope.Global { resolved_to = s } },[]) when SymbolResolver.is_resolved_to types s nil -> Some orig
1600-
| App({ scope = Scope.Global { resolved_to = s } },[]) when SymbolResolver.is_resolved_to types s nil -> Some orig
16011600
| App({ scope = Scope.Global { resolved_to = s } } as hd,[x;xs]) when SymbolResolver.is_resolved_to types s cons ->
16021601
begin match try_add_tail_cut ~types x, try_add_tail_cut ~types xs with
16031602
| Some x, Some xs -> Some (mk @@ App(hd,[x;xs]))
@@ -1608,6 +1607,11 @@ end = struct
16081607
if List.for_all Option.is_some xs then
16091608
Some (mk @@ App(hd,List.map Option.get xs))
16101609
else None
1610+
| App({ scope = Scope.Global { resolved_to = s } } as hd,[{ it = Lam(v,ty,t) } as lam]) when SymbolResolver.is_resolved_to types s pi ->
1611+
begin match try_add_tail_cut ~types t with
1612+
| Some x -> Some (mk @@ App(hd,[{lam with it = Lam(v,ty,x)}]))
1613+
| _ -> None
1614+
end
16111615
| App _-> Some (mk @@ Impl(R2L,loc,orig,mk @@ App(const_of_symb ~types cut ~loc,[])))
16121616
| _ -> None
16131617

tests/sources/implbang.elpi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pred p o:int.
2+
3+
main :- (pi x\ p x :- x = 1) =!=> (pi x\ p x :- x = 2) =!=> std.findall (p 1) [ _ ].

tests/suite/elpi_specific.ml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,4 +520,10 @@ let () = declare "tc_ambiguous"
520520
let () = declare "variadic"
521521
~source_elpi:"variadic.elpi"
522522
~description:"variadic"
523-
()
523+
()
524+
525+
let () = declare "implbang"
526+
~source_elpi:"implbang.elpi"
527+
~description:"tail cut =!=>"
528+
~expectation:Success
529+
()

0 commit comments

Comments
 (0)