Is it idiomatic to assert facts based on input data?

For parsing DCG is my first sword of choice.

Also Regular Expressions can be done with SWI-Prolog.
regex
library(pcre)


Why would it be wrong? If you read

Data stored this way notably does not change on backtracking . Typically it is a bad idea to use any of the predicates in this section for realising global variables that can be assigned to. Typically, first consider representing data processed by your program as terms passed around as predicate arguments

then to quote Pablo Picasso

“Learn the rules like a pro, so you can break them like an artist.”

I use assert with library(persistency) as often as I would use SQL in another language. Then as noted

If you need to reason over multiple solutions to a goal, consider findall/3, aggregate/3 and related predicates.

In the following<=> is just giving an example when using SWI-Prolog versus more traditional programming languages.

Another way to think of it is that you keep the data in a data store (library(persistency) <=> SQL database) then you select the needed data (findall and such <=> SQL) and pass the data around as needed (accumulator <=> collection)


I keep a more extensive list of such here.


HTH