Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9295989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T21:44:12+00:00 2026-06-18T21:44:12+00:00

I have this problem in Common Lisp. I need to manipulate existential variables introducing

  • 0

I have this problem in Common Lisp.
I need to manipulate existential variables introducing the rule of skolemization.

For example I need to buid a function which turns
(exist ?x (p ?x)) in (p sk00042).

sk00042 is a variable. Note that this function becomes a bit harder when universal variables are involved.

For example, the function given the expression (forall ?y (exist ?x (p ?x ?y)) turns it into (forall ?y (p (sf666 ?y) ?y).
The idea is that the existencial variable tells me that there is something that satisfies the formulae. If this existential quantifier is the outer , then this quantifier does not depend on anything and the variable ?x in the first example above should be replaced with the constant skoo42 which is generated by this function :
(defun skolem-variable () (gentemp "SV-")).

If the harder (second) case takes place and there’s a universal quantifier “out” of the existential one, then that something that exists depends on variables universally quantified, meaning that the function must take care of this dependence and the universal variables become incorporated in the constant, like in the example :

(forall ?y (exist ?x (p ?x ?y)) —-> (forall ?y (p (sf666 ?y) ?y)
For this also serves the function:

(defun skolem-function* (&rest args) (cons (gentemp "SF-") args))
(defun skolem-function (args) (apply #'skolem-function* args))

Here are some examples to get more familiar with the idea :

(skolemize '(forall ?y (exist ?x (p ?x ?y))))
;=> (forall ?y (P (SF-1 ?Y) ?Y))
(skolemize '(exist ?y (forall ?x (p ?x ?y))))
;=> (for all ?x (P ?X SV-2)
(skolemize '(exist ?y (and (p ?x) (f ?y))))
;=> (AND (P ?X) (F SV-4))
(skolemize '(forall ?x (exist ?y (and (p ?x) (f ?y)))))
;=> (forall ?x (AND (P ?X) (F (SF-5 ?X)))

I need to build the function (using skolem-variable and skolem-function above) that given
an expression controls if the outer is exist, then replaces the variable with skolem-variable. If the outer is a forall followed by and exist, the function does what i’ve explained above.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T21:44:13+00:00Added an answer on June 18, 2026 at 9:44 pm

    I just skimmed the Wikipedia article on the skolem normal form, but if I get it right, every existential becomes a skolem function invocation with the bound universals as arguments (or a skolem constant if no universals are in scope). One simple approach would be having a stack of bound universals while walking the expression tree recursively:

    (defun skolemize (form &optional (universals nil))
      (cond ((null form) nil)                                  ; subtree done
            ((consp (car form))                                ; walk branches
             (cons (skolemize (car form) universals)
                   (skolemize (cdr form) universals)))
            ((eq (car form) 'forall)                           ; universal binding
             (list 'forall
                   (cadr form)
                   (skolemize (caddr form)                     ; skolemize body
                              (cons (cadr form) universals)))) ; new var on the stack
            ((eq (car form) 'exist)                            ; existential binding
             (subst (if universals                             ; substitute variables
                        (cons (gentemp "SF-") universals)      ; with skolem function
                        (gentemp "SV-"))                       ; with skolem constant
                    (cadr form)
                    (skolemize (caddr form) universals)))
            (t (cons (car form) (skolemize (cdr form) universals)))))
    

    Note that this is just to get you started – I neither delved into this topic, nor is this really tested or optimized for performance or elegance. Also, it will accept malformed input, e.g. (skolemize '(forall (foo bar))).

    Your examples:

    CL-USER> (skolemize '(exist ?x (p ?x)))
    (P SV-16)
    CL-USER> (skolemize '(forall ?y (exist ?x (p ?x ?y))))
    (FORALL ?Y (P (SF-17 ?Y) ?Y))
    CL-USER> (skolemize '(exist ?y (forall ?x (p ?x ?y))))
    (FORALL ?X (P ?X SV-18))
    CL-USER> (skolemize '(exist ?y (and (p ?x) (f ?y))))
    (AND (P ?X) (F SV-19))
    CL-USER> (skolemize '(forall ?x (exist ?y (and (p ?x) (f ?y)))))
    (FORALL ?X (AND (P ?X) (F (SF-20 ?X))))
    

    Testing a more complex expression:

    CL-USER> (skolemize '(exist ?a
                          (forall ?b
                           (exist ?c
                            (forall ?d
                             (exist ?e (and (or (and (f ?a) (g ?b))
                                                (and (f ?c) (g ?d)))
                                            (or (and (f ?c) (g ?e))
                                                (and (f ?d) (g ?e))))))))))
    (FORALL ?B
      (FORALL ?D (AND (OR (AND (F SV-15) (G ?B))
                          (AND (F (SF-16 ?B)) (G ?D)))
                      (OR (AND (F (SF-16 ?B)) (G (SF-17 ?D ?B)))
                          (AND (F ?D) (G (SF-17 ?D ?B)))))))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a fairly common problem to which I have yet to find an
This must be a common problem with a common solution. I have a lot
This is a slightly original variation on a common problem. I have a fairly
I'm implementing an evolutionary algorithm in Common Lisp (CLISP) and I have a problem.
This is a common problem for me. I have a solution that contains a
This seems to be a fairly common problem, but the solutions that I have
I know this is a common problem, so I need an explanation so I
I have a problem with common lisp. I want to pass a string to
I have read this problem Find the most common entry in an array and
I have this problem: I want to generate a new source code file from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.