Advertisement
logicmoo

Untitled

Aug 23rd, 2018
525
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 1.81 KB | None | 0 0
  1. [23:49] <logicmoo> https://en.wikipedia.org/wiki/NOR_logic#AND
  2. [23:50] <logicmoo> that daigram shows how to set up the I/Os
  3. [23:51] <logicmoo> https://en.wikipedia.org/wiki/NOR_logic#XOR  shows you the one liner for XOR
  4. [23:54] <Defenestrate> im still having trouble working out how: [ ( A NOR A ) NOR ( B NOR B ) ] NOR
  5. [23:54] <Defenestrate> ( A NOR B ) mapped to your solution in prolog
  6. [23:56] <logicmoo> dont use the text use the picture
  7. [23:56] <Defenestrate> ok
  8. [23:56] <logicmoo> see this picure    https://en.wikipedia.org/wiki/NOR_logic#/media/File:XOR_from_NOR.svg
  9. [23:56] <logicmoo> imagine those are wires..
  10. [23:57] <logicmoo> xor(A,B,Q):- nor(A,A,NotA), nor(B,B,NotB), nor(NotA,NotB,NotNorAB),nor(A,B,NorAB), nor(NotNorAB,NorAB,Q).  
  11. [23:58] <logicmoo> label each wire a prolog varaible
  12. [23:59] <logicmoo> inside each gate write the  nor(Wire1In,Wire2In,WireOut)
  13. [00:00] <logicmoo> so if you look at https://en.wikipedia.org/wiki/NOR_logic#/media/File:AND_from_NOR.svg
  14. [00:01] <logicmoo> and(A,B,Q):- nor(A,A,NotA), nor(B,B,NotB), ... What Goes Here?.
  15. [00:02] <Defenestrate> nor(notA,notB,Q) ?
  16. [00:02] <Defenestrate> is that right?
  17. [00:02] <logicmoo> perfect!
  18. [00:02] <Defenestrate> yay :))
  19. [00:03] <Defenestrate> but now that i have this rule: and(A,B,Q):- nor(A,A,NotA), nor(B,B,NotB), nor(notA, notB, Q).
  20. [00:03] <logicmoo> well closer to:  nor(NotA,NotB,Q)    :)   vars need captialized
  21. [00:03] <Defenestrate> ah yes ofc
  22. [00:03] <Defenestrate> but would that work in prolog?
  23. [00:03] <logicmoo> yes
  24. [00:03] <Defenestrate> ok let me try
  25. [00:03] <Defenestrate> thank you so much, you're amazing at explaining
  26. [00:05] <Defenestrate> oh wow it works, thats amazing.
  27. [00:05] <logicmoo> i had not ever thought of this method before.. using the diagrams from that wiki page
  28. [00:05] <Defenestrate> prolog is so cool
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement