The Christian and Traditional Family propaganda of Prolog examples

something is a person if it is either Adam or Eve, or if it has a mother. We can express this in a single rule as follows:

person(X) :- (X=adam; X=eve; mother(X, Y)).

43 points · 13 comments · view on lemmy.world

13 Comments

bleistift2@sopuli.xyz · 13 pts · 1y (2 replies)

I learned Prolog in university and it was instructive. But has anyone ever professionally used it?

stinky@redlemmy.com · 5 pts · 1y

no

souperk@reddthat.com · 3 pts · 1y

DataLog is used to verify smart contracts. I don't know any specific examples of prolog used in the industry, though I am sure there are a few. Probably, there are expert systems implemented with prolog that are still used.

Logic programming in general has a few usages, the unification algorithm is used for pretty much every type system. Also, it is quite good for verification systems. For example, I know some symbolic execution systems implemented in OCaml.

DoctorNope@lemmy.one · 7 pts · 1y
sushibowl@feddit.nl · 7 pts · 1y (2 replies)

Can someone explain where the Y comes from? Is this something like, there exists a mother relation between this X and some Y?

sebastiancarlos@lemmy.sdf.org · 8 pts · 1y

mother can be used in several ways. If both X and Y variables are uninitialized, then it looks for all mother relationships. If one of them is initialized, it looks for matching relationships. If both are initialized, it returns true if such a relationship exists.

Ephera@lemmy.ml · 4 pts · 1y

Yeah, the Y is a wildcard in that position. Typically, you would write it as an underscore, primarily because most Prolog compilers will warn about unknown variables, since those could also just be a typo of an existing variable.

xmunk@sh.itjust.works · 5 pts · 1y (5 replies)

I'll admit I don't speak prolog but doesn't this definition lack a recursive case to ensure that the mother is either Eve or a descendent of Eve? And there should probably be a father case in there as well?

sebastiancarlos@lemmy.sdf.org · 9 pts · 1y (1 reply)

Depends on how you want to define your domain knowledge.

The thing you need to define for sure is the predicate mother/2 (Which has arity 2, or in other words, two arguments). From then on, multiple options are available:

  1. Take mother(X, Y) as an "axiom", and define mother terms for all elements:
mother(abel, eve).
mother(isaac, sarah).
  1. Derive mother(X, Y) from female(X) and parent(X, Y) terms.
mother(X, Y) :- 
  parent(X, Y), 
  female(Y).
  1. Smash the institutional gender power structures and define only parent/2 terms instead of mother/2 and father/2.
silasmariner@programming.dev · 7 pts · 1y

I never saw such a potent combination of gender politics and prolog

bleistift2@sopuli.xyz · 5 pts · 1y (2 replies)

doesn’t this definition lack a recursive case to ensure that the mother is either Eve or a descendent of Eve

We don’t see the definition of mother. It might already encode that Y is a person.

And there should probably be a father case in there as well?

While every person does also have a father, it’s completely redundant, since being a person can fully be described by [Edit: being having] a mother (or being Adam or Eve).

DrDeadCrash@programming.dev · 1 pts · 1y (1 reply)

since being a person can fully be described by being a mother

Can you explain how this is?

bleistift2@sopuli.xyz · 1 pts · 1y

Thanks for catching that. I fixed my comment.