Advertisement
chemoelectric

eprb_simulation.adb

Aug 25th, 2023
2,949
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ada 38.32 KB | Source Code | 0 0
  1. --********************************************************************
  2. -- This is free and unencumbered software released into the public domain.
  3.  
  4. -- Anyone is free to copy, modify, publish, use, compile, sell, or
  5. -- distribute this software, either in source code form or as a compiled
  6. -- binary, for any purpose, commercial or non-commercial, and by any
  7. -- means.
  8.  
  9. -- In jurisdictions that recognize copyright laws, the author or authors
  10. -- of this software dedicate any and all copyright interest in the
  11. -- software to the public domain. We make this dedication for the benefit
  12. -- of the public at large and to the detriment of our heirs and
  13. -- successors. We intend this dedication to be an overt act of
  14. -- relinquishment in perpetuity of all present and future rights to this
  15. -- software under copyright law.
  16.  
  17. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  18. -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19. -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  20. -- IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  21. -- OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  22. -- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  23. -- OTHER DEALINGS IN THE SOFTWARE.
  24.  
  25. -- For more information, please refer to <https://unlicense.org>
  26. ----------------------------------------------------------------------
  27.  
  28. -- A simulation of an EPR-B experiment, demonstrating that ‘Bell’s
  29. -- theorem’, which is described in the following reference, is wrong:
  30.  
  31. -- [1] J. S. Bell, ‘Bertlmann’s socks and the nature of reality’,
  32. --     preprint, CERN-TH-2926 (1980).
  33. --     http://cds.cern.ch/record/142461/ (Open access, CC BY 4.0)
  34.  
  35. -- The simulation is written in Ada—which, if carefully used, seems to
  36. -- me a good language for conveying scientific algorithms. Also, a
  37. -- free software Ada compiler is widely available: GCC. Many readers
  38. -- can compile this program, optimized and with runtime checks, by
  39. -- saving it in a file called ‘eprb_simulation.adb’ and then running
  40. -- the command
  41.  
  42. --   gnatmake -O2 -gnata eprb_simulation
  43.  
  44. -- which will create an executable program called ‘eprb_simulation’.
  45.  
  46. -- Ada, simply put, seemed the best choice, among the programming
  47. -- languages I felt comfortable using.
  48.  
  49. -- However, if you know another language, such as Fortran, Python, or
  50. -- Common Lisp, it would be very useful for the reader’s understanding
  51. -- to translate the program from Ada into the other language.
  52.  
  53. ----------------------------------------------------------------------
  54.  
  55. pragma ada_2022;
  56. pragma wide_character_encoding (utf8);
  57.  
  58. with ada.exceptions;
  59. with ada.wide_wide_text_io;
  60. with ada.containers.ordered_sets;
  61. with ada.numerics;
  62. with ada.numerics.generic_elementary_functions;
  63.  
  64. procedure eprb_simulation is
  65.  
  66.   subtype range_1_to_2 is integer range 1 .. 2;
  67.  
  68.   type scalar is digits 15;     -- double precision
  69.   type scalar_pair is array (range_1_to_2) of scalar;
  70.  
  71.   use ada.wide_wide_text_io;
  72.   use ada.numerics;
  73.  
  74.   package scalar_elementary_functions is
  75.     new ada.numerics.generic_elementary_functions (scalar);
  76.   use scalar_elementary_functions;
  77.  
  78.   package range_1_to_2_io is new integer_io (range_1_to_2);
  79.   use range_1_to_2_io;
  80.  
  81.   package scalar_io is new float_io (scalar);
  82.   use scalar_io;
  83.  
  84.   π     : constant scalar := pi;
  85.   π_2   : constant scalar := π / 2.0;
  86.   π_3   : constant scalar := π / 3.0;
  87.   π_4   : constant scalar := π / 4.0;
  88.   π_6   : constant scalar := π / 6.0;
  89.   π_8   : constant scalar := π / 8.0;
  90.   π_180 : constant scalar := π / 180.0;
  91.   two_π : constant scalar := 2.0 * π;
  92.  
  93.   programmer_mistake : exception;
  94.  
  95.   function cos2 (x : scalar)
  96.   return scalar is
  97.   begin
  98.     return cos (x) ** 2;
  99.   end cos2;
  100.  
  101.   function sin2 (x : scalar)
  102.   return scalar is
  103.   begin
  104.     return sin (x) ** 2;
  105.   end sin2;
  106.  
  107. ----------------------------------------------------------------------
  108.  
  109.   -- For the sake of reproducibility, let us write our own random
  110.   -- number generator. It will be a simple linear congruential
  111.   -- generator. The author has used one like it, in quicksorts and
  112.   -- quickselects to select the pivot. It is good enough for our
  113.   -- purpose.
  114.  
  115.   type uint64 is mod 2 ** 64;
  116.  
  117.   -- The multiplier lcg_a comes from Steele, Guy; Vigna, Sebastiano
  118.   -- (28 September 2021). ‘Computationally easy, spectrally good
  119.   -- multipliers for congruential pseudorandom number generators’.
  120.   -- arXiv:2001.05304v3 [cs.DS]
  121.  
  122.   lcg_a : constant uint64 := 16#F1357AEA2E62A9C5#;
  123.  
  124.   -- The value of lcg_c is not critical, but should be odd.
  125.  
  126.   lcg_c : constant uint64 := 1;
  127.  
  128.   seed  : uint64 := 0;
  129.  
  130.   --
  131.   -- random_scalar: returns a non-negative scalar less than 1.
  132.   --
  133.   function random_scalar
  134.   return scalar
  135.   with post => 0.0 <= random_scalar'result
  136.                 and random_scalar'result < 1.0 is
  137.     randval : scalar;
  138.   begin
  139.     -- Take the high 48 bits of the seed and divide it by 2**48.
  140.     randval := scalar (seed / (2**16)) / scalar (2**48);
  141.  
  142.     -- Update the seed.
  143.     seed := (lcg_a * seed) + lcg_c;
  144.  
  145.     return randval;
  146.   end random_scalar;
  147.  
  148.   --
  149.   -- random_1_or_2: returns the integer 1 or the integer 2.
  150.   --
  151.   function random_1_or_2
  152.   return range_1_to_2 is
  153.   begin
  154.     return (if random_scalar < 0.5 then 1 else 2);
  155.   end random_1_or_2;
  156.  
  157. ----------------------------------------------------------------------
  158.  
  159.   -- The simulation is of a two-arm optical experiments, involving
  160.   -- sources of plane-polarized photon pairs, polarizing beam
  161.   -- splitters, and photodetectors. There will be two versions of the
  162.   -- simulation.
  163.  
  164.   -- Simulation A will be a ‘local realistic’ experiment.
  165.  
  166.   -- Simulation B will be a ‘quantum entanglement’ experiment.
  167.  
  168. ----------------------------------------------------------------------
  169.  
  170.   -- In more detail, the objects of Simulation A, the ‘local
  171.   -- realistic’ experiment, are as follows.
  172.  
  173.   -- There are light pulses that we shall call photons. These are
  174.   -- randomly generated in pairs, which are oppositely
  175.   -- plane-polarized, either horizontally or vertically. Call the
  176.   -- polarization state φ. In our simulation, a photon also has a
  177.   -- state called ρ, which is a non-negative number less than
  178.   -- one. Thus the following is our representation:
  179.  
  180.   type φ_value is (horizontal, vertical);
  181.   subtype ρ_value is scalar range 0.0 .. 1.0;
  182.  
  183.   type photon_A is
  184.     record
  185.       φ : φ_value;
  186.       ρ : ρ_value;
  187.     end record;
  188.  
  189.   -- Next after photons, there are two polarizing beam splitters (PBS)
  190.   -- (https://en.wikipedia.org/w/index.php?title=Polarizer&oldid=1152014034#Beam-splitting_polarizers).
  191.   -- These redirect photons in proportion to the Law of Malus
  192.   -- (https://en.wikipedia.org/w/index.php?title=Polarizer&oldid=1152014034#Malus's_law_and_other_properties),
  193.   -- altering the photons’ polarization angles φ. However, we will not
  194.   -- care about the new value of φ.
  195.  
  196.   type pbs_A is
  197.     record
  198.       θ : scalar;               -- The angle of beam splitting.
  199.     end record;
  200.  
  201.   -- Finally, there are four photodetectors
  202.   -- (https://en.wikipedia.org/w/index.php?title=Photodetector&oldid=1168137030).
  203.   -- These are ideal photodetectors, that detect incident photons
  204.   -- without fail. They can detect only one photon at a time, but the
  205.   -- experimental arrangement is such that they will encounter at most
  206.   -- one at a time.
  207.  
  208. ----------------------------------------------------------------------
  209.  
  210.   -- Here is a procedure that generates a (left,right) pair of photons
  211.   -- at random. The correlated polarization angles are set by a system
  212.   -- of randomly positioned polarizing filters, so angles can be
  213.   -- recorded. The two polarizing filters can be separated from each
  214.   -- other by any distance whatsoever, and there is no physical
  215.   -- influence of one filter setting upon the other. The value of ρ is
  216.   -- randomly generated separately for each photon, but not recorded.
  217.  
  218.   procedure generate_photon_A_pair (photon_left  : out photon_A;
  219.                                     photon_right : out photon_A) is
  220.   begin
  221.     if random_1_or_2 = 1 then
  222.       photon_left.φ := horizontal;
  223.       photon_right.φ := vertical;
  224.     else
  225.       photon_left.φ := vertical;
  226.       photon_right.φ := horizontal;
  227.     end if;
  228.     photon_left.ρ := random_scalar;
  229.     photon_right.ρ := random_scalar;
  230.   end generate_photon_A_pair;
  231.  
  232. ----------------------------------------------------------------------
  233.  
  234.   -- The following procedure decides which of two photodetectors will
  235.   -- detect the photon that enters a given PBS. The output of the
  236.   -- procedure is the outputs of the two photodetectors. The photon
  237.   -- will have its angle of polarization altered, but the
  238.   -- photodetectors cannot measure angle of polarization, so that
  239.   -- information is simply lost.
  240.  
  241.   procedure split_beam_A (photon    : photon_A;
  242.                           pbs       : pbs_A;
  243.                           detector1 : out boolean;
  244.                           detector2 : out boolean) is
  245.     φ : scalar;
  246.   begin
  247.  
  248.     -- The Law of Malus tells us that the the square of the cosine of
  249.     -- the angle between the plane of polarization and the plane of
  250.     -- the PBS setting gives us the probability of transmission to
  251.     -- detector1.
  252.  
  253.     -- The photon’s hidden variable ρ is used as the random value.
  254.  
  255.     φ := (if photon.φ = horizontal then 0.0 else π_2);
  256.     if photon.ρ < cos2 (φ - pbs.θ) then
  257.       detector1 := true;
  258.       detector2 := false;
  259.     else
  260.       detector1 := false;
  261.       detector2 := true;
  262.     end if;
  263.  
  264.   end split_beam_A;
  265.  
  266. ----------------------------------------------------------------------
  267.  
  268.   -- The function one_event_A, below, simulates an event of the
  269.   -- simulation: from generation of a pair of photons to their
  270.   -- measurement by four photodetectors. The settings of the two PBS
  271.   -- are included in the output. The polarization angles of the
  272.   -- photons are included, as well. The output is gathered into a
  273.   -- record and given a unique identifier (so it can be stored in set
  274.   -- objects).
  275.  
  276.   type identifier_tag is mod 2 ** 128; -- (Set to 2**64 if necessary.)
  277.   current_identifier : identifier_tag := 0;
  278.  
  279.   type event_record is
  280.     record
  281.       identifier        : identifier_tag;
  282.       θ_left, θ_right   : scalar := 0.0;
  283.       φ_left, φ_right   : φ_value := horizontal;
  284.       detector_left_1   : boolean := false;
  285.       detector_left_2   : boolean := false;
  286.       detector_right_1  : boolean := false;
  287.       detector_right_2  : boolean := false;
  288.     end record;
  289.  
  290.   function one_event_A (θ_L, θ_R : scalar)
  291.   return event_record is
  292.     ev           : event_record;
  293.     pbs_left     : pbs_A;
  294.     pbs_right    : pbs_A;
  295.     photon_left  : photon_A;
  296.     photon_right : photon_A;
  297.   begin
  298.     ev.identifier := current_identifier;
  299.     current_identifier := current_identifier + 1;
  300.  
  301.     ev.θ_left := θ_L;
  302.     pbs_left.θ := θ_L;
  303.  
  304.     ev.θ_right := θ_R;
  305.     pbs_right.θ := θ_R;
  306.  
  307.     generate_photon_A_pair (photon_left, photon_right);
  308.     ev.φ_left := photon_left.φ;
  309.     ev.φ_right := photon_right.φ;
  310.  
  311.     split_beam_A (photon_left, pbs_left,
  312.                   ev.detector_left_1, ev.detector_left_2);
  313.     split_beam_A (photon_right, pbs_right,
  314.                   ev.detector_right_1, ev.detector_right_2);
  315.  
  316.     return ev;
  317.   end one_event_A;
  318.  
  319. ----------------------------------------------------------------------
  320.  
  321.   -- We wish to simulate some number of events, and to gather the
  322.   -- output records in a set. Here is where the set type is created.
  323.  
  324.   function "<" (a, b : event_record)
  325.   return boolean is
  326.   begin
  327.     return (a.identifier < b.identifier);
  328.   end "<";
  329.  
  330.   package event_record_sets is
  331.     new ada.containers.ordered_sets (element_type => event_record);
  332.  
  333. ----------------------------------------------------------------------
  334.  
  335.   -- The following function simulates a given number of events and
  336.   -- gathers the output records into a set.
  337.  
  338.   function simulate_events_A (number_of_events : natural;
  339.                               θ_L, θ_R         : scalar)
  340.   return event_record_sets.set is
  341.     use event_record_sets;
  342.     events : set;
  343.   begin
  344.     for i in 1 .. number_of_events loop
  345.       include (events, one_event_A (θ_L, θ_R));
  346.     end loop;
  347.     return events;
  348.   end simulate_events_A;
  349.  
  350. ----------------------------------------------------------------------
  351.  
  352.   -- For Simulation B, we must totally ignore the operations of the
  353.   -- apparatus. Quantum mechanics follows Bohr’s doctrine that eschews
  354.   -- cause-and-effect, as outside the realm of interest. Instead
  355.   -- quantum mechanics simply tells us what the probabilities of
  356.   -- different measurements are for a given experimental
  357.   -- arrangement. This is all we are supposed to care about. Thus we
  358.   -- do the simulation by calculating those probabilities and then
  359.   -- rolling dice.
  360.  
  361.   -- The apparatus for Simulation B will be the same as for Simulation
  362.   -- A, and it will be operated in the same way. However, we make no
  363.   -- assumptions that photons have ρ values. Strictly speaking, we
  364.   -- also do not assume they have φ values. Rather, it is the
  365.   -- polarizing filters that have φ values. We know those values, and
  366.   -- record them in the event records.
  367.  
  368.   -- (In some experiments people have actually run, there may be
  369.   -- analogs of our φ values that are measured at the far ends of the
  370.   -- experimental arms, rather than at the light source. Perhaps
  371.   -- someone will object to Simulation B on grounds of this
  372.   -- difference. Is Bell’s argument supposed to apply only to
  373.   -- particular experimental arrangements? Or perhaps it is that
  374.   -- photon pairs that have passed through polarizing filters have
  375.   -- their ‘magic entanglement’ robbed from them? My guess is the
  376.   -- objection would be a Schrödinger’s cat of all possible
  377.   -- challenges. However, an actually curious but doubtful reader can
  378.   -- modify this program to handle the different experimental
  379.   -- arrangement. Doing so would be much more convincing than if I did
  380.   -- the modification for them.)
  381.  
  382.   -- The only other measurements in the experiment are the PBS
  383.   -- settings and the photodetector outputs. These, too, are recorded
  384.   -- in the event records.
  385.  
  386.   -- Our task now is to calculate probabilities of different event
  387.   -- records. That is what the formulas of quantum mechanics provide
  388.   -- means to do in such a situation. It is what Niels Bohr considered
  389.   -- all that physicists ought to expect of their work.
  390.  
  391.   -- But I do not know how to do the formulas of quantum mechanics. In
  392.   -- my education, we got an introduction to quantum mechanics, but
  393.   -- not one deep enough to learn the special language that is used in
  394.   -- cases such as this. Instead I will use general methods of logical
  395.   -- inference. These will solve the problem entirely, without any
  396.   -- specialty knowledge.
  397.  
  398.   -- (That may come as a surprise to some quantum physicists, who are
  399.   -- not so deep inside the circle that they cannot see what is going
  400.   -- on outside it. They may have expected it impossible to solve a
  401.   -- quantum mechanics problem without its special language and a
  402.   -- benediction.)
  403.  
  404.   -- First of all, we must disabuse ourselves of Bell’s immensely
  405.   -- ignorant assertions in [1], that it is possible to declare two
  406.   -- variables ‘statistically independent’ on grounds that one cannot
  407.   -- have a causal effect on the other. Nor can one do so on grounds
  408.   -- of vague intuitions. Bell is doing nothing less than displaying
  409.   -- to us his ignorance of the methods of scientific inference. To
  410.   -- declare ‘statistical independence’, one must do nothing less than
  411.   -- present a mathematical proof. In our case, there is no possible
  412.   -- such proof, because the two variables are indubitably correlated:
  413.   -- if one is a vertical polarization, then the other is certainly a
  414.   -- horizontal polarization, and vice versa.
  415.  
  416.   -- Thus I have already shown that Bell is wrong, and thus the entire
  417.   -- opus based on his claims is discredited. CHSH is wrong, Aspect is
  418.   -- wrong, and so on, and so on. But let us continue nonetheless.
  419.  
  420.   -- We have disabused ourselves of Bell’s assertions, and instead
  421.   -- will use the correct expressions. A scientist or engineer in
  422.   -- practically any field except quantum physics would do the same,
  423.   -- because these are general methods of logical inference.
  424.  
  425.   -- We will use notation as follows (and analogously throughout):
  426.  
  427.   --    P(hL1)    probability of horizontal left polarizing filter
  428.   --              and a detection in left channel 1
  429.   --    P(vR2)    probability of a vertical right polarizing filter
  430.   --              and a detection in right channel 2
  431.   --    P(vL2,vR1)  joint probability of vL2 and vR1
  432.   --    P(vL2|vR1)  conditional probability of vL2, given vR1
  433.  
  434.   -- Calculations will be done separately for each pair of PBS
  435.   -- settings, and thus the PBS settings need not be considered in the
  436.   -- probabilities.
  437.  
  438.   -- To do LOGICAL INFERENCE correctly, one must use MATHEMATICAL
  439.   -- THEOREMS, not physical or intuitive justifications such as Bell
  440.   -- attempts. Thus it is not legal to write something like
  441.  
  442.   --    P(hL1,hR1) = P(hL1) × P(hR1)
  443.  
  444.   -- as Bell does. It is simply not allowed. There does not exist, in
  445.   -- mathematics, any theorem one can cite to justify such a step. One
  446.   -- MUST instead write one or the other of
  447.  
  448.   --    P(hL1,hR1) = P(hL1) × P(hR1|hL1)
  449.   --    P(hL1,hR1) = P(hL1|hR1) × P(hR1)
  450.  
  451.   -- This is a form of Bayes’ theorem
  452.   -- (https://en.wikipedia.org/w/index.php?title=Bayes%27_theorem&oldid=1171865590). (See
  453.   -- my footnote on ‘Bayes’ theorem’.)
  454.  
  455.   -- Notice that the value of P(hL1,hR1) according to Bell’s incorrect
  456.   -- calculation is a positive number. On the other hand, according to
  457.   -- the correct expressions, the value is zero: it is impossible to
  458.   -- have horizontally polarized filters simultaneously on both sides,
  459.   -- and therefore the conditional probability factors are zero.
  460.  
  461.   -- Already we see a tangible demonstration that we cannot expect to
  462.   -- get correct answers, if we reason as Bell does. Obviously there
  463.   -- is no causal effect of one polarizing filter on the other. Their
  464.   -- angles are correlated solely because they are set that way by a
  465.   -- third device, whose nature is unimportant (though it probably
  466.   -- would involve a system of shutters). Even so, we cannot write the
  467.   -- expression Bell claims we can. We MUST use Bayes’ theorem.
  468.  
  469.   -- (Here is another example of the need to use Bayes’ theorem rather
  470.   -- than arguments about causal influences—
  471.  
  472.   -- My father and I both uploaded some data about our DNAs to the
  473.   -- same ‘family tree’ service. The service confirmed that our DNAs
  474.   -- were about 50 percent similar, in whatever it was they
  475.   -- measured. I am not a molecular biologist and do not understand
  476.   -- these things. All I know is the two DNAs proved to be extremely
  477.   -- alike. Now think about that coincidence. There was this powerful
  478.   -- correlation between two samples of deoxyribonucleic acid. The
  479.   -- only connection between them is they had a common origin in one
  480.   -- organism, my father. There was no possible causal influence of
  481.   -- one sample on the other.
  482.  
  483.   -- By Bell’s reasoning, the only explanation for the DNA service’s
  484.   -- result is a spooky kind of action at a distance!
  485.  
  486.   -- Of course, in the field of genomics, such a conclusion would not
  487.   -- be publishable. If a renowned genomicist gave a lecture and came
  488.   -- to such a conclusion, it might be wise to call for
  489.   -- paramedics. However, strange beliefs may be due to indoctrination
  490.   -- rather than organic or conventional psychiatric causes, so the
  491.   -- situation in quantum theory is different.)
  492.  
  493.   -- The experiment, then, is a very simple one. The correlations may
  494.   -- be characterized thus: any conditional probability that has a ‘v’
  495.   -- on both sides of the ‘|’ must equal zero. The same is true if
  496.   -- instead of ‘v’ on both sides there is an ‘h’. Because excluding
  497.   -- the possibility of either ‘h’ or ‘v’ from one arm removes half of
  498.   -- the possible cases to choose from, the other conditional
  499.   -- probabilities must each equal twice their equivalents without the
  500.   -- condition. (That is, the denominator of the fraction is halved.)
  501.  
  502.   -- So let us write out the full set of probabilities, in the P
  503.   -- notation:
  504.  
  505.   --    P(hL1,hR1) = 0
  506.   --    P(hL1,hR2) = 0
  507.   --    P(hL2,hR1) = 0
  508.   --    P(hL2,hR2) = 0
  509.   --    P(vL1,vR1) = 0
  510.   --    P(vL1,vR2) = 0
  511.   --    P(vL2,vR1) = 0
  512.   --    P(vL2,vR2) = 0
  513.   --    P(hL1,vR1) = P(hL1) × P(vR1|hL1) = P(hL1) × (2 × P(vR1))
  514.   --    P(hL1,vR2) = P(hL1) × P(vR2|hL1) = P(hL1) × (2 × P(vR2))
  515.   --    P(hL2,vR1) = P(hL2) × P(vR1|hL2) = P(hL2) × (2 × P(vR1))
  516.   --    P(hL2,vR2) = P(hL2) × P(vR2|hL2) = P(hL2) × (2 × P(vR2))
  517.   --    P(vL1,hR1) = P(vL1) × P(hR1|vL1) = P(vL1) × (2 × P(hR1))
  518.   --    P(vL1,hR2) = P(vL1) × P(hR2|vL1) = P(vL1) × (2 × P(hR2))
  519.   --    P(vL2,hR1) = P(vL2) × P(hR1|vL2) = P(vL2) × (2 × P(hR1))
  520.   --    P(vL2,hR2) = P(vL2) × P(hR2|vL2) = P(vL2) × (2 × P(hR2))
  521.  
  522.   -- It remains to replace the P notations with more useful
  523.   -- expressions. A PBS is still presumed to follow the cosine-squared
  524.   -- rule, as in Simulation A. Also, the probability of either
  525.   -- polarization filter setting is one half, resulting in a factor of
  526.   -- ¼ in the joint probability. (This can be proved with Bayes’
  527.   -- theorem.) Therefore:
  528.  
  529.   --    P(hL1,vR1) = 2 × P(hL1) × P(vR1) = ½ × cos²(θ_L) × sin²(θ_R)
  530.   --    P(hL1,vR2) = 2 × P(hL1) × P(vR2) = ½ × cos²(θ_L) × cos²(θ_R)
  531.   --    P(hL2,vR1) = 2 × P(hL2) × P(vR1) = ½ × sin²(θ_L) × sin²(θ_R)
  532.   --    P(hL2,vR2) = 2 × P(hL2) × P(vR1) = ½ × sin²(θ_L) × cos²(θ_R)
  533.   --    P(vL1,hR1) = 2 × P(vL1) × P(hR1) = ½ × sin²(θ_L) × cos²(θ_R)
  534.   --    P(vL1,hR2) = 2 × P(vL1) × P(hR2) = ½ × sin²(θ_L) × sin²(θ_R)
  535.   --    P(vL2,hR1) = 2 × P(vL2) × P(hR1) = ½ × cos²(θ_L) × cos²(θ_R)
  536.   --    P(vL2,hR2) = 2 × P(vL2) × P(vR1) = ½ × cos²(θ_L) × sin²(θ_R)
  537.  
  538.   -- We should expect certain symmetries:
  539.  
  540.   --    P(hL1,vR2) = P(vL2,hR1) = ½ × cos²(θ_L) × cos²(θ_R)
  541.   --    P(vL1,hR2) = P(hL2,vR1) = ½ × sin²(θ_L) × sin²(θ_R)
  542.   --    P(hL2,vR2) = P(vL1,hR1) = ½ × sin²(θ_L) × cos²(θ_R)
  543.   --    P(hL1,vR1) = P(vL2,hR2) = ½ × cos²(θ_L) × sin²(θ_R)
  544.  
  545.   -- Plugging in some numbers for θ_L and θ_R confirms that the sum of
  546.   -- these joint probabilities is one.
  547.  
  548.   -- A good test that have indeed characterized the supposed ‘quantum
  549.   -- entanglement’ will be our ability to ‘clamp’ probabilities to
  550.   -- zero, by adjusting the PBS settings. It can be deduced, from the
  551.   -- (incorrect) assumption in [1] of ‘statistical independence of a
  552.   -- and b’, that such clamping ought to be impossible without ‘action
  553.   -- at a distance’.
  554.  
  555.   -- Set θ_L=0 and θ_R=π_2. Then
  556.  
  557.   --    P(hL1,vR2) = P(vL2,hR1) = ½ × cos²(θ_L) × cos²(θ_R) = 0
  558.   --    P(vL1,hR2) = P(hL2,vR1) = ½ × sin²(θ_L) × sin²(θ_R) = 0
  559.   --    P(hL2,vR2) = P(vL1,hR1) = ½ × sin²(θ_L) × cos²(θ_R) = 0
  560.   --    P(hL1,vR1) = P(vL2,hR2) = ½ × cos²(θ_L) × sin²(θ_R) = ½
  561.  
  562.   -- Thus there is definitely the supposed ‘quantum entanglement’.
  563.  
  564.   -- The same methods could be used to solve for the probabilities of
  565.   -- the outcomes in the experiment described in the Wikipedia
  566.   -- article. No knowledge of ‘Pauli matrices’ or ‘tensor products of
  567.   -- vector spaces’ is needed. One need not know what a ‘bra-ket’ is.
  568.  
  569.   -- Here, then, is Simulation B. It is merely random generation of
  570.   -- possible event records. However, that is all one should expect of
  571.   -- a ‘simulation’ of quantum theory.
  572.  
  573.   function one_event_B (θ_L, θ_R : scalar)
  574.   return event_record is
  575.     ev        : event_record;
  576.     P_hL1_vR2 : scalar;
  577.     P_vL2_hR1 : scalar;
  578.     P_vL1_hR2 : scalar;
  579.     P_hL2_vR1 : scalar;
  580.     P_hL2_vR2 : scalar;
  581.     P_vL1_hR1 : scalar;
  582.     P_hL1_vR1 : scalar;
  583.     P_vL2_hR2 : scalar;
  584.     r1, r2    : scalar;
  585.     r3, r4    : scalar;
  586.     r5, r6    : scalar;
  587.     r7, r8    : scalar;
  588.     r         : scalar;
  589.   begin
  590.     ev.identifier := current_identifier;
  591.     current_identifier := current_identifier + 1;
  592.  
  593.     ev.θ_left := θ_L;
  594.     ev.θ_right := θ_R;
  595.  
  596.     P_hL1_vR1 := 0.5 * cos2 (θ_L) * sin2 (θ_R);
  597.     P_hL1_vR2 := 0.5 * cos2 (θ_L) * cos2 (θ_R);
  598.     P_hL2_vR1 := 0.5 * sin2 (θ_L) * sin2 (θ_R);
  599.     P_hL2_vR2 := 0.5 * sin2 (θ_L) * cos2 (θ_R);
  600.     P_vL1_hR1 := 0.5 * sin2 (θ_L) * cos2 (θ_R);
  601.     P_vL1_hR2 := 0.5 * sin2 (θ_L) * sin2 (θ_R);
  602.     P_vL2_hR1 := 0.5 * cos2 (θ_L) * cos2 (θ_R);
  603.     P_vL2_hR2 := 0.5 * cos2 (θ_L) * sin2 (θ_R);
  604.  
  605.     r1 := P_hL1_vR1;
  606.     r2 := r1 + P_hL1_vR2;
  607.     r3 := r2 + P_hL2_vR1;
  608.     r4 := r3 + P_hL2_vR2;
  609.     r5 := r4 + P_vL1_hR1;
  610.     r6 := r5 + P_vL1_hR2;
  611.     r7 := r6 + P_vL2_hR1;
  612.     r8 := r7 + P_vL2_hR2;
  613.  
  614.     -- Sanity check.
  615.     if abs (r8 - 1.0) > 50.0 * scalar'model_epsilon then
  616.       raise programmer_mistake;
  617.     end if;
  618.  
  619.     ev.detector_left_1 := false;
  620.     ev.detector_left_2 := false;
  621.     ev.detector_right_1 := false;
  622.     ev.detector_right_2 := false;
  623.  
  624.     r := random_scalar;
  625.     if r < r1 then
  626.       -- P_hL1_vR1
  627.       ev.φ_left := horizontal;
  628.       ev.detector_left_1 := true;
  629.       ev.detector_right_1 := true;
  630.     elsif r < r2 then
  631.     -- P_hL1_vR2
  632.       ev.φ_left := horizontal;
  633.       ev.detector_left_1 := true;
  634.       ev.detector_right_2 := true;
  635.     elsif r < r3 then
  636.     -- P_hL2_vR1
  637.       ev.φ_left := horizontal;
  638.       ev.detector_left_2 := true;
  639.       ev.detector_right_1 := true;
  640.     elsif r < r4 then
  641.     -- P_hL2_vR2
  642.       ev.φ_left := horizontal;
  643.       ev.detector_left_2 := true;
  644.       ev.detector_right_2 := true;
  645.     elsif r < r5 then
  646.     -- P_vL1_hR1
  647.       ev.φ_left := vertical;
  648.       ev.detector_left_1 := true;
  649.       ev.detector_right_1 := true;
  650.     elsif r < r6 then
  651.     -- P_vL1_hR2
  652.       ev.φ_left := vertical;
  653.       ev.detector_left_1 := true;
  654.       ev.detector_right_2 := true;
  655.     elsif r < r7 then
  656.     -- P_vL2_hR1
  657.       ev.φ_left := vertical;
  658.       ev.detector_left_2 := true;
  659.       ev.detector_right_1 := true;
  660.     else
  661.     -- P_vL2_hR2
  662.       ev.φ_left := vertical;
  663.       ev.detector_left_2 := true;
  664.       ev.detector_right_2 := true;
  665.     end if;
  666.  
  667.     if ev.φ_left = vertical then
  668.       ev.φ_right := horizontal;
  669.     else
  670.       ev.φ_right := vertical;
  671.     end if;
  672.  
  673.     return ev;
  674.   end one_event_B;
  675.  
  676.   function simulate_events_B (number_of_events : natural;
  677.                               θ_L, θ_R         : scalar)
  678.   return event_record_sets.set is
  679.     use event_record_sets;
  680.     events : set;
  681.   begin
  682.     for i in 1 .. number_of_events loop
  683.       include (events, one_event_B (θ_L, θ_R));
  684.     end loop;
  685.     return events;
  686.   end simulate_events_B;
  687.  
  688.   ----------------------------------------------------------------------
  689.  
  690.   -- The following function calculates the frequencies of detections
  691.   -- in a set of event records, so these frequencies can be compared
  692.   -- to the probabilities.
  693.  
  694.   type detections_array is
  695.     array (φ_value,     -- Setting of the left-side polarizing filter.
  696.            range_1_to_2, -- Which detector was activated on the left.
  697.            range_1_to_2) -- Which detector was activated on the right.
  698.            of scalar;
  699.  
  700.   function detections_frequencies (events : event_record_sets.set)
  701.   return detections_array is
  702.     use event_record_sets;
  703.  
  704.     a    : detections_array;
  705.  
  706.     procedure initialize is
  707.     begin
  708.       for i in φ_value loop
  709.         for j in range_1_to_2 loop
  710.           for k in range_1_to_2 loop
  711.             a(i, j, k) := 0.0;
  712.           end loop;
  713.         end loop;
  714.       end loop;
  715.     end initialize;
  716.  
  717.     procedure count is
  718.       curs : cursor;
  719.       ev   : event_record;
  720.  
  721.       procedure check_record is
  722.       begin
  723.         if ev.φ_left = horizontal and ev.φ_right = horizontal then
  724.           raise programmer_mistake;
  725.         end if;
  726.         if ev.φ_left = vertical and ev.φ_right = vertical then
  727.           raise programmer_mistake;
  728.         end if;
  729.         if not (ev.detector_left_1 xor ev.detector_left_2) then
  730.           raise programmer_mistake;
  731.         end if;
  732.         if not (ev.detector_right_1 xor ev.detector_right_2) then
  733.           raise programmer_mistake;
  734.         end if;
  735.       end check_record;
  736.  
  737.     begin
  738.       curs := first (events);
  739.       while has_element (curs) loop
  740.         ev := element (curs);
  741.         check_record;
  742.         if ev.detector_left_1 then
  743.           if ev.detector_right_1 then
  744.             a(ev.φ_left, 1, 1) := @ + 1.0;
  745.           else
  746.             a(ev.φ_left, 1, 2) := @ + 1.0;
  747.           end if;
  748.         else
  749.           if ev.detector_right_1 then
  750.             a(ev.φ_left, 2, 1) := @ + 1.0;
  751.           else
  752.             a(ev.φ_left, 2, 2) := @ + 1.0;
  753.           end if;
  754.         end if;
  755.         curs := next (curs);
  756.       end loop;
  757.     end count;
  758.  
  759.     procedure normalize is
  760.       n : scalar;
  761.     begin
  762.       n := scalar (length (events));
  763.       for i in φ_value loop
  764.         for j in range_1_to_2 loop
  765.           for k in range_1_to_2 loop
  766.             a(i, j, k) := a(i, j, k) / n;
  767.           end loop;
  768.         end loop;
  769.       end loop;
  770.     end normalize;
  771.  
  772.   begin
  773.     initialize;
  774.     count;
  775.     normalize;
  776.     return a;
  777.   end detections_frequencies;
  778.  
  779.   ----------------------------------------------------------------------
  780.  
  781.   -- The following function fills in a detections_array with the
  782.   -- probabilities themselves, rather than simulated frequencies.
  783.  
  784.   function detections_probabilities (θ_L, θ_R : scalar)
  785.   return detections_array is
  786.     a : detections_array;
  787.   begin
  788.     a(horizontal, 1, 1) := 0.5 * cos2 (θ_L) * sin2 (θ_R);
  789.     a(horizontal, 1, 2) := 0.5 * cos2 (θ_L) * cos2 (θ_R);
  790.     a(horizontal, 2, 1) := 0.5 * sin2 (θ_L) * sin2 (θ_R);
  791.     a(horizontal, 2, 2) := 0.5 * sin2 (θ_L) * cos2 (θ_R);
  792.     a(vertical, 1, 1) := 0.5 * sin2 (θ_L) * cos2 (θ_R);
  793.     a(vertical, 1, 2) := 0.5 * sin2 (θ_L) * sin2 (θ_R);
  794.     a(vertical, 2, 1) := 0.5 * cos2 (θ_L) * cos2 (θ_R);
  795.     a(vertical, 2, 2) := 0.5 * cos2 (θ_L) * sin2 (θ_R);
  796.     return a;
  797.   end detections_probabilities;
  798.  
  799.   ----------------------------------------------------------------------
  800.  
  801. begin
  802.  
  803.   -- The main program.
  804.  
  805.   declare
  806.     number_of_events   : natural;
  807.     θ_L, θ_R           : scalar;
  808.     events_A, events_B : event_record_sets.set;
  809.     probabilities      : detections_array;
  810.     frequencies_A      : detections_array;
  811.     frequencies_B      : detections_array;
  812.     φ                  : φ_value;
  813.     i, j               : range_1_to_2;
  814.   begin
  815.     seed := 1234;
  816.     number_of_events := 1000000;
  817.  
  818.     for i in 1 .. 4 loop
  819.       if i = 1 then
  820.         θ_L := π / 4.0;
  821.         θ_R := 2.0 * π / 3.0;
  822.       else
  823.         θ_L := π_2 * random_scalar;
  824.         θ_R := π_2 * random_scalar;
  825.       end if;
  826.  
  827.       events_A := simulate_events_A (number_of_events, θ_L, θ_R);
  828.       events_B := simulate_events_B (number_of_events, θ_L, θ_R);
  829.  
  830.       probabilities := detections_probabilities (θ_L, θ_R);
  831.       frequencies_A := detections_frequencies (events_A);
  832.       frequencies_B := detections_frequencies (events_B);
  833.  
  834.       new_line;
  835.  
  836.       set_col (2);
  837.       put ("PBS left  θ");
  838.       set_col (15);
  839.       put (θ_L / π_180, 3, 5, 0);
  840.       new_line;
  841.  
  842.       set_col (2);
  843.       put ("PBS right θ");
  844.       set_col (15);
  845.       put (θ_R / π_180, 3, 5, 0);
  846.       new_line;
  847.  
  848.       set_col (5);
  849.       put ("φ");
  850.  
  851.       set_col (10);
  852.       put ("detec L");
  853.  
  854.       set_col (20);
  855.       put ("detec R");
  856.  
  857.       set_col (30);
  858.       put ("probability");
  859.  
  860.       set_col (44);
  861.       put ("freq classical");
  862.  
  863.       set_col (60);
  864.       put ("freq quantum");
  865.  
  866.       for φ in φ_value loop
  867.         for i in range_1_to_2 loop
  868.           for j in range_1_to_2 loop
  869.  
  870.             set_col (4);
  871.             if φ in horizontal then
  872.               put ("H/V");
  873.             else
  874.               put ("V/H");
  875.             end if;
  876.  
  877.             set_col (13);
  878.             put (i, 1);
  879.  
  880.             set_col (23);
  881.             put (j, 1);
  882.  
  883.             set_col (30);
  884.             put (probabilities(φ, i, j), 3, 5, 0);
  885.  
  886.             set_col (45);
  887.             put (frequencies_A(φ, i, j), 3, 5, 0);
  888.  
  889.             set_col (60);
  890.             put (frequencies_B(φ, i, j), 3, 5, 0);
  891.  
  892.           end loop;
  893.         end loop;
  894.       end loop;
  895.  
  896.       new_line;
  897.  
  898.     end loop;
  899.  
  900.     new_line;
  901.   end;
  902.  
  903. end eprb_simulation;
  904.  
  905. ----------------------------------------------------------------------
  906.  
  907. -- The output of the program should look something like the following,
  908. -- demonstrating that both the classical and quantum simulations
  909. -- approximate the quantum predictions.
  910.  
  911.  
  912. --  PBS left  θ   45.00000
  913. --  PBS right θ  120.00000
  914. --     φ    detec L   detec R   probability   freq classical  freq quantum
  915. --    H/V      1         1        0.18750        0.18709        0.18705
  916. --    H/V      1         2        0.06250        0.06252        0.06234
  917. --    H/V      2         1        0.18750        0.18646        0.18788
  918. --    H/V      2         2        0.06250        0.06223        0.06256
  919. --    V/H      1         1        0.06250        0.06263        0.06275
  920. --    V/H      1         2        0.18750        0.18838        0.18733
  921. --    V/H      2         1        0.06250        0.06258        0.06256
  922. --    V/H      2         2        0.18750        0.18809        0.18752
  923.  
  924. --  PBS left  θ   35.40353
  925. --  PBS right θ   58.09312
  926. --     φ    detec L   detec R   probability   freq classical  freq quantum
  927. --    H/V      1         1        0.23939        0.23912        0.23933
  928. --    H/V      1         2        0.09280        0.09297        0.09271
  929. --    H/V      2         1        0.12093        0.12105        0.12094
  930. --    H/V      2         2        0.04688        0.04711        0.04710
  931. --    V/H      1         1        0.04688        0.04661        0.04698
  932. --    V/H      1         2        0.12093        0.12076        0.12101
  933. --    V/H      2         1        0.09280        0.09265        0.09259
  934. --    V/H      2         2        0.23939        0.23973        0.23933
  935.  
  936. --  PBS left  θ   25.34591
  937. --  PBS right θ   89.05482
  938. --     φ    detec L   detec R   probability   freq classical  freq quantum
  939. --    H/V      1         1        0.40826        0.40835        0.40873
  940. --    H/V      1         2        0.00011        0.00011        0.00010
  941. --    H/V      2         1        0.09160        0.09127        0.09122
  942. --    H/V      2         2        0.00002        0.00003        0.00002
  943. --    V/H      1         1        0.00002        0.00002        0.00002
  944. --    V/H      1         2        0.09160        0.09147        0.09224
  945. --    V/H      2         1        0.00011        0.00011        0.00010
  946. --    V/H      2         2        0.40826        0.40864        0.40758
  947.  
  948. --  PBS left  θ   75.33916
  949. --  PBS right θ   76.26485
  950. --     φ    detec L   detec R   probability   freq classical  freq quantum
  951. --    H/V      1         1        0.03022        0.03033        0.03039
  952. --    H/V      1         2        0.00181        0.00183        0.00181
  953. --    H/V      2         1        0.44159        0.44165        0.44100
  954. --    H/V      2         2        0.02638        0.02656        0.02618
  955. --    V/H      1         1        0.02638        0.02653        0.02636
  956. --    V/H      1         2        0.44159        0.44117        0.44220
  957. --    V/H      2         1        0.00181        0.00178        0.00180
  958. --    V/H      2         2        0.03022        0.03015        0.03026
  959.  
  960. ----------------------------------------------------------------------
  961.  
  962. -- Afterword:
  963.  
  964. -- Of course, Simulation A also is soluble in closed form by
  965. -- probability theory. And you will find that its closed form solution
  966. -- is exactly the same as that of Simulation B. As, of course, it must
  967. -- be.
  968.  
  969. -- The problem with ‘Bell’s theorem’ is that Bell obviously did not
  970. -- know any probability theory. He only pretended to know
  971. -- probability theory, and then he solved our Simulation A, and
  972. -- every problem in its class, incorrectly. He did not know how to
  973. -- do scientific inference, and he found an audience that also did
  974. -- not know how to do it.
  975.  
  976. -- Perhaps it is the case to this day that quantum physicists do not
  977. -- realize ‘quantum’ problems can be solved without quantum
  978. -- theory. They believe in the magic of their incantations. In any
  979. -- case, methods of scientific inference are not taught to quantum
  980. -- physics students. What can be solved by scientific inference
  981. -- probably involves cause and effect by contact action, not
  982. -- ‘entanglement’ and ‘non-locality’. Restricting the teaching to the
  983. -- special incantations of quantum theory, and to the set of magic
  984. -- doctrines that accompany the incantations, neatly does its
  985. -- work. The students come out of their lessons believing in magic and
  986. -- telling the public that it is ‘science’.
  987.  
  988. ----------------------------------------------------------------------
  989.  
  990. -- A footnote on ‘Bayes’ theorem’:
  991.  
  992. -- We should ignore all the stuff on the ‘Bayes’ theorem’ Wikipedia
  993. -- page about ‘Interpretations’. Such disputes are a topic separate
  994. -- from what we are dealing with here. What matters to us is that
  995. -- probability theory done properly is FORMAL, not merely a batch of
  996. -- intuitions.
  997.  
  998. -- By far most specialists in mathematics regard probability theory as
  999. -- a subset of ‘measure theory’, which is a kind of generalization of
  1000. -- the notion of areas. Problems concerning various sets of interest
  1001. -- to mathematicians tend to be discussed.
  1002.  
  1003. -- Alternatively, probability theory can be built up as a very
  1004. -- carefully devised generalization of boolean logic, specifically
  1005. -- designed for the task of logical inference. This form of
  1006. -- probability theory is probably more useful to empirical scientists
  1007. -- and engineers than is the other.
  1008.  
  1009. -- Either form of probability works for us, because in either form of
  1010. -- probability theory the theorems that we use are the same.
  1011.  
  1012. --********************************************************************
  1013. -- Some instructions for the Emacs text editor.
  1014. -- local variables:
  1015. -- mode: indented-text
  1016. -- tab-width: 2
  1017. -- end:
  1018.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement