# =====================================================================================
# ACT harbor alarm bit — interoperability of information media
#
# Concrete topic from "The Science of Can and Can't":
# the same abstract bit can be carried by unlike physical substrates when the
# relevant information tasks are possible. Constructor theory expresses that in
# terms of tasks such as permutation, copying, and cloning.
#
# This example therefore has both sides:
#   - CAN   : a classical alarm bit can be permuted and copied between unlike media
#   - CAN'T : a superinformation token cannot have all of its states universally cloned
# =====================================================================================

@prefix : <http://example.org/alarm-bit/> .
@prefix arc: <https://example.org/arc#> .
@prefix log: <http://www.w3.org/2000/10/swap/log#> .

:case a arc:Case ;
  arc:question "Can the harbor alarm bit be copied between an optical beacon and a relay register, and what exactly can't be done for a quantum-like token?" .

# --------------------------------------------------------
# Classical substrates carrying the same abstract variable
# --------------------------------------------------------

:opticalBeacon a :InformationMedium ;
  :encodes :AlarmBit ;
  :zeroState :BlueLamp ;
  :oneState :RedLamp .

:relayRegister a :InformationMedium ;
  :encodes :AlarmBit ;
  :zeroState :LowVoltage ;
  :oneState :HighVoltage .

# ------------------------------------------------------
# Contrast substrate with superinformation-like behavior
# ------------------------------------------------------

:quantumToken a :SuperinformationMedium ;
  :encodes :PolarizationVariable ;
  :state :Horizontal ;
  :state :Vertical ;
  :state :Diagonal ;
  :state :AntiDiagonal .

# -------------------------------------------------------
# CAN rules — what becomes possible for information media
# -------------------------------------------------------

# Any information medium supports a local permutation of its designated variable.
{ ?M a :InformationMedium ;
     :encodes ?V ;
     :zeroState ?Z ;
     :oneState ?O . }
=>
{ ?M :can :LocalPermutation .
  [ a :PossibleTask ;
    :taskType :Permute ;
    :on ?M ;
    :variable ?V ;
    :fromState ?Z ;
    :toState ?O ] . } .

# Two unlike information media that encode the same variable can interoperate.
{ ?A a :InformationMedium ; :encodes ?V .
  ?B a :InformationMedium ; :encodes ?V . }
=>
{ ?A :can :InteroperateForVariable .
  ?B :can :InteroperateForVariable .
  [ a :PossibleTask ;
    :taskType :Copy ;
    :from ?A ;
    :to ?B ;
    :variable ?V ] . } .

# ------------------------------------------------------------------
# CAN'T rules — what becomes impossible for a superinformation token
# ------------------------------------------------------------------

# A superinformation medium cannot have all of its states universally cloned.
{ ?M a :SuperinformationMedium ; :encodes ?V . }
=>
{ ?M :cannot :UniversalClone .
  [ a :ImpossibleTask ;
    :taskType :CloneAllStates ;
    :on ?M ;
    :variable ?V ] . } .

# If universal cloning is unavailable, unrestricted classical-style fan-out of
# the entire state space is unavailable too.
{ ?M :cannot :UniversalClone . }
=>
{ ?M :cannot :UnrestrictedStateFanOut . } .

# ------
# Checks
# ------

# Positive checks for the classical alarm bit.
{ :opticalBeacon a :InformationMedium . }
=> { :case :checkC1 :Passed . } .

{ :relayRegister a :InformationMedium . }
=> { :case :checkC2 :Passed . } .

{ :opticalBeacon :encodes :AlarmBit .
  :relayRegister :encodes :AlarmBit . }
=> { :case :checkC3 :Passed . } .

{ ?T a :PossibleTask ;
     :taskType :Copy ;
     :from :opticalBeacon ;
     :to :relayRegister ;
     :variable :AlarmBit . }
=> { :case :checkC4 :Passed . } .

{ ?T a :PossibleTask ;
     :taskType :Copy ;
     :from :relayRegister ;
     :to :opticalBeacon ;
     :variable :AlarmBit . }
=> { :case :checkC5 :Passed . } .

{ :opticalBeacon :can :LocalPermutation . }
=> { :case :checkC6 :Passed . } .

{ :relayRegister :can :LocalPermutation . }
=> { :case :checkC7 :Passed . } .

# Negative checks for the superinformation token.
{ ?T a :ImpossibleTask ;
     :taskType :CloneAllStates ;
     :on :quantumToken ;
     :variable :PolarizationVariable . }
=> { :case :checkC8 :Passed . } .

{ :quantumToken :cannot :UniversalClone . }
=> { :case :checkC9 :Passed . } .

{ :quantumToken :cannot :UnrestrictedStateFanOut . }
=> { :case :checkC10 :Passed . } .

# ----------------
# ARC-style output
# ----------------

{ :case :checkC1 :Passed .
  :case :checkC2 :Passed .
  :case :checkC3 :Passed .
  :case :checkC4 :Passed .
  :case :checkC5 :Passed .
  :case :checkC6 :Passed .
  :case :checkC7 :Passed .
  :case :checkC8 :Passed .
  :case :checkC9 :Passed .
  :case :checkC10 :Passed . }
=>
{
  :out log:outputString """ACT harbor alarm bit interoperability

Answer
YES for the classical alarm bit.
NO for universal cloning and unrestricted fan-out of the quantum-like token.

Reason Why
The alarm state is modeled as an abstract bit carried by two unlike classical substrates. Because both the optical beacon and the relay register are information media for the same variable, local permutation and copying in both directions are possible. By contrast, the quantum-like token is treated as a superinformation medium, so universal cloning of all of its states is impossible, and unrestricted classical-style fan-out is blocked as well.

Check
C1  OK - the optical beacon is an information medium
C2  OK - the relay register is an information medium
C3  OK - both substrates encode the same abstract variable: AlarmBit
C4  OK - AlarmBit can be copied from optical beacon to relay register
C5  OK - AlarmBit can be copied from relay register to optical beacon
C6  OK - local permutation of AlarmBit is possible on the optical beacon
C7  OK - local permutation of AlarmBit is possible on the relay register
C8  OK - cloning all states of the quantum token is an impossible task
C9  OK - the quantum token cannot be universally cloned
C10 OK - the quantum token cannot support unrestricted classical-style fan-out
""" .
} .
