Re: [racket-users] recursive definition of a PROPOSITION

2016-02-18 Thread Daniel Prager
Hi Aysenur

Here are some hints:

   - It's simpler to work with symbols than strings in this sort of
   problem. E.g.

(define ops '(↔ → ∧ ⊕ ∨ ¬))
(define propositions '(P Q R X Y Z))


   - It helps to start by solving a simpler problem. Can you write a
   function (random-simple-expression) to randomly produce expressions with a
   single operation, using random propositions (no recursion required)? Sample
   output:

'(¬ P)
'(Q ⊕ R)

Solving this will set you on your way, give you a bit of confidence, and
hopefully prompt some ideas for solving the full problem.


   - Finally, seek the generalisation: (random-expression n). How will you
   use recursion to generate more complex structures, and keep count of the
   number of operations?


Dan

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] recursive definition of a PROPOSITION

2016-02-17 Thread Aysenur Türk
(define( app L1 L2)
  (if(empty? L1) L2
 (cons (car L1) (app(cdr L1)L2

(app ((list "↔" "→" "∧" "⊕" "∨" "¬")) (list "P" "Q" "R" "S" "U" "X" "Y" "Z"))

(define L (list "↔" "→" "∧" "⊕" "∨" "¬"))
(define ( f L n)
  (if (= n 0) "p"
  (string-append "p" (car L) (f(cdr L) (- n 1)

(f L 3)

You have the following recursive definition of a PROPOSITION:

T, F are propositions ( truth value of propositional variables) List item 
Propositional letters P, Q , R, S,U,X, Y, Z   are propositions. If A is a 
proposition the ¬A is a proposition. If A and B are propositions then A⊕B , A→B 
, A∧B, A∨B , A↔B are propositions. Write a DrRacket procedure that will 
randomly generate a proposition with a given number of operations .

2 formulas calculated by your program (the formulas must contain 3 different 
variables and 6 operatıons .

Hi everyon I'm new here.Can anyone help me for this problem ? I tried the solve 
it but it's probably wrong I didn't understand clearly because I'm a new in 
racket programming language.Thanks in advance for your answers !!

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.