Skip to content

Clingo programs with python scripts hang with Python3.12 #486

@yangdinglou

Description

@yangdinglou

Hi, I was facing a problem that part of my clingo codes suddenly fail to run (with infinite grounding). I thought it might be related to the upgrade to version 5.7, but it is not. Here is an example of the program which is executable in both Clingo 5.6.2 and 5.7 with Python 3.9 or 3.11, but not 3.12.

#show body_chain/3.
max_arg(6).

#script (python)

from itertools import permutations
from clingo.symbol import Tuple_, Number
def mk_tuple(xs):
    return Tuple_([Number(x) for x in xs])
def pyvars(arity, max_vars):
    for x in permutations(range(max_vars.number),arity.number):
        yield mk_tuple(x)

#end.


input(0).
input(1).
input(2).

func(if).
func(car).
func(cdr).
func(cons).
func(nulllist).

arity(if, 3).
arity(car, 1).
arity(cdr, 1).
arity(cons, 2).
arity(nulllist, 1).

vars(Func,@pyvars(A,MaxVars)):-
    max_arg(MaxVars),
    arity(Func, A).

4 {body_chain(Func, Args, Outarg) : func(Func), vars(Func, Args), Outarg = 1..8, not input(Outarg)} 5.

My device is Macbook with M1pro. If I remembered correctly, calling the file by Python-API (instead of clingo command line directly) works with 5.7.1+3.12. The issue was found when using Python installed by homebrew, and reappears in conda.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions